diff options
1312 files changed, 40443 insertions, 44341 deletions
diff --git a/.editorconfig b/.editorconfig index 7743622e78..92ee947a82 100644 --- a/.editorconfig +++ b/.editorconfig @@ -13,7 +13,7 @@ trim_trailing_whitespace = true indent_style = space indent_size = 4 -[{*.{py,cs},SConstruct,SCsub}] +[{*.py,SConstruct,SCsub}] indent_style = space indent_size = 4 @@ -21,7 +21,3 @@ indent_size = 4 [*.{yml,yaml}] indent_style = space indent_size = 2 - -[*.{csproj,props,targets,nuspec}] -indent_style = space -indent_size = 2 diff --git a/.github/workflows/javascript_builds.disabled b/.github/workflows/javascript_builds.yml index 006981f3d4..ced2c36a91 100644 --- a/.github/workflows/javascript_builds.disabled +++ b/.github/workflows/javascript_builds.yml @@ -4,9 +4,9 @@ on: [push, pull_request] # Global Settings env: GODOT_BASE_BRANCH: master - SCONSFLAGS: platform=javascript verbose=yes warnings=extra werror=yes debug_symbols=no --jobs=2 + SCONSFLAGS: platform=javascript verbose=yes warnings=extra debug_symbols=no --jobs=2 SCONS_CACHE_LIMIT: 4096 - EM_VERSION: 1.39.20 + EM_VERSION: 2.0.25 EM_CACHE_FOLDER: 'emsdk-cache' jobs: @@ -62,7 +62,7 @@ jobs: scons --version - name: Set up Emscripten latest - uses: mymindstorm/setup-emsdk@v6 + uses: mymindstorm/setup-emsdk@v10 with: version: ${{env.EM_VERSION}} actions-cache-folder: ${{env.EM_CACHE_FOLDER}} diff --git a/.github/workflows/linux_builds.yml b/.github/workflows/linux_builds.yml index ace1ce3fec..679362d749 100644 --- a/.github/workflows/linux_builds.yml +++ b/.github/workflows/linux_builds.yml @@ -70,12 +70,12 @@ jobs: run: | ./bin/godot.linuxbsd.opt.tools.64 --test - # Download, unzip and setup SwiftShader library [d4550ab8d3f] + # Download, unzip and setup SwiftShader library [4466040] - name: Download SwiftShader run: | - wget https://github.com/qarmin/gtk_library_store/releases/download/3.24.0/swiftshader.zip - unzip swiftshader.zip - rm swiftshader.zip + wget https://github.com/qarmin/gtk_library_store/releases/download/3.24.0/swiftshader2.zip + unzip swiftshader2.zip + rm swiftshader2.zip curr="$(pwd)/libvk_swiftshader.so" sed -i "s|PATH_TO_CHANGE|$curr|" vk_swiftshader_icd.json @@ -85,7 +85,7 @@ jobs: echo "Running --doctool to see if this changes the public API without updating the documentation." echo -e "If a diff is shown, it means that your code/doc changes are incomplete and you should update the class reference with --doctool.\n\n" VK_ICD_FILENAMES=$(pwd)/vk_swiftshader_icd.json DRI_PRIME=0 xvfb-run bin/godot.linuxbsd.opt.tools.64 --doctool . 2>&1 > /dev/null || true - git diff --color --exit-code + git diff --color --exit-code && ! git ls-files --others --exclude-standard | sed -e 's/^/New doc file missing in PR: /' | grep 'xml$' - uses: actions/upload-artifact@v2 with: @@ -144,12 +144,10 @@ jobs: scons --version # We should always be explicit with our flags usage here since it's gonna be sure to always set those flags - # [Workaround] SwiftShader doesn't support tessellation, so we skip Godot check about it - name: Compilation env: SCONS_CACHE: ${{github.workspace}}/.scons_cache/ run: | - sed -i "s|ERR_FAIL_COND_V(p_rasterization_state.patch_control_points|//ERR_FAIL_COND_V(p_rasterization_state.patch_control_points|" drivers/vulkan/rendering_device_vulkan.cpp scons tools=yes tests=yes target=debug debug_symbols=no use_asan=yes use_ubsan=yes ls -l bin/ @@ -158,12 +156,12 @@ jobs: run: | ./bin/godot.linuxbsd.tools.64s --test - # Download, unzip and setup SwiftShader library [d4550ab8d3f] + # Download, unzip and setup SwiftShader library [4466040] - name: Download SwiftShader run: | - wget https://github.com/qarmin/gtk_library_store/releases/download/3.24.0/swiftshader.zip - unzip swiftshader.zip - rm swiftshader.zip + wget https://github.com/qarmin/gtk_library_store/releases/download/3.24.0/swiftshader2.zip + unzip swiftshader2.zip + rm swiftshader2.zip curr="$(pwd)/libvk_swiftshader.so" sed -i "s|PATH_TO_CHANGE|$curr|" vk_swiftshader_icd.json diff --git a/SConstruct b/SConstruct index 601b2d6e80..5dec3f2020 100644 --- a/SConstruct +++ b/SConstruct @@ -759,7 +759,7 @@ if "env" in locals(): def print_elapsed_time(): elapsed_time_sec = round(time.time() - time_at_start, 3) time_ms = round((elapsed_time_sec % 1) * 1000) - print(f"[Time elapsed: {time.strftime('%H:%M:%S', time.gmtime(elapsed_time_sec))}.{time_ms:03}]") + print("[Time elapsed: {}.{:03}]".format(time.strftime("%H:%M:%S", time.gmtime(elapsed_time_sec)), time_ms)) atexit.register(print_elapsed_time) diff --git a/core/config/engine.cpp b/core/config/engine.cpp index ad31966a65..0b5b5627af 100644 --- a/core/config/engine.cpp +++ b/core/config/engine.cpp @@ -214,8 +214,8 @@ bool Engine::has_singleton(const String &p_name) const { } void Engine::get_singletons(List<Singleton> *p_singletons) { - for (List<Singleton>::Element *E = singletons.front(); E; E = E->next()) { - p_singletons->push_back(E->get()); + for (const Singleton &E : singletons) { + p_singletons->push_back(E); } } diff --git a/core/config/project_settings.cpp b/core/config/project_settings.cpp index ac4e0db5b7..c5e6c6d685 100644 --- a/core/config/project_settings.cpp +++ b/core/config/project_settings.cpp @@ -30,7 +30,7 @@ #include "project_settings.h" -#include "core/core_bind.h" +#include "core/core_bind.h" // For Compression enum. #include "core/core_string_names.h" #include "core/input/input_map.h" #include "core/io/dir_access.h" @@ -42,8 +42,6 @@ #include "core/os/os.h" #include "core/variant/variant_parser.h" -#include <zlib.h> - ProjectSettings *ProjectSettings::singleton = nullptr; ProjectSettings *ProjectSettings::get_singleton() { @@ -702,9 +700,7 @@ Error ProjectSettings::_save_settings_binary(const String &p_file, const Map<Str int count = 0; for (Map<String, List<String>>::Element *E = props.front(); E; E = E->next()) { - for (List<String>::Element *F = E->get().front(); F; F = F->next()) { - count++; - } + count += E->get().size(); } if (p_custom_features != String()) { @@ -736,8 +732,7 @@ Error ProjectSettings::_save_settings_binary(const String &p_file, const Map<Str } for (Map<String, List<String>>::Element *E = props.front(); E; E = E->next()) { - for (List<String>::Element *F = E->get().front(); F; F = F->next()) { - String key = F->get(); + for (String &key : E->get()) { if (E->key() != "") { key = E->key() + "/" + key; } @@ -805,8 +800,8 @@ Error ProjectSettings::_save_settings_text(const String &p_file, const Map<Strin if (E->key() != "") { file->store_string("[" + E->key() + "]\n\n"); } - for (List<String>::Element *F = E->get().front(); F; F = F->next()) { - String key = F->get(); + for (const String &F : E->get()) { + String key = F; if (E->key() != "") { key = E->key() + "/" + key; } @@ -819,7 +814,7 @@ Error ProjectSettings::_save_settings_text(const String &p_file, const Map<Strin String vstr; VariantWriter::write_to_string(value, vstr); - file->store_string(F->get().property_name_encode() + "=" + vstr + "\n"); + file->store_string(F.property_name_encode() + "=" + vstr + "\n"); } } @@ -933,11 +928,11 @@ Vector<String> ProjectSettings::get_optimizer_presets() const { ProjectSettings::get_singleton()->get_property_list(&pi); Vector<String> names; - for (List<PropertyInfo>::Element *E = pi.front(); E; E = E->next()) { - if (!E->get().name.begins_with("optimizer_presets/")) { + for (const PropertyInfo &E : pi) { + if (!E.name.begins_with("optimizer_presets/")) { continue; } - names.push_back(E->get().name.get_slicec('/', 1)); + names.push_back(E.name.get_slicec('/', 1)); } names.sort(); diff --git a/core/core_bind.cpp b/core/core_bind.cpp index 9a58528bd7..9e96d4b079 100644 --- a/core/core_bind.cpp +++ b/core/core_bind.cpp @@ -75,8 +75,8 @@ Vector<String> _ResourceLoader::get_recognized_extensions_for_type(const String List<String> exts; ResourceLoader::get_recognized_extensions_for_type(p_type, &exts); Vector<String> ret; - for (List<String>::Element *E = exts.front(); E; E = E->next()) { - ret.push_back(E->get()); + for (const String &E : exts) { + ret.push_back(E); } return ret; @@ -91,8 +91,8 @@ PackedStringArray _ResourceLoader::get_dependencies(const String &p_path) { ResourceLoader::get_dependencies(p_path, &deps); PackedStringArray ret; - for (List<String>::Element *E = deps.front(); E; E = E->next()) { - ret.push_back(E->get()); + for (const String &E : deps) { + ret.push_back(E); } return ret; @@ -141,8 +141,8 @@ Vector<String> _ResourceSaver::get_recognized_extensions(const RES &p_resource) List<String> exts; ResourceSaver::get_recognized_extensions(p_resource, &exts); Vector<String> ret; - for (List<String>::Element *E = exts.front(); E; E = E->next()) { - ret.push_back(E->get()); + for (const String &E : exts) { + ret.push_back(E); } return ret; } @@ -196,6 +196,10 @@ int _OS::get_low_processor_usage_mode_sleep_usec() const { return OS::get_singleton()->get_low_processor_usage_mode_sleep_usec(); } +void _OS::alert(const String &p_alert, const String &p_title) { + OS::get_singleton()->alert(p_alert, p_title); +} + String _OS::get_executable_path() const { return OS::get_singleton()->get_executable_path(); } @@ -264,8 +268,8 @@ String _OS::get_name() const { Vector<String> _OS::get_cmdline_args() { List<String> cmdline = OS::get_singleton()->get_cmdline_args(); Vector<String> cmdlinev; - for (List<String>::Element *E = cmdline.front(); E; E = E->next()) { - cmdlinev.push_back(E->get()); + for (const String &E : cmdline) { + cmdlinev.push_back(E); } return cmdlinev; @@ -351,20 +355,20 @@ void _OS::print_all_textures_by_size() { List<Ref<Resource>> rsrc; ResourceCache::get_cached_resources(&rsrc); - for (List<Ref<Resource>>::Element *E = rsrc.front(); E; E = E->next()) { - if (!E->get()->is_class("ImageTexture")) { + for (Ref<Resource> &res : rsrc) { + if (!res->is_class("ImageTexture")) { continue; } - Size2 size = E->get()->call("get_size"); - int fmt = E->get()->call("get_format"); + Size2 size = res->call("get_size"); + int fmt = res->call("get_format"); _OSCoreBindImg img; img.size = size; img.fmt = fmt; - img.path = E->get()->get_path(); + img.path = res->get_path(); img.vram = Image::get_image_data_size(img.size.width, img.size.height, Image::Format(img.fmt)); - img.id = E->get()->get_instance_id(); + img.id = res->get_instance_id(); total += img.vram; imgs.push_back(img); } @@ -372,8 +376,8 @@ void _OS::print_all_textures_by_size() { imgs.sort(); - for (List<_OSCoreBindImg>::Element *E = imgs.front(); E; E = E->next()) { - total -= E->get().vram; + for (_OSCoreBindImg &E : imgs) { + total -= E.vram; } } @@ -383,9 +387,7 @@ void _OS::print_resources_by_type(const Vector<String> &p_types) { List<Ref<Resource>> resources; ResourceCache::get_cached_resources(&resources); - for (List<Ref<Resource>>::Element *E = resources.front(); E; E = E->next()) { - Ref<Resource> r = E->get(); - + for (const Ref<Resource> &r : resources) { bool found = false; for (int i = 0; i < p_types.size(); i++) { @@ -487,6 +489,8 @@ void _OS::_bind_methods() { ClassDB::bind_method(D_METHOD("open_midi_inputs"), &_OS::open_midi_inputs); ClassDB::bind_method(D_METHOD("close_midi_inputs"), &_OS::close_midi_inputs); + ClassDB::bind_method(D_METHOD("alert", "text", "title"), &_OS::alert, DEFVAL("Alert!")); + ClassDB::bind_method(D_METHOD("set_low_processor_usage_mode", "enable"), &_OS::set_low_processor_usage_mode); ClassDB::bind_method(D_METHOD("is_in_low_processor_usage_mode"), &_OS::is_in_low_processor_usage_mode); @@ -1818,8 +1822,8 @@ PackedStringArray _ClassDB::get_class_list() const { PackedStringArray ret; ret.resize(classes.size()); int idx = 0; - for (List<StringName>::Element *E = classes.front(); E; E = E->next()) { - ret.set(idx++, E->get()); + for (const StringName &E : classes) { + ret.set(idx++, E); } return ret; @@ -1832,8 +1836,8 @@ PackedStringArray _ClassDB::get_inheriters_from_class(const StringName &p_class) PackedStringArray ret; ret.resize(classes.size()); int idx = 0; - for (List<StringName>::Element *E = classes.front(); E; E = E->next()) { - ret.set(idx++, E->get()); + for (const StringName &E : classes) { + ret.set(idx++, E); } return ret; @@ -1887,8 +1891,8 @@ Array _ClassDB::get_signal_list(StringName p_class, bool p_no_inheritance) const ClassDB::get_signal_list(p_class, &signals, p_no_inheritance); Array ret; - for (List<MethodInfo>::Element *E = signals.front(); E; E = E->next()) { - ret.push_back(E->get().operator Dictionary()); + for (const MethodInfo &E : signals) { + ret.push_back(E.operator Dictionary()); } return ret; @@ -1898,8 +1902,8 @@ Array _ClassDB::get_property_list(StringName p_class, bool p_no_inheritance) con List<PropertyInfo> plist; ClassDB::get_property_list(p_class, &plist, p_no_inheritance); Array ret; - for (List<PropertyInfo>::Element *E = plist.front(); E; E = E->next()) { - ret.push_back(E->get().operator Dictionary()); + for (const PropertyInfo &E : plist) { + ret.push_back(E.operator Dictionary()); } return ret; @@ -1931,12 +1935,12 @@ Array _ClassDB::get_method_list(StringName p_class, bool p_no_inheritance) const ClassDB::get_method_list(p_class, &methods, p_no_inheritance); Array ret; - for (List<MethodInfo>::Element *E = methods.front(); E; E = E->next()) { + for (const MethodInfo &E : methods) { #ifdef DEBUG_METHODS_ENABLED - ret.push_back(E->get().operator Dictionary()); + ret.push_back(E.operator Dictionary()); #else Dictionary dict; - dict["name"] = E->get().name; + dict["name"] = E.name; ret.push_back(dict); #endif } @@ -1951,8 +1955,8 @@ PackedStringArray _ClassDB::get_integer_constant_list(const StringName &p_class, PackedStringArray ret; ret.resize(constants.size()); int idx = 0; - for (List<String>::Element *E = constants.front(); E; E = E->next()) { - ret.set(idx++, E->get()); + for (const String &E : constants) { + ret.set(idx++, E); } return ret; diff --git a/core/core_bind.h b/core/core_bind.h index 673dbe32c4..1574c36d3c 100644 --- a/core/core_bind.h +++ b/core/core_bind.h @@ -58,9 +58,9 @@ public: }; enum CacheMode { - CACHE_MODE_IGNORE, //resource and subresources do not use path cache, no path is set into resource. - CACHE_MODE_REUSE, //resource and subresources use patch cache, reuse existing loaded resources instead of loading from disk when available - CACHE_MODE_REPLACE, //resource and and subresource use path cache, but replace existing loaded resources when available with information from disk + CACHE_MODE_IGNORE, // Resource and subresources do not use path cache, no path is set into resource. + CACHE_MODE_REUSE, // Resource and subresources use patch cache, reuse existing loaded resources instead of loading from disk when available. + CACHE_MODE_REPLACE, // Resource and subresource use path cache, but replace existing loaded resources when available with information from disk. }; static _ResourceLoader *get_singleton() { return singleton; } @@ -162,6 +162,8 @@ public: void set_low_processor_usage_mode_sleep_usec(int p_usec); int get_low_processor_usage_mode_sleep_usec() const; + void alert(const String &p_alert, const String &p_title = "ALERT!"); + String get_executable_path() const; int execute(const String &p_path, const Vector<String> &p_arguments, Array r_output = Array(), bool p_read_stderr = false); int create_process(const String &p_path, const Vector<String> &p_arguments); diff --git a/core/debugger/debugger_marshalls.cpp b/core/debugger/debugger_marshalls.cpp index 26f82c2658..2353a6ebf8 100644 --- a/core/debugger/debugger_marshalls.cpp +++ b/core/debugger/debugger_marshalls.cpp @@ -40,11 +40,11 @@ Array DebuggerMarshalls::ResourceUsage::serialize() { Array arr; arr.push_back(infos.size() * 4); - for (List<ResourceInfo>::Element *E = infos.front(); E; E = E->next()) { - arr.push_back(E->get().path); - arr.push_back(E->get().format); - arr.push_back(E->get().type); - arr.push_back(E->get().vram); + for (const ResourceInfo &E : infos) { + arr.push_back(E.path); + arr.push_back(E.format); + arr.push_back(E.type); + arr.push_back(E.vram); } return arr; } diff --git a/core/debugger/local_debugger.cpp b/core/debugger/local_debugger.cpp index ab368471e4..24833711d5 100644 --- a/core/debugger/local_debugger.cpp +++ b/core/debugger/local_debugger.cpp @@ -320,13 +320,13 @@ void LocalDebugger::print_variables(const List<String> &names, const List<Varian String value; Vector<String> value_lines; const List<Variant>::Element *V = values.front(); - for (const List<String>::Element *E = names.front(); E; E = E->next()) { + for (const String &E : names) { value = String(V->get()); if (variable_prefix.is_empty()) { - print_line(E->get() + ": " + String(V->get())); + print_line(E + ": " + String(V->get())); } else { - print_line(E->get() + ":"); + print_line(E + ":"); value_lines = value.split("\n"); for (int i = 0; i < value_lines.size(); ++i) { print_line(variable_prefix + value_lines[i]); diff --git a/core/debugger/remote_debugger.cpp b/core/debugger/remote_debugger.cpp index bdbb7766fa..0add12ff3d 100644 --- a/core/debugger/remote_debugger.cpp +++ b/core/debugger/remote_debugger.cpp @@ -427,16 +427,16 @@ void RemoteDebugger::_send_resource_usage() { List<RS::TextureInfo> tinfo; RS::get_singleton()->texture_debug_usage(&tinfo); - for (List<RS::TextureInfo>::Element *E = tinfo.front(); E; E = E->next()) { + for (const RS::TextureInfo &E : tinfo) { DebuggerMarshalls::ResourceInfo info; - info.path = E->get().path; - info.vram = E->get().bytes; - info.id = E->get().texture; + info.path = E.path; + info.vram = E.bytes; + info.id = E.texture; info.type = "Texture"; - if (E->get().depth == 0) { - info.format = itos(E->get().width) + "x" + itos(E->get().height) + " " + Image::get_format_name(E->get().format); + if (E.depth == 0) { + info.format = itos(E.width) + "x" + itos(E.height) + " " + Image::get_format_name(E.format); } else { - info.format = itos(E->get().width) + "x" + itos(E->get().height) + "x" + itos(E->get().depth) + " " + Image::get_format_name(E->get().format); + info.format = itos(E.width) + "x" + itos(E.height) + "x" + itos(E.depth) + " " + Image::get_format_name(E.format); } usage.infos.push_back(info); } diff --git a/core/extension/extension_api_dump.cpp b/core/extension/extension_api_dump.cpp index 3c132a619d..660e215478 100644 --- a/core/extension/extension_api_dump.cpp +++ b/core/extension/extension_api_dump.cpp @@ -94,8 +94,8 @@ Dictionary NativeExtensionAPIDump::generate_extension_api() { { Variant::NODE_PATH, ptrsize_32, ptrsize_64, ptrsize_32, ptrsize_64 }, { Variant::RID, sizeof(uint64_t), sizeof(uint64_t), sizeof(uint64_t), sizeof(uint64_t) }, { Variant::OBJECT, ptrsize_32, ptrsize_64, ptrsize_32, ptrsize_64 }, - { Variant::CALLABLE, sizeof(Callable), sizeof(Callable), sizeof(Callable), sizeof(Callable) }, //harcoded align - { Variant::SIGNAL, sizeof(Signal), sizeof(Signal), sizeof(Signal), sizeof(Signal) }, //harcoded align + { Variant::CALLABLE, sizeof(Callable), sizeof(Callable), sizeof(Callable), sizeof(Callable) }, // Hardcoded align. + { Variant::SIGNAL, sizeof(Signal), sizeof(Signal), sizeof(Signal), sizeof(Signal) }, // Hardcoded align. { Variant::DICTIONARY, ptrsize_32, ptrsize_64, ptrsize_32, ptrsize_64 }, { Variant::ARRAY, ptrsize_32, ptrsize_64, ptrsize_32, ptrsize_64 }, { Variant::PACKED_BYTE_ARRAY, ptrsize_32, ptrsize_64, ptrsize_32, ptrsize_64 }, @@ -146,7 +146,7 @@ Dictionary NativeExtensionAPIDump::generate_extension_api() { } { - //member offsets sizes + // Member offsets sizes. struct { Variant::Type type; const char *member; @@ -180,7 +180,7 @@ Dictionary NativeExtensionAPIDump::generate_extension_api() { { Variant::QUATERNION, "w", 3 * sizeof(float), 3 * sizeof(float), 3 * sizeof(double), 3 * sizeof(double) }, { Variant::AABB, "position", 0, 0, 0, 0 }, { Variant::AABB, "size", vec3_elems * sizeof(float), vec3_elems * sizeof(float), vec3_elems * sizeof(double), vec3_elems * sizeof(double) }, - //rememer that basis vectors are flipped! + // Remember that basis vectors are flipped! { Variant::BASIS, "x", 0, 0, 0, 0 }, { Variant::BASIS, "y", vec3_elems * sizeof(float), vec3_elems * sizeof(float), vec3_elems * sizeof(double), vec3_elems * sizeof(double) }, { Variant::BASIS, "z", vec3_elems * 2 * sizeof(float), vec3_elems * 2 * sizeof(float), vec3_elems * 2 * sizeof(double), vec3_elems * 2 * sizeof(double) }, @@ -251,7 +251,7 @@ Dictionary NativeExtensionAPIDump::generate_extension_api() { } { - // global enums and constants + // Global enums and constants. Array constants; Map<String, List<Pair<String, int>>> enum_list; @@ -276,10 +276,10 @@ Dictionary NativeExtensionAPIDump::generate_extension_api() { Dictionary d1; d1["name"] = E->key(); Array values; - for (List<Pair<String, int>>::Element *F = E->get().front(); F; F = F->next()) { + for (const Pair<String, int> &F : E->get()) { Dictionary d2; - d2["name"] = F->get().first; - d2["value"] = F->get().second; + d2["name"] = F.first; + d2["value"] = F.second; values.push_back(d2); } d1["values"] = values; @@ -294,8 +294,7 @@ Dictionary NativeExtensionAPIDump::generate_extension_api() { List<StringName> utility_func_names; Variant::get_utility_function_list(&utility_func_names); - for (List<StringName>::Element *E = utility_func_names.front(); E; E = E->next()) { - StringName name = E->get(); + for (const StringName &name : utility_func_names) { Dictionary func; func["name"] = String(name); if (Variant::has_utility_function_return_value(name)) { @@ -363,8 +362,7 @@ Dictionary NativeExtensionAPIDump::generate_extension_api() { List<StringName> member_names; Variant::get_member_list(type, &member_names); - for (List<StringName>::Element *E = member_names.front(); E; E = E->next()) { - StringName member_name = E->get(); + for (const StringName &member_name : member_names) { Dictionary d2; d2["name"] = String(member_name); d2["type"] = Variant::get_type_name(Variant::get_member_type(type, member_name)); @@ -380,8 +378,7 @@ Dictionary NativeExtensionAPIDump::generate_extension_api() { List<StringName> constant_names; Variant::get_constants_for_type(type, &constant_names); - for (List<StringName>::Element *E = constant_names.front(); E; E = E->next()) { - StringName constant_name = E->get(); + for (const StringName &constant_name : constant_names) { Dictionary d2; d2["name"] = String(constant_name); Variant constant = Variant::get_constant_value(type, constant_name); @@ -420,8 +417,7 @@ Dictionary NativeExtensionAPIDump::generate_extension_api() { List<StringName> method_names; Variant::get_builtin_method_list(type, &method_names); - for (List<StringName>::Element *E = method_names.front(); E; E = E->next()) { - StringName method_name = E->get(); + for (const StringName &method_name : method_names) { Dictionary d2; d2["name"] = String(method_name); if (Variant::has_builtin_method_return_value(type, method_name)) { @@ -503,9 +499,8 @@ Dictionary NativeExtensionAPIDump::generate_extension_api() { class_list.sort_custom<StringName::AlphCompare>(); - for (List<StringName>::Element *E = class_list.front(); E; E = E->next()) { + for (const StringName &class_name : class_list) { Dictionary d; - StringName class_name = E->get(); d["name"] = String(class_name); d["is_refcounted"] = ClassDB::is_parent_class(class_name, "RefCounted"); d["is_instantiable"] = ClassDB::can_instantiate(class_name); @@ -525,15 +520,15 @@ Dictionary NativeExtensionAPIDump::generate_extension_api() { Array constants; List<String> constant_list; ClassDB::get_integer_constant_list(class_name, &constant_list, true); - for (List<String>::Element *F = constant_list.front(); F; F = F->next()) { - StringName enum_name = ClassDB::get_integer_constant_enum(class_name, F->get()); + for (const String &F : constant_list) { + StringName enum_name = ClassDB::get_integer_constant_enum(class_name, F); if (enum_name != StringName()) { continue; //enums will be handled on their own } Dictionary d2; - d2["name"] = String(F->get()); - d2["value"] = ClassDB::get_integer_constant(class_name, F->get()); + d2["name"] = String(F); + d2["value"] = ClassDB::get_integer_constant(class_name, F); constants.push_back(d2); } @@ -547,13 +542,13 @@ Dictionary NativeExtensionAPIDump::generate_extension_api() { Array enums; List<StringName> enum_list; ClassDB::get_enum_list(class_name, &enum_list, true); - for (List<StringName>::Element *F = enum_list.front(); F; F = F->next()) { + for (const StringName &F : enum_list) { Dictionary d2; - d2["name"] = String(F->get()); + d2["name"] = String(F); Array values; List<StringName> enum_constant_list; - ClassDB::get_enum_constants(class_name, F->get(), &enum_constant_list, true); + ClassDB::get_enum_constants(class_name, F, &enum_constant_list, true); for (List<StringName>::Element *G = enum_constant_list.front(); G; G = G->next()) { Dictionary d3; d3["name"] = String(G->get()); @@ -575,14 +570,14 @@ Dictionary NativeExtensionAPIDump::generate_extension_api() { Array methods; List<MethodInfo> method_list; ClassDB::get_method_list(class_name, &method_list, true); - for (List<MethodInfo>::Element *F = method_list.front(); F; F = F->next()) { - StringName method_name = F->get().name; - if (F->get().flags & METHOD_FLAG_VIRTUAL) { + for (const MethodInfo &F : method_list) { + StringName method_name = F.name; + if (F.flags & METHOD_FLAG_VIRTUAL) { //virtual method - const MethodInfo &mi = F->get(); + const MethodInfo &mi = F; Dictionary d2; d2["name"] = String(method_name); - d2["is_const"] = (F->get().flags & METHOD_FLAG_CONST) ? true : false; + d2["is_const"] = (F.flags & METHOD_FLAG_CONST) ? true : false; d2["is_vararg"] = false; d2["is_virtual"] = true; // virtual functions have no hash since no MethodBind is involved @@ -619,7 +614,7 @@ Dictionary NativeExtensionAPIDump::generate_extension_api() { methods.push_back(d2); - } else if (F->get().name.begins_with("_")) { + } else if (F.name.begins_with("_")) { //hidden method, ignore } else { @@ -692,19 +687,19 @@ Dictionary NativeExtensionAPIDump::generate_extension_api() { Array signals; List<MethodInfo> signal_list; ClassDB::get_signal_list(class_name, &signal_list, true); - for (List<MethodInfo>::Element *F = signal_list.front(); F; F = F->next()) { - StringName signal_name = F->get().name; + for (const MethodInfo &F : signal_list) { + StringName signal_name = F.name; Dictionary d2; d2["name"] = String(signal_name); Array arguments; - for (int i = 0; i < F->get().arguments.size(); i++) { + for (int i = 0; i < F.arguments.size(); i++) { Dictionary d3; - d3["name"] = F->get().arguments[i].name; - Variant::Type type = F->get().arguments[i].type; - if (F->get().arguments[i].class_name != StringName()) { - d3["type"] = String(F->get().arguments[i].class_name); + d3["name"] = F.arguments[i].name; + Variant::Type type = F.arguments[i].type; + if (F.arguments[i].class_name != StringName()) { + d3["type"] = String(F.arguments[i].class_name); } else if (type == Variant::NIL) { d3["type"] = "Variant"; } else { @@ -728,28 +723,28 @@ Dictionary NativeExtensionAPIDump::generate_extension_api() { Array properties; List<PropertyInfo> property_list; ClassDB::get_property_list(class_name, &property_list, true); - for (List<PropertyInfo>::Element *F = property_list.front(); F; F = F->next()) { - if (F->get().usage & PROPERTY_USAGE_CATEGORY || F->get().usage & PROPERTY_USAGE_GROUP || F->get().usage & PROPERTY_USAGE_SUBGROUP) { + for (const PropertyInfo &F : property_list) { + if (F.usage & PROPERTY_USAGE_CATEGORY || F.usage & PROPERTY_USAGE_GROUP || F.usage & PROPERTY_USAGE_SUBGROUP) { continue; //not real properties } - if (F->get().name.begins_with("_")) { + if (F.name.begins_with("_")) { continue; //hidden property } - StringName property_name = F->get().name; + StringName property_name = F.name; Dictionary d2; d2["name"] = String(property_name); - if (F->get().class_name != StringName()) { - d2["type"] = String(F->get().class_name); - } else if (F->get().type == Variant::NIL && F->get().usage & PROPERTY_USAGE_NIL_IS_VARIANT) { + if (F.class_name != StringName()) { + d2["type"] = String(F.class_name); + } else if (F.type == Variant::NIL && F.usage & PROPERTY_USAGE_NIL_IS_VARIANT) { d2["type"] = "Variant"; } else { - d2["type"] = Variant::get_type_name(F->get().type); + d2["type"] = Variant::get_type_name(F.type); } - d2["setter"] = ClassDB::get_property_setter(class_name, F->get().name); - d2["getter"] = ClassDB::get_property_getter(class_name, F->get().name); - d2["index"] = ClassDB::get_property_index(class_name, F->get().name); + d2["setter"] = ClassDB::get_property_setter(class_name, F.name); + d2["getter"] = ClassDB::get_property_getter(class_name, F.name); + d2["index"] = ClassDB::get_property_index(class_name, F.name); properties.push_back(d2); } @@ -771,8 +766,7 @@ Dictionary NativeExtensionAPIDump::generate_extension_api() { List<Engine::Singleton> singleton_list; Engine::get_singleton()->get_singletons(&singleton_list); - for (List<Engine::Singleton>::Element *E = singleton_list.front(); E; E = E->next()) { - const Engine::Singleton &s = E->get(); + for (const Engine::Singleton &s : singleton_list) { Dictionary d; d["name"] = s.name; if (s.class_name != StringName()) { diff --git a/core/extension/gdnative_interface.cpp b/core/extension/gdnative_interface.cpp index 8f68b8d848..88fff342ee 100644 --- a/core/extension/gdnative_interface.cpp +++ b/core/extension/gdnative_interface.cpp @@ -281,8 +281,9 @@ static GDNativeBool gdnative_variant_has_key(const GDNativeVariantPtr p_self, co const Variant *self = (const Variant *)p_self; const Variant *key = (const Variant *)p_key; bool valid; - return self->has_key(*key, valid); + bool ret = self->has_key(*key, valid); *r_valid = valid; + return ret; } static void gdnative_variant_get_type_name(GDNativeVariantType p_type, GDNativeStringPtr r_ret) { diff --git a/core/extension/gdnative_interface.h b/core/extension/gdnative_interface.h index c1ebb3e76a..3e69a28d59 100644 --- a/core/extension/gdnative_interface.h +++ b/core/extension/gdnative_interface.h @@ -134,7 +134,7 @@ typedef void *GDNativeObjectPtr; typedef void *GDNativeTypePtr; typedef void *GDNativeMethodBindPtr; typedef int64_t GDNativeInt; -typedef uint32_t GDNativeBool; +typedef uint8_t GDNativeBool; typedef uint64_t GDObjectInstanceID; /* VARIANT DATA I/O */ diff --git a/core/extension/native_extension.cpp b/core/extension/native_extension.cpp index 65718a7507..16bc28e0a2 100644 --- a/core/extension/native_extension.cpp +++ b/core/extension/native_extension.cpp @@ -351,8 +351,8 @@ RES NativeExtensionResourceLoader::load(const String &p_path, const String &p_or String library_path; - for (List<String>::Element *E = libraries.front(); E; E = E->next()) { - Vector<String> tags = E->get().split("."); + for (const String &E : libraries) { + Vector<String> tags = E.split("."); bool all_tags_met = true; for (int i = 0; i < tags.size(); i++) { String tag = tags[i].strip_edges(); @@ -363,7 +363,7 @@ RES NativeExtensionResourceLoader::load(const String &p_path, const String &p_or } if (all_tags_met) { - library_path = config->get_value("libraries", E->get()); + library_path = config->get_value("libraries", E); break; } } diff --git a/core/input/gamecontrollerdb.txt b/core/input/gamecontrollerdb.txt index 884fb9550c..f136d83496 100644 --- a/core/input/gamecontrollerdb.txt +++ b/core/input/gamecontrollerdb.txt @@ -4,19 +4,24 @@ # Windows 03000000fa2d00000100000000000000,3DRUDDER,leftx:a0,lefty:a1,rightx:a5,righty:a2,platform:Windows, 03000000c82d00002038000000000000,8bitdo,a:b1,b:b0,back:b10,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b2,leftshoulder:b6,leftstick:b13,lefttrigger:b8,leftx:a0,lefty:a1,rightshoulder:b7,rightstick:b14,righttrigger:b9,rightx:a3,righty:a4,start:b11,x:b4,y:b3,platform:Windows, +03000000c82d00000951000000000000,8BitDo Dogbone Modkit,a:b1,b:b0,back:b10,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,start:b11,platform:Windows, 03000000c82d000011ab000000000000,8BitDo F30,a:b1,b:b0,back:b10,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b2,leftshoulder:b6,leftstick:b13,lefttrigger:b8,leftx:a0,lefty:a1,rightshoulder:b7,rightstick:b14,righttrigger:b9,rightx:a3,righty:a4,start:b11,x:b4,y:b3,platform:Windows, 03000000c82d00001038000000000000,8BitDo F30 Pro,a:b1,b:b0,back:b10,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b2,leftshoulder:b6,leftstick:b13,lefttrigger:b8,leftx:a0,lefty:a1,rightshoulder:b7,rightstick:b14,righttrigger:b9,rightx:a2,righty:a5,start:b11,x:b4,y:b3,platform:Windows, 03000000c82d00000090000000000000,8BitDo FC30 Pro,a:b1,b:b0,back:b10,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b2,leftshoulder:b6,leftstick:b13,lefttrigger:b8,leftx:a0,lefty:a1,rightshoulder:b7,rightstick:b14,righttrigger:b9,rightx:a3,righty:a4,start:b11,x:b4,y:b3,platform:Windows, 03000000c82d00000650000000000000,8BitDo M30,a:b0,b:b1,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:a4,lefttrigger:a5,leftx:a0,lefty:a1,rightshoulder:b6,righttrigger:b7,start:b11,x:b3,y:b4,platform:Windows, 03000000c82d00005106000000000000,8BitDo M30 Gamepad,a:b1,b:b0,back:b10,guide:b2,leftshoulder:b6,lefttrigger:b8,leftx:a0,lefty:a1,rightshoulder:b7,righttrigger:b9,start:b11,x:b4,y:b3,platform:Windows, +03000000c82d00000151000000000000,8BitDo M30 ModKit,a:b0,b:b1,back:b10,dpdown:+a2,dpleft:-a0,dpright:+a0,dpup:-a2,rightshoulder:b6,righttrigger:b7,start:b11,x:b3,y:b4,platform:Windows, 03000000c82d00000310000000000000,8BitDo N30,a:b0,b:b1,back:b10,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b6,leftx:a0,lefty:a1,rightshoulder:b7,start:b11,x:b3,y:b4,platform:Windows, 03000000c82d00002028000000000000,8BitDo N30,a:b1,b:b0,back:b10,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b2,leftshoulder:b6,leftstick:b13,lefttrigger:b8,leftx:a0,lefty:a1,rightshoulder:b7,rightstick:b14,righttrigger:b9,rightx:a2,righty:a5,start:b11,x:b4,y:b3,platform:Windows, 03000000c82d00008010000000000000,8BitDo N30,a:b0,b:b1,back:b10,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b6,leftx:a0,lefty:a1,rightshoulder:b7,start:b11,x:b3,y:b4,platform:Windows, +03000000c82d00000451000000000000,8BitDo N30 Modkit,a:b1,b:b0,back:b10,dpdown:+a2,dpleft:-a0,dpright:+a0,dpup:-a2,start:b11,platform:Windows, 03000000c82d00000190000000000000,8BitDo N30 Pro,a:b1,b:b0,back:b10,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b2,leftshoulder:b6,leftstick:b13,lefttrigger:b8,leftx:a0,lefty:a1,rightshoulder:b7,rightstick:b14,righttrigger:b9,rightx:a3,righty:a4,start:b11,x:b4,y:b3,platform:Windows, 03000000c82d00001590000000000000,8BitDo N30 Pro 2,a:b1,b:b0,back:b10,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b2,leftshoulder:b6,leftstick:b13,lefttrigger:b8,leftx:a0,lefty:a1,rightshoulder:b7,rightstick:b14,righttrigger:b9,rightx:a2,righty:a5,start:b11,x:b4,y:b3,platform:Windows, 03000000c82d00006528000000000000,8BitDo N30 Pro 2,a:b1,b:b0,back:b10,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b2,leftshoulder:b6,leftstick:b13,lefttrigger:b8,leftx:a0,lefty:a1,rightshoulder:b7,rightstick:b14,righttrigger:b9,rightx:a3,righty:a4,start:b11,x:b4,y:b3,platform:Windows, 03000000022000000090000000000000,8Bitdo NES30 Pro,a:b1,b:b0,back:b10,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b6,leftstick:b13,lefttrigger:b8,leftx:a0,lefty:a1,rightshoulder:b7,rightstick:b14,righttrigger:b9,rightx:a3,righty:a4,start:b11,x:b4,y:b3,platform:Windows, 03000000203800000900000000000000,8Bitdo NES30 Pro,a:b1,b:b0,back:b10,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b6,leftstick:b13,lefttrigger:b8,leftx:a0,lefty:a1,rightshoulder:b7,rightstick:b14,righttrigger:b9,rightx:a3,righty:a4,start:b11,x:b4,y:b3,platform:Windows, +03000000c82d00000360000000000000,8BitDo Pro 2,a:b1,b:b0,back:b10,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b6,leftstick:b13,lefttrigger:b8,leftx:a0,lefty:a1,rightshoulder:b7,rightstick:b14,righttrigger:b9,rightx:a3,righty:a4,start:b11,x:b4,y:b3,platform:Windows, +03000000c82d00002867000000000000,8BitDo S30 Modkit,a:b0,b:b1,dpdown:+a2,dpleft:-a0,dpright:+a0,dpup:-a2,leftshoulder:b8,lefttrigger:b9,rightshoulder:b6,righttrigger:b7,start:b11,x:b3,y:b4,platform:Windows, 03000000c82d00000130000000000000,8BitDo SF30,a:b1,b:b0,back:b10,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b2,leftshoulder:b6,leftstick:b13,lefttrigger:b8,leftx:a0,lefty:a1,rightshoulder:b7,rightstick:b14,righttrigger:b9,rightx:a2,righty:a5,start:b11,x:b4,y:b3,platform:Windows, 03000000c82d00000060000000000000,8Bitdo SF30 Pro,a:b1,b:b0,back:b10,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b6,leftstick:b13,lefttrigger:b8,leftx:a0,lefty:a1,rightshoulder:b7,rightstick:b14,righttrigger:b9,rightx:a2,righty:a3,start:b11,x:b4,y:b3,platform:Windows, 03000000c82d00000061000000000000,8Bitdo SF30 Pro,a:b1,b:b0,back:b10,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b2,leftshoulder:b6,leftstick:b13,lefttrigger:b8,leftx:a0,lefty:a1,rightshoulder:b7,rightstick:b14,righttrigger:b9,rightx:a2,righty:a3,start:b11,x:b4,y:b3,platform:Windows, @@ -24,19 +29,22 @@ 03000000102800000900000000000000,8Bitdo SFC30 GamePad,a:b1,b:b0,back:b10,leftshoulder:b6,leftx:a0,lefty:a1,rightshoulder:b7,start:b11,x:b4,y:b3,platform:Windows, 03000000c82d00003028000000000000,8Bitdo SFC30 GamePad,a:b1,b:b0,back:b10,leftshoulder:b6,leftx:a0,lefty:a1,rightshoulder:b7,start:b11,x:b4,y:b3,platform:Windows, 03000000c82d00000030000000000000,8BitDo SN30,a:b1,b:b0,back:b10,leftshoulder:b6,leftx:a0,lefty:a1,rightshoulder:b7,start:b11,x:b4,y:b3,platform:Windows, -03000000c82d00000351000000000000,8BitDo SN30,a:b1,b:b0,back:b10,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b2,leftshoulder:b6,leftstick:b13,lefttrigger:b8,leftx:a0,lefty:a1,rightshoulder:b7,rightstick:b14,righttrigger:b9,rightx:a2,righty:a5,start:b11,x:b4,y:b3,platform:Windows, 03000000c82d00001290000000000000,8BitDo SN30,a:b1,b:b0,back:b10,dpdown:+a1,dpleft:-a0,dpright:+a0,dpup:-a1,leftshoulder:b6,rightshoulder:b7,start:b11,x:b4,y:b3,platform:Windows, 03000000c82d000020ab000000000000,8BitDo SN30,a:b1,b:b0,back:b10,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b2,leftshoulder:b6,leftstick:b13,lefttrigger:b8,leftx:a0,lefty:a1,rightshoulder:b7,rightstick:b14,righttrigger:b9,rightx:a2,righty:a5,start:b11,x:b4,y:b3,platform:Windows, 03000000c82d00004028000000000000,8BitDo SN30,a:b1,b:b0,back:b10,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b2,leftshoulder:b6,leftstick:b13,lefttrigger:b8,leftx:a0,lefty:a1,rightshoulder:b7,rightstick:b14,righttrigger:b9,rightx:a2,righty:a5,start:b11,x:b4,y:b3,platform:Windows, 03000000c82d00006228000000000000,8BitDo SN30,a:b1,b:b0,back:b10,dpdown:+a1,dpleft:-a0,dpright:+a0,dpup:-a1,leftshoulder:b6,rightshoulder:b7,start:b11,x:b4,y:b3,platform:Windows, +03000000c82d00000351000000000000,8BitDo SN30 Modkit,a:b1,b:b0,back:b10,dpdown:+a2,dpleft:-a0,dpright:+a0,dpup:-a2,leftshoulder:b6,rightshoulder:b7,start:b11,x:b4,y:b3,platform:Windows, 03000000c82d00000160000000000000,8BitDo SN30 Pro,a:b1,b:b0,back:b10,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b2,leftshoulder:b6,leftstick:b13,lefttrigger:b8,leftx:a0,lefty:a1,rightshoulder:b7,rightstick:b14,righttrigger:b9,rightx:a2,righty:a3,start:b11,x:b4,y:b3,platform:Windows, 03000000c82d00000161000000000000,8BitDo SN30 Pro,a:b1,b:b0,back:b10,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b2,leftshoulder:b6,leftstick:b13,lefttrigger:b8,leftx:a0,lefty:a1,rightshoulder:b7,rightstick:b14,righttrigger:b9,rightx:a2,righty:a3,start:b11,x:b4,y:b3,platform:Windows, +03000000c82d00000121000000000000,8BitDo SN30 Pro for Android,a:b0,b:b1,back:b10,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b6,leftstick:b13,lefttrigger:b8,leftx:a0,lefty:a1,rightshoulder:b7,rightstick:b14,righttrigger:b9,rightx:a3,righty:a4,start:b11,x:b3,y:b4,platform:Windows, 03000000c82d00000260000000000000,8BitDo SN30 Pro+,a:b1,b:b0,back:b10,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b2,leftshoulder:b6,leftstick:b13,lefttrigger:b8,leftx:a0,lefty:a1,rightshoulder:b7,rightstick:b14,righttrigger:b9,rightx:a2,righty:a3,start:b11,x:b4,y:b3,platform:Windows, 03000000c82d00000261000000000000,8BitDo SN30 Pro+,a:b1,b:b0,back:b10,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b2,leftshoulder:b6,leftstick:b13,lefttrigger:b8,leftx:a0,lefty:a1,rightshoulder:b7,rightstick:b14,righttrigger:b9,rightx:a2,righty:a3,start:b11,x:b4,y:b3,platform:Windows, 03000000c82d00000031000000000000,8BitDo Wireless Adapter,a:b0,b:b1,back:b10,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b6,leftstick:b13,lefttrigger:b8,leftx:a0,lefty:a1,rightshoulder:b7,rightstick:b14,righttrigger:b9,rightx:a3,righty:a4,start:b11,x:b3,y:b4,platform:Windows, 03000000c82d00001890000000000000,8BitDo Zero 2,a:b1,b:b0,back:b10,leftshoulder:b6,leftx:a0,lefty:a1,rightshoulder:b7,start:b11,x:b4,y:b3,platform:Windows, 03000000c82d00003032000000000000,8BitDo Zero 2,a:b1,b:b0,back:b10,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b6,leftx:a0,lefty:a1,rightshoulder:b7,rightx:a2,righty:a3,start:b11,x:b4,y:b3,platform:Windows, 03000000a00500003232000000000000,8Bitdo Zero GamePad,a:b0,b:b1,back:b10,dpdown:+a2,dpleft:-a0,dpright:+a0,dpup:-a2,leftshoulder:b6,rightshoulder:b7,start:b11,x:b3,y:b4,platform:Windows, +03000000a30c00002700000000000000,Astro City Mini,a:b2,b:b1,back:b8,leftx:a3,lefty:a4,rightshoulder:b4,righttrigger:b5,start:b9,x:b3,y:b0,platform:Windows, +03000000a30c00002800000000000000,Astro City Mini,a:b2,b:b1,back:b8,leftx:a3,lefty:a4,rightshoulder:b4,righttrigger:b5,start:b9,x:b3,y:b0,platform:Windows, 030000008f0e00001200000000000000,Acme GA-02,a:b0,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b10,lefttrigger:b5,leftx:a0,lefty:a1,rightshoulder:b6,rightstick:b11,righttrigger:b7,rightx:a3,righty:a2,start:b9,x:b2,y:b3,platform:Windows, 03000000c01100000355000011010000,ACRUX USB GAME PAD,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b0,y:b3,platform:Windows, 03000000fa190000f0ff000000000000,Acteck AGJ-3200,a:b2,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b3,y:b0,platform:Windows, @@ -49,7 +57,9 @@ 030000006f0e00001901000000000000,Afterglow PS3 Controller,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b0,y:b3,platform:Windows, 030000006f0e00001a01000000000000,Afterglow PS3 Controller,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b0,y:b3,platform:Windows, 03000000d62000001d57000000000000,Airflo PS3 Controller,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b0,y:b3,platform:Windows, -03000000869800002400000000007801,Astro C40 TR,a:b0,b:b1,back:b6,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b10,leftshoulder:b4,leftstick:b8,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b9,righttrigger:a5,rightx:a3,righty:a4,start:b7,x:b2,y:b3,platform:Windows, +03000000491900001904000000000000,Amazon Luna Controller,a:b0,b:b1,back:b6,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b8,leftshoulder:b4,leftstick:b10,lefttrigger:a3,leftx:a0,lefty:a1,misc1:b9,rightshoulder:b5,rightstick:b11,righttrigger:a4,rightx:a2,righty:a5,start:b7,x:b2,y:b3,platform:Windows, +03000000710100001904000000000000,Amazon Luna Controller,a:b1,b:b0,back:b10,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b11,leftshoulder:b5,leftstick:b8,leftx:a0,lefty:a1,misc1:b9,rightshoulder:b4,rightstick:b7,rightx:a3,righty:a4,start:b6,x:b3,y:b2,platform:Windows, +03000000ef0500000300000000000000,AxisPad,a:b2,b:b3,back:b10,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b8,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b9,righttrigger:b7,rightx:a3,righty:a2,start:b11,x:b0,y:b1,platform:Windows, 03000000d6200000e557000000000000,Batarang,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b0,y:b3,platform:Windows, 03000000c01100001352000000000000,Battalife Joystick,a:b6,b:b7,back:b2,leftshoulder:b0,leftx:a0,lefty:a1,rightshoulder:b1,start:b3,x:b4,y:b5,platform:Windows, 030000006f0e00003201000000000000,Battlefield 4 PS3 Controller,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b0,y:b3,platform:Windows, @@ -65,7 +75,7 @@ 03000000808300000300000000000000,Betop Gamepad,a:b2,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a4,start:b9,x:b3,y:b0,platform:Windows, 030000006b1400000055000000000000,Bigben PS3 Controller,a:b0,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b2,y:b3,platform:Windows, 030000006b1400000103000000000000,Bigben PS3 Controller,a:b0,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b3,y:b2,platform:Windows, -03000000120c0000210e000000000000,Brook Mars,a:b1,b:b2,x:b0,y:b3,back:b8,guide:b12,start:b9,leftstick:b10,rightstick:b11,leftshoulder:b4,rightshoulder:b5,dpup:h0.1,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,leftx:a0,lefty:a1,rightx:a2,righty:a3,lefttrigger:b6,righttrigger:b7,platform:Windows, +03000000120c0000210e000000000000,Brook Mars,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b0,y:b3,platform:Windows, 0300000066f700000500000000000000,BrutalLegendTest,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a3,righty:a2,start:b9,x:b0,y:b3,platform:Windows, 03000000d81d00000b00000000000000,BUFFALO BSGP1601 Series ,a:b5,b:b3,back:b12,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b8,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b9,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b13,x:b4,y:b2,platform:Windows, 03000000e82000006058000000000000,Cideko AK08b,a:b2,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b3,y:b0,platform:Windows, @@ -106,7 +116,6 @@ 03000000ac0500004d04000000000000,GameSir,a:b0,b:b1,back:b10,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b6,leftstick:b13,lefttrigger:b8,leftx:a0,lefty:a1,rightshoulder:b7,rightstick:b14,righttrigger:b9,rightx:a3,righty:a4,start:b11,x:b3,y:b4,platform:Windows, 03000000ffff00000000000000000000,GameStop Gamepad,a:b0,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b2,y:b3,platform:Windows, 03000000c01100000140000000000000,GameStop PS4 Fun Controller,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:a3,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:a4,rightx:a2,righty:a5,start:b9,x:b0,y:b3,platform:Windows, -030000006f0e00000102000000007801,GameStop Xbox 360 Wired Controller,a:b0,b:b1,back:b6,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b10,leftshoulder:b4,leftstick:b8,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b9,righttrigger:a5,rightx:a3,righty:a4,start:b7,x:b2,y:b3,platform:Windows, 030000009b2800003200000000000000,GC/N64 to USB v3.4,a:b0,b:b7,dpdown:b11,dpleft:b12,dpright:b13,dpup:b10,lefttrigger:+a5,leftx:a0,lefty:a1,rightshoulder:b2,righttrigger:+a2,rightx:a3,righty:a4,start:b3,x:b1,y:b8,platform:Windows, 030000009b2800006000000000000000,GC/N64 to USB v3.6,a:b0,b:b7,dpdown:b11,dpleft:b12,dpright:b13,dpup:b10,lefttrigger:+a5,leftx:a0,lefty:a1,rightshoulder:b2,righttrigger:+a2,rightx:a3,righty:a4,start:b3,x:b1,y:b8,platform:Windows, 030000008305000009a0000000000000,Genius,a:b0,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b2,y:b3,platform:Windows, @@ -157,6 +166,7 @@ 030000007e0500000620000001000000,Joy-Con (L),+leftx:h0.2,+lefty:h0.4,-leftx:h0.8,-lefty:h0.1,a:b0,b:b1,back:b13,leftshoulder:b4,leftstick:b10,rightshoulder:b5,start:b8,x:b2,y:b3,platform:Windows, 030000007e0500000720000000000000,Joy-Con (R),+leftx:h0.2,+lefty:h0.4,-leftx:h0.8,-lefty:h0.1,a:b0,b:b1,back:b12,leftshoulder:b4,leftstick:b11,rightshoulder:b5,start:b9,x:b2,y:b3,platform:Windows, 030000007e0500000720000001000000,Joy-Con (R),+leftx:h0.2,+lefty:h0.4,-leftx:h0.8,-lefty:h0.1,a:b0,b:b1,back:b12,leftshoulder:b4,leftstick:b11,rightshoulder:b5,start:b9,x:b2,y:b3,platform:Windows, +03000000bd12000003c0000010010000,Joypad Alpha Shock,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b0,y:b3,platform:Windows, 03000000bd12000003c0000000000000,JY-P70UR,a:b1,b:b0,back:b5,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b6,leftstick:b10,lefttrigger:b7,leftx:a0,lefty:a1,rightshoulder:b8,rightstick:b11,righttrigger:b9,rightx:a3,righty:a2,start:b4,x:b3,y:b2,platform:Windows, 03000000242f00002d00000000000000,JYS Wireless Adapter,a:b2,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b3,y:b0,platform:Windows, 03000000242f00008a00000000000000,JYS Wireless Adapter,a:b1,b:b4,back:b10,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b6,leftstick:b13,lefttrigger:b8,rightshoulder:b7,rightstick:b14,righttrigger:b9,rightx:a3,righty:a4,start:b11,x:b0,y:b3,platform:Windows, @@ -184,6 +194,7 @@ 03000000380700001888000000000000,MadCatz SFIV FightStick PS3,a:b0,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b5,lefttrigger:b7,leftx:a0,lefty:a1,rightshoulder:b4,righttrigger:b6,rightx:a2,righty:a3,start:b9,x:b2,y:b3,platform:Windows, 03000000380700008081000000000000,MADCATZ SFV Arcade FightStick Alpha PS4,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,righttrigger:b7,rightx:a2,righty:a5,start:b9,x:b0,y:b3,platform:Windows, 030000002a0600001024000000000000,Matricom,a:b0,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a3,righty:a4,start:b9,x:b2,y:b3,platform:Windows, +030000009f000000adbb000000000000,MaxJoypad Virtual Controller,a:b1,b:b2,back:b9,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,righttrigger:b7,rightx:a2,righty:a3,start:b8,x:b3,y:b0,platform:Windows, 03000000250900000128000000000000,Mayflash Arcade Stick,a:b1,b:b2,back:b8,leftshoulder:b0,lefttrigger:b4,leftx:a0,lefty:a1,rightshoulder:b3,righttrigger:b7,start:b9,x:b5,y:b6,platform:Windows, 03000000790000004418000000000000,Mayflash GameCube Controller,a:b1,b:b2,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,lefttrigger:a3,leftx:a0,lefty:a1,rightshoulder:b7,righttrigger:a4,rightx:a5,righty:a2,start:b9,x:b0,y:b3,platform:Windows, 03000000790000004318000000000000,Mayflash GameCube Controller Adapter,a:b1,b:b2,back:b0,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b0,leftshoulder:b4,leftstick:b0,lefttrigger:a3,leftx:a0,lefty:a1,rightshoulder:b7,rightstick:b0,righttrigger:a4,rightx:a5,righty:a2,start:b9,x:b0,y:b3,platform:Windows, @@ -202,6 +213,8 @@ 03000000efbe0000edfe000000000000,Monect Virtual Controller,a:b2,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:a5,rightx:a3,righty:a4,start:b9,x:b3,y:b0,platform:Windows, 03000000250900006688000000000000,MP-8866 Super Dual Box,a:b2,b:b1,back:b9,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b6,leftstick:b10,lefttrigger:b4,leftx:a0,lefty:a1,rightshoulder:b7,rightstick:b11,righttrigger:b5,rightx:a2,righty:a3,start:b8,x:b3,y:b0,platform:Windows, 030000006b140000010c000000000000,NACON GC-400ES,a:b0,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b2,y:b3,platform:Windows, +03000000921200004b46000000000000,NES 2-port Adapter,a:b1,b:b0,back:b10,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,start:b11,platform:Windows, +03000000790000004518000000000000,NEXILUX GAMECUBE Controller Adapter,platform:Windows,a:b1,b:b0,x:b2,y:b3,start:b9,rightshoulder:b7,dpup:h0.1,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,leftx:a0,lefty:a1,rightx:a5,righty:a2,lefttrigger:a3,righttrigger:a4, 030000001008000001e5000000000000,NEXT SNES Controller,a:b2,b:b1,back:b8,dpdown:+a1,dpleft:-a0,dpright:+a0,dpup:-a1,leftshoulder:b4,rightshoulder:b5,righttrigger:b6,start:b9,x:b3,y:b0,platform:Windows, 03000000152000000182000000000000,NGDS,a:b2,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a3,righty:a4,start:b9,x:b3,y:b0,platform:Windows, 03000000bd12000015d0000000000000,Nintendo Retrolink USB Super SNES Classic Controller,a:b2,b:b1,back:b8,leftshoulder:b4,leftx:a0,lefty:a1,rightshoulder:b5,start:b9,x:b3,y:b0,platform:Windows, @@ -217,6 +230,7 @@ 030000006f0e00000901000000000000,PDP Versus Fighting Pad,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,lefttrigger:b6,rightshoulder:b5,righttrigger:b7,start:b9,x:b0,y:b3,platform:Windows, 030000008f0e00000300000000000000,Piranha xtreme,a:b2,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b6,leftstick:b10,lefttrigger:b4,leftx:a0,lefty:a1,rightshoulder:b7,rightstick:b11,righttrigger:b5,rightx:a3,righty:a2,start:b9,x:b3,y:b0,platform:Windows, 030000004c050000da0c000000000000,PlayStation Classic Controller,a:b2,b:b1,back:b8,dpdown:+a1,dpleft:-a0,dpright:+a0,dpup:-a1,leftshoulder:b6,lefttrigger:b4,rightshoulder:b7,righttrigger:b5,start:b9,x:b3,y:b0,platform:Windows, +030000004c0500003713000000000000,PlayStation Vita,a:b1,b:b2,back:b8,dpdown:b13,dpleft:b15,dpright:b14,dpup:b12,leftshoulder:b4,leftx:a0,lefty:a1,rightshoulder:b5,rightx:a3,righty:a4,start:b9,x:b0,y:b3,platform:Windows, 03000000d62000006dca000000000000,PowerA Pro Ex,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b0,y:b3,platform:Windows, 03000000d62000009557000000000000,Pro Elite PS3 Controller,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b0,y:b3,platform:Windows, 03000000d62000009f31000000000000,Pro Ex mini PS3 Controller,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b0,y:b3,platform:Windows, @@ -241,6 +255,7 @@ 030000004c050000c405000000000000,PS4 Controller,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:a3,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:a4,rightx:a2,righty:a5,start:b9,x:b0,y:b3,platform:Windows, 030000004c050000cc09000000000000,PS4 Controller,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:a3,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:a4,rightx:a2,righty:a5,start:b9,x:b0,y:b3,platform:Windows, 030000004c050000e60c000000000000,PS5 Controller,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:a3,leftx:a0,lefty:a1,misc1:b13,rightshoulder:b5,rightstick:b11,righttrigger:a4,rightx:a2,righty:a5,start:b9,x:b0,y:b3,platform:Windows, +03000000ff000000cb01000000000000,PSP,a:b0,b:b1,back:b6,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftx:a0,lefty:a1,rightshoulder:b5,start:b7,x:b2,y:b3,platform:Windows, 03000000300f00000011000000000000,QanBa Arcade JoyStick 1008,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,righttrigger:b7,start:b10,x:b0,y:b3,platform:Windows, 03000000300f00001611000000000000,QanBa Arcade JoyStick 4018,a:b1,b:b2,back:b10,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b9,leftshoulder:b4,lefttrigger:b6,rightshoulder:b5,righttrigger:b7,start:b8,x:b0,y:b3,platform:Windows, 03000000222c00000020000000000000,QANBA DRONE ARCADE JOYSTICK,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,lefttrigger:a3,rightshoulder:b5,righttrigger:a4,start:b9,x:b0,y:b3,platform:Windows, @@ -292,7 +307,6 @@ 030000009b2800000500000000000000,Saturn_Adapter_2.0,a:b1,b:b2,leftshoulder:b6,lefttrigger:b4,leftx:a0,lefty:a1,rightshoulder:b7,righttrigger:b5,start:b9,x:b0,y:b3,platform:Windows, 03000000a30c00002500000000000000,Sega Genesis Mini 3B controller,a:b2,b:b1,dpdown:+a4,dpleft:-a3,dpright:+a3,dpup:-a4,righttrigger:b5,start:b9,platform:Windows, 03000000a30c00002400000000000000,Sega Mega Drive Mini 6B controller,a:b2,b:b1,dpdown:+a4,dpleft:-a3,dpright:+a3,dpup:-a4,rightshoulder:b4,righttrigger:b5,start:b9,x:b3,y:b0,platform:Windows, -030000005e0400008e02000000007801,ShanWan PS3/PC Wired GamePad,a:b0,b:b1,back:b6,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b10,leftshoulder:b4,leftstick:b8,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b9,righttrigger:a5,rightx:a3,righty:a4,start:b7,x:b2,y:b3,platform:Windows, 03000000341a00000208000000000000,SL-6555-SBK,a:b0,b:b1,back:b6,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b8,lefttrigger:-a4,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b9,righttrigger:a4,rightx:a3,righty:a2,start:b7,x:b2,y:b3,platform:Windows, 03000000341a00000908000000000000,SL-6566,a:b0,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b2,y:b3,platform:Windows, 030000008f0e00000800000000000000,SpeedLink Strike FX,a:b2,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b3,y:b0,platform:Windows, @@ -337,8 +351,7 @@ 030000006f0e00000702000000000000,Victrix Pro Fight Stick for PS4,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:b6,rightshoulder:b5,righttrigger:b7,start:b9,x:b0,y:b3,platform:Windows, 0300000034120000adbe000000000000,vJoy Device,a:b0,b:b1,back:b15,dpdown:b6,dpleft:b7,dpright:b8,dpup:b5,guide:b16,leftshoulder:b9,leftstick:b13,lefttrigger:b11,leftx:a0,lefty:a1,rightshoulder:b10,rightstick:b14,righttrigger:b12,rightx:a3,righty:a4,start:b4,x:b2,y:b3,platform:Windows, 030000005e0400000a0b000000000000,Xbox Adaptive Controller,a:b0,b:b1,back:b6,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b8,lefttrigger:+a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b9,righttrigger:-a2,rightx:a3,righty:a4,start:b7,x:b2,y:b3,platform:Windows, -030000005e040000ff02000000007801,Xbox One Elite Controller,a:b0,b:b1,back:b6,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b8,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b9,righttrigger:a5,rightx:a3,righty:a4,start:b7,x:b2,y:b3,platform:Windows, -030000005e040000130b000000000000,Xbox Series Controller,a:b0,b:b1,back:b6,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b8,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b9,righttrigger:a5,rightx:a3,righty:a4,start:b7,x:b2,y:b3,platform:Windows, +030000005e040000130b000000000000,Xbox Series Controller,a:b0,b:b1,back:b6,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b10,leftshoulder:b4,leftstick:b8,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b9,righttrigger:a5,rightx:a3,righty:a4,start:b7,x:b2,y:b3,platform:Windows, 03000000341a00000608000000000000,Xeox,a:b0,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b2,y:b3,platform:Windows, 03000000450c00002043000000000000,XEOX Gamepad SL-6556-BK,a:b0,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b2,y:b3,platform:Windows, 03000000ac0500005b05000000000000,Xiaoji Gamesir-G3w,a:b2,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b3,y:b0,platform:Windows, @@ -362,6 +375,7 @@ xinput,XInput Controller,a:b0,b:b1,back:b6,dpdown:h0.4,dpleft:h0.8,dpright:h0.2, 03000000c82d00000190000001000000,8Bitdo NES30 Pro,a:b1,b:b0,back:b10,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b6,leftstick:b13,lefttrigger:b8,leftx:a0,lefty:a1,rightshoulder:b7,rightstick:b14,righttrigger:b9,rightx:a2,righty:a3,start:b11,x:b4,y:b3,platform:Mac OS X, 03000000102800000900000000000000,8Bitdo SFC30 GamePad Joystick,a:b1,b:b0,back:b10,leftshoulder:b6,leftx:a0,lefty:a1,rightshoulder:b7,start:b11,x:b4,y:b3,platform:Mac OS X, 03000000c82d00001290000001000000,8BitDo SN30 Gamepad,a:b1,b:b0,back:b10,leftshoulder:b6,leftx:a0,lefty:a1,rightshoulder:b7,start:b11,x:b4,y:b3,platform:Mac OS X, +03000000c82d00004028000000010000,8Bitdo SN30 GamePad,a:b1,b:b0,x:b4,y:b3,back:b10,start:b11,leftshoulder:b6,rightshoulder:b7,dpup:-a1,dpdown:+a1,dpleft:-a0,dpright:+a0,platform:Mac OS X, 03000000c82d00000160000001000000,8BitDo SN30 Pro,a:b1,b:b0,back:b10,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b6,leftstick:b13,lefttrigger:a4,leftx:a0,lefty:a1,rightshoulder:b7,rightstick:b14,righttrigger:a5,rightx:a2,righty:a3,start:b11,x:b4,y:b3,platform:Mac OS X, 03000000c82d00000161000000010000,8BitDo SN30 Pro,a:b1,b:b0,back:b10,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b2,leftshoulder:b6,leftstick:b13,lefttrigger:b8,leftx:a0,lefty:a1,rightshoulder:b7,rightstick:b14,righttrigger:b9,rightx:a2,righty:a5,start:b11,x:b4,y:b3,platform:Mac OS X, 03000000c82d00000260000001000000,8BitDo SN30 Pro+,a:b1,b:b0,back:b10,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b2,leftshoulder:b6,leftstick:b13,lefttrigger:b8,leftx:a0,lefty:a1,rightshoulder:b7,rightstick:b14,righttrigger:b9,rightx:a2,righty:a3,start:b11,x:b4,y:b3,platform:Mac OS X, @@ -371,21 +385,28 @@ xinput,XInput Controller,a:b0,b:b1,back:b6,dpdown:h0.4,dpleft:h0.8,dpright:h0.2, 03000000c82d00003032000000010000,8BitDo Zero 2,a:b1,b:b0,back:b10,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b6,leftx:a0,lefty:a1,rightshoulder:b7,rightx:a2,righty:a31,start:b11,x:b4,y:b3,platform:Mac OS X, 03000000a00500003232000008010000,8Bitdo Zero GamePad,a:b0,b:b1,back:b10,dpdown:+a1,dpleft:-a0,dpright:+a0,dpup:-a1,leftshoulder:b6,rightshoulder:b7,start:b11,x:b3,y:b4,platform:Mac OS X, 03000000a00500003232000009010000,8Bitdo Zero GamePad,a:b0,b:b1,back:b10,dpdown:+a1,dpleft:-a0,dpright:+a0,dpup:-a1,leftshoulder:b6,rightshoulder:b7,start:b11,x:b3,y:b4,platform:Mac OS X, +03000000a30c00002700000003030000,Astro City Mini,a:b2,b:b1,back:b8,leftx:a3,lefty:a4,rightshoulder:b4,righttrigger:b5,start:b9,x:b3,y:b0,platform:Mac OS X, +03000000a30c00002800000003030000,Astro City Mini,a:b2,b:b1,back:b8,leftx:a3,lefty:a4,rightshoulder:b4,righttrigger:b5,start:b9,x:b3,y:b0,platform:Mac OS X, 03000000050b00000045000031000000,ASUS Gamepad,a:b0,b:b1,back:b10,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b7,lefttrigger:a5,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b8,righttrigger:a4,rightx:a2,righty:a3,start:b9,x:b2,y:b3,platform:Mac OS X, +03000000ef0500000300000000020000,AxisPad,a:b2,b:b3,back:b10,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b8,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b9,righttrigger:b7,rightx:a3,righty:a2,start:b11,x:b0,y:b1,platform:Mac OS X, +03000000491900001904000001010000,Amazon Luna Controller,a:b0,b:b1,back:b6,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b8,leftshoulder:b4,leftstick:b10,lefttrigger:a3,leftx:a0,lefty:a1,misc1:b9,rightshoulder:b5,rightstick:b11,righttrigger:a4,rightx:a2,righty:a5,start:b7,x:b2,y:b3,platform:Mac OS X, +03000000710100001904000000010000,Amazon Luna Controller,a:b0,b:b1,back:b11,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b10,leftshoulder:b4,leftstick:b7,lefttrigger:a5,leftx:a0,lefty:a1,misc1:b9,rightshoulder:b5,rightstick:b8,righttrigger:a4,rightx:a2,righty:a3,start:b6,x:b2,y:b3,platform:Mac OS X, 03000000c62400001a89000000010000,BDA MOGA XP5-X Plus,a:b0,b:b1,back:b12,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b14,leftshoulder:b6,leftstick:b15,lefttrigger:a5,leftx:a0,lefty:a1,rightshoulder:b7,rightstick:b16,righttrigger:a4,rightx:a2,righty:a3,start:b13,x:b3,y:b4,platform:Mac OS X, 03000000c62400001b89000000010000,BDA MOGA XP5-X Plus,a:b0,b:b1,back:b10,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b6,leftstick:b13,lefttrigger:a5,leftx:a0,lefty:a1,rightshoulder:b7,rightstick:b14,righttrigger:a4,rightx:a2,righty:a3,start:b11,x:b3,y:b4,platform:Mac OS X, 03000000d62000002a79000000010000,BDA PS4 Fightpad,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:a3,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:a4,rightx:a2,righty:a5,start:b9,x:b0,y:b3,platform:Mac OS X, -03000000120c0000200e000000010000,Brook Mars,a:b1,b:b2,x:b0,y:b3,back:b8,guide:b12,start:b9,leftstick:b10,rightstick:b11,leftshoulder:b4,rightshoulder:b5,dpup:h0.1,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,leftx:a0,lefty:a1,rightx:a2,righty:a5,lefttrigger:a3,righttrigger:a4,platform:Mac OS X, -03000000120c0000210e000000010000,Brook Mars,a:b1,b:b2,x:b0,y:b3,back:b8,guide:b12,start:b9,leftstick:b10,rightstick:b11,leftshoulder:b4,rightshoulder:b5,dpup:h0.1,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,leftx:a0,lefty:a1,rightx:a2,righty:a3,lefttrigger:b6,righttrigger:b7,platform:Mac OS X, +03000000120c0000200e000000010000,Brook Mars,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:a3,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:a4,rightx:a2,righty:a5,start:b9,x:b0,y:b3,platform:Mac OS X, +03000000120c0000210e000000010000,Brook Mars,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b0,y:b3,platform:Mac OS X, 030000008305000031b0000000000000,Cideko AK08b,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b0,y:b3,platform:Mac OS X, 03000000260900008888000088020000,Cyber Gadget GameCube Controller,a:b0,b:b1,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,lefttrigger:a4,leftx:a0,lefty:a1,rightshoulder:b6,righttrigger:a5,rightx:a2,righty:a3~,start:b7,x:b2,y:b3,platform:Mac OS X, 03000000a306000022f6000001030000,Cyborg V.3 Rumble Pad,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:+a3,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:-a3,rightx:a2,righty:a4,start:b9,x:b0,y:b3,platform:Mac OS X, +03000000790000004618000000010000,GameCube Controller Adapter,a:b4,b:b0,dpdown:b56,dpleft:b60,dpright:b52,dpup:b48,lefttrigger:a12,leftx:a0,lefty:a4,rightshoulder:b28,righttrigger:a16,rightx:a20,righty:a8,start:b36,x:b8,y:b12,platform:Mac OS X, 03000000ad1b000001f9000000000000,Gamestop BB-070 X360 Controller,a:b0,b:b1,back:b9,dpdown:b12,dpleft:b13,dpright:b14,dpup:b11,guide:b10,leftshoulder:b4,leftstick:b6,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b7,righttrigger:a5,rightx:a3,righty:a4,start:b8,x:b2,y:b3,platform:Mac OS X, 0500000047532047616d657061640000,GameStop Gamepad,a:b0,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b2,y:b3,platform:Mac OS X, 03000000c01100000140000000010000,GameStop PS4 Fun Controller,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:a3,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:a4,rightx:a2,righty:a5,start:b9,x:b0,y:b3,platform:Mac OS X, 030000006f0e00000102000000000000,GameStop Xbox 360 Wired Controller,a:b0,b:b1,back:b9,dpdown:b12,dpleft:b13,dpright:b14,dpup:b11,guide:b10,leftshoulder:b4,leftstick:b6,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b7,righttrigger:a5,rightx:a3,righty:a4,start:b8,x:b2,y:b3,platform:Mac OS X, 030000007d0400000540000001010000,Gravis Eliminator GamePad Pro,a:b1,b:b2,back:b8,leftshoulder:b4,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,righttrigger:b7,start:b9,x:b0,y:b3,platform:Mac OS X, -030000008f0e00000300000007010000,GreenAsia Inc. USB Joystick,a:b2,b:b3,x:b0,y:b1,back:b8,start:b9,leftshoulder:b4,rightshoulder:b6,dpup:h0.1,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,leftx:a0,lefty:a1,rightx:a3,righty:a2,lefttrigger:b5,righttrigger:b7,platform:Mac OS X, +03000000280400000140000000020000,Gravis Gamepad Pro,a:b1,b:b2,back:b8,dpdown:+a1,dpleft:-a0,dpright:+a0,dpup:-a1,leftshoulder:b4,lefttrigger:b6,rightshoulder:b5,righttrigger:b7,start:b9,x:b0,y:b3,platform:Mac OS X, +030000008f0e00000300000007010000,GreenAsia Inc. USB Joystick,a:b2,b:b3,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,lefttrigger:b5,leftx:a0,lefty:a1,rightshoulder:b6,righttrigger:b7,rightx:a3,righty:a2,start:b9,x:b0,y:b1,platform:Mac OS X, 030000000d0f00002d00000000100000,Hori Fighting Commander 3 Pro,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b0,y:b3,platform:Mac OS X, 030000000d0f00005f00000000010000,Hori Fighting Commander 4 (PS3),a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b0,y:b3,platform:Mac OS X, 030000000d0f00005e00000000010000,Hori Fighting Commander 4 (PS4),a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,lefttrigger:a3,leftx:a0,lefty:a1,rightshoulder:b5,righttrigger:a4,rightx:a2,righty:a5,start:b9,x:b0,y:b3,platform:Mac OS X, @@ -416,11 +437,13 @@ xinput,XInput Controller,a:b0,b:b1,back:b6,dpdown:h0.4,dpleft:h0.8,dpright:h0.2, 03000000380700005082000000010000,Mad Catz FightPad PRO (PS4),a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:a3,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:a4,rightx:a2,righty:a5,start:b9,x:b0,y:b3,platform:Mac OS X, 03000000380700008433000000010000,Mad Catz FightStick TE S+ (PS3),a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b0,y:b3,platform:Mac OS X, 03000000380700008483000000010000,Mad Catz FightStick TE S+ (PS4),a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:a3,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:a4,rightx:a2,righty:a5,start:b9,x:b0,y:b3,platform:Mac OS X, +03000000790000000600000007010000,Marvo GT-004,a:b2,b:b1,x:b3,y:b0,back:b8,start:b9,leftstick:b10,rightstick:b11,leftshoulder:b4,rightshoulder:b5,dpup:h0.1,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,leftx:a0,lefty:a1,rightx:a2,righty:a3,lefttrigger:b6,righttrigger:b7,platform:Mac OS X, 03000000790000004418000000010000,Mayflash GameCube Controller,a:b1,b:b2,dpdown:b14,dpleft:b15,dpright:b13,dpup:b12,lefttrigger:a3,leftx:a0,lefty:a1,rightshoulder:b7,righttrigger:a4,rightx:a5,righty:a2,start:b9,x:b0,y:b3,platform:Mac OS X, 03000000242f00007300000000020000,Mayflash Magic NS,a:b1,b:b4,back:b10,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b6,leftstick:b13,lefttrigger:b8,rightshoulder:b7,rightstick:b14,righttrigger:b9,rightx:a2,righty:a3,start:b11,x:b0,y:b3,platform:Mac OS X, 0300000079000000d218000026010000,Mayflash Magic NS,a:b2,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b3,y:b0,platform:Mac OS X, 03000000d620000010a7000003010000,Mayflash Magic NS,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b0,y:b3,platform:Mac OS X, 0300000025090000e803000000000000,Mayflash Wii Classic Controller,a:b1,b:b0,back:b8,dpdown:b13,dpleft:b12,dpright:b14,dpup:b11,guide:b10,leftshoulder:b4,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b3,y:b2,platform:Mac OS X, +03000000790000000018000000010000,Mayflash Wii U Pro Controller Adapter,a:b4,b:b8,back:b32,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b16,leftstick:b40,lefttrigger:b24,leftx:a0,lefty:a4,rightshoulder:b20,rightstick:b44,righttrigger:b28,rightx:a8,righty:a12,start:b36,x:b0,y:b12,platform:Mac OS X, 03000000790000000018000000000000,Mayflash WiiU Pro Game Controller Adapter (DInput),a:b4,b:b8,back:b32,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b16,leftstick:b40,lefttrigger:b24,leftx:a0,lefty:a4,rightshoulder:b20,rightstick:b44,righttrigger:b28,rightx:a8,righty:a12,start:b36,x:b0,y:b12,platform:Mac OS X, 03000000d8140000cecf000000000000,MC Cthulhu,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,lefttrigger:b6,rightshoulder:b5,righttrigger:b7,start:b9,x:b0,y:b3,platform:Mac OS X, 030000005e0400002700000001010000,Microsoft SideWinder Plug & Play Game Pad,a:b0,b:b1,dpdown:+a1,dpleft:-a0,dpright:+a0,dpup:-a1,lefttrigger:b4,leftx:a0,lefty:a1,righttrigger:b5,x:b2,y:b3,platform:Mac OS X, @@ -428,15 +451,19 @@ xinput,XInput Controller,a:b0,b:b1,back:b6,dpdown:h0.4,dpleft:h0.8,dpright:h0.2, 03000000c62400002a89000000010000,MOGA XP5-A Plus,a:b0,b:b1,back:b10,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b21,leftshoulder:b6,leftstick:b13,lefttrigger:a5,leftx:a0,lefty:a1,rightshoulder:b7,rightstick:b14,righttrigger:a4,rightx:a2,righty:a3,start:b11,x:b3,y:b4,platform:Mac OS X, 03000000c62400002b89000000010000,MOGA XP5-A Plus,a:b0,b:b1,back:b10,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b6,leftstick:b13,lefttrigger:a5,leftx:a0,lefty:a1,rightshoulder:b7,rightstick:b14,righttrigger:a4,rightx:a2,righty:a3,start:b11,x:b3,y:b4,platform:Mac OS X, 03000000632500007505000000020000,NEOGEO mini PAD Controller,a:b1,b:b0,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,start:b9,x:b2,y:b3,platform:Mac OS X, +03000000921200004b46000003020000,NES 2-port Adapter,a:b1,b:b0,back:b10,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,start:b11,platform:Mac OS X, 030000001008000001e5000006010000,NEXT SNES Controller,a:b2,b:b1,back:b8,dpdown:+a1,dpleft:-a0,dpright:+a0,dpup:-a1,leftshoulder:b4,rightshoulder:b5,righttrigger:b6,start:b9,x:b3,y:b0,platform:Mac OS X, 03000000d620000011a7000000020000,Nintendo Switch Core (Plus) Wired Controller,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b0,y:b3,platform:Mac OS X, +03000000d620000011a7000010050000,Nintendo Switch PowerA Wired Controller,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b0,y:b3,platform:Mac OS X, 030000007e0500000920000000000000,Nintendo Switch Pro Controller,a:b0,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b2,y:b3,platform:Mac OS X, 030000007e0500000920000001000000,Nintendo Switch Pro Controller,a:b0,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b2,y:b3,platform:Mac OS X, 03000000550900001472000025050000,NVIDIA Controller v01.04,a:b0,b:b1,back:b17,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b15,leftshoulder:b4,leftstick:b7,lefttrigger:a3,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b8,righttrigger:a4,rightx:a2,righty:a5,start:b6,x:b2,y:b3,platform:Mac OS X, 030000006f0e00000901000002010000,PDP Versus Fighting Pad,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,lefttrigger:b6,rightshoulder:b5,righttrigger:b7,start:b9,x:b0,y:b3,platform:Mac OS X, 030000008f0e00000300000000000000,Piranha xtreme,a:b2,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b6,leftstick:b10,lefttrigger:b4,leftx:a0,lefty:a1,rightshoulder:b7,rightstick:b11,righttrigger:b5,rightx:a3,righty:a2,start:b9,x:b3,y:b0,platform:Mac OS X, 030000004c050000da0c000000010000,Playstation Classic Controller,a:b2,b:b1,back:b8,leftshoulder:b6,lefttrigger:b4,leftx:a0,lefty:a1,rightshoulder:b7,righttrigger:b5,start:b9,x:b3,y:b0,platform:Mac OS X, +030000004c0500003713000000010000,PlayStation Vita,a:b1,b:b2,back:b8,dpdown:b13,dpleft:b15,dpright:b14,dpup:b12,leftshoulder:b4,leftx:a0,lefty:a1,rightshoulder:b5,rightx:a3,righty:a4,start:b9,x:b0,y:b3,platform:Mac OS X, 03000000d62000006dca000000010000,PowerA Pro Ex,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b0,y:b3,platform:Mac OS X, +03000000100800000300000006010000,PS2 Adapter,a:b2,b:b1,back:b8,leftshoulder:b6,leftstick:b10,lefttrigger:b4,leftx:a0,lefty:a1,rightshoulder:b7,rightstick:b11,righttrigger:b5,rightx:a4,righty:a3,start:b9,x:b3,y:b0,platform:Mac OS X, 030000004c0500006802000000000000,PS3 Controller,a:b14,b:b13,back:b0,dpdown:b6,dpleft:b7,dpright:b5,dpup:b4,guide:b16,leftshoulder:b10,leftstick:b1,lefttrigger:b8,leftx:a0,lefty:a1,rightshoulder:b11,rightstick:b2,righttrigger:b9,rightx:a2,righty:a3,start:b3,x:b15,y:b12,platform:Mac OS X, 030000004c0500006802000000010000,PS3 Controller,a:b14,b:b13,back:b0,dpdown:b6,dpleft:b7,dpright:b5,dpup:b4,guide:b16,leftshoulder:b10,leftstick:b1,lefttrigger:b8,leftx:a0,lefty:a1,rightshoulder:b11,rightstick:b2,righttrigger:b9,rightx:a2,righty:a3,start:b3,x:b15,y:b12,platform:Mac OS X, 030000004c050000a00b000000010000,PS4 Controller,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:a3,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:a4,rightx:a2,righty:a5,start:b9,x:b0,y:b3,platform:Mac OS X, @@ -487,9 +514,11 @@ xinput,XInput Controller,a:b0,b:b1,back:b6,dpdown:h0.4,dpleft:h0.8,dpright:h0.2, 050000005769696d6f74652028303000,Wii Remote,a:b4,b:b5,back:b7,dpdown:b3,dpleft:b0,dpright:b1,dpup:b2,guide:b8,leftshoulder:b11,lefttrigger:b12,leftx:a0,lefty:a1,start:b6,x:b10,y:b9,platform:Mac OS X, 050000005769696d6f74652028313800,Wii U Pro Controller,a:b16,b:b15,back:b7,dpdown:b12,dpleft:b13,dpright:b14,dpup:b11,guide:b8,leftshoulder:b19,leftstick:b23,lefttrigger:b21,leftx:a0,lefty:a1,rightshoulder:b20,rightstick:b24,righttrigger:b22,rightx:a2,righty:a3,start:b6,x:b18,y:b17,platform:Mac OS X, 030000005e0400008e02000000000000,X360 Controller,a:b0,b:b1,back:b9,dpdown:b12,dpleft:b13,dpright:b14,dpup:b11,guide:b10,leftshoulder:b4,leftstick:b6,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b7,righttrigger:a5,rightx:a3,righty:a4,start:b8,x:b2,y:b3,platform:Mac OS X, +030000006f0e00000104000000000000,Xbox 360 Wired Controller,a:b0,b:b1,back:b9,dpdown:b12,dpleft:b13,dpright:b14,dpup:b11,guide:b10,leftshoulder:b4,leftstick:b6,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b7,righttrigger:a5,rightx:a3,righty:a4,start:b8,x:b2,y:b3,platform:Mac OS X, 03000000c6240000045d000000000000,Xbox 360 Wired Controller,a:b0,b:b1,back:b9,dpdown:b12,dpleft:b13,dpright:b14,dpup:b11,guide:b10,leftshoulder:b4,leftstick:b6,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b7,righttrigger:a5,rightx:a3,righty:a4,start:b8,x:b2,y:b3,platform:Mac OS X, 030000005e0400000a0b000000000000,Xbox Adaptive Controller,a:b0,b:b1,back:b9,dpdown:b12,dpleft:b13,dpright:b14,dpup:b11,guide:b10,leftshoulder:b4,leftstick:b6,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b7,righttrigger:a5,rightx:a3,righty:a4,start:b8,x:b2,y:b3,platform:Mac OS X, 030000005e040000050b000003090000,Xbox Elite Wireless Controller Series 2,a:b0,b:b1,back:b31,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b53,leftshoulder:b6,leftstick:b13,lefttrigger:a6,leftx:a0,lefty:a1,rightshoulder:b7,rightstick:b14,righttrigger:a5,rightx:a2,righty:a3,start:b11,x:b3,y:b4,platform:Mac OS X, +03000000c62400003a54000000000000,Xbox One PowerA Wired Controller,a:b0,b:b1,back:b9,dpdown:b12,dpleft:b13,dpright:b14,dpup:b11,guide:b10,leftshoulder:b4,leftstick:b6,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b7,righttrigger:a5,rightx:a3,righty:a4,start:b8,x:b2,y:b3,platform:Mac OS X, 030000005e040000d102000000000000,Xbox One Wired Controller,a:b0,b:b1,back:b9,dpdown:b12,dpleft:b13,dpright:b14,dpup:b11,guide:b10,leftshoulder:b4,leftstick:b6,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b7,righttrigger:a5,rightx:a3,righty:a4,start:b8,x:b2,y:b3,platform:Mac OS X, 030000005e040000dd02000000000000,Xbox One Wired Controller,a:b0,b:b1,back:b9,dpdown:b12,dpleft:b13,dpright:b14,dpup:b11,guide:b10,leftshoulder:b4,leftstick:b6,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b7,righttrigger:a5,rightx:a3,righty:a4,start:b8,x:b2,y:b3,platform:Mac OS X, 030000005e040000e302000000000000,Xbox One Wired Controller,a:b0,b:b1,back:b9,dpdown:b12,dpleft:b13,dpright:b14,dpup:b11,guide:b10,leftshoulder:b4,leftstick:b6,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b7,righttrigger:a5,rightx:a3,righty:a4,start:b8,x:b2,y:b3,platform:Mac OS X, @@ -545,18 +574,28 @@ xinput,XInput Controller,a:b0,b:b1,back:b6,dpdown:h0.4,dpleft:h0.8,dpright:h0.2, 03000000100000008200000011010000,Akishop Customs PS360+ v1.66,a:b1,b:b2,back:b12,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b8,leftshoulder:b4,lefttrigger:b6,rightshoulder:b5,righttrigger:b7,start:b9,x:b0,y:b3,platform:Linux, 030000007c1800000006000010010000,Alienware Dual Compatible Game Pad,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a3,righty:a2,start:b9,x:b0,y:b3,platform:Linux, 05000000491900000204000021000000,Amazon Fire Game Controller,a:b0,b:b1,back:b10,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b17,leftshoulder:b6,leftstick:b13,lefttrigger:a5,leftx:a0,lefty:a1,misc1:b12,rightshoulder:b7,rightstick:b14,righttrigger:a4,rightx:a2,righty:a3,start:b11,x:b3,y:b4,platform:Linux, +03000000491900001904000011010000,Amazon Luna Controller,a:b0,b:b1,back:b6,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b8,leftshoulder:b4,leftstick:b10,lefttrigger:a3,leftx:a0,lefty:a1,misc1:b9,rightshoulder:b5,rightstick:b11,righttrigger:a4,rightx:a2,righty:a5,start:b7,x:b2,y:b3,platform:Linux, +05000000710100001904000000010000,Amazon Luna Controller,a:b0,b:b1,back:b9,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b10,leftshoulder:b4,leftstick:b7,lefttrigger:a5,leftx:a0,lefty:a1,misc1:b11,rightshoulder:b5,rightstick:b8,righttrigger:a4,rightx:a2,righty:a3,start:b6,x:b2,y:b3,platform:Linux, 03000000790000003018000011010000,Arcade Fightstick F300,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,righttrigger:b7,start:b9,x:b0,y:b3,platform:Linux, +03000000a30c00002700000011010000,Astro City Mini,a:b2,b:b1,back:b8,leftx:a0,lefty:a1,rightshoulder:b4,righttrigger:b5,start:b9,x:b3,y:b0,platform:Linux, +03000000a30c00002800000011010000,Astro City Mini,a:b2,b:b1,back:b8,leftx:a0,lefty:a1,rightshoulder:b4,righttrigger:b5,start:b9,x:b3,y:b0,platform:Linux, 05000000050b00000045000031000000,ASUS Gamepad,a:b0,b:b1,back:b9,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b6,leftshoulder:b4,leftstick:b7,lefttrigger:a5,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b8,righttrigger:a4,rightx:a2,righty:a3,start:b10,x:b2,y:b3,platform:Linux, 05000000050b00000045000040000000,ASUS Gamepad,a:b0,b:b1,back:b9,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b6,leftshoulder:b4,leftstick:b7,lefttrigger:a5,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b8,righttrigger:a4,rightx:a2,righty:a3,start:b10,x:b2,y:b3,platform:Linux, +03000000503200000110000000000000,Atari Classic Controller,a:b0,back:b2,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b4,start:b3,x:b1,platform:Linux, +05000000503200000110000000000000,Atari Classic Controller,a:b0,back:b2,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b4,start:b3,x:b1,platform:Linux, +03000000503200000210000000000000,Atari Game Controller,a:b0,b:b1,back:b6,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b8,leftshoulder:b4,leftstick:b9,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b10,righttrigger:a5,rightx:a3,righty:a4,start:b7,x:b3,y:b2,platform:Linux, +05000000503200000210000000000000,Atari Game Controller,a:b0,b:b1,back:b6,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b8,leftshoulder:b4,leftstick:b9,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b10,righttrigger:a5,rightx:a3,righty:a4,start:b7,x:b3,y:b2,platform:Linux, 03000000120c00000500000010010000,AxisPad,a:b2,b:b3,back:b10,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b8,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b9,righttrigger:b7,rightx:a3,righty:a2,start:b11,x:b0,y:b1,platform:Linux, +03000000ef0500000300000000010000,AxisPad,a:b2,b:b3,back:b10,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b8,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b9,righttrigger:b7,rightx:a3,righty:a2,start:b11,x:b0,y:b1,platform:Linux, 03000000c62400001b89000011010000,BDA MOGA XP5-X Plus,a:b0,b:b1,back:b10,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b6,leftstick:b13,lefttrigger:a5,leftx:a0,lefty:a1,rightshoulder:b7,rightstick:b14,righttrigger:a4,rightx:a2,righty:a3,start:b11,x:b3,y:b4,platform:Linux, 03000000d62000002a79000011010000,BDA PS4 Fightpad,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:a3,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:a4,rightx:a2,righty:a5,start:b9,x:b0,y:b3,platform:Linux, 03000000c21100000791000011010000,Be1 GC101 Controller 1.03 mode,a:b2,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b3,y:b0,platform:Linux, 03000000c31100000791000011010000,Be1 GC101 GAMEPAD 1.03 mode,a:b0,b:b1,back:b10,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b6,leftstick:b13,lefttrigger:a5,leftx:a0,lefty:a1,rightshoulder:b7,rightstick:b14,righttrigger:a4,rightx:a2,righty:a3,start:b11,x:b3,y:b4,platform:Linux, 030000005e0400008e02000003030000,Be1 GC101 Xbox 360 Controller mode,a:b0,b:b1,back:b6,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b8,leftshoulder:b4,leftstick:b9,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b10,righttrigger:a5,rightx:a3,righty:a4,start:b7,x:b2,y:b3,platform:Linux, 03000000666600006706000000010000,boom PSX to PC Converter,a:b2,b:b1,back:b8,dpdown:b14,dpleft:b15,dpright:b13,dpup:b12,leftshoulder:b6,leftstick:b9,lefttrigger:b4,leftx:a0,lefty:a1,rightshoulder:b7,rightstick:b10,righttrigger:b5,rightx:a2,righty:a3,start:b11,x:b3,y:b0,platform:Linux, -03000000120c0000200e000011010000,Brook Mars,a:b1,b:b2,x:b0,y:b3,back:b8,guide:b12,start:b9,leftstick:b10,rightstick:b11,leftshoulder:b4,rightshoulder:b5,dpup:h0.1,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,leftx:a0,lefty:a1,rightx:a2,righty:a5,lefttrigger:a3,righttrigger:a4,platform:Linux, -03000000120c0000210e000011010000,Brook Mars,a:b1,b:b2,x:b0,y:b3,back:b8,guide:b12,start:b9,leftstick:b10,rightstick:b11,leftshoulder:b4,rightshoulder:b5,dpup:h0.1,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,leftx:a0,lefty:a1,rightx:a2,righty:a3,lefttrigger:b6,righttrigger:b7,platform:Linux, +03000000120c0000200e000011010000,Brook Mars,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:a3,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:a4,rightx:a2,righty:a5,start:b9,x:b0,y:b3,platform:Linux, +03000000120c0000210e000011010000,Brook Mars,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b0,y:b3,platform:Linux, +03000000120c0000f70e000011010000,Brook Universal Fighting Board,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:b6,rightshoulder:b5,rightstick:b11,righttrigger:b7,start:b9,x:b0,y:b3,platform:Linux, 03000000ffff0000ffff000000010000,Chinese-made Xbox Controller,a:b0,b:b1,back:b6,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b5,leftstick:b8,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b2,rightstick:b9,righttrigger:a5,rightx:a3,righty:a4,start:b7,x:b3,y:b4,platform:Linux, 03000000e82000006058000001010000,Cideko AK08b,a:b2,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b3,y:b0,platform:Linux, 030000000b0400003365000000010000,Competition Pro,a:b0,b:b1,back:b2,leftx:a0,lefty:a1,start:b3,platform:Linux, @@ -621,6 +660,7 @@ xinput,XInput Controller,a:b0,b:b1,back:b6,dpdown:h0.4,dpleft:h0.8,dpright:h0.2, 050000007e0500000620000001000000,Joy-Con (L),+leftx:h0.2,+lefty:h0.4,-leftx:h0.8,-lefty:h0.1,a:b0,b:b1,back:b13,leftshoulder:b4,leftstick:b10,rightshoulder:b5,start:b8,x:b2,y:b3,platform:Linux, 030000007e0500000720000001000000,Joy-Con (R),+leftx:h0.2,+lefty:h0.4,-leftx:h0.8,-lefty:h0.1,a:b0,b:b1,back:b12,leftshoulder:b4,leftstick:b11,rightshoulder:b5,start:b9,x:b2,y:b3,platform:Linux, 050000007e0500000720000001000000,Joy-Con (R),+leftx:h0.2,+lefty:h0.4,-leftx:h0.8,-lefty:h0.1,a:b0,b:b1,back:b12,leftshoulder:b4,leftstick:b11,rightshoulder:b5,start:b9,x:b2,y:b3,platform:Linux, +03000000bd12000003c0000010010000,Joypad Alpha Shock,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b0,y:b3,platform:Linux, 03000000242f00002d00000011010000,JYS Wireless Adapter,a:b2,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b3,y:b0,platform:Linux, 03000000242f00008a00000011010000,JYS Wireless Adapter,a:b1,b:b4,back:b10,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b6,leftstick:b13,lefttrigger:b8,rightshoulder:b7,rightstick:b14,righttrigger:b9,rightx:a2,righty:a3,start:b11,x:b0,y:b3,platform:Linux, 030000006f0e00000103000000020000,Logic3 Controller,a:b0,b:b1,back:b6,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b8,leftshoulder:b4,leftstick:b9,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b10,righttrigger:a5,rightx:a3,righty:a4,start:b7,x:b2,y:b3,platform:Linux, @@ -650,8 +690,9 @@ xinput,XInput Controller,a:b0,b:b1,back:b6,dpdown:h0.4,dpleft:h0.8,dpright:h0.2, 03000000ad1b000016f0000090040000,Mad Catz Xbox 360 Controller,a:b0,b:b1,back:b6,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b8,leftshoulder:b4,leftstick:b9,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b10,righttrigger:a5,rightx:a3,righty:a4,start:b7,x:b2,y:b3,platform:Linux, 03000000380700001888000010010000,MadCatz PC USB Wired Stick 8818,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b0,y:b3,platform:Linux, 03000000380700003888000010010000,MadCatz PC USB Wired Stick 8838,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:a0,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b0,y:b3,platform:Linux, +03000000242f0000f700000001010000,Magic-S Pro,a:b0,b:b1,back:b6,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b8,leftshoulder:b4,leftstick:b9,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b10,righttrigger:a5,rightx:a3,righty:a4,start:b7,x:b2,y:b3,platform:Linux, 03000000120c00000500000000010000,Manta Dualshock 2,a:b0,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a3,righty:a2,start:b9,x:b2,y:b3,platform:Linux, -03000000790000004418000010010000,Mayflash GameCube Controller,a:b1,b:b2,dpdown:b14,dpleft:b15,dpright:b13,dpup:b12,lefttrigger:a3,leftx:a0,lefty:a1,rightshoulder:b7,righttrigger:a4,rightx:a5,righty:a2,start:b9,x:b0,y:b3,platform:Linux, +03000000790000004418000010010000,Mayflash GameCube Controller,a:b1,b:b0,dpdown:b14,dpleft:b15,dpright:b13,dpup:b12,lefttrigger:a3,leftx:a0,lefty:a1,rightshoulder:b7,righttrigger:a4,rightx:a5,righty:a2,start:b9,x:b2,y:b3,platform:Linux, 03000000790000004318000010010000,Mayflash GameCube Controller Adapter,a:b1,b:b2,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,lefttrigger:a3,leftx:a0,lefty:a1,rightshoulder:b7,righttrigger:a4,rightx:a5,righty:a2,start:b9,x:b0,y:b3,platform:Linux, 03000000242f00007300000011010000,Mayflash Magic NS,a:b1,b:b4,back:b10,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b6,leftstick:b13,lefttrigger:b8,rightshoulder:b7,rightstick:b14,righttrigger:b9,rightx:a2,righty:a3,start:b11,x:b0,y:b3,platform:Linux, 0300000079000000d218000011010000,Mayflash Magic NS,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b0,y:b3,platform:Linux, @@ -681,15 +722,18 @@ xinput,XInput Controller,a:b0,b:b1,back:b6,dpdown:h0.4,dpleft:h0.8,dpright:h0.2, 03000000250900006688000000010000,MP-8866 Super Dual Box,a:b2,b:b1,back:b9,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b6,leftstick:b10,lefttrigger:b4,leftx:a0,lefty:a1,rightshoulder:b7,rightstick:b11,righttrigger:b5,rightx:a2,righty:a3,start:b8,x:b3,y:b0,platform:Linux, 030000006b140000010c000010010000,NACON GC-400ES,a:b0,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b2,y:b3,platform:Linux, 030000000d0f00000900000010010000,Natec Genesis P44,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b0,y:b3,platform:Linux, +03000000790000004518000010010000,NEXILUX GAMECUBE Controller Adapter,a:b1,b:b0,x:b2,y:b3,start:b9,rightshoulder:b7,dpup:h0.1,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,leftx:a0,lefty:a1,rightx:a5,righty:a2,lefttrigger:a3,righttrigger:a4,platform:Linux, 030000001008000001e5000010010000,NEXT SNES Controller,a:b2,b:b1,back:b8,dpdown:+a1,dpleft:-a0,dpright:+a0,dpup:-a1,leftshoulder:b4,rightshoulder:b5,righttrigger:b6,start:b9,x:b3,y:b0,platform:Linux, +060000007e0500003713000000000000,Nintendo 3DS,a:b0,b:b1,back:b8,dpdown:b11,dpleft:b12,dpright:b13,dpup:b10,leftshoulder:b4,leftx:a0,lefty:a1,rightshoulder:b5,rightx:a2,righty:a3,start:b9,x:b3,y:b2,platform:Linux, 060000007e0500000820000000000000,Nintendo Combined Joy-Cons (joycond),a:b0,b:b1,back:b9,dpdown:b15,dpleft:b16,dpright:b17,dpup:b14,guide:b11,leftshoulder:b5,leftstick:b12,lefttrigger:b7,leftx:a0,lefty:a1,rightshoulder:b6,rightstick:b13,righttrigger:b8,rightx:a2,righty:a3,start:b10,x:b3,y:b2,platform:Linux, 030000007e0500003703000000016800,Nintendo GameCube Controller,a:b0,b:b2,dpdown:b6,dpleft:b4,dpright:b5,dpup:b7,lefttrigger:a4,leftx:a0,lefty:a1~,rightshoulder:b9,righttrigger:a5,rightx:a2,righty:a3~,start:b8,x:b1,y:b3,platform:Linux, -03000000790000004618000010010000,Nintendo GameCube Controller Adapter,a:b1,b:b2,dpdown:b14,dpleft:b15,dpright:b13,dpup:b12,lefttrigger:b4,leftx:a0,lefty:a1,rightshoulder:b7,righttrigger:b5,rightx:a5~,righty:a2~,start:b9,x:b0,y:b3,platform:Linux, -050000007e0500000620000001800000,Nintendo Switch Left Joy-Con,a:b9,b:b8,x:b7,y:b10,back:b5,start:b0,leftstick:b6,leftshoulder:b2,rightshoulder:b4,leftx:a1,lefty:a0~,platform:Linux, -050000007e0500000720000001800000,Nintendo Switch Right Joy-Con,a:b1,b:b2,x:b0,y:b3,back:b9,start:b8,leftstick:b10,leftshoulder:b4,rightshoulder:b6,leftx:a1~,lefty:a0~,platform:Linux, +03000000790000004618000010010000,Nintendo GameCube Controller Adapter,a:b1,b:b0,dpdown:b14,dpleft:b15,dpright:b13,dpup:b12,lefttrigger:b4,leftx:a0,lefty:a1,rightshoulder:b7,righttrigger:b5,rightx:a5~,righty:a2~,start:b9,x:b2,y:b3,platform:Linux, +050000007e0500000620000001800000,Nintendo Switch Left Joy-Con,a:b9,b:b8,back:b5,leftshoulder:b2,leftstick:b6,leftx:a1,lefty:a0~,rightshoulder:b4,start:b0,x:b7,y:b10,platform:Linux, +030000007e0500000920000011810000,Nintendo Switch Pro Controller,a:b0,b:b1,back:b9,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b11,leftshoulder:b5,leftstick:b12,lefttrigger:b7,leftx:a0,lefty:a1,rightshoulder:b6,rightstick:b13,righttrigger:b8,rightx:a2,righty:a3,start:b10,x:b3,y:b2,platform:Linux, 050000007e0500000920000001000000,Nintendo Switch Pro Controller,a:b0,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b2,y:b3,platform:Linux, 050000007e0500000920000001800000,Nintendo Switch Pro Controller,a:b0,b:b1,back:b9,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b11,leftshoulder:b5,leftstick:b12,lefttrigger:b7,leftx:a0,lefty:a1,rightshoulder:b6,rightstick:b13,righttrigger:b8,rightx:a2,righty:a3,start:b10,x:b3,y:b2,platform:Linux, -030000007e0500000920000011810000,Nintendo Switch Pro Controller,a:b0,b:b1,back:b9,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b11,leftshoulder:b5,leftstick:b12,lefttrigger:b7,leftx:a0,lefty:a1,rightshoulder:b6,rightstick:b13,righttrigger:b8,rightx:a2,righty:a3,start:b10,x:b3,y:b2,platform:Linux, +050000007e0500000720000001800000,Nintendo Switch Right Joy-Con,a:b1,b:b2,back:b9,leftshoulder:b4,leftstick:b10,leftx:a1~,lefty:a0~,rightshoulder:b6,start:b8,x:b0,y:b3,platform:Linux, +050000007e0500001720000001000000,Nintendo Switch SNES Controller,a:b0,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,rightshoulder:b5,start:b9,x:b2,y:b3,platform:Linux, 050000007e0500003003000001000000,Nintendo Wii Remote Pro Controller,a:b0,b:b1,back:b8,dpdown:b14,dpleft:b15,dpright:b16,dpup:b13,guide:b10,leftshoulder:b4,leftstick:b11,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b12,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b3,y:b2,platform:Linux, 05000000010000000100000003000000,Nintendo Wiimote,a:b0,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b10,leftshoulder:b4,leftstick:b11,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b12,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b2,y:b3,platform:Linux, 030000000d0500000308000010010000,Nostromo n45 Dual Analog Gamepad,a:b0,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b9,leftshoulder:b4,leftstick:b12,lefttrigger:b5,leftx:a0,lefty:a1,rightshoulder:b6,rightstick:b11,righttrigger:b7,rightx:a3,righty:a2,start:b10,x:b2,y:b3,platform:Linux, @@ -717,8 +761,9 @@ xinput,XInput Controller,a:b0,b:b1,back:b6,dpdown:h0.4,dpleft:h0.8,dpright:h0.2, 030000006f0e0000a802000023020000,PDP Wired Controller for Xbox One,a:b0,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b10,leftshoulder:b4,leftstick:b11,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b12,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b2,y:b3,platform:Linux, 030000006f0e00008501000011010000,PDP Wired Fight Pad Pro for Nintendo Switch,a:b2,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b3,y:b0,platform:Linux, 0500000049190000030400001b010000,PG-9099,a:b0,b:b1,back:b10,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b6,leftstick:b13,lefttrigger:b8,leftx:a0,lefty:a1,rightshoulder:b7,rightstick:b14,righttrigger:b9,rightx:a2,righty:a3,start:b11,x:b3,y:b4,platform:Linux, -05000000491900000204000000000000,PG-9118,a:b73,b:b74,back:b83,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b79,leftstick:b86,lefttrigger:b81,leftx:a0,lefty:a1,rightshoulder:b80,rightstick:b87,righttrigger:b82,rightx:a2,righty:a3,start:b84,x:b76,y:b77,platform:Linux, +05000000491900000204000000000000,PG-9118,a:b0,b:b1,back:b10,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b6,leftstick:b13,lefttrigger:a5,leftx:a0,lefty:a1,rightshoulder:b7,rightstick:b14,righttrigger:a4,rightx:a2,righty:a3,start:b11,x:b3,y:b4,platform:Linux, 030000004c050000da0c000011010000,Playstation Controller,a:b2,b:b1,back:b8,leftshoulder:b6,lefttrigger:b4,leftx:a0,lefty:a1,rightshoulder:b7,righttrigger:b5,start:b9,x:b3,y:b0,platform:Linux, +030000004c0500003713000011010000,PlayStation Vita,a:b1,b:b2,back:b8,dpdown:b13,dpleft:b15,dpright:b14,dpup:b12,leftshoulder:b4,leftx:a0,lefty:a1,rightshoulder:b5,rightx:a3,righty:a4,start:b9,x:b0,y:b3,platform:Linux, 03000000c62400000053000000010000,PowerA,a:b0,b:b1,back:b6,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b8,leftshoulder:b4,leftstick:b9,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b10,righttrigger:a5,rightx:a3,righty:a4,start:b7,x:b2,y:b3,platform:Linux, 03000000c62400003a54000001010000,PowerA 1428124-01,a:b0,b:b1,back:b6,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b8,leftshoulder:b4,leftstick:b9,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b10,righttrigger:a5,rightx:a3,righty:a4,start:b7,x:b2,y:b3,platform:Linux, 03000000d62000006dca000011010000,PowerA Pro Ex,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b0,y:b3,platform:Linux, @@ -734,6 +779,7 @@ xinput,XInput Controller,a:b0,b:b1,back:b6,dpdown:h0.4,dpleft:h0.8,dpright:h0.2, 030000004c0500006802000011810000,PS3 Controller,a:b0,b:b1,back:b8,dpdown:b14,dpleft:b15,dpright:b16,dpup:b13,guide:b10,leftshoulder:b4,leftstick:b11,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b12,righttrigger:a5,rightx:a3,righty:a4,start:b9,x:b3,y:b2,platform:Linux, 030000006f0e00001402000011010000,PS3 Controller,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b0,y:b3,platform:Linux, 030000008f0e00000300000010010000,PS3 Controller,a:b2,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b3,y:b0,platform:Linux, +050000004c0500006802000000000000,PS3 Controller,a:b14,b:b13,back:b0,dpdown:b6,dpleft:b7,dpright:b5,dpup:b4,guide:b16,leftshoulder:b10,leftstick:b1,lefttrigger:b8,leftx:a0,lefty:a1,rightshoulder:b11,rightstick:b2,righttrigger:b9,rightx:a2,righty:a3,start:b3,x:b15,y:b12,platform:Linux, 050000004c0500006802000000010000,PS3 Controller,a:b14,b:b13,back:b0,dpdown:b6,dpleft:b7,dpright:b5,dpup:b4,guide:b16,leftshoulder:b10,leftstick:b1,lefttrigger:a12,leftx:a0,lefty:a1,rightshoulder:b11,rightstick:b2,righttrigger:a13,rightx:a2,righty:a3,start:b3,x:b15,y:b12,platform:Linux, 050000004c0500006802000000800000,PS3 Controller,a:b0,b:b1,back:b8,dpdown:b14,dpleft:b15,dpright:b16,dpup:b13,guide:b10,leftshoulder:b4,leftstick:b11,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b12,righttrigger:a5,rightx:a3,righty:a4,start:b9,x:b3,y:b2,platform:Linux, 050000004c0500006802000000810000,PS3 Controller,a:b0,b:b1,back:b8,dpdown:b14,dpleft:b15,dpright:b16,dpup:b13,guide:b10,leftshoulder:b4,leftstick:b11,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b12,righttrigger:a5,rightx:a3,righty:a4,start:b9,x:b3,y:b2,platform:Linux, @@ -755,7 +801,9 @@ xinput,XInput Controller,a:b0,b:b1,back:b6,dpdown:h0.4,dpleft:h0.8,dpright:h0.2, 050000004c050000cc09000001800000,PS4 Controller,a:b0,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b10,leftshoulder:b4,leftstick:b11,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b12,righttrigger:a5,rightx:a3,righty:a4,start:b9,x:b3,y:b2,platform:Linux, 030000004c050000e60c000011010000,PS5 Controller,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:a3,leftx:a0,lefty:a1,misc1:b13,rightshoulder:b5,rightstick:b11,righttrigger:a4,rightx:a2,righty:a5,start:b9,x:b0,y:b3,platform:Linux, 050000004c050000e60c000000010000,PS5 Controller,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:a3,leftx:a0,lefty:a1,misc1:b13,rightshoulder:b5,rightstick:b11,righttrigger:a4,rightx:a2,righty:a5,start:b9,x:b0,y:b3,platform:Linux, +03000000ff000000cb01000010010000,PSP,a:b0,b:b1,back:b6,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftx:a0,lefty:a1,rightshoulder:b5,start:b7,x:b2,y:b3,platform:Linux, 03000000300f00001211000011010000,QanBa Arcade JoyStick,a:b2,b:b0,back:b10,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b8,leftshoulder:b5,lefttrigger:b4,leftx:a0,lefty:a1,rightshoulder:b7,righttrigger:b6,start:b9,x:b1,y:b3,platform:Linux, +030000009b2800004200000001010000,Raphnet Technologies Dual NES to USB v2.0,a:b0,b:b1,back:b2,dpdown:+a1,dpleft:-a0,dpright:+a0,dpup:-a1,start:b3,platform:Linux, 030000009b2800003200000001010000,Raphnet Technologies GC/N64 to USB v3.4,a:b0,b:b7,dpdown:b11,dpleft:b12,dpright:b13,dpup:b10,lefttrigger:b4,leftx:a0,lefty:a1,rightshoulder:b2,righttrigger:b5,rightx:a3,righty:a4,start:b3,x:b1,y:b8,platform:Linux, 030000009b2800006000000001010000,Raphnet Technologies GC/N64 to USB v3.6,a:b0,b:b7,dpdown:b11,dpleft:b12,dpright:b13,dpup:b10,lefttrigger:b4,leftx:a0,lefty:a1,rightshoulder:b2,righttrigger:b5,rightx:a3,righty:a4,start:b3,x:b1,y:b8,platform:Linux, 030000009b2800000300000001010000,raphnet.net 4nes4snes v1.5,a:b0,b:b4,back:b2,leftshoulder:b6,leftx:a0,lefty:a1,rightshoulder:b7,start:b3,x:b1,y:b5,platform:Linux, @@ -792,7 +840,6 @@ xinput,XInput Controller,a:b0,b:b1,back:b6,dpdown:h0.4,dpleft:h0.8,dpright:h0.2, 03000000a306000018f5000010010000,Saitek PLC Saitek P3200 Rumble Pad,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b10,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a3,righty:a4,start:b9,x:b0,y:b3,platform:Linux, 03000000a306000020f6000011010000,Saitek PS2700 Rumble Pad,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a4,start:b9,x:b0,y:b3,platform:Linux, 03000000d81d00000e00000010010000,Savior,a:b0,b:b1,back:b8,leftshoulder:b6,leftstick:b10,lefttrigger:b7,leftx:a0,lefty:a1,rightshoulder:b2,rightstick:b11,righttrigger:b3,start:b9,x:b4,y:b5,platform:Linux, -03000000c01600008704000011010000,Serial/Keyboard/Mouse/Joystick,a:b12,b:b10,back:b4,dpdown:b2,dpleft:b3,dpright:b1,dpup:b0,leftshoulder:b9,leftstick:b14,lefttrigger:b6,leftx:a1,lefty:a0,rightshoulder:b8,rightstick:b15,righttrigger:b7,rightx:a2,righty:a3,start:b5,x:b13,y:b11,platform:Linux, 03000000f025000021c1000010010000,ShanWan Gioteck PS3 Wired Controller,a:b2,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b3,y:b0,platform:Linux, 03000000632500007505000010010000,SHANWAN PS3/PC Gamepad,a:b2,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b3,y:b0,platform:Linux, 03000000bc2000000055000010010000,ShanWan PS3/PC Wired GamePad,a:b0,b:b1,back:b10,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b6,leftstick:b13,lefttrigger:a5,leftx:a0,lefty:a1,rightshoulder:b7,rightstick:b14,righttrigger:a4,rightx:a2,righty:a3,start:b11,x:b3,y:b4,platform:Linux, @@ -800,17 +847,15 @@ xinput,XInput Controller,a:b0,b:b1,back:b6,dpdown:h0.4,dpleft:h0.8,dpright:h0.2, 03000000632500002305000010010000,ShanWan USB Gamepad,a:b2,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b3,y:b0,platform:Linux, 03000000341a00000908000010010000,SL-6566,a:b0,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b2,y:b3,platform:Linux, 030000004c050000e60c000011810000,Sony DualSense,a:b0,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b10,leftshoulder:b4,leftstick:b11,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b12,righttrigger:a5,rightx:a3,righty:a4,start:b9,x:b3,y:b2,platform:Linux, -030000004c050000e60c000000006800,Sony DualSense,a:b0,b:b1,x:b2,y:b3,back:b4,guide:b5,start:b6,leftstick:b7,rightstick:b8,leftshoulder:b9,rightshoulder:b10,dpup:b11,dpdown:b12,dpleft:b13,dpright:b14,leftx:a0,lefty:a1,rightx:a2,righty:a3,lefttrigger:a4,righttrigger:a5,platform:Linux, 050000004c050000e60c000000810000,Sony DualSense ,a:b0,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b10,leftshoulder:b4,leftstick:b11,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b12,righttrigger:a5,rightx:a3,righty:a4,start:b9,x:b3,y:b2,platform:Linux, -030000004c050000e60c000000016800,Sony DualSense ,a:b0,b:b1,x:b2,y:b3,back:b4,guide:b5,start:b6,leftstick:b7,rightstick:b8,leftshoulder:b9,rightshoulder:b10,dpup:b11,dpdown:b12,dpleft:b13,dpright:b14,leftx:a0,lefty:a1,rightx:a2,righty:a3,lefttrigger:a4,righttrigger:a5,platform:Linux, 03000000250900000500000000010000,Sony PS2 pad with SmartJoy adapter,a:b2,b:b1,back:b9,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b6,leftstick:b10,lefttrigger:b4,leftx:a0,lefty:a1,rightshoulder:b7,rightstick:b11,righttrigger:b5,rightx:a2,righty:a3,start:b8,x:b3,y:b0,platform:Linux, 030000005e0400008e02000073050000,Speedlink TORID Wireless Gamepad,a:b0,b:b1,back:b6,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b8,leftshoulder:b4,leftstick:b9,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b10,righttrigger:a5,rightx:a3,righty:a4,start:b7,x:b2,y:b3,platform:Linux, 030000005e0400008e02000020200000,SpeedLink XEOX Pro Analog Gamepad pad,a:b0,b:b1,back:b6,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b8,leftshoulder:b4,leftstick:b9,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b10,righttrigger:a5,rightx:a3,righty:a4,start:b7,x:b2,y:b3,platform:Linux, 03000000d11800000094000011010000,Stadia Controller,a:b0,b:b1,back:b6,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b8,leftshoulder:b4,leftstick:b9,lefttrigger:a5,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b10,righttrigger:a4,rightx:a2,righty:a3,start:b7,x:b2,y:b3,platform:Linux, 03000000de2800000112000001000000,Steam Controller,a:b0,b:b1,back:b6,dpdown:b14,dpleft:b15,dpright:b13,dpup:b12,guide:b8,leftshoulder:b4,leftstick:b9,lefttrigger:a2,leftx:a0,lefty:a1,paddle1:b11,paddle2:b10,rightshoulder:b5,righttrigger:a3,start:b7,x:b2,y:b3,platform:Linux, 03000000de2800000211000001000000,Steam Controller,a:b0,b:b1,back:b6,dpdown:b14,dpleft:b15,dpright:b13,dpup:b12,guide:b8,leftshoulder:b4,leftstick:b9,lefttrigger:a2,leftx:a0,lefty:a1,paddle1:b11,paddle2:b10,rightshoulder:b5,righttrigger:a3,start:b7,x:b2,y:b3,platform:Linux, -03000000de2800004211000001000000,Steam Controller,a:b0,b:b1,back:b6,dpdown:b14,dpleft:b15,dpright:b13,dpup:b12,guide:b8,leftshoulder:b4,leftstick:b9,lefttrigger:a2,leftx:a0,lefty:a1,paddle1:b11,paddle2:b10,rightshoulder:b5,righttrigger:a3,start:b7,x:b2,y:b3,platform:Linux, 03000000de2800000211000011010000,Steam Controller,a:b2,b:b3,back:b10,dpdown:b18,dpleft:b19,dpright:b20,dpup:b17,guide:b12,leftshoulder:b6,leftstick:b13,lefttrigger:b8,leftx:a0,lefty:a1,paddle1:b15,paddle2:b16,rightshoulder:b7,righttrigger:b9,rightx:a2,righty:a3,start:b11,x:b4,y:b5,platform:Linux, +03000000de2800004211000001000000,Steam Controller,a:b0,b:b1,back:b6,dpdown:b14,dpleft:b15,dpright:b13,dpup:b12,guide:b8,leftshoulder:b4,leftstick:b9,lefttrigger:a2,leftx:a0,lefty:a1,paddle1:b11,paddle2:b10,rightshoulder:b5,righttrigger:a3,start:b7,x:b2,y:b3,platform:Linux, 03000000de2800004211000011010000,Steam Controller,a:b2,b:b3,back:b10,dpdown:b18,dpleft:b19,dpright:b20,dpup:b17,guide:b12,leftshoulder:b6,leftstick:b13,lefttrigger:b8,leftx:a0,lefty:a1,paddle1:b15,paddle2:b16,rightshoulder:b7,righttrigger:b9,rightx:a2,righty:a3,start:b11,x:b4,y:b5,platform:Linux, 03000000de280000fc11000001000000,Steam Controller,a:b0,b:b1,back:b6,guide:b8,leftshoulder:b4,leftstick:b9,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b10,righttrigger:a5,rightx:a3,righty:a4,start:b7,x:b2,y:b3,platform:Linux, 05000000de2800000212000001000000,Steam Controller,a:b0,b:b1,back:b6,dpdown:b14,dpleft:b15,dpright:b13,dpup:b12,guide:b8,leftshoulder:b4,leftstick:b9,lefttrigger:a2,leftx:a0,lefty:a1,paddle1:b11,paddle2:b10,rightshoulder:b5,righttrigger:a3,start:b7,x:b2,y:b3,platform:Linux, @@ -874,6 +919,7 @@ xinput,XInput Controller,a:b0,b:b1,back:b6,dpdown:h0.4,dpleft:h0.8,dpright:h0.2, 030000005e040000130b000005050000,Xbox Series Controller,a:b0,b:b1,back:b10,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b6,leftstick:b13,lefttrigger:a5,leftx:a0,lefty:a1,rightshoulder:b7,rightstick:b14,righttrigger:a4,rightx:a2,righty:a3,start:b11,x:b3,y:b4,platform:Linux, 050000005e040000130b000001050000,Xbox Series Controller,a:b0,b:b1,back:b10,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b6,leftstick:b13,lefttrigger:a5,leftx:a0,lefty:a1,rightshoulder:b7,rightstick:b14,righttrigger:a4,rightx:a2,righty:a3,start:b11,x:b3,y:b4,platform:Linux, 050000005e040000130b000005050000,Xbox Series Controller,a:b0,b:b1,back:b10,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b6,leftstick:b13,lefttrigger:a5,leftx:a0,lefty:a1,rightshoulder:b7,rightstick:b14,righttrigger:a4,rightx:a2,righty:a3,start:b11,x:b3,y:b4,platform:Linux, +030000005e040000120b000005050000,XBox Series pad,a:b0,b:b1,back:b6,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b8,leftshoulder:b4,leftstick:b9,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b10,righttrigger:a5,rightx:a3,righty:a4,start:b7,x:b2,y:b3,platform:Linux, 030000005e0400008e02000000010000,xbox360 Wireless EasySMX,a:b0,b:b1,back:b6,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b8,leftshoulder:b4,leftstick:b9,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b10,righttrigger:a5,rightx:a3,righty:a4,start:b7,x:b2,y:b3,platform:Linux, 03000000450c00002043000010010000,XEOX Gamepad SL-6556-BK,a:b0,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b2,y:b3,platform:Linux, 03000000ac0500005b05000010010000,Xiaoji Gamesir-G3w,a:b2,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b3,y:b0,platform:Linux, @@ -900,7 +946,7 @@ xinput,XInput Controller,a:b0,b:b1,back:b6,dpdown:h0.4,dpleft:h0.8,dpright:h0.2, 050000003512000020ab000000780f00,8BitDo SNES30 Gamepad,a:b21,b:b20,back:b30,dpdown:+a1,dpleft:-a0,dpright:+a0,dpup:-a1,leftshoulder:b26,rightshoulder:b27,start:b31,x:b24,y:b23,platform:Android, 05000000c82d000018900000ffff0f00,8BitDo Zero 2,a:b1,b:b0,back:b4,leftshoulder:b9,leftx:a0,lefty:a1,rightshoulder:b10,start:b6,x:b3,y:b2,platform:Android, 05000000c82d000030320000ffff0f00,8BitDo Zero 2,a:b1,b:b0,back:b4,leftshoulder:b9,leftx:a0,lefty:a1,rightshoulder:b10,start:b6,x:b3,y:b2,platform:Android, -38383337343564366131323064613561,Brook Mars,a:b1,b:b19,x:b0,y:b2,leftshoulder:b3,rightshoulder:b20,lefttrigger:b9,righttrigger:b10,back:b17,start:b18,leftx:a0,lefty:a1,rightx:a2,righty:a3,leftstick:b15,rightstick:b6,platform:Android, +38383337343564366131323064613561,Brook Mars,a:b1,b:b19,back:b17,leftshoulder:b3,leftstick:b15,lefttrigger:b9,leftx:a0,lefty:a1,rightshoulder:b20,rightstick:b6,righttrigger:b10,rightx:a2,righty:a3,start:b18,x:b0,y:b2,platform:Android, 05000000bc20000000550000ffff3f00,GameSir G3w,a:b0,b:b1,back:b4,dpdown:b12,dpleft:b13,dpright:b14,dpup:b11,leftshoulder:b9,leftstick:b7,lefttrigger:a5,leftx:a0,lefty:a1,rightshoulder:b10,rightstick:b8,righttrigger:a4,rightx:a2,righty:a3,start:b6,x:b2,y:b3,platform:Android, 05000000d6020000e5890000dfff3f00,GPD XD Plus,a:b0,b:b1,back:b4,dpdown:b12,dpleft:b13,dpright:b14,dpup:b11,leftshoulder:b9,leftstick:b7,lefttrigger:a3,leftx:a0,lefty:a1,rightshoulder:b10,rightstick:b8,righttrigger:a4,rightx:a2,righty:a5,start:b6,x:b2,y:b3,platform:Android, 0500000031366332860c44aadfff0f00,GS Gamepad,a:b0,b:b1,back:b4,dpdown:b12,dpleft:b13,dpright:b14,dpup:b11,leftshoulder:b9,leftstick:b7,lefttrigger:b15,leftx:a0,lefty:a1,rightshoulder:b10,rightstick:b8,righttrigger:b16,rightx:a2,righty:a3,start:b6,x:b2,y:b3,platform:Android, @@ -916,9 +962,10 @@ xinput,XInput Controller,a:b0,b:b1,back:b6,dpdown:h0.4,dpleft:h0.8,dpright:h0.2, 050000005509000014720000df7f3f00,NVIDIA Controller v01.04,a:b0,b:b1,back:b4,dpdown:b12,dpleft:b13,dpright:b14,dpup:b11,leftshoulder:b9,leftstick:b7,lefttrigger:a3,leftx:a0,lefty:a1,rightshoulder:b10,rightstick:b8,righttrigger:a4,rightx:a2,righty:a5,start:b6,x:b2,y:b3,platform:Android, 050000004c05000068020000dfff3f00,PS3 Controller,a:b0,b:b1,back:b4,dpdown:b12,dpleft:b13,dpright:b14,dpup:b11,leftshoulder:b9,leftstick:b7,lefttrigger:a4,leftx:a0,lefty:a1,rightshoulder:b10,rightstick:b8,righttrigger:a5,rightx:a2,righty:a3,start:b6,x:b2,y:b3,platform:Android, 030000004c050000cc09000000006800,PS4 Controller,a:b0,b:b1,back:b4,dpdown:b12,dpleft:b13,dpright:b14,dpup:b11,guide:b5,leftshoulder:b9,leftstick:b7,lefttrigger:a4,leftx:a0,lefty:a1,rightshoulder:b10,rightstick:b8,righttrigger:a5,rightx:a2,righty:a3,start:b6,x:b2,y:b3,platform:Android, +050000004c050000c405000000783f00,PS4 Controller,a:b0,b:b1,back:b4,dpdown:b12,dpleft:b13,dpright:b14,dpup:b11,guide:b5,leftshoulder:b9,leftstick:b7,lefttrigger:a4,leftx:a0,lefty:a1,rightshoulder:b10,rightstick:b8,righttrigger:a5,rightx:a2,righty:a3,start:b6,x:b2,y:b3,platform:Android, 050000004c050000c4050000fffe3f00,PS4 Controller,a:b1,b:b17,back:b15,dpdown:b12,dpleft:b13,dpright:b14,dpup:b11,guide:b5,leftshoulder:b3,leftstick:b4,lefttrigger:+a3,leftx:a0,lefty:a1,rightshoulder:b18,rightstick:b6,righttrigger:+a4,rightx:a2,righty:a5,start:b16,x:b0,y:b2,platform:Android, 050000004c050000c4050000ffff3f00,PS4 Controller,a:b0,b:b1,back:b4,dpdown:b12,dpleft:b13,dpright:b14,dpup:b11,guide:b5,leftshoulder:b9,leftstick:b7,lefttrigger:a4,leftx:a0,lefty:a1,rightshoulder:b10,rightstick:b8,righttrigger:a5,rightx:a2,righty:a3,start:b6,x:b2,y:b3,platform:Android, -050000004c050000cc090000fffe3f00,PS4 Controller,a:b1,b:b17,back:b15,dpdown:b12,dpleft:b13,dpright:b14,dpup:b11,guide:b5,leftshoulder:b3,leftstick:b4,lefttrigger:a3,leftx:a0,lefty:a1,rightshoulder:b18,rightstick:b6,righttrigger:a4,rightx:a2,righty:a5,start:b16,x:b0,y:b2,platform:Android, +050000004c050000cc090000fffe3f00,PS4 Controller,a:b0,b:b1,back:b4,dpdown:b12,dpleft:b13,dpright:b14,dpup:b11,guide:b5,leftshoulder:b9,leftstick:b7,lefttrigger:a4,leftx:a0,lefty:a1,rightshoulder:b10,rightstick:b8,righttrigger:a5,rightx:a2,righty:a3,start:b6,x:b2,y:b3,platform:Android, 050000004c050000cc090000ffff3f00,PS4 Controller,a:b0,b:b1,back:b4,dpdown:b12,dpleft:b13,dpright:b14,dpup:b11,guide:b5,leftshoulder:b9,leftstick:b7,lefttrigger:a4,leftx:a0,lefty:a1,rightshoulder:b10,rightstick:b8,righttrigger:a5,rightx:a2,righty:a3,start:b6,x:b2,y:b3,platform:Android, 35643031303033326130316330353564,PS4 Controller,a:b1,b:b17,back:b15,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b5,leftshoulder:b3,leftstick:b4,lefttrigger:+a3,leftx:a0,lefty:a1,rightshoulder:b18,rightstick:b6,righttrigger:+a4,rightx:a2,righty:a5,start:b16,x:b0,y:b2,platform:Android, 050000004c050000e60c0000fffe3f00,PS5 Controller,a:b1,b:b17,back:b15,dpdown:b12,dpleft:b13,dpright:b14,dpup:b11,guide:b5,leftshoulder:b3,leftstick:b4,lefttrigger:a3,leftx:a0,lefty:a1,rightshoulder:b18,rightstick:b6,righttrigger:a4,rightx:a2,righty:a5,start:b16,x:b0,y:b2,platform:Android, @@ -933,9 +980,14 @@ xinput,XInput Controller,a:b0,b:b1,back:b6,dpdown:h0.4,dpleft:h0.8,dpright:h0.2, 050000004f0400000ed00000fffe3f00,ThrustMaster eSwap PRO Controller,a:b0,b:b1,back:b4,dpdown:b12,dpleft:b13,dpright:b14,dpup:b11,leftshoulder:b9,leftstick:b7,lefttrigger:a4,leftx:a0,lefty:a1,rightshoulder:b10,righttrigger:a5,rightx:a2,righty:a3,start:b6,x:b2,y:b3,platform:Android, 5477696e20555342204a6f7973746963,Twin USB Joystick,a:b22,b:b21,back:b28,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b26,leftstick:b30,lefttrigger:b24,leftx:a0,lefty:a1,rightshoulder:b27,rightstick:b31,righttrigger:b25,rightx:a3,righty:a2,start:b29,x:b23,y:b20,platform:Android, 30306539356238653637313730656134,Wireless HORIPAD Switch Pro Controller,a:b0,b:b1,back:b17,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b5,leftshoulder:b3,leftstick:b15,lefttrigger:b9,leftx:a0,lefty:a1,rightshoulder:b20,rightstick:b6,righttrigger:b10,rightx:a2,righty:a3,start:b18,x:b19,y:b2,platform:Android, +050000005e0400008e02000000783f00,Xbox 360 Controller,a:b0,b:b1,back:b4,dpdown:b12,dpleft:b13,dpright:b14,dpup:b11,guide:b5,leftshoulder:b9,leftstick:b7,lefttrigger:a4,leftx:a0,lefty:a1,rightshoulder:b10,rightstick:b8,righttrigger:a5,rightx:a2,righty:a3,start:b6,x:b2,y:b3,platform:Android, +050000005e040000000b000000783f00,Xbox One Elite 2 Controller,a:b0,b:b1,back:b4,dpdown:b12,dpleft:b13,dpright:b14,dpup:b11,guide:b5,leftshoulder:b9,leftstick:b7,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b10,rightstick:b8,righttrigger:a5,rightx:a3,righty:a4,start:b6,x:b2,y:b3,platform:Android, +050000005e040000e002000000783f00,Xbox One S Controller,a:b0,b:b1,back:b4,dpdown:b12,dpleft:b13,dpright:b14,dpup:b11,guide:b5,leftshoulder:b9,leftstick:b7,lefttrigger:a4,leftx:a0,lefty:a1,rightshoulder:b10,rightstick:b8,righttrigger:a5,rightx:a2,righty:a3,start:b6,x:b2,y:b3,platform:Android, +050000005e040000ea02000000783f00,Xbox One S Controller,a:b0,b:b1,back:b4,dpdown:b12,dpleft:b13,dpright:b14,dpup:b11,guide:b5,leftshoulder:b9,leftstick:b7,lefttrigger:a4,leftx:a0,lefty:a1,rightshoulder:b10,rightstick:b8,righttrigger:a5,rightx:a2,righty:a3,start:b6,x:b2,y:b3,platform:Android, 050000005e040000fd020000ff7f3f00,Xbox One S Controller,a:b0,b:b1,back:b4,dpdown:b12,dpleft:b13,dpright:b14,dpup:b11,guide:b5,leftshoulder:b9,leftstick:b7,lefttrigger:a4,leftx:a0,lefty:a1,rightshoulder:b10,rightstick:b8,righttrigger:a5,rightx:a2,righty:a3,start:b6,x:b2,y:b3,platform:Android, 050000005e040000e00200000ffe3f00,Xbox One Wireless Controller,a:b0,b:b1,back:b9,dpdown:b12,dpleft:b13,dpright:b14,dpup:b11,leftshoulder:b3,leftstick:b15,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b18,rightstick:b16,righttrigger:a5,rightx:a3,righty:a4,start:b10,x:b17,y:b2,platform:Android, 050000005e040000fd020000ffff3f00,Xbox One Wireless Controller,a:b0,b:b1,back:b4,dpdown:b12,dpleft:b13,dpright:b14,dpup:b11,leftshoulder:b9,leftstick:b7,lefttrigger:a5,leftx:a0,lefty:a1,rightshoulder:b10,rightstick:b8,righttrigger:a4,rightx:a2,righty:a3,start:b6,x:b2,y:b3,platform:Android, +050000005e040000120b000000783f00,Xbox Series Controller,a:b0,b:b1,back:b4,dpdown:b12,dpleft:b13,dpright:b14,dpup:b11,guide:b5,leftshoulder:b9,leftstick:b7,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b10,rightstick:b8,righttrigger:a5,rightx:a3,righty:a4,start:b6,x:b2,y:b3,platform:Android, 050000005e040000130b0000ffff3f00,Xbox Series Controller,a:b0,b:b1,back:b4,dpdown:b12,dpleft:b13,dpright:b14,dpup:b11,guide:b5,leftshoulder:b9,leftstick:b7,lefttrigger:a4,leftx:a0,lefty:a1,rightshoulder:b10,rightstick:b8,righttrigger:a5,rightx:a2,righty:a3,start:b6,x:b2,y:b3,platform:Android, 65633038363832353634653836396239,Xbox Series Controller,a:b0,b:b1,back:b15,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b5,leftshoulder:b9,leftstick:b7,lefttrigger:a4,leftx:a0,lefty:a1,rightshoulder:b10,rightstick:b8,righttrigger:a5,rightx:a2,righty:a3,start:b6,x:b2,y:b3,platform:Android, 050000005e04000091020000ff073f00,Xbox Wireless Controller,a:b0,b:b1,back:b4,guide:b5,leftshoulder:b9,leftstick:b7,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b10,rightstick:b8,righttrigger:a5,rightx:a3,righty:a4,start:b6,x:b2,y:b3,platform:Android, @@ -953,13 +1005,17 @@ xinput,XInput Controller,a:b0,b:b1,back:b6,dpdown:h0.4,dpleft:h0.8,dpright:h0.2, 4d466947616d65706164010000000000,MFi Extended Gamepad,a:b0,b:b1,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,righttrigger:a5,rightx:a3,righty:a4,start:b6,x:b2,y:b3,platform:iOS, 4d466947616d65706164020000000000,MFi Gamepad,a:b0,b:b1,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,rightshoulder:b5,start:b6,x:b2,y:b3,platform:iOS, 050000004c050000cc090000df070000,PS4 Controller,a:b0,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b6,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b7,righttrigger:a5,rightx:a3,righty:a4,start:b9,x:b2,y:b3,platform:iOS, +050000004c050000cc090000df870001,PS4 Controller,a:b0,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b6,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b7,righttrigger:a5,rightx:a3,righty:a4,start:b9,x:b2,y:b3,platform:iOS, 050000004c050000cc090000ff070000,PS4 Controller,a:b0,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b9,leftshoulder:b4,leftstick:b6,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b7,righttrigger:a5,rightx:a3,righty:a4,start:b10,x:b2,y:b3,platform:iOS, 050000004c050000cc090000ff870001,PS4 Controller,a:b0,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b9,leftshoulder:b4,leftstick:b6,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b7,righttrigger:a5,rightx:a3,righty:a4,start:b10,touchpad:b11,x:b2,y:b3,platform:iOS, 050000004c050000cc090000ff876d01,PS4 Controller,a:b0,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b9,leftshoulder:b4,leftstick:b6,lefttrigger:a2,leftx:a0,lefty:a1,misc1:b11,rightshoulder:b5,rightstick:b7,righttrigger:a5,rightx:a3,righty:a4,start:b10,x:b2,y:b3,platform:iOS, +050000004c050000e60c0000df870000,PS5 Controller,a:b0,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b6,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b7,righttrigger:a5,rightx:a3,righty:a4,start:b9,touchpad:b10,x:b2,y:b3,platform:iOS, +050000004c050000e60c0000ff870000,PS5 Controller,a:b0,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b9,leftshoulder:b4,leftstick:b6,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b7,righttrigger:a5,rightx:a3,righty:a4,start:b10,touchpad:b11,x:b2,y:b3,platform:iOS, 05000000ac0500000300000000006d03,Remote,a:b0,b:b2,leftx:a0,lefty:a1,platform:iOS, 05000000ac0500000300000043006d03,Remote,a:b0,b:b2,leftx:a0,lefty:a1,platform:iOS, 05000000de2800000511000001000000,Steam Controller,a:b0,b:b1,back:b6,guide:b8,leftshoulder:b4,leftstick:b9,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,righttrigger:a3,start:b7,x:b2,y:b3,platform:iOS, 05000000de2800000611000001000000,Steam Controller,a:b0,b:b1,back:b6,guide:b8,leftshoulder:b4,leftstick:b9,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,righttrigger:a3,start:b7,x:b2,y:b3,platform:iOS, +050000005e040000050b0000df070001,Xbox Elite Wireless Controller,a:b0,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b6,lefttrigger:a2,leftx:a0,lefty:a1,paddle1:b10,paddle2:b12,paddle3:b11,paddle4:b13,rightshoulder:b5,rightstick:b7,righttrigger:a5,rightx:a3,righty:a4,start:b9,x:b2,y:b3,platform:iOS, 050000005e040000050b0000ff070001,Xbox Elite Wireless Controller,a:b0,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b9,leftshoulder:b4,leftstick:b6,lefttrigger:a2,leftx:a0,lefty:a1,paddle1:b11,paddle2:b13,paddle3:b12,paddle4:b14,rightshoulder:b5,rightstick:b7,righttrigger:a5,rightx:a3,righty:a4,start:b10,x:b2,y:b3,platform:iOS, 050000005e040000e0020000df070000,Xbox Wireless Controller,a:b0,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b6,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b7,righttrigger:a5,rightx:a3,righty:a4,start:b9,x:b2,y:b3,platform:iOS, 050000005e040000e0020000ff070000,Xbox Wireless Controller,a:b0,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b9,leftshoulder:b4,leftstick:b6,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b7,righttrigger:a5,rightx:a3,righty:a4,start:b10,x:b2,y:b3,platform:iOS, diff --git a/core/input/godotcontrollerdb.txt b/core/input/godotcontrollerdb.txt index db612f04d2..5985b121c9 100644 --- a/core/input/godotcontrollerdb.txt +++ b/core/input/godotcontrollerdb.txt @@ -29,6 +29,8 @@ Linux0e8f3013,HuiJia USB GamePad,a:b2,b:b1,y:b0,x:b3,start:b9,back:b8,leftshould Windows0e8f3013,HuiJia USB GamePad,a:b2,b:b1,y:b0,x:b3,start:b9,back:b8,leftshoulder:b6,rightshoulder:b7,dpup:-a1,dpleft:-a0,dpdown:+a1,dpright:+a0,platform:Javascript MacOSX0e8f3013,HuiJia USB GamePad,a:b2,b:b1,y:b0,x:b3,start:b9,back:b8,leftshoulder:b6,rightshoulder:b7,dpup:-a4,dpleft:-a3,dpdown:+a4,dpright:+a3,platform:Javascript Linux046dc216,046d-c216-Logitech Logitech Dual Action,a:b1,b:b2,y:b3,x:b0,start:b9,back:b8,leftstick:b10,rightstick:b11,leftshoulder:b4,rightshoulder:b5,dpup:-a5,dpleft:-a4,dpdown:+a5,dpright:+a4,leftx:a0,lefty:a1,rightx:a2,righty:a3,lefttrigger:b6,righttrigger:b7,platform:Javascript +Linux20d6a713,Bensussen Deutsch & Associates Inc.(BDA) NSW Wired controller,a:b1,b:b2,y:b3,x:b0,start:b9,back:b8,leftstick:b10,rightstick:b11,leftshoulder:b4,rightshoulder:b5,dpup:-a5,dpleft:-a4,dpdown:+a5,dpright:+a4,leftx:a0,lefty:a1,rightx:a2,righty:a3,lefttrigger:b6,righttrigger:b7,platform:Javascript +Linux054c05c4,Sony Computer Entertainment Wireless Controller,a:b0,b:b1,y:b2,x:b3,start:b9,back:b8,leftstick:b11,rightstick:b12,leftshoulder:b4,rightshoulder:b5,dpup:-a7,dpleft:-a6,dpdown:+a7,dpright:+a6,leftx:a0,lefty:a1,rightx:a3,righty:a4,lefttrigger:a2,righttrigger:a5,platform:Javascript # UWP __UWP_GAMEPAD__,Xbox Controller,a:b2,b:b3,x:b4,y:b5,start:b0,back:b1,leftstick:b12,rightstick:b13,leftshoulder:b10,rightshoulder:b11,dpup:b6,dpdown:b7,dpleft:b8,dpright:b9,leftx:a0,lefty:a1,rightx:a2,righty:a3,lefttrigger:a4,righttrigger:a5,platform:UWP, diff --git a/core/input/input.cpp b/core/input/input.cpp index a712394b35..c205726b0a 100644 --- a/core/input/input.cpp +++ b/core/input/input.cpp @@ -101,7 +101,7 @@ void Input::_bind_methods() { ClassDB::bind_method(D_METHOD("is_action_just_pressed", "action", "exact_match"), &Input::is_action_just_pressed, DEFVAL(false)); ClassDB::bind_method(D_METHOD("is_action_just_released", "action", "exact_match"), &Input::is_action_just_released, DEFVAL(false)); ClassDB::bind_method(D_METHOD("get_action_strength", "action", "exact_match"), &Input::get_action_strength, DEFVAL(false)); - ClassDB::bind_method(D_METHOD("get_action_raw_strength", "action", "exact_match"), &Input::get_action_strength, DEFVAL(false)); + ClassDB::bind_method(D_METHOD("get_action_raw_strength", "action", "exact_match"), &Input::get_action_raw_strength, DEFVAL(false)); ClassDB::bind_method(D_METHOD("get_axis", "negative_action", "positive_action"), &Input::get_axis); ClassDB::bind_method(D_METHOD("get_vector", "negative_x", "positive_x", "negative_y", "positive_y", "deadzone"), &Input::get_vector, DEFVAL(-1.0f)); ClassDB::bind_method(D_METHOD("add_joy_mapping", "mapping", "update_existing"), &Input::add_joy_mapping, DEFVAL(false)); @@ -169,13 +169,12 @@ void Input::get_argument_options(const StringName &p_function, int p_idx, List<S String pf = p_function; if (p_idx == 0 && (pf == "is_action_pressed" || pf == "action_press" || pf == "action_release" || pf == "is_action_just_pressed" || pf == "is_action_just_released" || - pf == "get_action_strength" || pf == "get_axis" || pf == "get_vector")) { + pf == "get_action_strength" || pf == "get_action_raw_strength" || + pf == "get_axis" || pf == "get_vector")) { List<PropertyInfo> pinfo; ProjectSettings::get_singleton()->get_property_list(&pinfo); - for (List<PropertyInfo>::Element *E = pinfo.front(); E; E = E->next()) { - const PropertyInfo &pi = E->get(); - + for (const PropertyInfo &pi : pinfo) { if (!pi.name.begins_with("input/")) { continue; } @@ -438,7 +437,7 @@ void Input::joy_connection_changed(int p_idx, bool p_connected, String p_name, S } joy_names[p_idx] = js; - emit_signal("joy_connection_changed", p_idx, p_connected); + emit_signal(SNAME("joy_connection_changed"), p_idx, p_connected); } Vector3 Input::get_gravity() const { diff --git a/core/input/input_map.cpp b/core/input/input_map.cpp index b5f067d499..6714705bb5 100644 --- a/core/input/input_map.cpp +++ b/core/input/input_map.cpp @@ -65,11 +65,11 @@ String InputMap::_suggest_actions(const StringName &p_action) const { float closest_similarity = 0.0; // Find the most action with the most similar name. - for (List<StringName>::Element *E = actions.front(); E; E = E->next()) { - const float similarity = String(E->get()).similarity(p_action); + for (const StringName &action : actions) { + const float similarity = String(action).similarity(p_action); if (similarity > closest_similarity) { - closest_action = E->get(); + closest_action = action; closest_similarity = similarity; } } @@ -105,8 +105,8 @@ Array InputMap::_get_actions() { return ret; } - for (const List<StringName>::Element *E = actions.front(); E; E = E->next()) { - ret.push_back(E->get()); + for (const StringName &E : actions) { + ret.push_back(E); } return ret; @@ -129,13 +129,11 @@ List<Ref<InputEvent>>::Element *InputMap::_find_event(Action &p_action, const Re ERR_FAIL_COND_V(!p_event.is_valid(), nullptr); for (List<Ref<InputEvent>>::Element *E = p_action.inputs.front(); E; E = E->next()) { - const Ref<InputEvent> e = E->get(); - - int device = e->get_device(); + int device = E->get()->get_device(); if (device == ALL_DEVICES || device == p_event->get_device()) { - if (p_exact_match && e->is_match(p_event, true)) { + if (p_exact_match && E->get()->is_match(p_event, true)) { return E; - } else if (!p_exact_match && e->action_match(p_event, p_pressed, p_strength, p_raw_strength, p_action.deadzone)) { + } else if (!p_exact_match && E->get()->action_match(p_event, p_pressed, p_strength, p_raw_strength, p_action.deadzone)) { return E; } } @@ -198,7 +196,7 @@ Array InputMap::_action_get_events(const StringName &p_action) { const List<Ref<InputEvent>> *al = action_get_events(p_action); if (al) { for (const List<Ref<InputEvent>>::Element *E = al->front(); E; E = E->next()) { - ret.push_back(E->get()); + ret.push_back(E); } } @@ -263,9 +261,7 @@ void InputMap::load_from_project_settings() { List<PropertyInfo> pinfo; ProjectSettings::get_singleton()->get_property_list(&pinfo); - for (List<PropertyInfo>::Element *E = pinfo.front(); E; E = E->next()) { - const PropertyInfo &pi = E->get(); - + for (const PropertyInfo &pi : pinfo) { if (!pi.name.begins_with("input/")) { continue; } diff --git a/core/io/config_file.cpp b/core/io/config_file.cpp index 10f68f3cef..aeaf25f321 100644 --- a/core/io/config_file.cpp +++ b/core/io/config_file.cpp @@ -40,8 +40,8 @@ PackedStringArray ConfigFile::_get_sections() const { PackedStringArray arr; arr.resize(s.size()); int idx = 0; - for (const List<String>::Element *E = s.front(); E; E = E->next()) { - arr.set(idx++, E->get()); + for (const String &E : s) { + arr.set(idx++, E); } return arr; @@ -53,8 +53,8 @@ PackedStringArray ConfigFile::_get_section_keys(const String &p_section) const { PackedStringArray arr; arr.resize(s.size()); int idx = 0; - for (const List<String>::Element *E = s.front(); E; E = E->next()) { - arr.set(idx++, E->get()); + for (const String &E : s) { + arr.set(idx++, E); } return arr; diff --git a/core/io/dir_access.cpp b/core/io/dir_access.cpp index dfba00067f..8234adea06 100644 --- a/core/io/dir_access.cpp +++ b/core/io/dir_access.cpp @@ -93,8 +93,8 @@ static Error _erase_recursive(DirAccess *da) { da->list_dir_end(); - for (List<String>::Element *E = dirs.front(); E; E = E->next()) { - Error err = da->change_dir(E->get()); + for (const String &E : dirs) { + Error err = da->change_dir(E); if (err == OK) { err = _erase_recursive(da); if (err) { @@ -105,7 +105,7 @@ static Error _erase_recursive(DirAccess *da) { if (err) { return err; } - err = da->remove(da->get_current_dir().plus_file(E->get())); + err = da->remove(da->get_current_dir().plus_file(E)); if (err) { return err; } @@ -114,8 +114,8 @@ static Error _erase_recursive(DirAccess *da) { } } - for (List<String>::Element *E = files.front(); E; E = E->next()) { - Error err = da->remove(da->get_current_dir().plus_file(E->get())); + for (const String &E : files) { + Error err = da->remove(da->get_current_dir().plus_file(E)); if (err) { return err; } @@ -362,16 +362,15 @@ Error DirAccess::_copy_dir(DirAccess *p_target_da, String p_to, int p_chmod_flag list_dir_end(); - for (List<String>::Element *E = dirs.front(); E; E = E->next()) { - String rel_path = E->get(); + for (const String &rel_path : dirs) { String target_dir = p_to + rel_path; if (!p_target_da->dir_exists(target_dir)) { Error err = p_target_da->make_dir(target_dir); ERR_FAIL_COND_V_MSG(err != OK, err, "Cannot create directory '" + target_dir + "'."); } - Error err = change_dir(E->get()); - ERR_FAIL_COND_V_MSG(err != OK, err, "Cannot change current directory to '" + E->get() + "'."); + Error err = change_dir(rel_path); + ERR_FAIL_COND_V_MSG(err != OK, err, "Cannot change current directory to '" + rel_path + "'."); err = _copy_dir(p_target_da, p_to + rel_path + "/", p_chmod_flags, p_copy_links); if (err) { diff --git a/core/io/http_client.cpp b/core/io/http_client.cpp index 8000dd4290..5c1352c1b6 100644 --- a/core/io/http_client.cpp +++ b/core/io/http_client.cpp @@ -93,8 +93,7 @@ Dictionary HTTPClient::_get_response_headers_as_dictionary() { List<String> rh; get_response_headers(&rh); Dictionary ret; - for (const List<String>::Element *E = rh.front(); E; E = E->next()) { - const String &s = E->get(); + for (const String &s : rh) { int sp = s.find(":"); if (sp == -1) { continue; @@ -113,8 +112,8 @@ PackedStringArray HTTPClient::_get_response_headers() { PackedStringArray ret; ret.resize(rh.size()); int idx = 0; - for (const List<String>::Element *E = rh.front(); E; E = E->next()) { - ret.set(idx++, E->get()); + for (const String &E : rh) { + ret.set(idx++, E); } return ret; diff --git a/core/io/image_loader.cpp b/core/io/image_loader.cpp index b45e9d26b1..b9fc416f65 100644 --- a/core/io/image_loader.cpp +++ b/core/io/image_loader.cpp @@ -35,8 +35,8 @@ bool ImageFormatLoader::recognize(const String &p_extension) const { List<String> extensions; get_recognized_extensions(&extensions); - for (List<String>::Element *E = extensions.front(); E; E = E->next()) { - if (E->get().nocasecmp_to(p_extension) == 0) { + for (const String &E : extensions) { + if (E.nocasecmp_to(p_extension) == 0) { return true; } } diff --git a/core/io/ip.cpp b/core/io/ip.cpp index 001b1c4757..cd1b6d1994 100644 --- a/core/io/ip.cpp +++ b/core/io/ip.cpp @@ -252,8 +252,8 @@ Array IP::_get_local_addresses() const { Array addresses; List<IPAddress> ip_addresses; get_local_addresses(&ip_addresses); - for (List<IPAddress>::Element *E = ip_addresses.front(); E; E = E->next()) { - addresses.push_back(E->get()); + for (const IPAddress &E : ip_addresses) { + addresses.push_back(E); } return addresses; @@ -271,8 +271,8 @@ Array IP::_get_local_interfaces() const { rc["index"] = c.index; Array ips; - for (const List<IPAddress>::Element *F = c.ip_addresses.front(); F; F = F->next()) { - ips.push_front(F->get()); + for (const IPAddress &F : c.ip_addresses) { + ips.push_front(F); } rc["addresses"] = ips; @@ -286,8 +286,8 @@ void IP::get_local_addresses(List<IPAddress> *r_addresses) const { Map<String, Interface_Info> interfaces; get_local_interfaces(&interfaces); for (Map<String, Interface_Info>::Element *E = interfaces.front(); E; E = E->next()) { - for (const List<IPAddress>::Element *F = E->get().ip_addresses.front(); F; F = F->next()) { - r_addresses->push_front(F->get()); + for (const IPAddress &F : E->get().ip_addresses) { + r_addresses->push_front(F); } } } diff --git a/core/io/json.cpp b/core/io/json.cpp index b3a2498212..5823afbdcd 100644 --- a/core/io/json.cpp +++ b/core/io/json.cpp @@ -121,14 +121,17 @@ String JSON::_stringify(const Variant &p_var, const String &p_indent, int p_cur_ keys.sort(); } - for (List<Variant>::Element *E = keys.front(); E; E = E->next()) { - if (E != keys.front()) { + bool first_key = true; + for (const Variant &E : keys) { + if (first_key) { + first_key = false; + } else { s += ","; s += end_statement; } - s += _make_indent(p_indent, p_cur_indent + 1) + _stringify(String(E->get()), p_indent, p_cur_indent + 1, p_sort_keys, p_markers); + s += _make_indent(p_indent, p_cur_indent + 1) + _stringify(String(E), p_indent, p_cur_indent + 1, p_sort_keys, p_markers); s += colon; - s += _stringify(d[E->get()], p_indent, p_cur_indent + 1, p_sort_keys, p_markers); + s += _stringify(d[E], p_indent, p_cur_indent + 1, p_sort_keys, p_markers); } s += end_statement + _make_indent(p_indent, p_cur_indent) + "}"; diff --git a/core/io/marshalls.cpp b/core/io/marshalls.cpp index f342db2dad..4f85eced93 100644 --- a/core/io/marshalls.cpp +++ b/core/io/marshalls.cpp @@ -1031,7 +1031,8 @@ static void _encode_string(const String &p_string, uint8_t *&buf, int &r_len) { } } -Error encode_variant(const Variant &p_variant, uint8_t *r_buffer, int &r_len, bool p_full_objects) { +Error encode_variant(const Variant &p_variant, uint8_t *r_buffer, int &r_len, bool p_full_objects, int p_depth) { + ERR_FAIL_COND_V_MSG(p_depth > Variant::MAX_RECURSION_DEPTH, ERR_OUT_OF_MEMORY, "Potential inifite recursion detected. Bailing."); uint8_t *buf = r_buffer; r_len = 0; @@ -1358,8 +1359,8 @@ Error encode_variant(const Variant &p_variant, uint8_t *r_buffer, int &r_len, bo obj->get_property_list(&props); int pc = 0; - for (List<PropertyInfo>::Element *E = props.front(); E; E = E->next()) { - if (!(E->get().usage & PROPERTY_USAGE_STORAGE)) { + for (const PropertyInfo &E : props) { + if (!(E.usage & PROPERTY_USAGE_STORAGE)) { continue; } pc++; @@ -1372,18 +1373,16 @@ Error encode_variant(const Variant &p_variant, uint8_t *r_buffer, int &r_len, bo r_len += 4; - for (List<PropertyInfo>::Element *E = props.front(); E; E = E->next()) { - if (!(E->get().usage & PROPERTY_USAGE_STORAGE)) { + for (const PropertyInfo &E : props) { + if (!(E.usage & PROPERTY_USAGE_STORAGE)) { continue; } - _encode_string(E->get().name, buf, r_len); + _encode_string(E.name, buf, r_len); int len; - Error err = encode_variant(obj->get(E->get().name), buf, len, p_full_objects); - if (err) { - return err; - } + Error err = encode_variant(obj->get(E.name), buf, len, p_full_objects, p_depth + 1); + ERR_FAIL_COND_V(err, err); ERR_FAIL_COND_V(len % 4, ERR_BUG); r_len += len; if (buf) { @@ -1418,7 +1417,7 @@ Error encode_variant(const Variant &p_variant, uint8_t *r_buffer, int &r_len, bo List<Variant> keys; d.get_key_list(&keys); - for (List<Variant>::Element *E = keys.front(); E; E = E->next()) { + for (const Variant &E : keys) { /* CharString utf8 = E->->utf8(); @@ -1433,15 +1432,17 @@ Error encode_variant(const Variant &p_variant, uint8_t *r_buffer, int &r_len, bo r_len++; //pad */ int len; - encode_variant(E->get(), buf, len, p_full_objects); + Error err = encode_variant(E, buf, len, p_full_objects, p_depth + 1); + ERR_FAIL_COND_V(err, err); ERR_FAIL_COND_V(len % 4, ERR_BUG); r_len += len; if (buf) { buf += len; } - Variant *v = d.getptr(E->get()); + Variant *v = d.getptr(E); ERR_FAIL_COND_V(!v, ERR_BUG); - encode_variant(*v, buf, len, p_full_objects); + err = encode_variant(*v, buf, len, p_full_objects, p_depth + 1); + ERR_FAIL_COND_V(err, err); ERR_FAIL_COND_V(len % 4, ERR_BUG); r_len += len; if (buf) { @@ -1462,7 +1463,8 @@ Error encode_variant(const Variant &p_variant, uint8_t *r_buffer, int &r_len, bo for (int i = 0; i < v.size(); i++) { int len; - encode_variant(v.get(i), buf, len, p_full_objects); + Error err = encode_variant(v.get(i), buf, len, p_full_objects, p_depth + 1); + ERR_FAIL_COND_V(err, err); ERR_FAIL_COND_V(len % 4, ERR_BUG); r_len += len; if (buf) { diff --git a/core/io/marshalls.h b/core/io/marshalls.h index 3ebed914a3..05804d5a46 100644 --- a/core/io/marshalls.h +++ b/core/io/marshalls.h @@ -213,6 +213,6 @@ public: }; Error decode_variant(Variant &r_variant, const uint8_t *p_buffer, int p_len, int *r_len = nullptr, bool p_allow_objects = false); -Error encode_variant(const Variant &p_variant, uint8_t *r_buffer, int &r_len, bool p_full_objects = false); +Error encode_variant(const Variant &p_variant, uint8_t *r_buffer, int &r_len, bool p_full_objects = false, int p_depth = 0); #endif // MARSHALLS_H diff --git a/core/io/multiplayer_api.cpp b/core/io/multiplayer_api.cpp index 564397c88c..d4f09b2135 100644 --- a/core/io/multiplayer_api.cpp +++ b/core/io/multiplayer_api.cpp @@ -63,7 +63,7 @@ const MultiplayerAPI::RPCConfig _get_rpc_config(const Node *p_node, const String const Vector<MultiplayerAPI::RPCConfig> node_config = p_node->get_node_rpc_methods(); for (int i = 0; i < node_config.size(); i++) { if (node_config[i].name == p_method) { - r_id = ((uint16_t)i) & (1 << 15); + r_id = ((uint16_t)i) | (1 << 15); return node_config[i]; } } @@ -89,57 +89,22 @@ const MultiplayerAPI::RPCConfig _get_rpc_config_by_id(Node *p_node, uint16_t p_i config = p_node->get_script_instance()->get_rpc_methods(); } if (id < config.size()) { - return config[p_id]; + return config[id]; } return MultiplayerAPI::RPCConfig(); } -_FORCE_INLINE_ bool _should_call_local(MultiplayerAPI::RPCMode mode, bool is_master, bool &r_skip_rpc) { - switch (mode) { - case MultiplayerAPI::RPC_MODE_DISABLED: { - // Do nothing. - } break; - case MultiplayerAPI::RPC_MODE_REMOTE: { - // Do nothing. Remote cannot produce a local call. - } break; - case MultiplayerAPI::RPC_MODE_MASTERSYNC: { - if (is_master) { - r_skip_rpc = true; // I am the master, so skip remote call. - } - [[fallthrough]]; - } - case MultiplayerAPI::RPC_MODE_REMOTESYNC: - case MultiplayerAPI::RPC_MODE_PUPPETSYNC: { - // Call it, sync always results in a local call. - return true; - } break; - case MultiplayerAPI::RPC_MODE_MASTER: { - if (is_master) { - r_skip_rpc = true; // I am the master, so skip remote call. - } - return is_master; - } break; - case MultiplayerAPI::RPC_MODE_PUPPET: { - return !is_master; - } break; - } - return false; -} - _FORCE_INLINE_ bool _can_call_mode(Node *p_node, MultiplayerAPI::RPCMode mode, int p_remote_id) { switch (mode) { case MultiplayerAPI::RPC_MODE_DISABLED: { return false; } break; - case MultiplayerAPI::RPC_MODE_REMOTE: - case MultiplayerAPI::RPC_MODE_REMOTESYNC: { + case MultiplayerAPI::RPC_MODE_REMOTE: { return true; } break; - case MultiplayerAPI::RPC_MODE_MASTERSYNC: case MultiplayerAPI::RPC_MODE_MASTER: { return p_node->is_network_master(); } break; - case MultiplayerAPI::RPC_MODE_PUPPETSYNC: case MultiplayerAPI::RPC_MODE_PUPPET: { return !p_node->is_network_master() && p_remote_id == p_node->get_network_master(); } break; @@ -590,12 +555,12 @@ bool MultiplayerAPI::_send_confirm_path(Node *p_node, NodePath p_path, PathSentC ofs += encode_cstring(path.get_data(), &packet.write[ofs]); - for (List<int>::Element *E = peers_to_add.front(); E; E = E->next()) { - network_peer->set_target_peer(E->get()); // To all of you. + for (int &E : peers_to_add) { + network_peer->set_target_peer(E); // To all of you. network_peer->set_transfer_mode(MultiplayerPeer::TRANSFER_MODE_RELIABLE); network_peer->put_packet(packet.ptr(), packet.size()); - psc->confirmed_peers.insert(E->get(), false); // Insert into confirmed, but as false since it was not confirmed. + psc->confirmed_peers.insert(E, false); // Insert into confirmed, but as false since it was not confirmed. } } @@ -941,7 +906,7 @@ void MultiplayerAPI::_send_rpc(Node *p_from, int p_to, uint16_t p_rpc_id, const void MultiplayerAPI::_add_peer(int p_id) { connected_peers.insert(p_id); path_get_cache.insert(p_id, PathGetCache()); - emit_signal("network_peer_connected", p_id); + emit_signal(SNAME("network_peer_connected"), p_id); } void MultiplayerAPI::_del_peer(int p_id) { @@ -952,23 +917,23 @@ void MultiplayerAPI::_del_peer(int p_id) { // Some refactoring is needed to make this faster and do paths GC. List<NodePath> keys; path_send_cache.get_key_list(&keys); - for (List<NodePath>::Element *E = keys.front(); E; E = E->next()) { - PathSentCache *psc = path_send_cache.getptr(E->get()); + for (const NodePath &E : keys) { + PathSentCache *psc = path_send_cache.getptr(E); psc->confirmed_peers.erase(p_id); } - emit_signal("network_peer_disconnected", p_id); + emit_signal(SNAME("network_peer_disconnected"), p_id); } void MultiplayerAPI::_connected_to_server() { - emit_signal("connected_to_server"); + emit_signal(SNAME("connected_to_server")); } void MultiplayerAPI::_connection_failed() { - emit_signal("connection_failed"); + emit_signal(SNAME("connection_failed")); } void MultiplayerAPI::_server_disconnected() { - emit_signal("server_disconnected"); + emit_signal(SNAME("server_disconnected")); } void MultiplayerAPI::rpcp(Node *p_node, int p_peer_id, bool p_unreliable, const StringName &p_method, const Variant **p_arg, int p_argcount) { @@ -977,23 +942,21 @@ void MultiplayerAPI::rpcp(Node *p_node, int p_peer_id, bool p_unreliable, const ERR_FAIL_COND_MSG(network_peer->get_connection_status() != MultiplayerPeer::CONNECTION_CONNECTED, "Trying to call an RPC via a network peer which is not connected."); int node_id = network_peer->get_unique_id(); - bool skip_rpc = node_id == p_peer_id; bool call_local_native = false; bool call_local_script = false; - bool is_master = p_node->is_network_master(); uint16_t rpc_id = UINT16_MAX; const RPCConfig config = _get_rpc_config(p_node, p_method, rpc_id); ERR_FAIL_COND_MSG(config.name == StringName(), vformat("Unable to get the RPC configuration for the function \"%s\" at path: \"%s\". This happens when the method is not marked for RPCs.", p_method, p_node->get_path())); if (p_peer_id == 0 || p_peer_id == node_id || (p_peer_id < 0 && p_peer_id != -node_id)) { if (rpc_id & (1 << 15)) { - call_local_native = _should_call_local(config.rpc_mode, is_master, skip_rpc); + call_local_native = config.sync; } else { - call_local_script = _should_call_local(config.rpc_mode, is_master, skip_rpc); + call_local_script = config.sync; } } - if (!skip_rpc) { + if (p_peer_id != node_id) { #ifdef DEBUG_ENABLED _profile_node_data("out_rpc", p_node->get_instance_id()); #endif @@ -1030,7 +993,7 @@ void MultiplayerAPI::rpcp(Node *p_node, int p_peer_id, bool p_unreliable, const } } - ERR_FAIL_COND_MSG(skip_rpc && !(call_local_native || call_local_script), "RPC '" + p_method + "' on yourself is not allowed by selected mode."); + ERR_FAIL_COND_MSG(p_peer_id == node_id && !config.sync, "RPC '" + p_method + "' on yourself is not allowed by selected mode."); } Error MultiplayerAPI::send_bytes(Vector<uint8_t> p_data, int p_to, MultiplayerPeer::TransferMode p_mode) { @@ -1059,7 +1022,7 @@ void MultiplayerAPI::_process_raw(int p_from, const uint8_t *p_packet, int p_pac uint8_t *w = out.ptrw(); memcpy(&w[0], &p_packet[1], len); } - emit_signal("network_peer_packet", p_from, out); + emit_signal(SNAME("network_peer_packet"), p_from, out); } int MultiplayerAPI::get_network_unique_id() const { @@ -1068,9 +1031,7 @@ int MultiplayerAPI::get_network_unique_id() const { } bool MultiplayerAPI::is_network_server() const { - // XXX Maybe fail silently? Maybe should actually return true to make development of both local and online multiplayer easier? - ERR_FAIL_COND_V_MSG(!network_peer.is_valid(), false, "No network peer is assigned. I can't be a server."); - return network_peer->is_server(); + return network_peer.is_valid() && network_peer->is_server(); } void MultiplayerAPI::set_refuse_new_network_connections(bool p_refuse) { @@ -1138,9 +1099,6 @@ void MultiplayerAPI::_bind_methods() { BIND_ENUM_CONSTANT(RPC_MODE_REMOTE); BIND_ENUM_CONSTANT(RPC_MODE_MASTER); BIND_ENUM_CONSTANT(RPC_MODE_PUPPET); - BIND_ENUM_CONSTANT(RPC_MODE_REMOTESYNC); - BIND_ENUM_CONSTANT(RPC_MODE_MASTERSYNC); - BIND_ENUM_CONSTANT(RPC_MODE_PUPPETSYNC); } MultiplayerAPI::MultiplayerAPI() { diff --git a/core/io/multiplayer_api.h b/core/io/multiplayer_api.h index e9f96383c9..cc994a9852 100644 --- a/core/io/multiplayer_api.h +++ b/core/io/multiplayer_api.h @@ -43,14 +43,12 @@ public: RPC_MODE_REMOTE, // Using rpc() on it will call method in all remote peers RPC_MODE_MASTER, // Using rpc() on it will call method on wherever the master is, be it local or remote RPC_MODE_PUPPET, // Using rpc() on it will call method for all puppets - RPC_MODE_REMOTESYNC, // Using rpc() on it will call method in all remote peers and locally - RPC_MODE_MASTERSYNC, // Using rpc() on it will call method in the master peer and locally - RPC_MODE_PUPPETSYNC, // Using rpc() on it will call method in all puppets peers and locally }; struct RPCConfig { StringName name; RPCMode rpc_mode = RPC_MODE_DISABLED; + bool sync = false; MultiplayerPeer::TransferMode transfer_mode = MultiplayerPeer::TRANSFER_MODE_RELIABLE; int channel = 0; diff --git a/core/io/multiplayer_peer.cpp b/core/io/multiplayer_peer.cpp index 8126b4cea3..8b3b1eef8e 100644 --- a/core/io/multiplayer_peer.cpp +++ b/core/io/multiplayer_peer.cpp @@ -30,6 +30,29 @@ #include "multiplayer_peer.h" +#include "core/os/os.h" + +uint32_t MultiplayerPeer::generate_unique_id() const { + uint32_t hash = 0; + + while (hash == 0 || hash == 1) { + hash = hash_djb2_one_32( + (uint32_t)OS::get_singleton()->get_ticks_usec()); + hash = hash_djb2_one_32( + (uint32_t)OS::get_singleton()->get_unix_time(), hash); + hash = hash_djb2_one_32( + (uint32_t)OS::get_singleton()->get_user_data_dir().hash64(), hash); + hash = hash_djb2_one_32( + (uint32_t)((uint64_t)this), hash); // Rely on ASLR heap + hash = hash_djb2_one_32( + (uint32_t)((uint64_t)&hash), hash); // Rely on ASLR stack + + hash = hash & 0x7FFFFFFF; // Make it compatible with unsigned, since negative ID is used for exclusion + } + + return hash; +} + void MultiplayerPeer::_bind_methods() { ClassDB::bind_method(D_METHOD("set_transfer_mode", "mode"), &MultiplayerPeer::set_transfer_mode); ClassDB::bind_method(D_METHOD("get_transfer_mode"), &MultiplayerPeer::get_transfer_mode); @@ -41,6 +64,7 @@ void MultiplayerPeer::_bind_methods() { ClassDB::bind_method(D_METHOD("get_connection_status"), &MultiplayerPeer::get_connection_status); ClassDB::bind_method(D_METHOD("get_unique_id"), &MultiplayerPeer::get_unique_id); + ClassDB::bind_method(D_METHOD("generate_unique_id"), &MultiplayerPeer::generate_unique_id); ClassDB::bind_method(D_METHOD("set_refuse_new_connections", "enable"), &MultiplayerPeer::set_refuse_new_connections); ClassDB::bind_method(D_METHOD("is_refusing_new_connections"), &MultiplayerPeer::is_refusing_new_connections); diff --git a/core/io/multiplayer_peer.h b/core/io/multiplayer_peer.h index 432f47280f..91a3ad7954 100644 --- a/core/io/multiplayer_peer.h +++ b/core/io/multiplayer_peer.h @@ -72,6 +72,7 @@ public: virtual bool is_refusing_new_connections() const = 0; virtual ConnectionStatus get_connection_status() const = 0; + uint32_t generate_unique_id() const; MultiplayerPeer() {} }; diff --git a/core/io/packed_data_container.cpp b/core/io/packed_data_container.cpp index cf6a0b6027..4a76f0191d 100644 --- a/core/io/packed_data_container.cpp +++ b/core/io/packed_data_container.cpp @@ -268,21 +268,21 @@ uint32_t PackedDataContainer::_pack(const Variant &p_data, Vector<uint8_t> &tmpd d.get_key_list(&keys); List<DictKey> sortk; - for (List<Variant>::Element *E = keys.front(); E; E = E->next()) { + for (const Variant &key : keys) { DictKey dk; - dk.hash = E->get().hash(); - dk.key = E->get(); + dk.hash = key.hash(); + dk.key = key; sortk.push_back(dk); } sortk.sort(); int idx = 0; - for (List<DictKey>::Element *E = sortk.front(); E; E = E->next()) { - encode_uint32(E->get().hash, &tmpdata.write[pos + 8 + idx * 12 + 0]); - uint32_t ofs = _pack(E->get().key, tmpdata, string_cache); + for (const DictKey &E : sortk) { + encode_uint32(E.hash, &tmpdata.write[pos + 8 + idx * 12 + 0]); + uint32_t ofs = _pack(E.key, tmpdata, string_cache); encode_uint32(ofs, &tmpdata.write[pos + 8 + idx * 12 + 4]); - ofs = _pack(d[E->get().key], tmpdata, string_cache); + ofs = _pack(d[E.key], tmpdata, string_cache); encode_uint32(ofs, &tmpdata.write[pos + 8 + idx * 12 + 8]); idx++; } diff --git a/core/io/resource.cpp b/core/io/resource.cpp index efa622d976..727611a573 100644 --- a/core/io/resource.cpp +++ b/core/io/resource.cpp @@ -33,6 +33,7 @@ #include "core/core_string_names.h" #include "core/io/file_access.h" #include "core/io/resource_loader.h" +#include "core/math/math_funcs.h" #include "core/object/script_language.h" #include "core/os/os.h" #include "scene/main/node.h" //only so casting works @@ -94,12 +95,43 @@ String Resource::get_path() const { return path_cache; } -void Resource::set_subindex(int p_sub_index) { - subindex = p_sub_index; +String Resource::generate_scene_unique_id() { + // Generate a unique enough hash, but still user-readable. + // If it's not unique it does not matter because the saver will try again. + OS::Date date = OS::get_singleton()->get_date(); + OS::Time time = OS::get_singleton()->get_time(); + uint32_t hash = hash_djb2_one_32(OS::get_singleton()->get_ticks_usec()); + hash = hash_djb2_one_32(date.year, hash); + hash = hash_djb2_one_32(date.month, hash); + hash = hash_djb2_one_32(date.day, hash); + hash = hash_djb2_one_32(time.hour, hash); + hash = hash_djb2_one_32(time.minute, hash); + hash = hash_djb2_one_32(time.second, hash); + hash = hash_djb2_one_32(Math::rand(), hash); + + static constexpr uint32_t characters = 5; + static constexpr uint32_t char_count = ('z' - 'a'); + static constexpr uint32_t base = char_count + ('9' - '0'); + String id; + for (uint32_t i = 0; i < characters; i++) { + uint32_t c = hash % base; + if (c < char_count) { + id += String::chr('a' + c); + } else { + id += String::chr('0' + (c - char_count)); + } + hash /= base; + } + + return id; +} + +void Resource::set_scene_unique_id(const String &p_id) { + scene_unique_id = p_id; } -int Resource::get_subindex() const { - return subindex; +String Resource::get_scene_unique_id() const { + return scene_unique_id; } void Resource::set_name(const String &p_name) { @@ -133,15 +165,15 @@ Error Resource::copy_from(const Ref<Resource> &p_resource) { List<PropertyInfo> pi; p_resource->get_property_list(&pi); - for (List<PropertyInfo>::Element *E = pi.front(); E; E = E->next()) { - if (!(E->get().usage & PROPERTY_USAGE_STORAGE)) { + for (const PropertyInfo &E : pi) { + if (!(E.usage & PROPERTY_USAGE_STORAGE)) { continue; } - if (E->get().name == "resource_path") { + if (E.name == "resource_path") { continue; //do not change path } - set(E->get().name, p_resource->get(E->get().name)); + set(E.name, p_resource->get(E.name)); } return OK; } @@ -169,11 +201,11 @@ Ref<Resource> Resource::duplicate_for_local_scene(Node *p_for_scene, Map<Ref<Res r->local_scene = p_for_scene; - for (List<PropertyInfo>::Element *E = plist.front(); E; E = E->next()) { - if (!(E->get().usage & PROPERTY_USAGE_STORAGE)) { + for (const PropertyInfo &E : plist) { + if (!(E.usage & PROPERTY_USAGE_STORAGE)) { continue; } - Variant p = get(E->get().name); + Variant p = get(E.name); if (p.get_type() == Variant::OBJECT) { RES sr = p; if (sr.is_valid()) { @@ -189,7 +221,7 @@ Ref<Resource> Resource::duplicate_for_local_scene(Node *p_for_scene, Map<Ref<Res } } - r->set(E->get().name, p); + r->set(E.name, p); } return r; @@ -201,11 +233,11 @@ void Resource::configure_for_local_scene(Node *p_for_scene, Map<Ref<Resource>, R local_scene = p_for_scene; - for (List<PropertyInfo>::Element *E = plist.front(); E; E = E->next()) { - if (!(E->get().usage & PROPERTY_USAGE_STORAGE)) { + for (const PropertyInfo &E : plist) { + if (!(E.usage & PROPERTY_USAGE_STORAGE)) { continue; } - Variant p = get(E->get().name); + Variant p = get(E.name); if (p.get_type() == Variant::OBJECT) { RES sr = p; if (sr.is_valid()) { @@ -227,21 +259,21 @@ Ref<Resource> Resource::duplicate(bool p_subresources) const { Ref<Resource> r = (Resource *)ClassDB::instantiate(get_class()); ERR_FAIL_COND_V(r.is_null(), Ref<Resource>()); - for (List<PropertyInfo>::Element *E = plist.front(); E; E = E->next()) { - if (!(E->get().usage & PROPERTY_USAGE_STORAGE)) { + for (const PropertyInfo &E : plist) { + if (!(E.usage & PROPERTY_USAGE_STORAGE)) { continue; } - Variant p = get(E->get().name); + Variant p = get(E.name); if ((p.get_type() == Variant::DICTIONARY || p.get_type() == Variant::ARRAY)) { - r->set(E->get().name, p.duplicate(p_subresources)); - } else if (p.get_type() == Variant::OBJECT && (p_subresources || (E->get().usage & PROPERTY_USAGE_DO_NOT_SHARE_ON_DUPLICATE))) { + r->set(E.name, p.duplicate(p_subresources)); + } else if (p.get_type() == Variant::OBJECT && (p_subresources || (E.usage & PROPERTY_USAGE_DO_NOT_SHARE_ON_DUPLICATE))) { RES sr = p; if (sr.is_valid()) { - r->set(E->get().name, sr->duplicate(p_subresources)); + r->set(E.name, sr->duplicate(p_subresources)); } } else { - r->set(E->get().name, p); + r->set(E.name, p); } } @@ -285,9 +317,9 @@ uint32_t Resource::hash_edited_version() const { List<PropertyInfo> plist; get_property_list(&plist); - for (List<PropertyInfo>::Element *E = plist.front(); E; E = E->next()) { - if (E->get().usage & PROPERTY_USAGE_STORAGE && E->get().type == Variant::OBJECT && E->get().hint == PROPERTY_HINT_RESOURCE_TYPE) { - RES res = get(E->get().name); + for (const PropertyInfo &E : plist) { + if (E.usage & PROPERTY_USAGE_STORAGE && E.type == Variant::OBJECT && E.hint == PROPERTY_HINT_RESOURCE_TYPE) { + RES res = get(E.name); if (res.is_valid()) { hash = hash_djb2_one_32(res->hash_edited_version(), hash); } @@ -350,8 +382,8 @@ bool Resource::is_translation_remapped() const { #ifdef TOOLS_ENABLED //helps keep IDs same number when loading/saving scenes. -1 clears ID and it Returns -1 when no id stored -void Resource::set_id_for_path(const String &p_path, int p_id) { - if (p_id == -1) { +void Resource::set_id_for_path(const String &p_path, const String &p_id) { + if (p_id == "") { ResourceCache::path_cache_lock.write_lock(); ResourceCache::resource_path_cache[p_path].erase(get_path()); ResourceCache::path_cache_lock.write_unlock(); @@ -362,15 +394,15 @@ void Resource::set_id_for_path(const String &p_path, int p_id) { } } -int Resource::get_id_for_path(const String &p_path) const { +String Resource::get_id_for_path(const String &p_path) const { ResourceCache::path_cache_lock.read_lock(); if (ResourceCache::resource_path_cache[p_path].has(get_path())) { - int result = ResourceCache::resource_path_cache[p_path][get_path()]; + String result = ResourceCache::resource_path_cache[p_path][get_path()]; ResourceCache::path_cache_lock.read_unlock(); return result; } else { ResourceCache::path_cache_lock.read_unlock(); - return -1; + return ""; } } #endif @@ -414,7 +446,7 @@ Resource::~Resource() { HashMap<String, Resource *> ResourceCache::resources; #ifdef TOOLS_ENABLED -HashMap<String, HashMap<String, int>> ResourceCache::resource_path_cache; +HashMap<String, HashMap<String, String>> ResourceCache::resource_path_cache; #endif RWLock ResourceCache::lock; diff --git a/core/io/resource.h b/core/io/resource.h index 028fed1c6e..e864b371ad 100644 --- a/core/io/resource.h +++ b/core/io/resource.h @@ -31,6 +31,7 @@ #ifndef RESOURCE_H #define RESOURCE_H +#include "core/io/resource_uid.h" #include "core/object/class_db.h" #include "core/object/ref_counted.h" #include "core/templates/safe_refcount.h" @@ -59,7 +60,7 @@ private: String name; String path_cache; - int subindex = 0; + String scene_unique_id; virtual bool _use_builtin_script() const { return true; } @@ -105,8 +106,9 @@ public: virtual void set_path(const String &p_path, bool p_take_over = false); String get_path() const; - void set_subindex(int p_sub_index); - int get_subindex() const; + static String generate_scene_unique_id(); + void set_scene_unique_id(const String &p_id); + String get_scene_unique_id() const; virtual Ref<Resource> duplicate(bool p_subresources = false) const; Ref<Resource> duplicate_for_local_scene(Node *p_for_scene, Map<Ref<Resource>, Ref<Resource>> &remap_cache); @@ -140,8 +142,8 @@ public: #ifdef TOOLS_ENABLED //helps keep IDs same number when loading/saving scenes. -1 clears ID and it Returns -1 when no id stored - void set_id_for_path(const String &p_path, int p_id); - int get_id_for_path(const String &p_path) const; + void set_id_for_path(const String &p_path, const String &p_id); + String get_id_for_path(const String &p_path) const; #endif Resource(); @@ -156,7 +158,7 @@ class ResourceCache { static RWLock lock; static HashMap<String, Resource *> resources; #ifdef TOOLS_ENABLED - static HashMap<String, HashMap<String, int>> resource_path_cache; // each tscn has a set of resource paths and IDs + static HashMap<String, HashMap<String, String>> resource_path_cache; // Each tscn has a set of resource paths and IDs. static RWLock path_cache_lock; #endif // TOOLS_ENABLED friend void unregister_core_types(); diff --git a/core/io/resource_format_binary.cpp b/core/io/resource_format_binary.cpp index 0e9815245f..a3ebc32cc5 100644 --- a/core/io/resource_format_binary.cpp +++ b/core/io/resource_format_binary.cpp @@ -84,9 +84,10 @@ enum { OBJECT_EXTERNAL_RESOURCE = 1, OBJECT_INTERNAL_RESOURCE = 2, OBJECT_EXTERNAL_RESOURCE_INDEX = 3, - //version 2: added 64 bits support for float and int - //version 3: changed nodepath encoding - FORMAT_VERSION = 3, + // Version 2: added 64 bits support for float and int. + // Version 3: changed nodepath encoding. + // Version 4: new string ID for ext/subresources, breaks forward compat. + FORMAT_VERSION = 4, FORMAT_VERSION_CAN_RENAME_DEPS = 1, FORMAT_VERSION_NO_NODEPATH_PROPERTY = 3, }; @@ -311,7 +312,14 @@ Error ResourceLoaderBinary::parse_variant(Variant &r_v) { } break; case OBJECT_INTERNAL_RESOURCE: { uint32_t index = f->get_32(); - String path = res_path + "::" + itos(index); + String path; + + if (using_named_scene_ids) { // New format. + ERR_FAIL_INDEX_V((int)index, internal_resources.size(), ERR_PARSE_ERROR); + path = internal_resources[index].path; + } else { + path += res_path + "::" + itos(index); + } //always use internal cache for loading internal resources if (!internal_index_cache.has(path)) { @@ -320,7 +328,6 @@ Error ResourceLoaderBinary::parse_variant(Variant &r_v) { } else { r_v = internal_index_cache[path]; } - } break; case OBJECT_EXTERNAL_RESOURCE: { //old file format, still around for compatibility @@ -378,7 +385,6 @@ Error ResourceLoaderBinary::parse_variant(Variant &r_v) { ERR_FAIL_V(ERR_FILE_CORRUPT); } break; } - } break; case VARIANT_CALLABLE: { r_v = Callable(); @@ -659,15 +665,17 @@ Error ResourceLoaderBinary::load() { //maybe it is loaded already String path; - int subindex = 0; + String id; if (!main) { path = internal_resources[i].path; if (path.begins_with("local://")) { path = path.replace_first("local://", ""); - subindex = path.to_int(); + id = path; path = res_path + "::" + path; + + internal_resources.write[i].path = path; // Update path. } if (cache_mode == ResourceFormatLoader::CACHE_MODE_REUSE) { @@ -722,7 +730,7 @@ Error ResourceLoaderBinary::load() { if (path != String() && cache_mode != ResourceFormatLoader::CACHE_MODE_IGNORE) { r->set_path(path, cache_mode == ResourceFormatLoader::CACHE_MODE_REPLACE); //if got here because the resource with same path has different type, replace it } - r->set_subindex(subindex); + r->set_scene_unique_id(id); } if (!main) { @@ -808,13 +816,18 @@ String ResourceLoaderBinary::get_unicode_string() { } void ResourceLoaderBinary::get_dependencies(FileAccess *p_f, List<String> *p_dependencies, bool p_add_types) { - open(p_f); + open(p_f, false, true); if (error) { return; } for (int i = 0; i < external_resources.size(); i++) { - String dep = external_resources[i].path; + String dep; + if (external_resources[i].uid != ResourceUID::INVALID_ID) { + dep = ResourceUID::get_singleton()->id_to_text(external_resources[i].uid); + } else { + dep = external_resources[i].path; + } if (p_add_types && external_resources[i].type != String()) { dep += "::" + external_resources[i].type; @@ -824,7 +837,7 @@ void ResourceLoaderBinary::get_dependencies(FileAccess *p_f, List<String> *p_dep } } -void ResourceLoaderBinary::open(FileAccess *p_f) { +void ResourceLoaderBinary::open(FileAccess *p_f, bool p_no_resources, bool p_keep_uuid_paths) { error = OK; f = p_f; @@ -879,10 +892,28 @@ void ResourceLoaderBinary::open(FileAccess *p_f) { print_bl("type: " + type); importmd_ofs = f->get_64(); - for (int i = 0; i < 14; i++) { + uint32_t flags = f->get_32(); + if (flags & ResourceFormatSaverBinaryInstance::FORMAT_FLAG_NAMED_SCENE_IDS) { + using_named_scene_ids = true; + } + if (flags & ResourceFormatSaverBinaryInstance::FORMAT_FLAG_UIDS) { + using_uids = true; + } + + if (using_uids) { + uid = f->get_64(); + } else { + uid = ResourceUID::INVALID_ID; + } + + for (int i = 0; i < 5; i++) { f->get_32(); //skip a few reserved fields } + if (p_no_resources) { + return; + } + uint32_t string_table_size = f->get_32(); string_map.resize(string_table_size); for (uint32_t i = 0; i < string_table_size; i++) { @@ -896,8 +927,18 @@ void ResourceLoaderBinary::open(FileAccess *p_f) { for (uint32_t i = 0; i < ext_resources_size; i++) { ExtResource er; er.type = get_unicode_string(); - er.path = get_unicode_string(); + if (using_uids) { + er.uid = f->get_64(); + if (!p_keep_uuid_paths && er.uid != ResourceUID::INVALID_ID) { + if (ResourceUID::get_singleton()->has_id(er.uid)) { + // If a UID is found and the path is valid, it will be used, otherwise, it falls back to the path. + er.path = ResourceUID::get_singleton()->get_id_path(er.uid); + } else { + WARN_PRINT(String(res_path + ": In external resource #" + itos(i) + ", invalid UUID: " + ResourceUID::get_singleton()->id_to_text(er.uid) + " - using text path instead: " + er.path).utf8().get_data()); + } + } + } external_resources.push_back(er); } @@ -1013,8 +1054,8 @@ void ResourceFormatLoaderBinary::get_recognized_extensions_for_type(const String extensions.sort(); - for (List<String>::Element *E = extensions.front(); E; E = E->next()) { - String ext = E->get().to_lower(); + for (const String &E : extensions) { + String ext = E.to_lower(); p_extensions->push_back(ext); } } @@ -1024,8 +1065,8 @@ void ResourceFormatLoaderBinary::get_recognized_extensions(List<String> *p_exten ClassDB::get_resource_base_extensions(&extensions); extensions.sort(); - for (List<String>::Element *E = extensions.front(); E; E = E->next()) { - String ext = E->get().to_lower(); + for (const String &E : extensions) { + String ext = E.to_lower(); p_extensions->push_back(ext); } } @@ -1161,8 +1202,15 @@ Error ResourceFormatLoaderBinary::rename_dependencies(const String &p_path, cons uint64_t importmd_ofs = f->get_64(); fw->store_64(0); //metadata offset - for (int i = 0; i < 14; i++) { - fw->store_32(0); + uint32_t flags = f->get_32(); + bool using_uids = (flags & ResourceFormatSaverBinaryInstance::FORMAT_FLAG_UIDS); + uint64_t uid_data = f->get_64(); + + fw->store_32(flags); + fw->store_64(uid_data); + + for (int i = 0; i < 5; i++) { + f->store_32(0); // reserved f->get_32(); } @@ -1183,6 +1231,16 @@ Error ResourceFormatLoaderBinary::rename_dependencies(const String &p_path, cons String type = get_ustring(f); String path = get_ustring(f); + if (using_uids) { + ResourceUID::ID uid = f->get_64(); + if (uid != ResourceUID::INVALID_ID) { + if (ResourceUID::get_singleton()->has_id(uid)) { + // If a UID is found and the path is valid, it will be used, otherwise, it falls back to the path. + path = ResourceUID::get_singleton()->get_id_path(uid); + } + } + } + bool relative = false; if (!path.begins_with("res://")) { path = local_path.plus_file(path).simplify_path(); @@ -1194,6 +1252,8 @@ Error ResourceFormatLoaderBinary::rename_dependencies(const String &p_path, cons path = np; } + String full_path = path; + if (relative) { //restore relative path = local_path.path_to_file(path); @@ -1201,6 +1261,11 @@ Error ResourceFormatLoaderBinary::rename_dependencies(const String &p_path, cons save_ustring(fw, type); save_ustring(fw, path); + + if (using_uids) { + ResourceUID::ID uid = ResourceSaver::get_resource_id_for_path(full_path); + f->store_64(uid); + } } int64_t size_diff = (int64_t)fw->get_position() - (int64_t)f->get_position(); @@ -1256,6 +1321,28 @@ String ResourceFormatLoaderBinary::get_resource_type(const String &p_path) const return ClassDB::get_compatibility_remapped_class(r); } +ResourceUID::ID ResourceFormatLoaderBinary::get_resource_uid(const String &p_path) const { + String ext = p_path.get_extension().to_lower(); + if (!ClassDB::is_resource_extension(ext)) { + return ResourceUID::INVALID_ID; + } + + FileAccess *f = FileAccess::open(p_path, FileAccess::READ); + if (!f) { + return ResourceUID::INVALID_ID; //could not read + } + + ResourceLoaderBinary loader; + loader.local_path = ProjectSettings::get_singleton()->localize_path(p_path); + loader.res_path = loader.local_path; + //loader.set_local_path( Globals::get_singleton()->localize_path(p_path) ); + loader.open(f, true); + if (loader.error != OK) { + return ResourceUID::INVALID_ID; //could not read + } + return loader.uid; +} + /////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////// @@ -1269,11 +1356,7 @@ void ResourceFormatSaverBinaryInstance::_pad_buffer(FileAccess *f, int p_bytes) } } -void ResourceFormatSaverBinaryInstance::_write_variant(const Variant &p_property, const PropertyInfo &p_hint) { - write_variant(f, p_property, resource_set, external_resources, string_map, p_hint); -} - -void ResourceFormatSaverBinaryInstance::write_variant(FileAccess *f, const Variant &p_property, Set<RES> &resource_set, Map<RES, int> &external_resources, Map<StringName, int> &string_map, const PropertyInfo &p_hint) { +void ResourceFormatSaverBinaryInstance::write_variant(FileAccess *f, const Variant &p_property, Map<RES, int> &resource_map, Map<RES, int> &external_resources, Map<StringName, int> &string_map, const PropertyInfo &p_hint) { switch (p_property.get_type()) { case Variant::NIL: { f->store_32(VARIANT_NIL); @@ -1492,13 +1575,13 @@ void ResourceFormatSaverBinaryInstance::write_variant(FileAccess *f, const Varia f->store_32(OBJECT_EXTERNAL_RESOURCE_INDEX); f->store_32(external_resources[res]); } else { - if (!resource_set.has(res)) { + if (!resource_map.has(res)) { f->store_32(OBJECT_EMPTY); ERR_FAIL_MSG("Resource was not pre cached for the resource section, most likely due to circular reference."); } f->store_32(OBJECT_INTERNAL_RESOURCE); - f->store_32(res->get_subindex()); + f->store_32(resource_map[res]); //internal resource } @@ -1520,14 +1603,14 @@ void ResourceFormatSaverBinaryInstance::write_variant(FileAccess *f, const Varia List<Variant> keys; d.get_key_list(&keys); - for (List<Variant>::Element *E = keys.front(); E; E = E->next()) { + for (const Variant &E : keys) { /* - if (!_check_type(dict[E->get()])) + if (!_check_type(dict[E])) continue; */ - write_variant(f, E->get(), resource_set, external_resources, string_map); - write_variant(f, d[E->get()], resource_set, external_resources, string_map); + write_variant(f, E, resource_map, external_resources, string_map); + write_variant(f, d[E], resource_map, external_resources, string_map); } } break; @@ -1536,7 +1619,7 @@ void ResourceFormatSaverBinaryInstance::write_variant(FileAccess *f, const Varia Array a = p_property; f->store_32(uint32_t(a.size())); for (int i = 0; i < a.size(); i++) { - write_variant(f, a[i], resource_set, external_resources, string_map); + write_variant(f, a[i], resource_map, external_resources, string_map); } } break; @@ -1677,15 +1760,15 @@ void ResourceFormatSaverBinaryInstance::_find_resources(const Variant &p_variant res->get_property_list(&property_list); - for (List<PropertyInfo>::Element *E = property_list.front(); E; E = E->next()) { - if (E->get().usage & PROPERTY_USAGE_STORAGE) { - Variant value = res->get(E->get().name); - if (E->get().usage & PROPERTY_USAGE_RESOURCE_NOT_PERSISTENT) { + for (const PropertyInfo &E : property_list) { + if (E.usage & PROPERTY_USAGE_STORAGE) { + Variant value = res->get(E.name); + if (E.usage & PROPERTY_USAGE_RESOURCE_NOT_PERSISTENT) { RES sres = value; if (sres.is_valid()) { NonPersistentKey npk; npk.base = res; - npk.property = E->get().name; + npk.property = E.name; non_persistent_map[npk] = sres; resource_set.insert(sres); saved_resources.push_back(sres); @@ -1715,9 +1798,9 @@ void ResourceFormatSaverBinaryInstance::_find_resources(const Variant &p_variant Dictionary d = p_variant; List<Variant> keys; d.get_key_list(&keys); - for (List<Variant>::Element *E = keys.front(); E; E = E->next()) { - _find_resources(E->get()); - Variant v = d[E->get()]; + for (const Variant &E : keys) { + _find_resources(E); + Variant v = d[E]; _find_resources(v); } } break; @@ -1816,46 +1899,49 @@ Error ResourceFormatSaverBinaryInstance::save(const String &p_path, const RES &p save_unicode_string(f, p_resource->get_class()); f->store_64(0); //offset to import metadata - for (int i = 0; i < 14; i++) { + f->store_32(FORMAT_FLAG_NAMED_SCENE_IDS | FORMAT_FLAG_UIDS); + ResourceUID::ID uid = ResourceSaver::get_resource_id_for_path(p_path, true); + f->store_64(uid); + for (int i = 0; i < 5; i++) { f->store_32(0); // reserved } List<ResourceData> resources; { - for (List<RES>::Element *E = saved_resources.front(); E; E = E->next()) { + for (const RES &E : saved_resources) { ResourceData &rd = resources.push_back(ResourceData())->get(); - rd.type = E->get()->get_class(); + rd.type = E->get_class(); List<PropertyInfo> property_list; - E->get()->get_property_list(&property_list); + E->get_property_list(&property_list); - for (List<PropertyInfo>::Element *F = property_list.front(); F; F = F->next()) { - if (skip_editor && F->get().name.begins_with("__editor")) { + for (const PropertyInfo &F : property_list) { + if (skip_editor && F.name.begins_with("__editor")) { continue; } - if ((F->get().usage & PROPERTY_USAGE_STORAGE)) { + if ((F.usage & PROPERTY_USAGE_STORAGE)) { Property p; - p.name_idx = get_string_index(F->get().name); + p.name_idx = get_string_index(F.name); - if (F->get().usage & PROPERTY_USAGE_RESOURCE_NOT_PERSISTENT) { + if (F.usage & PROPERTY_USAGE_RESOURCE_NOT_PERSISTENT) { NonPersistentKey npk; - npk.base = E->get(); - npk.property = F->get().name; + npk.base = E; + npk.property = F.name; if (non_persistent_map.has(npk)) { p.value = non_persistent_map[npk]; } } else { - p.value = E->get()->get(F->get().name); + p.value = E->get(F.name); } - Variant default_value = ClassDB::class_get_default_property_value(E->get()->get_class(), F->get().name); + Variant default_value = ClassDB::class_get_default_property_value(E->get_class(), F.name); if (default_value.get_type() != Variant::NIL && bool(Variant::evaluate(Variant::OP_EQUAL, p.value, default_value))) { continue; } - p.pi = F->get(); + p.pi = F; rd.properties.push_back(p); } @@ -1882,41 +1968,47 @@ Error ResourceFormatSaverBinaryInstance::save(const String &p_path, const RES &p String path = save_order[i]->get_path(); path = relative_paths ? local_path.path_to_file(path) : path; save_unicode_string(f, path); + ResourceUID::ID ruid = ResourceSaver::get_resource_id_for_path(save_order[i]->get_path(), false); + f->store_64(ruid); } // save internal resource table f->store_32(saved_resources.size()); //amount of internal resources Vector<uint64_t> ofs_pos; - Set<int> used_indices; + Set<String> used_unique_ids; - for (List<RES>::Element *E = saved_resources.front(); E; E = E->next()) { - RES r = E->get(); + for (RES &r : saved_resources) { if (r->get_path() == "" || r->get_path().find("::") != -1) { - if (r->get_subindex() != 0) { - if (used_indices.has(r->get_subindex())) { - r->set_subindex(0); //repeated + if (r->get_scene_unique_id() != "") { + if (used_unique_ids.has(r->get_scene_unique_id())) { + r->set_scene_unique_id(""); } else { - used_indices.insert(r->get_subindex()); + used_unique_ids.insert(r->get_scene_unique_id()); } } } } - for (List<RES>::Element *E = saved_resources.front(); E; E = E->next()) { - RES r = E->get(); + Map<RES, int> resource_map; + int res_index = 0; + for (RES &r : saved_resources) { if (r->get_path() == "" || r->get_path().find("::") != -1) { - if (r->get_subindex() == 0) { - int new_subindex = 1; - if (used_indices.size()) { - new_subindex = used_indices.back()->get() + 1; + if (r->get_scene_unique_id() == "") { + String new_id; + + while (true) { + new_id = r->get_class() + "_" + Resource::generate_scene_unique_id(); + if (!used_unique_ids.has(new_id)) { + break; + } } - r->set_subindex(new_subindex); - used_indices.insert(new_subindex); + r->set_scene_unique_id(new_id); + used_unique_ids.insert(new_id); } - save_unicode_string(f, "local://" + itos(r->get_subindex())); + save_unicode_string(f, "local://" + r->get_scene_unique_id()); if (takeover_paths) { - r->set_path(p_path + "::" + itos(r->get_subindex()), true); + r->set_path(p_path + "::" + r->get_scene_unique_id(), true); } #ifdef TOOLS_ENABLED r->set_edited(false); @@ -1926,22 +2018,20 @@ Error ResourceFormatSaverBinaryInstance::save(const String &p_path, const RES &p } ofs_pos.push_back(f->get_position()); f->store_64(0); //offset in 64 bits + resource_map[r] = res_index++; } Vector<uint64_t> ofs_table; //now actually save the resources - for (List<ResourceData>::Element *E = resources.front(); E; E = E->next()) { - ResourceData &rd = E->get(); - + for (const ResourceData &rd : resources) { ofs_table.push_back(f->get_position()); save_unicode_string(f, rd.type); f->store_32(rd.properties.size()); - for (List<Property>::Element *F = rd.properties.front(); F; F = F->next()) { - Property &p = F->get(); + for (const Property &p : rd.properties) { f->store_32(p.name_idx); - _write_variant(p.value, F->get().pi); + write_variant(f, p.value, resource_map, external_resources, string_map, p.pi); } } diff --git a/core/io/resource_format_binary.h b/core/io/resource_format_binary.h index abc7403935..ac964d2053 100644 --- a/core/io/resource_format_binary.h +++ b/core/io/resource_format_binary.h @@ -47,6 +47,8 @@ class ResourceLoaderBinary { uint64_t importmd_ofs = 0; + ResourceUID::ID uid = ResourceUID::INVALID_ID; + Vector<char> str_buf; List<RES> resource_cache; @@ -57,9 +59,12 @@ class ResourceLoaderBinary { struct ExtResource { String path; String type; + ResourceUID::ID uid = ResourceUID::INVALID_ID; RES cache; }; + bool using_named_scene_ids = false; + bool using_uids = false; bool use_sub_threads = false; float *progress = nullptr; Vector<ExtResource> external_resources; @@ -93,7 +98,7 @@ public: void set_translation_remapped(bool p_remapped); void set_remaps(const Map<String, String> &p_remaps) { remaps = p_remaps; } - void open(FileAccess *p_f); + void open(FileAccess *p_f, bool p_no_resources = false, bool p_keep_uuid_paths = false); String recognize(FileAccess *p_f); void get_dependencies(FileAccess *p_f, List<String> *p_dependencies, bool p_add_types); @@ -108,6 +113,7 @@ public: virtual void get_recognized_extensions(List<String> *p_extensions) const; virtual bool handles_type(const String &p_type) const; virtual String get_resource_type(const String &p_path) const; + virtual ResourceUID::ID get_resource_uid(const String &p_path) const; virtual void get_dependencies(const String &p_path, List<String> *p_dependencies, bool p_add_types = false); virtual Error rename_dependencies(const String &p_path, const Map<String, String> &p_map); }; @@ -150,14 +156,17 @@ class ResourceFormatSaverBinaryInstance { }; static void _pad_buffer(FileAccess *f, int p_bytes); - void _write_variant(const Variant &p_property, const PropertyInfo &p_hint = PropertyInfo()); void _find_resources(const Variant &p_variant, bool p_main = false); static void save_unicode_string(FileAccess *f, const String &p_string, bool p_bit_on_len = false); int get_string_index(const String &p_string); public: + enum { + FORMAT_FLAG_NAMED_SCENE_IDS = 1, + FORMAT_FLAG_UIDS = 2, + }; Error save(const String &p_path, const RES &p_resource, uint32_t p_flags = 0); - static void write_variant(FileAccess *f, const Variant &p_property, Set<RES> &resource_set, Map<RES, int> &external_resources, Map<StringName, int> &string_map, const PropertyInfo &p_hint = PropertyInfo()); + static void write_variant(FileAccess *f, const Variant &p_property, Map<RES, int> &resource_map, Map<RES, int> &external_resources, Map<StringName, int> &string_map, const PropertyInfo &p_hint = PropertyInfo()); }; class ResourceFormatSaverBinary : public ResourceFormatSaver { diff --git a/core/io/resource_importer.cpp b/core/io/resource_importer.cpp index b503655edd..1e166015b0 100644 --- a/core/io/resource_importer.cpp +++ b/core/io/resource_importer.cpp @@ -93,6 +93,8 @@ Error ResourceFormatImporter::_get_path_and_type(const String &p_path, PathAndTy r_path_and_type.type = ClassDB::get_compatibility_remapped_class(value); } else if (assign == "importer") { r_path_and_type.importer = value; + } else if (assign == "uid") { + r_path_and_type.uid = ResourceUID::get_singleton()->text_to_id(value); } else if (assign == "group_file") { r_path_and_type.group_file = value; } else if (assign == "metadata") { @@ -146,10 +148,10 @@ void ResourceFormatImporter::get_recognized_extensions(List<String> *p_extension for (int i = 0; i < importers.size(); i++) { List<String> local_exts; importers[i]->get_recognized_extensions(&local_exts); - for (List<String>::Element *F = local_exts.front(); F; F = F->next()) { - if (!found.has(F->get())) { - p_extensions->push_back(F->get()); - found.insert(F->get()); + for (const String &F : local_exts) { + if (!found.has(F)) { + p_extensions->push_back(F); + found.insert(F); } } } @@ -175,10 +177,10 @@ void ResourceFormatImporter::get_recognized_extensions_for_type(const String &p_ List<String> local_exts; importers[i]->get_recognized_extensions(&local_exts); - for (List<String>::Element *F = local_exts.front(); F; F = F->next()) { - if (!found.has(F->get())) { - p_extensions->push_back(F->get()); - found.insert(F->get()); + for (const String &F : local_exts) { + if (!found.has(F)) { + p_extensions->push_back(F); + found.insert(F); } } } @@ -336,6 +338,17 @@ String ResourceFormatImporter::get_resource_type(const String &p_path) const { return pat.type; } +ResourceUID::ID ResourceFormatImporter::get_resource_uid(const String &p_path) const { + PathAndType pat; + Error err = _get_path_and_type(p_path, pat); + + if (err != OK) { + return ResourceUID::INVALID_ID; + } + + return pat.uid; +} + Variant ResourceFormatImporter::get_resource_metadata(const String &p_path) const { PathAndType pat; Error err = _get_path_and_type(p_path, pat); @@ -372,8 +385,8 @@ void ResourceFormatImporter::get_importers_for_extension(const String &p_extensi for (int i = 0; i < importers.size(); i++) { List<String> local_exts; importers[i]->get_recognized_extensions(&local_exts); - for (List<String>::Element *F = local_exts.front(); F; F = F->next()) { - if (p_extension.to_lower() == F->get()) { + for (const String &F : local_exts) { + if (p_extension.to_lower() == F) { r_importers->push_back(importers[i]); } } @@ -393,8 +406,8 @@ Ref<ResourceImporter> ResourceFormatImporter::get_importer_by_extension(const St for (int i = 0; i < importers.size(); i++) { List<String> local_exts; importers[i]->get_recognized_extensions(&local_exts); - for (List<String>::Element *F = local_exts.front(); F; F = F->next()) { - if (p_extension.to_lower() == F->get() && importers[i]->get_priority() > priority) { + for (const String &F : local_exts) { + if (p_extension.to_lower() == F && importers[i]->get_priority() > priority) { importer = importers[i]; priority = importers[i]->get_priority(); } @@ -445,3 +458,8 @@ ResourceFormatImporter *ResourceFormatImporter::singleton = nullptr; ResourceFormatImporter::ResourceFormatImporter() { singleton = this; } + +void ResourceImporter::_bind_methods() { + BIND_ENUM_CONSTANT(IMPORT_ORDER_DEFAULT); + BIND_ENUM_CONSTANT(IMPORT_ORDER_SCENE); +} diff --git a/core/io/resource_importer.h b/core/io/resource_importer.h index 2ceeb176e5..a1cacbd306 100644 --- a/core/io/resource_importer.h +++ b/core/io/resource_importer.h @@ -42,6 +42,7 @@ class ResourceFormatImporter : public ResourceFormatLoader { String importer; String group_file; Variant metadata; + uint64_t uid = ResourceUID::INVALID_ID; }; Error _get_path_and_type(const String &p_path, PathAndType &r_path_and_type, bool *r_valid = nullptr) const; @@ -63,6 +64,8 @@ public: virtual bool recognize_path(const String &p_path, const String &p_for_type = String()) const; virtual bool handles_type(const String &p_type) const; virtual String get_resource_type(const String &p_path) const; + virtual ResourceUID::ID get_resource_uid(const String &p_path) const; + virtual Variant get_resource_metadata(const String &p_path) const; virtual bool is_import_valid(const String &p_path) const; virtual void get_dependencies(const String &p_path, List<String> *p_dependencies, bool p_add_types = false); @@ -96,6 +99,9 @@ public: class ResourceImporter : public RefCounted { GDCLASS(ResourceImporter, RefCounted); +protected: + static void _bind_methods(); + public: virtual String get_importer_name() const = 0; virtual String get_visible_name() const = 0; @@ -103,7 +109,7 @@ public: virtual String get_save_extension() const = 0; virtual String get_resource_type() const = 0; virtual float get_priority() const { return 1.0; } - virtual int get_import_order() const { return 0; } + virtual int get_import_order() const { return IMPORT_ORDER_DEFAULT; } virtual int get_format_version() const { return 0; } struct ImportOption { @@ -117,6 +123,11 @@ public: ImportOption() {} }; + enum ImportOrder { + IMPORT_ORDER_DEFAULT = 0, + IMPORT_ORDER_SCENE = 100, + }; + virtual bool has_advanced_options() const { return false; } virtual void show_advanced_options(const String &p_path) {} @@ -137,4 +148,6 @@ public: virtual String get_import_settings_string() const { return String(); } }; +VARIANT_ENUM_CAST(ResourceImporter::ImportOrder); + #endif // RESOURCE_IMPORTER_H diff --git a/core/io/resource_loader.cpp b/core/io/resource_loader.cpp index c5dfe1f2b0..d02d827443 100644 --- a/core/io/resource_loader.cpp +++ b/core/io/resource_loader.cpp @@ -58,8 +58,8 @@ bool ResourceFormatLoader::recognize_path(const String &p_path, const String &p_ get_recognized_extensions_for_type(p_for_type, &extensions); } - for (List<String>::Element *E = extensions.front(); E; E = E->next()) { - if (E->get().nocasecmp_to(extension) == 0) { + for (const String &E : extensions) { + if (E.nocasecmp_to(extension) == 0) { return true; } } @@ -84,6 +84,14 @@ String ResourceFormatLoader::get_resource_type(const String &p_path) const { return ""; } +ResourceUID::ID ResourceFormatLoader::get_resource_uid(const String &p_path) const { + if (get_script_instance() && get_script_instance()->has_method("_get_resource_uid")) { + return get_script_instance()->call("_get_resource_uid", p_path); + } + + return ResourceUID::INVALID_ID; +} + void ResourceFormatLoader::get_recognized_extensions_for_type(const String &p_type, List<String> *p_extensions) const { if (p_type == "" || handles_type(p_type)) { get_recognized_extensions(p_extensions); @@ -270,13 +278,18 @@ void ResourceLoader::_thread_load_function(void *p_userdata) { thread_load_mutex->unlock(); } -Error ResourceLoader::load_threaded_request(const String &p_path, const String &p_type_hint, bool p_use_sub_threads, ResourceFormatLoader::CacheMode p_cache_mode, const String &p_source_resource) { - String local_path; - if (p_path.is_rel_path()) { - local_path = "res://" + p_path; +static String _validate_local_path(const String &p_path) { + ResourceUID::ID uid = ResourceUID::get_singleton()->text_to_id(p_path); + if (uid != ResourceUID::INVALID_ID) { + return ResourceUID::get_singleton()->get_id_path(uid); + } else if (p_path.is_rel_path()) { + return "res://" + p_path; } else { - local_path = ProjectSettings::get_singleton()->localize_path(p_path); + return ProjectSettings::get_singleton()->localize_path(p_path); } +} +Error ResourceLoader::load_threaded_request(const String &p_path, const String &p_type_hint, bool p_use_sub_threads, ResourceFormatLoader::CacheMode p_cache_mode, const String &p_source_resource) { + String local_path = _validate_local_path(p_path); thread_load_mutex->lock(); @@ -399,12 +412,7 @@ float ResourceLoader::_dependency_get_progress(const String &p_path) { } ResourceLoader::ThreadLoadStatus ResourceLoader::load_threaded_get_status(const String &p_path, float *r_progress) { - String local_path; - if (p_path.is_rel_path()) { - local_path = "res://" + p_path; - } else { - local_path = ProjectSettings::get_singleton()->localize_path(p_path); - } + String local_path = _validate_local_path(p_path); thread_load_mutex->lock(); if (!thread_load_tasks.has(local_path)) { @@ -424,12 +432,7 @@ ResourceLoader::ThreadLoadStatus ResourceLoader::load_threaded_get_status(const } RES ResourceLoader::load_threaded_get(const String &p_path, Error *r_error) { - String local_path; - if (p_path.is_rel_path()) { - local_path = "res://" + p_path; - } else { - local_path = ProjectSettings::get_singleton()->localize_path(p_path); - } + String local_path = _validate_local_path(p_path); thread_load_mutex->lock(); if (!thread_load_tasks.has(local_path)) { @@ -510,12 +513,7 @@ RES ResourceLoader::load(const String &p_path, const String &p_type_hint, Resour *r_error = ERR_CANT_OPEN; } - String local_path; - if (p_path.is_rel_path()) { - local_path = "res://" + p_path; - } else { - local_path = ProjectSettings::get_singleton()->localize_path(p_path); - } + String local_path = _validate_local_path(p_path); if (p_cache_mode != ResourceFormatLoader::CACHE_MODE_IGNORE) { thread_load_mutex->lock(); @@ -612,12 +610,7 @@ RES ResourceLoader::load(const String &p_path, const String &p_type_hint, Resour } bool ResourceLoader::exists(const String &p_path, const String &p_type_hint) { - String local_path; - if (p_path.is_rel_path()) { - local_path = "res://" + p_path; - } else { - local_path = ProjectSettings::get_singleton()->localize_path(p_path); - } + String local_path = _validate_local_path(p_path); if (ResourceCache::has(local_path)) { return true; // If cached, it probably exists @@ -677,14 +670,7 @@ void ResourceLoader::remove_resource_format_loader(Ref<ResourceFormatLoader> p_f } int ResourceLoader::get_import_order(const String &p_path) { - String path = _path_remap(p_path); - - String local_path; - if (path.is_rel_path()) { - local_path = "res://" + path; - } else { - local_path = ProjectSettings::get_singleton()->localize_path(path); - } + String local_path = _path_remap(_validate_local_path(p_path)); for (int i = 0; i < loader_count; i++) { if (!loader[i]->recognize_path(local_path)) { @@ -702,14 +688,7 @@ int ResourceLoader::get_import_order(const String &p_path) { } String ResourceLoader::get_import_group_file(const String &p_path) { - String path = _path_remap(p_path); - - String local_path; - if (path.is_rel_path()) { - local_path = "res://" + path; - } else { - local_path = ProjectSettings::get_singleton()->localize_path(path); - } + String local_path = _path_remap(_validate_local_path(p_path)); for (int i = 0; i < loader_count; i++) { if (!loader[i]->recognize_path(local_path)) { @@ -727,14 +706,7 @@ String ResourceLoader::get_import_group_file(const String &p_path) { } bool ResourceLoader::is_import_valid(const String &p_path) { - String path = _path_remap(p_path); - - String local_path; - if (path.is_rel_path()) { - local_path = "res://" + path; - } else { - local_path = ProjectSettings::get_singleton()->localize_path(path); - } + String local_path = _path_remap(_validate_local_path(p_path)); for (int i = 0; i < loader_count; i++) { if (!loader[i]->recognize_path(local_path)) { @@ -752,14 +724,7 @@ bool ResourceLoader::is_import_valid(const String &p_path) { } bool ResourceLoader::is_imported(const String &p_path) { - String path = _path_remap(p_path); - - String local_path; - if (path.is_rel_path()) { - local_path = "res://" + path; - } else { - local_path = ProjectSettings::get_singleton()->localize_path(path); - } + String local_path = _path_remap(_validate_local_path(p_path)); for (int i = 0; i < loader_count; i++) { if (!loader[i]->recognize_path(local_path)) { @@ -777,14 +742,7 @@ bool ResourceLoader::is_imported(const String &p_path) { } void ResourceLoader::get_dependencies(const String &p_path, List<String> *p_dependencies, bool p_add_types) { - String path = _path_remap(p_path); - - String local_path; - if (path.is_rel_path()) { - local_path = "res://" + path; - } else { - local_path = ProjectSettings::get_singleton()->localize_path(path); - } + String local_path = _path_remap(_validate_local_path(p_path)); for (int i = 0; i < loader_count; i++) { if (!loader[i]->recognize_path(local_path)) { @@ -800,14 +758,7 @@ void ResourceLoader::get_dependencies(const String &p_path, List<String> *p_depe } Error ResourceLoader::rename_dependencies(const String &p_path, const Map<String, String> &p_map) { - String path = _path_remap(p_path); - - String local_path; - if (path.is_rel_path()) { - local_path = "res://" + path; - } else { - local_path = ProjectSettings::get_singleton()->localize_path(path); - } + String local_path = _path_remap(_validate_local_path(p_path)); for (int i = 0; i < loader_count; i++) { if (!loader[i]->recognize_path(local_path)) { @@ -825,12 +776,7 @@ Error ResourceLoader::rename_dependencies(const String &p_path, const Map<String } String ResourceLoader::get_resource_type(const String &p_path) { - String local_path; - if (p_path.is_rel_path()) { - local_path = "res://" + p_path; - } else { - local_path = ProjectSettings::get_singleton()->localize_path(p_path); - } + String local_path = _validate_local_path(p_path); for (int i = 0; i < loader_count; i++) { String result = loader[i]->get_resource_type(local_path); @@ -842,6 +788,19 @@ String ResourceLoader::get_resource_type(const String &p_path) { return ""; } +ResourceUID::ID ResourceLoader::get_resource_uid(const String &p_path) { + String local_path = _validate_local_path(p_path); + + for (int i = 0; i < loader_count; i++) { + ResourceUID::ID id = loader[i]->get_resource_uid(local_path); + if (id != ResourceUID::INVALID_ID) { + return id; + } + } + + return ResourceUID::INVALID_ID; +} + String ResourceLoader::_path_remap(const String &p_path, bool *r_translation_remapped) { String new_path = p_path; @@ -978,15 +937,15 @@ void ResourceLoader::load_translation_remaps() { Dictionary remaps = ProjectSettings::get_singleton()->get("internationalization/locale/translation_remaps"); List<Variant> keys; remaps.get_key_list(&keys); - for (List<Variant>::Element *E = keys.front(); E; E = E->next()) { - Array langs = remaps[E->get()]; + for (const Variant &E : keys) { + Array langs = remaps[E]; Vector<String> lang_remaps; lang_remaps.resize(langs.size()); for (int i = 0; i < langs.size(); i++) { lang_remaps.write[i] = langs[i]; } - translation_remaps[String(E->get())] = lang_remaps; + translation_remaps[String(E)] = lang_remaps; } } @@ -1071,8 +1030,7 @@ void ResourceLoader::add_custom_loaders() { List<StringName> global_classes; ScriptServer::get_global_class_list(&global_classes); - for (List<StringName>::Element *E = global_classes.front(); E; E = E->next()) { - StringName class_name = E->get(); + for (const StringName &class_name : global_classes) { StringName base_class = ScriptServer::get_global_class_native_base(class_name); if (base_class == custom_loader_base_class) { diff --git a/core/io/resource_loader.h b/core/io/resource_loader.h index c656b9a69c..e525e80a9d 100644 --- a/core/io/resource_loader.h +++ b/core/io/resource_loader.h @@ -40,9 +40,9 @@ class ResourceFormatLoader : public RefCounted { public: enum CacheMode { - CACHE_MODE_IGNORE, //resource and subresources do not use path cache, no path is set into resource. - CACHE_MODE_REUSE, //resource and subresources use patch cache, reuse existing loaded resources instead of loading from disk when available - CACHE_MODE_REPLACE, //resource and and subresource use path cache, but replace existing loaded resources when available with information from disk + CACHE_MODE_IGNORE, // Resource and subresources do not use path cache, no path is set into resource. + CACHE_MODE_REUSE, // Resource and subresources use patch cache, reuse existing loaded resources instead of loading from disk when available. + CACHE_MODE_REPLACE, // Resource and subresource use path cache, but replace existing loaded resources when available with information from disk. }; protected: @@ -56,6 +56,7 @@ public: virtual bool recognize_path(const String &p_path, const String &p_for_type = String()) const; virtual bool handles_type(const String &p_type) const; virtual String get_resource_type(const String &p_path) const; + virtual ResourceUID::ID get_resource_uid(const String &p_path) const; virtual void get_dependencies(const String &p_path, List<String> *p_dependencies, bool p_add_types = false); virtual Error rename_dependencies(const String &p_path, const Map<String, String> &p_map); virtual bool is_import_valid(const String &p_path) const { return true; } @@ -107,7 +108,7 @@ private: friend class ResourceFormatImporter; friend class ResourceInteractiveLoader; - //internal load function + // Internal load function. static RES _load(const String &p_path, const String &p_original_path, const String &p_type_hint, ResourceFormatLoader::CacheMode p_cache_mode, Error *r_error, bool p_use_sub_threads, float *r_progress); static ResourceLoadedCallback _loaded_callback; @@ -157,6 +158,7 @@ public: static void add_resource_format_loader(Ref<ResourceFormatLoader> p_format_loader, bool p_at_front = false); static void remove_resource_format_loader(Ref<ResourceFormatLoader> p_format_loader); static String get_resource_type(const String &p_path); + static ResourceUID::ID get_resource_uid(const String &p_path); static void get_dependencies(const String &p_path, List<String> *p_dependencies, bool p_add_types = false); static Error rename_dependencies(const String &p_path, const Map<String, String> &p_map); static bool is_import_valid(const String &p_path); diff --git a/core/io/resource_saver.cpp b/core/io/resource_saver.cpp index 80cb85fba3..564de5ee69 100644 --- a/core/io/resource_saver.cpp +++ b/core/io/resource_saver.cpp @@ -39,6 +39,7 @@ Ref<ResourceFormatSaver> ResourceSaver::saver[MAX_SAVERS]; int ResourceSaver::saver_count = 0; bool ResourceSaver::timestamp_on_save = false; ResourceSavedCallback ResourceSaver::save_callback = nullptr; +ResourceSaverGetResourceIDForPath ResourceSaver::save_get_id_for_path = nullptr; Error ResourceFormatSaver::save(const String &p_path, const RES &p_resource, uint32_t p_flags) { if (get_script_instance() && get_script_instance()->has_method("_save")) { @@ -94,8 +95,8 @@ Error ResourceSaver::save(const String &p_path, const RES &p_resource, uint32_t bool recognized = false; saver[i]->get_recognized_extensions(p_resource, &extensions); - for (List<String>::Element *E = extensions.front(); E; E = E->next()) { - if (E->get().nocasecmp_to(extension) == 0) { + for (const String &E : extensions) { + if (E.nocasecmp_to(extension) == 0) { recognized = true; } } @@ -236,8 +237,7 @@ void ResourceSaver::add_custom_savers() { List<StringName> global_classes; ScriptServer::get_global_class_list(&global_classes); - for (List<StringName>::Element *E = global_classes.front(); E; E = E->next()) { - StringName class_name = E->get(); + for (const StringName &class_name : global_classes) { StringName base_class = ScriptServer::get_global_class_native_base(class_name); if (base_class == custom_saver_base_class) { @@ -259,3 +259,14 @@ void ResourceSaver::remove_custom_savers() { remove_resource_format_saver(custom_savers[i]); } } + +ResourceUID::ID ResourceSaver::get_resource_id_for_path(const String &p_path, bool p_generate) { + if (save_get_id_for_path) { + return save_get_id_for_path(p_path, p_generate); + } + return ResourceUID::INVALID_ID; +} + +void ResourceSaver::set_get_resource_id_for_path(ResourceSaverGetResourceIDForPath p_callback) { + save_get_id_for_path = p_callback; +} diff --git a/core/io/resource_saver.h b/core/io/resource_saver.h index 07154aac4d..2fc8d32126 100644 --- a/core/io/resource_saver.h +++ b/core/io/resource_saver.h @@ -48,6 +48,7 @@ public: }; typedef void (*ResourceSavedCallback)(Ref<Resource> p_resource, const String &p_path); +typedef ResourceUID::ID (*ResourceSaverGetResourceIDForPath)(const String &p_path, bool p_generate); class ResourceSaver { enum { @@ -58,6 +59,7 @@ class ResourceSaver { static int saver_count; static bool timestamp_on_save; static ResourceSavedCallback save_callback; + static ResourceSaverGetResourceIDForPath save_get_id_for_path; static Ref<ResourceFormatSaver> _find_custom_resource_format_saver(String path); @@ -80,7 +82,10 @@ public: static void set_timestamp_on_save(bool p_timestamp) { timestamp_on_save = p_timestamp; } static bool get_timestamp_on_save() { return timestamp_on_save; } + static ResourceUID::ID get_resource_id_for_path(const String &p_path, bool p_generate = false); + static void set_save_callback(ResourceSavedCallback p_callback); + static void set_get_resource_id_for_path(ResourceSaverGetResourceIDForPath p_callback); static bool add_custom_resource_format_saver(String script_path); static void remove_custom_resource_format_saver(String script_path); diff --git a/core/io/resource_uid.cpp b/core/io/resource_uid.cpp new file mode 100644 index 0000000000..97d683f415 --- /dev/null +++ b/core/io/resource_uid.cpp @@ -0,0 +1,262 @@ +/*************************************************************************/ +/* resource_uid.cpp */ +/*************************************************************************/ +/* This file is part of: */ +/* GODOT ENGINE */ +/* https://godotengine.org */ +/*************************************************************************/ +/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2021 Godot Engine contributors (cf. AUTHORS.md). */ +/* */ +/* 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. */ +/*************************************************************************/ + +#include "resource_uid.h" +#include "core/crypto/crypto.h" +#include "core/io/dir_access.h" +#include "core/io/file_access.h" + +static constexpr uint32_t char_count = ('z' - 'a'); +static constexpr uint32_t base = char_count + ('9' - '0'); + +const char *ResourceUID::CACHE_FILE = "res://.godot/uid_cache.bin"; + +String ResourceUID::id_to_text(ID p_id) const { + if (p_id < 0) { + return "uid://<invalid>"; + } + String txt; + + while (p_id) { + uint32_t c = p_id % base; + if (c < char_count) { + txt = String::chr('a' + c) + txt; + } else { + txt = String::chr('0' + (c - char_count)) + txt; + } + p_id /= base; + } + + return "uid://" + txt; +} + +ResourceUID::ID ResourceUID::text_to_id(const String &p_text) const { + if (!p_text.begins_with("uid://") || p_text == "uid://<invalid>") { + return INVALID_ID; + } + + uint32_t l = p_text.length(); + uint64_t uid = 0; + for (uint32_t i = 6; i < l; i++) { + uid *= base; + uint32_t c = p_text[i]; + if (c >= 'a' && c <= 'z') { + uid += c - 'a'; + } else if (c >= '0' && c <= '9') { + uid += c - '0' + char_count; + } else { + return INVALID_ID; + } + } + return ID(uid & 0x7FFFFFFFFFFFFFFF); +} + +ResourceUID::ID ResourceUID::create_id() const { + mutex.lock(); + if (crypto.is_null()) { + crypto = Ref<Crypto>(Crypto::create()); + } + mutex.unlock(); + while (true) { + PackedByteArray bytes = crypto->generate_random_bytes(8); + ERR_FAIL_COND_V(bytes.size() != 8, INVALID_ID); + const uint64_t *ptr64 = (const uint64_t *)bytes.ptr(); + ID id = int64_t((*ptr64) & 0x7FFFFFFFFFFFFFFF); + mutex.lock(); + bool exists = unique_ids.has(id); + mutex.unlock(); + if (!exists) { + return id; + } + } +} + +bool ResourceUID::has_id(ID p_id) const { + MutexLock l(mutex); + return unique_ids.has(p_id); +} +void ResourceUID::add_id(ID p_id, const String &p_path) { + MutexLock l(mutex); + ERR_FAIL_COND(unique_ids.has(p_id)); + Cache c; + c.cs = p_path.utf8(); + unique_ids[p_id] = c; + changed = true; +} + +void ResourceUID::set_id(ID p_id, const String &p_path) { + MutexLock l(mutex); + ERR_FAIL_COND(!unique_ids.has(p_id)); + CharString cs = p_path.utf8(); + if (strcmp(cs.ptr(), unique_ids[p_id].cs.ptr()) != 0) { + unique_ids[p_id].cs = cs; + unique_ids[p_id].saved_to_cache = false; //changed + changed = true; + } +} + +String ResourceUID::get_id_path(ID p_id) const { + MutexLock l(mutex); + ERR_FAIL_COND_V(!unique_ids.has(p_id), String()); + const CharString &cs = unique_ids[p_id].cs; + String s(cs.ptr()); + return s; +} +void ResourceUID::remove_id(ID p_id) { + MutexLock l(mutex); + ERR_FAIL_COND(!unique_ids.has(p_id)); + unique_ids.erase(p_id); +} + +Error ResourceUID::save_to_cache() { + if (!FileAccess::exists(CACHE_FILE)) { + DirAccessRef d = DirAccess::create(DirAccess::ACCESS_RESOURCES); + d->make_dir_recursive(String(CACHE_FILE).get_base_dir()); //ensure base dir exists + } + + FileAccessRef f = FileAccess::open(CACHE_FILE, FileAccess::WRITE); + if (!f) { + return ERR_CANT_OPEN; + } + + MutexLock l(mutex); + f->store_32(unique_ids.size()); + + cache_entries = 0; + + for (OrderedHashMap<ID, Cache>::Element E = unique_ids.front(); E; E = E.next()) { + f->store_64(E.key()); + uint32_t s = E.get().cs.length(); + f->store_32(s); + f->store_buffer((const uint8_t *)E.get().cs.ptr(), s); + E.get().saved_to_cache = true; + cache_entries++; + } + + changed = false; + return OK; +} + +Error ResourceUID::load_from_cache() { + FileAccessRef f = FileAccess::open(CACHE_FILE, FileAccess::READ); + if (!f) { + return ERR_CANT_OPEN; + } + + MutexLock l(mutex); + unique_ids.clear(); + + uint32_t entry_count = f->get_32(); + for (uint32_t i = 0; i < entry_count; i++) { + int64_t id = f->get_64(); + int32_t len = f->get_32(); + Cache c; + c.cs.resize(len + 1); + ERR_FAIL_COND_V(c.cs.size() != len + 1, ERR_FILE_CORRUPT); // out of memory + c.cs[len] = 0; + int32_t rl = f->get_buffer((uint8_t *)c.cs.ptrw(), len); + ERR_FAIL_COND_V(rl != len, ERR_FILE_CORRUPT); + + c.saved_to_cache = true; + unique_ids[id] = c; + } + + cache_entries = entry_count; + changed = false; + return OK; +} + +Error ResourceUID::update_cache() { + if (!changed) { + return OK; + } + + if (cache_entries == 0) { + return save_to_cache(); + } + MutexLock l(mutex); + + FileAccess *f = nullptr; + for (OrderedHashMap<ID, Cache>::Element E = unique_ids.front(); E; E = E.next()) { + if (!E.get().saved_to_cache) { + if (f == nullptr) { + f = FileAccess::open(CACHE_FILE, FileAccess::READ_WRITE); //append + if (!f) { + return ERR_CANT_OPEN; + } + f->seek_end(); + } + f->store_64(E.key()); + uint32_t s = E.get().cs.length(); + f->store_32(s); + f->store_buffer((const uint8_t *)E.get().cs.ptr(), s); + E.get().saved_to_cache = true; + cache_entries++; + } + } + + if (f != nullptr) { + f->seek(0); + f->store_32(cache_entries); //update amount of entries + f->close(); + memdelete(f); + } + + changed = false; + + return OK; +} + +void ResourceUID::clear() { + cache_entries = 0; + unique_ids.clear(); + changed = false; +} +void ResourceUID::_bind_methods() { + ClassDB::bind_method(D_METHOD("id_to_text", "id"), &ResourceUID::id_to_text); + ClassDB::bind_method(D_METHOD("text_to_id", "text_id"), &ResourceUID::text_to_id); + + ClassDB::bind_method(D_METHOD("create_id"), &ResourceUID::create_id); + + ClassDB::bind_method(D_METHOD("has_id", "id"), &ResourceUID::has_id); + ClassDB::bind_method(D_METHOD("add_id", "id", "path"), &ResourceUID::add_id); + ClassDB::bind_method(D_METHOD("set_id", "id", "path"), &ResourceUID::set_id); + ClassDB::bind_method(D_METHOD("get_id_path", "id"), &ResourceUID::get_id_path); + ClassDB::bind_method(D_METHOD("remove_id", "id"), &ResourceUID::remove_id); + + BIND_CONSTANT(INVALID_ID) +} +ResourceUID *ResourceUID::singleton = nullptr; +ResourceUID::ResourceUID() { + ERR_FAIL_COND(singleton != nullptr); + singleton = this; +} +ResourceUID::~ResourceUID() { +} diff --git a/core/io/resource_uid.h b/core/io/resource_uid.h new file mode 100644 index 0000000000..b12138425a --- /dev/null +++ b/core/io/resource_uid.h @@ -0,0 +1,89 @@ +/*************************************************************************/ +/* resource_uid.h */ +/*************************************************************************/ +/* This file is part of: */ +/* GODOT ENGINE */ +/* https://godotengine.org */ +/*************************************************************************/ +/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2021 Godot Engine contributors (cf. AUTHORS.md). */ +/* */ +/* 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 RESOURCE_UUID_H +#define RESOURCE_UUID_H + +#include "core/object/ref_counted.h" +#include "core/string/string_name.h" +#include "core/templates/ordered_hash_map.h" + +class Crypto; +class ResourceUID : public Object { + GDCLASS(ResourceUID, Object) +public: + typedef int64_t ID; + enum { + INVALID_ID = -1 + }; + + static const char *CACHE_FILE; + +private: + mutable Ref<Crypto> crypto; + Mutex mutex; + struct Cache { + CharString cs; + bool saved_to_cache = false; + }; + + OrderedHashMap<ID, Cache> unique_ids; //unique IDs and utf8 paths (less memory used) + static ResourceUID *singleton; + + uint32_t cache_entries = 0; + bool changed = false; + +protected: + static void _bind_methods(); + +public: + String id_to_text(ID p_id) const; + ID text_to_id(const String &p_text) const; + + ID create_id() const; + bool has_id(ID p_id) const; + void add_id(ID p_id, const String &p_path); + void set_id(ID p_id, const String &p_path); + String get_id_path(ID p_id) const; + void remove_id(ID p_id); + + Error load_from_cache(); + Error save_to_cache(); + Error update_cache(); + + void clear(); + + static ResourceUID *get_singleton() { return singleton; } + + ResourceUID(); + ~ResourceUID(); +}; + +#endif // RESOURCEUUID_H diff --git a/core/math/a_star.cpp b/core/math/a_star.cpp index 88e11a630c..322eb7ac61 100644 --- a/core/math/a_star.cpp +++ b/core/math/a_star.cpp @@ -35,18 +35,12 @@ #include "scene/scene_string_names.h" int AStar::get_available_point_id() const { - if (points.is_empty()) { - return 1; - } - - // calculate our new next available point id if bigger than before or next id already contained in set of points. if (points.has(last_free_id)) { - int cur_new_id = last_free_id; + int cur_new_id = last_free_id + 1; while (points.has(cur_new_id)) { cur_new_id++; } - int &non_const = const_cast<int &>(last_free_id); - non_const = cur_new_id; + const_cast<int &>(last_free_id) = cur_new_id; } return last_free_id; diff --git a/core/math/delaunay_3d.h b/core/math/delaunay_3d.h index 6f7209556e..81adf4d19a 100644 --- a/core/math/delaunay_3d.h +++ b/core/math/delaunay_3d.h @@ -375,8 +375,7 @@ public: OutputSimplex *ret_simplicesw = ret_simplices.ptrw(); uint32_t simplices_written = 0; - for (List<Simplex *>::Element *E = simplex_list.front(); E; E = E->next()) { - Simplex *simplex = E->get(); + for (Simplex *simplex : simplex_list) { bool invalid = false; for (int j = 0; j < 4; j++) { if (simplex->points[j] >= point_count) { diff --git a/core/math/dynamic_bvh.cpp b/core/math/dynamic_bvh.cpp index 8e596f0f9d..f3fb473981 100644 --- a/core/math/dynamic_bvh.cpp +++ b/core/math/dynamic_bvh.cpp @@ -181,7 +181,7 @@ DynamicBVH::Volume DynamicBVH::_bounds(Node **leaves, int p_count) { void DynamicBVH::_bottom_up(Node **leaves, int p_count) { while (p_count > 1) { - real_t minsize = Math_INF; + real_t minsize = INFINITY; int minidx[2] = { -1, -1 }; for (int i = 0; i < p_count; ++i) { for (int j = i + 1; j < p_count; ++j) { diff --git a/core/math/expression.cpp b/core/math/expression.cpp index 0146c345f0..05f2c8dac9 100644 --- a/core/math/expression.cpp +++ b/core/math/expression.cpp @@ -397,10 +397,10 @@ Error Expression::_get_token(Token &r_token) { r_token.value = Math_TAU; } else if (id == "INF") { r_token.type = TK_CONSTANT; - r_token.value = Math_INF; + r_token.value = INFINITY; } else if (id == "NAN") { r_token.type = TK_CONSTANT; - r_token.value = Math_NAN; + r_token.value = NAN; } else if (id == "not") { r_token.type = TK_OP_NOT; } else if (id == "or") { diff --git a/core/math/face3.h b/core/math/face3.h index 5091b338ef..9e9026e54e 100644 --- a/core/math/face3.h +++ b/core/math/face3.h @@ -50,8 +50,8 @@ public: /** * * @param p_plane plane used to split the face - * @param p_res array of at least 3 faces, amount used in functio return - * @param p_is_point_over array of at least 3 booleans, determining which face is over the plane, amount used in functio return + * @param p_res array of at least 3 faces, amount used in function return + * @param p_is_point_over array of at least 3 booleans, determining which face is over the plane, amount used in function return * @param _epsilon constant used for numerical error rounding, to add "thickness" to the plane (so coplanar points can happen) * @return amount of faces generated by the split, either 0 (means no split possible), 2 or 3 */ diff --git a/core/math/geometry_3d.h b/core/math/geometry_3d.h index 4ef9b4dbe6..766689e222 100644 --- a/core/math/geometry_3d.h +++ b/core/math/geometry_3d.h @@ -40,7 +40,7 @@ class Geometry3D { public: static void get_closest_points_between_segments(const Vector3 &p1, const Vector3 &p2, const Vector3 &q1, const Vector3 &q2, Vector3 &c1, Vector3 &c2) { -// Do the function 'd' as defined by pb. I think is is dot product of some sort. +// Do the function 'd' as defined by pb. I think it's a dot product of some sort. #define d_of(m, n, o, p) ((m.x - n.x) * (o.x - p.x) + (m.y - n.y) * (o.y - p.y) + (m.z - n.z) * (o.z - p.z)) // Calculate the parametric position on the 2 curves, mua and mub. diff --git a/core/math/math_defs.h b/core/math/math_defs.h index df2223fb78..7692e1be47 100644 --- a/core/math/math_defs.h +++ b/core/math/math_defs.h @@ -43,8 +43,6 @@ #define Math_TAU 6.2831853071795864769252867666 #define Math_PI 3.1415926535897932384626433833 #define Math_E 2.7182818284590452353602874714 -#define Math_INF INFINITY -#define Math_NAN NAN #ifdef DEBUG_ENABLED #define MATH_CHECKS diff --git a/core/math/math_funcs.cpp b/core/math/math_funcs.cpp index e92bb9f4aa..bbed257f60 100644 --- a/core/math/math_funcs.cpp +++ b/core/math/math_funcs.cpp @@ -88,16 +88,6 @@ int Math::range_step_decimals(double p_step) { return step_decimals(p_step); } -double Math::dectime(double p_value, double p_amount, double p_step) { - double sgn = p_value < 0 ? -1.0 : 1.0; - double val = Math::abs(p_value); - val -= p_amount * p_step; - if (val < 0.0) { - val = 0.0; - } - return val * sgn; -} - double Math::ease(double p_x, double p_c) { if (p_x < 0) { p_x = 0; diff --git a/core/math/math_funcs.h b/core/math/math_funcs.h index 3389407e72..4e4f566517 100644 --- a/core/math/math_funcs.h +++ b/core/math/math_funcs.h @@ -296,7 +296,6 @@ public: static int step_decimals(double p_step); static int range_step_decimals(double p_step); static double snapped(double p_value, double p_step); - static double dectime(double p_value, double p_amount, double p_step); static uint32_t larger_prime(uint32_t p_val); diff --git a/core/math/quick_hull.cpp b/core/math/quick_hull.cpp index 0d77bfe933..0960fe19a6 100644 --- a/core/math/quick_hull.cpp +++ b/core/math/quick_hull.cpp @@ -192,9 +192,9 @@ Error QuickHull::build(const Vector<Vector3> &p_points, Geometry3D::MeshData &r_ continue; } - for (List<Face>::Element *E = faces.front(); E; E = E->next()) { - if (E->get().plane.distance_to(p_points[i]) > over_tolerance) { - E->get().points_over.push_back(i); + for (Face &E : faces) { + if (E.plane.distance_to(p_points[i]) > over_tolerance) { + E.points_over.push_back(i); break; } } @@ -292,8 +292,8 @@ Error QuickHull::build(const Vector<Vector3> &p_points, Geometry3D::MeshData &r_ //distribute points into new faces - for (List<List<Face>::Element *>::Element *F = lit_faces.front(); F; F = F->next()) { - Face &lf = F->get()->get(); + for (List<Face>::Element *&F : lit_faces) { + Face &lf = F->get(); for (int i = 0; i < lf.points_over.size(); i++) { if (lf.points_over[i] == f.points_over[next]) { //do not add current one @@ -301,8 +301,8 @@ Error QuickHull::build(const Vector<Vector3> &p_points, Geometry3D::MeshData &r_ } Vector3 p = p_points[lf.points_over[i]]; - for (List<List<Face>::Element *>::Element *E = new_faces.front(); E; E = E->next()) { - Face &f2 = E->get()->get(); + for (List<Face>::Element *&E : new_faces) { + Face &f2 = E->get(); if (f2.plane.distance_to(p) > over_tolerance) { f2.points_over.push_back(lf.points_over[i]); break; @@ -320,10 +320,10 @@ Error QuickHull::build(const Vector<Vector3> &p_points, Geometry3D::MeshData &r_ //put faces that contain no points on the front - for (List<List<Face>::Element *>::Element *E = new_faces.front(); E; E = E->next()) { - Face &f2 = E->get()->get(); + for (List<Face>::Element *&E : new_faces) { + Face &f2 = E->get(); if (f2.points_over.size() == 0) { - faces.move_to_front(E->get()); + faces.move_to_front(E); } } @@ -336,19 +336,19 @@ Error QuickHull::build(const Vector<Vector3> &p_points, Geometry3D::MeshData &r_ Map<Edge, RetFaceConnect> ret_edges; List<Geometry3D::MeshData::Face> ret_faces; - for (List<Face>::Element *E = faces.front(); E; E = E->next()) { + for (const Face &E : faces) { Geometry3D::MeshData::Face f; - f.plane = E->get().plane; + f.plane = E.plane; for (int i = 0; i < 3; i++) { - f.indices.push_back(E->get().vertices[i]); + f.indices.push_back(E.vertices[i]); } List<Geometry3D::MeshData::Face>::Element *F = ret_faces.push_back(f); for (int i = 0; i < 3; i++) { - uint32_t a = E->get().vertices[i]; - uint32_t b = E->get().vertices[(i + 1) % 3]; + uint32_t a = E.vertices[i]; + uint32_t b = E.vertices[(i + 1) % 3]; Edge e(a, b); Map<Edge, RetFaceConnect>::Element *G = ret_edges.find(e); @@ -439,8 +439,8 @@ Error QuickHull::build(const Vector<Vector3> &p_points, Geometry3D::MeshData &r_ r_mesh.faces.resize(ret_faces.size()); int idx = 0; - for (List<Geometry3D::MeshData::Face>::Element *E = ret_faces.front(); E; E = E->next()) { - r_mesh.faces.write[idx++] = E->get(); + for (const Geometry3D::MeshData::Face &E : ret_faces) { + r_mesh.faces.write[idx++] = E; } r_mesh.edges.resize(ret_edges.size()); idx = 0; diff --git a/core/math/triangle_mesh.cpp b/core/math/triangle_mesh.cpp index 903d5951a8..bf06c848c5 100644 --- a/core/math/triangle_mesh.cpp +++ b/core/math/triangle_mesh.cpp @@ -32,9 +32,9 @@ #include "core/templates/sort_array.h" -int TriangleMesh::_create_bvh(BVH *p_bvh, BVH **p_bb, int p_from, int p_size, int p_depth, int &max_depth, int &max_alloc) { - if (p_depth > max_depth) { - max_depth = p_depth; +int TriangleMesh::_create_bvh(BVH *p_bvh, BVH **p_bb, int p_from, int p_size, int p_depth, int &r_max_depth, int &r_max_alloc) { + if (p_depth > r_max_depth) { + r_max_depth = p_depth; } if (p_size == 1) { @@ -70,10 +70,10 @@ int TriangleMesh::_create_bvh(BVH *p_bvh, BVH **p_bb, int p_from, int p_size, in } break; } - int left = _create_bvh(p_bvh, p_bb, p_from, p_size / 2, p_depth + 1, max_depth, max_alloc); - int right = _create_bvh(p_bvh, p_bb, p_from + p_size / 2, p_size - p_size / 2, p_depth + 1, max_depth, max_alloc); + int left = _create_bvh(p_bvh, p_bb, p_from, p_size / 2, p_depth + 1, r_max_depth, r_max_alloc); + int right = _create_bvh(p_bvh, p_bb, p_from + p_size / 2, p_size - p_size / 2, p_depth + 1, r_max_depth, r_max_alloc); - int index = max_alloc++; + int index = r_max_alloc++; BVH *_new = &p_bvh[index]; _new->aabb = aabb; _new->center = aabb.position + aabb.size * 0.5; diff --git a/core/math/vector2.h b/core/math/vector2.h index 78deb473b4..4d9f3126e9 100644 --- a/core/math/vector2.h +++ b/core/math/vector2.h @@ -300,6 +300,14 @@ struct Vector2i { return p_idx ? y : x; } + _FORCE_INLINE_ int min_axis() const { + return x < y ? 0 : 1; + } + + _FORCE_INLINE_ int max_axis() const { + return x < y ? 1 : 0; + } + Vector2i min(const Vector2i &p_vector2i) const { return Vector2(MIN(x, p_vector2i.x), MIN(y, p_vector2i.y)); } diff --git a/core/object/class_db.cpp b/core/object/class_db.cpp index a10405dfae..c6ba39be94 100644 --- a/core/object/class_db.cpp +++ b/core/object/class_db.cpp @@ -359,9 +359,9 @@ uint64_t ClassDB::get_api_hash(APIType p_api) { //must be alphabetically sorted for hash to compute names.sort_custom<StringName::AlphCompare>(); - for (List<StringName>::Element *E = names.front(); E; E = E->next()) { - ClassInfo *t = classes.getptr(E->get()); - ERR_FAIL_COND_V_MSG(!t, 0, "Cannot get class '" + String(E->get()) + "'."); + for (const StringName &E : names) { + ClassInfo *t = classes.getptr(E); + ERR_FAIL_COND_V_MSG(!t, 0, "Cannot get class '" + String(E) + "'."); if (t->api != p_api || !t->exposed) { continue; } @@ -388,8 +388,8 @@ uint64_t ClassDB::get_api_hash(APIType p_api) { snames.sort_custom<StringName::AlphCompare>(); - for (List<StringName>::Element *F = snames.front(); F; F = F->next()) { - MethodBind *mb = t->method_map[F->get()]; + for (const StringName &F : snames) { + MethodBind *mb = t->method_map[F]; hash = hash_djb2_one_64(mb->get_name().hash(), hash); hash = hash_djb2_one_64(mb->get_argument_count(), hash); hash = hash_djb2_one_64(mb->get_argument_type(-1), hash); //return @@ -426,9 +426,9 @@ uint64_t ClassDB::get_api_hash(APIType p_api) { snames.sort_custom<StringName::AlphCompare>(); - for (List<StringName>::Element *F = snames.front(); F; F = F->next()) { - hash = hash_djb2_one_64(F->get().hash(), hash); - hash = hash_djb2_one_64(t->constant_map[F->get()], hash); + for (const StringName &F : snames) { + hash = hash_djb2_one_64(F.hash(), hash); + hash = hash_djb2_one_64(t->constant_map[F], hash); } } @@ -444,9 +444,9 @@ uint64_t ClassDB::get_api_hash(APIType p_api) { snames.sort_custom<StringName::AlphCompare>(); - for (List<StringName>::Element *F = snames.front(); F; F = F->next()) { - MethodInfo &mi = t->signal_map[F->get()]; - hash = hash_djb2_one_64(F->get().hash(), hash); + for (const StringName &F : snames) { + MethodInfo &mi = t->signal_map[F]; + hash = hash_djb2_one_64(F.hash(), hash); for (int i = 0; i < mi.arguments.size(); i++) { hash = hash_djb2_one_64(mi.arguments[i].type, hash); } @@ -465,23 +465,23 @@ uint64_t ClassDB::get_api_hash(APIType p_api) { snames.sort_custom<StringName::AlphCompare>(); - for (List<StringName>::Element *F = snames.front(); F; F = F->next()) { - PropertySetGet *psg = t->property_setget.getptr(F->get()); + for (const StringName &F : snames) { + PropertySetGet *psg = t->property_setget.getptr(F); ERR_FAIL_COND_V(!psg, 0); - hash = hash_djb2_one_64(F->get().hash(), hash); + hash = hash_djb2_one_64(F.hash(), hash); hash = hash_djb2_one_64(psg->setter.hash(), hash); hash = hash_djb2_one_64(psg->getter.hash(), hash); } } //property list - for (List<PropertyInfo>::Element *F = t->property_list.front(); F; F = F->next()) { - hash = hash_djb2_one_64(F->get().name.hash(), hash); - hash = hash_djb2_one_64(F->get().type, hash); - hash = hash_djb2_one_64(F->get().hint, hash); - hash = hash_djb2_one_64(F->get().hint_string.hash(), hash); - hash = hash_djb2_one_64(F->get().usage, hash); + for (const PropertyInfo &F : t->property_list) { + hash = hash_djb2_one_64(F.name.hash(), hash); + hash = hash_djb2_one_64(F.type, hash); + hash = hash_djb2_one_64(F.hint, hash); + hash = hash_djb2_one_64(F.hint_string.hash(), hash); + hash = hash_djb2_one_64(F.usage, hash); } } @@ -602,7 +602,7 @@ static MethodInfo info_from_bind(MethodBind *p_method) { } #endif -void ClassDB::get_method_list(StringName p_class, List<MethodInfo> *p_methods, bool p_no_inheritance, bool p_exclude_from_properties) { +void ClassDB::get_method_list(const StringName &p_class, List<MethodInfo> *p_methods, bool p_no_inheritance, bool p_exclude_from_properties) { OBJTYPE_RLOCK; ClassInfo *type = classes.getptr(p_class); @@ -619,16 +619,16 @@ void ClassDB::get_method_list(StringName p_class, List<MethodInfo> *p_methods, b #ifdef DEBUG_METHODS_ENABLED - for (List<MethodInfo>::Element *E = type->virtual_methods.front(); E; E = E->next()) { - p_methods->push_back(E->get()); + for (const MethodInfo &E : type->virtual_methods) { + p_methods->push_back(E); } - for (List<StringName>::Element *E = type->method_order.front(); E; E = E->next()) { - if (p_exclude_from_properties && type->methods_in_properties.has(E->get())) { + for (const StringName &E : type->method_order) { + if (p_exclude_from_properties && type->methods_in_properties.has(E)) { continue; } - MethodBind *method = type->method_map.get(E->get()); + MethodBind *method = type->method_map.get(E); MethodInfo minfo = info_from_bind(method); p_methods->push_back(minfo); @@ -655,7 +655,7 @@ void ClassDB::get_method_list(StringName p_class, List<MethodInfo> *p_methods, b } } -bool ClassDB::get_method_info(StringName p_class, StringName p_method, MethodInfo *r_info, bool p_no_inheritance, bool p_exclude_from_properties) { +bool ClassDB::get_method_info(const StringName &p_class, const StringName &p_method, MethodInfo *r_info, bool p_no_inheritance, bool p_exclude_from_properties) { OBJTYPE_RLOCK; ClassInfo *type = classes.getptr(p_class); @@ -706,7 +706,7 @@ bool ClassDB::get_method_info(StringName p_class, StringName p_method, MethodInf return false; } -MethodBind *ClassDB::get_method(StringName p_class, StringName p_name) { +MethodBind *ClassDB::get_method(const StringName &p_class, const StringName &p_name) { OBJTYPE_RLOCK; ClassInfo *type = classes.getptr(p_class); @@ -763,8 +763,8 @@ void ClassDB::get_integer_constant_list(const StringName &p_class, List<String> while (type) { #ifdef DEBUG_METHODS_ENABLED - for (List<StringName>::Element *E = type->constant_order.front(); E; E = E->next()) { - p_constants->push_back(E->get()); + for (const StringName &E : type->constant_order) { + p_constants->push_back(E); } #else const StringName *K = nullptr; @@ -910,7 +910,7 @@ bool ClassDB::has_enum(const StringName &p_class, const StringName &p_name, bool return false; } -void ClassDB::add_signal(StringName p_class, const MethodInfo &p_signal) { +void ClassDB::add_signal(const StringName &p_class, const MethodInfo &p_signal) { OBJTYPE_WLOCK; ClassInfo *type = classes.getptr(p_class); @@ -929,7 +929,7 @@ void ClassDB::add_signal(StringName p_class, const MethodInfo &p_signal) { type->signal_map[sname] = p_signal; } -void ClassDB::get_signal_list(StringName p_class, List<MethodInfo> *p_signals, bool p_no_inheritance) { +void ClassDB::get_signal_list(const StringName &p_class, List<MethodInfo> *p_signals, bool p_no_inheritance) { OBJTYPE_RLOCK; ClassInfo *type = classes.getptr(p_class); @@ -951,7 +951,7 @@ void ClassDB::get_signal_list(StringName p_class, List<MethodInfo> *p_signals, b } } -bool ClassDB::has_signal(StringName p_class, StringName p_signal, bool p_no_inheritance) { +bool ClassDB::has_signal(const StringName &p_class, const StringName &p_signal, bool p_no_inheritance) { OBJTYPE_RLOCK; ClassInfo *type = classes.getptr(p_class); ClassInfo *check = type; @@ -968,7 +968,7 @@ bool ClassDB::has_signal(StringName p_class, StringName p_signal, bool p_no_inhe return false; } -bool ClassDB::get_signal(StringName p_class, StringName p_signal, MethodInfo *r_signal) { +bool ClassDB::get_signal(const StringName &p_class, const StringName &p_signal, MethodInfo *r_signal) { OBJTYPE_RLOCK; ClassInfo *type = classes.getptr(p_class); ClassInfo *check = type; @@ -985,7 +985,7 @@ bool ClassDB::get_signal(StringName p_class, StringName p_signal, MethodInfo *r_ return false; } -void ClassDB::add_property_group(StringName p_class, const String &p_name, const String &p_prefix) { +void ClassDB::add_property_group(const StringName &p_class, const String &p_name, const String &p_prefix) { OBJTYPE_WLOCK; ClassInfo *type = classes.getptr(p_class); ERR_FAIL_COND(!type); @@ -993,7 +993,7 @@ void ClassDB::add_property_group(StringName p_class, const String &p_name, const type->property_list.push_back(PropertyInfo(Variant::NIL, p_name, PROPERTY_HINT_NONE, p_prefix, PROPERTY_USAGE_GROUP)); } -void ClassDB::add_property_subgroup(StringName p_class, const String &p_name, const String &p_prefix) { +void ClassDB::add_property_subgroup(const StringName &p_class, const String &p_name, const String &p_prefix) { OBJTYPE_WLOCK; ClassInfo *type = classes.getptr(p_class); ERR_FAIL_COND(!type); @@ -1002,7 +1002,7 @@ void ClassDB::add_property_subgroup(StringName p_class, const String &p_name, co } // NOTE: For implementation simplicity reasons, this method doesn't allow setters to have optional arguments at the end. -void ClassDB::add_property(StringName p_class, const PropertyInfo &p_pinfo, const StringName &p_setter, const StringName &p_getter, int p_index) { +void ClassDB::add_property(const StringName &p_class, const PropertyInfo &p_pinfo, const StringName &p_setter, const StringName &p_getter, int p_index) { lock.read_lock(); ClassInfo *type = classes.getptr(p_class); lock.read_unlock(); @@ -1060,26 +1060,27 @@ void ClassDB::add_property(StringName p_class, const PropertyInfo &p_pinfo, cons type->property_setget[p_pinfo.name] = psg; } -void ClassDB::set_property_default_value(StringName p_class, const StringName &p_name, const Variant &p_default) { +void ClassDB::set_property_default_value(const StringName &p_class, const StringName &p_name, const Variant &p_default) { if (!default_values.has(p_class)) { default_values[p_class] = HashMap<StringName, Variant>(); } default_values[p_class][p_name] = p_default; } -void ClassDB::get_property_list(StringName p_class, List<PropertyInfo> *p_list, bool p_no_inheritance, const Object *p_validator) { +void ClassDB::get_property_list(const StringName &p_class, List<PropertyInfo> *p_list, bool p_no_inheritance, const Object *p_validator) { OBJTYPE_RLOCK; ClassInfo *type = classes.getptr(p_class); ClassInfo *check = type; while (check) { - for (List<PropertyInfo>::Element *E = check->property_list.front(); E; E = E->next()) { + for (const PropertyInfo &pi : check->property_list) { if (p_validator) { - PropertyInfo pi = E->get(); - p_validator->_validate_property(pi); - p_list->push_back(pi); + // Making a copy as we may modify it. + PropertyInfo pi_mut = pi; + p_validator->_validate_property(pi_mut); + p_list->push_back(pi_mut); } else { - p_list->push_back(E->get()); + p_list->push_back(pi); } } @@ -1090,7 +1091,7 @@ void ClassDB::get_property_list(StringName p_class, List<PropertyInfo> *p_list, } } -bool ClassDB::get_property_info(StringName p_class, StringName p_property, PropertyInfo *r_info, bool p_no_inheritance, const Object *p_validator) { +bool ClassDB::get_property_info(const StringName &p_class, const StringName &p_property, PropertyInfo *r_info, bool p_no_inheritance, const Object *p_validator) { OBJTYPE_RLOCK; ClassInfo *check = classes.getptr(p_class); @@ -1258,7 +1259,7 @@ Variant::Type ClassDB::get_property_type(const StringName &p_class, const String return Variant::NIL; } -StringName ClassDB::get_property_setter(StringName p_class, const StringName &p_property) { +StringName ClassDB::get_property_setter(const StringName &p_class, const StringName &p_property) { ClassInfo *type = classes.getptr(p_class); ClassInfo *check = type; while (check) { @@ -1273,7 +1274,7 @@ StringName ClassDB::get_property_setter(StringName p_class, const StringName &p_ return StringName(); } -StringName ClassDB::get_property_getter(StringName p_class, const StringName &p_property) { +StringName ClassDB::get_property_getter(const StringName &p_class, const StringName &p_property) { ClassInfo *type = classes.getptr(p_class); ClassInfo *check = type; while (check) { @@ -1305,7 +1306,7 @@ bool ClassDB::has_property(const StringName &p_class, const StringName &p_proper return false; } -void ClassDB::set_method_flags(StringName p_class, StringName p_method, int p_flags) { +void ClassDB::set_method_flags(const StringName &p_class, const StringName &p_method, int p_flags) { OBJTYPE_WLOCK; ClassInfo *type = classes.getptr(p_class); ClassInfo *check = type; @@ -1314,7 +1315,7 @@ void ClassDB::set_method_flags(StringName p_class, StringName p_method, int p_fl check->method_map[p_method]->set_hint_flags(p_flags); } -bool ClassDB::has_method(StringName p_class, StringName p_method, bool p_no_inheritance) { +bool ClassDB::has_method(const StringName &p_class, const StringName &p_method, bool p_no_inheritance) { ClassInfo *type = classes.getptr(p_class); ClassInfo *check = type; while (check) { @@ -1429,8 +1430,8 @@ void ClassDB::get_virtual_methods(const StringName &p_class, List<MethodInfo> *p ClassInfo *type = classes.getptr(p_class); ClassInfo *check = type; while (check) { - for (List<MethodInfo>::Element *E = check->virtual_methods.front(); E; E = E->next()) { - p_methods->push_back(E->get()); + for (const MethodInfo &E : check->virtual_methods) { + p_methods->push_back(E); } if (p_no_inheritance) { @@ -1442,14 +1443,14 @@ void ClassDB::get_virtual_methods(const StringName &p_class, List<MethodInfo> *p #endif } -void ClassDB::set_class_enabled(StringName p_class, bool p_enable) { +void ClassDB::set_class_enabled(const StringName &p_class, bool p_enable) { OBJTYPE_WLOCK; ERR_FAIL_COND_MSG(!classes.has(p_class), "Request for nonexistent class '" + p_class + "'."); classes[p_class].disabled = !p_enable; } -bool ClassDB::is_class_enabled(StringName p_class) { +bool ClassDB::is_class_enabled(const StringName &p_class) { OBJTYPE_RLOCK; ClassInfo *ti = classes.getptr(p_class); @@ -1463,7 +1464,7 @@ bool ClassDB::is_class_enabled(StringName p_class) { return !ti->disabled; } -bool ClassDB::is_class_exposed(StringName p_class) { +bool ClassDB::is_class_exposed(const StringName &p_class) { OBJTYPE_RLOCK; ClassInfo *ti = classes.getptr(p_class); @@ -1496,6 +1497,10 @@ void ClassDB::get_resource_base_extensions(List<String> *p_extensions) { } } +bool ClassDB::is_resource_extension(const StringName &p_extension) { + return resource_base_extensions.has(p_extension); +} + void ClassDB::get_extensions_for_type(const StringName &p_class, List<String> *p_extensions) { const StringName *K = nullptr; @@ -1530,11 +1535,11 @@ Variant ClassDB::class_get_default_property_value(const StringName &p_class, con if (c) { List<PropertyInfo> plist; c->get_property_list(&plist); - for (List<PropertyInfo>::Element *E = plist.front(); E; E = E->next()) { - if (E->get().usage & (PROPERTY_USAGE_STORAGE | PROPERTY_USAGE_EDITOR)) { - if (!default_values[p_class].has(E->get().name)) { - Variant v = c->get(E->get().name); - default_values[p_class][E->get().name] = v; + for (const PropertyInfo &E : plist) { + if (E.usage & (PROPERTY_USAGE_STORAGE | PROPERTY_USAGE_EDITOR)) { + if (!default_values[p_class].has(E.name)) { + Variant v = c->get(E.name); + default_values[p_class][E.name] = v; } } } diff --git a/core/object/class_db.h b/core/object/class_db.h index e0cba1b8b5..3a84e9ab38 100644 --- a/core/object/class_db.h +++ b/core/object/class_db.h @@ -311,7 +311,7 @@ public: } template <class M> - static MethodBind *bind_vararg_method(uint32_t p_flags, StringName p_name, M p_method, const MethodInfo &p_info = MethodInfo(), const Vector<Variant> &p_default_args = Vector<Variant>(), bool p_return_nil_is_variant = true) { + static MethodBind *bind_vararg_method(uint32_t p_flags, const StringName &p_name, M p_method, const MethodInfo &p_info = MethodInfo(), const Vector<Variant> &p_default_args = Vector<Variant>(), bool p_return_nil_is_variant = true) { GLOBAL_LOCK_FUNCTION; MethodBind *bind = create_vararg_method_bind(p_method, p_info, p_return_nil_is_variant); @@ -345,31 +345,31 @@ public: static void bind_method_custom(const StringName &p_class, MethodBind *p_method); - static void add_signal(StringName p_class, const MethodInfo &p_signal); - static bool has_signal(StringName p_class, StringName p_signal, bool p_no_inheritance = false); - static bool get_signal(StringName p_class, StringName p_signal, MethodInfo *r_signal); - static void get_signal_list(StringName p_class, List<MethodInfo> *p_signals, bool p_no_inheritance = false); - - static void add_property_group(StringName p_class, const String &p_name, const String &p_prefix = ""); - static void add_property_subgroup(StringName p_class, const String &p_name, const String &p_prefix = ""); - static void add_property(StringName p_class, const PropertyInfo &p_pinfo, const StringName &p_setter, const StringName &p_getter, int p_index = -1); - static void set_property_default_value(StringName p_class, const StringName &p_name, const Variant &p_default); - static void get_property_list(StringName p_class, List<PropertyInfo> *p_list, bool p_no_inheritance = false, const Object *p_validator = nullptr); - static bool get_property_info(StringName p_class, StringName p_property, PropertyInfo *r_info, bool p_no_inheritance = false, const Object *p_validator = nullptr); + static void add_signal(const StringName &p_class, const MethodInfo &p_signal); + static bool has_signal(const StringName &p_class, const StringName &p_signal, bool p_no_inheritance = false); + static bool get_signal(const StringName &p_class, const StringName &p_signal, MethodInfo *r_signal); + static void get_signal_list(const StringName &p_class, List<MethodInfo> *p_signals, bool p_no_inheritance = false); + + static void add_property_group(const StringName &p_class, const String &p_name, const String &p_prefix = ""); + static void add_property_subgroup(const StringName &p_class, const String &p_name, const String &p_prefix = ""); + static void add_property(const StringName &p_class, const PropertyInfo &p_pinfo, const StringName &p_setter, const StringName &p_getter, int p_index = -1); + static void set_property_default_value(const StringName &p_class, const StringName &p_name, const Variant &p_default); + static void get_property_list(const StringName &p_class, List<PropertyInfo> *p_list, bool p_no_inheritance = false, const Object *p_validator = nullptr); + static bool get_property_info(const StringName &p_class, const StringName &p_property, PropertyInfo *r_info, bool p_no_inheritance = false, const Object *p_validator = nullptr); static bool set_property(Object *p_object, const StringName &p_property, const Variant &p_value, bool *r_valid = nullptr); static bool get_property(Object *p_object, const StringName &p_property, Variant &r_value); static bool has_property(const StringName &p_class, const StringName &p_property, bool p_no_inheritance = false); static int get_property_index(const StringName &p_class, const StringName &p_property, bool *r_is_valid = nullptr); static Variant::Type get_property_type(const StringName &p_class, const StringName &p_property, bool *r_is_valid = nullptr); - static StringName get_property_setter(StringName p_class, const StringName &p_property); - static StringName get_property_getter(StringName p_class, const StringName &p_property); + static StringName get_property_setter(const StringName &p_class, const StringName &p_property); + static StringName get_property_getter(const StringName &p_class, const StringName &p_property); - static bool has_method(StringName p_class, StringName p_method, bool p_no_inheritance = false); - static void set_method_flags(StringName p_class, StringName p_method, int p_flags); + static bool has_method(const StringName &p_class, const StringName &p_method, bool p_no_inheritance = false); + static void set_method_flags(const StringName &p_class, const StringName &p_method, int p_flags); - static void get_method_list(StringName p_class, List<MethodInfo> *p_methods, bool p_no_inheritance = false, bool p_exclude_from_properties = false); - static bool get_method_info(StringName p_class, StringName p_method, MethodInfo *r_info, bool p_no_inheritance = false, bool p_exclude_from_properties = false); - static MethodBind *get_method(StringName p_class, StringName p_name); + static void get_method_list(const StringName &p_class, List<MethodInfo> *p_methods, bool p_no_inheritance = false, bool p_exclude_from_properties = false); + static bool get_method_info(const StringName &p_class, const StringName &p_method, MethodInfo *r_info, bool p_no_inheritance = false, bool p_exclude_from_properties = false); + static MethodBind *get_method(const StringName &p_class, const StringName &p_name); static void add_virtual_method(const StringName &p_class, const MethodInfo &p_method, bool p_virtual = true); static void get_virtual_methods(const StringName &p_class, List<MethodInfo> *p_methods, bool p_no_inheritance = false); @@ -388,14 +388,15 @@ public: static StringName get_category(const StringName &p_node); - static void set_class_enabled(StringName p_class, bool p_enable); - static bool is_class_enabled(StringName p_class); + static void set_class_enabled(const StringName &p_class, bool p_enable); + static bool is_class_enabled(const StringName &p_class); - static bool is_class_exposed(StringName p_class); + static bool is_class_exposed(const StringName &p_class); static void add_resource_base_extension(const StringName &p_extension, const StringName &p_class); static void get_resource_base_extensions(List<String> *p_extensions); static void get_extensions_for_type(const StringName &p_class, List<String> *p_extensions); + static bool is_resource_extension(const StringName &p_extension); static void add_compatibility_class(const StringName &p_class, const StringName &p_fallback); diff --git a/core/object/object.cpp b/core/object/object.cpp index 296d876701..d552d5e5e0 100644 --- a/core/object/object.cpp +++ b/core/object/object.cpp @@ -922,11 +922,11 @@ Variant Object::get_script() const { return script; } -bool Object::has_meta(const String &p_name) const { +bool Object::has_meta(const StringName &p_name) const { return metadata.has(p_name); } -void Object::set_meta(const String &p_name, const Variant &p_value) { +void Object::set_meta(const StringName &p_name, const Variant &p_value) { if (p_value.get_type() == Variant::NIL) { metadata.erase(p_name); return; @@ -935,12 +935,12 @@ void Object::set_meta(const String &p_name, const Variant &p_value) { metadata[p_name] = p_value; } -Variant Object::get_meta(const String &p_name) const { +Variant Object::get_meta(const StringName &p_name) const { ERR_FAIL_COND_V_MSG(!metadata.has(p_name), Variant(), "The object does not have any 'meta' values with the key '" + p_name + "'."); return metadata[p_name]; } -void Object::remove_meta(const String &p_name) { +void Object::remove_meta(const StringName &p_name) { metadata.erase(p_name); } @@ -964,23 +964,23 @@ Array Object::_get_method_list_bind() const { return ret; } -Vector<String> Object::_get_meta_list_bind() const { - Vector<String> _metaret; +Vector<StringName> Object::_get_meta_list_bind() const { + Vector<StringName> _metaret; List<Variant> keys; metadata.get_key_list(&keys); - for (List<Variant>::Element *E = keys.front(); E; E = E->next()) { - _metaret.push_back(E->get()); + for (const Variant &E : keys) { + _metaret.push_back(E); } return _metaret; } -void Object::get_meta_list(List<String> *p_list) const { +void Object::get_meta_list(List<StringName> *p_list) const { List<Variant> keys; metadata.get_key_list(&keys); - for (List<Variant>::Element *E = keys.front(); E; E = E->next()) { - p_list->push_back(E->get()); + for (const Variant &E : keys) { + p_list->push_back(E); } } @@ -1184,8 +1184,8 @@ Array Object::_get_signal_list() const { get_signal_list(&signal_list); Array ret; - for (List<MethodInfo>::Element *E = signal_list.front(); E; E = E->next()) { - ret.push_back(Dictionary(E->get())); + for (const MethodInfo &E : signal_list) { + ret.push_back(Dictionary(E)); } return ret; @@ -1197,8 +1197,7 @@ Array Object::_get_signal_connection_list(const String &p_signal) const { Array ret; - for (List<Connection>::Element *E = conns.front(); E; E = E->next()) { - Connection &c = E->get(); + for (const Connection &c : conns) { if (c.signal.get_name() == p_signal) { ret.push_back(c); } @@ -1297,8 +1296,8 @@ int Object::get_persistent_signal_connection_count() const { } void Object::get_signals_connected_to_this(List<Connection> *p_connections) const { - for (const List<Connection>::Element *E = connections.front(); E; E = E->next()) { - p_connections->push_back(E->get()); + for (const Connection &E : connections) { + p_connections->push_back(E); } } @@ -1500,9 +1499,9 @@ void Object::_clear_internal_resource_paths(const Variant &p_var) { List<Variant> keys; d.get_key_list(&keys); - for (List<Variant>::Element *E = keys.front(); E; E = E->next()) { - _clear_internal_resource_paths(E->get()); - _clear_internal_resource_paths(d[E->get()]); + for (const Variant &E : keys) { + _clear_internal_resource_paths(E); + _clear_internal_resource_paths(d[E]); } } break; default: { @@ -1531,8 +1530,8 @@ void Object::clear_internal_resource_paths() { get_property_list(&pinfo); - for (List<PropertyInfo>::Element *E = pinfo.front(); E; E = E->next()) { - _clear_internal_resource_paths(get(E->get().name)); + for (const PropertyInfo &E : pinfo) { + _clear_internal_resource_paths(get(E.name)); } } @@ -1666,12 +1665,12 @@ void Object::get_translatable_strings(List<String> *p_strings) const { List<PropertyInfo> plist; get_property_list(&plist); - for (List<PropertyInfo>::Element *E = plist.front(); E; E = E->next()) { - if (!(E->get().usage & PROPERTY_USAGE_INTERNATIONALIZED)) { + for (const PropertyInfo &E : plist) { + if (!(E.usage & PROPERTY_USAGE_INTERNATIONALIZED)) { continue; } - String text = get(E->get().name); + String text = get(E.name); if (text == "") { continue; @@ -1769,6 +1768,17 @@ uint32_t Object::get_edited_version() const { } #endif +void Object::set_instance_binding(void *p_token, void *p_binding, const GDNativeInstanceBindingCallbacks *p_callbacks) { + // This is only meant to be used on creation by the binder. + ERR_FAIL_COND(_instance_bindings != nullptr); + _instance_bindings = (InstanceBinding *)memalloc(sizeof(InstanceBinding)); + _instance_bindings[0].binding = p_binding; + _instance_bindings[0].free_callback = p_callbacks->free_callback; + _instance_bindings[0].reference_callback = p_callbacks->reference_callback; + _instance_bindings[0].token = p_token; + _instance_binding_count = 1; +} + void *Object::get_instance_binding(void *p_token, const GDNativeInstanceBindingCallbacks *p_callbacks) { void *binding = nullptr; _instance_binding_mutex.lock(); diff --git a/core/object/object.h b/core/object/object.h index 33d9b627f6..b7d0916a54 100644 --- a/core/object/object.h +++ b/core/object/object.h @@ -44,13 +44,13 @@ #include "core/variant/callable_bind.h" #include "core/variant/variant.h" -#define VARIANT_ARG_LIST const Variant &p_arg1 = Variant(), const Variant &p_arg2 = Variant(), const Variant &p_arg3 = Variant(), const Variant &p_arg4 = Variant(), const Variant &p_arg5 = Variant() -#define VARIANT_ARG_PASS p_arg1, p_arg2, p_arg3, p_arg4, p_arg5 -#define VARIANT_ARG_DECLARE const Variant &p_arg1, const Variant &p_arg2, const Variant &p_arg3, const Variant &p_arg4, const Variant &p_arg5 -#define VARIANT_ARG_MAX 5 -#define VARIANT_ARGPTRS const Variant *argptr[5] = { &p_arg1, &p_arg2, &p_arg3, &p_arg4, &p_arg5 }; -#define VARIANT_ARGPTRS_PASS *argptr[0], *argptr[1], *argptr[2], *argptr[3], *argptr[4] -#define VARIANT_ARGS_FROM_ARRAY(m_arr) m_arr[0], m_arr[1], m_arr[2], m_arr[3], m_arr[4] +#define VARIANT_ARG_LIST const Variant &p_arg1 = Variant(), const Variant &p_arg2 = Variant(), const Variant &p_arg3 = Variant(), const Variant &p_arg4 = Variant(), const Variant &p_arg5 = Variant(), const Variant &p_arg6 = Variant(), const Variant &p_arg7 = Variant(), const Variant &p_arg8 = Variant() +#define VARIANT_ARG_PASS p_arg1, p_arg2, p_arg3, p_arg4, p_arg5, p_arg6, p_arg7, p_arg8 +#define VARIANT_ARG_DECLARE const Variant &p_arg1, const Variant &p_arg2, const Variant &p_arg3, const Variant &p_arg4, const Variant &p_arg5, const Variant &p_arg6, const Variant &p_arg7, const Variant &p_arg8 +#define VARIANT_ARG_MAX 8 +#define VARIANT_ARGPTRS const Variant *argptr[8] = { &p_arg1, &p_arg2, &p_arg3, &p_arg4, &p_arg5, &p_arg6, &p_arg7, &p_arg8 }; +#define VARIANT_ARGPTRS_PASS *argptr[0], *argptr[1], *argptr[2], *argptr[3], *argptr[4], *argptr[5], *argptr[6]], *argptr[7] +#define VARIANT_ARGS_FROM_ARRAY(m_arr) m_arr[0], m_arr[1], m_arr[2], m_arr[3], m_arr[4], m_arr[5], m_arr[6], m_arr[7] /** @author Juan Linietsky <reduzio@gmail.com> @@ -615,7 +615,7 @@ protected: return &_class_name; } - Vector<String> _get_meta_list_bind() const; + Vector<StringName> _get_meta_list_bind() const; Array _get_property_list_bind() const; Array _get_method_list_bind() const; @@ -743,11 +743,11 @@ public: /* SCRIPT */ - bool has_meta(const String &p_name) const; - void set_meta(const String &p_name, const Variant &p_value); - void remove_meta(const String &p_name); - Variant get_meta(const String &p_name) const; - void get_meta_list(List<String> *p_list) const; + bool has_meta(const StringName &p_name) const; + void set_meta(const StringName &p_name, const Variant &p_value); + void remove_meta(const StringName &p_name); + Variant get_meta(const StringName &p_name) const; + void get_meta_list(List<StringName> *p_list) const; #ifdef TOOLS_ENABLED void set_edited(bool p_edited); @@ -804,8 +804,10 @@ public: #endif - //used by script languages to store binding data + // Used by script languages to store binding data. void *get_instance_binding(void *p_token, const GDNativeInstanceBindingCallbacks *p_callbacks); + // Used on creation by binding only. + void set_instance_binding(void *p_token, void *p_binding, const GDNativeInstanceBindingCallbacks *p_callbacks); void clear_internal_resource_paths(); diff --git a/core/object/script_language.cpp b/core/object/script_language.cpp index 626a7413e7..0fb8c7350c 100644 --- a/core/object/script_language.cpp +++ b/core/object/script_language.cpp @@ -63,8 +63,8 @@ Array Script::_get_script_property_list() { Array ret; List<PropertyInfo> list; get_script_property_list(&list); - for (List<PropertyInfo>::Element *E = list.front(); E; E = E->next()) { - ret.append(E->get().operator Dictionary()); + for (const PropertyInfo &E : list) { + ret.append(E.operator Dictionary()); } return ret; } @@ -73,8 +73,8 @@ Array Script::_get_script_method_list() { Array ret; List<MethodInfo> list; get_script_method_list(&list); - for (List<MethodInfo>::Element *E = list.front(); E; E = E->next()) { - ret.append(E->get().operator Dictionary()); + for (const MethodInfo &E : list) { + ret.append(E.operator Dictionary()); } return ret; } @@ -83,8 +83,8 @@ Array Script::_get_script_signal_list() { Array ret; List<MethodInfo> list; get_script_signal_list(&list); - for (List<MethodInfo>::Element *E = list.front(); E; E = E->next()) { - ret.append(E->get().operator Dictionary()); + for (const MethodInfo &E : list) { + ret.append(E.operator Dictionary()); } return ret; } @@ -257,8 +257,8 @@ void ScriptServer::get_global_class_list(List<StringName> *r_global_classes) { classes.push_back(*K); } classes.sort_custom<StringName::AlphCompare>(); - for (List<StringName>::Element *E = classes.front(); E; E = E->next()) { - r_global_classes->push_back(E->get()); + for (const StringName &E : classes) { + r_global_classes->push_back(E); } } @@ -266,12 +266,12 @@ void ScriptServer::save_global_classes() { List<StringName> gc; get_global_class_list(&gc); Array gcarr; - for (List<StringName>::Element *E = gc.front(); E; E = E->next()) { + for (const StringName &E : gc) { Dictionary d; - d["class"] = E->get(); - d["language"] = global_classes[E->get()].language; - d["path"] = global_classes[E->get()].path; - d["base"] = global_classes[E->get()].base; + d["class"] = E; + d["language"] = global_classes[E].language; + d["path"] = global_classes[E].path; + d["base"] = global_classes[E].base; gcarr.push_back(d); } @@ -297,10 +297,10 @@ void ScriptServer::save_global_classes() { void ScriptInstance::get_property_state(List<Pair<StringName, Variant>> &state) { List<PropertyInfo> pinfo; get_property_list(&pinfo); - for (List<PropertyInfo>::Element *E = pinfo.front(); E; E = E->next()) { - if (E->get().usage & PROPERTY_USAGE_STORAGE) { + for (const PropertyInfo &E : pinfo) { + if (E.usage & PROPERTY_USAGE_STORAGE) { Pair<StringName, Variant> p; - p.first = E->get().name; + p.first = E.name; if (get(p.first, p.second)) { state.push_back(p); } @@ -430,16 +430,16 @@ bool PlaceHolderScriptInstance::get(const StringName &p_name, Variant &r_ret) co void PlaceHolderScriptInstance::get_property_list(List<PropertyInfo> *p_properties) const { if (script->is_placeholder_fallback_enabled()) { - for (const List<PropertyInfo>::Element *E = properties.front(); E; E = E->next()) { - p_properties->push_back(E->get()); + for (const PropertyInfo &E : properties) { + p_properties->push_back(E); } } else { - for (const List<PropertyInfo>::Element *E = properties.front(); E; E = E->next()) { - PropertyInfo pinfo = E->get(); + for (const PropertyInfo &E : properties) { + PropertyInfo pinfo = E; if (!values.has(pinfo.name)) { pinfo.usage |= PROPERTY_USAGE_SCRIPT_DEFAULT_VALUE; } - p_properties->push_back(E->get()); + p_properties->push_back(E); } } } @@ -489,11 +489,11 @@ bool PlaceHolderScriptInstance::has_method(const StringName &p_method) const { void PlaceHolderScriptInstance::update(const List<PropertyInfo> &p_properties, const Map<StringName, Variant> &p_values) { Set<StringName> new_values; - for (const List<PropertyInfo>::Element *E = p_properties.front(); E; E = E->next()) { - StringName n = E->get().name; + for (const PropertyInfo &E : p_properties) { + StringName n = E.name; new_values.insert(n); - if (!values.has(n) || values[n].get_type() != E->get().type) { + if (!values.has(n) || values[n].get_type() != E.type) { if (p_values.has(n)) { values[n] = p_values[n]; } @@ -511,7 +511,7 @@ void PlaceHolderScriptInstance::update(const List<PropertyInfo> &p_properties, c Variant defval; if (script->get_property_default_value(E->key(), defval)) { //remove because it's the same as the default value - if (defval == E->get()) { + if (defval == E) { to_remove.push_back(E->key()); } } @@ -542,8 +542,8 @@ void PlaceHolderScriptInstance::property_set_fallback(const StringName &p_name, } bool found = false; - for (const List<PropertyInfo>::Element *F = properties.front(); F; F = F->next()) { - if (F->get().name == p_name) { + for (const PropertyInfo &F : properties) { + if (F.name == p_name) { found = true; break; } diff --git a/core/object/undo_redo.cpp b/core/object/undo_redo.cpp index 96c96c1efb..adf068eb2f 100644 --- a/core/object/undo_redo.cpp +++ b/core/object/undo_redo.cpp @@ -39,11 +39,15 @@ void UndoRedo::_discard_redo() { } for (int i = current_action + 1; i < actions.size(); i++) { - for (List<Operation>::Element *E = actions.write[i].do_ops.front(); E; E = E->next()) { - if (E->get().type == Operation::TYPE_REFERENCE) { - Object *obj = ObjectDB::get_instance(E->get().object); - if (obj) { - memdelete(obj); + for (Operation &E : actions.write[i].do_ops) { + if (E.type == Operation::TYPE_REFERENCE) { + if (E.ref.is_valid()) { + E.ref.unref(); + } else { + Object *obj = ObjectDB::get_instance(E.object); + if (obj) { + memdelete(obj); + } } } } @@ -65,7 +69,7 @@ bool UndoRedo::_redo(bool p_execute) { _process_operation_list(actions.write[current_action].do_ops.front()); } version++; - emit_signal("version_changed"); + emit_signal(SNAME("version_changed")); return true; } @@ -240,11 +244,15 @@ void UndoRedo::_pop_history_tail() { return; } - for (List<Operation>::Element *E = actions.write[0].undo_ops.front(); E; E = E->next()) { - if (E->get().type == Operation::TYPE_REFERENCE) { - Object *obj = ObjectDB::get_instance(E->get().object); - if (obj) { - memdelete(obj); + for (Operation &E : actions.write[0].undo_ops) { + if (E.type == Operation::TYPE_REFERENCE) { + if (E.ref.is_valid()) { + E.ref.unref(); + } else { + Object *obj = ObjectDB::get_instance(E.object); + if (obj) { + memdelete(obj); + } } } } @@ -352,7 +360,7 @@ bool UndoRedo::undo() { _process_operation_list(actions.write[current_action].undo_ops.front()); current_action--; version--; - emit_signal("version_changed"); + emit_signal(SNAME("version_changed")); return true; } @@ -385,7 +393,7 @@ void UndoRedo::clear_history(bool p_increase_version) { if (p_increase_version) { version++; - emit_signal("version_changed"); + emit_signal(SNAME("version_changed")); } } @@ -460,8 +468,8 @@ Variant UndoRedo::_add_do_method(const Variant **p_args, int p_argcount, Callabl v[i] = *p_args[i + 2]; } - static_assert(VARIANT_ARG_MAX == 5, "This code needs to be updated if VARIANT_ARG_MAX != 5"); - add_do_method(object, method, v[0], v[1], v[2], v[3], v[4]); + static_assert(VARIANT_ARG_MAX == 8, "This code needs to be updated if VARIANT_ARG_MAX != 8"); + add_do_method(object, method, v[0], v[1], v[2], v[3], v[4], v[5], v[6], v[7]); return Variant(); } @@ -497,8 +505,8 @@ Variant UndoRedo::_add_undo_method(const Variant **p_args, int p_argcount, Calla v[i] = *p_args[i + 2]; } - static_assert(VARIANT_ARG_MAX == 5, "This code needs to be updated if VARIANT_ARG_MAX != 5"); - add_undo_method(object, method, v[0], v[1], v[2], v[3], v[4]); + static_assert(VARIANT_ARG_MAX == 8, "This code needs to be updated if VARIANT_ARG_MAX != 8"); + add_undo_method(object, method, v[0], v[1], v[2], v[3], v[4], v[5], v[6], v[7]); return Variant(); } diff --git a/core/os/main_loop.cpp b/core/os/main_loop.cpp index 016d9d0a09..3c0e56f5a8 100644 --- a/core/os/main_loop.cpp +++ b/core/os/main_loop.cpp @@ -66,7 +66,7 @@ void MainLoop::initialize() { } } -bool MainLoop::physics_process(float p_time) { +bool MainLoop::physics_process(double p_time) { if (get_script_instance()) { return get_script_instance()->call("_physics_process", p_time); } @@ -74,7 +74,7 @@ bool MainLoop::physics_process(float p_time) { return false; } -bool MainLoop::process(float p_time) { +bool MainLoop::process(double p_time) { if (get_script_instance()) { return get_script_instance()->call("_process", p_time); } diff --git a/core/os/main_loop.h b/core/os/main_loop.h index 34e944709b..b42e9b18ff 100644 --- a/core/os/main_loop.h +++ b/core/os/main_loop.h @@ -60,8 +60,8 @@ public: }; virtual void initialize(); - virtual bool physics_process(float p_time); - virtual bool process(float p_time); + virtual bool physics_process(double p_time); + virtual bool process(double p_time); virtual void finalize(); void set_initialize_script(const Ref<Script> &p_initialize_script); diff --git a/core/os/os.cpp b/core/os/os.cpp index 535eee4797..f7af74da3e 100644 --- a/core/os/os.cpp +++ b/core/os/os.cpp @@ -110,6 +110,10 @@ void OS::printerr(const char *p_format, ...) { va_end(argp); } +void OS::alert(const String &p_alert, const String &p_title) { + fprintf(stderr, "%s: %s\n", p_title.utf8().get_data(), p_alert.utf8().get_data()); +} + void OS::set_low_processor_usage_mode(bool p_enabled) { low_processor_usage_mode = p_enabled; } diff --git a/core/os/os.h b/core/os/os.h index 301718a8b3..fcb195afe1 100644 --- a/core/os/os.h +++ b/core/os/os.h @@ -120,6 +120,8 @@ public: virtual void open_midi_inputs(); virtual void close_midi_inputs(); + virtual void alert(const String &p_alert, const String &p_title = "ALERT!"); + virtual Error open_dynamic_library(const String p_path, void *&p_library_handle, bool p_also_set_library_path = false) { return ERR_UNAVAILABLE; } virtual Error close_dynamic_library(void *p_library_handle) { return ERR_UNAVAILABLE; } virtual Error get_dynamic_library_symbol_handle(void *p_library_handle, const String p_name, void *&p_symbol_handle, bool p_optional = false) { return ERR_UNAVAILABLE; } diff --git a/core/os/pool_allocator.h b/core/os/pool_allocator.h index 15e50dac90..49f433ba97 100644 --- a/core/os/pool_allocator.h +++ b/core/os/pool_allocator.h @@ -37,7 +37,7 @@ @author Juan Linietsky <reduzio@gmail.com> * Generic Pool Allocator. * This is a generic memory pool allocator, with locking, compacting and alignment. (@TODO alignment) - * It used as a standard way to manage alloction in a specific region of memory, such as texture memory, + * It used as a standard way to manage allocation in a specific region of memory, such as texture memory, * audio sample memory, or just any kind of memory overall. * (@TODO) abstraction should be greater, because in many platforms, you need to manage a nonreachable memory. */ diff --git a/core/register_core_types.cpp b/core/register_core_types.cpp index eb37267546..3d1cb4a8e1 100644 --- a/core/register_core_types.cpp +++ b/core/register_core_types.cpp @@ -56,6 +56,7 @@ #include "core/io/pck_packer.h" #include "core/io/resource_format_binary.h" #include "core/io/resource_importer.h" +#include "core/io/resource_uid.h" #include "core/io/stream_peer_ssl.h" #include "core/io/tcp_server.h" #include "core/io/translation_loader_po.h" @@ -102,6 +103,8 @@ static NativeExtensionManager *native_extension_manager = nullptr; extern void register_global_constants(); extern void unregister_global_constants(); +static ResourceUID *resource_uid = nullptr; + void register_core_types() { //consistency check static_assert(sizeof(Callable) <= 16); @@ -225,6 +228,10 @@ void register_core_types() { GDREGISTER_VIRTUAL_CLASS(NativeExtensionManager); + GDREGISTER_VIRTUAL_CLASS(ResourceUID); + + resource_uid = memnew(ResourceUID); + native_extension_manager = memnew(NativeExtensionManager); ip = IP::create(); @@ -286,10 +293,11 @@ void register_core_singletons() { Engine::get_singleton()->add_singleton(Engine::Singleton("EngineDebugger", _EngineDebugger::get_singleton())); Engine::get_singleton()->add_singleton(Engine::Singleton("Time", Time::get_singleton())); Engine::get_singleton()->add_singleton(Engine::Singleton("NativeExtensionManager", NativeExtensionManager::get_singleton())); + Engine::get_singleton()->add_singleton(Engine::Singleton("ResourceUID", ResourceUID::get_singleton())); } void register_core_extensions() { - //harcoded for now + // Hardcoded for now. if (ProjectSettings::get_singleton()->has_setting("native_extensions/paths")) { Vector<String> paths = ProjectSettings::get_singleton()->get("native_extensions/paths"); for (int i = 0; i < paths.size(); i++) { @@ -304,6 +312,8 @@ void unregister_core_types() { native_extension_manager->deinitialize_extensions(NativeExtension::INITIALIZATION_LEVEL_CORE); memdelete(native_extension_manager); + + memdelete(resource_uid); memdelete(_resource_loader); memdelete(_resource_saver); memdelete(_os); diff --git a/core/string/node_path.cpp b/core/string/node_path.cpp index d3afa7b4dd..5fae13779e 100644 --- a/core/string/node_path.cpp +++ b/core/string/node_path.cpp @@ -240,19 +240,26 @@ NodePath NodePath::rel_path_to(const NodePath &p_np) const { common_parent--; Vector<StringName> relpath; + relpath.resize(src_dirs.size() + dst_dirs.size() + 1); - for (int i = src_dirs.size() - 1; i > common_parent; i--) { - relpath.push_back(".."); + StringName *relpath_ptr = relpath.ptrw(); + + int path_size = 0; + StringName back_str(".."); + for (int i = common_parent + 1; i < src_dirs.size(); i++) { + relpath_ptr[path_size++] = back_str; } for (int i = common_parent + 1; i < dst_dirs.size(); i++) { - relpath.push_back(dst_dirs[i]); + relpath_ptr[path_size++] = dst_dirs[i]; } - if (relpath.size() == 0) { - relpath.push_back("."); + if (path_size == 0) { + relpath_ptr[path_size++] = "."; } + relpath.resize(path_size); + return NodePath(relpath, p_np.get_subnames(), false); } diff --git a/core/string/optimized_translation.cpp b/core/string/optimized_translation.cpp index 268562d971..5863bd1c46 100644 --- a/core/string/optimized_translation.cpp +++ b/core/string/optimized_translation.cpp @@ -66,9 +66,9 @@ void OptimizedTranslation::generate(const Ref<Translation> &p_from) { int total_compression_size = 0; int total_string_size = 0; - for (List<StringName>::Element *E = keys.front(); E; E = E->next()) { + for (const StringName &E : keys) { //hash string - CharString cs = E->get().operator String().utf8(); + CharString cs = E.operator String().utf8(); uint32_t h = hash(0, cs.get_data()); Pair<int, CharString> p; p.first = idx; @@ -76,7 +76,7 @@ void OptimizedTranslation::generate(const Ref<Translation> &p_from) { buckets.write[h % size].push_back(p); //compress string - CharString src_s = p_from->get_message(E->get()).operator String().utf8(); + CharString src_s = p_from->get_message(E).operator String().utf8(); CompressedString ps; ps.orig_len = src_s.size(); ps.offset = total_compression_size; diff --git a/core/string/string_name.cpp b/core/string/string_name.cpp index 14b87072bb..9024f60dae 100644 --- a/core/string/string_name.cpp +++ b/core/string/string_name.cpp @@ -41,13 +41,17 @@ StaticCString StaticCString::create(const char *p_ptr) { StringName::_Data *StringName::_table[STRING_TABLE_LEN]; -StringName _scs_create(const char *p_chr) { - return (p_chr[0] ? StringName(StaticCString::create(p_chr)) : StringName()); +StringName _scs_create(const char *p_chr, bool p_static) { + return (p_chr[0] ? StringName(StaticCString::create(p_chr), p_static) : StringName()); } bool StringName::configured = false; Mutex StringName::mutex; +#ifdef DEBUG_ENABLED +bool StringName::debug_stringname = false; +#endif + void StringName::setup() { ERR_FAIL_COND(configured); for (int i = 0; i < STRING_TABLE_LEN; i++) { @@ -59,12 +63,29 @@ void StringName::setup() { void StringName::cleanup() { MutexLock lock(mutex); +#ifdef DEBUG_ENABLED + if (unlikely(debug_stringname)) { + Vector<_Data *> data; + for (int i = 0; i < STRING_TABLE_LEN; i++) { + _Data *d = _table[i]; + while (d) { + data.push_back(d); + d = d->next; + } + } + print_line("\nStringName Reference Ranking:\n"); + data.sort_custom<DebugSortReferences>(); + for (int i = 0; i < MIN(100, data.size()); i++) { + print_line(itos(i + 1) + ": " + data[i]->get_name() + " - " + itos(data[i]->debug_references)); + } + } +#endif int lost_strings = 0; for (int i = 0; i < STRING_TABLE_LEN; i++) { while (_table[i]) { _Data *d = _table[i]; lost_strings++; - if (OS::get_singleton()->is_stdout_verbose()) { + if (d->static_count.get() != d->refcount.get() && OS::get_singleton()->is_stdout_verbose()) { if (d->cname) { print_line("Orphan StringName: " + String(d->cname)); } else { @@ -79,6 +100,7 @@ void StringName::cleanup() { if (lost_strings) { print_verbose("StringName: " + itos(lost_strings) + " unclaimed string names at exit."); } + configured = false; } void StringName::unref() { @@ -87,6 +109,13 @@ void StringName::unref() { if (_data && _data->refcount.unref()) { MutexLock lock(mutex); + if (_data->static_count.get() > 0) { + if (_data->cname) { + ERR_PRINT("BUG: Unreferenced static string to 0: " + String(_data->cname)); + } else { + ERR_PRINT("BUG: Unreferenced static string to 0: " + String(_data->name)); + } + } if (_data->prev) { _data->prev->next = _data->next; } else { @@ -153,7 +182,7 @@ StringName::StringName(const StringName &p_name) { } } -StringName::StringName(const char *p_name) { +StringName::StringName(const char *p_name, bool p_static) { _data = nullptr; ERR_FAIL_COND(!configured); @@ -181,25 +210,42 @@ StringName::StringName(const char *p_name) { if (_data) { if (_data->refcount.ref()) { // exists - return; + if (p_static) { + _data->static_count.increment(); + } +#ifdef DEBUG_ENABLED + if (unlikely(debug_stringname)) { + _data->debug_references++; + } +#endif } + + return; } _data = memnew(_Data); _data->name = p_name; _data->refcount.init(); + _data->static_count.set(p_static ? 1 : 0); _data->hash = hash; _data->idx = idx; _data->cname = nullptr; _data->next = _table[idx]; _data->prev = nullptr; +#ifdef DEBUG_ENABLED + if (unlikely(debug_stringname)) { + // Keep in memory, force static. + _data->refcount.ref(); + _data->static_count.increment(); + } +#endif if (_table[idx]) { _table[idx]->prev = _data; } _table[idx] = _data; } -StringName::StringName(const StaticCString &p_static_string) { +StringName::StringName(const StaticCString &p_static_string, bool p_static) { _data = nullptr; ERR_FAIL_COND(!configured); @@ -225,6 +271,14 @@ StringName::StringName(const StaticCString &p_static_string) { if (_data) { if (_data->refcount.ref()) { // exists + if (p_static) { + _data->static_count.increment(); + } +#ifdef DEBUG_ENABLED + if (unlikely(debug_stringname)) { + _data->debug_references++; + } +#endif return; } } @@ -232,18 +286,26 @@ StringName::StringName(const StaticCString &p_static_string) { _data = memnew(_Data); _data->refcount.init(); + _data->static_count.set(p_static ? 1 : 0); _data->hash = hash; _data->idx = idx; _data->cname = p_static_string.ptr; _data->next = _table[idx]; _data->prev = nullptr; +#ifdef DEBUG_ENABLED + if (unlikely(debug_stringname)) { + // Keep in memory, force static. + _data->refcount.ref(); + _data->static_count.increment(); + } +#endif if (_table[idx]) { _table[idx]->prev = _data; } _table[idx] = _data; } -StringName::StringName(const String &p_name) { +StringName::StringName(const String &p_name, bool p_static) { _data = nullptr; ERR_FAIL_COND(!configured); @@ -269,6 +331,14 @@ StringName::StringName(const String &p_name) { if (_data) { if (_data->refcount.ref()) { // exists + if (p_static) { + _data->static_count.increment(); + } +#ifdef DEBUG_ENABLED + if (unlikely(debug_stringname)) { + _data->debug_references++; + } +#endif return; } } @@ -276,11 +346,20 @@ StringName::StringName(const String &p_name) { _data = memnew(_Data); _data->name = p_name; _data->refcount.init(); + _data->static_count.set(p_static ? 1 : 0); _data->hash = hash; _data->idx = idx; _data->cname = nullptr; _data->next = _table[idx]; _data->prev = nullptr; +#ifdef DEBUG_ENABLED + if (unlikely(debug_stringname)) { + // Keep in memory, force static. + _data->refcount.ref(); + _data->static_count.increment(); + } +#endif + if (_table[idx]) { _table[idx]->prev = _data; } @@ -311,6 +390,12 @@ StringName StringName::search(const char *p_name) { } if (_data && _data->refcount.ref()) { +#ifdef DEBUG_ENABLED + if (unlikely(debug_stringname)) { + _data->debug_references++; + } +#endif + return StringName(_data); } @@ -368,16 +453,17 @@ StringName StringName::search(const String &p_name) { } if (_data && _data->refcount.ref()) { +#ifdef DEBUG_ENABLED + if (unlikely(debug_stringname)) { + _data->debug_references++; + } +#endif return StringName(_data); } return StringName(); //does not exist } -StringName::~StringName() { - unref(); -} - bool operator==(const String &p_name, const StringName &p_string_name) { return p_name == p_string_name.operator String(); } diff --git a/core/string/string_name.h b/core/string/string_name.h index 44d0ea14fa..ce7988744b 100644 --- a/core/string/string_name.h +++ b/core/string/string_name.h @@ -44,16 +44,19 @@ struct StaticCString { class StringName { enum { - STRING_TABLE_BITS = 12, + STRING_TABLE_BITS = 16, STRING_TABLE_LEN = 1 << STRING_TABLE_BITS, STRING_TABLE_MASK = STRING_TABLE_LEN - 1 }; struct _Data { SafeRefCount refcount; + SafeNumeric<uint32_t> static_count; const char *cname = nullptr; String name; - +#ifdef DEBUG_ENABLED + uint32_t debug_references = 0; +#endif String get_name() const { return cname ? String(cname) : name; } int idx = 0; uint32_t hash = 0; @@ -79,6 +82,15 @@ class StringName { static void setup(); static void cleanup(); static bool configured; +#ifdef DEBUG_ENABLED + struct DebugSortReferences { + bool operator()(const _Data *p_left, const _Data *p_right) const { + return p_left->debug_references > p_right->debug_references; + } + }; + + static bool debug_stringname; +#endif StringName(_Data *p_data) { _data = p_data; } @@ -146,12 +158,20 @@ public: }; void operator=(const StringName &p_name); - StringName(const char *p_name); + StringName(const char *p_name, bool p_static = false); StringName(const StringName &p_name); - StringName(const String &p_name); - StringName(const StaticCString &p_static_string); + StringName(const String &p_name, bool p_static = false); + StringName(const StaticCString &p_static_string, bool p_static = false); StringName() {} - ~StringName(); + _FORCE_INLINE_ ~StringName() { + if (likely(configured) && _data) { //only free if configured + unref(); + } + } + +#ifdef DEBUG_ENABLED + static void set_debug_stringnames(bool p_enable) { debug_stringname = p_enable; } +#endif }; bool operator==(const String &p_name, const StringName &p_string_name); @@ -159,6 +179,8 @@ bool operator!=(const String &p_name, const StringName &p_string_name); bool operator==(const char *p_name, const StringName &p_string_name); bool operator!=(const char *p_name, const StringName &p_string_name); -StringName _scs_create(const char *p_chr); +StringName _scs_create(const char *p_chr, bool p_static = false); + +#define SNAME(m_arg) ([]() -> const StringName & { static StringName sname = _scs_create(m_arg, true); return sname; })() #endif // STRING_NAME_H diff --git a/core/string/translation.cpp b/core/string/translation.cpp index 153f0190fd..19d23fd375 100644 --- a/core/string/translation.cpp +++ b/core/string/translation.cpp @@ -84,6 +84,7 @@ static const char *locale_list[] = { "ast_ES", // Asturian (Spain) "ayc_PE", // Southern Aymara (Peru) "ay_PE", // Aymara (Peru) + "az", // Azerbaijani "az_AZ", // Azerbaijani (Azerbaijan) "be", // Belarusian "be_BY", // Belarusian (Belarus) @@ -240,6 +241,7 @@ static const char *locale_list[] = { "ka_GE", // Georgian (Georgia) "kk_KZ", // Kazakh (Kazakhstan) "kl_GL", // Kalaallisut (Greenland) + "km", // Central Khmer "km_KH", // Central Khmer (Cambodia) "kn_IN", // Kannada (India) "kok_IN", // Konkani (India) @@ -390,6 +392,7 @@ static const char *locale_list[] = { "tr_CY", // Turkish (Cyprus) "tr_TR", // Turkish (Turkey) "ts_ZA", // Tsonga (South Africa) + "tt", // Tatar "tt_RU", // Tatar (Russia) "tzm", // Central Atlas Tamazight "tzm_MA", // Central Atlas Tamazight (Marrocos) @@ -458,6 +461,7 @@ static const char *locale_names[] = { "Asturian (Spain)", "Southern Aymara (Peru)", "Aymara (Peru)", + "Azerbaijani", "Azerbaijani (Azerbaijan)", "Belarusian", "Belarusian (Belarus)", @@ -614,6 +618,7 @@ static const char *locale_names[] = { "Georgian (Georgia)", "Kazakh (Kazakhstan)", "Kalaallisut (Greenland)", + "Central Khmer", "Central Khmer (Cambodia)", "Kannada (India)", "Konkani (India)", @@ -764,6 +769,7 @@ static const char *locale_names[] = { "Turkish (Cyprus)", "Turkish (Turkey)", "Tsonga (South Africa)", + "Tatar", "Tatar (Russia)", "Central Atlas Tamazight", "Central Atlas Tamazight (Marrocos)", @@ -835,8 +841,8 @@ Vector<String> Translation::_get_message_list() const { void Translation::_set_messages(const Dictionary &p_messages) { List<Variant> keys; p_messages.get_key_list(&keys); - for (List<Variant>::Element *E = keys.front(); E; E = E->next()) { - translation_map[E->get()] = p_messages[E->get()]; + for (const Variant &E : keys) { + translation_map[E] = p_messages[E]; } } diff --git a/core/string/translation_po.cpp b/core/string/translation_po.cpp index f9b4e661e4..1da00aa54b 100644 --- a/core/string/translation_po.cpp +++ b/core/string/translation_po.cpp @@ -47,8 +47,7 @@ void TranslationPO::print_translation_map() { List<StringName> context_l; translation_map.get_key_list(&context_l); - for (List<StringName>::Element *E = context_l.front(); E; E = E->next()) { - StringName ctx = E->get(); + for (const StringName &ctx : context_l) { file->store_line(" ===== Context: " + String::utf8(String(ctx).utf8()) + " ===== "); const HashMap<StringName, Vector<StringName>> &inner_map = translation_map[ctx]; @@ -74,8 +73,7 @@ Dictionary TranslationPO::_get_messages() const { List<StringName> context_l; translation_map.get_key_list(&context_l); - for (List<StringName>::Element *E = context_l.front(); E; E = E->next()) { - StringName ctx = E->get(); + for (const StringName &ctx : context_l) { const HashMap<StringName, Vector<StringName>> &id_str_map = translation_map[ctx]; Dictionary d2; @@ -98,8 +96,7 @@ void TranslationPO::_set_messages(const Dictionary &p_messages) { List<Variant> context_l; p_messages.get_key_list(&context_l); - for (List<Variant>::Element *E = context_l.front(); E; E = E->next()) { - StringName ctx = E->get(); + for (const Variant &ctx : context_l) { const Dictionary &id_str_map = p_messages[ctx]; HashMap<StringName, Vector<StringName>> temp_map; @@ -121,8 +118,8 @@ Vector<String> TranslationPO::_get_message_list() const { get_message_list(&msgs); Vector<String> v; - for (List<StringName>::Element *E = msgs.front(); E; E = E->next()) { - v.push_back(E->get()); + for (const StringName &E : msgs) { + v.push_back(E); } return v; @@ -281,13 +278,13 @@ void TranslationPO::get_message_list(List<StringName> *r_messages) const { List<StringName> context_l; translation_map.get_key_list(&context_l); - for (List<StringName>::Element *E = context_l.front(); E; E = E->next()) { - if (String(E->get()) != "") { + for (const StringName &E : context_l) { + if (String(E) != "") { continue; } List<StringName> msgid_l; - translation_map[E->get()].get_key_list(&msgid_l); + translation_map[E].get_key_list(&msgid_l); for (List<StringName>::Element *E2 = msgid_l.front(); E2; E2 = E2->next()) { r_messages->push_back(E2->get()); @@ -300,8 +297,8 @@ int TranslationPO::get_message_count() const { translation_map.get_key_list(&context_l); int count = 0; - for (List<StringName>::Element *E = context_l.front(); E; E = E->next()) { - count += translation_map[E->get()].size(); + for (const StringName &E : context_l) { + count += translation_map[E].size(); } return count; } diff --git a/core/string/ustring.cpp b/core/string/ustring.cpp index 4cd2915ffa..7beecdb6b5 100644 --- a/core/string/ustring.cpp +++ b/core/string/ustring.cpp @@ -3421,11 +3421,8 @@ String String::format(const Variant &values, String placeholder) const { List<Variant> keys; d.get_key_list(&keys); - for (List<Variant>::Element *E = keys.front(); E; E = E->next()) { - String key = E->get(); - String val = d[E->get()]; - - new_string = new_string.replace(placeholder.replace("_", key), val); + for (const Variant &key : keys) { + new_string = new_string.replace(placeholder.replace("_", key), d[key]); } } else { ERR_PRINT(String("Invalid type: use Array or Dictionary.").ascii().get_data()); diff --git a/core/templates/command_queue_mt.h b/core/templates/command_queue_mt.h index acc46da0d5..519a896ffc 100644 --- a/core/templates/command_queue_mt.h +++ b/core/templates/command_queue_mt.h @@ -321,7 +321,7 @@ class CommandQueueMT { DECL_CMD(0) SPACE_SEP_LIST(DECL_CMD, 15) - /* comands that return */ + // Commands that return. DECL_CMD_RET(0) SPACE_SEP_LIST(DECL_CMD_RET, 15) diff --git a/core/templates/hashfuncs.h b/core/templates/hashfuncs.h index 4572b269cf..2e932f9f26 100644 --- a/core/templates/hashfuncs.h +++ b/core/templates/hashfuncs.h @@ -95,7 +95,7 @@ static inline uint32_t hash_djb2_one_float(double p_in, uint32_t p_prev = 5381) if (p_in == 0.0f) { u.d = 0.0; } else if (Math::is_nan(p_in)) { - u.d = Math_NAN; + u.d = NAN; } else { u.d = p_in; } @@ -124,7 +124,7 @@ static inline uint64_t hash_djb2_one_float_64(double p_in, uint64_t p_prev = 538 if (p_in == 0.0f) { u.d = 0.0; } else if (Math::is_nan(p_in)) { - u.d = Math_NAN; + u.d = NAN; } else { u.d = p_in; } diff --git a/core/templates/list.h b/core/templates/list.h index 6047b89670..c2e17a2f6f 100644 --- a/core/templates/list.h +++ b/core/templates/list.h @@ -176,8 +176,8 @@ public: return *this; } - _FORCE_INLINE_ bool operator==(const Iterator &b) const { return E == b.E; } - _FORCE_INLINE_ bool operator!=(const Iterator &b) const { return E != b.E; } + _FORCE_INLINE_ bool operator==(const ConstIterator &b) const { return E == b.E; } + _FORCE_INLINE_ bool operator!=(const ConstIterator &b) const { return E != b.E; } _FORCE_INLINE_ ConstIterator(const Element *p_E) { E = p_E; } _FORCE_INLINE_ ConstIterator() {} diff --git a/core/templates/pair.h b/core/templates/pair.h index 31706b6ecb..e30ee8bc56 100644 --- a/core/templates/pair.h +++ b/core/templates/pair.h @@ -62,7 +62,10 @@ bool operator!=(const Pair<F, S> &pair, const Pair<F, S> &other) { template <class F, class S> struct PairSort { bool operator()(const Pair<F, S> &A, const Pair<F, S> &B) const { - return A.first < B.first; + if (A.first != B.first) { + return A.first < B.first; + } + return A.second < B.second; } }; diff --git a/core/templates/rid_owner.h b/core/templates/rid_owner.h index 4f5c74ca46..8d139551ef 100644 --- a/core/templates/rid_owner.h +++ b/core/templates/rid_owner.h @@ -101,7 +101,7 @@ class RID_Alloc : public RID_AllocBase { //initialize for (uint32_t i = 0; i < elements_in_chunk; i++) { - //dont initialize chunk + // Don't initialize chunk. validator_chunks[chunk_count][i] = 0xFFFFFFFF; free_list_chunks[chunk_count][i] = alloc_count + i; } diff --git a/core/templates/set.h b/core/templates/set.h index 245c174862..9261d2d3d2 100644 --- a/core/templates/set.h +++ b/core/templates/set.h @@ -71,6 +71,9 @@ public: Element *prev() { return _prev; } + T &get() { + return value; + } const T &get() const { return value; }; @@ -118,8 +121,8 @@ public: return *this; } - _FORCE_INLINE_ bool operator==(const Iterator &b) const { return E == b.E; } - _FORCE_INLINE_ bool operator!=(const Iterator &b) const { return E != b.E; } + _FORCE_INLINE_ bool operator==(const ConstIterator &b) const { return E == b.E; } + _FORCE_INLINE_ bool operator!=(const ConstIterator &b) const { return E != b.E; } _FORCE_INLINE_ ConstIterator(const Element *p_E) { E = p_E; } _FORCE_INLINE_ ConstIterator() {} diff --git a/core/variant/binder_common.h b/core/variant/binder_common.h index ef5867c685..3cb2a6bfb5 100644 --- a/core/variant/binder_common.h +++ b/core/variant/binder_common.h @@ -69,17 +69,17 @@ struct VariantCaster<const T &> { template <> \ struct VariantCaster<m_enum> { \ static _FORCE_INLINE_ m_enum cast(const Variant &p_variant) { \ - return (m_enum)p_variant.operator int(); \ + return (m_enum)p_variant.operator int64_t(); \ } \ }; \ template <> \ struct PtrToArg<m_enum> { \ _FORCE_INLINE_ static m_enum convert(const void *p_ptr) { \ - return m_enum(*reinterpret_cast<const int *>(p_ptr)); \ + return m_enum(*reinterpret_cast<const int64_t *>(p_ptr)); \ } \ typedef int64_t EncodeT; \ _FORCE_INLINE_ static void encode(m_enum p_val, const void *p_ptr) { \ - *(int *)p_ptr = p_val; \ + *(int64_t *)p_ptr = p_val; \ } \ }; diff --git a/core/variant/callable.cpp b/core/variant/callable.cpp index ca6f3d615e..f487e718f4 100644 --- a/core/variant/callable.cpp +++ b/core/variant/callable.cpp @@ -407,8 +407,8 @@ Array Signal::get_connections() const { object->get_signal_connection_list(name, &connections); Array arr; - for (List<Object::Connection>::Element *E = connections.front(); E; E = E->next()) { - arr.push_back(E->get()); + for (const Object::Connection &E : connections) { + arr.push_back(E); } return arr; } diff --git a/core/variant/method_ptrcall.h b/core/variant/method_ptrcall.h index 7852187b77..8836e257a9 100644 --- a/core/variant/method_ptrcall.h +++ b/core/variant/method_ptrcall.h @@ -105,7 +105,7 @@ struct PtrToArg {}; } \ } -MAKE_PTRARGCONV(bool, uint32_t); +MAKE_PTRARGCONV(bool, uint8_t); // Integer types. MAKE_PTRARGCONV(uint8_t, int64_t); MAKE_PTRARGCONV(int8_t, int64_t); diff --git a/core/variant/variant.cpp b/core/variant/variant.cpp index badb5ba103..97a1b4c02a 100644 --- a/core/variant/variant.cpp +++ b/core/variant/variant.cpp @@ -1681,10 +1681,10 @@ String Variant::stringify(List<const void *> &stack) const { Vector<_VariantStrPair> pairs; - for (List<Variant>::Element *E = keys.front(); E; E = E->next()) { + for (const Variant &E : keys) { _VariantStrPair sp; - sp.key = E->get().stringify(stack); - sp.value = d[E->get()].stringify(stack); + sp.key = E.stringify(stack); + sp.value = d[E].stringify(stack); pairs.push_back(sp); } diff --git a/core/variant/variant.h b/core/variant/variant.h index 373fe32921..780f9b4e70 100644 --- a/core/variant/variant.h +++ b/core/variant/variant.h @@ -118,6 +118,11 @@ public: VARIANT_MAX }; + enum { + // Maximum recursion depth allowed when serializing variants. + MAX_RECURSION_DEPTH = 1024, + }; + private: friend struct _VariantCall; friend class VariantInternal; @@ -253,7 +258,7 @@ private: true, //PACKED_COLOR_ARRAY, }; - if (unlikely(needs_deinit[type])) { //make it fast for types that dont need deinit + if (unlikely(needs_deinit[type])) { // Make it fast for types that don't need deinit. _clear_internal(); } type = NIL; @@ -502,7 +507,7 @@ public: static uint32_t get_builtin_method_hash(Variant::Type p_type, const StringName &p_method); void call(const StringName &p_method, const Variant **p_args, int p_argcount, Variant &r_ret, Callable::CallError &r_error); - Variant call(const StringName &p_method, const Variant &p_arg1 = Variant(), const Variant &p_arg2 = Variant(), const Variant &p_arg3 = Variant(), const Variant &p_arg4 = Variant(), const Variant &p_arg5 = Variant()); + Variant call(const StringName &p_method, const Variant &p_arg1 = Variant(), const Variant &p_arg2 = Variant(), const Variant &p_arg3 = Variant(), const Variant &p_arg4 = Variant(), const Variant &p_arg5 = Variant(), const Variant &p_arg6 = Variant(), const Variant &p_arg7 = Variant(), const Variant &p_arg8 = Variant()); static void call_static(Variant::Type p_type, const StringName &p_method, const Variant **p_args, int p_argcount, Variant &r_ret, Callable::CallError &r_error); diff --git a/core/variant/variant_call.cpp b/core/variant/variant_call.cpp index 733361fe58..f8538f71d3 100644 --- a/core/variant/variant_call.cpp +++ b/core/variant/variant_call.cpp @@ -750,6 +750,42 @@ struct _VariantCall { return 0; } + static PackedInt32Array func_PackedByteArray_decode_s32_array(PackedByteArray *p_instance) { + uint64_t size = p_instance->size(); + const uint8_t *r = p_instance->ptr(); + PackedInt32Array dest; + dest.resize(size / sizeof(int32_t)); + memcpy(dest.ptrw(), r, size); + return dest; + } + + static PackedInt64Array func_PackedByteArray_decode_s64_array(PackedByteArray *p_instance) { + uint64_t size = p_instance->size(); + const uint8_t *r = p_instance->ptr(); + PackedInt64Array dest; + dest.resize(size / sizeof(int64_t)); + memcpy(dest.ptrw(), r, size); + return dest; + } + + static PackedFloat32Array func_PackedByteArray_decode_float_array(PackedByteArray *p_instance) { + uint64_t size = p_instance->size(); + const uint8_t *r = p_instance->ptr(); + PackedFloat32Array dest; + dest.resize(size / sizeof(float)); + memcpy(dest.ptrw(), r, size); + return dest; + } + + static PackedFloat64Array func_PackedByteArray_decode_double_array(PackedByteArray *p_instance) { + uint64_t size = p_instance->size(); + const uint8_t *r = p_instance->ptr(); + PackedFloat64Array dest; + dest.resize(size / sizeof(double)); + memcpy(dest.ptrw(), r, size); + return dest; + } + static void func_PackedByteArray_encode_u8(PackedByteArray *p_instance, int64_t p_offset, int64_t p_value) { uint64_t size = p_instance->size(); ERR_FAIL_COND(p_offset < 0 || p_offset > int64_t(size) - 1); @@ -1088,8 +1124,8 @@ bool Variant::has_builtin_method_return_value(Variant::Type p_type, const String void Variant::get_builtin_method_list(Variant::Type p_type, List<StringName> *p_list) { ERR_FAIL_INDEX(p_type, Variant::VARIANT_MAX); - for (List<StringName>::Element *E = builtin_method_names[p_type].front(); E; E = E->next()) { - p_list->push_back(E->get()); + for (const StringName &E : builtin_method_names[p_type]) { + p_list->push_back(E); } } @@ -1152,12 +1188,12 @@ void Variant::get_method_list(List<MethodInfo> *p_list) const { obj->get_method_list(p_list); } } else { - for (List<StringName>::Element *E = builtin_method_names[type].front(); E; E = E->next()) { - const VariantBuiltInMethodInfo *method = builtin_method_info[type].lookup_ptr(E->get()); + for (const StringName &E : builtin_method_names[type]) { + const VariantBuiltInMethodInfo *method = builtin_method_info[type].lookup_ptr(E); ERR_CONTINUE(!method); MethodInfo mi; - mi.name = E->get(); + mi.name = E; //return type if (method->has_return_type) { @@ -1824,6 +1860,11 @@ static void _register_variant_builtin_methods() { bind_function(PackedByteArray, decode_var, _VariantCall::func_PackedByteArray_decode_var, sarray("byte_offset", "allow_objects"), varray(false)); bind_function(PackedByteArray, decode_var_size, _VariantCall::func_PackedByteArray_decode_var_size, sarray("byte_offset", "allow_objects"), varray(false)); + bind_function(PackedByteArray, to_int32_array, _VariantCall::func_PackedByteArray_decode_s32_array, sarray(), varray()); + bind_function(PackedByteArray, to_int64_array, _VariantCall::func_PackedByteArray_decode_s64_array, sarray(), varray()); + bind_function(PackedByteArray, to_float32_array, _VariantCall::func_PackedByteArray_decode_float_array, sarray(), varray()); + bind_function(PackedByteArray, to_float64_array, _VariantCall::func_PackedByteArray_decode_double_array, sarray(), varray()); + bind_functionnc(PackedByteArray, encode_u8, _VariantCall::func_PackedByteArray_encode_u8, sarray("byte_offset", "value"), varray()); bind_functionnc(PackedByteArray, encode_s8, _VariantCall::func_PackedByteArray_encode_s8, sarray("byte_offset", "value"), varray()); bind_functionnc(PackedByteArray, encode_u16, _VariantCall::func_PackedByteArray_encode_u16, sarray("byte_offset", "value"), varray()); @@ -2002,7 +2043,7 @@ static void _register_variant_builtin_methods() { _VariantCall::add_variant_constant(Variant::VECTOR3, "ZERO", Vector3(0, 0, 0)); _VariantCall::add_variant_constant(Variant::VECTOR3, "ONE", Vector3(1, 1, 1)); - _VariantCall::add_variant_constant(Variant::VECTOR3, "INF", Vector3(Math_INF, Math_INF, Math_INF)); + _VariantCall::add_variant_constant(Variant::VECTOR3, "INF", Vector3(INFINITY, INFINITY, INFINITY)); _VariantCall::add_variant_constant(Variant::VECTOR3, "LEFT", Vector3(-1, 0, 0)); _VariantCall::add_variant_constant(Variant::VECTOR3, "RIGHT", Vector3(1, 0, 0)); _VariantCall::add_variant_constant(Variant::VECTOR3, "UP", Vector3(0, 1, 0)); @@ -2031,7 +2072,7 @@ static void _register_variant_builtin_methods() { _VariantCall::add_variant_constant(Variant::VECTOR2, "ZERO", Vector2(0, 0)); _VariantCall::add_variant_constant(Variant::VECTOR2, "ONE", Vector2(1, 1)); - _VariantCall::add_variant_constant(Variant::VECTOR2, "INF", Vector2(Math_INF, Math_INF)); + _VariantCall::add_variant_constant(Variant::VECTOR2, "INF", Vector2(INFINITY, INFINITY)); _VariantCall::add_variant_constant(Variant::VECTOR2, "LEFT", Vector2(-1, 0)); _VariantCall::add_variant_constant(Variant::VECTOR2, "RIGHT", Vector2(1, 0)); _VariantCall::add_variant_constant(Variant::VECTOR2, "UP", Vector2(0, -1)); diff --git a/core/variant/variant_op.h b/core/variant/variant_op.h index e744e76ea3..cbdd60f404 100644 --- a/core/variant/variant_op.h +++ b/core/variant/variant_op.h @@ -1261,8 +1261,10 @@ public: const String &a = *VariantGetInternalPtr<String>::get_ptr(&p_left); - b->get(a, &r_valid); - *r_ret = r_valid; + bool exist; + b->get(a, &exist); + *r_ret = exist; + r_valid = true; } static inline void validated_evaluate(const Variant *left, const Variant *right, Variant *r_ret) { Object *l = right->get_validated_object(); @@ -1293,8 +1295,10 @@ public: const StringName &a = *VariantGetInternalPtr<StringName>::get_ptr(&p_left); - b->get(a, &r_valid); - *r_ret = r_valid; + bool exist; + b->get(a, &exist); + *r_ret = exist; + r_valid = true; } static inline void validated_evaluate(const Variant *left, const Variant *right, Variant *r_ret) { Object *l = right->get_validated_object(); diff --git a/core/variant/variant_parser.cpp b/core/variant/variant_parser.cpp index 86d5ae7f38..50c48fd386 100644 --- a/core/variant/variant_parser.cpp +++ b/core/variant/variant_parser.cpp @@ -506,9 +506,9 @@ Error VariantParser::parse_value(Token &token, Variant &value, Stream *p_stream, } else if (id == "null" || id == "nil") { value = Variant(); } else if (id == "inf") { - value = Math_INF; + value = INFINITY; } else if (id == "nan") { - value = Math_NAN; + value = NAN; } else if (id == "Vector2") { Vector<real_t> args; Error err = _parse_construct<real_t>(p_stream, args, line, r_err_str); @@ -1586,8 +1586,8 @@ Error VariantWriter::write(const Variant &p_variant, StoreStringFunc p_store_str List<PropertyInfo> props; obj->get_property_list(&props); bool first = true; - for (List<PropertyInfo>::Element *E = props.front(); E; E = E->next()) { - if (E->get().usage & PROPERTY_USAGE_STORAGE || E->get().usage & PROPERTY_USAGE_SCRIPT_VARIABLE) { + for (const PropertyInfo &E : props) { + if (E.usage & PROPERTY_USAGE_STORAGE || E.usage & PROPERTY_USAGE_SCRIPT_VARIABLE) { //must be serialized if (first) { @@ -1596,8 +1596,8 @@ Error VariantWriter::write(const Variant &p_variant, StoreStringFunc p_store_str p_store_string_func(p_store_string_ud, ","); } - p_store_string_func(p_store_string_ud, "\"" + E->get().name + "\":"); - write(obj->get(E->get().name), p_store_string_func, p_store_string_ud, p_encode_res_func, p_encode_res_ud); + p_store_string_func(p_store_string_ud, "\"" + E.name + "\":"); + write(obj->get(E.name), p_store_string_func, p_store_string_ud, p_encode_res_func, p_encode_res_ud); } } @@ -1615,7 +1615,7 @@ Error VariantWriter::write(const Variant &p_variant, StoreStringFunc p_store_str p_store_string_func(p_store_string_ud, "{\n"); for (List<Variant>::Element *E = keys.front(); E; E = E->next()) { /* - if (!_check_type(dict[E->get()])) + if (!_check_type(dict[E])) continue; */ write(E->get(), p_store_string_func, p_store_string_ud, p_encode_res_func, p_encode_res_ud); diff --git a/core/variant/variant_parser.h b/core/variant/variant_parser.h index 05fc29b5e0..1ba26db6ed 100644 --- a/core/variant/variant_parser.h +++ b/core/variant/variant_parser.h @@ -73,9 +73,9 @@ public: struct ResourceParser { void *userdata = nullptr; - ParseResourceFunc func; - ParseResourceFunc ext_func; - ParseResourceFunc sub_func; + ParseResourceFunc func = nullptr; + ParseResourceFunc ext_func = nullptr; + ParseResourceFunc sub_func = nullptr; }; enum TokenType { diff --git a/core/variant/variant_setget.cpp b/core/variant/variant_setget.cpp index de1deace63..ae3c7685fd 100644 --- a/core/variant/variant_setget.cpp +++ b/core/variant/variant_setget.cpp @@ -1093,9 +1093,9 @@ void Variant::get_property_list(List<PropertyInfo> *p_list) const { const Dictionary *dic = reinterpret_cast<const Dictionary *>(_data._mem); List<Variant> keys; dic->get_key_list(&keys); - for (List<Variant>::Element *E = keys.front(); E; E = E->next()) { - if (E->get().get_type() == Variant::STRING) { - p_list->push_back(PropertyInfo(Variant::STRING, E->get())); + for (const Variant &E : keys) { + if (E.get_type() == Variant::STRING) { + p_list->push_back(PropertyInfo(Variant::STRING, E)); } } } else if (type == OBJECT) { @@ -1106,10 +1106,10 @@ void Variant::get_property_list(List<PropertyInfo> *p_list) const { } else { List<StringName> members; get_member_list(type, &members); - for (List<StringName>::Element *E = members.front(); E; E = E->next()) { + for (const StringName &E : members) { PropertyInfo pi; - pi.name = E->get(); - pi.type = get_member_type(type, E->get()); + pi.name = E; + pi.type = get_member_type(type, E); p_list->push_back(pi); } } diff --git a/core/variant/variant_utility.cpp b/core/variant/variant_utility.cpp index 1f69e81d99..34dbf130b6 100644 --- a/core/variant/variant_utility.cpp +++ b/core/variant/variant_utility.cpp @@ -249,10 +249,6 @@ struct VariantUtilityFunctions { return Math::move_toward(from, to, delta); } - static inline double dectime(double value, double amount, double step) { - return Math::dectime(value, amount, step); - } - static inline double deg2rad(double angle_deg) { return Math::deg2rad(angle_deg); } @@ -1195,7 +1191,6 @@ void Variant::_register_variant_utility_functions() { FUNCBINDR(smoothstep, sarray("from", "to", "x"), Variant::UTILITY_FUNC_TYPE_MATH); FUNCBINDR(move_toward, sarray("from", "to", "delta"), Variant::UTILITY_FUNC_TYPE_MATH); - FUNCBINDR(dectime, sarray("value", "amount", "step"), Variant::UTILITY_FUNC_TYPE_MATH); FUNCBINDR(deg2rad, sarray("deg"), Variant::UTILITY_FUNC_TYPE_MATH); FUNCBINDR(rad2deg, sarray("rad"), Variant::UTILITY_FUNC_TYPE_MATH); @@ -1397,8 +1392,8 @@ uint32_t Variant::get_utility_function_hash(const StringName &p_name) { } void Variant::get_utility_function_list(List<StringName> *r_functions) { - for (List<StringName>::Element *E = utility_function_name_table.front(); E; E = E->next()) { - r_functions->push_back(E->get()); + for (const StringName &E : utility_function_name_table) { + r_functions->push_back(E); } } diff --git a/doc/classes/@GlobalScope.xml b/doc/classes/@GlobalScope.xml index d0bd517050..c86812742c 100644 --- a/doc/classes/@GlobalScope.xml +++ b/doc/classes/@GlobalScope.xml @@ -11,18 +11,14 @@ </tutorials> <methods> <method name="abs"> - <return type="Variant"> - </return> - <argument index="0" name="x" type="Variant"> - </argument> + <return type="Variant" /> + <argument index="0" name="x" type="Variant" /> <description> </description> </method> <method name="absf"> - <return type="float"> - </return> - <argument index="0" name="x" type="float"> - </argument> + <return type="float" /> + <argument index="0" name="x" type="float" /> <description> Returns the absolute value of float parameter [code]x[/code] (i.e. positive value). [codeblock] @@ -32,10 +28,8 @@ </description> </method> <method name="absi"> - <return type="int"> - </return> - <argument index="0" name="x" type="int"> - </argument> + <return type="int" /> + <argument index="0" name="x" type="int" /> <description> Returns the absolute value of int parameter [code]x[/code] (i.e. positive value). [codeblock] @@ -45,10 +39,8 @@ </description> </method> <method name="acos"> - <return type="float"> - </return> - <argument index="0" name="x" type="float"> - </argument> + <return type="float" /> + <argument index="0" name="x" type="float" /> <description> Returns the arc cosine of [code]x[/code] in radians. Use to get the angle of cosine [code]x[/code]. [code]x[/code] must be between [code]-1.0[/code] and [code]1.0[/code] (inclusive), otherwise, [method acos] will return [constant @GDScript.NAN]. [codeblock] @@ -58,10 +50,8 @@ </description> </method> <method name="asin"> - <return type="float"> - </return> - <argument index="0" name="x" type="float"> - </argument> + <return type="float" /> + <argument index="0" name="x" type="float" /> <description> Returns the arc sine of [code]x[/code] in radians. Use to get the angle of sine [code]x[/code]. [code]x[/code] must be between [code]-1.0[/code] and [code]1.0[/code] (inclusive), otherwise, [method asin] will return [constant @GDScript.NAN]. [codeblock] @@ -71,10 +61,8 @@ </description> </method> <method name="atan"> - <return type="float"> - </return> - <argument index="0" name="x" type="float"> - </argument> + <return type="float" /> + <argument index="0" name="x" type="float" /> <description> Returns the arc tangent of [code]x[/code] in radians. Use it to get the angle from an angle's tangent in trigonometry: [code]atan(tan(angle)) == angle[/code]. The method cannot know in which quadrant the angle should fall. See [method atan2] if you have both [code]y[/code] and [code]x[/code]. @@ -84,12 +72,9 @@ </description> </method> <method name="atan2"> - <return type="float"> - </return> - <argument index="0" name="y" type="float"> - </argument> - <argument index="1" name="x" type="float"> - </argument> + <return type="float" /> + <argument index="0" name="y" type="float" /> + <argument index="1" name="x" type="float" /> <description> Returns the arc tangent of [code]y/x[/code] in radians. Use to get the angle of tangent [code]y/x[/code]. To compute the value, the method takes into account the sign of both arguments in order to determine the quadrant. Important note: The Y coordinate comes first, by convention. @@ -99,41 +84,32 @@ </description> </method> <method name="bytes2var"> - <return type="Variant"> - </return> - <argument index="0" name="bytes" type="PackedByteArray"> - </argument> + <return type="Variant" /> + <argument index="0" name="bytes" type="PackedByteArray" /> <description> Decodes a byte array back to a [Variant] value, without decoding objects. [b]Note:[/b] If you need object deserialization, see [method bytes2var_with_objects]. </description> </method> <method name="bytes2var_with_objects"> - <return type="Variant"> - </return> - <argument index="0" name="bytes" type="PackedByteArray"> - </argument> + <return type="Variant" /> + <argument index="0" name="bytes" type="PackedByteArray" /> <description> Decodes a byte array back to a [Variant] value. Decoding objects is allowed. [b]WARNING:[/b] Deserialized object can contain code which gets executed. Do not use this option if the serialized object comes from untrusted sources to avoid potential security threats (remote code execution). </description> </method> <method name="cartesian2polar"> - <return type="Vector2"> - </return> - <argument index="0" name="x" type="float"> - </argument> - <argument index="1" name="y" type="float"> - </argument> + <return type="Vector2" /> + <argument index="0" name="x" type="float" /> + <argument index="1" name="y" type="float" /> <description> Converts a 2D point expressed in the cartesian coordinate system (X and Y axis) to the polar coordinate system (a distance from the origin and an angle). </description> </method> <method name="ceil"> - <return type="float"> - </return> - <argument index="0" name="x" type="float"> - </argument> + <return type="float" /> + <argument index="0" name="x" type="float" /> <description> Rounds [code]x[/code] upward (towards positive infinity), returning the smallest whole number that is not less than [code]x[/code]. [codeblock] @@ -144,26 +120,18 @@ </description> </method> <method name="clamp"> - <return type="Variant"> - </return> - <argument index="0" name="value" type="Variant"> - </argument> - <argument index="1" name="min" type="Variant"> - </argument> - <argument index="2" name="max" type="Variant"> - </argument> + <return type="Variant" /> + <argument index="0" name="value" type="Variant" /> + <argument index="1" name="min" type="Variant" /> + <argument index="2" name="max" type="Variant" /> <description> </description> </method> <method name="clampf"> - <return type="float"> - </return> - <argument index="0" name="value" type="float"> - </argument> - <argument index="1" name="min" type="float"> - </argument> - <argument index="2" name="max" type="float"> - </argument> + <return type="float" /> + <argument index="0" name="value" type="float" /> + <argument index="1" name="min" type="float" /> + <argument index="2" name="max" type="float" /> <description> Clamps the float [code]value[/code] and returns a value not less than [code]min[/code] and not more than [code]max[/code]. [codeblock] @@ -178,14 +146,10 @@ </description> </method> <method name="clampi"> - <return type="int"> - </return> - <argument index="0" name="value" type="int"> - </argument> - <argument index="1" name="min" type="int"> - </argument> - <argument index="2" name="max" type="int"> - </argument> + <return type="int" /> + <argument index="0" name="value" type="int" /> + <argument index="1" name="min" type="int" /> + <argument index="2" name="max" type="int" /> <description> Clamps the integer [code]value[/code] and returns a value not less than [code]min[/code] and not more than [code]max[/code]. [codeblock] @@ -200,10 +164,8 @@ </description> </method> <method name="cos"> - <return type="float"> - </return> - <argument index="0" name="angle_rad" type="float"> - </argument> + <return type="float" /> + <argument index="0" name="angle_rad" type="float" /> <description> Returns the cosine of angle [code]angle_rad[/code] in radians. [codeblock] @@ -214,10 +176,8 @@ </description> </method> <method name="cosh"> - <return type="float"> - </return> - <argument index="0" name="x" type="float"> - </argument> + <return type="float" /> + <argument index="0" name="x" type="float" /> <description> Returns the hyperbolic cosine of [code]x[/code] in radians. [codeblock] @@ -227,36 +187,15 @@ </description> </method> <method name="db2linear"> - <return type="float"> - </return> - <argument index="0" name="db" type="float"> - </argument> + <return type="float" /> + <argument index="0" name="db" type="float" /> <description> Converts from decibels to linear energy (audio). </description> </method> - <method name="dectime"> - <return type="float"> - </return> - <argument index="0" name="value" type="float"> - </argument> - <argument index="1" name="amount" type="float"> - </argument> - <argument index="2" name="step" type="float"> - </argument> - <description> - Returns the result of [code]value[/code] decreased by [code]step[/code] * [code]amount[/code]. - [codeblock] - # a = 59 - a = dectime(60, 10, 0.1)) - [/codeblock] - </description> - </method> <method name="deg2rad"> - <return type="float"> - </return> - <argument index="0" name="deg" type="float"> - </argument> + <return type="float" /> + <argument index="0" name="deg" type="float" /> <description> Converts an angle expressed in degrees to radians. [codeblock] @@ -266,21 +205,16 @@ </description> </method> <method name="ease"> - <return type="float"> - </return> - <argument index="0" name="x" type="float"> - </argument> - <argument index="1" name="curve" type="float"> - </argument> + <return type="float" /> + <argument index="0" name="x" type="float" /> + <argument index="1" name="curve" type="float" /> <description> Easing function, based on exponent. The curve values are: 0 is constant, 1 is linear, 0 to 1 is ease-in, 1+ is ease out. Negative values are in-out/out in. </description> </method> <method name="exp"> - <return type="float"> - </return> - <argument index="0" name="x" type="float"> - </argument> + <return type="float" /> + <argument index="0" name="x" type="float" /> <description> The natural exponential function. It raises the mathematical constant [b]e[/b] to the power of [code]x[/code] and returns it. [b]e[/b] has an approximate value of 2.71828, and can be obtained with [code]exp(1)[/code]. @@ -291,10 +225,8 @@ </description> </method> <method name="floor"> - <return type="float"> - </return> - <argument index="0" name="x" type="float"> - </argument> + <return type="float" /> + <argument index="0" name="x" type="float" /> <description> Rounds [code]x[/code] downward (towards negative infinity), returning the largest whole number that is not more than [code]x[/code]. [codeblock] @@ -308,12 +240,9 @@ </description> </method> <method name="fmod"> - <return type="float"> - </return> - <argument index="0" name="x" type="float"> - </argument> - <argument index="1" name="y" type="float"> - </argument> + <return type="float" /> + <argument index="0" name="x" type="float" /> + <argument index="1" name="y" type="float" /> <description> Returns the floating-point remainder of [code]x/y[/code], keeping the sign of [code]x[/code]. [codeblock] @@ -324,12 +253,9 @@ </description> </method> <method name="fposmod"> - <return type="float"> - </return> - <argument index="0" name="x" type="float"> - </argument> - <argument index="1" name="y" type="float"> - </argument> + <return type="float" /> + <argument index="0" name="x" type="float" /> + <argument index="1" name="y" type="float" /> <description> Returns the floating-point modulus of [code]x/y[/code] that wraps equally in positive and negative. [codeblock] @@ -350,10 +276,8 @@ </description> </method> <method name="hash"> - <return type="int"> - </return> - <argument index="0" name="variable" type="Variant"> - </argument> + <return type="int" /> + <argument index="0" name="variable" type="Variant" /> <description> Returns the integer hash of the variable passed. [codeblock] @@ -362,10 +286,8 @@ </description> </method> <method name="instance_from_id"> - <return type="Object"> - </return> - <argument index="0" name="instance_id" type="int"> - </argument> + <return type="Object" /> + <argument index="0" name="instance_id" type="int" /> <description> Returns the Object that corresponds to [code]instance_id[/code]. All Objects have a unique instance ID. [codeblock] @@ -378,14 +300,10 @@ </description> </method> <method name="inverse_lerp"> - <return type="float"> - </return> - <argument index="0" name="from" type="float"> - </argument> - <argument index="1" name="to" type="float"> - </argument> - <argument index="2" name="weight" type="float"> - </argument> + <return type="float" /> + <argument index="0" name="from" type="float" /> + <argument index="1" name="to" type="float" /> + <argument index="2" name="weight" type="float" /> <description> Returns a normalized value considering the given range. This is the opposite of [method lerp]. [codeblock] @@ -398,12 +316,9 @@ </description> </method> <method name="is_equal_approx"> - <return type="bool"> - </return> - <argument index="0" name="a" type="float"> - </argument> - <argument index="1" name="b" type="float"> - </argument> + <return type="bool" /> + <argument index="0" name="a" type="float" /> + <argument index="1" name="b" type="float" /> <description> Returns [code]true[/code] if [code]a[/code] and [code]b[/code] are approximately equal to each other. Here, approximately equal means that [code]a[/code] and [code]b[/code] are within a small internal epsilon of each other, which scales with the magnitude of the numbers. @@ -411,59 +326,45 @@ </description> </method> <method name="is_inf"> - <return type="bool"> - </return> - <argument index="0" name="x" type="float"> - </argument> + <return type="bool" /> + <argument index="0" name="x" type="float" /> <description> Returns whether [code]x[/code] is an infinity value (either positive infinity or negative infinity). </description> </method> <method name="is_instance_id_valid"> - <return type="bool"> - </return> - <argument index="0" name="id" type="int"> - </argument> + <return type="bool" /> + <argument index="0" name="id" type="int" /> <description> </description> </method> <method name="is_instance_valid"> - <return type="bool"> - </return> - <argument index="0" name="instance" type="Variant"> - </argument> + <return type="bool" /> + <argument index="0" name="instance" type="Variant" /> <description> Returns whether [code]instance[/code] is a valid object (e.g. has not been deleted from memory). </description> </method> <method name="is_nan"> - <return type="bool"> - </return> - <argument index="0" name="x" type="float"> - </argument> + <return type="bool" /> + <argument index="0" name="x" type="float" /> <description> Returns whether [code]x[/code] is a NaN ("Not a Number" or invalid) value. </description> </method> <method name="is_zero_approx"> - <return type="bool"> - </return> - <argument index="0" name="x" type="float"> - </argument> + <return type="bool" /> + <argument index="0" name="x" type="float" /> <description> Returns [code]true[/code] if [code]x[/code] is zero or almost zero. This method is faster than using [method is_equal_approx] with one value as zero. </description> </method> <method name="lerp"> - <return type="float"> - </return> - <argument index="0" name="from" type="float"> - </argument> - <argument index="1" name="to" type="float"> - </argument> - <argument index="2" name="weight" type="float"> - </argument> + <return type="float" /> + <argument index="0" name="from" type="float" /> + <argument index="1" name="to" type="float" /> + <argument index="2" name="weight" type="float" /> <description> Linearly interpolates between two values by a normalized value. This is the opposite of [method inverse_lerp]. [codeblock] @@ -472,14 +373,10 @@ </description> </method> <method name="lerp_angle"> - <return type="float"> - </return> - <argument index="0" name="from" type="float"> - </argument> - <argument index="1" name="to" type="float"> - </argument> - <argument index="2" name="weight" type="float"> - </argument> + <return type="float" /> + <argument index="0" name="from" type="float" /> + <argument index="1" name="to" type="float" /> + <argument index="2" name="weight" type="float" /> <description> Linearly interpolates between two angles (in radians) by a normalized value. Similar to [method lerp], but interpolates correctly when the angles wrap around [constant @GDScript.TAU]. @@ -495,10 +392,8 @@ </description> </method> <method name="linear2db"> - <return type="float"> - </return> - <argument index="0" name="lin" type="float"> - </argument> + <return type="float" /> + <argument index="0" name="lin" type="float" /> <description> Converts from linear energy to decibels (audio). This can be used to implement volume sliders that behave as expected (since volume isn't linear). Example: [codeblock] @@ -510,10 +405,8 @@ </description> </method> <method name="log"> - <return type="float"> - </return> - <argument index="0" name="x" type="float"> - </argument> + <return type="float" /> + <argument index="0" name="x" type="float" /> <description> Natural logarithm. The amount of time needed to reach a certain level of continuous growth. [b]Note:[/b] This is not the same as the "log" function on most calculators, which uses a base 10 logarithm. @@ -524,8 +417,7 @@ </description> </method> <method name="max" qualifiers="vararg"> - <return type="Variant"> - </return> + <return type="Variant" /> <description> Returns the maximum of the given values. This method can take any number of arguments. [codeblock] @@ -534,12 +426,9 @@ </description> </method> <method name="maxf"> - <return type="float"> - </return> - <argument index="0" name="a" type="float"> - </argument> - <argument index="1" name="b" type="float"> - </argument> + <return type="float" /> + <argument index="0" name="a" type="float" /> + <argument index="1" name="b" type="float" /> <description> Returns the maximum of two float values. [codeblock] @@ -549,12 +438,9 @@ </description> </method> <method name="maxi"> - <return type="int"> - </return> - <argument index="0" name="a" type="int"> - </argument> - <argument index="1" name="b" type="int"> - </argument> + <return type="int" /> + <argument index="0" name="a" type="int" /> + <argument index="1" name="b" type="int" /> <description> Returns the maximum of two int values. [codeblock] @@ -564,8 +450,7 @@ </description> </method> <method name="min" qualifiers="vararg"> - <return type="Variant"> - </return> + <return type="Variant" /> <description> Returns the minimum of the given values. This method can take any number of arguments. [codeblock] @@ -574,12 +459,9 @@ </description> </method> <method name="minf"> - <return type="float"> - </return> - <argument index="0" name="a" type="float"> - </argument> - <argument index="1" name="b" type="float"> - </argument> + <return type="float" /> + <argument index="0" name="a" type="float" /> + <argument index="1" name="b" type="float" /> <description> Returns the minimum of two float values. [codeblock] @@ -589,12 +471,9 @@ </description> </method> <method name="mini"> - <return type="int"> - </return> - <argument index="0" name="a" type="int"> - </argument> - <argument index="1" name="b" type="int"> - </argument> + <return type="int" /> + <argument index="0" name="a" type="int" /> + <argument index="1" name="b" type="int" /> <description> Returns the minimum of two int values. [codeblock] @@ -604,14 +483,10 @@ </description> </method> <method name="move_toward"> - <return type="float"> - </return> - <argument index="0" name="from" type="float"> - </argument> - <argument index="1" name="to" type="float"> - </argument> - <argument index="2" name="delta" type="float"> - </argument> + <return type="float" /> + <argument index="0" name="from" type="float" /> + <argument index="1" name="to" type="float" /> + <argument index="2" name="delta" type="float" /> <description> Moves [code]from[/code] toward [code]to[/code] by the [code]delta[/code] value. Use a negative [code]delta[/code] value to move away. @@ -623,10 +498,8 @@ </description> </method> <method name="nearest_po2"> - <return type="int"> - </return> - <argument index="0" name="value" type="int"> - </argument> + <return type="int" /> + <argument index="0" name="value" type="int" /> <description> Returns the nearest equal or larger power of 2 for integer [code]value[/code]. In other words, returns the smallest value [code]a[/code] where [code]a = pow(2, n)[/code] such that [code]value <= a[/code] for some non-negative integer [code]n[/code]. @@ -642,23 +515,17 @@ </description> </method> <method name="polar2cartesian"> - <return type="Vector2"> - </return> - <argument index="0" name="r" type="float"> - </argument> - <argument index="1" name="th" type="float"> - </argument> + <return type="Vector2" /> + <argument index="0" name="r" type="float" /> + <argument index="1" name="th" type="float" /> <description> Converts a 2D point expressed in the polar coordinate system (a distance from the origin [code]r[/code] and an angle [code]th[/code]) to the cartesian coordinate system (X and Y axis). </description> </method> <method name="posmod"> - <return type="int"> - </return> - <argument index="0" name="x" type="int"> - </argument> - <argument index="1" name="y" type="int"> - </argument> + <return type="int" /> + <argument index="0" name="x" type="int" /> + <argument index="1" name="y" type="int" /> <description> Returns the integer modulus of [code]x/y[/code] that wraps equally in positive and negative. [codeblock] @@ -678,12 +545,9 @@ </description> </method> <method name="pow"> - <return type="float"> - </return> - <argument index="0" name="base" type="float"> - </argument> - <argument index="1" name="exp" type="float"> - </argument> + <return type="float" /> + <argument index="0" name="base" type="float" /> + <argument index="1" name="exp" type="float" /> <description> Returns the result of [code]base[/code] raised to the power of [code]exp[/code]. [codeblock] @@ -754,10 +618,8 @@ </description> </method> <method name="rad2deg"> - <return type="float"> - </return> - <argument index="0" name="rad" type="float"> - </argument> + <return type="float" /> + <argument index="0" name="rad" type="float" /> <description> Converts an angle expressed in radians to degrees. [codeblock] @@ -766,17 +628,14 @@ </description> </method> <method name="rand_from_seed"> - <return type="PackedInt64Array"> - </return> - <argument index="0" name="seed" type="int"> - </argument> + <return type="PackedInt64Array" /> + <argument index="0" name="seed" type="int" /> <description> Random from seed: pass a [code]seed[/code], and an array with both number and new seed is returned. "Seed" here refers to the internal state of the pseudo random number generator. The internal state of the current implementation is 64 bits. </description> </method> <method name="randf"> - <return type="float"> - </return> + <return type="float" /> <description> Returns a random floating point value between [code]0.0[/code] and [code]1.0[/code] (inclusive). [codeblock] @@ -785,12 +644,9 @@ </description> </method> <method name="randf_range"> - <return type="float"> - </return> - <argument index="0" name="from" type="float"> - </argument> - <argument index="1" name="to" type="float"> - </argument> + <return type="float" /> + <argument index="0" name="from" type="float" /> + <argument index="1" name="to" type="float" /> <description> Returns a random floating point value on the interval between [code]from[/code] and [code]to[/code] (inclusive). [codeblock] @@ -799,8 +655,7 @@ </description> </method> <method name="randi"> - <return type="int"> - </return> + <return type="int" /> <description> Returns a random unsigned 32-bit integer. Use remainder to obtain a random value in the interval [code][0, N - 1][/code] (where N is smaller than 2^32). [codeblock] @@ -812,12 +667,9 @@ </description> </method> <method name="randi_range"> - <return type="int"> - </return> - <argument index="0" name="from" type="int"> - </argument> - <argument index="1" name="to" type="int"> - </argument> + <return type="int" /> + <argument index="0" name="from" type="int" /> + <argument index="1" name="to" type="int" /> <description> Returns a random signed 32-bit integer between [code]from[/code] and [code]to[/code] (inclusive). If [code]to[/code] is lesser than [code]from[/code], they are swapped. [codeblock] @@ -833,18 +685,12 @@ </description> </method> <method name="range_lerp"> - <return type="float"> - </return> - <argument index="0" name="value" type="float"> - </argument> - <argument index="1" name="istart" type="float"> - </argument> - <argument index="2" name="istop" type="float"> - </argument> - <argument index="3" name="ostart" type="float"> - </argument> - <argument index="4" name="ostop" type="float"> - </argument> + <return type="float" /> + <argument index="0" name="value" type="float" /> + <argument index="1" name="istart" type="float" /> + <argument index="2" name="istop" type="float" /> + <argument index="3" name="ostart" type="float" /> + <argument index="4" name="ostop" type="float" /> <description> Maps a [code]value[/code] from range [code][istart, istop][/code] to [code][ostart, ostop][/code]. [codeblock] @@ -853,18 +699,14 @@ </description> </method> <method name="range_step_decimals"> - <return type="int"> - </return> - <argument index="0" name="x" type="float"> - </argument> + <return type="int" /> + <argument index="0" name="x" type="float" /> <description> </description> </method> <method name="round"> - <return type="float"> - </return> - <argument index="0" name="x" type="float"> - </argument> + <return type="float" /> + <argument index="0" name="x" type="float" /> <description> Rounds [code]x[/code] to the nearest whole number, with halfway cases rounded away from zero. [codeblock] @@ -874,8 +716,7 @@ </description> </method> <method name="seed"> - <argument index="0" name="base" type="int"> - </argument> + <argument index="0" name="base" type="int" /> <description> Sets seed for the random number generator. [codeblock] @@ -885,18 +726,14 @@ </description> </method> <method name="sign"> - <return type="Variant"> - </return> - <argument index="0" name="x" type="Variant"> - </argument> + <return type="Variant" /> + <argument index="0" name="x" type="Variant" /> <description> </description> </method> <method name="signf"> - <return type="float"> - </return> - <argument index="0" name="x" type="float"> - </argument> + <return type="float" /> + <argument index="0" name="x" type="float" /> <description> Returns the sign of [code]x[/code] as a float: -1.0 or 1.0. Returns 0.0 if [code]x[/code] is 0. [codeblock] @@ -907,10 +744,8 @@ </description> </method> <method name="signi"> - <return type="int"> - </return> - <argument index="0" name="x" type="int"> - </argument> + <return type="int" /> + <argument index="0" name="x" type="int" /> <description> Returns the sign of [code]x[/code] as an integer: -1 or 1. Returns 0 if [code]x[/code] is 0. [codeblock] @@ -921,10 +756,8 @@ </description> </method> <method name="sin"> - <return type="float"> - </return> - <argument index="0" name="angle_rad" type="float"> - </argument> + <return type="float" /> + <argument index="0" name="angle_rad" type="float" /> <description> Returns the sine of angle [code]angle_rad[/code] in radians. [codeblock] @@ -933,10 +766,8 @@ </description> </method> <method name="sinh"> - <return type="float"> - </return> - <argument index="0" name="x" type="float"> - </argument> + <return type="float" /> + <argument index="0" name="x" type="float" /> <description> Returns the hyperbolic sine of [code]x[/code]. [codeblock] @@ -946,14 +777,10 @@ </description> </method> <method name="smoothstep"> - <return type="float"> - </return> - <argument index="0" name="from" type="float"> - </argument> - <argument index="1" name="to" type="float"> - </argument> - <argument index="2" name="x" type="float"> - </argument> + <return type="float" /> + <argument index="0" name="from" type="float" /> + <argument index="1" name="to" type="float" /> + <argument index="2" name="x" type="float" /> <description> Returns the result of smoothly interpolating the value of [code]x[/code] between [code]0[/code] and [code]1[/code], based on the where [code]x[/code] lies with respect to the edges [code]from[/code] and [code]to[/code]. The return value is [code]0[/code] if [code]x <= from[/code], and [code]1[/code] if [code]x >= to[/code]. If [code]x[/code] lies between [code]from[/code] and [code]to[/code], the returned value follows an S-shaped curve that maps [code]x[/code] between [code]0[/code] and [code]1[/code]. @@ -967,12 +794,9 @@ </description> </method> <method name="snapped"> - <return type="float"> - </return> - <argument index="0" name="x" type="float"> - </argument> - <argument index="1" name="step" type="float"> - </argument> + <return type="float" /> + <argument index="0" name="x" type="float" /> + <argument index="1" name="step" type="float" /> <description> Snaps float value [code]x[/code] to a given [code]step[/code]. This can also be used to round a floating point number to an arbitrary number of decimals. [codeblock] @@ -983,10 +807,8 @@ </description> </method> <method name="sqrt"> - <return type="float"> - </return> - <argument index="0" name="x" type="float"> - </argument> + <return type="float" /> + <argument index="0" name="x" type="float" /> <description> Returns the square root of [code]x[/code], where [code]x[/code] is a non-negative number. [codeblock] @@ -996,10 +818,8 @@ </description> </method> <method name="step_decimals"> - <return type="int"> - </return> - <argument index="0" name="x" type="float"> - </argument> + <return type="int" /> + <argument index="0" name="x" type="float" /> <description> Returns the position of the first non-zero digit, after the decimal point. Note that the maximum return value is 10, which is a design decision in the implementation. [codeblock] @@ -1013,17 +833,14 @@ </description> </method> <method name="str" qualifiers="vararg"> - <return type="String"> - </return> + <return type="String" /> <description> Converts one or more arguments of any type to string in the best way possible. </description> </method> <method name="str2var"> - <return type="Variant"> - </return> - <argument index="0" name="string" type="String"> - </argument> + <return type="Variant" /> + <argument index="0" name="string" type="String" /> <description> Converts a formatted string that was returned by [method var2str] to the original value. [codeblock] @@ -1034,10 +851,8 @@ </description> </method> <method name="tan"> - <return type="float"> - </return> - <argument index="0" name="angle_rad" type="float"> - </argument> + <return type="float" /> + <argument index="0" name="angle_rad" type="float" /> <description> Returns the tangent of angle [code]angle_rad[/code] in radians. [codeblock] @@ -1046,10 +861,8 @@ </description> </method> <method name="tanh"> - <return type="float"> - </return> - <argument index="0" name="x" type="float"> - </argument> + <return type="float" /> + <argument index="0" name="x" type="float" /> <description> Returns the hyperbolic tangent of [code]x[/code]. [codeblock] @@ -1059,10 +872,8 @@ </description> </method> <method name="typeof"> - <return type="int"> - </return> - <argument index="0" name="variable" type="Variant"> - </argument> + <return type="int" /> + <argument index="0" name="variable" type="Variant" /> <description> Returns the internal type of the given Variant object, using the [enum Variant.Type] values. [codeblock] @@ -1077,29 +888,23 @@ </description> </method> <method name="var2bytes"> - <return type="PackedByteArray"> - </return> - <argument index="0" name="variable" type="Variant"> - </argument> + <return type="PackedByteArray" /> + <argument index="0" name="variable" type="Variant" /> <description> Encodes a [Variant] value to a byte array, without encoding objects. Deserialization can be done with [method bytes2var]. [b]Note:[/b] If you need object serialization, see [method var2bytes_with_objects]. </description> </method> <method name="var2bytes_with_objects"> - <return type="PackedByteArray"> - </return> - <argument index="0" name="variable" type="Variant"> - </argument> + <return type="PackedByteArray" /> + <argument index="0" name="variable" type="Variant" /> <description> Encodes a [Variant] value to a byte array. Encoding objects is allowed (and can potentially include code). Deserialization can be done with [method bytes2var_with_objects]. </description> </method> <method name="var2str"> - <return type="String"> - </return> - <argument index="0" name="variable" type="Variant"> - </argument> + <return type="String" /> + <argument index="0" name="variable" type="Variant" /> <description> Converts a Variant [code]variable[/code] to a formatted string that can later be parsed using [method str2var]. [codeblock] @@ -1116,24 +921,18 @@ </description> </method> <method name="weakref"> - <return type="Variant"> - </return> - <argument index="0" name="obj" type="Variant"> - </argument> + <return type="Variant" /> + <argument index="0" name="obj" type="Variant" /> <description> Returns a weak reference to an object, or [code]null[/code] is the argument is invalid. A weak reference to an object is not enough to keep the object alive: when the only remaining references to a referent are weak references, garbage collection is free to destroy the referent and reuse its memory for something else. However, until the object is actually destroyed the weak reference may return the object even if there are no strong references to it. </description> </method> <method name="wrapf"> - <return type="float"> - </return> - <argument index="0" name="value" type="float"> - </argument> - <argument index="1" name="min" type="float"> - </argument> - <argument index="2" name="max" type="float"> - </argument> + <return type="float" /> + <argument index="0" name="value" type="float" /> + <argument index="1" name="min" type="float" /> + <argument index="2" name="max" type="float" /> <description> Wraps float [code]value[/code] between [code]min[/code] and [code]max[/code]. Usable for creating loop-alike behavior or infinite surfaces. @@ -1154,14 +953,10 @@ </description> </method> <method name="wrapi"> - <return type="int"> - </return> - <argument index="0" name="value" type="int"> - </argument> - <argument index="1" name="min" type="int"> - </argument> - <argument index="2" name="max" type="int"> - </argument> + <return type="int" /> + <argument index="0" name="value" type="int" /> + <argument index="1" name="min" type="int" /> + <argument index="2" name="max" type="int" /> <description> Wraps integer [code]value[/code] between [code]min[/code] and [code]max[/code]. Usable for creating loop-alike behavior or infinite surfaces. @@ -1259,6 +1054,8 @@ <member name="ResourceSaver" type="ResourceSaver" setter="" getter=""> The [ResourceSaver] singleton. </member> + <member name="ResourceUID" type="ResourceUID" setter="" getter=""> + </member> <member name="TextServerManager" type="TextServerManager" setter="" getter=""> The [TextServerManager] singleton. </member> diff --git a/doc/classes/AABB.xml b/doc/classes/AABB.xml index 03607661df..4bc11e7166 100644 --- a/doc/classes/AABB.xml +++ b/doc/classes/AABB.xml @@ -15,243 +15,193 @@ </tutorials> <methods> <method name="AABB" qualifiers="constructor"> - <return type="AABB"> - </return> + <return type="AABB" /> <description> Constructs a default-initialized [AABB] with default (zero) values of [member position] and [member size]. </description> </method> <method name="AABB" qualifiers="constructor"> - <return type="AABB"> - </return> - <argument index="0" name="from" type="AABB"> - </argument> + <return type="AABB" /> + <argument index="0" name="from" type="AABB" /> <description> Constructs an [AABB] as a copy of the given [AABB]. </description> </method> <method name="AABB" qualifiers="constructor"> - <return type="AABB"> - </return> - <argument index="0" name="position" type="Vector3"> - </argument> - <argument index="1" name="size" type="Vector3"> - </argument> + <return type="AABB" /> + <argument index="0" name="position" type="Vector3" /> + <argument index="1" name="size" type="Vector3" /> <description> Constructs an [AABB] from a position and size. </description> </method> <method name="abs" qualifiers="const"> - <return type="AABB"> - </return> + <return type="AABB" /> <description> Returns an AABB with equivalent position and size, modified so that the most-negative corner is the origin and the size is positive. </description> </method> <method name="encloses" qualifiers="const"> - <return type="bool"> - </return> - <argument index="0" name="with" type="AABB"> - </argument> + <return type="bool" /> + <argument index="0" name="with" type="AABB" /> <description> Returns [code]true[/code] if this [AABB] completely encloses another one. </description> </method> <method name="expand" qualifiers="const"> - <return type="AABB"> - </return> - <argument index="0" name="to_point" type="Vector3"> - </argument> + <return type="AABB" /> + <argument index="0" name="to_point" type="Vector3" /> <description> Returns this [AABB] expanded to include a given point. </description> </method> <method name="get_area" qualifiers="const"> - <return type="float"> - </return> + <return type="float" /> <description> Returns the volume of the [AABB]. </description> </method> <method name="get_endpoint" qualifiers="const"> - <return type="Vector3"> - </return> - <argument index="0" name="idx" type="int"> - </argument> + <return type="Vector3" /> + <argument index="0" name="idx" type="int" /> <description> Gets the position of the 8 endpoints of the [AABB] in space. </description> </method> <method name="get_longest_axis" qualifiers="const"> - <return type="Vector3"> - </return> + <return type="Vector3" /> <description> Returns the normalized longest axis of the [AABB]. </description> </method> <method name="get_longest_axis_index" qualifiers="const"> - <return type="int"> - </return> + <return type="int" /> <description> Returns the index of the longest axis of the [AABB] (according to [Vector3]'s [code]AXIS_*[/code] constants). </description> </method> <method name="get_longest_axis_size" qualifiers="const"> - <return type="float"> - </return> + <return type="float" /> <description> Returns the scalar length of the longest axis of the [AABB]. </description> </method> <method name="get_shortest_axis" qualifiers="const"> - <return type="Vector3"> - </return> + <return type="Vector3" /> <description> Returns the normalized shortest axis of the [AABB]. </description> </method> <method name="get_shortest_axis_index" qualifiers="const"> - <return type="int"> - </return> + <return type="int" /> <description> Returns the index of the shortest axis of the [AABB] (according to [Vector3]::AXIS* enum). </description> </method> <method name="get_shortest_axis_size" qualifiers="const"> - <return type="float"> - </return> + <return type="float" /> <description> Returns the scalar length of the shortest axis of the [AABB]. </description> </method> <method name="get_support" qualifiers="const"> - <return type="Vector3"> - </return> - <argument index="0" name="dir" type="Vector3"> - </argument> + <return type="Vector3" /> + <argument index="0" name="dir" type="Vector3" /> <description> Returns the support point in a given direction. This is useful for collision detection algorithms. </description> </method> <method name="grow" qualifiers="const"> - <return type="AABB"> - </return> - <argument index="0" name="by" type="float"> - </argument> + <return type="AABB" /> + <argument index="0" name="by" type="float" /> <description> Returns a copy of the [AABB] grown a given amount of units towards all the sides. </description> </method> <method name="has_no_area" qualifiers="const"> - <return type="bool"> - </return> + <return type="bool" /> <description> Returns [code]true[/code] if the [AABB] is flat or empty. </description> </method> <method name="has_no_surface" qualifiers="const"> - <return type="bool"> - </return> + <return type="bool" /> <description> Returns [code]true[/code] if the [AABB] is empty. </description> </method> <method name="has_point" qualifiers="const"> - <return type="bool"> - </return> - <argument index="0" name="point" type="Vector3"> - </argument> + <return type="bool" /> + <argument index="0" name="point" type="Vector3" /> <description> Returns [code]true[/code] if the [AABB] contains a point. </description> </method> <method name="intersection" qualifiers="const"> - <return type="AABB"> - </return> - <argument index="0" name="with" type="AABB"> - </argument> + <return type="AABB" /> + <argument index="0" name="with" type="AABB" /> <description> Returns the intersection between two [AABB]. An empty AABB (size 0,0,0) is returned on failure. </description> </method> <method name="intersects" qualifiers="const"> - <return type="bool"> - </return> - <argument index="0" name="with" type="AABB"> - </argument> + <return type="bool" /> + <argument index="0" name="with" type="AABB" /> <description> Returns [code]true[/code] if the [AABB] overlaps with another. </description> </method> <method name="intersects_plane" qualifiers="const"> - <return type="bool"> - </return> - <argument index="0" name="plane" type="Plane"> - </argument> + <return type="bool" /> + <argument index="0" name="plane" type="Plane" /> <description> Returns [code]true[/code] if the [AABB] is on both sides of a plane. </description> </method> <method name="intersects_ray" qualifiers="const"> - <return type="Variant"> - </return> - <argument index="0" name="from" type="Vector3"> - </argument> - <argument index="1" name="dir" type="Vector3"> - </argument> + <return type="Variant" /> + <argument index="0" name="from" type="Vector3" /> + <argument index="1" name="dir" type="Vector3" /> <description> </description> </method> <method name="intersects_segment" qualifiers="const"> - <return type="Variant"> - </return> - <argument index="0" name="from" type="Vector3"> - </argument> - <argument index="1" name="to" type="Vector3"> - </argument> + <return type="Variant" /> + <argument index="0" name="from" type="Vector3" /> + <argument index="1" name="to" type="Vector3" /> <description> Returns [code]true[/code] if the [AABB] intersects the line segment between [code]from[/code] and [code]to[/code]. </description> </method> <method name="is_equal_approx" qualifiers="const"> - <return type="bool"> - </return> - <argument index="0" name="aabb" type="AABB"> - </argument> + <return type="bool" /> + <argument index="0" name="aabb" type="AABB" /> <description> Returns [code]true[/code] if this [AABB] and [code]aabb[/code] are approximately equal, by calling [method @GlobalScope.is_equal_approx] on each component. </description> </method> <method name="merge" qualifiers="const"> - <return type="AABB"> - </return> - <argument index="0" name="with" type="AABB"> - </argument> + <return type="AABB" /> + <argument index="0" name="with" type="AABB" /> <description> Returns a larger [AABB] that contains both this [AABB] and [code]with[/code]. </description> </method> <method name="operator !=" qualifiers="operator"> - <return type="bool"> - </return> - <argument index="0" name="right" type="AABB"> - </argument> + <return type="bool" /> + <argument index="0" name="right" type="AABB" /> <description> </description> </method> <method name="operator *" qualifiers="operator"> - <return type="AABB"> - </return> - <argument index="0" name="right" type="Transform3D"> - </argument> + <return type="AABB" /> + <argument index="0" name="right" type="Transform3D" /> <description> </description> </method> <method name="operator ==" qualifiers="operator"> - <return type="bool"> - </return> - <argument index="0" name="right" type="AABB"> - </argument> + <return type="bool" /> + <argument index="0" name="right" type="AABB" /> <description> </description> </method> diff --git a/doc/classes/AESContext.xml b/doc/classes/AESContext.xml index e179c97677..847d1226a2 100644 --- a/doc/classes/AESContext.xml +++ b/doc/classes/AESContext.xml @@ -80,38 +80,30 @@ </tutorials> <methods> <method name="finish"> - <return type="void"> - </return> + <return type="void" /> <description> Close this AES context so it can be started again. See [method start]. </description> </method> <method name="get_iv_state"> - <return type="PackedByteArray"> - </return> + <return type="PackedByteArray" /> <description> Get the current IV state for this context (IV gets updated when calling [method update]). You normally don't need this function. Note: This function only makes sense when the context is started with [constant MODE_CBC_ENCRYPT] or [constant MODE_CBC_DECRYPT]. </description> </method> <method name="start"> - <return type="int" enum="Error"> - </return> - <argument index="0" name="mode" type="int" enum="AESContext.Mode"> - </argument> - <argument index="1" name="key" type="PackedByteArray"> - </argument> - <argument index="2" name="iv" type="PackedByteArray" default="PackedByteArray()"> - </argument> + <return type="int" enum="Error" /> + <argument index="0" name="mode" type="int" enum="AESContext.Mode" /> + <argument index="1" name="key" type="PackedByteArray" /> + <argument index="2" name="iv" type="PackedByteArray" default="PackedByteArray()" /> <description> Start the AES context in the given [code]mode[/code]. A [code]key[/code] of either 16 or 32 bytes must always be provided, while an [code]iv[/code] (initialization vector) of exactly 16 bytes, is only needed when [code]mode[/code] is either [constant MODE_CBC_ENCRYPT] or [constant MODE_CBC_DECRYPT]. </description> </method> <method name="update"> - <return type="PackedByteArray"> - </return> - <argument index="0" name="src" type="PackedByteArray"> - </argument> + <return type="PackedByteArray" /> + <argument index="0" name="src" type="PackedByteArray" /> <description> Run the desired operation for this AES context. Will return a [PackedByteArray] containing the result of encrypting (or decrypting) the given [code]src[/code]. See [method start] for mode of operation. Note: The size of [code]src[/code] must be a multiple of 16. Apply some padding if needed. diff --git a/doc/classes/AStar.xml b/doc/classes/AStar.xml index cc7f7072b9..63dd250dbc 100644 --- a/doc/classes/AStar.xml +++ b/doc/classes/AStar.xml @@ -33,44 +33,34 @@ [/csharp] [/codeblocks] [method _estimate_cost] should return a lower bound of the distance, i.e. [code]_estimate_cost(u, v) <= _compute_cost(u, v)[/code]. This serves as a hint to the algorithm because the custom [code]_compute_cost[/code] might be computation-heavy. If this is not the case, make [method _estimate_cost] return the same value as [method _compute_cost] to provide the algorithm with the most accurate information. - If the default [method _estimate_cost] and [method _compute_cost] methods are used, or if the supplied [method _estimate_cost] method returns a lower bound of the cost, then the paths returned by A* will be the lowest cost paths. Here, the cost of a path equals to the sum of the [method _compute_cost] results of all segments in the path multiplied by the [code]weight_scale[/code]s of the end points of the respective segments. If the default methods are used and the [code]weight_scale[/code]s of all points are set to [code]1.0[/code], then this equals to the sum of Euclidean distances of all segments in the path. + If the default [method _estimate_cost] and [method _compute_cost] methods are used, or if the supplied [method _estimate_cost] method returns a lower bound of the cost, then the paths returned by A* will be the lowest-cost paths. Here, the cost of a path equals the sum of the [method _compute_cost] results of all segments in the path multiplied by the [code]weight_scale[/code]s of the endpoints of the respective segments. If the default methods are used and the [code]weight_scale[/code]s of all points are set to [code]1.0[/code], then this equals the sum of Euclidean distances of all segments in the path. </description> <tutorials> </tutorials> <methods> <method name="_compute_cost" qualifiers="virtual"> - <return type="float"> - </return> - <argument index="0" name="from_id" type="int"> - </argument> - <argument index="1" name="to_id" type="int"> - </argument> + <return type="float" /> + <argument index="0" name="from_id" type="int" /> + <argument index="1" name="to_id" type="int" /> <description> Called when computing the cost between two connected points. Note that this function is hidden in the default [code]AStar[/code] class. </description> </method> <method name="_estimate_cost" qualifiers="virtual"> - <return type="float"> - </return> - <argument index="0" name="from_id" type="int"> - </argument> - <argument index="1" name="to_id" type="int"> - </argument> + <return type="float" /> + <argument index="0" name="from_id" type="int" /> + <argument index="1" name="to_id" type="int" /> <description> Called when estimating the cost between a point and the path's ending point. Note that this function is hidden in the default [code]AStar[/code] class. </description> </method> <method name="add_point"> - <return type="void"> - </return> - <argument index="0" name="id" type="int"> - </argument> - <argument index="1" name="position" type="Vector3"> - </argument> - <argument index="2" name="weight_scale" type="float" default="1.0"> - </argument> + <return type="void" /> + <argument index="0" name="id" type="int" /> + <argument index="1" name="position" type="Vector3" /> + <argument index="2" name="weight_scale" type="float" default="1.0" /> <description> Adds a new point at the given position with the given identifier. The [code]id[/code] must be 0 or larger, and the [code]weight_scale[/code] must be 1 or larger. The [code]weight_scale[/code] is multiplied by the result of [method _compute_cost] when determining the overall cost of traveling across a segment from a neighboring point to this point. Thus, all else being equal, the algorithm prefers points with lower [code]weight_scale[/code]s to form a path. @@ -88,34 +78,25 @@ </description> </method> <method name="are_points_connected" qualifiers="const"> - <return type="bool"> - </return> - <argument index="0" name="id" type="int"> - </argument> - <argument index="1" name="to_id" type="int"> - </argument> - <argument index="2" name="bidirectional" type="bool" default="true"> - </argument> + <return type="bool" /> + <argument index="0" name="id" type="int" /> + <argument index="1" name="to_id" type="int" /> + <argument index="2" name="bidirectional" type="bool" default="true" /> <description> Returns whether the two given points are directly connected by a segment. If [code]bidirectional[/code] is [code]false[/code], returns whether movement from [code]id[/code] to [code]to_id[/code] is possible through this segment. </description> </method> <method name="clear"> - <return type="void"> - </return> + <return type="void" /> <description> Clears all the points and segments. </description> </method> <method name="connect_points"> - <return type="void"> - </return> - <argument index="0" name="id" type="int"> - </argument> - <argument index="1" name="to_id" type="int"> - </argument> - <argument index="2" name="bidirectional" type="bool" default="true"> - </argument> + <return type="void" /> + <argument index="0" name="id" type="int" /> + <argument index="1" name="to_id" type="int" /> + <argument index="2" name="bidirectional" type="bool" default="true" /> <description> Creates a segment between the given points. If [code]bidirectional[/code] is [code]false[/code], only movement from [code]id[/code] to [code]to_id[/code] is allowed, not the reverse direction. [codeblocks] @@ -135,42 +116,32 @@ </description> </method> <method name="disconnect_points"> - <return type="void"> - </return> - <argument index="0" name="id" type="int"> - </argument> - <argument index="1" name="to_id" type="int"> - </argument> - <argument index="2" name="bidirectional" type="bool" default="true"> - </argument> + <return type="void" /> + <argument index="0" name="id" type="int" /> + <argument index="1" name="to_id" type="int" /> + <argument index="2" name="bidirectional" type="bool" default="true" /> <description> Deletes the segment between the given points. If [code]bidirectional[/code] is [code]false[/code], only movement from [code]id[/code] to [code]to_id[/code] is prevented, and a unidirectional segment possibly remains. </description> </method> <method name="get_available_point_id" qualifiers="const"> - <return type="int"> - </return> + <return type="int" /> <description> Returns the next available point ID with no point associated to it. </description> </method> <method name="get_closest_point" qualifiers="const"> - <return type="int"> - </return> - <argument index="0" name="to_position" type="Vector3"> - </argument> - <argument index="1" name="include_disabled" type="bool" default="false"> - </argument> + <return type="int" /> + <argument index="0" name="to_position" type="Vector3" /> + <argument index="1" name="include_disabled" type="bool" default="false" /> <description> Returns the ID of the closest point to [code]to_position[/code], optionally taking disabled points into account. Returns [code]-1[/code] if there are no points in the points pool. [b]Note:[/b] If several points are the closest to [code]to_position[/code], the one with the smallest ID will be returned, ensuring a deterministic result. </description> </method> <method name="get_closest_position_in_segment" qualifiers="const"> - <return type="Vector3"> - </return> - <argument index="0" name="to_position" type="Vector3"> - </argument> + <return type="Vector3" /> + <argument index="0" name="to_position" type="Vector3" /> <description> Returns the closest position to [code]to_position[/code] that resides inside a segment between two connected points. [codeblocks] @@ -193,12 +164,9 @@ </description> </method> <method name="get_id_path"> - <return type="PackedInt32Array"> - </return> - <argument index="0" name="from_id" type="int"> - </argument> - <argument index="1" name="to_id" type="int"> - </argument> + <return type="PackedInt32Array" /> + <argument index="0" name="from_id" type="int" /> + <argument index="1" name="to_id" type="int" /> <description> Returns an array with the IDs of the points that form the path found by AStar between the given points. The array is ordered from the starting point to the ending point of the path. [codeblocks] @@ -233,17 +201,14 @@ </description> </method> <method name="get_point_capacity" qualifiers="const"> - <return type="int"> - </return> + <return type="int" /> <description> Returns the capacity of the structure backing the points, useful in conjunction with [code]reserve_space[/code]. </description> </method> <method name="get_point_connections"> - <return type="PackedInt32Array"> - </return> - <argument index="0" name="id" type="int"> - </argument> + <return type="PackedInt32Array" /> + <argument index="0" name="id" type="int" /> <description> Returns an array with the IDs of the points that form the connection with the given point. [codeblocks] @@ -274,114 +239,88 @@ </description> </method> <method name="get_point_count" qualifiers="const"> - <return type="int"> - </return> + <return type="int" /> <description> Returns the number of points currently in the points pool. </description> </method> <method name="get_point_path"> - <return type="PackedVector3Array"> - </return> - <argument index="0" name="from_id" type="int"> - </argument> - <argument index="1" name="to_id" type="int"> - </argument> + <return type="PackedVector3Array" /> + <argument index="0" name="from_id" type="int" /> + <argument index="1" name="to_id" type="int" /> <description> Returns an array with the points that are in the path found by AStar between the given points. The array is ordered from the starting point to the ending point of the path. [b]Note:[/b] This method is not thread-safe. If called from a [Thread], it will return an empty [PackedVector3Array] and will print an error message. </description> </method> <method name="get_point_position" qualifiers="const"> - <return type="Vector3"> - </return> - <argument index="0" name="id" type="int"> - </argument> + <return type="Vector3" /> + <argument index="0" name="id" type="int" /> <description> Returns the position of the point associated with the given [code]id[/code]. </description> </method> <method name="get_point_weight_scale" qualifiers="const"> - <return type="float"> - </return> - <argument index="0" name="id" type="int"> - </argument> + <return type="float" /> + <argument index="0" name="id" type="int" /> <description> Returns the weight scale of the point associated with the given [code]id[/code]. </description> </method> <method name="get_points"> - <return type="Array"> - </return> + <return type="Array" /> <description> Returns an array of all points. </description> </method> <method name="has_point" qualifiers="const"> - <return type="bool"> - </return> - <argument index="0" name="id" type="int"> - </argument> + <return type="bool" /> + <argument index="0" name="id" type="int" /> <description> Returns whether a point associated with the given [code]id[/code] exists. </description> </method> <method name="is_point_disabled" qualifiers="const"> - <return type="bool"> - </return> - <argument index="0" name="id" type="int"> - </argument> + <return type="bool" /> + <argument index="0" name="id" type="int" /> <description> Returns whether a point is disabled or not for pathfinding. By default, all points are enabled. </description> </method> <method name="remove_point"> - <return type="void"> - </return> - <argument index="0" name="id" type="int"> - </argument> + <return type="void" /> + <argument index="0" name="id" type="int" /> <description> Removes the point associated with the given [code]id[/code] from the points pool. </description> </method> <method name="reserve_space"> - <return type="void"> - </return> - <argument index="0" name="num_nodes" type="int"> - </argument> + <return type="void" /> + <argument index="0" name="num_nodes" type="int" /> <description> Reserves space internally for [code]num_nodes[/code] points, useful if you're adding a known large number of points at once, for a grid for instance. New capacity must be greater or equals to old capacity. </description> </method> <method name="set_point_disabled"> - <return type="void"> - </return> - <argument index="0" name="id" type="int"> - </argument> - <argument index="1" name="disabled" type="bool" default="true"> - </argument> + <return type="void" /> + <argument index="0" name="id" type="int" /> + <argument index="1" name="disabled" type="bool" default="true" /> <description> Disables or enables the specified point for pathfinding. Useful for making a temporary obstacle. </description> </method> <method name="set_point_position"> - <return type="void"> - </return> - <argument index="0" name="id" type="int"> - </argument> - <argument index="1" name="position" type="Vector3"> - </argument> + <return type="void" /> + <argument index="0" name="id" type="int" /> + <argument index="1" name="position" type="Vector3" /> <description> Sets the [code]position[/code] for the point with the given [code]id[/code]. </description> </method> <method name="set_point_weight_scale"> - <return type="void"> - </return> - <argument index="0" name="id" type="int"> - </argument> - <argument index="1" name="weight_scale" type="float"> - </argument> + <return type="void" /> + <argument index="0" name="id" type="int" /> + <argument index="1" name="weight_scale" type="float" /> <description> Sets the [code]weight_scale[/code] for the point with the given [code]id[/code]. The [code]weight_scale[/code] is multiplied by the result of [method _compute_cost] when determining the overall cost of traveling across a segment from a neighboring point to this point. </description> diff --git a/doc/classes/AStar2D.xml b/doc/classes/AStar2D.xml index 9edc300169..31d695b051 100644 --- a/doc/classes/AStar2D.xml +++ b/doc/classes/AStar2D.xml @@ -10,38 +10,28 @@ </tutorials> <methods> <method name="_compute_cost" qualifiers="virtual"> - <return type="float"> - </return> - <argument index="0" name="from_id" type="int"> - </argument> - <argument index="1" name="to_id" type="int"> - </argument> + <return type="float" /> + <argument index="0" name="from_id" type="int" /> + <argument index="1" name="to_id" type="int" /> <description> Called when computing the cost between two connected points. Note that this function is hidden in the default [code]AStar2D[/code] class. </description> </method> <method name="_estimate_cost" qualifiers="virtual"> - <return type="float"> - </return> - <argument index="0" name="from_id" type="int"> - </argument> - <argument index="1" name="to_id" type="int"> - </argument> + <return type="float" /> + <argument index="0" name="from_id" type="int" /> + <argument index="1" name="to_id" type="int" /> <description> Called when estimating the cost between a point and the path's ending point. Note that this function is hidden in the default [code]AStar2D[/code] class. </description> </method> <method name="add_point"> - <return type="void"> - </return> - <argument index="0" name="id" type="int"> - </argument> - <argument index="1" name="position" type="Vector2"> - </argument> - <argument index="2" name="weight_scale" type="float" default="1.0"> - </argument> + <return type="void" /> + <argument index="0" name="id" type="int" /> + <argument index="1" name="position" type="Vector2" /> + <argument index="2" name="weight_scale" type="float" default="1.0" /> <description> Adds a new point at the given position with the given identifier. The [code]id[/code] must be 0 or larger, and the [code]weight_scale[/code] must be 1 or larger. The [code]weight_scale[/code] is multiplied by the result of [method _compute_cost] when determining the overall cost of traveling across a segment from a neighboring point to this point. Thus, all else being equal, the algorithm prefers points with lower [code]weight_scale[/code]s to form a path. @@ -59,32 +49,24 @@ </description> </method> <method name="are_points_connected" qualifiers="const"> - <return type="bool"> - </return> - <argument index="0" name="id" type="int"> - </argument> - <argument index="1" name="to_id" type="int"> - </argument> + <return type="bool" /> + <argument index="0" name="id" type="int" /> + <argument index="1" name="to_id" type="int" /> <description> Returns whether there is a connection/segment between the given points. </description> </method> <method name="clear"> - <return type="void"> - </return> + <return type="void" /> <description> Clears all the points and segments. </description> </method> <method name="connect_points"> - <return type="void"> - </return> - <argument index="0" name="id" type="int"> - </argument> - <argument index="1" name="to_id" type="int"> - </argument> - <argument index="2" name="bidirectional" type="bool" default="true"> - </argument> + <return type="void" /> + <argument index="0" name="id" type="int" /> + <argument index="1" name="to_id" type="int" /> + <argument index="2" name="bidirectional" type="bool" default="true" /> <description> Creates a segment between the given points. If [code]bidirectional[/code] is [code]false[/code], only movement from [code]id[/code] to [code]to_id[/code] is allowed, not the reverse direction. [codeblocks] @@ -104,40 +86,31 @@ </description> </method> <method name="disconnect_points"> - <return type="void"> - </return> - <argument index="0" name="id" type="int"> - </argument> - <argument index="1" name="to_id" type="int"> - </argument> + <return type="void" /> + <argument index="0" name="id" type="int" /> + <argument index="1" name="to_id" type="int" /> <description> Deletes the segment between the given points. </description> </method> <method name="get_available_point_id" qualifiers="const"> - <return type="int"> - </return> + <return type="int" /> <description> Returns the next available point ID with no point associated to it. </description> </method> <method name="get_closest_point" qualifiers="const"> - <return type="int"> - </return> - <argument index="0" name="to_position" type="Vector2"> - </argument> - <argument index="1" name="include_disabled" type="bool" default="false"> - </argument> + <return type="int" /> + <argument index="0" name="to_position" type="Vector2" /> + <argument index="1" name="include_disabled" type="bool" default="false" /> <description> Returns the ID of the closest point to [code]to_position[/code], optionally taking disabled points into account. Returns [code]-1[/code] if there are no points in the points pool. [b]Note:[/b] If several points are the closest to [code]to_position[/code], the one with the smallest ID will be returned, ensuring a deterministic result. </description> </method> <method name="get_closest_position_in_segment" qualifiers="const"> - <return type="Vector2"> - </return> - <argument index="0" name="to_position" type="Vector2"> - </argument> + <return type="Vector2" /> + <argument index="0" name="to_position" type="Vector2" /> <description> Returns the closest position to [code]to_position[/code] that resides inside a segment between two connected points. [codeblocks] @@ -160,12 +133,9 @@ </description> </method> <method name="get_id_path"> - <return type="PackedInt32Array"> - </return> - <argument index="0" name="from_id" type="int"> - </argument> - <argument index="1" name="to_id" type="int"> - </argument> + <return type="PackedInt32Array" /> + <argument index="0" name="from_id" type="int" /> + <argument index="1" name="to_id" type="int" /> <description> Returns an array with the IDs of the points that form the path found by AStar2D between the given points. The array is ordered from the starting point to the ending point of the path. [codeblocks] @@ -201,17 +171,14 @@ </description> </method> <method name="get_point_capacity" qualifiers="const"> - <return type="int"> - </return> + <return type="int" /> <description> Returns the capacity of the structure backing the points, useful in conjunction with [code]reserve_space[/code]. </description> </method> <method name="get_point_connections"> - <return type="PackedInt32Array"> - </return> - <argument index="0" name="id" type="int"> - </argument> + <return type="PackedInt32Array" /> + <argument index="0" name="id" type="int" /> <description> Returns an array with the IDs of the points that form the connection with the given point. [codeblocks] @@ -243,114 +210,88 @@ </description> </method> <method name="get_point_count" qualifiers="const"> - <return type="int"> - </return> + <return type="int" /> <description> Returns the number of points currently in the points pool. </description> </method> <method name="get_point_path"> - <return type="PackedVector2Array"> - </return> - <argument index="0" name="from_id" type="int"> - </argument> - <argument index="1" name="to_id" type="int"> - </argument> + <return type="PackedVector2Array" /> + <argument index="0" name="from_id" type="int" /> + <argument index="1" name="to_id" type="int" /> <description> Returns an array with the points that are in the path found by AStar2D between the given points. The array is ordered from the starting point to the ending point of the path. [b]Note:[/b] This method is not thread-safe. If called from a [Thread], it will return an empty [PackedVector2Array] and will print an error message. </description> </method> <method name="get_point_position" qualifiers="const"> - <return type="Vector2"> - </return> - <argument index="0" name="id" type="int"> - </argument> + <return type="Vector2" /> + <argument index="0" name="id" type="int" /> <description> Returns the position of the point associated with the given [code]id[/code]. </description> </method> <method name="get_point_weight_scale" qualifiers="const"> - <return type="float"> - </return> - <argument index="0" name="id" type="int"> - </argument> + <return type="float" /> + <argument index="0" name="id" type="int" /> <description> Returns the weight scale of the point associated with the given [code]id[/code]. </description> </method> <method name="get_points"> - <return type="Array"> - </return> + <return type="Array" /> <description> Returns an array of all points. </description> </method> <method name="has_point" qualifiers="const"> - <return type="bool"> - </return> - <argument index="0" name="id" type="int"> - </argument> + <return type="bool" /> + <argument index="0" name="id" type="int" /> <description> Returns whether a point associated with the given [code]id[/code] exists. </description> </method> <method name="is_point_disabled" qualifiers="const"> - <return type="bool"> - </return> - <argument index="0" name="id" type="int"> - </argument> + <return type="bool" /> + <argument index="0" name="id" type="int" /> <description> Returns whether a point is disabled or not for pathfinding. By default, all points are enabled. </description> </method> <method name="remove_point"> - <return type="void"> - </return> - <argument index="0" name="id" type="int"> - </argument> + <return type="void" /> + <argument index="0" name="id" type="int" /> <description> Removes the point associated with the given [code]id[/code] from the points pool. </description> </method> <method name="reserve_space"> - <return type="void"> - </return> - <argument index="0" name="num_nodes" type="int"> - </argument> + <return type="void" /> + <argument index="0" name="num_nodes" type="int" /> <description> Reserves space internally for [code]num_nodes[/code] points, useful if you're adding a known large number of points at once, for a grid for instance. New capacity must be greater or equals to old capacity. </description> </method> <method name="set_point_disabled"> - <return type="void"> - </return> - <argument index="0" name="id" type="int"> - </argument> - <argument index="1" name="disabled" type="bool" default="true"> - </argument> + <return type="void" /> + <argument index="0" name="id" type="int" /> + <argument index="1" name="disabled" type="bool" default="true" /> <description> Disables or enables the specified point for pathfinding. Useful for making a temporary obstacle. </description> </method> <method name="set_point_position"> - <return type="void"> - </return> - <argument index="0" name="id" type="int"> - </argument> - <argument index="1" name="position" type="Vector2"> - </argument> + <return type="void" /> + <argument index="0" name="id" type="int" /> + <argument index="1" name="position" type="Vector2" /> <description> Sets the [code]position[/code] for the point with the given [code]id[/code]. </description> </method> <method name="set_point_weight_scale"> - <return type="void"> - </return> - <argument index="0" name="id" type="int"> - </argument> - <argument index="1" name="weight_scale" type="float"> - </argument> + <return type="void" /> + <argument index="0" name="id" type="int" /> + <argument index="1" name="weight_scale" type="float" /> <description> Sets the [code]weight_scale[/code] for the point with the given [code]id[/code]. The [code]weight_scale[/code] is multiplied by the result of [method _compute_cost] when determining the overall cost of traveling across a segment from a neighboring point to this point. </description> diff --git a/doc/classes/AcceptDialog.xml b/doc/classes/AcceptDialog.xml index fd1e2ba104..868ec5a774 100644 --- a/doc/classes/AcceptDialog.xml +++ b/doc/classes/AcceptDialog.xml @@ -10,14 +10,10 @@ </tutorials> <methods> <method name="add_button"> - <return type="Button"> - </return> - <argument index="0" name="text" type="String"> - </argument> - <argument index="1" name="right" type="bool" default="false"> - </argument> - <argument index="2" name="action" type="String" default=""""> - </argument> + <return type="Button" /> + <argument index="0" name="text" type="String" /> + <argument index="1" name="right" type="bool" default="false" /> + <argument index="2" name="action" type="String" default="""" /> <description> Adds a button with label [code]text[/code] and a custom [code]action[/code] to the dialog and returns the created button. [code]action[/code] will be passed to the [signal custom_action] signal when pressed. If [code]true[/code], [code]right[/code] will place the button to the right of any sibling buttons. @@ -25,43 +21,35 @@ </description> </method> <method name="add_cancel_button"> - <return type="Button"> - </return> - <argument index="0" name="name" type="String"> - </argument> + <return type="Button" /> + <argument index="0" name="name" type="String" /> <description> Adds a button with label [code]name[/code] and a cancel action to the dialog and returns the created button. You can use [method remove_button] method to remove a button created with this method from the dialog. </description> </method> <method name="get_label"> - <return type="Label"> - </return> + <return type="Label" /> <description> Returns the label used for built-in text. </description> </method> <method name="get_ok_button"> - <return type="Button"> - </return> + <return type="Button" /> <description> Returns the OK [Button] instance. </description> </method> <method name="register_text_enter"> - <return type="void"> - </return> - <argument index="0" name="line_edit" type="Control"> - </argument> + <return type="void" /> + <argument index="0" name="line_edit" type="Control" /> <description> Registers a [LineEdit] in the dialog. When the enter key is pressed, the dialog will be accepted. </description> </method> <method name="remove_button"> - <return type="void"> - </return> - <argument index="0" name="button" type="Control"> - </argument> + <return type="void" /> + <argument index="0" name="button" type="Control" /> <description> Removes the [code]button[/code] from the dialog. Does NOT free the [code]button[/code]. The [code]button[/code] must be a [Button] added with [method add_button] or [method add_cancel_button] method. After removal, pressing the [code]button[/code] will no longer emit this dialog's [signal custom_action] or [signal cancelled] signals. </description> @@ -96,8 +84,7 @@ </description> </signal> <signal name="custom_action"> - <argument index="0" name="action" type="StringName"> - </argument> + <argument index="0" name="action" type="StringName" /> <description> Emitted when a custom button is pressed. See [method add_button]. </description> @@ -105,4 +92,9 @@ </signals> <constants> </constants> + <theme_items> + <theme_item name="panel" type="StyleBox"> + Panel that fills up the background of the window. + </theme_item> + </theme_items> </class> diff --git a/doc/classes/AnimatedSprite2D.xml b/doc/classes/AnimatedSprite2D.xml index 7662e8368b..14e19b4c9a 100644 --- a/doc/classes/AnimatedSprite2D.xml +++ b/doc/classes/AnimatedSprite2D.xml @@ -13,26 +13,21 @@ </tutorials> <methods> <method name="is_playing" qualifiers="const"> - <return type="bool"> - </return> + <return type="bool" /> <description> Returns [code]true[/code] if an animation is currently being played. </description> </method> <method name="play"> - <return type="void"> - </return> - <argument index="0" name="anim" type="StringName" default="&"""> - </argument> - <argument index="1" name="backwards" type="bool" default="false"> - </argument> + <return type="void" /> + <argument index="0" name="anim" type="StringName" default="&""" /> + <argument index="1" name="backwards" type="bool" default="false" /> <description> Plays the animation named [code]anim[/code]. If no [code]anim[/code] is provided, the current animation is played. If [code]backwards[/code] is [code]true[/code], the animation will be played in reverse. </description> </method> <method name="stop"> - <return type="void"> - </return> + <return type="void" /> <description> Stops the current animation (does not reset the frame counter). </description> diff --git a/doc/classes/AnimatedSprite3D.xml b/doc/classes/AnimatedSprite3D.xml index 39ab317b79..6b3d426cef 100644 --- a/doc/classes/AnimatedSprite3D.xml +++ b/doc/classes/AnimatedSprite3D.xml @@ -11,24 +11,20 @@ </tutorials> <methods> <method name="is_playing" qualifiers="const"> - <return type="bool"> - </return> + <return type="bool" /> <description> Returns [code]true[/code] if an animation is currently being played. </description> </method> <method name="play"> - <return type="void"> - </return> - <argument index="0" name="anim" type="StringName" default="&"""> - </argument> + <return type="void" /> + <argument index="0" name="anim" type="StringName" default="&""" /> <description> Plays the animation named [code]anim[/code]. If no [code]anim[/code] is provided, the current animation is played. </description> </method> <method name="stop"> - <return type="void"> - </return> + <return type="void" /> <description> Stops the current animation (does not reset the frame counter). </description> diff --git a/doc/classes/AnimatedTexture.xml b/doc/classes/AnimatedTexture.xml index 5774842144..808b8bf053 100644 --- a/doc/classes/AnimatedTexture.xml +++ b/doc/classes/AnimatedTexture.xml @@ -13,30 +13,23 @@ </tutorials> <methods> <method name="get_frame_delay" qualifiers="const"> - <return type="float"> - </return> - <argument index="0" name="frame" type="int"> - </argument> + <return type="float" /> + <argument index="0" name="frame" type="int" /> <description> Returns the given frame's delay value. </description> </method> <method name="get_frame_texture" qualifiers="const"> - <return type="Texture2D"> - </return> - <argument index="0" name="frame" type="int"> - </argument> + <return type="Texture2D" /> + <argument index="0" name="frame" type="int" /> <description> Returns the given frame's [Texture2D]. </description> </method> <method name="set_frame_delay"> - <return type="void"> - </return> - <argument index="0" name="frame" type="int"> - </argument> - <argument index="1" name="delay" type="float"> - </argument> + <return type="void" /> + <argument index="0" name="frame" type="int" /> + <argument index="1" name="delay" type="float" /> <description> Sets an additional delay (in seconds) between this frame and the next one, that will be added to the time interval defined by [member fps]. By default, frames have no delay defined. If a delay value is defined, the final time interval between this frame and the next will be [code]1.0 / fps + delay[/code]. For example, for an animation with 3 frames, 2 FPS and a frame delay on the second frame of 1.2, the resulting playback will be: @@ -49,12 +42,9 @@ </description> </method> <method name="set_frame_texture"> - <return type="void"> - </return> - <argument index="0" name="frame" type="int"> - </argument> - <argument index="1" name="texture" type="Texture2D"> - </argument> + <return type="void" /> + <argument index="0" name="frame" type="int" /> + <argument index="1" name="texture" type="Texture2D" /> <description> Assigns a [Texture2D] to the given frame. Frame IDs start at 0, so the first frame has ID 0, and the last frame of the animation has ID [member frames] - 1. You can define any number of textures up to [constant MAX_FRAMES], but keep in mind that only frames from 0 to [member frames] - 1 will be part of the animation. diff --git a/doc/classes/Animation.xml b/doc/classes/Animation.xml index 894e784397..38e02745d4 100644 --- a/doc/classes/Animation.xml +++ b/doc/classes/Animation.xml @@ -32,673 +32,487 @@ </tutorials> <methods> <method name="add_track"> - <return type="int"> - </return> - <argument index="0" name="type" type="int" enum="Animation.TrackType"> - </argument> - <argument index="1" name="at_position" type="int" default="-1"> - </argument> + <return type="int" /> + <argument index="0" name="type" type="int" enum="Animation.TrackType" /> + <argument index="1" name="at_position" type="int" default="-1" /> <description> Adds a track to the Animation. </description> </method> <method name="animation_track_get_key_animation" qualifiers="const"> - <return type="StringName"> - </return> - <argument index="0" name="track_idx" type="int"> - </argument> - <argument index="1" name="key_idx" type="int"> - </argument> + <return type="StringName" /> + <argument index="0" name="track_idx" type="int" /> + <argument index="1" name="key_idx" type="int" /> <description> Returns the animation name at the key identified by [code]key_idx[/code]. The [code]track_idx[/code] must be the index of an Animation Track. </description> </method> <method name="animation_track_insert_key"> - <return type="int"> - </return> - <argument index="0" name="track_idx" type="int"> - </argument> - <argument index="1" name="time" type="float"> - </argument> - <argument index="2" name="animation" type="StringName"> - </argument> + <return type="int" /> + <argument index="0" name="track_idx" type="int" /> + <argument index="1" name="time" type="float" /> + <argument index="2" name="animation" type="StringName" /> <description> Inserts a key with value [code]animation[/code] at the given [code]time[/code] (in seconds). The [code]track_idx[/code] must be the index of an Animation Track. </description> </method> <method name="animation_track_set_key_animation"> - <return type="void"> - </return> - <argument index="0" name="track_idx" type="int"> - </argument> - <argument index="1" name="key_idx" type="int"> - </argument> - <argument index="2" name="animation" type="StringName"> - </argument> + <return type="void" /> + <argument index="0" name="track_idx" type="int" /> + <argument index="1" name="key_idx" type="int" /> + <argument index="2" name="animation" type="StringName" /> <description> Sets the key identified by [code]key_idx[/code] to value [code]animation[/code]. The [code]track_idx[/code] must be the index of an Animation Track. </description> </method> <method name="audio_track_get_key_end_offset" qualifiers="const"> - <return type="float"> - </return> - <argument index="0" name="track_idx" type="int"> - </argument> - <argument index="1" name="key_idx" type="int"> - </argument> + <return type="float" /> + <argument index="0" name="track_idx" type="int" /> + <argument index="1" name="key_idx" type="int" /> <description> Returns the end offset of the key identified by [code]key_idx[/code]. The [code]track_idx[/code] must be the index of an Audio Track. End offset is the number of seconds cut off at the ending of the audio stream. </description> </method> <method name="audio_track_get_key_start_offset" qualifiers="const"> - <return type="float"> - </return> - <argument index="0" name="track_idx" type="int"> - </argument> - <argument index="1" name="key_idx" type="int"> - </argument> + <return type="float" /> + <argument index="0" name="track_idx" type="int" /> + <argument index="1" name="key_idx" type="int" /> <description> Returns the start offset of the key identified by [code]key_idx[/code]. The [code]track_idx[/code] must be the index of an Audio Track. Start offset is the number of seconds cut off at the beginning of the audio stream. </description> </method> <method name="audio_track_get_key_stream" qualifiers="const"> - <return type="Resource"> - </return> - <argument index="0" name="track_idx" type="int"> - </argument> - <argument index="1" name="key_idx" type="int"> - </argument> + <return type="Resource" /> + <argument index="0" name="track_idx" type="int" /> + <argument index="1" name="key_idx" type="int" /> <description> Returns the audio stream of the key identified by [code]key_idx[/code]. The [code]track_idx[/code] must be the index of an Audio Track. </description> </method> <method name="audio_track_insert_key"> - <return type="int"> - </return> - <argument index="0" name="track_idx" type="int"> - </argument> - <argument index="1" name="time" type="float"> - </argument> - <argument index="2" name="stream" type="Resource"> - </argument> - <argument index="3" name="start_offset" type="float" default="0"> - </argument> - <argument index="4" name="end_offset" type="float" default="0"> - </argument> + <return type="int" /> + <argument index="0" name="track_idx" type="int" /> + <argument index="1" name="time" type="float" /> + <argument index="2" name="stream" type="Resource" /> + <argument index="3" name="start_offset" type="float" default="0" /> + <argument index="4" name="end_offset" type="float" default="0" /> <description> Inserts an Audio Track key at the given [code]time[/code] in seconds. The [code]track_idx[/code] must be the index of an Audio Track. [code]stream[/code] is the [AudioStream] resource to play. [code]start_offset[/code] is the number of seconds cut off at the beginning of the audio stream, while [code]end_offset[/code] is at the ending. </description> </method> <method name="audio_track_set_key_end_offset"> - <return type="void"> - </return> - <argument index="0" name="track_idx" type="int"> - </argument> - <argument index="1" name="key_idx" type="int"> - </argument> - <argument index="2" name="offset" type="float"> - </argument> + <return type="void" /> + <argument index="0" name="track_idx" type="int" /> + <argument index="1" name="key_idx" type="int" /> + <argument index="2" name="offset" type="float" /> <description> Sets the end offset of the key identified by [code]key_idx[/code] to value [code]offset[/code]. The [code]track_idx[/code] must be the index of an Audio Track. </description> </method> <method name="audio_track_set_key_start_offset"> - <return type="void"> - </return> - <argument index="0" name="track_idx" type="int"> - </argument> - <argument index="1" name="key_idx" type="int"> - </argument> - <argument index="2" name="offset" type="float"> - </argument> + <return type="void" /> + <argument index="0" name="track_idx" type="int" /> + <argument index="1" name="key_idx" type="int" /> + <argument index="2" name="offset" type="float" /> <description> Sets the start offset of the key identified by [code]key_idx[/code] to value [code]offset[/code]. The [code]track_idx[/code] must be the index of an Audio Track. </description> </method> <method name="audio_track_set_key_stream"> - <return type="void"> - </return> - <argument index="0" name="track_idx" type="int"> - </argument> - <argument index="1" name="key_idx" type="int"> - </argument> - <argument index="2" name="stream" type="Resource"> - </argument> + <return type="void" /> + <argument index="0" name="track_idx" type="int" /> + <argument index="1" name="key_idx" type="int" /> + <argument index="2" name="stream" type="Resource" /> <description> Sets the stream of the key identified by [code]key_idx[/code] to value [code]stream[/code]. The [code]track_idx[/code] must be the index of an Audio Track. </description> </method> <method name="bezier_track_get_key_in_handle" qualifiers="const"> - <return type="Vector2"> - </return> - <argument index="0" name="track_idx" type="int"> - </argument> - <argument index="1" name="key_idx" type="int"> - </argument> + <return type="Vector2" /> + <argument index="0" name="track_idx" type="int" /> + <argument index="1" name="key_idx" type="int" /> <description> Returns the in handle of the key identified by [code]key_idx[/code]. The [code]track_idx[/code] must be the index of a Bezier Track. </description> </method> <method name="bezier_track_get_key_out_handle" qualifiers="const"> - <return type="Vector2"> - </return> - <argument index="0" name="track_idx" type="int"> - </argument> - <argument index="1" name="key_idx" type="int"> - </argument> + <return type="Vector2" /> + <argument index="0" name="track_idx" type="int" /> + <argument index="1" name="key_idx" type="int" /> <description> Returns the out handle of the key identified by [code]key_idx[/code]. The [code]track_idx[/code] must be the index of a Bezier Track. </description> </method> <method name="bezier_track_get_key_value" qualifiers="const"> - <return type="float"> - </return> - <argument index="0" name="track_idx" type="int"> - </argument> - <argument index="1" name="key_idx" type="int"> - </argument> + <return type="float" /> + <argument index="0" name="track_idx" type="int" /> + <argument index="1" name="key_idx" type="int" /> <description> Returns the value of the key identified by [code]key_idx[/code]. The [code]track_idx[/code] must be the index of a Bezier Track. </description> </method> <method name="bezier_track_insert_key"> - <return type="int"> - </return> - <argument index="0" name="track_idx" type="int"> - </argument> - <argument index="1" name="time" type="float"> - </argument> - <argument index="2" name="value" type="float"> - </argument> - <argument index="3" name="in_handle" type="Vector2" default="Vector2(0, 0)"> - </argument> - <argument index="4" name="out_handle" type="Vector2" default="Vector2(0, 0)"> - </argument> + <return type="int" /> + <argument index="0" name="track_idx" type="int" /> + <argument index="1" name="time" type="float" /> + <argument index="2" name="value" type="float" /> + <argument index="3" name="in_handle" type="Vector2" default="Vector2(0, 0)" /> + <argument index="4" name="out_handle" type="Vector2" default="Vector2(0, 0)" /> <description> Inserts a Bezier Track key at the given [code]time[/code] in seconds. The [code]track_idx[/code] must be the index of a Bezier Track. [code]in_handle[/code] is the left-side weight of the added Bezier curve point, [code]out_handle[/code] is the right-side one, while [code]value[/code] is the actual value at this point. </description> </method> <method name="bezier_track_interpolate" qualifiers="const"> - <return type="float"> - </return> - <argument index="0" name="track_idx" type="int"> - </argument> - <argument index="1" name="time" type="float"> - </argument> + <return type="float" /> + <argument index="0" name="track_idx" type="int" /> + <argument index="1" name="time" type="float" /> <description> Returns the interpolated value at the given [code]time[/code] (in seconds). The [code]track_idx[/code] must be the index of a Bezier Track. </description> </method> <method name="bezier_track_set_key_in_handle"> - <return type="void"> - </return> - <argument index="0" name="track_idx" type="int"> - </argument> - <argument index="1" name="key_idx" type="int"> - </argument> - <argument index="2" name="in_handle" type="Vector2"> - </argument> + <return type="void" /> + <argument index="0" name="track_idx" type="int" /> + <argument index="1" name="key_idx" type="int" /> + <argument index="2" name="in_handle" type="Vector2" /> <description> Sets the in handle of the key identified by [code]key_idx[/code] to value [code]in_handle[/code]. The [code]track_idx[/code] must be the index of a Bezier Track. </description> </method> <method name="bezier_track_set_key_out_handle"> - <return type="void"> - </return> - <argument index="0" name="track_idx" type="int"> - </argument> - <argument index="1" name="key_idx" type="int"> - </argument> - <argument index="2" name="out_handle" type="Vector2"> - </argument> + <return type="void" /> + <argument index="0" name="track_idx" type="int" /> + <argument index="1" name="key_idx" type="int" /> + <argument index="2" name="out_handle" type="Vector2" /> <description> Sets the out handle of the key identified by [code]key_idx[/code] to value [code]out_handle[/code]. The [code]track_idx[/code] must be the index of a Bezier Track. </description> </method> <method name="bezier_track_set_key_value"> - <return type="void"> - </return> - <argument index="0" name="track_idx" type="int"> - </argument> - <argument index="1" name="key_idx" type="int"> - </argument> - <argument index="2" name="value" type="float"> - </argument> + <return type="void" /> + <argument index="0" name="track_idx" type="int" /> + <argument index="1" name="key_idx" type="int" /> + <argument index="2" name="value" type="float" /> <description> Sets the value of the key identified by [code]key_idx[/code] to the given value. The [code]track_idx[/code] must be the index of a Bezier Track. </description> </method> <method name="clear"> - <return type="void"> - </return> + <return type="void" /> <description> Clear the animation (clear all tracks and reset all). </description> </method> <method name="copy_track"> - <return type="void"> - </return> - <argument index="0" name="track_idx" type="int"> - </argument> - <argument index="1" name="to_animation" type="Animation"> - </argument> + <return type="void" /> + <argument index="0" name="track_idx" type="int" /> + <argument index="1" name="to_animation" type="Animation" /> <description> Adds a new track that is a copy of the given track from [code]to_animation[/code]. </description> </method> <method name="find_track" qualifiers="const"> - <return type="int"> - </return> - <argument index="0" name="path" type="NodePath"> - </argument> + <return type="int" /> + <argument index="0" name="path" type="NodePath" /> <description> Returns the index of the specified track. If the track is not found, return -1. </description> </method> <method name="get_track_count" qualifiers="const"> - <return type="int"> - </return> + <return type="int" /> <description> Returns the amount of tracks in the animation. </description> </method> <method name="method_track_get_key_indices" qualifiers="const"> - <return type="PackedInt32Array"> - </return> - <argument index="0" name="track_idx" type="int"> - </argument> - <argument index="1" name="time_sec" type="float"> - </argument> - <argument index="2" name="delta" type="float"> - </argument> + <return type="PackedInt32Array" /> + <argument index="0" name="track_idx" type="int" /> + <argument index="1" name="time_sec" type="float" /> + <argument index="2" name="delta" type="float" /> <description> Returns all the key indices of a method track, given a position and delta time. </description> </method> <method name="method_track_get_name" qualifiers="const"> - <return type="StringName"> - </return> - <argument index="0" name="track_idx" type="int"> - </argument> - <argument index="1" name="key_idx" type="int"> - </argument> + <return type="StringName" /> + <argument index="0" name="track_idx" type="int" /> + <argument index="1" name="key_idx" type="int" /> <description> Returns the method name of a method track. </description> </method> <method name="method_track_get_params" qualifiers="const"> - <return type="Array"> - </return> - <argument index="0" name="track_idx" type="int"> - </argument> - <argument index="1" name="key_idx" type="int"> - </argument> + <return type="Array" /> + <argument index="0" name="track_idx" type="int" /> + <argument index="1" name="key_idx" type="int" /> <description> Returns the arguments values to be called on a method track for a given key in a given track. </description> </method> <method name="remove_track"> - <return type="void"> - </return> - <argument index="0" name="track_idx" type="int"> - </argument> + <return type="void" /> + <argument index="0" name="track_idx" type="int" /> <description> Removes a track by specifying the track index. </description> </method> <method name="track_find_key" qualifiers="const"> - <return type="int"> - </return> - <argument index="0" name="track_idx" type="int"> - </argument> - <argument index="1" name="time" type="float"> - </argument> - <argument index="2" name="exact" type="bool" default="false"> - </argument> + <return type="int" /> + <argument index="0" name="track_idx" type="int" /> + <argument index="1" name="time" type="float" /> + <argument index="2" name="exact" type="bool" default="false" /> <description> Finds the key index by time in a given track. Optionally, only find it if the exact time is given. </description> </method> <method name="track_get_interpolation_loop_wrap" qualifiers="const"> - <return type="bool"> - </return> - <argument index="0" name="track_idx" type="int"> - </argument> + <return type="bool" /> + <argument index="0" name="track_idx" type="int" /> <description> Returns [code]true[/code] if the track at [code]idx[/code] wraps the interpolation loop. New tracks wrap the interpolation loop by default. </description> </method> <method name="track_get_interpolation_type" qualifiers="const"> - <return type="int" enum="Animation.InterpolationType"> - </return> - <argument index="0" name="track_idx" type="int"> - </argument> + <return type="int" enum="Animation.InterpolationType" /> + <argument index="0" name="track_idx" type="int" /> <description> Returns the interpolation type of a given track. </description> </method> <method name="track_get_key_count" qualifiers="const"> - <return type="int"> - </return> - <argument index="0" name="track_idx" type="int"> - </argument> + <return type="int" /> + <argument index="0" name="track_idx" type="int" /> <description> Returns the amount of keys in a given track. </description> </method> <method name="track_get_key_time" qualifiers="const"> - <return type="float"> - </return> - <argument index="0" name="track_idx" type="int"> - </argument> - <argument index="1" name="key_idx" type="int"> - </argument> + <return type="float" /> + <argument index="0" name="track_idx" type="int" /> + <argument index="1" name="key_idx" type="int" /> <description> Returns the time at which the key is located. </description> </method> <method name="track_get_key_transition" qualifiers="const"> - <return type="float"> - </return> - <argument index="0" name="track_idx" type="int"> - </argument> - <argument index="1" name="key_idx" type="int"> - </argument> + <return type="float" /> + <argument index="0" name="track_idx" type="int" /> + <argument index="1" name="key_idx" type="int" /> <description> Returns the transition curve (easing) for a specific key (see the built-in math function [method @GlobalScope.ease]). </description> </method> <method name="track_get_key_value" qualifiers="const"> - <return type="Variant"> - </return> - <argument index="0" name="track_idx" type="int"> - </argument> - <argument index="1" name="key_idx" type="int"> - </argument> + <return type="Variant" /> + <argument index="0" name="track_idx" type="int" /> + <argument index="1" name="key_idx" type="int" /> <description> Returns the value of a given key in a given track. </description> </method> <method name="track_get_path" qualifiers="const"> - <return type="NodePath"> - </return> - <argument index="0" name="track_idx" type="int"> - </argument> + <return type="NodePath" /> + <argument index="0" name="track_idx" type="int" /> <description> Gets the path of a track. For more information on the path format, see [method track_set_path]. </description> </method> <method name="track_get_type" qualifiers="const"> - <return type="int" enum="Animation.TrackType"> - </return> - <argument index="0" name="track_idx" type="int"> - </argument> + <return type="int" enum="Animation.TrackType" /> + <argument index="0" name="track_idx" type="int" /> <description> Gets the type of a track. </description> </method> <method name="track_insert_key"> - <return type="void"> - </return> - <argument index="0" name="track_idx" type="int"> - </argument> - <argument index="1" name="time" type="float"> - </argument> - <argument index="2" name="key" type="Variant"> - </argument> - <argument index="3" name="transition" type="float" default="1"> - </argument> + <return type="void" /> + <argument index="0" name="track_idx" type="int" /> + <argument index="1" name="time" type="float" /> + <argument index="2" name="key" type="Variant" /> + <argument index="3" name="transition" type="float" default="1" /> <description> Insert a generic key in a given track. </description> </method> <method name="track_is_enabled" qualifiers="const"> - <return type="bool"> - </return> - <argument index="0" name="track_idx" type="int"> - </argument> + <return type="bool" /> + <argument index="0" name="track_idx" type="int" /> <description> Returns [code]true[/code] if the track at index [code]idx[/code] is enabled. </description> </method> <method name="track_is_imported" qualifiers="const"> - <return type="bool"> - </return> - <argument index="0" name="track_idx" type="int"> - </argument> + <return type="bool" /> + <argument index="0" name="track_idx" type="int" /> <description> Returns [code]true[/code] if the given track is imported. Else, return [code]false[/code]. </description> </method> <method name="track_move_down"> - <return type="void"> - </return> - <argument index="0" name="track_idx" type="int"> - </argument> + <return type="void" /> + <argument index="0" name="track_idx" type="int" /> <description> Moves a track down. </description> </method> <method name="track_move_to"> - <return type="void"> - </return> - <argument index="0" name="track_idx" type="int"> - </argument> - <argument index="1" name="to_idx" type="int"> - </argument> + <return type="void" /> + <argument index="0" name="track_idx" type="int" /> + <argument index="1" name="to_idx" type="int" /> <description> Changes the index position of track [code]idx[/code] to the one defined in [code]to_idx[/code]. </description> </method> <method name="track_move_up"> - <return type="void"> - </return> - <argument index="0" name="track_idx" type="int"> - </argument> + <return type="void" /> + <argument index="0" name="track_idx" type="int" /> <description> Moves a track up. </description> </method> <method name="track_remove_key"> - <return type="void"> - </return> - <argument index="0" name="track_idx" type="int"> - </argument> - <argument index="1" name="key_idx" type="int"> - </argument> + <return type="void" /> + <argument index="0" name="track_idx" type="int" /> + <argument index="1" name="key_idx" type="int" /> <description> Removes a key by index in a given track. </description> </method> <method name="track_remove_key_at_time"> - <return type="void"> - </return> - <argument index="0" name="track_idx" type="int"> - </argument> - <argument index="1" name="time" type="float"> - </argument> + <return type="void" /> + <argument index="0" name="track_idx" type="int" /> + <argument index="1" name="time" type="float" /> <description> Removes a key at [code]time[/code] in a given track. </description> </method> <method name="track_set_enabled"> - <return type="void"> - </return> - <argument index="0" name="track_idx" type="int"> - </argument> - <argument index="1" name="enabled" type="bool"> - </argument> + <return type="void" /> + <argument index="0" name="track_idx" type="int" /> + <argument index="1" name="enabled" type="bool" /> <description> Enables/disables the given track. Tracks are enabled by default. </description> </method> <method name="track_set_imported"> - <return type="void"> - </return> - <argument index="0" name="track_idx" type="int"> - </argument> - <argument index="1" name="imported" type="bool"> - </argument> + <return type="void" /> + <argument index="0" name="track_idx" type="int" /> + <argument index="1" name="imported" type="bool" /> <description> Sets the given track as imported or not. </description> </method> <method name="track_set_interpolation_loop_wrap"> - <return type="void"> - </return> - <argument index="0" name="track_idx" type="int"> - </argument> - <argument index="1" name="interpolation" type="bool"> - </argument> + <return type="void" /> + <argument index="0" name="track_idx" type="int" /> + <argument index="1" name="interpolation" type="bool" /> <description> If [code]true[/code], the track at [code]idx[/code] wraps the interpolation loop. </description> </method> <method name="track_set_interpolation_type"> - <return type="void"> - </return> - <argument index="0" name="track_idx" type="int"> - </argument> - <argument index="1" name="interpolation" type="int" enum="Animation.InterpolationType"> - </argument> + <return type="void" /> + <argument index="0" name="track_idx" type="int" /> + <argument index="1" name="interpolation" type="int" enum="Animation.InterpolationType" /> <description> Sets the interpolation type of a given track. </description> </method> <method name="track_set_key_time"> - <return type="void"> - </return> - <argument index="0" name="track_idx" type="int"> - </argument> - <argument index="1" name="key_idx" type="int"> - </argument> - <argument index="2" name="time" type="float"> - </argument> + <return type="void" /> + <argument index="0" name="track_idx" type="int" /> + <argument index="1" name="key_idx" type="int" /> + <argument index="2" name="time" type="float" /> <description> Sets the time of an existing key. </description> </method> <method name="track_set_key_transition"> - <return type="void"> - </return> - <argument index="0" name="track_idx" type="int"> - </argument> - <argument index="1" name="key_idx" type="int"> - </argument> - <argument index="2" name="transition" type="float"> - </argument> + <return type="void" /> + <argument index="0" name="track_idx" type="int" /> + <argument index="1" name="key_idx" type="int" /> + <argument index="2" name="transition" type="float" /> <description> Sets the transition curve (easing) for a specific key (see the built-in math function [method @GlobalScope.ease]). </description> </method> <method name="track_set_key_value"> - <return type="void"> - </return> - <argument index="0" name="track_idx" type="int"> - </argument> - <argument index="1" name="key" type="int"> - </argument> - <argument index="2" name="value" type="Variant"> - </argument> + <return type="void" /> + <argument index="0" name="track_idx" type="int" /> + <argument index="1" name="key" type="int" /> + <argument index="2" name="value" type="Variant" /> <description> Sets the value of an existing key. </description> </method> <method name="track_set_path"> - <return type="void"> - </return> - <argument index="0" name="track_idx" type="int"> - </argument> - <argument index="1" name="path" type="NodePath"> - </argument> - <description> - Sets the path of a track. Paths must be valid scene-tree paths to a node, and must be specified starting from the parent node of the node that will reproduce the animation. Tracks that control properties or bones must append their name after the path, separated by [code]":"[/code]. + <return type="void" /> + <argument index="0" name="track_idx" type="int" /> + <argument index="1" name="path" type="NodePath" /> + <description> + Sets the path of a track. Paths must be valid scene-tree paths to a node and must be specified starting from the parent node of the node that will reproduce the animation. Tracks that control properties or bones must append their name after the path, separated by [code]":"[/code]. For example, [code]"character/skeleton:ankle"[/code] or [code]"character/mesh:transform/local"[/code]. </description> </method> <method name="track_swap"> - <return type="void"> - </return> - <argument index="0" name="track_idx" type="int"> - </argument> - <argument index="1" name="with_idx" type="int"> - </argument> + <return type="void" /> + <argument index="0" name="track_idx" type="int" /> + <argument index="1" name="with_idx" type="int" /> <description> Swaps the track [code]idx[/code]'s index position with the track [code]with_idx[/code]. </description> </method> <method name="transform_track_insert_key"> - <return type="int"> - </return> - <argument index="0" name="track_idx" type="int"> - </argument> - <argument index="1" name="time" type="float"> - </argument> - <argument index="2" name="location" type="Vector3"> - </argument> - <argument index="3" name="rotation" type="Quaternion"> - </argument> - <argument index="4" name="scale" type="Vector3"> - </argument> + <return type="int" /> + <argument index="0" name="track_idx" type="int" /> + <argument index="1" name="time" type="float" /> + <argument index="2" name="location" type="Vector3" /> + <argument index="3" name="rotation" type="Quaternion" /> + <argument index="4" name="scale" type="Vector3" /> <description> Insert a transform key for a transform track. </description> </method> <method name="transform_track_interpolate" qualifiers="const"> - <return type="Array"> - </return> - <argument index="0" name="track_idx" type="int"> - </argument> - <argument index="1" name="time_sec" type="float"> - </argument> + <return type="Array" /> + <argument index="0" name="track_idx" type="int" /> + <argument index="1" name="time_sec" type="float" /> <description> Returns the interpolated value of a transform track at a given time (in seconds). An array consisting of 3 elements: position ([Vector3]), rotation ([Quaternion]) and scale ([Vector3]). </description> </method> <method name="value_track_get_key_indices" qualifiers="const"> - <return type="PackedInt32Array"> - </return> - <argument index="0" name="track_idx" type="int"> - </argument> - <argument index="1" name="time_sec" type="float"> - </argument> - <argument index="2" name="delta" type="float"> - </argument> + <return type="PackedInt32Array" /> + <argument index="0" name="track_idx" type="int" /> + <argument index="1" name="time_sec" type="float" /> + <argument index="2" name="delta" type="float" /> <description> Returns all the key indices of a value track, given a position and delta time. </description> </method> <method name="value_track_get_update_mode" qualifiers="const"> - <return type="int" enum="Animation.UpdateMode"> - </return> - <argument index="0" name="track_idx" type="int"> - </argument> + <return type="int" enum="Animation.UpdateMode" /> + <argument index="0" name="track_idx" type="int" /> <description> Returns the update mode of a value track. </description> </method> <method name="value_track_interpolate" qualifiers="const"> - <return type="Variant"> - </return> - <argument index="0" name="track_idx" type="int"> - </argument> - <argument index="1" name="time_sec" type="float"> - </argument> + <return type="Variant" /> + <argument index="0" name="track_idx" type="int" /> + <argument index="1" name="time_sec" type="float" /> <description> Returns the interpolated value at the given time (in seconds). The [code]track_idx[/code] must be the index of a value track. </description> </method> <method name="value_track_set_update_mode"> - <return type="void"> - </return> - <argument index="0" name="track_idx" type="int"> - </argument> - <argument index="1" name="mode" type="int" enum="Animation.UpdateMode"> - </argument> + <return type="void" /> + <argument index="0" name="track_idx" type="int" /> + <argument index="1" name="mode" type="int" enum="Animation.UpdateMode" /> <description> Sets the update mode (see [enum UpdateMode]) of a value track. </description> diff --git a/doc/classes/AnimationNode.xml b/doc/classes/AnimationNode.xml index fddd8989ab..a9a08efcf1 100644 --- a/doc/classes/AnimationNode.xml +++ b/doc/classes/AnimationNode.xml @@ -12,58 +12,47 @@ </tutorials> <methods> <method name="_get_caption" qualifiers="virtual"> - <return type="String"> - </return> + <return type="String" /> <description> Gets the text caption for this node (used by some editors). </description> </method> <method name="_get_child_by_name" qualifiers="virtual"> - <return type="Object"> - </return> - <argument index="0" name="name" type="String"> - </argument> + <return type="Object" /> + <argument index="0" name="name" type="String" /> <description> Gets a child node by index (used by editors inheriting from [AnimationRootNode]). </description> </method> <method name="_get_child_nodes" qualifiers="virtual"> - <return type="Dictionary"> - </return> + <return type="Dictionary" /> <description> Gets all children nodes in order as a [code]name: node[/code] dictionary. Only useful when inheriting [AnimationRootNode]. </description> </method> <method name="_get_parameter_default_value" qualifiers="virtual"> - <return type="Variant"> - </return> - <argument index="0" name="name" type="StringName"> - </argument> + <return type="Variant" /> + <argument index="0" name="name" type="StringName" /> <description> Gets the default value of a parameter. Parameters are custom local memory used for your nodes, given a resource can be reused in multiple trees. </description> </method> <method name="_get_parameter_list" qualifiers="virtual"> - <return type="Array"> - </return> + <return type="Array" /> <description> Gets the property information for parameter. Parameters are custom local memory used for your nodes, given a resource can be reused in multiple trees. Format is similar to [method Object.get_property_list]. </description> </method> <method name="_has_filter" qualifiers="virtual"> - <return type="bool"> - </return> + <return type="bool" /> <description> Returns [code]true[/code] whether you want the blend tree editor to display filter editing on this node. </description> </method> <method name="_process" qualifiers="virtual"> - <return type="void"> - </return> - <argument index="0" name="time" type="float"> - </argument> - <argument index="1" name="seek" type="bool"> - </argument> + <return type="void" /> + <argument index="0" name="time" type="float" /> + <argument index="1" name="seek" type="bool" /> <description> User-defined callback called when a custom node is processed. The [code]time[/code] parameter is a relative delta, unless [code]seek[/code] is [code]true[/code], in which case it is absolute. Here, call the [method blend_input], [method blend_node] or [method blend_animation] functions. You can also use [method get_parameter] and [method set_parameter] to modify local memory. @@ -71,132 +60,94 @@ </description> </method> <method name="add_input"> - <return type="void"> - </return> - <argument index="0" name="name" type="String"> - </argument> + <return type="void" /> + <argument index="0" name="name" type="String" /> <description> Adds an input to the node. This is only useful for nodes created for use in an [AnimationNodeBlendTree]. </description> </method> <method name="blend_animation"> - <return type="void"> - </return> - <argument index="0" name="animation" type="StringName"> - </argument> - <argument index="1" name="time" type="float"> - </argument> - <argument index="2" name="delta" type="float"> - </argument> - <argument index="3" name="seeked" type="bool"> - </argument> - <argument index="4" name="blend" type="float"> - </argument> + <return type="void" /> + <argument index="0" name="animation" type="StringName" /> + <argument index="1" name="time" type="float" /> + <argument index="2" name="delta" type="float" /> + <argument index="3" name="seeked" type="bool" /> + <argument index="4" name="blend" type="float" /> <description> Blend an animation by [code]blend[/code] amount (name must be valid in the linked [AnimationPlayer]). A [code]time[/code] and [code]delta[/code] may be passed, as well as whether [code]seek[/code] happened. </description> </method> <method name="blend_input"> - <return type="float"> - </return> - <argument index="0" name="input_index" type="int"> - </argument> - <argument index="1" name="time" type="float"> - </argument> - <argument index="2" name="seek" type="bool"> - </argument> - <argument index="3" name="blend" type="float"> - </argument> - <argument index="4" name="filter" type="int" enum="AnimationNode.FilterAction" default="0"> - </argument> - <argument index="5" name="optimize" type="bool" default="true"> - </argument> + <return type="float" /> + <argument index="0" name="input_index" type="int" /> + <argument index="1" name="time" type="float" /> + <argument index="2" name="seek" type="bool" /> + <argument index="3" name="blend" type="float" /> + <argument index="4" name="filter" type="int" enum="AnimationNode.FilterAction" default="0" /> + <argument index="5" name="optimize" type="bool" default="true" /> <description> Blend an input. This is only useful for nodes created for an [AnimationNodeBlendTree]. The [code]time[/code] parameter is a relative delta, unless [code]seek[/code] is [code]true[/code], in which case it is absolute. A filter mode may be optionally passed (see [enum FilterAction] for options). </description> </method> <method name="blend_node"> - <return type="float"> - </return> - <argument index="0" name="name" type="StringName"> - </argument> - <argument index="1" name="node" type="AnimationNode"> - </argument> - <argument index="2" name="time" type="float"> - </argument> - <argument index="3" name="seek" type="bool"> - </argument> - <argument index="4" name="blend" type="float"> - </argument> - <argument index="5" name="filter" type="int" enum="AnimationNode.FilterAction" default="0"> - </argument> - <argument index="6" name="optimize" type="bool" default="true"> - </argument> + <return type="float" /> + <argument index="0" name="name" type="StringName" /> + <argument index="1" name="node" type="AnimationNode" /> + <argument index="2" name="time" type="float" /> + <argument index="3" name="seek" type="bool" /> + <argument index="4" name="blend" type="float" /> + <argument index="5" name="filter" type="int" enum="AnimationNode.FilterAction" default="0" /> + <argument index="6" name="optimize" type="bool" default="true" /> <description> Blend another animation node (in case this node contains children animation nodes). This function is only useful if you inherit from [AnimationRootNode] instead, else editors will not display your node for addition. </description> </method> <method name="get_input_count" qualifiers="const"> - <return type="int"> - </return> + <return type="int" /> <description> Amount of inputs in this node, only useful for nodes that go into [AnimationNodeBlendTree]. </description> </method> <method name="get_input_name"> - <return type="String"> - </return> - <argument index="0" name="input" type="int"> - </argument> + <return type="String" /> + <argument index="0" name="input" type="int" /> <description> Gets the name of an input by index. </description> </method> <method name="get_parameter" qualifiers="const"> - <return type="Variant"> - </return> - <argument index="0" name="name" type="StringName"> - </argument> + <return type="Variant" /> + <argument index="0" name="name" type="StringName" /> <description> Gets the value of a parameter. Parameters are custom local memory used for your nodes, given a resource can be reused in multiple trees. </description> </method> <method name="is_path_filtered" qualifiers="const"> - <return type="bool"> - </return> - <argument index="0" name="path" type="NodePath"> - </argument> + <return type="bool" /> + <argument index="0" name="path" type="NodePath" /> <description> Returns [code]true[/code] whether a given path is filtered. </description> </method> <method name="remove_input"> - <return type="void"> - </return> - <argument index="0" name="index" type="int"> - </argument> + <return type="void" /> + <argument index="0" name="index" type="int" /> <description> Removes an input, call this only when inactive. </description> </method> <method name="set_filter_path"> - <return type="void"> - </return> - <argument index="0" name="path" type="NodePath"> - </argument> - <argument index="1" name="enable" type="bool"> - </argument> + <return type="void" /> + <argument index="0" name="path" type="NodePath" /> + <argument index="1" name="enable" type="bool" /> <description> Adds or removes a path for the filter. </description> </method> <method name="set_parameter"> - <return type="void"> - </return> - <argument index="0" name="name" type="StringName"> - </argument> - <argument index="1" name="value" type="Variant"> - </argument> + <return type="void" /> + <argument index="0" name="name" type="StringName" /> + <argument index="1" name="value" type="Variant" /> <description> Sets a custom parameter. These are used as local storage, because resources can be reused across the tree or scenes. </description> diff --git a/doc/classes/AnimationNodeBlendSpace1D.xml b/doc/classes/AnimationNodeBlendSpace1D.xml index 263b59910b..c47d84fe37 100644 --- a/doc/classes/AnimationNodeBlendSpace1D.xml +++ b/doc/classes/AnimationNodeBlendSpace1D.xml @@ -14,70 +14,53 @@ </tutorials> <methods> <method name="add_blend_point"> - <return type="void"> - </return> - <argument index="0" name="node" type="AnimationRootNode"> - </argument> - <argument index="1" name="pos" type="float"> - </argument> - <argument index="2" name="at_index" type="int" default="-1"> - </argument> + <return type="void" /> + <argument index="0" name="node" type="AnimationRootNode" /> + <argument index="1" name="pos" type="float" /> + <argument index="2" name="at_index" type="int" default="-1" /> <description> Adds a new point that represents a [code]node[/code] on the virtual axis at a given position set by [code]pos[/code]. You can insert it at a specific index using the [code]at_index[/code] argument. If you use the default value for [code]at_index[/code], the point is inserted at the end of the blend points array. </description> </method> <method name="get_blend_point_count" qualifiers="const"> - <return type="int"> - </return> + <return type="int" /> <description> Returns the number of points on the blend axis. </description> </method> <method name="get_blend_point_node" qualifiers="const"> - <return type="AnimationRootNode"> - </return> - <argument index="0" name="point" type="int"> - </argument> + <return type="AnimationRootNode" /> + <argument index="0" name="point" type="int" /> <description> Returns the [AnimationNode] referenced by the point at index [code]point[/code]. </description> </method> <method name="get_blend_point_position" qualifiers="const"> - <return type="float"> - </return> - <argument index="0" name="point" type="int"> - </argument> + <return type="float" /> + <argument index="0" name="point" type="int" /> <description> Returns the position of the point at index [code]point[/code]. </description> </method> <method name="remove_blend_point"> - <return type="void"> - </return> - <argument index="0" name="point" type="int"> - </argument> + <return type="void" /> + <argument index="0" name="point" type="int" /> <description> Removes the point at index [code]point[/code] from the blend axis. </description> </method> <method name="set_blend_point_node"> - <return type="void"> - </return> - <argument index="0" name="point" type="int"> - </argument> - <argument index="1" name="node" type="AnimationRootNode"> - </argument> + <return type="void" /> + <argument index="0" name="point" type="int" /> + <argument index="1" name="node" type="AnimationRootNode" /> <description> Changes the [AnimationNode] referenced by the point at index [code]point[/code]. </description> </method> <method name="set_blend_point_position"> - <return type="void"> - </return> - <argument index="0" name="point" type="int"> - </argument> - <argument index="1" name="pos" type="float"> - </argument> + <return type="void" /> + <argument index="0" name="point" type="int" /> + <argument index="1" name="pos" type="float" /> <description> Updates the position of the point at index [code]point[/code] on the blend axis. </description> diff --git a/doc/classes/AnimationNodeBlendSpace2D.xml b/doc/classes/AnimationNodeBlendSpace2D.xml index 1a6d2bd755..8d51f9aecc 100644 --- a/doc/classes/AnimationNodeBlendSpace2D.xml +++ b/doc/classes/AnimationNodeBlendSpace2D.xml @@ -14,112 +14,84 @@ </tutorials> <methods> <method name="add_blend_point"> - <return type="void"> - </return> - <argument index="0" name="node" type="AnimationRootNode"> - </argument> - <argument index="1" name="pos" type="Vector2"> - </argument> - <argument index="2" name="at_index" type="int" default="-1"> - </argument> + <return type="void" /> + <argument index="0" name="node" type="AnimationRootNode" /> + <argument index="1" name="pos" type="Vector2" /> + <argument index="2" name="at_index" type="int" default="-1" /> <description> Adds a new point that represents a [code]node[/code] at the position set by [code]pos[/code]. You can insert it at a specific index using the [code]at_index[/code] argument. If you use the default value for [code]at_index[/code], the point is inserted at the end of the blend points array. </description> </method> <method name="add_triangle"> - <return type="void"> - </return> - <argument index="0" name="x" type="int"> - </argument> - <argument index="1" name="y" type="int"> - </argument> - <argument index="2" name="z" type="int"> - </argument> - <argument index="3" name="at_index" type="int" default="-1"> - </argument> + <return type="void" /> + <argument index="0" name="x" type="int" /> + <argument index="1" name="y" type="int" /> + <argument index="2" name="z" type="int" /> + <argument index="3" name="at_index" type="int" default="-1" /> <description> Creates a new triangle using three points [code]x[/code], [code]y[/code], and [code]z[/code]. Triangles can overlap. You can insert the triangle at a specific index using the [code]at_index[/code] argument. If you use the default value for [code]at_index[/code], the point is inserted at the end of the blend points array. </description> </method> <method name="get_blend_point_count" qualifiers="const"> - <return type="int"> - </return> + <return type="int" /> <description> Returns the number of points in the blend space. </description> </method> <method name="get_blend_point_node" qualifiers="const"> - <return type="AnimationRootNode"> - </return> - <argument index="0" name="point" type="int"> - </argument> + <return type="AnimationRootNode" /> + <argument index="0" name="point" type="int" /> <description> Returns the [AnimationRootNode] referenced by the point at index [code]point[/code]. </description> </method> <method name="get_blend_point_position" qualifiers="const"> - <return type="Vector2"> - </return> - <argument index="0" name="point" type="int"> - </argument> + <return type="Vector2" /> + <argument index="0" name="point" type="int" /> <description> Returns the position of the point at index [code]point[/code]. </description> </method> <method name="get_triangle_count" qualifiers="const"> - <return type="int"> - </return> + <return type="int" /> <description> Returns the number of triangles in the blend space. </description> </method> <method name="get_triangle_point"> - <return type="int"> - </return> - <argument index="0" name="triangle" type="int"> - </argument> - <argument index="1" name="point" type="int"> - </argument> + <return type="int" /> + <argument index="0" name="triangle" type="int" /> + <argument index="1" name="point" type="int" /> <description> Returns the position of the point at index [code]point[/code] in the triangle of index [code]triangle[/code]. </description> </method> <method name="remove_blend_point"> - <return type="void"> - </return> - <argument index="0" name="point" type="int"> - </argument> + <return type="void" /> + <argument index="0" name="point" type="int" /> <description> Removes the point at index [code]point[/code] from the blend space. </description> </method> <method name="remove_triangle"> - <return type="void"> - </return> - <argument index="0" name="triangle" type="int"> - </argument> + <return type="void" /> + <argument index="0" name="triangle" type="int" /> <description> Removes the triangle at index [code]triangle[/code] from the blend space. </description> </method> <method name="set_blend_point_node"> - <return type="void"> - </return> - <argument index="0" name="point" type="int"> - </argument> - <argument index="1" name="node" type="AnimationRootNode"> - </argument> + <return type="void" /> + <argument index="0" name="point" type="int" /> + <argument index="1" name="node" type="AnimationRootNode" /> <description> Changes the [AnimationNode] referenced by the point at index [code]point[/code]. </description> </method> <method name="set_blend_point_position"> - <return type="void"> - </return> - <argument index="0" name="point" type="int"> - </argument> - <argument index="1" name="pos" type="Vector2"> - </argument> + <return type="void" /> + <argument index="0" name="point" type="int" /> + <argument index="1" name="pos" type="Vector2" /> <description> Updates the position of the point at index [code]point[/code] on the blend axis. </description> diff --git a/doc/classes/AnimationNodeBlendTree.xml b/doc/classes/AnimationNodeBlendTree.xml index a90e8647bb..da532dc059 100644 --- a/doc/classes/AnimationNodeBlendTree.xml +++ b/doc/classes/AnimationNodeBlendTree.xml @@ -11,96 +11,71 @@ </tutorials> <methods> <method name="add_node"> - <return type="void"> - </return> - <argument index="0" name="name" type="StringName"> - </argument> - <argument index="1" name="node" type="AnimationNode"> - </argument> - <argument index="2" name="position" type="Vector2" default="Vector2(0, 0)"> - </argument> + <return type="void" /> + <argument index="0" name="name" type="StringName" /> + <argument index="1" name="node" type="AnimationNode" /> + <argument index="2" name="position" type="Vector2" default="Vector2(0, 0)" /> <description> Adds an [AnimationNode] at the given [code]position[/code]. The [code]name[/code] is used to identify the created sub-node later. </description> </method> <method name="connect_node"> - <return type="void"> - </return> - <argument index="0" name="input_node" type="StringName"> - </argument> - <argument index="1" name="input_index" type="int"> - </argument> - <argument index="2" name="output_node" type="StringName"> - </argument> + <return type="void" /> + <argument index="0" name="input_node" type="StringName" /> + <argument index="1" name="input_index" type="int" /> + <argument index="2" name="output_node" type="StringName" /> <description> Connects the output of an [AnimationNode] as input for another [AnimationNode], at the input port specified by [code]input_index[/code]. </description> </method> <method name="disconnect_node"> - <return type="void"> - </return> - <argument index="0" name="input_node" type="StringName"> - </argument> - <argument index="1" name="input_index" type="int"> - </argument> + <return type="void" /> + <argument index="0" name="input_node" type="StringName" /> + <argument index="1" name="input_index" type="int" /> <description> Disconnects the node connected to the specified input. </description> </method> <method name="get_node" qualifiers="const"> - <return type="AnimationNode"> - </return> - <argument index="0" name="name" type="StringName"> - </argument> + <return type="AnimationNode" /> + <argument index="0" name="name" type="StringName" /> <description> Returns the sub-node with the specified [code]name[/code]. </description> </method> <method name="get_node_position" qualifiers="const"> - <return type="Vector2"> - </return> - <argument index="0" name="name" type="StringName"> - </argument> + <return type="Vector2" /> + <argument index="0" name="name" type="StringName" /> <description> Returns the position of the sub-node with the specified [code]name[/code]. </description> </method> <method name="has_node" qualifiers="const"> - <return type="bool"> - </return> - <argument index="0" name="name" type="StringName"> - </argument> + <return type="bool" /> + <argument index="0" name="name" type="StringName" /> <description> Returns [code]true[/code] if a sub-node with specified [code]name[/code] exists. </description> </method> <method name="remove_node"> - <return type="void"> - </return> - <argument index="0" name="name" type="StringName"> - </argument> + <return type="void" /> + <argument index="0" name="name" type="StringName" /> <description> Removes a sub-node. </description> </method> <method name="rename_node"> - <return type="void"> - </return> - <argument index="0" name="name" type="StringName"> - </argument> - <argument index="1" name="new_name" type="StringName"> - </argument> + <return type="void" /> + <argument index="0" name="name" type="StringName" /> + <argument index="1" name="new_name" type="StringName" /> <description> Changes the name of a sub-node. </description> </method> <method name="set_node_position"> - <return type="void"> - </return> - <argument index="0" name="name" type="StringName"> - </argument> - <argument index="1" name="position" type="Vector2"> - </argument> + <return type="void" /> + <argument index="0" name="name" type="StringName" /> + <argument index="1" name="position" type="Vector2" /> <description> Modifies the position of a sub-node. </description> diff --git a/doc/classes/AnimationNodeOneShot.xml b/doc/classes/AnimationNodeOneShot.xml index 65ab363e1f..2ecc0ae07b 100644 --- a/doc/classes/AnimationNodeOneShot.xml +++ b/doc/classes/AnimationNodeOneShot.xml @@ -12,16 +12,13 @@ </tutorials> <methods> <method name="get_mix_mode" qualifiers="const"> - <return type="int" enum="AnimationNodeOneShot.MixMode"> - </return> + <return type="int" enum="AnimationNodeOneShot.MixMode" /> <description> </description> </method> <method name="set_mix_mode"> - <return type="void"> - </return> - <argument index="0" name="mode" type="int" enum="AnimationNodeOneShot.MixMode"> - </argument> + <return type="void" /> + <argument index="0" name="mode" type="int" enum="AnimationNodeOneShot.MixMode" /> <description> </description> </method> diff --git a/doc/classes/AnimationNodeStateMachine.xml b/doc/classes/AnimationNodeStateMachine.xml index 8e070142c4..9921e157f2 100644 --- a/doc/classes/AnimationNodeStateMachine.xml +++ b/doc/classes/AnimationNodeStateMachine.xml @@ -22,217 +22,166 @@ </tutorials> <methods> <method name="add_node"> - <return type="void"> - </return> - <argument index="0" name="name" type="StringName"> - </argument> - <argument index="1" name="node" type="AnimationNode"> - </argument> - <argument index="2" name="position" type="Vector2" default="Vector2(0, 0)"> - </argument> + <return type="void" /> + <argument index="0" name="name" type="StringName" /> + <argument index="1" name="node" type="AnimationNode" /> + <argument index="2" name="position" type="Vector2" default="Vector2(0, 0)" /> <description> Adds a new node to the graph. The [code]position[/code] is used for display in the editor. </description> </method> <method name="add_transition"> - <return type="void"> - </return> - <argument index="0" name="from" type="StringName"> - </argument> - <argument index="1" name="to" type="StringName"> - </argument> - <argument index="2" name="transition" type="AnimationNodeStateMachineTransition"> - </argument> + <return type="void" /> + <argument index="0" name="from" type="StringName" /> + <argument index="1" name="to" type="StringName" /> + <argument index="2" name="transition" type="AnimationNodeStateMachineTransition" /> <description> Adds a transition between the given nodes. </description> </method> <method name="get_end_node" qualifiers="const"> - <return type="String"> - </return> + <return type="String" /> <description> Returns the graph's end node. </description> </method> <method name="get_graph_offset" qualifiers="const"> - <return type="Vector2"> - </return> + <return type="Vector2" /> <description> Returns the draw offset of the graph. Used for display in the editor. </description> </method> <method name="get_node" qualifiers="const"> - <return type="AnimationNode"> - </return> - <argument index="0" name="name" type="StringName"> - </argument> + <return type="AnimationNode" /> + <argument index="0" name="name" type="StringName" /> <description> Returns the animation node with the given name. </description> </method> <method name="get_node_name" qualifiers="const"> - <return type="StringName"> - </return> - <argument index="0" name="node" type="AnimationNode"> - </argument> + <return type="StringName" /> + <argument index="0" name="node" type="AnimationNode" /> <description> Returns the given animation node's name. </description> </method> <method name="get_node_position" qualifiers="const"> - <return type="Vector2"> - </return> - <argument index="0" name="name" type="StringName"> - </argument> + <return type="Vector2" /> + <argument index="0" name="name" type="StringName" /> <description> Returns the given node's coordinates. Used for display in the editor. </description> </method> <method name="get_start_node" qualifiers="const"> - <return type="String"> - </return> + <return type="String" /> <description> Returns the graph's end node. </description> </method> <method name="get_transition" qualifiers="const"> - <return type="AnimationNodeStateMachineTransition"> - </return> - <argument index="0" name="idx" type="int"> - </argument> + <return type="AnimationNodeStateMachineTransition" /> + <argument index="0" name="idx" type="int" /> <description> Returns the given transition. </description> </method> <method name="get_transition_count" qualifiers="const"> - <return type="int"> - </return> + <return type="int" /> <description> Returns the number of connections in the graph. </description> </method> <method name="get_transition_from" qualifiers="const"> - <return type="StringName"> - </return> - <argument index="0" name="idx" type="int"> - </argument> + <return type="StringName" /> + <argument index="0" name="idx" type="int" /> <description> Returns the given transition's start node. </description> </method> <method name="get_transition_to" qualifiers="const"> - <return type="StringName"> - </return> - <argument index="0" name="idx" type="int"> - </argument> + <return type="StringName" /> + <argument index="0" name="idx" type="int" /> <description> Returns the given transition's end node. </description> </method> <method name="has_node" qualifiers="const"> - <return type="bool"> - </return> - <argument index="0" name="name" type="StringName"> - </argument> + <return type="bool" /> + <argument index="0" name="name" type="StringName" /> <description> Returns [code]true[/code] if the graph contains the given node. </description> </method> <method name="has_transition" qualifiers="const"> - <return type="bool"> - </return> - <argument index="0" name="from" type="StringName"> - </argument> - <argument index="1" name="to" type="StringName"> - </argument> + <return type="bool" /> + <argument index="0" name="from" type="StringName" /> + <argument index="1" name="to" type="StringName" /> <description> Returns [code]true[/code] if there is a transition between the given nodes. </description> </method> <method name="remove_node"> - <return type="void"> - </return> - <argument index="0" name="name" type="StringName"> - </argument> + <return type="void" /> + <argument index="0" name="name" type="StringName" /> <description> Deletes the given node from the graph. </description> </method> <method name="remove_transition"> - <return type="void"> - </return> - <argument index="0" name="from" type="StringName"> - </argument> - <argument index="1" name="to" type="StringName"> - </argument> + <return type="void" /> + <argument index="0" name="from" type="StringName" /> + <argument index="1" name="to" type="StringName" /> <description> Deletes the transition between the two specified nodes. </description> </method> <method name="remove_transition_by_index"> - <return type="void"> - </return> - <argument index="0" name="idx" type="int"> - </argument> + <return type="void" /> + <argument index="0" name="idx" type="int" /> <description> Deletes the given transition by index. </description> </method> <method name="rename_node"> - <return type="void"> - </return> - <argument index="0" name="name" type="StringName"> - </argument> - <argument index="1" name="new_name" type="StringName"> - </argument> + <return type="void" /> + <argument index="0" name="name" type="StringName" /> + <argument index="1" name="new_name" type="StringName" /> <description> Renames the given node. </description> </method> <method name="replace_node"> - <return type="void"> - </return> - <argument index="0" name="name" type="StringName"> - </argument> - <argument index="1" name="node" type="AnimationNode"> - </argument> + <return type="void" /> + <argument index="0" name="name" type="StringName" /> + <argument index="1" name="node" type="AnimationNode" /> <description> </description> </method> <method name="set_end_node"> - <return type="void"> - </return> - <argument index="0" name="name" type="StringName"> - </argument> + <return type="void" /> + <argument index="0" name="name" type="StringName" /> <description> Sets the given node as the graph end point. </description> </method> <method name="set_graph_offset"> - <return type="void"> - </return> - <argument index="0" name="offset" type="Vector2"> - </argument> + <return type="void" /> + <argument index="0" name="offset" type="Vector2" /> <description> Sets the draw offset of the graph. Used for display in the editor. </description> </method> <method name="set_node_position"> - <return type="void"> - </return> - <argument index="0" name="name" type="StringName"> - </argument> - <argument index="1" name="position" type="Vector2"> - </argument> + <return type="void" /> + <argument index="0" name="name" type="StringName" /> + <argument index="1" name="position" type="Vector2" /> <description> Sets the node's coordinates. Used for display in the editor. </description> </method> <method name="set_start_node"> - <return type="void"> - </return> - <argument index="0" name="name" type="StringName"> - </argument> + <return type="void" /> + <argument index="0" name="name" type="StringName" /> <description> Sets the given node as the graph start point. </description> diff --git a/doc/classes/AnimationNodeStateMachinePlayback.xml b/doc/classes/AnimationNodeStateMachinePlayback.xml index c8468f9c8f..5c11adfaf0 100644 --- a/doc/classes/AnimationNodeStateMachinePlayback.xml +++ b/doc/classes/AnimationNodeStateMachinePlayback.xml @@ -22,60 +22,50 @@ </tutorials> <methods> <method name="get_current_length" qualifiers="const"> - <return type="float"> - </return> + <return type="float" /> <description> </description> </method> <method name="get_current_node" qualifiers="const"> - <return type="StringName"> - </return> + <return type="StringName" /> <description> Returns the currently playing animation state. </description> </method> <method name="get_current_play_position" qualifiers="const"> - <return type="float"> - </return> + <return type="float" /> <description> Returns the playback position within the current animation state. </description> </method> <method name="get_travel_path" qualifiers="const"> - <return type="PackedStringArray"> - </return> + <return type="PackedStringArray" /> <description> Returns the current travel path as computed internally by the A* algorithm. </description> </method> <method name="is_playing" qualifiers="const"> - <return type="bool"> - </return> + <return type="bool" /> <description> Returns [code]true[/code] if an animation is playing. </description> </method> <method name="start"> - <return type="void"> - </return> - <argument index="0" name="node" type="StringName"> - </argument> + <return type="void" /> + <argument index="0" name="node" type="StringName" /> <description> Starts playing the given animation. </description> </method> <method name="stop"> - <return type="void"> - </return> + <return type="void" /> <description> Stops the currently playing animation. </description> </method> <method name="travel"> - <return type="void"> - </return> - <argument index="0" name="to_node" type="StringName"> - </argument> + <return type="void" /> + <argument index="0" name="to_node" type="StringName" /> <description> Transitions from the current state to another one, following the shortest path. </description> diff --git a/doc/classes/AnimationNodeTransition.xml b/doc/classes/AnimationNodeTransition.xml index 73c7006768..8c859e43be 100644 --- a/doc/classes/AnimationNodeTransition.xml +++ b/doc/classes/AnimationNodeTransition.xml @@ -13,38 +13,28 @@ </tutorials> <methods> <method name="get_input_caption" qualifiers="const"> - <return type="String"> - </return> - <argument index="0" name="input" type="int"> - </argument> + <return type="String" /> + <argument index="0" name="input" type="int" /> <description> </description> </method> <method name="is_input_set_as_auto_advance" qualifiers="const"> - <return type="bool"> - </return> - <argument index="0" name="input" type="int"> - </argument> + <return type="bool" /> + <argument index="0" name="input" type="int" /> <description> </description> </method> <method name="set_input_as_auto_advance"> - <return type="void"> - </return> - <argument index="0" name="input" type="int"> - </argument> - <argument index="1" name="enable" type="bool"> - </argument> + <return type="void" /> + <argument index="0" name="input" type="int" /> + <argument index="1" name="enable" type="bool" /> <description> </description> </method> <method name="set_input_caption"> - <return type="void"> - </return> - <argument index="0" name="input" type="int"> - </argument> - <argument index="1" name="caption" type="String"> - </argument> + <return type="void" /> + <argument index="0" name="input" type="int" /> + <argument index="1" name="caption" type="String" /> <description> </description> </method> diff --git a/doc/classes/AnimationPlayer.xml b/doc/classes/AnimationPlayer.xml index 8a94eee54c..1ef9d81d02 100644 --- a/doc/classes/AnimationPlayer.xml +++ b/doc/classes/AnimationPlayer.xml @@ -15,136 +15,106 @@ </tutorials> <methods> <method name="add_animation"> - <return type="int" enum="Error"> - </return> - <argument index="0" name="name" type="StringName"> - </argument> - <argument index="1" name="animation" type="Animation"> - </argument> + <return type="int" enum="Error" /> + <argument index="0" name="name" type="StringName" /> + <argument index="1" name="animation" type="Animation" /> <description> Adds [code]animation[/code] to the player accessible with the key [code]name[/code]. </description> </method> <method name="advance"> - <return type="void"> - </return> - <argument index="0" name="delta" type="float"> - </argument> + <return type="void" /> + <argument index="0" name="delta" type="float" /> <description> Shifts position in the animation timeline and immediately updates the animation. [code]delta[/code] is the time in seconds to shift. Events between the current frame and [code]delta[/code] are handled. </description> </method> <method name="animation_get_next" qualifiers="const"> - <return type="StringName"> - </return> - <argument index="0" name="anim_from" type="StringName"> - </argument> + <return type="StringName" /> + <argument index="0" name="anim_from" type="StringName" /> <description> Returns the name of the next animation in the queue. </description> </method> <method name="animation_set_next"> - <return type="void"> - </return> - <argument index="0" name="anim_from" type="StringName"> - </argument> - <argument index="1" name="anim_to" type="StringName"> - </argument> + <return type="void" /> + <argument index="0" name="anim_from" type="StringName" /> + <argument index="1" name="anim_to" type="StringName" /> <description> Triggers the [code]anim_to[/code] animation when the [code]anim_from[/code] animation completes. </description> </method> <method name="clear_caches"> - <return type="void"> - </return> + <return type="void" /> <description> [AnimationPlayer] caches animated nodes. It may not notice if a node disappears; [method clear_caches] forces it to update the cache again. </description> </method> <method name="clear_queue"> - <return type="void"> - </return> + <return type="void" /> <description> Clears all queued, unplayed animations. </description> </method> <method name="find_animation" qualifiers="const"> - <return type="StringName"> - </return> - <argument index="0" name="animation" type="Animation"> - </argument> + <return type="StringName" /> + <argument index="0" name="animation" type="Animation" /> <description> Returns the name of [code]animation[/code] or an empty string if not found. </description> </method> <method name="get_animation" qualifiers="const"> - <return type="Animation"> - </return> - <argument index="0" name="name" type="StringName"> - </argument> + <return type="Animation" /> + <argument index="0" name="name" type="StringName" /> <description> Returns the [Animation] with key [code]name[/code] or [code]null[/code] if not found. </description> </method> <method name="get_animation_list" qualifiers="const"> - <return type="PackedStringArray"> - </return> + <return type="PackedStringArray" /> <description> Returns the list of stored animation names. </description> </method> <method name="get_blend_time" qualifiers="const"> - <return type="float"> - </return> - <argument index="0" name="anim_from" type="StringName"> - </argument> - <argument index="1" name="anim_to" type="StringName"> - </argument> + <return type="float" /> + <argument index="0" name="anim_from" type="StringName" /> + <argument index="1" name="anim_to" type="StringName" /> <description> Gets the blend time (in seconds) between two animations, referenced by their names. </description> </method> <method name="get_playing_speed" qualifiers="const"> - <return type="float"> - </return> + <return type="float" /> <description> Gets the actual playing speed of current animation or 0 if not playing. This speed is the [member playback_speed] property multiplied by [code]custom_speed[/code] argument specified when calling the [method play] method. </description> </method> <method name="get_queue"> - <return type="PackedStringArray"> - </return> + <return type="PackedStringArray" /> <description> Returns a list of the animation names that are currently queued to play. </description> </method> <method name="has_animation" qualifiers="const"> - <return type="bool"> - </return> - <argument index="0" name="name" type="StringName"> - </argument> + <return type="bool" /> + <argument index="0" name="name" type="StringName" /> <description> Returns [code]true[/code] if the [AnimationPlayer] stores an [Animation] with key [code]name[/code]. </description> </method> <method name="is_playing" qualifiers="const"> - <return type="bool"> - </return> + <return type="bool" /> <description> Returns [code]true[/code] if playing an animation. </description> </method> <method name="play"> - <return type="void"> - </return> - <argument index="0" name="name" type="StringName" default=""""> - </argument> - <argument index="1" name="custom_blend" type="float" default="-1"> - </argument> - <argument index="2" name="custom_speed" type="float" default="1.0"> - </argument> - <argument index="3" name="from_end" type="bool" default="false"> - </argument> + <return type="void" /> + <argument index="0" name="name" type="StringName" default="""" /> + <argument index="1" name="custom_blend" type="float" default="-1" /> + <argument index="2" name="custom_speed" type="float" default="1.0" /> + <argument index="3" name="from_end" type="bool" default="false" /> <description> Plays the animation with key [code]name[/code]. Custom blend times and speed can be set. If [code]custom_speed[/code] is negative and [code]from_end[/code] is [code]true[/code], the animation will play backwards (which is equivalent to calling [method play_backwards]). The [AnimationPlayer] keeps track of its current or last played animation with [member assigned_animation]. If this method is called with that same animation [code]name[/code], or with no [code]name[/code] parameter, the assigned animation will resume playing if it was paused, or restart if it was stopped (see [method stop] for both pause and stop). If the animation was already playing, it will keep playing. @@ -152,76 +122,57 @@ </description> </method> <method name="play_backwards"> - <return type="void"> - </return> - <argument index="0" name="name" type="StringName" default=""""> - </argument> - <argument index="1" name="custom_blend" type="float" default="-1"> - </argument> + <return type="void" /> + <argument index="0" name="name" type="StringName" default="""" /> + <argument index="1" name="custom_blend" type="float" default="-1" /> <description> Plays the animation with key [code]name[/code] in reverse. This method is a shorthand for [method play] with [code]custom_speed = -1.0[/code] and [code]from_end = true[/code], so see its description for more information. </description> </method> <method name="queue"> - <return type="void"> - </return> - <argument index="0" name="name" type="StringName"> - </argument> + <return type="void" /> + <argument index="0" name="name" type="StringName" /> <description> Queues an animation for playback once the current one is done. [b]Note:[/b] If a looped animation is currently playing, the queued animation will never play unless the looped animation is stopped somehow. </description> </method> <method name="remove_animation"> - <return type="void"> - </return> - <argument index="0" name="name" type="StringName"> - </argument> + <return type="void" /> + <argument index="0" name="name" type="StringName" /> <description> Removes the animation with key [code]name[/code]. </description> </method> <method name="rename_animation"> - <return type="void"> - </return> - <argument index="0" name="name" type="StringName"> - </argument> - <argument index="1" name="newname" type="StringName"> - </argument> + <return type="void" /> + <argument index="0" name="name" type="StringName" /> + <argument index="1" name="newname" type="StringName" /> <description> Renames an existing animation with key [code]name[/code] to [code]newname[/code]. </description> </method> <method name="seek"> - <return type="void"> - </return> - <argument index="0" name="seconds" type="float"> - </argument> - <argument index="1" name="update" type="bool" default="false"> - </argument> + <return type="void" /> + <argument index="0" name="seconds" type="float" /> + <argument index="1" name="update" type="bool" default="false" /> <description> Seeks the animation to the [code]seconds[/code] point in time (in seconds). If [code]update[/code] is [code]true[/code], the animation updates too, otherwise it updates at process time. Events between the current frame and [code]seconds[/code] are skipped. </description> </method> <method name="set_blend_time"> - <return type="void"> - </return> - <argument index="0" name="anim_from" type="StringName"> - </argument> - <argument index="1" name="anim_to" type="StringName"> - </argument> - <argument index="2" name="sec" type="float"> - </argument> + <return type="void" /> + <argument index="0" name="anim_from" type="StringName" /> + <argument index="1" name="anim_to" type="StringName" /> + <argument index="2" name="sec" type="float" /> <description> Specifies a blend time (in seconds) between two animations, referenced by their names. </description> </method> <method name="stop"> - <return type="void"> - </return> - <argument index="0" name="reset" type="bool" default="true"> - </argument> + <return type="void" /> + <argument index="0" name="reset" type="bool" default="true" /> <description> Stops or pauses the currently playing animation. If [code]reset[/code] is [code]true[/code], the animation position is reset to [code]0[/code] and the playback speed is reset to [code]1.0[/code]. If [code]reset[/code] is [code]false[/code], the [member current_animation_position] will be kept and calling [method play] or [method play_backwards] without arguments or with the same animation name as [member assigned_animation] will resume the animation. @@ -270,25 +221,21 @@ </members> <signals> <signal name="animation_changed"> - <argument index="0" name="old_name" type="StringName"> - </argument> - <argument index="1" name="new_name" type="StringName"> - </argument> + <argument index="0" name="old_name" type="StringName" /> + <argument index="1" name="new_name" type="StringName" /> <description> Emitted when a queued animation plays after the previous animation was finished. See [method queue]. [b]Note:[/b] The signal is not emitted when the animation is changed via [method play] or from [AnimationTree]. </description> </signal> <signal name="animation_finished"> - <argument index="0" name="anim_name" type="StringName"> - </argument> + <argument index="0" name="anim_name" type="StringName" /> <description> Notifies when an animation finished playing. </description> </signal> <signal name="animation_started"> - <argument index="0" name="anim_name" type="StringName"> - </argument> + <argument index="0" name="anim_name" type="StringName" /> <description> Notifies when an animation starts playing. </description> diff --git a/doc/classes/AnimationTree.xml b/doc/classes/AnimationTree.xml index af7d8d73e8..843dd5a6d1 100644 --- a/doc/classes/AnimationTree.xml +++ b/doc/classes/AnimationTree.xml @@ -7,33 +7,27 @@ Note: When linked with an [AnimationPlayer], several properties and methods of the corresponding [AnimationPlayer] will not function as expected. Playback and transitions should be handled using only the [AnimationTree] and its constituent [AnimationNode](s). The [AnimationPlayer] node should be used solely for adding, deleting, and editing animations. </description> <tutorials> - <link title="AnimationTree">https://docs.godotengine.org/en/latest/tutorials/animation/animation_tree.html</link> + <link title="Using AnimationTree">https://docs.godotengine.org/en/latest/tutorials/animation/animation_tree.html</link> <link title="Third Person Shooter Demo">https://godotengine.org/asset-library/asset/678</link> </tutorials> <methods> <method name="advance"> - <return type="void"> - </return> - <argument index="0" name="delta" type="float"> - </argument> + <return type="void" /> + <argument index="0" name="delta" type="float" /> <description> Manually advance the animations by the specified time (in seconds). </description> </method> <method name="get_root_motion_transform" qualifiers="const"> - <return type="Transform3D"> - </return> + <return type="Transform3D" /> <description> - Retrieve the motion of the [member root_motion_track] as a [Transform3D] that can be used elsewhere. If [member root_motion_track] is not a path to a track of type [constant Animation.TYPE_TRANSFORM3D], returns an identity transformation. + Retrieve the motion of the [member root_motion_track] as a [Transform3D] that can be used elsewhere. If [member root_motion_track] is not a path to a track of type [constant Animation.TYPE_TRANSFORM3D], returns an identity transformation. See also [member root_motion_track] and [RootMotionView]. </description> </method> <method name="rename_parameter"> - <return type="void"> - </return> - <argument index="0" name="old_name" type="String"> - </argument> - <argument index="1" name="new_name" type="String"> - </argument> + <return type="void" /> + <argument index="0" name="old_name" type="String" /> + <argument index="1" name="new_name" type="String" /> <description> </description> </method> @@ -50,7 +44,7 @@ </member> <member name="root_motion_track" type="NodePath" setter="set_root_motion_track" getter="get_root_motion_track" default="NodePath("")"> The path to the Animation track used for root motion. Paths must be valid scene-tree paths to a node, and must be specified starting from the parent node of the node that will reproduce the animation. To specify a track that controls properties or bones, append its name after the path, separated by [code]":"[/code]. For example, [code]"character/skeleton:ankle"[/code] or [code]"character/mesh:transform/local"[/code]. - If the track has type [constant Animation.TYPE_TRANSFORM3D], the transformation will be cancelled visually, and the animation will appear to stay in place. + If the track has type [constant Animation.TYPE_TRANSFORM3D], the transformation will be cancelled visually, and the animation will appear to stay in place. See also [method get_root_motion_transform] and [RootMotionView]. </member> <member name="tree_root" type="AnimationNode" setter="set_tree_root" getter="get_tree_root"> The root animation node of this [AnimationTree]. See [AnimationNode]. diff --git a/doc/classes/Area2D.xml b/doc/classes/Area2D.xml index f52c810ad2..25f67f0571 100644 --- a/doc/classes/Area2D.xml +++ b/doc/classes/Area2D.xml @@ -14,38 +14,32 @@ </tutorials> <methods> <method name="get_overlapping_areas" qualifiers="const"> - <return type="Area2D[]"> - </return> + <return type="Area2D[]" /> <description> Returns a list of intersecting [Area2D]s. For performance reasons (collisions are all processed at the same time) this list is modified once during the physics step, not immediately after objects are moved. Consider using signals instead. </description> </method> <method name="get_overlapping_bodies" qualifiers="const"> - <return type="Node2D[]"> - </return> + <return type="Node2D[]" /> <description> Returns a list of intersecting [PhysicsBody2D]s. For performance reasons (collisions are all processed at the same time) this list is modified once during the physics step, not immediately after objects are moved. Consider using signals instead. </description> </method> <method name="overlaps_area" qualifiers="const"> - <return type="bool"> - </return> - <argument index="0" name="area" type="Node"> - </argument> + <return type="bool" /> + <argument index="0" name="area" type="Node" /> <description> If [code]true[/code], the given area overlaps the Area2D. - [b]Note:[/b] The result of this test is not immediate after moving objects. For performance, list of overlaps is updated once per frame and before the physics step. Consider using signals instead. + [b]Note:[/b] The result of this test is not immediate after moving objects. For performance, the list of overlaps is updated once per frame and before the physics step. Consider using signals instead. </description> </method> <method name="overlaps_body" qualifiers="const"> - <return type="bool"> - </return> - <argument index="0" name="body" type="Node"> - </argument> + <return type="bool" /> + <argument index="0" name="body" type="Node" /> <description> If [code]true[/code], the given physics body overlaps the Area2D. [b]Note:[/b] The result of this test is not immediate after moving objects. For performance, list of overlaps is updated once per frame and before the physics step. Consider using signals instead. - The [code]body[/code] argument can either be a [PhysicsBody2D] or a [TileMap] instance (while TileMaps are not physics body themselves, they register their tiles with collision shapes as a virtual physics body). + The [code]body[/code] argument can either be a [PhysicsBody2D] or a [TileMap] instance (while TileMaps are not physics bodies themselves, they register their tiles with collision shapes as a virtual physics body). </description> </method> </methods> @@ -91,30 +85,24 @@ </members> <signals> <signal name="area_entered"> - <argument index="0" name="area" type="Area2D"> - </argument> + <argument index="0" name="area" type="Area2D" /> <description> Emitted when another Area2D enters this Area2D. Requires [member monitoring] to be set to [code]true[/code]. [code]area[/code] the other Area2D. </description> </signal> <signal name="area_exited"> - <argument index="0" name="area" type="Area2D"> - </argument> + <argument index="0" name="area" type="Area2D" /> <description> Emitted when another Area2D exits this Area2D. Requires [member monitoring] to be set to [code]true[/code]. [code]area[/code] the other Area2D. </description> </signal> <signal name="area_shape_entered"> - <argument index="0" name="area_rid" type="RID"> - </argument> - <argument index="1" name="area" type="Area2D"> - </argument> - <argument index="2" name="area_shape" type="int"> - </argument> - <argument index="3" name="local_shape" type="int"> - </argument> + <argument index="0" name="area_rid" type="RID" /> + <argument index="1" name="area" type="Area2D" /> + <argument index="2" name="area_shape" type="int" /> + <argument index="3" name="local_shape" type="int" /> <description> Emitted when one of another Area2D's [Shape2D]s enters one of this Area2D's [Shape2D]s. Requires [member monitoring] to be set to [code]true[/code]. [code]area_id[/code] the [RID] of the other Area2D's [CollisionObject2D] used by the [PhysicsServer2D]. @@ -124,14 +112,10 @@ </description> </signal> <signal name="area_shape_exited"> - <argument index="0" name="area_rid" type="RID"> - </argument> - <argument index="1" name="area" type="Area2D"> - </argument> - <argument index="2" name="area_shape" type="int"> - </argument> - <argument index="3" name="local_shape" type="int"> - </argument> + <argument index="0" name="area_rid" type="RID" /> + <argument index="1" name="area" type="Area2D" /> + <argument index="2" name="area_shape" type="int" /> + <argument index="3" name="local_shape" type="int" /> <description> Emitted when one of another Area2D's [Shape2D]s exits one of this Area2D's [Shape2D]s. Requires [member monitoring] to be set to [code]true[/code]. [code]area_id[/code] the [RID] of the other Area2D's [CollisionObject2D] used by the [PhysicsServer2D]. @@ -141,30 +125,24 @@ </description> </signal> <signal name="body_entered"> - <argument index="0" name="body" type="Node2D"> - </argument> + <argument index="0" name="body" type="Node2D" /> <description> Emitted when a [PhysicsBody2D] or [TileMap] enters this Area2D. Requires [member monitoring] to be set to [code]true[/code]. [TileMap]s are detected if the [TileSet] has Collision [Shape2D]s. [code]body[/code] the [Node], if it exists in the tree, of the other [PhysicsBody2D] or [TileMap]. </description> </signal> <signal name="body_exited"> - <argument index="0" name="body" type="Node2D"> - </argument> + <argument index="0" name="body" type="Node2D" /> <description> Emitted when a [PhysicsBody2D] or [TileMap] exits this Area2D. Requires [member monitoring] to be set to [code]true[/code]. [TileMap]s are detected if the [TileSet] has Collision [Shape2D]s. [code]body[/code] the [Node], if it exists in the tree, of the other [PhysicsBody2D] or [TileMap]. </description> </signal> <signal name="body_shape_entered"> - <argument index="0" name="body_rid" type="RID"> - </argument> - <argument index="1" name="body" type="Node2D"> - </argument> - <argument index="2" name="body_shape" type="int"> - </argument> - <argument index="3" name="local_shape" type="int"> - </argument> + <argument index="0" name="body_rid" type="RID" /> + <argument index="1" name="body" type="Node2D" /> + <argument index="2" name="body_shape" type="int" /> + <argument index="3" name="local_shape" type="int" /> <description> Emitted when one of a [PhysicsBody2D] or [TileMap]'s [Shape2D]s enters one of this Area2D's [Shape2D]s. Requires [member monitoring] to be set to [code]true[/code]. [TileMap]s are detected if the [TileSet] has Collision [Shape2D]s. [code]body_id[/code] the [RID] of the [PhysicsBody2D] or [TileSet]'s [CollisionObject2D] used by the [PhysicsServer2D]. @@ -174,14 +152,10 @@ </description> </signal> <signal name="body_shape_exited"> - <argument index="0" name="body_rid" type="RID"> - </argument> - <argument index="1" name="body" type="Node2D"> - </argument> - <argument index="2" name="body_shape" type="int"> - </argument> - <argument index="3" name="local_shape" type="int"> - </argument> + <argument index="0" name="body_rid" type="RID" /> + <argument index="1" name="body" type="Node2D" /> + <argument index="2" name="body_shape" type="int" /> + <argument index="3" name="local_shape" type="int" /> <description> Emitted when one of a [PhysicsBody2D] or [TileMap]'s [Shape2D]s exits one of this Area2D's [Shape2D]s. Requires [member monitoring] to be set to [code]true[/code]. [TileMap]s are detected if the [TileSet] has Collision [Shape2D]s. [code]body_id[/code] the [RID] of the [PhysicsBody2D] or [TileSet]'s [CollisionObject2D] used by the [PhysicsServer2D]. diff --git a/doc/classes/Area3D.xml b/doc/classes/Area3D.xml index cc31b6c203..2180196bb5 100644 --- a/doc/classes/Area3D.xml +++ b/doc/classes/Area3D.xml @@ -12,34 +12,28 @@ </tutorials> <methods> <method name="get_overlapping_areas" qualifiers="const"> - <return type="Area3D[]"> - </return> + <return type="Area3D[]" /> <description> Returns a list of intersecting [Area3D]s. For performance reasons (collisions are all processed at the same time) this list is modified once during the physics step, not immediately after objects are moved. Consider using signals instead. </description> </method> <method name="get_overlapping_bodies" qualifiers="const"> - <return type="Node3D[]"> - </return> + <return type="Node3D[]" /> <description> Returns a list of intersecting [PhysicsBody3D]s. For performance reasons (collisions are all processed at the same time) this list is modified once during the physics step, not immediately after objects are moved. Consider using signals instead. </description> </method> <method name="overlaps_area" qualifiers="const"> - <return type="bool"> - </return> - <argument index="0" name="area" type="Node"> - </argument> + <return type="bool" /> + <argument index="0" name="area" type="Node" /> <description> If [code]true[/code], the given area overlaps the Area3D. [b]Note:[/b] The result of this test is not immediate after moving objects. For performance, list of overlaps is updated once per frame and before the physics step. Consider using signals instead. </description> </method> <method name="overlaps_body" qualifiers="const"> - <return type="bool"> - </return> - <argument index="0" name="body" type="Node"> - </argument> + <return type="bool" /> + <argument index="0" name="body" type="Node" /> <description> If [code]true[/code], the given physics body overlaps the Area3D. [b]Note:[/b] The result of this test is not immediate after moving objects. For performance, list of overlaps is updated once per frame and before the physics step. Consider using signals instead. @@ -101,30 +95,24 @@ </members> <signals> <signal name="area_entered"> - <argument index="0" name="area" type="Area3D"> - </argument> + <argument index="0" name="area" type="Area3D" /> <description> Emitted when another Area3D enters this Area3D. Requires [member monitoring] to be set to [code]true[/code]. [code]area[/code] the other Area3D. </description> </signal> <signal name="area_exited"> - <argument index="0" name="area" type="Area3D"> - </argument> + <argument index="0" name="area" type="Area3D" /> <description> Emitted when another Area3D exits this Area3D. Requires [member monitoring] to be set to [code]true[/code]. [code]area[/code] the other Area3D. </description> </signal> <signal name="area_shape_entered"> - <argument index="0" name="area_rid" type="RID"> - </argument> - <argument index="1" name="area" type="Area3D"> - </argument> - <argument index="2" name="area_shape" type="int"> - </argument> - <argument index="3" name="local_shape" type="int"> - </argument> + <argument index="0" name="area_rid" type="RID" /> + <argument index="1" name="area" type="Area3D" /> + <argument index="2" name="area_shape" type="int" /> + <argument index="3" name="local_shape" type="int" /> <description> Emitted when one of another Area3D's [Shape3D]s enters one of this Area3D's [Shape3D]s. Requires [member monitoring] to be set to [code]true[/code]. [code]area_id[/code] the [RID] of the other Area3D's [CollisionObject3D] used by the [PhysicsServer3D]. @@ -134,14 +122,10 @@ </description> </signal> <signal name="area_shape_exited"> - <argument index="0" name="area_rid" type="RID"> - </argument> - <argument index="1" name="area" type="Area3D"> - </argument> - <argument index="2" name="area_shape" type="int"> - </argument> - <argument index="3" name="local_shape" type="int"> - </argument> + <argument index="0" name="area_rid" type="RID" /> + <argument index="1" name="area" type="Area3D" /> + <argument index="2" name="area_shape" type="int" /> + <argument index="3" name="local_shape" type="int" /> <description> Emitted when one of another Area3D's [Shape3D]s enters one of this Area3D's [Shape3D]s. Requires [member monitoring] to be set to [code]true[/code]. [code]area_id[/code] the [RID] of the other Area3D's [CollisionObject3D] used by the [PhysicsServer3D]. @@ -151,30 +135,24 @@ </description> </signal> <signal name="body_entered"> - <argument index="0" name="body" type="Node3D"> - </argument> + <argument index="0" name="body" type="Node3D" /> <description> Emitted when a [PhysicsBody3D] or [GridMap] enters this Area3D. Requires [member monitoring] to be set to [code]true[/code]. [GridMap]s are detected if the [MeshLibrary] has Collision [Shape3D]s. [code]body[/code] the [Node], if it exists in the tree, of the other [PhysicsBody3D] or [GridMap]. </description> </signal> <signal name="body_exited"> - <argument index="0" name="body" type="Node3D"> - </argument> + <argument index="0" name="body" type="Node3D" /> <description> Emitted when a [PhysicsBody3D] or [GridMap] exits this Area3D. Requires [member monitoring] to be set to [code]true[/code]. [GridMap]s are detected if the [MeshLibrary] has Collision [Shape3D]s. [code]body[/code] the [Node], if it exists in the tree, of the other [PhysicsBody3D] or [GridMap]. </description> </signal> <signal name="body_shape_entered"> - <argument index="0" name="body_rid" type="RID"> - </argument> - <argument index="1" name="body" type="Node3D"> - </argument> - <argument index="2" name="body_shape" type="int"> - </argument> - <argument index="3" name="local_shape" type="int"> - </argument> + <argument index="0" name="body_rid" type="RID" /> + <argument index="1" name="body" type="Node3D" /> + <argument index="2" name="body_shape" type="int" /> + <argument index="3" name="local_shape" type="int" /> <description> Emitted when one of a [PhysicsBody3D] or [GridMap]'s [Shape3D]s enters one of this Area3D's [Shape3D]s. Requires [member monitoring] to be set to [code]true[/code]. [GridMap]s are detected if the [MeshLibrary] has Collision [Shape3D]s. [code]body_id[/code] the [RID] of the [PhysicsBody3D] or [MeshLibrary]'s [CollisionObject3D] used by the [PhysicsServer3D]. @@ -184,14 +162,10 @@ </description> </signal> <signal name="body_shape_exited"> - <argument index="0" name="body_rid" type="RID"> - </argument> - <argument index="1" name="body" type="Node3D"> - </argument> - <argument index="2" name="body_shape" type="int"> - </argument> - <argument index="3" name="local_shape" type="int"> - </argument> + <argument index="0" name="body_rid" type="RID" /> + <argument index="1" name="body" type="Node3D" /> + <argument index="2" name="body_shape" type="int" /> + <argument index="3" name="local_shape" type="int" /> <description> Emitted when one of a [PhysicsBody3D] or [GridMap]'s [Shape3D]s enters one of this Area3D's [Shape3D]s. Requires [member monitoring] to be set to [code]true[/code]. [GridMap]s are detected if the [MeshLibrary] has Collision [Shape3D]s. [code]body_id[/code] the [RID] of the [PhysicsBody3D] or [MeshLibrary]'s [CollisionObject3D] used by the [PhysicsServer3D]. diff --git a/doc/classes/Array.xml b/doc/classes/Array.xml index 543ec096c7..7767a1028d 100644 --- a/doc/classes/Array.xml +++ b/doc/classes/Array.xml @@ -1,10 +1,10 @@ <?xml version="1.0" encoding="UTF-8" ?> <class name="Array" version="4.0"> <brief_description> - Generic array datatype. + A generic array datatype. </brief_description> <description> - Generic array which can contain several elements of any type, accessible by a numerical index starting at 0. Negative indices can be used to count from the back, like in Python (-1 is the last element, -2 the second to last, etc.). + A generic array that can contain several elements of any type, accessible by a numerical index starting at 0. Negative indices can be used to count from the back, like in Python (-1 is the last element, -2 is the second to last, etc.). [b]Example:[/b] [codeblocks] [gdscript] @@ -39,123 +39,98 @@ [/csharp] [/codeblocks] [b]Note:[/b] Concatenating with the [code]+=[/code] operator will create a new array, which has a cost. If you want to append another array to an existing array, [method append_array] is more efficient. - [b]Note:[/b] Arrays are always passed by reference. To get a copy of an array which can be modified independently of the original array, use [method duplicate]. + [b]Note:[/b] Arrays are always passed by reference. To get a copy of an array that can be modified independently of the original array, use [method duplicate]. [b]Note:[/b] When declaring an array with [code]const[/code], the array itself can still be mutated by defining the values at individual indices or pushing/removing elements. Using [code]const[/code] will only prevent assigning the constant with another value after it was initialized. </description> <tutorials> </tutorials> <methods> <method name="Array" qualifiers="constructor"> - <return type="Array"> - </return> + <return type="Array" /> <description> Constructs an empty [Array]. </description> </method> <method name="Array" qualifiers="constructor"> - <return type="Array"> - </return> - <argument index="0" name="from" type="Array"> - </argument> + <return type="Array" /> + <argument index="0" name="from" type="Array" /> <description> Constructs an [Array] as a copy of the given [Array]. </description> </method> <method name="Array" qualifiers="constructor"> - <return type="Array"> - </return> - <argument index="0" name="from" type="PackedByteArray"> - </argument> + <return type="Array" /> + <argument index="0" name="from" type="PackedByteArray" /> <description> Constructs an array from a [PackedByteArray]. </description> </method> <method name="Array" qualifiers="constructor"> - <return type="Array"> - </return> - <argument index="0" name="from" type="PackedColorArray"> - </argument> + <return type="Array" /> + <argument index="0" name="from" type="PackedColorArray" /> <description> Constructs an array from a [PackedColorArray]. </description> </method> <method name="Array" qualifiers="constructor"> - <return type="Array"> - </return> - <argument index="0" name="from" type="PackedFloat32Array"> - </argument> + <return type="Array" /> + <argument index="0" name="from" type="PackedFloat32Array" /> <description> Constructs an array from a [PackedFloat32Array]. </description> </method> <method name="Array" qualifiers="constructor"> - <return type="Array"> - </return> - <argument index="0" name="from" type="PackedFloat64Array"> - </argument> + <return type="Array" /> + <argument index="0" name="from" type="PackedFloat64Array" /> <description> Constructs an array from a [PackedFloat64Array]. </description> </method> <method name="Array" qualifiers="constructor"> - <return type="Array"> - </return> - <argument index="0" name="from" type="PackedInt32Array"> - </argument> + <return type="Array" /> + <argument index="0" name="from" type="PackedInt32Array" /> <description> Constructs an array from a [PackedInt32Array]. </description> </method> <method name="Array" qualifiers="constructor"> - <return type="Array"> - </return> - <argument index="0" name="from" type="PackedInt64Array"> - </argument> + <return type="Array" /> + <argument index="0" name="from" type="PackedInt64Array" /> <description> Constructs an array from a [PackedInt64Array]. </description> </method> <method name="Array" qualifiers="constructor"> - <return type="Array"> - </return> - <argument index="0" name="from" type="PackedStringArray"> - </argument> + <return type="Array" /> + <argument index="0" name="from" type="PackedStringArray" /> <description> Constructs an array from a [PackedStringArray]. </description> </method> <method name="Array" qualifiers="constructor"> - <return type="Array"> - </return> - <argument index="0" name="from" type="PackedVector2Array"> - </argument> + <return type="Array" /> + <argument index="0" name="from" type="PackedVector2Array" /> <description> Constructs an array from a [PackedVector2Array]. </description> </method> <method name="Array" qualifiers="constructor"> - <return type="Array"> - </return> - <argument index="0" name="from" type="PackedVector3Array"> - </argument> + <return type="Array" /> + <argument index="0" name="from" type="PackedVector3Array" /> <description> Constructs an array from a [PackedVector3Array]. </description> </method> <method name="append"> - <return type="void"> - </return> - <argument index="0" name="value" type="Variant"> - </argument> + <return type="void" /> + <argument index="0" name="value" type="Variant" /> <description> Appends an element at the end of the array (alias of [method push_back]). </description> </method> <method name="append_array"> - <return type="void"> - </return> - <argument index="0" name="array" type="Array"> - </argument> + <return type="void" /> + <argument index="0" name="array" type="Array" /> <description> Appends another array at the end of this array. [codeblock] @@ -167,70 +142,55 @@ </description> </method> <method name="back" qualifiers="const"> - <return type="Variant"> - </return> + <return type="Variant" /> <description> Returns the last element of the array. Prints an error and returns [code]null[/code] if the array is empty. [b]Note:[/b] Calling this function is not the same as writing [code]array[-1][/code]. If the array is empty, accessing by index will pause project execution when running from the editor. </description> </method> <method name="bsearch"> - <return type="int"> - </return> - <argument index="0" name="value" type="Variant"> - </argument> - <argument index="1" name="before" type="bool" default="true"> - </argument> + <return type="int" /> + <argument index="0" name="value" type="Variant" /> + <argument index="1" name="before" type="bool" default="true" /> <description> Finds the index of an existing value (or the insertion index that maintains sorting order, if the value is not yet present in the array) using binary search. Optionally, a [code]before[/code] specifier can be passed. If [code]false[/code], the returned index comes after all existing entries of the value in the array. [b]Note:[/b] Calling [method bsearch] on an unsorted array results in unexpected behavior. </description> </method> <method name="bsearch_custom"> - <return type="int"> - </return> - <argument index="0" name="value" type="Variant"> - </argument> - <argument index="1" name="func" type="Callable"> - </argument> - <argument index="2" name="before" type="bool" default="true"> - </argument> + <return type="int" /> + <argument index="0" name="value" type="Variant" /> + <argument index="1" name="func" type="Callable" /> + <argument index="2" name="before" type="bool" default="true" /> <description> Finds the index of an existing value (or the insertion index that maintains sorting order, if the value is not yet present in the array) using binary search and a custom comparison method. Optionally, a [code]before[/code] specifier can be passed. If [code]false[/code], the returned index comes after all existing entries of the value in the array. The custom method receives two arguments (an element from the array and the value searched for) and must return [code]true[/code] if the first argument is less than the second, and return [code]false[/code] otherwise. [b]Note:[/b] Calling [method bsearch_custom] on an unsorted array results in unexpected behavior. </description> </method> <method name="clear"> - <return type="void"> - </return> + <return type="void" /> <description> Clears the array. This is equivalent to using [method resize] with a size of [code]0[/code]. </description> </method> <method name="count" qualifiers="const"> - <return type="int"> - </return> - <argument index="0" name="value" type="Variant"> - </argument> + <return type="int" /> + <argument index="0" name="value" type="Variant" /> <description> Returns the number of times an element is in the array. </description> </method> <method name="duplicate" qualifiers="const"> - <return type="Array"> - </return> - <argument index="0" name="deep" type="bool" default="false"> - </argument> + <return type="Array" /> + <argument index="0" name="deep" type="bool" default="false" /> <description> Returns a copy of the array. If [code]deep[/code] is [code]true[/code], a deep copy is performed: all nested arrays and dictionaries are duplicated and will not be shared with the original array. If [code]false[/code], a shallow copy is made and references to the original nested arrays and dictionaries are kept, so that modifying a sub-array or dictionary in the copy will also impact those referenced in the source array. </description> </method> <method name="erase"> - <return type="void"> - </return> - <argument index="0" name="value" type="Variant"> - </argument> + <return type="void" /> + <argument index="0" name="value" type="Variant" /> <description> Removes the first occurrence of a value from the array. To remove an element by index, use [method remove] instead. [b]Note:[/b] This method acts in-place and doesn't return a value. @@ -238,10 +198,8 @@ </description> </method> <method name="fill"> - <return type="void"> - </return> - <argument index="0" name="value" type="Variant"> - </argument> + <return type="void" /> + <argument index="0" name="value" type="Variant" /> <description> Assigns the given value to all elements in the array. This can typically be used together with [method resize] to create an array with a given size and initialized elements: [codeblocks] @@ -259,10 +217,8 @@ </description> </method> <method name="filter" qualifiers="const"> - <return type="Array"> - </return> - <argument index="0" name="method" type="Callable"> - </argument> + <return type="Array" /> + <argument index="0" name="method" type="Callable" /> <description> Calls the provided [Callable] on each element in the array and returns a new array with the elements for which the method returned [code]true[/code]. The callable's method should take one [Variant] parameter (the current array element) and return a boolean value. @@ -277,38 +233,30 @@ </description> </method> <method name="find" qualifiers="const"> - <return type="int"> - </return> - <argument index="0" name="what" type="Variant"> - </argument> - <argument index="1" name="from" type="int" default="0"> - </argument> + <return type="int" /> + <argument index="0" name="what" type="Variant" /> + <argument index="1" name="from" type="int" default="0" /> <description> Searches the array for a value and returns its index or [code]-1[/code] if not found. Optionally, the initial search index can be passed. </description> </method> <method name="find_last" qualifiers="const"> - <return type="int"> - </return> - <argument index="0" name="value" type="Variant"> - </argument> + <return type="int" /> + <argument index="0" name="value" type="Variant" /> <description> Searches the array in reverse order for a value and returns its index or [code]-1[/code] if not found. </description> </method> <method name="front" qualifiers="const"> - <return type="Variant"> - </return> + <return type="Variant" /> <description> Returns the first element of the array. Prints an error and returns [code]null[/code] if the array is empty. [b]Note:[/b] Calling this function is not the same as writing [code]array[0][/code]. If the array is empty, accessing by index will pause project execution when running from the editor. </description> </method> <method name="has" qualifiers="const"> - <return type="bool"> - </return> - <argument index="0" name="value" type="Variant"> - </argument> + <return type="bool" /> + <argument index="0" name="value" type="Variant" /> <description> Returns [code]true[/code] if the array contains the given value. [codeblocks] @@ -347,20 +295,16 @@ </description> </method> <method name="hash" qualifiers="const"> - <return type="int"> - </return> + <return type="int" /> <description> Returns a hashed integer value representing the array and its contents. [b]Note:[/b] Arrays with equal contents can still produce different hashes. Only the exact same arrays will produce the same hashed integer value. </description> </method> <method name="insert"> - <return type="void"> - </return> - <argument index="0" name="position" type="int"> - </argument> - <argument index="1" name="value" type="Variant"> - </argument> + <return type="void" /> + <argument index="0" name="position" type="int" /> + <argument index="1" name="value" type="Variant" /> <description> Inserts a new element at a given position in the array. The position must be valid, or at the end of the array ([code]pos == size()[/code]). [b]Note:[/b] This method acts in-place and doesn't return a value. @@ -368,17 +312,14 @@ </description> </method> <method name="is_empty" qualifiers="const"> - <return type="bool"> - </return> + <return type="bool" /> <description> Returns [code]true[/code] if the array is empty. </description> </method> <method name="map" qualifiers="const"> - <return type="Array"> - </return> - <argument index="0" name="method" type="Callable"> - </argument> + <return type="Array" /> + <argument index="0" name="method" type="Callable" /> <description> Calls the provided [Callable] for each element in the array and returns a new array filled with values returned by the method. The callable's method should take one [Variant] parameter (the current array element) and can return any [Variant]. @@ -393,124 +334,97 @@ </description> </method> <method name="max" qualifiers="const"> - <return type="Variant"> - </return> + <return type="Variant" /> <description> Returns the maximum value contained in the array if all elements are of comparable types. If the elements can't be compared, [code]null[/code] is returned. </description> </method> <method name="min" qualifiers="const"> - <return type="Variant"> - </return> + <return type="Variant" /> <description> Returns the minimum value contained in the array if all elements are of comparable types. If the elements can't be compared, [code]null[/code] is returned. </description> </method> <method name="operator !=" qualifiers="operator"> - <return type="bool"> - </return> - <argument index="0" name="right" type="Array"> - </argument> + <return type="bool" /> + <argument index="0" name="right" type="Array" /> <description> </description> </method> <method name="operator +" qualifiers="operator"> - <return type="Array"> - </return> - <argument index="0" name="right" type="Array"> - </argument> + <return type="Array" /> + <argument index="0" name="right" type="Array" /> <description> </description> </method> <method name="operator <" qualifiers="operator"> - <return type="bool"> - </return> - <argument index="0" name="right" type="Array"> - </argument> + <return type="bool" /> + <argument index="0" name="right" type="Array" /> <description> </description> </method> <method name="operator <=" qualifiers="operator"> - <return type="bool"> - </return> - <argument index="0" name="right" type="Array"> - </argument> + <return type="bool" /> + <argument index="0" name="right" type="Array" /> <description> </description> </method> <method name="operator ==" qualifiers="operator"> - <return type="bool"> - </return> - <argument index="0" name="right" type="Array"> - </argument> + <return type="bool" /> + <argument index="0" name="right" type="Array" /> <description> </description> </method> <method name="operator >" qualifiers="operator"> - <return type="bool"> - </return> - <argument index="0" name="right" type="Array"> - </argument> + <return type="bool" /> + <argument index="0" name="right" type="Array" /> <description> </description> </method> <method name="operator >=" qualifiers="operator"> - <return type="bool"> - </return> - <argument index="0" name="right" type="Array"> - </argument> + <return type="bool" /> + <argument index="0" name="right" type="Array" /> <description> </description> </method> <method name="operator []" qualifiers="operator"> - <return type="void"> - </return> - <argument index="0" name="index" type="int"> - </argument> + <return type="void" /> + <argument index="0" name="index" type="int" /> <description> </description> </method> <method name="pop_back"> - <return type="Variant"> - </return> + <return type="Variant" /> <description> Removes and returns the last element of the array. Returns [code]null[/code] if the array is empty, without printing an error message. See also [method pop_front]. </description> </method> <method name="pop_front"> - <return type="Variant"> - </return> + <return type="Variant" /> <description> Removes and returns the first element of the array. Returns [code]null[/code] if the array is empty, without printing an error message. See also [method pop_back]. [b]Note:[/b] On large arrays, this method is much slower than [method pop_back] as it will reindex all the array's elements every time it's called. The larger the array, the slower [method pop_front] will be. </description> </method> <method name="push_back"> - <return type="void"> - </return> - <argument index="0" name="value" type="Variant"> - </argument> + <return type="void" /> + <argument index="0" name="value" type="Variant" /> <description> Appends an element at the end of the array. See also [method push_front]. </description> </method> <method name="push_front"> - <return type="void"> - </return> - <argument index="0" name="value" type="Variant"> - </argument> + <return type="void" /> + <argument index="0" name="value" type="Variant" /> <description> Adds an element at the beginning of the array. See also [method push_back]. [b]Note:[/b] On large arrays, this method is much slower than [method push_back] as it will reindex all the array's elements every time it's called. The larger the array, the slower [method push_front] will be. </description> </method> <method name="reduce" qualifiers="const"> - <return type="Variant"> - </return> - <argument index="0" name="method" type="Callable"> - </argument> - <argument index="1" name="accum" type="Variant" default="null"> - </argument> + <return type="Variant" /> + <argument index="0" name="method" type="Callable" /> + <argument index="1" name="accum" type="Variant" default="null" /> <description> Calls the provided [Callable] for each element in array and accumulates the result in [code]accum[/code]. The callable's method takes two arguments: the current value of [code]accum[/code] and the current array element. If [code]accum[/code] is [code]null[/code] (default value), the iteration will start from the second element, with the first one used as initial value of [code]accum[/code]. @@ -525,10 +439,8 @@ </description> </method> <method name="remove"> - <return type="void"> - </return> - <argument index="0" name="position" type="int"> - </argument> + <return type="void" /> + <argument index="0" name="position" type="int" /> <description> Removes an element from the array by index. If the index does not exist in the array, nothing happens. To remove an element by searching for its value, use [method erase] instead. [b]Note:[/b] This method acts in-place and doesn't return a value. @@ -536,64 +448,50 @@ </description> </method> <method name="resize"> - <return type="int"> - </return> - <argument index="0" name="size" type="int"> - </argument> + <return type="int" /> + <argument index="0" name="size" type="int" /> <description> Resizes the array to contain a different number of elements. If the array size is smaller, elements are cleared, if bigger, new elements are [code]null[/code]. </description> </method> <method name="reverse"> - <return type="void"> - </return> + <return type="void" /> <description> Reverses the order of the elements in the array. </description> </method> <method name="rfind" qualifiers="const"> - <return type="int"> - </return> - <argument index="0" name="what" type="Variant"> - </argument> - <argument index="1" name="from" type="int" default="-1"> - </argument> + <return type="int" /> + <argument index="0" name="what" type="Variant" /> + <argument index="1" name="from" type="int" default="-1" /> <description> Searches the array in reverse order. Optionally, a start search index can be passed. If negative, the start index is considered relative to the end of the array. </description> </method> <method name="shuffle"> - <return type="void"> - </return> + <return type="void" /> <description> Shuffles the array such that the items will have a random order. This method uses the global random number generator common to methods such as [method @GlobalScope.randi]. Call [method @GlobalScope.randomize] to ensure that a new seed will be used each time if you want non-reproducible shuffling. </description> </method> <method name="size" qualifiers="const"> - <return type="int"> - </return> + <return type="int" /> <description> Returns the number of elements in the array. </description> </method> <method name="slice" qualifiers="const"> - <return type="Array"> - </return> - <argument index="0" name="begin" type="int"> - </argument> - <argument index="1" name="end" type="int"> - </argument> - <argument index="2" name="step" type="int" default="1"> - </argument> - <argument index="3" name="deep" type="bool" default="false"> - </argument> + <return type="Array" /> + <argument index="0" name="begin" type="int" /> + <argument index="1" name="end" type="int" /> + <argument index="2" name="step" type="int" default="1" /> + <argument index="3" name="deep" type="bool" default="false" /> <description> Duplicates the subset described in the function and returns it in an array, deeply copying the array if [code]deep[/code] is [code]true[/code]. Lower and upper index are inclusive, with the [code]step[/code] describing the change between indices while slicing. </description> </method> <method name="sort"> - <return type="void"> - </return> + <return type="void" /> <description> Sorts the array. [b]Note:[/b] Strings are sorted in alphabetical order (as opposed to natural order). This may lead to unexpected behavior when sorting an array of strings ending with a sequence of numbers. Consider the following example: @@ -610,10 +508,8 @@ </description> </method> <method name="sort_custom"> - <return type="void"> - </return> - <argument index="0" name="func" type="Callable"> - </argument> + <return type="void" /> + <argument index="0" name="func" type="Callable" /> <description> Sorts the array using a custom method. The custom method receives two arguments (a pair of elements from the array) and must return either [code]true[/code] or [code]false[/code]. For two elements [code]a[/code] and [code]b[/code], if the given method returns [code]true[/code], element [code]b[/code] will be after element [code]a[/code] in the array. [b]Note:[/b] you cannot randomize the return value as the heapsort algorithm expects a deterministic result. Doing so will result in unexpected behavior. diff --git a/doc/classes/ArrayMesh.xml b/doc/classes/ArrayMesh.xml index 7fbf53c7d1..637b9a9f16 100644 --- a/doc/classes/ArrayMesh.xml +++ b/doc/classes/ArrayMesh.xml @@ -51,190 +51,143 @@ </tutorials> <methods> <method name="add_blend_shape"> - <return type="void"> - </return> - <argument index="0" name="name" type="StringName"> - </argument> + <return type="void" /> + <argument index="0" name="name" type="StringName" /> <description> Adds name for a blend shape that will be added with [method add_surface_from_arrays]. Must be called before surface is added. </description> </method> <method name="add_surface_from_arrays"> - <return type="void"> - </return> - <argument index="0" name="primitive" type="int" enum="Mesh.PrimitiveType"> - </argument> - <argument index="1" name="arrays" type="Array"> - </argument> - <argument index="2" name="blend_shapes" type="Array" default="[]"> - </argument> + <return type="void" /> + <argument index="0" name="primitive" type="int" enum="Mesh.PrimitiveType" /> + <argument index="1" name="arrays" type="Array" /> + <argument index="2" name="blend_shapes" type="Array" default="[]" /> <argument index="3" name="lods" type="Dictionary" default="{ -}"> - </argument> - <argument index="4" name="compress_flags" type="int" default="0"> - </argument> +}" /> + <argument index="4" name="compress_flags" type="int" default="0" /> <description> Creates a new surface. - Surfaces are created to be rendered using a [code]primitive[/code], which may be any of the types defined in [enum Mesh.PrimitiveType]. (As a note, when using indices, it is recommended to only use points, lines or triangles.) [method Mesh.get_surface_count] will become the [code]surf_idx[/code] for this new surface. + Surfaces are created to be rendered using a [code]primitive[/code], which may be any of the types defined in [enum Mesh.PrimitiveType]. (As a note, when using indices, it is recommended to only use points, lines, or triangles.) [method Mesh.get_surface_count] will become the [code]surf_idx[/code] for this new surface. The [code]arrays[/code] argument is an array of arrays. See [enum Mesh.ArrayType] for the values used in this array. For example, [code]arrays[0][/code] is the array of vertices. That first vertex sub-array is always required; the others are optional. Adding an index array puts this function into "index mode" where the vertex and other arrays become the sources of data and the index array defines the vertex order. All sub-arrays must have the same length as the vertex array or be empty, except for [constant Mesh.ARRAY_INDEX] if it is used. </description> </method> <method name="clear_blend_shapes"> - <return type="void"> - </return> + <return type="void" /> <description> Removes all blend shapes from this [ArrayMesh]. </description> </method> <method name="clear_surfaces"> - <return type="void"> - </return> + <return type="void" /> <description> Removes all surfaces from this [ArrayMesh]. </description> </method> <method name="get_blend_shape_count" qualifiers="const"> - <return type="int"> - </return> + <return type="int" /> <description> Returns the number of blend shapes that the [ArrayMesh] holds. </description> </method> <method name="get_blend_shape_name" qualifiers="const"> - <return type="StringName"> - </return> - <argument index="0" name="index" type="int"> - </argument> + <return type="StringName" /> + <argument index="0" name="index" type="int" /> <description> Returns the name of the blend shape at this index. </description> </method> <method name="lightmap_unwrap"> - <return type="int" enum="Error"> - </return> - <argument index="0" name="transform" type="Transform3D"> - </argument> - <argument index="1" name="texel_size" type="float"> - </argument> + <return type="int" enum="Error" /> + <argument index="0" name="transform" type="Transform3D" /> + <argument index="1" name="texel_size" type="float" /> <description> Will perform a UV unwrap on the [ArrayMesh] to prepare the mesh for lightmapping. </description> </method> <method name="regen_normal_maps"> - <return type="void"> - </return> + <return type="void" /> <description> Will regenerate normal maps for the [ArrayMesh]. </description> </method> <method name="set_blend_shape_name"> - <return type="void"> - </return> - <argument index="0" name="index" type="int"> - </argument> - <argument index="1" name="name" type="StringName"> - </argument> + <return type="void" /> + <argument index="0" name="index" type="int" /> + <argument index="1" name="name" type="StringName" /> <description> </description> </method> <method name="surface_find_by_name" qualifiers="const"> - <return type="int"> - </return> - <argument index="0" name="name" type="String"> - </argument> + <return type="int" /> + <argument index="0" name="name" type="String" /> <description> Returns the index of the first surface with this name held within this [ArrayMesh]. If none are found, -1 is returned. </description> </method> <method name="surface_get_array_index_len" qualifiers="const"> - <return type="int"> - </return> - <argument index="0" name="surf_idx" type="int"> - </argument> + <return type="int" /> + <argument index="0" name="surf_idx" type="int" /> <description> Returns the length in indices of the index array in the requested surface (see [method add_surface_from_arrays]). </description> </method> <method name="surface_get_array_len" qualifiers="const"> - <return type="int"> - </return> - <argument index="0" name="surf_idx" type="int"> - </argument> + <return type="int" /> + <argument index="0" name="surf_idx" type="int" /> <description> Returns the length in vertices of the vertex array in the requested surface (see [method add_surface_from_arrays]). </description> </method> <method name="surface_get_format" qualifiers="const"> - <return type="int"> - </return> - <argument index="0" name="surf_idx" type="int"> - </argument> + <return type="int" /> + <argument index="0" name="surf_idx" type="int" /> <description> Returns the format mask of the requested surface (see [method add_surface_from_arrays]). </description> </method> <method name="surface_get_name" qualifiers="const"> - <return type="String"> - </return> - <argument index="0" name="surf_idx" type="int"> - </argument> + <return type="String" /> + <argument index="0" name="surf_idx" type="int" /> <description> Gets the name assigned to this surface. </description> </method> <method name="surface_get_primitive_type" qualifiers="const"> - <return type="int" enum="Mesh.PrimitiveType"> - </return> - <argument index="0" name="surf_idx" type="int"> - </argument> + <return type="int" enum="Mesh.PrimitiveType" /> + <argument index="0" name="surf_idx" type="int" /> <description> Returns the primitive type of the requested surface (see [method add_surface_from_arrays]). </description> </method> <method name="surface_set_name"> - <return type="void"> - </return> - <argument index="0" name="surf_idx" type="int"> - </argument> - <argument index="1" name="name" type="String"> - </argument> + <return type="void" /> + <argument index="0" name="surf_idx" type="int" /> + <argument index="1" name="name" type="String" /> <description> Sets a name for a given surface. </description> </method> <method name="surface_update_attribute_region"> - <return type="void"> - </return> - <argument index="0" name="surf_idx" type="int"> - </argument> - <argument index="1" name="offset" type="int"> - </argument> - <argument index="2" name="data" type="PackedByteArray"> - </argument> + <return type="void" /> + <argument index="0" name="surf_idx" type="int" /> + <argument index="1" name="offset" type="int" /> + <argument index="2" name="data" type="PackedByteArray" /> <description> </description> </method> <method name="surface_update_skin_region"> - <return type="void"> - </return> - <argument index="0" name="surf_idx" type="int"> - </argument> - <argument index="1" name="offset" type="int"> - </argument> - <argument index="2" name="data" type="PackedByteArray"> - </argument> + <return type="void" /> + <argument index="0" name="surf_idx" type="int" /> + <argument index="1" name="offset" type="int" /> + <argument index="2" name="data" type="PackedByteArray" /> <description> </description> </method> <method name="surface_update_vertex_region"> - <return type="void"> - </return> - <argument index="0" name="surf_idx" type="int"> - </argument> - <argument index="1" name="offset" type="int"> - </argument> - <argument index="2" name="data" type="PackedByteArray"> - </argument> + <return type="void" /> + <argument index="0" name="surf_idx" type="int" /> + <argument index="1" name="offset" type="int" /> + <argument index="2" name="data" type="PackedByteArray" /> <description> </description> </method> diff --git a/doc/classes/AudioEffectCapture.xml b/doc/classes/AudioEffectCapture.xml index c7ee621ca6..8e46acbd07 100644 --- a/doc/classes/AudioEffectCapture.xml +++ b/doc/classes/AudioEffectCapture.xml @@ -11,55 +11,46 @@ </tutorials> <methods> <method name="can_get_buffer" qualifiers="const"> - <return type="bool"> - </return> - <argument index="0" name="frames" type="int"> - </argument> + <return type="bool" /> + <argument index="0" name="frames" type="int" /> <description> Returns [code]true[/code] if at least [code]frames[/code] audio frames are available to read in the internal ring buffer. </description> </method> <method name="clear_buffer"> - <return type="void"> - </return> + <return type="void" /> <description> Clears the internal ring buffer. </description> </method> <method name="get_buffer"> - <return type="PackedVector2Array"> - </return> - <argument index="0" name="frames" type="int"> - </argument> + <return type="PackedVector2Array" /> + <argument index="0" name="frames" type="int" /> <description> Gets the next [code]frames[/code] audio samples from the internal ring buffer. Returns a [PackedVector2Array] containing exactly [code]frames[/code] audio samples if available, or an empty [PackedVector2Array] if insufficient data was available. </description> </method> <method name="get_buffer_length_frames" qualifiers="const"> - <return type="int"> - </return> + <return type="int" /> <description> Returns the total size of the internal ring buffer in frames. </description> </method> <method name="get_discarded_frames" qualifiers="const"> - <return type="int"> - </return> + <return type="int" /> <description> Returns the number of audio frames discarded from the audio bus due to full buffer. </description> </method> <method name="get_frames_available" qualifiers="const"> - <return type="int"> - </return> + <return type="int" /> <description> Returns the number of frames available to read using [method get_buffer]. </description> </method> <method name="get_pushed_frames" qualifiers="const"> - <return type="int"> - </return> + <return type="int" /> <description> Returns the number of audio frames inserted from the audio bus. </description> diff --git a/doc/classes/AudioEffectChorus.xml b/doc/classes/AudioEffectChorus.xml index 30913a1529..cc93a8fc03 100644 --- a/doc/classes/AudioEffectChorus.xml +++ b/doc/classes/AudioEffectChorus.xml @@ -10,110 +10,80 @@ </tutorials> <methods> <method name="get_voice_cutoff_hz" qualifiers="const"> - <return type="float"> - </return> - <argument index="0" name="voice_idx" type="int"> - </argument> + <return type="float" /> + <argument index="0" name="voice_idx" type="int" /> <description> </description> </method> <method name="get_voice_delay_ms" qualifiers="const"> - <return type="float"> - </return> - <argument index="0" name="voice_idx" type="int"> - </argument> + <return type="float" /> + <argument index="0" name="voice_idx" type="int" /> <description> </description> </method> <method name="get_voice_depth_ms" qualifiers="const"> - <return type="float"> - </return> - <argument index="0" name="voice_idx" type="int"> - </argument> + <return type="float" /> + <argument index="0" name="voice_idx" type="int" /> <description> </description> </method> <method name="get_voice_level_db" qualifiers="const"> - <return type="float"> - </return> - <argument index="0" name="voice_idx" type="int"> - </argument> + <return type="float" /> + <argument index="0" name="voice_idx" type="int" /> <description> </description> </method> <method name="get_voice_pan" qualifiers="const"> - <return type="float"> - </return> - <argument index="0" name="voice_idx" type="int"> - </argument> + <return type="float" /> + <argument index="0" name="voice_idx" type="int" /> <description> </description> </method> <method name="get_voice_rate_hz" qualifiers="const"> - <return type="float"> - </return> - <argument index="0" name="voice_idx" type="int"> - </argument> + <return type="float" /> + <argument index="0" name="voice_idx" type="int" /> <description> </description> </method> <method name="set_voice_cutoff_hz"> - <return type="void"> - </return> - <argument index="0" name="voice_idx" type="int"> - </argument> - <argument index="1" name="cutoff_hz" type="float"> - </argument> + <return type="void" /> + <argument index="0" name="voice_idx" type="int" /> + <argument index="1" name="cutoff_hz" type="float" /> <description> </description> </method> <method name="set_voice_delay_ms"> - <return type="void"> - </return> - <argument index="0" name="voice_idx" type="int"> - </argument> - <argument index="1" name="delay_ms" type="float"> - </argument> + <return type="void" /> + <argument index="0" name="voice_idx" type="int" /> + <argument index="1" name="delay_ms" type="float" /> <description> </description> </method> <method name="set_voice_depth_ms"> - <return type="void"> - </return> - <argument index="0" name="voice_idx" type="int"> - </argument> - <argument index="1" name="depth_ms" type="float"> - </argument> + <return type="void" /> + <argument index="0" name="voice_idx" type="int" /> + <argument index="1" name="depth_ms" type="float" /> <description> </description> </method> <method name="set_voice_level_db"> - <return type="void"> - </return> - <argument index="0" name="voice_idx" type="int"> - </argument> - <argument index="1" name="level_db" type="float"> - </argument> + <return type="void" /> + <argument index="0" name="voice_idx" type="int" /> + <argument index="1" name="level_db" type="float" /> <description> </description> </method> <method name="set_voice_pan"> - <return type="void"> - </return> - <argument index="0" name="voice_idx" type="int"> - </argument> - <argument index="1" name="pan" type="float"> - </argument> + <return type="void" /> + <argument index="0" name="voice_idx" type="int" /> + <argument index="1" name="pan" type="float" /> <description> </description> </method> <method name="set_voice_rate_hz"> - <return type="void"> - </return> - <argument index="0" name="voice_idx" type="int"> - </argument> - <argument index="1" name="rate_hz" type="float"> - </argument> + <return type="void" /> + <argument index="0" name="voice_idx" type="int" /> + <argument index="1" name="rate_hz" type="float" /> <description> </description> </method> diff --git a/doc/classes/AudioEffectEQ.xml b/doc/classes/AudioEffectEQ.xml index c27c2f221c..ddc1af0618 100644 --- a/doc/classes/AudioEffectEQ.xml +++ b/doc/classes/AudioEffectEQ.xml @@ -11,28 +11,22 @@ </tutorials> <methods> <method name="get_band_count" qualifiers="const"> - <return type="int"> - </return> + <return type="int" /> <description> Returns the number of bands of the equalizer. </description> </method> <method name="get_band_gain_db" qualifiers="const"> - <return type="float"> - </return> - <argument index="0" name="band_idx" type="int"> - </argument> + <return type="float" /> + <argument index="0" name="band_idx" type="int" /> <description> Returns the band's gain at the specified index, in dB. </description> </method> <method name="set_band_gain_db"> - <return type="void"> - </return> - <argument index="0" name="band_idx" type="int"> - </argument> - <argument index="1" name="volume_db" type="float"> - </argument> + <return type="void" /> + <argument index="0" name="band_idx" type="int" /> + <argument index="1" name="volume_db" type="float" /> <description> Sets band's gain at the specified index, in dB. </description> diff --git a/doc/classes/AudioEffectRecord.xml b/doc/classes/AudioEffectRecord.xml index 872ddf3b0f..9656718ee8 100644 --- a/doc/classes/AudioEffectRecord.xml +++ b/doc/classes/AudioEffectRecord.xml @@ -12,24 +12,20 @@ </tutorials> <methods> <method name="get_recording" qualifiers="const"> - <return type="AudioStreamSample"> - </return> + <return type="AudioStreamSample" /> <description> Returns the recorded sample. </description> </method> <method name="is_recording_active" qualifiers="const"> - <return type="bool"> - </return> + <return type="bool" /> <description> Returns whether the recording is active or not. </description> </method> <method name="set_recording_active"> - <return type="void"> - </return> - <argument index="0" name="record" type="bool"> - </argument> + <return type="void" /> + <argument index="0" name="record" type="bool" /> <description> If [code]true[/code], the sound will be recorded. Note that restarting the recording will remove the previously recorded sample. </description> diff --git a/doc/classes/AudioEffectSpectrumAnalyzerInstance.xml b/doc/classes/AudioEffectSpectrumAnalyzerInstance.xml index 53428cdfb8..0febf2abc1 100644 --- a/doc/classes/AudioEffectSpectrumAnalyzerInstance.xml +++ b/doc/classes/AudioEffectSpectrumAnalyzerInstance.xml @@ -8,14 +8,10 @@ </tutorials> <methods> <method name="get_magnitude_for_frequency_range" qualifiers="const"> - <return type="Vector2"> - </return> - <argument index="0" name="from_hz" type="float"> - </argument> - <argument index="1" name="to_hz" type="float"> - </argument> - <argument index="2" name="mode" type="int" enum="AudioEffectSpectrumAnalyzerInstance.MagnitudeMode" default="1"> - </argument> + <return type="Vector2" /> + <argument index="0" name="from_hz" type="float" /> + <argument index="1" name="to_hz" type="float" /> + <argument index="2" name="mode" type="int" enum="AudioEffectSpectrumAnalyzerInstance.MagnitudeMode" default="1" /> <description> </description> </method> diff --git a/doc/classes/AudioServer.xml b/doc/classes/AudioServer.xml index dafc0065f6..12a13ecfcc 100644 --- a/doc/classes/AudioServer.xml +++ b/doc/classes/AudioServer.xml @@ -14,380 +14,291 @@ </tutorials> <methods> <method name="add_bus"> - <return type="void"> - </return> - <argument index="0" name="at_position" type="int" default="-1"> - </argument> + <return type="void" /> + <argument index="0" name="at_position" type="int" default="-1" /> <description> Adds a bus at [code]at_position[/code]. </description> </method> <method name="add_bus_effect"> - <return type="void"> - </return> - <argument index="0" name="bus_idx" type="int"> - </argument> - <argument index="1" name="effect" type="AudioEffect"> - </argument> - <argument index="2" name="at_position" type="int" default="-1"> - </argument> + <return type="void" /> + <argument index="0" name="bus_idx" type="int" /> + <argument index="1" name="effect" type="AudioEffect" /> + <argument index="2" name="at_position" type="int" default="-1" /> <description> Adds an [AudioEffect] effect to the bus [code]bus_idx[/code] at [code]at_position[/code]. </description> </method> <method name="capture_get_device"> - <return type="String"> - </return> + <return type="String" /> <description> Name of the current device for audio input (see [method capture_get_device_list]). </description> </method> <method name="capture_get_device_list"> - <return type="Array"> - </return> + <return type="Array" /> <description> Returns the names of all audio input devices detected on the system. </description> </method> <method name="capture_set_device"> - <return type="void"> - </return> - <argument index="0" name="name" type="String"> - </argument> + <return type="void" /> + <argument index="0" name="name" type="String" /> <description> Sets which audio input device is used for audio capture. </description> </method> <method name="generate_bus_layout" qualifiers="const"> - <return type="AudioBusLayout"> - </return> + <return type="AudioBusLayout" /> <description> Generates an [AudioBusLayout] using the available buses and effects. </description> </method> <method name="get_bus_channels" qualifiers="const"> - <return type="int"> - </return> - <argument index="0" name="bus_idx" type="int"> - </argument> + <return type="int" /> + <argument index="0" name="bus_idx" type="int" /> <description> Returns the amount of channels of the bus at index [code]bus_idx[/code]. </description> </method> <method name="get_bus_effect"> - <return type="AudioEffect"> - </return> - <argument index="0" name="bus_idx" type="int"> - </argument> - <argument index="1" name="effect_idx" type="int"> - </argument> + <return type="AudioEffect" /> + <argument index="0" name="bus_idx" type="int" /> + <argument index="1" name="effect_idx" type="int" /> <description> Returns the [AudioEffect] at position [code]effect_idx[/code] in bus [code]bus_idx[/code]. </description> </method> <method name="get_bus_effect_count"> - <return type="int"> - </return> - <argument index="0" name="bus_idx" type="int"> - </argument> + <return type="int" /> + <argument index="0" name="bus_idx" type="int" /> <description> Returns the number of effects on the bus at [code]bus_idx[/code]. </description> </method> <method name="get_bus_effect_instance"> - <return type="AudioEffectInstance"> - </return> - <argument index="0" name="bus_idx" type="int"> - </argument> - <argument index="1" name="effect_idx" type="int"> - </argument> - <argument index="2" name="channel" type="int" default="0"> - </argument> + <return type="AudioEffectInstance" /> + <argument index="0" name="bus_idx" type="int" /> + <argument index="1" name="effect_idx" type="int" /> + <argument index="2" name="channel" type="int" default="0" /> <description> Returns the [AudioEffectInstance] assigned to the given bus and effect indices (and optionally channel). </description> </method> <method name="get_bus_index" qualifiers="const"> - <return type="int"> - </return> - <argument index="0" name="bus_name" type="StringName"> - </argument> + <return type="int" /> + <argument index="0" name="bus_name" type="StringName" /> <description> Returns the index of the bus with the name [code]bus_name[/code]. </description> </method> <method name="get_bus_name" qualifiers="const"> - <return type="String"> - </return> - <argument index="0" name="bus_idx" type="int"> - </argument> + <return type="String" /> + <argument index="0" name="bus_idx" type="int" /> <description> Returns the name of the bus with the index [code]bus_idx[/code]. </description> </method> <method name="get_bus_peak_volume_left_db" qualifiers="const"> - <return type="float"> - </return> - <argument index="0" name="bus_idx" type="int"> - </argument> - <argument index="1" name="channel" type="int"> - </argument> + <return type="float" /> + <argument index="0" name="bus_idx" type="int" /> + <argument index="1" name="channel" type="int" /> <description> Returns the peak volume of the left speaker at bus index [code]bus_idx[/code] and channel index [code]channel[/code]. </description> </method> <method name="get_bus_peak_volume_right_db" qualifiers="const"> - <return type="float"> - </return> - <argument index="0" name="bus_idx" type="int"> - </argument> - <argument index="1" name="channel" type="int"> - </argument> + <return type="float" /> + <argument index="0" name="bus_idx" type="int" /> + <argument index="1" name="channel" type="int" /> <description> Returns the peak volume of the right speaker at bus index [code]bus_idx[/code] and channel index [code]channel[/code]. </description> </method> <method name="get_bus_send" qualifiers="const"> - <return type="StringName"> - </return> - <argument index="0" name="bus_idx" type="int"> - </argument> + <return type="StringName" /> + <argument index="0" name="bus_idx" type="int" /> <description> Returns the name of the bus that the bus at index [code]bus_idx[/code] sends to. </description> </method> <method name="get_bus_volume_db" qualifiers="const"> - <return type="float"> - </return> - <argument index="0" name="bus_idx" type="int"> - </argument> + <return type="float" /> + <argument index="0" name="bus_idx" type="int" /> <description> Returns the volume of the bus at index [code]bus_idx[/code] in dB. </description> </method> <method name="get_device_list"> - <return type="Array"> - </return> + <return type="Array" /> <description> Returns the names of all audio devices detected on the system. </description> </method> <method name="get_mix_rate" qualifiers="const"> - <return type="float"> - </return> + <return type="float" /> <description> Returns the sample rate at the output of the [AudioServer]. </description> </method> <method name="get_output_latency" qualifiers="const"> - <return type="float"> - </return> + <return type="float" /> <description> Returns the audio driver's output latency. </description> </method> <method name="get_speaker_mode" qualifiers="const"> - <return type="int" enum="AudioServer.SpeakerMode"> - </return> + <return type="int" enum="AudioServer.SpeakerMode" /> <description> Returns the speaker configuration. </description> </method> <method name="get_time_since_last_mix" qualifiers="const"> - <return type="float"> - </return> + <return type="float" /> <description> Returns the relative time since the last mix occurred. </description> </method> <method name="get_time_to_next_mix" qualifiers="const"> - <return type="float"> - </return> + <return type="float" /> <description> Returns the relative time until the next mix occurs. </description> </method> <method name="is_bus_bypassing_effects" qualifiers="const"> - <return type="bool"> - </return> - <argument index="0" name="bus_idx" type="int"> - </argument> + <return type="bool" /> + <argument index="0" name="bus_idx" type="int" /> <description> If [code]true[/code], the bus at index [code]bus_idx[/code] is bypassing effects. </description> </method> <method name="is_bus_effect_enabled" qualifiers="const"> - <return type="bool"> - </return> - <argument index="0" name="bus_idx" type="int"> - </argument> - <argument index="1" name="effect_idx" type="int"> - </argument> + <return type="bool" /> + <argument index="0" name="bus_idx" type="int" /> + <argument index="1" name="effect_idx" type="int" /> <description> If [code]true[/code], the effect at index [code]effect_idx[/code] on the bus at index [code]bus_idx[/code] is enabled. </description> </method> <method name="is_bus_mute" qualifiers="const"> - <return type="bool"> - </return> - <argument index="0" name="bus_idx" type="int"> - </argument> + <return type="bool" /> + <argument index="0" name="bus_idx" type="int" /> <description> If [code]true[/code], the bus at index [code]bus_idx[/code] is muted. </description> </method> <method name="is_bus_solo" qualifiers="const"> - <return type="bool"> - </return> - <argument index="0" name="bus_idx" type="int"> - </argument> + <return type="bool" /> + <argument index="0" name="bus_idx" type="int" /> <description> If [code]true[/code], the bus at index [code]bus_idx[/code] is in solo mode. </description> </method> <method name="lock"> - <return type="void"> - </return> + <return type="void" /> <description> Locks the audio driver's main loop. [b]Note:[/b] Remember to unlock it afterwards. </description> </method> <method name="move_bus"> - <return type="void"> - </return> - <argument index="0" name="index" type="int"> - </argument> - <argument index="1" name="to_index" type="int"> - </argument> + <return type="void" /> + <argument index="0" name="index" type="int" /> + <argument index="1" name="to_index" type="int" /> <description> Moves the bus from index [code]index[/code] to index [code]to_index[/code]. </description> </method> <method name="remove_bus"> - <return type="void"> - </return> - <argument index="0" name="index" type="int"> - </argument> + <return type="void" /> + <argument index="0" name="index" type="int" /> <description> Removes the bus at index [code]index[/code]. </description> </method> <method name="remove_bus_effect"> - <return type="void"> - </return> - <argument index="0" name="bus_idx" type="int"> - </argument> - <argument index="1" name="effect_idx" type="int"> - </argument> + <return type="void" /> + <argument index="0" name="bus_idx" type="int" /> + <argument index="1" name="effect_idx" type="int" /> <description> Removes the effect at index [code]effect_idx[/code] from the bus at index [code]bus_idx[/code]. </description> </method> <method name="set_bus_bypass_effects"> - <return type="void"> - </return> - <argument index="0" name="bus_idx" type="int"> - </argument> - <argument index="1" name="enable" type="bool"> - </argument> + <return type="void" /> + <argument index="0" name="bus_idx" type="int" /> + <argument index="1" name="enable" type="bool" /> <description> If [code]true[/code], the bus at index [code]bus_idx[/code] is bypassing effects. </description> </method> <method name="set_bus_effect_enabled"> - <return type="void"> - </return> - <argument index="0" name="bus_idx" type="int"> - </argument> - <argument index="1" name="effect_idx" type="int"> - </argument> - <argument index="2" name="enabled" type="bool"> - </argument> + <return type="void" /> + <argument index="0" name="bus_idx" type="int" /> + <argument index="1" name="effect_idx" type="int" /> + <argument index="2" name="enabled" type="bool" /> <description> If [code]true[/code], the effect at index [code]effect_idx[/code] on the bus at index [code]bus_idx[/code] is enabled. </description> </method> <method name="set_bus_layout"> - <return type="void"> - </return> - <argument index="0" name="bus_layout" type="AudioBusLayout"> - </argument> + <return type="void" /> + <argument index="0" name="bus_layout" type="AudioBusLayout" /> <description> Overwrites the currently used [AudioBusLayout]. </description> </method> <method name="set_bus_mute"> - <return type="void"> - </return> - <argument index="0" name="bus_idx" type="int"> - </argument> - <argument index="1" name="enable" type="bool"> - </argument> + <return type="void" /> + <argument index="0" name="bus_idx" type="int" /> + <argument index="1" name="enable" type="bool" /> <description> If [code]true[/code], the bus at index [code]bus_idx[/code] is muted. </description> </method> <method name="set_bus_name"> - <return type="void"> - </return> - <argument index="0" name="bus_idx" type="int"> - </argument> - <argument index="1" name="name" type="String"> - </argument> + <return type="void" /> + <argument index="0" name="bus_idx" type="int" /> + <argument index="1" name="name" type="String" /> <description> Sets the name of the bus at index [code]bus_idx[/code] to [code]name[/code]. </description> </method> <method name="set_bus_send"> - <return type="void"> - </return> - <argument index="0" name="bus_idx" type="int"> - </argument> - <argument index="1" name="send" type="StringName"> - </argument> + <return type="void" /> + <argument index="0" name="bus_idx" type="int" /> + <argument index="1" name="send" type="StringName" /> <description> Connects the output of the bus at [code]bus_idx[/code] to the bus named [code]send[/code]. </description> </method> <method name="set_bus_solo"> - <return type="void"> - </return> - <argument index="0" name="bus_idx" type="int"> - </argument> - <argument index="1" name="enable" type="bool"> - </argument> + <return type="void" /> + <argument index="0" name="bus_idx" type="int" /> + <argument index="1" name="enable" type="bool" /> <description> If [code]true[/code], the bus at index [code]bus_idx[/code] is in solo mode. </description> </method> <method name="set_bus_volume_db"> - <return type="void"> - </return> - <argument index="0" name="bus_idx" type="int"> - </argument> - <argument index="1" name="volume_db" type="float"> - </argument> + <return type="void" /> + <argument index="0" name="bus_idx" type="int" /> + <argument index="1" name="volume_db" type="float" /> <description> Sets the volume of the bus at index [code]bus_idx[/code] to [code]volume_db[/code]. </description> </method> <method name="swap_bus_effects"> - <return type="void"> - </return> - <argument index="0" name="bus_idx" type="int"> - </argument> - <argument index="1" name="effect_idx" type="int"> - </argument> - <argument index="2" name="by_effect_idx" type="int"> - </argument> + <return type="void" /> + <argument index="0" name="bus_idx" type="int" /> + <argument index="1" name="effect_idx" type="int" /> + <argument index="2" name="by_effect_idx" type="int" /> <description> Swaps the position of two effects in bus [code]bus_idx[/code]. </description> </method> <method name="unlock"> - <return type="void"> - </return> + <return type="void" /> <description> Unlocks the audio driver's main loop. (After locking it, you should always unlock it.) </description> diff --git a/doc/classes/AudioStream.xml b/doc/classes/AudioStream.xml index bbfec579bb..8a58b178d8 100644 --- a/doc/classes/AudioStream.xml +++ b/doc/classes/AudioStream.xml @@ -14,8 +14,7 @@ </tutorials> <methods> <method name="get_length" qualifiers="const"> - <return type="float"> - </return> + <return type="float" /> <description> Returns the length of the audio stream in seconds. </description> diff --git a/doc/classes/AudioStreamGeneratorPlayback.xml b/doc/classes/AudioStreamGeneratorPlayback.xml index 503f72a048..d99d041053 100644 --- a/doc/classes/AudioStreamGeneratorPlayback.xml +++ b/doc/classes/AudioStreamGeneratorPlayback.xml @@ -12,48 +12,39 @@ </tutorials> <methods> <method name="can_push_buffer" qualifiers="const"> - <return type="bool"> - </return> - <argument index="0" name="amount" type="int"> - </argument> + <return type="bool" /> + <argument index="0" name="amount" type="int" /> <description> Returns [code]true[/code] if a buffer of the size [code]amount[/code] can be pushed to the audio sample data buffer without overflowing it, [code]false[/code] otherwise. </description> </method> <method name="clear_buffer"> - <return type="void"> - </return> + <return type="void" /> <description> Clears the audio sample data buffer. </description> </method> <method name="get_frames_available" qualifiers="const"> - <return type="int"> - </return> + <return type="int" /> <description> Returns the number of audio data frames left to play. If this returned number reaches [code]0[/code], the audio will stop playing until frames are added again. Therefore, make sure your script can always generate and push new audio frames fast enough to avoid audio cracking. </description> </method> <method name="get_skips" qualifiers="const"> - <return type="int"> - </return> + <return type="int" /> <description> </description> </method> <method name="push_buffer"> - <return type="bool"> - </return> - <argument index="0" name="frames" type="PackedVector2Array"> - </argument> + <return type="bool" /> + <argument index="0" name="frames" type="PackedVector2Array" /> <description> Pushes several audio data frames to the buffer. This is usually more efficient than [method push_frame] in C# and compiled languages via GDNative, but [method push_buffer] may be [i]less[/i] efficient in GDScript. </description> </method> <method name="push_frame"> - <return type="bool"> - </return> - <argument index="0" name="frame" type="Vector2"> - </argument> + <return type="bool" /> + <argument index="0" name="frame" type="Vector2" /> <description> Pushes a single audio data frame to the buffer. This is usually less efficient than [method push_buffer] in C# and compiled languages via GDNative, but [method push_frame] may be [i]more[/i] efficient in GDScript. </description> diff --git a/doc/classes/AudioStreamPlayer.xml b/doc/classes/AudioStreamPlayer.xml index 7c7f7e0cea..a6c437f875 100644 --- a/doc/classes/AudioStreamPlayer.xml +++ b/doc/classes/AudioStreamPlayer.xml @@ -17,40 +17,33 @@ </tutorials> <methods> <method name="get_playback_position"> - <return type="float"> - </return> + <return type="float" /> <description> Returns the position in the [AudioStream] in seconds. </description> </method> <method name="get_stream_playback"> - <return type="AudioStreamPlayback"> - </return> + <return type="AudioStreamPlayback" /> <description> Returns the [AudioStreamPlayback] object associated with this [AudioStreamPlayer]. </description> </method> <method name="play"> - <return type="void"> - </return> - <argument index="0" name="from_position" type="float" default="0.0"> - </argument> + <return type="void" /> + <argument index="0" name="from_position" type="float" default="0.0" /> <description> Plays the audio from the given [code]from_position[/code], in seconds. </description> </method> <method name="seek"> - <return type="void"> - </return> - <argument index="0" name="to_position" type="float"> - </argument> + <return type="void" /> + <argument index="0" name="to_position" type="float" /> <description> Sets the position from which audio will be played, in seconds. </description> </method> <method name="stop"> - <return type="void"> - </return> + <return type="void" /> <description> Stops the audio. </description> diff --git a/doc/classes/AudioStreamPlayer2D.xml b/doc/classes/AudioStreamPlayer2D.xml index b1e18ab550..c40c223091 100644 --- a/doc/classes/AudioStreamPlayer2D.xml +++ b/doc/classes/AudioStreamPlayer2D.xml @@ -13,40 +13,33 @@ </tutorials> <methods> <method name="get_playback_position"> - <return type="float"> - </return> + <return type="float" /> <description> Returns the position in the [AudioStream]. </description> </method> <method name="get_stream_playback"> - <return type="AudioStreamPlayback"> - </return> + <return type="AudioStreamPlayback" /> <description> Returns the [AudioStreamPlayback] object associated with this [AudioStreamPlayer2D]. </description> </method> <method name="play"> - <return type="void"> - </return> - <argument index="0" name="from_position" type="float" default="0.0"> - </argument> + <return type="void" /> + <argument index="0" name="from_position" type="float" default="0.0" /> <description> Plays the audio from the given position [code]from_position[/code], in seconds. </description> </method> <method name="seek"> - <return type="void"> - </return> - <argument index="0" name="to_position" type="float"> - </argument> + <return type="void" /> + <argument index="0" name="to_position" type="float" /> <description> Sets the position from which audio will be played, in seconds. </description> </method> <method name="stop"> - <return type="void"> - </return> + <return type="void" /> <description> Stops the audio. </description> diff --git a/doc/classes/AudioStreamPlayer3D.xml b/doc/classes/AudioStreamPlayer3D.xml index 3bd20b4b9b..584f03399c 100644 --- a/doc/classes/AudioStreamPlayer3D.xml +++ b/doc/classes/AudioStreamPlayer3D.xml @@ -14,40 +14,33 @@ </tutorials> <methods> <method name="get_playback_position"> - <return type="float"> - </return> + <return type="float" /> <description> Returns the position in the [AudioStream]. </description> </method> <method name="get_stream_playback"> - <return type="AudioStreamPlayback"> - </return> + <return type="AudioStreamPlayback" /> <description> Returns the [AudioStreamPlayback] object associated with this [AudioStreamPlayer3D]. </description> </method> <method name="play"> - <return type="void"> - </return> - <argument index="0" name="from_position" type="float" default="0.0"> - </argument> + <return type="void" /> + <argument index="0" name="from_position" type="float" default="0.0" /> <description> Plays the audio from the given position [code]from_position[/code], in seconds. </description> </method> <method name="seek"> - <return type="void"> - </return> - <argument index="0" name="to_position" type="float"> - </argument> + <return type="void" /> + <argument index="0" name="to_position" type="float" /> <description> Sets the position from which audio will be played, in seconds. </description> </method> <method name="stop"> - <return type="void"> - </return> + <return type="void" /> <description> Stops the audio. </description> diff --git a/doc/classes/AudioStreamSample.xml b/doc/classes/AudioStreamSample.xml index 5a0e71a0f8..7e1155d89b 100644 --- a/doc/classes/AudioStreamSample.xml +++ b/doc/classes/AudioStreamSample.xml @@ -11,10 +11,8 @@ </tutorials> <methods> <method name="save_to_wav"> - <return type="int" enum="Error"> - </return> - <argument index="0" name="path" type="String"> - </argument> + <return type="int" enum="Error" /> + <argument index="0" name="path" type="String" /> <description> Saves the AudioStreamSample as a WAV file to [code]path[/code]. Samples with IMA ADPCM format can't be saved. [b]Note:[/b] A [code].wav[/code] extension is automatically appended to [code]path[/code] if it is missing. diff --git a/doc/classes/BaseButton.xml b/doc/classes/BaseButton.xml index f7e31f5f9c..889c703b07 100644 --- a/doc/classes/BaseButton.xml +++ b/doc/classes/BaseButton.xml @@ -10,35 +10,38 @@ </tutorials> <methods> <method name="_pressed" qualifiers="virtual"> - <return type="void"> - </return> + <return type="void" /> <description> Called when the button is pressed. If you need to know the button's pressed state (and [member toggle_mode] is active), use [method _toggled] instead. </description> </method> <method name="_toggled" qualifiers="virtual"> - <return type="void"> - </return> - <argument index="0" name="button_pressed" type="bool"> - </argument> + <return type="void" /> + <argument index="0" name="button_pressed" type="bool" /> <description> Called when the button is toggled (only if [member toggle_mode] is active). </description> </method> <method name="get_draw_mode" qualifiers="const"> - <return type="int" enum="BaseButton.DrawMode"> - </return> + <return type="int" enum="BaseButton.DrawMode" /> <description> Returns the visual state used to draw the button. This is useful mainly when implementing your own draw code by either overriding _draw() or connecting to "draw" signal. The visual state of the button is defined by the [enum DrawMode] enum. </description> </method> <method name="is_hovered" qualifiers="const"> - <return type="bool"> - </return> + <return type="bool" /> <description> Returns [code]true[/code] if the mouse has entered the button and has not left it yet. </description> </method> + <method name="set_pressed_no_signal"> + <return type="void" /> + <argument index="0" name="pressed" type="bool" /> + <description> + Changes the [member pressed] state of the button, without emitting [signal toggled]. Use when you just want to change the state of the button without sending the pressed event (e.g. when initializing scene). Only works if [member toggle_mode] is [code]true[/code]. + [b]Note:[/b] This method doesn't unpress other buttons in [member button_group]. + </description> + </method> </methods> <members> <member name="action_mode" type="int" setter="set_action_mode" getter="get_action_mode" enum="BaseButton.ActionMode" default="1"> @@ -60,7 +63,8 @@ [b]Note:[/b] This property only affects the button's visual appearance. Signals will be emitted at the same moment regardless of this property's value. </member> <member name="pressed" type="bool" setter="set_pressed" getter="is_pressed" default="false"> - If [code]true[/code], the button's state is pressed. Means the button is pressed down or toggled (if [member toggle_mode] is active). + If [code]true[/code], the button's state is pressed. Means the button is pressed down or toggled (if [member toggle_mode] is active). Only works if [member toggle_mode] is [code]true[/code]. + [b]Note:[/b] Setting [member pressed] will result in [signal toggled] to be emitted. If you want to change the pressed state without emitting that signal, use [method set_pressed_no_signal]. </member> <member name="shortcut" type="Shortcut" setter="set_shortcut" getter="get_shortcut"> [Shortcut] associated to the button. @@ -93,8 +97,7 @@ </description> </signal> <signal name="toggled"> - <argument index="0" name="button_pressed" type="bool"> - </argument> + <argument index="0" name="button_pressed" type="bool" /> <description> Emitted when the button was just toggled between pressed and normal states (only if [member toggle_mode] is active). The new state is contained in the [code]button_pressed[/code] argument. </description> diff --git a/doc/classes/BaseMaterial3D.xml b/doc/classes/BaseMaterial3D.xml index 2a378ed03e..bbf7c5eb6d 100644 --- a/doc/classes/BaseMaterial3D.xml +++ b/doc/classes/BaseMaterial3D.xml @@ -11,61 +11,46 @@ </tutorials> <methods> <method name="get_feature" qualifiers="const"> - <return type="bool"> - </return> - <argument index="0" name="feature" type="int" enum="BaseMaterial3D.Feature"> - </argument> + <return type="bool" /> + <argument index="0" name="feature" type="int" enum="BaseMaterial3D.Feature" /> <description> Returns [code]true[/code], if the specified [enum Feature] is enabled. </description> </method> <method name="get_flag" qualifiers="const"> - <return type="bool"> - </return> - <argument index="0" name="flag" type="int" enum="BaseMaterial3D.Flags"> - </argument> + <return type="bool" /> + <argument index="0" name="flag" type="int" enum="BaseMaterial3D.Flags" /> <description> Returns [code]true[/code], if the specified flag is enabled. See [enum Flags] enumerator for options. </description> </method> <method name="get_texture" qualifiers="const"> - <return type="Texture2D"> - </return> - <argument index="0" name="param" type="int" enum="BaseMaterial3D.TextureParam"> - </argument> + <return type="Texture2D" /> + <argument index="0" name="param" type="int" enum="BaseMaterial3D.TextureParam" /> <description> Returns the [Texture] associated with the specified [enum TextureParam]. </description> </method> <method name="set_feature"> - <return type="void"> - </return> - <argument index="0" name="feature" type="int" enum="BaseMaterial3D.Feature"> - </argument> - <argument index="1" name="enable" type="bool"> - </argument> + <return type="void" /> + <argument index="0" name="feature" type="int" enum="BaseMaterial3D.Feature" /> + <argument index="1" name="enable" type="bool" /> <description> If [code]true[/code], enables the specified [enum Feature]. Many features that are available in [BaseMaterial3D]s need to be enabled before use. This way the cost for using the feature is only incurred when specified. Features can also be enabled by setting the corresponding member to [code]true[/code]. </description> </method> <method name="set_flag"> - <return type="void"> - </return> - <argument index="0" name="flag" type="int" enum="BaseMaterial3D.Flags"> - </argument> - <argument index="1" name="enable" type="bool"> - </argument> + <return type="void" /> + <argument index="0" name="flag" type="int" enum="BaseMaterial3D.Flags" /> + <argument index="1" name="enable" type="bool" /> <description> If [code]true[/code], enables the specified flag. Flags are optional behavior that can be turned on and off. Only one flag can be enabled at a time with this function, the flag enumerators cannot be bit-masked together to enable or disable multiple flags at once. Flags can also be enabled by setting the corresponding member to [code]true[/code]. See [enum Flags] enumerator for options. </description> </method> <method name="set_texture"> - <return type="void"> - </return> - <argument index="0" name="param" type="int" enum="BaseMaterial3D.TextureParam"> - </argument> - <argument index="1" name="texture" type="Texture2D"> - </argument> + <return type="void" /> + <argument index="0" name="param" type="int" enum="BaseMaterial3D.TextureParam" /> + <argument index="1" name="texture" type="Texture2D" /> <description> Sets the texture for the slot specified by [code]param[/code]. See [enum TextureParam] for available slots. </description> diff --git a/doc/classes/Basis.xml b/doc/classes/Basis.xml index bd1abe914d..9a4dd15c63 100644 --- a/doc/classes/Basis.xml +++ b/doc/classes/Basis.xml @@ -20,243 +20,191 @@ </tutorials> <methods> <method name="Basis" qualifiers="constructor"> - <return type="Basis"> - </return> + <return type="Basis" /> <description> Constructs a default-initialized [Basis] set to [constant IDENTITY]. </description> </method> <method name="Basis" qualifiers="constructor"> - <return type="Basis"> - </return> - <argument index="0" name="from" type="Basis"> - </argument> + <return type="Basis" /> + <argument index="0" name="from" type="Basis" /> <description> Constructs a [Basis] as a copy of the given [Basis]. </description> </method> <method name="Basis" qualifiers="constructor"> - <return type="Basis"> - </return> - <argument index="0" name="axis" type="Vector3"> - </argument> - <argument index="1" name="phi" type="float"> - </argument> + <return type="Basis" /> + <argument index="0" name="axis" type="Vector3" /> + <argument index="1" name="phi" type="float" /> <description> Constructs a pure rotation basis matrix, rotated around the given [code]axis[/code] by [code]phi[/code], in radians. The axis must be a normalized vector. </description> </method> <method name="Basis" qualifiers="constructor"> - <return type="Basis"> - </return> - <argument index="0" name="euler" type="Vector3"> - </argument> + <return type="Basis" /> + <argument index="0" name="euler" type="Vector3" /> <description> Constructs a pure rotation basis matrix from the given Euler angles (in the YXZ convention: when *composing*, first Y, then X, and Z last), given in the vector format as (X angle, Y angle, Z angle). Consider using the [Quaternion] constructor instead, which uses a quaternion instead of Euler angles. </description> </method> <method name="Basis" qualifiers="constructor"> - <return type="Basis"> - </return> - <argument index="0" name="from" type="Quaternion"> - </argument> + <return type="Basis" /> + <argument index="0" name="from" type="Quaternion" /> <description> Constructs a pure rotation basis matrix from the given quaternion. </description> </method> <method name="Basis" qualifiers="constructor"> - <return type="Basis"> - </return> - <argument index="0" name="x_axis" type="Vector3"> - </argument> - <argument index="1" name="y_axis" type="Vector3"> - </argument> - <argument index="2" name="z_axis" type="Vector3"> - </argument> + <return type="Basis" /> + <argument index="0" name="x_axis" type="Vector3" /> + <argument index="1" name="y_axis" type="Vector3" /> + <argument index="2" name="z_axis" type="Vector3" /> <description> Constructs a basis matrix from 3 axis vectors (matrix columns). </description> </method> <method name="determinant" qualifiers="const"> - <return type="float"> - </return> + <return type="float" /> <description> Returns the determinant of the basis matrix. If the basis is uniformly scaled, its determinant is the square of the scale. A negative determinant means the basis has a negative scale. A zero determinant means the basis isn't invertible, and is usually considered invalid. </description> </method> <method name="get_euler" qualifiers="const"> - <return type="Vector3"> - </return> + <return type="Vector3" /> <description> Returns the basis's rotation in the form of Euler angles (in the YXZ convention: when decomposing, first Z, then X, and Y last). The returned vector contains the rotation angles in the format (X angle, Y angle, Z angle). Consider using the [method get_rotation_quaternion] method instead, which returns a [Quaternion] quaternion instead of Euler angles. </description> </method> <method name="get_orthogonal_index" qualifiers="const"> - <return type="int"> - </return> + <return type="int" /> <description> This function considers a discretization of rotations into 24 points on unit sphere, lying along the vectors (x,y,z) with each component being either -1, 0, or 1, and returns the index of the point best representing the orientation of the object. It is mainly used by the [GridMap] editor. For further details, refer to the Godot source code. </description> </method> <method name="get_rotation_quaternion" qualifiers="const"> - <return type="Quaternion"> - </return> + <return type="Quaternion" /> <description> Returns the basis's rotation in the form of a quaternion. See [method get_euler] if you need Euler angles, but keep in mind quaternions should generally be preferred to Euler angles. </description> </method> <method name="get_scale" qualifiers="const"> - <return type="Vector3"> - </return> + <return type="Vector3" /> <description> Assuming that the matrix is the combination of a rotation and scaling, return the absolute value of scaling factors along each axis. </description> </method> <method name="inverse" qualifiers="const"> - <return type="Basis"> - </return> + <return type="Basis" /> <description> Returns the inverse of the matrix. </description> </method> <method name="is_equal_approx" qualifiers="const"> - <return type="bool"> - </return> - <argument index="0" name="b" type="Basis"> - </argument> + <return type="bool" /> + <argument index="0" name="b" type="Basis" /> <description> Returns [code]true[/code] if this basis and [code]b[/code] are approximately equal, by calling [code]is_equal_approx[/code] on each component. </description> </method> <method name="operator !=" qualifiers="operator"> - <return type="bool"> - </return> - <argument index="0" name="right" type="Basis"> - </argument> + <return type="bool" /> + <argument index="0" name="right" type="Basis" /> <description> </description> </method> <method name="operator *" qualifiers="operator"> - <return type="Vector3"> - </return> - <argument index="0" name="right" type="Vector3"> - </argument> + <return type="Vector3" /> + <argument index="0" name="right" type="Vector3" /> <description> </description> </method> <method name="operator *" qualifiers="operator"> - <return type="Basis"> - </return> - <argument index="0" name="right" type="Basis"> - </argument> + <return type="Basis" /> + <argument index="0" name="right" type="Basis" /> <description> </description> </method> <method name="operator *" qualifiers="operator"> - <return type="Basis"> - </return> - <argument index="0" name="right" type="float"> - </argument> + <return type="Basis" /> + <argument index="0" name="right" type="float" /> <description> This operator multiplies all components of the [Basis], which scales it uniformly. </description> </method> <method name="operator *" qualifiers="operator"> - <return type="Basis"> - </return> - <argument index="0" name="right" type="int"> - </argument> + <return type="Basis" /> + <argument index="0" name="right" type="int" /> <description> This operator multiplies all components of the [Basis], which scales it uniformly. </description> </method> <method name="operator ==" qualifiers="operator"> - <return type="bool"> - </return> - <argument index="0" name="right" type="Basis"> - </argument> + <return type="bool" /> + <argument index="0" name="right" type="Basis" /> <description> </description> </method> <method name="operator []" qualifiers="operator"> - <return type="Vector3"> - </return> - <argument index="0" name="index" type="int"> - </argument> + <return type="Vector3" /> + <argument index="0" name="index" type="int" /> <description> </description> </method> <method name="orthonormalized" qualifiers="const"> - <return type="Basis"> - </return> + <return type="Basis" /> <description> Returns the orthonormalized version of the matrix (useful to call from time to time to avoid rounding error for orthogonal matrices). This performs a Gram-Schmidt orthonormalization on the basis of the matrix. </description> </method> <method name="rotated" qualifiers="const"> - <return type="Basis"> - </return> - <argument index="0" name="axis" type="Vector3"> - </argument> - <argument index="1" name="phi" type="float"> - </argument> + <return type="Basis" /> + <argument index="0" name="axis" type="Vector3" /> + <argument index="1" name="phi" type="float" /> <description> Introduce an additional rotation around the given axis by phi (radians). The axis must be a normalized vector. </description> </method> <method name="scaled" qualifiers="const"> - <return type="Basis"> - </return> - <argument index="0" name="scale" type="Vector3"> - </argument> + <return type="Basis" /> + <argument index="0" name="scale" type="Vector3" /> <description> Introduce an additional scaling specified by the given 3D scaling factor. </description> </method> <method name="slerp" qualifiers="const"> - <return type="Basis"> - </return> - <argument index="0" name="to" type="Basis"> - </argument> - <argument index="1" name="weight" type="float"> - </argument> + <return type="Basis" /> + <argument index="0" name="to" type="Basis" /> + <argument index="1" name="weight" type="float" /> <description> Assuming that the matrix is a proper rotation matrix, slerp performs a spherical-linear interpolation with another rotation matrix. </description> </method> <method name="tdotx" qualifiers="const"> - <return type="float"> - </return> - <argument index="0" name="with" type="Vector3"> - </argument> + <return type="float" /> + <argument index="0" name="with" type="Vector3" /> <description> Transposed dot product with the X axis of the matrix. </description> </method> <method name="tdoty" qualifiers="const"> - <return type="float"> - </return> - <argument index="0" name="with" type="Vector3"> - </argument> + <return type="float" /> + <argument index="0" name="with" type="Vector3" /> <description> Transposed dot product with the Y axis of the matrix. </description> </method> <method name="tdotz" qualifiers="const"> - <return type="float"> - </return> - <argument index="0" name="with" type="Vector3"> - </argument> + <return type="float" /> + <argument index="0" name="with" type="Vector3" /> <description> Transposed dot product with the Z axis of the matrix. </description> </method> <method name="transposed" qualifiers="const"> - <return type="Basis"> - </return> + <return type="Basis" /> <description> Returns the transposed version of the matrix. </description> diff --git a/doc/classes/BitMap.xml b/doc/classes/BitMap.xml index 83e598d2ba..9a349c957f 100644 --- a/doc/classes/BitMap.xml +++ b/doc/classes/BitMap.xml @@ -10,66 +10,51 @@ </tutorials> <methods> <method name="create"> - <return type="void"> - </return> - <argument index="0" name="size" type="Vector2"> - </argument> + <return type="void" /> + <argument index="0" name="size" type="Vector2" /> <description> Creates a bitmap with the specified size, filled with [code]false[/code]. </description> </method> <method name="create_from_image_alpha"> - <return type="void"> - </return> - <argument index="0" name="image" type="Image"> - </argument> - <argument index="1" name="threshold" type="float" default="0.1"> - </argument> + <return type="void" /> + <argument index="0" name="image" type="Image" /> + <argument index="1" name="threshold" type="float" default="0.1" /> <description> Creates a bitmap that matches the given image dimensions, every element of the bitmap is set to [code]false[/code] if the alpha value of the image at that position is equal to [code]threshold[/code] or less, and [code]true[/code] in other case. </description> </method> <method name="get_bit" qualifiers="const"> - <return type="bool"> - </return> - <argument index="0" name="position" type="Vector2"> - </argument> + <return type="bool" /> + <argument index="0" name="position" type="Vector2" /> <description> Returns bitmap's value at the specified position. </description> </method> <method name="get_size" qualifiers="const"> - <return type="Vector2"> - </return> + <return type="Vector2" /> <description> Returns bitmap's dimensions. </description> </method> <method name="get_true_bit_count" qualifiers="const"> - <return type="int"> - </return> + <return type="int" /> <description> Returns the amount of bitmap elements that are set to [code]true[/code]. </description> </method> <method name="grow_mask"> - <return type="void"> - </return> - <argument index="0" name="pixels" type="int"> - </argument> - <argument index="1" name="rect" type="Rect2"> - </argument> + <return type="void" /> + <argument index="0" name="pixels" type="int" /> + <argument index="1" name="rect" type="Rect2" /> <description> Applies morphological dilation to the bitmap. The first argument is the dilation amount, Rect2 is the area where the dilation will be applied. </description> </method> <method name="opaque_to_polygons" qualifiers="const"> - <return type="Array"> - </return> - <argument index="0" name="rect" type="Rect2"> - </argument> - <argument index="1" name="epsilon" type="float" default="2.0"> - </argument> + <return type="Array" /> + <argument index="0" name="rect" type="Rect2" /> + <argument index="1" name="epsilon" type="float" default="2.0" /> <description> Creates an [Array] of polygons covering a rectangular portion of the bitmap. It uses a marching squares algorithm, followed by Ramer-Douglas-Peucker (RDP) reduction of the number of vertices. Each polygon is described as a [PackedVector2Array] of its vertices. To get polygons covering the whole bitmap, pass: @@ -80,23 +65,17 @@ </description> </method> <method name="set_bit"> - <return type="void"> - </return> - <argument index="0" name="position" type="Vector2"> - </argument> - <argument index="1" name="bit" type="bool"> - </argument> + <return type="void" /> + <argument index="0" name="position" type="Vector2" /> + <argument index="1" name="bit" type="bool" /> <description> Sets the bitmap's element at the specified position, to the specified value. </description> </method> <method name="set_bit_rect"> - <return type="void"> - </return> - <argument index="0" name="rect" type="Rect2"> - </argument> - <argument index="1" name="bit" type="bool"> - </argument> + <return type="void" /> + <argument index="0" name="rect" type="Rect2" /> + <argument index="1" name="bit" type="bool" /> <description> Sets a rectangular portion of the bitmap to the specified value. </description> diff --git a/doc/classes/Bone2D.xml b/doc/classes/Bone2D.xml index b8d5544d59..f9f3ea21f1 100644 --- a/doc/classes/Bone2D.xml +++ b/doc/classes/Bone2D.xml @@ -13,88 +13,73 @@ </tutorials> <methods> <method name="apply_rest"> - <return type="void"> - </return> + <return type="void" /> <description> Stores the node's current transforms in [member rest]. </description> </method> <method name="get_autocalculate_length_and_angle" qualifiers="const"> - <return type="bool"> - </return> + <return type="bool" /> <description> Returns whether this [code]Bone2D[/code] node is going to autocalculate its length and bone angle using its first [code]Bone2D[/code] child node, if one exists. If there are no [code]Bone2D[/code] children, then it cannot autocalculate these values and will print a warning. </description> </method> <method name="get_bone_angle" qualifiers="const"> - <return type="float"> - </return> + <return type="float" /> <description> Returns the angle of the bone in the [code]Bone2D[/code] node. [b]Note:[/b] This is different from the [code]Bone2D[/code]'s rotation. The bone angle is the rotation of the bone shown by the [code]Bone2D[/code] gizmo, and because [code]Bone2D[/code] bones are based on positions, this can vary from the actual rotation of the [code]Bone2D[/code] node. </description> </method> <method name="get_default_length" qualifiers="const"> - <return type="float"> - </return> + <return type="float" /> <description> Deprecated. Please use [code]get_length[/code] instead. </description> </method> <method name="get_index_in_skeleton" qualifiers="const"> - <return type="int"> - </return> + <return type="int" /> <description> Returns the node's index as part of the entire skeleton. See [Skeleton2D]. </description> </method> <method name="get_length" qualifiers="const"> - <return type="float"> - </return> + <return type="float" /> <description> Returns the length of the bone in the [code]Bone2D[/code] node. </description> </method> <method name="get_skeleton_rest" qualifiers="const"> - <return type="Transform2D"> - </return> + <return type="Transform2D" /> <description> Returns the node's [member rest] [code]Transform2D[/code] if it doesn't have a parent, or its rest pose relative to its parent. </description> </method> <method name="set_autocalculate_length_and_angle"> - <return type="void"> - </return> - <argument index="0" name="auto_calculate" type="bool"> - </argument> + <return type="void" /> + <argument index="0" name="auto_calculate" type="bool" /> <description> When set to [code]true[/code], the [code]Bone2D[/code] node will attempt to automatically calculate the bone angle and length using the first child [code]Bone2D[/code] node, if one exists. If none exist, the [code]Bone2D[/code] cannot automatically calculate these values and will print a warning. </description> </method> <method name="set_bone_angle"> - <return type="void"> - </return> - <argument index="0" name="angle" type="float"> - </argument> + <return type="void" /> + <argument index="0" name="angle" type="float" /> <description> Sets the bone angle for the [code]Bone2D[/code] node. This is typically set to the rotation from the [code]Bone2D[/code] node to a child [code]Bone2D[/code] node. [b]Note:[/b] This is different from the [code]Bone2D[/code]'s rotation. The bone angle is the rotation of the bone shown by the [code]Bone2D[/code] gizmo, and because [code]Bone2D[/code] bones are based on positions, this can vary from the actual rotation of the [code]Bone2D[/code] node. </description> </method> <method name="set_default_length"> - <return type="void"> - </return> - <argument index="0" name="default_length" type="float"> - </argument> + <return type="void" /> + <argument index="0" name="default_length" type="float" /> <description> Deprecated. Please use [code]set_length[/code] instead. </description> </method> <method name="set_length"> - <return type="void"> - </return> - <argument index="0" name="length" type="float"> - </argument> + <return type="void" /> + <argument index="0" name="length" type="float" /> <description> Sets the length of the bone in the [code]Bone2D[/code] node. </description> diff --git a/doc/classes/BoxContainer.xml b/doc/classes/BoxContainer.xml index ffa7c9066a..ec81b866f6 100644 --- a/doc/classes/BoxContainer.xml +++ b/doc/classes/BoxContainer.xml @@ -10,10 +10,8 @@ </tutorials> <methods> <method name="add_spacer"> - <return type="Control"> - </return> - <argument index="0" name="begin" type="bool"> - </argument> + <return type="Control" /> + <argument index="0" name="begin" type="bool" /> <description> Adds a [Control] node to the box as a spacer. If [code]begin[/code] is [code]true[/code], it will insert the [Control] node in front of all other children. </description> diff --git a/doc/classes/Button.xml b/doc/classes/Button.xml index 239e0bb2d9..823eda9c33 100644 --- a/doc/classes/Button.xml +++ b/doc/classes/Button.xml @@ -42,28 +42,22 @@ </tutorials> <methods> <method name="clear_opentype_features"> - <return type="void"> - </return> + <return type="void" /> <description> Removes all OpenType features. </description> </method> <method name="get_opentype_feature" qualifiers="const"> - <return type="int"> - </return> - <argument index="0" name="tag" type="String"> - </argument> + <return type="int" /> + <argument index="0" name="tag" type="String" /> <description> Returns OpenType feature [code]tag[/code]. </description> </method> <method name="set_opentype_feature"> - <return type="void"> - </return> - <argument index="0" name="tag" type="String"> - </argument> - <argument index="1" name="value" type="int"> - </argument> + <return type="void" /> + <argument index="0" name="tag" type="String" /> + <argument index="1" name="value" type="int" /> <description> Sets OpenType feature [code]tag[/code]. More info: [url=https://docs.microsoft.com/en-us/typography/opentype/spec/featuretags]OpenType feature tags[/url]. </description> diff --git a/doc/classes/ButtonGroup.xml b/doc/classes/ButtonGroup.xml index 0b31352611..302a213836 100644 --- a/doc/classes/ButtonGroup.xml +++ b/doc/classes/ButtonGroup.xml @@ -11,15 +11,13 @@ </tutorials> <methods> <method name="get_buttons"> - <return type="Array"> - </return> + <return type="Array" /> <description> Returns an [Array] of [Button]s who have this as their [ButtonGroup] (see [member BaseButton.button_group]). </description> </method> <method name="get_pressed_button"> - <return type="BaseButton"> - </return> + <return type="BaseButton" /> <description> Returns the current pressed button. </description> @@ -30,8 +28,7 @@ </members> <signals> <signal name="pressed"> - <argument index="0" name="button" type="Object"> - </argument> + <argument index="0" name="button" type="Object" /> <description> Emitted when one of the buttons of the group is pressed. </description> diff --git a/doc/classes/CPUParticles2D.xml b/doc/classes/CPUParticles2D.xml index 9620e9abd1..ab6897ca1d 100644 --- a/doc/classes/CPUParticles2D.xml +++ b/doc/classes/CPUParticles2D.xml @@ -12,97 +12,74 @@ </tutorials> <methods> <method name="convert_from_particles"> - <return type="void"> - </return> - <argument index="0" name="particles" type="Node"> - </argument> + <return type="void" /> + <argument index="0" name="particles" type="Node" /> <description> Sets this node's properties to match a given [GPUParticles2D] node with an assigned [ParticlesMaterial]. </description> </method> <method name="get_param" qualifiers="const"> - <return type="float"> - </return> - <argument index="0" name="param" type="int" enum="CPUParticles2D.Parameter"> - </argument> + <return type="float" /> + <argument index="0" name="param" type="int" enum="CPUParticles2D.Parameter" /> <description> Returns the base value of the parameter specified by [enum Parameter]. </description> </method> <method name="get_param_curve" qualifiers="const"> - <return type="Curve"> - </return> - <argument index="0" name="param" type="int" enum="CPUParticles2D.Parameter"> - </argument> + <return type="Curve" /> + <argument index="0" name="param" type="int" enum="CPUParticles2D.Parameter" /> <description> Returns the [Curve] of the parameter specified by [enum Parameter]. </description> </method> <method name="get_param_randomness" qualifiers="const"> - <return type="float"> - </return> - <argument index="0" name="param" type="int" enum="CPUParticles2D.Parameter"> - </argument> + <return type="float" /> + <argument index="0" name="param" type="int" enum="CPUParticles2D.Parameter" /> <description> Returns the randomness factor of the parameter specified by [enum Parameter]. </description> </method> <method name="get_particle_flag" qualifiers="const"> - <return type="bool"> - </return> - <argument index="0" name="particle_flag" type="int" enum="CPUParticles2D.ParticleFlags"> - </argument> + <return type="bool" /> + <argument index="0" name="particle_flag" type="int" enum="CPUParticles2D.ParticleFlags" /> <description> Returns the enabled state of the given flag (see [enum ParticleFlags] for options). </description> </method> <method name="restart"> - <return type="void"> - </return> + <return type="void" /> <description> Restarts the particle emitter. </description> </method> <method name="set_param"> - <return type="void"> - </return> - <argument index="0" name="param" type="int" enum="CPUParticles2D.Parameter"> - </argument> - <argument index="1" name="value" type="float"> - </argument> + <return type="void" /> + <argument index="0" name="param" type="int" enum="CPUParticles2D.Parameter" /> + <argument index="1" name="value" type="float" /> <description> Sets the base value of the parameter specified by [enum Parameter]. </description> </method> <method name="set_param_curve"> - <return type="void"> - </return> - <argument index="0" name="param" type="int" enum="CPUParticles2D.Parameter"> - </argument> - <argument index="1" name="curve" type="Curve"> - </argument> + <return type="void" /> + <argument index="0" name="param" type="int" enum="CPUParticles2D.Parameter" /> + <argument index="1" name="curve" type="Curve" /> <description> Sets the [Curve] of the parameter specified by [enum Parameter]. </description> </method> <method name="set_param_randomness"> - <return type="void"> - </return> - <argument index="0" name="param" type="int" enum="CPUParticles2D.Parameter"> - </argument> - <argument index="1" name="randomness" type="float"> - </argument> + <return type="void" /> + <argument index="0" name="param" type="int" enum="CPUParticles2D.Parameter" /> + <argument index="1" name="randomness" type="float" /> <description> Sets the randomness factor of the parameter specified by [enum Parameter]. </description> </method> <method name="set_particle_flag"> - <return type="void"> - </return> - <argument index="0" name="particle_flag" type="int" enum="CPUParticles2D.ParticleFlags"> - </argument> - <argument index="1" name="enable" type="bool"> - </argument> + <return type="void" /> + <argument index="0" name="particle_flag" type="int" enum="CPUParticles2D.ParticleFlags" /> + <argument index="1" name="enable" type="bool" /> <description> Enables or disables the given flag (see [enum ParticleFlags] for options). </description> @@ -152,7 +129,7 @@ Each particle's initial color. If [member texture] is defined, it will be multiplied by this color. </member> <member name="color_ramp" type="Gradient" setter="set_color_ramp" getter="get_color_ramp"> - Each particle's color will vary along this [Gradient]. + Each particle's color will vary along this [Gradient] (multiplied with [member color]). </member> <member name="damping" type="float" setter="set_param" getter="get_param" default="0.0"> The rate at which particles lose velocity. diff --git a/doc/classes/CPUParticles3D.xml b/doc/classes/CPUParticles3D.xml index 7509775d20..8aa3573996 100644 --- a/doc/classes/CPUParticles3D.xml +++ b/doc/classes/CPUParticles3D.xml @@ -11,97 +11,74 @@ </tutorials> <methods> <method name="convert_from_particles"> - <return type="void"> - </return> - <argument index="0" name="particles" type="Node"> - </argument> + <return type="void" /> + <argument index="0" name="particles" type="Node" /> <description> Sets this node's properties to match a given [GPUParticles3D] node with an assigned [ParticlesMaterial]. </description> </method> <method name="get_param" qualifiers="const"> - <return type="float"> - </return> - <argument index="0" name="param" type="int" enum="CPUParticles3D.Parameter"> - </argument> + <return type="float" /> + <argument index="0" name="param" type="int" enum="CPUParticles3D.Parameter" /> <description> Returns the base value of the parameter specified by [enum Parameter]. </description> </method> <method name="get_param_curve" qualifiers="const"> - <return type="Curve"> - </return> - <argument index="0" name="param" type="int" enum="CPUParticles3D.Parameter"> - </argument> + <return type="Curve" /> + <argument index="0" name="param" type="int" enum="CPUParticles3D.Parameter" /> <description> Returns the [Curve] of the parameter specified by [enum Parameter]. </description> </method> <method name="get_param_randomness" qualifiers="const"> - <return type="float"> - </return> - <argument index="0" name="param" type="int" enum="CPUParticles3D.Parameter"> - </argument> + <return type="float" /> + <argument index="0" name="param" type="int" enum="CPUParticles3D.Parameter" /> <description> Returns the randomness factor of the parameter specified by [enum Parameter]. </description> </method> <method name="get_particle_flag" qualifiers="const"> - <return type="bool"> - </return> - <argument index="0" name="particle_flag" type="int" enum="CPUParticles3D.ParticleFlags"> - </argument> + <return type="bool" /> + <argument index="0" name="particle_flag" type="int" enum="CPUParticles3D.ParticleFlags" /> <description> Returns the enabled state of the given particle flag (see [enum ParticleFlags] for options). </description> </method> <method name="restart"> - <return type="void"> - </return> + <return type="void" /> <description> Restarts the particle emitter. </description> </method> <method name="set_param"> - <return type="void"> - </return> - <argument index="0" name="param" type="int" enum="CPUParticles3D.Parameter"> - </argument> - <argument index="1" name="value" type="float"> - </argument> + <return type="void" /> + <argument index="0" name="param" type="int" enum="CPUParticles3D.Parameter" /> + <argument index="1" name="value" type="float" /> <description> Sets the base value of the parameter specified by [enum Parameter]. </description> </method> <method name="set_param_curve"> - <return type="void"> - </return> - <argument index="0" name="param" type="int" enum="CPUParticles3D.Parameter"> - </argument> - <argument index="1" name="curve" type="Curve"> - </argument> + <return type="void" /> + <argument index="0" name="param" type="int" enum="CPUParticles3D.Parameter" /> + <argument index="1" name="curve" type="Curve" /> <description> Sets the [Curve] of the parameter specified by [enum Parameter]. </description> </method> <method name="set_param_randomness"> - <return type="void"> - </return> - <argument index="0" name="param" type="int" enum="CPUParticles3D.Parameter"> - </argument> - <argument index="1" name="randomness" type="float"> - </argument> + <return type="void" /> + <argument index="0" name="param" type="int" enum="CPUParticles3D.Parameter" /> + <argument index="1" name="randomness" type="float" /> <description> Sets the randomness factor of the parameter specified by [enum Parameter]. </description> </method> <method name="set_particle_flag"> - <return type="void"> - </return> - <argument index="0" name="particle_flag" type="int" enum="CPUParticles3D.ParticleFlags"> - </argument> - <argument index="1" name="enable" type="bool"> - </argument> + <return type="void" /> + <argument index="0" name="particle_flag" type="int" enum="CPUParticles3D.ParticleFlags" /> + <argument index="1" name="enable" type="bool" /> <description> Enables or disables the given particle flag (see [enum ParticleFlags] for options). </description> @@ -148,10 +125,10 @@ Animation speed randomness ratio. </member> <member name="color" type="Color" setter="set_color" getter="get_color" default="Color(1, 1, 1, 1)"> - Unused for 3D particles. + Each particle's initial color. To have particle display color in a [BaseMaterial3D] make sure to set [member BaseMaterial3D.vertex_color_use_as_albedo] to [code]true[/code]. </member> <member name="color_ramp" type="Gradient" setter="set_color_ramp" getter="get_color_ramp"> - Unused for 3D particles. + Each particle's color will vary along this [GradientTexture] over its lifetime (multiplied with [member color]). </member> <member name="damping" type="float" setter="set_param" getter="get_param" default="0.0"> The rate at which particles lose velocity. @@ -177,9 +154,21 @@ <member name="emission_normals" type="PackedVector3Array" setter="set_emission_normals" getter="get_emission_normals"> Sets the direction the particles will be emitted in when using [constant EMISSION_SHAPE_DIRECTED_POINTS]. </member> - <member name="emission_points" type="PackedVector3Array" setter="set_emission_points" getter="get_emission_points" default="PackedVector3Array()"> + <member name="emission_points" type="PackedVector3Array" setter="set_emission_points" getter="get_emission_points"> Sets the initial positions to spawn particles when using [constant EMISSION_SHAPE_POINTS] or [constant EMISSION_SHAPE_DIRECTED_POINTS]. </member> + <member name="emission_ring_axis" type="Vector3" setter="set_emission_ring_axis" getter="get_emission_ring_axis"> + The axis of the ring when using the emitter [constant EMISSION_SHAPE_RING]. + </member> + <member name="emission_ring_height" type="float" setter="set_emission_ring_height" getter="get_emission_ring_height"> + The height of the ring when using the emitter [constant EMISSION_SHAPE_RING]. + </member> + <member name="emission_ring_inner_radius" type="float" setter="set_emission_ring_inner_radius" getter="get_emission_ring_inner_radius"> + The inner radius of the ring when using the emitter [constant EMISSION_SHAPE_RING]. + </member> + <member name="emission_ring_radius" type="float" setter="set_emission_ring_radius" getter="get_emission_ring_radius"> + The radius of the ring when using the emitter [constant EMISSION_SHAPE_RING]. + </member> <member name="emission_shape" type="int" setter="set_emission_shape" getter="get_emission_shape" enum="CPUParticles3D.EmissionShape" default="0"> Particles will be emitted inside this region. See [enum EmissionShape] for possible values. </member> @@ -378,7 +367,10 @@ <constant name="EMISSION_SHAPE_DIRECTED_POINTS" value="4" enum="EmissionShape"> Particles will be emitted at a position chosen randomly among [member emission_points]. Particle velocity and rotation will be set based on [member emission_normals]. Particle color will be modulated by [member emission_colors]. </constant> - <constant name="EMISSION_SHAPE_MAX" value="5" enum="EmissionShape"> + <constant name="EMISSION_SHAPE_RING" value="5" enum="EmissionShape"> + Particles will be emitted in a ring or cylinder. + </constant> + <constant name="EMISSION_SHAPE_MAX" value="6" enum="EmissionShape"> Represents the size of the [enum EmissionShape] enum. </constant> </constants> diff --git a/doc/classes/Callable.xml b/doc/classes/Callable.xml index 3c61e8278f..5228df706b 100644 --- a/doc/classes/Callable.xml +++ b/doc/classes/Callable.xml @@ -37,148 +37,122 @@ </tutorials> <methods> <method name="Callable" qualifiers="constructor"> - <return type="Callable"> - </return> + <return type="Callable" /> <description> Constructs a null [Callable] with no object nor method bound. </description> </method> <method name="Callable" qualifiers="constructor"> - <return type="Callable"> - </return> - <argument index="0" name="from" type="Callable"> - </argument> + <return type="Callable" /> + <argument index="0" name="from" type="Callable" /> <description> Constructs a [Callable] as a copy of the given [Callable]. </description> </method> <method name="Callable" qualifiers="constructor"> - <return type="Callable"> - </return> - <argument index="0" name="object" type="Object"> - </argument> - <argument index="1" name="method" type="StringName"> - </argument> + <return type="Callable" /> + <argument index="0" name="object" type="Object" /> + <argument index="1" name="method" type="StringName" /> <description> Creates a new [Callable] for the method called [code]method[/code] in the specified [code]object[/code]. </description> </method> <method name="bind" qualifiers="vararg const"> - <return type="Callable"> - </return> + <return type="Callable" /> <description> Returns a copy of this [Callable] with the arguments bound. Bound arguments are passed after the arguments supplied by [method call]. </description> </method> <method name="call" qualifiers="vararg const"> - <return type="Variant"> - </return> + <return type="Variant" /> <description> Calls the method represented by this [Callable]. Arguments can be passed and should match the method's signature. </description> </method> <method name="call_deferred" qualifiers="vararg const"> - <return type="void"> - </return> + <return type="void" /> <description> Calls the method represented by this [Callable] in deferred mode, i.e. during the idle frame. Arguments can be passed and should match the method's signature. </description> </method> <method name="get_method" qualifiers="const"> - <return type="StringName"> - </return> + <return type="StringName" /> <description> Returns the name of the method represented by this [Callable]. </description> </method> <method name="get_object" qualifiers="const"> - <return type="Object"> - </return> + <return type="Object" /> <description> Returns the object on which this [Callable] is called. </description> </method> <method name="get_object_id" qualifiers="const"> - <return type="int"> - </return> + <return type="int" /> <description> Returns the ID of this [Callable]'s object (see [method Object.get_instance_id]). </description> </method> <method name="hash" qualifiers="const"> - <return type="int"> - </return> + <return type="int" /> <description> Returns the hash value of this [Callable]'s object. </description> </method> <method name="is_custom" qualifiers="const"> - <return type="bool"> - </return> + <return type="bool" /> <description> Returns [code]true[/code] if this [Callable] is a custom callable whose behavior differs based on implementation details. Custom callables are used in the engine for various reasons. If [code]true[/code], you can't use [method get_method]. </description> </method> <method name="is_null" qualifiers="const"> - <return type="bool"> - </return> + <return type="bool" /> <description> Returns [code]true[/code] if this [Callable] has no target to call the method on. </description> </method> <method name="is_standard" qualifiers="const"> - <return type="bool"> - </return> + <return type="bool" /> <description> Returns [code]true[/code] if this [Callable] is a standard callable, referencing an object and a method using a [StringName]. </description> </method> <method name="is_valid" qualifiers="const"> - <return type="bool"> - </return> + <return type="bool" /> <description> Returns [code]true[/code] if the object exists and has a valid function assigned, or is a custom callable. </description> </method> <method name="operator !=" qualifiers="operator"> - <return type="bool"> - </return> - <argument index="0" name="right" type="Callable"> - </argument> + <return type="bool" /> + <argument index="0" name="right" type="Callable" /> <description> Returns [code]true[/code] if both [Callable]s invoke different targets. </description> </method> <method name="operator ==" qualifiers="operator"> - <return type="bool"> - </return> - <argument index="0" name="right" type="Callable"> - </argument> + <return type="bool" /> + <argument index="0" name="right" type="Callable" /> <description> Returns [code]true[/code] if both [Callable]s invoke the same custom target. </description> </method> <method name="rpc" qualifiers="vararg const"> - <return type="void"> - </return> + <return type="void" /> <description> Perform an RPC (Remote Procedure Call). This is used for multiplayer and is normally not available unless the function being called has been marked as [i]RPC[/i]. Calling it on unsupported functions will result in an error. </description> </method> <method name="rpc_id" qualifiers="vararg const"> - <return type="void"> - </return> - <argument index="0" name="peer_id" type="int"> - </argument> + <return type="void" /> + <argument index="0" name="peer_id" type="int" /> <description> Perform an RPC (Remote Procedure Call) on a specific peer ID (see multiplayer documentation for reference). This is used for multiplayer and is normally not available unless the function being called has been marked as [i]RPC[/i]. Calling it on unsupported functions will result in an error. </description> </method> <method name="unbind" qualifiers="const"> - <return type="Callable"> - </return> - <argument index="0" name="argcount" type="int"> - </argument> + <return type="Callable" /> + <argument index="0" name="argcount" type="int" /> <description> Returns a copy of this [Callable] with the arguments unbound. Calling the returned [Callable] will call the method without the extra arguments that are supplied in the [Callable] on which you are calling this method. </description> diff --git a/doc/classes/CallbackTweener.xml b/doc/classes/CallbackTweener.xml index 8ac285c3df..fab5f06ba8 100644 --- a/doc/classes/CallbackTweener.xml +++ b/doc/classes/CallbackTweener.xml @@ -11,10 +11,8 @@ </tutorials> <methods> <method name="set_delay"> - <return type="CallbackTweener"> - </return> - <argument index="0" name="delay" type="float"> - </argument> + <return type="CallbackTweener" /> + <argument index="0" name="delay" type="float" /> <description> Makes the callback call delayed by given time in seconds. Example: [codeblock] diff --git a/doc/classes/Camera2D.xml b/doc/classes/Camera2D.xml index 4620b3d93c..d0ff66ae06 100644 --- a/doc/classes/Camera2D.xml +++ b/doc/classes/Camera2D.xml @@ -5,7 +5,7 @@ </brief_description> <description> Camera node for 2D scenes. It forces the screen (current layer) to scroll following this node. This makes it easier (and faster) to program scrollable scenes than manually changing the position of [CanvasItem]-based nodes. - This node is intended to be a simple helper to get things going quickly and it may happen that more functionality is desired to change how the camera works. To make your own custom camera node, inherit from [Node2D] and change the transform of the canvas by setting [member Viewport.canvas_transform] in [Viewport] (you can obtain the current [Viewport] by using [method Node.get_viewport]). + This node is intended to be a simple helper to get things going quickly, but more functionality may be desired to change how the camera works. To make your own custom camera node, inherit it from [Node2D] and change the transform of the canvas by setting [member Viewport.canvas_transform] in [Viewport] (you can obtain the current [Viewport] by using [method Node.get_viewport]). Note that the [Camera2D] node's [code]position[/code] doesn't represent the actual position of the screen, which may differ due to applied smoothing or limits. You can use [method get_camera_screen_center] to get the real position. </description> <tutorials> @@ -15,91 +15,62 @@ </tutorials> <methods> <method name="align"> - <return type="void"> - </return> + <return type="void" /> <description> Aligns the camera to the tracked node. </description> </method> - <method name="clear_current"> - <return type="void"> - </return> - <description> - Removes any [Camera2D] from the ancestor [Viewport]'s internal currently-assigned camera. - </description> - </method> <method name="force_update_scroll"> - <return type="void"> - </return> + <return type="void" /> <description> Forces the camera to update scroll immediately. </description> </method> <method name="get_camera_position" qualifiers="const"> - <return type="Vector2"> - </return> + <return type="Vector2" /> <description> Returns the camera position. </description> </method> <method name="get_camera_screen_center" qualifiers="const"> - <return type="Vector2"> - </return> + <return type="Vector2" /> <description> Returns the location of the [Camera2D]'s screen-center, relative to the origin. </description> </method> <method name="get_drag_margin" qualifiers="const"> - <return type="float"> - </return> - <argument index="0" name="margin" type="int" enum="Side"> - </argument> + <return type="float" /> + <argument index="0" name="margin" type="int" enum="Side" /> <description> Returns the specified [enum Side]'s margin. See also [member drag_bottom_margin], [member drag_top_margin], [member drag_left_margin], and [member drag_right_margin]. </description> </method> <method name="get_limit" qualifiers="const"> - <return type="int"> - </return> - <argument index="0" name="margin" type="int" enum="Side"> - </argument> + <return type="int" /> + <argument index="0" name="margin" type="int" enum="Side" /> <description> Returns the camera limit for the specified [enum Side]. See also [member limit_bottom], [member limit_top], [member limit_left], and [member limit_right]. </description> </method> - <method name="make_current"> - <return type="void"> - </return> - <description> - Make this the current 2D camera for the scene (viewport and layer), in case there are many cameras in the scene. - </description> - </method> <method name="reset_smoothing"> - <return type="void"> - </return> + <return type="void" /> <description> Sets the camera's position immediately to its current smoothing destination. This has no effect if smoothing is disabled. </description> </method> <method name="set_drag_margin"> - <return type="void"> - </return> - <argument index="0" name="margin" type="int" enum="Side"> - </argument> - <argument index="1" name="drag_margin" type="float"> - </argument> + <return type="void" /> + <argument index="0" name="margin" type="int" enum="Side" /> + <argument index="1" name="drag_margin" type="float" /> <description> Sets the specified [enum Side]'s margin. See also [member drag_bottom_margin], [member drag_top_margin], [member drag_left_margin], and [member drag_right_margin]. </description> </method> <method name="set_limit"> - <return type="void"> - </return> - <argument index="0" name="margin" type="int" enum="Side"> - </argument> - <argument index="1" name="limit" type="int"> - </argument> + <return type="void" /> + <argument index="0" name="margin" type="int" enum="Side" /> + <argument index="1" name="limit" type="int" /> <description> Sets the camera limit for the specified [enum Side]. See also [member limit_bottom], [member limit_top], [member limit_left], and [member limit_right]. </description> @@ -109,7 +80,7 @@ <member name="anchor_mode" type="int" setter="set_anchor_mode" getter="get_anchor_mode" enum="Camera2D.AnchorMode" default="1"> The Camera2D's anchor point. See [enum AnchorMode] constants. </member> - <member name="current" type="bool" setter="_set_current" getter="is_current" default="false"> + <member name="current" type="bool" setter="set_current" getter="is_current" default="false"> If [code]true[/code], the camera is the active camera for the current scene. Only one camera can be current, so setting a different camera [code]current[/code] will disable this one. </member> <member name="custom_viewport" type="Node" setter="set_custom_viewport" getter="get_custom_viewport"> diff --git a/doc/classes/Camera3D.xml b/doc/classes/Camera3D.xml index afba478a20..2ada0c556d 100644 --- a/doc/classes/Camera3D.xml +++ b/doc/classes/Camera3D.xml @@ -11,173 +11,134 @@ </tutorials> <methods> <method name="clear_current"> - <return type="void"> - </return> - <argument index="0" name="enable_next" type="bool" default="true"> - </argument> + <return type="void" /> + <argument index="0" name="enable_next" type="bool" default="true" /> <description> If this is the current camera, remove it from being current. If [code]enable_next[/code] is [code]true[/code], request to make the next camera current, if any. </description> </method> <method name="get_camera_rid" qualifiers="const"> - <return type="RID"> - </return> + <return type="RID" /> <description> Returns the camera's RID from the [RenderingServer]. </description> </method> <method name="get_camera_transform" qualifiers="const"> - <return type="Transform3D"> - </return> + <return type="Transform3D" /> <description> Gets the camera transform. Subclassed cameras such as [ClippedCamera3D] may provide different transforms than the [Node] transform. </description> </method> <method name="get_cull_mask_bit" qualifiers="const"> - <return type="bool"> - </return> - <argument index="0" name="layer" type="int"> - </argument> + <return type="bool" /> + <argument index="0" name="layer" type="int" /> <description> Returns [code]true[/code] if the given [code]layer[/code] in the [member cull_mask] is enabled, [code]false[/code] otherwise. </description> </method> <method name="get_frustum" qualifiers="const"> - <return type="Array"> - </return> + <return type="Array" /> <description> - Returns the camera's frustum planes in world-space units as an array of [Plane]s in the following order: near, far, left, top, right, bottom. Not to be confused with [member frustum_offset]. + Returns the camera's frustum planes in world space units as an array of [Plane]s in the following order: near, far, left, top, right, bottom. Not to be confused with [member frustum_offset]. </description> </method> <method name="is_position_behind" qualifiers="const"> - <return type="bool"> - </return> - <argument index="0" name="world_point" type="Vector3"> - </argument> + <return type="bool" /> + <argument index="0" name="world_point" type="Vector3" /> <description> Returns [code]true[/code] if the given position is behind the camera (the blue part of the linked diagram). [url=https://raw.githubusercontent.com/godotengine/godot-docs/master/img/camera3d_position_frustum.png]See this diagram[/url] for an overview of position query methods. [b]Note:[/b] A position which returns [code]false[/code] may still be outside the camera's field of view. </description> </method> <method name="is_position_in_frustum" qualifiers="const"> - <return type="bool"> - </return> - <argument index="0" name="world_point" type="Vector3"> - </argument> + <return type="bool" /> + <argument index="0" name="world_point" type="Vector3" /> <description> Returns [code]true[/code] if the given position is inside the camera's frustum (the green part of the linked diagram). [url=https://raw.githubusercontent.com/godotengine/godot-docs/master/img/camera3d_position_frustum.png]See this diagram[/url] for an overview of position query methods. </description> </method> <method name="make_current"> - <return type="void"> - </return> + <return type="void" /> <description> Makes this camera the current camera for the [Viewport] (see class description). If the camera node is outside the scene tree, it will attempt to become current once it's added. </description> </method> <method name="project_local_ray_normal" qualifiers="const"> - <return type="Vector3"> - </return> - <argument index="0" name="screen_point" type="Vector2"> - </argument> + <return type="Vector3" /> + <argument index="0" name="screen_point" type="Vector2" /> <description> Returns a normal vector from the screen point location directed along the camera. Orthogonal cameras are normalized. Perspective cameras account for perspective, screen width/height, etc. </description> </method> <method name="project_position" qualifiers="const"> - <return type="Vector3"> - </return> - <argument index="0" name="screen_point" type="Vector2"> - </argument> - <argument index="1" name="z_depth" type="float"> - </argument> + <return type="Vector3" /> + <argument index="0" name="screen_point" type="Vector2" /> + <argument index="1" name="z_depth" type="float" /> <description> - Returns the 3D point in worldspace that maps to the given 2D coordinate in the [Viewport] rectangle on a plane that is the given [code]z_depth[/code] distance into the scene away from the camera. + Returns the 3D point in world space that maps to the given 2D coordinate in the [Viewport] rectangle on a plane that is the given [code]z_depth[/code] distance into the scene away from the camera. </description> </method> <method name="project_ray_normal" qualifiers="const"> - <return type="Vector3"> - </return> - <argument index="0" name="screen_point" type="Vector2"> - </argument> + <return type="Vector3" /> + <argument index="0" name="screen_point" type="Vector2" /> <description> - Returns a normal vector in worldspace, that is the result of projecting a point on the [Viewport] rectangle by the camera projection. This is useful for casting rays in the form of (origin, normal) for object intersection or picking. + Returns a normal vector in world space, that is the result of projecting a point on the [Viewport] rectangle by the camera projection. This is useful for casting rays in the form of (origin, normal) for object intersection or picking. </description> </method> <method name="project_ray_origin" qualifiers="const"> - <return type="Vector3"> - </return> - <argument index="0" name="screen_point" type="Vector2"> - </argument> + <return type="Vector3" /> + <argument index="0" name="screen_point" type="Vector2" /> <description> - Returns a 3D position in worldspace, that is the result of projecting a point on the [Viewport] rectangle by the camera projection. This is useful for casting rays in the form of (origin, normal) for object intersection or picking. + Returns a 3D position in world space, that is the result of projecting a point on the [Viewport] rectangle by the camera projection. This is useful for casting rays in the form of (origin, normal) for object intersection or picking. </description> </method> <method name="set_cull_mask_bit"> - <return type="void"> - </return> - <argument index="0" name="layer" type="int"> - </argument> - <argument index="1" name="enable" type="bool"> - </argument> + <return type="void" /> + <argument index="0" name="layer" type="int" /> + <argument index="1" name="enable" type="bool" /> <description> Enables or disables the given [code]layer[/code] in the [member cull_mask]. </description> </method> <method name="set_frustum"> - <return type="void"> - </return> - <argument index="0" name="size" type="float"> - </argument> - <argument index="1" name="offset" type="Vector2"> - </argument> - <argument index="2" name="z_near" type="float"> - </argument> - <argument index="3" name="z_far" type="float"> - </argument> + <return type="void" /> + <argument index="0" name="size" type="float" /> + <argument index="1" name="offset" type="Vector2" /> + <argument index="2" name="z_near" type="float" /> + <argument index="3" name="z_far" type="float" /> <description> - Sets the camera projection to frustum mode (see [constant PROJECTION_FRUSTUM]), by specifying a [code]size[/code], an [code]offset[/code], and the [code]z_near[/code] and [code]z_far[/code] clip planes in world-space units. + Sets the camera projection to frustum mode (see [constant PROJECTION_FRUSTUM]), by specifying a [code]size[/code], an [code]offset[/code], and the [code]z_near[/code] and [code]z_far[/code] clip planes in world space units. </description> </method> <method name="set_orthogonal"> - <return type="void"> - </return> - <argument index="0" name="size" type="float"> - </argument> - <argument index="1" name="z_near" type="float"> - </argument> - <argument index="2" name="z_far" type="float"> - </argument> + <return type="void" /> + <argument index="0" name="size" type="float" /> + <argument index="1" name="z_near" type="float" /> + <argument index="2" name="z_far" type="float" /> <description> - Sets the camera projection to orthogonal mode (see [constant PROJECTION_ORTHOGONAL]), by specifying a [code]size[/code], and the [code]z_near[/code] and [code]z_far[/code] clip planes in world-space units. (As a hint, 2D games often use this projection, with values specified in pixels.) + Sets the camera projection to orthogonal mode (see [constant PROJECTION_ORTHOGONAL]), by specifying a [code]size[/code], and the [code]z_near[/code] and [code]z_far[/code] clip planes in world space units. (As a hint, 2D games often use this projection, with values specified in pixels.) </description> </method> <method name="set_perspective"> - <return type="void"> - </return> - <argument index="0" name="fov" type="float"> - </argument> - <argument index="1" name="z_near" type="float"> - </argument> - <argument index="2" name="z_far" type="float"> - </argument> + <return type="void" /> + <argument index="0" name="fov" type="float" /> + <argument index="1" name="z_near" type="float" /> + <argument index="2" name="z_far" type="float" /> <description> - Sets the camera projection to perspective mode (see [constant PROJECTION_PERSPECTIVE]), by specifying a [code]fov[/code] (field of view) angle in degrees, and the [code]z_near[/code] and [code]z_far[/code] clip planes in world-space units. + Sets the camera projection to perspective mode (see [constant PROJECTION_PERSPECTIVE]), by specifying a [code]fov[/code] (field of view) angle in degrees, and the [code]z_near[/code] and [code]z_far[/code] clip planes in world space units. </description> </method> <method name="unproject_position" qualifiers="const"> - <return type="Vector2"> - </return> - <argument index="0" name="world_point" type="Vector3"> - </argument> + <return type="Vector2" /> + <argument index="0" name="world_point" type="Vector3" /> <description> - Returns the 2D coordinate in the [Viewport] rectangle that maps to the given 3D point in worldspace. + Returns the 2D coordinate in the [Viewport] rectangle that maps to the given 3D point in world space. [b]Note:[/b] When using this to position GUI elements over a 3D viewport, use [method is_position_behind] to prevent them from appearing if the 3D point is behind the camera: [codeblock] # This code block is part of a script that inherits from Node3D. # `control` is a reference to a node inheriting from Control. - control.visible = not get_viewport().get_camera().is_position_behind(global_transform.origin) - control.rect_position = get_viewport().get_camera().unproject_position(global_transform.origin) + control.visible = not get_viewport().get_camera_3d().is_position_behind(global_transform.origin) + control.rect_position = get_viewport().get_camera_3d().unproject_position(global_transform.origin) [/codeblock] </description> </method> diff --git a/doc/classes/CameraServer.xml b/doc/classes/CameraServer.xml index e00dc031dc..404ea08851 100644 --- a/doc/classes/CameraServer.xml +++ b/doc/classes/CameraServer.xml @@ -12,42 +12,34 @@ </tutorials> <methods> <method name="add_feed"> - <return type="void"> - </return> - <argument index="0" name="feed" type="CameraFeed"> - </argument> + <return type="void" /> + <argument index="0" name="feed" type="CameraFeed" /> <description> Adds the camera [code]feed[/code] to the camera server. </description> </method> <method name="feeds"> - <return type="Array"> - </return> + <return type="Array" /> <description> Returns an array of [CameraFeed]s. </description> </method> <method name="get_feed"> - <return type="CameraFeed"> - </return> - <argument index="0" name="index" type="int"> - </argument> + <return type="CameraFeed" /> + <argument index="0" name="index" type="int" /> <description> Returns the [CameraFeed] corresponding to the camera with the given [code]index[/code]. </description> </method> <method name="get_feed_count"> - <return type="int"> - </return> + <return type="int" /> <description> Returns the number of [CameraFeed]s registered. </description> </method> <method name="remove_feed"> - <return type="void"> - </return> - <argument index="0" name="feed" type="CameraFeed"> - </argument> + <return type="void" /> + <argument index="0" name="feed" type="CameraFeed" /> <description> Removes the specified camera [code]feed[/code]. </description> @@ -55,15 +47,13 @@ </methods> <signals> <signal name="camera_feed_added"> - <argument index="0" name="id" type="int"> - </argument> + <argument index="0" name="id" type="int" /> <description> Emitted when a [CameraFeed] is added (e.g. a webcam is plugged in). </description> </signal> <signal name="camera_feed_removed"> - <argument index="0" name="id" type="int"> - </argument> + <argument index="0" name="id" type="int" /> <description> Emitted when a [CameraFeed] is removed (e.g. a webcam is unplugged). </description> diff --git a/doc/classes/CanvasItem.xml b/doc/classes/CanvasItem.xml index d0950ae741..2c92ce0185 100644 --- a/doc/classes/CanvasItem.xml +++ b/doc/classes/CanvasItem.xml @@ -18,327 +18,217 @@ </tutorials> <methods> <method name="_draw" qualifiers="virtual"> - <return type="void"> - </return> + <return type="void" /> <description> Overridable function called by the engine (if defined) to draw the canvas item. </description> </method> <method name="draw_animation_slice"> - <return type="void"> - </return> - <argument index="0" name="animation_length" type="float"> - </argument> - <argument index="1" name="slice_begin" type="float"> - </argument> - <argument index="2" name="slice_end" type="float"> - </argument> - <argument index="3" name="offset" type="float" default="0.0"> - </argument> + <return type="void" /> + <argument index="0" name="animation_length" type="float" /> + <argument index="1" name="slice_begin" type="float" /> + <argument index="2" name="slice_end" type="float" /> + <argument index="3" name="offset" type="float" default="0.0" /> <description> Subsequent drawing commands will be ignored unless they fall within the specified animation slice. This is a faster way to implement animations that loop on background rather than redrawing constantly. </description> </method> <method name="draw_arc"> - <return type="void"> - </return> - <argument index="0" name="center" type="Vector2"> - </argument> - <argument index="1" name="radius" type="float"> - </argument> - <argument index="2" name="start_angle" type="float"> - </argument> - <argument index="3" name="end_angle" type="float"> - </argument> - <argument index="4" name="point_count" type="int"> - </argument> - <argument index="5" name="color" type="Color"> - </argument> - <argument index="6" name="width" type="float" default="1.0"> - </argument> - <argument index="7" name="antialiased" type="bool" default="false"> - </argument> + <return type="void" /> + <argument index="0" name="center" type="Vector2" /> + <argument index="1" name="radius" type="float" /> + <argument index="2" name="start_angle" type="float" /> + <argument index="3" name="end_angle" type="float" /> + <argument index="4" name="point_count" type="int" /> + <argument index="5" name="color" type="Color" /> + <argument index="6" name="width" type="float" default="1.0" /> + <argument index="7" name="antialiased" type="bool" default="false" /> <description> Draws an arc between the given angles. The larger the value of [code]point_count[/code], the smoother the curve. </description> </method> <method name="draw_char" qualifiers="const"> - <return type="float"> - </return> - <argument index="0" name="font" type="Font"> - </argument> - <argument index="1" name="pos" type="Vector2"> - </argument> - <argument index="2" name="char" type="String"> - </argument> - <argument index="3" name="next" type="String" default=""""> - </argument> - <argument index="4" name="size" type="int" default="-1"> - </argument> - <argument index="5" name="modulate" type="Color" default="Color(1, 1, 1, 1)"> - </argument> - <argument index="6" name="outline_size" type="int" default="0"> - </argument> - <argument index="7" name="outline_modulate" type="Color" default="Color(1, 1, 1, 0)"> - </argument> + <return type="float" /> + <argument index="0" name="font" type="Font" /> + <argument index="1" name="pos" type="Vector2" /> + <argument index="2" name="char" type="String" /> + <argument index="3" name="next" type="String" default="""" /> + <argument index="4" name="size" type="int" default="-1" /> + <argument index="5" name="modulate" type="Color" default="Color(1, 1, 1, 1)" /> + <argument index="6" name="outline_size" type="int" default="0" /> + <argument index="7" name="outline_modulate" type="Color" default="Color(1, 1, 1, 0)" /> <description> Draws a string character using a custom font. Returns the advance, depending on the character width and kerning with an optional next character. </description> </method> <method name="draw_circle"> - <return type="void"> - </return> - <argument index="0" name="position" type="Vector2"> - </argument> - <argument index="1" name="radius" type="float"> - </argument> - <argument index="2" name="color" type="Color"> - </argument> + <return type="void" /> + <argument index="0" name="position" type="Vector2" /> + <argument index="1" name="radius" type="float" /> + <argument index="2" name="color" type="Color" /> <description> Draws a colored circle. </description> </method> <method name="draw_colored_polygon"> - <return type="void"> - </return> - <argument index="0" name="points" type="PackedVector2Array"> - </argument> - <argument index="1" name="color" type="Color"> - </argument> - <argument index="2" name="uvs" type="PackedVector2Array" default="PackedVector2Array()"> - </argument> - <argument index="3" name="texture" type="Texture2D" default="null"> - </argument> + <return type="void" /> + <argument index="0" name="points" type="PackedVector2Array" /> + <argument index="1" name="color" type="Color" /> + <argument index="2" name="uvs" type="PackedVector2Array" default="PackedVector2Array()" /> + <argument index="3" name="texture" type="Texture2D" default="null" /> <description> Draws a colored polygon of any amount of points, convex or concave. </description> </method> <method name="draw_end_animation"> - <return type="void"> - </return> + <return type="void" /> <description> After submitting all animations slices via [method draw_animation_slice], this function can be used to revert drawing to its default state (all subsequent drawing commands will be visible). If you don't care about this particular use case, usage of this function after submitting the slices is not required. </description> </method> <method name="draw_line"> - <return type="void"> - </return> - <argument index="0" name="from" type="Vector2"> - </argument> - <argument index="1" name="to" type="Vector2"> - </argument> - <argument index="2" name="color" type="Color"> - </argument> - <argument index="3" name="width" type="float" default="1.0"> - </argument> + <return type="void" /> + <argument index="0" name="from" type="Vector2" /> + <argument index="1" name="to" type="Vector2" /> + <argument index="2" name="color" type="Color" /> + <argument index="3" name="width" type="float" default="1.0" /> <description> Draws a line from a 2D point to another, with a given color and width. </description> </method> <method name="draw_mesh"> - <return type="void"> - </return> - <argument index="0" name="mesh" type="Mesh"> - </argument> - <argument index="1" name="texture" type="Texture2D"> - </argument> - <argument index="2" name="transform" type="Transform2D" default="Transform2D(1, 0, 0, 1, 0, 0)"> - </argument> - <argument index="3" name="modulate" type="Color" default="Color(1, 1, 1, 1)"> - </argument> + <return type="void" /> + <argument index="0" name="mesh" type="Mesh" /> + <argument index="1" name="texture" type="Texture2D" /> + <argument index="2" name="transform" type="Transform2D" default="Transform2D(1, 0, 0, 1, 0, 0)" /> + <argument index="3" name="modulate" type="Color" default="Color(1, 1, 1, 1)" /> <description> Draws a [Mesh] in 2D, using the provided texture. See [MeshInstance2D] for related documentation. </description> </method> <method name="draw_multiline"> - <return type="void"> - </return> - <argument index="0" name="points" type="PackedVector2Array"> - </argument> - <argument index="1" name="color" type="Color"> - </argument> - <argument index="2" name="width" type="float" default="1.0"> - </argument> + <return type="void" /> + <argument index="0" name="points" type="PackedVector2Array" /> + <argument index="1" name="color" type="Color" /> + <argument index="2" name="width" type="float" default="1.0" /> <description> Draws multiple, parallel lines with a uniform [code]color[/code]. </description> </method> <method name="draw_multiline_colors"> - <return type="void"> - </return> - <argument index="0" name="points" type="PackedVector2Array"> - </argument> - <argument index="1" name="colors" type="PackedColorArray"> - </argument> - <argument index="2" name="width" type="float" default="1.0"> - </argument> + <return type="void" /> + <argument index="0" name="points" type="PackedVector2Array" /> + <argument index="1" name="colors" type="PackedColorArray" /> + <argument index="2" name="width" type="float" default="1.0" /> <description> Draws multiple, parallel lines with a uniform [code]width[/code] and segment-by-segment coloring. Colors assigned to line segments match by index between [code]points[/code] and [code]colors[/code]. </description> </method> <method name="draw_multiline_string" qualifiers="const"> - <return type="void"> - </return> - <argument index="0" name="font" type="Font"> - </argument> - <argument index="1" name="pos" type="Vector2"> - </argument> - <argument index="2" name="text" type="String"> - </argument> - <argument index="3" name="align" type="int" enum="HAlign" default="0"> - </argument> - <argument index="4" name="width" type="float" default="-1"> - </argument> - <argument index="5" name="max_lines" type="int" default="-1"> - </argument> - <argument index="6" name="size" type="int" default="-1"> - </argument> - <argument index="7" name="modulate" type="Color" default="Color(1, 1, 1, 1)"> - </argument> - <argument index="8" name="outline_size" type="int" default="0"> - </argument> - <argument index="9" name="outline_modulate" type="Color" default="Color(1, 1, 1, 0)"> - </argument> - <argument index="10" name="flags" type="int" default="51"> - </argument> + <return type="void" /> + <argument index="0" name="font" type="Font" /> + <argument index="1" name="pos" type="Vector2" /> + <argument index="2" name="text" type="String" /> + <argument index="3" name="align" type="int" enum="HAlign" default="0" /> + <argument index="4" name="width" type="float" default="-1" /> + <argument index="5" name="max_lines" type="int" default="-1" /> + <argument index="6" name="size" type="int" default="-1" /> + <argument index="7" name="modulate" type="Color" default="Color(1, 1, 1, 1)" /> + <argument index="8" name="outline_size" type="int" default="0" /> + <argument index="9" name="outline_modulate" type="Color" default="Color(1, 1, 1, 0)" /> + <argument index="10" name="flags" type="int" default="51" /> <description> Breaks [code]text[/code] to the lines and draws it using the specified [code]font[/code] at the [code]position[/code] (top-left corner). The text will have its color multiplied by [code]modulate[/code]. If [code]clip_w[/code] is greater than or equal to 0, the text will be clipped if it exceeds the specified width. </description> </method> <method name="draw_multimesh"> - <return type="void"> - </return> - <argument index="0" name="multimesh" type="MultiMesh"> - </argument> - <argument index="1" name="texture" type="Texture2D"> - </argument> + <return type="void" /> + <argument index="0" name="multimesh" type="MultiMesh" /> + <argument index="1" name="texture" type="Texture2D" /> <description> Draws a [MultiMesh] in 2D with the provided texture. See [MultiMeshInstance2D] for related documentation. </description> </method> <method name="draw_polygon"> - <return type="void"> - </return> - <argument index="0" name="points" type="PackedVector2Array"> - </argument> - <argument index="1" name="colors" type="PackedColorArray"> - </argument> - <argument index="2" name="uvs" type="PackedVector2Array" default="PackedVector2Array()"> - </argument> - <argument index="3" name="texture" type="Texture2D" default="null"> - </argument> + <return type="void" /> + <argument index="0" name="points" type="PackedVector2Array" /> + <argument index="1" name="colors" type="PackedColorArray" /> + <argument index="2" name="uvs" type="PackedVector2Array" default="PackedVector2Array()" /> + <argument index="3" name="texture" type="Texture2D" default="null" /> <description> Draws a polygon of any amount of points, convex or concave. </description> </method> <method name="draw_polyline"> - <return type="void"> - </return> - <argument index="0" name="points" type="PackedVector2Array"> - </argument> - <argument index="1" name="color" type="Color"> - </argument> - <argument index="2" name="width" type="float" default="1.0"> - </argument> - <argument index="3" name="antialiased" type="bool" default="false"> - </argument> + <return type="void" /> + <argument index="0" name="points" type="PackedVector2Array" /> + <argument index="1" name="color" type="Color" /> + <argument index="2" name="width" type="float" default="1.0" /> + <argument index="3" name="antialiased" type="bool" default="false" /> <description> Draws interconnected line segments with a uniform [code]color[/code] and [code]width[/code]. </description> </method> <method name="draw_polyline_colors"> - <return type="void"> - </return> - <argument index="0" name="points" type="PackedVector2Array"> - </argument> - <argument index="1" name="colors" type="PackedColorArray"> - </argument> - <argument index="2" name="width" type="float" default="1.0"> - </argument> - <argument index="3" name="antialiased" type="bool" default="false"> - </argument> + <return type="void" /> + <argument index="0" name="points" type="PackedVector2Array" /> + <argument index="1" name="colors" type="PackedColorArray" /> + <argument index="2" name="width" type="float" default="1.0" /> + <argument index="3" name="antialiased" type="bool" default="false" /> <description> Draws interconnected line segments with a uniform [code]width[/code] and segment-by-segment coloring. Colors assigned to line segments match by index between [code]points[/code] and [code]colors[/code]. </description> </method> <method name="draw_primitive"> - <return type="void"> - </return> - <argument index="0" name="points" type="PackedVector2Array"> - </argument> - <argument index="1" name="colors" type="PackedColorArray"> - </argument> - <argument index="2" name="uvs" type="PackedVector2Array"> - </argument> - <argument index="3" name="texture" type="Texture2D" default="null"> - </argument> - <argument index="4" name="width" type="float" default="1.0"> - </argument> + <return type="void" /> + <argument index="0" name="points" type="PackedVector2Array" /> + <argument index="1" name="colors" type="PackedColorArray" /> + <argument index="2" name="uvs" type="PackedVector2Array" /> + <argument index="3" name="texture" type="Texture2D" default="null" /> + <argument index="4" name="width" type="float" default="1.0" /> <description> Draws a custom primitive. 1 point for a point, 2 points for a line, 3 points for a triangle, and 4 points for a quad. </description> </method> <method name="draw_rect"> - <return type="void"> - </return> - <argument index="0" name="rect" type="Rect2"> - </argument> - <argument index="1" name="color" type="Color"> - </argument> - <argument index="2" name="filled" type="bool" default="true"> - </argument> - <argument index="3" name="width" type="float" default="1.0"> - </argument> + <return type="void" /> + <argument index="0" name="rect" type="Rect2" /> + <argument index="1" name="color" type="Color" /> + <argument index="2" name="filled" type="bool" default="true" /> + <argument index="3" name="width" type="float" default="1.0" /> <description> Draws a rectangle. If [code]filled[/code] is [code]true[/code], the rectangle will be filled with the [code]color[/code] specified. If [code]filled[/code] is [code]false[/code], the rectangle will be drawn as a stroke with the [code]color[/code] and [code]width[/code] specified. [b]Note:[/b] [code]width[/code] is only effective if [code]filled[/code] is [code]false[/code]. </description> </method> <method name="draw_set_transform"> - <return type="void"> - </return> - <argument index="0" name="position" type="Vector2"> - </argument> - <argument index="1" name="rotation" type="float" default="0.0"> - </argument> - <argument index="2" name="scale" type="Vector2" default="Vector2(1, 1)"> - </argument> + <return type="void" /> + <argument index="0" name="position" type="Vector2" /> + <argument index="1" name="rotation" type="float" default="0.0" /> + <argument index="2" name="scale" type="Vector2" default="Vector2(1, 1)" /> <description> Sets a custom transform for drawing via components. Anything drawn afterwards will be transformed by this. </description> </method> <method name="draw_set_transform_matrix"> - <return type="void"> - </return> - <argument index="0" name="xform" type="Transform2D"> - </argument> + <return type="void" /> + <argument index="0" name="xform" type="Transform2D" /> <description> Sets a custom transform for drawing via matrix. Anything drawn afterwards will be transformed by this. </description> </method> <method name="draw_string" qualifiers="const"> - <return type="void"> - </return> - <argument index="0" name="font" type="Font"> - </argument> - <argument index="1" name="pos" type="Vector2"> - </argument> - <argument index="2" name="text" type="String"> - </argument> - <argument index="3" name="align" type="int" enum="HAlign" default="0"> - </argument> - <argument index="4" name="width" type="float" default="-1"> - </argument> - <argument index="5" name="size" type="int" default="-1"> - </argument> - <argument index="6" name="modulate" type="Color" default="Color(1, 1, 1, 1)"> - </argument> - <argument index="7" name="outline_size" type="int" default="0"> - </argument> - <argument index="8" name="outline_modulate" type="Color" default="Color(1, 1, 1, 0)"> - </argument> - <argument index="9" name="flags" type="int" default="3"> - </argument> + <return type="void" /> + <argument index="0" name="font" type="Font" /> + <argument index="1" name="pos" type="Vector2" /> + <argument index="2" name="text" type="String" /> + <argument index="3" name="align" type="int" enum="HAlign" default="0" /> + <argument index="4" name="width" type="float" default="-1" /> + <argument index="5" name="size" type="int" default="-1" /> + <argument index="6" name="modulate" type="Color" default="Color(1, 1, 1, 1)" /> + <argument index="7" name="outline_size" type="int" default="0" /> + <argument index="8" name="outline_modulate" type="Color" default="Color(1, 1, 1, 0)" /> + <argument index="9" name="flags" type="int" default="3" /> <description> Draws [code]text[/code] using the specified [code]font[/code] at the [code]position[/code] (bottom-left corner using the baseline of the font). The text will have its color multiplied by [code]modulate[/code]. If [code]clip_w[/code] is greater than or equal to 0, the text will be clipped if it exceeds the specified width. [b]Example using the default project font:[/b] @@ -364,223 +254,177 @@ </description> </method> <method name="draw_style_box"> - <return type="void"> - </return> - <argument index="0" name="style_box" type="StyleBox"> - </argument> - <argument index="1" name="rect" type="Rect2"> - </argument> + <return type="void" /> + <argument index="0" name="style_box" type="StyleBox" /> + <argument index="1" name="rect" type="Rect2" /> <description> Draws a styled rectangle. </description> </method> <method name="draw_texture"> - <return type="void"> - </return> - <argument index="0" name="texture" type="Texture2D"> - </argument> - <argument index="1" name="position" type="Vector2"> - </argument> - <argument index="2" name="modulate" type="Color" default="Color(1, 1, 1, 1)"> - </argument> + <return type="void" /> + <argument index="0" name="texture" type="Texture2D" /> + <argument index="1" name="position" type="Vector2" /> + <argument index="2" name="modulate" type="Color" default="Color(1, 1, 1, 1)" /> <description> Draws a texture at a given position. </description> </method> <method name="draw_texture_rect"> - <return type="void"> - </return> - <argument index="0" name="texture" type="Texture2D"> - </argument> - <argument index="1" name="rect" type="Rect2"> - </argument> - <argument index="2" name="tile" type="bool"> - </argument> - <argument index="3" name="modulate" type="Color" default="Color(1, 1, 1, 1)"> - </argument> - <argument index="4" name="transpose" type="bool" default="false"> - </argument> + <return type="void" /> + <argument index="0" name="texture" type="Texture2D" /> + <argument index="1" name="rect" type="Rect2" /> + <argument index="2" name="tile" type="bool" /> + <argument index="3" name="modulate" type="Color" default="Color(1, 1, 1, 1)" /> + <argument index="4" name="transpose" type="bool" default="false" /> <description> Draws a textured rectangle at a given position, optionally modulated by a color. If [code]transpose[/code] is [code]true[/code], the texture will have its X and Y coordinates swapped. </description> </method> <method name="draw_texture_rect_region"> - <return type="void"> - </return> - <argument index="0" name="texture" type="Texture2D"> - </argument> - <argument index="1" name="rect" type="Rect2"> - </argument> - <argument index="2" name="src_rect" type="Rect2"> - </argument> - <argument index="3" name="modulate" type="Color" default="Color(1, 1, 1, 1)"> - </argument> - <argument index="4" name="transpose" type="bool" default="false"> - </argument> - <argument index="5" name="clip_uv" type="bool" default="true"> - </argument> + <return type="void" /> + <argument index="0" name="texture" type="Texture2D" /> + <argument index="1" name="rect" type="Rect2" /> + <argument index="2" name="src_rect" type="Rect2" /> + <argument index="3" name="modulate" type="Color" default="Color(1, 1, 1, 1)" /> + <argument index="4" name="transpose" type="bool" default="false" /> + <argument index="5" name="clip_uv" type="bool" default="true" /> <description> Draws a textured rectangle region at a given position, optionally modulated by a color. If [code]transpose[/code] is [code]true[/code], the texture will have its X and Y coordinates swapped. </description> </method> <method name="force_update_transform"> - <return type="void"> - </return> + <return type="void" /> <description> Forces the transform to update. Transform changes in physics are not instant for performance reasons. Transforms are accumulated and then set. Use this if you need an up-to-date transform when doing physics operations. </description> </method> <method name="get_canvas" qualifiers="const"> - <return type="RID"> - </return> + <return type="RID" /> <description> Returns the [RID] of the [World2D] canvas where this item is in. </description> </method> <method name="get_canvas_item" qualifiers="const"> - <return type="RID"> - </return> + <return type="RID" /> <description> Returns the canvas item RID used by [RenderingServer] for this item. </description> </method> <method name="get_canvas_transform" qualifiers="const"> - <return type="Transform2D"> - </return> + <return type="Transform2D" /> <description> Returns the transform matrix of this item's canvas. </description> </method> <method name="get_global_mouse_position" qualifiers="const"> - <return type="Vector2"> - </return> + <return type="Vector2" /> <description> Returns the global position of the mouse. </description> </method> <method name="get_global_transform" qualifiers="const"> - <return type="Transform2D"> - </return> + <return type="Transform2D" /> <description> Returns the global transform matrix of this item. </description> </method> <method name="get_global_transform_with_canvas" qualifiers="const"> - <return type="Transform2D"> - </return> + <return type="Transform2D" /> <description> Returns the global transform matrix of this item in relation to the canvas. </description> </method> <method name="get_local_mouse_position" qualifiers="const"> - <return type="Vector2"> - </return> + <return type="Vector2" /> <description> Returns the mouse position relative to this item's position. </description> </method> <method name="get_transform" qualifiers="const"> - <return type="Transform2D"> - </return> + <return type="Transform2D" /> <description> Returns the transform matrix of this item. </description> </method> <method name="get_viewport_rect" qualifiers="const"> - <return type="Rect2"> - </return> + <return type="Rect2" /> <description> Returns the viewport's boundaries as a [Rect2]. </description> </method> <method name="get_viewport_transform" qualifiers="const"> - <return type="Transform2D"> - </return> + <return type="Transform2D" /> <description> Returns this item's transform in relation to the viewport. </description> </method> <method name="get_world_2d" qualifiers="const"> - <return type="World2D"> - </return> + <return type="World2D" /> <description> Returns the [World2D] where this item is in. </description> </method> <method name="hide"> - <return type="void"> - </return> + <return type="void" /> <description> Hide the [CanvasItem] if it's currently visible. </description> </method> <method name="is_local_transform_notification_enabled" qualifiers="const"> - <return type="bool"> - </return> + <return type="bool" /> <description> Returns [code]true[/code] if local transform notifications are communicated to children. </description> </method> <method name="is_transform_notification_enabled" qualifiers="const"> - <return type="bool"> - </return> + <return type="bool" /> <description> Returns [code]true[/code] if global transform notifications are communicated to children. </description> </method> <method name="is_visible_in_tree" qualifiers="const"> - <return type="bool"> - </return> + <return type="bool" /> <description> Returns [code]true[/code] if the node is present in the [SceneTree], its [member visible] property is [code]true[/code] and all its antecedents are also visible. If any antecedent is hidden, this node will not be visible in the scene tree. </description> </method> <method name="make_canvas_position_local" qualifiers="const"> - <return type="Vector2"> - </return> - <argument index="0" name="screen_point" type="Vector2"> - </argument> + <return type="Vector2" /> + <argument index="0" name="screen_point" type="Vector2" /> <description> Assigns [code]screen_point[/code] as this node's new local transform. </description> </method> <method name="make_input_local" qualifiers="const"> - <return type="InputEvent"> - </return> - <argument index="0" name="event" type="InputEvent"> - </argument> + <return type="InputEvent" /> + <argument index="0" name="event" type="InputEvent" /> <description> Transformations issued by [code]event[/code]'s inputs are applied in local space instead of global space. </description> </method> <method name="set_notify_local_transform"> - <return type="void"> - </return> - <argument index="0" name="enable" type="bool"> - </argument> + <return type="void" /> + <argument index="0" name="enable" type="bool" /> <description> If [code]enable[/code] is [code]true[/code], children will be updated with local transform data. </description> </method> <method name="set_notify_transform"> - <return type="void"> - </return> - <argument index="0" name="enable" type="bool"> - </argument> + <return type="void" /> + <argument index="0" name="enable" type="bool" /> <description> If [code]enable[/code] is [code]true[/code], children will be updated with global transform data. </description> </method> <method name="show"> - <return type="void"> - </return> + <return type="void" /> <description> Show the [CanvasItem] if it's currently hidden. For controls that inherit [Popup], the correct way to make them visible is to call one of the multiple [code]popup*()[/code] functions instead. </description> </method> <method name="update"> - <return type="void"> - </return> + <return type="void" /> <description> Queue the [CanvasItem] for update. [constant NOTIFICATION_DRAW] will be called on idle time to request redraw. </description> diff --git a/doc/classes/CanvasLayer.xml b/doc/classes/CanvasLayer.xml index eb99368079..616fb24a6f 100644 --- a/doc/classes/CanvasLayer.xml +++ b/doc/classes/CanvasLayer.xml @@ -13,8 +13,7 @@ </tutorials> <methods> <method name="get_canvas" qualifiers="const"> - <return type="RID"> - </return> + <return type="RID" /> <description> Returns the RID of the canvas used by this layer. </description> diff --git a/doc/classes/CharacterBody2D.xml b/doc/classes/CharacterBody2D.xml index b2d8aba174..1ace7ee6bf 100644 --- a/doc/classes/CharacterBody2D.xml +++ b/doc/classes/CharacterBody2D.xml @@ -16,24 +16,20 @@ </tutorials> <methods> <method name="get_floor_normal" qualifiers="const"> - <return type="Vector2"> - </return> + <return type="Vector2" /> <description> Returns the surface normal of the floor at the last collision point. Only valid after calling [method move_and_slide] and when [method is_on_floor] returns [code]true[/code]. </description> </method> <method name="get_floor_velocity" qualifiers="const"> - <return type="Vector2"> - </return> + <return type="Vector2" /> <description> Returns the linear velocity of the floor at the last collision point. Only valid after calling [method move_and_slide] and when [method is_on_floor] returns [code]true[/code]. </description> </method> <method name="get_slide_collision"> - <return type="KinematicCollision2D"> - </return> - <argument index="0" name="slide_idx" type="int"> - </argument> + <return type="KinematicCollision2D" /> + <argument index="0" name="slide_idx" type="int" /> <description> Returns a [KinematicCollision2D], which contains information about a collision that occurred during the last call to [method move_and_slide]. Since the body can collide several times in a single call to [method move_and_slide], you must specify the index of the collision in the range 0 to ([method get_slide_count] - 1). [b]Example usage:[/b] @@ -54,36 +50,31 @@ </description> </method> <method name="get_slide_count" qualifiers="const"> - <return type="int"> - </return> + <return type="int" /> <description> Returns the number of times the body collided and changed direction during the last call to [method move_and_slide]. </description> </method> <method name="is_on_ceiling" qualifiers="const"> - <return type="bool"> - </return> + <return type="bool" /> <description> Returns [code]true[/code] if the body collided with the ceiling on the last call of [method move_and_slide]. Otherwise, returns [code]false[/code]. </description> </method> <method name="is_on_floor" qualifiers="const"> - <return type="bool"> - </return> + <return type="bool" /> <description> Returns [code]true[/code] if the body collided with the floor on the last call of [method move_and_slide]. Otherwise, returns [code]false[/code]. </description> </method> <method name="is_on_wall" qualifiers="const"> - <return type="bool"> - </return> + <return type="bool" /> <description> Returns [code]true[/code] if the body collided with a wall on the last call of [method move_and_slide]. Otherwise, returns [code]false[/code]. </description> </method> <method name="move_and_slide"> - <return type="void"> - </return> + <return type="void" /> <description> Moves the body based on [member linear_velocity]. If the body collides with another, it will slide along the other body rather than stop immediately. If the other body is a [CharacterBody2D] or [RigidBody2D], it will also be affected by the motion of the other body. You can use this to make moving and rotating platforms, or to make nodes push other nodes. This method should be used in [method Node._physics_process] (or in a method called by [method Node._physics_process]), as it uses the physics step's [code]delta[/code] value automatically in calculations. Otherwise, the simulation will run at an incorrect speed. @@ -110,9 +101,6 @@ <member name="max_slides" type="int" setter="set_max_slides" getter="get_max_slides" default="4"> Maximum number of times the body can change direction before it stops when calling [method move_and_slide]. </member> - <member name="motion/sync_to_physics" type="bool" setter="set_sync_to_physics" getter="is_sync_to_physics_enabled" default="false"> - If [code]true[/code], the body's movement will be synchronized to the physics frame. This is useful when animating movement via [AnimationPlayer], for example on moving platforms. Do [b]not[/b] use together with [method move_and_slide] or [method PhysicsBody2D.move_and_collide] functions. - </member> <member name="snap" type="Vector2" setter="set_snap" getter="get_snap" default="Vector2(0, 0)"> When set to a value different from [code]Vector2(0, 0)[/code], the body is kept attached to slopes when calling [method move_and_slide]. As long as the [code]snap[/code] vector is in contact with the ground, the body will remain attached to the surface. This means you must disable snap in order to jump, for example. You can do this by setting [code]snap[/code] to [code]Vector2(0, 0)[/code]. diff --git a/doc/classes/CharacterBody3D.xml b/doc/classes/CharacterBody3D.xml index c76e02fac0..577ab5e84c 100644 --- a/doc/classes/CharacterBody3D.xml +++ b/doc/classes/CharacterBody3D.xml @@ -17,59 +17,50 @@ </tutorials> <methods> <method name="get_floor_normal" qualifiers="const"> - <return type="Vector3"> - </return> + <return type="Vector3" /> <description> Returns the surface normal of the floor at the last collision point. Only valid after calling [method move_and_slide] and when [method is_on_floor] returns [code]true[/code]. </description> </method> <method name="get_floor_velocity" qualifiers="const"> - <return type="Vector3"> - </return> + <return type="Vector3" /> <description> Returns the linear velocity of the floor at the last collision point. Only valid after calling [method move_and_slide] and when [method is_on_floor] returns [code]true[/code]. </description> </method> <method name="get_slide_collision"> - <return type="KinematicCollision3D"> - </return> - <argument index="0" name="slide_idx" type="int"> - </argument> + <return type="KinematicCollision3D" /> + <argument index="0" name="slide_idx" type="int" /> <description> Returns a [KinematicCollision3D], which contains information about a collision that occurred during the last call to [method move_and_slide]. Since the body can collide several times in a single call to [method move_and_slide], you must specify the index of the collision in the range 0 to ([method get_slide_count] - 1). </description> </method> <method name="get_slide_count" qualifiers="const"> - <return type="int"> - </return> + <return type="int" /> <description> Returns the number of times the body collided and changed direction during the last call to [method move_and_slide]. </description> </method> <method name="is_on_ceiling" qualifiers="const"> - <return type="bool"> - </return> + <return type="bool" /> <description> Returns [code]true[/code] if the body collided with the ceiling on the last call of [method move_and_slide]. Otherwise, returns [code]false[/code]. </description> </method> <method name="is_on_floor" qualifiers="const"> - <return type="bool"> - </return> + <return type="bool" /> <description> Returns [code]true[/code] if the body collided with the floor on the last call of [method move_and_slide]. Otherwise, returns [code]false[/code]. </description> </method> <method name="is_on_wall" qualifiers="const"> - <return type="bool"> - </return> + <return type="bool" /> <description> Returns [code]true[/code] if the body collided with a wall on the last call of [method move_and_slide]. Otherwise, returns [code]false[/code]. </description> </method> <method name="move_and_slide"> - <return type="void"> - </return> + <return type="void" /> <description> Moves the body based on [member linear_velocity]. If the body collides with another, it will slide along the other body rather than stop immediately. If the other body is a [CharacterBody3D] or [RigidBody3D], it will also be affected by the motion of the other body. You can use this to make moving and rotating platforms, or to make nodes push other nodes. This method should be used in [method Node._physics_process] (or in a method called by [method Node._physics_process]), as it uses the physics step's [code]delta[/code] value automatically in calculations. Otherwise, the simulation will run at an incorrect speed. diff --git a/doc/classes/ClassDB.xml b/doc/classes/ClassDB.xml index 028781d313..063233fe50 100644 --- a/doc/classes/ClassDB.xml +++ b/doc/classes/ClassDB.xml @@ -10,208 +10,155 @@ </tutorials> <methods> <method name="can_instantiate" qualifiers="const"> - <return type="bool"> - </return> - <argument index="0" name="class" type="StringName"> - </argument> + <return type="bool" /> + <argument index="0" name="class" type="StringName" /> <description> Returns [code]true[/code] if you can instance objects from the specified [code]class[/code], [code]false[/code] in other case. </description> </method> <method name="class_exists" qualifiers="const"> - <return type="bool"> - </return> - <argument index="0" name="class" type="StringName"> - </argument> + <return type="bool" /> + <argument index="0" name="class" type="StringName" /> <description> Returns whether the specified [code]class[/code] is available or not. </description> </method> <method name="class_get_category" qualifiers="const"> - <return type="StringName"> - </return> - <argument index="0" name="class" type="StringName"> - </argument> + <return type="StringName" /> + <argument index="0" name="class" type="StringName" /> <description> Returns a category associated with the class for use in documentation and the Asset Library. Debug mode required. </description> </method> <method name="class_get_integer_constant" qualifiers="const"> - <return type="int"> - </return> - <argument index="0" name="class" type="StringName"> - </argument> - <argument index="1" name="name" type="StringName"> - </argument> + <return type="int" /> + <argument index="0" name="class" type="StringName" /> + <argument index="1" name="name" type="StringName" /> <description> Returns the value of the integer constant [code]name[/code] of [code]class[/code] or its ancestry. Always returns 0 when the constant could not be found. </description> </method> <method name="class_get_integer_constant_list" qualifiers="const"> - <return type="PackedStringArray"> - </return> - <argument index="0" name="class" type="StringName"> - </argument> - <argument index="1" name="no_inheritance" type="bool" default="false"> - </argument> + <return type="PackedStringArray" /> + <argument index="0" name="class" type="StringName" /> + <argument index="1" name="no_inheritance" type="bool" default="false" /> <description> Returns an array with the names all the integer constants of [code]class[/code] or its ancestry. </description> </method> <method name="class_get_method_list" qualifiers="const"> - <return type="Array"> - </return> - <argument index="0" name="class" type="StringName"> - </argument> - <argument index="1" name="no_inheritance" type="bool" default="false"> - </argument> + <return type="Array" /> + <argument index="0" name="class" type="StringName" /> + <argument index="1" name="no_inheritance" type="bool" default="false" /> <description> Returns an array with all the methods of [code]class[/code] or its ancestry if [code]no_inheritance[/code] is [code]false[/code]. Every element of the array is a [Dictionary] with the following keys: [code]args[/code], [code]default_args[/code], [code]flags[/code], [code]id[/code], [code]name[/code], [code]return: (class_name, hint, hint_string, name, type, usage)[/code]. [b]Note:[/code] In exported release builds the debug info is not available, so the returned dictionaries will contain only method names. </description> </method> <method name="class_get_property" qualifiers="const"> - <return type="Variant"> - </return> - <argument index="0" name="object" type="Object"> - </argument> - <argument index="1" name="property" type="StringName"> - </argument> + <return type="Variant" /> + <argument index="0" name="object" type="Object" /> + <argument index="1" name="property" type="StringName" /> <description> Returns the value of [code]property[/code] of [code]class[/code] or its ancestry. </description> </method> <method name="class_get_property_list" qualifiers="const"> - <return type="Array"> - </return> - <argument index="0" name="class" type="StringName"> - </argument> - <argument index="1" name="no_inheritance" type="bool" default="false"> - </argument> + <return type="Array" /> + <argument index="0" name="class" type="StringName" /> + <argument index="1" name="no_inheritance" type="bool" default="false" /> <description> Returns an array with all the properties of [code]class[/code] or its ancestry if [code]no_inheritance[/code] is [code]false[/code]. </description> </method> <method name="class_get_signal" qualifiers="const"> - <return type="Dictionary"> - </return> - <argument index="0" name="class" type="StringName"> - </argument> - <argument index="1" name="signal" type="StringName"> - </argument> + <return type="Dictionary" /> + <argument index="0" name="class" type="StringName" /> + <argument index="1" name="signal" type="StringName" /> <description> Returns the [code]signal[/code] data of [code]class[/code] or its ancestry. The returned value is a [Dictionary] with the following keys: [code]args[/code], [code]default_args[/code], [code]flags[/code], [code]id[/code], [code]name[/code], [code]return: (class_name, hint, hint_string, name, type, usage)[/code]. </description> </method> <method name="class_get_signal_list" qualifiers="const"> - <return type="Array"> - </return> - <argument index="0" name="class" type="StringName"> - </argument> - <argument index="1" name="no_inheritance" type="bool" default="false"> - </argument> + <return type="Array" /> + <argument index="0" name="class" type="StringName" /> + <argument index="1" name="no_inheritance" type="bool" default="false" /> <description> Returns an array with all the signals of [code]class[/code] or its ancestry if [code]no_inheritance[/code] is [code]false[/code]. Every element of the array is a [Dictionary] as described in [method class_get_signal]. </description> </method> <method name="class_has_integer_constant" qualifiers="const"> - <return type="bool"> - </return> - <argument index="0" name="class" type="StringName"> - </argument> - <argument index="1" name="name" type="StringName"> - </argument> + <return type="bool" /> + <argument index="0" name="class" type="StringName" /> + <argument index="1" name="name" type="StringName" /> <description> Returns whether [code]class[/code] or its ancestry has an integer constant called [code]name[/code] or not. </description> </method> <method name="class_has_method" qualifiers="const"> - <return type="bool"> - </return> - <argument index="0" name="class" type="StringName"> - </argument> - <argument index="1" name="method" type="StringName"> - </argument> - <argument index="2" name="no_inheritance" type="bool" default="false"> - </argument> + <return type="bool" /> + <argument index="0" name="class" type="StringName" /> + <argument index="1" name="method" type="StringName" /> + <argument index="2" name="no_inheritance" type="bool" default="false" /> <description> Returns whether [code]class[/code] (or its ancestry if [code]no_inheritance[/code] is [code]false[/code]) has a method called [code]method[/code] or not. </description> </method> <method name="class_has_signal" qualifiers="const"> - <return type="bool"> - </return> - <argument index="0" name="class" type="StringName"> - </argument> - <argument index="1" name="signal" type="StringName"> - </argument> + <return type="bool" /> + <argument index="0" name="class" type="StringName" /> + <argument index="1" name="signal" type="StringName" /> <description> Returns whether [code]class[/code] or its ancestry has a signal called [code]signal[/code] or not. </description> </method> <method name="class_set_property" qualifiers="const"> - <return type="int" enum="Error"> - </return> - <argument index="0" name="object" type="Object"> - </argument> - <argument index="1" name="property" type="StringName"> - </argument> - <argument index="2" name="value" type="Variant"> - </argument> + <return type="int" enum="Error" /> + <argument index="0" name="object" type="Object" /> + <argument index="1" name="property" type="StringName" /> + <argument index="2" name="value" type="Variant" /> <description> Sets [code]property[/code] value of [code]class[/code] to [code]value[/code]. </description> </method> <method name="get_class_list" qualifiers="const"> - <return type="PackedStringArray"> - </return> + <return type="PackedStringArray" /> <description> Returns the names of all the classes available. </description> </method> <method name="get_inheriters_from_class" qualifiers="const"> - <return type="PackedStringArray"> - </return> - <argument index="0" name="class" type="StringName"> - </argument> + <return type="PackedStringArray" /> + <argument index="0" name="class" type="StringName" /> <description> Returns the names of all the classes that directly or indirectly inherit from [code]class[/code]. </description> </method> <method name="get_parent_class" qualifiers="const"> - <return type="StringName"> - </return> - <argument index="0" name="class" type="StringName"> - </argument> + <return type="StringName" /> + <argument index="0" name="class" type="StringName" /> <description> Returns the parent class of [code]class[/code]. </description> </method> <method name="instantiate" qualifiers="const"> - <return type="Variant"> - </return> - <argument index="0" name="class" type="StringName"> - </argument> + <return type="Variant" /> + <argument index="0" name="class" type="StringName" /> <description> Creates an instance of [code]class[/code]. </description> </method> <method name="is_class_enabled" qualifiers="const"> - <return type="bool"> - </return> - <argument index="0" name="class" type="StringName"> - </argument> + <return type="bool" /> + <argument index="0" name="class" type="StringName" /> <description> Returns whether this [code]class[/code] is enabled or not. </description> </method> <method name="is_parent_class" qualifiers="const"> - <return type="bool"> - </return> - <argument index="0" name="class" type="StringName"> - </argument> - <argument index="1" name="inherits" type="StringName"> - </argument> + <return type="bool" /> + <argument index="0" name="class" type="StringName" /> + <argument index="1" name="inherits" type="StringName" /> <description> Returns whether [code]inherits[/code] is an ancestor of [code]class[/code] or not. </description> diff --git a/doc/classes/ClippedCamera3D.xml b/doc/classes/ClippedCamera3D.xml index 9116af19c3..1a76412826 100644 --- a/doc/classes/ClippedCamera3D.xml +++ b/doc/classes/ClippedCamera3D.xml @@ -10,72 +10,57 @@ </tutorials> <methods> <method name="add_exception"> - <return type="void"> - </return> - <argument index="0" name="node" type="Object"> - </argument> + <return type="void" /> + <argument index="0" name="node" type="Object" /> <description> Adds a collision exception so the camera does not collide with the specified node. </description> </method> <method name="add_exception_rid"> - <return type="void"> - </return> - <argument index="0" name="rid" type="RID"> - </argument> + <return type="void" /> + <argument index="0" name="rid" type="RID" /> <description> Adds a collision exception so the camera does not collide with the specified [RID]. </description> </method> <method name="clear_exceptions"> - <return type="void"> - </return> + <return type="void" /> <description> Removes all collision exceptions. </description> </method> <method name="get_clip_offset" qualifiers="const"> - <return type="float"> - </return> + <return type="float" /> <description> Returns the distance the camera has been offset due to a collision. </description> </method> <method name="get_collision_mask_bit" qualifiers="const"> - <return type="bool"> - </return> - <argument index="0" name="bit" type="int"> - </argument> + <return type="bool" /> + <argument index="0" name="bit" type="int" /> <description> Returns [code]true[/code] if the specified bit index is on. [b]Note:[/b] Bit indices range from 0-19. </description> </method> <method name="remove_exception"> - <return type="void"> - </return> - <argument index="0" name="node" type="Object"> - </argument> + <return type="void" /> + <argument index="0" name="node" type="Object" /> <description> Removes a collision exception with the specified node. </description> </method> <method name="remove_exception_rid"> - <return type="void"> - </return> - <argument index="0" name="rid" type="RID"> - </argument> + <return type="void" /> + <argument index="0" name="rid" type="RID" /> <description> Removes a collision exception with the specified [RID]. </description> </method> <method name="set_collision_mask_bit"> - <return type="void"> - </return> - <argument index="0" name="bit" type="int"> - </argument> - <argument index="1" name="value" type="bool"> - </argument> + <return type="void" /> + <argument index="0" name="bit" type="int" /> + <argument index="1" name="value" type="bool" /> <description> Sets the specified bit index to the [code]value[/code]. [b]Note:[/b] Bit indices range from 0-19. diff --git a/doc/classes/CodeEdit.xml b/doc/classes/CodeEdit.xml index 30fd47cdb6..6a3f38f51e 100644 --- a/doc/classes/CodeEdit.xml +++ b/doc/classes/CodeEdit.xml @@ -9,62 +9,45 @@ </tutorials> <methods> <method name="_confirm_code_completion" qualifiers="virtual"> - <return type="void"> - </return> - <argument index="0" name="replace" type="bool"> - </argument> + <return type="void" /> + <argument index="0" name="replace" type="bool" /> <description> Override this method to define how the selected entry should be inserted. If [code]replace[/code] is true, any existing text should be replaced. </description> </method> <method name="_filter_code_completion_candidates" qualifiers="virtual"> - <return type="Array"> - </return> - <argument index="0" name="candidates" type="Array"> - </argument> + <return type="Array" /> + <argument index="0" name="candidates" type="Array" /> <description> Override this method to define what items in [code]candidates[/code] should be displayed. Both [code]candidates[/code] and the return is a [Array] of [Dictionary], see [method get_code_completion_option] for [Dictionary] content. </description> </method> <method name="_request_code_completion" qualifiers="virtual"> - <return type="void"> - </return> - <argument index="0" name="force" type="bool"> - </argument> + <return type="void" /> + <argument index="0" name="force" type="bool" /> <description> Override this method to define what happens when the user requests code completion. If [code]force[/code] is true, any checks should be bypassed. </description> </method> <method name="add_code_completion_option"> - <return type="void"> - </return> - <argument index="0" name="type" type="int" enum="CodeEdit.CodeCompletionKind"> - </argument> - <argument index="1" name="display_text" type="String"> - </argument> - <argument index="2" name="insert_text" type="String"> - </argument> - <argument index="3" name="text_color" type="Color" default="Color(1, 1, 1, 1)"> - </argument> - <argument index="4" name="icon" type="Resource" default="null"> - </argument> - <argument index="5" name="value" type="Variant" default="0"> - </argument> + <return type="void" /> + <argument index="0" name="type" type="int" enum="CodeEdit.CodeCompletionKind" /> + <argument index="1" name="display_text" type="String" /> + <argument index="2" name="insert_text" type="String" /> + <argument index="3" name="text_color" type="Color" default="Color(1, 1, 1, 1)" /> + <argument index="4" name="icon" type="Resource" default="null" /> + <argument index="5" name="value" type="Variant" default="0" /> <description> Submits an item to the queue of potential candidates for the autocomplete menu. Call [method update_code_completion_options] to update the list. [b]Note[/b]: This list will replace all current candidates. </description> </method> <method name="add_comment_delimiter"> - <return type="void"> - </return> - <argument index="0" name="start_key" type="String"> - </argument> - <argument index="1" name="end_key" type="String"> - </argument> - <argument index="2" name="line_only" type="bool" default="false"> - </argument> + <return type="void" /> + <argument index="0" name="start_key" type="String" /> + <argument index="1" name="end_key" type="String" /> + <argument index="2" name="line_only" type="bool" default="false" /> <description> Adds a comment delimiter. Both the start and end keys must be symbols. Only the start key has to be unique. @@ -72,14 +55,10 @@ </description> </method> <method name="add_string_delimiter"> - <return type="void"> - </return> - <argument index="0" name="start_key" type="String"> - </argument> - <argument index="1" name="end_key" type="String"> - </argument> - <argument index="2" name="line_only" type="bool" default="false"> - </argument> + <return type="void" /> + <argument index="0" name="start_key" type="String" /> + <argument index="1" name="end_key" type="String" /> + <argument index="2" name="line_only" type="bool" default="false" /> <description> Adds a string delimiter. Both the start and end keys must be symbols. Only the start key has to be unique. @@ -87,109 +66,90 @@ </description> </method> <method name="can_fold_line" qualifiers="const"> - <return type="bool"> - </return> - <argument index="0" name="line" type="int"> - </argument> + <return type="bool" /> + <argument index="0" name="line" type="int" /> <description> Returns if the given line is foldable, that is, it has indented lines right below it or a comment / string block. </description> </method> <method name="cancel_code_completion"> - <return type="void"> - </return> + <return type="void" /> <description> Cancels the autocomplete menu. </description> </method> <method name="clear_bookmarked_lines"> - <return type="void"> - </return> + <return type="void" /> <description> </description> </method> <method name="clear_breakpointed_lines"> - <return type="void"> - </return> + <return type="void" /> <description> </description> </method> <method name="clear_comment_delimiters"> - <return type="void"> - </return> + <return type="void" /> <description> Removes all comment delimiters. </description> </method> <method name="clear_executing_lines"> - <return type="void"> - </return> + <return type="void" /> <description> </description> </method> <method name="clear_string_delimiters"> - <return type="void"> - </return> + <return type="void" /> <description> Removes all string delimiters. </description> </method> <method name="confirm_code_completion"> - <return type="void"> - </return> - <argument index="0" name="replace" type="bool" default="false"> - </argument> + <return type="void" /> + <argument index="0" name="replace" type="bool" default="false" /> <description> Inserts the selected entry into the text. If [code]replace[/code] is true, any existing text is replaced rather then merged. </description> </method> <method name="do_indent"> - <return type="void"> - </return> + <return type="void" /> <description> Perform an indent as if the user activated the "ui_text_indent" action. </description> </method> <method name="do_unindent"> - <return type="void"> - </return> + <return type="void" /> <description> Perform an unindent as if the user activated the "ui_text_unindent" action. </description> </method> <method name="fold_all_lines"> - <return type="void"> - </return> + <return type="void" /> <description> Folds all lines that are possible to be folded (see [method can_fold_line]). </description> </method> <method name="fold_line"> - <return type="void"> - </return> - <argument index="0" name="line" type="int"> - </argument> + <return type="void" /> + <argument index="0" name="line" type="int" /> <description> Folds the given line, if possible (see [method can_fold_line]). </description> </method> <method name="get_bookmarked_lines" qualifiers="const"> - <return type="Array"> - </return> + <return type="Array" /> <description> </description> </method> <method name="get_breakpointed_lines" qualifiers="const"> - <return type="Array"> - </return> + <return type="Array" /> <description> </description> </method> <method name="get_code_completion_option" qualifiers="const"> - <return type="Dictionary"> - </return> - <argument index="0" name="index" type="int"> - </argument> + <return type="Dictionary" /> + <argument index="0" name="index" type="int" /> <description> Gets the completion option at [code]index[/code]. The return [Dictionary] has the following key-values: [code]kind[/code]: [enum CodeCompletionKind] @@ -201,279 +161,216 @@ </description> </method> <method name="get_code_completion_options" qualifiers="const"> - <return type="Dictionary[]"> - </return> + <return type="Dictionary[]" /> <description> Gets all completion options, see [method get_code_completion_option] for return content. </description> </method> <method name="get_code_completion_selected_index" qualifiers="const"> - <return type="int"> - </return> + <return type="int" /> <description> Gets the index of the current selected completion option. </description> </method> <method name="get_delimiter_end_key" qualifiers="const"> - <return type="String"> - </return> - <argument index="0" name="delimiter_index" type="int"> - </argument> + <return type="String" /> + <argument index="0" name="delimiter_index" type="int" /> <description> Gets the end key for a string or comment region index. </description> </method> <method name="get_delimiter_end_position" qualifiers="const"> - <return type="Vector2"> - </return> - <argument index="0" name="line" type="int"> - </argument> - <argument index="1" name="column" type="int"> - </argument> + <return type="Vector2" /> + <argument index="0" name="line" type="int" /> + <argument index="1" name="column" type="int" /> <description> If [code]line[/code] [code]column[/code] is in a string or comment, returns the end position of the region. If not or no end could be found, both [Vector2] values will be [code]-1[/code]. </description> </method> <method name="get_delimiter_start_key" qualifiers="const"> - <return type="String"> - </return> - <argument index="0" name="delimiter_index" type="int"> - </argument> + <return type="String" /> + <argument index="0" name="delimiter_index" type="int" /> <description> Gets the start key for a string or comment region index. </description> </method> <method name="get_delimiter_start_position" qualifiers="const"> - <return type="Vector2"> - </return> - <argument index="0" name="line" type="int"> - </argument> - <argument index="1" name="column" type="int"> - </argument> + <return type="Vector2" /> + <argument index="0" name="line" type="int" /> + <argument index="1" name="column" type="int" /> <description> If [code]line[/code] [code]column[/code] is in a string or comment, returns the start position of the region. If not or no start could be found, both [Vector2] values will be [code]-1[/code]. </description> </method> <method name="get_executing_lines" qualifiers="const"> - <return type="Array"> - </return> + <return type="Array" /> <description> </description> </method> <method name="get_folded_lines" qualifiers="const"> - <return type="int[]"> - </return> + <return type="int[]" /> <description> Return all lines that are current folded. </description> </method> <method name="get_text_for_code_completion" qualifiers="const"> - <return type="String"> - </return> + <return type="String" /> <description> Returns the full text with char [code]0xFFFF[/code] at the caret location. </description> </method> <method name="has_comment_delimiter" qualifiers="const"> - <return type="bool"> - </return> - <argument index="0" name="start_key" type="String"> - </argument> + <return type="bool" /> + <argument index="0" name="start_key" type="String" /> <description> Returns [code]true[/code] if comment [code]start_key[/code] exists. </description> </method> <method name="has_string_delimiter" qualifiers="const"> - <return type="bool"> - </return> - <argument index="0" name="start_key" type="String"> - </argument> + <return type="bool" /> + <argument index="0" name="start_key" type="String" /> <description> Returns [code]true[/code] if string [code]start_key[/code] exists. </description> </method> <method name="indent_lines"> - <return type="void"> - </return> + <return type="void" /> <description> Indents selected lines, or in the case of no selection the caret line by one. </description> </method> <method name="is_in_comment" qualifiers="const"> - <return type="int"> - </return> - <argument index="0" name="line" type="int"> - </argument> - <argument index="1" name="column" type="int" default="-1"> - </argument> + <return type="int" /> + <argument index="0" name="line" type="int" /> + <argument index="1" name="column" type="int" default="-1" /> <description> Return delimiter index if [code]line[/code] [code]column[/code] is in a comment. If [code]column[/code] is not provided, will return delimiter index if the entire [code]line[/code] is a comment. Otherwise [code]-1[/code]. </description> </method> <method name="is_in_string" qualifiers="const"> - <return type="int"> - </return> - <argument index="0" name="line" type="int"> - </argument> - <argument index="1" name="column" type="int" default="-1"> - </argument> + <return type="int" /> + <argument index="0" name="line" type="int" /> + <argument index="1" name="column" type="int" default="-1" /> <description> Return the delimiter index if [code]line[/code] [code]column[/code] is in a string. If [code]column[/code] is not provided, will return the delimiter index if the entire [code]line[/code] is a string. Otherwise [code]-1[/code]. </description> </method> <method name="is_line_bookmarked" qualifiers="const"> - <return type="bool"> - </return> - <argument index="0" name="line" type="int"> - </argument> + <return type="bool" /> + <argument index="0" name="line" type="int" /> <description> </description> </method> <method name="is_line_breakpointed" qualifiers="const"> - <return type="bool"> - </return> - <argument index="0" name="line" type="int"> - </argument> + <return type="bool" /> + <argument index="0" name="line" type="int" /> <description> </description> </method> <method name="is_line_executing" qualifiers="const"> - <return type="bool"> - </return> - <argument index="0" name="line" type="int"> - </argument> + <return type="bool" /> + <argument index="0" name="line" type="int" /> <description> </description> </method> <method name="is_line_folded" qualifiers="const"> - <return type="bool"> - </return> - <argument index="0" name="line" type="int"> - </argument> + <return type="bool" /> + <argument index="0" name="line" type="int" /> <description> Returns whether the line at the specified index is folded or not. </description> </method> <method name="remove_comment_delimiter"> - <return type="void"> - </return> - <argument index="0" name="start_key" type="String"> - </argument> + <return type="void" /> + <argument index="0" name="start_key" type="String" /> <description> Removes the comment delimiter with [code]start_key[/code]. </description> </method> <method name="remove_string_delimiter"> - <return type="void"> - </return> - <argument index="0" name="start_key" type="String"> - </argument> + <return type="void" /> + <argument index="0" name="start_key" type="String" /> <description> Removes the string delimiter with [code]start_key[/code]. </description> </method> <method name="request_code_completion"> - <return type="void"> - </return> - <argument index="0" name="force" type="bool" default="false"> - </argument> + <return type="void" /> + <argument index="0" name="force" type="bool" default="false" /> <description> Emits [signal request_code_completion], if [code]force[/code] is true will bypass all checks. Otherwise will check that the caret is in a word or in front of a prefix. Will ignore the request if all current options are of type file path, node path or signal. </description> </method> <method name="set_code_completion_selected_index"> - <return type="void"> - </return> - <argument index="0" name="index" type="int"> - </argument> + <return type="void" /> + <argument index="0" name="index" type="int" /> <description> Sets the current selected completion option. </description> </method> <method name="set_code_hint"> - <return type="void"> - </return> - <argument index="0" name="code_hint" type="String"> - </argument> + <return type="void" /> + <argument index="0" name="code_hint" type="String" /> <description> Sets the code hint text. Pass an empty string to clear. </description> </method> <method name="set_code_hint_draw_below"> - <return type="void"> - </return> - <argument index="0" name="draw_below" type="bool"> - </argument> + <return type="void" /> + <argument index="0" name="draw_below" type="bool" /> <description> Sets if the code hint should draw below the text. </description> </method> <method name="set_line_as_bookmarked"> - <return type="void"> - </return> - <argument index="0" name="line" type="int"> - </argument> - <argument index="1" name="bookmarked" type="bool"> - </argument> + <return type="void" /> + <argument index="0" name="line" type="int" /> + <argument index="1" name="bookmarked" type="bool" /> <description> </description> </method> <method name="set_line_as_breakpoint"> - <return type="void"> - </return> - <argument index="0" name="line" type="int"> - </argument> - <argument index="1" name="breakpointed" type="bool"> - </argument> + <return type="void" /> + <argument index="0" name="line" type="int" /> + <argument index="1" name="breakpointed" type="bool" /> <description> </description> </method> <method name="set_line_as_executing"> - <return type="void"> - </return> - <argument index="0" name="line" type="int"> - </argument> - <argument index="1" name="executing" type="bool"> - </argument> + <return type="void" /> + <argument index="0" name="line" type="int" /> + <argument index="1" name="executing" type="bool" /> <description> </description> </method> <method name="toggle_foldable_line"> - <return type="void"> - </return> - <argument index="0" name="line" type="int"> - </argument> + <return type="void" /> + <argument index="0" name="line" type="int" /> <description> Toggle the folding of the code block at the given line. </description> </method> <method name="unfold_all_lines"> - <return type="void"> - </return> + <return type="void" /> <description> </description> </method> <method name="unfold_line"> - <return type="void"> - </return> - <argument index="0" name="line" type="int"> - </argument> + <return type="void" /> + <argument index="0" name="line" type="int" /> <description> Unfolds all lines that were previously folded. </description> </method> <method name="unindent_lines"> - <return type="void"> - </return> + <return type="void" /> <description> Unindents selected lines, or in the case of no selection the caret line by one. </description> </method> <method name="update_code_completion_options"> - <return type="void"> - </return> - <argument index="0" name="force" type="bool"> - </argument> + <return type="void" /> + <argument index="0" name="force" type="bool" /> <description> Submits all completion options added with [method add_code_completion_option]. Will try to force the autoccomplete menu to popup, if [code]force[/code] is [code]true[/code]. [b]Note[/b]: This will replace all current candidates. @@ -526,8 +423,7 @@ </members> <signals> <signal name="breakpoint_toggled"> - <argument index="0" name="line" type="int"> - </argument> + <argument index="0" name="line" type="int" /> <description> </description> </signal> diff --git a/doc/classes/CodeHighlighter.xml b/doc/classes/CodeHighlighter.xml index 0406c25ffd..2b93188d10 100644 --- a/doc/classes/CodeHighlighter.xml +++ b/doc/classes/CodeHighlighter.xml @@ -10,16 +10,11 @@ </tutorials> <methods> <method name="add_color_region"> - <return type="void"> - </return> - <argument index="0" name="start_key" type="String"> - </argument> - <argument index="1" name="end_key" type="String"> - </argument> - <argument index="2" name="color" type="Color"> - </argument> - <argument index="3" name="line_only" type="bool" default="false"> - </argument> + <return type="void" /> + <argument index="0" name="start_key" type="String" /> + <argument index="1" name="end_key" type="String" /> + <argument index="2" name="color" type="Color" /> + <argument index="3" name="line_only" type="bool" default="false" /> <description> Adds a color region such as comments or strings. Both the start and end keys must be symbols. Only the start key has to be unique. @@ -27,24 +22,18 @@ </description> </method> <method name="add_keyword_color"> - <return type="void"> - </return> - <argument index="0" name="keyword" type="String"> - </argument> - <argument index="1" name="color" type="Color"> - </argument> + <return type="void" /> + <argument index="0" name="keyword" type="String" /> + <argument index="1" name="color" type="Color" /> <description> Sets the color for a keyword. The keyword cannot contain any symbols except '_'. </description> </method> <method name="add_member_keyword_color"> - <return type="void"> - </return> - <argument index="0" name="member_keyword" type="String"> - </argument> - <argument index="1" name="color" type="Color"> - </argument> + <return type="void" /> + <argument index="0" name="member_keyword" type="String" /> + <argument index="1" name="color" type="Color" /> <description> Sets the color for a member keyword. The member keyword cannot contain any symbols except '_'. @@ -52,94 +41,75 @@ </description> </method> <method name="clear_color_regions"> - <return type="void"> - </return> + <return type="void" /> <description> Removes all color regions. </description> </method> <method name="clear_keyword_colors"> - <return type="void"> - </return> + <return type="void" /> <description> Removes all keywords. </description> </method> <method name="clear_member_keyword_colors"> - <return type="void"> - </return> + <return type="void" /> <description> Removes all member keywords. </description> </method> <method name="get_keyword_color" qualifiers="const"> - <return type="Color"> - </return> - <argument index="0" name="keyword" type="String"> - </argument> + <return type="Color" /> + <argument index="0" name="keyword" type="String" /> <description> Returns the color for a keyword. </description> </method> <method name="get_member_keyword_color" qualifiers="const"> - <return type="Color"> - </return> - <argument index="0" name="member_keyword" type="String"> - </argument> + <return type="Color" /> + <argument index="0" name="member_keyword" type="String" /> <description> Returns the color for a member keyword. </description> </method> <method name="has_color_region" qualifiers="const"> - <return type="bool"> - </return> - <argument index="0" name="start_key" type="String"> - </argument> + <return type="bool" /> + <argument index="0" name="start_key" type="String" /> <description> Return [code]true[/code] if the start key exists, else [code]false[/code]. </description> </method> <method name="has_keyword_color" qualifiers="const"> - <return type="bool"> - </return> - <argument index="0" name="keyword" type="String"> - </argument> + <return type="bool" /> + <argument index="0" name="keyword" type="String" /> <description> Return [code]true[/code] if the keyword exists, else [code]false[/code]. </description> </method> <method name="has_member_keyword_color" qualifiers="const"> - <return type="bool"> - </return> - <argument index="0" name="member_keyword" type="String"> - </argument> + <return type="bool" /> + <argument index="0" name="member_keyword" type="String" /> <description> Return [code]true[/code] if the member keyword exists, else [code]false[/code]. </description> </method> <method name="remove_color_region"> - <return type="void"> - </return> - <argument index="0" name="start_key" type="String"> - </argument> + <return type="void" /> + <argument index="0" name="start_key" type="String" /> <description> Removes the color region that uses that start key. </description> </method> <method name="remove_keyword_color"> - <return type="void"> - </return> - <argument index="0" name="keyword" type="String"> - </argument> + <return type="void" /> + <argument index="0" name="keyword" type="String" /> <description> Removes the keyword. </description> </method> <method name="remove_member_keyword_color"> - <return type="void"> - </return> - <argument index="0" name="member_keyword" type="String"> - </argument> + <return type="void" /> + <argument index="0" name="member_keyword" type="String" /> <description> Removes the member keyword. </description> diff --git a/doc/classes/CollisionObject2D.xml b/doc/classes/CollisionObject2D.xml index e96124c9eb..6bb756ea2c 100644 --- a/doc/classes/CollisionObject2D.xml +++ b/doc/classes/CollisionObject2D.xml @@ -10,248 +10,188 @@ </tutorials> <methods> <method name="_input_event" qualifiers="virtual"> - <return type="void"> - </return> - <argument index="0" name="viewport" type="Object"> - </argument> - <argument index="1" name="event" type="InputEvent"> - </argument> - <argument index="2" name="shape_idx" type="int"> - </argument> + <return type="void" /> + <argument index="0" name="viewport" type="Object" /> + <argument index="1" name="event" type="InputEvent" /> + <argument index="2" name="shape_idx" type="int" /> <description> Accepts unhandled [InputEvent]s. Requires [member input_pickable] to be [code]true[/code]. [code]shape_idx[/code] is the child index of the clicked [Shape2D]. Connect to the [code]input_event[/code] signal to easily pick up these events. </description> </method> <method name="create_shape_owner"> - <return type="int"> - </return> - <argument index="0" name="owner" type="Object"> - </argument> + <return type="int" /> + <argument index="0" name="owner" type="Object" /> <description> Creates a new shape owner for the given object. Returns [code]owner_id[/code] of the new owner for future reference. </description> </method> <method name="get_collision_layer_bit" qualifiers="const"> - <return type="bool"> - </return> - <argument index="0" name="bit" type="int"> - </argument> + <return type="bool" /> + <argument index="0" name="bit" type="int" /> <description> Returns whether or not the specified [code]bit[/code] of the [member collision_layer] is set. </description> </method> <method name="get_collision_mask_bit" qualifiers="const"> - <return type="bool"> - </return> - <argument index="0" name="bit" type="int"> - </argument> + <return type="bool" /> + <argument index="0" name="bit" type="int" /> <description> Returns whether or not the specified [code]bit[/code] of the [member collision_mask] is set. </description> </method> <method name="get_rid" qualifiers="const"> - <return type="RID"> - </return> + <return type="RID" /> <description> Returns the object's [RID]. </description> </method> <method name="get_shape_owner_one_way_collision_margin" qualifiers="const"> - <return type="float"> - </return> - <argument index="0" name="owner_id" type="int"> - </argument> + <return type="float" /> + <argument index="0" name="owner_id" type="int" /> <description> Returns the [code]one_way_collision_margin[/code] of the shape owner identified by given [code]owner_id[/code]. </description> </method> <method name="get_shape_owners"> - <return type="Array"> - </return> + <return type="Array" /> <description> Returns an [Array] of [code]owner_id[/code] identifiers. You can use these ids in other methods that take [code]owner_id[/code] as an argument. </description> </method> <method name="is_shape_owner_disabled" qualifiers="const"> - <return type="bool"> - </return> - <argument index="0" name="owner_id" type="int"> - </argument> + <return type="bool" /> + <argument index="0" name="owner_id" type="int" /> <description> If [code]true[/code], the shape owner and its shapes are disabled. </description> </method> <method name="is_shape_owner_one_way_collision_enabled" qualifiers="const"> - <return type="bool"> - </return> - <argument index="0" name="owner_id" type="int"> - </argument> + <return type="bool" /> + <argument index="0" name="owner_id" type="int" /> <description> Returns [code]true[/code] if collisions for the shape owner originating from this [CollisionObject2D] will not be reported to collided with [CollisionObject2D]s. </description> </method> <method name="remove_shape_owner"> - <return type="void"> - </return> - <argument index="0" name="owner_id" type="int"> - </argument> + <return type="void" /> + <argument index="0" name="owner_id" type="int" /> <description> Removes the given shape owner. </description> </method> <method name="set_collision_layer_bit"> - <return type="void"> - </return> - <argument index="0" name="bit" type="int"> - </argument> - <argument index="1" name="value" type="bool"> - </argument> + <return type="void" /> + <argument index="0" name="bit" type="int" /> + <argument index="1" name="value" type="bool" /> <description> - If [code]value[/value] is [code]true[/code], sets the specified [code]bit[/code] in the the [member collision_layer]. - If [code]value[/value] is [code]false[/code], clears the specified [code]bit[/code] in the the [member collision_layer]. + If [code]value[/code] is [code]true[/code], sets the specified [code]bit[/code] in the the [member collision_layer]. + If [code]value[/code] is [code]false[/code], clears the specified [code]bit[/code] in the the [member collision_layer]. </description> </method> <method name="set_collision_mask_bit"> - <return type="void"> - </return> - <argument index="0" name="bit" type="int"> - </argument> - <argument index="1" name="value" type="bool"> - </argument> + <return type="void" /> + <argument index="0" name="bit" type="int" /> + <argument index="1" name="value" type="bool" /> <description> - If [code]value[/value] is [code]true[/code], sets the specified [code]bit[/code] in the the [member collision_mask]. - If [code]value[/value] is [code]false[/code], clears the specified [code]bit[/code] in the the [member collision_mask]. + If [code]value[/code] is [code]true[/code], sets the specified [code]bit[/code] in the the [member collision_mask]. + If [code]value[/code] is [code]false[/code], clears the specified [code]bit[/code] in the the [member collision_mask]. </description> </method> <method name="shape_find_owner" qualifiers="const"> - <return type="int"> - </return> - <argument index="0" name="shape_index" type="int"> - </argument> + <return type="int" /> + <argument index="0" name="shape_index" type="int" /> <description> Returns the [code]owner_id[/code] of the given shape. </description> </method> <method name="shape_owner_add_shape"> - <return type="void"> - </return> - <argument index="0" name="owner_id" type="int"> - </argument> - <argument index="1" name="shape" type="Shape2D"> - </argument> + <return type="void" /> + <argument index="0" name="owner_id" type="int" /> + <argument index="1" name="shape" type="Shape2D" /> <description> Adds a [Shape2D] to the shape owner. </description> </method> <method name="shape_owner_clear_shapes"> - <return type="void"> - </return> - <argument index="0" name="owner_id" type="int"> - </argument> + <return type="void" /> + <argument index="0" name="owner_id" type="int" /> <description> Removes all shapes from the shape owner. </description> </method> <method name="shape_owner_get_owner" qualifiers="const"> - <return type="Object"> - </return> - <argument index="0" name="owner_id" type="int"> - </argument> + <return type="Object" /> + <argument index="0" name="owner_id" type="int" /> <description> Returns the parent object of the given shape owner. </description> </method> <method name="shape_owner_get_shape" qualifiers="const"> - <return type="Shape2D"> - </return> - <argument index="0" name="owner_id" type="int"> - </argument> - <argument index="1" name="shape_id" type="int"> - </argument> + <return type="Shape2D" /> + <argument index="0" name="owner_id" type="int" /> + <argument index="1" name="shape_id" type="int" /> <description> Returns the [Shape2D] with the given id from the given shape owner. </description> </method> <method name="shape_owner_get_shape_count" qualifiers="const"> - <return type="int"> - </return> - <argument index="0" name="owner_id" type="int"> - </argument> + <return type="int" /> + <argument index="0" name="owner_id" type="int" /> <description> Returns the number of shapes the given shape owner contains. </description> </method> <method name="shape_owner_get_shape_index" qualifiers="const"> - <return type="int"> - </return> - <argument index="0" name="owner_id" type="int"> - </argument> - <argument index="1" name="shape_id" type="int"> - </argument> + <return type="int" /> + <argument index="0" name="owner_id" type="int" /> + <argument index="1" name="shape_id" type="int" /> <description> Returns the child index of the [Shape2D] with the given id from the given shape owner. </description> </method> <method name="shape_owner_get_transform" qualifiers="const"> - <return type="Transform2D"> - </return> - <argument index="0" name="owner_id" type="int"> - </argument> + <return type="Transform2D" /> + <argument index="0" name="owner_id" type="int" /> <description> Returns the shape owner's [Transform2D]. </description> </method> <method name="shape_owner_remove_shape"> - <return type="void"> - </return> - <argument index="0" name="owner_id" type="int"> - </argument> - <argument index="1" name="shape_id" type="int"> - </argument> + <return type="void" /> + <argument index="0" name="owner_id" type="int" /> + <argument index="1" name="shape_id" type="int" /> <description> Removes a shape from the given shape owner. </description> </method> <method name="shape_owner_set_disabled"> - <return type="void"> - </return> - <argument index="0" name="owner_id" type="int"> - </argument> - <argument index="1" name="disabled" type="bool"> - </argument> + <return type="void" /> + <argument index="0" name="owner_id" type="int" /> + <argument index="1" name="disabled" type="bool" /> <description> If [code]true[/code], disables the given shape owner. </description> </method> <method name="shape_owner_set_one_way_collision"> - <return type="void"> - </return> - <argument index="0" name="owner_id" type="int"> - </argument> - <argument index="1" name="enable" type="bool"> - </argument> + <return type="void" /> + <argument index="0" name="owner_id" type="int" /> + <argument index="1" name="enable" type="bool" /> <description> If [code]enable[/code] is [code]true[/code], collisions for the shape owner originating from this [CollisionObject2D] will not be reported to collided with [CollisionObject2D]s. </description> </method> <method name="shape_owner_set_one_way_collision_margin"> - <return type="void"> - </return> - <argument index="0" name="owner_id" type="int"> - </argument> - <argument index="1" name="margin" type="float"> - </argument> + <return type="void" /> + <argument index="0" name="owner_id" type="int" /> + <argument index="1" name="margin" type="float" /> <description> Sets the [code]one_way_collision_margin[/code] of the shape owner identified by given [code]owner_id[/code] to [code]margin[/code] pixels. </description> </method> <method name="shape_owner_set_transform"> - <return type="void"> - </return> - <argument index="0" name="owner_id" type="int"> - </argument> - <argument index="1" name="transform" type="Transform2D"> - </argument> + <return type="void" /> + <argument index="0" name="owner_id" type="int" /> + <argument index="1" name="transform" type="Transform2D" /> <description> Sets the [Transform2D] of the given shape owner. </description> @@ -260,11 +200,11 @@ <members> <member name="collision_layer" type="int" setter="set_collision_layer" getter="get_collision_layer" default="1"> The physics layers this CollisionObject2D is in. Collision objects can exist in one or more of 32 different layers. See also [member collision_mask]. - [b]Note:[/b] A contact is detected if object A is in any of the layers that object B scans, or object B is in any layers that object A scans. See [url=https://docs.godotengine.org/en/latest/tutorials/physics/physics_introduction.html#collision-layers-and-masks]Collision layers and masks[/url] in the documentation for more information. + [b]Note:[/b] Object A can detect a contact with object B only if object B is in any of the layers that object A scans. See [url=https://docs.godotengine.org/en/latest/tutorials/physics/physics_introduction.html#collision-layers-and-masks]Collision layers and masks[/url] in the documentation for more information. </member> <member name="collision_mask" type="int" setter="set_collision_mask" getter="get_collision_mask" default="1"> The physics layers this CollisionObject2D scans. Collision objects can scan one or more of 32 different layers. See also [member collision_layer]. - [b]Note:[/b] A contact is detected if object A is in any of the layers that object B scans, or object B is in any layers that object A scans. See [url=https://docs.godotengine.org/en/latest/tutorials/physics/physics_introduction.html#collision-layers-and-masks]Collision layers and masks[/url] in the documentation for more information. + [b]Note:[/b] Object A can detect a contact with object B only if object B is in any of the layers that object A scans. See [url=https://docs.godotengine.org/en/latest/tutorials/physics/physics_introduction.html#collision-layers-and-masks]Collision layers and masks[/url] in the documentation for more information. </member> <member name="disable_mode" type="int" setter="set_disable_mode" getter="get_disable_mode" enum="CollisionObject2D.DisableMode" default="0"> Defines the behavior in physics when [member Node.process_mode] is set to [constant Node.PROCESS_MODE_DISABLED]. See [enum DisableMode] for more details about the different modes. @@ -275,24 +215,33 @@ </members> <signals> <signal name="input_event"> - <argument index="0" name="viewport" type="Node"> - </argument> - <argument index="1" name="event" type="InputEvent"> - </argument> - <argument index="2" name="shape_idx" type="int"> - </argument> + <argument index="0" name="viewport" type="Node" /> + <argument index="1" name="event" type="InputEvent" /> + <argument index="2" name="shape_idx" type="int" /> <description> Emitted when an input event occurs. Requires [member input_pickable] to be [code]true[/code] and at least one [code]collision_layer[/code] bit to be set. See [method _input_event] for details. </description> </signal> <signal name="mouse_entered"> <description> - Emitted when the mouse pointer enters any of this object's shapes. Requires [member input_pickable] to be [code]true[/code] and at least one [code]collision_layer[/code] bit to be set. + Emitted when the mouse pointer enters any of this object's shapes. Requires [member input_pickable] to be [code]true[/code] and at least one [member collision_layer] bit to be set. Note that moving between different shapes within a single [CollisionObject2D] won't cause this signal to be emitted. </description> </signal> <signal name="mouse_exited"> <description> - Emitted when the mouse pointer exits all this object's shapes. Requires [member input_pickable] to be [code]true[/code] and at least one [code]collision_layer[/code] bit to be set. + Emitted when the mouse pointer exits all this object's shapes. Requires [member input_pickable] to be [code]true[/code] and at least one [member collision_layer] bit to be set. Note that moving between different shapes within a single [CollisionObject2D] won't cause this signal to be emitted. + </description> + </signal> + <signal name="mouse_shape_entered"> + <argument index="0" name="shape_idx" type="int" /> + <description> + Emitted when the mouse pointer enters any of this object's shapes or moves from one shape to another. [code]shape_idx[/code] is the child index of the newly entered [Shape2D]. Requires [member input_pickable] to be [code]true[/code] and at least one [member collision_layer] bit to be set. + </description> + </signal> + <signal name="mouse_shape_exited"> + <argument index="0" name="shape_idx" type="int" /> + <description> + Emitted when the mouse pointer exits any of this object's shapes. [code]shape_idx[/code] is the child index of the exited [Shape2D]. Requires [member input_pickable] to be [code]true[/code] and at least one [member collision_layer] bit to be set. </description> </signal> </signals> diff --git a/doc/classes/CollisionObject3D.xml b/doc/classes/CollisionObject3D.xml index dfd1e85e56..0210f6297f 100644 --- a/doc/classes/CollisionObject3D.xml +++ b/doc/classes/CollisionObject3D.xml @@ -10,212 +10,160 @@ </tutorials> <methods> <method name="_input_event" qualifiers="virtual"> - <return type="void"> - </return> - <argument index="0" name="camera" type="Object"> - </argument> - <argument index="1" name="event" type="InputEvent"> - </argument> - <argument index="2" name="position" type="Vector3"> - </argument> - <argument index="3" name="normal" type="Vector3"> - </argument> - <argument index="4" name="shape_idx" type="int"> - </argument> + <return type="void" /> + <argument index="0" name="camera" type="Object" /> + <argument index="1" name="event" type="InputEvent" /> + <argument index="2" name="position" type="Vector3" /> + <argument index="3" name="normal" type="Vector3" /> + <argument index="4" name="shape_idx" type="int" /> <description> Receives unhandled [InputEvent]s. [code]position[/code] is the location in world space of the mouse pointer on the surface of the shape with index [code]shape_idx[/code] and [code]normal[/code] is the normal vector of the surface at that point. Connect to the [signal input_event] signal to easily pick up these events. </description> </method> <method name="create_shape_owner"> - <return type="int"> - </return> - <argument index="0" name="owner" type="Object"> - </argument> + <return type="int" /> + <argument index="0" name="owner" type="Object" /> <description> Creates a new shape owner for the given object. Returns [code]owner_id[/code] of the new owner for future reference. </description> </method> <method name="get_collision_layer_bit" qualifiers="const"> - <return type="bool"> - </return> - <argument index="0" name="bit" type="int"> - </argument> + <return type="bool" /> + <argument index="0" name="bit" type="int" /> <description> Returns whether or not the specified [code]bit[/code] of the [member collision_layer] is set. </description> </method> <method name="get_collision_mask_bit" qualifiers="const"> - <return type="bool"> - </return> - <argument index="0" name="bit" type="int"> - </argument> + <return type="bool" /> + <argument index="0" name="bit" type="int" /> <description> Returns whether or not the specified [code]bit[/code] of the [member collision_mask] is set. </description> </method> <method name="get_rid" qualifiers="const"> - <return type="RID"> - </return> + <return type="RID" /> <description> Returns the object's [RID]. </description> </method> <method name="get_shape_owners"> - <return type="Array"> - </return> + <return type="Array" /> <description> Returns an [Array] of [code]owner_id[/code] identifiers. You can use these ids in other methods that take [code]owner_id[/code] as an argument. </description> </method> <method name="is_shape_owner_disabled" qualifiers="const"> - <return type="bool"> - </return> - <argument index="0" name="owner_id" type="int"> - </argument> + <return type="bool" /> + <argument index="0" name="owner_id" type="int" /> <description> If [code]true[/code], the shape owner and its shapes are disabled. </description> </method> <method name="remove_shape_owner"> - <return type="void"> - </return> - <argument index="0" name="owner_id" type="int"> - </argument> + <return type="void" /> + <argument index="0" name="owner_id" type="int" /> <description> Removes the given shape owner. </description> </method> <method name="set_collision_layer_bit"> - <return type="void"> - </return> - <argument index="0" name="bit" type="int"> - </argument> - <argument index="1" name="value" type="bool"> - </argument> + <return type="void" /> + <argument index="0" name="bit" type="int" /> + <argument index="1" name="value" type="bool" /> <description> - If [code]value[/value] is [code]true[/code], sets the specified [code]bit[/code] in the the [member collision_layer]. - If [code]value[/value] is [code]false[/code], clears the specified [code]bit[/code] in the the [member collision_layer]. + If [code]value[/code] is [code]true[/code], sets the specified [code]bit[/code] in the the [member collision_layer]. + If [code]value[/code] is [code]false[/code], clears the specified [code]bit[/code] in the the [member collision_layer]. </description> </method> <method name="set_collision_mask_bit"> - <return type="void"> - </return> - <argument index="0" name="bit" type="int"> - </argument> - <argument index="1" name="value" type="bool"> - </argument> + <return type="void" /> + <argument index="0" name="bit" type="int" /> + <argument index="1" name="value" type="bool" /> <description> - If [code]value[/value] is [code]true[/code], sets the specified [code]bit[/code] in the the [member collision_mask]. - If [code]value[/value] is [code]false[/code], clears the specified [code]bit[/code] in the the [member collision_mask]. + If [code]value[/code] is [code]true[/code], sets the specified [code]bit[/code] in the the [member collision_mask]. + If [code]value[/code] is [code]false[/code], clears the specified [code]bit[/code] in the the [member collision_mask]. </description> </method> <method name="shape_find_owner" qualifiers="const"> - <return type="int"> - </return> - <argument index="0" name="shape_index" type="int"> - </argument> + <return type="int" /> + <argument index="0" name="shape_index" type="int" /> <description> Returns the [code]owner_id[/code] of the given shape. </description> </method> <method name="shape_owner_add_shape"> - <return type="void"> - </return> - <argument index="0" name="owner_id" type="int"> - </argument> - <argument index="1" name="shape" type="Shape3D"> - </argument> + <return type="void" /> + <argument index="0" name="owner_id" type="int" /> + <argument index="1" name="shape" type="Shape3D" /> <description> Adds a [Shape3D] to the shape owner. </description> </method> <method name="shape_owner_clear_shapes"> - <return type="void"> - </return> - <argument index="0" name="owner_id" type="int"> - </argument> + <return type="void" /> + <argument index="0" name="owner_id" type="int" /> <description> Removes all shapes from the shape owner. </description> </method> <method name="shape_owner_get_owner" qualifiers="const"> - <return type="Object"> - </return> - <argument index="0" name="owner_id" type="int"> - </argument> + <return type="Object" /> + <argument index="0" name="owner_id" type="int" /> <description> Returns the parent object of the given shape owner. </description> </method> <method name="shape_owner_get_shape" qualifiers="const"> - <return type="Shape3D"> - </return> - <argument index="0" name="owner_id" type="int"> - </argument> - <argument index="1" name="shape_id" type="int"> - </argument> + <return type="Shape3D" /> + <argument index="0" name="owner_id" type="int" /> + <argument index="1" name="shape_id" type="int" /> <description> Returns the [Shape3D] with the given id from the given shape owner. </description> </method> <method name="shape_owner_get_shape_count" qualifiers="const"> - <return type="int"> - </return> - <argument index="0" name="owner_id" type="int"> - </argument> + <return type="int" /> + <argument index="0" name="owner_id" type="int" /> <description> Returns the number of shapes the given shape owner contains. </description> </method> <method name="shape_owner_get_shape_index" qualifiers="const"> - <return type="int"> - </return> - <argument index="0" name="owner_id" type="int"> - </argument> - <argument index="1" name="shape_id" type="int"> - </argument> + <return type="int" /> + <argument index="0" name="owner_id" type="int" /> + <argument index="1" name="shape_id" type="int" /> <description> Returns the child index of the [Shape3D] with the given id from the given shape owner. </description> </method> <method name="shape_owner_get_transform" qualifiers="const"> - <return type="Transform3D"> - </return> - <argument index="0" name="owner_id" type="int"> - </argument> + <return type="Transform3D" /> + <argument index="0" name="owner_id" type="int" /> <description> Returns the shape owner's [Transform3D]. </description> </method> <method name="shape_owner_remove_shape"> - <return type="void"> - </return> - <argument index="0" name="owner_id" type="int"> - </argument> - <argument index="1" name="shape_id" type="int"> - </argument> + <return type="void" /> + <argument index="0" name="owner_id" type="int" /> + <argument index="1" name="shape_id" type="int" /> <description> Removes a shape from the given shape owner. </description> </method> <method name="shape_owner_set_disabled"> - <return type="void"> - </return> - <argument index="0" name="owner_id" type="int"> - </argument> - <argument index="1" name="disabled" type="bool"> - </argument> + <return type="void" /> + <argument index="0" name="owner_id" type="int" /> + <argument index="1" name="disabled" type="bool" /> <description> If [code]true[/code], disables the given shape owner. </description> </method> <method name="shape_owner_set_transform"> - <return type="void"> - </return> - <argument index="0" name="owner_id" type="int"> - </argument> - <argument index="1" name="transform" type="Transform3D"> - </argument> + <return type="void" /> + <argument index="0" name="owner_id" type="int" /> + <argument index="1" name="transform" type="Transform3D" /> <description> Sets the [Transform3D] of the given shape owner. </description> @@ -223,12 +171,12 @@ </methods> <members> <member name="collision_layer" type="int" setter="set_collision_layer" getter="get_collision_layer" default="1"> - The physics layers this CollisionObject3D is in. Collision objects can exist in one or more of 32 different layers. See also [member collision_mask]. - [b]Note:[/b] A contact is detected if object A is in any of the layers that object B scans, or object B is in any layers that object A scans. See [url=https://docs.godotengine.org/en/latest/tutorials/physics/physics_introduction.html#collision-layers-and-masks]Collision layers and masks[/url] in the documentation for more information. + The physics layers this CollisionObject3D [b]is in[/b]. Collision objects can exist in one or more of 32 different layers. See also [member collision_mask]. + [b]Note:[/b] Object A can detect a contact with object B only if object B is in any of the layers that object A scans. See [url=https://docs.godotengine.org/en/latest/tutorials/physics/physics_introduction.html#collision-layers-and-masks]Collision layers and masks[/url] in the documentation for more information. </member> <member name="collision_mask" type="int" setter="set_collision_mask" getter="get_collision_mask" default="1"> - The physics layers this CollisionObject3D scans. Collision objects can scan one or more of 32 different layers. See also [member collision_layer]. - [b]Note:[/b] A contact is detected if object A is in any of the layers that object B scans, or object B is in any layers that object A scans. See [url=https://docs.godotengine.org/en/latest/tutorials/physics/physics_introduction.html#collision-layers-and-masks]Collision layers and masks[/url] in the documentation for more information. + The physics layers this CollisionObject3D [b]scans[/b]. Collision objects can scan one or more of 32 different layers. See also [member collision_layer]. + [b]Note:[/b] Object A can detect a contact with object B only if object B is in any of the layers that object A scans. See [url=https://docs.godotengine.org/en/latest/tutorials/physics/physics_introduction.html#collision-layers-and-masks]Collision layers and masks[/url] in the documentation for more information. </member> <member name="disable_mode" type="int" setter="set_disable_mode" getter="get_disable_mode" enum="CollisionObject3D.DisableMode" default="0"> Defines the behavior in physics when [member Node.process_mode] is set to [constant Node.PROCESS_MODE_DISABLED]. See [enum DisableMode] for more details about the different modes. @@ -242,16 +190,11 @@ </members> <signals> <signal name="input_event"> - <argument index="0" name="camera" type="Node"> - </argument> - <argument index="1" name="event" type="InputEvent"> - </argument> - <argument index="2" name="position" type="Vector3"> - </argument> - <argument index="3" name="normal" type="Vector3"> - </argument> - <argument index="4" name="shape_idx" type="int"> - </argument> + <argument index="0" name="camera" type="Node" /> + <argument index="1" name="event" type="InputEvent" /> + <argument index="2" name="position" type="Vector3" /> + <argument index="3" name="normal" type="Vector3" /> + <argument index="4" name="shape_idx" type="int" /> <description> Emitted when the object receives an unhandled [InputEvent]. [code]position[/code] is the location in world space of the mouse pointer on the surface of the shape with index [code]shape_idx[/code] and [code]normal[/code] is the normal vector of the surface at that point. </description> diff --git a/doc/classes/CollisionShape3D.xml b/doc/classes/CollisionShape3D.xml index 5590947a4f..9184b672ff 100644 --- a/doc/classes/CollisionShape3D.xml +++ b/doc/classes/CollisionShape3D.xml @@ -14,17 +14,14 @@ </tutorials> <methods> <method name="make_convex_from_siblings"> - <return type="void"> - </return> + <return type="void" /> <description> Sets the collision shape's shape to the addition of all its convexed [MeshInstance3D] siblings geometry. </description> </method> <method name="resource_changed"> - <return type="void"> - </return> - <argument index="0" name="resource" type="Resource"> - </argument> + <return type="void" /> + <argument index="0" name="resource" type="Resource" /> <description> If this method exists within a script it will be called whenever the shape resource has been modified. </description> diff --git a/doc/classes/Color.xml b/doc/classes/Color.xml index 7b1415e40d..f00a20e95e 100644 --- a/doc/classes/Color.xml +++ b/doc/classes/Color.xml @@ -17,28 +17,22 @@ </tutorials> <methods> <method name="Color" qualifiers="constructor"> - <return type="Color"> - </return> + <return type="Color" /> <description> Constructs a default-initialized [Color] with all components set to [code]0[/code]. </description> </method> <method name="Color" qualifiers="constructor"> - <return type="Color"> - </return> - <argument index="0" name="from" type="Color"> - </argument> + <return type="Color" /> + <argument index="0" name="from" type="Color" /> <description> Constructs a [Color] as a copy of the given [Color]. </description> </method> <method name="Color" qualifiers="constructor"> - <return type="Color"> - </return> - <argument index="0" name="from" type="Color"> - </argument> - <argument index="1" name="alpha" type="float"> - </argument> + <return type="Color" /> + <argument index="0" name="from" type="Color" /> + <argument index="1" name="alpha" type="float" /> <description> Constructs a [Color] from an existing color, but with a custom alpha value. [codeblocks] @@ -52,36 +46,26 @@ </description> </method> <method name="Color" qualifiers="constructor"> - <return type="Color"> - </return> - <argument index="0" name="code" type="String"> - </argument> + <return type="Color" /> + <argument index="0" name="code" type="String" /> <description> Constructs a [Color] either from an HTML color code or from a standardized color name. Supported color names are the same as the constants. </description> </method> <method name="Color" qualifiers="constructor"> - <return type="Color"> - </return> - <argument index="0" name="code" type="String"> - </argument> - <argument index="1" name="alpha" type="float"> - </argument> + <return type="Color" /> + <argument index="0" name="code" type="String" /> + <argument index="1" name="alpha" type="float" /> <description> Constructs a [Color] either from an HTML color code or from a standardized color name, with [code]alpha[/code] on the range of 0 to 1. Supported color names are the same as the constants. </description> </method> <method name="Color" qualifiers="constructor"> - <return type="Color"> - </return> - <argument index="0" name="r" type="float"> - </argument> - <argument index="1" name="g" type="float"> - </argument> - <argument index="2" name="b" type="float"> - </argument> - <argument index="3" name="a" type="float"> - </argument> + <return type="Color" /> + <argument index="0" name="r" type="float" /> + <argument index="1" name="g" type="float" /> + <argument index="2" name="b" type="float" /> + <argument index="3" name="a" type="float" /> <description> Constructs a [Color] from RGBA values, typically between 0 and 1. [codeblocks] @@ -95,14 +79,10 @@ </description> </method> <method name="Color" qualifiers="constructor"> - <return type="Color"> - </return> - <argument index="0" name="r" type="float"> - </argument> - <argument index="1" name="g" type="float"> - </argument> - <argument index="2" name="b" type="float"> - </argument> + <return type="Color" /> + <argument index="0" name="r" type="float" /> + <argument index="1" name="g" type="float" /> + <argument index="2" name="b" type="float" /> <description> Constructs a [Color] from RGB values, typically between 0 and 1. Alpha will be 1. [codeblocks] @@ -116,10 +96,8 @@ </description> </method> <method name="blend" qualifiers="const"> - <return type="Color"> - </return> - <argument index="0" name="over" type="Color"> - </argument> + <return type="Color" /> + <argument index="0" name="over" type="Color" /> <description> Returns a new color resulting from blending this color over another. If the color is opaque, the result is also opaque. The second color may have a range of alpha values. [codeblocks] @@ -137,21 +115,16 @@ </description> </method> <method name="clamp" qualifiers="const"> - <return type="Color"> - </return> - <argument index="0" name="min" type="Color" default="Color(0, 0, 0, 0)"> - </argument> - <argument index="1" name="max" type="Color" default="Color(1, 1, 1, 1)"> - </argument> + <return type="Color" /> + <argument index="0" name="min" type="Color" default="Color(0, 0, 0, 0)" /> + <argument index="1" name="max" type="Color" default="Color(1, 1, 1, 1)" /> <description> Returns a new color with all components clamped between the components of [code]min[/code] and [code]max[/code], by running [method @GlobalScope.clamp] on each component. </description> </method> <method name="darkened" qualifiers="const"> - <return type="Color"> - </return> - <argument index="0" name="amount" type="float"> - </argument> + <return type="Color" /> + <argument index="0" name="amount" type="float" /> <description> Returns a new color resulting from making this color darker by the specified percentage (ratio from 0 to 1). [codeblocks] @@ -167,88 +140,67 @@ </description> </method> <method name="find_named_color" qualifiers="static"> - <return type="int"> - </return> - <argument index="0" name="name" type="String"> - </argument> + <return type="int" /> + <argument index="0" name="name" type="String" /> <description> </description> </method> <method name="from_rgbe9995" qualifiers="static"> - <return type="Color"> - </return> - <argument index="0" name="rgbe" type="int"> - </argument> + <return type="Color" /> + <argument index="0" name="rgbe" type="int" /> <description> </description> </method> <method name="from_string" qualifiers="static"> - <return type="Color"> - </return> - <argument index="0" name="str" type="String"> - </argument> - <argument index="1" name="default" type="Color"> - </argument> + <return type="Color" /> + <argument index="0" name="str" type="String" /> + <argument index="1" name="default" type="Color" /> <description> </description> </method> <method name="get_named_color" qualifiers="static"> - <return type="Color"> - </return> - <argument index="0" name="idx" type="int"> - </argument> + <return type="Color" /> + <argument index="0" name="idx" type="int" /> <description> </description> </method> <method name="get_named_color_count" qualifiers="static"> - <return type="int"> - </return> + <return type="int" /> <description> </description> </method> <method name="get_named_color_name" qualifiers="static"> - <return type="String"> - </return> - <argument index="0" name="idx" type="int"> - </argument> + <return type="String" /> + <argument index="0" name="idx" type="int" /> <description> </description> </method> <method name="hex" qualifiers="static"> - <return type="Color"> - </return> - <argument index="0" name="hex" type="int"> - </argument> + <return type="Color" /> + <argument index="0" name="hex" type="int" /> <description> </description> </method> <method name="hex64" qualifiers="static"> - <return type="Color"> - </return> - <argument index="0" name="hex" type="int"> - </argument> + <return type="Color" /> + <argument index="0" name="hex" type="int" /> <description> </description> </method> <method name="html" qualifiers="static"> - <return type="Color"> - </return> - <argument index="0" name="rgba" type="String"> - </argument> + <return type="Color" /> + <argument index="0" name="rgba" type="String" /> <description> </description> </method> <method name="html_is_valid" qualifiers="static"> - <return type="bool"> - </return> - <argument index="0" name="color" type="String"> - </argument> + <return type="bool" /> + <argument index="0" name="color" type="String" /> <description> </description> </method> <method name="inverted" qualifiers="const"> - <return type="Color"> - </return> + <return type="Color" /> <description> Returns the inverted color [code](1 - r, 1 - g, 1 - b, a)[/code]. [codeblocks] @@ -264,21 +216,16 @@ </description> </method> <method name="is_equal_approx" qualifiers="const"> - <return type="bool"> - </return> - <argument index="0" name="to" type="Color"> - </argument> + <return type="bool" /> + <argument index="0" name="to" type="Color" /> <description> Returns [code]true[/code] if this color and [code]color[/code] are approximately equal, by running [method @GlobalScope.is_equal_approx] on each component. </description> </method> <method name="lerp" qualifiers="const"> - <return type="Color"> - </return> - <argument index="0" name="to" type="Color"> - </argument> - <argument index="1" name="weight" type="float"> - </argument> + <return type="Color" /> + <argument index="0" name="to" type="Color" /> + <argument index="1" name="weight" type="float" /> <description> Returns the linear interpolation with another color. The interpolation factor [code]weight[/code] is between 0 and 1. [codeblocks] @@ -296,10 +243,8 @@ </description> </method> <method name="lightened" qualifiers="const"> - <return type="Color"> - </return> - <argument index="0" name="amount" type="float"> - </argument> + <return type="Color" /> + <argument index="0" name="amount" type="float" /> <description> Returns a new color resulting from making this color lighter by the specified percentage (ratio from 0 to 1). [codeblocks] @@ -315,108 +260,83 @@ </description> </method> <method name="operator !=" qualifiers="operator"> - <return type="bool"> - </return> - <argument index="0" name="right" type="Color"> - </argument> + <return type="bool" /> + <argument index="0" name="right" type="Color" /> <description> </description> </method> <method name="operator *" qualifiers="operator"> - <return type="Color"> - </return> - <argument index="0" name="right" type="Color"> - </argument> + <return type="Color" /> + <argument index="0" name="right" type="Color" /> <description> </description> </method> <method name="operator *" qualifiers="operator"> - <return type="Color"> - </return> - <argument index="0" name="right" type="float"> - </argument> + <return type="Color" /> + <argument index="0" name="right" type="float" /> <description> </description> </method> <method name="operator *" qualifiers="operator"> - <return type="Color"> - </return> - <argument index="0" name="right" type="int"> - </argument> + <return type="Color" /> + <argument index="0" name="right" type="int" /> <description> </description> </method> <method name="operator +" qualifiers="operator"> - <return type="Color"> - </return> - <argument index="0" name="right" type="Color"> - </argument> + <return type="Color" /> + <argument index="0" name="right" type="Color" /> <description> </description> </method> <method name="operator -" qualifiers="operator"> - <return type="Color"> - </return> - <argument index="0" name="right" type="Color"> - </argument> + <return type="Color" /> + <argument index="0" name="right" type="Color" /> <description> </description> </method> <method name="operator /" qualifiers="operator"> - <return type="Color"> - </return> - <argument index="0" name="right" type="Color"> - </argument> + <return type="Color" /> + <argument index="0" name="right" type="Color" /> <description> </description> </method> <method name="operator /" qualifiers="operator"> - <return type="Color"> - </return> - <argument index="0" name="right" type="float"> - </argument> + <return type="Color" /> + <argument index="0" name="right" type="float" /> <description> </description> </method> <method name="operator /" qualifiers="operator"> - <return type="Color"> - </return> - <argument index="0" name="right" type="int"> - </argument> + <return type="Color" /> + <argument index="0" name="right" type="int" /> <description> </description> </method> <method name="operator ==" qualifiers="operator"> - <return type="bool"> - </return> - <argument index="0" name="right" type="Color"> - </argument> + <return type="bool" /> + <argument index="0" name="right" type="Color" /> <description> </description> </method> <method name="operator []" qualifiers="operator"> - <return type="float"> - </return> - <argument index="0" name="index" type="int"> - </argument> + <return type="float" /> + <argument index="0" name="index" type="int" /> <description> </description> </method> <method name="operator unary+" qualifiers="operator"> - <return type="Color"> - </return> + <return type="Color" /> <description> </description> </method> <method name="operator unary-" qualifiers="operator"> - <return type="Color"> - </return> + <return type="Color" /> <description> </description> </method> <method name="to_abgr32" qualifiers="const"> - <return type="int"> - </return> + <return type="int" /> <description> Returns the color converted to a 32-bit integer in ABGR format (each byte represents a color channel). ABGR is the reversed version of the default format. [codeblocks] @@ -432,8 +352,7 @@ </description> </method> <method name="to_abgr64" qualifiers="const"> - <return type="int"> - </return> + <return type="int" /> <description> Returns the color converted to a 64-bit integer in ABGR format (each word represents a color channel). ABGR is the reversed version of the default format. [codeblocks] @@ -449,8 +368,7 @@ </description> </method> <method name="to_argb32" qualifiers="const"> - <return type="int"> - </return> + <return type="int" /> <description> Returns the color converted to a 32-bit integer in ARGB format (each byte represents a color channel). ARGB is more compatible with DirectX. [codeblocks] @@ -466,8 +384,7 @@ </description> </method> <method name="to_argb64" qualifiers="const"> - <return type="int"> - </return> + <return type="int" /> <description> Returns the color converted to a 64-bit integer in ARGB format (each word represents a color channel). ARGB is more compatible with DirectX. [codeblocks] @@ -483,10 +400,8 @@ </description> </method> <method name="to_html" qualifiers="const"> - <return type="String"> - </return> - <argument index="0" name="with_alpha" type="bool" default="true"> - </argument> + <return type="String" /> + <argument index="0" name="with_alpha" type="bool" default="true" /> <description> Returns the color converted to an HTML hexadecimal color string in RGBA format (ex: [code]ff34f822[/code]). Setting [code]with_alpha[/code] to [code]false[/code] excludes alpha from the hexadecimal string (and uses RGB instead of RGBA format). @@ -505,8 +420,7 @@ </description> </method> <method name="to_rgba32" qualifiers="const"> - <return type="int"> - </return> + <return type="int" /> <description> Returns the color converted to a 32-bit integer in RGBA format (each byte represents a color channel). RGBA is Godot's default format. [codeblocks] @@ -522,8 +436,7 @@ </description> </method> <method name="to_rgba64" qualifiers="const"> - <return type="int"> - </return> + <return type="int" /> <description> Returns the color converted to a 64-bit integer in RGBA format (each word represents a color channel). RGBA is Godot's default format. [codeblocks] diff --git a/doc/classes/ColorPicker.xml b/doc/classes/ColorPicker.xml index 2111358ef4..7b357034eb 100644 --- a/doc/classes/ColorPicker.xml +++ b/doc/classes/ColorPicker.xml @@ -11,27 +11,22 @@ </tutorials> <methods> <method name="add_preset"> - <return type="void"> - </return> - <argument index="0" name="color" type="Color"> - </argument> + <return type="void" /> + <argument index="0" name="color" type="Color" /> <description> Adds the given color to a list of color presets. The presets are displayed in the color picker and the user will be able to select them. [b]Note:[/b] the presets list is only for [i]this[/i] color picker. </description> </method> <method name="erase_preset"> - <return type="void"> - </return> - <argument index="0" name="color" type="Color"> - </argument> + <return type="void" /> + <argument index="0" name="color" type="Color" /> <description> Removes the given color from the list of color presets of this color picker. </description> </method> <method name="get_presets" qualifiers="const"> - <return type="PackedColorArray"> - </return> + <return type="PackedColorArray" /> <description> Returns the list of colors in the presets of the color picker. </description> @@ -67,22 +62,19 @@ </members> <signals> <signal name="color_changed"> - <argument index="0" name="color" type="Color"> - </argument> + <argument index="0" name="color" type="Color" /> <description> Emitted when the color is changed. </description> </signal> <signal name="preset_added"> - <argument index="0" name="color" type="Color"> - </argument> + <argument index="0" name="color" type="Color" /> <description> Emitted when a preset is added. </description> </signal> <signal name="preset_removed"> - <argument index="0" name="color" type="Color"> - </argument> + <argument index="0" name="color" type="Color" /> <description> Emitted when a preset is removed. </description> diff --git a/doc/classes/ColorPickerButton.xml b/doc/classes/ColorPickerButton.xml index 09b828366f..770daa79c6 100644 --- a/doc/classes/ColorPickerButton.xml +++ b/doc/classes/ColorPickerButton.xml @@ -13,15 +13,13 @@ </tutorials> <methods> <method name="get_picker"> - <return type="ColorPicker"> - </return> + <return type="ColorPicker" /> <description> Returns the [ColorPicker] that this node toggles. </description> </method> <method name="get_popup"> - <return type="PopupPanel"> - </return> + <return type="PopupPanel" /> <description> Returns the control's [PopupPanel] which allows you to connect to popup signals. This allows you to handle events when the ColorPicker is shown or hidden. </description> @@ -38,8 +36,7 @@ </members> <signals> <signal name="color_changed"> - <argument index="0" name="color" type="Color"> - </argument> + <argument index="0" name="color" type="Color" /> <description> Emitted when the color changes. </description> diff --git a/doc/classes/ConcavePolygonShape3D.xml b/doc/classes/ConcavePolygonShape3D.xml index b510905d1f..34fb06a476 100644 --- a/doc/classes/ConcavePolygonShape3D.xml +++ b/doc/classes/ConcavePolygonShape3D.xml @@ -12,17 +12,14 @@ </tutorials> <methods> <method name="get_faces" qualifiers="const"> - <return type="PackedVector3Array"> - </return> + <return type="PackedVector3Array" /> <description> Returns the faces (an array of triangles). </description> </method> <method name="set_faces"> - <return type="void"> - </return> - <argument index="0" name="faces" type="PackedVector3Array"> - </argument> + <return type="void" /> + <argument index="0" name="faces" type="PackedVector3Array" /> <description> Sets the faces (an array of triangles). </description> diff --git a/doc/classes/ConeTwistJoint3D.xml b/doc/classes/ConeTwistJoint3D.xml index bd6e24dafd..dd65b3c688 100644 --- a/doc/classes/ConeTwistJoint3D.xml +++ b/doc/classes/ConeTwistJoint3D.xml @@ -12,20 +12,15 @@ </tutorials> <methods> <method name="get_param" qualifiers="const"> - <return type="float"> - </return> - <argument index="0" name="param" type="int" enum="ConeTwistJoint3D.Param"> - </argument> + <return type="float" /> + <argument index="0" name="param" type="int" enum="ConeTwistJoint3D.Param" /> <description> </description> </method> <method name="set_param"> - <return type="void"> - </return> - <argument index="0" name="param" type="int" enum="ConeTwistJoint3D.Param"> - </argument> - <argument index="1" name="value" type="float"> - </argument> + <return type="void" /> + <argument index="0" name="param" type="int" enum="ConeTwistJoint3D.Param" /> + <argument index="1" name="value" type="float" /> <description> </description> </method> diff --git a/doc/classes/ConfigFile.xml b/doc/classes/ConfigFile.xml index 76855fc19f..bcd4266f6c 100644 --- a/doc/classes/ConfigFile.xml +++ b/doc/classes/ConfigFile.xml @@ -50,167 +50,127 @@ </tutorials> <methods> <method name="clear"> - <return type="void"> - </return> + <return type="void" /> <description> </description> </method> <method name="erase_section"> - <return type="void"> - </return> - <argument index="0" name="section" type="String"> - </argument> + <return type="void" /> + <argument index="0" name="section" type="String" /> <description> Deletes the specified section along with all the key-value pairs inside. Raises an error if the section does not exist. </description> </method> <method name="erase_section_key"> - <return type="void"> - </return> - <argument index="0" name="section" type="String"> - </argument> - <argument index="1" name="key" type="String"> - </argument> + <return type="void" /> + <argument index="0" name="section" type="String" /> + <argument index="1" name="key" type="String" /> <description> Deletes the specified key in a section. Raises an error if either the section or the key do not exist. </description> </method> <method name="get_section_keys" qualifiers="const"> - <return type="PackedStringArray"> - </return> - <argument index="0" name="section" type="String"> - </argument> + <return type="PackedStringArray" /> + <argument index="0" name="section" type="String" /> <description> Returns an array of all defined key identifiers in the specified section. Raises an error and returns an empty array if the section does not exist. </description> </method> <method name="get_sections" qualifiers="const"> - <return type="PackedStringArray"> - </return> + <return type="PackedStringArray" /> <description> Returns an array of all defined section identifiers. </description> </method> <method name="get_value" qualifiers="const"> - <return type="Variant"> - </return> - <argument index="0" name="section" type="String"> - </argument> - <argument index="1" name="key" type="String"> - </argument> - <argument index="2" name="default" type="Variant" default="null"> - </argument> + <return type="Variant" /> + <argument index="0" name="section" type="String" /> + <argument index="1" name="key" type="String" /> + <argument index="2" name="default" type="Variant" default="null" /> <description> Returns the current value for the specified section and key. If either the section or the key do not exist, the method returns the fallback [code]default[/code] value. If [code]default[/code] is not specified or set to [code]null[/code], an error is also raised. </description> </method> <method name="has_section" qualifiers="const"> - <return type="bool"> - </return> - <argument index="0" name="section" type="String"> - </argument> + <return type="bool" /> + <argument index="0" name="section" type="String" /> <description> Returns [code]true[/code] if the specified section exists. </description> </method> <method name="has_section_key" qualifiers="const"> - <return type="bool"> - </return> - <argument index="0" name="section" type="String"> - </argument> - <argument index="1" name="key" type="String"> - </argument> + <return type="bool" /> + <argument index="0" name="section" type="String" /> + <argument index="1" name="key" type="String" /> <description> Returns [code]true[/code] if the specified section-key pair exists. </description> </method> <method name="load"> - <return type="int" enum="Error"> - </return> - <argument index="0" name="path" type="String"> - </argument> + <return type="int" enum="Error" /> + <argument index="0" name="path" type="String" /> <description> Loads the config file specified as a parameter. The file's contents are parsed and loaded in the [ConfigFile] object which the method was called on. Returns one of the [enum Error] code constants ([code]OK[/code] on success). </description> </method> <method name="load_encrypted"> - <return type="int" enum="Error"> - </return> - <argument index="0" name="path" type="String"> - </argument> - <argument index="1" name="key" type="PackedByteArray"> - </argument> + <return type="int" enum="Error" /> + <argument index="0" name="path" type="String" /> + <argument index="1" name="key" type="PackedByteArray" /> <description> Loads the encrypted config file specified as a parameter, using the provided [code]key[/code] to decrypt it. The file's contents are parsed and loaded in the [ConfigFile] object which the method was called on. Returns one of the [enum Error] code constants ([code]OK[/code] on success). </description> </method> <method name="load_encrypted_pass"> - <return type="int" enum="Error"> - </return> - <argument index="0" name="path" type="String"> - </argument> - <argument index="1" name="password" type="String"> - </argument> + <return type="int" enum="Error" /> + <argument index="0" name="path" type="String" /> + <argument index="1" name="password" type="String" /> <description> Loads the encrypted config file specified as a parameter, using the provided [code]password[/code] to decrypt it. The file's contents are parsed and loaded in the [ConfigFile] object which the method was called on. Returns one of the [enum Error] code constants ([code]OK[/code] on success). </description> </method> <method name="parse"> - <return type="int" enum="Error"> - </return> - <argument index="0" name="data" type="String"> - </argument> + <return type="int" enum="Error" /> + <argument index="0" name="data" type="String" /> <description> Parses the passed string as the contents of a config file. The string is parsed and loaded in the ConfigFile object which the method was called on. Returns one of the [enum Error] code constants ([code]OK[/code] on success). </description> </method> <method name="save"> - <return type="int" enum="Error"> - </return> - <argument index="0" name="path" type="String"> - </argument> + <return type="int" enum="Error" /> + <argument index="0" name="path" type="String" /> <description> Saves the contents of the [ConfigFile] object to the file specified as a parameter. The output file uses an INI-style structure. Returns one of the [enum Error] code constants ([code]OK[/code] on success). </description> </method> <method name="save_encrypted"> - <return type="int" enum="Error"> - </return> - <argument index="0" name="path" type="String"> - </argument> - <argument index="1" name="key" type="PackedByteArray"> - </argument> + <return type="int" enum="Error" /> + <argument index="0" name="path" type="String" /> + <argument index="1" name="key" type="PackedByteArray" /> <description> Saves the contents of the [ConfigFile] object to the AES-256 encrypted file specified as a parameter, using the provided [code]key[/code] to encrypt it. The output file uses an INI-style structure. Returns one of the [enum Error] code constants ([code]OK[/code] on success). </description> </method> <method name="save_encrypted_pass"> - <return type="int" enum="Error"> - </return> - <argument index="0" name="path" type="String"> - </argument> - <argument index="1" name="password" type="String"> - </argument> + <return type="int" enum="Error" /> + <argument index="0" name="path" type="String" /> + <argument index="1" name="password" type="String" /> <description> Saves the contents of the [ConfigFile] object to the AES-256 encrypted file specified as a parameter, using the provided [code]password[/code] to encrypt it. The output file uses an INI-style structure. Returns one of the [enum Error] code constants ([code]OK[/code] on success). </description> </method> <method name="set_value"> - <return type="void"> - </return> - <argument index="0" name="section" type="String"> - </argument> - <argument index="1" name="key" type="String"> - </argument> - <argument index="2" name="value" type="Variant"> - </argument> + <return type="void" /> + <argument index="0" name="section" type="String" /> + <argument index="1" name="key" type="String" /> + <argument index="2" name="value" type="Variant" /> <description> Assigns a value to the specified key of the specified section. If either the section or the key do not exist, they are created. Passing a [code]null[/code] value deletes the specified key if it exists, and deletes the section if it ends up empty once the key has been removed. </description> diff --git a/doc/classes/ConfirmationDialog.xml b/doc/classes/ConfirmationDialog.xml index 0253ef21df..871082696c 100644 --- a/doc/classes/ConfirmationDialog.xml +++ b/doc/classes/ConfirmationDialog.xml @@ -19,8 +19,7 @@ </tutorials> <methods> <method name="get_cancel_button"> - <return type="Button"> - </return> + <return type="Button" /> <description> Returns the cancel button. </description> diff --git a/doc/classes/Container.xml b/doc/classes/Container.xml index c285b448d8..e78eb8d259 100644 --- a/doc/classes/Container.xml +++ b/doc/classes/Container.xml @@ -11,19 +11,15 @@ </tutorials> <methods> <method name="fit_child_in_rect"> - <return type="void"> - </return> - <argument index="0" name="child" type="Control"> - </argument> - <argument index="1" name="rect" type="Rect2"> - </argument> + <return type="void" /> + <argument index="0" name="child" type="Control" /> + <argument index="1" name="rect" type="Rect2" /> <description> Fit a child control in a given rect. This is mainly a helper for creating custom container classes. </description> </method> <method name="queue_sort"> - <return type="void"> - </return> + <return type="void" /> <description> Queue resort of the contained children. This is called automatically anyway, but can be called upon request. </description> diff --git a/doc/classes/Control.xml b/doc/classes/Control.xml index 9c4600e4f3..43e3c97bff 100644 --- a/doc/classes/Control.xml +++ b/doc/classes/Control.xml @@ -9,7 +9,7 @@ [b]User Interface nodes and input[/b] Godot sends input events to the scene's root node first, by calling [method Node._input]. [method Node._input] forwards the event down the node tree to the nodes under the mouse cursor, or on keyboard focus. To do so, it calls [code]MainLoop._input_event[/code]. [b]FIXME:[/b] No longer valid after DisplayServer split and Input refactoring. - Call [method accept_event] so no other node receives the event. Once you accepted an input, it becomes handled so [method Node._unhandled_input] will not process it. + Call [method accept_event] so no other node receives the event. Once you accept an input, it becomes handled so [method Node._unhandled_input] will not process it. Only one [Control] node can be in keyboard focus. Only the node in focus will receive keyboard events. To get the focus, call [method grab_focus]. [Control] nodes lose focus when another node grabs it, or if you hide the node in focus. Sets [member mouse_filter] to [constant MOUSE_FILTER_IGNORE] to tell a [Control] node to ignore mouse or touch events. You'll need it if you place an icon on top of a button. [Theme] resources change the Control's appearance. If you change the [Theme] on a [Control] node, it affects all of its children. To override some of the theme's parameters, call one of the [code]add_theme_*_override[/code] methods, like [method add_theme_font_override]. You can override the theme with the inspector. @@ -23,12 +23,9 @@ </tutorials> <methods> <method name="_can_drop_data" qualifiers="virtual"> - <return type="bool"> - </return> - <argument index="0" name="position" type="Vector2"> - </argument> - <argument index="1" name="data" type="Variant"> - </argument> + <return type="bool" /> + <argument index="0" name="position" type="Vector2" /> + <argument index="1" name="data" type="Variant" /> <description> Godot calls this method to test if [code]data[/code] from a control's [method _get_drag_data] can be dropped at [code]position[/code]. [code]position[/code] is local to this control. This method should only be used to test the data. Process the data in [method _drop_data]. @@ -51,12 +48,9 @@ </description> </method> <method name="_drop_data" qualifiers="virtual"> - <return type="void"> - </return> - <argument index="0" name="position" type="Vector2"> - </argument> - <argument index="1" name="data" type="Variant"> - </argument> + <return type="void" /> + <argument index="0" name="position" type="Vector2" /> + <argument index="1" name="data" type="Variant" /> <description> Godot calls this method to pass you the [code]data[/code] from a control's [method _get_drag_data] result. Godot first calls [method _can_drop_data] to test if [code]data[/code] is allowed to drop at [code]position[/code] where [code]position[/code] is local to this control. [codeblocks] @@ -80,10 +74,8 @@ </description> </method> <method name="_get_drag_data" qualifiers="virtual"> - <return type="Variant"> - </return> - <argument index="0" name="position" type="Vector2"> - </argument> + <return type="Variant" /> + <argument index="0" name="position" type="Vector2" /> <description> Godot calls this method to get data that can be dragged and dropped onto controls that expect drop data. Returns [code]null[/code] if there is no data to drag. Controls that want to receive drop data should implement [method _can_drop_data] and [method _drop_data]. [code]position[/code] is local to this control. Drag may be forced with [method force_drag]. A preview that will follow the mouse that should represent the data can be set with [method set_drag_preview]. A good time to set the preview is in this method. @@ -106,18 +98,15 @@ </description> </method> <method name="_get_minimum_size" qualifiers="virtual"> - <return type="Vector2"> - </return> + <return type="Vector2" /> <description> Virtual method to be implemented by the user. Returns the minimum size for this control. Alternative to [member rect_min_size] for controlling minimum size via code. The actual minimum size will be the max value of these two (in each axis separately). If not overridden, defaults to [constant Vector2.ZERO]. </description> </method> <method name="_gui_input" qualifiers="virtual"> - <return type="void"> - </return> - <argument index="0" name="event" type="InputEvent"> - </argument> + <return type="void" /> + <argument index="0" name="event" type="InputEvent" /> <description> Virtual method to be implemented by the user. Use this method to process and accept inputs on UI elements. See [method accept_event]. Example: clicking a control. @@ -147,14 +136,12 @@ * control has [member mouse_filter] set to [constant MOUSE_FILTER_IGNORE]; * control is obstructed by another [Control] on top of it, which doesn't have [member mouse_filter] set to [constant MOUSE_FILTER_IGNORE]; * control's parent has [member mouse_filter] set to [constant MOUSE_FILTER_STOP] or has accepted the event; - * it happens outside parent's rectangle and the parent has either [member rect_clip_content] enabled. + * it happens outside the parent's rectangle and the parent has either [member rect_clip_content] enabled. </description> </method> <method name="_has_point" qualifiers="virtual const"> - <return type="bool"> - </return> - <argument index="0" name="" type="Vector2"> - </argument> + <return type="bool" /> + <argument index="0" name="" type="Vector2" /> <description> Virtual method to be implemented by the user. Returns whether the given [code]point[/code] is inside this control. If not overridden, default behavior is checking if the point is within control's Rect. @@ -162,16 +149,14 @@ </description> </method> <method name="_make_custom_tooltip" qualifiers="virtual"> - <return type="Control"> - </return> - <argument index="0" name="for_text" type="String"> - </argument> + <return type="Control" /> + <argument index="0" name="for_text" type="String" /> <description> Virtual method to be implemented by the user. Returns a [Control] node that should be used as a tooltip instead of the default one. The [code]for_text[/code] includes the contents of the [member hint_tooltip] property. - 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 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 hint_tooltip] 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 rect_min_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 be [member CanvasItem.visible] when returned, otherwise, the viewport that instantiates it will not be able to calculate its minimum size reliably. Example of usage with a custom-constructed node: [codeblocks] [gdscript] @@ -209,105 +194,91 @@ </description> </method> <method name="_structured_text_parser" qualifiers="virtual"> - <return type="void"> - </return> - <argument index="0" name="args" type="Array"> - </argument> - <argument index="1" name="text" type="String"> - </argument> + <return type="void" /> + <argument index="0" name="args" type="Array" /> + <argument index="1" name="text" type="String" /> <description> User defined BiDi algorithm override function. Return [code]Array[/code] of [code]Vector2i[/code] text ranges, in the left-to-right order. Ranges should cover full source [code]text[/code] without overlaps. BiDi algorithm will be used on each range separately. </description> </method> <method name="accept_event"> - <return type="void"> - </return> + <return type="void" /> <description> Marks an input event as handled. Once you accept an input event, it stops propagating, even to nodes listening to [method Node._unhandled_input] or [method Node._unhandled_key_input]. </description> </method> <method name="add_theme_color_override"> - <return type="void"> - </return> - <argument index="0" name="name" type="StringName"> - </argument> - <argument index="1" name="color" type="Color"> - </argument> - <description> - Overrides the [Color] with given [code]name[/code] in the [member theme] resource the control uses. + <return type="void" /> + <argument index="0" name="name" type="StringName" /> + <argument index="1" name="color" type="Color" /> + <description> + Creates a local override for a theme [Color] with the specified [code]name[/code]. Local overrides always take precedence when fetching theme items for the control. An override can be removed with [method remove_theme_color_override]. + See also [method get_theme_color]. [b]Example of overriding a label's color and resetting it later:[/b] [codeblocks] [gdscript] - # Override the child node "MyLabel"'s font color to orange. + # Given the child Label node "MyLabel", override its font color with a custom value. $MyLabel.add_theme_color_override("font_color", Color(1, 0.5, 0)) - # Reset the color by creating a new node to get the default value: - var default_label_color = Label.new().get_theme_color("font_color") - $MyLabel.add_theme_color_override("font_color", default_label_color) + # Reset the font color of the child label. + $MyLabel.remove_theme_color_override("font_color") + # Alternatively it can be overridden with the default value from the Label type. + $MyLabel.add_theme_color_override("font_color", get_theme_color("font_color", "Label")) [/gdscript] [csharp] - // Override the child node "MyLabel"'s font color to orange. - GetNode<Label>("MyLabel").AddThemeColorOverride("font_color", new Color(1, 0.5f, 0)); - // Reset the color by creating a new node to get the default value: - var defaultLabelColor = new Label().GetThemeColor("font_color"); - GetNode<Label>("MyLabel").AddThemeColorOverride("font_color", defaultLabelColor); + // Given the child Label node "MyLabel", override its font color with a custom value. + GetNode<Label>("MyLabel").AddThemeColorOverride("font_color", new Color(1, 0.5f, 0)) + // Reset the font color of the child label. + GetNode<Label>("MyLabel").RemoveThemeColorOverride("font_color") + // Alternatively it can be overridden with the default value from the Label type. + GetNode<Label>("MyLabel").AddThemeColorOverride("font_color", GetThemeColor("font_color", "Label")) [/csharp] [/codeblocks] </description> </method> <method name="add_theme_constant_override"> - <return type="void"> - </return> - <argument index="0" name="name" type="StringName"> - </argument> - <argument index="1" name="constant" type="int"> - </argument> + <return type="void" /> + <argument index="0" name="name" type="StringName" /> + <argument index="1" name="constant" type="int" /> <description> - Overrides an integer constant with given [code]name[/code] in the [member theme] resource the control uses. + Creates a local override for a theme constant with the specified [code]name[/code]. Local overrides always take precedence when fetching theme items for the control. An override can be removed with [method remove_theme_constant_override]. + See also [method get_theme_constant]. </description> </method> <method name="add_theme_font_override"> - <return type="void"> - </return> - <argument index="0" name="name" type="StringName"> - </argument> - <argument index="1" name="font" type="Font"> - </argument> + <return type="void" /> + <argument index="0" name="name" type="StringName" /> + <argument index="1" name="font" type="Font" /> <description> - Overrides the font with given [code]name[/code] in the [member theme] resource the control uses. + Creates a local override for a theme [Font] with the specified [code]name[/code]. Local overrides always take precedence when fetching theme items for the control. An override can be removed with [method remove_theme_font_override]. + See also [method get_theme_font]. </description> </method> <method name="add_theme_font_size_override"> - <return type="void"> - </return> - <argument index="0" name="name" type="StringName"> - </argument> - <argument index="1" name="font_size" type="int"> - </argument> + <return type="void" /> + <argument index="0" name="name" type="StringName" /> + <argument index="1" name="font_size" type="int" /> <description> - Overrides the font size with given [code]name[/code] in the [member theme] resource the control uses. + Creates a local override for a theme font size with the specified [code]name[/code]. Local overrides always take precedence when fetching theme items for the control. An override can be removed with [method remove_theme_font_size_override]. + See also [method get_theme_font_size]. </description> </method> <method name="add_theme_icon_override"> - <return type="void"> - </return> - <argument index="0" name="name" type="StringName"> - </argument> - <argument index="1" name="texture" type="Texture2D"> - </argument> + <return type="void" /> + <argument index="0" name="name" type="StringName" /> + <argument index="1" name="texture" type="Texture2D" /> <description> - Overrides the icon with given [code]name[/code] in the [member theme] resource the control uses. + Creates a local override for a theme icon with the specified [code]name[/code]. Local overrides always take precedence when fetching theme items for the control. An override can be removed with [method remove_theme_icon_override]. + See also [method get_theme_icon]. </description> </method> <method name="add_theme_stylebox_override"> - <return type="void"> - </return> - <argument index="0" name="name" type="StringName"> - </argument> - <argument index="1" name="stylebox" type="StyleBox"> - </argument> - <description> - Overrides the [StyleBox] with given [code]name[/code] in the [member theme] resource the control uses. + <return type="void" /> + <argument index="0" name="name" type="StringName" /> + <argument index="1" name="stylebox" type="StyleBox" /> + <description> + Creates a local override for a theme [StyleBox] with the specified [code]name[/code]. Local overrides always take precedence when fetching theme items for the control. An override can be removed with [method remove_theme_stylebox_override]. + See also [method get_theme_stylebox]. [b]Example of modifying a property in a StyleBox by duplicating it:[/b] [codeblocks] [gdscript] @@ -318,8 +289,8 @@ new_stylebox_normal.border_width_top = 3 new_stylebox_normal.border_color = Color(0, 1, 0.5) $MyButton.add_theme_stylebox_override("normal", new_stylebox_normal) - # Remove the stylebox override: - $MyButton.add_theme_stylebox_override("normal", null) + # Remove the stylebox override. + $MyButton.remove_theme_stylebox_override("normal") [/gdscript] [csharp] // The snippet below assumes the child node MyButton has a StyleBoxFlat assigned. @@ -329,227 +300,196 @@ newStyleboxNormal.BorderWidthTop = 3; newStyleboxNormal.BorderColor = new Color(0, 1, 0.5f); GetNode<Button>("MyButton").AddThemeStyleboxOverride("normal", newStyleboxNormal); - // Remove the stylebox override: - GetNode<Button>("MyButton").AddThemeStyleboxOverride("normal", null); + // Remove the stylebox override. + GetNode<Button>("MyButton").RemoveThemeStyleboxOverride("normal"); [/csharp] [/codeblocks] </description> </method> <method name="find_next_valid_focus" qualifiers="const"> - <return type="Control"> - </return> + <return type="Control" /> <description> Finds the next (below in the tree) [Control] that can receive the focus. </description> </method> <method name="find_prev_valid_focus" qualifiers="const"> - <return type="Control"> - </return> + <return type="Control" /> <description> Finds the previous (above in the tree) [Control] that can receive the focus. </description> </method> <method name="force_drag"> - <return type="void"> - </return> - <argument index="0" name="data" type="Variant"> - </argument> - <argument index="1" name="preview" type="Control"> - </argument> + <return type="void" /> + <argument index="0" name="data" type="Variant" /> + <argument index="1" name="preview" type="Control" /> <description> Forces drag and bypasses [method _get_drag_data] and [method set_drag_preview] by passing [code]data[/code] and [code]preview[/code]. Drag will start even if the mouse is neither over nor pressed on this control. The methods [method _can_drop_data] and [method _drop_data] must be implemented on controls that want to receive drop data. </description> </method> <method name="get_anchor" qualifiers="const"> - <return type="float"> - </return> - <argument index="0" name="side" type="int" enum="Side"> - </argument> + <return type="float" /> + <argument index="0" name="side" type="int" enum="Side" /> <description> Returns the anchor for the specified [enum Side]. A getter method for [member anchor_bottom], [member anchor_left], [member anchor_right] and [member anchor_top]. </description> </method> <method name="get_begin" qualifiers="const"> - <return type="Vector2"> - </return> + <return type="Vector2" /> <description> Returns [member offset_left] and [member offset_top]. See also [member rect_position]. </description> </method> <method name="get_combined_minimum_size" qualifiers="const"> - <return type="Vector2"> - </return> + <return type="Vector2" /> <description> Returns combined minimum size from [member rect_min_size] and [method get_minimum_size]. </description> </method> <method name="get_cursor_shape" qualifiers="const"> - <return type="int" enum="Control.CursorShape"> - </return> - <argument index="0" name="position" type="Vector2" default="Vector2(0, 0)"> - </argument> + <return type="int" enum="Control.CursorShape" /> + <argument index="0" name="position" type="Vector2" default="Vector2(0, 0)" /> <description> Returns the mouse cursor shape the control displays on mouse hover. See [enum CursorShape]. </description> </method> <method name="get_end" qualifiers="const"> - <return type="Vector2"> - </return> + <return type="Vector2" /> <description> Returns [member offset_right] and [member offset_bottom]. </description> </method> <method name="get_focus_neighbor" qualifiers="const"> - <return type="NodePath"> - </return> - <argument index="0" name="side" type="int" enum="Side"> - </argument> + <return type="NodePath" /> + <argument index="0" name="side" type="int" enum="Side" /> <description> Returns the focus neighbor for the specified [enum Side]. A getter method for [member focus_neighbor_bottom], [member focus_neighbor_left], [member focus_neighbor_right] and [member focus_neighbor_top]. </description> </method> <method name="get_focus_owner" qualifiers="const"> - <return type="Control"> - </return> + <return type="Control" /> <description> Returns the control that has the keyboard focus or [code]null[/code] if none. </description> </method> <method name="get_global_rect" qualifiers="const"> - <return type="Rect2"> - </return> + <return type="Rect2" /> <description> Returns the position and size of the control relative to the top-left corner of the screen. See [member rect_position] and [member rect_size]. </description> </method> <method name="get_minimum_size" qualifiers="const"> - <return type="Vector2"> - </return> + <return type="Vector2" /> <description> Returns the minimum size for this control. See [member rect_min_size]. </description> </method> <method name="get_offset" qualifiers="const"> - <return type="float"> - </return> - <argument index="0" name="offset" type="int" enum="Side"> - </argument> + <return type="float" /> + <argument index="0" name="offset" type="int" enum="Side" /> <description> Returns the anchor for the specified [enum Side]. A getter method for [member offset_bottom], [member offset_left], [member offset_right] and [member offset_top]. </description> </method> <method name="get_parent_area_size" qualifiers="const"> - <return type="Vector2"> - </return> + <return type="Vector2" /> <description> Returns the width/height occupied in the parent control. </description> </method> <method name="get_parent_control" qualifiers="const"> - <return type="Control"> - </return> + <return type="Control" /> <description> Returns the parent control node. </description> </method> <method name="get_rect" qualifiers="const"> - <return type="Rect2"> - </return> + <return type="Rect2" /> <description> Returns the position and size of the control relative to the top-left corner of the parent Control. See [member rect_position] and [member rect_size]. </description> </method> <method name="get_theme_color" qualifiers="const"> - <return type="Color"> - </return> - <argument index="0" name="name" type="StringName"> - </argument> - <argument index="1" name="theme_type" type="StringName" default=""""> - </argument> - <description> - Returns a color from assigned [Theme] with given [code]name[/code] and associated with [Control] of given [code]theme_type[/code]. + <return type="Color" /> + <argument index="0" name="name" type="StringName" /> + <argument index="1" name="theme_type" type="StringName" default="""" /> + <description> + Returns a [Color] from the first matching [Theme] in the tree if that [Theme] has a color item with the specified [code]name[/code] and [code]theme_type[/code]. If [code]theme_type[/code] is omitted the class name of the current control is used as the type, or [member theme_type_variation] if it is defined. If the type is a class name its parent classes are also checked, in order of inheritance. If the type is a variation its base types are checked, in order of dependency, then the control's class name and its parent classes are checked. + For the current control its local overrides are considered first (see [method add_theme_color_override]), then its assigned [member theme]. After the current control, each parent control and its assigned [member theme] are considered; controls without a [member theme] assigned are skipped. If no matching [Theme] is found in the tree, a custom project [Theme] (see [member ProjectSettings.gui/theme/custom]) and the default [Theme] are used. [codeblocks] [gdscript] func _ready(): - modulate = get_theme_color("font_color", "Button") #get the color defined for button fonts + # Get the font color defined for the current Control's class, if it exists. + modulate = get_theme_color("font_color") + # Get the font color defined for the Button class. + modulate = get_theme_color("font_color", "Button") [/gdscript] [csharp] public override void _Ready() { - Modulate = GetThemeColor("font_color", "Button"); //get the color defined for button fonts + // Get the font color defined for the current Control's class, if it exists. + Modulate = GetThemeColor("font_color"); + // Get the font color defined for the Button class. + Modulate = GetThemeColor("font_color", "Button"); } [/csharp] [/codeblocks] </description> </method> <method name="get_theme_constant" qualifiers="const"> - <return type="int"> - </return> - <argument index="0" name="name" type="StringName"> - </argument> - <argument index="1" name="theme_type" type="StringName" default=""""> - </argument> + <return type="int" /> + <argument index="0" name="name" type="StringName" /> + <argument index="1" name="theme_type" type="StringName" default="""" /> <description> - Returns a constant from assigned [Theme] with given [code]name[/code] and associated with [Control] of given [code]theme_type[/code]. + Returns a constant from the first matching [Theme] in the tree if that [Theme] has a constant item with the specified [code]name[/code] and [code]theme_type[/code]. + See [method get_theme_color] for details. </description> </method> <method name="get_theme_font" qualifiers="const"> - <return type="Font"> - </return> - <argument index="0" name="name" type="StringName"> - </argument> - <argument index="1" name="theme_type" type="StringName" default=""""> - </argument> + <return type="Font" /> + <argument index="0" name="name" type="StringName" /> + <argument index="1" name="theme_type" type="StringName" default="""" /> <description> - Returns a font from assigned [Theme] with given [code]name[/code] and associated with [Control] of given [code]theme_type[/code]. + Returns a [Font] from the first matching [Theme] in the tree if that [Theme] has a font item with the specified [code]name[/code] and [code]theme_type[/code]. + See [method get_theme_color] for details. </description> </method> <method name="get_theme_font_size" qualifiers="const"> - <return type="int"> - </return> - <argument index="0" name="name" type="StringName"> - </argument> - <argument index="1" name="theme_type" type="StringName" default=""""> - </argument> + <return type="int" /> + <argument index="0" name="name" type="StringName" /> + <argument index="1" name="theme_type" type="StringName" default="""" /> <description> - Returns a font size from assigned [Theme] with given [code]name[/code] and associated with [Control] of given [code]theme_type[/code]. + Returns a font size from the first matching [Theme] in the tree if that [Theme] has a font size item with the specified [code]name[/code] and [code]theme_type[/code]. + See [method get_theme_color] for details. </description> </method> <method name="get_theme_icon" qualifiers="const"> - <return type="Texture2D"> - </return> - <argument index="0" name="name" type="StringName"> - </argument> - <argument index="1" name="theme_type" type="StringName" default=""""> - </argument> + <return type="Texture2D" /> + <argument index="0" name="name" type="StringName" /> + <argument index="1" name="theme_type" type="StringName" default="""" /> <description> - Returns an icon from assigned [Theme] with given [code]name[/code] and associated with [Control] of given [code]theme_type[/code]. + Returns an icon from the first matching [Theme] in the tree if that [Theme] has an icon item with the specified [code]name[/code] and [code]theme_type[/code]. + See [method get_theme_color] for details. </description> </method> <method name="get_theme_stylebox" qualifiers="const"> - <return type="StyleBox"> - </return> - <argument index="0" name="name" type="StringName"> - </argument> - <argument index="1" name="theme_type" type="StringName" default=""""> - </argument> + <return type="StyleBox" /> + <argument index="0" name="name" type="StringName" /> + <argument index="1" name="theme_type" type="StringName" default="""" /> <description> - Returns a [StyleBox] from assigned [Theme] with given [code]name[/code] and associated with [Control] of given [code]theme_type[/code]. + Returns a [StyleBox] from the first matching [Theme] in the tree if that [Theme] has a stylebox item with the specified [code]name[/code] and [code]theme_type[/code]. + See [method get_theme_color] for details. </description> </method> <method name="get_tooltip" qualifiers="const"> - <return type="String"> - </return> - <argument index="0" name="at_position" type="Vector2" default="Vector2(0, 0)"> - </argument> + <return type="String" /> + <argument index="0" name="at_position" type="Vector2" default="Vector2(0, 0)" /> <description> Returns the tooltip, which will appear when the cursor is resting over this control. See [member hint_tooltip]. </description> </method> <method name="grab_click_focus"> - <return type="void"> - </return> + <return type="void" /> <description> Creates an [InputEventMouseButton] that attempts to click the control. If the event is received, the control acquires focus. [codeblocks] @@ -567,225 +507,185 @@ </description> </method> <method name="grab_focus"> - <return type="void"> - </return> + <return type="void" /> <description> Steal the focus from another control and become the focused control (see [member focus_mode]). </description> </method> <method name="has_focus" qualifiers="const"> - <return type="bool"> - </return> + <return type="bool" /> <description> Returns [code]true[/code] if this is the current focused control. See [member focus_mode]. </description> </method> <method name="has_theme_color" qualifiers="const"> - <return type="bool"> - </return> - <argument index="0" name="name" type="StringName"> - </argument> - <argument index="1" name="theme_type" type="StringName" default=""""> - </argument> + <return type="bool" /> + <argument index="0" name="name" type="StringName" /> + <argument index="1" name="theme_type" type="StringName" default="""" /> <description> - Returns [code]true[/code] if [Color] with given [code]name[/code] and associated with [Control] of given [code]theme_type[/code] exists in assigned [Theme]. + Returns [code]true[/code] if there is a matching [Theme] in the tree that has a color item with the specified [code]name[/code] and [code]theme_type[/code]. + See [method get_theme_color] for details. </description> </method> <method name="has_theme_color_override" qualifiers="const"> - <return type="bool"> - </return> - <argument index="0" name="name" type="StringName"> - </argument> + <return type="bool" /> + <argument index="0" name="name" type="StringName" /> <description> - Returns [code]true[/code] if [Color] with given [code]name[/code] has a valid override in this [Control] node. + Returns [code]true[/code] if there is a local override for a theme [Color] with the specified [code]name[/code] in this [Control] node. + See [method add_theme_color_override]. </description> </method> <method name="has_theme_constant" qualifiers="const"> - <return type="bool"> - </return> - <argument index="0" name="name" type="StringName"> - </argument> - <argument index="1" name="theme_type" type="StringName" default=""""> - </argument> + <return type="bool" /> + <argument index="0" name="name" type="StringName" /> + <argument index="1" name="theme_type" type="StringName" default="""" /> <description> - Returns [code]true[/code] if constant with given [code]name[/code] and associated with [Control] of given [code]theme_type[/code] exists in assigned [Theme]. + Returns [code]true[/code] if there is a matching [Theme] in the tree that has a constant item with the specified [code]name[/code] and [code]theme_type[/code]. + See [method get_theme_color] for details. </description> </method> <method name="has_theme_constant_override" qualifiers="const"> - <return type="bool"> - </return> - <argument index="0" name="name" type="StringName"> - </argument> + <return type="bool" /> + <argument index="0" name="name" type="StringName" /> <description> - Returns [code]true[/code] if constant with given [code]name[/code] has a valid override in this [Control] node. + Returns [code]true[/code] if there is a local override for a theme constant with the specified [code]name[/code] in this [Control] node. + See [method add_theme_constant_override]. </description> </method> <method name="has_theme_font" qualifiers="const"> - <return type="bool"> - </return> - <argument index="0" name="name" type="StringName"> - </argument> - <argument index="1" name="theme_type" type="StringName" default=""""> - </argument> + <return type="bool" /> + <argument index="0" name="name" type="StringName" /> + <argument index="1" name="theme_type" type="StringName" default="""" /> <description> - Returns [code]true[/code] if font with given [code]name[/code] and associated with [Control] of given [code]theme_type[/code] exists in assigned [Theme]. + Returns [code]true[/code] if there is a matching [Theme] in the tree that has a font item with the specified [code]name[/code] and [code]theme_type[/code]. + See [method get_theme_color] for details. </description> </method> <method name="has_theme_font_override" qualifiers="const"> - <return type="bool"> - </return> - <argument index="0" name="name" type="StringName"> - </argument> + <return type="bool" /> + <argument index="0" name="name" type="StringName" /> <description> - Returns [code]true[/code] if font with given [code]name[/code] has a valid override in this [Control] node. + Returns [code]true[/code] if there is a local override for a theme [Font] with the specified [code]name[/code] in this [Control] node. + See [method add_theme_font_override]. </description> </method> <method name="has_theme_font_size" qualifiers="const"> - <return type="bool"> - </return> - <argument index="0" name="name" type="StringName"> - </argument> - <argument index="1" name="theme_type" type="StringName" default=""""> - </argument> + <return type="bool" /> + <argument index="0" name="name" type="StringName" /> + <argument index="1" name="theme_type" type="StringName" default="""" /> <description> - Returns [code]true[/code] if font size with given [code]name[/code] and associated with [Control] of given [code]theme_type[/code] exists in assigned [Theme]. + Returns [code]true[/code] if there is a matching [Theme] in the tree that has a font size item with the specified [code]name[/code] and [code]theme_type[/code]. + See [method get_theme_color] for details. </description> </method> <method name="has_theme_font_size_override" qualifiers="const"> - <return type="bool"> - </return> - <argument index="0" name="name" type="StringName"> - </argument> + <return type="bool" /> + <argument index="0" name="name" type="StringName" /> <description> - Returns [code]true[/code] if font size with given [code]name[/code] has a valid override in this [Control] node. + Returns [code]true[/code] if there is a local override for a theme font size with the specified [code]name[/code] in this [Control] node. + See [method add_theme_font_size_override]. </description> </method> <method name="has_theme_icon" qualifiers="const"> - <return type="bool"> - </return> - <argument index="0" name="name" type="StringName"> - </argument> - <argument index="1" name="theme_type" type="StringName" default=""""> - </argument> + <return type="bool" /> + <argument index="0" name="name" type="StringName" /> + <argument index="1" name="theme_type" type="StringName" default="""" /> <description> - Returns [code]true[/code] if icon with given [code]name[/code] and associated with [Control] of given [code]theme_type[/code] exists in assigned [Theme]. + Returns [code]true[/code] if there is a matching [Theme] in the tree that has an icon item with the specified [code]name[/code] and [code]theme_type[/code]. + See [method get_theme_color] for details. </description> </method> <method name="has_theme_icon_override" qualifiers="const"> - <return type="bool"> - </return> - <argument index="0" name="name" type="StringName"> - </argument> + <return type="bool" /> + <argument index="0" name="name" type="StringName" /> <description> - Returns [code]true[/code] if icon with given [code]name[/code] has a valid override in this [Control] node. + Returns [code]true[/code] if there is a local override for a theme icon with the specified [code]name[/code] in this [Control] node. + See [method add_theme_icon_override]. </description> </method> <method name="has_theme_stylebox" qualifiers="const"> - <return type="bool"> - </return> - <argument index="0" name="name" type="StringName"> - </argument> - <argument index="1" name="theme_type" type="StringName" default=""""> - </argument> + <return type="bool" /> + <argument index="0" name="name" type="StringName" /> + <argument index="1" name="theme_type" type="StringName" default="""" /> <description> - Returns [code]true[/code] if [StyleBox] with given [code]name[/code] and associated with [Control] of given [code]theme_type[/code] exists in assigned [Theme]. + Returns [code]true[/code] if there is a matching [Theme] in the tree that has a stylebox item with the specified [code]name[/code] and [code]theme_type[/code]. + See [method get_theme_color] for details. </description> </method> <method name="has_theme_stylebox_override" qualifiers="const"> - <return type="bool"> - </return> - <argument index="0" name="name" type="StringName"> - </argument> + <return type="bool" /> + <argument index="0" name="name" type="StringName" /> <description> - Returns [code]true[/code] if [StyleBox] with given [code]name[/code] has a valid override in this [Control] node. + Returns [code]true[/code] if there is a local override for a theme [StyleBox] with the specified [code]name[/code] in this [Control] node. + See [method add_theme_stylebox_override]. </description> </method> <method name="is_layout_rtl" qualifiers="const"> - <return type="bool"> - </return> + <return type="bool" /> <description> Returns [code]true[/code] if layout is right-to-left. </description> </method> <method name="minimum_size_changed"> - <return type="void"> - </return> + <return type="void" /> <description> Invalidates the size cache in this node and in parent nodes up to top_level. Intended to be used with [method get_minimum_size] when the return value is changed. Setting [member rect_min_size] directly calls this method automatically. </description> </method> <method name="release_focus"> - <return type="void"> - </return> + <return type="void" /> <description> Give up the focus. No other control will be able to receive keyboard input. </description> </method> <method name="remove_theme_color_override"> - <return type="void"> - </return> - <argument index="0" name="name" type="StringName"> - </argument> + <return type="void" /> + <argument index="0" name="name" type="StringName" /> <description> - Removes a theme override for a [Color] with the given [code]name[/code]. + Removes a local override for a theme [Color] with the specified [code]name[/code] previously added by [method add_theme_color_override] or via the Inspector dock. </description> </method> <method name="remove_theme_constant_override"> - <return type="void"> - </return> - <argument index="0" name="name" type="StringName"> - </argument> + <return type="void" /> + <argument index="0" name="name" type="StringName" /> <description> - Removes a theme override for a constant with the given [code]name[/code]. + Removes a local override for a theme constant with the specified [code]name[/code] previously added by [method add_theme_constant_override] or via the Inspector dock. </description> </method> <method name="remove_theme_font_override"> - <return type="void"> - </return> - <argument index="0" name="name" type="StringName"> - </argument> + <return type="void" /> + <argument index="0" name="name" type="StringName" /> <description> - Removes a theme override for a [Font] with the given [code]name[/code]. + Removes a local override for a theme [Font] with the specified [code]name[/code] previously added by [method add_theme_font_override] or via the Inspector dock. </description> </method> <method name="remove_theme_font_size_override"> - <return type="void"> - </return> - <argument index="0" name="name" type="StringName"> - </argument> + <return type="void" /> + <argument index="0" name="name" type="StringName" /> <description> - Removes a theme override for a font size with the given [code]name[/code]. + Removes a local override for a theme font size with the specified [code]name[/code] previously added by [method add_theme_font_size_override] or via the Inspector dock. </description> </method> <method name="remove_theme_icon_override"> - <return type="void"> - </return> - <argument index="0" name="name" type="StringName"> - </argument> + <return type="void" /> + <argument index="0" name="name" type="StringName" /> <description> - Removes a theme override for an icon with the given [code]name[/code]. + Removes a local override for a theme icon with the specified [code]name[/code] previously added by [method add_theme_icon_override] or via the Inspector dock. </description> </method> <method name="remove_theme_stylebox_override"> - <return type="void"> - </return> - <argument index="0" name="name" type="StringName"> - </argument> + <return type="void" /> + <argument index="0" name="name" type="StringName" /> <description> - Removes a theme override for a [StyleBox] with the given [code]name[/code]. + Removes a local override for a theme [StyleBox] with the specified [code]name[/code] previously added by [method add_theme_stylebox_override] or via the Inspector dock. </description> </method> <method name="set_anchor"> - <return type="void"> - </return> - <argument index="0" name="side" type="int" enum="Side"> - </argument> - <argument index="1" name="anchor" type="float"> - </argument> - <argument index="2" name="keep_offset" type="bool" default="false"> - </argument> - <argument index="3" name="push_opposite_anchor" type="bool" default="true"> - </argument> + <return type="void" /> + <argument index="0" name="side" type="int" enum="Side" /> + <argument index="1" name="anchor" type="float" /> + <argument index="2" name="keep_offset" type="bool" default="false" /> + <argument index="3" name="push_opposite_anchor" type="bool" default="true" /> <description> Sets the anchor for the specified [enum Side] to [code]anchor[/code]. A setter method for [member anchor_bottom], [member anchor_left], [member anchor_right] and [member anchor_top]. If [code]keep_offset[/code] is [code]true[/code], offsets aren't updated after this operation. @@ -793,59 +693,43 @@ </description> </method> <method name="set_anchor_and_offset"> - <return type="void"> - </return> - <argument index="0" name="side" type="int" enum="Side"> - </argument> - <argument index="1" name="anchor" type="float"> - </argument> - <argument index="2" name="offset" type="float"> - </argument> - <argument index="3" name="push_opposite_anchor" type="bool" default="false"> - </argument> + <return type="void" /> + <argument index="0" name="side" type="int" enum="Side" /> + <argument index="1" name="anchor" type="float" /> + <argument index="2" name="offset" type="float" /> + <argument index="3" name="push_opposite_anchor" type="bool" default="false" /> <description> Works the same as [method set_anchor], but instead of [code]keep_offset[/code] argument and automatic update of offset, it allows to set the offset yourself (see [method set_offset]). </description> </method> <method name="set_anchors_and_offsets_preset"> - <return type="void"> - </return> - <argument index="0" name="preset" type="int" enum="Control.LayoutPreset"> - </argument> - <argument index="1" name="resize_mode" type="int" enum="Control.LayoutPresetMode" default="0"> - </argument> - <argument index="2" name="margin" type="int" default="0"> - </argument> + <return type="void" /> + <argument index="0" name="preset" type="int" enum="Control.LayoutPreset" /> + <argument index="1" name="resize_mode" type="int" enum="Control.LayoutPresetMode" default="0" /> + <argument index="2" name="margin" type="int" default="0" /> <description> Sets both anchor preset and offset preset. See [method set_anchors_preset] and [method set_offsets_preset]. </description> </method> <method name="set_anchors_preset"> - <return type="void"> - </return> - <argument index="0" name="preset" type="int" enum="Control.LayoutPreset"> - </argument> - <argument index="1" name="keep_offsets" type="bool" default="false"> - </argument> - <description> - Sets the anchors to a [code]preset[/code] from [enum Control.LayoutPreset] enum. This is code equivalent of using the Layout menu in 2D editor. + <return type="void" /> + <argument index="0" name="preset" type="int" enum="Control.LayoutPreset" /> + <argument index="1" name="keep_offsets" type="bool" default="false" /> + <description> + Sets the anchors to a [code]preset[/code] from [enum Control.LayoutPreset] enum. This is the code equivalent to using the Layout menu in the 2D editor. If [code]keep_offsets[/code] is [code]true[/code], control's position will also be updated. </description> </method> <method name="set_begin"> - <return type="void"> - </return> - <argument index="0" name="position" type="Vector2"> - </argument> + <return type="void" /> + <argument index="0" name="position" type="Vector2" /> <description> Sets [member offset_left] and [member offset_top] at the same time. Equivalent of changing [member rect_position]. </description> </method> <method name="set_drag_forwarding"> - <return type="void"> - </return> - <argument index="0" name="target" type="Control"> - </argument> + <return type="void" /> + <argument index="0" name="target" type="Control" /> <description> Forwards the handling of this control's drag and drop to [code]target[/code] control. Forwarding can be implemented in the target control similar to the methods [method _get_drag_data], [method _can_drop_data], and [method _drop_data] but with two differences: @@ -909,10 +793,8 @@ </description> </method> <method name="set_drag_preview"> - <return type="void"> - </return> - <argument index="0" name="control" type="Control"> - </argument> + <return type="void" /> + <argument index="0" name="control" type="Control" /> <description> Shows the given control at the mouse pointer. A good time to call this method is in [method _get_drag_data]. The control must not be in the scene tree. You should not free the control, and you should not keep a reference to the control beyond the duration of the drag. It will be deleted automatically after the drag has ended. [codeblocks] @@ -945,92 +827,69 @@ </description> </method> <method name="set_end"> - <return type="void"> - </return> - <argument index="0" name="position" type="Vector2"> - </argument> + <return type="void" /> + <argument index="0" name="position" type="Vector2" /> <description> Sets [member offset_right] and [member offset_bottom] at the same time. </description> </method> <method name="set_focus_neighbor"> - <return type="void"> - </return> - <argument index="0" name="side" type="int" enum="Side"> - </argument> - <argument index="1" name="neighbor" type="NodePath"> - </argument> + <return type="void" /> + <argument index="0" name="side" type="int" enum="Side" /> + <argument index="1" name="neighbor" type="NodePath" /> <description> Sets the anchor for the specified [enum Side] to the [Control] at [code]neighbor[/code] node path. A setter method for [member focus_neighbor_bottom], [member focus_neighbor_left], [member focus_neighbor_right] and [member focus_neighbor_top]. </description> </method> <method name="set_global_position"> - <return type="void"> - </return> - <argument index="0" name="position" type="Vector2"> - </argument> - <argument index="1" name="keep_offsets" type="bool" default="false"> - </argument> + <return type="void" /> + <argument index="0" name="position" type="Vector2" /> + <argument index="1" name="keep_offsets" type="bool" default="false" /> <description> Sets the [member rect_global_position] to given [code]position[/code]. If [code]keep_offsets[/code] is [code]true[/code], control's anchors will be updated instead of offsets. </description> </method> <method name="set_offset"> - <return type="void"> - </return> - <argument index="0" name="side" type="int" enum="Side"> - </argument> - <argument index="1" name="offset" type="float"> - </argument> + <return type="void" /> + <argument index="0" name="side" type="int" enum="Side" /> + <argument index="1" name="offset" type="float" /> <description> Sets the offset for the specified [enum Side] to [code]offset[/code]. A setter method for [member offset_bottom], [member offset_left], [member offset_right] and [member offset_top]. </description> </method> <method name="set_offsets_preset"> - <return type="void"> - </return> - <argument index="0" name="preset" type="int" enum="Control.LayoutPreset"> - </argument> - <argument index="1" name="resize_mode" type="int" enum="Control.LayoutPresetMode" default="0"> - </argument> - <argument index="2" name="margin" type="int" default="0"> - </argument> - <description> - Sets the offsets to a [code]preset[/code] from [enum Control.LayoutPreset] enum. This is code equivalent of using the Layout menu in 2D editor. + <return type="void" /> + <argument index="0" name="preset" type="int" enum="Control.LayoutPreset" /> + <argument index="1" name="resize_mode" type="int" enum="Control.LayoutPresetMode" default="0" /> + <argument index="2" name="margin" type="int" default="0" /> + <description> + Sets the offsets to a [code]preset[/code] from [enum Control.LayoutPreset] enum. This is the code equivalent to using the Layout menu in the 2D editor. Use parameter [code]resize_mode[/code] with constants from [enum Control.LayoutPresetMode] to better determine the resulting size of the [Control]. Constant size will be ignored if used with presets that change size, e.g. [code]PRESET_LEFT_WIDE[/code]. Use parameter [code]margin[/code] to determine the gap between the [Control] and the edges. </description> </method> <method name="set_position"> - <return type="void"> - </return> - <argument index="0" name="position" type="Vector2"> - </argument> - <argument index="1" name="keep_offsets" type="bool" default="false"> - </argument> + <return type="void" /> + <argument index="0" name="position" type="Vector2" /> + <argument index="1" name="keep_offsets" type="bool" default="false" /> <description> Sets the [member rect_position] to given [code]position[/code]. If [code]keep_offsets[/code] is [code]true[/code], control's anchors will be updated instead of offsets. </description> </method> <method name="set_size"> - <return type="void"> - </return> - <argument index="0" name="size" type="Vector2"> - </argument> - <argument index="1" name="keep_offsets" type="bool" default="false"> - </argument> + <return type="void" /> + <argument index="0" name="size" type="Vector2" /> + <argument index="1" name="keep_offsets" type="bool" default="false" /> <description> Sets the size (see [member rect_size]). If [code]keep_offsets[/code] is [code]true[/code], control's anchors will be updated instead of offsets. </description> </method> <method name="warp_mouse"> - <return type="void"> - </return> - <argument index="0" name="to_position" type="Vector2"> - </argument> + <return type="void" /> + <argument index="0" name="to_position" type="Vector2" /> <description> Moves the mouse cursor to [code]to_position[/code], relative to [member rect_position] of this [Control]. </description> @@ -1049,6 +908,9 @@ <member name="anchor_top" type="float" setter="_set_anchor" getter="get_anchor" default="0.0"> Anchors the top edge of the node to the origin, the center or the end of its parent control. It changes how the top offset updates when the node moves or changes size. You can use one of the [enum Anchor] constants for convenience. </member> + <member name="auto_translate" type="bool" setter="set_auto_translate" getter="is_auto_translating" default="true"> + Toggles if any text should automatically change to its translated version depending on the current locale. + </member> <member name="focus_mode" type="int" setter="set_focus_mode" getter="get_focus_mode" enum="Control.FocusMode" default="0"> The focus access mode for the control (None, Click or All). Only one Control can be focused at the same time, and it will receive keyboard signals. </member> @@ -1183,8 +1045,7 @@ </description> </signal> <signal name="gui_input"> - <argument index="0" name="event" type="InputEvent"> - </argument> + <argument index="0" name="event" type="InputEvent" /> <description> Emitted when the node receives an [InputEvent]. </description> @@ -1197,11 +1058,13 @@ <signal name="mouse_entered"> <description> Emitted when the mouse enters the control's [code]Rect[/code] area, provided its [member mouse_filter] lets the event reach it. + [b]Note:[/b] [signal mouse_entered] will not be emitted if the mouse enters a child [Control] node before entering the parent's [code]Rect[/code] area, at least until the mouse is moved to reach the parent's [code]Rect[/code] area. </description> </signal> <signal name="mouse_exited"> <description> Emitted when the mouse leaves the control's [code]Rect[/code] area, provided its [member mouse_filter] lets the event reach it. + [b]Note:[/b] [signal mouse_exited] will be emitted if the mouse enters a child [Control] node, even if the mouse cursor is still inside the parent's [code]Rect[/code] area. </description> </signal> <signal name="resized"> diff --git a/doc/classes/ConvexPolygonShape2D.xml b/doc/classes/ConvexPolygonShape2D.xml index d53900e6c5..243605e2b7 100644 --- a/doc/classes/ConvexPolygonShape2D.xml +++ b/doc/classes/ConvexPolygonShape2D.xml @@ -11,10 +11,8 @@ </tutorials> <methods> <method name="set_point_cloud"> - <return type="void"> - </return> - <argument index="0" name="point_cloud" type="PackedVector2Array"> - </argument> + <return type="void" /> + <argument index="0" name="point_cloud" type="PackedVector2Array" /> <description> Based on the set of points provided, this creates and assigns the [member points] property using the convex hull algorithm. Removing all unneeded points. See [method Geometry2D.convex_hull] for details. </description> diff --git a/doc/classes/Crypto.xml b/doc/classes/Crypto.xml index deda6116f4..3d7ca956da 100644 --- a/doc/classes/Crypto.xml +++ b/doc/classes/Crypto.xml @@ -74,70 +74,52 @@ </tutorials> <methods> <method name="constant_time_compare"> - <return type="bool"> - </return> - <argument index="0" name="trusted" type="PackedByteArray"> - </argument> - <argument index="1" name="received" type="PackedByteArray"> - </argument> + <return type="bool" /> + <argument index="0" name="trusted" type="PackedByteArray" /> + <argument index="1" name="received" type="PackedByteArray" /> <description> Compares two [PackedByteArray]s for equality without leaking timing information in order to prevent timing attacks. See [url=https://paragonie.com/blog/2015/11/preventing-timing-attacks-on-string-comparison-with-double-hmac-strategy]this blog post[/url] for more information. </description> </method> <method name="decrypt"> - <return type="PackedByteArray"> - </return> - <argument index="0" name="key" type="CryptoKey"> - </argument> - <argument index="1" name="ciphertext" type="PackedByteArray"> - </argument> + <return type="PackedByteArray" /> + <argument index="0" name="key" type="CryptoKey" /> + <argument index="1" name="ciphertext" type="PackedByteArray" /> <description> Decrypt the given [code]ciphertext[/code] with the provided private [code]key[/code]. [b]Note[/b]: The maximum size of accepted ciphertext is limited by the key size. </description> </method> <method name="encrypt"> - <return type="PackedByteArray"> - </return> - <argument index="0" name="key" type="CryptoKey"> - </argument> - <argument index="1" name="plaintext" type="PackedByteArray"> - </argument> + <return type="PackedByteArray" /> + <argument index="0" name="key" type="CryptoKey" /> + <argument index="1" name="plaintext" type="PackedByteArray" /> <description> Encrypt the given [code]plaintext[/code] with the provided public [code]key[/code]. [b]Note[/b]: The maximum size of accepted plaintext is limited by the key size. </description> </method> <method name="generate_random_bytes"> - <return type="PackedByteArray"> - </return> - <argument index="0" name="size" type="int"> - </argument> + <return type="PackedByteArray" /> + <argument index="0" name="size" type="int" /> <description> Generates a [PackedByteArray] of cryptographically secure random bytes with given [code]size[/code]. </description> </method> <method name="generate_rsa"> - <return type="CryptoKey"> - </return> - <argument index="0" name="size" type="int"> - </argument> + <return type="CryptoKey" /> + <argument index="0" name="size" type="int" /> <description> Generates an RSA [CryptoKey] that can be used for creating self-signed certificates and passed to [method StreamPeerSSL.accept_stream]. </description> </method> <method name="generate_self_signed_certificate"> - <return type="X509Certificate"> - </return> - <argument index="0" name="key" type="CryptoKey"> - </argument> - <argument index="1" name="issuer_name" type="String" default=""CN=myserver,O=myorganisation,C=IT""> - </argument> - <argument index="2" name="not_before" type="String" default=""20140101000000""> - </argument> - <argument index="3" name="not_after" type="String" default=""20340101000000""> - </argument> + <return type="X509Certificate" /> + <argument index="0" name="key" type="CryptoKey" /> + <argument index="1" name="issuer_name" type="String" default=""CN=myserver,O=myorganisation,C=IT"" /> + <argument index="2" name="not_before" type="String" default=""20140101000000"" /> + <argument index="3" name="not_after" type="String" default=""20340101000000"" /> <description> Generates a self-signed [X509Certificate] from the given [CryptoKey] and [code]issuer_name[/code]. The certificate validity will be defined by [code]not_before[/code] and [code]not_after[/code] (first valid date and last valid date). The [code]issuer_name[/code] must contain at least "CN=" (common name, i.e. the domain name), "O=" (organization, i.e. your company name), "C=" (country, i.e. 2 lettered ISO-3166 code of the country the organization is based in). A small example to generate an RSA key and a X509 self-signed certificate. @@ -160,43 +142,30 @@ </description> </method> <method name="hmac_digest"> - <return type="PackedByteArray"> - </return> - <argument index="0" name="hash_type" type="int" enum="HashingContext.HashType"> - </argument> - <argument index="1" name="key" type="PackedByteArray"> - </argument> - <argument index="2" name="msg" type="PackedByteArray"> - </argument> + <return type="PackedByteArray" /> + <argument index="0" name="hash_type" type="int" enum="HashingContext.HashType" /> + <argument index="1" name="key" type="PackedByteArray" /> + <argument index="2" name="msg" type="PackedByteArray" /> <description> Generates an [url=https://en.wikipedia.org/wiki/HMAC]HMAC[/url] digest of [code]msg[/code] using [code]key[/code]. The [code]hash_type[/code] parameter is the hashing algorithm that is used for the inner and outer hashes. Currently, only [constant HashingContext.HASH_SHA256] and [constant HashingContext.HASH_SHA1] are supported. </description> </method> <method name="sign"> - <return type="PackedByteArray"> - </return> - <argument index="0" name="hash_type" type="int" enum="HashingContext.HashType"> - </argument> - <argument index="1" name="hash" type="PackedByteArray"> - </argument> - <argument index="2" name="key" type="CryptoKey"> - </argument> + <return type="PackedByteArray" /> + <argument index="0" name="hash_type" type="int" enum="HashingContext.HashType" /> + <argument index="1" name="hash" type="PackedByteArray" /> + <argument index="2" name="key" type="CryptoKey" /> <description> Sign a given [code]hash[/code] of type [code]hash_type[/code] with the provided private [code]key[/code]. </description> </method> <method name="verify"> - <return type="bool"> - </return> - <argument index="0" name="hash_type" type="int" enum="HashingContext.HashType"> - </argument> - <argument index="1" name="hash" type="PackedByteArray"> - </argument> - <argument index="2" name="signature" type="PackedByteArray"> - </argument> - <argument index="3" name="key" type="CryptoKey"> - </argument> + <return type="bool" /> + <argument index="0" name="hash_type" type="int" enum="HashingContext.HashType" /> + <argument index="1" name="hash" type="PackedByteArray" /> + <argument index="2" name="signature" type="PackedByteArray" /> + <argument index="3" name="key" type="CryptoKey" /> <description> Verify that a given [code]signature[/code] for [code]hash[/code] of type [code]hash_type[/code] against the provided public [code]key[/code]. </description> diff --git a/doc/classes/CryptoKey.xml b/doc/classes/CryptoKey.xml index 26b3087b21..afe2c6b301 100644 --- a/doc/classes/CryptoKey.xml +++ b/doc/classes/CryptoKey.xml @@ -12,52 +12,40 @@ </tutorials> <methods> <method name="is_public_only" qualifiers="const"> - <return type="bool"> - </return> + <return type="bool" /> <description> Return [code]true[/code] if this CryptoKey only has the public part, and not the private one. </description> </method> <method name="load"> - <return type="int" enum="Error"> - </return> - <argument index="0" name="path" type="String"> - </argument> - <argument index="1" name="public_only" type="bool" default="false"> - </argument> + <return type="int" enum="Error" /> + <argument index="0" name="path" type="String" /> + <argument index="1" name="public_only" type="bool" default="false" /> <description> Loads a key from [code]path[/code]. If [code]public_only[/code] is [code]true[/code], only the public key will be loaded. [b]Note[/b]: [code]path[/code] should be a "*.pub" file if [code]public_only[/code] is [code]true[/code], a "*.key" file otherwise. </description> </method> <method name="load_from_string"> - <return type="int" enum="Error"> - </return> - <argument index="0" name="string_key" type="String"> - </argument> - <argument index="1" name="public_only" type="bool" default="false"> - </argument> + <return type="int" enum="Error" /> + <argument index="0" name="string_key" type="String" /> + <argument index="1" name="public_only" type="bool" default="false" /> <description> Loads a key from the given [code]string[/code]. If [code]public_only[/code] is [code]true[/code], only the public key will be loaded. </description> </method> <method name="save"> - <return type="int" enum="Error"> - </return> - <argument index="0" name="path" type="String"> - </argument> - <argument index="1" name="public_only" type="bool" default="false"> - </argument> + <return type="int" enum="Error" /> + <argument index="0" name="path" type="String" /> + <argument index="1" name="public_only" type="bool" default="false" /> <description> Saves a key to the given [code]path[/code]. If [code]public_only[/code] is [code]true[/code], only the public key will be saved. [b]Note[/b]: [code]path[/code] should be a "*.pub" file if [code]public_only[/code] is [code]true[/code], a "*.key" file otherwise. </description> </method> <method name="save_to_string"> - <return type="String"> - </return> - <argument index="0" name="public_only" type="bool" default="false"> - </argument> + <return type="String" /> + <argument index="0" name="public_only" type="bool" default="false" /> <description> Returns a string containing the key in PEM format. If [code]public_only[/code] is [code]true[/code], only the public key will be included. </description> diff --git a/doc/classes/Curve.xml b/doc/classes/Curve.xml index e47c420a3b..2c337c32db 100644 --- a/doc/classes/Curve.xml +++ b/doc/classes/Curve.xml @@ -10,184 +10,140 @@ </tutorials> <methods> <method name="add_point"> - <return type="int"> - </return> - <argument index="0" name="position" type="Vector2"> - </argument> - <argument index="1" name="left_tangent" type="float" default="0"> - </argument> - <argument index="2" name="right_tangent" type="float" default="0"> - </argument> - <argument index="3" name="left_mode" type="int" enum="Curve.TangentMode" default="0"> - </argument> - <argument index="4" name="right_mode" type="int" enum="Curve.TangentMode" default="0"> - </argument> + <return type="int" /> + <argument index="0" name="position" type="Vector2" /> + <argument index="1" name="left_tangent" type="float" default="0" /> + <argument index="2" name="right_tangent" type="float" default="0" /> + <argument index="3" name="left_mode" type="int" enum="Curve.TangentMode" default="0" /> + <argument index="4" name="right_mode" type="int" enum="Curve.TangentMode" default="0" /> <description> Adds a point to the curve. For each side, if the [code]*_mode[/code] is [constant TANGENT_LINEAR], the [code]*_tangent[/code] angle (in degrees) uses the slope of the curve halfway to the adjacent point. Allows custom assignments to the [code]*_tangent[/code] angle if [code]*_mode[/code] is set to [constant TANGENT_FREE]. </description> </method> <method name="bake"> - <return type="void"> - </return> + <return type="void" /> <description> Recomputes the baked cache of points for the curve. </description> </method> <method name="clean_dupes"> - <return type="void"> - </return> + <return type="void" /> <description> Removes points that are closer than [code]CMP_EPSILON[/code] (0.00001) units to their neighbor on the curve. </description> </method> <method name="clear_points"> - <return type="void"> - </return> + <return type="void" /> <description> Removes all points from the curve. </description> </method> <method name="get_point_count" qualifiers="const"> - <return type="int"> - </return> + <return type="int" /> <description> Returns the number of points describing the curve. </description> </method> <method name="get_point_left_mode" qualifiers="const"> - <return type="int" enum="Curve.TangentMode"> - </return> - <argument index="0" name="index" type="int"> - </argument> + <return type="int" enum="Curve.TangentMode" /> + <argument index="0" name="index" type="int" /> <description> Returns the left [enum TangentMode] for the point at [code]index[/code]. </description> </method> <method name="get_point_left_tangent" qualifiers="const"> - <return type="float"> - </return> - <argument index="0" name="index" type="int"> - </argument> + <return type="float" /> + <argument index="0" name="index" type="int" /> <description> Returns the left tangent angle (in degrees) for the point at [code]index[/code]. </description> </method> <method name="get_point_position" qualifiers="const"> - <return type="Vector2"> - </return> - <argument index="0" name="index" type="int"> - </argument> + <return type="Vector2" /> + <argument index="0" name="index" type="int" /> <description> Returns the curve coordinates for the point at [code]index[/code]. </description> </method> <method name="get_point_right_mode" qualifiers="const"> - <return type="int" enum="Curve.TangentMode"> - </return> - <argument index="0" name="index" type="int"> - </argument> + <return type="int" enum="Curve.TangentMode" /> + <argument index="0" name="index" type="int" /> <description> Returns the right [enum TangentMode] for the point at [code]index[/code]. </description> </method> <method name="get_point_right_tangent" qualifiers="const"> - <return type="float"> - </return> - <argument index="0" name="index" type="int"> - </argument> + <return type="float" /> + <argument index="0" name="index" type="int" /> <description> Returns the right tangent angle (in degrees) for the point at [code]index[/code]. </description> </method> <method name="interpolate" qualifiers="const"> - <return type="float"> - </return> - <argument index="0" name="offset" type="float"> - </argument> + <return type="float" /> + <argument index="0" name="offset" type="float" /> <description> Returns the Y value for the point that would exist at the X position [code]offset[/code] along the curve. </description> </method> <method name="interpolate_baked" qualifiers="const"> - <return type="float"> - </return> - <argument index="0" name="offset" type="float"> - </argument> + <return type="float" /> + <argument index="0" name="offset" type="float" /> <description> Returns the Y value for the point that would exist at the X position [code]offset[/code] along the curve using the baked cache. Bakes the curve's points if not already baked. </description> </method> <method name="remove_point"> - <return type="void"> - </return> - <argument index="0" name="index" type="int"> - </argument> + <return type="void" /> + <argument index="0" name="index" type="int" /> <description> Removes the point at [code]index[/code] from the curve. </description> </method> <method name="set_point_left_mode"> - <return type="void"> - </return> - <argument index="0" name="index" type="int"> - </argument> - <argument index="1" name="mode" type="int" enum="Curve.TangentMode"> - </argument> + <return type="void" /> + <argument index="0" name="index" type="int" /> + <argument index="1" name="mode" type="int" enum="Curve.TangentMode" /> <description> Sets the left [enum TangentMode] for the point at [code]index[/code] to [code]mode[/code]. </description> </method> <method name="set_point_left_tangent"> - <return type="void"> - </return> - <argument index="0" name="index" type="int"> - </argument> - <argument index="1" name="tangent" type="float"> - </argument> + <return type="void" /> + <argument index="0" name="index" type="int" /> + <argument index="1" name="tangent" type="float" /> <description> Sets the left tangent angle for the point at [code]index[/code] to [code]tangent[/code]. </description> </method> <method name="set_point_offset"> - <return type="int"> - </return> - <argument index="0" name="index" type="int"> - </argument> - <argument index="1" name="offset" type="float"> - </argument> + <return type="int" /> + <argument index="0" name="index" type="int" /> + <argument index="1" name="offset" type="float" /> <description> Sets the offset from [code]0.5[/code]. </description> </method> <method name="set_point_right_mode"> - <return type="void"> - </return> - <argument index="0" name="index" type="int"> - </argument> - <argument index="1" name="mode" type="int" enum="Curve.TangentMode"> - </argument> + <return type="void" /> + <argument index="0" name="index" type="int" /> + <argument index="1" name="mode" type="int" enum="Curve.TangentMode" /> <description> Sets the right [enum TangentMode] for the point at [code]index[/code] to [code]mode[/code]. </description> </method> <method name="set_point_right_tangent"> - <return type="void"> - </return> - <argument index="0" name="index" type="int"> - </argument> - <argument index="1" name="tangent" type="float"> - </argument> + <return type="void" /> + <argument index="0" name="index" type="int" /> + <argument index="1" name="tangent" type="float" /> <description> Sets the right tangent angle for the point at [code]index[/code] to [code]tangent[/code]. </description> </method> <method name="set_point_value"> - <return type="void"> - </return> - <argument index="0" name="index" type="int"> - </argument> - <argument index="1" name="y" type="float"> - </argument> + <return type="void" /> + <argument index="0" name="index" type="int" /> + <argument index="1" name="y" type="float" /> <description> Assigns the vertical position [code]y[/code] to the point at [code]index[/code]. </description> diff --git a/doc/classes/Curve2D.xml b/doc/classes/Curve2D.xml index c9fcbd2892..c02b0f7ead 100644 --- a/doc/classes/Curve2D.xml +++ b/doc/classes/Curve2D.xml @@ -11,115 +11,90 @@ </tutorials> <methods> <method name="add_point"> - <return type="void"> - </return> - <argument index="0" name="position" type="Vector2"> - </argument> - <argument index="1" name="in" type="Vector2" default="Vector2(0, 0)"> - </argument> - <argument index="2" name="out" type="Vector2" default="Vector2(0, 0)"> - </argument> - <argument index="3" name="at_position" type="int" default="-1"> - </argument> + <return type="void" /> + <argument index="0" name="position" type="Vector2" /> + <argument index="1" name="in" type="Vector2" default="Vector2(0, 0)" /> + <argument index="2" name="out" type="Vector2" default="Vector2(0, 0)" /> + <argument index="3" name="at_position" type="int" default="-1" /> <description> Adds a point to a curve at [code]position[/code], with control points [code]in[/code] and [code]out[/code]. If [code]at_position[/code] is given, the point is inserted before the point number [code]at_position[/code], moving that point (and every point after) after the inserted point. If [code]at_position[/code] is not given, or is an illegal value ([code]at_position <0[/code] or [code]at_position >= [method get_point_count][/code]), the point will be appended at the end of the point list. </description> </method> <method name="clear_points"> - <return type="void"> - </return> + <return type="void" /> <description> Removes all points from the curve. </description> </method> <method name="get_baked_length" qualifiers="const"> - <return type="float"> - </return> + <return type="float" /> <description> Returns the total length of the curve, based on the cached points. Given enough density (see [member bake_interval]), it should be approximate enough. </description> </method> <method name="get_baked_points" qualifiers="const"> - <return type="PackedVector2Array"> - </return> + <return type="PackedVector2Array" /> <description> Returns the cache of points as a [PackedVector2Array]. </description> </method> <method name="get_closest_offset" qualifiers="const"> - <return type="float"> - </return> - <argument index="0" name="to_point" type="Vector2"> - </argument> + <return type="float" /> + <argument index="0" name="to_point" type="Vector2" /> <description> Returns the closest offset to [code]to_point[/code]. This offset is meant to be used in [method interpolate_baked]. [code]to_point[/code] must be in this curve's local space. </description> </method> <method name="get_closest_point" qualifiers="const"> - <return type="Vector2"> - </return> - <argument index="0" name="to_point" type="Vector2"> - </argument> + <return type="Vector2" /> + <argument index="0" name="to_point" type="Vector2" /> <description> Returns the closest baked point (in curve's local space) to [code]to_point[/code]. [code]to_point[/code] must be in this curve's local space. </description> </method> <method name="get_point_count" qualifiers="const"> - <return type="int"> - </return> + <return type="int" /> <description> Returns the number of points describing the curve. </description> </method> <method name="get_point_in" qualifiers="const"> - <return type="Vector2"> - </return> - <argument index="0" name="idx" type="int"> - </argument> + <return type="Vector2" /> + <argument index="0" name="idx" type="int" /> <description> Returns the position of the control point leading to the vertex [code]idx[/code]. The returned position is relative to the vertex [code]idx[/code]. If the index is out of bounds, the function sends an error to the console, and returns [code](0, 0)[/code]. </description> </method> <method name="get_point_out" qualifiers="const"> - <return type="Vector2"> - </return> - <argument index="0" name="idx" type="int"> - </argument> + <return type="Vector2" /> + <argument index="0" name="idx" type="int" /> <description> Returns the position of the control point leading out of the vertex [code]idx[/code]. The returned position is relative to the vertex [code]idx[/code]. If the index is out of bounds, the function sends an error to the console, and returns [code](0, 0)[/code]. </description> </method> <method name="get_point_position" qualifiers="const"> - <return type="Vector2"> - </return> - <argument index="0" name="idx" type="int"> - </argument> + <return type="Vector2" /> + <argument index="0" name="idx" type="int" /> <description> Returns the position of the vertex [code]idx[/code]. If the index is out of bounds, the function sends an error to the console, and returns [code](0, 0)[/code]. </description> </method> <method name="interpolate" qualifiers="const"> - <return type="Vector2"> - </return> - <argument index="0" name="idx" type="int"> - </argument> - <argument index="1" name="t" type="float"> - </argument> + <return type="Vector2" /> + <argument index="0" name="idx" type="int" /> + <argument index="1" name="t" type="float" /> <description> Returns the position between the vertex [code]idx[/code] and the vertex [code]idx + 1[/code], where [code]t[/code] controls if the point is the first vertex ([code]t = 0.0[/code]), the last vertex ([code]t = 1.0[/code]), or in between. Values of [code]t[/code] outside the range ([code]0.0 >= t <=1[/code]) give strange, but predictable results. If [code]idx[/code] is out of bounds it is truncated to the first or last vertex, and [code]t[/code] is ignored. If the curve has no points, the function sends an error to the console, and returns [code](0, 0)[/code]. </description> </method> <method name="interpolate_baked" qualifiers="const"> - <return type="Vector2"> - </return> - <argument index="0" name="offset" type="float"> - </argument> - <argument index="1" name="cubic" type="bool" default="false"> - </argument> + <return type="Vector2" /> + <argument index="0" name="offset" type="float" /> + <argument index="1" name="cubic" type="bool" default="false" /> <description> Returns a point within the curve at position [code]offset[/code], where [code]offset[/code] is measured as a pixel distance along the curve. To do that, it finds the two cached points where the [code]offset[/code] lies between, then interpolates the values. This interpolation is cubic if [code]cubic[/code] is set to [code]true[/code], or linear if set to [code]false[/code]. @@ -127,63 +102,47 @@ </description> </method> <method name="interpolatef" qualifiers="const"> - <return type="Vector2"> - </return> - <argument index="0" name="fofs" type="float"> - </argument> + <return type="Vector2" /> + <argument index="0" name="fofs" type="float" /> <description> Returns the position at the vertex [code]fofs[/code]. It calls [method interpolate] using the integer part of [code]fofs[/code] as [code]idx[/code], and its fractional part as [code]t[/code]. </description> </method> <method name="remove_point"> - <return type="void"> - </return> - <argument index="0" name="idx" type="int"> - </argument> + <return type="void" /> + <argument index="0" name="idx" type="int" /> <description> Deletes the point [code]idx[/code] from the curve. Sends an error to the console if [code]idx[/code] is out of bounds. </description> </method> <method name="set_point_in"> - <return type="void"> - </return> - <argument index="0" name="idx" type="int"> - </argument> - <argument index="1" name="position" type="Vector2"> - </argument> + <return type="void" /> + <argument index="0" name="idx" type="int" /> + <argument index="1" name="position" type="Vector2" /> <description> Sets the position of the control point leading to the vertex [code]idx[/code]. If the index is out of bounds, the function sends an error to the console. The position is relative to the vertex. </description> </method> <method name="set_point_out"> - <return type="void"> - </return> - <argument index="0" name="idx" type="int"> - </argument> - <argument index="1" name="position" type="Vector2"> - </argument> + <return type="void" /> + <argument index="0" name="idx" type="int" /> + <argument index="1" name="position" type="Vector2" /> <description> Sets the position of the control point leading out of the vertex [code]idx[/code]. If the index is out of bounds, the function sends an error to the console. The position is relative to the vertex. </description> </method> <method name="set_point_position"> - <return type="void"> - </return> - <argument index="0" name="idx" type="int"> - </argument> - <argument index="1" name="position" type="Vector2"> - </argument> + <return type="void" /> + <argument index="0" name="idx" type="int" /> + <argument index="1" name="position" type="Vector2" /> <description> Sets the position for the vertex [code]idx[/code]. If the index is out of bounds, the function sends an error to the console. </description> </method> <method name="tessellate" qualifiers="const"> - <return type="PackedVector2Array"> - </return> - <argument index="0" name="max_stages" type="int" default="5"> - </argument> - <argument index="1" name="tolerance_degrees" type="float" default="4"> - </argument> + <return type="PackedVector2Array" /> + <argument index="0" name="max_stages" type="int" default="5" /> + <argument index="1" name="tolerance_degrees" type="float" default="4" /> <description> Returns a list of points along the curve, with a curvature controlled point density. That is, the curvier parts will have more points than the straighter parts. This approximation makes straight segments between each point, then subdivides those segments until the resulting shape is similar enough. diff --git a/doc/classes/Curve3D.xml b/doc/classes/Curve3D.xml index fdf96b4262..5839ccba02 100644 --- a/doc/classes/Curve3D.xml +++ b/doc/classes/Curve3D.xml @@ -11,139 +11,110 @@ </tutorials> <methods> <method name="add_point"> - <return type="void"> - </return> - <argument index="0" name="position" type="Vector3"> - </argument> - <argument index="1" name="in" type="Vector3" default="Vector3(0, 0, 0)"> - </argument> - <argument index="2" name="out" type="Vector3" default="Vector3(0, 0, 0)"> - </argument> - <argument index="3" name="at_position" type="int" default="-1"> - </argument> + <return type="void" /> + <argument index="0" name="position" type="Vector3" /> + <argument index="1" name="in" type="Vector3" default="Vector3(0, 0, 0)" /> + <argument index="2" name="out" type="Vector3" default="Vector3(0, 0, 0)" /> + <argument index="3" name="at_position" type="int" default="-1" /> <description> Adds a point to a curve at [code]position[/code], with control points [code]in[/code] and [code]out[/code]. If [code]at_position[/code] is given, the point is inserted before the point number [code]at_position[/code], moving that point (and every point after) after the inserted point. If [code]at_position[/code] is not given, or is an illegal value ([code]at_position <0[/code] or [code]at_position >= [method get_point_count][/code]), the point will be appended at the end of the point list. </description> </method> <method name="clear_points"> - <return type="void"> - </return> + <return type="void" /> <description> Removes all points from the curve. </description> </method> <method name="get_baked_length" qualifiers="const"> - <return type="float"> - </return> + <return type="float" /> <description> Returns the total length of the curve, based on the cached points. Given enough density (see [member bake_interval]), it should be approximate enough. </description> </method> <method name="get_baked_points" qualifiers="const"> - <return type="PackedVector3Array"> - </return> + <return type="PackedVector3Array" /> <description> Returns the cache of points as a [PackedVector3Array]. </description> </method> <method name="get_baked_tilts" qualifiers="const"> - <return type="PackedFloat32Array"> - </return> + <return type="PackedFloat32Array" /> <description> Returns the cache of tilts as a [PackedFloat32Array]. </description> </method> <method name="get_baked_up_vectors" qualifiers="const"> - <return type="PackedVector3Array"> - </return> + <return type="PackedVector3Array" /> <description> Returns the cache of up vectors as a [PackedVector3Array]. If [member up_vector_enabled] is [code]false[/code], the cache will be empty. </description> </method> <method name="get_closest_offset" qualifiers="const"> - <return type="float"> - </return> - <argument index="0" name="to_point" type="Vector3"> - </argument> + <return type="float" /> + <argument index="0" name="to_point" type="Vector3" /> <description> Returns the closest offset to [code]to_point[/code]. This offset is meant to be used in [method interpolate_baked] or [method interpolate_baked_up_vector]. [code]to_point[/code] must be in this curve's local space. </description> </method> <method name="get_closest_point" qualifiers="const"> - <return type="Vector3"> - </return> - <argument index="0" name="to_point" type="Vector3"> - </argument> + <return type="Vector3" /> + <argument index="0" name="to_point" type="Vector3" /> <description> Returns the closest baked point (in curve's local space) to [code]to_point[/code]. [code]to_point[/code] must be in this curve's local space. </description> </method> <method name="get_point_count" qualifiers="const"> - <return type="int"> - </return> + <return type="int" /> <description> Returns the number of points describing the curve. </description> </method> <method name="get_point_in" qualifiers="const"> - <return type="Vector3"> - </return> - <argument index="0" name="idx" type="int"> - </argument> + <return type="Vector3" /> + <argument index="0" name="idx" type="int" /> <description> Returns the position of the control point leading to the vertex [code]idx[/code]. The returned position is relative to the vertex [code]idx[/code]. If the index is out of bounds, the function sends an error to the console, and returns [code](0, 0, 0)[/code]. </description> </method> <method name="get_point_out" qualifiers="const"> - <return type="Vector3"> - </return> - <argument index="0" name="idx" type="int"> - </argument> + <return type="Vector3" /> + <argument index="0" name="idx" type="int" /> <description> Returns the position of the control point leading out of the vertex [code]idx[/code]. The returned position is relative to the vertex [code]idx[/code]. If the index is out of bounds, the function sends an error to the console, and returns [code](0, 0, 0)[/code]. </description> </method> <method name="get_point_position" qualifiers="const"> - <return type="Vector3"> - </return> - <argument index="0" name="idx" type="int"> - </argument> + <return type="Vector3" /> + <argument index="0" name="idx" type="int" /> <description> Returns the position of the vertex [code]idx[/code]. If the index is out of bounds, the function sends an error to the console, and returns [code](0, 0, 0)[/code]. </description> </method> <method name="get_point_tilt" qualifiers="const"> - <return type="float"> - </return> - <argument index="0" name="idx" type="int"> - </argument> + <return type="float" /> + <argument index="0" name="idx" type="int" /> <description> Returns the tilt angle in radians for the point [code]idx[/code]. If the index is out of bounds, the function sends an error to the console, and returns [code]0[/code]. </description> </method> <method name="interpolate" qualifiers="const"> - <return type="Vector3"> - </return> - <argument index="0" name="idx" type="int"> - </argument> - <argument index="1" name="t" type="float"> - </argument> + <return type="Vector3" /> + <argument index="0" name="idx" type="int" /> + <argument index="1" name="t" type="float" /> <description> Returns the position between the vertex [code]idx[/code] and the vertex [code]idx + 1[/code], where [code]t[/code] controls if the point is the first vertex ([code]t = 0.0[/code]), the last vertex ([code]t = 1.0[/code]), or in between. Values of [code]t[/code] outside the range ([code]0.0 >= t <=1[/code]) give strange, but predictable results. If [code]idx[/code] is out of bounds it is truncated to the first or last vertex, and [code]t[/code] is ignored. If the curve has no points, the function sends an error to the console, and returns [code](0, 0, 0)[/code]. </description> </method> <method name="interpolate_baked" qualifiers="const"> - <return type="Vector3"> - </return> - <argument index="0" name="offset" type="float"> - </argument> - <argument index="1" name="cubic" type="bool" default="false"> - </argument> + <return type="Vector3" /> + <argument index="0" name="offset" type="float" /> + <argument index="1" name="cubic" type="bool" default="false" /> <description> Returns a point within the curve at position [code]offset[/code], where [code]offset[/code] is measured as a distance in 3D units along the curve. To do that, it finds the two cached points where the [code]offset[/code] lies between, then interpolates the values. This interpolation is cubic if [code]cubic[/code] is set to [code]true[/code], or linear if set to [code]false[/code]. @@ -151,12 +122,9 @@ </description> </method> <method name="interpolate_baked_up_vector" qualifiers="const"> - <return type="Vector3"> - </return> - <argument index="0" name="offset" type="float"> - </argument> - <argument index="1" name="apply_tilt" type="bool" default="false"> - </argument> + <return type="Vector3" /> + <argument index="0" name="offset" type="float" /> + <argument index="1" name="apply_tilt" type="bool" default="false" /> <description> Returns an up vector within the curve at position [code]offset[/code], where [code]offset[/code] is measured as a distance in 3D units along the curve. To do that, it finds the two cached up vectors where the [code]offset[/code] lies between, then interpolates the values. If [code]apply_tilt[/code] is [code]true[/code], an interpolated tilt is applied to the interpolated up vector. @@ -164,75 +132,56 @@ </description> </method> <method name="interpolatef" qualifiers="const"> - <return type="Vector3"> - </return> - <argument index="0" name="fofs" type="float"> - </argument> + <return type="Vector3" /> + <argument index="0" name="fofs" type="float" /> <description> Returns the position at the vertex [code]fofs[/code]. It calls [method interpolate] using the integer part of [code]fofs[/code] as [code]idx[/code], and its fractional part as [code]t[/code]. </description> </method> <method name="remove_point"> - <return type="void"> - </return> - <argument index="0" name="idx" type="int"> - </argument> + <return type="void" /> + <argument index="0" name="idx" type="int" /> <description> Deletes the point [code]idx[/code] from the curve. Sends an error to the console if [code]idx[/code] is out of bounds. </description> </method> <method name="set_point_in"> - <return type="void"> - </return> - <argument index="0" name="idx" type="int"> - </argument> - <argument index="1" name="position" type="Vector3"> - </argument> + <return type="void" /> + <argument index="0" name="idx" type="int" /> + <argument index="1" name="position" type="Vector3" /> <description> Sets the position of the control point leading to the vertex [code]idx[/code]. If the index is out of bounds, the function sends an error to the console. The position is relative to the vertex. </description> </method> <method name="set_point_out"> - <return type="void"> - </return> - <argument index="0" name="idx" type="int"> - </argument> - <argument index="1" name="position" type="Vector3"> - </argument> + <return type="void" /> + <argument index="0" name="idx" type="int" /> + <argument index="1" name="position" type="Vector3" /> <description> Sets the position of the control point leading out of the vertex [code]idx[/code]. If the index is out of bounds, the function sends an error to the console. The position is relative to the vertex. </description> </method> <method name="set_point_position"> - <return type="void"> - </return> - <argument index="0" name="idx" type="int"> - </argument> - <argument index="1" name="position" type="Vector3"> - </argument> + <return type="void" /> + <argument index="0" name="idx" type="int" /> + <argument index="1" name="position" type="Vector3" /> <description> Sets the position for the vertex [code]idx[/code]. If the index is out of bounds, the function sends an error to the console. </description> </method> <method name="set_point_tilt"> - <return type="void"> - </return> - <argument index="0" name="idx" type="int"> - </argument> - <argument index="1" name="tilt" type="float"> - </argument> + <return type="void" /> + <argument index="0" name="idx" type="int" /> + <argument index="1" name="tilt" type="float" /> <description> Sets the tilt angle in radians for the point [code]idx[/code]. If the index is out of bounds, the function sends an error to the console. The tilt controls the rotation along the look-at axis an object traveling the path would have. In the case of a curve controlling a [PathFollow3D], this tilt is an offset over the natural tilt the [PathFollow3D] calculates. </description> </method> <method name="tessellate" qualifiers="const"> - <return type="PackedVector3Array"> - </return> - <argument index="0" name="max_stages" type="int" default="5"> - </argument> - <argument index="1" name="tolerance_degrees" type="float" default="4"> - </argument> + <return type="PackedVector3Array" /> + <argument index="0" name="max_stages" type="int" default="5" /> + <argument index="1" name="tolerance_degrees" type="float" default="4" /> <description> Returns a list of points along the curve, with a curvature controlled point density. That is, the curvier parts will have more points than the straighter parts. This approximation makes straight segments between each point, then subdivides those segments until the resulting shape is similar enough. diff --git a/doc/classes/Curve3Texture.xml b/doc/classes/CurveXYZTexture.xml index 1b352dff0d..9afeb58060 100644 --- a/doc/classes/Curve3Texture.xml +++ b/doc/classes/CurveXYZTexture.xml @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="UTF-8" ?> -<class name="Curve3Texture" inherits="Texture2D" version="4.0"> +<class name="CurveXYZTexture" inherits="Texture2D" version="4.0"> <brief_description> </brief_description> <description> diff --git a/doc/classes/DTLSServer.xml b/doc/classes/DTLSServer.xml index 28d68d309f..627a7a65a5 100644 --- a/doc/classes/DTLSServer.xml +++ b/doc/classes/DTLSServer.xml @@ -147,23 +147,17 @@ </tutorials> <methods> <method name="setup"> - <return type="int" enum="Error"> - </return> - <argument index="0" name="key" type="CryptoKey"> - </argument> - <argument index="1" name="certificate" type="X509Certificate"> - </argument> - <argument index="2" name="chain" type="X509Certificate" default="null"> - </argument> + <return type="int" enum="Error" /> + <argument index="0" name="key" type="CryptoKey" /> + <argument index="1" name="certificate" type="X509Certificate" /> + <argument index="2" name="chain" type="X509Certificate" default="null" /> <description> Setup the DTLS server to use the given [code]private_key[/code] and provide the given [code]certificate[/code] to clients. You can pass the optional [code]chain[/code] parameter to provide additional CA chain information along with the certificate. </description> </method> <method name="take_connection"> - <return type="PacketPeerDTLS"> - </return> - <argument index="0" name="udp_peer" type="PacketPeerUDP"> - </argument> + <return type="PacketPeerDTLS" /> + <argument index="0" name="udp_peer" type="PacketPeerUDP" /> <description> Try to initiate the DTLS handshake with the given [code]udp_peer[/code] which must be already connected (see [method PacketPeerUDP.connect_to_host]). [b]Note[/b]: You must check that the state of the return PacketPeerUDP is [constant PacketPeerDTLS.STATUS_HANDSHAKING], as it is normal that 50% of the new connections will be invalid due to cookie exchange. diff --git a/doc/classes/Decal.xml b/doc/classes/Decal.xml index e84cea7c30..e993fc6198 100644 --- a/doc/classes/Decal.xml +++ b/doc/classes/Decal.xml @@ -12,10 +12,8 @@ </tutorials> <methods> <method name="get_texture" qualifiers="const"> - <return type="Texture2D"> - </return> - <argument index="0" name="type" type="int" enum="Decal.DecalTexture"> - </argument> + <return type="Texture2D" /> + <argument index="0" name="type" type="int" enum="Decal.DecalTexture" /> <description> Returns the [Texture2D] associated with the specified [enum DecalTexture]. This is a convenience method, in most cases you should access the texture directly. For example, instead of [code]albedo_tex = $Decal.get_texture(Decal.TEXTURE_ALBEDO)[/code], use [code]albedo_tex = $Decal.texture_albedo[/code]. @@ -35,12 +33,9 @@ </description> </method> <method name="set_texture"> - <return type="void"> - </return> - <argument index="0" name="type" type="int" enum="Decal.DecalTexture"> - </argument> - <argument index="1" name="texture" type="Texture2D"> - </argument> + <return type="void" /> + <argument index="0" name="type" type="int" enum="Decal.DecalTexture" /> + <argument index="1" name="texture" type="Texture2D" /> <description> Sets the [Texture2D] associated with the specified [enum DecalTexture]. This is a convenience method, in most cases you should access the texture directly. For example, instead of [code]$Decal.set_texture(Decal.TEXTURE_ALBEDO, albedo_tex)[/code], use [code]$Decal.texture_albedo = albedo_tex[/code]. diff --git a/doc/classes/Dictionary.xml b/doc/classes/Dictionary.xml index 16c4348994..59088f33fd 100644 --- a/doc/classes/Dictionary.xml +++ b/doc/classes/Dictionary.xml @@ -184,62 +184,49 @@ </tutorials> <methods> <method name="Dictionary" qualifiers="constructor"> - <return type="Dictionary"> - </return> + <return type="Dictionary" /> <description> Constructs an empty [Dictionary]. </description> </method> <method name="Dictionary" qualifiers="constructor"> - <return type="Dictionary"> - </return> - <argument index="0" name="from" type="Dictionary"> - </argument> + <return type="Dictionary" /> + <argument index="0" name="from" type="Dictionary" /> <description> Constructs a [Dictionary] as a copy of the given [Dictionary]. </description> </method> <method name="clear"> - <return type="void"> - </return> + <return type="void" /> <description> Clear the dictionary, removing all key/value pairs. </description> </method> <method name="duplicate" qualifiers="const"> - <return type="Dictionary"> - </return> - <argument index="0" name="deep" type="bool" default="false"> - </argument> + <return type="Dictionary" /> + <argument index="0" name="deep" type="bool" default="false" /> <description> Creates a copy of the dictionary, and returns it. The [code]deep[/code] parameter causes inner dictionaries and arrays to be copied recursively, but does not apply to objects. </description> </method> <method name="erase"> - <return type="bool"> - </return> - <argument index="0" name="key" type="Variant"> - </argument> + <return type="bool" /> + <argument index="0" name="key" type="Variant" /> <description> Erase a dictionary key/value pair by key. Returns [code]true[/code] if the given key was present in the dictionary, [code]false[/code] otherwise. Does not erase elements while iterating over the dictionary. </description> </method> <method name="get" qualifiers="const"> - <return type="Variant"> - </return> - <argument index="0" name="key" type="Variant"> - </argument> - <argument index="1" name="default" type="Variant" default="null"> - </argument> + <return type="Variant" /> + <argument index="0" name="key" type="Variant" /> + <argument index="1" name="default" type="Variant" default="null" /> <description> Returns the current value for the specified key in the [Dictionary]. If the key does not exist, the method returns the value of the optional default argument, or [code]null[/code] if it is omitted. </description> </method> <method name="has" qualifiers="const"> - <return type="bool"> - </return> - <argument index="0" name="key" type="Variant"> - </argument> + <return type="bool" /> + <argument index="0" name="key" type="Variant" /> <description> Returns [code]true[/code] if the dictionary has a given key. [b]Note:[/b] This is equivalent to using the [code]in[/code] operator as follows: @@ -261,17 +248,14 @@ </description> </method> <method name="has_all" qualifiers="const"> - <return type="bool"> - </return> - <argument index="0" name="keys" type="Array"> - </argument> + <return type="bool" /> + <argument index="0" name="keys" type="Array" /> <description> Returns [code]true[/code] if the dictionary has all the keys in the given array. </description> </method> <method name="hash" qualifiers="const"> - <return type="int"> - </return> + <return type="int" /> <description> Returns a hashed integer value representing the dictionary contents. This can be used to compare dictionaries by value: [codeblocks] @@ -293,53 +277,43 @@ </description> </method> <method name="is_empty" qualifiers="const"> - <return type="bool"> - </return> + <return type="bool" /> <description> Returns [code]true[/code] if the dictionary is empty. </description> </method> <method name="keys" qualifiers="const"> - <return type="Array"> - </return> + <return type="Array" /> <description> Returns the list of keys in the [Dictionary]. </description> </method> <method name="operator !=" qualifiers="operator"> - <return type="bool"> - </return> - <argument index="0" name="right" type="Dictionary"> - </argument> + <return type="bool" /> + <argument index="0" name="right" type="Dictionary" /> <description> </description> </method> <method name="operator ==" qualifiers="operator"> - <return type="bool"> - </return> - <argument index="0" name="right" type="Dictionary"> - </argument> + <return type="bool" /> + <argument index="0" name="right" type="Dictionary" /> <description> </description> </method> <method name="operator []" qualifiers="operator"> - <return type="Variant"> - </return> - <argument index="0" name="key" type="Variant"> - </argument> + <return type="Variant" /> + <argument index="0" name="key" type="Variant" /> <description> </description> </method> <method name="size" qualifiers="const"> - <return type="int"> - </return> + <return type="int" /> <description> Returns the number of keys in the dictionary. </description> </method> <method name="values" qualifiers="const"> - <return type="Array"> - </return> + <return type="Array" /> <description> Returns the list of values in the [Dictionary]. </description> diff --git a/doc/classes/Directory.xml b/doc/classes/Directory.xml index dae8d83f0c..919960cc9f 100644 --- a/doc/classes/Directory.xml +++ b/doc/classes/Directory.xml @@ -58,166 +58,134 @@ </tutorials> <methods> <method name="change_dir"> - <return type="int" enum="Error"> - </return> - <argument index="0" name="todir" type="String"> - </argument> + <return type="int" enum="Error" /> + <argument index="0" name="todir" type="String" /> <description> Changes the currently opened directory to the one passed as an argument. The argument can be relative to the current directory (e.g. [code]newdir[/code] or [code]../newdir[/code]), or an absolute path (e.g. [code]/tmp/newdir[/code] or [code]res://somedir/newdir[/code]). Returns one of the [enum Error] code constants ([code]OK[/code] on success). </description> </method> <method name="copy"> - <return type="int" enum="Error"> - </return> - <argument index="0" name="from" type="String"> - </argument> - <argument index="1" name="to" type="String"> - </argument> + <return type="int" enum="Error" /> + <argument index="0" name="from" type="String" /> + <argument index="1" name="to" type="String" /> <description> Copies the [code]from[/code] file to the [code]to[/code] destination. Both arguments should be paths to files, either relative or absolute. If the destination file exists and is not access-protected, it will be overwritten. Returns one of the [enum Error] code constants ([code]OK[/code] on success). </description> </method> <method name="current_is_dir" qualifiers="const"> - <return type="bool"> - </return> + <return type="bool" /> <description> Returns whether the current item processed with the last [method get_next] call is a directory ([code].[/code] and [code]..[/code] are considered directories). </description> </method> <method name="dir_exists"> - <return type="bool"> - </return> - <argument index="0" name="path" type="String"> - </argument> + <return type="bool" /> + <argument 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. If the [Directory] is not open, the path is relative to [code]res://[/code]. </description> </method> <method name="file_exists"> - <return type="bool"> - </return> - <argument index="0" name="path" type="String"> - </argument> + <return type="bool" /> + <argument index="0" name="path" type="String" /> <description> Returns whether the target file exists. The argument can be relative to the current directory, or an absolute path. If the [Directory] is not open, the path is relative to [code]res://[/code]. </description> </method> <method name="get_current_dir"> - <return type="String"> - </return> + <return type="String" /> <description> Returns the absolute path to the currently opened directory (e.g. [code]res://folder[/code] or [code]C:\tmp\folder[/code]). </description> </method> <method name="get_current_drive"> - <return type="int"> - </return> + <return type="int" /> <description> Returns the currently opened directory's drive index. See [method get_drive] to convert returned index to the name of the drive. </description> </method> <method name="get_drive"> - <return type="String"> - </return> - <argument index="0" name="idx" type="int"> - </argument> + <return type="String" /> + <argument index="0" name="idx" type="int" /> <description> On Windows, returns the name of the drive (partition) passed as an argument (e.g. [code]C:[/code]). On other platforms, or if the requested drive does not exist, the method returns an empty String. </description> </method> <method name="get_drive_count"> - <return type="int"> - </return> + <return type="int" /> <description> On Windows, returns the number of drives (partitions) mounted on the current filesystem. On other platforms, the method returns 0. </description> </method> <method name="get_next"> - <return type="String"> - </return> + <return type="String" /> <description> Returns the next element (file or directory) in the current directory (including [code].[/code] and [code]..[/code], unless [code]skip_navigational[/code] was given to [method list_dir_begin]). The name of the file or directory is returned (and not its full path). Once the stream has been fully processed, the method returns an empty String and closes the stream automatically (i.e. [method list_dir_end] would not be mandatory in such a case). </description> </method> <method name="get_space_left"> - <return type="int"> - </return> + <return type="int" /> <description> On UNIX desktop systems, returns the available space on the current directory's disk. On other platforms, this information is not available and the method returns 0 or -1. </description> </method> <method name="list_dir_begin"> - <return type="int" enum="Error"> - </return> - <argument index="0" name="show_navigational" type="bool" default="false"> - </argument> - <argument index="1" name="show_hidden" type="bool" default="false"> - </argument> - <description> - Initializes the stream used to list all files and directories using the [method get_next] function, closing the current opened stream if needed. Once the stream has been processed, it should typically be closed with [method list_dir_end]. + <return type="int" enum="Error" /> + <argument index="0" name="show_navigational" type="bool" default="false" /> + <argument index="1" name="show_hidden" type="bool" default="false" /> + <description> + Initializes the stream used to list all files and directories using the [method get_next] function, closing the currently opened stream if needed. Once the stream has been processed, it should typically be closed with [method list_dir_end]. If [code]show_navigational[/code] is [code]true[/code], [code].[/code] and [code]..[/code] are included too. If [code]show_hidden[/code] is [code]true[/code], hidden files are included too. </description> </method> <method name="list_dir_end"> - <return type="void"> - </return> + <return type="void" /> <description> Closes the current stream opened with [method list_dir_begin] (whether it has been fully processed with [method get_next] does not matter). </description> </method> <method name="make_dir"> - <return type="int" enum="Error"> - </return> - <argument index="0" name="path" type="String"> - </argument> + <return type="int" enum="Error" /> + <argument index="0" name="path" type="String" /> <description> Creates a directory. The argument can be relative to the current directory, or an absolute path. The target directory should be placed in an already existing directory (to create the full path recursively, see [method make_dir_recursive]). Returns one of the [enum Error] code constants ([code]OK[/code] on success). </description> </method> <method name="make_dir_recursive"> - <return type="int" enum="Error"> - </return> - <argument index="0" name="path" type="String"> - </argument> + <return type="int" enum="Error" /> + <argument index="0" name="path" type="String" /> <description> Creates a target directory and all necessary intermediate directories in its path, by calling [method make_dir] recursively. The argument can be relative to the current directory, or an absolute path. Returns one of the [enum Error] code constants ([code]OK[/code] on success). </description> </method> <method name="open"> - <return type="int" enum="Error"> - </return> - <argument index="0" name="path" type="String"> - </argument> + <return type="int" enum="Error" /> + <argument index="0" name="path" type="String" /> <description> Opens an existing directory of the filesystem. The [code]path[/code] argument can be within the project tree ([code]res://folder[/code]), the user directory ([code]user://folder[/code]) or an absolute path of the user filesystem (e.g. [code]/tmp/folder[/code] or [code]C:\tmp\folder[/code]). Returns one of the [enum Error] code constants ([code]OK[/code] on success). </description> </method> <method name="remove"> - <return type="int" enum="Error"> - </return> - <argument index="0" name="path" type="String"> - </argument> + <return type="int" enum="Error" /> + <argument index="0" name="path" type="String" /> <description> Deletes the target file or an empty directory. The argument can be relative to the current directory, or an absolute path. If the target directory is not empty, the operation will fail. Returns one of the [enum Error] code constants ([code]OK[/code] on success). </description> </method> <method name="rename"> - <return type="int" enum="Error"> - </return> - <argument index="0" name="from" type="String"> - </argument> - <argument index="1" name="to" type="String"> - </argument> + <return type="int" enum="Error" /> + <argument index="0" name="from" type="String" /> + <argument index="1" name="to" type="String" /> <description> Renames (move) the [code]from[/code] file to the [code]to[/code] destination. Both arguments should be paths to files, either relative or absolute. If the destination file exists and is not access-protected, it will be overwritten. Returns one of the [enum Error] code constants ([code]OK[/code] on success). diff --git a/doc/classes/DisplayServer.xml b/doc/classes/DisplayServer.xml index 17b51d5cbe..abb715b34e 100644 --- a/doc/classes/DisplayServer.xml +++ b/doc/classes/DisplayServer.xml @@ -7,481 +7,346 @@ <tutorials> </tutorials> <methods> - <method name="alert"> - <return type="void"> - </return> - <argument index="0" name="text" type="String"> - </argument> - <argument index="1" name="title" type="String" default=""Alert!""> - </argument> - <description> - </description> - </method> <method name="clipboard_get" qualifiers="const"> - <return type="String"> - </return> + <return type="String" /> <description> </description> </method> <method name="clipboard_set"> - <return type="void"> - </return> - <argument index="0" name="clipboard" type="String"> - </argument> + <return type="void" /> + <argument index="0" name="clipboard" type="String" /> <description> </description> </method> <method name="console_set_visible"> - <return type="void"> - </return> - <argument index="0" name="console_visible" type="bool"> - </argument> + <return type="void" /> + <argument index="0" name="console_visible" type="bool" /> <description> </description> </method> <method name="create_sub_window"> - <return type="int"> - </return> - <argument index="0" name="mode" type="int" enum="DisplayServer.WindowMode"> - </argument> - <argument index="1" name="vsync_mode" type="int" enum="DisplayServer.VSyncMode"> - </argument> - <argument index="2" name="flags" type="int"> - </argument> - <argument index="3" name="rect" type="Rect2i" default="Rect2i(0, 0, 0, 0)"> - </argument> + <return type="int" /> + <argument index="0" name="mode" type="int" enum="DisplayServer.WindowMode" /> + <argument index="1" name="vsync_mode" type="int" enum="DisplayServer.VSyncMode" /> + <argument index="2" name="flags" type="int" /> + <argument index="3" name="rect" type="Rect2i" default="Rect2i(0, 0, 0, 0)" /> <description> </description> </method> <method name="cursor_get_shape" qualifiers="const"> - <return type="int" enum="DisplayServer.CursorShape"> - </return> + <return type="int" enum="DisplayServer.CursorShape" /> <description> </description> </method> <method name="cursor_set_custom_image"> - <return type="void"> - </return> - <argument index="0" name="cursor" type="Resource"> - </argument> - <argument index="1" name="shape" type="int" enum="DisplayServer.CursorShape" default="0"> - </argument> - <argument index="2" name="hotspot" type="Vector2" default="Vector2(0, 0)"> - </argument> + <return type="void" /> + <argument index="0" name="cursor" type="Resource" /> + <argument index="1" name="shape" type="int" enum="DisplayServer.CursorShape" default="0" /> + <argument index="2" name="hotspot" type="Vector2" default="Vector2(0, 0)" /> <description> </description> </method> <method name="cursor_set_shape"> - <return type="void"> - </return> - <argument index="0" name="shape" type="int" enum="DisplayServer.CursorShape"> - </argument> + <return type="void" /> + <argument index="0" name="shape" type="int" enum="DisplayServer.CursorShape" /> <description> </description> </method> <method name="delete_sub_window"> - <return type="void"> - </return> - <argument index="0" name="window_id" type="int"> - </argument> + <return type="void" /> + <argument index="0" name="window_id" type="int" /> <description> </description> </method> <method name="dialog_input_text"> - <return type="int" enum="Error"> - </return> - <argument index="0" name="title" type="String"> - </argument> - <argument index="1" name="description" type="String"> - </argument> - <argument index="2" name="existing_text" type="String"> - </argument> - <argument index="3" name="callback" type="Callable"> - </argument> + <return type="int" enum="Error" /> + <argument index="0" name="title" type="String" /> + <argument index="1" name="description" type="String" /> + <argument index="2" name="existing_text" type="String" /> + <argument index="3" name="callback" type="Callable" /> <description> </description> </method> <method name="dialog_show"> - <return type="int" enum="Error"> - </return> - <argument index="0" name="title" type="String"> - </argument> - <argument index="1" name="description" type="String"> - </argument> - <argument index="2" name="buttons" type="PackedStringArray"> - </argument> - <argument index="3" name="callback" type="Callable"> - </argument> + <return type="int" enum="Error" /> + <argument index="0" name="title" type="String" /> + <argument index="1" name="description" type="String" /> + <argument index="2" name="buttons" type="PackedStringArray" /> + <argument index="3" name="callback" type="Callable" /> <description> </description> </method> <method name="enable_for_stealing_focus"> - <return type="void"> - </return> - <argument index="0" name="process_id" type="int"> - </argument> + <return type="void" /> + <argument index="0" name="process_id" type="int" /> <description> </description> </method> <method name="force_process_and_drop_events"> - <return type="void"> - </return> + <return type="void" /> <description> </description> </method> <method name="get_name" qualifiers="const"> - <return type="String"> - </return> + <return type="String" /> <description> </description> </method> <method name="get_screen_count" qualifiers="const"> - <return type="int"> - </return> + <return type="int" /> <description> </description> </method> <method name="get_swap_cancel_ok"> - <return type="bool"> - </return> + <return type="bool" /> <description> </description> </method> <method name="get_window_at_screen_position" qualifiers="const"> - <return type="int"> - </return> - <argument index="0" name="position" type="Vector2i"> - </argument> + <return type="int" /> + <argument index="0" name="position" type="Vector2i" /> <description> </description> </method> <method name="get_window_list" qualifiers="const"> - <return type="PackedInt32Array"> - </return> + <return type="PackedInt32Array" /> <description> </description> </method> <method name="global_menu_add_check_item"> - <return type="void"> - </return> - <argument index="0" name="menu_root" type="String"> - </argument> - <argument index="1" name="label" type="String"> - </argument> - <argument index="2" name="callback" type="Callable"> - </argument> - <argument index="3" name="tag" type="Variant" default="null"> - </argument> + <return type="void" /> + <argument index="0" name="menu_root" type="String" /> + <argument index="1" name="label" type="String" /> + <argument index="2" name="callback" type="Callable" /> + <argument index="3" name="tag" type="Variant" default="null" /> <description> </description> </method> <method name="global_menu_add_item"> - <return type="void"> - </return> - <argument index="0" name="menu_root" type="String"> - </argument> - <argument index="1" name="label" type="String"> - </argument> - <argument index="2" name="callback" type="Callable"> - </argument> - <argument index="3" name="tag" type="Variant" default="null"> - </argument> + <return type="void" /> + <argument index="0" name="menu_root" type="String" /> + <argument index="1" name="label" type="String" /> + <argument index="2" name="callback" type="Callable" /> + <argument index="3" name="tag" type="Variant" default="null" /> <description> </description> </method> <method name="global_menu_add_separator"> - <return type="void"> - </return> - <argument index="0" name="menu_root" type="String"> - </argument> + <return type="void" /> + <argument index="0" name="menu_root" type="String" /> <description> </description> </method> <method name="global_menu_add_submenu_item"> - <return type="void"> - </return> - <argument index="0" name="menu_root" type="String"> - </argument> - <argument index="1" name="label" type="String"> - </argument> - <argument index="2" name="submenu" type="String"> - </argument> + <return type="void" /> + <argument index="0" name="menu_root" type="String" /> + <argument index="1" name="label" type="String" /> + <argument index="2" name="submenu" type="String" /> <description> </description> </method> <method name="global_menu_clear"> - <return type="void"> - </return> - <argument index="0" name="menu_root" type="String"> - </argument> + <return type="void" /> + <argument index="0" name="menu_root" type="String" /> <description> </description> </method> <method name="global_menu_get_item_callback"> - <return type="Callable"> - </return> - <argument index="0" name="menu_root" type="String"> - </argument> - <argument index="1" name="idx" type="int"> - </argument> + <return type="Callable" /> + <argument index="0" name="menu_root" type="String" /> + <argument index="1" name="idx" type="int" /> <description> </description> </method> <method name="global_menu_get_item_submenu"> - <return type="String"> - </return> - <argument index="0" name="menu_root" type="String"> - </argument> - <argument index="1" name="idx" type="int"> - </argument> + <return type="String" /> + <argument index="0" name="menu_root" type="String" /> + <argument index="1" name="idx" type="int" /> <description> </description> </method> <method name="global_menu_get_item_tag"> - <return type="Variant"> - </return> - <argument index="0" name="menu_root" type="String"> - </argument> - <argument index="1" name="idx" type="int"> - </argument> + <return type="Variant" /> + <argument index="0" name="menu_root" type="String" /> + <argument index="1" name="idx" type="int" /> <description> </description> </method> <method name="global_menu_get_item_text"> - <return type="String"> - </return> - <argument index="0" name="menu_root" type="String"> - </argument> - <argument index="1" name="idx" type="int"> - </argument> + <return type="String" /> + <argument index="0" name="menu_root" type="String" /> + <argument index="1" name="idx" type="int" /> <description> </description> </method> <method name="global_menu_is_item_checkable" qualifiers="const"> - <return type="bool"> - </return> - <argument index="0" name="menu_root" type="String"> - </argument> - <argument index="1" name="idx" type="int"> - </argument> + <return type="bool" /> + <argument index="0" name="menu_root" type="String" /> + <argument index="1" name="idx" type="int" /> <description> </description> </method> <method name="global_menu_is_item_checked" qualifiers="const"> - <return type="bool"> - </return> - <argument index="0" name="menu_root" type="String"> - </argument> - <argument index="1" name="idx" type="int"> - </argument> + <return type="bool" /> + <argument index="0" name="menu_root" type="String" /> + <argument index="1" name="idx" type="int" /> <description> </description> </method> <method name="global_menu_remove_item"> - <return type="void"> - </return> - <argument index="0" name="menu_root" type="String"> - </argument> - <argument index="1" name="idx" type="int"> - </argument> + <return type="void" /> + <argument index="0" name="menu_root" type="String" /> + <argument index="1" name="idx" type="int" /> <description> </description> </method> <method name="global_menu_set_item_callback"> - <return type="void"> - </return> - <argument index="0" name="menu_root" type="String"> - </argument> - <argument index="1" name="idx" type="int"> - </argument> - <argument index="2" name="callback" type="Callable"> - </argument> + <return type="void" /> + <argument index="0" name="menu_root" type="String" /> + <argument index="1" name="idx" type="int" /> + <argument index="2" name="callback" type="Callable" /> <description> </description> </method> <method name="global_menu_set_item_checkable"> - <return type="void"> - </return> - <argument index="0" name="menu_root" type="String"> - </argument> - <argument index="1" name="idx" type="int"> - </argument> - <argument index="2" name="checkable" type="bool"> - </argument> + <return type="void" /> + <argument index="0" name="menu_root" type="String" /> + <argument index="1" name="idx" type="int" /> + <argument index="2" name="checkable" type="bool" /> <description> </description> </method> <method name="global_menu_set_item_checked"> - <return type="void"> - </return> - <argument index="0" name="menu_root" type="String"> - </argument> - <argument index="1" name="idx" type="int"> - </argument> - <argument index="2" name="checked" type="bool"> - </argument> + <return type="void" /> + <argument index="0" name="menu_root" type="String" /> + <argument index="1" name="idx" type="int" /> + <argument index="2" name="checked" type="bool" /> <description> </description> </method> <method name="global_menu_set_item_submenu"> - <return type="void"> - </return> - <argument index="0" name="menu_root" type="String"> - </argument> - <argument index="1" name="idx" type="int"> - </argument> - <argument index="2" name="submenu" type="String"> - </argument> + <return type="void" /> + <argument index="0" name="menu_root" type="String" /> + <argument index="1" name="idx" type="int" /> + <argument index="2" name="submenu" type="String" /> <description> </description> </method> <method name="global_menu_set_item_tag"> - <return type="void"> - </return> - <argument index="0" name="menu_root" type="String"> - </argument> - <argument index="1" name="idx" type="int"> - </argument> - <argument index="2" name="tag" type="Variant"> - </argument> + <return type="void" /> + <argument index="0" name="menu_root" type="String" /> + <argument index="1" name="idx" type="int" /> + <argument index="2" name="tag" type="Variant" /> <description> </description> </method> <method name="global_menu_set_item_text"> - <return type="void"> - </return> - <argument index="0" name="menu_root" type="String"> - </argument> - <argument index="1" name="idx" type="int"> - </argument> - <argument index="2" name="text" type="String"> - </argument> + <return type="void" /> + <argument index="0" name="menu_root" type="String" /> + <argument index="1" name="idx" type="int" /> + <argument index="2" name="text" type="String" /> <description> </description> </method> <method name="has_feature" qualifiers="const"> - <return type="bool"> - </return> - <argument index="0" name="feature" type="int" enum="DisplayServer.Feature"> - </argument> + <return type="bool" /> + <argument index="0" name="feature" type="int" enum="DisplayServer.Feature" /> <description> </description> </method> <method name="ime_get_selection" qualifiers="const"> - <return type="Vector2i"> - </return> + <return type="Vector2i" /> <description> </description> </method> <method name="ime_get_text" qualifiers="const"> - <return type="String"> - </return> + <return type="String" /> <description> </description> </method> <method name="is_console_visible" qualifiers="const"> - <return type="bool"> - </return> + <return type="bool" /> <description> </description> </method> <method name="keyboard_get_current_layout" qualifiers="const"> - <return type="int"> - </return> + <return type="int" /> <description> Returns active keyboard layout index. [b]Note:[/b] This method is implemented on Linux, macOS and Windows. </description> </method> <method name="keyboard_get_layout_count" qualifiers="const"> - <return type="int"> - </return> + <return type="int" /> <description> Returns the number of keyboard layouts. [b]Note:[/b] This method is implemented on Linux, macOS and Windows. </description> </method> <method name="keyboard_get_layout_language" qualifiers="const"> - <return type="String"> - </return> - <argument index="0" name="index" type="int"> - </argument> + <return type="String" /> + <argument index="0" name="index" type="int" /> <description> Returns the ISO-639/BCP-47 language code of the keyboard layout at position [code]index[/code]. [b]Note:[/b] This method is implemented on Linux, macOS and Windows. </description> </method> <method name="keyboard_get_layout_name" qualifiers="const"> - <return type="String"> - </return> - <argument index="0" name="index" type="int"> - </argument> + <return type="String" /> + <argument index="0" name="index" type="int" /> <description> Returns the localized name of the keyboard layout at position [code]index[/code]. [b]Note:[/b] This method is implemented on Linux, macOS and Windows. </description> </method> <method name="keyboard_set_current_layout"> - <return type="void"> - </return> - <argument index="0" name="index" type="int"> - </argument> + <return type="void" /> + <argument index="0" name="index" type="int" /> <description> Sets active keyboard layout. [b]Note:[/b] This method is implemented on Linux, macOS and Windows. </description> </method> <method name="mouse_get_absolute_position" qualifiers="const"> - <return type="Vector2i"> - </return> + <return type="Vector2i" /> <description> </description> </method> <method name="mouse_get_button_state" qualifiers="const"> - <return type="int" enum="MouseButton"> - </return> + <return type="int" enum="MouseButton" /> <description> </description> </method> <method name="mouse_get_mode" qualifiers="const"> - <return type="int" enum="DisplayServer.MouseMode"> - </return> + <return type="int" enum="DisplayServer.MouseMode" /> <description> </description> </method> <method name="mouse_get_position" qualifiers="const"> - <return type="Vector2i"> - </return> + <return type="Vector2i" /> <description> </description> </method> <method name="mouse_set_mode"> - <return type="void"> - </return> - <argument index="0" name="mouse_mode" type="int" enum="DisplayServer.MouseMode"> - </argument> + <return type="void" /> + <argument index="0" name="mouse_mode" type="int" enum="DisplayServer.MouseMode" /> <description> </description> </method> <method name="mouse_warp_to_position"> - <return type="void"> - </return> - <argument index="0" name="position" type="Vector2i"> - </argument> + <return type="void" /> + <argument index="0" name="position" type="Vector2i" /> <description> </description> </method> <method name="process_events"> - <return type="void"> - </return> + <return type="void" /> <description> </description> </method> <method name="screen_get_dpi" qualifiers="const"> - <return type="int"> - </return> - <argument index="0" name="screen" type="int" default="-1"> - </argument> + <return type="int" /> + <argument index="0" name="screen" type="int" default="-1" /> <description> Returns the dots per inch density of the specified screen. If [code]screen[/code] is [/code]SCREEN_OF_MAIN_WINDOW[/code] (the default value), a screen with the main window will be used. [b]Note:[/b] On macOS, returned value is inaccurate if fractional display scaling mode is used. @@ -498,8 +363,7 @@ </description> </method> <method name="screen_get_max_scale" qualifiers="const"> - <return type="float"> - </return> + <return type="float" /> <description> Return the greatest scale factor of all screens. [b]Note:[/b] On macOS returned value is [code]2.0[/code] if there is at least one hiDPI (Retina) screen in the system, and [code]1.0[/code] in all other cases. @@ -507,26 +371,20 @@ </description> </method> <method name="screen_get_orientation" qualifiers="const"> - <return type="int" enum="DisplayServer.ScreenOrientation"> - </return> - <argument index="0" name="screen" type="int" default="-1"> - </argument> + <return type="int" enum="DisplayServer.ScreenOrientation" /> + <argument index="0" name="screen" type="int" default="-1" /> <description> </description> </method> <method name="screen_get_position" qualifiers="const"> - <return type="Vector2i"> - </return> - <argument index="0" name="screen" type="int" default="-1"> - </argument> + <return type="Vector2i" /> + <argument index="0" name="screen" type="int" default="-1" /> <description> </description> </method> <method name="screen_get_scale" qualifiers="const"> - <return type="float"> - </return> - <argument index="0" name="screen" type="int" default="-1"> - </argument> + <return type="float" /> + <argument index="0" name="screen" type="int" default="-1" /> <description> Return the scale factor of the specified screen by index. [b]Note:[/b] On macOS returned value is [code]2.0[/code] for hiDPI (Retina) screen, and [code]1.0[/code] for all other cases. @@ -534,134 +392,103 @@ </description> </method> <method name="screen_get_size" qualifiers="const"> - <return type="Vector2i"> - </return> - <argument index="0" name="screen" type="int" default="-1"> - </argument> + <return type="Vector2i" /> + <argument index="0" name="screen" type="int" default="-1" /> <description> </description> </method> <method name="screen_get_usable_rect" qualifiers="const"> - <return type="Rect2i"> - </return> - <argument index="0" name="screen" type="int" default="-1"> - </argument> + <return type="Rect2i" /> + <argument index="0" name="screen" type="int" default="-1" /> <description> </description> </method> <method name="screen_is_kept_on" qualifiers="const"> - <return type="bool"> - </return> + <return type="bool" /> <description> </description> </method> <method name="screen_is_touchscreen" qualifiers="const"> - <return type="bool"> - </return> - <argument index="0" name="screen" type="int" default="-1"> - </argument> + <return type="bool" /> + <argument index="0" name="screen" type="int" default="-1" /> <description> </description> </method> <method name="screen_set_keep_on"> - <return type="void"> - </return> - <argument index="0" name="enable" type="bool"> - </argument> + <return type="void" /> + <argument index="0" name="enable" type="bool" /> <description> </description> </method> <method name="screen_set_orientation"> - <return type="void"> - </return> - <argument index="0" name="orientation" type="int" enum="DisplayServer.ScreenOrientation"> - </argument> - <argument index="1" name="screen" type="int" default="-1"> - </argument> + <return type="void" /> + <argument index="0" name="orientation" type="int" enum="DisplayServer.ScreenOrientation" /> + <argument index="1" name="screen" type="int" default="-1" /> <description> </description> </method> <method name="set_icon"> - <return type="void"> - </return> - <argument index="0" name="image" type="Image"> - </argument> + <return type="void" /> + <argument index="0" name="image" type="Image" /> <description> </description> </method> <method name="set_native_icon"> - <return type="void"> - </return> - <argument index="0" name="filename" type="String"> - </argument> + <return type="void" /> + <argument index="0" name="filename" type="String" /> <description> </description> </method> <method name="tablet_get_current_driver" qualifiers="const"> - <return type="String"> - </return> + <return type="String" /> <description> Returns current active tablet driver name. [b]Note:[/b] This method is implemented on Windows. </description> </method> <method name="tablet_get_driver_count" qualifiers="const"> - <return type="int"> - </return> + <return type="int" /> <description> Returns the total number of available tablet drivers. [b]Note:[/b] This method is implemented on Windows. </description> </method> <method name="tablet_get_driver_name" qualifiers="const"> - <return type="String"> - </return> - <argument index="0" name="idx" type="int"> - </argument> + <return type="String" /> + <argument index="0" name="idx" type="int" /> <description> Returns the tablet driver name for the given index. [b]Note:[/b] This method is implemented on Windows. </description> </method> <method name="tablet_set_current_driver"> - <return type="void"> - </return> - <argument index="0" name="name" type="String"> - </argument> + <return type="void" /> + <argument index="0" name="name" type="String" /> <description> Set active tablet driver name. [b]Note:[/b] This method is implemented on Windows. </description> </method> <method name="virtual_keyboard_get_height" qualifiers="const"> - <return type="int"> - </return> + <return type="int" /> <description> Returns the on-screen keyboard's height in pixels. Returns 0 if there is no keyboard or if it is currently hidden. </description> </method> <method name="virtual_keyboard_hide"> - <return type="void"> - </return> + <return type="void" /> <description> Hides the virtual keyboard if it is shown, does nothing otherwise. </description> </method> <method name="virtual_keyboard_show"> - <return type="void"> - </return> - <argument index="0" name="existing_text" type="String"> - </argument> - <argument index="1" name="position" type="Rect2" default="Rect2i(0, 0, 0, 0)"> - </argument> - <argument index="2" name="multiline" type="bool" default="false"> - </argument> - <argument index="3" name="max_length" type="int" default="-1"> - </argument> - <argument index="4" name="cursor_start" type="int" default="-1"> - </argument> - <argument index="5" name="cursor_end" type="int" default="-1"> - </argument> + <return type="void" /> + <argument index="0" name="existing_text" type="String" /> + <argument index="1" name="position" type="Rect2" default="Rect2i(0, 0, 0, 0)" /> + <argument index="2" name="multiline" type="bool" default="false" /> + <argument index="3" name="max_length" type="int" default="-1" /> + <argument index="4" name="cursor_start" type="int" default="-1" /> + <argument index="5" name="cursor_end" type="int" default="-1" /> <description> Shows the virtual keyboard if the platform has one. [code]existing_text[/code] parameter is useful for implementing your own [LineEdit] or [TextEdit], as it tells the virtual keyboard what text has already been typed (the virtual keyboard uses it for auto-correct and predictions). @@ -674,231 +501,167 @@ </description> </method> <method name="window_attach_instance_id"> - <return type="void"> - </return> - <argument index="0" name="instance_id" type="int"> - </argument> - <argument index="1" name="window_id" type="int" default="0"> - </argument> + <return type="void" /> + <argument index="0" name="instance_id" type="int" /> + <argument index="1" name="window_id" type="int" default="0" /> <description> </description> </method> <method name="window_can_draw" qualifiers="const"> - <return type="bool"> - </return> - <argument index="0" name="window_id" type="int" default="0"> - </argument> + <return type="bool" /> + <argument index="0" name="window_id" type="int" default="0" /> <description> </description> </method> <method name="window_get_attached_instance_id" qualifiers="const"> - <return type="int"> - </return> - <argument index="0" name="window_id" type="int" default="0"> - </argument> + <return type="int" /> + <argument index="0" name="window_id" type="int" default="0" /> <description> </description> </method> <method name="window_get_current_screen" qualifiers="const"> - <return type="int"> - </return> - <argument index="0" name="window_id" type="int" default="0"> - </argument> + <return type="int" /> + <argument index="0" name="window_id" type="int" default="0" /> <description> </description> </method> <method name="window_get_flag" qualifiers="const"> - <return type="bool"> - </return> - <argument index="0" name="flag" type="int" enum="DisplayServer.WindowFlags"> - </argument> - <argument index="1" name="window_id" type="int" default="0"> - </argument> + <return type="bool" /> + <argument index="0" name="flag" type="int" enum="DisplayServer.WindowFlags" /> + <argument index="1" name="window_id" type="int" default="0" /> <description> </description> </method> <method name="window_get_max_size" qualifiers="const"> - <return type="Vector2i"> - </return> - <argument index="0" name="window_id" type="int" default="0"> - </argument> + <return type="Vector2i" /> + <argument index="0" name="window_id" type="int" default="0" /> <description> </description> </method> <method name="window_get_min_size" qualifiers="const"> - <return type="Vector2i"> - </return> - <argument index="0" name="window_id" type="int" default="0"> - </argument> + <return type="Vector2i" /> + <argument index="0" name="window_id" type="int" default="0" /> <description> </description> </method> <method name="window_get_mode" qualifiers="const"> - <return type="int" enum="DisplayServer.WindowMode"> - </return> - <argument index="0" name="window_id" type="int" default="0"> - </argument> + <return type="int" enum="DisplayServer.WindowMode" /> + <argument index="0" name="window_id" type="int" default="0" /> <description> </description> </method> <method name="window_get_position" qualifiers="const"> - <return type="Vector2i"> - </return> - <argument index="0" name="window_id" type="int" default="0"> - </argument> + <return type="Vector2i" /> + <argument index="0" name="window_id" type="int" default="0" /> <description> </description> </method> <method name="window_get_real_size" qualifiers="const"> - <return type="Vector2i"> - </return> - <argument index="0" name="window_id" type="int" default="0"> - </argument> + <return type="Vector2i" /> + <argument index="0" name="window_id" type="int" default="0" /> <description> </description> </method> <method name="window_get_size" qualifiers="const"> - <return type="Vector2i"> - </return> - <argument index="0" name="window_id" type="int" default="0"> - </argument> + <return type="Vector2i" /> + <argument index="0" name="window_id" type="int" default="0" /> <description> </description> </method> <method name="window_get_vsync_mode" qualifiers="const"> - <return type="int" enum="DisplayServer.VSyncMode"> - </return> - <argument index="0" name="window_id" type="int" default="0"> - </argument> + <return type="int" enum="DisplayServer.VSyncMode" /> + <argument index="0" name="window_id" type="int" default="0" /> <description> Returns the VSync mode of the given window. </description> </method> <method name="window_move_to_foreground"> - <return type="void"> - </return> - <argument index="0" name="window_id" type="int" default="0"> - </argument> + <return type="void" /> + <argument index="0" name="window_id" type="int" default="0" /> <description> </description> </method> <method name="window_request_attention"> - <return type="void"> - </return> - <argument index="0" name="window_id" type="int" default="0"> - </argument> + <return type="void" /> + <argument index="0" name="window_id" type="int" default="0" /> <description> </description> </method> <method name="window_set_current_screen"> - <return type="void"> - </return> - <argument index="0" name="screen" type="int"> - </argument> - <argument index="1" name="window_id" type="int" default="0"> - </argument> + <return type="void" /> + <argument index="0" name="screen" type="int" /> + <argument index="1" name="window_id" type="int" default="0" /> <description> </description> </method> <method name="window_set_drop_files_callback"> - <return type="void"> - </return> - <argument index="0" name="callback" type="Callable"> - </argument> - <argument index="1" name="window_id" type="int" default="0"> - </argument> + <return type="void" /> + <argument index="0" name="callback" type="Callable" /> + <argument index="1" name="window_id" type="int" default="0" /> <description> </description> </method> <method name="window_set_flag"> - <return type="void"> - </return> - <argument index="0" name="flag" type="int" enum="DisplayServer.WindowFlags"> - </argument> - <argument index="1" name="enabled" type="bool"> - </argument> - <argument index="2" name="window_id" type="int" default="0"> - </argument> + <return type="void" /> + <argument index="0" name="flag" type="int" enum="DisplayServer.WindowFlags" /> + <argument index="1" name="enabled" type="bool" /> + <argument index="2" name="window_id" type="int" default="0" /> <description> </description> </method> <method name="window_set_ime_active"> - <return type="void"> - </return> - <argument index="0" name="active" type="bool"> - </argument> - <argument index="1" name="window_id" type="int" default="0"> - </argument> + <return type="void" /> + <argument index="0" name="active" type="bool" /> + <argument index="1" name="window_id" type="int" default="0" /> <description> </description> </method> <method name="window_set_ime_position"> - <return type="void"> - </return> - <argument index="0" name="position" type="Vector2i"> - </argument> - <argument index="1" name="window_id" type="int" default="0"> - </argument> + <return type="void" /> + <argument index="0" name="position" type="Vector2i" /> + <argument index="1" name="window_id" type="int" default="0" /> <description> </description> </method> <method name="window_set_input_event_callback"> - <return type="void"> - </return> - <argument index="0" name="callback" type="Callable"> - </argument> - <argument index="1" name="window_id" type="int" default="0"> - </argument> + <return type="void" /> + <argument index="0" name="callback" type="Callable" /> + <argument index="1" name="window_id" type="int" default="0" /> <description> </description> </method> <method name="window_set_input_text_callback"> - <return type="void"> - </return> - <argument index="0" name="callback" type="Callable"> - </argument> - <argument index="1" name="window_id" type="int" default="0"> - </argument> + <return type="void" /> + <argument index="0" name="callback" type="Callable" /> + <argument index="1" name="window_id" type="int" default="0" /> <description> </description> </method> <method name="window_set_max_size"> - <return type="void"> - </return> - <argument index="0" name="max_size" type="Vector2i"> - </argument> - <argument index="1" name="window_id" type="int" default="0"> - </argument> + <return type="void" /> + <argument index="0" name="max_size" type="Vector2i" /> + <argument index="1" name="window_id" type="int" default="0" /> <description> </description> </method> <method name="window_set_min_size"> - <return type="void"> - </return> - <argument index="0" name="min_size" type="Vector2i"> - </argument> - <argument index="1" name="window_id" type="int" default="0"> - </argument> + <return type="void" /> + <argument index="0" name="min_size" type="Vector2i" /> + <argument index="1" name="window_id" type="int" default="0" /> <description> </description> </method> <method name="window_set_mode"> - <return type="void"> - </return> - <argument index="0" name="mode" type="int" enum="DisplayServer.WindowMode"> - </argument> - <argument index="1" name="window_id" type="int" default="0"> - </argument> + <return type="void" /> + <argument index="0" name="mode" type="int" enum="DisplayServer.WindowMode" /> + <argument index="1" name="window_id" type="int" default="0" /> <description> </description> </method> <method name="window_set_mouse_passthrough"> - <return type="void"> - </return> - <argument index="0" name="region" type="PackedVector2Array"> - </argument> - <argument index="1" name="window_id" type="int" default="0"> - </argument> + <return type="void" /> + <argument index="0" name="region" type="PackedVector2Array" /> + <argument index="1" name="window_id" type="int" default="0" /> <description> Sets a polygonal region of the window which accepts mouse events. Mouse events outside the region will be passed through. Passing an empty array will disable passthrough support (all mouse events will be intercepted by the window, which is the default behavior). @@ -929,62 +692,44 @@ </description> </method> <method name="window_set_position"> - <return type="void"> - </return> - <argument index="0" name="position" type="Vector2i"> - </argument> - <argument index="1" name="window_id" type="int" default="0"> - </argument> + <return type="void" /> + <argument index="0" name="position" type="Vector2i" /> + <argument index="1" name="window_id" type="int" default="0" /> <description> </description> </method> <method name="window_set_rect_changed_callback"> - <return type="void"> - </return> - <argument index="0" name="callback" type="Callable"> - </argument> - <argument index="1" name="window_id" type="int" default="0"> - </argument> + <return type="void" /> + <argument index="0" name="callback" type="Callable" /> + <argument index="1" name="window_id" type="int" default="0" /> <description> </description> </method> <method name="window_set_size"> - <return type="void"> - </return> - <argument index="0" name="size" type="Vector2i"> - </argument> - <argument index="1" name="window_id" type="int" default="0"> - </argument> + <return type="void" /> + <argument index="0" name="size" type="Vector2i" /> + <argument index="1" name="window_id" type="int" default="0" /> <description> </description> </method> <method name="window_set_title"> - <return type="void"> - </return> - <argument index="0" name="title" type="String"> - </argument> - <argument index="1" name="window_id" type="int" default="0"> - </argument> + <return type="void" /> + <argument index="0" name="title" type="String" /> + <argument index="1" name="window_id" type="int" default="0" /> <description> </description> </method> <method name="window_set_transient"> - <return type="void"> - </return> - <argument index="0" name="window_id" type="int"> - </argument> - <argument index="1" name="parent_window_id" type="int"> - </argument> + <return type="void" /> + <argument index="0" name="window_id" type="int" /> + <argument index="1" name="parent_window_id" type="int" /> <description> </description> </method> <method name="window_set_vsync_mode"> - <return type="void"> - </return> - <argument index="0" name="vsync_mode" type="int" enum="DisplayServer.VSyncMode"> - </argument> - <argument index="1" name="window_id" type="int" default="0"> - </argument> + <return type="void" /> + <argument index="0" name="vsync_mode" type="int" enum="DisplayServer.VSyncMode" /> + <argument index="1" name="window_id" type="int" default="0" /> <description> Sets the VSync mode of the given window. See [enum DisplayServer.VSyncMode] for possible values and how they affect the behavior of your application. @@ -992,12 +737,9 @@ </description> </method> <method name="window_set_window_event_callback"> - <return type="void"> - </return> - <argument index="0" name="callback" type="Callable"> - </argument> - <argument index="1" name="window_id" type="int" default="0"> - </argument> + <return type="void" /> + <argument index="0" name="callback" type="Callable" /> + <argument index="1" name="window_id" type="int" default="0" /> <description> </description> </method> diff --git a/doc/classes/EditorDebuggerPlugin.xml b/doc/classes/EditorDebuggerPlugin.xml index 9484d33252..d67df8dfee 100644 --- a/doc/classes/EditorDebuggerPlugin.xml +++ b/doc/classes/EditorDebuggerPlugin.xml @@ -12,63 +12,50 @@ </tutorials> <methods> <method name="has_capture"> - <return type="bool"> - </return> - <argument index="0" name="name" type="StringName"> - </argument> + <return type="bool" /> + <argument index="0" name="name" type="StringName" /> <description> Returns [code]true[/code] if a message capture with given name is present otherwise [code]false[/code]. </description> </method> <method name="is_breaked"> - <return type="bool"> - </return> + <return type="bool" /> <description> Returns [code]true[/code] if the game is in break state otherwise [code]false[/code]. </description> </method> <method name="is_debuggable"> - <return type="bool"> - </return> + <return type="bool" /> <description> Returns [code]true[/code] if the game can be debugged otherwise [code]false[/code]. </description> </method> <method name="is_session_active"> - <return type="bool"> - </return> + <return type="bool" /> <description> Returns [code]true[/code] if there is an instance of the game running with the attached debugger otherwise [code]false[/code]. </description> </method> <method name="register_message_capture"> - <return type="void"> - </return> - <argument index="0" name="name" type="StringName"> - </argument> - <argument index="1" name="callable" type="Callable"> - </argument> + <return type="void" /> + <argument index="0" name="name" type="StringName" /> + <argument index="1" name="callable" type="Callable" /> <description> Registers a message capture with given [code]name[/code]. If [code]name[/code] is "my_message" then messages starting with "my_message:" will be called with the given callable. Callable must accept a message string and a data array as argument. If the message and data are valid then callable must return [code]true[/code] otherwise [code]false[/code]. </description> </method> <method name="send_message"> - <return type="void"> - </return> - <argument index="0" name="message" type="String"> - </argument> - <argument index="1" name="data" type="Array"> - </argument> + <return type="void" /> + <argument index="0" name="message" type="String" /> + <argument index="1" name="data" type="Array" /> <description> Sends a message with given [code]message[/code] and [code]data[/code] array. </description> </method> <method name="unregister_message_capture"> - <return type="void"> - </return> - <argument index="0" name="name" type="StringName"> - </argument> + <return type="void" /> + <argument index="0" name="name" type="StringName" /> <description> Unregisters the message capture with given name. </description> @@ -76,8 +63,7 @@ </methods> <signals> <signal name="breaked"> - <argument index="0" name="can_debug" type="bool"> - </argument> + <argument index="0" name="can_debug" type="bool" /> <description> Emitted when the game enters a break state. </description> diff --git a/doc/classes/EditorExportPlugin.xml b/doc/classes/EditorExportPlugin.xml index d9e3003fbb..16c50b4d3e 100644 --- a/doc/classes/EditorExportPlugin.xml +++ b/doc/classes/EditorExportPlugin.xml @@ -10,77 +10,57 @@ </tutorials> <methods> <method name="_export_begin" qualifiers="virtual"> - <return type="void"> - </return> - <argument index="0" name="features" type="PackedStringArray"> - </argument> - <argument index="1" name="is_debug" type="bool"> - </argument> - <argument index="2" name="path" type="String"> - </argument> - <argument index="3" name="flags" type="int"> - </argument> + <return type="void" /> + <argument index="0" name="features" type="PackedStringArray" /> + <argument index="1" name="is_debug" type="bool" /> + <argument index="2" name="path" type="String" /> + <argument index="3" name="flags" type="int" /> <description> Virtual method to be overridden by the user. It is called when the export starts and provides all information about the export. [code]features[/code] is the list of features for the export, [code]is_debug[/code] is [code]true[/code] for debug builds, [code]path[/code] is the target path for the exported project. [code]flags[/code] is only used when running a runnable profile, e.g. when using native run on Android. </description> </method> <method name="_export_end" qualifiers="virtual"> - <return type="void"> - </return> + <return type="void" /> <description> Virtual method to be overridden by the user. Called when the export is finished. </description> </method> <method name="_export_file" qualifiers="virtual"> - <return type="void"> - </return> - <argument index="0" name="path" type="String"> - </argument> - <argument index="1" name="type" type="String"> - </argument> - <argument index="2" name="features" type="PackedStringArray"> - </argument> + <return type="void" /> + <argument index="0" name="path" type="String" /> + <argument index="1" name="type" type="String" /> + <argument index="2" name="features" type="PackedStringArray" /> <description> Virtual method to be overridden by the user. Called for each exported file, providing arguments that can be used to identify the file. [code]path[/code] is the path of the file, [code]type[/code] is the [Resource] represented by the file (e.g. [PackedScene]) and [code]features[/code] is the list of features for the export. Calling [method skip] inside this callback will make the file not included in the export. </description> </method> <method name="add_file"> - <return type="void"> - </return> - <argument index="0" name="path" type="String"> - </argument> - <argument index="1" name="file" type="PackedByteArray"> - </argument> - <argument index="2" name="remap" type="bool"> - </argument> + <return type="void" /> + <argument index="0" name="path" type="String" /> + <argument index="1" name="file" type="PackedByteArray" /> + <argument index="2" name="remap" type="bool" /> <description> Adds a custom file to be exported. [code]path[/code] is the virtual path that can be used to load the file, [code]file[/code] is the binary data of the file. If [code]remap[/code] is [code]true[/code], file will not be exported, but instead remapped to the given [code]path[/code]. </description> </method> <method name="add_ios_bundle_file"> - <return type="void"> - </return> - <argument index="0" name="path" type="String"> - </argument> + <return type="void" /> + <argument index="0" name="path" type="String" /> <description> Adds an iOS bundle file from the given [code]path[/code] to the exported project. </description> </method> <method name="add_ios_cpp_code"> - <return type="void"> - </return> - <argument index="0" name="code" type="String"> - </argument> + <return type="void" /> + <argument index="0" name="code" type="String" /> <description> Adds a C++ code to the iOS export. The final code is created from the code appended by each active export plugin. </description> </method> <method name="add_ios_embedded_framework"> - <return type="void"> - </return> - <argument index="0" name="path" type="String"> - </argument> + <return type="void" /> + <argument index="0" name="path" type="String" /> <description> Adds a dynamic library (*.dylib, *.framework) to Linking Phase in iOS's Xcode project and embeds it into resulting binary. [b]Note:[/b] For static libraries (*.a) works in same way as [code]add_ios_framework[/code]. @@ -88,55 +68,43 @@ </description> </method> <method name="add_ios_framework"> - <return type="void"> - </return> - <argument index="0" name="path" type="String"> - </argument> + <return type="void" /> + <argument index="0" name="path" type="String" /> <description> Adds a static library (*.a) or dynamic library (*.dylib, *.framework) to Linking Phase in iOS's Xcode project. </description> </method> <method name="add_ios_linker_flags"> - <return type="void"> - </return> - <argument index="0" name="flags" type="String"> - </argument> + <return type="void" /> + <argument index="0" name="flags" type="String" /> <description> Adds linker flags for the iOS export. </description> </method> <method name="add_ios_plist_content"> - <return type="void"> - </return> - <argument index="0" name="plist_content" type="String"> - </argument> + <return type="void" /> + <argument index="0" name="plist_content" type="String" /> <description> Adds content for iOS Property List files. </description> </method> <method name="add_ios_project_static_lib"> - <return type="void"> - </return> - <argument index="0" name="path" type="String"> - </argument> + <return type="void" /> + <argument index="0" name="path" type="String" /> <description> Adds a static lib from the given [code]path[/code] to the iOS project. </description> </method> <method name="add_shared_object"> - <return type="void"> - </return> - <argument index="0" name="path" type="String"> - </argument> - <argument index="1" name="tags" type="PackedStringArray"> - </argument> + <return type="void" /> + <argument index="0" name="path" type="String" /> + <argument index="1" name="tags" type="PackedStringArray" /> <description> Adds a shared object with the given [code]tags[/code] and destination [code]path[/code]. </description> </method> <method name="skip"> - <return type="void"> - </return> + <return type="void" /> <description> To be called inside [method _export_file]. Skips the current file, so it's not included in the export. </description> diff --git a/doc/classes/EditorFeatureProfile.xml b/doc/classes/EditorFeatureProfile.xml index 0cd839f370..a41730d5d0 100644 --- a/doc/classes/EditorFeatureProfile.xml +++ b/doc/classes/EditorFeatureProfile.xml @@ -11,112 +11,84 @@ </tutorials> <methods> <method name="get_feature_name"> - <return type="String"> - </return> - <argument index="0" name="feature" type="int" enum="EditorFeatureProfile.Feature"> - </argument> + <return type="String" /> + <argument index="0" name="feature" type="int" enum="EditorFeatureProfile.Feature" /> <description> Returns the specified [code]feature[/code]'s human-readable name. </description> </method> <method name="is_class_disabled" qualifiers="const"> - <return type="bool"> - </return> - <argument index="0" name="class_name" type="StringName"> - </argument> + <return type="bool" /> + <argument index="0" name="class_name" type="StringName" /> <description> Returns [code]true[/code] if the class specified by [code]class_name[/code] is disabled. When disabled, the class won't appear in the Create New Node dialog. </description> </method> <method name="is_class_editor_disabled" qualifiers="const"> - <return type="bool"> - </return> - <argument index="0" name="class_name" type="StringName"> - </argument> + <return type="bool" /> + <argument index="0" name="class_name" type="StringName" /> <description> Returns [code]true[/code] if editing for the class specified by [code]class_name[/code] is disabled. When disabled, the class will still appear in the Create New Node dialog but the inspector will be read-only when selecting a node that extends the class. </description> </method> <method name="is_class_property_disabled" qualifiers="const"> - <return type="bool"> - </return> - <argument index="0" name="class_name" type="StringName"> - </argument> - <argument index="1" name="property" type="StringName"> - </argument> + <return type="bool" /> + <argument index="0" name="class_name" type="StringName" /> + <argument index="1" name="property" type="StringName" /> <description> Returns [code]true[/code] if [code]property[/code] is disabled in the class specified by [code]class_name[/code]. When a property is disabled, it won't appear in the inspector when selecting a node that extends the class specified by [code]class_name[/code]. </description> </method> <method name="is_feature_disabled" qualifiers="const"> - <return type="bool"> - </return> - <argument index="0" name="feature" type="int" enum="EditorFeatureProfile.Feature"> - </argument> + <return type="bool" /> + <argument index="0" name="feature" type="int" enum="EditorFeatureProfile.Feature" /> <description> Returns [code]true[/code] if the [code]feature[/code] is disabled. When a feature is disabled, it will disappear from the editor entirely. </description> </method> <method name="load_from_file"> - <return type="int" enum="Error"> - </return> - <argument index="0" name="path" type="String"> - </argument> + <return type="int" enum="Error" /> + <argument index="0" name="path" type="String" /> <description> Loads an editor feature profile from a file. The file must follow the JSON format obtained by using the feature profile manager's [b]Export[/b] button or the [method save_to_file] method. </description> </method> <method name="save_to_file"> - <return type="int" enum="Error"> - </return> - <argument index="0" name="path" type="String"> - </argument> + <return type="int" enum="Error" /> + <argument index="0" name="path" type="String" /> <description> Saves the editor feature profile to a file in JSON format. It can then be imported using the feature profile manager's [b]Import[/b] button or the [method load_from_file] button. </description> </method> <method name="set_disable_class"> - <return type="void"> - </return> - <argument index="0" name="class_name" type="StringName"> - </argument> - <argument index="1" name="disable" type="bool"> - </argument> + <return type="void" /> + <argument index="0" name="class_name" type="StringName" /> + <argument index="1" name="disable" type="bool" /> <description> If [code]disable[/code] is [code]true[/code], disables the class specified by [code]class_name[/code]. When disabled, the class won't appear in the Create New Node dialog. </description> </method> <method name="set_disable_class_editor"> - <return type="void"> - </return> - <argument index="0" name="class_name" type="StringName"> - </argument> - <argument index="1" name="disable" type="bool"> - </argument> + <return type="void" /> + <argument index="0" name="class_name" type="StringName" /> + <argument index="1" name="disable" type="bool" /> <description> If [code]disable[/code] is [code]true[/code], disables editing for the class specified by [code]class_name[/code]. When disabled, the class will still appear in the Create New Node dialog but the inspector will be read-only when selecting a node that extends the class. </description> </method> <method name="set_disable_class_property"> - <return type="void"> - </return> - <argument index="0" name="class_name" type="StringName"> - </argument> - <argument index="1" name="property" type="StringName"> - </argument> - <argument index="2" name="disable" type="bool"> - </argument> + <return type="void" /> + <argument index="0" name="class_name" type="StringName" /> + <argument index="1" name="property" type="StringName" /> + <argument index="2" name="disable" type="bool" /> <description> If [code]disable[/code] is [code]true[/code], disables editing for [code]property[/code] in the class specified by [code]class_name[/code]. When a property is disabled, it won't appear in the inspector when selecting a node that extends the class specified by [code]class_name[/code]. </description> </method> <method name="set_disable_feature"> - <return type="void"> - </return> - <argument index="0" name="feature" type="int" enum="EditorFeatureProfile.Feature"> - </argument> - <argument index="1" name="disable" type="bool"> - </argument> + <return type="void" /> + <argument index="0" name="feature" type="int" enum="EditorFeatureProfile.Feature" /> + <argument index="1" name="disable" type="bool" /> <description> If [code]disable[/code] is [code]true[/code], disables the editor feature specified in [code]feature[/code]. When a feature is disabled, it will disappear from the editor entirely. </description> diff --git a/doc/classes/EditorFileDialog.xml b/doc/classes/EditorFileDialog.xml index 084459e518..53fba9f3b8 100644 --- a/doc/classes/EditorFileDialog.xml +++ b/doc/classes/EditorFileDialog.xml @@ -9,32 +9,27 @@ </tutorials> <methods> <method name="add_filter"> - <return type="void"> - </return> - <argument index="0" name="filter" type="String"> - </argument> + <return type="void" /> + <argument index="0" name="filter" type="String" /> <description> Adds a comma-delimited file extension filter option to the [EditorFileDialog] with an optional semi-colon-delimited label. For example, [code]"*.tscn, *.scn; Scenes"[/code] results in filter text "Scenes (*.tscn, *.scn)". </description> </method> <method name="clear_filters"> - <return type="void"> - </return> + <return type="void" /> <description> Removes all filters except for "All Files (*)". </description> </method> <method name="get_vbox"> - <return type="VBoxContainer"> - </return> + <return type="VBoxContainer" /> <description> Returns the [code]VBoxContainer[/code] used to display the file system. </description> </method> <method name="invalidate"> - <return type="void"> - </return> + <return type="void" /> <description> Notify the [EditorFileDialog] that its view of the data is no longer accurate. Updates the view contents on next view update. </description> @@ -70,22 +65,19 @@ </members> <signals> <signal name="dir_selected"> - <argument index="0" name="dir" type="String"> - </argument> + <argument index="0" name="dir" type="String" /> <description> Emitted when a directory is selected. </description> </signal> <signal name="file_selected"> - <argument index="0" name="path" type="String"> - </argument> + <argument index="0" name="path" type="String" /> <description> Emitted when a file is selected. </description> </signal> <signal name="files_selected"> - <argument index="0" name="paths" type="PackedStringArray"> - </argument> + <argument index="0" name="paths" type="PackedStringArray" /> <description> Emitted when multiple files are selected. </description> diff --git a/doc/classes/EditorFileSystem.xml b/doc/classes/EditorFileSystem.xml index 3a045817c2..6b4a2b03a3 100644 --- a/doc/classes/EditorFileSystem.xml +++ b/doc/classes/EditorFileSystem.xml @@ -11,70 +11,58 @@ </tutorials> <methods> <method name="get_file_type" qualifiers="const"> - <return type="String"> - </return> - <argument index="0" name="path" type="String"> - </argument> + <return type="String" /> + <argument index="0" name="path" type="String" /> <description> Gets the type of the file, given the full path. </description> </method> <method name="get_filesystem"> - <return type="EditorFileSystemDirectory"> - </return> + <return type="EditorFileSystemDirectory" /> <description> Gets the root directory object. </description> </method> <method name="get_filesystem_path"> - <return type="EditorFileSystemDirectory"> - </return> - <argument index="0" name="path" type="String"> - </argument> + <return type="EditorFileSystemDirectory" /> + <argument index="0" name="path" type="String" /> <description> Returns a view into the filesystem at [code]path[/code]. </description> </method> <method name="get_scanning_progress" qualifiers="const"> - <return type="float"> - </return> + <return type="float" /> <description> Returns the scan progress for 0 to 1 if the FS is being scanned. </description> </method> <method name="is_scanning" qualifiers="const"> - <return type="bool"> - </return> + <return type="bool" /> <description> Returns [code]true[/code] of the filesystem is being scanned. </description> </method> <method name="scan"> - <return type="void"> - </return> + <return type="void" /> <description> Scan the filesystem for changes. </description> </method> <method name="scan_sources"> - <return type="void"> - </return> + <return type="void" /> <description> Check if the source of any imported resource changed. </description> </method> <method name="update_file"> - <return type="void"> - </return> - <argument index="0" name="path" type="String"> - </argument> + <return type="void" /> + <argument index="0" name="path" type="String" /> <description> Update a file information. Call this if an external program (not Godot) modified the file. </description> </method> <method name="update_script_classes"> - <return type="void"> - </return> + <return type="void" /> <description> Scans the script files and updates the list of custom class names. </description> @@ -87,22 +75,19 @@ </description> </signal> <signal name="resources_reimported"> - <argument index="0" name="resources" type="PackedStringArray"> - </argument> + <argument index="0" name="resources" type="PackedStringArray" /> <description> Emitted if a resource is reimported. </description> </signal> <signal name="resources_reload"> - <argument index="0" name="resources" type="PackedStringArray"> - </argument> + <argument index="0" name="resources" type="PackedStringArray" /> <description> Emitted if at least one resource is reloaded when the filesystem is scanned. </description> </signal> <signal name="sources_changed"> - <argument index="0" name="exist" type="bool"> - </argument> + <argument index="0" name="exist" type="bool" /> <description> Emitted if the source of any imported file changed. </description> diff --git a/doc/classes/EditorFileSystemDirectory.xml b/doc/classes/EditorFileSystemDirectory.xml index b852ae1063..28793cb8af 100644 --- a/doc/classes/EditorFileSystemDirectory.xml +++ b/doc/classes/EditorFileSystemDirectory.xml @@ -10,117 +10,94 @@ </tutorials> <methods> <method name="find_dir_index" qualifiers="const"> - <return type="int"> - </return> - <argument index="0" name="name" type="String"> - </argument> + <return type="int" /> + <argument index="0" name="name" type="String" /> <description> Returns the index of the directory with name [code]name[/code] or [code]-1[/code] if not found. </description> </method> <method name="find_file_index" qualifiers="const"> - <return type="int"> - </return> - <argument index="0" name="name" type="String"> - </argument> + <return type="int" /> + <argument index="0" name="name" type="String" /> <description> Returns the index of the file with name [code]name[/code] or [code]-1[/code] if not found. </description> </method> <method name="get_file" qualifiers="const"> - <return type="String"> - </return> - <argument index="0" name="idx" type="int"> - </argument> + <return type="String" /> + <argument index="0" name="idx" type="int" /> <description> Returns the name of the file at index [code]idx[/code]. </description> </method> <method name="get_file_count" qualifiers="const"> - <return type="int"> - </return> + <return type="int" /> <description> Returns the number of files in this directory. </description> </method> <method name="get_file_import_is_valid" qualifiers="const"> - <return type="bool"> - </return> - <argument index="0" name="idx" type="int"> - </argument> + <return type="bool" /> + <argument index="0" name="idx" type="int" /> <description> Returns [code]true[/code] if the file at index [code]idx[/code] imported properly. </description> </method> <method name="get_file_path" qualifiers="const"> - <return type="String"> - </return> - <argument index="0" name="idx" type="int"> - </argument> + <return type="String" /> + <argument index="0" name="idx" type="int" /> <description> Returns the path to the file at index [code]idx[/code]. </description> </method> <method name="get_file_script_class_extends" qualifiers="const"> - <return type="String"> - </return> - <argument index="0" name="idx" type="int"> - </argument> + <return type="String" /> + <argument index="0" name="idx" type="int" /> <description> Returns the base class of the script class defined in the file at index [code]idx[/code]. If the file doesn't define a script class using the [code]class_name[/code] syntax, this will return an empty string. </description> </method> <method name="get_file_script_class_name" qualifiers="const"> - <return type="String"> - </return> - <argument index="0" name="idx" type="int"> - </argument> + <return type="String" /> + <argument index="0" name="idx" type="int" /> <description> Returns the name of the script class defined in the file at index [code]idx[/code]. If the file doesn't define a script class using the [code]class_name[/code] syntax, this will return an empty string. </description> </method> <method name="get_file_type" qualifiers="const"> - <return type="StringName"> - </return> - <argument index="0" name="idx" type="int"> - </argument> + <return type="StringName" /> + <argument index="0" name="idx" type="int" /> <description> Returns the file extension of the file at index [code]idx[/code]. </description> </method> <method name="get_name"> - <return type="String"> - </return> + <return type="String" /> <description> Returns the name of this directory. </description> </method> <method name="get_parent"> - <return type="EditorFileSystemDirectory"> - </return> + <return type="EditorFileSystemDirectory" /> <description> Returns the parent directory for this directory or [code]null[/code] if called on a directory at [code]res://[/code] or [code]user://[/code]. </description> </method> <method name="get_path" qualifiers="const"> - <return type="String"> - </return> + <return type="String" /> <description> Returns the path to this directory. </description> </method> <method name="get_subdir"> - <return type="EditorFileSystemDirectory"> - </return> - <argument index="0" name="idx" type="int"> - </argument> + <return type="EditorFileSystemDirectory" /> + <argument index="0" name="idx" type="int" /> <description> Returns the subdirectory at index [code]idx[/code]. </description> </method> <method name="get_subdir_count" qualifiers="const"> - <return type="int"> - </return> + <return type="int" /> <description> Returns the number of subdirectories in this directory. </description> diff --git a/doc/classes/EditorImportPlugin.xml b/doc/classes/EditorImportPlugin.xml index a532e9bc2b..b379ccc8c6 100644 --- a/doc/classes/EditorImportPlugin.xml +++ b/doc/classes/EditorImportPlugin.xml @@ -114,35 +114,28 @@ </tutorials> <methods> <method name="_get_import_options" qualifiers="virtual"> - <return type="Array"> - </return> - <argument index="0" name="preset" type="int"> - </argument> + <return type="Array" /> + <argument index="0" name="preset" type="int" /> <description> Gets the options and default values for the preset at this index. Returns an Array of Dictionaries with the following keys: [code]name[/code], [code]default_value[/code], [code]property_hint[/code] (optional), [code]hint_string[/code] (optional), [code]usage[/code] (optional). </description> </method> <method name="_get_import_order" qualifiers="virtual"> - <return type="int"> - </return> + <return type="int" /> <description> - Gets the order of this importer to be run when importing resources. Higher values will be called later. Use this to ensure the importer runs after the dependencies are already imported. + Gets the order of this importer to be run when importing resources. Importers with [i]lower[/i] import orders will be called first, and higher values will be called later. Use this to ensure the importer runs after the dependencies are already imported. The default import order is [code]0[/code] unless overridden by a specific importer. See [enum ResourceImporter.ImportOrder] for some predefined values. </description> </method> <method name="_get_importer_name" qualifiers="virtual"> - <return type="String"> - </return> + <return type="String" /> <description> Gets the unique name of the importer. </description> </method> <method name="_get_option_visibility" qualifiers="virtual"> - <return type="bool"> - </return> - <argument index="0" name="option" type="String"> - </argument> - <argument index="1" name="options" type="Dictionary"> - </argument> + <return type="bool" /> + <argument index="0" name="option" type="String" /> + <argument index="1" name="options" type="Dictionary" /> <description> This method can be overridden to hide specific import options if conditions are met. This is mainly useful for hiding options that depend on others if one of them is disabled. For example: [codeblocks] @@ -171,69 +164,55 @@ </description> </method> <method name="_get_preset_count" qualifiers="virtual"> - <return type="int"> - </return> + <return type="int" /> <description> Gets the number of initial presets defined by the plugin. Use [method _get_import_options] to get the default options for the preset and [method _get_preset_name] to get the name of the preset. </description> </method> <method name="_get_preset_name" qualifiers="virtual"> - <return type="String"> - </return> - <argument index="0" name="preset" type="int"> - </argument> + <return type="String" /> + <argument index="0" name="preset" type="int" /> <description> Gets the name of the options preset at this index. </description> </method> <method name="_get_priority" qualifiers="virtual"> - <return type="float"> - </return> + <return type="float" /> <description> Gets the priority of this plugin for the recognized extension. Higher priority plugins will be preferred. The default priority is [code]1.0[/code]. </description> </method> <method name="_get_recognized_extensions" qualifiers="virtual"> - <return type="Array"> - </return> + <return type="Array" /> <description> Gets the list of file extensions to associate with this loader (case-insensitive). e.g. [code]["obj"][/code]. </description> </method> <method name="_get_resource_type" qualifiers="virtual"> - <return type="String"> - </return> + <return type="String" /> <description> Gets the Godot resource type associated with this loader. e.g. [code]"Mesh"[/code] or [code]"Animation"[/code]. </description> </method> <method name="_get_save_extension" qualifiers="virtual"> - <return type="String"> - </return> + <return type="String" /> <description> Gets the extension used to save this resource in the [code].godot/imported[/code] directory. </description> </method> <method name="_get_visible_name" qualifiers="virtual"> - <return type="String"> - </return> + <return type="String" /> <description> Gets the name to display in the import window. You should choose this name as a continuation to "Import as", e.g. "Import as Special Mesh". </description> </method> <method name="_import" qualifiers="virtual"> - <return type="int"> - </return> - <argument index="0" name="source_file" type="String"> - </argument> - <argument index="1" name="save_path" type="String"> - </argument> - <argument index="2" name="options" type="Dictionary"> - </argument> - <argument index="3" name="platform_variants" type="Array"> - </argument> - <argument index="4" name="gen_files" type="Array"> - </argument> + <return type="int" /> + <argument index="0" name="source_file" type="String" /> + <argument index="1" name="save_path" type="String" /> + <argument index="2" name="options" type="Dictionary" /> + <argument index="3" name="platform_variants" type="Array" /> + <argument index="4" name="gen_files" type="Array" /> <description> Imports [code]source_file[/code] into [code]save_path[/code] with the import [code]options[/code] specified. The [code]platform_variants[/code] and [code]gen_files[/code] arrays will be modified by this function. This method must be overridden to do the actual importing work. See this class' description for an example of overriding this method. diff --git a/doc/classes/EditorInspector.xml b/doc/classes/EditorInspector.xml index d85f95baff..515c4b4d32 100644 --- a/doc/classes/EditorInspector.xml +++ b/doc/classes/EditorInspector.xml @@ -16,55 +16,46 @@ </members> <signals> <signal name="object_id_selected"> - <argument index="0" name="id" type="int"> - </argument> + <argument index="0" name="id" type="int" /> <description> Emitted when the Edit button of an [Object] has been pressed in the inspector. This is mainly used in the remote scene tree inspector. </description> </signal> <signal name="property_deleted"> - <argument index="0" name="property" type="String"> - </argument> + <argument index="0" name="property" type="String" /> <description> Emitted when a property is removed from the inspector. </description> </signal> <signal name="property_edited"> - <argument index="0" name="property" type="String"> - </argument> + <argument index="0" name="property" type="String" /> <description> Emitted when a property is edited in the inspector. </description> </signal> <signal name="property_keyed"> - <argument index="0" name="property" type="String"> - </argument> + <argument index="0" name="property" type="String" /> <description> Emitted when a property is keyed in the inspector. Properties can be keyed by clicking the "key" icon next to a property when the Animation panel is toggled. </description> </signal> <signal name="property_selected"> - <argument index="0" name="property" type="String"> - </argument> + <argument index="0" name="property" type="String" /> <description> Emitted when a property is selected in the inspector. </description> </signal> <signal name="property_toggled"> - <argument index="0" name="property" type="String"> - </argument> - <argument index="1" name="checked" type="bool"> - </argument> + <argument index="0" name="property" type="String" /> + <argument index="1" name="checked" type="bool" /> <description> Emitted when a boolean property is toggled in the inspector. [b]Note:[/b] This signal is never emitted if the internal [code]autoclear[/code] property enabled. Since this property is always enabled in the editor inspector, this signal is never emitted by the editor itself. </description> </signal> <signal name="resource_selected"> - <argument index="0" name="res" type="Object"> - </argument> - <argument index="1" name="prop" type="String"> - </argument> + <argument index="0" name="res" type="Object" /> + <argument index="1" name="prop" type="String" /> <description> Emitted when a resource is selected in the inspector. </description> diff --git a/doc/classes/EditorInspectorPlugin.xml b/doc/classes/EditorInspectorPlugin.xml index c992d0fbb4..085568466a 100644 --- a/doc/classes/EditorInspectorPlugin.xml +++ b/doc/classes/EditorInspectorPlugin.xml @@ -16,83 +16,62 @@ </tutorials> <methods> <method name="_can_handle" qualifiers="virtual"> - <return type="bool"> - </return> - <argument index="0" name="object" type="Object"> - </argument> + <return type="bool" /> + <argument index="0" name="object" type="Object" /> <description> Returns [code]true[/code] if this object can be handled by this plugin. </description> </method> <method name="_parse_begin" qualifiers="virtual"> - <return type="void"> - </return> + <return type="void" /> <description> Called to allow adding controls at the beginning of the list. </description> </method> <method name="_parse_category" qualifiers="virtual"> - <return type="void"> - </return> - <argument index="0" name="category" type="String"> - </argument> + <return type="void" /> + <argument index="0" name="category" type="String" /> <description> Called to allow adding controls at the beginning of the category. </description> </method> <method name="_parse_end" qualifiers="virtual"> - <return type="void"> - </return> + <return type="void" /> <description> Called to allow adding controls at the end of the list. </description> </method> <method name="_parse_property" qualifiers="virtual"> - <return type="bool"> - </return> - <argument index="0" name="type" type="int"> - </argument> - <argument index="1" name="path" type="String"> - </argument> - <argument index="2" name="hint" type="int"> - </argument> - <argument index="3" name="hint_text" type="String"> - </argument> - <argument index="4" name="usage" type="int"> - </argument> + <return type="bool" /> + <argument index="0" name="type" type="int" /> + <argument index="1" name="path" type="String" /> + <argument index="2" name="hint" type="int" /> + <argument index="3" name="hint_text" type="String" /> + <argument index="4" name="usage" type="int" /> <description> Called to allow adding property specific editors to the inspector. Usually these inherit [EditorProperty]. Returning [code]true[/code] removes the built-in editor for this property, otherwise allows to insert a custom editor before the built-in one. </description> </method> <method name="add_custom_control"> - <return type="void"> - </return> - <argument index="0" name="control" type="Control"> - </argument> + <return type="void" /> + <argument index="0" name="control" type="Control" /> <description> Adds a custom control, not necessarily a property editor. </description> </method> <method name="add_property_editor"> - <return type="void"> - </return> - <argument index="0" name="property" type="String"> - </argument> - <argument index="1" name="editor" type="Control"> - </argument> + <return type="void" /> + <argument index="0" name="property" type="String" /> + <argument index="1" name="editor" type="Control" /> <description> Adds a property editor, this must inherit [EditorProperty]. </description> </method> <method name="add_property_editor_for_multiple_properties"> - <return type="void"> - </return> - <argument index="0" name="label" type="String"> - </argument> - <argument index="1" name="properties" type="PackedStringArray"> - </argument> - <argument index="2" name="editor" type="Control"> - </argument> + <return type="void" /> + <argument index="0" name="label" type="String" /> + <argument index="1" name="properties" type="PackedStringArray" /> + <argument index="2" name="editor" type="Control" /> <description> Adds an editor that allows modifying multiple properties, this must inherit [EditorProperty]. </description> diff --git a/doc/classes/EditorInterface.xml b/doc/classes/EditorInterface.xml index 3f324bf1a0..185b4f8c39 100644 --- a/doc/classes/EditorInterface.xml +++ b/doc/classes/EditorInterface.xml @@ -11,267 +11,217 @@ </tutorials> <methods> <method name="edit_node"> - <return type="void"> - </return> - <argument index="0" name="node" type="Node"> - </argument> + <return type="void" /> + <argument index="0" name="node" type="Node" /> <description> Edits the given [Node]. The node will be also selected if it's inside the scene tree. </description> </method> <method name="edit_resource"> - <return type="void"> - </return> - <argument index="0" name="resource" type="Resource"> - </argument> + <return type="void" /> + <argument index="0" name="resource" type="Resource" /> <description> Edits the given [Resource]. </description> </method> <method name="get_base_control"> - <return type="Control"> - </return> + <return type="Control" /> <description> Returns the main container of Godot editor's window. For example, you can use it to retrieve the size of the container and place your controls accordingly. </description> </method> <method name="get_current_path" qualifiers="const"> - <return type="String"> - </return> + <return type="String" /> <description> Returns the current path being viewed in the [FileSystemDock]. </description> </method> <method name="get_edited_scene_root"> - <return type="Node"> - </return> + <return type="Node" /> <description> Returns the edited (current) scene's root [Node]. </description> </method> <method name="get_editor_main_control"> - <return type="Control"> - </return> + <return type="Control" /> <description> Returns the main editor control. Use this as a parent for main screens. [b]Note:[/b] This returns the main editor control containing the whole editor, not the 2D or 3D viewports specifically. </description> </method> <method name="get_editor_paths"> - <return type="EditorPaths"> - </return> + <return type="EditorPaths" /> <description> </description> </method> <method name="get_editor_scale" qualifiers="const"> - <return type="float"> - </return> + <return type="float" /> <description> Returns the actual scale of the editor UI ([code]1.0[/code] being 100% scale). This can be used to adjust position and dimensions of the UI added by plugins. [b]Note:[/b] This value is set via the [code]interface/editor/display_scale[/code] and [code]interface/editor/custom_display_scale[/code] editor settings. Editor must be restarted for changes to be properly applied. </description> </method> <method name="get_editor_settings"> - <return type="EditorSettings"> - </return> + <return type="EditorSettings" /> <description> Returns the editor's [EditorSettings] instance. </description> </method> <method name="get_file_system_dock"> - <return type="FileSystemDock"> - </return> + <return type="FileSystemDock" /> <description> Returns the editor's [FileSystemDock] instance. </description> </method> <method name="get_inspector" qualifiers="const"> - <return type="EditorInspector"> - </return> + <return type="EditorInspector" /> <description> Returns the editor's [EditorInspector] instance. </description> </method> <method name="get_open_scenes" qualifiers="const"> - <return type="Array"> - </return> + <return type="Array" /> <description> Returns an [Array] with the file paths of the currently opened scenes. </description> </method> <method name="get_playing_scene" qualifiers="const"> - <return type="String"> - </return> + <return type="String" /> <description> Returns the name of the scene that is being played. If no scene is currently being played, returns an empty string. </description> </method> <method name="get_resource_filesystem"> - <return type="EditorFileSystem"> - </return> + <return type="EditorFileSystem" /> <description> Returns the editor's [EditorFileSystem] instance. </description> </method> <method name="get_resource_previewer"> - <return type="EditorResourcePreview"> - </return> + <return type="EditorResourcePreview" /> <description> Returns the editor's [EditorResourcePreview] instance. </description> </method> <method name="get_script_editor"> - <return type="ScriptEditor"> - </return> + <return type="ScriptEditor" /> <description> Returns the editor's [ScriptEditor] instance. </description> </method> <method name="get_selected_path" qualifiers="const"> - <return type="String"> - </return> + <return type="String" /> <description> Returns the path of the directory currently selected in the [FileSystemDock]. If a file is selected, its base directory will be returned using [method String.get_base_dir] instead. </description> </method> <method name="get_selection"> - <return type="EditorSelection"> - </return> + <return type="EditorSelection" /> <description> Returns the editor's [EditorSelection] instance. </description> </method> <method name="inspect_object"> - <return type="void"> - </return> - <argument index="0" name="object" type="Object"> - </argument> - <argument index="1" name="for_property" type="String" default=""""> - </argument> - <argument index="2" name="inspector_only" type="bool" default="false"> - </argument> + <return type="void" /> + <argument index="0" name="object" type="Object" /> + <argument index="1" name="for_property" type="String" default="""" /> + <argument index="2" name="inspector_only" type="bool" default="false" /> <description> Shows the given property on the given [code]object[/code] in the editor's Inspector dock. If [code]inspector_only[/code] is [code]true[/code], plugins will not attempt to edit [code]object[/code]. </description> </method> <method name="is_playing_scene" qualifiers="const"> - <return type="bool"> - </return> + <return type="bool" /> <description> Returns [code]true[/code] if a scene is currently being played, [code]false[/code] otherwise. Paused scenes are considered as being played. </description> </method> <method name="is_plugin_enabled" qualifiers="const"> - <return type="bool"> - </return> - <argument index="0" name="plugin" type="String"> - </argument> + <return type="bool" /> + <argument index="0" name="plugin" type="String" /> <description> Returns [code]true[/code] if the specified [code]plugin[/code] is enabled. The plugin name is the same as its directory name. </description> </method> <method name="make_mesh_previews"> - <return type="Array"> - </return> - <argument index="0" name="meshes" type="Array"> - </argument> - <argument index="1" name="preview_size" type="int"> - </argument> + <return type="Array" /> + <argument index="0" name="meshes" type="Array" /> + <argument index="1" name="preview_size" type="int" /> <description> Returns mesh previews rendered at the given size as an [Array] of [Texture2D]s. </description> </method> <method name="open_scene_from_path"> - <return type="void"> - </return> - <argument index="0" name="scene_filepath" type="String"> - </argument> + <return type="void" /> + <argument index="0" name="scene_filepath" type="String" /> <description> Opens the scene at the given path. </description> </method> <method name="play_current_scene"> - <return type="void"> - </return> + <return type="void" /> <description> Plays the currently active scene. </description> </method> <method name="play_custom_scene"> - <return type="void"> - </return> - <argument index="0" name="scene_filepath" type="String"> - </argument> + <return type="void" /> + <argument index="0" name="scene_filepath" type="String" /> <description> Plays the scene specified by its filepath. </description> </method> <method name="play_main_scene"> - <return type="void"> - </return> + <return type="void" /> <description> Plays the main scene. </description> </method> <method name="reload_scene_from_path"> - <return type="void"> - </return> - <argument index="0" name="scene_filepath" type="String"> - </argument> + <return type="void" /> + <argument index="0" name="scene_filepath" type="String" /> <description> Reloads the scene at the given path. </description> </method> <method name="save_scene"> - <return type="int" enum="Error"> - </return> + <return type="int" enum="Error" /> <description> Saves the scene. Returns either [code]OK[/code] or [code]ERR_CANT_CREATE[/code] (see [@GlobalScope] constants). </description> </method> <method name="save_scene_as"> - <return type="void"> - </return> - <argument index="0" name="path" type="String"> - </argument> - <argument index="1" name="with_preview" type="bool" default="true"> - </argument> + <return type="void" /> + <argument index="0" name="path" type="String" /> + <argument index="1" name="with_preview" type="bool" default="true" /> <description> Saves the scene as a file at [code]path[/code]. </description> </method> <method name="select_file"> - <return type="void"> - </return> - <argument index="0" name="file" type="String"> - </argument> + <return type="void" /> + <argument index="0" name="file" type="String" /> <description> Selects the file, with the path provided by [code]file[/code], in the FileSystem dock. </description> </method> <method name="set_main_screen_editor"> - <return type="void"> - </return> - <argument index="0" name="name" type="String"> - </argument> + <return type="void" /> + <argument index="0" name="name" type="String" /> <description> Sets the editor's current main screen to the one specified in [code]name[/code]. [code]name[/code] must match the text of the tab in question exactly ([code]2D[/code], [code]3D[/code], [code]Script[/code], [code]AssetLib[/code]). </description> </method> <method name="set_plugin_enabled"> - <return type="void"> - </return> - <argument index="0" name="plugin" type="String"> - </argument> - <argument index="1" name="enabled" type="bool"> - </argument> + <return type="void" /> + <argument index="0" name="plugin" type="String" /> + <argument index="1" name="enabled" type="bool" /> <description> Sets the enabled status of a plugin. The plugin name is the same as its directory name. </description> </method> <method name="stop_playing_scene"> - <return type="void"> - </return> + <return type="void" /> <description> Stops the scene that is currently playing. </description> diff --git a/doc/classes/EditorNode3DGizmo.xml b/doc/classes/EditorNode3DGizmo.xml index 221b5e44d6..39f6805254 100644 --- a/doc/classes/EditorNode3DGizmo.xml +++ b/doc/classes/EditorNode3DGizmo.xml @@ -1,189 +1,198 @@ <?xml version="1.0" encoding="UTF-8" ?> <class name="EditorNode3DGizmo" inherits="Node3DGizmo" version="4.0"> <brief_description> - Custom gizmo for editing Node3D objects. + Gizmo for editing Node3D objects. </brief_description> <description> - Custom gizmo that is used for providing custom visualization and editing (handles) for Node3D objects. See [EditorNode3DGizmoPlugin] for more information. + Gizmo that is used for providing custom visualization and editing (handles and subgizmos) for Node3D objects. Can be overridden to create custom gizmos, but for simple gizmos creating a [EditorNode3DGizmoPlugin] is usually recommended. </description> <tutorials> </tutorials> <methods> <method name="_commit_handle" qualifiers="virtual"> - <return type="void"> - </return> - <argument index="0" name="index" type="int"> - </argument> - <argument index="1" name="restore" type="Variant"> - </argument> - <argument index="2" name="cancel" type="bool" default="false"> - </argument> + <return type="void" /> + <argument index="0" name="id" type="int" /> + <argument index="1" name="restore" type="Variant" /> + <argument index="2" name="cancel" type="bool" default="false" /> <description> - Commit a handle being edited (handles must have been previously added by [method add_handles]). - If the [code]cancel[/code] parameter is [code]true[/code], an option to restore the edited value to the original is provided. + Override this method to commit a handle being edited (handles must have been previously added by [method add_handles]). This usually means creating an [UndoRedo] action for the change, using the current handle value as "do" and the [code]restore[/code] argument as "undo". + If the [code]cancel[/code] argument is [code]true[/code], the [code]restore[/code] value should be directly set, without any [UndoRedo] action. + </description> + </method> + <method name="_commit_subgizmos" qualifiers="virtual"> + <return type="void" /> + <argument index="0" name="ids" type="PackedInt32Array" /> + <argument index="1" name="restore" type="Array" /> + <argument index="2" name="cancel" type="bool" default="false" /> + <description> + Override this method to commit a group of subgizmos being edited (see [method _subgizmos_intersect_ray] and [method _subgizmos_intersect_frustum]). This usually means creating an [UndoRedo] action for the change, using the current transforms as "do" and the [code]restore[/code] transforms as "undo". + If the [code]cancel[/code] argument is [code]true[/code], the [code]restore[/code] transforms should be directly set, without any [UndoRedo] action. </description> </method> <method name="_get_handle_name" qualifiers="virtual"> - <return type="String"> - </return> - <argument index="0" name="index" type="int"> - </argument> + <return type="String" /> + <argument index="0" name="id" type="int" /> <description> - Gets the name of an edited handle (handles must have been previously added by [method add_handles]). + Override this method to return the name of an edited handle (handles must have been previously added by [method add_handles]). Handles can be named for reference to the user when editing. </description> </method> <method name="_get_handle_value" qualifiers="virtual"> - <return type="Variant"> - </return> - <argument index="0" name="index" type="int"> - </argument> + <return type="Variant" /> + <argument index="0" name="id" type="int" /> + <description> + Override this method to return the current value of a handle. This value will be requested at the start of an edit and used as the [code]restore[/code] argument in [method _commit_handle]. + </description> + </method> + <method name="_get_subgizmo_transform" qualifiers="virtual"> + <return type="Transform3D" /> + <argument index="0" name="id" type="int" /> <description> - Gets actual value of a handle. This value can be anything and used for eventually undoing the motion when calling [method _commit_handle]. + Override this method to return the current transform of a subgizmo. This transform will be requested at the start of an edit and used as the [code]restore[/code] argument in [method _commit_subgizmos]. </description> </method> <method name="_is_handle_highlighted" qualifiers="virtual"> - <return type="bool"> - </return> - <argument index="0" name="index" type="int"> - </argument> + <return type="bool" /> + <argument index="0" name="id" type="int" /> <description> - Returns [code]true[/code] if the handle at index [code]index[/code] is highlighted by being hovered with the mouse. + Override this method to return [code]true[/code] whenever the given handle should be highlighted in the editor. </description> </method> <method name="_redraw" qualifiers="virtual"> - <return type="void"> - </return> + <return type="void" /> <description> - This function is called when the [Node3D] this gizmo refers to changes (the [method Node3D.update_gizmo] is called). + Override this method to add all the gizmo elements whenever a gizmo update is requested. It's common to call [method clear] at the beginning of this method and then add visual elements depending on the node's properties. </description> </method> <method name="_set_handle" qualifiers="virtual"> - <return type="void"> - </return> - <argument index="0" name="index" type="int"> - </argument> - <argument index="1" name="camera" type="Camera3D"> - </argument> - <argument index="2" name="point" type="Vector2"> - </argument> + <return type="void" /> + <argument index="0" name="id" type="int" /> + <argument index="1" name="camera" type="Camera3D" /> + <argument index="2" name="point" type="Vector2" /> <description> - This function is used when the user drags a gizmo handle (previously added with [method add_handles]) in screen coordinates. - The [Camera3D] is also provided so screen coordinates can be converted to raycasts. + Override this method to update the node properties when the user drags a gizmo handle (previously added with [method add_handles]). The provided [code]point[/code] is the mouse position in screen coordinates and the [code]camera[/code] can be used to convert it to raycasts. + </description> + </method> + <method name="_set_subgizmo_transform" qualifiers="virtual"> + <return type="void" /> + <argument index="0" name="id" type="int" /> + <argument index="1" name="transform" type="Transform3D" /> + <description> + Override this method to update the node properties during subgizmo editing (see [method _subgizmos_intersect_ray] and [method _subgizmos_intersect_frustum]). The [code]transform[/code] is given in the Node3D's local coordinate system. + </description> + </method> + <method name="_subgizmos_intersect_frustum" qualifiers="virtual"> + <return type="PackedInt32Array" /> + <argument index="0" name="camera" type="Camera3D" /> + <argument index="1" name="frustum" type="Array" /> + <description> + Override this method to allow selecting subgizmos using mouse drag box selection. Given a [code]camera[/code] and a [code]frustum[/code], this method should return which subgizmos are contained within the frustum. The [code]frustum[/code] argument consists of an [code]Array[/code] with all the [code]Plane[/code]s that make up the selection frustum. The returned value should contain a list of unique subgizmo identifiers, which can have any non-negative value and will be used in other virtual methods like [method _get_subgizmo_transform] or [method _commit_subgizmos]. + </description> + </method> + <method name="_subgizmos_intersect_ray" qualifiers="virtual"> + <return type="int" /> + <argument index="0" name="camera" type="Camera3D" /> + <argument index="1" name="point" type="Vector2" /> + <description> + Override this method to allow selecting subgizmos using mouse clicks. Given a [code]camera[/code] and a [code]point[/code] in screen coordinates, this method should return which subgizmo should be selected. The returned value should be a unique subgizmo identifier, which can have any non-negative value and will be used in other virtual methods like [method _get_subgizmo_transform] or [method _commit_subgizmos]. </description> </method> <method name="add_collision_segments"> - <return type="void"> - </return> - <argument index="0" name="segments" type="PackedVector3Array"> - </argument> + <return type="void" /> + <argument index="0" name="segments" type="PackedVector3Array" /> <description> - Adds the specified [code]segments[/code] to the gizmo's collision shape for picking. Call this function during [method _redraw]. + Adds the specified [code]segments[/code] to the gizmo's collision shape for picking. Call this method during [method _redraw]. </description> </method> <method name="add_collision_triangles"> - <return type="void"> - </return> - <argument index="0" name="triangles" type="TriangleMesh"> - </argument> + <return type="void" /> + <argument index="0" name="triangles" type="TriangleMesh" /> <description> - Adds collision triangles to the gizmo for picking. A [TriangleMesh] can be generated from a regular [Mesh] too. Call this function during [method _redraw]. + Adds collision triangles to the gizmo for picking. A [TriangleMesh] can be generated from a regular [Mesh] too. Call this method during [method _redraw]. </description> </method> <method name="add_handles"> - <return type="void"> - </return> - <argument index="0" name="handles" type="PackedVector3Array"> - </argument> - <argument index="1" name="material" type="Material"> - </argument> - <argument index="2" name="billboard" type="bool" default="false"> - </argument> - <argument index="3" name="secondary" type="bool" default="false"> - </argument> + <return type="void" /> + <argument index="0" name="handles" type="PackedVector3Array" /> + <argument index="1" name="material" type="Material" /> + <argument index="2" name="ids" type="PackedInt32Array" /> + <argument index="3" name="billboard" type="bool" default="false" /> + <argument index="4" name="secondary" type="bool" default="false" /> <description> - Adds a list of handles (points) which can be used to deform the object being edited. - There are virtual functions which will be called upon editing of these handles. Call this function during [method _redraw]. + Adds a list of handles (points) which can be used to edit the properties of the gizmo's Node3D. The [code]ids[/code] argument can be used to specify a custom identifier for each handle, if an empty [code]Array[/code] is passed, the ids will be assigned automatically from the [code]handles[/code] argument order. + There are virtual methods which will be called upon editing of these handles. Call this method during [method _redraw]. </description> </method> <method name="add_lines"> - <return type="void"> - </return> - <argument index="0" name="lines" type="PackedVector3Array"> - </argument> - <argument index="1" name="material" type="Material"> - </argument> - <argument index="2" name="billboard" type="bool" default="false"> - </argument> - <argument index="3" name="modulate" type="Color" default="Color(1, 1, 1, 1)"> - </argument> + <return type="void" /> + <argument index="0" name="lines" type="PackedVector3Array" /> + <argument index="1" name="material" type="Material" /> + <argument index="2" name="billboard" type="bool" default="false" /> + <argument index="3" name="modulate" type="Color" default="Color(1, 1, 1, 1)" /> <description> - Adds lines to the gizmo (as sets of 2 points), with a given material. The lines are used for visualizing the gizmo. Call this function during [method _redraw]. + Adds lines to the gizmo (as sets of 2 points), with a given material. The lines are used for visualizing the gizmo. Call this method during [method _redraw]. </description> </method> <method name="add_mesh"> - <return type="void"> - </return> - <argument index="0" name="mesh" type="ArrayMesh"> - </argument> - <argument index="1" name="billboard" type="bool" default="false"> - </argument> - <argument index="2" name="skeleton" type="SkinReference" default="null"> - </argument> - <argument index="3" name="material" type="Material" default="null"> - </argument> + <return type="void" /> + <argument index="0" name="mesh" type="ArrayMesh" /> + <argument index="1" name="material" type="Material" default="null" /> + <argument index="2" name="transform" type="Transform3D" default="Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0)" /> + <argument index="3" name="skeleton" type="SkinReference" default="null" /> <description> - Adds a mesh to the gizmo with the specified [code]billboard[/code] state, [code]skeleton[/code] and [code]material[/code]. If [code]billboard[/code] is [code]true[/code], the mesh will rotate to always face the camera. Call this function during [method _redraw]. + Adds a mesh to the gizmo with the specified [code]material[/code], local [code]transform[/code] and [code]skeleton[/code]. Call this method during [method _redraw]. </description> </method> <method name="add_unscaled_billboard"> - <return type="void"> - </return> - <argument index="0" name="material" type="Material"> - </argument> - <argument index="1" name="default_scale" type="float" default="1"> - </argument> - <argument index="2" name="modulate" type="Color" default="Color(1, 1, 1, 1)"> - </argument> + <return type="void" /> + <argument index="0" name="material" type="Material" /> + <argument index="1" name="default_scale" type="float" default="1" /> + <argument index="2" name="modulate" type="Color" default="Color(1, 1, 1, 1)" /> <description> - Adds an unscaled billboard for visualization. Call this function during [method _redraw]. + Adds an unscaled billboard for visualization and selection. Call this method during [method _redraw]. </description> </method> <method name="clear"> - <return type="void"> - </return> + <return type="void" /> <description> Removes everything in the gizmo including meshes, collisions and handles. </description> </method> <method name="get_plugin" qualifiers="const"> - <return type="EditorNode3DGizmoPlugin"> - </return> + <return type="EditorNode3DGizmoPlugin" /> <description> Returns the [EditorNode3DGizmoPlugin] that owns this gizmo. It's useful to retrieve materials using [method EditorNode3DGizmoPlugin.get_material]. </description> </method> <method name="get_spatial_node" qualifiers="const"> - <return type="Node3D"> - </return> + <return type="Node3D" /> <description> Returns the Node3D node associated with this gizmo. </description> </method> + <method name="get_subgizmo_selection" qualifiers="const"> + <return type="PackedInt32Array" /> + <description> + Returns a list of the currently selected subgizmos. Can be used to highlight selected elements during [method _redraw]. + </description> + </method> + <method name="is_subgizmo_selected" qualifiers="const"> + <return type="bool" /> + <argument index="0" name="arg0" type="int" /> + <description> + Returns [code]true[/code] if the given subgizmo is currently selected. Can be used to highlight selected elements during [method _redraw]. + </description> + </method> <method name="set_hidden"> - <return type="void"> - </return> - <argument index="0" name="hidden" type="bool"> - </argument> + <return type="void" /> + <argument index="0" name="hidden" type="bool" /> <description> Sets the gizmo's hidden state. If [code]true[/code], the gizmo will be hidden. If [code]false[/code], it will be shown. </description> </method> <method name="set_spatial_node"> - <return type="void"> - </return> - <argument index="0" name="node" type="Node"> - </argument> + <return type="void" /> + <argument index="0" name="node" type="Node" /> <description> Sets the reference [Node3D] node for the gizmo. [code]node[/code] must inherit from [Node3D]. </description> diff --git a/doc/classes/EditorNode3DGizmoPlugin.xml b/doc/classes/EditorNode3DGizmoPlugin.xml index 41c94cbbc6..fb72427a7a 100644 --- a/doc/classes/EditorNode3DGizmoPlugin.xml +++ b/doc/classes/EditorNode3DGizmoPlugin.xml @@ -11,188 +11,185 @@ </tutorials> <methods> <method name="_can_be_hidden" qualifiers="virtual"> - <return type="bool"> - </return> + <return type="bool" /> <description> - Override this method to define whether the gizmo can be hidden or not. Returns [code]true[/code] if not overridden. + Override this method to define whether the gizmos handled by this plugin can be hidden or not. Returns [code]true[/code] if not overridden. </description> </method> <method name="_commit_handle" qualifiers="virtual"> - <return type="void"> - </return> - <argument index="0" name="gizmo" type="EditorNode3DGizmo"> - </argument> - <argument index="1" name="index" type="int"> - </argument> - <argument index="2" name="restore" type="Variant"> - </argument> - <argument index="3" name="cancel" type="bool" default="false"> - </argument> + <return type="void" /> + <argument index="0" name="gizmo" type="EditorNode3DGizmo" /> + <argument index="1" name="id" type="int" /> + <argument index="2" name="restore" type="Variant" /> + <argument index="3" name="cancel" type="bool" default="false" /> <description> - Override this method to commit gizmo handles. Called for this plugin's active gizmos. + Override this method to commit a handle being edited (handles must have been previously added by [method EditorNode3DGizmo.add_handles] during [method _redraw]). This usually means creating an [UndoRedo] action for the change, using the current handle value as "do" and the [code]restore[/code] argument as "undo". + If the [code]cancel[/code] argument is [code]true[/code], the [code]restore[/code] value should be directly set, without any [UndoRedo] action. Called for this plugin's active gizmos. + </description> + </method> + <method name="_commit_subgizmos" qualifiers="virtual"> + <return type="void" /> + <argument index="0" name="gizmo" type="EditorNode3DGizmo" /> + <argument index="1" name="ids" type="PackedInt32Array" /> + <argument index="2" name="restore" type="Array" /> + <argument index="3" name="cancel" type="bool" default="false" /> + <description> + Override this method to commit a group of subgizmos being edited (see [method _subgizmos_intersect_ray] and [method _subgizmos_intersect_frustum]). This usually means creating an [UndoRedo] action for the change, using the current transforms as "do" and the [code]restore[/code] transforms as "undo". + If the [code]cancel[/code] argument is [code]true[/code], the [code]restore[/code] transforms should be directly set, without any [UndoRedo] action. As with all subgizmo methods, transforms are given in local space respect to the gizmo's Node3D. Called for this plugin's active gizmos. </description> </method> <method name="_create_gizmo" qualifiers="virtual"> - <return type="EditorNode3DGizmo"> - </return> - <argument index="0" name="spatial" type="Node3D"> - </argument> + <return type="EditorNode3DGizmo" /> + <argument index="0" name="spatial" 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]. </description> </method> <method name="_get_gizmo_name" qualifiers="virtual"> - <return type="String"> - </return> + <return type="String" /> <description> Override this method to provide the name that will appear in the gizmo visibility menu. </description> </method> <method name="_get_handle_name" qualifiers="virtual"> - <return type="String"> - </return> - <argument index="0" name="gizmo" type="EditorNode3DGizmo"> - </argument> - <argument index="1" name="index" type="int"> - </argument> + <return type="String" /> + <argument index="0" name="gizmo" type="EditorNode3DGizmo" /> + <argument index="1" name="id" type="int" /> <description> Override this method to provide gizmo's handle names. Called for this plugin's active gizmos. </description> </method> <method name="_get_handle_value" qualifiers="virtual"> - <return type="Variant"> - </return> - <argument index="0" name="gizmo" type="EditorNode3DGizmo"> - </argument> - <argument index="1" name="index" type="int"> - </argument> + <return type="Variant" /> + <argument index="0" name="gizmo" type="EditorNode3DGizmo" /> + <argument index="1" name="id" type="int" /> <description> - Gets actual value of a handle from gizmo. Called for this plugin's active gizmos. + Override this method to return the current value of a handle. This value will be requested at the start of an edit and used as the [code]restore[/code] argument in [method _commit_handle]. Called for this plugin's active gizmos. </description> </method> <method name="_get_priority" qualifiers="virtual"> - <return type="int"> - </return> + <return type="int" /> + <description> + Override this method to set the gizmo's priority. Gizmos with higher priority will have precedence when processing inputs like handles or subgizmos selection. + All built-in editor gizmos return a priority of [code]-1[/code]. If not overridden, this method will return [code]0[/code], which means custom gizmos will automatically get higher priority than built-in gizmos. + </description> + </method> + <method name="_get_subgizmo_transform" qualifiers="virtual"> + <return type="Transform3D" /> + <argument index="0" name="gizmo" type="EditorNode3DGizmo" /> + <argument index="1" name="id" type="int" /> <description> - Override this method to set the gizmo's priority. Higher values correspond to higher priority. If a gizmo with higher priority conflicts with another gizmo, only the gizmo with higher priority will be used. - All built-in editor gizmos return a priority of [code]-1[/code]. If not overridden, this method will return [code]0[/code], which means custom gizmos will automatically override built-in gizmos. + Override this method to return the current transform of a subgizmo. As with all subgizmo methods, the transform should be in local space respect to the gizmo's Node3D. This transform will be requested at the start of an edit and used in the [code]restore[/code] argument in [method _commit_subgizmos]. Called for this plugin's active gizmos. </description> </method> <method name="_has_gizmo" qualifiers="virtual"> - <return type="bool"> - </return> - <argument index="0" name="spatial" type="Node3D"> - </argument> + <return type="bool" /> + <argument index="0" name="spatial" type="Node3D" /> <description> Override this method to define which Node3D nodes have a gizmo from this plugin. Whenever a [Node3D] node is added to a scene this method is called, if it returns [code]true[/code] the node gets a generic [EditorNode3DGizmo] assigned and is added to this plugin's list of active gizmos. </description> </method> <method name="_is_handle_highlighted" qualifiers="virtual"> - <return type="bool"> - </return> - <argument index="0" name="gizmo" type="EditorNode3DGizmo"> - </argument> - <argument index="1" name="index" type="int"> - </argument> + <return type="bool" /> + <argument index="0" name="gizmo" type="EditorNode3DGizmo" /> + <argument index="1" name="id" type="int" /> <description> - Gets whether a handle is highlighted or not. Called for this plugin's active gizmos. + Override this method to return [code]true[/code] whenever to given handle should be highlighted in the editor. Called for this plugin's active gizmos. </description> </method> <method name="_is_selectable_when_hidden" qualifiers="virtual"> - <return type="bool"> - </return> + <return type="bool" /> <description> Override this method to define whether Node3D with this gizmo should be selectable even when the gizmo is hidden. </description> </method> <method name="_redraw" qualifiers="virtual"> - <return type="void"> - </return> - <argument index="0" name="gizmo" type="EditorNode3DGizmo"> - </argument> + <return type="void" /> + <argument index="0" name="gizmo" type="EditorNode3DGizmo" /> <description> - Callback to redraw the provided gizmo. Called for this plugin's active gizmos. + Override this method to add all the gizmo elements whenever a gizmo update is requested. It's common to call [method EditorNode3DGizmo.clear] at the beginning of this method and then add visual elements depending on the node's properties. </description> </method> <method name="_set_handle" qualifiers="virtual"> - <return type="void"> - </return> - <argument index="0" name="gizmo" type="EditorNode3DGizmo"> - </argument> - <argument index="1" name="index" type="int"> - </argument> - <argument index="2" name="camera" type="Camera3D"> - </argument> - <argument index="3" name="point" type="Vector2"> - </argument> + <return type="void" /> + <argument index="0" name="gizmo" type="EditorNode3DGizmo" /> + <argument index="1" name="id" type="int" /> + <argument index="2" name="camera" type="Camera3D" /> + <argument index="3" name="point" type="Vector2" /> + <description> + Override this method to update the node's properties when the user drags a gizmo handle (previously added with [method EditorNode3DGizmo.add_handles]). The provided [code]point[/code] is the mouse position in screen coordinates and the [code]camera[/code] can be used to convert it to raycasts. Called for this plugin's active gizmos. + </description> + </method> + <method name="_set_subgizmo_transform" qualifiers="virtual"> + <return type="void" /> + <argument index="0" name="gizmo" type="EditorNode3DGizmo" /> + <argument index="1" name="id" type="int" /> + <argument index="2" name="transform" type="Transform3D" /> + <description> + Override this method to update the node properties during subgizmo editing (see [method _subgizmos_intersect_ray] and [method _subgizmos_intersect_frustum]). The [code]transform[/code] is given in the Node3D's local coordinate system. Called for this plugin's active gizmos. + </description> + </method> + <method name="_subgizmos_intersect_frustum" qualifiers="virtual"> + <return type="PackedInt32Array" /> + <argument index="0" name="gizmo" type="EditorNode3DGizmo" /> + <argument index="1" name="camera" type="Camera3D" /> + <argument index="2" name="frustum" type="Array" /> + <description> + Override this method to allow selecting subgizmos using mouse drag box selection. Given a [code]camera[/code] and a [code]frustum[/code], this method should return which subgizmos are contained within the frustum. The [code]frustum[/code] argument consists of an [code]Array[/code] with all the [code]Plane[/code]s that make up the selection frustum. The returned value should contain a list of unique subgizmo identifiers, these identifiers can have any non-negative value and will be used in other virtual methods like [method _get_subgizmo_transform] or [method _commit_subgizmos]. Called for this plugin's active gizmos. + </description> + </method> + <method name="_subgizmos_intersect_ray" qualifiers="virtual"> + <return type="int" /> + <argument index="0" name="gizmo" type="EditorNode3DGizmo" /> + <argument index="1" name="camera" type="Camera3D" /> + <argument index="2" name="point" type="Vector2" /> <description> - Update the value of a handle after it has been updated. Called for this plugin's active gizmos. + Override this method to allow selecting subgizmos using mouse clicks. Given a [code]camera[/code] and a [code]point[/code] in screen coordinates, this method should return which subgizmo should be selected. The returned value should be a unique subgizmo identifier, which can have any non-negative value and will be used in other virtual methods like [method _get_subgizmo_transform] or [method _commit_subgizmos]. Called for this plugin's active gizmos. </description> </method> <method name="add_material"> - <return type="void"> - </return> - <argument index="0" name="name" type="String"> - </argument> - <argument index="1" name="material" type="StandardMaterial3D"> - </argument> + <return type="void" /> + <argument index="0" name="name" type="String" /> + <argument index="1" name="material" type="StandardMaterial3D" /> <description> Adds a new material to the internal material list for the plugin. It can then be accessed with [method get_material]. Should not be overridden. </description> </method> <method name="create_handle_material"> - <return type="void"> - </return> - <argument index="0" name="name" type="String"> - </argument> - <argument index="1" name="billboard" type="bool" default="false"> - </argument> - <argument index="2" name="texture" type="Texture2D" default="null"> - </argument> + <return type="void" /> + <argument index="0" name="name" type="String" /> + <argument index="1" name="billboard" type="bool" default="false" /> + <argument index="2" name="texture" type="Texture2D" default="null" /> <description> Creates a handle material with its variants (selected and/or editable) and adds them to the internal material list. They can then be accessed with [method get_material] and used in [method EditorNode3DGizmo.add_handles]. Should not be overridden. You can optionally provide a texture to use instead of the default icon. </description> </method> <method name="create_icon_material"> - <return type="void"> - </return> - <argument index="0" name="name" type="String"> - </argument> - <argument index="1" name="texture" type="Texture2D"> - </argument> - <argument index="2" name="on_top" type="bool" default="false"> - </argument> - <argument index="3" name="color" type="Color" default="Color(1, 1, 1, 1)"> - </argument> + <return type="void" /> + <argument index="0" name="name" type="String" /> + <argument index="1" name="texture" type="Texture2D" /> + <argument index="2" name="on_top" type="bool" default="false" /> + <argument index="3" name="color" type="Color" default="Color(1, 1, 1, 1)" /> <description> Creates an icon material with its variants (selected and/or editable) and adds them to the internal material list. They can then be accessed with [method get_material] and used in [method EditorNode3DGizmo.add_unscaled_billboard]. Should not be overridden. </description> </method> <method name="create_material"> - <return type="void"> - </return> - <argument index="0" name="name" type="String"> - </argument> - <argument index="1" name="color" type="Color"> - </argument> - <argument index="2" name="billboard" type="bool" default="false"> - </argument> - <argument index="3" name="on_top" type="bool" default="false"> - </argument> - <argument index="4" name="use_vertex_color" type="bool" default="false"> - </argument> + <return type="void" /> + <argument index="0" name="name" type="String" /> + <argument index="1" name="color" type="Color" /> + <argument index="2" name="billboard" type="bool" default="false" /> + <argument index="3" name="on_top" type="bool" default="false" /> + <argument index="4" name="use_vertex_color" type="bool" default="false" /> <description> Creates an unshaded material with its variants (selected and/or editable) and adds them to the internal material list. They can then be accessed with [method get_material] and used in [method EditorNode3DGizmo.add_mesh] and [method EditorNode3DGizmo.add_lines]. Should not be overridden. </description> </method> <method name="get_material"> - <return type="StandardMaterial3D"> - </return> - <argument index="0" name="name" type="String"> - </argument> - <argument index="1" name="gizmo" type="EditorNode3DGizmo" default="null"> - </argument> + <return type="StandardMaterial3D" /> + <argument index="0" name="name" type="String" /> + <argument index="1" name="gizmo" type="EditorNode3DGizmo" default="null" /> <description> Gets material from the internal list of materials. If an [EditorNode3DGizmo] is provided, it will try to get the corresponding variant (selected and/or editable). </description> diff --git a/doc/classes/EditorPaths.xml b/doc/classes/EditorPaths.xml index d0d785dbb8..28a8314857 100644 --- a/doc/classes/EditorPaths.xml +++ b/doc/classes/EditorPaths.xml @@ -8,32 +8,27 @@ </tutorials> <methods> <method name="get_cache_dir" qualifiers="const"> - <return type="String"> - </return> + <return type="String" /> <description> </description> </method> <method name="get_config_dir" qualifiers="const"> - <return type="String"> - </return> + <return type="String" /> <description> </description> </method> <method name="get_data_dir" qualifiers="const"> - <return type="String"> - </return> + <return type="String" /> <description> </description> </method> <method name="get_self_contained_file" qualifiers="const"> - <return type="String"> - </return> + <return type="String" /> <description> </description> </method> <method name="is_self_contained" qualifiers="const"> - <return type="bool"> - </return> + <return type="bool" /> <description> </description> </method> diff --git a/doc/classes/EditorPlugin.xml b/doc/classes/EditorPlugin.xml index 753227513b..37efca7f48 100644 --- a/doc/classes/EditorPlugin.xml +++ b/doc/classes/EditorPlugin.xml @@ -11,56 +11,47 @@ </tutorials> <methods> <method name="_apply_changes" qualifiers="virtual"> - <return type="void"> - </return> + <return type="void" /> <description> This method is called when the editor is about to save the project, switch to another tab, etc. It asks the plugin to apply any pending state changes to ensure consistency. This is used, for example, in shader editors to let the plugin know that it must apply the shader code being written by the user to the object. </description> </method> <method name="_build" qualifiers="virtual"> - <return type="bool"> - </return> + <return type="bool" /> <description> This method is called when the editor is about to run the project. The plugin can then perform required operations before the project runs. This method must return a boolean. If this method returns [code]false[/code], the project will not run. The run is aborted immediately, so this also prevents all other plugins' [method _build] methods from running. </description> </method> <method name="_clear" qualifiers="virtual"> - <return type="void"> - </return> + <return type="void" /> <description> Clear all the state and reset the object being edited to zero. This ensures your plugin does not keep editing a currently existing node, or a node from the wrong scene. </description> </method> <method name="_disable_plugin" qualifiers="virtual"> - <return type="void"> - </return> + <return type="void" /> <description> Called by the engine when the user disables the [EditorPlugin] in the Plugin tab of the project settings window. </description> </method> <method name="_edit" qualifiers="virtual"> - <return type="void"> - </return> - <argument index="0" name="object" type="Object"> - </argument> + <return type="void" /> + <argument index="0" name="object" type="Object" /> <description> This function is used for plugins that edit specific object types (nodes or resources). It requests the editor to edit the given object. </description> </method> <method name="_enable_plugin" qualifiers="virtual"> - <return type="void"> - </return> + <return type="void" /> <description> Called by the engine when the user enables the [EditorPlugin] in the Plugin tab of the project settings window. </description> </method> <method name="_forward_canvas_draw_over_viewport" qualifiers="virtual"> - <return type="void"> - </return> - <argument index="0" name="overlay" type="Control"> - </argument> + <return type="void" /> + <argument index="0" name="overlay" type="Control" /> <description> Called by the engine when the 2D editor's viewport is updated. Use the [code]overlay[/code] [Control] for drawing. You can update the viewport manually by calling [method update_overlays]. [codeblocks] @@ -97,20 +88,16 @@ </description> </method> <method name="_forward_canvas_force_draw_over_viewport" qualifiers="virtual"> - <return type="void"> - </return> - <argument index="0" name="overlay" type="Control"> - </argument> + <return type="void" /> + <argument index="0" name="overlay" type="Control" /> <description> This method is the same as [method _forward_canvas_draw_over_viewport], except it draws on top of everything. Useful when you need an extra layer that shows over anything else. You need to enable calling of this method by using [method set_force_draw_over_forwarding_enabled]. </description> </method> <method name="_forward_canvas_gui_input" qualifiers="virtual"> - <return type="bool"> - </return> - <argument index="0" name="event" type="InputEvent"> - </argument> + <return type="bool" /> + <argument index="0" name="event" type="InputEvent" /> <description> Called when there is a root node in the current edited scene, [method _handles] is implemented and an [InputEvent] happens in the 2D viewport. Intercepts the [InputEvent], if [code]return true[/code] [EditorPlugin] consumes the [code]event[/code], otherwise forwards [code]event[/code] to other Editor classes. Example: [codeblocks] @@ -145,10 +132,8 @@ </description> </method> <method name="_forward_spatial_draw_over_viewport" qualifiers="virtual"> - <return type="void"> - </return> - <argument index="0" name="overlay" type="Control"> - </argument> + <return type="void" /> + <argument index="0" name="overlay" type="Control" /> <description> Called by the engine when the 3D editor's viewport is updated. Use the [code]overlay[/code] [Control] for drawing. You can update the viewport manually by calling [method update_overlays]. [codeblocks] @@ -185,22 +170,17 @@ </description> </method> <method name="_forward_spatial_force_draw_over_viewport" qualifiers="virtual"> - <return type="void"> - </return> - <argument index="0" name="overlay" type="Control"> - </argument> + <return type="void" /> + <argument index="0" name="overlay" type="Control" /> <description> This method is the same as [method _forward_spatial_draw_over_viewport], except it draws on top of everything. Useful when you need an extra layer that shows over anything else. You need to enable calling of this method by using [method set_force_draw_over_forwarding_enabled]. </description> </method> <method name="_forward_spatial_gui_input" qualifiers="virtual"> - <return type="bool"> - </return> - <argument index="0" name="camera" type="Camera3D"> - </argument> - <argument index="1" name="event" type="InputEvent"> - </argument> + <return type="bool" /> + <argument index="0" name="camera" type="Camera3D" /> + <argument index="1" name="event" type="InputEvent" /> <description> Called when there is a root node in the current edited scene, [method _handles] is implemented and an [InputEvent] happens in the 3D viewport. Intercepts the [InputEvent], if [code]return true[/code] [EditorPlugin] consumes the [code]event[/code], otherwise forwards [code]event[/code] to other Editor classes. Example: [codeblocks] @@ -235,15 +215,13 @@ </description> </method> <method name="_get_breakpoints" qualifiers="virtual"> - <return type="PackedStringArray"> - </return> + <return type="PackedStringArray" /> <description> This is for editors that edit script-based objects. You can return a list of breakpoints in the format ([code]script:line[/code]), for example: [code]res://path_to_script.gd:25[/code]. </description> </method> <method name="_get_plugin_icon" qualifiers="virtual"> - <return type="Texture2D"> - </return> + <return type="Texture2D" /> <description> Override this method in your plugin to return a [Texture2D] in order to give it an icon. For main screen plugins, this appears at the top of the screen, to the right of the "2D", "3D", "Script", and "AssetLib" buttons. @@ -269,109 +247,86 @@ </description> </method> <method name="_get_plugin_name" qualifiers="virtual"> - <return type="String"> - </return> + <return type="String" /> <description> Override this method in your plugin to provide the name of the plugin when displayed in the Godot editor. For main screen plugins, this appears at the top of the screen, to the right of the "2D", "3D", "Script", and "AssetLib" buttons. </description> </method> <method name="_get_state" qualifiers="virtual"> - <return type="Dictionary"> - </return> + <return type="Dictionary" /> <description> Gets the state of your plugin editor. This is used when saving the scene (so state is kept when opening it again) and for switching tabs (so state can be restored when the tab returns). </description> </method> <method name="_get_window_layout" qualifiers="virtual"> - <return type="void"> - </return> - <argument index="0" name="layout" type="ConfigFile"> - </argument> + <return type="void" /> + <argument index="0" name="layout" type="ConfigFile" /> <description> Gets the GUI layout of the plugin. This is used to save the project's editor layout when [method queue_save_layout] is called or the editor layout was changed(For example changing the position of a dock). </description> </method> <method name="_handles" qualifiers="virtual"> - <return type="bool"> - </return> - <argument index="0" name="object" type="Object"> - </argument> + <return type="bool" /> + <argument index="0" name="object" type="Object" /> <description> Implement this function if your plugin edits a specific type of object (Resource or Node). If you return [code]true[/code], then you will get the functions [method _edit] and [method _make_visible] called when the editor requests them. If you have declared the methods [method _forward_canvas_gui_input] and [method _forward_spatial_gui_input] these will be called too. </description> </method> <method name="_has_main_screen" qualifiers="virtual"> - <return type="bool"> - </return> + <return type="bool" /> <description> Returns [code]true[/code] if this is a main screen editor plugin (it goes in the workspace selector together with [b]2D[/b], [b]3D[/b], [b]Script[/b] and [b]AssetLib[/b]). </description> </method> <method name="_make_visible" qualifiers="virtual"> - <return type="void"> - </return> - <argument index="0" name="visible" type="bool"> - </argument> + <return type="void" /> + <argument index="0" name="visible" type="bool" /> <description> This function will be called when the editor is requested to become visible. It is used for plugins that edit a specific object type. Remember that you have to manage the visibility of all your editor controls manually. </description> </method> <method name="_save_external_data" qualifiers="virtual"> - <return type="void"> - </return> + <return type="void" /> <description> This method is called after the editor saves the project or when it's closed. It asks the plugin to save edited external scenes/resources. </description> </method> <method name="_set_state" qualifiers="virtual"> - <return type="void"> - </return> - <argument index="0" name="state" type="Dictionary"> - </argument> + <return type="void" /> + <argument index="0" name="state" type="Dictionary" /> <description> Restore the state saved by [method _get_state]. </description> </method> <method name="_set_window_layout" qualifiers="virtual"> - <return type="void"> - </return> - <argument index="0" name="layout" type="ConfigFile"> - </argument> + <return type="void" /> + <argument index="0" name="layout" type="ConfigFile" /> <description> Restore the plugin GUI layout saved by [method _get_window_layout]. </description> </method> <method name="add_autoload_singleton"> - <return type="void"> - </return> - <argument index="0" name="name" type="String"> - </argument> - <argument index="1" name="path" type="String"> - </argument> + <return type="void" /> + <argument index="0" name="name" type="String" /> + <argument index="1" name="path" type="String" /> <description> Adds a script at [code]path[/code] to the Autoload list as [code]name[/code]. </description> </method> <method name="add_control_to_bottom_panel"> - <return type="Button"> - </return> - <argument index="0" name="control" type="Control"> - </argument> - <argument index="1" name="title" type="String"> - </argument> + <return type="Button" /> + <argument index="0" name="control" type="Control" /> + <argument index="1" name="title" type="String" /> <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]. </description> </method> <method name="add_control_to_container"> - <return type="void"> - </return> - <argument index="0" name="container" type="int" enum="EditorPlugin.CustomControlContainer"> - </argument> - <argument index="1" name="control" type="Control"> - </argument> + <return type="void" /> + <argument index="0" name="container" type="int" enum="EditorPlugin.CustomControlContainer" /> + <argument index="1" name="control" type="Control" /> <description> Adds a custom control to a container (see [enum CustomControlContainer]). There are many locations where custom controls can be added in the editor UI. Please remember that you have to manage the visibility of your custom controls yourself (and likely hide it after adding it). @@ -379,12 +334,9 @@ </description> </method> <method name="add_control_to_dock"> - <return type="void"> - </return> - <argument index="0" name="slot" type="int" enum="EditorPlugin.DockSlot"> - </argument> - <argument index="1" name="control" type="Control"> - </argument> + <return type="void" /> + <argument index="0" name="slot" type="int" enum="EditorPlugin.DockSlot" /> + <argument index="1" name="control" type="Control" /> <description> Adds the control to a specific dock slot (see [enum DockSlot] for options). If the dock is repositioned and as long as the plugin is active, the editor will save the dock position on further sessions. @@ -392,47 +344,36 @@ </description> </method> <method name="add_custom_type"> - <return type="void"> - </return> - <argument index="0" name="type" type="String"> - </argument> - <argument index="1" name="base" type="String"> - </argument> - <argument index="2" name="script" type="Script"> - </argument> - <argument index="3" name="icon" type="Texture2D"> - </argument> + <return type="void" /> + <argument index="0" name="type" type="String" /> + <argument index="1" name="base" type="String" /> + <argument index="2" name="script" type="Script" /> + <argument index="3" name="icon" type="Texture2D" /> <description> Adds a custom type, which will appear in the list of nodes or resources. An icon can be optionally passed. - When given node or resource is selected, the base type will be instantiated (e.g. "Node3D", "Control", "Resource"), then the script will be loaded and set to this object. + When a given node or resource is selected, the base type will be instantiated (e.g. "Node3D", "Control", "Resource"), then the script will be loaded and set to this object. You can use the virtual method [method _handles] to check if your custom object is being edited by checking the script or using the [code]is[/code] keyword. During run-time, this will be a simple object with a script so this function does not need to be called then. </description> </method> <method name="add_debugger_plugin"> - <return type="void"> - </return> - <argument index="0" name="script" type="Script"> - </argument> + <return type="void" /> + <argument index="0" name="script" type="Script" /> <description> Adds a [Script] as debugger plugin to the Debugger. The script must extend [EditorDebuggerPlugin]. </description> </method> <method name="add_export_plugin"> - <return type="void"> - </return> - <argument index="0" name="plugin" type="EditorExportPlugin"> - </argument> + <return type="void" /> + <argument index="0" name="plugin" type="EditorExportPlugin" /> <description> Registers a new [EditorExportPlugin]. Export plugins are used to perform tasks when the project is being exported. See [method add_inspector_plugin] for an example of how to register a plugin. </description> </method> <method name="add_import_plugin"> - <return type="void"> - </return> - <argument index="0" name="importer" type="EditorImportPlugin"> - </argument> + <return type="void" /> + <argument index="0" name="importer" type="EditorImportPlugin" /> <description> Registers a new [EditorImportPlugin]. Import plugins are used to import custom and unsupported assets as a custom [Resource] type. [b]Note:[/b] If you want to import custom 3D asset formats use [method add_scene_import_plugin] instead. @@ -440,10 +381,8 @@ </description> </method> <method name="add_inspector_plugin"> - <return type="void"> - </return> - <argument index="0" name="plugin" type="EditorInspectorPlugin"> - </argument> + <return type="void" /> + <argument index="0" name="plugin" type="EditorInspectorPlugin" /> <description> Registers a new [EditorInspectorPlugin]. Inspector plugins are used to extend [EditorInspector] and provide custom configuration tools for your object's properties. [b]Note:[/b] Always use [method remove_inspector_plugin] to remove the registered [EditorInspectorPlugin] when your [EditorPlugin] is disabled to prevent leaks and an unexpected behavior. @@ -462,255 +401,202 @@ </description> </method> <method name="add_scene_import_plugin"> - <return type="void"> - </return> - <argument index="0" name="scene_importer" type="EditorSceneImporter"> - </argument> + <return type="void" /> + <argument index="0" name="scene_importer" type="EditorSceneImporter" /> <description> Registers a new [EditorSceneImporter]. Scene importers are used to import custom 3D asset formats as scenes. </description> </method> <method name="add_spatial_gizmo_plugin"> - <return type="void"> - </return> - <argument index="0" name="plugin" type="EditorNode3DGizmoPlugin"> - </argument> + <return type="void" /> + <argument index="0" name="plugin" type="EditorNode3DGizmoPlugin" /> <description> Registers a new [EditorNode3DGizmoPlugin]. Gizmo plugins are used to add custom gizmos to the 3D preview viewport for a [Node3D]. See [method add_inspector_plugin] for an example of how to register a plugin. </description> </method> <method name="add_tool_menu_item"> - <return type="void"> - </return> - <argument index="0" name="name" type="String"> - </argument> - <argument index="1" name="callable" type="Callable"> - </argument> + <return type="void" /> + <argument index="0" name="name" type="String" /> + <argument index="1" name="callable" type="Callable" /> <description> Adds a custom menu item to [b]Project > Tools[/b] named [code]name[/code]. When clicked, the provided [code]callable[/code] will be called. </description> </method> <method name="add_tool_submenu_item"> - <return type="void"> - </return> - <argument index="0" name="name" type="String"> - </argument> - <argument index="1" name="submenu" type="Object"> - </argument> + <return type="void" /> + <argument index="0" name="name" type="String" /> + <argument index="1" name="submenu" type="Object" /> <description> Adds a custom submenu under [b]Project > Tools >[/b] [code]name[/code]. [code]submenu[/code] should be an object of class [PopupMenu]. Use [code]remove_tool_menu_item(name)[/code] on plugin clean up to remove the menu. </description> </method> <method name="add_translation_parser_plugin"> - <return type="void"> - </return> - <argument index="0" name="parser" type="EditorTranslationParserPlugin"> - </argument> + <return type="void" /> + <argument index="0" name="parser" type="EditorTranslationParserPlugin" /> <description> Registers a custom translation parser plugin for extracting translatable strings from custom files. </description> </method> <method name="add_undo_redo_inspector_hook_callback"> - <return type="void"> - </return> - <argument index="0" name="callable" type="Callable"> - </argument> + <return type="void" /> + <argument index="0" name="callable" type="Callable" /> <description> Hooks a callback into the undo/redo action creation when a property is modified in the inspector. This allows, for example, to save other properties that may be lost when a given property is modified. The callback should have 4 arguments: [Object] [code]undo_redo[/code], [Object] [code]modified_object[/code], [String] [code]property[/code] and [Variant] [code]new_value[/code]. They are, respectively, the [UndoRedo] object used by the inspector, the currently modified object, the name of the modified property and the new value the property is about to take. </description> </method> <method name="get_editor_interface"> - <return type="EditorInterface"> - </return> + <return type="EditorInterface" /> <description> Returns the [EditorInterface] object that gives you control over Godot editor's window and its functionalities. </description> </method> <method name="get_script_create_dialog"> - <return type="ScriptCreateDialog"> - </return> + <return type="ScriptCreateDialog" /> <description> Gets the Editor's dialogue used for making scripts. [b]Note:[/b] Users can configure it before use. </description> </method> <method name="get_undo_redo"> - <return type="UndoRedo"> - </return> + <return type="UndoRedo" /> <description> Gets the undo/redo object. Most actions in the editor can be undoable, so use this object to make sure this happens when it's worth it. </description> </method> <method name="hide_bottom_panel"> - <return type="void"> - </return> + <return type="void" /> <description> Minimizes the bottom panel. </description> </method> <method name="make_bottom_panel_item_visible"> - <return type="void"> - </return> - <argument index="0" name="item" type="Control"> - </argument> + <return type="void" /> + <argument index="0" name="item" type="Control" /> <description> Makes a specific item in the bottom panel visible. </description> </method> <method name="queue_save_layout"> - <return type="void"> - </return> + <return type="void" /> <description> Queue save the project's editor layout. </description> </method> <method name="remove_autoload_singleton"> - <return type="void"> - </return> - <argument index="0" name="name" type="String"> - </argument> + <return type="void" /> + <argument index="0" name="name" type="String" /> <description> Removes an Autoload [code]name[/code] from the list. </description> </method> <method name="remove_control_from_bottom_panel"> - <return type="void"> - </return> - <argument index="0" name="control" type="Control"> - </argument> + <return type="void" /> + <argument index="0" name="control" type="Control" /> <description> Removes the control from the bottom panel. You have to manually [method Node.queue_free] the control. </description> </method> <method name="remove_control_from_container"> - <return type="void"> - </return> - <argument index="0" name="container" type="int" enum="EditorPlugin.CustomControlContainer"> - </argument> - <argument index="1" name="control" type="Control"> - </argument> + <return type="void" /> + <argument index="0" name="container" type="int" enum="EditorPlugin.CustomControlContainer" /> + <argument index="1" name="control" type="Control" /> <description> Removes the control from the specified container. You have to manually [method Node.queue_free] the control. </description> </method> <method name="remove_control_from_docks"> - <return type="void"> - </return> - <argument index="0" name="control" type="Control"> - </argument> + <return type="void" /> + <argument index="0" name="control" type="Control" /> <description> Removes the control from the dock. You have to manually [method Node.queue_free] the control. </description> </method> <method name="remove_custom_type"> - <return type="void"> - </return> - <argument index="0" name="type" type="String"> - </argument> + <return type="void" /> + <argument index="0" name="type" type="String" /> <description> Removes a custom type added by [method add_custom_type]. </description> </method> <method name="remove_debugger_plugin"> - <return type="void"> - </return> - <argument index="0" name="script" type="Script"> - </argument> + <return type="void" /> + <argument index="0" name="script" type="Script" /> <description> Removes the debugger plugin with given script from the Debugger. </description> </method> <method name="remove_export_plugin"> - <return type="void"> - </return> - <argument index="0" name="plugin" type="EditorExportPlugin"> - </argument> + <return type="void" /> + <argument index="0" name="plugin" type="EditorExportPlugin" /> <description> Removes an export plugin registered by [method add_export_plugin]. </description> </method> <method name="remove_import_plugin"> - <return type="void"> - </return> - <argument index="0" name="importer" type="EditorImportPlugin"> - </argument> + <return type="void" /> + <argument index="0" name="importer" type="EditorImportPlugin" /> <description> Removes an import plugin registered by [method add_import_plugin]. </description> </method> <method name="remove_inspector_plugin"> - <return type="void"> - </return> - <argument index="0" name="plugin" type="EditorInspectorPlugin"> - </argument> + <return type="void" /> + <argument index="0" name="plugin" type="EditorInspectorPlugin" /> <description> Removes an inspector plugin registered by [method add_import_plugin] </description> </method> <method name="remove_scene_import_plugin"> - <return type="void"> - </return> - <argument index="0" name="scene_importer" type="EditorSceneImporter"> - </argument> + <return type="void" /> + <argument index="0" name="scene_importer" type="EditorSceneImporter" /> <description> Removes a scene importer registered by [method add_scene_import_plugin]. </description> </method> <method name="remove_spatial_gizmo_plugin"> - <return type="void"> - </return> - <argument index="0" name="plugin" type="EditorNode3DGizmoPlugin"> - </argument> + <return type="void" /> + <argument index="0" name="plugin" type="EditorNode3DGizmoPlugin" /> <description> Removes a gizmo plugin registered by [method add_spatial_gizmo_plugin]. </description> </method> <method name="remove_tool_menu_item"> - <return type="void"> - </return> - <argument index="0" name="name" type="String"> - </argument> + <return type="void" /> + <argument index="0" name="name" type="String" /> <description> Removes a menu [code]name[/code] from [b]Project > Tools[/b]. </description> </method> <method name="remove_translation_parser_plugin"> - <return type="void"> - </return> - <argument index="0" name="parser" type="EditorTranslationParserPlugin"> - </argument> + <return type="void" /> + <argument index="0" name="parser" type="EditorTranslationParserPlugin" /> <description> Removes a custom translation parser plugin registered by [method add_translation_parser_plugin]. </description> </method> <method name="remove_undo_redo_inspector_hook_callback"> - <return type="void"> - </return> - <argument index="0" name="callable" type="Callable"> - </argument> + <return type="void" /> + <argument index="0" name="callable" type="Callable" /> <description> Removes a callback previsously added by [method add_undo_redo_inspector_hook_callback]. </description> </method> <method name="set_force_draw_over_forwarding_enabled"> - <return type="void"> - </return> + <return type="void" /> <description> Enables calling of [method _forward_canvas_force_draw_over_viewport] for the 2D editor and [method _forward_spatial_force_draw_over_viewport] for the 3D editor when their viewports are updated. You need to call this method only once and it will work permanently for this plugin. </description> </method> <method name="set_input_event_forwarding_always_enabled"> - <return type="void"> - </return> + <return type="void" /> <description> Use this method if you always want to receive inputs from 3D view screen inside [method _forward_spatial_gui_input]. It might be especially usable if your plugin will want to use raycast in the scene. </description> </method> <method name="update_overlays" qualifiers="const"> - <return type="int"> - </return> + <return type="int" /> <description> Updates the overlays of the 2D and 3D editor viewport. Causes methods [method _forward_canvas_draw_over_viewport], [method _forward_canvas_force_draw_over_viewport], [method _forward_spatial_draw_over_viewport] and [method _forward_spatial_force_draw_over_viewport] to be called. </description> @@ -718,8 +604,7 @@ </methods> <signals> <signal name="main_screen_changed"> - <argument index="0" name="screen_name" type="String"> - </argument> + <argument index="0" name="screen_name" type="String" /> <description> Emitted when user changes the workspace ([b]2D[/b], [b]3D[/b], [b]Script[/b], [b]AssetLib[/b]). Also works with custom screens defined by plugins. </description> @@ -729,21 +614,18 @@ </description> </signal> <signal name="resource_saved"> - <argument index="0" name="resource" type="Resource"> - </argument> + <argument index="0" name="resource" type="Resource" /> <description> </description> </signal> <signal name="scene_changed"> - <argument index="0" name="scene_root" type="Node"> - </argument> + <argument index="0" name="scene_root" type="Node" /> <description> Emitted when the scene is changed in the editor. The argument will return the root node of the scene that has just become active. If this scene is new and empty, the argument will be [code]null[/code]. </description> </signal> <signal name="scene_closed"> - <argument index="0" name="filepath" type="String"> - </argument> + <argument index="0" name="filepath" type="String" /> <description> Emitted when user closes a scene. The argument is file path to a closed scene. </description> diff --git a/doc/classes/EditorProperty.xml b/doc/classes/EditorProperty.xml index 549d2c1628..41f42568ad 100644 --- a/doc/classes/EditorProperty.xml +++ b/doc/classes/EditorProperty.xml @@ -10,62 +10,49 @@ </tutorials> <methods> <method name="_update_property" qualifiers="virtual"> - <return type="void"> - </return> + <return type="void" /> <description> When this virtual function is called, you must update your editor. </description> </method> <method name="add_focusable"> - <return type="void"> - </return> - <argument index="0" name="control" type="Control"> - </argument> + <return type="void" /> + <argument index="0" name="control" type="Control" /> <description> If any of the controls added can gain keyboard focus, add it here. This ensures that focus will be restored if the inspector is refreshed. </description> </method> <method name="emit_changed"> - <return type="void"> - </return> - <argument index="0" name="property" type="StringName"> - </argument> - <argument index="1" name="value" type="Variant"> - </argument> - <argument index="2" name="field" type="StringName" default="&"""> - </argument> - <argument index="3" name="changing" type="bool" default="false"> - </argument> + <return type="void" /> + <argument index="0" name="property" type="StringName" /> + <argument index="1" name="value" type="Variant" /> + <argument index="2" name="field" type="StringName" default="&""" /> + <argument index="3" name="changing" type="bool" default="false" /> <description> If one or several properties have changed, this must be called. [code]field[/code] is used in case your editor can modify fields separately (as an example, Vector3.x). The [code]changing[/code] argument avoids the editor requesting this property to be refreshed (leave as [code]false[/code] if unsure). </description> </method> <method name="get_edited_object"> - <return type="Object"> - </return> + <return type="Object" /> <description> Gets the edited object. </description> </method> <method name="get_edited_property"> - <return type="StringName"> - </return> + <return type="StringName" /> <description> Gets the edited property. If your editor is for a single property (added via [method EditorInspectorPlugin._parse_property]), then this will return the property. </description> </method> <method name="get_tooltip_text" qualifiers="const"> - <return type="String"> - </return> + <return type="String" /> <description> Override if you want to allow a custom tooltip over your property. </description> </method> <method name="set_bottom_editor"> - <return type="void"> - </return> - <argument index="0" name="editor" type="Control"> - </argument> + <return type="void" /> + <argument index="0" name="editor" type="Control" /> <description> Adds controls with this function if you want them on the bottom (below the label). </description> @@ -96,78 +83,62 @@ </members> <signals> <signal name="multiple_properties_changed"> - <argument index="0" name="properties" type="PackedStringArray"> - </argument> - <argument index="1" name="value" type="Array"> - </argument> + <argument index="0" name="properties" type="PackedStringArray" /> + <argument index="1" name="value" type="Array" /> <description> Emit it if you want multiple properties modified at the same time. Do not use if added via [method EditorInspectorPlugin._parse_property]. </description> </signal> <signal name="object_id_selected"> - <argument index="0" name="property" type="StringName"> - </argument> - <argument index="1" name="id" type="int"> - </argument> + <argument index="0" name="property" type="StringName" /> + <argument index="1" name="id" type="int" /> <description> Used by sub-inspectors. Emit it if what was selected was an Object ID. </description> </signal> <signal name="property_changed"> - <argument index="0" name="property" type="StringName"> - </argument> - <argument index="1" name="value" type="Variant"> - </argument> + <argument index="0" name="property" type="StringName" /> + <argument index="1" name="value" type="Variant" /> <description> Do not emit this manually, use the [method emit_changed] method instead. </description> </signal> <signal name="property_checked"> - <argument index="0" name="property" type="StringName"> - </argument> - <argument index="1" name="bool" type="String"> - </argument> + <argument index="0" name="property" type="StringName" /> + <argument index="1" name="bool" type="String" /> <description> Emitted when a property was checked. Used internally. </description> </signal> <signal name="property_deleted"> - <argument index="0" name="property" type="StringName"> - </argument> + <argument index="0" name="property" type="StringName" /> <description> Emitted when a property was deleted. Used internally. </description> </signal> <signal name="property_keyed"> - <argument index="0" name="property" type="StringName"> - </argument> + <argument index="0" name="property" type="StringName" /> <description> Emit it if you want to add this value as an animation key (check for keying being enabled first). </description> </signal> <signal name="property_keyed_with_value"> - <argument index="0" name="property" type="StringName"> - </argument> - <argument index="1" name="value" type="Variant"> - </argument> + <argument index="0" name="property" type="StringName" /> + <argument index="1" name="value" type="Variant" /> <description> Emit it if you want to key a property with a single value. </description> </signal> <signal name="resource_selected"> - <argument index="0" name="path" type="String"> - </argument> - <argument index="1" name="resource" type="Resource"> - </argument> + <argument index="0" name="path" type="String" /> + <argument index="1" name="resource" type="Resource" /> <description> If you want a sub-resource to be edited, emit this signal with the resource. </description> </signal> <signal name="selected"> - <argument index="0" name="path" type="String"> - </argument> - <argument index="1" name="focusable_idx" type="int"> - </argument> + <argument index="0" name="path" type="String" /> + <argument index="1" name="focusable_idx" type="int" /> <description> Emitted when selected. Used internally. </description> diff --git a/doc/classes/EditorResourceConversionPlugin.xml b/doc/classes/EditorResourceConversionPlugin.xml index 1d7e98c99d..3de508c88d 100644 --- a/doc/classes/EditorResourceConversionPlugin.xml +++ b/doc/classes/EditorResourceConversionPlugin.xml @@ -8,16 +8,13 @@ </tutorials> <methods> <method name="_convert" qualifiers="virtual"> - <return type="Resource"> - </return> - <argument index="0" name="resource" type="Resource"> - </argument> + <return type="Resource" /> + <argument index="0" name="resource" type="Resource" /> <description> </description> </method> <method name="_converts_to" qualifiers="virtual"> - <return type="String"> - </return> + <return type="String" /> <description> </description> </method> diff --git a/doc/classes/EditorResourcePicker.xml b/doc/classes/EditorResourcePicker.xml index 0029955819..a0f2df1f0c 100644 --- a/doc/classes/EditorResourcePicker.xml +++ b/doc/classes/EditorResourcePicker.xml @@ -11,36 +11,29 @@ </tutorials> <methods> <method name="_handle_menu_selected" qualifiers="virtual"> - <return type="void"> - </return> - <argument index="0" name="id" type="int"> - </argument> + <return type="void" /> + <argument index="0" name="id" type="int" /> <description> This virtual method can be implemented to handle context menu items not handled by default. See [method _set_create_options]. </description> </method> <method name="_set_create_options" qualifiers="virtual"> - <return type="void"> - </return> - <argument index="0" name="menu_node" type="Object"> - </argument> + <return type="void" /> + <argument index="0" name="menu_node" type="Object" /> <description> This virtual method is called when updating the context menu of [EditorResourcePicker]. Implement this method to override the "New ..." items with your own options. [code]menu_node[/code] is a reference to the [PopupMenu] node. [b]Note:[/b] Implement [method _handle_menu_selected] to handle these custom items. </description> </method> <method name="get_allowed_types" qualifiers="const"> - <return type="PackedStringArray"> - </return> + <return type="PackedStringArray" /> <description> Returns a list of all allowed types and subtypes corresponding to the [member base_type]. If the [member base_type] is empty, an empty list is returned. </description> </method> <method name="set_toggle_pressed"> - <return type="void"> - </return> - <argument index="0" name="pressed" type="bool"> - </argument> + <return type="void" /> + <argument index="0" name="pressed" type="bool" /> <description> Sets the toggle mode state for the main button. Works only if [member toggle_mode] is set to [code]true[/code]. </description> @@ -62,15 +55,13 @@ </members> <signals> <signal name="resource_changed"> - <argument index="0" name="resource" type="Resource"> - </argument> + <argument index="0" name="resource" type="Resource" /> <description> Emitted when the value of the edited resource was changed. </description> </signal> <signal name="resource_selected"> - <argument index="0" name="resource" type="Resource"> - </argument> + <argument index="0" name="resource" type="Resource" /> <description> Emitted when the resource value was set and user clicked to edit it. </description> diff --git a/doc/classes/EditorResourcePreview.xml b/doc/classes/EditorResourcePreview.xml index 3239a75ada..c2693b4e1e 100644 --- a/doc/classes/EditorResourcePreview.xml +++ b/doc/classes/EditorResourcePreview.xml @@ -11,60 +11,44 @@ </tutorials> <methods> <method name="add_preview_generator"> - <return type="void"> - </return> - <argument index="0" name="generator" type="EditorResourcePreviewGenerator"> - </argument> + <return type="void" /> + <argument index="0" name="generator" type="EditorResourcePreviewGenerator" /> <description> Create an own, custom preview generator. </description> </method> <method name="check_for_invalidation"> - <return type="void"> - </return> - <argument index="0" name="path" type="String"> - </argument> + <return type="void" /> + <argument index="0" name="path" type="String" /> <description> Check if the resource changed, if so, it will be invalidated and the corresponding signal emitted. </description> </method> <method name="queue_edited_resource_preview"> - <return type="void"> - </return> - <argument index="0" name="resource" type="Resource"> - </argument> - <argument index="1" name="receiver" type="Object"> - </argument> - <argument index="2" name="receiver_func" type="StringName"> - </argument> - <argument index="3" name="userdata" type="Variant"> - </argument> + <return type="void" /> + <argument index="0" name="resource" type="Resource" /> + <argument index="1" name="receiver" type="Object" /> + <argument index="2" name="receiver_func" type="StringName" /> + <argument index="3" name="userdata" type="Variant" /> <description> Queue the [code]resource[/code] being edited for preview. Once the preview is ready, the [code]receiver[/code]'s [code]receiver_func[/code] will be called. The [code]receiver_func[/code] must take the following four arguments: [String] path, [Texture2D] preview, [Texture2D] thumbnail_preview, [Variant] userdata. [code]userdata[/code] can be anything, and will be returned when [code]receiver_func[/code] is called. [b]Note[/b]: If it was not possible to create the preview the [code]receiver_func[/code] will still be called, but the preview will be null. </description> </method> <method name="queue_resource_preview"> - <return type="void"> - </return> - <argument index="0" name="path" type="String"> - </argument> - <argument index="1" name="receiver" type="Object"> - </argument> - <argument index="2" name="receiver_func" type="StringName"> - </argument> - <argument index="3" name="userdata" type="Variant"> - </argument> + <return type="void" /> + <argument index="0" name="path" type="String" /> + <argument index="1" name="receiver" type="Object" /> + <argument index="2" name="receiver_func" type="StringName" /> + <argument index="3" name="userdata" type="Variant" /> <description> Queue a resource file located at [code]path[/code] for preview. Once the preview is ready, the [code]receiver[/code]'s [code]receiver_func[/code] will be called. The [code]receiver_func[/code] must take the following four arguments: [String] path, [Texture2D] preview, [Texture2D] thumbnail_preview, [Variant] userdata. [code]userdata[/code] can be anything, and will be returned when [code]receiver_func[/code] is called. [b]Note[/b]: If it was not possible to create the preview the [code]receiver_func[/code] will still be called, but the preview will be null. </description> </method> <method name="remove_preview_generator"> - <return type="void"> - </return> - <argument index="0" name="generator" type="EditorResourcePreviewGenerator"> - </argument> + <return type="void" /> + <argument index="0" name="generator" type="EditorResourcePreviewGenerator" /> <description> Removes a custom preview generator. </description> @@ -72,8 +56,7 @@ </methods> <signals> <signal name="preview_invalidated"> - <argument index="0" name="path" type="String"> - </argument> + <argument index="0" name="path" type="String" /> <description> Emitted if a preview was invalidated (changed). [code]path[/code] corresponds to the path of the preview. </description> diff --git a/doc/classes/EditorResourcePreviewGenerator.xml b/doc/classes/EditorResourcePreviewGenerator.xml index 3594474e36..7054b1f4d0 100644 --- a/doc/classes/EditorResourcePreviewGenerator.xml +++ b/doc/classes/EditorResourcePreviewGenerator.xml @@ -10,20 +10,16 @@ </tutorials> <methods> <method name="_can_generate_small_preview" qualifiers="virtual"> - <return type="bool"> - </return> + <return type="bool" /> <description> If this function returns [code]true[/code], the generator will call [method _generate] or [method _generate_from_path] for small previews as well. By default, it returns [code]false[/code]. </description> </method> <method name="_generate" qualifiers="virtual"> - <return type="Texture2D"> - </return> - <argument index="0" name="from" type="Resource"> - </argument> - <argument index="1" name="size" type="Vector2"> - </argument> + <return type="Texture2D" /> + <argument index="0" name="from" type="Resource" /> + <argument index="1" name="size" type="Vector2" /> <description> Generate a preview from a given resource with the specified size. This must always be implemented. Returning an empty texture is an OK way to fail and let another generator take care. @@ -31,12 +27,9 @@ </description> </method> <method name="_generate_from_path" qualifiers="virtual"> - <return type="Texture2D"> - </return> - <argument index="0" name="path" type="String"> - </argument> - <argument index="1" name="size" type="Vector2"> - </argument> + <return type="Texture2D" /> + <argument index="0" name="path" type="String" /> + <argument index="1" name="size" type="Vector2" /> <description> Generate a preview directly from a path with the specified size. Implementing this is optional, as default code will load and call [method _generate]. Returning an empty texture is an OK way to fail and let another generator take care. @@ -44,18 +37,15 @@ </description> </method> <method name="_generate_small_preview_automatically" qualifiers="virtual"> - <return type="bool"> - </return> + <return type="bool" /> <description> If this function returns [code]true[/code], the generator will automatically generate the small previews from the normal preview texture generated by the methods [method _generate] or [method _generate_from_path]. By default, it returns [code]false[/code]. </description> </method> <method name="_handles" qualifiers="virtual"> - <return type="bool"> - </return> - <argument index="0" name="type" type="String"> - </argument> + <return type="bool" /> + <argument index="0" name="type" type="String" /> <description> Returns [code]true[/code] if your generator supports the resource of type [code]type[/code]. </description> diff --git a/doc/classes/EditorSceneImporter.xml b/doc/classes/EditorSceneImporter.xml index 8df3091057..2e9d6a43d8 100644 --- a/doc/classes/EditorSceneImporter.xml +++ b/doc/classes/EditorSceneImporter.xml @@ -9,62 +9,44 @@ </tutorials> <methods> <method name="_get_extensions" qualifiers="virtual"> - <return type="Array"> - </return> + <return type="Array" /> <description> </description> </method> <method name="_get_import_flags" qualifiers="virtual"> - <return type="int"> - </return> + <return type="int" /> <description> </description> </method> <method name="_import_animation" qualifiers="virtual"> - <return type="Animation"> - </return> - <argument index="0" name="path" type="String"> - </argument> - <argument index="1" name="flags" type="int"> - </argument> - <argument index="2" name="bake_fps" type="int"> - </argument> + <return type="Animation" /> + <argument index="0" name="path" type="String" /> + <argument index="1" name="flags" type="int" /> + <argument index="2" name="bake_fps" type="int" /> <description> </description> </method> <method name="_import_scene" qualifiers="virtual"> - <return type="Node"> - </return> - <argument index="0" name="path" type="String"> - </argument> - <argument index="1" name="flags" type="int"> - </argument> - <argument index="2" name="bake_fps" type="int"> - </argument> + <return type="Node" /> + <argument index="0" name="path" type="String" /> + <argument index="1" name="flags" type="int" /> + <argument index="2" name="bake_fps" type="int" /> <description> </description> </method> <method name="import_animation_from_other_importer"> - <return type="Animation"> - </return> - <argument index="0" name="path" type="String"> - </argument> - <argument index="1" name="flags" type="int"> - </argument> - <argument index="2" name="bake_fps" type="int"> - </argument> + <return type="Animation" /> + <argument index="0" name="path" type="String" /> + <argument index="1" name="flags" type="int" /> + <argument index="2" name="bake_fps" type="int" /> <description> </description> </method> <method name="import_scene_from_other_importer"> - <return type="Node"> - </return> - <argument index="0" name="path" type="String"> - </argument> - <argument index="1" name="flags" type="int"> - </argument> - <argument index="2" name="bake_fps" type="int"> - </argument> + <return type="Node" /> + <argument index="0" name="path" type="String" /> + <argument index="1" name="flags" type="int" /> + <argument index="2" name="bake_fps" type="int" /> <description> </description> </method> diff --git a/doc/classes/EditorSceneImporterMesh.xml b/doc/classes/EditorSceneImporterMesh.xml index 90eca9072b..3a9eea87bb 100644 --- a/doc/classes/EditorSceneImporterMesh.xml +++ b/doc/classes/EditorSceneImporterMesh.xml @@ -8,161 +8,120 @@ </tutorials> <methods> <method name="add_blend_shape"> - <return type="void"> - </return> - <argument index="0" name="name" type="String"> - </argument> + <return type="void" /> + <argument index="0" name="name" type="String" /> <description> </description> </method> <method name="add_surface"> - <return type="void"> - </return> - <argument index="0" name="primitive" type="int" enum="Mesh.PrimitiveType"> - </argument> - <argument index="1" name="arrays" type="Array"> - </argument> - <argument index="2" name="blend_shapes" type="Array" default="[]"> - </argument> + <return type="void" /> + <argument index="0" name="primitive" type="int" enum="Mesh.PrimitiveType" /> + <argument index="1" name="arrays" type="Array" /> + <argument index="2" name="blend_shapes" type="Array" default="[]" /> <argument index="3" name="lods" type="Dictionary" default="{ -}"> - </argument> - <argument index="4" name="material" type="Material" default="null"> - </argument> - <argument index="5" name="name" type="String" default=""""> - </argument> +}" /> + <argument index="4" name="material" type="Material" default="null" /> + <argument index="5" name="name" type="String" default="""" /> <description> </description> </method> <method name="clear"> - <return type="void"> - </return> + <return type="void" /> <description> </description> </method> <method name="get_blend_shape_count" qualifiers="const"> - <return type="int"> - </return> + <return type="int" /> <description> </description> </method> <method name="get_blend_shape_mode" qualifiers="const"> - <return type="int" enum="Mesh.BlendShapeMode"> - </return> + <return type="int" enum="Mesh.BlendShapeMode" /> <description> </description> </method> <method name="get_blend_shape_name" qualifiers="const"> - <return type="String"> - </return> - <argument index="0" name="blend_shape_idx" type="int"> - </argument> + <return type="String" /> + <argument index="0" name="blend_shape_idx" type="int" /> <description> </description> </method> <method name="get_lightmap_size_hint" qualifiers="const"> - <return type="Vector2i"> - </return> + <return type="Vector2i" /> <description> </description> </method> <method name="get_mesh"> - <return type="ArrayMesh"> - </return> - <argument index="0" name="arg0" type="Mesh"> - </argument> + <return type="ArrayMesh" /> + <argument index="0" name="arg0" type="Mesh" /> <description> </description> </method> <method name="get_surface_arrays" qualifiers="const"> - <return type="Array"> - </return> - <argument index="0" name="surface_idx" type="int"> - </argument> + <return type="Array" /> + <argument index="0" name="surface_idx" type="int" /> <description> </description> </method> <method name="get_surface_blend_shape_arrays" qualifiers="const"> - <return type="Array"> - </return> - <argument index="0" name="surface_idx" type="int"> - </argument> - <argument index="1" name="blend_shape_idx" type="int"> - </argument> + <return type="Array" /> + <argument index="0" name="surface_idx" type="int" /> + <argument index="1" name="blend_shape_idx" type="int" /> <description> </description> </method> <method name="get_surface_count" qualifiers="const"> - <return type="int"> - </return> + <return type="int" /> <description> </description> </method> <method name="get_surface_lod_count" qualifiers="const"> - <return type="int"> - </return> - <argument index="0" name="surface_idx" type="int"> - </argument> + <return type="int" /> + <argument index="0" name="surface_idx" type="int" /> <description> </description> </method> <method name="get_surface_lod_indices" qualifiers="const"> - <return type="PackedInt32Array"> - </return> - <argument index="0" name="surface_idx" type="int"> - </argument> - <argument index="1" name="lod_idx" type="int"> - </argument> + <return type="PackedInt32Array" /> + <argument index="0" name="surface_idx" type="int" /> + <argument index="1" name="lod_idx" type="int" /> <description> </description> </method> <method name="get_surface_lod_size" qualifiers="const"> - <return type="float"> - </return> - <argument index="0" name="surface_idx" type="int"> - </argument> - <argument index="1" name="lod_idx" type="int"> - </argument> + <return type="float" /> + <argument index="0" name="surface_idx" type="int" /> + <argument index="1" name="lod_idx" type="int" /> <description> </description> </method> <method name="get_surface_material" qualifiers="const"> - <return type="Material"> - </return> - <argument index="0" name="surface_idx" type="int"> - </argument> + <return type="Material" /> + <argument index="0" name="surface_idx" type="int" /> <description> </description> </method> <method name="get_surface_name" qualifiers="const"> - <return type="String"> - </return> - <argument index="0" name="surface_idx" type="int"> - </argument> + <return type="String" /> + <argument index="0" name="surface_idx" type="int" /> <description> </description> </method> <method name="get_surface_primitive_type"> - <return type="int" enum="Mesh.PrimitiveType"> - </return> - <argument index="0" name="surface_idx" type="int"> - </argument> + <return type="int" enum="Mesh.PrimitiveType" /> + <argument index="0" name="surface_idx" type="int" /> <description> </description> </method> <method name="set_blend_shape_mode"> - <return type="void"> - </return> - <argument index="0" name="mode" type="int" enum="Mesh.BlendShapeMode"> - </argument> + <return type="void" /> + <argument index="0" name="mode" type="int" enum="Mesh.BlendShapeMode" /> <description> </description> </method> <method name="set_lightmap_size_hint"> - <return type="void"> - </return> - <argument index="0" name="size" type="Vector2i"> - </argument> + <return type="void" /> + <argument index="0" name="size" type="Vector2i" /> <description> </description> </method> diff --git a/doc/classes/EditorScenePostImport.xml b/doc/classes/EditorScenePostImport.xml index d2b5e84ff7..95b0b42d9f 100644 --- a/doc/classes/EditorScenePostImport.xml +++ b/doc/classes/EditorScenePostImport.xml @@ -56,17 +56,14 @@ </tutorials> <methods> <method name="_post_import" qualifiers="virtual"> - <return type="Object"> - </return> - <argument index="0" name="scene" type="Object"> - </argument> + <return type="Object" /> + <argument index="0" name="scene" type="Object" /> <description> Called after the scene was imported. This method must return the modified version of the scene. </description> </method> <method name="get_source_file" qualifiers="const"> - <return type="String"> - </return> + <return type="String" /> <description> Returns the source file path which got imported (e.g. [code]res://scene.dae[/code]). </description> diff --git a/doc/classes/EditorScript.xml b/doc/classes/EditorScript.xml index a91ea0eb14..6d793fe961 100644 --- a/doc/classes/EditorScript.xml +++ b/doc/classes/EditorScript.xml @@ -35,32 +35,27 @@ </tutorials> <methods> <method name="_run" qualifiers="virtual"> - <return type="void"> - </return> + <return type="void" /> <description> This method is executed by the Editor when [b]File > Run[/b] is used. </description> </method> <method name="add_root_node"> - <return type="void"> - </return> - <argument index="0" name="node" type="Node"> - </argument> + <return type="void" /> + <argument index="0" name="node" type="Node" /> <description> Adds [code]node[/code] as a child of the root node in the editor context. [b]Warning:[/b] The implementation of this method is currently disabled. </description> </method> <method name="get_editor_interface"> - <return type="EditorInterface"> - </return> + <return type="EditorInterface" /> <description> Returns the [EditorInterface] singleton instance. </description> </method> <method name="get_scene"> - <return type="Node"> - </return> + <return type="Node" /> <description> Returns the Editor's currently active scene. </description> diff --git a/doc/classes/EditorSelection.xml b/doc/classes/EditorSelection.xml index 63e89750c3..69ae865d5d 100644 --- a/doc/classes/EditorSelection.xml +++ b/doc/classes/EditorSelection.xml @@ -11,41 +11,34 @@ </tutorials> <methods> <method name="add_node"> - <return type="void"> - </return> - <argument index="0" name="node" type="Node"> - </argument> + <return type="void" /> + <argument index="0" name="node" type="Node" /> <description> Adds a node to the selection. [b]Note:[/b] The newly selected node will not be automatically edited in the inspector. If you want to edit a node, use [method EditorInterface.edit_node]. </description> </method> <method name="clear"> - <return type="void"> - </return> + <return type="void" /> <description> Clear the selection. </description> </method> <method name="get_selected_nodes"> - <return type="Node[]"> - </return> + <return type="Node[]" /> <description> Gets the list of selected nodes. </description> </method> <method name="get_transformable_selected_nodes"> - <return type="Array"> - </return> + <return type="Array" /> <description> Gets the list of selected nodes, optimized for transform operations (i.e. moving them, rotating, etc). This list avoids situations where a node is selected and also child/grandchild. </description> </method> <method name="remove_node"> - <return type="void"> - </return> - <argument index="0" name="node" type="Node"> - </argument> + <return type="void" /> + <argument index="0" name="node" type="Node" /> <description> Removes a node from the selection. </description> diff --git a/doc/classes/EditorSettings.xml b/doc/classes/EditorSettings.xml index e732223516..ad63abafa6 100644 --- a/doc/classes/EditorSettings.xml +++ b/doc/classes/EditorSettings.xml @@ -31,10 +31,8 @@ </tutorials> <methods> <method name="add_property_info"> - <return type="void"> - </return> - <argument index="0" name="info" type="Dictionary"> - </argument> + <return type="void" /> + <argument index="0" name="info" type="Dictionary" /> <description> Adds a custom property info to a property. The dictionary must contain: - [code]name[/code]: [String] (the name of the property) @@ -73,145 +71,110 @@ </description> </method> <method name="erase"> - <return type="void"> - </return> - <argument index="0" name="property" type="String"> - </argument> + <return type="void" /> + <argument index="0" name="property" type="String" /> <description> Erases the setting whose name is specified by [code]property[/code]. </description> </method> <method name="get_favorites" qualifiers="const"> - <return type="PackedStringArray"> - </return> + <return type="PackedStringArray" /> <description> Returns the list of favorite files and directories for this project. </description> </method> <method name="get_project_metadata" qualifiers="const"> - <return type="Variant"> - </return> - <argument index="0" name="section" type="String"> - </argument> - <argument index="1" name="key" type="String"> - </argument> - <argument index="2" name="default" type="Variant" default="null"> - </argument> + <return type="Variant" /> + <argument index="0" name="section" type="String" /> + <argument index="1" name="key" type="String" /> + <argument index="2" name="default" type="Variant" default="null" /> <description> Returns project-specific metadata for the [code]section[/code] and [code]key[/code] specified. If the metadata doesn't exist, [code]default[/code] will be returned instead. See also [method set_project_metadata]. </description> </method> <method name="get_project_settings_dir" qualifiers="const"> - <return type="String"> - </return> + <return type="String" /> <description> Returns the project-specific settings path. Projects all have a unique subdirectory inside the settings path where project-specific settings are saved. </description> </method> <method name="get_recent_dirs" qualifiers="const"> - <return type="PackedStringArray"> - </return> + <return type="PackedStringArray" /> <description> Returns the list of recently visited folders in the file dialog for this project. </description> </method> <method name="get_setting" qualifiers="const"> - <return type="Variant"> - </return> - <argument index="0" name="name" type="String"> - </argument> + <return type="Variant" /> + <argument index="0" name="name" type="String" /> <description> Returns the value of the setting specified by [code]name[/code]. This is equivalent to using [method Object.get] on the EditorSettings instance. </description> </method> <method name="has_setting" qualifiers="const"> - <return type="bool"> - </return> - <argument index="0" name="name" type="String"> - </argument> + <return type="bool" /> + <argument index="0" name="name" type="String" /> <description> Returns [code]true[/code] if the setting specified by [code]name[/code] exists, [code]false[/code] otherwise. </description> </method> <method name="property_can_revert"> - <return type="bool"> - </return> - <argument index="0" name="name" type="String"> - </argument> + <return type="bool" /> + <argument index="0" name="name" type="String" /> <description> Returns [code]true[/code] if the setting specified by [code]name[/code] can have its value reverted to the default value, [code]false[/code] otherwise. When this method returns [code]true[/code], a Revert button will display next to the setting in the Editor Settings. </description> </method> <method name="property_get_revert"> - <return type="Variant"> - </return> - <argument index="0" name="name" type="String"> - </argument> + <return type="Variant" /> + <argument index="0" name="name" type="String" /> <description> Returns the default value of the setting specified by [code]name[/code]. This is the value that would be applied when clicking the Revert button in the Editor Settings. </description> </method> <method name="set_builtin_action_override"> - <return type="void"> - </return> - <argument index="0" name="name" type="String"> - </argument> - <argument index="1" name="actions_list" type="Array"> - </argument> + <return type="void" /> + <argument index="0" name="name" type="String" /> + <argument index="1" name="actions_list" type="Array" /> <description> </description> </method> <method name="set_favorites"> - <return type="void"> - </return> - <argument index="0" name="dirs" type="PackedStringArray"> - </argument> + <return type="void" /> + <argument index="0" name="dirs" type="PackedStringArray" /> <description> Sets the list of favorite files and directories for this project. </description> </method> <method name="set_initial_value"> - <return type="void"> - </return> - <argument index="0" name="name" type="StringName"> - </argument> - <argument index="1" name="value" type="Variant"> - </argument> - <argument index="2" name="update_current" type="bool"> - </argument> + <return type="void" /> + <argument index="0" name="name" type="StringName" /> + <argument index="1" name="value" type="Variant" /> + <argument index="2" name="update_current" type="bool" /> <description> Sets the initial value of the setting specified by [code]name[/code] to [code]value[/code]. This is used to provide a value for the Revert button in the Editor Settings. If [code]update_current[/code] is true, the current value of the setting will be set to [code]value[/code] as well. </description> </method> <method name="set_project_metadata"> - <return type="void"> - </return> - <argument index="0" name="section" type="String"> - </argument> - <argument index="1" name="key" type="String"> - </argument> - <argument index="2" name="data" type="Variant"> - </argument> + <return type="void" /> + <argument index="0" name="section" type="String" /> + <argument index="1" name="key" type="String" /> + <argument index="2" name="data" type="Variant" /> <description> Sets project-specific metadata with the [code]section[/code], [code]key[/code] and [code]data[/code] specified. This metadata is stored outside the project folder and therefore won't be checked into version control. See also [method get_project_metadata]. </description> </method> <method name="set_recent_dirs"> - <return type="void"> - </return> - <argument index="0" name="dirs" type="PackedStringArray"> - </argument> + <return type="void" /> + <argument index="0" name="dirs" type="PackedStringArray" /> <description> Sets the list of recently visited folders in the file dialog for this project. </description> </method> <method name="set_setting"> - <return type="void"> - </return> - <argument index="0" name="name" type="String"> - </argument> - <argument index="1" name="value" type="Variant"> - </argument> + <return type="void" /> + <argument index="0" name="name" type="String" /> + <argument index="1" name="value" type="Variant" /> <description> Sets the [code]value[/code] of the setting specified by [code]name[/code]. This is equivalent to using [method Object.set] on the EditorSettings instance. </description> diff --git a/doc/classes/EditorSyntaxHighlighter.xml b/doc/classes/EditorSyntaxHighlighter.xml index d81b25345f..37644a8595 100644 --- a/doc/classes/EditorSyntaxHighlighter.xml +++ b/doc/classes/EditorSyntaxHighlighter.xml @@ -11,22 +11,19 @@ </tutorials> <methods> <method name="_get_name" qualifiers="virtual"> - <return type="String"> - </return> + <return type="String" /> <description> Virtual method which can be overridden to return the syntax highlighter name. </description> </method> <method name="_get_supported_extentions" qualifiers="virtual"> - <return type="Array"> - </return> + <return type="Array" /> <description> Virtual method which can be overridden to return the supported file extensions. </description> </method> <method name="_get_supported_languages" qualifiers="virtual"> - <return type="Array"> - </return> + <return type="Array" /> <description> Virtual method which can be overridden to return the supported language names. </description> diff --git a/doc/classes/EditorTranslationParserPlugin.xml b/doc/classes/EditorTranslationParserPlugin.xml index a9f4e90e72..47da8ec37b 100644 --- a/doc/classes/EditorTranslationParserPlugin.xml +++ b/doc/classes/EditorTranslationParserPlugin.xml @@ -103,21 +103,16 @@ </tutorials> <methods> <method name="_get_recognized_extensions" qualifiers="virtual"> - <return type="Array"> - </return> + <return type="Array" /> <description> Gets the list of file extensions to associate with this parser, e.g. [code]["csv"][/code]. </description> </method> <method name="_parse_file" qualifiers="virtual"> - <return type="void"> - </return> - <argument index="0" name="path" type="String"> - </argument> - <argument index="1" name="msgids" type="Array"> - </argument> - <argument index="2" name="msgids_context_plural" type="Array"> - </argument> + <return type="void" /> + <argument index="0" name="path" type="String" /> + <argument index="1" name="msgids" type="Array" /> + <argument index="2" name="msgids_context_plural" type="Array" /> <description> Override this method to define a custom parsing logic to extract the translatable strings. </description> diff --git a/doc/classes/EditorVCSInterface.xml b/doc/classes/EditorVCSInterface.xml index 0056b5ce16..5dd4901e3e 100644 --- a/doc/classes/EditorVCSInterface.xml +++ b/doc/classes/EditorVCSInterface.xml @@ -10,19 +10,15 @@ </tutorials> <methods> <method name="commit"> - <return type="void"> - </return> - <argument index="0" name="msg" type="String"> - </argument> + <return type="void" /> + <argument index="0" name="msg" type="String" /> <description> Creates a version commit if the addon is initialized, else returns without doing anything. Uses the files which have been staged previously, with the commit message set to a value as provided as in the argument. </description> </method> <method name="get_file_diff"> - <return type="Array"> - </return> - <argument index="0" name="file_path" type="String"> - </argument> + <return type="Array" /> + <argument index="0" name="file_path" type="String" /> <description> Returns an [Array] of [Dictionary] objects containing the diff output from the VCS in use, if a VCS addon is initialized, else returns an empty [Array] object. The diff contents also consist of some contextual lines which provide context to the observed line change in the file. Each [Dictionary] object has the line diff contents under the keys: @@ -35,8 +31,7 @@ </description> </method> <method name="get_modified_files_data"> - <return type="Dictionary"> - </return> + <return type="Dictionary" /> <description> Returns a [Dictionary] containing the path of the detected file change mapped to an integer signifying what kind of change the corresponding file has experienced. The following integer values are being used to signify that the detected file is: @@ -48,63 +43,52 @@ </description> </method> <method name="get_project_name"> - <return type="String"> - </return> + <return type="String" /> <description> Returns the project name of the VCS working directory. </description> </method> <method name="get_vcs_name"> - <return type="String"> - </return> + <return type="String" /> <description> Returns the name of the VCS if the VCS has been initialized, else return an empty string. </description> </method> <method name="initialize"> - <return type="bool"> - </return> - <argument index="0" name="project_root_path" type="String"> - </argument> + <return type="bool" /> + <argument index="0" name="project_root_path" type="String" /> <description> Initializes the VCS addon if not already. Uses the argument value as the path to the working directory of the project. Creates the initial commit if required. Returns [code]true[/code] if no failure occurs, else returns [code]false[/code]. </description> </method> <method name="is_addon_ready"> - <return type="bool"> - </return> + <return type="bool" /> <description> Returns [code]true[/code] if the addon is ready to respond to function calls, else returns [code]false[/code]. </description> </method> <method name="is_vcs_initialized"> - <return type="bool"> - </return> + <return type="bool" /> <description> Returns [code]true[/code] if the VCS addon has been initialized, else returns [code]false[/code]. </description> </method> <method name="shut_down"> - <return type="bool"> - </return> + <return type="bool" /> <description> Shuts down the VCS addon to allow cleanup code to run on call. Returns [code]true[/code] is no failure occurs, else returns [code]false[/code]. </description> </method> <method name="stage_file"> - <return type="void"> - </return> - <argument index="0" name="file_path" type="String"> - </argument> + <return type="void" /> + <argument index="0" name="file_path" type="String" /> <description> Stages the file which should be committed when [method EditorVCSInterface.commit] is called. Argument should contain the absolute path. </description> </method> <method name="unstage_file"> - <return type="void"> - </return> - <argument index="0" name="file_path" type="String"> - </argument> + <return type="void" /> + <argument index="0" name="file_path" type="String" /> <description> Unstages the file which was staged previously to be committed, so that it is no longer committed when [method EditorVCSInterface.commit] is called. Argument should contain the absolute path. </description> diff --git a/doc/classes/Engine.xml b/doc/classes/Engine.xml index c0a8407ece..e4411ab125 100644 --- a/doc/classes/Engine.xml +++ b/doc/classes/Engine.xml @@ -10,8 +10,7 @@ </tutorials> <methods> <method name="get_author_info" qualifiers="const"> - <return type="Dictionary"> - </return> + <return type="Dictionary" /> <description> Returns engine author information in a Dictionary. [code]lead_developers[/code] - Array of Strings, lead developer names @@ -21,8 +20,7 @@ </description> </method> <method name="get_copyright_info" qualifiers="const"> - <return type="Array"> - </return> + <return type="Array" /> <description> Returns an Array of copyright information Dictionaries. [code]name[/code] - String, component name @@ -30,81 +28,69 @@ </description> </method> <method name="get_donor_info" qualifiers="const"> - <return type="Dictionary"> - </return> + <return type="Dictionary" /> <description> Returns a Dictionary of Arrays of donor names. {[code]platinum_sponsors[/code], [code]gold_sponsors[/code], [code]silver_sponsors[/code], [code]bronze_sponsors[/code], [code]mini_sponsors[/code], [code]gold_donors[/code], [code]silver_donors[/code], [code]bronze_donors[/code]} </description> </method> <method name="get_frames_drawn"> - <return type="int"> - </return> + <return type="int" /> <description> Returns the total number of frames drawn. If the render loop is disabled with [code]--disable-render-loop[/code] via command line, this returns [code]0[/code]. See also [method get_process_frames]. </description> </method> <method name="get_frames_per_second" qualifiers="const"> - <return type="float"> - </return> + <return type="float" /> <description> Returns the frames per second of the running game. </description> </method> <method name="get_license_info" qualifiers="const"> - <return type="Dictionary"> - </return> + <return type="Dictionary" /> <description> Returns Dictionary of licenses used by Godot and included third party components. </description> </method> <method name="get_license_text" qualifiers="const"> - <return type="String"> - </return> + <return type="String" /> <description> Returns Godot license text. </description> </method> <method name="get_main_loop" qualifiers="const"> - <return type="MainLoop"> - </return> + <return type="MainLoop" /> <description> Returns the main loop object (see [MainLoop] and [SceneTree]). </description> </method> <method name="get_physics_frames" qualifiers="const"> - <return type="int"> - </return> + <return type="int" /> <description> Returns the total number of frames passed since engine initialization which is advanced on each [b]physics frame[/b]. </description> </method> <method name="get_physics_interpolation_fraction" qualifiers="const"> - <return type="float"> - </return> + <return type="float" /> <description> Returns the fraction through the current physics tick we are at the time of rendering the frame. This can be used to implement fixed timestep interpolation. </description> </method> <method name="get_process_frames" qualifiers="const"> - <return type="int"> - </return> + <return type="int" /> <description> Returns the total number of frames passed since engine initialization which is advanced on each [b]process frame[/b], regardless of whether the render loop is enabled. See also [method get_frames_drawn]. </description> </method> <method name="get_singleton" qualifiers="const"> - <return type="Object"> - </return> - <argument index="0" name="name" type="String"> - </argument> + <return type="Object" /> + <argument index="0" name="name" type="String" /> <description> Returns a global singleton with given [code]name[/code]. Often used for plugins, e.g. GodotPayments. </description> </method> <method name="get_version_info" qualifiers="const"> - <return type="Dictionary"> - </return> + <return type="Dictionary" /> <description> Returns the current engine version information in a Dictionary. [code]major[/code] - Holds the major version number as an int @@ -138,17 +124,14 @@ </description> </method> <method name="has_singleton" qualifiers="const"> - <return type="bool"> - </return> - <argument index="0" name="name" type="String"> - </argument> + <return type="bool" /> + <argument index="0" name="name" type="String" /> <description> Returns [code]true[/code] if a singleton with given [code]name[/code] exists in global scope. </description> </method> <method name="is_in_physics_frame" qualifiers="const"> - <return type="bool"> - </return> + <return type="bool" /> <description> Returns [code]true[/code] if the game is inside the fixed process and physics phase of the game loop. </description> @@ -170,7 +153,7 @@ The number of fixed iterations per second. This controls how often physics simulation and [method Node._physics_process] methods are run. This value should generally always be set to [code]60[/code] or above, as Godot doesn't interpolate the physics step. As a result, values lower than [code]60[/code] will look stuttery. This value can be increased to make input more reactive or work around tunneling issues, but keep in mind doing so will increase CPU usage. </member> <member name="physics_jitter_fix" type="float" setter="set_physics_jitter_fix" getter="get_physics_jitter_fix" default="0.5"> - Controls how much physics ticks are synchronized with real time. For 0 or less, the ticks are synchronized. Such values are recommended for network games, where clock synchronization matters. Higher values cause higher deviation of in-game clock and real clock, but allows smoothing out framerate jitters. The default value of 0.5 should be fine for most; values above 2 could cause the game to react to dropped frames with a noticeable delay and are not recommended. + Controls how much physics ticks are synchronized with real time. For 0 or less, the ticks are synchronized. Such values are recommended for network games, where clock synchronization matters. Higher values cause higher deviation of the in-game clock and real clock but smooth out framerate jitters. The default value of 0.5 should be fine for most; values above 2 could cause the game to react to dropped frames with a noticeable delay and are not recommended. [b]Note:[/b] For best results, when using a custom physics interpolation solution, the physics jitter fix should be disabled by setting [member physics_jitter_fix] to [code]0[/code]. </member> <member name="print_error_messages" type="bool" setter="set_print_error_messages" getter="is_printing_error_messages" default="true"> diff --git a/doc/classes/EngineDebugger.xml b/doc/classes/EngineDebugger.xml index 50ccb6b075..30d5193384 100644 --- a/doc/classes/EngineDebugger.xml +++ b/doc/classes/EngineDebugger.xml @@ -10,86 +10,64 @@ </tutorials> <methods> <method name="has_capture"> - <return type="bool"> - </return> - <argument index="0" name="name" type="StringName"> - </argument> + <return type="bool" /> + <argument index="0" name="name" type="StringName" /> <description> Returns [code]true[/code] if a capture with the given name is present otherwise [code]false[/code]. </description> </method> <method name="has_profiler"> - <return type="bool"> - </return> - <argument index="0" name="name" type="StringName"> - </argument> + <return type="bool" /> + <argument index="0" name="name" type="StringName" /> <description> Returns [code]true[/code] if a profiler with the given name is present otherwise [code]false[/code]. </description> </method> <method name="is_active"> - <return type="bool"> - </return> + <return type="bool" /> <description> Returns [code]true[/code] if the debugger is active otherwise [code]false[/code]. </description> </method> <method name="is_profiling"> - <return type="bool"> - </return> - <argument index="0" name="name" type="StringName"> - </argument> + <return type="bool" /> + <argument index="0" name="name" type="StringName" /> <description> Returns [code]true[/code] if a profiler with the given name is present and active otherwise [code]false[/code]. </description> </method> <method name="profiler_add_frame_data"> - <return type="void"> - </return> - <argument index="0" name="name" type="StringName"> - </argument> - <argument index="1" name="data" type="Array"> - </argument> + <return type="void" /> + <argument index="0" name="name" type="StringName" /> + <argument index="1" name="data" type="Array" /> <description> Calls the [code]add[/code] callable of the profiler with given [code]name[/code] and [code]data[/code]. </description> </method> <method name="profiler_enable"> - <return type="void"> - </return> - <argument index="0" name="name" type="StringName"> - </argument> - <argument index="1" name="enable" type="bool"> - </argument> - <argument index="2" name="arguments" type="Array" default="[]"> - </argument> + <return type="void" /> + <argument index="0" name="name" type="StringName" /> + <argument index="1" name="enable" type="bool" /> + <argument index="2" name="arguments" type="Array" default="[]" /> <description> Calls the [code]toggle[/code] callable of the profiler with given [code]name[/code] and [code]arguments[/code]. Enables/Disables the same profiler depending on [code]enable[/code] argument. </description> </method> <method name="register_message_capture"> - <return type="void"> - </return> - <argument index="0" name="name" type="StringName"> - </argument> - <argument index="1" name="callable" type="Callable"> - </argument> + <return type="void" /> + <argument index="0" name="name" type="StringName" /> + <argument index="1" name="callable" type="Callable" /> <description> Registers a message capture with given [code]name[/code]. If [code]name[/code] is "my_message" then messages starting with "my_message:" will be called with the given callable. Callable must accept a message string and a data array as argument. If the message and data are valid then callable must return [code]true[/code] otherwise [code]false[/code]. </description> </method> <method name="register_profiler"> - <return type="void"> - </return> - <argument index="0" name="name" type="StringName"> - </argument> - <argument index="1" name="toggle" type="Callable"> - </argument> - <argument index="2" name="add" type="Callable"> - </argument> - <argument index="3" name="tick" type="Callable"> - </argument> + <return type="void" /> + <argument index="0" name="name" type="StringName" /> + <argument index="1" name="toggle" type="Callable" /> + <argument index="2" name="add" type="Callable" /> + <argument index="3" name="tick" type="Callable" /> <description> Registers a profiler with the given [code]name[/code]. [code]toggle[/code] callable is called when the profiler is enabled/disabled. It must take an argument array as an argument. @@ -98,30 +76,23 @@ </description> </method> <method name="send_message"> - <return type="void"> - </return> - <argument index="0" name="message" type="String"> - </argument> - <argument index="1" name="data" type="Array"> - </argument> + <return type="void" /> + <argument index="0" name="message" type="String" /> + <argument index="1" name="data" type="Array" /> <description> Sends a message with given [code]message[/code] and [code]data[/code] array. </description> </method> <method name="unregister_message_capture"> - <return type="void"> - </return> - <argument index="0" name="name" type="StringName"> - </argument> + <return type="void" /> + <argument index="0" name="name" type="StringName" /> <description> Unregisters the message capture with given [code]name[/code]. </description> </method> <method name="unregister_profiler"> - <return type="void"> - </return> - <argument index="0" name="name" type="StringName"> - </argument> + <return type="void" /> + <argument index="0" name="name" type="StringName" /> <description> Unregisters a profiler with given [code]name[/code]. </description> diff --git a/doc/classes/Environment.xml b/doc/classes/Environment.xml index ae87a62c84..2c4e5ea886 100644 --- a/doc/classes/Environment.xml +++ b/doc/classes/Environment.xml @@ -19,21 +19,16 @@ </tutorials> <methods> <method name="get_glow_level" qualifiers="const"> - <return type="float"> - </return> - <argument index="0" name="idx" type="int"> - </argument> + <return type="float" /> + <argument index="0" name="idx" type="int" /> <description> Returns the intensity of the glow level [code]idx[/code]. </description> </method> <method name="set_glow_level"> - <return type="void"> - </return> - <argument index="0" name="idx" type="int"> - </argument> - <argument index="1" name="intensity" type="float"> - </argument> + <return type="void" /> + <argument index="0" name="idx" type="int" /> + <argument index="1" name="intensity" type="float" /> <description> Sets the intensity of the glow level [code]idx[/code]. A value above [code]0.0[/code] enables the level. Each level relies on the previous level. This means that enabling higher glow levels will slow down the glow effect rendering, even if previous levels aren't enabled. </description> diff --git a/doc/classes/Expression.xml b/doc/classes/Expression.xml index 640b45dca4..809a5bb80c 100644 --- a/doc/classes/Expression.xml +++ b/doc/classes/Expression.xml @@ -52,40 +52,31 @@ </tutorials> <methods> <method name="execute"> - <return type="Variant"> - </return> - <argument index="0" name="inputs" type="Array" default="[]"> - </argument> - <argument index="1" name="base_instance" type="Object" default="null"> - </argument> - <argument index="2" name="show_error" type="bool" default="true"> - </argument> + <return type="Variant" /> + <argument index="0" name="inputs" type="Array" default="[]" /> + <argument index="1" name="base_instance" type="Object" default="null" /> + <argument index="2" name="show_error" type="bool" default="true" /> <description> Executes the expression that was previously parsed by [method parse] and returns the result. Before you use the returned object, you should check if the method failed by calling [method has_execute_failed]. If you defined input variables in [method parse], you can specify their values in the inputs array, in the same order. </description> </method> <method name="get_error_text" qualifiers="const"> - <return type="String"> - </return> + <return type="String" /> <description> Returns the error text if [method parse] has failed. </description> </method> <method name="has_execute_failed" qualifiers="const"> - <return type="bool"> - </return> + <return type="bool" /> <description> Returns [code]true[/code] if [method execute] has failed. </description> </method> <method name="parse"> - <return type="int" enum="Error"> - </return> - <argument index="0" name="expression" type="String"> - </argument> - <argument index="1" name="input_names" type="PackedStringArray" default="PackedStringArray()"> - </argument> + <return type="int" enum="Error" /> + <argument index="0" name="expression" type="String" /> + <argument index="1" name="input_names" type="PackedStringArray" default="PackedStringArray()" /> <description> Parses the expression and returns an [enum Error] code. You can optionally specify names of variables that may appear in the expression with [code]input_names[/code], so that you can bind them when it gets executed. diff --git a/doc/classes/File.xml b/doc/classes/File.xml index f98c31dc7f..de3beedf0f 100644 --- a/doc/classes/File.xml +++ b/doc/classes/File.xml @@ -50,285 +50,231 @@ </tutorials> <methods> <method name="close"> - <return type="void"> - </return> + <return type="void" /> <description> Closes the currently opened file and prevents subsequent read/write operations. Use [method flush] to persist the data to disk without closing the file. </description> </method> <method name="eof_reached" qualifiers="const"> - <return type="bool"> - </return> + <return type="bool" /> <description> Returns [code]true[/code] if the file cursor has read past the end of the file. [b]Note:[/b] This function will still return [code]false[/code] while at the end of the file and only activates when reading past it. This can be confusing but it conforms to how low-level file access works in all operating systems. There is always [method get_length] and [method get_position] to implement a custom logic. </description> </method> <method name="file_exists" qualifiers="const"> - <return type="bool"> - </return> - <argument index="0" name="path" type="String"> - </argument> + <return type="bool" /> + <argument index="0" name="path" type="String" /> <description> Returns [code]true[/code] if the file exists in the given path. [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="flush"> - <return type="void"> - </return> + <return type="void" /> <description> Writes the file's buffer to disk. Flushing is automatically performed when the file is closed. This means you don't need to call [method flush] manually before closing a file using [method close]. Still, calling [method flush] can be used to ensure the data is safe even if the project crashes instead of being closed gracefully. [b]Note:[/b] Only call [method flush] when you actually need it. Otherwise, it will decrease performance due to constant disk writes. </description> </method> <method name="get_16" qualifiers="const"> - <return type="int"> - </return> + <return type="int" /> <description> Returns the next 16 bits from the file as an integer. See [method store_16] for details on what values can be stored and retrieved this way. </description> </method> <method name="get_32" qualifiers="const"> - <return type="int"> - </return> + <return type="int" /> <description> Returns the next 32 bits from the file as an integer. See [method store_32] for details on what values can be stored and retrieved this way. </description> </method> <method name="get_64" qualifiers="const"> - <return type="int"> - </return> + <return type="int" /> <description> Returns the next 64 bits from the file as an integer. See [method store_64] for details on what values can be stored and retrieved this way. </description> </method> <method name="get_8" qualifiers="const"> - <return type="int"> - </return> + <return type="int" /> <description> Returns the next 8 bits from the file as an integer. See [method store_8] for details on what values can be stored and retrieved this way. </description> </method> <method name="get_as_text" qualifiers="const"> - <return type="String"> - </return> + <return type="String" /> <description> Returns the whole file as a [String]. Text is interpreted as being UTF-8 encoded. </description> </method> <method name="get_buffer" qualifiers="const"> - <return type="PackedByteArray"> - </return> - <argument index="0" name="length" type="int"> - </argument> + <return type="PackedByteArray" /> + <argument index="0" name="length" type="int" /> <description> Returns next [code]length[/code] bytes of the file as a [PackedByteArray]. </description> </method> <method name="get_csv_line" qualifiers="const"> - <return type="PackedStringArray"> - </return> - <argument index="0" name="delim" type="String" default="",""> - </argument> + <return type="PackedStringArray" /> + <argument index="0" name="delim" type="String" default="","" /> <description> Returns the next value of the file in CSV (Comma-Separated Values) format. You can pass a different delimiter [code]delim[/code] to use other than the default [code]","[/code] (comma). This delimiter must be one-character long. Text is interpreted as being UTF-8 encoded. </description> </method> <method name="get_double" qualifiers="const"> - <return type="float"> - </return> + <return type="float" /> <description> Returns the next 64 bits from the file as a floating-point number. </description> </method> <method name="get_error" qualifiers="const"> - <return type="int" enum="Error"> - </return> + <return type="int" enum="Error" /> <description> Returns the last error that happened when trying to perform operations. Compare with the [code]ERR_FILE_*[/code] constants from [enum Error]. </description> </method> <method name="get_float" qualifiers="const"> - <return type="float"> - </return> + <return type="float" /> <description> Returns the next 32 bits from the file as a floating-point number. </description> </method> <method name="get_length" qualifiers="const"> - <return type="int"> - </return> + <return type="int" /> <description> Returns the size of the file in bytes. </description> </method> <method name="get_line" qualifiers="const"> - <return type="String"> - </return> + <return type="String" /> <description> Returns the next line of the file as a [String]. Text is interpreted as being UTF-8 encoded. </description> </method> <method name="get_md5" qualifiers="const"> - <return type="String"> - </return> - <argument index="0" name="path" type="String"> - </argument> + <return type="String" /> + <argument index="0" name="path" type="String" /> <description> Returns an MD5 String representing the file at the given path or an empty [String] on failure. </description> </method> <method name="get_modified_time" qualifiers="const"> - <return type="int"> - </return> - <argument index="0" name="file" type="String"> - </argument> + <return type="int" /> + <argument index="0" name="file" type="String" /> <description> Returns the last time the [code]file[/code] was modified in Unix timestamp format or returns a [String] "ERROR IN [code]file[/code]". This Unix timestamp can be converted to another format using the [Time] singleton. </description> </method> <method name="get_pascal_string"> - <return type="String"> - </return> + <return type="String" /> <description> Returns a [String] saved in Pascal format from the file. Text is interpreted as being UTF-8 encoded. </description> </method> <method name="get_path" qualifiers="const"> - <return type="String"> - </return> + <return type="String" /> <description> Returns the path as a [String] for the current open file. </description> </method> <method name="get_path_absolute" qualifiers="const"> - <return type="String"> - </return> + <return type="String" /> <description> Returns the absolute path as a [String] for the current open file. </description> </method> <method name="get_position" qualifiers="const"> - <return type="int"> - </return> + <return type="int" /> <description> Returns the file cursor's position. </description> </method> <method name="get_real" qualifiers="const"> - <return type="float"> - </return> + <return type="float" /> <description> Returns the next bits from the file as a floating-point number. </description> </method> <method name="get_sha256" qualifiers="const"> - <return type="String"> - </return> - <argument index="0" name="path" type="String"> - </argument> + <return type="String" /> + <argument index="0" name="path" type="String" /> <description> Returns a SHA-256 [String] representing the file at the given path or an empty [String] on failure. </description> </method> <method name="get_var" qualifiers="const"> - <return type="Variant"> - </return> - <argument index="0" name="allow_objects" type="bool" default="false"> - </argument> + <return type="Variant" /> + <argument index="0" name="allow_objects" type="bool" default="false" /> <description> Returns the next [Variant] value from the file. If [code]allow_objects[/code] is [code]true[/code], decoding objects is allowed. [b]Warning:[/b] Deserialized objects can contain code which gets executed. Do not use this option if the serialized object comes from untrusted sources to avoid potential security threats such as remote code execution. </description> </method> <method name="is_open" qualifiers="const"> - <return type="bool"> - </return> + <return type="bool" /> <description> Returns [code]true[/code] if the file is currently opened. </description> </method> <method name="open"> - <return type="int" enum="Error"> - </return> - <argument index="0" name="path" type="String"> - </argument> - <argument index="1" name="flags" type="int" enum="File.ModeFlags"> - </argument> + <return type="int" enum="Error" /> + <argument index="0" name="path" type="String" /> + <argument index="1" name="flags" type="int" enum="File.ModeFlags" /> <description> Opens the file for writing or reading, depending on the flags. </description> </method> <method name="open_compressed"> - <return type="int" enum="Error"> - </return> - <argument index="0" name="path" type="String"> - </argument> - <argument index="1" name="mode_flags" type="int" enum="File.ModeFlags"> - </argument> - <argument index="2" name="compression_mode" type="int" enum="File.CompressionMode" default="0"> - </argument> + <return type="int" enum="Error" /> + <argument index="0" name="path" type="String" /> + <argument index="1" name="mode_flags" type="int" enum="File.ModeFlags" /> + <argument index="2" name="compression_mode" type="int" enum="File.CompressionMode" default="0" /> <description> Opens a compressed file for reading or writing. [b]Note:[/b] [method open_compressed] can only read files that were saved by Godot, not third-party compression formats. See [url=https://github.com/godotengine/godot/issues/28999]GitHub issue #28999[/url] for a workaround. </description> </method> <method name="open_encrypted"> - <return type="int" enum="Error"> - </return> - <argument index="0" name="path" type="String"> - </argument> - <argument index="1" name="mode_flags" type="int" enum="File.ModeFlags"> - </argument> - <argument index="2" name="key" type="PackedByteArray"> - </argument> + <return type="int" enum="Error" /> + <argument index="0" name="path" type="String" /> + <argument index="1" name="mode_flags" type="int" enum="File.ModeFlags" /> + <argument index="2" name="key" type="PackedByteArray" /> <description> 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. </description> </method> <method name="open_encrypted_with_pass"> - <return type="int" enum="Error"> - </return> - <argument index="0" name="path" type="String"> - </argument> - <argument index="1" name="mode_flags" type="int" enum="File.ModeFlags"> - </argument> - <argument index="2" name="pass" type="String"> - </argument> + <return type="int" enum="Error" /> + <argument index="0" name="path" type="String" /> + <argument index="1" name="mode_flags" type="int" enum="File.ModeFlags" /> + <argument index="2" name="pass" type="String" /> <description> Opens an encrypted file in write or read mode. You need to pass a password to encrypt/decrypt it. </description> </method> <method name="seek"> - <return type="void"> - </return> - <argument index="0" name="position" type="int"> - </argument> + <return type="void" /> + <argument index="0" name="position" type="int" /> <description> Changes the file reading/writing cursor to the specified position (in bytes from the beginning of the file). </description> </method> <method name="seek_end"> - <return type="void"> - </return> - <argument index="0" name="position" type="int" default="0"> - </argument> + <return type="void" /> + <argument index="0" name="position" type="int" default="0" /> <description> Changes the file reading/writing cursor to the specified position (in bytes from the end of the file). [b]Note:[/b] This is an offset, so you should use negative numbers or the cursor will be at the end of the file. </description> </method> <method name="store_16"> - <return type="void"> - </return> - <argument index="0" name="value" type="int"> - </argument> + <return type="void" /> + <argument index="0" name="value" type="int" /> <description> Stores an integer as 16 bits in the file. [b]Note:[/b] The [code]value[/code] should lie in the interval [code][0, 2^16 - 1][/code]. Any other value will overflow and wrap around. @@ -370,10 +316,8 @@ </description> </method> <method name="store_32"> - <return type="void"> - </return> - <argument index="0" name="value" type="int"> - </argument> + <return type="void" /> + <argument index="0" name="value" type="int" /> <description> Stores an integer as 32 bits in the file. [b]Note:[/b] The [code]value[/code] should lie in the interval [code][0, 2^32 - 1][/code]. Any other value will overflow and wrap around. @@ -381,20 +325,16 @@ </description> </method> <method name="store_64"> - <return type="void"> - </return> - <argument index="0" name="value" type="int"> - </argument> + <return type="void" /> + <argument index="0" name="value" type="int" /> <description> Stores an integer as 64 bits in the file. [b]Note:[/b] The [code]value[/code] must lie in the interval [code][-2^63, 2^63 - 1][/code] (i.e. be a valid [int] value). </description> </method> <method name="store_8"> - <return type="void"> - </return> - <argument index="0" name="value" type="int"> - </argument> + <return type="void" /> + <argument index="0" name="value" type="int" /> <description> Stores an integer as 8 bits in the file. [b]Note:[/b] The [code]value[/code] should lie in the interval [code][0, 255][/code]. Any other value will overflow and wrap around. @@ -402,88 +342,68 @@ </description> </method> <method name="store_buffer"> - <return type="void"> - </return> - <argument index="0" name="buffer" type="PackedByteArray"> - </argument> + <return type="void" /> + <argument index="0" name="buffer" type="PackedByteArray" /> <description> Stores the given array of bytes in the file. </description> </method> <method name="store_csv_line"> - <return type="void"> - </return> - <argument index="0" name="values" type="PackedStringArray"> - </argument> - <argument index="1" name="delim" type="String" default="",""> - </argument> + <return type="void" /> + <argument index="0" name="values" type="PackedStringArray" /> + <argument index="1" name="delim" type="String" default="","" /> <description> Store the given [PackedStringArray] in the file as a line formatted in the CSV (Comma-Separated Values) format. You can pass a different delimiter [code]delim[/code] to use other than the default [code]","[/code] (comma). This delimiter must be one-character long. Text will be encoded as UTF-8. </description> </method> <method name="store_double"> - <return type="void"> - </return> - <argument index="0" name="value" type="float"> - </argument> + <return type="void" /> + <argument index="0" name="value" type="float" /> <description> Stores a floating-point number as 64 bits in the file. </description> </method> <method name="store_float"> - <return type="void"> - </return> - <argument index="0" name="value" type="float"> - </argument> + <return type="void" /> + <argument index="0" name="value" type="float" /> <description> Stores a floating-point number as 32 bits in the file. </description> </method> <method name="store_line"> - <return type="void"> - </return> - <argument index="0" name="line" type="String"> - </argument> + <return type="void" /> + <argument index="0" name="line" type="String" /> <description> Appends [code]line[/code] to the file followed by a line return character ([code]\n[/code]), encoding the text as UTF-8. </description> </method> <method name="store_pascal_string"> - <return type="void"> - </return> - <argument index="0" name="string" type="String"> - </argument> + <return type="void" /> + <argument index="0" name="string" type="String" /> <description> Stores the given [String] as a line in the file in Pascal format (i.e. also store the length of the string). Text will be encoded as UTF-8. </description> </method> <method name="store_real"> - <return type="void"> - </return> - <argument index="0" name="value" type="float"> - </argument> + <return type="void" /> + <argument index="0" name="value" type="float" /> <description> Stores a floating-point number in the file. </description> </method> <method name="store_string"> - <return type="void"> - </return> - <argument index="0" name="string" type="String"> - </argument> + <return type="void" /> + <argument index="0" name="string" type="String" /> <description> Appends [code]string[/code] to the file without a line return, encoding the text as UTF-8. </description> </method> <method name="store_var"> - <return type="void"> - </return> - <argument index="0" name="value" type="Variant"> - </argument> - <argument index="1" name="full_objects" type="bool" default="false"> - </argument> + <return type="void" /> + <argument index="0" name="value" type="Variant" /> + <argument index="1" name="full_objects" type="bool" default="false" /> <description> Stores any Variant value in the file. If [code]full_objects[/code] is [code]true[/code], encoding objects is allowed (and can potentially include code). [b]Note:[/b] Not all properties are included. Only properties that are configured with the [constant PROPERTY_USAGE_STORAGE] flag set will be serialized. You can add a new usage flag to a property by overriding the [method Object._get_property_list] method in your class. You can also check how property usage is configured by calling [method Object._get_property_list]. See [enum PropertyUsageFlags] for the possible usage flags. diff --git a/doc/classes/FileDialog.xml b/doc/classes/FileDialog.xml index 8ccee1c82e..7e16a6bf5a 100644 --- a/doc/classes/FileDialog.xml +++ b/doc/classes/FileDialog.xml @@ -10,45 +10,38 @@ </tutorials> <methods> <method name="add_filter"> - <return type="void"> - </return> - <argument index="0" name="filter" type="String"> - </argument> + <return type="void" /> + <argument index="0" name="filter" type="String" /> <description> Adds [code]filter[/code] as a custom filter; [code]filter[/code] should be of the form [code]"filename.extension ; Description"[/code]. For example, [code]"*.png ; PNG Images"[/code]. </description> </method> <method name="clear_filters"> - <return type="void"> - </return> + <return type="void" /> <description> Clear all the added filters in the dialog. </description> </method> <method name="deselect_all"> - <return type="void"> - </return> + <return type="void" /> <description> Clear all currently selected items in the dialog. </description> </method> <method name="get_line_edit"> - <return type="LineEdit"> - </return> + <return type="LineEdit" /> <description> Returns the LineEdit for the selected file. </description> </method> <method name="get_vbox"> - <return type="VBoxContainer"> - </return> + <return type="VBoxContainer" /> <description> Returns the vertical box container of the dialog, custom controls can be added to it. </description> </method> <method name="invalidate"> - <return type="void"> - </return> + <return type="void" /> <description> Invalidate and update the current dialog content list. </description> @@ -85,22 +78,19 @@ </members> <signals> <signal name="dir_selected"> - <argument index="0" name="dir" type="String"> - </argument> + <argument index="0" name="dir" type="String" /> <description> Emitted when the user selects a directory. </description> </signal> <signal name="file_selected"> - <argument index="0" name="path" type="String"> - </argument> + <argument index="0" name="path" type="String" /> <description> Emitted when the user selects a file by double-clicking it or pressing the [b]OK[/b] button. </description> </signal> <signal name="files_selected"> - <argument index="0" name="paths" type="PackedStringArray"> - </argument> + <argument index="0" name="paths" type="PackedStringArray" /> <description> Emitted when the user selects multiple files. </description> diff --git a/doc/classes/FileSystemDock.xml b/doc/classes/FileSystemDock.xml index 15f92e90e3..a164415245 100644 --- a/doc/classes/FileSystemDock.xml +++ b/doc/classes/FileSystemDock.xml @@ -8,10 +8,8 @@ </tutorials> <methods> <method name="navigate_to_path"> - <return type="void"> - </return> - <argument index="0" name="path" type="String"> - </argument> + <return type="void" /> + <argument index="0" name="path" type="String" /> <description> </description> </method> @@ -22,42 +20,34 @@ </description> </signal> <signal name="file_removed"> - <argument index="0" name="file" type="String"> - </argument> + <argument index="0" name="file" type="String" /> <description> </description> </signal> <signal name="files_moved"> - <argument index="0" name="old_file" type="String"> - </argument> - <argument index="1" name="new_file" type="String"> - </argument> + <argument index="0" name="old_file" type="String" /> + <argument index="1" name="new_file" type="String" /> <description> </description> </signal> <signal name="folder_moved"> - <argument index="0" name="old_folder" type="String"> - </argument> - <argument index="1" name="new_file" type="String"> - </argument> + <argument index="0" name="old_folder" type="String" /> + <argument index="1" name="new_file" type="String" /> <description> </description> </signal> <signal name="folder_removed"> - <argument index="0" name="folder" type="String"> - </argument> + <argument index="0" name="folder" type="String" /> <description> </description> </signal> <signal name="inherit"> - <argument index="0" name="file" type="String"> - </argument> + <argument index="0" name="file" type="String" /> <description> </description> </signal> <signal name="instance"> - <argument index="0" name="files" type="PackedStringArray"> - </argument> + <argument index="0" name="files" type="PackedStringArray" /> <description> </description> </signal> diff --git a/doc/classes/Font.xml b/doc/classes/Font.xml index 186bfbb931..06dcaca846 100644 --- a/doc/classes/Font.xml +++ b/doc/classes/Font.xml @@ -64,188 +64,131 @@ </tutorials> <methods> <method name="add_data"> - <return type="void"> - </return> - <argument index="0" name="data" type="FontData"> - </argument> + <return type="void" /> + <argument index="0" name="data" type="FontData" /> <description> Add font data source to the set. </description> </method> <method name="draw_char" qualifiers="const"> - <return type="float"> - </return> - <argument index="0" name="canvas_item" type="RID"> - </argument> - <argument index="1" name="pos" type="Vector2"> - </argument> - <argument index="2" name="char" type="int"> - </argument> - <argument index="3" name="next" type="int" default="0"> - </argument> - <argument index="4" name="size" type="int" default="-1"> - </argument> - <argument index="5" name="modulate" type="Color" default="Color(1, 1, 1, 1)"> - </argument> - <argument index="6" name="outline_size" type="int" default="0"> - </argument> - <argument index="7" name="outline_modulate" type="Color" default="Color(1, 1, 1, 0)"> - </argument> + <return type="float" /> + <argument index="0" name="canvas_item" type="RID" /> + <argument index="1" name="pos" type="Vector2" /> + <argument index="2" name="char" type="int" /> + <argument index="3" name="next" type="int" default="0" /> + <argument index="4" name="size" type="int" default="-1" /> + <argument index="5" name="modulate" type="Color" default="Color(1, 1, 1, 1)" /> + <argument index="6" name="outline_size" type="int" default="0" /> + <argument index="7" name="outline_modulate" type="Color" default="Color(1, 1, 1, 0)" /> <description> Draw a single Unicode character [code]char[/code] into a canvas item using the font, at a given position, with [code]modulate[/code] color, and optionally kerning if [code]next[/code] is passed. [code]position[/code] specifies the baseline, not the top. To draw from the top, [i]ascent[/i] must be added to the Y axis. [b]Note:[/b] Do not use this function to draw strings character by character, use [method draw_string] or [TextLine] instead. </description> </method> <method name="draw_multiline_string" qualifiers="const"> - <return type="void"> - </return> - <argument index="0" name="canvas_item" type="RID"> - </argument> - <argument index="1" name="pos" type="Vector2"> - </argument> - <argument index="2" name="text" type="String"> - </argument> - <argument index="3" name="align" type="int" enum="HAlign" default="0"> - </argument> - <argument index="4" name="width" type="float" default="-1"> - </argument> - <argument index="5" name="max_lines" type="int" default="-1"> - </argument> - <argument index="6" name="size" type="int" default="-1"> - </argument> - <argument index="7" name="modulate" type="Color" default="Color(1, 1, 1, 1)"> - </argument> - <argument index="8" name="outline_size" type="int" default="0"> - </argument> - <argument index="9" name="outline_modulate" type="Color" default="Color(1, 1, 1, 0)"> - </argument> - <argument index="10" name="flags" type="int" default="51"> - </argument> + <return type="void" /> + <argument index="0" name="canvas_item" type="RID" /> + <argument index="1" name="pos" type="Vector2" /> + <argument index="2" name="text" type="String" /> + <argument index="3" name="align" type="int" enum="HAlign" default="0" /> + <argument index="4" name="width" type="float" default="-1" /> + <argument index="5" name="max_lines" type="int" default="-1" /> + <argument index="6" name="size" type="int" default="-1" /> + <argument index="7" name="modulate" type="Color" default="Color(1, 1, 1, 1)" /> + <argument index="8" name="outline_size" type="int" default="0" /> + <argument index="9" name="outline_modulate" type="Color" default="Color(1, 1, 1, 0)" /> + <argument index="10" name="flags" type="int" default="51" /> <description> Breaks [code]text[/code] to the lines using rules specified by [code]flags[/code] and draws it into a canvas item using the font, at a given position, with [code]modulate[/code] color, optionally clipping the width and aligning horizontally. [code]position[/code] specifies the baseline of the first line, not the top. To draw from the top, [i]ascent[/i] must be added to the Y axis. See also [method CanvasItem.draw_multiline_string]. </description> </method> <method name="draw_string" qualifiers="const"> - <return type="void"> - </return> - <argument index="0" name="canvas_item" type="RID"> - </argument> - <argument index="1" name="pos" type="Vector2"> - </argument> - <argument index="2" name="text" type="String"> - </argument> - <argument index="3" name="align" type="int" enum="HAlign" default="0"> - </argument> - <argument index="4" name="width" type="float" default="-1"> - </argument> - <argument index="5" name="size" type="int" default="-1"> - </argument> - <argument index="6" name="modulate" type="Color" default="Color(1, 1, 1, 1)"> - </argument> - <argument index="7" name="outline_size" type="int" default="0"> - </argument> - <argument index="8" name="outline_modulate" type="Color" default="Color(1, 1, 1, 0)"> - </argument> - <argument index="9" name="flags" type="int" default="3"> - </argument> + <return type="void" /> + <argument index="0" name="canvas_item" type="RID" /> + <argument index="1" name="pos" type="Vector2" /> + <argument index="2" name="text" type="String" /> + <argument index="3" name="align" type="int" enum="HAlign" default="0" /> + <argument index="4" name="width" type="float" default="-1" /> + <argument index="5" name="size" type="int" default="-1" /> + <argument index="6" name="modulate" type="Color" default="Color(1, 1, 1, 1)" /> + <argument index="7" name="outline_size" type="int" default="0" /> + <argument index="8" name="outline_modulate" type="Color" default="Color(1, 1, 1, 0)" /> + <argument index="9" name="flags" type="int" default="3" /> <description> Draw [code]text[/code] into a canvas item using the font, at a given position, with [code]modulate[/code] color, optionally clipping the width and aligning horizontally. [code]position[/code] specifies the baseline, not the top. To draw from the top, [i]ascent[/i] must be added to the Y axis. See also [method CanvasItem.draw_string]. </description> </method> <method name="get_ascent" qualifiers="const"> - <return type="float"> - </return> - <argument index="0" name="size" type="int" default="-1"> - </argument> + <return type="float" /> + <argument index="0" name="size" type="int" default="-1" /> <description> Returns the average font ascent (number of pixels above the baseline). [b]Note:[/b] Real ascent of the string is context-dependent and can be significantly different from the value returned by this function. Use it only as rough estimate (e.g. as the ascent of empty line). </description> </method> <method name="get_char_size" qualifiers="const"> - <return type="Vector2"> - </return> - <argument index="0" name="char" type="int"> - </argument> - <argument index="1" name="next" type="int" default="0"> - </argument> - <argument index="2" name="size" type="int" default="-1"> - </argument> + <return type="Vector2" /> + <argument index="0" name="char" type="int" /> + <argument index="1" name="next" type="int" default="0" /> + <argument index="2" name="size" type="int" default="-1" /> <description> Returns the size of a character, optionally taking kerning into account if the next character is provided. [b]Note:[/b] Do not use this function to calculate width of the string character by character, use [method get_string_size] or [TextLine] instead. The height returned is the font height (see also [method get_height]) and has no relation to the glyph height. </description> </method> <method name="get_data" qualifiers="const"> - <return type="FontData"> - </return> - <argument index="0" name="idx" type="int"> - </argument> + <return type="FontData" /> + <argument index="0" name="idx" type="int" /> <description> Returns the font data source at index [code]idx[/code]. If the index does not exist, returns [code]null[/code]. </description> </method> <method name="get_data_count" qualifiers="const"> - <return type="int"> - </return> + <return type="int" /> <description> Returns the number of font data sources. </description> </method> <method name="get_descent" qualifiers="const"> - <return type="float"> - </return> - <argument index="0" name="size" type="int" default="-1"> - </argument> + <return type="float" /> + <argument index="0" name="size" type="int" default="-1" /> <description> Returns the average font descent (number of pixels below the baseline). [b]Note:[/b] Real descent of the string is context-dependent and can be significantly different from the value returned by this function. Use it only as rough estimate (e.g. as the descent of empty line). </description> </method> <method name="get_height" qualifiers="const"> - <return type="float"> - </return> - <argument index="0" name="size" type="int" default="-1"> - </argument> + <return type="float" /> + <argument index="0" name="size" type="int" default="-1" /> <description> Returns the total average font height (ascent plus descent) in pixels. [b]Note:[/b] Real height of the string is context-dependent and can be significantly different from the value returned by this function. Use it only as rough estimate (e.g. as the height of empty line). </description> </method> <method name="get_multiline_string_size" qualifiers="const"> - <return type="Vector2"> - </return> - <argument index="0" name="text" type="String"> - </argument> - <argument index="1" name="width" type="float" default="-1"> - </argument> - <argument index="2" name="size" type="int" default="-1"> - </argument> - <argument index="3" name="flags" type="int" default="48"> - </argument> + <return type="Vector2" /> + <argument index="0" name="text" type="String" /> + <argument index="1" name="width" type="float" default="-1" /> + <argument index="2" name="size" type="int" default="-1" /> + <argument index="3" name="flags" type="int" default="48" /> <description> Returns the size of a bounding box of a string broken into the lines, taking kerning and advance into account. See also [method draw_multiline_string]. </description> </method> <method name="get_spacing" qualifiers="const"> - <return type="int"> - </return> - <argument index="0" name="type" type="int"> - </argument> + <return type="int" /> + <argument index="0" name="type" type="int" /> <description> Returns the spacing for the given [code]type[/code] (see [enum SpacingType]). </description> </method> <method name="get_string_size" qualifiers="const"> - <return type="Vector2"> - </return> - <argument index="0" name="text" type="String"> - </argument> - <argument index="1" name="size" type="int" default="-1"> - </argument> + <return type="Vector2" /> + <argument index="0" name="text" type="String" /> + <argument index="1" name="size" type="int" default="-1" /> <description> Returns the size of a bounding box of a string, taking kerning and advance into account. [b]Note:[/b] Real height of the string is context-dependent and can be significantly different from the value returned by [method get_height]. @@ -253,76 +196,60 @@ </description> </method> <method name="get_supported_chars" qualifiers="const"> - <return type="String"> - </return> + <return type="String" /> <description> Returns a string containing all the characters available in the font. If a given character is included in more than one font data source, it appears only once in the returned string. </description> </method> <method name="get_underline_position" qualifiers="const"> - <return type="float"> - </return> - <argument index="0" name="size" type="int" default="-1"> - </argument> + <return type="float" /> + <argument index="0" name="size" type="int" default="-1" /> <description> Return average pixel offset of the underline below the baseline. [b]Note:[/b] Real underline position of the string is context-dependent and can be significantly different from the value returned by this function. Use it only as rough estimate. </description> </method> <method name="get_underline_thickness" qualifiers="const"> - <return type="float"> - </return> - <argument index="0" name="size" type="int" default="-1"> - </argument> + <return type="float" /> + <argument index="0" name="size" type="int" default="-1" /> <description> Return average thickness of the underline. [b]Note:[/b] Real underline thickness of the string is context-dependent and can be significantly different from the value returned by this function. Use it only as rough estimate. </description> </method> <method name="has_char" qualifiers="const"> - <return type="bool"> - </return> - <argument index="0" name="char" type="int"> - </argument> + <return type="bool" /> + <argument index="0" name="char" type="int" /> <description> Return [code]true[/code] if a Unicode [code]char[/code] is available in the font. </description> </method> <method name="remove_data"> - <return type="void"> - </return> - <argument index="0" name="idx" type="int"> - </argument> + <return type="void" /> + <argument index="0" name="idx" type="int" /> <description> Removes the font data source at index [code]idx[/code]. If the index does not exist, nothing happens. </description> </method> <method name="set_data"> - <return type="void"> - </return> - <argument index="0" name="idx" type="int"> - </argument> - <argument index="1" name="data" type="FontData"> - </argument> + <return type="void" /> + <argument index="0" name="idx" type="int" /> + <argument index="1" name="data" type="FontData" /> <description> Sets the font data source at index [code]idx[/code]. If the index does not exist, nothing happens. </description> </method> <method name="set_spacing"> - <return type="void"> - </return> - <argument index="0" name="type" type="int"> - </argument> - <argument index="1" name="value" type="int"> - </argument> + <return type="void" /> + <argument index="0" name="type" type="int" /> + <argument index="1" name="value" type="int" /> <description> Sets the spacing for [code]type[/code] (see [enum SpacingType]) to [code]value[/code] in pixels (not relative to the font size). </description> </method> <method name="update_changes"> - <return type="void"> - </return> + <return type="void" /> <description> After editing a font (changing data sources, etc.). Call this function to propagate changes to controls that might use it. </description> diff --git a/doc/classes/FontData.xml b/doc/classes/FontData.xml index 0a2fb03750..7a845a698f 100644 --- a/doc/classes/FontData.xml +++ b/doc/classes/FontData.xml @@ -12,57 +12,39 @@ </tutorials> <methods> <method name="bitmap_add_char"> - <return type="void"> - </return> - <argument index="0" name="char" type="int"> - </argument> - <argument index="1" name="texture_idx" type="int"> - </argument> - <argument index="2" name="rect" type="Rect2"> - </argument> - <argument index="3" name="align" type="Vector2"> - </argument> - <argument index="4" name="advance" type="float"> - </argument> + <return type="void" /> + <argument index="0" name="char" type="int" /> + <argument index="1" name="texture_idx" type="int" /> + <argument index="2" name="rect" type="Rect2" /> + <argument index="3" name="align" type="Vector2" /> + <argument index="4" name="advance" type="float" /> <description> Adds a character to the font, where [code]character[/code] is the Unicode value, [code]texture[/code] is the texture index, [code]rect[/code] is the region in the texture (in pixels!), [code]align[/code] is the (optional) alignment for the character and [code]advance[/code] is the (optional) advance. </description> </method> <method name="bitmap_add_kerning_pair"> - <return type="void"> - </return> - <argument index="0" name="A" type="int"> - </argument> - <argument index="1" name="B" type="int"> - </argument> - <argument index="2" name="kerning" type="int"> - </argument> + <return type="void" /> + <argument index="0" name="A" type="int" /> + <argument index="1" name="B" type="int" /> + <argument index="2" name="kerning" type="int" /> <description> Adds a kerning pair to the bitmap font as a difference. Kerning pairs are special cases where a typeface advance is determined by the next character. </description> </method> <method name="bitmap_add_texture"> - <return type="void"> - </return> - <argument index="0" name="texture" type="Texture"> - </argument> + <return type="void" /> + <argument index="0" name="texture" type="Texture" /> <description> Adds a texture to the bitmap font. </description> </method> <method name="draw_glyph" qualifiers="const"> - <return type="Vector2"> - </return> - <argument index="0" name="canvas" type="RID"> - </argument> - <argument index="1" name="size" type="int"> - </argument> - <argument index="2" name="pos" type="Vector2"> - </argument> - <argument index="3" name="index" type="int"> - </argument> - <argument index="4" name="color" type="Color" default="Color(1, 1, 1, 1)"> - </argument> + <return type="Vector2" /> + <argument index="0" name="canvas" type="RID" /> + <argument index="1" name="size" type="int" /> + <argument index="2" name="pos" type="Vector2" /> + <argument index="3" name="index" type="int" /> + <argument index="4" name="color" type="Color" default="Color(1, 1, 1, 1)" /> <description> Draws single glyph into a canvas item at the position, using [code]font[/code] at the size [code]size[/code]. Returns advance of the glyph for horizontal and vertical layouts. @@ -70,20 +52,13 @@ </description> </method> <method name="draw_glyph_outline" qualifiers="const"> - <return type="Vector2"> - </return> - <argument index="0" name="canvas" type="RID"> - </argument> - <argument index="1" name="size" type="int"> - </argument> - <argument index="2" name="outline_size" type="int"> - </argument> - <argument index="3" name="pos" type="Vector2"> - </argument> - <argument index="4" name="index" type="int"> - </argument> - <argument index="5" name="color" type="Color" default="Color(1, 1, 1, 1)"> - </argument> + <return type="Vector2" /> + <argument index="0" name="canvas" type="RID" /> + <argument index="1" name="size" type="int" /> + <argument index="2" name="outline_size" type="int" /> + <argument index="3" name="pos" type="Vector2" /> + <argument index="4" name="index" type="int" /> + <argument index="5" name="color" type="Color" default="Color(1, 1, 1, 1)" /> <description> Draws single glyph outline of size [code]outline_size[/code] into a canvas item at the position, using [code]font[/code] at the size [code]size[/code]. If outline drawing is not supported, nothing is drawn. Returns advance of the glyph for horizontal and vertical layouts (regardless of outline drawing support). @@ -91,290 +66,223 @@ </description> </method> <method name="get_ascent" qualifiers="const"> - <return type="float"> - </return> - <argument index="0" name="size" type="int"> - </argument> + <return type="float" /> + <argument index="0" name="size" type="int" /> <description> Returns the font ascent (number of pixels above the baseline). </description> </method> <method name="get_base_size" qualifiers="const"> - <return type="float"> - </return> + <return type="float" /> <description> Returns the base size of the font (the only size supported for non-scalable fonts, meaningless for scalable fonts). </description> </method> <method name="get_descent" qualifiers="const"> - <return type="float"> - </return> - <argument index="0" name="size" type="int"> - </argument> + <return type="float" /> + <argument index="0" name="size" type="int" /> <description> Returns the font descent (number of pixels below the baseline). </description> </method> <method name="get_glyph_advance" qualifiers="const"> - <return type="Vector2"> - </return> - <argument index="0" name="index" type="int"> - </argument> - <argument index="1" name="size" type="int"> - </argument> + <return type="Vector2" /> + <argument index="0" name="index" type="int" /> + <argument index="1" name="size" type="int" /> <description> Returns advance of the glyph for horizontal and vertical layouts. Note: Glyph index is bound to the font data, use only glyphs indices returned by [method TextServer.shaped_text_get_glyphs] or [method get_glyph_index] for this font data. </description> </method> <method name="get_glyph_index" qualifiers="const"> - <return type="int"> - </return> - <argument index="0" name="char" type="int"> - </argument> - <argument index="1" name="variation_selector" type="int" default="0"> - </argument> + <return type="int" /> + <argument index="0" name="char" type="int" /> + <argument index="1" name="variation_selector" type="int" default="0" /> <description> Return the glyph index of a [code]char[/code], optionally modified by the [code]variation_selector[/code]. </description> </method> <method name="get_glyph_kerning" qualifiers="const"> - <return type="Vector2"> - </return> - <argument index="0" name="index_a" type="int"> - </argument> - <argument index="1" name="index_b" type="int"> - </argument> - <argument index="2" name="size" type="int"> - </argument> + <return type="Vector2" /> + <argument index="0" name="index_a" type="int" /> + <argument index="1" name="index_b" type="int" /> + <argument index="2" name="size" type="int" /> <description> Returns a kerning of the pair of glyphs for horizontal and vertical layouts. Note: Glyph index is bound to the font data, use only glyphs indices returned by [method TextServer.shaped_text_get_glyphs] or [method get_glyph_index] for this font data. </description> </method> <method name="get_height" qualifiers="const"> - <return type="float"> - </return> - <argument index="0" name="size" type="int"> - </argument> + <return type="float" /> + <argument index="0" name="size" type="int" /> <description> Returns the total font height (ascent plus descent) in pixels. </description> </method> <method name="get_language_support_override" qualifiers="const"> - <return type="bool"> - </return> - <argument index="0" name="language" type="String"> - </argument> + <return type="bool" /> + <argument index="0" name="language" type="String" /> <description> Returns [code]true[/code] if support override is enabled for the [code]language[/code]. </description> </method> <method name="get_language_support_overrides" qualifiers="const"> - <return type="PackedStringArray"> - </return> + <return type="PackedStringArray" /> <description> Returns list of language support overrides. </description> </method> <method name="get_script_support_override" qualifiers="const"> - <return type="bool"> - </return> - <argument index="0" name="script" type="String"> - </argument> + <return type="bool" /> + <argument index="0" name="script" type="String" /> <description> Returns [code]true[/code] if support override is enabled for the [code]script[/code]. </description> </method> <method name="get_script_support_overrides" qualifiers="const"> - <return type="PackedStringArray"> - </return> + <return type="PackedStringArray" /> <description> Returns list of script support overrides. </description> </method> <method name="get_spacing" qualifiers="const"> - <return type="int"> - </return> - <argument index="0" name="type" type="int"> - </argument> + <return type="int" /> + <argument index="0" name="type" type="int" /> <description> Returns the spacing for the given [code]type[/code] (see [enum SpacingType]). </description> </method> <method name="get_supported_chars" qualifiers="const"> - <return type="String"> - </return> + <return type="String" /> <description> Returns a string containing all the characters available in the font. </description> </method> <method name="get_underline_position" qualifiers="const"> - <return type="float"> - </return> - <argument index="0" name="size" type="int"> - </argument> + <return type="float" /> + <argument index="0" name="size" type="int" /> <description> Returns underline offset (number of pixels below the baseline). </description> </method> <method name="get_underline_thickness" qualifiers="const"> - <return type="float"> - </return> - <argument index="0" name="size" type="int"> - </argument> + <return type="float" /> + <argument index="0" name="size" type="int" /> <description> Returns underline thickness in pixels. </description> </method> <method name="get_variation" qualifiers="const"> - <return type="float"> - </return> - <argument index="0" name="tag" type="String"> - </argument> + <return type="float" /> + <argument index="0" name="tag" type="String" /> <description> Returns variation coordinate [code]tag[/code]. </description> </method> <method name="get_variation_list" qualifiers="const"> - <return type="Dictionary"> - </return> + <return type="Dictionary" /> <description> Returns list of supported [url=https://docs.microsoft.com/en-us/typography/opentype/spec/dvaraxisreg]variation coordinates[/url], each coordinate is returned as [code]tag: Vector3i(min_value,max_value,default_value)[/code]. Font variations allow for continuous change of glyph characteristics along some given design axis, such as weight, width or slant. </description> </method> <method name="has_char" qualifiers="const"> - <return type="bool"> - </return> - <argument index="0" name="char" type="int"> - </argument> + <return type="bool" /> + <argument index="0" name="char" type="int" /> <description> Return [code]true[/code] if a Unicode [code]char[/code] is available in the font. </description> </method> <method name="has_outline" qualifiers="const"> - <return type="bool"> - </return> + <return type="bool" /> <description> Returns [code]true[/code], if font supports drawing glyph outlines. </description> </method> <method name="is_language_supported" qualifiers="const"> - <return type="bool"> - </return> - <argument index="0" name="language" type="String"> - </argument> + <return type="bool" /> + <argument index="0" name="language" type="String" /> <description> Returns [code]true[/code], if font supports given language ([url=https://en.wikipedia.org/wiki/ISO_639-1]ISO 639[/url] code). </description> </method> <method name="is_script_supported" qualifiers="const"> - <return type="bool"> - </return> - <argument index="0" name="script" type="String"> - </argument> + <return type="bool" /> + <argument index="0" name="script" type="String" /> <description> Returns [code]true[/code], if font supports given script ([url=https://en.wikipedia.org/wiki/ISO_15924]ISO 15924[/url] code). </description> </method> <method name="load_memory"> - <return type="void"> - </return> - <argument index="0" name="data" type="PackedByteArray"> - </argument> - <argument index="1" name="type" type="String"> - </argument> - <argument index="2" name="base_size" type="int" default="16"> - </argument> + <return type="void" /> + <argument index="0" name="data" type="PackedByteArray" /> + <argument index="1" name="type" type="String" /> + <argument index="2" name="base_size" type="int" default="16" /> <description> Creates new font from the data in memory. Note: For non-scalable fonts [code]base_size[/code] is ignored, use [method get_base_size] to check actual font size. </description> </method> <method name="load_resource"> - <return type="void"> - </return> - <argument index="0" name="filename" type="String"> - </argument> - <argument index="1" name="base_size" type="int" default="16"> - </argument> + <return type="void" /> + <argument index="0" name="filename" type="String" /> + <argument index="1" name="base_size" type="int" default="16" /> <description> Creates new font from the file. Note: For non-scalable fonts [code]base_size[/code] is ignored, use [method get_base_size] to check actual font size. </description> </method> <method name="new_bitmap"> - <return type="void"> - </return> - <argument index="0" name="height" type="float"> - </argument> - <argument index="1" name="ascent" type="float"> - </argument> - <argument index="2" name="base_size" type="int"> - </argument> + <return type="void" /> + <argument index="0" name="height" type="float" /> + <argument index="1" name="ascent" type="float" /> + <argument index="2" name="base_size" type="int" /> <description> Creates new, empty bitmap font. </description> </method> <method name="remove_language_support_override"> - <return type="void"> - </return> - <argument index="0" name="language" type="String"> - </argument> + <return type="void" /> + <argument index="0" name="language" type="String" /> <description> Remove language support override. </description> </method> <method name="remove_script_support_override"> - <return type="void"> - </return> - <argument index="0" name="script" type="String"> - </argument> + <return type="void" /> + <argument index="0" name="script" type="String" /> <description> Removes script support override. </description> </method> <method name="set_language_support_override"> - <return type="void"> - </return> - <argument index="0" name="language" type="String"> - </argument> - <argument index="1" name="supported" type="bool"> - </argument> + <return type="void" /> + <argument index="0" name="language" type="String" /> + <argument index="1" name="supported" type="bool" /> <description> Adds override for [method is_language_supported]. </description> </method> <method name="set_script_support_override"> - <return type="void"> - </return> - <argument index="0" name="script" type="String"> - </argument> - <argument index="1" name="supported" type="bool"> - </argument> + <return type="void" /> + <argument index="0" name="script" type="String" /> + <argument index="1" name="supported" type="bool" /> <description> Adds override for [method is_script_supported]. </description> </method> <method name="set_spacing"> - <return type="void"> - </return> - <argument index="0" name="type" type="int"> - </argument> - <argument index="1" name="value" type="int"> - </argument> + <return type="void" /> + <argument index="0" name="type" type="int" /> + <argument index="1" name="value" type="int" /> <description> Sets the spacing for [code]type[/code] (see [enum SpacingType]) to [code]value[/code] in pixels (not relative to the font size). </description> </method> <method name="set_variation"> - <return type="void"> - </return> - <argument index="0" name="tag" type="String"> - </argument> - <argument index="1" name="value" type="float"> - </argument> + <return type="void" /> + <argument index="0" name="tag" type="String" /> + <argument index="1" name="value" type="float" /> <description> Sets variation coordinate [code]tag[/code]. </description> diff --git a/doc/classes/GPUParticles2D.xml b/doc/classes/GPUParticles2D.xml index 8684a7f41a..72bd6a6411 100644 --- a/doc/classes/GPUParticles2D.xml +++ b/doc/classes/GPUParticles2D.xml @@ -13,15 +13,13 @@ </tutorials> <methods> <method name="capture_rect" qualifiers="const"> - <return type="Rect2"> - </return> + <return type="Rect2" /> <description> Returns a rectangle containing the positions of all existing particles. </description> </method> <method name="restart"> - <return type="void"> - </return> + <return type="void" /> <description> Restarts all the existing particles. </description> diff --git a/doc/classes/GPUParticles3D.xml b/doc/classes/GPUParticles3D.xml index 55e9b33aa8..3f7b20f274 100644 --- a/doc/classes/GPUParticles3D.xml +++ b/doc/classes/GPUParticles3D.xml @@ -13,51 +13,38 @@ </tutorials> <methods> <method name="capture_aabb" qualifiers="const"> - <return type="AABB"> - </return> + <return type="AABB" /> <description> Returns the axis-aligned bounding box that contains all the particles that are active in the current frame. </description> </method> <method name="emit_particle"> - <return type="void"> - </return> - <argument index="0" name="xform" type="Transform3D"> - </argument> - <argument index="1" name="velocity" type="Vector3"> - </argument> - <argument index="2" name="color" type="Color"> - </argument> - <argument index="3" name="custom" type="Color"> - </argument> - <argument index="4" name="flags" type="int"> - </argument> + <return type="void" /> + <argument index="0" name="xform" type="Transform3D" /> + <argument index="1" name="velocity" type="Vector3" /> + <argument index="2" name="color" type="Color" /> + <argument index="3" name="custom" type="Color" /> + <argument index="4" name="flags" type="int" /> <description> </description> </method> <method name="get_draw_pass_mesh" qualifiers="const"> - <return type="Mesh"> - </return> - <argument index="0" name="pass" type="int"> - </argument> + <return type="Mesh" /> + <argument index="0" name="pass" type="int" /> <description> Returns the [Mesh] that is drawn at index [code]pass[/code]. </description> </method> <method name="restart"> - <return type="void"> - </return> + <return type="void" /> <description> Restarts the particle emission, clearing existing particles. </description> </method> <method name="set_draw_pass_mesh"> - <return type="void"> - </return> - <argument index="0" name="pass" type="int"> - </argument> - <argument index="1" name="mesh" type="Mesh"> - </argument> + <return type="void" /> + <argument index="0" name="pass" type="int" /> + <argument index="1" name="mesh" type="Mesh" /> <description> Sets the [Mesh] that is drawn at index [code]pass[/code]. </description> diff --git a/doc/classes/Generic6DOFJoint3D.xml b/doc/classes/Generic6DOFJoint3D.xml index 79b861dfb8..ebfcaa7678 100644 --- a/doc/classes/Generic6DOFJoint3D.xml +++ b/doc/classes/Generic6DOFJoint3D.xml @@ -10,110 +10,80 @@ </tutorials> <methods> <method name="get_flag_x" qualifiers="const"> - <return type="bool"> - </return> - <argument index="0" name="flag" type="int" enum="Generic6DOFJoint3D.Flag"> - </argument> + <return type="bool" /> + <argument index="0" name="flag" type="int" enum="Generic6DOFJoint3D.Flag" /> <description> </description> </method> <method name="get_flag_y" qualifiers="const"> - <return type="bool"> - </return> - <argument index="0" name="flag" type="int" enum="Generic6DOFJoint3D.Flag"> - </argument> + <return type="bool" /> + <argument index="0" name="flag" type="int" enum="Generic6DOFJoint3D.Flag" /> <description> </description> </method> <method name="get_flag_z" qualifiers="const"> - <return type="bool"> - </return> - <argument index="0" name="flag" type="int" enum="Generic6DOFJoint3D.Flag"> - </argument> + <return type="bool" /> + <argument index="0" name="flag" type="int" enum="Generic6DOFJoint3D.Flag" /> <description> </description> </method> <method name="get_param_x" qualifiers="const"> - <return type="float"> - </return> - <argument index="0" name="param" type="int" enum="Generic6DOFJoint3D.Param"> - </argument> + <return type="float" /> + <argument index="0" name="param" type="int" enum="Generic6DOFJoint3D.Param" /> <description> </description> </method> <method name="get_param_y" qualifiers="const"> - <return type="float"> - </return> - <argument index="0" name="param" type="int" enum="Generic6DOFJoint3D.Param"> - </argument> + <return type="float" /> + <argument index="0" name="param" type="int" enum="Generic6DOFJoint3D.Param" /> <description> </description> </method> <method name="get_param_z" qualifiers="const"> - <return type="float"> - </return> - <argument index="0" name="param" type="int" enum="Generic6DOFJoint3D.Param"> - </argument> + <return type="float" /> + <argument index="0" name="param" type="int" enum="Generic6DOFJoint3D.Param" /> <description> </description> </method> <method name="set_flag_x"> - <return type="void"> - </return> - <argument index="0" name="flag" type="int" enum="Generic6DOFJoint3D.Flag"> - </argument> - <argument index="1" name="value" type="bool"> - </argument> + <return type="void" /> + <argument index="0" name="flag" type="int" enum="Generic6DOFJoint3D.Flag" /> + <argument index="1" name="value" type="bool" /> <description> </description> </method> <method name="set_flag_y"> - <return type="void"> - </return> - <argument index="0" name="flag" type="int" enum="Generic6DOFJoint3D.Flag"> - </argument> - <argument index="1" name="value" type="bool"> - </argument> + <return type="void" /> + <argument index="0" name="flag" type="int" enum="Generic6DOFJoint3D.Flag" /> + <argument index="1" name="value" type="bool" /> <description> </description> </method> <method name="set_flag_z"> - <return type="void"> - </return> - <argument index="0" name="flag" type="int" enum="Generic6DOFJoint3D.Flag"> - </argument> - <argument index="1" name="value" type="bool"> - </argument> + <return type="void" /> + <argument index="0" name="flag" type="int" enum="Generic6DOFJoint3D.Flag" /> + <argument index="1" name="value" type="bool" /> <description> </description> </method> <method name="set_param_x"> - <return type="void"> - </return> - <argument index="0" name="param" type="int" enum="Generic6DOFJoint3D.Param"> - </argument> - <argument index="1" name="value" type="float"> - </argument> + <return type="void" /> + <argument index="0" name="param" type="int" enum="Generic6DOFJoint3D.Param" /> + <argument index="1" name="value" type="float" /> <description> </description> </method> <method name="set_param_y"> - <return type="void"> - </return> - <argument index="0" name="param" type="int" enum="Generic6DOFJoint3D.Param"> - </argument> - <argument index="1" name="value" type="float"> - </argument> + <return type="void" /> + <argument index="0" name="param" type="int" enum="Generic6DOFJoint3D.Param" /> + <argument index="1" name="value" type="float" /> <description> </description> </method> <method name="set_param_z"> - <return type="void"> - </return> - <argument index="0" name="param" type="int" enum="Generic6DOFJoint3D.Param"> - </argument> - <argument index="1" name="value" type="float"> - </argument> + <return type="void" /> + <argument index="0" name="param" type="int" enum="Generic6DOFJoint3D.Param" /> + <argument index="1" name="value" type="float" /> <description> </description> </method> diff --git a/doc/classes/Geometry2D.xml b/doc/classes/Geometry2D.xml index 13354ec19e..157124cded 100644 --- a/doc/classes/Geometry2D.xml +++ b/doc/classes/Geometry2D.xml @@ -10,192 +10,139 @@ </tutorials> <methods> <method name="clip_polygons"> - <return type="Array"> - </return> - <argument index="0" name="polygon_a" type="PackedVector2Array"> - </argument> - <argument index="1" name="polygon_b" type="PackedVector2Array"> - </argument> + <return type="Array" /> + <argument index="0" name="polygon_a" type="PackedVector2Array" /> + <argument index="1" name="polygon_b" type="PackedVector2Array" /> <description> Clips [code]polygon_a[/code] against [code]polygon_b[/code] and returns an array of clipped polygons. This performs [constant OPERATION_DIFFERENCE] between polygons. Returns an empty array if [code]polygon_b[/code] completely overlaps [code]polygon_a[/code]. If [code]polygon_b[/code] is enclosed by [code]polygon_a[/code], returns an outer polygon (boundary) and inner polygon (hole) which could be distinguished by calling [method is_polygon_clockwise]. </description> </method> <method name="clip_polyline_with_polygon"> - <return type="Array"> - </return> - <argument index="0" name="polyline" type="PackedVector2Array"> - </argument> - <argument index="1" name="polygon" type="PackedVector2Array"> - </argument> + <return type="Array" /> + <argument index="0" name="polyline" type="PackedVector2Array" /> + <argument index="1" name="polygon" type="PackedVector2Array" /> <description> Clips [code]polyline[/code] against [code]polygon[/code] and returns an array of clipped polylines. This performs [constant OPERATION_DIFFERENCE] between the polyline and the polygon. This operation can be thought of as cutting a line with a closed shape. </description> </method> <method name="convex_hull"> - <return type="PackedVector2Array"> - </return> - <argument index="0" name="points" type="PackedVector2Array"> - </argument> + <return type="PackedVector2Array" /> + <argument index="0" name="points" type="PackedVector2Array" /> <description> Given an array of [Vector2]s, returns the convex hull as a list of points in counterclockwise order. The last point is the same as the first one. </description> </method> <method name="exclude_polygons"> - <return type="Array"> - </return> - <argument index="0" name="polygon_a" type="PackedVector2Array"> - </argument> - <argument index="1" name="polygon_b" type="PackedVector2Array"> - </argument> + <return type="Array" /> + <argument index="0" name="polygon_a" type="PackedVector2Array" /> + <argument index="1" name="polygon_b" type="PackedVector2Array" /> <description> Mutually excludes common area defined by intersection of [code]polygon_a[/code] and [code]polygon_b[/code] (see [method intersect_polygons]) and returns an array of excluded polygons. This performs [constant OPERATION_XOR] between polygons. In other words, returns all but common area between polygons. The operation may result in an outer polygon (boundary) and inner polygon (hole) produced which could be distinguished by calling [method is_polygon_clockwise]. </description> </method> <method name="get_closest_point_to_segment"> - <return type="Vector2"> - </return> - <argument index="0" name="point" type="Vector2"> - </argument> - <argument index="1" name="s1" type="Vector2"> - </argument> - <argument index="2" name="s2" type="Vector2"> - </argument> + <return type="Vector2" /> + <argument index="0" name="point" type="Vector2" /> + <argument index="1" name="s1" type="Vector2" /> + <argument index="2" name="s2" type="Vector2" /> <description> Returns the 2D point on the 2D segment ([code]s1[/code], [code]s2[/code]) that is closest to [code]point[/code]. The returned point will always be inside the specified segment. </description> </method> <method name="get_closest_point_to_segment_uncapped"> - <return type="Vector2"> - </return> - <argument index="0" name="point" type="Vector2"> - </argument> - <argument index="1" name="s1" type="Vector2"> - </argument> - <argument index="2" name="s2" type="Vector2"> - </argument> + <return type="Vector2" /> + <argument index="0" name="point" type="Vector2" /> + <argument index="1" name="s1" type="Vector2" /> + <argument index="2" name="s2" type="Vector2" /> <description> Returns the 2D point on the 2D line defined by ([code]s1[/code], [code]s2[/code]) that is closest to [code]point[/code]. The returned point can be inside the segment ([code]s1[/code], [code]s2[/code]) or outside of it, i.e. somewhere on the line extending from the segment. </description> </method> <method name="get_closest_points_between_segments"> - <return type="PackedVector2Array"> - </return> - <argument index="0" name="p1" type="Vector2"> - </argument> - <argument index="1" name="q1" type="Vector2"> - </argument> - <argument index="2" name="p2" type="Vector2"> - </argument> - <argument index="3" name="q2" type="Vector2"> - </argument> + <return type="PackedVector2Array" /> + <argument index="0" name="p1" type="Vector2" /> + <argument index="1" name="q1" type="Vector2" /> + <argument index="2" name="p2" type="Vector2" /> + <argument index="3" name="q2" type="Vector2" /> <description> Given the two 2D segments ([code]p1[/code], [code]q1[/code]) and ([code]p2[/code], [code]q2[/code]), finds those two points on the two segments that are closest to each other. Returns a [PackedVector2Array] that contains this point on ([code]p1[/code], [code]q1[/code]) as well the accompanying point on ([code]p2[/code], [code]q2[/code]). </description> </method> <method name="intersect_polygons"> - <return type="Array"> - </return> - <argument index="0" name="polygon_a" type="PackedVector2Array"> - </argument> - <argument index="1" name="polygon_b" type="PackedVector2Array"> - </argument> + <return type="Array" /> + <argument index="0" name="polygon_a" type="PackedVector2Array" /> + <argument index="1" name="polygon_b" type="PackedVector2Array" /> <description> Intersects [code]polygon_a[/code] with [code]polygon_b[/code] and returns an array of intersected polygons. This performs [constant OPERATION_INTERSECTION] between polygons. In other words, returns common area shared by polygons. Returns an empty array if no intersection occurs. The operation may result in an outer polygon (boundary) and inner polygon (hole) produced which could be distinguished by calling [method is_polygon_clockwise]. </description> </method> <method name="intersect_polyline_with_polygon"> - <return type="Array"> - </return> - <argument index="0" name="polyline" type="PackedVector2Array"> - </argument> - <argument index="1" name="polygon" type="PackedVector2Array"> - </argument> + <return type="Array" /> + <argument index="0" name="polyline" type="PackedVector2Array" /> + <argument index="1" name="polygon" type="PackedVector2Array" /> <description> Intersects [code]polyline[/code] with [code]polygon[/code] and returns an array of intersected polylines. This performs [constant OPERATION_INTERSECTION] between the polyline and the polygon. This operation can be thought of as chopping a line with a closed shape. </description> </method> <method name="is_point_in_circle"> - <return type="bool"> - </return> - <argument index="0" name="point" type="Vector2"> - </argument> - <argument index="1" name="circle_position" type="Vector2"> - </argument> - <argument index="2" name="circle_radius" type="float"> - </argument> + <return type="bool" /> + <argument index="0" name="point" type="Vector2" /> + <argument index="1" name="circle_position" type="Vector2" /> + <argument index="2" name="circle_radius" type="float" /> <description> Returns [code]true[/code] if [code]point[/code] is inside the circle or if it's located exactly [i]on[/i] the circle's boundary, otherwise returns [code]false[/code]. </description> </method> <method name="is_point_in_polygon"> - <return type="bool"> - </return> - <argument index="0" name="point" type="Vector2"> - </argument> - <argument index="1" name="polygon" type="PackedVector2Array"> - </argument> + <return type="bool" /> + <argument index="0" name="point" type="Vector2" /> + <argument index="1" name="polygon" type="PackedVector2Array" /> <description> Returns [code]true[/code] if [code]point[/code] is inside [code]polygon[/code] or if it's located exactly [i]on[/i] polygon's boundary, otherwise returns [code]false[/code]. </description> </method> <method name="is_polygon_clockwise"> - <return type="bool"> - </return> - <argument index="0" name="polygon" type="PackedVector2Array"> - </argument> + <return type="bool" /> + <argument index="0" name="polygon" type="PackedVector2Array" /> <description> Returns [code]true[/code] if [code]polygon[/code]'s vertices are ordered in clockwise order, otherwise returns [code]false[/code]. </description> </method> <method name="line_intersects_line"> - <return type="Variant"> - </return> - <argument index="0" name="from_a" type="Vector2"> - </argument> - <argument index="1" name="dir_a" type="Vector2"> - </argument> - <argument index="2" name="from_b" type="Vector2"> - </argument> - <argument index="3" name="dir_b" type="Vector2"> - </argument> + <return type="Variant" /> + <argument index="0" name="from_a" type="Vector2" /> + <argument index="1" name="dir_a" type="Vector2" /> + <argument index="2" name="from_b" type="Vector2" /> + <argument index="3" name="dir_b" type="Vector2" /> <description> Checks if the two lines ([code]from_a[/code], [code]dir_a[/code]) and ([code]from_b[/code], [code]dir_b[/code]) intersect. If yes, return the point of intersection as [Vector2]. If no intersection takes place, returns an empty [Variant]. [b]Note:[/b] The lines are specified using direction vectors, not end points. </description> </method> <method name="make_atlas"> - <return type="Dictionary"> - </return> - <argument index="0" name="sizes" type="PackedVector2Array"> - </argument> + <return type="Dictionary" /> + <argument index="0" name="sizes" type="PackedVector2Array" /> <description> Given an array of [Vector2]s representing tiles, builds an atlas. The returned dictionary has two keys: [code]points[/code] is a vector of [Vector2] that specifies the positions of each tile, [code]size[/code] contains the overall size of the whole atlas as [Vector2]. </description> </method> <method name="merge_polygons"> - <return type="Array"> - </return> - <argument index="0" name="polygon_a" type="PackedVector2Array"> - </argument> - <argument index="1" name="polygon_b" type="PackedVector2Array"> - </argument> + <return type="Array" /> + <argument index="0" name="polygon_a" type="PackedVector2Array" /> + <argument index="1" name="polygon_b" type="PackedVector2Array" /> <description> Merges (combines) [code]polygon_a[/code] and [code]polygon_b[/code] and returns an array of merged polygons. This performs [constant OPERATION_UNION] between polygons. The operation may result in an outer polygon (boundary) and multiple inner polygons (holes) produced which could be distinguished by calling [method is_polygon_clockwise]. </description> </method> <method name="offset_polygon"> - <return type="Array"> - </return> - <argument index="0" name="polygon" type="PackedVector2Array"> - </argument> - <argument index="1" name="delta" type="float"> - </argument> - <argument index="2" name="join_type" type="int" enum="Geometry2D.PolyJoinType" default="0"> - </argument> + <return type="Array" /> + <argument index="0" name="polygon" type="PackedVector2Array" /> + <argument index="1" name="delta" type="float" /> + <argument index="2" name="join_type" type="int" enum="Geometry2D.PolyJoinType" default="0" /> <description> Inflates or deflates [code]polygon[/code] by [code]delta[/code] units (pixels). If [code]delta[/code] is positive, makes the polygon grow outward. If [code]delta[/code] is negative, shrinks the polygon inward. Returns an array of polygons because inflating/deflating may result in multiple discrete polygons. Returns an empty array if [code]delta[/code] is negative and the absolute value of it approximately exceeds the minimum bounding rectangle dimensions of the polygon. Each polygon's vertices will be rounded as determined by [code]join_type[/code], see [enum PolyJoinType]. @@ -219,16 +166,11 @@ </description> </method> <method name="offset_polyline"> - <return type="Array"> - </return> - <argument index="0" name="polyline" type="PackedVector2Array"> - </argument> - <argument index="1" name="delta" type="float"> - </argument> - <argument index="2" name="join_type" type="int" enum="Geometry2D.PolyJoinType" default="0"> - </argument> - <argument index="3" name="end_type" type="int" enum="Geometry2D.PolyEndType" default="3"> - </argument> + <return type="Array" /> + <argument index="0" name="polyline" type="PackedVector2Array" /> + <argument index="1" name="delta" type="float" /> + <argument index="2" name="join_type" type="int" enum="Geometry2D.PolyJoinType" default="0" /> + <argument index="3" name="end_type" type="int" enum="Geometry2D.PolyEndType" default="3" /> <description> Inflates or deflates [code]polyline[/code] by [code]delta[/code] units (pixels), producing polygons. If [code]delta[/code] is positive, makes the polyline grow outward. Returns an array of polygons because inflating/deflating may result in multiple discrete polygons. If [code]delta[/code] is negative, returns an empty array. Each polygon's vertices will be rounded as determined by [code]join_type[/code], see [enum PolyJoinType]. @@ -237,49 +179,35 @@ </description> </method> <method name="point_is_inside_triangle" qualifiers="const"> - <return type="bool"> - </return> - <argument index="0" name="point" type="Vector2"> - </argument> - <argument index="1" name="a" type="Vector2"> - </argument> - <argument index="2" name="b" type="Vector2"> - </argument> - <argument index="3" name="c" type="Vector2"> - </argument> + <return type="bool" /> + <argument index="0" name="point" type="Vector2" /> + <argument index="1" name="a" type="Vector2" /> + <argument index="2" name="b" type="Vector2" /> + <argument index="3" name="c" type="Vector2" /> <description> Returns if [code]point[/code] is inside the triangle specified by [code]a[/code], [code]b[/code] and [code]c[/code]. </description> </method> <method name="segment_intersects_segment"> - <return type="Variant"> - </return> - <argument index="0" name="from_a" type="Vector2"> - </argument> - <argument index="1" name="to_a" type="Vector2"> - </argument> - <argument index="2" name="from_b" type="Vector2"> - </argument> - <argument index="3" name="to_b" type="Vector2"> - </argument> + <return type="Variant" /> + <argument index="0" name="from_a" type="Vector2" /> + <argument index="1" name="to_a" type="Vector2" /> + <argument index="2" name="from_b" type="Vector2" /> + <argument index="3" name="to_b" type="Vector2" /> <description> Checks if the two segments ([code]from_a[/code], [code]to_a[/code]) and ([code]from_b[/code], [code]to_b[/code]) intersect. If yes, return the point of intersection as [Vector2]. If no intersection takes place, returns an empty [Variant]. </description> </method> <method name="triangulate_delaunay"> - <return type="PackedInt32Array"> - </return> - <argument index="0" name="points" type="PackedVector2Array"> - </argument> + <return type="PackedInt32Array" /> + <argument index="0" name="points" type="PackedVector2Array" /> <description> Triangulates the area specified by discrete set of [code]points[/code] such that no point is inside the circumcircle of any resulting triangle. Returns a [PackedInt32Array] where each triangle consists of three consecutive point indices into [code]points[/code] (i.e. the returned array will have [code]n * 3[/code] elements, with [code]n[/code] being the number of found triangles). If the triangulation did not succeed, an empty [PackedInt32Array] is returned. </description> </method> <method name="triangulate_polygon"> - <return type="PackedInt32Array"> - </return> - <argument index="0" name="polygon" type="PackedVector2Array"> - </argument> + <return type="PackedInt32Array" /> + <argument index="0" name="polygon" type="PackedVector2Array" /> <description> Triangulates the polygon specified by the points in [code]polygon[/code]. Returns a [PackedInt32Array] where each triangle consists of three consecutive point indices into [code]polygon[/code] (i.e. the returned array will have [code]n * 3[/code] elements, with [code]n[/code] being the number of found triangles). If the triangulation did not succeed, an empty [PackedInt32Array] is returned. </description> diff --git a/doc/classes/Geometry3D.xml b/doc/classes/Geometry3D.xml index 9f012008e3..9d0234529a 100644 --- a/doc/classes/Geometry3D.xml +++ b/doc/classes/Geometry3D.xml @@ -10,171 +10,116 @@ </tutorials> <methods> <method name="build_box_planes"> - <return type="Array"> - </return> - <argument index="0" name="extents" type="Vector3"> - </argument> + <return type="Array" /> + <argument index="0" name="extents" type="Vector3" /> <description> Returns an array with 6 [Plane]s that describe the sides of a box centered at the origin. The box size is defined by [code]extents[/code], which represents one (positive) corner of the box (i.e. half its actual size). </description> </method> <method name="build_capsule_planes"> - <return type="Array"> - </return> - <argument index="0" name="radius" type="float"> - </argument> - <argument index="1" name="height" type="float"> - </argument> - <argument index="2" name="sides" type="int"> - </argument> - <argument index="3" name="lats" type="int"> - </argument> - <argument index="4" name="axis" type="int" enum="Vector3.Axis" default="2"> - </argument> + <return type="Array" /> + <argument index="0" name="radius" type="float" /> + <argument index="1" name="height" type="float" /> + <argument index="2" name="sides" type="int" /> + <argument index="3" name="lats" type="int" /> + <argument index="4" name="axis" type="int" enum="Vector3.Axis" default="2" /> <description> Returns an array of [Plane]s closely bounding a faceted capsule centered at the origin with radius [code]radius[/code] and height [code]height[/code]. The parameter [code]sides[/code] defines how many planes will be generated for the side part of the capsule, whereas [code]lats[/code] gives the number of latitudinal steps at the bottom and top of the capsule. The parameter [code]axis[/code] describes the axis along which the capsule is oriented (0 for X, 1 for Y, 2 for Z). </description> </method> <method name="build_cylinder_planes"> - <return type="Array"> - </return> - <argument index="0" name="radius" type="float"> - </argument> - <argument index="1" name="height" type="float"> - </argument> - <argument index="2" name="sides" type="int"> - </argument> - <argument index="3" name="axis" type="int" enum="Vector3.Axis" default="2"> - </argument> + <return type="Array" /> + <argument index="0" name="radius" type="float" /> + <argument index="1" name="height" type="float" /> + <argument index="2" name="sides" type="int" /> + <argument index="3" name="axis" type="int" enum="Vector3.Axis" default="2" /> <description> Returns an array of [Plane]s closely bounding a faceted cylinder centered at the origin with radius [code]radius[/code] and height [code]height[/code]. The parameter [code]sides[/code] defines how many planes will be generated for the round part of the cylinder. The parameter [code]axis[/code] describes the axis along which the cylinder is oriented (0 for X, 1 for Y, 2 for Z). </description> </method> <method name="clip_polygon"> - <return type="PackedVector3Array"> - </return> - <argument index="0" name="points" type="PackedVector3Array"> - </argument> - <argument index="1" name="plane" type="Plane"> - </argument> + <return type="PackedVector3Array" /> + <argument index="0" name="points" type="PackedVector3Array" /> + <argument index="1" name="plane" type="Plane" /> <description> Clips the polygon defined by the points in [code]points[/code] against the [code]plane[/code] and returns the points of the clipped polygon. </description> </method> <method name="get_closest_point_to_segment"> - <return type="Vector3"> - </return> - <argument index="0" name="point" type="Vector3"> - </argument> - <argument index="1" name="s1" type="Vector3"> - </argument> - <argument index="2" name="s2" type="Vector3"> - </argument> + <return type="Vector3" /> + <argument index="0" name="point" type="Vector3" /> + <argument index="1" name="s1" type="Vector3" /> + <argument index="2" name="s2" type="Vector3" /> <description> Returns the 3D point on the 3D segment ([code]s1[/code], [code]s2[/code]) that is closest to [code]point[/code]. The returned point will always be inside the specified segment. </description> </method> <method name="get_closest_point_to_segment_uncapped"> - <return type="Vector3"> - </return> - <argument index="0" name="point" type="Vector3"> - </argument> - <argument index="1" name="s1" type="Vector3"> - </argument> - <argument index="2" name="s2" type="Vector3"> - </argument> + <return type="Vector3" /> + <argument index="0" name="point" type="Vector3" /> + <argument index="1" name="s1" type="Vector3" /> + <argument index="2" name="s2" type="Vector3" /> <description> Returns the 3D point on the 3D line defined by ([code]s1[/code], [code]s2[/code]) that is closest to [code]point[/code]. The returned point can be inside the segment ([code]s1[/code], [code]s2[/code]) or outside of it, i.e. somewhere on the line extending from the segment. </description> </method> <method name="get_closest_points_between_segments"> - <return type="PackedVector3Array"> - </return> - <argument index="0" name="p1" type="Vector3"> - </argument> - <argument index="1" name="p2" type="Vector3"> - </argument> - <argument index="2" name="q1" type="Vector3"> - </argument> - <argument index="3" name="q2" type="Vector3"> - </argument> + <return type="PackedVector3Array" /> + <argument index="0" name="p1" type="Vector3" /> + <argument index="1" name="p2" type="Vector3" /> + <argument index="2" name="q1" type="Vector3" /> + <argument index="3" name="q2" type="Vector3" /> <description> Given the two 3D segments ([code]p1[/code], [code]p2[/code]) and ([code]q1[/code], [code]q2[/code]), finds those two points on the two segments that are closest to each other. Returns a [PackedVector3Array] that contains this point on ([code]p1[/code], [code]p2[/code]) as well the accompanying point on ([code]q1[/code], [code]q2[/code]). </description> </method> <method name="ray_intersects_triangle"> - <return type="Variant"> - </return> - <argument index="0" name="from" type="Vector3"> - </argument> - <argument index="1" name="dir" type="Vector3"> - </argument> - <argument index="2" name="a" type="Vector3"> - </argument> - <argument index="3" name="b" type="Vector3"> - </argument> - <argument index="4" name="c" type="Vector3"> - </argument> + <return type="Variant" /> + <argument index="0" name="from" type="Vector3" /> + <argument index="1" name="dir" type="Vector3" /> + <argument index="2" name="a" type="Vector3" /> + <argument index="3" name="b" type="Vector3" /> + <argument index="4" name="c" type="Vector3" /> <description> Tests if the 3D ray starting at [code]from[/code] with the direction of [code]dir[/code] intersects the triangle specified by [code]a[/code], [code]b[/code] and [code]c[/code]. If yes, returns the point of intersection as [Vector3]. If no intersection takes place, an empty [Variant] is returned. </description> </method> <method name="segment_intersects_convex"> - <return type="PackedVector3Array"> - </return> - <argument index="0" name="from" type="Vector3"> - </argument> - <argument index="1" name="to" type="Vector3"> - </argument> - <argument index="2" name="planes" type="Array"> - </argument> + <return type="PackedVector3Array" /> + <argument index="0" name="from" type="Vector3" /> + <argument index="1" name="to" type="Vector3" /> + <argument index="2" name="planes" type="Array" /> <description> Given a convex hull defined though the [Plane]s in the array [code]planes[/code], tests if the segment ([code]from[/code], [code]to[/code]) intersects with that hull. If an intersection is found, returns a [PackedVector3Array] containing the point the intersection and the hull's normal. Otherwise, returns an empty array. </description> </method> <method name="segment_intersects_cylinder"> - <return type="PackedVector3Array"> - </return> - <argument index="0" name="from" type="Vector3"> - </argument> - <argument index="1" name="to" type="Vector3"> - </argument> - <argument index="2" name="height" type="float"> - </argument> - <argument index="3" name="radius" type="float"> - </argument> + <return type="PackedVector3Array" /> + <argument index="0" name="from" type="Vector3" /> + <argument index="1" name="to" type="Vector3" /> + <argument index="2" name="height" type="float" /> + <argument index="3" name="radius" type="float" /> <description> Checks if the segment ([code]from[/code], [code]to[/code]) intersects the cylinder with height [code]height[/code] that is centered at the origin and has radius [code]radius[/code]. If no, returns an empty [PackedVector3Array]. If an intersection takes place, the returned array contains the point of intersection and the cylinder's normal at the point of intersection. </description> </method> <method name="segment_intersects_sphere"> - <return type="PackedVector3Array"> - </return> - <argument index="0" name="from" type="Vector3"> - </argument> - <argument index="1" name="to" type="Vector3"> - </argument> - <argument index="2" name="sphere_position" type="Vector3"> - </argument> - <argument index="3" name="sphere_radius" type="float"> - </argument> + <return type="PackedVector3Array" /> + <argument index="0" name="from" type="Vector3" /> + <argument index="1" name="to" type="Vector3" /> + <argument index="2" name="sphere_position" type="Vector3" /> + <argument index="3" name="sphere_radius" type="float" /> <description> Checks if the segment ([code]from[/code], [code]to[/code]) intersects the sphere that is located at [code]sphere_position[/code] and has radius [code]sphere_radius[/code]. If no, returns an empty [PackedVector3Array]. If yes, returns a [PackedVector3Array] containing the point of intersection and the sphere's normal at the point of intersection. </description> </method> <method name="segment_intersects_triangle"> - <return type="Variant"> - </return> - <argument index="0" name="from" type="Vector3"> - </argument> - <argument index="1" name="to" type="Vector3"> - </argument> - <argument index="2" name="a" type="Vector3"> - </argument> - <argument index="3" name="b" type="Vector3"> - </argument> - <argument index="4" name="c" type="Vector3"> - </argument> + <return type="Variant" /> + <argument index="0" name="from" type="Vector3" /> + <argument index="1" name="to" type="Vector3" /> + <argument index="2" name="a" type="Vector3" /> + <argument index="3" name="b" type="Vector3" /> + <argument index="4" name="c" type="Vector3" /> <description> Tests if the segment ([code]from[/code], [code]to[/code]) intersects the triangle [code]a[/code], [code]b[/code], [code]c[/code]. If yes, returns the point of intersection as [Vector3]. If no intersection takes place, an empty [Variant] is returned. </description> diff --git a/doc/classes/GeometryInstance3D.xml b/doc/classes/GeometryInstance3D.xml index 667ca2dacf..97cef205c3 100644 --- a/doc/classes/GeometryInstance3D.xml +++ b/doc/classes/GeometryInstance3D.xml @@ -10,29 +10,22 @@ </tutorials> <methods> <method name="get_shader_instance_uniform" qualifiers="const"> - <return type="Variant"> - </return> - <argument index="0" name="uniform" type="StringName"> - </argument> + <return type="Variant" /> + <argument index="0" name="uniform" type="StringName" /> <description> </description> </method> <method name="set_custom_aabb"> - <return type="void"> - </return> - <argument index="0" name="aabb" type="AABB"> - </argument> + <return type="void" /> + <argument index="0" name="aabb" type="AABB" /> <description> Overrides the bounding box of this node with a custom one. To remove it, set an [AABB] with all fields set to zero. </description> </method> <method name="set_shader_instance_uniform"> - <return type="void"> - </return> - <argument index="0" name="uniform" type="StringName"> - </argument> - <argument index="1" name="value" type="Variant"> - </argument> + <return type="void" /> + <argument index="0" name="uniform" type="StringName" /> + <argument index="1" name="value" type="Variant" /> <description> </description> </method> diff --git a/doc/classes/Gradient.xml b/doc/classes/Gradient.xml index 1f1f266c59..a9577fda90 100644 --- a/doc/classes/Gradient.xml +++ b/doc/classes/Gradient.xml @@ -10,77 +10,59 @@ </tutorials> <methods> <method name="add_point"> - <return type="void"> - </return> - <argument index="0" name="offset" type="float"> - </argument> - <argument index="1" name="color" type="Color"> - </argument> + <return type="void" /> + <argument index="0" name="offset" type="float" /> + <argument index="1" name="color" type="Color" /> <description> Adds the specified color to the end of the gradient, with the specified offset. </description> </method> <method name="get_color"> - <return type="Color"> - </return> - <argument index="0" name="point" type="int"> - </argument> + <return type="Color" /> + <argument index="0" name="point" type="int" /> <description> Returns the color of the gradient color at index [code]point[/code]. </description> </method> <method name="get_offset"> - <return type="float"> - </return> - <argument index="0" name="point" type="int"> - </argument> + <return type="float" /> + <argument index="0" name="point" type="int" /> <description> Returns the offset of the gradient color at index [code]point[/code]. </description> </method> <method name="get_point_count" qualifiers="const"> - <return type="int"> - </return> + <return type="int" /> <description> Returns the number of colors in the gradient. </description> </method> <method name="interpolate"> - <return type="Color"> - </return> - <argument index="0" name="offset" type="float"> - </argument> + <return type="Color" /> + <argument index="0" name="offset" type="float" /> <description> Returns the interpolated color specified by [code]offset[/code]. </description> </method> <method name="remove_point"> - <return type="void"> - </return> - <argument index="0" name="point" type="int"> - </argument> + <return type="void" /> + <argument index="0" name="point" type="int" /> <description> Removes the color at the index [code]point[/code]. </description> </method> <method name="set_color"> - <return type="void"> - </return> - <argument index="0" name="point" type="int"> - </argument> - <argument index="1" name="color" type="Color"> - </argument> + <return type="void" /> + <argument index="0" name="point" type="int" /> + <argument index="1" name="color" type="Color" /> <description> Sets the color of the gradient color at index [code]point[/code]. </description> </method> <method name="set_offset"> - <return type="void"> - </return> - <argument index="0" name="point" type="int"> - </argument> - <argument index="1" name="offset" type="float"> - </argument> + <return type="void" /> + <argument index="0" name="point" type="int" /> + <argument index="1" name="offset" type="float" /> <description> Sets the offset for the gradient color at index [code]point[/code]. </description> diff --git a/doc/classes/GraphEdit.xml b/doc/classes/GraphEdit.xml index 65701b3a6a..44c571e800 100644 --- a/doc/classes/GraphEdit.xml +++ b/doc/classes/GraphEdit.xml @@ -11,163 +11,120 @@ </tutorials> <methods> <method name="add_valid_connection_type"> - <return type="void"> - </return> - <argument index="0" name="from_type" type="int"> - </argument> - <argument index="1" name="to_type" type="int"> - </argument> + <return type="void" /> + <argument index="0" name="from_type" type="int" /> + <argument index="1" name="to_type" type="int" /> <description> Makes possible the connection between two different slot types. The type is defined with the [method GraphNode.set_slot] method. </description> </method> <method name="add_valid_left_disconnect_type"> - <return type="void"> - </return> - <argument index="0" name="type" type="int"> - </argument> + <return type="void" /> + <argument index="0" name="type" type="int" /> <description> Makes possible to disconnect nodes when dragging from the slot at the left if it has the specified type. </description> </method> <method name="add_valid_right_disconnect_type"> - <return type="void"> - </return> - <argument index="0" name="type" type="int"> - </argument> + <return type="void" /> + <argument index="0" name="type" type="int" /> <description> Makes possible to disconnect nodes when dragging from the slot at the right if it has the specified type. </description> </method> <method name="clear_connections"> - <return type="void"> - </return> + <return type="void" /> <description> Removes all connections between nodes. </description> </method> <method name="connect_node"> - <return type="int" enum="Error"> - </return> - <argument index="0" name="from" type="StringName"> - </argument> - <argument index="1" name="from_port" type="int"> - </argument> - <argument index="2" name="to" type="StringName"> - </argument> - <argument index="3" name="to_port" type="int"> - </argument> + <return type="int" enum="Error" /> + <argument index="0" name="from" type="StringName" /> + <argument index="1" name="from_port" type="int" /> + <argument index="2" name="to" type="StringName" /> + <argument index="3" name="to_port" type="int" /> <description> Create a connection between the [code]from_port[/code] slot of the [code]from[/code] GraphNode and the [code]to_port[/code] slot of the [code]to[/code] GraphNode. If the connection already exists, no connection is created. </description> </method> <method name="disconnect_node"> - <return type="void"> - </return> - <argument index="0" name="from" type="StringName"> - </argument> - <argument index="1" name="from_port" type="int"> - </argument> - <argument index="2" name="to" type="StringName"> - </argument> - <argument index="3" name="to_port" type="int"> - </argument> + <return type="void" /> + <argument index="0" name="from" type="StringName" /> + <argument index="1" name="from_port" type="int" /> + <argument index="2" name="to" type="StringName" /> + <argument index="3" name="to_port" type="int" /> <description> Removes the connection between the [code]from_port[/code] slot of the [code]from[/code] GraphNode and the [code]to_port[/code] slot of the [code]to[/code] GraphNode. If the connection does not exist, no connection is removed. </description> </method> <method name="get_connection_list" qualifiers="const"> - <return type="Array"> - </return> + <return type="Array" /> <description> Returns an Array containing the list of connections. A connection consists in a structure of the form [code]{ from_port: 0, from: "GraphNode name 0", to_port: 1, to: "GraphNode name 1" }[/code]. </description> </method> <method name="get_zoom_hbox"> - <return type="HBoxContainer"> - </return> + <return type="HBoxContainer" /> <description> Gets the [HBoxContainer] that contains the zooming and grid snap controls in the top left of the graph. Warning: The intended usage of this function is to allow you to reposition or add your own custom controls to the container. This is an internal control and as such should not be freed. If you wish to hide this or any of its children, use their [member CanvasItem.visible] property instead. </description> </method> <method name="is_node_connected"> - <return type="bool"> - </return> - <argument index="0" name="from" type="StringName"> - </argument> - <argument index="1" name="from_port" type="int"> - </argument> - <argument index="2" name="to" type="StringName"> - </argument> - <argument index="3" name="to_port" type="int"> - </argument> + <return type="bool" /> + <argument index="0" name="from" type="StringName" /> + <argument index="1" name="from_port" type="int" /> + <argument index="2" name="to" type="StringName" /> + <argument index="3" name="to_port" type="int" /> <description> Returns [code]true[/code] if the [code]from_port[/code] slot of the [code]from[/code] GraphNode is connected to the [code]to_port[/code] slot of the [code]to[/code] GraphNode. </description> </method> <method name="is_valid_connection_type" qualifiers="const"> - <return type="bool"> - </return> - <argument index="0" name="from_type" type="int"> - </argument> - <argument index="1" name="to_type" type="int"> - </argument> + <return type="bool" /> + <argument index="0" name="from_type" type="int" /> + <argument index="1" name="to_type" type="int" /> <description> Returns whether it's possible to connect slots of the specified types. </description> </method> <method name="remove_valid_connection_type"> - <return type="void"> - </return> - <argument index="0" name="from_type" type="int"> - </argument> - <argument index="1" name="to_type" type="int"> - </argument> + <return type="void" /> + <argument index="0" name="from_type" type="int" /> + <argument index="1" name="to_type" type="int" /> <description> Makes it not possible to connect between two different slot types. The type is defined with the [method GraphNode.set_slot] method. </description> </method> <method name="remove_valid_left_disconnect_type"> - <return type="void"> - </return> - <argument index="0" name="type" type="int"> - </argument> + <return type="void" /> + <argument index="0" name="type" type="int" /> <description> Removes the possibility to disconnect nodes when dragging from the slot at the left if it has the specified type. </description> </method> <method name="remove_valid_right_disconnect_type"> - <return type="void"> - </return> - <argument index="0" name="type" type="int"> - </argument> + <return type="void" /> + <argument index="0" name="type" type="int" /> <description> Removes the possibility to disconnect nodes when dragging from the slot at the right if it has the specified type. </description> </method> <method name="set_connection_activity"> - <return type="void"> - </return> - <argument index="0" name="from" type="StringName"> - </argument> - <argument index="1" name="from_port" type="int"> - </argument> - <argument index="2" name="to" type="StringName"> - </argument> - <argument index="3" name="to_port" type="int"> - </argument> - <argument index="4" name="amount" type="float"> - </argument> + <return type="void" /> + <argument index="0" name="from" type="StringName" /> + <argument index="1" name="from_port" type="int" /> + <argument index="2" name="to" type="StringName" /> + <argument index="3" name="to_port" type="int" /> + <argument index="4" name="amount" type="float" /> <description> Sets the coloration of the connection between [code]from[/code]'s [code]from_port[/code] and [code]to[/code]'s [code]to_port[/code] with the color provided in the [code]activity[/code] theme property. </description> </method> <method name="set_selected"> - <return type="void"> - </return> - <argument index="0" name="node" type="Node"> - </argument> + <return type="void" /> + <argument index="0" name="node" type="Node" /> <description> Sets the specified [code]node[/code] as the one selected. </description> @@ -226,36 +183,26 @@ </description> </signal> <signal name="connection_from_empty"> - <argument index="0" name="to" type="StringName"> - </argument> - <argument index="1" name="to_slot" type="int"> - </argument> - <argument index="2" name="release_position" type="Vector2"> - </argument> + <argument index="0" name="to" type="StringName" /> + <argument index="1" name="to_slot" type="int" /> + <argument index="2" name="release_position" type="Vector2" /> <description> Emitted when user dragging connection from input port into empty space of the graph. </description> </signal> <signal name="connection_request"> - <argument index="0" name="from" type="StringName"> - </argument> - <argument index="1" name="from_slot" type="int"> - </argument> - <argument index="2" name="to" type="StringName"> - </argument> - <argument index="3" name="to_slot" type="int"> - </argument> + <argument index="0" name="from" type="StringName" /> + <argument index="1" name="from_slot" type="int" /> + <argument index="2" name="to" type="StringName" /> + <argument index="3" name="to_slot" type="int" /> <description> Emitted to the GraphEdit when the connection between the [code]from_slot[/code] slot of the [code]from[/code] GraphNode and the [code]to_slot[/code] slot of the [code]to[/code] GraphNode is attempted to be created. </description> </signal> <signal name="connection_to_empty"> - <argument index="0" name="from" type="StringName"> - </argument> - <argument index="1" name="from_slot" type="int"> - </argument> - <argument index="2" name="release_position" type="Vector2"> - </argument> + <argument index="0" name="from" type="StringName" /> + <argument index="1" name="from_slot" type="int" /> + <argument index="2" name="release_position" type="Vector2" /> <description> Emitted when user dragging connection from output port into empty space of the graph. </description> @@ -271,14 +218,10 @@ </description> </signal> <signal name="disconnection_request"> - <argument index="0" name="from" type="StringName"> - </argument> - <argument index="1" name="from_slot" type="int"> - </argument> - <argument index="2" name="to" type="StringName"> - </argument> - <argument index="3" name="to_slot" type="int"> - </argument> + <argument index="0" name="from" type="StringName" /> + <argument index="1" name="from_slot" type="int" /> + <argument index="2" name="to" type="StringName" /> + <argument index="3" name="to_slot" type="int" /> <description> Emitted to the GraphEdit when the connection between [code]from_slot[/code] slot of [code]from[/code] GraphNode and [code]to_slot[/code] slot of [code]to[/code] GraphNode is attempted to be removed. </description> @@ -294,14 +237,12 @@ </description> </signal> <signal name="node_deselected"> - <argument index="0" name="node" type="Node"> - </argument> + <argument index="0" name="node" type="Node" /> <description> </description> </signal> <signal name="node_selected"> - <argument index="0" name="node" type="Node"> - </argument> + <argument index="0" name="node" type="Node" /> <description> Emitted when a GraphNode is selected. </description> @@ -312,15 +253,13 @@ </description> </signal> <signal name="popup_request"> - <argument index="0" name="position" type="Vector2"> - </argument> + <argument index="0" name="position" type="Vector2" /> <description> Emitted when a popup is requested. Happens on right-clicking in the GraphEdit. [code]position[/code] is the position of the mouse pointer when the signal is sent. </description> </signal> <signal name="scroll_offset_changed"> - <argument index="0" name="ofs" type="Vector2"> - </argument> + <argument index="0" name="ofs" type="Vector2" /> <description> Emitted when the scroll offset is changed by the user. It will not be emitted when changed in code. </description> diff --git a/doc/classes/GraphNode.xml b/doc/classes/GraphNode.xml index 84eda7fcea..e1374b4f7a 100644 --- a/doc/classes/GraphNode.xml +++ b/doc/classes/GraphNode.xml @@ -12,191 +12,146 @@ </tutorials> <methods> <method name="clear_all_slots"> - <return type="void"> - </return> + <return type="void" /> <description> Disables all input and output slots of the GraphNode. </description> </method> <method name="clear_opentype_features"> - <return type="void"> - </return> + <return type="void" /> <description> Removes all OpenType features. </description> </method> <method name="clear_slot"> - <return type="void"> - </return> - <argument index="0" name="idx" type="int"> - </argument> + <return type="void" /> + <argument index="0" name="idx" type="int" /> <description> Disables input and output slot whose index is [code]idx[/code]. </description> </method> <method name="get_connection_input_color"> - <return type="Color"> - </return> - <argument index="0" name="idx" type="int"> - </argument> + <return type="Color" /> + <argument index="0" name="idx" type="int" /> <description> Returns the [Color] of the input connection [code]idx[/code]. </description> </method> <method name="get_connection_input_count"> - <return type="int"> - </return> + <return type="int" /> <description> Returns the number of enabled input slots (connections) to the GraphNode. </description> </method> <method name="get_connection_input_position"> - <return type="Vector2"> - </return> - <argument index="0" name="idx" type="int"> - </argument> + <return type="Vector2" /> + <argument index="0" name="idx" type="int" /> <description> Returns the position of the input connection [code]idx[/code]. </description> </method> <method name="get_connection_input_type"> - <return type="int"> - </return> - <argument index="0" name="idx" type="int"> - </argument> + <return type="int" /> + <argument index="0" name="idx" type="int" /> <description> Returns the type of the input connection [code]idx[/code]. </description> </method> <method name="get_connection_output_color"> - <return type="Color"> - </return> - <argument index="0" name="idx" type="int"> - </argument> + <return type="Color" /> + <argument index="0" name="idx" type="int" /> <description> Returns the [Color] of the output connection [code]idx[/code]. </description> </method> <method name="get_connection_output_count"> - <return type="int"> - </return> + <return type="int" /> <description> Returns the number of enabled output slots (connections) of the GraphNode. </description> </method> <method name="get_connection_output_position"> - <return type="Vector2"> - </return> - <argument index="0" name="idx" type="int"> - </argument> + <return type="Vector2" /> + <argument index="0" name="idx" type="int" /> <description> Returns the position of the output connection [code]idx[/code]. </description> </method> <method name="get_connection_output_type"> - <return type="int"> - </return> - <argument index="0" name="idx" type="int"> - </argument> + <return type="int" /> + <argument index="0" name="idx" type="int" /> <description> Returns the type of the output connection [code]idx[/code]. </description> </method> <method name="get_opentype_feature" qualifiers="const"> - <return type="int"> - </return> - <argument index="0" name="tag" type="String"> - </argument> + <return type="int" /> + <argument index="0" name="tag" type="String" /> <description> Returns OpenType feature [code]tag[/code]. </description> </method> <method name="get_slot_color_left" qualifiers="const"> - <return type="Color"> - </return> - <argument index="0" name="idx" type="int"> - </argument> + <return type="Color" /> + <argument index="0" name="idx" type="int" /> <description> Returns the left (input) [Color] of the slot [code]idx[/code]. </description> </method> <method name="get_slot_color_right" qualifiers="const"> - <return type="Color"> - </return> - <argument index="0" name="idx" type="int"> - </argument> + <return type="Color" /> + <argument index="0" name="idx" type="int" /> <description> Returns the right (output) [Color] of the slot [code]idx[/code]. </description> </method> <method name="get_slot_type_left" qualifiers="const"> - <return type="int"> - </return> - <argument index="0" name="idx" type="int"> - </argument> + <return type="int" /> + <argument index="0" name="idx" type="int" /> <description> Returns the left (input) type of the slot [code]idx[/code]. </description> </method> <method name="get_slot_type_right" qualifiers="const"> - <return type="int"> - </return> - <argument index="0" name="idx" type="int"> - </argument> + <return type="int" /> + <argument index="0" name="idx" type="int" /> <description> Returns the right (output) type of the slot [code]idx[/code]. </description> </method> <method name="is_slot_enabled_left" qualifiers="const"> - <return type="bool"> - </return> - <argument index="0" name="idx" type="int"> - </argument> + <return type="bool" /> + <argument index="0" name="idx" type="int" /> <description> Returns [code]true[/code] if left (input) side of the slot [code]idx[/code] is enabled. </description> </method> <method name="is_slot_enabled_right" qualifiers="const"> - <return type="bool"> - </return> - <argument index="0" name="idx" type="int"> - </argument> + <return type="bool" /> + <argument index="0" name="idx" type="int" /> <description> Returns [code]true[/code] if right (output) side of the slot [code]idx[/code] is enabled. </description> </method> <method name="set_opentype_feature"> - <return type="void"> - </return> - <argument index="0" name="tag" type="String"> - </argument> - <argument index="1" name="value" type="int"> - </argument> + <return type="void" /> + <argument index="0" name="tag" type="String" /> + <argument index="1" name="value" type="int" /> <description> Sets OpenType feature [code]tag[/code]. More info: [url=https://docs.microsoft.com/en-us/typography/opentype/spec/featuretags]OpenType feature tags[/url]. </description> </method> <method name="set_slot"> - <return type="void"> - </return> - <argument index="0" name="idx" type="int"> - </argument> - <argument index="1" name="enable_left" type="bool"> - </argument> - <argument index="2" name="type_left" type="int"> - </argument> - <argument index="3" name="color_left" type="Color"> - </argument> - <argument index="4" name="enable_right" type="bool"> - </argument> - <argument index="5" name="type_right" type="int"> - </argument> - <argument index="6" name="color_right" type="Color"> - </argument> - <argument index="7" name="custom_left" type="Texture2D" default="null"> - </argument> - <argument index="8" name="custom_right" type="Texture2D" default="null"> - </argument> + <return type="void" /> + <argument index="0" name="idx" type="int" /> + <argument index="1" name="enable_left" type="bool" /> + <argument index="2" name="type_left" type="int" /> + <argument index="3" name="color_left" type="Color" /> + <argument index="4" name="enable_right" type="bool" /> + <argument index="5" name="type_right" type="int" /> + <argument index="6" name="color_right" type="Color" /> + <argument index="7" name="custom_left" type="Texture2D" default="null" /> + <argument index="8" name="custom_right" type="Texture2D" default="null" /> <description> Sets properties of the slot with ID [code]idx[/code]. If [code]enable_left[/code]/[code]right[/code], a port will appear and the slot will be able to be connected from this side. @@ -208,67 +163,49 @@ </description> </method> <method name="set_slot_color_left"> - <return type="void"> - </return> - <argument index="0" name="idx" type="int"> - </argument> - <argument index="1" name="color_left" type="Color"> - </argument> + <return type="void" /> + <argument index="0" name="idx" type="int" /> + <argument index="1" name="color_left" type="Color" /> <description> Sets the [Color] of the left (input) side of the slot [code]idx[/code] to [code]color_left[/code]. </description> </method> <method name="set_slot_color_right"> - <return type="void"> - </return> - <argument index="0" name="idx" type="int"> - </argument> - <argument index="1" name="color_right" type="Color"> - </argument> + <return type="void" /> + <argument index="0" name="idx" type="int" /> + <argument index="1" name="color_right" type="Color" /> <description> Sets the [Color] of the right (output) side of the slot [code]idx[/code] to [code]color_right[/code]. </description> </method> <method name="set_slot_enabled_left"> - <return type="void"> - </return> - <argument index="0" name="idx" type="int"> - </argument> - <argument index="1" name="enable_left" type="bool"> - </argument> + <return type="void" /> + <argument index="0" name="idx" type="int" /> + <argument index="1" name="enable_left" type="bool" /> <description> Toggles the left (input) side of the slot [code]idx[/code]. If [code]enable_left[/code] is [code]true[/code], a port will appear on the left side and the slot will be able to be connected from this side. </description> </method> <method name="set_slot_enabled_right"> - <return type="void"> - </return> - <argument index="0" name="idx" type="int"> - </argument> - <argument index="1" name="enable_right" type="bool"> - </argument> + <return type="void" /> + <argument index="0" name="idx" type="int" /> + <argument index="1" name="enable_right" type="bool" /> <description> Toggles the right (output) side of the slot [code]idx[/code]. If [code]enable_right[/code] is [code]true[/code], a port will appear on the right side and the slot will be able to be connected from this side. </description> </method> <method name="set_slot_type_left"> - <return type="void"> - </return> - <argument index="0" name="idx" type="int"> - </argument> - <argument index="1" name="type_left" type="int"> - </argument> + <return type="void" /> + <argument index="0" name="idx" type="int" /> + <argument index="1" name="type_left" type="int" /> <description> Sets the left (input) type of the slot [code]idx[/code] to [code]type_left[/code]. </description> </method> <method name="set_slot_type_right"> - <return type="void"> - </return> - <argument index="0" name="idx" type="int"> - </argument> - <argument index="1" name="type_right" type="int"> - </argument> + <return type="void" /> + <argument index="0" name="idx" type="int" /> + <argument index="1" name="type_right" type="int" /> <description> Sets the right (output) type of the slot [code]idx[/code] to [code]type_right[/code]. </description> @@ -314,10 +251,8 @@ </description> </signal> <signal name="dragged"> - <argument index="0" name="from" type="Vector2"> - </argument> - <argument index="1" name="to" type="Vector2"> - </argument> + <argument index="0" name="from" type="Vector2" /> + <argument index="1" name="to" type="Vector2" /> <description> Emitted when the GraphNode is dragged. </description> @@ -333,15 +268,13 @@ </description> </signal> <signal name="resize_request"> - <argument index="0" name="new_minsize" type="Vector2"> - </argument> + <argument index="0" name="new_minsize" type="Vector2" /> <description> Emitted when the GraphNode is requested to be resized. Happens on dragging the resizer handle (see [member resizable]). </description> </signal> <signal name="slot_updated"> - <argument index="0" name="idx" type="int"> - </argument> + <argument index="0" name="idx" type="int" /> <description> Emitted when any GraphNode's slot is updated. </description> diff --git a/doc/classes/HMACContext.xml b/doc/classes/HMACContext.xml index 9fa96e5ddf..88d3c5e2f3 100644 --- a/doc/classes/HMACContext.xml +++ b/doc/classes/HMACContext.xml @@ -56,28 +56,22 @@ </tutorials> <methods> <method name="finish"> - <return type="PackedByteArray"> - </return> + <return type="PackedByteArray" /> <description> Returns the resulting HMAC. If the HMAC failed, an empty [PackedByteArray] is returned. </description> </method> <method name="start"> - <return type="int" enum="Error"> - </return> - <argument index="0" name="hash_type" type="int" enum="HashingContext.HashType"> - </argument> - <argument index="1" name="key" type="PackedByteArray"> - </argument> + <return type="int" enum="Error" /> + <argument index="0" name="hash_type" type="int" enum="HashingContext.HashType" /> + <argument index="1" name="key" type="PackedByteArray" /> <description> Initializes the HMACContext. This method cannot be called again on the same HMACContext until [method finish] has been called. </description> </method> <method name="update"> - <return type="int" enum="Error"> - </return> - <argument index="0" name="data" type="PackedByteArray"> - </argument> + <return type="int" enum="Error" /> + <argument index="0" name="data" type="PackedByteArray" /> <description> Updates the message to be HMACed. This can be called multiple times before [method finish] is called to append [code]data[/code] to the message, but cannot be called until [method start] has been called. </description> diff --git a/doc/classes/HTTPClient.xml b/doc/classes/HTTPClient.xml index a08bed751f..df42869dbe 100644 --- a/doc/classes/HTTPClient.xml +++ b/doc/classes/HTTPClient.xml @@ -17,23 +17,17 @@ </tutorials> <methods> <method name="close"> - <return type="void"> - </return> + <return type="void" /> <description> Closes the current connection, allowing reuse of this [HTTPClient]. </description> </method> <method name="connect_to_host"> - <return type="int" enum="Error"> - </return> - <argument index="0" name="host" type="String"> - </argument> - <argument index="1" name="port" type="int" default="-1"> - </argument> - <argument index="2" name="use_ssl" type="bool" default="false"> - </argument> - <argument index="3" name="verify_host" type="bool" default="true"> - </argument> + <return type="int" enum="Error" /> + <argument index="0" name="host" type="String" /> + <argument index="1" name="port" type="int" default="-1" /> + <argument index="2" name="use_ssl" type="bool" default="false" /> + <argument index="3" name="verify_host" type="bool" default="true" /> <description> Connects to a host. This needs to be done before any requests are sent. The host should not have http:// prepended but will strip the protocol identifier if provided. @@ -42,30 +36,26 @@ </description> </method> <method name="get_response_body_length" qualifiers="const"> - <return type="int"> - </return> + <return type="int" /> <description> Returns the response's body length. [b]Note:[/b] Some Web servers may not send a body length. In this case, the value returned will be [code]-1[/code]. If using chunked transfer encoding, the body length will also be [code]-1[/code]. </description> </method> <method name="get_response_code" qualifiers="const"> - <return type="int"> - </return> + <return type="int" /> <description> Returns the response's HTTP status code. </description> </method> <method name="get_response_headers"> - <return type="PackedStringArray"> - </return> + <return type="PackedStringArray" /> <description> Returns the response headers. </description> </method> <method name="get_response_headers_as_dictionary"> - <return type="Dictionary"> - </return> + <return type="Dictionary" /> <description> Returns all response headers as a Dictionary of structure [code]{ "key": "value1; value2" }[/code] where the case-sensitivity of the keys and values is kept like the server delivers it. A value is a simple String, this string can have more than one value where "; " is used as separator. [b]Example:[/b] @@ -78,38 +68,32 @@ </description> </method> <method name="get_status" qualifiers="const"> - <return type="int" enum="HTTPClient.Status"> - </return> + <return type="int" enum="HTTPClient.Status" /> <description> Returns a [enum Status] constant. Need to call [method poll] in order to get status updates. </description> </method> <method name="has_response" qualifiers="const"> - <return type="bool"> - </return> + <return type="bool" /> <description> If [code]true[/code], this [HTTPClient] has a response available. </description> </method> <method name="is_response_chunked" qualifiers="const"> - <return type="bool"> - </return> + <return type="bool" /> <description> If [code]true[/code], this [HTTPClient] has a response that is chunked. </description> </method> <method name="poll"> - <return type="int" enum="Error"> - </return> + <return type="int" enum="Error" /> <description> This needs to be called in order to have any request processed. Check results with [method get_status]. </description> </method> <method name="query_string_from_dict"> - <return type="String"> - </return> - <argument index="0" name="fields" type="Dictionary"> - </argument> + <return type="String" /> + <argument index="0" name="fields" type="Dictionary" /> <description> Generates a GET/POST application/x-www-form-urlencoded style query string from a provided dictionary, e.g.: [codeblocks] @@ -140,23 +124,17 @@ </description> </method> <method name="read_response_body_chunk"> - <return type="PackedByteArray"> - </return> + <return type="PackedByteArray" /> <description> Reads one chunk from the response. </description> </method> <method name="request"> - <return type="int" enum="Error"> - </return> - <argument index="0" name="method" type="int" enum="HTTPClient.Method"> - </argument> - <argument index="1" name="url" type="String"> - </argument> - <argument index="2" name="headers" type="PackedStringArray"> - </argument> - <argument index="3" name="body" type="String" default=""""> - </argument> + <return type="int" enum="Error" /> + <argument index="0" name="method" type="int" enum="HTTPClient.Method" /> + <argument index="1" name="url" type="String" /> + <argument index="2" name="headers" type="PackedStringArray" /> + <argument index="3" name="body" type="String" default="""" /> <description> Sends a request to the connected host. The URL parameter is usually just the part after the host, so for [code]http://somehost.com/index.php[/code], it is [code]/index.php[/code]. When sending requests to an HTTP proxy server, it should be an absolute URL. For [constant HTTPClient.METHOD_OPTIONS] requests, [code]*[/code] is also allowed. For [constant HTTPClient.METHOD_CONNECT] requests, it should be the authority component ([code]host:port[/code]). @@ -180,16 +158,11 @@ </description> </method> <method name="request_raw"> - <return type="int" enum="Error"> - </return> - <argument index="0" name="method" type="int" enum="HTTPClient.Method"> - </argument> - <argument index="1" name="url" type="String"> - </argument> - <argument index="2" name="headers" type="PackedStringArray"> - </argument> - <argument index="3" name="body" type="PackedByteArray"> - </argument> + <return type="int" enum="Error" /> + <argument index="0" name="method" type="int" enum="HTTPClient.Method" /> + <argument index="1" name="url" type="String" /> + <argument index="2" name="headers" type="PackedStringArray" /> + <argument index="3" name="body" type="PackedByteArray" /> <description> Sends a raw request to the connected host. The URL parameter is usually just the part after the host, so for [code]http://somehost.com/index.php[/code], it is [code]/index.php[/code]. When sending requests to an HTTP proxy server, it should be an absolute URL. For [constant HTTPClient.METHOD_OPTIONS] requests, [code]*[/code] is also allowed. For [constant HTTPClient.METHOD_CONNECT] requests, it should be the authority component ([code]host:port[/code]). diff --git a/doc/classes/HTTPRequest.xml b/doc/classes/HTTPRequest.xml index 908e355db3..4a56c7e3fd 100644 --- a/doc/classes/HTTPRequest.xml +++ b/doc/classes/HTTPRequest.xml @@ -159,47 +159,37 @@ </tutorials> <methods> <method name="cancel_request"> - <return type="void"> - </return> + <return type="void" /> <description> Cancels the current request. </description> </method> <method name="get_body_size" qualifiers="const"> - <return type="int"> - </return> + <return type="int" /> <description> Returns the response body length. [b]Note:[/b] Some Web servers may not send a body length. In this case, the value returned will be [code]-1[/code]. If using chunked transfer encoding, the body length will also be [code]-1[/code]. </description> </method> <method name="get_downloaded_bytes" qualifiers="const"> - <return type="int"> - </return> + <return type="int" /> <description> Returns the amount of bytes this HTTPRequest downloaded. </description> </method> <method name="get_http_client_status" qualifiers="const"> - <return type="int" enum="HTTPClient.Status"> - </return> + <return type="int" enum="HTTPClient.Status" /> <description> Returns the current status of the underlying [HTTPClient]. See [enum HTTPClient.Status]. </description> </method> <method name="request"> - <return type="int" enum="Error"> - </return> - <argument index="0" name="url" type="String"> - </argument> - <argument index="1" name="custom_headers" type="PackedStringArray" default="PackedStringArray()"> - </argument> - <argument index="2" name="ssl_validate_domain" type="bool" default="true"> - </argument> - <argument index="3" name="method" type="int" enum="HTTPClient.Method" default="0"> - </argument> - <argument index="4" name="request_data" type="String" default=""""> - </argument> + <return type="int" enum="Error" /> + <argument index="0" name="url" type="String" /> + <argument index="1" name="custom_headers" type="PackedStringArray" default="PackedStringArray()" /> + <argument index="2" name="ssl_validate_domain" type="bool" default="true" /> + <argument index="3" name="method" type="int" enum="HTTPClient.Method" default="0" /> + <argument index="4" name="request_data" type="String" default="""" /> <description> Creates request on the underlying [HTTPClient]. If there is no configuration errors, it tries to connect using [method HTTPClient.connect_to_host] and passes parameters onto [method HTTPClient.request]. Returns [constant OK] if request is successfully created. (Does not imply that the server has responded), [constant ERR_UNCONFIGURED] if not in the tree, [constant ERR_BUSY] if still processing previous request, [constant ERR_INVALID_PARAMETER] if given string is not a valid URL format, or [constant ERR_CANT_CONNECT] if not using thread and the [HTTPClient] cannot connect to host. @@ -207,18 +197,12 @@ </description> </method> <method name="request_raw"> - <return type="int" enum="Error"> - </return> - <argument index="0" name="url" type="String"> - </argument> - <argument index="1" name="custom_headers" type="PackedStringArray" default="PackedStringArray()"> - </argument> - <argument index="2" name="ssl_validate_domain" type="bool" default="true"> - </argument> - <argument index="3" name="method" type="int" enum="HTTPClient.Method" default="0"> - </argument> - <argument index="4" name="request_data_raw" type="PackedByteArray" default="PackedByteArray()"> - </argument> + <return type="int" enum="Error" /> + <argument index="0" name="url" type="String" /> + <argument index="1" name="custom_headers" type="PackedStringArray" default="PackedStringArray()" /> + <argument index="2" name="ssl_validate_domain" type="bool" default="true" /> + <argument index="3" name="method" type="int" enum="HTTPClient.Method" default="0" /> + <argument index="4" name="request_data_raw" type="PackedByteArray" default="PackedByteArray()" /> <description> Creates request on the underlying [HTTPClient] using a raw array of bytes for the request body. If there is no configuration errors, it tries to connect using [method HTTPClient.connect_to_host] and passes parameters onto [method HTTPClient.request]. Returns [constant OK] if request is successfully created. (Does not imply that the server has responded), [constant ERR_UNCONFIGURED] if not in the tree, [constant ERR_BUSY] if still processing previous request, [constant ERR_INVALID_PARAMETER] if given string is not a valid URL format, or [constant ERR_CANT_CONNECT] if not using thread and the [HTTPClient] cannot connect to host. @@ -253,14 +237,10 @@ </members> <signals> <signal name="request_completed"> - <argument index="0" name="result" type="int"> - </argument> - <argument index="1" name="response_code" type="int"> - </argument> - <argument index="2" name="headers" type="PackedStringArray"> - </argument> - <argument index="3" name="body" type="PackedByteArray"> - </argument> + <argument index="0" name="result" type="int" /> + <argument index="1" name="response_code" type="int" /> + <argument index="2" name="headers" type="PackedStringArray" /> + <argument index="3" name="body" type="PackedByteArray" /> <description> Emitted when a request is completed. </description> diff --git a/doc/classes/HashingContext.xml b/doc/classes/HashingContext.xml index 1c7b7ca937..f470f1611d 100644 --- a/doc/classes/HashingContext.xml +++ b/doc/classes/HashingContext.xml @@ -63,26 +63,21 @@ </tutorials> <methods> <method name="finish"> - <return type="PackedByteArray"> - </return> + <return type="PackedByteArray" /> <description> Closes the current context, and return the computed hash. </description> </method> <method name="start"> - <return type="int" enum="Error"> - </return> - <argument index="0" name="type" type="int" enum="HashingContext.HashType"> - </argument> + <return type="int" enum="Error" /> + <argument index="0" name="type" type="int" enum="HashingContext.HashType" /> <description> Starts a new hash computation of the given [code]type[/code] (e.g. [constant HASH_SHA256] to start computation of a SHA-256). </description> </method> <method name="update"> - <return type="int" enum="Error"> - </return> - <argument index="0" name="chunk" type="PackedByteArray"> - </argument> + <return type="int" enum="Error" /> + <argument index="0" name="chunk" type="PackedByteArray" /> <description> Updates the computation with the given [code]chunk[/code] of data. </description> diff --git a/doc/classes/HingeJoint3D.xml b/doc/classes/HingeJoint3D.xml index f2c652d51a..a8e7f343ff 100644 --- a/doc/classes/HingeJoint3D.xml +++ b/doc/classes/HingeJoint3D.xml @@ -10,41 +10,31 @@ </tutorials> <methods> <method name="get_flag" qualifiers="const"> - <return type="bool"> - </return> - <argument index="0" name="flag" type="int" enum="HingeJoint3D.Flag"> - </argument> + <return type="bool" /> + <argument index="0" name="flag" type="int" enum="HingeJoint3D.Flag" /> <description> Returns the value of the specified flag. </description> </method> <method name="get_param" qualifiers="const"> - <return type="float"> - </return> - <argument index="0" name="param" type="int" enum="HingeJoint3D.Param"> - </argument> + <return type="float" /> + <argument index="0" name="param" type="int" enum="HingeJoint3D.Param" /> <description> Returns the value of the specified parameter. </description> </method> <method name="set_flag"> - <return type="void"> - </return> - <argument index="0" name="flag" type="int" enum="HingeJoint3D.Flag"> - </argument> - <argument index="1" name="enabled" type="bool"> - </argument> + <return type="void" /> + <argument index="0" name="flag" type="int" enum="HingeJoint3D.Flag" /> + <argument index="1" name="enabled" type="bool" /> <description> If [code]true[/code], enables the specified flag. </description> </method> <method name="set_param"> - <return type="void"> - </return> - <argument index="0" name="param" type="int" enum="HingeJoint3D.Param"> - </argument> - <argument index="1" name="value" type="float"> - </argument> + <return type="void" /> + <argument index="0" name="param" type="int" enum="HingeJoint3D.Param" /> + <argument index="1" name="value" type="float" /> <description> Sets the value of the specified parameter. </description> diff --git a/doc/classes/IP.xml b/doc/classes/IP.xml index b3ce1abaeb..8eb994a913 100644 --- a/doc/classes/IP.xml +++ b/doc/classes/IP.xml @@ -10,33 +10,27 @@ </tutorials> <methods> <method name="clear_cache"> - <return type="void"> - </return> - <argument index="0" name="hostname" type="String" default=""""> - </argument> + <return type="void" /> + <argument index="0" name="hostname" type="String" default="""" /> <description> Removes all of a [code]hostname[/code]'s cached references. If no [code]hostname[/code] is given, all cached IP addresses are removed. </description> </method> <method name="erase_resolve_item"> - <return type="void"> - </return> - <argument index="0" name="id" type="int"> - </argument> + <return type="void" /> + <argument index="0" name="id" type="int" /> <description> Removes a given item [code]id[/code] from the queue. This should be used to free a queue after it has completed to enable more queries to happen. </description> </method> <method name="get_local_addresses" qualifiers="const"> - <return type="Array"> - </return> + <return type="Array" /> <description> Returns all the user's current IPv4 and IPv6 addresses as an array. </description> </method> <method name="get_local_interfaces" qualifiers="const"> - <return type="Array"> - </return> + <return type="Array" /> <description> Returns all network adapters as an array. Each adapter is a dictionary of the form: @@ -51,61 +45,46 @@ </description> </method> <method name="get_resolve_item_address" qualifiers="const"> - <return type="String"> - </return> - <argument index="0" name="id" type="int"> - </argument> + <return type="String" /> + <argument index="0" name="id" type="int" /> <description> Returns a queued hostname's IP address, given its queue [code]id[/code]. Returns an empty string on error or if resolution hasn't happened yet (see [method get_resolve_item_status]). </description> </method> <method name="get_resolve_item_addresses" qualifiers="const"> - <return type="Array"> - </return> - <argument index="0" name="id" type="int"> - </argument> + <return type="Array" /> + <argument index="0" name="id" type="int" /> <description> Returns resolved addresses, or an empty array if an error happened or resolution didn't happen yet (see [method get_resolve_item_status]). </description> </method> <method name="get_resolve_item_status" qualifiers="const"> - <return type="int" enum="IP.ResolverStatus"> - </return> - <argument index="0" name="id" type="int"> - </argument> + <return type="int" enum="IP.ResolverStatus" /> + <argument index="0" name="id" type="int" /> <description> Returns a queued hostname's status as a [enum ResolverStatus] constant, given its queue [code]id[/code]. </description> </method> <method name="resolve_hostname"> - <return type="String"> - </return> - <argument index="0" name="host" type="String"> - </argument> - <argument index="1" name="ip_type" type="int" enum="IP.Type" default="3"> - </argument> + <return type="String" /> + <argument index="0" name="host" type="String" /> + <argument index="1" name="ip_type" type="int" enum="IP.Type" default="3" /> <description> Returns a given hostname's IPv4 or IPv6 address when resolved (blocking-type method). The address type returned depends on the [enum Type] constant given as [code]ip_type[/code]. </description> </method> <method name="resolve_hostname_addresses"> - <return type="Array"> - </return> - <argument index="0" name="host" type="String"> - </argument> - <argument index="1" name="ip_type" type="int" enum="IP.Type" default="3"> - </argument> + <return type="Array" /> + <argument index="0" name="host" type="String" /> + <argument index="1" name="ip_type" type="int" enum="IP.Type" default="3" /> <description> Resolves a given hostname in a blocking way. Addresses are returned as an [Array] of IPv4 or IPv6 addresses depending on [code]ip_type[/code]. </description> </method> <method name="resolve_hostname_queue_item"> - <return type="int"> - </return> - <argument index="0" name="host" type="String"> - </argument> - <argument index="1" name="ip_type" type="int" enum="IP.Type" default="3"> - </argument> + <return type="int" /> + <argument index="0" name="host" type="String" /> + <argument index="1" name="ip_type" type="int" enum="IP.Type" default="3" /> <description> Creates a queue item to resolve a hostname to an IPv4 or IPv6 address depending on the [enum Type] constant given as [code]ip_type[/code]. Returns the queue ID if successful, or [constant RESOLVER_INVALID_ID] on error. </description> diff --git a/doc/classes/Image.xml b/doc/classes/Image.xml index 167b90ea73..34c5fb582e 100644 --- a/doc/classes/Image.xml +++ b/doc/classes/Image.xml @@ -13,352 +13,269 @@ </tutorials> <methods> <method name="adjust_bcs"> - <return type="void"> - </return> - <argument index="0" name="brightness" type="float"> - </argument> - <argument index="1" name="contrast" type="float"> - </argument> - <argument index="2" name="saturation" type="float"> - </argument> + <return type="void" /> + <argument index="0" name="brightness" type="float" /> + <argument index="1" name="contrast" type="float" /> + <argument index="2" name="saturation" type="float" /> <description> </description> </method> <method name="blend_rect"> - <return type="void"> - </return> - <argument index="0" name="src" type="Image"> - </argument> - <argument index="1" name="src_rect" type="Rect2"> - </argument> - <argument index="2" name="dst" type="Vector2"> - </argument> + <return type="void" /> + <argument index="0" name="src" type="Image" /> + <argument index="1" name="src_rect" type="Rect2" /> + <argument index="2" name="dst" type="Vector2" /> <description> Alpha-blends [code]src_rect[/code] from [code]src[/code] image to this image at coordinates [code]dest[/code]. </description> </method> <method name="blend_rect_mask"> - <return type="void"> - </return> - <argument index="0" name="src" type="Image"> - </argument> - <argument index="1" name="mask" type="Image"> - </argument> - <argument index="2" name="src_rect" type="Rect2"> - </argument> - <argument index="3" name="dst" type="Vector2"> - </argument> + <return type="void" /> + <argument index="0" name="src" type="Image" /> + <argument index="1" name="mask" type="Image" /> + <argument index="2" name="src_rect" type="Rect2" /> + <argument index="3" name="dst" type="Vector2" /> <description> Alpha-blends [code]src_rect[/code] from [code]src[/code] image to this image using [code]mask[/code] image at coordinates [code]dst[/code]. Alpha channels are required for both [code]src[/code] and [code]mask[/code]. [code]dst[/code] pixels and [code]src[/code] pixels will blend if the corresponding mask pixel's alpha value is not 0. [code]src[/code] image and [code]mask[/code] image [b]must[/b] have the same size (width and height) but they can have different formats. </description> </method> <method name="blit_rect"> - <return type="void"> - </return> - <argument index="0" name="src" type="Image"> - </argument> - <argument index="1" name="src_rect" type="Rect2"> - </argument> - <argument index="2" name="dst" type="Vector2"> - </argument> + <return type="void" /> + <argument index="0" name="src" type="Image" /> + <argument index="1" name="src_rect" type="Rect2" /> + <argument index="2" name="dst" type="Vector2" /> <description> Copies [code]src_rect[/code] from [code]src[/code] image to this image at coordinates [code]dst[/code]. </description> </method> <method name="blit_rect_mask"> - <return type="void"> - </return> - <argument index="0" name="src" type="Image"> - </argument> - <argument index="1" name="mask" type="Image"> - </argument> - <argument index="2" name="src_rect" type="Rect2"> - </argument> - <argument index="3" name="dst" type="Vector2"> - </argument> + <return type="void" /> + <argument index="0" name="src" type="Image" /> + <argument index="1" name="mask" type="Image" /> + <argument index="2" name="src_rect" type="Rect2" /> + <argument index="3" name="dst" type="Vector2" /> <description> Blits [code]src_rect[/code] area from [code]src[/code] image to this image at the coordinates given by [code]dst[/code]. [code]src[/code] pixel is copied onto [code]dst[/code] if the corresponding [code]mask[/code] pixel's alpha value is not 0. [code]src[/code] image and [code]mask[/code] image [b]must[/b] have the same size (width and height) but they can have different formats. </description> </method> <method name="bump_map_to_normal_map"> - <return type="void"> - </return> - <argument index="0" name="bump_scale" type="float" default="1.0"> - </argument> + <return type="void" /> + <argument index="0" name="bump_scale" type="float" default="1.0" /> <description> Converts a bump map to a normal map. A bump map provides a height offset per-pixel, while a normal map provides a normal direction per pixel. </description> </method> <method name="clear_mipmaps"> - <return type="void"> - </return> + <return type="void" /> <description> Removes the image's mipmaps. </description> </method> <method name="compress"> - <return type="int" enum="Error"> - </return> - <argument index="0" name="mode" type="int" enum="Image.CompressMode"> - </argument> - <argument index="1" name="source" type="int" enum="Image.CompressSource" default="0"> - </argument> - <argument index="2" name="lossy_quality" type="float" default="0.7"> - </argument> + <return type="int" enum="Error" /> + <argument index="0" name="mode" type="int" enum="Image.CompressMode" /> + <argument index="1" name="source" type="int" enum="Image.CompressSource" default="0" /> + <argument index="2" name="lossy_quality" type="float" default="0.7" /> <description> Compresses the image to use less memory. Can not directly access pixel data while the image is compressed. Returns error if the chosen compression mode is not available. See [enum CompressMode] and [enum CompressSource] constants. </description> </method> <method name="compress_from_channels"> - <return type="int" enum="Error"> - </return> - <argument index="0" name="mode" type="int" enum="Image.CompressMode"> - </argument> - <argument index="1" name="channels" type="int" enum="Image.UsedChannels"> - </argument> - <argument index="2" name="lossy_quality" type="float" default="0.7"> - </argument> + <return type="int" enum="Error" /> + <argument index="0" name="mode" type="int" enum="Image.CompressMode" /> + <argument index="1" name="channels" type="int" enum="Image.UsedChannels" /> + <argument index="2" name="lossy_quality" type="float" default="0.7" /> <description> </description> </method> <method name="convert"> - <return type="void"> - </return> - <argument index="0" name="format" type="int" enum="Image.Format"> - </argument> + <return type="void" /> + <argument index="0" name="format" type="int" enum="Image.Format" /> <description> Converts the image's format. See [enum Format] constants. </description> </method> <method name="copy_from"> - <return type="void"> - </return> - <argument index="0" name="src" type="Image"> - </argument> + <return type="void" /> + <argument index="0" name="src" type="Image" /> <description> Copies [code]src[/code] image to this image. </description> </method> <method name="create"> - <return type="void"> - </return> - <argument index="0" name="width" type="int"> - </argument> - <argument index="1" name="height" type="int"> - </argument> - <argument index="2" name="use_mipmaps" type="bool"> - </argument> - <argument index="3" name="format" type="int" enum="Image.Format"> - </argument> + <return type="void" /> + <argument index="0" name="width" type="int" /> + <argument index="1" name="height" type="int" /> + <argument index="2" name="use_mipmaps" type="bool" /> + <argument index="3" name="format" type="int" enum="Image.Format" /> <description> Creates an empty image of given size and format. See [enum Format] constants. If [code]use_mipmaps[/code] is [code]true[/code] then generate mipmaps for this image. See the [method generate_mipmaps]. </description> </method> <method name="create_from_data"> - <return type="void"> - </return> - <argument index="0" name="width" type="int"> - </argument> - <argument index="1" name="height" type="int"> - </argument> - <argument index="2" name="use_mipmaps" type="bool"> - </argument> - <argument index="3" name="format" type="int" enum="Image.Format"> - </argument> - <argument index="4" name="data" type="PackedByteArray"> - </argument> + <return type="void" /> + <argument index="0" name="width" type="int" /> + <argument index="1" name="height" type="int" /> + <argument index="2" name="use_mipmaps" type="bool" /> + <argument index="3" name="format" type="int" enum="Image.Format" /> + <argument index="4" name="data" type="PackedByteArray" /> <description> Creates a new image of given size and format. See [enum Format] constants. Fills the image with the given raw data. If [code]use_mipmaps[/code] is [code]true[/code] then loads mipmaps for this image from [code]data[/code]. See [method generate_mipmaps]. </description> </method> <method name="crop"> - <return type="void"> - </return> - <argument index="0" name="width" type="int"> - </argument> - <argument index="1" name="height" type="int"> - </argument> + <return type="void" /> + <argument index="0" name="width" type="int" /> + <argument index="1" name="height" type="int" /> <description> Crops the image to the given [code]width[/code] and [code]height[/code]. If the specified size is larger than the current size, the extra area is filled with black pixels. </description> </method> <method name="decompress"> - <return type="int" enum="Error"> - </return> + <return type="int" enum="Error" /> <description> Decompresses the image if it is VRAM compressed in a supported format. Returns [constant OK] if the format is supported, otherwise [constant ERR_UNAVAILABLE]. [b]Note:[/b] The following formats can be decompressed: DXT, RGTC, BPTC, PVRTC1. The formats ETC1 and ETC2 are not supported. </description> </method> <method name="detect_alpha" qualifiers="const"> - <return type="int" enum="Image.AlphaMode"> - </return> + <return type="int" enum="Image.AlphaMode" /> <description> Returns [constant ALPHA_BLEND] if the image has data for alpha values. Returns [constant ALPHA_BIT] if all the alpha values are stored in a single bit. Returns [constant ALPHA_NONE] if no data for alpha values is found. </description> </method> <method name="detect_used_channels"> - <return type="int" enum="Image.UsedChannels"> - </return> - <argument index="0" name="source" type="int" enum="Image.CompressSource" default="0"> - </argument> + <return type="int" enum="Image.UsedChannels" /> + <argument index="0" name="source" type="int" enum="Image.CompressSource" default="0" /> <description> </description> </method> <method name="fill"> - <return type="void"> - </return> - <argument index="0" name="color" type="Color"> - </argument> + <return type="void" /> + <argument index="0" name="color" type="Color" /> <description> Fills the image with a given [Color]. </description> </method> <method name="fix_alpha_edges"> - <return type="void"> - </return> + <return type="void" /> <description> Blends low-alpha pixels with nearby pixels. </description> </method> <method name="flip_x"> - <return type="void"> - </return> + <return type="void" /> <description> Flips the image horizontally. </description> </method> <method name="flip_y"> - <return type="void"> - </return> + <return type="void" /> <description> Flips the image vertically. </description> </method> <method name="generate_mipmaps"> - <return type="int" enum="Error"> - </return> - <argument index="0" name="renormalize" type="bool" default="false"> - </argument> + <return type="int" enum="Error" /> + <argument index="0" name="renormalize" type="bool" default="false" /> <description> - Generates mipmaps for the image. Mipmaps are precalculated and lower resolution copies of the image. Mipmaps are automatically used if the image needs to be scaled down when rendered. This improves image quality and the performance of the rendering. Returns an error if the image is compressed, in a custom format or if the image's width/height is 0. + Generates mipmaps for the image. Mipmaps are precalculated lower-resolution copies of the image that are automatically used if the image needs to be scaled down when rendered. They help improve image quality and performance when rendering. This method returns an error if the image is compressed, in a custom format, or if the image's width/height is [code]0[/code]. </description> </method> <method name="get_data" qualifiers="const"> - <return type="PackedByteArray"> - </return> + <return type="PackedByteArray" /> <description> Returns a copy of the image's raw data. </description> </method> <method name="get_format" qualifiers="const"> - <return type="int" enum="Image.Format"> - </return> + <return type="int" enum="Image.Format" /> <description> Returns the image's format. See [enum Format] constants. </description> </method> <method name="get_height" qualifiers="const"> - <return type="int"> - </return> + <return type="int" /> <description> Returns the image's height. </description> </method> <method name="get_mipmap_offset" qualifiers="const"> - <return type="int"> - </return> - <argument index="0" name="mipmap" type="int"> - </argument> + <return type="int" /> + <argument index="0" name="mipmap" type="int" /> <description> Returns the offset where the image's mipmap with index [code]mipmap[/code] is stored in the [code]data[/code] dictionary. </description> </method> <method name="get_pixel" qualifiers="const"> - <return type="Color"> - </return> - <argument index="0" name="x" type="int"> - </argument> - <argument index="1" name="y" type="int"> - </argument> + <return type="Color" /> + <argument index="0" name="x" type="int" /> + <argument index="1" name="y" type="int" /> <description> Returns the color of the pixel at [code](x, y)[/code]. This is the same as [method get_pixelv], but with two integer arguments instead of a [Vector2i] argument. </description> </method> <method name="get_pixelv" qualifiers="const"> - <return type="Color"> - </return> - <argument index="0" name="point" type="Vector2i"> - </argument> + <return type="Color" /> + <argument index="0" name="point" type="Vector2i" /> <description> Returns the color of the pixel at [code]point[/code]. This is the same as [method get_pixel], but with a [Vector2i] argument instead of two integer arguments. </description> </method> <method name="get_rect" qualifiers="const"> - <return type="Image"> - </return> - <argument index="0" name="rect" type="Rect2"> - </argument> + <return type="Image" /> + <argument index="0" name="rect" type="Rect2" /> <description> Returns a new image that is a copy of the image's area specified with [code]rect[/code]. </description> </method> <method name="get_size" qualifiers="const"> - <return type="Vector2"> - </return> + <return type="Vector2" /> <description> Returns the image's size (width and height). </description> </method> <method name="get_used_rect" qualifiers="const"> - <return type="Rect2"> - </return> + <return type="Rect2" /> <description> Returns a [Rect2] enclosing the visible portion of the image, considering each pixel with a non-zero alpha channel as visible. </description> </method> <method name="get_width" qualifiers="const"> - <return type="int"> - </return> + <return type="int" /> <description> Returns the image's width. </description> </method> <method name="has_mipmaps" qualifiers="const"> - <return type="bool"> - </return> + <return type="bool" /> <description> Returns [code]true[/code] if the image has generated mipmaps. </description> </method> <method name="is_compressed" qualifiers="const"> - <return type="bool"> - </return> + <return type="bool" /> <description> Returns [code]true[/code] if the image is compressed. </description> </method> <method name="is_empty" qualifiers="const"> - <return type="bool"> - </return> + <return type="bool" /> <description> Returns [code]true[/code] if the image has no data. </description> </method> <method name="is_invisible" qualifiers="const"> - <return type="bool"> - </return> + <return type="bool" /> <description> Returns [code]true[/code] if all the image's pixels have an alpha value of 0. Returns [code]false[/code] if any pixel has an alpha value higher than 0. </description> </method> <method name="load"> - <return type="int" enum="Error"> - </return> - <argument index="0" name="path" type="String"> - </argument> + <return type="int" enum="Error" /> + <argument index="0" name="path" type="String" /> <description> Loads an image from file [code]path[/code]. See [url=https://docs.godotengine.org/en/latest/getting_started/workflow/assets/importing_images.html#supported-image-formats]Supported image formats[/url] for a list of supported image formats and limitations. [b]Warning:[/b] This method should only be used in the editor or in cases when you need to load external images at run-time, such as images located at the [code]user://[/code] directory, and may not work in exported projects. @@ -366,131 +283,102 @@ </description> </method> <method name="load_bmp_from_buffer"> - <return type="int" enum="Error"> - </return> - <argument index="0" name="buffer" type="PackedByteArray"> - </argument> + <return type="int" enum="Error" /> + <argument index="0" name="buffer" type="PackedByteArray" /> <description> Loads an image from the binary contents of a BMP file. [b]Note:[/b] Godot's BMP module doesn't support 16-bit per pixel images. Only 1-bit, 4-bit, 8-bit, 24-bit, and 32-bit per pixel images are supported. </description> </method> <method name="load_jpg_from_buffer"> - <return type="int" enum="Error"> - </return> - <argument index="0" name="buffer" type="PackedByteArray"> - </argument> + <return type="int" enum="Error" /> + <argument index="0" name="buffer" type="PackedByteArray" /> <description> Loads an image from the binary contents of a JPEG file. </description> </method> <method name="load_png_from_buffer"> - <return type="int" enum="Error"> - </return> - <argument index="0" name="buffer" type="PackedByteArray"> - </argument> + <return type="int" enum="Error" /> + <argument index="0" name="buffer" type="PackedByteArray" /> <description> Loads an image from the binary contents of a PNG file. </description> </method> <method name="load_tga_from_buffer"> - <return type="int" enum="Error"> - </return> - <argument index="0" name="buffer" type="PackedByteArray"> - </argument> + <return type="int" enum="Error" /> + <argument index="0" name="buffer" type="PackedByteArray" /> <description> Loads an image from the binary contents of a TGA file. </description> </method> <method name="load_webp_from_buffer"> - <return type="int" enum="Error"> - </return> - <argument index="0" name="buffer" type="PackedByteArray"> - </argument> + <return type="int" enum="Error" /> + <argument index="0" name="buffer" type="PackedByteArray" /> <description> Loads an image from the binary contents of a WebP file. </description> </method> <method name="normal_map_to_xy"> - <return type="void"> - </return> + <return type="void" /> <description> Converts the image's data to represent coordinates on a 3D plane. This is used when the image represents a normal map. A normal map can add lots of detail to a 3D surface without increasing the polygon count. </description> </method> <method name="premultiply_alpha"> - <return type="void"> - </return> + <return type="void" /> <description> Multiplies color values with alpha values. Resulting color values for a pixel are [code](color * alpha)/256[/code]. </description> </method> <method name="resize"> - <return type="void"> - </return> - <argument index="0" name="width" type="int"> - </argument> - <argument index="1" name="height" type="int"> - </argument> - <argument index="2" name="interpolation" type="int" enum="Image.Interpolation" default="1"> - </argument> + <return type="void" /> + <argument index="0" name="width" type="int" /> + <argument index="1" name="height" type="int" /> + <argument index="2" name="interpolation" type="int" enum="Image.Interpolation" default="1" /> <description> Resizes the image to the given [code]width[/code] and [code]height[/code]. New pixels are calculated using the [code]interpolation[/code] mode defined via [enum Interpolation] constants. </description> </method> <method name="resize_to_po2"> - <return type="void"> - </return> - <argument index="0" name="square" type="bool" default="false"> - </argument> - <argument index="1" name="interpolation" type="int" enum="Image.Interpolation" default="1"> - </argument> + <return type="void" /> + <argument index="0" name="square" type="bool" default="false" /> + <argument index="1" name="interpolation" type="int" enum="Image.Interpolation" default="1" /> <description> Resizes the image to the nearest power of 2 for the width and height. If [code]square[/code] is [code]true[/code] then set width and height to be the same. New pixels are calculated using the [code]interpolation[/code] mode defined via [enum Interpolation] constants. </description> </method> <method name="rgbe_to_srgb"> - <return type="Image"> - </return> + <return type="Image" /> <description> Converts a standard RGBE (Red Green Blue Exponent) image to an sRGB image. </description> </method> <method name="save_exr" qualifiers="const"> - <return type="int" enum="Error"> - </return> - <argument index="0" name="path" type="String"> - </argument> - <argument index="1" name="grayscale" type="bool" default="false"> - </argument> + <return type="int" enum="Error" /> + <argument index="0" name="path" type="String" /> + <argument index="1" name="grayscale" type="bool" default="false" /> <description> Saves the image as an EXR file to [code]path[/code]. If [code]grayscale[/code] is [code]true[/code] and the image has only one channel, it will be saved explicitly as monochrome rather than one red channel. This function will return [constant ERR_UNAVAILABLE] if Godot was compiled without the TinyEXR module. + [b]Note:[/b] The TinyEXR module is disabled in non-editor builds, which means [method save_exr] will return [constant ERR_UNAVAILABLE] when it is called from an exported project. </description> </method> <method name="save_png" qualifiers="const"> - <return type="int" enum="Error"> - </return> - <argument index="0" name="path" type="String"> - </argument> + <return type="int" enum="Error" /> + <argument index="0" name="path" type="String" /> <description> Saves the image as a PNG file to [code]path[/code]. </description> </method> <method name="save_png_to_buffer" qualifiers="const"> - <return type="PackedByteArray"> - </return> + <return type="PackedByteArray" /> <description> </description> </method> <method name="set_pixel"> - <return type="void"> - </return> - <argument index="0" name="x" type="int"> - </argument> - <argument index="1" name="y" type="int"> - </argument> - <argument index="2" name="color" type="Color"> - </argument> + <return type="void" /> + <argument index="0" name="x" type="int" /> + <argument index="1" name="y" type="int" /> + <argument index="2" name="color" type="Color" /> <description> Sets the [Color] of the pixel at [code](x, y)[/code] to [code]color[/code]. Example: [codeblocks] @@ -515,12 +403,9 @@ </description> </method> <method name="set_pixelv"> - <return type="void"> - </return> - <argument index="0" name="point" type="Vector2i"> - </argument> - <argument index="1" name="color" type="Color"> - </argument> + <return type="void" /> + <argument index="0" name="point" type="Vector2i" /> + <argument index="1" name="color" type="Color" /> <description> Sets the [Color] of the pixel at [code]point[/code] to [code]color[/code]. Example: [codeblocks] @@ -545,15 +430,13 @@ </description> </method> <method name="shrink_x2"> - <return type="void"> - </return> + <return type="void" /> <description> Shrinks the image by a factor of 2. </description> </method> <method name="srgb_to_linear"> - <return type="void"> - </return> + <return type="void" /> <description> Converts the raw data from the sRGB colorspace to a linear scale. </description> @@ -710,7 +593,7 @@ </constant> <constant name="INTERPOLATE_TRILINEAR" value="3" enum="Interpolation"> Performs bilinear separately on the two most-suited mipmap levels, then linearly interpolates between them. - It's slower than [constant INTERPOLATE_BILINEAR], but produces higher-quality results with much less aliasing artifacts. + It's slower than [constant INTERPOLATE_BILINEAR], but produces higher-quality results with far fewer aliasing artifacts. If the image does not have mipmaps, they will be generated and used internally, but no mipmaps will be generated on the resulting image. [b]Note:[/b] If you intend to scale multiple copies of the original image, it's better to call [method generate_mipmaps]] on it in advance, to avoid wasting processing power in generating them again and again. On the other hand, if the image already has mipmaps, they will be used, and a new set will be generated for the resulting image. diff --git a/doc/classes/ImageTexture.xml b/doc/classes/ImageTexture.xml index f89b6ad57b..435fec6a50 100644 --- a/doc/classes/ImageTexture.xml +++ b/doc/classes/ImageTexture.xml @@ -32,35 +32,28 @@ </tutorials> <methods> <method name="create_from_image"> - <return type="void"> - </return> - <argument index="0" name="image" type="Image"> - </argument> + <return type="void" /> + <argument index="0" name="image" type="Image" /> <description> Initializes the texture by allocating and setting the data from an [Image]. </description> </method> <method name="get_format" qualifiers="const"> - <return type="int" enum="Image.Format"> - </return> + <return type="int" enum="Image.Format" /> <description> Returns the format of the texture, one of [enum Image.Format]. </description> </method> <method name="set_size_override"> - <return type="void"> - </return> - <argument index="0" name="size" type="Vector2"> - </argument> + <return type="void" /> + <argument index="0" name="size" type="Vector2" /> <description> Resizes the texture to the specified dimensions. </description> </method> <method name="update"> - <return type="void"> - </return> - <argument index="0" name="image" type="Image"> - </argument> + <return type="void" /> + <argument index="0" name="image" type="Image" /> <description> Replaces the texture's data with a new [Image]. [b]Note:[/b] The texture has to be initialized first with the [method create_from_image] method before it can be updated. The new image dimensions, format, and mipmaps configuration should match the existing texture's image configuration, otherwise it has to be re-created with the [method create_from_image] method. diff --git a/doc/classes/ImageTexture3D.xml b/doc/classes/ImageTexture3D.xml index d05082487d..538a836c1c 100644 --- a/doc/classes/ImageTexture3D.xml +++ b/doc/classes/ImageTexture3D.xml @@ -8,28 +8,19 @@ </tutorials> <methods> <method name="create"> - <return type="int" enum="Error"> - </return> - <argument index="0" name="format" type="int" enum="Image.Format"> - </argument> - <argument index="1" name="width" type="int"> - </argument> - <argument index="2" name="height" type="int"> - </argument> - <argument index="3" name="depth" type="int"> - </argument> - <argument index="4" name="use_mipmaps" type="bool"> - </argument> - <argument index="5" name="data" type="Image[]"> - </argument> + <return type="int" enum="Error" /> + <argument index="0" name="format" type="int" enum="Image.Format" /> + <argument index="1" name="width" type="int" /> + <argument index="2" name="height" type="int" /> + <argument index="3" name="depth" type="int" /> + <argument index="4" name="use_mipmaps" type="bool" /> + <argument index="5" name="data" type="Image[]" /> <description> </description> </method> <method name="update"> - <return type="void"> - </return> - <argument index="0" name="data" type="Image[]"> - </argument> + <return type="void" /> + <argument index="0" name="data" type="Image[]" /> <description> </description> </method> diff --git a/doc/classes/ImageTextureLayered.xml b/doc/classes/ImageTextureLayered.xml index d06b44afa9..1b7400803d 100644 --- a/doc/classes/ImageTextureLayered.xml +++ b/doc/classes/ImageTextureLayered.xml @@ -8,20 +8,15 @@ </tutorials> <methods> <method name="create_from_images"> - <return type="int" enum="Error"> - </return> - <argument index="0" name="images" type="Array"> - </argument> + <return type="int" enum="Error" /> + <argument index="0" name="images" type="Array" /> <description> </description> </method> <method name="update_layer"> - <return type="void"> - </return> - <argument index="0" name="image" type="Image"> - </argument> - <argument index="1" name="layer" type="int"> - </argument> + <return type="void" /> + <argument index="0" name="image" type="Image" /> + <argument index="1" name="layer" type="int" /> <description> </description> </method> diff --git a/doc/classes/ImmediateMesh.xml b/doc/classes/ImmediateMesh.xml index d2ae091cad..69637d5bdd 100644 --- a/doc/classes/ImmediateMesh.xml +++ b/doc/classes/ImmediateMesh.xml @@ -10,89 +10,70 @@ </tutorials> <methods> <method name="clear_surfaces"> - <return type="void"> - </return> + <return type="void" /> <description> Clear all surfaces. </description> </method> <method name="surface_add_vertex"> - <return type="void"> - </return> - <argument index="0" name="vertex" type="Vector3"> - </argument> + <return type="void" /> + <argument index="0" name="vertex" type="Vector3" /> <description> Add a 3D vertex using the current attributes previously set. </description> </method> <method name="surface_add_vertex_2d"> - <return type="void"> - </return> - <argument index="0" name="vertex" type="Vector2"> - </argument> + <return type="void" /> + <argument index="0" name="vertex" type="Vector2" /> <description> Add a 2D vertex using the current attributes previously set. </description> </method> <method name="surface_begin"> - <return type="void"> - </return> - <argument index="0" name="primitive" type="int" enum="Mesh.PrimitiveType"> - </argument> - <argument index="1" name="material" type="Material" default="null"> - </argument> + <return type="void" /> + <argument index="0" name="primitive" type="int" enum="Mesh.PrimitiveType" /> + <argument index="1" name="material" type="Material" default="null" /> <description> Begin a new surface. </description> </method> <method name="surface_end"> - <return type="void"> - </return> + <return type="void" /> <description> End and commit current surface. Note that surface being created will not be visible until this function is called. </description> </method> <method name="surface_set_color"> - <return type="void"> - </return> - <argument index="0" name="color" type="Color"> - </argument> + <return type="void" /> + <argument index="0" name="color" type="Color" /> <description> Set the color attribute that will be pushed with the next vertex. </description> </method> <method name="surface_set_normal"> - <return type="void"> - </return> - <argument index="0" name="normal" type="Vector3"> - </argument> + <return type="void" /> + <argument index="0" name="normal" type="Vector3" /> <description> Set the normal attribute that will be pushed with the next vertex. </description> </method> <method name="surface_set_tangent"> - <return type="void"> - </return> - <argument index="0" name="tangent" type="Plane"> - </argument> + <return type="void" /> + <argument index="0" name="tangent" type="Plane" /> <description> Set the tangent attribute that will be pushed with the next vertex. </description> </method> <method name="surface_set_uv"> - <return type="void"> - </return> - <argument index="0" name="uv" type="Vector2"> - </argument> + <return type="void" /> + <argument index="0" name="uv" type="Vector2" /> <description> Set the UV attribute that will be pushed with the next vertex. </description> </method> <method name="surface_set_uv2"> - <return type="void"> - </return> - <argument index="0" name="uv2" type="Vector2"> - </argument> + <return type="void" /> + <argument index="0" name="uv2" type="Vector2" /> <description> Set the UV2 attribute that will be pushed with the next vertex. </description> diff --git a/doc/classes/Input.xml b/doc/classes/Input.xml index b970070659..293456b645 100644 --- a/doc/classes/Input.xml +++ b/doc/classes/Input.xml @@ -13,12 +13,9 @@ </tutorials> <methods> <method name="action_press"> - <return type="void"> - </return> - <argument index="0" name="action" type="StringName"> - </argument> - <argument index="1" name="strength" type="float" default="1.0"> - </argument> + <return type="void" /> + <argument index="0" name="action" type="StringName" /> + <argument index="1" name="strength" type="float" default="1.0" /> <description> This will simulate pressing the specified action. The strength can be used for non-boolean actions, it's ranged between 0 and 1 representing the intensity of the given action. @@ -26,28 +23,22 @@ </description> </method> <method name="action_release"> - <return type="void"> - </return> - <argument index="0" name="action" type="StringName"> - </argument> + <return type="void" /> + <argument index="0" name="action" type="StringName" /> <description> If the specified action is already pressed, this will release it. </description> </method> <method name="add_joy_mapping"> - <return type="void"> - </return> - <argument index="0" name="mapping" type="String"> - </argument> - <argument index="1" name="update_existing" type="bool" default="false"> - </argument> + <return type="void" /> + <argument index="0" name="mapping" type="String" /> + <argument index="1" name="update_existing" type="bool" default="false" /> <description> Adds a new mapping entry (in SDL2 format) to the mapping database. Optionally update already connected devices. </description> </method> <method name="get_accelerometer" qualifiers="const"> - <return type="Vector3"> - </return> + <return type="Vector3" /> <description> Returns the acceleration in m/s² of the device's accelerometer sensor, if the device has one. Otherwise, the method returns [constant Vector3.ZERO]. Note this method returns an empty [Vector3] when running from the editor even when your device has an accelerometer. You must export your project to a supported device to read values from the accelerometer. @@ -55,257 +46,203 @@ </description> </method> <method name="get_action_raw_strength" qualifiers="const"> - <return type="float"> - </return> - <argument index="0" name="action" type="StringName"> - </argument> - <argument index="1" name="exact_match" type="bool" default="false"> - </argument> + <return type="float" /> + <argument index="0" name="action" type="StringName" /> + <argument index="1" name="exact_match" type="bool" default="false" /> <description> Returns a value between 0 and 1 representing the raw intensity of the given action, ignoring the action's deadzone. In most cases, you should use [method get_action_strength] instead. + If [code]exact_match[/code] is [code]false[/code], it ignores the input modifiers for [InputEventKey] and [InputEventMouseButton] events, and the direction for [InputEventJoypadMotion] events. </description> </method> <method name="get_action_strength" qualifiers="const"> - <return type="float"> - </return> - <argument index="0" name="action" type="StringName"> - </argument> - <argument index="1" name="exact_match" type="bool" default="false"> - </argument> + <return type="float" /> + <argument index="0" name="action" type="StringName" /> + <argument index="1" name="exact_match" type="bool" default="false" /> <description> Returns a value between 0 and 1 representing the intensity of the given action. In a joypad, for example, the further away the axis (analog sticks or L2, R2 triggers) is from the dead zone, the closer the value will be to 1. If the action is mapped to a control that has no axis as the keyboard, the value returned will be 0 or 1. + If [code]exact_match[/code] is [code]false[/code], it ignores the input modifiers for [InputEventKey] and [InputEventMouseButton] events, and the direction for [InputEventJoypadMotion] events. </description> </method> <method name="get_axis" qualifiers="const"> - <return type="float"> - </return> - <argument index="0" name="negative_action" type="StringName"> - </argument> - <argument index="1" name="positive_action" type="StringName"> - </argument> + <return type="float" /> + <argument index="0" name="negative_action" type="StringName" /> + <argument index="1" name="positive_action" type="StringName" /> <description> Get axis input by specifying two actions, one negative and one positive. This is a shorthand for writing [code]Input.get_action_strength("positive_action") - Input.get_action_strength("negative_action")[/code]. </description> </method> <method name="get_connected_joypads"> - <return type="Array"> - </return> + <return type="Array" /> <description> Returns an [Array] containing the device IDs of all currently connected joypads. </description> </method> <method name="get_current_cursor_shape" qualifiers="const"> - <return type="int" enum="Input.CursorShape"> - </return> + <return type="int" enum="Input.CursorShape" /> <description> Returns the currently assigned cursor shape (see [enum CursorShape]). </description> </method> <method name="get_gravity" qualifiers="const"> - <return type="Vector3"> - </return> + <return type="Vector3" /> <description> Returns the gravity in m/s² of the device's accelerometer sensor, if the device has one. Otherwise, the method returns [constant Vector3.ZERO]. [b]Note:[/b] This method only works on Android and iOS. On other platforms, it always returns [constant Vector3.ZERO]. </description> </method> <method name="get_gyroscope" qualifiers="const"> - <return type="Vector3"> - </return> + <return type="Vector3" /> <description> Returns the rotation rate in rad/s around a device's X, Y, and Z axes of the gyroscope sensor, if the device has one. Otherwise, the method returns [constant Vector3.ZERO]. [b]Note:[/b] This method only works on Android and iOS. On other platforms, it always returns [constant Vector3.ZERO]. </description> </method> <method name="get_joy_axis" qualifiers="const"> - <return type="float"> - </return> - <argument index="0" name="device" type="int"> - </argument> - <argument index="1" name="axis" type="int" enum="JoyAxis"> - </argument> + <return type="float" /> + <argument index="0" name="device" type="int" /> + <argument index="1" name="axis" type="int" enum="JoyAxis" /> <description> Returns the current value of the joypad axis at given index (see [enum JoyAxis]). </description> </method> <method name="get_joy_guid" qualifiers="const"> - <return type="String"> - </return> - <argument index="0" name="device" type="int"> - </argument> + <return type="String" /> + <argument index="0" name="device" type="int" /> <description> Returns a SDL2-compatible device GUID on platforms that use gamepad remapping. Returns [code]"Default Gamepad"[/code] otherwise. </description> </method> <method name="get_joy_name"> - <return type="String"> - </return> - <argument index="0" name="device" type="int"> - </argument> + <return type="String" /> + <argument index="0" name="device" type="int" /> <description> Returns the name of the joypad at the specified device index. </description> </method> <method name="get_joy_vibration_duration"> - <return type="float"> - </return> - <argument index="0" name="device" type="int"> - </argument> + <return type="float" /> + <argument index="0" name="device" type="int" /> <description> Returns the duration of the current vibration effect in seconds. </description> </method> <method name="get_joy_vibration_strength"> - <return type="Vector2"> - </return> - <argument index="0" name="device" type="int"> - </argument> + <return type="Vector2" /> + <argument index="0" name="device" type="int" /> <description> Returns the strength of the joypad vibration: x is the strength of the weak motor, and y is the strength of the strong motor. </description> </method> <method name="get_last_mouse_speed" qualifiers="const"> - <return type="Vector2"> - </return> + <return type="Vector2" /> <description> Returns the mouse speed for the last time the cursor was moved, and this until the next frame where the mouse moves. This means that even if the mouse is not moving, this function will still return the value of the last motion. </description> </method> <method name="get_magnetometer" qualifiers="const"> - <return type="Vector3"> - </return> + <return type="Vector3" /> <description> Returns the magnetic field strength in micro-Tesla for all axes of the device's magnetometer sensor, if the device has one. Otherwise, the method returns [constant Vector3.ZERO]. [b]Note:[/b] This method only works on Android, iOS and UWP. On other platforms, it always returns [constant Vector3.ZERO]. </description> </method> <method name="get_mouse_button_mask" qualifiers="const"> - <return type="int"> - </return> + <return type="int" /> <description> Returns mouse buttons as a bitmask. If multiple mouse buttons are pressed at the same time, the bits are added together. </description> </method> <method name="get_mouse_mode" qualifiers="const"> - <return type="int" enum="Input.MouseMode"> - </return> + <return type="int" enum="Input.MouseMode" /> <description> Returns the mouse mode. See the constants for more information. </description> </method> <method name="get_vector" qualifiers="const"> - <return type="Vector2"> - </return> - <argument index="0" name="negative_x" type="StringName"> - </argument> - <argument index="1" name="positive_x" type="StringName"> - </argument> - <argument index="2" name="negative_y" type="StringName"> - </argument> - <argument index="3" name="positive_y" type="StringName"> - </argument> - <argument index="4" name="deadzone" type="float" default="-1.0"> - </argument> - <description> - Get vector input by specifying four actions, two for the X axis and two for the Y axis, negative and positive. + <return type="Vector2" /> + <argument index="0" name="negative_x" type="StringName" /> + <argument index="1" name="positive_x" type="StringName" /> + <argument index="2" name="negative_y" type="StringName" /> + <argument index="3" name="positive_y" type="StringName" /> + <argument index="4" name="deadzone" type="float" default="-1.0" /> + <description> + Gets an input vector by specifying four actions for the positive and negative X and Y axes. This method is useful when getting vector input, such as from a joystick, directional pad, arrows, or WASD. The vector has its length limited to 1 and has a circular deadzone, which is useful for using vector input as movement. By default, the deadzone is automatically calculated from the average of the action deadzones. However, you can override the deadzone to be whatever you want (on the range of 0 to 1). </description> </method> <method name="is_action_just_pressed" qualifiers="const"> - <return type="bool"> - </return> - <argument index="0" name="action" type="StringName"> - </argument> - <argument index="1" name="exact_match" type="bool" default="false"> - </argument> + <return type="bool" /> + <argument index="0" name="action" type="StringName" /> + <argument index="1" name="exact_match" type="bool" default="false" /> <description> Returns [code]true[/code] when the user starts pressing the action event, meaning it's [code]true[/code] only on the frame that the user pressed down the button. This is useful for code that needs to run only once when an action is pressed, instead of every frame while it's pressed. + If [code]exact_match[/code] is [code]false[/code], it ignores the input modifiers for [InputEventKey] and [InputEventMouseButton] events, and the direction for [InputEventJoypadMotion] events. </description> </method> <method name="is_action_just_released" qualifiers="const"> - <return type="bool"> - </return> - <argument index="0" name="action" type="StringName"> - </argument> - <argument index="1" name="exact_match" type="bool" default="false"> - </argument> + <return type="bool" /> + <argument index="0" name="action" type="StringName" /> + <argument index="1" name="exact_match" type="bool" default="false" /> <description> Returns [code]true[/code] when the user stops pressing the action event, meaning it's [code]true[/code] only on the frame that the user released the button. + If [code]exact_match[/code] is [code]false[/code], it ignores the input modifiers for [InputEventKey] and [InputEventMouseButton] events, and the direction for [InputEventJoypadMotion] events. </description> </method> <method name="is_action_pressed" qualifiers="const"> - <return type="bool"> - </return> - <argument index="0" name="action" type="StringName"> - </argument> - <argument index="1" name="exact_match" type="bool" default="false"> - </argument> + <return type="bool" /> + <argument index="0" name="action" type="StringName" /> + <argument index="1" name="exact_match" type="bool" default="false" /> <description> Returns [code]true[/code] if you are pressing the action event. Note that if an action has multiple buttons assigned and more than one of them is pressed, releasing one button will release the action, even if some other button assigned to this action is still pressed. + If [code]exact_match[/code] is [code]false[/code], it ignores the input modifiers for [InputEventKey] and [InputEventMouseButton] events, and the direction for [InputEventJoypadMotion] events. </description> </method> <method name="is_joy_button_pressed" qualifiers="const"> - <return type="bool"> - </return> - <argument index="0" name="device" type="int"> - </argument> - <argument index="1" name="button" type="int" enum="JoyButton"> - </argument> + <return type="bool" /> + <argument index="0" name="device" type="int" /> + <argument index="1" name="button" type="int" enum="JoyButton" /> <description> Returns [code]true[/code] if you are pressing the joypad button (see [enum JoyButton]). </description> </method> <method name="is_joy_known"> - <return type="bool"> - </return> - <argument index="0" name="device" type="int"> - </argument> + <return type="bool" /> + <argument index="0" name="device" type="int" /> <description> Returns [code]true[/code] if the system knows the specified device. This means that it sets all button and axis indices. Unknown joypads are not expected to match these constants, but you can still retrieve events from them. </description> </method> <method name="is_key_pressed" qualifiers="const"> - <return type="bool"> - </return> - <argument index="0" name="keycode" type="int"> - </argument> + <return type="bool" /> + <argument index="0" name="keycode" type="int" /> <description> Returns [code]true[/code] if you are pressing the key in the current keyboard layout. You can pass a [enum Key] constant. </description> </method> <method name="is_mouse_button_pressed" qualifiers="const"> - <return type="bool"> - </return> - <argument index="0" name="button" type="int" enum="MouseButton"> - </argument> + <return type="bool" /> + <argument index="0" name="button" type="int" enum="MouseButton" /> <description> Returns [code]true[/code] if you are pressing the mouse button specified with [enum MouseButton]. </description> </method> <method name="joy_connection_changed"> - <return type="void"> - </return> - <argument index="0" name="device" type="int"> - </argument> - <argument index="1" name="connected" type="bool"> - </argument> - <argument index="2" name="name" type="String"> - </argument> - <argument index="3" name="guid" type="String"> - </argument> + <return type="void" /> + <argument index="0" name="device" type="int" /> + <argument index="1" name="connected" type="bool" /> + <argument index="2" name="name" type="String" /> + <argument index="3" name="guid" type="String" /> <description> Notifies the [Input] singleton that a connection has changed, to update the state for the [code]device[/code] index. This is used internally and should not have to be called from user scripts. See [signal joy_connection_changed] for the signal emitted when this is triggered internally. </description> </method> <method name="parse_input_event"> - <return type="void"> - </return> - <argument index="0" name="event" type="InputEvent"> - </argument> + <return type="void" /> + <argument index="0" name="event" type="InputEvent" /> <description> Feeds an [InputEvent] to the game. Can be used to artificially trigger input events from code. Also generates [method Node._input] calls. Example: @@ -326,23 +263,17 @@ </description> </method> <method name="remove_joy_mapping"> - <return type="void"> - </return> - <argument index="0" name="guid" type="String"> - </argument> + <return type="void" /> + <argument index="0" name="guid" type="String" /> <description> Removes all mappings from the internal database that match the given GUID. </description> </method> <method name="set_custom_mouse_cursor"> - <return type="void"> - </return> - <argument index="0" name="image" type="Resource"> - </argument> - <argument index="1" name="shape" type="int" enum="Input.CursorShape" default="0"> - </argument> - <argument index="2" name="hotspot" type="Vector2" default="Vector2(0, 0)"> - </argument> + <return type="void" /> + <argument index="0" name="image" type="Resource" /> + <argument index="1" name="shape" type="int" enum="Input.CursorShape" default="0" /> + <argument index="2" name="hotspot" type="Vector2" default="Vector2(0, 0)" /> <description> Sets a custom mouse cursor image, which is only visible inside the game window. The hotspot can also be specified. Passing [code]null[/code] to the image parameter resets to the system cursor. See [enum CursorShape] for the list of shapes. [code]image[/code]'s size must be lower than 256×256. @@ -352,10 +283,8 @@ </description> </method> <method name="set_default_cursor_shape"> - <return type="void"> - </return> - <argument index="0" name="shape" type="int" enum="Input.CursorShape" default="0"> - </argument> + <return type="void" /> + <argument index="0" name="shape" type="int" enum="Input.CursorShape" default="0" /> <description> Sets the default cursor shape to be used in the viewport instead of [constant CURSOR_ARROW]. [b]Note:[/b] If you want to change the default cursor shape for [Control]'s nodes, use [member Control.mouse_default_cursor_shape] instead. @@ -363,64 +292,49 @@ </description> </method> <method name="set_mouse_mode"> - <return type="void"> - </return> - <argument index="0" name="mode" type="int" enum="Input.MouseMode"> - </argument> + <return type="void" /> + <argument index="0" name="mode" type="int" enum="Input.MouseMode" /> <description> Sets the mouse mode. See the constants for more information. </description> </method> <method name="set_use_accumulated_input"> - <return type="void"> - </return> - <argument index="0" name="enable" type="bool"> - </argument> + <return type="void" /> + <argument index="0" name="enable" type="bool" /> <description> Enables or disables the accumulation of similar input events sent by the operating system. When input accumulation is enabled, all input events generated during a frame will be merged and emitted when the frame is done rendering. Therefore, this limits the number of input method calls per second to the rendering FPS. Input accumulation is enabled by default. It can be disabled to get slightly more precise/reactive input at the cost of increased CPU usage. In applications where drawing freehand lines is required, input accumulation should generally be disabled while the user is drawing the line to get results that closely follow the actual input. </description> </method> <method name="start_joy_vibration"> - <return type="void"> - </return> - <argument index="0" name="device" type="int"> - </argument> - <argument index="1" name="weak_magnitude" type="float"> - </argument> - <argument index="2" name="strong_magnitude" type="float"> - </argument> - <argument index="3" name="duration" type="float" default="0"> - </argument> + <return type="void" /> + <argument index="0" name="device" type="int" /> + <argument index="1" name="weak_magnitude" type="float" /> + <argument index="2" name="strong_magnitude" type="float" /> + <argument index="3" name="duration" type="float" default="0" /> <description> Starts to vibrate the joypad. Joypads usually come with two rumble motors, a strong and a weak one. [code]weak_magnitude[/code] is the strength of the weak motor (between 0 and 1) and [code]strong_magnitude[/code] is the strength of the strong motor (between 0 and 1). [code]duration[/code] is the duration of the effect in seconds (a duration of 0 will try to play the vibration indefinitely). [b]Note:[/b] Not every hardware is compatible with long effect durations; it is recommended to restart an effect if it has to be played for more than a few seconds. </description> </method> <method name="stop_joy_vibration"> - <return type="void"> - </return> - <argument index="0" name="device" type="int"> - </argument> + <return type="void" /> + <argument index="0" name="device" type="int" /> <description> Stops the vibration of the joypad. </description> </method> <method name="vibrate_handheld"> - <return type="void"> - </return> - <argument index="0" name="duration_ms" type="int" default="500"> - </argument> + <return type="void" /> + <argument index="0" name="duration_ms" type="int" default="500" /> <description> Vibrate Android and iOS devices. [b]Note:[/b] It needs [code]VIBRATE[/code] permission for Android at export settings. iOS does not support duration. </description> </method> <method name="warp_mouse_position"> - <return type="void"> - </return> - <argument index="0" name="to" type="Vector2"> - </argument> + <return type="void" /> + <argument index="0" name="to" type="Vector2" /> <description> Sets the mouse position to the specified vector. </description> @@ -428,10 +342,8 @@ </methods> <signals> <signal name="joy_connection_changed"> - <argument index="0" name="device" type="int"> - </argument> - <argument index="1" name="connected" type="bool"> - </argument> + <argument index="0" name="device" type="int" /> + <argument index="1" name="connected" type="bool" /> <description> Emitted when a joypad device has been connected or disconnected. </description> diff --git a/doc/classes/InputEvent.xml b/doc/classes/InputEvent.xml index c28c4c4282..cd14965d1b 100644 --- a/doc/classes/InputEvent.xml +++ b/doc/classes/InputEvent.xml @@ -14,108 +14,87 @@ </tutorials> <methods> <method name="accumulate"> - <return type="bool"> - </return> - <argument index="0" name="with_event" type="InputEvent"> - </argument> + <return type="bool" /> + <argument index="0" name="with_event" type="InputEvent" /> <description> Returns [code]true[/code] if the given input event and this input event can be added together (only for events of type [InputEventMouseMotion]). The given input event's position, global position and speed will be copied. The resulting [code]relative[/code] is a sum of both events. Both events' modifiers have to be identical. </description> </method> <method name="as_text" qualifiers="const"> - <return type="String"> - </return> + <return type="String" /> <description> Returns a [String] representation of the event. </description> </method> <method name="get_action_strength" qualifiers="const"> - <return type="float"> - </return> - <argument index="0" name="action" type="StringName"> - </argument> - <argument index="1" name="exact_match" type="bool" default="false"> - </argument> + <return type="float" /> + <argument index="0" name="action" type="StringName" /> + <argument index="1" name="exact_match" type="bool" default="false" /> <description> Returns a value between 0.0 and 1.0 depending on the given actions' state. Useful for getting the value of events of type [InputEventJoypadMotion]. + If [code]exact_match[/code] is [code]false[/code], it ignores the input modifiers for [InputEventKey] and [InputEventMouseButton] events, and the direction for [InputEventJoypadMotion] events. </description> </method> <method name="is_action" qualifiers="const"> - <return type="bool"> - </return> - <argument index="0" name="action" type="StringName"> - </argument> - <argument index="1" name="exact_match" type="bool" default="false"> - </argument> + <return type="bool" /> + <argument index="0" name="action" type="StringName" /> + <argument index="1" name="exact_match" type="bool" default="false" /> <description> Returns [code]true[/code] if this input event matches a pre-defined action of any type. + If [code]exact_match[/code] is [code]false[/code], it ignores the input modifiers for [InputEventKey] and [InputEventMouseButton] events, and the direction for [InputEventJoypadMotion] events. </description> </method> <method name="is_action_pressed" qualifiers="const"> - <return type="bool"> - </return> - <argument index="0" name="action" type="StringName"> - </argument> - <argument index="1" name="allow_echo" type="bool" default="false"> - </argument> - <argument index="2" name="exact_match" type="bool" default="false"> - </argument> + <return type="bool" /> + <argument index="0" name="action" type="StringName" /> + <argument index="1" name="allow_echo" type="bool" default="false" /> + <argument index="2" name="exact_match" type="bool" default="false" /> <description> Returns [code]true[/code] if the given action is being pressed (and is not an echo event for [InputEventKey] events, unless [code]allow_echo[/code] is [code]true[/code]). Not relevant for events of type [InputEventMouseMotion] or [InputEventScreenDrag]. + If [code]exact_match[/code] is [code]false[/code], it ignores the input modifiers for [InputEventKey] and [InputEventMouseButton] events, and the direction for [InputEventJoypadMotion] events. </description> </method> <method name="is_action_released" qualifiers="const"> - <return type="bool"> - </return> - <argument index="0" name="action" type="StringName"> - </argument> - <argument index="1" name="exact_match" type="bool" default="false"> - </argument> + <return type="bool" /> + <argument index="0" name="action" type="StringName" /> + <argument index="1" name="exact_match" type="bool" default="false" /> <description> Returns [code]true[/code] if the given action is released (i.e. not pressed). Not relevant for events of type [InputEventMouseMotion] or [InputEventScreenDrag]. + If [code]exact_match[/code] is [code]false[/code], it ignores the input modifiers for [InputEventKey] and [InputEventMouseButton] events, and the direction for [InputEventJoypadMotion] events. </description> </method> <method name="is_action_type" qualifiers="const"> - <return type="bool"> - </return> + <return type="bool" /> <description> Returns [code]true[/code] if this input event's type is one that can be assigned to an input action. </description> </method> <method name="is_echo" qualifiers="const"> - <return type="bool"> - </return> + <return type="bool" /> <description> Returns [code]true[/code] if this input event is an echo event (only for events of type [InputEventKey]). </description> </method> <method name="is_match" qualifiers="const"> - <return type="bool"> - </return> - <argument index="0" name="event" type="InputEvent"> - </argument> - <argument index="1" name="exact_match" type="bool" default="true"> - </argument> + <return type="bool" /> + <argument index="0" name="event" type="InputEvent" /> + <argument index="1" name="exact_match" type="bool" default="true" /> <description> Returns [code]true[/code] if the specified [code]event[/code] matches this event. Only valid for action events i.e key ([InputEventKey]), button ([InputEventMouseButton] or [InputEventJoypadButton]), axis [InputEventJoypadMotion] or action ([InputEventAction]) events. If [code]exact_match[/code] is [code]false[/code], it ignores the input modifiers for [InputEventKey] and [InputEventMouseButton] events, and the direction for [InputEventJoypadMotion] events. </description> </method> <method name="is_pressed" qualifiers="const"> - <return type="bool"> - </return> + <return type="bool" /> <description> Returns [code]true[/code] if this input event is pressed. Not relevant for events of type [InputEventMouseMotion] or [InputEventScreenDrag]. </description> </method> <method name="xformed_by" qualifiers="const"> - <return type="InputEvent"> - </return> - <argument index="0" name="xform" type="Transform2D"> - </argument> - <argument index="1" name="local_ofs" type="Vector2" default="Vector2(0, 0)"> - </argument> + <return type="InputEvent" /> + <argument index="0" name="xform" type="Transform2D" /> + <argument index="1" name="local_ofs" type="Vector2" default="Vector2(0, 0)" /> <description> Returns a copy of the given input event which has been offset by [code]local_ofs[/code] and transformed by [code]xform[/code]. Relevant for events of type [InputEventMouseButton], [InputEventMouseMotion], [InputEventScreenTouch], [InputEventScreenDrag], [InputEventMagnifyGesture] and [InputEventPanGesture]. </description> diff --git a/doc/classes/InputEventKey.xml b/doc/classes/InputEventKey.xml index 9f2b829823..1b09ddee94 100644 --- a/doc/classes/InputEventKey.xml +++ b/doc/classes/InputEventKey.xml @@ -11,16 +11,14 @@ </tutorials> <methods> <method name="get_keycode_with_modifiers" qualifiers="const"> - <return type="int"> - </return> + <return type="int" /> <description> Returns the keycode combined with modifier keys such as [kbd]Shift[/kbd] or [kbd]Alt[/kbd]. See also [InputEventWithModifiers]. To get a human-readable representation of the [InputEventKey] with modifiers, use [code]OS.get_keycode_string(event.get_keycode_with_modifiers())[/code] where [code]event[/code] is the [InputEventKey]. </description> </method> <method name="get_physical_keycode_with_modifiers" qualifiers="const"> - <return type="int"> - </return> + <return type="int" /> <description> Returns the physical keycode combined with modifier keys such as [kbd]Shift[/kbd] or [kbd]Alt[/kbd]. See also [InputEventWithModifiers]. To get a human-readable representation of the [InputEventKey] with modifiers, use [code]OS.get_keycode_string(event.get_physical_keycode_with_modifiers())[/code] where [code]event[/code] is the [InputEventKey]. diff --git a/doc/classes/InputMap.xml b/doc/classes/InputMap.xml index 3948ab0208..16c2695613 100644 --- a/doc/classes/InputMap.xml +++ b/doc/classes/InputMap.xml @@ -11,129 +11,99 @@ </tutorials> <methods> <method name="action_add_event"> - <return type="void"> - </return> - <argument index="0" name="action" type="StringName"> - </argument> - <argument index="1" name="event" type="InputEvent"> - </argument> + <return type="void" /> + <argument index="0" name="action" type="StringName" /> + <argument index="1" name="event" type="InputEvent" /> <description> Adds an [InputEvent] to an action. This [InputEvent] will trigger the action. </description> </method> <method name="action_erase_event"> - <return type="void"> - </return> - <argument index="0" name="action" type="StringName"> - </argument> - <argument index="1" name="event" type="InputEvent"> - </argument> + <return type="void" /> + <argument index="0" name="action" type="StringName" /> + <argument index="1" name="event" type="InputEvent" /> <description> Removes an [InputEvent] from an action. </description> </method> <method name="action_erase_events"> - <return type="void"> - </return> - <argument index="0" name="action" type="StringName"> - </argument> + <return type="void" /> + <argument index="0" name="action" type="StringName" /> <description> Removes all events from an action. </description> </method> <method name="action_get_deadzone"> - <return type="float"> - </return> - <argument index="0" name="action" type="StringName"> - </argument> + <return type="float" /> + <argument index="0" name="action" type="StringName" /> <description> Returns a deadzone value for the action. </description> </method> <method name="action_get_events"> - <return type="Array"> - </return> - <argument index="0" name="action" type="StringName"> - </argument> + <return type="Array" /> + <argument index="0" name="action" type="StringName" /> <description> Returns an array of [InputEvent]s associated with a given action. </description> </method> <method name="action_has_event"> - <return type="bool"> - </return> - <argument index="0" name="action" type="StringName"> - </argument> - <argument index="1" name="event" type="InputEvent"> - </argument> + <return type="bool" /> + <argument index="0" name="action" type="StringName" /> + <argument index="1" name="event" type="InputEvent" /> <description> Returns [code]true[/code] if the action has the given [InputEvent] associated with it. </description> </method> <method name="action_set_deadzone"> - <return type="void"> - </return> - <argument index="0" name="action" type="StringName"> - </argument> - <argument index="1" name="deadzone" type="float"> - </argument> + <return type="void" /> + <argument index="0" name="action" type="StringName" /> + <argument index="1" name="deadzone" type="float" /> <description> Sets a deadzone value for the action. </description> </method> <method name="add_action"> - <return type="void"> - </return> - <argument index="0" name="action" type="StringName"> - </argument> - <argument index="1" name="deadzone" type="float" default="0.5"> - </argument> + <return type="void" /> + <argument index="0" name="action" type="StringName" /> + <argument index="1" name="deadzone" type="float" default="0.5" /> <description> Adds an empty action to the [InputMap] with a configurable [code]deadzone[/code]. An [InputEvent] can then be added to this action with [method action_add_event]. </description> </method> <method name="erase_action"> - <return type="void"> - </return> - <argument index="0" name="action" type="StringName"> - </argument> + <return type="void" /> + <argument index="0" name="action" type="StringName" /> <description> Removes an action from the [InputMap]. </description> </method> <method name="event_is_action" qualifiers="const"> - <return type="bool"> - </return> - <argument index="0" name="event" type="InputEvent"> - </argument> - <argument index="1" name="action" type="StringName"> - </argument> - <argument index="2" name="exact_match" type="bool" default="false"> - </argument> + <return type="bool" /> + <argument index="0" name="event" type="InputEvent" /> + <argument index="1" name="action" type="StringName" /> + <argument index="2" name="exact_match" type="bool" default="false" /> <description> Returns [code]true[/code] if the given event is part of an existing action. This method ignores keyboard modifiers if the given [InputEvent] is not pressed (for proper release detection). See [method action_has_event] if you don't want this behavior. + If [code]exact_match[/code] is [code]false[/code], it ignores the input modifiers for [InputEventKey] and [InputEventMouseButton] events, and the direction for [InputEventJoypadMotion] events. </description> </method> <method name="get_actions"> - <return type="Array"> - </return> + <return type="Array" /> <description> Returns an array of all actions in the [InputMap]. </description> </method> <method name="has_action" qualifiers="const"> - <return type="bool"> - </return> - <argument index="0" name="action" type="StringName"> - </argument> + <return type="bool" /> + <argument index="0" name="action" type="StringName" /> <description> Returns [code]true[/code] if the [InputMap] has a registered action with the given name. </description> </method> <method name="load_from_project_settings"> - <return type="void"> - </return> + <return type="void" /> <description> Clears all [InputEventAction] in the [InputMap] and load it anew from [ProjectSettings]. </description> diff --git a/doc/classes/InstancePlaceholder.xml b/doc/classes/InstancePlaceholder.xml index 934764b461..75892895d7 100644 --- a/doc/classes/InstancePlaceholder.xml +++ b/doc/classes/InstancePlaceholder.xml @@ -11,28 +11,22 @@ </tutorials> <methods> <method name="create_instance"> - <return type="Node"> - </return> - <argument index="0" name="replace" type="bool" default="false"> - </argument> - <argument index="1" name="custom_scene" type="PackedScene" default="null"> - </argument> + <return type="Node" /> + <argument index="0" name="replace" type="bool" default="false" /> + <argument index="1" name="custom_scene" type="PackedScene" default="null" /> <description> Not thread-safe. Use [method Object.call_deferred] if calling from a thread. </description> </method> <method name="get_instance_path" qualifiers="const"> - <return type="String"> - </return> + <return type="String" /> <description> Gets the path to the [PackedScene] resource file that is loaded by default when calling [method create_instance]. Not thread-safe. Use [method Object.call_deferred] if calling from a thread. </description> </method> <method name="get_stored_values"> - <return type="Dictionary"> - </return> - <argument index="0" name="with_order" type="bool" default="false"> - </argument> + <return type="Dictionary" /> + <argument index="0" name="with_order" type="bool" default="false" /> <description> </description> </method> diff --git a/doc/classes/ItemList.xml b/doc/classes/ItemList.xml index c639e0b88e..c60864886e 100644 --- a/doc/classes/ItemList.xml +++ b/doc/classes/ItemList.xml @@ -12,25 +12,18 @@ </tutorials> <methods> <method name="add_icon_item"> - <return type="int"> - </return> - <argument index="0" name="icon" type="Texture2D"> - </argument> - <argument index="1" name="selectable" type="bool" default="true"> - </argument> + <return type="int" /> + <argument index="0" name="icon" type="Texture2D" /> + <argument index="1" name="selectable" type="bool" default="true" /> <description> Adds an item to the item list with no text, only an icon. Returns the index of an added item. </description> </method> <method name="add_item"> - <return type="int"> - </return> - <argument index="0" name="text" type="String"> - </argument> - <argument index="1" name="icon" type="Texture2D" default="null"> - </argument> - <argument index="2" name="selectable" type="bool" default="true"> - </argument> + <return type="int" /> + <argument index="0" name="text" type="String" /> + <argument index="1" name="icon" type="Texture2D" default="null" /> + <argument index="2" name="selectable" type="bool" default="true" /> <description> Adds an item to the item list with specified text. Returns the index of an added item. Specify an [code]icon[/code], or use [code]null[/code] as the [code]icon[/code] for a list item with no icon. @@ -38,433 +31,331 @@ </description> </method> <method name="clear"> - <return type="void"> - </return> + <return type="void" /> <description> Removes all items from the list. </description> </method> <method name="clear_item_opentype_features"> - <return type="void"> - </return> - <argument index="0" name="idx" type="int"> - </argument> + <return type="void" /> + <argument index="0" name="idx" type="int" /> <description> Removes all OpenType features from the item's text. </description> </method> <method name="deselect"> - <return type="void"> - </return> - <argument index="0" name="idx" type="int"> - </argument> + <return type="void" /> + <argument index="0" name="idx" type="int" /> <description> Ensures the item associated with the specified index is not selected. </description> </method> <method name="deselect_all"> - <return type="void"> - </return> + <return type="void" /> <description> Ensures there are no items selected. </description> </method> <method name="ensure_current_is_visible"> - <return type="void"> - </return> + <return type="void" /> <description> Ensure current selection is visible, adjusting the scroll position as necessary. </description> </method> <method name="get_item_at_position" qualifiers="const"> - <return type="int"> - </return> - <argument index="0" name="position" type="Vector2"> - </argument> - <argument index="1" name="exact" type="bool" default="false"> - </argument> + <return type="int" /> + <argument index="0" name="position" type="Vector2" /> + <argument index="1" name="exact" type="bool" default="false" /> <description> Returns the item index at the given [code]position[/code]. When there is no item at that point, -1 will be returned if [code]exact[/code] is [code]true[/code], and the closest item index will be returned otherwise. </description> </method> <method name="get_item_count" qualifiers="const"> - <return type="int"> - </return> + <return type="int" /> <description> Returns the number of items currently in the list. </description> </method> <method name="get_item_custom_bg_color" qualifiers="const"> - <return type="Color"> - </return> - <argument index="0" name="idx" type="int"> - </argument> + <return type="Color" /> + <argument index="0" name="idx" type="int" /> <description> Returns the custom background color of the item specified by [code]idx[/code] index. </description> </method> <method name="get_item_custom_fg_color" qualifiers="const"> - <return type="Color"> - </return> - <argument index="0" name="idx" type="int"> - </argument> + <return type="Color" /> + <argument index="0" name="idx" type="int" /> <description> Returns the custom foreground color of the item specified by [code]idx[/code] index. </description> </method> <method name="get_item_icon" qualifiers="const"> - <return type="Texture2D"> - </return> - <argument index="0" name="idx" type="int"> - </argument> + <return type="Texture2D" /> + <argument index="0" name="idx" type="int" /> <description> Returns the icon associated with the specified index. </description> </method> <method name="get_item_icon_modulate" qualifiers="const"> - <return type="Color"> - </return> - <argument index="0" name="idx" type="int"> - </argument> + <return type="Color" /> + <argument index="0" name="idx" type="int" /> <description> Returns a [Color] modulating item's icon at the specified index. </description> </method> <method name="get_item_icon_region" qualifiers="const"> - <return type="Rect2"> - </return> - <argument index="0" name="idx" type="int"> - </argument> + <return type="Rect2" /> + <argument index="0" name="idx" type="int" /> <description> Returns the region of item's icon used. The whole icon will be used if the region has no area. </description> </method> <method name="get_item_language" qualifiers="const"> - <return type="String"> - </return> - <argument index="0" name="idx" type="int"> - </argument> + <return type="String" /> + <argument index="0" name="idx" type="int" /> <description> Returns item's text language code. </description> </method> <method name="get_item_metadata" qualifiers="const"> - <return type="Variant"> - </return> - <argument index="0" name="idx" type="int"> - </argument> + <return type="Variant" /> + <argument index="0" name="idx" type="int" /> <description> Returns the metadata value of the specified index. </description> </method> <method name="get_item_opentype_feature" qualifiers="const"> - <return type="int"> - </return> - <argument index="0" name="idx" type="int"> - </argument> - <argument index="1" name="tag" type="String"> - </argument> + <return type="int" /> + <argument index="0" name="idx" type="int" /> + <argument index="1" name="tag" type="String" /> <description> Returns OpenType feature [code]tag[/code] of the item's text. </description> </method> <method name="get_item_text" qualifiers="const"> - <return type="String"> - </return> - <argument index="0" name="idx" type="int"> - </argument> + <return type="String" /> + <argument index="0" name="idx" type="int" /> <description> Returns the text associated with the specified index. </description> </method> <method name="get_item_text_direction" qualifiers="const"> - <return type="int" enum="Control.TextDirection"> - </return> - <argument index="0" name="idx" type="int"> - </argument> + <return type="int" enum="Control.TextDirection" /> + <argument index="0" name="idx" type="int" /> <description> Returns item's text base writing direction. </description> </method> <method name="get_item_tooltip" qualifiers="const"> - <return type="String"> - </return> - <argument index="0" name="idx" type="int"> - </argument> + <return type="String" /> + <argument index="0" name="idx" type="int" /> <description> Returns the tooltip hint associated with the specified index. </description> </method> <method name="get_selected_items"> - <return type="PackedInt32Array"> - </return> + <return type="PackedInt32Array" /> <description> Returns an array with the indexes of the selected items. </description> </method> <method name="get_v_scroll"> - <return type="VScrollBar"> - </return> + <return type="VScrollBar" /> <description> Returns the [Object] ID associated with the list. </description> </method> <method name="is_anything_selected"> - <return type="bool"> - </return> + <return type="bool" /> <description> Returns [code]true[/code] if one or more items are selected. </description> </method> <method name="is_item_disabled" qualifiers="const"> - <return type="bool"> - </return> - <argument index="0" name="idx" type="int"> - </argument> + <return type="bool" /> + <argument index="0" name="idx" type="int" /> <description> Returns [code]true[/code] if the item at the specified index is disabled. </description> </method> <method name="is_item_icon_transposed" qualifiers="const"> - <return type="bool"> - </return> - <argument index="0" name="idx" type="int"> - </argument> + <return type="bool" /> + <argument index="0" name="idx" type="int" /> <description> Returns [code]true[/code] if the item icon will be drawn transposed, i.e. the X and Y axes are swapped. </description> </method> <method name="is_item_selectable" qualifiers="const"> - <return type="bool"> - </return> - <argument index="0" name="idx" type="int"> - </argument> + <return type="bool" /> + <argument index="0" name="idx" type="int" /> <description> Returns [code]true[/code] if the item at the specified index is selectable. </description> </method> <method name="is_item_tooltip_enabled" qualifiers="const"> - <return type="bool"> - </return> - <argument index="0" name="idx" type="int"> - </argument> + <return type="bool" /> + <argument index="0" name="idx" type="int" /> <description> Returns [code]true[/code] if the tooltip is enabled for specified item index. </description> </method> <method name="is_selected" qualifiers="const"> - <return type="bool"> - </return> - <argument index="0" name="idx" type="int"> - </argument> + <return type="bool" /> + <argument index="0" name="idx" type="int" /> <description> Returns [code]true[/code] if the item at the specified index is currently selected. </description> </method> <method name="move_item"> - <return type="void"> - </return> - <argument index="0" name="from_idx" type="int"> - </argument> - <argument index="1" name="to_idx" type="int"> - </argument> + <return type="void" /> + <argument index="0" name="from_idx" type="int" /> + <argument index="1" name="to_idx" type="int" /> <description> Moves item from index [code]from_idx[/code] to [code]to_idx[/code]. </description> </method> <method name="remove_item"> - <return type="void"> - </return> - <argument index="0" name="idx" type="int"> - </argument> + <return type="void" /> + <argument index="0" name="idx" type="int" /> <description> Removes the item specified by [code]idx[/code] index from the list. </description> </method> <method name="select"> - <return type="void"> - </return> - <argument index="0" name="idx" type="int"> - </argument> - <argument index="1" name="single" type="bool" default="true"> - </argument> + <return type="void" /> + <argument index="0" name="idx" type="int" /> + <argument index="1" name="single" type="bool" default="true" /> <description> Select the item at the specified index. [b]Note:[/b] This method does not trigger the item selection signal. </description> </method> <method name="set_item_custom_bg_color"> - <return type="void"> - </return> - <argument index="0" name="idx" type="int"> - </argument> - <argument index="1" name="custom_bg_color" type="Color"> - </argument> + <return type="void" /> + <argument index="0" name="idx" type="int" /> + <argument index="1" name="custom_bg_color" type="Color" /> <description> Sets the background color of the item specified by [code]idx[/code] index to the specified [Color]. </description> </method> <method name="set_item_custom_fg_color"> - <return type="void"> - </return> - <argument index="0" name="idx" type="int"> - </argument> - <argument index="1" name="custom_fg_color" type="Color"> - </argument> + <return type="void" /> + <argument index="0" name="idx" type="int" /> + <argument index="1" name="custom_fg_color" type="Color" /> <description> Sets the foreground color of the item specified by [code]idx[/code] index to the specified [Color]. </description> </method> <method name="set_item_disabled"> - <return type="void"> - </return> - <argument index="0" name="idx" type="int"> - </argument> - <argument index="1" name="disabled" type="bool"> - </argument> + <return type="void" /> + <argument index="0" name="idx" type="int" /> + <argument index="1" name="disabled" type="bool" /> <description> Disables (or enables) the item at the specified index. Disabled items cannot be selected and do not trigger activation signals (when double-clicking or pressing [kbd]Enter[/kbd]). </description> </method> <method name="set_item_icon"> - <return type="void"> - </return> - <argument index="0" name="idx" type="int"> - </argument> - <argument index="1" name="icon" type="Texture2D"> - </argument> + <return type="void" /> + <argument index="0" name="idx" type="int" /> + <argument index="1" name="icon" type="Texture2D" /> <description> Sets (or replaces) the icon's [Texture2D] associated with the specified index. </description> </method> <method name="set_item_icon_modulate"> - <return type="void"> - </return> - <argument index="0" name="idx" type="int"> - </argument> - <argument index="1" name="modulate" type="Color"> - </argument> + <return type="void" /> + <argument index="0" name="idx" type="int" /> + <argument index="1" name="modulate" type="Color" /> <description> Sets a modulating [Color] of the item associated with the specified index. </description> </method> <method name="set_item_icon_region"> - <return type="void"> - </return> - <argument index="0" name="idx" type="int"> - </argument> - <argument index="1" name="rect" type="Rect2"> - </argument> + <return type="void" /> + <argument index="0" name="idx" type="int" /> + <argument index="1" name="rect" type="Rect2" /> <description> Sets the region of item's icon used. The whole icon will be used if the region has no area. </description> </method> <method name="set_item_icon_transposed"> - <return type="void"> - </return> - <argument index="0" name="idx" type="int"> - </argument> - <argument index="1" name="transposed" type="bool"> - </argument> + <return type="void" /> + <argument index="0" name="idx" type="int" /> + <argument index="1" name="transposed" type="bool" /> <description> Sets whether the item icon will be drawn transposed. </description> </method> <method name="set_item_language"> - <return type="void"> - </return> - <argument index="0" name="idx" type="int"> - </argument> - <argument index="1" name="language" type="String"> - </argument> + <return type="void" /> + <argument index="0" name="idx" type="int" /> + <argument index="1" name="language" type="String" /> <description> Sets language code of item's text used for line-breaking and text shaping algorithms, if left empty current locale is used instead. </description> </method> <method name="set_item_metadata"> - <return type="void"> - </return> - <argument index="0" name="idx" type="int"> - </argument> - <argument index="1" name="metadata" type="Variant"> - </argument> + <return type="void" /> + <argument index="0" name="idx" type="int" /> + <argument index="1" name="metadata" type="Variant" /> <description> Sets a value (of any type) to be stored with the item associated with the specified index. </description> </method> <method name="set_item_opentype_feature"> - <return type="void"> - </return> - <argument index="0" name="idx" type="int"> - </argument> - <argument index="1" name="tag" type="String"> - </argument> - <argument index="2" name="value" type="int"> - </argument> + <return type="void" /> + <argument index="0" name="idx" type="int" /> + <argument index="1" name="tag" type="String" /> + <argument index="2" name="value" type="int" /> <description> Sets OpenType feature [code]tag[/code] for the item's text. More info: [url=https://docs.microsoft.com/en-us/typography/opentype/spec/featuretags]OpenType feature tags[/url]. </description> </method> <method name="set_item_selectable"> - <return type="void"> - </return> - <argument index="0" name="idx" type="int"> - </argument> - <argument index="1" name="selectable" type="bool"> - </argument> + <return type="void" /> + <argument index="0" name="idx" type="int" /> + <argument index="1" name="selectable" type="bool" /> <description> Allows or disallows selection of the item associated with the specified index. </description> </method> <method name="set_item_text"> - <return type="void"> - </return> - <argument index="0" name="idx" type="int"> - </argument> - <argument index="1" name="text" type="String"> - </argument> + <return type="void" /> + <argument index="0" name="idx" type="int" /> + <argument index="1" name="text" type="String" /> <description> Sets text of the item associated with the specified index. </description> </method> <method name="set_item_text_direction"> - <return type="void"> - </return> - <argument index="0" name="idx" type="int"> - </argument> - <argument index="1" name="direction" type="int" enum="Control.TextDirection"> - </argument> + <return type="void" /> + <argument index="0" name="idx" type="int" /> + <argument index="1" name="direction" type="int" enum="Control.TextDirection" /> <description> Sets item's text base writing direction. </description> </method> <method name="set_item_tooltip"> - <return type="void"> - </return> - <argument index="0" name="idx" type="int"> - </argument> - <argument index="1" name="tooltip" type="String"> - </argument> + <return type="void" /> + <argument index="0" name="idx" type="int" /> + <argument index="1" name="tooltip" type="String" /> <description> Sets the tooltip hint for the item associated with the specified index. </description> </method> <method name="set_item_tooltip_enabled"> - <return type="void"> - </return> - <argument index="0" name="idx" type="int"> - </argument> - <argument index="1" name="enable" type="bool"> - </argument> + <return type="void" /> + <argument index="0" name="idx" type="int" /> + <argument index="1" name="enable" type="bool" /> <description> Sets whether the tooltip hint is enabled for specified item index. </description> </method> <method name="sort_items_by_text"> - <return type="void"> - </return> + <return type="void" /> <description> Sorts items in the list by their text. </description> @@ -515,17 +406,14 @@ </members> <signals> <signal name="item_activated"> - <argument index="0" name="index" type="int"> - </argument> + <argument index="0" name="index" type="int" /> <description> Triggered when specified list item is activated via double-clicking or by pressing [kbd]Enter[/kbd]. </description> </signal> <signal name="item_rmb_selected"> - <argument index="0" name="index" type="int"> - </argument> - <argument index="1" name="at_position" type="Vector2"> - </argument> + <argument index="0" name="index" type="int" /> + <argument index="1" name="at_position" type="Vector2" /> <description> Triggered when specified list item has been selected via right mouse clicking. The click position is also provided to allow appropriate popup of context menus at the correct location. @@ -533,18 +421,15 @@ </description> </signal> <signal name="item_selected"> - <argument index="0" name="index" type="int"> - </argument> + <argument index="0" name="index" type="int" /> <description> Triggered when specified item has been selected. [member allow_reselect] must be enabled to reselect an item. </description> </signal> <signal name="multi_selected"> - <argument index="0" name="index" type="int"> - </argument> - <argument index="1" name="selected" type="bool"> - </argument> + <argument index="0" name="index" type="int" /> + <argument index="1" name="selected" type="bool" /> <description> Triggered when a multiple selection is altered on a list allowing multiple selection. </description> @@ -555,8 +440,7 @@ </description> </signal> <signal name="rmb_clicked"> - <argument index="0" name="at_position" type="Vector2"> - </argument> + <argument index="0" name="at_position" type="Vector2" /> <description> Triggered when a right mouse click is issued within the rect of the list but on empty space. [member allow_rmb_select] must be enabled. diff --git a/doc/classes/JSON.xml b/doc/classes/JSON.xml index b95aaed143..cee7db08e9 100644 --- a/doc/classes/JSON.xml +++ b/doc/classes/JSON.xml @@ -30,48 +30,38 @@ </tutorials> <methods> <method name="get_data" qualifiers="const"> - <return type="Variant"> - </return> + <return type="Variant" /> <description> Returns the [Variant] containing the data of a successful [method parse]. [b]Note:[/b] It will return [code]Null[/code] if the last call to parse was unsuccessful or [method parse] has not yet been called. </description> </method> <method name="get_error_line" qualifiers="const"> - <return type="int"> - </return> + <return type="int" /> <description> Returns [code]0[/code] if the last call to [method parse] was successful, or the line number where the parse failed. </description> </method> <method name="get_error_message" qualifiers="const"> - <return type="String"> - </return> + <return type="String" /> <description> Returns an empty string if the last call to [method parse] was successful, or the error message if it failed. </description> </method> <method name="parse"> - <return type="int" enum="Error"> - </return> - <argument index="0" name="json_string" type="String"> - </argument> + <return type="int" enum="Error" /> + <argument index="0" name="json_string" type="String" /> <description> Attempts to parse the [code]json_string[/code] provided. Returns an [enum Error]. If the parse was successful, it returns [code]OK[/code] and the result can be retrieved using [method get_data]. If unsuccessful, use [method get_error_line] and [method get_error_message] for identifying the source of the failure. </description> </method> <method name="stringify"> - <return type="String"> - </return> - <argument index="0" name="data" type="Variant"> - </argument> - <argument index="1" name="indent" type="String" default=""""> - </argument> - <argument index="2" name="sort_keys" type="bool" default="true"> - </argument> - <argument index="3" name="full_precision" type="bool" default="false"> - </argument> + <return type="String" /> + <argument index="0" name="data" type="Variant" /> + <argument index="1" name="indent" type="String" default="""" /> + <argument index="2" name="sort_keys" type="bool" default="true" /> + <argument index="3" name="full_precision" type="bool" default="false" /> <description> Converts a [Variant] var to JSON text and returns the result. Useful for serializing data to store or send over the network. [b]Note:[/b] The JSON specification does not define integer or float types, but only a [i]number[/i] type. Therefore, converting a Variant to JSON text will convert all numerical values to [float] types. diff --git a/doc/classes/JSONRPC.xml b/doc/classes/JSONRPC.xml index 1e74159f58..30e99f4a30 100644 --- a/doc/classes/JSONRPC.xml +++ b/doc/classes/JSONRPC.xml @@ -8,74 +8,52 @@ </tutorials> <methods> <method name="make_notification"> - <return type="Dictionary"> - </return> - <argument index="0" name="method" type="String"> - </argument> - <argument index="1" name="params" type="Variant"> - </argument> + <return type="Dictionary" /> + <argument index="0" name="method" type="String" /> + <argument index="1" name="params" type="Variant" /> <description> </description> </method> <method name="make_request"> - <return type="Dictionary"> - </return> - <argument index="0" name="method" type="String"> - </argument> - <argument index="1" name="params" type="Variant"> - </argument> - <argument index="2" name="id" type="Variant"> - </argument> + <return type="Dictionary" /> + <argument index="0" name="method" type="String" /> + <argument index="1" name="params" type="Variant" /> + <argument index="2" name="id" type="Variant" /> <description> </description> </method> <method name="make_response"> - <return type="Dictionary"> - </return> - <argument index="0" name="result" type="Variant"> - </argument> - <argument index="1" name="id" type="Variant"> - </argument> + <return type="Dictionary" /> + <argument index="0" name="result" type="Variant" /> + <argument index="1" name="id" type="Variant" /> <description> </description> </method> <method name="make_response_error" qualifiers="const"> - <return type="Dictionary"> - </return> - <argument index="0" name="code" type="int"> - </argument> - <argument index="1" name="message" type="String"> - </argument> - <argument index="2" name="id" type="Variant" default="null"> - </argument> + <return type="Dictionary" /> + <argument index="0" name="code" type="int" /> + <argument index="1" name="message" type="String" /> + <argument index="2" name="id" type="Variant" default="null" /> <description> </description> </method> <method name="process_action"> - <return type="Variant"> - </return> - <argument index="0" name="action" type="Variant"> - </argument> - <argument index="1" name="recurse" type="bool" default="false"> - </argument> + <return type="Variant" /> + <argument index="0" name="action" type="Variant" /> + <argument index="1" name="recurse" type="bool" default="false" /> <description> </description> </method> <method name="process_string"> - <return type="String"> - </return> - <argument index="0" name="action" type="String"> - </argument> + <return type="String" /> + <argument index="0" name="action" type="String" /> <description> </description> </method> <method name="set_scope"> - <return type="void"> - </return> - <argument index="0" name="scope" type="String"> - </argument> - <argument index="1" name="target" type="Object"> - </argument> + <return type="void" /> + <argument index="0" name="scope" type="String" /> + <argument index="1" name="target" type="Object" /> <description> </description> </method> diff --git a/doc/classes/JavaClassWrapper.xml b/doc/classes/JavaClassWrapper.xml index 7bad336af9..90d988f9bb 100644 --- a/doc/classes/JavaClassWrapper.xml +++ b/doc/classes/JavaClassWrapper.xml @@ -8,10 +8,8 @@ </tutorials> <methods> <method name="wrap"> - <return type="JavaClass"> - </return> - <argument index="0" name="name" type="String"> - </argument> + <return type="JavaClass" /> + <argument index="0" name="name" type="String" /> <description> </description> </method> diff --git a/doc/classes/JavaScript.xml b/doc/classes/JavaScript.xml index c87e637ff5..d68b4492c7 100644 --- a/doc/classes/JavaScript.xml +++ b/doc/classes/JavaScript.xml @@ -12,32 +12,24 @@ </tutorials> <methods> <method name="create_callback"> - <return type="JavaScriptObject"> - </return> - <argument index="0" name="callable" type="Callable"> - </argument> + <return type="JavaScriptObject" /> + <argument index="0" name="callable" type="Callable" /> <description> Creates a reference to a [Callable] that can be used as a callback by JavaScript. The reference must be kept until the callback happens, or it won't be called at all. See [JavaScriptObject] for usage. </description> </method> <method name="create_object" qualifiers="vararg"> - <return type="Variant"> - </return> - <argument index="0" name="object" type="String"> - </argument> + <return type="Variant" /> + <argument index="0" name="object" type="String" /> <description> Creates a new JavaScript object using the [code]new[/code] constructor. The [code]object[/code] must a valid property of the JavaScript [code]window[/code]. See [JavaScriptObject] for usage. </description> </method> <method name="download_buffer"> - <return type="void"> - </return> - <argument index="0" name="buffer" type="PackedByteArray"> - </argument> - <argument index="1" name="name" type="String"> - </argument> - <argument index="2" name="mime" type="String" default=""application/octet-stream""> - </argument> + <return type="void" /> + <argument index="0" name="buffer" type="PackedByteArray" /> + <argument index="1" name="name" type="String" /> + <argument index="2" name="mime" type="String" default=""application/octet-stream"" /> <description> Prompts the user to download a file containing the specified [code]buffer[/code]. The file will have the given [code]name[/code] and [code]mime[/code] type. [b]Note:[/b] The browser may override the [url=https://en.wikipedia.org/wiki/Media_type]MIME type[/url] provided based on the file [code]name[/code]'s extension. @@ -46,22 +38,17 @@ </description> </method> <method name="eval"> - <return type="Variant"> - </return> - <argument index="0" name="code" type="String"> - </argument> - <argument index="1" name="use_global_execution_context" type="bool" default="false"> - </argument> + <return type="Variant" /> + <argument index="0" name="code" type="String" /> + <argument index="1" name="use_global_execution_context" type="bool" default="false" /> <description> Execute the string [code]code[/code] as JavaScript code within the browser window. This is a call to the actual global JavaScript function [code]eval()[/code]. If [code]use_global_execution_context[/code] is [code]true[/code], the code will be evaluated in the global execution context. Otherwise, it is evaluated in the execution context of a function within the engine's runtime environment. </description> </method> <method name="get_interface"> - <return type="JavaScriptObject"> - </return> - <argument index="0" name="interface" type="String"> - </argument> + <return type="JavaScriptObject" /> + <argument index="0" name="interface" type="String" /> <description> Returns an interface to a JavaScript object that can be used by scripts. The [code]interface[/code] must be a valid property of the JavaScript [code]window[/code]. The callback must accept a single [Array] argument, which will contain the JavaScript [code]arguments[/code]. See [JavaScriptObject] for usage. </description> diff --git a/doc/classes/Label.xml b/doc/classes/Label.xml index ca22567ad5..42ee246730 100644 --- a/doc/classes/Label.xml +++ b/doc/classes/Label.xml @@ -4,7 +4,7 @@ Displays plain text in a line or wrapped inside a rectangle. For formatted text, use [RichTextLabel]. </brief_description> <description> - Label displays plain text on the screen. It gives you control over the horizontal and vertical alignment, and can wrap the text inside the node's bounding rectangle. It doesn't support bold, italics or other formatting. For that, use [RichTextLabel] instead. + Label displays plain text on the screen. It gives you control over the horizontal and vertical alignment and can wrap the text inside the node's bounding rectangle. It doesn't support bold, italics, or other formatting. For that, use [RichTextLabel] instead. [b]Note:[/b] Contrarily to most other [Control]s, Label's [member Control.mouse_filter] defaults to [constant Control.MOUSE_FILTER_IGNORE] (i.e. it doesn't react to mouse input events). This implies that a label won't display any configured [member Control.hint_tooltip], unless you change its mouse filter. </description> <tutorials> @@ -12,24 +12,20 @@ </tutorials> <methods> <method name="clear_opentype_features"> - <return type="void"> - </return> + <return type="void" /> <description> Removes all OpenType features. </description> </method> <method name="get_line_count" qualifiers="const"> - <return type="int"> - </return> + <return type="int" /> <description> Returns the amount of lines of text the Label has. </description> </method> <method name="get_line_height" qualifiers="const"> - <return type="int"> - </return> - <argument index="0" name="line" type="int" default="-1"> - </argument> + <return type="int" /> + <argument index="0" name="line" type="int" default="-1" /> <description> Returns the height of the line [code]line[/code]. If [code]line[/code] is set to [code]-1[/code], returns the biggest line height. @@ -37,35 +33,28 @@ </description> </method> <method name="get_opentype_feature" qualifiers="const"> - <return type="int"> - </return> - <argument index="0" name="tag" type="String"> - </argument> + <return type="int" /> + <argument index="0" name="tag" type="String" /> <description> Returns OpenType feature [code]tag[/code]. </description> </method> <method name="get_total_character_count" qualifiers="const"> - <return type="int"> - </return> + <return type="int" /> <description> Returns the total number of printable characters in the text (excluding spaces and newlines). </description> </method> <method name="get_visible_line_count" qualifiers="const"> - <return type="int"> - </return> + <return type="int" /> <description> Returns the number of lines shown. Useful if the [Label]'s height cannot currently display all lines. </description> </method> <method name="set_opentype_feature"> - <return type="void"> - </return> - <argument index="0" name="tag" type="String"> - </argument> - <argument index="1" name="value" type="int"> - </argument> + <return type="void" /> + <argument index="0" name="tag" type="String" /> + <argument index="1" name="value" type="int" /> <description> Returns OpenType feature [code]tag[/code]. More info: [url=https://docs.microsoft.com/en-us/typography/opentype/spec/featuretags]OpenType feature tags[/url]. </description> diff --git a/doc/classes/Light2D.xml b/doc/classes/Light2D.xml index 0e71f29b58..918e8a5c8a 100644 --- a/doc/classes/Light2D.xml +++ b/doc/classes/Light2D.xml @@ -12,16 +12,13 @@ </tutorials> <methods> <method name="get_height" qualifiers="const"> - <return type="float"> - </return> + <return type="float" /> <description> </description> </method> <method name="set_height"> - <return type="void"> - </return> - <argument index="0" name="height" type="float"> - </argument> + <return type="void" /> + <argument index="0" name="height" type="float" /> <description> </description> </method> diff --git a/doc/classes/Light3D.xml b/doc/classes/Light3D.xml index 815d20223d..380e9314d4 100644 --- a/doc/classes/Light3D.xml +++ b/doc/classes/Light3D.xml @@ -12,21 +12,16 @@ </tutorials> <methods> <method name="get_param" qualifiers="const"> - <return type="float"> - </return> - <argument index="0" name="param" type="int" enum="Light3D.Param"> - </argument> + <return type="float" /> + <argument index="0" name="param" type="int" enum="Light3D.Param" /> <description> Returns the value of the specified [enum Light3D.Param] parameter. </description> </method> <method name="set_param"> - <return type="void"> - </return> - <argument index="0" name="param" type="int" enum="Light3D.Param"> - </argument> - <argument index="1" name="value" type="float"> - </argument> + <return type="void" /> + <argument index="0" name="param" type="int" enum="Light3D.Param" /> + <argument index="1" name="value" type="float" /> <description> Sets the value of the specified [enum Light3D.Param] parameter. </description> diff --git a/doc/classes/LightmapGIData.xml b/doc/classes/LightmapGIData.xml index 3a37c6dcb7..c577439c8f 100644 --- a/doc/classes/LightmapGIData.xml +++ b/doc/classes/LightmapGIData.xml @@ -8,50 +8,38 @@ </tutorials> <methods> <method name="add_user"> - <return type="void"> - </return> - <argument index="0" name="path" type="NodePath"> - </argument> - <argument index="1" name="uv_scale" type="Rect2"> - </argument> - <argument index="2" name="slice_index" type="int"> - </argument> - <argument index="3" name="sub_instance" type="int"> - </argument> + <return type="void" /> + <argument index="0" name="path" type="NodePath" /> + <argument index="1" name="uv_scale" type="Rect2" /> + <argument index="2" name="slice_index" type="int" /> + <argument index="3" name="sub_instance" type="int" /> <description> </description> </method> <method name="clear_users"> - <return type="void"> - </return> + <return type="void" /> <description> </description> </method> <method name="get_user_count" qualifiers="const"> - <return type="int"> - </return> + <return type="int" /> <description> </description> </method> <method name="get_user_path" qualifiers="const"> - <return type="NodePath"> - </return> - <argument index="0" name="user_idx" type="int"> - </argument> + <return type="NodePath" /> + <argument index="0" name="user_idx" type="int" /> <description> </description> </method> <method name="is_using_spherical_harmonics" qualifiers="const"> - <return type="bool"> - </return> + <return type="bool" /> <description> </description> </method> <method name="set_uses_spherical_harmonics"> - <return type="void"> - </return> - <argument index="0" name="uses_spherical_harmonics" type="bool"> - </argument> + <return type="void" /> + <argument index="0" name="uses_spherical_harmonics" type="bool" /> <description> </description> </method> diff --git a/doc/classes/Line2D.xml b/doc/classes/Line2D.xml index 587d5833b9..093ba51755 100644 --- a/doc/classes/Line2D.xml +++ b/doc/classes/Line2D.xml @@ -12,56 +12,44 @@ </tutorials> <methods> <method name="add_point"> - <return type="void"> - </return> - <argument index="0" name="position" type="Vector2"> - </argument> - <argument index="1" name="at_position" type="int" default="-1"> - </argument> + <return type="void" /> + <argument index="0" name="position" type="Vector2" /> + <argument index="1" name="at_position" type="int" default="-1" /> <description> Adds a point at the [code]position[/code]. Appends the point at the end of the line. If [code]at_position[/code] is given, the point is inserted before the point number [code]at_position[/code], moving that point (and every point after) after the inserted point. If [code]at_position[/code] is not given, or is an illegal value ([code]at_position < 0[/code] or [code]at_position >= [method get_point_count][/code]), the point will be appended at the end of the point list. </description> </method> <method name="clear_points"> - <return type="void"> - </return> + <return type="void" /> <description> Removes all points from the line. </description> </method> <method name="get_point_count" qualifiers="const"> - <return type="int"> - </return> + <return type="int" /> <description> Returns the Line2D's amount of points. </description> </method> <method name="get_point_position" qualifiers="const"> - <return type="Vector2"> - </return> - <argument index="0" name="i" type="int"> - </argument> + <return type="Vector2" /> + <argument index="0" name="i" type="int" /> <description> Returns point [code]i[/code]'s position. </description> </method> <method name="remove_point"> - <return type="void"> - </return> - <argument index="0" name="i" type="int"> - </argument> + <return type="void" /> + <argument index="0" name="i" type="int" /> <description> Removes the point at index [code]i[/code] from the line. </description> </method> <method name="set_point_position"> - <return type="void"> - </return> - <argument index="0" name="i" type="int"> - </argument> - <argument index="1" name="position" type="Vector2"> - </argument> + <return type="void" /> + <argument index="0" name="i" type="int" /> + <argument index="1" name="position" type="Vector2" /> <description> Overwrites the position in point [code]i[/code] with the supplied [code]position[/code]. </description> diff --git a/doc/classes/LineEdit.xml b/doc/classes/LineEdit.xml index 773f7b1a02..45bb553c9c 100644 --- a/doc/classes/LineEdit.xml +++ b/doc/classes/LineEdit.xml @@ -32,92 +32,80 @@ </tutorials> <methods> <method name="clear"> - <return type="void"> - </return> + <return type="void" /> <description> Erases the [LineEdit]'s [member text]. </description> </method> <method name="clear_opentype_features"> - <return type="void"> - </return> + <return type="void" /> <description> Removes all OpenType features. </description> </method> <method name="delete_char_at_caret"> - <return type="void"> - </return> + <return type="void" /> <description> Deletes one character at the caret's current position (equivalent to pressing [kbd]Delete[/kbd]). </description> </method> <method name="delete_text"> - <return type="void"> - </return> - <argument index="0" name="from_column" type="int"> - </argument> - <argument index="1" name="to_column" type="int"> - </argument> + <return type="void" /> + <argument index="0" name="from_column" type="int" /> + <argument index="1" name="to_column" type="int" /> <description> Deletes a section of the [member text] going from position [code]from_column[/code] to [code]to_column[/code]. Both parameters should be within the text's length. </description> </method> <method name="deselect"> - <return type="void"> - </return> + <return type="void" /> <description> Clears the current selection. </description> </method> <method name="get_menu" qualifiers="const"> - <return type="PopupMenu"> - </return> + <return type="PopupMenu" /> <description> Returns the [PopupMenu] of this [LineEdit]. By default, this menu is displayed when right-clicking on the [LineEdit]. </description> </method> <method name="get_opentype_feature" qualifiers="const"> - <return type="int"> - </return> - <argument index="0" name="tag" type="String"> - </argument> + <return type="int" /> + <argument index="0" name="tag" type="String" /> <description> Returns OpenType feature [code]tag[/code]. </description> </method> <method name="get_scroll_offset" qualifiers="const"> - <return type="int"> - </return> + <return type="int" /> <description> Returns the scroll offset due to [member caret_column], as a number of characters. </description> </method> <method name="insert_text_at_caret"> - <return type="void"> - </return> - <argument index="0" name="text" type="String"> - </argument> + <return type="void" /> + <argument index="0" name="text" type="String" /> <description> Inserts [code]text[/code] at the caret. If the resulting value is longer than [member max_length], nothing happens. </description> </method> + <method name="is_menu_visible" qualifiers="const"> + <return type="bool" /> + <description> + Returns whether the menu is visible. Use this instead of [code]get_menu().visible[/code] to improve performance (so the creation of the menu is avoided). + </description> + </method> <method name="menu_option"> - <return type="void"> - </return> - <argument index="0" name="option" type="int"> - </argument> + <return type="void" /> + <argument index="0" name="option" type="int" /> <description> Executes a given action as defined in the [enum MenuItems] enum. </description> </method> <method name="select"> - <return type="void"> - </return> - <argument index="0" name="from" type="int" default="0"> - </argument> - <argument index="1" name="to" type="int" default="-1"> - </argument> + <return type="void" /> + <argument index="0" name="from" type="int" default="0" /> + <argument index="1" name="to" type="int" default="-1" /> <description> Selects characters inside [LineEdit] between [code]from[/code] and [code]to[/code]. By default, [code]from[/code] is at the beginning and [code]to[/code] at the end. [codeblocks] @@ -137,19 +125,15 @@ </description> </method> <method name="select_all"> - <return type="void"> - </return> + <return type="void" /> <description> Selects the whole [String]. </description> </method> <method name="set_opentype_feature"> - <return type="void"> - </return> - <argument index="0" name="tag" type="String"> - </argument> - <argument index="1" name="value" type="int"> - </argument> + <return type="void" /> + <argument index="0" name="tag" type="String" /> + <argument index="1" name="value" type="int" /> <description> Returns OpenType feature [code]tag[/code]. More info: [url=https://docs.microsoft.com/en-us/typography/opentype/spec/featuretags]OpenType feature tags[/url]. </description> @@ -260,22 +244,19 @@ </members> <signals> <signal name="text_change_rejected"> - <argument index="0" name="rejected_substring" type="String"> - </argument> + <argument index="0" name="rejected_substring" type="String" /> <description> Emitted when appending text that overflows the [member max_length]. The appended text is truncated to fit [member max_length], and the part that couldn't fit is passed as the [code]rejected_substring[/code] argument. </description> </signal> <signal name="text_changed"> - <argument index="0" name="new_text" type="String"> - </argument> + <argument index="0" name="new_text" type="String" /> <description> Emitted when the text changes. </description> </signal> <signal name="text_submitted"> - <argument index="0" name="new_text" type="String"> - </argument> + <argument index="0" name="new_text" type="String" /> <description> Emitted when the user presses [constant KEY_ENTER] on the [LineEdit]. </description> diff --git a/doc/classes/LinkButton.xml b/doc/classes/LinkButton.xml index 51b20cd04d..dbf13fd842 100644 --- a/doc/classes/LinkButton.xml +++ b/doc/classes/LinkButton.xml @@ -11,28 +11,22 @@ </tutorials> <methods> <method name="clear_opentype_features"> - <return type="void"> - </return> + <return type="void" /> <description> Removes all OpenType features. </description> </method> <method name="get_opentype_feature" qualifiers="const"> - <return type="int"> - </return> - <argument index="0" name="tag" type="String"> - </argument> + <return type="int" /> + <argument index="0" name="tag" type="String" /> <description> Returns OpenType feature [code]tag[/code]. </description> </method> <method name="set_opentype_feature"> - <return type="void"> - </return> - <argument index="0" name="tag" type="String"> - </argument> - <argument index="1" name="value" type="int"> - </argument> + <return type="void" /> + <argument index="0" name="tag" type="String" /> + <argument index="1" name="value" type="int" /> <description> Returns OpenType feature [code]tag[/code]. More info: [url=https://docs.microsoft.com/en-us/typography/opentype/spec/featuretags]OpenType feature tags[/url]. </description> diff --git a/doc/classes/Listener3D.xml b/doc/classes/Listener3D.xml index b2fcbe534d..9cc803f241 100644 --- a/doc/classes/Listener3D.xml +++ b/doc/classes/Listener3D.xml @@ -11,30 +11,26 @@ </tutorials> <methods> <method name="clear_current"> - <return type="void"> - </return> + <return type="void" /> <description> Disables the listener to use the current camera's listener instead. </description> </method> <method name="get_listener_transform" qualifiers="const"> - <return type="Transform3D"> - </return> + <return type="Transform3D" /> <description> Returns the listener's global orthonormalized [Transform3D]. </description> </method> <method name="is_current" qualifiers="const"> - <return type="bool"> - </return> + <return type="bool" /> <description> Returns [code]true[/code] if the listener was made current using [method make_current], [code]false[/code] otherwise. [b]Note:[/b] There may be more than one Listener3D marked as "current" in the scene tree, but only the one that was made current last will be used. </description> </method> <method name="make_current"> - <return type="void"> - </return> + <return type="void" /> <description> Enables the listener. This will override the current camera's listener. </description> diff --git a/doc/classes/MainLoop.xml b/doc/classes/MainLoop.xml index 537ecf2b2b..11124a1436 100644 --- a/doc/classes/MainLoop.xml +++ b/doc/classes/MainLoop.xml @@ -45,34 +45,28 @@ </tutorials> <methods> <method name="_finalize" qualifiers="virtual"> - <return type="void"> - </return> + <return type="void" /> <description> Called before the program exits. </description> </method> <method name="_initialize" qualifiers="virtual"> - <return type="void"> - </return> + <return type="void" /> <description> Called once during initialization. </description> </method> <method name="_physics_process" qualifiers="virtual"> - <return type="bool"> - </return> - <argument index="0" name="delta" type="float"> - </argument> + <return type="bool" /> + <argument index="0" name="delta" type="float" /> <description> Called each physics frame with the time since the last physics frame as argument ([code]delta[/code], in seconds). Equivalent to [method Node._physics_process]. If implemented, the method must return a boolean value. [code]true[/code] ends the main loop, while [code]false[/code] lets it proceed to the next frame. </description> </method> <method name="_process" qualifiers="virtual"> - <return type="bool"> - </return> - <argument index="0" name="delta" type="float"> - </argument> + <return type="bool" /> + <argument index="0" name="delta" type="float" /> <description> Called each process (idle) frame with the time since the last process frame as argument (in seconds). Equivalent to [method Node._process]. If implemented, the method must return a boolean value. [code]true[/code] ends the main loop, while [code]false[/code] lets it proceed to the next frame. @@ -81,10 +75,8 @@ </methods> <signals> <signal name="on_request_permissions_result"> - <argument index="0" name="permission" type="String"> - </argument> - <argument index="1" name="granted" type="bool"> - </argument> + <argument index="0" name="permission" type="String" /> + <argument index="1" name="granted" type="bool" /> <description> Emitted when a user responds to a permission request. </description> diff --git a/doc/classes/Marshalls.xml b/doc/classes/Marshalls.xml index 4250ffd700..0f36dd11ca 100644 --- a/doc/classes/Marshalls.xml +++ b/doc/classes/Marshalls.xml @@ -10,60 +10,46 @@ </tutorials> <methods> <method name="base64_to_raw"> - <return type="PackedByteArray"> - </return> - <argument index="0" name="base64_str" type="String"> - </argument> + <return type="PackedByteArray" /> + <argument index="0" name="base64_str" type="String" /> <description> Returns a decoded [PackedByteArray] corresponding to the Base64-encoded string [code]base64_str[/code]. </description> </method> <method name="base64_to_utf8"> - <return type="String"> - </return> - <argument index="0" name="base64_str" type="String"> - </argument> + <return type="String" /> + <argument index="0" name="base64_str" type="String" /> <description> Returns a decoded string corresponding to the Base64-encoded string [code]base64_str[/code]. </description> </method> <method name="base64_to_variant"> - <return type="Variant"> - </return> - <argument index="0" name="base64_str" type="String"> - </argument> - <argument index="1" name="allow_objects" type="bool" default="false"> - </argument> + <return type="Variant" /> + <argument index="0" name="base64_str" type="String" /> + <argument index="1" name="allow_objects" type="bool" default="false" /> <description> Returns a decoded [Variant] corresponding to the Base64-encoded string [code]base64_str[/code]. If [code]allow_objects[/code] is [code]true[/code], decoding objects is allowed. [b]Warning:[/b] Deserialized objects can contain code which gets executed. Do not use this option if the serialized object comes from untrusted sources to avoid potential security threats such as remote code execution. </description> </method> <method name="raw_to_base64"> - <return type="String"> - </return> - <argument index="0" name="array" type="PackedByteArray"> - </argument> + <return type="String" /> + <argument index="0" name="array" type="PackedByteArray" /> <description> Returns a Base64-encoded string of a given [PackedByteArray]. </description> </method> <method name="utf8_to_base64"> - <return type="String"> - </return> - <argument index="0" name="utf8_str" type="String"> - </argument> + <return type="String" /> + <argument index="0" name="utf8_str" type="String" /> <description> Returns a Base64-encoded string of the UTF-8 string [code]utf8_str[/code]. </description> </method> <method name="variant_to_base64"> - <return type="String"> - </return> - <argument index="0" name="variant" type="Variant"> - </argument> - <argument index="1" name="full_objects" type="bool" default="false"> - </argument> + <return type="String" /> + <argument index="0" name="variant" type="Variant" /> + <argument index="1" name="full_objects" type="bool" default="false" /> <description> Returns a Base64-encoded string of the [Variant] [code]variant[/code]. If [code]full_objects[/code] is [code]true[/code], encoding objects is allowed (and can potentially include code). </description> diff --git a/doc/classes/Material.xml b/doc/classes/Material.xml index 0d287a5d1d..a3e98228c6 100644 --- a/doc/classes/Material.xml +++ b/doc/classes/Material.xml @@ -12,8 +12,7 @@ </tutorials> <methods> <method name="inspect_native_shader_code"> - <return type="void"> - </return> + <return type="void" /> <description> </description> </method> diff --git a/doc/classes/MenuButton.xml b/doc/classes/MenuButton.xml index 3b37853d70..2d4df97895 100644 --- a/doc/classes/MenuButton.xml +++ b/doc/classes/MenuButton.xml @@ -12,17 +12,14 @@ </tutorials> <methods> <method name="get_popup" qualifiers="const"> - <return type="PopupMenu"> - </return> + <return type="PopupMenu" /> <description> Returns the [PopupMenu] contained in this button. </description> </method> <method name="set_disable_shortcuts"> - <return type="void"> - </return> - <argument index="0" name="disabled" type="bool"> - </argument> + <return type="void" /> + <argument index="0" name="disabled" type="bool" /> <description> If [code]true[/code], shortcuts are disabled and cannot be used to trigger the button. </description> diff --git a/doc/classes/Mesh.xml b/doc/classes/Mesh.xml index 2cc0bd2ef9..bfa55c2d35 100644 --- a/doc/classes/Mesh.xml +++ b/doc/classes/Mesh.xml @@ -14,12 +14,9 @@ </tutorials> <methods> <method name="create_convex_shape" qualifiers="const"> - <return type="Shape3D"> - </return> - <argument index="0" name="clean" type="bool" default="true"> - </argument> - <argument index="1" name="simplify" type="bool" default="false"> - </argument> + <return type="Shape3D" /> + <argument index="0" name="clean" type="bool" default="true" /> + <argument index="1" name="simplify" type="bool" default="false" /> <description> Calculate a [ConvexPolygonShape3D] from the mesh. If [code]clean[/code] is [code]true[/code] (default), duplicate and interior vertices are removed automatically. You can set it to [code]false[/code] to make the process faster if not needed. @@ -27,85 +24,69 @@ </description> </method> <method name="create_outline" qualifiers="const"> - <return type="Mesh"> - </return> - <argument index="0" name="margin" type="float"> - </argument> + <return type="Mesh" /> + <argument index="0" name="margin" type="float" /> <description> Calculate an outline mesh at a defined offset (margin) from the original mesh. [b]Note:[/b] This method typically returns the vertices in reverse order (e.g. clockwise to counterclockwise). </description> </method> <method name="create_trimesh_shape" qualifiers="const"> - <return type="Shape3D"> - </return> + <return type="Shape3D" /> <description> Calculate a [ConcavePolygonShape3D] from the mesh. </description> </method> <method name="generate_triangle_mesh" qualifiers="const"> - <return type="TriangleMesh"> - </return> + <return type="TriangleMesh" /> <description> Generate a [TriangleMesh] from the mesh. </description> </method> <method name="get_aabb" qualifiers="const"> - <return type="AABB"> - </return> + <return type="AABB" /> <description> Returns the smallest [AABB] enclosing this mesh in local space. Not affected by [code]custom_aabb[/code]. See also [method VisualInstance3D.get_transformed_aabb]. [b]Note:[/b] This is only implemented for [ArrayMesh] and [PrimitiveMesh]. </description> </method> <method name="get_faces" qualifiers="const"> - <return type="PackedVector3Array"> - </return> + <return type="PackedVector3Array" /> <description> Returns all the vertices that make up the faces of the mesh. Each three vertices represent one triangle. </description> </method> <method name="get_surface_count" qualifiers="const"> - <return type="int"> - </return> + <return type="int" /> <description> Returns the amount of surfaces that the [Mesh] holds. </description> </method> <method name="surface_get_arrays" qualifiers="const"> - <return type="Array"> - </return> - <argument index="0" name="surf_idx" type="int"> - </argument> + <return type="Array" /> + <argument index="0" name="surf_idx" type="int" /> <description> Returns the arrays for the vertices, normals, uvs, etc. that make up the requested surface (see [method ArrayMesh.add_surface_from_arrays]). </description> </method> <method name="surface_get_blend_shape_arrays" qualifiers="const"> - <return type="Array"> - </return> - <argument index="0" name="surf_idx" type="int"> - </argument> + <return type="Array" /> + <argument index="0" name="surf_idx" type="int" /> <description> Returns the blend shape arrays for the requested surface. </description> </method> <method name="surface_get_material" qualifiers="const"> - <return type="Material"> - </return> - <argument index="0" name="surf_idx" type="int"> - </argument> + <return type="Material" /> + <argument index="0" name="surf_idx" type="int" /> <description> Returns a [Material] in a given surface. Surface is rendered using this material. </description> </method> <method name="surface_set_material"> - <return type="void"> - </return> - <argument index="0" name="surf_idx" type="int"> - </argument> - <argument index="1" name="material" type="Material"> - </argument> + <return type="void" /> + <argument index="0" name="surf_idx" type="int" /> + <argument index="1" name="material" type="Material" /> <description> Sets a [Material] for a given surface. Surface will be rendered using this material. </description> diff --git a/doc/classes/MeshDataTool.xml b/doc/classes/MeshDataTool.xml index c0ee1e1956..338deed0be 100644 --- a/doc/classes/MeshDataTool.xml +++ b/doc/classes/MeshDataTool.xml @@ -52,366 +52,281 @@ </tutorials> <methods> <method name="clear"> - <return type="void"> - </return> + <return type="void" /> <description> Clears all data currently in MeshDataTool. </description> </method> <method name="commit_to_surface"> - <return type="int" enum="Error"> - </return> - <argument index="0" name="mesh" type="ArrayMesh"> - </argument> + <return type="int" enum="Error" /> + <argument index="0" name="mesh" type="ArrayMesh" /> <description> Adds a new surface to specified [Mesh] with edited data. </description> </method> <method name="create_from_surface"> - <return type="int" enum="Error"> - </return> - <argument index="0" name="mesh" type="ArrayMesh"> - </argument> - <argument index="1" name="surface" type="int"> - </argument> + <return type="int" enum="Error" /> + <argument index="0" name="mesh" type="ArrayMesh" /> + <argument index="1" name="surface" type="int" /> <description> Uses specified surface of given [Mesh] to populate data for MeshDataTool. Requires [Mesh] with primitive type [constant Mesh.PRIMITIVE_TRIANGLES]. </description> </method> <method name="get_edge_count" qualifiers="const"> - <return type="int"> - </return> + <return type="int" /> <description> Returns the number of edges in this [Mesh]. </description> </method> <method name="get_edge_faces" qualifiers="const"> - <return type="PackedInt32Array"> - </return> - <argument index="0" name="idx" type="int"> - </argument> + <return type="PackedInt32Array" /> + <argument index="0" name="idx" type="int" /> <description> Returns array of faces that touch given edge. </description> </method> <method name="get_edge_meta" qualifiers="const"> - <return type="Variant"> - </return> - <argument index="0" name="idx" type="int"> - </argument> + <return type="Variant" /> + <argument index="0" name="idx" type="int" /> <description> Returns meta information assigned to given edge. </description> </method> <method name="get_edge_vertex" qualifiers="const"> - <return type="int"> - </return> - <argument index="0" name="idx" type="int"> - </argument> - <argument index="1" name="vertex" type="int"> - </argument> + <return type="int" /> + <argument index="0" name="idx" type="int" /> + <argument index="1" name="vertex" type="int" /> <description> Returns index of specified vertex connected to given edge. Vertex argument can only be 0 or 1 because edges are comprised of two vertices. </description> </method> <method name="get_face_count" qualifiers="const"> - <return type="int"> - </return> + <return type="int" /> <description> Returns the number of faces in this [Mesh]. </description> </method> <method name="get_face_edge" qualifiers="const"> - <return type="int"> - </return> - <argument index="0" name="idx" type="int"> - </argument> - <argument index="1" name="edge" type="int"> - </argument> + <return type="int" /> + <argument index="0" name="idx" type="int" /> + <argument index="1" name="edge" type="int" /> <description> Returns specified edge associated with given face. Edge argument must 2 or less because a face only has three edges. </description> </method> <method name="get_face_meta" qualifiers="const"> - <return type="Variant"> - </return> - <argument index="0" name="idx" type="int"> - </argument> + <return type="Variant" /> + <argument index="0" name="idx" type="int" /> <description> Returns the metadata associated with the given face. </description> </method> <method name="get_face_normal" qualifiers="const"> - <return type="Vector3"> - </return> - <argument index="0" name="idx" type="int"> - </argument> + <return type="Vector3" /> + <argument index="0" name="idx" type="int" /> <description> Calculates and returns the face normal of the given face. </description> </method> <method name="get_face_vertex" qualifiers="const"> - <return type="int"> - </return> - <argument index="0" name="idx" type="int"> - </argument> - <argument index="1" name="vertex" type="int"> - </argument> + <return type="int" /> + <argument index="0" name="idx" type="int" /> + <argument index="1" name="vertex" type="int" /> <description> Returns the specified vertex of the given face. Vertex argument must be 2 or less because faces contain three vertices. </description> </method> <method name="get_format" qualifiers="const"> - <return type="int"> - </return> + <return type="int" /> <description> Returns the [Mesh]'s format. Format is an integer made up of [Mesh] format flags combined together. For example, a mesh containing both vertices and normals would return a format of [code]3[/code] because [constant Mesh.ARRAY_FORMAT_VERTEX] is [code]1[/code] and [constant Mesh.ARRAY_FORMAT_NORMAL] is [code]2[/code]. See [enum Mesh.ArrayFormat] for a list of format flags. </description> </method> <method name="get_material" qualifiers="const"> - <return type="Material"> - </return> + <return type="Material" /> <description> Returns the material assigned to the [Mesh]. </description> </method> <method name="get_vertex" qualifiers="const"> - <return type="Vector3"> - </return> - <argument index="0" name="idx" type="int"> - </argument> + <return type="Vector3" /> + <argument index="0" name="idx" type="int" /> <description> Returns the vertex at given index. </description> </method> <method name="get_vertex_bones" qualifiers="const"> - <return type="PackedInt32Array"> - </return> - <argument index="0" name="idx" type="int"> - </argument> + <return type="PackedInt32Array" /> + <argument index="0" name="idx" type="int" /> <description> Returns the bones of the given vertex. </description> </method> <method name="get_vertex_color" qualifiers="const"> - <return type="Color"> - </return> - <argument index="0" name="idx" type="int"> - </argument> + <return type="Color" /> + <argument index="0" name="idx" type="int" /> <description> Returns the color of the given vertex. </description> </method> <method name="get_vertex_count" qualifiers="const"> - <return type="int"> - </return> + <return type="int" /> <description> Returns the total number of vertices in [Mesh]. </description> </method> <method name="get_vertex_edges" qualifiers="const"> - <return type="PackedInt32Array"> - </return> - <argument index="0" name="idx" type="int"> - </argument> + <return type="PackedInt32Array" /> + <argument index="0" name="idx" type="int" /> <description> Returns an array of edges that share the given vertex. </description> </method> <method name="get_vertex_faces" qualifiers="const"> - <return type="PackedInt32Array"> - </return> - <argument index="0" name="idx" type="int"> - </argument> + <return type="PackedInt32Array" /> + <argument index="0" name="idx" type="int" /> <description> Returns an array of faces that share the given vertex. </description> </method> <method name="get_vertex_meta" qualifiers="const"> - <return type="Variant"> - </return> - <argument index="0" name="idx" type="int"> - </argument> + <return type="Variant" /> + <argument index="0" name="idx" type="int" /> <description> Returns the metadata associated with the given vertex. </description> </method> <method name="get_vertex_normal" qualifiers="const"> - <return type="Vector3"> - </return> - <argument index="0" name="idx" type="int"> - </argument> + <return type="Vector3" /> + <argument index="0" name="idx" type="int" /> <description> Returns the normal of the given vertex. </description> </method> <method name="get_vertex_tangent" qualifiers="const"> - <return type="Plane"> - </return> - <argument index="0" name="idx" type="int"> - </argument> + <return type="Plane" /> + <argument index="0" name="idx" type="int" /> <description> Returns the tangent of the given vertex. </description> </method> <method name="get_vertex_uv" qualifiers="const"> - <return type="Vector2"> - </return> - <argument index="0" name="idx" type="int"> - </argument> + <return type="Vector2" /> + <argument index="0" name="idx" type="int" /> <description> Returns the UV of the given vertex. </description> </method> <method name="get_vertex_uv2" qualifiers="const"> - <return type="Vector2"> - </return> - <argument index="0" name="idx" type="int"> - </argument> + <return type="Vector2" /> + <argument index="0" name="idx" type="int" /> <description> Returns the UV2 of the given vertex. </description> </method> <method name="get_vertex_weights" qualifiers="const"> - <return type="PackedFloat32Array"> - </return> - <argument index="0" name="idx" type="int"> - </argument> + <return type="PackedFloat32Array" /> + <argument index="0" name="idx" type="int" /> <description> Returns bone weights of the given vertex. </description> </method> <method name="set_edge_meta"> - <return type="void"> - </return> - <argument index="0" name="idx" type="int"> - </argument> - <argument index="1" name="meta" type="Variant"> - </argument> + <return type="void" /> + <argument index="0" name="idx" type="int" /> + <argument index="1" name="meta" type="Variant" /> <description> Sets the metadata of the given edge. </description> </method> <method name="set_face_meta"> - <return type="void"> - </return> - <argument index="0" name="idx" type="int"> - </argument> - <argument index="1" name="meta" type="Variant"> - </argument> + <return type="void" /> + <argument index="0" name="idx" type="int" /> + <argument index="1" name="meta" type="Variant" /> <description> Sets the metadata of the given face. </description> </method> <method name="set_material"> - <return type="void"> - </return> - <argument index="0" name="material" type="Material"> - </argument> + <return type="void" /> + <argument index="0" name="material" type="Material" /> <description> Sets the material to be used by newly-constructed [Mesh]. </description> </method> <method name="set_vertex"> - <return type="void"> - </return> - <argument index="0" name="idx" type="int"> - </argument> - <argument index="1" name="vertex" type="Vector3"> - </argument> + <return type="void" /> + <argument index="0" name="idx" type="int" /> + <argument index="1" name="vertex" type="Vector3" /> <description> Sets the position of the given vertex. </description> </method> <method name="set_vertex_bones"> - <return type="void"> - </return> - <argument index="0" name="idx" type="int"> - </argument> - <argument index="1" name="bones" type="PackedInt32Array"> - </argument> + <return type="void" /> + <argument index="0" name="idx" type="int" /> + <argument index="1" name="bones" type="PackedInt32Array" /> <description> Sets the bones of the given vertex. </description> </method> <method name="set_vertex_color"> - <return type="void"> - </return> - <argument index="0" name="idx" type="int"> - </argument> - <argument index="1" name="color" type="Color"> - </argument> + <return type="void" /> + <argument index="0" name="idx" type="int" /> + <argument index="1" name="color" type="Color" /> <description> Sets the color of the given vertex. </description> </method> <method name="set_vertex_meta"> - <return type="void"> - </return> - <argument index="0" name="idx" type="int"> - </argument> - <argument index="1" name="meta" type="Variant"> - </argument> + <return type="void" /> + <argument index="0" name="idx" type="int" /> + <argument index="1" name="meta" type="Variant" /> <description> Sets the metadata associated with the given vertex. </description> </method> <method name="set_vertex_normal"> - <return type="void"> - </return> - <argument index="0" name="idx" type="int"> - </argument> - <argument index="1" name="normal" type="Vector3"> - </argument> + <return type="void" /> + <argument index="0" name="idx" type="int" /> + <argument index="1" name="normal" type="Vector3" /> <description> Sets the normal of the given vertex. </description> </method> <method name="set_vertex_tangent"> - <return type="void"> - </return> - <argument index="0" name="idx" type="int"> - </argument> - <argument index="1" name="tangent" type="Plane"> - </argument> + <return type="void" /> + <argument index="0" name="idx" type="int" /> + <argument index="1" name="tangent" type="Plane" /> <description> Sets the tangent of the given vertex. </description> </method> <method name="set_vertex_uv"> - <return type="void"> - </return> - <argument index="0" name="idx" type="int"> - </argument> - <argument index="1" name="uv" type="Vector2"> - </argument> + <return type="void" /> + <argument index="0" name="idx" type="int" /> + <argument index="1" name="uv" type="Vector2" /> <description> Sets the UV of the given vertex. </description> </method> <method name="set_vertex_uv2"> - <return type="void"> - </return> - <argument index="0" name="idx" type="int"> - </argument> - <argument index="1" name="uv2" type="Vector2"> - </argument> + <return type="void" /> + <argument index="0" name="idx" type="int" /> + <argument index="1" name="uv2" type="Vector2" /> <description> Sets the UV2 of the given vertex. </description> </method> <method name="set_vertex_weights"> - <return type="void"> - </return> - <argument index="0" name="idx" type="int"> - </argument> - <argument index="1" name="weights" type="PackedFloat32Array"> - </argument> + <return type="void" /> + <argument index="0" name="idx" type="int" /> + <argument index="1" name="weights" type="PackedFloat32Array" /> <description> Sets the bone weights of the given vertex. </description> diff --git a/doc/classes/MeshInstance3D.xml b/doc/classes/MeshInstance3D.xml index 930301a742..665d5d3c77 100644 --- a/doc/classes/MeshInstance3D.xml +++ b/doc/classes/MeshInstance3D.xml @@ -14,12 +14,9 @@ </tutorials> <methods> <method name="create_convex_collision"> - <return type="void"> - </return> - <argument index="0" name="clean" type="bool" default="true"> - </argument> - <argument index="1" name="simplify" type="bool" default="false"> - </argument> + <return type="void" /> + <argument index="0" name="clean" type="bool" default="true" /> + <argument index="1" name="simplify" type="bool" default="false" /> <description> This helper creates a [StaticBody3D] child node with a [ConvexPolygonShape3D] collision shape calculated from the mesh geometry. It's mainly used for testing. If [code]clean[/code] is [code]true[/code] (default), duplicate and interior vertices are removed automatically. You can set it to [code]false[/code] to make the process faster if not needed. @@ -27,58 +24,47 @@ </description> </method> <method name="create_debug_tangents"> - <return type="void"> - </return> + <return type="void" /> <description> This helper creates a [MeshInstance3D] child node with gizmos at every vertex calculated from the mesh geometry. It's mainly used for testing. </description> </method> <method name="create_multiple_convex_collisions"> - <return type="void"> - </return> + <return type="void" /> <description> This helper creates a [StaticBody3D] child node with multiple [ConvexPolygonShape3D] collision shapes calculated from the mesh geometry via convex decomposition. It's mainly used for testing. </description> </method> <method name="create_trimesh_collision"> - <return type="void"> - </return> + <return type="void" /> <description> This helper creates a [StaticBody3D] child node with a [ConcavePolygonShape3D] collision shape calculated from the mesh geometry. It's mainly used for testing. </description> </method> <method name="get_active_material" qualifiers="const"> - <return type="Material"> - </return> - <argument index="0" name="surface" type="int"> - </argument> + <return type="Material" /> + <argument index="0" name="surface" type="int" /> <description> Returns the [Material] that will be used by the [Mesh] when drawing. This can return the [member GeometryInstance3D.material_override], the surface override [Material] defined in this [MeshInstance3D], or the surface [Material] defined in the [Mesh]. For example, if [member GeometryInstance3D.material_override] is used, all surfaces will return the override material. </description> </method> <method name="get_surface_override_material" qualifiers="const"> - <return type="Material"> - </return> - <argument index="0" name="surface" type="int"> - </argument> + <return type="Material" /> + <argument index="0" name="surface" type="int" /> <description> Returns the override [Material] for the specified surface of the [Mesh] resource. </description> </method> <method name="get_surface_override_material_count" qualifiers="const"> - <return type="int"> - </return> + <return type="int" /> <description> Returns the number of surface override materials. This is equivalent to [method Mesh.get_surface_count]. </description> </method> <method name="set_surface_override_material"> - <return type="void"> - </return> - <argument index="0" name="surface" type="int"> - </argument> - <argument index="1" name="material" type="Material"> - </argument> + <return type="void" /> + <argument index="0" name="surface" type="int" /> + <argument index="1" name="material" type="Material" /> <description> Sets the override [Material] for the specified surface of the [Mesh] resource. This material is associated with this [MeshInstance3D] rather than with the [Mesh] resource. </description> diff --git a/doc/classes/MeshLibrary.xml b/doc/classes/MeshLibrary.xml index b33bcc89e3..9e0292f946 100644 --- a/doc/classes/MeshLibrary.xml +++ b/doc/classes/MeshLibrary.xml @@ -12,172 +12,133 @@ </tutorials> <methods> <method name="clear"> - <return type="void"> - </return> + <return type="void" /> <description> Clears the library. </description> </method> <method name="create_item"> - <return type="void"> - </return> - <argument index="0" name="id" type="int"> - </argument> + <return type="void" /> + <argument index="0" name="id" type="int" /> <description> Creates a new item in the library with the given ID. You can get an unused ID from [method get_last_unused_item_id]. </description> </method> <method name="find_item_by_name" qualifiers="const"> - <return type="int"> - </return> - <argument index="0" name="name" type="String"> - </argument> + <return type="int" /> + <argument index="0" name="name" type="String" /> <description> Returns the first item with the given name. </description> </method> <method name="get_item_list" qualifiers="const"> - <return type="PackedInt32Array"> - </return> + <return type="PackedInt32Array" /> <description> Returns the list of item IDs in use. </description> </method> <method name="get_item_mesh" qualifiers="const"> - <return type="Mesh"> - </return> - <argument index="0" name="id" type="int"> - </argument> + <return type="Mesh" /> + <argument index="0" name="id" type="int" /> <description> Returns the item's mesh. </description> </method> <method name="get_item_name" qualifiers="const"> - <return type="String"> - </return> - <argument index="0" name="id" type="int"> - </argument> + <return type="String" /> + <argument index="0" name="id" type="int" /> <description> Returns the item's name. </description> </method> <method name="get_item_navmesh" qualifiers="const"> - <return type="NavigationMesh"> - </return> - <argument index="0" name="id" type="int"> - </argument> + <return type="NavigationMesh" /> + <argument index="0" name="id" type="int" /> <description> Returns the item's navigation mesh. </description> </method> <method name="get_item_navmesh_transform" qualifiers="const"> - <return type="Transform3D"> - </return> - <argument index="0" name="id" type="int"> - </argument> + <return type="Transform3D" /> + <argument index="0" name="id" type="int" /> <description> Returns the transform applied to the item's navigation mesh. </description> </method> <method name="get_item_preview" qualifiers="const"> - <return type="Texture2D"> - </return> - <argument index="0" name="id" type="int"> - </argument> + <return type="Texture2D" /> + <argument index="0" name="id" type="int" /> <description> When running in the editor, returns a generated item preview (a 3D rendering in isometric perspective). When used in a running project, returns the manually-defined item preview which can be set using [method set_item_preview]. Returns an empty [Texture2D] if no preview was manually set in a running project. </description> </method> <method name="get_item_shapes" qualifiers="const"> - <return type="Array"> - </return> - <argument index="0" name="id" type="int"> - </argument> + <return type="Array" /> + <argument index="0" name="id" type="int" /> <description> Returns an item's collision shapes. The array consists of each [Shape3D] followed by its [Transform3D]. </description> </method> <method name="get_last_unused_item_id" qualifiers="const"> - <return type="int"> - </return> + <return type="int" /> <description> Gets an unused ID for a new item. </description> </method> <method name="remove_item"> - <return type="void"> - </return> - <argument index="0" name="id" type="int"> - </argument> + <return type="void" /> + <argument index="0" name="id" type="int" /> <description> Removes the item. </description> </method> <method name="set_item_mesh"> - <return type="void"> - </return> - <argument index="0" name="id" type="int"> - </argument> - <argument index="1" name="mesh" type="Mesh"> - </argument> + <return type="void" /> + <argument index="0" name="id" type="int" /> + <argument index="1" name="mesh" type="Mesh" /> <description> Sets the item's mesh. </description> </method> <method name="set_item_name"> - <return type="void"> - </return> - <argument index="0" name="id" type="int"> - </argument> - <argument index="1" name="name" type="String"> - </argument> + <return type="void" /> + <argument index="0" name="id" type="int" /> + <argument index="1" name="name" type="String" /> <description> Sets the item's name. This name is shown in the editor. It can also be used to look up the item later using [method find_item_by_name]. </description> </method> <method name="set_item_navmesh"> - <return type="void"> - </return> - <argument index="0" name="id" type="int"> - </argument> - <argument index="1" name="navmesh" type="NavigationMesh"> - </argument> + <return type="void" /> + <argument index="0" name="id" type="int" /> + <argument index="1" name="navmesh" type="NavigationMesh" /> <description> Sets the item's navigation mesh. </description> </method> <method name="set_item_navmesh_transform"> - <return type="void"> - </return> - <argument index="0" name="id" type="int"> - </argument> - <argument index="1" name="navmesh" type="Transform3D"> - </argument> + <return type="void" /> + <argument index="0" name="id" type="int" /> + <argument index="1" name="navmesh" type="Transform3D" /> <description> Sets the transform to apply to the item's navigation mesh. </description> </method> <method name="set_item_preview"> - <return type="void"> - </return> - <argument index="0" name="id" type="int"> - </argument> - <argument index="1" name="texture" type="Texture2D"> - </argument> + <return type="void" /> + <argument index="0" name="id" type="int" /> + <argument index="1" name="texture" type="Texture2D" /> <description> Sets a texture to use as the item's preview icon in the editor. </description> </method> <method name="set_item_shapes"> - <return type="void"> - </return> - <argument index="0" name="id" type="int"> - </argument> - <argument index="1" name="shapes" type="Array"> - </argument> + <return type="void" /> + <argument index="0" name="id" type="int" /> + <argument index="1" name="shapes" type="Array" /> <description> Sets an item's collision shapes. The array should consist of [Shape3D] objects, each followed by a [Transform3D] that will be applied to it. For shapes that should not have a transform, use [constant Transform3D.IDENTITY]. diff --git a/doc/classes/MethodTweener.xml b/doc/classes/MethodTweener.xml index 42b91abf93..1b93b20d9f 100644 --- a/doc/classes/MethodTweener.xml +++ b/doc/classes/MethodTweener.xml @@ -4,35 +4,29 @@ Interpolates an abstract value and supplies it to a method called over time. </brief_description> <description> - [MethodTweener] is similar to a combination of [CallbackTweener] and [PropertyTweener]. It calls a method providing an interpolated value as a paramater. See [method Tween.tween_method] for more usage information. + [MethodTweener] is similar to a combination of [CallbackTweener] and [PropertyTweener]. It calls a method providing an interpolated value as a parameter. See [method Tween.tween_method] for more usage information. [b]Note:[/b] [method Tween.tween_method] is the only correct way to create [MethodTweener]. Any [MethodTweener] created manually will not function correctly. </description> <tutorials> </tutorials> <methods> <method name="set_delay"> - <return type="MethodTweener"> - </return> - <argument index="0" name="delay" type="float"> - </argument> + <return type="MethodTweener" /> + <argument index="0" name="delay" type="float" /> <description> Sets the time in seconds after which the [MethodTweener] will start interpolating. By default there's no delay. </description> </method> <method name="set_ease"> - <return type="MethodTweener"> - </return> - <argument index="0" name="ease" type="int" enum="Tween.EaseType"> - </argument> + <return type="MethodTweener" /> + <argument index="0" name="ease" type="int" enum="Tween.EaseType" /> <description> Sets the type of used easing from [enum Tween.EaseType]. If not set, the default easing is used from the [Tween] that contains this Tweener. </description> </method> <method name="set_trans"> - <return type="MethodTweener"> - </return> - <argument index="0" name="trans" type="int" enum="Tween.TransitionType"> - </argument> + <return type="MethodTweener" /> + <argument index="0" name="trans" type="int" enum="Tween.TransitionType" /> <description> Sets the type of used transition from [enum Tween.TransitionType]. If not set, the default transition is used from the [Tween] that contains this Tweener. </description> diff --git a/doc/classes/MultiMesh.xml b/doc/classes/MultiMesh.xml index 7151e58c5f..7b4a53a810 100644 --- a/doc/classes/MultiMesh.xml +++ b/doc/classes/MultiMesh.xml @@ -6,7 +6,7 @@ <description> MultiMesh provides low-level mesh instancing. Drawing thousands of [MeshInstance3D] nodes can be slow, since each object is submitted to the GPU then drawn individually. MultiMesh is much faster as it can draw thousands of instances with a single draw call, resulting in less API overhead. - As a drawback, if the instances are too far away of each other, performance may be reduced as every single instance will always render (they are spatially indexed as one, for the whole object). + As a drawback, if the instances are too far away from each other, performance may be reduced as every single instance will always render (they are spatially indexed as one, for the whole object). Since instances may have any behavior, the AABB used for visibility must be provided by the user. </description> <tutorials> @@ -15,90 +15,69 @@ </tutorials> <methods> <method name="get_aabb" qualifiers="const"> - <return type="AABB"> - </return> + <return type="AABB" /> <description> Returns the visibility axis-aligned bounding box in local space. See also [method VisualInstance3D.get_transformed_aabb]. </description> </method> <method name="get_instance_color" qualifiers="const"> - <return type="Color"> - </return> - <argument index="0" name="instance" type="int"> - </argument> + <return type="Color" /> + <argument index="0" name="instance" type="int" /> <description> Gets a specific instance's color. </description> </method> <method name="get_instance_custom_data" qualifiers="const"> - <return type="Color"> - </return> - <argument index="0" name="instance" type="int"> - </argument> + <return type="Color" /> + <argument index="0" name="instance" type="int" /> <description> Returns the custom data that has been set for a specific instance. </description> </method> <method name="get_instance_transform" qualifiers="const"> - <return type="Transform3D"> - </return> - <argument index="0" name="instance" type="int"> - </argument> + <return type="Transform3D" /> + <argument index="0" name="instance" type="int" /> <description> Returns the [Transform3D] of a specific instance. </description> </method> <method name="get_instance_transform_2d" qualifiers="const"> - <return type="Transform2D"> - </return> - <argument index="0" name="instance" type="int"> - </argument> + <return type="Transform2D" /> + <argument index="0" name="instance" type="int" /> <description> Returns the [Transform2D] of a specific instance. </description> </method> <method name="set_instance_color"> - <return type="void"> - </return> - <argument index="0" name="instance" type="int"> - </argument> - <argument index="1" name="color" type="Color"> - </argument> + <return type="void" /> + <argument index="0" name="instance" type="int" /> + <argument index="1" name="color" type="Color" /> <description> Sets the color of a specific instance by [i]multiplying[/i] the mesh's existing vertex colors. For the color to take effect, ensure that [member use_colors] is [code]true[/code] on the [MultiMesh] and [member BaseMaterial3D.vertex_color_use_as_albedo] is [code]true[/code] on the material. </description> </method> <method name="set_instance_custom_data"> - <return type="void"> - </return> - <argument index="0" name="instance" type="int"> - </argument> - <argument index="1" name="custom_data" type="Color"> - </argument> + <return type="void" /> + <argument index="0" name="instance" type="int" /> + <argument index="1" name="custom_data" type="Color" /> <description> Sets custom data for a specific instance. Although [Color] is used, it is just a container for 4 floating point numbers. For the custom data to be used, ensure that [member use_custom_data] is [code]true[/code]. </description> </method> <method name="set_instance_transform"> - <return type="void"> - </return> - <argument index="0" name="instance" type="int"> - </argument> - <argument index="1" name="transform" type="Transform3D"> - </argument> + <return type="void" /> + <argument index="0" name="instance" type="int" /> + <argument index="1" name="transform" type="Transform3D" /> <description> Sets the [Transform3D] for a specific instance. </description> </method> <method name="set_instance_transform_2d"> - <return type="void"> - </return> - <argument index="0" name="instance" type="int"> - </argument> - <argument index="1" name="transform" type="Transform2D"> - </argument> + <return type="void" /> + <argument index="0" name="instance" type="int" /> + <argument index="1" name="transform" type="Transform2D" /> <description> Sets the [Transform2D] for a specific instance. </description> diff --git a/doc/classes/MultiplayerAPI.xml b/doc/classes/MultiplayerAPI.xml index c4d8a5b1b9..104f649921 100644 --- a/doc/classes/MultiplayerAPI.xml +++ b/doc/classes/MultiplayerAPI.xml @@ -13,65 +13,54 @@ </tutorials> <methods> <method name="clear"> - <return type="void"> - </return> + <return type="void" /> <description> Clears the current MultiplayerAPI network state (you shouldn't call this unless you know what you are doing). </description> </method> <method name="get_network_connected_peers" qualifiers="const"> - <return type="PackedInt32Array"> - </return> + <return type="PackedInt32Array" /> <description> Returns the peer IDs of all connected peers of this MultiplayerAPI's [member network_peer]. </description> </method> <method name="get_network_unique_id" qualifiers="const"> - <return type="int"> - </return> + <return type="int" /> <description> Returns the unique peer ID of this MultiplayerAPI's [member network_peer]. </description> </method> <method name="get_rpc_sender_id" qualifiers="const"> - <return type="int"> - </return> + <return type="int" /> <description> Returns the sender's peer ID for the RPC currently being executed. [b]Note:[/b] If not inside an RPC this method will return 0. </description> </method> <method name="has_network_peer" qualifiers="const"> - <return type="bool"> - </return> + <return type="bool" /> <description> Returns [code]true[/code] if there is a [member network_peer] set. </description> </method> <method name="is_network_server" qualifiers="const"> - <return type="bool"> - </return> + <return type="bool" /> <description> Returns [code]true[/code] if this MultiplayerAPI's [member network_peer] is in server mode (listening for connections). </description> </method> <method name="poll"> - <return type="void"> - </return> + <return type="void" /> <description> Method used for polling the MultiplayerAPI. You only need to worry about this if you are using [member Node.custom_multiplayer] override or you set [member SceneTree.multiplayer_poll] to [code]false[/code]. By default, [SceneTree] will poll its MultiplayerAPI for you. [b]Note:[/b] This method results in RPCs and RSETs being called, so they will be executed in the same context of this function (e.g. [code]_process[/code], [code]physics[/code], [Thread]). </description> </method> <method name="send_bytes"> - <return type="int" enum="Error"> - </return> - <argument index="0" name="bytes" type="PackedByteArray"> - </argument> - <argument index="1" name="id" type="int" default="0"> - </argument> - <argument index="2" name="mode" type="int" enum="MultiplayerPeer.TransferMode" default="2"> - </argument> + <return type="int" enum="Error" /> + <argument index="0" name="bytes" type="PackedByteArray" /> + <argument index="1" name="id" type="int" default="0" /> + <argument index="2" name="mode" type="int" enum="MultiplayerPeer.TransferMode" default="2" /> <description> Sends the given raw [code]bytes[/code] to a specific peer identified by [code]id[/code] (see [method MultiplayerPeer.set_target_peer]). Default ID is [code]0[/code], i.e. broadcast to all peers. </description> @@ -105,24 +94,20 @@ </description> </signal> <signal name="network_peer_connected"> - <argument index="0" name="id" type="int"> - </argument> + <argument index="0" name="id" type="int" /> <description> Emitted when this MultiplayerAPI's [member network_peer] connects with a new peer. ID is the peer ID of the new peer. Clients get notified when other clients connect to the same server. Upon connecting to a server, a client also receives this signal for the server (with ID being 1). </description> </signal> <signal name="network_peer_disconnected"> - <argument index="0" name="id" type="int"> - </argument> + <argument index="0" name="id" type="int" /> <description> Emitted when this MultiplayerAPI's [member network_peer] disconnects from a peer. Clients get notified when other clients disconnect from the same server. </description> </signal> <signal name="network_peer_packet"> - <argument index="0" name="id" type="int"> - </argument> - <argument index="1" name="packet" type="PackedByteArray"> - </argument> + <argument index="0" name="id" type="int" /> + <argument index="1" name="packet" type="PackedByteArray" /> <description> Emitted when this MultiplayerAPI's [member network_peer] receive a [code]packet[/code] with custom data (see [method send_bytes]). ID is the peer ID of the peer that sent the packet. </description> @@ -146,14 +131,5 @@ <constant name="RPC_MODE_PUPPET" value="3" enum="RPCMode"> Used with [method Node.rpc_config] to set a method to be called or a property to be changed only on puppets for this node. Analogous to the [code]puppet[/code] keyword. Only accepts calls or property changes from the node's network master, see [method Node.set_network_master]. </constant> - <constant name="RPC_MODE_REMOTESYNC" value="4" enum="RPCMode"> - Behave like [constant RPC_MODE_REMOTE] but also make the call or property change locally. Analogous to the [code]remotesync[/code] keyword. - </constant> - <constant name="RPC_MODE_MASTERSYNC" value="5" enum="RPCMode"> - Behave like [constant RPC_MODE_MASTER] but also make the call or property change locally. Analogous to the [code]mastersync[/code] keyword. - </constant> - <constant name="RPC_MODE_PUPPETSYNC" value="6" enum="RPCMode"> - Behave like [constant RPC_MODE_PUPPET] but also make the call or property change locally. Analogous to the [code]puppetsync[/code] keyword. - </constant> </constants> </class> diff --git a/doc/classes/MultiplayerPeer.xml b/doc/classes/MultiplayerPeer.xml index 713cd64b82..88cd058c51 100644 --- a/doc/classes/MultiplayerPeer.xml +++ b/doc/classes/MultiplayerPeer.xml @@ -12,39 +12,39 @@ <link title="WebRTC Signaling Demo">https://godotengine.org/asset-library/asset/537</link> </tutorials> <methods> + <method name="generate_unique_id" qualifiers="const"> + <return type="int" /> + <description> + Returns a randomly generated integer that can be used as a network unique ID. + </description> + </method> <method name="get_connection_status" qualifiers="const"> - <return type="int" enum="MultiplayerPeer.ConnectionStatus"> - </return> + <return type="int" enum="MultiplayerPeer.ConnectionStatus" /> <description> Returns the current state of the connection. See [enum ConnectionStatus]. </description> </method> <method name="get_packet_peer" qualifiers="const"> - <return type="int"> - </return> + <return type="int" /> <description> Returns the ID of the [MultiplayerPeer] who sent the most recent packet. </description> </method> <method name="get_unique_id" qualifiers="const"> - <return type="int"> - </return> + <return type="int" /> <description> Returns the ID of this [MultiplayerPeer]. </description> </method> <method name="poll"> - <return type="void"> - </return> + <return type="void" /> <description> Waits up to 1 second to receive a new network event. </description> </method> <method name="set_target_peer"> - <return type="void"> - </return> - <argument index="0" name="id" type="int"> - </argument> + <return type="void" /> + <argument index="0" name="id" type="int" /> <description> Sets the peer to which packets will be sent. The [code]id[/code] can be one of: [constant TARGET_PEER_BROADCAST] to send to all connected peers, [constant TARGET_PEER_SERVER] to send to the peer acting as server, a valid peer ID to send to that specific peer, a negative peer ID to send to all peers except that one. By default, the target peer is [constant TARGET_PEER_BROADCAST]. @@ -71,15 +71,13 @@ </description> </signal> <signal name="peer_connected"> - <argument index="0" name="id" type="int"> - </argument> + <argument index="0" name="id" type="int" /> <description> Emitted by the server when a client connects. </description> </signal> <signal name="peer_disconnected"> - <argument index="0" name="id" type="int"> - </argument> + <argument index="0" name="id" type="int" /> <description> Emitted by the server when a client disconnects. </description> diff --git a/doc/classes/Mutex.xml b/doc/classes/Mutex.xml index dfda614f8e..f97b2344a5 100644 --- a/doc/classes/Mutex.xml +++ b/doc/classes/Mutex.xml @@ -11,22 +11,19 @@ </tutorials> <methods> <method name="lock"> - <return type="void"> - </return> + <return type="void" /> <description> Locks this [Mutex], blocks until it is unlocked by the current owner. </description> </method> <method name="try_lock"> - <return type="int" enum="Error"> - </return> + <return type="int" enum="Error" /> <description> Tries locking this [Mutex], but does not block. Returns [constant OK] on success, [constant ERR_BUSY] otherwise. </description> </method> <method name="unlock"> - <return type="void"> - </return> + <return type="void" /> <description> Unlocks this [Mutex], leaving it to other threads. </description> diff --git a/doc/classes/NativeExtension.xml b/doc/classes/NativeExtension.xml index c48af7df7b..fa8575383c 100644 --- a/doc/classes/NativeExtension.xml +++ b/doc/classes/NativeExtension.xml @@ -8,38 +8,30 @@ </tutorials> <methods> <method name="close_library"> - <return type="void"> - </return> + <return type="void" /> <description> </description> </method> <method name="get_minimum_library_initialization_level" qualifiers="const"> - <return type="int" enum="NativeExtension.InitializationLevel"> - </return> + <return type="int" enum="NativeExtension.InitializationLevel" /> <description> </description> </method> <method name="initialize_library"> - <return type="void"> - </return> - <argument index="0" name="level" type="int" enum="NativeExtension.InitializationLevel"> - </argument> + <return type="void" /> + <argument index="0" name="level" type="int" enum="NativeExtension.InitializationLevel" /> <description> </description> </method> <method name="is_library_open" qualifiers="const"> - <return type="bool"> - </return> + <return type="bool" /> <description> </description> </method> <method name="open_library"> - <return type="int" enum="Error"> - </return> - <argument index="0" name="path" type="String"> - </argument> - <argument index="1" name="entry_symbol" type="String"> - </argument> + <return type="int" enum="Error" /> + <argument index="0" name="path" type="String" /> + <argument index="1" name="entry_symbol" type="String" /> <description> </description> </method> diff --git a/doc/classes/NativeExtensionManager.xml b/doc/classes/NativeExtensionManager.xml index ba9018ff4c..c14ce94aff 100644 --- a/doc/classes/NativeExtensionManager.xml +++ b/doc/classes/NativeExtensionManager.xml @@ -8,40 +8,31 @@ </tutorials> <methods> <method name="get_extension"> - <return type="NativeExtension"> - </return> - <argument index="0" name="path" type="String"> - </argument> + <return type="NativeExtension" /> + <argument index="0" name="path" type="String" /> <description> </description> </method> <method name="get_loaded_extensions" qualifiers="const"> - <return type="PackedStringArray"> - </return> + <return type="PackedStringArray" /> <description> </description> </method> <method name="load_extension"> - <return type="int" enum="NativeExtensionManager.LoadStatus"> - </return> - <argument index="0" name="path" type="String"> - </argument> + <return type="int" enum="NativeExtensionManager.LoadStatus" /> + <argument index="0" name="path" type="String" /> <description> </description> </method> <method name="reload_extension"> - <return type="int" enum="NativeExtensionManager.LoadStatus"> - </return> - <argument index="0" name="path" type="String"> - </argument> + <return type="int" enum="NativeExtensionManager.LoadStatus" /> + <argument index="0" name="path" type="String" /> <description> </description> </method> <method name="unload_extension"> - <return type="int" enum="NativeExtensionManager.LoadStatus"> - </return> - <argument index="0" name="path" type="String"> - </argument> + <return type="int" enum="NativeExtensionManager.LoadStatus" /> + <argument index="0" name="path" type="String" /> <description> </description> </method> diff --git a/doc/classes/NavigationAgent2D.xml b/doc/classes/NavigationAgent2D.xml index de81ae4d91..c05f7c2094 100644 --- a/doc/classes/NavigationAgent2D.xml +++ b/doc/classes/NavigationAgent2D.xml @@ -10,88 +10,74 @@ </tutorials> <methods> <method name="distance_to_target" qualifiers="const"> - <return type="float"> - </return> + <return type="float" /> <description> Returns the distance to the target location, using the agent's global position. The user must set the target location with [method set_target_location] in order for this to be accurate. </description> </method> <method name="get_final_location"> - <return type="Vector2"> - </return> + <return type="Vector2" /> <description> Returns the reachable final location in global coordinates. This can change if the navigation path is altered in any way. </description> </method> <method name="get_nav_path" qualifiers="const"> - <return type="PackedVector2Array"> - </return> + <return type="PackedVector2Array" /> <description> Returns the path from start to finish in global coordinates. </description> </method> <method name="get_nav_path_index" qualifiers="const"> - <return type="int"> - </return> + <return type="int" /> <description> Returns which index the agent is currently on in the navigation path's [PackedVector2Array]. </description> </method> <method name="get_next_location"> - <return type="Vector2"> - </return> + <return type="Vector2" /> <description> Returns a [Vector2] in global coordinates, that can be moved to, making sure that there are no static objects in the way. If the agent does not have a navigation path, it will return the position of the agent's parent. </description> </method> <method name="get_rid" qualifiers="const"> - <return type="RID"> - </return> + <return type="RID" /> <description> </description> </method> <method name="get_target_location" qualifiers="const"> - <return type="Vector2"> - </return> + <return type="Vector2" /> <description> Returns the user defined [Vector2] after setting the target location. </description> </method> <method name="is_navigation_finished"> - <return type="bool"> - </return> + <return type="bool" /> <description> Returns true if the navigation path's final location has been reached. </description> </method> <method name="is_target_reachable"> - <return type="bool"> - </return> + <return type="bool" /> <description> Returns true if the target location is reachable. The target location is set using [method set_target_location]. </description> </method> <method name="is_target_reached" qualifiers="const"> - <return type="bool"> - </return> + <return type="bool" /> <description> Returns true if the target location is reached. The target location is set using [method set_target_location]. It may not always be possible to reach the target location. It should always be possible to reach the final location though. See [method get_final_location]. </description> </method> <method name="set_target_location"> - <return type="void"> - </return> - <argument index="0" name="location" type="Vector2"> - </argument> + <return type="void" /> + <argument index="0" name="location" type="Vector2" /> <description> Sets the user desired final location. This will clear the current navigation path. </description> </method> <method name="set_velocity"> - <return type="void"> - </return> - <argument index="0" name="velocity" type="Vector2"> - </argument> + <return type="void" /> + <argument index="0" name="velocity" type="Vector2" /> <description> Sends the passed in velocity to the collision avoidance algorithm. It will adjust the velocity to avoid collisions. Once the adjustment to the velocity is complete, it will emit the [signal velocity_computed] signal. </description> @@ -137,8 +123,7 @@ </description> </signal> <signal name="velocity_computed"> - <argument index="0" name="safe_velocity" type="Vector3"> - </argument> + <argument index="0" name="safe_velocity" type="Vector3" /> <description> Notifies when the collision avoidance velocity is calculated. Emitted by [method set_velocity]. </description> diff --git a/doc/classes/NavigationAgent3D.xml b/doc/classes/NavigationAgent3D.xml index 8942a37774..af4a058489 100644 --- a/doc/classes/NavigationAgent3D.xml +++ b/doc/classes/NavigationAgent3D.xml @@ -10,88 +10,74 @@ </tutorials> <methods> <method name="distance_to_target" qualifiers="const"> - <return type="float"> - </return> + <return type="float" /> <description> Returns the distance to the target location, using the agent's global position. The user must set the target location with [method set_target_location] in order for this to be accurate. </description> </method> <method name="get_final_location"> - <return type="Vector3"> - </return> + <return type="Vector3" /> <description> Returns the reachable final location in global coordinates. This can change if the navigation path is altered in any way. Because of this, it would be best to check this each frame. </description> </method> <method name="get_nav_path" qualifiers="const"> - <return type="PackedVector3Array"> - </return> + <return type="PackedVector3Array" /> <description> Returns the path from start to finish in global coordinates. </description> </method> <method name="get_nav_path_index" qualifiers="const"> - <return type="int"> - </return> + <return type="int" /> <description> Returns which index the agent is currently on in the navigation path's [PackedVector3Array]. </description> </method> <method name="get_next_location"> - <return type="Vector3"> - </return> + <return type="Vector3" /> <description> Returns a [Vector3] in global coordinates, that can be moved to, making sure that there are no static objects in the way. If the agent does not have a navigation path, it will return the origin of the agent's parent. </description> </method> <method name="get_rid" qualifiers="const"> - <return type="RID"> - </return> + <return type="RID" /> <description> </description> </method> <method name="get_target_location" qualifiers="const"> - <return type="Vector3"> - </return> + <return type="Vector3" /> <description> Returns the user defined [Vector3] after setting the target location. </description> </method> <method name="is_navigation_finished"> - <return type="bool"> - </return> + <return type="bool" /> <description> Returns true if the navigation path's final location has been reached. </description> </method> <method name="is_target_reachable"> - <return type="bool"> - </return> + <return type="bool" /> <description> Returns true if the target location is reachable. The target location is set using [method set_target_location]. </description> </method> <method name="is_target_reached" qualifiers="const"> - <return type="bool"> - </return> + <return type="bool" /> <description> Returns true if the target location is reached. The target location is set using [method set_target_location]. It may not always be possible to reach the target location. It should always be possible to reach the final location though. See [method get_final_location]. </description> </method> <method name="set_target_location"> - <return type="void"> - </return> - <argument index="0" name="location" type="Vector3"> - </argument> + <return type="void" /> + <argument index="0" name="location" type="Vector3" /> <description> Sets the user desired final location. This will clear the current navigation path. </description> </method> <method name="set_velocity"> - <return type="void"> - </return> - <argument index="0" name="velocity" type="Vector3"> - </argument> + <return type="void" /> + <argument index="0" name="velocity" type="Vector3" /> <description> Sends the passed in velocity to the collision avoidance algorithm. It will adjust the velocity to avoid collisions. Once the adjustment to the velocity is complete, it will emit the [signal velocity_computed] signal. </description> @@ -143,8 +129,7 @@ </description> </signal> <signal name="velocity_computed"> - <argument index="0" name="safe_velocity" type="Vector3"> - </argument> + <argument index="0" name="safe_velocity" type="Vector3" /> <description> Notifies when the collision avoidance velocity is calculated. Emitted by [method set_velocity]. </description> diff --git a/doc/classes/NavigationMesh.xml b/doc/classes/NavigationMesh.xml index 871c92798a..1d9b2b0a36 100644 --- a/doc/classes/NavigationMesh.xml +++ b/doc/classes/NavigationMesh.xml @@ -9,70 +9,54 @@ </tutorials> <methods> <method name="add_polygon"> - <return type="void"> - </return> - <argument index="0" name="polygon" type="PackedInt32Array"> - </argument> + <return type="void" /> + <argument index="0" name="polygon" type="PackedInt32Array" /> <description> </description> </method> <method name="clear_polygons"> - <return type="void"> - </return> + <return type="void" /> <description> </description> </method> <method name="create_from_mesh"> - <return type="void"> - </return> - <argument index="0" name="mesh" type="Mesh"> - </argument> + <return type="void" /> + <argument index="0" name="mesh" type="Mesh" /> <description> </description> </method> <method name="get_collision_mask_bit" qualifiers="const"> - <return type="bool"> - </return> - <argument index="0" name="bit" type="int"> - </argument> + <return type="bool" /> + <argument index="0" name="bit" type="int" /> <description> </description> </method> <method name="get_polygon"> - <return type="PackedInt32Array"> - </return> - <argument index="0" name="idx" type="int"> - </argument> + <return type="PackedInt32Array" /> + <argument index="0" name="idx" type="int" /> <description> </description> </method> <method name="get_polygon_count" qualifiers="const"> - <return type="int"> - </return> + <return type="int" /> <description> </description> </method> <method name="get_vertices" qualifiers="const"> - <return type="PackedVector3Array"> - </return> + <return type="PackedVector3Array" /> <description> </description> </method> <method name="set_collision_mask_bit"> - <return type="void"> - </return> - <argument index="0" name="bit" type="int"> - </argument> - <argument index="1" name="value" type="bool"> - </argument> + <return type="void" /> + <argument index="0" name="bit" type="int" /> + <argument index="1" name="value" type="bool" /> <description> </description> </method> <method name="set_vertices"> - <return type="void"> - </return> - <argument index="0" name="vertices" type="PackedVector3Array"> - </argument> + <return type="void" /> + <argument index="0" name="vertices" type="PackedVector3Array" /> <description> </description> </method> diff --git a/doc/classes/NavigationMeshGenerator.xml b/doc/classes/NavigationMeshGenerator.xml index ce1182ffbe..9931033260 100644 --- a/doc/classes/NavigationMeshGenerator.xml +++ b/doc/classes/NavigationMeshGenerator.xml @@ -8,20 +8,15 @@ </tutorials> <methods> <method name="bake"> - <return type="void"> - </return> - <argument index="0" name="nav_mesh" type="NavigationMesh"> - </argument> - <argument index="1" name="root_node" type="Node"> - </argument> + <return type="void" /> + <argument index="0" name="nav_mesh" type="NavigationMesh" /> + <argument index="1" name="root_node" type="Node" /> <description> </description> </method> <method name="clear"> - <return type="void"> - </return> - <argument index="0" name="nav_mesh" type="NavigationMesh"> - </argument> + <return type="void" /> + <argument index="0" name="nav_mesh" type="NavigationMesh" /> <description> </description> </method> diff --git a/doc/classes/NavigationPolygon.xml b/doc/classes/NavigationPolygon.xml index 38921078d7..e1e2c34a63 100644 --- a/doc/classes/NavigationPolygon.xml +++ b/doc/classes/NavigationPolygon.xml @@ -47,119 +47,95 @@ </tutorials> <methods> <method name="add_outline"> - <return type="void"> - </return> - <argument index="0" name="outline" type="PackedVector2Array"> - </argument> + <return type="void" /> + <argument index="0" name="outline" type="PackedVector2Array" /> <description> Appends a [PackedVector2Array] that contains the vertices of an outline to the internal array that contains all the outlines. You have to call [method make_polygons_from_outlines] in order for this array to be converted to polygons that the engine will use. </description> </method> <method name="add_outline_at_index"> - <return type="void"> - </return> - <argument index="0" name="outline" type="PackedVector2Array"> - </argument> - <argument index="1" name="index" type="int"> - </argument> + <return type="void" /> + <argument index="0" name="outline" type="PackedVector2Array" /> + <argument index="1" name="index" type="int" /> <description> Adds a [PackedVector2Array] that contains the vertices of an outline to the internal array that contains all the outlines at a fixed position. You have to call [method make_polygons_from_outlines] in order for this array to be converted to polygons that the engine will use. </description> </method> <method name="add_polygon"> - <return type="void"> - </return> - <argument index="0" name="polygon" type="PackedInt32Array"> - </argument> + <return type="void" /> + <argument index="0" name="polygon" type="PackedInt32Array" /> <description> Adds a polygon using the indices of the vertices you get when calling [method get_vertices]. </description> </method> <method name="clear_outlines"> - <return type="void"> - </return> + <return type="void" /> <description> Clears the array of the outlines, but it doesn't clear the vertices and the polygons that were created by them. </description> </method> <method name="clear_polygons"> - <return type="void"> - </return> + <return type="void" /> <description> Clears the array of polygons, but it doesn't clear the array of outlines and vertices. </description> </method> <method name="get_outline" qualifiers="const"> - <return type="PackedVector2Array"> - </return> - <argument index="0" name="idx" type="int"> - </argument> + <return type="PackedVector2Array" /> + <argument index="0" name="idx" type="int" /> <description> Returns a [PackedVector2Array] containing the vertices of an outline that was created in the editor or by script. </description> </method> <method name="get_outline_count" qualifiers="const"> - <return type="int"> - </return> + <return type="int" /> <description> Returns the number of outlines that were created in the editor or by script. </description> </method> <method name="get_polygon"> - <return type="PackedInt32Array"> - </return> - <argument index="0" name="idx" type="int"> - </argument> + <return type="PackedInt32Array" /> + <argument index="0" name="idx" type="int" /> <description> Returns a [PackedInt32Array] containing the indices of the vertices of a created polygon. </description> </method> <method name="get_polygon_count" qualifiers="const"> - <return type="int"> - </return> + <return type="int" /> <description> Returns the count of all polygons. </description> </method> <method name="get_vertices" qualifiers="const"> - <return type="PackedVector2Array"> - </return> + <return type="PackedVector2Array" /> <description> Returns a [PackedVector2Array] containing all the vertices being used to create the polygons. </description> </method> <method name="make_polygons_from_outlines"> - <return type="void"> - </return> + <return type="void" /> <description> Creates polygons from the outlines added in the editor or by script. </description> </method> <method name="remove_outline"> - <return type="void"> - </return> - <argument index="0" name="idx" type="int"> - </argument> + <return type="void" /> + <argument index="0" name="idx" type="int" /> <description> Removes an outline created in the editor or by script. You have to call [method make_polygons_from_outlines] for the polygons to update. </description> </method> <method name="set_outline"> - <return type="void"> - </return> - <argument index="0" name="idx" type="int"> - </argument> - <argument index="1" name="outline" type="PackedVector2Array"> - </argument> + <return type="void" /> + <argument index="0" name="idx" type="int" /> + <argument index="1" name="outline" type="PackedVector2Array" /> <description> Changes an outline created in the editor or by script. You have to call [method make_polygons_from_outlines] for the polygons to update. </description> </method> <method name="set_vertices"> - <return type="void"> - </return> - <argument index="0" name="vertices" type="PackedVector2Array"> - </argument> + <return type="void" /> + <argument index="0" name="vertices" type="PackedVector2Array" /> <description> Sets the vertices that can be then indexed to create polygons with the [method add_polygon] method. </description> diff --git a/doc/classes/NavigationRegion3D.xml b/doc/classes/NavigationRegion3D.xml index 2904ba4200..da06641b48 100644 --- a/doc/classes/NavigationRegion3D.xml +++ b/doc/classes/NavigationRegion3D.xml @@ -11,8 +11,7 @@ </tutorials> <methods> <method name="bake_navigation_mesh"> - <return type="void"> - </return> + <return type="void" /> <description> Bakes the [NavigationMesh]. The baking is done in a separate thread because navigation baking is not a cheap operation. This can be done at runtime. When it is completed, it automatically sets the new [NavigationMesh]. </description> diff --git a/doc/classes/NavigationServer2D.xml b/doc/classes/NavigationServer2D.xml index b0a57ed227..042ab06e6f 100644 --- a/doc/classes/NavigationServer2D.xml +++ b/doc/classes/NavigationServer2D.xml @@ -16,337 +16,249 @@ </tutorials> <methods> <method name="agent_create" qualifiers="const"> - <return type="RID"> - </return> + <return type="RID" /> <description> Creates the agent. </description> </method> <method name="agent_is_map_changed" qualifiers="const"> - <return type="bool"> - </return> - <argument index="0" name="agent" type="RID"> - </argument> + <return type="bool" /> + <argument index="0" name="agent" type="RID" /> <description> Returns true if the map got changed the previous frame. </description> </method> <method name="agent_set_callback" qualifiers="const"> - <return type="void"> - </return> - <argument index="0" name="agent" type="RID"> - </argument> - <argument index="1" name="receiver" type="Object"> - </argument> - <argument index="2" name="method" type="StringName"> - </argument> - <argument index="3" name="userdata" type="Variant" default="null"> - </argument> + <return type="void" /> + <argument index="0" name="agent" type="RID" /> + <argument index="1" name="receiver" type="Object" /> + <argument index="2" name="method" type="StringName" /> + <argument index="3" name="userdata" type="Variant" default="null" /> <description> Callback called at the end of the RVO process. </description> </method> <method name="agent_set_map" qualifiers="const"> - <return type="void"> - </return> - <argument index="0" name="agent" type="RID"> - </argument> - <argument index="1" name="map" type="RID"> - </argument> + <return type="void" /> + <argument index="0" name="agent" type="RID" /> + <argument index="1" name="map" type="RID" /> <description> Puts the agent in the map. </description> </method> <method name="agent_set_max_neighbors" qualifiers="const"> - <return type="void"> - </return> - <argument index="0" name="agent" type="RID"> - </argument> - <argument index="1" name="count" type="int"> - </argument> + <return type="void" /> + <argument index="0" name="agent" type="RID" /> + <argument index="1" name="count" type="int" /> <description> Sets the maximum number of other agents the agent takes into account in the navigation. The larger this number, the longer the running time of the simulation. If the number is too low, the simulation will not be safe. </description> </method> <method name="agent_set_max_speed" qualifiers="const"> - <return type="void"> - </return> - <argument index="0" name="agent" type="RID"> - </argument> - <argument index="1" name="max_speed" type="float"> - </argument> + <return type="void" /> + <argument index="0" name="agent" type="RID" /> + <argument index="1" name="max_speed" type="float" /> <description> Sets the maximum speed of the agent. Must be positive. </description> </method> <method name="agent_set_neighbor_dist" qualifiers="const"> - <return type="void"> - </return> - <argument index="0" name="agent" type="RID"> - </argument> - <argument index="1" name="dist" type="float"> - </argument> + <return type="void" /> + <argument index="0" name="agent" type="RID" /> + <argument index="1" name="dist" type="float" /> <description> Sets the maximum distance to other agents this agent takes into account in the navigation. The larger this number, the longer the running time of the simulation. If the number is too low, the simulation will not be safe. </description> </method> <method name="agent_set_position" qualifiers="const"> - <return type="void"> - </return> - <argument index="0" name="agent" type="RID"> - </argument> - <argument index="1" name="position" type="Vector2"> - </argument> + <return type="void" /> + <argument index="0" name="agent" type="RID" /> + <argument index="1" name="position" type="Vector2" /> <description> Sets the position of the agent in world space. </description> </method> <method name="agent_set_radius" qualifiers="const"> - <return type="void"> - </return> - <argument index="0" name="agent" type="RID"> - </argument> - <argument index="1" name="radius" type="float"> - </argument> + <return type="void" /> + <argument index="0" name="agent" type="RID" /> + <argument index="1" name="radius" type="float" /> <description> Sets the radius of the agent. </description> </method> <method name="agent_set_target_velocity" qualifiers="const"> - <return type="void"> - </return> - <argument index="0" name="agent" type="RID"> - </argument> - <argument index="1" name="target_velocity" type="Vector2"> - </argument> + <return type="void" /> + <argument index="0" name="agent" type="RID" /> + <argument index="1" name="target_velocity" type="Vector2" /> <description> Sets the new target velocity. </description> </method> <method name="agent_set_time_horizon" qualifiers="const"> - <return type="void"> - </return> - <argument index="0" name="agent" type="RID"> - </argument> - <argument index="1" name="time" type="float"> - </argument> + <return type="void" /> + <argument index="0" name="agent" type="RID" /> + <argument index="1" name="time" type="float" /> <description> The minimal amount of time for which the agent's velocities that are computed by the simulation are safe with respect to other agents. The larger this number, the sooner this agent will respond to the presence of other agents, but the less freedom this agent has in choosing its velocities. Must be positive. </description> </method> <method name="agent_set_velocity" qualifiers="const"> - <return type="void"> - </return> - <argument index="0" name="agent" type="RID"> - </argument> - <argument index="1" name="velocity" type="Vector2"> - </argument> + <return type="void" /> + <argument index="0" name="agent" type="RID" /> + <argument index="1" name="velocity" type="Vector2" /> <description> Sets the current velocity of the agent. </description> </method> <method name="free" qualifiers="const"> - <return type="void"> - </return> - <argument index="0" name="object" type="RID"> - </argument> + <return type="void" /> + <argument index="0" name="object" type="RID" /> <description> Destroy the RID </description> </method> <method name="map_create" qualifiers="const"> - <return type="RID"> - </return> + <return type="RID" /> <description> Create a new map. </description> </method> <method name="map_get_cell_size" qualifiers="const"> - <return type="float"> - </return> - <argument index="0" name="map" type="RID"> - </argument> + <return type="float" /> + <argument index="0" name="map" type="RID" /> <description> Returns the map cell size. </description> </method> <method name="map_get_closest_point" qualifiers="const"> - <return type="Vector2"> - </return> - <argument index="0" name="map" type="RID"> - </argument> - <argument index="1" name="to_point" type="Vector2"> - </argument> + <return type="Vector2" /> + <argument index="0" name="map" type="RID" /> + <argument index="1" name="to_point" type="Vector2" /> <description> Returns the point closest to the provided [code]to_point[/code] on the navigation mesh surface. </description> </method> <method name="map_get_closest_point_owner" qualifiers="const"> - <return type="RID"> - </return> - <argument index="0" name="map" type="RID"> - </argument> - <argument index="1" name="to_point" type="Vector2"> - </argument> + <return type="RID" /> + <argument index="0" name="map" type="RID" /> + <argument index="1" name="to_point" type="Vector2" /> <description> Returns the owner region RID for the point returned by [method map_get_closest_point]. </description> </method> <method name="map_get_edge_connection_margin" qualifiers="const"> - <return type="float"> - </return> - <argument index="0" name="map" type="RID"> - </argument> + <return type="float" /> + <argument index="0" name="map" type="RID" /> <description> Returns the edge connection margin of the map. The edge connection margin is a distance used to connect two regions. </description> </method> <method name="map_get_path" qualifiers="const"> - <return type="PackedVector2Array"> - </return> - <argument index="0" name="map" type="RID"> - </argument> - <argument index="1" name="origin" type="Vector2"> - </argument> - <argument index="2" name="destination" type="Vector2"> - </argument> - <argument index="3" name="optimize" type="bool"> - </argument> - <argument index="4" name="layers" type="int" default="1"> - </argument> + <return type="PackedVector2Array" /> + <argument index="0" name="map" type="RID" /> + <argument index="1" name="origin" type="Vector2" /> + <argument index="2" name="destination" type="Vector2" /> + <argument index="3" name="optimize" type="bool" /> + <argument index="4" name="layers" type="int" default="1" /> <description> Returns the navigation path to reach the destination from the origin. [code]layers[/code] is a bitmask of all region layers that are allowed to be in the path. </description> </method> <method name="map_is_active" qualifiers="const"> - <return type="bool"> - </return> - <argument index="0" name="nap" type="RID"> - </argument> + <return type="bool" /> + <argument index="0" name="nap" type="RID" /> <description> Returns true if the map is active. </description> </method> <method name="map_set_active" qualifiers="const"> - <return type="void"> - </return> - <argument index="0" name="map" type="RID"> - </argument> - <argument index="1" name="active" type="bool"> - </argument> + <return type="void" /> + <argument index="0" name="map" type="RID" /> + <argument index="1" name="active" type="bool" /> <description> Sets the map active. </description> </method> <method name="map_set_cell_size" qualifiers="const"> - <return type="void"> - </return> - <argument index="0" name="map" type="RID"> - </argument> - <argument index="1" name="cell_size" type="float"> - </argument> + <return type="void" /> + <argument index="0" name="map" type="RID" /> + <argument index="1" name="cell_size" type="float" /> <description> Set the map cell size used to weld the navigation mesh polygons. </description> </method> <method name="map_set_edge_connection_margin" qualifiers="const"> - <return type="void"> - </return> - <argument index="0" name="map" type="RID"> - </argument> - <argument index="1" name="margin" type="float"> - </argument> + <return type="void" /> + <argument index="0" name="map" type="RID" /> + <argument index="1" name="margin" type="float" /> <description> Set the map edge connection margin used to weld the compatible region edges. </description> </method> <method name="region_create" qualifiers="const"> - <return type="RID"> - </return> + <return type="RID" /> <description> Creates a new region. </description> </method> <method name="region_get_connection_pathway_end" qualifiers="const"> - <return type="Vector2"> - </return> - <argument index="0" name="region" type="RID"> - </argument> - <argument index="1" name="connection" type="int"> - </argument> + <return type="Vector2" /> + <argument index="0" name="region" type="RID" /> + <argument index="1" name="connection" type="int" /> <description> Returns the ending point of a connection door. [code]connection[/code] is an index between 0 and the return value of [method region_get_connections_count]. </description> </method> <method name="region_get_connection_pathway_start" qualifiers="const"> - <return type="Vector2"> - </return> - <argument index="0" name="region" type="RID"> - </argument> - <argument index="1" name="connection" type="int"> - </argument> + <return type="Vector2" /> + <argument index="0" name="region" type="RID" /> + <argument index="1" name="connection" type="int" /> <description> Returns the starting point of a connection door. [code]connection[/code] is an index between 0 and the return value of [method region_get_connections_count]. </description> </method> <method name="region_get_connections_count" qualifiers="const"> - <return type="int"> - </return> - <argument index="0" name="region" type="RID"> - </argument> + <return type="int" /> + <argument index="0" name="region" type="RID" /> <description> Returns how many connections this [code]region[/code] has with other regions in the map. </description> </method> <method name="region_get_layers" qualifiers="const"> - <return type="int"> - </return> - <argument index="0" name="region" type="RID"> - </argument> + <return type="int" /> + <argument index="0" name="region" type="RID" /> <description> Returns the region's layers. </description> </method> <method name="region_set_layers" qualifiers="const"> - <return type="void"> - </return> - <argument index="0" name="region" type="RID"> - </argument> - <argument index="1" name="layers" type="int"> - </argument> + <return type="void" /> + <argument index="0" name="region" type="RID" /> + <argument index="1" name="layers" type="int" /> <description> Set the region's layers. This allows selecting regions from a path request (when using [method NavigationServer2D.map_get_path]). </description> </method> <method name="region_set_map" qualifiers="const"> - <return type="void"> - </return> - <argument index="0" name="region" type="RID"> - </argument> - <argument index="1" name="map" type="RID"> - </argument> + <return type="void" /> + <argument index="0" name="region" type="RID" /> + <argument index="1" name="map" type="RID" /> <description> Sets the map for the region. </description> </method> <method name="region_set_navpoly" qualifiers="const"> - <return type="void"> - </return> - <argument index="0" name="region" type="RID"> - </argument> - <argument index="1" name="nav_poly" type="NavigationPolygon"> - </argument> + <return type="void" /> + <argument index="0" name="region" type="RID" /> + <argument index="1" name="nav_poly" type="NavigationPolygon" /> <description> Sets the navigation mesh for the region. </description> </method> <method name="region_set_transform" qualifiers="const"> - <return type="void"> - </return> - <argument index="0" name="region" type="RID"> - </argument> - <argument index="1" name="transform" type="Transform2D"> - </argument> + <return type="void" /> + <argument index="0" name="region" type="RID" /> + <argument index="1" name="transform" type="Transform2D" /> <description> Sets the global transformation for the region. </description> @@ -354,8 +266,7 @@ </methods> <signals> <signal name="map_changed"> - <argument index="0" name="map" type="RID"> - </argument> + <argument index="0" name="map" type="RID" /> <description> Emitted when a navigation map is updated, when a region moves or is modified. </description> diff --git a/doc/classes/NavigationServer3D.xml b/doc/classes/NavigationServer3D.xml index ef9efcb99c..73ca18655a 100644 --- a/doc/classes/NavigationServer3D.xml +++ b/doc/classes/NavigationServer3D.xml @@ -16,301 +16,221 @@ </tutorials> <methods> <method name="agent_create" qualifiers="const"> - <return type="RID"> - </return> + <return type="RID" /> <description> Creates the agent. </description> </method> <method name="agent_is_map_changed" qualifiers="const"> - <return type="bool"> - </return> - <argument index="0" name="agent" type="RID"> - </argument> + <return type="bool" /> + <argument index="0" name="agent" type="RID" /> <description> Returns true if the map got changed the previous frame. </description> </method> <method name="agent_set_callback" qualifiers="const"> - <return type="void"> - </return> - <argument index="0" name="agent" type="RID"> - </argument> - <argument index="1" name="receiver" type="Object"> - </argument> - <argument index="2" name="method" type="StringName"> - </argument> - <argument index="3" name="userdata" type="Variant" default="null"> - </argument> + <return type="void" /> + <argument index="0" name="agent" type="RID" /> + <argument index="1" name="receiver" type="Object" /> + <argument index="2" name="method" type="StringName" /> + <argument index="3" name="userdata" type="Variant" default="null" /> <description> Callback called at the end of the RVO process. </description> </method> <method name="agent_set_map" qualifiers="const"> - <return type="void"> - </return> - <argument index="0" name="agent" type="RID"> - </argument> - <argument index="1" name="map" type="RID"> - </argument> + <return type="void" /> + <argument index="0" name="agent" type="RID" /> + <argument index="1" name="map" type="RID" /> <description> Puts the agent in the map. </description> </method> <method name="agent_set_max_neighbors" qualifiers="const"> - <return type="void"> - </return> - <argument index="0" name="agent" type="RID"> - </argument> - <argument index="1" name="count" type="int"> - </argument> + <return type="void" /> + <argument index="0" name="agent" type="RID" /> + <argument index="1" name="count" type="int" /> <description> Sets the maximum number of other agents the agent takes into account in the navigation. The larger this number, the longer the running time of the simulation. If the number is too low, the simulation will not be safe. </description> </method> <method name="agent_set_max_speed" qualifiers="const"> - <return type="void"> - </return> - <argument index="0" name="agent" type="RID"> - </argument> - <argument index="1" name="max_speed" type="float"> - </argument> + <return type="void" /> + <argument index="0" name="agent" type="RID" /> + <argument index="1" name="max_speed" type="float" /> <description> Sets the maximum speed of the agent. Must be positive. </description> </method> <method name="agent_set_neighbor_dist" qualifiers="const"> - <return type="void"> - </return> - <argument index="0" name="agent" type="RID"> - </argument> - <argument index="1" name="dist" type="float"> - </argument> + <return type="void" /> + <argument index="0" name="agent" type="RID" /> + <argument index="1" name="dist" type="float" /> <description> Sets the maximum distance to other agents this agent takes into account in the navigation. The larger this number, the longer the running time of the simulation. If the number is too low, the simulation will not be safe. </description> </method> <method name="agent_set_position" qualifiers="const"> - <return type="void"> - </return> - <argument index="0" name="agent" type="RID"> - </argument> - <argument index="1" name="position" type="Vector3"> - </argument> + <return type="void" /> + <argument index="0" name="agent" type="RID" /> + <argument index="1" name="position" type="Vector3" /> <description> Sets the position of the agent in world space. </description> </method> <method name="agent_set_radius" qualifiers="const"> - <return type="void"> - </return> - <argument index="0" name="agent" type="RID"> - </argument> - <argument index="1" name="radius" type="float"> - </argument> + <return type="void" /> + <argument index="0" name="agent" type="RID" /> + <argument index="1" name="radius" type="float" /> <description> Sets the radius of the agent. </description> </method> <method name="agent_set_target_velocity" qualifiers="const"> - <return type="void"> - </return> - <argument index="0" name="agent" type="RID"> - </argument> - <argument index="1" name="target_velocity" type="Vector3"> - </argument> + <return type="void" /> + <argument index="0" name="agent" type="RID" /> + <argument index="1" name="target_velocity" type="Vector3" /> <description> Sets the new target velocity. </description> </method> <method name="agent_set_time_horizon" qualifiers="const"> - <return type="void"> - </return> - <argument index="0" name="agent" type="RID"> - </argument> - <argument index="1" name="time" type="float"> - </argument> + <return type="void" /> + <argument index="0" name="agent" type="RID" /> + <argument index="1" name="time" type="float" /> <description> The minimal amount of time for which the agent's velocities that are computed by the simulation are safe with respect to other agents. The larger this number, the sooner this agent will respond to the presence of other agents, but the less freedom this agent has in choosing its velocities. Must be positive. </description> </method> <method name="agent_set_velocity" qualifiers="const"> - <return type="void"> - </return> - <argument index="0" name="agent" type="RID"> - </argument> - <argument index="1" name="velocity" type="Vector3"> - </argument> + <return type="void" /> + <argument index="0" name="agent" type="RID" /> + <argument index="1" name="velocity" type="Vector3" /> <description> Sets the current velocity of the agent. </description> </method> <method name="free" qualifiers="const"> - <return type="void"> - </return> - <argument index="0" name="object" type="RID"> - </argument> + <return type="void" /> + <argument index="0" name="object" type="RID" /> <description> Destroy the RID </description> </method> <method name="map_create" qualifiers="const"> - <return type="RID"> - </return> + <return type="RID" /> <description> Create a new map. </description> </method> <method name="map_get_cell_size" qualifiers="const"> - <return type="float"> - </return> - <argument index="0" name="map" type="RID"> - </argument> + <return type="float" /> + <argument index="0" name="map" type="RID" /> <description> Returns the map cell size. </description> </method> <method name="map_get_closest_point" qualifiers="const"> - <return type="Vector3"> - </return> - <argument index="0" name="map" type="RID"> - </argument> - <argument index="1" name="to_point" type="Vector3"> - </argument> + <return type="Vector3" /> + <argument index="0" name="map" type="RID" /> + <argument index="1" name="to_point" type="Vector3" /> <description> Returns the point closest to the provided [code]point[/code] on the navigation mesh surface. </description> </method> <method name="map_get_closest_point_normal" qualifiers="const"> - <return type="Vector3"> - </return> - <argument index="0" name="map" type="RID"> - </argument> - <argument index="1" name="to_point" type="Vector3"> - </argument> + <return type="Vector3" /> + <argument index="0" name="map" type="RID" /> + <argument index="1" name="to_point" type="Vector3" /> <description> Returns the normal for the point returned by [method map_get_closest_point]. </description> </method> <method name="map_get_closest_point_owner" qualifiers="const"> - <return type="RID"> - </return> - <argument index="0" name="map" type="RID"> - </argument> - <argument index="1" name="to_point" type="Vector3"> - </argument> + <return type="RID" /> + <argument index="0" name="map" type="RID" /> + <argument index="1" name="to_point" type="Vector3" /> <description> Returns the owner region RID for the point returned by [method map_get_closest_point]. </description> </method> <method name="map_get_closest_point_to_segment" qualifiers="const"> - <return type="Vector3"> - </return> - <argument index="0" name="map" type="RID"> - </argument> - <argument index="1" name="start" type="Vector3"> - </argument> - <argument index="2" name="end" type="Vector3"> - </argument> - <argument index="3" name="use_collision" type="bool" default="false"> - </argument> + <return type="Vector3" /> + <argument index="0" name="map" type="RID" /> + <argument index="1" name="start" type="Vector3" /> + <argument index="2" name="end" type="Vector3" /> + <argument index="3" name="use_collision" type="bool" default="false" /> <description> Returns the closest point between the navigation surface and the segment. </description> </method> <method name="map_get_edge_connection_margin" qualifiers="const"> - <return type="float"> - </return> - <argument index="0" name="map" type="RID"> - </argument> + <return type="float" /> + <argument index="0" name="map" type="RID" /> <description> Returns the edge connection margin of the map. This distance is the minimum vertex distance needed to connect two edges from different regions. </description> </method> <method name="map_get_path" qualifiers="const"> - <return type="PackedVector3Array"> - </return> - <argument index="0" name="map" type="RID"> - </argument> - <argument index="1" name="origin" type="Vector3"> - </argument> - <argument index="2" name="destination" type="Vector3"> - </argument> - <argument index="3" name="optimize" type="bool"> - </argument> - <argument index="4" name="layers" type="int" default="1"> - </argument> + <return type="PackedVector3Array" /> + <argument index="0" name="map" type="RID" /> + <argument index="1" name="origin" type="Vector3" /> + <argument index="2" name="destination" type="Vector3" /> + <argument index="3" name="optimize" type="bool" /> + <argument index="4" name="layers" type="int" default="1" /> <description> Returns the navigation path to reach the destination from the origin. [code]layers[/code] is a bitmask of all region layers that are allowed to be in the path. </description> </method> <method name="map_get_up" qualifiers="const"> - <return type="Vector3"> - </return> - <argument index="0" name="map" type="RID"> - </argument> + <return type="Vector3" /> + <argument index="0" name="map" type="RID" /> <description> Returns the map's up direction. </description> </method> <method name="map_is_active" qualifiers="const"> - <return type="bool"> - </return> - <argument index="0" name="nap" type="RID"> - </argument> + <return type="bool" /> + <argument index="0" name="nap" type="RID" /> <description> Returns true if the map is active. </description> </method> <method name="map_set_active" qualifiers="const"> - <return type="void"> - </return> - <argument index="0" name="map" type="RID"> - </argument> - <argument index="1" name="active" type="bool"> - </argument> + <return type="void" /> + <argument index="0" name="map" type="RID" /> + <argument index="1" name="active" type="bool" /> <description> Sets the map active. </description> </method> <method name="map_set_cell_size" qualifiers="const"> - <return type="void"> - </return> - <argument index="0" name="map" type="RID"> - </argument> - <argument index="1" name="cell_size" type="float"> - </argument> + <return type="void" /> + <argument index="0" name="map" type="RID" /> + <argument index="1" name="cell_size" type="float" /> <description> Set the map cell size used to weld the navigation mesh polygons. </description> </method> <method name="map_set_edge_connection_margin" qualifiers="const"> - <return type="void"> - </return> - <argument index="0" name="map" type="RID"> - </argument> - <argument index="1" name="margin" type="float"> - </argument> + <return type="void" /> + <argument index="0" name="map" type="RID" /> + <argument index="1" name="margin" type="float" /> <description> Set the map edge connection margin used to weld the compatible region edges. </description> </method> <method name="map_set_up" qualifiers="const"> - <return type="void"> - </return> - <argument index="0" name="map" type="RID"> - </argument> - <argument index="1" name="up" type="Vector3"> - </argument> + <return type="void" /> + <argument index="0" name="map" type="RID" /> + <argument index="1" name="up" type="Vector3" /> <description> Sets the map up direction. </description> </method> <method name="process"> - <return type="void"> - </return> - <argument index="0" name="delta_time" type="float"> - </argument> + <return type="void" /> + <argument index="0" name="delta_time" type="float" /> <description> Process the collision avoidance agents. The result of this process is needed by the physics server, so this must be called in the main thread. @@ -318,112 +238,84 @@ </description> </method> <method name="region_bake_navmesh" qualifiers="const"> - <return type="void"> - </return> - <argument index="0" name="mesh" type="NavigationMesh"> - </argument> - <argument index="1" name="node" type="Node"> - </argument> + <return type="void" /> + <argument index="0" name="mesh" type="NavigationMesh" /> + <argument index="1" name="node" type="Node" /> <description> Bakes the navigation mesh. </description> </method> <method name="region_create" qualifiers="const"> - <return type="RID"> - </return> + <return type="RID" /> <description> Creates a new region. </description> </method> <method name="region_get_connection_pathway_end" qualifiers="const"> - <return type="Vector3"> - </return> - <argument index="0" name="region" type="RID"> - </argument> - <argument index="1" name="connection" type="int"> - </argument> + <return type="Vector3" /> + <argument index="0" name="region" type="RID" /> + <argument index="1" name="connection" type="int" /> <description> Returns the ending point of a connection door. [code]connection[/code] is an index between 0 and the return value of [method region_get_connections_count]. </description> </method> <method name="region_get_connection_pathway_start" qualifiers="const"> - <return type="Vector3"> - </return> - <argument index="0" name="region" type="RID"> - </argument> - <argument index="1" name="connection" type="int"> - </argument> + <return type="Vector3" /> + <argument index="0" name="region" type="RID" /> + <argument index="1" name="connection" type="int" /> <description> Returns the starting point of a connection door. [code]connection[/code] is an index between 0 and the return value of [method region_get_connections_count]. </description> </method> <method name="region_get_connections_count" qualifiers="const"> - <return type="int"> - </return> - <argument index="0" name="region" type="RID"> - </argument> + <return type="int" /> + <argument index="0" name="region" type="RID" /> <description> Returns how many connections this [code]region[/code] has with other regions in the map. </description> </method> <method name="region_get_layers" qualifiers="const"> - <return type="int"> - </return> - <argument index="0" name="region" type="RID"> - </argument> + <return type="int" /> + <argument index="0" name="region" type="RID" /> <description> Returns the region's layers. </description> </method> <method name="region_set_layers" qualifiers="const"> - <return type="void"> - </return> - <argument index="0" name="region" type="RID"> - </argument> - <argument index="1" name="layers" type="int"> - </argument> + <return type="void" /> + <argument index="0" name="region" type="RID" /> + <argument index="1" name="layers" type="int" /> <description> Set the region's layers. This allows selecting regions from a path request (when using [method NavigationServer3D.map_get_path]). </description> </method> <method name="region_set_map" qualifiers="const"> - <return type="void"> - </return> - <argument index="0" name="region" type="RID"> - </argument> - <argument index="1" name="map" type="RID"> - </argument> + <return type="void" /> + <argument index="0" name="region" type="RID" /> + <argument index="1" name="map" type="RID" /> <description> Sets the map for the region. </description> </method> <method name="region_set_navmesh" qualifiers="const"> - <return type="void"> - </return> - <argument index="0" name="region" type="RID"> - </argument> - <argument index="1" name="nav_mesh" type="NavigationMesh"> - </argument> + <return type="void" /> + <argument index="0" name="region" type="RID" /> + <argument index="1" name="nav_mesh" type="NavigationMesh" /> <description> Sets the navigation mesh for the region. </description> </method> <method name="region_set_transform" qualifiers="const"> - <return type="void"> - </return> - <argument index="0" name="region" type="RID"> - </argument> - <argument index="1" name="transform" type="Transform3D"> - </argument> + <return type="void" /> + <argument index="0" name="region" type="RID" /> + <argument index="1" name="transform" type="Transform3D" /> <description> Sets the global transformation for the region. </description> </method> <method name="set_active" qualifiers="const"> - <return type="void"> - </return> - <argument index="0" name="active" type="bool"> - </argument> + <return type="void" /> + <argument index="0" name="active" type="bool" /> <description> Control activation of this server. </description> @@ -431,8 +323,7 @@ </methods> <signals> <signal name="map_changed"> - <argument index="0" name="map" type="RID"> - </argument> + <argument index="0" name="map" type="RID" /> <description> Emitted when a navigation map is updated, when a region moves or is modified. </description> diff --git a/doc/classes/NinePatchRect.xml b/doc/classes/NinePatchRect.xml index 5d59f994d3..77fd9165bb 100644 --- a/doc/classes/NinePatchRect.xml +++ b/doc/classes/NinePatchRect.xml @@ -10,21 +10,16 @@ </tutorials> <methods> <method name="get_patch_margin" qualifiers="const"> - <return type="int"> - </return> - <argument index="0" name="margin" type="int" enum="Side"> - </argument> + <return type="int" /> + <argument index="0" name="margin" type="int" enum="Side" /> <description> Returns the size of the margin on the specified [enum Side]. </description> </method> <method name="set_patch_margin"> - <return type="void"> - </return> - <argument index="0" name="margin" type="int" enum="Side"> - </argument> - <argument index="1" name="value" type="int"> - </argument> + <return type="void" /> + <argument index="0" name="margin" type="int" enum="Side" /> + <argument index="1" name="value" type="int" /> <description> Sets the size of the margin on the specified [enum Side] to [code]value[/code] pixels. </description> diff --git a/doc/classes/Node.xml b/doc/classes/Node.xml index fc971effd7..3874046628 100644 --- a/doc/classes/Node.xml +++ b/doc/classes/Node.xml @@ -22,24 +22,21 @@ </tutorials> <methods> <method name="_enter_tree" qualifiers="virtual"> - <return type="void"> - </return> + <return type="void" /> <description> Called when the node enters the [SceneTree] (e.g. upon instancing, scene changing, or after calling [method add_child] in a script). If the node has children, its [method _enter_tree] callback will be called first, and then that of the children. Corresponds to the [constant NOTIFICATION_ENTER_TREE] notification in [method Object._notification]. </description> </method> <method name="_exit_tree" qualifiers="virtual"> - <return type="void"> - </return> + <return type="void" /> <description> Called when the node is about to leave the [SceneTree] (e.g. upon freeing, scene changing, or after calling [method remove_child] in a script). If the node has children, its [method _exit_tree] callback will be called last, after all its children have left the tree. Corresponds to the [constant NOTIFICATION_EXIT_TREE] notification in [method Object._notification] and signal [signal tree_exiting]. To get notified when the node has already left the active tree, connect to the [signal tree_exited]. </description> </method> <method name="_get_configuration_warnings" qualifiers="virtual"> - <return type="String[]"> - </return> + <return type="String[]" /> <description> The elements in the array returned from this method are displayed as warnings in the Scene Dock if the script that overrides it is a [code]tool[/code] script. Returning an empty array produces no warnings. @@ -47,10 +44,8 @@ </description> </method> <method name="_input" qualifiers="virtual"> - <return type="void"> - </return> - <argument index="0" name="event" type="InputEvent"> - </argument> + <return type="void" /> + <argument index="0" name="event" type="InputEvent" /> <description> Called when there is an input event. The input event propagates up through the node tree until a node consumes it. It is only called if input processing is enabled, which is done automatically if this method is overridden, and can be toggled with [method set_process_input]. @@ -60,10 +55,8 @@ </description> </method> <method name="_physics_process" qualifiers="virtual"> - <return type="void"> - </return> - <argument index="0" name="delta" type="float"> - </argument> + <return type="void" /> + <argument index="0" name="delta" type="float" /> <description> Called during the physics processing step of the main loop. Physics processing means that the frame rate is synced to the physics, i.e. the [code]delta[/code] variable should be constant. [code]delta[/code] is in seconds. It is only called if physics processing is enabled, which is done automatically if this method is overridden, and can be toggled with [method set_physics_process]. @@ -72,10 +65,8 @@ </description> </method> <method name="_process" qualifiers="virtual"> - <return type="void"> - </return> - <argument index="0" name="delta" type="float"> - </argument> + <return type="void" /> + <argument index="0" name="delta" type="float" /> <description> Called during the processing step of the main loop. Processing happens at every frame and as fast as possible, so the [code]delta[/code] time since the previous frame is not constant. [code]delta[/code] is in seconds. It is only called if processing is enabled, which is done automatically if this method is overridden, and can be toggled with [method set_process]. @@ -84,8 +75,7 @@ </description> </method> <method name="_ready" qualifiers="virtual"> - <return type="void"> - </return> + <return type="void" /> <description> Called when the node is "ready", i.e. when both the node and its children have entered the scene tree. If the node has children, their [method _ready] callbacks get triggered first, and the parent node will receive the ready notification afterwards. Corresponds to the [constant NOTIFICATION_READY] notification in [method Object._notification]. See also the [code]onready[/code] keyword for variables. @@ -94,10 +84,8 @@ </description> </method> <method name="_unhandled_input" qualifiers="virtual"> - <return type="void"> - </return> - <argument index="0" name="event" type="InputEvent"> - </argument> + <return type="void" /> + <argument index="0" name="event" type="InputEvent" /> <description> Called when an [InputEvent] hasn't been consumed by [method _input] or any GUI. The input event propagates up through the node tree until a node consumes it. It is only called if unhandled input processing is enabled, which is done automatically if this method is overridden, and can be toggled with [method set_process_unhandled_input]. @@ -107,10 +95,8 @@ </description> </method> <method name="_unhandled_key_input" qualifiers="virtual"> - <return type="void"> - </return> - <argument index="0" name="event" type="InputEventKey"> - </argument> + <return type="void" /> + <argument index="0" name="event" type="InputEventKey" /> <description> Called when an [InputEventKey] hasn't been consumed by [method _input] or any GUI. The input event propagates up through the node tree until a node consumes it. It is only called if unhandled key input processing is enabled, which is done automatically if this method is overridden, and can be toggled with [method set_process_unhandled_key_input]. @@ -120,12 +106,9 @@ </description> </method> <method name="add_child"> - <return type="void"> - </return> - <argument index="0" name="node" type="Node"> - </argument> - <argument index="1" name="legible_unique_name" type="bool" default="false"> - </argument> + <return type="void" /> + <argument index="0" name="node" type="Node" /> + <argument index="1" name="legible_unique_name" type="bool" default="false" /> <description> Adds a child node. Nodes can have any number of children, but every child must have a unique name. Child nodes are automatically deleted when the parent node is deleted, so an entire scene can be removed by deleting its topmost node. If [code]legible_unique_name[/code] is [code]true[/code], the child node will have a human-readable name based on the name of the node being instantiated instead of its type. @@ -151,12 +134,9 @@ </description> </method> <method name="add_sibling"> - <return type="void"> - </return> - <argument index="0" name="sibling" type="Node"> - </argument> - <argument index="1" name="legible_unique_name" type="bool" default="false"> - </argument> + <return type="void" /> + <argument index="0" name="sibling" type="Node" /> + <argument index="1" name="legible_unique_name" type="bool" default="false" /> <description> Adds a [code]sibling[/code] node to current's node parent, at the same level as that node, right below it. If [code]legible_unique_name[/code] is [code]true[/code], the child node will have a human-readable name based on the name of the node being instantiated instead of its type. @@ -164,27 +144,22 @@ </description> </method> <method name="add_to_group"> - <return type="void"> - </return> - <argument index="0" name="group" type="StringName"> - </argument> - <argument index="1" name="persistent" type="bool" default="false"> - </argument> + <return type="void" /> + <argument index="0" name="group" type="StringName" /> + <argument index="1" name="persistent" type="bool" default="false" /> <description> Adds the node to a group. Groups are helpers to name and organize a subset of nodes, for example "enemies" or "collectables". A node can be in any number of groups. Nodes can be assigned a group at any time, but will not be added until they are inside the scene tree (see [method is_inside_tree]). See notes in the description, and the group methods in [SceneTree]. The [code]persistent[/code] option is used when packing node to [PackedScene] and saving to file. Non-persistent groups aren't stored. </description> </method> <method name="can_process" qualifiers="const"> - <return type="bool"> - </return> + <return type="bool" /> <description> Returns [code]true[/code] if the node can process while the scene tree is paused (see [member process_mode]). Always returns [code]true[/code] if the scene tree is not paused, and [code]false[/code] if the node is not in the tree. </description> </method> <method name="create_tween"> - <return type="Tween"> - </return> + <return type="Tween" /> <description> Creates a new [Tween] and binds it to this node. This is equivalent of doing: [codeblock] @@ -193,10 +168,8 @@ </description> </method> <method name="duplicate" qualifiers="const"> - <return type="Node"> - </return> - <argument index="0" name="flags" type="int" default="15"> - </argument> + <return type="Node" /> + <argument index="0" name="flags" type="int" default="15" /> <description> Duplicates the node, returning a new node. You can fine-tune the behavior using the [code]flags[/code] (see [enum DuplicateFlags]). @@ -204,14 +177,10 @@ </description> </method> <method name="find_node" qualifiers="const"> - <return type="Node"> - </return> - <argument index="0" name="mask" type="String"> - </argument> - <argument index="1" name="recursive" type="bool" default="true"> - </argument> - <argument index="2" name="owned" type="bool" default="true"> - </argument> + <return type="Node" /> + <argument index="0" name="mask" type="String" /> + <argument index="1" name="recursive" type="bool" default="true" /> + <argument index="2" name="owned" type="bool" default="true" /> <description> Finds a descendant of this node whose name matches [code]mask[/code] as in [method String.match] (i.e. case-sensitive, but [code]"*"[/code] matches zero or more characters and [code]"?"[/code] matches any single character except [code]"."[/code]). [b]Note:[/b] It does not match against the full path, just against individual node names. @@ -220,10 +189,8 @@ </description> </method> <method name="find_parent" qualifiers="const"> - <return type="Node"> - </return> - <argument index="0" name="mask" type="String"> - </argument> + <return type="Node" /> + <argument index="0" name="mask" type="String" /> <description> Finds the first parent of the current node whose name matches [code]mask[/code] as in [method String.match] (i.e. case-sensitive, but [code]"*"[/code] matches zero or more characters and [code]"?"[/code] matches any single character except [code]"."[/code]). [b]Note:[/b] It does not match against the full path, just against individual node names. @@ -231,10 +198,8 @@ </description> </method> <method name="get_child" qualifiers="const"> - <return type="Node"> - </return> - <argument index="0" name="idx" type="int"> - </argument> + <return type="Node" /> + <argument index="0" name="idx" type="int" /> <description> Returns a child node by its index (see [method get_child_count]). This method is often used for iterating all children of a node. Negative indices access the children from the last one. @@ -242,51 +207,43 @@ </description> </method> <method name="get_child_count" qualifiers="const"> - <return type="int"> - </return> + <return type="int" /> <description> Returns the number of child nodes. </description> </method> <method name="get_children" qualifiers="const"> - <return type="Node[]"> - </return> + <return type="Node[]" /> <description> Returns an array of references to node's children. </description> </method> <method name="get_editor_description" qualifiers="const"> - <return type="String"> - </return> + <return type="String" /> <description> </description> </method> <method name="get_groups" qualifiers="const"> - <return type="Array"> - </return> + <return type="Array" /> <description> Returns an array listing the groups that the node is a member of. </description> </method> <method name="get_index" qualifiers="const"> - <return type="int"> - </return> + <return type="int" /> <description> Returns the node's order in the scene tree branch. For example, if called on the first child node the position is [code]0[/code]. </description> </method> <method name="get_network_master" qualifiers="const"> - <return type="int"> - </return> + <return type="int" /> <description> Returns the peer ID of the network master for this node. See [method set_network_master]. </description> </method> <method name="get_node" qualifiers="const"> - <return type="Node"> - </return> - <argument index="0" name="path" type="NodePath"> - </argument> + <return type="Node" /> + <argument index="0" name="path" type="NodePath" /> <description> Fetches a node. The [NodePath] can be either a relative path (from the current node) or an absolute path (in the scene tree) to a node. If the path does not exist, a [code]null instance[/code] is returned and an error is logged. Attempts to access methods on the return value will result in an "Attempt to call <method> on a null instance." error. [b]Note:[/b] Fetching absolute paths only works when the node is inside the scene tree (see [method is_inside_tree]). @@ -319,10 +276,8 @@ </description> </method> <method name="get_node_and_resource"> - <return type="Array"> - </return> - <argument index="0" name="path" type="NodePath"> - </argument> + <return type="Array" /> + <argument index="0" name="path" type="NodePath" /> <description> Fetches a node and one of its resources as specified by the [NodePath]'s subname (e.g. [code]Area2D/CollisionShape2D:shape[/code]). If several nested resources are specified in the [NodePath], the last one will be fetched. The return value is an array of size 3: the first index points to the [Node] (or [code]null[/code] if not found), the second index points to the [Resource] (or [code]null[/code] if not found), and the third index is the remaining [NodePath], if any. @@ -342,208 +297,172 @@ </description> </method> <method name="get_node_or_null" qualifiers="const"> - <return type="Node"> - </return> - <argument index="0" name="path" type="NodePath"> - </argument> + <return type="Node" /> + <argument index="0" name="path" type="NodePath" /> <description> Similar to [method get_node], but does not log an error if [code]path[/code] does not point to a valid [Node]. </description> </method> <method name="get_parent" qualifiers="const"> - <return type="Node"> - </return> + <return type="Node" /> <description> Returns the parent node of the current node, or a [code]null instance[/code] if the node lacks a parent. </description> </method> <method name="get_path" qualifiers="const"> - <return type="NodePath"> - </return> + <return type="NodePath" /> <description> Returns the absolute path of the current node. This only works if the current node is inside the scene tree (see [method is_inside_tree]). </description> </method> <method name="get_path_to" qualifiers="const"> - <return type="NodePath"> - </return> - <argument index="0" name="node" type="Node"> - </argument> + <return type="NodePath" /> + <argument index="0" name="node" type="Node" /> <description> Returns the relative [NodePath] from this node to the specified [code]node[/code]. Both nodes must be in the same scene or the function will fail. </description> </method> <method name="get_physics_process_delta_time" qualifiers="const"> - <return type="float"> - </return> + <return type="float" /> <description> Returns the time elapsed (in seconds) since the last physics-bound frame (see [method _physics_process]). This is always a constant value in physics processing unless the frames per second is changed via [member Engine.iterations_per_second]. </description> </method> <method name="get_process_delta_time" qualifiers="const"> - <return type="float"> - </return> + <return type="float" /> <description> Returns the time elapsed (in seconds) since the last process callback. This value may vary from frame to frame. </description> </method> <method name="get_scene_instance_load_placeholder" qualifiers="const"> - <return type="bool"> - </return> + <return type="bool" /> <description> Returns [code]true[/code] if this is an instance load placeholder. See [InstancePlaceholder]. </description> </method> <method name="get_tree" qualifiers="const"> - <return type="SceneTree"> - </return> + <return type="SceneTree" /> <description> Returns the [SceneTree] that contains this node. </description> </method> <method name="get_viewport" qualifiers="const"> - <return type="Viewport"> - </return> + <return type="Viewport" /> <description> Returns the node's [Viewport]. </description> </method> <method name="has_node" qualifiers="const"> - <return type="bool"> - </return> - <argument index="0" name="path" type="NodePath"> - </argument> + <return type="bool" /> + <argument index="0" name="path" type="NodePath" /> <description> Returns [code]true[/code] if the node that the [NodePath] points to exists. </description> </method> <method name="has_node_and_resource" qualifiers="const"> - <return type="bool"> - </return> - <argument index="0" name="path" type="NodePath"> - </argument> + <return type="bool" /> + <argument index="0" name="path" type="NodePath" /> <description> Returns [code]true[/code] if the [NodePath] points to a valid node and its subname points to a valid resource, e.g. [code]Area2D/CollisionShape2D:shape[/code]. Properties with a non-[Resource] type (e.g. nodes or primitive math types) are not considered resources. </description> </method> <method name="is_ancestor_of" qualifiers="const"> - <return type="bool"> - </return> - <argument index="0" name="node" type="Node"> - </argument> + <return type="bool" /> + <argument index="0" name="node" type="Node" /> <description> Returns [code]true[/code] if the given node is a direct or indirect child of the current node. </description> </method> <method name="is_displayed_folded" qualifiers="const"> - <return type="bool"> - </return> + <return type="bool" /> <description> Returns [code]true[/code] if the node is folded (collapsed) in the Scene dock. </description> </method> <method name="is_greater_than" qualifiers="const"> - <return type="bool"> - </return> - <argument index="0" name="node" type="Node"> - </argument> + <return type="bool" /> + <argument index="0" name="node" type="Node" /> <description> Returns [code]true[/code] if the given node occurs later in the scene hierarchy than the current node. </description> </method> <method name="is_in_group" qualifiers="const"> - <return type="bool"> - </return> - <argument index="0" name="group" type="StringName"> - </argument> + <return type="bool" /> + <argument index="0" name="group" type="StringName" /> <description> Returns [code]true[/code] if this node is in the specified group. See notes in the description, and the group methods in [SceneTree]. </description> </method> <method name="is_inside_tree" qualifiers="const"> - <return type="bool"> - </return> + <return type="bool" /> <description> Returns [code]true[/code] if this node is currently inside a [SceneTree]. </description> </method> <method name="is_network_master" qualifiers="const"> - <return type="bool"> - </return> + <return type="bool" /> <description> Returns [code]true[/code] if the local system is the master of this node. </description> </method> <method name="is_physics_processing" qualifiers="const"> - <return type="bool"> - </return> + <return type="bool" /> <description> Returns [code]true[/code] if physics processing is enabled (see [method set_physics_process]). </description> </method> <method name="is_physics_processing_internal" qualifiers="const"> - <return type="bool"> - </return> + <return type="bool" /> <description> Returns [code]true[/code] if internal physics processing is enabled (see [method set_physics_process_internal]). </description> </method> <method name="is_processing" qualifiers="const"> - <return type="bool"> - </return> + <return type="bool" /> <description> Returns [code]true[/code] if processing is enabled (see [method set_process]). </description> </method> <method name="is_processing_input" qualifiers="const"> - <return type="bool"> - </return> + <return type="bool" /> <description> Returns [code]true[/code] if the node is processing input (see [method set_process_input]). </description> </method> <method name="is_processing_internal" qualifiers="const"> - <return type="bool"> - </return> + <return type="bool" /> <description> Returns [code]true[/code] if internal processing is enabled (see [method set_process_internal]). </description> </method> <method name="is_processing_unhandled_input" qualifiers="const"> - <return type="bool"> - </return> + <return type="bool" /> <description> Returns [code]true[/code] if the node is processing unhandled input (see [method set_process_unhandled_input]). </description> </method> <method name="is_processing_unhandled_key_input" qualifiers="const"> - <return type="bool"> - </return> + <return type="bool" /> <description> Returns [code]true[/code] if the node is processing unhandled key input (see [method set_process_unhandled_key_input]). </description> </method> <method name="move_child"> - <return type="void"> - </return> - <argument index="0" name="child_node" type="Node"> - </argument> - <argument index="1" name="to_position" type="int"> - </argument> + <return type="void" /> + <argument index="0" name="child_node" type="Node" /> + <argument index="1" name="to_position" type="int" /> <description> Moves a child node to a different position (order) among the other children. Since calls, signals, etc are performed by tree order, changing the order of children nodes may be useful. </description> </method> <method name="print_stray_nodes"> - <return type="void"> - </return> + <return type="void" /> <description> Prints all stray nodes (nodes outside the [SceneTree]). Used for debugging. Works only in debug builds. </description> </method> <method name="print_tree"> - <return type="void"> - </return> + <return type="void" /> <description> Prints the tree to stdout. Used mainly for debugging purposes. This version displays the path relative to the current node, and is good for copy/pasting into the [method get_node] function. [b]Example output:[/b] @@ -558,8 +477,7 @@ </description> </method> <method name="print_tree_pretty"> - <return type="void"> - </return> + <return type="void" /> <description> Similar to [method print_tree], this prints the tree to stdout. This version displays a more graphical representation similar to what is displayed in the scene inspector. It is useful for inspecting larger trees. [b]Example output:[/b] @@ -574,226 +492,175 @@ </description> </method> <method name="propagate_call"> - <return type="void"> - </return> - <argument index="0" name="method" type="StringName"> - </argument> - <argument index="1" name="args" type="Array" default="[]"> - </argument> - <argument index="2" name="parent_first" type="bool" default="false"> - </argument> + <return type="void" /> + <argument index="0" name="method" type="StringName" /> + <argument index="1" name="args" type="Array" default="[]" /> + <argument index="2" name="parent_first" type="bool" default="false" /> <description> Calls the given method (if present) with the arguments given in [code]args[/code] on this node and recursively on all its children. If the [code]parent_first[/code] argument is [code]true[/code], the method will be called on the current node first, then on all its children. If [code]parent_first[/code] is [code]false[/code], the children will be called first. </description> </method> <method name="propagate_notification"> - <return type="void"> - </return> - <argument index="0" name="what" type="int"> - </argument> + <return type="void" /> + <argument index="0" name="what" type="int" /> <description> Notifies the current node and all its children recursively by calling [method Object.notification] on all of them. </description> </method> <method name="queue_free"> - <return type="void"> - </return> + <return type="void" /> <description> Queues a node for deletion at the end of the current frame. When deleted, all of its child nodes will be deleted as well. This method ensures it's safe to delete the node, contrary to [method Object.free]. Use [method Object.is_queued_for_deletion] to check whether a node will be deleted at the end of the frame. </description> </method> <method name="raise"> - <return type="void"> - </return> + <return type="void" /> <description> Moves this node to the bottom of parent node's children hierarchy. This is often useful in GUIs ([Control] nodes), because their order of drawing depends on their order in the tree. The top Node is drawn first, then any siblings below the top Node in the hierarchy are successively drawn on top of it. After using [code]raise[/code], a Control will be drawn on top of its siblings. </description> </method> <method name="remove_and_skip"> - <return type="void"> - </return> + <return type="void" /> <description> Removes a node and sets all its children as children of the parent node (if it exists). All event subscriptions that pass by the removed node will be unsubscribed. </description> </method> <method name="remove_child"> - <return type="void"> - </return> - <argument index="0" name="node" type="Node"> - </argument> + <return type="void" /> + <argument index="0" name="node" type="Node" /> <description> Removes a child node. The node is NOT deleted and must be deleted manually. </description> </method> <method name="remove_from_group"> - <return type="void"> - </return> - <argument index="0" name="group" type="StringName"> - </argument> + <return type="void" /> + <argument index="0" name="group" type="StringName" /> <description> Removes a node from a group. See notes in the description, and the group methods in [SceneTree]. </description> </method> <method name="replace_by"> - <return type="void"> - </return> - <argument index="0" name="node" type="Node"> - </argument> - <argument index="1" name="keep_groups" type="bool" default="false"> - </argument> + <return type="void" /> + <argument index="0" name="node" type="Node" /> + <argument index="1" name="keep_groups" type="bool" default="false" /> <description> Replaces a node in a scene by the given one. Subscriptions that pass through this node will be lost. If [code]keep_groups[/code] is [code]true[/code], the [code]node[/code] is added to the same groups that the replaced node is in. </description> </method> <method name="request_ready"> - <return type="void"> - </return> + <return type="void" /> <description> Requests that [code]_ready[/code] be called again. Note that the method won't be called immediately, but is scheduled for when the node is added to the scene tree again (see [method _ready]). [code]_ready[/code] is called only for the node which requested it, which means that you need to request ready for each child if you want them to call [code]_ready[/code] too (in which case, [code]_ready[/code] will be called in the same order as it would normally). </description> </method> <method name="rpc" qualifiers="vararg"> - <return type="Variant"> - </return> - <argument index="0" name="method" type="StringName"> - </argument> + <return type="Variant" /> + <argument index="0" name="method" type="StringName" /> <description> Sends a remote procedure call request for the given [code]method[/code] to peers on the network (and locally), optionally sending all additional arguments as arguments to the method called by the RPC. The call request will only be received by nodes with the same [NodePath], including the exact same node name. Behaviour depends on the RPC configuration for the given method, see [method rpc_config]. Methods are not exposed to RPCs by default. Returns an empty [Variant]. [b]Note:[/b] You can only safely use RPCs on clients after you received the [code]connected_to_server[/code] signal from the [MultiplayerAPI]. You also need to keep track of the connection state, either by the [MultiplayerAPI] signals like [code]server_disconnected[/code] or by checking [code]get_multiplayer().network_peer.get_connection_status() == CONNECTION_CONNECTED[/code]. </description> </method> <method name="rpc_config"> - <return type="int"> - </return> - <argument index="0" name="method" type="StringName"> - </argument> - <argument index="1" name="rpc_mode" type="int" enum="MultiplayerAPI.RPCMode"> - </argument> - <argument index="2" name="transfer_mode" type="int" enum="MultiplayerPeer.TransferMode" default="2"> - </argument> - <argument index="3" name="channel" type="int" default="0"> - </argument> + <return type="int" /> + <argument index="0" name="method" type="StringName" /> + <argument index="1" name="rpc_mode" type="int" enum="MultiplayerAPI.RPCMode" /> + <argument index="2" name="transfer_mode" type="int" enum="MultiplayerPeer.TransferMode" default="2" /> + <argument index="3" name="channel" type="int" default="0" /> <description> Changes the RPC mode for the given [code]method[/code] to the given [code]rpc_mode[/code], optionally specifying the [code]transfer_mode[/code] and [code]channel[/code] (on supported peers). See [enum MultiplayerAPI.RPCMode] and [enum MultiplayerPeer.TransferMode]. An alternative is annotating methods and properties with the corresponding keywords ([code]remote[/code], [code]master[/code], [code]puppet[/code], [code]remotesync[/code], [code]mastersync[/code], [code]puppetsync[/code]). By default, methods are not exposed to networking (and RPCs). </description> </method> <method name="rpc_id" qualifiers="vararg"> - <return type="Variant"> - </return> - <argument index="0" name="peer_id" type="int"> - </argument> - <argument index="1" name="method" type="StringName"> - </argument> + <return type="Variant" /> + <argument index="0" name="peer_id" type="int" /> + <argument index="1" name="method" type="StringName" /> <description> Sends a [method rpc] to a specific peer identified by [code]peer_id[/code] (see [method MultiplayerPeer.set_target_peer]). Returns an empty [Variant]. </description> </method> <method name="set_display_folded"> - <return type="void"> - </return> - <argument index="0" name="fold" type="bool"> - </argument> + <return type="void" /> + <argument index="0" name="fold" type="bool" /> <description> Sets the folded state of the node in the Scene dock. </description> </method> <method name="set_editor_description"> - <return type="void"> - </return> - <argument index="0" name="editor_description" type="String"> - </argument> + <return type="void" /> + <argument index="0" name="editor_description" type="String" /> <description> </description> </method> <method name="set_network_master"> - <return type="void"> - </return> - <argument index="0" name="id" type="int"> - </argument> - <argument index="1" name="recursive" type="bool" default="true"> - </argument> + <return type="void" /> + <argument index="0" name="id" type="int" /> + <argument index="1" name="recursive" type="bool" default="true" /> <description> Sets the node's network master to the peer with the given peer ID. The network master is the peer that has authority over the node on the network. Useful in conjunction with the [code]master[/code] and [code]puppet[/code] keywords. Inherited from the parent node by default, which ultimately defaults to peer ID 1 (the server). If [code]recursive[/code], the given peer is recursively set as the master for all children of this node. </description> </method> <method name="set_physics_process"> - <return type="void"> - </return> - <argument index="0" name="enable" type="bool"> - </argument> + <return type="void" /> + <argument index="0" name="enable" type="bool" /> <description> Enables or disables physics (i.e. fixed framerate) processing. When a node is being processed, it will receive a [constant NOTIFICATION_PHYSICS_PROCESS] at a fixed (usually 60 FPS, see [member Engine.iterations_per_second] to change) interval (and the [method _physics_process] callback will be called if exists). Enabled automatically if [method _physics_process] is overridden. Any calls to this before [method _ready] will be ignored. </description> </method> <method name="set_physics_process_internal"> - <return type="void"> - </return> - <argument index="0" name="enable" type="bool"> - </argument> + <return type="void" /> + <argument index="0" name="enable" type="bool" /> <description> Enables or disables internal physics for this node. Internal physics processing happens in isolation from the normal [method _physics_process] calls and is used by some nodes internally to guarantee proper functioning even if the node is paused or physics processing is disabled for scripting ([method set_physics_process]). Only useful for advanced uses to manipulate built-in nodes' behavior. [b]Warning:[/b] Built-in Nodes rely on the internal processing for their own logic, so changing this value from your code may lead to unexpected behavior. Script access to this internal logic is provided for specific advanced uses, but is unsafe and not supported. </description> </method> <method name="set_process"> - <return type="void"> - </return> - <argument index="0" name="enable" type="bool"> - </argument> + <return type="void" /> + <argument index="0" name="enable" type="bool" /> <description> Enables or disables processing. When a node is being processed, it will receive a [constant NOTIFICATION_PROCESS] on every drawn frame (and the [method _process] callback will be called if exists). Enabled automatically if [method _process] is overridden. Any calls to this before [method _ready] will be ignored. </description> </method> <method name="set_process_input"> - <return type="void"> - </return> - <argument index="0" name="enable" type="bool"> - </argument> + <return type="void" /> + <argument index="0" name="enable" type="bool" /> <description> Enables or disables input processing. This is not required for GUI controls! Enabled automatically if [method _input] is overridden. Any calls to this before [method _ready] will be ignored. </description> </method> <method name="set_process_internal"> - <return type="void"> - </return> - <argument index="0" name="enable" type="bool"> - </argument> + <return type="void" /> + <argument index="0" name="enable" type="bool" /> <description> Enables or disabled internal processing for this node. Internal processing happens in isolation from the normal [method _process] calls and is used by some nodes internally to guarantee proper functioning even if the node is paused or processing is disabled for scripting ([method set_process]). Only useful for advanced uses to manipulate built-in nodes' behavior. [b]Warning:[/b] Built-in Nodes rely on the internal processing for their own logic, so changing this value from your code may lead to unexpected behavior. Script access to this internal logic is provided for specific advanced uses, but is unsafe and not supported. </description> </method> <method name="set_process_unhandled_input"> - <return type="void"> - </return> - <argument index="0" name="enable" type="bool"> - </argument> + <return type="void" /> + <argument index="0" name="enable" type="bool" /> <description> Enables unhandled input processing. This is not required for GUI controls! It enables the node to receive all input that was not previously handled (usually by a [Control]). Enabled automatically if [method _unhandled_input] is overridden. Any calls to this before [method _ready] will be ignored. </description> </method> <method name="set_process_unhandled_key_input"> - <return type="void"> - </return> - <argument index="0" name="enable" type="bool"> - </argument> + <return type="void" /> + <argument index="0" name="enable" type="bool" /> <description> Enables unhandled key input processing. Enabled automatically if [method _unhandled_key_input] is overridden. Any calls to this before [method _ready] will be ignored. </description> </method> <method name="set_scene_instance_load_placeholder"> - <return type="void"> - </return> - <argument index="0" name="load_placeholder" type="bool"> - </argument> + <return type="void" /> + <argument index="0" name="load_placeholder" type="bool" /> <description> Sets whether this is an instance load placeholder. See [InstancePlaceholder]. </description> </method> <method name="update_configuration_warnings"> - <return type="void"> - </return> + <return type="void" /> <description> Updates the warning displayed for this node in the Scene Dock. Use [method _get_configuration_warnings] to setup the warning message to display. diff --git a/doc/classes/Node2D.xml b/doc/classes/Node2D.xml index 9ffa333f17..cc790b7c28 100644 --- a/doc/classes/Node2D.xml +++ b/doc/classes/Node2D.xml @@ -12,104 +12,80 @@ </tutorials> <methods> <method name="apply_scale"> - <return type="void"> - </return> - <argument index="0" name="ratio" type="Vector2"> - </argument> + <return type="void" /> + <argument index="0" name="ratio" type="Vector2" /> <description> Multiplies the current scale by the [code]ratio[/code] vector. </description> </method> <method name="get_angle_to" qualifiers="const"> - <return type="float"> - </return> - <argument index="0" name="point" type="Vector2"> - </argument> + <return type="float" /> + <argument index="0" name="point" type="Vector2" /> <description> Returns the angle between the node and the [code]point[/code] in radians. </description> </method> <method name="get_relative_transform_to_parent" qualifiers="const"> - <return type="Transform2D"> - </return> - <argument index="0" name="parent" type="Node"> - </argument> + <return type="Transform2D" /> + <argument index="0" name="parent" type="Node" /> <description> Returns the [Transform2D] relative to this node's parent. </description> </method> <method name="global_translate"> - <return type="void"> - </return> - <argument index="0" name="offset" type="Vector2"> - </argument> + <return type="void" /> + <argument index="0" name="offset" type="Vector2" /> <description> Adds the [code]offset[/code] vector to the node's global position. </description> </method> <method name="look_at"> - <return type="void"> - </return> - <argument index="0" name="point" type="Vector2"> - </argument> + <return type="void" /> + <argument index="0" name="point" type="Vector2" /> <description> Rotates the node so it points towards the [code]point[/code], which is expected to use global coordinates. </description> </method> <method name="move_local_x"> - <return type="void"> - </return> - <argument index="0" name="delta" type="float"> - </argument> - <argument index="1" name="scaled" type="bool" default="false"> - </argument> + <return type="void" /> + <argument index="0" name="delta" type="float" /> + <argument index="1" name="scaled" type="bool" default="false" /> <description> Applies a local translation on the node's X axis based on the [method Node._process]'s [code]delta[/code]. If [code]scaled[/code] is [code]false[/code], normalizes the movement. </description> </method> <method name="move_local_y"> - <return type="void"> - </return> - <argument index="0" name="delta" type="float"> - </argument> - <argument index="1" name="scaled" type="bool" default="false"> - </argument> + <return type="void" /> + <argument index="0" name="delta" type="float" /> + <argument index="1" name="scaled" type="bool" default="false" /> <description> Applies a local translation on the node's Y axis based on the [method Node._process]'s [code]delta[/code]. If [code]scaled[/code] is [code]false[/code], normalizes the movement. </description> </method> <method name="rotate"> - <return type="void"> - </return> - <argument index="0" name="radians" type="float"> - </argument> + <return type="void" /> + <argument index="0" name="radians" type="float" /> <description> Applies a rotation to the node, in radians, starting from its current rotation. </description> </method> <method name="to_global" qualifiers="const"> - <return type="Vector2"> - </return> - <argument index="0" name="local_point" type="Vector2"> - </argument> + <return type="Vector2" /> + <argument index="0" name="local_point" type="Vector2" /> <description> Transforms the provided local position into a position in global coordinate space. The input is expected to be local relative to the [Node2D] it is called on. e.g. Applying this method to the positions of child nodes will correctly transform their positions into the global coordinate space, but applying it to a node's own position will give an incorrect result, as it will incorporate the node's own transformation into its global position. </description> </method> <method name="to_local" qualifiers="const"> - <return type="Vector2"> - </return> - <argument index="0" name="global_point" type="Vector2"> - </argument> + <return type="Vector2" /> + <argument index="0" name="global_point" type="Vector2" /> <description> Transforms the provided global position into a position in local coordinate space. The output will be local relative to the [Node2D] it is called on. e.g. It is appropriate for determining the positions of child nodes, but it is not appropriate for determining its own position relative to its parent. </description> </method> <method name="translate"> - <return type="void"> - </return> - <argument index="0" name="offset" type="Vector2"> - </argument> + <return type="void" /> + <argument index="0" name="offset" type="Vector2" /> <description> Translates the node by the given [code]offset[/code] in local coordinates. </description> diff --git a/doc/classes/Node3D.xml b/doc/classes/Node3D.xml index 14e03a2186..983d8961fb 100644 --- a/doc/classes/Node3D.xml +++ b/doc/classes/Node3D.xml @@ -13,98 +13,105 @@ <link title="All 3D Demos">https://github.com/godotengine/godot-demo-projects/tree/master/3d</link> </tutorials> <methods> + <method name="add_gizmo"> + <return type="void" /> + <argument index="0" name="gizmo" type="Node3DGizmo" /> + <description> + Attach a gizmo to this [code]Node3D[/code]. + </description> + </method> + <method name="clear_gizmos"> + <return type="void" /> + <description> + Clear all gizmos attached to this [code]Node3D[/code]. + </description> + </method> + <method name="clear_subgizmo_selection"> + <return type="void" /> + <description> + Clears subgizmo selection for this node in the editor. Useful when subgizmo IDs become invalid after a property change. + </description> + </method> <method name="force_update_transform"> - <return type="void"> - </return> + <return type="void" /> <description> Forces the transform to update. Transform changes in physics are not instant for performance reasons. Transforms are accumulated and then set. Use this if you need an up-to-date transform when doing physics operations. </description> </method> + <method name="get_gizmos" qualifiers="const"> + <return type="Array" /> + <description> + Returns all the gizmos attached to this [code]Node3D[/code]. + </description> + </method> <method name="get_parent_node_3d" qualifiers="const"> - <return type="Node3D"> - </return> + <return type="Node3D" /> <description> Returns the parent [Node3D], or an empty [Object] if no parent exists or parent is not of type [Node3D]. </description> </method> <method name="get_world_3d" qualifiers="const"> - <return type="World3D"> - </return> + <return type="World3D" /> <description> Returns the current [World3D] resource this [Node3D] node is registered to. </description> </method> <method name="global_rotate"> - <return type="void"> - </return> - <argument index="0" name="axis" type="Vector3"> - </argument> - <argument index="1" name="angle" type="float"> - </argument> + <return type="void" /> + <argument index="0" name="axis" type="Vector3" /> + <argument index="1" name="angle" type="float" /> <description> Rotates the global (world) transformation around axis, a unit [Vector3], by specified angle in radians. The rotation axis is in global coordinate system. </description> </method> <method name="global_scale"> - <return type="void"> - </return> - <argument index="0" name="scale" type="Vector3"> - </argument> + <return type="void" /> + <argument index="0" name="scale" type="Vector3" /> <description> Scales the global (world) transformation by the given [Vector3] scale factors. </description> </method> <method name="global_translate"> - <return type="void"> - </return> - <argument index="0" name="offset" type="Vector3"> - </argument> + <return type="void" /> + <argument index="0" name="offset" type="Vector3" /> <description> Moves the global (world) transformation by [Vector3] offset. The offset is in global coordinate system. </description> </method> <method name="hide"> - <return type="void"> - </return> + <return type="void" /> <description> Disables rendering of this node. Changes [member visible] to [code]false[/code]. </description> </method> <method name="is_local_transform_notification_enabled" qualifiers="const"> - <return type="bool"> - </return> + <return type="bool" /> <description> Returns whether node notifies about its local transformation changes. [Node3D] will not propagate this by default. </description> </method> <method name="is_scale_disabled" qualifiers="const"> - <return type="bool"> - </return> + <return type="bool" /> <description> Returns whether this node uses a scale of [code](1, 1, 1)[/code] or its local transformation scale. </description> </method> <method name="is_transform_notification_enabled" qualifiers="const"> - <return type="bool"> - </return> + <return type="bool" /> <description> Returns whether the node notifies about its global and local transformation changes. [Node3D] will not propagate this by default. </description> </method> <method name="is_visible_in_tree" qualifiers="const"> - <return type="bool"> - </return> + <return type="bool" /> <description> Returns [code]true[/code] if the node is present in the [SceneTree], its [member visible] property is [code]true[/code] and all its antecedents are also visible. If any antecedent is hidden, this node will not be visible in the scene tree. </description> </method> <method name="look_at"> - <return type="void"> - </return> - <argument index="0" name="target" type="Vector3"> - </argument> - <argument index="1" name="up" type="Vector3" default="Vector3(0, 1, 0)"> - </argument> + <return type="void" /> + <argument index="0" name="target" type="Vector3" /> + <argument index="1" name="up" type="Vector3" default="Vector3(0, 1, 0)" /> <description> Rotates itself so that the local -Z axis points towards the [code]target[/code] position. The transform will first be rotated around the given [code]up[/code] vector, and then fully aligned to the target by a further rotation around an axis perpendicular to both the [code]target[/code] and [code]up[/code] vectors. @@ -112,182 +119,141 @@ </description> </method> <method name="look_at_from_position"> - <return type="void"> - </return> - <argument index="0" name="position" type="Vector3"> - </argument> - <argument index="1" name="target" type="Vector3"> - </argument> - <argument index="2" name="up" type="Vector3" default="Vector3(0, 1, 0)"> - </argument> + <return type="void" /> + <argument index="0" name="position" type="Vector3" /> + <argument index="1" name="target" type="Vector3" /> + <argument index="2" name="up" type="Vector3" default="Vector3(0, 1, 0)" /> <description> Moves the node to the specified [code]position[/code], and then rotates itself to point toward the [code]target[/code] as per [method look_at]. Operations take place in global space. </description> </method> <method name="orthonormalize"> - <return type="void"> - </return> + <return type="void" /> <description> Resets this node's transformations (like scale, skew and taper) preserving its rotation and translation by performing Gram-Schmidt orthonormalization on this node's [Transform3D]. </description> </method> <method name="rotate"> - <return type="void"> - </return> - <argument index="0" name="axis" type="Vector3"> - </argument> - <argument index="1" name="angle" type="float"> - </argument> + <return type="void" /> + <argument index="0" name="axis" type="Vector3" /> + <argument index="1" name="angle" type="float" /> <description> Rotates the local transformation around axis, a unit [Vector3], by specified angle in radians. </description> </method> <method name="rotate_object_local"> - <return type="void"> - </return> - <argument index="0" name="axis" type="Vector3"> - </argument> - <argument index="1" name="angle" type="float"> - </argument> + <return type="void" /> + <argument index="0" name="axis" type="Vector3" /> + <argument index="1" name="angle" type="float" /> <description> Rotates the local transformation around axis, a unit [Vector3], by specified angle in radians. The rotation axis is in object-local coordinate system. </description> </method> <method name="rotate_x"> - <return type="void"> - </return> - <argument index="0" name="angle" type="float"> - </argument> + <return type="void" /> + <argument index="0" name="angle" type="float" /> <description> Rotates the local transformation around the X axis by angle in radians. </description> </method> <method name="rotate_y"> - <return type="void"> - </return> - <argument index="0" name="angle" type="float"> - </argument> + <return type="void" /> + <argument index="0" name="angle" type="float" /> <description> Rotates the local transformation around the Y axis by angle in radians. </description> </method> <method name="rotate_z"> - <return type="void"> - </return> - <argument index="0" name="angle" type="float"> - </argument> + <return type="void" /> + <argument index="0" name="angle" type="float" /> <description> Rotates the local transformation around the Z axis by angle in radians. </description> </method> <method name="scale_object_local"> - <return type="void"> - </return> - <argument index="0" name="scale" type="Vector3"> - </argument> + <return type="void" /> + <argument index="0" name="scale" type="Vector3" /> <description> Scales the local transformation by given 3D scale factors in object-local coordinate system. </description> </method> <method name="set_disable_scale"> - <return type="void"> - </return> - <argument index="0" name="disable" type="bool"> - </argument> + <return type="void" /> + <argument index="0" name="disable" type="bool" /> <description> Sets whether the node uses a scale of [code](1, 1, 1)[/code] or its local transformation scale. Changes to the local transformation scale are preserved. </description> </method> <method name="set_identity"> - <return type="void"> - </return> + <return type="void" /> <description> Reset all transformations for this node (sets its [Transform3D] to the identity matrix). </description> </method> <method name="set_ignore_transform_notification"> - <return type="void"> - </return> - <argument index="0" name="enabled" type="bool"> - </argument> + <return type="void" /> + <argument index="0" name="enabled" type="bool" /> <description> Sets whether the node ignores notification that its transformation (global or local) changed. </description> </method> <method name="set_notify_local_transform"> - <return type="void"> - </return> - <argument index="0" name="enable" type="bool"> - </argument> + <return type="void" /> + <argument index="0" name="enable" type="bool" /> <description> Sets whether the node notifies about its local transformation changes. [Node3D] will not propagate this by default. </description> </method> <method name="set_notify_transform"> - <return type="void"> - </return> - <argument index="0" name="enable" type="bool"> - </argument> + <return type="void" /> + <argument index="0" name="enable" type="bool" /> <description> Sets whether the node notifies about its global and local transformation changes. [Node3D] will not propagate this by default, unless it is in the editor context and it has a valid gizmo. </description> </method> <method name="show"> - <return type="void"> - </return> + <return type="void" /> <description> Enables rendering of this node. Changes [member visible] to [code]true[/code]. </description> </method> <method name="to_global" qualifiers="const"> - <return type="Vector3"> - </return> - <argument index="0" name="local_point" type="Vector3"> - </argument> + <return type="Vector3" /> + <argument index="0" name="local_point" type="Vector3" /> <description> Transforms [code]local_point[/code] from this node's local space to world space. </description> </method> <method name="to_local" qualifiers="const"> - <return type="Vector3"> - </return> - <argument index="0" name="global_point" type="Vector3"> - </argument> + <return type="Vector3" /> + <argument index="0" name="global_point" type="Vector3" /> <description> Transforms [code]global_point[/code] from world space to this node's local space. </description> </method> <method name="translate"> - <return type="void"> - </return> - <argument index="0" name="offset" type="Vector3"> - </argument> + <return type="void" /> + <argument index="0" name="offset" type="Vector3" /> <description> Changes the node's position by the given offset [Vector3]. Note that the translation [code]offset[/code] is affected by the node's scale, so if scaled by e.g. [code](10, 1, 1)[/code], a translation by an offset of [code](2, 0, 0)[/code] would actually add 20 ([code]2 * 10[/code]) to the X coordinate. </description> </method> <method name="translate_object_local"> - <return type="void"> - </return> - <argument index="0" name="offset" type="Vector3"> - </argument> + <return type="void" /> + <argument index="0" name="offset" type="Vector3" /> <description> Changes the node's position by the given offset [Vector3] in local space. </description> </method> - <method name="update_gizmo"> - <return type="void"> - </return> + <method name="update_gizmos"> + <return type="void" /> <description> - Updates the [Node3DGizmo] of this node. + Updates all the [Node3DGizmo]s attached to this node. </description> </method> </methods> <members> - <member name="gizmo" type="Node3DGizmo" setter="set_gizmo" getter="get_gizmo"> - The [Node3DGizmo] for this node. Used for example in [EditorNode3DGizmo] as custom visualization and editing handles in Editor. - </member> <member name="global_transform" type="Transform3D" setter="set_global_transform" getter="get_global_transform"> World3D space (global) [Transform3D] of this node. </member> @@ -308,7 +274,7 @@ Local space [Transform3D] of this node, with respect to the parent node. </member> <member name="visibility_parent" type="NodePath" setter="set_visibility_parent" getter="get_visibility_parent" default="NodePath("")"> - Defines the visibility range parent for this node and its subtree. The visibility parent must be a GeometryInstance3D. Any visual instance will only be visible if the visibility parent (and all of its visibility ancestors) is hidden by being closer to the camera than its own [member GeometryInstance3D.visibility_range_begin]. Nodes hidden via the [member Node3D.visible] property are essentially removed from the visibility dependency tree, so dependant instances will not take the hidden node or its ancestors into account. + Defines the visibility range parent for this node and its subtree. The visibility parent must be a GeometryInstance3D. Any visual instance will only be visible if the visibility parent (and all of its visibility ancestors) is hidden by being closer to the camera than its own [member GeometryInstance3D.visibility_range_begin]. Nodes hidden via the [member Node3D.visible] property are essentially removed from the visibility dependency tree, so dependent instances will not take the hidden node or its ancestors into account. </member> <member name="visible" type="bool" setter="set_visible" getter="is_visible" default="true"> If [code]true[/code], this node is drawn. The node is only visible if all of its antecedents are visible as well (in other words, [method is_visible_in_tree] must return [code]true[/code]). @@ -324,7 +290,7 @@ <constants> <constant name="NOTIFICATION_TRANSFORM_CHANGED" value="2000"> Node3D nodes receives this notification when their global transform changes. This means that either the current or a parent node changed its transform. - In order for [constant NOTIFICATION_TRANSFORM_CHANGED] to work, users first need to ask for it, with [method set_notify_transform]. The notification is also sent if the node is in the editor context and it has a valid gizmo. + In order for [constant NOTIFICATION_TRANSFORM_CHANGED] to work, users first need to ask for it, with [method set_notify_transform]. The notification is also sent if the node is in the editor context and it has at least one valid gizmo. </constant> <constant name="NOTIFICATION_ENTER_WORLD" value="41"> Node3D nodes receives this notification when they are registered to new [World3D] resource. diff --git a/doc/classes/NodePath.xml b/doc/classes/NodePath.xml index 0ba2e73ad4..d05630d277 100644 --- a/doc/classes/NodePath.xml +++ b/doc/classes/NodePath.xml @@ -27,26 +27,21 @@ </tutorials> <methods> <method name="NodePath" qualifiers="constructor"> - <return type="NodePath"> - </return> + <return type="NodePath" /> <description> Constructs an empty [NodePath]. </description> </method> <method name="NodePath" qualifiers="constructor"> - <return type="NodePath"> - </return> - <argument index="0" name="from" type="NodePath"> - </argument> + <return type="NodePath" /> + <argument index="0" name="from" type="NodePath" /> <description> Constructs a [NodePath] as a copy of the given [NodePath]. </description> </method> <method name="NodePath" qualifiers="constructor"> - <return type="NodePath"> - </return> - <argument index="0" name="from" type="String"> - </argument> + <return type="NodePath" /> + <argument index="0" name="from" type="String" /> <description> Creates a NodePath from a string, e.g. [code]"Path2D/PathFollow2D/Sprite2D:texture:size"[/code]. A path is absolute if it starts with a slash. Absolute paths are only valid in the global scene tree, not within individual scenes. In a relative path, [code]"."[/code] and [code]".."[/code] indicate the current node and its parent. The "subnames" optionally included after the path to the target node can point to resources or properties, and can also be nested. @@ -68,8 +63,7 @@ </description> </method> <method name="get_as_property_path" qualifiers="const"> - <return type="NodePath"> - </return> + <return type="NodePath" /> <description> Returns a node path with a colon character ([code]:[/code]) prepended, transforming it to a pure property path with no node name (defaults to resolving from the current node). [codeblocks] @@ -91,8 +85,7 @@ </description> </method> <method name="get_concatenated_subnames" qualifiers="const"> - <return type="StringName"> - </return> + <return type="StringName" /> <description> Returns all subnames concatenated with a colon character ([code]:[/code]) as separator, i.e. the right side of the first colon in a node path. [codeblocks] @@ -108,10 +101,8 @@ </description> </method> <method name="get_name" qualifiers="const"> - <return type="StringName"> - </return> - <argument index="0" name="idx" type="int"> - </argument> + <return type="StringName" /> + <argument index="0" name="idx" type="int" /> <description> Gets the node name indicated by [code]idx[/code] (0 to [method get_name_count]). [codeblocks] @@ -131,18 +122,15 @@ </description> </method> <method name="get_name_count" qualifiers="const"> - <return type="int"> - </return> + <return type="int" /> <description> Gets the number of node names which make up the path. Subnames (see [method get_subname_count]) are not included. For example, [code]"Path2D/PathFollow2D/Sprite2D"[/code] has 3 names. </description> </method> <method name="get_subname" qualifiers="const"> - <return type="StringName"> - </return> - <argument index="0" name="idx" type="int"> - </argument> + <return type="StringName" /> + <argument index="0" name="idx" type="int" /> <description> Gets the resource or property name indicated by [code]idx[/code] (0 to [method get_subname_count]). [codeblocks] @@ -160,40 +148,33 @@ </description> </method> <method name="get_subname_count" qualifiers="const"> - <return type="int"> - </return> + <return type="int" /> <description> Gets the number of resource or property names ("subnames") in the path. Each subname is listed after a colon character ([code]:[/code]) in the node path. For example, [code]"Path2D/PathFollow2D/Sprite2D:texture:load_path"[/code] has 2 subnames. </description> </method> <method name="is_absolute" qualifiers="const"> - <return type="bool"> - </return> + <return type="bool" /> <description> Returns [code]true[/code] if the node path is absolute (as opposed to relative), which means that it starts with a slash character ([code]/[/code]). Absolute node paths can be used to access the root node ([code]"/root"[/code]) or autoloads (e.g. [code]"/global"[/code] if a "global" autoload was registered). </description> </method> <method name="is_empty" qualifiers="const"> - <return type="bool"> - </return> + <return type="bool" /> <description> Returns [code]true[/code] if the node path is empty. </description> </method> <method name="operator !=" qualifiers="operator"> - <return type="bool"> - </return> - <argument index="0" name="right" type="NodePath"> - </argument> + <return type="bool" /> + <argument index="0" name="right" type="NodePath" /> <description> </description> </method> <method name="operator ==" qualifiers="operator"> - <return type="bool"> - </return> - <argument index="0" name="right" type="NodePath"> - </argument> + <return type="bool" /> + <argument index="0" name="right" type="NodePath" /> <description> </description> </method> diff --git a/doc/classes/OS.xml b/doc/classes/OS.xml index a9396306f4..e5d45189c7 100644 --- a/doc/classes/OS.xml +++ b/doc/classes/OS.xml @@ -10,28 +10,31 @@ <link title="OS Test Demo">https://godotengine.org/asset-library/asset/677</link> </tutorials> <methods> + <method name="alert"> + <return type="void" /> + <argument index="0" name="text" type="String" /> + <argument index="1" name="title" type="String" default=""Alert!"" /> + <description> + Displays a modal dialog box using the host OS' facilities. Execution is blocked until the dialog is closed. + </description> + </method> <method name="can_use_threads" qualifiers="const"> - <return type="bool"> - </return> + <return type="bool" /> <description> Returns [code]true[/code] if the current host platform is using multiple threads. </description> </method> <method name="close_midi_inputs"> - <return type="void"> - </return> + <return type="void" /> <description> Shuts down system MIDI driver. [b]Note:[/b] This method is implemented on Linux, macOS and Windows. </description> </method> <method name="create_process"> - <return type="int"> - </return> - <argument index="0" name="path" type="String"> - </argument> - <argument index="1" name="arguments" type="PackedStringArray"> - </argument> + <return type="int" /> + <argument index="0" name="path" type="String" /> + <argument index="1" name="arguments" type="PackedStringArray" /> <description> Creates a new process that runs independently of Godot. It will not terminate if Godot terminates. The file specified in [code]path[/code] must exist and be executable. Platform path resolution will be used. The [code]arguments[/code] are used in the given order and separated by a space. If the process creation succeeds, the method will return the new process ID, which you can use to monitor the process (and potentially terminate it with [method kill]). If the process creation fails, the method will return [code]-1[/code]. @@ -49,38 +52,30 @@ </description> </method> <method name="delay_msec" qualifiers="const"> - <return type="void"> - </return> - <argument index="0" name="msec" type="int"> - </argument> + <return type="void" /> + <argument index="0" name="msec" type="int" /> <description> - Delay execution of the current thread by [code]msec[/code] milliseconds. [code]usec[/code] must be greater than or equal to [code]0[/code]. Otherwise, [method delay_msec] will do nothing and will print an error message. + Delay execution of the current thread by [code]msec[/code] milliseconds. [code]msec[/code] must be greater than or equal to [code]0[/code]. Otherwise, [method delay_msec] will do nothing and will print an error message. </description> </method> <method name="delay_usec" qualifiers="const"> - <return type="void"> - </return> - <argument index="0" name="usec" type="int"> - </argument> + <return type="void" /> + <argument index="0" name="usec" type="int" /> <description> Delay execution of the current thread by [code]usec[/code] microseconds. [code]usec[/code] must be greater than or equal to [code]0[/code]. Otherwise, [method delay_usec] will do nothing and will print an error message. </description> </method> <method name="dump_memory_to_file"> - <return type="void"> - </return> - <argument index="0" name="file" type="String"> - </argument> + <return type="void" /> + <argument index="0" name="file" type="String" /> <description> Dumps the memory allocation ringlist to a file (only works in debug). Entry format per line: "Address - Size - Description". </description> </method> <method name="dump_resources_to_file"> - <return type="void"> - </return> - <argument index="0" name="file" type="String"> - </argument> + <return type="void" /> + <argument index="0" name="file" type="String" /> <description> Dumps all used resources to file (only works in debug). Entry format per line: "Resource Type : Resource Location". @@ -88,16 +83,11 @@ </description> </method> <method name="execute"> - <return type="int"> - </return> - <argument index="0" name="path" type="String"> - </argument> - <argument index="1" name="arguments" type="PackedStringArray"> - </argument> - <argument index="2" name="output" type="Array" default="[]"> - </argument> - <argument index="3" name="read_stderr" type="bool" default="false"> - </argument> + <return type="int" /> + <argument index="0" name="path" type="String" /> + <argument index="1" name="arguments" type="PackedStringArray" /> + <argument index="2" name="output" type="Array" default="[]" /> + <argument index="3" name="read_stderr" type="bool" default="false" /> <description> Executes a command. The file specified in [code]path[/code] must exist and be executable. Platform path resolution will be used. The [code]arguments[/code] are used in the given order and separated by a space. If an [code]output[/code] [Array] is provided, the complete shell output of the process will be appended as a single [String] element in [code]output[/code]. If [code]read_stderr[/code] is [code]true[/code], the output to the standard error stream will be included too. If the command is successfully executed, the method will return the exit code of the command, or [code]-1[/code] if it fails. @@ -128,25 +118,21 @@ </description> </method> <method name="find_keycode_from_string" qualifiers="const"> - <return type="int"> - </return> - <argument index="0" name="string" type="String"> - </argument> + <return type="int" /> + <argument index="0" name="string" type="String" /> <description> Returns the keycode of the given string (e.g. "Escape"). </description> </method> <method name="get_cache_dir" qualifiers="const"> - <return type="String"> - </return> + <return type="String" /> <description> Returns the [i]global[/i] cache data directory according to the operating system's standards. On desktop platforms, this path can be overridden by setting the [code]XDG_CACHE_HOME[/code] environment variable before starting the project. See [url=https://docs.godotengine.org/en/latest/tutorials/io/data_paths.html]File paths in Godot projects[/url] in the documentation for more information. See also [method get_config_dir] and [method get_data_dir]. Not to be confused with [method get_user_data_dir], which returns the [i]project-specific[/i] user data path. </description> </method> <method name="get_cmdline_args"> - <return type="PackedStringArray"> - </return> + <return type="PackedStringArray" /> <description> Returns the command-line arguments passed to the engine. Command-line arguments can be written in any form, including both [code]--key value[/code] and [code]--key=value[/code] forms so they can be properly parsed, as long as custom command-line arguments do not conflict with engine arguments. @@ -176,16 +162,14 @@ </description> </method> <method name="get_config_dir" qualifiers="const"> - <return type="String"> - </return> + <return type="String" /> <description> Returns the [i]global[/i] user configuration directory according to the operating system's standards. On desktop platforms, this path can be overridden by setting the [code]XDG_CONFIG_HOME[/code] environment variable before starting the project. See [url=https://docs.godotengine.org/en/latest/tutorials/io/data_paths.html]File paths in Godot projects[/url] in the documentation for more information. See also [method get_cache_dir] and [method get_data_dir]. Not to be confused with [method get_user_data_dir], which returns the [i]project-specific[/i] user data path. </description> </method> <method name="get_connected_midi_inputs"> - <return type="PackedStringArray"> - </return> + <return type="PackedStringArray" /> <description> Returns an array of MIDI device names. The returned array will be empty if the system MIDI driver has not previously been initialised with [method open_midi_inputs]. @@ -193,141 +177,121 @@ </description> </method> <method name="get_data_dir" qualifiers="const"> - <return type="String"> - </return> + <return type="String" /> <description> Returns the [i]global[/i] user data directory according to the operating system's standards. On desktop platforms, this path can be overridden by setting the [code]XDG_DATA_HOME[/code] environment variable before starting the project. See [url=https://docs.godotengine.org/en/latest/tutorials/io/data_paths.html]File paths in Godot projects[/url] in the documentation for more information. See also [method get_cache_dir] and [method get_config_dir]. Not to be confused with [method get_user_data_dir], which returns the [i]project-specific[/i] user data path. </description> </method> <method name="get_environment" qualifiers="const"> - <return type="String"> - </return> - <argument index="0" name="variable" type="String"> - </argument> + <return type="String" /> + <argument index="0" name="variable" type="String" /> <description> Returns the value of an environment variable. Returns an empty string if the environment variable doesn't exist. [b]Note:[/b] Double-check the casing of [code]variable[/code]. Environment variable names are case-sensitive on all platforms except Windows. </description> </method> <method name="get_executable_path" qualifiers="const"> - <return type="String"> - </return> + <return type="String" /> <description> Returns the path to the current engine executable. </description> </method> <method name="get_external_data_dir" qualifiers="const"> - <return type="String"> - </return> + <return type="String" /> <description> On Android, returns the absolute directory path where user data can be written to external storage if available. On all other platforms, this will return the same location as [method get_user_data_dir]. </description> </method> <method name="get_granted_permissions" qualifiers="const"> - <return type="PackedStringArray"> - </return> + <return type="PackedStringArray" /> <description> - With this function you can get the list of dangerous permissions that have been granted to the Android application. + With this function, you can get the list of dangerous permissions that have been granted to the Android application. [b]Note:[/b] This method is implemented on Android. </description> </method> <method name="get_keycode_string" qualifiers="const"> - <return type="String"> - </return> - <argument index="0" name="code" type="int"> - </argument> + <return type="String" /> + <argument index="0" name="code" type="int" /> <description> Returns the given keycode as a string (e.g. Return values: [code]"Escape"[/code], [code]"Shift+Escape"[/code]). See also [member InputEventKey.keycode] and [method InputEventKey.get_keycode_with_modifiers]. </description> </method> <method name="get_locale" qualifiers="const"> - <return type="String"> - </return> + <return type="String" /> <description> Returns the host OS locale as a string of the form [code]language_Script_COUNTRY_VARIANT@extra[/code]. [code]language[/code] - 2 or 3-letter [url=https://en.wikipedia.org/wiki/List_of_ISO_639-1_codes]language code[/url], in lower case. [code]Script[/code] - optional, 4-letter [url=https://en.wikipedia.org/wiki/ISO_15924]script code[/url], in title case. [code]COUNTRY[/code] - optional, 2 or 3-letter [url=https://en.wikipedia.org/wiki/ISO_3166-1]country code[/url], in upper case. - [code]VARIANT[/code] - optional, language variant, region and sort order. Variant can have any number of underscored key words. + [code]VARIANT[/code] - optional, language variant, region and sort order. Variant can have any number of underscored keywords. [code]extra[/code] - optional, semicolon separated list of additional key words. Currency, calendar, sort order and numbering system information. </description> </method> <method name="get_model_name" qualifiers="const"> - <return type="String"> - </return> + <return type="String" /> <description> Returns the model name of the current device. [b]Note:[/b] This method is implemented on Android and iOS. Returns [code]"GenericDevice"[/code] on unsupported platforms. </description> </method> <method name="get_name" qualifiers="const"> - <return type="String"> - </return> + <return type="String" /> <description> Returns the name of the host OS. Possible values are: [code]"Android"[/code], [code]"iOS"[/code], [code]"HTML5"[/code], [code]"OSX"[/code], [code]"Server"[/code], [code]"Windows"[/code], [code]"UWP"[/code], [code]"X11"[/code]. </description> </method> <method name="get_process_id" qualifiers="const"> - <return type="int"> - </return> + <return type="int" /> <description> Returns the project's process ID. [b]Note:[/b] This method is implemented on Android, iOS, Linux, macOS and Windows. </description> </method> <method name="get_processor_count" qualifiers="const"> - <return type="int"> - </return> + <return type="int" /> <description> Returns the number of threads available on the host machine. </description> </method> <method name="get_static_memory_peak_usage" qualifiers="const"> - <return type="int"> - </return> + <return type="int" /> <description> Returns the maximum amount of static memory used (only works in debug). </description> </method> <method name="get_static_memory_usage" qualifiers="const"> - <return type="int"> - </return> + <return type="int" /> <description> Returns the amount of static memory being used by the program in bytes. </description> </method> <method name="get_system_dir" qualifiers="const"> - <return type="String"> - </return> - <argument index="0" name="dir" type="int" enum="OS.SystemDir"> - </argument> + <return type="String" /> + <argument index="0" name="dir" type="int" enum="OS.SystemDir" /> <description> Returns the actual path to commonly used folders across different platforms. Available locations are specified in [enum SystemDir]. [b]Note:[/b] This method is implemented on Android, Linux, macOS and Windows. </description> </method> <method name="get_thread_caller_id" qualifiers="const"> - <return type="int"> - </return> + <return type="int" /> <description> Returns the ID of the current thread. This can be used in logs to ease debugging of multi-threaded applications. [b]Note:[/b] Thread IDs are not deterministic and may be reused across application restarts. </description> </method> <method name="get_unique_id" qualifiers="const"> - <return type="String"> - </return> + <return type="String" /> <description> Returns a string that is unique to the device. - [b]Note:[/b] This string may change without notice if the user reinstalls/upgrades their operating system or changes their hardware. This means it should generally not be used to encrypt persistent data as the data saved prior to an unexpected ID change would become inaccessible. The returned string may also be falsified using external programs, so do not rely on the string returned by [method get_unique_id] for security purposes. + [b]Note:[/b] This string may change without notice if the user reinstalls/upgrades their operating system or changes their hardware. This means it should generally not be used to encrypt persistent data as the data saved before an unexpected ID change would become inaccessible. The returned string may also be falsified using external programs, so do not rely on the string returned by [method get_unique_id] for security purposes. [b]Note:[/b] Returns an empty string on HTML5 and UWP, as this method isn't implemented on those platforms yet. </description> </method> <method name="get_user_data_dir" qualifiers="const"> - <return type="String"> - </return> + <return type="String" /> <description> Returns the absolute directory path where user data is written ([code]user://[/code]). On Linux, this is [code]~/.local/share/godot/app_userdata/[project_name][/code], or [code]~/.local/share/[custom_name][/code] if [code]use_custom_user_dir[/code] is set. @@ -338,28 +302,23 @@ </description> </method> <method name="has_environment" qualifiers="const"> - <return type="bool"> - </return> - <argument index="0" name="variable" type="String"> - </argument> + <return type="bool" /> + <argument index="0" name="variable" type="String" /> <description> Returns [code]true[/code] if the environment variable with the name [code]variable[/code] exists. [b]Note:[/b] Double-check the casing of [code]variable[/code]. Environment variable names are case-sensitive on all platforms except Windows. </description> </method> <method name="has_feature" qualifiers="const"> - <return type="bool"> - </return> - <argument index="0" name="tag_name" type="String"> - </argument> + <return type="bool" /> + <argument index="0" name="tag_name" type="String" /> <description> - Returns [code]true[/code] if the feature for the given feature tag is supported in the currently running instance, depending on platform, build etc. Can be used to check whether you're currently running a debug build, on a certain platform or arch, etc. Refer to the [url=https://docs.godotengine.org/en/latest/getting_started/workflow/export/feature_tags.html]Feature Tags[/url] documentation for more details. + Returns [code]true[/code] if the feature for the given feature tag is supported in the currently running instance, depending on the platform, build, etc. Can be used to check whether you're currently running a debug build, on a certain platform or arch, etc. Refer to the [url=https://docs.godotengine.org/en/latest/getting_started/workflow/export/feature_tags.html]Feature Tags[/url] documentation for more details. [b]Note:[/b] Tag names are case-sensitive. </description> </method> <method name="is_debug_build" qualifiers="const"> - <return type="bool"> - </return> + <return type="bool" /> <description> Returns [code]true[/code] if the Godot binary used to run the project is a [i]debug[/i] export template, or when running in the editor. Returns [code]false[/code] if the Godot binary used to run the project is a [i]release[/i] export template. @@ -367,33 +326,27 @@ </description> </method> <method name="is_keycode_unicode" qualifiers="const"> - <return type="bool"> - </return> - <argument index="0" name="code" type="int"> - </argument> + <return type="bool" /> + <argument index="0" name="code" type="int" /> <description> Returns [code]true[/code] if the input keycode corresponds to a Unicode character. </description> </method> <method name="is_stdout_verbose" qualifiers="const"> - <return type="bool"> - </return> + <return type="bool" /> <description> Returns [code]true[/code] if the engine was executed with [code]-v[/code] (verbose stdout). </description> </method> <method name="is_userfs_persistent" qualifiers="const"> - <return type="bool"> - </return> + <return type="bool" /> <description> If [code]true[/code], the [code]user://[/code] file system is persistent, so that its state is the same after a player quits and starts the game again. Relevant to the HTML5 platform, where this persistence may be unavailable. </description> </method> <method name="kill"> - <return type="int" enum="Error"> - </return> - <argument index="0" name="pid" type="int"> - </argument> + <return type="int" enum="Error" /> + <argument index="0" name="pid" type="int" /> <description> Kill (terminate) the process identified by the given process ID ([code]pid[/code]), e.g. the one returned by [method execute] in non-blocking mode. [b]Note:[/b] This method can also be used to kill processes that were not spawned by the game. @@ -401,99 +354,79 @@ </description> </method> <method name="open_midi_inputs"> - <return type="void"> - </return> + <return type="void" /> <description> Initialises the singleton for the system MIDI driver. [b]Note:[/b] This method is implemented on Linux, macOS and Windows. </description> </method> <method name="print_all_resources"> - <return type="void"> - </return> - <argument index="0" name="tofile" type="String" default=""""> - </argument> + <return type="void" /> + <argument index="0" name="tofile" type="String" default="""" /> <description> Shows all resources in the game. Optionally, the list can be written to a file by specifying a file path in [code]tofile[/code]. </description> </method> <method name="print_all_textures_by_size"> - <return type="void"> - </return> + <return type="void" /> <description> Shows the list of loaded textures sorted by size in memory. </description> </method> <method name="print_resources_by_type"> - <return type="void"> - </return> - <argument index="0" name="types" type="PackedStringArray"> - </argument> + <return type="void" /> + <argument index="0" name="types" type="PackedStringArray" /> <description> Shows the number of resources loaded by the game of the given types. </description> </method> <method name="print_resources_in_use"> - <return type="void"> - </return> - <argument index="0" name="short" type="bool" default="false"> - </argument> + <return type="void" /> + <argument index="0" name="short" type="bool" default="false" /> <description> Shows all resources currently used by the game. </description> </method> <method name="request_permission"> - <return type="bool"> - </return> - <argument index="0" name="name" type="String"> - </argument> + <return type="bool" /> + <argument index="0" name="name" type="String" /> <description> At the moment this function is only used by [code]AudioDriverOpenSL[/code] to request permission for [code]RECORD_AUDIO[/code] on Android. </description> </method> <method name="request_permissions"> - <return type="bool"> - </return> + <return type="bool" /> <description> - With this function you can request dangerous permissions since normal permissions are automatically granted at install time in Android application. + With this function, you can request dangerous permissions since normal permissions are automatically granted at install time in Android applications. [b]Note:[/b] This method is implemented on Android. </description> </method> <method name="set_environment" qualifiers="const"> - <return type="bool"> - </return> - <argument index="0" name="variable" type="String"> - </argument> - <argument index="1" name="value" type="String"> - </argument> + <return type="bool" /> + <argument index="0" name="variable" type="String" /> + <argument index="1" name="value" type="String" /> <description> Sets the value of the environment variable [code]variable[/code] to [code]value[/code]. The environment variable will be set for the Godot process and any process executed with [method execute] after running [method set_environment]. The environment variable will [i]not[/i] persist to processes run after the Godot process was terminated. [b]Note:[/b] Double-check the casing of [code]variable[/code]. Environment variable names are case-sensitive on all platforms except Windows. </description> </method> <method name="set_thread_name"> - <return type="int" enum="Error"> - </return> - <argument index="0" name="name" type="String"> - </argument> + <return type="int" enum="Error" /> + <argument index="0" name="name" type="String" /> <description> Sets the name of the current thread. </description> </method> <method name="set_use_file_access_save_and_swap"> - <return type="void"> - </return> - <argument index="0" name="enabled" type="bool"> - </argument> + <return type="void" /> + <argument index="0" name="enabled" type="bool" /> <description> Enables backup saves if [code]enabled[/code] is [code]true[/code]. </description> </method> <method name="shell_open"> - <return type="int" enum="Error"> - </return> - <argument index="0" name="uri" type="String"> - </argument> + <return type="int" enum="Error" /> + <argument index="0" name="uri" type="String" /> <description> Requests the OS to open a resource with the most appropriate program. For example: - [code]OS.shell_open("C:\\Users\name\Downloads")[/code] on Windows opens the file explorer at the user's Downloads folder. diff --git a/doc/classes/Object.xml b/doc/classes/Object.xml index cdf76a3a59..9ad79dc17a 100644 --- a/doc/classes/Object.xml +++ b/doc/classes/Object.xml @@ -33,18 +33,15 @@ </tutorials> <methods> <method name="_get" qualifiers="virtual"> - <return type="Variant"> - </return> - <argument index="0" name="property" type="StringName"> - </argument> + <return type="Variant" /> + <argument index="0" name="property" type="StringName" /> <description> Virtual method which can be overridden to customize the return value of [method get]. Returns the given property. Returns [code]null[/code] if the [code]property[/code] does not exist. </description> </method> <method name="_get_property_list" qualifiers="virtual"> - <return type="Array"> - </return> + <return type="Array" /> <description> Virtual method which can be overridden to customize the return value of [method get_property_list]. Returns the object's property list as an [Array] of dictionaries. @@ -52,57 +49,45 @@ </description> </method> <method name="_init" qualifiers="virtual"> - <return type="void"> - </return> + <return type="void" /> <description> Called when the object is initialized. </description> </method> <method name="_notification" qualifiers="virtual"> - <return type="void"> - </return> - <argument index="0" name="what" type="int"> - </argument> + <return type="void" /> + <argument index="0" name="what" type="int" /> <description> Called whenever the object receives a notification, which is identified in [code]what[/code] by a constant. The base [Object] has two constants [constant NOTIFICATION_POSTINITIALIZE] and [constant NOTIFICATION_PREDELETE], but subclasses such as [Node] define a lot more notifications which are also received by this method. </description> </method> <method name="_set" qualifiers="virtual"> - <return type="bool"> - </return> - <argument index="0" name="property" type="StringName"> - </argument> - <argument index="1" name="value" type="Variant"> - </argument> + <return type="bool" /> + <argument index="0" name="property" type="StringName" /> + <argument index="1" name="value" type="Variant" /> <description> Virtual method which can be overridden to customize the return value of [method set]. Sets a property. Returns [code]true[/code] if the [code]property[/code] exists. </description> </method> <method name="_to_string" qualifiers="virtual"> - <return type="String"> - </return> + <return type="String" /> <description> Virtual method which can be overridden to customize the return value of [method to_string], and thus the object's representation where it is converted to a string, e.g. with [code]print(obj)[/code]. Returns a [String] representing the object. If not overridden, defaults to [code]"[ClassName:RID]"[/code]. </description> </method> <method name="add_user_signal"> - <return type="void"> - </return> - <argument index="0" name="signal" type="String"> - </argument> - <argument index="1" name="arguments" type="Array" default="[]"> - </argument> + <return type="void" /> + <argument index="0" name="signal" type="String" /> + <argument index="1" name="arguments" type="Array" default="[]" /> <description> Adds a user-defined [code]signal[/code]. Arguments are optional, but can be added as an [Array] of dictionaries, each containing [code]name: String[/code] and [code]type: int[/code] (see [enum Variant.Type]) entries. </description> </method> <method name="call" qualifiers="vararg"> - <return type="Variant"> - </return> - <argument index="0" name="method" type="StringName"> - </argument> + <return type="Variant" /> + <argument index="0" name="method" type="StringName" /> <description> Calls the [code]method[/code] on the object and returns the result. This method supports a variable number of arguments, so parameters are passed as a comma separated list. Example: [codeblocks] @@ -119,10 +104,8 @@ </description> </method> <method name="call_deferred" qualifiers="vararg"> - <return type="void"> - </return> - <argument index="0" name="method" type="StringName"> - </argument> + <return type="void" /> + <argument index="0" name="method" type="StringName" /> <description> Calls the [code]method[/code] on the object during idle time. This method supports a variable number of arguments, so parameters are passed as a comma separated list. Example: [codeblocks] @@ -139,12 +122,9 @@ </description> </method> <method name="callv"> - <return type="Variant"> - </return> - <argument index="0" name="method" type="StringName"> - </argument> - <argument index="1" name="arg_array" type="Array"> - </argument> + <return type="Variant" /> + <argument index="0" name="method" type="StringName" /> + <argument index="1" name="arg_array" type="Array" /> <description> Calls the [code]method[/code] on the object and returns the result. Contrarily to [method call], this method does not support a variable number of arguments but expects all parameters to be via a single [Array]. [codeblocks] @@ -160,23 +140,17 @@ </description> </method> <method name="can_translate_messages" qualifiers="const"> - <return type="bool"> - </return> + <return type="bool" /> <description> Returns [code]true[/code] if the object can translate strings. See [method set_message_translation] and [method tr]. </description> </method> <method name="connect"> - <return type="int" enum="Error"> - </return> - <argument index="0" name="signal" type="StringName"> - </argument> - <argument index="1" name="callable" type="Callable"> - </argument> - <argument index="2" name="binds" type="Array" default="[]"> - </argument> - <argument index="3" name="flags" type="int" default="0"> - </argument> + <return type="int" enum="Error" /> + <argument index="0" name="signal" type="StringName" /> + <argument index="1" name="callable" type="Callable" /> + <argument index="2" name="binds" type="Array" default="[]" /> + <argument index="3" name="flags" type="int" default="0" /> <description> Connects a [code]signal[/code] to a [code]callable[/code]. Pass optional [code]binds[/code] to the call as an [Array] of parameters. These parameters will be passed to the [Callable]'s method after any parameter used in the call to [method emit_signal]. Use [code]flags[/code] to set deferred or one-shot connections. See [enum ConnectFlags] constants. [b]Note:[/b] This method is the legacy implementation for connecting signals. The recommended modern approach is to use [method Signal.connect] and to use [method Callable.bind] to add and validate parameter binds. Both syntaxes are shown below. @@ -315,22 +289,17 @@ </description> </method> <method name="disconnect"> - <return type="void"> - </return> - <argument index="0" name="signal" type="StringName"> - </argument> - <argument index="1" name="callable" type="Callable"> - </argument> + <return type="void" /> + <argument index="0" name="signal" type="StringName" /> + <argument index="1" name="callable" type="Callable" /> <description> Disconnects a [code]signal[/code] from a given [code]callable[/code]. If you try to disconnect a connection that does not exist, the method will throw an error. Use [method is_connected] to ensure that the connection exists. </description> </method> <method name="emit_signal" qualifiers="vararg"> - <return type="void"> - </return> - <argument index="0" name="signal" type="StringName"> - </argument> + <return type="void" /> + <argument index="0" name="signal" type="StringName" /> <description> Emits the given [code]signal[/code]. The signal must exist, so it should be a built-in signal of this class or one of its parent classes, or a user-defined signal. This method supports a variable number of arguments, so parameters are passed as a comma separated list. Example: [codeblocks] @@ -346,32 +315,27 @@ </description> </method> <method name="free"> - <return type="void"> - </return> + <return type="void" /> <description> Deletes the object from memory. Any pre-existing reference to the freed object will become invalid, e.g. [code]is_instance_valid(object)[/code] will return [code]false[/code]. </description> </method> <method name="get" qualifiers="const"> - <return type="Variant"> - </return> - <argument index="0" name="property" type="String"> - </argument> + <return type="Variant" /> + <argument index="0" name="property" type="String" /> <description> Returns the [Variant] value of the given [code]property[/code]. If the [code]property[/code] doesn't exist, this will return [code]null[/code]. [b]Note:[/b] In C#, the property name must be specified as snake_case if it is defined by a built-in Godot node. This doesn't apply to user-defined properties where you should use the same convention as in the C# source (typically PascalCase). </description> </method> <method name="get_class" qualifiers="const"> - <return type="String"> - </return> + <return type="String" /> <description> Returns the object's class as a [String]. </description> </method> <method name="get_incoming_connections" qualifiers="const"> - <return type="Array"> - </return> + <return type="Array" /> <description> Returns an [Array] of dictionaries with information about signals that are connected to the object. Each [Dictionary] contains three String entries: @@ -381,214 +345,170 @@ </description> </method> <method name="get_indexed" qualifiers="const"> - <return type="Variant"> - </return> - <argument index="0" name="property" type="NodePath"> - </argument> + <return type="Variant" /> + <argument index="0" name="property" type="NodePath" /> <description> Gets the object's property indexed by the given [NodePath]. The node path should be relative to the current object and can use the colon character ([code]:[/code]) to access nested properties. Examples: [code]"position:x"[/code] or [code]"material:next_pass:blend_mode"[/code]. </description> </method> <method name="get_instance_id" qualifiers="const"> - <return type="int"> - </return> + <return type="int" /> <description> Returns the object's unique instance ID. This ID can be saved in [EncodedObjectAsID], and can be used to retrieve the object instance with [method @GlobalScope.instance_from_id]. </description> </method> <method name="get_meta" qualifiers="const"> - <return type="Variant"> - </return> - <argument index="0" name="name" type="String"> - </argument> + <return type="Variant" /> + <argument index="0" name="name" type="StringName" /> <description> Returns the object's metadata entry for the given [code]name[/code]. </description> </method> <method name="get_meta_list" qualifiers="const"> - <return type="PackedStringArray"> - </return> + <return type="PackedStringArray" /> <description> Returns the object's metadata as a [PackedStringArray]. </description> </method> <method name="get_method_list" qualifiers="const"> - <return type="Array"> - </return> + <return type="Array" /> <description> Returns the object's methods and their signatures as an [Array]. </description> </method> <method name="get_property_list" qualifiers="const"> - <return type="Array"> - </return> + <return type="Array" /> <description> Returns the object's property list as an [Array] of dictionaries. Each property's [Dictionary] contain at least [code]name: String[/code] and [code]type: int[/code] (see [enum Variant.Type]) entries. Optionally, it can also include [code]hint: int[/code] (see [enum PropertyHint]), [code]hint_string: String[/code], and [code]usage: int[/code] (see [enum PropertyUsageFlags]). </description> </method> <method name="get_script" qualifiers="const"> - <return type="Variant"> - </return> + <return type="Variant" /> <description> Returns the object's [Script] instance, or [code]null[/code] if none is assigned. </description> </method> <method name="get_signal_connection_list" qualifiers="const"> - <return type="Array"> - </return> - <argument index="0" name="signal" type="String"> - </argument> + <return type="Array" /> + <argument index="0" name="signal" type="String" /> <description> Returns an [Array] of connections for the given [code]signal[/code]. </description> </method> <method name="get_signal_list" qualifiers="const"> - <return type="Array"> - </return> + <return type="Array" /> <description> Returns the list of signals as an [Array] of dictionaries. </description> </method> <method name="has_meta" qualifiers="const"> - <return type="bool"> - </return> - <argument index="0" name="name" type="String"> - </argument> + <return type="bool" /> + <argument index="0" name="name" type="StringName" /> <description> Returns [code]true[/code] if a metadata entry is found with the given [code]name[/code]. </description> </method> <method name="has_method" qualifiers="const"> - <return type="bool"> - </return> - <argument index="0" name="method" type="StringName"> - </argument> + <return type="bool" /> + <argument index="0" name="method" type="StringName" /> <description> Returns [code]true[/code] if the object contains the given [code]method[/code]. </description> </method> <method name="has_signal" qualifiers="const"> - <return type="bool"> - </return> - <argument index="0" name="signal" type="StringName"> - </argument> + <return type="bool" /> + <argument index="0" name="signal" type="StringName" /> <description> Returns [code]true[/code] if the given [code]signal[/code] exists. </description> </method> <method name="has_user_signal" qualifiers="const"> - <return type="bool"> - </return> - <argument index="0" name="signal" type="StringName"> - </argument> + <return type="bool" /> + <argument index="0" name="signal" type="StringName" /> <description> Returns [code]true[/code] if the given user-defined [code]signal[/code] exists. Only signals added using [method add_user_signal] are taken into account. </description> </method> <method name="is_blocking_signals" qualifiers="const"> - <return type="bool"> - </return> + <return type="bool" /> <description> Returns [code]true[/code] if signal emission blocking is enabled. </description> </method> <method name="is_class" qualifiers="const"> - <return type="bool"> - </return> - <argument index="0" name="class" type="String"> - </argument> + <return type="bool" /> + <argument index="0" name="class" type="String" /> <description> Returns [code]true[/code] if the object inherits from the given [code]class[/code]. </description> </method> <method name="is_connected" qualifiers="const"> - <return type="bool"> - </return> - <argument index="0" name="signal" type="StringName"> - </argument> - <argument index="1" name="callable" type="Callable"> - </argument> + <return type="bool" /> + <argument index="0" name="signal" type="StringName" /> + <argument index="1" name="callable" type="Callable" /> <description> Returns [code]true[/code] if a connection exists for a given [code]signal[/code] and [code]callable[/code]. </description> </method> <method name="is_queued_for_deletion" qualifiers="const"> - <return type="bool"> - </return> + <return type="bool" /> <description> Returns [code]true[/code] if the [method Node.queue_free] method was called for the object. </description> </method> <method name="notification"> - <return type="void"> - </return> - <argument index="0" name="what" type="int"> - </argument> - <argument index="1" name="reversed" type="bool" default="false"> - </argument> + <return type="void" /> + <argument index="0" name="what" type="int" /> + <argument index="1" name="reversed" type="bool" default="false" /> <description> Send a given notification to the object, which will also trigger a call to the [method _notification] method of all classes that the object inherits from. If [code]reversed[/code] is [code]true[/code], [method _notification] is called first on the object's own class, and then up to its successive parent classes. If [code]reversed[/code] is [code]false[/code], [method _notification] is called first on the highest ancestor ([Object] itself), and then down to its successive inheriting classes. </description> </method> <method name="notify_property_list_changed"> - <return type="void"> - </return> + <return type="void" /> <description> Notify the editor that the property list has changed by emitting the [signal property_list_changed] signal, so that editor plugins can take the new values into account. </description> </method> <method name="remove_meta"> - <return type="void"> - </return> - <argument index="0" name="name" type="String"> - </argument> + <return type="void" /> + <argument index="0" name="name" type="StringName" /> <description> Removes a given entry from the object's metadata. See also [method set_meta]. </description> </method> <method name="set"> - <return type="void"> - </return> - <argument index="0" name="property" type="String"> - </argument> - <argument index="1" name="value" type="Variant"> - </argument> + <return type="void" /> + <argument index="0" name="property" type="String" /> + <argument index="1" name="value" type="Variant" /> <description> Assigns a new value to the given property. If the [code]property[/code] does not exist, nothing will happen. [b]Note:[/b] In C#, the property name must be specified as snake_case if it is defined by a built-in Godot node. This doesn't apply to user-defined properties where you should use the same convention as in the C# source (typically PascalCase). </description> </method> <method name="set_block_signals"> - <return type="void"> - </return> - <argument index="0" name="enable" type="bool"> - </argument> + <return type="void" /> + <argument index="0" name="enable" type="bool" /> <description> If set to [code]true[/code], signal emission is blocked. </description> </method> <method name="set_deferred"> - <return type="void"> - </return> - <argument index="0" name="property" type="StringName"> - </argument> - <argument index="1" name="value" type="Variant"> - </argument> + <return type="void" /> + <argument index="0" name="property" type="StringName" /> + <argument index="1" name="value" type="Variant" /> <description> Assigns a new value to the given property, after the current frame's physics step. This is equivalent to calling [method set] via [method call_deferred], i.e. [code]call_deferred("set", property, value)[/code]. [b]Note:[/b] In C#, the property name must be specified as snake_case if it is defined by a built-in Godot node. This doesn't apply to user-defined properties where you should use the same convention as in the C# source (typically PascalCase). </description> </method> <method name="set_indexed"> - <return type="void"> - </return> - <argument index="0" name="property" type="NodePath"> - </argument> - <argument index="1" name="value" type="Variant"> - </argument> + <return type="void" /> + <argument index="0" name="property" type="NodePath" /> + <argument index="1" name="value" type="Variant" /> <description> Assigns a new value to the property identified by the [NodePath]. The node path should be relative to the current object and can use the colon character ([code]:[/code]) to access nested properties. Example: [codeblocks] @@ -608,51 +528,40 @@ </description> </method> <method name="set_message_translation"> - <return type="void"> - </return> - <argument index="0" name="enable" type="bool"> - </argument> + <return type="void" /> + <argument index="0" name="enable" type="bool" /> <description> Defines whether the object can translate strings (with calls to [method tr]). Enabled by default. </description> </method> <method name="set_meta"> - <return type="void"> - </return> - <argument index="0" name="name" type="String"> - </argument> - <argument index="1" name="value" type="Variant"> - </argument> + <return type="void" /> + <argument index="0" name="name" type="StringName" /> + <argument index="1" name="value" type="Variant" /> <description> Adds, changes or removes a given entry in the object's metadata. Metadata are serialized and can take any [Variant] value. To remove a given entry from the object's metadata, use [method remove_meta]. Metadata is also removed if its value is set to [code]null[/code]. This means you can also use [code]set_meta("name", null)[/code] to remove metadata for [code]"name"[/code]. </description> </method> <method name="set_script"> - <return type="void"> - </return> - <argument index="0" name="script" type="Variant"> - </argument> + <return type="void" /> + <argument index="0" name="script" type="Variant" /> <description> Assigns a script to the object. Each object can have a single script assigned to it, which are used to extend its functionality. If the object already had a script, the previous script instance will be freed and its variables and state will be lost. The new script's [method _init] method will be called. </description> </method> <method name="to_string"> - <return type="String"> - </return> + <return type="String" /> <description> Returns a [String] representing the object. If not overridden, defaults to [code]"[ClassName:RID]"[/code]. Override the method [method _to_string] to customize the [String] representation. </description> </method> <method name="tr" qualifiers="const"> - <return type="String"> - </return> - <argument index="0" name="message" type="StringName"> - </argument> - <argument index="1" name="context" type="StringName" default=""""> - </argument> + <return type="String" /> + <argument index="0" name="message" type="StringName" /> + <argument index="1" name="context" type="StringName" default="""" /> <description> Translates a message using translation catalogs configured in the Project Settings. An additional context could be used to specify the translation context. Only works if message translation is enabled (which it is by default), otherwise it returns the [code]message[/code] unchanged. See [method set_message_translation]. @@ -660,16 +569,11 @@ </description> </method> <method name="tr_n" qualifiers="const"> - <return type="String"> - </return> - <argument index="0" name="message" type="StringName"> - </argument> - <argument index="1" name="plural_message" type="StringName"> - </argument> - <argument index="2" name="n" type="int"> - </argument> - <argument index="3" name="context" type="StringName" default=""""> - </argument> + <return type="String" /> + <argument index="0" name="message" type="StringName" /> + <argument index="1" name="plural_message" type="StringName" /> + <argument index="2" name="n" type="int" /> + <argument index="3" name="context" type="StringName" default="""" /> <description> Translates a message involving plurals using translation catalogs configured in the Project Settings. An additional context could be used to specify the translation context. Only works if message translation is enabled (which it is by default), otherwise it returns the [code]message[/code] or [code]plural_message[/code] unchanged. See [method set_message_translation]. diff --git a/doc/classes/OccluderInstance3D.xml b/doc/classes/OccluderInstance3D.xml index 76b784d21d..150bfd9257 100644 --- a/doc/classes/OccluderInstance3D.xml +++ b/doc/classes/OccluderInstance3D.xml @@ -8,20 +8,15 @@ </tutorials> <methods> <method name="get_bake_mask_bit" qualifiers="const"> - <return type="bool"> - </return> - <argument index="0" name="layer" type="int"> - </argument> + <return type="bool" /> + <argument index="0" name="layer" type="int" /> <description> </description> </method> <method name="set_bake_mask_bit"> - <return type="void"> - </return> - <argument index="0" name="layer" type="int"> - </argument> - <argument index="1" name="enabled" type="bool"> - </argument> + <return type="void" /> + <argument index="0" name="layer" type="int" /> + <argument index="1" name="enabled" type="bool" /> <description> </description> </method> diff --git a/doc/classes/OptimizedTranslation.xml b/doc/classes/OptimizedTranslation.xml index a5ca93c7ff..195fa28188 100644 --- a/doc/classes/OptimizedTranslation.xml +++ b/doc/classes/OptimizedTranslation.xml @@ -10,10 +10,8 @@ </tutorials> <methods> <method name="generate"> - <return type="void"> - </return> - <argument index="0" name="from" type="Translation"> - </argument> + <return type="void" /> + <argument index="0" name="from" type="Translation" /> <description> Generates and sets an optimized translation from the given [Translation] resource. </description> diff --git a/doc/classes/OptionButton.xml b/doc/classes/OptionButton.xml index 4c03c59f8b..ae268203ad 100644 --- a/doc/classes/OptionButton.xml +++ b/doc/classes/OptionButton.xml @@ -11,195 +11,151 @@ </tutorials> <methods> <method name="add_icon_item"> - <return type="void"> - </return> - <argument index="0" name="texture" type="Texture2D"> - </argument> - <argument index="1" name="label" type="String"> - </argument> - <argument index="2" name="id" type="int" default="-1"> - </argument> + <return type="void" /> + <argument index="0" name="texture" type="Texture2D" /> + <argument index="1" name="label" type="String" /> + <argument index="2" name="id" type="int" default="-1" /> <description> Adds an item, with a [code]texture[/code] icon, text [code]label[/code] and (optionally) [code]id[/code]. If no [code]id[/code] is passed, the item index will be used as the item's ID. New items are appended at the end. </description> </method> <method name="add_item"> - <return type="void"> - </return> - <argument index="0" name="label" type="String"> - </argument> - <argument index="1" name="id" type="int" default="-1"> - </argument> + <return type="void" /> + <argument index="0" name="label" type="String" /> + <argument index="1" name="id" type="int" default="-1" /> <description> Adds an item, with text [code]label[/code] and (optionally) [code]id[/code]. If no [code]id[/code] is passed, the item index will be used as the item's ID. New items are appended at the end. </description> </method> <method name="add_separator"> - <return type="void"> - </return> + <return type="void" /> <description> Adds a separator to the list of items. Separators help to group items. Separator also takes up an index and is appended at the end. </description> </method> <method name="clear"> - <return type="void"> - </return> + <return type="void" /> <description> Clears all the items in the [OptionButton]. </description> </method> <method name="get_item_count" qualifiers="const"> - <return type="int"> - </return> + <return type="int" /> <description> Returns the amount of items in the OptionButton, including separators. </description> </method> <method name="get_item_icon" qualifiers="const"> - <return type="Texture2D"> - </return> - <argument index="0" name="idx" type="int"> - </argument> + <return type="Texture2D" /> + <argument index="0" name="idx" type="int" /> <description> Returns the icon of the item at index [code]idx[/code]. </description> </method> <method name="get_item_id" qualifiers="const"> - <return type="int"> - </return> - <argument index="0" name="idx" type="int"> - </argument> + <return type="int" /> + <argument index="0" name="idx" type="int" /> <description> Returns the ID of the item at index [code]idx[/code]. </description> </method> <method name="get_item_index" qualifiers="const"> - <return type="int"> - </return> - <argument index="0" name="id" type="int"> - </argument> + <return type="int" /> + <argument index="0" name="id" type="int" /> <description> Returns the index of the item with the given [code]id[/code]. </description> </method> <method name="get_item_metadata" qualifiers="const"> - <return type="Variant"> - </return> - <argument index="0" name="idx" type="int"> - </argument> + <return type="Variant" /> + <argument index="0" name="idx" type="int" /> <description> Retrieves the metadata of an item. Metadata may be any type and can be used to store extra information about an item, such as an external string ID. </description> </method> <method name="get_item_text" qualifiers="const"> - <return type="String"> - </return> - <argument index="0" name="idx" type="int"> - </argument> + <return type="String" /> + <argument index="0" name="idx" type="int" /> <description> Returns the text of the item at index [code]idx[/code]. </description> </method> <method name="get_popup" qualifiers="const"> - <return type="PopupMenu"> - </return> + <return type="PopupMenu" /> <description> Returns the [PopupMenu] contained in this button. </description> </method> <method name="get_selected_id" qualifiers="const"> - <return type="int"> - </return> + <return type="int" /> <description> Returns the ID of the selected item, or [code]0[/code] if no item is selected. </description> </method> <method name="get_selected_metadata" qualifiers="const"> - <return type="Variant"> - </return> + <return type="Variant" /> <description> Gets the metadata of the selected item. Metadata for items can be set using [method set_item_metadata]. </description> </method> <method name="is_item_disabled" qualifiers="const"> - <return type="bool"> - </return> - <argument index="0" name="idx" type="int"> - </argument> + <return type="bool" /> + <argument index="0" name="idx" type="int" /> <description> Returns [code]true[/code] if the item at index [code]idx[/code] is disabled. </description> </method> <method name="remove_item"> - <return type="void"> - </return> - <argument index="0" name="idx" type="int"> - </argument> + <return type="void" /> + <argument index="0" name="idx" type="int" /> <description> Removes the item at index [code]idx[/code]. </description> </method> <method name="select"> - <return type="void"> - </return> - <argument index="0" name="idx" type="int"> - </argument> + <return type="void" /> + <argument index="0" name="idx" type="int" /> <description> Selects an item by index and makes it the current item. This will work even if the item is disabled. </description> </method> <method name="set_item_disabled"> - <return type="void"> - </return> - <argument index="0" name="idx" type="int"> - </argument> - <argument index="1" name="disabled" type="bool"> - </argument> + <return type="void" /> + <argument index="0" name="idx" type="int" /> + <argument index="1" name="disabled" type="bool" /> <description> Sets whether the item at index [code]idx[/code] is disabled. Disabled items are drawn differently in the dropdown and are not selectable by the user. If the current selected item is set as disabled, it will remain selected. </description> </method> <method name="set_item_icon"> - <return type="void"> - </return> - <argument index="0" name="idx" type="int"> - </argument> - <argument index="1" name="texture" type="Texture2D"> - </argument> + <return type="void" /> + <argument index="0" name="idx" type="int" /> + <argument index="1" name="texture" type="Texture2D" /> <description> Sets the icon of the item at index [code]idx[/code]. </description> </method> <method name="set_item_id"> - <return type="void"> - </return> - <argument index="0" name="idx" type="int"> - </argument> - <argument index="1" name="id" type="int"> - </argument> + <return type="void" /> + <argument index="0" name="idx" type="int" /> + <argument index="1" name="id" type="int" /> <description> Sets the ID of the item at index [code]idx[/code]. </description> </method> <method name="set_item_metadata"> - <return type="void"> - </return> - <argument index="0" name="idx" type="int"> - </argument> - <argument index="1" name="metadata" type="Variant"> - </argument> + <return type="void" /> + <argument index="0" name="idx" type="int" /> + <argument index="1" name="metadata" type="Variant" /> <description> Sets the metadata of an item. Metadata may be of any type and can be used to store extra information about an item, such as an external string ID. </description> </method> <method name="set_item_text"> - <return type="void"> - </return> - <argument index="0" name="idx" type="int"> - </argument> - <argument index="1" name="text" type="String"> - </argument> + <return type="void" /> + <argument index="0" name="idx" type="int" /> + <argument index="1" name="text" type="String" /> <description> Sets the text of the item at index [code]idx[/code]. </description> @@ -215,15 +171,13 @@ </members> <signals> <signal name="item_focused"> - <argument index="0" name="index" type="int"> - </argument> + <argument index="0" name="index" type="int" /> <description> Emitted when the user navigates to an item using the [code]ui_up[/code] or [code]ui_down[/code] actions. The index of the item selected is passed as argument. </description> </signal> <signal name="item_selected"> - <argument index="0" name="index" type="int"> - </argument> + <argument index="0" name="index" type="int" /> <description> Emitted when the current item has been changed by the user. The index of the item selected is passed as argument. </description> diff --git a/doc/classes/PCKPacker.xml b/doc/classes/PCKPacker.xml index 40e8683c93..0af329983d 100644 --- a/doc/classes/PCKPacker.xml +++ b/doc/classes/PCKPacker.xml @@ -25,38 +25,27 @@ </tutorials> <methods> <method name="add_file"> - <return type="int" enum="Error"> - </return> - <argument index="0" name="pck_path" type="String"> - </argument> - <argument index="1" name="source_path" type="String"> - </argument> - <argument index="2" name="encrypt" type="bool" default="false"> - </argument> + <return type="int" enum="Error" /> + <argument index="0" name="pck_path" type="String" /> + <argument index="1" name="source_path" type="String" /> + <argument index="2" name="encrypt" type="bool" default="false" /> <description> Adds the [code]source_path[/code] file to the current PCK package at the [code]pck_path[/code] internal path (should start with [code]res://[/code]). </description> </method> <method name="flush"> - <return type="int" enum="Error"> - </return> - <argument index="0" name="verbose" type="bool" default="false"> - </argument> + <return type="int" enum="Error" /> + <argument index="0" name="verbose" type="bool" default="false" /> <description> Writes the files specified using all [method add_file] calls since the last flush. If [code]verbose[/code] is [code]true[/code], a list of files added will be printed to the console for easier debugging. </description> </method> <method name="pck_start"> - <return type="int" enum="Error"> - </return> - <argument index="0" name="pck_name" type="String"> - </argument> - <argument index="1" name="alignment" type="int" default="0"> - </argument> - <argument index="2" name="key" type="String" default=""""> - </argument> - <argument index="3" name="encrypt_directory" type="bool" default="false"> - </argument> + <return type="int" enum="Error" /> + <argument index="0" name="pck_name" type="String" /> + <argument index="1" name="alignment" type="int" default="0" /> + <argument index="2" name="key" type="String" default="""" /> + <argument index="3" name="encrypt_directory" type="bool" default="false" /> <description> Creates a new PCK file with the name [code]pck_name[/code]. The [code].pck[/code] file extension isn't added automatically, so it should be part of [code]pck_name[/code] (even though it's not required). </description> diff --git a/doc/classes/PackedByteArray.xml b/doc/classes/PackedByteArray.xml index 0652cf0aa1..af92590da3 100644 --- a/doc/classes/PackedByteArray.xml +++ b/doc/classes/PackedByteArray.xml @@ -10,183 +10,138 @@ </tutorials> <methods> <method name="PackedByteArray" qualifiers="constructor"> - <return type="PackedByteArray"> - </return> + <return type="PackedByteArray" /> <description> Constructs an empty [PackedByteArray]. </description> </method> <method name="PackedByteArray" qualifiers="constructor"> - <return type="PackedByteArray"> - </return> - <argument index="0" name="from" type="PackedByteArray"> - </argument> + <return type="PackedByteArray" /> + <argument index="0" name="from" type="PackedByteArray" /> <description> Constructs a [PackedByteArray] as a copy of the given [PackedByteArray]. </description> </method> <method name="PackedByteArray" qualifiers="constructor"> - <return type="PackedByteArray"> - </return> - <argument index="0" name="from" type="Array"> - </argument> + <return type="PackedByteArray" /> + <argument index="0" name="from" type="Array" /> <description> Constructs a new [PackedByteArray]. Optionally, you can pass in a generic [Array] that will be converted. </description> </method> <method name="append"> - <return type="bool"> - </return> - <argument index="0" name="value" type="int"> - </argument> + <return type="bool" /> + <argument index="0" name="value" type="int" /> <description> Appends an element at the end of the array (alias of [method push_back]). </description> </method> <method name="append_array"> - <return type="void"> - </return> - <argument index="0" name="array" type="PackedByteArray"> - </argument> + <return type="void" /> + <argument index="0" name="array" type="PackedByteArray" /> <description> Appends a [PackedByteArray] at the end of this array. </description> </method> <method name="compress" qualifiers="const"> - <return type="PackedByteArray"> - </return> - <argument index="0" name="compression_mode" type="int" default="0"> - </argument> + <return type="PackedByteArray" /> + <argument index="0" name="compression_mode" type="int" default="0" /> <description> Returns a new [PackedByteArray] with the data compressed. Set the compression mode using one of [enum File.CompressionMode]'s constants. </description> </method> <method name="decode_double" qualifiers="const"> - <return type="float"> - </return> - <argument index="0" name="byte_offset" type="int"> - </argument> + <return type="float" /> + <argument index="0" name="byte_offset" type="int" /> <description> </description> </method> <method name="decode_float" qualifiers="const"> - <return type="float"> - </return> - <argument index="0" name="byte_offset" type="int"> - </argument> + <return type="float" /> + <argument index="0" name="byte_offset" type="int" /> <description> </description> </method> <method name="decode_half" qualifiers="const"> - <return type="float"> - </return> - <argument index="0" name="byte_offset" type="int"> - </argument> + <return type="float" /> + <argument index="0" name="byte_offset" type="int" /> <description> </description> </method> <method name="decode_s16" qualifiers="const"> - <return type="int"> - </return> - <argument index="0" name="byte_offset" type="int"> - </argument> + <return type="int" /> + <argument index="0" name="byte_offset" type="int" /> <description> </description> </method> <method name="decode_s32" qualifiers="const"> - <return type="int"> - </return> - <argument index="0" name="byte_offset" type="int"> - </argument> + <return type="int" /> + <argument index="0" name="byte_offset" type="int" /> <description> </description> </method> <method name="decode_s64" qualifiers="const"> - <return type="int"> - </return> - <argument index="0" name="byte_offset" type="int"> - </argument> + <return type="int" /> + <argument index="0" name="byte_offset" type="int" /> <description> </description> </method> <method name="decode_s8" qualifiers="const"> - <return type="int"> - </return> - <argument index="0" name="byte_offset" type="int"> - </argument> + <return type="int" /> + <argument index="0" name="byte_offset" type="int" /> <description> </description> </method> <method name="decode_u16" qualifiers="const"> - <return type="int"> - </return> - <argument index="0" name="byte_offset" type="int"> - </argument> + <return type="int" /> + <argument index="0" name="byte_offset" type="int" /> <description> </description> </method> <method name="decode_u32" qualifiers="const"> - <return type="int"> - </return> - <argument index="0" name="byte_offset" type="int"> - </argument> + <return type="int" /> + <argument index="0" name="byte_offset" type="int" /> <description> </description> </method> <method name="decode_u64" qualifiers="const"> - <return type="int"> - </return> - <argument index="0" name="byte_offset" type="int"> - </argument> + <return type="int" /> + <argument index="0" name="byte_offset" type="int" /> <description> </description> </method> <method name="decode_u8" qualifiers="const"> - <return type="int"> - </return> - <argument index="0" name="byte_offset" type="int"> - </argument> + <return type="int" /> + <argument index="0" name="byte_offset" type="int" /> <description> </description> </method> <method name="decode_var" qualifiers="const"> - <return type="Variant"> - </return> - <argument index="0" name="byte_offset" type="int"> - </argument> - <argument index="1" name="allow_objects" type="bool" default="false"> - </argument> + <return type="Variant" /> + <argument index="0" name="byte_offset" type="int" /> + <argument index="1" name="allow_objects" type="bool" default="false" /> <description> </description> </method> <method name="decode_var_size" qualifiers="const"> - <return type="int"> - </return> - <argument index="0" name="byte_offset" type="int"> - </argument> - <argument index="1" name="allow_objects" type="bool" default="false"> - </argument> + <return type="int" /> + <argument index="0" name="byte_offset" type="int" /> + <argument index="1" name="allow_objects" type="bool" default="false" /> <description> </description> </method> <method name="decompress" qualifiers="const"> - <return type="PackedByteArray"> - </return> - <argument index="0" name="buffer_size" type="int"> - </argument> - <argument index="1" name="compression_mode" type="int" default="0"> - </argument> + <return type="PackedByteArray" /> + <argument index="0" name="buffer_size" type="int" /> + <argument index="1" name="compression_mode" type="int" default="0" /> <description> Returns a new [PackedByteArray] with the data decompressed. Set [code]buffer_size[/code] to the size of the uncompressed data. Set the compression mode using one of [enum File.CompressionMode]'s constants. </description> </method> <method name="decompress_dynamic" qualifiers="const"> - <return type="PackedByteArray"> - </return> - <argument index="0" name="max_output_size" type="int"> - </argument> - <argument index="1" name="compression_mode" type="int" default="0"> - </argument> + <return type="PackedByteArray" /> + <argument index="0" name="max_output_size" type="int" /> + <argument index="1" name="compression_mode" type="int" default="0" /> <description> Returns a new [PackedByteArray] with the data decompressed. Set the compression mode using one of [enum File.CompressionMode]'s constants. [b]This method only accepts gzip and deflate compression modes.[/b] This method is potentially slower than [code]decompress[/code], as it may have to re-allocate its output buffer multiple times while decompressing, whereas [code]decompress[/code] knows it's output buffer size from the beginning. @@ -194,193 +149,143 @@ </description> </method> <method name="duplicate"> - <return type="PackedByteArray"> - </return> + <return type="PackedByteArray" /> <description> Creates a copy of the array, and returns it. </description> </method> <method name="encode_double"> - <return type="void"> - </return> - <argument index="0" name="byte_offset" type="int"> - </argument> - <argument index="1" name="value" type="float"> - </argument> + <return type="void" /> + <argument index="0" name="byte_offset" type="int" /> + <argument index="1" name="value" type="float" /> <description> </description> </method> <method name="encode_float"> - <return type="void"> - </return> - <argument index="0" name="byte_offset" type="int"> - </argument> - <argument index="1" name="value" type="float"> - </argument> + <return type="void" /> + <argument index="0" name="byte_offset" type="int" /> + <argument index="1" name="value" type="float" /> <description> </description> </method> <method name="encode_half"> - <return type="void"> - </return> - <argument index="0" name="byte_offset" type="int"> - </argument> - <argument index="1" name="value" type="float"> - </argument> + <return type="void" /> + <argument index="0" name="byte_offset" type="int" /> + <argument index="1" name="value" type="float" /> <description> </description> </method> <method name="encode_s16"> - <return type="void"> - </return> - <argument index="0" name="byte_offset" type="int"> - </argument> - <argument index="1" name="value" type="int"> - </argument> + <return type="void" /> + <argument index="0" name="byte_offset" type="int" /> + <argument index="1" name="value" type="int" /> <description> </description> </method> <method name="encode_s32"> - <return type="void"> - </return> - <argument index="0" name="byte_offset" type="int"> - </argument> - <argument index="1" name="value" type="int"> - </argument> + <return type="void" /> + <argument index="0" name="byte_offset" type="int" /> + <argument index="1" name="value" type="int" /> <description> </description> </method> <method name="encode_s64"> - <return type="void"> - </return> - <argument index="0" name="byte_offset" type="int"> - </argument> - <argument index="1" name="value" type="int"> - </argument> + <return type="void" /> + <argument index="0" name="byte_offset" type="int" /> + <argument index="1" name="value" type="int" /> <description> </description> </method> <method name="encode_s8"> - <return type="void"> - </return> - <argument index="0" name="byte_offset" type="int"> - </argument> - <argument index="1" name="value" type="int"> - </argument> + <return type="void" /> + <argument index="0" name="byte_offset" type="int" /> + <argument index="1" name="value" type="int" /> <description> </description> </method> <method name="encode_u16"> - <return type="void"> - </return> - <argument index="0" name="byte_offset" type="int"> - </argument> - <argument index="1" name="value" type="int"> - </argument> + <return type="void" /> + <argument index="0" name="byte_offset" type="int" /> + <argument index="1" name="value" type="int" /> <description> </description> </method> <method name="encode_u32"> - <return type="void"> - </return> - <argument index="0" name="byte_offset" type="int"> - </argument> - <argument index="1" name="value" type="int"> - </argument> + <return type="void" /> + <argument index="0" name="byte_offset" type="int" /> + <argument index="1" name="value" type="int" /> <description> </description> </method> <method name="encode_u64"> - <return type="void"> - </return> - <argument index="0" name="byte_offset" type="int"> - </argument> - <argument index="1" name="value" type="int"> - </argument> + <return type="void" /> + <argument index="0" name="byte_offset" type="int" /> + <argument index="1" name="value" type="int" /> <description> </description> </method> <method name="encode_u8"> - <return type="void"> - </return> - <argument index="0" name="byte_offset" type="int"> - </argument> - <argument index="1" name="value" type="int"> - </argument> + <return type="void" /> + <argument index="0" name="byte_offset" type="int" /> + <argument index="1" name="value" type="int" /> <description> </description> </method> <method name="encode_var"> - <return type="int"> - </return> - <argument index="0" name="byte_offset" type="int"> - </argument> - <argument index="1" name="value" type="Variant"> - </argument> - <argument index="2" name="allow_objects" type="bool" default="false"> - </argument> + <return type="int" /> + <argument index="0" name="byte_offset" type="int" /> + <argument index="1" name="value" type="Variant" /> + <argument index="2" name="allow_objects" type="bool" default="false" /> <description> </description> </method> <method name="fill"> - <return type="void"> - </return> - <argument index="0" name="value" type="int"> - </argument> + <return type="void" /> + <argument index="0" name="value" type="int" /> <description> Assigns the given value to all elements in the array. This can typically be used together with [method resize] to create an array with a given size and initialized elements. </description> </method> <method name="get_string_from_ascii" qualifiers="const"> - <return type="String"> - </return> + <return type="String" /> <description> Converts ASCII/Latin-1 encoded array to [String]. Fast alternative to [method get_string_from_utf8] if the content is ASCII/Latin-1 only. Unlike the UTF-8 function this function maps every byte to a character in the array. Multibyte sequences will not be interpreted correctly. For parsing user input always use [method get_string_from_utf8]. </description> </method> <method name="get_string_from_utf16" qualifiers="const"> - <return type="String"> - </return> + <return type="String" /> <description> Converts UTF-16 encoded array to [String]. If the BOM is missing, system endianness is assumed. Returns empty string if source array is not valid UTF-16 string. </description> </method> <method name="get_string_from_utf32" qualifiers="const"> - <return type="String"> - </return> + <return type="String" /> <description> Converts UTF-32 encoded array to [String]. System endianness is assumed. Returns empty string if source array is not valid UTF-32 string. </description> </method> <method name="get_string_from_utf8" qualifiers="const"> - <return type="String"> - </return> + <return type="String" /> <description> Converts UTF-8 encoded array to [String]. Slower than [method get_string_from_ascii] but supports UTF-8 encoded data. Use this function if you are unsure about the source of the data. For user input this function should always be preferred. Returns empty string if source array is not valid UTF-8 string. </description> </method> <method name="has"> - <return type="bool"> - </return> - <argument index="0" name="value" type="int"> - </argument> + <return type="bool" /> + <argument index="0" name="value" type="int" /> <description> Returns [code]true[/code] if the array contains [code]value[/code]. </description> </method> <method name="has_encoded_var" qualifiers="const"> - <return type="bool"> - </return> - <argument index="0" name="byte_offset" type="int"> - </argument> - <argument index="1" name="allow_objects" type="bool" default="false"> - </argument> + <return type="bool" /> + <argument index="0" name="byte_offset" type="int" /> + <argument index="1" name="allow_objects" type="bool" default="false" /> <description> </description> </method> <method name="hex_encode" qualifiers="const"> - <return type="String"> - </return> + <return type="String" /> <description> Returns a hexadecimal representation of this array as a [String]. [codeblocks] @@ -396,125 +301,130 @@ </description> </method> <method name="insert"> - <return type="int"> - </return> - <argument index="0" name="at_index" type="int"> - </argument> - <argument index="1" name="value" type="int"> - </argument> + <return type="int" /> + <argument index="0" name="at_index" type="int" /> + <argument index="1" name="value" type="int" /> <description> Inserts a new element at a given position in the array. The position must be valid, or at the end of the array ([code]idx == size()[/code]). </description> </method> <method name="is_empty" qualifiers="const"> - <return type="bool"> - </return> + <return type="bool" /> <description> Returns [code]true[/code] if the array is empty. </description> </method> <method name="operator !=" qualifiers="operator"> - <return type="bool"> - </return> - <argument index="0" name="right" type="PackedByteArray"> - </argument> + <return type="bool" /> + <argument index="0" name="right" type="PackedByteArray" /> <description> </description> </method> <method name="operator +" qualifiers="operator"> - <return type="PackedByteArray"> - </return> - <argument index="0" name="right" type="PackedByteArray"> - </argument> + <return type="PackedByteArray" /> + <argument index="0" name="right" type="PackedByteArray" /> <description> </description> </method> <method name="operator ==" qualifiers="operator"> - <return type="bool"> - </return> - <argument index="0" name="right" type="PackedByteArray"> - </argument> + <return type="bool" /> + <argument index="0" name="right" type="PackedByteArray" /> <description> </description> </method> <method name="operator []" qualifiers="operator"> - <return type="int"> - </return> - <argument index="0" name="index" type="int"> - </argument> + <return type="int" /> + <argument index="0" name="index" type="int" /> <description> </description> </method> <method name="push_back"> - <return type="bool"> - </return> - <argument index="0" name="value" type="int"> - </argument> + <return type="bool" /> + <argument index="0" name="value" type="int" /> <description> Appends an element at the end of the array. </description> </method> <method name="remove"> - <return type="void"> - </return> - <argument index="0" name="index" type="int"> - </argument> + <return type="void" /> + <argument index="0" name="index" type="int" /> <description> Removes an element from the array by index. </description> </method> <method name="resize"> - <return type="int"> - </return> - <argument index="0" name="new_size" type="int"> - </argument> + <return type="int" /> + <argument index="0" name="new_size" type="int" /> <description> Sets the size of the array. If the array is grown, reserves elements at the end of the array. If the array is shrunk, truncates the array to the new size. </description> </method> <method name="reverse"> - <return type="void"> - </return> + <return type="void" /> <description> Reverses the order of the elements in the array. </description> </method> <method name="set"> - <return type="void"> - </return> - <argument index="0" name="index" type="int"> - </argument> - <argument index="1" name="value" type="int"> - </argument> + <return type="void" /> + <argument index="0" name="index" type="int" /> + <argument index="1" name="value" type="int" /> <description> Changes the byte at the given index. </description> </method> <method name="size" qualifiers="const"> - <return type="int"> - </return> + <return type="int" /> <description> Returns the size of the array. </description> </method> <method name="sort"> - <return type="void"> - </return> + <return type="void" /> <description> Sorts the elements of the array in ascending order. </description> </method> <method name="subarray" qualifiers="const"> - <return type="PackedByteArray"> - </return> - <argument index="0" name="from" type="int"> - </argument> - <argument index="1" name="to" type="int"> - </argument> + <return type="PackedByteArray" /> + <argument index="0" name="from" type="int" /> + <argument index="1" name="to" type="int" /> <description> Returns the slice of the [PackedByteArray] between indices (inclusive) as a new [PackedByteArray]. Any negative index is considered to be from the end of the array. </description> </method> + <method name="to_float32_array" qualifiers="const"> + <return type="PackedFloat32Array" /> + <description> + Returns a copy of the data converted to a [PackedFloat32Array], where each block of 4 bytes has been converted to a 32-bit float (C++ [code]float[/code]). + The size of the new array will be [code]byte_array.size() / 4[/code]. + If the original data can't be converted to 32-bit floats, the resulting data is undefined. + </description> + </method> + <method name="to_float64_array" qualifiers="const"> + <return type="PackedFloat64Array" /> + <description> + Returns a copy of the data converted to a [PackedFloat64Array], where each block of 8 bytes has been converted to a 64-bit float (C++ [code]double[/code], Godot [float]). + The size of the new array will be [code]byte_array.size() / 8[/code]. + If the original data can't be converted to 64-bit floats, the resulting data is undefined. + </description> + </method> + <method name="to_int32_array" qualifiers="const"> + <return type="PackedInt32Array" /> + <description> + Returns a copy of the data converted to a [PackedInt32Array], where each block of 4 bytes has been converted to a signed 32-bit integer (C++ [code]int32_t[/code]). + The size of the new array will be [code]byte_array.size() / 4[/code]. + If the original data can't be converted to signed 32-bit integers, the resulting data is undefined. + </description> + </method> + <method name="to_int64_array" qualifiers="const"> + <return type="PackedInt64Array" /> + <description> + Returns a copy of the data converted to a [PackedInt64Array], where each block of 4 bytes has been converted to a signed 64-bit integer (C++ [code]int64_t[/code], Godot [int]). + The size of the new array will be [code]byte_array.size() / 8[/code]. + If the original data can't be converted to signed 64-bit integers, the resulting data is undefined. + </description> + </method> </methods> <constants> </constants> diff --git a/doc/classes/PackedColorArray.xml b/doc/classes/PackedColorArray.xml index 19cfcd7c87..a5a5703bfa 100644 --- a/doc/classes/PackedColorArray.xml +++ b/doc/classes/PackedColorArray.xml @@ -10,195 +10,153 @@ </tutorials> <methods> <method name="PackedColorArray" qualifiers="constructor"> - <return type="PackedColorArray"> - </return> + <return type="PackedColorArray" /> <description> Constructs an empty [PackedColorArray]. </description> </method> <method name="PackedColorArray" qualifiers="constructor"> - <return type="PackedColorArray"> - </return> - <argument index="0" name="from" type="PackedColorArray"> - </argument> + <return type="PackedColorArray" /> + <argument index="0" name="from" type="PackedColorArray" /> <description> Constructs a [PackedColorArray] as a copy of the given [PackedColorArray]. </description> </method> <method name="PackedColorArray" qualifiers="constructor"> - <return type="PackedColorArray"> - </return> - <argument index="0" name="from" type="Array"> - </argument> + <return type="PackedColorArray" /> + <argument index="0" name="from" type="Array" /> <description> Constructs a new [PackedColorArray]. Optionally, you can pass in a generic [Array] that will be converted. </description> </method> <method name="append"> - <return type="bool"> - </return> - <argument index="0" name="value" type="Color"> - </argument> + <return type="bool" /> + <argument index="0" name="value" type="Color" /> <description> Appends an element at the end of the array (alias of [method push_back]). </description> </method> <method name="append_array"> - <return type="void"> - </return> - <argument index="0" name="array" type="PackedColorArray"> - </argument> + <return type="void" /> + <argument index="0" name="array" type="PackedColorArray" /> <description> Appends a [PackedColorArray] at the end of this array. </description> </method> <method name="duplicate"> - <return type="PackedColorArray"> - </return> + <return type="PackedColorArray" /> <description> Creates a copy of the array, and returns it. </description> </method> <method name="fill"> - <return type="void"> - </return> - <argument index="0" name="value" type="Color"> - </argument> + <return type="void" /> + <argument index="0" name="value" type="Color" /> <description> Assigns the given value to all elements in the array. This can typically be used together with [method resize] to create an array with a given size and initialized elements. </description> </method> <method name="has"> - <return type="bool"> - </return> - <argument index="0" name="value" type="Color"> - </argument> + <return type="bool" /> + <argument index="0" name="value" type="Color" /> <description> Returns [code]true[/code] if the array contains [code]value[/code]. </description> </method> <method name="insert"> - <return type="int"> - </return> - <argument index="0" name="at_index" type="int"> - </argument> - <argument index="1" name="value" type="Color"> - </argument> + <return type="int" /> + <argument index="0" name="at_index" type="int" /> + <argument index="1" name="value" type="Color" /> <description> Inserts a new element at a given position in the array. The position must be valid, or at the end of the array ([code]idx == size()[/code]). </description> </method> <method name="is_empty" qualifiers="const"> - <return type="bool"> - </return> + <return type="bool" /> <description> Returns [code]true[/code] if the array is empty. </description> </method> <method name="operator !=" qualifiers="operator"> - <return type="bool"> - </return> - <argument index="0" name="right" type="PackedColorArray"> - </argument> + <return type="bool" /> + <argument index="0" name="right" type="PackedColorArray" /> <description> </description> </method> <method name="operator +" qualifiers="operator"> - <return type="PackedColorArray"> - </return> - <argument index="0" name="right" type="PackedColorArray"> - </argument> + <return type="PackedColorArray" /> + <argument index="0" name="right" type="PackedColorArray" /> <description> </description> </method> <method name="operator ==" qualifiers="operator"> - <return type="bool"> - </return> - <argument index="0" name="right" type="PackedColorArray"> - </argument> + <return type="bool" /> + <argument index="0" name="right" type="PackedColorArray" /> <description> </description> </method> <method name="operator []" qualifiers="operator"> - <return type="Color"> - </return> - <argument index="0" name="index" type="int"> - </argument> + <return type="Color" /> + <argument index="0" name="index" type="int" /> <description> </description> </method> <method name="push_back"> - <return type="bool"> - </return> - <argument index="0" name="value" type="Color"> - </argument> + <return type="bool" /> + <argument index="0" name="value" type="Color" /> <description> Appends a value to the array. </description> </method> <method name="remove"> - <return type="void"> - </return> - <argument index="0" name="index" type="int"> - </argument> + <return type="void" /> + <argument index="0" name="index" type="int" /> <description> Removes an element from the array by index. </description> </method> <method name="resize"> - <return type="int"> - </return> - <argument index="0" name="new_size" type="int"> - </argument> + <return type="int" /> + <argument index="0" name="new_size" type="int" /> <description> Sets the size of the array. If the array is grown, reserves elements at the end of the array. If the array is shrunk, truncates the array to the new size. </description> </method> <method name="reverse"> - <return type="void"> - </return> + <return type="void" /> <description> Reverses the order of the elements in the array. </description> </method> <method name="set"> - <return type="void"> - </return> - <argument index="0" name="index" type="int"> - </argument> - <argument index="1" name="value" type="Color"> - </argument> + <return type="void" /> + <argument index="0" name="index" type="int" /> + <argument index="1" name="value" type="Color" /> <description> Changes the [Color] at the given index. </description> </method> <method name="size" qualifiers="const"> - <return type="int"> - </return> + <return type="int" /> <description> Returns the size of the array. </description> </method> <method name="sort"> - <return type="void"> - </return> + <return type="void" /> <description> Sorts the elements of the array in ascending order. </description> </method> <method name="subarray" qualifiers="const"> - <return type="PackedColorArray"> - </return> - <argument index="0" name="from" type="int"> - </argument> - <argument index="1" name="to" type="int"> - </argument> + <return type="PackedColorArray" /> + <argument index="0" name="from" type="int" /> + <argument index="1" name="to" type="int" /> <description> </description> </method> <method name="to_byte_array" qualifiers="const"> - <return type="PackedByteArray"> - </return> + <return type="PackedByteArray" /> <description> </description> </method> diff --git a/doc/classes/PackedDataContainer.xml b/doc/classes/PackedDataContainer.xml index f72db514f0..0a765fcc75 100644 --- a/doc/classes/PackedDataContainer.xml +++ b/doc/classes/PackedDataContainer.xml @@ -8,16 +8,13 @@ </tutorials> <methods> <method name="pack"> - <return type="int" enum="Error"> - </return> - <argument index="0" name="value" type="Variant"> - </argument> + <return type="int" enum="Error" /> + <argument index="0" name="value" type="Variant" /> <description> </description> </method> <method name="size" qualifiers="const"> - <return type="int"> - </return> + <return type="int" /> <description> </description> </method> diff --git a/doc/classes/PackedDataContainerRef.xml b/doc/classes/PackedDataContainerRef.xml index bfd5a6f1c1..5e42079b97 100644 --- a/doc/classes/PackedDataContainerRef.xml +++ b/doc/classes/PackedDataContainerRef.xml @@ -9,8 +9,7 @@ </tutorials> <methods> <method name="size" qualifiers="const"> - <return type="int"> - </return> + <return type="int" /> <description> </description> </method> diff --git a/doc/classes/PackedFloat32Array.xml b/doc/classes/PackedFloat32Array.xml index ab97c9a695..9e7dd8f99e 100644 --- a/doc/classes/PackedFloat32Array.xml +++ b/doc/classes/PackedFloat32Array.xml @@ -11,196 +11,156 @@ </tutorials> <methods> <method name="PackedFloat32Array" qualifiers="constructor"> - <return type="PackedFloat32Array"> - </return> + <return type="PackedFloat32Array" /> <description> Constructs an empty [PackedFloat32Array]. </description> </method> <method name="PackedFloat32Array" qualifiers="constructor"> - <return type="PackedFloat32Array"> - </return> - <argument index="0" name="from" type="PackedFloat32Array"> - </argument> + <return type="PackedFloat32Array" /> + <argument index="0" name="from" type="PackedFloat32Array" /> <description> Constructs a [PackedFloat32Array] as a copy of the given [PackedFloat32Array]. </description> </method> <method name="PackedFloat32Array" qualifiers="constructor"> - <return type="PackedFloat32Array"> - </return> - <argument index="0" name="from" type="Array"> - </argument> + <return type="PackedFloat32Array" /> + <argument index="0" name="from" type="Array" /> <description> Constructs a new [PackedFloat32Array]. Optionally, you can pass in a generic [Array] that will be converted. </description> </method> <method name="append"> - <return type="bool"> - </return> - <argument index="0" name="value" type="float"> - </argument> + <return type="bool" /> + <argument index="0" name="value" type="float" /> <description> Appends an element at the end of the array (alias of [method push_back]). </description> </method> <method name="append_array"> - <return type="void"> - </return> - <argument index="0" name="array" type="PackedFloat32Array"> - </argument> + <return type="void" /> + <argument index="0" name="array" type="PackedFloat32Array" /> <description> Appends a [PackedFloat32Array] at the end of this array. </description> </method> <method name="duplicate"> - <return type="PackedFloat32Array"> - </return> + <return type="PackedFloat32Array" /> <description> Creates a copy of the array, and returns it. </description> </method> <method name="fill"> - <return type="void"> - </return> - <argument index="0" name="value" type="float"> - </argument> + <return type="void" /> + <argument index="0" name="value" type="float" /> <description> Assigns the given value to all elements in the array. This can typically be used together with [method resize] to create an array with a given size and initialized elements. </description> </method> <method name="has"> - <return type="bool"> - </return> - <argument index="0" name="value" type="float"> - </argument> + <return type="bool" /> + <argument index="0" name="value" type="float" /> <description> Returns [code]true[/code] if the array contains [code]value[/code]. </description> </method> <method name="insert"> - <return type="int"> - </return> - <argument index="0" name="at_index" type="int"> - </argument> - <argument index="1" name="value" type="float"> - </argument> + <return type="int" /> + <argument index="0" name="at_index" type="int" /> + <argument index="1" name="value" type="float" /> <description> Inserts a new element at a given position in the array. The position must be valid, or at the end of the array ([code]idx == size()[/code]). </description> </method> <method name="is_empty" qualifiers="const"> - <return type="bool"> - </return> + <return type="bool" /> <description> Returns [code]true[/code] if the array is empty. </description> </method> <method name="operator !=" qualifiers="operator"> - <return type="bool"> - </return> - <argument index="0" name="right" type="PackedFloat32Array"> - </argument> + <return type="bool" /> + <argument index="0" name="right" type="PackedFloat32Array" /> <description> </description> </method> <method name="operator +" qualifiers="operator"> - <return type="PackedFloat32Array"> - </return> - <argument index="0" name="right" type="PackedFloat32Array"> - </argument> + <return type="PackedFloat32Array" /> + <argument index="0" name="right" type="PackedFloat32Array" /> <description> </description> </method> <method name="operator ==" qualifiers="operator"> - <return type="bool"> - </return> - <argument index="0" name="right" type="PackedFloat32Array"> - </argument> + <return type="bool" /> + <argument index="0" name="right" type="PackedFloat32Array" /> <description> </description> </method> <method name="operator []" qualifiers="operator"> - <return type="float"> - </return> - <argument index="0" name="index" type="int"> - </argument> + <return type="float" /> + <argument index="0" name="index" type="int" /> <description> </description> </method> <method name="push_back"> - <return type="bool"> - </return> - <argument index="0" name="value" type="float"> - </argument> + <return type="bool" /> + <argument index="0" name="value" type="float" /> <description> Appends an element at the end of the array. </description> </method> <method name="remove"> - <return type="void"> - </return> - <argument index="0" name="index" type="int"> - </argument> + <return type="void" /> + <argument index="0" name="index" type="int" /> <description> Removes an element from the array by index. </description> </method> <method name="resize"> - <return type="int"> - </return> - <argument index="0" name="new_size" type="int"> - </argument> + <return type="int" /> + <argument index="0" name="new_size" type="int" /> <description> Sets the size of the array. If the array is grown, reserves elements at the end of the array. If the array is shrunk, truncates the array to the new size. </description> </method> <method name="reverse"> - <return type="void"> - </return> + <return type="void" /> <description> Reverses the order of the elements in the array. </description> </method> <method name="set"> - <return type="void"> - </return> - <argument index="0" name="index" type="int"> - </argument> - <argument index="1" name="value" type="float"> - </argument> + <return type="void" /> + <argument index="0" name="index" type="int" /> + <argument index="1" name="value" type="float" /> <description> Changes the float at the given index. </description> </method> <method name="size" qualifiers="const"> - <return type="int"> - </return> + <return type="int" /> <description> Returns the size of the array. </description> </method> <method name="sort"> - <return type="void"> - </return> + <return type="void" /> <description> Sorts the elements of the array in ascending order. </description> </method> <method name="subarray" qualifiers="const"> - <return type="PackedFloat32Array"> - </return> - <argument index="0" name="from" type="int"> - </argument> - <argument index="1" name="to" type="int"> - </argument> + <return type="PackedFloat32Array" /> + <argument index="0" name="from" type="int" /> + <argument index="1" name="to" type="int" /> <description> </description> </method> <method name="to_byte_array" qualifiers="const"> - <return type="PackedByteArray"> - </return> + <return type="PackedByteArray" /> <description> + Returns a copy of the data converted to a [PackedByteArray], where each element have been encoded as 4 bytes. + The size of the new array will be [code]float32_array.size() * 4[/code]. </description> </method> </methods> diff --git a/doc/classes/PackedFloat64Array.xml b/doc/classes/PackedFloat64Array.xml index ad20801b01..ff4cf0edf8 100644 --- a/doc/classes/PackedFloat64Array.xml +++ b/doc/classes/PackedFloat64Array.xml @@ -11,196 +11,156 @@ </tutorials> <methods> <method name="PackedFloat64Array" qualifiers="constructor"> - <return type="PackedFloat64Array"> - </return> + <return type="PackedFloat64Array" /> <description> Constructs an empty [PackedFloat64Array]. </description> </method> <method name="PackedFloat64Array" qualifiers="constructor"> - <return type="PackedFloat64Array"> - </return> - <argument index="0" name="from" type="PackedFloat64Array"> - </argument> + <return type="PackedFloat64Array" /> + <argument index="0" name="from" type="PackedFloat64Array" /> <description> Constructs a [PackedFloat64Array] as a copy of the given [PackedFloat64Array]. </description> </method> <method name="PackedFloat64Array" qualifiers="constructor"> - <return type="PackedFloat64Array"> - </return> - <argument index="0" name="from" type="Array"> - </argument> + <return type="PackedFloat64Array" /> + <argument index="0" name="from" type="Array" /> <description> Constructs a new [PackedFloat64Array]. Optionally, you can pass in a generic [Array] that will be converted. </description> </method> <method name="append"> - <return type="bool"> - </return> - <argument index="0" name="value" type="float"> - </argument> + <return type="bool" /> + <argument index="0" name="value" type="float" /> <description> Appends an element at the end of the array (alias of [method push_back]). </description> </method> <method name="append_array"> - <return type="void"> - </return> - <argument index="0" name="array" type="PackedFloat64Array"> - </argument> + <return type="void" /> + <argument index="0" name="array" type="PackedFloat64Array" /> <description> Appends a [PackedFloat64Array] at the end of this array. </description> </method> <method name="duplicate"> - <return type="PackedFloat64Array"> - </return> + <return type="PackedFloat64Array" /> <description> Creates a copy of the array, and returns it. </description> </method> <method name="fill"> - <return type="void"> - </return> - <argument index="0" name="value" type="float"> - </argument> + <return type="void" /> + <argument index="0" name="value" type="float" /> <description> Assigns the given value to all elements in the array. This can typically be used together with [method resize] to create an array with a given size and initialized elements. </description> </method> <method name="has"> - <return type="bool"> - </return> - <argument index="0" name="value" type="float"> - </argument> + <return type="bool" /> + <argument index="0" name="value" type="float" /> <description> Returns [code]true[/code] if the array contains [code]value[/code]. </description> </method> <method name="insert"> - <return type="int"> - </return> - <argument index="0" name="at_index" type="int"> - </argument> - <argument index="1" name="value" type="float"> - </argument> + <return type="int" /> + <argument index="0" name="at_index" type="int" /> + <argument index="1" name="value" type="float" /> <description> Inserts a new element at a given position in the array. The position must be valid, or at the end of the array ([code]idx == size()[/code]). </description> </method> <method name="is_empty" qualifiers="const"> - <return type="bool"> - </return> + <return type="bool" /> <description> Returns [code]true[/code] if the array is empty. </description> </method> <method name="operator !=" qualifiers="operator"> - <return type="bool"> - </return> - <argument index="0" name="right" type="PackedFloat64Array"> - </argument> + <return type="bool" /> + <argument index="0" name="right" type="PackedFloat64Array" /> <description> </description> </method> <method name="operator +" qualifiers="operator"> - <return type="PackedFloat64Array"> - </return> - <argument index="0" name="right" type="PackedFloat64Array"> - </argument> + <return type="PackedFloat64Array" /> + <argument index="0" name="right" type="PackedFloat64Array" /> <description> </description> </method> <method name="operator ==" qualifiers="operator"> - <return type="bool"> - </return> - <argument index="0" name="right" type="PackedFloat64Array"> - </argument> + <return type="bool" /> + <argument index="0" name="right" type="PackedFloat64Array" /> <description> </description> </method> <method name="operator []" qualifiers="operator"> - <return type="float"> - </return> - <argument index="0" name="index" type="int"> - </argument> + <return type="float" /> + <argument index="0" name="index" type="int" /> <description> </description> </method> <method name="push_back"> - <return type="bool"> - </return> - <argument index="0" name="value" type="float"> - </argument> + <return type="bool" /> + <argument index="0" name="value" type="float" /> <description> Appends an element at the end of the array. </description> </method> <method name="remove"> - <return type="void"> - </return> - <argument index="0" name="index" type="int"> - </argument> + <return type="void" /> + <argument index="0" name="index" type="int" /> <description> Removes an element from the array by index. </description> </method> <method name="resize"> - <return type="int"> - </return> - <argument index="0" name="new_size" type="int"> - </argument> + <return type="int" /> + <argument index="0" name="new_size" type="int" /> <description> Sets the size of the array. If the array is grown, reserves elements at the end of the array. If the array is shrunk, truncates the array to the new size. </description> </method> <method name="reverse"> - <return type="void"> - </return> + <return type="void" /> <description> Reverses the order of the elements in the array. </description> </method> <method name="set"> - <return type="void"> - </return> - <argument index="0" name="index" type="int"> - </argument> - <argument index="1" name="value" type="float"> - </argument> + <return type="void" /> + <argument index="0" name="index" type="int" /> + <argument index="1" name="value" type="float" /> <description> Changes the float at the given index. </description> </method> <method name="size" qualifiers="const"> - <return type="int"> - </return> + <return type="int" /> <description> Returns the size of the array. </description> </method> <method name="sort"> - <return type="void"> - </return> + <return type="void" /> <description> Sorts the elements of the array in ascending order. </description> </method> <method name="subarray" qualifiers="const"> - <return type="PackedFloat64Array"> - </return> - <argument index="0" name="from" type="int"> - </argument> - <argument index="1" name="to" type="int"> - </argument> + <return type="PackedFloat64Array" /> + <argument index="0" name="from" type="int" /> + <argument index="1" name="to" type="int" /> <description> </description> </method> <method name="to_byte_array" qualifiers="const"> - <return type="PackedByteArray"> - </return> + <return type="PackedByteArray" /> <description> + Returns a copy of the data converted to a [PackedByteArray], where each element have been encoded as 8 bytes. + The size of the new array will be [code]float64_array.size() * 8[/code]. </description> </method> </methods> diff --git a/doc/classes/PackedInt32Array.xml b/doc/classes/PackedInt32Array.xml index ff4729082e..2e9716b665 100644 --- a/doc/classes/PackedInt32Array.xml +++ b/doc/classes/PackedInt32Array.xml @@ -11,196 +11,156 @@ </tutorials> <methods> <method name="PackedInt32Array" qualifiers="constructor"> - <return type="PackedInt32Array"> - </return> + <return type="PackedInt32Array" /> <description> Constructs an empty [PackedInt32Array]. </description> </method> <method name="PackedInt32Array" qualifiers="constructor"> - <return type="PackedInt32Array"> - </return> - <argument index="0" name="from" type="PackedInt32Array"> - </argument> + <return type="PackedInt32Array" /> + <argument index="0" name="from" type="PackedInt32Array" /> <description> Constructs a [PackedInt32Array] as a copy of the given [PackedInt32Array]. </description> </method> <method name="PackedInt32Array" qualifiers="constructor"> - <return type="PackedInt32Array"> - </return> - <argument index="0" name="from" type="Array"> - </argument> + <return type="PackedInt32Array" /> + <argument index="0" name="from" type="Array" /> <description> Constructs a new [PackedInt32Array]. Optionally, you can pass in a generic [Array] that will be converted. </description> </method> <method name="append"> - <return type="bool"> - </return> - <argument index="0" name="value" type="int"> - </argument> + <return type="bool" /> + <argument index="0" name="value" type="int" /> <description> Appends an element at the end of the array (alias of [method push_back]). </description> </method> <method name="append_array"> - <return type="void"> - </return> - <argument index="0" name="array" type="PackedInt32Array"> - </argument> + <return type="void" /> + <argument index="0" name="array" type="PackedInt32Array" /> <description> Appends a [PackedInt32Array] at the end of this array. </description> </method> <method name="duplicate"> - <return type="PackedInt32Array"> - </return> + <return type="PackedInt32Array" /> <description> Creates a copy of the array, and returns it. </description> </method> <method name="fill"> - <return type="void"> - </return> - <argument index="0" name="value" type="int"> - </argument> + <return type="void" /> + <argument index="0" name="value" type="int" /> <description> Assigns the given value to all elements in the array. This can typically be used together with [method resize] to create an array with a given size and initialized elements. </description> </method> <method name="has"> - <return type="bool"> - </return> - <argument index="0" name="value" type="int"> - </argument> + <return type="bool" /> + <argument index="0" name="value" type="int" /> <description> Returns [code]true[/code] if the array contains [code]value[/code]. </description> </method> <method name="insert"> - <return type="int"> - </return> - <argument index="0" name="at_index" type="int"> - </argument> - <argument index="1" name="value" type="int"> - </argument> + <return type="int" /> + <argument index="0" name="at_index" type="int" /> + <argument index="1" name="value" type="int" /> <description> Inserts a new integer at a given position in the array. The position must be valid, or at the end of the array ([code]idx == size()[/code]). </description> </method> <method name="is_empty" qualifiers="const"> - <return type="bool"> - </return> + <return type="bool" /> <description> Returns [code]true[/code] if the array is empty. </description> </method> <method name="operator !=" qualifiers="operator"> - <return type="bool"> - </return> - <argument index="0" name="right" type="PackedInt32Array"> - </argument> + <return type="bool" /> + <argument index="0" name="right" type="PackedInt32Array" /> <description> </description> </method> <method name="operator +" qualifiers="operator"> - <return type="PackedInt32Array"> - </return> - <argument index="0" name="right" type="PackedInt32Array"> - </argument> + <return type="PackedInt32Array" /> + <argument index="0" name="right" type="PackedInt32Array" /> <description> </description> </method> <method name="operator ==" qualifiers="operator"> - <return type="bool"> - </return> - <argument index="0" name="right" type="PackedInt32Array"> - </argument> + <return type="bool" /> + <argument index="0" name="right" type="PackedInt32Array" /> <description> </description> </method> <method name="operator []" qualifiers="operator"> - <return type="int"> - </return> - <argument index="0" name="index" type="int"> - </argument> + <return type="int" /> + <argument index="0" name="index" type="int" /> <description> </description> </method> <method name="push_back"> - <return type="bool"> - </return> - <argument index="0" name="value" type="int"> - </argument> + <return type="bool" /> + <argument index="0" name="value" type="int" /> <description> Appends a value to the array. </description> </method> <method name="remove"> - <return type="void"> - </return> - <argument index="0" name="index" type="int"> - </argument> + <return type="void" /> + <argument index="0" name="index" type="int" /> <description> Removes an element from the array by index. </description> </method> <method name="resize"> - <return type="int"> - </return> - <argument index="0" name="new_size" type="int"> - </argument> + <return type="int" /> + <argument index="0" name="new_size" type="int" /> <description> Sets the size of the array. If the array is grown, reserves elements at the end of the array. If the array is shrunk, truncates the array to the new size. </description> </method> <method name="reverse"> - <return type="void"> - </return> + <return type="void" /> <description> Reverses the order of the elements in the array. </description> </method> <method name="set"> - <return type="void"> - </return> - <argument index="0" name="index" type="int"> - </argument> - <argument index="1" name="value" type="int"> - </argument> + <return type="void" /> + <argument index="0" name="index" type="int" /> + <argument index="1" name="value" type="int" /> <description> Changes the integer at the given index. </description> </method> <method name="size" qualifiers="const"> - <return type="int"> - </return> + <return type="int" /> <description> Returns the array size. </description> </method> <method name="sort"> - <return type="void"> - </return> + <return type="void" /> <description> Sorts the elements of the array in ascending order. </description> </method> <method name="subarray" qualifiers="const"> - <return type="PackedInt32Array"> - </return> - <argument index="0" name="from" type="int"> - </argument> - <argument index="1" name="to" type="int"> - </argument> + <return type="PackedInt32Array" /> + <argument index="0" name="from" type="int" /> + <argument index="1" name="to" type="int" /> <description> </description> </method> <method name="to_byte_array" qualifiers="const"> - <return type="PackedByteArray"> - </return> + <return type="PackedByteArray" /> <description> + Returns a copy of the data converted to a [PackedByteArray], where each element have been encoded as 4 bytes. + The size of the new array will be [code]int32_array.size() * 4[/code]. </description> </method> </methods> diff --git a/doc/classes/PackedInt64Array.xml b/doc/classes/PackedInt64Array.xml index 195b12b129..1e7fff3bc6 100644 --- a/doc/classes/PackedInt64Array.xml +++ b/doc/classes/PackedInt64Array.xml @@ -11,196 +11,156 @@ </tutorials> <methods> <method name="PackedInt64Array" qualifiers="constructor"> - <return type="PackedInt64Array"> - </return> + <return type="PackedInt64Array" /> <description> Constructs an empty [PackedInt64Array]. </description> </method> <method name="PackedInt64Array" qualifiers="constructor"> - <return type="PackedInt64Array"> - </return> - <argument index="0" name="from" type="PackedInt64Array"> - </argument> + <return type="PackedInt64Array" /> + <argument index="0" name="from" type="PackedInt64Array" /> <description> Constructs a [PackedInt64Array] as a copy of the given [PackedInt64Array]. </description> </method> <method name="PackedInt64Array" qualifiers="constructor"> - <return type="PackedInt64Array"> - </return> - <argument index="0" name="from" type="Array"> - </argument> + <return type="PackedInt64Array" /> + <argument index="0" name="from" type="Array" /> <description> Constructs a new [PackedInt64Array]. Optionally, you can pass in a generic [Array] that will be converted. </description> </method> <method name="append"> - <return type="bool"> - </return> - <argument index="0" name="value" type="int"> - </argument> + <return type="bool" /> + <argument index="0" name="value" type="int" /> <description> Appends an element at the end of the array (alias of [method push_back]). </description> </method> <method name="append_array"> - <return type="void"> - </return> - <argument index="0" name="array" type="PackedInt64Array"> - </argument> + <return type="void" /> + <argument index="0" name="array" type="PackedInt64Array" /> <description> Appends a [PackedInt64Array] at the end of this array. </description> </method> <method name="duplicate"> - <return type="PackedInt64Array"> - </return> + <return type="PackedInt64Array" /> <description> Creates a copy of the array, and returns it. </description> </method> <method name="fill"> - <return type="void"> - </return> - <argument index="0" name="value" type="int"> - </argument> + <return type="void" /> + <argument index="0" name="value" type="int" /> <description> Assigns the given value to all elements in the array. This can typically be used together with [method resize] to create an array with a given size and initialized elements. </description> </method> <method name="has"> - <return type="bool"> - </return> - <argument index="0" name="value" type="int"> - </argument> + <return type="bool" /> + <argument index="0" name="value" type="int" /> <description> Returns [code]true[/code] if the array contains [code]value[/code]. </description> </method> <method name="insert"> - <return type="int"> - </return> - <argument index="0" name="at_index" type="int"> - </argument> - <argument index="1" name="value" type="int"> - </argument> + <return type="int" /> + <argument index="0" name="at_index" type="int" /> + <argument index="1" name="value" type="int" /> <description> Inserts a new integer at a given position in the array. The position must be valid, or at the end of the array ([code]idx == size()[/code]). </description> </method> <method name="is_empty" qualifiers="const"> - <return type="bool"> - </return> + <return type="bool" /> <description> Returns [code]true[/code] if the array is empty. </description> </method> <method name="operator !=" qualifiers="operator"> - <return type="bool"> - </return> - <argument index="0" name="right" type="PackedInt64Array"> - </argument> + <return type="bool" /> + <argument index="0" name="right" type="PackedInt64Array" /> <description> </description> </method> <method name="operator +" qualifiers="operator"> - <return type="PackedInt64Array"> - </return> - <argument index="0" name="right" type="PackedInt64Array"> - </argument> + <return type="PackedInt64Array" /> + <argument index="0" name="right" type="PackedInt64Array" /> <description> </description> </method> <method name="operator ==" qualifiers="operator"> - <return type="bool"> - </return> - <argument index="0" name="right" type="PackedInt64Array"> - </argument> + <return type="bool" /> + <argument index="0" name="right" type="PackedInt64Array" /> <description> </description> </method> <method name="operator []" qualifiers="operator"> - <return type="int"> - </return> - <argument index="0" name="index" type="int"> - </argument> + <return type="int" /> + <argument index="0" name="index" type="int" /> <description> </description> </method> <method name="push_back"> - <return type="bool"> - </return> - <argument index="0" name="value" type="int"> - </argument> + <return type="bool" /> + <argument index="0" name="value" type="int" /> <description> Appends a value to the array. </description> </method> <method name="remove"> - <return type="void"> - </return> - <argument index="0" name="index" type="int"> - </argument> + <return type="void" /> + <argument index="0" name="index" type="int" /> <description> Removes an element from the array by index. </description> </method> <method name="resize"> - <return type="int"> - </return> - <argument index="0" name="new_size" type="int"> - </argument> + <return type="int" /> + <argument index="0" name="new_size" type="int" /> <description> Sets the size of the array. If the array is grown, reserves elements at the end of the array. If the array is shrunk, truncates the array to the new size. </description> </method> <method name="reverse"> - <return type="void"> - </return> + <return type="void" /> <description> Reverses the order of the elements in the array. </description> </method> <method name="set"> - <return type="void"> - </return> - <argument index="0" name="index" type="int"> - </argument> - <argument index="1" name="value" type="int"> - </argument> + <return type="void" /> + <argument index="0" name="index" type="int" /> + <argument index="1" name="value" type="int" /> <description> Changes the integer at the given index. </description> </method> <method name="size" qualifiers="const"> - <return type="int"> - </return> + <return type="int" /> <description> Returns the array size. </description> </method> <method name="sort"> - <return type="void"> - </return> + <return type="void" /> <description> Sorts the elements of the array in ascending order. </description> </method> <method name="subarray" qualifiers="const"> - <return type="PackedInt64Array"> - </return> - <argument index="0" name="from" type="int"> - </argument> - <argument index="1" name="to" type="int"> - </argument> + <return type="PackedInt64Array" /> + <argument index="0" name="from" type="int" /> + <argument index="1" name="to" type="int" /> <description> </description> </method> <method name="to_byte_array" qualifiers="const"> - <return type="PackedByteArray"> - </return> + <return type="PackedByteArray" /> <description> + Returns a copy of the data converted to a [PackedByteArray], where each element have been encoded as 8 bytes. + The size of the new array will be [code]int64_array.size() * 8[/code]. </description> </method> </methods> diff --git a/doc/classes/PackedScene.xml b/doc/classes/PackedScene.xml index f39cae8be5..1374496b52 100644 --- a/doc/classes/PackedScene.xml +++ b/doc/classes/PackedScene.xml @@ -77,33 +77,27 @@ </tutorials> <methods> <method name="can_instantiate" qualifiers="const"> - <return type="bool"> - </return> + <return type="bool" /> <description> Returns [code]true[/code] if the scene file has nodes. </description> </method> <method name="get_state"> - <return type="SceneState"> - </return> + <return type="SceneState" /> <description> Returns the [code]SceneState[/code] representing the scene file contents. </description> </method> <method name="instantiate" qualifiers="const"> - <return type="Node"> - </return> - <argument index="0" name="edit_state" type="int" enum="PackedScene.GenEditState" default="0"> - </argument> + <return type="Node" /> + <argument index="0" name="edit_state" type="int" enum="PackedScene.GenEditState" default="0" /> <description> Instantiates the scene's node hierarchy. Triggers child scene instantiation(s). Triggers a [constant Node.NOTIFICATION_INSTANCED] notification on the root node. </description> </method> <method name="pack"> - <return type="int" enum="Error"> - </return> - <argument index="0" name="path" type="Node"> - </argument> + <return type="int" enum="Error" /> + <argument index="0" name="path" type="Node" /> <description> Pack will ignore any sub-nodes not owned by given node. See [member Node.owner]. </description> diff --git a/doc/classes/PackedStringArray.xml b/doc/classes/PackedStringArray.xml index 22458832da..04113d4a2e 100644 --- a/doc/classes/PackedStringArray.xml +++ b/doc/classes/PackedStringArray.xml @@ -11,195 +11,153 @@ </tutorials> <methods> <method name="PackedStringArray" qualifiers="constructor"> - <return type="PackedStringArray"> - </return> + <return type="PackedStringArray" /> <description> Constructs an empty [PackedStringArray]. </description> </method> <method name="PackedStringArray" qualifiers="constructor"> - <return type="PackedStringArray"> - </return> - <argument index="0" name="from" type="PackedStringArray"> - </argument> + <return type="PackedStringArray" /> + <argument index="0" name="from" type="PackedStringArray" /> <description> Constructs a [PackedStringArray] as a copy of the given [PackedStringArray]. </description> </method> <method name="PackedStringArray" qualifiers="constructor"> - <return type="PackedStringArray"> - </return> - <argument index="0" name="from" type="Array"> - </argument> + <return type="PackedStringArray" /> + <argument index="0" name="from" type="Array" /> <description> Constructs a new [PackedStringArray]. Optionally, you can pass in a generic [Array] that will be converted. </description> </method> <method name="append"> - <return type="bool"> - </return> - <argument index="0" name="value" type="String"> - </argument> + <return type="bool" /> + <argument index="0" name="value" type="String" /> <description> Appends an element at the end of the array (alias of [method push_back]). </description> </method> <method name="append_array"> - <return type="void"> - </return> - <argument index="0" name="array" type="PackedStringArray"> - </argument> + <return type="void" /> + <argument index="0" name="array" type="PackedStringArray" /> <description> Appends a [PackedStringArray] at the end of this array. </description> </method> <method name="duplicate"> - <return type="PackedStringArray"> - </return> + <return type="PackedStringArray" /> <description> Creates a copy of the array, and returns it. </description> </method> <method name="fill"> - <return type="void"> - </return> - <argument index="0" name="value" type="String"> - </argument> + <return type="void" /> + <argument index="0" name="value" type="String" /> <description> Assigns the given value to all elements in the array. This can typically be used together with [method resize] to create an array with a given size and initialized elements. </description> </method> <method name="has"> - <return type="bool"> - </return> - <argument index="0" name="value" type="String"> - </argument> + <return type="bool" /> + <argument index="0" name="value" type="String" /> <description> Returns [code]true[/code] if the array contains [code]value[/code]. </description> </method> <method name="insert"> - <return type="int"> - </return> - <argument index="0" name="at_index" type="int"> - </argument> - <argument index="1" name="value" type="String"> - </argument> + <return type="int" /> + <argument index="0" name="at_index" type="int" /> + <argument index="1" name="value" type="String" /> <description> Inserts a new element at a given position in the array. The position must be valid, or at the end of the array ([code]idx == size()[/code]). </description> </method> <method name="is_empty" qualifiers="const"> - <return type="bool"> - </return> + <return type="bool" /> <description> Returns [code]true[/code] if the array is empty. </description> </method> <method name="operator !=" qualifiers="operator"> - <return type="bool"> - </return> - <argument index="0" name="right" type="PackedStringArray"> - </argument> + <return type="bool" /> + <argument index="0" name="right" type="PackedStringArray" /> <description> </description> </method> <method name="operator +" qualifiers="operator"> - <return type="PackedStringArray"> - </return> - <argument index="0" name="right" type="PackedStringArray"> - </argument> + <return type="PackedStringArray" /> + <argument index="0" name="right" type="PackedStringArray" /> <description> </description> </method> <method name="operator ==" qualifiers="operator"> - <return type="bool"> - </return> - <argument index="0" name="right" type="PackedStringArray"> - </argument> + <return type="bool" /> + <argument index="0" name="right" type="PackedStringArray" /> <description> </description> </method> <method name="operator []" qualifiers="operator"> - <return type="String"> - </return> - <argument index="0" name="index" type="int"> - </argument> + <return type="String" /> + <argument index="0" name="index" type="int" /> <description> </description> </method> <method name="push_back"> - <return type="bool"> - </return> - <argument index="0" name="value" type="String"> - </argument> + <return type="bool" /> + <argument index="0" name="value" type="String" /> <description> Appends a string element at end of the array. </description> </method> <method name="remove"> - <return type="void"> - </return> - <argument index="0" name="index" type="int"> - </argument> + <return type="void" /> + <argument index="0" name="index" type="int" /> <description> Removes an element from the array by index. </description> </method> <method name="resize"> - <return type="int"> - </return> - <argument index="0" name="new_size" type="int"> - </argument> + <return type="int" /> + <argument index="0" name="new_size" type="int" /> <description> Sets the size of the array. If the array is grown, reserves elements at the end of the array. If the array is shrunk, truncates the array to the new size. </description> </method> <method name="reverse"> - <return type="void"> - </return> + <return type="void" /> <description> Reverses the order of the elements in the array. </description> </method> <method name="set"> - <return type="void"> - </return> - <argument index="0" name="index" type="int"> - </argument> - <argument index="1" name="value" type="String"> - </argument> + <return type="void" /> + <argument index="0" name="index" type="int" /> + <argument index="1" name="value" type="String" /> <description> Changes the [String] at the given index. </description> </method> <method name="size" qualifiers="const"> - <return type="int"> - </return> + <return type="int" /> <description> Returns the size of the array. </description> </method> <method name="sort"> - <return type="void"> - </return> + <return type="void" /> <description> Sorts the elements of the array in ascending order. </description> </method> <method name="subarray" qualifiers="const"> - <return type="PackedStringArray"> - </return> - <argument index="0" name="from" type="int"> - </argument> - <argument index="1" name="to" type="int"> - </argument> + <return type="PackedStringArray" /> + <argument index="0" name="from" type="int" /> + <argument index="1" name="to" type="int" /> <description> </description> </method> <method name="to_byte_array" qualifiers="const"> - <return type="PackedByteArray"> - </return> + <return type="PackedByteArray" /> <description> </description> </method> diff --git a/doc/classes/PackedVector2Array.xml b/doc/classes/PackedVector2Array.xml index 6c8791f988..76d3aff20e 100644 --- a/doc/classes/PackedVector2Array.xml +++ b/doc/classes/PackedVector2Array.xml @@ -11,203 +11,159 @@ </tutorials> <methods> <method name="PackedVector2Array" qualifiers="constructor"> - <return type="PackedVector2Array"> - </return> + <return type="PackedVector2Array" /> <description> Constructs an empty [PackedVector2Array]. </description> </method> <method name="PackedVector2Array" qualifiers="constructor"> - <return type="PackedVector2Array"> - </return> - <argument index="0" name="from" type="PackedVector2Array"> - </argument> + <return type="PackedVector2Array" /> + <argument index="0" name="from" type="PackedVector2Array" /> <description> Constructs a [PackedVector2Array] as a copy of the given [PackedVector2Array]. </description> </method> <method name="PackedVector2Array" qualifiers="constructor"> - <return type="PackedVector2Array"> - </return> - <argument index="0" name="from" type="Array"> - </argument> + <return type="PackedVector2Array" /> + <argument index="0" name="from" type="Array" /> <description> Constructs a new [PackedVector2Array]. Optionally, you can pass in a generic [Array] that will be converted. </description> </method> <method name="append"> - <return type="bool"> - </return> - <argument index="0" name="value" type="Vector2"> - </argument> + <return type="bool" /> + <argument index="0" name="value" type="Vector2" /> <description> Appends an element at the end of the array (alias of [method push_back]). </description> </method> <method name="append_array"> - <return type="void"> - </return> - <argument index="0" name="array" type="PackedVector2Array"> - </argument> + <return type="void" /> + <argument index="0" name="array" type="PackedVector2Array" /> <description> Appends a [PackedVector2Array] at the end of this array. </description> </method> <method name="duplicate"> - <return type="PackedVector2Array"> - </return> + <return type="PackedVector2Array" /> <description> Creates a copy of the array, and returns it. </description> </method> <method name="fill"> - <return type="void"> - </return> - <argument index="0" name="value" type="Vector2"> - </argument> + <return type="void" /> + <argument index="0" name="value" type="Vector2" /> <description> Assigns the given value to all elements in the array. This can typically be used together with [method resize] to create an array with a given size and initialized elements. </description> </method> <method name="has"> - <return type="bool"> - </return> - <argument index="0" name="value" type="Vector2"> - </argument> + <return type="bool" /> + <argument index="0" name="value" type="Vector2" /> <description> Returns [code]true[/code] if the array contains [code]value[/code]. </description> </method> <method name="insert"> - <return type="int"> - </return> - <argument index="0" name="at_index" type="int"> - </argument> - <argument index="1" name="value" type="Vector2"> - </argument> + <return type="int" /> + <argument index="0" name="at_index" type="int" /> + <argument index="1" name="value" type="Vector2" /> <description> Inserts a new element at a given position in the array. The position must be valid, or at the end of the array ([code]idx == size()[/code]). </description> </method> <method name="is_empty" qualifiers="const"> - <return type="bool"> - </return> + <return type="bool" /> <description> Returns [code]true[/code] if the array is empty. </description> </method> <method name="operator !=" qualifiers="operator"> - <return type="bool"> - </return> - <argument index="0" name="right" type="PackedVector2Array"> - </argument> + <return type="bool" /> + <argument index="0" name="right" type="PackedVector2Array" /> <description> </description> </method> <method name="operator *" qualifiers="operator"> - <return type="PackedVector2Array"> - </return> - <argument index="0" name="right" type="Transform2D"> - </argument> + <return type="PackedVector2Array" /> + <argument index="0" name="right" type="Transform2D" /> <description> </description> </method> <method name="operator +" qualifiers="operator"> - <return type="PackedVector2Array"> - </return> - <argument index="0" name="right" type="PackedVector2Array"> - </argument> + <return type="PackedVector2Array" /> + <argument index="0" name="right" type="PackedVector2Array" /> <description> </description> </method> <method name="operator ==" qualifiers="operator"> - <return type="bool"> - </return> - <argument index="0" name="right" type="PackedVector2Array"> - </argument> + <return type="bool" /> + <argument index="0" name="right" type="PackedVector2Array" /> <description> </description> </method> <method name="operator []" qualifiers="operator"> - <return type="Vector2"> - </return> - <argument index="0" name="index" type="int"> - </argument> + <return type="Vector2" /> + <argument index="0" name="index" type="int" /> <description> </description> </method> <method name="push_back"> - <return type="bool"> - </return> - <argument index="0" name="value" type="Vector2"> - </argument> + <return type="bool" /> + <argument index="0" name="value" type="Vector2" /> <description> Inserts a [Vector2] at the end. </description> </method> <method name="remove"> - <return type="void"> - </return> - <argument index="0" name="index" type="int"> - </argument> + <return type="void" /> + <argument index="0" name="index" type="int" /> <description> Removes an element from the array by index. </description> </method> <method name="resize"> - <return type="int"> - </return> - <argument index="0" name="new_size" type="int"> - </argument> + <return type="int" /> + <argument index="0" name="new_size" type="int" /> <description> Sets the size of the array. If the array is grown, reserves elements at the end of the array. If the array is shrunk, truncates the array to the new size. </description> </method> <method name="reverse"> - <return type="void"> - </return> + <return type="void" /> <description> Reverses the order of the elements in the array. </description> </method> <method name="set"> - <return type="void"> - </return> - <argument index="0" name="index" type="int"> - </argument> - <argument index="1" name="value" type="Vector2"> - </argument> + <return type="void" /> + <argument index="0" name="index" type="int" /> + <argument index="1" name="value" type="Vector2" /> <description> Changes the [Vector2] at the given index. </description> </method> <method name="size" qualifiers="const"> - <return type="int"> - </return> + <return type="int" /> <description> Returns the size of the array. </description> </method> <method name="sort"> - <return type="void"> - </return> + <return type="void" /> <description> Sorts the elements of the array in ascending order. </description> </method> <method name="subarray" qualifiers="const"> - <return type="PackedVector2Array"> - </return> - <argument index="0" name="from" type="int"> - </argument> - <argument index="1" name="to" type="int"> - </argument> + <return type="PackedVector2Array" /> + <argument index="0" name="from" type="int" /> + <argument index="1" name="to" type="int" /> <description> </description> </method> <method name="to_byte_array" qualifiers="const"> - <return type="PackedByteArray"> - </return> + <return type="PackedByteArray" /> <description> </description> </method> diff --git a/doc/classes/PackedVector3Array.xml b/doc/classes/PackedVector3Array.xml index 00ded39082..1a35f71619 100644 --- a/doc/classes/PackedVector3Array.xml +++ b/doc/classes/PackedVector3Array.xml @@ -10,203 +10,159 @@ </tutorials> <methods> <method name="PackedVector3Array" qualifiers="constructor"> - <return type="PackedVector3Array"> - </return> + <return type="PackedVector3Array" /> <description> Constructs an empty [PackedVector3Array]. </description> </method> <method name="PackedVector3Array" qualifiers="constructor"> - <return type="PackedVector3Array"> - </return> - <argument index="0" name="from" type="PackedVector3Array"> - </argument> + <return type="PackedVector3Array" /> + <argument index="0" name="from" type="PackedVector3Array" /> <description> Constructs a [PackedVector3Array] as a copy of the given [PackedVector3Array]. </description> </method> <method name="PackedVector3Array" qualifiers="constructor"> - <return type="PackedVector3Array"> - </return> - <argument index="0" name="from" type="Array"> - </argument> + <return type="PackedVector3Array" /> + <argument index="0" name="from" type="Array" /> <description> Constructs a new [PackedVector3Array]. Optionally, you can pass in a generic [Array] that will be converted. </description> </method> <method name="append"> - <return type="bool"> - </return> - <argument index="0" name="value" type="Vector3"> - </argument> + <return type="bool" /> + <argument index="0" name="value" type="Vector3" /> <description> Appends an element at the end of the array (alias of [method push_back]). </description> </method> <method name="append_array"> - <return type="void"> - </return> - <argument index="0" name="array" type="PackedVector3Array"> - </argument> + <return type="void" /> + <argument index="0" name="array" type="PackedVector3Array" /> <description> Appends a [PackedVector3Array] at the end of this array. </description> </method> <method name="duplicate"> - <return type="PackedVector3Array"> - </return> + <return type="PackedVector3Array" /> <description> Creates a copy of the array, and returns it. </description> </method> <method name="fill"> - <return type="void"> - </return> - <argument index="0" name="value" type="Vector3"> - </argument> + <return type="void" /> + <argument index="0" name="value" type="Vector3" /> <description> Assigns the given value to all elements in the array. This can typically be used together with [method resize] to create an array with a given size and initialized elements. </description> </method> <method name="has"> - <return type="bool"> - </return> - <argument index="0" name="value" type="Vector3"> - </argument> + <return type="bool" /> + <argument index="0" name="value" type="Vector3" /> <description> Returns [code]true[/code] if the array contains [code]value[/code]. </description> </method> <method name="insert"> - <return type="int"> - </return> - <argument index="0" name="at_index" type="int"> - </argument> - <argument index="1" name="value" type="Vector3"> - </argument> + <return type="int" /> + <argument index="0" name="at_index" type="int" /> + <argument index="1" name="value" type="Vector3" /> <description> Inserts a new element at a given position in the array. The position must be valid, or at the end of the array ([code]idx == size()[/code]). </description> </method> <method name="is_empty" qualifiers="const"> - <return type="bool"> - </return> + <return type="bool" /> <description> Returns [code]true[/code] if the array is empty. </description> </method> <method name="operator !=" qualifiers="operator"> - <return type="bool"> - </return> - <argument index="0" name="right" type="PackedVector3Array"> - </argument> + <return type="bool" /> + <argument index="0" name="right" type="PackedVector3Array" /> <description> </description> </method> <method name="operator *" qualifiers="operator"> - <return type="PackedVector3Array"> - </return> - <argument index="0" name="right" type="Transform3D"> - </argument> + <return type="PackedVector3Array" /> + <argument index="0" name="right" type="Transform3D" /> <description> </description> </method> <method name="operator +" qualifiers="operator"> - <return type="PackedVector3Array"> - </return> - <argument index="0" name="right" type="PackedVector3Array"> - </argument> + <return type="PackedVector3Array" /> + <argument index="0" name="right" type="PackedVector3Array" /> <description> </description> </method> <method name="operator ==" qualifiers="operator"> - <return type="bool"> - </return> - <argument index="0" name="right" type="PackedVector3Array"> - </argument> + <return type="bool" /> + <argument index="0" name="right" type="PackedVector3Array" /> <description> </description> </method> <method name="operator []" qualifiers="operator"> - <return type="Vector3"> - </return> - <argument index="0" name="index" type="int"> - </argument> + <return type="Vector3" /> + <argument index="0" name="index" type="int" /> <description> </description> </method> <method name="push_back"> - <return type="bool"> - </return> - <argument index="0" name="value" type="Vector3"> - </argument> + <return type="bool" /> + <argument index="0" name="value" type="Vector3" /> <description> Inserts a [Vector3] at the end. </description> </method> <method name="remove"> - <return type="void"> - </return> - <argument index="0" name="index" type="int"> - </argument> + <return type="void" /> + <argument index="0" name="index" type="int" /> <description> Removes an element from the array by index. </description> </method> <method name="resize"> - <return type="int"> - </return> - <argument index="0" name="new_size" type="int"> - </argument> + <return type="int" /> + <argument index="0" name="new_size" type="int" /> <description> Sets the size of the array. If the array is grown, reserves elements at the end of the array. If the array is shrunk, truncates the array to the new size. </description> </method> <method name="reverse"> - <return type="void"> - </return> + <return type="void" /> <description> Reverses the order of the elements in the array. </description> </method> <method name="set"> - <return type="void"> - </return> - <argument index="0" name="index" type="int"> - </argument> - <argument index="1" name="value" type="Vector3"> - </argument> + <return type="void" /> + <argument index="0" name="index" type="int" /> + <argument index="1" name="value" type="Vector3" /> <description> Changes the [Vector3] at the given index. </description> </method> <method name="size" qualifiers="const"> - <return type="int"> - </return> + <return type="int" /> <description> Returns the size of the array. </description> </method> <method name="sort"> - <return type="void"> - </return> + <return type="void" /> <description> Sorts the elements of the array in ascending order. </description> </method> <method name="subarray" qualifiers="const"> - <return type="PackedVector3Array"> - </return> - <argument index="0" name="from" type="int"> - </argument> - <argument index="1" name="to" type="int"> - </argument> + <return type="PackedVector3Array" /> + <argument index="0" name="from" type="int" /> + <argument index="1" name="to" type="int" /> <description> </description> </method> <method name="to_byte_array" qualifiers="const"> - <return type="PackedByteArray"> - </return> + <return type="PackedByteArray" /> <description> </description> </method> diff --git a/doc/classes/PacketPeer.xml b/doc/classes/PacketPeer.xml index 0a758c2cd6..8d0aa89287 100644 --- a/doc/classes/PacketPeer.xml +++ b/doc/classes/PacketPeer.xml @@ -10,52 +10,42 @@ </tutorials> <methods> <method name="get_available_packet_count" qualifiers="const"> - <return type="int"> - </return> + <return type="int" /> <description> Returns the number of packets currently available in the ring-buffer. </description> </method> <method name="get_packet"> - <return type="PackedByteArray"> - </return> + <return type="PackedByteArray" /> <description> Gets a raw packet. </description> </method> <method name="get_packet_error" qualifiers="const"> - <return type="int" enum="Error"> - </return> + <return type="int" enum="Error" /> <description> Returns the error state of the last packet received (via [method get_packet] and [method get_var]). </description> </method> <method name="get_var"> - <return type="Variant"> - </return> - <argument index="0" name="allow_objects" type="bool" default="false"> - </argument> + <return type="Variant" /> + <argument index="0" name="allow_objects" type="bool" default="false" /> <description> Gets a Variant. If [code]allow_objects[/code] is [code]true[/code], decoding objects is allowed. [b]Warning:[/b] Deserialized objects can contain code which gets executed. Do not use this option if the serialized object comes from untrusted sources to avoid potential security threats such as remote code execution. </description> </method> <method name="put_packet"> - <return type="int" enum="Error"> - </return> - <argument index="0" name="buffer" type="PackedByteArray"> - </argument> + <return type="int" enum="Error" /> + <argument index="0" name="buffer" type="PackedByteArray" /> <description> Sends a raw packet. </description> </method> <method name="put_var"> - <return type="int" enum="Error"> - </return> - <argument index="0" name="var" type="Variant"> - </argument> - <argument index="1" name="full_objects" type="bool" default="false"> - </argument> + <return type="int" enum="Error" /> + <argument index="0" name="var" type="Variant" /> + <argument index="1" name="full_objects" type="bool" default="false" /> <description> Sends a [Variant] as a packet. If [code]full_objects[/code] is [code]true[/code], encoding objects is allowed (and can potentially include code). </description> diff --git a/doc/classes/PacketPeerDTLS.xml b/doc/classes/PacketPeerDTLS.xml index 19ebb9d81e..99a1aea5a6 100644 --- a/doc/classes/PacketPeerDTLS.xml +++ b/doc/classes/PacketPeerDTLS.xml @@ -10,37 +10,29 @@ </tutorials> <methods> <method name="connect_to_peer"> - <return type="int" enum="Error"> - </return> - <argument index="0" name="packet_peer" type="PacketPeerUDP"> - </argument> - <argument index="1" name="validate_certs" type="bool" default="true"> - </argument> - <argument index="2" name="for_hostname" type="String" default=""""> - </argument> - <argument index="3" name="valid_certificate" type="X509Certificate" default="null"> - </argument> + <return type="int" enum="Error" /> + <argument index="0" name="packet_peer" type="PacketPeerUDP" /> + <argument index="1" name="validate_certs" type="bool" default="true" /> + <argument index="2" name="for_hostname" type="String" default="""" /> + <argument index="3" name="valid_certificate" type="X509Certificate" default="null" /> <description> Connects a [code]peer[/code] beginning the DTLS handshake using the underlying [PacketPeerUDP] which must be connected (see [method PacketPeerUDP.connect_to_host]). If [code]validate_certs[/code] is [code]true[/code], [PacketPeerDTLS] will validate that the certificate presented by the remote peer and match it with the [code]for_hostname[/code] argument. You can specify a custom [X509Certificate] to use for validation via the [code]valid_certificate[/code] argument. </description> </method> <method name="disconnect_from_peer"> - <return type="void"> - </return> + <return type="void" /> <description> Disconnects this peer, terminating the DTLS session. </description> </method> <method name="get_status" qualifiers="const"> - <return type="int" enum="PacketPeerDTLS.Status"> - </return> + <return type="int" enum="PacketPeerDTLS.Status" /> <description> Returns the status of the connection. See [enum Status] for values. </description> </method> <method name="poll"> - <return type="void"> - </return> + <return type="void" /> <description> Poll the connection to check for incoming packets. Call this frequently to update the status and keep the connection working. </description> diff --git a/doc/classes/PacketPeerUDP.xml b/doc/classes/PacketPeerUDP.xml index 2707df612c..e2acb91058 100644 --- a/doc/classes/PacketPeerUDP.xml +++ b/doc/classes/PacketPeerUDP.xml @@ -10,14 +10,10 @@ </tutorials> <methods> <method name="bind"> - <return type="int" enum="Error"> - </return> - <argument index="0" name="port" type="int"> - </argument> - <argument index="1" name="bind_address" type="String" default=""*""> - </argument> - <argument index="2" name="recv_buf_size" type="int" default="65536"> - </argument> + <return type="int" enum="Error" /> + <argument index="0" name="port" type="int" /> + <argument index="1" name="bind_address" type="String" default=""*"" /> + <argument index="2" name="recv_buf_size" type="int" default="65536" /> <description> Binds this [PacketPeerUDP] to the specified [code]port[/code] and [code]address[/code] with a buffer size [code]recv_buf_size[/code], allowing it to receive incoming packets. If [code]address[/code] is set to [code]"*"[/code] (default), the peer will be bound on all available addresses (both IPv4 and IPv6). @@ -26,66 +22,54 @@ </description> </method> <method name="close"> - <return type="void"> - </return> + <return type="void" /> <description> Closes the [PacketPeerUDP]'s underlying UDP socket. </description> </method> <method name="connect_to_host"> - <return type="int" enum="Error"> - </return> - <argument index="0" name="host" type="String"> - </argument> - <argument index="1" name="port" type="int"> - </argument> + <return type="int" enum="Error" /> + <argument index="0" name="host" type="String" /> + <argument index="1" name="port" type="int" /> <description> Calling this method connects this UDP peer to the given [code]host[/code]/[code]port[/code] pair. UDP is in reality connectionless, so this option only means that incoming packets from different addresses are automatically discarded, and that outgoing packets are always sent to the connected address (future calls to [method set_dest_address] are not allowed). This method does not send any data to the remote peer, to do that, use [method PacketPeer.put_var] or [method PacketPeer.put_packet] as usual. See also [UDPServer]. [b]Note:[/b] Connecting to the remote peer does not help to protect from malicious attacks like IP spoofing, etc. Think about using an encryption technique like SSL or DTLS if you feel like your application is transferring sensitive information. </description> </method> <method name="get_local_port" qualifiers="const"> - <return type="int"> - </return> + <return type="int" /> <description> Returns the local port to which this peer is bound. </description> </method> <method name="get_packet_ip" qualifiers="const"> - <return type="String"> - </return> + <return type="String" /> <description> Returns the IP of the remote peer that sent the last packet(that was received with [method PacketPeer.get_packet] or [method PacketPeer.get_var]). </description> </method> <method name="get_packet_port" qualifiers="const"> - <return type="int"> - </return> + <return type="int" /> <description> Returns the port of the remote peer that sent the last packet(that was received with [method PacketPeer.get_packet] or [method PacketPeer.get_var]). </description> </method> <method name="is_bound" qualifiers="const"> - <return type="bool"> - </return> + <return type="bool" /> <description> Returns whether this [PacketPeerUDP] is bound to an address and can receive packets. </description> </method> <method name="is_connected_to_host" qualifiers="const"> - <return type="bool"> - </return> + <return type="bool" /> <description> Returns [code]true[/code] if the UDP socket is open and has been connected to a remote address. See [method connect_to_host]. </description> </method> <method name="join_multicast_group"> - <return type="int" enum="Error"> - </return> - <argument index="0" name="multicast_address" type="String"> - </argument> - <argument index="1" name="interface_name" type="String"> - </argument> + <return type="int" enum="Error" /> + <argument index="0" name="multicast_address" type="String" /> + <argument index="1" name="interface_name" type="String" /> <description> Joins the multicast group specified by [code]multicast_address[/code] using the interface identified by [code]interface_name[/code]. You can join the same multicast group with multiple interfaces. Use [method IP.get_local_interfaces] to know which are available. @@ -93,41 +77,32 @@ </description> </method> <method name="leave_multicast_group"> - <return type="int" enum="Error"> - </return> - <argument index="0" name="multicast_address" type="String"> - </argument> - <argument index="1" name="interface_name" type="String"> - </argument> + <return type="int" enum="Error" /> + <argument index="0" name="multicast_address" type="String" /> + <argument index="1" name="interface_name" type="String" /> <description> Removes the interface identified by [code]interface_name[/code] from the multicast group specified by [code]multicast_address[/code]. </description> </method> <method name="set_broadcast_enabled"> - <return type="void"> - </return> - <argument index="0" name="enabled" type="bool"> - </argument> + <return type="void" /> + <argument index="0" name="enabled" type="bool" /> <description> Enable or disable sending of broadcast packets (e.g. [code]set_dest_address("255.255.255.255", 4343)[/code]. This option is disabled by default. Note: Some Android devices might require the [code]CHANGE_WIFI_MULTICAST_STATE[/code] permission and this option to be enabled to receive broadcast packets too. </description> </method> <method name="set_dest_address"> - <return type="int" enum="Error"> - </return> - <argument index="0" name="host" type="String"> - </argument> - <argument index="1" name="port" type="int"> - </argument> + <return type="int" enum="Error" /> + <argument index="0" name="host" type="String" /> + <argument index="1" name="port" type="int" /> <description> Sets the destination address and port for sending packets and variables. A hostname will be resolved using DNS if needed. Note: [method set_broadcast_enabled] must be enabled before sending packets to a broadcast address (e.g. [code]255.255.255.255[/code]). </description> </method> <method name="wait"> - <return type="int" enum="Error"> - </return> + <return type="int" enum="Error" /> <description> Waits for a packet to arrive on the bound address. See [method bind]. [b]Note:[/b] [method wait] can't be interrupted once it has been called. This can be worked around by allowing the other party to send a specific "death pill" packet like this: diff --git a/doc/classes/ParticlesMaterial.xml b/doc/classes/ParticlesMaterial.xml index e8fde21032..3520d3b966 100644 --- a/doc/classes/ParticlesMaterial.xml +++ b/doc/classes/ParticlesMaterial.xml @@ -12,81 +12,61 @@ </tutorials> <methods> <method name="get_param" qualifiers="const"> - <return type="float"> - </return> - <argument index="0" name="param" type="int" enum="ParticlesMaterial.Parameter"> - </argument> + <return type="float" /> + <argument index="0" name="param" type="int" enum="ParticlesMaterial.Parameter" /> <description> Returns the value of the specified parameter. </description> </method> <method name="get_param_randomness" qualifiers="const"> - <return type="float"> - </return> - <argument index="0" name="param" type="int" enum="ParticlesMaterial.Parameter"> - </argument> + <return type="float" /> + <argument index="0" name="param" type="int" enum="ParticlesMaterial.Parameter" /> <description> Returns the randomness ratio associated with the specified parameter. </description> </method> <method name="get_param_texture" qualifiers="const"> - <return type="Texture2D"> - </return> - <argument index="0" name="param" type="int" enum="ParticlesMaterial.Parameter"> - </argument> + <return type="Texture2D" /> + <argument index="0" name="param" type="int" enum="ParticlesMaterial.Parameter" /> <description> Returns the [Texture2D] used by the specified parameter. </description> </method> <method name="get_particle_flag" qualifiers="const"> - <return type="bool"> - </return> - <argument index="0" name="particle_flag" type="int" enum="ParticlesMaterial.ParticleFlags"> - </argument> + <return type="bool" /> + <argument index="0" name="particle_flag" type="int" enum="ParticlesMaterial.ParticleFlags" /> <description> Returns [code]true[/code] if the specified particle flag is enabled. See [enum ParticleFlags] for options. </description> </method> <method name="set_param"> - <return type="void"> - </return> - <argument index="0" name="param" type="int" enum="ParticlesMaterial.Parameter"> - </argument> - <argument index="1" name="value" type="float"> - </argument> + <return type="void" /> + <argument index="0" name="param" type="int" enum="ParticlesMaterial.Parameter" /> + <argument index="1" name="value" type="float" /> <description> Sets the specified [enum Parameter]. </description> </method> <method name="set_param_randomness"> - <return type="void"> - </return> - <argument index="0" name="param" type="int" enum="ParticlesMaterial.Parameter"> - </argument> - <argument index="1" name="randomness" type="float"> - </argument> + <return type="void" /> + <argument index="0" name="param" type="int" enum="ParticlesMaterial.Parameter" /> + <argument index="1" name="randomness" type="float" /> <description> Sets the randomness ratio for the specified [enum Parameter]. </description> </method> <method name="set_param_texture"> - <return type="void"> - </return> - <argument index="0" name="param" type="int" enum="ParticlesMaterial.Parameter"> - </argument> - <argument index="1" name="texture" type="Texture2D"> - </argument> + <return type="void" /> + <argument index="0" name="param" type="int" enum="ParticlesMaterial.Parameter" /> + <argument index="1" name="texture" type="Texture2D" /> <description> Sets the [Texture2D] for the specified [enum Parameter]. </description> </method> <method name="set_particle_flag"> - <return type="void"> - </return> - <argument index="0" name="particle_flag" type="int" enum="ParticlesMaterial.ParticleFlags"> - </argument> - <argument index="1" name="enable" type="bool"> - </argument> + <return type="void" /> + <argument index="0" name="particle_flag" type="int" enum="ParticlesMaterial.ParticleFlags" /> + <argument index="1" name="enable" type="bool" /> <description> If [code]true[/code], enables the specified particle flag. See [enum ParticleFlags] for options. </description> @@ -145,7 +125,7 @@ Each particle's initial color. If the [GPUParticles2D]'s [code]texture[/code] is defined, it will be multiplied by this color. To have particle display color in a [BaseMaterial3D] make sure to set [member BaseMaterial3D.vertex_color_use_as_albedo] to [code]true[/code]. </member> <member name="color_ramp" type="Texture2D" setter="set_color_ramp" getter="get_color_ramp"> - Each particle's color will vary along this [GradientTexture]. + Each particle's color will vary along this [GradientTexture] over its lifetime (multiplied with [member color]). </member> <member name="damping" type="float" setter="set_param" getter="get_param" default="0.0"> The rate at which particles lose velocity. @@ -174,6 +154,18 @@ <member name="emission_point_texture" type="Texture2D" setter="set_emission_point_texture" getter="get_emission_point_texture"> Particles will be emitted at positions determined by sampling this texture at a random position. Used with [constant EMISSION_SHAPE_POINTS] and [constant EMISSION_SHAPE_DIRECTED_POINTS]. Can be created automatically from mesh or node by selecting "Create Emission Points from Mesh/Node" under the "Particles" tool in the toolbar. </member> + <member name="emission_ring_axis" type="Vector3" setter="set_emission_ring_axis" getter="get_emission_ring_axis"> + The axis of the ring when using the emitter [constant EMISSION_SHAPE_RING]. + </member> + <member name="emission_ring_height" type="float" setter="set_emission_ring_height" getter="get_emission_ring_height"> + The height of the ring when using the emitter [constant EMISSION_SHAPE_RING]. + </member> + <member name="emission_ring_inner_radius" type="float" setter="set_emission_ring_inner_radius" getter="get_emission_ring_inner_radius"> + The inner radius of the ring when using the emitter [constant EMISSION_SHAPE_RING]. + </member> + <member name="emission_ring_radius" type="float" setter="set_emission_ring_radius" getter="get_emission_ring_radius"> + The radius of the ring when using the emitter [constant EMISSION_SHAPE_RING]. + </member> <member name="emission_shape" type="int" setter="set_emission_shape" getter="get_emission_shape" enum="ParticlesMaterial.EmissionShape" default="0"> Particles will be emitted inside this region. Use [enum EmissionShape] constants for values. </member> @@ -338,7 +330,10 @@ <constant name="EMISSION_SHAPE_DIRECTED_POINTS" value="4" enum="EmissionShape"> Particles will be emitted at a position determined by sampling a random point on the [member emission_point_texture]. Particle velocity and rotation will be set based on [member emission_normal_texture]. Particle color will be modulated by [member emission_color_texture]. </constant> - <constant name="EMISSION_SHAPE_MAX" value="5" enum="EmissionShape"> + <constant name="EMISSION_SHAPE_RING" value="5" enum="EmissionShape"> + Particles will be emitted in a ring or cylinder. + </constant> + <constant name="EMISSION_SHAPE_MAX" value="6" enum="EmissionShape"> Represents the size of the [enum EmissionShape] enum. </constant> <constant name="SUB_EMITTER_DISABLED" value="0" enum="SubEmitterMode"> diff --git a/doc/classes/Performance.xml b/doc/classes/Performance.xml index a141961df5..335c3d254b 100644 --- a/doc/classes/Performance.xml +++ b/doc/classes/Performance.xml @@ -14,14 +14,10 @@ </tutorials> <methods> <method name="add_custom_monitor"> - <return type="void"> - </return> - <argument index="0" name="id" type="StringName"> - </argument> - <argument index="1" name="callable" type="Callable"> - </argument> - <argument index="2" name="arguments" type="Array" default="[]"> - </argument> + <return type="void" /> + <argument index="0" name="id" type="StringName" /> + <argument index="1" name="callable" type="Callable" /> + <argument index="2" name="arguments" type="Array" default="[]" /> <description> Adds a custom monitor with name same as id. You can specify the category of monitor using '/' in id. If there are more than one '/' then default category is used. Default category is "Custom". [codeblocks] @@ -77,27 +73,22 @@ </description> </method> <method name="get_custom_monitor"> - <return type="Variant"> - </return> - <argument index="0" name="id" type="StringName"> - </argument> + <return type="Variant" /> + <argument index="0" name="id" type="StringName" /> <description> Returns the value of custom monitor with given id. The callable is called to get the value of custom monitor. [b]Note:[/b] It throws an error if the given id is absent. </description> </method> <method name="get_custom_monitor_names"> - <return type="Array"> - </return> + <return type="Array" /> <description> Returns the names of active custom monitors in an array. </description> </method> <method name="get_monitor" qualifiers="const"> - <return type="float"> - </return> - <argument index="0" name="monitor" type="int" enum="Performance.Monitor"> - </argument> + <return type="float" /> + <argument index="0" name="monitor" type="int" enum="Performance.Monitor" /> <description> Returns the value of one of the available monitors. You should provide one of the [enum Monitor] constants as the argument, like this: [codeblocks] @@ -111,26 +102,21 @@ </description> </method> <method name="get_monitor_modification_time"> - <return type="int"> - </return> + <return type="int" /> <description> Returns the last tick in which custom monitor was added/removed. </description> </method> <method name="has_custom_monitor"> - <return type="bool"> - </return> - <argument index="0" name="id" type="StringName"> - </argument> + <return type="bool" /> + <argument index="0" name="id" type="StringName" /> <description> Returns true if custom monitor with the given id is present otherwise returns false. </description> </method> <method name="remove_custom_monitor"> - <return type="void"> - </return> - <argument index="0" name="id" type="StringName"> - </argument> + <return type="void" /> + <argument index="0" name="id" type="StringName" /> <description> Removes the custom monitor with given id. [b]Note:[/b] It throws an error if the given id is already absent. diff --git a/doc/classes/PhysicalBone2D.xml b/doc/classes/PhysicalBone2D.xml index cea75bad52..b4d92475a1 100644 --- a/doc/classes/PhysicalBone2D.xml +++ b/doc/classes/PhysicalBone2D.xml @@ -12,15 +12,13 @@ </tutorials> <methods> <method name="get_joint" qualifiers="const"> - <return type="Joint2D"> - </return> + <return type="Joint2D" /> <description> Returns the first [Joint2D] child node, if one exists. This is mainly a helper function to make it easier to get the [Joint2D] that the [code]PhysicalBone2D[/code] is autoconfiguring. </description> </method> <method name="is_simulating_physics" qualifiers="const"> - <return type="bool"> - </return> + <return type="bool" /> <description> Returns a boolean that indicates whether the [code]PhysicalBone2D[/code] node is running and simulating using the Godot 2D physics engine. When [code]true[/code], the PhysicalBone2D node is using physics. </description> diff --git a/doc/classes/PhysicalBone3D.xml b/doc/classes/PhysicalBone3D.xml index 2ed862e9ce..710e96239b 100644 --- a/doc/classes/PhysicalBone3D.xml +++ b/doc/classes/PhysicalBone3D.xml @@ -8,38 +8,30 @@ </tutorials> <methods> <method name="apply_central_impulse"> - <return type="void"> - </return> - <argument index="0" name="impulse" type="Vector3"> - </argument> + <return type="void" /> + <argument index="0" name="impulse" type="Vector3" /> <description> </description> </method> <method name="apply_impulse"> - <return type="void"> - </return> - <argument index="0" name="impulse" type="Vector3"> - </argument> - <argument index="1" name="position" type="Vector3" default="Vector3(0, 0, 0)"> - </argument> + <return type="void" /> + <argument index="0" name="impulse" type="Vector3" /> + <argument index="1" name="position" type="Vector3" default="Vector3(0, 0, 0)" /> <description> </description> </method> <method name="get_bone_id" qualifiers="const"> - <return type="int"> - </return> + <return type="int" /> <description> </description> </method> <method name="get_simulate_physics"> - <return type="bool"> - </return> + <return type="bool" /> <description> </description> </method> <method name="is_simulating_physics"> - <return type="bool"> - </return> + <return type="bool" /> <description> </description> </method> diff --git a/doc/classes/PhysicsBody2D.xml b/doc/classes/PhysicsBody2D.xml index 654b0fb668..4d1cd072d0 100644 --- a/doc/classes/PhysicsBody2D.xml +++ b/doc/classes/PhysicsBody2D.xml @@ -11,34 +11,25 @@ </tutorials> <methods> <method name="add_collision_exception_with"> - <return type="void"> - </return> - <argument index="0" name="body" type="Node"> - </argument> + <return type="void" /> + <argument index="0" name="body" type="Node" /> <description> Adds a body to the list of bodies that this body can't collide with. </description> </method> <method name="get_collision_exceptions"> - <return type="PhysicsBody2D[]"> - </return> + <return type="PhysicsBody2D[]" /> <description> Returns an array of nodes that were added as collision exceptions for this body. </description> </method> <method name="move_and_collide"> - <return type="KinematicCollision2D"> - </return> - <argument index="0" name="rel_vec" type="Vector2"> - </argument> - <argument index="1" name="infinite_inertia" type="bool" default="true"> - </argument> - <argument index="2" name="exclude_raycast_shapes" type="bool" default="true"> - </argument> - <argument index="3" name="test_only" type="bool" default="false"> - </argument> - <argument index="4" name="safe_margin" type="float" default="0.08"> - </argument> + <return type="KinematicCollision2D" /> + <argument index="0" name="rel_vec" type="Vector2" /> + <argument index="1" name="infinite_inertia" type="bool" default="true" /> + <argument index="2" name="exclude_raycast_shapes" type="bool" default="true" /> + <argument index="3" name="test_only" type="bool" default="false" /> + <argument index="4" name="safe_margin" type="float" default="0.08" /> <description> Moves the body along the vector [code]rel_vec[/code]. The body will stop if it collides. Returns a [KinematicCollision2D], which contains information about the collision. If [code]test_only[/code] is [code]true[/code], the body does not move but the would-be collision information is given. @@ -46,29 +37,20 @@ </description> </method> <method name="remove_collision_exception_with"> - <return type="void"> - </return> - <argument index="0" name="body" type="Node"> - </argument> + <return type="void" /> + <argument index="0" name="body" type="Node" /> <description> Removes a body from the list of bodies that this body can't collide with. </description> </method> <method name="test_move"> - <return type="bool"> - </return> - <argument index="0" name="from" type="Transform2D"> - </argument> - <argument index="1" name="rel_vec" type="Vector2"> - </argument> - <argument index="2" name="infinite_inertia" type="bool" default="true"> - </argument> - <argument index="3" name="exclude_raycast_shapes" type="bool" default="true"> - </argument> - <argument index="4" name="collision" type="KinematicCollision2D" default="null"> - </argument> - <argument index="5" name="safe_margin" type="float" default="0.08"> - </argument> + <return type="bool" /> + <argument index="0" name="from" type="Transform2D" /> + <argument index="1" name="rel_vec" type="Vector2" /> + <argument index="2" name="infinite_inertia" type="bool" default="true" /> + <argument index="3" name="exclude_raycast_shapes" type="bool" default="true" /> + <argument index="4" name="collision" type="KinematicCollision2D" default="null" /> + <argument index="5" name="safe_margin" type="float" default="0.08" /> <description> Checks for collisions without moving the body. Virtually sets the node's position, scale and rotation to that of the given [Transform2D], then tries to move the body along the vector [code]rel_vec[/code]. Returns [code]true[/code] if a collision would occur. [code]collision[/code] is an optional object of type [KinematicCollision2D], which contains additional information about the collision (should there be one). diff --git a/doc/classes/PhysicsBody3D.xml b/doc/classes/PhysicsBody3D.xml index 1ec38000be..a2a68115d0 100644 --- a/doc/classes/PhysicsBody3D.xml +++ b/doc/classes/PhysicsBody3D.xml @@ -11,43 +11,32 @@ </tutorials> <methods> <method name="add_collision_exception_with"> - <return type="void"> - </return> - <argument index="0" name="body" type="Node"> - </argument> + <return type="void" /> + <argument index="0" name="body" type="Node" /> <description> Adds a body to the list of bodies that this body can't collide with. </description> </method> <method name="get_axis_lock" qualifiers="const"> - <return type="bool"> - </return> - <argument index="0" name="axis" type="int" enum="PhysicsServer3D.BodyAxis"> - </argument> + <return type="bool" /> + <argument index="0" name="axis" type="int" enum="PhysicsServer3D.BodyAxis" /> <description> Returns [code]true[/code] if the specified linear or rotational [code]axis[/code] is locked. </description> </method> <method name="get_collision_exceptions"> - <return type="PhysicsBody3D[]"> - </return> + <return type="PhysicsBody3D[]" /> <description> Returns an array of nodes that were added as collision exceptions for this body. </description> </method> <method name="move_and_collide"> - <return type="KinematicCollision3D"> - </return> - <argument index="0" name="rel_vec" type="Vector3"> - </argument> - <argument index="1" name="infinite_inertia" type="bool" default="true"> - </argument> - <argument index="2" name="exclude_raycast_shapes" type="bool" default="true"> - </argument> - <argument index="3" name="test_only" type="bool" default="false"> - </argument> - <argument index="4" name="safe_margin" type="float" default="0.001"> - </argument> + <return type="KinematicCollision3D" /> + <argument index="0" name="rel_vec" type="Vector3" /> + <argument index="1" name="infinite_inertia" type="bool" default="true" /> + <argument index="2" name="exclude_raycast_shapes" type="bool" default="true" /> + <argument index="3" name="test_only" type="bool" default="false" /> + <argument index="4" name="safe_margin" type="float" default="0.001" /> <description> Moves the body along the vector [code]rel_vec[/code]. The body will stop if it collides. Returns a [KinematicCollision3D], which contains information about the collision. If [code]test_only[/code] is [code]true[/code], the body does not move but the would-be collision information is given. @@ -55,40 +44,28 @@ </description> </method> <method name="remove_collision_exception_with"> - <return type="void"> - </return> - <argument index="0" name="body" type="Node"> - </argument> + <return type="void" /> + <argument index="0" name="body" type="Node" /> <description> Removes a body from the list of bodies that this body can't collide with. </description> </method> <method name="set_axis_lock"> - <return type="void"> - </return> - <argument index="0" name="axis" type="int" enum="PhysicsServer3D.BodyAxis"> - </argument> - <argument index="1" name="lock" type="bool"> - </argument> + <return type="void" /> + <argument index="0" name="axis" type="int" enum="PhysicsServer3D.BodyAxis" /> + <argument index="1" name="lock" type="bool" /> <description> Locks or unlocks the specified linear or rotational [code]axis[/code] depending on the value of [code]lock[/code]. </description> </method> <method name="test_move"> - <return type="bool"> - </return> - <argument index="0" name="from" type="Transform3D"> - </argument> - <argument index="1" name="rel_vec" type="Vector3"> - </argument> - <argument index="2" name="infinite_inertia" type="bool" default="true"> - </argument> - <argument index="3" name="exclude_raycast_shapes" type="bool" default="true"> - </argument> - <argument index="4" name="collision" type="KinematicCollision3D" default="null"> - </argument> - <argument index="5" name="safe_margin" type="float" default="0.001"> - </argument> + <return type="bool" /> + <argument index="0" name="from" type="Transform3D" /> + <argument index="1" name="rel_vec" type="Vector3" /> + <argument index="2" name="infinite_inertia" type="bool" default="true" /> + <argument index="3" name="exclude_raycast_shapes" type="bool" default="true" /> + <argument index="4" name="collision" type="KinematicCollision3D" default="null" /> + <argument index="5" name="safe_margin" type="float" default="0.001" /> <description> Checks for collisions without moving the body. Virtually sets the node's position, scale and rotation to that of the given [Transform3D], then tries to move the body along the vector [code]rel_vec[/code]. Returns [code]true[/code] if a collision would occur. [code]collision[/code] is an optional object of type [KinematicCollision3D], which contains additional information about the collision (should there be one). diff --git a/doc/classes/PhysicsDirectBodyState2D.xml b/doc/classes/PhysicsDirectBodyState2D.xml index 65cb3e7f38..ab3a04698f 100644 --- a/doc/classes/PhysicsDirectBodyState2D.xml +++ b/doc/classes/PhysicsDirectBodyState2D.xml @@ -11,171 +11,134 @@ </tutorials> <methods> <method name="add_central_force"> - <return type="void"> - </return> - <argument index="0" name="force" type="Vector2"> - </argument> + <return type="void" /> + <argument index="0" name="force" type="Vector2" /> <description> Adds a constant directional force without affecting rotation. </description> </method> <method name="add_force"> - <return type="void"> - </return> - <argument index="0" name="force" type="Vector2"> - </argument> - <argument index="1" name="position" type="Vector2" default="Vector2(0, 0)"> - </argument> + <return type="void" /> + <argument index="0" name="force" type="Vector2" /> + <argument index="1" name="position" type="Vector2" default="Vector2(0, 0)" /> <description> Adds a positioned force to the body. Both the force and the offset from the body origin are in global coordinates. </description> </method> <method name="add_torque"> - <return type="void"> - </return> - <argument index="0" name="torque" type="float"> - </argument> + <return type="void" /> + <argument index="0" name="torque" type="float" /> <description> Adds a constant rotational force. </description> </method> <method name="apply_central_impulse"> - <return type="void"> - </return> - <argument index="0" name="impulse" type="Vector2"> - </argument> + <return type="void" /> + <argument index="0" name="impulse" type="Vector2" /> <description> Applies a directional impulse without affecting rotation. </description> </method> <method name="apply_impulse"> - <return type="void"> - </return> - <argument index="0" name="impulse" type="Vector2"> - </argument> - <argument index="1" name="position" type="Vector2" default="Vector2(0, 0)"> - </argument> + <return type="void" /> + <argument index="0" name="impulse" type="Vector2" /> + <argument index="1" name="position" type="Vector2" default="Vector2(0, 0)" /> <description> Applies a positioned impulse to the body. An impulse is time-independent! Applying an impulse every frame would result in a framerate-dependent force. For this reason, it should only be used when simulating one-time impacts (use the "_force" functions otherwise). The offset uses the rotation of the global coordinate system, but is centered at the object's origin. </description> </method> <method name="apply_torque_impulse"> - <return type="void"> - </return> - <argument index="0" name="impulse" type="float"> - </argument> + <return type="void" /> + <argument index="0" name="impulse" type="float" /> <description> Applies a rotational impulse to the body. </description> </method> <method name="get_contact_collider" qualifiers="const"> - <return type="RID"> - </return> - <argument index="0" name="contact_idx" type="int"> - </argument> + <return type="RID" /> + <argument index="0" name="contact_idx" type="int" /> <description> Returns the collider's [RID]. </description> </method> <method name="get_contact_collider_id" qualifiers="const"> - <return type="int"> - </return> - <argument index="0" name="contact_idx" type="int"> - </argument> + <return type="int" /> + <argument index="0" name="contact_idx" type="int" /> <description> Returns the collider's object id. </description> </method> <method name="get_contact_collider_object" qualifiers="const"> - <return type="Object"> - </return> - <argument index="0" name="contact_idx" type="int"> - </argument> + <return type="Object" /> + <argument index="0" name="contact_idx" type="int" /> <description> Returns the collider object. This depends on how it was created (will return a scene node if such was used to create it). </description> </method> <method name="get_contact_collider_position" qualifiers="const"> - <return type="Vector2"> - </return> - <argument index="0" name="contact_idx" type="int"> - </argument> + <return type="Vector2" /> + <argument index="0" name="contact_idx" type="int" /> <description> Returns the contact position in the collider. </description> </method> <method name="get_contact_collider_shape" qualifiers="const"> - <return type="int"> - </return> - <argument index="0" name="contact_idx" type="int"> - </argument> + <return type="int" /> + <argument index="0" name="contact_idx" type="int" /> <description> Returns the collider's shape index. </description> </method> <method name="get_contact_collider_shape_metadata" qualifiers="const"> - <return type="Variant"> - </return> - <argument index="0" name="contact_idx" type="int"> - </argument> + <return type="Variant" /> + <argument index="0" name="contact_idx" type="int" /> <description> Returns the collided shape's metadata. This metadata is different from [method Object.get_meta], and is set with [method PhysicsServer2D.shape_set_data]. </description> </method> <method name="get_contact_collider_velocity_at_position" qualifiers="const"> - <return type="Vector2"> - </return> - <argument index="0" name="contact_idx" type="int"> - </argument> + <return type="Vector2" /> + <argument index="0" name="contact_idx" type="int" /> <description> Returns the linear velocity vector at the collider's contact point. </description> </method> <method name="get_contact_count" qualifiers="const"> - <return type="int"> - </return> + <return type="int" /> <description> Returns the number of contacts this body has with other bodies. [b]Note:[/b] By default, this returns 0 unless bodies are configured to monitor contacts. See [member RigidBody2D.contact_monitor]. </description> </method> <method name="get_contact_local_normal" qualifiers="const"> - <return type="Vector2"> - </return> - <argument index="0" name="contact_idx" type="int"> - </argument> + <return type="Vector2" /> + <argument index="0" name="contact_idx" type="int" /> <description> Returns the local normal at the contact point. </description> </method> <method name="get_contact_local_position" qualifiers="const"> - <return type="Vector2"> - </return> - <argument index="0" name="contact_idx" type="int"> - </argument> + <return type="Vector2" /> + <argument index="0" name="contact_idx" type="int" /> <description> Returns the local position of the contact point. </description> </method> <method name="get_contact_local_shape" qualifiers="const"> - <return type="int"> - </return> - <argument index="0" name="contact_idx" type="int"> - </argument> + <return type="int" /> + <argument index="0" name="contact_idx" type="int" /> <description> Returns the local shape index of the collision. </description> </method> <method name="get_space_state"> - <return type="PhysicsDirectSpaceState2D"> - </return> + <return type="PhysicsDirectSpaceState2D" /> <description> Returns the current state of the space, useful for queries. </description> </method> <method name="integrate_forces"> - <return type="void"> - </return> + <return type="void" /> <description> Calls the built-in force integration code. </description> diff --git a/doc/classes/PhysicsDirectBodyState3D.xml b/doc/classes/PhysicsDirectBodyState3D.xml index 85feeef86e..6af62c2bcc 100644 --- a/doc/classes/PhysicsDirectBodyState3D.xml +++ b/doc/classes/PhysicsDirectBodyState3D.xml @@ -10,173 +10,136 @@ </tutorials> <methods> <method name="add_central_force"> - <return type="void"> - </return> - <argument index="0" name="force" type="Vector3" default="Vector3(0, 0, 0)"> - </argument> + <return type="void" /> + <argument index="0" name="force" type="Vector3" default="Vector3(0, 0, 0)" /> <description> Adds a constant directional force without affecting rotation. This is equivalent to [code]add_force(force, Vector3(0,0,0))[/code]. </description> </method> <method name="add_force"> - <return type="void"> - </return> - <argument index="0" name="force" type="Vector3"> - </argument> - <argument index="1" name="position" type="Vector3" default="Vector3(0, 0, 0)"> - </argument> + <return type="void" /> + <argument index="0" name="force" type="Vector3" /> + <argument index="1" name="position" type="Vector3" default="Vector3(0, 0, 0)" /> <description> Adds a positioned force to the body. Both the force and the offset from the body origin are in global coordinates. </description> </method> <method name="add_torque"> - <return type="void"> - </return> - <argument index="0" name="torque" type="Vector3"> - </argument> + <return type="void" /> + <argument index="0" name="torque" type="Vector3" /> <description> Adds a constant rotational force without affecting position. </description> </method> <method name="apply_central_impulse"> - <return type="void"> - </return> - <argument index="0" name="impulse" type="Vector3" default="Vector3(0, 0, 0)"> - </argument> + <return type="void" /> + <argument index="0" name="impulse" type="Vector3" default="Vector3(0, 0, 0)" /> <description> Applies a single directional impulse without affecting rotation. This is equivalent to [code]apply_impulse(Vector3(0, 0, 0), impulse)[/code]. </description> </method> <method name="apply_impulse"> - <return type="void"> - </return> - <argument index="0" name="impulse" type="Vector3"> - </argument> - <argument index="1" name="position" type="Vector3" default="Vector3(0, 0, 0)"> - </argument> + <return type="void" /> + <argument index="0" name="impulse" type="Vector3" /> + <argument index="1" name="position" type="Vector3" default="Vector3(0, 0, 0)" /> <description> Applies a positioned impulse to the body. An impulse is time-independent! Applying an impulse every frame would result in a framerate-dependent force. For this reason it should only be used when simulating one-time impacts. The position uses the rotation of the global coordinate system, but is centered at the object's origin. </description> </method> <method name="apply_torque_impulse"> - <return type="void"> - </return> - <argument index="0" name="impulse" type="Vector3"> - </argument> + <return type="void" /> + <argument index="0" name="impulse" type="Vector3" /> <description> Apply a torque impulse (which will be affected by the body mass and shape). This will rotate the body around the vector [code]j[/code] passed as parameter. </description> </method> <method name="get_contact_collider" qualifiers="const"> - <return type="RID"> - </return> - <argument index="0" name="contact_idx" type="int"> - </argument> + <return type="RID" /> + <argument index="0" name="contact_idx" type="int" /> <description> Returns the collider's [RID]. </description> </method> <method name="get_contact_collider_id" qualifiers="const"> - <return type="int"> - </return> - <argument index="0" name="contact_idx" type="int"> - </argument> + <return type="int" /> + <argument index="0" name="contact_idx" type="int" /> <description> Returns the collider's object id. </description> </method> <method name="get_contact_collider_object" qualifiers="const"> - <return type="Object"> - </return> - <argument index="0" name="contact_idx" type="int"> - </argument> + <return type="Object" /> + <argument index="0" name="contact_idx" type="int" /> <description> Returns the collider object. </description> </method> <method name="get_contact_collider_position" qualifiers="const"> - <return type="Vector3"> - </return> - <argument index="0" name="contact_idx" type="int"> - </argument> + <return type="Vector3" /> + <argument index="0" name="contact_idx" type="int" /> <description> Returns the contact position in the collider. </description> </method> <method name="get_contact_collider_shape" qualifiers="const"> - <return type="int"> - </return> - <argument index="0" name="contact_idx" type="int"> - </argument> + <return type="int" /> + <argument index="0" name="contact_idx" type="int" /> <description> Returns the collider's shape index. </description> </method> <method name="get_contact_collider_velocity_at_position" qualifiers="const"> - <return type="Vector3"> - </return> - <argument index="0" name="contact_idx" type="int"> - </argument> + <return type="Vector3" /> + <argument index="0" name="contact_idx" type="int" /> <description> Returns the linear velocity vector at the collider's contact point. </description> </method> <method name="get_contact_count" qualifiers="const"> - <return type="int"> - </return> + <return type="int" /> <description> Returns the number of contacts this body has with other bodies. [b]Note:[/b] By default, this returns 0 unless bodies are configured to monitor contacts. See [member RigidBody3D.contact_monitor]. </description> </method> <method name="get_contact_impulse" qualifiers="const"> - <return type="float"> - </return> - <argument index="0" name="contact_idx" type="int"> - </argument> + <return type="float" /> + <argument index="0" name="contact_idx" type="int" /> <description> Impulse created by the contact. Only implemented for Bullet physics. </description> </method> <method name="get_contact_local_normal" qualifiers="const"> - <return type="Vector3"> - </return> - <argument index="0" name="contact_idx" type="int"> - </argument> + <return type="Vector3" /> + <argument index="0" name="contact_idx" type="int" /> <description> Returns the local normal at the contact point. </description> </method> <method name="get_contact_local_position" qualifiers="const"> - <return type="Vector3"> - </return> - <argument index="0" name="contact_idx" type="int"> - </argument> + <return type="Vector3" /> + <argument index="0" name="contact_idx" type="int" /> <description> Returns the local position of the contact point. </description> </method> <method name="get_contact_local_shape" qualifiers="const"> - <return type="int"> - </return> - <argument index="0" name="contact_idx" type="int"> - </argument> + <return type="int" /> + <argument index="0" name="contact_idx" type="int" /> <description> Returns the local shape index of the collision. </description> </method> <method name="get_space_state"> - <return type="PhysicsDirectSpaceState3D"> - </return> + <return type="PhysicsDirectSpaceState3D" /> <description> Returns the current state of the space, useful for queries. </description> </method> <method name="integrate_forces"> - <return type="void"> - </return> + <return type="void" /> <description> Calls the built-in force integration code. </description> diff --git a/doc/classes/PhysicsDirectSpaceState2D.xml b/doc/classes/PhysicsDirectSpaceState2D.xml index 6c8c957e5d..2a32bc1cb9 100644 --- a/doc/classes/PhysicsDirectSpaceState2D.xml +++ b/doc/classes/PhysicsDirectSpaceState2D.xml @@ -11,10 +11,8 @@ </tutorials> <methods> <method name="cast_motion"> - <return type="Array"> - </return> - <argument index="0" name="shape" type="PhysicsShapeQueryParameters2D"> - </argument> + <return type="Array" /> + <argument index="0" name="shape" type="PhysicsShapeQueryParameters2D" /> <description> Checks how far a [Shape2D] can move without colliding. All the parameters for the query, including the shape and the motion, are supplied through a [PhysicsShapeQueryParameters2D] object. Returns an array with the safe and unsafe proportions (between 0 and 1) of the motion. The safe proportion is the maximum fraction of the motion that can be made without a collision. The unsafe proportion is the minimum fraction of the distance that must be moved for a collision. If no collision is detected a result of [code][1.0, 1.0][/code] will be returned. @@ -22,21 +20,16 @@ </description> </method> <method name="collide_shape"> - <return type="Array"> - </return> - <argument index="0" name="shape" type="PhysicsShapeQueryParameters2D"> - </argument> - <argument index="1" name="max_results" type="int" default="32"> - </argument> + <return type="Array" /> + <argument index="0" name="shape" type="PhysicsShapeQueryParameters2D" /> + <argument index="1" name="max_results" type="int" default="32" /> <description> Checks the intersections of a shape, given through a [PhysicsShapeQueryParameters2D] object, against the space. The resulting array contains a list of points where the shape intersects another. Like with [method intersect_shape], the number of returned results can be limited to save processing time. </description> </method> <method name="get_rest_info"> - <return type="Dictionary"> - </return> - <argument index="0" name="shape" type="PhysicsShapeQueryParameters2D"> - </argument> + <return type="Dictionary" /> + <argument index="0" name="shape" type="PhysicsShapeQueryParameters2D" /> <description> Checks the intersections of a shape, given through a [PhysicsShapeQueryParameters2D] object, against the space. If it collides with more than one shape, the nearest one is selected. If the shape did not intersect anything, then an empty dictionary is returned instead. [b]Note:[/b] This method does not take into account the [code]motion[/code] property of the object. The returned object is a dictionary containing the following fields: @@ -50,20 +43,13 @@ </description> </method> <method name="intersect_point"> - <return type="Array"> - </return> - <argument index="0" name="point" type="Vector2"> - </argument> - <argument index="1" name="max_results" type="int" default="32"> - </argument> - <argument index="2" name="exclude" type="Array" default="[]"> - </argument> - <argument index="3" name="collision_layer" type="int" default="2147483647"> - </argument> - <argument index="4" name="collide_with_bodies" type="bool" default="true"> - </argument> - <argument index="5" name="collide_with_areas" type="bool" default="false"> - </argument> + <return type="Array" /> + <argument index="0" name="point" type="Vector2" /> + <argument index="1" name="max_results" type="int" default="32" /> + <argument index="2" name="exclude" type="Array" default="[]" /> + <argument index="3" name="collision_layer" type="int" default="2147483647" /> + <argument index="4" name="collide_with_bodies" type="bool" default="true" /> + <argument index="5" name="collide_with_areas" type="bool" default="false" /> <description> Checks whether a point is inside any solid shape. The shapes the point is inside of are returned in an array containing dictionaries with the following fields: [code]collider[/code]: The colliding object. @@ -76,40 +62,25 @@ </description> </method> <method name="intersect_point_on_canvas"> - <return type="Array"> - </return> - <argument index="0" name="point" type="Vector2"> - </argument> - <argument index="1" name="canvas_instance_id" type="int"> - </argument> - <argument index="2" name="max_results" type="int" default="32"> - </argument> - <argument index="3" name="exclude" type="Array" default="[]"> - </argument> - <argument index="4" name="collision_layer" type="int" default="2147483647"> - </argument> - <argument index="5" name="collide_with_bodies" type="bool" default="true"> - </argument> - <argument index="6" name="collide_with_areas" type="bool" default="false"> - </argument> + <return type="Array" /> + <argument index="0" name="point" type="Vector2" /> + <argument index="1" name="canvas_instance_id" type="int" /> + <argument index="2" name="max_results" type="int" default="32" /> + <argument index="3" name="exclude" type="Array" default="[]" /> + <argument index="4" name="collision_layer" type="int" default="2147483647" /> + <argument index="5" name="collide_with_bodies" type="bool" default="true" /> + <argument index="6" name="collide_with_areas" type="bool" default="false" /> <description> </description> </method> <method name="intersect_ray"> - <return type="Dictionary"> - </return> - <argument index="0" name="from" type="Vector2"> - </argument> - <argument index="1" name="to" type="Vector2"> - </argument> - <argument index="2" name="exclude" type="Array" default="[]"> - </argument> - <argument index="3" name="collision_layer" type="int" default="2147483647"> - </argument> - <argument index="4" name="collide_with_bodies" type="bool" default="true"> - </argument> - <argument index="5" name="collide_with_areas" type="bool" default="false"> - </argument> + <return type="Dictionary" /> + <argument index="0" name="from" type="Vector2" /> + <argument index="1" name="to" type="Vector2" /> + <argument index="2" name="exclude" type="Array" default="[]" /> + <argument index="3" name="collision_layer" type="int" default="2147483647" /> + <argument index="4" name="collide_with_bodies" type="bool" default="true" /> + <argument index="5" name="collide_with_areas" type="bool" default="false" /> <description> Intersects a ray in a given space. The returned object is a dictionary with the following fields: [code]collider[/code]: The colliding object. @@ -124,12 +95,9 @@ </description> </method> <method name="intersect_shape"> - <return type="Array"> - </return> - <argument index="0" name="shape" type="PhysicsShapeQueryParameters2D"> - </argument> - <argument index="1" name="max_results" type="int" default="32"> - </argument> + <return type="Array" /> + <argument index="0" name="shape" type="PhysicsShapeQueryParameters2D" /> + <argument index="1" name="max_results" type="int" default="32" /> <description> Checks the intersections of a shape, given through a [PhysicsShapeQueryParameters2D] object, against the space. [b]Note:[/b] This method does not take into account the [code]motion[/code] property of the object. The intersected shapes are returned in an array containing dictionaries with the following fields: diff --git a/doc/classes/PhysicsDirectSpaceState3D.xml b/doc/classes/PhysicsDirectSpaceState3D.xml index a69b6f07fd..a6bfc8754d 100644 --- a/doc/classes/PhysicsDirectSpaceState3D.xml +++ b/doc/classes/PhysicsDirectSpaceState3D.xml @@ -11,12 +11,9 @@ </tutorials> <methods> <method name="cast_motion"> - <return type="Array"> - </return> - <argument index="0" name="shape" type="PhysicsShapeQueryParameters3D"> - </argument> - <argument index="1" name="motion" type="Vector3"> - </argument> + <return type="Array" /> + <argument index="0" name="shape" type="PhysicsShapeQueryParameters3D" /> + <argument index="1" name="motion" type="Vector3" /> <description> Checks how far a [Shape3D] can move without colliding. All the parameters for the query, including the shape, are supplied through a [PhysicsShapeQueryParameters3D] object. Returns an array with the safe and unsafe proportions (between 0 and 1) of the motion. The safe proportion is the maximum fraction of the motion that can be made without a collision. The unsafe proportion is the minimum fraction of the distance that must be moved for a collision. If no collision is detected a result of [code][1.0, 1.0][/code] will be returned. @@ -24,21 +21,16 @@ </description> </method> <method name="collide_shape"> - <return type="Array"> - </return> - <argument index="0" name="shape" type="PhysicsShapeQueryParameters3D"> - </argument> - <argument index="1" name="max_results" type="int" default="32"> - </argument> + <return type="Array" /> + <argument index="0" name="shape" type="PhysicsShapeQueryParameters3D" /> + <argument index="1" name="max_results" type="int" default="32" /> <description> Checks the intersections of a shape, given through a [PhysicsShapeQueryParameters3D] object, against the space. The resulting array contains a list of points where the shape intersects another. Like with [method intersect_shape], the number of returned results can be limited to save processing time. </description> </method> <method name="get_rest_info"> - <return type="Dictionary"> - </return> - <argument index="0" name="shape" type="PhysicsShapeQueryParameters3D"> - </argument> + <return type="Dictionary" /> + <argument index="0" name="shape" type="PhysicsShapeQueryParameters3D" /> <description> Checks the intersections of a shape, given through a [PhysicsShapeQueryParameters3D] object, against the space. If it collides with more than one shape, the nearest one is selected. The returned object is a dictionary containing the following fields: [code]collider_id[/code]: The colliding object's ID. @@ -51,20 +43,13 @@ </description> </method> <method name="intersect_ray"> - <return type="Dictionary"> - </return> - <argument index="0" name="from" type="Vector3"> - </argument> - <argument index="1" name="to" type="Vector3"> - </argument> - <argument index="2" name="exclude" type="Array" default="[]"> - </argument> - <argument index="3" name="collision_mask" type="int" default="2147483647"> - </argument> - <argument index="4" name="collide_with_bodies" type="bool" default="true"> - </argument> - <argument index="5" name="collide_with_areas" type="bool" default="false"> - </argument> + <return type="Dictionary" /> + <argument index="0" name="from" type="Vector3" /> + <argument index="1" name="to" type="Vector3" /> + <argument index="2" name="exclude" type="Array" default="[]" /> + <argument index="3" name="collision_mask" type="int" default="2147483647" /> + <argument index="4" name="collide_with_bodies" type="bool" default="true" /> + <argument index="5" name="collide_with_areas" type="bool" default="false" /> <description> Intersects a ray in a given space. The returned object is a dictionary with the following fields: [code]collider[/code]: The colliding object. @@ -78,12 +63,9 @@ </description> </method> <method name="intersect_shape"> - <return type="Array"> - </return> - <argument index="0" name="shape" type="PhysicsShapeQueryParameters3D"> - </argument> - <argument index="1" name="max_results" type="int" default="32"> - </argument> + <return type="Array" /> + <argument index="0" name="shape" type="PhysicsShapeQueryParameters3D" /> + <argument index="1" name="max_results" type="int" default="32" /> <description> Checks the intersections of a shape, given through a [PhysicsShapeQueryParameters3D] object, against the space. The intersected shapes are returned in an array containing dictionaries with the following fields: [code]collider[/code]: The colliding object. diff --git a/doc/classes/PhysicsServer2D.xml b/doc/classes/PhysicsServer2D.xml index 33cd61eb9c..cf23fecd08 100644 --- a/doc/classes/PhysicsServer2D.xml +++ b/doc/classes/PhysicsServer2D.xml @@ -10,197 +10,145 @@ </tutorials> <methods> <method name="area_add_shape"> - <return type="void"> - </return> - <argument index="0" name="area" type="RID"> - </argument> - <argument index="1" name="shape" type="RID"> - </argument> - <argument index="2" name="transform" type="Transform2D" default="Transform2D(1, 0, 0, 1, 0, 0)"> - </argument> - <argument index="3" name="disabled" type="bool" default="false"> - </argument> + <return type="void" /> + <argument index="0" name="area" type="RID" /> + <argument index="1" name="shape" type="RID" /> + <argument index="2" name="transform" type="Transform2D" default="Transform2D(1, 0, 0, 1, 0, 0)" /> + <argument index="3" name="disabled" type="bool" default="false" /> <description> Adds a shape to the area, along with a transform matrix. Shapes are usually referenced by their index, so you should track which shape has a given index. </description> </method> <method name="area_attach_canvas_instance_id"> - <return type="void"> - </return> - <argument index="0" name="area" type="RID"> - </argument> - <argument index="1" name="id" type="int"> - </argument> + <return type="void" /> + <argument index="0" name="area" type="RID" /> + <argument index="1" name="id" type="int" /> <description> </description> </method> <method name="area_attach_object_instance_id"> - <return type="void"> - </return> - <argument index="0" name="area" type="RID"> - </argument> - <argument index="1" name="id" type="int"> - </argument> + <return type="void" /> + <argument index="0" name="area" type="RID" /> + <argument index="1" name="id" type="int" /> <description> Assigns the area to a descendant of [Object], so it can exist in the node tree. </description> </method> <method name="area_clear_shapes"> - <return type="void"> - </return> - <argument index="0" name="area" type="RID"> - </argument> + <return type="void" /> + <argument index="0" name="area" type="RID" /> <description> Removes all shapes from an area. It does not delete the shapes, so they can be reassigned later. </description> </method> <method name="area_create"> - <return type="RID"> - </return> + <return type="RID" /> <description> Creates an [Area2D]. After creating an [Area2D] with this method, assign it to a space using [method area_set_space] to use the created [Area2D] in the physics world. </description> </method> <method name="area_get_canvas_instance_id" qualifiers="const"> - <return type="int"> - </return> - <argument index="0" name="area" type="RID"> - </argument> + <return type="int" /> + <argument index="0" name="area" type="RID" /> <description> </description> </method> <method name="area_get_object_instance_id" qualifiers="const"> - <return type="int"> - </return> - <argument index="0" name="area" type="RID"> - </argument> + <return type="int" /> + <argument index="0" name="area" type="RID" /> <description> Gets the instance ID of the object the area is assigned to. </description> </method> <method name="area_get_param" qualifiers="const"> - <return type="Variant"> - </return> - <argument index="0" name="area" type="RID"> - </argument> - <argument index="1" name="param" type="int" enum="PhysicsServer2D.AreaParameter"> - </argument> + <return type="Variant" /> + <argument index="0" name="area" type="RID" /> + <argument index="1" name="param" type="int" enum="PhysicsServer2D.AreaParameter" /> <description> Returns an area parameter value. See [enum AreaParameter] for a list of available parameters. </description> </method> <method name="area_get_shape" qualifiers="const"> - <return type="RID"> - </return> - <argument index="0" name="area" type="RID"> - </argument> - <argument index="1" name="shape_idx" type="int"> - </argument> + <return type="RID" /> + <argument index="0" name="area" type="RID" /> + <argument index="1" name="shape_idx" type="int" /> <description> Returns the [RID] of the nth shape of an area. </description> </method> <method name="area_get_shape_count" qualifiers="const"> - <return type="int"> - </return> - <argument index="0" name="area" type="RID"> - </argument> + <return type="int" /> + <argument index="0" name="area" type="RID" /> <description> Returns the number of shapes assigned to an area. </description> </method> <method name="area_get_shape_transform" qualifiers="const"> - <return type="Transform2D"> - </return> - <argument index="0" name="area" type="RID"> - </argument> - <argument index="1" name="shape_idx" type="int"> - </argument> + <return type="Transform2D" /> + <argument index="0" name="area" type="RID" /> + <argument index="1" name="shape_idx" type="int" /> <description> Returns the transform matrix of a shape within an area. </description> </method> <method name="area_get_space" qualifiers="const"> - <return type="RID"> - </return> - <argument index="0" name="area" type="RID"> - </argument> + <return type="RID" /> + <argument index="0" name="area" type="RID" /> <description> Returns the space assigned to the area. </description> </method> <method name="area_get_space_override_mode" qualifiers="const"> - <return type="int" enum="PhysicsServer2D.AreaSpaceOverrideMode"> - </return> - <argument index="0" name="area" type="RID"> - </argument> + <return type="int" enum="PhysicsServer2D.AreaSpaceOverrideMode" /> + <argument index="0" name="area" type="RID" /> <description> Returns the space override mode for the area. </description> </method> <method name="area_get_transform" qualifiers="const"> - <return type="Transform2D"> - </return> - <argument index="0" name="area" type="RID"> - </argument> + <return type="Transform2D" /> + <argument index="0" name="area" type="RID" /> <description> Returns the transform matrix for an area. </description> </method> <method name="area_remove_shape"> - <return type="void"> - </return> - <argument index="0" name="area" type="RID"> - </argument> - <argument index="1" name="shape_idx" type="int"> - </argument> + <return type="void" /> + <argument index="0" name="area" type="RID" /> + <argument index="1" name="shape_idx" type="int" /> <description> Removes a shape from an area. It does not delete the shape, so it can be reassigned later. </description> </method> <method name="area_set_area_monitor_callback"> - <return type="void"> - </return> - <argument index="0" name="area" type="RID"> - </argument> - <argument index="1" name="receiver" type="Object"> - </argument> - <argument index="2" name="method" type="StringName"> - </argument> + <return type="void" /> + <argument index="0" name="area" type="RID" /> + <argument index="1" name="receiver" type="Object" /> + <argument index="2" name="method" type="StringName" /> <description> </description> </method> <method name="area_set_collision_layer"> - <return type="void"> - </return> - <argument index="0" name="area" type="RID"> - </argument> - <argument index="1" name="layer" type="int"> - </argument> + <return type="void" /> + <argument index="0" name="area" type="RID" /> + <argument index="1" name="layer" type="int" /> <description> Assigns the area to one or many physics layers. </description> </method> <method name="area_set_collision_mask"> - <return type="void"> - </return> - <argument index="0" name="area" type="RID"> - </argument> - <argument index="1" name="mask" type="int"> - </argument> + <return type="void" /> + <argument index="0" name="area" type="RID" /> + <argument index="1" name="mask" type="int" /> <description> Sets which physics layers the area will monitor. </description> </method> <method name="area_set_monitor_callback"> - <return type="void"> - </return> - <argument index="0" name="area" type="RID"> - </argument> - <argument index="1" name="receiver" type="Object"> - </argument> - <argument index="2" name="method" type="StringName"> - </argument> + <return type="void" /> + <argument index="0" name="area" type="RID" /> + <argument index="1" name="receiver" type="Object" /> + <argument index="2" name="method" type="StringName" /> <description> Sets the function to call when any body/area enters or exits the area. This callback will be called for any object interacting with the area, and takes five parameters: 1: [constant AREA_BODY_ADDED] or [constant AREA_BODY_REMOVED], depending on whether the object entered or exited the area. @@ -211,907 +159,662 @@ </description> </method> <method name="area_set_monitorable"> - <return type="void"> - </return> - <argument index="0" name="area" type="RID"> - </argument> - <argument index="1" name="monitorable" type="bool"> - </argument> + <return type="void" /> + <argument index="0" name="area" type="RID" /> + <argument index="1" name="monitorable" type="bool" /> <description> </description> </method> <method name="area_set_param"> - <return type="void"> - </return> - <argument index="0" name="area" type="RID"> - </argument> - <argument index="1" name="param" type="int" enum="PhysicsServer2D.AreaParameter"> - </argument> - <argument index="2" name="value" type="Variant"> - </argument> + <return type="void" /> + <argument index="0" name="area" type="RID" /> + <argument index="1" name="param" type="int" enum="PhysicsServer2D.AreaParameter" /> + <argument index="2" name="value" type="Variant" /> <description> Sets the value for an area parameter. See [enum AreaParameter] for a list of available parameters. </description> </method> <method name="area_set_shape"> - <return type="void"> - </return> - <argument index="0" name="area" type="RID"> - </argument> - <argument index="1" name="shape_idx" type="int"> - </argument> - <argument index="2" name="shape" type="RID"> - </argument> + <return type="void" /> + <argument index="0" name="area" type="RID" /> + <argument index="1" name="shape_idx" type="int" /> + <argument index="2" name="shape" type="RID" /> <description> Substitutes a given area shape by another. The old shape is selected by its index, the new one by its [RID]. </description> </method> <method name="area_set_shape_disabled"> - <return type="void"> - </return> - <argument index="0" name="area" type="RID"> - </argument> - <argument index="1" name="shape_idx" type="int"> - </argument> - <argument index="2" name="disabled" type="bool"> - </argument> + <return type="void" /> + <argument index="0" name="area" type="RID" /> + <argument index="1" name="shape_idx" type="int" /> + <argument index="2" name="disabled" type="bool" /> <description> Disables a given shape in an area. </description> </method> <method name="area_set_shape_transform"> - <return type="void"> - </return> - <argument index="0" name="area" type="RID"> - </argument> - <argument index="1" name="shape_idx" type="int"> - </argument> - <argument index="2" name="transform" type="Transform2D"> - </argument> + <return type="void" /> + <argument index="0" name="area" type="RID" /> + <argument index="1" name="shape_idx" type="int" /> + <argument index="2" name="transform" type="Transform2D" /> <description> Sets the transform matrix for an area shape. </description> </method> <method name="area_set_space"> - <return type="void"> - </return> - <argument index="0" name="area" type="RID"> - </argument> - <argument index="1" name="space" type="RID"> - </argument> + <return type="void" /> + <argument index="0" name="area" type="RID" /> + <argument index="1" name="space" type="RID" /> <description> Assigns a space to the area. </description> </method> <method name="area_set_space_override_mode"> - <return type="void"> - </return> - <argument index="0" name="area" type="RID"> - </argument> - <argument index="1" name="mode" type="int" enum="PhysicsServer2D.AreaSpaceOverrideMode"> - </argument> + <return type="void" /> + <argument index="0" name="area" type="RID" /> + <argument index="1" name="mode" type="int" enum="PhysicsServer2D.AreaSpaceOverrideMode" /> <description> Sets the space override mode for the area. See [enum AreaSpaceOverrideMode] for a list of available modes. </description> </method> <method name="area_set_transform"> - <return type="void"> - </return> - <argument index="0" name="area" type="RID"> - </argument> - <argument index="1" name="transform" type="Transform2D"> - </argument> + <return type="void" /> + <argument index="0" name="area" type="RID" /> + <argument index="1" name="transform" type="Transform2D" /> <description> Sets the transform matrix for an area. </description> </method> <method name="body_add_central_force"> - <return type="void"> - </return> - <argument index="0" name="body" type="RID"> - </argument> - <argument index="1" name="force" type="Vector2"> - </argument> + <return type="void" /> + <argument index="0" name="body" type="RID" /> + <argument index="1" name="force" type="Vector2" /> <description> </description> </method> <method name="body_add_collision_exception"> - <return type="void"> - </return> - <argument index="0" name="body" type="RID"> - </argument> - <argument index="1" name="excepted_body" type="RID"> - </argument> + <return type="void" /> + <argument index="0" name="body" type="RID" /> + <argument index="1" name="excepted_body" type="RID" /> <description> Adds a body to the list of bodies exempt from collisions. </description> </method> <method name="body_add_force"> - <return type="void"> - </return> - <argument index="0" name="body" type="RID"> - </argument> - <argument index="1" name="force" type="Vector2"> - </argument> - <argument index="2" name="position" type="Vector2" default="Vector2(0, 0)"> - </argument> + <return type="void" /> + <argument index="0" name="body" type="RID" /> + <argument index="1" name="force" type="Vector2" /> + <argument index="2" name="position" type="Vector2" default="Vector2(0, 0)" /> <description> Adds a positioned force to the applied force and torque. As with [method body_apply_impulse], both the force and the offset from the body origin are in global coordinates. A force differs from an impulse in that, while the two are forces, the impulse clears itself after being applied. </description> </method> <method name="body_add_shape"> - <return type="void"> - </return> - <argument index="0" name="body" type="RID"> - </argument> - <argument index="1" name="shape" type="RID"> - </argument> - <argument index="2" name="transform" type="Transform2D" default="Transform2D(1, 0, 0, 1, 0, 0)"> - </argument> - <argument index="3" name="disabled" type="bool" default="false"> - </argument> + <return type="void" /> + <argument index="0" name="body" type="RID" /> + <argument index="1" name="shape" type="RID" /> + <argument index="2" name="transform" type="Transform2D" default="Transform2D(1, 0, 0, 1, 0, 0)" /> + <argument index="3" name="disabled" type="bool" default="false" /> <description> Adds a shape to the body, along with a transform matrix. Shapes are usually referenced by their index, so you should track which shape has a given index. </description> </method> <method name="body_add_torque"> - <return type="void"> - </return> - <argument index="0" name="body" type="RID"> - </argument> - <argument index="1" name="torque" type="float"> - </argument> + <return type="void" /> + <argument index="0" name="body" type="RID" /> + <argument index="1" name="torque" type="float" /> <description> </description> </method> <method name="body_apply_central_impulse"> - <return type="void"> - </return> - <argument index="0" name="body" type="RID"> - </argument> - <argument index="1" name="impulse" type="Vector2"> - </argument> + <return type="void" /> + <argument index="0" name="body" type="RID" /> + <argument index="1" name="impulse" type="Vector2" /> <description> </description> </method> <method name="body_apply_impulse"> - <return type="void"> - </return> - <argument index="0" name="body" type="RID"> - </argument> - <argument index="1" name="impulse" type="Vector2"> - </argument> - <argument index="2" name="position" type="Vector2" default="Vector2(0, 0)"> - </argument> + <return type="void" /> + <argument index="0" name="body" type="RID" /> + <argument index="1" name="impulse" type="Vector2" /> + <argument index="2" name="position" type="Vector2" default="Vector2(0, 0)" /> <description> Adds a positioned impulse to the applied force and torque. Both the force and the offset from the body origin are in global coordinates. </description> </method> <method name="body_apply_torque_impulse"> - <return type="void"> - </return> - <argument index="0" name="body" type="RID"> - </argument> - <argument index="1" name="impulse" type="float"> - </argument> + <return type="void" /> + <argument index="0" name="body" type="RID" /> + <argument index="1" name="impulse" type="float" /> <description> </description> </method> <method name="body_attach_canvas_instance_id"> - <return type="void"> - </return> - <argument index="0" name="body" type="RID"> - </argument> - <argument index="1" name="id" type="int"> - </argument> + <return type="void" /> + <argument index="0" name="body" type="RID" /> + <argument index="1" name="id" type="int" /> <description> </description> </method> <method name="body_attach_object_instance_id"> - <return type="void"> - </return> - <argument index="0" name="body" type="RID"> - </argument> - <argument index="1" name="id" type="int"> - </argument> + <return type="void" /> + <argument index="0" name="body" type="RID" /> + <argument index="1" name="id" type="int" /> <description> Assigns the area to a descendant of [Object], so it can exist in the node tree. </description> </method> <method name="body_clear_shapes"> - <return type="void"> - </return> - <argument index="0" name="body" type="RID"> - </argument> + <return type="void" /> + <argument index="0" name="body" type="RID" /> <description> Removes all shapes from a body. </description> </method> <method name="body_create"> - <return type="RID"> - </return> + <return type="RID" /> <description> Creates a physics body. </description> </method> <method name="body_get_canvas_instance_id" qualifiers="const"> - <return type="int"> - </return> - <argument index="0" name="body" type="RID"> - </argument> + <return type="int" /> + <argument index="0" name="body" type="RID" /> <description> </description> </method> <method name="body_get_collision_layer" qualifiers="const"> - <return type="int"> - </return> - <argument index="0" name="body" type="RID"> - </argument> + <return type="int" /> + <argument index="0" name="body" type="RID" /> <description> Returns the physics layer or layers a body belongs to. </description> </method> <method name="body_get_collision_mask" qualifiers="const"> - <return type="int"> - </return> - <argument index="0" name="body" type="RID"> - </argument> + <return type="int" /> + <argument index="0" name="body" type="RID" /> <description> Returns the physics layer or layers a body can collide with. </description> </method> <method name="body_get_continuous_collision_detection_mode" qualifiers="const"> - <return type="int" enum="PhysicsServer2D.CCDMode"> - </return> - <argument index="0" name="body" type="RID"> - </argument> + <return type="int" enum="PhysicsServer2D.CCDMode" /> + <argument index="0" name="body" type="RID" /> <description> Returns the continuous collision detection mode. </description> </method> <method name="body_get_direct_state"> - <return type="PhysicsDirectBodyState2D"> - </return> - <argument index="0" name="body" type="RID"> - </argument> + <return type="PhysicsDirectBodyState2D" /> + <argument index="0" name="body" type="RID" /> <description> Returns the [PhysicsDirectBodyState2D] of the body. </description> </method> <method name="body_get_max_contacts_reported" qualifiers="const"> - <return type="int"> - </return> - <argument index="0" name="body" type="RID"> - </argument> + <return type="int" /> + <argument index="0" name="body" type="RID" /> <description> Returns the maximum contacts that can be reported. See [method body_set_max_contacts_reported]. </description> </method> <method name="body_get_mode" qualifiers="const"> - <return type="int" enum="PhysicsServer2D.BodyMode"> - </return> - <argument index="0" name="body" type="RID"> - </argument> + <return type="int" enum="PhysicsServer2D.BodyMode" /> + <argument index="0" name="body" type="RID" /> <description> Returns the body mode. </description> </method> <method name="body_get_object_instance_id" qualifiers="const"> - <return type="int"> - </return> - <argument index="0" name="body" type="RID"> - </argument> + <return type="int" /> + <argument index="0" name="body" type="RID" /> <description> Gets the instance ID of the object the area is assigned to. </description> </method> <method name="body_get_param" qualifiers="const"> - <return type="float"> - </return> - <argument index="0" name="body" type="RID"> - </argument> - <argument index="1" name="param" type="int" enum="PhysicsServer2D.BodyParameter"> - </argument> + <return type="float" /> + <argument index="0" name="body" type="RID" /> + <argument index="1" name="param" type="int" enum="PhysicsServer2D.BodyParameter" /> <description> Returns the value of a body parameter. See [enum BodyParameter] for a list of available parameters. </description> </method> <method name="body_get_shape" qualifiers="const"> - <return type="RID"> - </return> - <argument index="0" name="body" type="RID"> - </argument> - <argument index="1" name="shape_idx" type="int"> - </argument> + <return type="RID" /> + <argument index="0" name="body" type="RID" /> + <argument index="1" name="shape_idx" type="int" /> <description> Returns the [RID] of the nth shape of a body. </description> </method> <method name="body_get_shape_count" qualifiers="const"> - <return type="int"> - </return> - <argument index="0" name="body" type="RID"> - </argument> + <return type="int" /> + <argument index="0" name="body" type="RID" /> <description> Returns the number of shapes assigned to a body. </description> </method> <method name="body_get_shape_metadata" qualifiers="const"> - <return type="Variant"> - </return> - <argument index="0" name="body" type="RID"> - </argument> - <argument index="1" name="shape_idx" type="int"> - </argument> + <return type="Variant" /> + <argument index="0" name="body" type="RID" /> + <argument index="1" name="shape_idx" type="int" /> <description> Returns the metadata of a shape of a body. </description> </method> <method name="body_get_shape_transform" qualifiers="const"> - <return type="Transform2D"> - </return> - <argument index="0" name="body" type="RID"> - </argument> - <argument index="1" name="shape_idx" type="int"> - </argument> + <return type="Transform2D" /> + <argument index="0" name="body" type="RID" /> + <argument index="1" name="shape_idx" type="int" /> <description> Returns the transform matrix of a body shape. </description> </method> <method name="body_get_space" qualifiers="const"> - <return type="RID"> - </return> - <argument index="0" name="body" type="RID"> - </argument> + <return type="RID" /> + <argument index="0" name="body" type="RID" /> <description> Returns the [RID] of the space assigned to a body. </description> </method> <method name="body_get_state" qualifiers="const"> - <return type="Variant"> - </return> - <argument index="0" name="body" type="RID"> - </argument> - <argument index="1" name="state" type="int" enum="PhysicsServer2D.BodyState"> - </argument> + <return type="Variant" /> + <argument index="0" name="body" type="RID" /> + <argument index="1" name="state" type="int" enum="PhysicsServer2D.BodyState" /> <description> Returns a body state. </description> </method> <method name="body_is_omitting_force_integration" qualifiers="const"> - <return type="bool"> - </return> - <argument index="0" name="body" type="RID"> - </argument> + <return type="bool" /> + <argument index="0" name="body" type="RID" /> <description> Returns whether a body uses a callback function to calculate its own physics (see [method body_set_force_integration_callback]). </description> </method> <method name="body_remove_collision_exception"> - <return type="void"> - </return> - <argument index="0" name="body" type="RID"> - </argument> - <argument index="1" name="excepted_body" type="RID"> - </argument> + <return type="void" /> + <argument index="0" name="body" type="RID" /> + <argument index="1" name="excepted_body" type="RID" /> <description> Removes a body from the list of bodies exempt from collisions. </description> </method> <method name="body_remove_shape"> - <return type="void"> - </return> - <argument index="0" name="body" type="RID"> - </argument> - <argument index="1" name="shape_idx" type="int"> - </argument> + <return type="void" /> + <argument index="0" name="body" type="RID" /> + <argument index="1" name="shape_idx" type="int" /> <description> Removes a shape from a body. The shape is not deleted, so it can be reused afterwards. </description> </method> <method name="body_set_axis_velocity"> - <return type="void"> - </return> - <argument index="0" name="body" type="RID"> - </argument> - <argument index="1" name="axis_velocity" type="Vector2"> - </argument> + <return type="void" /> + <argument index="0" name="body" type="RID" /> + <argument index="1" name="axis_velocity" type="Vector2" /> <description> Sets an axis velocity. The velocity in the given vector axis will be set as the given vector length. This is useful for jumping behavior. </description> </method> <method name="body_set_collision_layer"> - <return type="void"> - </return> - <argument index="0" name="body" type="RID"> - </argument> - <argument index="1" name="layer" type="int"> - </argument> + <return type="void" /> + <argument index="0" name="body" type="RID" /> + <argument index="1" name="layer" type="int" /> <description> Sets the physics layer or layers a body belongs to. </description> </method> <method name="body_set_collision_mask"> - <return type="void"> - </return> - <argument index="0" name="body" type="RID"> - </argument> - <argument index="1" name="mask" type="int"> - </argument> + <return type="void" /> + <argument index="0" name="body" type="RID" /> + <argument index="1" name="mask" type="int" /> <description> Sets the physics layer or layers a body can collide with. </description> </method> <method name="body_set_continuous_collision_detection_mode"> - <return type="void"> - </return> - <argument index="0" name="body" type="RID"> - </argument> - <argument index="1" name="mode" type="int" enum="PhysicsServer2D.CCDMode"> - </argument> + <return type="void" /> + <argument index="0" name="body" type="RID" /> + <argument index="1" name="mode" type="int" enum="PhysicsServer2D.CCDMode" /> <description> Sets the continuous collision detection mode using one of the [enum CCDMode] constants. Continuous collision detection tries to predict where a moving body will collide, instead of moving it and correcting its movement if it collided. </description> </method> <method name="body_set_force_integration_callback"> - <return type="void"> - </return> - <argument index="0" name="body" type="RID"> - </argument> - <argument index="1" name="callable" type="Callable"> - </argument> - <argument index="2" name="userdata" type="Variant" default="null"> - </argument> + <return type="void" /> + <argument index="0" name="body" type="RID" /> + <argument index="1" name="callable" type="Callable" /> + <argument index="2" name="userdata" type="Variant" default="null" /> <description> Sets the function used to calculate physics for an object, if that object allows it (see [method body_set_omit_force_integration]). </description> </method> <method name="body_set_max_contacts_reported"> - <return type="void"> - </return> - <argument index="0" name="body" type="RID"> - </argument> - <argument index="1" name="amount" type="int"> - </argument> + <return type="void" /> + <argument index="0" name="body" type="RID" /> + <argument index="1" name="amount" type="int" /> <description> Sets the maximum contacts to report. Bodies can keep a log of the contacts with other bodies, this is enabled by setting the maximum amount of contacts reported to a number greater than 0. </description> </method> <method name="body_set_mode"> - <return type="void"> - </return> - <argument index="0" name="body" type="RID"> - </argument> - <argument index="1" name="mode" type="int" enum="PhysicsServer2D.BodyMode"> - </argument> + <return type="void" /> + <argument index="0" name="body" type="RID" /> + <argument index="1" name="mode" type="int" enum="PhysicsServer2D.BodyMode" /> <description> Sets the body mode using one of the [enum BodyMode] constants. </description> </method> <method name="body_set_omit_force_integration"> - <return type="void"> - </return> - <argument index="0" name="body" type="RID"> - </argument> - <argument index="1" name="enable" type="bool"> - </argument> + <return type="void" /> + <argument index="0" name="body" type="RID" /> + <argument index="1" name="enable" type="bool" /> <description> Sets whether a body uses a callback function to calculate its own physics (see [method body_set_force_integration_callback]). </description> </method> <method name="body_set_param"> - <return type="void"> - </return> - <argument index="0" name="body" type="RID"> - </argument> - <argument index="1" name="param" type="int" enum="PhysicsServer2D.BodyParameter"> - </argument> - <argument index="2" name="value" type="float"> - </argument> + <return type="void" /> + <argument index="0" name="body" type="RID" /> + <argument index="1" name="param" type="int" enum="PhysicsServer2D.BodyParameter" /> + <argument index="2" name="value" type="float" /> <description> Sets a body parameter. See [enum BodyParameter] for a list of available parameters. </description> </method> <method name="body_set_shape"> - <return type="void"> - </return> - <argument index="0" name="body" type="RID"> - </argument> - <argument index="1" name="shape_idx" type="int"> - </argument> - <argument index="2" name="shape" type="RID"> - </argument> + <return type="void" /> + <argument index="0" name="body" type="RID" /> + <argument index="1" name="shape_idx" type="int" /> + <argument index="2" name="shape" type="RID" /> <description> Substitutes a given body shape by another. The old shape is selected by its index, the new one by its [RID]. </description> </method> <method name="body_set_shape_as_one_way_collision"> - <return type="void"> - </return> - <argument index="0" name="body" type="RID"> - </argument> - <argument index="1" name="shape_idx" type="int"> - </argument> - <argument index="2" name="enable" type="bool"> - </argument> - <argument index="3" name="margin" type="float"> - </argument> + <return type="void" /> + <argument index="0" name="body" type="RID" /> + <argument index="1" name="shape_idx" type="int" /> + <argument index="2" name="enable" type="bool" /> + <argument index="3" name="margin" type="float" /> <description> Enables one way collision on body if [code]enable[/code] is [code]true[/code]. </description> </method> <method name="body_set_shape_disabled"> - <return type="void"> - </return> - <argument index="0" name="body" type="RID"> - </argument> - <argument index="1" name="shape_idx" type="int"> - </argument> - <argument index="2" name="disabled" type="bool"> - </argument> + <return type="void" /> + <argument index="0" name="body" type="RID" /> + <argument index="1" name="shape_idx" type="int" /> + <argument index="2" name="disabled" type="bool" /> <description> Disables shape in body if [code]disable[/code] is [code]true[/code]. </description> </method> <method name="body_set_shape_metadata"> - <return type="void"> - </return> - <argument index="0" name="body" type="RID"> - </argument> - <argument index="1" name="shape_idx" type="int"> - </argument> - <argument index="2" name="metadata" type="Variant"> - </argument> + <return type="void" /> + <argument index="0" name="body" type="RID" /> + <argument index="1" name="shape_idx" type="int" /> + <argument index="2" name="metadata" type="Variant" /> <description> Sets metadata of a shape within a body. This metadata is different from [method Object.set_meta], and can be retrieved on shape queries. </description> </method> <method name="body_set_shape_transform"> - <return type="void"> - </return> - <argument index="0" name="body" type="RID"> - </argument> - <argument index="1" name="shape_idx" type="int"> - </argument> - <argument index="2" name="transform" type="Transform2D"> - </argument> + <return type="void" /> + <argument index="0" name="body" type="RID" /> + <argument index="1" name="shape_idx" type="int" /> + <argument index="2" name="transform" type="Transform2D" /> <description> Sets the transform matrix for a body shape. </description> </method> <method name="body_set_space"> - <return type="void"> - </return> - <argument index="0" name="body" type="RID"> - </argument> - <argument index="1" name="space" type="RID"> - </argument> + <return type="void" /> + <argument index="0" name="body" type="RID" /> + <argument index="1" name="space" type="RID" /> <description> Assigns a space to the body (see [method space_create]). </description> </method> <method name="body_set_state"> - <return type="void"> - </return> - <argument index="0" name="body" type="RID"> - </argument> - <argument index="1" name="state" type="int" enum="PhysicsServer2D.BodyState"> - </argument> - <argument index="2" name="value" type="Variant"> - </argument> + <return type="void" /> + <argument index="0" name="body" type="RID" /> + <argument index="1" name="state" type="int" enum="PhysicsServer2D.BodyState" /> + <argument index="2" name="value" type="Variant" /> <description> Sets a body state using one of the [enum BodyState] constants. Note that the method doesn't take effect immediately. The state will change on the next physics frame. </description> </method> <method name="body_test_motion"> - <return type="bool"> - </return> - <argument index="0" name="body" type="RID"> - </argument> - <argument index="1" name="from" type="Transform2D"> - </argument> - <argument index="2" name="motion" type="Vector2"> - </argument> - <argument index="3" name="infinite_inertia" type="bool"> - </argument> - <argument index="4" name="margin" type="float" default="0.08"> - </argument> - <argument index="5" name="result" type="PhysicsTestMotionResult2D" default="null"> - </argument> + <return type="bool" /> + <argument index="0" name="body" type="RID" /> + <argument index="1" name="from" type="Transform2D" /> + <argument index="2" name="motion" type="Vector2" /> + <argument index="3" name="infinite_inertia" type="bool" /> + <argument index="4" name="margin" type="float" default="0.08" /> + <argument index="5" name="result" type="PhysicsTestMotionResult2D" default="null" /> + <argument index="6" name="exclude_raycast_shapes" type="bool" default="true" /> + <argument index="7" name="exclude" type="Array" default="[]" /> <description> Returns [code]true[/code] if a collision would result from moving in the given direction from a given point in space. Margin increases the size of the shapes involved in the collision detection. [PhysicsTestMotionResult2D] can be passed to return additional information in. </description> </method> <method name="capsule_shape_create"> - <return type="RID"> - </return> + <return type="RID" /> <description> </description> </method> <method name="circle_shape_create"> - <return type="RID"> - </return> + <return type="RID" /> <description> </description> </method> <method name="concave_polygon_shape_create"> - <return type="RID"> - </return> + <return type="RID" /> <description> </description> </method> <method name="convex_polygon_shape_create"> - <return type="RID"> - </return> + <return type="RID" /> <description> </description> </method> <method name="damped_spring_joint_get_param" qualifiers="const"> - <return type="float"> - </return> - <argument index="0" name="joint" type="RID"> - </argument> - <argument index="1" name="param" type="int" enum="PhysicsServer2D.DampedSpringParam"> - </argument> + <return type="float" /> + <argument index="0" name="joint" type="RID" /> + <argument index="1" name="param" type="int" enum="PhysicsServer2D.DampedSpringParam" /> <description> Returns the value of a damped spring joint parameter. See [enum DampedSpringParam] for a list of available parameters. </description> </method> <method name="damped_spring_joint_set_param"> - <return type="void"> - </return> - <argument index="0" name="joint" type="RID"> - </argument> - <argument index="1" name="param" type="int" enum="PhysicsServer2D.DampedSpringParam"> - </argument> - <argument index="2" name="value" type="float"> - </argument> + <return type="void" /> + <argument index="0" name="joint" type="RID" /> + <argument index="1" name="param" type="int" enum="PhysicsServer2D.DampedSpringParam" /> + <argument index="2" name="value" type="float" /> <description> Sets a damped spring joint parameter. See [enum DampedSpringParam] for a list of available parameters. </description> </method> <method name="free_rid"> - <return type="void"> - </return> - <argument index="0" name="rid" type="RID"> - </argument> + <return type="void" /> + <argument index="0" name="rid" type="RID" /> <description> Destroys any of the objects created by PhysicsServer2D. If the [RID] passed is not one of the objects that can be created by PhysicsServer2D, an error will be sent to the console. </description> </method> <method name="get_process_info"> - <return type="int"> - </return> - <argument index="0" name="process_info" type="int" enum="PhysicsServer2D.ProcessInfo"> - </argument> + <return type="int" /> + <argument index="0" name="process_info" type="int" enum="PhysicsServer2D.ProcessInfo" /> <description> Returns information about the current state of the 2D physics engine. See [enum ProcessInfo] for a list of available states. </description> </method> <method name="joint_clear"> - <return type="void"> - </return> - <argument index="0" name="joint" type="RID"> - </argument> + <return type="void" /> + <argument index="0" name="joint" type="RID" /> <description> </description> </method> <method name="joint_create"> - <return type="RID"> - </return> + <return type="RID" /> <description> </description> </method> <method name="joint_get_param" qualifiers="const"> - <return type="float"> - </return> - <argument index="0" name="joint" type="RID"> - </argument> - <argument index="1" name="param" type="int" enum="PhysicsServer2D.JointParam"> - </argument> + <return type="float" /> + <argument index="0" name="joint" type="RID" /> + <argument index="1" name="param" type="int" enum="PhysicsServer2D.JointParam" /> <description> Returns the value of a joint parameter. </description> </method> <method name="joint_get_type" qualifiers="const"> - <return type="int" enum="PhysicsServer2D.JointType"> - </return> - <argument index="0" name="joint" type="RID"> - </argument> + <return type="int" enum="PhysicsServer2D.JointType" /> + <argument index="0" name="joint" type="RID" /> <description> Returns a joint's type (see [enum JointType]). </description> </method> <method name="joint_make_damped_spring"> - <return type="void"> - </return> - <argument index="0" name="joint" type="RID"> - </argument> - <argument index="1" name="anchor_a" type="Vector2"> - </argument> - <argument index="2" name="anchor_b" type="Vector2"> - </argument> - <argument index="3" name="body_a" type="RID"> - </argument> - <argument index="4" name="body_b" type="RID"> - </argument> + <return type="void" /> + <argument index="0" name="joint" type="RID" /> + <argument index="1" name="anchor_a" type="Vector2" /> + <argument index="2" name="anchor_b" type="Vector2" /> + <argument index="3" name="body_a" type="RID" /> + <argument index="4" name="body_b" type="RID" /> <description> </description> </method> <method name="joint_make_groove"> - <return type="void"> - </return> - <argument index="0" name="joint" type="RID"> - </argument> - <argument index="1" name="groove1_a" type="Vector2"> - </argument> - <argument index="2" name="groove2_a" type="Vector2"> - </argument> - <argument index="3" name="anchor_b" type="Vector2"> - </argument> - <argument index="4" name="body_a" type="RID"> - </argument> - <argument index="5" name="body_b" type="RID"> - </argument> + <return type="void" /> + <argument index="0" name="joint" type="RID" /> + <argument index="1" name="groove1_a" type="Vector2" /> + <argument index="2" name="groove2_a" type="Vector2" /> + <argument index="3" name="anchor_b" type="Vector2" /> + <argument index="4" name="body_a" type="RID" /> + <argument index="5" name="body_b" type="RID" /> <description> </description> </method> <method name="joint_make_pin"> - <return type="void"> - </return> - <argument index="0" name="joint" type="RID"> - </argument> - <argument index="1" name="anchor" type="Vector2"> - </argument> - <argument index="2" name="body_a" type="RID"> - </argument> - <argument index="3" name="body_b" type="RID"> - </argument> + <return type="void" /> + <argument index="0" name="joint" type="RID" /> + <argument index="1" name="anchor" type="Vector2" /> + <argument index="2" name="body_a" type="RID" /> + <argument index="3" name="body_b" type="RID" /> <description> </description> </method> <method name="joint_set_param"> - <return type="void"> - </return> - <argument index="0" name="joint" type="RID"> - </argument> - <argument index="1" name="param" type="int" enum="PhysicsServer2D.JointParam"> - </argument> - <argument index="2" name="value" type="float"> - </argument> + <return type="void" /> + <argument index="0" name="joint" type="RID" /> + <argument index="1" name="param" type="int" enum="PhysicsServer2D.JointParam" /> + <argument index="2" name="value" type="float" /> <description> Sets a joint parameter. See [enum JointParam] for a list of available parameters. </description> </method> <method name="line_shape_create"> - <return type="RID"> - </return> + <return type="RID" /> <description> </description> </method> <method name="ray_shape_create"> - <return type="RID"> - </return> + <return type="RID" /> <description> </description> </method> <method name="rectangle_shape_create"> - <return type="RID"> - </return> + <return type="RID" /> <description> </description> </method> <method name="segment_shape_create"> - <return type="RID"> - </return> + <return type="RID" /> <description> </description> </method> <method name="set_active"> - <return type="void"> - </return> - <argument index="0" name="active" type="bool"> - </argument> + <return type="void" /> + <argument index="0" name="active" type="bool" /> <description> Activates or deactivates the 2D physics engine. </description> </method> <method name="set_collision_iterations"> - <return type="void"> - </return> - <argument index="0" name="iterations" type="int"> - </argument> + <return type="void" /> + <argument index="0" name="iterations" type="int" /> <description> - Sets the amount of iterations for calculating velocities of colliding bodies. The greater the amount, the more accurate the collisions, but with a performance loss. + Sets the amount of iterations for calculating velocities of colliding bodies. The greater the amount of iterations, the more accurate the collisions will be. However, a greater amount of iterations requires more CPU power, which can decrease performance. The default value is [code]8[/code]. </description> </method> <method name="shape_get_data" qualifiers="const"> - <return type="Variant"> - </return> - <argument index="0" name="shape" type="RID"> - </argument> + <return type="Variant" /> + <argument index="0" name="shape" type="RID" /> <description> Returns the shape data. </description> </method> <method name="shape_get_type" qualifiers="const"> - <return type="int" enum="PhysicsServer2D.ShapeType"> - </return> - <argument index="0" name="shape" type="RID"> - </argument> + <return type="int" enum="PhysicsServer2D.ShapeType" /> + <argument index="0" name="shape" type="RID" /> <description> Returns a shape's type (see [enum ShapeType]). </description> </method> <method name="shape_set_data"> - <return type="void"> - </return> - <argument index="0" name="shape" type="RID"> - </argument> - <argument index="1" name="data" type="Variant"> - </argument> + <return type="void" /> + <argument index="0" name="shape" type="RID" /> + <argument index="1" name="data" type="Variant" /> <description> Sets the shape data that defines its shape and size. The data to be passed depends on the kind of shape created [method shape_get_type]. </description> </method> <method name="space_create"> - <return type="RID"> - </return> + <return type="RID" /> <description> Creates a space. A space is a collection of parameters for the physics engine that can be assigned to an area or a body. It can be assigned to an area with [method area_set_space], or to a body with [method body_set_space]. </description> </method> <method name="space_get_direct_state"> - <return type="PhysicsDirectSpaceState2D"> - </return> - <argument index="0" name="space" type="RID"> - </argument> + <return type="PhysicsDirectSpaceState2D" /> + <argument index="0" name="space" type="RID" /> <description> Returns the state of a space, a [PhysicsDirectSpaceState2D]. This object can be used to make collision/intersection queries. </description> </method> <method name="space_get_param" qualifiers="const"> - <return type="float"> - </return> - <argument index="0" name="space" type="RID"> - </argument> - <argument index="1" name="param" type="int" enum="PhysicsServer2D.SpaceParameter"> - </argument> + <return type="float" /> + <argument index="0" name="space" type="RID" /> + <argument index="1" name="param" type="int" enum="PhysicsServer2D.SpaceParameter" /> <description> Returns the value of a space parameter. </description> </method> <method name="space_is_active" qualifiers="const"> - <return type="bool"> - </return> - <argument index="0" name="space" type="RID"> - </argument> + <return type="bool" /> + <argument index="0" name="space" type="RID" /> <description> Returns whether the space is active. </description> </method> <method name="space_set_active"> - <return type="void"> - </return> - <argument index="0" name="space" type="RID"> - </argument> - <argument index="1" name="active" type="bool"> - </argument> + <return type="void" /> + <argument index="0" name="space" type="RID" /> + <argument index="1" name="active" type="bool" /> <description> Marks a space as active. It will not have an effect, unless it is assigned to an area or body. </description> </method> <method name="space_set_param"> - <return type="void"> - </return> - <argument index="0" name="space" type="RID"> - </argument> - <argument index="1" name="param" type="int" enum="PhysicsServer2D.SpaceParameter"> - </argument> - <argument index="2" name="value" type="float"> - </argument> + <return type="void" /> + <argument index="0" name="space" type="RID" /> + <argument index="1" name="param" type="int" enum="PhysicsServer2D.SpaceParameter" /> + <argument index="2" name="value" type="float" /> <description> Sets the value for a space parameter. See [enum SpaceParameter] for a list of available parameters. </description> diff --git a/doc/classes/PhysicsServer3D.xml b/doc/classes/PhysicsServer3D.xml index 88ce222324..7bca8afdda 100644 --- a/doc/classes/PhysicsServer3D.xml +++ b/doc/classes/PhysicsServer3D.xml @@ -10,179 +10,132 @@ </tutorials> <methods> <method name="area_add_shape"> - <return type="void"> - </return> - <argument index="0" name="area" type="RID"> - </argument> - <argument index="1" name="shape" type="RID"> - </argument> - <argument index="2" name="transform" type="Transform3D" default="Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0)"> - </argument> - <argument index="3" name="disabled" type="bool" default="false"> - </argument> + <return type="void" /> + <argument index="0" name="area" type="RID" /> + <argument index="1" name="shape" type="RID" /> + <argument index="2" name="transform" type="Transform3D" default="Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0)" /> + <argument index="3" name="disabled" type="bool" default="false" /> <description> Adds a shape to the area, along with a transform matrix. Shapes are usually referenced by their index, so you should track which shape has a given index. </description> </method> <method name="area_attach_object_instance_id"> - <return type="void"> - </return> - <argument index="0" name="area" type="RID"> - </argument> - <argument index="1" name="id" type="int"> - </argument> + <return type="void" /> + <argument index="0" name="area" type="RID" /> + <argument index="1" name="id" type="int" /> <description> Assigns the area to a descendant of [Object], so it can exist in the node tree. </description> </method> <method name="area_clear_shapes"> - <return type="void"> - </return> - <argument index="0" name="area" type="RID"> - </argument> + <return type="void" /> + <argument index="0" name="area" type="RID" /> <description> Removes all shapes from an area. It does not delete the shapes, so they can be reassigned later. </description> </method> <method name="area_create"> - <return type="RID"> - </return> + <return type="RID" /> <description> Creates an [Area3D]. </description> </method> <method name="area_get_object_instance_id" qualifiers="const"> - <return type="int"> - </return> - <argument index="0" name="area" type="RID"> - </argument> + <return type="int" /> + <argument index="0" name="area" type="RID" /> <description> Gets the instance ID of the object the area is assigned to. </description> </method> <method name="area_get_param" qualifiers="const"> - <return type="Variant"> - </return> - <argument index="0" name="area" type="RID"> - </argument> - <argument index="1" name="param" type="int" enum="PhysicsServer3D.AreaParameter"> - </argument> + <return type="Variant" /> + <argument index="0" name="area" type="RID" /> + <argument index="1" name="param" type="int" enum="PhysicsServer3D.AreaParameter" /> <description> Returns an area parameter value. A list of available parameters is on the [enum AreaParameter] constants. </description> </method> <method name="area_get_shape" qualifiers="const"> - <return type="RID"> - </return> - <argument index="0" name="area" type="RID"> - </argument> - <argument index="1" name="shape_idx" type="int"> - </argument> + <return type="RID" /> + <argument index="0" name="area" type="RID" /> + <argument index="1" name="shape_idx" type="int" /> <description> Returns the [RID] of the nth shape of an area. </description> </method> <method name="area_get_shape_count" qualifiers="const"> - <return type="int"> - </return> - <argument index="0" name="area" type="RID"> - </argument> + <return type="int" /> + <argument index="0" name="area" type="RID" /> <description> Returns the number of shapes assigned to an area. </description> </method> <method name="area_get_shape_transform" qualifiers="const"> - <return type="Transform3D"> - </return> - <argument index="0" name="area" type="RID"> - </argument> - <argument index="1" name="shape_idx" type="int"> - </argument> + <return type="Transform3D" /> + <argument index="0" name="area" type="RID" /> + <argument index="1" name="shape_idx" type="int" /> <description> Returns the transform matrix of a shape within an area. </description> </method> <method name="area_get_space" qualifiers="const"> - <return type="RID"> - </return> - <argument index="0" name="area" type="RID"> - </argument> + <return type="RID" /> + <argument index="0" name="area" type="RID" /> <description> Returns the space assigned to the area. </description> </method> <method name="area_get_space_override_mode" qualifiers="const"> - <return type="int" enum="PhysicsServer3D.AreaSpaceOverrideMode"> - </return> - <argument index="0" name="area" type="RID"> - </argument> + <return type="int" enum="PhysicsServer3D.AreaSpaceOverrideMode" /> + <argument index="0" name="area" type="RID" /> <description> Returns the space override mode for the area. </description> </method> <method name="area_get_transform" qualifiers="const"> - <return type="Transform3D"> - </return> - <argument index="0" name="area" type="RID"> - </argument> + <return type="Transform3D" /> + <argument index="0" name="area" type="RID" /> <description> Returns the transform matrix for an area. </description> </method> <method name="area_remove_shape"> - <return type="void"> - </return> - <argument index="0" name="area" type="RID"> - </argument> - <argument index="1" name="shape_idx" type="int"> - </argument> + <return type="void" /> + <argument index="0" name="area" type="RID" /> + <argument index="1" name="shape_idx" type="int" /> <description> Removes a shape from an area. It does not delete the shape, so it can be reassigned later. </description> </method> <method name="area_set_area_monitor_callback"> - <return type="void"> - </return> - <argument index="0" name="area" type="RID"> - </argument> - <argument index="1" name="receiver" type="Object"> - </argument> - <argument index="2" name="method" type="StringName"> - </argument> + <return type="void" /> + <argument index="0" name="area" type="RID" /> + <argument index="1" name="receiver" type="Object" /> + <argument index="2" name="method" type="StringName" /> <description> </description> </method> <method name="area_set_collision_layer"> - <return type="void"> - </return> - <argument index="0" name="area" type="RID"> - </argument> - <argument index="1" name="layer" type="int"> - </argument> + <return type="void" /> + <argument index="0" name="area" type="RID" /> + <argument index="1" name="layer" type="int" /> <description> Assigns the area to one or many physics layers. </description> </method> <method name="area_set_collision_mask"> - <return type="void"> - </return> - <argument index="0" name="area" type="RID"> - </argument> - <argument index="1" name="mask" type="int"> - </argument> + <return type="void" /> + <argument index="0" name="area" type="RID" /> + <argument index="1" name="mask" type="int" /> <description> Sets which physics layers the area will monitor. </description> </method> <method name="area_set_monitor_callback"> - <return type="void"> - </return> - <argument index="0" name="area" type="RID"> - </argument> - <argument index="1" name="receiver" type="Object"> - </argument> - <argument index="2" name="method" type="StringName"> - </argument> + <return type="void" /> + <argument index="0" name="area" type="RID" /> + <argument index="1" name="receiver" type="Object" /> + <argument index="2" name="method" type="StringName" /> <description> Sets the function to call when any body/area enters or exits the area. This callback will be called for any object interacting with the area, and takes five parameters: 1: [constant AREA_BODY_ADDED] or [constant AREA_BODY_REMOVED], depending on whether the object entered or exited the area. @@ -193,1124 +146,821 @@ </description> </method> <method name="area_set_monitorable"> - <return type="void"> - </return> - <argument index="0" name="area" type="RID"> - </argument> - <argument index="1" name="monitorable" type="bool"> - </argument> + <return type="void" /> + <argument index="0" name="area" type="RID" /> + <argument index="1" name="monitorable" type="bool" /> <description> </description> </method> <method name="area_set_param"> - <return type="void"> - </return> - <argument index="0" name="area" type="RID"> - </argument> - <argument index="1" name="param" type="int" enum="PhysicsServer3D.AreaParameter"> - </argument> - <argument index="2" name="value" type="Variant"> - </argument> + <return type="void" /> + <argument index="0" name="area" type="RID" /> + <argument index="1" name="param" type="int" enum="PhysicsServer3D.AreaParameter" /> + <argument index="2" name="value" type="Variant" /> <description> Sets the value for an area parameter. A list of available parameters is on the [enum AreaParameter] constants. </description> </method> <method name="area_set_ray_pickable"> - <return type="void"> - </return> - <argument index="0" name="area" type="RID"> - </argument> - <argument index="1" name="enable" type="bool"> - </argument> + <return type="void" /> + <argument index="0" name="area" type="RID" /> + <argument index="1" name="enable" type="bool" /> <description> Sets object pickable with rays. </description> </method> <method name="area_set_shape"> - <return type="void"> - </return> - <argument index="0" name="area" type="RID"> - </argument> - <argument index="1" name="shape_idx" type="int"> - </argument> - <argument index="2" name="shape" type="RID"> - </argument> + <return type="void" /> + <argument index="0" name="area" type="RID" /> + <argument index="1" name="shape_idx" type="int" /> + <argument index="2" name="shape" type="RID" /> <description> Substitutes a given area shape by another. The old shape is selected by its index, the new one by its [RID]. </description> </method> <method name="area_set_shape_disabled"> - <return type="void"> - </return> - <argument index="0" name="area" type="RID"> - </argument> - <argument index="1" name="shape_idx" type="int"> - </argument> - <argument index="2" name="disabled" type="bool"> - </argument> + <return type="void" /> + <argument index="0" name="area" type="RID" /> + <argument index="1" name="shape_idx" type="int" /> + <argument index="2" name="disabled" type="bool" /> <description> </description> </method> <method name="area_set_shape_transform"> - <return type="void"> - </return> - <argument index="0" name="area" type="RID"> - </argument> - <argument index="1" name="shape_idx" type="int"> - </argument> - <argument index="2" name="transform" type="Transform3D"> - </argument> + <return type="void" /> + <argument index="0" name="area" type="RID" /> + <argument index="1" name="shape_idx" type="int" /> + <argument index="2" name="transform" type="Transform3D" /> <description> Sets the transform matrix for an area shape. </description> </method> <method name="area_set_space"> - <return type="void"> - </return> - <argument index="0" name="area" type="RID"> - </argument> - <argument index="1" name="space" type="RID"> - </argument> + <return type="void" /> + <argument index="0" name="area" type="RID" /> + <argument index="1" name="space" type="RID" /> <description> Assigns a space to the area. </description> </method> <method name="area_set_space_override_mode"> - <return type="void"> - </return> - <argument index="0" name="area" type="RID"> - </argument> - <argument index="1" name="mode" type="int" enum="PhysicsServer3D.AreaSpaceOverrideMode"> - </argument> + <return type="void" /> + <argument index="0" name="area" type="RID" /> + <argument index="1" name="mode" type="int" enum="PhysicsServer3D.AreaSpaceOverrideMode" /> <description> Sets the space override mode for the area. The modes are described in the [enum AreaSpaceOverrideMode] constants. </description> </method> <method name="area_set_transform"> - <return type="void"> - </return> - <argument index="0" name="area" type="RID"> - </argument> - <argument index="1" name="transform" type="Transform3D"> - </argument> + <return type="void" /> + <argument index="0" name="area" type="RID" /> + <argument index="1" name="transform" type="Transform3D" /> <description> Sets the transform matrix for an area. </description> </method> <method name="body_add_central_force"> - <return type="void"> - </return> - <argument index="0" name="body" type="RID"> - </argument> - <argument index="1" name="force" type="Vector3"> - </argument> + <return type="void" /> + <argument index="0" name="body" type="RID" /> + <argument index="1" name="force" type="Vector3" /> <description> </description> </method> <method name="body_add_collision_exception"> - <return type="void"> - </return> - <argument index="0" name="body" type="RID"> - </argument> - <argument index="1" name="excepted_body" type="RID"> - </argument> + <return type="void" /> + <argument index="0" name="body" type="RID" /> + <argument index="1" name="excepted_body" type="RID" /> <description> Adds a body to the list of bodies exempt from collisions. </description> </method> <method name="body_add_force"> - <return type="void"> - </return> - <argument index="0" name="body" type="RID"> - </argument> - <argument index="1" name="force" type="Vector3"> - </argument> - <argument index="2" name="position" type="Vector3" default="Vector3(0, 0, 0)"> - </argument> + <return type="void" /> + <argument index="0" name="body" type="RID" /> + <argument index="1" name="force" type="Vector3" /> + <argument index="2" name="position" type="Vector3" default="Vector3(0, 0, 0)" /> <description> </description> </method> <method name="body_add_shape"> - <return type="void"> - </return> - <argument index="0" name="body" type="RID"> - </argument> - <argument index="1" name="shape" type="RID"> - </argument> - <argument index="2" name="transform" type="Transform3D" default="Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0)"> - </argument> - <argument index="3" name="disabled" type="bool" default="false"> - </argument> + <return type="void" /> + <argument index="0" name="body" type="RID" /> + <argument index="1" name="shape" type="RID" /> + <argument index="2" name="transform" type="Transform3D" default="Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0)" /> + <argument index="3" name="disabled" type="bool" default="false" /> <description> Adds a shape to the body, along with a transform matrix. Shapes are usually referenced by their index, so you should track which shape has a given index. </description> </method> <method name="body_add_torque"> - <return type="void"> - </return> - <argument index="0" name="body" type="RID"> - </argument> - <argument index="1" name="torque" type="Vector3"> - </argument> + <return type="void" /> + <argument index="0" name="body" type="RID" /> + <argument index="1" name="torque" type="Vector3" /> <description> </description> </method> <method name="body_apply_central_impulse"> - <return type="void"> - </return> - <argument index="0" name="body" type="RID"> - </argument> - <argument index="1" name="impulse" type="Vector3"> - </argument> + <return type="void" /> + <argument index="0" name="body" type="RID" /> + <argument index="1" name="impulse" type="Vector3" /> <description> </description> </method> <method name="body_apply_impulse"> - <return type="void"> - </return> - <argument index="0" name="body" type="RID"> - </argument> - <argument index="1" name="impulse" type="Vector3"> - </argument> - <argument index="2" name="position" type="Vector3" default="Vector3(0, 0, 0)"> - </argument> + <return type="void" /> + <argument index="0" name="body" type="RID" /> + <argument index="1" name="impulse" type="Vector3" /> + <argument index="2" name="position" type="Vector3" default="Vector3(0, 0, 0)" /> <description> Gives the body a push at a [code]position[/code] in the direction of the [code]impulse[/code]. </description> </method> <method name="body_apply_torque_impulse"> - <return type="void"> - </return> - <argument index="0" name="body" type="RID"> - </argument> - <argument index="1" name="impulse" type="Vector3"> - </argument> + <return type="void" /> + <argument index="0" name="body" type="RID" /> + <argument index="1" name="impulse" type="Vector3" /> <description> Gives the body a push to rotate it. </description> </method> <method name="body_attach_object_instance_id"> - <return type="void"> - </return> - <argument index="0" name="body" type="RID"> - </argument> - <argument index="1" name="id" type="int"> - </argument> + <return type="void" /> + <argument index="0" name="body" type="RID" /> + <argument index="1" name="id" type="int" /> <description> Assigns the area to a descendant of [Object], so it can exist in the node tree. </description> </method> <method name="body_clear_shapes"> - <return type="void"> - </return> - <argument index="0" name="body" type="RID"> - </argument> + <return type="void" /> + <argument index="0" name="body" type="RID" /> <description> Removes all shapes from a body. </description> </method> <method name="body_create"> - <return type="RID"> - </return> + <return type="RID" /> <description> </description> </method> <method name="body_get_collision_layer" qualifiers="const"> - <return type="int"> - </return> - <argument index="0" name="body" type="RID"> - </argument> + <return type="int" /> + <argument index="0" name="body" type="RID" /> <description> Returns the physics layer or layers a body belongs to. </description> </method> <method name="body_get_collision_mask" qualifiers="const"> - <return type="int"> - </return> - <argument index="0" name="body" type="RID"> - </argument> + <return type="int" /> + <argument index="0" name="body" type="RID" /> <description> Returns the physics layer or layers a body can collide with. - </description> </method> <method name="body_get_direct_state"> - <return type="PhysicsDirectBodyState3D"> - </return> - <argument index="0" name="body" type="RID"> - </argument> + <return type="PhysicsDirectBodyState3D" /> + <argument index="0" name="body" type="RID" /> <description> Returns the [PhysicsDirectBodyState3D] of the body. </description> </method> <method name="body_get_max_contacts_reported" qualifiers="const"> - <return type="int"> - </return> - <argument index="0" name="body" type="RID"> - </argument> + <return type="int" /> + <argument index="0" name="body" type="RID" /> <description> Returns the maximum contacts that can be reported. See [method body_set_max_contacts_reported]. </description> </method> <method name="body_get_mode" qualifiers="const"> - <return type="int" enum="PhysicsServer3D.BodyMode"> - </return> - <argument index="0" name="body" type="RID"> - </argument> + <return type="int" enum="PhysicsServer3D.BodyMode" /> + <argument index="0" name="body" type="RID" /> <description> Returns the body mode. </description> </method> <method name="body_get_object_instance_id" qualifiers="const"> - <return type="int"> - </return> - <argument index="0" name="body" type="RID"> - </argument> + <return type="int" /> + <argument index="0" name="body" type="RID" /> <description> Gets the instance ID of the object the area is assigned to. </description> </method> <method name="body_get_param" qualifiers="const"> - <return type="float"> - </return> - <argument index="0" name="body" type="RID"> - </argument> - <argument index="1" name="param" type="int" enum="PhysicsServer3D.BodyParameter"> - </argument> + <return type="float" /> + <argument index="0" name="body" type="RID" /> + <argument index="1" name="param" type="int" enum="PhysicsServer3D.BodyParameter" /> <description> Returns the value of a body parameter. A list of available parameters is on the [enum BodyParameter] constants. </description> </method> <method name="body_get_shape" qualifiers="const"> - <return type="RID"> - </return> - <argument index="0" name="body" type="RID"> - </argument> - <argument index="1" name="shape_idx" type="int"> - </argument> + <return type="RID" /> + <argument index="0" name="body" type="RID" /> + <argument index="1" name="shape_idx" type="int" /> <description> Returns the [RID] of the nth shape of a body. </description> </method> <method name="body_get_shape_count" qualifiers="const"> - <return type="int"> - </return> - <argument index="0" name="body" type="RID"> - </argument> + <return type="int" /> + <argument index="0" name="body" type="RID" /> <description> Returns the number of shapes assigned to a body. </description> </method> <method name="body_get_shape_transform" qualifiers="const"> - <return type="Transform3D"> - </return> - <argument index="0" name="body" type="RID"> - </argument> - <argument index="1" name="shape_idx" type="int"> - </argument> + <return type="Transform3D" /> + <argument index="0" name="body" type="RID" /> + <argument index="1" name="shape_idx" type="int" /> <description> Returns the transform matrix of a body shape. </description> </method> <method name="body_get_space" qualifiers="const"> - <return type="RID"> - </return> - <argument index="0" name="body" type="RID"> - </argument> + <return type="RID" /> + <argument index="0" name="body" type="RID" /> <description> Returns the [RID] of the space assigned to a body. </description> </method> <method name="body_get_state" qualifiers="const"> - <return type="Variant"> - </return> - <argument index="0" name="body" type="RID"> - </argument> - <argument index="1" name="state" type="int" enum="PhysicsServer3D.BodyState"> - </argument> + <return type="Variant" /> + <argument index="0" name="body" type="RID" /> + <argument index="1" name="state" type="int" enum="PhysicsServer3D.BodyState" /> <description> Returns a body state. </description> </method> <method name="body_is_axis_locked" qualifiers="const"> - <return type="bool"> - </return> - <argument index="0" name="body" type="RID"> - </argument> - <argument index="1" name="axis" type="int" enum="PhysicsServer3D.BodyAxis"> - </argument> + <return type="bool" /> + <argument index="0" name="body" type="RID" /> + <argument index="1" name="axis" type="int" enum="PhysicsServer3D.BodyAxis" /> <description> </description> </method> <method name="body_is_continuous_collision_detection_enabled" qualifiers="const"> - <return type="bool"> - </return> - <argument index="0" name="body" type="RID"> - </argument> + <return type="bool" /> + <argument index="0" name="body" type="RID" /> <description> If [code]true[/code], the continuous collision detection mode is enabled. </description> </method> <method name="body_is_omitting_force_integration" qualifiers="const"> - <return type="bool"> - </return> - <argument index="0" name="body" type="RID"> - </argument> + <return type="bool" /> + <argument index="0" name="body" type="RID" /> <description> Returns whether a body uses a callback function to calculate its own physics (see [method body_set_force_integration_callback]). </description> </method> <method name="body_remove_collision_exception"> - <return type="void"> - </return> - <argument index="0" name="body" type="RID"> - </argument> - <argument index="1" name="excepted_body" type="RID"> - </argument> + <return type="void" /> + <argument index="0" name="body" type="RID" /> + <argument index="1" name="excepted_body" type="RID" /> <description> Removes a body from the list of bodies exempt from collisions. Continuous collision detection tries to predict where a moving body will collide, instead of moving it and correcting its movement if it collided. </description> </method> <method name="body_remove_shape"> - <return type="void"> - </return> - <argument index="0" name="body" type="RID"> - </argument> - <argument index="1" name="shape_idx" type="int"> - </argument> + <return type="void" /> + <argument index="0" name="body" type="RID" /> + <argument index="1" name="shape_idx" type="int" /> <description> Removes a shape from a body. The shape is not deleted, so it can be reused afterwards. </description> </method> <method name="body_set_axis_lock"> - <return type="void"> - </return> - <argument index="0" name="body" type="RID"> - </argument> - <argument index="1" name="axis" type="int" enum="PhysicsServer3D.BodyAxis"> - </argument> - <argument index="2" name="lock" type="bool"> - </argument> + <return type="void" /> + <argument index="0" name="body" type="RID" /> + <argument index="1" name="axis" type="int" enum="PhysicsServer3D.BodyAxis" /> + <argument index="2" name="lock" type="bool" /> <description> </description> </method> <method name="body_set_axis_velocity"> - <return type="void"> - </return> - <argument index="0" name="body" type="RID"> - </argument> - <argument index="1" name="axis_velocity" type="Vector3"> - </argument> + <return type="void" /> + <argument index="0" name="body" type="RID" /> + <argument index="1" name="axis_velocity" type="Vector3" /> <description> Sets an axis velocity. The velocity in the given vector axis will be set as the given vector length. This is useful for jumping behavior. </description> </method> <method name="body_set_collision_layer"> - <return type="void"> - </return> - <argument index="0" name="body" type="RID"> - </argument> - <argument index="1" name="layer" type="int"> - </argument> + <return type="void" /> + <argument index="0" name="body" type="RID" /> + <argument index="1" name="layer" type="int" /> <description> Sets the physics layer or layers a body belongs to. </description> </method> <method name="body_set_collision_mask"> - <return type="void"> - </return> - <argument index="0" name="body" type="RID"> - </argument> - <argument index="1" name="mask" type="int"> - </argument> + <return type="void" /> + <argument index="0" name="body" type="RID" /> + <argument index="1" name="mask" type="int" /> <description> Sets the physics layer or layers a body can collide with. </description> </method> <method name="body_set_enable_continuous_collision_detection"> - <return type="void"> - </return> - <argument index="0" name="body" type="RID"> - </argument> - <argument index="1" name="enable" type="bool"> - </argument> + <return type="void" /> + <argument index="0" name="body" type="RID" /> + <argument index="1" name="enable" type="bool" /> <description> If [code]true[/code], the continuous collision detection mode is enabled. Continuous collision detection tries to predict where a moving body will collide, instead of moving it and correcting its movement if it collided. </description> </method> <method name="body_set_force_integration_callback"> - <return type="void"> - </return> - <argument index="0" name="body" type="RID"> - </argument> - <argument index="1" name="callable" type="Callable"> - </argument> - <argument index="2" name="userdata" type="Variant" default="null"> - </argument> + <return type="void" /> + <argument index="0" name="body" type="RID" /> + <argument index="1" name="callable" type="Callable" /> + <argument index="2" name="userdata" type="Variant" default="null" /> <description> Sets the function used to calculate physics for an object, if that object allows it (see [method body_set_omit_force_integration]). </description> </method> <method name="body_set_max_contacts_reported"> - <return type="void"> - </return> - <argument index="0" name="body" type="RID"> - </argument> - <argument index="1" name="amount" type="int"> - </argument> + <return type="void" /> + <argument index="0" name="body" type="RID" /> + <argument index="1" name="amount" type="int" /> <description> Sets the maximum contacts to report. Bodies can keep a log of the contacts with other bodies, this is enabled by setting the maximum amount of contacts reported to a number greater than 0. </description> </method> <method name="body_set_mode"> - <return type="void"> - </return> - <argument index="0" name="body" type="RID"> - </argument> - <argument index="1" name="mode" type="int" enum="PhysicsServer3D.BodyMode"> - </argument> + <return type="void" /> + <argument index="0" name="body" type="RID" /> + <argument index="1" name="mode" type="int" enum="PhysicsServer3D.BodyMode" /> <description> Sets the body mode, from one of the [enum BodyMode] constants. </description> </method> <method name="body_set_omit_force_integration"> - <return type="void"> - </return> - <argument index="0" name="body" type="RID"> - </argument> - <argument index="1" name="enable" type="bool"> - </argument> + <return type="void" /> + <argument index="0" name="body" type="RID" /> + <argument index="1" name="enable" type="bool" /> <description> Sets whether a body uses a callback function to calculate its own physics (see [method body_set_force_integration_callback]). </description> </method> <method name="body_set_param"> - <return type="void"> - </return> - <argument index="0" name="body" type="RID"> - </argument> - <argument index="1" name="param" type="int" enum="PhysicsServer3D.BodyParameter"> - </argument> - <argument index="2" name="value" type="float"> - </argument> + <return type="void" /> + <argument index="0" name="body" type="RID" /> + <argument index="1" name="param" type="int" enum="PhysicsServer3D.BodyParameter" /> + <argument index="2" name="value" type="float" /> <description> Sets a body parameter. A list of available parameters is on the [enum BodyParameter] constants. </description> </method> <method name="body_set_ray_pickable"> - <return type="void"> - </return> - <argument index="0" name="body" type="RID"> - </argument> - <argument index="1" name="enable" type="bool"> - </argument> + <return type="void" /> + <argument index="0" name="body" type="RID" /> + <argument index="1" name="enable" type="bool" /> <description> Sets the body pickable with rays if [code]enabled[/code] is set. </description> </method> <method name="body_set_shape"> - <return type="void"> - </return> - <argument index="0" name="body" type="RID"> - </argument> - <argument index="1" name="shape_idx" type="int"> - </argument> - <argument index="2" name="shape" type="RID"> - </argument> + <return type="void" /> + <argument index="0" name="body" type="RID" /> + <argument index="1" name="shape_idx" type="int" /> + <argument index="2" name="shape" type="RID" /> <description> Substitutes a given body shape by another. The old shape is selected by its index, the new one by its [RID]. </description> </method> <method name="body_set_shape_disabled"> - <return type="void"> - </return> - <argument index="0" name="body" type="RID"> - </argument> - <argument index="1" name="shape_idx" type="int"> - </argument> - <argument index="2" name="disabled" type="bool"> - </argument> + <return type="void" /> + <argument index="0" name="body" type="RID" /> + <argument index="1" name="shape_idx" type="int" /> + <argument index="2" name="disabled" type="bool" /> <description> </description> </method> <method name="body_set_shape_transform"> - <return type="void"> - </return> - <argument index="0" name="body" type="RID"> - </argument> - <argument index="1" name="shape_idx" type="int"> - </argument> - <argument index="2" name="transform" type="Transform3D"> - </argument> + <return type="void" /> + <argument index="0" name="body" type="RID" /> + <argument index="1" name="shape_idx" type="int" /> + <argument index="2" name="transform" type="Transform3D" /> <description> Sets the transform matrix for a body shape. </description> </method> <method name="body_set_space"> - <return type="void"> - </return> - <argument index="0" name="body" type="RID"> - </argument> - <argument index="1" name="space" type="RID"> - </argument> + <return type="void" /> + <argument index="0" name="body" type="RID" /> + <argument index="1" name="space" type="RID" /> <description> Assigns a space to the body (see [method space_create]). </description> </method> <method name="body_set_state"> - <return type="void"> - </return> - <argument index="0" name="body" type="RID"> - </argument> - <argument index="1" name="state" type="int" enum="PhysicsServer3D.BodyState"> - </argument> - <argument index="2" name="value" type="Variant"> - </argument> + <return type="void" /> + <argument index="0" name="body" type="RID" /> + <argument index="1" name="state" type="int" enum="PhysicsServer3D.BodyState" /> + <argument index="2" name="value" type="Variant" /> <description> Sets a body state (see [enum BodyState] constants). </description> </method> <method name="body_test_motion"> - <return type="bool"> - </return> - <argument index="0" name="body" type="RID"> - </argument> - <argument index="1" name="from" type="Transform3D"> - </argument> - <argument index="2" name="motion" type="Vector3"> - </argument> - <argument index="3" name="infinite_inertia" type="bool"> - </argument> - <argument index="4" name="margin" type="float" default="0.001"> - </argument> - <argument index="5" name="result" type="PhysicsTestMotionResult3D" default="null"> - </argument> + <return type="bool" /> + <argument index="0" name="body" type="RID" /> + <argument index="1" name="from" type="Transform3D" /> + <argument index="2" name="motion" type="Vector3" /> + <argument index="3" name="infinite_inertia" type="bool" /> + <argument index="4" name="margin" type="float" default="0.001" /> + <argument index="5" name="result" type="PhysicsTestMotionResult3D" default="null" /> <description> Returns [code]true[/code] if a collision would result from moving in the given direction from a given point in space. Margin increases the size of the shapes involved in the collision detection. [PhysicsTestMotionResult3D] can be passed to return additional information in. </description> </method> <method name="box_shape_create"> - <return type="RID"> - </return> + <return type="RID" /> <description> </description> </method> <method name="capsule_shape_create"> - <return type="RID"> - </return> + <return type="RID" /> <description> </description> </method> <method name="concave_polygon_shape_create"> - <return type="RID"> - </return> + <return type="RID" /> <description> </description> </method> <method name="cone_twist_joint_get_param" qualifiers="const"> - <return type="float"> - </return> - <argument index="0" name="joint" type="RID"> - </argument> - <argument index="1" name="param" type="int" enum="PhysicsServer3D.ConeTwistJointParam"> - </argument> + <return type="float" /> + <argument index="0" name="joint" type="RID" /> + <argument index="1" name="param" type="int" enum="PhysicsServer3D.ConeTwistJointParam" /> <description> Gets a cone_twist_joint parameter (see [enum ConeTwistJointParam] constants). </description> </method> <method name="cone_twist_joint_set_param"> - <return type="void"> - </return> - <argument index="0" name="joint" type="RID"> - </argument> - <argument index="1" name="param" type="int" enum="PhysicsServer3D.ConeTwistJointParam"> - </argument> - <argument index="2" name="value" type="float"> - </argument> + <return type="void" /> + <argument index="0" name="joint" type="RID" /> + <argument index="1" name="param" type="int" enum="PhysicsServer3D.ConeTwistJointParam" /> + <argument index="2" name="value" type="float" /> <description> Sets a cone_twist_joint parameter (see [enum ConeTwistJointParam] constants). </description> </method> <method name="convex_polygon_shape_create"> - <return type="RID"> - </return> + <return type="RID" /> <description> </description> </method> <method name="custom_shape_create"> - <return type="RID"> - </return> + <return type="RID" /> <description> </description> </method> <method name="cylinder_shape_create"> - <return type="RID"> - </return> + <return type="RID" /> <description> </description> </method> <method name="free_rid"> - <return type="void"> - </return> - <argument index="0" name="rid" type="RID"> - </argument> + <return type="void" /> + <argument index="0" name="rid" type="RID" /> <description> Destroys any of the objects created by PhysicsServer3D. If the [RID] passed is not one of the objects that can be created by PhysicsServer3D, an error will be sent to the console. </description> </method> <method name="generic_6dof_joint_get_flag" qualifiers="const"> - <return type="bool"> - </return> - <argument index="0" name="joint" type="RID"> - </argument> - <argument index="1" name="axis" type="int" enum="Vector3.Axis"> - </argument> - <argument index="2" name="flag" type="int" enum="PhysicsServer3D.G6DOFJointAxisFlag"> - </argument> + <return type="bool" /> + <argument index="0" name="joint" type="RID" /> + <argument index="1" name="axis" type="int" enum="Vector3.Axis" /> + <argument index="2" name="flag" type="int" enum="PhysicsServer3D.G6DOFJointAxisFlag" /> <description> Gets a generic_6_DOF_joint flag (see [enum G6DOFJointAxisFlag] constants). </description> </method> <method name="generic_6dof_joint_get_param" qualifiers="const"> - <return type="float"> - </return> - <argument index="0" name="joint" type="RID"> - </argument> - <argument index="1" name="axis" type="int" enum="Vector3.Axis"> - </argument> - <argument index="2" name="param" type="int" enum="PhysicsServer3D.G6DOFJointAxisParam"> - </argument> + <return type="float" /> + <argument index="0" name="joint" type="RID" /> + <argument index="1" name="axis" type="int" enum="Vector3.Axis" /> + <argument index="2" name="param" type="int" enum="PhysicsServer3D.G6DOFJointAxisParam" /> <description> Gets a generic_6_DOF_joint parameter (see [enum G6DOFJointAxisParam] constants). </description> </method> <method name="generic_6dof_joint_set_flag"> - <return type="void"> - </return> - <argument index="0" name="joint" type="RID"> - </argument> - <argument index="1" name="axis" type="int" enum="Vector3.Axis"> - </argument> - <argument index="2" name="flag" type="int" enum="PhysicsServer3D.G6DOFJointAxisFlag"> - </argument> - <argument index="3" name="enable" type="bool"> - </argument> + <return type="void" /> + <argument index="0" name="joint" type="RID" /> + <argument index="1" name="axis" type="int" enum="Vector3.Axis" /> + <argument index="2" name="flag" type="int" enum="PhysicsServer3D.G6DOFJointAxisFlag" /> + <argument index="3" name="enable" type="bool" /> <description> Sets a generic_6_DOF_joint flag (see [enum G6DOFJointAxisFlag] constants). </description> </method> <method name="generic_6dof_joint_set_param"> - <return type="void"> - </return> - <argument index="0" name="joint" type="RID"> - </argument> - <argument index="1" name="axis" type="int" enum="Vector3.Axis"> - </argument> - <argument index="2" name="param" type="int" enum="PhysicsServer3D.G6DOFJointAxisParam"> - </argument> - <argument index="3" name="value" type="float"> - </argument> + <return type="void" /> + <argument index="0" name="joint" type="RID" /> + <argument index="1" name="axis" type="int" enum="Vector3.Axis" /> + <argument index="2" name="param" type="int" enum="PhysicsServer3D.G6DOFJointAxisParam" /> + <argument index="3" name="value" type="float" /> <description> Sets a generic_6_DOF_joint parameter (see [enum G6DOFJointAxisParam] constants). </description> </method> <method name="get_process_info"> - <return type="int"> - </return> - <argument index="0" name="process_info" type="int" enum="PhysicsServer3D.ProcessInfo"> - </argument> + <return type="int" /> + <argument index="0" name="process_info" type="int" enum="PhysicsServer3D.ProcessInfo" /> <description> Returns an Info defined by the [enum ProcessInfo] input given. </description> </method> <method name="heightmap_shape_create"> - <return type="RID"> - </return> + <return type="RID" /> <description> </description> </method> <method name="hinge_joint_get_flag" qualifiers="const"> - <return type="bool"> - </return> - <argument index="0" name="joint" type="RID"> - </argument> - <argument index="1" name="flag" type="int" enum="PhysicsServer3D.HingeJointFlag"> - </argument> + <return type="bool" /> + <argument index="0" name="joint" type="RID" /> + <argument index="1" name="flag" type="int" enum="PhysicsServer3D.HingeJointFlag" /> <description> Gets a hinge_joint flag (see [enum HingeJointFlag] constants). </description> </method> <method name="hinge_joint_get_param" qualifiers="const"> - <return type="float"> - </return> - <argument index="0" name="joint" type="RID"> - </argument> - <argument index="1" name="param" type="int" enum="PhysicsServer3D.HingeJointParam"> - </argument> + <return type="float" /> + <argument index="0" name="joint" type="RID" /> + <argument index="1" name="param" type="int" enum="PhysicsServer3D.HingeJointParam" /> <description> Gets a hinge_joint parameter (see [enum HingeJointParam]). </description> </method> <method name="hinge_joint_set_flag"> - <return type="void"> - </return> - <argument index="0" name="joint" type="RID"> - </argument> - <argument index="1" name="flag" type="int" enum="PhysicsServer3D.HingeJointFlag"> - </argument> - <argument index="2" name="enabled" type="bool"> - </argument> + <return type="void" /> + <argument index="0" name="joint" type="RID" /> + <argument index="1" name="flag" type="int" enum="PhysicsServer3D.HingeJointFlag" /> + <argument index="2" name="enabled" type="bool" /> <description> Sets a hinge_joint flag (see [enum HingeJointFlag] constants). </description> </method> <method name="hinge_joint_set_param"> - <return type="void"> - </return> - <argument index="0" name="joint" type="RID"> - </argument> - <argument index="1" name="param" type="int" enum="PhysicsServer3D.HingeJointParam"> - </argument> - <argument index="2" name="value" type="float"> - </argument> + <return type="void" /> + <argument index="0" name="joint" type="RID" /> + <argument index="1" name="param" type="int" enum="PhysicsServer3D.HingeJointParam" /> + <argument index="2" name="value" type="float" /> <description> Sets a hinge_joint parameter (see [enum HingeJointParam] constants). </description> </method> <method name="joint_clear"> - <return type="void"> - </return> - <argument index="0" name="joint" type="RID"> - </argument> + <return type="void" /> + <argument index="0" name="joint" type="RID" /> <description> </description> </method> <method name="joint_create"> - <return type="RID"> - </return> + <return type="RID" /> <description> </description> </method> <method name="joint_get_solver_priority" qualifiers="const"> - <return type="int"> - </return> - <argument index="0" name="joint" type="RID"> - </argument> + <return type="int" /> + <argument index="0" name="joint" type="RID" /> <description> Gets the priority value of the Joint3D. </description> </method> <method name="joint_get_type" qualifiers="const"> - <return type="int" enum="PhysicsServer3D.JointType"> - </return> - <argument index="0" name="joint" type="RID"> - </argument> + <return type="int" enum="PhysicsServer3D.JointType" /> + <argument index="0" name="joint" type="RID" /> <description> Returns the type of the Joint3D. </description> </method> <method name="joint_make_cone_twist"> - <return type="void"> - </return> - <argument index="0" name="joint" type="RID"> - </argument> - <argument index="1" name="body_A" type="RID"> - </argument> - <argument index="2" name="local_ref_A" type="Transform3D"> - </argument> - <argument index="3" name="body_B" type="RID"> - </argument> - <argument index="4" name="local_ref_B" type="Transform3D"> - </argument> + <return type="void" /> + <argument index="0" name="joint" type="RID" /> + <argument index="1" name="body_A" type="RID" /> + <argument index="2" name="local_ref_A" type="Transform3D" /> + <argument index="3" name="body_B" type="RID" /> + <argument index="4" name="local_ref_B" type="Transform3D" /> <description> </description> </method> <method name="joint_make_generic_6dof"> - <return type="void"> - </return> - <argument index="0" name="joint" type="RID"> - </argument> - <argument index="1" name="body_A" type="RID"> - </argument> - <argument index="2" name="local_ref_A" type="Transform3D"> - </argument> - <argument index="3" name="body_B" type="RID"> - </argument> - <argument index="4" name="local_ref_B" type="Transform3D"> - </argument> + <return type="void" /> + <argument index="0" name="joint" type="RID" /> + <argument index="1" name="body_A" type="RID" /> + <argument index="2" name="local_ref_A" type="Transform3D" /> + <argument index="3" name="body_B" type="RID" /> + <argument index="4" name="local_ref_B" type="Transform3D" /> <description> </description> </method> <method name="joint_make_hinge"> - <return type="void"> - </return> - <argument index="0" name="joint" type="RID"> - </argument> - <argument index="1" name="body_A" type="RID"> - </argument> - <argument index="2" name="hinge_A" type="Transform3D"> - </argument> - <argument index="3" name="body_B" type="RID"> - </argument> - <argument index="4" name="hinge_B" type="Transform3D"> - </argument> + <return type="void" /> + <argument index="0" name="joint" type="RID" /> + <argument index="1" name="body_A" type="RID" /> + <argument index="2" name="hinge_A" type="Transform3D" /> + <argument index="3" name="body_B" type="RID" /> + <argument index="4" name="hinge_B" type="Transform3D" /> <description> </description> </method> <method name="joint_make_pin"> - <return type="void"> - </return> - <argument index="0" name="joint" type="RID"> - </argument> - <argument index="1" name="body_A" type="RID"> - </argument> - <argument index="2" name="local_A" type="Vector3"> - </argument> - <argument index="3" name="body_B" type="RID"> - </argument> - <argument index="4" name="local_B" type="Vector3"> - </argument> + <return type="void" /> + <argument index="0" name="joint" type="RID" /> + <argument index="1" name="body_A" type="RID" /> + <argument index="2" name="local_A" type="Vector3" /> + <argument index="3" name="body_B" type="RID" /> + <argument index="4" name="local_B" type="Vector3" /> <description> </description> </method> <method name="joint_make_slider"> - <return type="void"> - </return> - <argument index="0" name="joint" type="RID"> - </argument> - <argument index="1" name="body_A" type="RID"> - </argument> - <argument index="2" name="local_ref_A" type="Transform3D"> - </argument> - <argument index="3" name="body_B" type="RID"> - </argument> - <argument index="4" name="local_ref_B" type="Transform3D"> - </argument> + <return type="void" /> + <argument index="0" name="joint" type="RID" /> + <argument index="1" name="body_A" type="RID" /> + <argument index="2" name="local_ref_A" type="Transform3D" /> + <argument index="3" name="body_B" type="RID" /> + <argument index="4" name="local_ref_B" type="Transform3D" /> <description> </description> </method> <method name="joint_set_solver_priority"> - <return type="void"> - </return> - <argument index="0" name="joint" type="RID"> - </argument> - <argument index="1" name="priority" type="int"> - </argument> + <return type="void" /> + <argument index="0" name="joint" type="RID" /> + <argument index="1" name="priority" type="int" /> <description> Sets the priority value of the Joint3D. </description> </method> <method name="pin_joint_get_local_a" qualifiers="const"> - <return type="Vector3"> - </return> - <argument index="0" name="joint" type="RID"> - </argument> + <return type="Vector3" /> + <argument index="0" name="joint" type="RID" /> <description> Returns position of the joint in the local space of body a of the joint. </description> </method> <method name="pin_joint_get_local_b" qualifiers="const"> - <return type="Vector3"> - </return> - <argument index="0" name="joint" type="RID"> - </argument> + <return type="Vector3" /> + <argument index="0" name="joint" type="RID" /> <description> Returns position of the joint in the local space of body b of the joint. </description> </method> <method name="pin_joint_get_param" qualifiers="const"> - <return type="float"> - </return> - <argument index="0" name="joint" type="RID"> - </argument> - <argument index="1" name="param" type="int" enum="PhysicsServer3D.PinJointParam"> - </argument> + <return type="float" /> + <argument index="0" name="joint" type="RID" /> + <argument index="1" name="param" type="int" enum="PhysicsServer3D.PinJointParam" /> <description> Gets a pin_joint parameter (see [enum PinJointParam] constants). </description> </method> <method name="pin_joint_set_local_a"> - <return type="void"> - </return> - <argument index="0" name="joint" type="RID"> - </argument> - <argument index="1" name="local_A" type="Vector3"> - </argument> + <return type="void" /> + <argument index="0" name="joint" type="RID" /> + <argument index="1" name="local_A" type="Vector3" /> <description> Sets position of the joint in the local space of body a of the joint. </description> </method> <method name="pin_joint_set_local_b"> - <return type="void"> - </return> - <argument index="0" name="joint" type="RID"> - </argument> - <argument index="1" name="local_B" type="Vector3"> - </argument> + <return type="void" /> + <argument index="0" name="joint" type="RID" /> + <argument index="1" name="local_B" type="Vector3" /> <description> Sets position of the joint in the local space of body b of the joint. </description> </method> <method name="pin_joint_set_param"> - <return type="void"> - </return> - <argument index="0" name="joint" type="RID"> - </argument> - <argument index="1" name="param" type="int" enum="PhysicsServer3D.PinJointParam"> - </argument> - <argument index="2" name="value" type="float"> - </argument> + <return type="void" /> + <argument index="0" name="joint" type="RID" /> + <argument index="1" name="param" type="int" enum="PhysicsServer3D.PinJointParam" /> + <argument index="2" name="value" type="float" /> <description> Sets a pin_joint parameter (see [enum PinJointParam] constants). </description> </method> <method name="plane_shape_create"> - <return type="RID"> - </return> + <return type="RID" /> <description> </description> </method> <method name="ray_shape_create"> - <return type="RID"> - </return> + <return type="RID" /> <description> </description> </method> <method name="set_active"> - <return type="void"> - </return> - <argument index="0" name="active" type="bool"> - </argument> + <return type="void" /> + <argument index="0" name="active" type="bool" /> <description> Activates or deactivates the 3D physics engine. </description> </method> + <method name="set_collision_iterations"> + <return type="void" /> + <argument index="0" name="iterations" type="int" /> + <description> + Sets the amount of iterations for calculating velocities of colliding bodies. The greater the amount of iterations, the more accurate the collisions will be. However, a greater amount of iterations requires more CPU power, which can decrease performance. The default value is [code]8[/code]. + [b]Note:[/b] Only has an effect when using the default GodotPhysics engine, not the Bullet physics engine. + </description> + </method> <method name="shape_get_data" qualifiers="const"> - <return type="Variant"> - </return> - <argument index="0" name="shape" type="RID"> - </argument> + <return type="Variant" /> + <argument index="0" name="shape" type="RID" /> <description> Returns the shape data. </description> </method> <method name="shape_get_type" qualifiers="const"> - <return type="int" enum="PhysicsServer3D.ShapeType"> - </return> - <argument index="0" name="shape" type="RID"> - </argument> + <return type="int" enum="PhysicsServer3D.ShapeType" /> + <argument index="0" name="shape" type="RID" /> <description> Returns the type of shape (see [enum ShapeType] constants). </description> </method> <method name="shape_set_data"> - <return type="void"> - </return> - <argument index="0" name="shape" type="RID"> - </argument> - <argument index="1" name="data" type="Variant"> - </argument> + <return type="void" /> + <argument index="0" name="shape" type="RID" /> + <argument index="1" name="data" type="Variant" /> <description> Sets the shape data that defines its shape and size. The data to be passed depends on the kind of shape created [method shape_get_type]. </description> </method> <method name="slider_joint_get_param" qualifiers="const"> - <return type="float"> - </return> - <argument index="0" name="joint" type="RID"> - </argument> - <argument index="1" name="param" type="int" enum="PhysicsServer3D.SliderJointParam"> - </argument> + <return type="float" /> + <argument index="0" name="joint" type="RID" /> + <argument index="1" name="param" type="int" enum="PhysicsServer3D.SliderJointParam" /> <description> Gets a slider_joint parameter (see [enum SliderJointParam] constants). </description> </method> <method name="slider_joint_set_param"> - <return type="void"> - </return> - <argument index="0" name="joint" type="RID"> - </argument> - <argument index="1" name="param" type="int" enum="PhysicsServer3D.SliderJointParam"> - </argument> - <argument index="2" name="value" type="float"> - </argument> + <return type="void" /> + <argument index="0" name="joint" type="RID" /> + <argument index="1" name="param" type="int" enum="PhysicsServer3D.SliderJointParam" /> + <argument index="2" name="value" type="float" /> <description> Gets a slider_joint parameter (see [enum SliderJointParam] constants). </description> </method> <method name="soft_body_get_bounds" qualifiers="const"> - <return type="AABB"> - </return> - <argument index="0" name="body" type="RID"> - </argument> + <return type="AABB" /> + <argument index="0" name="body" type="RID" /> <description> </description> </method> <method name="space_create"> - <return type="RID"> - </return> + <return type="RID" /> <description> Creates a space. A space is a collection of parameters for the physics engine that can be assigned to an area or a body. It can be assigned to an area with [method area_set_space], or to a body with [method body_set_space]. </description> </method> <method name="space_get_direct_state"> - <return type="PhysicsDirectSpaceState3D"> - </return> - <argument index="0" name="space" type="RID"> - </argument> + <return type="PhysicsDirectSpaceState3D" /> + <argument index="0" name="space" type="RID" /> <description> Returns the state of a space, a [PhysicsDirectSpaceState3D]. This object can be used to make collision/intersection queries. </description> </method> <method name="space_get_param" qualifiers="const"> - <return type="float"> - </return> - <argument index="0" name="space" type="RID"> - </argument> - <argument index="1" name="param" type="int" enum="PhysicsServer3D.SpaceParameter"> - </argument> + <return type="float" /> + <argument index="0" name="space" type="RID" /> + <argument index="1" name="param" type="int" enum="PhysicsServer3D.SpaceParameter" /> <description> Returns the value of a space parameter. </description> </method> <method name="space_is_active" qualifiers="const"> - <return type="bool"> - </return> - <argument index="0" name="space" type="RID"> - </argument> + <return type="bool" /> + <argument index="0" name="space" type="RID" /> <description> Returns whether the space is active. </description> </method> <method name="space_set_active"> - <return type="void"> - </return> - <argument index="0" name="space" type="RID"> - </argument> - <argument index="1" name="active" type="bool"> - </argument> + <return type="void" /> + <argument index="0" name="space" type="RID" /> + <argument index="1" name="active" type="bool" /> <description> Marks a space as active. It will not have an effect, unless it is assigned to an area or body. </description> </method> <method name="space_set_param"> - <return type="void"> - </return> - <argument index="0" name="space" type="RID"> - </argument> - <argument index="1" name="param" type="int" enum="PhysicsServer3D.SpaceParameter"> - </argument> - <argument index="2" name="value" type="float"> - </argument> + <return type="void" /> + <argument index="0" name="space" type="RID" /> + <argument index="1" name="param" type="int" enum="PhysicsServer3D.SpaceParameter" /> + <argument index="2" name="value" type="float" /> <description> Sets the value for a space parameter. A list of available parameters is on the [enum SpaceParameter] constants. </description> </method> <method name="sphere_shape_create"> - <return type="RID"> - </return> + <return type="RID" /> <description> </description> </method> diff --git a/doc/classes/PinJoint3D.xml b/doc/classes/PinJoint3D.xml index 37a85e497f..84b60c0d8c 100644 --- a/doc/classes/PinJoint3D.xml +++ b/doc/classes/PinJoint3D.xml @@ -10,21 +10,16 @@ </tutorials> <methods> <method name="get_param" qualifiers="const"> - <return type="float"> - </return> - <argument index="0" name="param" type="int" enum="PinJoint3D.Param"> - </argument> + <return type="float" /> + <argument index="0" name="param" type="int" enum="PinJoint3D.Param" /> <description> Returns the value of the specified parameter. </description> </method> <method name="set_param"> - <return type="void"> - </return> - <argument index="0" name="param" type="int" enum="PinJoint3D.Param"> - </argument> - <argument index="1" name="value" type="float"> - </argument> + <return type="void" /> + <argument index="0" name="param" type="int" enum="PinJoint3D.Param" /> + <argument index="1" name="value" type="float" /> <description> Sets the value of the specified parameter. </description> diff --git a/doc/classes/Plane.xml b/doc/classes/Plane.xml index 12869061c4..c243c3ad15 100644 --- a/doc/classes/Plane.xml +++ b/doc/classes/Plane.xml @@ -11,189 +11,143 @@ </tutorials> <methods> <method name="Plane" qualifiers="constructor"> - <return type="Plane"> - </return> + <return type="Plane" /> <description> Constructs a default-initialized [Plane] with all components set to [code]0[/code]. </description> </method> <method name="Plane" qualifiers="constructor"> - <return type="Plane"> - </return> - <argument index="0" name="from" type="Plane"> - </argument> + <return type="Plane" /> + <argument index="0" name="from" type="Plane" /> <description> Constructs a [Plane] as a copy of the given [Plane]. </description> </method> <method name="Plane" qualifiers="constructor"> - <return type="Plane"> - </return> - <argument index="0" name="a" type="float"> - </argument> - <argument index="1" name="b" type="float"> - </argument> - <argument index="2" name="c" type="float"> - </argument> - <argument index="3" name="d" type="float"> - </argument> + <return type="Plane" /> + <argument index="0" name="a" type="float" /> + <argument index="1" name="b" type="float" /> + <argument index="2" name="c" type="float" /> + <argument index="3" name="d" type="float" /> <description> Creates a plane from the four parameters. The three components of the resulting plane's [member normal] are [code]a[/code], [code]b[/code] and [code]c[/code], and the plane has a distance of [code]d[/code] from the origin. </description> </method> <method name="Plane" qualifiers="constructor"> - <return type="Plane"> - </return> - <argument index="0" name="normal" type="Vector3"> - </argument> - <argument index="1" name="d" type="float"> - </argument> + <return type="Plane" /> + <argument index="0" name="normal" type="Vector3" /> + <argument index="1" name="d" type="float" /> <description> Creates a plane from the normal and the plane's distance to the origin. </description> </method> <method name="Plane" qualifiers="constructor"> - <return type="Plane"> - </return> - <argument index="0" name="point" type="Vector3"> - </argument> - <argument index="1" name="normal" type="Vector3"> - </argument> + <return type="Plane" /> + <argument index="0" name="point" type="Vector3" /> + <argument index="1" name="normal" type="Vector3" /> <description> Creates a plane from the given position and a plane normal. </description> </method> <method name="Plane" qualifiers="constructor"> - <return type="Plane"> - </return> - <argument index="0" name="point1" type="Vector3"> - </argument> - <argument index="1" name="point2" type="Vector3"> - </argument> - <argument index="2" name="point3" type="Vector3"> - </argument> + <return type="Plane" /> + <argument index="0" name="point1" type="Vector3" /> + <argument index="1" name="point2" type="Vector3" /> + <argument index="2" name="point3" type="Vector3" /> <description> Creates a plane from the three points, given in clockwise order. </description> </method> <method name="center" qualifiers="const"> - <return type="Vector3"> - </return> + <return type="Vector3" /> <description> Returns the center of the plane. </description> </method> <method name="distance_to" qualifiers="const"> - <return type="float"> - </return> - <argument index="0" name="point" type="Vector3"> - </argument> + <return type="float" /> + <argument index="0" name="point" type="Vector3" /> <description> Returns the shortest distance from the plane to the position [code]point[/code]. </description> </method> <method name="has_point" qualifiers="const"> - <return type="bool"> - </return> - <argument index="0" name="point" type="Vector3"> - </argument> - <argument index="1" name="epsilon" type="float" default="1e-05"> - </argument> + <return type="bool" /> + <argument index="0" name="point" type="Vector3" /> + <argument index="1" name="epsilon" type="float" default="1e-05" /> <description> Returns [code]true[/code] if [code]point[/code] is inside the plane. Comparison uses a custom minimum [code]epsilon[/code] threshold. </description> </method> <method name="intersect_3" qualifiers="const"> - <return type="Variant"> - </return> - <argument index="0" name="b" type="Plane"> - </argument> - <argument index="1" name="c" type="Plane"> - </argument> + <return type="Variant" /> + <argument index="0" name="b" type="Plane" /> + <argument index="1" name="c" type="Plane" /> <description> Returns the intersection point of the three planes [code]b[/code], [code]c[/code] and this plane. If no intersection is found, [code]null[/code] is returned. </description> </method> <method name="intersects_ray" qualifiers="const"> - <return type="Variant"> - </return> - <argument index="0" name="from" type="Vector3"> - </argument> - <argument index="1" name="dir" type="Vector3"> - </argument> + <return type="Variant" /> + <argument index="0" name="from" type="Vector3" /> + <argument index="1" name="dir" type="Vector3" /> <description> Returns the intersection point of a ray consisting of the position [code]from[/code] and the direction normal [code]dir[/code] with this plane. If no intersection is found, [code]null[/code] is returned. </description> </method> <method name="intersects_segment" qualifiers="const"> - <return type="Variant"> - </return> - <argument index="0" name="from" type="Vector3"> - </argument> - <argument index="1" name="to" type="Vector3"> - </argument> + <return type="Variant" /> + <argument index="0" name="from" type="Vector3" /> + <argument index="1" name="to" type="Vector3" /> <description> Returns the intersection point of a segment from position [code]begin[/code] to position [code]end[/code] with this plane. If no intersection is found, [code]null[/code] is returned. </description> </method> <method name="is_equal_approx" qualifiers="const"> - <return type="bool"> - </return> - <argument index="0" name="to_plane" type="Plane"> - </argument> + <return type="bool" /> + <argument index="0" name="to_plane" type="Plane" /> <description> Returns [code]true[/code] if this plane and [code]plane[/code] are approximately equal, by running [method @GlobalScope.is_equal_approx] on each component. </description> </method> <method name="is_point_over" qualifiers="const"> - <return type="bool"> - </return> - <argument index="0" name="plane" type="Vector3"> - </argument> + <return type="bool" /> + <argument index="0" name="plane" type="Vector3" /> <description> Returns [code]true[/code] if [code]point[/code] is located above the plane. </description> </method> <method name="normalized" qualifiers="const"> - <return type="Plane"> - </return> + <return type="Plane" /> <description> Returns a copy of the plane, normalized. </description> </method> <method name="operator !=" qualifiers="operator"> - <return type="bool"> - </return> - <argument index="0" name="right" type="Plane"> - </argument> + <return type="bool" /> + <argument index="0" name="right" type="Plane" /> <description> </description> </method> <method name="operator ==" qualifiers="operator"> - <return type="bool"> - </return> - <argument index="0" name="right" type="Plane"> - </argument> + <return type="bool" /> + <argument index="0" name="right" type="Plane" /> <description> </description> </method> <method name="operator unary+" qualifiers="operator"> - <return type="Plane"> - </return> + <return type="Plane" /> <description> </description> </method> <method name="operator unary-" qualifiers="operator"> - <return type="Plane"> - </return> + <return type="Plane" /> <description> </description> </method> <method name="project" qualifiers="const"> - <return type="Vector3"> - </return> - <argument index="0" name="point" type="Vector3"> - </argument> + <return type="Vector3" /> + <argument index="0" name="point" type="Vector3" /> <description> Returns the orthogonal projection of [code]point[/code] into a point in the plane. </description> diff --git a/doc/classes/Polygon2D.xml b/doc/classes/Polygon2D.xml index 5a53063148..23106cddf7 100644 --- a/doc/classes/Polygon2D.xml +++ b/doc/classes/Polygon2D.xml @@ -10,75 +10,58 @@ </tutorials> <methods> <method name="add_bone"> - <return type="void"> - </return> - <argument index="0" name="path" type="NodePath"> - </argument> - <argument index="1" name="weights" type="PackedFloat32Array"> - </argument> + <return type="void" /> + <argument index="0" name="path" type="NodePath" /> + <argument index="1" name="weights" type="PackedFloat32Array" /> <description> Adds a bone with the specified [code]path[/code] and [code]weights[/code]. </description> </method> <method name="clear_bones"> - <return type="void"> - </return> + <return type="void" /> <description> Removes all bones from this [Polygon2D]. </description> </method> <method name="erase_bone"> - <return type="void"> - </return> - <argument index="0" name="index" type="int"> - </argument> + <return type="void" /> + <argument index="0" name="index" type="int" /> <description> Removes the specified bone from this [Polygon2D]. </description> </method> <method name="get_bone_count" qualifiers="const"> - <return type="int"> - </return> + <return type="int" /> <description> Returns the number of bones in this [Polygon2D]. </description> </method> <method name="get_bone_path" qualifiers="const"> - <return type="NodePath"> - </return> - <argument index="0" name="index" type="int"> - </argument> + <return type="NodePath" /> + <argument index="0" name="index" type="int" /> <description> Returns the path to the node associated with the specified bone. </description> </method> <method name="get_bone_weights" qualifiers="const"> - <return type="PackedFloat32Array"> - </return> - <argument index="0" name="index" type="int"> - </argument> + <return type="PackedFloat32Array" /> + <argument index="0" name="index" type="int" /> <description> Returns the height values of the specified bone. </description> </method> <method name="set_bone_path"> - <return type="void"> - </return> - <argument index="0" name="index" type="int"> - </argument> - <argument index="1" name="path" type="NodePath"> - </argument> + <return type="void" /> + <argument index="0" name="index" type="int" /> + <argument index="1" name="path" type="NodePath" /> <description> Sets the path to the node associated with the specified bone. </description> </method> <method name="set_bone_weights"> - <return type="void"> - </return> - <argument index="0" name="index" type="int"> - </argument> - <argument index="1" name="weights" type="PackedFloat32Array"> - </argument> + <return type="void" /> + <argument index="0" name="index" type="int" /> + <argument index="1" name="weights" type="PackedFloat32Array" /> <description> Sets the weight values for the specified bone. </description> diff --git a/doc/classes/PolygonPathFinder.xml b/doc/classes/PolygonPathFinder.xml index 49453d32ac..f77912bafe 100644 --- a/doc/classes/PolygonPathFinder.xml +++ b/doc/classes/PolygonPathFinder.xml @@ -8,72 +8,53 @@ </tutorials> <methods> <method name="find_path"> - <return type="PackedVector2Array"> - </return> - <argument index="0" name="from" type="Vector2"> - </argument> - <argument index="1" name="to" type="Vector2"> - </argument> + <return type="PackedVector2Array" /> + <argument index="0" name="from" type="Vector2" /> + <argument index="1" name="to" type="Vector2" /> <description> </description> </method> <method name="get_bounds" qualifiers="const"> - <return type="Rect2"> - </return> + <return type="Rect2" /> <description> </description> </method> <method name="get_closest_point" qualifiers="const"> - <return type="Vector2"> - </return> - <argument index="0" name="point" type="Vector2"> - </argument> + <return type="Vector2" /> + <argument index="0" name="point" type="Vector2" /> <description> </description> </method> <method name="get_intersections" qualifiers="const"> - <return type="PackedVector2Array"> - </return> - <argument index="0" name="from" type="Vector2"> - </argument> - <argument index="1" name="to" type="Vector2"> - </argument> + <return type="PackedVector2Array" /> + <argument index="0" name="from" type="Vector2" /> + <argument index="1" name="to" type="Vector2" /> <description> </description> </method> <method name="get_point_penalty" qualifiers="const"> - <return type="float"> - </return> - <argument index="0" name="idx" type="int"> - </argument> + <return type="float" /> + <argument index="0" name="idx" type="int" /> <description> </description> </method> <method name="is_point_inside" qualifiers="const"> - <return type="bool"> - </return> - <argument index="0" name="point" type="Vector2"> - </argument> + <return type="bool" /> + <argument index="0" name="point" type="Vector2" /> <description> </description> </method> <method name="set_point_penalty"> - <return type="void"> - </return> - <argument index="0" name="idx" type="int"> - </argument> - <argument index="1" name="penalty" type="float"> - </argument> + <return type="void" /> + <argument index="0" name="idx" type="int" /> + <argument index="1" name="penalty" type="float" /> <description> </description> </method> <method name="setup"> - <return type="void"> - </return> - <argument index="0" name="points" type="PackedVector2Array"> - </argument> - <argument index="1" name="connections" type="PackedInt32Array"> - </argument> + <return type="void" /> + <argument index="0" name="points" type="PackedVector2Array" /> + <argument index="1" name="connections" type="PackedInt32Array" /> <description> </description> </method> diff --git a/doc/classes/PopupMenu.xml b/doc/classes/PopupMenu.xml index 3489c5435a..a2c8a581cf 100644 --- a/doc/classes/PopupMenu.xml +++ b/doc/classes/PopupMenu.xml @@ -12,14 +12,10 @@ </tutorials> <methods> <method name="add_check_item"> - <return type="void"> - </return> - <argument index="0" name="label" type="String"> - </argument> - <argument index="1" name="id" type="int" default="-1"> - </argument> - <argument index="2" name="accel" type="int" default="0"> - </argument> + <return type="void" /> + <argument index="0" name="label" type="String" /> + <argument index="1" name="id" type="int" default="-1" /> + <argument index="2" name="accel" type="int" default="0" /> <description> Adds a new checkable item with text [code]label[/code]. An [code]id[/code] can optionally be provided, as well as an accelerator ([code]accel[/code]). If no [code]id[/code] is provided, one will be created from the index. If no [code]accel[/code] is provided then the default [code]0[/code] will be assigned to it. See [method get_item_accelerator] for more info on accelerators. @@ -27,14 +23,10 @@ </description> </method> <method name="add_check_shortcut"> - <return type="void"> - </return> - <argument index="0" name="shortcut" type="Shortcut"> - </argument> - <argument index="1" name="id" type="int" default="-1"> - </argument> - <argument index="2" name="global" type="bool" default="false"> - </argument> + <return type="void" /> + <argument index="0" name="shortcut" type="Shortcut" /> + <argument index="1" name="id" type="int" default="-1" /> + <argument index="2" name="global" type="bool" default="false" /> <description> Adds a new checkable item and assigns the specified [Shortcut] to it. Sets the label of the checkbox to the [Shortcut]'s name. An [code]id[/code] can optionally be provided. If no [code]id[/code] is provided, one will be created from the index. @@ -42,16 +34,11 @@ </description> </method> <method name="add_icon_check_item"> - <return type="void"> - </return> - <argument index="0" name="texture" type="Texture2D"> - </argument> - <argument index="1" name="label" type="String"> - </argument> - <argument index="2" name="id" type="int" default="-1"> - </argument> - <argument index="3" name="accel" type="int" default="0"> - </argument> + <return type="void" /> + <argument index="0" name="texture" type="Texture2D" /> + <argument index="1" name="label" type="String" /> + <argument index="2" name="id" type="int" default="-1" /> + <argument index="3" name="accel" type="int" default="0" /> <description> Adds a new checkable item with text [code]label[/code] and icon [code]texture[/code]. An [code]id[/code] can optionally be provided, as well as an accelerator ([code]accel[/code]). If no [code]id[/code] is provided, one will be created from the index. If no [code]accel[/code] is provided then the default [code]0[/code] will be assigned to it. See [method get_item_accelerator] for more info on accelerators. @@ -59,16 +46,11 @@ </description> </method> <method name="add_icon_check_shortcut"> - <return type="void"> - </return> - <argument index="0" name="texture" type="Texture2D"> - </argument> - <argument index="1" name="shortcut" type="Shortcut"> - </argument> - <argument index="2" name="id" type="int" default="-1"> - </argument> - <argument index="3" name="global" type="bool" default="false"> - </argument> + <return type="void" /> + <argument index="0" name="texture" type="Texture2D" /> + <argument index="1" name="shortcut" type="Shortcut" /> + <argument index="2" name="id" type="int" default="-1" /> + <argument index="3" name="global" type="bool" default="false" /> <description> Adds a new checkable item and assigns the specified [Shortcut] and icon [code]texture[/code] to it. Sets the label of the checkbox to the [Shortcut]'s name. An [code]id[/code] can optionally be provided. If no [code]id[/code] is provided, one will be created from the index. @@ -76,94 +58,64 @@ </description> </method> <method name="add_icon_item"> - <return type="void"> - </return> - <argument index="0" name="texture" type="Texture2D"> - </argument> - <argument index="1" name="label" type="String"> - </argument> - <argument index="2" name="id" type="int" default="-1"> - </argument> - <argument index="3" name="accel" type="int" default="0"> - </argument> + <return type="void" /> + <argument index="0" name="texture" type="Texture2D" /> + <argument index="1" name="label" type="String" /> + <argument index="2" name="id" type="int" default="-1" /> + <argument index="3" name="accel" type="int" default="0" /> <description> Adds a new item with text [code]label[/code] and icon [code]texture[/code]. An [code]id[/code] can optionally be provided, as well as an accelerator ([code]accel[/code]). If no [code]id[/code] is provided, one will be created from the index. If no [code]accel[/code] is provided then the default [code]0[/code] will be assigned to it. See [method get_item_accelerator] for more info on accelerators. </description> </method> <method name="add_icon_radio_check_item"> - <return type="void"> - </return> - <argument index="0" name="texture" type="Texture2D"> - </argument> - <argument index="1" name="label" type="String"> - </argument> - <argument index="2" name="id" type="int" default="-1"> - </argument> - <argument index="3" name="accel" type="int" default="0"> - </argument> + <return type="void" /> + <argument index="0" name="texture" type="Texture2D" /> + <argument index="1" name="label" type="String" /> + <argument index="2" name="id" type="int" default="-1" /> + <argument index="3" name="accel" type="int" default="0" /> <description> Same as [method add_icon_check_item], but uses a radio check button. </description> </method> <method name="add_icon_radio_check_shortcut"> - <return type="void"> - </return> - <argument index="0" name="texture" type="Texture2D"> - </argument> - <argument index="1" name="shortcut" type="Shortcut"> - </argument> - <argument index="2" name="id" type="int" default="-1"> - </argument> - <argument index="3" name="global" type="bool" default="false"> - </argument> + <return type="void" /> + <argument index="0" name="texture" type="Texture2D" /> + <argument index="1" name="shortcut" type="Shortcut" /> + <argument index="2" name="id" type="int" default="-1" /> + <argument index="3" name="global" type="bool" default="false" /> <description> Same as [method add_icon_check_shortcut], but uses a radio check button. </description> </method> <method name="add_icon_shortcut"> - <return type="void"> - </return> - <argument index="0" name="texture" type="Texture2D"> - </argument> - <argument index="1" name="shortcut" type="Shortcut"> - </argument> - <argument index="2" name="id" type="int" default="-1"> - </argument> - <argument index="3" name="global" type="bool" default="false"> - </argument> + <return type="void" /> + <argument index="0" name="texture" type="Texture2D" /> + <argument index="1" name="shortcut" type="Shortcut" /> + <argument index="2" name="id" type="int" default="-1" /> + <argument index="3" name="global" type="bool" default="false" /> <description> Adds a new item and assigns the specified [Shortcut] and icon [code]texture[/code] to it. Sets the label of the checkbox to the [Shortcut]'s name. An [code]id[/code] can optionally be provided. If no [code]id[/code] is provided, one will be created from the index. </description> </method> <method name="add_item"> - <return type="void"> - </return> - <argument index="0" name="label" type="String"> - </argument> - <argument index="1" name="id" type="int" default="-1"> - </argument> - <argument index="2" name="accel" type="int" default="0"> - </argument> + <return type="void" /> + <argument index="0" name="label" type="String" /> + <argument index="1" name="id" type="int" default="-1" /> + <argument index="2" name="accel" type="int" default="0" /> <description> Adds a new item with text [code]label[/code]. An [code]id[/code] can optionally be provided, as well as an accelerator ([code]accel[/code]). If no [code]id[/code] is provided, one will be created from the index. If no [code]accel[/code] is provided then the default [code]0[/code] will be assigned to it. See [method get_item_accelerator] for more info on accelerators. </description> </method> <method name="add_multistate_item"> - <return type="void"> - </return> - <argument index="0" name="label" type="String"> - </argument> - <argument index="1" name="max_states" type="int"> - </argument> - <argument index="2" name="default_state" type="int" default="0"> - </argument> - <argument index="3" name="id" type="int" default="-1"> - </argument> - <argument index="4" name="accel" type="int" default="0"> - </argument> + <return type="void" /> + <argument index="0" name="label" type="String" /> + <argument index="1" name="max_states" type="int" /> + <argument index="2" name="default_state" type="int" default="0" /> + <argument index="3" name="id" type="int" default="-1" /> + <argument index="4" name="accel" type="int" default="0" /> <description> Adds a new multistate item with text [code]label[/code]. Contrarily to normal binary items, multistate items can have more than two states, as defined by [code]max_states[/code]. Each press or activate of the item will increase the state by one. The default value is defined by [code]default_state[/code]. @@ -171,14 +123,10 @@ </description> </method> <method name="add_radio_check_item"> - <return type="void"> - </return> - <argument index="0" name="label" type="String"> - </argument> - <argument index="1" name="id" type="int" default="-1"> - </argument> - <argument index="2" name="accel" type="int" default="0"> - </argument> + <return type="void" /> + <argument index="0" name="label" type="String" /> + <argument index="1" name="id" type="int" default="-1" /> + <argument index="2" name="accel" type="int" default="0" /> <description> Adds a new radio check button with text [code]label[/code]. An [code]id[/code] can optionally be provided, as well as an accelerator ([code]accel[/code]). If no [code]id[/code] is provided, one will be created from the index. If no [code]accel[/code] is provided then the default [code]0[/code] will be assigned to it. See [method get_item_accelerator] for more info on accelerators. @@ -186,14 +134,10 @@ </description> </method> <method name="add_radio_check_shortcut"> - <return type="void"> - </return> - <argument index="0" name="shortcut" type="Shortcut"> - </argument> - <argument index="1" name="id" type="int" default="-1"> - </argument> - <argument index="2" name="global" type="bool" default="false"> - </argument> + <return type="void" /> + <argument index="0" name="shortcut" type="Shortcut" /> + <argument index="1" name="id" type="int" default="-1" /> + <argument index="2" name="global" type="bool" default="false" /> <description> Adds a new radio check button and assigns a [Shortcut] to it. Sets the label of the checkbox to the [Shortcut]'s name. An [code]id[/code] can optionally be provided. If no [code]id[/code] is provided, one will be created from the index. @@ -201,469 +145,354 @@ </description> </method> <method name="add_separator"> - <return type="void"> - </return> - <argument index="0" name="label" type="String" default=""""> - </argument> - <argument index="1" name="id" type="int" default="-1"> - </argument> + <return type="void" /> + <argument index="0" name="label" type="String" default="""" /> + <argument index="1" name="id" type="int" default="-1" /> <description> Adds a separator between items. Separators also occupy an index, which you can set by using the [code]id[/code] parameter. A [code]label[/code] can optionally be provided, which will appear at the center of the separator. </description> </method> <method name="add_shortcut"> - <return type="void"> - </return> - <argument index="0" name="shortcut" type="Shortcut"> - </argument> - <argument index="1" name="id" type="int" default="-1"> - </argument> - <argument index="2" name="global" type="bool" default="false"> - </argument> + <return type="void" /> + <argument index="0" name="shortcut" type="Shortcut" /> + <argument index="1" name="id" type="int" default="-1" /> + <argument index="2" name="global" type="bool" default="false" /> <description> Adds a [Shortcut]. An [code]id[/code] can optionally be provided. If no [code]id[/code] is provided, one will be created from the index. </description> </method> <method name="add_submenu_item"> - <return type="void"> - </return> - <argument index="0" name="label" type="String"> - </argument> - <argument index="1" name="submenu" type="String"> - </argument> - <argument index="2" name="id" type="int" default="-1"> - </argument> + <return type="void" /> + <argument index="0" name="label" type="String" /> + <argument index="1" name="submenu" type="String" /> + <argument index="2" name="id" type="int" default="-1" /> <description> Adds an item that will act as a submenu of the parent [PopupMenu] node when clicked. The [code]submenu[/code] argument is the name of the child [PopupMenu] node that will be shown when the item is clicked. An [code]id[/code] can optionally be provided. If no [code]id[/code] is provided, one will be created from the index. </description> </method> <method name="clear"> - <return type="void"> - </return> + <return type="void" /> <description> Removes all items from the [PopupMenu]. </description> </method> <method name="clear_item_opentype_features"> - <return type="void"> - </return> - <argument index="0" name="idx" type="int"> - </argument> + <return type="void" /> + <argument index="0" name="idx" type="int" /> <description> Removes all OpenType features form the item's text. </description> </method> <method name="get_current_index" qualifiers="const"> - <return type="int"> - </return> + <return type="int" /> <description> Returns the index of the currently focused item. Returns [code]-1[/code] if no item is focused. </description> </method> <method name="get_item_accelerator" qualifiers="const"> - <return type="int"> - </return> - <argument index="0" name="idx" type="int"> - </argument> + <return type="int" /> + <argument index="0" name="idx" type="int" /> <description> Returns the accelerator of the item at index [code]idx[/code]. Accelerators are special combinations of keys that activate the item, no matter which control is focused. </description> </method> <method name="get_item_count" qualifiers="const"> - <return type="int"> - </return> + <return type="int" /> <description> Returns the number of items in the [PopupMenu]. </description> </method> <method name="get_item_icon" qualifiers="const"> - <return type="Texture2D"> - </return> - <argument index="0" name="idx" type="int"> - </argument> + <return type="Texture2D" /> + <argument index="0" name="idx" type="int" /> <description> Returns the icon of the item at index [code]idx[/code]. </description> </method> <method name="get_item_id" qualifiers="const"> - <return type="int"> - </return> - <argument index="0" name="idx" type="int"> - </argument> + <return type="int" /> + <argument index="0" name="idx" type="int" /> <description> Returns the id of the item at index [code]idx[/code]. [code]id[/code] can be manually assigned, while index can not. </description> </method> <method name="get_item_index" qualifiers="const"> - <return type="int"> - </return> - <argument index="0" name="id" type="int"> - </argument> + <return type="int" /> + <argument index="0" name="id" type="int" /> <description> Returns the index of the item containing the specified [code]id[/code]. Index is automatically assigned to each item by the engine. Index can not be set manually. </description> </method> <method name="get_item_language" qualifiers="const"> - <return type="String"> - </return> - <argument index="0" name="idx" type="int"> - </argument> + <return type="String" /> + <argument index="0" name="idx" type="int" /> <description> Returns item's text language code. </description> </method> <method name="get_item_metadata" qualifiers="const"> - <return type="Variant"> - </return> - <argument index="0" name="idx" type="int"> - </argument> + <return type="Variant" /> + <argument index="0" name="idx" type="int" /> <description> Returns the metadata of the specified item, which might be of any type. You can set it with [method set_item_metadata], which provides a simple way of assigning context data to items. </description> </method> <method name="get_item_opentype_feature" qualifiers="const"> - <return type="int"> - </return> - <argument index="0" name="idx" type="int"> - </argument> - <argument index="1" name="tag" type="String"> - </argument> + <return type="int" /> + <argument index="0" name="idx" type="int" /> + <argument index="1" name="tag" type="String" /> <description> Returns OpenType feature [code]tag[/code] of the item's text. </description> </method> <method name="get_item_shortcut" qualifiers="const"> - <return type="Shortcut"> - </return> - <argument index="0" name="idx" type="int"> - </argument> + <return type="Shortcut" /> + <argument index="0" name="idx" type="int" /> <description> Returns the [Shortcut] associated with the specified [code]idx[/code] item. </description> </method> <method name="get_item_submenu" qualifiers="const"> - <return type="String"> - </return> - <argument index="0" name="idx" type="int"> - </argument> + <return type="String" /> + <argument index="0" name="idx" type="int" /> <description> Returns the submenu name of the item at index [code]idx[/code]. See [method add_submenu_item] for more info on how to add a submenu. </description> </method> <method name="get_item_text" qualifiers="const"> - <return type="String"> - </return> - <argument index="0" name="idx" type="int"> - </argument> + <return type="String" /> + <argument index="0" name="idx" type="int" /> <description> Returns the text of the item at index [code]idx[/code]. </description> </method> <method name="get_item_text_direction" qualifiers="const"> - <return type="int" enum="Control.TextDirection"> - </return> - <argument index="0" name="idx" type="int"> - </argument> + <return type="int" enum="Control.TextDirection" /> + <argument index="0" name="idx" type="int" /> <description> Returns item's text base writing direction. </description> </method> <method name="get_item_tooltip" qualifiers="const"> - <return type="String"> - </return> - <argument index="0" name="idx" type="int"> - </argument> + <return type="String" /> + <argument index="0" name="idx" type="int" /> <description> Returns the tooltip associated with the specified index index [code]idx[/code]. </description> </method> <method name="is_item_checkable" qualifiers="const"> - <return type="bool"> - </return> - <argument index="0" name="idx" type="int"> - </argument> + <return type="bool" /> + <argument index="0" name="idx" type="int" /> <description> Returns [code]true[/code] if the item at index [code]idx[/code] is checkable in some way, i.e. if it has a checkbox or radio button. [b]Note:[/b] Checkable items just display a checkmark or radio button, but don't have any built-in checking behavior and must be checked/unchecked manually. </description> </method> <method name="is_item_checked" qualifiers="const"> - <return type="bool"> - </return> - <argument index="0" name="idx" type="int"> - </argument> + <return type="bool" /> + <argument index="0" name="idx" type="int" /> <description> Returns [code]true[/code] if the item at index [code]idx[/code] is checked. </description> </method> <method name="is_item_disabled" qualifiers="const"> - <return type="bool"> - </return> - <argument index="0" name="idx" type="int"> - </argument> + <return type="bool" /> + <argument index="0" name="idx" type="int" /> <description> Returns [code]true[/code] if the item at index [code]idx[/code] is disabled. When it is disabled it can't be selected, or its action invoked. See [method set_item_disabled] for more info on how to disable an item. </description> </method> <method name="is_item_radio_checkable" qualifiers="const"> - <return type="bool"> - </return> - <argument index="0" name="idx" type="int"> - </argument> + <return type="bool" /> + <argument index="0" name="idx" type="int" /> <description> Returns [code]true[/code] if the item at index [code]idx[/code] has radio button-style checkability. [b]Note:[/b] This is purely cosmetic; you must add the logic for checking/unchecking items in radio groups. </description> </method> <method name="is_item_separator" qualifiers="const"> - <return type="bool"> - </return> - <argument index="0" name="idx" type="int"> - </argument> + <return type="bool" /> + <argument index="0" name="idx" type="int" /> <description> Returns [code]true[/code] if the item is a separator. If it is, it will be displayed as a line. See [method add_separator] for more info on how to add a separator. </description> </method> <method name="is_item_shortcut_disabled" qualifiers="const"> - <return type="bool"> - </return> - <argument index="0" name="idx" type="int"> - </argument> + <return type="bool" /> + <argument index="0" name="idx" type="int" /> <description> Returns [code]true[/code] if the specified item's shortcut is disabled. </description> </method> <method name="remove_item"> - <return type="void"> - </return> - <argument index="0" name="idx" type="int"> - </argument> + <return type="void" /> + <argument index="0" name="idx" type="int" /> <description> Removes the item at index [code]idx[/code] from the menu. [b]Note:[/b] The indices of items after the removed item will be shifted by one. </description> </method> <method name="set_item_accelerator"> - <return type="void"> - </return> - <argument index="0" name="idx" type="int"> - </argument> - <argument index="1" name="accel" type="int"> - </argument> + <return type="void" /> + <argument index="0" name="idx" type="int" /> + <argument index="1" name="accel" type="int" /> <description> Sets the accelerator of the item at index [code]idx[/code]. Accelerators are special combinations of keys that activate the item, no matter which control is focused. </description> </method> <method name="set_item_as_checkable"> - <return type="void"> - </return> - <argument index="0" name="idx" type="int"> - </argument> - <argument index="1" name="enable" type="bool"> - </argument> + <return type="void" /> + <argument index="0" name="idx" type="int" /> + <argument index="1" name="enable" type="bool" /> <description> Sets whether the item at index [code]idx[/code] has a checkbox. If [code]false[/code], sets the type of the item to plain text. [b]Note:[/b] Checkable items just display a checkmark, but don't have any built-in checking behavior and must be checked/unchecked manually. </description> </method> <method name="set_item_as_radio_checkable"> - <return type="void"> - </return> - <argument index="0" name="idx" type="int"> - </argument> - <argument index="1" name="enable" type="bool"> - </argument> + <return type="void" /> + <argument index="0" name="idx" type="int" /> + <argument index="1" name="enable" type="bool" /> <description> Sets the type of the item at the specified index [code]idx[/code] to radio button. If [code]false[/code], sets the type of the item to plain text. </description> </method> <method name="set_item_as_separator"> - <return type="void"> - </return> - <argument index="0" name="idx" type="int"> - </argument> - <argument index="1" name="enable" type="bool"> - </argument> + <return type="void" /> + <argument index="0" name="idx" type="int" /> + <argument index="1" name="enable" type="bool" /> <description> Mark the item at index [code]idx[/code] as a separator, which means that it would be displayed as a line. If [code]false[/code], sets the type of the item to plain text. </description> </method> <method name="set_item_checked"> - <return type="void"> - </return> - <argument index="0" name="idx" type="int"> - </argument> - <argument index="1" name="checked" type="bool"> - </argument> + <return type="void" /> + <argument index="0" name="idx" type="int" /> + <argument index="1" name="checked" type="bool" /> <description> Sets the checkstate status of the item at index [code]idx[/code]. </description> </method> <method name="set_item_disabled"> - <return type="void"> - </return> - <argument index="0" name="idx" type="int"> - </argument> - <argument index="1" name="disabled" type="bool"> - </argument> + <return type="void" /> + <argument index="0" name="idx" type="int" /> + <argument index="1" name="disabled" type="bool" /> <description> Enables/disables the item at index [code]idx[/code]. When it is disabled, it can't be selected and its action can't be invoked. </description> </method> <method name="set_item_icon"> - <return type="void"> - </return> - <argument index="0" name="idx" type="int"> - </argument> - <argument index="1" name="icon" type="Texture2D"> - </argument> + <return type="void" /> + <argument index="0" name="idx" type="int" /> + <argument index="1" name="icon" type="Texture2D" /> <description> Replaces the [Texture2D] icon of the specified [code]idx[/code]. </description> </method> <method name="set_item_id"> - <return type="void"> - </return> - <argument index="0" name="idx" type="int"> - </argument> - <argument index="1" name="id" type="int"> - </argument> + <return type="void" /> + <argument index="0" name="idx" type="int" /> + <argument index="1" name="id" type="int" /> <description> Sets the [code]id[/code] of the item at index [code]idx[/code]. </description> </method> <method name="set_item_language"> - <return type="void"> - </return> - <argument index="0" name="idx" type="int"> - </argument> - <argument index="1" name="language" type="String"> - </argument> + <return type="void" /> + <argument index="0" name="idx" type="int" /> + <argument index="1" name="language" type="String" /> <description> Sets language code of item's text used for line-breaking and text shaping algorithms, if left empty current locale is used instead. </description> </method> <method name="set_item_metadata"> - <return type="void"> - </return> - <argument index="0" name="idx" type="int"> - </argument> - <argument index="1" name="metadata" type="Variant"> - </argument> + <return type="void" /> + <argument index="0" name="idx" type="int" /> + <argument index="1" name="metadata" type="Variant" /> <description> Sets the metadata of an item, which may be of any type. You can later get it with [method get_item_metadata], which provides a simple way of assigning context data to items. </description> </method> <method name="set_item_multistate"> - <return type="void"> - </return> - <argument index="0" name="idx" type="int"> - </argument> - <argument index="1" name="state" type="int"> - </argument> + <return type="void" /> + <argument index="0" name="idx" type="int" /> + <argument index="1" name="state" type="int" /> <description> Sets the state of a multistate item. See [method add_multistate_item] for details. </description> </method> <method name="set_item_opentype_feature"> - <return type="void"> - </return> - <argument index="0" name="idx" type="int"> - </argument> - <argument index="1" name="tag" type="String"> - </argument> - <argument index="2" name="value" type="int"> - </argument> + <return type="void" /> + <argument index="0" name="idx" type="int" /> + <argument index="1" name="tag" type="String" /> + <argument index="2" name="value" type="int" /> <description> Sets OpenType feature [code]tag[/code] for the item's text. More info: [url=https://docs.microsoft.com/en-us/typography/opentype/spec/featuretags]OpenType feature tags[/url]. </description> </method> <method name="set_item_shortcut"> - <return type="void"> - </return> - <argument index="0" name="idx" type="int"> - </argument> - <argument index="1" name="shortcut" type="Shortcut"> - </argument> - <argument index="2" name="global" type="bool" default="false"> - </argument> + <return type="void" /> + <argument index="0" name="idx" type="int" /> + <argument index="1" name="shortcut" type="Shortcut" /> + <argument index="2" name="global" type="bool" default="false" /> <description> Sets a [Shortcut] for the specified item [code]idx[/code]. </description> </method> <method name="set_item_shortcut_disabled"> - <return type="void"> - </return> - <argument index="0" name="idx" type="int"> - </argument> - <argument index="1" name="disabled" type="bool"> - </argument> + <return type="void" /> + <argument index="0" name="idx" type="int" /> + <argument index="1" name="disabled" type="bool" /> <description> Disables the [Shortcut] of the specified index [code]idx[/code]. </description> </method> <method name="set_item_submenu"> - <return type="void"> - </return> - <argument index="0" name="idx" type="int"> - </argument> - <argument index="1" name="submenu" type="String"> - </argument> + <return type="void" /> + <argument index="0" name="idx" type="int" /> + <argument index="1" name="submenu" type="String" /> <description> Sets the submenu of the item at index [code]idx[/code]. The submenu is the name of a child [PopupMenu] node that would be shown when the item is clicked. </description> </method> <method name="set_item_text"> - <return type="void"> - </return> - <argument index="0" name="idx" type="int"> - </argument> - <argument index="1" name="text" type="String"> - </argument> + <return type="void" /> + <argument index="0" name="idx" type="int" /> + <argument index="1" name="text" type="String" /> <description> Sets the text of the item at index [code]idx[/code]. </description> </method> <method name="set_item_text_direction"> - <return type="void"> - </return> - <argument index="0" name="idx" type="int"> - </argument> - <argument index="1" name="direction" type="int" enum="Control.TextDirection"> - </argument> + <return type="void" /> + <argument index="0" name="idx" type="int" /> + <argument index="1" name="direction" type="int" enum="Control.TextDirection" /> <description> Sets item's text base writing direction. </description> </method> <method name="set_item_tooltip"> - <return type="void"> - </return> - <argument index="0" name="idx" type="int"> - </argument> - <argument index="1" name="tooltip" type="String"> - </argument> + <return type="void" /> + <argument index="0" name="idx" type="int" /> + <argument index="1" name="tooltip" type="String" /> <description> Sets the [String] tooltip of the item at the specified index [code]idx[/code]. </description> </method> <method name="toggle_item_checked"> - <return type="void"> - </return> - <argument index="0" name="idx" type="int"> - </argument> + <return type="void" /> + <argument index="0" name="idx" type="int" /> <description> Toggles the check state of the item of the specified index [code]idx[/code]. </description> </method> <method name="toggle_item_multistate"> - <return type="void"> - </return> - <argument index="0" name="idx" type="int"> - </argument> + <return type="void" /> + <argument index="0" name="idx" type="int" /> <description> Cycle to the next state of a multistate item. See [method add_multistate_item] for details. </description> @@ -688,22 +517,19 @@ </members> <signals> <signal name="id_focused"> - <argument index="0" name="id" type="int"> - </argument> + <argument index="0" name="id" type="int" /> <description> Emitted when user navigated to an item of some [code]id[/code] using [code]ui_up[/code] or [code]ui_down[/code] action. </description> </signal> <signal name="id_pressed"> - <argument index="0" name="id" type="int"> - </argument> + <argument index="0" name="id" type="int" /> <description> Emitted when an item of some [code]id[/code] is pressed or its accelerator is activated. </description> </signal> <signal name="index_pressed"> - <argument index="0" name="index" type="int"> - </argument> + <argument index="0" name="index" type="int" /> <description> Emitted when an item of some [code]index[/code] is pressed or its accelerator is activated. </description> diff --git a/doc/classes/PrimitiveMesh.xml b/doc/classes/PrimitiveMesh.xml index ca41c367c8..36bec3ff61 100644 --- a/doc/classes/PrimitiveMesh.xml +++ b/doc/classes/PrimitiveMesh.xml @@ -10,8 +10,7 @@ </tutorials> <methods> <method name="get_mesh_arrays" qualifiers="const"> - <return type="Array"> - </return> + <return type="Array" /> <description> Returns mesh arrays used to constitute surface of [Mesh]. The result can be passed to [method ArrayMesh.add_surface_from_arrays] to create a new surface. For example: [codeblocks] diff --git a/doc/classes/ProjectSettings.xml b/doc/classes/ProjectSettings.xml index fbd257cdba..a1a320446b 100644 --- a/doc/classes/ProjectSettings.xml +++ b/doc/classes/ProjectSettings.xml @@ -16,10 +16,8 @@ </tutorials> <methods> <method name="add_property_info"> - <return type="void"> - </return> - <argument index="0" name="hint" type="Dictionary"> - </argument> + <return type="void" /> + <argument index="0" name="hint" type="Dictionary" /> <description> Adds a custom property info to a property. The dictionary must contain: - [code]name[/code]: [String] (the property's name) @@ -56,28 +54,22 @@ </description> </method> <method name="clear"> - <return type="void"> - </return> - <argument index="0" name="name" type="String"> - </argument> + <return type="void" /> + <argument index="0" name="name" type="String" /> <description> Clears the whole configuration (not recommended, may break things). </description> </method> <method name="get_order" qualifiers="const"> - <return type="int"> - </return> - <argument index="0" name="name" type="String"> - </argument> + <return type="int" /> + <argument index="0" name="name" type="String" /> <description> Returns the order of a configuration value (influences when saved to the config file). </description> </method> <method name="get_setting" qualifiers="const"> - <return type="Variant"> - </return> - <argument index="0" name="name" type="String"> - </argument> + <return type="Variant" /> + <argument index="0" name="name" type="String" /> <description> Returns the value of a setting. [b]Example:[/b] @@ -92,10 +84,8 @@ </description> </method> <method name="globalize_path" qualifiers="const"> - <return type="String"> - </return> - <argument index="0" name="path" type="String"> - </argument> + <return type="String" /> + <argument index="0" name="path" type="String" /> <description> Returns the absolute, native OS path corresponding to the localized [code]path[/code] (starting with [code]res://[/code] or [code]user://[/code]). The returned path will vary depending on the operating system and user preferences. See [url=https://docs.godotengine.org/en/latest/tutorials/io/data_paths.html]File paths in Godot projects[/url] to see what those paths convert to. See also [method localize_path]. [b]Note:[/b] [method globalize_path] with [code]res://[/code] will not work in an exported project. Instead, prepend the executable's base directory to the path when running from an exported project: @@ -115,23 +105,17 @@ </description> </method> <method name="has_setting" qualifiers="const"> - <return type="bool"> - </return> - <argument index="0" name="name" type="String"> - </argument> + <return type="bool" /> + <argument index="0" name="name" type="String" /> <description> Returns [code]true[/code] if a configuration value is present. </description> </method> <method name="load_resource_pack"> - <return type="bool"> - </return> - <argument index="0" name="pack" type="String"> - </argument> - <argument index="1" name="replace_files" type="bool" default="true"> - </argument> - <argument index="2" name="offset" type="int" default="0"> - </argument> + <return type="bool" /> + <argument index="0" name="pack" type="String" /> + <argument index="1" name="replace_files" type="bool" default="true" /> + <argument index="2" name="offset" type="int" default="0" /> <description> Loads the contents of the .pck or .zip file specified by [code]pack[/code] into the resource filesystem ([code]res://[/code]). Returns [code]true[/code] on success. [b]Note:[/b] If a file from [code]pack[/code] shares the same path as a file already in the resource filesystem, any attempts to load that file will use the file from [code]pack[/code] unless [code]replace_files[/code] is set to [code]false[/code]. @@ -139,78 +123,60 @@ </description> </method> <method name="localize_path" qualifiers="const"> - <return type="String"> - </return> - <argument index="0" name="path" type="String"> - </argument> + <return type="String" /> + <argument index="0" name="path" type="String" /> <description> Returns the localized path (starting with [code]res://[/code]) corresponding to the absolute, native OS [code]path[/code]. See also [method globalize_path]. </description> </method> <method name="property_can_revert"> - <return type="bool"> - </return> - <argument index="0" name="name" type="String"> - </argument> + <return type="bool" /> + <argument index="0" name="name" type="String" /> <description> Returns [code]true[/code] if the specified property exists and its initial value differs from the current value. </description> </method> <method name="property_get_revert"> - <return type="Variant"> - </return> - <argument index="0" name="name" type="String"> - </argument> + <return type="Variant" /> + <argument index="0" name="name" type="String" /> <description> Returns the specified property's initial value. Returns [code]null[/code] if the property does not exist. </description> </method> <method name="save"> - <return type="int" enum="Error"> - </return> + <return type="int" enum="Error" /> <description> Saves the configuration to the [code]project.godot[/code] file. [b]Note:[/b] This method is intended to be used by editor plugins, as modified [ProjectSettings] can't be loaded back in the running app. If you want to change project settings in exported projects, use [method save_custom] to save [code]override.cfg[/code] file. </description> </method> <method name="save_custom"> - <return type="int" enum="Error"> - </return> - <argument index="0" name="file" type="String"> - </argument> + <return type="int" enum="Error" /> + <argument index="0" name="file" type="String" /> <description> Saves the configuration to a custom file. The file extension must be [code].godot[/code] (to save in text-based [ConfigFile] format) or [code].binary[/code] (to save in binary format). You can also save [code]override.cfg[/code] file, which is also text, but can be used in exported projects unlike other formats. </description> </method> <method name="set_initial_value"> - <return type="void"> - </return> - <argument index="0" name="name" type="String"> - </argument> - <argument index="1" name="value" type="Variant"> - </argument> + <return type="void" /> + <argument index="0" name="name" type="String" /> + <argument index="1" name="value" type="Variant" /> <description> Sets the specified property's initial value. This is the value the property reverts to. </description> </method> <method name="set_order"> - <return type="void"> - </return> - <argument index="0" name="name" type="String"> - </argument> - <argument index="1" name="position" type="int"> - </argument> + <return type="void" /> + <argument index="0" name="name" type="String" /> + <argument index="1" name="position" type="int" /> <description> Sets the order of a configuration value (influences when saved to the config file). </description> </method> <method name="set_setting"> - <return type="void"> - </return> - <argument index="0" name="name" type="String"> - </argument> - <argument index="1" name="value" type="Variant"> - </argument> + <return type="void" /> + <argument index="0" name="name" type="String" /> + <argument index="1" name="value" type="Variant" /> <description> Sets the value of a setting. [b]Example:[/b] @@ -1569,12 +1535,16 @@ <member name="rendering/shadows/shadows/soft_shadow_quality.mobile" type="int" setter="" getter="" default="0"> Lower-end override for [member rendering/shadows/shadows/soft_shadow_quality] on mobile devices, due to performance concerns or driver support. </member> + <member name="rendering/textures/decals/filter" type="int" setter="" getter="" default="3"> + </member> <member name="rendering/textures/default_filters/anisotropic_filtering_level" type="int" setter="" getter="" default="2"> Sets the maximum number of samples to take when using anisotropic filtering on textures (as a power of two). A higher sample count will result in sharper textures at oblique angles, but is more expensive to compute. A value of [code]0[/code] forcibly disables anisotropic filtering, even on materials where it is enabled. </member> <member name="rendering/textures/default_filters/use_nearest_mipmap_filter" type="bool" setter="" getter="" default="false"> If [code]true[/code], uses nearest-neighbor mipmap filtering when using mipmaps (also called "bilinear filtering"), which will result in visible seams appearing between mipmap stages. This may increase performance in mobile as less memory bandwidth is used. If [code]false[/code], linear mipmap filtering (also called "trilinear filtering") is used. </member> + <member name="rendering/textures/light_projectors/filter" type="int" setter="" getter="" default="3"> + </member> <member name="rendering/textures/lossless_compression/force_png" type="bool" setter="" getter="" default="false"> If [code]true[/code], the texture importer will import lossless textures using the PNG format. Otherwise, it will default to using WebP. </member> diff --git a/doc/classes/PropertyTweener.xml b/doc/classes/PropertyTweener.xml index 1e77bb33c6..7914b26676 100644 --- a/doc/classes/PropertyTweener.xml +++ b/doc/classes/PropertyTweener.xml @@ -11,8 +11,7 @@ </tutorials> <methods> <method name="as_relative"> - <return type="PropertyTweener"> - </return> + <return type="PropertyTweener" /> <description> When called, the final value will be used as a relative value instead. Example: [codeblock] @@ -22,10 +21,8 @@ </description> </method> <method name="from"> - <return type="PropertyTweener"> - </return> - <argument index="0" name="value" type="Variant"> - </argument> + <return type="PropertyTweener" /> + <argument index="0" name="value" type="Variant" /> <description> Sets a custom initial value to the [PropertyTweener]. Example: [codeblock] @@ -35,8 +32,7 @@ </description> </method> <method name="from_current"> - <return type="PropertyTweener"> - </return> + <return type="PropertyTweener" /> <description> Makes the [PropertyTweener] use the current property value (i.e. at the time of creating this [PropertyTweener]) as a starting point. This is equivalent of using [method from] with the current value. These two calls will do the same: [codeblock] @@ -46,28 +42,22 @@ </description> </method> <method name="set_delay"> - <return type="PropertyTweener"> - </return> - <argument index="0" name="delay" type="float"> - </argument> + <return type="PropertyTweener" /> + <argument index="0" name="delay" type="float" /> <description> Sets the time in seconds after which the [PropertyTweener] will start interpolating. By default there's no delay. </description> </method> <method name="set_ease"> - <return type="PropertyTweener"> - </return> - <argument index="0" name="ease" type="int" enum="Tween.EaseType"> - </argument> + <return type="PropertyTweener" /> + <argument index="0" name="ease" type="int" enum="Tween.EaseType" /> <description> Sets the type of used easing from [enum Tween.EaseType]. If not set, the default easing is used from the [Tween] that contains this Tweener. </description> </method> <method name="set_trans"> - <return type="PropertyTweener"> - </return> - <argument index="0" name="trans" type="int" enum="Tween.TransitionType"> - </argument> + <return type="PropertyTweener" /> + <argument index="0" name="trans" type="int" enum="Tween.TransitionType" /> <description> Sets the type of used transition from [enum Tween.TransitionType]. If not set, the default transition is used from the [Tween] that contains this Tweener. </description> diff --git a/doc/classes/ProximityGroup3D.xml b/doc/classes/ProximityGroup3D.xml index 22e397b832..15735bd6f6 100644 --- a/doc/classes/ProximityGroup3D.xml +++ b/doc/classes/ProximityGroup3D.xml @@ -10,12 +10,9 @@ </tutorials> <methods> <method name="broadcast"> - <return type="void"> - </return> - <argument index="0" name="method" type="String"> - </argument> - <argument index="1" name="parameters" type="Variant"> - </argument> + <return type="void" /> + <argument index="0" name="method" type="String" /> + <argument index="1" name="parameters" type="Variant" /> <description> </description> </method> @@ -30,10 +27,8 @@ </members> <signals> <signal name="broadcast"> - <argument index="0" name="method" type="String"> - </argument> - <argument index="1" name="parameters" type="Array"> - </argument> + <argument index="0" name="method" type="String" /> + <argument index="1" name="parameters" type="Array" /> <description> </description> </signal> diff --git a/doc/classes/Quaternion.xml b/doc/classes/Quaternion.xml index 06434ab268..720188f67e 100644 --- a/doc/classes/Quaternion.xml +++ b/doc/classes/Quaternion.xml @@ -14,279 +14,214 @@ </tutorials> <methods> <method name="Quaternion" qualifiers="constructor"> - <return type="Quaternion"> - </return> + <return type="Quaternion" /> <description> Constructs a default-initialized quaternion with all components set to [code]0[/code]. </description> </method> <method name="Quaternion" qualifiers="constructor"> - <return type="Quaternion"> - </return> - <argument index="0" name="from" type="Quaternion"> - </argument> + <return type="Quaternion" /> + <argument index="0" name="from" type="Quaternion" /> <description> Constructs a [Quaternion] as a copy of the given [Quaternion]. </description> </method> <method name="Quaternion" qualifiers="constructor"> - <return type="Quaternion"> - </return> - <argument index="0" name="arc_from" type="Vector3"> - </argument> - <argument index="1" name="arc_to" type="Vector3"> - </argument> + <return type="Quaternion" /> + <argument index="0" name="arc_from" type="Vector3" /> + <argument index="1" name="arc_to" type="Vector3" /> <description> </description> </method> <method name="Quaternion" qualifiers="constructor"> - <return type="Quaternion"> - </return> - <argument index="0" name="axis" type="Vector3"> - </argument> - <argument index="1" name="angle" type="float"> - </argument> + <return type="Quaternion" /> + <argument index="0" name="axis" type="Vector3" /> + <argument index="1" name="angle" type="float" /> <description> Constructs a quaternion that will rotate around the given axis by the specified angle. The axis must be a normalized vector. </description> </method> <method name="Quaternion" qualifiers="constructor"> - <return type="Quaternion"> - </return> - <argument index="0" name="euler" type="Vector3"> - </argument> + <return type="Quaternion" /> + <argument index="0" name="euler" type="Vector3" /> <description> Constructs a quaternion that will perform a rotation specified by Euler angles (in the YXZ convention: when decomposing, first Z, then X, and Y last), given in the vector format as (X angle, Y angle, Z angle). </description> </method> <method name="Quaternion" qualifiers="constructor"> - <return type="Quaternion"> - </return> - <argument index="0" name="from" type="Basis"> - </argument> + <return type="Quaternion" /> + <argument index="0" name="from" type="Basis" /> <description> Constructs a quaternion from the given [Basis]. </description> </method> <method name="Quaternion" qualifiers="constructor"> - <return type="Quaternion"> - </return> - <argument index="0" name="x" type="float"> - </argument> - <argument index="1" name="y" type="float"> - </argument> - <argument index="2" name="z" type="float"> - </argument> - <argument index="3" name="w" type="float"> - </argument> + <return type="Quaternion" /> + <argument index="0" name="x" type="float" /> + <argument index="1" name="y" type="float" /> + <argument index="2" name="z" type="float" /> + <argument index="3" name="w" type="float" /> <description> Constructs a quaternion defined by the given values. </description> </method> <method name="angle_to" qualifiers="const"> - <return type="float"> - </return> - <argument index="0" name="to" type="Quaternion"> - </argument> + <return type="float" /> + <argument index="0" name="to" type="Quaternion" /> <description> Returns the angle between this quaternion and [code]to[/code]. This is the magnitude of the angle you would need to rotate by to get from one to the other. [b]Note:[/b] This method has an abnormally high amount of floating-point error, so methods such as [code]is_zero_approx[/code] will not work reliably. </description> </method> <method name="cubic_slerp" qualifiers="const"> - <return type="Quaternion"> - </return> - <argument index="0" name="b" type="Quaternion"> - </argument> - <argument index="1" name="pre_a" type="Quaternion"> - </argument> - <argument index="2" name="post_b" type="Quaternion"> - </argument> - <argument index="3" name="weight" type="float"> - </argument> + <return type="Quaternion" /> + <argument index="0" name="b" type="Quaternion" /> + <argument index="1" name="pre_a" type="Quaternion" /> + <argument index="2" name="post_b" type="Quaternion" /> + <argument index="3" name="weight" type="float" /> <description> Performs a cubic spherical interpolation between quaternions [code]pre_a[/code], this vector, [code]b[/code], and [code]post_b[/code], by the given amount [code]weight[/code]. </description> </method> <method name="dot" qualifiers="const"> - <return type="float"> - </return> - <argument index="0" name="with" type="Quaternion"> - </argument> + <return type="float" /> + <argument index="0" name="with" type="Quaternion" /> <description> Returns the dot product of two quaternions. </description> </method> <method name="get_euler" qualifiers="const"> - <return type="Vector3"> - </return> + <return type="Vector3" /> <description> Returns Euler angles (in the YXZ convention: when decomposing, first Z, then X, and Y last) corresponding to the rotation represented by the unit quaternion. Returned vector contains the rotation angles in the format (X angle, Y angle, Z angle). </description> </method> <method name="inverse" qualifiers="const"> - <return type="Quaternion"> - </return> + <return type="Quaternion" /> <description> Returns the inverse of the quaternion. </description> </method> <method name="is_equal_approx" qualifiers="const"> - <return type="bool"> - </return> - <argument index="0" name="to" type="Quaternion"> - </argument> + <return type="bool" /> + <argument index="0" name="to" type="Quaternion" /> <description> Returns [code]true[/code] if this quaternion and [code]quat[/code] are approximately equal, by running [method @GlobalScope.is_equal_approx] on each component. </description> </method> <method name="is_normalized" qualifiers="const"> - <return type="bool"> - </return> + <return type="bool" /> <description> Returns whether the quaternion is normalized or not. </description> </method> <method name="length" qualifiers="const"> - <return type="float"> - </return> + <return type="float" /> <description> Returns the length of the quaternion. </description> </method> <method name="length_squared" qualifiers="const"> - <return type="float"> - </return> + <return type="float" /> <description> Returns the length of the quaternion, squared. </description> </method> <method name="normalized" qualifiers="const"> - <return type="Quaternion"> - </return> + <return type="Quaternion" /> <description> Returns a copy of the quaternion, normalized to unit length. </description> </method> <method name="operator !=" qualifiers="operator"> - <return type="bool"> - </return> - <argument index="0" name="right" type="Quaternion"> - </argument> + <return type="bool" /> + <argument index="0" name="right" type="Quaternion" /> <description> </description> </method> <method name="operator *" qualifiers="operator"> - <return type="Vector3"> - </return> - <argument index="0" name="right" type="Vector3"> - </argument> + <return type="Vector3" /> + <argument index="0" name="right" type="Vector3" /> <description> </description> </method> <method name="operator *" qualifiers="operator"> - <return type="Quaternion"> - </return> - <argument index="0" name="right" type="Quaternion"> - </argument> + <return type="Quaternion" /> + <argument index="0" name="right" type="Quaternion" /> <description> </description> </method> <method name="operator *" qualifiers="operator"> - <return type="Quaternion"> - </return> - <argument index="0" name="right" type="float"> - </argument> + <return type="Quaternion" /> + <argument index="0" name="right" type="float" /> <description> </description> </method> <method name="operator *" qualifiers="operator"> - <return type="Quaternion"> - </return> - <argument index="0" name="right" type="int"> - </argument> + <return type="Quaternion" /> + <argument index="0" name="right" type="int" /> <description> </description> </method> <method name="operator +" qualifiers="operator"> - <return type="Quaternion"> - </return> - <argument index="0" name="right" type="Quaternion"> - </argument> + <return type="Quaternion" /> + <argument index="0" name="right" type="Quaternion" /> <description> </description> </method> <method name="operator -" qualifiers="operator"> - <return type="Quaternion"> - </return> - <argument index="0" name="right" type="Quaternion"> - </argument> + <return type="Quaternion" /> + <argument index="0" name="right" type="Quaternion" /> <description> </description> </method> <method name="operator /" qualifiers="operator"> - <return type="Quaternion"> - </return> - <argument index="0" name="right" type="float"> - </argument> + <return type="Quaternion" /> + <argument index="0" name="right" type="float" /> <description> </description> </method> <method name="operator /" qualifiers="operator"> - <return type="Quaternion"> - </return> - <argument index="0" name="right" type="int"> - </argument> + <return type="Quaternion" /> + <argument index="0" name="right" type="int" /> <description> </description> </method> <method name="operator ==" qualifiers="operator"> - <return type="bool"> - </return> - <argument index="0" name="right" type="Quaternion"> - </argument> + <return type="bool" /> + <argument index="0" name="right" type="Quaternion" /> <description> </description> </method> <method name="operator []" qualifiers="operator"> - <return type="float"> - </return> - <argument index="0" name="index" type="int"> - </argument> + <return type="float" /> + <argument index="0" name="index" type="int" /> <description> </description> </method> <method name="operator unary+" qualifiers="operator"> - <return type="Quaternion"> - </return> + <return type="Quaternion" /> <description> </description> </method> <method name="operator unary-" qualifiers="operator"> - <return type="Quaternion"> - </return> + <return type="Quaternion" /> <description> </description> </method> <method name="slerp" qualifiers="const"> - <return type="Quaternion"> - </return> - <argument index="0" name="to" type="Quaternion"> - </argument> - <argument index="1" name="weight" type="float"> - </argument> + <return type="Quaternion" /> + <argument index="0" name="to" type="Quaternion" /> + <argument index="1" name="weight" type="float" /> <description> Returns the result of the spherical linear interpolation between this quaternion and [code]to[/code] by amount [code]weight[/code]. [b]Note:[/b] Both quaternions must be normalized. </description> </method> <method name="slerpni" qualifiers="const"> - <return type="Quaternion"> - </return> - <argument index="0" name="to" type="Quaternion"> - </argument> - <argument index="1" name="weight" type="float"> - </argument> + <return type="Quaternion" /> + <argument index="0" name="to" type="Quaternion" /> + <argument index="1" name="weight" type="float" /> <description> Returns the result of the spherical linear interpolation between this quaternion and [code]to[/code] by amount [code]weight[/code], but without checking if the rotation path is not bigger than 90 degrees. </description> diff --git a/doc/classes/RDPipelineColorBlendStateAttachment.xml b/doc/classes/RDPipelineColorBlendStateAttachment.xml index a6a1900cb5..30430d6670 100644 --- a/doc/classes/RDPipelineColorBlendStateAttachment.xml +++ b/doc/classes/RDPipelineColorBlendStateAttachment.xml @@ -8,8 +8,7 @@ </tutorials> <methods> <method name="set_as_mix"> - <return type="void"> - </return> + <return type="void" /> <description> </description> </method> diff --git a/doc/classes/RDShaderFile.xml b/doc/classes/RDShaderFile.xml index 346a97a1c0..22fcf9867c 100644 --- a/doc/classes/RDShaderFile.xml +++ b/doc/classes/RDShaderFile.xml @@ -7,27 +7,21 @@ <tutorials> </tutorials> <methods> - <method name="get_bytecode" qualifiers="const"> - <return type="RDShaderBytecode"> - </return> - <argument index="0" name="version" type="StringName" default="&"""> - </argument> + <method name="get_spirv" qualifiers="const"> + <return type="RDShaderSPIRV" /> + <argument index="0" name="version" type="StringName" default="&""" /> <description> </description> </method> <method name="get_version_list" qualifiers="const"> - <return type="PackedStringArray"> - </return> + <return type="PackedStringArray" /> <description> </description> </method> <method name="set_bytecode"> - <return type="void"> - </return> - <argument index="0" name="bytecode" type="RDShaderBytecode"> - </argument> - <argument index="1" name="version" type="StringName" default="&"""> - </argument> + <return type="void" /> + <argument index="0" name="bytecode" type="RDShaderSPIRV" /> + <argument index="1" name="version" type="StringName" default="&""" /> <description> </description> </method> diff --git a/doc/classes/RDShaderBytecode.xml b/doc/classes/RDShaderSPIRV.xml index 20bf9bdd72..20de8230aa 100644 --- a/doc/classes/RDShaderBytecode.xml +++ b/doc/classes/RDShaderSPIRV.xml @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="UTF-8" ?> -<class name="RDShaderBytecode" inherits="Resource" version="4.0"> +<class name="RDShaderSPIRV" inherits="Resource" version="4.0"> <brief_description> </brief_description> <description> @@ -8,38 +8,28 @@ </tutorials> <methods> <method name="get_stage_bytecode" qualifiers="const"> - <return type="PackedByteArray"> - </return> - <argument index="0" name="stage" type="int" enum="RenderingDevice.ShaderStage"> - </argument> + <return type="PackedByteArray" /> + <argument index="0" name="stage" type="int" enum="RenderingDevice.ShaderStage" /> <description> </description> </method> <method name="get_stage_compile_error" qualifiers="const"> - <return type="String"> - </return> - <argument index="0" name="stage" type="int" enum="RenderingDevice.ShaderStage"> - </argument> + <return type="String" /> + <argument index="0" name="stage" type="int" enum="RenderingDevice.ShaderStage" /> <description> </description> </method> <method name="set_stage_bytecode"> - <return type="void"> - </return> - <argument index="0" name="stage" type="int" enum="RenderingDevice.ShaderStage"> - </argument> - <argument index="1" name="bytecode" type="PackedByteArray"> - </argument> + <return type="void" /> + <argument index="0" name="stage" type="int" enum="RenderingDevice.ShaderStage" /> + <argument index="1" name="bytecode" type="PackedByteArray" /> <description> </description> </method> <method name="set_stage_compile_error"> - <return type="void"> - </return> - <argument index="0" name="stage" type="int" enum="RenderingDevice.ShaderStage"> - </argument> - <argument index="1" name="compile_error" type="String"> - </argument> + <return type="void" /> + <argument index="0" name="stage" type="int" enum="RenderingDevice.ShaderStage" /> + <argument index="1" name="compile_error" type="String" /> <description> </description> </method> diff --git a/doc/classes/RDShaderSource.xml b/doc/classes/RDShaderSource.xml index 68fc43d8ef..2d37ce37f2 100644 --- a/doc/classes/RDShaderSource.xml +++ b/doc/classes/RDShaderSource.xml @@ -8,20 +8,15 @@ </tutorials> <methods> <method name="get_stage_source" qualifiers="const"> - <return type="String"> - </return> - <argument index="0" name="stage" type="int" enum="RenderingDevice.ShaderStage"> - </argument> + <return type="String" /> + <argument index="0" name="stage" type="int" enum="RenderingDevice.ShaderStage" /> <description> </description> </method> <method name="set_stage_source"> - <return type="void"> - </return> - <argument index="0" name="stage" type="int" enum="RenderingDevice.ShaderStage"> - </argument> - <argument index="1" name="source" type="String"> - </argument> + <return type="void" /> + <argument index="0" name="stage" type="int" enum="RenderingDevice.ShaderStage" /> + <argument index="1" name="source" type="String" /> <description> </description> </method> diff --git a/doc/classes/RDTextureFormat.xml b/doc/classes/RDTextureFormat.xml index ccfa6d1b95..2588dcfc40 100644 --- a/doc/classes/RDTextureFormat.xml +++ b/doc/classes/RDTextureFormat.xml @@ -8,18 +8,14 @@ </tutorials> <methods> <method name="add_shareable_format"> - <return type="void"> - </return> - <argument index="0" name="format" type="int" enum="RenderingDevice.DataFormat"> - </argument> + <return type="void" /> + <argument index="0" name="format" type="int" enum="RenderingDevice.DataFormat" /> <description> </description> </method> <method name="remove_shareable_format"> - <return type="void"> - </return> - <argument index="0" name="format" type="int" enum="RenderingDevice.DataFormat"> - </argument> + <return type="void" /> + <argument index="0" name="format" type="int" enum="RenderingDevice.DataFormat" /> <description> </description> </method> diff --git a/doc/classes/RDUniform.xml b/doc/classes/RDUniform.xml index 666935d663..93adecc7de 100644 --- a/doc/classes/RDUniform.xml +++ b/doc/classes/RDUniform.xml @@ -8,22 +8,18 @@ </tutorials> <methods> <method name="add_id"> - <return type="void"> - </return> - <argument index="0" name="id" type="RID"> - </argument> + <return type="void" /> + <argument index="0" name="id" type="RID" /> <description> </description> </method> <method name="clear_ids"> - <return type="void"> - </return> + <return type="void" /> <description> </description> </method> <method name="get_ids" qualifiers="const"> - <return type="Array"> - </return> + <return type="Array" /> <description> </description> </method> diff --git a/doc/classes/RID.xml b/doc/classes/RID.xml index e686a4b8fd..ddd30dbc82 100644 --- a/doc/classes/RID.xml +++ b/doc/classes/RID.xml @@ -10,73 +10,57 @@ </tutorials> <methods> <method name="RID" qualifiers="constructor"> - <return type="RID"> - </return> + <return type="RID" /> <description> Constructs an empty [RID] with the invalid ID [code]0[/code]. </description> </method> <method name="RID" qualifiers="constructor"> - <return type="RID"> - </return> - <argument index="0" name="from" type="RID"> - </argument> + <return type="RID" /> + <argument index="0" name="from" type="RID" /> <description> Constructs a [RID] as a copy of the given [RID]. </description> </method> <method name="get_id" qualifiers="const"> - <return type="int"> - </return> + <return type="int" /> <description> Returns the ID of the referenced resource. </description> </method> <method name="operator !=" qualifiers="operator"> - <return type="bool"> - </return> - <argument index="0" name="right" type="RID"> - </argument> + <return type="bool" /> + <argument index="0" name="right" type="RID" /> <description> </description> </method> <method name="operator <" qualifiers="operator"> - <return type="bool"> - </return> - <argument index="0" name="right" type="RID"> - </argument> + <return type="bool" /> + <argument index="0" name="right" type="RID" /> <description> </description> </method> <method name="operator <=" qualifiers="operator"> - <return type="bool"> - </return> - <argument index="0" name="right" type="RID"> - </argument> + <return type="bool" /> + <argument index="0" name="right" type="RID" /> <description> </description> </method> <method name="operator ==" qualifiers="operator"> - <return type="bool"> - </return> - <argument index="0" name="right" type="RID"> - </argument> + <return type="bool" /> + <argument index="0" name="right" type="RID" /> <description> </description> </method> <method name="operator >" qualifiers="operator"> - <return type="bool"> - </return> - <argument index="0" name="right" type="RID"> - </argument> + <return type="bool" /> + <argument index="0" name="right" type="RID" /> <description> </description> </method> <method name="operator >=" qualifiers="operator"> - <return type="bool"> - </return> - <argument index="0" name="right" type="RID"> - </argument> + <return type="bool" /> + <argument index="0" name="right" type="RID" /> <description> </description> </method> diff --git a/doc/classes/RandomNumberGenerator.xml b/doc/classes/RandomNumberGenerator.xml index 9c84cdd03e..2cf3cbb83d 100644 --- a/doc/classes/RandomNumberGenerator.xml +++ b/doc/classes/RandomNumberGenerator.xml @@ -20,55 +20,43 @@ </tutorials> <methods> <method name="randf"> - <return type="float"> - </return> + <return type="float" /> <description> Returns a pseudo-random float between [code]0.0[/code] and [code]1.0[/code] (inclusive). </description> </method> <method name="randf_range"> - <return type="float"> - </return> - <argument index="0" name="from" type="float"> - </argument> - <argument index="1" name="to" type="float"> - </argument> + <return type="float" /> + <argument index="0" name="from" type="float" /> + <argument index="1" name="to" type="float" /> <description> Returns a pseudo-random float between [code]from[/code] and [code]to[/code] (inclusive). </description> </method> <method name="randfn"> - <return type="float"> - </return> - <argument index="0" name="mean" type="float" default="0.0"> - </argument> - <argument index="1" name="deviation" type="float" default="1.0"> - </argument> + <return type="float" /> + <argument index="0" name="mean" type="float" default="0.0" /> + <argument index="1" name="deviation" type="float" default="1.0" /> <description> Returns a [url=https://en.wikipedia.org/wiki/Normal_distribution]normally-distributed[/url] pseudo-random number, using Box-Muller transform with the specified [code]mean[/code] and a standard [code]deviation[/code]. This is also called Gaussian distribution. </description> </method> <method name="randi"> - <return type="int"> - </return> + <return type="int" /> <description> Returns a pseudo-random 32-bit unsigned integer between [code]0[/code] and [code]4294967295[/code] (inclusive). </description> </method> <method name="randi_range"> - <return type="int"> - </return> - <argument index="0" name="from" type="int"> - </argument> - <argument index="1" name="to" type="int"> - </argument> + <return type="int" /> + <argument index="0" name="from" type="int" /> + <argument index="1" name="to" type="int" /> <description> Returns a pseudo-random 32-bit signed integer between [code]from[/code] and [code]to[/code] (inclusive). </description> </method> <method name="randomize"> - <return type="void"> - </return> + <return type="void" /> <description> Setups a time-based seed to for this [RandomNumberGenerator] instance. Unlike the [@GlobalScope] random number generation functions, different [RandomNumberGenerator] instances can use different seeds. </description> diff --git a/doc/classes/Range.xml b/doc/classes/Range.xml index 8690f6d7e7..30b915b437 100644 --- a/doc/classes/Range.xml +++ b/doc/classes/Range.xml @@ -10,17 +10,14 @@ </tutorials> <methods> <method name="share"> - <return type="void"> - </return> - <argument index="0" name="with" type="Node"> - </argument> + <return type="void" /> + <argument index="0" name="with" type="Node" /> <description> Binds two ranges together along with any ranges previously grouped with either of them. When any of range's member variables change, it will share the new value with all other ranges in its group. </description> </method> <method name="unshare"> - <return type="void"> - </return> + <return type="void" /> <description> Stops range from sharing its member variables with any other. </description> @@ -65,8 +62,7 @@ </description> </signal> <signal name="value_changed"> - <argument index="0" name="value" type="float"> - </argument> + <argument index="0" name="value" type="float" /> <description> Emitted when [member value] changes. </description> diff --git a/doc/classes/RayCast2D.xml b/doc/classes/RayCast2D.xml index 14b67b46df..d8a5fc8508 100644 --- a/doc/classes/RayCast2D.xml +++ b/doc/classes/RayCast2D.xml @@ -15,108 +15,88 @@ </tutorials> <methods> <method name="add_exception"> - <return type="void"> - </return> - <argument index="0" name="node" type="Object"> - </argument> + <return type="void" /> + <argument index="0" name="node" type="Object" /> <description> Adds a collision exception so the ray does not report collisions with the specified node. </description> </method> <method name="add_exception_rid"> - <return type="void"> - </return> - <argument index="0" name="rid" type="RID"> - </argument> + <return type="void" /> + <argument index="0" name="rid" type="RID" /> <description> Adds a collision exception so the ray does not report collisions with the specified [RID]. </description> </method> <method name="clear_exceptions"> - <return type="void"> - </return> + <return type="void" /> <description> Removes all collision exceptions for this ray. </description> </method> <method name="force_raycast_update"> - <return type="void"> - </return> + <return type="void" /> <description> Updates the collision information for the ray. Use this method to update the collision information immediately instead of waiting for the next [code]_physics_process[/code] call, for example if the ray or its parent has changed state. [b]Note:[/b] [member enabled] does not need to be [code]true[/code] for this to work. </description> </method> <method name="get_collider" qualifiers="const"> - <return type="Object"> - </return> + <return type="Object" /> <description> Returns the first object that the ray intersects, or [code]null[/code] if no object is intersecting the ray (i.e. [method is_colliding] returns [code]false[/code]). </description> </method> <method name="get_collider_shape" qualifiers="const"> - <return type="int"> - </return> + <return type="int" /> <description> Returns the shape ID of the first object that the ray intersects, or [code]0[/code] if no object is intersecting the ray (i.e. [method is_colliding] returns [code]false[/code]). </description> </method> <method name="get_collision_mask_bit" qualifiers="const"> - <return type="bool"> - </return> - <argument index="0" name="bit" type="int"> - </argument> + <return type="bool" /> + <argument index="0" name="bit" type="int" /> <description> Returns an individual bit on the collision mask. </description> </method> <method name="get_collision_normal" qualifiers="const"> - <return type="Vector2"> - </return> + <return type="Vector2" /> <description> Returns the normal of the intersecting object's shape at the collision point. </description> </method> <method name="get_collision_point" qualifiers="const"> - <return type="Vector2"> - </return> + <return type="Vector2" /> <description> Returns the collision point at which the ray intersects the closest object. [b]Note:[/b] this point is in the [b]global[/b] coordinate system. </description> </method> <method name="is_colliding" qualifiers="const"> - <return type="bool"> - </return> + <return type="bool" /> <description> Returns whether any object is intersecting with the ray's vector (considering the vector length). </description> </method> <method name="remove_exception"> - <return type="void"> - </return> - <argument index="0" name="node" type="Object"> - </argument> + <return type="void" /> + <argument index="0" name="node" type="Object" /> <description> Removes a collision exception so the ray does report collisions with the specified node. </description> </method> <method name="remove_exception_rid"> - <return type="void"> - </return> - <argument index="0" name="rid" type="RID"> - </argument> + <return type="void" /> + <argument index="0" name="rid" type="RID" /> <description> Removes a collision exception so the ray does report collisions with the specified [RID]. </description> </method> <method name="set_collision_mask_bit"> - <return type="void"> - </return> - <argument index="0" name="bit" type="int"> - </argument> - <argument index="1" name="value" type="bool"> - </argument> + <return type="void" /> + <argument index="0" name="bit" type="int" /> + <argument index="1" name="value" type="bool" /> <description> Sets or clears individual bits on the collision mask. This makes selecting the areas scanned easier. </description> diff --git a/doc/classes/RayCast3D.xml b/doc/classes/RayCast3D.xml index 98c8c96403..4e8eb960db 100644 --- a/doc/classes/RayCast3D.xml +++ b/doc/classes/RayCast3D.xml @@ -16,33 +16,27 @@ </tutorials> <methods> <method name="add_exception"> - <return type="void"> - </return> - <argument index="0" name="node" type="Object"> - </argument> + <return type="void" /> + <argument index="0" name="node" type="Object" /> <description> Adds a collision exception so the ray does not report collisions with the specified node. </description> </method> <method name="add_exception_rid"> - <return type="void"> - </return> - <argument index="0" name="rid" type="RID"> - </argument> + <return type="void" /> + <argument index="0" name="rid" type="RID" /> <description> Adds a collision exception so the ray does not report collisions with the specified [RID]. </description> </method> <method name="clear_exceptions"> - <return type="void"> - </return> + <return type="void" /> <description> Removes all collision exceptions for this ray. </description> </method> <method name="force_raycast_update"> - <return type="void"> - </return> + <return type="void" /> <description> Updates the collision information for the ray. Use this method to update the collision information immediately instead of waiting for the next [code]_physics_process[/code] call, for example if the ray or its parent has changed state. @@ -50,76 +44,62 @@ </description> </method> <method name="get_collider" qualifiers="const"> - <return type="Object"> - </return> + <return type="Object" /> <description> Returns the first object that the ray intersects, or [code]null[/code] if no object is intersecting the ray (i.e. [method is_colliding] returns [code]false[/code]). </description> </method> <method name="get_collider_shape" qualifiers="const"> - <return type="int"> - </return> + <return type="int" /> <description> Returns the shape ID of the first object that the ray intersects, or [code]0[/code] if no object is intersecting the ray (i.e. [method is_colliding] returns [code]false[/code]). </description> </method> <method name="get_collision_mask_bit" qualifiers="const"> - <return type="bool"> - </return> - <argument index="0" name="bit" type="int"> - </argument> + <return type="bool" /> + <argument index="0" name="bit" type="int" /> <description> Returns [code]true[/code] if the bit index passed is turned on. [b]Note:[/b] Bit indices range from 0-19. </description> </method> <method name="get_collision_normal" qualifiers="const"> - <return type="Vector3"> - </return> + <return type="Vector3" /> <description> Returns the normal of the intersecting object's shape at the collision point. </description> </method> <method name="get_collision_point" qualifiers="const"> - <return type="Vector3"> - </return> + <return type="Vector3" /> <description> Returns the collision point at which the ray intersects the closest object. [b]Note:[/b] This point is in the [b]global[/b] coordinate system. </description> </method> <method name="is_colliding" qualifiers="const"> - <return type="bool"> - </return> + <return type="bool" /> <description> Returns whether any object is intersecting with the ray's vector (considering the vector length). </description> </method> <method name="remove_exception"> - <return type="void"> - </return> - <argument index="0" name="node" type="Object"> - </argument> + <return type="void" /> + <argument index="0" name="node" type="Object" /> <description> Removes a collision exception so the ray does report collisions with the specified node. </description> </method> <method name="remove_exception_rid"> - <return type="void"> - </return> - <argument index="0" name="rid" type="RID"> - </argument> + <return type="void" /> + <argument index="0" name="rid" type="RID" /> <description> Removes a collision exception so the ray does report collisions with the specified [RID]. </description> </method> <method name="set_collision_mask_bit"> - <return type="void"> - </return> - <argument index="0" name="bit" type="int"> - </argument> - <argument index="1" name="value" type="bool"> - </argument> + <return type="void" /> + <argument index="0" name="bit" type="int" /> + <argument index="1" name="value" type="bool" /> <description> Sets the bit index passed to the [code]value[/code] passed. [b]Note:[/b] Bit indexes range from 0-19. diff --git a/doc/classes/Rect2.xml b/doc/classes/Rect2.xml index 627c488b01..e6c8ff86b6 100644 --- a/doc/classes/Rect2.xml +++ b/doc/classes/Rect2.xml @@ -15,200 +15,153 @@ </tutorials> <methods> <method name="Rect2" qualifiers="constructor"> - <return type="Rect2"> - </return> + <return type="Rect2" /> <description> Constructs a default-initialized [Rect2] with default (zero) values of [member position] and [member size]. </description> </method> <method name="Rect2" qualifiers="constructor"> - <return type="Rect2"> - </return> - <argument index="0" name="from" type="Rect2"> - </argument> + <return type="Rect2" /> + <argument index="0" name="from" type="Rect2" /> <description> Constructs a [Rect2] as a copy of the given [Rect2]. </description> </method> <method name="Rect2" qualifiers="constructor"> - <return type="Rect2"> - </return> - <argument index="0" name="from" type="Rect2i"> - </argument> + <return type="Rect2" /> + <argument index="0" name="from" type="Rect2i" /> <description> Constructs a [Rect2] from a [Rect2i]. </description> </method> <method name="Rect2" qualifiers="constructor"> - <return type="Rect2"> - </return> - <argument index="0" name="position" type="Vector2"> - </argument> - <argument index="1" name="size" type="Vector2"> - </argument> + <return type="Rect2" /> + <argument index="0" name="position" type="Vector2" /> + <argument index="1" name="size" type="Vector2" /> <description> Constructs a [Rect2] by position and size. </description> </method> <method name="Rect2" qualifiers="constructor"> - <return type="Rect2"> - </return> - <argument index="0" name="x" type="float"> - </argument> - <argument index="1" name="y" type="float"> - </argument> - <argument index="2" name="width" type="float"> - </argument> - <argument index="3" name="height" type="float"> - </argument> + <return type="Rect2" /> + <argument index="0" name="x" type="float" /> + <argument index="1" name="y" type="float" /> + <argument index="2" name="width" type="float" /> + <argument index="3" name="height" type="float" /> <description> Constructs a [Rect2] by x, y, width, and height. </description> </method> <method name="abs" qualifiers="const"> - <return type="Rect2"> - </return> + <return type="Rect2" /> <description> Returns a [Rect2] with equivalent position and area, modified so that the top-left corner is the origin and [code]width[/code] and [code]height[/code] are positive. </description> </method> <method name="encloses" qualifiers="const"> - <return type="bool"> - </return> - <argument index="0" name="b" type="Rect2"> - </argument> + <return type="bool" /> + <argument index="0" name="b" type="Rect2" /> <description> Returns [code]true[/code] if this [Rect2] completely encloses another one. </description> </method> <method name="expand" qualifiers="const"> - <return type="Rect2"> - </return> - <argument index="0" name="to" type="Vector2"> - </argument> + <return type="Rect2" /> + <argument index="0" name="to" type="Vector2" /> <description> Returns this [Rect2] expanded to include a given point. </description> </method> <method name="get_area" qualifiers="const"> - <return type="float"> - </return> + <return type="float" /> <description> Returns the area of the [Rect2]. </description> </method> <method name="grow" qualifiers="const"> - <return type="Rect2"> - </return> - <argument index="0" name="amount" type="float"> - </argument> + <return type="Rect2" /> + <argument index="0" name="amount" type="float" /> <description> Returns a copy of the [Rect2] grown by the specified [code]amount[/code] on all sides. </description> </method> <method name="grow_individual" qualifiers="const"> - <return type="Rect2"> - </return> - <argument index="0" name="left" type="float"> - </argument> - <argument index="1" name="top" type="float"> - </argument> - <argument index="2" name="right" type="float"> - </argument> - <argument index="3" name="bottom" type="float"> - </argument> + <return type="Rect2" /> + <argument index="0" name="left" type="float" /> + <argument index="1" name="top" type="float" /> + <argument index="2" name="right" type="float" /> + <argument index="3" name="bottom" type="float" /> <description> Returns a copy of the [Rect2] grown by the specified amount on each side individually. </description> </method> <method name="grow_side" qualifiers="const"> - <return type="Rect2"> - </return> - <argument index="0" name="side" type="int"> - </argument> - <argument index="1" name="amount" type="float"> - </argument> + <return type="Rect2" /> + <argument index="0" name="side" type="int" /> + <argument index="1" name="amount" type="float" /> <description> Returns a copy of the [Rect2] grown by the specified [code]amount[/code] on the specified [enum Side]. </description> </method> <method name="has_no_area" qualifiers="const"> - <return type="bool"> - </return> + <return type="bool" /> <description> Returns [code]true[/code] if the [Rect2] is flat or empty. </description> </method> <method name="has_point" qualifiers="const"> - <return type="bool"> - </return> - <argument index="0" name="point" type="Vector2"> - </argument> + <return type="bool" /> + <argument index="0" name="point" type="Vector2" /> <description> Returns [code]true[/code] if the [Rect2] contains a point. </description> </method> <method name="intersection" qualifiers="const"> - <return type="Rect2"> - </return> - <argument index="0" name="b" type="Rect2"> - </argument> + <return type="Rect2" /> + <argument index="0" name="b" type="Rect2" /> <description> Returns the intersection of this [Rect2] and [code]b[/code]. If the rectangles do not intersect, an empty [Rect2] is returned. </description> </method> <method name="intersects" qualifiers="const"> - <return type="bool"> - </return> - <argument index="0" name="b" type="Rect2"> - </argument> - <argument index="1" name="include_borders" type="bool" default="false"> - </argument> + <return type="bool" /> + <argument index="0" name="b" type="Rect2" /> + <argument index="1" name="include_borders" type="bool" default="false" /> <description> Returns [code]true[/code] if the [Rect2] overlaps with [code]b[/code] (i.e. they have at least one point in common). If [code]include_borders[/code] is [code]true[/code], they will also be considered overlapping if their borders touch, even without intersection. </description> </method> <method name="is_equal_approx" qualifiers="const"> - <return type="bool"> - </return> - <argument index="0" name="rect" type="Rect2"> - </argument> + <return type="bool" /> + <argument index="0" name="rect" type="Rect2" /> <description> Returns [code]true[/code] if this [Rect2] and [code]rect[/code] are approximately equal, by calling [code]is_equal_approx[/code] on each component. </description> </method> <method name="merge" qualifiers="const"> - <return type="Rect2"> - </return> - <argument index="0" name="b" type="Rect2"> - </argument> + <return type="Rect2" /> + <argument index="0" name="b" type="Rect2" /> <description> Returns a larger [Rect2] that contains this [Rect2] and [code]b[/code]. </description> </method> <method name="operator !=" qualifiers="operator"> - <return type="bool"> - </return> - <argument index="0" name="right" type="Rect2"> - </argument> + <return type="bool" /> + <argument index="0" name="right" type="Rect2" /> <description> </description> </method> <method name="operator *" qualifiers="operator"> - <return type="Rect2"> - </return> - <argument index="0" name="right" type="Transform2D"> - </argument> + <return type="Rect2" /> + <argument index="0" name="right" type="Transform2D" /> <description> </description> </method> <method name="operator ==" qualifiers="operator"> - <return type="bool"> - </return> - <argument index="0" name="right" type="Rect2"> - </argument> + <return type="bool" /> + <argument index="0" name="right" type="Rect2" /> <description> </description> </method> diff --git a/doc/classes/Rect2i.xml b/doc/classes/Rect2i.xml index 67d148084f..a75c31a007 100644 --- a/doc/classes/Rect2i.xml +++ b/doc/classes/Rect2i.xml @@ -13,181 +13,139 @@ </tutorials> <methods> <method name="Rect2i" qualifiers="constructor"> - <return type="Rect2i"> - </return> + <return type="Rect2i" /> <description> Constructs a default-initialized [Rect2i] with default (zero) values of [member position] and [member size]. </description> </method> <method name="Rect2i" qualifiers="constructor"> - <return type="Rect2i"> - </return> - <argument index="0" name="from" type="Rect2i"> - </argument> + <return type="Rect2i" /> + <argument index="0" name="from" type="Rect2i" /> <description> Constructs a [Rect2i] as a copy of the given [Rect2i]. </description> </method> <method name="Rect2i" qualifiers="constructor"> - <return type="Rect2i"> - </return> - <argument index="0" name="from" type="Rect2"> - </argument> + <return type="Rect2i" /> + <argument index="0" name="from" type="Rect2" /> <description> Constructs a new [Rect2i] from [Rect2]. The floating point coordinates will be truncated. </description> </method> <method name="Rect2i" qualifiers="constructor"> - <return type="Rect2i"> - </return> - <argument index="0" name="position" type="Vector2i"> - </argument> - <argument index="1" name="size" type="Vector2i"> - </argument> + <return type="Rect2i" /> + <argument index="0" name="position" type="Vector2i" /> + <argument index="1" name="size" type="Vector2i" /> <description> Constructs a [Rect2i] by position and size. </description> </method> <method name="Rect2i" qualifiers="constructor"> - <return type="Rect2i"> - </return> - <argument index="0" name="x" type="int"> - </argument> - <argument index="1" name="y" type="int"> - </argument> - <argument index="2" name="width" type="int"> - </argument> - <argument index="3" name="height" type="int"> - </argument> + <return type="Rect2i" /> + <argument index="0" name="x" type="int" /> + <argument index="1" name="y" type="int" /> + <argument index="2" name="width" type="int" /> + <argument index="3" name="height" type="int" /> <description> Constructs a [Rect2i] by x, y, width, and height. </description> </method> <method name="abs" qualifiers="const"> - <return type="Rect2i"> - </return> + <return type="Rect2i" /> <description> Returns a [Rect2i] with equivalent position and area, modified so that the top-left corner is the origin and [code]width[/code] and [code]height[/code] are positive. </description> </method> <method name="encloses" qualifiers="const"> - <return type="bool"> - </return> - <argument index="0" name="b" type="Rect2i"> - </argument> + <return type="bool" /> + <argument index="0" name="b" type="Rect2i" /> <description> Returns [code]true[/code] if this [Rect2i] completely encloses another one. </description> </method> <method name="expand" qualifiers="const"> - <return type="Rect2i"> - </return> - <argument index="0" name="to" type="Vector2i"> - </argument> + <return type="Rect2i" /> + <argument index="0" name="to" type="Vector2i" /> <description> Returns this [Rect2i] expanded to include a given point. </description> </method> <method name="get_area" qualifiers="const"> - <return type="int"> - </return> + <return type="int" /> <description> Returns the area of the [Rect2i]. </description> </method> <method name="grow" qualifiers="const"> - <return type="Rect2i"> - </return> - <argument index="0" name="amount" type="int"> - </argument> + <return type="Rect2i" /> + <argument index="0" name="amount" type="int" /> <description> Returns a copy of the [Rect2i] grown by the specified [code]amount[/code] on all sides. </description> </method> <method name="grow_individual" qualifiers="const"> - <return type="Rect2i"> - </return> - <argument index="0" name="left" type="int"> - </argument> - <argument index="1" name="top" type="int"> - </argument> - <argument index="2" name="right" type="int"> - </argument> - <argument index="3" name="bottom" type="int"> - </argument> + <return type="Rect2i" /> + <argument index="0" name="left" type="int" /> + <argument index="1" name="top" type="int" /> + <argument index="2" name="right" type="int" /> + <argument index="3" name="bottom" type="int" /> <description> Returns a copy of the [Rect2i] grown by the specified amount on each side individually. </description> </method> <method name="grow_side" qualifiers="const"> - <return type="Rect2i"> - </return> - <argument index="0" name="side" type="int"> - </argument> - <argument index="1" name="amount" type="int"> - </argument> + <return type="Rect2i" /> + <argument index="0" name="side" type="int" /> + <argument index="1" name="amount" type="int" /> <description> Returns a copy of the [Rect2i] grown by the specified [code]amount[/code] on the specified [enum Side]. </description> </method> <method name="has_no_area" qualifiers="const"> - <return type="bool"> - </return> + <return type="bool" /> <description> Returns [code]true[/code] if the [Rect2i] is flat or empty. </description> </method> <method name="has_point" qualifiers="const"> - <return type="bool"> - </return> - <argument index="0" name="point" type="Vector2i"> - </argument> + <return type="bool" /> + <argument index="0" name="point" type="Vector2i" /> <description> Returns [code]true[/code] if the [Rect2i] contains a point. </description> </method> <method name="intersection" qualifiers="const"> - <return type="Rect2i"> - </return> - <argument index="0" name="b" type="Rect2i"> - </argument> + <return type="Rect2i" /> + <argument index="0" name="b" type="Rect2i" /> <description> Returns the intersection of this [Rect2i] and [code]b[/code]. If the rectangles do not intersect, an empty [Rect2i] is returned. </description> </method> <method name="intersects" qualifiers="const"> - <return type="bool"> - </return> - <argument index="0" name="b" type="Rect2i"> - </argument> + <return type="bool" /> + <argument index="0" name="b" type="Rect2i" /> <description> Returns [code]true[/code] if the [Rect2i] overlaps with [code]b[/code] (i.e. they have at least one point in common). If [code]include_borders[/code] is [code]true[/code], they will also be considered overlapping if their borders touch, even without intersection. </description> </method> <method name="merge" qualifiers="const"> - <return type="Rect2i"> - </return> - <argument index="0" name="b" type="Rect2i"> - </argument> + <return type="Rect2i" /> + <argument index="0" name="b" type="Rect2i" /> <description> Returns a larger [Rect2i] that contains this [Rect2i] and [code]b[/code]. </description> </method> <method name="operator !=" qualifiers="operator"> - <return type="bool"> - </return> - <argument index="0" name="right" type="Rect2i"> - </argument> + <return type="bool" /> + <argument index="0" name="right" type="Rect2i" /> <description> </description> </method> <method name="operator ==" qualifiers="operator"> - <return type="bool"> - </return> - <argument index="0" name="right" type="Rect2i"> - </argument> + <return type="bool" /> + <argument index="0" name="right" type="Rect2i" /> <description> </description> </method> diff --git a/doc/classes/RefCounted.xml b/doc/classes/RefCounted.xml index cf96514203..bf52c34777 100644 --- a/doc/classes/RefCounted.xml +++ b/doc/classes/RefCounted.xml @@ -14,24 +14,21 @@ </tutorials> <methods> <method name="init_ref"> - <return type="bool"> - </return> + <return type="bool" /> <description> Initializes the internal reference counter. Use this only if you really know what you are doing. Returns whether the initialization was successful. </description> </method> <method name="reference"> - <return type="bool"> - </return> + <return type="bool" /> <description> Increments the internal reference counter. Use this only if you really know what you are doing. Returns [code]true[/code] if the increment was successful, [code]false[/code] otherwise. </description> </method> <method name="unreference"> - <return type="bool"> - </return> + <return type="bool" /> <description> Decrements the internal reference counter. Use this only if you really know what you are doing. Returns [code]true[/code] if the decrement was successful, [code]false[/code] otherwise. diff --git a/doc/classes/RemoteTransform2D.xml b/doc/classes/RemoteTransform2D.xml index 84ec673920..613726b555 100644 --- a/doc/classes/RemoteTransform2D.xml +++ b/doc/classes/RemoteTransform2D.xml @@ -11,8 +11,7 @@ </tutorials> <methods> <method name="force_update_cache"> - <return type="void"> - </return> + <return type="void" /> <description> [RemoteTransform2D] caches the remote node. It may not notice if the remote node disappears; [method force_update_cache] forces it to update the cache again. </description> diff --git a/doc/classes/RemoteTransform3D.xml b/doc/classes/RemoteTransform3D.xml index 453177496f..cc19d5c25d 100644 --- a/doc/classes/RemoteTransform3D.xml +++ b/doc/classes/RemoteTransform3D.xml @@ -11,8 +11,7 @@ </tutorials> <methods> <method name="force_update_cache"> - <return type="void"> - </return> + <return type="void" /> <description> [RemoteTransform3D] caches the remote node. It may not notice if the remote node disappears; [method force_update_cache] forces it to update the cache again. </description> diff --git a/doc/classes/RenderingDevice.xml b/doc/classes/RenderingDevice.xml index 901a985961..c017bcaa1a 100644 --- a/doc/classes/RenderingDevice.xml +++ b/doc/classes/RenderingDevice.xml @@ -8,888 +8,627 @@ </tutorials> <methods> <method name="barrier"> - <return type="void"> - </return> - <argument index="0" name="from" type="int" default="7"> - </argument> - <argument index="1" name="to" type="int" default="7"> - </argument> + <return type="void" /> + <argument index="0" name="from" type="int" default="7" /> + <argument index="1" name="to" type="int" default="7" /> <description> </description> </method> <method name="buffer_clear"> - <return type="int" enum="Error"> - </return> - <argument index="0" name="buffer" type="RID"> - </argument> - <argument index="1" name="offset" type="int"> - </argument> - <argument index="2" name="size_bytes" type="int"> - </argument> - <argument index="3" name="post_barrier" type="int" default="7"> - </argument> + <return type="int" enum="Error" /> + <argument index="0" name="buffer" type="RID" /> + <argument index="1" name="offset" type="int" /> + <argument index="2" name="size_bytes" type="int" /> + <argument index="3" name="post_barrier" type="int" default="7" /> <description> </description> </method> <method name="buffer_get_data"> - <return type="PackedByteArray"> - </return> - <argument index="0" name="buffer" type="RID"> - </argument> + <return type="PackedByteArray" /> + <argument index="0" name="buffer" type="RID" /> <description> </description> </method> <method name="buffer_update"> - <return type="int" enum="Error"> - </return> - <argument index="0" name="buffer" type="RID"> - </argument> - <argument index="1" name="offset" type="int"> - </argument> - <argument index="2" name="size_bytes" type="int"> - </argument> - <argument index="3" name="data" type="PackedByteArray"> - </argument> - <argument index="4" name="post_barrier" type="int" default="7"> - </argument> + <return type="int" enum="Error" /> + <argument index="0" name="buffer" type="RID" /> + <argument index="1" name="offset" type="int" /> + <argument index="2" name="size_bytes" type="int" /> + <argument index="3" name="data" type="PackedByteArray" /> + <argument index="4" name="post_barrier" type="int" default="7" /> <description> </description> </method> <method name="capture_timestamp"> - <return type="void"> - </return> - <argument index="0" name="name" type="String"> - </argument> + <return type="void" /> + <argument index="0" name="name" type="String" /> <description> </description> </method> <method name="compute_list_add_barrier"> - <return type="void"> - </return> - <argument index="0" name="compute_list" type="int"> - </argument> + <return type="void" /> + <argument index="0" name="compute_list" type="int" /> <description> </description> </method> <method name="compute_list_begin"> - <return type="int"> - </return> - <argument index="0" name="allow_draw_overlap" type="bool" default="false"> - </argument> + <return type="int" /> + <argument index="0" name="allow_draw_overlap" type="bool" default="false" /> <description> </description> </method> <method name="compute_list_bind_compute_pipeline"> - <return type="void"> - </return> - <argument index="0" name="compute_list" type="int"> - </argument> - <argument index="1" name="compute_pipeline" type="RID"> - </argument> + <return type="void" /> + <argument index="0" name="compute_list" type="int" /> + <argument index="1" name="compute_pipeline" type="RID" /> <description> </description> </method> <method name="compute_list_bind_uniform_set"> - <return type="void"> - </return> - <argument index="0" name="compute_list" type="int"> - </argument> - <argument index="1" name="uniform_set" type="RID"> - </argument> - <argument index="2" name="set_index" type="int"> - </argument> + <return type="void" /> + <argument index="0" name="compute_list" type="int" /> + <argument index="1" name="uniform_set" type="RID" /> + <argument index="2" name="set_index" type="int" /> <description> </description> </method> <method name="compute_list_dispatch"> - <return type="void"> - </return> - <argument index="0" name="compute_list" type="int"> - </argument> - <argument index="1" name="x_groups" type="int"> - </argument> - <argument index="2" name="y_groups" type="int"> - </argument> - <argument index="3" name="z_groups" type="int"> - </argument> + <return type="void" /> + <argument index="0" name="compute_list" type="int" /> + <argument index="1" name="x_groups" type="int" /> + <argument index="2" name="y_groups" type="int" /> + <argument index="3" name="z_groups" type="int" /> <description> </description> </method> <method name="compute_list_end"> - <return type="void"> - </return> - <argument index="0" name="post_barrier" type="int" default="7"> - </argument> + <return type="void" /> + <argument index="0" name="post_barrier" type="int" default="7" /> <description> </description> </method> <method name="compute_list_set_push_constant"> - <return type="void"> - </return> - <argument index="0" name="compute_list" type="int"> - </argument> - <argument index="1" name="buffer" type="PackedByteArray"> - </argument> - <argument index="2" name="size_bytes" type="int"> - </argument> + <return type="void" /> + <argument index="0" name="compute_list" type="int" /> + <argument index="1" name="buffer" type="PackedByteArray" /> + <argument index="2" name="size_bytes" type="int" /> <description> </description> </method> <method name="compute_pipeline_create"> - <return type="RID"> - </return> - <argument index="0" name="shader" type="RID"> - </argument> - <argument index="1" name="specialization_constants" type="RDPipelineSpecializationConstant[]" default="[]"> - </argument> + <return type="RID" /> + <argument index="0" name="shader" type="RID" /> + <argument index="1" name="specialization_constants" type="RDPipelineSpecializationConstant[]" default="[]" /> <description> </description> </method> <method name="compute_pipeline_is_valid"> - <return type="bool"> - </return> - <argument index="0" name="compute_pieline" type="RID"> - </argument> + <return type="bool" /> + <argument index="0" name="compute_pieline" type="RID" /> <description> </description> </method> <method name="create_local_device"> - <return type="RenderingDevice"> - </return> + <return type="RenderingDevice" /> <description> </description> </method> <method name="draw_command_begin_label"> - <return type="void"> - </return> - <argument index="0" name="name" type="String"> - </argument> - <argument index="1" name="color" type="Color"> - </argument> + <return type="void" /> + <argument index="0" name="name" type="String" /> + <argument index="1" name="color" type="Color" /> <description> </description> </method> <method name="draw_command_end_label"> - <return type="void"> - </return> + <return type="void" /> <description> </description> </method> <method name="draw_command_insert_label"> - <return type="void"> - </return> - <argument index="0" name="name" type="String"> - </argument> - <argument index="1" name="color" type="Color"> - </argument> + <return type="void" /> + <argument index="0" name="name" type="String" /> + <argument index="1" name="color" type="Color" /> <description> </description> </method> <method name="draw_list_begin"> - <return type="int"> - </return> - <argument index="0" name="framebuffer" type="RID"> - </argument> - <argument index="1" name="initial_color_action" type="int" enum="RenderingDevice.InitialAction"> - </argument> - <argument index="2" name="final_color_action" type="int" enum="RenderingDevice.FinalAction"> - </argument> - <argument index="3" name="initial_depth_action" type="int" enum="RenderingDevice.InitialAction"> - </argument> - <argument index="4" name="final_depth_action" type="int" enum="RenderingDevice.FinalAction"> - </argument> - <argument index="5" name="clear_color_values" type="PackedColorArray" default="PackedColorArray()"> - </argument> - <argument index="6" name="clear_depth" type="float" default="1.0"> - </argument> - <argument index="7" name="clear_stencil" type="int" default="0"> - </argument> - <argument index="8" name="region" type="Rect2" default="Rect2i(0, 0, 0, 0)"> - </argument> - <argument index="9" name="storage_textures" type="Array" default="[]"> - </argument> + <return type="int" /> + <argument index="0" name="framebuffer" type="RID" /> + <argument index="1" name="initial_color_action" type="int" enum="RenderingDevice.InitialAction" /> + <argument index="2" name="final_color_action" type="int" enum="RenderingDevice.FinalAction" /> + <argument index="3" name="initial_depth_action" type="int" enum="RenderingDevice.InitialAction" /> + <argument index="4" name="final_depth_action" type="int" enum="RenderingDevice.FinalAction" /> + <argument index="5" name="clear_color_values" type="PackedColorArray" default="PackedColorArray()" /> + <argument index="6" name="clear_depth" type="float" default="1.0" /> + <argument index="7" name="clear_stencil" type="int" default="0" /> + <argument index="8" name="region" type="Rect2" default="Rect2i(0, 0, 0, 0)" /> + <argument index="9" name="storage_textures" type="Array" default="[]" /> <description> </description> </method> <method name="draw_list_begin_for_screen"> - <return type="int"> - </return> - <argument index="0" name="screen" type="int" default="0"> - </argument> - <argument index="1" name="clear_color" type="Color" default="Color(0, 0, 0, 1)"> - </argument> + <return type="int" /> + <argument index="0" name="screen" type="int" default="0" /> + <argument index="1" name="clear_color" type="Color" default="Color(0, 0, 0, 1)" /> <description> </description> </method> <method name="draw_list_begin_split"> - <return type="PackedInt64Array"> - </return> - <argument index="0" name="framebuffer" type="RID"> - </argument> - <argument index="1" name="splits" type="int"> - </argument> - <argument index="2" name="initial_color_action" type="int" enum="RenderingDevice.InitialAction"> - </argument> - <argument index="3" name="final_color_action" type="int" enum="RenderingDevice.FinalAction"> - </argument> - <argument index="4" name="initial_depth_action" type="int" enum="RenderingDevice.InitialAction"> - </argument> - <argument index="5" name="final_depth_action" type="int" enum="RenderingDevice.FinalAction"> - </argument> - <argument index="6" name="clear_color_values" type="PackedColorArray" default="PackedColorArray()"> - </argument> - <argument index="7" name="clear_depth" type="float" default="1.0"> - </argument> - <argument index="8" name="clear_stencil" type="int" default="0"> - </argument> - <argument index="9" name="region" type="Rect2" default="Rect2i(0, 0, 0, 0)"> - </argument> - <argument index="10" name="storage_textures" type="RID[]" default="[]"> - </argument> + <return type="PackedInt64Array" /> + <argument index="0" name="framebuffer" type="RID" /> + <argument index="1" name="splits" type="int" /> + <argument index="2" name="initial_color_action" type="int" enum="RenderingDevice.InitialAction" /> + <argument index="3" name="final_color_action" type="int" enum="RenderingDevice.FinalAction" /> + <argument index="4" name="initial_depth_action" type="int" enum="RenderingDevice.InitialAction" /> + <argument index="5" name="final_depth_action" type="int" enum="RenderingDevice.FinalAction" /> + <argument index="6" name="clear_color_values" type="PackedColorArray" default="PackedColorArray()" /> + <argument index="7" name="clear_depth" type="float" default="1.0" /> + <argument index="8" name="clear_stencil" type="int" default="0" /> + <argument index="9" name="region" type="Rect2" default="Rect2i(0, 0, 0, 0)" /> + <argument index="10" name="storage_textures" type="RID[]" default="[]" /> <description> </description> </method> <method name="draw_list_bind_index_array"> - <return type="void"> - </return> - <argument index="0" name="draw_list" type="int"> - </argument> - <argument index="1" name="index_array" type="RID"> - </argument> + <return type="void" /> + <argument index="0" name="draw_list" type="int" /> + <argument index="1" name="index_array" type="RID" /> <description> </description> </method> <method name="draw_list_bind_render_pipeline"> - <return type="void"> - </return> - <argument index="0" name="draw_list" type="int"> - </argument> - <argument index="1" name="render_pipeline" type="RID"> - </argument> + <return type="void" /> + <argument index="0" name="draw_list" type="int" /> + <argument index="1" name="render_pipeline" type="RID" /> <description> </description> </method> <method name="draw_list_bind_uniform_set"> - <return type="void"> - </return> - <argument index="0" name="draw_list" type="int"> - </argument> - <argument index="1" name="uniform_set" type="RID"> - </argument> - <argument index="2" name="set_index" type="int"> - </argument> + <return type="void" /> + <argument index="0" name="draw_list" type="int" /> + <argument index="1" name="uniform_set" type="RID" /> + <argument index="2" name="set_index" type="int" /> <description> </description> </method> <method name="draw_list_bind_vertex_array"> - <return type="void"> - </return> - <argument index="0" name="draw_list" type="int"> - </argument> - <argument index="1" name="vertex_array" type="RID"> - </argument> + <return type="void" /> + <argument index="0" name="draw_list" type="int" /> + <argument index="1" name="vertex_array" type="RID" /> <description> </description> </method> <method name="draw_list_disable_scissor"> - <return type="void"> - </return> - <argument index="0" name="draw_list" type="int"> - </argument> + <return type="void" /> + <argument index="0" name="draw_list" type="int" /> <description> </description> </method> <method name="draw_list_draw"> - <return type="void"> - </return> - <argument index="0" name="draw_list" type="int"> - </argument> - <argument index="1" name="use_indices" type="bool"> - </argument> - <argument index="2" name="instances" type="int"> - </argument> - <argument index="3" name="procedural_vertex_count" type="int" default="0"> - </argument> + <return type="void" /> + <argument index="0" name="draw_list" type="int" /> + <argument index="1" name="use_indices" type="bool" /> + <argument index="2" name="instances" type="int" /> + <argument index="3" name="procedural_vertex_count" type="int" default="0" /> <description> </description> </method> <method name="draw_list_enable_scissor"> - <return type="void"> - </return> - <argument index="0" name="draw_list" type="int"> - </argument> - <argument index="1" name="rect" type="Rect2" default="Rect2i(0, 0, 0, 0)"> - </argument> + <return type="void" /> + <argument index="0" name="draw_list" type="int" /> + <argument index="1" name="rect" type="Rect2" default="Rect2i(0, 0, 0, 0)" /> <description> </description> </method> <method name="draw_list_end"> - <return type="void"> - </return> - <argument index="0" name="post_barrier" type="int" default="7"> - </argument> + <return type="void" /> + <argument index="0" name="post_barrier" type="int" default="7" /> <description> </description> </method> <method name="draw_list_set_push_constant"> - <return type="void"> - </return> - <argument index="0" name="draw_list" type="int"> - </argument> - <argument index="1" name="buffer" type="PackedByteArray"> - </argument> - <argument index="2" name="size_bytes" type="int"> - </argument> + <return type="void" /> + <argument index="0" name="draw_list" type="int" /> + <argument index="1" name="buffer" type="PackedByteArray" /> + <argument index="2" name="size_bytes" type="int" /> <description> </description> </method> <method name="draw_list_switch_to_next_pass"> - <return type="int"> - </return> + <return type="int" /> <description> </description> </method> <method name="draw_list_switch_to_next_pass_split"> - <return type="PackedInt64Array"> - </return> - <argument index="0" name="splits" type="int"> - </argument> + <return type="PackedInt64Array" /> + <argument index="0" name="splits" type="int" /> <description> </description> </method> <method name="framebuffer_create"> - <return type="RID"> - </return> - <argument index="0" name="textures" type="RID[]"> - </argument> - <argument index="1" name="validate_with_format" type="int" default="-1"> - </argument> - <argument index="2" name="view_count" type="int" default="1"> - </argument> + <return type="RID" /> + <argument index="0" name="textures" type="RID[]" /> + <argument index="1" name="validate_with_format" type="int" default="-1" /> + <argument index="2" name="view_count" type="int" default="1" /> <description> </description> </method> <method name="framebuffer_create_empty"> - <return type="RID"> - </return> - <argument index="0" name="size" type="Vector2i"> - </argument> - <argument index="1" name="samples" type="int" enum="RenderingDevice.TextureSamples" default="0"> - </argument> - <argument index="2" name="validate_with_format" type="int" default="-1"> - </argument> + <return type="RID" /> + <argument index="0" name="size" type="Vector2i" /> + <argument index="1" name="samples" type="int" enum="RenderingDevice.TextureSamples" default="0" /> + <argument index="2" name="validate_with_format" type="int" default="-1" /> <description> </description> </method> <method name="framebuffer_create_multipass"> - <return type="RID"> - </return> - <argument index="0" name="textures" type="RID[]"> - </argument> - <argument index="1" name="passes" type="RDFramebufferPass[]"> - </argument> - <argument index="2" name="validate_with_format" type="int" default="-1"> - </argument> - <argument index="3" name="view_count" type="int" default="1"> - </argument> + <return type="RID" /> + <argument index="0" name="textures" type="RID[]" /> + <argument index="1" name="passes" type="RDFramebufferPass[]" /> + <argument index="2" name="validate_with_format" type="int" default="-1" /> + <argument index="3" name="view_count" type="int" default="1" /> <description> </description> </method> <method name="framebuffer_format_create"> - <return type="int"> - </return> - <argument index="0" name="attachments" type="RDAttachmentFormat[]"> - </argument> - <argument index="1" name="view_count" type="int" default="1"> - </argument> + <return type="int" /> + <argument index="0" name="attachments" type="RDAttachmentFormat[]" /> + <argument index="1" name="view_count" type="int" default="1" /> <description> </description> </method> <method name="framebuffer_format_create_empty"> - <return type="int"> - </return> - <argument index="0" name="samples" type="int" enum="RenderingDevice.TextureSamples" default="0"> - </argument> + <return type="int" /> + <argument index="0" name="samples" type="int" enum="RenderingDevice.TextureSamples" default="0" /> <description> </description> </method> <method name="framebuffer_format_create_multipass"> - <return type="int"> - </return> - <argument index="0" name="attachments" type="RDAttachmentFormat[]"> - </argument> - <argument index="1" name="passes" type="RDFramebufferPass[]"> - </argument> - <argument index="2" name="view_count" type="int" default="1"> - </argument> + <return type="int" /> + <argument index="0" name="attachments" type="RDAttachmentFormat[]" /> + <argument index="1" name="passes" type="RDFramebufferPass[]" /> + <argument index="2" name="view_count" type="int" default="1" /> <description> </description> </method> <method name="framebuffer_format_get_texture_samples"> - <return type="int" enum="RenderingDevice.TextureSamples"> - </return> - <argument index="0" name="format" type="int"> - </argument> - <argument index="1" name="render_pass" type="int" default="0"> - </argument> + <return type="int" enum="RenderingDevice.TextureSamples" /> + <argument index="0" name="format" type="int" /> + <argument index="1" name="render_pass" type="int" default="0" /> <description> </description> </method> <method name="framebuffer_get_format"> - <return type="int"> - </return> - <argument index="0" name="framebuffer" type="RID"> - </argument> + <return type="int" /> + <argument index="0" name="framebuffer" type="RID" /> <description> </description> </method> <method name="free"> - <return type="void"> - </return> - <argument index="0" name="rid" type="RID"> - </argument> + <return type="void" /> + <argument index="0" name="rid" type="RID" /> <description> </description> </method> <method name="full_barrier"> - <return type="void"> - </return> + <return type="void" /> <description> </description> </method> <method name="get_captured_timestamp_cpu_time" qualifiers="const"> - <return type="int"> - </return> - <argument index="0" name="index" type="int"> - </argument> + <return type="int" /> + <argument index="0" name="index" type="int" /> <description> </description> </method> <method name="get_captured_timestamp_gpu_time" qualifiers="const"> - <return type="int"> - </return> - <argument index="0" name="index" type="int"> - </argument> + <return type="int" /> + <argument index="0" name="index" type="int" /> <description> </description> </method> <method name="get_captured_timestamp_name" qualifiers="const"> - <return type="String"> - </return> - <argument index="0" name="index" type="int"> - </argument> + <return type="String" /> + <argument index="0" name="index" type="int" /> <description> </description> </method> <method name="get_captured_timestamps_count" qualifiers="const"> - <return type="int"> - </return> + <return type="int" /> <description> </description> </method> <method name="get_captured_timestamps_frame" qualifiers="const"> - <return type="int"> - </return> + <return type="int" /> <description> </description> </method> <method name="get_device_name" qualifiers="const"> - <return type="String"> - </return> + <return type="String" /> <description> </description> </method> <method name="get_device_pipeline_cache_uuid" qualifiers="const"> - <return type="String"> - </return> + <return type="String" /> <description> </description> </method> <method name="get_device_vendor_name" qualifiers="const"> - <return type="String"> - </return> + <return type="String" /> <description> </description> </method> <method name="get_frame_delay" qualifiers="const"> - <return type="int"> - </return> + <return type="int" /> <description> </description> </method> <method name="get_memory_usage" qualifiers="const"> - <return type="int"> - </return> - <argument index="0" name="arg0" type="int" enum="RenderingDevice.MemoryType"> - </argument> + <return type="int" /> + <argument index="0" name="arg0" type="int" enum="RenderingDevice.MemoryType" /> <description> </description> </method> <method name="index_array_create"> - <return type="RID"> - </return> - <argument index="0" name="index_buffer" type="RID"> - </argument> - <argument index="1" name="index_offset" type="int"> - </argument> - <argument index="2" name="index_count" type="int"> - </argument> + <return type="RID" /> + <argument index="0" name="index_buffer" type="RID" /> + <argument index="1" name="index_offset" type="int" /> + <argument index="2" name="index_count" type="int" /> <description> </description> </method> <method name="index_buffer_create"> - <return type="RID"> - </return> - <argument index="0" name="size_indices" type="int"> - </argument> - <argument index="1" name="format" type="int" enum="RenderingDevice.IndexBufferFormat"> - </argument> - <argument index="2" name="data" type="PackedByteArray" default="PackedByteArray()"> - </argument> - <argument index="3" name="use_restart_indices" type="bool" default="false"> - </argument> + <return type="RID" /> + <argument index="0" name="size_indices" type="int" /> + <argument index="1" name="format" type="int" enum="RenderingDevice.IndexBufferFormat" /> + <argument index="2" name="data" type="PackedByteArray" default="PackedByteArray()" /> + <argument index="3" name="use_restart_indices" type="bool" default="false" /> <description> </description> </method> <method name="limit_get"> - <return type="int"> - </return> - <argument index="0" name="limit" type="int" enum="RenderingDevice.Limit"> - </argument> + <return type="int" /> + <argument index="0" name="limit" type="int" enum="RenderingDevice.Limit" /> <description> </description> </method> <method name="render_pipeline_create"> - <return type="RID"> - </return> - <argument index="0" name="shader" type="RID"> - </argument> - <argument index="1" name="framebuffer_format" type="int"> - </argument> - <argument index="2" name="vertex_format" type="int"> - </argument> - <argument index="3" name="primitive" type="int" enum="RenderingDevice.RenderPrimitive"> - </argument> - <argument index="4" name="rasterization_state" type="RDPipelineRasterizationState"> - </argument> - <argument index="5" name="multisample_state" type="RDPipelineMultisampleState"> - </argument> - <argument index="6" name="stencil_state" type="RDPipelineDepthStencilState"> - </argument> - <argument index="7" name="color_blend_state" type="RDPipelineColorBlendState"> - </argument> - <argument index="8" name="dynamic_state_flags" type="int" default="0"> - </argument> - <argument index="9" name="for_render_pass" type="int" default="0"> - </argument> - <argument index="10" name="specialization_constants" type="RDPipelineSpecializationConstant[]" default="[]"> - </argument> + <return type="RID" /> + <argument index="0" name="shader" type="RID" /> + <argument index="1" name="framebuffer_format" type="int" /> + <argument index="2" name="vertex_format" type="int" /> + <argument index="3" name="primitive" type="int" enum="RenderingDevice.RenderPrimitive" /> + <argument index="4" name="rasterization_state" type="RDPipelineRasterizationState" /> + <argument index="5" name="multisample_state" type="RDPipelineMultisampleState" /> + <argument index="6" name="stencil_state" type="RDPipelineDepthStencilState" /> + <argument index="7" name="color_blend_state" type="RDPipelineColorBlendState" /> + <argument index="8" name="dynamic_state_flags" type="int" default="0" /> + <argument index="9" name="for_render_pass" type="int" default="0" /> + <argument index="10" name="specialization_constants" type="RDPipelineSpecializationConstant[]" default="[]" /> <description> </description> </method> <method name="render_pipeline_is_valid"> - <return type="bool"> - </return> - <argument index="0" name="render_pipeline" type="RID"> - </argument> + <return type="bool" /> + <argument index="0" name="render_pipeline" type="RID" /> <description> </description> </method> <method name="sampler_create"> - <return type="RID"> - </return> - <argument index="0" name="state" type="RDSamplerState"> - </argument> + <return type="RID" /> + <argument index="0" name="state" type="RDSamplerState" /> <description> </description> </method> <method name="screen_get_framebuffer_format" qualifiers="const"> - <return type="int"> - </return> + <return type="int" /> <description> </description> </method> <method name="screen_get_height" qualifiers="const"> - <return type="int"> - </return> - <argument index="0" name="screen" type="int" default="0"> - </argument> + <return type="int" /> + <argument index="0" name="screen" type="int" default="0" /> <description> </description> </method> <method name="screen_get_width" qualifiers="const"> - <return type="int"> - </return> - <argument index="0" name="screen" type="int" default="0"> - </argument> + <return type="int" /> + <argument index="0" name="screen" type="int" default="0" /> <description> </description> </method> <method name="set_resource_name"> - <return type="void"> - </return> - <argument index="0" name="id" type="RID"> - </argument> - <argument index="1" name="name" type="String"> - </argument> + <return type="void" /> + <argument index="0" name="id" type="RID" /> + <argument index="1" name="name" type="String" /> <description> </description> </method> - <method name="shader_compile_from_source"> - <return type="RDShaderBytecode"> - </return> - <argument index="0" name="shader_source" type="RDShaderSource"> - </argument> - <argument index="1" name="allow_cache" type="bool" default="true"> - </argument> + <method name="shader_compile_binary_from_spirv"> + <return type="PackedByteArray" /> + <argument index="0" name="spirv_data" type="RDShaderSPIRV" /> <description> </description> </method> - <method name="shader_create"> - <return type="RID"> - </return> - <argument index="0" name="shader_data" type="RDShaderBytecode"> - </argument> + <method name="shader_compile_spirv_from_source"> + <return type="RDShaderSPIRV" /> + <argument index="0" name="shader_source" type="RDShaderSource" /> + <argument index="1" name="allow_cache" type="bool" default="true" /> + <description> + </description> + </method> + <method name="shader_create_from_bytecode"> + <return type="RID" /> + <argument index="0" name="binary_data" type="PackedByteArray" /> + <description> + </description> + </method> + <method name="shader_create_from_spirv"> + <return type="PackedByteArray" /> + <argument index="0" name="spirv_data" type="RDShaderSPIRV" /> <description> </description> </method> <method name="shader_get_vertex_input_attribute_mask"> - <return type="int"> - </return> - <argument index="0" name="shader" type="RID"> - </argument> + <return type="int" /> + <argument index="0" name="shader" type="RID" /> <description> </description> </method> <method name="storage_buffer_create"> - <return type="RID"> - </return> - <argument index="0" name="size_bytes" type="int"> - </argument> - <argument index="1" name="data" type="PackedByteArray" default="PackedByteArray()"> - </argument> - <argument index="2" name="usage" type="int" default="0"> - </argument> + <return type="RID" /> + <argument index="0" name="size_bytes" type="int" /> + <argument index="1" name="data" type="PackedByteArray" default="PackedByteArray()" /> + <argument index="2" name="usage" type="int" default="0" /> <description> </description> </method> <method name="submit"> - <return type="void"> - </return> + <return type="void" /> <description> </description> </method> <method name="sync"> - <return type="void"> - </return> + <return type="void" /> <description> </description> </method> <method name="texture_buffer_create"> - <return type="RID"> - </return> - <argument index="0" name="size_bytes" type="int"> - </argument> - <argument index="1" name="format" type="int" enum="RenderingDevice.DataFormat"> - </argument> - <argument index="2" name="data" type="PackedByteArray" default="PackedByteArray()"> - </argument> + <return type="RID" /> + <argument index="0" name="size_bytes" type="int" /> + <argument index="1" name="format" type="int" enum="RenderingDevice.DataFormat" /> + <argument index="2" name="data" type="PackedByteArray" default="PackedByteArray()" /> <description> </description> </method> <method name="texture_clear"> - <return type="int" enum="Error"> - </return> - <argument index="0" name="texture" type="RID"> - </argument> - <argument index="1" name="color" type="Color"> - </argument> - <argument index="2" name="base_mipmap" type="int"> - </argument> - <argument index="3" name="mipmap_count" type="int"> - </argument> - <argument index="4" name="base_layer" type="int"> - </argument> - <argument index="5" name="layer_count" type="int"> - </argument> - <argument index="6" name="post_barrier" type="int" default="7"> - </argument> + <return type="int" enum="Error" /> + <argument index="0" name="texture" type="RID" /> + <argument index="1" name="color" type="Color" /> + <argument index="2" name="base_mipmap" type="int" /> + <argument index="3" name="mipmap_count" type="int" /> + <argument index="4" name="base_layer" type="int" /> + <argument index="5" name="layer_count" type="int" /> + <argument index="6" name="post_barrier" type="int" default="7" /> <description> </description> </method> <method name="texture_copy"> - <return type="int" enum="Error"> - </return> - <argument index="0" name="from_texture" type="RID"> - </argument> - <argument index="1" name="to_texture" type="RID"> - </argument> - <argument index="2" name="from_pos" type="Vector3"> - </argument> - <argument index="3" name="to_pos" type="Vector3"> - </argument> - <argument index="4" name="size" type="Vector3"> - </argument> - <argument index="5" name="src_mipmap" type="int"> - </argument> - <argument index="6" name="dst_mipmap" type="int"> - </argument> - <argument index="7" name="src_layer" type="int"> - </argument> - <argument index="8" name="dst_layer" type="int"> - </argument> - <argument index="9" name="post_barrier" type="int" default="7"> - </argument> + <return type="int" enum="Error" /> + <argument index="0" name="from_texture" type="RID" /> + <argument index="1" name="to_texture" type="RID" /> + <argument index="2" name="from_pos" type="Vector3" /> + <argument index="3" name="to_pos" type="Vector3" /> + <argument index="4" name="size" type="Vector3" /> + <argument index="5" name="src_mipmap" type="int" /> + <argument index="6" name="dst_mipmap" type="int" /> + <argument index="7" name="src_layer" type="int" /> + <argument index="8" name="dst_layer" type="int" /> + <argument index="9" name="post_barrier" type="int" default="7" /> <description> </description> </method> <method name="texture_create"> - <return type="RID"> - </return> - <argument index="0" name="format" type="RDTextureFormat"> - </argument> - <argument index="1" name="view" type="RDTextureView"> - </argument> - <argument index="2" name="data" type="PackedByteArray[]" default="[]"> - </argument> + <return type="RID" /> + <argument index="0" name="format" type="RDTextureFormat" /> + <argument index="1" name="view" type="RDTextureView" /> + <argument index="2" name="data" type="PackedByteArray[]" default="[]" /> <description> </description> </method> <method name="texture_create_shared"> - <return type="RID"> - </return> - <argument index="0" name="view" type="RDTextureView"> - </argument> - <argument index="1" name="with_texture" type="RID"> - </argument> + <return type="RID" /> + <argument index="0" name="view" type="RDTextureView" /> + <argument index="1" name="with_texture" type="RID" /> <description> </description> </method> <method name="texture_create_shared_from_slice"> - <return type="RID"> - </return> - <argument index="0" name="view" type="RDTextureView"> - </argument> - <argument index="1" name="with_texture" type="RID"> - </argument> - <argument index="2" name="layer" type="int"> - </argument> - <argument index="3" name="mipmap" type="int"> - </argument> - <argument index="4" name="slice_type" type="int" enum="RenderingDevice.TextureSliceType" default="0"> - </argument> + <return type="RID" /> + <argument index="0" name="view" type="RDTextureView" /> + <argument index="1" name="with_texture" type="RID" /> + <argument index="2" name="layer" type="int" /> + <argument index="3" name="mipmap" type="int" /> + <argument index="4" name="slice_type" type="int" enum="RenderingDevice.TextureSliceType" default="0" /> <description> </description> </method> <method name="texture_get_data"> - <return type="PackedByteArray"> - </return> - <argument index="0" name="texture" type="RID"> - </argument> - <argument index="1" name="layer" type="int"> - </argument> + <return type="PackedByteArray" /> + <argument index="0" name="texture" type="RID" /> + <argument index="1" name="layer" type="int" /> <description> </description> </method> <method name="texture_is_format_supported_for_usage" qualifiers="const"> - <return type="bool"> - </return> - <argument index="0" name="format" type="int" enum="RenderingDevice.DataFormat"> - </argument> - <argument index="1" name="usage_flags" type="int"> - </argument> + <return type="bool" /> + <argument index="0" name="format" type="int" enum="RenderingDevice.DataFormat" /> + <argument index="1" name="usage_flags" type="int" /> <description> </description> </method> <method name="texture_is_shared"> - <return type="bool"> - </return> - <argument index="0" name="texture" type="RID"> - </argument> + <return type="bool" /> + <argument index="0" name="texture" type="RID" /> <description> </description> </method> <method name="texture_is_valid"> - <return type="bool"> - </return> - <argument index="0" name="texture" type="RID"> - </argument> + <return type="bool" /> + <argument index="0" name="texture" type="RID" /> <description> </description> </method> <method name="texture_resolve_multisample"> - <return type="int" enum="Error"> - </return> - <argument index="0" name="from_texture" type="RID"> - </argument> - <argument index="1" name="to_texture" type="RID"> - </argument> - <argument index="2" name="post_barrier" type="int" default="7"> - </argument> + <return type="int" enum="Error" /> + <argument index="0" name="from_texture" type="RID" /> + <argument index="1" name="to_texture" type="RID" /> + <argument index="2" name="post_barrier" type="int" default="7" /> <description> </description> </method> <method name="texture_update"> - <return type="int" enum="Error"> - </return> - <argument index="0" name="texture" type="RID"> - </argument> - <argument index="1" name="layer" type="int"> - </argument> - <argument index="2" name="data" type="PackedByteArray"> - </argument> - <argument index="3" name="post_barrier" type="int" default="7"> - </argument> + <return type="int" enum="Error" /> + <argument index="0" name="texture" type="RID" /> + <argument index="1" name="layer" type="int" /> + <argument index="2" name="data" type="PackedByteArray" /> + <argument index="3" name="post_barrier" type="int" default="7" /> <description> </description> </method> <method name="uniform_buffer_create"> - <return type="RID"> - </return> - <argument index="0" name="size_bytes" type="int"> - </argument> - <argument index="1" name="data" type="PackedByteArray" default="PackedByteArray()"> - </argument> + <return type="RID" /> + <argument index="0" name="size_bytes" type="int" /> + <argument index="1" name="data" type="PackedByteArray" default="PackedByteArray()" /> <description> </description> </method> <method name="uniform_set_create"> - <return type="RID"> - </return> - <argument index="0" name="uniforms" type="Array"> - </argument> - <argument index="1" name="shader" type="RID"> - </argument> - <argument index="2" name="shader_set" type="int"> - </argument> + <return type="RID" /> + <argument index="0" name="uniforms" type="Array" /> + <argument index="1" name="shader" type="RID" /> + <argument index="2" name="shader_set" type="int" /> <description> </description> </method> <method name="uniform_set_is_valid"> - <return type="bool"> - </return> - <argument index="0" name="uniform_set" type="RID"> - </argument> + <return type="bool" /> + <argument index="0" name="uniform_set" type="RID" /> <description> </description> </method> <method name="vertex_buffer_create"> - <return type="RID"> - </return> - <argument index="0" name="size_bytes" type="int"> - </argument> - <argument index="1" name="data" type="PackedByteArray" default="PackedByteArray()"> - </argument> - <argument index="2" name="use_as_storage" type="bool" default="false"> - </argument> + <return type="RID" /> + <argument index="0" name="size_bytes" type="int" /> + <argument index="1" name="data" type="PackedByteArray" default="PackedByteArray()" /> + <argument index="2" name="use_as_storage" type="bool" default="false" /> <description> </description> </method> <method name="vertex_format_create"> - <return type="int"> - </return> - <argument index="0" name="vertex_descriptions" type="RDVertexAttribute[]"> - </argument> + <return type="int" /> + <argument index="0" name="vertex_descriptions" type="RDVertexAttribute[]" /> <description> </description> </method> diff --git a/doc/classes/RenderingServer.xml b/doc/classes/RenderingServer.xml index 6b45653bf2..df8bfb7e34 100644 --- a/doc/classes/RenderingServer.xml +++ b/doc/classes/RenderingServer.xml @@ -19,1199 +19,840 @@ </tutorials> <methods> <method name="bake_render_uv2"> - <return type="Image[]"> - </return> - <argument index="0" name="base" type="RID"> - </argument> - <argument index="1" name="material_overrides" type="Array"> - </argument> - <argument index="2" name="image_size" type="Vector2i"> - </argument> + <return type="Image[]" /> + <argument index="0" name="base" type="RID" /> + <argument index="1" name="material_overrides" type="Array" /> + <argument index="2" name="image_size" type="Vector2i" /> <description> </description> </method> <method name="camera_create"> - <return type="RID"> - </return> + <return type="RID" /> <description> Creates a camera and adds it to the RenderingServer. It can be accessed with the RID that is returned. This RID will be used in all [code]camera_*[/code] RenderingServer functions. Once finished with your RID, you will want to free the RID using the RenderingServer's [method free_rid] static method. </description> </method> <method name="camera_effects_create"> - <return type="RID"> - </return> + <return type="RID" /> <description> </description> </method> <method name="camera_effects_set_custom_exposure"> - <return type="void"> - </return> - <argument index="0" name="camera_effects" type="RID"> - </argument> - <argument index="1" name="enable" type="bool"> - </argument> - <argument index="2" name="exposure" type="float"> - </argument> + <return type="void" /> + <argument index="0" name="camera_effects" type="RID" /> + <argument index="1" name="enable" type="bool" /> + <argument index="2" name="exposure" type="float" /> <description> </description> </method> <method name="camera_effects_set_dof_blur"> - <return type="void"> - </return> - <argument index="0" name="camera_effects" type="RID"> - </argument> - <argument index="1" name="far_enable" type="bool"> - </argument> - <argument index="2" name="far_distance" type="float"> - </argument> - <argument index="3" name="far_transition" type="float"> - </argument> - <argument index="4" name="near_enable" type="bool"> - </argument> - <argument index="5" name="near_distance" type="float"> - </argument> - <argument index="6" name="near_transition" type="float"> - </argument> - <argument index="7" name="amount" type="float"> - </argument> + <return type="void" /> + <argument index="0" name="camera_effects" type="RID" /> + <argument index="1" name="far_enable" type="bool" /> + <argument index="2" name="far_distance" type="float" /> + <argument index="3" name="far_transition" type="float" /> + <argument index="4" name="near_enable" type="bool" /> + <argument index="5" name="near_distance" type="float" /> + <argument index="6" name="near_transition" type="float" /> + <argument index="7" name="amount" type="float" /> <description> </description> </method> <method name="camera_effects_set_dof_blur_bokeh_shape"> - <return type="void"> - </return> - <argument index="0" name="shape" type="int" enum="RenderingServer.DOFBokehShape"> - </argument> + <return type="void" /> + <argument index="0" name="shape" type="int" enum="RenderingServer.DOFBokehShape" /> <description> </description> </method> <method name="camera_effects_set_dof_blur_quality"> - <return type="void"> - </return> - <argument index="0" name="quality" type="int" enum="RenderingServer.DOFBlurQuality"> - </argument> - <argument index="1" name="use_jitter" type="bool"> - </argument> + <return type="void" /> + <argument index="0" name="quality" type="int" enum="RenderingServer.DOFBlurQuality" /> + <argument index="1" name="use_jitter" type="bool" /> <description> </description> </method> <method name="camera_set_camera_effects"> - <return type="void"> - </return> - <argument index="0" name="camera" type="RID"> - </argument> - <argument index="1" name="effects" type="RID"> - </argument> + <return type="void" /> + <argument index="0" name="camera" type="RID" /> + <argument index="1" name="effects" type="RID" /> <description> </description> </method> <method name="camera_set_cull_mask"> - <return type="void"> - </return> - <argument index="0" name="camera" type="RID"> - </argument> - <argument index="1" name="layers" type="int"> - </argument> + <return type="void" /> + <argument index="0" name="camera" type="RID" /> + <argument index="1" name="layers" type="int" /> <description> Sets the cull mask associated with this camera. The cull mask describes which 3D layers are rendered by this camera. Equivalent to [member Camera3D.cull_mask]. </description> </method> <method name="camera_set_environment"> - <return type="void"> - </return> - <argument index="0" name="camera" type="RID"> - </argument> - <argument index="1" name="env" type="RID"> - </argument> + <return type="void" /> + <argument index="0" name="camera" type="RID" /> + <argument index="1" name="env" type="RID" /> <description> Sets the environment used by this camera. Equivalent to [member Camera3D.environment]. </description> </method> <method name="camera_set_frustum"> - <return type="void"> - </return> - <argument index="0" name="camera" type="RID"> - </argument> - <argument index="1" name="size" type="float"> - </argument> - <argument index="2" name="offset" type="Vector2"> - </argument> - <argument index="3" name="z_near" type="float"> - </argument> - <argument index="4" name="z_far" type="float"> - </argument> + <return type="void" /> + <argument index="0" name="camera" type="RID" /> + <argument index="1" name="size" type="float" /> + <argument index="2" name="offset" type="Vector2" /> + <argument index="3" name="z_near" type="float" /> + <argument index="4" name="z_far" type="float" /> <description> Sets camera to use frustum projection. This mode allows adjusting the [code]offset[/code] argument to create "tilted frustum" effects. </description> </method> <method name="camera_set_orthogonal"> - <return type="void"> - </return> - <argument index="0" name="camera" type="RID"> - </argument> - <argument index="1" name="size" type="float"> - </argument> - <argument index="2" name="z_near" type="float"> - </argument> - <argument index="3" name="z_far" type="float"> - </argument> + <return type="void" /> + <argument index="0" name="camera" type="RID" /> + <argument index="1" name="size" type="float" /> + <argument index="2" name="z_near" type="float" /> + <argument index="3" name="z_far" type="float" /> <description> Sets camera to use orthogonal projection, also known as orthographic projection. Objects remain the same size on the screen no matter how far away they are. </description> </method> <method name="camera_set_perspective"> - <return type="void"> - </return> - <argument index="0" name="camera" type="RID"> - </argument> - <argument index="1" name="fovy_degrees" type="float"> - </argument> - <argument index="2" name="z_near" type="float"> - </argument> - <argument index="3" name="z_far" type="float"> - </argument> + <return type="void" /> + <argument index="0" name="camera" type="RID" /> + <argument index="1" name="fovy_degrees" type="float" /> + <argument index="2" name="z_near" type="float" /> + <argument index="3" name="z_far" type="float" /> <description> Sets camera to use perspective projection. Objects on the screen becomes smaller when they are far away. </description> </method> <method name="camera_set_transform"> - <return type="void"> - </return> - <argument index="0" name="camera" type="RID"> - </argument> - <argument index="1" name="transform" type="Transform3D"> - </argument> + <return type="void" /> + <argument index="0" name="camera" type="RID" /> + <argument index="1" name="transform" type="Transform3D" /> <description> Sets [Transform3D] of camera. </description> </method> <method name="camera_set_use_vertical_aspect"> - <return type="void"> - </return> - <argument index="0" name="camera" type="RID"> - </argument> - <argument index="1" name="enable" type="bool"> - </argument> + <return type="void" /> + <argument index="0" name="camera" type="RID" /> + <argument index="1" name="enable" type="bool" /> <description> If [code]true[/code], preserves the horizontal aspect ratio which is equivalent to [constant Camera3D.KEEP_WIDTH]. If [code]false[/code], preserves the vertical aspect ratio which is equivalent to [constant Camera3D.KEEP_HEIGHT]. </description> </method> <method name="canvas_create"> - <return type="RID"> - </return> + <return type="RID" /> <description> Creates a canvas and returns the assigned [RID]. It can be accessed with the RID that is returned. This RID will be used in all [code]canvas_*[/code] RenderingServer functions. Once finished with your RID, you will want to free the RID using the RenderingServer's [method free_rid] static method. </description> </method> <method name="canvas_item_add_circle"> - <return type="void"> - </return> - <argument index="0" name="item" type="RID"> - </argument> - <argument index="1" name="pos" type="Vector2"> - </argument> - <argument index="2" name="radius" type="float"> - </argument> - <argument index="3" name="color" type="Color"> - </argument> + <return type="void" /> + <argument index="0" name="item" type="RID" /> + <argument index="1" name="pos" type="Vector2" /> + <argument index="2" name="radius" type="float" /> + <argument index="3" name="color" type="Color" /> <description> </description> </method> <method name="canvas_item_add_clip_ignore"> - <return type="void"> - </return> - <argument index="0" name="item" type="RID"> - </argument> - <argument index="1" name="ignore" type="bool"> - </argument> + <return type="void" /> + <argument index="0" name="item" type="RID" /> + <argument index="1" name="ignore" type="bool" /> <description> </description> </method> <method name="canvas_item_add_line"> - <return type="void"> - </return> - <argument index="0" name="item" type="RID"> - </argument> - <argument index="1" name="from" type="Vector2"> - </argument> - <argument index="2" name="to" type="Vector2"> - </argument> - <argument index="3" name="color" type="Color"> - </argument> - <argument index="4" name="width" type="float" default="1.0"> - </argument> + <return type="void" /> + <argument index="0" name="item" type="RID" /> + <argument index="1" name="from" type="Vector2" /> + <argument index="2" name="to" type="Vector2" /> + <argument index="3" name="color" type="Color" /> + <argument index="4" name="width" type="float" default="1.0" /> <description> </description> </method> <method name="canvas_item_add_mesh"> - <return type="void"> - </return> - <argument index="0" name="item" type="RID"> - </argument> - <argument index="1" name="mesh" type="RID"> - </argument> - <argument index="2" name="transform" type="Transform2D" default="Transform2D(1, 0, 0, 1, 0, 0)"> - </argument> - <argument index="3" name="modulate" type="Color" default="Color(1, 1, 1, 1)"> - </argument> - <argument index="4" name="texture" type="RID"> - </argument> + <return type="void" /> + <argument index="0" name="item" type="RID" /> + <argument index="1" name="mesh" type="RID" /> + <argument index="2" name="transform" type="Transform2D" default="Transform2D(1, 0, 0, 1, 0, 0)" /> + <argument index="3" name="modulate" type="Color" default="Color(1, 1, 1, 1)" /> + <argument index="4" name="texture" type="RID" /> <description> </description> </method> <method name="canvas_item_add_multimesh"> - <return type="void"> - </return> - <argument index="0" name="item" type="RID"> - </argument> - <argument index="1" name="mesh" type="RID"> - </argument> - <argument index="2" name="texture" type="RID"> - </argument> + <return type="void" /> + <argument index="0" name="item" type="RID" /> + <argument index="1" name="mesh" type="RID" /> + <argument index="2" name="texture" type="RID" /> <description> </description> </method> <method name="canvas_item_add_nine_patch"> - <return type="void"> - </return> - <argument index="0" name="item" type="RID"> - </argument> - <argument index="1" name="rect" type="Rect2"> - </argument> - <argument index="2" name="source" type="Rect2"> - </argument> - <argument index="3" name="texture" type="RID"> - </argument> - <argument index="4" name="topleft" type="Vector2"> - </argument> - <argument index="5" name="bottomright" type="Vector2"> - </argument> - <argument index="6" name="x_axis_mode" type="int" enum="RenderingServer.NinePatchAxisMode" default="0"> - </argument> - <argument index="7" name="y_axis_mode" type="int" enum="RenderingServer.NinePatchAxisMode" default="0"> - </argument> - <argument index="8" name="draw_center" type="bool" default="true"> - </argument> - <argument index="9" name="modulate" type="Color" default="Color(1, 1, 1, 1)"> - </argument> + <return type="void" /> + <argument index="0" name="item" type="RID" /> + <argument index="1" name="rect" type="Rect2" /> + <argument index="2" name="source" type="Rect2" /> + <argument index="3" name="texture" type="RID" /> + <argument index="4" name="topleft" type="Vector2" /> + <argument index="5" name="bottomright" type="Vector2" /> + <argument index="6" name="x_axis_mode" type="int" enum="RenderingServer.NinePatchAxisMode" default="0" /> + <argument index="7" name="y_axis_mode" type="int" enum="RenderingServer.NinePatchAxisMode" default="0" /> + <argument index="8" name="draw_center" type="bool" default="true" /> + <argument index="9" name="modulate" type="Color" default="Color(1, 1, 1, 1)" /> <description> </description> </method> <method name="canvas_item_add_particles"> - <return type="void"> - </return> - <argument index="0" name="item" type="RID"> - </argument> - <argument index="1" name="particles" type="RID"> - </argument> - <argument index="2" name="texture" type="RID"> - </argument> + <return type="void" /> + <argument index="0" name="item" type="RID" /> + <argument index="1" name="particles" type="RID" /> + <argument index="2" name="texture" type="RID" /> <description> </description> </method> <method name="canvas_item_add_polygon"> - <return type="void"> - </return> - <argument index="0" name="item" type="RID"> - </argument> - <argument index="1" name="points" type="PackedVector2Array"> - </argument> - <argument index="2" name="colors" type="PackedColorArray"> - </argument> - <argument index="3" name="uvs" type="PackedVector2Array" default="PackedVector2Array()"> - </argument> - <argument index="4" name="texture" type="RID"> - </argument> + <return type="void" /> + <argument index="0" name="item" type="RID" /> + <argument index="1" name="points" type="PackedVector2Array" /> + <argument index="2" name="colors" type="PackedColorArray" /> + <argument index="3" name="uvs" type="PackedVector2Array" default="PackedVector2Array()" /> + <argument index="4" name="texture" type="RID" /> <description> </description> </method> <method name="canvas_item_add_polyline"> - <return type="void"> - </return> - <argument index="0" name="item" type="RID"> - </argument> - <argument index="1" name="points" type="PackedVector2Array"> - </argument> - <argument index="2" name="colors" type="PackedColorArray"> - </argument> - <argument index="3" name="width" type="float" default="1.0"> - </argument> - <argument index="4" name="antialiased" type="bool" default="false"> - </argument> + <return type="void" /> + <argument index="0" name="item" type="RID" /> + <argument index="1" name="points" type="PackedVector2Array" /> + <argument index="2" name="colors" type="PackedColorArray" /> + <argument index="3" name="width" type="float" default="1.0" /> + <argument index="4" name="antialiased" type="bool" default="false" /> <description> </description> </method> <method name="canvas_item_add_primitive"> - <return type="void"> - </return> - <argument index="0" name="item" type="RID"> - </argument> - <argument index="1" name="points" type="PackedVector2Array"> - </argument> - <argument index="2" name="colors" type="PackedColorArray"> - </argument> - <argument index="3" name="uvs" type="PackedVector2Array"> - </argument> - <argument index="4" name="texture" type="RID"> - </argument> - <argument index="5" name="width" type="float" default="1.0"> - </argument> + <return type="void" /> + <argument index="0" name="item" type="RID" /> + <argument index="1" name="points" type="PackedVector2Array" /> + <argument index="2" name="colors" type="PackedColorArray" /> + <argument index="3" name="uvs" type="PackedVector2Array" /> + <argument index="4" name="texture" type="RID" /> + <argument index="5" name="width" type="float" default="1.0" /> <description> </description> </method> <method name="canvas_item_add_rect"> - <return type="void"> - </return> - <argument index="0" name="item" type="RID"> - </argument> - <argument index="1" name="rect" type="Rect2"> - </argument> - <argument index="2" name="color" type="Color"> - </argument> + <return type="void" /> + <argument index="0" name="item" type="RID" /> + <argument index="1" name="rect" type="Rect2" /> + <argument index="2" name="color" type="Color" /> <description> </description> </method> <method name="canvas_item_add_set_transform"> - <return type="void"> - </return> - <argument index="0" name="item" type="RID"> - </argument> - <argument index="1" name="transform" type="Transform2D"> - </argument> + <return type="void" /> + <argument index="0" name="item" type="RID" /> + <argument index="1" name="transform" type="Transform2D" /> <description> </description> </method> <method name="canvas_item_add_texture_rect"> - <return type="void"> - </return> - <argument index="0" name="item" type="RID"> - </argument> - <argument index="1" name="rect" type="Rect2"> - </argument> - <argument index="2" name="texture" type="RID"> - </argument> - <argument index="3" name="tile" type="bool" default="false"> - </argument> - <argument index="4" name="modulate" type="Color" default="Color(1, 1, 1, 1)"> - </argument> - <argument index="5" name="transpose" type="bool" default="false"> - </argument> + <return type="void" /> + <argument index="0" name="item" type="RID" /> + <argument index="1" name="rect" type="Rect2" /> + <argument index="2" name="texture" type="RID" /> + <argument index="3" name="tile" type="bool" default="false" /> + <argument index="4" name="modulate" type="Color" default="Color(1, 1, 1, 1)" /> + <argument index="5" name="transpose" type="bool" default="false" /> <description> </description> </method> <method name="canvas_item_add_texture_rect_region"> - <return type="void"> - </return> - <argument index="0" name="item" type="RID"> - </argument> - <argument index="1" name="rect" type="Rect2"> - </argument> - <argument index="2" name="texture" type="RID"> - </argument> - <argument index="3" name="src_rect" type="Rect2"> - </argument> - <argument index="4" name="modulate" type="Color" default="Color(1, 1, 1, 1)"> - </argument> - <argument index="5" name="transpose" type="bool" default="false"> - </argument> - <argument index="6" name="clip_uv" type="bool" default="true"> - </argument> + <return type="void" /> + <argument index="0" name="item" type="RID" /> + <argument index="1" name="rect" type="Rect2" /> + <argument index="2" name="texture" type="RID" /> + <argument index="3" name="src_rect" type="Rect2" /> + <argument index="4" name="modulate" type="Color" default="Color(1, 1, 1, 1)" /> + <argument index="5" name="transpose" type="bool" default="false" /> + <argument index="6" name="clip_uv" type="bool" default="true" /> <description> </description> </method> <method name="canvas_item_add_triangle_array"> - <return type="void"> - </return> - <argument index="0" name="item" type="RID"> - </argument> - <argument index="1" name="indices" type="PackedInt32Array"> - </argument> - <argument index="2" name="points" type="PackedVector2Array"> - </argument> - <argument index="3" name="colors" type="PackedColorArray"> - </argument> - <argument index="4" name="uvs" type="PackedVector2Array" default="PackedVector2Array()"> - </argument> - <argument index="5" name="bones" type="PackedInt32Array" default="PackedInt32Array()"> - </argument> - <argument index="6" name="weights" type="PackedFloat32Array" default="PackedFloat32Array()"> - </argument> - <argument index="7" name="texture" type="RID"> - </argument> - <argument index="8" name="count" type="int" default="-1"> - </argument> + <return type="void" /> + <argument index="0" name="item" type="RID" /> + <argument index="1" name="indices" type="PackedInt32Array" /> + <argument index="2" name="points" type="PackedVector2Array" /> + <argument index="3" name="colors" type="PackedColorArray" /> + <argument index="4" name="uvs" type="PackedVector2Array" default="PackedVector2Array()" /> + <argument index="5" name="bones" type="PackedInt32Array" default="PackedInt32Array()" /> + <argument index="6" name="weights" type="PackedFloat32Array" default="PackedFloat32Array()" /> + <argument index="7" name="texture" type="RID" /> + <argument index="8" name="count" type="int" default="-1" /> <description> </description> </method> <method name="canvas_item_clear"> - <return type="void"> - </return> - <argument index="0" name="item" type="RID"> - </argument> + <return type="void" /> + <argument index="0" name="item" type="RID" /> <description> Clears the [CanvasItem] and removes all commands in it. </description> </method> <method name="canvas_item_create"> - <return type="RID"> - </return> + <return type="RID" /> <description> </description> </method> <method name="canvas_item_set_canvas_group_mode"> - <return type="void"> - </return> - <argument index="0" name="item" type="RID"> - </argument> - <argument index="1" name="mode" type="int" enum="RenderingServer.CanvasGroupMode"> - </argument> - <argument index="2" name="clear_margin" type="float" default="5.0"> - </argument> - <argument index="3" name="fit_empty" type="bool" default="false"> - </argument> - <argument index="4" name="fit_margin" type="float" default="0.0"> - </argument> - <argument index="5" name="blur_mipmaps" type="bool" default="false"> - </argument> + <return type="void" /> + <argument index="0" name="item" type="RID" /> + <argument index="1" name="mode" type="int" enum="RenderingServer.CanvasGroupMode" /> + <argument index="2" name="clear_margin" type="float" default="5.0" /> + <argument index="3" name="fit_empty" type="bool" default="false" /> + <argument index="4" name="fit_margin" type="float" default="0.0" /> + <argument index="5" name="blur_mipmaps" type="bool" default="false" /> <description> </description> </method> <method name="canvas_item_set_clip"> - <return type="void"> - </return> - <argument index="0" name="item" type="RID"> - </argument> - <argument index="1" name="clip" type="bool"> - </argument> + <return type="void" /> + <argument index="0" name="item" type="RID" /> + <argument index="1" name="clip" type="bool" /> <description> </description> </method> <method name="canvas_item_set_copy_to_backbuffer"> - <return type="void"> - </return> - <argument index="0" name="item" type="RID"> - </argument> - <argument index="1" name="enabled" type="bool"> - </argument> - <argument index="2" name="rect" type="Rect2"> - </argument> + <return type="void" /> + <argument index="0" name="item" type="RID" /> + <argument index="1" name="enabled" type="bool" /> + <argument index="2" name="rect" type="Rect2" /> <description> Sets the [CanvasItem] to copy a rect to the backbuffer. </description> </method> <method name="canvas_item_set_custom_rect"> - <return type="void"> - </return> - <argument index="0" name="item" type="RID"> - </argument> - <argument index="1" name="use_custom_rect" type="bool"> - </argument> - <argument index="2" name="rect" type="Rect2" default="Rect2(0, 0, 0, 0)"> - </argument> + <return type="void" /> + <argument index="0" name="item" type="RID" /> + <argument index="1" name="use_custom_rect" type="bool" /> + <argument index="2" name="rect" type="Rect2" default="Rect2(0, 0, 0, 0)" /> <description> </description> </method> <method name="canvas_item_set_default_texture_filter"> - <return type="void"> - </return> - <argument index="0" name="item" type="RID"> - </argument> - <argument index="1" name="filter" type="int" enum="RenderingServer.CanvasItemTextureFilter"> - </argument> + <return type="void" /> + <argument index="0" name="item" type="RID" /> + <argument index="1" name="filter" type="int" enum="RenderingServer.CanvasItemTextureFilter" /> <description> </description> </method> <method name="canvas_item_set_default_texture_repeat"> - <return type="void"> - </return> - <argument index="0" name="item" type="RID"> - </argument> - <argument index="1" name="repeat" type="int" enum="RenderingServer.CanvasItemTextureRepeat"> - </argument> + <return type="void" /> + <argument index="0" name="item" type="RID" /> + <argument index="1" name="repeat" type="int" enum="RenderingServer.CanvasItemTextureRepeat" /> <description> </description> </method> <method name="canvas_item_set_distance_field_mode"> - <return type="void"> - </return> - <argument index="0" name="item" type="RID"> - </argument> - <argument index="1" name="enabled" type="bool"> - </argument> + <return type="void" /> + <argument index="0" name="item" type="RID" /> + <argument index="1" name="enabled" type="bool" /> <description> </description> </method> <method name="canvas_item_set_draw_behind_parent"> - <return type="void"> - </return> - <argument index="0" name="item" type="RID"> - </argument> - <argument index="1" name="enabled" type="bool"> - </argument> + <return type="void" /> + <argument index="0" name="item" type="RID" /> + <argument index="1" name="enabled" type="bool" /> <description> </description> </method> <method name="canvas_item_set_draw_index"> - <return type="void"> - </return> - <argument index="0" name="item" type="RID"> - </argument> - <argument index="1" name="index" type="int"> - </argument> + <return type="void" /> + <argument index="0" name="item" type="RID" /> + <argument index="1" name="index" type="int" /> <description> Sets the index for the [CanvasItem]. </description> </method> <method name="canvas_item_set_light_mask"> - <return type="void"> - </return> - <argument index="0" name="item" type="RID"> - </argument> - <argument index="1" name="mask" type="int"> - </argument> + <return type="void" /> + <argument index="0" name="item" type="RID" /> + <argument index="1" name="mask" type="int" /> <description> </description> </method> <method name="canvas_item_set_material"> - <return type="void"> - </return> - <argument index="0" name="item" type="RID"> - </argument> - <argument index="1" name="material" type="RID"> - </argument> + <return type="void" /> + <argument index="0" name="item" type="RID" /> + <argument index="1" name="material" type="RID" /> <description> Sets a new material to the [CanvasItem]. </description> </method> <method name="canvas_item_set_modulate"> - <return type="void"> - </return> - <argument index="0" name="item" type="RID"> - </argument> - <argument index="1" name="color" type="Color"> - </argument> + <return type="void" /> + <argument index="0" name="item" type="RID" /> + <argument index="1" name="color" type="Color" /> <description> </description> </method> <method name="canvas_item_set_parent"> - <return type="void"> - </return> - <argument index="0" name="item" type="RID"> - </argument> - <argument index="1" name="parent" type="RID"> - </argument> + <return type="void" /> + <argument index="0" name="item" type="RID" /> + <argument index="1" name="parent" type="RID" /> <description> </description> </method> <method name="canvas_item_set_self_modulate"> - <return type="void"> - </return> - <argument index="0" name="item" type="RID"> - </argument> - <argument index="1" name="color" type="Color"> - </argument> + <return type="void" /> + <argument index="0" name="item" type="RID" /> + <argument index="1" name="color" type="Color" /> <description> </description> </method> <method name="canvas_item_set_sort_children_by_y"> - <return type="void"> - </return> - <argument index="0" name="item" type="RID"> - </argument> - <argument index="1" name="enabled" type="bool"> - </argument> + <return type="void" /> + <argument index="0" name="item" type="RID" /> + <argument index="1" name="enabled" type="bool" /> <description> </description> </method> <method name="canvas_item_set_transform"> - <return type="void"> - </return> - <argument index="0" name="item" type="RID"> - </argument> - <argument index="1" name="transform" type="Transform2D"> - </argument> + <return type="void" /> + <argument index="0" name="item" type="RID" /> + <argument index="1" name="transform" type="Transform2D" /> <description> </description> </method> <method name="canvas_item_set_use_parent_material"> - <return type="void"> - </return> - <argument index="0" name="item" type="RID"> - </argument> - <argument index="1" name="enabled" type="bool"> - </argument> + <return type="void" /> + <argument index="0" name="item" type="RID" /> + <argument index="1" name="enabled" type="bool" /> <description> Sets if the [CanvasItem] uses its parent's material. </description> </method> <method name="canvas_item_set_visibility_notifier"> - <return type="void"> - </return> - <argument index="0" name="item" type="RID"> - </argument> - <argument index="1" name="enable" type="bool"> - </argument> - <argument index="2" name="area" type="Rect2"> - </argument> - <argument index="3" name="enter_callable" type="Callable"> - </argument> - <argument index="4" name="exit_callable" type="Callable"> - </argument> + <return type="void" /> + <argument index="0" name="item" type="RID" /> + <argument index="1" name="enable" type="bool" /> + <argument index="2" name="area" type="Rect2" /> + <argument index="3" name="enter_callable" type="Callable" /> + <argument index="4" name="exit_callable" type="Callable" /> <description> </description> </method> <method name="canvas_item_set_visible"> - <return type="void"> - </return> - <argument index="0" name="item" type="RID"> - </argument> - <argument index="1" name="visible" type="bool"> - </argument> + <return type="void" /> + <argument index="0" name="item" type="RID" /> + <argument index="1" name="visible" type="bool" /> <description> </description> </method> <method name="canvas_item_set_z_as_relative_to_parent"> - <return type="void"> - </return> - <argument index="0" name="item" type="RID"> - </argument> - <argument index="1" name="enabled" type="bool"> - </argument> + <return type="void" /> + <argument index="0" name="item" type="RID" /> + <argument index="1" name="enabled" type="bool" /> <description> If this is enabled, the Z index of the parent will be added to the children's Z index. </description> </method> <method name="canvas_item_set_z_index"> - <return type="void"> - </return> - <argument index="0" name="item" type="RID"> - </argument> - <argument index="1" name="z_index" type="int"> - </argument> + <return type="void" /> + <argument index="0" name="item" type="RID" /> + <argument index="1" name="z_index" type="int" /> <description> Sets the [CanvasItem]'s Z index, i.e. its draw order (lower indexes are drawn first). </description> </method> <method name="canvas_light_attach_to_canvas"> - <return type="void"> - </return> - <argument index="0" name="light" type="RID"> - </argument> - <argument index="1" name="canvas" type="RID"> - </argument> + <return type="void" /> + <argument index="0" name="light" type="RID" /> + <argument index="1" name="canvas" type="RID" /> <description> Attaches the canvas light to the canvas. Removes it from its previous canvas. </description> </method> <method name="canvas_light_create"> - <return type="RID"> - </return> + <return type="RID" /> <description> Creates a canvas light and adds it to the RenderingServer. It can be accessed with the RID that is returned. This RID will be used in all [code]canvas_light_*[/code] RenderingServer functions. Once finished with your RID, you will want to free the RID using the RenderingServer's [method free_rid] static method. </description> </method> <method name="canvas_light_occluder_attach_to_canvas"> - <return type="void"> - </return> - <argument index="0" name="occluder" type="RID"> - </argument> - <argument index="1" name="canvas" type="RID"> - </argument> + <return type="void" /> + <argument index="0" name="occluder" type="RID" /> + <argument index="1" name="canvas" type="RID" /> <description> Attaches a light occluder to the canvas. Removes it from its previous canvas. </description> </method> <method name="canvas_light_occluder_create"> - <return type="RID"> - </return> + <return type="RID" /> <description> Creates a light occluder and adds it to the RenderingServer. It can be accessed with the RID that is returned. This RID will be used in all [code]canvas_light_ocluder_*[/code] RenderingServer functions. Once finished with your RID, you will want to free the RID using the RenderingServer's [method free_rid] static method. </description> </method> <method name="canvas_light_occluder_set_as_sdf_collision"> - <return type="void"> - </return> - <argument index="0" name="occluder" type="RID"> - </argument> - <argument index="1" name="enable" type="bool"> - </argument> + <return type="void" /> + <argument index="0" name="occluder" type="RID" /> + <argument index="1" name="enable" type="bool" /> <description> </description> </method> <method name="canvas_light_occluder_set_enabled"> - <return type="void"> - </return> - <argument index="0" name="occluder" type="RID"> - </argument> - <argument index="1" name="enabled" type="bool"> - </argument> + <return type="void" /> + <argument index="0" name="occluder" type="RID" /> + <argument index="1" name="enabled" type="bool" /> <description> Enables or disables light occluder. </description> </method> <method name="canvas_light_occluder_set_light_mask"> - <return type="void"> - </return> - <argument index="0" name="occluder" type="RID"> - </argument> - <argument index="1" name="mask" type="int"> - </argument> + <return type="void" /> + <argument index="0" name="occluder" type="RID" /> + <argument index="1" name="mask" type="int" /> <description> The light mask. See [LightOccluder2D] for more information on light masks. </description> </method> <method name="canvas_light_occluder_set_polygon"> - <return type="void"> - </return> - <argument index="0" name="occluder" type="RID"> - </argument> - <argument index="1" name="polygon" type="RID"> - </argument> + <return type="void" /> + <argument index="0" name="occluder" type="RID" /> + <argument index="1" name="polygon" type="RID" /> <description> Sets a light occluder's polygon. </description> </method> <method name="canvas_light_occluder_set_transform"> - <return type="void"> - </return> - <argument index="0" name="occluder" type="RID"> - </argument> - <argument index="1" name="transform" type="Transform2D"> - </argument> + <return type="void" /> + <argument index="0" name="occluder" type="RID" /> + <argument index="1" name="transform" type="Transform2D" /> <description> Sets a light occluder's [Transform2D]. </description> </method> <method name="canvas_light_set_color"> - <return type="void"> - </return> - <argument index="0" name="light" type="RID"> - </argument> - <argument index="1" name="color" type="Color"> - </argument> + <return type="void" /> + <argument index="0" name="light" type="RID" /> + <argument index="1" name="color" type="Color" /> <description> Sets the color for a light. </description> </method> <method name="canvas_light_set_enabled"> - <return type="void"> - </return> - <argument index="0" name="light" type="RID"> - </argument> - <argument index="1" name="enabled" type="bool"> - </argument> + <return type="void" /> + <argument index="0" name="light" type="RID" /> + <argument index="1" name="enabled" type="bool" /> <description> Enables or disables a canvas light. </description> </method> <method name="canvas_light_set_energy"> - <return type="void"> - </return> - <argument index="0" name="light" type="RID"> - </argument> - <argument index="1" name="energy" type="float"> - </argument> + <return type="void" /> + <argument index="0" name="light" type="RID" /> + <argument index="1" name="energy" type="float" /> <description> Sets a canvas light's energy. </description> </method> <method name="canvas_light_set_height"> - <return type="void"> - </return> - <argument index="0" name="light" type="RID"> - </argument> - <argument index="1" name="height" type="float"> - </argument> + <return type="void" /> + <argument index="0" name="light" type="RID" /> + <argument index="1" name="height" type="float" /> <description> Sets a canvas light's height. </description> </method> <method name="canvas_light_set_item_cull_mask"> - <return type="void"> - </return> - <argument index="0" name="light" type="RID"> - </argument> - <argument index="1" name="mask" type="int"> - </argument> + <return type="void" /> + <argument index="0" name="light" type="RID" /> + <argument index="1" name="mask" type="int" /> <description> The light mask. See [LightOccluder2D] for more information on light masks. </description> </method> <method name="canvas_light_set_item_shadow_cull_mask"> - <return type="void"> - </return> - <argument index="0" name="light" type="RID"> - </argument> - <argument index="1" name="mask" type="int"> - </argument> + <return type="void" /> + <argument index="0" name="light" type="RID" /> + <argument index="1" name="mask" type="int" /> <description> The binary mask used to determine which layers this canvas light's shadows affects. See [LightOccluder2D] for more information on light masks. </description> </method> <method name="canvas_light_set_layer_range"> - <return type="void"> - </return> - <argument index="0" name="light" type="RID"> - </argument> - <argument index="1" name="min_layer" type="int"> - </argument> - <argument index="2" name="max_layer" type="int"> - </argument> + <return type="void" /> + <argument index="0" name="light" type="RID" /> + <argument index="1" name="min_layer" type="int" /> + <argument index="2" name="max_layer" type="int" /> <description> The layer range that gets rendered with this light. </description> </method> <method name="canvas_light_set_mode"> - <return type="void"> - </return> - <argument index="0" name="light" type="RID"> - </argument> - <argument index="1" name="mode" type="int" enum="RenderingServer.CanvasLightMode"> - </argument> + <return type="void" /> + <argument index="0" name="light" type="RID" /> + <argument index="1" name="mode" type="int" enum="RenderingServer.CanvasLightMode" /> <description> The mode of the light, see [enum CanvasLightMode] constants. </description> </method> <method name="canvas_light_set_shadow_color"> - <return type="void"> - </return> - <argument index="0" name="light" type="RID"> - </argument> - <argument index="1" name="color" type="Color"> - </argument> + <return type="void" /> + <argument index="0" name="light" type="RID" /> + <argument index="1" name="color" type="Color" /> <description> Sets the color of the canvas light's shadow. </description> </method> <method name="canvas_light_set_shadow_enabled"> - <return type="void"> - </return> - <argument index="0" name="light" type="RID"> - </argument> - <argument index="1" name="enabled" type="bool"> - </argument> + <return type="void" /> + <argument index="0" name="light" type="RID" /> + <argument index="1" name="enabled" type="bool" /> <description> Enables or disables the canvas light's shadow. </description> </method> <method name="canvas_light_set_shadow_filter"> - <return type="void"> - </return> - <argument index="0" name="light" type="RID"> - </argument> - <argument index="1" name="filter" type="int" enum="RenderingServer.CanvasLightShadowFilter"> - </argument> + <return type="void" /> + <argument index="0" name="light" type="RID" /> + <argument index="1" name="filter" type="int" enum="RenderingServer.CanvasLightShadowFilter" /> <description> Sets the canvas light's shadow's filter, see [enum CanvasLightShadowFilter] constants. </description> </method> <method name="canvas_light_set_shadow_smooth"> - <return type="void"> - </return> - <argument index="0" name="light" type="RID"> - </argument> - <argument index="1" name="smooth" type="float"> - </argument> + <return type="void" /> + <argument index="0" name="light" type="RID" /> + <argument index="1" name="smooth" type="float" /> <description> Smoothens the shadow. The lower, the smoother. </description> </method> <method name="canvas_light_set_texture"> - <return type="void"> - </return> - <argument index="0" name="light" type="RID"> - </argument> - <argument index="1" name="texture" type="RID"> - </argument> + <return type="void" /> + <argument index="0" name="light" type="RID" /> + <argument index="1" name="texture" type="RID" /> <description> Sets the texture to be used by a [PointLight2D]. Equivalent to [member PointLight2D.texture]. </description> </method> <method name="canvas_light_set_texture_offset"> - <return type="void"> - </return> - <argument index="0" name="light" type="RID"> - </argument> - <argument index="1" name="offset" type="Vector2"> - </argument> + <return type="void" /> + <argument index="0" name="light" type="RID" /> + <argument index="1" name="offset" type="Vector2" /> <description> Sets the offset of a [PointLight2D]'s texture. Equivalent to [member PointLight2D.offset]. </description> </method> <method name="canvas_light_set_texture_scale"> - <return type="void"> - </return> - <argument index="0" name="light" type="RID"> - </argument> - <argument index="1" name="scale" type="float"> - </argument> + <return type="void" /> + <argument index="0" name="light" type="RID" /> + <argument index="1" name="scale" type="float" /> <description> Sets the scale factor of a [PointLight2D]'s texture. Equivalent to [member PointLight2D.texture_scale]. </description> </method> <method name="canvas_light_set_transform"> - <return type="void"> - </return> - <argument index="0" name="light" type="RID"> - </argument> - <argument index="1" name="transform" type="Transform2D"> - </argument> + <return type="void" /> + <argument index="0" name="light" type="RID" /> + <argument index="1" name="transform" type="Transform2D" /> <description> Sets the canvas light's [Transform2D]. </description> </method> <method name="canvas_light_set_z_range"> - <return type="void"> - </return> - <argument index="0" name="light" type="RID"> - </argument> - <argument index="1" name="min_z" type="int"> - </argument> - <argument index="2" name="max_z" type="int"> - </argument> + <return type="void" /> + <argument index="0" name="light" type="RID" /> + <argument index="1" name="min_z" type="int" /> + <argument index="2" name="max_z" type="int" /> <description> Sets the Z range of objects that will be affected by this light. Equivalent to [member Light2D.range_z_min] and [member Light2D.range_z_max]. </description> </method> <method name="canvas_occluder_polygon_create"> - <return type="RID"> - </return> + <return type="RID" /> <description> Creates a new light occluder polygon and adds it to the RenderingServer. It can be accessed with the RID that is returned. This RID will be used in all [code]canvas_occluder_polygon_*[/code] RenderingServer functions. Once finished with your RID, you will want to free the RID using the RenderingServer's [method free_rid] static method. </description> </method> <method name="canvas_occluder_polygon_set_cull_mode"> - <return type="void"> - </return> - <argument index="0" name="occluder_polygon" type="RID"> - </argument> - <argument index="1" name="mode" type="int" enum="RenderingServer.CanvasOccluderPolygonCullMode"> - </argument> + <return type="void" /> + <argument index="0" name="occluder_polygon" type="RID" /> + <argument index="1" name="mode" type="int" enum="RenderingServer.CanvasOccluderPolygonCullMode" /> <description> Sets an occluder polygons cull mode. See [enum CanvasOccluderPolygonCullMode] constants. </description> </method> <method name="canvas_occluder_polygon_set_shape"> - <return type="void"> - </return> - <argument index="0" name="occluder_polygon" type="RID"> - </argument> - <argument index="1" name="shape" type="PackedVector2Array"> - </argument> - <argument index="2" name="closed" type="bool"> - </argument> + <return type="void" /> + <argument index="0" name="occluder_polygon" type="RID" /> + <argument index="1" name="shape" type="PackedVector2Array" /> + <argument index="2" name="closed" type="bool" /> <description> Sets the shape of the occluder polygon. </description> </method> <method name="canvas_set_disable_scale"> - <return type="void"> - </return> - <argument index="0" name="disable" type="bool"> - </argument> + <return type="void" /> + <argument index="0" name="disable" type="bool" /> <description> </description> </method> <method name="canvas_set_item_mirroring"> - <return type="void"> - </return> - <argument index="0" name="canvas" type="RID"> - </argument> - <argument index="1" name="item" type="RID"> - </argument> - <argument index="2" name="mirroring" type="Vector2"> - </argument> + <return type="void" /> + <argument index="0" name="canvas" type="RID" /> + <argument index="1" name="item" type="RID" /> + <argument index="2" name="mirroring" type="Vector2" /> <description> A copy of the canvas item will be drawn with a local offset of the mirroring [Vector2]. </description> </method> <method name="canvas_set_modulate"> - <return type="void"> - </return> - <argument index="0" name="canvas" type="RID"> - </argument> - <argument index="1" name="color" type="Color"> - </argument> + <return type="void" /> + <argument index="0" name="canvas" type="RID" /> + <argument index="1" name="color" type="Color" /> <description> Modulates all colors in the given canvas. </description> </method> <method name="canvas_set_shadow_texture_size"> - <return type="void"> - </return> - <argument index="0" name="size" type="int"> - </argument> + <return type="void" /> + <argument index="0" name="size" type="int" /> <description> </description> </method> <method name="canvas_texture_create"> - <return type="RID"> - </return> + <return type="RID" /> <description> </description> </method> <method name="canvas_texture_set_channel"> - <return type="void"> - </return> - <argument index="0" name="canvas_texture" type="RID"> - </argument> - <argument index="1" name="channel" type="int" enum="RenderingServer.CanvasTextureChannel"> - </argument> - <argument index="2" name="texture" type="RID"> - </argument> + <return type="void" /> + <argument index="0" name="canvas_texture" type="RID" /> + <argument index="1" name="channel" type="int" enum="RenderingServer.CanvasTextureChannel" /> + <argument index="2" name="texture" type="RID" /> <description> </description> </method> <method name="canvas_texture_set_shading_parameters"> - <return type="void"> - </return> - <argument index="0" name="canvas_texture" type="RID"> - </argument> - <argument index="1" name="base_color" type="Color"> - </argument> - <argument index="2" name="shininess" type="float"> - </argument> + <return type="void" /> + <argument index="0" name="canvas_texture" type="RID" /> + <argument index="1" name="base_color" type="Color" /> + <argument index="2" name="shininess" type="float" /> <description> </description> </method> <method name="canvas_texture_set_texture_filter"> - <return type="void"> - </return> - <argument index="0" name="canvas_texture" type="RID"> - </argument> - <argument index="1" name="filter" type="int" enum="RenderingServer.CanvasItemTextureFilter"> - </argument> + <return type="void" /> + <argument index="0" name="canvas_texture" type="RID" /> + <argument index="1" name="filter" type="int" enum="RenderingServer.CanvasItemTextureFilter" /> <description> </description> </method> <method name="canvas_texture_set_texture_repeat"> - <return type="void"> - </return> - <argument index="0" name="canvas_texture" type="RID"> - </argument> - <argument index="1" name="repeat" type="int" enum="RenderingServer.CanvasItemTextureRepeat"> - </argument> + <return type="void" /> + <argument index="0" name="canvas_texture" type="RID" /> + <argument index="1" name="repeat" type="int" enum="RenderingServer.CanvasItemTextureRepeat" /> <description> </description> </method> <method name="create_local_rendering_device" qualifiers="const"> - <return type="RenderingDevice"> - </return> + <return type="RenderingDevice" /> <description> </description> </method> <method name="decal_create"> - <return type="RID"> - </return> + <return type="RID" /> <description> </description> </method> <method name="decal_set_albedo_mix"> - <return type="void"> - </return> - <argument index="0" name="decal" type="RID"> - </argument> - <argument index="1" name="albedo_mix" type="float"> - </argument> + <return type="void" /> + <argument index="0" name="decal" type="RID" /> + <argument index="1" name="albedo_mix" type="float" /> <description> </description> </method> <method name="decal_set_cull_mask"> - <return type="void"> - </return> - <argument index="0" name="decal" type="RID"> - </argument> - <argument index="1" name="mask" type="int"> - </argument> + <return type="void" /> + <argument index="0" name="decal" type="RID" /> + <argument index="1" name="mask" type="int" /> <description> </description> </method> <method name="decal_set_distance_fade"> - <return type="void"> - </return> - <argument index="0" name="decal" type="RID"> - </argument> - <argument index="1" name="enabled" type="bool"> - </argument> - <argument index="2" name="begin" type="float"> - </argument> - <argument index="3" name="length" type="float"> - </argument> + <return type="void" /> + <argument index="0" name="decal" type="RID" /> + <argument index="1" name="enabled" type="bool" /> + <argument index="2" name="begin" type="float" /> + <argument index="3" name="length" type="float" /> <description> </description> </method> <method name="decal_set_emission_energy"> - <return type="void"> - </return> - <argument index="0" name="decal" type="RID"> - </argument> - <argument index="1" name="energy" type="float"> - </argument> + <return type="void" /> + <argument index="0" name="decal" type="RID" /> + <argument index="1" name="energy" type="float" /> <description> </description> </method> <method name="decal_set_extents"> - <return type="void"> - </return> - <argument index="0" name="decal" type="RID"> - </argument> - <argument index="1" name="extents" type="Vector3"> - </argument> + <return type="void" /> + <argument index="0" name="decal" type="RID" /> + <argument index="1" name="extents" type="Vector3" /> <description> </description> </method> <method name="decal_set_fade"> - <return type="void"> - </return> - <argument index="0" name="decal" type="RID"> - </argument> - <argument index="1" name="above" type="float"> - </argument> - <argument index="2" name="below" type="float"> - </argument> + <return type="void" /> + <argument index="0" name="decal" type="RID" /> + <argument index="1" name="above" type="float" /> + <argument index="2" name="below" type="float" /> <description> </description> </method> <method name="decal_set_modulate"> - <return type="void"> - </return> - <argument index="0" name="decal" type="RID"> - </argument> - <argument index="1" name="color" type="Color"> - </argument> + <return type="void" /> + <argument index="0" name="decal" type="RID" /> + <argument index="1" name="color" type="Color" /> <description> </description> </method> <method name="decal_set_normal_fade"> - <return type="void"> - </return> - <argument index="0" name="decal" type="RID"> - </argument> - <argument index="1" name="fade" type="float"> - </argument> + <return type="void" /> + <argument index="0" name="decal" type="RID" /> + <argument index="1" name="fade" type="float" /> <description> </description> </method> <method name="decal_set_texture"> - <return type="void"> - </return> - <argument index="0" name="decal" type="RID"> - </argument> - <argument index="1" name="type" type="int" enum="RenderingServer.DecalTexture"> - </argument> - <argument index="2" name="texture" type="RID"> - </argument> + <return type="void" /> + <argument index="0" name="decal" type="RID" /> + <argument index="1" name="type" type="int" enum="RenderingServer.DecalTexture" /> + <argument index="2" name="texture" type="RID" /> + <description> + </description> + </method> + <method name="decals_set_filter"> + <return type="void" /> + <argument index="0" name="filter" type="int" enum="RenderingServer.DecalFilter" /> <description> </description> </method> <method name="directional_light_create"> - <return type="RID"> - </return> + <return type="RID" /> <description> Creates a directional light and adds it to the RenderingServer. It can be accessed with the RID that is returned. This RID can be used in most [code]light_*[/code] RenderingServer functions. Once finished with your RID, you will want to free the RID using the RenderingServer's [method free_rid] static method. @@ -1219,610 +860,423 @@ </description> </method> <method name="directional_shadow_atlas_set_size"> - <return type="void"> - </return> - <argument index="0" name="size" type="int"> - </argument> - <argument index="1" name="is_16bits" type="bool"> - </argument> + <return type="void" /> + <argument index="0" name="size" type="int" /> + <argument index="1" name="is_16bits" type="bool" /> <description> </description> </method> <method name="directional_shadow_quality_set"> - <return type="void"> - </return> - <argument index="0" name="quality" type="int" enum="RenderingServer.ShadowQuality"> - </argument> + <return type="void" /> + <argument index="0" name="quality" type="int" enum="RenderingServer.ShadowQuality" /> <description> </description> </method> <method name="environment_bake_panorama"> - <return type="Image"> - </return> - <argument index="0" name="environment" type="RID"> - </argument> - <argument index="1" name="bake_irradiance" type="bool"> - </argument> - <argument index="2" name="size" type="Vector2i"> - </argument> + <return type="Image" /> + <argument index="0" name="environment" type="RID" /> + <argument index="1" name="bake_irradiance" type="bool" /> + <argument index="2" name="size" type="Vector2i" /> <description> </description> </method> <method name="environment_create"> - <return type="RID"> - </return> + <return type="RID" /> <description> Creates an environment and adds it to the RenderingServer. It can be accessed with the RID that is returned. This RID will be used in all [code]environment_*[/code] RenderingServer functions. Once finished with your RID, you will want to free the RID using the RenderingServer's [method free_rid] static method. </description> </method> <method name="environment_glow_set_use_bicubic_upscale"> - <return type="void"> - </return> - <argument index="0" name="enable" type="bool"> - </argument> + <return type="void" /> + <argument index="0" name="enable" type="bool" /> <description> </description> </method> <method name="environment_glow_set_use_high_quality"> - <return type="void"> - </return> - <argument index="0" name="enable" type="bool"> - </argument> + <return type="void" /> + <argument index="0" name="enable" type="bool" /> <description> </description> </method> <method name="environment_set_adjustment"> - <return type="void"> - </return> - <argument index="0" name="env" type="RID"> - </argument> - <argument index="1" name="enable" type="bool"> - </argument> - <argument index="2" name="brightness" type="float"> - </argument> - <argument index="3" name="contrast" type="float"> - </argument> - <argument index="4" name="saturation" type="float"> - </argument> - <argument index="5" name="use_1d_color_correction" type="bool"> - </argument> - <argument index="6" name="color_correction" type="RID"> - </argument> + <return type="void" /> + <argument index="0" name="env" type="RID" /> + <argument index="1" name="enable" type="bool" /> + <argument index="2" name="brightness" type="float" /> + <argument index="3" name="contrast" type="float" /> + <argument index="4" name="saturation" type="float" /> + <argument index="5" name="use_1d_color_correction" type="bool" /> + <argument index="6" name="color_correction" type="RID" /> <description> Sets the values to be used with the "Adjustment" post-process effect. See [Environment] for more details. </description> </method> <method name="environment_set_ambient_light"> - <return type="void"> - </return> - <argument index="0" name="env" type="RID"> - </argument> - <argument index="1" name="color" type="Color"> - </argument> - <argument index="2" name="ambient" type="int" enum="RenderingServer.EnvironmentAmbientSource" default="0"> - </argument> - <argument index="3" name="energy" type="float" default="1.0"> - </argument> - <argument index="4" name="sky_contibution" type="float" default="0.0"> - </argument> - <argument index="5" name="reflection_source" type="int" enum="RenderingServer.EnvironmentReflectionSource" default="0"> - </argument> - <argument index="6" name="ao_color" type="Color" default="Color(0, 0, 0, 1)"> - </argument> + <return type="void" /> + <argument index="0" name="env" type="RID" /> + <argument index="1" name="color" type="Color" /> + <argument index="2" name="ambient" type="int" enum="RenderingServer.EnvironmentAmbientSource" default="0" /> + <argument index="3" name="energy" type="float" default="1.0" /> + <argument index="4" name="sky_contibution" type="float" default="0.0" /> + <argument index="5" name="reflection_source" type="int" enum="RenderingServer.EnvironmentReflectionSource" default="0" /> + <argument index="6" name="ao_color" type="Color" default="Color(0, 0, 0, 1)" /> <description> </description> </method> <method name="environment_set_background"> - <return type="void"> - </return> - <argument index="0" name="env" type="RID"> - </argument> - <argument index="1" name="bg" type="int" enum="RenderingServer.EnvironmentBG"> - </argument> + <return type="void" /> + <argument index="0" name="env" type="RID" /> + <argument index="1" name="bg" type="int" enum="RenderingServer.EnvironmentBG" /> <description> Sets the [i]BGMode[/i] of the environment. Equivalent to [member Environment.background_mode]. </description> </method> <method name="environment_set_bg_color"> - <return type="void"> - </return> - <argument index="0" name="env" type="RID"> - </argument> - <argument index="1" name="color" type="Color"> - </argument> + <return type="void" /> + <argument index="0" name="env" type="RID" /> + <argument index="1" name="color" type="Color" /> <description> Color displayed for clear areas of the scene (if using Custom color or Color+Sky background modes). </description> </method> <method name="environment_set_bg_energy"> - <return type="void"> - </return> - <argument index="0" name="env" type="RID"> - </argument> - <argument index="1" name="energy" type="float"> - </argument> + <return type="void" /> + <argument index="0" name="env" type="RID" /> + <argument index="1" name="energy" type="float" /> <description> Sets the intensity of the background color. </description> </method> <method name="environment_set_canvas_max_layer"> - <return type="void"> - </return> - <argument index="0" name="env" type="RID"> - </argument> - <argument index="1" name="max_layer" type="int"> - </argument> + <return type="void" /> + <argument index="0" name="env" type="RID" /> + <argument index="1" name="max_layer" type="int" /> <description> Sets the maximum layer to use if using Canvas background mode. </description> </method> <method name="environment_set_fog"> - <return type="void"> - </return> - <argument index="0" name="env" type="RID"> - </argument> - <argument index="1" name="enable" type="bool"> - </argument> - <argument index="2" name="light_color" type="Color"> - </argument> - <argument index="3" name="light_energy" type="float"> - </argument> - <argument index="4" name="sun_scatter" type="float"> - </argument> - <argument index="5" name="density" type="float"> - </argument> - <argument index="6" name="height" type="float"> - </argument> - <argument index="7" name="height_density" type="float"> - </argument> - <argument index="8" name="aerial_perspective" type="float"> - </argument> + <return type="void" /> + <argument index="0" name="env" type="RID" /> + <argument index="1" name="enable" type="bool" /> + <argument index="2" name="light_color" type="Color" /> + <argument index="3" name="light_energy" type="float" /> + <argument index="4" name="sun_scatter" type="float" /> + <argument index="5" name="density" type="float" /> + <argument index="6" name="height" type="float" /> + <argument index="7" name="height_density" type="float" /> + <argument index="8" name="aerial_perspective" type="float" /> <description> </description> </method> <method name="environment_set_glow"> - <return type="void"> - </return> - <argument index="0" name="env" type="RID"> - </argument> - <argument index="1" name="enable" type="bool"> - </argument> - <argument index="2" name="levels" type="PackedFloat32Array"> - </argument> - <argument index="3" name="intensity" type="float"> - </argument> - <argument index="4" name="strength" type="float"> - </argument> - <argument index="5" name="mix" type="float"> - </argument> - <argument index="6" name="bloom_threshold" type="float"> - </argument> - <argument index="7" name="blend_mode" type="int" enum="RenderingServer.EnvironmentGlowBlendMode"> - </argument> - <argument index="8" name="hdr_bleed_threshold" type="float"> - </argument> - <argument index="9" name="hdr_bleed_scale" type="float"> - </argument> - <argument index="10" name="hdr_luminance_cap" type="float"> - </argument> + <return type="void" /> + <argument index="0" name="env" type="RID" /> + <argument index="1" name="enable" type="bool" /> + <argument index="2" name="levels" type="PackedFloat32Array" /> + <argument index="3" name="intensity" type="float" /> + <argument index="4" name="strength" type="float" /> + <argument index="5" name="mix" type="float" /> + <argument index="6" name="bloom_threshold" type="float" /> + <argument index="7" name="blend_mode" type="int" enum="RenderingServer.EnvironmentGlowBlendMode" /> + <argument index="8" name="hdr_bleed_threshold" type="float" /> + <argument index="9" name="hdr_bleed_scale" type="float" /> + <argument index="10" name="hdr_luminance_cap" type="float" /> <description> </description> </method> <method name="environment_set_sdfgi"> - <return type="void"> - </return> - <argument index="0" name="env" type="RID"> - </argument> - <argument index="1" name="enable" type="bool"> - </argument> - <argument index="2" name="cascades" type="int" enum="RenderingServer.EnvironmentSDFGICascades"> - </argument> - <argument index="3" name="min_cell_size" type="float"> - </argument> - <argument index="4" name="y_scale" type="int" enum="RenderingServer.EnvironmentSDFGIYScale"> - </argument> - <argument index="5" name="use_occlusion" type="bool"> - </argument> - <argument index="6" name="bounce_feedback" type="float"> - </argument> - <argument index="7" name="read_sky" type="bool"> - </argument> - <argument index="8" name="energy" type="float"> - </argument> - <argument index="9" name="normal_bias" type="float"> - </argument> - <argument index="10" name="probe_bias" type="float"> - </argument> + <return type="void" /> + <argument index="0" name="env" type="RID" /> + <argument index="1" name="enable" type="bool" /> + <argument index="2" name="cascades" type="int" enum="RenderingServer.EnvironmentSDFGICascades" /> + <argument index="3" name="min_cell_size" type="float" /> + <argument index="4" name="y_scale" type="int" enum="RenderingServer.EnvironmentSDFGIYScale" /> + <argument index="5" name="use_occlusion" type="bool" /> + <argument index="6" name="bounce_feedback" type="float" /> + <argument index="7" name="read_sky" type="bool" /> + <argument index="8" name="energy" type="float" /> + <argument index="9" name="normal_bias" type="float" /> + <argument index="10" name="probe_bias" type="float" /> <description> </description> </method> <method name="environment_set_sdfgi_frames_to_converge"> - <return type="void"> - </return> - <argument index="0" name="frames" type="int" enum="RenderingServer.EnvironmentSDFGIFramesToConverge"> - </argument> + <return type="void" /> + <argument index="0" name="frames" type="int" enum="RenderingServer.EnvironmentSDFGIFramesToConverge" /> <description> </description> </method> <method name="environment_set_sdfgi_frames_to_update_light"> - <return type="void"> - </return> - <argument index="0" name="frames" type="int" enum="RenderingServer.EnvironmentSDFGIFramesToUpdateLight"> - </argument> + <return type="void" /> + <argument index="0" name="frames" type="int" enum="RenderingServer.EnvironmentSDFGIFramesToUpdateLight" /> <description> </description> </method> <method name="environment_set_sdfgi_ray_count"> - <return type="void"> - </return> - <argument index="0" name="ray_count" type="int" enum="RenderingServer.EnvironmentSDFGIRayCount"> - </argument> + <return type="void" /> + <argument index="0" name="ray_count" type="int" enum="RenderingServer.EnvironmentSDFGIRayCount" /> <description> </description> </method> <method name="environment_set_sky"> - <return type="void"> - </return> - <argument index="0" name="env" type="RID"> - </argument> - <argument index="1" name="sky" type="RID"> - </argument> + <return type="void" /> + <argument index="0" name="env" type="RID" /> + <argument index="1" name="sky" type="RID" /> <description> Sets the [Sky] to be used as the environment's background when using [i]BGMode[/i] sky. Equivalent to [member Environment.sky]. </description> </method> <method name="environment_set_sky_custom_fov"> - <return type="void"> - </return> - <argument index="0" name="env" type="RID"> - </argument> - <argument index="1" name="scale" type="float"> - </argument> + <return type="void" /> + <argument index="0" name="env" type="RID" /> + <argument index="1" name="scale" type="float" /> <description> Sets a custom field of view for the background [Sky]. Equivalent to [member Environment.sky_custom_fov]. </description> </method> <method name="environment_set_sky_orientation"> - <return type="void"> - </return> - <argument index="0" name="env" type="RID"> - </argument> - <argument index="1" name="orientation" type="Basis"> - </argument> + <return type="void" /> + <argument index="0" name="env" type="RID" /> + <argument index="1" name="orientation" type="Basis" /> <description> Sets the rotation of the background [Sky] expressed as a [Basis]. Equivalent to [member Environment.sky_rotation], where the rotation vector is used to construct the [Basis]. </description> </method> <method name="environment_set_ssao"> - <return type="void"> - </return> - <argument index="0" name="env" type="RID"> - </argument> - <argument index="1" name="enable" type="bool"> - </argument> - <argument index="2" name="radius" type="float"> - </argument> - <argument index="3" name="intensity" type="float"> - </argument> - <argument index="4" name="power" type="float"> - </argument> - <argument index="5" name="detail" type="float"> - </argument> - <argument index="6" name="horizon" type="float"> - </argument> - <argument index="7" name="sharpness" type="float"> - </argument> - <argument index="8" name="light_affect" type="float"> - </argument> - <argument index="9" name="ao_channel_affect" type="float"> - </argument> + <return type="void" /> + <argument index="0" name="env" type="RID" /> + <argument index="1" name="enable" type="bool" /> + <argument index="2" name="radius" type="float" /> + <argument index="3" name="intensity" type="float" /> + <argument index="4" name="power" type="float" /> + <argument index="5" name="detail" type="float" /> + <argument index="6" name="horizon" type="float" /> + <argument index="7" name="sharpness" type="float" /> + <argument index="8" name="light_affect" type="float" /> + <argument index="9" name="ao_channel_affect" type="float" /> <description> Sets the variables to be used with the "screen space ambient occlusion" post-process effect. See [Environment] for more details. </description> </method> <method name="environment_set_ssao_quality"> - <return type="void"> - </return> - <argument index="0" name="quality" type="int" enum="RenderingServer.EnvironmentSSAOQuality"> - </argument> - <argument index="1" name="half_size" type="bool"> - </argument> - <argument index="2" name="adaptive_target" type="float"> - </argument> - <argument index="3" name="blur_passes" type="int"> - </argument> - <argument index="4" name="fadeout_from" type="float"> - </argument> - <argument index="5" name="fadeout_to" type="float"> - </argument> + <return type="void" /> + <argument index="0" name="quality" type="int" enum="RenderingServer.EnvironmentSSAOQuality" /> + <argument index="1" name="half_size" type="bool" /> + <argument index="2" name="adaptive_target" type="float" /> + <argument index="3" name="blur_passes" type="int" /> + <argument index="4" name="fadeout_from" type="float" /> + <argument index="5" name="fadeout_to" type="float" /> <description> </description> </method> <method name="environment_set_ssr"> - <return type="void"> - </return> - <argument index="0" name="env" type="RID"> - </argument> - <argument index="1" name="enable" type="bool"> - </argument> - <argument index="2" name="max_steps" type="int"> - </argument> - <argument index="3" name="fade_in" type="float"> - </argument> - <argument index="4" name="fade_out" type="float"> - </argument> - <argument index="5" name="depth_tolerance" type="float"> - </argument> + <return type="void" /> + <argument index="0" name="env" type="RID" /> + <argument index="1" name="enable" type="bool" /> + <argument index="2" name="max_steps" type="int" /> + <argument index="3" name="fade_in" type="float" /> + <argument index="4" name="fade_out" type="float" /> + <argument index="5" name="depth_tolerance" type="float" /> <description> Sets the variables to be used with the "screen space reflections" post-process effect. See [Environment] for more details. </description> </method> <method name="environment_set_ssr_roughness_quality"> - <return type="void"> - </return> - <argument index="0" name="quality" type="int" enum="RenderingServer.EnvironmentSSRRoughnessQuality"> - </argument> + <return type="void" /> + <argument index="0" name="quality" type="int" enum="RenderingServer.EnvironmentSSRRoughnessQuality" /> <description> </description> </method> <method name="environment_set_tonemap"> - <return type="void"> - </return> - <argument index="0" name="env" type="RID"> - </argument> - <argument index="1" name="tone_mapper" type="int" enum="RenderingServer.EnvironmentToneMapper"> - </argument> - <argument index="2" name="exposure" type="float"> - </argument> - <argument index="3" name="white" type="float"> - </argument> - <argument index="4" name="auto_exposure" type="bool"> - </argument> - <argument index="5" name="min_luminance" type="float"> - </argument> - <argument index="6" name="max_luminance" type="float"> - </argument> - <argument index="7" name="auto_exp_speed" type="float"> - </argument> - <argument index="8" name="auto_exp_grey" type="float"> - </argument> + <return type="void" /> + <argument index="0" name="env" type="RID" /> + <argument index="1" name="tone_mapper" type="int" enum="RenderingServer.EnvironmentToneMapper" /> + <argument index="2" name="exposure" type="float" /> + <argument index="3" name="white" type="float" /> + <argument index="4" name="auto_exposure" type="bool" /> + <argument index="5" name="min_luminance" type="float" /> + <argument index="6" name="max_luminance" type="float" /> + <argument index="7" name="auto_exp_speed" type="float" /> + <argument index="8" name="auto_exp_grey" type="float" /> <description> Sets the variables to be used with the "tonemap" post-process effect. See [Environment] for more details. </description> </method> <method name="environment_set_volumetric_fog"> - <return type="void"> - </return> - <argument index="0" name="env" type="RID"> - </argument> - <argument index="1" name="enable" type="bool"> - </argument> - <argument index="2" name="density" type="float"> - </argument> - <argument index="3" name="light" type="Color"> - </argument> - <argument index="4" name="light_energy" type="float"> - </argument> - <argument index="5" name="length" type="float"> - </argument> - <argument index="6" name="p_detail_spread" type="float"> - </argument> - <argument index="7" name="gi_inject" type="float"> - </argument> - <argument index="8" name="temporal_reprojection" type="bool"> - </argument> - <argument index="9" name="temporal_reprojection_amount" type="float"> - </argument> + <return type="void" /> + <argument index="0" name="env" type="RID" /> + <argument index="1" name="enable" type="bool" /> + <argument index="2" name="density" type="float" /> + <argument index="3" name="light" type="Color" /> + <argument index="4" name="light_energy" type="float" /> + <argument index="5" name="length" type="float" /> + <argument index="6" name="p_detail_spread" type="float" /> + <argument index="7" name="gi_inject" type="float" /> + <argument index="8" name="temporal_reprojection" type="bool" /> + <argument index="9" name="temporal_reprojection_amount" type="float" /> <description> </description> </method> <method name="environment_set_volumetric_fog_filter_active"> - <return type="void"> - </return> - <argument index="0" name="active" type="bool"> - </argument> + <return type="void" /> + <argument index="0" name="active" type="bool" /> <description> </description> </method> <method name="environment_set_volumetric_fog_volume_size"> - <return type="void"> - </return> - <argument index="0" name="size" type="int"> - </argument> - <argument index="1" name="depth" type="int"> - </argument> + <return type="void" /> + <argument index="0" name="size" type="int" /> + <argument index="1" name="depth" type="int" /> <description> </description> </method> <method name="force_draw"> - <return type="void"> - </return> - <argument index="0" name="swap_buffers" type="bool" default="true"> - </argument> - <argument index="1" name="frame_step" type="float" default="0.0"> - </argument> + <return type="void" /> + <argument index="0" name="swap_buffers" type="bool" default="true" /> + <argument index="1" name="frame_step" type="float" default="0.0" /> <description> </description> </method> <method name="force_sync"> - <return type="void"> - </return> + <return type="void" /> <description> </description> </method> <method name="free_rid"> - <return type="void"> - </return> - <argument index="0" name="rid" type="RID"> - </argument> + <return type="void" /> + <argument index="0" name="rid" type="RID" /> <description> Tries to free an object in the RenderingServer. </description> </method> <method name="get_frame_setup_time_cpu" qualifiers="const"> - <return type="float"> - </return> + <return type="float" /> <description> </description> </method> <method name="get_rendering_info"> - <return type="int"> - </return> - <argument index="0" name="info" type="int" enum="RenderingServer.RenderingInfo"> - </argument> + <return type="int" /> + <argument index="0" name="info" type="int" enum="RenderingServer.RenderingInfo" /> <description> </description> </method> <method name="get_test_cube"> - <return type="RID"> - </return> + <return type="RID" /> <description> Returns the id of the test cube. Creates one if none exists. </description> </method> <method name="get_test_texture"> - <return type="RID"> - </return> + <return type="RID" /> <description> Returns the id of the test texture. Creates one if none exists. </description> </method> <method name="get_video_adapter_name" qualifiers="const"> - <return type="String"> - </return> + <return type="String" /> <description> Returns the name of the video adapter (e.g. "GeForce GTX 1080/PCIe/SSE2"). [b]Note:[/b] When running a headless or server binary, this function returns an empty string. </description> </method> <method name="get_video_adapter_vendor" qualifiers="const"> - <return type="String"> - </return> + <return type="String" /> <description> Returns the vendor of the video adapter (e.g. "NVIDIA Corporation"). [b]Note:[/b] When running a headless or server binary, this function returns an empty string. </description> </method> <method name="get_white_texture"> - <return type="RID"> - </return> + <return type="RID" /> <description> Returns the id of a white texture. Creates one if none exists. </description> </method> <method name="global_variable_add"> - <return type="void"> - </return> - <argument index="0" name="name" type="StringName"> - </argument> - <argument index="1" name="type" type="int" enum="RenderingServer.GlobalVariableType"> - </argument> - <argument index="2" name="default_value" type="Variant"> - </argument> + <return type="void" /> + <argument index="0" name="name" type="StringName" /> + <argument index="1" name="type" type="int" enum="RenderingServer.GlobalVariableType" /> + <argument index="2" name="default_value" type="Variant" /> <description> </description> </method> <method name="global_variable_get" qualifiers="const"> - <return type="Variant"> - </return> - <argument index="0" name="name" type="StringName"> - </argument> + <return type="Variant" /> + <argument index="0" name="name" type="StringName" /> <description> </description> </method> <method name="global_variable_get_list" qualifiers="const"> - <return type="PackedStringArray"> - </return> + <return type="PackedStringArray" /> <description> </description> </method> <method name="global_variable_get_type" qualifiers="const"> - <return type="int" enum="RenderingServer.GlobalVariableType"> - </return> - <argument index="0" name="name" type="StringName"> - </argument> + <return type="int" enum="RenderingServer.GlobalVariableType" /> + <argument index="0" name="name" type="StringName" /> <description> </description> </method> <method name="global_variable_remove"> - <return type="void"> - </return> - <argument index="0" name="name" type="StringName"> - </argument> + <return type="void" /> + <argument index="0" name="name" type="StringName" /> <description> </description> </method> <method name="global_variable_set"> - <return type="void"> - </return> - <argument index="0" name="name" type="StringName"> - </argument> - <argument index="1" name="value" type="Variant"> - </argument> + <return type="void" /> + <argument index="0" name="name" type="StringName" /> + <argument index="1" name="value" type="Variant" /> <description> </description> </method> <method name="global_variable_set_override"> - <return type="void"> - </return> - <argument index="0" name="name" type="StringName"> - </argument> - <argument index="1" name="value" type="Variant"> - </argument> + <return type="void" /> + <argument index="0" name="name" type="StringName" /> + <argument index="1" name="value" type="Variant" /> <description> </description> </method> <method name="has_changed" qualifiers="const"> - <return type="bool"> - </return> + <return type="bool" /> <description> Returns [code]true[/code] if changes have been made to the RenderingServer's data. [method force_draw] is usually called if this happens. </description> </method> <method name="has_feature" qualifiers="const"> - <return type="bool"> - </return> - <argument index="0" name="feature" type="int" enum="RenderingServer.Features"> - </argument> + <return type="bool" /> + <argument index="0" name="feature" type="int" enum="RenderingServer.Features" /> <description> Not yet implemented. Always returns [code]false[/code]. </description> </method> <method name="has_os_feature" qualifiers="const"> - <return type="bool"> - </return> - <argument index="0" name="feature" type="String"> - </argument> + <return type="bool" /> + <argument index="0" name="feature" type="String" /> <description> Returns [code]true[/code] if the OS supports a certain feature. Features might be [code]s3tc[/code], [code]etc[/code], [code]etc2[/code] and [code]pvrtc[/code]. </description> </method> <method name="instance_attach_object_instance_id"> - <return type="void"> - </return> - <argument index="0" name="instance" type="RID"> - </argument> - <argument index="1" name="id" type="int"> - </argument> + <return type="void" /> + <argument index="0" name="instance" type="RID" /> + <argument index="1" name="id" type="int" /> <description> Attaches a unique Object ID to instance. Object ID must be attached to instance for proper culling with [method instances_cull_aabb], [method instances_cull_convex], and [method instances_cull_ray]. </description> </method> <method name="instance_attach_skeleton"> - <return type="void"> - </return> - <argument index="0" name="instance" type="RID"> - </argument> - <argument index="1" name="skeleton" type="RID"> - </argument> + <return type="void" /> + <argument index="0" name="instance" type="RID" /> + <argument index="1" name="skeleton" type="RID" /> <description> Attaches a skeleton to an instance. Removes the previous skeleton from the instance. </description> </method> <method name="instance_create"> - <return type="RID"> - </return> + <return type="RID" /> <description> Creates a visual instance and adds it to the RenderingServer. It can be accessed with the RID that is returned. This RID will be used in all [code]instance_*[/code] RenderingServer functions. Once finished with your RID, you will want to free the RID using the RenderingServer's [method free_rid] static method. @@ -1830,652 +1284,473 @@ </description> </method> <method name="instance_create2"> - <return type="RID"> - </return> - <argument index="0" name="base" type="RID"> - </argument> - <argument index="1" name="scenario" type="RID"> - </argument> + <return type="RID" /> + <argument index="0" name="base" type="RID" /> + <argument index="1" name="scenario" type="RID" /> <description> Creates a visual instance, adds it to the RenderingServer, and sets both base and scenario. It can be accessed with the RID that is returned. This RID will be used in all [code]instance_*[/code] RenderingServer functions. Once finished with your RID, you will want to free the RID using the RenderingServer's [method free_rid] static method. </description> </method> <method name="instance_geometry_get_shader_parameter" qualifiers="const"> - <return type="Variant"> - </return> - <argument index="0" name="instance" type="RID"> - </argument> - <argument index="1" name="parameter" type="StringName"> - </argument> + <return type="Variant" /> + <argument index="0" name="instance" type="RID" /> + <argument index="1" name="parameter" type="StringName" /> <description> </description> </method> <method name="instance_geometry_get_shader_parameter_default_value" qualifiers="const"> - <return type="Variant"> - </return> - <argument index="0" name="instance" type="RID"> - </argument> - <argument index="1" name="parameter" type="StringName"> - </argument> + <return type="Variant" /> + <argument index="0" name="instance" type="RID" /> + <argument index="1" name="parameter" type="StringName" /> <description> </description> </method> <method name="instance_geometry_get_shader_parameter_list" qualifiers="const"> - <return type="Array"> - </return> - <argument index="0" name="instance" type="RID"> - </argument> + <return type="Array" /> + <argument index="0" name="instance" type="RID" /> <description> </description> </method> <method name="instance_geometry_set_cast_shadows_setting"> - <return type="void"> - </return> - <argument index="0" name="instance" type="RID"> - </argument> - <argument index="1" name="shadow_casting_setting" type="int" enum="RenderingServer.ShadowCastingSetting"> - </argument> + <return type="void" /> + <argument index="0" name="instance" type="RID" /> + <argument index="1" name="shadow_casting_setting" type="int" enum="RenderingServer.ShadowCastingSetting" /> <description> Sets the shadow casting setting to one of [enum ShadowCastingSetting]. Equivalent to [member GeometryInstance3D.cast_shadow]. </description> </method> <method name="instance_geometry_set_flag"> - <return type="void"> - </return> - <argument index="0" name="instance" type="RID"> - </argument> - <argument index="1" name="flag" type="int" enum="RenderingServer.InstanceFlags"> - </argument> - <argument index="2" name="enabled" type="bool"> - </argument> + <return type="void" /> + <argument index="0" name="instance" type="RID" /> + <argument index="1" name="flag" type="int" enum="RenderingServer.InstanceFlags" /> + <argument index="2" name="enabled" type="bool" /> <description> Sets the flag for a given [enum InstanceFlags]. See [enum InstanceFlags] for more details. </description> </method> <method name="instance_geometry_set_lightmap"> - <return type="void"> - </return> - <argument index="0" name="instance" type="RID"> - </argument> - <argument index="1" name="lightmap" type="RID"> - </argument> - <argument index="2" name="lightmap_uv_scale" type="Rect2"> - </argument> - <argument index="3" name="lightmap_slice" type="int"> - </argument> + <return type="void" /> + <argument index="0" name="instance" type="RID" /> + <argument index="1" name="lightmap" type="RID" /> + <argument index="2" name="lightmap_uv_scale" type="Rect2" /> + <argument index="3" name="lightmap_slice" type="int" /> <description> </description> </method> <method name="instance_geometry_set_lod_bias"> - <return type="void"> - </return> - <argument index="0" name="instance" type="RID"> - </argument> - <argument index="1" name="lod_bias" type="float"> - </argument> + <return type="void" /> + <argument index="0" name="instance" type="RID" /> + <argument index="1" name="lod_bias" type="float" /> <description> </description> </method> <method name="instance_geometry_set_material_override"> - <return type="void"> - </return> - <argument index="0" name="instance" type="RID"> - </argument> - <argument index="1" name="material" type="RID"> - </argument> + <return type="void" /> + <argument index="0" name="instance" type="RID" /> + <argument index="1" name="material" type="RID" /> <description> Sets a material that will override the material for all surfaces on the mesh associated with this instance. Equivalent to [member GeometryInstance3D.material_override]. </description> </method> <method name="instance_geometry_set_shader_parameter"> - <return type="void"> - </return> - <argument index="0" name="instance" type="RID"> - </argument> - <argument index="1" name="parameter" type="StringName"> - </argument> - <argument index="2" name="value" type="Variant"> - </argument> + <return type="void" /> + <argument index="0" name="instance" type="RID" /> + <argument index="1" name="parameter" type="StringName" /> + <argument index="2" name="value" type="Variant" /> <description> </description> </method> <method name="instance_geometry_set_visibility_range"> - <return type="void"> - </return> - <argument index="0" name="instance" type="RID"> - </argument> - <argument index="1" name="min" type="float"> - </argument> - <argument index="2" name="max" type="float"> - </argument> - <argument index="3" name="min_margin" type="float"> - </argument> - <argument index="4" name="max_margin" type="float"> - </argument> + <return type="void" /> + <argument index="0" name="instance" type="RID" /> + <argument index="1" name="min" type="float" /> + <argument index="2" name="max" type="float" /> + <argument index="3" name="min_margin" type="float" /> + <argument index="4" name="max_margin" type="float" /> <description> Sets the visibility range values for the given geometry instance. Equivalent to [member GeometryInstance3D.visibility_range_begin] and related properties. </description> </method> <method name="instance_set_base"> - <return type="void"> - </return> - <argument index="0" name="instance" type="RID"> - </argument> - <argument index="1" name="base" type="RID"> - </argument> + <return type="void" /> + <argument index="0" name="instance" type="RID" /> + <argument index="1" name="base" type="RID" /> <description> Sets the base of the instance. A base can be any of the 3D objects that are created in the RenderingServer that can be displayed. For example, any of the light types, mesh, multimesh, immediate geometry, particle system, reflection probe, lightmap, and the GI probe are all types that can be set as the base of an instance in order to be displayed in the scenario. </description> </method> <method name="instance_set_blend_shape_weight"> - <return type="void"> - </return> - <argument index="0" name="instance" type="RID"> - </argument> - <argument index="1" name="shape" type="int"> - </argument> - <argument index="2" name="weight" type="float"> - </argument> + <return type="void" /> + <argument index="0" name="instance" type="RID" /> + <argument index="1" name="shape" type="int" /> + <argument index="2" name="weight" type="float" /> <description> Sets the weight for a given blend shape associated with this instance. </description> </method> <method name="instance_set_custom_aabb"> - <return type="void"> - </return> - <argument index="0" name="instance" type="RID"> - </argument> - <argument index="1" name="aabb" type="AABB"> - </argument> + <return type="void" /> + <argument index="0" name="instance" type="RID" /> + <argument index="1" name="aabb" type="AABB" /> <description> Sets a custom AABB to use when culling objects from the view frustum. Equivalent to [method GeometryInstance3D.set_custom_aabb]. </description> </method> <method name="instance_set_extra_visibility_margin"> - <return type="void"> - </return> - <argument index="0" name="instance" type="RID"> - </argument> - <argument index="1" name="margin" type="float"> - </argument> + <return type="void" /> + <argument index="0" name="instance" type="RID" /> + <argument index="1" name="margin" type="float" /> <description> Sets a margin to increase the size of the AABB when culling objects from the view frustum. This allows you to avoid culling objects that fall outside the view frustum. Equivalent to [member GeometryInstance3D.extra_cull_margin]. </description> </method> <method name="instance_set_layer_mask"> - <return type="void"> - </return> - <argument index="0" name="instance" type="RID"> - </argument> - <argument index="1" name="mask" type="int"> - </argument> + <return type="void" /> + <argument index="0" name="instance" type="RID" /> + <argument index="1" name="mask" type="int" /> <description> Sets the render layers that this instance will be drawn to. Equivalent to [member VisualInstance3D.layers]. </description> </method> <method name="instance_set_scenario"> - <return type="void"> - </return> - <argument index="0" name="instance" type="RID"> - </argument> - <argument index="1" name="scenario" type="RID"> - </argument> + <return type="void" /> + <argument index="0" name="instance" type="RID" /> + <argument index="1" name="scenario" type="RID" /> <description> Sets the scenario that the instance is in. The scenario is the 3D world that the objects will be displayed in. </description> </method> <method name="instance_set_surface_override_material"> - <return type="void"> - </return> - <argument index="0" name="instance" type="RID"> - </argument> - <argument index="1" name="surface" type="int"> - </argument> - <argument index="2" name="material" type="RID"> - </argument> + <return type="void" /> + <argument index="0" name="instance" type="RID" /> + <argument index="1" name="surface" type="int" /> + <argument index="2" name="material" type="RID" /> <description> Sets the override material of a specific surface. Equivalent to [method MeshInstance3D.set_surface_override_material]. </description> </method> <method name="instance_set_transform"> - <return type="void"> - </return> - <argument index="0" name="instance" type="RID"> - </argument> - <argument index="1" name="transform" type="Transform3D"> - </argument> + <return type="void" /> + <argument index="0" name="instance" type="RID" /> + <argument index="1" name="transform" type="Transform3D" /> <description> Sets the world space transform of the instance. Equivalent to [member Node3D.transform]. </description> </method> <method name="instance_set_visibility_parent"> - <return type="void"> - </return> - <argument index="0" name="instance" type="RID"> - </argument> - <argument index="1" name="parent" type="RID"> - </argument> + <return type="void" /> + <argument index="0" name="instance" type="RID" /> + <argument index="1" name="parent" type="RID" /> <description> Sets the visibility parent for the given instance. Equivalent to [member Node3D.visibility_parent]. </description> </method> <method name="instance_set_visible"> - <return type="void"> - </return> - <argument index="0" name="instance" type="RID"> - </argument> - <argument index="1" name="visible" type="bool"> - </argument> + <return type="void" /> + <argument index="0" name="instance" type="RID" /> + <argument index="1" name="visible" type="bool" /> <description> Sets whether an instance is drawn or not. Equivalent to [member Node3D.visible]. </description> </method> <method name="instances_cull_aabb" qualifiers="const"> - <return type="Array"> - </return> - <argument index="0" name="aabb" type="AABB"> - </argument> - <argument index="1" name="scenario" type="RID"> - </argument> + <return type="Array" /> + <argument index="0" name="aabb" type="AABB" /> + <argument index="1" name="scenario" type="RID" /> <description> Returns an array of object IDs intersecting with the provided AABB. Only visual 3D nodes are considered, such as [MeshInstance3D] or [DirectionalLight3D]. Use [method @GlobalScope.instance_from_id] to obtain the actual nodes. A scenario RID must be provided, which is available in the [World3D] you want to query. This forces an update for all resources queued to update. [b]Warning:[/b] This function is primarily intended for editor usage. For in-game use cases, prefer physics collision. </description> </method> <method name="instances_cull_convex" qualifiers="const"> - <return type="Array"> - </return> - <argument index="0" name="convex" type="Array"> - </argument> - <argument index="1" name="scenario" type="RID"> - </argument> + <return type="Array" /> + <argument index="0" name="convex" type="Array" /> + <argument index="1" name="scenario" type="RID" /> <description> Returns an array of object IDs intersecting with the provided convex shape. Only visual 3D nodes are considered, such as [MeshInstance3D] or [DirectionalLight3D]. Use [method @GlobalScope.instance_from_id] to obtain the actual nodes. A scenario RID must be provided, which is available in the [World3D] you want to query. This forces an update for all resources queued to update. [b]Warning:[/b] This function is primarily intended for editor usage. For in-game use cases, prefer physics collision. </description> </method> <method name="instances_cull_ray" qualifiers="const"> - <return type="Array"> - </return> - <argument index="0" name="from" type="Vector3"> - </argument> - <argument index="1" name="to" type="Vector3"> - </argument> - <argument index="2" name="scenario" type="RID"> - </argument> + <return type="Array" /> + <argument index="0" name="from" type="Vector3" /> + <argument index="1" name="to" type="Vector3" /> + <argument index="2" name="scenario" type="RID" /> <description> Returns an array of object IDs intersecting with the provided 3D ray. Only visual 3D nodes are considered, such as [MeshInstance3D] or [DirectionalLight3D]. Use [method @GlobalScope.instance_from_id] to obtain the actual nodes. A scenario RID must be provided, which is available in the [World3D] you want to query. This forces an update for all resources queued to update. [b]Warning:[/b] This function is primarily intended for editor usage. For in-game use cases, prefer physics collision. </description> </method> <method name="light_directional_set_blend_splits"> - <return type="void"> - </return> - <argument index="0" name="light" type="RID"> - </argument> - <argument index="1" name="enable" type="bool"> - </argument> + <return type="void" /> + <argument index="0" name="light" type="RID" /> + <argument index="1" name="enable" type="bool" /> <description> If [code]true[/code], this directional light will blend between shadow map splits resulting in a smoother transition between them. Equivalent to [member DirectionalLight3D.directional_shadow_blend_splits]. </description> </method> <method name="light_directional_set_shadow_mode"> - <return type="void"> - </return> - <argument index="0" name="light" type="RID"> - </argument> - <argument index="1" name="mode" type="int" enum="RenderingServer.LightDirectionalShadowMode"> - </argument> + <return type="void" /> + <argument index="0" name="light" type="RID" /> + <argument index="1" name="mode" type="int" enum="RenderingServer.LightDirectionalShadowMode" /> <description> Sets the shadow mode for this directional light. Equivalent to [member DirectionalLight3D.directional_shadow_mode]. See [enum LightDirectionalShadowMode] for options. </description> </method> <method name="light_directional_set_sky_only"> - <return type="void"> - </return> - <argument index="0" name="light" type="RID"> - </argument> - <argument index="1" name="enable" type="bool"> - </argument> + <return type="void" /> + <argument index="0" name="light" type="RID" /> + <argument index="1" name="enable" type="bool" /> <description> If [code]true[/code], this light will not be used for anything except sky shaders. Use this for lights that impact your sky shader that you may want to hide from affecting the rest of the scene. For example, you may want to enable this when the sun in your sky shader falls below the horizon. </description> </method> <method name="light_omni_set_shadow_mode"> - <return type="void"> - </return> - <argument index="0" name="light" type="RID"> - </argument> - <argument index="1" name="mode" type="int" enum="RenderingServer.LightOmniShadowMode"> - </argument> + <return type="void" /> + <argument index="0" name="light" type="RID" /> + <argument index="1" name="mode" type="int" enum="RenderingServer.LightOmniShadowMode" /> <description> Sets whether to use a dual paraboloid or a cubemap for the shadow map. Dual paraboloid is faster but may suffer from artifacts. Equivalent to [member OmniLight3D.omni_shadow_mode]. </description> </method> + <method name="light_projectors_set_filter"> + <return type="void" /> + <argument index="0" name="filter" type="int" enum="RenderingServer.LightProjectorFilter" /> + <description> + </description> + </method> <method name="light_set_bake_mode"> - <return type="void"> - </return> - <argument index="0" name="light" type="RID"> - </argument> - <argument index="1" name="bake_mode" type="int" enum="RenderingServer.LightBakeMode"> - </argument> + <return type="void" /> + <argument index="0" name="light" type="RID" /> + <argument index="1" name="bake_mode" type="int" enum="RenderingServer.LightBakeMode" /> <description> </description> </method> <method name="light_set_color"> - <return type="void"> - </return> - <argument index="0" name="light" type="RID"> - </argument> - <argument index="1" name="color" type="Color"> - </argument> + <return type="void" /> + <argument index="0" name="light" type="RID" /> + <argument index="1" name="color" type="Color" /> <description> Sets the color of the light. Equivalent to [member Light3D.light_color]. </description> </method> <method name="light_set_cull_mask"> - <return type="void"> - </return> - <argument index="0" name="light" type="RID"> - </argument> - <argument index="1" name="mask" type="int"> - </argument> + <return type="void" /> + <argument index="0" name="light" type="RID" /> + <argument index="1" name="mask" type="int" /> <description> Sets the cull mask for this Light3D. Lights only affect objects in the selected layers. Equivalent to [member Light3D.light_cull_mask]. </description> </method> <method name="light_set_max_sdfgi_cascade"> - <return type="void"> - </return> - <argument index="0" name="light" type="RID"> - </argument> - <argument index="1" name="cascade" type="int"> - </argument> + <return type="void" /> + <argument index="0" name="light" type="RID" /> + <argument index="1" name="cascade" type="int" /> <description> </description> </method> <method name="light_set_negative"> - <return type="void"> - </return> - <argument index="0" name="light" type="RID"> - </argument> - <argument index="1" name="enable" type="bool"> - </argument> + <return type="void" /> + <argument index="0" name="light" type="RID" /> + <argument index="1" name="enable" type="bool" /> <description> If [code]true[/code], light will subtract light instead of adding light. Equivalent to [member Light3D.light_negative]. </description> </method> <method name="light_set_param"> - <return type="void"> - </return> - <argument index="0" name="light" type="RID"> - </argument> - <argument index="1" name="param" type="int" enum="RenderingServer.LightParam"> - </argument> - <argument index="2" name="value" type="float"> - </argument> + <return type="void" /> + <argument index="0" name="light" type="RID" /> + <argument index="1" name="param" type="int" enum="RenderingServer.LightParam" /> + <argument index="2" name="value" type="float" /> <description> Sets the specified light parameter. See [enum LightParam] for options. Equivalent to [method Light3D.set_param]. </description> </method> <method name="light_set_projector"> - <return type="void"> - </return> - <argument index="0" name="light" type="RID"> - </argument> - <argument index="1" name="texture" type="RID"> - </argument> + <return type="void" /> + <argument index="0" name="light" type="RID" /> + <argument index="1" name="texture" type="RID" /> <description> Not implemented in Godot 3.x. </description> </method> <method name="light_set_reverse_cull_face_mode"> - <return type="void"> - </return> - <argument index="0" name="light" type="RID"> - </argument> - <argument index="1" name="enabled" type="bool"> - </argument> + <return type="void" /> + <argument index="0" name="light" type="RID" /> + <argument index="1" name="enabled" type="bool" /> <description> If [code]true[/code], reverses the backface culling of the mesh. This can be useful when you have a flat mesh that has a light behind it. If you need to cast a shadow on both sides of the mesh, set the mesh to use double-sided shadows with [method instance_geometry_set_cast_shadows_setting]. Equivalent to [member Light3D.shadow_reverse_cull_face]. </description> </method> <method name="light_set_shadow"> - <return type="void"> - </return> - <argument index="0" name="light" type="RID"> - </argument> - <argument index="1" name="enabled" type="bool"> - </argument> + <return type="void" /> + <argument index="0" name="light" type="RID" /> + <argument index="1" name="enabled" type="bool" /> <description> If [code]true[/code], light will cast shadows. Equivalent to [member Light3D.shadow_enabled]. </description> </method> <method name="light_set_shadow_color"> - <return type="void"> - </return> - <argument index="0" name="light" type="RID"> - </argument> - <argument index="1" name="color" type="Color"> - </argument> + <return type="void" /> + <argument index="0" name="light" type="RID" /> + <argument index="1" name="color" type="Color" /> <description> Sets the color of the shadow cast by the light. Equivalent to [member Light3D.shadow_color]. </description> </method> <method name="lightmap_create"> - <return type="RID"> - </return> + <return type="RID" /> <description> </description> </method> <method name="lightmap_get_probe_capture_bsp_tree" qualifiers="const"> - <return type="PackedInt32Array"> - </return> - <argument index="0" name="lightmap" type="RID"> - </argument> + <return type="PackedInt32Array" /> + <argument index="0" name="lightmap" type="RID" /> <description> </description> </method> <method name="lightmap_get_probe_capture_points" qualifiers="const"> - <return type="PackedVector3Array"> - </return> - <argument index="0" name="lightmap" type="RID"> - </argument> + <return type="PackedVector3Array" /> + <argument index="0" name="lightmap" type="RID" /> <description> </description> </method> <method name="lightmap_get_probe_capture_sh" qualifiers="const"> - <return type="PackedColorArray"> - </return> - <argument index="0" name="lightmap" type="RID"> - </argument> + <return type="PackedColorArray" /> + <argument index="0" name="lightmap" type="RID" /> <description> </description> </method> <method name="lightmap_get_probe_capture_tetrahedra" qualifiers="const"> - <return type="PackedInt32Array"> - </return> - <argument index="0" name="lightmap" type="RID"> - </argument> + <return type="PackedInt32Array" /> + <argument index="0" name="lightmap" type="RID" /> <description> </description> </method> <method name="lightmap_set_probe_bounds"> - <return type="void"> - </return> - <argument index="0" name="lightmap" type="RID"> - </argument> - <argument index="1" name="bounds" type="AABB"> - </argument> + <return type="void" /> + <argument index="0" name="lightmap" type="RID" /> + <argument index="1" name="bounds" type="AABB" /> <description> </description> </method> <method name="lightmap_set_probe_capture_data"> - <return type="void"> - </return> - <argument index="0" name="lightmap" type="RID"> - </argument> - <argument index="1" name="points" type="PackedVector3Array"> - </argument> - <argument index="2" name="point_sh" type="PackedColorArray"> - </argument> - <argument index="3" name="tetrahedra" type="PackedInt32Array"> - </argument> - <argument index="4" name="bsp_tree" type="PackedInt32Array"> - </argument> + <return type="void" /> + <argument index="0" name="lightmap" type="RID" /> + <argument index="1" name="points" type="PackedVector3Array" /> + <argument index="2" name="point_sh" type="PackedColorArray" /> + <argument index="3" name="tetrahedra" type="PackedInt32Array" /> + <argument index="4" name="bsp_tree" type="PackedInt32Array" /> <description> </description> </method> <method name="lightmap_set_probe_capture_update_speed"> - <return type="void"> - </return> - <argument index="0" name="speed" type="float"> - </argument> + <return type="void" /> + <argument index="0" name="speed" type="float" /> <description> </description> </method> <method name="lightmap_set_probe_interior"> - <return type="void"> - </return> - <argument index="0" name="lightmap" type="RID"> - </argument> - <argument index="1" name="interior" type="bool"> - </argument> + <return type="void" /> + <argument index="0" name="lightmap" type="RID" /> + <argument index="1" name="interior" type="bool" /> <description> </description> </method> <method name="lightmap_set_textures"> - <return type="void"> - </return> - <argument index="0" name="lightmap" type="RID"> - </argument> - <argument index="1" name="light" type="RID"> - </argument> - <argument index="2" name="uses_sh" type="bool"> - </argument> + <return type="void" /> + <argument index="0" name="lightmap" type="RID" /> + <argument index="1" name="light" type="RID" /> + <argument index="2" name="uses_sh" type="bool" /> <description> </description> </method> <method name="make_sphere_mesh"> - <return type="RID"> - </return> - <argument index="0" name="latitudes" type="int"> - </argument> - <argument index="1" name="longitudes" type="int"> - </argument> - <argument index="2" name="radius" type="float"> - </argument> + <return type="RID" /> + <argument index="0" name="latitudes" type="int" /> + <argument index="1" name="longitudes" type="int" /> + <argument index="2" name="radius" type="float" /> <description> Returns a mesh of a sphere with the given amount of horizontal and vertical subdivisions. </description> </method> <method name="material_create"> - <return type="RID"> - </return> + <return type="RID" /> <description> Creates an empty material and adds it to the RenderingServer. It can be accessed with the RID that is returned. This RID will be used in all [code]material_*[/code] RenderingServer functions. Once finished with your RID, you will want to free the RID using the RenderingServer's [method free_rid] static method. </description> </method> <method name="material_get_param" qualifiers="const"> - <return type="Variant"> - </return> - <argument index="0" name="material" type="RID"> - </argument> - <argument index="1" name="parameter" type="StringName"> - </argument> + <return type="Variant" /> + <argument index="0" name="material" type="RID" /> + <argument index="1" name="parameter" type="StringName" /> <description> Returns the value of a certain material's parameter. </description> </method> <method name="material_set_next_pass"> - <return type="void"> - </return> - <argument index="0" name="material" type="RID"> - </argument> - <argument index="1" name="next_material" type="RID"> - </argument> + <return type="void" /> + <argument index="0" name="material" type="RID" /> + <argument index="1" name="next_material" type="RID" /> <description> Sets an object's next material. </description> </method> <method name="material_set_param"> - <return type="void"> - </return> - <argument index="0" name="material" type="RID"> - </argument> - <argument index="1" name="parameter" type="StringName"> - </argument> - <argument index="2" name="value" type="Variant"> - </argument> + <return type="void" /> + <argument index="0" name="material" type="RID" /> + <argument index="1" name="parameter" type="StringName" /> + <argument index="2" name="value" type="Variant" /> <description> Sets a material's parameter. </description> </method> <method name="material_set_render_priority"> - <return type="void"> - </return> - <argument index="0" name="material" type="RID"> - </argument> - <argument index="1" name="priority" type="int"> - </argument> + <return type="void" /> + <argument index="0" name="material" type="RID" /> + <argument index="1" name="priority" type="int" /> <description> Sets a material's render priority. </description> </method> <method name="material_set_shader"> - <return type="void"> - </return> - <argument index="0" name="shader_material" type="RID"> - </argument> - <argument index="1" name="shader" type="RID"> - </argument> + <return type="void" /> + <argument index="0" name="shader_material" type="RID" /> + <argument index="1" name="shader" type="RID" /> <description> Sets a shader material's shader. </description> </method> <method name="mesh_add_surface"> - <return type="void"> - </return> - <argument index="0" name="mesh" type="RID"> - </argument> - <argument index="1" name="surface" type="Dictionary"> - </argument> + <return type="void" /> + <argument index="0" name="mesh" type="RID" /> + <argument index="1" name="surface" type="Dictionary" /> <description> </description> </method> <method name="mesh_add_surface_from_arrays"> - <return type="void"> - </return> - <argument index="0" name="mesh" type="RID"> - </argument> - <argument index="1" name="primitive" type="int" enum="RenderingServer.PrimitiveType"> - </argument> - <argument index="2" name="arrays" type="Array"> - </argument> - <argument index="3" name="blend_shapes" type="Array" default="[]"> - </argument> + <return type="void" /> + <argument index="0" name="mesh" type="RID" /> + <argument index="1" name="primitive" type="int" enum="RenderingServer.PrimitiveType" /> + <argument index="2" name="arrays" type="Array" /> + <argument index="3" name="blend_shapes" type="Array" default="[]" /> <argument index="4" name="lods" type="Dictionary" default="{ -}"> - </argument> - <argument index="5" name="compress_format" type="int" default="0"> - </argument> +}" /> + <argument index="5" name="compress_format" type="int" default="0" /> <description> </description> </method> <method name="mesh_clear"> - <return type="void"> - </return> - <argument index="0" name="mesh" type="RID"> - </argument> + <return type="void" /> + <argument index="0" name="mesh" type="RID" /> <description> Removes all surfaces from a mesh. </description> </method> <method name="mesh_create"> - <return type="RID"> - </return> + <return type="RID" /> <description> Creates a new mesh and adds it to the RenderingServer. It can be accessed with the RID that is returned. This RID will be used in all [code]mesh_*[/code] RenderingServer functions. Once finished with your RID, you will want to free the RID using the RenderingServer's [method free_rid] static method. @@ -2483,242 +1758,171 @@ </description> </method> <method name="mesh_create_from_surfaces"> - <return type="RID"> - </return> - <argument index="0" name="surfaces" type="Dictionary[]"> - </argument> - <argument index="1" name="blend_shape_count" type="int" default="0"> - </argument> + <return type="RID" /> + <argument index="0" name="surfaces" type="Dictionary[]" /> + <argument index="1" name="blend_shape_count" type="int" default="0" /> <description> </description> </method> <method name="mesh_get_blend_shape_count" qualifiers="const"> - <return type="int"> - </return> - <argument index="0" name="mesh" type="RID"> - </argument> + <return type="int" /> + <argument index="0" name="mesh" type="RID" /> <description> Returns a mesh's blend shape count. </description> </method> <method name="mesh_get_blend_shape_mode" qualifiers="const"> - <return type="int" enum="RenderingServer.BlendShapeMode"> - </return> - <argument index="0" name="mesh" type="RID"> - </argument> + <return type="int" enum="RenderingServer.BlendShapeMode" /> + <argument index="0" name="mesh" type="RID" /> <description> Returns a mesh's blend shape mode. </description> </method> <method name="mesh_get_custom_aabb" qualifiers="const"> - <return type="AABB"> - </return> - <argument index="0" name="mesh" type="RID"> - </argument> + <return type="AABB" /> + <argument index="0" name="mesh" type="RID" /> <description> Returns a mesh's custom aabb. </description> </method> <method name="mesh_get_surface"> - <return type="Dictionary"> - </return> - <argument index="0" name="mesh" type="RID"> - </argument> - <argument index="1" name="surface" type="int"> - </argument> + <return type="Dictionary" /> + <argument index="0" name="mesh" type="RID" /> + <argument index="1" name="surface" type="int" /> <description> </description> </method> <method name="mesh_get_surface_count" qualifiers="const"> - <return type="int"> - </return> - <argument index="0" name="mesh" type="RID"> - </argument> + <return type="int" /> + <argument index="0" name="mesh" type="RID" /> <description> Returns a mesh's number of surfaces. </description> </method> <method name="mesh_set_blend_shape_mode"> - <return type="void"> - </return> - <argument index="0" name="mesh" type="RID"> - </argument> - <argument index="1" name="mode" type="int" enum="RenderingServer.BlendShapeMode"> - </argument> + <return type="void" /> + <argument index="0" name="mesh" type="RID" /> + <argument index="1" name="mode" type="int" enum="RenderingServer.BlendShapeMode" /> <description> Sets a mesh's blend shape mode. </description> </method> <method name="mesh_set_custom_aabb"> - <return type="void"> - </return> - <argument index="0" name="mesh" type="RID"> - </argument> - <argument index="1" name="aabb" type="AABB"> - </argument> + <return type="void" /> + <argument index="0" name="mesh" type="RID" /> + <argument index="1" name="aabb" type="AABB" /> <description> Sets a mesh's custom aabb. </description> </method> <method name="mesh_set_shadow_mesh"> - <return type="void"> - </return> - <argument index="0" name="mesh" type="RID"> - </argument> - <argument index="1" name="shadow_mesh" type="RID"> - </argument> + <return type="void" /> + <argument index="0" name="mesh" type="RID" /> + <argument index="1" name="shadow_mesh" type="RID" /> <description> </description> </method> <method name="mesh_surface_get_arrays" qualifiers="const"> - <return type="Array"> - </return> - <argument index="0" name="mesh" type="RID"> - </argument> - <argument index="1" name="surface" type="int"> - </argument> + <return type="Array" /> + <argument index="0" name="mesh" type="RID" /> + <argument index="1" name="surface" type="int" /> <description> Returns a mesh's surface's buffer arrays. </description> </method> <method name="mesh_surface_get_blend_shape_arrays" qualifiers="const"> - <return type="Array"> - </return> - <argument index="0" name="mesh" type="RID"> - </argument> - <argument index="1" name="surface" type="int"> - </argument> + <return type="Array" /> + <argument index="0" name="mesh" type="RID" /> + <argument index="1" name="surface" type="int" /> <description> Returns a mesh's surface's arrays for blend shapes. </description> </method> <method name="mesh_surface_get_format_attribute_stride" qualifiers="const"> - <return type="int"> - </return> - <argument index="0" name="format" type="int"> - </argument> - <argument index="1" name="vertex_count" type="int"> - </argument> + <return type="int" /> + <argument index="0" name="format" type="int" /> + <argument index="1" name="vertex_count" type="int" /> <description> </description> </method> <method name="mesh_surface_get_format_offset" qualifiers="const"> - <return type="int"> - </return> - <argument index="0" name="format" type="int"> - </argument> - <argument index="1" name="vertex_count" type="int"> - </argument> - <argument index="2" name="array_index" type="int"> - </argument> + <return type="int" /> + <argument index="0" name="format" type="int" /> + <argument index="1" name="vertex_count" type="int" /> + <argument index="2" name="array_index" type="int" /> <description> </description> </method> <method name="mesh_surface_get_format_skin_stride" qualifiers="const"> - <return type="int"> - </return> - <argument index="0" name="format" type="int"> - </argument> - <argument index="1" name="vertex_count" type="int"> - </argument> + <return type="int" /> + <argument index="0" name="format" type="int" /> + <argument index="1" name="vertex_count" type="int" /> <description> </description> </method> <method name="mesh_surface_get_format_vertex_stride" qualifiers="const"> - <return type="int"> - </return> - <argument index="0" name="format" type="int"> - </argument> - <argument index="1" name="vertex_count" type="int"> - </argument> + <return type="int" /> + <argument index="0" name="format" type="int" /> + <argument index="1" name="vertex_count" type="int" /> <description> </description> </method> <method name="mesh_surface_get_material" qualifiers="const"> - <return type="RID"> - </return> - <argument index="0" name="mesh" type="RID"> - </argument> - <argument index="1" name="surface" type="int"> - </argument> + <return type="RID" /> + <argument index="0" name="mesh" type="RID" /> + <argument index="1" name="surface" type="int" /> <description> Returns a mesh's surface's material. </description> </method> <method name="mesh_surface_set_material"> - <return type="void"> - </return> - <argument index="0" name="mesh" type="RID"> - </argument> - <argument index="1" name="surface" type="int"> - </argument> - <argument index="2" name="material" type="RID"> - </argument> + <return type="void" /> + <argument index="0" name="mesh" type="RID" /> + <argument index="1" name="surface" type="int" /> + <argument index="2" name="material" type="RID" /> <description> Sets a mesh's surface's material. </description> </method> <method name="mesh_surface_update_attribute_region"> - <return type="void"> - </return> - <argument index="0" name="mesh" type="RID"> - </argument> - <argument index="1" name="surface" type="int"> - </argument> - <argument index="2" name="offset" type="int"> - </argument> - <argument index="3" name="data" type="PackedByteArray"> - </argument> + <return type="void" /> + <argument index="0" name="mesh" type="RID" /> + <argument index="1" name="surface" type="int" /> + <argument index="2" name="offset" type="int" /> + <argument index="3" name="data" type="PackedByteArray" /> <description> </description> </method> <method name="mesh_surface_update_skin_region"> - <return type="void"> - </return> - <argument index="0" name="mesh" type="RID"> - </argument> - <argument index="1" name="surface" type="int"> - </argument> - <argument index="2" name="offset" type="int"> - </argument> - <argument index="3" name="data" type="PackedByteArray"> - </argument> + <return type="void" /> + <argument index="0" name="mesh" type="RID" /> + <argument index="1" name="surface" type="int" /> + <argument index="2" name="offset" type="int" /> + <argument index="3" name="data" type="PackedByteArray" /> <description> </description> </method> <method name="mesh_surface_update_vertex_region"> - <return type="void"> - </return> - <argument index="0" name="mesh" type="RID"> - </argument> - <argument index="1" name="surface" type="int"> - </argument> - <argument index="2" name="offset" type="int"> - </argument> - <argument index="3" name="data" type="PackedByteArray"> - </argument> + <return type="void" /> + <argument index="0" name="mesh" type="RID" /> + <argument index="1" name="surface" type="int" /> + <argument index="2" name="offset" type="int" /> + <argument index="3" name="data" type="PackedByteArray" /> <description> </description> </method> <method name="multimesh_allocate_data"> - <return type="void"> - </return> - <argument index="0" name="multimesh" type="RID"> - </argument> - <argument index="1" name="instances" type="int"> - </argument> - <argument index="2" name="transform_format" type="int" enum="RenderingServer.MultimeshTransformFormat"> - </argument> - <argument index="3" name="color_format" type="bool" default="false"> - </argument> - <argument index="4" name="custom_data_format" type="bool" default="false"> - </argument> + <return type="void" /> + <argument index="0" name="multimesh" type="RID" /> + <argument index="1" name="instances" type="int" /> + <argument index="2" name="transform_format" type="int" enum="RenderingServer.MultimeshTransformFormat" /> + <argument index="3" name="color_format" type="bool" default="false" /> + <argument index="4" name="custom_data_format" type="bool" default="false" /> <description> </description> </method> <method name="multimesh_create"> - <return type="RID"> - </return> + <return type="RID" /> <description> Creates a new multimesh on the RenderingServer and returns an [RID] handle. This RID will be used in all [code]multimesh_*[/code] RenderingServer functions. Once finished with your RID, you will want to free the RID using the RenderingServer's [method free_rid] static method. @@ -2726,198 +1930,145 @@ </description> </method> <method name="multimesh_get_aabb" qualifiers="const"> - <return type="AABB"> - </return> - <argument index="0" name="multimesh" type="RID"> - </argument> + <return type="AABB" /> + <argument index="0" name="multimesh" type="RID" /> <description> Calculates and returns the axis-aligned bounding box that encloses all instances within the multimesh. </description> </method> <method name="multimesh_get_buffer" qualifiers="const"> - <return type="PackedFloat32Array"> - </return> - <argument index="0" name="multimesh" type="RID"> - </argument> + <return type="PackedFloat32Array" /> + <argument index="0" name="multimesh" type="RID" /> <description> </description> </method> <method name="multimesh_get_instance_count" qualifiers="const"> - <return type="int"> - </return> - <argument index="0" name="multimesh" type="RID"> - </argument> + <return type="int" /> + <argument index="0" name="multimesh" type="RID" /> <description> Returns the number of instances allocated for this multimesh. </description> </method> <method name="multimesh_get_mesh" qualifiers="const"> - <return type="RID"> - </return> - <argument index="0" name="multimesh" type="RID"> - </argument> + <return type="RID" /> + <argument index="0" name="multimesh" type="RID" /> <description> Returns the RID of the mesh that will be used in drawing this multimesh. </description> </method> <method name="multimesh_get_visible_instances" qualifiers="const"> - <return type="int"> - </return> - <argument index="0" name="multimesh" type="RID"> - </argument> + <return type="int" /> + <argument index="0" name="multimesh" type="RID" /> <description> Returns the number of visible instances for this multimesh. </description> </method> <method name="multimesh_instance_get_color" qualifiers="const"> - <return type="Color"> - </return> - <argument index="0" name="multimesh" type="RID"> - </argument> - <argument index="1" name="index" type="int"> - </argument> + <return type="Color" /> + <argument index="0" name="multimesh" type="RID" /> + <argument index="1" name="index" type="int" /> <description> Returns the color by which the specified instance will be modulated. </description> </method> <method name="multimesh_instance_get_custom_data" qualifiers="const"> - <return type="Color"> - </return> - <argument index="0" name="multimesh" type="RID"> - </argument> - <argument index="1" name="index" type="int"> - </argument> + <return type="Color" /> + <argument index="0" name="multimesh" type="RID" /> + <argument index="1" name="index" type="int" /> <description> Returns the custom data associated with the specified instance. </description> </method> <method name="multimesh_instance_get_transform" qualifiers="const"> - <return type="Transform3D"> - </return> - <argument index="0" name="multimesh" type="RID"> - </argument> - <argument index="1" name="index" type="int"> - </argument> + <return type="Transform3D" /> + <argument index="0" name="multimesh" type="RID" /> + <argument index="1" name="index" type="int" /> <description> Returns the [Transform3D] of the specified instance. </description> </method> <method name="multimesh_instance_get_transform_2d" qualifiers="const"> - <return type="Transform2D"> - </return> - <argument index="0" name="multimesh" type="RID"> - </argument> - <argument index="1" name="index" type="int"> - </argument> + <return type="Transform2D" /> + <argument index="0" name="multimesh" type="RID" /> + <argument index="1" name="index" type="int" /> <description> Returns the [Transform2D] of the specified instance. For use when the multimesh is set to use 2D transforms. </description> </method> <method name="multimesh_instance_set_color"> - <return type="void"> - </return> - <argument index="0" name="multimesh" type="RID"> - </argument> - <argument index="1" name="index" type="int"> - </argument> - <argument index="2" name="color" type="Color"> - </argument> + <return type="void" /> + <argument index="0" name="multimesh" type="RID" /> + <argument index="1" name="index" type="int" /> + <argument index="2" name="color" type="Color" /> <description> Sets the color by which this instance will be modulated. Equivalent to [method MultiMesh.set_instance_color]. </description> </method> <method name="multimesh_instance_set_custom_data"> - <return type="void"> - </return> - <argument index="0" name="multimesh" type="RID"> - </argument> - <argument index="1" name="index" type="int"> - </argument> - <argument index="2" name="custom_data" type="Color"> - </argument> + <return type="void" /> + <argument index="0" name="multimesh" type="RID" /> + <argument index="1" name="index" type="int" /> + <argument index="2" name="custom_data" type="Color" /> <description> Sets the custom data for this instance. Custom data is passed as a [Color], but is interpreted as a [code]vec4[/code] in the shader. Equivalent to [method MultiMesh.set_instance_custom_data]. </description> </method> <method name="multimesh_instance_set_transform"> - <return type="void"> - </return> - <argument index="0" name="multimesh" type="RID"> - </argument> - <argument index="1" name="index" type="int"> - </argument> - <argument index="2" name="transform" type="Transform3D"> - </argument> + <return type="void" /> + <argument index="0" name="multimesh" type="RID" /> + <argument index="1" name="index" type="int" /> + <argument index="2" name="transform" type="Transform3D" /> <description> Sets the [Transform3D] for this instance. Equivalent to [method MultiMesh.set_instance_transform]. </description> </method> <method name="multimesh_instance_set_transform_2d"> - <return type="void"> - </return> - <argument index="0" name="multimesh" type="RID"> - </argument> - <argument index="1" name="index" type="int"> - </argument> - <argument index="2" name="transform" type="Transform2D"> - </argument> + <return type="void" /> + <argument index="0" name="multimesh" type="RID" /> + <argument index="1" name="index" type="int" /> + <argument index="2" name="transform" type="Transform2D" /> <description> Sets the [Transform2D] for this instance. For use when multimesh is used in 2D. Equivalent to [method MultiMesh.set_instance_transform_2d]. </description> </method> <method name="multimesh_set_buffer"> - <return type="void"> - </return> - <argument index="0" name="multimesh" type="RID"> - </argument> - <argument index="1" name="buffer" type="PackedFloat32Array"> - </argument> + <return type="void" /> + <argument index="0" name="multimesh" type="RID" /> + <argument index="1" name="buffer" type="PackedFloat32Array" /> <description> </description> </method> <method name="multimesh_set_mesh"> - <return type="void"> - </return> - <argument index="0" name="multimesh" type="RID"> - </argument> - <argument index="1" name="mesh" type="RID"> - </argument> + <return type="void" /> + <argument index="0" name="multimesh" type="RID" /> + <argument index="1" name="mesh" type="RID" /> <description> Sets the mesh to be drawn by the multimesh. Equivalent to [member MultiMesh.mesh]. </description> </method> <method name="multimesh_set_visible_instances"> - <return type="void"> - </return> - <argument index="0" name="multimesh" type="RID"> - </argument> - <argument index="1" name="visible" type="int"> - </argument> + <return type="void" /> + <argument index="0" name="multimesh" type="RID" /> + <argument index="1" name="visible" type="int" /> <description> Sets the number of instances visible at a given time. If -1, all instances that have been allocated are drawn. Equivalent to [member MultiMesh.visible_instance_count]. </description> </method> <method name="occluder_create"> - <return type="RID"> - </return> + <return type="RID" /> <description> </description> </method> <method name="occluder_set_mesh"> - <return type="void"> - </return> - <argument index="0" name="occluder" type="RID"> - </argument> - <argument index="1" name="vertices" type="PackedVector3Array"> - </argument> - <argument index="2" name="indices" type="PackedInt32Array"> - </argument> + <return type="void" /> + <argument index="0" name="occluder" type="RID" /> + <argument index="1" name="vertices" type="PackedVector3Array" /> + <argument index="2" name="indices" type="PackedInt32Array" /> <description> </description> </method> <method name="omni_light_create"> - <return type="RID"> - </return> + <return type="RID" /> <description> Creates a new omni light and adds it to the RenderingServer. It can be accessed with the RID that is returned. This RID can be used in most [code]light_*[/code] RenderingServer functions. Once finished with your RID, you will want to free the RID using the RenderingServer's [method free_rid] static method. @@ -2925,112 +2076,81 @@ </description> </method> <method name="particles_collision_create"> - <return type="RID"> - </return> + <return type="RID" /> <description> </description> </method> <method name="particles_collision_height_field_update"> - <return type="void"> - </return> - <argument index="0" name="particles_collision" type="RID"> - </argument> + <return type="void" /> + <argument index="0" name="particles_collision" type="RID" /> <description> </description> </method> <method name="particles_collision_set_attractor_attenuation"> - <return type="void"> - </return> - <argument index="0" name="particles_collision" type="RID"> - </argument> - <argument index="1" name="curve" type="float"> - </argument> + <return type="void" /> + <argument index="0" name="particles_collision" type="RID" /> + <argument index="1" name="curve" type="float" /> <description> </description> </method> <method name="particles_collision_set_attractor_directionality"> - <return type="void"> - </return> - <argument index="0" name="particles_collision" type="RID"> - </argument> - <argument index="1" name="amount" type="float"> - </argument> + <return type="void" /> + <argument index="0" name="particles_collision" type="RID" /> + <argument index="1" name="amount" type="float" /> <description> </description> </method> <method name="particles_collision_set_attractor_strength"> - <return type="void"> - </return> - <argument index="0" name="particles_collision" type="RID"> - </argument> - <argument index="1" name="setrngth" type="float"> - </argument> + <return type="void" /> + <argument index="0" name="particles_collision" type="RID" /> + <argument index="1" name="setrngth" type="float" /> <description> </description> </method> <method name="particles_collision_set_box_extents"> - <return type="void"> - </return> - <argument index="0" name="particles_collision" type="RID"> - </argument> - <argument index="1" name="extents" type="Vector3"> - </argument> + <return type="void" /> + <argument index="0" name="particles_collision" type="RID" /> + <argument index="1" name="extents" type="Vector3" /> <description> </description> </method> <method name="particles_collision_set_collision_type"> - <return type="void"> - </return> - <argument index="0" name="particles_collision" type="RID"> - </argument> - <argument index="1" name="type" type="int" enum="RenderingServer.ParticlesCollisionType"> - </argument> + <return type="void" /> + <argument index="0" name="particles_collision" type="RID" /> + <argument index="1" name="type" type="int" enum="RenderingServer.ParticlesCollisionType" /> <description> </description> </method> <method name="particles_collision_set_cull_mask"> - <return type="void"> - </return> - <argument index="0" name="particles_collision" type="RID"> - </argument> - <argument index="1" name="mask" type="int"> - </argument> + <return type="void" /> + <argument index="0" name="particles_collision" type="RID" /> + <argument index="1" name="mask" type="int" /> <description> </description> </method> <method name="particles_collision_set_field_texture"> - <return type="void"> - </return> - <argument index="0" name="particles_collision" type="RID"> - </argument> - <argument index="1" name="texture" type="RID"> - </argument> + <return type="void" /> + <argument index="0" name="particles_collision" type="RID" /> + <argument index="1" name="texture" type="RID" /> <description> </description> </method> <method name="particles_collision_set_height_field_resolution"> - <return type="void"> - </return> - <argument index="0" name="particles_collision" type="RID"> - </argument> - <argument index="1" name="resolution" type="int" enum="RenderingServer.ParticlesCollisionHeightfieldResolution"> - </argument> + <return type="void" /> + <argument index="0" name="particles_collision" type="RID" /> + <argument index="1" name="resolution" type="int" enum="RenderingServer.ParticlesCollisionHeightfieldResolution" /> <description> </description> </method> <method name="particles_collision_set_sphere_radius"> - <return type="void"> - </return> - <argument index="0" name="particles_collision" type="RID"> - </argument> - <argument index="1" name="radius" type="float"> - </argument> + <return type="void" /> + <argument index="0" name="particles_collision" type="RID" /> + <argument index="1" name="radius" type="float" /> <description> </description> </method> <method name="particles_create"> - <return type="RID"> - </return> + <return type="RID" /> <description> Creates a particle system and adds it to the RenderingServer. It can be accessed with the RID that is returned. This RID will be used in all [code]particles_*[/code] RenderingServer functions. Once finished with your RID, you will want to free the RID using the RenderingServer's [method free_rid] static method. @@ -3038,332 +2158,240 @@ </description> </method> <method name="particles_emit"> - <return type="void"> - </return> - <argument index="0" name="particles" type="RID"> - </argument> - <argument index="1" name="transform" type="Transform3D"> - </argument> - <argument index="2" name="velocity" type="Vector3"> - </argument> - <argument index="3" name="color" type="Color"> - </argument> - <argument index="4" name="custom" type="Color"> - </argument> - <argument index="5" name="emit_flags" type="int"> - </argument> + <return type="void" /> + <argument index="0" name="particles" type="RID" /> + <argument index="1" name="transform" type="Transform3D" /> + <argument index="2" name="velocity" type="Vector3" /> + <argument index="3" name="color" type="Color" /> + <argument index="4" name="custom" type="Color" /> + <argument index="5" name="emit_flags" type="int" /> <description> </description> </method> <method name="particles_get_current_aabb"> - <return type="AABB"> - </return> - <argument index="0" name="particles" type="RID"> - </argument> + <return type="AABB" /> + <argument index="0" name="particles" type="RID" /> <description> Calculates and returns the axis-aligned bounding box that contains all the particles. Equivalent to [method GPUParticles3D.capture_aabb]. </description> </method> <method name="particles_get_emitting"> - <return type="bool"> - </return> - <argument index="0" name="particles" type="RID"> - </argument> + <return type="bool" /> + <argument index="0" name="particles" type="RID" /> <description> Returns [code]true[/code] if particles are currently set to emitting. </description> </method> <method name="particles_is_inactive"> - <return type="bool"> - </return> - <argument index="0" name="particles" type="RID"> - </argument> + <return type="bool" /> + <argument index="0" name="particles" type="RID" /> <description> Returns [code]true[/code] if particles are not emitting and particles are set to inactive. </description> </method> <method name="particles_request_process"> - <return type="void"> - </return> - <argument index="0" name="particles" type="RID"> - </argument> + <return type="void" /> + <argument index="0" name="particles" type="RID" /> <description> Add particle system to list of particle systems that need to be updated. Update will take place on the next frame, or on the next call to [method instances_cull_aabb], [method instances_cull_convex], or [method instances_cull_ray]. </description> </method> <method name="particles_restart"> - <return type="void"> - </return> - <argument index="0" name="particles" type="RID"> - </argument> + <return type="void" /> + <argument index="0" name="particles" type="RID" /> <description> Reset the particles on the next update. Equivalent to [method GPUParticles3D.restart]. </description> </method> <method name="particles_set_amount"> - <return type="void"> - </return> - <argument index="0" name="particles" type="RID"> - </argument> - <argument index="1" name="amount" type="int"> - </argument> + <return type="void" /> + <argument index="0" name="particles" type="RID" /> + <argument index="1" name="amount" type="int" /> <description> Sets the number of particles to be drawn and allocates the memory for them. Equivalent to [member GPUParticles3D.amount]. </description> </method> <method name="particles_set_collision_base_size"> - <return type="void"> - </return> - <argument index="0" name="particles" type="RID"> - </argument> - <argument index="1" name="size" type="float"> - </argument> + <return type="void" /> + <argument index="0" name="particles" type="RID" /> + <argument index="1" name="size" type="float" /> <description> </description> </method> <method name="particles_set_custom_aabb"> - <return type="void"> - </return> - <argument index="0" name="particles" type="RID"> - </argument> - <argument index="1" name="aabb" type="AABB"> - </argument> + <return type="void" /> + <argument index="0" name="particles" type="RID" /> + <argument index="1" name="aabb" type="AABB" /> <description> Sets a custom axis-aligned bounding box for the particle system. Equivalent to [member GPUParticles3D.visibility_aabb]. </description> </method> <method name="particles_set_draw_order"> - <return type="void"> - </return> - <argument index="0" name="particles" type="RID"> - </argument> - <argument index="1" name="order" type="int" enum="RenderingServer.ParticlesDrawOrder"> - </argument> + <return type="void" /> + <argument index="0" name="particles" type="RID" /> + <argument index="1" name="order" type="int" enum="RenderingServer.ParticlesDrawOrder" /> <description> Sets the draw order of the particles to one of the named enums from [enum ParticlesDrawOrder]. See [enum ParticlesDrawOrder] for options. Equivalent to [member GPUParticles3D.draw_order]. </description> </method> <method name="particles_set_draw_pass_mesh"> - <return type="void"> - </return> - <argument index="0" name="particles" type="RID"> - </argument> - <argument index="1" name="pass" type="int"> - </argument> - <argument index="2" name="mesh" type="RID"> - </argument> + <return type="void" /> + <argument index="0" name="particles" type="RID" /> + <argument index="1" name="pass" type="int" /> + <argument index="2" name="mesh" type="RID" /> <description> Sets the mesh to be used for the specified draw pass. Equivalent to [member GPUParticles3D.draw_pass_1], [member GPUParticles3D.draw_pass_2], [member GPUParticles3D.draw_pass_3], and [member GPUParticles3D.draw_pass_4]. </description> </method> <method name="particles_set_draw_passes"> - <return type="void"> - </return> - <argument index="0" name="particles" type="RID"> - </argument> - <argument index="1" name="count" type="int"> - </argument> + <return type="void" /> + <argument index="0" name="particles" type="RID" /> + <argument index="1" name="count" type="int" /> <description> Sets the number of draw passes to use. Equivalent to [member GPUParticles3D.draw_passes]. </description> </method> <method name="particles_set_emission_transform"> - <return type="void"> - </return> - <argument index="0" name="particles" type="RID"> - </argument> - <argument index="1" name="transform" type="Transform3D"> - </argument> + <return type="void" /> + <argument index="0" name="particles" type="RID" /> + <argument index="1" name="transform" type="Transform3D" /> <description> Sets the [Transform3D] that will be used by the particles when they first emit. </description> </method> <method name="particles_set_emitting"> - <return type="void"> - </return> - <argument index="0" name="particles" type="RID"> - </argument> - <argument index="1" name="emitting" type="bool"> - </argument> + <return type="void" /> + <argument index="0" name="particles" type="RID" /> + <argument index="1" name="emitting" type="bool" /> <description> If [code]true[/code], particles will emit over time. Setting to false does not reset the particles, but only stops their emission. Equivalent to [member GPUParticles3D.emitting]. </description> </method> <method name="particles_set_explosiveness_ratio"> - <return type="void"> - </return> - <argument index="0" name="particles" type="RID"> - </argument> - <argument index="1" name="ratio" type="float"> - </argument> + <return type="void" /> + <argument index="0" name="particles" type="RID" /> + <argument index="1" name="ratio" type="float" /> <description> Sets the explosiveness ratio. Equivalent to [member GPUParticles3D.explosiveness]. </description> </method> <method name="particles_set_fixed_fps"> - <return type="void"> - </return> - <argument index="0" name="particles" type="RID"> - </argument> - <argument index="1" name="fps" type="int"> - </argument> + <return type="void" /> + <argument index="0" name="particles" type="RID" /> + <argument index="1" name="fps" type="int" /> <description> Sets the frame rate that the particle system rendering will be fixed to. Equivalent to [member GPUParticles3D.fixed_fps]. </description> </method> <method name="particles_set_fractional_delta"> - <return type="void"> - </return> - <argument index="0" name="particles" type="RID"> - </argument> - <argument index="1" name="enable" type="bool"> - </argument> + <return type="void" /> + <argument index="0" name="particles" type="RID" /> + <argument index="1" name="enable" type="bool" /> <description> If [code]true[/code], uses fractional delta which smooths the movement of the particles. Equivalent to [member GPUParticles3D.fract_delta]. </description> </method> <method name="particles_set_interpolate"> - <return type="void"> - </return> - <argument index="0" name="particles" type="RID"> - </argument> - <argument index="1" name="enable" type="bool"> - </argument> + <return type="void" /> + <argument index="0" name="particles" type="RID" /> + <argument index="1" name="enable" type="bool" /> <description> </description> </method> <method name="particles_set_lifetime"> - <return type="void"> - </return> - <argument index="0" name="particles" type="RID"> - </argument> - <argument index="1" name="lifetime" type="float"> - </argument> + <return type="void" /> + <argument index="0" name="particles" type="RID" /> + <argument index="1" name="lifetime" type="float" /> <description> Sets the lifetime of each particle in the system. Equivalent to [member GPUParticles3D.lifetime]. </description> </method> <method name="particles_set_mode"> - <return type="void"> - </return> - <argument index="0" name="particles" type="RID"> - </argument> - <argument index="1" name="mode" type="int" enum="RenderingServer.ParticlesMode"> - </argument> + <return type="void" /> + <argument index="0" name="particles" type="RID" /> + <argument index="1" name="mode" type="int" enum="RenderingServer.ParticlesMode" /> <description> </description> </method> <method name="particles_set_one_shot"> - <return type="void"> - </return> - <argument index="0" name="particles" type="RID"> - </argument> - <argument index="1" name="one_shot" type="bool"> - </argument> + <return type="void" /> + <argument index="0" name="particles" type="RID" /> + <argument index="1" name="one_shot" type="bool" /> <description> If [code]true[/code], particles will emit once and then stop. Equivalent to [member GPUParticles3D.one_shot]. </description> </method> <method name="particles_set_pre_process_time"> - <return type="void"> - </return> - <argument index="0" name="particles" type="RID"> - </argument> - <argument index="1" name="time" type="float"> - </argument> + <return type="void" /> + <argument index="0" name="particles" type="RID" /> + <argument index="1" name="time" type="float" /> <description> Sets the preprocess time for the particles' animation. This lets you delay starting an animation until after the particles have begun emitting. Equivalent to [member GPUParticles3D.preprocess]. </description> </method> <method name="particles_set_process_material"> - <return type="void"> - </return> - <argument index="0" name="particles" type="RID"> - </argument> - <argument index="1" name="material" type="RID"> - </argument> + <return type="void" /> + <argument index="0" name="particles" type="RID" /> + <argument index="1" name="material" type="RID" /> <description> Sets the material for processing the particles. Note: this is not the material used to draw the materials. Equivalent to [member GPUParticles3D.process_material]. </description> </method> <method name="particles_set_randomness_ratio"> - <return type="void"> - </return> - <argument index="0" name="particles" type="RID"> - </argument> - <argument index="1" name="ratio" type="float"> - </argument> + <return type="void" /> + <argument index="0" name="particles" type="RID" /> + <argument index="1" name="ratio" type="float" /> <description> Sets the emission randomness ratio. This randomizes the emission of particles within their phase. Equivalent to [member GPUParticles3D.randomness]. </description> </method> <method name="particles_set_speed_scale"> - <return type="void"> - </return> - <argument index="0" name="particles" type="RID"> - </argument> - <argument index="1" name="scale" type="float"> - </argument> + <return type="void" /> + <argument index="0" name="particles" type="RID" /> + <argument index="1" name="scale" type="float" /> <description> Sets the speed scale of the particle system. Equivalent to [member GPUParticles3D.speed_scale]. </description> </method> <method name="particles_set_subemitter"> - <return type="void"> - </return> - <argument index="0" name="particles" type="RID"> - </argument> - <argument index="1" name="subemitter_particles" type="RID"> - </argument> + <return type="void" /> + <argument index="0" name="particles" type="RID" /> + <argument index="1" name="subemitter_particles" type="RID" /> <description> </description> </method> <method name="particles_set_trail_bind_poses"> - <return type="void"> - </return> - <argument index="0" name="particles" type="RID"> - </argument> - <argument index="1" name="bind_poses" type="Transform3D[]"> - </argument> + <return type="void" /> + <argument index="0" name="particles" type="RID" /> + <argument index="1" name="bind_poses" type="Transform3D[]" /> <description> </description> </method> <method name="particles_set_trails"> - <return type="void"> - </return> - <argument index="0" name="particles" type="RID"> - </argument> - <argument index="1" name="enable" type="bool"> - </argument> - <argument index="2" name="length_sec" type="float"> - </argument> + <return type="void" /> + <argument index="0" name="particles" type="RID" /> + <argument index="1" name="enable" type="bool" /> + <argument index="2" name="length_sec" type="float" /> <description> </description> </method> <method name="particles_set_transform_align"> - <return type="void"> - </return> - <argument index="0" name="particles" type="RID"> - </argument> - <argument index="1" name="align" type="int" enum="RenderingServer.ParticlesTransformAlign"> - </argument> + <return type="void" /> + <argument index="0" name="particles" type="RID" /> + <argument index="1" name="align" type="int" enum="RenderingServer.ParticlesTransformAlign" /> <description> </description> </method> <method name="particles_set_use_local_coordinates"> - <return type="void"> - </return> - <argument index="0" name="particles" type="RID"> - </argument> - <argument index="1" name="enable" type="bool"> - </argument> + <return type="void" /> + <argument index="0" name="particles" type="RID" /> + <argument index="1" name="enable" type="bool" /> <description> If [code]true[/code], particles use local coordinates. If [code]false[/code] they use global coordinates. Equivalent to [member GPUParticles3D.local_coords]. </description> </method> <method name="reflection_probe_create"> - <return type="RID"> - </return> + <return type="RID" /> <description> Creates a reflection probe and adds it to the RenderingServer. It can be accessed with the RID that is returned. This RID will be used in all [code]reflection_probe_*[/code] RenderingServer functions. Once finished with your RID, you will want to free the RID using the RenderingServer's [method free_rid] static method. @@ -3371,171 +2399,124 @@ </description> </method> <method name="reflection_probe_set_ambient_color"> - <return type="void"> - </return> - <argument index="0" name="probe" type="RID"> - </argument> - <argument index="1" name="color" type="Color"> - </argument> + <return type="void" /> + <argument index="0" name="probe" type="RID" /> + <argument index="1" name="color" type="Color" /> <description> </description> </method> <method name="reflection_probe_set_ambient_energy"> - <return type="void"> - </return> - <argument index="0" name="probe" type="RID"> - </argument> - <argument index="1" name="energy" type="float"> - </argument> + <return type="void" /> + <argument index="0" name="probe" type="RID" /> + <argument index="1" name="energy" type="float" /> <description> </description> </method> <method name="reflection_probe_set_ambient_mode"> - <return type="void"> - </return> - <argument index="0" name="probe" type="RID"> - </argument> - <argument index="1" name="mode" type="int" enum="RenderingServer.ReflectionProbeAmbientMode"> - </argument> + <return type="void" /> + <argument index="0" name="probe" type="RID" /> + <argument index="1" name="mode" type="int" enum="RenderingServer.ReflectionProbeAmbientMode" /> <description> </description> </method> <method name="reflection_probe_set_as_interior"> - <return type="void"> - </return> - <argument index="0" name="probe" type="RID"> - </argument> - <argument index="1" name="enable" type="bool"> - </argument> + <return type="void" /> + <argument index="0" name="probe" type="RID" /> + <argument index="1" name="enable" type="bool" /> <description> If [code]true[/code], reflections will ignore sky contribution. Equivalent to [member ReflectionProbe.interior]. </description> </method> <method name="reflection_probe_set_cull_mask"> - <return type="void"> - </return> - <argument index="0" name="probe" type="RID"> - </argument> - <argument index="1" name="layers" type="int"> - </argument> + <return type="void" /> + <argument index="0" name="probe" type="RID" /> + <argument index="1" name="layers" type="int" /> <description> Sets the render cull mask for this reflection probe. Only instances with a matching cull mask will be rendered by this probe. Equivalent to [member ReflectionProbe.cull_mask]. </description> </method> <method name="reflection_probe_set_enable_box_projection"> - <return type="void"> - </return> - <argument index="0" name="probe" type="RID"> - </argument> - <argument index="1" name="enable" type="bool"> - </argument> + <return type="void" /> + <argument index="0" name="probe" type="RID" /> + <argument index="1" name="enable" type="bool" /> <description> If [code]true[/code], uses box projection. This can make reflections look more correct in certain situations. Equivalent to [member ReflectionProbe.box_projection]. </description> </method> <method name="reflection_probe_set_enable_shadows"> - <return type="void"> - </return> - <argument index="0" name="probe" type="RID"> - </argument> - <argument index="1" name="enable" type="bool"> - </argument> + <return type="void" /> + <argument index="0" name="probe" type="RID" /> + <argument index="1" name="enable" type="bool" /> <description> If [code]true[/code], computes shadows in the reflection probe. This makes the reflection much slower to compute. Equivalent to [member ReflectionProbe.enable_shadows]. </description> </method> <method name="reflection_probe_set_extents"> - <return type="void"> - </return> - <argument index="0" name="probe" type="RID"> - </argument> - <argument index="1" name="extents" type="Vector3"> - </argument> + <return type="void" /> + <argument index="0" name="probe" type="RID" /> + <argument index="1" name="extents" type="Vector3" /> <description> Sets the size of the area that the reflection probe will capture. Equivalent to [member ReflectionProbe.extents]. </description> </method> <method name="reflection_probe_set_intensity"> - <return type="void"> - </return> - <argument index="0" name="probe" type="RID"> - </argument> - <argument index="1" name="intensity" type="float"> - </argument> + <return type="void" /> + <argument index="0" name="probe" type="RID" /> + <argument index="1" name="intensity" type="float" /> <description> Sets the intensity of the reflection probe. Intensity modulates the strength of the reflection. Equivalent to [member ReflectionProbe.intensity]. </description> </method> <method name="reflection_probe_set_lod_threshold"> - <return type="void"> - </return> - <argument index="0" name="probe" type="RID"> - </argument> - <argument index="1" name="pixels" type="float"> - </argument> + <return type="void" /> + <argument index="0" name="probe" type="RID" /> + <argument index="1" name="pixels" type="float" /> <description> </description> </method> <method name="reflection_probe_set_max_distance"> - <return type="void"> - </return> - <argument index="0" name="probe" type="RID"> - </argument> - <argument index="1" name="distance" type="float"> - </argument> + <return type="void" /> + <argument index="0" name="probe" type="RID" /> + <argument index="1" name="distance" type="float" /> <description> Sets the max distance away from the probe an object can be before it is culled. Equivalent to [member ReflectionProbe.max_distance]. </description> </method> <method name="reflection_probe_set_origin_offset"> - <return type="void"> - </return> - <argument index="0" name="probe" type="RID"> - </argument> - <argument index="1" name="offset" type="Vector3"> - </argument> + <return type="void" /> + <argument index="0" name="probe" type="RID" /> + <argument index="1" name="offset" type="Vector3" /> <description> Sets the origin offset to be used when this reflection probe is in box project mode. Equivalent to [member ReflectionProbe.origin_offset]. </description> </method> <method name="reflection_probe_set_resolution"> - <return type="void"> - </return> - <argument index="0" name="probe" type="RID"> - </argument> - <argument index="1" name="resolution" type="int"> - </argument> + <return type="void" /> + <argument index="0" name="probe" type="RID" /> + <argument index="1" name="resolution" type="int" /> <description> </description> </method> <method name="reflection_probe_set_update_mode"> - <return type="void"> - </return> - <argument index="0" name="probe" type="RID"> - </argument> - <argument index="1" name="mode" type="int" enum="RenderingServer.ReflectionProbeUpdateMode"> - </argument> + <return type="void" /> + <argument index="0" name="probe" type="RID" /> + <argument index="1" name="mode" type="int" enum="RenderingServer.ReflectionProbeUpdateMode" /> <description> Sets how often the reflection probe updates. Can either be once or every frame. See [enum ReflectionProbeUpdateMode] for options. </description> </method> <method name="request_frame_drawn_callback"> - <return type="void"> - </return> - <argument index="0" name="where" type="Object"> - </argument> - <argument index="1" name="method" type="StringName"> - </argument> - <argument index="2" name="userdata" type="Variant"> - </argument> + <return type="void" /> + <argument index="0" name="where" type="Object" /> + <argument index="1" name="method" type="StringName" /> + <argument index="2" name="userdata" type="Variant" /> <description> Schedules a callback to the corresponding named [code]method[/code] on [code]where[/code] after a frame has been drawn. The callback method must use only 1 argument which will be called with [code]userdata[/code]. </description> </method> <method name="scenario_create"> - <return type="RID"> - </return> + <return type="RID" /> <description> Creates a scenario and adds it to the RenderingServer. It can be accessed with the RID that is returned. This RID will be used in all [code]scenario_*[/code] RenderingServer functions. Once finished with your RID, you will want to free the RID using the RenderingServer's [method free_rid] static method. @@ -3543,293 +2524,214 @@ </description> </method> <method name="scenario_set_camera_effects"> - <return type="void"> - </return> - <argument index="0" name="scenario" type="RID"> - </argument> - <argument index="1" name="effects" type="RID"> - </argument> + <return type="void" /> + <argument index="0" name="scenario" type="RID" /> + <argument index="1" name="effects" type="RID" /> <description> </description> </method> <method name="scenario_set_environment"> - <return type="void"> - </return> - <argument index="0" name="scenario" type="RID"> - </argument> - <argument index="1" name="environment" type="RID"> - </argument> + <return type="void" /> + <argument index="0" name="scenario" type="RID" /> + <argument index="1" name="environment" type="RID" /> <description> Sets the environment that will be used with this scenario. </description> </method> <method name="scenario_set_fallback_environment"> - <return type="void"> - </return> - <argument index="0" name="scenario" type="RID"> - </argument> - <argument index="1" name="environment" type="RID"> - </argument> + <return type="void" /> + <argument index="0" name="scenario" type="RID" /> + <argument index="1" name="environment" type="RID" /> <description> Sets the fallback environment to be used by this scenario. The fallback environment is used if no environment is set. Internally, this is used by the editor to provide a default environment. </description> </method> <method name="screen_space_roughness_limiter_set_active"> - <return type="void"> - </return> - <argument index="0" name="enable" type="bool"> - </argument> - <argument index="1" name="amount" type="float"> - </argument> - <argument index="2" name="limit" type="float"> - </argument> + <return type="void" /> + <argument index="0" name="enable" type="bool" /> + <argument index="1" name="amount" type="float" /> + <argument index="2" name="limit" type="float" /> <description> </description> </method> <method name="set_boot_image"> - <return type="void"> - </return> - <argument index="0" name="image" type="Image"> - </argument> - <argument index="1" name="color" type="Color"> - </argument> - <argument index="2" name="scale" type="bool"> - </argument> - <argument index="3" name="use_filter" type="bool" default="true"> - </argument> + <return type="void" /> + <argument index="0" name="image" type="Image" /> + <argument index="1" name="color" type="Color" /> + <argument index="2" name="scale" type="bool" /> + <argument index="3" name="use_filter" type="bool" default="true" /> <description> Sets a boot image. The color defines the background color. If [code]scale[/code] is [code]true[/code], the image will be scaled to fit the screen size. If [code]use_filter[/code] is [code]true[/code], the image will be scaled with linear interpolation. If [code]use_filter[/code] is [code]false[/code], the image will be scaled with nearest-neighbor interpolation. </description> </method> <method name="set_debug_generate_wireframes"> - <return type="void"> - </return> - <argument index="0" name="generate" type="bool"> - </argument> + <return type="void" /> + <argument index="0" name="generate" type="bool" /> <description> If [code]true[/code], the engine will generate wireframes for use with the wireframe debug mode. </description> </method> <method name="set_default_clear_color"> - <return type="void"> - </return> - <argument index="0" name="color" type="Color"> - </argument> + <return type="void" /> + <argument index="0" name="color" type="Color" /> <description> Sets the default clear color which is used when a specific clear color has not been selected. </description> </method> <method name="shader_create"> - <return type="RID"> - </return> + <return type="RID" /> <description> Creates an empty shader and adds it to the RenderingServer. It can be accessed with the RID that is returned. This RID will be used in all [code]shader_*[/code] RenderingServer functions. Once finished with your RID, you will want to free the RID using the RenderingServer's [method free_rid] static method. </description> </method> <method name="shader_get_code" qualifiers="const"> - <return type="String"> - </return> - <argument index="0" name="shader" type="RID"> - </argument> + <return type="String" /> + <argument index="0" name="shader" type="RID" /> <description> Returns a shader's code. </description> </method> <method name="shader_get_default_texture_param" qualifiers="const"> - <return type="RID"> - </return> - <argument index="0" name="shader" type="RID"> - </argument> - <argument index="1" name="param" type="StringName"> - </argument> + <return type="RID" /> + <argument index="0" name="shader" type="RID" /> + <argument index="1" name="param" type="StringName" /> <description> Returns a default texture from a shader searched by name. </description> </method> <method name="shader_get_param_default" qualifiers="const"> - <return type="Variant"> - </return> - <argument index="0" name="shader" type="RID"> - </argument> - <argument index="1" name="param" type="StringName"> - </argument> + <return type="Variant" /> + <argument index="0" name="shader" type="RID" /> + <argument index="1" name="param" type="StringName" /> <description> </description> </method> <method name="shader_get_param_list" qualifiers="const"> - <return type="Dictionary[]"> - </return> - <argument index="0" name="shader" type="RID"> - </argument> + <return type="Dictionary[]" /> + <argument index="0" name="shader" type="RID" /> <description> Returns the parameters of a shader. </description> </method> <method name="shader_set_default_texture_param"> - <return type="void"> - </return> - <argument index="0" name="shader" type="RID"> - </argument> - <argument index="1" name="param" type="StringName"> - </argument> - <argument index="2" name="texture" type="RID"> - </argument> + <return type="void" /> + <argument index="0" name="shader" type="RID" /> + <argument index="1" name="param" type="StringName" /> + <argument index="2" name="texture" type="RID" /> <description> Sets a shader's default texture. Overwrites the texture given by name. </description> </method> <method name="shadows_quality_set"> - <return type="void"> - </return> - <argument index="0" name="quality" type="int" enum="RenderingServer.ShadowQuality"> - </argument> + <return type="void" /> + <argument index="0" name="quality" type="int" enum="RenderingServer.ShadowQuality" /> <description> </description> </method> <method name="skeleton_allocate_data"> - <return type="void"> - </return> - <argument index="0" name="skeleton" type="RID"> - </argument> - <argument index="1" name="bones" type="int"> - </argument> - <argument index="2" name="is_2d_skeleton" type="bool" default="false"> - </argument> + <return type="void" /> + <argument index="0" name="skeleton" type="RID" /> + <argument index="1" name="bones" type="int" /> + <argument index="2" name="is_2d_skeleton" type="bool" default="false" /> <description> </description> </method> <method name="skeleton_bone_get_transform" qualifiers="const"> - <return type="Transform3D"> - </return> - <argument index="0" name="skeleton" type="RID"> - </argument> - <argument index="1" name="bone" type="int"> - </argument> + <return type="Transform3D" /> + <argument index="0" name="skeleton" type="RID" /> + <argument index="1" name="bone" type="int" /> <description> Returns the [Transform3D] set for a specific bone of this skeleton. </description> </method> <method name="skeleton_bone_get_transform_2d" qualifiers="const"> - <return type="Transform2D"> - </return> - <argument index="0" name="skeleton" type="RID"> - </argument> - <argument index="1" name="bone" type="int"> - </argument> + <return type="Transform2D" /> + <argument index="0" name="skeleton" type="RID" /> + <argument index="1" name="bone" type="int" /> <description> Returns the [Transform2D] set for a specific bone of this skeleton. </description> </method> <method name="skeleton_bone_set_transform"> - <return type="void"> - </return> - <argument index="0" name="skeleton" type="RID"> - </argument> - <argument index="1" name="bone" type="int"> - </argument> - <argument index="2" name="transform" type="Transform3D"> - </argument> + <return type="void" /> + <argument index="0" name="skeleton" type="RID" /> + <argument index="1" name="bone" type="int" /> + <argument index="2" name="transform" type="Transform3D" /> <description> Sets the [Transform3D] for a specific bone of this skeleton. </description> </method> <method name="skeleton_bone_set_transform_2d"> - <return type="void"> - </return> - <argument index="0" name="skeleton" type="RID"> - </argument> - <argument index="1" name="bone" type="int"> - </argument> - <argument index="2" name="transform" type="Transform2D"> - </argument> + <return type="void" /> + <argument index="0" name="skeleton" type="RID" /> + <argument index="1" name="bone" type="int" /> + <argument index="2" name="transform" type="Transform2D" /> <description> Sets the [Transform2D] for a specific bone of this skeleton. </description> </method> <method name="skeleton_create"> - <return type="RID"> - </return> + <return type="RID" /> <description> Creates a skeleton and adds it to the RenderingServer. It can be accessed with the RID that is returned. This RID will be used in all [code]skeleton_*[/code] RenderingServer functions. Once finished with your RID, you will want to free the RID using the RenderingServer's [method free_rid] static method. </description> </method> <method name="skeleton_get_bone_count" qualifiers="const"> - <return type="int"> - </return> - <argument index="0" name="skeleton" type="RID"> - </argument> + <return type="int" /> + <argument index="0" name="skeleton" type="RID" /> <description> Returns the number of bones allocated for this skeleton. </description> </method> <method name="skeleton_set_base_transform_2d"> - <return type="void"> - </return> - <argument index="0" name="skeleton" type="RID"> - </argument> - <argument index="1" name="base_transform" type="Transform2D"> - </argument> + <return type="void" /> + <argument index="0" name="skeleton" type="RID" /> + <argument index="1" name="base_transform" type="Transform2D" /> <description> </description> </method> <method name="sky_bake_panorama"> - <return type="Image"> - </return> - <argument index="0" name="sky" type="RID"> - </argument> - <argument index="1" name="energy" type="float"> - </argument> - <argument index="2" name="bake_irradiance" type="bool"> - </argument> - <argument index="3" name="size" type="Vector2i"> - </argument> + <return type="Image" /> + <argument index="0" name="sky" type="RID" /> + <argument index="1" name="energy" type="float" /> + <argument index="2" name="bake_irradiance" type="bool" /> + <argument index="3" name="size" type="Vector2i" /> <description> </description> </method> <method name="sky_create"> - <return type="RID"> - </return> + <return type="RID" /> <description> Creates an empty sky and adds it to the RenderingServer. It can be accessed with the RID that is returned. This RID will be used in all [code]sky_*[/code] RenderingServer functions. Once finished with your RID, you will want to free the RID using the RenderingServer's [method free_rid] static method. </description> </method> <method name="sky_set_material"> - <return type="void"> - </return> - <argument index="0" name="sky" type="RID"> - </argument> - <argument index="1" name="material" type="RID"> - </argument> + <return type="void" /> + <argument index="0" name="sky" type="RID" /> + <argument index="1" name="material" type="RID" /> <description> Sets the material that the sky uses to render the background and reflection maps. </description> </method> <method name="sky_set_mode"> - <return type="void"> - </return> - <argument index="0" name="sky" type="RID"> - </argument> - <argument index="1" name="mode" type="int" enum="RenderingServer.SkyMode"> - </argument> + <return type="void" /> + <argument index="0" name="sky" type="RID" /> + <argument index="1" name="mode" type="int" enum="RenderingServer.SkyMode" /> <description> </description> </method> <method name="sky_set_radiance_size"> - <return type="void"> - </return> - <argument index="0" name="sky" type="RID"> - </argument> - <argument index="1" name="radiance_size" type="int"> - </argument> + <return type="void" /> + <argument index="0" name="sky" type="RID" /> + <argument index="1" name="radiance_size" type="int" /> <description> </description> </method> <method name="spot_light_create"> - <return type="RID"> - </return> + <return type="RID" /> <description> Creates a spot light and adds it to the RenderingServer. It can be accessed with the RID that is returned. This RID can be used in most [code]light_*[/code] RenderingServer functions. Once finished with your RID, you will want to free the RID using the RenderingServer's [method free_rid] static method. @@ -3837,226 +2739,161 @@ </description> </method> <method name="sub_surface_scattering_set_quality"> - <return type="void"> - </return> - <argument index="0" name="quality" type="int" enum="RenderingServer.SubSurfaceScatteringQuality"> - </argument> + <return type="void" /> + <argument index="0" name="quality" type="int" enum="RenderingServer.SubSurfaceScatteringQuality" /> <description> </description> </method> <method name="sub_surface_scattering_set_scale"> - <return type="void"> - </return> - <argument index="0" name="scale" type="float"> - </argument> - <argument index="1" name="depth_scale" type="float"> - </argument> + <return type="void" /> + <argument index="0" name="scale" type="float" /> + <argument index="1" name="depth_scale" type="float" /> <description> </description> </method> <method name="texture_2d_create"> - <return type="RID"> - </return> - <argument index="0" name="image" type="Image"> - </argument> + <return type="RID" /> + <argument index="0" name="image" type="Image" /> <description> </description> </method> <method name="texture_2d_get" qualifiers="const"> - <return type="Image"> - </return> - <argument index="0" name="texture" type="RID"> - </argument> + <return type="Image" /> + <argument index="0" name="texture" type="RID" /> <description> </description> </method> <method name="texture_2d_layer_get" qualifiers="const"> - <return type="Image"> - </return> - <argument index="0" name="texture" type="RID"> - </argument> - <argument index="1" name="layer" type="int"> - </argument> + <return type="Image" /> + <argument index="0" name="texture" type="RID" /> + <argument index="1" name="layer" type="int" /> <description> </description> </method> <method name="texture_2d_layered_create"> - <return type="RID"> - </return> - <argument index="0" name="layers" type="Image[]"> - </argument> - <argument index="1" name="layered_type" type="int" enum="RenderingServer.TextureLayeredType"> - </argument> + <return type="RID" /> + <argument index="0" name="layers" type="Image[]" /> + <argument index="1" name="layered_type" type="int" enum="RenderingServer.TextureLayeredType" /> <description> </description> </method> <method name="texture_2d_layered_placeholder_create"> - <return type="RID"> - </return> - <argument index="0" name="layered_type" type="int" enum="RenderingServer.TextureLayeredType"> - </argument> + <return type="RID" /> + <argument index="0" name="layered_type" type="int" enum="RenderingServer.TextureLayeredType" /> <description> </description> </method> <method name="texture_2d_placeholder_create"> - <return type="RID"> - </return> + <return type="RID" /> <description> </description> </method> <method name="texture_2d_update"> - <return type="void"> - </return> - <argument index="0" name="texture" type="RID"> - </argument> - <argument index="1" name="image" type="Image"> - </argument> - <argument index="2" name="layer" type="int"> - </argument> + <return type="void" /> + <argument index="0" name="texture" type="RID" /> + <argument index="1" name="image" type="Image" /> + <argument index="2" name="layer" type="int" /> <description> </description> </method> <method name="texture_3d_create"> - <return type="RID"> - </return> - <argument index="0" name="format" type="int" enum="Image.Format"> - </argument> - <argument index="1" name="width" type="int"> - </argument> - <argument index="2" name="height" type="int"> - </argument> - <argument index="3" name="depth" type="int"> - </argument> - <argument index="4" name="mipmaps" type="bool"> - </argument> - <argument index="5" name="data" type="Image[]"> - </argument> + <return type="RID" /> + <argument index="0" name="format" type="int" enum="Image.Format" /> + <argument index="1" name="width" type="int" /> + <argument index="2" name="height" type="int" /> + <argument index="3" name="depth" type="int" /> + <argument index="4" name="mipmaps" type="bool" /> + <argument index="5" name="data" type="Image[]" /> <description> </description> </method> <method name="texture_3d_get" qualifiers="const"> - <return type="Image[]"> - </return> - <argument index="0" name="texture" type="RID"> - </argument> + <return type="Image[]" /> + <argument index="0" name="texture" type="RID" /> <description> </description> </method> <method name="texture_3d_placeholder_create"> - <return type="RID"> - </return> + <return type="RID" /> <description> </description> </method> <method name="texture_3d_update"> - <return type="void"> - </return> - <argument index="0" name="texture" type="RID"> - </argument> - <argument index="1" name="data" type="Image[]"> - </argument> + <return type="void" /> + <argument index="0" name="texture" type="RID" /> + <argument index="1" name="data" type="Image[]" /> <description> </description> </method> <method name="texture_get_path" qualifiers="const"> - <return type="String"> - </return> - <argument index="0" name="texture" type="RID"> - </argument> + <return type="String" /> + <argument index="0" name="texture" type="RID" /> <description> </description> </method> <method name="texture_proxy_create"> - <return type="RID"> - </return> - <argument index="0" name="base" type="RID"> - </argument> + <return type="RID" /> + <argument index="0" name="base" type="RID" /> <description> </description> </method> <method name="texture_proxy_update"> - <return type="void"> - </return> - <argument index="0" name="texture" type="RID"> - </argument> - <argument index="1" name="proxy_to" type="RID"> - </argument> + <return type="void" /> + <argument index="0" name="texture" type="RID" /> + <argument index="1" name="proxy_to" type="RID" /> <description> </description> </method> <method name="texture_replace"> - <return type="void"> - </return> - <argument index="0" name="texture" type="RID"> - </argument> - <argument index="1" name="by_texture" type="RID"> - </argument> + <return type="void" /> + <argument index="0" name="texture" type="RID" /> + <argument index="1" name="by_texture" type="RID" /> <description> </description> </method> <method name="texture_set_force_redraw_if_visible"> - <return type="void"> - </return> - <argument index="0" name="texture" type="RID"> - </argument> - <argument index="1" name="enable" type="bool"> - </argument> + <return type="void" /> + <argument index="0" name="texture" type="RID" /> + <argument index="1" name="enable" type="bool" /> <description> </description> </method> <method name="texture_set_path"> - <return type="void"> - </return> - <argument index="0" name="texture" type="RID"> - </argument> - <argument index="1" name="path" type="String"> - </argument> + <return type="void" /> + <argument index="0" name="texture" type="RID" /> + <argument index="1" name="path" type="String" /> <description> </description> </method> <method name="texture_set_size_override"> - <return type="void"> - </return> - <argument index="0" name="texture" type="RID"> - </argument> - <argument index="1" name="width" type="int"> - </argument> - <argument index="2" name="height" type="int"> - </argument> + <return type="void" /> + <argument index="0" name="texture" type="RID" /> + <argument index="1" name="width" type="int" /> + <argument index="2" name="height" type="int" /> <description> </description> </method> <method name="viewport_attach_camera"> - <return type="void"> - </return> - <argument index="0" name="viewport" type="RID"> - </argument> - <argument index="1" name="camera" type="RID"> - </argument> + <return type="void" /> + <argument index="0" name="viewport" type="RID" /> + <argument index="1" name="camera" type="RID" /> <description> Sets a viewport's camera. </description> </method> <method name="viewport_attach_canvas"> - <return type="void"> - </return> - <argument index="0" name="viewport" type="RID"> - </argument> - <argument index="1" name="canvas" type="RID"> - </argument> + <return type="void" /> + <argument index="0" name="viewport" type="RID" /> + <argument index="1" name="canvas" type="RID" /> <description> Sets a viewport's canvas. </description> </method> <method name="viewport_attach_to_screen"> - <return type="void"> - </return> - <argument index="0" name="viewport" type="RID"> - </argument> - <argument index="1" name="rect" type="Rect2" default="Rect2(0, 0, 0, 0)"> - </argument> - <argument index="2" name="screen" type="int" default="0"> - </argument> + <return type="void" /> + <argument index="0" name="viewport" type="RID" /> + <argument index="1" name="rect" type="Rect2" default="Rect2(0, 0, 0, 0)" /> + <argument index="2" name="screen" type="int" default="0" /> <description> Copies the viewport to a region of the screen specified by [code]rect[/code]. If [method viewport_set_render_direct_to_screen] is [code]true[/code], then the viewport does not use a framebuffer and the contents of the viewport are rendered directly to screen. However, note that the root viewport is drawn last, therefore it will draw over the screen. Accordingly, you must set the root viewport to an area that does not cover the area that you have attached this viewport to. For example, you can set the root viewport to not render at all with the following code: @@ -4072,570 +2909,408 @@ </description> </method> <method name="viewport_create"> - <return type="RID"> - </return> + <return type="RID" /> <description> Creates an empty viewport and adds it to the RenderingServer. It can be accessed with the RID that is returned. This RID will be used in all [code]viewport_*[/code] RenderingServer functions. Once finished with your RID, you will want to free the RID using the RenderingServer's [method free_rid] static method. </description> </method> <method name="viewport_get_measured_render_time_cpu" qualifiers="const"> - <return type="float"> - </return> - <argument index="0" name="viewport" type="RID"> - </argument> + <return type="float" /> + <argument index="0" name="viewport" type="RID" /> <description> </description> </method> <method name="viewport_get_measured_render_time_gpu" qualifiers="const"> - <return type="float"> - </return> - <argument index="0" name="viewport" type="RID"> - </argument> + <return type="float" /> + <argument index="0" name="viewport" type="RID" /> <description> </description> </method> <method name="viewport_get_render_info"> - <return type="int"> - </return> - <argument index="0" name="viewport" type="RID"> - </argument> - <argument index="1" name="type" type="int" enum="RenderingServer.ViewportRenderInfoType"> - </argument> - <argument index="2" name="info" type="int" enum="RenderingServer.ViewportRenderInfo"> - </argument> + <return type="int" /> + <argument index="0" name="viewport" type="RID" /> + <argument index="1" name="type" type="int" enum="RenderingServer.ViewportRenderInfoType" /> + <argument index="2" name="info" type="int" enum="RenderingServer.ViewportRenderInfo" /> <description> </description> </method> <method name="viewport_get_texture" qualifiers="const"> - <return type="RID"> - </return> - <argument index="0" name="viewport" type="RID"> - </argument> + <return type="RID" /> + <argument index="0" name="viewport" type="RID" /> <description> Returns the viewport's last rendered frame. </description> </method> <method name="viewport_remove_canvas"> - <return type="void"> - </return> - <argument index="0" name="viewport" type="RID"> - </argument> - <argument index="1" name="canvas" type="RID"> - </argument> + <return type="void" /> + <argument index="0" name="viewport" type="RID" /> + <argument index="1" name="canvas" type="RID" /> <description> Detaches a viewport from a canvas and vice versa. </description> </method> <method name="viewport_set_active"> - <return type="void"> - </return> - <argument index="0" name="viewport" type="RID"> - </argument> - <argument index="1" name="active" type="bool"> - </argument> + <return type="void" /> + <argument index="0" name="viewport" type="RID" /> + <argument index="1" name="active" type="bool" /> <description> If [code]true[/code], sets the viewport active, else sets it inactive. </description> </method> <method name="viewport_set_canvas_stacking"> - <return type="void"> - </return> - <argument index="0" name="viewport" type="RID"> - </argument> - <argument index="1" name="canvas" type="RID"> - </argument> - <argument index="2" name="layer" type="int"> - </argument> - <argument index="3" name="sublayer" type="int"> - </argument> + <return type="void" /> + <argument index="0" name="viewport" type="RID" /> + <argument index="1" name="canvas" type="RID" /> + <argument index="2" name="layer" type="int" /> + <argument index="3" name="sublayer" type="int" /> <description> Sets the stacking order for a viewport's canvas. [code]layer[/code] is the actual canvas layer, while [code]sublayer[/code] specifies the stacking order of the canvas among those in the same layer. </description> </method> <method name="viewport_set_canvas_transform"> - <return type="void"> - </return> - <argument index="0" name="viewport" type="RID"> - </argument> - <argument index="1" name="canvas" type="RID"> - </argument> - <argument index="2" name="offset" type="Transform2D"> - </argument> + <return type="void" /> + <argument index="0" name="viewport" type="RID" /> + <argument index="1" name="canvas" type="RID" /> + <argument index="2" name="offset" type="Transform2D" /> <description> Sets the transformation of a viewport's canvas. </description> </method> <method name="viewport_set_clear_mode"> - <return type="void"> - </return> - <argument index="0" name="viewport" type="RID"> - </argument> - <argument index="1" name="clear_mode" type="int" enum="RenderingServer.ViewportClearMode"> - </argument> + <return type="void" /> + <argument index="0" name="viewport" type="RID" /> + <argument index="1" name="clear_mode" type="int" enum="RenderingServer.ViewportClearMode" /> <description> Sets the clear mode of a viewport. See [enum ViewportClearMode] for options. </description> </method> <method name="viewport_set_debug_draw"> - <return type="void"> - </return> - <argument index="0" name="viewport" type="RID"> - </argument> - <argument index="1" name="draw" type="int" enum="RenderingServer.ViewportDebugDraw"> - </argument> + <return type="void" /> + <argument index="0" name="viewport" type="RID" /> + <argument index="1" name="draw" type="int" enum="RenderingServer.ViewportDebugDraw" /> <description> Sets the debug draw mode of a viewport. See [enum ViewportDebugDraw] for options. </description> </method> <method name="viewport_set_default_canvas_item_texture_filter"> - <return type="void"> - </return> - <argument index="0" name="viewport" type="RID"> - </argument> - <argument index="1" name="filter" type="int" enum="RenderingServer.CanvasItemTextureFilter"> - </argument> + <return type="void" /> + <argument index="0" name="viewport" type="RID" /> + <argument index="1" name="filter" type="int" enum="RenderingServer.CanvasItemTextureFilter" /> <description> </description> </method> <method name="viewport_set_default_canvas_item_texture_repeat"> - <return type="void"> - </return> - <argument index="0" name="viewport" type="RID"> - </argument> - <argument index="1" name="repeat" type="int" enum="RenderingServer.CanvasItemTextureRepeat"> - </argument> + <return type="void" /> + <argument index="0" name="viewport" type="RID" /> + <argument index="1" name="repeat" type="int" enum="RenderingServer.CanvasItemTextureRepeat" /> <description> </description> </method> <method name="viewport_set_disable_2d"> - <return type="void"> - </return> - <argument index="0" name="viewport" type="RID"> - </argument> - <argument index="1" name="disable" type="bool"> - </argument> + <return type="void" /> + <argument index="0" name="viewport" type="RID" /> + <argument index="1" name="disable" type="bool" /> <description> If [code]true[/code], the viewport's canvas is not rendered. </description> </method> <method name="viewport_set_disable_3d"> - <return type="void"> - </return> - <argument index="0" name="viewport" type="RID"> - </argument> - <argument index="1" name="disable" type="bool"> - </argument> + <return type="void" /> + <argument index="0" name="viewport" type="RID" /> + <argument index="1" name="disable" type="bool" /> <description> </description> </method> <method name="viewport_set_disable_environment"> - <return type="void"> - </return> - <argument index="0" name="viewport" type="RID"> - </argument> - <argument index="1" name="disabled" type="bool"> - </argument> + <return type="void" /> + <argument index="0" name="viewport" type="RID" /> + <argument index="1" name="disabled" type="bool" /> <description> If [code]true[/code], rendering of a viewport's environment is disabled. </description> </method> <method name="viewport_set_global_canvas_transform"> - <return type="void"> - </return> - <argument index="0" name="viewport" type="RID"> - </argument> - <argument index="1" name="transform" type="Transform2D"> - </argument> + <return type="void" /> + <argument index="0" name="viewport" type="RID" /> + <argument index="1" name="transform" type="Transform2D" /> <description> Sets the viewport's global transformation matrix. </description> </method> <method name="viewport_set_measure_render_time"> - <return type="void"> - </return> - <argument index="0" name="viewport" type="RID"> - </argument> - <argument index="1" name="enable" type="bool"> - </argument> + <return type="void" /> + <argument index="0" name="viewport" type="RID" /> + <argument index="1" name="enable" type="bool" /> <description> </description> </method> <method name="viewport_set_msaa"> - <return type="void"> - </return> - <argument index="0" name="viewport" type="RID"> - </argument> - <argument index="1" name="msaa" type="int" enum="RenderingServer.ViewportMSAA"> - </argument> + <return type="void" /> + <argument index="0" name="viewport" type="RID" /> + <argument index="1" name="msaa" type="int" enum="RenderingServer.ViewportMSAA" /> <description> Sets the anti-aliasing mode. See [enum ViewportMSAA] for options. </description> </method> <method name="viewport_set_occlusion_culling_build_quality"> - <return type="void"> - </return> - <argument index="0" name="quality" type="int" enum="RenderingServer.ViewportOcclusionCullingBuildQuality"> - </argument> + <return type="void" /> + <argument index="0" name="quality" type="int" enum="RenderingServer.ViewportOcclusionCullingBuildQuality" /> <description> </description> </method> <method name="viewport_set_occlusion_rays_per_thread"> - <return type="void"> - </return> - <argument index="0" name="rays_per_thread" type="int"> - </argument> + <return type="void" /> + <argument index="0" name="rays_per_thread" type="int" /> <description> </description> </method> <method name="viewport_set_parent_viewport"> - <return type="void"> - </return> - <argument index="0" name="viewport" type="RID"> - </argument> - <argument index="1" name="parent_viewport" type="RID"> - </argument> + <return type="void" /> + <argument index="0" name="viewport" type="RID" /> + <argument index="1" name="parent_viewport" type="RID" /> <description> Sets the viewport's parent to another viewport. </description> </method> <method name="viewport_set_render_direct_to_screen"> - <return type="void"> - </return> - <argument index="0" name="viewport" type="RID"> - </argument> - <argument index="1" name="enabled" type="bool"> - </argument> + <return type="void" /> + <argument index="0" name="viewport" type="RID" /> + <argument index="1" name="enabled" type="bool" /> <description> If [code]true[/code], render the contents of the viewport directly to screen. This allows a low-level optimization where you can skip drawing a viewport to the root viewport. While this optimization can result in a significant increase in speed (especially on older devices), it comes at a cost of usability. When this is enabled, you cannot read from the viewport or from the [code]SCREEN_TEXTURE[/code]. You also lose the benefit of certain window settings, such as the various stretch modes. Another consequence to be aware of is that in 2D the rendering happens in window coordinates, so if you have a viewport that is double the size of the window, and you set this, then only the portion that fits within the window will be drawn, no automatic scaling is possible, even if your game scene is significantly larger than the window size. </description> </method> <method name="viewport_set_scenario"> - <return type="void"> - </return> - <argument index="0" name="viewport" type="RID"> - </argument> - <argument index="1" name="scenario" type="RID"> - </argument> + <return type="void" /> + <argument index="0" name="viewport" type="RID" /> + <argument index="1" name="scenario" type="RID" /> <description> Sets a viewport's scenario. The scenario contains information about environment information, reflection atlas etc. </description> </method> <method name="viewport_set_screen_space_aa"> - <return type="void"> - </return> - <argument index="0" name="viewport" type="RID"> - </argument> - <argument index="1" name="mode" type="int" enum="RenderingServer.ViewportScreenSpaceAA"> - </argument> + <return type="void" /> + <argument index="0" name="viewport" type="RID" /> + <argument index="1" name="mode" type="int" enum="RenderingServer.ViewportScreenSpaceAA" /> <description> </description> </method> <method name="viewport_set_sdf_oversize_and_scale"> - <return type="void"> - </return> - <argument index="0" name="viewport" type="RID"> - </argument> - <argument index="1" name="oversize" type="int" enum="RenderingServer.ViewportSDFOversize"> - </argument> - <argument index="2" name="scale" type="int" enum="RenderingServer.ViewportSDFScale"> - </argument> + <return type="void" /> + <argument index="0" name="viewport" type="RID" /> + <argument index="1" name="oversize" type="int" enum="RenderingServer.ViewportSDFOversize" /> + <argument index="2" name="scale" type="int" enum="RenderingServer.ViewportSDFScale" /> <description> </description> </method> <method name="viewport_set_shadow_atlas_quadrant_subdivision"> - <return type="void"> - </return> - <argument index="0" name="viewport" type="RID"> - </argument> - <argument index="1" name="quadrant" type="int"> - </argument> - <argument index="2" name="subdivision" type="int"> - </argument> + <return type="void" /> + <argument index="0" name="viewport" type="RID" /> + <argument index="1" name="quadrant" type="int" /> + <argument index="2" name="subdivision" type="int" /> <description> Sets the shadow atlas quadrant's subdivision. </description> </method> <method name="viewport_set_shadow_atlas_size"> - <return type="void"> - </return> - <argument index="0" name="viewport" type="RID"> - </argument> - <argument index="1" name="size" type="int"> - </argument> - <argument index="2" name="use_16_bits" type="bool" default="false"> - </argument> + <return type="void" /> + <argument index="0" name="viewport" type="RID" /> + <argument index="1" name="size" type="int" /> + <argument index="2" name="use_16_bits" type="bool" default="false" /> <description> Sets the size of the shadow atlas's images (used for omni and spot lights). The value will be rounded up to the nearest power of 2. </description> </method> <method name="viewport_set_size"> - <return type="void"> - </return> - <argument index="0" name="viewport" type="RID"> - </argument> - <argument index="1" name="width" type="int"> - </argument> - <argument index="2" name="height" type="int"> - </argument> + <return type="void" /> + <argument index="0" name="viewport" type="RID" /> + <argument index="1" name="width" type="int" /> + <argument index="2" name="height" type="int" /> <description> Sets the viewport's width and height. </description> </method> <method name="viewport_set_snap_2d_transforms_to_pixel"> - <return type="void"> - </return> - <argument index="0" name="viewport" type="RID"> - </argument> - <argument index="1" name="enabled" type="bool"> - </argument> + <return type="void" /> + <argument index="0" name="viewport" type="RID" /> + <argument index="1" name="enabled" type="bool" /> <description> </description> </method> <method name="viewport_set_snap_2d_vertices_to_pixel"> - <return type="void"> - </return> - <argument index="0" name="viewport" type="RID"> - </argument> - <argument index="1" name="enabled" type="bool"> - </argument> + <return type="void" /> + <argument index="0" name="viewport" type="RID" /> + <argument index="1" name="enabled" type="bool" /> <description> </description> </method> <method name="viewport_set_transparent_background"> - <return type="void"> - </return> - <argument index="0" name="viewport" type="RID"> - </argument> - <argument index="1" name="enabled" type="bool"> - </argument> + <return type="void" /> + <argument index="0" name="viewport" type="RID" /> + <argument index="1" name="enabled" type="bool" /> <description> If [code]true[/code], the viewport renders its background as transparent. </description> </method> <method name="viewport_set_update_mode"> - <return type="void"> - </return> - <argument index="0" name="viewport" type="RID"> - </argument> - <argument index="1" name="update_mode" type="int" enum="RenderingServer.ViewportUpdateMode"> - </argument> + <return type="void" /> + <argument index="0" name="viewport" type="RID" /> + <argument index="1" name="update_mode" type="int" enum="RenderingServer.ViewportUpdateMode" /> <description> Sets when the viewport should be updated. See [enum ViewportUpdateMode] constants for options. </description> </method> <method name="viewport_set_use_debanding"> - <return type="void"> - </return> - <argument index="0" name="viewport" type="RID"> - </argument> - <argument index="1" name="enable" type="bool"> - </argument> + <return type="void" /> + <argument index="0" name="viewport" type="RID" /> + <argument index="1" name="enable" type="bool" /> <description> </description> </method> <method name="viewport_set_use_occlusion_culling"> - <return type="void"> - </return> - <argument index="0" name="viewport" type="RID"> - </argument> - <argument index="1" name="enable" type="bool"> - </argument> + <return type="void" /> + <argument index="0" name="viewport" type="RID" /> + <argument index="1" name="enable" type="bool" /> <description> </description> </method> <method name="viewport_set_use_xr"> - <return type="void"> - </return> - <argument index="0" name="viewport" type="RID"> - </argument> - <argument index="1" name="use_xr" type="bool"> - </argument> + <return type="void" /> + <argument index="0" name="viewport" type="RID" /> + <argument index="1" name="use_xr" type="bool" /> <description> If [code]true[/code], the viewport uses augmented or virtual reality technologies. See [XRInterface]. </description> </method> <method name="visibility_notifier_create"> - <return type="RID"> - </return> + <return type="RID" /> <description> </description> </method> <method name="visibility_notifier_set_aabb"> - <return type="void"> - </return> - <argument index="0" name="notifier" type="RID"> - </argument> - <argument index="1" name="aabb" type="AABB"> - </argument> + <return type="void" /> + <argument index="0" name="notifier" type="RID" /> + <argument index="1" name="aabb" type="AABB" /> <description> </description> </method> <method name="visibility_notifier_set_callbacks"> - <return type="void"> - </return> - <argument index="0" name="notifier" type="RID"> - </argument> - <argument index="1" name="enter_callable" type="Callable"> - </argument> - <argument index="2" name="exit_callable" type="Callable"> - </argument> + <return type="void" /> + <argument index="0" name="notifier" type="RID" /> + <argument index="1" name="enter_callable" type="Callable" /> + <argument index="2" name="exit_callable" type="Callable" /> <description> </description> </method> <method name="voxel_gi_allocate_data"> - <return type="void"> - </return> - <argument index="0" name="voxel_gi" type="RID"> - </argument> - <argument index="1" name="to_cell_xform" type="Transform3D"> - </argument> - <argument index="2" name="aabb" type="AABB"> - </argument> - <argument index="3" name="octree_size" type="Vector3i"> - </argument> - <argument index="4" name="octree_cells" type="PackedByteArray"> - </argument> - <argument index="5" name="data_cells" type="PackedByteArray"> - </argument> - <argument index="6" name="distance_field" type="PackedByteArray"> - </argument> - <argument index="7" name="level_counts" type="PackedInt32Array"> - </argument> + <return type="void" /> + <argument index="0" name="voxel_gi" type="RID" /> + <argument index="1" name="to_cell_xform" type="Transform3D" /> + <argument index="2" name="aabb" type="AABB" /> + <argument index="3" name="octree_size" type="Vector3i" /> + <argument index="4" name="octree_cells" type="PackedByteArray" /> + <argument index="5" name="data_cells" type="PackedByteArray" /> + <argument index="6" name="distance_field" type="PackedByteArray" /> + <argument index="7" name="level_counts" type="PackedInt32Array" /> <description> </description> </method> <method name="voxel_gi_create"> - <return type="RID"> - </return> + <return type="RID" /> <description> </description> </method> <method name="voxel_gi_get_data_cells" qualifiers="const"> - <return type="PackedByteArray"> - </return> - <argument index="0" name="voxel_gi" type="RID"> - </argument> + <return type="PackedByteArray" /> + <argument index="0" name="voxel_gi" type="RID" /> <description> </description> </method> <method name="voxel_gi_get_distance_field" qualifiers="const"> - <return type="PackedByteArray"> - </return> - <argument index="0" name="voxel_gi" type="RID"> - </argument> + <return type="PackedByteArray" /> + <argument index="0" name="voxel_gi" type="RID" /> <description> </description> </method> <method name="voxel_gi_get_level_counts" qualifiers="const"> - <return type="PackedInt32Array"> - </return> - <argument index="0" name="voxel_gi" type="RID"> - </argument> + <return type="PackedInt32Array" /> + <argument index="0" name="voxel_gi" type="RID" /> <description> </description> </method> <method name="voxel_gi_get_octree_cells" qualifiers="const"> - <return type="PackedByteArray"> - </return> - <argument index="0" name="voxel_gi" type="RID"> - </argument> + <return type="PackedByteArray" /> + <argument index="0" name="voxel_gi" type="RID" /> <description> </description> </method> <method name="voxel_gi_get_octree_size" qualifiers="const"> - <return type="Vector3i"> - </return> - <argument index="0" name="voxel_gi" type="RID"> - </argument> + <return type="Vector3i" /> + <argument index="0" name="voxel_gi" type="RID" /> <description> </description> </method> <method name="voxel_gi_get_to_cell_xform" qualifiers="const"> - <return type="Transform3D"> - </return> - <argument index="0" name="voxel_gi" type="RID"> - </argument> + <return type="Transform3D" /> + <argument index="0" name="voxel_gi" type="RID" /> <description> </description> </method> <method name="voxel_gi_set_bias"> - <return type="void"> - </return> - <argument index="0" name="voxel_gi" type="RID"> - </argument> - <argument index="1" name="bias" type="float"> - </argument> + <return type="void" /> + <argument index="0" name="voxel_gi" type="RID" /> + <argument index="1" name="bias" type="float" /> <description> </description> </method> <method name="voxel_gi_set_dynamic_range"> - <return type="void"> - </return> - <argument index="0" name="voxel_gi" type="RID"> - </argument> - <argument index="1" name="range" type="float"> - </argument> + <return type="void" /> + <argument index="0" name="voxel_gi" type="RID" /> + <argument index="1" name="range" type="float" /> <description> </description> </method> <method name="voxel_gi_set_energy"> - <return type="void"> - </return> - <argument index="0" name="voxel_gi" type="RID"> - </argument> - <argument index="1" name="energy" type="float"> - </argument> + <return type="void" /> + <argument index="0" name="voxel_gi" type="RID" /> + <argument index="1" name="energy" type="float" /> <description> </description> </method> <method name="voxel_gi_set_interior"> - <return type="void"> - </return> - <argument index="0" name="voxel_gi" type="RID"> - </argument> - <argument index="1" name="enable" type="bool"> - </argument> + <return type="void" /> + <argument index="0" name="voxel_gi" type="RID" /> + <argument index="1" name="enable" type="bool" /> <description> </description> </method> <method name="voxel_gi_set_normal_bias"> - <return type="void"> - </return> - <argument index="0" name="voxel_gi" type="RID"> - </argument> - <argument index="1" name="bias" type="float"> - </argument> + <return type="void" /> + <argument index="0" name="voxel_gi" type="RID" /> + <argument index="1" name="bias" type="float" /> <description> </description> </method> <method name="voxel_gi_set_propagation"> - <return type="void"> - </return> - <argument index="0" name="voxel_gi" type="RID"> - </argument> - <argument index="1" name="amount" type="float"> - </argument> + <return type="void" /> + <argument index="0" name="voxel_gi" type="RID" /> + <argument index="1" name="amount" type="float" /> <description> </description> </method> <method name="voxel_gi_set_quality"> - <return type="void"> - </return> - <argument index="0" name="quality" type="int" enum="RenderingServer.VoxelGIQuality"> - </argument> + <return type="void" /> + <argument index="0" name="quality" type="int" enum="RenderingServer.VoxelGIQuality" /> <description> </description> </method> <method name="voxel_gi_set_use_two_bounces"> - <return type="void"> - </return> - <argument index="0" name="voxel_gi" type="RID"> - </argument> - <argument index="1" name="enable" type="bool"> - </argument> + <return type="void" /> + <argument index="0" name="voxel_gi" type="RID" /> + <argument index="1" name="enable" type="bool" /> <description> </description> </method> @@ -4865,6 +3540,16 @@ <constant name="MULTIMESH_TRANSFORM_3D" value="1" enum="MultimeshTransformFormat"> Use [Transform3D] to store MultiMesh transform. </constant> + <constant name="LIGHT_PROJECTOR_FILTER_NEAREST" value="0" enum="LightProjectorFilter"> + </constant> + <constant name="LIGHT_PROJECTOR_FILTER_NEAREST_MIPMAPS" value="1" enum="LightProjectorFilter"> + </constant> + <constant name="LIGHT_PROJECTOR_FILTER_LINEAR" value="2" enum="LightProjectorFilter"> + </constant> + <constant name="LIGHT_PROJECTOR_FILTER_LINEAR_MIPMAPS" value="3" enum="LightProjectorFilter"> + </constant> + <constant name="LIGHT_PROJECTOR_FILTER_LINEAR_MIPMAPS_ANISOTROPIC" value="4" enum="LightProjectorFilter"> + </constant> <constant name="LIGHT_DIRECTIONAL" value="0" enum="LightType"> Is a directional (sun) light. </constant> @@ -4986,6 +3671,16 @@ </constant> <constant name="DECAL_TEXTURE_MAX" value="4" enum="DecalTexture"> </constant> + <constant name="DECAL_FILTER_NEAREST" value="0" enum="DecalFilter"> + </constant> + <constant name="DECAL_FILTER_NEAREST_MIPMAPS" value="1" enum="DecalFilter"> + </constant> + <constant name="DECAL_FILTER_LINEAR" value="2" enum="DecalFilter"> + </constant> + <constant name="DECAL_FILTER_LINEAR_MIPMAPS" value="3" enum="DecalFilter"> + </constant> + <constant name="DECAL_FILTER_LINEAR_MIPMAPS_ANISOTROPIC" value="4" enum="DecalFilter"> + </constant> <constant name="VOXEL_GI_QUALITY_LOW" value="0" enum="VoxelGIQuality"> </constant> <constant name="VOXEL_GI_QUALITY_HIGH" value="1" enum="VoxelGIQuality"> diff --git a/doc/classes/Resource.xml b/doc/classes/Resource.xml index c8800a3c25..701ecf815c 100644 --- a/doc/classes/Resource.xml +++ b/doc/classes/Resource.xml @@ -13,17 +13,14 @@ </tutorials> <methods> <method name="_setup_local_to_scene" qualifiers="virtual"> - <return type="void"> - </return> + <return type="void" /> <description> Virtual function which can be overridden to customize the behavior value of [method setup_local_to_scene]. </description> </method> <method name="duplicate" qualifiers="const"> - <return type="Resource"> - </return> - <argument index="0" name="subresources" type="bool" default="false"> - </argument> + <return type="Resource" /> + <argument index="0" name="subresources" type="bool" default="false" /> <description> Duplicates the resource, returning a new resource. By default, sub-resources are shared between resource copies for efficiency. This can be changed by passing [code]true[/code] to the [code]subresources[/code] argument which will copy the subresources. [b]Note:[/b] If [code]subresources[/code] is [code]true[/code], this method will only perform a shallow copy. Nested resources within subresources will not be duplicated and will still be shared. @@ -31,8 +28,7 @@ </description> </method> <method name="emit_changed"> - <return type="void"> - </return> + <return type="void" /> <description> Emits the [signal changed] signal. If external objects which depend on this resource should be updated, this method must be called manually whenever the state of this resource has changed (such as modification of properties). @@ -44,32 +40,27 @@ </description> </method> <method name="get_local_scene" qualifiers="const"> - <return type="Node"> - </return> + <return type="Node" /> <description> If [member resource_local_to_scene] is enabled and the resource was loaded from a [PackedScene] instantiation, returns the local scene where this resource's unique copy is in use. Otherwise, returns [code]null[/code]. </description> </method> <method name="get_rid" qualifiers="const"> - <return type="RID"> - </return> + <return type="RID" /> <description> Returns the RID of the resource (or an empty RID). Many resources (such as [Texture2D], [Mesh], etc) are high-level abstractions of resources stored in a server, so this function will return the original RID. </description> </method> <method name="setup_local_to_scene"> - <return type="void"> - </return> + <return type="void" /> <description> This method is called when a resource with [member resource_local_to_scene] enabled is loaded from a [PackedScene] instantiation. Its behavior can be customized by overriding [method _setup_local_to_scene] from script. For most resources, this method performs no base logic. [ViewportTexture] performs custom logic to properly set the proxy texture and flags in the local viewport. </description> </method> <method name="take_over_path"> - <return type="void"> - </return> - <argument index="0" name="path" type="String"> - </argument> + <return type="void" /> + <argument index="0" name="path" type="String" /> <description> Sets the path of the resource, potentially overriding an existing cache entry for this path. This differs from setting [member resource_path], as the latter would error out if another resource was already cached for the given path. </description> diff --git a/doc/classes/ResourceFormatLoader.xml b/doc/classes/ResourceFormatLoader.xml index 6abe5c813b..bce5785cc1 100644 --- a/doc/classes/ResourceFormatLoader.xml +++ b/doc/classes/ResourceFormatLoader.xml @@ -12,67 +12,51 @@ </tutorials> <methods> <method name="_get_dependencies" qualifiers="virtual"> - <return type="void"> - </return> - <argument index="0" name="path" type="String"> - </argument> - <argument index="1" name="add_types" type="String"> - </argument> + <return type="void" /> + <argument index="0" name="path" type="String" /> + <argument index="1" name="add_types" type="String" /> <description> If implemented, gets the dependencies of a given resource. If [code]add_types[/code] is [code]true[/code], paths should be appended [code]::TypeName[/code], where [code]TypeName[/code] is the class name of the dependency. [b]Note:[/b] Custom resource types defined by scripts aren't known by the [ClassDB], so you might just return [code]"Resource"[/code] for them. </description> </method> <method name="_get_recognized_extensions" qualifiers="virtual"> - <return type="PackedStringArray"> - </return> + <return type="PackedStringArray" /> <description> Gets the list of extensions for files this loader is able to read. </description> </method> <method name="_get_resource_type" qualifiers="virtual"> - <return type="String"> - </return> - <argument index="0" name="path" type="String"> - </argument> + <return type="String" /> + <argument index="0" name="path" type="String" /> <description> Gets the class name of the resource associated with the given path. If the loader cannot handle it, it should return [code]""[/code]. [b]Note:[/b] Custom resource types defined by scripts aren't known by the [ClassDB], so you might just return [code]"Resource"[/code] for them. </description> </method> <method name="_handles_type" qualifiers="virtual"> - <return type="bool"> - </return> - <argument index="0" name="typename" type="StringName"> - </argument> + <return type="bool" /> + <argument index="0" name="typename" type="StringName" /> <description> Tells which resource class this loader can load. [b]Note:[/b] Custom resource types defined by scripts aren't known by the [ClassDB], so you might just handle [code]"Resource"[/code] for them. </description> </method> <method name="_load" qualifiers="virtual"> - <return type="Variant"> - </return> - <argument index="0" name="path" type="String"> - </argument> - <argument index="1" name="original_path" type="String"> - </argument> - <argument index="2" name="use_sub_threads" type="bool"> - </argument> - <argument index="3" name="cache_mode" type="int"> - </argument> + <return type="Variant" /> + <argument index="0" name="path" type="String" /> + <argument index="1" name="original_path" type="String" /> + <argument index="2" name="use_sub_threads" type="bool" /> + <argument index="3" name="cache_mode" type="int" /> <description> Loads a resource when the engine finds this loader to be compatible. If the loaded resource is the result of an import, [code]original_path[/code] will target the source file. Returns a [Resource] object on success, or an [enum Error] constant in case of failure. The [code]cache_mode[/code] property defines whether and how the cache should be used or updated when loading the resource. See [enum CacheMode] for details. </description> </method> <method name="_rename_dependencies" qualifiers="virtual"> - <return type="int"> - </return> - <argument index="0" name="path" type="String"> - </argument> - <argument index="1" name="renames" type="String"> - </argument> + <return type="int" /> + <argument index="0" name="path" type="String" /> + <argument index="1" name="renames" type="String" /> <description> If implemented, renames dependencies within the given resource and saves it. [code]renames[/code] is a dictionary [code]{ String => String }[/code] mapping old dependency paths to new paths. Returns [constant OK] on success, or an [enum Error] constant in case of failure. diff --git a/doc/classes/ResourceFormatSaver.xml b/doc/classes/ResourceFormatSaver.xml index df71e05d02..ef9eebc953 100644 --- a/doc/classes/ResourceFormatSaver.xml +++ b/doc/classes/ResourceFormatSaver.xml @@ -11,32 +11,24 @@ </tutorials> <methods> <method name="_get_recognized_extensions" qualifiers="virtual"> - <return type="PackedStringArray"> - </return> - <argument index="0" name="resource" type="Resource"> - </argument> + <return type="PackedStringArray" /> + <argument index="0" name="resource" type="Resource" /> <description> Returns the list of extensions available for saving the resource object, provided it is recognized (see [method _recognize]). </description> </method> <method name="_recognize" qualifiers="virtual"> - <return type="bool"> - </return> - <argument index="0" name="resource" type="Resource"> - </argument> + <return type="bool" /> + <argument index="0" name="resource" type="Resource" /> <description> Returns whether the given resource object can be saved by this saver. </description> </method> <method name="_save" qualifiers="virtual"> - <return type="int"> - </return> - <argument index="0" name="path" type="String"> - </argument> - <argument index="1" name="resource" type="Resource"> - </argument> - <argument index="2" name="flags" type="int"> - </argument> + <return type="int" /> + <argument index="0" name="path" type="String" /> + <argument index="1" name="resource" type="Resource" /> + <argument index="2" name="flags" type="int" /> <description> Saves the given resource object to a file at the target [code]path[/code]. [code]flags[/code] is a bitmask composed with [enum ResourceSaver.SaverFlags] constants. Returns [constant OK] on success, or an [enum Error] constant in case of failure. diff --git a/doc/classes/ResourceImporter.xml b/doc/classes/ResourceImporter.xml index 59900b1b73..03d47ee518 100644 --- a/doc/classes/ResourceImporter.xml +++ b/doc/classes/ResourceImporter.xml @@ -1,13 +1,22 @@ <?xml version="1.0" encoding="UTF-8" ?> <class name="ResourceImporter" inherits="RefCounted" version="4.0"> <brief_description> + Base class for the implementation of core resource importers. </brief_description> <description> + This is the base class for the resource importers implemented in core. To implement your own resource importers using editor plugins, see [EditorImportPlugin]. </description> <tutorials> + <link title="Import plugins">https://docs.godotengine.org/en/latest/tutorials/plugins/editor/import_plugins.html</link> </tutorials> <methods> </methods> <constants> + <constant name="IMPORT_ORDER_DEFAULT" value="0" enum="ImportOrder"> + The default import order. + </constant> + <constant name="IMPORT_ORDER_SCENE" value="100" enum="ImportOrder"> + The import order for scenes, which ensures scenes are imported [i]after[/i] all other core resources such as textures. Custom importers should generally have an import order lower than [code]100[/code] to avoid issues when importing scenes that rely on custom resources. + </constant> </constants> </class> diff --git a/doc/classes/ResourceLoader.xml b/doc/classes/ResourceLoader.xml index 682d7b97f3..3a3ce189d5 100644 --- a/doc/classes/ResourceLoader.xml +++ b/doc/classes/ResourceLoader.xml @@ -12,54 +12,41 @@ </tutorials> <methods> <method name="exists"> - <return type="bool"> - </return> - <argument index="0" name="path" type="String"> - </argument> - <argument index="1" name="type_hint" type="String" default=""""> - </argument> + <return type="bool" /> + <argument index="0" name="path" type="String" /> + <argument index="1" name="type_hint" type="String" default="""" /> <description> Returns whether a recognized resource exists for the given [code]path[/code]. An optional [code]type_hint[/code] can be used to further specify the [Resource] type that should be handled by the [ResourceFormatLoader]. Anything that inherits from [Resource] can be used as a type hint, for example [Image]. </description> </method> <method name="get_dependencies"> - <return type="PackedStringArray"> - </return> - <argument index="0" name="path" type="String"> - </argument> + <return type="PackedStringArray" /> + <argument index="0" name="path" type="String" /> <description> Returns the dependencies for the resource at the given [code]path[/code]. </description> </method> <method name="get_recognized_extensions_for_type"> - <return type="PackedStringArray"> - </return> - <argument index="0" name="type" type="String"> - </argument> + <return type="PackedStringArray" /> + <argument index="0" name="type" type="String" /> <description> Returns the list of recognized extensions for a resource type. </description> </method> <method name="has_cached"> - <return type="bool"> - </return> - <argument index="0" name="path" type="String"> - </argument> + <return type="bool" /> + <argument index="0" name="path" type="String" /> <description> Returns whether a cached resource is available for the given [code]path[/code]. Once a resource has been loaded by the engine, it is cached in memory for faster access, and future calls to the [method load] method will use the cached version. The cached resource can be overridden by using [method Resource.take_over_path] on a new resource for that same path. </description> </method> <method name="load"> - <return type="Resource"> - </return> - <argument index="0" name="path" type="String"> - </argument> - <argument index="1" name="type_hint" type="String" default=""""> - </argument> - <argument index="2" name="cache_mode" type="int" enum="ResourceLoader.CacheMode" default="1"> - </argument> + <return type="Resource" /> + <argument index="0" name="path" type="String" /> + <argument index="1" name="type_hint" type="String" default="""" /> + <argument index="2" name="cache_mode" type="int" enum="ResourceLoader.CacheMode" default="1" /> <description> Loads a resource at the given [code]path[/code], caching the result for further access. The registered [ResourceFormatLoader]s are queried sequentially to find the first one which can handle the file's extension, and then attempt loading. If loading fails, the remaining ResourceFormatLoaders are also attempted. @@ -70,45 +57,34 @@ </description> </method> <method name="load_threaded_get"> - <return type="Resource"> - </return> - <argument index="0" name="path" type="String"> - </argument> + <return type="Resource" /> + <argument index="0" name="path" type="String" /> <description> Returns the resource loaded by [method load_threaded_request]. If this is called before the loading thread is done (i.e. [method load_threaded_get_status] is not [constant THREAD_LOAD_LOADED]), the calling thread will be blocked until the resource has finished loading. </description> </method> <method name="load_threaded_get_status"> - <return type="int" enum="ResourceLoader.ThreadLoadStatus"> - </return> - <argument index="0" name="path" type="String"> - </argument> - <argument index="1" name="progress" type="Array" default="[]"> - </argument> + <return type="int" enum="ResourceLoader.ThreadLoadStatus" /> + <argument index="0" name="path" type="String" /> + <argument index="1" name="progress" type="Array" default="[]" /> <description> Returns the status of a threaded loading operation started with [method load_threaded_request] for the resource at [code]path[/code]. See [enum ThreadLoadStatus] for possible return values. An array variable can optionally be passed via [code]progress[/code], and will return a one-element array containing the percentage of completion of the threaded loading. </description> </method> <method name="load_threaded_request"> - <return type="int" enum="Error"> - </return> - <argument index="0" name="path" type="String"> - </argument> - <argument index="1" name="type_hint" type="String" default=""""> - </argument> - <argument index="2" name="use_sub_threads" type="bool" default="false"> - </argument> + <return type="int" enum="Error" /> + <argument index="0" name="path" type="String" /> + <argument index="1" name="type_hint" type="String" default="""" /> + <argument index="2" name="use_sub_threads" type="bool" default="false" /> <description> Loads the resource using threads. If [code]use_sub_threads[/code] is [code]true[/code], multiple threads will be used to load the resource, which makes loading faster, but may affect the main thread (and thus cause game slowdowns). </description> </method> <method name="set_abort_on_missing_resources"> - <return type="void"> - </return> - <argument index="0" name="abort" type="bool"> - </argument> + <return type="void" /> + <argument index="0" name="abort" type="bool" /> <description> Changes the behavior on missing sub-resources. The default behavior is to abort loading. </description> diff --git a/doc/classes/ResourcePreloader.xml b/doc/classes/ResourcePreloader.xml index 3159a4c424..8ac8717581 100644 --- a/doc/classes/ResourcePreloader.xml +++ b/doc/classes/ResourcePreloader.xml @@ -11,57 +11,44 @@ </tutorials> <methods> <method name="add_resource"> - <return type="void"> - </return> - <argument index="0" name="name" type="StringName"> - </argument> - <argument index="1" name="resource" type="Resource"> - </argument> + <return type="void" /> + <argument index="0" name="name" type="StringName" /> + <argument index="1" name="resource" type="Resource" /> <description> Adds a resource to the preloader with the given [code]name[/code]. If a resource with the given [code]name[/code] already exists, the new resource will be renamed to "[code]name[/code] N" where N is an incrementing number starting from 2. </description> </method> <method name="get_resource" qualifiers="const"> - <return type="Resource"> - </return> - <argument index="0" name="name" type="StringName"> - </argument> + <return type="Resource" /> + <argument index="0" name="name" type="StringName" /> <description> Returns the resource associated to [code]name[/code]. </description> </method> <method name="get_resource_list" qualifiers="const"> - <return type="PackedStringArray"> - </return> + <return type="PackedStringArray" /> <description> Returns the list of resources inside the preloader. </description> </method> <method name="has_resource" qualifiers="const"> - <return type="bool"> - </return> - <argument index="0" name="name" type="StringName"> - </argument> + <return type="bool" /> + <argument index="0" name="name" type="StringName" /> <description> Returns [code]true[/code] if the preloader contains a resource associated to [code]name[/code]. </description> </method> <method name="remove_resource"> - <return type="void"> - </return> - <argument index="0" name="name" type="StringName"> - </argument> + <return type="void" /> + <argument index="0" name="name" type="StringName" /> <description> Removes the resource associated to [code]name[/code] from the preloader. </description> </method> <method name="rename_resource"> - <return type="void"> - </return> - <argument index="0" name="name" type="StringName"> - </argument> - <argument index="1" name="newname" type="StringName"> - </argument> + <return type="void" /> + <argument index="0" name="name" type="StringName" /> + <argument index="1" name="newname" type="StringName" /> <description> Renames a resource inside the preloader from [code]name[/code] to [code]newname[/code]. </description> diff --git a/doc/classes/ResourceSaver.xml b/doc/classes/ResourceSaver.xml index 437b0ce730..39f166db2e 100644 --- a/doc/classes/ResourceSaver.xml +++ b/doc/classes/ResourceSaver.xml @@ -11,23 +11,17 @@ </tutorials> <methods> <method name="get_recognized_extensions"> - <return type="PackedStringArray"> - </return> - <argument index="0" name="type" type="Resource"> - </argument> + <return type="PackedStringArray" /> + <argument index="0" name="type" type="Resource" /> <description> Returns the list of extensions available for saving a resource of a given type. </description> </method> <method name="save"> - <return type="int" enum="Error"> - </return> - <argument index="0" name="path" type="String"> - </argument> - <argument index="1" name="resource" type="Resource"> - </argument> - <argument index="2" name="flags" type="int" enum="ResourceSaver.SaverFlags" default="0"> - </argument> + <return type="int" enum="Error" /> + <argument index="0" name="path" type="String" /> + <argument index="1" name="resource" type="Resource" /> + <argument index="2" name="flags" type="int" enum="ResourceSaver.SaverFlags" default="0" /> <description> Saves a resource to disk to the given path, using a [ResourceFormatSaver] that recognizes the resource object. The [code]flags[/code] bitmask can be specified to customize the save behavior. diff --git a/doc/classes/ResourceUID.xml b/doc/classes/ResourceUID.xml new file mode 100644 index 0000000000..9e3d647ccf --- /dev/null +++ b/doc/classes/ResourceUID.xml @@ -0,0 +1,64 @@ +<?xml version="1.0" encoding="UTF-8" ?> +<class name="ResourceUID" inherits="Object" version="4.0"> + <brief_description> + </brief_description> + <description> + </description> + <tutorials> + </tutorials> + <methods> + <method name="add_id"> + <return type="void" /> + <argument index="0" name="id" type="int" /> + <argument index="1" name="path" type="String" /> + <description> + </description> + </method> + <method name="create_id" qualifiers="const"> + <return type="int" /> + <description> + </description> + </method> + <method name="get_id_path" qualifiers="const"> + <return type="String" /> + <argument index="0" name="id" type="int" /> + <description> + </description> + </method> + <method name="has_id" qualifiers="const"> + <return type="bool" /> + <argument index="0" name="id" type="int" /> + <description> + </description> + </method> + <method name="id_to_text" qualifiers="const"> + <return type="String" /> + <argument index="0" name="id" type="int" /> + <description> + </description> + </method> + <method name="remove_id"> + <return type="void" /> + <argument index="0" name="id" type="int" /> + <description> + </description> + </method> + <method name="set_id"> + <return type="void" /> + <argument index="0" name="id" type="int" /> + <argument index="1" name="path" type="String" /> + <description> + </description> + </method> + <method name="text_to_id" qualifiers="const"> + <return type="int" /> + <argument index="0" name="text_id" type="String" /> + <description> + </description> + </method> + </methods> + <constants> + <constant name="INVALID_ID" value="-1"> + </constant> + </constants> +</class> diff --git a/doc/classes/RichTextEffect.xml b/doc/classes/RichTextEffect.xml index edab35f162..142afbb860 100644 --- a/doc/classes/RichTextEffect.xml +++ b/doc/classes/RichTextEffect.xml @@ -24,10 +24,8 @@ </tutorials> <methods> <method name="_process_custom_fx" qualifiers="virtual"> - <return type="bool"> - </return> - <argument index="0" name="char_fx" type="CharFXTransform"> - </argument> + <return type="bool" /> + <argument index="0" name="char_fx" type="CharFXTransform" /> <description> Override this method to modify properties in [code]char_fx[/code]. The method must return [code]true[/code] if the character could be transformed successfully. If the method returns [code]false[/code], it will skip transformation to avoid displaying broken text. </description> diff --git a/doc/classes/RichTextLabel.xml b/doc/classes/RichTextLabel.xml index 38884a027f..e1362917b0 100644 --- a/doc/classes/RichTextLabel.xml +++ b/doc/classes/RichTextLabel.xml @@ -16,443 +16,346 @@ </tutorials> <methods> <method name="add_image"> - <return type="void"> - </return> - <argument index="0" name="image" type="Texture2D"> - </argument> - <argument index="1" name="width" type="int" default="0"> - </argument> - <argument index="2" name="height" type="int" default="0"> - </argument> - <argument index="3" name="color" type="Color" default="Color(1, 1, 1, 1)"> - </argument> - <argument index="4" name="inline_align" type="int" enum="VAlign" default="0"> - </argument> + <return type="void" /> + <argument index="0" name="image" type="Texture2D" /> + <argument index="1" name="width" type="int" default="0" /> + <argument index="2" name="height" type="int" default="0" /> + <argument index="3" name="color" type="Color" default="Color(1, 1, 1, 1)" /> + <argument index="4" name="inline_align" type="int" enum="VAlign" default="0" /> <description> Adds an image's opening and closing tags to the tag stack, optionally providing a [code]width[/code] and [code]height[/code] to resize the image and a [code]color[/code] to tint the image. If [code]width[/code] or [code]height[/code] is set to 0, the image size will be adjusted in order to keep the original aspect ratio. </description> </method> <method name="add_text"> - <return type="void"> - </return> - <argument index="0" name="text" type="String"> - </argument> + <return type="void" /> + <argument index="0" name="text" type="String" /> <description> Adds raw non-BBCode-parsed text to the tag stack. </description> </method> <method name="append_bbcode"> - <return type="int" enum="Error"> - </return> - <argument index="0" name="bbcode" type="String"> - </argument> + <return type="int" enum="Error" /> + <argument index="0" name="bbcode" type="String" /> <description> Parses [code]bbcode[/code] and adds tags to the tag stack as needed. Returns the result of the parsing, [constant OK] if successful. [b]Note:[/b] Using this method, you can't close a tag that was opened in a previous [method append_bbcode] call. This is done to improve performance, especially when updating large RichTextLabels since rebuilding the whole BBCode every time would be slower. If you absolutely need to close a tag in a future method call, append the [member bbcode_text] instead of using [method append_bbcode]. </description> </method> <method name="clear"> - <return type="void"> - </return> + <return type="void" /> <description> Clears the tag stack and sets [member bbcode_text] to an empty string. </description> </method> <method name="get_content_height" qualifiers="const"> - <return type="int"> - </return> + <return type="int" /> <description> Returns the height of the content. </description> </method> <method name="get_line_count" qualifiers="const"> - <return type="int"> - </return> + <return type="int" /> <description> Returns the total number of lines in the text. Wrapped text is counted as multiple lines. </description> </method> <method name="get_paragraph_count" qualifiers="const"> - <return type="int"> - </return> + <return type="int" /> <description> Returns the total number of paragraphs (newlines or [code]p[/code] tags in the tag stack's text tags). Considers wrapped text as one paragraph. </description> </method> <method name="get_selected_text" qualifiers="const"> - <return type="String"> - </return> + <return type="String" /> <description> Returns the current selection text. Does not include BBCodes. </description> </method> <method name="get_selection_from" qualifiers="const"> - <return type="int"> - </return> + <return type="int" /> <description> Returns the current selection first character index if a selection is active, [code]-1[/code] otherwise. Does not include BBCodes. </description> </method> <method name="get_selection_to" qualifiers="const"> - <return type="int"> - </return> + <return type="int" /> <description> Returns the current selection last character index if a selection is active, [code]-1[/code] otherwise. Does not include BBCodes. </description> </method> <method name="get_total_character_count" qualifiers="const"> - <return type="int"> - </return> + <return type="int" /> <description> Returns the total number of characters from text tags. Does not include BBCodes. </description> </method> <method name="get_v_scroll"> - <return type="VScrollBar"> - </return> + <return type="VScrollBar" /> <description> Returns the vertical scrollbar. </description> </method> <method name="get_visible_line_count" qualifiers="const"> - <return type="int"> - </return> + <return type="int" /> <description> Returns the number of visible lines. </description> </method> <method name="get_visible_paragraph_count" qualifiers="const"> - <return type="int"> - </return> + <return type="int" /> <description> Returns the number of visible paragraphs. A paragraph is considered visible if at least one of its lines is visible. </description> </method> <method name="install_effect"> - <return type="void"> - </return> - <argument index="0" name="effect" type="Variant"> - </argument> + <return type="void" /> + <argument index="0" name="effect" type="Variant" /> <description> Installs a custom effect. [code]effect[/code] should be a valid [RichTextEffect]. </description> </method> <method name="newline"> - <return type="void"> - </return> + <return type="void" /> <description> Adds a newline tag to the tag stack. </description> </method> <method name="parse_bbcode"> - <return type="int" enum="Error"> - </return> - <argument index="0" name="bbcode" type="String"> - </argument> + <return type="int" enum="Error" /> + <argument index="0" name="bbcode" type="String" /> <description> The assignment version of [method append_bbcode]. Clears the tag stack and inserts the new content. Returns [constant OK] if parses [code]bbcode[/code] successfully. </description> </method> <method name="parse_expressions_for_values"> - <return type="Dictionary"> - </return> - <argument index="0" name="expressions" type="PackedStringArray"> - </argument> + <return type="Dictionary" /> + <argument index="0" name="expressions" type="PackedStringArray" /> <description> Parses BBCode parameter [code]expressions[/code] into a dictionary. </description> </method> <method name="pop"> - <return type="void"> - </return> + <return type="void" /> <description> Terminates the current tag. Use after [code]push_*[/code] methods to close BBCodes manually. Does not need to follow [code]add_*[/code] methods. </description> </method> <method name="push_bgcolor"> - <return type="void"> - </return> - <argument index="0" name="bgcolor" type="Color"> - </argument> + <return type="void" /> + <argument index="0" name="bgcolor" type="Color" /> <description> Adds a [code][bgcolor][/code] tag to the tag stack. </description> </method> <method name="push_bold"> - <return type="void"> - </return> + <return type="void" /> <description> Adds a [code][font][/code] tag with a bold font to the tag stack. This is the same as adding a [code][b][/code] tag if not currently in a [code][i][/code] tag. </description> </method> <method name="push_bold_italics"> - <return type="void"> - </return> + <return type="void" /> <description> Adds a [code][font][/code] tag with a bold italics font to the tag stack. </description> </method> <method name="push_cell"> - <return type="void"> - </return> + <return type="void" /> <description> Adds a [code][cell][/code] tag to the tag stack. Must be inside a [code][table][/code] tag. See [method push_table] for details. </description> </method> <method name="push_color"> - <return type="void"> - </return> - <argument index="0" name="color" type="Color"> - </argument> + <return type="void" /> + <argument index="0" name="color" type="Color" /> <description> Adds a [code][color][/code] tag to the tag stack. </description> </method> <method name="push_dropcap"> - <return type="void"> - </return> - <argument index="0" name="string" type="String"> - </argument> - <argument index="1" name="font" type="Font"> - </argument> - <argument index="2" name="size" type="int"> - </argument> - <argument index="3" name="dropcap_margins" type="Rect2" default="Rect2(0, 0, 0, 0)"> - </argument> - <argument index="4" name="color" type="Color" default="Color(1, 1, 1, 1)"> - </argument> - <argument index="5" name="outline_size" type="int" default="0"> - </argument> - <argument index="6" name="outline_color" type="Color" default="Color(0, 0, 0, 0)"> - </argument> + <return type="void" /> + <argument index="0" name="string" type="String" /> + <argument index="1" name="font" type="Font" /> + <argument index="2" name="size" type="int" /> + <argument index="3" name="dropcap_margins" type="Rect2" default="Rect2(0, 0, 0, 0)" /> + <argument index="4" name="color" type="Color" default="Color(1, 1, 1, 1)" /> + <argument index="5" name="outline_size" type="int" default="0" /> + <argument index="6" name="outline_color" type="Color" default="Color(0, 0, 0, 0)" /> <description> Adds a [code][dropcap][/code] tag to the tag stack. Drop cap (dropped capital) is a decorative element at the beginning of a paragraph that is larger than the rest of the text. </description> </method> <method name="push_fgcolor"> - <return type="void"> - </return> - <argument index="0" name="fgcolor" type="Color"> - </argument> + <return type="void" /> + <argument index="0" name="fgcolor" type="Color" /> <description> Adds a [code][fgcolor][/code] tag to the tag stack. </description> </method> <method name="push_font"> - <return type="void"> - </return> - <argument index="0" name="font" type="Font"> - </argument> + <return type="void" /> + <argument index="0" name="font" type="Font" /> <description> Adds a [code][font][/code] tag to the tag stack. Overrides default fonts for its duration. </description> </method> <method name="push_font_features"> - <return type="void"> - </return> - <argument index="0" name="opentype_features" type="Dictionary"> - </argument> + <return type="void" /> + <argument index="0" name="opentype_features" type="Dictionary" /> <description> Adds a [code][ot_feature][/code] tag to the tag stack. Overrides default OpenType font feature for its duration. </description> </method> <method name="push_font_size"> - <return type="void"> - </return> - <argument index="0" name="font_size" type="int"> - </argument> + <return type="void" /> + <argument index="0" name="font_size" type="int" /> <description> Adds a [code][font_size][/code] tag to the tag stack. Overrides default font size for its duration. </description> </method> <method name="push_indent"> - <return type="void"> - </return> - <argument index="0" name="level" type="int"> - </argument> + <return type="void" /> + <argument index="0" name="level" type="int" /> <description> Adds an [code][indent][/code] tag to the tag stack. Multiplies [code]level[/code] by current [member tab_size] to determine new margin length. </description> </method> <method name="push_italics"> - <return type="void"> - </return> + <return type="void" /> <description> Adds a [code][font][/code] tag with a italics font to the tag stack. This is the same as adding a [code][i][/code] tag if not currently in a [code][b][/code] tag. </description> </method> <method name="push_list"> - <return type="void"> - </return> - <argument index="0" name="level" type="int"> - </argument> - <argument index="1" name="type" type="int" enum="RichTextLabel.ListType"> - </argument> - <argument index="2" name="capitalize" type="bool"> - </argument> + <return type="void" /> + <argument index="0" name="level" type="int" /> + <argument index="1" name="type" type="int" enum="RichTextLabel.ListType" /> + <argument index="2" name="capitalize" type="bool" /> <description> Adds [code][ol][/code] or [code][ul][/code] tag to the tag stack. Multiplies [code]level[/code] by current [member tab_size] to determine new margin length. </description> </method> <method name="push_meta"> - <return type="void"> - </return> - <argument index="0" name="data" type="Variant"> - </argument> + <return type="void" /> + <argument index="0" name="data" type="Variant" /> <description> Adds a [code][meta][/code] tag to the tag stack. Similar to the BBCode [code][url=something]{text}[/url][/code], but supports non-[String] metadata types. </description> </method> <method name="push_mono"> - <return type="void"> - </return> + <return type="void" /> <description> Adds a [code][font][/code] tag with a monospace font to the tag stack. </description> </method> <method name="push_normal"> - <return type="void"> - </return> + <return type="void" /> <description> Adds a [code][font][/code] tag with a normal font to the tag stack. </description> </method> <method name="push_outline_color"> - <return type="void"> - </return> - <argument index="0" name="color" type="Color"> - </argument> + <return type="void" /> + <argument index="0" name="color" type="Color" /> <description> Adds a [code][outline_color][/code] tag to the tag stack. Adds text outline for its duration. </description> </method> <method name="push_outline_size"> - <return type="void"> - </return> - <argument index="0" name="outline_size" type="int"> - </argument> + <return type="void" /> + <argument index="0" name="outline_size" type="int" /> <description> Adds a [code][outline_size][/code] tag to the tag stack. Overrides default text outline size for its duration. </description> </method> <method name="push_paragraph"> - <return type="void"> - </return> - <argument index="0" name="align" type="int" enum="RichTextLabel.Align"> - </argument> - <argument index="1" name="base_direction" type="int" enum="Control.TextDirection" default="0"> - </argument> - <argument index="2" name="language" type="String" default=""""> - </argument> - <argument index="3" name="st_parser" type="int" enum="Control.StructuredTextParser" default="0"> - </argument> + <return type="void" /> + <argument index="0" name="align" type="int" enum="RichTextLabel.Align" /> + <argument index="1" name="base_direction" type="int" enum="Control.TextDirection" default="0" /> + <argument index="2" name="language" type="String" default="""" /> + <argument index="3" name="st_parser" type="int" enum="Control.StructuredTextParser" default="0" /> <description> Adds a [code][p][/code] tag to the tag stack. </description> </method> <method name="push_strikethrough"> - <return type="void"> - </return> + <return type="void" /> <description> Adds a [code][s][/code] tag to the tag stack. </description> </method> <method name="push_table"> - <return type="void"> - </return> - <argument index="0" name="columns" type="int"> - </argument> - <argument index="1" name="inline_align" type="int" enum="VAlign" default="0"> - </argument> + <return type="void" /> + <argument index="0" name="columns" type="int" /> + <argument index="1" name="inline_align" type="int" enum="VAlign" default="0" /> <description> Adds a [code][table=columns,inline_align][/code] tag to the tag stack. </description> </method> <method name="push_underline"> - <return type="void"> - </return> + <return type="void" /> <description> Adds a [code][u][/code] tag to the tag stack. </description> </method> <method name="remove_line"> - <return type="bool"> - </return> - <argument index="0" name="line" type="int"> - </argument> + <return type="bool" /> + <argument index="0" name="line" type="int" /> <description> Removes a line of content from the label. Returns [code]true[/code] if the line exists. The [code]line[/code] argument is the index of the line to remove, it can take values in the interval [code][0, get_line_count() - 1][/code]. </description> </method> <method name="scroll_to_line"> - <return type="void"> - </return> - <argument index="0" name="line" type="int"> - </argument> + <return type="void" /> + <argument index="0" name="line" type="int" /> <description> Scrolls the window's top line to match [code]line[/code]. </description> </method> <method name="scroll_to_paragraph"> - <return type="void"> - </return> - <argument index="0" name="paragraph" type="int"> - </argument> + <return type="void" /> + <argument index="0" name="paragraph" type="int" /> <description> Scrolls the window's top line to match first line of the [code]paragraph[/code]. </description> </method> <method name="set_cell_border_color"> - <return type="void"> - </return> - <argument index="0" name="color" type="Color"> - </argument> + <return type="void" /> + <argument index="0" name="color" type="Color" /> <description> Sets color of a table cell border. </description> </method> <method name="set_cell_padding"> - <return type="void"> - </return> - <argument index="0" name="padding" type="Rect2"> - </argument> + <return type="void" /> + <argument index="0" name="padding" type="Rect2" /> <description> Sets inner padding of a table cell. </description> </method> <method name="set_cell_row_background_color"> - <return type="void"> - </return> - <argument index="0" name="odd_row_bg" type="Color"> - </argument> - <argument index="1" name="even_row_bg" type="Color"> - </argument> + <return type="void" /> + <argument index="0" name="odd_row_bg" type="Color" /> + <argument index="1" name="even_row_bg" type="Color" /> <description> Sets color of a table cell. Separate colors for alternating rows can be specified. </description> </method> <method name="set_cell_size_override"> - <return type="void"> - </return> - <argument index="0" name="min_size" type="Vector2"> - </argument> - <argument index="1" name="max_size" type="Vector2"> - </argument> + <return type="void" /> + <argument index="0" name="min_size" type="Vector2" /> + <argument index="1" name="max_size" type="Vector2" /> <description> Sets minimum and maximum size overrides for a table cell. </description> </method> <method name="set_table_column_expand"> - <return type="void"> - </return> - <argument index="0" name="column" type="int"> - </argument> - <argument index="1" name="expand" type="bool"> - </argument> - <argument index="2" name="ratio" type="int"> - </argument> + <return type="void" /> + <argument index="0" name="column" type="int" /> + <argument index="1" name="expand" type="bool" /> + <argument index="2" name="ratio" type="int" /> <description> Edits the selected column's expansion options. If [code]expand[/code] is [code]true[/code], the column expands in proportion to its expansion ratio versus the other columns' ratios. For example, 2 columns with ratios 3 and 4 plus 70 pixels in available width would expand 30 and 40 pixels, respectively. @@ -522,22 +425,19 @@ </members> <signals> <signal name="meta_clicked"> - <argument index="0" name="meta" type="Variant"> - </argument> + <argument index="0" name="meta" type="Variant" /> <description> Triggered when the user clicks on content between meta tags. If the meta is defined in text, e.g. [code][url={"data"="hi"}]hi[/url][/code], then the parameter for this signal will be a [String] type. If a particular type or an object is desired, the [method push_meta] method must be used to manually insert the data into the tag stack. </description> </signal> <signal name="meta_hover_ended"> - <argument index="0" name="meta" type="Variant"> - </argument> + <argument index="0" name="meta" type="Variant" /> <description> Triggers when the mouse exits a meta tag. </description> </signal> <signal name="meta_hover_started"> - <argument index="0" name="meta" type="Variant"> - </argument> + <argument index="0" name="meta" type="Variant" /> <description> Triggers when the mouse enters a meta tag. </description> diff --git a/doc/classes/RigidBody2D.xml b/doc/classes/RigidBody2D.xml index 64573b7282..db16552db3 100644 --- a/doc/classes/RigidBody2D.xml +++ b/doc/classes/RigidBody2D.xml @@ -17,85 +17,66 @@ </tutorials> <methods> <method name="_integrate_forces" qualifiers="virtual"> - <return type="void"> - </return> - <argument index="0" name="state" type="PhysicsDirectBodyState2D"> - </argument> + <return type="void" /> + <argument index="0" name="state" type="PhysicsDirectBodyState2D" /> <description> Allows you to read and safely modify the simulation state for the object. Use this instead of [method Node._physics_process] if you need to directly change the body's [code]position[/code] or other physics properties. By default, it works in addition to the usual physics behavior, but [member custom_integrator] allows you to disable the default behavior and write custom force integration for a body. </description> </method> <method name="add_central_force"> - <return type="void"> - </return> - <argument index="0" name="force" type="Vector2"> - </argument> + <return type="void" /> + <argument index="0" name="force" type="Vector2" /> <description> Adds a constant directional force without affecting rotation. </description> </method> <method name="add_force"> - <return type="void"> - </return> - <argument index="0" name="force" type="Vector2"> - </argument> - <argument index="1" name="position" type="Vector2" default="Vector2(0, 0)"> - </argument> + <return type="void" /> + <argument index="0" name="force" type="Vector2" /> + <argument index="1" name="position" type="Vector2" default="Vector2(0, 0)" /> <description> Adds a positioned force to the body. Both the force and the offset from the body origin are in global coordinates. </description> </method> <method name="add_torque"> - <return type="void"> - </return> - <argument index="0" name="torque" type="float"> - </argument> + <return type="void" /> + <argument index="0" name="torque" type="float" /> <description> Adds a constant rotational force. </description> </method> <method name="apply_central_impulse"> - <return type="void"> - </return> - <argument index="0" name="impulse" type="Vector2" default="Vector2(0, 0)"> - </argument> + <return type="void" /> + <argument index="0" name="impulse" type="Vector2" default="Vector2(0, 0)" /> <description> Applies a directional impulse without affecting rotation. </description> </method> <method name="apply_impulse"> - <return type="void"> - </return> - <argument index="0" name="impulse" type="Vector2"> - </argument> - <argument index="1" name="position" type="Vector2" default="Vector2(0, 0)"> - </argument> + <return type="void" /> + <argument index="0" name="impulse" type="Vector2" /> + <argument index="1" name="position" type="Vector2" default="Vector2(0, 0)" /> <description> Applies a positioned impulse to the body. An impulse is time-independent! Applying an impulse every frame would result in a framerate-dependent force. For this reason it should only be used when simulating one-time impacts (use the "_force" functions otherwise). The position uses the rotation of the global coordinate system, but is centered at the object's origin. </description> </method> <method name="apply_torque_impulse"> - <return type="void"> - </return> - <argument index="0" name="torque" type="float"> - </argument> + <return type="void" /> + <argument index="0" name="torque" type="float" /> <description> Applies a rotational impulse to the body. </description> </method> <method name="get_colliding_bodies" qualifiers="const"> - <return type="Node2D[]"> - </return> + <return type="Node2D[]" /> <description> Returns a list of the bodies colliding with this one. Requires [member contact_monitor] to be set to [code]true[/code] and [member contacts_reported] to be set high enough to detect all the collisions. [b]Note:[/b] The result of this test is not immediate after moving objects. For performance, list of collisions is updated once per frame and before the physics step. Consider using signals instead. </description> </method> <method name="set_axis_velocity"> - <return type="void"> - </return> - <argument index="0" name="axis_velocity" type="Vector2"> - </argument> + <return type="void" /> + <argument index="0" name="axis_velocity" type="Vector2" /> <description> Sets the body's velocity on the given axis. The velocity in the given vector axis will be set as the given vector length. This is useful for jumping behavior. </description> @@ -161,30 +142,24 @@ </members> <signals> <signal name="body_entered"> - <argument index="0" name="body" type="Node"> - </argument> + <argument index="0" name="body" type="Node" /> <description> Emitted when a collision with another [PhysicsBody2D] or [TileMap] occurs. Requires [member contact_monitor] to be set to [code]true[/code] and [member contacts_reported] to be set high enough to detect all the collisions. [TileMap]s are detected if the [TileSet] has Collision [Shape2D]s. [code]body[/code] the [Node], if it exists in the tree, of the other [PhysicsBody2D] or [TileMap]. </description> </signal> <signal name="body_exited"> - <argument index="0" name="body" type="Node"> - </argument> + <argument index="0" name="body" type="Node" /> <description> Emitted when the collision with another [PhysicsBody2D] or [TileMap] ends. Requires [member contact_monitor] to be set to [code]true[/code] and [member contacts_reported] to be set high enough to detect all the collisions. [TileMap]s are detected if the [TileSet] has Collision [Shape2D]s. [code]body[/code] the [Node], if it exists in the tree, of the other [PhysicsBody2D] or [TileMap]. </description> </signal> <signal name="body_shape_entered"> - <argument index="0" name="body_rid" type="RID"> - </argument> - <argument index="1" name="body" type="Node"> - </argument> - <argument index="2" name="body_shape" type="int"> - </argument> - <argument index="3" name="local_shape" type="int"> - </argument> + <argument index="0" name="body_rid" type="RID" /> + <argument index="1" name="body" type="Node" /> + <argument index="2" name="body_shape" type="int" /> + <argument index="3" name="local_shape" type="int" /> <description> Emitted when one of this RigidBody2D's [Shape2D]s collides with another [PhysicsBody2D] or [TileMap]'s [Shape2D]s. Requires [member contact_monitor] to be set to [code]true[/code] and [member contacts_reported] to be set high enough to detect all the collisions. [TileMap]s are detected if the [TileSet] has Collision [Shape2D]s. [code]body_id[/code] the [RID] of the other [PhysicsBody2D] or [TileSet]'s [CollisionObject2D] used by the [PhysicsServer2D]. @@ -194,14 +169,10 @@ </description> </signal> <signal name="body_shape_exited"> - <argument index="0" name="body_rid" type="RID"> - </argument> - <argument index="1" name="body" type="Node"> - </argument> - <argument index="2" name="body_shape" type="int"> - </argument> - <argument index="3" name="local_shape" type="int"> - </argument> + <argument index="0" name="body_rid" type="RID" /> + <argument index="1" name="body" type="Node" /> + <argument index="2" name="body_shape" type="int" /> + <argument index="3" name="local_shape" type="int" /> <description> Emitted when the collision between one of this RigidBody2D's [Shape2D]s and another [PhysicsBody2D] or [TileMap]'s [Shape2D]s ends. Requires [member contact_monitor] to be set to [code]true[/code] and [member contacts_reported] to be set high enough to detect all the collisions. [TileMap]s are detected if the [TileSet] has Collision [Shape2D]s. [code]body_id[/code] the [RID] of the other [PhysicsBody2D] or [TileSet]'s [CollisionObject2D] used by the [PhysicsServer2D]. diff --git a/doc/classes/RigidBody3D.xml b/doc/classes/RigidBody3D.xml index fb2b9690a3..f4299335bf 100644 --- a/doc/classes/RigidBody3D.xml +++ b/doc/classes/RigidBody3D.xml @@ -17,95 +17,75 @@ </tutorials> <methods> <method name="_integrate_forces" qualifiers="virtual"> - <return type="void"> - </return> - <argument index="0" name="state" type="PhysicsDirectBodyState3D"> - </argument> + <return type="void" /> + <argument index="0" name="state" type="PhysicsDirectBodyState3D" /> <description> Called during physics processing, allowing you to read and safely modify the simulation state for the object. By default, it works in addition to the usual physics behavior, but the [member custom_integrator] property allows you to disable the default behavior and do fully custom force integration for a body. </description> </method> <method name="add_central_force"> - <return type="void"> - </return> - <argument index="0" name="force" type="Vector3"> - </argument> + <return type="void" /> + <argument index="0" name="force" type="Vector3" /> <description> Adds a constant directional force (i.e. acceleration) without affecting rotation. This is equivalent to [code]add_force(force, Vector3(0,0,0))[/code]. </description> </method> <method name="add_force"> - <return type="void"> - </return> - <argument index="0" name="force" type="Vector3"> - </argument> - <argument index="1" name="position" type="Vector3" default="Vector3(0, 0, 0)"> - </argument> + <return type="void" /> + <argument index="0" name="force" type="Vector3" /> + <argument index="1" name="position" type="Vector3" default="Vector3(0, 0, 0)" /> <description> Adds a constant directional force (i.e. acceleration). The position uses the rotation of the global coordinate system, but is centered at the object's origin. </description> </method> <method name="add_torque"> - <return type="void"> - </return> - <argument index="0" name="torque" type="Vector3"> - </argument> + <return type="void" /> + <argument index="0" name="torque" type="Vector3" /> <description> Adds a constant rotational force (i.e. a motor) without affecting position. </description> </method> <method name="apply_central_impulse"> - <return type="void"> - </return> - <argument index="0" name="impulse" type="Vector3"> - </argument> + <return type="void" /> + <argument index="0" name="impulse" type="Vector3" /> <description> Applies a directional impulse without affecting rotation. This is equivalent to [code]apply_impulse(Vector3(0,0,0), impulse)[/code]. </description> </method> <method name="apply_impulse"> - <return type="void"> - </return> - <argument index="0" name="impulse" type="Vector3"> - </argument> - <argument index="1" name="position" type="Vector3" default="Vector3(0, 0, 0)"> - </argument> + <return type="void" /> + <argument index="0" name="impulse" type="Vector3" /> + <argument index="1" name="position" type="Vector3" default="Vector3(0, 0, 0)" /> <description> Applies a positioned impulse to the body. An impulse is time independent! Applying an impulse every frame would result in a framerate-dependent force. For this reason it should only be used when simulating one-time impacts. The position uses the rotation of the global coordinate system, but is centered at the object's origin. </description> </method> <method name="apply_torque_impulse"> - <return type="void"> - </return> - <argument index="0" name="impulse" type="Vector3"> - </argument> + <return type="void" /> + <argument index="0" name="impulse" type="Vector3" /> <description> Applies a torque impulse which will be affected by the body mass and shape. This will rotate the body around the [code]impulse[/code] vector passed. </description> </method> <method name="get_colliding_bodies" qualifiers="const"> - <return type="Array"> - </return> + <return type="Array" /> <description> Returns a list of the bodies colliding with this one. Requires [member contact_monitor] to be set to [code]true[/code] and [member contacts_reported] to be set high enough to detect all the collisions. [b]Note:[/b] The result of this test is not immediate after moving objects. For performance, list of collisions is updated once per frame and before the physics step. Consider using signals instead. </description> </method> <method name="get_inverse_inertia_tensor" qualifiers="const"> - <return type="Basis"> - </return> + <return type="Basis" /> <description> Returns the inverse inertia tensor basis. This is used to calculate the angular acceleration resulting from a torque applied to the [RigidBody3D]. </description> </method> <method name="set_axis_velocity"> - <return type="void"> - </return> - <argument index="0" name="axis_velocity" type="Vector3"> - </argument> + <return type="void" /> + <argument index="0" name="axis_velocity" type="Vector3" /> <description> Sets an axis velocity. The velocity in the given vector axis will be set as the given vector length. This is useful for jumping behavior. </description> @@ -162,30 +142,24 @@ </members> <signals> <signal name="body_entered"> - <argument index="0" name="body" type="Node"> - </argument> + <argument index="0" name="body" type="Node" /> <description> Emitted when a collision with another [PhysicsBody3D] or [GridMap] occurs. Requires [member contact_monitor] to be set to [code]true[/code] and [member contacts_reported] to be set high enough to detect all the collisions. [GridMap]s are detected if the [MeshLibrary] has Collision [Shape3D]s. [code]body[/code] the [Node], if it exists in the tree, of the other [PhysicsBody3D] or [GridMap]. </description> </signal> <signal name="body_exited"> - <argument index="0" name="body" type="Node"> - </argument> + <argument index="0" name="body" type="Node" /> <description> Emitted when the collision with another [PhysicsBody3D] or [GridMap] ends. Requires [member contact_monitor] to be set to [code]true[/code] and [member contacts_reported] to be set high enough to detect all the collisions. [GridMap]s are detected if the [MeshLibrary] has Collision [Shape3D]s. [code]body[/code] the [Node], if it exists in the tree, of the other [PhysicsBody3D] or [GridMap]. </description> </signal> <signal name="body_shape_entered"> - <argument index="0" name="body_rid" type="RID"> - </argument> - <argument index="1" name="body" type="Node"> - </argument> - <argument index="2" name="body_shape" type="int"> - </argument> - <argument index="3" name="local_shape" type="int"> - </argument> + <argument index="0" name="body_rid" type="RID" /> + <argument index="1" name="body" type="Node" /> + <argument index="2" name="body_shape" type="int" /> + <argument index="3" name="local_shape" type="int" /> <description> Emitted when one of this RigidBody3D's [Shape3D]s collides with another [PhysicsBody3D] or [GridMap]'s [Shape3D]s. Requires [member contact_monitor] to be set to [code]true[/code] and [member contacts_reported] to be set high enough to detect all the collisions. [GridMap]s are detected if the [MeshLibrary] has Collision [Shape3D]s. [code]body_id[/code] the [RID] of the other [PhysicsBody3D] or [MeshLibrary]'s [CollisionObject3D] used by the [PhysicsServer3D]. @@ -196,14 +170,10 @@ </description> </signal> <signal name="body_shape_exited"> - <argument index="0" name="body_rid" type="RID"> - </argument> - <argument index="1" name="body" type="Node"> - </argument> - <argument index="2" name="body_shape" type="int"> - </argument> - <argument index="3" name="local_shape" type="int"> - </argument> + <argument index="0" name="body_rid" type="RID" /> + <argument index="1" name="body" type="Node" /> + <argument index="2" name="body_shape" type="int" /> + <argument index="3" name="local_shape" type="int" /> <description> Emitted when the collision between one of this RigidBody3D's [Shape3D]s and another [PhysicsBody3D] or [GridMap]'s [Shape3D]s ends. Requires [member contact_monitor] to be set to [code]true[/code] and [member contacts_reported] to be set high enough to detect all the collisions. [GridMap]s are detected if the [MeshLibrary] has Collision [Shape3D]s. [code]body_id[/code] the [RID] of the other [PhysicsBody3D] or [MeshLibrary]'s [CollisionObject3D] used by the [PhysicsServer3D]. [GridMap]s are detected if the Meshes have [Shape3D]s. diff --git a/doc/classes/RootMotionView.xml b/doc/classes/RootMotionView.xml index be8d8d0078..e31ea9265e 100644 --- a/doc/classes/RootMotionView.xml +++ b/doc/classes/RootMotionView.xml @@ -1,23 +1,32 @@ <?xml version="1.0" encoding="UTF-8" ?> <class name="RootMotionView" inherits="VisualInstance3D" version="4.0"> <brief_description> + Editor-only helper for setting up root motion in [AnimationTree]. </brief_description> <description> + [i]Root motion[/i] refers to an animation technique where a mesh's skeleton is used to give impulse to a character. When working with 3D animations, a popular technique is for animators to use the root skeleton bone to give motion to the rest of the skeleton. This allows animating characters in a way where steps actually match the floor below. It also allows precise interaction with objects during cinematics. See also [AnimationTree]. + [b]Note:[/b] [RootMotionView] is only visible in the editor. It will be hidden automatically in the running project, and will also be converted to a plain [Node] in the running project. This means a script attached to a [RootMotionView] node [i]must[/i] have [code]extends Node[/code] instead of [code]extends RootMotionView[/code]. Additionally, it must not be a [code]@tool[/code] script. </description> <tutorials> + <link title="Using AnimationTree - Root motion">https://docs.godotengine.org/en/latest/tutorials/animation/animation_tree.html#root-motion</link> </tutorials> <methods> </methods> <members> <member name="animation_path" type="NodePath" setter="set_animation_path" getter="get_animation_path"> + Path to an [AnimationTree] node to use as a basis for root motion. </member> <member name="cell_size" type="float" setter="set_cell_size" getter="get_cell_size"> + The grid's cell size in 3D units. </member> <member name="color" type="Color" setter="set_color" getter="get_color"> + The grid's color. </member> <member name="radius" type="float" setter="set_radius" getter="get_radius"> + The grid's radius in 3D units. The grid's opacity will fade gradually as the distance from the origin increases until this [member radius] is reached. </member> <member name="zero_y" type="bool" setter="set_zero_y" getter="get_zero_y"> + If [code]true[/code], the grid's points will all be on the same Y coordinate ([i]local[/i] Y = 0). If [code]false[/code], the points' original Y coordinate is preserved. </member> </members> <constants> diff --git a/doc/classes/SceneState.xml b/doc/classes/SceneState.xml index 6d804cc697..1c3bac9270 100644 --- a/doc/classes/SceneState.xml +++ b/doc/classes/SceneState.xml @@ -11,187 +11,146 @@ </tutorials> <methods> <method name="get_connection_binds" qualifiers="const"> - <return type="Array"> - </return> - <argument index="0" name="idx" type="int"> - </argument> + <return type="Array" /> + <argument index="0" name="idx" type="int" /> <description> Returns the list of bound parameters for the signal at [code]idx[/code]. </description> </method> <method name="get_connection_count" qualifiers="const"> - <return type="int"> - </return> + <return type="int" /> <description> Returns the number of signal connections in the scene. The [code]idx[/code] argument used to query connection metadata in other [code]get_connection_*[/code] methods in the interval [code][0, get_connection_count() - 1][/code]. </description> </method> <method name="get_connection_flags" qualifiers="const"> - <return type="int"> - </return> - <argument index="0" name="idx" type="int"> - </argument> + <return type="int" /> + <argument index="0" name="idx" type="int" /> <description> Returns the connection flags for the signal at [code]idx[/code]. See [enum Object.ConnectFlags] constants. </description> </method> <method name="get_connection_method" qualifiers="const"> - <return type="StringName"> - </return> - <argument index="0" name="idx" type="int"> - </argument> + <return type="StringName" /> + <argument index="0" name="idx" type="int" /> <description> Returns the method connected to the signal at [code]idx[/code]. </description> </method> <method name="get_connection_signal" qualifiers="const"> - <return type="StringName"> - </return> - <argument index="0" name="idx" type="int"> - </argument> + <return type="StringName" /> + <argument index="0" name="idx" type="int" /> <description> Returns the name of the signal at [code]idx[/code]. </description> </method> <method name="get_connection_source" qualifiers="const"> - <return type="NodePath"> - </return> - <argument index="0" name="idx" type="int"> - </argument> + <return type="NodePath" /> + <argument index="0" name="idx" type="int" /> <description> Returns the path to the node that owns the signal at [code]idx[/code], relative to the root node. </description> </method> <method name="get_connection_target" qualifiers="const"> - <return type="NodePath"> - </return> - <argument index="0" name="idx" type="int"> - </argument> + <return type="NodePath" /> + <argument index="0" name="idx" type="int" /> <description> Returns the path to the node that owns the method connected to the signal at [code]idx[/code], relative to the root node. </description> </method> <method name="get_node_count" qualifiers="const"> - <return type="int"> - </return> + <return type="int" /> <description> Returns the number of nodes in the scene. The [code]idx[/code] argument used to query node data in other [code]get_node_*[/code] methods in the interval [code][0, get_node_count() - 1][/code]. </description> </method> <method name="get_node_groups" qualifiers="const"> - <return type="PackedStringArray"> - </return> - <argument index="0" name="idx" type="int"> - </argument> + <return type="PackedStringArray" /> + <argument index="0" name="idx" type="int" /> <description> Returns the list of group names associated with the node at [code]idx[/code]. </description> </method> <method name="get_node_index" qualifiers="const"> - <return type="int"> - </return> - <argument index="0" name="idx" type="int"> - </argument> + <return type="int" /> + <argument index="0" name="idx" type="int" /> <description> Returns the node's index, which is its position relative to its siblings. This is only relevant and saved in scenes for cases where new nodes are added to an instantiated or inherited scene among siblings from the base scene. Despite the name, this index is not related to the [code]idx[/code] argument used here and in other methods. </description> </method> <method name="get_node_instance" qualifiers="const"> - <return type="PackedScene"> - </return> - <argument index="0" name="idx" type="int"> - </argument> + <return type="PackedScene" /> + <argument index="0" name="idx" type="int" /> <description> Returns a [PackedScene] for the node at [code]idx[/code] (i.e. the whole branch starting at this node, with its child nodes and resources), or [code]null[/code] if the node is not an instance. </description> </method> <method name="get_node_instance_placeholder" qualifiers="const"> - <return type="String"> - </return> - <argument index="0" name="idx" type="int"> - </argument> + <return type="String" /> + <argument index="0" name="idx" type="int" /> <description> Returns the path to the represented scene file if the node at [code]idx[/code] is an [InstancePlaceholder]. </description> </method> <method name="get_node_name" qualifiers="const"> - <return type="StringName"> - </return> - <argument index="0" name="idx" type="int"> - </argument> + <return type="StringName" /> + <argument index="0" name="idx" type="int" /> <description> Returns the name of the node at [code]idx[/code]. </description> </method> <method name="get_node_owner_path" qualifiers="const"> - <return type="NodePath"> - </return> - <argument index="0" name="idx" type="int"> - </argument> + <return type="NodePath" /> + <argument index="0" name="idx" type="int" /> <description> Returns the path to the owner of the node at [code]idx[/code], relative to the root node. </description> </method> <method name="get_node_path" qualifiers="const"> - <return type="NodePath"> - </return> - <argument index="0" name="idx" type="int"> - </argument> - <argument index="1" name="for_parent" type="bool" default="false"> - </argument> + <return type="NodePath" /> + <argument index="0" name="idx" type="int" /> + <argument index="1" name="for_parent" type="bool" default="false" /> <description> Returns the path to the node at [code]idx[/code]. If [code]for_parent[/code] is [code]true[/code], returns the path of the [code]idx[/code] node's parent instead. </description> </method> <method name="get_node_property_count" qualifiers="const"> - <return type="int"> - </return> - <argument index="0" name="idx" type="int"> - </argument> + <return type="int" /> + <argument index="0" name="idx" type="int" /> <description> Returns the number of exported or overridden properties for the node at [code]idx[/code]. The [code]prop_idx[/code] argument used to query node property data in other [code]get_node_property_*[/code] methods in the interval [code][0, get_node_property_count() - 1][/code]. </description> </method> <method name="get_node_property_name" qualifiers="const"> - <return type="StringName"> - </return> - <argument index="0" name="idx" type="int"> - </argument> - <argument index="1" name="prop_idx" type="int"> - </argument> + <return type="StringName" /> + <argument index="0" name="idx" type="int" /> + <argument index="1" name="prop_idx" type="int" /> <description> Returns the name of the property at [code]prop_idx[/code] for the node at [code]idx[/code]. </description> </method> <method name="get_node_property_value" qualifiers="const"> - <return type="Variant"> - </return> - <argument index="0" name="idx" type="int"> - </argument> - <argument index="1" name="prop_idx" type="int"> - </argument> + <return type="Variant" /> + <argument index="0" name="idx" type="int" /> + <argument index="1" name="prop_idx" type="int" /> <description> Returns the value of the property at [code]prop_idx[/code] for the node at [code]idx[/code]. </description> </method> <method name="get_node_type" qualifiers="const"> - <return type="StringName"> - </return> - <argument index="0" name="idx" type="int"> - </argument> + <return type="StringName" /> + <argument index="0" name="idx" type="int" /> <description> Returns the type of the node at [code]idx[/code]. </description> </method> <method name="is_node_instance_placeholder" qualifiers="const"> - <return type="bool"> - </return> - <argument index="0" name="idx" type="int"> - </argument> + <return type="bool" /> + <argument index="0" name="idx" type="int" /> <description> Returns [code]true[/code] if the node at [code]idx[/code] is an [InstancePlaceholder]. </description> diff --git a/doc/classes/SceneTree.xml b/doc/classes/SceneTree.xml index bf51b4dfa7..59e3190213 100644 --- a/doc/classes/SceneTree.xml +++ b/doc/classes/SceneTree.xml @@ -14,36 +14,27 @@ </tutorials> <methods> <method name="call_group" qualifiers="vararg"> - <return type="Variant"> - </return> - <argument index="0" name="group" type="StringName"> - </argument> - <argument index="1" name="method" type="StringName"> - </argument> + <return type="Variant" /> + <argument index="0" name="group" type="StringName" /> + <argument index="1" name="method" type="StringName" /> <description> Calls [code]method[/code] on each member of the given group. You can pass arguments to [code]method[/code] by specifying them at the end of the method call. [b]Note:[/b] [method call_group] will always call methods with an one-frame delay, in a way similar to [method Object.call_deferred]. To call methods immediately, use [method call_group_flags] with the [constant GROUP_CALL_REALTIME] flag. </description> </method> <method name="call_group_flags" qualifiers="vararg"> - <return type="Variant"> - </return> - <argument index="0" name="flags" type="int"> - </argument> - <argument index="1" name="group" type="StringName"> - </argument> - <argument index="2" name="method" type="StringName"> - </argument> + <return type="Variant" /> + <argument index="0" name="flags" type="int" /> + <argument index="1" name="group" type="StringName" /> + <argument index="2" name="method" type="StringName" /> <description> Calls [code]method[/code] on each member of the given group, respecting the given [enum GroupCallFlags]. You can pass arguments to [code]method[/code] by specifying them at the end of the method call. [b]Note:[/b] Group call flags are used to control the method calling behavior. If the [constant GROUP_CALL_REALTIME] flag is present in the [code]flags[/code] argument, methods will be called immediately. If this flag isn't present in [code]flags[/code], methods will be called with a one-frame delay in a way similar to [method call_group]. </description> </method> <method name="change_scene"> - <return type="int" enum="Error"> - </return> - <argument index="0" name="path" type="String"> - </argument> + <return type="int" enum="Error" /> + <argument index="0" name="path" type="String" /> <description> Changes the running scene to the one at the given [code]path[/code], after loading it into a [PackedScene] and creating a new instance. Returns [constant OK] on success, [constant ERR_CANT_OPEN] if the [code]path[/code] cannot be loaded into a [PackedScene], or [constant ERR_CANT_CREATE] if that scene cannot be instantiated. @@ -51,10 +42,8 @@ </description> </method> <method name="change_scene_to"> - <return type="int" enum="Error"> - </return> - <argument index="0" name="packed_scene" type="PackedScene"> - </argument> + <return type="int" enum="Error" /> + <argument index="0" name="packed_scene" type="PackedScene" /> <description> Changes the running scene to a new instance of the given [PackedScene]. Returns [constant OK] on success or [constant ERR_CANT_CREATE] if the scene cannot be instantiated. @@ -62,12 +51,9 @@ </description> </method> <method name="create_timer"> - <return type="SceneTreeTimer"> - </return> - <argument index="0" name="time_sec" type="float"> - </argument> - <argument index="1" name="process_always" type="bool" default="true"> - </argument> + <return type="SceneTreeTimer" /> + <argument index="0" name="time_sec" type="float" /> + <argument index="1" name="process_always" type="bool" default="true" /> <description> Returns a [SceneTreeTimer] which will [signal SceneTreeTimer.timeout] after the given time in seconds elapsed in this [SceneTree]. If [code]process_always[/code] is set to [code]false[/code], pausing the [SceneTree] will also pause the timer. Commonly used to create a one-shot delay timer as in the following example: @@ -91,97 +77,76 @@ </description> </method> <method name="create_tween"> - <return type="Tween"> - </return> + <return type="Tween" /> <description> Creates and returns a new [Tween]. </description> </method> <method name="get_first_node_in_group"> - <return type="Node"> - </return> - <argument index="0" name="group" type="StringName"> - </argument> + <return type="Node" /> + <argument index="0" name="group" type="StringName" /> <description> </description> </method> <method name="get_frame" qualifiers="const"> - <return type="int"> - </return> + <return type="int" /> <description> Returns the current frame number, i.e. the total frame count since the application started. </description> </method> <method name="get_node_count" qualifiers="const"> - <return type="int"> - </return> + <return type="int" /> <description> Returns the number of nodes in this [SceneTree]. </description> </method> <method name="get_nodes_in_group"> - <return type="Array"> - </return> - <argument index="0" name="group" type="StringName"> - </argument> + <return type="Array" /> + <argument index="0" name="group" type="StringName" /> <description> Returns a list of all nodes assigned to the given group. </description> </method> <method name="get_processed_tweens"> - <return type="Array"> - </return> + <return type="Array" /> <description> - Returns an array of currently exising [Tween]s in the [SceneTree] (both running and paused). + Returns an array of currently existing [Tween]s in the [SceneTree] (both running and paused). </description> </method> <method name="has_group" qualifiers="const"> - <return type="bool"> - </return> - <argument index="0" name="name" type="StringName"> - </argument> + <return type="bool" /> + <argument index="0" name="name" type="StringName" /> <description> Returns [code]true[/code] if the given group exists. </description> </method> <method name="notify_group"> - <return type="void"> - </return> - <argument index="0" name="group" type="StringName"> - </argument> - <argument index="1" name="notification" type="int"> - </argument> + <return type="void" /> + <argument index="0" name="group" type="StringName" /> + <argument index="1" name="notification" type="int" /> <description> Sends the given notification to all members of the [code]group[/code]. </description> </method> <method name="notify_group_flags"> - <return type="void"> - </return> - <argument index="0" name="call_flags" type="int"> - </argument> - <argument index="1" name="group" type="StringName"> - </argument> - <argument index="2" name="notification" type="int"> - </argument> + <return type="void" /> + <argument index="0" name="call_flags" type="int" /> + <argument index="1" name="group" type="StringName" /> + <argument index="2" name="notification" type="int" /> <description> Sends the given notification to all members of the [code]group[/code], respecting the given [enum GroupCallFlags]. </description> </method> <method name="queue_delete"> - <return type="void"> - </return> - <argument index="0" name="obj" type="Object"> - </argument> + <return type="void" /> + <argument index="0" name="obj" type="Object" /> <description> Queues the given object for deletion, delaying the call to [method Object.free] to after the current frame. </description> </method> <method name="quit"> - <return type="void"> - </return> - <argument index="0" name="exit_code" type="int" default="0"> - </argument> + <return type="void" /> + <argument index="0" name="exit_code" type="int" default="0" /> <description> Quits the application at the end of the current iteration. Argument [code]exit_code[/code] can optionally be given (defaulting to 0) to customize the exit status code. By convention, an exit code of [code]0[/code] indicates success whereas a non-zero exit code indicates an error. @@ -190,56 +155,42 @@ </description> </method> <method name="reload_current_scene"> - <return type="int" enum="Error"> - </return> + <return type="int" enum="Error" /> <description> Reloads the currently active scene. Returns [constant OK] on success, [constant ERR_UNCONFIGURED] if no [member current_scene] was defined yet, [constant ERR_CANT_OPEN] if [member current_scene] cannot be loaded into a [PackedScene], or [constant ERR_CANT_CREATE] if the scene cannot be instantiated. </description> </method> <method name="set_auto_accept_quit"> - <return type="void"> - </return> - <argument index="0" name="enabled" type="bool"> - </argument> + <return type="void" /> + <argument index="0" name="enabled" type="bool" /> <description> If [code]true[/code], the application automatically accepts quitting. Enabled by default. For mobile platforms, see [method set_quit_on_go_back]. </description> </method> <method name="set_group"> - <return type="void"> - </return> - <argument index="0" name="group" type="StringName"> - </argument> - <argument index="1" name="property" type="String"> - </argument> - <argument index="2" name="value" type="Variant"> - </argument> + <return type="void" /> + <argument index="0" name="group" type="StringName" /> + <argument index="1" name="property" type="String" /> + <argument index="2" name="value" type="Variant" /> <description> Sets the given [code]property[/code] to [code]value[/code] on all members of the given group. </description> </method> <method name="set_group_flags"> - <return type="void"> - </return> - <argument index="0" name="call_flags" type="int"> - </argument> - <argument index="1" name="group" type="StringName"> - </argument> - <argument index="2" name="property" type="String"> - </argument> - <argument index="3" name="value" type="Variant"> - </argument> + <return type="void" /> + <argument index="0" name="call_flags" type="int" /> + <argument index="1" name="group" type="StringName" /> + <argument index="2" name="property" type="String" /> + <argument index="3" name="value" type="Variant" /> <description> Sets the given [code]property[/code] to [code]value[/code] on all members of the given group, respecting the given [enum GroupCallFlags]. </description> </method> <method name="set_quit_on_go_back"> - <return type="void"> - </return> - <argument index="0" name="enabled" type="bool"> - </argument> + <return type="void" /> + <argument index="0" name="enabled" type="bool" /> <description> If [code]true[/code], the application quits automatically on going back (e.g. on Android). Enabled by default. To handle 'Go Back' button when this option is disabled, use [constant DisplayServer.WINDOW_EVENT_GO_BACK_REQUEST]. @@ -277,38 +228,32 @@ </members> <signals> <signal name="files_dropped"> - <argument index="0" name="files" type="PackedStringArray"> - </argument> - <argument index="1" name="screen" type="int"> - </argument> + <argument index="0" name="files" type="PackedStringArray" /> + <argument index="1" name="screen" type="int" /> <description> Emitted when files are dragged from the OS file manager and dropped in the game window. The arguments are a list of file paths and the identifier of the screen where the drag originated. </description> </signal> <signal name="node_added"> - <argument index="0" name="node" type="Node"> - </argument> + <argument index="0" name="node" type="Node" /> <description> Emitted whenever a node is added to the [SceneTree]. </description> </signal> <signal name="node_configuration_warning_changed"> - <argument index="0" name="node" type="Node"> - </argument> + <argument index="0" name="node" type="Node" /> <description> Emitted when a node's configuration changed. Only emitted in [code]tool[/code] mode. </description> </signal> <signal name="node_removed"> - <argument index="0" name="node" type="Node"> - </argument> + <argument index="0" name="node" type="Node" /> <description> Emitted whenever a node is removed from the [SceneTree]. </description> </signal> <signal name="node_renamed"> - <argument index="0" name="node" type="Node"> - </argument> + <argument index="0" name="node" type="Node" /> <description> Emitted whenever a node is renamed. </description> diff --git a/doc/classes/Script.xml b/doc/classes/Script.xml index e7527d73e2..843d8ef9cb 100644 --- a/doc/classes/Script.xml +++ b/doc/classes/Script.xml @@ -12,100 +12,83 @@ </tutorials> <methods> <method name="can_instantiate" qualifiers="const"> - <return type="bool"> - </return> + <return type="bool" /> <description> Returns [code]true[/code] if the script can be instantiated. </description> </method> <method name="get_base_script" qualifiers="const"> - <return type="Script"> - </return> + <return type="Script" /> <description> Returns the script directly inherited by this script. </description> </method> <method name="get_instance_base_type" qualifiers="const"> - <return type="StringName"> - </return> + <return type="StringName" /> <description> Returns the script's base type. </description> </method> <method name="get_property_default_value"> - <return type="Variant"> - </return> - <argument index="0" name="property" type="StringName"> - </argument> + <return type="Variant" /> + <argument index="0" name="property" type="StringName" /> <description> Returns the default value of the specified property. </description> </method> <method name="get_script_constant_map"> - <return type="Dictionary"> - </return> + <return type="Dictionary" /> <description> Returns a dictionary containing constant names and their values. </description> </method> <method name="get_script_method_list"> - <return type="Array"> - </return> + <return type="Array" /> <description> Returns the list of methods in this [Script]. </description> </method> <method name="get_script_property_list"> - <return type="Array"> - </return> + <return type="Array" /> <description> Returns the list of properties in this [Script]. </description> </method> <method name="get_script_signal_list"> - <return type="Array"> - </return> + <return type="Array" /> <description> Returns the list of user signals defined in this [Script]. </description> </method> <method name="has_script_signal" qualifiers="const"> - <return type="bool"> - </return> - <argument index="0" name="signal_name" type="StringName"> - </argument> + <return type="bool" /> + <argument index="0" name="signal_name" type="StringName" /> <description> Returns [code]true[/code] if the script, or a base class, defines a signal with the given name. </description> </method> <method name="has_source_code" qualifiers="const"> - <return type="bool"> - </return> + <return type="bool" /> <description> Returns [code]true[/code] if the script contains non-empty source code. </description> </method> <method name="instance_has" qualifiers="const"> - <return type="bool"> - </return> - <argument index="0" name="base_object" type="Object"> - </argument> + <return type="bool" /> + <argument index="0" name="base_object" type="Object" /> <description> Returns [code]true[/code] if [code]base_object[/code] is an instance of this script. </description> </method> <method name="is_tool" qualifiers="const"> - <return type="bool"> - </return> + <return type="bool" /> <description> Returns [code]true[/code] if the script is a tool script. A tool script can run in the editor. </description> </method> <method name="reload"> - <return type="int" enum="Error"> - </return> - <argument index="0" name="keep_state" type="bool" default="false"> - </argument> + <return type="int" enum="Error" /> + <argument index="0" name="keep_state" type="bool" default="false" /> <description> Reloads the script's class implementation. Returns an error code. </description> diff --git a/doc/classes/ScriptCreateDialog.xml b/doc/classes/ScriptCreateDialog.xml index 7185213c44..189bfdc3b8 100644 --- a/doc/classes/ScriptCreateDialog.xml +++ b/doc/classes/ScriptCreateDialog.xml @@ -28,16 +28,11 @@ </tutorials> <methods> <method name="config"> - <return type="void"> - </return> - <argument index="0" name="inherits" type="String"> - </argument> - <argument index="1" name="path" type="String"> - </argument> - <argument index="2" name="built_in_enabled" type="bool" default="true"> - </argument> - <argument index="3" name="load_enabled" type="bool" default="true"> - </argument> + <return type="void" /> + <argument index="0" name="inherits" type="String" /> + <argument index="1" name="path" type="String" /> + <argument index="2" name="built_in_enabled" type="bool" default="true" /> + <argument index="3" name="load_enabled" type="bool" default="true" /> <description> Prefills required fields to configure the ScriptCreateDialog for use. </description> @@ -49,8 +44,7 @@ </members> <signals> <signal name="script_created"> - <argument index="0" name="script" type="Script"> - </argument> + <argument index="0" name="script" type="Script" /> <description> Emitted when the user clicks the OK button. </description> diff --git a/doc/classes/ScriptEditor.xml b/doc/classes/ScriptEditor.xml index 31dbf7453f..628be54e1d 100644 --- a/doc/classes/ScriptEditor.xml +++ b/doc/classes/ScriptEditor.xml @@ -10,68 +10,55 @@ </tutorials> <methods> <method name="get_current_editor" qualifiers="const"> - <return type="ScriptEditorBase"> - </return> + <return type="ScriptEditorBase" /> <description> Returns the [ScriptEditorBase] object that the user is currently editing. </description> </method> <method name="get_current_script"> - <return type="Script"> - </return> + <return type="Script" /> <description> Returns a [Script] that is currently active in editor. </description> </method> <method name="get_open_script_editors" qualifiers="const"> - <return type="Array"> - </return> + <return type="Array" /> <description> Returns an array with all [ScriptEditorBase] objects which are currently open in editor. </description> </method> <method name="get_open_scripts" qualifiers="const"> - <return type="Array"> - </return> + <return type="Array" /> <description> Returns an array with all [Script] objects which are currently open in editor. </description> </method> <method name="goto_line"> - <return type="void"> - </return> - <argument index="0" name="line_number" type="int"> - </argument> + <return type="void" /> + <argument index="0" name="line_number" type="int" /> <description> Goes to the specified line in the current script. </description> </method> <method name="open_script_create_dialog"> - <return type="void"> - </return> - <argument index="0" name="base_name" type="String"> - </argument> - <argument index="1" name="base_path" type="String"> - </argument> + <return type="void" /> + <argument index="0" name="base_name" type="String" /> + <argument index="1" name="base_path" type="String" /> <description> Opens the script create dialog. The script will extend [code]base_name[/code]. The file extension can be omitted from [code]base_path[/code]. It will be added based on the selected scripting language. </description> </method> <method name="register_syntax_highlighter"> - <return type="void"> - </return> - <argument index="0" name="syntax_highlighter" type="EditorSyntaxHighlighter"> - </argument> + <return type="void" /> + <argument index="0" name="syntax_highlighter" type="EditorSyntaxHighlighter" /> <description> Registers the [EditorSyntaxHighlighter] to the editor, the [EditorSyntaxHighlighter] will be available on all open scripts. [b]Note:[/b] Does not apply to scripts that are already opened. </description> </method> <method name="unregister_syntax_highlighter"> - <return type="void"> - </return> - <argument index="0" name="syntax_highlighter" type="EditorSyntaxHighlighter"> - </argument> + <return type="void" /> + <argument index="0" name="syntax_highlighter" type="EditorSyntaxHighlighter" /> <description> Unregisters the [EditorSyntaxHighlighter] from the editor. [b]Note:[/b] The [EditorSyntaxHighlighter] will still be applied to scripts that are already opened. @@ -80,15 +67,13 @@ </methods> <signals> <signal name="editor_script_changed"> - <argument index="0" name="script" type="Script"> - </argument> + <argument index="0" name="script" type="Script" /> <description> Emitted when user changed active script. Argument is a freshly activated [Script]. </description> </signal> <signal name="script_close"> - <argument index="0" name="script" type="Script"> - </argument> + <argument index="0" name="script" type="Script" /> <description> Emitted when editor is about to close the active script. Argument is a [Script] that is going to be closed. </description> diff --git a/doc/classes/ScriptEditorBase.xml b/doc/classes/ScriptEditorBase.xml index a135062bd8..0efcde5638 100644 --- a/doc/classes/ScriptEditorBase.xml +++ b/doc/classes/ScriptEditorBase.xml @@ -10,17 +10,14 @@ </tutorials> <methods> <method name="_add_syntax_highlighter" qualifiers="virtual"> - <return type="void"> - </return> - <argument index="0" name="highlighter" type="Object"> - </argument> + <return type="void" /> + <argument index="0" name="highlighter" type="Object" /> <description> Adds a [EditorSyntaxHighlighter] to the open script. </description> </method> <method name="get_base_editor" qualifiers="const"> - <return type="Control"> - </return> + <return type="Control" /> <description> Returns the underlying [Control] used for editing scripts. This can be either [CodeEdit] (for text scripts) or [GraphEdit] (for visual scripts). </description> @@ -33,8 +30,7 @@ </description> </signal> <signal name="go_to_help"> - <argument index="0" name="what" type="String"> - </argument> + <argument index="0" name="what" type="String" /> <description> Emitted when the user requests a specific documentation page. </description> @@ -45,24 +41,20 @@ </description> </signal> <signal name="replace_in_files_requested"> - <argument index="0" name="text" type="String"> - </argument> + <argument index="0" name="text" type="String" /> <description> Emitted when the user request to find and replace text in the file system. Not used by visual scripts. </description> </signal> <signal name="request_help"> - <argument index="0" name="topic" type="String"> - </argument> + <argument index="0" name="topic" type="String" /> <description> Emitted when the user requests contextual help. </description> </signal> <signal name="request_open_script_at_line"> - <argument index="0" name="script" type="Object"> - </argument> - <argument index="1" name="line" type="int"> - </argument> + <argument index="0" name="script" type="Object" /> + <argument index="1" name="line" type="int" /> <description> Emitted when the user requests a script. </description> @@ -73,8 +65,7 @@ </description> </signal> <signal name="search_in_files_requested"> - <argument index="0" name="text" type="String"> - </argument> + <argument index="0" name="text" type="String" /> <description> Emitted when the user request to search text in the file system. Not used by visual scripts. </description> diff --git a/doc/classes/ScrollContainer.xml b/doc/classes/ScrollContainer.xml index 60f3106b4b..600e2ee245 100644 --- a/doc/classes/ScrollContainer.xml +++ b/doc/classes/ScrollContainer.xml @@ -12,24 +12,20 @@ </tutorials> <methods> <method name="ensure_control_visible"> - <return type="void"> - </return> - <argument index="0" name="control" type="Control"> - </argument> + <return type="void" /> + <argument index="0" name="control" type="Control" /> <description> Ensures the given [code]control[/code] is visible (must be a direct or indirect child of the ScrollContainer). Used by [member follow_focus]. </description> </method> <method name="get_h_scrollbar"> - <return type="HScrollBar"> - </return> + <return type="HScrollBar" /> <description> Returns the horizontal scrollbar [HScrollBar] of this [ScrollContainer]. </description> </method> <method name="get_v_scrollbar"> - <return type="VScrollBar"> - </return> + <return type="VScrollBar" /> <description> Returns the vertical scrollbar [VScrollBar] of this [ScrollContainer]. </description> diff --git a/doc/classes/Semaphore.xml b/doc/classes/Semaphore.xml index e8b405e52a..7794161ac4 100644 --- a/doc/classes/Semaphore.xml +++ b/doc/classes/Semaphore.xml @@ -11,22 +11,19 @@ </tutorials> <methods> <method name="post"> - <return type="void"> - </return> + <return type="void" /> <description> Lowers the [Semaphore], allowing one more thread in. </description> </method> <method name="try_wait"> - <return type="int" enum="Error"> - </return> + <return type="int" enum="Error" /> <description> Like [method wait], but won't block, so if the value is zero, fails immediately and returns [constant ERR_BUSY]. If non-zero, it returns [constant OK] to report success. </description> </method> <method name="wait"> - <return type="void"> - </return> + <return type="void" /> <description> Waits for the [Semaphore], if its value is zero, blocks until non-zero. </description> diff --git a/doc/classes/Shader.xml b/doc/classes/Shader.xml index a717eba438..bc5457b8ce 100644 --- a/doc/classes/Shader.xml +++ b/doc/classes/Shader.xml @@ -12,39 +12,31 @@ </tutorials> <methods> <method name="get_default_texture_param" qualifiers="const"> - <return type="Texture2D"> - </return> - <argument index="0" name="param" type="StringName"> - </argument> + <return type="Texture2D" /> + <argument index="0" name="param" type="StringName" /> <description> Returns the texture that is set as default for the specified parameter. [b]Note:[/b] [code]param[/code] must match the name of the uniform in the code exactly. </description> </method> <method name="get_mode" qualifiers="const"> - <return type="int" enum="Shader.Mode"> - </return> + <return type="int" enum="Shader.Mode" /> <description> Returns the shader mode for the shader, either [constant MODE_CANVAS_ITEM], [constant MODE_SPATIAL] or [constant MODE_PARTICLES]. </description> </method> <method name="has_param" qualifiers="const"> - <return type="bool"> - </return> - <argument index="0" name="name" type="StringName"> - </argument> + <return type="bool" /> + <argument index="0" name="name" type="StringName" /> <description> Returns [code]true[/code] if the shader has this param defined as a uniform in its code. [b]Note:[/b] [code]param[/code] must match the name of the uniform in the code exactly. </description> </method> <method name="set_default_texture_param"> - <return type="void"> - </return> - <argument index="0" name="param" type="StringName"> - </argument> - <argument index="1" name="texture" type="Texture2D"> - </argument> + <return type="void" /> + <argument index="0" name="param" type="StringName" /> + <argument index="1" name="texture" type="Texture2D" /> <description> Sets the default texture to be used with a texture uniform. The default is used if a texture is not set in the [ShaderMaterial]. [b]Note:[/b] [code]param[/code] must match the name of the uniform in the code exactly. diff --git a/doc/classes/ShaderMaterial.xml b/doc/classes/ShaderMaterial.xml index b1748703ff..fe3ddc1b60 100644 --- a/doc/classes/ShaderMaterial.xml +++ b/doc/classes/ShaderMaterial.xml @@ -11,39 +11,30 @@ </tutorials> <methods> <method name="get_shader_param" qualifiers="const"> - <return type="Variant"> - </return> - <argument index="0" name="param" type="StringName"> - </argument> + <return type="Variant" /> + <argument index="0" name="param" type="StringName" /> <description> Returns the current value set for this material of a uniform in the shader. </description> </method> <method name="property_can_revert"> - <return type="bool"> - </return> - <argument index="0" name="name" type="String"> - </argument> + <return type="bool" /> + <argument index="0" name="name" type="String" /> <description> Returns [code]true[/code] if the property identified by [code]name[/code] can be reverted to a default value. </description> </method> <method name="property_get_revert"> - <return type="Variant"> - </return> - <argument index="0" name="name" type="String"> - </argument> + <return type="Variant" /> + <argument index="0" name="name" type="String" /> <description> Returns the default value of the material property with given [code]name[/code]. </description> </method> <method name="set_shader_param"> - <return type="void"> - </return> - <argument index="0" name="param" type="StringName"> - </argument> - <argument index="1" name="value" type="Variant"> - </argument> + <return type="void" /> + <argument index="0" name="param" type="StringName" /> + <argument index="1" name="value" type="Variant" /> <description> Changes the value set for this material of a uniform in the shader. [b]Note:[/b] [code]param[/code] must match the name of the uniform in the code exactly. </description> diff --git a/doc/classes/Shape2D.xml b/doc/classes/Shape2D.xml index 65a37314f6..c1191aa9de 100644 --- a/doc/classes/Shape2D.xml +++ b/doc/classes/Shape2D.xml @@ -11,76 +11,53 @@ </tutorials> <methods> <method name="collide"> - <return type="bool"> - </return> - <argument index="0" name="local_xform" type="Transform2D"> - </argument> - <argument index="1" name="with_shape" type="Shape2D"> - </argument> - <argument index="2" name="shape_xform" type="Transform2D"> - </argument> + <return type="bool" /> + <argument index="0" name="local_xform" type="Transform2D" /> + <argument index="1" name="with_shape" type="Shape2D" /> + <argument index="2" name="shape_xform" type="Transform2D" /> <description> Returns [code]true[/code] if this shape is colliding with another. This method needs the transformation matrix for this shape ([code]local_xform[/code]), the shape to check collisions with ([code]with_shape[/code]), and the transformation matrix of that shape ([code]shape_xform[/code]). </description> </method> <method name="collide_and_get_contacts"> - <return type="Array"> - </return> - <argument index="0" name="local_xform" type="Transform2D"> - </argument> - <argument index="1" name="with_shape" type="Shape2D"> - </argument> - <argument index="2" name="shape_xform" type="Transform2D"> - </argument> + <return type="Array" /> + <argument index="0" name="local_xform" type="Transform2D" /> + <argument index="1" name="with_shape" type="Shape2D" /> + <argument index="2" name="shape_xform" type="Transform2D" /> <description> Returns a list of the points where this shape touches another. If there are no collisions the list is empty. This method needs the transformation matrix for this shape ([code]local_xform[/code]), the shape to check collisions with ([code]with_shape[/code]), and the transformation matrix of that shape ([code]shape_xform[/code]). </description> </method> <method name="collide_with_motion"> - <return type="bool"> - </return> - <argument index="0" name="local_xform" type="Transform2D"> - </argument> - <argument index="1" name="local_motion" type="Vector2"> - </argument> - <argument index="2" name="with_shape" type="Shape2D"> - </argument> - <argument index="3" name="shape_xform" type="Transform2D"> - </argument> - <argument index="4" name="shape_motion" type="Vector2"> - </argument> + <return type="bool" /> + <argument index="0" name="local_xform" type="Transform2D" /> + <argument index="1" name="local_motion" type="Vector2" /> + <argument index="2" name="with_shape" type="Shape2D" /> + <argument index="3" name="shape_xform" type="Transform2D" /> + <argument index="4" name="shape_motion" type="Vector2" /> <description> Returns whether this shape would collide with another, if a given movement was applied. This method needs the transformation matrix for this shape ([code]local_xform[/code]), the movement to test on this shape ([code]local_motion[/code]), the shape to check collisions with ([code]with_shape[/code]), the transformation matrix of that shape ([code]shape_xform[/code]), and the movement to test onto the other object ([code]shape_motion[/code]). </description> </method> <method name="collide_with_motion_and_get_contacts"> - <return type="Array"> - </return> - <argument index="0" name="local_xform" type="Transform2D"> - </argument> - <argument index="1" name="local_motion" type="Vector2"> - </argument> - <argument index="2" name="with_shape" type="Shape2D"> - </argument> - <argument index="3" name="shape_xform" type="Transform2D"> - </argument> - <argument index="4" name="shape_motion" type="Vector2"> - </argument> + <return type="Array" /> + <argument index="0" name="local_xform" type="Transform2D" /> + <argument index="1" name="local_motion" type="Vector2" /> + <argument index="2" name="with_shape" type="Shape2D" /> + <argument index="3" name="shape_xform" type="Transform2D" /> + <argument index="4" name="shape_motion" type="Vector2" /> <description> Returns a list of the points where this shape would touch another, if a given movement was applied. If there are no collisions the list is empty. This method needs the transformation matrix for this shape ([code]local_xform[/code]), the movement to test on this shape ([code]local_motion[/code]), the shape to check collisions with ([code]with_shape[/code]), the transformation matrix of that shape ([code]shape_xform[/code]), and the movement to test onto the other object ([code]shape_motion[/code]). </description> </method> <method name="draw"> - <return type="void"> - </return> - <argument index="0" name="canvas_item" type="RID"> - </argument> - <argument index="1" name="color" type="Color"> - </argument> + <return type="void" /> + <argument index="0" name="canvas_item" type="RID" /> + <argument index="1" name="color" type="Color" /> <description> Draws a solid shape onto a [CanvasItem] with the [RenderingServer] API filled with the specified [code]color[/code]. The exact drawing method is specific for each shape and cannot be configured. </description> diff --git a/doc/classes/Shape3D.xml b/doc/classes/Shape3D.xml index b5f70132d7..5fd16d8d36 100644 --- a/doc/classes/Shape3D.xml +++ b/doc/classes/Shape3D.xml @@ -11,8 +11,7 @@ </tutorials> <methods> <method name="get_debug_mesh"> - <return type="ArrayMesh"> - </return> + <return type="ArrayMesh" /> <description> Returns the [ArrayMesh] used to draw the debug collision for this [Shape3D]. </description> diff --git a/doc/classes/Shortcut.xml b/doc/classes/Shortcut.xml index 55bbb083c9..04955103dc 100644 --- a/doc/classes/Shortcut.xml +++ b/doc/classes/Shortcut.xml @@ -11,24 +11,20 @@ </tutorials> <methods> <method name="get_as_text" qualifiers="const"> - <return type="String"> - </return> + <return type="String" /> <description> Returns the shortcut's [InputEvent] as a [String]. </description> </method> <method name="is_shortcut" qualifiers="const"> - <return type="bool"> - </return> - <argument index="0" name="event" type="InputEvent"> - </argument> + <return type="bool" /> + <argument index="0" name="event" type="InputEvent" /> <description> Returns [code]true[/code] if the shortcut's [InputEvent] equals [code]event[/code]. </description> </method> <method name="is_valid" qualifiers="const"> - <return type="bool"> - </return> + <return type="bool" /> <description> If [code]true[/code], this shortcut is valid. </description> diff --git a/doc/classes/Signal.xml b/doc/classes/Signal.xml index 1fd70a43fd..0e44abef42 100644 --- a/doc/classes/Signal.xml +++ b/doc/classes/Signal.xml @@ -9,117 +9,93 @@ </tutorials> <methods> <method name="Signal" qualifiers="constructor"> - <return type="Signal"> - </return> + <return type="Signal" /> <description> Constructs a null [Signal] with no object nor signal name bound. </description> </method> <method name="Signal" qualifiers="constructor"> - <return type="Signal"> - </return> - <argument index="0" name="from" type="Signal"> - </argument> + <return type="Signal" /> + <argument index="0" name="from" type="Signal" /> <description> Constructs a [Signal] as a copy of the given [Signal]. </description> </method> <method name="Signal" qualifiers="constructor"> - <return type="Signal"> - </return> - <argument index="0" name="object" type="Object"> - </argument> - <argument index="1" name="signal" type="StringName"> - </argument> + <return type="Signal" /> + <argument index="0" name="object" type="Object" /> + <argument index="1" name="signal" type="StringName" /> <description> Creates a new [Signal] with the name [code]signal[/code] in the specified [code]object[/code]. </description> </method> <method name="connect"> - <return type="int"> - </return> - <argument index="0" name="callable" type="Callable"> - </argument> - <argument index="1" name="binds" type="Array" default="[]"> - </argument> - <argument index="2" name="flags" type="int" default="0"> - </argument> + <return type="int" /> + <argument index="0" name="callable" type="Callable" /> + <argument index="1" name="binds" type="Array" default="[]" /> + <argument index="2" name="flags" type="int" default="0" /> <description> Connects this signal to the specified [Callable], optionally providing binds and connection flags. </description> </method> <method name="disconnect"> - <return type="void"> - </return> - <argument index="0" name="callable" type="Callable"> - </argument> + <return type="void" /> + <argument index="0" name="callable" type="Callable" /> <description> Disconnects this signal from the specified [Callable]. </description> </method> <method name="emit" qualifiers="vararg const"> - <return type="void"> - </return> + <return type="void" /> <description> Emits this signal to all connected objects. </description> </method> <method name="get_connections" qualifiers="const"> - <return type="Array"> - </return> + <return type="Array" /> <description> Returns the list of [Callable]s connected to this signal. </description> </method> <method name="get_name" qualifiers="const"> - <return type="StringName"> - </return> + <return type="StringName" /> <description> Returns the name of this signal. </description> </method> <method name="get_object" qualifiers="const"> - <return type="Object"> - </return> + <return type="Object" /> <description> Returns the object emitting this signal. </description> </method> <method name="get_object_id" qualifiers="const"> - <return type="int"> - </return> + <return type="int" /> <description> Returns the ID of the object emitting this signal (see [method Object.get_instance_id]). </description> </method> <method name="is_connected" qualifiers="const"> - <return type="bool"> - </return> - <argument index="0" name="callable" type="Callable"> - </argument> + <return type="bool" /> + <argument index="0" name="callable" type="Callable" /> <description> Returns [code]true[/code] if the specified [Callable] is connected to this signal. </description> </method> <method name="is_null" qualifiers="const"> - <return type="bool"> - </return> + <return type="bool" /> <description> </description> </method> <method name="operator !=" qualifiers="operator"> - <return type="bool"> - </return> - <argument index="0" name="right" type="Signal"> - </argument> + <return type="bool" /> + <argument index="0" name="right" type="Signal" /> <description> </description> </method> <method name="operator ==" qualifiers="operator"> - <return type="bool"> - </return> - <argument index="0" name="right" type="Signal"> - </argument> + <return type="bool" /> + <argument index="0" name="right" type="Signal" /> <description> </description> </method> diff --git a/doc/classes/Skeleton2D.xml b/doc/classes/Skeleton2D.xml index 6665a4a9f6..828d24338b 100644 --- a/doc/classes/Skeleton2D.xml +++ b/doc/classes/Skeleton2D.xml @@ -11,77 +11,60 @@ </tutorials> <methods> <method name="execute_modifications"> - <return type="void"> - </return> - <argument index="0" name="delta" type="float"> - </argument> - <argument index="1" name="execution_mode" type="int"> - </argument> + <return type="void" /> + <argument index="0" name="delta" type="float" /> + <argument index="1" name="execution_mode" type="int" /> <description> Executes all the modifications on the [SkeletonModificationStack2D], if the Skeleton3D has one assigned. </description> </method> <method name="get_bone"> - <return type="Bone2D"> - </return> - <argument index="0" name="idx" type="int"> - </argument> + <return type="Bone2D" /> + <argument index="0" name="idx" type="int" /> <description> Returns a [Bone2D] from the node hierarchy parented by Skeleton2D. The object to return is identified by the parameter [code]idx[/code]. Bones are indexed by descending the node hierarchy from top to bottom, adding the children of each branch before moving to the next sibling. </description> </method> <method name="get_bone_count" qualifiers="const"> - <return type="int"> - </return> + <return type="int" /> <description> Returns the number of [Bone2D] nodes in the node hierarchy parented by Skeleton2D. </description> </method> <method name="get_bone_local_pose_override"> - <return type="Transform2D"> - </return> - <argument index="0" name="bone_idx" type="int"> - </argument> + <return type="Transform2D" /> + <argument index="0" name="bone_idx" type="int" /> <description> Returns the local pose override transform for [code]bone_idx[/code]. </description> </method> <method name="get_modification_stack" qualifiers="const"> - <return type="SkeletonModificationStack2D"> - </return> + <return type="SkeletonModificationStack2D" /> <description> Returns the [SkeletonModificationStack2D] attached to this skeleton, if one exists. </description> </method> <method name="get_skeleton" qualifiers="const"> - <return type="RID"> - </return> + <return type="RID" /> <description> Returns the [RID] of a Skeleton2D instance. </description> </method> <method name="set_bone_local_pose_override"> - <return type="void"> - </return> - <argument index="0" name="bone_idx" type="int"> - </argument> - <argument index="1" name="override_pose" type="Transform2D"> - </argument> - <argument index="2" name="strength" type="float"> - </argument> - <argument index="3" name="persistent" type="bool"> - </argument> + <return type="void" /> + <argument index="0" name="bone_idx" type="int" /> + <argument index="1" name="override_pose" type="Transform2D" /> + <argument index="2" name="strength" type="float" /> + <argument index="3" name="persistent" type="bool" /> <description> Sets the local pose transform, [code]pose[/code], for the bone at [code]bone_idx[/code]. - [code]amount[/code] is the interpolation strengh that will be used when applying the pose, and [code]persistent[/code] determines if the applied pose will remain. + [code]amount[/code] is the interpolation strength that will be used when applying the pose, and [code]persistent[/code] determines if the applied pose will remain. [b]Note:[/b] The pose transform needs to be a local transform relative to the [Bone2D] node at [code]bone_idx[/code]! </description> </method> <method name="set_modification_stack"> - <return type="void"> - </return> - <argument index="0" name="modification_stack" type="SkeletonModificationStack2D"> - </argument> + <return type="void" /> + <argument index="0" name="modification_stack" type="SkeletonModificationStack2D" /> <description> Sets the [SkeletonModificationStack2D] attached to this skeleton. </description> diff --git a/doc/classes/Skeleton3D.xml b/doc/classes/Skeleton3D.xml index 136f2f0a63..0ec2f6b7ca 100644 --- a/doc/classes/Skeleton3D.xml +++ b/doc/classes/Skeleton3D.xml @@ -14,220 +14,173 @@ </tutorials> <methods> <method name="add_bone"> - <return type="void"> - </return> - <argument index="0" name="name" type="String"> - </argument> + <return type="void" /> + <argument index="0" name="name" type="String" /> <description> Adds a bone, with name [code]name[/code]. [method get_bone_count] will become the bone index. </description> </method> <method name="bone_transform_to_world_transform"> - <return type="Transform3D"> - </return> - <argument index="0" name="bone_transform" type="Transform3D"> - </argument> + <return type="Transform3D" /> + <argument index="0" name="bone_transform" type="Transform3D" /> <description> Takes the given bone pose/transform and converts it to a world transform, relative to the [Skeleton3D] node. This is useful for using the bone transform in calculations with transforms from [Node3D]-based nodes. </description> </method> <method name="clear_bones"> - <return type="void"> - </return> + <return type="void" /> <description> Clear all the bones in this skeleton. </description> </method> <method name="clear_bones_global_pose_override"> - <return type="void"> - </return> + <return type="void" /> <description> Removes the global pose override on all bones in the skeleton. </description> </method> <method name="find_bone" qualifiers="const"> - <return type="int"> - </return> - <argument index="0" name="name" type="String"> - </argument> + <return type="int" /> + <argument index="0" name="name" type="String" /> <description> Returns the bone index that matches [code]name[/code] as its name. </description> </method> <method name="get_bone_count" qualifiers="const"> - <return type="int"> - </return> + <return type="int" /> <description> Returns the amount of bones in the skeleton. </description> </method> <method name="get_bone_custom_pose" qualifiers="const"> - <return type="Transform3D"> - </return> - <argument index="0" name="bone_idx" type="int"> - </argument> + <return type="Transform3D" /> + <argument index="0" name="bone_idx" type="int" /> <description> Returns the custom pose of the specified bone. Custom pose is applied on top of the rest pose. </description> </method> <method name="get_bone_global_pose" qualifiers="const"> - <return type="Transform3D"> - </return> - <argument index="0" name="bone_idx" type="int"> - </argument> + <return type="Transform3D" /> + <argument index="0" name="bone_idx" type="int" /> <description> Returns the overall transform of the specified bone, with respect to the skeleton. Being relative to the skeleton frame, this is not the actual "global" transform of the bone. </description> </method> <method name="get_bone_global_pose_no_override" qualifiers="const"> - <return type="Transform3D"> - </return> - <argument index="0" name="bone_idx" type="int"> - </argument> + <return type="Transform3D" /> + <argument index="0" name="bone_idx" type="int" /> <description> Returns the overall transform of the specified bone, with respect to the skeleton, but without any global pose overrides. Being relative to the skeleton frame, this is not the actual "global" transform of the bone. </description> </method> <method name="get_bone_name" qualifiers="const"> - <return type="String"> - </return> - <argument index="0" name="bone_idx" type="int"> - </argument> + <return type="String" /> + <argument index="0" name="bone_idx" type="int" /> <description> Returns the name of the bone at index [code]index[/code]. </description> </method> <method name="get_bone_parent" qualifiers="const"> - <return type="int"> - </return> - <argument index="0" name="bone_idx" type="int"> - </argument> + <return type="int" /> + <argument index="0" name="bone_idx" type="int" /> <description> Returns the bone index which is the parent of the bone at [code]bone_idx[/code]. If -1, then bone has no parent. [b]Note:[/b] The parent bone returned will always be less than [code]bone_idx[/code]. </description> </method> <method name="get_bone_pose" qualifiers="const"> - <return type="Transform3D"> - </return> - <argument index="0" name="bone_idx" type="int"> - </argument> + <return type="Transform3D" /> + <argument index="0" name="bone_idx" type="int" /> <description> Returns the pose transform of the specified bone. Pose is applied on top of the custom pose, which is applied on top the rest pose. </description> </method> <method name="get_bone_process_orders"> - <return type="PackedInt32Array"> - </return> + <return type="PackedInt32Array" /> <description> </description> </method> <method name="get_bone_rest" qualifiers="const"> - <return type="Transform3D"> - </return> - <argument index="0" name="bone_idx" type="int"> - </argument> + <return type="Transform3D" /> + <argument index="0" name="bone_idx" type="int" /> <description> Returns the rest transform for a bone [code]bone_idx[/code]. </description> </method> <method name="is_bone_rest_disabled" qualifiers="const"> - <return type="bool"> - </return> - <argument index="0" name="bone_idx" type="int"> - </argument> + <return type="bool" /> + <argument index="0" name="bone_idx" type="int" /> <description> Returns whether the bone rest for the bone at [code]bone_idx[/code] is disabled. </description> </method> <method name="localize_rests"> - <return type="void"> - </return> + <return type="void" /> <description> Returns all bones in the skeleton to their rest poses. </description> </method> <method name="physical_bones_add_collision_exception"> - <return type="void"> - </return> - <argument index="0" name="exception" type="RID"> - </argument> + <return type="void" /> + <argument index="0" name="exception" type="RID" /> <description> Adds a collision exception to the physical bone. Works just like the [RigidBody3D] node. </description> </method> <method name="physical_bones_remove_collision_exception"> - <return type="void"> - </return> - <argument index="0" name="exception" type="RID"> - </argument> + <return type="void" /> + <argument index="0" name="exception" type="RID" /> <description> Removes a collision exception to the physical bone. Works just like the [RigidBody3D] node. </description> </method> <method name="physical_bones_start_simulation"> - <return type="void"> - </return> - <argument index="0" name="bones" type="StringName[]" default="[]"> - </argument> + <return type="void" /> + <argument index="0" name="bones" type="StringName[]" default="[]" /> <description> Tells the [PhysicalBone3D] nodes in the Skeleton to start simulating and reacting to the physics world. Optionally, a list of bone names can be passed-in, allowing only the passed-in bones to be simulated. </description> </method> <method name="physical_bones_stop_simulation"> - <return type="void"> - </return> + <return type="void" /> <description> Tells the [PhysicalBone3D] nodes in the Skeleton to stop simulating. </description> </method> <method name="register_skin"> - <return type="SkinReference"> - </return> - <argument index="0" name="skin" type="Skin"> - </argument> + <return type="SkinReference" /> + <argument index="0" name="skin" type="Skin" /> <description> Binds the given Skin to the Skeleton. </description> </method> <method name="set_bone_custom_pose"> - <return type="void"> - </return> - <argument index="0" name="bone_idx" type="int"> - </argument> - <argument index="1" name="custom_pose" type="Transform3D"> - </argument> + <return type="void" /> + <argument index="0" name="bone_idx" type="int" /> + <argument index="1" name="custom_pose" type="Transform3D" /> <description> Sets the custom pose transform, [code]custom_pose[/code], for the bone at [code]bone_idx[/code]. This pose is an addition to the bone rest pose. [b]Note[/b]: The pose transform needs to be in bone space. Use [method world_transform_to_bone_transform] to convert a world transform, like one you can get from a [Node3D], to bone space. </description> </method> <method name="set_bone_disable_rest"> - <return type="void"> - </return> - <argument index="0" name="bone_idx" type="int"> - </argument> - <argument index="1" name="disable" type="bool"> - </argument> + <return type="void" /> + <argument index="0" name="bone_idx" type="int" /> + <argument index="1" name="disable" type="bool" /> <description> Disables the rest pose for the bone at [code]bone_idx[/code] if [code]true[/code], enables the bone rest if [code]false[/code]. </description> </method> <method name="set_bone_global_pose_override"> - <return type="void"> - </return> - <argument index="0" name="bone_idx" type="int"> - </argument> - <argument index="1" name="pose" type="Transform3D"> - </argument> - <argument index="2" name="amount" type="float"> - </argument> - <argument index="3" name="persistent" type="bool" default="false"> - </argument> + <return type="void" /> + <argument index="0" name="bone_idx" type="int" /> + <argument index="1" name="pose" type="Transform3D" /> + <argument index="2" name="amount" type="float" /> + <argument index="3" name="persistent" type="bool" default="false" /> <description> Sets the global pose transform, [code]pose[/code], for the bone at [code]bone_idx[/code]. [code]amount[/code] is the interpolation strength that will be used when applying the pose, and [code]persistent[/code] determines if the applied pose will remain. @@ -235,64 +188,48 @@ </description> </method> <method name="set_bone_name"> - <return type="void"> - </return> - <argument index="0" name="bone_idx" type="int"> - </argument> - <argument index="1" name="name" type="String"> - </argument> + <return type="void" /> + <argument index="0" name="bone_idx" type="int" /> + <argument index="1" name="name" type="String" /> <description> </description> </method> <method name="set_bone_parent"> - <return type="void"> - </return> - <argument index="0" name="bone_idx" type="int"> - </argument> - <argument index="1" name="parent_idx" type="int"> - </argument> + <return type="void" /> + <argument index="0" name="bone_idx" type="int" /> + <argument index="1" name="parent_idx" type="int" /> <description> Sets the bone index [code]parent_idx[/code] as the parent of the bone at [code]bone_idx[/code]. If -1, then bone has no parent. [b]Note:[/b] [code]parent_idx[/code] must be less than [code]bone_idx[/code]. </description> </method> <method name="set_bone_pose"> - <return type="void"> - </return> - <argument index="0" name="bone_idx" type="int"> - </argument> - <argument index="1" name="pose" type="Transform3D"> - </argument> + <return type="void" /> + <argument index="0" name="bone_idx" type="int" /> + <argument index="1" name="pose" type="Transform3D" /> <description> Sets the pose transform for bone [code]bone_idx[/code]. [b]Note[/b]: The pose transform needs to be in bone space. Use [method world_transform_to_bone_transform] to convert a world transform, like one you can get from a [Node3D], to bone space. </description> </method> <method name="set_bone_rest"> - <return type="void"> - </return> - <argument index="0" name="bone_idx" type="int"> - </argument> - <argument index="1" name="rest" type="Transform3D"> - </argument> + <return type="void" /> + <argument index="0" name="bone_idx" type="int" /> + <argument index="1" name="rest" type="Transform3D" /> <description> Sets the rest transform for bone [code]bone_idx[/code]. </description> </method> <method name="unparent_bone_and_rest"> - <return type="void"> - </return> - <argument index="0" name="bone_idx" type="int"> - </argument> + <return type="void" /> + <argument index="0" name="bone_idx" type="int" /> <description> Unparents the bone at [code]bone_idx[/code] and sets its rest position to that of its parent prior to being reset. </description> </method> <method name="world_transform_to_bone_transform"> - <return type="Transform3D"> - </return> - <argument index="0" name="world_transform" type="Transform3D"> - </argument> + <return type="Transform3D" /> + <argument index="0" name="world_transform" type="Transform3D" /> <description> Takes the given world transform, relative to the [Skeleton3D], and converts it to a bone pose/transform. This is useful for using setting bone poses using transforms from [Node3D]-based nodes. diff --git a/doc/classes/SkeletonIK3D.xml b/doc/classes/SkeletonIK3D.xml index 138ebe4411..93cdd770cc 100644 --- a/doc/classes/SkeletonIK3D.xml +++ b/doc/classes/SkeletonIK3D.xml @@ -9,28 +9,23 @@ </tutorials> <methods> <method name="get_parent_skeleton" qualifiers="const"> - <return type="Skeleton3D"> - </return> + <return type="Skeleton3D" /> <description> </description> </method> <method name="is_running"> - <return type="bool"> - </return> + <return type="bool" /> <description> </description> </method> <method name="start"> - <return type="void"> - </return> - <argument index="0" name="one_time" type="bool" default="false"> - </argument> + <return type="void" /> + <argument index="0" name="one_time" type="bool" default="false" /> <description> </description> </method> <method name="stop"> - <return type="void"> - </return> + <return type="void" /> <description> </description> </method> diff --git a/doc/classes/SkeletonModification2D.xml b/doc/classes/SkeletonModification2D.xml index 8596dac76e..cff55b6a17 100644 --- a/doc/classes/SkeletonModification2D.xml +++ b/doc/classes/SkeletonModification2D.xml @@ -11,81 +11,64 @@ </tutorials> <methods> <method name="_draw_editor_gizmo" qualifiers="virtual"> - <return type="void"> - </return> + <return type="void" /> <description> - Used for drawing [b]editor-only[/b] modification gizmos. This function will only be called in the Godot editor and can be overriden to draw custom gizmos. + Used for drawing [b]editor-only[/b] modification gizmos. This function will only be called in the Godot editor and can be overridden to draw custom gizmos. [b]Note:[/b] You will need to use the Skeleton2D from [method SkeletonModificationStack2D.get_skeleton] and it's draw functions, as the [SkeletonModification2D] resource cannot draw on its own. </description> </method> <method name="_execute" qualifiers="virtual"> - <return type="void"> - </return> - <argument index="0" name="delta" type="float"> - </argument> + <return type="void" /> + <argument index="0" name="delta" type="float" /> <description> Executes the given modification. This is where the modification performs whatever function it is designed to do. </description> </method> <method name="_setup_modification" qualifiers="virtual"> - <return type="void"> - </return> - <argument index="0" name="modification_stack" type="SkeletonModificationStack2D"> - </argument> + <return type="void" /> + <argument index="0" name="modification_stack" type="SkeletonModificationStack2D" /> <description> Called when the modification is setup. This is where the modification performs initialization. </description> </method> <method name="clamp_angle"> - <return type="float"> - </return> - <argument index="0" name="angle" type="float"> - </argument> - <argument index="1" name="min" type="float"> - </argument> - <argument index="2" name="max" type="float"> - </argument> - <argument index="3" name="invert" type="bool"> - </argument> + <return type="float" /> + <argument index="0" name="angle" type="float" /> + <argument index="1" name="min" type="float" /> + <argument index="2" name="max" type="float" /> + <argument index="3" name="invert" type="bool" /> <description> Takes a angle and clamps it so it is within the passed-in [code]min[/code] and [code]max[/code] range. [code]invert[/code] will inversely clamp the angle, clamping it to the range outside of the given bounds. </description> </method> <method name="get_editor_draw_gizmo" qualifiers="const"> - <return type="bool"> - </return> + <return type="bool" /> <description> Returns whether this modification will call [method _draw_editor_gizmo] in the Godot editor to draw modification-specific gizmos. </description> </method> <method name="get_is_setup" qualifiers="const"> - <return type="bool"> - </return> + <return type="bool" /> <description> Returns whether this modification has been successfully setup or not. </description> </method> <method name="get_modification_stack"> - <return type="SkeletonModificationStack2D"> - </return> + <return type="SkeletonModificationStack2D" /> <description> Returns the [SkeletonModificationStack2D] that this modification is bound to. Through the modification stack, you can access the Skeleton3D the modification is operating on. </description> </method> <method name="set_editor_draw_gizmo"> - <return type="void"> - </return> - <argument index="0" name="draw_gizmo" type="bool"> - </argument> + <return type="void" /> + <argument index="0" name="draw_gizmo" type="bool" /> <description> Sets whether this modification will call [method _draw_editor_gizmo] in the Godot editor to draw modification-specific gizmos. </description> </method> <method name="set_is_setup"> - <return type="void"> - </return> - <argument index="0" name="is_setup" type="bool"> - </argument> + <return type="void" /> + <argument index="0" name="is_setup" type="bool" /> <description> Manually allows you to set the setup state of the modification. This function should only rarely be used, as the [SkeletonModificationStack2D] the modification is bound to should handle setting the modification up. </description> @@ -96,7 +79,7 @@ If [code]true[/code], the modification's [method _execute] function will be called by the [SkeletonModificationStack2D]. </member> <member name="execution_mode" type="int" setter="set_execution_mode" getter="get_execution_mode" default="0"> - The execution mode for the modification. This tells the modification stack when to execute the modification. Some modifications have settings that are only availible in certain execution modes. + The execution mode for the modification. This tells the modification stack when to execute the modification. Some modifications have settings that are only available in certain execution modes. </member> </members> <constants> diff --git a/doc/classes/SkeletonModification2DCCDIK.xml b/doc/classes/SkeletonModification2DCCDIK.xml index 014d366a42..f876615de7 100644 --- a/doc/classes/SkeletonModification2DCCDIK.xml +++ b/doc/classes/SkeletonModification2DCCDIK.xml @@ -4,7 +4,7 @@ A modification that uses CCDIK to manipulate a series of bones to reach a target in 2D. </brief_description> <description> - This [SkeletonModification2D] uses an algorithm called [b]C[/b]yclic [b]C[/b]oordinate [b]D[/b]escent [b]I[/b]nverse [b]K[/b]inematics, or CCDIK, to maniuplate a chain of bones in a [Skeleton2D] so it reaches a defined target. + This [SkeletonModification2D] uses an algorithm called [b]C[/b]yclic [b]C[/b]oordinate [b]D[/b]escent [b]I[/b]nverse [b]K[/b]inematics, or CCDIK, to manipulate a chain of bones in a [Skeleton2D] so it reaches a defined target. CCDIK works by rotating a set of bones, typically called a "bone chain", on a single axis. Each bone is rotated to face the target from the tip (by default), which over a chain of bones allow it to rotate properly to reach the target. Because the bones only rotate on a single axis, CCDIK [i]can[/i] look more robotic than other IK solvers. [b]Note:[/b] The CCDIK modifier has [code]ccdik_joints[/code], which are the data objects that hold the data for each joint in the CCDIK chain. This is different from a bone! CCDIK joints hold the data needed for each bone in the bone chain used by CCDIK. CCDIK also fully supports angle constraints, allowing for more control over how a solution is met. @@ -13,142 +13,107 @@ </tutorials> <methods> <method name="get_ccdik_joint_bone2d_node" qualifiers="const"> - <return type="NodePath"> - </return> - <argument index="0" name="joint_idx" type="int"> - </argument> + <return type="NodePath" /> + <argument index="0" name="joint_idx" type="int" /> <description> Returns the [Bone2D] node assigned to the CCDIK joint at [code]joint_idx[/code]. </description> </method> <method name="get_ccdik_joint_bone_index" qualifiers="const"> - <return type="int"> - </return> - <argument index="0" name="joint_idx" type="int"> - </argument> + <return type="int" /> + <argument index="0" name="joint_idx" type="int" /> <description> Returns the index of the [Bone2D] node assigned to the CCDIK joint at [code]joint_idx[/code]. </description> </method> <method name="get_ccdik_joint_constraint_angle_invert" qualifiers="const"> - <return type="bool"> - </return> - <argument index="0" name="joint_idx" type="int"> - </argument> + <return type="bool" /> + <argument index="0" name="joint_idx" type="int" /> <description> Returns whether the CCDIK joint at [code]joint_idx[/code] uses an inverted joint constraint. See [method set_ccdik_joint_constraint_angle_invert] for details. </description> </method> <method name="get_ccdik_joint_constraint_angle_max" qualifiers="const"> - <return type="float"> - </return> - <argument index="0" name="joint_idx" type="int"> - </argument> + <return type="float" /> + <argument index="0" name="joint_idx" type="int" /> <description> Returns the maximum angle constraint for the joint at [code]joint_idx[/code]. </description> </method> <method name="get_ccdik_joint_constraint_angle_min" qualifiers="const"> - <return type="float"> - </return> - <argument index="0" name="joint_idx" type="int"> - </argument> + <return type="float" /> + <argument index="0" name="joint_idx" type="int" /> <description> Returns the minimum angle constraint for the joint at [code]joint_idx[/code]. </description> </method> <method name="get_ccdik_joint_enable_constraint" qualifiers="const"> - <return type="bool"> - </return> - <argument index="0" name="joint_idx" type="int"> - </argument> + <return type="bool" /> + <argument index="0" name="joint_idx" type="int" /> <description> Returns whether angle constraints on the CCDIK joint at [code]joint_idx[/code] are enabled. </description> </method> <method name="get_ccdik_joint_rotate_from_joint" qualifiers="const"> - <return type="bool"> - </return> - <argument index="0" name="joint_idx" type="int"> - </argument> + <return type="bool" /> + <argument index="0" name="joint_idx" type="int" /> <description> Returns whether the joint at [code]joint_idx[/code] is set to rotate from the joint, [code]true[/code], or to rotate from the tip, [code]false[/code]. The default is to rotate from the tip. </description> </method> <method name="set_ccdik_joint_bone2d_node"> - <return type="void"> - </return> - <argument index="0" name="joint_idx" type="int"> - </argument> - <argument index="1" name="bone2d_nodepath" type="NodePath"> - </argument> + <return type="void" /> + <argument index="0" name="joint_idx" type="int" /> + <argument index="1" name="bone2d_nodepath" type="NodePath" /> <description> Sets the [Bone2D] node assigned to the CCDIK joint at [code]joint_idx[/code]. </description> </method> <method name="set_ccdik_joint_bone_index"> - <return type="void"> - </return> - <argument index="0" name="joint_idx" type="int"> - </argument> - <argument index="1" name="bone_idx" type="int"> - </argument> + <return type="void" /> + <argument index="0" name="joint_idx" type="int" /> + <argument index="1" name="bone_idx" type="int" /> <description> Sets the bone index, [code]bone_index[/code], of the CCDIK joint at [code]joint_idx[/code]. When possible, this will also update the [code]bone2d_node[/code] of the CCDIK joint based on data provided by the linked skeleton. </description> </method> <method name="set_ccdik_joint_constraint_angle_invert"> - <return type="void"> - </return> - <argument index="0" name="joint_idx" type="int"> - </argument> - <argument index="1" name="invert" type="bool"> - </argument> + <return type="void" /> + <argument index="0" name="joint_idx" type="int" /> + <argument index="1" name="invert" type="bool" /> <description> Sets whether the CCDIK joint at [code]joint_idx[/code] uses an inverted joint constraint. An inverted joint constraint only constraints the CCDIK joint to the angles [i]outside of[/i] the inputted minimum and maximum angles. For this reason, it is referred to as an inverted joint constraint, as it constraints the joint to the outside of the inputted values. </description> </method> <method name="set_ccdik_joint_constraint_angle_max"> - <return type="void"> - </return> - <argument index="0" name="joint_idx" type="int"> - </argument> - <argument index="1" name="angle_max" type="float"> - </argument> + <return type="void" /> + <argument index="0" name="joint_idx" type="int" /> + <argument index="1" name="angle_max" type="float" /> <description> Sets the maximum angle constraint for the joint at [code]joint_idx[/code]. </description> </method> <method name="set_ccdik_joint_constraint_angle_min"> - <return type="void"> - </return> - <argument index="0" name="joint_idx" type="int"> - </argument> - <argument index="1" name="angle_min" type="float"> - </argument> + <return type="void" /> + <argument index="0" name="joint_idx" type="int" /> + <argument index="1" name="angle_min" type="float" /> <description> Sets the minimum angle constraint for the joint at [code]joint_idx[/code]. </description> </method> <method name="set_ccdik_joint_enable_constraint"> - <return type="void"> - </return> - <argument index="0" name="joint_idx" type="int"> - </argument> - <argument index="1" name="enable_constraint" type="bool"> - </argument> + <return type="void" /> + <argument index="0" name="joint_idx" type="int" /> + <argument index="1" name="enable_constraint" type="bool" /> <description> Determines whether angle constraints on the CCDIK joint at [code]joint_idx[/code] are enabled. When [code]true[/code], constraints will be enabled and taken into account when solving. </description> </method> <method name="set_ccdik_joint_rotate_from_joint"> - <return type="void"> - </return> - <argument index="0" name="joint_idx" type="int"> - </argument> - <argument index="1" name="rotate_from_joint" type="bool"> - </argument> + <return type="void" /> + <argument index="0" name="joint_idx" type="int" /> + <argument index="1" name="rotate_from_joint" type="bool" /> <description> Sets whether the joint at [code]joint_idx[/code] is set to rotate from the joint, [code]true[/code], or to rotate from the tip, [code]false[/code]. </description> diff --git a/doc/classes/SkeletonModification2DFABRIK.xml b/doc/classes/SkeletonModification2DFABRIK.xml index 62ab34b06f..314405498a 100644 --- a/doc/classes/SkeletonModification2DFABRIK.xml +++ b/doc/classes/SkeletonModification2DFABRIK.xml @@ -14,81 +14,61 @@ </tutorials> <methods> <method name="get_fabrik_joint_bone2d_node" qualifiers="const"> - <return type="NodePath"> - </return> - <argument index="0" name="joint_idx" type="int"> - </argument> + <return type="NodePath" /> + <argument index="0" name="joint_idx" type="int" /> <description> Returns the [Bone2D] node assigned to the FABRIK joint at [code]joint_idx[/code]. </description> </method> <method name="get_fabrik_joint_bone_index" qualifiers="const"> - <return type="int"> - </return> - <argument index="0" name="joint_idx" type="int"> - </argument> + <return type="int" /> + <argument index="0" name="joint_idx" type="int" /> <description> Returns the index of the [Bone2D] node assigned to the FABRIK joint at [code]joint_idx[/code]. </description> </method> <method name="get_fabrik_joint_magnet_position" qualifiers="const"> - <return type="Vector2"> - </return> - <argument index="0" name="joint_idx" type="int"> - </argument> + <return type="Vector2" /> + <argument index="0" name="joint_idx" type="int" /> <description> Returns the magnet position vector for the joint at [code]joint_idx[/code]. </description> </method> <method name="get_fabrik_joint_use_target_rotation" qualifiers="const"> - <return type="bool"> - </return> - <argument index="0" name="joint_idx" type="int"> - </argument> + <return type="bool" /> + <argument index="0" name="joint_idx" type="int" /> <description> Returns whether the joint is using the target's rotation rather than allowing FABRIK to rotate the joint. This option only applies to the tip/final joint in the chain. </description> </method> <method name="set_fabrik_joint_bone2d_node"> - <return type="void"> - </return> - <argument index="0" name="joint_idx" type="int"> - </argument> - <argument index="1" name="bone2d_nodepath" type="NodePath"> - </argument> + <return type="void" /> + <argument index="0" name="joint_idx" type="int" /> + <argument index="1" name="bone2d_nodepath" type="NodePath" /> <description> Sets the [Bone2D] node assigned to the FABRIK joint at [code]joint_idx[/code]. </description> </method> <method name="set_fabrik_joint_bone_index"> - <return type="void"> - </return> - <argument index="0" name="joint_idx" type="int"> - </argument> - <argument index="1" name="bone_idx" type="int"> - </argument> + <return type="void" /> + <argument index="0" name="joint_idx" type="int" /> + <argument index="1" name="bone_idx" type="int" /> <description> Sets the bone index, [code]bone_index[/code], of the FABRIK joint at [code]joint_idx[/code]. When possible, this will also update the [code]bone2d_node[/code] of the FABRIK joint based on data provided by the linked skeleton. </description> </method> <method name="set_fabrik_joint_magnet_position"> - <return type="void"> - </return> - <argument index="0" name="joint_idx" type="int"> - </argument> - <argument index="1" name="magnet_position" type="Vector2"> - </argument> + <return type="void" /> + <argument index="0" name="joint_idx" type="int" /> + <argument index="1" name="magnet_position" type="Vector2" /> <description> Sets the magnet position vector for the joint at [code]joint_idx[/code]. </description> </method> <method name="set_fabrik_joint_use_target_rotation"> - <return type="void"> - </return> - <argument index="0" name="joint_idx" type="int"> - </argument> - <argument index="1" name="use_target_rotation" type="bool"> - </argument> + <return type="void" /> + <argument index="0" name="joint_idx" type="int" /> + <argument index="1" name="use_target_rotation" type="bool" /> <description> Sets whether the joint at [code]joint_idx[/code] will use the target node's rotation rather than letting FABRIK rotate the node. [b]Note:[/b] This option only works for the tip/final joint in the chain. For all other nodes, this option will be ignored. diff --git a/doc/classes/SkeletonModification2DJiggle.xml b/doc/classes/SkeletonModification2DJiggle.xml index ae46acd0d0..8d3732e225 100644 --- a/doc/classes/SkeletonModification2DJiggle.xml +++ b/doc/classes/SkeletonModification2DJiggle.xml @@ -12,193 +12,147 @@ </tutorials> <methods> <method name="get_collision_mask" qualifiers="const"> - <return type="int"> - </return> + <return type="int" /> <description> Returns the collision mask used by the Jiggle modifier when collisions are enabled. </description> </method> <method name="get_jiggle_joint_bone2d_node" qualifiers="const"> - <return type="NodePath"> - </return> - <argument index="0" name="joint_idx" type="int"> - </argument> + <return type="NodePath" /> + <argument index="0" name="joint_idx" type="int" /> <description> Returns the [Bone2D] node assigned to the Jiggle joint at [code]joint_idx[/code]. </description> </method> <method name="get_jiggle_joint_bone_index" qualifiers="const"> - <return type="int"> - </return> - <argument index="0" name="joint_idx" type="int"> - </argument> + <return type="int" /> + <argument index="0" name="joint_idx" type="int" /> <description> Returns the index of the [Bone2D] node assigned to the Jiggle joint at [code]joint_idx[/code]. </description> </method> <method name="get_jiggle_joint_damping" qualifiers="const"> - <return type="float"> - </return> - <argument index="0" name="joint_idx" type="int"> - </argument> + <return type="float" /> + <argument index="0" name="joint_idx" type="int" /> <description> Returns the amount of damping of the Jiggle joint at [code]joint_idx[/code]. </description> </method> <method name="get_jiggle_joint_gravity" qualifiers="const"> - <return type="Vector2"> - </return> - <argument index="0" name="joint_idx" type="int"> - </argument> + <return type="Vector2" /> + <argument index="0" name="joint_idx" type="int" /> <description> Returns a [Vector2] representing the amount of gravity the Jiggle joint at [code]joint_idx[/code] is influenced by. </description> </method> <method name="get_jiggle_joint_mass" qualifiers="const"> - <return type="float"> - </return> - <argument index="0" name="joint_idx" type="int"> - </argument> + <return type="float" /> + <argument index="0" name="joint_idx" type="int" /> <description> Returns the amount of mass of the jiggle joint at [code]joint_idx[/code]. </description> </method> <method name="get_jiggle_joint_override" qualifiers="const"> - <return type="bool"> - </return> - <argument index="0" name="joint_idx" type="int"> - </argument> + <return type="bool" /> + <argument index="0" name="joint_idx" type="int" /> <description> - Returns a boolean that indiciates whether the joint at [code]joint_idx[/code] is overriding the default Jiggle joint data defined in the modification. + Returns a boolean that indicates whether the joint at [code]joint_idx[/code] is overriding the default Jiggle joint data defined in the modification. </description> </method> <method name="get_jiggle_joint_stiffness" qualifiers="const"> - <return type="float"> - </return> - <argument index="0" name="joint_idx" type="int"> - </argument> + <return type="float" /> + <argument index="0" name="joint_idx" type="int" /> <description> Returns the stiffness of the Jiggle joint at [code]joint_idx[/code]. </description> </method> <method name="get_jiggle_joint_use_gravity" qualifiers="const"> - <return type="bool"> - </return> - <argument index="0" name="joint_idx" type="int"> - </argument> + <return type="bool" /> + <argument index="0" name="joint_idx" type="int" /> <description> - Returns a boolean that indiciates whether the joint at [code]joint_idx[/code] is using gravity or not. + Returns a boolean that indicates whether the joint at [code]joint_idx[/code] is using gravity or not. </description> </method> <method name="get_use_colliders" qualifiers="const"> - <return type="bool"> - </return> + <return type="bool" /> <description> Returns whether the jiggle modifier is taking physics colliders into account when solving. </description> </method> <method name="set_collision_mask"> - <return type="void"> - </return> - <argument index="0" name="collision_mask" type="int"> - </argument> + <return type="void" /> + <argument index="0" name="collision_mask" type="int" /> <description> Sets the collision mask that the Jiggle modifier will use when reacting to colliders, if the Jiggle modifier is set to take colliders into account. </description> </method> <method name="set_jiggle_joint_bone2d_node"> - <return type="void"> - </return> - <argument index="0" name="joint_idx" type="int"> - </argument> - <argument index="1" name="bone2d_node" type="NodePath"> - </argument> + <return type="void" /> + <argument index="0" name="joint_idx" type="int" /> + <argument index="1" name="bone2d_node" type="NodePath" /> <description> Sets the [Bone2D] node assigned to the Jiggle joint at [code]joint_idx[/code]. </description> </method> <method name="set_jiggle_joint_bone_index"> - <return type="void"> - </return> - <argument index="0" name="joint_idx" type="int"> - </argument> - <argument index="1" name="bone_idx" type="int"> - </argument> + <return type="void" /> + <argument index="0" name="joint_idx" type="int" /> + <argument index="1" name="bone_idx" type="int" /> <description> Sets the bone index, [code]bone_index[/code], of the Jiggle joint at [code]joint_idx[/code]. When possible, this will also update the [code]bone2d_node[/code] of the Jiggle joint based on data provided by the linked skeleton. </description> </method> <method name="set_jiggle_joint_damping"> - <return type="void"> - </return> - <argument index="0" name="joint_idx" type="int"> - </argument> - <argument index="1" name="damping" type="float"> - </argument> + <return type="void" /> + <argument index="0" name="joint_idx" type="int" /> + <argument index="1" name="damping" type="float" /> <description> Sets the amount of dampening of the Jiggle joint at [code]joint_idx[/code]. </description> </method> <method name="set_jiggle_joint_gravity"> - <return type="void"> - </return> - <argument index="0" name="joint_idx" type="int"> - </argument> - <argument index="1" name="gravity" type="Vector2"> - </argument> + <return type="void" /> + <argument index="0" name="joint_idx" type="int" /> + <argument index="1" name="gravity" type="Vector2" /> <description> Sets the gravity vector of the Jiggle joint at [code]joint_idx[/code]. </description> </method> <method name="set_jiggle_joint_mass"> - <return type="void"> - </return> - <argument index="0" name="joint_idx" type="int"> - </argument> - <argument index="1" name="mass" type="float"> - </argument> + <return type="void" /> + <argument index="0" name="joint_idx" type="int" /> + <argument index="1" name="mass" type="float" /> <description> Sets the of mass of the Jiggle joint at [code]joint_idx[/code]. </description> </method> <method name="set_jiggle_joint_override"> - <return type="void"> - </return> - <argument index="0" name="joint_idx" type="int"> - </argument> - <argument index="1" name="override" type="bool"> - </argument> + <return type="void" /> + <argument index="0" name="joint_idx" type="int" /> + <argument index="1" name="override" type="bool" /> <description> Sets whether the Jiggle joint at [code]joint_idx[/code] should override the default Jiggle joint settings. Setting this to [code]true[/code] will make the joint use its own settings rather than the default ones attached to the modification. </description> </method> <method name="set_jiggle_joint_stiffness"> - <return type="void"> - </return> - <argument index="0" name="joint_idx" type="int"> - </argument> - <argument index="1" name="stiffness" type="float"> - </argument> + <return type="void" /> + <argument index="0" name="joint_idx" type="int" /> + <argument index="1" name="stiffness" type="float" /> <description> Sets the of stiffness of the Jiggle joint at [code]joint_idx[/code]. </description> </method> <method name="set_jiggle_joint_use_gravity"> - <return type="void"> - </return> - <argument index="0" name="joint_idx" type="int"> - </argument> - <argument index="1" name="use_gravity" type="bool"> - </argument> + <return type="void" /> + <argument index="0" name="joint_idx" type="int" /> + <argument index="1" name="use_gravity" type="bool" /> <description> Sets whether the Jiggle joint at [code]joint_idx[/code] should use gravity. </description> </method> <method name="set_use_colliders"> - <return type="void"> - </return> - <argument index="0" name="use_colliders" type="bool"> - </argument> + <return type="void" /> + <argument index="0" name="use_colliders" type="bool" /> <description> If [code]true[/code], the Jiggle modifier will take colliders into account, keeping them from entering into these collision objects. </description> @@ -206,19 +160,19 @@ </methods> <members> <member name="damping" type="float" setter="set_damping" getter="get_damping" default="0.75"> - The default amount of dampening applied to the Jiggle joints, if they are not overriden. Higher values lead to more of the calculated velocity being applied. + The default amount of dampening applied to the Jiggle joints, if they are not overridden. Higher values lead to more of the calculated velocity being applied. </member> <member name="gravity" type="Vector2" setter="set_gravity" getter="get_gravity" default="Vector2(0, 6)"> - The default amount of gravity applied to the Jiggle joints, if they are not overriden. + The default amount of gravity applied to the Jiggle joints, if they are not overridden. </member> <member name="jiggle_data_chain_length" type="int" setter="set_jiggle_data_chain_length" getter="get_jiggle_data_chain_length" default="0"> The amount of Jiggle joints in the Jiggle modification. </member> <member name="mass" type="float" setter="set_mass" getter="get_mass" default="0.75"> - The default amount of mass assigned to the Jiggle joints, if they are not overriden. Higher values lead to faster movements and more overshooting. + The default amount of mass assigned to the Jiggle joints, if they are not overridden. Higher values lead to faster movements and more overshooting. </member> <member name="stiffness" type="float" setter="set_stiffness" getter="get_stiffness" default="3.0"> - The default amount of stiffness assigned to the Jiggle joints, if they are not overriden. Higher values act more like springs, quickly moving into the correct position. + The default amount of stiffness assigned to the Jiggle joints, if they are not overridden. Higher values act more like springs, quickly moving into the correct position. </member> <member name="target_nodepath" type="NodePath" setter="set_target_node" getter="get_target_node" default="NodePath("")"> The NodePath to the node that is the target for the Jiggle modification. This node is what the Jiggle chain will attempt to rotate the bone chain to. diff --git a/doc/classes/SkeletonModification2DLookAt.xml b/doc/classes/SkeletonModification2DLookAt.xml index b0fa0e5a01..998a897d20 100644 --- a/doc/classes/SkeletonModification2DLookAt.xml +++ b/doc/classes/SkeletonModification2DLookAt.xml @@ -10,82 +10,67 @@ </tutorials> <methods> <method name="get_additional_rotation" qualifiers="const"> - <return type="float"> - </return> + <return type="float" /> <description> Returns the amount of additional rotation that is applied after the LookAt modification executes. </description> </method> <method name="get_constraint_angle_invert" qualifiers="const"> - <return type="bool"> - </return> + <return type="bool" /> <description> Returns whether the constraints to this modification are inverted or not. </description> </method> <method name="get_constraint_angle_max" qualifiers="const"> - <return type="float"> - </return> + <return type="float" /> <description> Returns the constraint's maximum allowed angle. </description> </method> <method name="get_constraint_angle_min" qualifiers="const"> - <return type="float"> - </return> + <return type="float" /> <description> Returns the constraint's minimum allowed angle. </description> </method> <method name="get_enable_constraint" qualifiers="const"> - <return type="bool"> - </return> + <return type="bool" /> <description> Returns [code]true[/code] if the LookAt modification is using constraints. </description> </method> <method name="set_additional_rotation"> - <return type="void"> - </return> - <argument index="0" name="rotation" type="float"> - </argument> + <return type="void" /> + <argument index="0" name="rotation" type="float" /> <description> Sets the amount of additional rotation that is to be applied after executing the modification. This allows for offsetting the results by the inputted rotation amount. </description> </method> <method name="set_constraint_angle_invert"> - <return type="void"> - </return> - <argument index="0" name="invert" type="bool"> - </argument> + <return type="void" /> + <argument index="0" name="invert" type="bool" /> <description> When [code]true[/code], the modification will use an inverted joint constraint. An inverted joint constraint only constraints the [Bone2D] to the angles [i]outside of[/i] the inputted minimum and maximum angles. For this reason, it is referred to as an inverted joint constraint, as it constraints the joint to the outside of the inputted values. </description> </method> <method name="set_constraint_angle_max"> - <return type="void"> - </return> - <argument index="0" name="angle_max" type="float"> - </argument> + <return type="void" /> + <argument index="0" name="angle_max" type="float" /> <description> Sets the constraint's maximum allowed angle. </description> </method> <method name="set_constraint_angle_min"> - <return type="void"> - </return> - <argument index="0" name="angle_min" type="float"> - </argument> + <return type="void" /> + <argument index="0" name="angle_min" type="float" /> <description> Sets the constraint's minimum allowed angle. </description> </method> <method name="set_enable_constraint"> - <return type="void"> - </return> - <argument index="0" name="enable_constraint" type="bool"> - </argument> + <return type="void" /> + <argument index="0" name="enable_constraint" type="bool" /> <description> Sets whether this modification will use constraints or not. When [code]true[/code], constraints will be applied when solving the LookAt modification. </description> diff --git a/doc/classes/SkeletonModification2DPhysicalBones.xml b/doc/classes/SkeletonModification2DPhysicalBones.xml index 2547727097..e6bcb3c9d7 100644 --- a/doc/classes/SkeletonModification2DPhysicalBones.xml +++ b/doc/classes/SkeletonModification2DPhysicalBones.xml @@ -10,48 +10,38 @@ </tutorials> <methods> <method name="fetch_physical_bones"> - <return type="void"> - </return> + <return type="void" /> <description> Empties the list of [PhysicalBone2D] nodes and populates it will all [PhysicalBone2D] nodes that are children of the [Skeleton2D]. </description> </method> <method name="get_physical_bone_node" qualifiers="const"> - <return type="NodePath"> - </return> - <argument index="0" name="joint_idx" type="int"> - </argument> + <return type="NodePath" /> + <argument index="0" name="joint_idx" type="int" /> <description> Returns the [PhysicalBone2D] node at [code]joint_idx[/code]. </description> </method> <method name="set_physical_bone_node"> - <return type="void"> - </return> - <argument index="0" name="joint_idx" type="int"> - </argument> - <argument index="1" name="physicalbone2d_node" type="NodePath"> - </argument> + <return type="void" /> + <argument index="0" name="joint_idx" type="int" /> + <argument index="1" name="physicalbone2d_node" type="NodePath" /> <description> Sets the [PhysicalBone2D] node at [code]joint_idx[/code]. [b]Note:[/b] This is just the index used for this modification, not the bone index used in the [Skeleton2D]. </description> </method> <method name="start_simulation"> - <return type="void"> - </return> - <argument index="0" name="bones" type="StringName[]" default="[]"> - </argument> + <return type="void" /> + <argument index="0" name="bones" type="StringName[]" default="[]" /> <description> Tell the [PhysicalBone2D] nodes to start simulating and interacting with the physics world. Optionally, an array of bone names can be passed to this function, and that will cause only [PhysicalBone2D] nodes with those names to start simulating. </description> </method> <method name="stop_simulation"> - <return type="void"> - </return> - <argument index="0" name="bones" type="StringName[]" default="[]"> - </argument> + <return type="void" /> + <argument index="0" name="bones" type="StringName[]" default="[]" /> <description> Tell the [PhysicalBone2D] nodes to stop simulating and interacting with the physics world. Optionally, an array of bone names can be passed to this function, and that will cause only [PhysicalBone2D] nodes with those names to stop simulating. diff --git a/doc/classes/SkeletonModification2DStackHolder.xml b/doc/classes/SkeletonModification2DStackHolder.xml index 313cf81482..e5d9f2194a 100644 --- a/doc/classes/SkeletonModification2DStackHolder.xml +++ b/doc/classes/SkeletonModification2DStackHolder.xml @@ -11,17 +11,14 @@ </tutorials> <methods> <method name="get_held_modification_stack" qualifiers="const"> - <return type="SkeletonModificationStack2D"> - </return> + <return type="SkeletonModificationStack2D" /> <description> Returns the [SkeletonModificationStack2D] that this modification is holding. </description> </method> <method name="set_held_modification_stack"> - <return type="void"> - </return> - <argument index="0" name="held_modification_stack" type="SkeletonModificationStack2D"> - </argument> + <return type="void" /> + <argument index="0" name="held_modification_stack" type="SkeletonModificationStack2D" /> <description> Sets the [SkeletonModificationStack2D] that this modification is holding. This modification stack will then be executed when this modification is executed. </description> diff --git a/doc/classes/SkeletonModification2DTwoBoneIK.xml b/doc/classes/SkeletonModification2DTwoBoneIK.xml index 554515556b..25ee981d5d 100644 --- a/doc/classes/SkeletonModification2DTwoBoneIK.xml +++ b/doc/classes/SkeletonModification2DTwoBoneIK.xml @@ -4,72 +4,60 @@ A modification that rotates two bones using the law of cosigns to reach the target. </brief_description> <description> - This [SkeletonModification2D] uses an algorithm typically called TwoBoneIK. This algorithm works by leveraging the law of cosigns and the lengths of the bones to figure out what rotation the bones currently have, and what rotation they need to make a complete triangle, where the first bone, the second bone, and the target form the three verticies of the triangle. Because the algorithm works by making a triangle, it can only opperate on two bones. + This [SkeletonModification2D] uses an algorithm typically called TwoBoneIK. This algorithm works by leveraging the law of cosigns and the lengths of the bones to figure out what rotation the bones currently have, and what rotation they need to make a complete triangle, where the first bone, the second bone, and the target form the three vertices of the triangle. Because the algorithm works by making a triangle, it can only operate on two bones. TwoBoneIK is great for arms, legs, and really any joints that can be represented by just two bones that bend to reach a target. This solver is more lightweight than [SkeletonModification2DFABRIK], but gives similar, natural looking results. </description> <tutorials> </tutorials> <methods> <method name="get_joint_one_bone2d_node" qualifiers="const"> - <return type="NodePath"> - </return> + <return type="NodePath" /> <description> Returns the [Bone2D] node that is being used as the first bone in the TwoBoneIK modification. </description> </method> <method name="get_joint_one_bone_idx" qualifiers="const"> - <return type="int"> - </return> + <return type="int" /> <description> Returns the index of the [Bone2D] node that is being used as the first bone in the TwoBoneIK modification. </description> </method> <method name="get_joint_two_bone2d_node" qualifiers="const"> - <return type="NodePath"> - </return> + <return type="NodePath" /> <description> Returns the [Bone2D] node that is being used as the second bone in the TwoBoneIK modification. </description> </method> <method name="get_joint_two_bone_idx" qualifiers="const"> - <return type="int"> - </return> + <return type="int" /> <description> Returns the index of the [Bone2D] node that is being used as the second bone in the TwoBoneIK modification. </description> </method> <method name="set_joint_one_bone2d_node"> - <return type="void"> - </return> - <argument index="0" name="bone2d_node" type="NodePath"> - </argument> + <return type="void" /> + <argument index="0" name="bone2d_node" type="NodePath" /> <description> Sets the [Bone2D] node that is being used as the first bone in the TwoBoneIK modification. </description> </method> <method name="set_joint_one_bone_idx"> - <return type="void"> - </return> - <argument index="0" name="bone_idx" type="int"> - </argument> + <return type="void" /> + <argument index="0" name="bone_idx" type="int" /> <description> Sets the index of the [Bone2D] node that is being used as the first bone in the TwoBoneIK modification. </description> </method> <method name="set_joint_two_bone2d_node"> - <return type="void"> - </return> - <argument index="0" name="bone2d_node" type="NodePath"> - </argument> + <return type="void" /> + <argument index="0" name="bone2d_node" type="NodePath" /> <description> Sets the [Bone2D] node that is being used as the second bone in the TwoBoneIK modification. </description> </method> <method name="set_joint_two_bone_idx"> - <return type="void"> - </return> - <argument index="0" name="bone_idx" type="int"> - </argument> + <return type="void" /> + <argument index="0" name="bone_idx" type="int" /> <description> Sets the index of the [Bone2D] node that is being used as the second bone in the TwoBoneIK modification. </description> diff --git a/doc/classes/SkeletonModificationStack2D.xml b/doc/classes/SkeletonModificationStack2D.xml index 35b899fe08..97b8e3b945 100644 --- a/doc/classes/SkeletonModificationStack2D.xml +++ b/doc/classes/SkeletonModificationStack2D.xml @@ -12,81 +12,64 @@ </tutorials> <methods> <method name="add_modification"> - <return type="void"> - </return> - <argument index="0" name="modification" type="SkeletonModification2D"> - </argument> + <return type="void" /> + <argument index="0" name="modification" type="SkeletonModification2D" /> <description> Adds the passed-in [SkeletonModification2D] to the stack. </description> </method> <method name="delete_modification"> - <return type="void"> - </return> - <argument index="0" name="mod_idx" type="int"> - </argument> + <return type="void" /> + <argument index="0" name="mod_idx" type="int" /> <description> Deletes the [SkeletonModification2D] at the index position [code]mod_idx[/code], if it exists. </description> </method> <method name="enable_all_modifications"> - <return type="void"> - </return> - <argument index="0" name="enabled" type="bool"> - </argument> + <return type="void" /> + <argument index="0" name="enabled" type="bool" /> <description> Enables all [SkeletonModification2D]s in the stack. </description> </method> <method name="execute"> - <return type="void"> - </return> - <argument index="0" name="delta" type="float"> - </argument> - <argument index="1" name="execution_mode" type="int"> - </argument> + <return type="void" /> + <argument index="0" name="delta" type="float" /> + <argument index="1" name="execution_mode" type="int" /> <description> Executes all of the [SkeletonModification2D]s in the stack that use the same execution mode as the passed-in [code]execution_mode[/code], starting from index [code]0[/code] to [member modification_count]. [b]Note:[/b] The order of the modifications can matter depending on the modifications. For example, modifications on a spine should operate before modifications on the arms in order to get proper results. </description> </method> <method name="get_is_setup" qualifiers="const"> - <return type="bool"> - </return> + <return type="bool" /> <description> - Returns a boolean that indiciates whether the modification stack is setup and can execute. + Returns a boolean that indicates whether the modification stack is setup and can execute. </description> </method> <method name="get_modification" qualifiers="const"> - <return type="SkeletonModification2D"> - </return> - <argument index="0" name="mod_idx" type="int"> - </argument> + <return type="SkeletonModification2D" /> + <argument index="0" name="mod_idx" type="int" /> <description> Returns the [SkeletonModification2D] at the passed-in index, [code]mod_idx[/code]. </description> </method> <method name="get_skeleton" qualifiers="const"> - <return type="Skeleton2D"> - </return> + <return type="Skeleton2D" /> <description> Returns the [Skeleton2D] node that the SkeletonModificationStack2D is bound to. </description> </method> <method name="set_modification"> - <return type="void"> - </return> - <argument index="0" name="mod_idx" type="int"> - </argument> - <argument index="1" name="modification" type="SkeletonModification2D"> - </argument> + <return type="void" /> + <argument index="0" name="mod_idx" type="int" /> + <argument index="1" name="modification" type="SkeletonModification2D" /> <description> Sets the modification at [code]mod_idx[/code] to the passed-in modification, [code]modification[/code]. </description> </method> <method name="setup"> - <return type="void"> - </return> + <return type="void" /> <description> Sets up the modification stack so it can execute. This function should be called by [Skeleton2D] and shouldn't be manually called unless you know what you are doing. </description> diff --git a/doc/classes/Skin.xml b/doc/classes/Skin.xml index f409b6c80c..67ca36f4d6 100644 --- a/doc/classes/Skin.xml +++ b/doc/classes/Skin.xml @@ -8,86 +8,64 @@ </tutorials> <methods> <method name="add_bind"> - <return type="void"> - </return> - <argument index="0" name="bone" type="int"> - </argument> - <argument index="1" name="pose" type="Transform3D"> - </argument> + <return type="void" /> + <argument index="0" name="bone" type="int" /> + <argument index="1" name="pose" type="Transform3D" /> <description> </description> </method> <method name="clear_binds"> - <return type="void"> - </return> + <return type="void" /> <description> </description> </method> <method name="get_bind_bone" qualifiers="const"> - <return type="int"> - </return> - <argument index="0" name="bind_index" type="int"> - </argument> + <return type="int" /> + <argument index="0" name="bind_index" type="int" /> <description> </description> </method> <method name="get_bind_count" qualifiers="const"> - <return type="int"> - </return> + <return type="int" /> <description> </description> </method> <method name="get_bind_name" qualifiers="const"> - <return type="StringName"> - </return> - <argument index="0" name="bind_index" type="int"> - </argument> + <return type="StringName" /> + <argument index="0" name="bind_index" type="int" /> <description> </description> </method> <method name="get_bind_pose" qualifiers="const"> - <return type="Transform3D"> - </return> - <argument index="0" name="bind_index" type="int"> - </argument> + <return type="Transform3D" /> + <argument index="0" name="bind_index" type="int" /> <description> </description> </method> <method name="set_bind_bone"> - <return type="void"> - </return> - <argument index="0" name="bind_index" type="int"> - </argument> - <argument index="1" name="bone" type="int"> - </argument> + <return type="void" /> + <argument index="0" name="bind_index" type="int" /> + <argument index="1" name="bone" type="int" /> <description> </description> </method> <method name="set_bind_count"> - <return type="void"> - </return> - <argument index="0" name="bind_count" type="int"> - </argument> + <return type="void" /> + <argument index="0" name="bind_count" type="int" /> <description> </description> </method> <method name="set_bind_name"> - <return type="void"> - </return> - <argument index="0" name="bind_index" type="int"> - </argument> - <argument index="1" name="name" type="StringName"> - </argument> + <return type="void" /> + <argument index="0" name="bind_index" type="int" /> + <argument index="1" name="name" type="StringName" /> <description> </description> </method> <method name="set_bind_pose"> - <return type="void"> - </return> - <argument index="0" name="bind_index" type="int"> - </argument> - <argument index="1" name="pose" type="Transform3D"> - </argument> + <return type="void" /> + <argument index="0" name="bind_index" type="int" /> + <argument index="1" name="pose" type="Transform3D" /> <description> </description> </method> diff --git a/doc/classes/SkinReference.xml b/doc/classes/SkinReference.xml index 3f8bc3be82..d0634c543c 100644 --- a/doc/classes/SkinReference.xml +++ b/doc/classes/SkinReference.xml @@ -8,14 +8,12 @@ </tutorials> <methods> <method name="get_skeleton" qualifiers="const"> - <return type="RID"> - </return> + <return type="RID" /> <description> </description> </method> <method name="get_skin" qualifiers="const"> - <return type="Skin"> - </return> + <return type="Skin" /> <description> </description> </method> diff --git a/doc/classes/SliderJoint3D.xml b/doc/classes/SliderJoint3D.xml index ef9c9a48b6..dc9760b667 100644 --- a/doc/classes/SliderJoint3D.xml +++ b/doc/classes/SliderJoint3D.xml @@ -10,20 +10,15 @@ </tutorials> <methods> <method name="get_param" qualifiers="const"> - <return type="float"> - </return> - <argument index="0" name="param" type="int" enum="SliderJoint3D.Param"> - </argument> + <return type="float" /> + <argument index="0" name="param" type="int" enum="SliderJoint3D.Param" /> <description> </description> </method> <method name="set_param"> - <return type="void"> - </return> - <argument index="0" name="param" type="int" enum="SliderJoint3D.Param"> - </argument> - <argument index="1" name="value" type="float"> - </argument> + <return type="void" /> + <argument index="0" name="param" type="int" enum="SliderJoint3D.Param" /> + <argument index="1" name="value" type="float" /> <description> </description> </method> diff --git a/doc/classes/SoftBody3D.xml b/doc/classes/SoftBody3D.xml index b143c60d9d..53bd7e67bf 100644 --- a/doc/classes/SoftBody3D.xml +++ b/doc/classes/SoftBody3D.xml @@ -11,72 +11,56 @@ </tutorials> <methods> <method name="add_collision_exception_with"> - <return type="void"> - </return> - <argument index="0" name="body" type="Node"> - </argument> + <return type="void" /> + <argument index="0" name="body" type="Node" /> <description> Adds a body to the list of bodies that this body can't collide with. </description> </method> <method name="get_collision_exceptions"> - <return type="Array"> - </return> + <return type="Array" /> <description> Returns an array of nodes that were added as collision exceptions for this body. </description> </method> <method name="get_collision_layer_bit" qualifiers="const"> - <return type="bool"> - </return> - <argument index="0" name="bit" type="int"> - </argument> + <return type="bool" /> + <argument index="0" name="bit" type="int" /> <description> Returns an individual bit on the collision mask. </description> </method> <method name="get_collision_mask_bit" qualifiers="const"> - <return type="bool"> - </return> - <argument index="0" name="bit" type="int"> - </argument> + <return type="bool" /> + <argument index="0" name="bit" type="int" /> <description> Returns an individual bit on the collision mask. </description> </method> <method name="get_physics_rid" qualifiers="const"> - <return type="RID"> - </return> + <return type="RID" /> <description> </description> </method> <method name="remove_collision_exception_with"> - <return type="void"> - </return> - <argument index="0" name="body" type="Node"> - </argument> + <return type="void" /> + <argument index="0" name="body" type="Node" /> <description> Removes a body from the list of bodies that this body can't collide with. </description> </method> <method name="set_collision_layer_bit"> - <return type="void"> - </return> - <argument index="0" name="bit" type="int"> - </argument> - <argument index="1" name="value" type="bool"> - </argument> + <return type="void" /> + <argument index="0" name="bit" type="int" /> + <argument index="1" name="value" type="bool" /> <description> Sets individual bits on the layer mask. Use this if you only need to change one layer's value. </description> </method> <method name="set_collision_mask_bit"> - <return type="void"> - </return> - <argument index="0" name="bit" type="int"> - </argument> - <argument index="1" name="value" type="bool"> - </argument> + <return type="void" /> + <argument index="0" name="bit" type="int" /> + <argument index="1" name="value" type="bool" /> <description> Sets individual bits on the collision mask. Use this if you only need to change one layer's value. </description> @@ -84,12 +68,12 @@ </methods> <members> <member name="collision_layer" type="int" setter="set_collision_layer" getter="get_collision_layer" default="1"> - The physics layers this SoftBody3D is in. - Collidable objects can exist in any of 32 different layers. These layers work like a tagging system, and are not visual. A collidable can use these layers to select with which objects it can collide, using the collision_mask property. - A contact is detected if object A is in any of the layers that object B scans, or object B is in any layer scanned by object A. See [url=https://docs.godotengine.org/en/latest/tutorials/physics/physics_introduction.html#collision-layers-and-masks]Collision layers and masks[/url] in the documentation for more information. + The physics layers this SoftBody3D [b]is in[/b]. Collision objects can exist in one or more of 32 different layers. See also [member collision_mask]. + [b]Note:[/b] Object A can detect a contact with object B only if object B is in any of the layers that object A scans. See [url=https://docs.godotengine.org/en/latest/tutorials/physics/physics_introduction.html#collision-layers-and-masks]Collision layers and masks[/url] in the documentation for more information. </member> <member name="collision_mask" type="int" setter="set_collision_mask" getter="get_collision_mask" default="1"> - The physics layers this SoftBody3D scans for collisions. See [url=https://docs.godotengine.org/en/latest/tutorials/physics/physics_introduction.html#collision-layers-and-masks]Collision layers and masks[/url] in the documentation for more information. + The physics layers this SoftBody3D [b]scans[/b]. Collision objects can scan one or more of 32 different layers. See also [member collision_layer]. + [b]Note:[/b] Object A can detect a contact with object B only if object B is in any of the layers that object A scans. See [url=https://docs.godotengine.org/en/latest/tutorials/physics/physics_introduction.html#collision-layers-and-masks]Collision layers and masks[/url] in the documentation for more information. </member> <member name="damping_coefficient" type="float" setter="set_damping_coefficient" getter="get_damping_coefficient" default="0.01"> </member> diff --git a/doc/classes/SpinBox.xml b/doc/classes/SpinBox.xml index 7e2481f458..1c1e6e5a15 100644 --- a/doc/classes/SpinBox.xml +++ b/doc/classes/SpinBox.xml @@ -30,15 +30,13 @@ </tutorials> <methods> <method name="apply"> - <return type="void"> - </return> + <return type="void" /> <description> Applies the current value of this [SpinBox]. </description> </method> <method name="get_line_edit"> - <return type="LineEdit"> - </return> + <return type="LineEdit" /> <description> Returns the [LineEdit] instance from this [SpinBox]. You can use it to access properties and methods of [LineEdit]. </description> diff --git a/doc/classes/SplitContainer.xml b/doc/classes/SplitContainer.xml index b3f85ce7e1..be49a99988 100644 --- a/doc/classes/SplitContainer.xml +++ b/doc/classes/SplitContainer.xml @@ -10,8 +10,7 @@ </tutorials> <methods> <method name="clamp_split_offset"> - <return type="void"> - </return> + <return type="void" /> <description> Clamps the [member split_offset] value to not go outside the currently possible minimal and maximum values. </description> @@ -30,8 +29,7 @@ </members> <signals> <signal name="dragged"> - <argument index="0" name="offset" type="int"> - </argument> + <argument index="0" name="offset" type="int" /> <description> Emitted when the dragger is dragged by user. </description> diff --git a/doc/classes/SpringArm3D.xml b/doc/classes/SpringArm3D.xml index 3ffdbebae8..50aa3d39b8 100644 --- a/doc/classes/SpringArm3D.xml +++ b/doc/classes/SpringArm3D.xml @@ -13,33 +13,27 @@ </tutorials> <methods> <method name="add_excluded_object"> - <return type="void"> - </return> - <argument index="0" name="RID" type="RID"> - </argument> + <return type="void" /> + <argument index="0" name="RID" type="RID" /> <description> Adds the [PhysicsBody3D] object with the given [RID] to the list of [PhysicsBody3D] objects excluded from the collision check. </description> </method> <method name="clear_excluded_objects"> - <return type="void"> - </return> + <return type="void" /> <description> Clears the list of [PhysicsBody3D] objects excluded from the collision check. </description> </method> <method name="get_hit_length"> - <return type="float"> - </return> + <return type="float" /> <description> Returns the spring arm's current length. </description> </method> <method name="remove_excluded_object"> - <return type="bool"> - </return> - <argument index="0" name="RID" type="RID"> - </argument> + <return type="bool" /> + <argument index="0" name="RID" type="RID" /> <description> Removes the given [RID] from the list of [PhysicsBody3D] objects excluded from the collision check. </description> diff --git a/doc/classes/Sprite2D.xml b/doc/classes/Sprite2D.xml index b419b003bf..0b26fdc055 100644 --- a/doc/classes/Sprite2D.xml +++ b/doc/classes/Sprite2D.xml @@ -11,8 +11,7 @@ </tutorials> <methods> <method name="get_rect" qualifiers="const"> - <return type="Rect2"> - </return> + <return type="Rect2" /> <description> Returns a [Rect2] representing the Sprite2D's boundary in local coordinates. Can be used to detect if the Sprite2D was clicked. Example: [codeblocks] @@ -41,10 +40,8 @@ </description> </method> <method name="is_pixel_opaque" qualifiers="const"> - <return type="bool"> - </return> - <argument index="0" name="pos" type="Vector2"> - </argument> + <return type="bool" /> + <argument index="0" name="pos" type="Vector2" /> <description> Returns [code]true[/code], if the pixel at the given position is opaque and [code]false[/code] in other case. [b]Note:[/b] It also returns [code]false[/code], if the sprite's texture is [code]null[/code] or if the given position is invalid. diff --git a/doc/classes/SpriteBase3D.xml b/doc/classes/SpriteBase3D.xml index 3168e2d848..b723c9f4d4 100644 --- a/doc/classes/SpriteBase3D.xml +++ b/doc/classes/SpriteBase3D.xml @@ -10,35 +10,28 @@ </tutorials> <methods> <method name="generate_triangle_mesh" qualifiers="const"> - <return type="TriangleMesh"> - </return> + <return type="TriangleMesh" /> <description> Returns a [TriangleMesh] with the sprite's vertices following its current configuration (such as its [member axis] and [member pixel_size]). </description> </method> <method name="get_draw_flag" qualifiers="const"> - <return type="bool"> - </return> - <argument index="0" name="flag" type="int" enum="SpriteBase3D.DrawFlags"> - </argument> + <return type="bool" /> + <argument index="0" name="flag" type="int" enum="SpriteBase3D.DrawFlags" /> <description> Returns the value of the specified flag. </description> </method> <method name="get_item_rect" qualifiers="const"> - <return type="Rect2"> - </return> + <return type="Rect2" /> <description> Returns the rectangle representing this sprite. </description> </method> <method name="set_draw_flag"> - <return type="void"> - </return> - <argument index="0" name="flag" type="int" enum="SpriteBase3D.DrawFlags"> - </argument> - <argument index="1" name="enabled" type="bool"> - </argument> + <return type="void" /> + <argument index="0" name="flag" type="int" enum="SpriteBase3D.DrawFlags" /> + <argument index="1" name="enabled" type="bool" /> <description> If [code]true[/code], the specified flag will be enabled. See [enum SpriteBase3D.DrawFlags] for a list of flags. </description> diff --git a/doc/classes/SpriteFrames.xml b/doc/classes/SpriteFrames.xml index 1c7d84c5a2..3bd40ff6f4 100644 --- a/doc/classes/SpriteFrames.xml +++ b/doc/classes/SpriteFrames.xml @@ -11,159 +11,120 @@ </tutorials> <methods> <method name="add_animation"> - <return type="void"> - </return> - <argument index="0" name="anim" type="StringName"> - </argument> + <return type="void" /> + <argument index="0" name="anim" type="StringName" /> <description> Adds a new animation to the library. </description> </method> <method name="add_frame"> - <return type="void"> - </return> - <argument index="0" name="anim" type="StringName"> - </argument> - <argument index="1" name="frame" type="Texture2D"> - </argument> - <argument index="2" name="at_position" type="int" default="-1"> - </argument> + <return type="void" /> + <argument index="0" name="anim" type="StringName" /> + <argument index="1" name="frame" type="Texture2D" /> + <argument index="2" name="at_position" type="int" default="-1" /> <description> Adds a frame to the given animation. </description> </method> <method name="clear"> - <return type="void"> - </return> - <argument index="0" name="anim" type="StringName"> - </argument> + <return type="void" /> + <argument index="0" name="anim" type="StringName" /> <description> Removes all frames from the given animation. </description> </method> <method name="clear_all"> - <return type="void"> - </return> + <return type="void" /> <description> Removes all animations. A "default" animation will be created. </description> </method> <method name="get_animation_loop" qualifiers="const"> - <return type="bool"> - </return> - <argument index="0" name="anim" type="StringName"> - </argument> + <return type="bool" /> + <argument index="0" name="anim" type="StringName" /> <description> Returns [code]true[/code] if the given animation is configured to loop when it finishes playing. Otherwise, returns [code]false[/code]. </description> </method> <method name="get_animation_names" qualifiers="const"> - <return type="PackedStringArray"> - </return> + <return type="PackedStringArray" /> <description> Returns an array containing the names associated to each animation. Values are placed in alphabetical order. </description> </method> <method name="get_animation_speed" qualifiers="const"> - <return type="float"> - </return> - <argument index="0" name="anim" type="StringName"> - </argument> + <return type="float" /> + <argument index="0" name="anim" type="StringName" /> <description> The animation's speed in frames per second. </description> </method> <method name="get_frame" qualifiers="const"> - <return type="Texture2D"> - </return> - <argument index="0" name="anim" type="StringName"> - </argument> - <argument index="1" name="idx" type="int"> - </argument> + <return type="Texture2D" /> + <argument index="0" name="anim" type="StringName" /> + <argument index="1" name="idx" type="int" /> <description> Returns the animation's selected frame. </description> </method> <method name="get_frame_count" qualifiers="const"> - <return type="int"> - </return> - <argument index="0" name="anim" type="StringName"> - </argument> + <return type="int" /> + <argument index="0" name="anim" type="StringName" /> <description> Returns the number of frames in the animation. </description> </method> <method name="has_animation" qualifiers="const"> - <return type="bool"> - </return> - <argument index="0" name="anim" type="StringName"> - </argument> + <return type="bool" /> + <argument index="0" name="anim" type="StringName" /> <description> If [code]true[/code], the named animation exists. </description> </method> <method name="remove_animation"> - <return type="void"> - </return> - <argument index="0" name="anim" type="StringName"> - </argument> + <return type="void" /> + <argument index="0" name="anim" type="StringName" /> <description> Removes the given animation. </description> </method> <method name="remove_frame"> - <return type="void"> - </return> - <argument index="0" name="anim" type="StringName"> - </argument> - <argument index="1" name="idx" type="int"> - </argument> + <return type="void" /> + <argument index="0" name="anim" type="StringName" /> + <argument index="1" name="idx" type="int" /> <description> Removes the animation's selected frame. </description> </method> <method name="rename_animation"> - <return type="void"> - </return> - <argument index="0" name="anim" type="StringName"> - </argument> - <argument index="1" name="newname" type="StringName"> - </argument> + <return type="void" /> + <argument index="0" name="anim" type="StringName" /> + <argument index="1" name="newname" type="StringName" /> <description> Changes the animation's name to [code]newname[/code]. </description> </method> <method name="set_animation_loop"> - <return type="void"> - </return> - <argument index="0" name="anim" type="StringName"> - </argument> - <argument index="1" name="loop" type="bool"> - </argument> + <return type="void" /> + <argument index="0" name="anim" type="StringName" /> + <argument index="1" name="loop" type="bool" /> <description> If [code]true[/code], the animation will loop. </description> </method> <method name="set_animation_speed"> - <return type="void"> - </return> - <argument index="0" name="anim" type="StringName"> - </argument> - <argument index="1" name="speed" type="float"> - </argument> + <return type="void" /> + <argument index="0" name="anim" type="StringName" /> + <argument index="1" name="speed" type="float" /> <description> The animation's speed in frames per second. </description> </method> <method name="set_frame"> - <return type="void"> - </return> - <argument index="0" name="anim" type="StringName"> - </argument> - <argument index="1" name="idx" type="int"> - </argument> - <argument index="2" name="txt" type="Texture2D"> - </argument> + <return type="void" /> + <argument index="0" name="anim" type="StringName" /> + <argument index="1" name="idx" type="int" /> + <argument index="2" name="txt" type="Texture2D" /> <description> Sets the texture of the given frame. </description> diff --git a/doc/classes/StaticBody2D.xml b/doc/classes/StaticBody2D.xml index 85915a53fe..326bf58e22 100644 --- a/doc/classes/StaticBody2D.xml +++ b/doc/classes/StaticBody2D.xml @@ -29,6 +29,9 @@ The physics material override for the body. If a material is assigned to this property, it will be used instead of any other physics material, such as an inherited one. </member> + <member name="sync_to_physics" type="bool" setter="set_sync_to_physics" getter="is_sync_to_physics_enabled" default="false"> + If [code]true[/code] and [member kinematic_motion] is enabled, the body's movement will be synchronized to the physics frame. This is useful when animating movement via [AnimationPlayer], for example on moving platforms. Do [b]not[/b] use together with [method PhysicsBody2D.move_and_collide]. + </member> </members> <constants> </constants> diff --git a/doc/classes/StaticBody3D.xml b/doc/classes/StaticBody3D.xml index f83d440f10..69c123002f 100644 --- a/doc/classes/StaticBody3D.xml +++ b/doc/classes/StaticBody3D.xml @@ -32,6 +32,9 @@ The physics material override for the body. If a material is assigned to this property, it will be used instead of any other physics material, such as an inherited one. </member> + <member name="sync_to_physics" type="bool" setter="set_sync_to_physics" getter="is_sync_to_physics_enabled" default="false"> + If [code]true[/code] and [member kinematic_motion] is enabled, the body's movement will be synchronized to the physics frame. This is useful when animating movement via [AnimationPlayer], for example on moving platforms. Do [b]not[/b] use together with [method PhysicsBody3D.move_and_collide]. + </member> </members> <constants> </constants> diff --git a/doc/classes/StreamPeer.xml b/doc/classes/StreamPeer.xml index 5367a572f1..e3d77d22c5 100644 --- a/doc/classes/StreamPeer.xml +++ b/doc/classes/StreamPeer.xml @@ -10,205 +10,166 @@ </tutorials> <methods> <method name="get_16"> - <return type="int"> - </return> + <return type="int" /> <description> Gets a signed 16-bit value from the stream. </description> </method> <method name="get_32"> - <return type="int"> - </return> + <return type="int" /> <description> Gets a signed 32-bit value from the stream. </description> </method> <method name="get_64"> - <return type="int"> - </return> + <return type="int" /> <description> Gets a signed 64-bit value from the stream. </description> </method> <method name="get_8"> - <return type="int"> - </return> + <return type="int" /> <description> Gets a signed byte from the stream. </description> </method> <method name="get_available_bytes" qualifiers="const"> - <return type="int"> - </return> + <return type="int" /> <description> Returns the amount of bytes this [StreamPeer] has available. </description> </method> <method name="get_data"> - <return type="Array"> - </return> - <argument index="0" name="bytes" type="int"> - </argument> + <return type="Array" /> + <argument index="0" name="bytes" type="int" /> <description> Returns a chunk data with the received bytes. The amount of bytes to be received can be requested in the [code]bytes[/code] argument. If not enough bytes are available, the function will block until the desired amount is received. This function returns two values, an [enum @GlobalScope.Error] code and a data array. </description> </method> <method name="get_double"> - <return type="float"> - </return> + <return type="float" /> <description> Gets a double-precision float from the stream. </description> </method> <method name="get_float"> - <return type="float"> - </return> + <return type="float" /> <description> Gets a single-precision float from the stream. </description> </method> <method name="get_partial_data"> - <return type="Array"> - </return> - <argument index="0" name="bytes" type="int"> - </argument> + <return type="Array" /> + <argument index="0" name="bytes" type="int" /> <description> Returns a chunk data with the received bytes. The amount of bytes to be received can be requested in the "bytes" argument. If not enough bytes are available, the function will return how many were actually received. This function returns two values, an [enum @GlobalScope.Error] code, and a data array. </description> </method> <method name="get_string"> - <return type="String"> - </return> - <argument index="0" name="bytes" type="int" default="-1"> - </argument> + <return type="String" /> + <argument index="0" name="bytes" type="int" default="-1" /> <description> Gets a string with byte-length [code]bytes[/code] from the stream. If [code]bytes[/code] is negative (default) the length will be read from the stream using the reverse process of [method put_string]. </description> </method> <method name="get_u16"> - <return type="int"> - </return> + <return type="int" /> <description> Gets an unsigned 16-bit value from the stream. </description> </method> <method name="get_u32"> - <return type="int"> - </return> + <return type="int" /> <description> Gets an unsigned 32-bit value from the stream. </description> </method> <method name="get_u64"> - <return type="int"> - </return> + <return type="int" /> <description> Gets an unsigned 64-bit value from the stream. </description> </method> <method name="get_u8"> - <return type="int"> - </return> + <return type="int" /> <description> Gets an unsigned byte from the stream. </description> </method> <method name="get_utf8_string"> - <return type="String"> - </return> - <argument index="0" name="bytes" type="int" default="-1"> - </argument> + <return type="String" /> + <argument index="0" name="bytes" type="int" default="-1" /> <description> Gets an UTF-8 string with byte-length [code]bytes[/code] from the stream (this decodes the string sent as UTF-8). If [code]bytes[/code] is negative (default) the length will be read from the stream using the reverse process of [method put_utf8_string]. </description> </method> <method name="get_var"> - <return type="Variant"> - </return> - <argument index="0" name="allow_objects" type="bool" default="false"> - </argument> + <return type="Variant" /> + <argument index="0" name="allow_objects" type="bool" default="false" /> <description> Gets a Variant from the stream. If [code]allow_objects[/code] is [code]true[/code], decoding objects is allowed. [b]Warning:[/b] Deserialized objects can contain code which gets executed. Do not use this option if the serialized object comes from untrusted sources to avoid potential security threats such as remote code execution. </description> </method> <method name="put_16"> - <return type="void"> - </return> - <argument index="0" name="value" type="int"> - </argument> + <return type="void" /> + <argument index="0" name="value" type="int" /> <description> Puts a signed 16-bit value into the stream. </description> </method> <method name="put_32"> - <return type="void"> - </return> - <argument index="0" name="value" type="int"> - </argument> + <return type="void" /> + <argument index="0" name="value" type="int" /> <description> Puts a signed 32-bit value into the stream. </description> </method> <method name="put_64"> - <return type="void"> - </return> - <argument index="0" name="value" type="int"> - </argument> + <return type="void" /> + <argument index="0" name="value" type="int" /> <description> Puts a signed 64-bit value into the stream. </description> </method> <method name="put_8"> - <return type="void"> - </return> - <argument index="0" name="value" type="int"> - </argument> + <return type="void" /> + <argument index="0" name="value" type="int" /> <description> Puts a signed byte into the stream. </description> </method> <method name="put_data"> - <return type="int" enum="Error"> - </return> - <argument index="0" name="data" type="PackedByteArray"> - </argument> + <return type="int" enum="Error" /> + <argument index="0" name="data" type="PackedByteArray" /> <description> Sends a chunk of data through the connection, blocking if necessary until the data is done sending. This function returns an [enum @GlobalScope.Error] code. </description> </method> <method name="put_double"> - <return type="void"> - </return> - <argument index="0" name="value" type="float"> - </argument> + <return type="void" /> + <argument index="0" name="value" type="float" /> <description> Puts a double-precision float into the stream. </description> </method> <method name="put_float"> - <return type="void"> - </return> - <argument index="0" name="value" type="float"> - </argument> + <return type="void" /> + <argument index="0" name="value" type="float" /> <description> Puts a single-precision float into the stream. </description> </method> <method name="put_partial_data"> - <return type="Array"> - </return> - <argument index="0" name="data" type="PackedByteArray"> - </argument> + <return type="Array" /> + <argument index="0" name="data" type="PackedByteArray" /> <description> Sends a chunk of data through the connection. If all the data could not be sent at once, only part of it will. This function returns two values, an [enum @GlobalScope.Error] code and an integer, describing how much data was actually sent. </description> </method> <method name="put_string"> - <return type="void"> - </return> - <argument index="0" name="value" type="String"> - </argument> + <return type="void" /> + <argument index="0" name="value" type="String" /> <description> Puts a zero-terminated ASCII string into the stream prepended by a 32-bit unsigned integer representing its size. Note: To put an ASCII string without prepending its size, you can use [method put_data]: @@ -223,46 +184,36 @@ </description> </method> <method name="put_u16"> - <return type="void"> - </return> - <argument index="0" name="value" type="int"> - </argument> + <return type="void" /> + <argument index="0" name="value" type="int" /> <description> Puts an unsigned 16-bit value into the stream. </description> </method> <method name="put_u32"> - <return type="void"> - </return> - <argument index="0" name="value" type="int"> - </argument> + <return type="void" /> + <argument index="0" name="value" type="int" /> <description> Puts an unsigned 32-bit value into the stream. </description> </method> <method name="put_u64"> - <return type="void"> - </return> - <argument index="0" name="value" type="int"> - </argument> + <return type="void" /> + <argument index="0" name="value" type="int" /> <description> Puts an unsigned 64-bit value into the stream. </description> </method> <method name="put_u8"> - <return type="void"> - </return> - <argument index="0" name="value" type="int"> - </argument> + <return type="void" /> + <argument index="0" name="value" type="int" /> <description> Puts an unsigned byte into the stream. </description> </method> <method name="put_utf8_string"> - <return type="void"> - </return> - <argument index="0" name="value" type="String"> - </argument> + <return type="void" /> + <argument index="0" name="value" type="String" /> <description> Puts a zero-terminated UTF-8 string into the stream prepended by a 32 bits unsigned integer representing its size. Note: To put an UTF-8 string without prepending its size, you can use [method put_data]: @@ -277,12 +228,9 @@ </description> </method> <method name="put_var"> - <return type="void"> - </return> - <argument index="0" name="value" type="Variant"> - </argument> - <argument index="1" name="full_objects" type="bool" default="false"> - </argument> + <return type="void" /> + <argument index="0" name="value" type="Variant" /> + <argument index="1" name="full_objects" type="bool" default="false" /> <description> Puts a Variant into the stream. If [code]full_objects[/code] is [code]true[/code] encoding objects is allowed (and can potentially include code). </description> diff --git a/doc/classes/StreamPeerBuffer.xml b/doc/classes/StreamPeerBuffer.xml index 03a150b90f..62476ca166 100644 --- a/doc/classes/StreamPeerBuffer.xml +++ b/doc/classes/StreamPeerBuffer.xml @@ -8,42 +8,34 @@ </tutorials> <methods> <method name="clear"> - <return type="void"> - </return> + <return type="void" /> <description> </description> </method> <method name="duplicate" qualifiers="const"> - <return type="StreamPeerBuffer"> - </return> + <return type="StreamPeerBuffer" /> <description> </description> </method> <method name="get_position" qualifiers="const"> - <return type="int"> - </return> + <return type="int" /> <description> </description> </method> <method name="get_size" qualifiers="const"> - <return type="int"> - </return> + <return type="int" /> <description> </description> </method> <method name="resize"> - <return type="void"> - </return> - <argument index="0" name="size" type="int"> - </argument> + <return type="void" /> + <argument index="0" name="size" type="int" /> <description> </description> </method> <method name="seek"> - <return type="void"> - </return> - <argument index="0" name="position" type="int"> - </argument> + <return type="void" /> + <argument index="0" name="position" type="int" /> <description> </description> </method> diff --git a/doc/classes/StreamPeerSSL.xml b/doc/classes/StreamPeerSSL.xml index 6a06c0b3f4..034168c2a0 100644 --- a/doc/classes/StreamPeerSSL.xml +++ b/doc/classes/StreamPeerSSL.xml @@ -11,53 +11,40 @@ </tutorials> <methods> <method name="accept_stream"> - <return type="int" enum="Error"> - </return> - <argument index="0" name="stream" type="StreamPeer"> - </argument> - <argument index="1" name="private_key" type="CryptoKey"> - </argument> - <argument index="2" name="certificate" type="X509Certificate"> - </argument> - <argument index="3" name="chain" type="X509Certificate" default="null"> - </argument> + <return type="int" enum="Error" /> + <argument index="0" name="stream" type="StreamPeer" /> + <argument index="1" name="private_key" type="CryptoKey" /> + <argument index="2" name="certificate" type="X509Certificate" /> + <argument index="3" name="chain" type="X509Certificate" default="null" /> <description> Accepts a peer connection as a server using the given [code]private_key[/code] and providing the given [code]certificate[/code] to the client. You can pass the optional [code]chain[/code] parameter to provide additional CA chain information along with the certificate. </description> </method> <method name="connect_to_stream"> - <return type="int" enum="Error"> - </return> - <argument index="0" name="stream" type="StreamPeer"> - </argument> - <argument index="1" name="validate_certs" type="bool" default="false"> - </argument> - <argument index="2" name="for_hostname" type="String" default=""""> - </argument> - <argument index="3" name="valid_certificate" type="X509Certificate" default="null"> - </argument> + <return type="int" enum="Error" /> + <argument index="0" name="stream" type="StreamPeer" /> + <argument index="1" name="validate_certs" type="bool" default="false" /> + <argument index="2" name="for_hostname" type="String" default="""" /> + <argument index="3" name="valid_certificate" type="X509Certificate" default="null" /> <description> Connects to a peer using an underlying [StreamPeer] [code]stream[/code]. If [code]validate_certs[/code] is [code]true[/code], [StreamPeerSSL] will validate that the certificate presented by the peer matches the [code]for_hostname[/code]. [b]Note:[/b] Specifying a custom [code]valid_certificate[/code] is not supported in HTML5 exports due to browsers restrictions. </description> </method> <method name="disconnect_from_stream"> - <return type="void"> - </return> + <return type="void" /> <description> Disconnects from host. </description> </method> <method name="get_status" qualifiers="const"> - <return type="int" enum="StreamPeerSSL.Status"> - </return> + <return type="int" enum="StreamPeerSSL.Status" /> <description> Returns the status of the connection. See [enum Status] for values. </description> </method> <method name="poll"> - <return type="void"> - </return> + <return type="void" /> <description> Poll the connection to check for incoming bytes. Call this right before [method StreamPeer.get_available_bytes] for it to work properly. </description> diff --git a/doc/classes/StreamPeerTCP.xml b/doc/classes/StreamPeerTCP.xml index 7b7c1d7426..bba48e7275 100644 --- a/doc/classes/StreamPeerTCP.xml +++ b/doc/classes/StreamPeerTCP.xml @@ -10,75 +10,61 @@ </tutorials> <methods> <method name="bind"> - <return type="int" enum="Error"> - </return> - <argument index="0" name="port" type="int"> - </argument> - <argument index="1" name="host" type="String" default=""*""> - </argument> + <return type="int" enum="Error" /> + <argument index="0" name="port" type="int" /> + <argument index="1" name="host" type="String" default=""*"" /> <description> Opens the TCP socket, and binds it to the specified local address. This method is generally not needed, and only used to force the subsequent call to [method connect_to_host] to use the specified [code]host[/code] and [code]port[/code] as source address. This can be desired in some NAT punchthrough techniques, or when forcing the source network interface. </description> </method> <method name="connect_to_host"> - <return type="int" enum="Error"> - </return> - <argument index="0" name="host" type="String"> - </argument> - <argument index="1" name="port" type="int"> - </argument> + <return type="int" enum="Error" /> + <argument index="0" name="host" type="String" /> + <argument index="1" name="port" type="int" /> <description> Connects to the specified [code]host:port[/code] pair. A hostname will be resolved if valid. Returns [constant OK] on success. </description> </method> <method name="disconnect_from_host"> - <return type="void"> - </return> + <return type="void" /> <description> Disconnects from host. </description> </method> <method name="get_connected_host" qualifiers="const"> - <return type="String"> - </return> + <return type="String" /> <description> Returns the IP of this peer. </description> </method> <method name="get_connected_port" qualifiers="const"> - <return type="int"> - </return> + <return type="int" /> <description> Returns the port of this peer. </description> </method> <method name="get_local_port" qualifiers="const"> - <return type="int"> - </return> + <return type="int" /> <description> Returns the local port to which this peer is bound. </description> </method> <method name="get_status"> - <return type="int" enum="StreamPeerTCP.Status"> - </return> + <return type="int" enum="StreamPeerTCP.Status" /> <description> Returns the status of the connection, see [enum Status]. </description> </method> <method name="is_connected_to_host" qualifiers="const"> - <return type="bool"> - </return> + <return type="bool" /> <description> Returns [code]true[/code] if this peer is currently connected or is connecting to a host, [code]false[/code] otherwise. </description> </method> <method name="set_no_delay"> - <return type="void"> - </return> - <argument index="0" name="enabled" type="bool"> - </argument> + <return type="void" /> + <argument index="0" name="enabled" type="bool" /> <description> If [code]enabled[/code] is [code]true[/code], packets will be sent immediately. If [code]enabled[/code] is [code]false[/code] (the default), packet transfers will be delayed and combined using [url=https://en.wikipedia.org/wiki/Nagle%27s_algorithm]Nagle's algorithm[/url]. [b]Note:[/b] It's recommended to leave this disabled for applications that send large packets or need to transfer a lot of data, as enabling this can decrease the total available bandwidth. diff --git a/doc/classes/StreamTexture2D.xml b/doc/classes/StreamTexture2D.xml index 214298475c..7b6c594786 100644 --- a/doc/classes/StreamTexture2D.xml +++ b/doc/classes/StreamTexture2D.xml @@ -10,10 +10,8 @@ </tutorials> <methods> <method name="load"> - <return type="int" enum="Error"> - </return> - <argument index="0" name="path" type="String"> - </argument> + <return type="int" enum="Error" /> + <argument index="0" name="path" type="String" /> <description> Loads the texture from the given path. </description> diff --git a/doc/classes/StreamTexture3D.xml b/doc/classes/StreamTexture3D.xml index 7054a4ee99..4b2eb16ba3 100644 --- a/doc/classes/StreamTexture3D.xml +++ b/doc/classes/StreamTexture3D.xml @@ -8,10 +8,8 @@ </tutorials> <methods> <method name="load"> - <return type="int" enum="Error"> - </return> - <argument index="0" name="path" type="String"> - </argument> + <return type="int" enum="Error" /> + <argument index="0" name="path" type="String" /> <description> </description> </method> diff --git a/doc/classes/StreamTextureLayered.xml b/doc/classes/StreamTextureLayered.xml index 10a7aae976..888fb339db 100644 --- a/doc/classes/StreamTextureLayered.xml +++ b/doc/classes/StreamTextureLayered.xml @@ -8,10 +8,8 @@ </tutorials> <methods> <method name="load"> - <return type="int" enum="Error"> - </return> - <argument index="0" name="path" type="String"> - </argument> + <return type="int" enum="Error" /> + <argument index="0" name="path" type="String" /> <description> </description> </method> diff --git a/doc/classes/String.xml b/doc/classes/String.xml index 3bf05e7c92..027ae2000a 100644 --- a/doc/classes/String.xml +++ b/doc/classes/String.xml @@ -11,58 +11,47 @@ </tutorials> <methods> <method name="String" qualifiers="constructor"> - <return type="String"> - </return> + <return type="String" /> <description> Constructs an empty [String] ([code]""[/code]). </description> </method> <method name="String" qualifiers="constructor"> - <return type="String"> - </return> - <argument index="0" name="from" type="String"> - </argument> + <return type="String" /> + <argument index="0" name="from" type="String" /> <description> Constructs a [String] as a copy of the given [String]. </description> </method> <method name="String" qualifiers="constructor"> - <return type="String"> - </return> - <argument index="0" name="from" type="NodePath"> - </argument> + <return type="String" /> + <argument index="0" name="from" type="NodePath" /> <description> Constructs a new String from the given [NodePath]. </description> </method> <method name="String" qualifiers="constructor"> - <return type="String"> - </return> - <argument index="0" name="from" type="StringName"> - </argument> + <return type="String" /> + <argument index="0" name="from" type="StringName" /> <description> Constructs a new String from the given [StringName]. </description> </method> <method name="begins_with" qualifiers="const"> - <return type="bool"> - </return> - <argument index="0" name="text" type="String"> - </argument> + <return type="bool" /> + <argument index="0" name="text" type="String" /> <description> Returns [code]true[/code] if the string begins with the given string. </description> </method> <method name="bigrams" qualifiers="const"> - <return type="PackedStringArray"> - </return> + <return type="PackedStringArray" /> <description> Returns the bigrams (pairs of consecutive letters) of this string. </description> </method> <method name="bin_to_int" qualifiers="const"> - <return type="int"> - </return> + <return type="int" /> <description> Converts a string containing a binary number into an integer. Binary strings can either be prefixed with [code]0b[/code] or not, and they can also start with a [code]-[/code] before the optional prefix. [codeblocks] @@ -78,32 +67,27 @@ </description> </method> <method name="c_escape" qualifiers="const"> - <return type="String"> - </return> + <return type="String" /> <description> Returns a copy of the string with special characters escaped using the C language standard. </description> </method> <method name="c_unescape" qualifiers="const"> - <return type="String"> - </return> + <return type="String" /> <description> Returns a copy of the string with escaped characters replaced by their meanings. Supported escape sequences are [code]\'[/code], [code]\"[/code], [code]\?[/code], [code]\\[/code], [code]\a[/code], [code]\b[/code], [code]\f[/code], [code]\n[/code], [code]\r[/code], [code]\t[/code], [code]\v[/code]. [b]Note:[/b] Unlike the GDScript parser, this method doesn't support the [code]\uXXXX[/code] escape sequence. </description> </method> <method name="capitalize" qualifiers="const"> - <return type="String"> - </return> + <return type="String" /> <description> Changes the case of some letters. Replaces underscores with spaces, adds spaces before in-word uppercase characters, converts all letters to lowercase, then capitalizes the first letter and every letter following a space character. For [code]capitalize camelCase mixed_with_underscores[/code], it will return [code]Capitalize Camel Case Mixed With Underscores[/code]. </description> </method> <method name="casecmp_to" qualifiers="const"> - <return type="int"> - </return> - <argument index="0" name="to" type="String"> - </argument> + <return type="int" /> + <argument index="0" name="to" type="String" /> <description> Performs a case-sensitive comparison to another string. Returns [code]-1[/code] if less than, [code]1[/code] if greater than, or [code]0[/code] if equal. "less than" or "greater than" are determined by the [url=https://en.wikipedia.org/wiki/List_of_Unicode_characters]Unicode code points[/code] of each string, which roughly matches the alphabetical order. [b]Behavior with different string lengths:[/b] Returns [code]1[/code] if the "base" string is longer than the [code]to[/code] string or [code]-1[/code] if the "base" string is shorter than the [code]to[/code] string. Keep in mind this length is determined by the number of Unicode codepoints, [i]not[/i] the actual visible characters. @@ -112,62 +96,46 @@ </description> </method> <method name="chr" qualifiers="static"> - <return type="String"> - </return> - <argument index="0" name="char" type="int"> - </argument> + <return type="String" /> + <argument index="0" name="char" type="int" /> <description> </description> </method> <method name="count" qualifiers="const"> - <return type="int"> - </return> - <argument index="0" name="what" type="String"> - </argument> - <argument index="1" name="from" type="int" default="0"> - </argument> - <argument index="2" name="to" type="int" default="0"> - </argument> + <return type="int" /> + <argument index="0" name="what" type="String" /> + <argument index="1" name="from" type="int" default="0" /> + <argument index="2" name="to" type="int" default="0" /> <description> Returns the number of occurrences of substring [code]what[/code] between [code]from[/code] and [code]to[/code] positions. If [code]from[/code] and [code]to[/code] equals 0 the whole string will be used. If only [code]to[/code] equals 0 the remained substring will be used. </description> </method> <method name="countn" qualifiers="const"> - <return type="int"> - </return> - <argument index="0" name="what" type="String"> - </argument> - <argument index="1" name="from" type="int" default="0"> - </argument> - <argument index="2" name="to" type="int" default="0"> - </argument> + <return type="int" /> + <argument index="0" name="what" type="String" /> + <argument index="1" name="from" type="int" default="0" /> + <argument index="2" name="to" type="int" default="0" /> <description> Returns the number of occurrences of substring [code]what[/code] (ignoring case) between [code]from[/code] and [code]to[/code] positions. If [code]from[/code] and [code]to[/code] equals 0 the whole string will be used. If only [code]to[/code] equals 0 the remained substring will be used. </description> </method> <method name="dedent" qualifiers="const"> - <return type="String"> - </return> + <return type="String" /> <description> Returns a copy of the string with indentation (leading tabs and spaces) removed. </description> </method> <method name="ends_with" qualifiers="const"> - <return type="bool"> - </return> - <argument index="0" name="text" type="String"> - </argument> + <return type="bool" /> + <argument index="0" name="text" type="String" /> <description> Returns [code]true[/code] if the string ends with the given string. </description> </method> <method name="find" qualifiers="const"> - <return type="int"> - </return> - <argument index="0" name="what" type="String"> - </argument> - <argument index="1" name="from" type="int" default="0"> - </argument> + <return type="int" /> + <argument index="0" name="what" type="String" /> + <argument index="1" name="from" type="int" default="0" /> <description> Returns the index of the [b]first[/b] case-sensitive occurrence of the specified string in this instance, or [code]-1[/code]. Optionally, the starting search index can be specified, continuing to the end of the string. [b]Note:[/b] If you just want to know whether a string contains a substring, use the [code]in[/code] operator as follows: @@ -183,65 +151,53 @@ </description> </method> <method name="findn" qualifiers="const"> - <return type="int"> - </return> - <argument index="0" name="what" type="String"> - </argument> - <argument index="1" name="from" type="int" default="0"> - </argument> + <return type="int" /> + <argument index="0" name="what" type="String" /> + <argument index="1" name="from" type="int" default="0" /> <description> Returns the index of the [b]first[/b] case-insensitive occurrence of the specified string in this instance, or [code]-1[/code]. Optionally, the starting search index can be specified, continuing to the end of the string. </description> </method> <method name="format" qualifiers="const"> - <return type="String"> - </return> - <argument index="0" name="values" type="Variant"> - </argument> - <argument index="1" name="placeholder" type="String" default=""{_}""> - </argument> + <return type="String" /> + <argument index="0" name="values" type="Variant" /> + <argument index="1" name="placeholder" type="String" default=""{_}"" /> <description> Formats the string by replacing all occurrences of [code]placeholder[/code] with [code]values[/code]. </description> </method> <method name="get_base_dir" qualifiers="const"> - <return type="String"> - </return> + <return type="String" /> <description> If the string is a valid file path, returns the base directory name. </description> </method> <method name="get_basename" qualifiers="const"> - <return type="String"> - </return> + <return type="String" /> <description> If the string is a valid file path, returns the full file path without the extension. </description> </method> <method name="get_extension" qualifiers="const"> - <return type="String"> - </return> + <return type="String" /> <description> If the string is a valid file path, returns the extension. </description> </method> <method name="get_file" qualifiers="const"> - <return type="String"> - </return> + <return type="String" /> <description> If the string is a valid file path, returns the filename. </description> </method> <method name="hash" qualifiers="const"> - <return type="int"> - </return> + <return type="int" /> <description> Hashes the string and returns a 32-bit integer. </description> </method> <method name="hex_to_int" qualifiers="const"> - <return type="int"> - </return> + <return type="int" /> <description> Converts a string containing a hexadecimal number into an integer. Hexadecimal strings can either be prefixed with [code]0x[/code] or not, and they can also start with a [code]-[/code] before the optional prefix. [codeblocks] @@ -257,120 +213,98 @@ </description> </method> <method name="humanize_size" qualifiers="static"> - <return type="String"> - </return> - <argument index="0" name="size" type="int"> - </argument> + <return type="String" /> + <argument index="0" name="size" type="int" /> <description> </description> </method> <method name="insert" qualifiers="const"> - <return type="String"> - </return> - <argument index="0" name="position" type="int"> - </argument> - <argument index="1" name="what" type="String"> - </argument> + <return type="String" /> + <argument index="0" name="position" type="int" /> + <argument index="1" name="what" type="String" /> <description> Returns a copy of the string with the substring [code]what[/code] inserted at the given position. </description> </method> <method name="is_absolute_path" qualifiers="const"> - <return type="bool"> - </return> + <return type="bool" /> <description> If the string is a path to a file or directory, returns [code]true[/code] if the path is absolute. </description> </method> <method name="is_empty" qualifiers="const"> - <return type="bool"> - </return> + <return type="bool" /> <description> Returns [code]true[/code] if the length of the string equals [code]0[/code]. </description> </method> <method name="is_rel_path" qualifiers="const"> - <return type="bool"> - </return> + <return type="bool" /> <description> If the string is a path to a file or directory, returns [code]true[/code] if the path is relative. </description> </method> <method name="is_subsequence_of" qualifiers="const"> - <return type="bool"> - </return> - <argument index="0" name="text" type="String"> - </argument> + <return type="bool" /> + <argument index="0" name="text" type="String" /> <description> Returns [code]true[/code] if this string is a subsequence of the given string. </description> </method> <method name="is_subsequence_ofi" qualifiers="const"> - <return type="bool"> - </return> - <argument index="0" name="text" type="String"> - </argument> + <return type="bool" /> + <argument index="0" name="text" type="String" /> <description> Returns [code]true[/code] if this string is a subsequence of the given string, without considering case. </description> </method> <method name="is_valid_filename" qualifiers="const"> - <return type="bool"> - </return> + <return type="bool" /> <description> Returns [code]true[/code] if this string is free from characters that aren't allowed in file names, those being: [code]: / \ ? * " | % < >[/code] </description> </method> <method name="is_valid_float" qualifiers="const"> - <return type="bool"> - </return> + <return type="bool" /> <description> Returns [code]true[/code] if this string contains a valid float. </description> </method> <method name="is_valid_hex_number" qualifiers="const"> - <return type="bool"> - </return> - <argument index="0" name="with_prefix" type="bool" default="false"> - </argument> + <return type="bool" /> + <argument index="0" name="with_prefix" type="bool" default="false" /> <description> Returns [code]true[/code] if this string contains a valid hexadecimal number. If [code]with_prefix[/code] is [code]true[/code], then a validity of the hexadecimal number is determined by [code]0x[/code] prefix, for instance: [code]0xDEADC0DE[/code]. </description> </method> <method name="is_valid_html_color" qualifiers="const"> - <return type="bool"> - </return> + <return type="bool" /> <description> Returns [code]true[/code] if this string contains a valid color in hexadecimal HTML notation. Other HTML notations such as named colors or [code]hsl()[/code] colors aren't considered valid by this method and will return [code]false[/code]. </description> </method> <method name="is_valid_identifier" qualifiers="const"> - <return type="bool"> - </return> + <return type="bool" /> <description> Returns [code]true[/code] if this string is a valid identifier. A valid identifier may contain only letters, digits and underscores ([code]_[/code]) and the first character may not be a digit. </description> </method> <method name="is_valid_int" qualifiers="const"> - <return type="bool"> - </return> + <return type="bool" /> <description> Returns [code]true[/code] if this string contains a valid integer. </description> </method> <method name="is_valid_ip_address" qualifiers="const"> - <return type="bool"> - </return> + <return type="bool" /> <description> Returns [code]true[/code] if this string contains only a well-formatted IPv4 or IPv6 address. This method considers [url=https://en.wikipedia.org/wiki/Reserved_IP_addresses]reserved IP addresses[/url] such as [code]0.0.0.0[/code] as valid. </description> </method> <method name="join" qualifiers="const"> - <return type="String"> - </return> - <argument index="0" name="parts" type="PackedStringArray"> - </argument> + <return type="String" /> + <argument index="0" name="parts" type="PackedStringArray" /> <description> Return a [String] which is the concatenation of the [code]parts[/code]. The separator between elements is the string providing this method. Example: @@ -385,17 +319,14 @@ </description> </method> <method name="json_escape" qualifiers="const"> - <return type="String"> - </return> + <return type="String" /> <description> Returns a copy of the string with special characters escaped using the JSON standard. </description> </method> <method name="left" qualifiers="const"> - <return type="String"> - </return> - <argument index="0" name="position" type="int"> - </argument> + <return type="String" /> + <argument index="0" name="position" type="int" /> <description> Returns a number of characters from the left of the string. If negative [code]position[/code] is used, the characters are counted downwards from [String]'s length. Examples: @@ -406,70 +337,56 @@ </description> </method> <method name="length" qualifiers="const"> - <return type="int"> - </return> + <return type="int" /> <description> Returns the string's amount of characters. </description> </method> <method name="lpad" qualifiers="const"> - <return type="String"> - </return> - <argument index="0" name="min_length" type="int"> - </argument> - <argument index="1" name="character" type="String" default="" ""> - </argument> + <return type="String" /> + <argument index="0" name="min_length" type="int" /> + <argument index="1" name="character" type="String" default="" "" /> <description> Formats a string to be at least [code]min_length[/code] long by adding [code]character[/code]s to the left of the string. </description> </method> <method name="lstrip" qualifiers="const"> - <return type="String"> - </return> - <argument index="0" name="chars" type="String"> - </argument> + <return type="String" /> + <argument index="0" name="chars" type="String" /> <description> Returns a copy of the string with characters removed from the left. The [code]chars[/code] argument is a string specifying the set of characters to be removed. [b]Note:[/b] The [code]chars[/code] is not a prefix. See [method trim_prefix] method that will remove a single prefix string rather than a set of characters. </description> </method> <method name="match" qualifiers="const"> - <return type="bool"> - </return> - <argument index="0" name="expr" type="String"> - </argument> + <return type="bool" /> + <argument index="0" name="expr" type="String" /> <description> Does a simple case-sensitive expression match, where [code]"*"[/code] matches zero or more arbitrary characters and [code]"?"[/code] matches any single character except a period ([code]"."[/code]). </description> </method> <method name="matchn" qualifiers="const"> - <return type="bool"> - </return> - <argument index="0" name="expr" type="String"> - </argument> + <return type="bool" /> + <argument index="0" name="expr" type="String" /> <description> Does a simple case-insensitive expression match, where [code]"*"[/code] matches zero or more arbitrary characters and [code]"?"[/code] matches any single character except a period ([code]"."[/code]). </description> </method> <method name="md5_buffer" qualifiers="const"> - <return type="PackedByteArray"> - </return> + <return type="PackedByteArray" /> <description> Returns the MD5 hash of the string as an array of bytes. </description> </method> <method name="md5_text" qualifiers="const"> - <return type="String"> - </return> + <return type="String" /> <description> Returns the MD5 hash of the string as a string. </description> </method> <method name="naturalnocasecmp_to" qualifiers="const"> - <return type="int"> - </return> - <argument index="0" name="to" type="String"> - </argument> + <return type="int" /> + <argument index="0" name="to" type="String" /> <description> Performs a case-insensitive [i]natural order[/i] comparison to another string. Returns [code]-1[/code] if less than, [code]1[/code] if greater than, or [code]0[/code] if equal. "less than" or "greater than" are determined by the [url=https://en.wikipedia.org/wiki/List_of_Unicode_characters]Unicode code points[/code] of each string, which roughly matches the alphabetical order. Internally, lowercase characters will be converted to uppercase during the comparison. When used for sorting, natural order comparison will order suites of numbers as expected by most people. If you sort the numbers from 1 to 10 using natural order, you will get [code][1, 2, 3, ...][/code] instead of [code][1, 10, 2, 3, ...][/code]. @@ -479,10 +396,8 @@ </description> </method> <method name="nocasecmp_to" qualifiers="const"> - <return type="int"> - </return> - <argument index="0" name="to" type="String"> - </argument> + <return type="int" /> + <argument index="0" name="to" type="String" /> <description> Performs a case-insensitive comparison to another string. Returns [code]-1[/code] if less than, [code]1[/code] if greater than, or [code]0[/code] if equal. "less than" or "greater than" are determined by the [url=https://en.wikipedia.org/wiki/List_of_Unicode_characters]Unicode code points[/code] of each string, which roughly matches the alphabetical order. Internally, lowercase characters will be converted to uppercase during the comparison. [b]Behavior with different string lengths:[/b] Returns [code]1[/code] if the "base" string is longer than the [code]to[/code] string or [code]-1[/code] if the "base" string is shorter than the [code]to[/code] string. Keep in mind this length is determined by the number of Unicode codepoints, [i]not[/i] the actual visible characters. @@ -491,188 +406,141 @@ </description> </method> <method name="num" qualifiers="static"> - <return type="String"> - </return> - <argument index="0" name="number" type="float"> - </argument> - <argument index="1" name="decimals" type="int" default="-1"> - </argument> + <return type="String" /> + <argument index="0" name="number" type="float" /> + <argument index="1" name="decimals" type="int" default="-1" /> <description> </description> </method> <method name="num_scientific" qualifiers="static"> - <return type="String"> - </return> - <argument index="0" name="number" type="float"> - </argument> + <return type="String" /> + <argument index="0" name="number" type="float" /> <description> </description> </method> <method name="operator !=" qualifiers="operator"> - <return type="bool"> - </return> - <argument index="0" name="right" type="String"> - </argument> + <return type="bool" /> + <argument index="0" name="right" type="String" /> <description> </description> </method> <method name="operator !=" qualifiers="operator"> - <return type="bool"> - </return> - <argument index="0" name="right" type="StringName"> - </argument> + <return type="bool" /> + <argument index="0" name="right" type="StringName" /> <description> </description> </method> <method name="operator %" qualifiers="operator"> - <return type="String"> - </return> - <argument index="0" name="right" type="Variant"> - </argument> + <return type="String" /> + <argument index="0" name="right" type="Variant" /> <description> </description> </method> <method name="operator +" qualifiers="operator"> - <return type="String"> - </return> - <argument index="0" name="right" type="String"> - </argument> + <return type="String" /> + <argument index="0" name="right" type="String" /> <description> </description> </method> <method name="operator <" qualifiers="operator"> - <return type="bool"> - </return> - <argument index="0" name="right" type="String"> - </argument> + <return type="bool" /> + <argument index="0" name="right" type="String" /> <description> </description> </method> <method name="operator <=" qualifiers="operator"> - <return type="bool"> - </return> - <argument index="0" name="right" type="String"> - </argument> + <return type="bool" /> + <argument index="0" name="right" type="String" /> <description> </description> </method> <method name="operator ==" qualifiers="operator"> - <return type="bool"> - </return> - <argument index="0" name="right" type="String"> - </argument> + <return type="bool" /> + <argument index="0" name="right" type="String" /> <description> </description> </method> <method name="operator ==" qualifiers="operator"> - <return type="bool"> - </return> - <argument index="0" name="right" type="StringName"> - </argument> + <return type="bool" /> + <argument index="0" name="right" type="StringName" /> <description> </description> </method> <method name="operator >" qualifiers="operator"> - <return type="bool"> - </return> - <argument index="0" name="right" type="String"> - </argument> + <return type="bool" /> + <argument index="0" name="right" type="String" /> <description> </description> </method> <method name="operator >=" qualifiers="operator"> - <return type="bool"> - </return> - <argument index="0" name="right" type="String"> - </argument> + <return type="bool" /> + <argument index="0" name="right" type="String" /> <description> </description> </method> <method name="pad_decimals" qualifiers="const"> - <return type="String"> - </return> - <argument index="0" name="digits" type="int"> - </argument> + <return type="String" /> + <argument index="0" name="digits" type="int" /> <description> Formats a number to have an exact number of [code]digits[/code] after the decimal point. </description> </method> <method name="pad_zeros" qualifiers="const"> - <return type="String"> - </return> - <argument index="0" name="digits" type="int"> - </argument> + <return type="String" /> + <argument index="0" name="digits" type="int" /> <description> Formats a number to have an exact number of [code]digits[/code] before the decimal point. </description> </method> <method name="plus_file" qualifiers="const"> - <return type="String"> - </return> - <argument index="0" name="file" type="String"> - </argument> + <return type="String" /> + <argument index="0" name="file" type="String" /> <description> If the string is a path, this concatenates [code]file[/code] at the end of the string as a subpath. E.g. [code]"this/is".plus_file("path") == "this/is/path"[/code]. </description> </method> <method name="repeat" qualifiers="const"> - <return type="String"> - </return> - <argument index="0" name="count" type="int"> - </argument> + <return type="String" /> + <argument index="0" name="count" type="int" /> <description> Returns original string repeated a number of times. The number of repetitions is given by the argument. </description> </method> <method name="replace" qualifiers="const"> - <return type="String"> - </return> - <argument index="0" name="what" type="String"> - </argument> - <argument index="1" name="forwhat" type="String"> - </argument> + <return type="String" /> + <argument index="0" name="what" type="String" /> + <argument index="1" name="forwhat" type="String" /> <description> Replaces occurrences of a case-sensitive substring with the given one inside the string. </description> </method> <method name="replacen" qualifiers="const"> - <return type="String"> - </return> - <argument index="0" name="what" type="String"> - </argument> - <argument index="1" name="forwhat" type="String"> - </argument> + <return type="String" /> + <argument index="0" name="what" type="String" /> + <argument index="1" name="forwhat" type="String" /> <description> Replaces occurrences of a case-insensitive substring with the given one inside the string. </description> </method> <method name="rfind" qualifiers="const"> - <return type="int"> - </return> - <argument index="0" name="what" type="String"> - </argument> - <argument index="1" name="from" type="int" default="-1"> - </argument> + <return type="int" /> + <argument index="0" name="what" type="String" /> + <argument index="1" name="from" type="int" default="-1" /> <description> Returns the index of the [b]last[/b] case-sensitive occurrence of the specified string in this instance, or [code]-1[/code]. Optionally, the starting search index can be specified, continuing to the beginning of the string. </description> </method> <method name="rfindn" qualifiers="const"> - <return type="int"> - </return> - <argument index="0" name="what" type="String"> - </argument> - <argument index="1" name="from" type="int" default="-1"> - </argument> + <return type="int" /> + <argument index="0" name="what" type="String" /> + <argument index="1" name="from" type="int" default="-1" /> <description> Returns the index of the [b]last[/b] case-insensitive occurrence of the specified string in this instance, or [code]-1[/code]. Optionally, the starting search index can be specified, continuing to the beginning of the string. </description> </method> <method name="right" qualifiers="const"> - <return type="String"> - </return> - <argument index="0" name="position" type="int"> - </argument> + <return type="String" /> + <argument index="0" name="position" type="int" /> <description> Returns a number of characters from the right of the string. If negative [code]position[/code] is used, the characters are counted downwards from [String]'s length. Examples: @@ -683,25 +551,18 @@ </description> </method> <method name="rpad" qualifiers="const"> - <return type="String"> - </return> - <argument index="0" name="min_length" type="int"> - </argument> - <argument index="1" name="character" type="String" default="" ""> - </argument> + <return type="String" /> + <argument index="0" name="min_length" type="int" /> + <argument index="1" name="character" type="String" default="" "" /> <description> Formats a string to be at least [code]min_length[/code] long by adding [code]character[/code]s to the right of the string. </description> </method> <method name="rsplit" qualifiers="const"> - <return type="PackedStringArray"> - </return> - <argument index="0" name="delimiter" type="String"> - </argument> - <argument index="1" name="allow_empty" type="bool" default="true"> - </argument> - <argument index="2" name="maxsplit" type="int" default="0"> - </argument> + <return type="PackedStringArray" /> + <argument index="0" name="delimiter" type="String" /> + <argument index="1" name="allow_empty" type="bool" default="true" /> + <argument index="2" name="maxsplit" type="int" default="0" /> <description> Splits the string by a [code]delimiter[/code] string and returns an array of the substrings, starting from right. The splits in the returned array are sorted in the same order as the original string, from left to right. @@ -722,61 +583,49 @@ </description> </method> <method name="rstrip" qualifiers="const"> - <return type="String"> - </return> - <argument index="0" name="chars" type="String"> - </argument> + <return type="String" /> + <argument index="0" name="chars" type="String" /> <description> Returns a copy of the string with characters removed from the right. The [code]chars[/code] argument is a string specifying the set of characters to be removed. [b]Note:[/b] The [code]chars[/code] is not a suffix. See [method trim_suffix] method that will remove a single suffix string rather than a set of characters. </description> </method> <method name="sha1_buffer" qualifiers="const"> - <return type="PackedByteArray"> - </return> + <return type="PackedByteArray" /> <description> Returns the SHA-1 hash of the string as an array of bytes. </description> </method> <method name="sha1_text" qualifiers="const"> - <return type="String"> - </return> + <return type="String" /> <description> Returns the SHA-1 hash of the string as a string. </description> </method> <method name="sha256_buffer" qualifiers="const"> - <return type="PackedByteArray"> - </return> + <return type="PackedByteArray" /> <description> Returns the SHA-256 hash of the string as an array of bytes. </description> </method> <method name="sha256_text" qualifiers="const"> - <return type="String"> - </return> + <return type="String" /> <description> Returns the SHA-256 hash of the string as a string. </description> </method> <method name="similarity" qualifiers="const"> - <return type="float"> - </return> - <argument index="0" name="text" type="String"> - </argument> + <return type="float" /> + <argument index="0" name="text" type="String" /> <description> Returns the similarity index of the text compared to this string. 1 means totally similar and 0 means totally dissimilar. </description> </method> <method name="split" qualifiers="const"> - <return type="PackedStringArray"> - </return> - <argument index="0" name="delimiter" type="String"> - </argument> - <argument index="1" name="allow_empty" type="bool" default="true"> - </argument> - <argument index="2" name="maxsplit" type="int" default="0"> - </argument> + <return type="PackedStringArray" /> + <argument index="0" name="delimiter" type="String" /> + <argument index="1" name="allow_empty" type="bool" default="true" /> + <argument index="2" name="maxsplit" type="int" default="0" /> <description> Splits the string by a [code]delimiter[/code] string and returns an array of the substrings. The [code]delimiter[/code] can be of any length. If [code]maxsplit[/code] is specified, it defines the number of splits to do from the left up to [code]maxsplit[/code]. The default value of [code]0[/code] means that all items are split. @@ -800,132 +649,107 @@ </description> </method> <method name="split_floats" qualifiers="const"> - <return type="PackedFloat32Array"> - </return> - <argument index="0" name="delimiter" type="String"> - </argument> - <argument index="1" name="allow_empty" type="bool" default="true"> - </argument> + <return type="PackedFloat32Array" /> + <argument index="0" name="delimiter" type="String" /> + <argument index="1" name="allow_empty" type="bool" default="true" /> <description> Splits the string in floats by using a delimiter string and returns an array of the substrings. For example, [code]"1,2.5,3"[/code] will return [code][1,2.5,3][/code] if split by [code]","[/code]. </description> </method> <method name="strip_edges" qualifiers="const"> - <return type="String"> - </return> - <argument index="0" name="left" type="bool" default="true"> - </argument> - <argument index="1" name="right" type="bool" default="true"> - </argument> + <return type="String" /> + <argument index="0" name="left" type="bool" default="true" /> + <argument index="1" name="right" type="bool" default="true" /> <description> Returns a copy of the string stripped of any non-printable character (including tabulations, spaces and line breaks) at the beginning and the end. The optional arguments are used to toggle stripping on the left and right edges respectively. </description> </method> <method name="strip_escapes" qualifiers="const"> - <return type="String"> - </return> + <return type="String" /> <description> Returns a copy of the string stripped of any escape character. These include all non-printable control characters of the first page of the ASCII table (< 32), such as tabulation ([code]\t[/code] in C) and newline ([code]\n[/code] and [code]\r[/code]) characters, but not spaces. </description> </method> <method name="substr" qualifiers="const"> - <return type="String"> - </return> - <argument index="0" name="from" type="int"> - </argument> - <argument index="1" name="len" type="int" default="-1"> - </argument> + <return type="String" /> + <argument index="0" name="from" type="int" /> + <argument index="1" name="len" type="int" default="-1" /> <description> Returns part of the string from the position [code]from[/code] with length [code]len[/code]. Argument [code]len[/code] is optional and using [code]-1[/code] will return remaining characters from given position. </description> </method> <method name="to_ascii_buffer" qualifiers="const"> - <return type="PackedByteArray"> - </return> + <return type="PackedByteArray" /> <description> Converts the String (which is a character array) to ASCII/Latin-1 encoded [PackedByteArray] (which is an array of bytes). The conversion is faster compared to [method to_utf8_buffer], as this method assumes that all the characters in the String are ASCII/Latin-1 characters, unsupported characters are replaced with spaces. </description> </method> <method name="to_float" qualifiers="const"> - <return type="float"> - </return> + <return type="float" /> <description> Converts a string containing a decimal number into a [code]float[/code]. </description> </method> <method name="to_int" qualifiers="const"> - <return type="int"> - </return> + <return type="int" /> <description> Converts a string containing an integer number into an [code]int[/code]. </description> </method> <method name="to_lower" qualifiers="const"> - <return type="String"> - </return> + <return type="String" /> <description> Returns the string converted to lowercase. </description> </method> <method name="to_upper" qualifiers="const"> - <return type="String"> - </return> + <return type="String" /> <description> Returns the string converted to uppercase. </description> </method> <method name="to_utf16_buffer" qualifiers="const"> - <return type="PackedByteArray"> - </return> + <return type="PackedByteArray" /> <description> Converts the String (which is an array of characters) to UTF-16 encoded [PackedByteArray] (which is an array of bytes). </description> </method> <method name="to_utf32_buffer" qualifiers="const"> - <return type="PackedByteArray"> - </return> + <return type="PackedByteArray" /> <description> Converts the String (which is an array of characters) to UTF-32 encoded [PackedByteArray] (which is an array of bytes). </description> </method> <method name="to_utf8_buffer" qualifiers="const"> - <return type="PackedByteArray"> - </return> + <return type="PackedByteArray" /> <description> Converts the String (which is an array of characters) to UTF-8 encode [PackedByteArray] (which is an array of bytes). The conversion is a bit slower than [method to_ascii_buffer], but supports all UTF-8 characters. Therefore, you should prefer this function over [method to_ascii_buffer]. </description> </method> <method name="trim_prefix" qualifiers="const"> - <return type="String"> - </return> - <argument index="0" name="prefix" type="String"> - </argument> + <return type="String" /> + <argument index="0" name="prefix" type="String" /> <description> Removes a given string from the start if it starts with it or leaves the string unchanged. </description> </method> <method name="trim_suffix" qualifiers="const"> - <return type="String"> - </return> - <argument index="0" name="suffix" type="String"> - </argument> + <return type="String" /> + <argument index="0" name="suffix" type="String" /> <description> Removes a given string from the end if it ends with it or leaves the string unchanged. </description> </method> <method name="unicode_at" qualifiers="const"> - <return type="int"> - </return> - <argument index="0" name="at" type="int"> - </argument> + <return type="int" /> + <argument index="0" name="at" type="int" /> <description> Returns the character code at position [code]at[/code]. </description> </method> <method name="uri_decode" qualifiers="const"> - <return type="String"> - </return> + <return type="String" /> <description> Decodes a string in URL encoded format. This is meant to decode parameters in a URL when receiving an HTTP request. [codeblocks] @@ -939,8 +763,7 @@ </description> </method> <method name="uri_encode" qualifiers="const"> - <return type="String"> - </return> + <return type="String" /> <description> Encodes a string to URL friendly format. This is meant to encode parameters in a URL when sending an HTTP request. [codeblocks] @@ -954,24 +777,20 @@ </description> </method> <method name="validate_node_name" qualifiers="const"> - <return type="String"> - </return> + <return type="String" /> <description> Removes any characters from the string that are prohibited in [Node] names ([code].[/code] [code]:[/code] [code]@[/code] [code]/[/code] [code]"[/code]). </description> </method> <method name="xml_escape" qualifiers="const"> - <return type="String"> - </return> - <argument index="0" name="escape_quotes" type="bool" default="false"> - </argument> + <return type="String" /> + <argument index="0" name="escape_quotes" type="bool" default="false" /> <description> Returns a copy of the string with special characters escaped using the XML standard. If [code]escape_quotes[/code] is [code]true[/code], the single quote ([code]'[/code]) and double quote ([code]"[/code]) characters are also escaped. </description> </method> <method name="xml_unescape" qualifiers="const"> - <return type="String"> - </return> + <return type="String" /> <description> Returns a copy of the string with escaped characters replaced by their meanings according to the XML standard. </description> diff --git a/doc/classes/StringName.xml b/doc/classes/StringName.xml index be32f6a234..4c2619e782 100644 --- a/doc/classes/StringName.xml +++ b/doc/classes/StringName.xml @@ -10,59 +10,46 @@ </tutorials> <methods> <method name="StringName" qualifiers="constructor"> - <return type="StringName"> - </return> + <return type="StringName" /> <description> Constructs an empty [StringName]. </description> </method> <method name="StringName" qualifiers="constructor"> - <return type="StringName"> - </return> - <argument index="0" name="from" type="StringName"> - </argument> + <return type="StringName" /> + <argument index="0" name="from" type="StringName" /> <description> Constructs a [StringName] as a copy of the given [StringName]. </description> </method> <method name="StringName" qualifiers="constructor"> - <return type="StringName"> - </return> - <argument index="0" name="from" type="String"> - </argument> + <return type="StringName" /> + <argument index="0" name="from" type="String" /> <description> Creates a new [StringName] from the given [String]. </description> </method> <method name="operator !=" qualifiers="operator"> - <return type="bool"> - </return> - <argument index="0" name="right" type="String"> - </argument> + <return type="bool" /> + <argument index="0" name="right" type="String" /> <description> </description> </method> <method name="operator !=" qualifiers="operator"> - <return type="bool"> - </return> - <argument index="0" name="right" type="StringName"> - </argument> + <return type="bool" /> + <argument index="0" name="right" type="StringName" /> <description> </description> </method> <method name="operator ==" qualifiers="operator"> - <return type="bool"> - </return> - <argument index="0" name="right" type="String"> - </argument> + <return type="bool" /> + <argument index="0" name="right" type="String" /> <description> </description> </method> <method name="operator ==" qualifiers="operator"> - <return type="bool"> - </return> - <argument index="0" name="right" type="StringName"> - </argument> + <return type="bool" /> + <argument index="0" name="right" type="StringName" /> <description> </description> </method> diff --git a/doc/classes/StyleBox.xml b/doc/classes/StyleBox.xml index a01dfbd4b8..024524251d 100644 --- a/doc/classes/StyleBox.xml +++ b/doc/classes/StyleBox.xml @@ -11,82 +11,65 @@ </tutorials> <methods> <method name="draw" qualifiers="const"> - <return type="void"> - </return> - <argument index="0" name="canvas_item" type="RID"> - </argument> - <argument index="1" name="rect" type="Rect2"> - </argument> + <return type="void" /> + <argument index="0" name="canvas_item" type="RID" /> + <argument index="1" name="rect" type="Rect2" /> <description> Draws this stylebox using a [CanvasItem] with given [RID]. You can get a [RID] value using [method Object.get_instance_id] on a [CanvasItem]-derived node. </description> </method> <method name="get_center_size" qualifiers="const"> - <return type="Vector2"> - </return> + <return type="Vector2" /> <description> Returns the size of this [StyleBox] without the margins. </description> </method> <method name="get_current_item_drawn" qualifiers="const"> - <return type="CanvasItem"> - </return> + <return type="CanvasItem" /> <description> Returns the [CanvasItem] that handles its [constant CanvasItem.NOTIFICATION_DRAW] or [method CanvasItem._draw] callback at this moment. </description> </method> <method name="get_default_margin" qualifiers="const"> - <return type="float"> - </return> - <argument index="0" name="margin" type="int" enum="Side"> - </argument> + <return type="float" /> + <argument index="0" name="margin" type="int" enum="Side" /> <description> Returns the default margin of the specified [enum Side]. </description> </method> <method name="get_margin" qualifiers="const"> - <return type="float"> - </return> - <argument index="0" name="margin" type="int" enum="Side"> - </argument> + <return type="float" /> + <argument index="0" name="margin" type="int" enum="Side" /> <description> Returns the content margin offset for the specified [enum Side]. Positive values reduce size inwards, unlike [Control]'s margin values. </description> </method> <method name="get_minimum_size" qualifiers="const"> - <return type="Vector2"> - </return> + <return type="Vector2" /> <description> Returns the minimum size that this stylebox can be shrunk to. </description> </method> <method name="get_offset" qualifiers="const"> - <return type="Vector2"> - </return> + <return type="Vector2" /> <description> Returns the "offset" of a stylebox. This helper function returns a value equivalent to [code]Vector2(style.get_margin(MARGIN_LEFT), style.get_margin(MARGIN_TOP))[/code]. </description> </method> <method name="set_default_margin"> - <return type="void"> - </return> - <argument index="0" name="margin" type="int" enum="Side"> - </argument> - <argument index="1" name="offset" type="float"> - </argument> + <return type="void" /> + <argument index="0" name="margin" type="int" enum="Side" /> + <argument index="1" name="offset" type="float" /> <description> Sets the default value of the specified [enum Side] to [code]offset[/code] pixels. </description> </method> <method name="test_mask" qualifiers="const"> - <return type="bool"> - </return> - <argument index="0" name="point" type="Vector2"> - </argument> - <argument index="1" name="rect" type="Rect2"> - </argument> + <return type="bool" /> + <argument index="0" name="point" type="Vector2" /> + <argument index="1" name="rect" type="Rect2" /> <description> Test a position in a rectangle, return whether it passes the mask test. </description> diff --git a/doc/classes/StyleBoxFlat.xml b/doc/classes/StyleBoxFlat.xml index 9e02fb57c3..540b007341 100644 --- a/doc/classes/StyleBoxFlat.xml +++ b/doc/classes/StyleBoxFlat.xml @@ -25,125 +25,93 @@ </tutorials> <methods> <method name="get_border_width" qualifiers="const"> - <return type="int"> - </return> - <argument index="0" name="margin" type="int" enum="Side"> - </argument> + <return type="int" /> + <argument index="0" name="margin" type="int" enum="Side" /> <description> Returns the specified [enum Side]'s border width. </description> </method> <method name="get_border_width_min" qualifiers="const"> - <return type="int"> - </return> + <return type="int" /> <description> Returns the smallest border width out of all four borders. </description> </method> <method name="get_corner_radius" qualifiers="const"> - <return type="int"> - </return> - <argument index="0" name="corner" type="int" enum="Corner"> - </argument> + <return type="int" /> + <argument index="0" name="corner" type="int" enum="Corner" /> <description> Returns the given [code]corner[/code]'s radius. See [enum Corner] for possible values. </description> </method> <method name="get_expand_margin" qualifiers="const"> - <return type="float"> - </return> - <argument index="0" name="margin" type="int" enum="Side"> - </argument> + <return type="float" /> + <argument index="0" name="margin" type="int" enum="Side" /> <description> Returns the size of the specified [enum Side]'s expand margin. </description> </method> <method name="set_border_width"> - <return type="void"> - </return> - <argument index="0" name="margin" type="int" enum="Side"> - </argument> - <argument index="1" name="width" type="int"> - </argument> + <return type="void" /> + <argument index="0" name="margin" type="int" enum="Side" /> + <argument index="1" name="width" type="int" /> <description> Sets the specified [enum Side]'s border width to [code]width[/code] pixels. </description> </method> <method name="set_border_width_all"> - <return type="void"> - </return> - <argument index="0" name="width" type="int"> - </argument> + <return type="void" /> + <argument index="0" name="width" type="int" /> <description> Sets the border width to [code]width[/code] pixels for all sides. </description> </method> <method name="set_corner_radius"> - <return type="void"> - </return> - <argument index="0" name="corner" type="int" enum="Corner"> - </argument> - <argument index="1" name="radius" type="int"> - </argument> + <return type="void" /> + <argument index="0" name="corner" type="int" enum="Corner" /> + <argument index="1" name="radius" type="int" /> <description> Sets the corner radius to [code]radius[/code] pixels for the given [code]corner[/code]. See [enum Corner] for possible values. </description> </method> <method name="set_corner_radius_all"> - <return type="void"> - </return> - <argument index="0" name="radius" type="int"> - </argument> + <return type="void" /> + <argument index="0" name="radius" type="int" /> <description> Sets the corner radius to [code]radius[/code] pixels for all corners. </description> </method> <method name="set_corner_radius_individual"> - <return type="void"> - </return> - <argument index="0" name="radius_top_left" type="int"> - </argument> - <argument index="1" name="radius_top_right" type="int"> - </argument> - <argument index="2" name="radius_bottom_right" type="int"> - </argument> - <argument index="3" name="radius_bottom_left" type="int"> - </argument> + <return type="void" /> + <argument index="0" name="radius_top_left" type="int" /> + <argument index="1" name="radius_top_right" type="int" /> + <argument index="2" name="radius_bottom_right" type="int" /> + <argument index="3" name="radius_bottom_left" type="int" /> <description> Sets the corner radius for each corner to [code]radius_top_left[/code], [code]radius_top_right[/code], [code]radius_bottom_right[/code], and [code]radius_bottom_left[/code] pixels. </description> </method> <method name="set_expand_margin"> - <return type="void"> - </return> - <argument index="0" name="margin" type="int" enum="Side"> - </argument> - <argument index="1" name="size" type="float"> - </argument> + <return type="void" /> + <argument index="0" name="margin" type="int" enum="Side" /> + <argument index="1" name="size" type="float" /> <description> Sets the expand margin to [code]size[/code] pixels for the specified [enum Side]. </description> </method> <method name="set_expand_margin_all"> - <return type="void"> - </return> - <argument index="0" name="size" type="float"> - </argument> + <return type="void" /> + <argument index="0" name="size" type="float" /> <description> Sets the expand margin to [code]size[/code] pixels for all margins. </description> </method> <method name="set_expand_margin_individual"> - <return type="void"> - </return> - <argument index="0" name="size_left" type="float"> - </argument> - <argument index="1" name="size_top" type="float"> - </argument> - <argument index="2" name="size_right" type="float"> - </argument> - <argument index="3" name="size_bottom" type="float"> - </argument> + <return type="void" /> + <argument index="0" name="size_left" type="float" /> + <argument index="1" name="size_top" type="float" /> + <argument index="2" name="size_right" type="float" /> + <argument index="3" name="size_bottom" type="float" /> <description> Sets the expand margin for each margin to [code]size_left[/code], [code]size_top[/code], [code]size_right[/code], and [code]size_bottom[/code] pixels. </description> diff --git a/doc/classes/StyleBoxTexture.xml b/doc/classes/StyleBoxTexture.xml index be14048126..92939dfbf5 100644 --- a/doc/classes/StyleBoxTexture.xml +++ b/doc/classes/StyleBoxTexture.xml @@ -10,65 +10,48 @@ </tutorials> <methods> <method name="get_expand_margin_size" qualifiers="const"> - <return type="float"> - </return> - <argument index="0" name="margin" type="int" enum="Side"> - </argument> + <return type="float" /> + <argument index="0" name="margin" type="int" enum="Side" /> <description> Returns the expand margin size of the specified [enum Side]. </description> </method> <method name="get_margin_size" qualifiers="const"> - <return type="float"> - </return> - <argument index="0" name="margin" type="int" enum="Side"> - </argument> + <return type="float" /> + <argument index="0" name="margin" type="int" enum="Side" /> <description> Returns the margin size of the specified [enum Side]. </description> </method> <method name="set_expand_margin_all"> - <return type="void"> - </return> - <argument index="0" name="size" type="float"> - </argument> + <return type="void" /> + <argument index="0" name="size" type="float" /> <description> Sets the expand margin to [code]size[/code] pixels for all margins. </description> </method> <method name="set_expand_margin_individual"> - <return type="void"> - </return> - <argument index="0" name="size_left" type="float"> - </argument> - <argument index="1" name="size_top" type="float"> - </argument> - <argument index="2" name="size_right" type="float"> - </argument> - <argument index="3" name="size_bottom" type="float"> - </argument> + <return type="void" /> + <argument index="0" name="size_left" type="float" /> + <argument index="1" name="size_top" type="float" /> + <argument index="2" name="size_right" type="float" /> + <argument index="3" name="size_bottom" type="float" /> <description> Sets the expand margin for each margin to [code]size_left[/code], [code]size_top[/code], [code]size_right[/code], and [code]size_bottom[/code] pixels. </description> </method> <method name="set_expand_margin_size"> - <return type="void"> - </return> - <argument index="0" name="margin" type="int" enum="Side"> - </argument> - <argument index="1" name="size" type="float"> - </argument> + <return type="void" /> + <argument index="0" name="margin" type="int" enum="Side" /> + <argument index="1" name="size" type="float" /> <description> Sets the expand margin to [code]size[/code] pixels for the specified [enum Side]. </description> </method> <method name="set_margin_size"> - <return type="void"> - </return> - <argument index="0" name="margin" type="int" enum="Side"> - </argument> - <argument index="1" name="size" type="float"> - </argument> + <return type="void" /> + <argument index="0" name="margin" type="int" enum="Side" /> + <argument index="1" name="size" type="float" /> <description> Sets the margin to [code]size[/code] pixels for the specified [enum Side]. </description> diff --git a/doc/classes/SurfaceTool.xml b/doc/classes/SurfaceTool.xml index a8b836ff0c..e5b03eb4d4 100644 --- a/doc/classes/SurfaceTool.xml +++ b/doc/classes/SurfaceTool.xml @@ -32,294 +32,225 @@ </tutorials> <methods> <method name="add_index"> - <return type="void"> - </return> - <argument index="0" name="index" type="int"> - </argument> + <return type="void" /> + <argument index="0" name="index" type="int" /> <description> Adds an index to index array if you are using indexed vertices. Does not need to be called before adding vertices. </description> </method> <method name="add_triangle_fan"> - <return type="void"> - </return> - <argument index="0" name="vertices" type="PackedVector3Array"> - </argument> - <argument index="1" name="uvs" type="PackedVector2Array" default="PackedVector2Array()"> - </argument> - <argument index="2" name="colors" type="PackedColorArray" default="PackedColorArray()"> - </argument> - <argument index="3" name="uv2s" type="PackedVector2Array" default="PackedVector2Array()"> - </argument> - <argument index="4" name="normals" type="PackedVector3Array" default="PackedVector3Array()"> - </argument> - <argument index="5" name="tangents" type="Array" default="[]"> - </argument> + <return type="void" /> + <argument index="0" name="vertices" type="PackedVector3Array" /> + <argument index="1" name="uvs" type="PackedVector2Array" default="PackedVector2Array()" /> + <argument index="2" name="colors" type="PackedColorArray" default="PackedColorArray()" /> + <argument index="3" name="uv2s" type="PackedVector2Array" default="PackedVector2Array()" /> + <argument index="4" name="normals" type="PackedVector3Array" default="PackedVector3Array()" /> + <argument index="5" name="tangents" type="Array" default="[]" /> <description> Inserts a triangle fan made of array data into [Mesh] being constructed. Requires the primitive type be set to [constant Mesh.PRIMITIVE_TRIANGLES]. </description> </method> <method name="add_vertex"> - <return type="void"> - </return> - <argument index="0" name="vertex" type="Vector3"> - </argument> + <return type="void" /> + <argument index="0" name="vertex" type="Vector3" /> <description> Specifies the position of current vertex. Should be called after specifying other vertex properties (e.g. Color, UV). </description> </method> <method name="append_from"> - <return type="void"> - </return> - <argument index="0" name="existing" type="Mesh"> - </argument> - <argument index="1" name="surface" type="int"> - </argument> - <argument index="2" name="transform" type="Transform3D"> - </argument> + <return type="void" /> + <argument index="0" name="existing" type="Mesh" /> + <argument index="1" name="surface" type="int" /> + <argument index="2" name="transform" type="Transform3D" /> <description> Append vertices from a given [Mesh] surface onto the current vertex array with specified [Transform3D]. </description> </method> <method name="begin"> - <return type="void"> - </return> - <argument index="0" name="primitive" type="int" enum="Mesh.PrimitiveType"> - </argument> + <return type="void" /> + <argument index="0" name="primitive" type="int" enum="Mesh.PrimitiveType" /> <description> Called before adding any vertices. Takes the primitive type as an argument (e.g. [constant Mesh.PRIMITIVE_TRIANGLES]). </description> </method> <method name="clear"> - <return type="void"> - </return> + <return type="void" /> <description> Clear all information passed into the surface tool so far. </description> </method> <method name="commit"> - <return type="ArrayMesh"> - </return> - <argument index="0" name="existing" type="ArrayMesh" default="null"> - </argument> - <argument index="1" name="flags" type="int" default="0"> - </argument> + <return type="ArrayMesh" /> + <argument index="0" name="existing" type="ArrayMesh" default="null" /> + <argument index="1" name="flags" type="int" default="0" /> <description> Returns a constructed [ArrayMesh] from current information passed in. If an existing [ArrayMesh] is passed in as an argument, will add an extra surface to the existing [ArrayMesh]. [b]FIXME:[/b] Document possible values for [code]flags[/code], it changed in 4.0. Likely some combinations of [enum Mesh.ArrayFormat]. </description> </method> <method name="commit_to_arrays"> - <return type="Array"> - </return> + <return type="Array" /> <description> Commits the data to the same format used by [method ArrayMesh.add_surface_from_arrays]. This way you can further process the mesh data using the [ArrayMesh] API. </description> </method> <method name="create_from"> - <return type="void"> - </return> - <argument index="0" name="existing" type="Mesh"> - </argument> - <argument index="1" name="surface" type="int"> - </argument> + <return type="void" /> + <argument index="0" name="existing" type="Mesh" /> + <argument index="1" name="surface" type="int" /> <description> Creates a vertex array from an existing [Mesh]. </description> </method> <method name="create_from_blend_shape"> - <return type="void"> - </return> - <argument index="0" name="existing" type="Mesh"> - </argument> - <argument index="1" name="surface" type="int"> - </argument> - <argument index="2" name="blend_shape" type="String"> - </argument> + <return type="void" /> + <argument index="0" name="existing" type="Mesh" /> + <argument index="1" name="surface" type="int" /> + <argument index="2" name="blend_shape" type="String" /> <description> Creates a vertex array from the specified blend shape of an existing [Mesh]. This can be used to extract a specific pose from a blend shape. </description> </method> <method name="deindex"> - <return type="void"> - </return> + <return type="void" /> <description> Removes the index array by expanding the vertex array. </description> </method> <method name="generate_lod"> - <return type="PackedInt32Array"> - </return> - <argument index="0" name="nd_threshold" type="float"> - </argument> - <argument index="1" name="target_index_count" type="int" default="3"> - </argument> + <return type="PackedInt32Array" /> + <argument index="0" name="nd_threshold" type="float" /> + <argument index="1" name="target_index_count" type="int" default="3" /> <description> </description> </method> <method name="generate_normals"> - <return type="void"> - </return> - <argument index="0" name="flip" type="bool" default="false"> - </argument> + <return type="void" /> + <argument index="0" name="flip" type="bool" default="false" /> <description> Generates normals from vertices so you do not have to do it manually. If [code]flip[/code] 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]. [b]Note:[/b] [method generate_normals] only works if the primitive type to be set to [constant Mesh.PRIMITIVE_TRIANGLES]. </description> </method> <method name="generate_tangents"> - <return type="void"> - </return> + <return type="void" /> <description> Generates a tangent vector for each vertex. Requires that each vertex have UVs and normals set already. </description> </method> <method name="get_custom_format" qualifiers="const"> - <return type="int" enum="SurfaceTool.CustomFormat"> - </return> - <argument index="0" name="index" type="int"> - </argument> + <return type="int" enum="SurfaceTool.CustomFormat" /> + <argument index="0" name="index" type="int" /> <description> </description> </method> <method name="get_max_axis_length" qualifiers="const"> - <return type="float"> - </return> + <return type="float" /> <description> </description> </method> <method name="get_primitive" qualifiers="const"> - <return type="int" enum="Mesh.PrimitiveType"> - </return> + <return type="int" enum="Mesh.PrimitiveType" /> <description> </description> </method> <method name="get_skin_weight_count" qualifiers="const"> - <return type="int" enum="SurfaceTool.SkinWeightCount"> - </return> + <return type="int" enum="SurfaceTool.SkinWeightCount" /> <description> </description> </method> <method name="index"> - <return type="void"> - </return> + <return type="void" /> <description> Shrinks the vertex array by creating an index array. This can improve performance by avoiding vertex reuse. </description> </method> <method name="optimize_indices_for_cache"> - <return type="void"> - </return> + <return type="void" /> <description> </description> </method> <method name="set_bones"> - <return type="void"> - </return> - <argument index="0" name="bones" type="PackedInt32Array"> - </argument> + <return type="void" /> + <argument index="0" name="bones" type="PackedInt32Array" /> <description> Specifies an array of bones to use for the [i]next[/i] vertex. [code]bones[/code] must contain 4 integers. </description> </method> <method name="set_color"> - <return type="void"> - </return> - <argument index="0" name="color" type="Color"> - </argument> + <return type="void" /> + <argument index="0" name="color" type="Color" /> <description> Specifies a [Color] to use for the [i]next[/i] vertex. If every vertex needs to have this information set and you fail to submit it for the first vertex, this information may not be used at all. [b]Note:[/b] The material must have [member BaseMaterial3D.vertex_color_use_as_albedo] enabled for the vertex color to be visible. </description> </method> <method name="set_custom"> - <return type="void"> - </return> - <argument index="0" name="index" type="int"> - </argument> - <argument index="1" name="custom" type="Color"> - </argument> + <return type="void" /> + <argument index="0" name="index" type="int" /> + <argument index="1" name="custom" type="Color" /> <description> </description> </method> <method name="set_custom_format"> - <return type="void"> - </return> - <argument index="0" name="index" type="int"> - </argument> - <argument index="1" name="format" type="int" enum="SurfaceTool.CustomFormat"> - </argument> + <return type="void" /> + <argument index="0" name="index" type="int" /> + <argument index="1" name="format" type="int" enum="SurfaceTool.CustomFormat" /> <description> </description> </method> <method name="set_material"> - <return type="void"> - </return> - <argument index="0" name="material" type="Material"> - </argument> + <return type="void" /> + <argument index="0" name="material" type="Material" /> <description> Sets [Material] to be used by the [Mesh] you are constructing. </description> </method> <method name="set_normal"> - <return type="void"> - </return> - <argument index="0" name="normal" type="Vector3"> - </argument> + <return type="void" /> + <argument index="0" name="normal" type="Vector3" /> <description> Specifies a normal to use for the [i]next[/i] vertex. If every vertex needs to have this information set and you fail to submit it for the first vertex, this information may not be used at all. </description> </method> <method name="set_skin_weight_count"> - <return type="void"> - </return> - <argument index="0" name="count" type="int" enum="SurfaceTool.SkinWeightCount"> - </argument> + <return type="void" /> + <argument index="0" name="count" type="int" enum="SurfaceTool.SkinWeightCount" /> <description> </description> </method> <method name="set_smooth_group"> - <return type="void"> - </return> - <argument index="0" name="index" type="int"> - </argument> + <return type="void" /> + <argument index="0" name="index" type="int" /> <description> Specifies whether the current vertex (if using only vertex arrays) or current index (if also using index arrays) should use smooth normals for normal calculation. </description> </method> <method name="set_tangent"> - <return type="void"> - </return> - <argument index="0" name="tangent" type="Plane"> - </argument> + <return type="void" /> + <argument index="0" name="tangent" type="Plane" /> <description> Specifies a tangent to use for the [i]next[/i] vertex. If every vertex needs to have this information set and you fail to submit it for the first vertex, this information may not be used at all. </description> </method> <method name="set_uv"> - <return type="void"> - </return> - <argument index="0" name="uv" type="Vector2"> - </argument> + <return type="void" /> + <argument index="0" name="uv" type="Vector2" /> <description> Specifies a set of UV coordinates to use for the [i]next[/i] vertex. If every vertex needs to have this information set and you fail to submit it for the first vertex, this information may not be used at all. </description> </method> <method name="set_uv2"> - <return type="void"> - </return> - <argument index="0" name="uv2" type="Vector2"> - </argument> + <return type="void" /> + <argument index="0" name="uv2" type="Vector2" /> <description> Specifies an optional second set of UV coordinates to use for the [i]next[/i] vertex. If every vertex needs to have this information set and you fail to submit it for the first vertex, this information may not be used at all. </description> </method> <method name="set_weights"> - <return type="void"> - </return> - <argument index="0" name="weights" type="PackedFloat32Array"> - </argument> + <return type="void" /> + <argument index="0" name="weights" type="PackedFloat32Array" /> <description> Specifies weight values to use for the [i]next[/i] vertex. [code]weights[/code] must contain 4 values. If every vertex needs to have this information set and you fail to submit it for the first vertex, this information may not be used at all. </description> diff --git a/doc/classes/SyntaxHighlighter.xml b/doc/classes/SyntaxHighlighter.xml index 642d75fa9b..ea0d1c27a3 100644 --- a/doc/classes/SyntaxHighlighter.xml +++ b/doc/classes/SyntaxHighlighter.xml @@ -12,42 +12,35 @@ </tutorials> <methods> <method name="_clear_highlighting_cache" qualifiers="virtual"> - <return type="void"> - </return> + <return type="void" /> <description> Virtual method which can be overridden to clear any local caches. </description> </method> <method name="_get_line_syntax_highlighting" qualifiers="virtual"> - <return type="Dictionary"> - </return> - <argument index="0" name="line" type="int"> - </argument> + <return type="Dictionary" /> + <argument index="0" name="line" type="int" /> <description> Virtual method which can be overridden to return syntax highlighting data. See [method get_line_syntax_highlighting] for more details. </description> </method> <method name="_update_cache" qualifiers="virtual"> - <return type="void"> - </return> + <return type="void" /> <description> Virtual method which can be overridden to update any local caches. </description> </method> <method name="clear_highlighting_cache"> - <return type="void"> - </return> + <return type="void" /> <description> Clears all cached syntax highlighting data. Then calls overridable method [method _clear_highlighting_cache]. </description> </method> <method name="get_line_syntax_highlighting"> - <return type="Dictionary"> - </return> - <argument index="0" name="line" type="int"> - </argument> + <return type="Dictionary" /> + <argument index="0" name="line" type="int" /> <description> Returns syntax highlighting data for a single line. If the line is not cached, calls [method _get_line_syntax_highlighting] to calculate the data. The return [Dictionary] is column number to [Dictionary]. The column number notes the start of a region, the region will end if another region is found, or at the end of the line. The nested [Dictionary] contains the data for that region, currently only the key "color" is supported. @@ -66,15 +59,13 @@ </description> </method> <method name="get_text_edit"> - <return type="TextEdit"> - </return> + <return type="TextEdit" /> <description> Returns the associated [TextEdit] node. </description> </method> <method name="update_cache"> - <return type="void"> - </return> + <return type="void" /> <description> Clears then updates the [SyntaxHighlighter] caches. Override [method _update_cache] for a callback. [b]Note:[/b] This is called automatically when the associated [TextEdit] node, updates its own cache. diff --git a/doc/classes/TCPServer.xml b/doc/classes/TCPServer.xml index 7160055c6d..9692693eff 100644 --- a/doc/classes/TCPServer.xml +++ b/doc/classes/TCPServer.xml @@ -10,33 +10,27 @@ </tutorials> <methods> <method name="get_local_port" qualifiers="const"> - <return type="int"> - </return> + <return type="int" /> <description> Returns the local port this server is listening to. </description> </method> <method name="is_connection_available" qualifiers="const"> - <return type="bool"> - </return> + <return type="bool" /> <description> Returns [code]true[/code] if a connection is available for taking. </description> </method> <method name="is_listening" qualifiers="const"> - <return type="bool"> - </return> + <return type="bool" /> <description> Returns [code]true[/code] if the server is currently listening for connections. </description> </method> <method name="listen"> - <return type="int" enum="Error"> - </return> - <argument index="0" name="port" type="int"> - </argument> - <argument index="1" name="bind_address" type="String" default=""*""> - </argument> + <return type="int" enum="Error" /> + <argument index="0" name="port" type="int" /> + <argument index="1" name="bind_address" type="String" default=""*"" /> <description> Listen on the [code]port[/code] binding to [code]bind_address[/code]. If [code]bind_address[/code] is set as [code]"*"[/code] (default), the server will listen on all available addresses (both IPv4 and IPv6). @@ -45,15 +39,13 @@ </description> </method> <method name="stop"> - <return type="void"> - </return> + <return type="void" /> <description> Stops listening. </description> </method> <method name="take_connection"> - <return type="StreamPeerTCP"> - </return> + <return type="StreamPeerTCP" /> <description> If a connection is available, returns a StreamPeerTCP with the connection. </description> diff --git a/doc/classes/TabContainer.xml b/doc/classes/TabContainer.xml index 3f24509ec7..2abe4dc90f 100644 --- a/doc/classes/TabContainer.xml +++ b/doc/classes/TabContainer.xml @@ -13,124 +13,98 @@ </tutorials> <methods> <method name="get_current_tab_control" qualifiers="const"> - <return type="Control"> - </return> + <return type="Control" /> <description> Returns the child [Control] node located at the active tab index. </description> </method> <method name="get_popup" qualifiers="const"> - <return type="Popup"> - </return> + <return type="Popup" /> <description> Returns the [Popup] node instance if one has been set already with [method set_popup]. </description> </method> <method name="get_previous_tab" qualifiers="const"> - <return type="int"> - </return> + <return type="int" /> <description> Returns the previously active tab index. </description> </method> <method name="get_tab_control" qualifiers="const"> - <return type="Control"> - </return> - <argument index="0" name="tab_idx" type="int"> - </argument> + <return type="Control" /> + <argument index="0" name="tab_idx" type="int" /> <description> Returns the [Control] node from the tab at index [code]tab_idx[/code]. </description> </method> <method name="get_tab_count" qualifiers="const"> - <return type="int"> - </return> + <return type="int" /> <description> Returns the number of tabs. </description> </method> <method name="get_tab_disabled" qualifiers="const"> - <return type="bool"> - </return> - <argument index="0" name="tab_idx" type="int"> - </argument> + <return type="bool" /> + <argument index="0" name="tab_idx" type="int" /> <description> Returns [code]true[/code] if the tab at index [code]tab_idx[/code] is disabled. </description> </method> <method name="get_tab_icon" qualifiers="const"> - <return type="Texture2D"> - </return> - <argument index="0" name="tab_idx" type="int"> - </argument> + <return type="Texture2D" /> + <argument index="0" name="tab_idx" type="int" /> <description> Returns the [Texture2D] for the tab at index [code]tab_idx[/code] or [code]null[/code] if the tab has no [Texture2D]. </description> </method> <method name="get_tab_title" qualifiers="const"> - <return type="String"> - </return> - <argument index="0" name="tab_idx" type="int"> - </argument> + <return type="String" /> + <argument index="0" name="tab_idx" type="int" /> <description> Returns the title of the tab at index [code]tab_idx[/code]. Tab titles default to the name of the indexed child node, but this can be overridden with [method set_tab_title]. </description> </method> <method name="get_tabs_rearrange_group" qualifiers="const"> - <return type="int"> - </return> + <return type="int" /> <description> Returns the [TabContainer] rearrange group id. </description> </method> <method name="set_popup"> - <return type="void"> - </return> - <argument index="0" name="popup" type="Node"> - </argument> + <return type="void" /> + <argument index="0" name="popup" type="Node" /> <description> If set on a [Popup] node instance, a popup menu icon appears in the top-right corner of the [TabContainer]. Clicking it will expand the [Popup] node. </description> </method> <method name="set_tab_disabled"> - <return type="void"> - </return> - <argument index="0" name="tab_idx" type="int"> - </argument> - <argument index="1" name="disabled" type="bool"> - </argument> + <return type="void" /> + <argument index="0" name="tab_idx" type="int" /> + <argument index="1" name="disabled" type="bool" /> <description> If [code]disabled[/code] is [code]false[/code], hides the tab at index [code]tab_idx[/code]. [b]Note:[/b] Its title text will remain, unless also removed with [method set_tab_title]. </description> </method> <method name="set_tab_icon"> - <return type="void"> - </return> - <argument index="0" name="tab_idx" type="int"> - </argument> - <argument index="1" name="icon" type="Texture2D"> - </argument> + <return type="void" /> + <argument index="0" name="tab_idx" type="int" /> + <argument index="1" name="icon" type="Texture2D" /> <description> Sets an icon for the tab at index [code]tab_idx[/code]. </description> </method> <method name="set_tab_title"> - <return type="void"> - </return> - <argument index="0" name="tab_idx" type="int"> - </argument> - <argument index="1" name="title" type="String"> - </argument> + <return type="void" /> + <argument index="0" name="tab_idx" type="int" /> + <argument index="1" name="title" type="String" /> <description> Sets a title for the tab at index [code]tab_idx[/code]. Tab titles default to the name of the indexed child node, but this can be overridden with [method set_tab_title]. </description> </method> <method name="set_tabs_rearrange_group"> - <return type="void"> - </return> - <argument index="0" name="group_id" type="int"> - </argument> + <return type="void" /> + <argument index="0" name="group_id" type="int" /> <description> Defines rearrange group id, choose for each [TabContainer] the same value to enable tab drag between [TabContainer]. Enable drag with [code]set_drag_to_rearrange_enabled(true)[/code]. </description> @@ -163,15 +137,13 @@ </description> </signal> <signal name="tab_changed"> - <argument index="0" name="tab" type="int"> - </argument> + <argument index="0" name="tab" type="int" /> <description> Emitted when switching to another tab. </description> </signal> <signal name="tab_selected"> - <argument index="0" name="tab" type="int"> - </argument> + <argument index="0" name="tab" type="int" /> <description> Emitted when a tab is selected, even if it is the current tab. </description> diff --git a/doc/classes/Tabs.xml b/doc/classes/Tabs.xml index aff104c922..537bb9c403 100644 --- a/doc/classes/Tabs.xml +++ b/doc/classes/Tabs.xml @@ -10,244 +10,188 @@ </tutorials> <methods> <method name="add_tab"> - <return type="void"> - </return> - <argument index="0" name="title" type="String" default=""""> - </argument> - <argument index="1" name="icon" type="Texture2D" default="null"> - </argument> + <return type="void" /> + <argument index="0" name="title" type="String" default="""" /> + <argument index="1" name="icon" type="Texture2D" default="null" /> <description> Adds a new tab. </description> </method> <method name="clear_tab_opentype_features"> - <return type="void"> - </return> - <argument index="0" name="tab_idx" type="int"> - </argument> + <return type="void" /> + <argument index="0" name="tab_idx" type="int" /> <description> Removes all OpenType features from the tab title. </description> </method> <method name="ensure_tab_visible"> - <return type="void"> - </return> - <argument index="0" name="idx" type="int"> - </argument> + <return type="void" /> + <argument index="0" name="idx" type="int" /> <description> Moves the scroll view to make the tab visible. </description> </method> <method name="get_offset_buttons_visible" qualifiers="const"> - <return type="bool"> - </return> + <return type="bool" /> <description> Returns [code]true[/code] if the offset buttons (the ones that appear when there's not enough space for all tabs) are visible. </description> </method> <method name="get_previous_tab" qualifiers="const"> - <return type="int"> - </return> + <return type="int" /> <description> Returns the previously active tab index. </description> </method> <method name="get_select_with_rmb" qualifiers="const"> - <return type="bool"> - </return> + <return type="bool" /> <description> Returns [code]true[/code] if select with right mouse button is enabled. </description> </method> <method name="get_tab_count" qualifiers="const"> - <return type="int"> - </return> + <return type="int" /> <description> Returns the number of tabs. </description> </method> <method name="get_tab_disabled" qualifiers="const"> - <return type="bool"> - </return> - <argument index="0" name="tab_idx" type="int"> - </argument> + <return type="bool" /> + <argument index="0" name="tab_idx" type="int" /> <description> Returns [code]true[/code] if the tab at index [code]tab_idx[/code] is disabled. </description> </method> <method name="get_tab_icon" qualifiers="const"> - <return type="Texture2D"> - </return> - <argument index="0" name="tab_idx" type="int"> - </argument> + <return type="Texture2D" /> + <argument index="0" name="tab_idx" type="int" /> <description> Returns the [Texture2D] for the tab at index [code]tab_idx[/code] or [code]null[/code] if the tab has no [Texture2D]. </description> </method> <method name="get_tab_language" qualifiers="const"> - <return type="String"> - </return> - <argument index="0" name="tab_idx" type="int"> - </argument> + <return type="String" /> + <argument index="0" name="tab_idx" type="int" /> <description> Returns tab title language code. </description> </method> <method name="get_tab_offset" qualifiers="const"> - <return type="int"> - </return> + <return type="int" /> <description> Returns the number of hidden tabs offsetted to the left. </description> </method> <method name="get_tab_opentype_feature" qualifiers="const"> - <return type="int"> - </return> - <argument index="0" name="tab_idx" type="int"> - </argument> - <argument index="1" name="tag" type="String"> - </argument> + <return type="int" /> + <argument index="0" name="tab_idx" type="int" /> + <argument index="1" name="tag" type="String" /> <description> Returns OpenType feature [code]tag[/code] of the tab title. </description> </method> <method name="get_tab_rect" qualifiers="const"> - <return type="Rect2"> - </return> - <argument index="0" name="tab_idx" type="int"> - </argument> + <return type="Rect2" /> + <argument index="0" name="tab_idx" type="int" /> <description> Returns tab [Rect2] with local position and size. </description> </method> <method name="get_tab_text_direction" qualifiers="const"> - <return type="int" enum="Control.TextDirection"> - </return> - <argument index="0" name="tab_idx" type="int"> - </argument> + <return type="int" enum="Control.TextDirection" /> + <argument index="0" name="tab_idx" type="int" /> <description> Returns tab title text base writing direction. </description> </method> <method name="get_tab_title" qualifiers="const"> - <return type="String"> - </return> - <argument index="0" name="tab_idx" type="int"> - </argument> + <return type="String" /> + <argument index="0" name="tab_idx" type="int" /> <description> Returns the title of the tab at index [code]tab_idx[/code]. Tab titles default to the name of the indexed child node, but this can be overridden with [method set_tab_title]. </description> </method> <method name="get_tabs_rearrange_group" qualifiers="const"> - <return type="int"> - </return> + <return type="int" /> <description> Returns the [Tabs]' rearrange group ID. </description> </method> <method name="move_tab"> - <return type="void"> - </return> - <argument index="0" name="from" type="int"> - </argument> - <argument index="1" name="to" type="int"> - </argument> + <return type="void" /> + <argument index="0" name="from" type="int" /> + <argument index="1" name="to" type="int" /> <description> Moves a tab from [code]from[/code] to [code]to[/code]. </description> </method> <method name="remove_tab"> - <return type="void"> - </return> - <argument index="0" name="tab_idx" type="int"> - </argument> + <return type="void" /> + <argument index="0" name="tab_idx" type="int" /> <description> Removes the tab at index [code]tab_idx[/code]. </description> </method> <method name="set_select_with_rmb"> - <return type="void"> - </return> - <argument index="0" name="enabled" type="bool"> - </argument> + <return type="void" /> + <argument index="0" name="enabled" type="bool" /> <description> If [code]true[/code], enables selecting a tab with the right mouse button. </description> </method> <method name="set_tab_disabled"> - <return type="void"> - </return> - <argument index="0" name="tab_idx" type="int"> - </argument> - <argument index="1" name="disabled" type="bool"> - </argument> + <return type="void" /> + <argument index="0" name="tab_idx" type="int" /> + <argument index="1" name="disabled" type="bool" /> <description> If [code]disabled[/code] is [code]false[/code], hides the tab at index [code]tab_idx[/code]. [b]Note:[/b] Its title text will remain unless it is also removed with [method set_tab_title]. </description> </method> <method name="set_tab_icon"> - <return type="void"> - </return> - <argument index="0" name="tab_idx" type="int"> - </argument> - <argument index="1" name="icon" type="Texture2D"> - </argument> + <return type="void" /> + <argument index="0" name="tab_idx" type="int" /> + <argument index="1" name="icon" type="Texture2D" /> <description> Sets an [code]icon[/code] for the tab at index [code]tab_idx[/code]. </description> </method> <method name="set_tab_language"> - <return type="void"> - </return> - <argument index="0" name="tab_idx" type="int"> - </argument> - <argument index="1" name="language" type="String"> - </argument> + <return type="void" /> + <argument index="0" name="tab_idx" type="int" /> + <argument index="1" name="language" type="String" /> <description> Sets language code of tab title used for line-breaking and text shaping algorithms, if left empty current locale is used instead. </description> </method> <method name="set_tab_opentype_feature"> - <return type="void"> - </return> - <argument index="0" name="tab_idx" type="int"> - </argument> - <argument index="1" name="tag" type="String"> - </argument> - <argument index="2" name="values" type="int"> - </argument> + <return type="void" /> + <argument index="0" name="tab_idx" type="int" /> + <argument index="1" name="tag" type="String" /> + <argument index="2" name="values" type="int" /> <description> Sets OpenType feature [code]tag[/code] for the tab title. More info: [url=https://docs.microsoft.com/en-us/typography/opentype/spec/featuretags]OpenType feature tags[/url]. </description> </method> <method name="set_tab_text_direction"> - <return type="void"> - </return> - <argument index="0" name="tab_idx" type="int"> - </argument> - <argument index="1" name="direction" type="int" enum="Control.TextDirection"> - </argument> + <return type="void" /> + <argument index="0" name="tab_idx" type="int" /> + <argument index="1" name="direction" type="int" enum="Control.TextDirection" /> <description> Sets tab title base writing direction. </description> </method> <method name="set_tab_title"> - <return type="void"> - </return> - <argument index="0" name="tab_idx" type="int"> - </argument> - <argument index="1" name="title" type="String"> - </argument> + <return type="void" /> + <argument index="0" name="tab_idx" type="int" /> + <argument index="1" name="title" type="String" /> <description> Sets a [code]title[/code] for the tab at index [code]tab_idx[/code]. </description> </method> <method name="set_tabs_rearrange_group"> - <return type="void"> - </return> - <argument index="0" name="group_id" type="int"> - </argument> + <return type="void" /> + <argument index="0" name="group_id" type="int" /> <description> Defines the rearrange group ID. Choose for each [Tabs] the same value to dragging tabs between [Tabs]. Enable drag with [code]set_drag_to_rearrange_enabled(true)[/code]. </description> @@ -275,43 +219,37 @@ </members> <signals> <signal name="reposition_active_tab_request"> - <argument index="0" name="idx_to" type="int"> - </argument> + <argument index="0" name="idx_to" type="int" /> <description> Emitted when the active tab is rearranged via mouse drag. See [member drag_to_rearrange_enabled]. </description> </signal> <signal name="right_button_pressed"> - <argument index="0" name="tab" type="int"> - </argument> + <argument index="0" name="tab" type="int" /> <description> Emitted when a tab is right-clicked. </description> </signal> <signal name="tab_changed"> - <argument index="0" name="tab" type="int"> - </argument> + <argument index="0" name="tab" type="int" /> <description> Emitted when switching to another tab. </description> </signal> <signal name="tab_clicked"> - <argument index="0" name="tab" type="int"> - </argument> + <argument index="0" name="tab" type="int" /> <description> Emitted when a tab is clicked, even if it is the current tab. </description> </signal> <signal name="tab_closed"> - <argument index="0" name="tab" type="int"> - </argument> + <argument index="0" name="tab" type="int" /> <description> Emitted when a tab is closed. </description> </signal> <signal name="tab_hovered"> - <argument index="0" name="tab" type="int"> - </argument> + <argument index="0" name="tab" type="int" /> <description> Emitted when a tab is hovered by the mouse. </description> diff --git a/doc/classes/TextEdit.xml b/doc/classes/TextEdit.xml index 5de6c059c3..5444721e10 100644 --- a/doc/classes/TextEdit.xml +++ b/doc/classes/TextEdit.xml @@ -11,92 +11,74 @@ </tutorials> <methods> <method name="_backspace" qualifiers="virtual"> - <return type="void"> - </return> + <return type="void" /> <description> A virtual method that is called whenever backspace is triggered. </description> </method> <method name="add_gutter"> - <return type="void"> - </return> - <argument index="0" name="at" type="int" default="-1"> - </argument> + <return type="void" /> + <argument index="0" name="at" type="int" default="-1" /> <description> </description> </method> <method name="backspace"> - <return type="void"> - </return> + <return type="void" /> <description> Causes the [TextEdit] to perform a backspace. </description> </method> <method name="center_viewport_to_cursor"> - <return type="void"> - </return> + <return type="void" /> <description> Centers the viewport on the line the editing cursor is at. This also resets the [member scroll_horizontal] value to [code]0[/code]. </description> </method> <method name="clear_opentype_features"> - <return type="void"> - </return> + <return type="void" /> <description> Removes all OpenType features. </description> </method> <method name="clear_undo_history"> - <return type="void"> - </return> + <return type="void" /> <description> Clears the undo history. </description> </method> <method name="copy"> - <return type="void"> - </return> + <return type="void" /> <description> Copy's the current text selection. </description> </method> <method name="cursor_get_column" qualifiers="const"> - <return type="int"> - </return> + <return type="int" /> <description> Returns the column the editing cursor is at. </description> </method> <method name="cursor_get_line" qualifiers="const"> - <return type="int"> - </return> + <return type="int" /> <description> Returns the line the editing cursor is at. </description> </method> <method name="cursor_set_column"> - <return type="void"> - </return> - <argument index="0" name="column" type="int"> - </argument> - <argument index="1" name="adjust_viewport" type="bool" default="true"> - </argument> + <return type="void" /> + <argument index="0" name="column" type="int" /> + <argument index="1" name="adjust_viewport" type="bool" default="true" /> <description> Moves the cursor at the specified [code]column[/code] index. If [code]adjust_viewport[/code] is set to [code]true[/code], the viewport will center at the cursor position after the move occurs. </description> </method> <method name="cursor_set_line"> - <return type="void"> - </return> - <argument index="0" name="line" type="int"> - </argument> - <argument index="1" name="adjust_viewport" type="bool" default="true"> - </argument> - <argument index="2" name="can_be_hidden" type="bool" default="true"> - </argument> - <argument index="3" name="wrap_index" type="int" default="0"> - </argument> + <return type="void" /> + <argument index="0" name="line" type="int" /> + <argument index="1" name="adjust_viewport" type="bool" default="true" /> + <argument index="2" name="can_be_hidden" type="bool" default="true" /> + <argument index="3" name="wrap_index" type="int" default="0" /> <description> Moves the cursor at the specified [code]line[/code] index. If [code]adjust_viewport[/code] is set to [code]true[/code], the viewport will center at the cursor position after the move occurs. @@ -104,343 +86,276 @@ </description> </method> <method name="cut"> - <return type="void"> - </return> + <return type="void" /> <description> Cut's the current selection. </description> </method> <method name="delete_selection"> - <return type="void"> - </return> + <return type="void" /> <description> </description> </method> <method name="deselect"> - <return type="void"> - </return> + <return type="void" /> <description> Deselects the current selection. </description> </method> <method name="get_caret_draw_pos" qualifiers="const"> - <return type="Vector2"> - </return> + <return type="Vector2" /> <description> - Gets the caret pixel draw poistion. + Gets the caret pixel draw position. </description> </method> <method name="get_first_non_whitespace_column" qualifiers="const"> - <return type="int"> - </return> - <argument index="0" name="line" type="int"> - </argument> + <return type="int" /> + <argument index="0" name="line" type="int" /> <description> </description> </method> <method name="get_gutter_count" qualifiers="const"> - <return type="int"> - </return> + <return type="int" /> <description> </description> </method> <method name="get_gutter_name" qualifiers="const"> - <return type="String"> - </return> - <argument index="0" name="gutter" type="int"> - </argument> + <return type="String" /> + <argument index="0" name="gutter" type="int" /> <description> </description> </method> <method name="get_gutter_type" qualifiers="const"> - <return type="int" enum="TextEdit.GutterType"> - </return> - <argument index="0" name="gutter" type="int"> - </argument> + <return type="int" enum="TextEdit.GutterType" /> + <argument index="0" name="gutter" type="int" /> <description> </description> </method> <method name="get_gutter_width" qualifiers="const"> - <return type="int"> - </return> - <argument index="0" name="gutter" type="int"> - </argument> + <return type="int" /> + <argument index="0" name="gutter" type="int" /> <description> </description> </method> <method name="get_indent_level" qualifiers="const"> - <return type="int"> - </return> - <argument index="0" name="line" type="int"> - </argument> + <return type="int" /> + <argument index="0" name="line" type="int" /> <description> Returns the indent level of a specific line. </description> </method> <method name="get_line" qualifiers="const"> - <return type="String"> - </return> - <argument index="0" name="line" type="int"> - </argument> + <return type="String" /> + <argument index="0" name="line" type="int" /> <description> Returns the text of a specific line. </description> </method> <method name="get_line_background_color"> - <return type="Color"> - </return> - <argument index="0" name="line" type="int"> - </argument> + <return type="Color" /> + <argument index="0" name="line" type="int" /> <description> Returns the current background color of the line. [code]Color(0, 0, 0, 0)[/code] is returned if no color is set. </description> </method> <method name="get_line_count" qualifiers="const"> - <return type="int"> - </return> + <return type="int" /> <description> Returns the amount of total lines in the text. </description> </method> <method name="get_line_gutter_icon" qualifiers="const"> - <return type="Texture2D"> - </return> - <argument index="0" name="line" type="int"> - </argument> - <argument index="1" name="gutter" type="int"> - </argument> + <return type="Texture2D" /> + <argument index="0" name="line" type="int" /> + <argument index="1" name="gutter" type="int" /> <description> </description> </method> <method name="get_line_gutter_item_color"> - <return type="Color"> - </return> - <argument index="0" name="line" type="int"> - </argument> - <argument index="1" name="gutter" type="int"> - </argument> + <return type="Color" /> + <argument index="0" name="line" type="int" /> + <argument index="1" name="gutter" type="int" /> <description> </description> </method> <method name="get_line_gutter_metadata" qualifiers="const"> - <return type="Variant"> - </return> - <argument index="0" name="line" type="int"> - </argument> - <argument index="1" name="gutter" type="int"> - </argument> + <return type="Variant" /> + <argument index="0" name="line" type="int" /> + <argument index="1" name="gutter" type="int" /> <description> </description> </method> <method name="get_line_gutter_text" qualifiers="const"> - <return type="String"> - </return> - <argument index="0" name="line" type="int"> - </argument> - <argument index="1" name="gutter" type="int"> - </argument> + <return type="String" /> + <argument index="0" name="line" type="int" /> + <argument index="1" name="gutter" type="int" /> <description> </description> </method> <method name="get_menu" qualifiers="const"> - <return type="PopupMenu"> - </return> + <return type="PopupMenu" /> <description> Returns the [PopupMenu] of this [TextEdit]. By default, this menu is displayed when right-clicking on the [TextEdit]. </description> </method> <method name="get_opentype_feature" qualifiers="const"> - <return type="int"> - </return> - <argument index="0" name="tag" type="String"> - </argument> + <return type="int" /> + <argument index="0" name="tag" type="String" /> <description> Returns OpenType feature [code]tag[/code]. </description> </method> <method name="get_selection_column" qualifiers="const"> - <return type="int"> - </return> + <return type="int" /> <description> </description> </method> <method name="get_selection_from_column" qualifiers="const"> - <return type="int"> - </return> + <return type="int" /> <description> Returns the selection begin column. </description> </method> <method name="get_selection_from_line" qualifiers="const"> - <return type="int"> - </return> + <return type="int" /> <description> Returns the selection begin line. </description> </method> <method name="get_selection_line" qualifiers="const"> - <return type="int"> - </return> + <return type="int" /> <description> </description> </method> <method name="get_selection_mode" qualifiers="const"> - <return type="int" enum="TextEdit.SelectionMode"> - </return> + <return type="int" enum="TextEdit.SelectionMode" /> <description> </description> </method> <method name="get_selection_text" qualifiers="const"> - <return type="String"> - </return> + <return type="String" /> <description> Returns the text inside the selection. </description> </method> <method name="get_selection_to_column" qualifiers="const"> - <return type="int"> - </return> + <return type="int" /> <description> Returns the selection end column. </description> </method> <method name="get_selection_to_line" qualifiers="const"> - <return type="int"> - </return> + <return type="int" /> <description> Returns the selection end line. </description> </method> <method name="get_tab_size" qualifiers="const"> - <return type="int"> - </return> + <return type="int" /> <description> Returns the [TextEdit]'s' tab size. </description> </method> <method name="get_visible_line_count" qualifiers="const"> - <return type="int"> - </return> + <return type="int" /> <description> Returns the number of visible lines, including wrapped text. </description> </method> <method name="get_word_under_cursor" qualifiers="const"> - <return type="String"> - </return> + <return type="String" /> <description> Returns a [String] text with the word under the caret (text cursor) location. </description> </method> <method name="insert_text_at_cursor"> - <return type="void"> - </return> - <argument index="0" name="text" type="String"> - </argument> + <return type="void" /> + <argument index="0" name="text" type="String" /> <description> Insert the specified text at the cursor position. </description> </method> <method name="is_caret_visible" qualifiers="const"> - <return type="bool"> - </return> + <return type="bool" /> <description> Returns [code]true[/code] if the caret is visible on the screen. </description> </method> <method name="is_gutter_clickable" qualifiers="const"> - <return type="bool"> - </return> - <argument index="0" name="gutter" type="int"> - </argument> + <return type="bool" /> + <argument index="0" name="gutter" type="int" /> <description> </description> </method> <method name="is_gutter_drawn" qualifiers="const"> - <return type="bool"> - </return> - <argument index="0" name="gutter" type="int"> - </argument> + <return type="bool" /> + <argument index="0" name="gutter" type="int" /> <description> </description> </method> <method name="is_gutter_overwritable" qualifiers="const"> - <return type="bool"> - </return> - <argument index="0" name="gutter" type="int"> - </argument> + <return type="bool" /> + <argument index="0" name="gutter" type="int" /> <description> </description> </method> <method name="is_line_gutter_clickable" qualifiers="const"> - <return type="bool"> - </return> - <argument index="0" name="line" type="int"> - </argument> - <argument index="1" name="gutter" type="int"> - </argument> + <return type="bool" /> + <argument index="0" name="line" type="int" /> + <argument index="1" name="gutter" type="int" /> <description> </description> </method> + <method name="is_menu_visible" qualifiers="const"> + <return type="bool" /> + <description> + Returns whether the menu is visible. Use this instead of [code]get_menu().visible[/code] to improve performance (so the creation of the menu is avoided). + </description> + </method> <method name="is_selection_active" qualifiers="const"> - <return type="bool"> - </return> + <return type="bool" /> <description> Returns [code]true[/code] if the selection is active. </description> </method> <method name="menu_option"> - <return type="void"> - </return> - <argument index="0" name="option" type="int"> - </argument> + <return type="void" /> + <argument index="0" name="option" type="int" /> <description> Triggers a right-click menu action by the specified index. See [enum MenuItems] for a list of available indexes. </description> </method> <method name="merge_gutters"> - <return type="void"> - </return> - <argument index="0" name="from_line" type="int"> - </argument> - <argument index="1" name="to_line" type="int"> - </argument> + <return type="void" /> + <argument index="0" name="from_line" type="int" /> + <argument index="1" name="to_line" type="int" /> <description> </description> </method> <method name="paste"> - <return type="void"> - </return> + <return type="void" /> <description> Paste the current selection. </description> </method> <method name="redo"> - <return type="void"> - </return> + <return type="void" /> <description> Perform redo operation. </description> </method> <method name="remove_gutter"> - <return type="void"> - </return> - <argument index="0" name="gutter" type="int"> - </argument> + <return type="void" /> + <argument index="0" name="gutter" type="int" /> <description> </description> </method> <method name="search" qualifiers="const"> - <return type="Dictionary"> - </return> - <argument index="0" name="key" type="String"> - </argument> - <argument index="1" name="flags" type="int"> - </argument> - <argument index="2" name="from_line" type="int"> - </argument> - <argument index="3" name="from_column" type="int"> - </argument> + <return type="Dictionary" /> + <argument index="0" name="key" type="String" /> + <argument index="1" name="flags" type="int" /> + <argument index="2" name="from_line" type="int" /> + <argument index="3" name="from_column" type="int" /> <description> Perform a search inside the text. Search flags can be specified in the [enum SearchFlags] enum. Returns an empty [code]Dictionary[/code] if no result was found. Otherwise, returns a [code]Dictionary[/code] containing [code]line[/code] and [code]column[/code] entries, e.g: @@ -465,218 +380,154 @@ </description> </method> <method name="select"> - <return type="void"> - </return> - <argument index="0" name="from_line" type="int"> - </argument> - <argument index="1" name="from_column" type="int"> - </argument> - <argument index="2" name="to_line" type="int"> - </argument> - <argument index="3" name="to_column" type="int"> - </argument> + <return type="void" /> + <argument index="0" name="from_line" type="int" /> + <argument index="1" name="from_column" type="int" /> + <argument index="2" name="to_line" type="int" /> + <argument index="3" name="to_column" type="int" /> <description> Perform selection, from line/column to line/column. If [member selecting_enabled] is [code]false[/code], no selection will occur. </description> </method> <method name="select_all"> - <return type="void"> - </return> + <return type="void" /> <description> Select all the text. If [member selecting_enabled] is [code]false[/code], no selection will occur. </description> </method> <method name="set_gutter_clickable"> - <return type="void"> - </return> - <argument index="0" name="gutter" type="int"> - </argument> - <argument index="1" name="clickable" type="bool"> - </argument> + <return type="void" /> + <argument index="0" name="gutter" type="int" /> + <argument index="1" name="clickable" type="bool" /> <description> </description> </method> <method name="set_gutter_custom_draw"> - <return type="void"> - </return> - <argument index="0" name="column" type="int"> - </argument> - <argument index="1" name="object" type="Object"> - </argument> - <argument index="2" name="callback" type="StringName"> - </argument> + <return type="void" /> + <argument index="0" name="column" type="int" /> + <argument index="1" name="object" type="Object" /> + <argument index="2" name="callback" type="StringName" /> <description> </description> </method> <method name="set_gutter_draw"> - <return type="void"> - </return> - <argument index="0" name="gutter" type="int"> - </argument> - <argument index="1" name="draw" type="bool"> - </argument> + <return type="void" /> + <argument index="0" name="gutter" type="int" /> + <argument index="1" name="draw" type="bool" /> <description> </description> </method> <method name="set_gutter_name"> - <return type="void"> - </return> - <argument index="0" name="gutter" type="int"> - </argument> - <argument index="1" name="name" type="String"> - </argument> + <return type="void" /> + <argument index="0" name="gutter" type="int" /> + <argument index="1" name="name" type="String" /> <description> </description> </method> <method name="set_gutter_overwritable"> - <return type="void"> - </return> - <argument index="0" name="gutter" type="int"> - </argument> - <argument index="1" name="overwritable" type="bool"> - </argument> + <return type="void" /> + <argument index="0" name="gutter" type="int" /> + <argument index="1" name="overwritable" type="bool" /> <description> </description> </method> <method name="set_gutter_type"> - <return type="void"> - </return> - <argument index="0" name="gutter" type="int"> - </argument> - <argument index="1" name="type" type="int" enum="TextEdit.GutterType"> - </argument> + <return type="void" /> + <argument index="0" name="gutter" type="int" /> + <argument index="1" name="type" type="int" enum="TextEdit.GutterType" /> <description> </description> </method> <method name="set_gutter_width"> - <return type="void"> - </return> - <argument index="0" name="gutter" type="int"> - </argument> - <argument index="1" name="width" type="int"> - </argument> + <return type="void" /> + <argument index="0" name="gutter" type="int" /> + <argument index="1" name="width" type="int" /> <description> </description> </method> <method name="set_line"> - <return type="void"> - </return> - <argument index="0" name="line" type="int"> - </argument> - <argument index="1" name="new_text" type="String"> - </argument> + <return type="void" /> + <argument index="0" name="line" type="int" /> + <argument index="1" name="new_text" type="String" /> <description> Sets the text for a specific line. </description> </method> <method name="set_line_background_color"> - <return type="void"> - </return> - <argument index="0" name="line" type="int"> - </argument> - <argument index="1" name="color" type="Color"> - </argument> + <return type="void" /> + <argument index="0" name="line" type="int" /> + <argument index="1" name="color" type="Color" /> <description> Sets the current background color of the line. Set to [code]Color(0, 0, 0, 0)[/code] for no color. </description> </method> <method name="set_line_gutter_clickable"> - <return type="void"> - </return> - <argument index="0" name="line" type="int"> - </argument> - <argument index="1" name="gutter" type="int"> - </argument> - <argument index="2" name="clickable" type="bool"> - </argument> + <return type="void" /> + <argument index="0" name="line" type="int" /> + <argument index="1" name="gutter" type="int" /> + <argument index="2" name="clickable" type="bool" /> <description> </description> </method> <method name="set_line_gutter_icon"> - <return type="void"> - </return> - <argument index="0" name="line" type="int"> - </argument> - <argument index="1" name="gutter" type="int"> - </argument> - <argument index="2" name="icon" type="Texture2D"> - </argument> + <return type="void" /> + <argument index="0" name="line" type="int" /> + <argument index="1" name="gutter" type="int" /> + <argument index="2" name="icon" type="Texture2D" /> <description> </description> </method> <method name="set_line_gutter_item_color"> - <return type="void"> - </return> - <argument index="0" name="line" type="int"> - </argument> - <argument index="1" name="gutter" type="int"> - </argument> - <argument index="2" name="color" type="Color"> - </argument> + <return type="void" /> + <argument index="0" name="line" type="int" /> + <argument index="1" name="gutter" type="int" /> + <argument index="2" name="color" type="Color" /> <description> </description> </method> <method name="set_line_gutter_metadata"> - <return type="void"> - </return> - <argument index="0" name="line" type="int"> - </argument> - <argument index="1" name="gutter" type="int"> - </argument> - <argument index="2" name="metadata" type="Variant"> - </argument> + <return type="void" /> + <argument index="0" name="line" type="int" /> + <argument index="1" name="gutter" type="int" /> + <argument index="2" name="metadata" type="Variant" /> <description> </description> </method> <method name="set_line_gutter_text"> - <return type="void"> - </return> - <argument index="0" name="line" type="int"> - </argument> - <argument index="1" name="gutter" type="int"> - </argument> - <argument index="2" name="text" type="String"> - </argument> + <return type="void" /> + <argument index="0" name="line" type="int" /> + <argument index="1" name="gutter" type="int" /> + <argument index="2" name="text" type="String" /> <description> </description> </method> <method name="set_opentype_feature"> - <return type="void"> - </return> - <argument index="0" name="tag" type="String"> - </argument> - <argument index="1" name="value" type="int"> - </argument> + <return type="void" /> + <argument index="0" name="tag" type="String" /> + <argument index="1" name="value" type="int" /> <description> Sets OpenType feature [code]tag[/code]. More info: [url=https://docs.microsoft.com/en-us/typography/opentype/spec/featuretags]OpenType feature tags[/url]. </description> </method> <method name="set_selection_mode"> - <return type="void"> - </return> - <argument index="0" name="mode" type="int" enum="TextEdit.SelectionMode"> - </argument> - <argument index="1" name="line" type="int" default="-1"> - </argument> - <argument index="2" name="column" type="int" default="-1"> - </argument> + <return type="void" /> + <argument index="0" name="mode" type="int" enum="TextEdit.SelectionMode" /> + <argument index="1" name="line" type="int" default="-1" /> + <argument index="2" name="column" type="int" default="-1" /> <description> </description> </method> <method name="set_tab_size"> - <return type="void"> - </return> - <argument index="0" name="size" type="int"> - </argument> + <return type="void" /> + <argument index="0" name="size" type="int" /> <description> Sets the tab size for the [TextEdit] to use. </description> </method> <method name="undo"> - <return type="void"> - </return> + <return type="void" /> <description> Perform undo operation. </description> @@ -788,10 +639,8 @@ </description> </signal> <signal name="gutter_clicked"> - <argument index="0" name="line" type="int"> - </argument> - <argument index="1" name="gutter" type="int"> - </argument> + <argument index="0" name="line" type="int" /> + <argument index="1" name="gutter" type="int" /> <description> </description> </signal> @@ -800,26 +649,20 @@ </description> </signal> <signal name="lines_edited_from"> - <argument index="0" name="from_line" type="int"> - </argument> - <argument index="1" name="to_line" type="int"> - </argument> + <argument index="0" name="from_line" type="int" /> + <argument index="1" name="to_line" type="int" /> <description> </description> </signal> <signal name="symbol_lookup"> - <argument index="0" name="symbol" type="String"> - </argument> - <argument index="1" name="row" type="int"> - </argument> - <argument index="2" name="column" type="int"> - </argument> + <argument index="0" name="symbol" type="String" /> + <argument index="1" name="row" type="int" /> + <argument index="2" name="column" type="int" /> <description> </description> </signal> <signal name="symbol_validate"> - <argument index="0" name="symbol" type="String"> - </argument> + <argument index="0" name="symbol" type="String" /> <description> </description> </signal> @@ -851,9 +694,9 @@ </constant> <constant name="GUTTER_TYPE_STRING" value="0" enum="GutterType"> </constant> - <constant name="GUTTER_TPYE_ICON" value="1" enum="GutterType"> + <constant name="GUTTER_TYPE_ICON" value="1" enum="GutterType"> </constant> - <constant name="GUTTER_TPYE_CUSTOM" value="2" enum="GutterType"> + <constant name="GUTTER_TYPE_CUSTOM" value="2" enum="GutterType"> </constant> <constant name="MENU_CUT" value="0" enum="MenuItems"> Cuts (copies and clears) the selected text. diff --git a/doc/classes/TextLine.xml b/doc/classes/TextLine.xml index 318c3be794..cc66f56d65 100644 --- a/doc/classes/TextLine.xml +++ b/doc/classes/TextLine.xml @@ -10,175 +10,134 @@ </tutorials> <methods> <method name="add_object"> - <return type="bool"> - </return> - <argument index="0" name="key" type="Variant"> - </argument> - <argument index="1" name="size" type="Vector2"> - </argument> - <argument index="2" name="inline_align" type="int" enum="VAlign" default="1"> - </argument> - <argument index="3" name="length" type="int" default="1"> - </argument> + <return type="bool" /> + <argument index="0" name="key" type="Variant" /> + <argument index="1" name="size" type="Vector2" /> + <argument index="2" name="inline_align" type="int" enum="VAlign" default="1" /> + <argument index="3" name="length" type="int" default="1" /> <description> Adds inline object to the text buffer, [code]key[/code] must be unique. In the text, object is represented as [code]length[/code] object replacement characters. </description> </method> <method name="add_string"> - <return type="bool"> - </return> - <argument index="0" name="text" type="String"> - </argument> - <argument index="1" name="fonts" type="Font"> - </argument> - <argument index="2" name="size" type="int"> - </argument> + <return type="bool" /> + <argument index="0" name="text" type="String" /> + <argument index="1" name="fonts" type="Font" /> + <argument index="2" name="size" type="int" /> <argument index="3" name="opentype_features" type="Dictionary" default="{ -}"> - </argument> - <argument index="4" name="language" type="String" default=""""> - </argument> +}" /> + <argument index="4" name="language" type="String" default="""" /> <description> Adds text span and font to draw it. </description> </method> <method name="clear"> - <return type="void"> - </return> + <return type="void" /> <description> Clears text line (removes text and inline objects). </description> </method> <method name="draw" qualifiers="const"> - <return type="void"> - </return> - <argument index="0" name="canvas" type="RID"> - </argument> - <argument index="1" name="pos" type="Vector2"> - </argument> - <argument index="2" name="color" type="Color" default="Color(1, 1, 1, 1)"> - </argument> + <return type="void" /> + <argument index="0" name="canvas" type="RID" /> + <argument index="1" name="pos" type="Vector2" /> + <argument index="2" name="color" type="Color" default="Color(1, 1, 1, 1)" /> <description> Draw text into a canvas item at a given position, with [code]color[/code]. [code]pos[/code] specifies the top left corner of the bounding box. </description> </method> <method name="draw_outline" qualifiers="const"> - <return type="void"> - </return> - <argument index="0" name="canvas" type="RID"> - </argument> - <argument index="1" name="pos" type="Vector2"> - </argument> - <argument index="2" name="outline_size" type="int" default="1"> - </argument> - <argument index="3" name="color" type="Color" default="Color(1, 1, 1, 1)"> - </argument> + <return type="void" /> + <argument index="0" name="canvas" type="RID" /> + <argument index="1" name="pos" type="Vector2" /> + <argument index="2" name="outline_size" type="int" default="1" /> + <argument index="3" name="color" type="Color" default="Color(1, 1, 1, 1)" /> <description> Draw text into a canvas item at a given position, with [code]color[/code]. [code]pos[/code] specifies the top left corner of the bounding box. </description> </method> <method name="get_line_ascent" qualifiers="const"> - <return type="float"> - </return> + <return type="float" /> <description> Returns the text ascent (number of pixels above the baseline for horizontal layout or to the left of baseline for vertical). </description> </method> <method name="get_line_descent" qualifiers="const"> - <return type="float"> - </return> + <return type="float" /> <description> Returns the text descent (number of pixels below the baseline for horizontal layout or to the right of baseline for vertical). </description> </method> <method name="get_line_underline_position" qualifiers="const"> - <return type="float"> - </return> + <return type="float" /> <description> Returns pixel offset of the underline below the baseline. </description> </method> <method name="get_line_underline_thickness" qualifiers="const"> - <return type="float"> - </return> + <return type="float" /> <description> Returns thickness of the underline. </description> </method> <method name="get_line_width" qualifiers="const"> - <return type="float"> - </return> + <return type="float" /> <description> Returns width (for horizontal layout) or height (for vertical) of the text. </description> </method> <method name="get_object_rect" qualifiers="const"> - <return type="Rect2"> - </return> - <argument index="0" name="key" type="Variant"> - </argument> + <return type="Rect2" /> + <argument index="0" name="key" type="Variant" /> <description> Returns bounding rectangle of the inline object. </description> </method> <method name="get_objects" qualifiers="const"> - <return type="Array"> - </return> + <return type="Array" /> <description> Returns array of inline objects. </description> </method> <method name="get_rid" qualifiers="const"> - <return type="RID"> - </return> + <return type="RID" /> <description> Returns TextServer buffer RID. </description> </method> <method name="get_size" qualifiers="const"> - <return type="Vector2"> - </return> + <return type="Vector2" /> <description> Returns size of the bounding box of the text. </description> </method> <method name="hit_test" qualifiers="const"> - <return type="int"> - </return> - <argument index="0" name="coords" type="float"> - </argument> + <return type="int" /> + <argument index="0" name="coords" type="float" /> <description> Returns caret character offset at the specified pixel offset at the baseline. This function always returns a valid position. </description> </method> <method name="resize_object"> - <return type="bool"> - </return> - <argument index="0" name="key" type="Variant"> - </argument> - <argument index="1" name="size" type="Vector2"> - </argument> - <argument index="2" name="inline_align" type="int" enum="VAlign" default="1"> - </argument> + <return type="bool" /> + <argument index="0" name="key" type="Variant" /> + <argument index="1" name="size" type="Vector2" /> + <argument index="2" name="inline_align" type="int" enum="VAlign" default="1" /> <description> Sets new size and alignment of embedded object. </description> </method> <method name="set_bidi_override"> - <return type="void"> - </return> - <argument index="0" name="override" type="Array"> - </argument> + <return type="void" /> + <argument index="0" name="override" type="Array" /> <description> Overrides BiDi for the structured text. Override ranges should cover full source text without overlaps. BiDi algorithm will be used on each range separately. </description> </method> <method name="tab_align"> - <return type="void"> - </return> - <argument index="0" name="tab_stops" type="PackedFloat32Array"> - </argument> + <return type="void" /> + <argument index="0" name="tab_stops" type="PackedFloat32Array" /> <description> Aligns text to the given tab-stops. </description> diff --git a/doc/classes/TextParagraph.xml b/doc/classes/TextParagraph.xml index d67a9bcb85..9050f9246a 100644 --- a/doc/classes/TextParagraph.xml +++ b/doc/classes/TextParagraph.xml @@ -10,356 +10,265 @@ </tutorials> <methods> <method name="add_object"> - <return type="bool"> - </return> - <argument index="0" name="key" type="Variant"> - </argument> - <argument index="1" name="size" type="Vector2"> - </argument> - <argument index="2" name="inline_align" type="int" enum="VAlign" default="1"> - </argument> - <argument index="3" name="length" type="int" default="1"> - </argument> + <return type="bool" /> + <argument index="0" name="key" type="Variant" /> + <argument index="1" name="size" type="Vector2" /> + <argument index="2" name="inline_align" type="int" enum="VAlign" default="1" /> + <argument index="3" name="length" type="int" default="1" /> <description> Adds inline object to the text buffer, [code]key[/code] must be unique. In the text, object is represented as [code]length[/code] object replacement characters. </description> </method> <method name="add_string"> - <return type="bool"> - </return> - <argument index="0" name="text" type="String"> - </argument> - <argument index="1" name="fonts" type="Font"> - </argument> - <argument index="2" name="size" type="int"> - </argument> + <return type="bool" /> + <argument index="0" name="text" type="String" /> + <argument index="1" name="fonts" type="Font" /> + <argument index="2" name="size" type="int" /> <argument index="3" name="opentype_features" type="Dictionary" default="{ -}"> - </argument> - <argument index="4" name="language" type="String" default=""""> - </argument> +}" /> + <argument index="4" name="language" type="String" default="""" /> <description> Adds text span and font to draw it. </description> </method> <method name="clear"> - <return type="void"> - </return> + <return type="void" /> <description> Clears text paragraph (removes text and inline objects). </description> </method> <method name="clear_dropcap"> - <return type="void"> - </return> + <return type="void" /> <description> Removes dropcap. </description> </method> <method name="draw" qualifiers="const"> - <return type="void"> - </return> - <argument index="0" name="canvas" type="RID"> - </argument> - <argument index="1" name="pos" type="Vector2"> - </argument> - <argument index="2" name="color" type="Color" default="Color(1, 1, 1, 1)"> - </argument> - <argument index="3" name="dc_color" type="Color" default="Color(1, 1, 1, 1)"> - </argument> + <return type="void" /> + <argument index="0" name="canvas" type="RID" /> + <argument index="1" name="pos" type="Vector2" /> + <argument index="2" name="color" type="Color" default="Color(1, 1, 1, 1)" /> + <argument index="3" name="dc_color" type="Color" default="Color(1, 1, 1, 1)" /> <description> Draw all lines of the text and drop cap into a canvas item at a given position, with [code]color[/code]. [code]pos[/code] specifies the top left corner of the bounding box. </description> </method> <method name="draw_dropcap" qualifiers="const"> - <return type="void"> - </return> - <argument index="0" name="canvas" type="RID"> - </argument> - <argument index="1" name="pos" type="Vector2"> - </argument> - <argument index="2" name="color" type="Color" default="Color(1, 1, 1, 1)"> - </argument> + <return type="void" /> + <argument index="0" name="canvas" type="RID" /> + <argument index="1" name="pos" type="Vector2" /> + <argument index="2" name="color" type="Color" default="Color(1, 1, 1, 1)" /> <description> Draw drop cap into a canvas item at a given position, with [code]color[/code]. [code]pos[/code] specifies the top left corner of the bounding box. </description> </method> <method name="draw_dropcap_outline" qualifiers="const"> - <return type="void"> - </return> - <argument index="0" name="canvas" type="RID"> - </argument> - <argument index="1" name="pos" type="Vector2"> - </argument> - <argument index="2" name="outline_size" type="int" default="1"> - </argument> - <argument index="3" name="color" type="Color" default="Color(1, 1, 1, 1)"> - </argument> + <return type="void" /> + <argument index="0" name="canvas" type="RID" /> + <argument index="1" name="pos" type="Vector2" /> + <argument index="2" name="outline_size" type="int" default="1" /> + <argument index="3" name="color" type="Color" default="Color(1, 1, 1, 1)" /> <description> Draw drop cap outline into a canvas item at a given position, with [code]color[/code]. [code]pos[/code] specifies the top left corner of the bounding box. </description> </method> <method name="draw_line" qualifiers="const"> - <return type="void"> - </return> - <argument index="0" name="canvas" type="RID"> - </argument> - <argument index="1" name="pos" type="Vector2"> - </argument> - <argument index="2" name="line" type="int"> - </argument> - <argument index="3" name="color" type="Color" default="Color(1, 1, 1, 1)"> - </argument> + <return type="void" /> + <argument index="0" name="canvas" type="RID" /> + <argument index="1" name="pos" type="Vector2" /> + <argument index="2" name="line" type="int" /> + <argument index="3" name="color" type="Color" default="Color(1, 1, 1, 1)" /> <description> Draw single line of text into a canvas item at a given position, with [code]color[/code]. [code]pos[/code] specifies the top left corner of the bounding box. </description> </method> <method name="draw_line_outline" qualifiers="const"> - <return type="void"> - </return> - <argument index="0" name="canvas" type="RID"> - </argument> - <argument index="1" name="pos" type="Vector2"> - </argument> - <argument index="2" name="line" type="int"> - </argument> - <argument index="3" name="outline_size" type="int" default="1"> - </argument> - <argument index="4" name="color" type="Color" default="Color(1, 1, 1, 1)"> - </argument> + <return type="void" /> + <argument index="0" name="canvas" type="RID" /> + <argument index="1" name="pos" type="Vector2" /> + <argument index="2" name="line" type="int" /> + <argument index="3" name="outline_size" type="int" default="1" /> + <argument index="4" name="color" type="Color" default="Color(1, 1, 1, 1)" /> <description> Draw outline of the single line of text into a canvas item at a given position, with [code]color[/code]. [code]pos[/code] specifies the top left corner of the bounding box. </description> </method> <method name="draw_outline" qualifiers="const"> - <return type="void"> - </return> - <argument index="0" name="canvas" type="RID"> - </argument> - <argument index="1" name="pos" type="Vector2"> - </argument> - <argument index="2" name="outline_size" type="int" default="1"> - </argument> - <argument index="3" name="color" type="Color" default="Color(1, 1, 1, 1)"> - </argument> - <argument index="4" name="dc_color" type="Color" default="Color(1, 1, 1, 1)"> - </argument> + <return type="void" /> + <argument index="0" name="canvas" type="RID" /> + <argument index="1" name="pos" type="Vector2" /> + <argument index="2" name="outline_size" type="int" default="1" /> + <argument index="3" name="color" type="Color" default="Color(1, 1, 1, 1)" /> + <argument index="4" name="dc_color" type="Color" default="Color(1, 1, 1, 1)" /> <description> Draw outlines of all lines of the text and drop cap into a canvas item at a given position, with [code]color[/code]. [code]pos[/code] specifies the top left corner of the bounding box. </description> </method> <method name="get_dropcap_lines" qualifiers="const"> - <return type="int"> - </return> + <return type="int" /> <description> Returns number of lines used by dropcap. </description> </method> <method name="get_dropcap_rid" qualifiers="const"> - <return type="RID"> - </return> + <return type="RID" /> <description> Return drop cap text buffer RID. </description> </method> <method name="get_dropcap_size" qualifiers="const"> - <return type="Vector2"> - </return> + <return type="Vector2" /> <description> Returns drop cap bounding box size. </description> </method> <method name="get_line_ascent" qualifiers="const"> - <return type="float"> - </return> - <argument index="0" name="line" type="int"> - </argument> + <return type="float" /> + <argument index="0" name="line" type="int" /> <description> Returns the text line ascent (number of pixels above the baseline for horizontal layout or to the left of baseline for vertical). </description> </method> <method name="get_line_count" qualifiers="const"> - <return type="int"> - </return> + <return type="int" /> <description> Returns number of lines in the paragraph. </description> </method> <method name="get_line_descent" qualifiers="const"> - <return type="float"> - </return> - <argument index="0" name="line" type="int"> - </argument> + <return type="float" /> + <argument index="0" name="line" type="int" /> <description> Returns the text line descent (number of pixels below the baseline for horizontal layout or to the right of baseline for vertical). </description> </method> <method name="get_line_object_rect" qualifiers="const"> - <return type="Rect2"> - </return> - <argument index="0" name="line" type="int"> - </argument> - <argument index="1" name="key" type="Variant"> - </argument> + <return type="Rect2" /> + <argument index="0" name="line" type="int" /> + <argument index="1" name="key" type="Variant" /> <description> Returns bounding rectangle of the inline object. </description> </method> <method name="get_line_objects" qualifiers="const"> - <return type="Array"> - </return> - <argument index="0" name="line" type="int"> - </argument> + <return type="Array" /> + <argument index="0" name="line" type="int" /> <description> Returns array of inline objects in the line. </description> </method> <method name="get_line_range" qualifiers="const"> - <return type="Vector2i"> - </return> - <argument index="0" name="line" type="int"> - </argument> + <return type="Vector2i" /> + <argument index="0" name="line" type="int" /> <description> Returns character range of the line. </description> </method> <method name="get_line_rid" qualifiers="const"> - <return type="RID"> - </return> - <argument index="0" name="line" type="int"> - </argument> + <return type="RID" /> + <argument index="0" name="line" type="int" /> <description> Returns TextServer line buffer RID. </description> </method> <method name="get_line_size" qualifiers="const"> - <return type="Vector2"> - </return> - <argument index="0" name="line" type="int"> - </argument> + <return type="Vector2" /> + <argument index="0" name="line" type="int" /> <description> Returns size of the bounding box of the line of text. </description> </method> <method name="get_line_underline_position" qualifiers="const"> - <return type="float"> - </return> - <argument index="0" name="line" type="int"> - </argument> + <return type="float" /> + <argument index="0" name="line" type="int" /> <description> Returns pixel offset of the underline below the baseline. </description> </method> <method name="get_line_underline_thickness" qualifiers="const"> - <return type="float"> - </return> - <argument index="0" name="line" type="int"> - </argument> + <return type="float" /> + <argument index="0" name="line" type="int" /> <description> Returns thickness of the underline. </description> </method> <method name="get_line_width" qualifiers="const"> - <return type="float"> - </return> - <argument index="0" name="line" type="int"> - </argument> + <return type="float" /> + <argument index="0" name="line" type="int" /> <description> Returns width (for horizontal layout) or height (for vertical) of the line of text. </description> </method> <method name="get_non_wraped_size" qualifiers="const"> - <return type="Vector2"> - </return> + <return type="Vector2" /> <description> Returns the size of the bounding box of the paragraph, without line breaks. </description> </method> <method name="get_rid" qualifiers="const"> - <return type="RID"> - </return> + <return type="RID" /> <description> Returns TextServer full string buffer RID. </description> </method> <method name="get_size" qualifiers="const"> - <return type="Vector2"> - </return> + <return type="Vector2" /> <description> Returns the size of the bounding box of the paragraph. </description> </method> <method name="get_spacing_bottom" qualifiers="const"> - <return type="int"> - </return> + <return type="int" /> <description> Returns extra spacing at the bottom of the line. See [member Font.extra_spacing_bottom]. </description> </method> <method name="get_spacing_top" qualifiers="const"> - <return type="int"> - </return> + <return type="int" /> <description> Returns extra spacing at the top of the line. See [member Font.extra_spacing_top]. </description> </method> <method name="hit_test" qualifiers="const"> - <return type="int"> - </return> - <argument index="0" name="coords" type="Vector2"> - </argument> + <return type="int" /> + <argument index="0" name="coords" type="Vector2" /> <description> Returns caret character offset at the specified coordinates. This function always returns a valid position. </description> </method> <method name="resize_object"> - <return type="bool"> - </return> - <argument index="0" name="key" type="Variant"> - </argument> - <argument index="1" name="size" type="Vector2"> - </argument> - <argument index="2" name="inline_align" type="int" enum="VAlign" default="1"> - </argument> + <return type="bool" /> + <argument index="0" name="key" type="Variant" /> + <argument index="1" name="size" type="Vector2" /> + <argument index="2" name="inline_align" type="int" enum="VAlign" default="1" /> <description> Sets new size and alignment of embedded object. </description> </method> <method name="set_bidi_override"> - <return type="void"> - </return> - <argument index="0" name="override" type="Array"> - </argument> + <return type="void" /> + <argument index="0" name="override" type="Array" /> <description> Overrides BiDi for the structured text. Override ranges should cover full source text without overlaps. BiDi algorithm will be used on each range separately. </description> </method> <method name="set_dropcap"> - <return type="bool"> - </return> - <argument index="0" name="text" type="String"> - </argument> - <argument index="1" name="fonts" type="Font"> - </argument> - <argument index="2" name="size" type="int"> - </argument> - <argument index="3" name="dropcap_margins" type="Rect2" default="Rect2(0, 0, 0, 0)"> - </argument> + <return type="bool" /> + <argument index="0" name="text" type="String" /> + <argument index="1" name="fonts" type="Font" /> + <argument index="2" name="size" type="int" /> + <argument index="3" name="dropcap_margins" type="Rect2" default="Rect2(0, 0, 0, 0)" /> <argument index="4" name="opentype_features" type="Dictionary" default="{ -}"> - </argument> - <argument index="5" name="language" type="String" default=""""> - </argument> +}" /> + <argument index="5" name="language" type="String" default="""" /> <description> Sets drop cap, overrides previously set drop cap. Drop cap (dropped capital) is a decorative element at the beginning of a paragraph that is larger than the rest of the text. </description> </method> <method name="tab_align"> - <return type="void"> - </return> - <argument index="0" name="tab_stops" type="PackedFloat32Array"> - </argument> + <return type="void" /> + <argument index="0" name="tab_stops" type="PackedFloat32Array" /> <description> Aligns paragraph to the given tab-stops. </description> diff --git a/doc/classes/TextServer.xml b/doc/classes/TextServer.xml index 0f9318fda1..dbf7ae93aa 100644 --- a/doc/classes/TextServer.xml +++ b/doc/classes/TextServer.xml @@ -10,51 +10,37 @@ </tutorials> <methods> <method name="create_font_bitmap"> - <return type="RID"> - </return> - <argument index="0" name="height" type="float"> - </argument> - <argument index="1" name="ascent" type="float"> - </argument> - <argument index="2" name="base_size" type="int"> - </argument> + <return type="RID" /> + <argument index="0" name="height" type="float" /> + <argument index="1" name="ascent" type="float" /> + <argument index="2" name="base_size" type="int" /> <description> Creates new, empty bitmap font. To free the resulting font, use [method free_rid] method. </description> </method> <method name="create_font_memory"> - <return type="RID"> - </return> - <argument index="0" name="data" type="PackedByteArray"> - </argument> - <argument index="1" name="type" type="String"> - </argument> - <argument index="2" name="base_size" type="int" default="16"> - </argument> + <return type="RID" /> + <argument index="0" name="data" type="PackedByteArray" /> + <argument index="1" name="type" type="String" /> + <argument index="2" name="base_size" type="int" default="16" /> <description> Creates new font from the data in memory. To free the resulting font, use [method free_rid] method. Note: For non-scalable fonts [code]base_size[/code] is ignored, use [method font_get_base_size] to check actual font size. </description> </method> <method name="create_font_resource"> - <return type="RID"> - </return> - <argument index="0" name="filename" type="String"> - </argument> - <argument index="1" name="base_size" type="int" default="16"> - </argument> + <return type="RID" /> + <argument index="0" name="filename" type="String" /> + <argument index="1" name="base_size" type="int" default="16" /> <description> Creates new font from the file. To free the resulting font, use [method free_rid] method. Note: For non-scalable fonts [code]base_size[/code] is ignored, use [method font_get_base_size] to check actual font size. </description> </method> <method name="create_font_system"> - <return type="RID"> - </return> - <argument index="0" name="name" type="String"> - </argument> - <argument index="1" name="base_size" type="int" default="16"> - </argument> + <return type="RID" /> + <argument index="0" name="name" type="String" /> + <argument index="1" name="base_size" type="int" default="16" /> <description> Creates new font from the system font. To free the resulting font, use [method free_rid] method. Note: This method is supported by servers with the [code]FEATURE_FONT_SYSTEM[/code] feature. @@ -62,12 +48,9 @@ </description> </method> <method name="create_shaped_text"> - <return type="RID"> - </return> - <argument index="0" name="direction" type="int" enum="TextServer.Direction" default="0"> - </argument> - <argument index="1" name="orientation" type="int" enum="TextServer.Orientation" default="0"> - </argument> + <return type="RID" /> + <argument index="0" name="direction" type="int" enum="TextServer.Direction" default="0" /> + <argument index="1" name="orientation" type="int" enum="TextServer.Orientation" default="0" /> <description> Creates new buffer for complex text layout, with the given [code]direction[/code] and [code]orientation[/code]. To free the resulting buffer, use [method free_rid] method. Note: Direction is ignored if server does not support [code]FEATURE_BIDI_LAYOUT[/code] feature. @@ -75,198 +58,138 @@ </description> </method> <method name="draw_hex_code_box" qualifiers="const"> - <return type="void"> - </return> - <argument index="0" name="canvas" type="RID"> - </argument> - <argument index="1" name="size" type="int"> - </argument> - <argument index="2" name="pos" type="Vector2"> - </argument> - <argument index="3" name="index" type="int"> - </argument> - <argument index="4" name="color" type="Color"> - </argument> + <return type="void" /> + <argument index="0" name="canvas" type="RID" /> + <argument index="1" name="size" type="int" /> + <argument index="2" name="pos" type="Vector2" /> + <argument index="3" name="index" type="int" /> + <argument index="4" name="color" type="Color" /> <description> Draws box displaying character hexadecimal code. Used for replacing missing characters. </description> </method> <method name="font_bitmap_add_char"> - <return type="void"> - </return> - <argument index="0" name="font" type="RID"> - </argument> - <argument index="1" name="char" type="int"> - </argument> - <argument index="2" name="texture_idx" type="int"> - </argument> - <argument index="3" name="rect" type="Rect2"> - </argument> - <argument index="4" name="align" type="Vector2"> - </argument> - <argument index="5" name="advance" type="float"> - </argument> + <return type="void" /> + <argument index="0" name="font" type="RID" /> + <argument index="1" name="char" type="int" /> + <argument index="2" name="texture_idx" type="int" /> + <argument index="3" name="rect" type="Rect2" /> + <argument index="4" name="align" type="Vector2" /> + <argument index="5" name="advance" type="float" /> <description> Adds a character to the font, where [code]character[/code] is the Unicode value, [code]texture[/code] is the texture index, [code]rect[/code] is the region in the texture (in pixels!), [code]align[/code] is the (optional) alignment for the character and [code]advance[/code] is the (optional) advance. </description> </method> <method name="font_bitmap_add_kerning_pair"> - <return type="void"> - </return> - <argument index="0" name="font" type="RID"> - </argument> - <argument index="1" name="A" type="int"> - </argument> - <argument index="2" name="B" type="int"> - </argument> - <argument index="3" name="kerning" type="int"> - </argument> + <return type="void" /> + <argument index="0" name="font" type="RID" /> + <argument index="1" name="A" type="int" /> + <argument index="2" name="B" type="int" /> + <argument index="3" name="kerning" type="int" /> <description> Adds a kerning pair to the bitmap font as a difference. Kerning pairs are special cases where a typeface advance is determined by the next character. </description> </method> <method name="font_bitmap_add_texture"> - <return type="void"> - </return> - <argument index="0" name="font" type="RID"> - </argument> - <argument index="1" name="texture" type="Texture"> - </argument> + <return type="void" /> + <argument index="0" name="font" type="RID" /> + <argument index="1" name="texture" type="Texture" /> <description> Adds a texture to the bitmap font. </description> </method> <method name="font_draw_glyph" qualifiers="const"> - <return type="Vector2"> - </return> - <argument index="0" name="font" type="RID"> - </argument> - <argument index="1" name="canvas" type="RID"> - </argument> - <argument index="2" name="size" type="int"> - </argument> - <argument index="3" name="pos" type="Vector2"> - </argument> - <argument index="4" name="index" type="int"> - </argument> - <argument index="5" name="color" type="Color" default="Color(1, 1, 1, 1)"> - </argument> + <return type="Vector2" /> + <argument index="0" name="font" type="RID" /> + <argument index="1" name="canvas" type="RID" /> + <argument index="2" name="size" type="int" /> + <argument index="3" name="pos" type="Vector2" /> + <argument index="4" name="index" type="int" /> + <argument index="5" name="color" type="Color" default="Color(1, 1, 1, 1)" /> <description> Draws single glyph into a canvas item at the position, using [code]font[/code] at the size [code]size[/code]. Note: Glyph index is specific to the font, use glyphs indices returned by [method shaped_text_get_glyphs] or [method font_get_glyph_index]. </description> </method> <method name="font_draw_glyph_outline" qualifiers="const"> - <return type="Vector2"> - </return> - <argument index="0" name="font" type="RID"> - </argument> - <argument index="1" name="canvas" type="RID"> - </argument> - <argument index="2" name="size" type="int"> - </argument> - <argument index="3" name="outline_size" type="int"> - </argument> - <argument index="4" name="pos" type="Vector2"> - </argument> - <argument index="5" name="index" type="int"> - </argument> - <argument index="6" name="color" type="Color" default="Color(1, 1, 1, 1)"> - </argument> + <return type="Vector2" /> + <argument index="0" name="font" type="RID" /> + <argument index="1" name="canvas" type="RID" /> + <argument index="2" name="size" type="int" /> + <argument index="3" name="outline_size" type="int" /> + <argument index="4" name="pos" type="Vector2" /> + <argument index="5" name="index" type="int" /> + <argument index="6" name="color" type="Color" default="Color(1, 1, 1, 1)" /> <description> Draws single glyph outline of size [code]outline_size[/code] into a canvas item at the position, using [code]font[/code] at the size [code]size[/code]. Note: Glyph index is specific to the font, use glyphs indices returned by [method shaped_text_get_glyphs] or [method font_get_glyph_index]. </description> </method> <method name="font_get_antialiased" qualifiers="const"> - <return type="bool"> - </return> - <argument index="0" name="font" type="RID"> - </argument> + <return type="bool" /> + <argument index="0" name="font" type="RID" /> <description> Returns [code]true[/code], if font anti-aliasing is supported and enabled. </description> </method> <method name="font_get_ascent" qualifiers="const"> - <return type="float"> - </return> - <argument index="0" name="font" type="RID"> - </argument> - <argument index="1" name="size" type="int"> - </argument> + <return type="float" /> + <argument index="0" name="font" type="RID" /> + <argument index="1" name="size" type="int" /> <description> Returns the font ascent (number of pixels above the baseline). </description> </method> <method name="font_get_base_size" qualifiers="const"> - <return type="float"> - </return> - <argument index="0" name="font" type="RID"> - </argument> + <return type="float" /> + <argument index="0" name="font" type="RID" /> <description> Returns the default size of the font. </description> </method> <method name="font_get_descent" qualifiers="const"> - <return type="float"> - </return> - <argument index="0" name="font" type="RID"> - </argument> - <argument index="1" name="size" type="int"> - </argument> + <return type="float" /> + <argument index="0" name="font" type="RID" /> + <argument index="1" name="size" type="int" /> <description> Returns the font descent (number of pixels below the baseline). </description> </method> <method name="font_get_distance_field_hint" qualifiers="const"> - <return type="bool"> - </return> - <argument index="0" name="font" type="RID"> - </argument> + <return type="bool" /> + <argument index="0" name="font" type="RID" /> <description> Returns [code]true[/code], if distance field hint is enabled. </description> </method> <method name="font_get_feature_list" qualifiers="const"> - <return type="Dictionary"> - </return> - <argument index="0" name="font" type="RID"> - </argument> + <return type="Dictionary" /> + <argument index="0" name="font" type="RID" /> <description> Returns list of OpenType features supported by font. </description> </method> <method name="font_get_force_autohinter" qualifiers="const"> - <return type="bool"> - </return> - <argument index="0" name="font" type="RID"> - </argument> + <return type="bool" /> + <argument index="0" name="font" type="RID" /> <description> Returns [code]true[/code], if autohinter is supported and enabled. </description> </method> <method name="font_get_glyph_advance" qualifiers="const"> - <return type="Vector2"> - </return> - <argument index="0" name="font" type="RID"> - </argument> - <argument index="1" name="index" type="int"> - </argument> - <argument index="2" name="size" type="int"> - </argument> + <return type="Vector2" /> + <argument index="0" name="font" type="RID" /> + <argument index="1" name="index" type="int" /> + <argument index="2" name="size" type="int" /> <description> Returns advance of the glyph. </description> </method> <method name="font_get_glyph_contours" qualifiers="const"> - <return type="Dictionary"> - </return> - <argument index="0" name="font" type="RID"> - </argument> - <argument index="1" name="size" type="int"> - </argument> - <argument index="2" name="index" type="int"> - </argument> + <return type="Dictionary" /> + <argument index="0" name="font" type="RID" /> + <argument index="1" name="size" type="int" /> + <argument index="2" name="index" type="int" /> <description> Returns outline contours of the glyph in a Dictionary. [code]points[/code] - [PackedVector3Array], containing outline points. [code]x[/code] and [code]y[/code] are point coordinates. [code]z[/code] is the type of the point, using the [enum ContourPointTag] values. @@ -275,955 +198,701 @@ </description> </method> <method name="font_get_glyph_index" qualifiers="const"> - <return type="int"> - </return> - <argument index="0" name="font" type="RID"> - </argument> - <argument index="1" name="char" type="int"> - </argument> - <argument index="2" name="variation_selector" type="int" default="0"> - </argument> + <return type="int" /> + <argument index="0" name="font" type="RID" /> + <argument index="1" name="char" type="int" /> + <argument index="2" name="variation_selector" type="int" default="0" /> <description> Returns the glyph index of a [code]char[/code], optionally modified by the [code]variation_selector[/code]. </description> </method> <method name="font_get_glyph_kerning" qualifiers="const"> - <return type="Vector2"> - </return> - <argument index="0" name="font" type="RID"> - </argument> - <argument index="1" name="index_a" type="int"> - </argument> - <argument index="2" name="index_b" type="int"> - </argument> - <argument index="3" name="size" type="int"> - </argument> + <return type="Vector2" /> + <argument index="0" name="font" type="RID" /> + <argument index="1" name="index_a" type="int" /> + <argument index="2" name="index_b" type="int" /> + <argument index="3" name="size" type="int" /> <description> Returns a kerning of the pair of glyphs. </description> </method> <method name="font_get_height" qualifiers="const"> - <return type="float"> - </return> - <argument index="0" name="font" type="RID"> - </argument> - <argument index="1" name="size" type="int"> - </argument> + <return type="float" /> + <argument index="0" name="font" type="RID" /> + <argument index="1" name="size" type="int" /> <description> Returns the total font height (ascent plus descent) in pixels. </description> </method> <method name="font_get_hinting" qualifiers="const"> - <return type="int" enum="TextServer.Hinting"> - </return> - <argument index="0" name="font" type="RID"> - </argument> + <return type="int" enum="TextServer.Hinting" /> + <argument index="0" name="font" type="RID" /> <description> Returns the font hinting. </description> </method> <method name="font_get_language_support_override"> - <return type="bool"> - </return> - <argument index="0" name="font" type="RID"> - </argument> - <argument index="1" name="language" type="String"> - </argument> + <return type="bool" /> + <argument index="0" name="font" type="RID" /> + <argument index="1" name="language" type="String" /> <description> Returns [code]true[/code] if support override is enabled for the [code]language[/code]. </description> </method> <method name="font_get_language_support_overrides"> - <return type="PackedStringArray"> - </return> - <argument index="0" name="font" type="RID"> - </argument> + <return type="PackedStringArray" /> + <argument index="0" name="font" type="RID" /> <description> Returns list of language support overrides. </description> </method> <method name="font_get_oversampling" qualifiers="const"> - <return type="float"> - </return> + <return type="float" /> <description> Returns the font oversampling factor, shared by all fonts in the TextServer. </description> </method> <method name="font_get_script_support_override"> - <return type="bool"> - </return> - <argument index="0" name="font" type="RID"> - </argument> - <argument index="1" name="script" type="String"> - </argument> + <return type="bool" /> + <argument index="0" name="font" type="RID" /> + <argument index="1" name="script" type="String" /> <description> Returns [code]true[/code] if support override is enabled for the [code]script[/code]. </description> </method> <method name="font_get_script_support_overrides"> - <return type="PackedStringArray"> - </return> - <argument index="0" name="font" type="RID"> - </argument> + <return type="PackedStringArray" /> + <argument index="0" name="font" type="RID" /> <description> Returns list of script support overrides. </description> </method> <method name="font_get_spacing_glyph" qualifiers="const"> - <return type="int"> - </return> - <argument index="0" name="font" type="RID"> - </argument> + <return type="int" /> + <argument index="0" name="font" type="RID" /> <description> Returns extra spacing for each glyph in pixels. </description> </method> <method name="font_get_spacing_space" qualifiers="const"> - <return type="int"> - </return> - <argument index="0" name="font" type="RID"> - </argument> + <return type="int" /> + <argument index="0" name="font" type="RID" /> <description> Sets extra spacing for each glyph in pixels. </description> </method> <method name="font_get_supported_chars" qualifiers="const"> - <return type="String"> - </return> - <argument index="0" name="font" type="RID"> - </argument> + <return type="String" /> + <argument index="0" name="font" type="RID" /> <description> Returns a string containing all the characters available in the font. </description> </method> <method name="font_get_underline_position" qualifiers="const"> - <return type="float"> - </return> - <argument index="0" name="font" type="RID"> - </argument> - <argument index="1" name="size" type="int"> - </argument> + <return type="float" /> + <argument index="0" name="font" type="RID" /> + <argument index="1" name="size" type="int" /> <description> Returns underline offset (number of pixels below the baseline). </description> </method> <method name="font_get_underline_thickness" qualifiers="const"> - <return type="float"> - </return> - <argument index="0" name="font" type="RID"> - </argument> - <argument index="1" name="size" type="int"> - </argument> + <return type="float" /> + <argument index="0" name="font" type="RID" /> + <argument index="1" name="size" type="int" /> <description> Returns underline thickness in pixels. </description> </method> <method name="font_get_variation" qualifiers="const"> - <return type="float"> - </return> - <argument index="0" name="font" type="RID"> - </argument> - <argument index="1" name="tag" type="String"> - </argument> + <return type="float" /> + <argument index="0" name="font" type="RID" /> + <argument index="1" name="tag" type="String" /> <description> Returns variation coordinate [code]tag[/code]. </description> </method> <method name="font_get_variation_list" qualifiers="const"> - <return type="Dictionary"> - </return> - <argument index="0" name="font" type="RID"> - </argument> + <return type="Dictionary" /> + <argument index="0" name="font" type="RID" /> <description> Returns list of supported [url=https://docs.microsoft.com/en-us/typography/opentype/spec/dvaraxisreg]variation coordinates[/url], each coordinate is returned as [code]tag: Vector3i(min_value,max_value,default_value)[/code]. Font variations allow for continuous change of glyph characteristics along some given design axis, such as weight, width or slant. </description> </method> <method name="font_has_char" qualifiers="const"> - <return type="bool"> - </return> - <argument index="0" name="font" type="RID"> - </argument> - <argument index="1" name="char" type="int"> - </argument> + <return type="bool" /> + <argument index="0" name="font" type="RID" /> + <argument index="1" name="char" type="int" /> <description> Returns [code]true[/code] if [code]char[/code] is available in the font. </description> </method> <method name="font_has_outline" qualifiers="const"> - <return type="bool"> - </return> - <argument index="0" name="font" type="RID"> - </argument> + <return type="bool" /> + <argument index="0" name="font" type="RID" /> <description> Returns [code]true[/code], if font supports glyph outlines. </description> </method> <method name="font_is_language_supported" qualifiers="const"> - <return type="bool"> - </return> - <argument index="0" name="font" type="RID"> - </argument> - <argument index="1" name="language" type="String"> - </argument> + <return type="bool" /> + <argument index="0" name="font" type="RID" /> + <argument index="1" name="language" type="String" /> <description> Returns [code]true[/code], if font supports given language (ISO 639 code). </description> </method> <method name="font_is_script_supported" qualifiers="const"> - <return type="bool"> - </return> - <argument index="0" name="font" type="RID"> - </argument> - <argument index="1" name="script" type="String"> - </argument> + <return type="bool" /> + <argument index="0" name="font" type="RID" /> + <argument index="1" name="script" type="String" /> <description> Returns [code]true[/code], if font supports given script (ISO 15924 code). </description> </method> <method name="font_remove_language_support_override"> - <return type="void"> - </return> - <argument index="0" name="font" type="RID"> - </argument> - <argument index="1" name="language" type="String"> - </argument> + <return type="void" /> + <argument index="0" name="font" type="RID" /> + <argument index="1" name="language" type="String" /> <description> Remove language support override. </description> </method> <method name="font_remove_script_support_override"> - <return type="void"> - </return> - <argument index="0" name="font" type="RID"> - </argument> - <argument index="1" name="script" type="String"> - </argument> + <return type="void" /> + <argument index="0" name="font" type="RID" /> + <argument index="1" name="script" type="String" /> <description> Removes script support override. </description> </method> <method name="font_set_antialiased"> - <return type="void"> - </return> - <argument index="0" name="font" type="RID"> - </argument> - <argument index="1" name="antialiased" type="bool"> - </argument> + <return type="void" /> + <argument index="0" name="font" type="RID" /> + <argument index="1" name="antialiased" type="bool" /> <description> Sets font anti-aliasing. </description> </method> <method name="font_set_distance_field_hint"> - <return type="void"> - </return> - <argument index="0" name="font" type="RID"> - </argument> - <argument index="1" name="distance_field" type="bool"> - </argument> + <return type="void" /> + <argument index="0" name="font" type="RID" /> + <argument index="1" name="distance_field" type="bool" /> <description> Sets font distance field hint. </description> </method> <method name="font_set_force_autohinter"> - <return type="void"> - </return> - <argument index="0" name="font" type="RID"> - </argument> - <argument index="1" name="enabeld" type="bool"> - </argument> + <return type="void" /> + <argument index="0" name="font" type="RID" /> + <argument index="1" name="enabeld" type="bool" /> <description> Enables/disables default autohinter. </description> </method> <method name="font_set_hinting"> - <return type="void"> - </return> - <argument index="0" name="font" type="RID"> - </argument> - <argument index="1" name="hinting" type="int" enum="TextServer.Hinting"> - </argument> + <return type="void" /> + <argument index="0" name="font" type="RID" /> + <argument index="1" name="hinting" type="int" enum="TextServer.Hinting" /> <description> Sets font hinting. </description> </method> <method name="font_set_language_support_override"> - <return type="void"> - </return> - <argument index="0" name="font" type="RID"> - </argument> - <argument index="1" name="language" type="String"> - </argument> - <argument index="2" name="supported" type="bool"> - </argument> + <return type="void" /> + <argument index="0" name="font" type="RID" /> + <argument index="1" name="language" type="String" /> + <argument index="2" name="supported" type="bool" /> <description> Adds override for [method font_is_language_supported]. </description> </method> <method name="font_set_oversampling"> - <return type="void"> - </return> - <argument index="0" name="oversampling" type="float"> - </argument> + <return type="void" /> + <argument index="0" name="oversampling" type="float" /> <description> Sets oversampling factor, shared by all font in the TextServer. </description> </method> <method name="font_set_script_support_override"> - <return type="void"> - </return> - <argument index="0" name="font" type="RID"> - </argument> - <argument index="1" name="script" type="String"> - </argument> - <argument index="2" name="supported" type="bool"> - </argument> + <return type="void" /> + <argument index="0" name="font" type="RID" /> + <argument index="1" name="script" type="String" /> + <argument index="2" name="supported" type="bool" /> <description> Adds override for [method font_is_script_supported]. </description> </method> <method name="font_set_spacing_glyph"> - <return type="void"> - </return> - <argument index="0" name="font" type="RID"> - </argument> - <argument index="1" name="value" type="int"> - </argument> + <return type="void" /> + <argument index="0" name="font" type="RID" /> + <argument index="1" name="value" type="int" /> <description> Returns extra spacing for the space character in pixels. </description> </method> <method name="font_set_spacing_space"> - <return type="void"> - </return> - <argument index="0" name="font" type="RID"> - </argument> - <argument index="1" name="value" type="int"> - </argument> + <return type="void" /> + <argument index="0" name="font" type="RID" /> + <argument index="1" name="value" type="int" /> <description> Sets extra spacing for the space character in pixels. </description> </method> <method name="font_set_variation"> - <return type="void"> - </return> - <argument index="0" name="font" type="RID"> - </argument> - <argument index="1" name="tag" type="String"> - </argument> - <argument index="2" name="value" type="float"> - </argument> + <return type="void" /> + <argument index="0" name="font" type="RID" /> + <argument index="1" name="tag" type="String" /> + <argument index="2" name="value" type="float" /> <description> Sets variation coordinate [code]name[/code]. Unsupported coordinates will be silently ignored. </description> </method> <method name="format_number" qualifiers="const"> - <return type="String"> - </return> - <argument index="0" name="number" type="String"> - </argument> - <argument index="1" name="language" type="String" default=""""> - </argument> + <return type="String" /> + <argument index="0" name="number" type="String" /> + <argument index="1" name="language" type="String" default="""" /> <description> Converts a number from the Western Arabic (0..9) to the numeral systems used in [code]language[/code]. </description> </method> <method name="free_rid"> - <return type="void"> - </return> - <argument index="0" name="rid" type="RID"> - </argument> + <return type="void" /> + <argument index="0" name="rid" type="RID" /> <description> Frees an object created by this [TextServer]. </description> </method> <method name="get_hex_code_box_size" qualifiers="const"> - <return type="Vector2"> - </return> - <argument index="0" name="size" type="int"> - </argument> - <argument index="1" name="index" type="int"> - </argument> + <return type="Vector2" /> + <argument index="0" name="size" type="int" /> + <argument index="1" name="index" type="int" /> <description> Returns size of the replacement character (box with character hexadecimal code that is drawn in place of invalid characters). </description> </method> <method name="get_name" qualifiers="const"> - <return type="String"> - </return> + <return type="String" /> <description> Returns the name of the server interface. </description> </method> <method name="get_system_fonts" qualifiers="const"> - <return type="PackedStringArray"> - </return> + <return type="PackedStringArray" /> <description> Returns list of available system fonts. Note: This method is supported by servers with the [code]FEATURE_FONT_SYSTEM[/code] feature. </description> </method> <method name="has"> - <return type="bool"> - </return> - <argument index="0" name="rid" type="RID"> - </argument> + <return type="bool" /> + <argument index="0" name="rid" type="RID" /> <description> Returns [code]true[/code] if [code]rid[/code] is valid resource owned by this text server. </description> </method> <method name="has_feature"> - <return type="bool"> - </return> - <argument index="0" name="feature" type="int" enum="TextServer.Feature"> - </argument> + <return type="bool" /> + <argument index="0" name="feature" type="int" enum="TextServer.Feature" /> <description> Returns [code]true[/code] if the server supports a feature. </description> </method> <method name="is_locale_right_to_left"> - <return type="bool"> - </return> - <argument index="0" name="locale" type="String"> - </argument> + <return type="bool" /> + <argument index="0" name="locale" type="String" /> <description> Returns [code]true[/code] if locale is right-to-left. </description> </method> <method name="load_support_data"> - <return type="bool"> - </return> - <argument index="0" name="filename" type="String"> - </argument> + <return type="bool" /> + <argument index="0" name="filename" type="String" /> <description> Loads optional TextServer database (e.g. ICU break iterators and dictionaries). Note: This function should be called before any other TextServer functions used, otherwise it won't have any effect. </description> </method> <method name="name_to_tag"> - <return type="int"> - </return> - <argument index="0" name="name" type="String"> - </argument> + <return type="int" /> + <argument index="0" name="name" type="String" /> <description> Converts readable feature, variation, script or language name to OpenType tag. </description> </method> <method name="parse_number" qualifiers="const"> - <return type="String"> - </return> - <argument index="0" name="number" type="String"> - </argument> - <argument index="1" name="language" type="String" default=""""> - </argument> + <return type="String" /> + <argument index="0" name="number" type="String" /> + <argument index="1" name="language" type="String" default="""" /> <description> Converts a number from the numeral systems used in [code]language[/code] to Western Arabic (0..9). </description> </method> <method name="percent_sign" qualifiers="const"> - <return type="String"> - </return> - <argument index="0" name="language" type="String" default=""""> - </argument> + <return type="String" /> + <argument index="0" name="language" type="String" default="""" /> <description> Returns percent sign used in the [code]language[/code]. </description> </method> <method name="shaped_text_add_object"> - <return type="bool"> - </return> - <argument index="0" name="shaped" type="RID"> - </argument> - <argument index="1" name="key" type="Variant"> - </argument> - <argument index="2" name="size" type="Vector2"> - </argument> - <argument index="3" name="inline_align" type="int" enum="VAlign" default="1"> - </argument> - <argument index="4" name="length" type="int" default="1"> - </argument> + <return type="bool" /> + <argument index="0" name="shaped" type="RID" /> + <argument index="1" name="key" type="Variant" /> + <argument index="2" name="size" type="Vector2" /> + <argument index="3" name="inline_align" type="int" enum="VAlign" default="1" /> + <argument index="4" name="length" type="int" default="1" /> <description> Adds inline object to the text buffer, [code]key[/code] must be unique. In the text, object is represented as [code]length[/code] object replacement characters. </description> </method> <method name="shaped_text_add_string"> - <return type="bool"> - </return> - <argument index="0" name="shaped" type="RID"> - </argument> - <argument index="1" name="text" type="String"> - </argument> - <argument index="2" name="fonts" type="Array"> - </argument> - <argument index="3" name="size" type="int"> - </argument> + <return type="bool" /> + <argument index="0" name="shaped" type="RID" /> + <argument index="1" name="text" type="String" /> + <argument index="2" name="fonts" type="Array" /> + <argument index="3" name="size" type="int" /> <argument index="4" name="opentype_features" type="Dictionary" default="{ -}"> - </argument> - <argument index="5" name="language" type="String" default=""""> - </argument> +}" /> + <argument index="5" name="language" type="String" default="""" /> <description> Adds text span and font to draw it to the text buffer. </description> </method> <method name="shaped_text_clear"> - <return type="void"> - </return> - <argument index="0" name="rid" type="RID"> - </argument> + <return type="void" /> + <argument index="0" name="rid" type="RID" /> <description> Clears text buffer (removes text and inline objects). </description> </method> <method name="shaped_text_draw" qualifiers="const"> - <return type="void"> - </return> - <argument index="0" name="shaped" type="RID"> - </argument> - <argument index="1" name="canvas" type="RID"> - </argument> - <argument index="2" name="pos" type="Vector2"> - </argument> - <argument index="3" name="clip_l" type="float" default="-1"> - </argument> - <argument index="4" name="clip_r" type="float" default="-1"> - </argument> - <argument index="5" name="color" type="Color" default="Color(1, 1, 1, 1)"> - </argument> + <return type="void" /> + <argument index="0" name="shaped" type="RID" /> + <argument index="1" name="canvas" type="RID" /> + <argument index="2" name="pos" type="Vector2" /> + <argument index="3" name="clip_l" type="float" default="-1" /> + <argument index="4" name="clip_r" type="float" default="-1" /> + <argument index="5" name="color" type="Color" default="Color(1, 1, 1, 1)" /> <description> Draw shaped text into a canvas item at a given position, with [code]color[/code]. [code]pos[/code] specifies the leftmost point of the baseline (for horizontal layout) or topmost point of the baseline (for vertical layout). </description> </method> <method name="shaped_text_draw_outline" qualifiers="const"> - <return type="void"> - </return> - <argument index="0" name="shaped" type="RID"> - </argument> - <argument index="1" name="canvas" type="RID"> - </argument> - <argument index="2" name="pos" type="Vector2"> - </argument> - <argument index="3" name="clip_l" type="float" default="-1"> - </argument> - <argument index="4" name="clip_r" type="float" default="-1"> - </argument> - <argument index="5" name="outline_size" type="int" default="1"> - </argument> - <argument index="6" name="color" type="Color" default="Color(1, 1, 1, 1)"> - </argument> + <return type="void" /> + <argument index="0" name="shaped" type="RID" /> + <argument index="1" name="canvas" type="RID" /> + <argument index="2" name="pos" type="Vector2" /> + <argument index="3" name="clip_l" type="float" default="-1" /> + <argument index="4" name="clip_r" type="float" default="-1" /> + <argument index="5" name="outline_size" type="int" default="1" /> + <argument index="6" name="color" type="Color" default="Color(1, 1, 1, 1)" /> <description> Draw the outline of the shaped text into a canvas item at a given position, with [code]color[/code]. [code]pos[/code] specifies the leftmost point of the baseline (for horizontal layout) or topmost point of the baseline (for vertical layout). </description> </method> <method name="shaped_text_fit_to_width"> - <return type="float"> - </return> - <argument index="0" name="shaped" type="RID"> - </argument> - <argument index="1" name="width" type="float"> - </argument> - <argument index="2" name="jst_flags" type="int" default="3"> - </argument> + <return type="float" /> + <argument index="0" name="shaped" type="RID" /> + <argument index="1" name="width" type="float" /> + <argument index="2" name="jst_flags" type="int" default="3" /> <description> Adjusts text with to fit to specified width, returns new text width. </description> </method> <method name="shaped_text_get_ascent" qualifiers="const"> - <return type="float"> - </return> - <argument index="0" name="shaped" type="RID"> - </argument> + <return type="float" /> + <argument index="0" name="shaped" type="RID" /> <description> Returns the text ascent (number of pixels above the baseline for horizontal layout or to the left of baseline for vertical). Note: overall ascent can be higher than font ascent, if some glyphs are displaced from the baseline. </description> </method> <method name="shaped_text_get_carets" qualifiers="const"> - <return type="Dictionary"> - </return> - <argument index="0" name="shaped" type="RID"> - </argument> - <argument index="1" name="position" type="int"> - </argument> + <return type="Dictionary" /> + <argument index="0" name="shaped" type="RID" /> + <argument index="1" name="position" type="int" /> <description> Returns shapes of the carets corresponding to the character offset [code]position[/code] in the text. Returned caret shape is 1 pixel wide rectangle. </description> </method> <method name="shaped_text_get_descent" qualifiers="const"> - <return type="float"> - </return> - <argument index="0" name="shaped" type="RID"> - </argument> + <return type="float" /> + <argument index="0" name="shaped" type="RID" /> <description> Returns the text descent (number of pixels below the baseline for horizontal layout or to the right of baseline for vertical). Note: overall descent can be higher than font descent, if some glyphs are displaced from the baseline. </description> </method> <method name="shaped_text_get_direction" qualifiers="const"> - <return type="int" enum="TextServer.Direction"> - </return> - <argument index="0" name="shaped" type="RID"> - </argument> + <return type="int" enum="TextServer.Direction" /> + <argument index="0" name="shaped" type="RID" /> <description> Returns direction of the text. </description> </method> <method name="shaped_text_get_dominant_direciton_in_range" qualifiers="const"> - <return type="int" enum="TextServer.Direction"> - </return> - <argument index="0" name="shaped" type="RID"> - </argument> - <argument index="1" name="start" type="int"> - </argument> - <argument index="2" name="end" type="int"> - </argument> + <return type="int" enum="TextServer.Direction" /> + <argument index="0" name="shaped" type="RID" /> + <argument index="1" name="start" type="int" /> + <argument index="2" name="end" type="int" /> <description> Returns dominant direction of in the range of text. </description> </method> <method name="shaped_text_get_glyphs" qualifiers="const"> - <return type="Array"> - </return> - <argument index="0" name="shaped" type="RID"> - </argument> + <return type="Array" /> + <argument index="0" name="shaped" type="RID" /> <description> Returns text glyphs. </description> </method> <method name="shaped_text_get_line_breaks" qualifiers="const"> - <return type="Array"> - </return> - <argument index="0" name="shaped" type="RID"> - </argument> - <argument index="1" name="width" type="float"> - </argument> - <argument index="2" name="start" type="int" default="0"> - </argument> - <argument index="3" name="break_flags" type="int" default="48"> - </argument> + <return type="Array" /> + <argument index="0" name="shaped" type="RID" /> + <argument index="1" name="width" type="float" /> + <argument index="2" name="start" type="int" default="0" /> + <argument index="3" name="break_flags" type="int" default="48" /> <description> Breaks text to the lines and returns character ranges for each line. </description> </method> <method name="shaped_text_get_line_breaks_adv" qualifiers="const"> - <return type="Array"> - </return> - <argument index="0" name="shaped" type="RID"> - </argument> - <argument index="1" name="width" type="PackedFloat32Array"> - </argument> - <argument index="2" name="start" type="int" default="0"> - </argument> - <argument index="3" name="once" type="bool" default="true"> - </argument> - <argument index="4" name="break_flags" type="int" default="48"> - </argument> + <return type="Array" /> + <argument index="0" name="shaped" type="RID" /> + <argument index="1" name="width" type="PackedFloat32Array" /> + <argument index="2" name="start" type="int" default="0" /> + <argument index="3" name="once" type="bool" default="true" /> + <argument index="4" name="break_flags" type="int" default="48" /> <description> Breaks text to the lines and columns. Returns character ranges for each segment. </description> </method> <method name="shaped_text_get_object_rect" qualifiers="const"> - <return type="Rect2"> - </return> - <argument index="0" name="shaped" type="RID"> - </argument> - <argument index="1" name="key" type="Variant"> - </argument> + <return type="Rect2" /> + <argument index="0" name="shaped" type="RID" /> + <argument index="1" name="key" type="Variant" /> <description> Returns bounding rectangle of the inline object. </description> </method> <method name="shaped_text_get_objects" qualifiers="const"> - <return type="Array"> - </return> - <argument index="0" name="shaped" type="RID"> - </argument> + <return type="Array" /> + <argument index="0" name="shaped" type="RID" /> <description> Returns array of inline objects. </description> </method> <method name="shaped_text_get_orientation" qualifiers="const"> - <return type="int" enum="TextServer.Orientation"> - </return> - <argument index="0" name="shaped" type="RID"> - </argument> + <return type="int" enum="TextServer.Orientation" /> + <argument index="0" name="shaped" type="RID" /> <description> Returns text orientation. </description> </method> <method name="shaped_text_get_parent" qualifiers="const"> - <return type="RID"> - </return> - <argument index="0" name="shaped" type="RID"> - </argument> + <return type="RID" /> + <argument index="0" name="shaped" type="RID" /> <description> Sets text orientation. </description> </method> <method name="shaped_text_get_preserve_control" qualifiers="const"> - <return type="bool"> - </return> - <argument index="0" name="shaped" type="RID"> - </argument> + <return type="bool" /> + <argument index="0" name="shaped" type="RID" /> <description> Returns [code]true[/code] if text buffer is configured to display control characters. </description> </method> <method name="shaped_text_get_preserve_invalid" qualifiers="const"> - <return type="bool"> - </return> - <argument index="0" name="shaped" type="RID"> - </argument> + <return type="bool" /> + <argument index="0" name="shaped" type="RID" /> <description> Returns [code]true[/code] if text buffer is configured to display hexadecimal codes in place of invalid characters. Note: If set to [code]false[/code], nothing is displayed in place of invalid characters. </description> </method> <method name="shaped_text_get_range" qualifiers="const"> - <return type="Vector2i"> - </return> - <argument index="0" name="shaped" type="RID"> - </argument> + <return type="Vector2i" /> + <argument index="0" name="shaped" type="RID" /> <description> Returns substring buffer character range in the parent buffer. </description> </method> <method name="shaped_text_get_selection" qualifiers="const"> - <return type="Array"> - </return> - <argument index="0" name="shaped" type="RID"> - </argument> - <argument index="1" name="start" type="int"> - </argument> - <argument index="2" name="end" type="int"> - </argument> + <return type="Array" /> + <argument index="0" name="shaped" type="RID" /> + <argument index="1" name="start" type="int" /> + <argument index="2" name="end" type="int" /> <description> Returns selection rectangles for the specified character range. </description> </method> <method name="shaped_text_get_size" qualifiers="const"> - <return type="Vector2"> - </return> - <argument index="0" name="shaped" type="RID"> - </argument> + <return type="Vector2" /> + <argument index="0" name="shaped" type="RID" /> <description> Returns size of the text. </description> </method> <method name="shaped_text_get_underline_position" qualifiers="const"> - <return type="float"> - </return> - <argument index="0" name="shaped" type="RID"> - </argument> + <return type="float" /> + <argument index="0" name="shaped" type="RID" /> <description> Returns pixel offset of the underline below the baseline. </description> </method> <method name="shaped_text_get_underline_thickness" qualifiers="const"> - <return type="float"> - </return> - <argument index="0" name="shaped" type="RID"> - </argument> + <return type="float" /> + <argument index="0" name="shaped" type="RID" /> <description> Returns thickness of the underline. </description> </method> <method name="shaped_text_get_width" qualifiers="const"> - <return type="float"> - </return> - <argument index="0" name="shaped" type="RID"> - </argument> + <return type="float" /> + <argument index="0" name="shaped" type="RID" /> <description> Returns width (for horizontal layout) or height (for vertical) of the text. </description> </method> <method name="shaped_text_get_word_breaks" qualifiers="const"> - <return type="Array"> - </return> - <argument index="0" name="shaped" type="RID"> - </argument> + <return type="Array" /> + <argument index="0" name="shaped" type="RID" /> <description> Breaks text into words and returns array of character ranges. </description> </method> <method name="shaped_text_hit_test_grapheme" qualifiers="const"> - <return type="int"> - </return> - <argument index="0" name="shaped" type="RID"> - </argument> - <argument index="1" name="coords" type="float"> - </argument> + <return type="int" /> + <argument index="0" name="shaped" type="RID" /> + <argument index="1" name="coords" type="float" /> <description> Returns grapheme index at the specified pixel offset at the baseline, or [code]-1[/code] if none is found. </description> </method> <method name="shaped_text_hit_test_position" qualifiers="const"> - <return type="int"> - </return> - <argument index="0" name="shaped" type="RID"> - </argument> - <argument index="1" name="coords" type="float"> - </argument> + <return type="int" /> + <argument index="0" name="shaped" type="RID" /> + <argument index="1" name="coords" type="float" /> <description> Returns caret character offset at the specified pixel offset at the baseline. This function always returns a valid position. </description> </method> <method name="shaped_text_is_ready" qualifiers="const"> - <return type="bool"> - </return> - <argument index="0" name="shaped" type="RID"> - </argument> + <return type="bool" /> + <argument index="0" name="shaped" type="RID" /> <description> Returns [code]true[/code] if buffer is successfully shaped. </description> </method> <method name="shaped_text_next_grapheme_pos"> - <return type="int"> - </return> - <argument index="0" name="shaped" type="RID"> - </argument> - <argument index="1" name="pos" type="int"> - </argument> + <return type="int" /> + <argument index="0" name="shaped" type="RID" /> + <argument index="1" name="pos" type="int" /> <description> Returns composite character end position closest to the [code]pos[/code]. </description> </method> <method name="shaped_text_overrun_trim_to_width"> - <return type="void"> - </return> - <argument index="0" name="shaped" type="RID"> - </argument> - <argument index="1" name="width" type="float" default="0"> - </argument> - <argument index="2" name="overrun_trim_flags" type="int" default="0"> - </argument> + <return type="void" /> + <argument index="0" name="shaped" type="RID" /> + <argument index="1" name="width" type="float" default="0" /> + <argument index="2" name="overrun_trim_flags" type="int" default="0" /> <description> Trims text if it exceeds the given width. </description> </method> <method name="shaped_text_prev_grapheme_pos"> - <return type="int"> - </return> - <argument index="0" name="shaped" type="RID"> - </argument> - <argument index="1" name="pos" type="int"> - </argument> + <return type="int" /> + <argument index="0" name="shaped" type="RID" /> + <argument index="1" name="pos" type="int" /> <description> Returns composite character start position closest to the [code]pos[/code]. </description> </method> <method name="shaped_text_resize_object"> - <return type="bool"> - </return> - <argument index="0" name="shaped" type="RID"> - </argument> - <argument index="1" name="key" type="Variant"> - </argument> - <argument index="2" name="size" type="Vector2"> - </argument> - <argument index="3" name="inline_align" type="int" enum="VAlign" default="1"> - </argument> + <return type="bool" /> + <argument index="0" name="shaped" type="RID" /> + <argument index="1" name="key" type="Variant" /> + <argument index="2" name="size" type="Vector2" /> + <argument index="3" name="inline_align" type="int" enum="VAlign" default="1" /> <description> Sets new size and alignment of embedded object. </description> </method> <method name="shaped_text_set_bidi_override"> - <return type="void"> - </return> - <argument index="0" name="shaped" type="RID"> - </argument> - <argument index="1" name="override" type="Array"> - </argument> + <return type="void" /> + <argument index="0" name="shaped" type="RID" /> + <argument index="1" name="override" type="Array" /> <description> Overrides BiDi for the structured text. Override ranges should cover full source text without overlaps. BiDi algorithm will be used on each range separately. </description> </method> <method name="shaped_text_set_direction"> - <return type="void"> - </return> - <argument index="0" name="shaped" type="RID"> - </argument> - <argument index="1" name="direction" type="int" enum="TextServer.Direction" default="0"> - </argument> + <return type="void" /> + <argument index="0" name="shaped" type="RID" /> + <argument index="1" name="direction" type="int" enum="TextServer.Direction" default="0" /> <description> Sets desired text direction. If set to [code]TEXT_DIRECTION_AUTO[/code], direction will be detected based on the buffer contents and current locale. Note: Direction is ignored if server does not support [code]FEATURE_BIDI_LAYOUT[/code] feature. </description> </method> <method name="shaped_text_set_orientation"> - <return type="void"> - </return> - <argument index="0" name="shaped" type="RID"> - </argument> - <argument index="1" name="orientation" type="int" enum="TextServer.Orientation" default="0"> - </argument> + <return type="void" /> + <argument index="0" name="shaped" type="RID" /> + <argument index="1" name="orientation" type="int" enum="TextServer.Orientation" default="0" /> <description> Sets desired text orientation. Note: Orientation is ignored if server does not support [code]FEATURE_VERTICAL_LAYOUT[/code] feature. </description> </method> <method name="shaped_text_set_preserve_control"> - <return type="void"> - </return> - <argument index="0" name="shaped" type="RID"> - </argument> - <argument index="1" name="enabled" type="bool"> - </argument> + <return type="void" /> + <argument index="0" name="shaped" type="RID" /> + <argument index="1" name="enabled" type="bool" /> <description> If set to [code]true[/code] text buffer will display control characters. </description> </method> <method name="shaped_text_set_preserve_invalid"> - <return type="void"> - </return> - <argument index="0" name="shaped" type="RID"> - </argument> - <argument index="1" name="enabled" type="bool"> - </argument> + <return type="void" /> + <argument index="0" name="shaped" type="RID" /> + <argument index="1" name="enabled" type="bool" /> <description> If set to [code]true[/code] text buffer will display invalid characters as hexadecimal codes, otherwise nothing is displayed. </description> </method> <method name="shaped_text_shape"> - <return type="bool"> - </return> - <argument index="0" name="shaped" type="RID"> - </argument> + <return type="bool" /> + <argument index="0" name="shaped" type="RID" /> <description> Shapes buffer if it's not shaped. Returns [code]true[/code] if the string is shaped successfully. Note: It is not necessary to call this function manually, buffer will be shaped automatically as soon as any of its output data is requested. </description> </method> <method name="shaped_text_substr" qualifiers="const"> - <return type="RID"> - </return> - <argument index="0" name="shaped" type="RID"> - </argument> - <argument index="1" name="start" type="int"> - </argument> - <argument index="2" name="length" type="int"> - </argument> + <return type="RID" /> + <argument index="0" name="shaped" type="RID" /> + <argument index="1" name="start" type="int" /> + <argument index="2" name="length" type="int" /> <description> Returns text buffer for the substring of the text in the [code]shaped[/code] text buffer (including inline objects). </description> </method> <method name="shaped_text_tab_align"> - <return type="float"> - </return> - <argument index="0" name="shaped" type="RID"> - </argument> - <argument index="1" name="tab_stops" type="PackedFloat32Array"> - </argument> + <return type="float" /> + <argument index="0" name="shaped" type="RID" /> + <argument index="1" name="tab_stops" type="PackedFloat32Array" /> <description> Aligns shaped text to the given tab-stops. </description> </method> <method name="tag_to_name"> - <return type="String"> - </return> - <argument index="0" name="tag" type="int"> - </argument> + <return type="String" /> + <argument index="0" name="tag" type="int" /> <description> Converts OpenType tag to readable feature, variation, script or language name. </description> diff --git a/doc/classes/TextServerManager.xml b/doc/classes/TextServerManager.xml index 29586f30b4..b1dd314544 100644 --- a/doc/classes/TextServerManager.xml +++ b/doc/classes/TextServerManager.xml @@ -11,67 +11,54 @@ </tutorials> <methods> <method name="find_interface" qualifiers="const"> - <return type="TextServer"> - </return> - <argument index="0" name="name" type="String"> - </argument> + <return type="TextServer" /> + <argument index="0" name="name" type="String" /> <description> Finds an interface by its name. </description> </method> <method name="get_interface" qualifiers="const"> - <return type="TextServer"> - </return> - <argument index="0" name="index" type="int"> - </argument> + <return type="TextServer" /> + <argument index="0" name="index" type="int" /> <description> Returns the interface registered at a given index. </description> </method> <method name="get_interface_count" qualifiers="const"> - <return type="int"> - </return> + <return type="int" /> <description> Returns the number of interfaces currently registered. </description> </method> <method name="get_interface_features" qualifiers="const"> - <return type="int"> - </return> - <argument index="0" name="index" type="int"> - </argument> + <return type="int" /> + <argument index="0" name="index" type="int" /> <description> Returns text server supported features (binary OR). </description> </method> <method name="get_interface_name" qualifiers="const"> - <return type="String"> - </return> - <argument index="0" name="index" type="int"> - </argument> + <return type="String" /> + <argument index="0" name="index" type="int" /> <description> Returns the interface name registered at a given index. </description> </method> <method name="get_interfaces" qualifiers="const"> - <return type="Array"> - </return> + <return type="Array" /> <description> Returns a list of available interfaces the index and name of each interface. </description> </method> <method name="get_primary_interface" qualifiers="const"> - <return type="TextServer"> - </return> + <return type="TextServer" /> <description> Returns the primary [TextServer] interface. </description> </method> <method name="set_primary_interface"> - <return type="bool"> - </return> - <argument index="0" name="index" type="int"> - </argument> + <return type="bool" /> + <argument index="0" name="index" type="int" /> <description> Sets (and initializes it if required) interface registered at a given index as the primary. Invalidates all references to the fonts and text buffers. </description> diff --git a/doc/classes/Texture2D.xml b/doc/classes/Texture2D.xml index 35b719ae48..bf5ddeb4ab 100644 --- a/doc/classes/Texture2D.xml +++ b/doc/classes/Texture2D.xml @@ -13,87 +13,64 @@ </tutorials> <methods> <method name="draw" qualifiers="const"> - <return type="void"> - </return> - <argument index="0" name="canvas_item" type="RID"> - </argument> - <argument index="1" name="position" type="Vector2"> - </argument> - <argument index="2" name="modulate" type="Color" default="Color(1, 1, 1, 1)"> - </argument> - <argument index="3" name="transpose" type="bool" default="false"> - </argument> + <return type="void" /> + <argument index="0" name="canvas_item" type="RID" /> + <argument index="1" name="position" type="Vector2" /> + <argument index="2" name="modulate" type="Color" default="Color(1, 1, 1, 1)" /> + <argument index="3" name="transpose" type="bool" default="false" /> <description> Draws the texture using a [CanvasItem] with the [RenderingServer] API at the specified [code]position[/code]. </description> </method> <method name="draw_rect" qualifiers="const"> - <return type="void"> - </return> - <argument index="0" name="canvas_item" type="RID"> - </argument> - <argument index="1" name="rect" type="Rect2"> - </argument> - <argument index="2" name="tile" type="bool"> - </argument> - <argument index="3" name="modulate" type="Color" default="Color(1, 1, 1, 1)"> - </argument> - <argument index="4" name="transpose" type="bool" default="false"> - </argument> + <return type="void" /> + <argument index="0" name="canvas_item" type="RID" /> + <argument index="1" name="rect" type="Rect2" /> + <argument index="2" name="tile" type="bool" /> + <argument index="3" name="modulate" type="Color" default="Color(1, 1, 1, 1)" /> + <argument index="4" name="transpose" type="bool" default="false" /> <description> Draws the texture using a [CanvasItem] with the [RenderingServer] API. </description> </method> <method name="draw_rect_region" qualifiers="const"> - <return type="void"> - </return> - <argument index="0" name="canvas_item" type="RID"> - </argument> - <argument index="1" name="rect" type="Rect2"> - </argument> - <argument index="2" name="src_rect" type="Rect2"> - </argument> - <argument index="3" name="modulate" type="Color" default="Color(1, 1, 1, 1)"> - </argument> - <argument index="4" name="transpose" type="bool" default="false"> - </argument> - <argument index="5" name="clip_uv" type="bool" default="true"> - </argument> + <return type="void" /> + <argument index="0" name="canvas_item" type="RID" /> + <argument index="1" name="rect" type="Rect2" /> + <argument index="2" name="src_rect" type="Rect2" /> + <argument index="3" name="modulate" type="Color" default="Color(1, 1, 1, 1)" /> + <argument index="4" name="transpose" type="bool" default="false" /> + <argument index="5" name="clip_uv" type="bool" default="true" /> <description> Draws a part of the texture using a [CanvasItem] with the [RenderingServer] API. </description> </method> <method name="get_height" qualifiers="const"> - <return type="int"> - </return> + <return type="int" /> <description> Returns the texture height. </description> </method> <method name="get_image" qualifiers="const"> - <return type="Image"> - </return> + <return type="Image" /> <description> Returns an [Image] that is a copy of data from this [Texture2D]. [Image]s can be accessed and manipulated directly. </description> </method> <method name="get_size" qualifiers="const"> - <return type="Vector2"> - </return> + <return type="Vector2" /> <description> Returns the texture size. </description> </method> <method name="get_width" qualifiers="const"> - <return type="int"> - </return> + <return type="int" /> <description> Returns the texture width. </description> </method> <method name="has_alpha" qualifiers="const"> - <return type="bool"> - </return> + <return type="bool" /> <description> Returns [code]true[/code] if this [Texture2D] has an alpha channel. </description> diff --git a/doc/classes/Texture3D.xml b/doc/classes/Texture3D.xml index 85e940716d..8ba0d7d4b9 100644 --- a/doc/classes/Texture3D.xml +++ b/doc/classes/Texture3D.xml @@ -8,38 +8,32 @@ </tutorials> <methods> <method name="get_data" qualifiers="const"> - <return type="Image[]"> - </return> + <return type="Image[]" /> <description> </description> </method> <method name="get_depth" qualifiers="const"> - <return type="int"> - </return> + <return type="int" /> <description> </description> </method> <method name="get_format" qualifiers="const"> - <return type="int" enum="Image.Format"> - </return> + <return type="int" enum="Image.Format" /> <description> </description> </method> <method name="get_height" qualifiers="const"> - <return type="int"> - </return> + <return type="int" /> <description> </description> </method> <method name="get_width" qualifiers="const"> - <return type="int"> - </return> + <return type="int" /> <description> </description> </method> <method name="has_mipmaps" qualifiers="const"> - <return type="bool"> - </return> + <return type="bool" /> <description> </description> </method> diff --git a/doc/classes/TextureLayered.xml b/doc/classes/TextureLayered.xml index d81c3c7c5a..dd8c709049 100644 --- a/doc/classes/TextureLayered.xml +++ b/doc/classes/TextureLayered.xml @@ -10,50 +10,42 @@ </tutorials> <methods> <method name="get_format" qualifiers="const"> - <return type="int" enum="Image.Format"> - </return> + <return type="int" enum="Image.Format" /> <description> Returns the current format being used by this texture. See [enum Image.Format] for details. </description> </method> <method name="get_height" qualifiers="const"> - <return type="int"> - </return> + <return type="int" /> <description> Returns the height of the texture. Height is typically represented by the Y-axis. </description> </method> <method name="get_layer_data" qualifiers="const"> - <return type="Image"> - </return> - <argument index="0" name="layer" type="int"> - </argument> + <return type="Image" /> + <argument index="0" name="layer" type="int" /> <description> Returns an [Image] resource with the data from specified [code]layer[/code]. </description> </method> <method name="get_layered_type" qualifiers="const"> - <return type="int" enum="TextureLayered.LayeredType"> - </return> + <return type="int" enum="TextureLayered.LayeredType" /> <description> </description> </method> <method name="get_layers" qualifiers="const"> - <return type="int"> - </return> + <return type="int" /> <description> </description> </method> <method name="get_width" qualifiers="const"> - <return type="int"> - </return> + <return type="int" /> <description> Returns the width of the texture. Width is typically represented by the X-axis. </description> </method> <method name="has_mipmaps" qualifiers="const"> - <return type="bool"> - </return> + <return type="bool" /> <description> </description> </method> diff --git a/doc/classes/TextureProgressBar.xml b/doc/classes/TextureProgressBar.xml index 59cde536ad..9da89ebe43 100644 --- a/doc/classes/TextureProgressBar.xml +++ b/doc/classes/TextureProgressBar.xml @@ -10,20 +10,15 @@ </tutorials> <methods> <method name="get_stretch_margin" qualifiers="const"> - <return type="int"> - </return> - <argument index="0" name="margin" type="int" enum="Side"> - </argument> + <return type="int" /> + <argument index="0" name="margin" type="int" enum="Side" /> <description> </description> </method> <method name="set_stretch_margin"> - <return type="void"> - </return> - <argument index="0" name="margin" type="int" enum="Side"> - </argument> - <argument index="1" name="value" type="int"> - </argument> + <return type="void" /> + <argument index="0" name="margin" type="int" enum="Side" /> + <argument index="1" name="value" type="int" /> <description> </description> </method> diff --git a/doc/classes/Theme.xml b/doc/classes/Theme.xml index 969d8ab2a4..1124fb8084 100644 --- a/doc/classes/Theme.xml +++ b/doc/classes/Theme.xml @@ -12,625 +12,464 @@ </tutorials> <methods> <method name="clear"> - <return type="void"> - </return> + <return type="void" /> <description> Clears all values on the theme. </description> </method> <method name="clear_color"> - <return type="void"> - </return> - <argument index="0" name="name" type="StringName"> - </argument> - <argument index="1" name="theme_type" type="StringName"> - </argument> + <return type="void" /> + <argument index="0" name="name" type="StringName" /> + <argument index="1" name="theme_type" type="StringName" /> <description> Clears the [Color] at [code]name[/code] if the theme has [code]theme_type[/code]. </description> </method> <method name="clear_constant"> - <return type="void"> - </return> - <argument index="0" name="name" type="StringName"> - </argument> - <argument index="1" name="theme_type" type="StringName"> - </argument> + <return type="void" /> + <argument index="0" name="name" type="StringName" /> + <argument index="1" name="theme_type" type="StringName" /> <description> Clears the constant at [code]name[/code] if the theme has [code]theme_type[/code]. </description> </method> <method name="clear_font"> - <return type="void"> - </return> - <argument index="0" name="name" type="StringName"> - </argument> - <argument index="1" name="theme_type" type="StringName"> - </argument> + <return type="void" /> + <argument index="0" name="name" type="StringName" /> + <argument index="1" name="theme_type" type="StringName" /> <description> Clears the [Font] at [code]name[/code] if the theme has [code]theme_type[/code]. </description> </method> <method name="clear_font_size"> - <return type="void"> - </return> - <argument index="0" name="name" type="StringName"> - </argument> - <argument index="1" name="theme_type" type="StringName"> - </argument> + <return type="void" /> + <argument index="0" name="name" type="StringName" /> + <argument index="1" name="theme_type" type="StringName" /> <description> Clears the font size [code]name[/code] if the theme has [code]theme_type[/code]. </description> </method> <method name="clear_icon"> - <return type="void"> - </return> - <argument index="0" name="name" type="StringName"> - </argument> - <argument index="1" name="theme_type" type="StringName"> - </argument> + <return type="void" /> + <argument index="0" name="name" type="StringName" /> + <argument index="1" name="theme_type" type="StringName" /> <description> Clears the icon at [code]name[/code] if the theme has [code]theme_type[/code]. </description> </method> <method name="clear_stylebox"> - <return type="void"> - </return> - <argument index="0" name="name" type="StringName"> - </argument> - <argument index="1" name="theme_type" type="StringName"> - </argument> + <return type="void" /> + <argument index="0" name="name" type="StringName" /> + <argument index="1" name="theme_type" type="StringName" /> <description> Clears [StyleBox] at [code]name[/code] if the theme has [code]theme_type[/code]. </description> </method> <method name="clear_theme_item"> - <return type="void"> - </return> - <argument index="0" name="data_type" type="int" enum="Theme.DataType"> - </argument> - <argument index="1" name="name" type="StringName"> - </argument> - <argument index="2" name="theme_type" type="StringName"> - </argument> + <return type="void" /> + <argument index="0" name="data_type" type="int" enum="Theme.DataType" /> + <argument index="1" name="name" type="StringName" /> + <argument index="2" name="theme_type" type="StringName" /> <description> Clears the theme item of [code]data_type[/code] at [code]name[/code] if the theme has [code]theme_type[/code]. </description> </method> <method name="clear_type_variation"> - <return type="void"> - </return> - <argument index="0" name="theme_type" type="StringName"> - </argument> + <return type="void" /> + <argument index="0" name="theme_type" type="StringName" /> <description> Unmarks [code]theme_type[/code] as being a variation of any other type. </description> </method> <method name="copy_default_theme"> - <return type="void"> - </return> + <return type="void" /> <description> Sets the theme's values to a copy of the default theme values. </description> </method> <method name="copy_theme"> - <return type="void"> - </return> - <argument index="0" name="other" type="Theme"> - </argument> + <return type="void" /> + <argument index="0" name="other" type="Theme" /> <description> Sets the theme's values to a copy of a given theme. </description> </method> <method name="get_color" qualifiers="const"> - <return type="Color"> - </return> - <argument index="0" name="name" type="StringName"> - </argument> - <argument index="1" name="theme_type" type="StringName"> - </argument> + <return type="Color" /> + <argument index="0" name="name" type="StringName" /> + <argument index="1" name="theme_type" type="StringName" /> <description> Returns the [Color] at [code]name[/code] if the theme has [code]theme_type[/code]. </description> </method> <method name="get_color_list" qualifiers="const"> - <return type="PackedStringArray"> - </return> - <argument index="0" name="theme_type" type="String"> - </argument> + <return type="PackedStringArray" /> + <argument index="0" name="theme_type" type="String" /> <description> Returns all the [Color]s as a [PackedStringArray] filled with each [Color]'s name, for use in [method get_color], if the theme has [code]theme_type[/code]. </description> </method> <method name="get_color_type_list" qualifiers="const"> - <return type="PackedStringArray"> - </return> + <return type="PackedStringArray" /> <description> Returns all the [Color] types as a [PackedStringArray] filled with unique type names, for use in [method get_color] and/or [method get_color_list]. </description> </method> <method name="get_constant" qualifiers="const"> - <return type="int"> - </return> - <argument index="0" name="name" type="StringName"> - </argument> - <argument index="1" name="theme_type" type="StringName"> - </argument> + <return type="int" /> + <argument index="0" name="name" type="StringName" /> + <argument index="1" name="theme_type" type="StringName" /> <description> Returns the constant at [code]name[/code] if the theme has [code]theme_type[/code]. </description> </method> <method name="get_constant_list" qualifiers="const"> - <return type="PackedStringArray"> - </return> - <argument index="0" name="theme_type" type="String"> - </argument> + <return type="PackedStringArray" /> + <argument index="0" name="theme_type" type="String" /> <description> Returns all the constants as a [PackedStringArray] filled with each constant's name, for use in [method get_constant], if the theme has [code]theme_type[/code]. </description> </method> <method name="get_constant_type_list" qualifiers="const"> - <return type="PackedStringArray"> - </return> + <return type="PackedStringArray" /> <description> Returns all the constant types as a [PackedStringArray] filled with unique type names, for use in [method get_constant] and/or [method get_constant_list]. </description> </method> <method name="get_font" qualifiers="const"> - <return type="Font"> - </return> - <argument index="0" name="name" type="StringName"> - </argument> - <argument index="1" name="theme_type" type="StringName"> - </argument> + <return type="Font" /> + <argument index="0" name="name" type="StringName" /> + <argument index="1" name="theme_type" type="StringName" /> <description> Returns the [Font] at [code]name[/code] if the theme has [code]theme_type[/code]. </description> </method> <method name="get_font_list" qualifiers="const"> - <return type="PackedStringArray"> - </return> - <argument index="0" name="theme_type" type="String"> - </argument> + <return type="PackedStringArray" /> + <argument index="0" name="theme_type" type="String" /> <description> Returns all the [Font]s as a [PackedStringArray] filled with each [Font]'s name, for use in [method get_font], if the theme has [code]theme_type[/code]. </description> </method> <method name="get_font_size" qualifiers="const"> - <return type="int"> - </return> - <argument index="0" name="name" type="StringName"> - </argument> - <argument index="1" name="theme_type" type="StringName"> - </argument> + <return type="int" /> + <argument index="0" name="name" type="StringName" /> + <argument index="1" name="theme_type" type="StringName" /> <description> Returns the font size at [code]name[/code] if the theme has [code]theme_type[/code]. </description> </method> <method name="get_font_size_list" qualifiers="const"> - <return type="PackedStringArray"> - </return> - <argument index="0" name="theme_type" type="String"> - </argument> + <return type="PackedStringArray" /> + <argument index="0" name="theme_type" type="String" /> <description> Returns all the font sizes as a [PackedStringArray] filled with each font size name, for use in [method get_font_size], if the theme has [code]theme_type[/code]. </description> </method> <method name="get_font_size_type_list" qualifiers="const"> - <return type="PackedStringArray"> - </return> + <return type="PackedStringArray" /> <description> Returns all the font size types as a [PackedStringArray] filled with unique type names, for use in [method get_font_size] and/or [method get_font_size_list]. </description> </method> <method name="get_font_type_list" qualifiers="const"> - <return type="PackedStringArray"> - </return> + <return type="PackedStringArray" /> <description> Returns all the [Font] types as a [PackedStringArray] filled with unique type names, for use in [method get_font] and/or [method get_font_list]. </description> </method> <method name="get_icon" qualifiers="const"> - <return type="Texture2D"> - </return> - <argument index="0" name="name" type="StringName"> - </argument> - <argument index="1" name="theme_type" type="StringName"> - </argument> + <return type="Texture2D" /> + <argument index="0" name="name" type="StringName" /> + <argument index="1" name="theme_type" type="StringName" /> <description> Returns the icon [Texture2D] at [code]name[/code] if the theme has [code]theme_type[/code]. </description> </method> <method name="get_icon_list" qualifiers="const"> - <return type="PackedStringArray"> - </return> - <argument index="0" name="theme_type" type="String"> - </argument> + <return type="PackedStringArray" /> + <argument index="0" name="theme_type" type="String" /> <description> Returns all the icons as a [PackedStringArray] filled with each [Texture2D]'s name, for use in [method get_icon], if the theme has [code]theme_type[/code]. </description> </method> <method name="get_icon_type_list" qualifiers="const"> - <return type="PackedStringArray"> - </return> + <return type="PackedStringArray" /> <description> Returns all the icon types as a [PackedStringArray] filled with unique type names, for use in [method get_icon] and/or [method get_icon_list]. </description> </method> <method name="get_stylebox" qualifiers="const"> - <return type="StyleBox"> - </return> - <argument index="0" name="name" type="StringName"> - </argument> - <argument index="1" name="theme_type" type="StringName"> - </argument> + <return type="StyleBox" /> + <argument index="0" name="name" type="StringName" /> + <argument index="1" name="theme_type" type="StringName" /> <description> Returns the [StyleBox] at [code]name[/code] if the theme has [code]theme_type[/code]. Valid [code]name[/code]s may be found using [method get_stylebox_list]. Valid [code]theme_type[/code]s may be found using [method get_stylebox_type_list]. </description> </method> <method name="get_stylebox_list" qualifiers="const"> - <return type="PackedStringArray"> - </return> - <argument index="0" name="theme_type" type="String"> - </argument> + <return type="PackedStringArray" /> + <argument index="0" name="theme_type" type="String" /> <description> Returns all the [StyleBox]s as a [PackedStringArray] filled with each [StyleBox]'s name, for use in [method get_stylebox], if the theme has [code]theme_type[/code]. Valid [code]theme_type[/code]s may be found using [method get_stylebox_type_list]. </description> </method> <method name="get_stylebox_type_list" qualifiers="const"> - <return type="PackedStringArray"> - </return> + <return type="PackedStringArray" /> <description> Returns all the [StyleBox] types as a [PackedStringArray] filled with unique type names, for use in [method get_stylebox] and/or [method get_stylebox_list]. </description> </method> <method name="get_theme_item" qualifiers="const"> - <return type="Variant"> - </return> - <argument index="0" name="data_type" type="int" enum="Theme.DataType"> - </argument> - <argument index="1" name="name" type="StringName"> - </argument> - <argument index="2" name="theme_type" type="StringName"> - </argument> + <return type="Variant" /> + <argument index="0" name="data_type" type="int" enum="Theme.DataType" /> + <argument index="1" name="name" type="StringName" /> + <argument index="2" name="theme_type" type="StringName" /> <description> Returns the theme item of [code]data_type[/code] at [code]name[/code] if the theme has [code]theme_type[/code]. Valid [code]name[/code]s may be found using [method get_theme_item_list] or a data type specific method. Valid [code]theme_type[/code]s may be found using [method get_theme_item_type_list] or a data type specific method. </description> </method> <method name="get_theme_item_list" qualifiers="const"> - <return type="PackedStringArray"> - </return> - <argument index="0" name="data_type" type="int" enum="Theme.DataType"> - </argument> - <argument index="1" name="theme_type" type="String"> - </argument> + <return type="PackedStringArray" /> + <argument index="0" name="data_type" type="int" enum="Theme.DataType" /> + <argument index="1" name="theme_type" type="String" /> <description> Returns all the theme items of [code]data_type[/code] as a [PackedStringArray] filled with each theme items's name, for use in [method get_theme_item] or a data type specific method, if the theme has [code]theme_type[/code]. Valid [code]theme_type[/code]s may be found using [method get_theme_item_type_list] or a data type specific method. </description> </method> <method name="get_theme_item_type_list" qualifiers="const"> - <return type="PackedStringArray"> - </return> - <argument index="0" name="data_type" type="int" enum="Theme.DataType"> - </argument> + <return type="PackedStringArray" /> + <argument index="0" name="data_type" type="int" enum="Theme.DataType" /> <description> Returns all the theme items of [code]data_type[/code] types as a [PackedStringArray] filled with unique type names, for use in [method get_theme_item], [method get_theme_item_list] or data type specific methods. </description> </method> <method name="get_type_list" qualifiers="const"> - <return type="PackedStringArray"> - </return> + <return type="PackedStringArray" /> <description> Returns all the theme types as a [PackedStringArray] filled with unique type names, for use in other [code]get_*[/code] functions of this theme. </description> </method> <method name="get_type_variation_base" qualifiers="const"> - <return type="StringName"> - </return> - <argument index="0" name="theme_type" type="StringName"> - </argument> + <return type="StringName" /> + <argument index="0" name="theme_type" type="StringName" /> <description> Returns the base theme type if [code]theme_type[/code] is a valid variation type. Returns an empty string otherwise. </description> </method> <method name="get_type_variation_list" qualifiers="const"> - <return type="PackedStringArray"> - </return> - <argument index="0" name="base_type" type="StringName"> - </argument> + <return type="PackedStringArray" /> + <argument index="0" name="base_type" type="StringName" /> <description> Returns a list of all variation for the given [code]base_type[/code]. </description> </method> <method name="has_color" qualifiers="const"> - <return type="bool"> - </return> - <argument index="0" name="name" type="StringName"> - </argument> - <argument index="1" name="theme_type" type="StringName"> - </argument> + <return type="bool" /> + <argument index="0" name="name" type="StringName" /> + <argument index="1" name="theme_type" type="StringName" /> <description> Returns [code]true[/code] if [Color] with [code]name[/code] is in [code]theme_type[/code]. Returns [code]false[/code] if the theme does not have [code]theme_type[/code]. </description> </method> <method name="has_constant" qualifiers="const"> - <return type="bool"> - </return> - <argument index="0" name="name" type="StringName"> - </argument> - <argument index="1" name="theme_type" type="StringName"> - </argument> + <return type="bool" /> + <argument index="0" name="name" type="StringName" /> + <argument index="1" name="theme_type" type="StringName" /> <description> Returns [code]true[/code] if constant with [code]name[/code] is in [code]theme_type[/code]. Returns [code]false[/code] if the theme does not have [code]theme_type[/code]. </description> </method> <method name="has_font" qualifiers="const"> - <return type="bool"> - </return> - <argument index="0" name="name" type="StringName"> - </argument> - <argument index="1" name="theme_type" type="StringName"> - </argument> + <return type="bool" /> + <argument index="0" name="name" type="StringName" /> + <argument index="1" name="theme_type" type="StringName" /> <description> Returns [code]true[/code] if [Font] with [code]name[/code] is in [code]theme_type[/code]. Returns [code]false[/code] if the theme does not have [code]theme_type[/code]. </description> </method> <method name="has_font_size" qualifiers="const"> - <return type="bool"> - </return> - <argument index="0" name="name" type="StringName"> - </argument> - <argument index="1" name="theme_type" type="StringName"> - </argument> + <return type="bool" /> + <argument index="0" name="name" type="StringName" /> + <argument index="1" name="theme_type" type="StringName" /> <description> Returns [code]true[/code] if font size with [code]name[/code] is in [code]theme_type[/code]. Returns [code]false[/code] if the theme does not have [code]theme_type[/code]. </description> </method> <method name="has_icon" qualifiers="const"> - <return type="bool"> - </return> - <argument index="0" name="name" type="StringName"> - </argument> - <argument index="1" name="theme_type" type="StringName"> - </argument> + <return type="bool" /> + <argument index="0" name="name" type="StringName" /> + <argument index="1" name="theme_type" type="StringName" /> <description> Returns [code]true[/code] if icon [Texture2D] with [code]name[/code] is in [code]theme_type[/code]. Returns [code]false[/code] if the theme does not have [code]theme_type[/code]. </description> </method> <method name="has_stylebox" qualifiers="const"> - <return type="bool"> - </return> - <argument index="0" name="name" type="StringName"> - </argument> - <argument index="1" name="theme_type" type="StringName"> - </argument> + <return type="bool" /> + <argument index="0" name="name" type="StringName" /> + <argument index="1" name="theme_type" type="StringName" /> <description> Returns [code]true[/code] if [StyleBox] with [code]name[/code] is in [code]theme_type[/code]. Returns [code]false[/code] if the theme does not have [code]theme_type[/code]. </description> </method> <method name="has_theme_item" qualifiers="const"> - <return type="bool"> - </return> - <argument index="0" name="data_type" type="int" enum="Theme.DataType"> - </argument> - <argument index="1" name="name" type="StringName"> - </argument> - <argument index="2" name="theme_type" type="StringName"> - </argument> + <return type="bool" /> + <argument index="0" name="data_type" type="int" enum="Theme.DataType" /> + <argument index="1" name="name" type="StringName" /> + <argument index="2" name="theme_type" type="StringName" /> <description> Returns [code]true[/code] if a theme item of [code]data_type[/code] with [code]name[/code] is in [code]theme_type[/code]. Returns [code]false[/code] if the theme does not have [code]theme_type[/code]. </description> </method> <method name="is_type_variation" qualifiers="const"> - <return type="bool"> - </return> - <argument index="0" name="theme_type" type="StringName"> - </argument> - <argument index="1" name="base_type" type="StringName"> - </argument> + <return type="bool" /> + <argument index="0" name="theme_type" type="StringName" /> + <argument index="1" name="base_type" type="StringName" /> <description> Returns [code]true[/code] if [code]theme_type[/code] is marked as a variation of [code]base_type[/code] in this theme. </description> </method> <method name="rename_color"> - <return type="void"> - </return> - <argument index="0" name="old_name" type="StringName"> - </argument> - <argument index="1" name="name" type="StringName"> - </argument> - <argument index="2" name="theme_type" type="StringName"> - </argument> + <return type="void" /> + <argument index="0" name="old_name" type="StringName" /> + <argument index="1" name="name" type="StringName" /> + <argument index="2" name="theme_type" type="StringName" /> <description> Renames the [Color] at [code]old_name[/code] to [code]name[/code] if the theme has [code]theme_type[/code]. If [code]name[/code] is already taken, this method fails. </description> </method> <method name="rename_constant"> - <return type="void"> - </return> - <argument index="0" name="old_name" type="StringName"> - </argument> - <argument index="1" name="name" type="StringName"> - </argument> - <argument index="2" name="theme_type" type="StringName"> - </argument> + <return type="void" /> + <argument index="0" name="old_name" type="StringName" /> + <argument index="1" name="name" type="StringName" /> + <argument index="2" name="theme_type" type="StringName" /> <description> Renames the constant at [code]old_name[/code] to [code]name[/code] if the theme has [code]theme_type[/code]. If [code]name[/code] is already taken, this method fails. </description> </method> <method name="rename_font"> - <return type="void"> - </return> - <argument index="0" name="old_name" type="StringName"> - </argument> - <argument index="1" name="name" type="StringName"> - </argument> - <argument index="2" name="theme_type" type="StringName"> - </argument> + <return type="void" /> + <argument index="0" name="old_name" type="StringName" /> + <argument index="1" name="name" type="StringName" /> + <argument index="2" name="theme_type" type="StringName" /> <description> Renames the [Font] at [code]old_name[/code] to [code]name[/code] if the theme has [code]theme_type[/code]. If [code]name[/code] is already taken, this method fails. </description> </method> <method name="rename_font_size"> - <return type="void"> - </return> - <argument index="0" name="old_name" type="StringName"> - </argument> - <argument index="1" name="name" type="StringName"> - </argument> - <argument index="2" name="theme_type" type="StringName"> - </argument> + <return type="void" /> + <argument index="0" name="old_name" type="StringName" /> + <argument index="1" name="name" type="StringName" /> + <argument index="2" name="theme_type" type="StringName" /> <description> Renames the font size [code]old_name[/code] to [code]name[/code] if the theme has [code]theme_type[/code]. If [code]name[/code] is already taken, this method fails. </description> </method> <method name="rename_icon"> - <return type="void"> - </return> - <argument index="0" name="old_name" type="StringName"> - </argument> - <argument index="1" name="name" type="StringName"> - </argument> - <argument index="2" name="theme_type" type="StringName"> - </argument> + <return type="void" /> + <argument index="0" name="old_name" type="StringName" /> + <argument index="1" name="name" type="StringName" /> + <argument index="2" name="theme_type" type="StringName" /> <description> Renames the icon at [code]old_name[/code] to [code]name[/code] if the theme has [code]theme_type[/code]. If [code]name[/code] is already taken, this method fails. </description> </method> <method name="rename_stylebox"> - <return type="void"> - </return> - <argument index="0" name="old_name" type="StringName"> - </argument> - <argument index="1" name="name" type="StringName"> - </argument> - <argument index="2" name="theme_type" type="StringName"> - </argument> + <return type="void" /> + <argument index="0" name="old_name" type="StringName" /> + <argument index="1" name="name" type="StringName" /> + <argument index="2" name="theme_type" type="StringName" /> <description> Renames [StyleBox] at [code]old_name[/code] to [code]name[/code] if the theme has [code]theme_type[/code]. If [code]name[/code] is already taken, this method fails. </description> </method> <method name="rename_theme_item"> - <return type="void"> - </return> - <argument index="0" name="data_type" type="int" enum="Theme.DataType"> - </argument> - <argument index="1" name="old_name" type="StringName"> - </argument> - <argument index="2" name="name" type="StringName"> - </argument> - <argument index="3" name="theme_type" type="StringName"> - </argument> + <return type="void" /> + <argument index="0" name="data_type" type="int" enum="Theme.DataType" /> + <argument index="1" name="old_name" type="StringName" /> + <argument index="2" name="name" type="StringName" /> + <argument index="3" name="theme_type" type="StringName" /> <description> Renames the theme item of [code]data_type[/code] at [code]old_name[/code] to [code]name[/code] if the theme has [code]theme_type[/code]. If [code]name[/code] is already taken, this method fails. </description> </method> <method name="set_color"> - <return type="void"> - </return> - <argument index="0" name="name" type="StringName"> - </argument> - <argument index="1" name="theme_type" type="StringName"> - </argument> - <argument index="2" name="color" type="Color"> - </argument> + <return type="void" /> + <argument index="0" name="name" type="StringName" /> + <argument index="1" name="theme_type" type="StringName" /> + <argument index="2" name="color" type="Color" /> <description> Sets the theme's [Color] to [code]color[/code] at [code]name[/code] in [code]theme_type[/code]. Creates [code]theme_type[/code] if the theme does not have it. </description> </method> <method name="set_constant"> - <return type="void"> - </return> - <argument index="0" name="name" type="StringName"> - </argument> - <argument index="1" name="theme_type" type="StringName"> - </argument> - <argument index="2" name="constant" type="int"> - </argument> + <return type="void" /> + <argument index="0" name="name" type="StringName" /> + <argument index="1" name="theme_type" type="StringName" /> + <argument index="2" name="constant" type="int" /> <description> Sets the theme's constant to [code]constant[/code] at [code]name[/code] in [code]theme_type[/code]. Creates [code]theme_type[/code] if the theme does not have it. </description> </method> <method name="set_font"> - <return type="void"> - </return> - <argument index="0" name="name" type="StringName"> - </argument> - <argument index="1" name="theme_type" type="StringName"> - </argument> - <argument index="2" name="font" type="Font"> - </argument> + <return type="void" /> + <argument index="0" name="name" type="StringName" /> + <argument index="1" name="theme_type" type="StringName" /> + <argument index="2" name="font" type="Font" /> <description> Sets the theme's [Font] to [code]font[/code] at [code]name[/code] in [code]theme_type[/code]. Creates [code]theme_type[/code] if the theme does not have it. </description> </method> <method name="set_font_size"> - <return type="void"> - </return> - <argument index="0" name="name" type="StringName"> - </argument> - <argument index="1" name="theme_type" type="StringName"> - </argument> - <argument index="2" name="font_size" type="int"> - </argument> + <return type="void" /> + <argument index="0" name="name" type="StringName" /> + <argument index="1" name="theme_type" type="StringName" /> + <argument index="2" name="font_size" type="int" /> <description> Sets the theme's font size to [code]font_size[/code] at [code]name[/code] in [code]theme_type[/code]. Creates [code]theme_type[/code] if the theme does not have it. </description> </method> <method name="set_icon"> - <return type="void"> - </return> - <argument index="0" name="name" type="StringName"> - </argument> - <argument index="1" name="theme_type" type="StringName"> - </argument> - <argument index="2" name="texture" type="Texture2D"> - </argument> + <return type="void" /> + <argument index="0" name="name" type="StringName" /> + <argument index="1" name="theme_type" type="StringName" /> + <argument index="2" name="texture" type="Texture2D" /> <description> Sets the theme's icon [Texture2D] to [code]texture[/code] at [code]name[/code] in [code]theme_type[/code]. Creates [code]theme_type[/code] if the theme does not have it. </description> </method> <method name="set_stylebox"> - <return type="void"> - </return> - <argument index="0" name="name" type="StringName"> - </argument> - <argument index="1" name="theme_type" type="StringName"> - </argument> - <argument index="2" name="texture" type="StyleBox"> - </argument> + <return type="void" /> + <argument index="0" name="name" type="StringName" /> + <argument index="1" name="theme_type" type="StringName" /> + <argument index="2" name="texture" type="StyleBox" /> <description> Sets theme's [StyleBox] to [code]stylebox[/code] at [code]name[/code] in [code]theme_type[/code]. Creates [code]theme_type[/code] if the theme does not have it. </description> </method> <method name="set_theme_item"> - <return type="void"> - </return> - <argument index="0" name="data_type" type="int" enum="Theme.DataType"> - </argument> - <argument index="1" name="name" type="StringName"> - </argument> - <argument index="2" name="theme_type" type="StringName"> - </argument> - <argument index="3" name="value" type="Variant"> - </argument> + <return type="void" /> + <argument index="0" name="data_type" type="int" enum="Theme.DataType" /> + <argument index="1" name="name" type="StringName" /> + <argument index="2" name="theme_type" type="StringName" /> + <argument index="3" name="value" type="Variant" /> <description> Sets the theme item of [code]data_type[/code] to [code]value[/code] at [code]name[/code] in [code]theme_type[/code]. Does nothing if the [code]value[/code] type does not match [code]data_type[/code]. @@ -638,12 +477,9 @@ </description> </method> <method name="set_type_variation"> - <return type="void"> - </return> - <argument index="0" name="theme_type" type="StringName"> - </argument> - <argument index="1" name="base_type" type="StringName"> - </argument> + <return type="void" /> + <argument index="0" name="theme_type" type="StringName" /> + <argument index="1" name="base_type" type="StringName" /> <description> Marks [code]theme_type[/code] as being a variation of [code]base_type[/code]. This adds [code]theme_type[/code] as a suggested option for [member Control.theme_type_variation] on a [Control] that is of the [code]base_type[/code] class. diff --git a/doc/classes/Thread.xml b/doc/classes/Thread.xml index 5ac9416b72..b553aad518 100644 --- a/doc/classes/Thread.xml +++ b/doc/classes/Thread.xml @@ -14,38 +14,30 @@ </tutorials> <methods> <method name="get_id" qualifiers="const"> - <return type="String"> - </return> + <return type="String" /> <description> Returns the current [Thread]'s ID, uniquely identifying it among all threads. If the [Thread] is not running this returns an empty string. </description> </method> <method name="is_active" qualifiers="const"> - <return type="bool"> - </return> + <return type="bool" /> <description> Returns [code]true[/code] if this [Thread] is currently active. An active [Thread] cannot start work on a new method but can be joined with [method wait_to_finish]. </description> </method> <method name="start"> - <return type="int" enum="Error"> - </return> - <argument index="0" name="instance" type="Object"> - </argument> - <argument index="1" name="method" type="StringName"> - </argument> - <argument index="2" name="userdata" type="Variant" default="null"> - </argument> - <argument index="3" name="priority" type="int" enum="Thread.Priority" default="1"> - </argument> + <return type="int" enum="Error" /> + <argument index="0" name="instance" type="Object" /> + <argument index="1" name="method" type="StringName" /> + <argument index="2" name="userdata" type="Variant" default="null" /> + <argument index="3" name="priority" type="int" enum="Thread.Priority" default="1" /> <description> Starts a new [Thread] that runs [code]method[/code] on object [code]instance[/code] with [code]userdata[/code] passed as an argument. Even if no userdata is passed, [code]method[/code] must accept one argument and it will be null. The [code]priority[/code] of the [Thread] can be changed by passing a value from the [enum Priority] enum. Returns [constant OK] on success, or [constant ERR_CANT_CREATE] on failure. </description> </method> <method name="wait_to_finish"> - <return type="Variant"> - </return> + <return type="Variant" /> <description> Joins the [Thread] and waits for it to finish. Returns what the method called returned. </description> diff --git a/doc/classes/TileData.xml b/doc/classes/TileData.xml index bb793024eb..b5031cfc63 100644 --- a/doc/classes/TileData.xml +++ b/doc/classes/TileData.xml @@ -8,208 +8,149 @@ </tutorials> <methods> <method name="add_collision_polygon"> - <return type="void"> - </return> - <argument index="0" name="layer_id" type="int"> - </argument> + <return type="void" /> + <argument index="0" name="layer_id" type="int" /> <description> </description> </method> <method name="get_collision_polygon_one_way_margin" qualifiers="const"> - <return type="float"> - </return> - <argument index="0" name="layer_id" type="int"> - </argument> - <argument index="1" name="polygon_index" type="int"> - </argument> + <return type="float" /> + <argument index="0" name="layer_id" type="int" /> + <argument index="1" name="polygon_index" type="int" /> <description> </description> </method> <method name="get_collision_polygon_points" qualifiers="const"> - <return type="PackedVector2Array"> - </return> - <argument index="0" name="layer_id" type="int"> - </argument> - <argument index="1" name="polygon_index" type="int"> - </argument> + <return type="PackedVector2Array" /> + <argument index="0" name="layer_id" type="int" /> + <argument index="1" name="polygon_index" type="int" /> <description> </description> </method> <method name="get_collision_polygons_count" qualifiers="const"> - <return type="int"> - </return> - <argument index="0" name="layer_id" type="int"> - </argument> + <return type="int" /> + <argument index="0" name="layer_id" type="int" /> <description> </description> </method> <method name="get_custom_data" qualifiers="const"> - <return type="Variant"> - </return> - <argument index="0" name="layer_name" type="String"> - </argument> + <return type="Variant" /> + <argument index="0" name="layer_name" type="String" /> <description> </description> </method> <method name="get_custom_data_by_layer_id" qualifiers="const"> - <return type="Variant"> - </return> - <argument index="0" name="layer_id" type="int"> - </argument> + <return type="Variant" /> + <argument index="0" name="layer_id" type="int" /> <description> </description> </method> <method name="get_navigation_polygon" qualifiers="const"> - <return type="NavigationPolygon"> - </return> - <argument index="0" name="layer_id" type="int"> - </argument> + <return type="NavigationPolygon" /> + <argument index="0" name="layer_id" type="int" /> <description> </description> </method> <method name="get_occluder" qualifiers="const"> - <return type="OccluderPolygon2D"> - </return> - <argument index="0" name="layer_id" type="int"> - </argument> + <return type="OccluderPolygon2D" /> + <argument index="0" name="layer_id" type="int" /> <description> </description> </method> <method name="get_peering_bit_terrain" qualifiers="const"> - <return type="int"> - </return> - <argument index="0" name="peering_bit" type="int" enum="TileSet.CellNeighbor"> - </argument> + <return type="int" /> + <argument index="0" name="peering_bit" type="int" enum="TileSet.CellNeighbor" /> <description> </description> </method> <method name="is_collision_polygon_one_way" qualifiers="const"> - <return type="bool"> - </return> - <argument index="0" name="layer_id" type="int"> - </argument> - <argument index="1" name="polygon_index" type="int"> - </argument> + <return type="bool" /> + <argument index="0" name="layer_id" type="int" /> + <argument index="1" name="polygon_index" type="int" /> <description> </description> </method> <method name="remove_collision_polygon"> - <return type="void"> - </return> - <argument index="0" name="layer_id" type="int"> - </argument> - <argument index="1" name="polygon_index" type="int"> - </argument> + <return type="void" /> + <argument index="0" name="layer_id" type="int" /> + <argument index="1" name="polygon_index" type="int" /> <description> </description> </method> <method name="set_collision_polygon_one_way"> - <return type="void"> - </return> - <argument index="0" name="layer_id" type="int"> - </argument> - <argument index="1" name="polygon_index" type="int"> - </argument> - <argument index="2" name="one_way" type="bool"> - </argument> + <return type="void" /> + <argument index="0" name="layer_id" type="int" /> + <argument index="1" name="polygon_index" type="int" /> + <argument index="2" name="one_way" type="bool" /> <description> </description> </method> <method name="set_collision_polygon_one_way_margin"> - <return type="void"> - </return> - <argument index="0" name="layer_id" type="int"> - </argument> - <argument index="1" name="polygon_index" type="int"> - </argument> - <argument index="2" name="one_way_margin" type="float"> - </argument> + <return type="void" /> + <argument index="0" name="layer_id" type="int" /> + <argument index="1" name="polygon_index" type="int" /> + <argument index="2" name="one_way_margin" type="float" /> <description> </description> </method> <method name="set_collision_polygon_points"> - <return type="void"> - </return> - <argument index="0" name="layer_id" type="int"> - </argument> - <argument index="1" name="polygon_index" type="int"> - </argument> - <argument index="2" name="polygon" type="PackedVector2Array"> - </argument> + <return type="void" /> + <argument index="0" name="layer_id" type="int" /> + <argument index="1" name="polygon_index" type="int" /> + <argument index="2" name="polygon" type="PackedVector2Array" /> <description> </description> </method> <method name="set_collision_polygons_count"> - <return type="void"> - </return> - <argument index="0" name="layer_id" type="int"> - </argument> - <argument index="1" name="polygons_count" type="int"> - </argument> + <return type="void" /> + <argument index="0" name="layer_id" type="int" /> + <argument index="1" name="polygons_count" type="int" /> <description> </description> </method> <method name="set_custom_data"> - <return type="void"> - </return> - <argument index="0" name="layer_name" type="String"> - </argument> - <argument index="1" name="value" type="Variant"> - </argument> + <return type="void" /> + <argument index="0" name="layer_name" type="String" /> + <argument index="1" name="value" type="Variant" /> <description> </description> </method> <method name="set_custom_data_by_layer_id"> - <return type="void"> - </return> - <argument index="0" name="layer_id" type="int"> - </argument> - <argument index="1" name="value" type="Variant"> - </argument> + <return type="void" /> + <argument index="0" name="layer_id" type="int" /> + <argument index="1" name="value" type="Variant" /> <description> </description> </method> <method name="set_navigation_polygon"> - <return type="void"> - </return> - <argument index="0" name="layer_id" type="int"> - </argument> - <argument index="1" name="navigation_polygon" type="NavigationPolygon"> - </argument> + <return type="void" /> + <argument index="0" name="layer_id" type="int" /> + <argument index="1" name="navigation_polygon" type="NavigationPolygon" /> <description> </description> </method> <method name="set_occluder"> - <return type="void"> - </return> - <argument index="0" name="layer_id" type="int"> - </argument> - <argument index="1" name="occluder_polygon" type="OccluderPolygon2D"> - </argument> + <return type="void" /> + <argument index="0" name="layer_id" type="int" /> + <argument index="1" name="occluder_polygon" type="OccluderPolygon2D" /> <description> </description> </method> <method name="set_peering_bit_terrain"> - <return type="void"> - </return> - <argument index="0" name="peering_bit" type="int" enum="TileSet.CellNeighbor"> - </argument> - <argument index="1" name="terrain" type="int"> - </argument> + <return type="void" /> + <argument index="0" name="peering_bit" type="int" enum="TileSet.CellNeighbor" /> + <argument index="1" name="terrain" type="int" /> <description> </description> </method> <method name="tile_get_material" qualifiers="const"> - <return type="ShaderMaterial"> - </return> + <return type="ShaderMaterial" /> <description> </description> </method> <method name="tile_set_material"> - <return type="void"> - </return> - <argument index="0" name="material" type="ShaderMaterial"> - </argument> + <return type="void" /> + <argument index="0" name="material" type="ShaderMaterial" /> <description> </description> </method> diff --git a/doc/classes/TileMap.xml b/doc/classes/TileMap.xml index 5a4068ec86..957619ad81 100644 --- a/doc/classes/TileMap.xml +++ b/doc/classes/TileMap.xml @@ -18,111 +18,89 @@ </tutorials> <methods> <method name="clear"> - <return type="void"> - </return> + <return type="void" /> <description> Clears all cells. </description> </method> <method name="fix_invalid_tiles"> - <return type="void"> - </return> + <return type="void" /> <description> Clears cells that do not exist in the tileset. </description> </method> <method name="get_cell_alternative_tile" qualifiers="const"> - <return type="int"> - </return> - <argument index="0" name="coords" type="Vector2i"> - </argument> + <return type="int" /> + <argument index="0" name="coords" type="Vector2i" /> + <argument index="1" name="use_proxies" type="bool" /> <description> </description> </method> <method name="get_cell_atlas_coords" qualifiers="const"> - <return type="Vector2i"> - </return> - <argument index="0" name="coords" type="Vector2i"> - </argument> + <return type="Vector2i" /> + <argument index="0" name="coords" type="Vector2i" /> + <argument index="1" name="use_proxies" type="bool" /> <description> </description> </method> <method name="get_cell_source_id" qualifiers="const"> - <return type="int"> - </return> - <argument index="0" name="coords" type="Vector2i"> - </argument> + <return type="int" /> + <argument index="0" name="coords" type="Vector2i" /> + <argument index="1" name="use_proxies" type="bool" /> <description> </description> </method> <method name="get_neighbor_cell" qualifiers="const"> - <return type="Vector2i"> - </return> - <argument index="0" name="coords" type="Vector2i"> - </argument> - <argument index="1" name="neighbor" type="int" enum="TileSet.CellNeighbor"> - </argument> + <return type="Vector2i" /> + <argument index="0" name="coords" type="Vector2i" /> + <argument index="1" name="neighbor" type="int" enum="TileSet.CellNeighbor" /> <description> </description> </method> <method name="get_surrounding_tiles"> - <return type="Vector2i[]"> - </return> - <argument index="0" name="coords" type="Vector2i"> - </argument> + <return type="Vector2i[]" /> + <argument index="0" name="coords" type="Vector2i" /> <description> </description> </method> <method name="get_used_cells" qualifiers="const"> - <return type="Vector2i[]"> - </return> + <return type="Vector2i[]" /> <description> Returns a [Vector2] array with the positions of all cells containing a tile from the tileset (i.e. a tile index different from [code]-1[/code]). </description> </method> <method name="get_used_rect"> - <return type="Rect2"> - </return> + <return type="Rect2" /> <description> Returns a rectangle enclosing the used (non-empty) tiles of the map. </description> </method> <method name="map_to_world" qualifiers="const"> - <return type="Vector2"> - </return> - <argument index="0" name="map_position" type="Vector2i"> - </argument> + <return type="Vector2" /> + <argument index="0" name="map_position" type="Vector2i" /> <description> Returns the local position corresponding to the given tilemap (grid-based) coordinates. </description> </method> <method name="set_cell"> - <return type="void"> - </return> - <argument index="0" name="coords" type="Vector2i"> - </argument> - <argument index="1" name="source_id" type="int" default="-1"> - </argument> - <argument index="2" name="atlas_coords" type="Vector2i" default="Vector2i(-1, -1)"> - </argument> - <argument index="3" name="alternative_tile" type="int" default="-1"> - </argument> + <return type="void" /> + <argument index="0" name="coords" type="Vector2i" /> + <argument index="1" name="source_id" type="int" default="-1" /> + <argument index="2" name="atlas_coords" type="Vector2i" default="Vector2i(-1, -1)" /> + <argument index="3" name="alternative_tile" type="int" default="-1" /> <description> Sets the tile index for the cell given by a Vector2i. </description> </method> <method name="update_dirty_quadrants"> - <return type="void"> - </return> + <return type="void" /> <description> Updates the tile map's quadrants, allowing things such as navigation and collision shapes to be immediately used if modified. </description> </method> <method name="world_to_map" qualifiers="const"> - <return type="Vector2i"> - </return> - <argument index="0" name="world_position" type="Vector2"> - </argument> + <return type="Vector2i" /> + <argument index="0" name="world_position" type="Vector2" /> <description> Returns the tilemap (grid-based) coordinates corresponding to the given local position. </description> diff --git a/doc/classes/TileSet.xml b/doc/classes/TileSet.xml index 436e15387d..27e31f25a4 100644 --- a/doc/classes/TileSet.xml +++ b/doc/classes/TileSet.xml @@ -18,254 +18,292 @@ </tutorials> <methods> <method name="add_source"> - <return type="int"> - </return> - <argument index="0" name="atlas_source_id_override" type="TileSetSource"> - </argument> - <argument index="1" name="arg1" type="int" default="-1"> - </argument> + <return type="int" /> + <argument index="0" name="atlas_source_id_override" type="TileSetSource" /> + <argument index="1" name="arg1" type="int" default="-1" /> + <description> + </description> + </method> + <method name="cleanup_invalid_tile_proxies"> + <return type="void" /> + <description> + </description> + </method> + <method name="clear_tile_proxies"> + <return type="void" /> + <description> + </description> + </method> + <method name="get_alternative_level_tile_proxy"> + <return type="Array" /> + <argument index="0" name="source_from" type="int" /> + <argument index="1" name="coords_from" type="Vector2i" /> + <argument index="2" name="alternative_from" type="int" /> + <description> + </description> + </method> + <method name="get_coords_level_tile_proxy"> + <return type="Array" /> + <argument index="0" name="source_from" type="int" /> + <argument index="1" name="coords_from" type="Vector2i" /> <description> </description> </method> <method name="get_navigation_layer_layers" qualifiers="const"> - <return type="int"> - </return> - <argument index="0" name="layer_index" type="int"> - </argument> + <return type="int" /> + <argument index="0" name="layer_index" type="int" /> <description> </description> </method> <method name="get_next_source_id" qualifiers="const"> - <return type="int"> - </return> + <return type="int" /> <description> </description> </method> <method name="get_occlusion_layer_light_mask" qualifiers="const"> - <return type="int"> - </return> - <argument index="0" name="arg0" type="int"> - </argument> + <return type="int" /> + <argument index="0" name="arg0" type="int" /> <description> </description> </method> <method name="get_occlusion_layer_sdf_collision" qualifiers="const"> - <return type="bool"> - </return> - <argument index="0" name="arg0" type="int"> - </argument> + <return type="bool" /> + <argument index="0" name="arg0" type="int" /> <description> </description> </method> <method name="get_physics_layer_collision_layer" qualifiers="const"> - <return type="int"> - </return> - <argument index="0" name="layer_index" type="int"> - </argument> + <return type="int" /> + <argument index="0" name="layer_index" type="int" /> <description> </description> </method> <method name="get_physics_layer_collision_mask" qualifiers="const"> - <return type="int"> - </return> - <argument index="0" name="layer_index" type="int"> - </argument> + <return type="int" /> + <argument index="0" name="layer_index" type="int" /> <description> </description> </method> <method name="get_physics_layer_physics_material" qualifiers="const"> - <return type="PhysicsMaterial"> - </return> - <argument index="0" name="layer_index" type="int"> - </argument> + <return type="PhysicsMaterial" /> + <argument index="0" name="layer_index" type="int" /> <description> </description> </method> <method name="get_source" qualifiers="const"> - <return type="TileSetSource"> - </return> - <argument index="0" name="index" type="int"> - </argument> + <return type="TileSetSource" /> + <argument index="0" name="index" type="int" /> <description> </description> </method> <method name="get_source_count" qualifiers="const"> - <return type="int"> - </return> + <return type="int" /> <description> </description> </method> <method name="get_source_id" qualifiers="const"> - <return type="int"> - </return> - <argument index="0" name="index" type="int"> - </argument> + <return type="int" /> + <argument index="0" name="index" type="int" /> + <description> + </description> + </method> + <method name="get_source_level_tile_proxy"> + <return type="int" /> + <argument index="0" name="source_from" type="int" /> <description> </description> </method> <method name="get_terrain_color" qualifiers="const"> - <return type="Color"> - </return> - <argument index="0" name="terrain_set" type="int"> - </argument> - <argument index="1" name="terrain_index" type="int"> - </argument> + <return type="Color" /> + <argument index="0" name="terrain_set" type="int" /> + <argument index="1" name="terrain_index" type="int" /> <description> </description> </method> <method name="get_terrain_name" qualifiers="const"> - <return type="String"> - </return> - <argument index="0" name="terrain_set" type="int"> - </argument> - <argument index="1" name="terrain_index" type="int"> - </argument> + <return type="String" /> + <argument index="0" name="terrain_set" type="int" /> + <argument index="1" name="terrain_index" type="int" /> <description> </description> </method> <method name="get_terrain_set_mode" qualifiers="const"> - <return type="int" enum="TileSet.TerrainMode"> - </return> - <argument index="0" name="terrain_set" type="int"> - </argument> + <return type="int" enum="TileSet.TerrainMode" /> + <argument index="0" name="terrain_set" type="int" /> <description> </description> </method> <method name="get_terrains_count" qualifiers="const"> - <return type="int"> - </return> - <argument index="0" name="terrain_set" type="int"> - </argument> + <return type="int" /> + <argument index="0" name="terrain_set" type="int" /> + <description> + </description> + </method> + <method name="has_alternative_level_tile_proxy"> + <return type="bool" /> + <argument index="0" name="source_from" type="int" /> + <argument index="1" name="coords_from" type="Vector2i" /> + <argument index="2" name="alternative_from" type="int" /> + <description> + </description> + </method> + <method name="has_coords_level_tile_proxy"> + <return type="bool" /> + <argument index="0" name="source_from" type="int" /> + <argument index="1" name="coords_from" type="Vector2i" /> <description> </description> </method> <method name="has_source" qualifiers="const"> - <return type="bool"> - </return> - <argument index="0" name="index" type="int"> - </argument> + <return type="bool" /> + <argument index="0" name="index" type="int" /> + <description> + </description> + </method> + <method name="has_source_level_tile_proxy"> + <return type="bool" /> + <argument index="0" name="source_from" type="int" /> + <description> + </description> + </method> + <method name="map_tile_proxy" qualifiers="const"> + <return type="Array" /> + <argument index="0" name="source_from" type="int" /> + <argument index="1" name="coords_from" type="Vector2i" /> + <argument index="2" name="alternative_from" type="int" /> + <description> + </description> + </method> + <method name="remove_alternative_level_tile_proxy"> + <return type="void" /> + <argument index="0" name="source_from" type="int" /> + <argument index="1" name="coords_from" type="Vector2i" /> + <argument index="2" name="alternative_from" type="int" /> + <description> + </description> + </method> + <method name="remove_coords_level_tile_proxy"> + <return type="void" /> + <argument index="0" name="source_from" type="int" /> + <argument index="1" name="coords_from" type="Vector2i" /> <description> </description> </method> <method name="remove_source"> - <return type="void"> - </return> - <argument index="0" name="source_id" type="int"> - </argument> + <return type="void" /> + <argument index="0" name="source_id" type="int" /> + <description> + </description> + </method> + <method name="remove_source_level_tile_proxy"> + <return type="void" /> + <argument index="0" name="source_from" type="int" /> + <description> + </description> + </method> + <method name="set_alternative_level_tile_proxy"> + <return type="void" /> + <argument index="0" name="source_from" type="int" /> + <argument index="1" name="coords_from" type="Vector2i" /> + <argument index="2" name="alternative_from" type="int" /> + <argument index="3" name="source_to" type="int" /> + <argument index="4" name="coords_to" type="Vector2i" /> + <argument index="5" name="alternative_to" type="int" /> + <description> + </description> + </method> + <method name="set_coords_level_tile_proxy"> + <return type="void" /> + <argument index="0" name="p_source_from" type="int" /> + <argument index="1" name="coords_from" type="Vector2i" /> + <argument index="2" name="source_to" type="int" /> + <argument index="3" name="coords_to" type="Vector2i" /> <description> </description> </method> <method name="set_navigation_layer_layers"> - <return type="void"> - </return> - <argument index="0" name="layer_index" type="int"> - </argument> - <argument index="1" name="layers" type="int"> - </argument> + <return type="void" /> + <argument index="0" name="layer_index" type="int" /> + <argument index="1" name="layers" type="int" /> <description> </description> </method> <method name="set_occlusion_layer_light_mask"> - <return type="void"> - </return> - <argument index="0" name="layer_index" type="int"> - </argument> - <argument index="1" name="light_mask" type="int"> - </argument> + <return type="void" /> + <argument index="0" name="layer_index" type="int" /> + <argument index="1" name="light_mask" type="int" /> <description> </description> </method> <method name="set_occlusion_layer_sdf_collision"> - <return type="void"> - </return> - <argument index="0" name="layer_index" type="int"> - </argument> - <argument index="1" name="sdf_collision" type="int"> - </argument> + <return type="void" /> + <argument index="0" name="layer_index" type="int" /> + <argument index="1" name="sdf_collision" type="int" /> <description> </description> </method> <method name="set_physics_layer_collision_layer"> - <return type="void"> - </return> - <argument index="0" name="layer_index" type="int"> - </argument> - <argument index="1" name="layer" type="int"> - </argument> + <return type="void" /> + <argument index="0" name="layer_index" type="int" /> + <argument index="1" name="layer" type="int" /> <description> </description> </method> <method name="set_physics_layer_collision_mask"> - <return type="void"> - </return> - <argument index="0" name="layer_index" type="int"> - </argument> - <argument index="1" name="mask" type="int"> - </argument> + <return type="void" /> + <argument index="0" name="layer_index" type="int" /> + <argument index="1" name="mask" type="int" /> <description> </description> </method> <method name="set_physics_layer_physics_material"> - <return type="void"> - </return> - <argument index="0" name="layer_index" type="int"> - </argument> - <argument index="1" name="physics_material" type="PhysicsMaterial"> - </argument> + <return type="void" /> + <argument index="0" name="layer_index" type="int" /> + <argument index="1" name="physics_material" type="PhysicsMaterial" /> <description> </description> </method> <method name="set_source_id"> - <return type="void"> - </return> - <argument index="0" name="source_id" type="int"> - </argument> - <argument index="1" name="arg1" type="int"> - </argument> + <return type="void" /> + <argument index="0" name="source_id" type="int" /> + <argument index="1" name="arg1" type="int" /> + <description> + </description> + </method> + <method name="set_source_level_tile_proxy"> + <return type="void" /> + <argument index="0" name="source_from" type="int" /> + <argument index="1" name="source_to" type="int" /> <description> </description> </method> <method name="set_terrain_color"> - <return type="void"> - </return> - <argument index="0" name="terrain_set" type="int"> - </argument> - <argument index="1" name="terrain_index" type="int"> - </argument> - <argument index="2" name="color" type="Color"> - </argument> + <return type="void" /> + <argument index="0" name="terrain_set" type="int" /> + <argument index="1" name="terrain_index" type="int" /> + <argument index="2" name="color" type="Color" /> <description> </description> </method> <method name="set_terrain_name"> - <return type="void"> - </return> - <argument index="0" name="terrain_set" type="int"> - </argument> - <argument index="1" name="terrain_index" type="int"> - </argument> - <argument index="2" name="name" type="String"> - </argument> + <return type="void" /> + <argument index="0" name="terrain_set" type="int" /> + <argument index="1" name="terrain_index" type="int" /> + <argument index="2" name="name" type="String" /> <description> </description> </method> <method name="set_terrain_set_mode"> - <return type="void"> - </return> - <argument index="0" name="terrain_set" type="int"> - </argument> - <argument index="1" name="mode" type="int" enum="TileSet.TerrainMode"> - </argument> + <return type="void" /> + <argument index="0" name="terrain_set" type="int" /> + <argument index="1" name="mode" type="int" enum="TileSet.TerrainMode" /> <description> </description> </method> <method name="set_terrains_count"> - <return type="void"> - </return> - <argument index="0" name="terrain_set" type="int"> - </argument> - <argument index="1" name="terrains_count" type="int"> - </argument> + <return type="void" /> + <argument index="0" name="terrain_set" type="int" /> + <argument index="1" name="terrains_count" type="int" /> <description> </description> </method> diff --git a/doc/classes/TileSetAtlasSource.xml b/doc/classes/TileSetAtlasSource.xml index 8482c356d7..8caa3a7c39 100644 --- a/doc/classes/TileSetAtlasSource.xml +++ b/doc/classes/TileSetAtlasSource.xml @@ -8,186 +8,136 @@ </tutorials> <methods> <method name="can_move_tile_in_atlas" qualifiers="const"> - <return type="bool"> - </return> - <argument index="0" name="atlas_coords" type="Vector2i"> - </argument> - <argument index="1" name="new_atlas_coords" type="Vector2i" default="Vector2i(-1, -1)"> - </argument> - <argument index="2" name="new_size" type="Vector2i" default="Vector2i(-1, -1)"> - </argument> + <return type="bool" /> + <argument index="0" name="atlas_coords" type="Vector2i" /> + <argument index="1" name="new_atlas_coords" type="Vector2i" default="Vector2i(-1, -1)" /> + <argument index="2" name="new_size" type="Vector2i" default="Vector2i(-1, -1)" /> <description> </description> </method> <method name="clear_tiles_outside_texture"> - <return type="void"> - </return> + <return type="void" /> <description> </description> </method> <method name="create_alternative_tile"> - <return type="int"> - </return> - <argument index="0" name="atlas_coords" type="Vector2i"> - </argument> - <argument index="1" name="alternative_id_override" type="int" default="-1"> - </argument> + <return type="int" /> + <argument index="0" name="atlas_coords" type="Vector2i" /> + <argument index="1" name="alternative_id_override" type="int" default="-1" /> <description> </description> </method> <method name="create_tile"> - <return type="void"> - </return> - <argument index="0" name="atlas_coords" type="Vector2i"> - </argument> - <argument index="1" name="size" type="Vector2i" default="Vector2i(1, 1)"> - </argument> + <return type="void" /> + <argument index="0" name="atlas_coords" type="Vector2i" /> + <argument index="1" name="size" type="Vector2i" default="Vector2i(1, 1)" /> <description> </description> </method> <method name="get_alternative_tile_id" qualifiers="const"> - <return type="int"> - </return> - <argument index="0" name="atlas_coords" type="Vector2i"> - </argument> - <argument index="1" name="index" type="int"> - </argument> + <return type="int" /> + <argument index="0" name="atlas_coords" type="Vector2i" /> + <argument index="1" name="index" type="int" /> <description> </description> </method> <method name="get_alternative_tiles_count" qualifiers="const"> - <return type="int"> - </return> - <argument index="0" name="atlas_coords" type="Vector2i"> - </argument> + <return type="int" /> + <argument index="0" name="atlas_coords" type="Vector2i" /> <description> </description> </method> <method name="get_atlas_grid_size" qualifiers="const"> - <return type="Vector2i"> - </return> + <return type="Vector2i" /> <description> </description> </method> <method name="get_next_alternative_tile_id" qualifiers="const"> - <return type="int"> - </return> - <argument index="0" name="atlas_coords" type="Vector2i"> - </argument> + <return type="int" /> + <argument index="0" name="atlas_coords" type="Vector2i" /> <description> </description> </method> <method name="get_tile_at_coords" qualifiers="const"> - <return type="Vector2i"> - </return> - <argument index="0" name="atlas_coords" type="Vector2i"> - </argument> + <return type="Vector2i" /> + <argument index="0" name="atlas_coords" type="Vector2i" /> <description> </description> </method> <method name="get_tile_data" qualifiers="const"> - <return type="Object"> - </return> - <argument index="0" name="atlas_coords" type="Vector2i"> - </argument> - <argument index="1" name="index" type="int"> - </argument> + <return type="Object" /> + <argument index="0" name="atlas_coords" type="Vector2i" /> + <argument index="1" name="index" type="int" /> <description> </description> </method> <method name="get_tile_id" qualifiers="const"> - <return type="Vector2i"> - </return> - <argument index="0" name="index" type="int"> - </argument> + <return type="Vector2i" /> + <argument index="0" name="index" type="int" /> <description> </description> </method> <method name="get_tile_size_in_atlas" qualifiers="const"> - <return type="Vector2i"> - </return> - <argument index="0" name="atlas_coords" type="Vector2i"> - </argument> + <return type="Vector2i" /> + <argument index="0" name="atlas_coords" type="Vector2i" /> <description> </description> </method> <method name="get_tile_texture_region" qualifiers="const"> - <return type="Rect2i"> - </return> - <argument index="0" name="atlas_coords" type="Vector2i"> - </argument> + <return type="Rect2i" /> + <argument index="0" name="atlas_coords" type="Vector2i" /> <description> </description> </method> <method name="get_tiles_count" qualifiers="const"> - <return type="int"> - </return> + <return type="int" /> <description> </description> </method> <method name="has_alternative_tile" qualifiers="const"> - <return type="bool"> - </return> - <argument index="0" name="atlas_coords" type="Vector2i"> - </argument> - <argument index="1" name="alternative_tile" type="int"> - </argument> + <return type="bool" /> + <argument index="0" name="atlas_coords" type="Vector2i" /> + <argument index="1" name="alternative_tile" type="int" /> <description> </description> </method> <method name="has_tile" qualifiers="const"> - <return type="bool"> - </return> - <argument index="0" name="atlas_coords" type="Vector2i"> - </argument> + <return type="bool" /> + <argument index="0" name="atlas_coords" type="Vector2i" /> <description> </description> </method> <method name="has_tiles_outside_texture"> - <return type="bool"> - </return> + <return type="bool" /> <description> </description> </method> <method name="move_tile_in_atlas"> - <return type="void"> - </return> - <argument index="0" name="atlas_coords" type="Vector2i"> - </argument> - <argument index="1" name="new_atlas_coords" type="Vector2i" default="Vector2i(-1, -1)"> - </argument> - <argument index="2" name="new_size" type="Vector2i" default="Vector2i(-1, -1)"> - </argument> + <return type="void" /> + <argument index="0" name="atlas_coords" type="Vector2i" /> + <argument index="1" name="new_atlas_coords" type="Vector2i" default="Vector2i(-1, -1)" /> + <argument index="2" name="new_size" type="Vector2i" default="Vector2i(-1, -1)" /> <description> </description> </method> <method name="remove_alternative_tile"> - <return type="void"> - </return> - <argument index="0" name="atlas_coords" type="Vector2i"> - </argument> - <argument index="1" name="alternative_tile" type="int"> - </argument> + <return type="void" /> + <argument index="0" name="atlas_coords" type="Vector2i" /> + <argument index="1" name="alternative_tile" type="int" /> <description> </description> </method> <method name="remove_tile"> - <return type="void"> - </return> - <argument index="0" name="atlas_coords" type="Vector2i"> - </argument> + <return type="void" /> + <argument index="0" name="atlas_coords" type="Vector2i" /> <description> </description> </method> <method name="set_alternative_tile_id"> - <return type="void"> - </return> - <argument index="0" name="atlas_coords" type="Vector2i"> - </argument> - <argument index="1" name="alternative_tile" type="int"> - </argument> - <argument index="2" name="new_id" type="int"> - </argument> + <return type="void" /> + <argument index="0" name="atlas_coords" type="Vector2i" /> + <argument index="1" name="alternative_tile" type="int" /> + <argument index="2" name="new_id" type="int" /> <description> </description> </method> diff --git a/doc/classes/TileSetScenesCollectionSource.xml b/doc/classes/TileSetScenesCollectionSource.xml index 1a00eb51c0..a44f519a4c 100644 --- a/doc/classes/TileSetScenesCollectionSource.xml +++ b/doc/classes/TileSetScenesCollectionSource.xml @@ -8,144 +8,107 @@ </tutorials> <methods> <method name="create_scene_tile"> - <return type="int"> - </return> - <argument index="0" name="packed_scene" type="PackedScene"> - </argument> - <argument index="1" name="id_override" type="int" default="-1"> - </argument> + <return type="int" /> + <argument index="0" name="packed_scene" type="PackedScene" /> + <argument index="1" name="id_override" type="int" default="-1" /> <description> </description> </method> <method name="get_alternative_tile_id" qualifiers="const"> - <return type="int"> - </return> - <argument index="0" name="atlas_coords" type="Vector2i"> - </argument> - <argument index="1" name="index" type="int"> - </argument> + <return type="int" /> + <argument index="0" name="atlas_coords" type="Vector2i" /> + <argument index="1" name="index" type="int" /> <description> </description> </method> <method name="get_alternative_tiles_count" qualifiers="const"> - <return type="int"> - </return> - <argument index="0" name="atlas_coords" type="Vector2i"> - </argument> + <return type="int" /> + <argument index="0" name="atlas_coords" type="Vector2i" /> <description> </description> </method> <method name="get_next_scene_tile_id" qualifiers="const"> - <return type="int"> - </return> + <return type="int" /> <description> </description> </method> <method name="get_scene_tile_display_placeholder" qualifiers="const"> - <return type="bool"> - </return> - <argument index="0" name="id" type="int"> - </argument> + <return type="bool" /> + <argument index="0" name="id" type="int" /> <description> </description> </method> <method name="get_scene_tile_id"> - <return type="int"> - </return> - <argument index="0" name="index" type="int"> - </argument> + <return type="int" /> + <argument index="0" name="index" type="int" /> <description> </description> </method> <method name="get_scene_tile_scene" qualifiers="const"> - <return type="PackedScene"> - </return> - <argument index="0" name="id" type="int"> - </argument> + <return type="PackedScene" /> + <argument index="0" name="id" type="int" /> <description> </description> </method> <method name="get_scene_tiles_count"> - <return type="int"> - </return> + <return type="int" /> <description> </description> </method> <method name="get_tile_id" qualifiers="const"> - <return type="Vector2i"> - </return> - <argument index="0" name="index" type="int"> - </argument> + <return type="Vector2i" /> + <argument index="0" name="index" type="int" /> <description> </description> </method> <method name="get_tiles_count" qualifiers="const"> - <return type="int"> - </return> + <return type="int" /> <description> </description> </method> <method name="has_alternative_tile" qualifiers="const"> - <return type="bool"> - </return> - <argument index="0" name="atlas_coords" type="Vector2i"> - </argument> - <argument index="1" name="alternative_tile" type="int"> - </argument> + <return type="bool" /> + <argument index="0" name="atlas_coords" type="Vector2i" /> + <argument index="1" name="alternative_tile" type="int" /> <description> </description> </method> <method name="has_scene_tile_id"> - <return type="bool"> - </return> - <argument index="0" name="id" type="int"> - </argument> + <return type="bool" /> + <argument index="0" name="id" type="int" /> <description> </description> </method> <method name="has_tile" qualifiers="const"> - <return type="bool"> - </return> - <argument index="0" name="atlas_coords" type="Vector2i"> - </argument> + <return type="bool" /> + <argument index="0" name="atlas_coords" type="Vector2i" /> <description> </description> </method> <method name="remove_scene_tile"> - <return type="void"> - </return> - <argument index="0" name="id" type="int"> - </argument> + <return type="void" /> + <argument index="0" name="id" type="int" /> <description> </description> </method> <method name="set_scene_tile_display_placeholder"> - <return type="void"> - </return> - <argument index="0" name="id" type="int"> - </argument> - <argument index="1" name="display_placeholder" type="bool"> - </argument> + <return type="void" /> + <argument index="0" name="id" type="int" /> + <argument index="1" name="display_placeholder" type="bool" /> <description> </description> </method> <method name="set_scene_tile_id"> - <return type="void"> - </return> - <argument index="0" name="id" type="int"> - </argument> - <argument index="1" name="new_id" type="int"> - </argument> + <return type="void" /> + <argument index="0" name="id" type="int" /> + <argument index="1" name="new_id" type="int" /> <description> </description> </method> <method name="set_scene_tile_scene"> - <return type="void"> - </return> - <argument index="0" name="id" type="int"> - </argument> - <argument index="1" name="packed_scene" type="PackedScene"> - </argument> + <return type="void" /> + <argument index="0" name="id" type="int" /> + <argument index="1" name="packed_scene" type="PackedScene" /> <description> </description> </method> diff --git a/doc/classes/Time.xml b/doc/classes/Time.xml index 0c7c090e97..24ce30154d 100644 --- a/doc/classes/Time.xml +++ b/doc/classes/Time.xml @@ -13,81 +13,63 @@ </tutorials> <methods> <method name="get_date_dict_from_system" qualifiers="const"> - <return type="Dictionary"> - </return> - <argument index="0" name="utc" type="bool" default="false"> - </argument> + <return type="Dictionary" /> + <argument index="0" name="utc" type="bool" default="false" /> <description> Returns the current date as a dictionary of keys: [code]year[/code], [code]month[/code], [code]day[/code], [code]weekday[/code], and [code]dst[/code] (Daylight Savings Time). The returned values are in the system's local time when [code]utc[/code] is false, otherwise they are in UTC. </description> </method> <method name="get_date_dict_from_unix_time" qualifiers="const"> - <return type="Dictionary"> - </return> - <argument index="0" name="unix_time_val" type="int"> - </argument> + <return type="Dictionary" /> + <argument index="0" name="unix_time_val" type="int" /> <description> Converts the given Unix timestamp to a dictionary of keys: [code]year[/code], [code]month[/code], [code]day[/code], and [code]weekday[/code]. </description> </method> <method name="get_date_string_from_system" qualifiers="const"> - <return type="String"> - </return> - <argument index="0" name="utc" type="bool" default="false"> - </argument> + <return type="String" /> + <argument index="0" name="utc" type="bool" default="false" /> <description> Returns the current date as an ISO 8601 date string (YYYY-MM-DD). The returned values are in the system's local time when [code]utc[/code] is false, otherwise they are in UTC. </description> </method> <method name="get_date_string_from_unix_time" qualifiers="const"> - <return type="String"> - </return> - <argument index="0" name="unix_time_val" type="int"> - </argument> + <return type="String" /> + <argument index="0" name="unix_time_val" type="int" /> <description> Converts the given Unix timestamp to an ISO 8601 date string (YYYY-MM-DD). </description> </method> <method name="get_datetime_dict_from_string" qualifiers="const"> - <return type="Dictionary"> - </return> - <argument index="0" name="datetime" type="String"> - </argument> - <argument index="1" name="weekday" type="bool"> - </argument> + <return type="Dictionary" /> + <argument index="0" name="datetime" type="String" /> + <argument index="1" name="weekday" type="bool" /> <description> Converts the given ISO 8601 date and time string (YYYY-MM-DDTHH:MM:SS) to a dictionary of keys: [code]year[/code], [code]month[/code], [code]day[/code], [code]weekday[/code], [code]hour[/code], [code]minute[/code], and [code]second[/code]. If [code]weekday[/code] is false, then the [code]weekday[/code] entry is excluded (the calculation is relatively expensive). </description> </method> <method name="get_datetime_dict_from_system" qualifiers="const"> - <return type="Dictionary"> - </return> - <argument index="0" name="utc" type="bool" default="false"> - </argument> + <return type="Dictionary" /> + <argument index="0" name="utc" type="bool" default="false" /> <description> Returns the current date as a dictionary of keys: [code]year[/code], [code]month[/code], [code]day[/code], [code]weekday[/code], [code]hour[/code], [code]minute[/code], and [code]second[/code]. </description> </method> <method name="get_datetime_dict_from_unix_time" qualifiers="const"> - <return type="Dictionary"> - </return> - <argument index="0" name="unix_time_val" type="int"> - </argument> + <return type="Dictionary" /> + <argument index="0" name="unix_time_val" type="int" /> <description> Converts the given Unix timestamp to a dictionary of keys: [code]year[/code], [code]month[/code], [code]day[/code], and [code]weekday[/code]. The returned Dictionary's values will be the same as the [method get_datetime_dict_from_system] if the Unix timestamp is the current time, with the exception of Daylight Savings Time as it cannot be determined from the epoch. </description> </method> <method name="get_datetime_string_from_dict" qualifiers="const"> - <return type="String"> - </return> - <argument index="0" name="datetime" type="Dictionary"> - </argument> - <argument index="1" name="use_space" type="bool"> - </argument> + <return type="String" /> + <argument index="0" name="datetime" type="Dictionary" /> + <argument index="1" name="use_space" type="bool" /> <description> Converts the given dictionary of keys to an ISO 8601 date and time string (YYYY-MM-DDTHH:MM:SS). The given dictionary can be populated with the following keys: [code]year[/code], [code]month[/code], [code]day[/code], [code]hour[/code], [code]minute[/code], and [code]second[/code]. Any other entries (including [code]dst[/code]) are ignored. @@ -96,12 +78,9 @@ </description> </method> <method name="get_datetime_string_from_system" qualifiers="const"> - <return type="String"> - </return> - <argument index="0" name="utc" type="bool" default="false"> - </argument> - <argument index="1" name="use_space" type="bool" default="false"> - </argument> + <return type="String" /> + <argument index="0" name="utc" type="bool" default="false" /> + <argument index="1" name="use_space" type="bool" default="false" /> <description> Returns the current date and time as a dictionary of keys: [code]year[/code], [code]month[/code], [code]day[/code], [code]weekday[/code], [code]dst[/code] (Daylight Savings Time), [code]hour[/code], [code]minute[/code], and [code]second[/code]. The returned values are in the system's local time when [code]utc[/code] is false, otherwise they are in UTC. @@ -109,81 +88,65 @@ </description> </method> <method name="get_datetime_string_from_unix_time" qualifiers="const"> - <return type="String"> - </return> - <argument index="0" name="unix_time_val" type="int"> - </argument> - <argument index="1" name="use_space" type="bool" default="false"> - </argument> + <return type="String" /> + <argument index="0" name="unix_time_val" type="int" /> + <argument index="1" name="use_space" type="bool" default="false" /> <description> Converts the given Unix timestamp to an ISO 8601 date and time string (YYYY-MM-DDTHH:MM:SS). If [code]use_space[/code] is true, use a space instead of the letter T in the middle. </description> </method> <method name="get_ticks_msec" qualifiers="const"> - <return type="int"> - </return> + <return type="int" /> <description> Returns the amount of time passed in milliseconds since the engine started. </description> </method> <method name="get_ticks_usec" qualifiers="const"> - <return type="int"> - </return> + <return type="int" /> <description> Returns the amount of time passed in microseconds since the engine started. </description> </method> <method name="get_time_dict_from_system" qualifiers="const"> - <return type="Dictionary"> - </return> - <argument index="0" name="utc" type="bool" default="false"> - </argument> + <return type="Dictionary" /> + <argument index="0" name="utc" type="bool" default="false" /> <description> Returns the current time as a dictionary of keys: [code]hour[/code], [code]minute[/code], and [code]second[/code]. The returned values are in the system's local time when [code]utc[/code] is false, otherwise they are in UTC. </description> </method> <method name="get_time_dict_from_unix_time" qualifiers="const"> - <return type="Dictionary"> - </return> - <argument index="0" name="unix_time_val" type="int"> - </argument> + <return type="Dictionary" /> + <argument index="0" name="unix_time_val" type="int" /> <description> Converts the given time to a dictionary of keys: [code]hour[/code], [code]minute[/code], and [code]second[/code]. </description> </method> <method name="get_time_string_from_system" qualifiers="const"> - <return type="String"> - </return> - <argument index="0" name="utc" type="bool" default="false"> - </argument> + <return type="String" /> + <argument index="0" name="utc" type="bool" default="false" /> <description> Returns the current time as an ISO 8601 time string (HH:MM:SS). The returned values are in the system's local time when [code]utc[/code] is false, otherwise they are in UTC. </description> </method> <method name="get_time_string_from_unix_time" qualifiers="const"> - <return type="String"> - </return> - <argument index="0" name="unix_time_val" type="int"> - </argument> + <return type="String" /> + <argument index="0" name="unix_time_val" type="int" /> <description> Converts the given Unix timestamp to an ISO 8601 time string (HH:MM:SS). </description> </method> <method name="get_time_zone_from_system" qualifiers="const"> - <return type="Dictionary"> - </return> + <return type="Dictionary" /> <description> Returns the current time zone as a dictionary of keys: [code]bias[/code] and [code]name[/code]. The [code]bias[/code] value is the offset from UTC in minutes, since not all time zones are multiples of an hour from UTC. </description> </method> <method name="get_unix_time_from_datetime_dict" qualifiers="const"> - <return type="int"> - </return> - <argument index="0" name="datetime" type="Dictionary"> - </argument> + <return type="int" /> + <argument index="0" name="datetime" type="Dictionary" /> <description> Converts a dictionary of time values to a Unix timestamp. The given dictionary can be populated with the following keys: [code]year[/code], [code]month[/code], [code]day[/code], [code]hour[/code], [code]minute[/code], and [code]second[/code]. Any other entries (including [code]dst[/code]) are ignored. @@ -192,17 +155,14 @@ </description> </method> <method name="get_unix_time_from_datetime_string" qualifiers="const"> - <return type="int"> - </return> - <argument index="0" name="datetime" type="String"> - </argument> + <return type="int" /> + <argument index="0" name="datetime" type="String" /> <description> Converts the given ISO 8601 date and/or time string to a Unix timestamp. The string can contain a date only, a time only, or both. </description> </method> <method name="get_unix_time_from_system" qualifiers="const"> - <return type="float"> - </return> + <return type="float" /> <description> Returns the current Unix timestamp in seconds based on the system time. </description> diff --git a/doc/classes/Timer.xml b/doc/classes/Timer.xml index 807d8033c1..b91f159160 100644 --- a/doc/classes/Timer.xml +++ b/doc/classes/Timer.xml @@ -12,25 +12,21 @@ </tutorials> <methods> <method name="is_stopped" qualifiers="const"> - <return type="bool"> - </return> + <return type="bool" /> <description> Returns [code]true[/code] if the timer is stopped. </description> </method> <method name="start"> - <return type="void"> - </return> - <argument index="0" name="time_sec" type="float" default="-1"> - </argument> + <return type="void" /> + <argument index="0" name="time_sec" type="float" default="-1" /> <description> Starts the timer. Sets [code]wait_time[/code] to [code]time_sec[/code] if [code]time_sec > 0[/code]. This also resets the remaining time to [code]wait_time[/code]. [b]Note:[/b] this method will not resume a paused timer. See [member paused]. </description> </method> <method name="stop"> - <return type="void"> - </return> + <return type="void" /> <description> Stops the timer. </description> diff --git a/doc/classes/TouchScreenButton.xml b/doc/classes/TouchScreenButton.xml index bb4c17c531..e75a41a936 100644 --- a/doc/classes/TouchScreenButton.xml +++ b/doc/classes/TouchScreenButton.xml @@ -12,8 +12,7 @@ </tutorials> <methods> <method name="is_pressed" qualifiers="const"> - <return type="bool"> - </return> + <return type="bool" /> <description> Returns [code]true[/code] if this button is currently pressed. </description> diff --git a/doc/classes/Transform2D.xml b/doc/classes/Transform2D.xml index 4f9b59c188..2c3eda1e07 100644 --- a/doc/classes/Transform2D.xml +++ b/doc/classes/Transform2D.xml @@ -15,243 +15,190 @@ </tutorials> <methods> <method name="Transform2D" qualifiers="constructor"> - <return type="Transform2D"> - </return> + <return type="Transform2D" /> <description> Constructs a default-initialized [Transform2D] set to [constant IDENTITY]. </description> </method> <method name="Transform2D" qualifiers="constructor"> - <return type="Transform2D"> - </return> - <argument index="0" name="from" type="Transform2D"> - </argument> + <return type="Transform2D" /> + <argument index="0" name="from" type="Transform2D" /> <description> Constructs a [Transform2D] as a copy of the given [Transform2D]. </description> </method> <method name="Transform2D" qualifiers="constructor"> - <return type="Transform2D"> - </return> - <argument index="0" name="rotation" type="float"> - </argument> - <argument index="1" name="position" type="Vector2"> - </argument> + <return type="Transform2D" /> + <argument index="0" name="rotation" type="float" /> + <argument index="1" name="position" type="Vector2" /> <description> Constructs the transform from a given angle (in radians) and position. </description> </method> <method name="Transform2D" qualifiers="constructor"> - <return type="Transform2D"> - </return> - <argument index="0" name="x_axis" type="Vector2"> - </argument> - <argument index="1" name="y_axis" type="Vector2"> - </argument> - <argument index="2" name="origin" type="Vector2"> - </argument> + <return type="Transform2D" /> + <argument index="0" name="x_axis" type="Vector2" /> + <argument index="1" name="y_axis" type="Vector2" /> + <argument index="2" name="origin" type="Vector2" /> <description> Constructs the transform from 3 [Vector2] values representing [member x], [member y], and the [member origin] (the three column vectors). </description> </method> <method name="affine_inverse" qualifiers="const"> - <return type="Transform2D"> - </return> + <return type="Transform2D" /> <description> Returns the inverse of the transform, under the assumption that the transformation is composed of rotation, scaling and translation. </description> </method> <method name="basis_xform" qualifiers="const"> - <return type="Vector2"> - </return> - <argument index="0" name="v" type="Vector2"> - </argument> + <return type="Vector2" /> + <argument index="0" name="v" type="Vector2" /> <description> Returns a vector transformed (multiplied) by the basis matrix. This method does not account for translation (the origin vector). </description> </method> <method name="basis_xform_inv" qualifiers="const"> - <return type="Vector2"> - </return> - <argument index="0" name="v" type="Vector2"> - </argument> + <return type="Vector2" /> + <argument index="0" name="v" type="Vector2" /> <description> Returns a vector transformed (multiplied) by the inverse basis matrix. This method does not account for translation (the origin vector). </description> </method> <method name="get_origin" qualifiers="const"> - <return type="Vector2"> - </return> + <return type="Vector2" /> <description> Returns the transform's origin (translation). </description> </method> <method name="get_rotation" qualifiers="const"> - <return type="float"> - </return> + <return type="float" /> <description> Returns the transform's rotation (in radians). </description> </method> <method name="get_scale" qualifiers="const"> - <return type="Vector2"> - </return> + <return type="Vector2" /> <description> Returns the scale. </description> </method> <method name="interpolate_with" qualifiers="const"> - <return type="Transform2D"> - </return> - <argument index="0" name="xform" type="Transform2D"> - </argument> - <argument index="1" name="weight" type="float"> - </argument> + <return type="Transform2D" /> + <argument index="0" name="xform" type="Transform2D" /> + <argument index="1" name="weight" type="float" /> <description> Returns a transform interpolated between this transform and another by a given [code]weight[/code] (on the range of 0.0 to 1.0). </description> </method> <method name="inverse" qualifiers="const"> - <return type="Transform2D"> - </return> + <return type="Transform2D" /> <description> Returns the inverse of the transform, under the assumption that the transformation is composed of rotation and translation (no scaling, use [method affine_inverse] for transforms with scaling). </description> </method> <method name="is_equal_approx" qualifiers="const"> - <return type="bool"> - </return> - <argument index="0" name="xform" type="Transform2D"> - </argument> + <return type="bool" /> + <argument index="0" name="xform" type="Transform2D" /> <description> Returns [code]true[/code] if this transform and [code]transform[/code] are approximately equal, by calling [code]is_equal_approx[/code] on each component. </description> </method> <method name="looking_at" qualifiers="const"> - <return type="Transform2D"> - </return> - <argument index="0" name="target" type="Vector2" default="Transform2D(1, 0, 0, 1, 0, 0)"> - </argument> + <return type="Transform2D" /> + <argument index="0" name="target" type="Vector2" default="Transform2D(1, 0, 0, 1, 0, 0)" /> <description> Returns a copy of the transform rotated such that it's rotation on the X-axis points towards the [code]target[/code] position. Operations take place in global space. </description> </method> <method name="operator !=" qualifiers="operator"> - <return type="bool"> - </return> - <argument index="0" name="right" type="Transform2D"> - </argument> + <return type="bool" /> + <argument index="0" name="right" type="Transform2D" /> <description> </description> </method> <method name="operator *" qualifiers="operator"> - <return type="Vector2"> - </return> - <argument index="0" name="right" type="Vector2"> - </argument> + <return type="Vector2" /> + <argument index="0" name="right" type="Vector2" /> <description> </description> </method> <method name="operator *" qualifiers="operator"> - <return type="Rect2"> - </return> - <argument index="0" name="right" type="Rect2"> - </argument> + <return type="Rect2" /> + <argument index="0" name="right" type="Rect2" /> <description> </description> </method> <method name="operator *" qualifiers="operator"> - <return type="Transform2D"> - </return> - <argument index="0" name="right" type="Transform2D"> - </argument> + <return type="Transform2D" /> + <argument index="0" name="right" type="Transform2D" /> <description> </description> </method> <method name="operator *" qualifiers="operator"> - <return type="PackedVector2Array"> - </return> - <argument index="0" name="right" type="PackedVector2Array"> - </argument> + <return type="PackedVector2Array" /> + <argument index="0" name="right" type="PackedVector2Array" /> <description> </description> </method> <method name="operator *" qualifiers="operator"> - <return type="Transform2D"> - </return> - <argument index="0" name="right" type="float"> - </argument> + <return type="Transform2D" /> + <argument index="0" name="right" type="float" /> <description> This operator multiplies all components of the [Transform2D], including the origin vector, which scales it uniformly. </description> </method> <method name="operator *" qualifiers="operator"> - <return type="Transform2D"> - </return> - <argument index="0" name="right" type="int"> - </argument> + <return type="Transform2D" /> + <argument index="0" name="right" type="int" /> <description> This operator multiplies all components of the [Transform2D], including the origin vector, which scales it uniformly. </description> </method> <method name="operator ==" qualifiers="operator"> - <return type="bool"> - </return> - <argument index="0" name="right" type="Transform2D"> - </argument> + <return type="bool" /> + <argument index="0" name="right" type="Transform2D" /> <description> </description> </method> <method name="operator []" qualifiers="operator"> - <return type="Vector2"> - </return> - <argument index="0" name="index" type="int"> - </argument> + <return type="Vector2" /> + <argument index="0" name="index" type="int" /> <description> </description> </method> <method name="orthonormalized" qualifiers="const"> - <return type="Transform2D"> - </return> + <return type="Transform2D" /> <description> Returns the transform with the basis orthogonal (90 degrees), and normalized axis vectors (scale of 1 or -1). </description> </method> <method name="rotated" qualifiers="const"> - <return type="Transform2D"> - </return> - <argument index="0" name="phi" type="float"> - </argument> + <return type="Transform2D" /> + <argument index="0" name="phi" type="float" /> <description> Rotates the transform by the given angle (in radians), using matrix multiplication. </description> </method> <method name="scaled" qualifiers="const"> - <return type="Transform2D"> - </return> - <argument index="0" name="scale" type="Vector2"> - </argument> + <return type="Transform2D" /> + <argument index="0" name="scale" type="Vector2" /> <description> Scales the transform by the given scale factor, using matrix multiplication. </description> </method> <method name="set_rotation"> - <return type="void"> - </return> - <argument index="0" name="rotation" type="float"> - </argument> + <return type="void" /> + <argument index="0" name="rotation" type="float" /> <description> Sets the transform's rotation (in radians). </description> </method> <method name="translated" qualifiers="const"> - <return type="Transform2D"> - </return> - <argument index="0" name="offset" type="Vector2"> - </argument> + <return type="Transform2D" /> + <argument index="0" name="offset" type="Vector2" /> <description> Translates the transform by the given offset, relative to the transform's basis vectors. Unlike [method rotated] and [method scaled], this does not use matrix multiplication. diff --git a/doc/classes/Transform3D.xml b/doc/classes/Transform3D.xml index 5410cbced7..53cdfd53c9 100644 --- a/doc/classes/Transform3D.xml +++ b/doc/classes/Transform3D.xml @@ -17,88 +17,67 @@ </tutorials> <methods> <method name="Transform3D" qualifiers="constructor"> - <return type="Transform3D"> - </return> + <return type="Transform3D" /> <description> Constructs a default-initialized [Transform3D] set to [constant IDENTITY]. </description> </method> <method name="Transform3D" qualifiers="constructor"> - <return type="Transform3D"> - </return> - <argument index="0" name="from" type="Transform3D"> - </argument> + <return type="Transform3D" /> + <argument index="0" name="from" type="Transform3D" /> <description> Constructs a [Transform3D] as a copy of the given [Transform3D]. </description> </method> <method name="Transform3D" qualifiers="constructor"> - <return type="Transform3D"> - </return> - <argument index="0" name="basis" type="Basis"> - </argument> - <argument index="1" name="origin" type="Vector3"> - </argument> + <return type="Transform3D" /> + <argument index="0" name="basis" type="Basis" /> + <argument index="1" name="origin" type="Vector3" /> <description> Constructs a Transform3D from a [Basis] and [Vector3]. </description> </method> <method name="Transform3D" qualifiers="constructor"> - <return type="Transform3D"> - </return> - <argument index="0" name="x_axis" type="Vector3"> - </argument> - <argument index="1" name="y_axis" type="Vector3"> - </argument> - <argument index="2" name="z_axis" type="Vector3"> - </argument> - <argument index="3" name="origin" type="Vector3"> - </argument> + <return type="Transform3D" /> + <argument index="0" name="x_axis" type="Vector3" /> + <argument index="1" name="y_axis" type="Vector3" /> + <argument index="2" name="z_axis" type="Vector3" /> + <argument index="3" name="origin" type="Vector3" /> <description> Constructs a Transform3D from four [Vector3] values (matrix columns). Each axis corresponds to local basis vectors (some of which may be scaled). </description> </method> <method name="affine_inverse" qualifiers="const"> - <return type="Transform3D"> - </return> + <return type="Transform3D" /> <description> Returns the inverse of the transform, under the assumption that the transformation is composed of rotation, scaling and translation. </description> </method> <method name="interpolate_with" qualifiers="const"> - <return type="Transform3D"> - </return> - <argument index="0" name="xform" type="Transform3D"> - </argument> - <argument index="1" name="weight" type="float"> - </argument> + <return type="Transform3D" /> + <argument index="0" name="xform" type="Transform3D" /> + <argument index="1" name="weight" type="float" /> <description> Interpolates the transform to other Transform3D by weight amount (on the range of 0.0 to 1.0). </description> </method> <method name="inverse" qualifiers="const"> - <return type="Transform3D"> - </return> + <return type="Transform3D" /> <description> Returns the inverse of the transform, under the assumption that the transformation is composed of rotation and translation (no scaling, use affine_inverse for transforms with scaling). </description> </method> <method name="is_equal_approx" qualifiers="const"> - <return type="bool"> - </return> - <argument index="0" name="xform" type="Transform3D"> - </argument> + <return type="bool" /> + <argument index="0" name="xform" type="Transform3D" /> <description> Returns [code]true[/code] if this transform and [code]transform[/code] are approximately equal, by calling [code]is_equal_approx[/code] on each component. </description> </method> <method name="looking_at" qualifiers="const"> - <return type="Transform3D"> - </return> - <argument index="0" name="target" type="Vector3"> - </argument> - <argument index="1" name="up" type="Vector3" default="Vector3(0, 1, 0)"> - </argument> + <return type="Transform3D" /> + <argument index="0" name="target" type="Vector3" /> + <argument index="1" name="up" type="Vector3" default="Vector3(0, 1, 0)" /> <description> Returns a copy of the transform rotated such that its -Z axis points towards the [code]target[/code] position. The transform will first be rotated around the given [code]up[/code] vector, and then fully aligned to the target by a further rotation around an axis perpendicular to both the [code]target[/code] and [code]up[/code] vectors. @@ -106,103 +85,79 @@ </description> </method> <method name="operator !=" qualifiers="operator"> - <return type="bool"> - </return> - <argument index="0" name="right" type="Transform3D"> - </argument> + <return type="bool" /> + <argument index="0" name="right" type="Transform3D" /> <description> </description> </method> <method name="operator *" qualifiers="operator"> - <return type="PackedVector3Array"> - </return> - <argument index="0" name="right" type="PackedVector3Array"> - </argument> + <return type="PackedVector3Array" /> + <argument index="0" name="right" type="PackedVector3Array" /> <description> </description> </method> <method name="operator *" qualifiers="operator"> - <return type="Transform3D"> - </return> - <argument index="0" name="right" type="Transform3D"> - </argument> + <return type="Transform3D" /> + <argument index="0" name="right" type="Transform3D" /> <description> </description> </method> <method name="operator *" qualifiers="operator"> - <return type="AABB"> - </return> - <argument index="0" name="right" type="AABB"> - </argument> + <return type="AABB" /> + <argument index="0" name="right" type="AABB" /> <description> </description> </method> <method name="operator *" qualifiers="operator"> - <return type="Vector3"> - </return> - <argument index="0" name="right" type="Vector3"> - </argument> + <return type="Vector3" /> + <argument index="0" name="right" type="Vector3" /> <description> </description> </method> <method name="operator *" qualifiers="operator"> - <return type="Transform3D"> - </return> - <argument index="0" name="right" type="float"> - </argument> + <return type="Transform3D" /> + <argument index="0" name="right" type="float" /> <description> This operator multiplies all components of the [Transform3D], including the origin vector, which scales it uniformly. </description> </method> <method name="operator *" qualifiers="operator"> - <return type="Transform3D"> - </return> - <argument index="0" name="right" type="int"> - </argument> + <return type="Transform3D" /> + <argument index="0" name="right" type="int" /> <description> This operator multiplies all components of the [Transform3D], including the origin vector, which scales it uniformly. </description> </method> <method name="operator ==" qualifiers="operator"> - <return type="bool"> - </return> - <argument index="0" name="right" type="Transform3D"> - </argument> + <return type="bool" /> + <argument index="0" name="right" type="Transform3D" /> <description> </description> </method> <method name="orthonormalized" qualifiers="const"> - <return type="Transform3D"> - </return> + <return type="Transform3D" /> <description> Returns the transform with the basis orthogonal (90 degrees), and normalized axis vectors. </description> </method> <method name="rotated" qualifiers="const"> - <return type="Transform3D"> - </return> - <argument index="0" name="axis" type="Vector3"> - </argument> - <argument index="1" name="phi" type="float"> - </argument> + <return type="Transform3D" /> + <argument index="0" name="axis" type="Vector3" /> + <argument index="1" name="phi" type="float" /> <description> Rotates the transform around the given axis by the given angle (in radians), using matrix multiplication. The axis must be a normalized vector. </description> </method> <method name="scaled" qualifiers="const"> - <return type="Transform3D"> - </return> - <argument index="0" name="scale" type="Vector3"> - </argument> + <return type="Transform3D" /> + <argument index="0" name="scale" type="Vector3" /> <description> Scales basis and origin of the transform by the given scale factor, using matrix multiplication. </description> </method> <method name="translated" qualifiers="const"> - <return type="Transform3D"> - </return> - <argument index="0" name="offset" type="Vector3"> - </argument> + <return type="Transform3D" /> + <argument index="0" name="offset" type="Vector3" /> <description> Translates the transform by the given offset, relative to the transform's basis vectors. Unlike [method rotated] and [method scaled], this does not use matrix multiplication. diff --git a/doc/classes/Translation.xml b/doc/classes/Translation.xml index d286c6cf0c..4b83a2abf5 100644 --- a/doc/classes/Translation.xml +++ b/doc/classes/Translation.xml @@ -12,80 +12,59 @@ </tutorials> <methods> <method name="add_message"> - <return type="void"> - </return> - <argument index="0" name="src_message" type="StringName"> - </argument> - <argument index="1" name="xlated_message" type="StringName"> - </argument> - <argument index="2" name="context" type="StringName" default=""""> - </argument> + <return type="void" /> + <argument index="0" name="src_message" type="StringName" /> + <argument index="1" name="xlated_message" type="StringName" /> + <argument index="2" name="context" type="StringName" default="""" /> <description> Adds a message if nonexistent, followed by its translation. An additional context could be used to specify the translation context or differentiate polysemic words. </description> </method> <method name="add_plural_message"> - <return type="void"> - </return> - <argument index="0" name="src_message" type="StringName"> - </argument> - <argument index="1" name="xlated_messages" type="PackedStringArray"> - </argument> - <argument index="2" name="context" type="StringName" default=""""> - </argument> + <return type="void" /> + <argument index="0" name="src_message" type="StringName" /> + <argument index="1" name="xlated_messages" type="PackedStringArray" /> + <argument index="2" name="context" type="StringName" default="""" /> <description> Adds a message involving plural translation if nonexistent, followed by its translation. An additional context could be used to specify the translation context or differentiate polysemic words. </description> </method> <method name="erase_message"> - <return type="void"> - </return> - <argument index="0" name="src_message" type="StringName"> - </argument> - <argument index="1" name="context" type="StringName" default=""""> - </argument> + <return type="void" /> + <argument index="0" name="src_message" type="StringName" /> + <argument index="1" name="context" type="StringName" default="""" /> <description> Erases a message. </description> </method> <method name="get_message" qualifiers="const"> - <return type="StringName"> - </return> - <argument index="0" name="src_message" type="StringName"> - </argument> - <argument index="1" name="context" type="StringName" default=""""> - </argument> + <return type="StringName" /> + <argument index="0" name="src_message" type="StringName" /> + <argument index="1" name="context" type="StringName" default="""" /> <description> Returns a message's translation. </description> </method> <method name="get_message_count" qualifiers="const"> - <return type="int"> - </return> + <return type="int" /> <description> Returns the number of existing messages. </description> </method> <method name="get_message_list" qualifiers="const"> - <return type="PackedStringArray"> - </return> + <return type="PackedStringArray" /> <description> Returns all the messages (keys). </description> </method> <method name="get_plural_message" qualifiers="const"> - <return type="StringName"> - </return> - <argument index="0" name="src_message" type="StringName"> - </argument> - <argument index="1" name="src_plural_message" type="StringName"> - </argument> - <argument index="2" name="n" type="int"> - </argument> - <argument index="3" name="context" type="StringName" default=""""> - </argument> + <return type="StringName" /> + <argument index="0" name="src_message" type="StringName" /> + <argument index="1" name="src_plural_message" type="StringName" /> + <argument index="2" name="n" type="int" /> + <argument index="3" name="context" type="StringName" default="""" /> <description> Returns a message's translation involving plurals. The number [code]n[/code] is the number or quantity of the plural object. It will be used to guide the translation system to fetch the correct plural form for the selected language. diff --git a/doc/classes/TranslationServer.xml b/doc/classes/TranslationServer.xml index 664cb3e2e3..655c16b0cd 100644 --- a/doc/classes/TranslationServer.xml +++ b/doc/classes/TranslationServer.xml @@ -12,94 +12,73 @@ </tutorials> <methods> <method name="add_translation"> - <return type="void"> - </return> - <argument index="0" name="translation" type="Translation"> - </argument> + <return type="void" /> + <argument index="0" name="translation" type="Translation" /> <description> Adds a [Translation] resource. </description> </method> <method name="clear"> - <return type="void"> - </return> + <return type="void" /> <description> Clears the server from all translations. </description> </method> <method name="get_loaded_locales" qualifiers="const"> - <return type="Array"> - </return> + <return type="Array" /> <description> Returns an Array of all loaded locales of the game. </description> </method> <method name="get_locale" qualifiers="const"> - <return type="String"> - </return> + <return type="String" /> <description> Returns the current locale of the game. </description> </method> <method name="get_locale_name" qualifiers="const"> - <return type="String"> - </return> - <argument index="0" name="locale" type="String"> - </argument> + <return type="String" /> + <argument index="0" name="locale" type="String" /> <description> Returns a locale's language and its variant (e.g. [code]"en_US"[/code] would return [code]"English (United States)"[/code]). </description> </method> <method name="get_translation_object"> - <return type="Translation"> - </return> - <argument index="0" name="locale" type="String"> - </argument> + <return type="Translation" /> + <argument index="0" name="locale" type="String" /> <description> Returns the [Translation] instance based on the [code]locale[/code] passed in. It will return a [code]nullptr[/code] if there is no [Translation] instance that matches the [code]locale[/code]. </description> </method> <method name="remove_translation"> - <return type="void"> - </return> - <argument index="0" name="translation" type="Translation"> - </argument> + <return type="void" /> + <argument index="0" name="translation" type="Translation" /> <description> Removes the given translation from the server. </description> </method> <method name="set_locale"> - <return type="void"> - </return> - <argument index="0" name="locale" type="String"> - </argument> + <return type="void" /> + <argument index="0" name="locale" type="String" /> <description> Sets the locale of the game. </description> </method> <method name="translate" qualifiers="const"> - <return type="StringName"> - </return> - <argument index="0" name="message" type="StringName"> - </argument> - <argument index="1" name="context" type="StringName" default=""""> - </argument> + <return type="StringName" /> + <argument index="0" name="message" type="StringName" /> + <argument index="1" name="context" type="StringName" default="""" /> <description> Returns the current locale's translation for the given message (key) and context. </description> </method> <method name="translate_plural" qualifiers="const"> - <return type="StringName"> - </return> - <argument index="0" name="message" type="StringName"> - </argument> - <argument index="1" name="plural_message" type="StringName"> - </argument> - <argument index="2" name="n" type="int"> - </argument> - <argument index="3" name="context" type="StringName" default=""""> - </argument> + <return type="StringName" /> + <argument index="0" name="message" type="StringName" /> + <argument index="1" name="plural_message" type="StringName" /> + <argument index="2" name="n" type="int" /> + <argument index="3" name="context" type="StringName" default="""" /> <description> Returns the current locale's translation for the given message (key), plural_message and context. The number [code]n[/code] is the number or quantity of the plural object. It will be used to guide the translation system to fetch the correct plural form for the selected language. diff --git a/doc/classes/Tree.xml b/doc/classes/Tree.xml index b498b9bb90..c7c2c04256 100644 --- a/doc/classes/Tree.xml +++ b/doc/classes/Tree.xml @@ -36,35 +36,28 @@ </tutorials> <methods> <method name="are_column_titles_visible" qualifiers="const"> - <return type="bool"> - </return> + <return type="bool" /> <description> Returns [code]true[/code] if the column titles are being shown. </description> </method> <method name="clear"> - <return type="void"> - </return> + <return type="void" /> <description> Clears the tree. This removes all items. </description> </method> <method name="clear_column_title_opentype_features"> - <return type="void"> - </return> - <argument index="0" name="column" type="int"> - </argument> + <return type="void" /> + <argument index="0" name="column" type="int" /> <description> Removes all OpenType features from the item's text. </description> </method> <method name="create_item"> - <return type="TreeItem"> - </return> - <argument index="0" name="parent" type="Object" default="null"> - </argument> - <argument index="1" name="idx" type="int" default="-1"> - </argument> + <return type="TreeItem" /> + <argument index="0" name="parent" type="Object" default="null" /> + <argument index="1" name="idx" type="int" default="-1" /> <description> Creates an item in the tree and adds it as a child of [code]parent[/code]. If [code]parent[/code] is [code]null[/code], the root item will be the parent, or the new item will be the root itself if the tree is empty. @@ -72,15 +65,13 @@ </description> </method> <method name="edit_selected"> - <return type="bool"> - </return> + <return type="bool" /> <description> Edits the selected tree item as if it was clicked. The item must be set editable with [method TreeItem.set_editable]. Returns [code]true[/code] if the item could be edited. Fails if no item is selected. </description> </method> <method name="ensure_cursor_is_visible"> - <return type="void"> - </return> + <return type="void" /> <description> Makes the currently focused cell visible. This will scroll the tree if necessary. In [constant SELECT_ROW] mode, this will not do horizontal scrolling, as all the cells in the selected row is focused logically. @@ -88,81 +79,63 @@ </description> </method> <method name="get_column_at_position" qualifiers="const"> - <return type="int"> - </return> - <argument index="0" name="position" type="Vector2"> - </argument> + <return type="int" /> + <argument index="0" name="position" type="Vector2" /> <description> Returns the column index at [code]position[/code], or -1 if no item is there. </description> </method> <method name="get_column_expand_ratio" qualifiers="const"> - <return type="int"> - </return> - <argument index="0" name="column" type="int"> - </argument> + <return type="int" /> + <argument index="0" name="column" type="int" /> <description> </description> </method> <method name="get_column_title" qualifiers="const"> - <return type="String"> - </return> - <argument index="0" name="column" type="int"> - </argument> + <return type="String" /> + <argument index="0" name="column" type="int" /> <description> Returns the column's title. </description> </method> <method name="get_column_title_direction" qualifiers="const"> - <return type="int" enum="Control.TextDirection"> - </return> - <argument index="0" name="column" type="int"> - </argument> + <return type="int" enum="Control.TextDirection" /> + <argument index="0" name="column" type="int" /> <description> Returns column title base writing direction. </description> </method> <method name="get_column_title_language" qualifiers="const"> - <return type="String"> - </return> - <argument index="0" name="column" type="int"> - </argument> + <return type="String" /> + <argument index="0" name="column" type="int" /> <description> Returns column title language code. </description> </method> <method name="get_column_title_opentype_feature" qualifiers="const"> - <return type="int"> - </return> - <argument index="0" name="column" type="int"> - </argument> - <argument index="1" name="tag" type="String"> - </argument> + <return type="int" /> + <argument index="0" name="column" type="int" /> + <argument index="1" name="tag" type="String" /> <description> Returns OpenType feature [code]tag[/code] of the column title. </description> </method> <method name="get_column_width" qualifiers="const"> - <return type="int"> - </return> - <argument index="0" name="column" type="int"> - </argument> + <return type="int" /> + <argument index="0" name="column" type="int" /> <description> Returns the column's width in pixels. </description> </method> <method name="get_custom_popup_rect" qualifiers="const"> - <return type="Rect2"> - </return> + <return type="Rect2" /> <description> Returns the rectangle for custom popups. Helper to create custom cell controls that display a popup. See [method TreeItem.set_cell_mode]. </description> </method> <method name="get_drop_section_at_position" qualifiers="const"> - <return type="int"> - </return> - <argument index="0" name="position" type="Vector2"> - </argument> + <return type="int" /> + <argument index="0" name="position" type="Vector2" /> <description> Returns the drop section at [code]position[/code], or -100 if no item is there. Values -1, 0, or 1 will be returned for the "above item", "on item", and "below item" drop sections, respectively. See [enum DropModeFlags] for a description of each drop section. @@ -170,8 +143,7 @@ </description> </method> <method name="get_edited" qualifiers="const"> - <return type="TreeItem"> - </return> + <return type="TreeItem" /> <description> Returns the currently edited item. Can be used with [signal item_edited] to get the item that was modified. [codeblocks] @@ -197,66 +169,54 @@ </description> </method> <method name="get_edited_column" qualifiers="const"> - <return type="int"> - </return> + <return type="int" /> <description> Returns the column for the currently edited item. </description> </method> <method name="get_item_area_rect" qualifiers="const"> - <return type="Rect2"> - </return> - <argument index="0" name="item" type="Object"> - </argument> - <argument index="1" name="column" type="int" default="-1"> - </argument> + <return type="Rect2" /> + <argument index="0" name="item" type="Object" /> + <argument index="1" name="column" type="int" default="-1" /> <description> Returns the rectangle area for the specified item. If [code]column[/code] is specified, only get the position and size of that column, otherwise get the rectangle containing all columns. </description> </method> <method name="get_item_at_position" qualifiers="const"> - <return type="TreeItem"> - </return> - <argument index="0" name="position" type="Vector2"> - </argument> + <return type="TreeItem" /> + <argument index="0" name="position" type="Vector2" /> <description> Returns the tree item at the specified position (relative to the tree origin position). </description> </method> <method name="get_next_selected"> - <return type="TreeItem"> - </return> - <argument index="0" name="from" type="Object"> - </argument> + <return type="TreeItem" /> + <argument index="0" name="from" type="Object" /> <description> Returns the next selected item after the given one, or [code]null[/code] if the end is reached. If [code]from[/code] is [code]null[/code], this returns the first selected item. </description> </method> <method name="get_pressed_button" qualifiers="const"> - <return type="int"> - </return> + <return type="int" /> <description> Returns the last pressed button's index. </description> </method> <method name="get_root" qualifiers="const"> - <return type="TreeItem"> - </return> + <return type="TreeItem" /> <description> Returns the tree's root item, or [code]null[/code] if the tree is empty. </description> </method> <method name="get_scroll" qualifiers="const"> - <return type="Vector2"> - </return> + <return type="Vector2" /> <description> Returns the current scrolling position. </description> </method> <method name="get_selected" qualifiers="const"> - <return type="TreeItem"> - </return> + <return type="TreeItem" /> <description> Returns the currently focused item, or [code]null[/code] if no item is focused. In [constant SELECT_ROW] and [constant SELECT_SINGLE] modes, the focused item is same as the selected item. In [constant SELECT_MULTI] mode, the focused item is the item under the focus cursor, not necessarily selected. @@ -264,8 +224,7 @@ </description> </method> <method name="get_selected_column" qualifiers="const"> - <return type="int"> - </return> + <return type="int" /> <description> Returns the currently focused column, or -1 if no column is focused. In [constant SELECT_SINGLE] mode, the focused column is the selected column. In [constant SELECT_ROW] mode, the focused column is always 0 if any item is selected. In [constant SELECT_MULTI] mode, the focused column is the column under the focus cursor, and there are not necessarily any column selected. @@ -273,123 +232,90 @@ </description> </method> <method name="is_column_clipping_content" qualifiers="const"> - <return type="bool"> - </return> - <argument index="0" name="column" type="int"> - </argument> + <return type="bool" /> + <argument index="0" name="column" type="int" /> <description> </description> </method> <method name="is_column_expanding" qualifiers="const"> - <return type="bool"> - </return> - <argument index="0" name="column" type="int"> - </argument> + <return type="bool" /> + <argument index="0" name="column" type="int" /> <description> </description> </method> <method name="scroll_to_item"> - <return type="void"> - </return> - <argument index="0" name="item" type="Object"> - </argument> + <return type="void" /> + <argument index="0" name="item" type="Object" /> <description> Causes the [Tree] to jump to the specified item. </description> </method> <method name="set_column_clip_content"> - <return type="void"> - </return> - <argument index="0" name="column" type="int"> - </argument> - <argument index="1" name="enable" type="bool"> - </argument> + <return type="void" /> + <argument index="0" name="column" type="int" /> + <argument index="1" name="enable" type="bool" /> <description> </description> </method> <method name="set_column_custom_minimum_width"> - <return type="void"> - </return> - <argument index="0" name="column" type="int"> - </argument> - <argument index="1" name="min_width" type="int"> - </argument> + <return type="void" /> + <argument index="0" name="column" type="int" /> + <argument index="1" name="min_width" type="int" /> <description> Overrides the calculated minimum width of a column. It can be set to `0` to restore the default behavior. Columns that have the "Expand" flag will use their "min_width" in a similar fashion to [member Control.size_flags_stretch_ratio]. </description> </method> <method name="set_column_expand"> - <return type="void"> - </return> - <argument index="0" name="column" type="int"> - </argument> - <argument index="1" name="expand" type="bool"> - </argument> + <return type="void" /> + <argument index="0" name="column" type="int" /> + <argument index="1" name="expand" type="bool" /> <description> If [code]true[/code], the column will have the "Expand" flag of [Control]. Columns that have the "Expand" flag will use their "min_width" in a similar fashion to [member Control.size_flags_stretch_ratio]. </description> </method> <method name="set_column_expand_ratio"> - <return type="void"> - </return> - <argument index="0" name="column" type="int"> - </argument> - <argument index="1" name="ratio" type="int"> - </argument> + <return type="void" /> + <argument index="0" name="column" type="int" /> + <argument index="1" name="ratio" type="int" /> <description> </description> </method> <method name="set_column_title"> - <return type="void"> - </return> - <argument index="0" name="column" type="int"> - </argument> - <argument index="1" name="title" type="String"> - </argument> + <return type="void" /> + <argument index="0" name="column" type="int" /> + <argument index="1" name="title" type="String" /> <description> Sets the title of a column. </description> </method> <method name="set_column_title_direction"> - <return type="void"> - </return> - <argument index="0" name="column" type="int"> - </argument> - <argument index="1" name="direction" type="int" enum="Control.TextDirection"> - </argument> + <return type="void" /> + <argument index="0" name="column" type="int" /> + <argument index="1" name="direction" type="int" enum="Control.TextDirection" /> <description> Sets column title base writing direction. </description> </method> <method name="set_column_title_language"> - <return type="void"> - </return> - <argument index="0" name="column" type="int"> - </argument> - <argument index="1" name="language" type="String"> - </argument> + <return type="void" /> + <argument index="0" name="column" type="int" /> + <argument index="1" name="language" type="String" /> <description> Sets language code of column title used for line-breaking and text shaping algorithms, if left empty current locale is used instead. </description> </method> <method name="set_column_title_opentype_feature"> - <return type="void"> - </return> - <argument index="0" name="column" type="int"> - </argument> - <argument index="1" name="tag" type="String"> - </argument> - <argument index="2" name="value" type="int"> - </argument> + <return type="void" /> + <argument index="0" name="column" type="int" /> + <argument index="1" name="tag" type="String" /> + <argument index="2" name="value" type="int" /> <description> Sets OpenType feature [code]tag[/code] for the column title. </description> </method> <method name="set_column_titles_visible"> - <return type="void"> - </return> - <argument index="0" name="visible" type="bool"> - </argument> + <return type="void" /> + <argument index="0" name="visible" type="bool" /> <description> If [code]true[/code], column titles are visible. </description> @@ -429,12 +355,9 @@ </members> <signals> <signal name="button_pressed"> - <argument index="0" name="item" type="TreeItem"> - </argument> - <argument index="1" name="column" type="int"> - </argument> - <argument index="2" name="id" type="int"> - </argument> + <argument index="0" name="item" type="TreeItem" /> + <argument index="1" name="column" type="int" /> + <argument index="2" name="id" type="int" /> <description> Emitted when a button on the tree was pressed (see [method TreeItem.add_button]). </description> @@ -445,29 +368,25 @@ </description> </signal> <signal name="column_title_pressed"> - <argument index="0" name="column" type="int"> - </argument> + <argument index="0" name="column" type="int" /> <description> Emitted when a column's title is pressed. </description> </signal> <signal name="custom_popup_edited"> - <argument index="0" name="arrow_clicked" type="bool"> - </argument> + <argument index="0" name="arrow_clicked" type="bool" /> <description> Emitted when a cell with the [constant TreeItem.CELL_MODE_CUSTOM] is clicked to be edited. </description> </signal> <signal name="empty_rmb"> - <argument index="0" name="position" type="Vector2"> - </argument> + <argument index="0" name="position" type="Vector2" /> <description> Emitted when the right mouse button is pressed in the empty space of the tree. </description> </signal> <signal name="empty_tree_rmb_selected"> - <argument index="0" name="position" type="Vector2"> - </argument> + <argument index="0" name="position" type="Vector2" /> <description> Emitted when the right mouse button is pressed if right mouse button selection is active and the tree is empty. </description> @@ -478,8 +397,7 @@ </description> </signal> <signal name="item_collapsed"> - <argument index="0" name="item" type="TreeItem"> - </argument> + <argument index="0" name="item" type="TreeItem" /> <description> Emitted when an item is collapsed by a click on the folding arrow. </description> @@ -505,8 +423,7 @@ </description> </signal> <signal name="item_rmb_selected"> - <argument index="0" name="position" type="Vector2"> - </argument> + <argument index="0" name="position" type="Vector2" /> <description> Emitted when an item is selected with the right mouse button. </description> @@ -517,12 +434,9 @@ </description> </signal> <signal name="multi_selected"> - <argument index="0" name="item" type="TreeItem"> - </argument> - <argument index="1" name="column" type="int"> - </argument> - <argument index="2" name="selected" type="bool"> - </argument> + <argument index="0" name="item" type="TreeItem" /> + <argument index="1" name="column" type="int" /> + <argument index="2" name="selected" type="bool" /> <description> Emitted instead of [code]item_selected[/code] if [code]select_mode[/code] is [constant SELECT_MULTI]. </description> diff --git a/doc/classes/TreeItem.xml b/doc/classes/TreeItem.xml index 85c9caa101..944b9fdc06 100644 --- a/doc/classes/TreeItem.xml +++ b/doc/classes/TreeItem.xml @@ -11,811 +11,611 @@ </tutorials> <methods> <method name="add_button"> - <return type="void"> - </return> - <argument index="0" name="column" type="int"> - </argument> - <argument index="1" name="button" type="Texture2D"> - </argument> - <argument index="2" name="button_idx" type="int" default="-1"> - </argument> - <argument index="3" name="disabled" type="bool" default="false"> - </argument> - <argument index="4" name="tooltip" type="String" default=""""> - </argument> + <return type="void" /> + <argument index="0" name="column" type="int" /> + <argument index="1" name="button" type="Texture2D" /> + <argument index="2" name="button_idx" type="int" default="-1" /> + <argument index="3" name="disabled" type="bool" default="false" /> + <argument index="4" name="tooltip" type="String" default="""" /> <description> Adds a button with [Texture2D] [code]button[/code] at column [code]column[/code]. The [code]button_idx[/code] index is used to identify the button when calling other methods. If not specified, the next available index is used, which may be retrieved by calling [method get_button_count] immediately after this method. Optionally, the button can be [code]disabled[/code] and have a [code]tooltip[/code]. </description> </method> <method name="call_recursive" qualifiers="vararg"> - <return type="Variant"> - </return> - <argument index="0" name="method" type="StringName"> - </argument> + <return type="Variant" /> + <argument index="0" name="method" type="StringName" /> <description> Calls the [code]method[/code] on the actual TreeItem and its children recursively. Pass parameters as a comma separated list. </description> </method> <method name="clear_custom_bg_color"> - <return type="void"> - </return> - <argument index="0" name="column" type="int"> - </argument> + <return type="void" /> + <argument index="0" name="column" type="int" /> <description> Resets the background color for the given column to default. </description> </method> <method name="clear_custom_color"> - <return type="void"> - </return> - <argument index="0" name="column" type="int"> - </argument> + <return type="void" /> + <argument index="0" name="column" type="int" /> <description> Resets the color for the given column to default. </description> </method> <method name="clear_opentype_features"> - <return type="void"> - </return> - <argument index="0" name="column" type="int"> - </argument> + <return type="void" /> + <argument index="0" name="column" type="int" /> <description> Removes all OpenType features. </description> </method> <method name="create_child"> - <return type="TreeItem"> - </return> - <argument index="0" name="idx" type="int" default="-1"> - </argument> + <return type="TreeItem" /> + <argument index="0" name="idx" type="int" default="-1" /> <description> Creates an item and adds it as a child. The new item will be inserted as position [code]idx[/code] (the default value [code]-1[/code] means the last position), or it will be the last child if [code]idx[/code] is higher than the child count. </description> </method> <method name="deselect"> - <return type="void"> - </return> - <argument index="0" name="column" type="int"> - </argument> + <return type="void" /> + <argument index="0" name="column" type="int" /> <description> Deselects the given column. </description> </method> <method name="erase_button"> - <return type="void"> - </return> - <argument index="0" name="column" type="int"> - </argument> - <argument index="1" name="button_idx" type="int"> - </argument> + <return type="void" /> + <argument index="0" name="column" type="int" /> + <argument index="1" name="button_idx" type="int" /> <description> Removes the button at index [code]button_idx[/code] in column [code]column[/code]. </description> </method> <method name="get_button" qualifiers="const"> - <return type="Texture2D"> - </return> - <argument index="0" name="column" type="int"> - </argument> - <argument index="1" name="button_idx" type="int"> - </argument> + <return type="Texture2D" /> + <argument index="0" name="column" type="int" /> + <argument index="1" name="button_idx" type="int" /> <description> Returns the [Texture2D] of the button at index [code]button_idx[/code] in column [code]column[/code]. </description> </method> <method name="get_button_count" qualifiers="const"> - <return type="int"> - </return> - <argument index="0" name="column" type="int"> - </argument> + <return type="int" /> + <argument index="0" name="column" type="int" /> <description> Returns the number of buttons in column [code]column[/code]. May be used to get the most recently added button's index, if no index was specified. </description> </method> <method name="get_button_tooltip" qualifiers="const"> - <return type="String"> - </return> - <argument index="0" name="column" type="int"> - </argument> - <argument index="1" name="button_idx" type="int"> - </argument> + <return type="String" /> + <argument index="0" name="column" type="int" /> + <argument index="1" name="button_idx" type="int" /> <description> Returns the tooltip string for the button at index [code]button_idx[/code] in column [code]column[/code]. </description> </method> <method name="get_cell_mode" qualifiers="const"> - <return type="int" enum="TreeItem.TreeCellMode"> - </return> - <argument index="0" name="column" type="int"> - </argument> + <return type="int" enum="TreeItem.TreeCellMode" /> + <argument index="0" name="column" type="int" /> <description> Returns the column's cell mode. </description> </method> <method name="get_child"> - <return type="TreeItem"> - </return> - <argument index="0" name="idx" type="int"> - </argument> + <return type="TreeItem" /> + <argument index="0" name="idx" type="int" /> <description> Returns a child item by its index (see [method get_child_count]). This method is often used for iterating all children of an item. Negative indices access the children from the last one. </description> </method> <method name="get_child_count"> - <return type="int"> - </return> + <return type="int" /> <description> Returns the number of child items. </description> </method> <method name="get_children"> - <return type="Array"> - </return> + <return type="Array" /> <description> Returns an array of references to the item's children. </description> </method> <method name="get_custom_bg_color" qualifiers="const"> - <return type="Color"> - </return> - <argument index="0" name="column" type="int"> - </argument> + <return type="Color" /> + <argument index="0" name="column" type="int" /> <description> Returns the custom background color of column [code]column[/code]. </description> </method> <method name="get_custom_color" qualifiers="const"> - <return type="Color"> - </return> - <argument index="0" name="column" type="int"> - </argument> + <return type="Color" /> + <argument index="0" name="column" type="int" /> <description> Returns the custom color of column [code]column[/code]. </description> </method> <method name="get_custom_font" qualifiers="const"> - <return type="Font"> - </return> - <argument index="0" name="column" type="int"> - </argument> + <return type="Font" /> + <argument index="0" name="column" type="int" /> <description> </description> </method> <method name="get_expand_right" qualifiers="const"> - <return type="bool"> - </return> - <argument index="0" name="column" type="int"> - </argument> + <return type="bool" /> + <argument index="0" name="column" type="int" /> <description> Returns [code]true[/code] if [code]expand_right[/code] is set. </description> </method> <method name="get_first_child" qualifiers="const"> - <return type="TreeItem"> - </return> + <return type="TreeItem" /> <description> Returns the TreeItem's first child. </description> </method> <method name="get_icon" qualifiers="const"> - <return type="Texture2D"> - </return> - <argument index="0" name="column" type="int"> - </argument> + <return type="Texture2D" /> + <argument index="0" name="column" type="int" /> <description> Returns the given column's icon [Texture2D]. Error if no icon is set. </description> </method> <method name="get_icon_max_width" qualifiers="const"> - <return type="int"> - </return> - <argument index="0" name="column" type="int"> - </argument> + <return type="int" /> + <argument index="0" name="column" type="int" /> <description> Returns the column's icon's maximum width. </description> </method> <method name="get_icon_modulate" qualifiers="const"> - <return type="Color"> - </return> - <argument index="0" name="column" type="int"> - </argument> + <return type="Color" /> + <argument index="0" name="column" type="int" /> <description> Returns the [Color] modulating the column's icon. </description> </method> <method name="get_icon_region" qualifiers="const"> - <return type="Rect2"> - </return> - <argument index="0" name="column" type="int"> - </argument> + <return type="Rect2" /> + <argument index="0" name="column" type="int" /> <description> Returns the icon [Texture2D] region as [Rect2]. </description> </method> <method name="get_index"> - <return type="int"> - </return> + <return type="int" /> <description> Returns the node's order in the tree. For example, if called on the first child item the position is [code]0[/code]. </description> </method> <method name="get_language" qualifiers="const"> - <return type="String"> - </return> - <argument index="0" name="column" type="int"> - </argument> + <return type="String" /> + <argument index="0" name="column" type="int" /> <description> Returns item's text language code. </description> </method> <method name="get_metadata" qualifiers="const"> - <return type="Variant"> - </return> - <argument index="0" name="column" type="int"> - </argument> + <return type="Variant" /> + <argument index="0" name="column" type="int" /> <description> Returns the metadata value that was set for the given column using [method set_metadata]. </description> </method> <method name="get_next" qualifiers="const"> - <return type="TreeItem"> - </return> + <return type="TreeItem" /> <description> Returns the next TreeItem in the tree or a null object if there is none. </description> </method> <method name="get_next_visible"> - <return type="TreeItem"> - </return> - <argument index="0" name="wrap" type="bool" default="false"> - </argument> + <return type="TreeItem" /> + <argument index="0" name="wrap" type="bool" default="false" /> <description> Returns the next visible TreeItem in the tree or a null object if there is none. If [code]wrap[/code] is enabled, the method will wrap around to the first visible element in the tree when called on the last visible element, otherwise it returns [code]null[/code]. </description> </method> <method name="get_opentype_feature" qualifiers="const"> - <return type="int"> - </return> - <argument index="0" name="column" type="int"> - </argument> - <argument index="1" name="tag" type="String"> - </argument> + <return type="int" /> + <argument index="0" name="column" type="int" /> + <argument index="1" name="tag" type="String" /> <description> Returns OpenType feature [code]tag[/code] of the item's text. </description> </method> <method name="get_parent" qualifiers="const"> - <return type="TreeItem"> - </return> + <return type="TreeItem" /> <description> Returns the parent TreeItem or a null object if there is none. </description> </method> <method name="get_prev"> - <return type="TreeItem"> - </return> + <return type="TreeItem" /> <description> Returns the previous TreeItem in the tree or a null object if there is none. </description> </method> <method name="get_prev_visible"> - <return type="TreeItem"> - </return> - <argument index="0" name="wrap" type="bool" default="false"> - </argument> + <return type="TreeItem" /> + <argument index="0" name="wrap" type="bool" default="false" /> <description> Returns the previous visible TreeItem in the tree or a null object if there is none. If [code]wrap[/code] is enabled, the method will wrap around to the last visible element in the tree when called on the first visible element, otherwise it returns [code]null[/code]. </description> </method> <method name="get_range" qualifiers="const"> - <return type="float"> - </return> - <argument index="0" name="column" type="int"> - </argument> + <return type="float" /> + <argument index="0" name="column" type="int" /> <description> Returns the value of a [constant CELL_MODE_RANGE] column. </description> </method> <method name="get_range_config"> - <return type="Dictionary"> - </return> - <argument index="0" name="column" type="int"> - </argument> + <return type="Dictionary" /> + <argument index="0" name="column" type="int" /> <description> Returns a dictionary containing the range parameters for a given column. The keys are "min", "max", "step", and "expr". </description> </method> <method name="get_structured_text_bidi_override" qualifiers="const"> - <return type="int" enum="Control.StructuredTextParser"> - </return> - <argument index="0" name="column" type="int"> - </argument> + <return type="int" enum="Control.StructuredTextParser" /> + <argument index="0" name="column" type="int" /> <description> </description> </method> <method name="get_structured_text_bidi_override_options" qualifiers="const"> - <return type="Array"> - </return> - <argument index="0" name="column" type="int"> - </argument> + <return type="Array" /> + <argument index="0" name="column" type="int" /> <description> </description> </method> <method name="get_suffix" qualifiers="const"> - <return type="String"> - </return> - <argument index="0" name="column" type="int"> - </argument> + <return type="String" /> + <argument index="0" name="column" type="int" /> <description> Gets the suffix string shown after the column value. </description> </method> <method name="get_text" qualifiers="const"> - <return type="String"> - </return> - <argument index="0" name="column" type="int"> - </argument> + <return type="String" /> + <argument index="0" name="column" type="int" /> <description> Returns the given column's text. </description> </method> <method name="get_text_align" qualifiers="const"> - <return type="int" enum="TreeItem.TextAlign"> - </return> - <argument index="0" name="column" type="int"> - </argument> + <return type="int" enum="TreeItem.TextAlign" /> + <argument index="0" name="column" type="int" /> <description> Returns the given column's text alignment. </description> </method> <method name="get_text_direction" qualifiers="const"> - <return type="int" enum="Control.TextDirection"> - </return> - <argument index="0" name="column" type="int"> - </argument> + <return type="int" enum="Control.TextDirection" /> + <argument index="0" name="column" type="int" /> <description> Returns item's text base writing direction. </description> </method> <method name="get_tooltip" qualifiers="const"> - <return type="String"> - </return> - <argument index="0" name="column" type="int"> - </argument> + <return type="String" /> + <argument index="0" name="column" type="int" /> <description> Returns the given column's tooltip. </description> </method> <method name="get_tree" qualifiers="const"> - <return type="Tree"> - </return> + <return type="Tree" /> <description> Returns the [Tree] that owns this TreeItem. </description> </method> <method name="is_button_disabled" qualifiers="const"> - <return type="bool"> - </return> - <argument index="0" name="column" type="int"> - </argument> - <argument index="1" name="button_idx" type="int"> - </argument> + <return type="bool" /> + <argument index="0" name="column" type="int" /> + <argument index="1" name="button_idx" type="int" /> <description> Returns [code]true[/code] if the button at index [code]button_idx[/code] for the given column is disabled. </description> </method> <method name="is_checked" qualifiers="const"> - <return type="bool"> - </return> - <argument index="0" name="column" type="int"> - </argument> + <return type="bool" /> + <argument index="0" name="column" type="int" /> <description> Returns [code]true[/code] if the given column is checked. </description> </method> <method name="is_custom_set_as_button" qualifiers="const"> - <return type="bool"> - </return> - <argument index="0" name="column" type="int"> - </argument> + <return type="bool" /> + <argument index="0" name="column" type="int" /> <description> </description> </method> <method name="is_editable"> - <return type="bool"> - </return> - <argument index="0" name="column" type="int"> - </argument> + <return type="bool" /> + <argument index="0" name="column" type="int" /> <description> Returns [code]true[/code] if column [code]column[/code] is editable. </description> </method> <method name="is_selectable" qualifiers="const"> - <return type="bool"> - </return> - <argument index="0" name="column" type="int"> - </argument> + <return type="bool" /> + <argument index="0" name="column" type="int" /> <description> Returns [code]true[/code] if column [code]column[/code] is selectable. </description> </method> <method name="is_selected"> - <return type="bool"> - </return> - <argument index="0" name="column" type="int"> - </argument> + <return type="bool" /> + <argument index="0" name="column" type="int" /> <description> Returns [code]true[/code] if column [code]column[/code] is selected. </description> </method> <method name="move_after"> - <return type="void"> - </return> - <argument index="0" name="item" type="Object"> - </argument> + <return type="void" /> + <argument index="0" name="item" type="Object" /> <description> Moves this TreeItem right after the given [code]item[/code]. [b]Note:[/b] You can't move to the root or move the root. </description> </method> <method name="move_before"> - <return type="void"> - </return> - <argument index="0" name="item" type="Object"> - </argument> + <return type="void" /> + <argument index="0" name="item" type="Object" /> <description> Moves this TreeItem right before the given [code]item[/code]. [b]Note:[/b] You can't move to the root or move the root. </description> </method> <method name="remove_child"> - <return type="void"> - </return> - <argument index="0" name="child" type="Object"> - </argument> + <return type="void" /> + <argument index="0" name="child" type="Object" /> <description> Removes the given child [TreeItem] and all its children from the [Tree]. Note that it doesn't free the item from memory, so it can be reused later. To completely remove a [TreeItem] use [method Object.free]. </description> </method> <method name="select"> - <return type="void"> - </return> - <argument index="0" name="column" type="int"> - </argument> + <return type="void" /> + <argument index="0" name="column" type="int" /> <description> Selects the column [code]column[/code]. </description> </method> <method name="set_button"> - <return type="void"> - </return> - <argument index="0" name="column" type="int"> - </argument> - <argument index="1" name="button_idx" type="int"> - </argument> - <argument index="2" name="button" type="Texture2D"> - </argument> + <return type="void" /> + <argument index="0" name="column" type="int" /> + <argument index="1" name="button_idx" type="int" /> + <argument index="2" name="button" type="Texture2D" /> <description> Sets the given column's button [Texture2D] at index [code]button_idx[/code] to [code]button[/code]. </description> </method> <method name="set_button_disabled"> - <return type="void"> - </return> - <argument index="0" name="column" type="int"> - </argument> - <argument index="1" name="button_idx" type="int"> - </argument> - <argument index="2" name="disabled" type="bool"> - </argument> + <return type="void" /> + <argument index="0" name="column" type="int" /> + <argument index="1" name="button_idx" type="int" /> + <argument index="2" name="disabled" type="bool" /> <description> If [code]true[/code], disables the button at index [code]button_idx[/code] in column [code]column[/code]. </description> </method> <method name="set_cell_mode"> - <return type="void"> - </return> - <argument index="0" name="column" type="int"> - </argument> - <argument index="1" name="mode" type="int" enum="TreeItem.TreeCellMode"> - </argument> + <return type="void" /> + <argument index="0" name="column" type="int" /> + <argument index="1" name="mode" type="int" enum="TreeItem.TreeCellMode" /> <description> Sets the given column's cell mode to [code]mode[/code]. See [enum TreeCellMode] constants. </description> </method> <method name="set_checked"> - <return type="void"> - </return> - <argument index="0" name="column" type="int"> - </argument> - <argument index="1" name="checked" type="bool"> - </argument> + <return type="void" /> + <argument index="0" name="column" type="int" /> + <argument index="1" name="checked" type="bool" /> <description> If [code]true[/code], the column [code]column[/code] is checked. </description> </method> <method name="set_custom_as_button"> - <return type="void"> - </return> - <argument index="0" name="column" type="int"> - </argument> - <argument index="1" name="enable" type="bool"> - </argument> + <return type="void" /> + <argument index="0" name="column" type="int" /> + <argument index="1" name="enable" type="bool" /> <description> </description> </method> <method name="set_custom_bg_color"> - <return type="void"> - </return> - <argument index="0" name="column" type="int"> - </argument> - <argument index="1" name="color" type="Color"> - </argument> - <argument index="2" name="just_outline" type="bool" default="false"> - </argument> + <return type="void" /> + <argument index="0" name="column" type="int" /> + <argument index="1" name="color" type="Color" /> + <argument index="2" name="just_outline" type="bool" default="false" /> <description> Sets the given column's custom background color and whether to just use it as an outline. </description> </method> <method name="set_custom_color"> - <return type="void"> - </return> - <argument index="0" name="column" type="int"> - </argument> - <argument index="1" name="color" type="Color"> - </argument> + <return type="void" /> + <argument index="0" name="column" type="int" /> + <argument index="1" name="color" type="Color" /> <description> Sets the given column's custom color. </description> </method> <method name="set_custom_draw"> - <return type="void"> - </return> - <argument index="0" name="column" type="int"> - </argument> - <argument index="1" name="object" type="Object"> - </argument> - <argument index="2" name="callback" type="StringName"> - </argument> + <return type="void" /> + <argument index="0" name="column" type="int" /> + <argument index="1" name="object" type="Object" /> + <argument index="2" name="callback" type="StringName" /> <description> Sets the given column's custom draw callback to [code]callback[/code] method on [code]object[/code]. The [code]callback[/code] should accept two arguments: the [TreeItem] that is drawn and its position and size as a [Rect2]. </description> </method> <method name="set_custom_font"> - <return type="void"> - </return> - <argument index="0" name="column" type="int"> - </argument> - <argument index="1" name="font" type="Font"> - </argument> + <return type="void" /> + <argument index="0" name="column" type="int" /> + <argument index="1" name="font" type="Font" /> <description> </description> </method> <method name="set_editable"> - <return type="void"> - </return> - <argument index="0" name="column" type="int"> - </argument> - <argument index="1" name="enabled" type="bool"> - </argument> + <return type="void" /> + <argument index="0" name="column" type="int" /> + <argument index="1" name="enabled" type="bool" /> <description> If [code]true[/code], column [code]column[/code] is editable. </description> </method> <method name="set_expand_right"> - <return type="void"> - </return> - <argument index="0" name="column" type="int"> - </argument> - <argument index="1" name="enable" type="bool"> - </argument> + <return type="void" /> + <argument index="0" name="column" type="int" /> + <argument index="1" name="enable" type="bool" /> <description> If [code]true[/code], column [code]column[/code] is expanded to the right. </description> </method> <method name="set_icon"> - <return type="void"> - </return> - <argument index="0" name="column" type="int"> - </argument> - <argument index="1" name="texture" type="Texture2D"> - </argument> + <return type="void" /> + <argument index="0" name="column" type="int" /> + <argument index="1" name="texture" type="Texture2D" /> <description> Sets the given column's icon [Texture2D]. </description> </method> <method name="set_icon_max_width"> - <return type="void"> - </return> - <argument index="0" name="column" type="int"> - </argument> - <argument index="1" name="width" type="int"> - </argument> + <return type="void" /> + <argument index="0" name="column" type="int" /> + <argument index="1" name="width" type="int" /> <description> Sets the given column's icon's maximum width. </description> </method> <method name="set_icon_modulate"> - <return type="void"> - </return> - <argument index="0" name="column" type="int"> - </argument> - <argument index="1" name="modulate" type="Color"> - </argument> + <return type="void" /> + <argument index="0" name="column" type="int" /> + <argument index="1" name="modulate" type="Color" /> <description> Modulates the given column's icon with [code]modulate[/code]. </description> </method> <method name="set_icon_region"> - <return type="void"> - </return> - <argument index="0" name="column" type="int"> - </argument> - <argument index="1" name="region" type="Rect2"> - </argument> + <return type="void" /> + <argument index="0" name="column" type="int" /> + <argument index="1" name="region" type="Rect2" /> <description> Sets the given column's icon's texture region. </description> </method> <method name="set_language"> - <return type="void"> - </return> - <argument index="0" name="column" type="int"> - </argument> - <argument index="1" name="language" type="String"> - </argument> + <return type="void" /> + <argument index="0" name="column" type="int" /> + <argument index="1" name="language" type="String" /> <description> Sets language code of item's text used for line-breaking and text shaping algorithms, if left empty current locale is used instead. </description> </method> <method name="set_metadata"> - <return type="void"> - </return> - <argument index="0" name="column" type="int"> - </argument> - <argument index="1" name="meta" type="Variant"> - </argument> + <return type="void" /> + <argument index="0" name="column" type="int" /> + <argument index="1" name="meta" type="Variant" /> <description> Sets the metadata value for the given column, which can be retrieved later using [method get_metadata]. This can be used, for example, to store a reference to the original data. </description> </method> <method name="set_opentype_feature"> - <return type="void"> - </return> - <argument index="0" name="column" type="int"> - </argument> - <argument index="1" name="tag" type="String"> - </argument> - <argument index="2" name="value" type="int"> - </argument> + <return type="void" /> + <argument index="0" name="column" type="int" /> + <argument index="1" name="tag" type="String" /> + <argument index="2" name="value" type="int" /> <description> Sets OpenType feature [code]tag[/code] for the item's text. </description> </method> <method name="set_range"> - <return type="void"> - </return> - <argument index="0" name="column" type="int"> - </argument> - <argument index="1" name="value" type="float"> - </argument> + <return type="void" /> + <argument index="0" name="column" type="int" /> + <argument index="1" name="value" type="float" /> <description> Sets the value of a [constant CELL_MODE_RANGE] column. </description> </method> <method name="set_range_config"> - <return type="void"> - </return> - <argument index="0" name="column" type="int"> - </argument> - <argument index="1" name="min" type="float"> - </argument> - <argument index="2" name="max" type="float"> - </argument> - <argument index="3" name="step" type="float"> - </argument> - <argument index="4" name="expr" type="bool" default="false"> - </argument> + <return type="void" /> + <argument index="0" name="column" type="int" /> + <argument index="1" name="min" type="float" /> + <argument index="2" name="max" type="float" /> + <argument index="3" name="step" type="float" /> + <argument index="4" name="expr" type="bool" default="false" /> <description> Sets the range of accepted values for a column. The column must be in the [constant CELL_MODE_RANGE] mode. If [code]expr[/code] is [code]true[/code], the edit mode slider will use an exponential scale as with [member Range.exp_edit]. </description> </method> <method name="set_selectable"> - <return type="void"> - </return> - <argument index="0" name="column" type="int"> - </argument> - <argument index="1" name="selectable" type="bool"> - </argument> + <return type="void" /> + <argument index="0" name="column" type="int" /> + <argument index="1" name="selectable" type="bool" /> <description> If [code]true[/code], the given column is selectable. </description> </method> <method name="set_structured_text_bidi_override"> - <return type="void"> - </return> - <argument index="0" name="column" type="int"> - </argument> - <argument index="1" name="parser" type="int" enum="Control.StructuredTextParser"> - </argument> + <return type="void" /> + <argument index="0" name="column" type="int" /> + <argument index="1" name="parser" type="int" enum="Control.StructuredTextParser" /> <description> </description> </method> <method name="set_structured_text_bidi_override_options"> - <return type="void"> - </return> - <argument index="0" name="column" type="int"> - </argument> - <argument index="1" name="args" type="Array"> - </argument> + <return type="void" /> + <argument index="0" name="column" type="int" /> + <argument index="1" name="args" type="Array" /> <description> </description> </method> <method name="set_suffix"> - <return type="void"> - </return> - <argument index="0" name="column" type="int"> - </argument> - <argument index="1" name="text" type="String"> - </argument> + <return type="void" /> + <argument index="0" name="column" type="int" /> + <argument index="1" name="text" type="String" /> <description> Sets a string to be shown after a column's value (for example, a unit abbreviation). </description> </method> <method name="set_text"> - <return type="void"> - </return> - <argument index="0" name="column" type="int"> - </argument> - <argument index="1" name="text" type="String"> - </argument> + <return type="void" /> + <argument index="0" name="column" type="int" /> + <argument index="1" name="text" type="String" /> <description> Sets the given column's text value. </description> </method> <method name="set_text_align"> - <return type="void"> - </return> - <argument index="0" name="column" type="int"> - </argument> - <argument index="1" name="text_align" type="int" enum="TreeItem.TextAlign"> - </argument> + <return type="void" /> + <argument index="0" name="column" type="int" /> + <argument index="1" name="text_align" type="int" enum="TreeItem.TextAlign" /> <description> Sets the given column's text alignment. See [enum TextAlign] for possible values. </description> </method> <method name="set_text_direction"> - <return type="void"> - </return> - <argument index="0" name="column" type="int"> - </argument> - <argument index="1" name="direction" type="int" enum="Control.TextDirection"> - </argument> + <return type="void" /> + <argument index="0" name="column" type="int" /> + <argument index="1" name="direction" type="int" enum="Control.TextDirection" /> <description> Sets item's text base writing direction. </description> </method> <method name="set_tooltip"> - <return type="void"> - </return> - <argument index="0" name="column" type="int"> - </argument> - <argument index="1" name="tooltip" type="String"> - </argument> + <return type="void" /> + <argument index="0" name="column" type="int" /> + <argument index="1" name="tooltip" type="String" /> <description> Sets the given column's tooltip text. </description> </method> <method name="uncollapse_tree"> - <return type="void"> - </return> + <return type="void" /> <description> </description> </method> diff --git a/doc/classes/Tween.xml b/doc/classes/Tween.xml index 253822cf32..372a6e7ebf 100644 --- a/doc/classes/Tween.xml +++ b/doc/classes/Tween.xml @@ -44,18 +44,15 @@ </tutorials> <methods> <method name="bind_node"> - <return type="Tween"> - </return> - <argument index="0" name="node" type="Node"> - </argument> + <return type="Tween" /> + <argument index="0" name="node" type="Node" /> <description> Binds this [Tween] with the given [code]node[/code]. [Tween]s are processed directly by the [SceneTree], so they run independently of the animated nodes. When you bind a [Node] with the [Tween], the [Tween] will halt the animation when the object is not inside tree and the [Tween] will be automatically killed when the bound object is freed. Also [constant TWEEN_PAUSE_BOUND] will make the pausing behavior dependent on the bound node. For a shorter way to create and bind a [Tween], you can use [method Node.create_tween]. </description> </method> <method name="chain"> - <return type="Tween"> - </return> + <return type="Tween" /> <description> Used to chain two [Tweener]s after [method set_parallel] is called with [code]true[/code]. [codeblock] @@ -67,10 +64,8 @@ </description> </method> <method name="custom_step"> - <return type="bool"> - </return> - <argument index="0" name="delta" type="float"> - </argument> + <return type="bool" /> + <argument index="0" name="delta" type="float" /> <description> Processes the [Tween] by given [code]delta[/code] value, in seconds. Mostly useful when the [Tween] is paused, for controlling it manually. Can also be used to end the [Tween] animation immediately, by using [code]delta[/code] longer than the whole duration. Returns [code]true[/code] if the [Tween] still has [Tweener]s that haven't finished. @@ -78,20 +73,13 @@ </description> </method> <method name="interpolate_value"> - <return type="Variant"> - </return> - <argument index="0" name="trans_type" type="Variant"> - </argument> - <argument index="1" name="ease_type" type="Variant"> - </argument> - <argument index="2" name="elapsed_time" type="float"> - </argument> - <argument index="3" name="initial_value" type="float"> - </argument> - <argument index="4" name="delta_value" type="int" enum="Tween.TransitionType"> - </argument> - <argument index="5" name="duration" type="int" enum="Tween.EaseType"> - </argument> + <return type="Variant" /> + <argument index="0" name="trans_type" type="Variant" /> + <argument index="1" name="ease_type" type="Variant" /> + <argument index="2" name="elapsed_time" type="float" /> + <argument index="3" name="initial_value" type="float" /> + <argument index="4" name="delta_value" type="int" enum="Tween.TransitionType" /> + <argument index="5" name="duration" type="int" enum="Tween.EaseType" /> <description> This method can be used for manual interpolation of a value, when you don't want [Tween] to do animating for you. It's similar to [method @GlobalScope.lerp], but with support for custom transition and easing. [code]elapsed_time[/code] is the time in seconds that passed after the interping started and it's used to control the position of the interpolation. E.g. when it's equal to half of the [code]duration[/code], the interpolated value will be halfway between initial and final values. This value can also be greater than [code]duration[/code] or lower than 0, which will extrapolate the value. @@ -101,31 +89,27 @@ </description> </method> <method name="is_running"> - <return type="bool"> - </return> + <return type="bool" /> <description> Returns whether the [Tween] is currently running, i.e. it wasn't paused and it's not finished. </description> </method> <method name="is_valid"> - <return type="bool"> - </return> + <return type="bool" /> <description> Returns whether the [Tween] is valid. A valid [Tween] is a [Tween] contained by the scene tree (i.e. the array from [method SceneTree.get_processed_tweens] will contain this [Tween]). [Tween] might become invalid when it has finished tweening or was killed, also when created with [code]Tween.new()[/code]. Invalid [Tween] can't have [Tweener]s appended, because it can't animate them. You can however still use [method interpolate_value]. </description> </method> <method name="kill"> - <return type="void"> - </return> + <return type="void" /> <description> Aborts all tweening operations and invalidates the [Tween]. </description> </method> <method name="parallel"> - <return type="Tween"> - </return> + <return type="Tween" /> <description> - Makes the next [Tweener] run parallely to the previous one. Example: + Makes the next [Tweener] run parallelly to the previous one. Example: [codeblock] var tween = create_tween() tween.tween_property(...) @@ -137,97 +121,78 @@ </description> </method> <method name="pause"> - <return type="void"> - </return> + <return type="void" /> <description> Pauses the tweening. The animation can be resumed by using [method play]. </description> </method> <method name="play"> - <return type="void"> - </return> + <return type="void" /> <description> Resumes a paused or stopped [Tween]. </description> </method> <method name="set_ease"> - <return type="Tween"> - </return> - <argument index="0" name="ease" type="int" enum="Tween.EaseType"> - </argument> + <return type="Tween" /> + <argument 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]. </description> </method> <method name="set_loops"> - <return type="Tween"> - </return> - <argument index="0" name="loops" type="int" default="0"> - </argument> + <return type="Tween" /> + <argument index="0" name="loops" type="int" default="0" /> <description> Sets the number of times the tweening sequence will be repeated, i.e. [code]set_loops(2)[/code] will run the animation twice. Calling this method without arguments will make the [Tween] run infinitely, until it is either killed by [method kill] or by freeing bound node, or all the animated objects have been freed (which makes further animation impossible). </description> </method> <method name="set_parallel"> - <return type="Tween"> - </return> - <argument index="0" name="parallel" type="bool" default="true"> - </argument> + <return type="Tween" /> + <argument index="0" name="parallel" type="bool" default="true" /> <description> - If [code]parallel[/code] is [code]true[/code], the [Tweener]s appended after this method will by default run simultanously, as opposed to sequentially. + If [code]parallel[/code] is [code]true[/code], the [Tweener]s appended after this method will by default run simultaneously, as opposed to sequentially. </description> </method> <method name="set_pause_mode"> - <return type="Tween"> - </return> - <argument index="0" name="mode" type="int" enum="Tween.TweenPauseMode"> - </argument> + <return type="Tween" /> + <argument index="0" name="mode" type="int" enum="Tween.TweenPauseMode" /> <description> Determines the behavior of the [Tween] when the [SceneTree] is paused. Check [enum TweenPauseMode] for options. Default value is [constant TWEEN_PAUSE_BOUND]. </description> </method> <method name="set_process_mode"> - <return type="Tween"> - </return> - <argument index="0" name="mode" type="int" enum="Tween.TweenProcessMode"> - </argument> + <return type="Tween" /> + <argument index="0" name="mode" type="int" enum="Tween.TweenProcessMode" /> <description> Determines whether the [Tween] should run during idle frame (see [method Node._process]) or physics frame (see [method Node._physics_process]. Default value is [constant TWEEN_PROCESS_IDLE]. </description> </method> <method name="set_speed_scale"> - <return type="Tween"> - </return> - <argument index="0" name="speed" type="float"> - </argument> + <return type="Tween" /> + <argument index="0" name="speed" type="float" /> <description> Scales the speed of tweening. This affects all [Tweener]s and their delays. </description> </method> <method name="set_trans"> - <return type="Tween"> - </return> - <argument index="0" name="trans" type="int" enum="Tween.TransitionType"> - </argument> + <return type="Tween" /> + <argument 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]. </description> </method> <method name="stop"> - <return type="void"> - </return> + <return type="void" /> <description> Stops the tweening and resets the [Tween] to its initial state. This will not remove any appended [Tweener]s. </description> </method> <method name="tween_callback"> - <return type="CallbackTweener"> - </return> - <argument index="0" name="callback" type="Callable"> - </argument> + <return type="CallbackTweener" /> + <argument index="0" name="callback" type="Callable" /> <description> Creates and appends a [CallbackTweener]. This method can be used to call an arbitrary method in any object. Use [method Callable.bind] to bind additional arguments for the call. Example: object that keeps shooting every 1 second. @@ -244,10 +209,8 @@ </description> </method> <method name="tween_interval"> - <return type="IntervalTweener"> - </return> - <argument index="0" name="time" type="float"> - </argument> + <return type="IntervalTweener" /> + <argument index="0" name="time" type="float" /> <description> Creates and appends an [IntervalTweener]. This method can be used to create delays in the tween animation, as an alternative for using the delay in other [Tweener]s or when there's no animation (in which case the [Tween] acts as a timer). [code]time[/code] is the length of the interval, in seconds. Example: creating an interval in code execution. @@ -271,16 +234,11 @@ </description> </method> <method name="tween_method"> - <return type="MethodTweener"> - </return> - <argument index="0" name="method" type="Callable"> - </argument> - <argument index="1" name="from" type="float"> - </argument> - <argument index="2" name="to" type="float"> - </argument> - <argument index="3" name="duration" type="float"> - </argument> + <return type="MethodTweener" /> + <argument index="0" name="method" type="Callable" /> + <argument index="1" name="from" type="float" /> + <argument index="2" name="to" type="float" /> + <argument index="3" name="duration" type="float" /> <description> Creates and appends a [MethodTweener]. This method is similar to a combination of [method tween_callback] and [method tween_property]. It calls a method over time with a tweened value provided as an argument. The value is tweened between [code]from[/code] and [code]to[/code] over the time specified by [code]duration[/code], in seconds. Use [method Callable.bind] to bind additional arguments for the call. You can use [method MethodTweener.set_ease] and [method MethodTweener.set_trans] to tweak the easing and transition of the value or [method MethodTweener.set_delay] to delay the tweening. Example: making a 3D object look from one point to another point. @@ -300,16 +258,11 @@ </description> </method> <method name="tween_property"> - <return type="PropertyTweener"> - </return> - <argument index="0" name="object" type="Object"> - </argument> - <argument index="1" name="property" type="NodePath"> - </argument> - <argument index="2" name="final_val" type="Variant"> - </argument> - <argument index="3" name="duration" type="float"> - </argument> + <return type="PropertyTweener" /> + <argument index="0" name="object" type="Object" /> + <argument index="1" name="property" type="NodePath" /> + <argument index="2" name="final_val" type="Variant" /> + <argument index="3" name="duration" type="float" /> <description> Creates and appends a [PropertyTweener]. This method tweens a [code]property[/code] of an [code]object[/code] between an initial value and [code]final_val[/code] in a span of time equal to [code]duration[/code], in seconds. The initial value by default is a value at the time the tweening of the [PropertyTweener] start. For example: [codeblock] @@ -336,15 +289,13 @@ </description> </signal> <signal name="loop_finished"> - <argument index="0" name="loop_count" type="int"> - </argument> + <argument index="0" name="loop_count" type="int" /> <description> Emitted when a full loop is complete (see [method set_loops]), providing the loop index. This signal is not emitted after final loop, use [signal finished] instead for this case. </description> </signal> <signal name="step_finished"> - <argument index="0" name="idx" type="int"> - </argument> + <argument index="0" name="idx" type="int" /> <description> Emitted when one step of the [Tween] is complete, providing the step index. One step is either a single [Tweener] or a group of [Tweener]s running parallelly. </description> diff --git a/doc/classes/Tweener.xml b/doc/classes/Tweener.xml index 5cd502ced9..a3279502e0 100644 --- a/doc/classes/Tweener.xml +++ b/doc/classes/Tweener.xml @@ -13,7 +13,7 @@ <signals> <signal name="finished"> <description> - Emited when the [Tweener] has just finished its job. + Emitted when the [Tweener] has just finished its job. </description> </signal> </signals> diff --git a/doc/classes/UDPServer.xml b/doc/classes/UDPServer.xml index 5e2906450c..eb6d42fb0f 100644 --- a/doc/classes/UDPServer.xml +++ b/doc/classes/UDPServer.xml @@ -124,54 +124,45 @@ </tutorials> <methods> <method name="get_local_port" qualifiers="const"> - <return type="int"> - </return> + <return type="int" /> <description> Returns the local port this server is listening to. </description> </method> <method name="is_connection_available" qualifiers="const"> - <return type="bool"> - </return> + <return type="bool" /> <description> Returns [code]true[/code] if a packet with a new address/port combination was received on the socket. </description> </method> <method name="is_listening" qualifiers="const"> - <return type="bool"> - </return> + <return type="bool" /> <description> Returns [code]true[/code] if the socket is open and listening on a port. </description> </method> <method name="listen"> - <return type="int" enum="Error"> - </return> - <argument index="0" name="port" type="int"> - </argument> - <argument index="1" name="bind_address" type="String" default=""*""> - </argument> + <return type="int" enum="Error" /> + <argument index="0" name="port" type="int" /> + <argument index="1" name="bind_address" type="String" default=""*"" /> <description> Starts the server by opening a UDP socket listening on the given port. You can optionally specify a [code]bind_address[/code] to only listen for packets sent to that address. See also [method PacketPeerUDP.bind]. </description> </method> <method name="poll"> - <return type="int" enum="Error"> - </return> + <return type="int" enum="Error" /> <description> Call this method at regular intervals (e.g. inside [method Node._process]) to process new packets. And packet from known address/port pair will be delivered to the appropriate [PacketPeerUDP], any packet received from an unknown address/port pair will be added as a pending connection (see [method is_connection_available], [method take_connection]). The maximum number of pending connection is defined via [member max_pending_connections]. </description> </method> <method name="stop"> - <return type="void"> - </return> + <return type="void" /> <description> Stops the server, closing the UDP socket if open. Will close all connected [PacketPeerUDP] accepted via [method take_connection] (remote peers will not be notified). </description> </method> <method name="take_connection"> - <return type="PacketPeerUDP"> - </return> + <return type="PacketPeerUDP" /> <description> Returns the first pending connection (connected to the appropriate address/port). Will return [code]null[/code] if no new connection is available. See also [method is_connection_available], [method PacketPeerUDP.connect_to_host]. </description> diff --git a/doc/classes/UndoRedo.xml b/doc/classes/UndoRedo.xml index aba6183124..4417447891 100644 --- a/doc/classes/UndoRedo.xml +++ b/doc/classes/UndoRedo.xml @@ -63,171 +63,135 @@ </tutorials> <methods> <method name="add_do_method" qualifiers="vararg"> - <return type="void"> - </return> - <argument index="0" name="object" type="Object"> - </argument> - <argument index="1" name="method" type="StringName"> - </argument> + <return type="void" /> + <argument index="0" name="object" type="Object" /> + <argument index="1" name="method" type="StringName" /> <description> Register a method that will be called when the action is committed. </description> </method> <method name="add_do_property"> - <return type="void"> - </return> - <argument index="0" name="object" type="Object"> - </argument> - <argument index="1" name="property" type="StringName"> - </argument> - <argument index="2" name="value" type="Variant"> - </argument> + <return type="void" /> + <argument index="0" name="object" type="Object" /> + <argument index="1" name="property" type="StringName" /> + <argument index="2" name="value" type="Variant" /> <description> Register a property value change for "do". </description> </method> <method name="add_do_reference"> - <return type="void"> - </return> - <argument index="0" name="object" type="Object"> - </argument> + <return type="void" /> + <argument index="0" name="object" type="Object" /> <description> Register a reference for "do" that will be erased if the "do" history is lost. This is useful mostly for new nodes created for the "do" call. Do not use for resources. </description> </method> <method name="add_undo_method" qualifiers="vararg"> - <return type="void"> - </return> - <argument index="0" name="object" type="Object"> - </argument> - <argument index="1" name="method" type="StringName"> - </argument> + <return type="void" /> + <argument index="0" name="object" type="Object" /> + <argument index="1" name="method" type="StringName" /> <description> Register a method that will be called when the action is undone. </description> </method> <method name="add_undo_property"> - <return type="void"> - </return> - <argument index="0" name="object" type="Object"> - </argument> - <argument index="1" name="property" type="StringName"> - </argument> - <argument index="2" name="value" type="Variant"> - </argument> + <return type="void" /> + <argument index="0" name="object" type="Object" /> + <argument index="1" name="property" type="StringName" /> + <argument index="2" name="value" type="Variant" /> <description> Register a property value change for "undo". </description> </method> <method name="add_undo_reference"> - <return type="void"> - </return> - <argument index="0" name="object" type="Object"> - </argument> + <return type="void" /> + <argument index="0" name="object" type="Object" /> <description> Register a reference for "undo" that will be erased if the "undo" history is lost. This is useful mostly for nodes removed with the "do" call (not the "undo" call!). </description> </method> <method name="clear_history"> - <return type="void"> - </return> - <argument index="0" name="increase_version" type="bool" default="true"> - </argument> + <return type="void" /> + <argument index="0" name="increase_version" type="bool" default="true" /> <description> Clear the undo/redo history and associated references. Passing [code]false[/code] to [code]increase_version[/code] will prevent the version number to be increased from this. </description> </method> <method name="commit_action"> - <return type="void"> - </return> - <argument index="0" name="execute" type="bool" default="true"> - </argument> + <return type="void" /> + <argument index="0" name="execute" type="bool" default="true" /> <description> Commit the action. If [code]execute[/code] is true (default), all "do" methods/properties are called/set when this function is called. </description> </method> <method name="create_action"> - <return type="void"> - </return> - <argument index="0" name="name" type="String"> - </argument> - <argument index="1" name="merge_mode" type="int" enum="UndoRedo.MergeMode" default="0"> - </argument> + <return type="void" /> + <argument index="0" name="name" type="String" /> + <argument index="1" name="merge_mode" type="int" enum="UndoRedo.MergeMode" default="0" /> <description> Create a new action. After this is called, do all your calls to [method add_do_method], [method add_undo_method], [method add_do_property], and [method add_undo_property], then commit the action with [method commit_action]. The way actions are merged is dictated by the [code]merge_mode[/code] argument. See [enum MergeMode] for details. </description> </method> <method name="get_action_name"> - <return type="String"> - </return> - <argument index="0" name="id" type="int"> - </argument> + <return type="String" /> + <argument index="0" name="id" type="int" /> <description> Gets the action name from its index. </description> </method> <method name="get_current_action"> - <return type="int"> - </return> + <return type="int" /> <description> Gets the index of the current action. </description> </method> <method name="get_current_action_name" qualifiers="const"> - <return type="String"> - </return> + <return type="String" /> <description> Gets the name of the current action, equivalent to [code]get_action_name(get_current_action())[/code]. </description> </method> <method name="get_history_count"> - <return type="int"> - </return> + <return type="int" /> <description> Return how many elements are in the history. </description> </method> <method name="get_version" qualifiers="const"> - <return type="int"> - </return> + <return type="int" /> <description> Gets the version. Every time a new action is committed, the [UndoRedo]'s version number is increased automatically. This is useful mostly to check if something changed from a saved version. </description> </method> <method name="has_redo"> - <return type="bool"> - </return> + <return type="bool" /> <description> Returns [code]true[/code] if a "redo" action is available. </description> </method> <method name="has_undo"> - <return type="bool"> - </return> + <return type="bool" /> <description> Returns [code]true[/code] if an "undo" action is available. </description> </method> <method name="is_committing_action" qualifiers="const"> - <return type="bool"> - </return> + <return type="bool" /> <description> Returns [code]true[/code] if the [UndoRedo] is currently committing the action, i.e. running its "do" method or property change (see [method commit_action]). </description> </method> <method name="redo"> - <return type="bool"> - </return> + <return type="bool" /> <description> Redo the last action. </description> </method> <method name="undo"> - <return type="bool"> - </return> + <return type="bool" /> <description> Undo the last action. </description> diff --git a/doc/classes/Vector2.xml b/doc/classes/Vector2.xml index 498aefbef0..cb5662419e 100644 --- a/doc/classes/Vector2.xml +++ b/doc/classes/Vector2.xml @@ -18,51 +18,41 @@ </tutorials> <methods> <method name="Vector2" qualifiers="constructor"> - <return type="Vector2"> - </return> + <return type="Vector2" /> <description> Constructs a default-initialized [Vector2] with all components set to [code]0[/code]. </description> </method> <method name="Vector2" qualifiers="constructor"> - <return type="Vector2"> - </return> - <argument index="0" name="from" type="Vector2"> - </argument> + <return type="Vector2" /> + <argument index="0" name="from" type="Vector2" /> <description> Constructs a [Vector2] as a copy of the given [Vector2]. </description> </method> <method name="Vector2" qualifiers="constructor"> - <return type="Vector2"> - </return> - <argument index="0" name="from" type="Vector2i"> - </argument> + <return type="Vector2" /> + <argument index="0" name="from" type="Vector2i" /> <description> Constructs a new [Vector2] from [Vector2i]. </description> </method> <method name="Vector2" qualifiers="constructor"> - <return type="Vector2"> - </return> - <argument index="0" name="x" type="float"> - </argument> - <argument index="1" name="y" type="float"> - </argument> + <return type="Vector2" /> + <argument index="0" name="x" type="float" /> + <argument index="1" name="y" type="float" /> <description> Constructs a new [Vector2] from the given [code]x[/code] and [code]y[/code]. </description> </method> <method name="abs" qualifiers="const"> - <return type="Vector2"> - </return> + <return type="Vector2" /> <description> Returns a new vector with all components in absolute values (i.e. positive). </description> </method> <method name="angle" qualifiers="const"> - <return type="float"> - </return> + <return type="float" /> <description> Returns this vector's angle with respect to the positive X axis, or [code](1, 0)[/code] vector, in radians. For example, [code]Vector2.RIGHT.angle()[/code] will return zero, [code]Vector2.DOWN.angle()[/code] will return [code]PI / 2[/code] (a quarter turn, or 90 degrees), and [code]Vector2(1, -1).angle()[/code] will return [code]-PI / 4[/code] (a negative eighth turn, or -45 degrees). @@ -70,114 +60,88 @@ </description> </method> <method name="angle_to" qualifiers="const"> - <return type="float"> - </return> - <argument index="0" name="to" type="Vector2"> - </argument> + <return type="float" /> + <argument index="0" name="to" type="Vector2" /> <description> Returns the angle to the given vector, in radians. </description> </method> <method name="angle_to_point" qualifiers="const"> - <return type="float"> - </return> - <argument index="0" name="to" type="Vector2"> - </argument> + <return type="float" /> + <argument index="0" name="to" type="Vector2" /> <description> Returns the angle between the line connecting the two points and the X axis, in radians. </description> </method> <method name="aspect" qualifiers="const"> - <return type="float"> - </return> + <return type="float" /> <description> Returns the aspect ratio of this vector, the ratio of [member x] to [member y]. </description> </method> <method name="bounce" qualifiers="const"> - <return type="Vector2"> - </return> - <argument index="0" name="n" type="Vector2"> - </argument> + <return type="Vector2" /> + <argument index="0" name="n" type="Vector2" /> <description> Returns the vector "bounced off" from a plane defined by the given normal. </description> </method> <method name="ceil" qualifiers="const"> - <return type="Vector2"> - </return> + <return type="Vector2" /> <description> Returns the vector with all components rounded up (towards positive infinity). </description> </method> <method name="clamp" qualifiers="const"> - <return type="Vector2"> - </return> - <argument index="0" name="min" type="Vector2"> - </argument> - <argument index="1" name="max" type="Vector2"> - </argument> + <return type="Vector2" /> + <argument index="0" name="min" type="Vector2" /> + <argument index="1" name="max" type="Vector2" /> <description> Returns a new vector with all components clamped between the components of [code]min[/code] and [code]max[/code], by running [method @GlobalScope.clamp] on each component. </description> </method> <method name="cross" qualifiers="const"> - <return type="float"> - </return> - <argument index="0" name="with" type="Vector2"> - </argument> + <return type="float" /> + <argument index="0" name="with" type="Vector2" /> <description> Returns the cross product of this vector and [code]with[/code]. </description> </method> <method name="cubic_interpolate" qualifiers="const"> - <return type="Vector2"> - </return> - <argument index="0" name="b" type="Vector2"> - </argument> - <argument index="1" name="pre_a" type="Vector2"> - </argument> - <argument index="2" name="post_b" type="Vector2"> - </argument> - <argument index="3" name="weight" type="float"> - </argument> + <return type="Vector2" /> + <argument index="0" name="b" type="Vector2" /> + <argument index="1" name="pre_a" type="Vector2" /> + <argument index="2" name="post_b" type="Vector2" /> + <argument index="3" name="weight" type="float" /> <description> Cubically interpolates between this vector and [code]b[/code] using [code]pre_a[/code] and [code]post_b[/code] as handles, and returns the result at position [code]weight[/code]. [code]weight[/code] is on the range of 0.0 to 1.0, representing the amount of interpolation. </description> </method> <method name="direction_to" qualifiers="const"> - <return type="Vector2"> - </return> - <argument index="0" name="b" type="Vector2"> - </argument> + <return type="Vector2" /> + <argument index="0" name="b" type="Vector2" /> <description> Returns the normalized vector pointing from this vector to [code]b[/code]. This is equivalent to using [code](b - a).normalized()[/code]. </description> </method> <method name="distance_squared_to" qualifiers="const"> - <return type="float"> - </return> - <argument index="0" name="to" type="Vector2"> - </argument> + <return type="float" /> + <argument index="0" name="to" type="Vector2" /> <description> Returns the squared distance between this vector and [code]b[/code]. This method runs faster than [method distance_to], so prefer it if you need to compare vectors or need the squared distance for some formula. </description> </method> <method name="distance_to" qualifiers="const"> - <return type="float"> - </return> - <argument index="0" name="to" type="Vector2"> - </argument> + <return type="float" /> + <argument index="0" name="to" type="Vector2" /> <description> Returns the distance between this vector and [code]to[/code]. </description> </method> <method name="dot" qualifiers="const"> - <return type="float"> - </return> - <argument index="0" name="with" type="Vector2"> - </argument> + <return type="float" /> + <argument index="0" name="with" type="Vector2" /> <description> Returns the dot product of this vector and [code]with[/code]. This can be used to compare the angle between two vectors. For example, this can be used to determine whether an enemy is facing the player. The dot product will be [code]0[/code] for a straight angle (90 degrees), greater than 0 for angles narrower than 90 degrees and lower than 0 for angles wider than 90 degrees. @@ -186,313 +150,244 @@ </description> </method> <method name="floor" qualifiers="const"> - <return type="Vector2"> - </return> + <return type="Vector2" /> <description> Returns the vector with all components rounded down (towards negative infinity). </description> </method> <method name="is_equal_approx" qualifiers="const"> - <return type="bool"> - </return> - <argument index="0" name="to" type="Vector2"> - </argument> + <return type="bool" /> + <argument index="0" name="to" type="Vector2" /> <description> Returns [code]true[/code] if this vector and [code]v[/code] are approximately equal, by running [method @GlobalScope.is_equal_approx] on each component. </description> </method> <method name="is_normalized" qualifiers="const"> - <return type="bool"> - </return> + <return type="bool" /> <description> Returns [code]true[/code] if the vector is normalized, [code]false[/code] otherwise. </description> </method> <method name="length" qualifiers="const"> - <return type="float"> - </return> + <return type="float" /> <description> Returns the length (magnitude) of this vector. </description> </method> <method name="length_squared" qualifiers="const"> - <return type="float"> - </return> + <return type="float" /> <description> Returns the squared length (squared magnitude) of this vector. This method runs faster than [method length], so prefer it if you need to compare vectors or need the squared distance for some formula. </description> </method> <method name="lerp" qualifiers="const"> - <return type="Vector2"> - </return> - <argument index="0" name="to" type="Vector2"> - </argument> - <argument index="1" name="weight" type="float"> - </argument> + <return type="Vector2" /> + <argument index="0" name="to" type="Vector2" /> + <argument index="1" name="weight" type="float" /> <description> Returns the result of the linear interpolation between this vector and [code]to[/code] by amount [code]weight[/code]. [code]weight[/code] is on the range of 0.0 to 1.0, representing the amount of interpolation. </description> </method> <method name="limit_length" qualifiers="const"> - <return type="Vector2"> - </return> - <argument index="0" name="length" type="float" default="1.0"> - </argument> + <return type="Vector2" /> + <argument index="0" name="length" type="float" default="1.0" /> <description> Returns the vector with a maximum length by limiting its length to [code]length[/code]. </description> </method> <method name="move_toward" qualifiers="const"> - <return type="Vector2"> - </return> - <argument index="0" name="to" type="Vector2"> - </argument> - <argument index="1" name="delta" type="float"> - </argument> + <return type="Vector2" /> + <argument index="0" name="to" type="Vector2" /> + <argument index="1" name="delta" type="float" /> <description> Moves the vector toward [code]to[/code] by the fixed [code]delta[/code] amount. </description> </method> <method name="normalized" qualifiers="const"> - <return type="Vector2"> - </return> + <return type="Vector2" /> <description> Returns the vector scaled to unit length. Equivalent to [code]v / v.length()[/code]. </description> </method> <method name="operator !=" qualifiers="operator"> - <return type="bool"> - </return> - <argument index="0" name="right" type="Vector2"> - </argument> + <return type="bool" /> + <argument index="0" name="right" type="Vector2" /> <description> </description> </method> <method name="operator *" qualifiers="operator"> - <return type="Vector2"> - </return> - <argument index="0" name="right" type="Vector2"> - </argument> + <return type="Vector2" /> + <argument index="0" name="right" type="Vector2" /> <description> </description> </method> <method name="operator *" qualifiers="operator"> - <return type="Vector2"> - </return> - <argument index="0" name="right" type="Transform2D"> - </argument> + <return type="Vector2" /> + <argument index="0" name="right" type="Transform2D" /> <description> </description> </method> <method name="operator *" qualifiers="operator"> - <return type="Vector2"> - </return> - <argument index="0" name="right" type="float"> - </argument> + <return type="Vector2" /> + <argument index="0" name="right" type="float" /> <description> </description> </method> <method name="operator *" qualifiers="operator"> - <return type="Vector2"> - </return> - <argument index="0" name="right" type="int"> - </argument> + <return type="Vector2" /> + <argument index="0" name="right" type="int" /> <description> </description> </method> <method name="operator +" qualifiers="operator"> - <return type="Vector2"> - </return> - <argument index="0" name="right" type="Vector2"> - </argument> + <return type="Vector2" /> + <argument index="0" name="right" type="Vector2" /> <description> </description> </method> <method name="operator -" qualifiers="operator"> - <return type="Vector2"> - </return> - <argument index="0" name="right" type="Vector2"> - </argument> + <return type="Vector2" /> + <argument index="0" name="right" type="Vector2" /> <description> </description> </method> <method name="operator /" qualifiers="operator"> - <return type="Vector2"> - </return> - <argument index="0" name="right" type="Vector2"> - </argument> + <return type="Vector2" /> + <argument index="0" name="right" type="Vector2" /> <description> </description> </method> <method name="operator /" qualifiers="operator"> - <return type="Vector2"> - </return> - <argument index="0" name="right" type="float"> - </argument> + <return type="Vector2" /> + <argument index="0" name="right" type="float" /> <description> </description> </method> <method name="operator /" qualifiers="operator"> - <return type="Vector2"> - </return> - <argument index="0" name="right" type="int"> - </argument> + <return type="Vector2" /> + <argument index="0" name="right" type="int" /> <description> </description> </method> <method name="operator <" qualifiers="operator"> - <return type="bool"> - </return> - <argument index="0" name="right" type="Vector2"> - </argument> + <return type="bool" /> + <argument index="0" name="right" type="Vector2" /> <description> </description> </method> <method name="operator <=" qualifiers="operator"> - <return type="bool"> - </return> - <argument index="0" name="right" type="Vector2"> - </argument> + <return type="bool" /> + <argument index="0" name="right" type="Vector2" /> <description> </description> </method> <method name="operator ==" qualifiers="operator"> - <return type="bool"> - </return> - <argument index="0" name="right" type="Vector2"> - </argument> + <return type="bool" /> + <argument index="0" name="right" type="Vector2" /> <description> </description> </method> <method name="operator >" qualifiers="operator"> - <return type="bool"> - </return> - <argument index="0" name="right" type="Vector2"> - </argument> + <return type="bool" /> + <argument index="0" name="right" type="Vector2" /> <description> </description> </method> <method name="operator >=" qualifiers="operator"> - <return type="bool"> - </return> - <argument index="0" name="right" type="Vector2"> - </argument> + <return type="bool" /> + <argument index="0" name="right" type="Vector2" /> <description> </description> </method> <method name="operator []" qualifiers="operator"> - <return type="float"> - </return> - <argument index="0" name="index" type="int"> - </argument> + <return type="float" /> + <argument index="0" name="index" type="int" /> <description> </description> </method> <method name="operator unary+" qualifiers="operator"> - <return type="Vector2"> - </return> + <return type="Vector2" /> <description> </description> </method> <method name="operator unary-" qualifiers="operator"> - <return type="Vector2"> - </return> + <return type="Vector2" /> <description> </description> </method> <method name="orthogonal" qualifiers="const"> - <return type="Vector2"> - </return> + <return type="Vector2" /> <description> Returns a perpendicular vector rotated 90 degrees counter-clockwise compared to the original, with the same length. </description> </method> <method name="posmod" qualifiers="const"> - <return type="Vector2"> - </return> - <argument index="0" name="mod" type="float"> - </argument> + <return type="Vector2" /> + <argument index="0" name="mod" type="float" /> <description> Returns a vector composed of the [method @GlobalScope.fposmod] of this vector's components and [code]mod[/code]. </description> </method> <method name="posmodv" qualifiers="const"> - <return type="Vector2"> - </return> - <argument index="0" name="modv" type="Vector2"> - </argument> + <return type="Vector2" /> + <argument index="0" name="modv" type="Vector2" /> <description> Returns a vector composed of the [method @GlobalScope.fposmod] of this vector's components and [code]modv[/code]'s components. </description> </method> <method name="project" qualifiers="const"> - <return type="Vector2"> - </return> - <argument index="0" name="b" type="Vector2"> - </argument> + <return type="Vector2" /> + <argument index="0" name="b" type="Vector2" /> <description> Returns the vector projected onto the vector [code]b[/code]. </description> </method> <method name="reflect" qualifiers="const"> - <return type="Vector2"> - </return> - <argument index="0" name="n" type="Vector2"> - </argument> + <return type="Vector2" /> + <argument index="0" name="n" type="Vector2" /> <description> Returns the vector reflected from a plane defined by the given normal. </description> </method> <method name="rotated" qualifiers="const"> - <return type="Vector2"> - </return> - <argument index="0" name="phi" type="float"> - </argument> + <return type="Vector2" /> + <argument index="0" name="phi" type="float" /> <description> Returns the vector rotated by [code]phi[/code] radians. See also [method @GlobalScope.deg2rad]. </description> </method> <method name="round" qualifiers="const"> - <return type="Vector2"> - </return> + <return type="Vector2" /> <description> Returns the vector with all components rounded to the nearest integer, with halfway cases rounded away from zero. </description> </method> <method name="sign" qualifiers="const"> - <return type="Vector2"> - </return> + <return type="Vector2" /> <description> Returns the vector with each component set to one or negative one, depending on the signs of the components, or zero if the component is zero, by calling [method @GlobalScope.sign] on each component. </description> </method> <method name="slerp" qualifiers="const"> - <return type="Vector2"> - </return> - <argument index="0" name="to" type="Vector2"> - </argument> - <argument index="1" name="weight" type="float"> - </argument> + <return type="Vector2" /> + <argument index="0" name="to" type="Vector2" /> + <argument index="1" name="weight" type="float" /> <description> Returns the result of spherical linear interpolation between this vector and [code]to[/code], by amount [code]weight[/code]. [code]weight[/code] is on the range of 0.0 to 1.0, representing the amount of interpolation. [b]Note:[/b] Both vectors must be normalized. </description> </method> <method name="slide" qualifiers="const"> - <return type="Vector2"> - </return> - <argument index="0" name="n" type="Vector2"> - </argument> + <return type="Vector2" /> + <argument index="0" name="n" type="Vector2" /> <description> Returns this vector slid along a plane defined by the given normal. </description> </method> <method name="snapped" qualifiers="const"> - <return type="Vector2"> - </return> - <argument index="0" name="step" type="Vector2"> - </argument> + <return type="Vector2" /> + <argument index="0" name="step" type="Vector2" /> <description> Returns this vector with each component snapped to the nearest multiple of [code]step[/code]. This can also be used to round to an arbitrary number of decimals. </description> diff --git a/doc/classes/Vector2i.xml b/doc/classes/Vector2i.xml index 5f190de8ca..212b1fd22b 100644 --- a/doc/classes/Vector2i.xml +++ b/doc/classes/Vector2i.xml @@ -15,217 +15,167 @@ </tutorials> <methods> <method name="Vector2i" qualifiers="constructor"> - <return type="Vector2i"> - </return> + <return type="Vector2i" /> <description> Constructs a default-initialized [Vector2i] with all components set to [code]0[/code]. </description> </method> <method name="Vector2i" qualifiers="constructor"> - <return type="Vector2i"> - </return> - <argument index="0" name="from" type="Vector2i"> - </argument> + <return type="Vector2i" /> + <argument index="0" name="from" type="Vector2i" /> <description> Constructs a [Vector2i] as a copy of the given [Vector2i]. </description> </method> <method name="Vector2i" qualifiers="constructor"> - <return type="Vector2i"> - </return> - <argument index="0" name="from" type="Vector2"> - </argument> + <return type="Vector2i" /> + <argument index="0" name="from" type="Vector2" /> <description> Constructs a new [Vector2i] from [Vector2]. The floating point coordinates will be truncated. </description> </method> <method name="Vector2i" qualifiers="constructor"> - <return type="Vector2i"> - </return> - <argument index="0" name="x" type="int"> - </argument> - <argument index="1" name="y" type="int"> - </argument> + <return type="Vector2i" /> + <argument index="0" name="x" type="int" /> + <argument index="1" name="y" type="int" /> <description> Constructs a new [Vector2i] from the given [code]x[/code] and [code]y[/code]. </description> </method> <method name="abs" qualifiers="const"> - <return type="Vector2i"> - </return> + <return type="Vector2i" /> <description> Returns a new vector with all components in absolute values (i.e. positive). </description> </method> <method name="aspect" qualifiers="const"> - <return type="float"> - </return> + <return type="float" /> <description> Returns the ratio of [member x] to [member y]. </description> </method> <method name="clamp" qualifiers="const"> - <return type="Vector2i"> - </return> - <argument index="0" name="min" type="Vector2i"> - </argument> - <argument index="1" name="max" type="Vector2i"> - </argument> + <return type="Vector2i" /> + <argument index="0" name="min" type="Vector2i" /> + <argument index="1" name="max" type="Vector2i" /> <description> Returns a new vector with all components clamped between the components of [code]min[/code] and [code]max[/code], by running [method @GlobalScope.clamp] on each component. </description> </method> <method name="operator !=" qualifiers="operator"> - <return type="bool"> - </return> - <argument index="0" name="right" type="Vector2i"> - </argument> + <return type="bool" /> + <argument index="0" name="right" type="Vector2i" /> <description> </description> </method> <method name="operator %" qualifiers="operator"> - <return type="Vector2i"> - </return> - <argument index="0" name="right" type="Vector2i"> - </argument> + <return type="Vector2i" /> + <argument index="0" name="right" type="Vector2i" /> <description> </description> </method> <method name="operator %" qualifiers="operator"> - <return type="Vector2i"> - </return> - <argument index="0" name="right" type="int"> - </argument> + <return type="Vector2i" /> + <argument index="0" name="right" type="int" /> <description> </description> </method> <method name="operator *" qualifiers="operator"> - <return type="Vector2i"> - </return> - <argument index="0" name="right" type="Vector2i"> - </argument> + <return type="Vector2i" /> + <argument index="0" name="right" type="Vector2i" /> <description> </description> </method> <method name="operator *" qualifiers="operator"> - <return type="Vector2i"> - </return> - <argument index="0" name="right" type="float"> - </argument> + <return type="Vector2i" /> + <argument index="0" name="right" type="float" /> <description> </description> </method> <method name="operator *" qualifiers="operator"> - <return type="Vector2i"> - </return> - <argument index="0" name="right" type="int"> - </argument> + <return type="Vector2i" /> + <argument index="0" name="right" type="int" /> <description> </description> </method> <method name="operator +" qualifiers="operator"> - <return type="Vector2i"> - </return> - <argument index="0" name="right" type="Vector2i"> - </argument> + <return type="Vector2i" /> + <argument index="0" name="right" type="Vector2i" /> <description> </description> </method> <method name="operator -" qualifiers="operator"> - <return type="Vector2i"> - </return> - <argument index="0" name="right" type="Vector2i"> - </argument> + <return type="Vector2i" /> + <argument index="0" name="right" type="Vector2i" /> <description> </description> </method> <method name="operator /" qualifiers="operator"> - <return type="Vector2i"> - </return> - <argument index="0" name="right" type="Vector2i"> - </argument> + <return type="Vector2i" /> + <argument index="0" name="right" type="Vector2i" /> <description> </description> </method> <method name="operator /" qualifiers="operator"> - <return type="Vector2i"> - </return> - <argument index="0" name="right" type="float"> - </argument> + <return type="Vector2i" /> + <argument index="0" name="right" type="float" /> <description> </description> </method> <method name="operator /" qualifiers="operator"> - <return type="Vector2i"> - </return> - <argument index="0" name="right" type="int"> - </argument> + <return type="Vector2i" /> + <argument index="0" name="right" type="int" /> <description> </description> </method> <method name="operator <" qualifiers="operator"> - <return type="bool"> - </return> - <argument index="0" name="right" type="Vector2i"> - </argument> + <return type="bool" /> + <argument index="0" name="right" type="Vector2i" /> <description> </description> </method> <method name="operator <=" qualifiers="operator"> - <return type="bool"> - </return> - <argument index="0" name="right" type="Vector2i"> - </argument> + <return type="bool" /> + <argument index="0" name="right" type="Vector2i" /> <description> </description> </method> <method name="operator ==" qualifiers="operator"> - <return type="bool"> - </return> - <argument index="0" name="right" type="Vector2i"> - </argument> + <return type="bool" /> + <argument index="0" name="right" type="Vector2i" /> <description> </description> </method> <method name="operator >" qualifiers="operator"> - <return type="bool"> - </return> - <argument index="0" name="right" type="Vector2i"> - </argument> + <return type="bool" /> + <argument index="0" name="right" type="Vector2i" /> <description> </description> </method> <method name="operator >=" qualifiers="operator"> - <return type="bool"> - </return> - <argument index="0" name="right" type="Vector2i"> - </argument> + <return type="bool" /> + <argument index="0" name="right" type="Vector2i" /> <description> </description> </method> <method name="operator []" qualifiers="operator"> - <return type="int"> - </return> - <argument index="0" name="index" type="int"> - </argument> + <return type="int" /> + <argument index="0" name="index" type="int" /> <description> </description> </method> <method name="operator unary+" qualifiers="operator"> - <return type="Vector2i"> - </return> + <return type="Vector2i" /> <description> </description> </method> <method name="operator unary-" qualifiers="operator"> - <return type="Vector2i"> - </return> + <return type="Vector2i" /> <description> </description> </method> <method name="sign" qualifiers="const"> - <return type="Vector2i"> - </return> + <return type="Vector2i" /> <description> Returns the vector with each component set to one or negative one, depending on the signs of the components. </description> diff --git a/doc/classes/Vector3.xml b/doc/classes/Vector3.xml index 1361666c18..78251b0342 100644 --- a/doc/classes/Vector3.xml +++ b/doc/classes/Vector3.xml @@ -18,143 +18,110 @@ </tutorials> <methods> <method name="Vector3" qualifiers="constructor"> - <return type="Vector3"> - </return> + <return type="Vector3" /> <description> Constructs a default-initialized [Vector3] with all components set to [code]0[/code]. </description> </method> <method name="Vector3" qualifiers="constructor"> - <return type="Vector3"> - </return> - <argument index="0" name="from" type="Vector3"> - </argument> + <return type="Vector3" /> + <argument index="0" name="from" type="Vector3" /> <description> Constructs a [Vector3] as a copy of the given [Vector3]. </description> </method> <method name="Vector3" qualifiers="constructor"> - <return type="Vector3"> - </return> - <argument index="0" name="from" type="Vector3i"> - </argument> + <return type="Vector3" /> + <argument index="0" name="from" type="Vector3i" /> <description> Constructs a new [Vector3] from [Vector3i]. </description> </method> <method name="Vector3" qualifiers="constructor"> - <return type="Vector3"> - </return> - <argument index="0" name="x" type="float"> - </argument> - <argument index="1" name="y" type="float"> - </argument> - <argument index="2" name="z" type="float"> - </argument> + <return type="Vector3" /> + <argument index="0" name="x" type="float" /> + <argument index="1" name="y" type="float" /> + <argument index="2" name="z" type="float" /> <description> Returns a [Vector3] with the given components. </description> </method> <method name="abs" qualifiers="const"> - <return type="Vector3"> - </return> + <return type="Vector3" /> <description> Returns a new vector with all components in absolute values (i.e. positive). </description> </method> <method name="angle_to" qualifiers="const"> - <return type="float"> - </return> - <argument index="0" name="to" type="Vector3"> - </argument> + <return type="float" /> + <argument index="0" name="to" type="Vector3" /> <description> Returns the unsigned minimum angle to the given vector, in radians. </description> </method> <method name="bounce" qualifiers="const"> - <return type="Vector3"> - </return> - <argument index="0" name="n" type="Vector3"> - </argument> + <return type="Vector3" /> + <argument index="0" name="n" type="Vector3" /> <description> Returns the vector "bounced off" from a plane defined by the given normal. </description> </method> <method name="ceil" qualifiers="const"> - <return type="Vector3"> - </return> + <return type="Vector3" /> <description> Returns a new vector with all components rounded up (towards positive infinity). </description> </method> <method name="clamp" qualifiers="const"> - <return type="Vector3"> - </return> - <argument index="0" name="min" type="Vector3"> - </argument> - <argument index="1" name="max" type="Vector3"> - </argument> + <return type="Vector3" /> + <argument index="0" name="min" type="Vector3" /> + <argument index="1" name="max" type="Vector3" /> <description> Returns a new vector with all components clamped between the components of [code]min[/code] and [code]max[/code], by running [method @GlobalScope.clamp] on each component. </description> </method> <method name="cross" qualifiers="const"> - <return type="Vector3"> - </return> - <argument index="0" name="with" type="Vector3"> - </argument> + <return type="Vector3" /> + <argument index="0" name="with" type="Vector3" /> <description> Returns the cross product of this vector and [code]b[/code]. </description> </method> <method name="cubic_interpolate" qualifiers="const"> - <return type="Vector3"> - </return> - <argument index="0" name="b" type="Vector3"> - </argument> - <argument index="1" name="pre_a" type="Vector3"> - </argument> - <argument index="2" name="post_b" type="Vector3"> - </argument> - <argument index="3" name="weight" type="float"> - </argument> + <return type="Vector3" /> + <argument index="0" name="b" type="Vector3" /> + <argument index="1" name="pre_a" type="Vector3" /> + <argument index="2" name="post_b" type="Vector3" /> + <argument index="3" name="weight" type="float" /> <description> Performs a cubic interpolation between vectors [code]pre_a[/code], [code]a[/code], [code]b[/code], [code]post_b[/code] ([code]a[/code] is current), by the given amount [code]weight[/code]. [code]weight[/code] is on the range of 0.0 to 1.0, representing the amount of interpolation. </description> </method> <method name="direction_to" qualifiers="const"> - <return type="Vector3"> - </return> - <argument index="0" name="b" type="Vector3"> - </argument> + <return type="Vector3" /> + <argument index="0" name="b" type="Vector3" /> <description> Returns the normalized vector pointing from this vector to [code]b[/code]. This is equivalent to using [code](b - a).normalized()[/code]. </description> </method> <method name="distance_squared_to" qualifiers="const"> - <return type="float"> - </return> - <argument index="0" name="b" type="Vector3"> - </argument> + <return type="float" /> + <argument index="0" name="b" type="Vector3" /> <description> Returns the squared distance between this vector and [code]b[/code]. This method runs faster than [method distance_to], so prefer it if you need to compare vectors or need the squared distance for some formula. </description> </method> <method name="distance_to" qualifiers="const"> - <return type="float"> - </return> - <argument index="0" name="b" type="Vector3"> - </argument> + <return type="float" /> + <argument index="0" name="b" type="Vector3" /> <description> Returns the distance between this vector and [code]b[/code]. </description> </method> <method name="dot" qualifiers="const"> - <return type="float"> - </return> - <argument index="0" name="with" type="Vector3"> - </argument> + <return type="float" /> + <argument index="0" name="with" type="Vector3" /> <description> Returns the dot product of this vector and [code]b[/code]. This can be used to compare the angle between two vectors. For example, this can be used to determine whether an enemy is facing the player. The dot product will be [code]0[/code] for a straight angle (90 degrees), greater than 0 for angles narrower than 90 degrees and lower than 0 for angles wider than 90 degrees. @@ -163,372 +130,290 @@ </description> </method> <method name="floor" qualifiers="const"> - <return type="Vector3"> - </return> + <return type="Vector3" /> <description> Returns a new vector with all components rounded down (towards negative infinity). </description> </method> <method name="inverse" qualifiers="const"> - <return type="Vector3"> - </return> + <return type="Vector3" /> <description> Returns the inverse of the vector. This is the same as [code]Vector3(1.0 / v.x, 1.0 / v.y, 1.0 / v.z)[/code]. </description> </method> <method name="is_equal_approx" qualifiers="const"> - <return type="bool"> - </return> - <argument index="0" name="to" type="Vector3"> - </argument> + <return type="bool" /> + <argument index="0" name="to" type="Vector3" /> <description> Returns [code]true[/code] if this vector and [code]v[/code] are approximately equal, by running [method @GlobalScope.is_equal_approx] on each component. </description> </method> <method name="is_normalized" qualifiers="const"> - <return type="bool"> - </return> + <return type="bool" /> <description> Returns [code]true[/code] if the vector is normalized, [code]false[/code] otherwise. </description> </method> <method name="length" qualifiers="const"> - <return type="float"> - </return> + <return type="float" /> <description> Returns the length (magnitude) of this vector. </description> </method> <method name="length_squared" qualifiers="const"> - <return type="float"> - </return> + <return type="float" /> <description> Returns the squared length (squared magnitude) of this vector. This method runs faster than [method length], so prefer it if you need to compare vectors or need the squared distance for some formula. </description> </method> <method name="lerp" qualifiers="const"> - <return type="Vector3"> - </return> - <argument index="0" name="to" type="Vector3"> - </argument> - <argument index="1" name="weight" type="float"> - </argument> + <return type="Vector3" /> + <argument index="0" name="to" type="Vector3" /> + <argument index="1" name="weight" type="float" /> <description> Returns the result of the linear interpolation between this vector and [code]to[/code] by amount [code]weight[/code]. [code]weight[/code] is on the range of 0.0 to 1.0, representing the amount of interpolation. </description> </method> <method name="limit_length" qualifiers="const"> - <return type="Vector3"> - </return> - <argument index="0" name="length" type="float" default="1.0"> - </argument> + <return type="Vector3" /> + <argument index="0" name="length" type="float" default="1.0" /> <description> Returns the vector with a maximum length by limiting its length to [code]length[/code]. </description> </method> <method name="max_axis" qualifiers="const"> - <return type="int"> - </return> + <return type="int" /> <description> Returns the axis of the vector's largest value. See [code]AXIS_*[/code] constants. If all components are equal, this method returns [constant AXIS_X]. </description> </method> <method name="min_axis" qualifiers="const"> - <return type="int"> - </return> + <return type="int" /> <description> Returns the axis of the vector's smallest value. See [code]AXIS_*[/code] constants. If all components are equal, this method returns [constant AXIS_Z]. </description> </method> <method name="move_toward" qualifiers="const"> - <return type="Vector3"> - </return> - <argument index="0" name="to" type="Vector3"> - </argument> - <argument index="1" name="delta" type="float"> - </argument> + <return type="Vector3" /> + <argument index="0" name="to" type="Vector3" /> + <argument index="1" name="delta" type="float" /> <description> Moves this vector toward [code]to[/code] by the fixed [code]delta[/code] amount. </description> </method> <method name="normalized" qualifiers="const"> - <return type="Vector3"> - </return> + <return type="Vector3" /> <description> Returns the vector scaled to unit length. Equivalent to [code]v / v.length()[/code]. </description> </method> <method name="operator !=" qualifiers="operator"> - <return type="bool"> - </return> - <argument index="0" name="right" type="Vector3"> - </argument> + <return type="bool" /> + <argument index="0" name="right" type="Vector3" /> <description> </description> </method> <method name="operator *" qualifiers="operator"> - <return type="Vector3"> - </return> - <argument index="0" name="right" type="Vector3"> - </argument> + <return type="Vector3" /> + <argument index="0" name="right" type="Vector3" /> <description> </description> </method> <method name="operator *" qualifiers="operator"> - <return type="Vector3"> - </return> - <argument index="0" name="right" type="Basis"> - </argument> + <return type="Vector3" /> + <argument index="0" name="right" type="Basis" /> <description> </description> </method> <method name="operator *" qualifiers="operator"> - <return type="Vector3"> - </return> - <argument index="0" name="right" type="Quaternion"> - </argument> + <return type="Vector3" /> + <argument index="0" name="right" type="Quaternion" /> <description> </description> </method> <method name="operator *" qualifiers="operator"> - <return type="Vector3"> - </return> - <argument index="0" name="right" type="Transform3D"> - </argument> + <return type="Vector3" /> + <argument index="0" name="right" type="Transform3D" /> <description> </description> </method> <method name="operator *" qualifiers="operator"> - <return type="Vector3"> - </return> - <argument index="0" name="right" type="float"> - </argument> + <return type="Vector3" /> + <argument index="0" name="right" type="float" /> <description> </description> </method> <method name="operator *" qualifiers="operator"> - <return type="Vector3"> - </return> - <argument index="0" name="right" type="int"> - </argument> + <return type="Vector3" /> + <argument index="0" name="right" type="int" /> <description> </description> </method> <method name="operator +" qualifiers="operator"> - <return type="Vector3"> - </return> - <argument index="0" name="right" type="Vector3"> - </argument> + <return type="Vector3" /> + <argument index="0" name="right" type="Vector3" /> <description> </description> </method> <method name="operator -" qualifiers="operator"> - <return type="Vector3"> - </return> - <argument index="0" name="right" type="Vector3"> - </argument> + <return type="Vector3" /> + <argument index="0" name="right" type="Vector3" /> <description> </description> </method> <method name="operator /" qualifiers="operator"> - <return type="Vector3"> - </return> - <argument index="0" name="right" type="Vector3"> - </argument> + <return type="Vector3" /> + <argument index="0" name="right" type="Vector3" /> <description> </description> </method> <method name="operator /" qualifiers="operator"> - <return type="Vector3"> - </return> - <argument index="0" name="right" type="float"> - </argument> + <return type="Vector3" /> + <argument index="0" name="right" type="float" /> <description> </description> </method> <method name="operator /" qualifiers="operator"> - <return type="Vector3"> - </return> - <argument index="0" name="right" type="int"> - </argument> + <return type="Vector3" /> + <argument index="0" name="right" type="int" /> <description> </description> </method> <method name="operator <" qualifiers="operator"> - <return type="bool"> - </return> - <argument index="0" name="right" type="Vector3"> - </argument> + <return type="bool" /> + <argument index="0" name="right" type="Vector3" /> <description> </description> </method> <method name="operator <=" qualifiers="operator"> - <return type="bool"> - </return> - <argument index="0" name="right" type="Vector3"> - </argument> + <return type="bool" /> + <argument index="0" name="right" type="Vector3" /> <description> </description> </method> <method name="operator ==" qualifiers="operator"> - <return type="bool"> - </return> - <argument index="0" name="right" type="Vector3"> - </argument> + <return type="bool" /> + <argument index="0" name="right" type="Vector3" /> <description> </description> </method> <method name="operator >" qualifiers="operator"> - <return type="bool"> - </return> - <argument index="0" name="right" type="Vector3"> - </argument> + <return type="bool" /> + <argument index="0" name="right" type="Vector3" /> <description> </description> </method> <method name="operator >=" qualifiers="operator"> - <return type="bool"> - </return> - <argument index="0" name="right" type="Vector3"> - </argument> + <return type="bool" /> + <argument index="0" name="right" type="Vector3" /> <description> </description> </method> <method name="operator []" qualifiers="operator"> - <return type="float"> - </return> - <argument index="0" name="index" type="int"> - </argument> + <return type="float" /> + <argument index="0" name="index" type="int" /> <description> </description> </method> <method name="operator unary+" qualifiers="operator"> - <return type="Vector3"> - </return> + <return type="Vector3" /> <description> </description> </method> <method name="operator unary-" qualifiers="operator"> - <return type="Vector3"> - </return> + <return type="Vector3" /> <description> </description> </method> <method name="outer" qualifiers="const"> - <return type="Basis"> - </return> - <argument index="0" name="with" type="Vector3"> - </argument> + <return type="Basis" /> + <argument index="0" name="with" type="Vector3" /> <description> Returns the outer product with [code]b[/code]. </description> </method> <method name="posmod" qualifiers="const"> - <return type="Vector3"> - </return> - <argument index="0" name="mod" type="float"> - </argument> + <return type="Vector3" /> + <argument index="0" name="mod" type="float" /> <description> Returns a vector composed of the [method @GlobalScope.fposmod] of this vector's components and [code]mod[/code]. </description> </method> <method name="posmodv" qualifiers="const"> - <return type="Vector3"> - </return> - <argument index="0" name="modv" type="Vector3"> - </argument> + <return type="Vector3" /> + <argument index="0" name="modv" type="Vector3" /> <description> Returns a vector composed of the [method @GlobalScope.fposmod] of this vector's components and [code]modv[/code]'s components. </description> </method> <method name="project" qualifiers="const"> - <return type="Vector3"> - </return> - <argument index="0" name="b" type="Vector3"> - </argument> + <return type="Vector3" /> + <argument index="0" name="b" type="Vector3" /> <description> Returns this vector projected onto another vector [code]b[/code]. </description> </method> <method name="reflect" qualifiers="const"> - <return type="Vector3"> - </return> - <argument index="0" name="n" type="Vector3"> - </argument> + <return type="Vector3" /> + <argument index="0" name="n" type="Vector3" /> <description> Returns this vector reflected from a plane defined by the given normal. </description> </method> <method name="rotated" qualifiers="const"> - <return type="Vector3"> - </return> - <argument index="0" name="by_axis" type="Vector3"> - </argument> - <argument index="1" name="phi" type="float"> - </argument> + <return type="Vector3" /> + <argument index="0" name="by_axis" type="Vector3" /> + <argument index="1" name="phi" type="float" /> <description> Rotates this vector around a given axis by [code]phi[/code] radians. The axis must be a normalized vector. </description> </method> <method name="round" qualifiers="const"> - <return type="Vector3"> - </return> + <return type="Vector3" /> <description> Returns this vector with all components rounded to the nearest integer, with halfway cases rounded away from zero. </description> </method> <method name="sign" qualifiers="const"> - <return type="Vector3"> - </return> + <return type="Vector3" /> <description> Returns a vector with each component set to one or negative one, depending on the signs of this vector's components, or zero if the component is zero, by calling [method @GlobalScope.sign] on each component. </description> </method> <method name="signed_angle_to" qualifiers="const"> - <return type="float"> - </return> - <argument index="0" name="to" type="Vector3"> - </argument> - <argument index="1" name="axis" type="Vector3"> - </argument> + <return type="float" /> + <argument index="0" name="to" type="Vector3" /> + <argument index="1" name="axis" type="Vector3" /> <description> Returns the signed angle to the given vector, in radians. The sign of the angle is positive in a counter-clockwise direction and negative in a clockwise direction when viewed from the side specified by the [code]axis[/code]. </description> </method> <method name="slerp" qualifiers="const"> - <return type="Vector3"> - </return> - <argument index="0" name="to" type="Vector3"> - </argument> - <argument index="1" name="weight" type="float"> - </argument> + <return type="Vector3" /> + <argument index="0" name="to" type="Vector3" /> + <argument index="1" name="weight" type="float" /> <description> Returns the result of spherical linear interpolation between this vector and [code]to[/code], by amount [code]weight[/code]. [code]weight[/code] is on the range of 0.0 to 1.0, representing the amount of interpolation. [b]Note:[/b] Both vectors must be normalized. </description> </method> <method name="slide" qualifiers="const"> - <return type="Vector3"> - </return> - <argument index="0" name="n" type="Vector3"> - </argument> + <return type="Vector3" /> + <argument index="0" name="n" type="Vector3" /> <description> Returns this vector slid along a plane defined by the given normal. </description> </method> <method name="snapped" qualifiers="const"> - <return type="Vector3"> - </return> - <argument index="0" name="step" type="Vector3"> - </argument> + <return type="Vector3" /> + <argument index="0" name="step" type="Vector3" /> <description> Returns this vector with each component snapped to the nearest multiple of [code]step[/code]. This can also be used to round to an arbitrary number of decimals. </description> </method> <method name="to_diagonal_matrix" qualifiers="const"> - <return type="Basis"> - </return> + <return type="Basis" /> <description> Returns a diagonal matrix with the vector as main diagonal. This is equivalent to a Basis with no rotation or shearing and this vector's components set as the scale. diff --git a/doc/classes/Vector3i.xml b/doc/classes/Vector3i.xml index e08bafa665..75df182025 100644 --- a/doc/classes/Vector3i.xml +++ b/doc/classes/Vector3i.xml @@ -15,225 +15,173 @@ </tutorials> <methods> <method name="Vector3i" qualifiers="constructor"> - <return type="Vector3i"> - </return> + <return type="Vector3i" /> <description> Constructs a default-initialized [Vector3i] with all components set to [code]0[/code]. </description> </method> <method name="Vector3i" qualifiers="constructor"> - <return type="Vector3i"> - </return> - <argument index="0" name="from" type="Vector3i"> - </argument> + <return type="Vector3i" /> + <argument index="0" name="from" type="Vector3i" /> <description> Constructs a [Vector3i] as a copy of the given [Vector3i]. </description> </method> <method name="Vector3i" qualifiers="constructor"> - <return type="Vector3i"> - </return> - <argument index="0" name="from" type="Vector3"> - </argument> + <return type="Vector3i" /> + <argument index="0" name="from" type="Vector3" /> <description> Constructs a new [Vector3i] from [Vector3]. The floating point coordinates will be truncated. </description> </method> <method name="Vector3i" qualifiers="constructor"> - <return type="Vector3i"> - </return> - <argument index="0" name="x" type="int"> - </argument> - <argument index="1" name="y" type="int"> - </argument> - <argument index="2" name="z" type="int"> - </argument> + <return type="Vector3i" /> + <argument index="0" name="x" type="int" /> + <argument index="1" name="y" type="int" /> + <argument index="2" name="z" type="int" /> <description> Returns a [Vector3i] with the given components. </description> </method> <method name="abs" qualifiers="const"> - <return type="Vector3i"> - </return> + <return type="Vector3i" /> <description> </description> </method> <method name="clamp" qualifiers="const"> - <return type="Vector3i"> - </return> - <argument index="0" name="min" type="Vector3i"> - </argument> - <argument index="1" name="max" type="Vector3i"> - </argument> + <return type="Vector3i" /> + <argument index="0" name="min" type="Vector3i" /> + <argument index="1" name="max" type="Vector3i" /> <description> Returns a new vector with all components clamped between the components of [code]min[/code] and [code]max[/code], by running [method @GlobalScope.clamp] on each component. </description> </method> <method name="max_axis" qualifiers="const"> - <return type="int"> - </return> + <return type="int" /> <description> Returns the axis of the vector's largest value. See [code]AXIS_*[/code] constants. If all components are equal, this method returns [constant AXIS_X]. </description> </method> <method name="min_axis" qualifiers="const"> - <return type="int"> - </return> + <return type="int" /> <description> Returns the axis of the vector's smallest value. See [code]AXIS_*[/code] constants. If all components are equal, this method returns [constant AXIS_Z]. </description> </method> <method name="operator !=" qualifiers="operator"> - <return type="bool"> - </return> - <argument index="0" name="right" type="Vector3i"> - </argument> + <return type="bool" /> + <argument index="0" name="right" type="Vector3i" /> <description> </description> </method> <method name="operator %" qualifiers="operator"> - <return type="Vector3i"> - </return> - <argument index="0" name="right" type="Vector3i"> - </argument> + <return type="Vector3i" /> + <argument index="0" name="right" type="Vector3i" /> <description> </description> </method> <method name="operator %" qualifiers="operator"> - <return type="Vector3i"> - </return> - <argument index="0" name="right" type="int"> - </argument> + <return type="Vector3i" /> + <argument index="0" name="right" type="int" /> <description> </description> </method> <method name="operator *" qualifiers="operator"> - <return type="Vector3i"> - </return> - <argument index="0" name="right" type="Vector3i"> - </argument> + <return type="Vector3i" /> + <argument index="0" name="right" type="Vector3i" /> <description> </description> </method> <method name="operator *" qualifiers="operator"> - <return type="Vector3i"> - </return> - <argument index="0" name="right" type="float"> - </argument> + <return type="Vector3i" /> + <argument index="0" name="right" type="float" /> <description> </description> </method> <method name="operator *" qualifiers="operator"> - <return type="Vector3i"> - </return> - <argument index="0" name="right" type="int"> - </argument> + <return type="Vector3i" /> + <argument index="0" name="right" type="int" /> <description> </description> </method> <method name="operator +" qualifiers="operator"> - <return type="Vector3i"> - </return> - <argument index="0" name="right" type="Vector3i"> - </argument> + <return type="Vector3i" /> + <argument index="0" name="right" type="Vector3i" /> <description> </description> </method> <method name="operator -" qualifiers="operator"> - <return type="Vector3i"> - </return> - <argument index="0" name="right" type="Vector3i"> - </argument> + <return type="Vector3i" /> + <argument index="0" name="right" type="Vector3i" /> <description> </description> </method> <method name="operator /" qualifiers="operator"> - <return type="Vector3i"> - </return> - <argument index="0" name="right" type="Vector3i"> - </argument> + <return type="Vector3i" /> + <argument index="0" name="right" type="Vector3i" /> <description> </description> </method> <method name="operator /" qualifiers="operator"> - <return type="Vector3i"> - </return> - <argument index="0" name="right" type="float"> - </argument> + <return type="Vector3i" /> + <argument index="0" name="right" type="float" /> <description> </description> </method> <method name="operator /" qualifiers="operator"> - <return type="Vector3i"> - </return> - <argument index="0" name="right" type="int"> - </argument> + <return type="Vector3i" /> + <argument index="0" name="right" type="int" /> <description> </description> </method> <method name="operator <" qualifiers="operator"> - <return type="bool"> - </return> - <argument index="0" name="right" type="Vector3i"> - </argument> + <return type="bool" /> + <argument index="0" name="right" type="Vector3i" /> <description> </description> </method> <method name="operator <=" qualifiers="operator"> - <return type="bool"> - </return> - <argument index="0" name="right" type="Vector3i"> - </argument> + <return type="bool" /> + <argument index="0" name="right" type="Vector3i" /> <description> </description> </method> <method name="operator ==" qualifiers="operator"> - <return type="bool"> - </return> - <argument index="0" name="right" type="Vector3i"> - </argument> + <return type="bool" /> + <argument index="0" name="right" type="Vector3i" /> <description> </description> </method> <method name="operator >" qualifiers="operator"> - <return type="bool"> - </return> - <argument index="0" name="right" type="Vector3i"> - </argument> + <return type="bool" /> + <argument index="0" name="right" type="Vector3i" /> <description> </description> </method> <method name="operator >=" qualifiers="operator"> - <return type="bool"> - </return> - <argument index="0" name="right" type="Vector3i"> - </argument> + <return type="bool" /> + <argument index="0" name="right" type="Vector3i" /> <description> </description> </method> <method name="operator []" qualifiers="operator"> - <return type="int"> - </return> - <argument index="0" name="index" type="int"> - </argument> + <return type="int" /> + <argument index="0" name="index" type="int" /> <description> </description> </method> <method name="operator unary+" qualifiers="operator"> - <return type="Vector3i"> - </return> + <return type="Vector3i" /> <description> </description> </method> <method name="operator unary-" qualifiers="operator"> - <return type="Vector3i"> - </return> + <return type="Vector3i" /> <description> </description> </method> <method name="sign" qualifiers="const"> - <return type="Vector3i"> - </return> + <return type="Vector3i" /> <description> Returns the vector with each component set to one or negative one, depending on the signs of the components. </description> diff --git a/doc/classes/VehicleWheel3D.xml b/doc/classes/VehicleWheel3D.xml index fb0cb03d1c..35f1189a06 100644 --- a/doc/classes/VehicleWheel3D.xml +++ b/doc/classes/VehicleWheel3D.xml @@ -12,22 +12,19 @@ </tutorials> <methods> <method name="get_rpm" qualifiers="const"> - <return type="float"> - </return> + <return type="float" /> <description> Returns the rotational speed of the wheel in revolutions per minute. </description> </method> <method name="get_skidinfo" qualifiers="const"> - <return type="float"> - </return> + <return type="float" /> <description> Returns a value between 0.0 and 1.0 that indicates whether this wheel is skidding. 0.0 is skidding (the wheel has lost grip, e.g. icy terrain), 1.0 means not skidding (the wheel has full grip, e.g. dry asphalt road). </description> </method> <method name="is_in_contact" qualifiers="const"> - <return type="bool"> - </return> + <return type="bool" /> <description> Returns [code]true[/code] if this wheel is in contact with a surface. </description> diff --git a/doc/classes/VelocityTracker3D.xml b/doc/classes/VelocityTracker3D.xml index 2d5e3a4d30..7e97cad5bf 100644 --- a/doc/classes/VelocityTracker3D.xml +++ b/doc/classes/VelocityTracker3D.xml @@ -8,24 +8,19 @@ </tutorials> <methods> <method name="get_tracked_linear_velocity" qualifiers="const"> - <return type="Vector3"> - </return> + <return type="Vector3" /> <description> </description> </method> <method name="reset"> - <return type="void"> - </return> - <argument index="0" name="position" type="Vector3"> - </argument> + <return type="void" /> + <argument index="0" name="position" type="Vector3" /> <description> </description> </method> <method name="update_position"> - <return type="void"> - </return> - <argument index="0" name="position" type="Vector3"> - </argument> + <return type="void" /> + <argument index="0" name="position" type="Vector3" /> <description> </description> </method> diff --git a/doc/classes/VideoPlayer.xml b/doc/classes/VideoPlayer.xml index 12558ebbbc..86b2dd102b 100644 --- a/doc/classes/VideoPlayer.xml +++ b/doc/classes/VideoPlayer.xml @@ -13,37 +13,32 @@ </tutorials> <methods> <method name="get_stream_name" qualifiers="const"> - <return type="String"> - </return> + <return type="String" /> <description> Returns the video stream's name, or [code]"<No Stream>"[/code] if no video stream is assigned. </description> </method> <method name="get_video_texture" qualifiers="const"> - <return type="Texture2D"> - </return> + <return type="Texture2D" /> <description> Returns the current frame as a [Texture2D]. </description> </method> <method name="is_playing" qualifiers="const"> - <return type="bool"> - </return> + <return type="bool" /> <description> Returns [code]true[/code] if the video is playing. [b]Note:[/b] The video is still considered playing if paused during playback. </description> </method> <method name="play"> - <return type="void"> - </return> + <return type="void" /> <description> Starts the video playback from the beginning. If the video is paused, this will not unpause the video. </description> </method> <method name="stop"> - <return type="void"> - </return> + <return type="void" /> <description> Stops the video playback and sets the stream position to 0. [b]Note:[/b] Although the stream position will be set to 0, the first frame of the video stream won't become the current frame. diff --git a/doc/classes/Viewport.xml b/doc/classes/Viewport.xml index 00827fe324..c2edab7e82 100644 --- a/doc/classes/Viewport.xml +++ b/doc/classes/Viewport.xml @@ -23,62 +23,57 @@ </tutorials> <methods> <method name="find_world_2d" qualifiers="const"> - <return type="World2D"> - </return> + <return type="World2D" /> <description> Returns the 2D world of the viewport. </description> </method> <method name="find_world_3d" qualifiers="const"> - <return type="World3D"> - </return> + <return type="World3D" /> <description> Returns the 3D world of the viewport, or if none the world of the parent viewport. </description> </method> - <method name="get_camera" qualifiers="const"> - <return type="Camera3D"> - </return> + <method name="get_camera_2d" qualifiers="const"> + <return type="Camera2D" /> <description> - Returns the active 3D camera. + Returns the currently active 2D camera. Returns null if there are no active cameras. + </description> + </method> + <method name="get_camera_3d" qualifiers="const"> + <return type="Camera3D" /> + <description> + Returns the currently active 3D camera. </description> </method> <method name="get_final_transform" qualifiers="const"> - <return type="Transform2D"> - </return> + <return type="Transform2D" /> <description> Returns the total transform of the viewport. </description> </method> <method name="get_mouse_position" qualifiers="const"> - <return type="Vector2"> - </return> + <return type="Vector2" /> <description> Returns the mouse position relative to the viewport. </description> </method> <method name="get_render_info"> - <return type="int"> - </return> - <argument index="0" name="type" type="int" enum="Viewport.RenderInfoType"> - </argument> - <argument index="1" name="info" type="int" enum="Viewport.RenderInfo"> - </argument> + <return type="int" /> + <argument index="0" name="type" type="int" enum="Viewport.RenderInfoType" /> + <argument index="1" name="info" type="int" enum="Viewport.RenderInfo" /> <description> </description> </method> <method name="get_shadow_atlas_quadrant_subdiv" qualifiers="const"> - <return type="int" enum="Viewport.ShadowAtlasQuadrantSubdiv"> - </return> - <argument index="0" name="quadrant" type="int"> - </argument> + <return type="int" enum="Viewport.ShadowAtlasQuadrantSubdiv" /> + <argument index="0" name="quadrant" type="int" /> <description> Returns the [enum ShadowAtlasQuadrantSubdiv] of the specified quadrant. </description> </method> <method name="get_texture" qualifiers="const"> - <return type="ViewportTexture"> - </return> + <return type="ViewportTexture" /> <description> Returns the viewport's texture. [b]Note:[/b] Due to the way OpenGL works, the resulting [ViewportTexture] is flipped vertically. You can use [method Image.flip_y] on the result of [method Texture2D.get_image] to flip it back, for example: @@ -95,96 +90,76 @@ </description> </method> <method name="get_viewport_rid" qualifiers="const"> - <return type="RID"> - </return> + <return type="RID" /> <description> Returns the viewport's RID from the [RenderingServer]. </description> </method> <method name="get_visible_rect" qualifiers="const"> - <return type="Rect2"> - </return> + <return type="Rect2" /> <description> Returns the visible rectangle in global screen coordinates. </description> </method> <method name="gui_get_drag_data" qualifiers="const"> - <return type="Variant"> - </return> + <return type="Variant" /> <description> Returns the drag data from the GUI, that was previously returned by [method Control._get_drag_data]. </description> </method> <method name="gui_is_dragging" qualifiers="const"> - <return type="bool"> - </return> + <return type="bool" /> <description> Returns [code]true[/code] if the viewport is currently performing a drag operation. </description> </method> <method name="input"> - <return type="void"> - </return> - <argument index="0" name="event" type="InputEvent"> - </argument> - <argument index="1" name="in_local_coords" type="bool" default="false"> - </argument> + <return type="void" /> + <argument index="0" name="event" type="InputEvent" /> + <argument index="1" name="in_local_coords" type="bool" default="false" /> <description> </description> </method> <method name="input_text"> - <return type="void"> - </return> - <argument index="0" name="text" type="String"> - </argument> + <return type="void" /> + <argument index="0" name="text" type="String" /> <description> </description> </method> <method name="is_embedding_subwindows" qualifiers="const"> - <return type="bool"> - </return> + <return type="bool" /> <description> </description> </method> <method name="is_input_handled" qualifiers="const"> - <return type="bool"> - </return> + <return type="bool" /> <description> </description> </method> <method name="set_input_as_handled"> - <return type="void"> - </return> + <return type="void" /> <description> Stops the input from propagating further down the [SceneTree]. </description> </method> <method name="set_shadow_atlas_quadrant_subdiv"> - <return type="void"> - </return> - <argument index="0" name="quadrant" type="int"> - </argument> - <argument index="1" name="subdiv" type="int" enum="Viewport.ShadowAtlasQuadrantSubdiv"> - </argument> + <return type="void" /> + <argument index="0" name="quadrant" type="int" /> + <argument index="1" name="subdiv" type="int" enum="Viewport.ShadowAtlasQuadrantSubdiv" /> <description> Sets the number of subdivisions to use in the specified quadrant. A higher number of subdivisions allows you to have more shadows in the scene at once, but reduces the quality of the shadows. A good practice is to have quadrants with a varying number of subdivisions and to have as few subdivisions as possible. </description> </method> <method name="unhandled_input"> - <return type="void"> - </return> - <argument index="0" name="event" type="InputEvent"> - </argument> - <argument index="1" name="in_local_coords" type="bool" default="false"> - </argument> + <return type="void" /> + <argument index="0" name="event" type="InputEvent" /> + <argument index="1" name="in_local_coords" type="bool" default="false" /> <description> </description> </method> <method name="warp_mouse"> - <return type="void"> - </return> - <argument index="0" name="to_position" type="Vector2"> - </argument> + <return type="void" /> + <argument index="0" name="to_position" type="Vector2" /> <description> Warps the mouse to a position relative to the viewport. </description> @@ -284,8 +259,7 @@ </members> <signals> <signal name="gui_focus_changed"> - <argument index="0" name="node" type="Control"> - </argument> + <argument index="0" name="node" type="Control" /> <description> Emitted when a Control node grabs keyboard focus. </description> diff --git a/doc/classes/VisibleOnScreenNotifier2D.xml b/doc/classes/VisibleOnScreenNotifier2D.xml index daad200ca8..995bd9e9d7 100644 --- a/doc/classes/VisibleOnScreenNotifier2D.xml +++ b/doc/classes/VisibleOnScreenNotifier2D.xml @@ -12,8 +12,7 @@ </tutorials> <methods> <method name="is_on_screen" qualifiers="const"> - <return type="bool"> - </return> + <return type="bool" /> <description> If [code]true[/code], the bounding rectangle is on the screen. [b]Note:[/b] It takes one frame for the node's visibility to be assessed once added to the scene tree, so this method will return [code]false[/code] right after it is instantiated, even if it will be on screen in the draw pass. diff --git a/doc/classes/VisibleOnScreenNotifier3D.xml b/doc/classes/VisibleOnScreenNotifier3D.xml index 85ff324fbf..03db449c80 100644 --- a/doc/classes/VisibleOnScreenNotifier3D.xml +++ b/doc/classes/VisibleOnScreenNotifier3D.xml @@ -12,8 +12,7 @@ </tutorials> <methods> <method name="is_on_screen" qualifiers="const"> - <return type="bool"> - </return> + <return type="bool" /> <description> If [code]true[/code], the bounding box is on the screen. [b]Note:[/b] It takes one frame for the node's visibility to be assessed once added to the scene tree, so this method will return [code]false[/code] right after it is instantiated, even if it will be on screen in the draw pass. diff --git a/doc/classes/VisualInstance3D.xml b/doc/classes/VisualInstance3D.xml index 2a12254b71..2d9c266f3c 100644 --- a/doc/classes/VisualInstance3D.xml +++ b/doc/classes/VisualInstance3D.xml @@ -10,59 +10,48 @@ </tutorials> <methods> <method name="get_aabb" qualifiers="const"> - <return type="AABB"> - </return> + <return type="AABB" /> <description> Returns the [AABB] (also known as the bounding box) for this [VisualInstance3D]. See also [method get_transformed_aabb]. </description> </method> <method name="get_base" qualifiers="const"> - <return type="RID"> - </return> + <return type="RID" /> <description> Returns the RID of the resource associated with this [VisualInstance3D]. For example, if the Node is a [MeshInstance3D], this will return the RID of the associated [Mesh]. </description> </method> <method name="get_instance" qualifiers="const"> - <return type="RID"> - </return> + <return type="RID" /> <description> Returns the RID of this instance. This RID is the same as the RID returned by [method RenderingServer.instance_create]. This RID is needed if you want to call [RenderingServer] functions directly on this [VisualInstance3D]. </description> </method> <method name="get_layer_mask_bit" qualifiers="const"> - <return type="bool"> - </return> - <argument index="0" name="layer" type="int"> - </argument> + <return type="bool" /> + <argument index="0" name="layer" type="int" /> <description> Returns [code]true[/code] when the specified layer is enabled in [member layers] and [code]false[/code] otherwise. </description> </method> <method name="get_transformed_aabb" qualifiers="const"> - <return type="AABB"> - </return> + <return type="AABB" /> <description> Returns the transformed [AABB] (also known as the bounding box) for this [VisualInstance3D]. Transformed in this case means the [AABB] plus the position, rotation, and scale of the [Node3D]'s [Transform3D]. See also [method get_aabb]. </description> </method> <method name="set_base"> - <return type="void"> - </return> - <argument index="0" name="base" type="RID"> - </argument> + <return type="void" /> + <argument index="0" name="base" type="RID" /> <description> Sets the resource that is instantiated by this [VisualInstance3D], which changes how the engine handles the [VisualInstance3D] under the hood. Equivalent to [method RenderingServer.instance_set_base]. </description> </method> <method name="set_layer_mask_bit"> - <return type="void"> - </return> - <argument index="0" name="layer" type="int"> - </argument> - <argument index="1" name="enabled" type="bool"> - </argument> + <return type="void" /> + <argument index="0" name="layer" type="int" /> + <argument index="1" name="enabled" type="bool" /> <description> Enables a particular layer in [member layers]. </description> diff --git a/doc/classes/VisualShader.xml b/doc/classes/VisualShader.xml index 19b4acd8f1..6f65f32ed5 100644 --- a/doc/classes/VisualShader.xml +++ b/doc/classes/VisualShader.xml @@ -11,195 +11,135 @@ </tutorials> <methods> <method name="add_node"> - <return type="void"> - </return> - <argument index="0" name="type" type="int" enum="VisualShader.Type"> - </argument> - <argument index="1" name="node" type="VisualShaderNode"> - </argument> - <argument index="2" name="position" type="Vector2"> - </argument> - <argument index="3" name="id" type="int"> - </argument> + <return type="void" /> + <argument index="0" name="type" type="int" enum="VisualShader.Type" /> + <argument index="1" name="node" type="VisualShaderNode" /> + <argument index="2" name="position" type="Vector2" /> + <argument index="3" name="id" type="int" /> <description> Adds the specified node to the shader. </description> </method> <method name="can_connect_nodes" qualifiers="const"> - <return type="bool"> - </return> - <argument index="0" name="type" type="int" enum="VisualShader.Type"> - </argument> - <argument index="1" name="from_node" type="int"> - </argument> - <argument index="2" name="from_port" type="int"> - </argument> - <argument index="3" name="to_node" type="int"> - </argument> - <argument index="4" name="to_port" type="int"> - </argument> + <return type="bool" /> + <argument index="0" name="type" type="int" enum="VisualShader.Type" /> + <argument index="1" name="from_node" type="int" /> + <argument index="2" name="from_port" type="int" /> + <argument index="3" name="to_node" type="int" /> + <argument index="4" name="to_port" type="int" /> <description> Returns [code]true[/code] if the specified nodes and ports can be connected together. </description> </method> <method name="connect_nodes"> - <return type="int" enum="Error"> - </return> - <argument index="0" name="type" type="int" enum="VisualShader.Type"> - </argument> - <argument index="1" name="from_node" type="int"> - </argument> - <argument index="2" name="from_port" type="int"> - </argument> - <argument index="3" name="to_node" type="int"> - </argument> - <argument index="4" name="to_port" type="int"> - </argument> + <return type="int" enum="Error" /> + <argument index="0" name="type" type="int" enum="VisualShader.Type" /> + <argument index="1" name="from_node" type="int" /> + <argument index="2" name="from_port" type="int" /> + <argument index="3" name="to_node" type="int" /> + <argument index="4" name="to_port" type="int" /> <description> Connects the specified nodes and ports. </description> </method> <method name="connect_nodes_forced"> - <return type="void"> - </return> - <argument index="0" name="type" type="int" enum="VisualShader.Type"> - </argument> - <argument index="1" name="from_node" type="int"> - </argument> - <argument index="2" name="from_port" type="int"> - </argument> - <argument index="3" name="to_node" type="int"> - </argument> - <argument index="4" name="to_port" type="int"> - </argument> + <return type="void" /> + <argument index="0" name="type" type="int" enum="VisualShader.Type" /> + <argument index="1" name="from_node" type="int" /> + <argument index="2" name="from_port" type="int" /> + <argument index="3" name="to_node" type="int" /> + <argument index="4" name="to_port" type="int" /> <description> Connects the specified nodes and ports, even if they can't be connected. Such connection is invalid and will not function properly. </description> </method> <method name="disconnect_nodes"> - <return type="void"> - </return> - <argument index="0" name="type" type="int" enum="VisualShader.Type"> - </argument> - <argument index="1" name="from_node" type="int"> - </argument> - <argument index="2" name="from_port" type="int"> - </argument> - <argument index="3" name="to_node" type="int"> - </argument> - <argument index="4" name="to_port" type="int"> - </argument> + <return type="void" /> + <argument index="0" name="type" type="int" enum="VisualShader.Type" /> + <argument index="1" name="from_node" type="int" /> + <argument index="2" name="from_port" type="int" /> + <argument index="3" name="to_node" type="int" /> + <argument index="4" name="to_port" type="int" /> <description> Connects the specified nodes and ports. </description> </method> <method name="get_node" qualifiers="const"> - <return type="VisualShaderNode"> - </return> - <argument index="0" name="type" type="int" enum="VisualShader.Type"> - </argument> - <argument index="1" name="id" type="int"> - </argument> + <return type="VisualShaderNode" /> + <argument index="0" name="type" type="int" enum="VisualShader.Type" /> + <argument index="1" name="id" type="int" /> <description> Returns the shader node instance with specified [code]type[/code] and [code]id[/code]. </description> </method> <method name="get_node_connections" qualifiers="const"> - <return type="Array"> - </return> - <argument index="0" name="type" type="int" enum="VisualShader.Type"> - </argument> + <return type="Array" /> + <argument index="0" name="type" type="int" enum="VisualShader.Type" /> <description> Returns the list of connected nodes with the specified type. </description> </method> <method name="get_node_list" qualifiers="const"> - <return type="PackedInt32Array"> - </return> - <argument index="0" name="type" type="int" enum="VisualShader.Type"> - </argument> + <return type="PackedInt32Array" /> + <argument index="0" name="type" type="int" enum="VisualShader.Type" /> <description> Returns the list of all nodes in the shader with the specified type. </description> </method> <method name="get_node_position" qualifiers="const"> - <return type="Vector2"> - </return> - <argument index="0" name="type" type="int" enum="VisualShader.Type"> - </argument> - <argument index="1" name="id" type="int"> - </argument> + <return type="Vector2" /> + <argument index="0" name="type" type="int" enum="VisualShader.Type" /> + <argument index="1" name="id" type="int" /> <description> Returns the position of the specified node within the shader graph. </description> </method> <method name="get_valid_node_id" qualifiers="const"> - <return type="int"> - </return> - <argument index="0" name="type" type="int" enum="VisualShader.Type"> - </argument> + <return type="int" /> + <argument index="0" name="type" type="int" enum="VisualShader.Type" /> <description> </description> </method> <method name="is_node_connection" qualifiers="const"> - <return type="bool"> - </return> - <argument index="0" name="type" type="int" enum="VisualShader.Type"> - </argument> - <argument index="1" name="from_node" type="int"> - </argument> - <argument index="2" name="from_port" type="int"> - </argument> - <argument index="3" name="to_node" type="int"> - </argument> - <argument index="4" name="to_port" type="int"> - </argument> + <return type="bool" /> + <argument index="0" name="type" type="int" enum="VisualShader.Type" /> + <argument index="1" name="from_node" type="int" /> + <argument index="2" name="from_port" type="int" /> + <argument index="3" name="to_node" type="int" /> + <argument index="4" name="to_port" type="int" /> <description> Returns [code]true[/code] if the specified node and port connection exist. </description> </method> <method name="remove_node"> - <return type="void"> - </return> - <argument index="0" name="type" type="int" enum="VisualShader.Type"> - </argument> - <argument index="1" name="id" type="int"> - </argument> + <return type="void" /> + <argument index="0" name="type" type="int" enum="VisualShader.Type" /> + <argument index="1" name="id" type="int" /> <description> Removes the specified node from the shader. </description> </method> <method name="replace_node"> - <return type="void"> - </return> - <argument index="0" name="type" type="int" enum="VisualShader.Type"> - </argument> - <argument index="1" name="id" type="int"> - </argument> - <argument index="2" name="new_class" type="StringName"> - </argument> + <return type="void" /> + <argument index="0" name="type" type="int" enum="VisualShader.Type" /> + <argument index="1" name="id" type="int" /> + <argument index="2" name="new_class" type="StringName" /> <description> Replaces the specified node with a node of new class type. </description> </method> <method name="set_mode"> - <return type="void"> - </return> - <argument index="0" name="mode" type="int" enum="Shader.Mode"> - </argument> + <return type="void" /> + <argument index="0" name="mode" type="int" enum="Shader.Mode" /> <description> Sets the mode of this shader. </description> </method> <method name="set_node_position"> - <return type="void"> - </return> - <argument index="0" name="type" type="int" enum="VisualShader.Type"> - </argument> - <argument index="1" name="id" type="int"> - </argument> - <argument index="2" name="position" type="Vector2"> - </argument> + <return type="void" /> + <argument index="0" name="type" type="int" enum="VisualShader.Type" /> + <argument index="1" name="id" type="int" /> + <argument index="2" name="position" type="Vector2" /> <description> Sets the position of the specified node. </description> diff --git a/doc/classes/VisualShaderNode.xml b/doc/classes/VisualShaderNode.xml index 9a74f2322e..2cff70b4f1 100644 --- a/doc/classes/VisualShaderNode.xml +++ b/doc/classes/VisualShaderNode.xml @@ -4,59 +4,49 @@ Base class for nodes in a visual shader graph. </brief_description> <description> + Visual shader graphs consist of various nodes. Each node in the graph is a separate object and they are represented as a rectangular boxes with title and a set of properties. Each node has also connection ports that allow to connect it to another nodes and control the flow of the shader. </description> <tutorials> <link title="VisualShaders">https://docs.godotengine.org/en/latest/tutorials/shading/visual_shaders.html</link> </tutorials> <methods> <method name="clear_default_input_values"> - <return type="void"> - </return> + <return type="void" /> <description> Clears the default input ports value. </description> </method> <method name="get_default_input_values" qualifiers="const"> - <return type="Array"> - </return> + <return type="Array" /> <description> Returns an [Array] containing default values for all of the input ports of the node in the form [code][index0, value0, index1, value1, ...][/code]. </description> </method> <method name="get_input_port_default_value" qualifiers="const"> - <return type="Variant"> - </return> - <argument index="0" name="port" type="int"> - </argument> + <return type="Variant" /> + <argument index="0" name="port" type="int" /> <description> Returns the default value of the input [code]port[/code]. </description> </method> <method name="remove_input_port_default_value"> - <return type="void"> - </return> - <argument index="0" name="port" type="int"> - </argument> + <return type="void" /> + <argument index="0" name="port" type="int" /> <description> Removes the default value of the input [code]port[/code]. </description> </method> <method name="set_default_input_values"> - <return type="void"> - </return> - <argument index="0" name="values" type="Array"> - </argument> + <return type="void" /> + <argument index="0" name="values" type="Array" /> <description> Sets the default input ports values using an [Array] of the form [code][index0, value0, index1, value1, ...][/code]. For example: [code][0, Vector3(0, 0, 0), 1, Vector3(0, 0, 0)][/code]. </description> </method> <method name="set_input_port_default_value"> - <return type="void"> - </return> - <argument index="0" name="port" type="int"> - </argument> - <argument index="1" name="value" type="Variant"> - </argument> + <return type="void" /> + <argument index="0" name="port" type="int" /> + <argument index="1" name="value" type="Variant" /> <description> Sets the default value for the selected input [code]port[/code]. </description> diff --git a/doc/classes/VisualShaderNodeCurveTexture.xml b/doc/classes/VisualShaderNodeCurveTexture.xml index 26b7b07df2..4839ceab92 100644 --- a/doc/classes/VisualShaderNodeCurveTexture.xml +++ b/doc/classes/VisualShaderNodeCurveTexture.xml @@ -1,8 +1,10 @@ <?xml version="1.0" encoding="UTF-8" ?> <class name="VisualShaderNodeCurveTexture" inherits="VisualShaderNodeResizableBase" version="4.0"> <brief_description> + Performs a [CurveTexture] lookup within the visual shader graph. </brief_description> <description> + Comes with a built-in editor for texture's curves. </description> <tutorials> </tutorials> @@ -10,6 +12,7 @@ </methods> <members> <member name="texture" type="CurveTexture" setter="set_texture" getter="get_texture"> + The source texture. </member> </members> <constants> diff --git a/doc/classes/VisualShaderNodeCurveXYZTexture.xml b/doc/classes/VisualShaderNodeCurveXYZTexture.xml new file mode 100644 index 0000000000..11cdc541bb --- /dev/null +++ b/doc/classes/VisualShaderNodeCurveXYZTexture.xml @@ -0,0 +1,20 @@ +<?xml version="1.0" encoding="UTF-8" ?> +<class name="VisualShaderNodeCurveXYZTexture" inherits="VisualShaderNodeResizableBase" version="4.0"> + <brief_description> + Performs a [CurveXYZTexture] lookup within the visual shader graph. + </brief_description> + <description> + Comes with a built-in editor for texture's curves. + </description> + <tutorials> + </tutorials> + <methods> + </methods> + <members> + <member name="texture" type="CurveXYZTexture" setter="set_texture" getter="get_texture"> + The source texture. + </member> + </members> + <constants> + </constants> +</class> diff --git a/doc/classes/VisualShaderNodeCustom.xml b/doc/classes/VisualShaderNodeCustom.xml index 17fc2f8c4d..f6dbd2ad43 100644 --- a/doc/classes/VisualShaderNodeCustom.xml +++ b/doc/classes/VisualShaderNodeCustom.xml @@ -17,24 +17,18 @@ </tutorials> <methods> <method name="_get_category" qualifiers="virtual"> - <return type="String"> - </return> + <return type="String" /> <description> Override this method to define the path to the associated custom node in the Visual Shader Editor's members dialog. The path may look like [code]"MyGame/MyFunctions/Noise"[/code]. Defining this method is [b]optional[/b]. If not overridden, the node will be filed under the "Addons" category. </description> </method> <method name="_get_code" qualifiers="virtual"> - <return type="String"> - </return> - <argument index="0" name="input_vars" type="Array"> - </argument> - <argument index="1" name="output_vars" type="Array"> - </argument> - <argument index="2" name="mode" type="int"> - </argument> - <argument index="3" name="type" type="int"> - </argument> + <return type="String" /> + <argument index="0" name="input_vars" type="Array" /> + <argument index="1" name="output_vars" type="Array" /> + <argument index="2" name="mode" type="int" /> + <argument index="3" name="type" type="int" /> <description> Override this method to define the actual shader code of the associated custom node. The shader code should be returned as a string, which can have multiple lines (the [code]"""[/code] multiline string construct can be used for convenience). The [code]input_vars[/code] and [code]output_vars[/code] arrays contain the string names of the various input and output variables, as defined by [code]_get_input_*[/code] and [code]_get_output_*[/code] virtual methods in this class. @@ -44,18 +38,15 @@ </description> </method> <method name="_get_description" qualifiers="virtual"> - <return type="String"> - </return> + <return type="String" /> <description> Override this method to define the description of the associated custom node in the Visual Shader Editor's members dialog. Defining this method is [b]optional[/b]. </description> </method> <method name="_get_global_code" qualifiers="virtual"> - <return type="String"> - </return> - <argument index="0" name="mode" type="int"> - </argument> + <return type="String" /> + <argument index="0" name="mode" type="int" /> <description> Override this method to add shader code on top of the global shader, to define your own standard library of reusable methods, varyings, constants, uniforms, etc. The shader code should be returned as a string, which can have multiple lines (the [code]"""[/code] multiline string construct can be used for convenience). Be careful with this functionality as it can cause name conflicts with other custom nodes, so be sure to give the defined entities unique names. @@ -64,80 +55,67 @@ </description> </method> <method name="_get_input_port_count" qualifiers="virtual"> - <return type="int"> - </return> + <return type="int" /> <description> Override this method to define the amount of input ports of the associated custom node. Defining this method is [b]required[/b]. If not overridden, the node has no input ports. </description> </method> <method name="_get_input_port_name" qualifiers="virtual"> - <return type="StringName"> - </return> - <argument index="0" name="port" type="int"> - </argument> + <return type="StringName" /> + <argument index="0" name="port" type="int" /> <description> Override this method to define the names of input ports of the associated custom node. The names are used both for the input slots in the editor and as identifiers in the shader code, and are passed in the [code]input_vars[/code] array in [method _get_code]. Defining this method is [b]optional[/b], but recommended. If not overridden, input ports are named as [code]"in" + str(port)[/code]. </description> </method> <method name="_get_input_port_type" qualifiers="virtual"> - <return type="int"> - </return> - <argument index="0" name="port" type="int"> - </argument> + <return type="int" /> + <argument index="0" name="port" type="int" /> <description> Override this method to define the returned type of each input port of the associated custom node (see [enum VisualShaderNode.PortType] for possible types). Defining this method is [b]optional[/b], but recommended. If not overridden, input ports will return the [constant VisualShaderNode.PORT_TYPE_SCALAR] type. </description> </method> <method name="_get_name" qualifiers="virtual"> - <return type="String"> - </return> + <return type="String" /> <description> Override this method to define the name of the associated custom node in the Visual Shader Editor's members dialog and graph. Defining this method is [b]optional[/b], but recommended. If not overridden, the node will be named as "Unnamed". </description> </method> <method name="_get_output_port_count" qualifiers="virtual"> - <return type="int"> - </return> + <return type="int" /> <description> Override this method to define the amount of output ports of the associated custom node. Defining this method is [b]required[/b]. If not overridden, the node has no output ports. </description> </method> <method name="_get_output_port_name" qualifiers="virtual"> - <return type="StringName"> - </return> - <argument index="0" name="port" type="int"> - </argument> + <return type="StringName" /> + <argument index="0" name="port" type="int" /> <description> Override this method to define the names of output ports of the associated custom node. The names are used both for the output slots in the editor and as identifiers in the shader code, and are passed in the [code]output_vars[/code] array in [method _get_code]. Defining this method is [b]optional[/b], but recommended. If not overridden, output ports are named as [code]"out" + str(port)[/code]. </description> </method> <method name="_get_output_port_type" qualifiers="virtual"> - <return type="int"> - </return> - <argument index="0" name="port" type="int"> - </argument> + <return type="int" /> + <argument index="0" name="port" type="int" /> <description> Override this method to define the returned type of each output port of the associated custom node (see [enum VisualShaderNode.PortType] for possible types). Defining this method is [b]optional[/b], but recommended. If not overridden, output ports will return the [constant VisualShaderNode.PORT_TYPE_SCALAR] type. </description> </method> <method name="_get_return_icon_type" qualifiers="virtual"> - <return type="int"> - </return> + <return type="int" /> <description> Override this method to define the return icon of the associated custom node in the Visual Shader Editor's members dialog. Defining this method is [b]optional[/b]. If not overridden, no return icon is shown. </description> </method> <method name="_is_highend" qualifiers="virtual"> - <return type="bool"> - </return> + <return type="bool" /> <description> Override this method to enable high-end mark in the Visual Shader Editor's members dialog. Defining this method is [b]optional[/b]. If not overridden, it's false. diff --git a/doc/classes/VisualShaderNodeGroupBase.xml b/doc/classes/VisualShaderNodeGroupBase.xml index be3f7f173d..a692d47638 100644 --- a/doc/classes/VisualShaderNodeGroupBase.xml +++ b/doc/classes/VisualShaderNodeGroupBase.xml @@ -10,190 +10,148 @@ </tutorials> <methods> <method name="add_input_port"> - <return type="void"> - </return> - <argument index="0" name="id" type="int"> - </argument> - <argument index="1" name="type" type="int"> - </argument> - <argument index="2" name="name" type="String"> - </argument> + <return type="void" /> + <argument index="0" name="id" type="int" /> + <argument index="1" name="type" type="int" /> + <argument index="2" name="name" type="String" /> <description> Adds an input port with the specified [code]type[/code] (see [enum VisualShaderNode.PortType]) and [code]name[/code]. </description> </method> <method name="add_output_port"> - <return type="void"> - </return> - <argument index="0" name="id" type="int"> - </argument> - <argument index="1" name="type" type="int"> - </argument> - <argument index="2" name="name" type="String"> - </argument> + <return type="void" /> + <argument index="0" name="id" type="int" /> + <argument index="1" name="type" type="int" /> + <argument index="2" name="name" type="String" /> <description> Adds an output port with the specified [code]type[/code] (see [enum VisualShaderNode.PortType]) and [code]name[/code]. </description> </method> <method name="clear_input_ports"> - <return type="void"> - </return> + <return type="void" /> <description> Removes all previously specified input ports. </description> </method> <method name="clear_output_ports"> - <return type="void"> - </return> + <return type="void" /> <description> Removes all previously specified output ports. </description> </method> <method name="get_free_input_port_id" qualifiers="const"> - <return type="int"> - </return> + <return type="int" /> <description> Returns a free input port ID which can be used in [method add_input_port]. </description> </method> <method name="get_free_output_port_id" qualifiers="const"> - <return type="int"> - </return> + <return type="int" /> <description> Returns a free output port ID which can be used in [method add_output_port]. </description> </method> <method name="get_input_port_count" qualifiers="const"> - <return type="int"> - </return> + <return type="int" /> <description> Returns the number of input ports in use. Alternative for [method get_free_input_port_id]. </description> </method> <method name="get_inputs" qualifiers="const"> - <return type="String"> - </return> + <return type="String" /> <description> Returns a [String] description of the input ports as a colon-separated list using the format [code]id,type,name;[/code] (see [method add_input_port]). </description> </method> <method name="get_output_port_count" qualifiers="const"> - <return type="int"> - </return> + <return type="int" /> <description> Returns the number of output ports in use. Alternative for [method get_free_output_port_id]. </description> </method> <method name="get_outputs" qualifiers="const"> - <return type="String"> - </return> + <return type="String" /> <description> Returns a [String] description of the output ports as a colon-separated list using the format [code]id,type,name;[/code] (see [method add_output_port]). </description> </method> <method name="has_input_port" qualifiers="const"> - <return type="bool"> - </return> - <argument index="0" name="id" type="int"> - </argument> + <return type="bool" /> + <argument index="0" name="id" type="int" /> <description> Returns [code]true[/code] if the specified input port exists. </description> </method> <method name="has_output_port" qualifiers="const"> - <return type="bool"> - </return> - <argument index="0" name="id" type="int"> - </argument> + <return type="bool" /> + <argument index="0" name="id" type="int" /> <description> Returns [code]true[/code] if the specified output port exists. </description> </method> <method name="is_valid_port_name" qualifiers="const"> - <return type="bool"> - </return> - <argument index="0" name="name" type="String"> - </argument> + <return type="bool" /> + <argument index="0" name="name" type="String" /> <description> Returns [code]true[/code] if the specified port name does not override an existed port name and is valid within the shader. </description> </method> <method name="remove_input_port"> - <return type="void"> - </return> - <argument index="0" name="id" type="int"> - </argument> + <return type="void" /> + <argument index="0" name="id" type="int" /> <description> Removes the specified input port. </description> </method> <method name="remove_output_port"> - <return type="void"> - </return> - <argument index="0" name="id" type="int"> - </argument> + <return type="void" /> + <argument index="0" name="id" type="int" /> <description> Removes the specified output port. </description> </method> <method name="set_input_port_name"> - <return type="void"> - </return> - <argument index="0" name="id" type="int"> - </argument> - <argument index="1" name="name" type="String"> - </argument> + <return type="void" /> + <argument index="0" name="id" type="int" /> + <argument index="1" name="name" type="String" /> <description> Renames the specified input port. </description> </method> <method name="set_input_port_type"> - <return type="void"> - </return> - <argument index="0" name="id" type="int"> - </argument> - <argument index="1" name="type" type="int"> - </argument> + <return type="void" /> + <argument index="0" name="id" type="int" /> + <argument index="1" name="type" type="int" /> <description> Sets the specified input port's type (see [enum VisualShaderNode.PortType]). </description> </method> <method name="set_inputs"> - <return type="void"> - </return> - <argument index="0" name="inputs" type="String"> - </argument> + <return type="void" /> + <argument index="0" name="inputs" type="String" /> <description> Defines all input ports using a [String] formatted as a colon-separated list: [code]id,type,name;[/code] (see [method add_input_port]). </description> </method> <method name="set_output_port_name"> - <return type="void"> - </return> - <argument index="0" name="id" type="int"> - </argument> - <argument index="1" name="name" type="String"> - </argument> + <return type="void" /> + <argument index="0" name="id" type="int" /> + <argument index="1" name="name" type="String" /> <description> Renames the specified output port. </description> </method> <method name="set_output_port_type"> - <return type="void"> - </return> - <argument index="0" name="id" type="int"> - </argument> - <argument index="1" name="type" type="int"> - </argument> + <return type="void" /> + <argument index="0" name="id" type="int" /> + <argument index="1" name="type" type="int" /> <description> Sets the specified output port's type (see [enum VisualShaderNode.PortType]). </description> </method> <method name="set_outputs"> - <return type="void"> - </return> - <argument index="0" name="outputs" type="String"> - </argument> + <return type="void" /> + <argument index="0" name="outputs" type="String" /> <description> Defines all output ports using a [String] formatted as a colon-separated list: [code]id,type,name;[/code] (see [method add_output_port]). </description> diff --git a/doc/classes/VisualShaderNodeInput.xml b/doc/classes/VisualShaderNodeInput.xml index 067f78dffe..dd62d668eb 100644 --- a/doc/classes/VisualShaderNodeInput.xml +++ b/doc/classes/VisualShaderNodeInput.xml @@ -11,8 +11,7 @@ </tutorials> <methods> <method name="get_input_real_name" qualifiers="const"> - <return type="String"> - </return> + <return type="String" /> <description> Returns a translated name of the current constant in the Godot Shader Language. E.g. [code]"ALBEDO"[/code] if the [member input_name] equal to [code]"albedo"[/code]. </description> diff --git a/doc/classes/VisualShaderNodeResizableBase.xml b/doc/classes/VisualShaderNodeResizableBase.xml index 9052f6854b..f42289a10e 100644 --- a/doc/classes/VisualShaderNodeResizableBase.xml +++ b/doc/classes/VisualShaderNodeResizableBase.xml @@ -1,8 +1,10 @@ <?xml version="1.0" encoding="UTF-8" ?> <class name="VisualShaderNodeResizableBase" inherits="VisualShaderNode" version="4.0"> <brief_description> + Base class for resizable nodes in a visual shader graph. </brief_description> <description> + Resizable nodes have a handle that allows the user to adjust their size as needed. </description> <tutorials> </tutorials> diff --git a/doc/classes/VoxelGI.xml b/doc/classes/VoxelGI.xml index 5b395becb7..eceb651d5e 100644 --- a/doc/classes/VoxelGI.xml +++ b/doc/classes/VoxelGI.xml @@ -14,19 +14,15 @@ </tutorials> <methods> <method name="bake"> - <return type="void"> - </return> - <argument index="0" name="from_node" type="Node" default="null"> - </argument> - <argument index="1" name="create_visual_debug" type="bool" default="false"> - </argument> + <return type="void" /> + <argument index="0" name="from_node" type="Node" default="null" /> + <argument index="1" name="create_visual_debug" type="bool" default="false" /> <description> Bakes the effect from all [GeometryInstance3D]s marked with [constant GeometryInstance3D.GI_MODE_BAKED] and [Light3D]s marked with either [constant Light3D.BAKE_DYNAMIC] or [constant Light3D.BAKE_STATIC]. If [code]create_visual_debug[/code] is [code]true[/code], after baking the light, this will generate a [MultiMesh] that has a cube representing each solid cell with each cube colored to the cell's albedo color. This can be used to visualize the [VoxelGI]'s data and debug any issues that may be occurring. </description> </method> <method name="debug_bake"> - <return type="void"> - </return> + <return type="void" /> <description> Calls [method bake] with [code]create_visual_debug[/code] enabled. </description> diff --git a/doc/classes/VoxelGIData.xml b/doc/classes/VoxelGIData.xml index f613002233..5c2c7f9dc6 100644 --- a/doc/classes/VoxelGIData.xml +++ b/doc/classes/VoxelGIData.xml @@ -9,58 +9,44 @@ </tutorials> <methods> <method name="allocate"> - <return type="void"> - </return> - <argument index="0" name="to_cell_xform" type="Transform3D"> - </argument> - <argument index="1" name="aabb" type="AABB"> - </argument> - <argument index="2" name="octree_size" type="Vector3"> - </argument> - <argument index="3" name="octree_cells" type="PackedByteArray"> - </argument> - <argument index="4" name="data_cells" type="PackedByteArray"> - </argument> - <argument index="5" name="distance_field" type="PackedByteArray"> - </argument> - <argument index="6" name="level_counts" type="PackedInt32Array"> - </argument> + <return type="void" /> + <argument index="0" name="to_cell_xform" type="Transform3D" /> + <argument index="1" name="aabb" type="AABB" /> + <argument index="2" name="octree_size" type="Vector3" /> + <argument index="3" name="octree_cells" type="PackedByteArray" /> + <argument index="4" name="data_cells" type="PackedByteArray" /> + <argument index="5" name="distance_field" type="PackedByteArray" /> + <argument index="6" name="level_counts" type="PackedInt32Array" /> <description> </description> </method> <method name="get_bounds" qualifiers="const"> - <return type="AABB"> - </return> + <return type="AABB" /> <description> </description> </method> <method name="get_data_cells" qualifiers="const"> - <return type="PackedByteArray"> - </return> + <return type="PackedByteArray" /> <description> </description> </method> <method name="get_level_counts" qualifiers="const"> - <return type="PackedInt32Array"> - </return> + <return type="PackedInt32Array" /> <description> </description> </method> <method name="get_octree_cells" qualifiers="const"> - <return type="PackedByteArray"> - </return> + <return type="PackedByteArray" /> <description> </description> </method> <method name="get_octree_size" qualifiers="const"> - <return type="Vector3"> - </return> + <return type="Vector3" /> <description> </description> </method> <method name="get_to_cell_xform" qualifiers="const"> - <return type="Transform3D"> - </return> + <return type="Transform3D" /> <description> </description> </method> diff --git a/doc/classes/WeakRef.xml b/doc/classes/WeakRef.xml index 6c9a7de67f..339c1620bf 100644 --- a/doc/classes/WeakRef.xml +++ b/doc/classes/WeakRef.xml @@ -10,8 +10,7 @@ </tutorials> <methods> <method name="get_ref" qualifiers="const"> - <return type="Variant"> - </return> + <return type="Variant" /> <description> Returns the [Object] this weakref is referring to. </description> diff --git a/doc/classes/Window.xml b/doc/classes/Window.xml index c8efaca1fc..bc76118a56 100644 --- a/doc/classes/Window.xml +++ b/doc/classes/Window.xml @@ -8,314 +8,239 @@ </tutorials> <methods> <method name="can_draw" qualifiers="const"> - <return type="bool"> - </return> + <return type="bool" /> <description> </description> </method> <method name="child_controls_changed"> - <return type="void"> - </return> + <return type="void" /> <description> </description> </method> <method name="get_contents_minimum_size" qualifiers="const"> - <return type="Vector2"> - </return> + <return type="Vector2" /> <description> Returns the combined minimum size from the child [Control] nodes of the window. </description> </method> <method name="get_flag" qualifiers="const"> - <return type="bool"> - </return> - <argument index="0" name="flag" type="int" enum="Window.Flags"> - </argument> + <return type="bool" /> + <argument index="0" name="flag" type="int" enum="Window.Flags" /> <description> </description> </method> <method name="get_layout_direction" qualifiers="const"> - <return type="int" enum="Window.LayoutDirection"> - </return> + <return type="int" enum="Window.LayoutDirection" /> <description> Returns layout direction and text writing direction. </description> </method> <method name="get_real_size" qualifiers="const"> - <return type="Vector2i"> - </return> + <return type="Vector2i" /> <description> </description> </method> <method name="get_theme_color" qualifiers="const"> - <return type="Color"> - </return> - <argument index="0" name="name" type="StringName"> - </argument> - <argument index="1" name="theme_type" type="StringName" default=""""> - </argument> + <return type="Color" /> + <argument index="0" name="name" type="StringName" /> + <argument index="1" name="theme_type" type="StringName" default="""" /> <description> </description> </method> <method name="get_theme_constant" qualifiers="const"> - <return type="int"> - </return> - <argument index="0" name="name" type="StringName"> - </argument> - <argument index="1" name="theme_type" type="StringName" default=""""> - </argument> + <return type="int" /> + <argument index="0" name="name" type="StringName" /> + <argument index="1" name="theme_type" type="StringName" default="""" /> <description> </description> </method> <method name="get_theme_font" qualifiers="const"> - <return type="Font"> - </return> - <argument index="0" name="name" type="StringName"> - </argument> - <argument index="1" name="theme_type" type="StringName" default=""""> - </argument> + <return type="Font" /> + <argument index="0" name="name" type="StringName" /> + <argument index="1" name="theme_type" type="StringName" default="""" /> <description> Returns the [Font] at [code]name[/code] if the theme has [code]theme_type[/code]. </description> </method> <method name="get_theme_font_size" qualifiers="const"> - <return type="int"> - </return> - <argument index="0" name="name" type="StringName"> - </argument> - <argument index="1" name="theme_type" type="StringName" default=""""> - </argument> + <return type="int" /> + <argument index="0" name="name" type="StringName" /> + <argument index="1" name="theme_type" type="StringName" default="""" /> <description> Returns the font size at [code]name[/code] if the theme has [code]theme_type[/code]. </description> </method> <method name="get_theme_icon" qualifiers="const"> - <return type="Texture2D"> - </return> - <argument index="0" name="name" type="StringName"> - </argument> - <argument index="1" name="theme_type" type="StringName" default=""""> - </argument> + <return type="Texture2D" /> + <argument index="0" name="name" type="StringName" /> + <argument index="1" name="theme_type" type="StringName" default="""" /> <description> </description> </method> <method name="get_theme_stylebox" qualifiers="const"> - <return type="StyleBox"> - </return> - <argument index="0" name="name" type="StringName"> - </argument> - <argument index="1" name="theme_type" type="StringName" default=""""> - </argument> + <return type="StyleBox" /> + <argument index="0" name="name" type="StringName" /> + <argument index="1" name="theme_type" type="StringName" default="""" /> <description> </description> </method> <method name="grab_focus"> - <return type="void"> - </return> + <return type="void" /> <description> </description> </method> <method name="has_focus" qualifiers="const"> - <return type="bool"> - </return> + <return type="bool" /> <description> </description> </method> <method name="has_theme_color" qualifiers="const"> - <return type="bool"> - </return> - <argument index="0" name="name" type="StringName"> - </argument> - <argument index="1" name="theme_type" type="StringName" default=""""> - </argument> + <return type="bool" /> + <argument index="0" name="name" type="StringName" /> + <argument index="1" name="theme_type" type="StringName" default="""" /> <description> </description> </method> <method name="has_theme_constant" qualifiers="const"> - <return type="bool"> - </return> - <argument index="0" name="name" type="StringName"> - </argument> - <argument index="1" name="theme_type" type="StringName" default=""""> - </argument> + <return type="bool" /> + <argument index="0" name="name" type="StringName" /> + <argument index="1" name="theme_type" type="StringName" default="""" /> <description> </description> </method> <method name="has_theme_font" qualifiers="const"> - <return type="bool"> - </return> - <argument index="0" name="name" type="StringName"> - </argument> - <argument index="1" name="theme_type" type="StringName" default=""""> - </argument> + <return type="bool" /> + <argument index="0" name="name" type="StringName" /> + <argument index="1" name="theme_type" type="StringName" default="""" /> <description> Returns [code]true[/code] if [Font] with [code]name[/code] is in [code]theme_type[/code]. Returns [code]false[/code] if the theme does not have [code]theme_type[/code]. </description> </method> <method name="has_theme_font_size" qualifiers="const"> - <return type="bool"> - </return> - <argument index="0" name="name" type="StringName"> - </argument> - <argument index="1" name="theme_type" type="StringName" default=""""> - </argument> + <return type="bool" /> + <argument index="0" name="name" type="StringName" /> + <argument index="1" name="theme_type" type="StringName" default="""" /> <description> Returns [code]true[/code] if font size with [code]name[/code] is in [code]theme_type[/code]. Returns [code]false[/code] if the theme does not have [code]theme_type[/code]. </description> </method> <method name="has_theme_icon" qualifiers="const"> - <return type="bool"> - </return> - <argument index="0" name="name" type="StringName"> - </argument> - <argument index="1" name="theme_type" type="StringName" default=""""> - </argument> + <return type="bool" /> + <argument index="0" name="name" type="StringName" /> + <argument index="1" name="theme_type" type="StringName" default="""" /> <description> </description> </method> <method name="has_theme_stylebox" qualifiers="const"> - <return type="bool"> - </return> - <argument index="0" name="name" type="StringName"> - </argument> - <argument index="1" name="theme_type" type="StringName" default=""""> - </argument> + <return type="bool" /> + <argument index="0" name="name" type="StringName" /> + <argument index="1" name="theme_type" type="StringName" default="""" /> <description> </description> </method> <method name="hide"> - <return type="void"> - </return> + <return type="void" /> <description> </description> </method> <method name="is_embedded" qualifiers="const"> - <return type="bool"> - </return> + <return type="bool" /> <description> </description> </method> <method name="is_layout_rtl" qualifiers="const"> - <return type="bool"> - </return> + <return type="bool" /> <description> Returns [code]true[/code] if layout is right-to-left. </description> </method> <method name="is_maximize_allowed" qualifiers="const"> - <return type="bool"> - </return> + <return type="bool" /> <description> </description> </method> <method name="is_using_font_oversampling" qualifiers="const"> - <return type="bool"> - </return> + <return type="bool" /> <description> </description> </method> <method name="move_to_foreground"> - <return type="void"> - </return> + <return type="void" /> <description> </description> </method> <method name="popup"> - <return type="void"> - </return> - <argument index="0" name="rect" type="Rect2i" default="Rect2i(0, 0, 0, 0)"> - </argument> + <return type="void" /> + <argument index="0" name="rect" type="Rect2i" default="Rect2i(0, 0, 0, 0)" /> <description> </description> </method> <method name="popup_centered"> - <return type="void"> - </return> - <argument index="0" name="minsize" type="Vector2i" default="Vector2i(0, 0)"> - </argument> + <return type="void" /> + <argument index="0" name="minsize" type="Vector2i" default="Vector2i(0, 0)" /> <description> </description> </method> <method name="popup_centered_clamped"> - <return type="void"> - </return> - <argument index="0" name="minsize" type="Vector2i" default="Vector2i(0, 0)"> - </argument> - <argument index="1" name="fallback_ratio" type="float" default="0.75"> - </argument> + <return type="void" /> + <argument index="0" name="minsize" type="Vector2i" default="Vector2i(0, 0)" /> + <argument index="1" name="fallback_ratio" type="float" default="0.75" /> <description> </description> </method> <method name="popup_centered_ratio"> - <return type="void"> - </return> - <argument index="0" name="ratio" type="float" default="0.8"> - </argument> + <return type="void" /> + <argument index="0" name="ratio" type="float" default="0.8" /> <description> </description> </method> <method name="popup_on_parent"> - <return type="void"> - </return> - <argument index="0" name="parent_rect" type="Rect2i"> - </argument> + <return type="void" /> + <argument index="0" name="parent_rect" type="Rect2i" /> <description> </description> </method> <method name="request_attention"> - <return type="void"> - </return> + <return type="void" /> <description> </description> </method> <method name="set_flag"> - <return type="void"> - </return> - <argument index="0" name="flag" type="int" enum="Window.Flags"> - </argument> - <argument index="1" name="enabled" type="bool"> - </argument> + <return type="void" /> + <argument index="0" name="flag" type="int" enum="Window.Flags" /> + <argument index="1" name="enabled" type="bool" /> <description> </description> </method> <method name="set_ime_active"> - <return type="void"> - </return> - <argument index="0" name="active" type="bool"> - </argument> + <return type="void" /> + <argument index="0" name="active" type="bool" /> <description> </description> </method> <method name="set_ime_position"> - <return type="void"> - </return> - <argument index="0" name="position" type="Vector2i"> - </argument> + <return type="void" /> + <argument index="0" name="position" type="Vector2i" /> <description> </description> </method> <method name="set_layout_direction"> - <return type="void"> - </return> - <argument index="0" name="direction" type="int" enum="Window.LayoutDirection"> - </argument> + <return type="void" /> + <argument index="0" name="direction" type="int" enum="Window.LayoutDirection" /> <description> Sets layout direction and text writing direction. Right-to-left layouts are necessary for certain languages (e.g. Arabic and Hebrew). </description> </method> <method name="set_use_font_oversampling"> - <return type="void"> - </return> - <argument index="0" name="enable" type="bool"> - </argument> + <return type="void" /> + <argument index="0" name="enable" type="bool" /> <description> </description> </method> <method name="show"> - <return type="void"> - </return> + <return type="void" /> <description> </description> </method> @@ -323,6 +248,9 @@ <members> <member name="always_on_top" type="bool" setter="set_flag" getter="get_flag" default="false"> </member> + <member name="auto_translate" type="bool" setter="set_auto_translate" getter="is_auto_translating" default="true"> + Toggles if any text should automatically change to its translated version depending on the current locale. + </member> <member name="borderless" type="bool" setter="set_flag" getter="get_flag" default="false"> </member> <member name="content_scale_aspect" type="int" setter="set_content_scale_aspect" getter="get_content_scale_aspect" enum="Window.ContentScaleAspect" default="0"> @@ -374,8 +302,7 @@ </description> </signal> <signal name="files_dropped"> - <argument index="0" name="files" type="PackedStringArray"> - </argument> + <argument index="0" name="files" type="PackedStringArray" /> <description> </description> </signal> @@ -404,8 +331,7 @@ </description> </signal> <signal name="window_input"> - <argument index="0" name="event" type="InputEvent"> - </argument> + <argument index="0" name="event" type="InputEvent" /> <description> </description> </signal> @@ -469,11 +395,11 @@ </theme_item> <theme_item name="close_h_ofs" type="int" default="18"> </theme_item> - <theme_item name="close_highlight" type="Texture2D"> + <theme_item name="close_pressed" type="Texture2D"> </theme_item> <theme_item name="close_v_ofs" type="int" default="18"> </theme_item> - <theme_item name="panel" type="StyleBox"> + <theme_item name="embedded_border" type="StyleBox"> </theme_item> <theme_item name="resize_margin" type="int" default="4"> </theme_item> @@ -494,7 +420,5 @@ <theme_item name="title_outline_size" type="int" default="0"> The size of the title outline. </theme_item> - <theme_item name="window_panel" type="StyleBox"> - </theme_item> </theme_items> </class> diff --git a/doc/classes/X509Certificate.xml b/doc/classes/X509Certificate.xml index d2b7b20cd6..5900e68339 100644 --- a/doc/classes/X509Certificate.xml +++ b/doc/classes/X509Certificate.xml @@ -12,19 +12,15 @@ </tutorials> <methods> <method name="load"> - <return type="int" enum="Error"> - </return> - <argument index="0" name="path" type="String"> - </argument> + <return type="int" enum="Error" /> + <argument index="0" name="path" type="String" /> <description> Loads a certificate from [code]path[/code] ("*.crt" file). </description> </method> <method name="save"> - <return type="int" enum="Error"> - </return> - <argument index="0" name="path" type="String"> - </argument> + <return type="int" enum="Error" /> + <argument index="0" name="path" type="String" /> <description> Saves a certificate to the given [code]path[/code] (should be a "*.crt" file). </description> diff --git a/doc/classes/XMLParser.xml b/doc/classes/XMLParser.xml index ab5c58c51c..4af3de8dfd 100644 --- a/doc/classes/XMLParser.xml +++ b/doc/classes/XMLParser.xml @@ -10,136 +10,111 @@ </tutorials> <methods> <method name="get_attribute_count" qualifiers="const"> - <return type="int"> - </return> + <return type="int" /> <description> Gets the amount of attributes in the current element. </description> </method> <method name="get_attribute_name" qualifiers="const"> - <return type="String"> - </return> - <argument index="0" name="idx" type="int"> - </argument> + <return type="String" /> + <argument index="0" name="idx" type="int" /> <description> Gets the name of the attribute specified by the index in [code]idx[/code] argument. </description> </method> <method name="get_attribute_value" qualifiers="const"> - <return type="String"> - </return> - <argument index="0" name="idx" type="int"> - </argument> + <return type="String" /> + <argument index="0" name="idx" type="int" /> <description> Gets the value of the attribute specified by the index in [code]idx[/code] argument. </description> </method> <method name="get_current_line" qualifiers="const"> - <return type="int"> - </return> + <return type="int" /> <description> Gets the current line in the parsed file (currently not implemented). </description> </method> <method name="get_named_attribute_value" qualifiers="const"> - <return type="String"> - </return> - <argument index="0" name="name" type="String"> - </argument> + <return type="String" /> + <argument index="0" name="name" type="String" /> <description> Gets the value of a certain attribute of the current element by name. This will raise an error if the element has no such attribute. </description> </method> <method name="get_named_attribute_value_safe" qualifiers="const"> - <return type="String"> - </return> - <argument index="0" name="name" type="String"> - </argument> + <return type="String" /> + <argument index="0" name="name" type="String" /> <description> Gets the value of a certain attribute of the current element by name. This will return an empty [String] if the attribute is not found. </description> </method> <method name="get_node_data" qualifiers="const"> - <return type="String"> - </return> + <return type="String" /> <description> Gets the contents of a text node. This will raise an error in any other type of node. </description> </method> <method name="get_node_name" qualifiers="const"> - <return type="String"> - </return> + <return type="String" /> <description> Gets the name of the current element node. This will raise an error if the current node type is neither [constant NODE_ELEMENT] nor [constant NODE_ELEMENT_END]. </description> </method> <method name="get_node_offset" qualifiers="const"> - <return type="int"> - </return> + <return type="int" /> <description> Gets the byte offset of the current node since the beginning of the file or buffer. </description> </method> <method name="get_node_type"> - <return type="int" enum="XMLParser.NodeType"> - </return> + <return type="int" enum="XMLParser.NodeType" /> <description> Gets the type of the current node. Compare with [enum NodeType] constants. </description> </method> <method name="has_attribute" qualifiers="const"> - <return type="bool"> - </return> - <argument index="0" name="name" type="String"> - </argument> + <return type="bool" /> + <argument index="0" name="name" type="String" /> <description> Check whether the current element has a certain attribute. </description> </method> <method name="is_empty" qualifiers="const"> - <return type="bool"> - </return> + <return type="bool" /> <description> Check whether the current element is empty (this only works for completely empty tags, e.g. [code]<element \>[/code]). </description> </method> <method name="open"> - <return type="int" enum="Error"> - </return> - <argument index="0" name="file" type="String"> - </argument> + <return type="int" enum="Error" /> + <argument index="0" name="file" type="String" /> <description> Opens an XML file for parsing. This returns an error code. </description> </method> <method name="open_buffer"> - <return type="int" enum="Error"> - </return> - <argument index="0" name="buffer" type="PackedByteArray"> - </argument> + <return type="int" enum="Error" /> + <argument index="0" name="buffer" type="PackedByteArray" /> <description> Opens an XML raw buffer for parsing. This returns an error code. </description> </method> <method name="read"> - <return type="int" enum="Error"> - </return> + <return type="int" enum="Error" /> <description> Reads the next node of the file. This returns an error code. </description> </method> <method name="seek"> - <return type="int" enum="Error"> - </return> - <argument index="0" name="position" type="int"> - </argument> + <return type="int" enum="Error" /> + <argument index="0" name="position" type="int" /> <description> Moves the buffer cursor to a certain offset (since the beginning) and read the next node there. This returns an error code. </description> </method> <method name="skip_section"> - <return type="void"> - </return> + <return type="void" /> <description> Skips the current section. If the node contains other elements, they will be ignored and the cursor will go to the closing of the current element. </description> diff --git a/doc/classes/XRAnchor3D.xml b/doc/classes/XRAnchor3D.xml index a409c79230..ccbfab1273 100644 --- a/doc/classes/XRAnchor3D.xml +++ b/doc/classes/XRAnchor3D.xml @@ -12,36 +12,31 @@ </tutorials> <methods> <method name="get_anchor_name" qualifiers="const"> - <return type="String"> - </return> + <return type="String" /> <description> Returns the name given to this anchor. </description> </method> <method name="get_is_active" qualifiers="const"> - <return type="bool"> - </return> + <return type="bool" /> <description> Returns [code]true[/code] if the anchor is being tracked and [code]false[/code] if no anchor with this ID is currently known. </description> </method> <method name="get_mesh" qualifiers="const"> - <return type="Mesh"> - </return> + <return type="Mesh" /> <description> If provided by the [XRInterface], this returns a mesh object for the anchor. For an anchor, this can be a shape related to the object being tracked or it can be a mesh that provides topology related to the anchor and can be used to create shadows/reflections on surfaces or for generating collision shapes. </description> </method> <method name="get_plane" qualifiers="const"> - <return type="Plane"> - </return> + <return type="Plane" /> <description> Returns a plane aligned with our anchor; handy for intersection testing. </description> </method> <method name="get_size" qualifiers="const"> - <return type="Vector3"> - </return> + <return type="Vector3" /> <description> Returns the estimated size of the plane that was detected. Say when the anchor relates to a table in the real world, this is the estimated size of the surface of that table. </description> @@ -54,8 +49,7 @@ </members> <signals> <signal name="mesh_updated"> - <argument index="0" name="mesh" type="Mesh"> - </argument> + <argument index="0" name="mesh" type="Mesh" /> <description> Emitted when the mesh associated with the anchor changes or when one becomes available. This is especially important for topology that is constantly being [code]mesh_updated[/code]. </description> diff --git a/doc/classes/XRController3D.xml b/doc/classes/XRController3D.xml index 5d8c23bd6f..47ddc22823 100644 --- a/doc/classes/XRController3D.xml +++ b/doc/classes/XRController3D.xml @@ -13,54 +13,45 @@ </tutorials> <methods> <method name="get_controller_name" qualifiers="const"> - <return type="String"> - </return> + <return type="String" /> <description> If active, returns the name of the associated controller if provided by the AR/VR SDK used. </description> </method> <method name="get_is_active" qualifiers="const"> - <return type="bool"> - </return> + <return type="bool" /> <description> Returns [code]true[/code] if the bound controller is active. XR systems attempt to track active controllers. </description> </method> <method name="get_joystick_axis" qualifiers="const"> - <return type="float"> - </return> - <argument index="0" name="axis" type="int"> - </argument> + <return type="float" /> + <argument index="0" name="axis" type="int" /> <description> Returns the value of the given axis for things like triggers, touchpads, etc. that are embedded into the controller. </description> </method> <method name="get_joystick_id" qualifiers="const"> - <return type="int"> - </return> + <return type="int" /> <description> Returns the ID of the joystick object bound to this. Every controller tracked by the [XRServer] that has buttons and axis will also be registered as a joystick within Godot. This means that all the normal joystick tracking and input mapping will work for buttons and axis found on the AR/VR controllers. This ID is purely offered as information so you can link up the controller with its joystick entry. </description> </method> <method name="get_mesh" qualifiers="const"> - <return type="Mesh"> - </return> + <return type="Mesh" /> <description> If provided by the [XRInterface], this returns a mesh associated with the controller. This can be used to visualize the controller. </description> </method> <method name="get_tracker_hand" qualifiers="const"> - <return type="int" enum="XRPositionalTracker.TrackerHand"> - </return> + <return type="int" enum="XRPositionalTracker.TrackerHand" /> <description> Returns the hand holding this controller, if known. See [enum XRPositionalTracker.TrackerHand]. </description> </method> <method name="is_button_pressed" qualifiers="const"> - <return type="bool"> - </return> - <argument index="0" name="button" type="int"> - </argument> + <return type="bool" /> + <argument index="0" name="button" type="int" /> <description> Returns [code]true[/code] if the button at index [code]button[/code] is pressed. See [enum JoyButton]. </description> @@ -80,22 +71,19 @@ </members> <signals> <signal name="button_pressed"> - <argument index="0" name="button" type="int"> - </argument> + <argument index="0" name="button" type="int" /> <description> Emitted when a button on this controller is pressed. </description> </signal> <signal name="button_released"> - <argument index="0" name="button" type="int"> - </argument> + <argument index="0" name="button" type="int" /> <description> Emitted when a button on this controller is released. </description> </signal> <signal name="mesh_updated"> - <argument index="0" name="mesh" type="Mesh"> - </argument> + <argument index="0" name="mesh" type="Mesh" /> <description> Emitted when the mesh associated with the controller changes or when one becomes available. Generally speaking this will be a static mesh after becoming available. </description> diff --git a/doc/classes/XRInterface.xml b/doc/classes/XRInterface.xml index fec98007c3..1fb73e59b4 100644 --- a/doc/classes/XRInterface.xml +++ b/doc/classes/XRInterface.xml @@ -12,50 +12,43 @@ </tutorials> <methods> <method name="get_camera_feed_id"> - <return type="int"> - </return> + <return type="int" /> <description> If this is an AR interface that requires displaying a camera feed as the background, this method returns the feed ID in the [CameraServer] for this interface. </description> </method> <method name="get_capabilities" qualifiers="const"> - <return type="int"> - </return> + <return type="int" /> <description> Returns a combination of [enum Capabilities] flags providing information about the capabilities of this interface. </description> </method> <method name="get_name" qualifiers="const"> - <return type="StringName"> - </return> + <return type="StringName" /> <description> Returns the name of this interface (OpenVR, OpenHMD, ARKit, etc). </description> </method> <method name="get_render_targetsize"> - <return type="Vector2"> - </return> + <return type="Vector2" /> <description> Returns the resolution at which we should render our intermediate results before things like lens distortion are applied by the VR platform. </description> </method> <method name="get_tracking_status" qualifiers="const"> - <return type="int" enum="XRInterface.Tracking_status"> - </return> + <return type="int" enum="XRInterface.Tracking_status" /> <description> If supported, returns the status of our tracking. This will allow you to provide feedback to the user whether there are issues with positional tracking. </description> </method> <method name="get_view_count"> - <return type="int"> - </return> + <return type="int" /> <description> Returns the number of views that need to be rendered for this device. 1 for Monoscopic, 2 for Stereoscopic. </description> </method> <method name="initialize"> - <return type="bool"> - </return> + <return type="bool" /> <description> Call this to initialize this interface. The first interface that is initialized is identified as the primary interface and it will be used for rendering output. After initializing the interface you want to use you then need to enable the AR/VR mode of a viewport and rendering should commence. @@ -65,8 +58,7 @@ </description> </method> <method name="uninitialize"> - <return type="void"> - </return> + <return type="void" /> <description> Turns the interface off. </description> diff --git a/doc/classes/XRPositionalTracker.xml b/doc/classes/XRPositionalTracker.xml index cd8cb71cd9..8cc7c872b6 100644 --- a/doc/classes/XRPositionalTracker.xml +++ b/doc/classes/XRPositionalTracker.xml @@ -13,80 +13,68 @@ </tutorials> <methods> <method name="get_joy_id" qualifiers="const"> - <return type="int"> - </return> + <return type="int" /> <description> If this is a controller that is being tracked, the controller will also be represented by a joystick entry with this ID. </description> </method> <method name="get_mesh" qualifiers="const"> - <return type="Mesh"> - </return> + <return type="Mesh" /> <description> Returns the mesh related to a controller or anchor point if one is available. </description> </method> <method name="get_orientation" qualifiers="const"> - <return type="Basis"> - </return> + <return type="Basis" /> <description> Returns the controller's orientation matrix. </description> </method> <method name="get_position" qualifiers="const"> - <return type="Vector3"> - </return> + <return type="Vector3" /> <description> Returns the world-space controller position. </description> </method> <method name="get_tracker_hand" qualifiers="const"> - <return type="int" enum="XRPositionalTracker.TrackerHand"> - </return> + <return type="int" enum="XRPositionalTracker.TrackerHand" /> <description> Returns the hand holding this tracker, if known. See [enum TrackerHand] constants. </description> </method> <method name="get_tracker_id" qualifiers="const"> - <return type="int"> - </return> + <return type="int" /> <description> Returns the internal tracker ID. This uniquely identifies the tracker per tracker type and matches the ID you need to specify for nodes such as the [XRController3D] and [XRAnchor3D] nodes. </description> </method> <method name="get_tracker_name" qualifiers="const"> - <return type="StringName"> - </return> + <return type="StringName" /> <description> Returns the controller or anchor point's name, if applicable. </description> </method> <method name="get_tracker_type" qualifiers="const"> - <return type="int" enum="XRServer.TrackerType"> - </return> + <return type="int" enum="XRServer.TrackerType" /> <description> Returns the tracker's type, which will be one of the values from the [enum XRServer.TrackerType] enum. </description> </method> <method name="get_transform" qualifiers="const"> - <return type="Transform3D"> - </return> - <argument index="0" name="adjust_by_reference_frame" type="bool"> - </argument> + <return type="Transform3D" /> + <argument index="0" name="adjust_by_reference_frame" type="bool" /> <description> Returns the transform combining this device's orientation and position. </description> </method> <method name="is_tracking_orientation" qualifiers="const"> - <return type="bool"> - </return> + <return type="bool" /> <description> Returns [code]true[/code] if this device is tracking orientation. </description> </method> <method name="is_tracking_position" qualifiers="const"> - <return type="bool"> - </return> + <return type="bool" /> <description> Returns [code]true[/code] if this device is tracking position. </description> diff --git a/doc/classes/XRServer.xml b/doc/classes/XRServer.xml index 149e177700..5dd9b75ad2 100644 --- a/doc/classes/XRServer.xml +++ b/doc/classes/XRServer.xml @@ -11,30 +11,23 @@ </tutorials> <methods> <method name="add_interface"> - <return type="void"> - </return> - <argument index="0" name="interface" type="XRInterface"> - </argument> + <return type="void" /> + <argument index="0" name="interface" type="XRInterface" /> <description> Registers an [XRInterface] object. </description> </method> <method name="add_tracker"> - <return type="void"> - </return> - <argument index="0" name="tracker" type="XRPositionalTracker"> - </argument> + <return type="void" /> + <argument index="0" name="tracker" type="XRPositionalTracker" /> <description> Registers a new [XRPositionalTracker] that tracks a spatial location in real space. </description> </method> <method name="center_on_hmd"> - <return type="void"> - </return> - <argument index="0" name="rotation_mode" type="int" enum="XRServer.RotationMode"> - </argument> - <argument index="1" name="keep_height" type="bool"> - </argument> + <return type="void" /> + <argument index="0" name="rotation_mode" type="int" enum="XRServer.RotationMode" /> + <argument index="1" name="keep_height" type="bool" /> <description> This is an important function to understand correctly. AR and VR platforms all handle positioning slightly differently. For platforms that do not offer spatial tracking, our origin point (0,0,0) is the location of our HMD, but you have little control over the direction the player is facing in the real world. @@ -45,111 +38,91 @@ </description> </method> <method name="clear_primary_interface_if"> - <return type="void"> - </return> - <argument index="0" name="interface" type="XRInterface"> - </argument> + <return type="void" /> + <argument index="0" name="interface" type="XRInterface" /> <description> Clears our current primary interface if it is set to the provided interface. </description> </method> <method name="find_interface" qualifiers="const"> - <return type="XRInterface"> - </return> - <argument index="0" name="name" type="String"> - </argument> + <return type="XRInterface" /> + <argument index="0" name="name" type="String" /> <description> Finds an interface by its name. For instance, if your project uses capabilities of an AR/VR platform, you can find the interface for that platform by name and initialize it. </description> </method> <method name="get_hmd_transform"> - <return type="Transform3D"> - </return> + <return type="Transform3D" /> <description> Returns the primary interface's transformation. </description> </method> <method name="get_interface" qualifiers="const"> - <return type="XRInterface"> - </return> - <argument index="0" name="idx" type="int"> - </argument> + <return type="XRInterface" /> + <argument index="0" name="idx" type="int" /> <description> Returns the interface registered at a given index in our list of interfaces. </description> </method> <method name="get_interface_count" qualifiers="const"> - <return type="int"> - </return> + <return type="int" /> <description> Returns the number of interfaces currently registered with the AR/VR server. If your project supports multiple AR/VR platforms, you can look through the available interface, and either present the user with a selection or simply try to initialize each interface and use the first one that returns [code]true[/code]. </description> </method> <method name="get_interfaces" qualifiers="const"> - <return type="Array"> - </return> + <return type="Array" /> <description> Returns a list of available interfaces the ID and name of each interface. </description> </method> <method name="get_last_commit_usec"> - <return type="int"> - </return> + <return type="int" /> <description> Returns the absolute timestamp (in μs) of the last [XRServer] commit of the AR/VR eyes to [RenderingServer]. The value comes from an internal call to [method Time.get_ticks_usec]. </description> </method> <method name="get_last_frame_usec"> - <return type="int"> - </return> + <return type="int" /> <description> Returns the duration (in μs) of the last frame. This is computed as the difference between [method get_last_commit_usec] and [method get_last_process_usec] when committing. </description> </method> <method name="get_last_process_usec"> - <return type="int"> - </return> + <return type="int" /> <description> Returns the absolute timestamp (in μs) of the last [XRServer] process callback. The value comes from an internal call to [method Time.get_ticks_usec]. </description> </method> <method name="get_reference_frame" qualifiers="const"> - <return type="Transform3D"> - </return> + <return type="Transform3D" /> <description> Returns the reference frame transform. Mostly used internally and exposed for GDNative build interfaces. </description> </method> <method name="get_tracker" qualifiers="const"> - <return type="XRPositionalTracker"> - </return> - <argument index="0" name="idx" type="int"> - </argument> + <return type="XRPositionalTracker" /> + <argument index="0" name="idx" type="int" /> <description> Returns the positional tracker at the given ID. </description> </method> <method name="get_tracker_count" qualifiers="const"> - <return type="int"> - </return> + <return type="int" /> <description> Returns the number of trackers currently registered. </description> </method> <method name="remove_interface"> - <return type="void"> - </return> - <argument index="0" name="interface" type="XRInterface"> - </argument> + <return type="void" /> + <argument index="0" name="interface" type="XRInterface" /> <description> Removes this interface. </description> </method> <method name="remove_tracker"> - <return type="void"> - </return> - <argument index="0" name="tracker" type="XRPositionalTracker"> - </argument> + <return type="void" /> + <argument index="0" name="tracker" type="XRPositionalTracker" /> <description> Removes this positional tracker. </description> @@ -165,37 +138,29 @@ </members> <signals> <signal name="interface_added"> - <argument index="0" name="interface_name" type="StringName"> - </argument> + <argument index="0" name="interface_name" type="StringName" /> <description> Emitted when a new interface has been added. </description> </signal> <signal name="interface_removed"> - <argument index="0" name="interface_name" type="StringName"> - </argument> + <argument index="0" name="interface_name" type="StringName" /> <description> Emitted when an interface is removed. </description> </signal> <signal name="tracker_added"> - <argument index="0" name="tracker_name" type="StringName"> - </argument> - <argument index="1" name="type" type="int"> - </argument> - <argument index="2" name="id" type="int"> - </argument> + <argument index="0" name="tracker_name" type="StringName" /> + <argument index="1" name="type" type="int" /> + <argument index="2" name="id" type="int" /> <description> Emitted when a new tracker has been added. If you don't use a fixed number of controllers or if you're using [XRAnchor3D]s for an AR solution, it is important to react to this signal to add the appropriate [XRController3D] or [XRAnchor3D] nodes related to this new tracker. </description> </signal> <signal name="tracker_removed"> - <argument index="0" name="tracker_name" type="StringName"> - </argument> - <argument index="1" name="type" type="int"> - </argument> - <argument index="2" name="id" type="int"> - </argument> + <argument index="0" name="tracker_name" type="StringName" /> + <argument index="1" name="type" type="int" /> + <argument index="2" name="id" type="int" /> <description> Emitted when a tracker is removed. You should remove any [XRController3D] or [XRAnchor3D] points if applicable. This is not mandatory, the nodes simply become inactive and will be made active again when a new tracker becomes available (i.e. a new controller is switched on that takes the place of the previous one). </description> diff --git a/doc/classes/bool.xml b/doc/classes/bool.xml index 48f336d58c..f3b16217e5 100644 --- a/doc/classes/bool.xml +++ b/doc/classes/bool.xml @@ -93,71 +93,56 @@ </tutorials> <methods> <method name="bool" qualifiers="constructor"> - <return type="bool"> - </return> + <return type="bool" /> <description> Constructs a default-initialized [bool] set to [code]false[/code]. </description> </method> <method name="bool" qualifiers="constructor"> - <return type="bool"> - </return> - <argument index="0" name="from" type="bool"> - </argument> + <return type="bool" /> + <argument index="0" name="from" type="bool" /> <description> Constructs a [bool] as a copy of the given [bool]. </description> </method> <method name="bool" qualifiers="constructor"> - <return type="bool"> - </return> - <argument index="0" name="from" type="float"> - </argument> + <return type="bool" /> + <argument index="0" name="from" type="float" /> <description> Cast a [float] value to a boolean value, this method will return [code]false[/code] if [code]0.0[/code] is passed in, and [code]true[/code] for all other floats. </description> </method> <method name="bool" qualifiers="constructor"> - <return type="bool"> - </return> - <argument index="0" name="from" type="int"> - </argument> + <return type="bool" /> + <argument index="0" name="from" type="int" /> <description> Cast an [int] value to a boolean value, this method will return [code]false[/code] if [code]0[/code] is passed in, and [code]true[/code] for all other ints. </description> </method> <method name="operator !=" qualifiers="operator"> - <return type="bool"> - </return> - <argument index="0" name="right" type="bool"> - </argument> + <return type="bool" /> + <argument index="0" name="right" type="bool" /> <description> Returns [code]true[/code] if two bools are different, i.e. one is [code]true[/code] and the other is [code]false[/code]. </description> </method> <method name="operator <" qualifiers="operator"> - <return type="bool"> - </return> - <argument index="0" name="right" type="bool"> - </argument> + <return type="bool" /> + <argument index="0" name="right" type="bool" /> <description> Returns [code]true[/code] if left operand is [code]false[/code] and right operand is [code]true[/code]. </description> </method> <method name="operator ==" qualifiers="operator"> - <return type="bool"> - </return> - <argument index="0" name="right" type="bool"> - </argument> + <return type="bool" /> + <argument index="0" name="right" type="bool" /> <description> Returns [code]true[/code] if two bools are equal, i.e. both are [code]true[/code] or both are [code]false[/code]. </description> </method> <method name="operator >" qualifiers="operator"> - <return type="bool"> - </return> - <argument index="0" name="right" type="bool"> - </argument> + <return type="bool" /> + <argument index="0" name="right" type="bool" /> <description> Returns [code]true[/code] if left operand is [code]true[/code] and right operand is [code]false[/code]. </description> diff --git a/doc/classes/float.xml b/doc/classes/float.xml index 585c847d22..60878eb0bd 100644 --- a/doc/classes/float.xml +++ b/doc/classes/float.xml @@ -10,71 +10,56 @@ </tutorials> <methods> <method name="float" qualifiers="constructor"> - <return type="float"> - </return> + <return type="float" /> <description> Constructs a default-initialized [float] set to [code]0.0[/code]. </description> </method> <method name="float" qualifiers="constructor"> - <return type="float"> - </return> - <argument index="0" name="from" type="float"> - </argument> + <return type="float" /> + <argument index="0" name="from" type="float" /> <description> Constructs a [float] as a copy of the given [float]. </description> </method> <method name="float" qualifiers="constructor"> - <return type="float"> - </return> - <argument index="0" name="from" type="bool"> - </argument> + <return type="float" /> + <argument index="0" name="from" type="bool" /> <description> Cast a [bool] value to a floating-point value, [code]float(true)[/code] will be equal to 1.0 and [code]float(false)[/code] will be equal to 0.0. </description> </method> <method name="float" qualifiers="constructor"> - <return type="float"> - </return> - <argument index="0" name="from" type="int"> - </argument> + <return type="float" /> + <argument index="0" name="from" type="int" /> <description> Cast an [int] value to a floating-point value, [code]float(1)[/code] will be equal to [code]1.0[/code]. </description> </method> <method name="operator !=" qualifiers="operator"> - <return type="bool"> - </return> - <argument index="0" name="right" type="float"> - </argument> + <return type="bool" /> + <argument index="0" name="right" type="float" /> <description> Returns [code]true[/code] if two floats are different from each other. </description> </method> <method name="operator !=" qualifiers="operator"> - <return type="bool"> - </return> - <argument index="0" name="right" type="int"> - </argument> + <return type="bool" /> + <argument index="0" name="right" type="int" /> <description> Returns [code]true[/code] if the integer has different value than the float. </description> </method> <method name="operator *" qualifiers="operator"> - <return type="float"> - </return> - <argument index="0" name="right" type="float"> - </argument> + <return type="float" /> + <argument index="0" name="right" type="float" /> <description> Multiplies two [float]s. </description> </method> <method name="operator *" qualifiers="operator"> - <return type="Vector2"> - </return> - <argument index="0" name="right" type="Vector2"> - </argument> + <return type="Vector2" /> + <argument index="0" name="right" type="Vector2" /> <description> Multiplies each component of the [Vector2] by the given [float]. [codeblock] @@ -83,10 +68,8 @@ </description> </method> <method name="operator *" qualifiers="operator"> - <return type="Vector2i"> - </return> - <argument index="0" name="right" type="Vector2i"> - </argument> + <return type="Vector2i" /> + <argument index="0" name="right" type="Vector2i" /> <description> Multiplies each component of the [Vector2i] by the given [float]. [codeblock] @@ -95,37 +78,29 @@ </description> </method> <method name="operator *" qualifiers="operator"> - <return type="Vector3"> - </return> - <argument index="0" name="right" type="Vector3"> - </argument> + <return type="Vector3" /> + <argument index="0" name="right" type="Vector3" /> <description> Multiplies each component of the [Vector3] by the given [float]. </description> </method> <method name="operator *" qualifiers="operator"> - <return type="Vector3i"> - </return> - <argument index="0" name="right" type="Vector3i"> - </argument> + <return type="Vector3i" /> + <argument index="0" name="right" type="Vector3i" /> <description> Multiplies each component of the [Vector3i] by the given [float]. </description> </method> <method name="operator *" qualifiers="operator"> - <return type="Quaternion"> - </return> - <argument index="0" name="right" type="Quaternion"> - </argument> + <return type="Quaternion" /> + <argument index="0" name="right" type="Quaternion" /> <description> Multiplies each component of the [Quaternion] by the given [float]. </description> </method> <method name="operator *" qualifiers="operator"> - <return type="Color"> - </return> - <argument index="0" name="right" type="Color"> - </argument> + <return type="Color" /> + <argument index="0" name="right" type="Color" /> <description> Multiplies each component of the [Color] by the given [float]. [codeblock] @@ -134,168 +109,132 @@ </description> </method> <method name="operator *" qualifiers="operator"> - <return type="float"> - </return> - <argument index="0" name="right" type="int"> - </argument> + <return type="float" /> + <argument index="0" name="right" type="int" /> <description> Multiplies a [float] and an [int]. The result is a [float]. </description> </method> <method name="operator +" qualifiers="operator"> - <return type="float"> - </return> - <argument index="0" name="right" type="float"> - </argument> + <return type="float" /> + <argument index="0" name="right" type="float" /> <description> Adds two floats. </description> </method> <method name="operator +" qualifiers="operator"> - <return type="float"> - </return> - <argument index="0" name="right" type="int"> - </argument> + <return type="float" /> + <argument index="0" name="right" type="int" /> <description> Adds a [float] and an [int]. The result is a [float]. </description> </method> <method name="operator -" qualifiers="operator"> - <return type="float"> - </return> - <argument index="0" name="right" type="float"> - </argument> + <return type="float" /> + <argument index="0" name="right" type="float" /> <description> Subtracts a float from a float. </description> </method> <method name="operator -" qualifiers="operator"> - <return type="float"> - </return> - <argument index="0" name="right" type="int"> - </argument> + <return type="float" /> + <argument index="0" name="right" type="int" /> <description> Subtracts an [int] from a [float]. The result is a [float]. </description> </method> <method name="operator /" qualifiers="operator"> - <return type="float"> - </return> - <argument index="0" name="right" type="float"> - </argument> + <return type="float" /> + <argument index="0" name="right" type="float" /> <description> Divides two floats. </description> </method> <method name="operator /" qualifiers="operator"> - <return type="float"> - </return> - <argument index="0" name="right" type="int"> - </argument> + <return type="float" /> + <argument index="0" name="right" type="int" /> <description> Divides a [float] by an [int]. The result is a [float]. </description> </method> <method name="operator <" qualifiers="operator"> - <return type="bool"> - </return> - <argument index="0" name="right" type="float"> - </argument> + <return type="bool" /> + <argument index="0" name="right" type="float" /> <description> Returns [code]true[/code] the left float is less than the right one. </description> </method> <method name="operator <" qualifiers="operator"> - <return type="bool"> - </return> - <argument index="0" name="right" type="int"> - </argument> + <return type="bool" /> + <argument index="0" name="right" type="int" /> <description> Returns [code]true[/code] if this [float] is less than the given [int]. </description> </method> <method name="operator <=" qualifiers="operator"> - <return type="bool"> - </return> - <argument index="0" name="right" type="float"> - </argument> + <return type="bool" /> + <argument index="0" name="right" type="float" /> <description> Returns [code]true[/code] the left integer is less than or equal to the right one. </description> </method> <method name="operator <=" qualifiers="operator"> - <return type="bool"> - </return> - <argument index="0" name="right" type="int"> - </argument> + <return type="bool" /> + <argument index="0" name="right" type="int" /> <description> Returns [code]true[/code] if this [float] is less than or equal to the given [int]. </description> </method> <method name="operator ==" qualifiers="operator"> - <return type="bool"> - </return> - <argument index="0" name="right" type="float"> - </argument> + <return type="bool" /> + <argument index="0" name="right" type="float" /> <description> Returns [code]true[/code] if both floats are exactly equal. [b]Note:[/b] Due to floating-point precision errors, consider using [method @GlobalScope.is_equal_approx] or [method @GlobalScope.is_zero_approx] instead, which are more reliable. </description> </method> <method name="operator ==" qualifiers="operator"> - <return type="bool"> - </return> - <argument index="0" name="right" type="int"> - </argument> + <return type="bool" /> + <argument index="0" name="right" type="int" /> <description> Returns [code]true[/code] if the [float] and the given [int] are equal. </description> </method> <method name="operator >" qualifiers="operator"> - <return type="bool"> - </return> - <argument index="0" name="right" type="float"> - </argument> + <return type="bool" /> + <argument index="0" name="right" type="float" /> <description> Returns [code]true[/code] the left float is greater than the right one. </description> </method> <method name="operator >" qualifiers="operator"> - <return type="bool"> - </return> - <argument index="0" name="right" type="int"> - </argument> + <return type="bool" /> + <argument index="0" name="right" type="int" /> <description> Returns [code]true[/code] if this [float] is greater than the given [int]. </description> </method> <method name="operator >=" qualifiers="operator"> - <return type="bool"> - </return> - <argument index="0" name="right" type="float"> - </argument> + <return type="bool" /> + <argument index="0" name="right" type="float" /> <description> Returns [code]true[/code] the left float is greater than or equal to the right one. </description> </method> <method name="operator >=" qualifiers="operator"> - <return type="bool"> - </return> - <argument index="0" name="right" type="int"> - </argument> + <return type="bool" /> + <argument index="0" name="right" type="int" /> <description> Returns [code]true[/code] if this [float] is greater than or equal to the given [int]. </description> </method> <method name="operator unary+" qualifiers="operator"> - <return type="float"> - </return> + <return type="float" /> <description> </description> </method> <method name="operator unary-" qualifiers="operator"> - <return type="float"> - </return> + <return type="float" /> <description> </description> </method> diff --git a/doc/classes/int.xml b/doc/classes/int.xml index 95918c9007..84a01aa0d0 100644 --- a/doc/classes/int.xml +++ b/doc/classes/int.xml @@ -40,62 +40,49 @@ </tutorials> <methods> <method name="int" qualifiers="constructor"> - <return type="int"> - </return> + <return type="int" /> <description> Constructs a default-initialized [int] set to [code]0[/code]. </description> </method> <method name="int" qualifiers="constructor"> - <return type="int"> - </return> - <argument index="0" name="from" type="int"> - </argument> + <return type="int" /> + <argument index="0" name="from" type="int" /> <description> Constructs an [int] as a copy of the given [int]. </description> </method> <method name="int" qualifiers="constructor"> - <return type="int"> - </return> - <argument index="0" name="from" type="bool"> - </argument> + <return type="int" /> + <argument index="0" name="from" type="bool" /> <description> Cast a [bool] value to an integer value, [code]int(true)[/code] will be equals to 1 and [code]int(false)[/code] will be equals to 0. </description> </method> <method name="int" qualifiers="constructor"> - <return type="int"> - </return> - <argument index="0" name="from" type="float"> - </argument> + <return type="int" /> + <argument index="0" name="from" type="float" /> <description> Cast a float value to an integer value, this method simply removes the number fractions (i.e. rounds [code]from[/code] towards zero), so for example [code]int(2.7)[/code] will be equals to 2, [code]int(0.1)[/code] will be equals to 0 and [code]int(-2.7)[/code] will be equals to -2. This operation is also called truncation. </description> </method> <method name="operator !=" qualifiers="operator"> - <return type="bool"> - </return> - <argument index="0" name="right" type="float"> - </argument> + <return type="bool" /> + <argument index="0" name="right" type="float" /> <description> Returns [code]true[/code] if operands are different from each other. </description> </method> <method name="operator !=" qualifiers="operator"> - <return type="bool"> - </return> - <argument index="0" name="right" type="int"> - </argument> + <return type="bool" /> + <argument index="0" name="right" type="int" /> <description> Returns [code]true[/code] if operands are different from each other. </description> </method> <method name="operator %" qualifiers="operator"> - <return type="int"> - </return> - <argument index="0" name="right" type="int"> - </argument> + <return type="int" /> + <argument index="0" name="right" type="int" /> <description> Returns the result of the modulo operator for two integers, i.e. the remainder after dividing both numbers. [codeblock] @@ -106,10 +93,8 @@ </description> </method> <method name="operator &" qualifiers="operator"> - <return type="int"> - </return> - <argument index="0" name="right" type="int"> - </argument> + <return type="int" /> + <argument index="0" name="right" type="int" /> <description> Returns the result of bitwise [code]AND[/code] operation for two integers. [codeblock] @@ -126,28 +111,22 @@ </description> </method> <method name="operator *" qualifiers="operator"> - <return type="int"> - </return> - <argument index="0" name="right" type="int"> - </argument> + <return type="int" /> + <argument index="0" name="right" type="int" /> <description> Multiplies two [int]s. </description> </method> <method name="operator *" qualifiers="operator"> - <return type="float"> - </return> - <argument index="0" name="right" type="float"> - </argument> + <return type="float" /> + <argument index="0" name="right" type="float" /> <description> Multiplies an [int] and a [float]. The result is a [float]. </description> </method> <method name="operator *" qualifiers="operator"> - <return type="Vector2"> - </return> - <argument index="0" name="right" type="Vector2"> - </argument> + <return type="Vector2" /> + <argument index="0" name="right" type="Vector2" /> <description> Multiplies each component of the vector by the given integer. [codeblock] @@ -156,46 +135,36 @@ </description> </method> <method name="operator *" qualifiers="operator"> - <return type="Vector2i"> - </return> - <argument index="0" name="right" type="Vector2i"> - </argument> + <return type="Vector2i" /> + <argument index="0" name="right" type="Vector2i" /> <description> Multiplies each component of the integer vector by the given integer. </description> </method> <method name="operator *" qualifiers="operator"> - <return type="Vector3"> - </return> - <argument index="0" name="right" type="Vector3"> - </argument> + <return type="Vector3" /> + <argument index="0" name="right" type="Vector3" /> <description> Multiplies each component of the vector by the given integer. </description> </method> <method name="operator *" qualifiers="operator"> - <return type="Vector3i"> - </return> - <argument index="0" name="right" type="Vector3i"> - </argument> + <return type="Vector3i" /> + <argument index="0" name="right" type="Vector3i" /> <description> Multiplies each component of the integer vector by the given integer. </description> </method> <method name="operator *" qualifiers="operator"> - <return type="Quaternion"> - </return> - <argument index="0" name="right" type="Quaternion"> - </argument> + <return type="Quaternion" /> + <argument index="0" name="right" type="Quaternion" /> <description> Multiplies each component of the quaternion by the given integer. </description> </method> <method name="operator *" qualifiers="operator"> - <return type="Color"> - </return> - <argument index="0" name="right" type="Color"> - </argument> + <return type="Color" /> + <argument index="0" name="right" type="Color" /> <description> Multiplies each component of the color by the given integer. [codeblock] @@ -204,46 +173,36 @@ </description> </method> <method name="operator +" qualifiers="operator"> - <return type="float"> - </return> - <argument index="0" name="right" type="float"> - </argument> + <return type="float" /> + <argument index="0" name="right" type="float" /> <description> Adds an [int] to a [float]. The result is a [float]. </description> </method> <method name="operator +" qualifiers="operator"> - <return type="int"> - </return> - <argument index="0" name="right" type="int"> - </argument> + <return type="int" /> + <argument index="0" name="right" type="int" /> <description> Adds two integers. </description> </method> <method name="operator -" qualifiers="operator"> - <return type="float"> - </return> - <argument index="0" name="right" type="float"> - </argument> + <return type="float" /> + <argument index="0" name="right" type="float" /> <description> Subtracts a [float] from an [int]. The result is a [float]. </description> </method> <method name="operator -" qualifiers="operator"> - <return type="int"> - </return> - <argument index="0" name="right" type="int"> - </argument> + <return type="int" /> + <argument index="0" name="right" type="int" /> <description> Subtracts two integers. </description> </method> <method name="operator /" qualifiers="operator"> - <return type="float"> - </return> - <argument index="0" name="right" type="float"> - </argument> + <return type="float" /> + <argument index="0" name="right" type="float" /> <description> Divides an [int] by a [float]. The result is a [float]. [codeblock] @@ -252,10 +211,8 @@ </description> </method> <method name="operator /" qualifiers="operator"> - <return type="int"> - </return> - <argument index="0" name="right" type="int"> - </argument> + <return type="int" /> + <argument index="0" name="right" type="int" /> <description> Divides two integers. The decimal part of the result is discarded (truncated). [codeblock] @@ -265,28 +222,22 @@ </description> </method> <method name="operator <" qualifiers="operator"> - <return type="bool"> - </return> - <argument index="0" name="right" type="float"> - </argument> + <return type="bool" /> + <argument index="0" name="right" type="float" /> <description> Returns [code]true[/code] if this [int] is less than the given [float]. </description> </method> <method name="operator <" qualifiers="operator"> - <return type="bool"> - </return> - <argument index="0" name="right" type="int"> - </argument> + <return type="bool" /> + <argument index="0" name="right" type="int" /> <description> Returns [code]true[/code] the left integer is less than the right one. </description> </method> <method name="operator <<" qualifiers="operator"> - <return type="int"> - </return> - <argument index="0" name="right" type="int"> - </argument> + <return type="int" /> + <argument index="0" name="right" type="int" /> <description> Performs bitwise shift left operation on the integer. Effectively the same as multiplying by a power of 2. [codeblock] @@ -296,82 +247,64 @@ </description> </method> <method name="operator <=" qualifiers="operator"> - <return type="bool"> - </return> - <argument index="0" name="right" type="float"> - </argument> + <return type="bool" /> + <argument index="0" name="right" type="float" /> <description> Returns [code]true[/code] if this [int] is less than or equal to the given [float]. </description> </method> <method name="operator <=" qualifiers="operator"> - <return type="bool"> - </return> - <argument index="0" name="right" type="int"> - </argument> + <return type="bool" /> + <argument index="0" name="right" type="int" /> <description> Returns [code]true[/code] the left integer is less than or equal to the right one. </description> </method> <method name="operator ==" qualifiers="operator"> - <return type="bool"> - </return> - <argument index="0" name="right" type="float"> - </argument> + <return type="bool" /> + <argument index="0" name="right" type="float" /> <description> Returns [code]true[/code] if the integer is equal to the given [float]. </description> </method> <method name="operator ==" qualifiers="operator"> - <return type="bool"> - </return> - <argument index="0" name="right" type="int"> - </argument> + <return type="bool" /> + <argument index="0" name="right" type="int" /> <description> Returns [code]true[/code] if both integers are equal. </description> </method> <method name="operator >" qualifiers="operator"> - <return type="bool"> - </return> - <argument index="0" name="right" type="float"> - </argument> + <return type="bool" /> + <argument index="0" name="right" type="float" /> <description> Returns [code]true[/code] if this [int] is greater than the given [float]. </description> </method> <method name="operator >" qualifiers="operator"> - <return type="bool"> - </return> - <argument index="0" name="right" type="int"> - </argument> + <return type="bool" /> + <argument index="0" name="right" type="int" /> <description> Returns [code]true[/code] the left integer is greater than the right one. </description> </method> <method name="operator >=" qualifiers="operator"> - <return type="bool"> - </return> - <argument index="0" name="right" type="float"> - </argument> + <return type="bool" /> + <argument index="0" name="right" type="float" /> <description> Returns [code]true[/code] if this [int] is greater than or equal to the given [float]. </description> </method> <method name="operator >=" qualifiers="operator"> - <return type="bool"> - </return> - <argument index="0" name="right" type="int"> - </argument> + <return type="bool" /> + <argument index="0" name="right" type="int" /> <description> Returns [code]true[/code] the left integer is greater than or equal to the right one. </description> </method> <method name="operator >>" qualifiers="operator"> - <return type="int"> - </return> - <argument index="0" name="right" type="int"> - </argument> + <return type="int" /> + <argument index="0" name="right" type="int" /> <description> Performs bitwise shift right operation on the integer. Effectively the same as dividing by a power of 2. [codeblock] @@ -381,10 +314,8 @@ </description> </method> <method name="operator ^" qualifiers="operator"> - <return type="int"> - </return> - <argument index="0" name="right" type="int"> - </argument> + <return type="int" /> + <argument index="0" name="right" type="int" /> <description> Returns the result of bitwise [code]XOR[/code] operation for two integers. [codeblock] @@ -394,22 +325,18 @@ </description> </method> <method name="operator unary+" qualifiers="operator"> - <return type="int"> - </return> + <return type="int" /> <description> </description> </method> <method name="operator unary-" qualifiers="operator"> - <return type="int"> - </return> + <return type="int" /> <description> </description> </method> <method name="operator |" qualifiers="operator"> - <return type="int"> - </return> - <argument index="0" name="right" type="int"> - </argument> + <return type="int" /> + <argument index="0" name="right" type="int" /> <description> Returns the result of bitwise [code]OR[/code] operation for two integers. [codeblock] @@ -426,8 +353,7 @@ </description> </method> <method name="operator ~" qualifiers="operator"> - <return type="int"> - </return> + <return type="int" /> <description> Returns the result of bitwise [code]NOT[/code] operation for the integer. It's effectively equal to [code]-int + 1[/code]. [codeblock] diff --git a/drivers/unix/file_access_unix.cpp b/drivers/unix/file_access_unix.cpp index 6ea55219bb..f07c654bd6 100644 --- a/drivers/unix/file_access_unix.cpp +++ b/drivers/unix/file_access_unix.cpp @@ -111,7 +111,7 @@ Error FileAccessUnix::_open(const String &p_path, int p_mode_flags) { } } - if (is_backup_save_enabled() && (p_mode_flags & WRITE) && !(p_mode_flags & READ)) { + if (is_backup_save_enabled() && (p_mode_flags == WRITE)) { save_path = path; path = path + ".tmp"; } diff --git a/drivers/unix/net_socket_posix.cpp b/drivers/unix/net_socket_posix.cpp index efeaf32ff7..e01c6a0e0f 100644 --- a/drivers/unix/net_socket_posix.cpp +++ b/drivers/unix/net_socket_posix.cpp @@ -269,11 +269,11 @@ _FORCE_INLINE_ Error NetSocketPosix::_change_multicast_group(IPAddress p_ip, Str break; // IPv6 uses index. } - for (List<IPAddress>::Element *F = c.ip_addresses.front(); F; F = F->next()) { - if (!F->get().is_ipv4()) { + for (const IPAddress &F : c.ip_addresses) { + if (!F.is_ipv4()) { continue; // Wrong IP type } - if_ip = F->get(); + if_ip = F; break; } break; diff --git a/drivers/unix/os_unix.cpp b/drivers/unix/os_unix.cpp index a5c61bbea5..f6a3e93b55 100644 --- a/drivers/unix/os_unix.cpp +++ b/drivers/unix/os_unix.cpp @@ -139,10 +139,6 @@ void OS_Unix::finalize_core() { NetSocketPosix::cleanup(); } -void OS_Unix::alert(const String &p_alert, const String &p_title) { - fprintf(stderr, "ERROR: %s\n", p_alert.utf8().get_data()); -} - String OS_Unix::get_stdin_string(bool p_block) { if (p_block) { char buff[1024]; diff --git a/drivers/unix/os_unix.h b/drivers/unix/os_unix.h index 6c79d984e9..bf82019d38 100644 --- a/drivers/unix/os_unix.h +++ b/drivers/unix/os_unix.h @@ -52,7 +52,6 @@ protected: public: OS_Unix(); - virtual void alert(const String &p_alert, const String &p_title = "ALERT!"); virtual String get_stdin_string(bool p_block) override; //virtual void set_mouse_show(bool p_show); diff --git a/drivers/vulkan/SCsub b/drivers/vulkan/SCsub index 14b9d63204..6a2a57d18c 100644 --- a/drivers/vulkan/SCsub +++ b/drivers/vulkan/SCsub @@ -105,7 +105,7 @@ elif env["builtin_vulkan"]: else: # Always build VMA. thirdparty_dir = "#thirdparty/vulkan" - env.Prepend(CPPPATH=[thirdparty_dir]) + env.Prepend(CPPPATH=[thirdparty_dir, thirdparty_dir + "/include"]) # Build Vulkan loader library env_thirdparty = env.Clone() diff --git a/drivers/vulkan/rendering_device_vulkan.cpp b/drivers/vulkan/rendering_device_vulkan.cpp index d3d49503d8..9ee2a28240 100644 --- a/drivers/vulkan/rendering_device_vulkan.cpp +++ b/drivers/vulkan/rendering_device_vulkan.cpp @@ -31,11 +31,14 @@ #include "rendering_device_vulkan.h" #include "core/config/project_settings.h" +#include "core/io/compression.h" #include "core/io/file_access.h" +#include "core/io/marshalls.h" #include "core/os/os.h" #include "core/templates/hashfuncs.h" #include "drivers/vulkan/vulkan_context.h" +#include "thirdparty/misc/smolv.h" #include "thirdparty/spirv-reflect/spirv_reflect.h" //#define FORCE_FULL_BARRIER @@ -4360,53 +4363,87 @@ bool RenderingDeviceVulkan::_uniform_add_binding(Vector<Vector<VkDescriptorSetLa } #endif -RID RenderingDeviceVulkan::shader_create(const Vector<ShaderStageData> &p_stages) { - //descriptor layouts - Vector<Vector<VkDescriptorSetLayoutBinding>> set_bindings; - Vector<Vector<UniformInfo>> uniform_info; - Shader::PushConstant push_constant; - push_constant.push_constant_size = 0; - push_constant.push_constants_vk_stage = 0; +#define SHADER_BINARY_VERSION 1 - uint32_t vertex_input_mask = 0; +String RenderingDeviceVulkan::shader_get_binary_cache_key() const { + return "Vulkan-SV" + itos(SHADER_BINARY_VERSION); +} - uint32_t fragment_outputs = 0; +struct RenderingDeviceVulkanShaderBinaryDataBinding { + uint32_t type; + uint32_t binding; + uint32_t stages; + uint32_t length; //size of arrays (in total elements), or ubos (in bytes * total elements) +}; - uint32_t stages_processed = 0; +struct RenderingDeviceVulkanShaderBinarySpecializationConstant { + uint32_t type; + uint32_t constant_id; + union { + uint32_t int_value; + float float_value; + bool bool_value; + }; + uint32_t stage_flags; +}; - Vector<Shader::SpecializationConstant> specialization_constants; +struct RenderingDeviceVulkanShaderBinaryData { + uint32_t vertex_input_mask; + uint32_t fragment_outputs; + uint32_t specialization_constant_count; + uint32_t is_compute; + uint32_t compute_local_size[3]; + uint32_t set_count; + uint32_t push_constant_size; + uint32_t push_constants_vk_stage; + uint32_t stage_count; +}; - bool is_compute = false; +Vector<uint8_t> RenderingDeviceVulkan::shader_compile_binary_from_spirv(const Vector<ShaderStageSPIRVData> &p_spirv) { + RenderingDeviceVulkanShaderBinaryData binary_data; + binary_data.vertex_input_mask = 0; + binary_data.fragment_outputs = 0; + binary_data.specialization_constant_count = 0; + binary_data.is_compute = 0; + binary_data.compute_local_size[0] = 0; + binary_data.compute_local_size[1] = 0; + binary_data.compute_local_size[2] = 0; + binary_data.set_count = 0; + binary_data.push_constant_size = 0; + binary_data.push_constants_vk_stage = 0; + + Vector<Vector<RenderingDeviceVulkanShaderBinaryDataBinding>> uniform_info; //set bindings + Vector<RenderingDeviceVulkanShaderBinarySpecializationConstant> specialization_constants; - uint32_t compute_local_size[3] = { 0, 0, 0 }; + uint32_t stages_processed = 0; - for (int i = 0; i < p_stages.size(); i++) { - if (p_stages[i].shader_stage == SHADER_STAGE_COMPUTE) { - is_compute = true; - ERR_FAIL_COND_V_MSG(p_stages.size() != 1, RID(), + for (int i = 0; i < p_spirv.size(); i++) { + if (p_spirv[i].shader_stage == SHADER_STAGE_COMPUTE) { + binary_data.is_compute = true; + ERR_FAIL_COND_V_MSG(p_spirv.size() != 1, Vector<uint8_t>(), "Compute shaders can only receive one stage, dedicated to compute."); } - ERR_FAIL_COND_V_MSG(stages_processed & (1 << p_stages[i].shader_stage), RID(), - "Stage " + String(shader_stage_names[p_stages[i].shader_stage]) + " submitted more than once."); + ERR_FAIL_COND_V_MSG(stages_processed & (1 << p_spirv[i].shader_stage), Vector<uint8_t>(), + "Stage " + String(shader_stage_names[p_spirv[i].shader_stage]) + " submitted more than once."); { SpvReflectShaderModule module; - const uint8_t *spirv = p_stages[i].spir_v.ptr(); - SpvReflectResult result = spvReflectCreateShaderModule(p_stages[i].spir_v.size(), spirv, &module); - ERR_FAIL_COND_V_MSG(result != SPV_REFLECT_RESULT_SUCCESS, RID(), - "Reflection of SPIR-V shader stage '" + String(shader_stage_names[p_stages[i].shader_stage]) + "' failed parsing shader."); - - if (is_compute) { - compute_local_size[0] = module.entry_points->local_size.x; - compute_local_size[1] = module.entry_points->local_size.y; - compute_local_size[2] = module.entry_points->local_size.z; + const uint8_t *spirv = p_spirv[i].spir_v.ptr(); + SpvReflectResult result = spvReflectCreateShaderModule(p_spirv[i].spir_v.size(), spirv, &module); + ERR_FAIL_COND_V_MSG(result != SPV_REFLECT_RESULT_SUCCESS, Vector<uint8_t>(), + "Reflection of SPIR-V shader stage '" + String(shader_stage_names[p_spirv[i].shader_stage]) + "' failed parsing shader."); + + if (binary_data.is_compute) { + binary_data.compute_local_size[0] = module.entry_points->local_size.x; + binary_data.compute_local_size[1] = module.entry_points->local_size.y; + binary_data.compute_local_size[2] = module.entry_points->local_size.z; } uint32_t binding_count = 0; result = spvReflectEnumerateDescriptorBindings(&module, &binding_count, nullptr); - ERR_FAIL_COND_V_MSG(result != SPV_REFLECT_RESULT_SUCCESS, RID(), - "Reflection of SPIR-V shader stage '" + String(shader_stage_names[p_stages[i].shader_stage]) + "' failed enumerating descriptor bindings."); + ERR_FAIL_COND_V_MSG(result != SPV_REFLECT_RESULT_SUCCESS, Vector<uint8_t>(), + "Reflection of SPIR-V shader stage '" + String(shader_stage_names[p_spirv[i].shader_stage]) + "' failed enumerating descriptor bindings."); - uint32_t stage = p_stages[i].shader_stage; + uint32_t stage = p_spirv[i].shader_stage; if (binding_count > 0) { //Parse bindings @@ -4415,56 +4452,47 @@ RID RenderingDeviceVulkan::shader_create(const Vector<ShaderStageData> &p_stages bindings.resize(binding_count); result = spvReflectEnumerateDescriptorBindings(&module, &binding_count, bindings.ptrw()); - ERR_FAIL_COND_V_MSG(result != SPV_REFLECT_RESULT_SUCCESS, RID(), - "Reflection of SPIR-V shader stage '" + String(shader_stage_names[p_stages[i].shader_stage]) + "' failed getting descriptor bindings."); + ERR_FAIL_COND_V_MSG(result != SPV_REFLECT_RESULT_SUCCESS, Vector<uint8_t>(), + "Reflection of SPIR-V shader stage '" + String(shader_stage_names[p_spirv[i].shader_stage]) + "' failed getting descriptor bindings."); for (uint32_t j = 0; j < binding_count; j++) { const SpvReflectDescriptorBinding &binding = *bindings[j]; - VkDescriptorSetLayoutBinding layout_binding; - UniformInfo info; + RenderingDeviceVulkanShaderBinaryDataBinding info; bool need_array_dimensions = false; bool need_block_size = false; switch (binding.descriptor_type) { case SPV_REFLECT_DESCRIPTOR_TYPE_SAMPLER: { - layout_binding.descriptorType = VK_DESCRIPTOR_TYPE_SAMPLER; info.type = UNIFORM_TYPE_SAMPLER; need_array_dimensions = true; } break; case SPV_REFLECT_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER: { - layout_binding.descriptorType = VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER; info.type = UNIFORM_TYPE_SAMPLER_WITH_TEXTURE; need_array_dimensions = true; } break; case SPV_REFLECT_DESCRIPTOR_TYPE_SAMPLED_IMAGE: { - layout_binding.descriptorType = VK_DESCRIPTOR_TYPE_SAMPLED_IMAGE; info.type = UNIFORM_TYPE_TEXTURE; need_array_dimensions = true; } break; case SPV_REFLECT_DESCRIPTOR_TYPE_STORAGE_IMAGE: { - layout_binding.descriptorType = VK_DESCRIPTOR_TYPE_STORAGE_IMAGE; info.type = UNIFORM_TYPE_IMAGE; need_array_dimensions = true; } break; case SPV_REFLECT_DESCRIPTOR_TYPE_UNIFORM_TEXEL_BUFFER: { - layout_binding.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_TEXEL_BUFFER; info.type = UNIFORM_TYPE_TEXTURE_BUFFER; need_array_dimensions = true; } break; case SPV_REFLECT_DESCRIPTOR_TYPE_STORAGE_TEXEL_BUFFER: { - layout_binding.descriptorType = VK_DESCRIPTOR_TYPE_STORAGE_TEXEL_BUFFER; info.type = UNIFORM_TYPE_IMAGE_BUFFER; need_array_dimensions = true; } break; case SPV_REFLECT_DESCRIPTOR_TYPE_UNIFORM_BUFFER: { - layout_binding.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; info.type = UNIFORM_TYPE_UNIFORM_BUFFER; need_block_size = true; } break; case SPV_REFLECT_DESCRIPTOR_TYPE_STORAGE_BUFFER: { - layout_binding.descriptorType = VK_DESCRIPTOR_TYPE_STORAGE_BUFFER; info.type = UNIFORM_TYPE_STORAGE_BUFFER; need_block_size = true; } break; @@ -4477,7 +4505,6 @@ RID RenderingDeviceVulkan::shader_create(const Vector<ShaderStageData> &p_stages continue; } break; case SPV_REFLECT_DESCRIPTOR_TYPE_INPUT_ATTACHMENT: { - layout_binding.descriptorType = VK_DESCRIPTOR_TYPE_INPUT_ATTACHMENT; info.type = UNIFORM_TYPE_INPUT_ATTACHMENT; } break; case SPV_REFLECT_DESCRIPTOR_TYPE_ACCELERATION_STRUCTURE_KHR: { @@ -4499,42 +4526,35 @@ RID RenderingDeviceVulkan::shader_create(const Vector<ShaderStageData> &p_stages } } - layout_binding.descriptorCount = info.length; - } else if (need_block_size) { info.length = binding.block.size; - layout_binding.descriptorCount = 1; } else { info.length = 0; - layout_binding.descriptorCount = 1; } info.binding = binding.binding; uint32_t set = binding.set; - //print_line("Stage: " + String(shader_stage_names[stage]) + " set=" + itos(set) + " binding=" + itos(info.binding) + " type=" + shader_uniform_names[info.type] + " length=" + itos(info.length)); - - ERR_FAIL_COND_V_MSG(set >= MAX_UNIFORM_SETS, RID(), + ERR_FAIL_COND_V_MSG(set >= MAX_UNIFORM_SETS, Vector<uint8_t>(), "On shader stage '" + String(shader_stage_names[stage]) + "', uniform '" + binding.name + "' uses a set (" + itos(set) + ") index larger than what is supported (" + itos(MAX_UNIFORM_SETS) + ")."); - ERR_FAIL_COND_V_MSG(set >= limits.maxBoundDescriptorSets, RID(), + ERR_FAIL_COND_V_MSG(set >= limits.maxBoundDescriptorSets, Vector<uint8_t>(), "On shader stage '" + String(shader_stage_names[stage]) + "', uniform '" + binding.name + "' uses a set (" + itos(set) + ") index larger than what is supported by the hardware (" + itos(limits.maxBoundDescriptorSets) + ")."); - if (set < (uint32_t)set_bindings.size()) { + if (set < (uint32_t)uniform_info.size()) { //check if this already exists bool exists = false; - for (int k = 0; k < set_bindings[set].size(); k++) { - if (set_bindings[set][k].binding == (uint32_t)info.binding) { + for (int k = 0; k < uniform_info[set].size(); k++) { + if (uniform_info[set][k].binding == (uint32_t)info.binding) { //already exists, verify that it's the same type - ERR_FAIL_COND_V_MSG(set_bindings[set][k].descriptorType != layout_binding.descriptorType, RID(), + ERR_FAIL_COND_V_MSG(uniform_info[set][k].type != info.type, Vector<uint8_t>(), "On shader stage '" + String(shader_stage_names[stage]) + "', uniform '" + binding.name + "' trying to re-use location for set=" + itos(set) + ", binding=" + itos(info.binding) + " with different uniform type."); //also, verify that it's the same size - ERR_FAIL_COND_V_MSG(set_bindings[set][k].descriptorCount != layout_binding.descriptorCount || uniform_info[set][k].length != info.length, RID(), + ERR_FAIL_COND_V_MSG(uniform_info[set][k].length != info.length, Vector<uint8_t>(), "On shader stage '" + String(shader_stage_names[stage]) + "', uniform '" + binding.name + "' trying to re-use location for set=" + itos(set) + ", binding=" + itos(info.binding) + " with different uniform size."); //just append stage mask and return - set_bindings.write[set].write[k].stageFlags |= shader_stage_masks[stage]; uniform_info.write[set].write[k].stages |= 1 << stage; exists = true; } @@ -4545,19 +4565,12 @@ RID RenderingDeviceVulkan::shader_create(const Vector<ShaderStageData> &p_stages } } - layout_binding.binding = info.binding; - layout_binding.stageFlags = shader_stage_masks[stage]; - layout_binding.pImmutableSamplers = nullptr; //no support for this yet - info.stages = 1 << stage; - info.binding = info.binding; - if (set >= (uint32_t)set_bindings.size()) { - set_bindings.resize(set + 1); + if (set >= (uint32_t)uniform_info.size()) { uniform_info.resize(set + 1); } - set_bindings.write[set].push_back(layout_binding); uniform_info.write[set].push_back(info); } } @@ -4567,43 +4580,41 @@ RID RenderingDeviceVulkan::shader_create(const Vector<ShaderStageData> &p_stages uint32_t sc_count = 0; result = spvReflectEnumerateSpecializationConstants(&module, &sc_count, nullptr); - ERR_FAIL_COND_V_MSG(result != SPV_REFLECT_RESULT_SUCCESS, RID(), - "Reflection of SPIR-V shader stage '" + String(shader_stage_names[p_stages[i].shader_stage]) + "' failed enumerating specialization constants."); + ERR_FAIL_COND_V_MSG(result != SPV_REFLECT_RESULT_SUCCESS, Vector<uint8_t>(), + "Reflection of SPIR-V shader stage '" + String(shader_stage_names[p_spirv[i].shader_stage]) + "' failed enumerating specialization constants."); if (sc_count) { Vector<SpvReflectSpecializationConstant *> spec_constants; spec_constants.resize(sc_count); result = spvReflectEnumerateSpecializationConstants(&module, &sc_count, spec_constants.ptrw()); - ERR_FAIL_COND_V_MSG(result != SPV_REFLECT_RESULT_SUCCESS, RID(), - "Reflection of SPIR-V shader stage '" + String(shader_stage_names[p_stages[i].shader_stage]) + "' failed obtaining specialization constants."); + ERR_FAIL_COND_V_MSG(result != SPV_REFLECT_RESULT_SUCCESS, Vector<uint8_t>(), + "Reflection of SPIR-V shader stage '" + String(shader_stage_names[p_spirv[i].shader_stage]) + "' failed obtaining specialization constants."); for (uint32_t j = 0; j < sc_count; j++) { int32_t existing = -1; - Shader::SpecializationConstant sconst; - sconst.constant.constant_id = spec_constants[j]->constant_id; + RenderingDeviceVulkanShaderBinarySpecializationConstant sconst; + sconst.constant_id = spec_constants[j]->constant_id; switch (spec_constants[j]->constant_type) { case SPV_REFLECT_SPECIALIZATION_CONSTANT_BOOL: { - sconst.constant.type = PIPELINE_SPECIALIZATION_CONSTANT_TYPE_BOOL; - sconst.constant.bool_value = spec_constants[j]->default_value.int_bool_value != 0; + sconst.type = PIPELINE_SPECIALIZATION_CONSTANT_TYPE_BOOL; + sconst.bool_value = spec_constants[j]->default_value.int_bool_value != 0; } break; case SPV_REFLECT_SPECIALIZATION_CONSTANT_INT: { - sconst.constant.type = PIPELINE_SPECIALIZATION_CONSTANT_TYPE_INT; - sconst.constant.int_value = spec_constants[j]->default_value.int_bool_value; + sconst.type = PIPELINE_SPECIALIZATION_CONSTANT_TYPE_INT; + sconst.int_value = spec_constants[j]->default_value.int_bool_value; } break; case SPV_REFLECT_SPECIALIZATION_CONSTANT_FLOAT: { - sconst.constant.type = PIPELINE_SPECIALIZATION_CONSTANT_TYPE_FLOAT; - sconst.constant.float_value = spec_constants[j]->default_value.float_value; + sconst.type = PIPELINE_SPECIALIZATION_CONSTANT_TYPE_FLOAT; + sconst.float_value = spec_constants[j]->default_value.float_value; } break; } - sconst.stage_flags = 1 << p_stages[i].shader_stage; - - print_line("spec constant " + itos(i) + ": " + String(spec_constants[j]->name) + " type " + itos(spec_constants[j]->constant_type) + " id " + itos(spec_constants[j]->constant_id)); + sconst.stage_flags = 1 << p_spirv[i].shader_stage; for (int k = 0; k < specialization_constants.size(); k++) { - if (specialization_constants[k].constant.constant_id == sconst.constant.constant_id) { - ERR_FAIL_COND_V_MSG(specialization_constants[k].constant.type != sconst.constant.type, RID(), "More than one specialization constant used for id (" + itos(sconst.constant.constant_id) + "), but their types differ."); - ERR_FAIL_COND_V_MSG(specialization_constants[k].constant.int_value != sconst.constant.int_value, RID(), "More than one specialization constant used for id (" + itos(sconst.constant.constant_id) + "), but their default values differ."); + if (specialization_constants[k].constant_id == sconst.constant_id) { + ERR_FAIL_COND_V_MSG(specialization_constants[k].type != sconst.type, Vector<uint8_t>(), "More than one specialization constant used for id (" + itos(sconst.constant_id) + "), but their types differ."); + ERR_FAIL_COND_V_MSG(specialization_constants[k].int_value != sconst.int_value, Vector<uint8_t>(), "More than one specialization constant used for id (" + itos(sconst.constant_id) + "), but their default values differ."); existing = k; break; } @@ -4621,20 +4632,20 @@ RID RenderingDeviceVulkan::shader_create(const Vector<ShaderStageData> &p_stages if (stage == SHADER_STAGE_VERTEX) { uint32_t iv_count = 0; result = spvReflectEnumerateInputVariables(&module, &iv_count, nullptr); - ERR_FAIL_COND_V_MSG(result != SPV_REFLECT_RESULT_SUCCESS, RID(), - "Reflection of SPIR-V shader stage '" + String(shader_stage_names[p_stages[i].shader_stage]) + "' failed enumerating input variables."); + ERR_FAIL_COND_V_MSG(result != SPV_REFLECT_RESULT_SUCCESS, Vector<uint8_t>(), + "Reflection of SPIR-V shader stage '" + String(shader_stage_names[p_spirv[i].shader_stage]) + "' failed enumerating input variables."); if (iv_count) { Vector<SpvReflectInterfaceVariable *> input_vars; input_vars.resize(iv_count); result = spvReflectEnumerateInputVariables(&module, &iv_count, input_vars.ptrw()); - ERR_FAIL_COND_V_MSG(result != SPV_REFLECT_RESULT_SUCCESS, RID(), - "Reflection of SPIR-V shader stage '" + String(shader_stage_names[p_stages[i].shader_stage]) + "' failed obtaining input variables."); + ERR_FAIL_COND_V_MSG(result != SPV_REFLECT_RESULT_SUCCESS, Vector<uint8_t>(), + "Reflection of SPIR-V shader stage '" + String(shader_stage_names[p_spirv[i].shader_stage]) + "' failed obtaining input variables."); for (uint32_t j = 0; j < iv_count; j++) { if (input_vars[j] && input_vars[j]->decoration_flags == 0) { //regular input - vertex_input_mask |= (1 << uint32_t(input_vars[j]->location)); + binary_data.vertex_input_mask |= (1 << uint32_t(input_vars[j]->location)); } } } @@ -4643,21 +4654,21 @@ RID RenderingDeviceVulkan::shader_create(const Vector<ShaderStageData> &p_stages if (stage == SHADER_STAGE_FRAGMENT) { uint32_t ov_count = 0; result = spvReflectEnumerateOutputVariables(&module, &ov_count, nullptr); - ERR_FAIL_COND_V_MSG(result != SPV_REFLECT_RESULT_SUCCESS, RID(), - "Reflection of SPIR-V shader stage '" + String(shader_stage_names[p_stages[i].shader_stage]) + "' failed enumerating output variables."); + ERR_FAIL_COND_V_MSG(result != SPV_REFLECT_RESULT_SUCCESS, Vector<uint8_t>(), + "Reflection of SPIR-V shader stage '" + String(shader_stage_names[p_spirv[i].shader_stage]) + "' failed enumerating output variables."); if (ov_count) { Vector<SpvReflectInterfaceVariable *> output_vars; output_vars.resize(ov_count); result = spvReflectEnumerateOutputVariables(&module, &ov_count, output_vars.ptrw()); - ERR_FAIL_COND_V_MSG(result != SPV_REFLECT_RESULT_SUCCESS, RID(), - "Reflection of SPIR-V shader stage '" + String(shader_stage_names[p_stages[i].shader_stage]) + "' failed obtaining output variables."); + ERR_FAIL_COND_V_MSG(result != SPV_REFLECT_RESULT_SUCCESS, Vector<uint8_t>(), + "Reflection of SPIR-V shader stage '" + String(shader_stage_names[p_spirv[i].shader_stage]) + "' failed obtaining output variables."); for (uint32_t j = 0; j < ov_count; j++) { const SpvReflectInterfaceVariable *refvar = output_vars[j]; if (refvar != nullptr && refvar->built_in != SpvBuiltInFragDepth) { - fragment_outputs |= 1 << refvar->location; + binary_data.fragment_outputs |= 1 << refvar->location; } } } @@ -4665,18 +4676,18 @@ RID RenderingDeviceVulkan::shader_create(const Vector<ShaderStageData> &p_stages uint32_t pc_count = 0; result = spvReflectEnumeratePushConstantBlocks(&module, &pc_count, nullptr); - ERR_FAIL_COND_V_MSG(result != SPV_REFLECT_RESULT_SUCCESS, RID(), - "Reflection of SPIR-V shader stage '" + String(shader_stage_names[p_stages[i].shader_stage]) + "' failed enumerating push constants."); + ERR_FAIL_COND_V_MSG(result != SPV_REFLECT_RESULT_SUCCESS, Vector<uint8_t>(), + "Reflection of SPIR-V shader stage '" + String(shader_stage_names[p_spirv[i].shader_stage]) + "' failed enumerating push constants."); if (pc_count) { - ERR_FAIL_COND_V_MSG(pc_count > 1, RID(), - "Reflection of SPIR-V shader stage '" + String(shader_stage_names[p_stages[i].shader_stage]) + "': Only one push constant is supported, which should be the same across shader stages."); + ERR_FAIL_COND_V_MSG(pc_count > 1, Vector<uint8_t>(), + "Reflection of SPIR-V shader stage '" + String(shader_stage_names[p_spirv[i].shader_stage]) + "': Only one push constant is supported, which should be the same across shader stages."); Vector<SpvReflectBlockVariable *> pconstants; pconstants.resize(pc_count); result = spvReflectEnumeratePushConstantBlocks(&module, &pc_count, pconstants.ptrw()); - ERR_FAIL_COND_V_MSG(result != SPV_REFLECT_RESULT_SUCCESS, RID(), - "Reflection of SPIR-V shader stage '" + String(shader_stage_names[p_stages[i].shader_stage]) + "' failed obtaining push constants."); + ERR_FAIL_COND_V_MSG(result != SPV_REFLECT_RESULT_SUCCESS, Vector<uint8_t>(), + "Reflection of SPIR-V shader stage '" + String(shader_stage_names[p_spirv[i].shader_stage]) + "' failed obtaining push constants."); #if 0 if (pconstants[0] == nullptr) { FileAccess *f = FileAccess::open("res://popo.spv", FileAccess::WRITE); @@ -4685,11 +4696,11 @@ RID RenderingDeviceVulkan::shader_create(const Vector<ShaderStageData> &p_stages } #endif - ERR_FAIL_COND_V_MSG(push_constant.push_constant_size && push_constant.push_constant_size != pconstants[0]->size, RID(), - "Reflection of SPIR-V shader stage '" + String(shader_stage_names[p_stages[i].shader_stage]) + "': Push constant block must be the same across shader stages."); + ERR_FAIL_COND_V_MSG(binary_data.push_constant_size && binary_data.push_constant_size != pconstants[0]->size, Vector<uint8_t>(), + "Reflection of SPIR-V shader stage '" + String(shader_stage_names[p_spirv[i].shader_stage]) + "': Push constant block must be the same across shader stages."); - push_constant.push_constant_size = pconstants[0]->size; - push_constant.push_constants_vk_stage |= shader_stage_masks[stage]; + binary_data.push_constant_size = pconstants[0]->size; + binary_data.push_constants_vk_stage |= shader_stage_masks[stage]; //print_line("Stage: " + String(shader_stage_names[stage]) + " push constant of size=" + itos(push_constant.push_constant_size)); } @@ -4698,9 +4709,291 @@ RID RenderingDeviceVulkan::shader_create(const Vector<ShaderStageData> &p_stages spvReflectDestroyShaderModule(&module); } - stages_processed |= (1 << p_stages[i].shader_stage); + stages_processed |= (1 << p_spirv[i].shader_stage); + } + + Vector<Vector<uint8_t>> compressed_stages; + Vector<uint32_t> smolv_size; + Vector<uint32_t> zstd_size; //if 0, stdno t used + + uint32_t stages_binary_size = 0; + + bool strip_debug = false; + + for (int i = 0; i < p_spirv.size(); i++) { + smolv::ByteArray smolv; + if (!smolv::Encode(p_spirv[i].spir_v.ptr(), p_spirv[i].spir_v.size(), smolv, strip_debug ? smolv::kEncodeFlagStripDebugInfo : 0)) { + ERR_FAIL_V_MSG(Vector<uint8_t>(), "Error compressing shader stage :" + String(shader_stage_names[p_spirv[i].shader_stage])); + } else { + smolv_size.push_back(smolv.size()); + { //zstd + Vector<uint8_t> zstd; + zstd.resize(Compression::get_max_compressed_buffer_size(smolv.size(), Compression::MODE_ZSTD)); + int dst_size = Compression::compress(zstd.ptrw(), &smolv[0], smolv.size(), Compression::MODE_ZSTD); + + if (dst_size > 0 && (uint32_t)dst_size < smolv.size()) { + zstd_size.push_back(dst_size); + zstd.resize(dst_size); + compressed_stages.push_back(zstd); + } else { + Vector<uint8_t> smv; + smv.resize(smolv.size()); + memcpy(smv.ptrw(), &smolv[0], smolv.size()); + zstd_size.push_back(0); //not using zstd + compressed_stages.push_back(smv); + } + } + } + uint32_t s = compressed_stages[i].size(); + if (s % 4 != 0) { + s += 4 - (s % 4); + } + stages_binary_size += s; + } + + binary_data.specialization_constant_count = specialization_constants.size(); + binary_data.set_count = uniform_info.size(); + binary_data.stage_count = p_spirv.size(); + + uint32_t total_size = sizeof(uint32_t) * 3; //header + version + main datasize; + total_size += sizeof(RenderingDeviceVulkanShaderBinaryData); + + for (int i = 0; i < uniform_info.size(); i++) { + total_size += sizeof(uint32_t); + total_size += uniform_info[i].size() * sizeof(RenderingDeviceVulkanShaderBinaryDataBinding); + } + + total_size += sizeof(RenderingDeviceVulkanShaderBinarySpecializationConstant) * specialization_constants.size(); + + total_size += compressed_stages.size() * sizeof(uint32_t) * 3; //sizes + total_size += stages_binary_size; + + Vector<uint8_t> ret; + ret.resize(total_size); + uint32_t offset = 0; + { + uint8_t *binptr = ret.ptrw(); + binptr[0] = 'G'; + binptr[1] = 'V'; + binptr[2] = 'B'; + binptr[3] = 'D'; //godot vulkan binary data + offset += 4; + encode_uint32(SHADER_BINARY_VERSION, binptr + offset); + offset += sizeof(uint32_t); + encode_uint32(sizeof(RenderingDeviceVulkanShaderBinaryData), binptr + offset); + offset += sizeof(uint32_t); + memcpy(binptr + offset, &binary_data, sizeof(RenderingDeviceVulkanShaderBinaryData)); + offset += sizeof(RenderingDeviceVulkanShaderBinaryData); + + for (int i = 0; i < uniform_info.size(); i++) { + int count = uniform_info[i].size(); + encode_uint32(count, binptr + offset); + offset += sizeof(uint32_t); + if (count > 0) { + memcpy(binptr + offset, uniform_info[i].ptr(), sizeof(RenderingDeviceVulkanShaderBinaryDataBinding) * count); + offset += sizeof(RenderingDeviceVulkanShaderBinaryDataBinding) * count; + } + } + + if (specialization_constants.size()) { + memcpy(binptr + offset, specialization_constants.ptr(), sizeof(RenderingDeviceVulkanShaderBinarySpecializationConstant) * specialization_constants.size()); + offset += sizeof(RenderingDeviceVulkanShaderBinarySpecializationConstant) * specialization_constants.size(); + } + + for (int i = 0; i < compressed_stages.size(); i++) { + encode_uint32(p_spirv[i].shader_stage, binptr + offset); + offset += sizeof(uint32_t); + encode_uint32(smolv_size[i], binptr + offset); + offset += sizeof(uint32_t); + encode_uint32(zstd_size[i], binptr + offset); + offset += sizeof(uint32_t); + memcpy(binptr + offset, compressed_stages[i].ptr(), compressed_stages[i].size()); + + uint32_t s = compressed_stages[i].size(); + + if (s % 4 != 0) { + s += 4 - (s % 4); + } + + offset += s; + } + + ERR_FAIL_COND_V(offset != (uint32_t)ret.size(), Vector<uint8_t>()); } + return ret; +} + +RID RenderingDeviceVulkan::shader_create_from_bytecode(const Vector<uint8_t> &p_shader_binary) { + const uint8_t *binptr = p_shader_binary.ptr(); + uint32_t binsize = p_shader_binary.size(); + + uint32_t read_offset = 0; + //consistency check + ERR_FAIL_COND_V(binsize < sizeof(uint32_t) * 3 + sizeof(RenderingDeviceVulkanShaderBinaryData), RID()); + ERR_FAIL_COND_V(binptr[0] != 'G' || binptr[1] != 'V' || binptr[2] != 'B' || binptr[3] != 'D', RID()); + + uint32_t bin_version = decode_uint32(binptr + 4); + ERR_FAIL_COND_V(bin_version > SHADER_BINARY_VERSION, RID()); + + uint32_t bin_data_size = decode_uint32(binptr + 8); + + const RenderingDeviceVulkanShaderBinaryData &binary_data = *(const RenderingDeviceVulkanShaderBinaryData *)(binptr + 12); + + Shader::PushConstant push_constant; + push_constant.push_constant_size = binary_data.push_constant_size; + push_constant.push_constants_vk_stage = binary_data.push_constants_vk_stage; + + uint32_t vertex_input_mask = binary_data.vertex_input_mask; + + uint32_t fragment_outputs = binary_data.fragment_outputs; + + bool is_compute = binary_data.is_compute; + + uint32_t compute_local_size[3] = { binary_data.compute_local_size[0], binary_data.compute_local_size[1], binary_data.compute_local_size[2] }; + + read_offset += sizeof(uint32_t) * 3 + bin_data_size; + + Vector<Vector<VkDescriptorSetLayoutBinding>> set_bindings; + Vector<Vector<UniformInfo>> uniform_info; + + set_bindings.resize(binary_data.set_count); + uniform_info.resize(binary_data.set_count); + + for (uint32_t i = 0; i < binary_data.set_count; i++) { + ERR_FAIL_COND_V(read_offset + sizeof(uint32_t) >= binsize, RID()); + uint32_t set_count = decode_uint32(binptr + read_offset); + read_offset += sizeof(uint32_t); + const RenderingDeviceVulkanShaderBinaryDataBinding *set_ptr = (const RenderingDeviceVulkanShaderBinaryDataBinding *)(binptr + read_offset); + uint32_t set_size = set_count * sizeof(RenderingDeviceVulkanShaderBinaryDataBinding); + ERR_FAIL_COND_V(read_offset + set_size >= binsize, RID()); + + for (uint32_t j = 0; j < set_count; j++) { + UniformInfo info; + info.type = UniformType(set_ptr[j].type); + info.length = set_ptr[j].length; + info.binding = set_ptr[j].binding; + info.stages = set_ptr[j].stages; + + VkDescriptorSetLayoutBinding layout_binding; + layout_binding.pImmutableSamplers = nullptr; + layout_binding.binding = set_ptr[j].binding; + layout_binding.descriptorCount = 1; + layout_binding.stageFlags = 0; + for (uint32_t k = 0; k < SHADER_STAGE_MAX; k++) { + if (set_ptr[j].stages & (1 << k)) { + layout_binding.stageFlags |= shader_stage_masks[k]; + } + } + + switch (info.type) { + case UNIFORM_TYPE_SAMPLER: { + layout_binding.descriptorType = VK_DESCRIPTOR_TYPE_SAMPLER; + layout_binding.descriptorCount = set_ptr[j].length; + } break; + case UNIFORM_TYPE_SAMPLER_WITH_TEXTURE: { + layout_binding.descriptorType = VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER; + layout_binding.descriptorCount = set_ptr[j].length; + } break; + case UNIFORM_TYPE_TEXTURE: { + layout_binding.descriptorType = VK_DESCRIPTOR_TYPE_SAMPLED_IMAGE; + layout_binding.descriptorCount = set_ptr[j].length; + } break; + case UNIFORM_TYPE_IMAGE: { + layout_binding.descriptorType = VK_DESCRIPTOR_TYPE_STORAGE_IMAGE; + layout_binding.descriptorCount = set_ptr[j].length; + } break; + case UNIFORM_TYPE_TEXTURE_BUFFER: { + layout_binding.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_TEXEL_BUFFER; + layout_binding.descriptorCount = set_ptr[j].length; + } break; + case UNIFORM_TYPE_IMAGE_BUFFER: { + layout_binding.descriptorType = VK_DESCRIPTOR_TYPE_STORAGE_TEXEL_BUFFER; + } break; + case UNIFORM_TYPE_UNIFORM_BUFFER: { + layout_binding.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; + } break; + case UNIFORM_TYPE_STORAGE_BUFFER: { + layout_binding.descriptorType = VK_DESCRIPTOR_TYPE_STORAGE_BUFFER; + } break; + case UNIFORM_TYPE_INPUT_ATTACHMENT: { + layout_binding.descriptorType = VK_DESCRIPTOR_TYPE_INPUT_ATTACHMENT; + } break; + default: { + ERR_FAIL_V(RID()); + } + } + + set_bindings.write[i].push_back(layout_binding); + uniform_info.write[i].push_back(info); + } + + read_offset += set_size; + } + + ERR_FAIL_COND_V(read_offset + binary_data.specialization_constant_count * sizeof(RenderingDeviceVulkanShaderBinarySpecializationConstant) >= binsize, RID()); + + Vector<Shader::SpecializationConstant> specialization_constants; + + for (uint32_t i = 0; i < binary_data.specialization_constant_count; i++) { + const RenderingDeviceVulkanShaderBinarySpecializationConstant &src_sc = *(const RenderingDeviceVulkanShaderBinarySpecializationConstant *)(binptr + read_offset); + Shader::SpecializationConstant sc; + sc.constant.int_value = src_sc.int_value; + sc.constant.type = PipelineSpecializationConstantType(src_sc.type); + sc.constant.constant_id = src_sc.constant_id; + sc.stage_flags = src_sc.stage_flags; + specialization_constants.push_back(sc); + + read_offset += sizeof(RenderingDeviceVulkanShaderBinarySpecializationConstant); + } + + Vector<Vector<uint8_t>> stage_spirv_data; + Vector<ShaderStage> stage_type; + + for (uint32_t i = 0; i < binary_data.stage_count; i++) { + ERR_FAIL_COND_V(read_offset + sizeof(uint32_t) * 3 >= binsize, RID()); + uint32_t stage = decode_uint32(binptr + read_offset); + read_offset += sizeof(uint32_t); + uint32_t smolv_size = decode_uint32(binptr + read_offset); + read_offset += sizeof(uint32_t); + uint32_t zstd_size = decode_uint32(binptr + read_offset); + read_offset += sizeof(uint32_t); + + uint32_t buf_size = (zstd_size > 0) ? zstd_size : smolv_size; + + Vector<uint8_t> smolv; + const uint8_t *src_smolv = nullptr; + + if (zstd_size > 0) { + //decompress to smolv + smolv.resize(smolv_size); + int dec_smolv_size = Compression::decompress(smolv.ptrw(), smolv.size(), binptr + read_offset, zstd_size, Compression::MODE_ZSTD); + ERR_FAIL_COND_V(dec_smolv_size != (int32_t)smolv_size, RID()); + src_smolv = smolv.ptr(); + } else { + src_smolv = binptr + read_offset; + } + + Vector<uint8_t> spirv; + uint32_t spirv_size = smolv::GetDecodedBufferSize(src_smolv, smolv_size); + spirv.resize(spirv_size); + if (!smolv::Decode(src_smolv, smolv_size, spirv.ptrw(), spirv_size)) { + ERR_FAIL_V_MSG(RID(), "Malformed smolv input uncompressing shader stage:" + String(shader_stage_names[stage])); + } + stage_spirv_data.push_back(spirv); + stage_type.push_back(ShaderStage(stage)); + + if (buf_size % 4 != 0) { + buf_size += 4 - (buf_size % 4); + } + + ERR_FAIL_COND_V(read_offset + buf_size > binsize, RID()); + + read_offset += buf_size; + } + + ERR_FAIL_COND_V(read_offset != binsize, RID()); + //all good, let's create modules _THREAD_SAFE_METHOD_ @@ -4719,13 +5012,13 @@ RID RenderingDeviceVulkan::shader_create(const Vector<ShaderStageData> &p_stages String error_text; bool success = true; - for (int i = 0; i < p_stages.size(); i++) { + for (int i = 0; i < stage_spirv_data.size(); i++) { VkShaderModuleCreateInfo shader_module_create_info; shader_module_create_info.sType = VK_STRUCTURE_TYPE_SHADER_MODULE_CREATE_INFO; shader_module_create_info.pNext = nullptr; shader_module_create_info.flags = 0; - shader_module_create_info.codeSize = p_stages[i].spir_v.size(); - const uint8_t *r = p_stages[i].spir_v.ptr(); + shader_module_create_info.codeSize = stage_spirv_data[i].size(); + const uint8_t *r = stage_spirv_data[i].ptr(); shader_module_create_info.pCode = (const uint32_t *)r; @@ -4733,7 +5026,7 @@ RID RenderingDeviceVulkan::shader_create(const Vector<ShaderStageData> &p_stages VkResult res = vkCreateShaderModule(device, &shader_module_create_info, nullptr, &module); if (res) { success = false; - error_text = "Error (" + itos(res) + ") creating shader module for stage: " + String(shader_stage_names[p_stages[i].shader_stage]); + error_text = "Error (" + itos(res) + ") creating shader module for stage: " + String(shader_stage_names[stage_type[i]]); break; } @@ -4749,7 +5042,7 @@ RID RenderingDeviceVulkan::shader_create(const Vector<ShaderStageData> &p_stages shader_stage.sType = VK_STRUCTURE_TYPE_PIPELINE_SHADER_STAGE_CREATE_INFO; shader_stage.pNext = nullptr; shader_stage.flags = 0; - shader_stage.stage = shader_stage_bits[p_stages[i].shader_stage]; + shader_stage.stage = shader_stage_bits[stage_type[i]]; shader_stage.module = module; shader_stage.pName = "main"; shader_stage.pSpecializationInfo = nullptr; @@ -5810,7 +6103,7 @@ RID RenderingDeviceVulkan::render_pipeline_create(RID p_shader, FramebufferForma tessellation_create_info.sType = VK_STRUCTURE_TYPE_PIPELINE_TESSELLATION_STATE_CREATE_INFO; tessellation_create_info.pNext = nullptr; tessellation_create_info.flags = 0; - ERR_FAIL_COND_V(p_rasterization_state.patch_control_points < 1 || p_rasterization_state.patch_control_points > limits.maxTessellationPatchSize, RID()); + ERR_FAIL_COND_V(limits.maxTessellationPatchSize > 0 && (p_rasterization_state.patch_control_points < 1 || p_rasterization_state.patch_control_points > limits.maxTessellationPatchSize), RID()); tessellation_create_info.patchControlPoints = p_rasterization_state.patch_control_points; VkPipelineViewportStateCreateInfo viewport_state_create_info; @@ -6039,7 +6332,7 @@ RID RenderingDeviceVulkan::render_pipeline_create(RID p_shader, FramebufferForma specialization_info.resize(pipeline_stages.size()); specialization_map_entries.resize(pipeline_stages.size()); for (int i = 0; i < shader->specialization_constants.size(); i++) { - //see if overriden + //see if overridden const Shader::SpecializationConstant &sc = shader->specialization_constants[i]; data_ptr[i] = sc.constant.int_value; //just copy the 32 bits @@ -6047,7 +6340,7 @@ RID RenderingDeviceVulkan::render_pipeline_create(RID p_shader, FramebufferForma const PipelineSpecializationConstant &psc = p_specialization_constants[j]; if (psc.constant_id == sc.constant.constant_id) { ERR_FAIL_COND_V_MSG(psc.type != sc.constant.type, RID(), "Specialization constant provided for id (" + itos(sc.constant.constant_id) + ") is of the wrong type."); - data_ptr[i] = sc.constant.int_value; + data_ptr[i] = psc.int_value; break; } } @@ -6070,14 +6363,14 @@ RID RenderingDeviceVulkan::render_pipeline_create(RID p_shader, FramebufferForma } } - for (int k = 0; k < pipeline_stages.size(); k++) { - if (specialization_map_entries[k].size()) { - specialization_info.write[k].dataSize = specialization_constant_data.size() * sizeof(uint32_t); - specialization_info.write[k].pData = data_ptr; - specialization_info.write[k].mapEntryCount = specialization_map_entries[k].size(); - specialization_info.write[k].pMapEntries = specialization_map_entries[k].ptr(); + for (int i = 0; i < pipeline_stages.size(); i++) { + if (specialization_map_entries[i].size()) { + specialization_info.write[i].dataSize = specialization_constant_data.size() * sizeof(uint32_t); + specialization_info.write[i].pData = data_ptr; + specialization_info.write[i].mapEntryCount = specialization_map_entries[i].size(); + specialization_info.write[i].pMapEntries = specialization_map_entries[i].ptr(); - pipeline_stages.write[k].pSpecializationInfo = specialization_info.ptr(); + pipeline_stages.write[i].pSpecializationInfo = specialization_info.ptr() + i; } } } @@ -6183,7 +6476,7 @@ RID RenderingDeviceVulkan::compute_pipeline_create(RID p_shader, const Vector<Pi specialization_constant_data.resize(shader->specialization_constants.size()); uint32_t *data_ptr = specialization_constant_data.ptrw(); for (int i = 0; i < shader->specialization_constants.size(); i++) { - //see if overriden + //see if overridden const Shader::SpecializationConstant &sc = shader->specialization_constants[i]; data_ptr[i] = sc.constant.int_value; //just copy the 32 bits @@ -8544,8 +8837,8 @@ void RenderingDeviceVulkan::_free_rids(T &p_owner, const char *p_type) { } else { WARN_PRINT(vformat("%d RIDs of type \"%s\" were leaked.", owned.size(), p_type)); } - for (List<RID>::Element *E = owned.front(); E; E = E->next()) { - free(E->get()); + for (const RID &E : owned) { + free(E); } } } @@ -8766,13 +9059,13 @@ void RenderingDeviceVulkan::finalize() { List<RID>::Element *N = E->next(); if (texture_is_shared(E->get())) { free(E->get()); - owned.erase(E->get()); + owned.erase(E); } E = N; } //free non shared second, this will avoid an error trying to free unexisting textures due to dependencies. - for (List<RID>::Element *E = owned.front(); E; E = E->next()) { - free(E->get()); + for (const RID &E : owned) { + free(E); } } } diff --git a/drivers/vulkan/rendering_device_vulkan.h b/drivers/vulkan/rendering_device_vulkan.h index 8b95ff43b8..f9ff61310a 100644 --- a/drivers/vulkan/rendering_device_vulkan.h +++ b/drivers/vulkan/rendering_device_vulkan.h @@ -652,8 +652,8 @@ class RenderingDeviceVulkan : public RenderingDevice { // Basically, you can mix and match pools as you // like, but you'll run into fragmentation issues. // Because of this, the recommended approach is to - // create a a pool for every descriptor set type, - // as this prevents fragmentation. + // create a pool for every descriptor set type, as + // this prevents fragmentation. // // This is implemented here as a having a list of // pools (each can contain up to 64 sets) for each @@ -1083,7 +1083,11 @@ public: /**** SHADER ****/ /****************/ - virtual RID shader_create(const Vector<ShaderStageData> &p_stages); + virtual String shader_get_binary_cache_key() const; + virtual Vector<uint8_t> shader_compile_binary_from_spirv(const Vector<ShaderStageSPIRVData> &p_spirv); + + virtual RID shader_create_from_bytecode(const Vector<uint8_t> &p_shader_binary); + virtual uint32_t shader_get_vertex_input_attribute_mask(RID p_shader); /*****************/ diff --git a/drivers/vulkan/vulkan_context.cpp b/drivers/vulkan/vulkan_context.cpp index d35c519320..a9d0fb6fed 100644 --- a/drivers/vulkan/vulkan_context.cpp +++ b/drivers/vulkan/vulkan_context.cpp @@ -577,26 +577,22 @@ Error VulkanContext::_check_capabilities() { multiview_capabilities.max_view_count = multiviewProperties.maxMultiviewViewCount; multiview_capabilities.max_instance_count = multiviewProperties.maxMultiviewInstanceIndex; -#ifdef DEBUG_ENABLED - print_line("- Vulkan multiview supported:"); - print_line(" max view count: " + itos(multiview_capabilities.max_view_count)); - print_line(" max instances: " + itos(multiview_capabilities.max_instance_count)); + print_verbose("- Vulkan multiview supported:"); + print_verbose(" max view count: " + itos(multiview_capabilities.max_view_count)); + print_verbose(" max instances: " + itos(multiview_capabilities.max_instance_count)); } else { - print_line("- Vulkan multiview not supported"); -#endif + print_verbose("- Vulkan multiview not supported"); } -#ifdef DEBUG_ENABLED - print_line("- Vulkan subgroup:"); - print_line(" size: " + itos(subgroup_capabilities.size)); - print_line(" stages: " + subgroup_capabilities.supported_stages_desc()); - print_line(" supported ops: " + subgroup_capabilities.supported_operations_desc()); + print_verbose("- Vulkan subgroup:"); + print_verbose(" size: " + itos(subgroup_capabilities.size)); + print_verbose(" stages: " + subgroup_capabilities.supported_stages_desc()); + print_verbose(" supported ops: " + subgroup_capabilities.supported_operations_desc()); if (subgroup_capabilities.quadOperationsInAllStages) { - print_line(" quad operations in all stages"); + print_verbose(" quad operations in all stages"); } } else { - print_line("- Couldn't call vkGetPhysicalDeviceProperties2"); -#endif + print_verbose("- Couldn't call vkGetPhysicalDeviceProperties2"); } return OK; @@ -737,10 +733,11 @@ Error VulkanContext::_create_physical_device() { } vendor_names[] = { { 0x1002, "AMD" }, { 0x1010, "ImgTec" }, + { 0x106B, "Apple" }, { 0x10DE, "NVIDIA" }, { 0x13B5, "ARM" }, { 0x5143, "Qualcomm" }, - { 0x8086, "INTEL" }, + { 0x8086, "Intel" }, { 0, nullptr }, }; device_name = gpu_props.deviceName; @@ -757,9 +754,9 @@ Error VulkanContext::_create_physical_device() { vendor_idx++; } } -#ifdef DEBUG_ENABLED + print_line("Using Vulkan Device #" + itos(device_index) + ": " + device_vendor + " - " + device_name); -#endif + device_api_version = gpu_props.apiVersion; err = vkEnumerateDeviceExtensionProperties(gpu, nullptr, &device_extension_count, nullptr); diff --git a/drivers/windows/file_access_windows.cpp b/drivers/windows/file_access_windows.cpp index d6deda7b5d..f504bad60d 100644 --- a/drivers/windows/file_access_windows.cpp +++ b/drivers/windows/file_access_windows.cpp @@ -108,7 +108,7 @@ Error FileAccessWindows::_open(const String &p_path, int p_mode_flags) { } #endif - if (is_backup_save_enabled() && p_mode_flags & WRITE && !(p_mode_flags & READ)) { + if (is_backup_save_enabled() && p_mode_flags == WRITE) { save_path = path; path = path + ".tmp"; } diff --git a/editor/action_map_editor.cpp b/editor/action_map_editor.cpp index 1c3ba89cd3..9126e0512e 100644 --- a/editor/action_map_editor.cpp +++ b/editor/action_map_editor.cpp @@ -200,7 +200,7 @@ void InputEventConfigurationDialog::_tab_selected(int p_tab) { if (is_connected("window_input", signal_method)) { disconnect("window_input", signal_method); } - input_list_tree->call_deferred("ensure_cursor_is_visible"); + input_list_tree->call_deferred(SNAME("ensure_cursor_is_visible")); if (input_list_tree->get_selected() == nullptr) { // If nothing selected, scroll to top. input_list_tree->scroll_to_item(input_list_tree->get_root()); @@ -532,14 +532,14 @@ void InputEventConfigurationDialog::_notification(int p_what) { switch (p_what) { case NOTIFICATION_ENTER_TREE: case NOTIFICATION_THEME_CHANGED: { - input_list_search->set_right_icon(input_list_search->get_theme_icon("Search", "EditorIcons")); + input_list_search->set_right_icon(input_list_search->get_theme_icon(SNAME("Search"), SNAME("EditorIcons"))); - physical_key_checkbox->set_icon(get_theme_icon("KeyboardPhysical", "EditorIcons")); + physical_key_checkbox->set_icon(get_theme_icon(SNAME("KeyboardPhysical"), SNAME("EditorIcons"))); - icon_cache.keyboard = get_theme_icon("Keyboard", "EditorIcons"); - icon_cache.mouse = get_theme_icon("Mouse", "EditorIcons"); - icon_cache.joypad_button = get_theme_icon("JoyButton", "EditorIcons"); - icon_cache.joypad_axis = get_theme_icon("JoyAxis", "EditorIcons"); + icon_cache.keyboard = get_theme_icon(SNAME("Keyboard"), SNAME("EditorIcons")); + icon_cache.mouse = get_theme_icon(SNAME("Mouse"), SNAME("EditorIcons")); + icon_cache.joypad_button = get_theme_icon(SNAME("JoyButton"), SNAME("EditorIcons")); + icon_cache.joypad_axis = get_theme_icon(SNAME("JoyAxis"), SNAME("EditorIcons")); _update_input_list(); } break; @@ -581,7 +581,7 @@ void InputEventConfigurationDialog::set_allowed_input_types(int p_type_masks) { InputEventConfigurationDialog::InputEventConfigurationDialog() { allowed_input_types = INPUT_KEY | INPUT_MOUSE_BUTTON | INPUT_JOY_BUTTON | INPUT_JOY_MOTION; - set_title("Event Configuration"); + set_title(TTR("Event Configuration")); set_min_size(Size2i(550 * EDSCALE, 0)); // Min width VBoxContainer *main_vbox = memnew(VBoxContainer); @@ -595,7 +595,7 @@ InputEventConfigurationDialog::InputEventConfigurationDialog() { main_vbox->add_child(tab_container); CenterContainer *cc = memnew(CenterContainer); - cc->set_name("Listen for Input"); + cc->set_name(TTR("Listen for Input")); event_as_text = memnew(Label); event_as_text->set_align(Label::ALIGN_CENTER); cc->add_child(event_as_text); @@ -604,7 +604,7 @@ InputEventConfigurationDialog::InputEventConfigurationDialog() { // List of all input options to manually select from. VBoxContainer *manual_vbox = memnew(VBoxContainer); - manual_vbox->set_name("Manual Selection"); + manual_vbox->set_name(TTR("Manual Selection")); manual_vbox->set_v_size_flags(Control::SIZE_EXPAND_FILL); tab_container->add_child(manual_vbox); @@ -632,7 +632,7 @@ InputEventConfigurationDialog::InputEventConfigurationDialog() { Label *opts_label = memnew(Label); opts_label->set_theme_type_variation("HeaderSmall"); - opts_label->set_text("Additional Options"); + opts_label->set_text(TTR("Additional Options")); additional_options_container->add_child(opts_label); // Device Selection @@ -641,7 +641,7 @@ InputEventConfigurationDialog::InputEventConfigurationDialog() { Label *device_label = memnew(Label); device_label->set_theme_type_variation("HeaderSmall"); - device_label->set_text("Device:"); + device_label->set_text(TTR("Device:")); device_container->add_child(device_label); device_id_option = memnew(OptionButton); @@ -724,7 +724,7 @@ void ActionMapEditor::_event_config_confirmed() { } new_action["events"] = events; - emit_signal("action_edited", current_action_name, new_action); + emit_signal(SNAME("action_edited"), current_action_name, new_action); } void ActionMapEditor::_add_action_pressed() { @@ -738,7 +738,7 @@ void ActionMapEditor::_add_action(const String &p_name) { } add_edit->clear(); - emit_signal("action_added", p_name); + emit_signal(SNAME("action_added"), p_name); } void ActionMapEditor::_action_edited() { @@ -762,7 +762,7 @@ void ActionMapEditor::_action_edited() { return; } - emit_signal("action_renamed", old_name, new_name); + emit_signal(SNAME("action_renamed"), old_name, new_name); } else if (action_tree->get_selected_column() == 1) { // Deadzone Edited String name = ti->get_meta("__name"); @@ -771,7 +771,7 @@ void ActionMapEditor::_action_edited() { new_action["deadzone"] = ti->get_range(1); // Call deferred so that input can finish propagating through tree, allowing re-making of tree to occur. - call_deferred("emit_signal", "action_edited", name, new_action); + call_deferred(SNAME("emit_signal"), "action_edited", name, new_action); } } @@ -808,7 +808,7 @@ void ActionMapEditor::_tree_button_pressed(Object *p_item, int p_column, int p_i case ActionMapEditor::BUTTON_REMOVE_ACTION: { // Send removed action name String name = item->get_meta("__name"); - emit_signal("action_removed", name); + emit_signal(SNAME("action_removed"), name); } break; case ActionMapEditor::BUTTON_REMOVE_EVENT: { // Remove event and send updated action @@ -821,7 +821,7 @@ void ActionMapEditor::_tree_button_pressed(Object *p_item, int p_column, int p_i events.remove(event_index); action["events"] = events; - emit_signal("action_edited", action_name, action); + emit_signal(SNAME("action_edited"), action_name, action); } break; default: break; @@ -922,7 +922,7 @@ void ActionMapEditor::drop_data_fw(const Point2 &p_point, const Variant &p_data, // Change action order. String relative_to = target->get_meta("__name"); String action_name = selected->get_meta("__name"); - emit_signal("action_reordered", action_name, relative_to, drop_above); + emit_signal(SNAME("action_reordered"), action_name, relative_to, drop_above); } else if (d["input_type"] == "event") { // Change event order @@ -956,7 +956,7 @@ void ActionMapEditor::drop_data_fw(const Point2 &p_point, const Variant &p_data, } new_action["events"] = new_events; - emit_signal("action_edited", selected->get_parent()->get_meta("__name"), new_action); + emit_signal(SNAME("action_edited"), selected->get_parent()->get_meta("__name"), new_action); } } @@ -964,7 +964,7 @@ void ActionMapEditor::_notification(int p_what) { switch (p_what) { case NOTIFICATION_ENTER_TREE: case NOTIFICATION_THEME_CHANGED: { - action_list_search->set_right_icon(get_theme_icon("Search", "EditorIcons")); + action_list_search->set_right_icon(get_theme_icon(SNAME("Search"), SNAME("EditorIcons"))); } break; default: break; @@ -1038,11 +1038,11 @@ void ActionMapEditor::update_action_list(const Vector<ActionInfo> &p_action_info action_item->set_range(1, deadzone); // Third column - buttons - action_item->add_button(2, action_tree->get_theme_icon("Add", "EditorIcons"), BUTTON_ADD_EVENT, false, TTR("Add Event")); - action_item->add_button(2, action_tree->get_theme_icon("Remove", "EditorIcons"), BUTTON_REMOVE_ACTION, !action_info.editable, action_info.editable ? "Remove Action" : "Cannot Remove Action"); + action_item->add_button(2, action_tree->get_theme_icon(SNAME("Add"), SNAME("EditorIcons")), BUTTON_ADD_EVENT, false, TTR("Add Event")); + action_item->add_button(2, action_tree->get_theme_icon(SNAME("Remove"), SNAME("EditorIcons")), BUTTON_REMOVE_ACTION, !action_info.editable, action_info.editable ? TTR("Remove Action") : TTR("Cannot Remove Action")); - action_item->set_custom_bg_color(0, action_tree->get_theme_color("prop_subsection", "Editor")); - action_item->set_custom_bg_color(1, action_tree->get_theme_color("prop_subsection", "Editor")); + action_item->set_custom_bg_color(0, action_tree->get_theme_color(SNAME("prop_subsection"), SNAME("Editor"))); + action_item->set_custom_bg_color(1, action_tree->get_theme_color(SNAME("prop_subsection"), SNAME("Editor"))); for (int evnt_idx = 0; evnt_idx < events.size(); evnt_idx++) { Ref<InputEvent> event = events[evnt_idx]; @@ -1058,8 +1058,8 @@ void ActionMapEditor::update_action_list(const Vector<ActionInfo> &p_action_info event_item->set_meta("__index", evnt_idx); // Third Column - Buttons - event_item->add_button(2, action_tree->get_theme_icon("Edit", "EditorIcons"), BUTTON_EDIT_EVENT, false, TTR("Edit Event")); - event_item->add_button(2, action_tree->get_theme_icon("Remove", "EditorIcons"), BUTTON_REMOVE_EVENT, false, TTR("Remove Event")); + event_item->add_button(2, action_tree->get_theme_icon(SNAME("Edit"), SNAME("EditorIcons")), BUTTON_EDIT_EVENT, false, TTR("Edit Event")); + event_item->add_button(2, action_tree->get_theme_icon(SNAME("Remove"), SNAME("EditorIcons")), BUTTON_REMOVE_EVENT, false, TTR("Remove Event")); event_item->set_button_color(2, 0, Color(1, 1, 1, 0.75)); event_item->set_button_color(2, 1, Color(1, 1, 1, 0.75)); } diff --git a/editor/animation_bezier_editor.cpp b/editor/animation_bezier_editor.cpp index 63ffab6727..1e3140e202 100644 --- a/editor/animation_bezier_editor.cpp +++ b/editor/animation_bezier_editor.cpp @@ -217,19 +217,19 @@ void AnimationBezierTrackEdit::_draw_line_clipped(const Vector2 &p_from, const V void AnimationBezierTrackEdit::_notification(int p_what) { if (p_what == NOTIFICATION_THEME_CHANGED || p_what == NOTIFICATION_ENTER_TREE) { - bezier_icon = get_theme_icon("KeyBezierPoint", "EditorIcons"); - bezier_handle_icon = get_theme_icon("KeyBezierHandle", "EditorIcons"); - selected_icon = get_theme_icon("KeyBezierSelected", "EditorIcons"); + bezier_icon = get_theme_icon(SNAME("KeyBezierPoint"), SNAME("EditorIcons")); + bezier_handle_icon = get_theme_icon(SNAME("KeyBezierHandle"), SNAME("EditorIcons")); + selected_icon = get_theme_icon(SNAME("KeyBezierSelected"), SNAME("EditorIcons")); if (handle_mode_option->get_item_count() == 0) { - handle_mode_option->add_icon_item(get_theme_icon("BezierHandlesFree", "EditorIcons"), TTR("Free"), HANDLE_MODE_FREE); - handle_mode_option->add_icon_item(get_theme_icon("BezierHandlesBalanced", "EditorIcons"), TTR("Balanced"), HANDLE_MODE_BALANCED); - handle_mode_option->add_icon_item(get_theme_icon("BezierHandlesMirror", "EditorIcons"), TTR("Mirror"), HANDLE_MODE_MIRROR); + handle_mode_option->add_icon_item(get_theme_icon(SNAME("BezierHandlesFree"), SNAME("EditorIcons")), TTR("Free"), HANDLE_MODE_FREE); + handle_mode_option->add_icon_item(get_theme_icon(SNAME("BezierHandlesBalanced"), SNAME("EditorIcons")), TTR("Balanced"), HANDLE_MODE_BALANCED); + handle_mode_option->add_icon_item(get_theme_icon(SNAME("BezierHandlesMirror"), SNAME("EditorIcons")), TTR("Mirror"), HANDLE_MODE_MIRROR); } } if (p_what == NOTIFICATION_RESIZED) { int right_limit = get_size().width - timeline->get_buttons_width(); - int hsep = get_theme_constant("hseparation", "ItemList"); - int vsep = get_theme_constant("vseparation", "ItemList"); + int hsep = get_theme_constant(SNAME("hseparation"), SNAME("ItemList")); + int vsep = get_theme_constant(SNAME("vseparation"), SNAME("ItemList")); handle_mode_option->set_position(Vector2(right_limit + hsep, get_size().height - handle_mode_option->get_combined_minimum_size().height - vsep)); handle_mode_option->set_size(Vector2(timeline->get_buttons_width() - hsep * 2, handle_mode_option->get_combined_minimum_size().height)); @@ -242,16 +242,16 @@ void AnimationBezierTrackEdit::_notification(int p_what) { int limit = timeline->get_name_limit(); if (has_focus()) { - Color accent = get_theme_color("accent_color", "Editor"); + Color accent = get_theme_color(SNAME("accent_color"), SNAME("Editor")); accent.a *= 0.7; draw_rect(Rect2(Point2(), get_size()), accent, false); } - Ref<Font> font = get_theme_font("font", "Label"); - int font_size = get_theme_font_size("font_size", "Label"); - Color color = get_theme_color("font_color", "Label"); - int hsep = get_theme_constant("hseparation", "ItemList"); - int vsep = get_theme_constant("vseparation", "ItemList"); + Ref<Font> font = get_theme_font(SNAME("font"), SNAME("Label")); + int font_size = get_theme_font_size(SNAME("font_size"), SNAME("Label")); + Color color = get_theme_color(SNAME("font_color"), SNAME("Label")); + int hsep = get_theme_constant(SNAME("hseparation"), SNAME("ItemList")); + int vsep = get_theme_constant(SNAME("vseparation"), SNAME("ItemList")); Color linecolor = color; linecolor.a = 0.2; @@ -261,7 +261,7 @@ void AnimationBezierTrackEdit::_notification(int p_what) { draw_line(Point2(right_limit, 0), Point2(right_limit, get_size().height), linecolor); - Ref<Texture2D> close_icon = get_theme_icon("Close", "EditorIcons"); + Ref<Texture2D> close_icon = get_theme_icon(SNAME("Close"), SNAME("EditorIcons")); close_icon_rect.position = Vector2(get_size().width - close_icon->get_width() - hsep, hsep); close_icon_rect.size = close_icon->get_size(); @@ -349,7 +349,7 @@ void AnimationBezierTrackEdit::_notification(int p_what) { subtracks[i] = rect; } else { - Color ac = get_theme_color("accent_color", "Editor"); + Color ac = get_theme_color(SNAME("accent_color"), SNAME("Editor")); ac.a = 0.5; draw_rect(rect, ac); } @@ -360,7 +360,7 @@ void AnimationBezierTrackEdit::_notification(int p_what) { vofs += text_buf.get_size().y + vsep; } - Color accent = get_theme_color("accent_color", "Editor"); + Color accent = get_theme_color(SNAME("accent_color"), SNAME("Editor")); { //guides float min_left_scale = font->get_height(font_size) + vsep; @@ -401,7 +401,7 @@ void AnimationBezierTrackEdit::_notification(int p_what) { { //draw OTHER curves float scale = timeline->get_zoom_scale(); - Ref<Texture2D> point = get_theme_icon("KeyValue", "EditorIcons"); + Ref<Texture2D> point = get_theme_icon(SNAME("KeyValue"), SNAME("EditorIcons")); for (Map<int, Color>::Element *E = subtrack_colors.front(); E; E = E->next()) { _draw_track(E->key(), E->get()); @@ -418,7 +418,7 @@ void AnimationBezierTrackEdit::_notification(int p_what) { } //draw edited curve - const Color highlight = get_theme_color("highlight_color", "Editor"); + const Color highlight = get_theme_color(SNAME("highlight_color"), SNAME("Editor")); _draw_track(track, highlight); } @@ -547,7 +547,7 @@ void AnimationBezierTrackEdit::_play_position_draw() { int px = (-timeline->get_value() + play_position_pos) * scale + timeline->get_name_limit(); if (px >= timeline->get_name_limit() && px < (get_size().width - timeline->get_buttons_width())) { - Color color = get_theme_color("accent_color", "Editor"); + Color color = get_theme_color(SNAME("accent_color"), SNAME("Editor")); play_position->draw_line(Point2(px, 0), Point2(px, h), color, Math::round(2 * EDSCALE)); } } @@ -576,7 +576,7 @@ String AnimationBezierTrackEdit::get_tooltip(const Point2 &p_pos) const { void AnimationBezierTrackEdit::_clear_selection() { selection.clear(); - emit_signal("clear_selection"); + emit_signal(SNAME("clear_selection")); update(); } @@ -597,7 +597,7 @@ void AnimationBezierTrackEdit::_select_at_anim(const Ref<Animation> &p_anim, int ERR_FAIL_COND(idx < 0); selection.insert(idx); - emit_signal("select_key", idx, true); + emit_signal(SNAME("select_key"), idx, true); update(); } @@ -663,9 +663,9 @@ void AnimationBezierTrackEdit::_gui_input(const Ref<InputEvent> &p_event) { menu->add_icon_item(bezier_icon, TTR("Insert Key Here"), MENU_KEY_INSERT); if (selection.size()) { menu->add_separator(); - menu->add_icon_item(get_theme_icon("Duplicate", "EditorIcons"), TTR("Duplicate Selected Key(s)"), MENU_KEY_DUPLICATE); + menu->add_icon_item(get_theme_icon(SNAME("Duplicate"), SNAME("EditorIcons")), TTR("Duplicate Selected Key(s)"), MENU_KEY_DUPLICATE); menu->add_separator(); - menu->add_icon_item(get_theme_icon("Remove", "EditorIcons"), TTR("Delete Selected Key(s)"), MENU_KEY_DELETE); + menu->add_icon_item(get_theme_icon(SNAME("Remove"), SNAME("EditorIcons")), TTR("Delete Selected Key(s)"), MENU_KEY_DELETE); } menu->set_as_minsize(); @@ -676,7 +676,7 @@ void AnimationBezierTrackEdit::_gui_input(const Ref<InputEvent> &p_event) { if (mb.is_valid() && mb->is_pressed() && mb->get_button_index() == MOUSE_BUTTON_LEFT) { if (close_icon_rect.has_point(mb->get_position())) { - emit_signal("close_request"); + emit_signal(SNAME("close_request")); return; } for (Map<int, Rect2>::Element *E = subtracks.front(); E; E = E->next()) { @@ -898,8 +898,7 @@ void AnimationBezierTrackEdit::_gui_input(const Ref<InputEvent> &p_event) { } // 6-(undo) reinsert overlapped keys - for (List<AnimMoveRestore>::Element *E = to_restore.front(); E; E = E->next()) { - AnimMoveRestore &amr = E->get(); + for (const AnimMoveRestore &amr : to_restore) { undo_redo->add_undo_method(animation.ptr(), "track_insert_key", amr.track, amr.time, amr.key, 1); } @@ -1091,9 +1090,9 @@ void AnimationBezierTrackEdit::duplicate_selection() { //reselect duplicated selection.clear(); - for (List<Pair<int, float>>::Element *E = new_selection_values.front(); E; E = E->next()) { - int track = E->get().first; - float time = E->get().second; + for (const Pair<int, float> &E : new_selection_values) { + int track = E.first; + float time = E.second; int existing_idx = animation->track_find_key(track, time, true); diff --git a/editor/animation_track_editor.cpp b/editor/animation_track_editor.cpp index 05945a8ae2..91835c1866 100644 --- a/editor/animation_track_editor.cpp +++ b/editor/animation_track_editor.cpp @@ -598,12 +598,12 @@ public: if (ap) { List<StringName> anims; ap->get_animation_list(&anims); - for (List<StringName>::Element *E = anims.front(); E; E = E->next()) { + for (const StringName &E : anims) { if (animations != String()) { animations += ","; } - animations += String(E->get()); + animations += String(E); } } } @@ -702,8 +702,8 @@ public: for (Map<int, List<float>>::Element *E = key_ofs_map.front(); E; E = E->next()) { int key = 0; - for (List<float>::Element *F = E->value().front(); F; F = F->next()) { - float key_ofs = F->get(); + for (float &F : E->value()) { + float key_ofs = F; if (from != key_ofs) { key++; continue; @@ -728,8 +728,8 @@ public: bool change_notify_deserved = false; for (Map<int, List<float>>::Element *E = key_ofs_map.front(); E; E = E->next()) { int track = E->key(); - for (List<float>::Element *F = E->value().front(); F; F = F->next()) { - float key_ofs = F->get(); + for (float &F : E->value()) { + float key_ofs = F; int key = animation->track_find_key(track, key_ofs, true); ERR_FAIL_COND_V(key == -1, false); @@ -986,8 +986,8 @@ public: bool _get(const StringName &p_name, Variant &r_ret) const { for (Map<int, List<float>>::Element *E = key_ofs_map.front(); E; E = E->next()) { int track = E->key(); - for (List<float>::Element *F = E->value().front(); F; F = F->next()) { - float key_ofs = F->get(); + for (float &F : E->value()) { + float key_ofs = F; int key = animation->track_find_key(track, key_ofs, true); ERR_CONTINUE(key == -1); @@ -1137,8 +1137,8 @@ public: same_key_type = false; } - for (List<float>::Element *F = E->value().front(); F; F = F->next()) { - int key = animation->track_find_key(track, F->get(), true); + for (float &F : E->value()) { + int key = animation->track_find_key(track, F, true); ERR_FAIL_COND(key == -1); if (first_key < 0) { first_key = key; @@ -1290,7 +1290,7 @@ public: void AnimationTimelineEdit::_zoom_changed(double) { update(); play_position->update(); - emit_signal("zoom_changed"); + emit_signal(SNAME("zoom_changed")); } float AnimationTimelineEdit::get_zoom_scale() const { @@ -1321,7 +1321,7 @@ void AnimationTimelineEdit::_anim_length_changed(double p_new_len) { editing = false; update(); - emit_signal("length_changed", p_new_len); + emit_signal(SNAME("length_changed"), p_new_len); } void AnimationTimelineEdit::_anim_loop_pressed() { @@ -1332,11 +1332,11 @@ void AnimationTimelineEdit::_anim_loop_pressed() { } int AnimationTimelineEdit::get_buttons_width() const { - Ref<Texture2D> interp_mode = get_theme_icon("TrackContinuous", "EditorIcons"); - Ref<Texture2D> interp_type = get_theme_icon("InterpRaw", "EditorIcons"); - Ref<Texture2D> loop_type = get_theme_icon("InterpWrapClamp", "EditorIcons"); - Ref<Texture2D> remove_icon = get_theme_icon("Remove", "EditorIcons"); - Ref<Texture2D> down_icon = get_theme_icon("select_arrow", "Tree"); + Ref<Texture2D> interp_mode = get_theme_icon(SNAME("TrackContinuous"), SNAME("EditorIcons")); + Ref<Texture2D> interp_type = get_theme_icon(SNAME("InterpRaw"), SNAME("EditorIcons")); + Ref<Texture2D> loop_type = get_theme_icon(SNAME("InterpWrapClamp"), SNAME("EditorIcons")); + Ref<Texture2D> remove_icon = get_theme_icon(SNAME("Remove"), SNAME("EditorIcons")); + Ref<Texture2D> down_icon = get_theme_icon(SNAME("select_arrow"), SNAME("Tree")); int total_w = interp_mode->get_width() + interp_type->get_width() + loop_type->get_width() + remove_icon->get_width(); total_w += (down_icon->get_width() + 4 * EDSCALE) * 4; @@ -1345,7 +1345,7 @@ int AnimationTimelineEdit::get_buttons_width() const { } int AnimationTimelineEdit::get_name_limit() const { - Ref<Texture2D> hsize_icon = get_theme_icon("Hsize", "EditorIcons"); + Ref<Texture2D> hsize_icon = get_theme_icon(SNAME("Hsize"), SNAME("EditorIcons")); int limit = MAX(name_limit, add_track->get_minimum_size().width + hsize_icon->get_width()); @@ -1356,17 +1356,17 @@ int AnimationTimelineEdit::get_name_limit() const { void AnimationTimelineEdit::_notification(int p_what) { if (p_what == NOTIFICATION_ENTER_TREE) { - add_track->set_icon(get_theme_icon("Add", "EditorIcons")); - loop->set_icon(get_theme_icon("Loop", "EditorIcons")); - time_icon->set_texture(get_theme_icon("Time", "EditorIcons")); + add_track->set_icon(get_theme_icon(SNAME("Add"), SNAME("EditorIcons"))); + loop->set_icon(get_theme_icon(SNAME("Loop"), SNAME("EditorIcons"))); + time_icon->set_texture(get_theme_icon(SNAME("Time"), SNAME("EditorIcons"))); add_track->get_popup()->clear(); - add_track->get_popup()->add_icon_item(get_theme_icon("KeyValue", "EditorIcons"), TTR("Property Track")); - add_track->get_popup()->add_icon_item(get_theme_icon("KeyXform", "EditorIcons"), TTR("3D Transform Track")); - add_track->get_popup()->add_icon_item(get_theme_icon("KeyCall", "EditorIcons"), TTR("Call Method Track")); - add_track->get_popup()->add_icon_item(get_theme_icon("KeyBezier", "EditorIcons"), TTR("Bezier Curve Track")); - add_track->get_popup()->add_icon_item(get_theme_icon("KeyAudio", "EditorIcons"), TTR("Audio Playback Track")); - add_track->get_popup()->add_icon_item(get_theme_icon("KeyAnimation", "EditorIcons"), TTR("Animation Playback Track")); + add_track->get_popup()->add_icon_item(get_theme_icon(SNAME("KeyValue"), SNAME("EditorIcons")), TTR("Property Track")); + add_track->get_popup()->add_icon_item(get_theme_icon(SNAME("KeyXform"), SNAME("EditorIcons")), TTR("3D Transform Track")); + add_track->get_popup()->add_icon_item(get_theme_icon(SNAME("KeyCall"), SNAME("EditorIcons")), TTR("Call Method Track")); + add_track->get_popup()->add_icon_item(get_theme_icon(SNAME("KeyBezier"), SNAME("EditorIcons")), TTR("Bezier Curve Track")); + add_track->get_popup()->add_icon_item(get_theme_icon(SNAME("KeyAudio"), SNAME("EditorIcons")), TTR("Audio Playback Track")); + add_track->get_popup()->add_icon_item(get_theme_icon(SNAME("KeyAnimation"), SNAME("EditorIcons")), TTR("Animation Playback Track")); } if (p_what == NOTIFICATION_RESIZED) { @@ -1381,9 +1381,9 @@ void AnimationTimelineEdit::_notification(int p_what) { return; } - Ref<Font> font = get_theme_font("font", "Label"); - int font_size = get_theme_font_size("font_size", "Label"); - Color color = get_theme_color("font_color", "Label"); + Ref<Font> font = get_theme_font(SNAME("font"), SNAME("Label")); + int font_size = get_theme_font_size(SNAME("font_size"), SNAME("Label")); + Color color = get_theme_color(SNAME("font_color"), SNAME("Label")); int zoomw = key_range; float scale = get_zoom_scale(); @@ -1394,7 +1394,7 @@ void AnimationTimelineEdit::_notification(int p_what) { l = 0.001; //avoid crashor } - Ref<Texture2D> hsize_icon = get_theme_icon("Hsize", "EditorIcons"); + Ref<Texture2D> hsize_icon = get_theme_icon(SNAME("Hsize"), SNAME("EditorIcons")); hsize_rect = Rect2(get_name_limit() - hsize_icon->get_width() - 2 * EDSCALE, (get_size().height - hsize_icon->get_height()) / 2, hsize_icon->get_width(), hsize_icon->get_height()); draw_texture(hsize_icon, hsize_rect.position); @@ -1443,7 +1443,7 @@ void AnimationTimelineEdit::_notification(int p_what) { int end_px = (l - get_value()) * scale; int begin_px = -get_value() * scale; - Color notimecol = get_theme_color("dark_color_2", "Editor"); + Color notimecol = get_theme_color(SNAME("dark_color_2"), SNAME("Editor")); Color timecolor = color; timecolor.a = 0.2; Color linecolor = color; @@ -1568,10 +1568,10 @@ void AnimationTimelineEdit::set_animation(const Ref<Animation> &p_animation) { Size2 AnimationTimelineEdit::get_minimum_size() const { Size2 ms = add_track->get_minimum_size(); - Ref<Font> font = get_theme_font("font", "Label"); - int font_size = get_theme_font_size("font_size", "Label"); + Ref<Font> font = get_theme_font(SNAME("font"), SNAME("Label")); + int font_size = get_theme_font_size(SNAME("font_size"), SNAME("Label")); ms.height = MAX(ms.height, font->get_height(font_size)); - ms.width = get_buttons_width() + add_track->get_minimum_size().width + get_theme_icon("Hsize", "EditorIcons")->get_width() + 2; + ms.width = get_buttons_width() + add_track->get_minimum_size().width + get_theme_icon(SNAME("Hsize"), SNAME("EditorIcons"))->get_width() + 2; return ms; } @@ -1633,11 +1633,11 @@ void AnimationTimelineEdit::_play_position_draw() { int px = (-get_value() + play_position_pos) * scale + get_name_limit(); if (px >= get_name_limit() && px < (play_position->get_size().width - get_buttons_width())) { - Color color = get_theme_color("accent_color", "Editor"); + Color color = get_theme_color(SNAME("accent_color"), SNAME("Editor")); play_position->draw_line(Point2(px, 0), Point2(px, h), color, Math::round(2 * EDSCALE)); play_position->draw_texture( - get_theme_icon("TimelineIndicator", "EditorIcons"), - Point2(px - get_theme_icon("TimelineIndicator", "EditorIcons")->get_width() * 0.5, 0), + get_theme_icon(SNAME("TimelineIndicator"), SNAME("EditorIcons")), + Point2(px - get_theme_icon(SNAME("TimelineIndicator"), SNAME("EditorIcons"))->get_width() * 0.5, 0), color); } } @@ -1685,7 +1685,7 @@ void AnimationTimelineEdit::_gui_input(const Ref<InputEvent> &p_event) { int x = mb->get_position().x - get_name_limit(); float ofs = x / get_zoom_scale() + get_value(); - emit_signal("timeline_changed", ofs, false, Input::get_singleton()->is_key_pressed(KEY_ALT)); + emit_signal(SNAME("timeline_changed"), ofs, false, Input::get_singleton()->is_key_pressed(KEY_ALT)); dragging_timeline = true; } if (!dragging_timeline && mb->get_button_index() == MOUSE_BUTTON_MIDDLE) { @@ -1718,13 +1718,13 @@ void AnimationTimelineEdit::_gui_input(const Ref<InputEvent> &p_event) { int ofs = mm->get_position().x - dragging_hsize_from; name_limit = dragging_hsize_at + ofs; update(); - emit_signal("name_limit_changed"); + emit_signal(SNAME("name_limit_changed")); play_position->update(); } if (dragging_timeline) { int x = mm->get_position().x - get_name_limit(); float ofs = x / get_zoom_scale() + get_value(); - emit_signal("timeline_changed", ofs, false, Input::get_singleton()->is_key_pressed(KEY_ALT)); + emit_signal(SNAME("timeline_changed"), ofs, false, Input::get_singleton()->is_key_pressed(KEY_ALT)); } if (panning_timeline) { int x = mm->get_position().x - get_name_limit(); @@ -1750,7 +1750,7 @@ void AnimationTimelineEdit::set_hscroll(HScrollBar *p_hscroll) { } void AnimationTimelineEdit::_track_added(int p_track) { - emit_signal("track_added", p_track); + emit_signal(SNAME("track_added"), p_track); } void AnimationTimelineEdit::_bind_methods() { @@ -1832,31 +1832,31 @@ void AnimationTrackEdit::_notification(int p_what) { int limit = timeline->get_name_limit(); if (has_focus()) { - Color accent = get_theme_color("accent_color", "Editor"); + Color accent = get_theme_color(SNAME("accent_color"), SNAME("Editor")); accent.a *= 0.7; // Offside so the horizontal sides aren't cutoff. draw_rect(Rect2(Point2(1 * EDSCALE, 0), get_size() - Size2(1 * EDSCALE, 0)), accent, false); } - Ref<Font> font = get_theme_font("font", "Label"); - int font_size = get_theme_font_size("font_size", "Label"); - Color color = get_theme_color("font_color", "Label"); + Ref<Font> font = get_theme_font(SNAME("font"), SNAME("Label")); + int font_size = get_theme_font_size(SNAME("font_size"), SNAME("Label")); + Color color = get_theme_color(SNAME("font_color"), SNAME("Label")); Ref<Texture2D> type_icons[6] = { - get_theme_icon("KeyValue", "EditorIcons"), - get_theme_icon("KeyXform", "EditorIcons"), - get_theme_icon("KeyCall", "EditorIcons"), - get_theme_icon("KeyBezier", "EditorIcons"), - get_theme_icon("KeyAudio", "EditorIcons"), - get_theme_icon("KeyAnimation", "EditorIcons") + get_theme_icon(SNAME("KeyValue"), SNAME("EditorIcons")), + get_theme_icon(SNAME("KeyXform"), SNAME("EditorIcons")), + get_theme_icon(SNAME("KeyCall"), SNAME("EditorIcons")), + get_theme_icon(SNAME("KeyBezier"), SNAME("EditorIcons")), + get_theme_icon(SNAME("KeyAudio"), SNAME("EditorIcons")), + get_theme_icon(SNAME("KeyAnimation"), SNAME("EditorIcons")) }; - int hsep = get_theme_constant("hseparation", "ItemList"); + int hsep = get_theme_constant(SNAME("hseparation"), SNAME("ItemList")); Color linecolor = color; linecolor.a = 0.2; // NAMES AND ICONS // { - Ref<Texture2D> check = animation->track_is_enabled(track) ? get_theme_icon("checked", "CheckBox") : get_theme_icon("unchecked", "CheckBox"); + Ref<Texture2D> check = animation->track_is_enabled(track) ? get_theme_icon(SNAME("checked"), SNAME("CheckBox")) : get_theme_icon(SNAME("unchecked"), SNAME("CheckBox")); int ofs = in_group ? check->get_width() : 0; //not the best reference for margin but.. @@ -1877,7 +1877,7 @@ void AnimationTrackEdit::_notification(int p_what) { String text; Color text_color = color; if (node && EditorNode::get_singleton()->get_editor_selection()->is_selected(node)) { - text_color = get_theme_color("accent_color", "Editor"); + text_color = get_theme_color(SNAME("accent_color"), SNAME("Editor")); } if (in_group) { @@ -1952,25 +1952,25 @@ void AnimationTrackEdit::_notification(int p_what) { { Ref<Texture2D> wrap_icon[2] = { - get_theme_icon("InterpWrapClamp", "EditorIcons"), - get_theme_icon("InterpWrapLoop", "EditorIcons"), + get_theme_icon(SNAME("InterpWrapClamp"), SNAME("EditorIcons")), + get_theme_icon(SNAME("InterpWrapLoop"), SNAME("EditorIcons")), }; Ref<Texture2D> interp_icon[3] = { - get_theme_icon("InterpRaw", "EditorIcons"), - get_theme_icon("InterpLinear", "EditorIcons"), - get_theme_icon("InterpCubic", "EditorIcons") + get_theme_icon(SNAME("InterpRaw"), SNAME("EditorIcons")), + get_theme_icon(SNAME("InterpLinear"), SNAME("EditorIcons")), + get_theme_icon(SNAME("InterpCubic"), SNAME("EditorIcons")) }; Ref<Texture2D> cont_icon[4] = { - get_theme_icon("TrackContinuous", "EditorIcons"), - get_theme_icon("TrackDiscrete", "EditorIcons"), - get_theme_icon("TrackTrigger", "EditorIcons"), - get_theme_icon("TrackCapture", "EditorIcons") + get_theme_icon(SNAME("TrackContinuous"), SNAME("EditorIcons")), + get_theme_icon(SNAME("TrackDiscrete"), SNAME("EditorIcons")), + get_theme_icon(SNAME("TrackTrigger"), SNAME("EditorIcons")), + get_theme_icon(SNAME("TrackCapture"), SNAME("EditorIcons")) }; int ofs = get_size().width - timeline->get_buttons_width(); - Ref<Texture2D> down_icon = get_theme_icon("select_arrow", "Tree"); + Ref<Texture2D> down_icon = get_theme_icon(SNAME("select_arrow"), SNAME("Tree")); draw_line(Point2(ofs, 0), Point2(ofs, get_size().height), linecolor, Math::round(EDSCALE)); @@ -2007,7 +2007,7 @@ void AnimationTrackEdit::_notification(int p_what) { update_mode_rect.size.x += down_icon->get_width(); bezier_edit_rect = Rect2(); } else if (animation->track_get_type(track) == Animation::TYPE_BEZIER) { - Ref<Texture2D> bezier_icon = get_theme_icon("EditBezier", "EditorIcons"); + Ref<Texture2D> bezier_icon = get_theme_icon(SNAME("EditBezier"), SNAME("EditorIcons")); update_mode_rect.size.x += down_icon->get_width(); bezier_edit_rect.position = update_mode_rect.position + (update_mode_rect.size - bezier_icon->get_size()) / 2; bezier_edit_rect.size = bezier_icon->get_size(); @@ -2092,7 +2092,7 @@ void AnimationTrackEdit::_notification(int p_what) { { //erase - Ref<Texture2D> icon = get_theme_icon("Remove", "EditorIcons"); + Ref<Texture2D> icon = get_theme_icon(SNAME("Remove"), SNAME("EditorIcons")); remove_rect.position.x = ofs + ((get_size().width - ofs) - icon->get_width()) / 2; remove_rect.position.y = int(get_size().height - icon->get_height()) / 2; @@ -2109,7 +2109,7 @@ void AnimationTrackEdit::_notification(int p_what) { } if (dropping_at != 0) { - Color drop_color = get_theme_color("accent_color", "Editor"); + Color drop_color = get_theme_color(SNAME("accent_color"), SNAME("Editor")); if (dropping_at < 0) { draw_line(Vector2(0, 0), Vector2(get_size().width, 0), drop_color, Math::round(EDSCALE)); } else { @@ -2161,7 +2161,7 @@ void AnimationTrackEdit::draw_key_link(int p_index, float p_pixels_sec, int p_x, return; } - Color color = get_theme_color("font_color", "Label"); + Color color = get_theme_color(SNAME("font_color"), SNAME("Label")); color.a = 0.5; int from_x = MAX(p_x, p_clip_left); @@ -2186,16 +2186,16 @@ void AnimationTrackEdit::draw_key(int p_index, float p_pixels_sec, int p_x, bool const Variant &v = animation->track_get_key_value(track, p_index); Variant::Type valid_type = Variant::NIL; if (!_is_value_key_valid(v, valid_type)) { - icon_to_draw = get_theme_icon("KeyInvalid", "EditorIcons"); + icon_to_draw = get_theme_icon(SNAME("KeyInvalid"), SNAME("EditorIcons")); } } Vector2 ofs(p_x - icon_to_draw->get_width() / 2, int(get_size().height - icon_to_draw->get_height()) / 2); if (animation->track_get_type(track) == Animation::TYPE_METHOD) { - Ref<Font> font = get_theme_font("font", "Label"); - int font_size = get_theme_font_size("font_size", "Label"); - Color color = get_theme_color("font_color", "Label"); + Ref<Font> font = get_theme_font(SNAME("font"), SNAME("Label")); + int font_size = get_theme_font_size(SNAME("font_size"), SNAME("Label")); + Color color = get_theme_color(SNAME("font_color"), SNAME("Label")); color.a = 0.5; Dictionary d = animation->track_get_key_value(track, p_index); @@ -2298,19 +2298,19 @@ void AnimationTrackEdit::set_animation_and_track(const Ref<Animation> &p_animati update(); Ref<Texture2D> type_icons[6] = { - get_theme_icon("KeyValue", "EditorIcons"), - get_theme_icon("KeyXform", "EditorIcons"), - get_theme_icon("KeyCall", "EditorIcons"), - get_theme_icon("KeyBezier", "EditorIcons"), - get_theme_icon("KeyAudio", "EditorIcons"), - get_theme_icon("KeyAnimation", "EditorIcons") + get_theme_icon(SNAME("KeyValue"), SNAME("EditorIcons")), + get_theme_icon(SNAME("KeyXform"), SNAME("EditorIcons")), + get_theme_icon(SNAME("KeyCall"), SNAME("EditorIcons")), + get_theme_icon(SNAME("KeyBezier"), SNAME("EditorIcons")), + get_theme_icon(SNAME("KeyAudio"), SNAME("EditorIcons")), + get_theme_icon(SNAME("KeyAnimation"), SNAME("EditorIcons")) }; ERR_FAIL_INDEX(track, animation->get_track_count()); node_path = animation->track_get_path(p_track); type_icon = type_icons[animation->track_get_type(track)]; - selected_icon = get_theme_icon("KeySelected", "EditorIcons"); + selected_icon = get_theme_icon(SNAME("KeySelected"), SNAME("EditorIcons")); } NodePath AnimationTrackEdit::get_path() const { @@ -2318,10 +2318,10 @@ NodePath AnimationTrackEdit::get_path() const { } Size2 AnimationTrackEdit::get_minimum_size() const { - Ref<Texture2D> texture = get_theme_icon("Object", "EditorIcons"); - Ref<Font> font = get_theme_font("font", "Label"); - int font_size = get_theme_font_size("font_size", "Label"); - int separation = get_theme_constant("vseparation", "ItemList"); + Ref<Texture2D> texture = get_theme_icon(SNAME("Object"), SNAME("EditorIcons")); + Ref<Font> font = get_theme_font(SNAME("font"), SNAME("Label")); + int font_size = get_theme_font_size(SNAME("font_size"), SNAME("Label")); + int separation = get_theme_constant(SNAME("vseparation"), SNAME("ItemList")); int max_h = MAX(texture->get_height(), font->get_height(font_size)); max_h = MAX(max_h, get_key_height()); @@ -2355,7 +2355,7 @@ void AnimationTrackEdit::_play_position_draw() { int px = (-timeline->get_value() + play_position_pos) * scale + timeline->get_name_limit(); if (px >= timeline->get_name_limit() && px < (get_size().width - timeline->get_buttons_width())) { - Color color = get_theme_color("accent_color", "Editor"); + Color color = get_theme_color(SNAME("accent_color"), SNAME("Editor")); play_position->draw_line(Point2(px, 0), Point2(px, h), color, Math::round(2 * EDSCALE)); } } @@ -2556,17 +2556,17 @@ void AnimationTrackEdit::_gui_input(const Ref<InputEvent> &p_event) { if (p_event->is_pressed()) { if (ED_GET_SHORTCUT("animation_editor/duplicate_selection")->is_shortcut(p_event)) { - emit_signal("duplicate_request"); + emit_signal(SNAME("duplicate_request")); accept_event(); } if (ED_GET_SHORTCUT("animation_editor/duplicate_selection_transposed")->is_shortcut(p_event)) { - emit_signal("duplicate_transpose_request"); + emit_signal(SNAME("duplicate_transpose_request")); accept_event(); } if (ED_GET_SHORTCUT("animation_editor/delete_selection")->is_shortcut(p_event)) { - emit_signal("delete_request"); + emit_signal(SNAME("delete_request")); accept_event(); } } @@ -2597,10 +2597,10 @@ void AnimationTrackEdit::_gui_input(const Ref<InputEvent> &p_event) { menu->connect("id_pressed", callable_mp(this, &AnimationTrackEdit::_menu_selected)); } menu->clear(); - menu->add_icon_item(get_theme_icon("TrackContinuous", "EditorIcons"), TTR("Continuous"), MENU_CALL_MODE_CONTINUOUS); - menu->add_icon_item(get_theme_icon("TrackDiscrete", "EditorIcons"), TTR("Discrete"), MENU_CALL_MODE_DISCRETE); - menu->add_icon_item(get_theme_icon("TrackTrigger", "EditorIcons"), TTR("Trigger"), MENU_CALL_MODE_TRIGGER); - menu->add_icon_item(get_theme_icon("TrackCapture", "EditorIcons"), TTR("Capture"), MENU_CALL_MODE_CAPTURE); + menu->add_icon_item(get_theme_icon(SNAME("TrackContinuous"), SNAME("EditorIcons")), TTR("Continuous"), MENU_CALL_MODE_CONTINUOUS); + menu->add_icon_item(get_theme_icon(SNAME("TrackDiscrete"), SNAME("EditorIcons")), TTR("Discrete"), MENU_CALL_MODE_DISCRETE); + menu->add_icon_item(get_theme_icon(SNAME("TrackTrigger"), SNAME("EditorIcons")), TTR("Trigger"), MENU_CALL_MODE_TRIGGER); + menu->add_icon_item(get_theme_icon(SNAME("TrackCapture"), SNAME("EditorIcons")), TTR("Capture"), MENU_CALL_MODE_CAPTURE); menu->set_as_minsize(); Vector2 popup_pos = get_screen_position() + update_mode_rect.position + Vector2(0, update_mode_rect.size.height); @@ -2616,9 +2616,9 @@ void AnimationTrackEdit::_gui_input(const Ref<InputEvent> &p_event) { menu->connect("id_pressed", callable_mp(this, &AnimationTrackEdit::_menu_selected)); } menu->clear(); - menu->add_icon_item(get_theme_icon("InterpRaw", "EditorIcons"), TTR("Nearest"), MENU_INTERPOLATION_NEAREST); - menu->add_icon_item(get_theme_icon("InterpLinear", "EditorIcons"), TTR("Linear"), MENU_INTERPOLATION_LINEAR); - menu->add_icon_item(get_theme_icon("InterpCubic", "EditorIcons"), TTR("Cubic"), MENU_INTERPOLATION_CUBIC); + menu->add_icon_item(get_theme_icon(SNAME("InterpRaw"), SNAME("EditorIcons")), TTR("Nearest"), MENU_INTERPOLATION_NEAREST); + menu->add_icon_item(get_theme_icon(SNAME("InterpLinear"), SNAME("EditorIcons")), TTR("Linear"), MENU_INTERPOLATION_LINEAR); + menu->add_icon_item(get_theme_icon(SNAME("InterpCubic"), SNAME("EditorIcons")), TTR("Cubic"), MENU_INTERPOLATION_CUBIC); menu->set_as_minsize(); Vector2 popup_pos = get_screen_position() + interp_mode_rect.position + Vector2(0, interp_mode_rect.size.height); @@ -2634,8 +2634,8 @@ void AnimationTrackEdit::_gui_input(const Ref<InputEvent> &p_event) { menu->connect("id_pressed", callable_mp(this, &AnimationTrackEdit::_menu_selected)); } menu->clear(); - menu->add_icon_item(get_theme_icon("InterpWrapClamp", "EditorIcons"), TTR("Clamp Loop Interp"), MENU_LOOP_CLAMP); - menu->add_icon_item(get_theme_icon("InterpWrapLoop", "EditorIcons"), TTR("Wrap Loop Interp"), MENU_LOOP_WRAP); + menu->add_icon_item(get_theme_icon(SNAME("InterpWrapClamp"), SNAME("EditorIcons")), TTR("Clamp Loop Interp"), MENU_LOOP_CLAMP); + menu->add_icon_item(get_theme_icon(SNAME("InterpWrapLoop"), SNAME("EditorIcons")), TTR("Wrap Loop Interp"), MENU_LOOP_WRAP); menu->set_as_minsize(); Vector2 popup_pos = get_screen_position() + loop_mode_rect.position + Vector2(0, loop_mode_rect.size.height); @@ -2645,13 +2645,13 @@ void AnimationTrackEdit::_gui_input(const Ref<InputEvent> &p_event) { } if (remove_rect.has_point(pos)) { - emit_signal("remove_request", track); + emit_signal(SNAME("remove_request"), track); accept_event(); return; } if (bezier_edit_rect.has_point(pos)) { - emit_signal("bezier_edit"); + emit_signal(SNAME("bezier_edit")); accept_event(); } @@ -2692,16 +2692,16 @@ void AnimationTrackEdit::_gui_input(const Ref<InputEvent> &p_event) { if (key_idx != -1) { if (mb->is_command_pressed() || mb->is_shift_pressed()) { if (editor->is_key_selected(track, key_idx)) { - emit_signal("deselect_key", key_idx); + emit_signal(SNAME("deselect_key"), key_idx); } else { - emit_signal("select_key", key_idx, false); + emit_signal(SNAME("select_key"), key_idx, false); moving_selection_attempt = true; select_single_attempt = -1; moving_selection_from_ofs = (mb->get_position().x - limit) / timeline->get_zoom_scale(); } } else { if (!editor->is_key_selected(track, key_idx)) { - emit_signal("select_key", key_idx, true); + emit_signal(SNAME("select_key"), key_idx, true); select_single_attempt = -1; } else { select_single_attempt = key_idx; @@ -2727,12 +2727,12 @@ void AnimationTrackEdit::_gui_input(const Ref<InputEvent> &p_event) { } menu->clear(); - menu->add_icon_item(get_theme_icon("Key", "EditorIcons"), TTR("Insert Key"), MENU_KEY_INSERT); + menu->add_icon_item(get_theme_icon(SNAME("Key"), SNAME("EditorIcons")), TTR("Insert Key"), MENU_KEY_INSERT); if (editor->is_selection_active()) { menu->add_separator(); - menu->add_icon_item(get_theme_icon("Duplicate", "EditorIcons"), TTR("Duplicate Key(s)"), MENU_KEY_DUPLICATE); + menu->add_icon_item(get_theme_icon(SNAME("Duplicate"), SNAME("EditorIcons")), TTR("Duplicate Key(s)"), MENU_KEY_DUPLICATE); menu->add_separator(); - menu->add_icon_item(get_theme_icon("Remove", "EditorIcons"), TTR("Delete Key(s)"), MENU_KEY_DELETE); + menu->add_icon_item(get_theme_icon(SNAME("Remove"), SNAME("EditorIcons")), TTR("Delete Key(s)"), MENU_KEY_DELETE); } menu->set_as_minsize(); @@ -2757,7 +2757,7 @@ void AnimationTrackEdit::_gui_input(const Ref<InputEvent> &p_event) { } path->set_text(animation->track_get_path(track)); - Vector2 theme_ofs = path->get_theme_stylebox("normal", "LineEdit")->get_offset(); + Vector2 theme_ofs = path->get_theme_stylebox(SNAME("normal"), SNAME("LineEdit"))->get_offset(); path_popup->set_position(get_screen_position() + path_rect.position - theme_ofs); path_popup->set_size(path_rect.size); path_popup->popup(); @@ -2770,9 +2770,9 @@ void AnimationTrackEdit::_gui_input(const Ref<InputEvent> &p_event) { if (!mb->is_pressed() && mb->get_button_index() == MOUSE_BUTTON_LEFT) { moving_selection_attempt = false; if (moving_selection) { - emit_signal("move_selection_commit"); + emit_signal(SNAME("move_selection_commit")); } else if (select_single_attempt != -1) { - emit_signal("select_key", select_single_attempt, true); + emit_signal(SNAME("select_key"), select_single_attempt, true); } moving_selection = false; select_single_attempt = -1; @@ -2781,7 +2781,7 @@ void AnimationTrackEdit::_gui_input(const Ref<InputEvent> &p_event) { if (moving_selection && mb->is_pressed() && mb->get_button_index() == MOUSE_BUTTON_RIGHT) { moving_selection_attempt = false; moving_selection = false; - emit_signal("move_selection_cancel"); + emit_signal(SNAME("move_selection_cancel")); } } @@ -2789,11 +2789,11 @@ void AnimationTrackEdit::_gui_input(const Ref<InputEvent> &p_event) { if (mm.is_valid() && mm->get_button_mask() & MOUSE_BUTTON_MASK_LEFT && moving_selection_attempt) { if (!moving_selection) { moving_selection = true; - emit_signal("move_selection_begin"); + emit_signal(SNAME("move_selection_begin")); } float new_ofs = (mm->get_position().x - timeline->get_name_limit()) / timeline->get_zoom_scale(); - emit_signal("move_selection", new_ofs - moving_selection_from_ofs); + emit_signal(SNAME("move_selection"), new_ofs - moving_selection_from_ofs); } } @@ -2847,7 +2847,7 @@ bool AnimationTrackEdit::can_drop_data(const Point2 &p_point, const Variant &p_d } const_cast<AnimationTrackEdit *>(this)->update(); - const_cast<AnimationTrackEdit *>(this)->emit_signal("drop_attempted", track); + const_cast<AnimationTrackEdit *>(this)->emit_signal(SNAME("drop_attempted"), track); return true; } @@ -2875,9 +2875,9 @@ void AnimationTrackEdit::drop_data(const Point2 &p_point, const Variant &p_data) int from_track = d["index"]; if (dropping_at < 0) { - emit_signal("dropped", from_track, track); + emit_signal(SNAME("dropped"), from_track, track); } else { - emit_signal("dropped", from_track, track + 1); + emit_signal(SNAME("dropped"), from_track, track + 1); } } @@ -2916,14 +2916,14 @@ void AnimationTrackEdit::_menu_selected(int p_index) { } break; case MENU_KEY_INSERT: { - emit_signal("insert_key", insert_at_pos); + emit_signal(SNAME("insert_key"), insert_at_pos); } break; case MENU_KEY_DUPLICATE: { - emit_signal("duplicate_request"); + emit_signal(SNAME("duplicate_request")); } break; case MENU_KEY_DELETE: { - emit_signal("delete_request"); + emit_signal(SNAME("delete_request")); } break; } @@ -2956,9 +2956,9 @@ void AnimationTrackEdit::append_to_selection(const Rect2 &p_box, bool p_deselect if (select_rect.intersects(rect)) { if (p_deselection) { - emit_signal("deselect_key", i); + emit_signal(SNAME("deselect_key"), i); } else { - emit_signal("select_key", i, false); + emit_signal(SNAME("select_key"), i, false); } } } @@ -3057,19 +3057,19 @@ AnimationTrackEdit *AnimationTrackEditPlugin::create_animation_track_edit(Object void AnimationTrackEditGroup::_notification(int p_what) { if (p_what == NOTIFICATION_DRAW) { - Ref<Font> font = get_theme_font("font", "Label"); - int font_size = get_theme_font_size("font_size", "Label"); - int separation = get_theme_constant("hseparation", "ItemList"); - Color color = get_theme_color("font_color", "Label"); + Ref<Font> font = get_theme_font(SNAME("font"), SNAME("Label")); + int font_size = get_theme_font_size(SNAME("font_size"), SNAME("Label")); + int separation = get_theme_constant(SNAME("hseparation"), SNAME("ItemList")); + Color color = get_theme_color(SNAME("font_color"), SNAME("Label")); if (root && root->has_node(node)) { Node *n = root->get_node(node); if (n && EditorNode::get_singleton()->get_editor_selection()->is_selected(n)) { - color = get_theme_color("accent_color", "Editor"); + color = get_theme_color(SNAME("accent_color"), SNAME("Editor")); } } - Color bgcol = get_theme_color("dark_color_2", "Editor"); + Color bgcol = get_theme_color(SNAME("dark_color_2"), SNAME("Editor")); bgcol.a *= 0.6; draw_rect(Rect2(Point2(), get_size()), bgcol); Color linecolor = color; @@ -3087,7 +3087,7 @@ void AnimationTrackEditGroup::_notification(int p_what) { int px = (-timeline->get_value() + timeline->get_play_position()) * timeline->get_zoom_scale() + timeline->get_name_limit(); if (px >= timeline->get_name_limit() && px < (get_size().width - timeline->get_buttons_width())) { - Color accent = get_theme_color("accent_color", "Editor"); + Color accent = get_theme_color(SNAME("accent_color"), SNAME("Editor")); draw_line(Point2(px, 0), Point2(px, get_size().height), accent, Math::round(2 * EDSCALE)); } } @@ -3102,9 +3102,9 @@ void AnimationTrackEditGroup::set_type_and_name(const Ref<Texture2D> &p_type, co } Size2 AnimationTrackEditGroup::get_minimum_size() const { - Ref<Font> font = get_theme_font("font", "Label"); - int font_size = get_theme_font_size("font_size", "Label"); - int separation = get_theme_constant("vseparation", "ItemList"); + Ref<Font> font = get_theme_font(SNAME("font"), SNAME("Label")); + int font_size = get_theme_font_size(SNAME("font_size"), SNAME("Label")); + int separation = get_theme_constant(SNAME("vseparation"), SNAME("ItemList")); return Vector2(0, MAX(font->get_height(font_size), icon->get_height()) + separation); } @@ -3226,7 +3226,7 @@ void AnimationTrackEditor::update_keying() { keying = keying_enabled; - emit_signal("keying_changed"); + emit_signal(SNAME("keying_changed")); } bool AnimationTrackEditor::has_keying() const { @@ -3283,7 +3283,7 @@ void AnimationTrackEditor::_name_limit_changed() { } void AnimationTrackEditor::_timeline_changed(float p_new_pos, bool p_drag, bool p_timeline_only) { - emit_signal("timeline_changed", p_new_pos, p_drag, p_timeline_only); + emit_signal(SNAME("timeline_changed"), p_new_pos, p_drag, p_timeline_only); } void AnimationTrackEditor::_track_remove_request(int p_track) { @@ -3356,9 +3356,9 @@ void AnimationTrackEditor::_query_insert(const InsertData &p_id) { } insert_frame = Engine::get_singleton()->get_frames_drawn(); - for (List<InsertData>::Element *E = insert_data.front(); E; E = E->next()) { + for (const InsertData &E : insert_data) { //prevent insertion of multiple tracks - if (E->get().path == p_id.path) { + if (E.path == p_id.path) { return; //already inserted a track for this on this frame } } @@ -3430,14 +3430,14 @@ void AnimationTrackEditor::_query_insert(const InsertData &p_id) { insert_confirm->popup_centered(); insert_query = true; } else { - call_deferred("_insert_delay", reset_allowed && EDITOR_GET("editors/animation/default_create_reset_tracks"), all_bezier && EDITOR_GET("editors/animation/default_create_bezier_tracks")); + call_deferred(SNAME("_insert_delay"), reset_allowed && EDITOR_GET("editors/animation/default_create_reset_tracks"), all_bezier && EDITOR_GET("editors/animation/default_create_bezier_tracks")); insert_queue = true; } } else { if (!insert_query && !insert_queue) { // Create Beziers wouldn't make sense in this case, where no tracks are being created - call_deferred("_insert_delay", reset_allowed && EDITOR_GET("editors/animation/default_create_reset_tracks"), false); + call_deferred(SNAME("_insert_delay"), reset_allowed && EDITOR_GET("editors/animation/default_create_reset_tracks"), false); insert_queue = true; } } @@ -3482,7 +3482,7 @@ void AnimationTrackEditor::_insert_delay(bool p_create_reset, bool p_create_bezi pos = animation->get_length(); } set_anim_pos(pos); - emit_signal("timeline_changed", pos, true); + emit_signal(SNAME("timeline_changed"), pos, true); } insert_queue = false; } @@ -3843,9 +3843,9 @@ PropertyInfo AnimationTrackEditor::_find_hint_for_track(int p_idx, NodePath &r_b List<PropertyInfo> pinfo; property_info_base.get_property_list(&pinfo); - for (List<PropertyInfo>::Element *E = pinfo.front(); E; E = E->next()) { - if (E->get().name == leftover_path[leftover_path.size() - 1]) { - return E->get(); + for (const PropertyInfo &E : pinfo) { + if (E.name == leftover_path[leftover_path.size() - 1]) { + return E; } } @@ -4166,7 +4166,7 @@ void AnimationTrackEditor::_update_tracks() { if (!group_sort.has(base_path)) { AnimationTrackEditGroup *g = memnew(AnimationTrackEditGroup); - Ref<Texture2D> icon = get_theme_icon("Node", "EditorIcons"); + Ref<Texture2D> icon = get_theme_icon(SNAME("Node"), SNAME("EditorIcons")); String name = base_path; String tooltip; if (root && root->has_node(base_path)) { @@ -4245,7 +4245,7 @@ void AnimationTrackEditor::_animation_changed() { } animation_changing_awaiting_update = true; - call_deferred("_animation_update"); + call_deferred(SNAME("_animation_update")); } void AnimationTrackEditor::_snap_mode_changed(int p_mode) { @@ -4313,8 +4313,8 @@ void AnimationTrackEditor::_animation_update() { bezier_edit->update(); _update_step_spinbox(); - emit_signal("animation_step_changed", animation->get_step()); - emit_signal("animation_len_changed", animation->get_length()); + emit_signal(SNAME("animation_step_changed"), animation->get_step()); + emit_signal(SNAME("animation_len_changed"), animation->get_length()); animation_changing_awaiting_update = false; } @@ -4325,13 +4325,13 @@ MenuButton *AnimationTrackEditor::get_edit_menu() { void AnimationTrackEditor::_notification(int p_what) { if (p_what == NOTIFICATION_THEME_CHANGED || p_what == NOTIFICATION_ENTER_TREE) { - zoom_icon->set_texture(get_theme_icon("Zoom", "EditorIcons")); - snap->set_icon(get_theme_icon("Snap", "EditorIcons")); + zoom_icon->set_texture(get_theme_icon(SNAME("Zoom"), SNAME("EditorIcons"))); + snap->set_icon(get_theme_icon(SNAME("Snap"), SNAME("EditorIcons"))); view_group->set_icon(get_theme_icon(view_group->is_pressed() ? "AnimationTrackList" : "AnimationTrackGroup", "EditorIcons")); - selected_filter->set_icon(get_theme_icon("AnimationFilter", "EditorIcons")); - imported_anim_warning->set_icon(get_theme_icon("NodeWarning", "EditorIcons")); - main_panel->add_theme_style_override("panel", get_theme_stylebox("bg", "Tree")); - edit->get_popup()->set_item_icon(edit->get_popup()->get_item_index(EDIT_APPLY_RESET), get_theme_icon("Reload", "EditorIcons")); + selected_filter->set_icon(get_theme_icon(SNAME("AnimationFilter"), SNAME("EditorIcons"))); + imported_anim_warning->set_icon(get_theme_icon(SNAME("NodeWarning"), SNAME("EditorIcons"))); + main_panel->add_theme_style_override("panel", get_theme_stylebox(SNAME("bg"), SNAME("Tree"))); + edit->get_popup()->set_item_icon(edit->get_popup()->get_item_index(EDIT_APPLY_RESET), get_theme_icon(SNAME("Reload"), SNAME("EditorIcons"))); } if (p_what == NOTIFICATION_READY) { @@ -4341,7 +4341,7 @@ void AnimationTrackEditor::_notification(int p_what) { if (p_what == NOTIFICATION_VISIBILITY_CHANGED) { update_keying(); EditorNode::get_singleton()->update_keying(); - emit_signal("keying_changed"); + emit_signal(SNAME("keying_changed")); } } @@ -4367,11 +4367,11 @@ void AnimationTrackEditor::_update_step(double p_new_step) { step->set_block_signals(true); undo_redo->commit_action(); step->set_block_signals(false); - emit_signal("animation_step_changed", step_value); + emit_signal(SNAME("animation_step_changed"), step_value); } void AnimationTrackEditor::_update_length(double p_new_len) { - emit_signal("animation_len_changed", p_new_len); + emit_signal(SNAME("animation_len_changed"), p_new_len); } void AnimationTrackEditor::_dropped_track(int p_from_track, int p_to_track) { @@ -4675,21 +4675,21 @@ void AnimationTrackEditor::_add_method_key(const String &p_method) { List<MethodInfo> minfo; base->get_method_list(&minfo); - for (List<MethodInfo>::Element *E = minfo.front(); E; E = E->next()) { - if (E->get().name == p_method) { + for (const MethodInfo &E : minfo) { + if (E.name == p_method) { Dictionary d; d["method"] = p_method; Array params; - int first_defarg = E->get().arguments.size() - E->get().default_arguments.size(); + int first_defarg = E.arguments.size() - E.default_arguments.size(); - for (int i = 0; i < E->get().arguments.size(); i++) { + for (int i = 0; i < E.arguments.size(); i++) { if (i >= first_defarg) { - Variant arg = E->get().default_arguments[i - first_defarg]; + Variant arg = E.default_arguments[i - first_defarg]; params.push_back(arg); } else { Callable::CallError ce; Variant arg; - Variant::construct(E->get().arguments[i].type, arg, nullptr, 0, ce); + Variant::construct(E.arguments[i].type, arg, nullptr, 0, ce); params.push_back(arg); } } @@ -4936,8 +4936,7 @@ void AnimationTrackEditor::_move_selection_commit() { } // 6 - (undo) reinsert overlapped keys - for (List<_AnimMoveRestore>::Element *E = to_restore.front(); E; E = E->next()) { - _AnimMoveRestore &amr = E->get(); + for (_AnimMoveRestore &amr : to_restore) { undo_redo->add_undo_method(animation.ptr(), "track_insert_key", amr.track, amr.time, amr.key, amr.transition); } @@ -4980,8 +4979,8 @@ float AnimationTrackEditor::get_moving_selection_offset() const { void AnimationTrackEditor::_box_selection_draw() { const Rect2 selection_rect = Rect2(Point2(), box_selection->get_size()); - box_selection->draw_rect(selection_rect, get_theme_color("box_selection_fill_color", "Editor")); - box_selection->draw_rect(selection_rect, get_theme_color("box_selection_stroke_color", "Editor"), false, Math::round(EDSCALE)); + box_selection->draw_rect(selection_rect, get_theme_color(SNAME("box_selection_fill_color"), SNAME("Editor"))); + box_selection->draw_rect(selection_rect, get_theme_color(SNAME("box_selection_stroke_color"), SNAME("Editor")), false, Math::round(EDSCALE)); } void AnimationTrackEditor::_scroll_input(const Ref<InputEvent> &p_event) { @@ -5151,9 +5150,9 @@ void AnimationTrackEditor::_anim_duplicate_keys(bool transpose) { //reselect duplicated Map<SelectedKey, KeyInfo> new_selection; - for (List<Pair<int, float>>::Element *E = new_selection_values.front(); E; E = E->next()) { - int track = E->get().first; - float time = E->get().second; + for (const Pair<int, float> &E : new_selection_values) { + int track = E.first; + float time = E.second; int existing_idx = animation->track_find_key(track, time, true); @@ -5201,7 +5200,7 @@ void AnimationTrackEditor::goto_prev_step(bool p_from_mouse_event) { pos = 0; } set_anim_pos(pos); - emit_signal("timeline_changed", pos, true); + emit_signal(SNAME("timeline_changed"), pos, true); } void AnimationTrackEditor::goto_next_step(bool p_from_mouse_event) { @@ -5228,7 +5227,7 @@ void AnimationTrackEditor::goto_next_step(bool p_from_mouse_event) { } set_anim_pos(pos); - emit_signal("timeline_changed", pos, true); + emit_signal(SNAME("timeline_changed"), pos, true); } void AnimationTrackEditor::_edit_menu_pressed(int p_option) { @@ -5247,7 +5246,7 @@ void AnimationTrackEditor::_edit_menu_pressed(int p_option) { } String text; - Ref<Texture2D> icon = get_theme_icon("Node", "EditorIcons"); + Ref<Texture2D> icon = get_theme_icon(SNAME("Node"), SNAME("EditorIcons")); if (node) { if (has_theme_icon(node->get_class(), "EditorIcons")) { icon = get_theme_icon(node->get_class(), "EditorIcons"); @@ -5462,8 +5461,7 @@ void AnimationTrackEditor::_edit_menu_pressed(int p_option) { } // 6-(undo) reinsert overlapped keys - for (List<_AnimMoveRestore>::Element *E = to_restore.front(); E; E = E->next()) { - _AnimMoveRestore &amr = E->get(); + for (_AnimMoveRestore &amr : to_restore) { undo_redo->add_undo_method(animation.ptr(), "track_insert_key", amr.track, amr.time, amr.key, amr.transition); } @@ -5543,8 +5541,8 @@ void AnimationTrackEditor::_edit_menu_pressed(int p_option) { if (cleanup_all->is_pressed()) { List<StringName> names; AnimationPlayerEditor::singleton->get_player()->get_animation_list(&names); - for (List<StringName>::Element *E = names.front(); E; E = E->next()) { - _cleanup_animation(AnimationPlayerEditor::singleton->get_player()->get_animation(E->get())); + for (const StringName &E : names) { + _cleanup_animation(AnimationPlayerEditor::singleton->get_player()->get_animation(E)); } } else { _cleanup_animation(animation); diff --git a/editor/animation_track_editor_plugins.cpp b/editor/animation_track_editor_plugins.cpp index 54c1e89d1e..0caed1e8e3 100644 --- a/editor/animation_track_editor_plugins.cpp +++ b/editor/animation_track_editor_plugins.cpp @@ -42,12 +42,12 @@ /// BOOL /// int AnimationTrackEditBool::get_key_height() const { - Ref<Texture2D> checked = get_theme_icon("checked", "CheckBox"); + Ref<Texture2D> checked = get_theme_icon(SNAME("checked"), SNAME("CheckBox")); return checked->get_height(); } Rect2 AnimationTrackEditBool::get_key_rect(int p_index, float p_pixels_sec) { - Ref<Texture2D> checked = get_theme_icon("checked", "CheckBox"); + Ref<Texture2D> checked = get_theme_icon(SNAME("checked"), SNAME("CheckBox")); return Rect2(-checked->get_width() / 2, 0, checked->get_width(), get_size().height); } @@ -72,7 +72,7 @@ void AnimationTrackEditBool::draw_key(int p_index, float p_pixels_sec, int p_x, draw_texture(icon, ofs); if (p_selected) { - Color color = get_theme_color("accent_color", "Editor"); + Color color = get_theme_color(SNAME("accent_color"), SNAME("Editor")); draw_rect_clipped(Rect2(ofs, icon->get_size()), color, false); } } @@ -80,14 +80,14 @@ void AnimationTrackEditBool::draw_key(int p_index, float p_pixels_sec, int p_x, /// COLOR /// int AnimationTrackEditColor::get_key_height() const { - Ref<Font> font = get_theme_font("font", "Label"); - int font_size = get_theme_font_size("font_size", "Label"); + Ref<Font> font = get_theme_font(SNAME("font"), SNAME("Label")); + int font_size = get_theme_font_size(SNAME("font_size"), SNAME("Label")); return font->get_height(font_size) * 0.8; } Rect2 AnimationTrackEditColor::get_key_rect(int p_index, float p_pixels_sec) { - Ref<Font> font = get_theme_font("font", "Label"); - int font_size = get_theme_font_size("font_size", "Label"); + Ref<Font> font = get_theme_font(SNAME("font"), SNAME("Label")); + int font_size = get_theme_font_size(SNAME("font_size"), SNAME("Label")); int fh = font->get_height(font_size) * 0.8; return Rect2(-fh / 2, 0, fh, get_size().height); } @@ -97,8 +97,8 @@ bool AnimationTrackEditColor::is_key_selectable_by_distance() const { } void AnimationTrackEditColor::draw_key_link(int p_index, float p_pixels_sec, int p_x, int p_next_x, int p_clip_left, int p_clip_right) { - Ref<Font> font = get_theme_font("font", "Label"); - int font_size = get_theme_font_size("font_size", "Label"); + Ref<Font> font = get_theme_font(SNAME("font"), SNAME("Label")); + int font_size = get_theme_font_size(SNAME("font_size"), SNAME("Label")); int fh = (font->get_height(font_size) * 0.8); fh /= 3; @@ -167,8 +167,8 @@ void AnimationTrackEditColor::draw_key_link(int p_index, float p_pixels_sec, int void AnimationTrackEditColor::draw_key(int p_index, float p_pixels_sec, int p_x, bool p_selected, int p_clip_left, int p_clip_right) { Color color = get_animation()->track_get_key_value(get_track(), p_index); - Ref<Font> font = get_theme_font("font", "Label"); - int font_size = get_theme_font_size("font_size", "Label"); + Ref<Font> font = get_theme_font(SNAME("font"), SNAME("Label")); + int font_size = get_theme_font_size(SNAME("font_size"), SNAME("Label")); int fh = font->get_height(font_size) * 0.8; Rect2 rect(Vector2(p_x - fh / 2, int(get_size().height - fh) / 2), Size2(fh, fh)); @@ -180,7 +180,7 @@ void AnimationTrackEditColor::draw_key(int p_index, float p_pixels_sec, int p_x, draw_rect_clipped(rect, color); if (p_selected) { - Color accent = get_theme_color("accent_color", "Editor"); + Color accent = get_theme_color(SNAME("accent_color"), SNAME("Editor")); draw_rect_clipped(rect, accent, false); } } @@ -206,8 +206,8 @@ int AnimationTrackEditAudio::get_key_height() const { return AnimationTrackEdit::get_key_height(); } - Ref<Font> font = get_theme_font("font", "Label"); - int font_size = get_theme_font_size("font_size", "Label"); + Ref<Font> font = get_theme_font(SNAME("font"), SNAME("Label")); + int font_size = get_theme_font_size(SNAME("font_size"), SNAME("Label")); return int(font->get_height(font_size) * 1.5); } @@ -239,8 +239,8 @@ Rect2 AnimationTrackEditAudio::get_key_rect(int p_index, float p_pixels_sec) { return Rect2(0, 0, len * p_pixels_sec, get_size().height); } else { - Ref<Font> font = get_theme_font("font", "Label"); - int font_size = get_theme_font_size("font_size", "Label"); + Ref<Font> font = get_theme_font(SNAME("font"), SNAME("Label")); + int font_size = get_theme_font_size(SNAME("font_size"), SNAME("Label")); int fh = font->get_height(font_size) * 0.8; return Rect2(0, 0, fh, get_size().height); } @@ -303,8 +303,8 @@ void AnimationTrackEditAudio::draw_key(int p_index, float p_pixels_sec, int p_x, return; } - Ref<Font> font = get_theme_font("font", "Label"); - int font_size = get_theme_font_size("font_size", "Label"); + Ref<Font> font = get_theme_font(SNAME("font"), SNAME("Label")); + int font_size = get_theme_font_size(SNAME("font_size"), SNAME("Label")); float fh = int(font->get_height(font_size) * 1.5); Rect2 rect = Rect2(from_x, (get_size().height - fh) / 2, to_x - from_x, fh); draw_rect(rect, Color(0.25, 0.25, 0.25)); @@ -330,20 +330,20 @@ void AnimationTrackEditAudio::draw_key(int p_index, float p_pixels_sec, int p_x, RS::get_singleton()->canvas_item_add_multiline(get_canvas_item(), lines, color); if (p_selected) { - Color accent = get_theme_color("accent_color", "Editor"); + Color accent = get_theme_color(SNAME("accent_color"), SNAME("Editor")); draw_rect(rect, accent, false); } } else { - Ref<Font> font = get_theme_font("font", "Label"); - int font_size = get_theme_font_size("font_size", "Label"); + Ref<Font> font = get_theme_font(SNAME("font"), SNAME("Label")); + int font_size = get_theme_font_size(SNAME("font_size"), SNAME("Label")); int fh = font->get_height(font_size) * 0.8; Rect2 rect(Vector2(p_x, int(get_size().height - fh) / 2), Size2(fh, fh)); - Color color = get_theme_color("font_color", "Label"); + Color color = get_theme_color(SNAME("font_color"), SNAME("Label")); draw_rect(rect, color); if (p_selected) { - Color accent = get_theme_color("accent_color", "Editor"); + Color accent = get_theme_color(SNAME("accent_color"), SNAME("Editor")); draw_rect(rect, accent, false); } } @@ -367,8 +367,8 @@ int AnimationTrackEditSpriteFrame::get_key_height() const { return AnimationTrackEdit::get_key_height(); } - Ref<Font> font = get_theme_font("font", "Label"); - int font_size = get_theme_font_size("font_size", "Label"); + Ref<Font> font = get_theme_font(SNAME("font"), SNAME("Label")); + int font_size = get_theme_font_size(SNAME("font_size"), SNAME("Label")); return int(font->get_height(font_size) * 2); } @@ -435,8 +435,8 @@ Rect2 AnimationTrackEditSpriteFrame::get_key_rect(int p_index, float p_pixels_se size = size.floor(); - Ref<Font> font = get_theme_font("font", "Label"); - int font_size = get_theme_font_size("font_size", "Label"); + Ref<Font> font = get_theme_font(SNAME("font"), SNAME("Label")); + int font_size = get_theme_font_size(SNAME("font_size"), SNAME("Label")); int height = int(font->get_height(font_size) * 2); int width = height * size.width / size.height; @@ -526,8 +526,8 @@ void AnimationTrackEditSpriteFrame::draw_key(int p_index, float p_pixels_sec, in region.size = texture->get_size(); } - Ref<Font> font = get_theme_font("font", "Label"); - int font_size = get_theme_font_size("font_size", "Label"); + Ref<Font> font = get_theme_font(SNAME("font"), SNAME("Label")); + int font_size = get_theme_font_size(SNAME("font_size"), SNAME("Label")); int height = int(font->get_height(font_size) * 2); int width = height * region.size.width / region.size.height; @@ -542,7 +542,7 @@ void AnimationTrackEditSpriteFrame::draw_key(int p_index, float p_pixels_sec, in return; } - Color accent = get_theme_color("accent_color", "Editor"); + Color accent = get_theme_color(SNAME("accent_color"), SNAME("Editor")); Color bg = accent; bg.a = 0.15; @@ -570,8 +570,8 @@ int AnimationTrackEditSubAnim::get_key_height() const { return AnimationTrackEdit::get_key_height(); } - Ref<Font> font = get_theme_font("font", "Label"); - int font_size = get_theme_font_size("font_size", "Label"); + Ref<Font> font = get_theme_font(SNAME("font"), SNAME("Label")); + int font_size = get_theme_font_size(SNAME("font_size"), SNAME("Label")); return int(font->get_height(font_size) * 1.5); } @@ -599,8 +599,8 @@ Rect2 AnimationTrackEditSubAnim::get_key_rect(int p_index, float p_pixels_sec) { return Rect2(0, 0, len * p_pixels_sec, get_size().height); } else { - Ref<Font> font = get_theme_font("font", "Label"); - int font_size = get_theme_font_size("font_size", "Label"); + Ref<Font> font = get_theme_font(SNAME("font"), SNAME("Label")); + int font_size = get_theme_font_size(SNAME("font_size"), SNAME("Label")); int fh = font->get_height(font_size) * 0.8; return Rect2(0, 0, fh, get_size().height); } @@ -654,13 +654,13 @@ void AnimationTrackEditSubAnim::draw_key(int p_index, float p_pixels_sec, int p_ return; } - Ref<Font> font = get_theme_font("font", "Label"); - int font_size = get_theme_font_size("font_size", "Label"); + Ref<Font> font = get_theme_font(SNAME("font"), SNAME("Label")); + int font_size = get_theme_font_size(SNAME("font_size"), SNAME("Label")); int fh = font->get_height(font_size) * 1.5; Rect2 rect(from_x, int(get_size().height - fh) / 2, to_x - from_x, fh); - Color color = get_theme_color("font_color", "Label"); + Color color = get_theme_color(SNAME("font_color"), SNAME("Label")); Color bg = color; bg.r = 1 - color.r; bg.g = 1 - color.g; @@ -703,20 +703,20 @@ void AnimationTrackEditSubAnim::draw_key(int p_index, float p_pixels_sec, int p_ } if (p_selected) { - Color accent = get_theme_color("accent_color", "Editor"); + Color accent = get_theme_color(SNAME("accent_color"), SNAME("Editor")); draw_rect(rect, accent, false); } } else { - Ref<Font> font = get_theme_font("font", "Label"); - int font_size = get_theme_font_size("font_size", "Label"); + Ref<Font> font = get_theme_font(SNAME("font"), SNAME("Label")); + int font_size = get_theme_font_size(SNAME("font_size"), SNAME("Label")); int fh = font->get_height(font_size) * 0.8; Rect2 rect(Vector2(p_x, int(get_size().height - fh) / 2), Size2(fh, fh)); - Color color = get_theme_color("font_color", "Label"); + Color color = get_theme_color(SNAME("font_color"), SNAME("Label")); draw_rect(rect, color); if (p_selected) { - Color accent = get_theme_color("accent_color", "Editor"); + Color accent = get_theme_color(SNAME("accent_color"), SNAME("Editor")); draw_rect(rect, accent, false); } } @@ -729,12 +729,12 @@ void AnimationTrackEditSubAnim::set_node(Object *p_object) { //// VOLUME DB //// int AnimationTrackEditVolumeDB::get_key_height() const { - Ref<Texture2D> volume_texture = get_theme_icon("ColorTrackVu", "EditorIcons"); + Ref<Texture2D> volume_texture = get_theme_icon(SNAME("ColorTrackVu"), SNAME("EditorIcons")); return volume_texture->get_height() * 1.2; } void AnimationTrackEditVolumeDB::draw_bg(int p_clip_left, int p_clip_right) { - Ref<Texture2D> volume_texture = get_theme_icon("ColorTrackVu", "EditorIcons"); + Ref<Texture2D> volume_texture = get_theme_icon(SNAME("ColorTrackVu"), SNAME("EditorIcons")); int tex_h = volume_texture->get_height(); int y_from = (get_size().height - tex_h) / 2; @@ -745,7 +745,7 @@ void AnimationTrackEditVolumeDB::draw_bg(int p_clip_left, int p_clip_right) { } void AnimationTrackEditVolumeDB::draw_fg(int p_clip_left, int p_clip_right) { - Ref<Texture2D> volume_texture = get_theme_icon("ColorTrackVu", "EditorIcons"); + Ref<Texture2D> volume_texture = get_theme_icon(SNAME("ColorTrackVu"), SNAME("EditorIcons")); int tex_h = volume_texture->get_height(); int y_from = (get_size().height - tex_h) / 2; int db0 = y_from + (24 / 80.0) * tex_h; @@ -780,12 +780,12 @@ void AnimationTrackEditVolumeDB::draw_key_link(int p_index, float p_pixels_sec, to_x = p_clip_right; } - Ref<Texture2D> volume_texture = get_theme_icon("ColorTrackVu", "EditorIcons"); + Ref<Texture2D> volume_texture = get_theme_icon(SNAME("ColorTrackVu"), SNAME("EditorIcons")); int tex_h = volume_texture->get_height(); int y_from = (get_size().height - tex_h) / 2; - Color color = get_theme_color("font_color", "Label"); + Color color = get_theme_color(SNAME("font_color"), SNAME("Label")); color.a *= 0.7; draw_line(Point2(from_x, y_from + h * tex_h), Point2(to_x, y_from + h_n * tex_h), color, 2); @@ -806,8 +806,8 @@ void AnimationTrackEditTypeAudio::_preview_changed(ObjectID p_which) { } int AnimationTrackEditTypeAudio::get_key_height() const { - Ref<Font> font = get_theme_font("font", "Label"); - int font_size = get_theme_font_size("font_size", "Label"); + Ref<Font> font = get_theme_font(SNAME("font"), SNAME("Label")); + int font_size = get_theme_font_size(SNAME("font_size"), SNAME("Label")); return int(font->get_height(font_size) * 1.5); } @@ -871,8 +871,8 @@ void AnimationTrackEditTypeAudio::draw_key(int p_index, float p_pixels_sec, int } } - Ref<Font> font = get_theme_font("font", "Label"); - int font_size = get_theme_font_size("font_size", "Label"); + Ref<Font> font = get_theme_font(SNAME("font"), SNAME("Label")); + int font_size = get_theme_font_size(SNAME("font_size"), SNAME("Label")); float fh = int(font->get_height(font_size) * 1.5); float len = stream->get_length(); @@ -947,7 +947,7 @@ void AnimationTrackEditTypeAudio::draw_key(int p_index, float p_pixels_sec, int RS::get_singleton()->canvas_item_add_multiline(get_canvas_item(), lines, color); - Color cut_color = get_theme_color("accent_color", "Editor"); + Color cut_color = get_theme_color(SNAME("accent_color"), SNAME("Editor")); cut_color.a = 0.7; if (start_ofs > 0 && pixel_begin > p_clip_left) { draw_rect(Rect2(pixel_begin, rect.position.y, 1, rect.size.y), cut_color); @@ -957,7 +957,7 @@ void AnimationTrackEditTypeAudio::draw_key(int p_index, float p_pixels_sec, int } if (p_selected) { - Color accent = get_theme_color("accent_color", "Editor"); + Color accent = get_theme_color(SNAME("accent_color"), SNAME("Editor")); draw_rect(rect, accent, false); } } @@ -1143,8 +1143,8 @@ int AnimationTrackEditTypeAnimation::get_key_height() const { return AnimationTrackEdit::get_key_height(); } - Ref<Font> font = get_theme_font("font", "Label"); - int font_size = get_theme_font_size("font_size", "Label"); + Ref<Font> font = get_theme_font(SNAME("font"), SNAME("Label")); + int font_size = get_theme_font_size(SNAME("font_size"), SNAME("Label")); return int(font->get_height(font_size) * 1.5); } @@ -1172,8 +1172,8 @@ Rect2 AnimationTrackEditTypeAnimation::get_key_rect(int p_index, float p_pixels_ return Rect2(0, 0, len * p_pixels_sec, get_size().height); } else { - Ref<Font> font = get_theme_font("font", "Label"); - int font_size = get_theme_font_size("font_size", "Label"); + Ref<Font> font = get_theme_font(SNAME("font"), SNAME("Label")); + int font_size = get_theme_font_size(SNAME("font_size"), SNAME("Label")); int fh = font->get_height(font_size) * 0.8; return Rect2(0, 0, fh, get_size().height); } @@ -1227,13 +1227,13 @@ void AnimationTrackEditTypeAnimation::draw_key(int p_index, float p_pixels_sec, return; } - Ref<Font> font = get_theme_font("font", "Label"); - int font_size = get_theme_font_size("font_size", "Label"); + Ref<Font> font = get_theme_font(SNAME("font"), SNAME("Label")); + int font_size = get_theme_font_size(SNAME("font_size"), SNAME("Label")); int fh = font->get_height(font_size) * 1.5; Rect2 rect(from_x, int(get_size().height - fh) / 2, to_x - from_x, fh); - Color color = get_theme_color("font_color", "Label"); + Color color = get_theme_color(SNAME("font_color"), SNAME("Label")); Color bg = color; bg.r = 1 - color.r; bg.g = 1 - color.g; @@ -1276,20 +1276,20 @@ void AnimationTrackEditTypeAnimation::draw_key(int p_index, float p_pixels_sec, } if (p_selected) { - Color accent = get_theme_color("accent_color", "Editor"); + Color accent = get_theme_color(SNAME("accent_color"), SNAME("Editor")); draw_rect(rect, accent, false); } } else { - Ref<Font> font = get_theme_font("font", "Label"); - int font_size = get_theme_font_size("font_size", "Label"); + Ref<Font> font = get_theme_font(SNAME("font"), SNAME("Label")); + int font_size = get_theme_font_size(SNAME("font_size"), SNAME("Label")); int fh = font->get_height(font_size) * 0.8; Rect2 rect(Vector2(p_x, int(get_size().height - fh) / 2), Size2(fh, fh)); - Color color = get_theme_color("font_color", "Label"); + Color color = get_theme_color(SNAME("font_color"), SNAME("Label")); draw_rect(rect, color); if (p_selected) { - Color accent = get_theme_color("accent_color", "Editor"); + Color accent = get_theme_color(SNAME("accent_color"), SNAME("Editor")); draw_rect(rect, accent, false); } } diff --git a/editor/audio_stream_preview.cpp b/editor/audio_stream_preview.cpp index ad6e3ac1dc..f7f4988873 100644 --- a/editor/audio_stream_preview.cpp +++ b/editor/audio_stream_preview.cpp @@ -97,7 +97,7 @@ AudioStreamPreview::AudioStreamPreview() { //// void AudioStreamPreviewGenerator::_update_emit(ObjectID p_id) { - emit_signal("preview_updated", p_id); + emit_signal(SNAME("preview_updated"), p_id); } void AudioStreamPreviewGenerator::_preview_thread(void *p_preview) { @@ -150,7 +150,7 @@ void AudioStreamPreviewGenerator::_preview_thread(void *p_preview) { } frames_todo -= to_read; - singleton->call_deferred("_update_emit", preview->id); + singleton->call_deferred(SNAME("_update_emit"), preview->id); } preview->playback->stop(); diff --git a/editor/code_editor.cpp b/editor/code_editor.cpp index 03914bec3b..285084a72b 100644 --- a/editor/code_editor.cpp +++ b/editor/code_editor.cpp @@ -31,6 +31,7 @@ #include "code_editor.h" #include "core/input/input.h" +#include "core/object/message_queue.h" #include "core/os/keyboard.h" #include "core/string/string_builder.h" #include "editor/editor_scale.h" @@ -88,23 +89,23 @@ GotoLineDialog::GotoLineDialog() { void FindReplaceBar::_notification(int p_what) { if (p_what == NOTIFICATION_READY) { - find_prev->set_icon(get_theme_icon("MoveUp", "EditorIcons")); - find_next->set_icon(get_theme_icon("MoveDown", "EditorIcons")); - hide_button->set_normal_texture(get_theme_icon("Close", "EditorIcons")); - hide_button->set_hover_texture(get_theme_icon("Close", "EditorIcons")); - hide_button->set_pressed_texture(get_theme_icon("Close", "EditorIcons")); + find_prev->set_icon(get_theme_icon(SNAME("MoveUp"), SNAME("EditorIcons"))); + find_next->set_icon(get_theme_icon(SNAME("MoveDown"), SNAME("EditorIcons"))); + hide_button->set_normal_texture(get_theme_icon(SNAME("Close"), SNAME("EditorIcons"))); + hide_button->set_hover_texture(get_theme_icon(SNAME("Close"), SNAME("EditorIcons"))); + hide_button->set_pressed_texture(get_theme_icon(SNAME("Close"), SNAME("EditorIcons"))); hide_button->set_custom_minimum_size(hide_button->get_normal_texture()->get_size()); } else if (p_what == NOTIFICATION_VISIBILITY_CHANGED) { set_process_unhandled_input(is_visible_in_tree()); } else if (p_what == EditorSettings::NOTIFICATION_EDITOR_SETTINGS_CHANGED) { - find_prev->set_icon(get_theme_icon("MoveUp", "EditorIcons")); - find_next->set_icon(get_theme_icon("MoveDown", "EditorIcons")); - hide_button->set_normal_texture(get_theme_icon("Close", "EditorIcons")); - hide_button->set_hover_texture(get_theme_icon("Close", "EditorIcons")); - hide_button->set_pressed_texture(get_theme_icon("Close", "EditorIcons")); + find_prev->set_icon(get_theme_icon(SNAME("MoveUp"), SNAME("EditorIcons"))); + find_next->set_icon(get_theme_icon(SNAME("MoveDown"), SNAME("EditorIcons"))); + hide_button->set_normal_texture(get_theme_icon(SNAME("Close"), SNAME("EditorIcons"))); + hide_button->set_hover_texture(get_theme_icon(SNAME("Close"), SNAME("EditorIcons"))); + hide_button->set_pressed_texture(get_theme_icon(SNAME("Close"), SNAME("EditorIcons"))); hide_button->set_custom_minimum_size(hide_button->get_normal_texture()->get_size()); } else if (p_what == NOTIFICATION_THEME_CHANGED) { - matches_label->add_theme_color_override("font_color", results_count > 0 ? get_theme_color("font_color", "Label") : get_theme_color("error_color", "Editor")); + matches_label->add_theme_color_override("font_color", results_count > 0 ? get_theme_color(SNAME("font_color"), SNAME("Label")) : get_theme_color(SNAME("error_color"), SNAME("Editor"))); } else if (p_what == NOTIFICATION_PREDELETE) { if (base_text_editor) { base_text_editor->remove_find_replace_bar(); @@ -304,10 +305,10 @@ void FindReplaceBar::_replace_all() { } text_editor->set_v_scroll(vsval); - matches_label->add_theme_color_override("font_color", rc > 0 ? get_theme_color("font_color", "Label") : get_theme_color("error_color", "Editor")); + matches_label->add_theme_color_override("font_color", rc > 0 ? get_theme_color(SNAME("font_color"), SNAME("Label")) : get_theme_color(SNAME("error_color"), SNAME("Editor"))); matches_label->set_text(vformat(TTR("%d replaced."), rc)); - text_editor->call_deferred("connect", "text_changed", callable_mp(this, &FindReplaceBar::_editor_text_changed)); + text_editor->call_deferred(SNAME("connect"), "text_changed", callable_mp(this, &FindReplaceBar::_editor_text_changed)); results_count = -1; } @@ -368,7 +369,7 @@ void FindReplaceBar::_update_matches_label() { } else { matches_label->show(); - matches_label->add_theme_color_override("font_color", results_count > 0 ? get_theme_color("font_color", "Label") : get_theme_color("error_color", "Editor")); + matches_label->add_theme_color_override("font_color", results_count > 0 ? get_theme_color(SNAME("font_color"), SNAME("Label")) : get_theme_color(SNAME("error_color"), SNAME("Editor"))); matches_label->set_text(vformat(results_count == 1 ? TTR("%d match.") : TTR("%d matches."), results_count)); } } @@ -480,10 +481,10 @@ void FindReplaceBar::_show_search(bool p_focus_replace, bool p_show_only) { if (p_focus_replace) { search_text->deselect(); - replace_text->call_deferred("grab_focus"); + replace_text->call_deferred(SNAME("grab_focus")); } else { replace_text->deselect(); - search_text->call_deferred("grab_focus"); + search_text->call_deferred(SNAME("grab_focus")); } if (text_editor->is_selection_active() && !selection_only->is_pressed()) { @@ -585,7 +586,7 @@ bool FindReplaceBar::is_selection_only() const { } void FindReplaceBar::set_error(const String &p_label) { - emit_signal("error", p_label); + emit_signal(SNAME("error"), p_label); } void FindReplaceBar::set_text_edit(CodeTextEditor *p_text_editor) { @@ -760,10 +761,10 @@ void CodeTextEditor::_text_editor_gui_input(const Ref<InputEvent> &p_event) { Ref<InputEventMagnifyGesture> magnify_gesture = p_event; if (magnify_gesture.is_valid()) { - font_size = text_editor->get_theme_font_size("font_size"); + font_size = text_editor->get_theme_font_size(SNAME("font_size")); font_size *= powf(magnify_gesture->get_factor(), 0.25); - _add_font_size((int)font_size - text_editor->get_theme_font_size("font_size")); + _add_font_size((int)font_size - text_editor->get_theme_font_size(SNAME("font_size"))); return; } @@ -854,9 +855,7 @@ void CodeTextEditor::_complete_request() { return; } - for (List<ScriptCodeCompletionOption>::Element *E = entries.front(); E; E = E->next()) { - ScriptCodeCompletionOption &e = E->get(); - + for (const ScriptCodeCompletionOption &e : entries) { Color font_color = completion_font_color; if (e.insert_text.begins_with("\"") || e.insert_text.begins_with("\'")) { font_color = completion_string_color; @@ -875,38 +874,38 @@ Ref<Texture2D> CodeTextEditor::_get_completion_icon(const ScriptCodeCompletionOp if (has_theme_icon(p_option.display, "EditorIcons")) { tex = get_theme_icon(p_option.display, "EditorIcons"); } else { - tex = get_theme_icon("Object", "EditorIcons"); + tex = get_theme_icon(SNAME("Object"), SNAME("EditorIcons")); } } break; case ScriptCodeCompletionOption::KIND_ENUM: - tex = get_theme_icon("Enum", "EditorIcons"); + tex = get_theme_icon(SNAME("Enum"), SNAME("EditorIcons")); break; case ScriptCodeCompletionOption::KIND_FILE_PATH: - tex = get_theme_icon("File", "EditorIcons"); + tex = get_theme_icon(SNAME("File"), SNAME("EditorIcons")); break; case ScriptCodeCompletionOption::KIND_NODE_PATH: - tex = get_theme_icon("NodePath", "EditorIcons"); + tex = get_theme_icon(SNAME("NodePath"), SNAME("EditorIcons")); break; case ScriptCodeCompletionOption::KIND_VARIABLE: - tex = get_theme_icon("Variant", "EditorIcons"); + tex = get_theme_icon(SNAME("Variant"), SNAME("EditorIcons")); break; case ScriptCodeCompletionOption::KIND_CONSTANT: - tex = get_theme_icon("MemberConstant", "EditorIcons"); + tex = get_theme_icon(SNAME("MemberConstant"), SNAME("EditorIcons")); break; case ScriptCodeCompletionOption::KIND_MEMBER: - tex = get_theme_icon("MemberProperty", "EditorIcons"); + tex = get_theme_icon(SNAME("MemberProperty"), SNAME("EditorIcons")); break; case ScriptCodeCompletionOption::KIND_SIGNAL: - tex = get_theme_icon("MemberSignal", "EditorIcons"); + tex = get_theme_icon(SNAME("MemberSignal"), SNAME("EditorIcons")); break; case ScriptCodeCompletionOption::KIND_FUNCTION: - tex = get_theme_icon("MemberMethod", "EditorIcons"); + tex = get_theme_icon(SNAME("MemberMethod"), SNAME("EditorIcons")); break; case ScriptCodeCompletionOption::KIND_PLAIN_TEXT: - tex = get_theme_icon("BoxMesh", "EditorIcons"); + tex = get_theme_icon(SNAME("BoxMesh"), SNAME("EditorIcons")); break; default: - tex = get_theme_icon("String", "EditorIcons"); + tex = get_theme_icon(SNAME("String"), SNAME("EditorIcons")); break; } return tex; @@ -919,7 +918,7 @@ void CodeTextEditor::_font_resize_timeout() { } bool CodeTextEditor::_add_font_size(int p_delta) { - int old_size = text_editor->get_theme_font_size("font_size"); + int old_size = text_editor->get_theme_font_size(SNAME("font_size")); int new_size = CLAMP(old_size + p_delta, 8 * EDSCALE, 96 * EDSCALE); if (new_size != old_size) { @@ -1411,19 +1410,19 @@ void CodeTextEditor::toggle_inline_comment(const String &delimiter) { void CodeTextEditor::goto_line(int p_line) { text_editor->deselect(); text_editor->unfold_line(p_line); - text_editor->call_deferred("cursor_set_line", p_line); + text_editor->call_deferred(SNAME("cursor_set_line"), p_line); } void CodeTextEditor::goto_line_selection(int p_line, int p_begin, int p_end) { text_editor->unfold_line(p_line); - text_editor->call_deferred("cursor_set_line", p_line); - text_editor->call_deferred("cursor_set_column", p_begin); + text_editor->call_deferred(SNAME("cursor_set_line"), p_line); + text_editor->call_deferred(SNAME("cursor_set_column"), p_begin); text_editor->select(p_line, p_begin, p_line, p_end); } void CodeTextEditor::goto_line_centered(int p_line) { goto_line(p_line); - text_editor->call_deferred("center_viewport_to_cursor"); + text_editor->call_deferred(SNAME("center_viewport_to_cursor")); } void CodeTextEditor::set_executing_line(int p_line) { @@ -1542,20 +1541,20 @@ void CodeTextEditor::_update_text_editor_theme() { text_editor->add_theme_color_override("search_result_color", EDITOR_GET("text_editor/highlighting/search_result_color")); text_editor->add_theme_color_override("search_result_border_color", EDITOR_GET("text_editor/highlighting/search_result_border_color")); text_editor->add_theme_constant_override("line_spacing", EDITOR_DEF("text_editor/theme/line_spacing", 6)); - emit_signal("load_theme_settings"); + emit_signal(SNAME("load_theme_settings")); _load_theme_settings(); } void CodeTextEditor::_update_font() { - text_editor->add_theme_font_override("font", get_theme_font("source", "EditorFonts")); - text_editor->add_theme_font_size_override("font_size", get_theme_font_size("source_size", "EditorFonts")); + text_editor->add_theme_font_override("font", get_theme_font(SNAME("source"), SNAME("EditorFonts"))); + text_editor->add_theme_font_size_override("font_size", get_theme_font_size(SNAME("source_size"), SNAME("EditorFonts"))); - error->add_theme_font_override("font", get_theme_font("status_source", "EditorFonts")); - error->add_theme_font_size_override("font_size", get_theme_font_size("status_source_size", "EditorFonts")); - error->add_theme_color_override("font_color", get_theme_color("error_color", "Editor")); + error->add_theme_font_override("font", get_theme_font(SNAME("status_source"), SNAME("EditorFonts"))); + error->add_theme_font_size_override("font_size", get_theme_font_size(SNAME("status_source_size"), SNAME("EditorFonts"))); + error->add_theme_color_override("font_color", get_theme_color(SNAME("error_color"), SNAME("Editor"))); - Ref<Font> status_bar_font = get_theme_font("status_source", "EditorFonts"); - int status_bar_font_size = get_theme_font_size("status_source_size", "EditorFonts"); + Ref<Font> status_bar_font = get_theme_font(SNAME("status_source"), SNAME("EditorFonts")); + int status_bar_font_size = get_theme_font_size(SNAME("status_source_size"), SNAME("EditorFonts")); error->add_theme_font_override("font", status_bar_font); error->add_theme_font_size_override("font_size", status_bar_font_size); int count = status_bar->get_child_count(); @@ -1569,6 +1568,17 @@ void CodeTextEditor::_update_font() { } void CodeTextEditor::_on_settings_change() { + if (settings_changed) { + return; + } + + settings_changed = true; + MessageQueue::get_singleton()->push_callable(callable_mp(this, &CodeTextEditor::_apply_settings_change)); +} + +void CodeTextEditor::_apply_settings_change() { + settings_changed = false; + _update_text_editor_theme(); _update_font(); @@ -1614,7 +1624,7 @@ void CodeTextEditor::_on_settings_change() { void CodeTextEditor::_text_changed_idle_timeout() { _validate_script(); - emit_signal("validate_script"); + emit_signal(SNAME("validate_script")); } void CodeTextEditor::validate_script() { @@ -1633,19 +1643,19 @@ void CodeTextEditor::_warning_button_pressed() { void CodeTextEditor::_set_show_errors_panel(bool p_show) { is_errors_panel_opened = p_show; - emit_signal("show_errors_panel", p_show); + emit_signal(SNAME("show_errors_panel"), p_show); } void CodeTextEditor::_set_show_warnings_panel(bool p_show) { is_warnings_panel_opened = p_show; - emit_signal("show_warnings_panel", p_show); + emit_signal(SNAME("show_warnings_panel"), p_show); } void CodeTextEditor::_toggle_scripts_pressed() { if (is_layout_rtl()) { - toggle_scripts_button->set_icon(ScriptEditor::get_singleton()->toggle_scripts_panel() ? get_theme_icon("Forward", "EditorIcons") : get_theme_icon("Back", "EditorIcons")); + toggle_scripts_button->set_icon(ScriptEditor::get_singleton()->toggle_scripts_panel() ? get_theme_icon(SNAME("Forward"), SNAME("EditorIcons")) : get_theme_icon(SNAME("Back"), SNAME("EditorIcons"))); } else { - toggle_scripts_button->set_icon(ScriptEditor::get_singleton()->toggle_scripts_panel() ? get_theme_icon("Back", "EditorIcons") : get_theme_icon("Forward", "EditorIcons")); + toggle_scripts_button->set_icon(ScriptEditor::get_singleton()->toggle_scripts_panel() ? get_theme_icon(SNAME("Back"), SNAME("EditorIcons")) : get_theme_icon(SNAME("Forward"), SNAME("EditorIcons"))); } } @@ -1666,8 +1676,8 @@ void CodeTextEditor::_notification(int p_what) { _update_font(); } break; case NOTIFICATION_ENTER_TREE: { - error_button->set_icon(get_theme_icon("StatusError", "EditorIcons")); - warning_button->set_icon(get_theme_icon("NodeWarning", "EditorIcons")); + error_button->set_icon(get_theme_icon(SNAME("StatusError"), SNAME("EditorIcons"))); + warning_button->set_icon(get_theme_icon(SNAME("NodeWarning"), SNAME("EditorIcons"))); add_theme_constant_override("separation", 4 * EDSCALE); } break; case NOTIFICATION_VISIBILITY_CHANGED: { @@ -1779,9 +1789,9 @@ void CodeTextEditor::show_toggle_scripts_button() { void CodeTextEditor::update_toggle_scripts_button() { if (is_layout_rtl()) { - toggle_scripts_button->set_icon(ScriptEditor::get_singleton()->is_scripts_panel_toggled() ? get_theme_icon("Forward", "EditorIcons") : get_theme_icon("Back", "EditorIcons")); + toggle_scripts_button->set_icon(ScriptEditor::get_singleton()->is_scripts_panel_toggled() ? get_theme_icon(SNAME("Forward"), SNAME("EditorIcons")) : get_theme_icon(SNAME("Back"), SNAME("EditorIcons"))); } else { - toggle_scripts_button->set_icon(ScriptEditor::get_singleton()->is_scripts_panel_toggled() ? get_theme_icon("Back", "EditorIcons") : get_theme_icon("Forward", "EditorIcons")); + toggle_scripts_button->set_icon(ScriptEditor::get_singleton()->is_scripts_panel_toggled() ? get_theme_icon(SNAME("Back"), SNAME("EditorIcons")) : get_theme_icon(SNAME("Forward"), SNAME("EditorIcons"))); } toggle_scripts_button->set_tooltip(TTR("Toggle Scripts Panel") + " (" + ED_GET_SHORTCUT("script_editor/toggle_scripts_panel")->get_as_text() + ")"); } @@ -1871,9 +1881,9 @@ CodeTextEditor::CodeTextEditor() { error_button->connect("pressed", callable_mp(this, &CodeTextEditor::_error_button_pressed)); error_button->set_tooltip(TTR("Errors")); - error_button->add_theme_color_override("font_color", EditorNode::get_singleton()->get_gui_base()->get_theme_color("error_color", "Editor")); - error_button->add_theme_font_override("font", EditorNode::get_singleton()->get_gui_base()->get_theme_font("status_source", "EditorFonts")); - error_button->add_theme_font_size_override("font_size", EditorNode::get_singleton()->get_gui_base()->get_theme_font_size("status_source_size", "EditorFonts")); + error_button->add_theme_color_override("font_color", EditorNode::get_singleton()->get_gui_base()->get_theme_color(SNAME("error_color"), SNAME("Editor"))); + error_button->add_theme_font_override("font", EditorNode::get_singleton()->get_gui_base()->get_theme_font(SNAME("status_source"), SNAME("EditorFonts"))); + error_button->add_theme_font_size_override("font_size", EditorNode::get_singleton()->get_gui_base()->get_theme_font_size(SNAME("status_source_size"), SNAME("EditorFonts"))); is_errors_panel_opened = false; set_error_count(0); @@ -1887,9 +1897,9 @@ CodeTextEditor::CodeTextEditor() { warning_button->connect("pressed", callable_mp(this, &CodeTextEditor::_warning_button_pressed)); warning_button->set_tooltip(TTR("Warnings")); - warning_button->add_theme_color_override("font_color", EditorNode::get_singleton()->get_gui_base()->get_theme_color("warning_color", "Editor")); - warning_button->add_theme_font_override("font", EditorNode::get_singleton()->get_gui_base()->get_theme_font("status_source", "EditorFonts")); - warning_button->add_theme_font_size_override("font_size", EditorNode::get_singleton()->get_gui_base()->get_theme_font_size("status_source_size", "EditorFonts")); + warning_button->add_theme_color_override("font_color", EditorNode::get_singleton()->get_gui_base()->get_theme_color(SNAME("warning_color"), SNAME("Editor"))); + warning_button->add_theme_font_override("font", EditorNode::get_singleton()->get_gui_base()->get_theme_font(SNAME("status_source"), SNAME("EditorFonts"))); + warning_button->add_theme_font_size_override("font_size", EditorNode::get_singleton()->get_gui_base()->get_theme_font_size(SNAME("status_source_size"), SNAME("EditorFonts"))); is_warnings_panel_opened = false; set_warning_count(0); @@ -1898,8 +1908,8 @@ CodeTextEditor::CodeTextEditor() { line_and_col_txt = memnew(Label); status_bar->add_child(line_and_col_txt); line_and_col_txt->set_v_size_flags(SIZE_EXPAND | SIZE_SHRINK_CENTER); - line_and_col_txt->add_theme_font_override("font", EditorNode::get_singleton()->get_gui_base()->get_theme_font("status_source", "EditorFonts")); - line_and_col_txt->add_theme_font_size_override("font_size", EditorNode::get_singleton()->get_gui_base()->get_theme_font_size("status_source_size", "EditorFonts")); + line_and_col_txt->add_theme_font_override("font", EditorNode::get_singleton()->get_gui_base()->get_theme_font(SNAME("status_source"), SNAME("EditorFonts"))); + line_and_col_txt->add_theme_font_size_override("font_size", EditorNode::get_singleton()->get_gui_base()->get_theme_font_size(SNAME("status_source_size"), SNAME("EditorFonts"))); line_and_col_txt->set_tooltip(TTR("Line and column numbers.")); line_and_col_txt->set_mouse_filter(MOUSE_FILTER_STOP); diff --git a/editor/code_editor.h b/editor/code_editor.h index 0e5a84b3d5..4cd4880df0 100644 --- a/editor/code_editor.h +++ b/editor/code_editor.h @@ -162,7 +162,10 @@ class CodeTextEditor : public VBoxContainer { int error_line; int error_column; + bool settings_changed = false; + void _on_settings_change(); + void _apply_settings_change(); void _update_text_editor_theme(); void _update_font(); diff --git a/editor/connections_dialog.cpp b/editor/connections_dialog.cpp index c79a8d9a0e..c773f51342 100644 --- a/editor/connections_dialog.cpp +++ b/editor/connections_dialog.cpp @@ -134,7 +134,7 @@ void ConnectDialog::ok_pressed() { return; } } - emit_signal("connected"); + emit_signal(SNAME("connected")); hide(); } @@ -360,7 +360,7 @@ void ConnectDialog::init(ConnectionData c, bool bEdit) { void ConnectDialog::popup_dialog(const String &p_for_signal) { from_signal->set_text(p_for_signal); - error_label->add_theme_color_override("font_color", error_label->get_theme_color("error_color", "Editor")); + error_label->add_theme_color_override("font_color", error_label->get_theme_color(SNAME("error_color"), SNAME("Editor"))); if (!advanced->is_pressed()) { error_label->set_visible(!_find_first_script(get_tree()->get_edited_scene_root(), get_tree()->get_edited_scene_root())); } @@ -509,13 +509,13 @@ ConnectDialog::~ConnectDialog() { // Originally copied and adapted from EditorProperty, try to keep style in sync. Control *ConnectionsDockTree::make_custom_tooltip(const String &p_text) const { EditorHelpBit *help_bit = memnew(EditorHelpBit); - help_bit->add_theme_style_override("panel", get_theme_stylebox("panel", "TooltipPanel")); + help_bit->add_theme_style_override("panel", get_theme_stylebox(SNAME("panel"), SNAME("TooltipPanel"))); help_bit->get_rich_text()->set_fixed_size_to_width(360 * EDSCALE); String text = TTR("Signal:") + " [u][b]" + p_text.get_slice("::", 0) + "[/b][/u]"; text += p_text.get_slice("::", 1).strip_edges() + "\n"; text += p_text.get_slice("::", 2).strip_edges(); - help_bit->call_deferred("set_text", text); //hack so it uses proper theme once inside scene + help_bit->call_deferred(SNAME("set_text"), text); //hack so it uses proper theme once inside scene return help_bit; } @@ -591,7 +591,7 @@ void ConnectionsDock::_make_or_edit_connection() { it = nullptr; if (add_script_function) { - editor->emit_signal("script_add_function_request", target, cToMake.method, script_function_args); + editor->emit_signal(SNAME("script_add_function_request"), target, cToMake.method, script_function_args); hide(); } @@ -921,14 +921,14 @@ void ConnectionsDock::update_tree() { } } else { ClassDB::get_signal_list(base, &node_signals2, true); - if (has_theme_icon(base, "EditorIcons")) { - icon = get_theme_icon(base, "EditorIcons"); + if (has_theme_icon(base, SNAME("EditorIcons"))) { + icon = get_theme_icon(base, SNAME("EditorIcons")); } name = base; } if (!icon.is_valid()) { - icon = get_theme_icon("Object", "EditorIcons"); + icon = get_theme_icon(SNAME("Object"), SNAME("EditorIcons")); } TreeItem *section_item = nullptr; @@ -940,13 +940,11 @@ void ConnectionsDock::update_tree() { section_item->set_icon(0, icon); section_item->set_selectable(0, false); section_item->set_editable(0, false); - section_item->set_custom_bg_color(0, get_theme_color("prop_subsection", "Editor")); + section_item->set_custom_bg_color(0, get_theme_color(SNAME("prop_subsection"), SNAME("Editor"))); node_signals2.sort(); } - for (List<MethodInfo>::Element *E = node_signals2.front(); E; E = E->next()) { - MethodInfo &mi = E->get(); - + for (MethodInfo &mi : node_signals2) { StringName signal_name = mi.name; String signaldesc = "("; PackedStringArray argnames; @@ -982,7 +980,7 @@ void ConnectionsDock::update_tree() { sinfo["name"] = signal_name; sinfo["args"] = argnames; signal_item->set_metadata(0, sinfo); - signal_item->set_icon(0, get_theme_icon("Signal", "EditorIcons")); + signal_item->set_icon(0, get_theme_icon(SNAME("Signal"), SNAME("EditorIcons"))); // Set tooltip with the signal's documentation. { @@ -1025,8 +1023,8 @@ void ConnectionsDock::update_tree() { List<Object::Connection> connections; selectedNode->get_signal_connection_list(signal_name, &connections); - for (List<Object::Connection>::Element *F = connections.front(); F; F = F->next()) { - Connection cn = F->get(); + for (const Object::Connection &F : connections) { + Connection cn = F; if (!(cn.flags & CONNECT_PERSIST)) { continue; } @@ -1059,7 +1057,7 @@ void ConnectionsDock::update_tree() { connection_item->set_text(0, path); Connection cd = c; connection_item->set_metadata(0, cd); - connection_item->set_icon(0, get_theme_icon("Slot", "EditorIcons")); + connection_item->set_icon(0, get_theme_icon(SNAME("Slot"), SNAME("EditorIcons"))); } } @@ -1083,7 +1081,7 @@ ConnectionsDock::ConnectionsDock(EditorNode *p_editor) { search_box = memnew(LineEdit); search_box->set_h_size_flags(Control::SIZE_EXPAND_FILL); search_box->set_placeholder(TTR("Filter signals")); - search_box->set_right_icon(get_theme_icon("Search", "EditorIcons")); + search_box->set_right_icon(get_theme_icon(SNAME("Search"), SNAME("EditorIcons"))); search_box->set_clear_button_enabled(true); search_box->connect("text_changed", callable_mp(this, &ConnectionsDock::_filter_changed)); vbc->add_child(search_box); diff --git a/editor/create_dialog.cpp b/editor/create_dialog.cpp index 027cee3f1c..3389b53317 100644 --- a/editor/create_dialog.cpp +++ b/editor/create_dialog.cpp @@ -40,7 +40,7 @@ void CreateDialog::popup_create(bool p_dont_clear, bool p_replace_mode, const String &p_select_type) { _fill_type_list(); - icon_fallback = search_options->has_theme_icon(base_type, "EditorIcons") ? base_type : "Object"; + icon_fallback = search_options->has_theme_icon(base_type, SNAME("EditorIcons")) ? base_type : "Object"; if (p_dont_clear) { search_box->select_all(); @@ -168,7 +168,7 @@ void CreateDialog::_update_search() { TreeItem *root = search_options->create_item(); root->set_text(0, base_type); - root->set_icon(0, search_options->get_theme_icon(icon_fallback, "EditorIcons")); + root->set_icon(0, search_options->get_theme_icon(icon_fallback, SNAME("EditorIcons"))); search_options_types[base_type] = root; _configure_search_option_item(root, base_type, ClassDB::class_exists(base_type)); @@ -195,7 +195,8 @@ void CreateDialog::_update_search() { select_type(_top_result(candidates, search_text)); } else { favorite->set_disabled(true); - help_bit->set_text(""); + help_bit->set_text(vformat(TTR("No results for \"%s\"."), search_text)); + help_bit->get_rich_text()->set_self_modulate(Color(1, 1, 1, 0.5)); get_ok_button()->set_disabled(true); search_options->deselect_all(); } @@ -236,7 +237,7 @@ void CreateDialog::_configure_search_option_item(TreeItem *r_item, const String bool can_instantiate = (p_cpp_type && ClassDB::can_instantiate(p_type)) || !p_cpp_type; if (!can_instantiate) { - r_item->set_custom_color(0, search_options->get_theme_color("disabled_font_color", "Editor")); + r_item->set_custom_color(0, search_options->get_theme_color(SNAME("disabled_font_color"), SNAME("Editor"))); r_item->set_icon(0, EditorNode::get_singleton()->get_class_icon(p_type, "NodeDisabled")); r_item->set_selectable(0, false); } else { @@ -338,7 +339,7 @@ void CreateDialog::_confirmed() { memdelete(f); } - emit_signal("create"); + emit_signal(SNAME("create")); hide(); _cleanup(); } @@ -366,16 +367,16 @@ void CreateDialog::_notification(int p_what) { switch (p_what) { case NOTIFICATION_ENTER_TREE: { connect("confirmed", callable_mp(this, &CreateDialog::_confirmed)); - search_box->set_right_icon(search_options->get_theme_icon("Search", "EditorIcons")); + search_box->set_right_icon(search_options->get_theme_icon(SNAME("Search"), SNAME("EditorIcons"))); search_box->set_clear_button_enabled(true); - favorite->set_icon(search_options->get_theme_icon("Favorites", "EditorIcons")); + favorite->set_icon(search_options->get_theme_icon(SNAME("Favorites"), SNAME("EditorIcons"))); } break; case NOTIFICATION_EXIT_TREE: { disconnect("confirmed", callable_mp(this, &CreateDialog::_confirmed)); } break; case NOTIFICATION_VISIBILITY_CHANGED: { if (is_visible()) { - search_box->call_deferred("grab_focus"); // still not visible + search_box->call_deferred(SNAME("grab_focus")); // still not visible search_box->select_all(); } else { EditorSettings::get_singleton()->get_project_metadata("dialog_bounds", "create_new_node", Rect2(get_position(), get_size())); @@ -393,8 +394,15 @@ void CreateDialog::select_type(const String &p_type) { to_select->select(0); search_options->scroll_to_item(to_select); - if (EditorHelp::get_doc_data()->class_list.has(p_type)) { - help_bit->set_text(DTR(EditorHelp::get_doc_data()->class_list[p_type].brief_description)); + if (EditorHelp::get_doc_data()->class_list.has(p_type) && !DTR(EditorHelp::get_doc_data()->class_list[p_type].brief_description).is_empty()) { + // Display both class name and description, since the help bit may be displayed + // far away from the location (especially if the dialog was resized to be taller). + help_bit->set_text(vformat("[b]%s[/b]: %s", p_type, DTR(EditorHelp::get_doc_data()->class_list[p_type].brief_description))); + help_bit->get_rich_text()->set_self_modulate(Color(1, 1, 1, 1)); + } else { + // Use nested `vformat()` as translators shouldn't interfere with BBCode tags. + help_bit->set_text(vformat(TTR("No description available for %s."), vformat("[b]%s[/b]", p_type))); + help_bit->get_rich_text()->set_self_modulate(Color(1, 1, 1, 0.5)); } favorite->set_disabled(false); @@ -439,8 +447,7 @@ Variant CreateDialog::instance_selected() { List<PropertyInfo> pinfo; ((Object *)obj)->get_property_list(&pinfo); - for (List<PropertyInfo>::Element *E = pinfo.front(); E; E = E->next()) { - PropertyInfo pi = E->get(); + for (const PropertyInfo &pi : pinfo) { if (pi.type == Variant::OBJECT && pi.usage & PROPERTY_USAGE_EDITOR_INSTANTIATE_OBJECT) { Object *prop = ClassDB::instantiate(pi.class_name); ((Object *)obj)->set(pi.name, prop); @@ -607,7 +614,7 @@ void CreateDialog::_save_and_update_favorite_list() { memdelete(f); } - emit_signal("favorites_updated"); + emit_signal(SNAME("favorites_updated")); } void CreateDialog::_load_favorites_and_history() { diff --git a/editor/debugger/editor_debugger_inspector.cpp b/editor/debugger/editor_debugger_inspector.cpp index 6035cc072e..a1eb71235c 100644 --- a/editor/debugger/editor_debugger_inspector.cpp +++ b/editor/debugger/editor_debugger_inspector.cpp @@ -41,7 +41,7 @@ bool EditorDebuggerRemoteObject::_set(const StringName &p_name, const Variant &p } prop_values[p_name] = p_value; - emit_signal("value_edited", remote_object_id, p_name, p_value); + emit_signal(SNAME("value_edited"), remote_object_id, p_name, p_value); return true; } @@ -56,8 +56,8 @@ bool EditorDebuggerRemoteObject::_get(const StringName &p_name, Variant &r_ret) void EditorDebuggerRemoteObject::_get_property_list(List<PropertyInfo> *p_list) const { p_list->clear(); //sorry, no want category - for (const List<PropertyInfo>::Element *E = prop_list.front(); E; E = E->next()) { - p_list->push_back(E->get()); + for (const PropertyInfo &E : prop_list) { + p_list->push_back(E); } } @@ -114,11 +114,11 @@ void EditorDebuggerInspector::_notification(int p_what) { } void EditorDebuggerInspector::_object_edited(ObjectID p_id, const String &p_prop, const Variant &p_value) { - emit_signal("object_edited", p_id, p_prop, p_value); + emit_signal(SNAME("object_edited"), p_id, p_prop, p_value); } void EditorDebuggerInspector::_object_selected(ObjectID p_object) { - emit_signal("object_selected", p_object); + emit_signal(SNAME("object_selected"), p_object); } ObjectID EditorDebuggerInspector::add_object(const Array &p_arr) { @@ -190,7 +190,7 @@ ObjectID EditorDebuggerInspector::add_object(const Array &p_arr) { if (old_prop_size == debugObj->prop_list.size() && new_props_added == 0) { //only some may have changed, if so, then update those, if exist for (Set<String>::Element *E = changed.front(); E; E = E->next()) { - emit_signal("object_property_updated", debugObj->remote_object_id, E->get()); + emit_signal(SNAME("object_property_updated"), debugObj->remote_object_id, E->get()); } } else { //full update, because props were added or removed diff --git a/editor/debugger/editor_debugger_node.cpp b/editor/debugger/editor_debugger_node.cpp index 5f90680115..690ce98cb9 100644 --- a/editor/debugger/editor_debugger_node.cpp +++ b/editor/debugger/editor_debugger_node.cpp @@ -55,8 +55,8 @@ EditorDebuggerNode::EditorDebuggerNode() { singleton = this; } - add_theme_constant_override("margin_left", -EditorNode::get_singleton()->get_gui_base()->get_theme_stylebox("BottomPanelDebuggerOverride", "EditorStyles")->get_margin(SIDE_LEFT)); - add_theme_constant_override("margin_right", -EditorNode::get_singleton()->get_gui_base()->get_theme_stylebox("BottomPanelDebuggerOverride", "EditorStyles")->get_margin(SIDE_RIGHT)); + add_theme_constant_override("margin_left", -EditorNode::get_singleton()->get_gui_base()->get_theme_stylebox(SNAME("BottomPanelDebuggerOverride"), SNAME("EditorStyles"))->get_margin(SIDE_LEFT)); + add_theme_constant_override("margin_right", -EditorNode::get_singleton()->get_gui_base()->get_theme_stylebox(SNAME("BottomPanelDebuggerOverride"), SNAME("EditorStyles"))->get_margin(SIDE_RIGHT)); tabs = memnew(TabContainer); tabs->set_tab_align(TabContainer::ALIGN_LEFT); @@ -112,7 +112,7 @@ ScriptEditorDebugger *EditorDebuggerNode::_add_debugger() { if (tabs->get_tab_count() > 1) { node->clear_style(); tabs->set_tabs_visible(true); - tabs->add_theme_style_override("panel", EditorNode::get_singleton()->get_gui_base()->get_theme_stylebox("DebuggerPanel", "EditorStyles")); + tabs->add_theme_style_override("panel", EditorNode::get_singleton()->get_gui_base()->get_theme_stylebox(SNAME("DebuggerPanel"), SNAME("EditorStyles"))); } if (!debugger_plugins.is_empty()) { @@ -135,7 +135,7 @@ void EditorDebuggerNode::_stack_frame_selected(int p_debugger) { void EditorDebuggerNode::_error_selected(const String &p_file, int p_line, int p_debugger) { Ref<Script> s = ResourceLoader::load(p_file); - emit_signal("goto_script_line", s, p_line - 1); + emit_signal(SNAME("goto_script_line"), s, p_line - 1); } void EditorDebuggerNode::_text_editor_stack_goto(const ScriptEditorDebugger *p_debugger) { @@ -145,8 +145,8 @@ void EditorDebuggerNode::_text_editor_stack_goto(const ScriptEditorDebugger *p_d } stack_script = ResourceLoader::load(file); const int line = p_debugger->get_stack_script_line() - 1; - emit_signal("goto_script_line", stack_script, line); - emit_signal("set_execution", stack_script, line); + emit_signal(SNAME("goto_script_line"), stack_script, line); + emit_signal(SNAME("set_execution"), stack_script, line); stack_script.unref(); // Why?!? } @@ -226,10 +226,10 @@ void EditorDebuggerNode::_notification(int p_what) { switch (p_what) { case EditorSettings::NOTIFICATION_EDITOR_SETTINGS_CHANGED: { if (tabs->get_tab_count() > 1) { - add_theme_constant_override("margin_left", -EditorNode::get_singleton()->get_gui_base()->get_theme_stylebox("BottomPanelDebuggerOverride", "EditorStyles")->get_margin(SIDE_LEFT)); - add_theme_constant_override("margin_right", -EditorNode::get_singleton()->get_gui_base()->get_theme_stylebox("BottomPanelDebuggerOverride", "EditorStyles")->get_margin(SIDE_RIGHT)); + add_theme_constant_override("margin_left", -EditorNode::get_singleton()->get_gui_base()->get_theme_stylebox(SNAME("BottomPanelDebuggerOverride"), SNAME("EditorStyles"))->get_margin(SIDE_LEFT)); + add_theme_constant_override("margin_right", -EditorNode::get_singleton()->get_gui_base()->get_theme_stylebox(SNAME("BottomPanelDebuggerOverride"), SNAME("EditorStyles"))->get_margin(SIDE_RIGHT)); - tabs->add_theme_style_override("panel", EditorNode::get_singleton()->get_gui_base()->get_theme_stylebox("DebuggerPanel", "EditorStyles")); + tabs->add_theme_style_override("panel", EditorNode::get_singleton()->get_gui_base()->get_theme_stylebox(SNAME("DebuggerPanel"), SNAME("EditorStyles"))); } } break; case NOTIFICATION_READY: { @@ -268,11 +268,11 @@ void EditorDebuggerNode::_notification(int p_what) { } else { debugger_button->set_text(TTR("Debugger") + " (" + itos(error_count + warning_count) + ")"); if (error_count >= 1 && warning_count >= 1) { - debugger_button->set_icon(get_theme_icon("ErrorWarning", "EditorIcons")); + debugger_button->set_icon(get_theme_icon(SNAME("ErrorWarning"), SNAME("EditorIcons"))); } else if (error_count >= 1) { - debugger_button->set_icon(get_theme_icon("Error", "EditorIcons")); + debugger_button->set_icon(get_theme_icon(SNAME("Error"), SNAME("EditorIcons"))); } else { - debugger_button->set_icon(get_theme_icon("Warning", "EditorIcons")); + debugger_button->set_icon(get_theme_icon(SNAME("Warning"), SNAME("EditorIcons"))); } } last_error_count = error_count; @@ -359,7 +359,7 @@ void EditorDebuggerNode::_debugger_wants_stop(int p_id) { // Ask editor to kill PID. int pid = get_debugger(p_id)->get_remote_pid(); if (pid) { - EditorNode::get_singleton()->call_deferred("stop_child_process", pid); + EditorNode::get_singleton()->call_deferred(SNAME("stop_child_process"), pid); } } @@ -475,7 +475,7 @@ void EditorDebuggerNode::_breaked(bool p_breaked, bool p_can_debug, int p_debugg } _break_state_changed(); EditorNode::get_singleton()->get_pause_button()->set_pressed(p_breaked); - emit_signal("breaked", p_breaked, p_can_debug); + emit_signal(SNAME("breaked"), p_breaked, p_can_debug); } bool EditorDebuggerNode::is_skip_breakpoints() const { diff --git a/editor/debugger/editor_debugger_node.h b/editor/debugger/editor_debugger_node.h index 3510ac0726..9a40383c17 100644 --- a/editor/debugger/editor_debugger_node.h +++ b/editor/debugger/editor_debugger_node.h @@ -123,7 +123,7 @@ protected: void _save_node_requested(ObjectID p_id, const String &p_file, int p_debugger); void _clear_execution(REF p_script) { - emit_signal("clear_execution", p_script); + emit_signal(SNAME("clear_execution"), p_script); } void _text_editor_stack_goto(const ScriptEditorDebugger *p_debugger); diff --git a/editor/debugger/editor_debugger_tree.cpp b/editor/debugger/editor_debugger_tree.cpp index ec92edc795..1feab98948 100644 --- a/editor/debugger/editor_debugger_tree.cpp +++ b/editor/debugger/editor_debugger_tree.cpp @@ -75,7 +75,7 @@ void EditorDebuggerTree::_scene_tree_selected() { inspected_object_id = uint64_t(item->get_metadata(0)); - emit_signal("object_selected", inspected_object_id, debugger_id); + emit_signal(SNAME("object_selected"), inspected_object_id, debugger_id); } void EditorDebuggerTree::_scene_tree_folded(Object *p_obj) { @@ -105,8 +105,8 @@ void EditorDebuggerTree::_scene_tree_rmb_selected(const Vector2 &p_position) { item->select(0); item_menu->clear(); - item_menu->add_icon_item(get_theme_icon("CreateNewSceneFrom", "EditorIcons"), TTR("Save Branch as Scene"), ITEM_MENU_SAVE_REMOTE_NODE); - item_menu->add_icon_item(get_theme_icon("CopyNodePath", "EditorIcons"), TTR("Copy Node Path"), ITEM_MENU_COPY_NODE_PATH); + item_menu->add_icon_item(get_theme_icon(SNAME("CreateNewSceneFrom"), SNAME("EditorIcons")), TTR("Save Branch as Scene"), ITEM_MENU_SAVE_REMOTE_NODE); + item_menu->add_icon_item(get_theme_icon(SNAME("CopyNodePath"), SNAME("EditorIcons")), TTR("Copy Node Path"), ITEM_MENU_COPY_NODE_PATH); item_menu->set_position(get_screen_transform().xform(get_local_mouse_position())); item_menu->popup(); } @@ -211,7 +211,7 @@ void EditorDebuggerTree::update_scene_tree(const SceneDebuggerTree *p_tree, int } debugger_id = p_debugger; // Needed by hook, could be avoided if every debugger had its own tree if (scroll_item) { - call_deferred("scroll_to_item", scroll_item); + call_deferred(SNAME("scroll_to_item"), scroll_item); } last_filter = filter; updating_scene_tree = false; @@ -279,5 +279,5 @@ void EditorDebuggerTree::_file_selected(const String &p_file) { if (inspected_object_id.is_null()) { return; } - emit_signal("save_node", inspected_object_id, p_file, debugger_id); + emit_signal(SNAME("save_node"), inspected_object_id, p_file, debugger_id); } diff --git a/editor/debugger/editor_network_profiler.cpp b/editor/debugger/editor_network_profiler.cpp index 1c781c4d98..9479fbd5d4 100644 --- a/editor/debugger/editor_network_profiler.cpp +++ b/editor/debugger/editor_network_profiler.cpp @@ -40,14 +40,14 @@ void EditorNetworkProfiler::_bind_methods() { void EditorNetworkProfiler::_notification(int p_what) { if (p_what == NOTIFICATION_ENTER_TREE || p_what == NOTIFICATION_THEME_CHANGED) { - activate->set_icon(get_theme_icon("Play", "EditorIcons")); - clear_button->set_icon(get_theme_icon("Clear", "EditorIcons")); - incoming_bandwidth_text->set_right_icon(get_theme_icon("ArrowDown", "EditorIcons")); - outgoing_bandwidth_text->set_right_icon(get_theme_icon("ArrowUp", "EditorIcons")); + activate->set_icon(get_theme_icon(SNAME("Play"), SNAME("EditorIcons"))); + clear_button->set_icon(get_theme_icon(SNAME("Clear"), SNAME("EditorIcons"))); + incoming_bandwidth_text->set_right_icon(get_theme_icon(SNAME("ArrowDown"), SNAME("EditorIcons"))); + outgoing_bandwidth_text->set_right_icon(get_theme_icon(SNAME("ArrowUp"), SNAME("EditorIcons"))); // This needs to be done here to set the faded color when the profiler is first opened - incoming_bandwidth_text->add_theme_color_override("font_uneditable_color", get_theme_color("font_color", "Editor") * Color(1, 1, 1, 0.5)); - outgoing_bandwidth_text->add_theme_color_override("font_uneditable_color", get_theme_color("font_color", "Editor") * Color(1, 1, 1, 0.5)); + incoming_bandwidth_text->add_theme_color_override("font_uneditable_color", get_theme_color(SNAME("font_color"), SNAME("Editor")) * Color(1, 1, 1, 0.5)); + outgoing_bandwidth_text->add_theme_color_override("font_uneditable_color", get_theme_color(SNAME("font_color"), SNAME("Editor")) * Color(1, 1, 1, 0.5)); } } @@ -73,13 +73,13 @@ void EditorNetworkProfiler::_update_frame() { void EditorNetworkProfiler::_activate_pressed() { if (activate->is_pressed()) { - activate->set_icon(get_theme_icon("Stop", "EditorIcons")); + activate->set_icon(get_theme_icon(SNAME("Stop"), SNAME("EditorIcons"))); activate->set_text(TTR("Stop")); } else { - activate->set_icon(get_theme_icon("Play", "EditorIcons")); + activate->set_icon(get_theme_icon(SNAME("Play"), SNAME("EditorIcons"))); activate->set_text(TTR("Start")); } - emit_signal("enable_profiling", activate->is_pressed()); + emit_signal(SNAME("enable_profiling"), activate->is_pressed()); } void EditorNetworkProfiler::_clear_pressed() { @@ -114,10 +114,10 @@ void EditorNetworkProfiler::set_bandwidth(int p_incoming, int p_outgoing) { // Make labels more prominent when the bandwidth is greater than 0 to attract user attention incoming_bandwidth_text->add_theme_color_override( "font_uneditable_color", - get_theme_color("font_color", "Editor") * Color(1, 1, 1, p_incoming > 0 ? 1 : 0.5)); + get_theme_color(SNAME("font_color"), SNAME("Editor")) * Color(1, 1, 1, p_incoming > 0 ? 1 : 0.5)); outgoing_bandwidth_text->add_theme_color_override( "font_uneditable_color", - get_theme_color("font_color", "Editor") * Color(1, 1, 1, p_outgoing > 0 ? 1 : 0.5)); + get_theme_color(SNAME("font_color"), SNAME("Editor")) * Color(1, 1, 1, p_outgoing > 0 ? 1 : 0.5)); } bool EditorNetworkProfiler::is_profiling() { diff --git a/editor/debugger/editor_performance_profiler.cpp b/editor/debugger/editor_performance_profiler.cpp index 08609080c5..08ed675d16 100644 --- a/editor/debugger/editor_performance_profiler.cpp +++ b/editor/debugger/editor_performance_profiler.cpp @@ -109,9 +109,9 @@ void EditorPerformanceProfiler::_monitor_draw() { info_message->hide(); - Ref<StyleBox> graph_style_box = get_theme_stylebox("normal", "TextEdit"); - Ref<Font> graph_font = get_theme_font("font", "TextEdit"); - int font_size = get_theme_font_size("font_size", "TextEdit"); + Ref<StyleBox> graph_style_box = get_theme_stylebox(SNAME("normal"), SNAME("TextEdit")); + Ref<Font> graph_font = get_theme_font(SNAME("font"), SNAME("TextEdit")); + int font_size = get_theme_font_size(SNAME("font_size"), SNAME("TextEdit")); int columns = int(Math::ceil(Math::sqrt(float(active.size())))); int rows = int(Math::ceil(float(active.size()) / float(columns))); @@ -130,7 +130,7 @@ void EditorPerformanceProfiler::_monitor_draw() { rect.position += graph_style_box->get_offset(); rect.size -= graph_style_box->get_minimum_size(); - Color draw_color = get_theme_color("accent_color", "Editor"); + Color draw_color = get_theme_color(SNAME("accent_color"), SNAME("Editor")); draw_color.set_hsv(Math::fmod(hue_shift * float(current.frame_index), 0.9f), draw_color.get_s() * 0.9f, draw_color.get_v() * value_multiplier, 0.6f); monitor_draw->draw_string(graph_font, rect.position + Point2(0, graph_font->get_ascent(font_size)), current.item->get_text(0), HALIGN_LEFT, rect.size.x, font_size, draw_color); @@ -271,7 +271,7 @@ void EditorPerformanceProfiler::_marker_input(const Ref<InputEvent> &p_event) { } else { marker_key = ""; } - Ref<StyleBox> graph_style_box = get_theme_stylebox("normal", "TextEdit"); + Ref<StyleBox> graph_style_box = get_theme_stylebox(SNAME("normal"), SNAME("TextEdit")); rect.position += graph_style_box->get_offset(); rect.size -= graph_style_box->get_minimum_size(); Vector2 point = mb->get_position() - rect.position; diff --git a/editor/debugger/editor_profiler.cpp b/editor/debugger/editor_profiler.cpp index 5f4d1b6f36..fa9c9f61f5 100644 --- a/editor/debugger/editor_profiler.cpp +++ b/editor/debugger/editor_profiler.cpp @@ -135,11 +135,11 @@ String EditorProfiler::_get_time_as_text(const Metric &m, float p_time, int p_ca } Color EditorProfiler::_get_color_from_signature(const StringName &p_signature) const { - Color bc = get_theme_color("error_color", "Editor"); + Color bc = get_theme_color(SNAME("error_color"), SNAME("Editor")); double rot = ABS(double(p_signature.hash()) / double(0x7FFFFFFF)); Color c; c.set_hsv(rot, bc.get_s(), bc.get_v()); - return c.lerp(get_theme_color("base_color", "Editor"), 0.07); + return c.lerp(get_theme_color(SNAME("base_color"), SNAME("Editor")), 0.07); } void EditorProfiler::_item_edited() { @@ -180,7 +180,7 @@ void EditorProfiler::_update_plot() { } uint8_t *wr = graph_image.ptrw(); - const Color background_color = get_theme_color("dark_color_2", "Editor"); + const Color background_color = get_theme_color(SNAME("dark_color_2"), SNAME("Editor")); // Clear the previous frame and set the background color. for (int i = 0; i < desired_len; i += 4) { @@ -356,7 +356,7 @@ void EditorProfiler::_update_frame() { item->set_metadata(1, it.script); item->set_metadata(2, it.line); item->set_text_align(2, TreeItem::ALIGN_RIGHT); - item->set_tooltip(0, it.script + ":" + itos(it.line)); + item->set_tooltip(0, it.name + "\n" + it.script + ":" + itos(it.line)); float time = dtime == DISPLAY_SELF_TIME ? it.self : it.total; @@ -376,14 +376,14 @@ void EditorProfiler::_update_frame() { void EditorProfiler::_activate_pressed() { if (activate->is_pressed()) { - activate->set_icon(get_theme_icon("Stop", "EditorIcons")); + activate->set_icon(get_theme_icon(SNAME("Stop"), SNAME("EditorIcons"))); activate->set_text(TTR("Stop")); _clear_pressed(); } else { - activate->set_icon(get_theme_icon("Play", "EditorIcons")); + activate->set_icon(get_theme_icon(SNAME("Play"), SNAME("EditorIcons"))); activate->set_text(TTR("Start")); } - emit_signal("enable_profiling", activate->is_pressed()); + emit_signal(SNAME("enable_profiling"), activate->is_pressed()); } void EditorProfiler::_clear_pressed() { @@ -394,8 +394,8 @@ void EditorProfiler::_clear_pressed() { void EditorProfiler::_notification(int p_what) { if (p_what == NOTIFICATION_ENTER_TREE || p_what == NOTIFICATION_LAYOUT_DIRECTION_CHANGED || p_what == NOTIFICATION_TRANSLATION_CHANGED) { - activate->set_icon(get_theme_icon("Play", "EditorIcons")); - clear_button->set_icon(get_theme_icon("Clear", "EditorIcons")); + activate->set_icon(get_theme_icon(SNAME("Play"), SNAME("EditorIcons"))); + clear_button->set_icon(get_theme_icon(SNAME("Clear"), SNAME("EditorIcons"))); } } @@ -462,7 +462,7 @@ void EditorProfiler::_graph_tex_input(const Ref<InputEvent> &p_ev) { if (activate->is_pressed()) { if (!seeking) { - emit_signal("break_request"); + emit_signal(SNAME("break_request")); } } @@ -588,8 +588,8 @@ EditorProfiler::EditorProfiler() { hb->add_child(memnew(Label(TTR("Measure:")))); display_mode = memnew(OptionButton); - display_mode->add_item(TTR("Frame Time (sec)")); - display_mode->add_item(TTR("Average Time (sec)")); + display_mode->add_item(TTR("Frame Time (ms)")); + display_mode->add_item(TTR("Average Time (ms)")); display_mode->add_item(TTR("Frame %")); display_mode->add_item(TTR("Physics Frame %")); display_mode->connect("item_selected", callable_mp(this, &EditorProfiler::_combo_changed)); @@ -601,6 +601,7 @@ EditorProfiler::EditorProfiler() { display_time = memnew(OptionButton); display_time->add_item(TTR("Inclusive")); display_time->add_item(TTR("Self")); + display_time->set_tooltip(TTR("Inclusive: Includes time from other functions called by this function.\nUse this to spot bottlenecks.\n\nSelf: Only count the time spent in the function itself, not in other functions called by that function.\nUse this to find individual functions to optimize.")); display_time->connect("item_selected", callable_mp(this, &EditorProfiler::_combo_changed)); hb->add_child(display_time); diff --git a/editor/debugger/editor_visual_profiler.cpp b/editor/debugger/editor_visual_profiler.cpp index a0e8a3bd35..f17ad0d36c 100644 --- a/editor/debugger/editor_visual_profiler.cpp +++ b/editor/debugger/editor_visual_profiler.cpp @@ -123,11 +123,11 @@ String EditorVisualProfiler::_get_time_as_text(float p_time) { } Color EditorVisualProfiler::_get_color_from_signature(const StringName &p_signature) const { - Color bc = get_theme_color("error_color", "Editor"); + Color bc = get_theme_color(SNAME("error_color"), SNAME("Editor")); double rot = ABS(double(p_signature.hash()) / double(0x7FFFFFFF)); Color c; c.set_hsv(rot, bc.get_s(), bc.get_v()); - return c.lerp(get_theme_color("base_color", "Editor"), 0.07); + return c.lerp(get_theme_color(SNAME("base_color"), SNAME("Editor")), 0.07); } void EditorVisualProfiler::_item_selected() { @@ -318,7 +318,7 @@ void EditorVisualProfiler::_update_plot() { void EditorVisualProfiler::_update_frame(bool p_focus_selected) { int cursor_metric = _get_cursor_index(); - Ref<Texture> track_icon = get_theme_icon("TrackColor", "EditorIcons"); + Ref<Texture> track_icon = get_theme_icon(SNAME("TrackColor"), SNAME("EditorIcons")); ERR_FAIL_INDEX(cursor_metric, frame_metrics.size()); @@ -365,13 +365,13 @@ void EditorVisualProfiler::_update_frame(bool p_focus_selected) { } TreeItem *category = variables->create_item(parent); - for (List<TreeItem *>::Element *E = stack.front(); E; E = E->next()) { - float total_cpu = E->get()->get_metadata(1); - float total_gpu = E->get()->get_metadata(2); + for (TreeItem *E : stack) { + float total_cpu = E->get_metadata(1); + float total_gpu = E->get_metadata(2); total_cpu += cpu_time; total_gpu += gpu_time; - E->get()->set_metadata(1, cpu_time); - E->get()->set_metadata(2, gpu_time); + E->set_metadata(1, cpu_time); + E->set_metadata(2, gpu_time); } category->set_icon(0, track_icon); @@ -392,11 +392,11 @@ void EditorVisualProfiler::_update_frame(bool p_focus_selected) { } } - for (List<TreeItem *>::Element *E = categories.front(); E; E = E->next()) { - float total_cpu = E->get()->get_metadata(1); - float total_gpu = E->get()->get_metadata(2); - E->get()->set_text(1, _get_time_as_text(total_cpu)); - E->get()->set_text(2, _get_time_as_text(total_gpu)); + for (TreeItem *E : categories) { + float total_cpu = E->get_metadata(1); + float total_gpu = E->get_metadata(2); + E->set_text(1, _get_time_as_text(total_cpu)); + E->set_text(2, _get_time_as_text(total_gpu)); } if (ensure_selected) { @@ -407,14 +407,14 @@ void EditorVisualProfiler::_update_frame(bool p_focus_selected) { void EditorVisualProfiler::_activate_pressed() { if (activate->is_pressed()) { - activate->set_icon(get_theme_icon("Stop", "EditorIcons")); + activate->set_icon(get_theme_icon(SNAME("Stop"), SNAME("EditorIcons"))); activate->set_text(TTR("Stop")); _clear_pressed(); //always clear on start } else { - activate->set_icon(get_theme_icon("Play", "EditorIcons")); + activate->set_icon(get_theme_icon(SNAME("Play"), SNAME("EditorIcons"))); activate->set_text(TTR("Start")); } - emit_signal("enable_profiling", activate->is_pressed()); + emit_signal(SNAME("enable_profiling"), activate->is_pressed()); } void EditorVisualProfiler::_clear_pressed() { @@ -425,11 +425,11 @@ void EditorVisualProfiler::_clear_pressed() { void EditorVisualProfiler::_notification(int p_what) { if (p_what == NOTIFICATION_ENTER_TREE || p_what == NOTIFICATION_LAYOUT_DIRECTION_CHANGED || p_what == NOTIFICATION_TRANSLATION_CHANGED) { if (is_layout_rtl()) { - activate->set_icon(get_theme_icon("PlayBackwards", "EditorIcons")); + activate->set_icon(get_theme_icon(SNAME("PlayBackwards"), SNAME("EditorIcons"))); } else { - activate->set_icon(get_theme_icon("Play", "EditorIcons")); + activate->set_icon(get_theme_icon(SNAME("Play"), SNAME("EditorIcons"))); } - clear_button->set_icon(get_theme_icon("Clear", "EditorIcons")); + clear_button->set_icon(get_theme_icon(SNAME("Clear"), SNAME("EditorIcons"))); } } @@ -437,8 +437,8 @@ void EditorVisualProfiler::_graph_tex_draw() { if (last_metric < 0) { return; } - Ref<Font> font = get_theme_font("font", "Label"); - int font_size = get_theme_font_size("font_size", "Label"); + Ref<Font> font = get_theme_font(SNAME("font"), SNAME("Label")); + int font_size = get_theme_font_size(SNAME("font_size"), SNAME("Label")); if (seeking) { int max_frames = frame_metrics.size(); int frame = cursor_metric_edit->get_value() - (frame_metrics[last_metric].frame_number - max_frames + 1); diff --git a/editor/debugger/script_editor_debugger.cpp b/editor/debugger/script_editor_debugger.cpp index 09bbf846fe..9856fbec74 100644 --- a/editor/debugger/script_editor_debugger.cpp +++ b/editor/debugger/script_editor_debugger.cpp @@ -87,9 +87,9 @@ void ScriptEditorDebugger::debug_copy() { void ScriptEditorDebugger::debug_skip_breakpoints() { skip_breakpoints_value = !skip_breakpoints_value; if (skip_breakpoints_value) { - skip_breakpoints->set_icon(get_theme_icon("DebugSkipBreakpointsOn", "EditorIcons")); + skip_breakpoints->set_icon(get_theme_icon(SNAME("DebugSkipBreakpointsOn"), SNAME("EditorIcons"))); } else { - skip_breakpoints->set_icon(get_theme_icon("DebugSkipBreakpointsOff", "EditorIcons")); + skip_breakpoints->set_icon(get_theme_icon(SNAME("DebugSkipBreakpointsOff"), SNAME("EditorIcons"))); } Array msg; @@ -136,11 +136,11 @@ void ScriptEditorDebugger::update_tabs() { } else { errors_tab->set_name(TTR("Errors") + " (" + itos(error_count + warning_count) + ")"); if (error_count >= 1 && warning_count >= 1) { - tabs->set_tab_icon(errors_tab->get_index(), get_theme_icon("ErrorWarning", "EditorIcons")); + tabs->set_tab_icon(errors_tab->get_index(), get_theme_icon(SNAME("ErrorWarning"), SNAME("EditorIcons"))); } else if (error_count >= 1) { - tabs->set_tab_icon(errors_tab->get_index(), get_theme_icon("Error", "EditorIcons")); + tabs->set_tab_icon(errors_tab->get_index(), get_theme_icon(SNAME("Error"), SNAME("EditorIcons"))); } else { - tabs->set_tab_icon(errors_tab->get_index(), get_theme_icon("Warning", "EditorIcons")); + tabs->set_tab_icon(errors_tab->get_index(), get_theme_icon(SNAME("Warning"), SNAME("EditorIcons"))); } } } @@ -264,7 +264,7 @@ Object *ScriptEditorDebugger::get_remote_object(ObjectID p_id) { } void ScriptEditorDebugger::_remote_object_selected(ObjectID p_id) { - emit_signal("remote_object_requested", p_id); + emit_signal(SNAME("remote_object_requested"), p_id); } void ScriptEditorDebugger::_remote_object_edited(ObjectID p_id, const String &p_prop, const Variant &p_value) { @@ -273,7 +273,7 @@ void ScriptEditorDebugger::_remote_object_edited(ObjectID p_id, const String &p_ } void ScriptEditorDebugger::_remote_object_property_updated(ObjectID p_id, const String &p_property) { - emit_signal("remote_object_property_updated", p_id, p_property); + emit_signal(SNAME("remote_object_property_updated"), p_id, p_property); } void ScriptEditorDebugger::_video_mem_request() { @@ -305,7 +305,7 @@ void ScriptEditorDebugger::_parse_message(const String &p_msg, const Array &p_da can_debug = can_continue; _update_buttons_state(); _set_reason_text(error, MESSAGE_ERROR); - emit_signal("breaked", true, can_continue); + emit_signal(SNAME("breaked"), true, can_continue); DisplayServer::get_singleton()->window_move_to_foreground(); if (error != "") { tabs->set_current_tab(0); @@ -319,7 +319,7 @@ void ScriptEditorDebugger::_parse_message(const String &p_msg, const Array &p_da _clear_execution(); _update_buttons_state(); _set_reason_text(TTR("Execution resumed."), MESSAGE_SUCCESS); - emit_signal("breaked", false, false); + emit_signal(SNAME("breaked"), false, false); profiler->set_enabled(true); profiler->disable_seeking(); } else if (p_msg == "set_pid") { @@ -332,12 +332,12 @@ void ScriptEditorDebugger::_parse_message(const String &p_msg, const Array &p_da } else if (p_msg == "scene:scene_tree") { scene_tree->nodes.clear(); scene_tree->deserialize(p_data); - emit_signal("remote_tree_updated"); + emit_signal(SNAME("remote_tree_updated")); _update_buttons_state(); } else if (p_msg == "scene:inspect_object") { ObjectID id = inspector->add_object(p_data); if (id.is_valid()) { - emit_signal("remote_object_updated", id); + emit_signal(SNAME("remote_object_updated"), id); } } else if (p_msg == "memory:usage") { vmem_tree->clear(); @@ -347,18 +347,18 @@ void ScriptEditorDebugger::_parse_message(const String &p_msg, const Array &p_da uint64_t total = 0; - for (List<DebuggerMarshalls::ResourceInfo>::Element *E = usage.infos.front(); E; E = E->next()) { + for (const DebuggerMarshalls::ResourceInfo &E : usage.infos) { TreeItem *it = vmem_tree->create_item(root); - String type = E->get().type; - int bytes = E->get().vram; - it->set_text(0, E->get().path); + String type = E.type; + int bytes = E.vram; + it->set_text(0, E.path); it->set_text(1, type); - it->set_text(2, E->get().format); + it->set_text(2, E.format); it->set_text(3, String::humanize_size(bytes)); total += bytes; - if (has_theme_icon(type, "EditorIcons")) { - it->set_icon(0, get_theme_icon(type, "EditorIcons")); + if (has_theme_icon(type, SNAME("EditorIcons"))) { + it->set_icon(0, get_theme_icon(type, SNAME("EditorIcons"))); } } @@ -698,7 +698,7 @@ void ScriptEditorDebugger::_parse_message(const String &p_msg, const Array &p_da network_profiler->set_bandwidth(p_data[0], p_data[1]); } else if (p_msg == "request_quit") { - emit_signal("stop_requested"); + emit_signal(SNAME("stop_requested")); _stop_and_notify(); } else if (p_msg == "performance:profile_names") { @@ -739,13 +739,13 @@ void ScriptEditorDebugger::_parse_message(const String &p_msg, const Array &p_da void ScriptEditorDebugger::_set_reason_text(const String &p_reason, MessageType p_type) { switch (p_type) { case MESSAGE_ERROR: - reason->add_theme_color_override("font_color", get_theme_color("error_color", "Editor")); + reason->add_theme_color_override("font_color", get_theme_color(SNAME("error_color"), SNAME("Editor"))); break; case MESSAGE_WARNING: - reason->add_theme_color_override("font_color", get_theme_color("warning_color", "Editor")); + reason->add_theme_color_override("font_color", get_theme_color(SNAME("warning_color"), SNAME("Editor"))); break; default: - reason->add_theme_color_override("font_color", get_theme_color("success_color", "Editor")); + reason->add_theme_color_override("font_color", get_theme_color(SNAME("success_color"), SNAME("Editor"))); } reason->set_text(p_reason); reason->set_tooltip(p_reason.word_wrap(80)); @@ -754,21 +754,21 @@ void ScriptEditorDebugger::_set_reason_text(const String &p_reason, MessageType void ScriptEditorDebugger::_notification(int p_what) { switch (p_what) { case NOTIFICATION_ENTER_TREE: { - skip_breakpoints->set_icon(get_theme_icon("DebugSkipBreakpointsOff", "EditorIcons")); - copy->set_icon(get_theme_icon("ActionCopy", "EditorIcons")); + skip_breakpoints->set_icon(get_theme_icon(SNAME("DebugSkipBreakpointsOff"), SNAME("EditorIcons"))); + copy->set_icon(get_theme_icon(SNAME("ActionCopy"), SNAME("EditorIcons"))); - step->set_icon(get_theme_icon("DebugStep", "EditorIcons")); - next->set_icon(get_theme_icon("DebugNext", "EditorIcons")); - dobreak->set_icon(get_theme_icon("Pause", "EditorIcons")); - docontinue->set_icon(get_theme_icon("DebugContinue", "EditorIcons")); + step->set_icon(get_theme_icon(SNAME("DebugStep"), SNAME("EditorIcons"))); + next->set_icon(get_theme_icon(SNAME("DebugNext"), SNAME("EditorIcons"))); + dobreak->set_icon(get_theme_icon(SNAME("Pause"), SNAME("EditorIcons"))); + docontinue->set_icon(get_theme_icon(SNAME("DebugContinue"), SNAME("EditorIcons"))); le_set->connect("pressed", callable_mp(this, &ScriptEditorDebugger::_live_edit_set)); le_clear->connect("pressed", callable_mp(this, &ScriptEditorDebugger::_live_edit_clear)); error_tree->connect("item_selected", callable_mp(this, &ScriptEditorDebugger::_error_selected)); error_tree->connect("item_activated", callable_mp(this, &ScriptEditorDebugger::_error_activated)); - vmem_refresh->set_icon(get_theme_icon("Reload", "EditorIcons")); - vmem_export->set_icon(get_theme_icon("Save", "EditorIcons")); + vmem_refresh->set_icon(get_theme_icon(SNAME("Reload"), SNAME("EditorIcons"))); + vmem_export->set_icon(get_theme_icon(SNAME("Save"), SNAME("EditorIcons"))); - reason->add_theme_color_override("font_color", get_theme_color("error_color", "Editor")); + reason->add_theme_color_override("font_color", get_theme_color(SNAME("error_color"), SNAME("Editor"))); } break; case NOTIFICATION_PROCESS: { @@ -793,7 +793,7 @@ void ScriptEditorDebugger::_notification(int p_what) { } else if (camera_override >= CameraOverride::OVERRIDE_3D_1) { int viewport_idx = camera_override - CameraOverride::OVERRIDE_3D_1; Node3DEditorViewport *viewport = Node3DEditor::get_singleton()->get_editor_viewport(viewport_idx); - Camera3D *const cam = viewport->get_camera(); + Camera3D *const cam = viewport->get_camera_3d(); Array msg; msg.push_back(cam->get_camera_transform()); @@ -831,16 +831,16 @@ void ScriptEditorDebugger::_notification(int p_what) { } break; case EditorSettings::NOTIFICATION_EDITOR_SETTINGS_CHANGED: { if (tabs->has_theme_stylebox_override("panel")) { - tabs->add_theme_style_override("panel", editor->get_gui_base()->get_theme_stylebox("DebuggerPanel", "EditorStyles")); + tabs->add_theme_style_override("panel", editor->get_gui_base()->get_theme_stylebox(SNAME("DebuggerPanel"), SNAME("EditorStyles"))); } - copy->set_icon(get_theme_icon("ActionCopy", "EditorIcons")); - step->set_icon(get_theme_icon("DebugStep", "EditorIcons")); - next->set_icon(get_theme_icon("DebugNext", "EditorIcons")); - dobreak->set_icon(get_theme_icon("Pause", "EditorIcons")); - docontinue->set_icon(get_theme_icon("DebugContinue", "EditorIcons")); - vmem_refresh->set_icon(get_theme_icon("Reload", "EditorIcons")); - vmem_export->set_icon(get_theme_icon("Save", "EditorIcons")); + copy->set_icon(get_theme_icon(SNAME("ActionCopy"), SNAME("EditorIcons"))); + step->set_icon(get_theme_icon(SNAME("DebugStep"), SNAME("EditorIcons"))); + next->set_icon(get_theme_icon(SNAME("DebugNext"), SNAME("EditorIcons"))); + dobreak->set_icon(get_theme_icon(SNAME("Pause"), SNAME("EditorIcons"))); + docontinue->set_icon(get_theme_icon(SNAME("DebugContinue"), SNAME("EditorIcons"))); + vmem_refresh->set_icon(get_theme_icon(SNAME("Reload"), SNAME("EditorIcons"))); + vmem_export->set_icon(get_theme_icon(SNAME("Save"), SNAME("EditorIcons"))); } break; } } @@ -854,7 +854,7 @@ void ScriptEditorDebugger::_clear_execution() { Dictionary d = ti->get_metadata(0); stack_script = ResourceLoader::load(d["file"]); - emit_signal("clear_execution", stack_script); + emit_signal(SNAME("clear_execution"), stack_script); stack_script.unref(); stack_dump->clear(); inspector->clear_stack_variables(); @@ -878,7 +878,7 @@ void ScriptEditorDebugger::start(Ref<RemoteDebuggerPeer> p_peer) { tabs->set_current_tab(0); _set_reason_text(TTR("Debug session started."), MESSAGE_SUCCESS); _update_buttons_state(); - emit_signal("started"); + emit_signal(SNAME("started")); } void ScriptEditorDebugger::_update_buttons_state() { @@ -896,7 +896,7 @@ void ScriptEditorDebugger::_update_buttons_state() { void ScriptEditorDebugger::_stop_and_notify() { stop(); - emit_signal("stopped"); + emit_signal(SNAME("stopped")); _set_reason_text(TTR("Debug session closed."), MESSAGE_WARNING); } @@ -959,7 +959,7 @@ void ScriptEditorDebugger::_profiler_seeked() { } void ScriptEditorDebugger::_stack_dump_frame_selected() { - emit_signal("stack_frame_selected"); + emit_signal(SNAME("stack_frame_selected")); int frame = get_stack_script_frame(); @@ -1332,7 +1332,7 @@ void ScriptEditorDebugger::_error_selected() { return; } - emit_signal("error_selected", String(meta[0]), int(meta[1])); + emit_signal(SNAME("error_selected"), String(meta[0]), int(meta[1])); } void ScriptEditorDebugger::_expand_errors_list() { @@ -1373,8 +1373,8 @@ void ScriptEditorDebugger::_error_tree_item_rmb_selected(const Vector2 &p_pos) { item_menu->set_size(Size2(1, 1)); if (error_tree->is_anything_selected()) { - item_menu->add_icon_item(get_theme_icon("ActionCopy", "EditorIcons"), TTR("Copy Error"), ACTION_COPY_ERROR); - item_menu->add_icon_item(get_theme_icon("Instance", "EditorIcons"), TTR("Open C++ Source on GitHub"), ACTION_OPEN_SOURCE); + item_menu->add_icon_item(get_theme_icon(SNAME("ActionCopy"), SNAME("EditorIcons")), TTR("Copy Error"), ACTION_COPY_ERROR); + item_menu->add_icon_item(get_theme_icon(SNAME("Instance"), SNAME("EditorIcons")), TTR("Open C++ Source on GitHub"), ACTION_OPEN_SOURCE); } if (item_menu->get_item_count() > 0) { @@ -1393,9 +1393,9 @@ void ScriptEditorDebugger::_item_menu_id_pressed(int p_option) { String type; - if (ti->get_icon(0) == get_theme_icon("Warning", "EditorIcons")) { + if (ti->get_icon(0) == get_theme_icon(SNAME("Warning"), SNAME("EditorIcons"))) { type = "W "; - } else if (ti->get_icon(0) == get_theme_icon("Error", "EditorIcons")) { + } else if (ti->get_icon(0) == get_theme_icon(SNAME("Error"), SNAME("EditorIcons"))) { type = "E "; } @@ -1518,7 +1518,7 @@ ScriptEditorDebugger::ScriptEditorDebugger(EditorNode *p_editor) { tabs = memnew(TabContainer); tabs->set_tab_align(TabContainer::ALIGN_LEFT); - tabs->add_theme_style_override("panel", editor->get_gui_base()->get_theme_stylebox("DebuggerPanel", "EditorStyles")); + tabs->add_theme_style_override("panel", editor->get_gui_base()->get_theme_stylebox(SNAME("DebuggerPanel"), SNAME("EditorStyles"))); tabs->connect("tab_changed", callable_mp(this, &ScriptEditorDebugger::_tab_changed)); add_child(tabs); diff --git a/editor/dependency_editor.cpp b/editor/dependency_editor.cpp index e26344f3ec..069ae2c7f2 100644 --- a/editor/dependency_editor.cpp +++ b/editor/dependency_editor.cpp @@ -55,8 +55,8 @@ void DependencyEditor::_load_pressed(Object *p_item, int p_cell, int p_button) { search->clear_filters(); List<String> ext; ResourceLoader::get_recognized_extensions_for_type(ti->get_metadata(0), &ext); - for (List<String>::Element *E = ext.front(); E; E = E->next()) { - search->add_filter("*" + E->get()); + for (const String &E : ext) { + search->add_filter("*" + E); } search->popup_file_dialog(); } @@ -120,13 +120,13 @@ void DependencyEditor::_fix_all() { Map<String, Map<String, String>> candidates; - for (List<String>::Element *E = missing.front(); E; E = E->next()) { - String base = E->get().get_file(); + for (const String &E : missing) { + String base = E.get_file(); if (!candidates.has(base)) { candidates[base] = Map<String, String>(); } - candidates[base][E->get()] = ""; + candidates[base][E] = ""; } _fix_and_find(EditorFileSystem::get_singleton()->get_filesystem(), candidates); @@ -162,14 +162,12 @@ void DependencyEditor::_update_list() { TreeItem *root = tree->create_item(); - Ref<Texture2D> folder = tree->get_theme_icon("folder", "FileDialog"); + Ref<Texture2D> folder = tree->get_theme_icon(SNAME("folder"), SNAME("FileDialog")); bool broken = false; - for (List<String>::Element *E = deps.front(); E; E = E->next()) { + for (const String &n : deps) { TreeItem *item = tree->create_item(root); - - String n = E->get(); String path; String type; @@ -180,6 +178,15 @@ void DependencyEditor::_update_list() { path = n; type = "Resource"; } + + ResourceUID::ID uid = ResourceUID::get_singleton()->text_to_id(path); + if (uid != ResourceUID::INVALID_ID) { + // dependency is in uid format, obtain proper path + ERR_CONTINUE(!ResourceUID::get_singleton()->has_id(uid)); + + path = ResourceUID::get_singleton()->get_id_path(uid); + } + String name = path.get_file(); Ref<Texture2D> icon = EditorNode::get_singleton()->get_class_icon(type); @@ -278,7 +285,7 @@ void DependencyEditorOwners::_select_file(int p_idx) { if (ResourceLoader::get_resource_type(fpath) == "PackedScene") { editor->open_request(fpath); hide(); - emit_signal("confirmed"); + emit_signal(SNAME("confirmed")); } } @@ -412,17 +419,17 @@ void DependencyRemoveDialog::_build_removed_dependency_tree(const Vector<Removed if (!tree_items.has(rd.dependency_folder)) { TreeItem *folder_item = owners->create_item(owners->get_root()); folder_item->set_text(0, rd.dependency_folder); - folder_item->set_icon(0, owners->get_theme_icon("Folder", "EditorIcons")); + folder_item->set_icon(0, owners->get_theme_icon(SNAME("Folder"), SNAME("EditorIcons"))); tree_items[rd.dependency_folder] = folder_item; } TreeItem *dependency_item = owners->create_item(tree_items[rd.dependency_folder]); dependency_item->set_text(0, rd.dependency); - dependency_item->set_icon(0, owners->get_theme_icon("Warning", "EditorIcons")); + dependency_item->set_icon(0, owners->get_theme_icon(SNAME("Warning"), SNAME("EditorIcons"))); tree_items[rd.dependency] = dependency_item; } else { TreeItem *dependency_item = owners->create_item(owners->get_root()); dependency_item->set_text(0, rd.dependency); - dependency_item->set_icon(0, owners->get_theme_icon("Warning", "EditorIcons")); + dependency_item->set_icon(0, owners->get_theme_icon(SNAME("Warning"), SNAME("EditorIcons"))); tree_items[rd.dependency] = dependency_item; } } @@ -508,7 +515,7 @@ void DependencyRemoveDialog::ok_pressed() { if (err != OK) { EditorNode::get_singleton()->add_io_error(TTR("Cannot remove:") + "\n" + files_to_delete[i] + "\n"); } else { - emit_signal("file_removed", files_to_delete[i]); + emit_signal(SNAME("file_removed"), files_to_delete[i]); } } @@ -525,7 +532,7 @@ void DependencyRemoveDialog::ok_pressed() { if (err != OK) { EditorNode::get_singleton()->add_io_error(TTR("Cannot remove:") + "\n" + dirs_to_delete[i] + "\n"); } else { - emit_signal("folder_removed", dirs_to_delete[i]); + emit_signal(SNAME("folder_removed"), dirs_to_delete[i]); } } @@ -665,7 +672,7 @@ bool OrphanResourcesDialog::_fill_owners(EditorFileSystemDirectory *efsd, HashMa if (p_parent) { dir_item = files->create_item(p_parent); dir_item->set_text(0, efsd->get_subdir(i)->get_name()); - dir_item->set_icon(0, files->get_theme_icon("folder", "FileDialog")); + dir_item->set_icon(0, files->get_theme_icon(SNAME("folder"), SNAME("FileDialog"))); } bool children = _fill_owners(efsd->get_subdir(i), refs, dir_item); @@ -701,7 +708,7 @@ bool OrphanResourcesDialog::_fill_owners(EditorFileSystemDirectory *efsd, HashMa int ds = efsd->get_file_deps(i).size(); ti->set_text(1, itos(ds)); if (ds) { - ti->add_button(1, files->get_theme_icon("GuiVisibilityVisible", "EditorIcons"), -1, false, TTR("Show Dependencies")); + ti->add_button(1, files->get_theme_icon(SNAME("GuiVisibilityVisible"), SNAME("EditorIcons")), -1, false, TTR("Show Dependencies")); } ti->set_metadata(0, path); has_children = true; @@ -741,9 +748,9 @@ void OrphanResourcesDialog::_find_to_delete(TreeItem *p_item, List<String> &path void OrphanResourcesDialog::_delete_confirm() { DirAccess *da = DirAccess::create(DirAccess::ACCESS_RESOURCES); - for (List<String>::Element *E = paths.front(); E; E = E->next()) { - da->remove(E->get()); - EditorFileSystem::get_singleton()->update_file(E->get()); + for (const String &E : paths) { + da->remove(E); + EditorFileSystem::get_singleton()->update_file(E); } memdelete(da); refresh(); diff --git a/editor/doc_tools.cpp b/editor/doc_tools.cpp index befafec6cb..c752d0d4fd 100644 --- a/editor/doc_tools.cpp +++ b/editor/doc_tools.cpp @@ -266,20 +266,20 @@ void DocTools::generate(bool p_basic_types) { } List<PropertyInfo>::Element *EO = own_properties.front(); - for (List<PropertyInfo>::Element *E = properties.front(); E; E = E->next()) { + for (const PropertyInfo &E : properties) { bool inherited = EO == nullptr; - if (EO && EO->get() == E->get()) { + if (EO && EO->get() == E) { inherited = false; EO = EO->next(); } - if (E->get().usage & PROPERTY_USAGE_GROUP || E->get().usage & PROPERTY_USAGE_SUBGROUP || E->get().usage & PROPERTY_USAGE_CATEGORY || E->get().usage & PROPERTY_USAGE_INTERNAL) { + if (E.usage & PROPERTY_USAGE_GROUP || E.usage & PROPERTY_USAGE_SUBGROUP || E.usage & PROPERTY_USAGE_CATEGORY || E.usage & PROPERTY_USAGE_INTERNAL) { continue; } DocData::PropertyDoc prop; - prop.name = E->get().name; + prop.name = E.name; prop.overridden = inherited; @@ -288,20 +288,20 @@ void DocTools::generate(bool p_basic_types) { if (name == "ProjectSettings") { // Special case for project settings, so that settings are not taken from the current project's settings - if (E->get().name == "script" || !ProjectSettings::get_singleton()->is_builtin_setting(E->get().name)) { + if (E.name == "script" || !ProjectSettings::get_singleton()->is_builtin_setting(E.name)) { continue; } - if (E->get().usage & PROPERTY_USAGE_EDITOR) { - if (!ProjectSettings::get_singleton()->get_ignore_value_in_docs(E->get().name)) { - default_value = ProjectSettings::get_singleton()->property_get_revert(E->get().name); + if (E.usage & PROPERTY_USAGE_EDITOR) { + if (!ProjectSettings::get_singleton()->get_ignore_value_in_docs(E.name)) { + default_value = ProjectSettings::get_singleton()->property_get_revert(E.name); default_value_valid = true; } } } else { - default_value = get_documentation_default_value(name, E->get().name, default_value_valid); + default_value = get_documentation_default_value(name, E.name, default_value_valid); if (inherited) { bool base_default_value_valid = false; - Variant base_default_value = get_documentation_default_value(ClassDB::get_parent_class(name), E->get().name, base_default_value_valid); + Variant base_default_value = get_documentation_default_value(ClassDB::get_parent_class(name), E.name, base_default_value_valid); if (!default_value_valid || !base_default_value_valid || default_value == base_default_value) { continue; } @@ -309,13 +309,13 @@ void DocTools::generate(bool p_basic_types) { } //used to track uninitialized values using valgrind - //print_line("getting default value for " + String(name) + "." + String(E->get().name)); + //print_line("getting default value for " + String(name) + "." + String(E.name)); if (default_value_valid && default_value.get_type() != Variant::OBJECT) { prop.default_value = default_value.get_construct_string().replace("\n", ""); } - StringName setter = ClassDB::get_property_setter(name, E->get().name); - StringName getter = ClassDB::get_property_getter(name, E->get().name); + StringName setter = ClassDB::get_property_setter(name, E.name); + StringName getter = ClassDB::get_property_getter(name, E.name); prop.setter = setter; prop.getter = getter; @@ -353,10 +353,10 @@ void DocTools::generate(bool p_basic_types) { } if (!found_type) { - if (E->get().type == Variant::OBJECT && E->get().hint == PROPERTY_HINT_RESOURCE_TYPE) { - prop.type = E->get().hint_string; + if (E.type == Variant::OBJECT && E.hint == PROPERTY_HINT_RESOURCE_TYPE) { + prop.type = E.hint_string; } else { - prop.type = Variant::get_type_name(E->get().type); + prop.type = Variant::get_type_name(E.type); } } @@ -367,62 +367,62 @@ void DocTools::generate(bool p_basic_types) { ClassDB::get_method_list(name, &method_list, true); method_list.sort(); - for (List<MethodInfo>::Element *E = method_list.front(); E; E = E->next()) { - if (E->get().name == "" || (E->get().name[0] == '_' && !(E->get().flags & METHOD_FLAG_VIRTUAL))) { + for (const MethodInfo &E : method_list) { + if (E.name == "" || (E.name[0] == '_' && !(E.flags & METHOD_FLAG_VIRTUAL))) { continue; //hidden, don't count } - if (skip_setter_getter_methods && setters_getters.has(E->get().name)) { + if (skip_setter_getter_methods && setters_getters.has(E.name)) { // Don't skip parametric setters and getters, i.e. method which require // one or more parameters to define what property should be set or retrieved. // E.g. CPUParticles3D::set_param(Parameter param, float value). - if (E->get().arguments.size() == 0 /* getter */ || (E->get().arguments.size() == 1 && E->get().return_val.type == Variant::NIL /* setter */)) { + if (E.arguments.size() == 0 /* getter */ || (E.arguments.size() == 1 && E.return_val.type == Variant::NIL /* setter */)) { continue; } } DocData::MethodDoc method; - method.name = E->get().name; + method.name = E.name; - if (E->get().flags & METHOD_FLAG_VIRTUAL) { + if (E.flags & METHOD_FLAG_VIRTUAL) { method.qualifiers = "virtual"; } - if (E->get().flags & METHOD_FLAG_CONST) { + if (E.flags & METHOD_FLAG_CONST) { if (method.qualifiers != "") { method.qualifiers += " "; } method.qualifiers += "const"; } - if (E->get().flags & METHOD_FLAG_VARARG) { + if (E.flags & METHOD_FLAG_VARARG) { if (method.qualifiers != "") { method.qualifiers += " "; } method.qualifiers += "vararg"; } - if (E->get().flags & METHOD_FLAG_STATIC) { + if (E.flags & METHOD_FLAG_STATIC) { if (method.qualifiers != "") { method.qualifiers += " "; } method.qualifiers += "static"; } - for (int i = -1; i < E->get().arguments.size(); i++) { + for (int i = -1; i < E.arguments.size(); i++) { if (i == -1) { #ifdef DEBUG_METHODS_ENABLED - DocData::return_doc_from_retinfo(method, E->get().return_val); + DocData::return_doc_from_retinfo(method, E.return_val); #endif } else { - const PropertyInfo &arginfo = E->get().arguments[i]; + const PropertyInfo &arginfo = E.arguments[i]; DocData::ArgumentDoc argument; DocData::argument_doc_from_arginfo(argument, arginfo); - int darg_idx = i - (E->get().arguments.size() - E->get().default_arguments.size()); + int darg_idx = i - (E.arguments.size() - E.default_arguments.size()); if (darg_idx >= 0) { - Variant default_arg = E->get().default_arguments[darg_idx]; + Variant default_arg = E.default_arguments[darg_idx]; argument.default_value = default_arg.get_construct_string(); } @@ -455,12 +455,12 @@ void DocTools::generate(bool p_basic_types) { List<String> constant_list; ClassDB::get_integer_constant_list(name, &constant_list, true); - for (List<String>::Element *E = constant_list.front(); E; E = E->next()) { + for (const String &E : constant_list) { DocData::ConstantDoc constant; - constant.name = E->get(); - constant.value = itos(ClassDB::get_integer_constant(name, E->get())); + constant.name = E; + constant.value = itos(ClassDB::get_integer_constant(name, E)); constant.is_value_valid = true; - constant.enumeration = ClassDB::get_integer_constant_enum(name, E->get()); + constant.enumeration = ClassDB::get_integer_constant_enum(name, E); c.constants.push_back(constant); } @@ -469,53 +469,53 @@ void DocTools::generate(bool p_basic_types) { { List<StringName> l; Theme::get_default()->get_constant_list(cname, &l); - for (List<StringName>::Element *E = l.front(); E; E = E->next()) { + for (const StringName &E : l) { DocData::PropertyDoc pd; - pd.name = E->get(); + pd.name = E; pd.type = "int"; - pd.default_value = itos(Theme::get_default()->get_constant(E->get(), cname)); + pd.default_value = itos(Theme::get_default()->get_constant(E, cname)); c.theme_properties.push_back(pd); } l.clear(); Theme::get_default()->get_color_list(cname, &l); - for (List<StringName>::Element *E = l.front(); E; E = E->next()) { + for (const StringName &E : l) { DocData::PropertyDoc pd; - pd.name = E->get(); + pd.name = E; pd.type = "Color"; - pd.default_value = Variant(Theme::get_default()->get_color(E->get(), cname)).get_construct_string(); + pd.default_value = Variant(Theme::get_default()->get_color(E, cname)).get_construct_string(); c.theme_properties.push_back(pd); } l.clear(); Theme::get_default()->get_icon_list(cname, &l); - for (List<StringName>::Element *E = l.front(); E; E = E->next()) { + for (const StringName &E : l) { DocData::PropertyDoc pd; - pd.name = E->get(); + pd.name = E; pd.type = "Texture2D"; c.theme_properties.push_back(pd); } l.clear(); Theme::get_default()->get_font_list(cname, &l); - for (List<StringName>::Element *E = l.front(); E; E = E->next()) { + for (const StringName &E : l) { DocData::PropertyDoc pd; - pd.name = E->get(); + pd.name = E; pd.type = "Font"; c.theme_properties.push_back(pd); } l.clear(); Theme::get_default()->get_font_size_list(cname, &l); - for (List<StringName>::Element *E = l.front(); E; E = E->next()) { + for (const StringName &E : l) { DocData::PropertyDoc pd; - pd.name = E->get(); + pd.name = E; pd.type = "int"; c.theme_properties.push_back(pd); } l.clear(); Theme::get_default()->get_stylebox_list(cname, &l); - for (List<StringName>::Element *E = l.front(); E; E = E->next()) { + for (const StringName &E : l) { DocData::PropertyDoc pd; - pd.name = E->get(); + pd.name = E; pd.type = "StyleBox"; c.theme_properties.push_back(pd); } @@ -621,8 +621,7 @@ void DocTools::generate(bool p_basic_types) { method_list.push_back(mi); } - for (List<MethodInfo>::Element *E = method_list.front(); E; E = E->next()) { - MethodInfo &mi = E->get(); + for (const MethodInfo &mi : method_list) { DocData::MethodDoc method; method.name = mi.name; @@ -675,8 +674,7 @@ void DocTools::generate(bool p_basic_types) { List<PropertyInfo> properties; v.get_property_list(&properties); - for (List<PropertyInfo>::Element *E = properties.front(); E; E = E->next()) { - PropertyInfo pi = E->get(); + for (const PropertyInfo &pi : properties) { DocData::PropertyDoc property; property.name = pi.name; property.type = Variant::get_type_name(pi.type); @@ -688,10 +686,10 @@ void DocTools::generate(bool p_basic_types) { List<StringName> constants; Variant::get_constants_for_type(Variant::Type(i), &constants); - for (List<StringName>::Element *E = constants.front(); E; E = E->next()) { + for (const StringName &E : constants) { DocData::ConstantDoc constant; - constant.name = E->get(); - Variant value = Variant::get_constant_value(Variant::Type(i), E->get()); + constant.name = E; + Variant value = Variant::get_constant_value(Variant::Type(i), E); constant.value = value.get_type() == Variant::INT ? itos(value) : value.get_construct_string(); constant.is_value_valid = true; c.constants.push_back(constant); @@ -723,9 +721,8 @@ void DocTools::generate(bool p_basic_types) { Engine::get_singleton()->get_singletons(&singletons); //servers (this is kind of hackish) - for (List<Engine::Singleton>::Element *E = singletons.front(); E; E = E->next()) { + for (const Engine::Singleton &s : singletons) { DocData::PropertyDoc pd; - Engine::Singleton &s = E->get(); if (!s.ptr) { continue; } @@ -743,13 +740,13 @@ void DocTools::generate(bool p_basic_types) { List<StringName> utility_functions; Variant::get_utility_function_list(&utility_functions); utility_functions.sort_custom<StringName::AlphCompare>(); - for (List<StringName>::Element *E = utility_functions.front(); E; E = E->next()) { + for (const StringName &E : utility_functions) { DocData::MethodDoc md; - md.name = E->get(); + md.name = E; //return - if (Variant::has_utility_function_return_value(E->get())) { + if (Variant::has_utility_function_return_value(E)) { PropertyInfo pi; - pi.type = Variant::get_utility_function_return_type(E->get()); + pi.type = Variant::get_utility_function_return_type(E); if (pi.type == Variant::NIL) { pi.usage = PROPERTY_USAGE_NIL_IS_VARIANT; } @@ -758,13 +755,13 @@ void DocTools::generate(bool p_basic_types) { md.return_type = ad.type; } - if (Variant::is_utility_function_vararg(E->get())) { + if (Variant::is_utility_function_vararg(E)) { md.qualifiers = "vararg"; } else { - for (int i = 0; i < Variant::get_utility_function_argument_count(E->get()); i++) { + for (int i = 0; i < Variant::get_utility_function_argument_count(E); i++) { PropertyInfo pi; - pi.type = Variant::get_utility_function_argument_type(E->get(), i); - pi.name = Variant::get_utility_function_argument_name(E->get(), i); + pi.type = Variant::get_utility_function_argument_type(E, i); + pi.name = Variant::get_utility_function_argument_name(E, i); if (pi.type == Variant::NIL) { pi.usage = PROPERTY_USAGE_NIL_IS_VARIANT; } @@ -793,8 +790,7 @@ void DocTools::generate(bool p_basic_types) { List<MethodInfo> minfo; lang->get_public_functions(&minfo); - for (List<MethodInfo>::Element *E = minfo.front(); E; E = E->next()) { - MethodInfo &mi = E->get(); + for (const MethodInfo &mi : minfo) { DocData::MethodDoc md; md.name = mi.name; @@ -813,7 +809,7 @@ void DocTools::generate(bool p_basic_types) { int darg_idx = j - (mi.arguments.size() - mi.default_arguments.size()); if (darg_idx >= 0) { - Variant default_arg = E->get().default_arguments[darg_idx]; + Variant default_arg = mi.default_arguments[darg_idx]; ad.default_value = default_arg.get_construct_string(); } @@ -827,10 +823,10 @@ void DocTools::generate(bool p_basic_types) { List<Pair<String, Variant>> cinfo; lang->get_public_constants(&cinfo); - for (List<Pair<String, Variant>>::Element *E = cinfo.front(); E; E = E->next()) { + for (const Pair<String, Variant> &E : cinfo) { DocData::ConstantDoc cd; - cd.name = E->get().first; - cd.value = E->get().second; + cd.name = E.first; + cd.value = E.second; cd.is_value_valid = true; c.constants.push_back(cd); } @@ -1212,8 +1208,7 @@ Error DocTools::save_classes(const String &p_default_path, const Map<String, Str if (m.return_enum != String()) { enum_text = " enum=\"" + m.return_enum + "\""; } - _write_string(f, 3, "<return type=\"" + m.return_type + "\"" + enum_text + ">"); - _write_string(f, 3, "</return>"); + _write_string(f, 3, "<return type=\"" + m.return_type + "\"" + enum_text + " />"); } for (int j = 0; j < m.arguments.size(); j++) { @@ -1225,12 +1220,10 @@ Error DocTools::save_classes(const String &p_default_path, const Map<String, Str } if (a.default_value != "") { - _write_string(f, 3, "<argument index=\"" + itos(j) + "\" name=\"" + a.name.xml_escape() + "\" type=\"" + a.type.xml_escape() + "\"" + enum_text + " default=\"" + a.default_value.xml_escape(true) + "\">"); + _write_string(f, 3, "<argument index=\"" + itos(j) + "\" name=\"" + a.name.xml_escape() + "\" type=\"" + a.type.xml_escape() + "\"" + enum_text + " default=\"" + a.default_value.xml_escape(true) + "\" />"); } else { - _write_string(f, 3, "<argument index=\"" + itos(j) + "\" name=\"" + a.name.xml_escape() + "\" type=\"" + a.type.xml_escape() + "\"" + enum_text + ">"); + _write_string(f, 3, "<argument index=\"" + itos(j) + "\" name=\"" + a.name.xml_escape() + "\" type=\"" + a.type.xml_escape() + "\"" + enum_text + " />"); } - - _write_string(f, 3, "</argument>"); } _write_string(f, 3, "<description>"); @@ -1278,8 +1271,7 @@ Error DocTools::save_classes(const String &p_default_path, const Map<String, Str _write_string(f, 2, "<signal name=\"" + m.name + "\">"); for (int j = 0; j < m.arguments.size(); j++) { const DocData::ArgumentDoc &a = m.arguments[j]; - _write_string(f, 3, "<argument index=\"" + itos(j) + "\" name=\"" + a.name.xml_escape() + "\" type=\"" + a.type.xml_escape() + "\">"); - _write_string(f, 3, "</argument>"); + _write_string(f, 3, "<argument index=\"" + itos(j) + "\" name=\"" + a.name.xml_escape() + "\" type=\"" + a.type.xml_escape() + "\" />"); } _write_string(f, 3, "<description>"); diff --git a/editor/editor_about.cpp b/editor/editor_about.cpp index 1f1446a8a8..c895e2c158 100644 --- a/editor/editor_about.cpp +++ b/editor/editor_about.cpp @@ -41,15 +41,15 @@ static const String META_TEXT_TO_COPY = "text_to_copy"; void EditorAbout::_theme_changed() { - const Ref<Font> font = get_theme_font("source", "EditorFonts"); - const int font_size = get_theme_font_size("source_size", "EditorFonts"); + const Ref<Font> font = get_theme_font(SNAME("source"), SNAME("EditorFonts")); + const int font_size = get_theme_font_size(SNAME("source_size"), SNAME("EditorFonts")); _tpl_text->add_theme_font_override("normal_font", font); _tpl_text->add_theme_font_size_override("normal_font_size", font_size); _tpl_text->add_theme_constant_override("line_separation", 6 * EDSCALE); _license_text->add_theme_font_override("normal_font", font); _license_text->add_theme_font_size_override("normal_font_size", font_size); _license_text->add_theme_constant_override("line_separation", 6 * EDSCALE); - _logo->set_texture(get_theme_icon("Logo", "EditorIcons")); + _logo->set_texture(get_theme_icon(SNAME("Logo"), SNAME("EditorIcons"))); } void EditorAbout::_notification(int p_what) { diff --git a/editor/editor_asset_installer.cpp b/editor/editor_asset_installer.cpp index dc90f26d48..8dd3045887 100644 --- a/editor/editor_asset_installer.cpp +++ b/editor/editor_asset_installer.cpp @@ -132,57 +132,57 @@ void EditorAssetInstaller::open(const String &p_path, int p_depth) { Map<String, Ref<Texture2D>> extension_guess; { - extension_guess["bmp"] = tree->get_theme_icon("ImageTexture", "EditorIcons"); - extension_guess["dds"] = tree->get_theme_icon("ImageTexture", "EditorIcons"); - extension_guess["exr"] = tree->get_theme_icon("ImageTexture", "EditorIcons"); - extension_guess["hdr"] = tree->get_theme_icon("ImageTexture", "EditorIcons"); - extension_guess["jpg"] = tree->get_theme_icon("ImageTexture", "EditorIcons"); - extension_guess["jpeg"] = tree->get_theme_icon("ImageTexture", "EditorIcons"); - extension_guess["png"] = tree->get_theme_icon("ImageTexture", "EditorIcons"); - extension_guess["svg"] = tree->get_theme_icon("ImageTexture", "EditorIcons"); - extension_guess["svgz"] = tree->get_theme_icon("ImageTexture", "EditorIcons"); - extension_guess["tga"] = tree->get_theme_icon("ImageTexture", "EditorIcons"); - extension_guess["webp"] = tree->get_theme_icon("ImageTexture", "EditorIcons"); - - extension_guess["wav"] = tree->get_theme_icon("AudioStreamSample", "EditorIcons"); - extension_guess["ogg"] = tree->get_theme_icon("AudioStreamOGGVorbis", "EditorIcons"); - extension_guess["mp3"] = tree->get_theme_icon("AudioStreamMP3", "EditorIcons"); - - extension_guess["scn"] = tree->get_theme_icon("PackedScene", "EditorIcons"); - extension_guess["tscn"] = tree->get_theme_icon("PackedScene", "EditorIcons"); - extension_guess["escn"] = tree->get_theme_icon("PackedScene", "EditorIcons"); - extension_guess["dae"] = tree->get_theme_icon("PackedScene", "EditorIcons"); - extension_guess["gltf"] = tree->get_theme_icon("PackedScene", "EditorIcons"); - extension_guess["glb"] = tree->get_theme_icon("PackedScene", "EditorIcons"); - - extension_guess["gdshader"] = tree->get_theme_icon("Shader", "EditorIcons"); - extension_guess["gd"] = tree->get_theme_icon("GDScript", "EditorIcons"); + extension_guess["bmp"] = tree->get_theme_icon(SNAME("ImageTexture"), SNAME("EditorIcons")); + extension_guess["dds"] = tree->get_theme_icon(SNAME("ImageTexture"), SNAME("EditorIcons")); + extension_guess["exr"] = tree->get_theme_icon(SNAME("ImageTexture"), SNAME("EditorIcons")); + extension_guess["hdr"] = tree->get_theme_icon(SNAME("ImageTexture"), SNAME("EditorIcons")); + extension_guess["jpg"] = tree->get_theme_icon(SNAME("ImageTexture"), SNAME("EditorIcons")); + extension_guess["jpeg"] = tree->get_theme_icon(SNAME("ImageTexture"), SNAME("EditorIcons")); + extension_guess["png"] = tree->get_theme_icon(SNAME("ImageTexture"), SNAME("EditorIcons")); + extension_guess["svg"] = tree->get_theme_icon(SNAME("ImageTexture"), SNAME("EditorIcons")); + extension_guess["svgz"] = tree->get_theme_icon(SNAME("ImageTexture"), SNAME("EditorIcons")); + extension_guess["tga"] = tree->get_theme_icon(SNAME("ImageTexture"), SNAME("EditorIcons")); + extension_guess["webp"] = tree->get_theme_icon(SNAME("ImageTexture"), SNAME("EditorIcons")); + + extension_guess["wav"] = tree->get_theme_icon(SNAME("AudioStreamSample"), SNAME("EditorIcons")); + extension_guess["ogg"] = tree->get_theme_icon(SNAME("AudioStreamOGGVorbis"), SNAME("EditorIcons")); + extension_guess["mp3"] = tree->get_theme_icon(SNAME("AudioStreamMP3"), SNAME("EditorIcons")); + + extension_guess["scn"] = tree->get_theme_icon(SNAME("PackedScene"), SNAME("EditorIcons")); + extension_guess["tscn"] = tree->get_theme_icon(SNAME("PackedScene"), SNAME("EditorIcons")); + extension_guess["escn"] = tree->get_theme_icon(SNAME("PackedScene"), SNAME("EditorIcons")); + extension_guess["dae"] = tree->get_theme_icon(SNAME("PackedScene"), SNAME("EditorIcons")); + extension_guess["gltf"] = tree->get_theme_icon(SNAME("PackedScene"), SNAME("EditorIcons")); + extension_guess["glb"] = tree->get_theme_icon(SNAME("PackedScene"), SNAME("EditorIcons")); + + extension_guess["gdshader"] = tree->get_theme_icon(SNAME("Shader"), SNAME("EditorIcons")); + extension_guess["gd"] = tree->get_theme_icon(SNAME("GDScript"), SNAME("EditorIcons")); if (Engine::get_singleton()->has_singleton("GodotSharp")) { - extension_guess["cs"] = tree->get_theme_icon("CSharpScript", "EditorIcons"); + extension_guess["cs"] = tree->get_theme_icon(SNAME("CSharpScript"), SNAME("EditorIcons")); } else { // Mark C# support as unavailable. - extension_guess["cs"] = tree->get_theme_icon("ImportFail", "EditorIcons"); + extension_guess["cs"] = tree->get_theme_icon(SNAME("ImportFail"), SNAME("EditorIcons")); } - extension_guess["vs"] = tree->get_theme_icon("VisualScript", "EditorIcons"); + extension_guess["vs"] = tree->get_theme_icon(SNAME("VisualScript"), SNAME("EditorIcons")); - extension_guess["res"] = tree->get_theme_icon("Resource", "EditorIcons"); - extension_guess["tres"] = tree->get_theme_icon("Resource", "EditorIcons"); - extension_guess["atlastex"] = tree->get_theme_icon("AtlasTexture", "EditorIcons"); + extension_guess["res"] = tree->get_theme_icon(SNAME("Resource"), SNAME("EditorIcons")); + extension_guess["tres"] = tree->get_theme_icon(SNAME("Resource"), SNAME("EditorIcons")); + extension_guess["atlastex"] = tree->get_theme_icon(SNAME("AtlasTexture"), SNAME("EditorIcons")); // By default, OBJ files are imported as Mesh resources rather than PackedScenes. - extension_guess["obj"] = tree->get_theme_icon("Mesh", "EditorIcons"); - - extension_guess["txt"] = tree->get_theme_icon("TextFile", "EditorIcons"); - extension_guess["md"] = tree->get_theme_icon("TextFile", "EditorIcons"); - extension_guess["rst"] = tree->get_theme_icon("TextFile", "EditorIcons"); - extension_guess["json"] = tree->get_theme_icon("TextFile", "EditorIcons"); - extension_guess["yml"] = tree->get_theme_icon("TextFile", "EditorIcons"); - extension_guess["yaml"] = tree->get_theme_icon("TextFile", "EditorIcons"); - extension_guess["toml"] = tree->get_theme_icon("TextFile", "EditorIcons"); - extension_guess["cfg"] = tree->get_theme_icon("TextFile", "EditorIcons"); - extension_guess["ini"] = tree->get_theme_icon("TextFile", "EditorIcons"); + extension_guess["obj"] = tree->get_theme_icon(SNAME("Mesh"), SNAME("EditorIcons")); + + extension_guess["txt"] = tree->get_theme_icon(SNAME("TextFile"), SNAME("EditorIcons")); + extension_guess["md"] = tree->get_theme_icon(SNAME("TextFile"), SNAME("EditorIcons")); + extension_guess["rst"] = tree->get_theme_icon(SNAME("TextFile"), SNAME("EditorIcons")); + extension_guess["json"] = tree->get_theme_icon(SNAME("TextFile"), SNAME("EditorIcons")); + extension_guess["yml"] = tree->get_theme_icon(SNAME("TextFile"), SNAME("EditorIcons")); + extension_guess["yaml"] = tree->get_theme_icon(SNAME("TextFile"), SNAME("EditorIcons")); + extension_guess["toml"] = tree->get_theme_icon(SNAME("TextFile"), SNAME("EditorIcons")); + extension_guess["cfg"] = tree->get_theme_icon(SNAME("TextFile"), SNAME("EditorIcons")); + extension_guess["ini"] = tree->get_theme_icon(SNAME("TextFile"), SNAME("EditorIcons")); } - Ref<Texture2D> generic_extension = tree->get_theme_icon("Object", "EditorIcons"); + Ref<Texture2D> generic_extension = tree->get_theme_icon(SNAME("Object"), SNAME("EditorIcons")); unzClose(pkg); @@ -191,7 +191,7 @@ void EditorAssetInstaller::open(const String &p_path, int p_depth) { TreeItem *root = tree->create_item(); root->set_cell_mode(0, TreeItem::CELL_MODE_CHECK); root->set_checked(0, true); - root->set_icon(0, tree->get_theme_icon("folder", "FileDialog")); + root->set_icon(0, tree->get_theme_icon(SNAME("folder"), SNAME("FileDialog"))); root->set_text(0, "res://"); root->set_editable(0, true); Map<String, TreeItem *> dir_map; @@ -242,7 +242,7 @@ void EditorAssetInstaller::open(const String &p_path, int p_depth) { if (isdir) { dir_map[path] = ti; ti->set_text(0, path.get_file() + "/"); - ti->set_icon(0, tree->get_theme_icon("folder", "FileDialog")); + ti->set_icon(0, tree->get_theme_icon(SNAME("folder"), SNAME("FileDialog"))); ti->set_metadata(0, String()); } else { String file = path.get_file(); @@ -257,7 +257,7 @@ void EditorAssetInstaller::open(const String &p_path, int p_depth) { String res_path = "res://" + path; if (FileAccess::exists(res_path)) { num_file_conflicts += 1; - ti->set_custom_color(0, tree->get_theme_color("error_color", "Editor")); + ti->set_custom_color(0, tree->get_theme_color(SNAME("error_color"), SNAME("Editor"))); ti->set_tooltip(0, vformat(TTR("%s (already exists)"), res_path)); ti->set_checked(0, false); } else { diff --git a/editor/editor_audio_buses.cpp b/editor/editor_audio_buses.cpp index 3e3428ad93..5209ee06c6 100644 --- a/editor/editor_audio_buses.cpp +++ b/editor/editor_audio_buses.cpp @@ -62,44 +62,51 @@ void EditorAudioBus::_update_visible_channels() { void EditorAudioBus::_notification(int p_what) { switch (p_what) { - case NOTIFICATION_READY: { + case NOTIFICATION_ENTER_TREE: + case NOTIFICATION_THEME_CHANGED: { for (int i = 0; i < CHANNELS_MAX; i++) { - channel[i].vu_l->set_under_texture(get_theme_icon("BusVuEmpty", "EditorIcons")); - channel[i].vu_l->set_progress_texture(get_theme_icon("BusVuFull", "EditorIcons")); - channel[i].vu_r->set_under_texture(get_theme_icon("BusVuEmpty", "EditorIcons")); - channel[i].vu_r->set_progress_texture(get_theme_icon("BusVuFull", "EditorIcons")); + channel[i].vu_l->set_under_texture(get_theme_icon(SNAME("BusVuEmpty"), SNAME("EditorIcons"))); + channel[i].vu_l->set_progress_texture(get_theme_icon(SNAME("BusVuFull"), SNAME("EditorIcons"))); + channel[i].vu_r->set_under_texture(get_theme_icon(SNAME("BusVuEmpty"), SNAME("EditorIcons"))); + channel[i].vu_r->set_progress_texture(get_theme_icon(SNAME("BusVuFull"), SNAME("EditorIcons"))); channel[i].prev_active = true; } - disabled_vu = get_theme_icon("BusVuFrozen", "EditorIcons"); + disabled_vu = get_theme_icon(SNAME("BusVuFrozen"), SNAME("EditorIcons")); Color solo_color = EditorSettings::get_singleton()->is_dark_theme() ? Color(1.0, 0.89, 0.22) : Color(1.0, 0.92, 0.44); Color mute_color = EditorSettings::get_singleton()->is_dark_theme() ? Color(1.0, 0.16, 0.16) : Color(1.0, 0.44, 0.44); Color bypass_color = EditorSettings::get_singleton()->is_dark_theme() ? Color(0.13, 0.8, 1.0) : Color(0.44, 0.87, 1.0); - solo->set_icon(get_theme_icon("AudioBusSolo", "EditorIcons")); + solo->set_icon(get_theme_icon(SNAME("AudioBusSolo"), SNAME("EditorIcons"))); solo->add_theme_color_override("icon_pressed_color", solo_color); - mute->set_icon(get_theme_icon("AudioBusMute", "EditorIcons")); + mute->set_icon(get_theme_icon(SNAME("AudioBusMute"), SNAME("EditorIcons"))); mute->add_theme_color_override("icon_pressed_color", mute_color); - bypass->set_icon(get_theme_icon("AudioBusBypass", "EditorIcons")); + bypass->set_icon(get_theme_icon(SNAME("AudioBusBypass"), SNAME("EditorIcons"))); bypass->add_theme_color_override("icon_pressed_color", bypass_color); - bus_options->set_icon(get_theme_icon("GuiTabMenuHl", "EditorIcons")); + bus_options->set_icon(get_theme_icon(SNAME("GuiTabMenuHl"), SNAME("EditorIcons"))); + audio_value_preview_label->add_theme_color_override("font_color", get_theme_color(SNAME("font_color"), SNAME("TooltipLabel"))); + audio_value_preview_label->add_theme_color_override("font_shadow_color", get_theme_color(SNAME("font_shadow_color"), SNAME("TooltipLabel"))); + audio_value_preview_box->add_theme_style_override("panel", get_theme_stylebox(SNAME("panel"), SNAME("TooltipPanel"))); + } break; + + case NOTIFICATION_READY: { update_bus(); set_process(true); } break; case NOTIFICATION_DRAW: { if (is_master) { - draw_style_box(get_theme_stylebox("disabled", "Button"), Rect2(Vector2(), get_size())); + draw_style_box(get_theme_stylebox(SNAME("disabled"), SNAME("Button")), Rect2(Vector2(), get_size())); } else if (has_focus()) { - draw_style_box(get_theme_stylebox("focus", "Button"), Rect2(Vector2(), get_size())); + draw_style_box(get_theme_stylebox(SNAME("focus"), SNAME("Button")), Rect2(Vector2(), get_size())); } else { - draw_style_box(get_theme_stylebox("panel", "TabContainer"), Rect2(Vector2(), get_size())); + draw_style_box(get_theme_stylebox(SNAME("panel"), SNAME("TabContainer")), Rect2(Vector2(), get_size())); } if (get_index() != 0 && hovering_drop) { - Color accent = get_theme_color("accent_color", "Editor"); + Color accent = get_theme_color(SNAME("accent_color"), SNAME("Editor")); accent.a *= 0.7; draw_rect(Rect2(Point2(), get_size()), accent, false); } @@ -157,26 +164,7 @@ void EditorAudioBus::_notification(int p_what) { set_process(is_visible_in_tree()); } break; - case NOTIFICATION_THEME_CHANGED: { - for (int i = 0; i < CHANNELS_MAX; i++) { - channel[i].vu_l->set_under_texture(get_theme_icon("BusVuEmpty", "EditorIcons")); - channel[i].vu_l->set_progress_texture(get_theme_icon("BusVuFull", "EditorIcons")); - channel[i].vu_r->set_under_texture(get_theme_icon("BusVuEmpty", "EditorIcons")); - channel[i].vu_r->set_progress_texture(get_theme_icon("BusVuFull", "EditorIcons")); - channel[i].prev_active = true; - } - - disabled_vu = get_theme_icon("BusVuFrozen", "EditorIcons"); - - solo->set_icon(get_theme_icon("AudioBusSolo", "EditorIcons")); - mute->set_icon(get_theme_icon("AudioBusMute", "EditorIcons")); - bypass->set_icon(get_theme_icon("AudioBusBypass", "EditorIcons")); - - bus_options->set_icon(get_theme_icon("GuiTabMenuHl", "EditorIcons")); - audio_value_preview_box->add_theme_color_override("font_color", get_theme_color("font_color", "TooltipLabel")); - audio_value_preview_box->add_theme_style_override("panel", get_theme_stylebox("panel", "TooltipPanel")); - } break; case NOTIFICATION_MOUSE_EXIT: case NOTIFICATION_DRAG_END: { if (hovering_drop) { @@ -567,12 +555,12 @@ void EditorAudioBus::_effects_gui_input(Ref<InputEvent> p_event) { void EditorAudioBus::_bus_popup_pressed(int p_option) { if (p_option == 2) { // Reset volume - emit_signal("vol_reset_request"); + emit_signal(SNAME("vol_reset_request")); } else if (p_option == 1) { - emit_signal("delete_request"); + emit_signal(SNAME("delete_request")); } else if (p_option == 0) { //duplicate - emit_signal("duplicate_request", get_index()); + emit_signal(SNAME("duplicate_request"), get_index()); } } @@ -585,7 +573,7 @@ Variant EditorAudioBus::get_drag_data(const Point2 &p_point) { Panel *p = memnew(Panel); c->add_child(p); p->set_modulate(Color(1, 1, 1, 0.7)); - p->add_theme_style_override("panel", get_theme_stylebox("focus", "Button")); + p->add_theme_style_override("panel", get_theme_stylebox(SNAME("focus"), SNAME("Button"))); p->set_size(get_size()); p->set_position(-p_point); set_drag_preview(c); @@ -594,7 +582,7 @@ Variant EditorAudioBus::get_drag_data(const Point2 &p_point) { d["index"] = get_index(); if (get_index() < AudioServer::get_singleton()->get_bus_count() - 1) { - emit_signal("drop_end_request"); + emit_signal(SNAME("drop_end_request")); } return d; @@ -616,7 +604,7 @@ bool EditorAudioBus::can_drop_data(const Point2 &p_point, const Variant &p_data) void EditorAudioBus::drop_data(const Point2 &p_point, const Variant &p_data) { Dictionary d = p_data; - emit_signal("dropped", d["index"], get_index()); + emit_signal(SNAME("dropped"), d["index"], get_index()); } Variant EditorAudioBus::get_drag_data_fw(const Point2 &p_point, Control *p_from) { @@ -833,6 +821,11 @@ EditorAudioBus::EditorAudioBus(EditorAudioBuses *p_buses, bool p_is_master) { slider->set_clip_contents(false); audio_value_preview_box = memnew(Panel); + slider->add_child(audio_value_preview_box); + audio_value_preview_box->set_as_top_level(true); + audio_value_preview_box->set_mouse_filter(MOUSE_FILTER_PASS); + audio_value_preview_box->hide(); + HBoxContainer *audioprev_hbc = memnew(HBoxContainer); audioprev_hbc->set_v_size_flags(SIZE_EXPAND_FILL); audioprev_hbc->set_h_size_flags(SIZE_EXPAND_FILL); @@ -842,16 +835,8 @@ EditorAudioBus::EditorAudioBus(EditorAudioBuses *p_buses, bool p_is_master) { audio_value_preview_label->set_v_size_flags(SIZE_EXPAND_FILL); audio_value_preview_label->set_h_size_flags(SIZE_EXPAND_FILL); audio_value_preview_label->set_mouse_filter(MOUSE_FILTER_PASS); - audio_value_preview_box->add_theme_color_override("font_color", get_theme_color("font_color", "TooltipLabel")); - audioprev_hbc->add_child(audio_value_preview_label); - slider->add_child(audio_value_preview_box); - audio_value_preview_box->set_as_top_level(true); - audio_value_preview_box->add_theme_style_override("panel", get_theme_stylebox("panel", "TooltipPanel")); - audio_value_preview_box->set_mouse_filter(MOUSE_FILTER_PASS); - audio_value_preview_box->hide(); - preview_timer = memnew(Timer); preview_timer->set_wait_time(0.8f); preview_timer->set_one_shot(true); @@ -920,15 +905,15 @@ EditorAudioBus::EditorAudioBus(EditorAudioBuses *p_buses, bool p_is_master) { List<StringName> effects; ClassDB::get_inheriters_from_class("AudioEffect", &effects); effects.sort_custom<StringName::AlphCompare>(); - for (List<StringName>::Element *E = effects.front(); E; E = E->next()) { - if (!ClassDB::can_instantiate(E->get())) { + for (const StringName &E : effects) { + if (!ClassDB::can_instantiate(E)) { continue; } - Ref<Texture2D> icon = EditorNode::get_singleton()->get_class_icon(E->get()); - String name = E->get().operator String().replace("AudioEffect", ""); + Ref<Texture2D> icon = EditorNode::get_singleton()->get_class_icon(E); + String name = E.operator String().replace("AudioEffect", ""); effect_options->add_item(name); - effect_options->set_item_metadata(effect_options->get_item_count() - 1, E->get()); + effect_options->set_item_metadata(effect_options->get_item_count() - 1, E); effect_options->set_item_icon(effect_options->get_item_count() - 1, icon); } @@ -955,10 +940,10 @@ EditorAudioBus::EditorAudioBus(EditorAudioBuses *p_buses, bool p_is_master) { void EditorAudioBusDrop::_notification(int p_what) { switch (p_what) { case NOTIFICATION_DRAW: { - draw_style_box(get_theme_stylebox("normal", "Button"), Rect2(Vector2(), get_size())); + draw_style_box(get_theme_stylebox(SNAME("normal"), SNAME("Button")), Rect2(Vector2(), get_size())); if (hovering_drop) { - Color accent = get_theme_color("accent_color", "Editor"); + Color accent = get_theme_color(SNAME("accent_color"), SNAME("Editor")); accent.a *= 0.7; draw_rect(Rect2(Point2(), get_size()), accent, false); } @@ -986,7 +971,7 @@ bool EditorAudioBusDrop::can_drop_data(const Point2 &p_point, const Variant &p_d void EditorAudioBusDrop::drop_data(const Point2 &p_point, const Variant &p_data) { Dictionary d = p_data; - emit_signal("dropped", d["index"], AudioServer::get_singleton()->get_bus_count()); + emit_signal(SNAME("dropped"), d["index"], AudioServer::get_singleton()->get_bus_count()); } void EditorAudioBusDrop::_bind_methods() { @@ -1026,7 +1011,7 @@ void EditorAudioBuses::_notification(int p_what) { switch (p_what) { case NOTIFICATION_ENTER_TREE: case NOTIFICATION_THEME_CHANGED: { - bus_scroll->add_theme_style_override("bg", get_theme_stylebox("bg", "Tree")); + bus_scroll->add_theme_style_override("bg", get_theme_stylebox(SNAME("bg"), SNAME("Tree"))); } break; case NOTIFICATION_READY: { _update_buses(); @@ -1217,7 +1202,7 @@ void EditorAudioBuses::_load_default_layout() { AudioServer::get_singleton()->set_bus_layout(state); _update_buses(); EditorNode::get_singleton()->get_undo_redo()->clear_history(); - call_deferred("_select_layout"); + call_deferred(SNAME("_select_layout")); } void EditorAudioBuses::_file_dialog_callback(const String &p_string) { @@ -1233,7 +1218,7 @@ void EditorAudioBuses::_file_dialog_callback(const String &p_string) { AudioServer::get_singleton()->set_bus_layout(state); _update_buses(); EditorNode::get_singleton()->get_undo_redo()->clear_history(); - call_deferred("_select_layout"); + call_deferred(SNAME("_select_layout")); } else if (file_dialog->get_file_mode() == EditorFileDialog::FILE_MODE_SAVE_FILE) { if (new_layout) { @@ -1253,7 +1238,7 @@ void EditorAudioBuses::_file_dialog_callback(const String &p_string) { file->set_text(String(TTR("Layout")) + ": " + p_string.get_file()); _update_buses(); EditorNode::get_singleton()->get_undo_redo()->clear_history(); - call_deferred("_select_layout"); + call_deferred(SNAME("_select_layout")); } } @@ -1331,8 +1316,8 @@ EditorAudioBuses::EditorAudioBuses() { file_dialog = memnew(EditorFileDialog); List<String> ext; ResourceLoader::get_recognized_extensions_for_type("AudioBusLayout", &ext); - for (List<String>::Element *E = ext.front(); E; E = E->next()) { - file_dialog->add_filter("*." + E->get() + "; Audio Bus Layout"); + for (const String &E : ext) { + file_dialog->add_filter("*." + E + "; Audio Bus Layout"); } add_child(file_dialog); file_dialog->connect("file_selected", callable_mp(this, &EditorAudioBuses::_file_dialog_callback)); @@ -1354,7 +1339,7 @@ void EditorAudioBuses::open_layout(const String &p_path) { AudioServer::get_singleton()->set_bus_layout(state); _update_buses(); EditorNode::get_singleton()->get_undo_redo()->clear_history(); - call_deferred("_select_layout"); + call_deferred(SNAME("_select_layout")); } void AudioBusesEditorPlugin::edit(Object *p_node) { @@ -1385,8 +1370,8 @@ void EditorAudioMeterNotches::add_notch(float p_normalized_offset, float p_db_va } Size2 EditorAudioMeterNotches::get_minimum_size() const { - Ref<Font> font = get_theme_font("font", "Label"); - int font_size = get_theme_font_size("font_size", "Label"); + Ref<Font> font = get_theme_font(SNAME("font"), SNAME("Label")); + int font_size = get_theme_font_size(SNAME("font_size"), SNAME("Label")); float font_height = font->get_height(font_size); float width = 0; @@ -1411,7 +1396,7 @@ void EditorAudioMeterNotches::_bind_methods() { void EditorAudioMeterNotches::_notification(int p_what) { switch (p_what) { case NOTIFICATION_THEME_CHANGED: { - notch_color = get_theme_color("font_color", "Editor"); + notch_color = get_theme_color(SNAME("font_color"), SNAME("Editor")); } break; case NOTIFICATION_DRAW: { _draw_audio_notches(); @@ -1420,8 +1405,8 @@ void EditorAudioMeterNotches::_notification(int p_what) { } void EditorAudioMeterNotches::_draw_audio_notches() { - Ref<Font> font = get_theme_font("font", "Label"); - int font_size = get_theme_font_size("font_size", "Label"); + Ref<Font> font = get_theme_font(SNAME("font"), SNAME("Label")); + int font_size = get_theme_font_size(SNAME("font_size"), SNAME("Label")); float font_height = font->get_height(font_size); for (int i = 0; i < notches.size(); i++) { @@ -1443,5 +1428,5 @@ void EditorAudioMeterNotches::_draw_audio_notches() { } EditorAudioMeterNotches::EditorAudioMeterNotches() { - notch_color = get_theme_color("font_color", "Editor"); + notch_color = get_theme_color(SNAME("font_color"), SNAME("Editor")); } diff --git a/editor/editor_autoload_settings.cpp b/editor/editor_autoload_settings.cpp index 12ae55fbc1..fad76682b5 100644 --- a/editor/editor_autoload_settings.cpp +++ b/editor/editor_autoload_settings.cpp @@ -46,19 +46,18 @@ void EditorAutoloadSettings::_notification(int p_what) { ResourceLoader::get_recognized_extensions_for_type("Script", &afn); ResourceLoader::get_recognized_extensions_for_type("PackedScene", &afn); - for (List<String>::Element *E = afn.front(); E; E = E->next()) { - file_dialog->add_filter("*." + E->get()); + for (const String &E : afn) { + file_dialog->add_filter("*." + E); } - for (List<AutoLoadInfo>::Element *E = autoload_cache.front(); E; E = E->next()) { - AutoLoadInfo &info = E->get(); + for (const AutoLoadInfo &info : autoload_cache) { if (info.node && info.in_editor) { - get_tree()->get_root()->call_deferred("add_child", info.node); + get_tree()->get_root()->call_deferred(SNAME("add_child"), info.node); } } - browse_button->set_icon(get_theme_icon("Folder", "EditorIcons")); + browse_button->set_icon(get_theme_icon(SNAME("Folder"), SNAME("EditorIcons"))); } else if (p_what == NOTIFICATION_THEME_CHANGED) { - browse_button->set_icon(get_theme_icon("Folder", "EditorIcons")); + browse_button->set_icon(get_theme_icon(SNAME("Folder"), SNAME("EditorIcons"))); } } @@ -102,8 +101,8 @@ bool EditorAutoloadSettings::_autoload_name_is_valid(const String &p_name, Strin for (int i = 0; i < ScriptServer::get_language_count(); i++) { List<String> keywords; ScriptServer::get_language(i)->get_reserved_words(&keywords); - for (List<String>::Element *E = keywords.front(); E; E = E->next()) { - if (E->get() == p_name) { + for (const String &E : keywords) { + if (E == p_name) { if (r_error) { *r_error = TTR("Invalid name.") + "\n" + TTR("Keyword cannot be used as an autoload name."); } @@ -379,8 +378,7 @@ void EditorAutoloadSettings::update_autoload() { Map<String, AutoLoadInfo> to_remove; List<AutoLoadInfo *> to_add; - for (List<AutoLoadInfo>::Element *E = autoload_cache.front(); E; E = E->next()) { - AutoLoadInfo &info = E->get(); + for (const AutoLoadInfo &info : autoload_cache) { to_remove.insert(info.name, info); } @@ -392,9 +390,7 @@ void EditorAutoloadSettings::update_autoload() { List<PropertyInfo> props; ProjectSettings::get_singleton()->get_property_list(&props); - for (List<PropertyInfo>::Element *E = props.front(); E; E = E->next()) { - const PropertyInfo &pi = E->get(); - + for (const PropertyInfo &pi : props) { if (!pi.name.begins_with("autoload/")) { continue; } @@ -453,10 +449,10 @@ void EditorAutoloadSettings::update_autoload() { item->set_editable(2, true); item->set_text(2, TTR("Enable")); item->set_checked(2, info.is_singleton); - item->add_button(3, get_theme_icon("Load", "EditorIcons"), BUTTON_OPEN); - item->add_button(3, get_theme_icon("MoveUp", "EditorIcons"), BUTTON_MOVE_UP); - item->add_button(3, get_theme_icon("MoveDown", "EditorIcons"), BUTTON_MOVE_DOWN); - item->add_button(3, get_theme_icon("Remove", "EditorIcons"), BUTTON_DELETE); + item->add_button(3, get_theme_icon(SNAME("Load"), SNAME("EditorIcons")), BUTTON_OPEN); + item->add_button(3, get_theme_icon(SNAME("MoveUp"), SNAME("EditorIcons")), BUTTON_MOVE_UP); + item->add_button(3, get_theme_icon(SNAME("MoveDown"), SNAME("EditorIcons")), BUTTON_MOVE_DOWN); + item->add_button(3, get_theme_icon(SNAME("Remove"), SNAME("EditorIcons")), BUTTON_DELETE); item->set_selectable(3, false); } @@ -470,7 +466,7 @@ void EditorAutoloadSettings::update_autoload() { } if (info.in_editor) { ERR_CONTINUE(!info.node); - get_tree()->get_root()->call_deferred("remove_child", info.node); + get_tree()->get_root()->call_deferred(SNAME("remove_child"), info.node); } if (info.node) { @@ -483,9 +479,7 @@ void EditorAutoloadSettings::update_autoload() { // Load new/changed autoloads List<Node *> nodes_to_add; - for (List<AutoLoadInfo *>::Element *E = to_add.front(); E; E = E->next()) { - AutoLoadInfo *info = E->get(); - + for (AutoLoadInfo *info : to_add) { info->node = _create_autoload(info->path); ERR_CONTINUE(!info->node); @@ -518,8 +512,8 @@ void EditorAutoloadSettings::update_autoload() { } } - for (List<Node *>::Element *E = nodes_to_add.front(); E; E = E->next()) { - get_tree()->get_root()->add_child(E->get()); + for (Node *E : nodes_to_add) { + get_tree()->get_root()->add_child(E); } updating_autoload = false; @@ -649,8 +643,8 @@ void EditorAutoloadSettings::drop_data_fw(const Point2 &p_point, const Variant & int i = 0; - for (List<AutoLoadInfo>::Element *F = autoload_cache.front(); F; F = F->next()) { - orders.write[i++] = F->get().order; + for (const AutoLoadInfo &F : autoload_cache) { + orders.write[i++] = F.order; } orders.sort(); @@ -661,9 +655,9 @@ void EditorAutoloadSettings::drop_data_fw(const Point2 &p_point, const Variant & i = 0; - for (List<AutoLoadInfo>::Element *F = autoload_cache.front(); F; F = F->next()) { - undo_redo->add_do_method(ProjectSettings::get_singleton(), "set_order", "autoload/" + F->get().name, orders[i++]); - undo_redo->add_undo_method(ProjectSettings::get_singleton(), "set_order", "autoload/" + F->get().name, F->get().order); + for (const AutoLoadInfo &F : autoload_cache) { + undo_redo->add_do_method(ProjectSettings::get_singleton(), "set_order", "autoload/" + F.name, orders[i++]); + undo_redo->add_undo_method(ProjectSettings::get_singleton(), "set_order", "autoload/" + F.name, F.order); } orders.clear(); @@ -764,9 +758,7 @@ EditorAutoloadSettings::EditorAutoloadSettings() { // Make first cache List<PropertyInfo> props; ProjectSettings::get_singleton()->get_property_list(&props); - for (List<PropertyInfo>::Element *E = props.front(); E; E = E->next()) { - const PropertyInfo &pi = E->get(); - + for (const PropertyInfo &pi : props) { if (!pi.name.begins_with("autoload/")) { continue; } @@ -799,9 +791,7 @@ EditorAutoloadSettings::EditorAutoloadSettings() { autoload_cache.push_back(info); } - for (List<AutoLoadInfo>::Element *E = autoload_cache.front(); E; E = E->next()) { - AutoLoadInfo &info = E->get(); - + for (AutoLoadInfo &info : autoload_cache) { info.node = _create_autoload(info.path); if (info.node) { @@ -904,8 +894,7 @@ EditorAutoloadSettings::EditorAutoloadSettings() { } EditorAutoloadSettings::~EditorAutoloadSettings() { - for (List<AutoLoadInfo>::Element *E = autoload_cache.front(); E; E = E->next()) { - AutoLoadInfo &info = E->get(); + for (const AutoLoadInfo &info : autoload_cache) { if (info.node && !info.in_editor) { memdelete(info.node); } @@ -914,7 +903,7 @@ EditorAutoloadSettings::~EditorAutoloadSettings() { void EditorAutoloadSettings::_set_autoload_add_path(const String &p_text) { autoload_add_path->set_text(p_text); - autoload_add_path->emit_signal("text_submitted", p_text); + autoload_add_path->emit_signal(SNAME("text_submitted"), p_text); } void EditorAutoloadSettings::_browse_autoload_add_path() { diff --git a/editor/editor_data.cpp b/editor/editor_data.cpp index 3823d7e14f..c62e5b75b2 100644 --- a/editor/editor_data.cpp +++ b/editor/editor_data.cpp @@ -299,13 +299,13 @@ void EditorData::copy_object_params(Object *p_object) { List<PropertyInfo> pinfo; p_object->get_property_list(&pinfo); - for (List<PropertyInfo>::Element *E = pinfo.front(); E; E = E->next()) { - if (!(E->get().usage & PROPERTY_USAGE_EDITOR) || E->get().name == "script" || E->get().name == "scripts") { + for (const PropertyInfo &E : pinfo) { + if (!(E.usage & PROPERTY_USAGE_EDITOR) || E.name == "script" || E.name == "scripts") { continue; } PropertyData pd; - pd.name = E->get().name; + pd.name = E.name; pd.value = p_object->get(pd.name); clipboard.push_back(pd); } @@ -404,9 +404,9 @@ void EditorData::restore_editor_global_states() { void EditorData::paste_object_params(Object *p_object) { ERR_FAIL_NULL(p_object); undo_redo.create_action(TTR("Paste Params")); - for (List<PropertyData>::Element *E = clipboard.front(); E; E = E->next()) { - String name = E->get().name; - undo_redo.add_do_property(p_object, name, E->get().value); + for (const PropertyData &E : clipboard) { + String name = E.name; + undo_redo.add_do_property(p_object, name, E.value); undo_redo.add_undo_property(p_object, name, p_object->get(name)); } undo_redo.commit_action(); @@ -616,8 +616,8 @@ bool EditorData::check_and_update_scene(int p_idx) { //transfer selection List<Node *> new_selection; - for (List<Node *>::Element *E = edited_scene.write[p_idx].selection.front(); E; E = E->next()) { - NodePath p = edited_scene[p_idx].root->get_path_to(E->get()); + for (const Node *E : edited_scene.write[p_idx].selection) { + NodePath p = edited_scene[p_idx].root->get_path_to(E); Node *new_node = new_scene->get_node(p); if (new_node) { new_selection.push_back(new_node); @@ -841,8 +841,8 @@ Dictionary EditorData::restore_edited_scene_state(EditorSelection *p_selection, p_history->history = es.history_stored; p_selection->clear(); - for (List<Node *>::Element *E = es.selection.front(); E; E = E->next()) { - p_selection->add_node(E->get()); + for (Node *E : es.selection) { + p_selection->add_node(E); } set_editor_states(es.editor_states); @@ -964,9 +964,9 @@ void EditorData::script_class_save_icon_paths() { _script_class_icon_paths.get_key_list(&keys); Dictionary d; - for (List<StringName>::Element *E = keys.front(); E; E = E->next()) { - if (ScriptServer::is_global_class(E->get())) { - d[E->get()] = _script_class_icon_paths[E->get()]; + for (const StringName &E : keys) { + if (ScriptServer::is_global_class(E)) { + d[E] = _script_class_icon_paths[E]; } } @@ -996,8 +996,8 @@ void EditorData::script_class_load_icon_paths() { List<Variant> keys; d.get_key_list(&keys); - for (List<Variant>::Element *E = keys.front(); E; E = E->next()) { - String name = E->get().operator String(); + for (const Variant &E : keys) { + String name = E.operator String(); _script_class_icon_paths[name] = d[name]; String path = ScriptServer::get_global_class_path(name); @@ -1038,8 +1038,8 @@ void EditorSelection::add_node(Node *p_node) { changed = true; nl_changed = true; Object *meta = nullptr; - for (List<Object *>::Element *E = editor_plugins.front(); E; E = E->next()) { - meta = E->get()->call("_get_editor_data", p_node); + for (Object *E : editor_plugins) { + meta = E->call("_get_editor_data", p_node); if (meta) { break; } @@ -1048,7 +1048,7 @@ void EditorSelection::add_node(Node *p_node) { p_node->connect("tree_exiting", callable_mp(this, &EditorSelection::_node_removed), varray(p_node), CONNECT_ONESHOT); - //emit_signal("selection_changed"); + //emit_signal(SNAME("selection_changed")); } void EditorSelection::remove_node(Node *p_node) { @@ -1066,7 +1066,7 @@ void EditorSelection::remove_node(Node *p_node) { } selection.erase(p_node); p_node->disconnect("tree_exiting", callable_mp(this, &EditorSelection::_node_removed)); - //emit_signal("selection_changed"); + //emit_signal(SNAME("selection_changed")); } bool EditorSelection::is_selected(Node *p_node) const { @@ -1076,8 +1076,8 @@ bool EditorSelection::is_selected(Node *p_node) const { Array EditorSelection::_get_transformable_selected_nodes() { Array ret; - for (List<Node *>::Element *E = selected_node_list.front(); E; E = E->next()) { - ret.push_back(E->get()); + for (const Node *E : selected_node_list) { + ret.push_back(E); } return ret; @@ -1144,12 +1144,12 @@ void EditorSelection::update() { changed = false; if (!emitted) { emitted = true; - call_deferred("_emit_change"); + call_deferred(SNAME("_emit_change")); } } void EditorSelection::_emit_change() { - emit_signal("selection_changed"); + emit_signal(SNAME("selection_changed")); emitted = false; } diff --git a/editor/editor_dir_dialog.cpp b/editor/editor_dir_dialog.cpp index 4366d83fe2..5df392b91e 100644 --- a/editor/editor_dir_dialog.cpp +++ b/editor/editor_dir_dialog.cpp @@ -43,7 +43,7 @@ void EditorDirDialog::_update_dir(TreeItem *p_item, EditorFileSystemDirectory *p String path = p_dir->get_path(); p_item->set_metadata(0, p_dir->get_path()); - p_item->set_icon(0, tree->get_theme_icon("Folder", "EditorIcons")); + p_item->set_icon(0, tree->get_theme_icon(SNAME("Folder"), SNAME("EditorIcons"))); if (!p_item->get_parent()) { p_item->set_text(0, "res://"); @@ -129,7 +129,7 @@ void EditorDirDialog::ok_pressed() { } String dir = ti->get_metadata(0); - emit_signal("dir_selected", dir); + emit_signal(SNAME("dir_selected"), dir); hide(); } diff --git a/editor/editor_export.cpp b/editor/editor_export.cpp index fc483b46b7..b374f56f6d 100644 --- a/editor/editor_export.cpp +++ b/editor/editor_export.cpp @@ -80,9 +80,9 @@ bool EditorExportPreset::_get(const StringName &p_name, Variant &r_ret) const { } void EditorExportPreset::_get_property_list(List<PropertyInfo> *p_list) const { - for (const List<PropertyInfo>::Element *E = properties.front(); E; E = E->next()) { - if (platform->get_option_visibility(E->get().name, values)) { - p_list->push_back(E->get()); + for (const PropertyInfo &E : properties) { + if (platform->get_option_visibility(E.name, values)) { + p_list->push_back(E); } } } @@ -436,9 +436,9 @@ Ref<EditorExportPreset> EditorExportPlatform::create_preset() { List<ExportOption> options; get_export_options(&options); - for (List<ExportOption>::Element *E = options.front(); E; E = E->next()) { - preset->properties.push_back(E->get().option); - preset->values[E->get().option.name] = E->get().default_value; + for (const ExportOption &E : options) { + preset->properties.push_back(E.option); + preset->values[E.option.name] = E.default_value; } return preset; @@ -679,9 +679,9 @@ EditorExportPlatform::FeatureContainers EditorExportPlatform::get_feature_contai platform->get_preset_features(p_preset, &feature_list); FeatureContainers result; - for (List<String>::Element *E = feature_list.front(); E; E = E->next()) { - result.features.insert(E->get()); - result.features_pv.push_back(E->get()); + for (const String &E : feature_list) { + result.features.insert(E); + result.features_pv.push_back(E); } if (p_preset->get_custom_features() != String()) { @@ -752,9 +752,7 @@ Error EditorExportPlatform::export_project_files(const Ref<EditorExportPreset> & List<PropertyInfo> props; ProjectSettings::get_singleton()->get_property_list(&props); - for (List<PropertyInfo>::Element *E = props.front(); E; E = E->next()) { - const PropertyInfo &pi = E->get(); - + for (const PropertyInfo &pi : props) { if (!pi.name.begins_with("autoload/")) { continue; } @@ -899,8 +897,8 @@ Error EditorExportPlatform::export_project_files(const Ref<EditorExportPreset> & Set<String> remap_features; - for (List<String>::Element *F = remaps.front(); F; F = F->next()) { - String remap = F->get(); + for (const String &F : remaps) { + String remap = F; String feature = remap.get_slice(".", 1); if (features.has(feature)) { remap_features.insert(feature); @@ -913,8 +911,8 @@ Error EditorExportPlatform::export_project_files(const Ref<EditorExportPreset> & err = OK; - for (List<String>::Element *F = remaps.front(); F; F = F->next()) { - String remap = F->get(); + for (const String &F : remaps) { + String remap = F; if (remap == "path") { String remapped_path = config->get_value("remap", remap); Vector<uint8_t> array = FileAccess::get_file_as_array(remapped_path); @@ -1050,6 +1048,13 @@ Error EditorExportPlatform::export_project_files(const Ref<EditorExportPreset> & return err; } } + if (FileAccess::exists(ResourceUID::CACHE_FILE)) { + Vector<uint8_t> array = FileAccess::get_file_as_array(ResourceUID::CACHE_FILE); + err = p_func(p_udata, ResourceUID::CACHE_FILE, array, idx, total, enc_in_filters, enc_ex_filters, key); + if (err != OK) { + return err; + } + } // Store text server data if it is supported. if (TS->has_feature(TextServer::FEATURE_USE_SUPPORT_DATA)) { @@ -1362,7 +1367,7 @@ void EditorExportPlatform::gen_export_flags(Vector<String> &r_flags, int p_flags if (breakpoints.size()) { r_flags.push_back("--breakpoints"); String bpoints; - for (const List<String>::Element *E = breakpoints.front(); E; E = E->next()) { + for (List<String>::Element *E = breakpoints.front(); E; E = E->next()) { bpoints += E->get().replace(" ", "%20"); if (E->next()) { bpoints += ","; @@ -1436,8 +1441,8 @@ void EditorExport::_save() { String option_section = "preset." + itos(i) + ".options"; - for (const List<PropertyInfo>::Element *E = preset->get_properties().front(); E; E = E->next()) { - config->set_value(option_section, E->get().name, preset->get(E->get().name)); + for (const PropertyInfo &E : preset->get_properties()) { + config->set_value(option_section, E.name, preset->get(E.name)); } } @@ -1642,10 +1647,10 @@ void EditorExport::load_config() { config->get_section_keys(option_section, &options); - for (List<String>::Element *E = options.front(); E; E = E->next()) { - Variant value = config->get_value(option_section, E->get()); + for (const String &E : options) { + Variant value = config->get_value(option_section, E); - preset->set(E->get(), value); + preset->set(E, value); } add_export_preset(preset); @@ -1684,11 +1689,11 @@ void EditorExport::update_export_presets() { preset->properties.clear(); preset->values.clear(); - for (List<EditorExportPlatform::ExportOption>::Element *E = options.front(); E; E = E->next()) { - preset->properties.push_back(E->get().option); + for (const EditorExportPlatform::ExportOption &E : options) { + preset->properties.push_back(E.option); - StringName option_name = E->get().option.name; - preset->values[option_name] = previous_values.has(option_name) ? previous_values[option_name] : E->get().default_value; + StringName option_name = E.option.name; + preset->values[option_name] = previous_values.has(option_name) ? previous_values[option_name] : E.default_value; } } } diff --git a/editor/editor_feature_profile.cpp b/editor/editor_feature_profile.cpp index 58d2b6e86e..72a0c353e8 100644 --- a/editor/editor_feature_profile.cpp +++ b/editor/editor_feature_profile.cpp @@ -497,7 +497,7 @@ void EditorFeatureProfileManager::_fill_classes_from(TreeItem *p_parent, const S bool disabled_editor = edited->is_class_editor_disabled(p_class); bool disabled_properties = edited->has_class_properties_disabled(p_class); if (disabled) { - class_item->set_custom_color(0, class_list->get_theme_color("disabled_font_color", "Editor")); + class_item->set_custom_color(0, class_list->get_theme_color(SNAME("disabled_font_color"), SNAME("Editor"))); } else if (disabled_editor && disabled_properties) { text += " " + TTR("(Editor Disabled, Properties Disabled)"); } else if (disabled_properties) { @@ -527,9 +527,8 @@ void EditorFeatureProfileManager::_fill_classes_from(TreeItem *p_parent, const S ClassDB::get_direct_inheriters_from_class(p_class, &child_classes); child_classes.sort_custom<StringName::AlphCompare>(); - for (List<StringName>::Element *E = child_classes.front(); E; E = E->next()) { - String name = E->get(); - if (name.begins_with("Editor") || ClassDB::get_api_type(name) != ClassDB::API_CORE) { + for (const StringName &name : child_classes) { + if (String(name).begins_with("Editor") || ClassDB::get_api_type(name) != ClassDB::API_CORE) { continue; } _fill_classes_from(class_item, name, p_selected); @@ -597,9 +596,9 @@ void EditorFeatureProfileManager::_class_list_item_selected() { TreeItem *properties = property_list->create_item(root); properties->set_text(0, TTR("Class Properties:")); - for (List<PropertyInfo>::Element *E = props.front(); E; E = E->next()) { - String name = E->get().name; - if (!(E->get().usage & PROPERTY_USAGE_EDITOR)) { + for (const PropertyInfo &E : props) { + String name = E.name; + if (!(E.usage & PROPERTY_USAGE_EDITOR)) { continue; } TreeItem *property = property_list->create_item(properties); @@ -609,7 +608,7 @@ void EditorFeatureProfileManager::_class_list_item_selected() { property->set_checked(0, !edited->is_class_property_disabled(class_name, name)); property->set_text(0, name.capitalize()); property->set_metadata(0, name); - String icon_type = Variant::get_type_name(E->get().type); + String icon_type = Variant::get_type_name(E.type); property->set_icon(0, EditorNode::get_singleton()->get_class_icon(icon_type)); } } @@ -741,7 +740,7 @@ void EditorFeatureProfileManager::_update_selected_profile() { TreeItem *features = class_list->create_item(root); TreeItem *last_feature; - features->set_text(0, TTR("Main Features") + ":"); + features->set_text(0, TTR("Main Features:")); for (int i = 0; i < EditorFeatureProfile::FEATURE_MAX; i++) { TreeItem *feature; if (i == EditorFeatureProfile::FEATURE_IMPORT_DOCK) { @@ -765,7 +764,7 @@ void EditorFeatureProfileManager::_update_selected_profile() { } TreeItem *classes = class_list->create_item(root); - classes->set_text(0, TTR("Nodes and Classes") + ":"); + classes->set_text(0, TTR("Nodes and Classes:")); _fill_classes_from(classes, "Node", class_selected); _fill_classes_from(classes, "Resource", class_selected); @@ -834,7 +833,7 @@ void EditorFeatureProfileManager::_save_and_update() { } void EditorFeatureProfileManager::_emit_current_profile_changed() { - emit_signal("current_feature_profile_changed"); + emit_signal(SNAME("current_feature_profile_changed")); } void EditorFeatureProfileManager::notify_changed() { @@ -918,7 +917,7 @@ EditorFeatureProfileManager::EditorFeatureProfileManager() { class_list_vbc->set_h_size_flags(Control::SIZE_EXPAND_FILL); class_list = memnew(Tree); - class_list_vbc->add_margin_child(TTR("Configure Selected Profile") + ":", class_list, true); + class_list_vbc->add_margin_child(TTR("Configure Selected Profile:"), class_list, true); class_list->set_hide_root(true); class_list->set_edit_checkbox_cell_only_when_checkbox_is_pressed(true); class_list->connect("cell_selected", callable_mp(this, &EditorFeatureProfileManager::_class_list_item_selected)); @@ -932,11 +931,11 @@ EditorFeatureProfileManager::EditorFeatureProfileManager() { property_list_vbc->set_h_size_flags(Control::SIZE_EXPAND_FILL); description_bit = memnew(EditorHelpBit); - property_list_vbc->add_margin_child(TTR("Description") + ":", description_bit, false); + property_list_vbc->add_margin_child(TTR("Description:"), description_bit, false); description_bit->set_custom_minimum_size(Size2(0, 80) * EDSCALE); property_list = memnew(Tree); - property_list_vbc->add_margin_child(TTR("Extra Options") + ":", property_list, true); + property_list_vbc->add_margin_child(TTR("Extra Options:"), property_list, true); property_list->set_hide_root(true); property_list->set_hide_folding(true); property_list->set_edit_checkbox_cell_only_when_checkbox_is_pressed(true); @@ -958,7 +957,7 @@ EditorFeatureProfileManager::EditorFeatureProfileManager() { VBoxContainer *new_profile_vb = memnew(VBoxContainer); new_profile_dialog->add_child(new_profile_vb); Label *new_profile_label = memnew(Label); - new_profile_label->set_text(TTR("New profile name") + ":"); + new_profile_label->set_text(TTR("New profile name:")); new_profile_vb->add_child(new_profile_label); new_profile_name = memnew(LineEdit); new_profile_vb->add_child(new_profile_name); diff --git a/editor/editor_file_dialog.cpp b/editor/editor_file_dialog.cpp index a07b3a7c19..5ccbed1b49 100644 --- a/editor/editor_file_dialog.cpp +++ b/editor/editor_file_dialog.cpp @@ -61,22 +61,22 @@ VBoxContainer *EditorFileDialog::get_vbox() { void EditorFileDialog::_notification(int p_what) { if (p_what == NOTIFICATION_READY || p_what == NOTIFICATION_THEME_CHANGED || p_what == Control::NOTIFICATION_LAYOUT_DIRECTION_CHANGED || p_what == NOTIFICATION_TRANSLATION_CHANGED) { // Update icons. - mode_thumbnails->set_icon(item_list->get_theme_icon("FileThumbnail", "EditorIcons")); - mode_list->set_icon(item_list->get_theme_icon("FileList", "EditorIcons")); + mode_thumbnails->set_icon(item_list->get_theme_icon(SNAME("FileThumbnail"), SNAME("EditorIcons"))); + mode_list->set_icon(item_list->get_theme_icon(SNAME("FileList"), SNAME("EditorIcons"))); if (is_layout_rtl()) { - dir_prev->set_icon(item_list->get_theme_icon("Forward", "EditorIcons")); - dir_next->set_icon(item_list->get_theme_icon("Back", "EditorIcons")); + dir_prev->set_icon(item_list->get_theme_icon(SNAME("Forward"), SNAME("EditorIcons"))); + dir_next->set_icon(item_list->get_theme_icon(SNAME("Back"), SNAME("EditorIcons"))); } else { - dir_prev->set_icon(item_list->get_theme_icon("Back", "EditorIcons")); - dir_next->set_icon(item_list->get_theme_icon("Forward", "EditorIcons")); + dir_prev->set_icon(item_list->get_theme_icon(SNAME("Back"), SNAME("EditorIcons"))); + dir_next->set_icon(item_list->get_theme_icon(SNAME("Forward"), SNAME("EditorIcons"))); } - dir_up->set_icon(item_list->get_theme_icon("ArrowUp", "EditorIcons")); - refresh->set_icon(item_list->get_theme_icon("Reload", "EditorIcons")); - favorite->set_icon(item_list->get_theme_icon("Favorites", "EditorIcons")); - show_hidden->set_icon(item_list->get_theme_icon("GuiVisibilityVisible", "EditorIcons")); + dir_up->set_icon(item_list->get_theme_icon(SNAME("ArrowUp"), SNAME("EditorIcons"))); + refresh->set_icon(item_list->get_theme_icon(SNAME("Reload"), SNAME("EditorIcons"))); + favorite->set_icon(item_list->get_theme_icon(SNAME("Favorites"), SNAME("EditorIcons"))); + show_hidden->set_icon(item_list->get_theme_icon(SNAME("GuiVisibilityVisible"), SNAME("EditorIcons"))); - fav_up->set_icon(item_list->get_theme_icon("MoveUp", "EditorIcons")); - fav_down->set_icon(item_list->get_theme_icon("MoveDown", "EditorIcons")); + fav_up->set_icon(item_list->get_theme_icon(SNAME("MoveUp"), SNAME("EditorIcons"))); + fav_down->set_icon(item_list->get_theme_icon(SNAME("MoveDown"), SNAME("EditorIcons"))); } else if (p_what == NOTIFICATION_PROCESS) { if (preview_waiting) { @@ -100,21 +100,21 @@ void EditorFileDialog::_notification(int p_what) { set_display_mode((DisplayMode)EditorSettings::get_singleton()->get("filesystem/file_dialog/display_mode").operator int()); // Update icons. - mode_thumbnails->set_icon(item_list->get_theme_icon("FileThumbnail", "EditorIcons")); - mode_list->set_icon(item_list->get_theme_icon("FileList", "EditorIcons")); + mode_thumbnails->set_icon(item_list->get_theme_icon(SNAME("FileThumbnail"), SNAME("EditorIcons"))); + mode_list->set_icon(item_list->get_theme_icon(SNAME("FileList"), SNAME("EditorIcons"))); if (is_layout_rtl()) { - dir_prev->set_icon(item_list->get_theme_icon("Forward", "EditorIcons")); - dir_next->set_icon(item_list->get_theme_icon("Back", "EditorIcons")); + dir_prev->set_icon(item_list->get_theme_icon(SNAME("Forward"), SNAME("EditorIcons"))); + dir_next->set_icon(item_list->get_theme_icon(SNAME("Back"), SNAME("EditorIcons"))); } else { - dir_prev->set_icon(item_list->get_theme_icon("Back", "EditorIcons")); - dir_next->set_icon(item_list->get_theme_icon("Forward", "EditorIcons")); + dir_prev->set_icon(item_list->get_theme_icon(SNAME("Back"), SNAME("EditorIcons"))); + dir_next->set_icon(item_list->get_theme_icon(SNAME("Forward"), SNAME("EditorIcons"))); } - dir_up->set_icon(item_list->get_theme_icon("ArrowUp", "EditorIcons")); - refresh->set_icon(item_list->get_theme_icon("Reload", "EditorIcons")); - favorite->set_icon(item_list->get_theme_icon("Favorites", "EditorIcons")); + dir_up->set_icon(item_list->get_theme_icon(SNAME("ArrowUp"), SNAME("EditorIcons"))); + refresh->set_icon(item_list->get_theme_icon(SNAME("Reload"), SNAME("EditorIcons"))); + favorite->set_icon(item_list->get_theme_icon(SNAME("Favorites"), SNAME("EditorIcons"))); - fav_up->set_icon(item_list->get_theme_icon("MoveUp", "EditorIcons")); - fav_down->set_icon(item_list->get_theme_icon("MoveDown", "EditorIcons")); + fav_up->set_icon(item_list->get_theme_icon(SNAME("MoveUp"), SNAME("EditorIcons"))); + fav_down->set_icon(item_list->get_theme_icon(SNAME("MoveDown"), SNAME("EditorIcons"))); // DO NOT CALL UPDATE FILE LIST HERE, ALL HUNDREDS OF HIDDEN DIALOGS WILL RESPOND, CALL INVALIDATE INSTEAD invalidate(); } else if (p_what == NOTIFICATION_VISIBILITY_CHANGED) { @@ -245,7 +245,7 @@ void EditorFileDialog::_save_confirm_pressed() { String f = dir_access->get_current_dir().plus_file(file->get_text()); _save_to_recent(); hide(); - emit_signal("file_selected", f); + emit_signal(SNAME("file_selected"), f); } void EditorFileDialog::_post_popup() { @@ -279,8 +279,8 @@ void EditorFileDialog::_post_popup() { } if (is_visible()) { - Ref<Texture2D> folder = item_list->get_theme_icon("folder", "FileDialog"); - const Color folder_color = item_list->get_theme_color("folder_icon_modulate", "FileDialog"); + Ref<Texture2D> folder = item_list->get_theme_icon(SNAME("folder"), SNAME("FileDialog")); + const Color folder_color = item_list->get_theme_color(SNAME("folder_icon_modulate"), SNAME("FileDialog")); recent->clear(); bool res = access == ACCESS_RESOURCES; @@ -379,7 +379,7 @@ void EditorFileDialog::_action_pressed() { if (files.size()) { _save_to_recent(); hide(); - emit_signal("files_selected", files); + emit_signal(SNAME("files_selected"), files); } return; @@ -390,7 +390,7 @@ void EditorFileDialog::_action_pressed() { if ((mode == FILE_MODE_OPEN_ANY || mode == FILE_MODE_OPEN_FILE) && dir_access->file_exists(f)) { _save_to_recent(); hide(); - emit_signal("file_selected", f); + emit_signal(SNAME("file_selected"), f); } else if (mode == FILE_MODE_OPEN_ANY || mode == FILE_MODE_OPEN_DIR) { String path = dir_access->get_current_dir(); @@ -409,7 +409,7 @@ void EditorFileDialog::_action_pressed() { _save_to_recent(); hide(); - emit_signal("dir_selected", path); + emit_signal(SNAME("dir_selected"), path); } if (mode == FILE_MODE_SAVE_FILE) { @@ -474,7 +474,7 @@ void EditorFileDialog::_action_pressed() { } else { _save_to_recent(); hide(); - emit_signal("file_selected", f); + emit_signal(SNAME("file_selected"), f); } } } @@ -563,8 +563,8 @@ void EditorFileDialog::_item_dc_selected(int p_item) { if (d["dir"]) { dir_access->change_dir(d["name"]); - call_deferred("_update_file_list"); - call_deferred("_update_dir"); + call_deferred(SNAME("_update_file_list")); + call_deferred(SNAME("_update_dir")); _push_history(); @@ -595,16 +595,16 @@ void EditorFileDialog::_item_list_item_rmb_selected(int p_item, const Vector2 &p } if (single_item_selected) { - item_menu->add_icon_item(item_list->get_theme_icon("ActionCopy", "EditorIcons"), TTR("Copy Path"), ITEM_MENU_COPY_PATH); + item_menu->add_icon_item(item_list->get_theme_icon(SNAME("ActionCopy"), SNAME("EditorIcons")), TTR("Copy Path"), ITEM_MENU_COPY_PATH); } if (allow_delete) { - item_menu->add_icon_item(item_list->get_theme_icon("Remove", "EditorIcons"), TTR("Delete"), ITEM_MENU_DELETE, KEY_DELETE); + item_menu->add_icon_item(item_list->get_theme_icon(SNAME("Remove"), SNAME("EditorIcons")), TTR("Delete"), ITEM_MENU_DELETE, KEY_DELETE); } if (single_item_selected) { item_menu->add_separator(); Dictionary item_meta = item_list->get_item_metadata(p_item); String item_text = item_meta["dir"] ? TTR("Open in File Manager") : TTR("Show in File Manager"); - item_menu->add_icon_item(item_list->get_theme_icon("Filesystem", "EditorIcons"), item_text, ITEM_MENU_SHOW_IN_EXPLORER); + item_menu->add_icon_item(item_list->get_theme_icon(SNAME("Filesystem"), SNAME("EditorIcons")), item_text, ITEM_MENU_SHOW_IN_EXPLORER); } if (item_menu->get_item_count() > 0) { @@ -623,11 +623,11 @@ void EditorFileDialog::_item_list_rmb_clicked(const Vector2 &p_pos) { item_menu->set_size(Size2(1, 1)); if (can_create_dir) { - item_menu->add_icon_item(item_list->get_theme_icon("folder", "FileDialog"), TTR("New Folder..."), ITEM_MENU_NEW_FOLDER, KEY_MASK_CMD | KEY_N); + item_menu->add_icon_item(item_list->get_theme_icon(SNAME("folder"), SNAME("FileDialog")), TTR("New Folder..."), ITEM_MENU_NEW_FOLDER, KEY_MASK_CMD | KEY_N); } - item_menu->add_icon_item(item_list->get_theme_icon("Reload", "EditorIcons"), TTR("Refresh"), ITEM_MENU_REFRESH, KEY_F5); + item_menu->add_icon_item(item_list->get_theme_icon(SNAME("Reload"), SNAME("EditorIcons")), TTR("Refresh"), ITEM_MENU_REFRESH, KEY_F5); item_menu->add_separator(); - item_menu->add_icon_item(item_list->get_theme_icon("Filesystem", "EditorIcons"), TTR("Open in File Manager"), ITEM_MENU_SHOW_IN_EXPLORER); + item_menu->add_icon_item(item_list->get_theme_icon(SNAME("Filesystem"), SNAME("EditorIcons")), TTR("Open in File Manager"), ITEM_MENU_SHOW_IN_EXPLORER); item_menu->set_position(item_list->get_global_position() + p_pos); item_menu->popup(); @@ -731,11 +731,11 @@ void EditorFileDialog::update_file_list() { item_list->set_fixed_icon_size(Size2(thumbnail_size, thumbnail_size)); if (thumbnail_size < 64) { - folder_thumbnail = item_list->get_theme_icon("FolderMediumThumb", "EditorIcons"); - file_thumbnail = item_list->get_theme_icon("FileMediumThumb", "EditorIcons"); + folder_thumbnail = item_list->get_theme_icon(SNAME("FolderMediumThumb"), SNAME("EditorIcons")); + file_thumbnail = item_list->get_theme_icon(SNAME("FileMediumThumb"), SNAME("EditorIcons")); } else { - folder_thumbnail = item_list->get_theme_icon("FolderBigThumb", "EditorIcons"); - file_thumbnail = item_list->get_theme_icon("FileBigThumb", "EditorIcons"); + folder_thumbnail = item_list->get_theme_icon(SNAME("FolderBigThumb"), SNAME("EditorIcons")); + file_thumbnail = item_list->get_theme_icon(SNAME("FileBigThumb"), SNAME("EditorIcons")); } preview_vb->hide(); @@ -755,8 +755,8 @@ void EditorFileDialog::update_file_list() { dir_access->list_dir_begin(); - Ref<Texture2D> folder = item_list->get_theme_icon("folder", "FileDialog"); - const Color folder_color = item_list->get_theme_color("folder_icon_modulate", "FileDialog"); + Ref<Texture2D> folder = item_list->get_theme_icon(SNAME("folder"), SNAME("FileDialog")); + const Color folder_color = item_list->get_theme_color(SNAME("folder_icon_modulate"), SNAME("FileDialog")); List<String> files; List<String> dirs; @@ -830,8 +830,8 @@ void EditorFileDialog::update_file_list() { while (!files.is_empty()) { bool match = patterns.is_empty(); - for (List<String>::Element *E = patterns.front(); E; E = E->next()) { - if (files.front()->get().matchn(E->get())) { + for (const String &E : patterns) { + if (files.front()->get().matchn(E)) { match = true; break; } @@ -1206,8 +1206,8 @@ void EditorFileDialog::_update_favorites() { bool res = access == ACCESS_RESOURCES; String current = get_current_dir(); - Ref<Texture2D> folder_icon = item_list->get_theme_icon("Folder", "EditorIcons"); - const Color folder_color = item_list->get_theme_color("folder_icon_modulate", "FileDialog"); + Ref<Texture2D> folder_icon = item_list->get_theme_icon(SNAME("Folder"), SNAME("EditorIcons")); + const Color folder_color = item_list->get_theme_color(SNAME("folder_icon_modulate"), SNAME("FileDialog")); favorites->clear(); favorite->set_pressed(false); diff --git a/editor/editor_file_system.cpp b/editor/editor_file_system.cpp index a2507f3cf2..78861eff9d 100644 --- a/editor/editor_file_system.cpp +++ b/editor/editor_file_system.cpp @@ -43,7 +43,7 @@ EditorFileSystem *EditorFileSystem::singleton = nullptr; //the name is the version, to keep compatibility with different versions of Godot -#define CACHE_FILE_NAME "filesystem_cache6" +#define CACHE_FILE_NAME "filesystem_cache7" void EditorFileSystemDirectory::sort_files() { files.sort_custom<FileInfoSort>(); @@ -116,7 +116,26 @@ String EditorFileSystemDirectory::get_file_path(int p_idx) const { Vector<String> EditorFileSystemDirectory::get_file_deps(int p_idx) const { ERR_FAIL_INDEX_V(p_idx, files.size(), Vector<String>()); - return files[p_idx]->deps; + Vector<String> deps; + + for (int i = 0; i < files[p_idx]->deps.size(); i++) { + String dep = files[p_idx]->deps[i]; + int sep_idx = dep.find("::"); //may contain type information, unwanted + if (sep_idx != -1) { + dep = dep.substr(0, sep_idx); + } + ResourceUID::ID uid = ResourceUID::get_singleton()->text_to_id(dep); + if (uid != ResourceUID::INVALID_ID) { + //return proper dependency resource from uid + if (ResourceUID::get_singleton()->has_id(uid)) { + dep = ResourceUID::get_singleton()->get_id_path(uid); + } else { + continue; + } + } + deps.push_back(dep); + } + return deps; } bool EditorFileSystemDirectory::get_file_import_is_valid(int p_idx) const { @@ -234,7 +253,7 @@ void EditorFileSystem::_scan_filesystem() { } else { Vector<String> split = l.split("::"); - ERR_CONTINUE(split.size() != 8); + ERR_CONTINUE(split.size() != 9); String name = split[0]; String file; @@ -243,15 +262,16 @@ void EditorFileSystem::_scan_filesystem() { FileCache fc; fc.type = split[1]; - fc.modification_time = split[2].to_int(); - fc.import_modification_time = split[3].to_int(); - fc.import_valid = split[4].to_int() != 0; - fc.import_group_file = split[5].strip_edges(); - fc.script_class_name = split[6].get_slice("<>", 0); - fc.script_class_extends = split[6].get_slice("<>", 1); - fc.script_class_icon_path = split[6].get_slice("<>", 2); - - String deps = split[7].strip_edges(); + fc.uid = split[2].to_int(); + fc.modification_time = split[3].to_int(); + fc.import_modification_time = split[4].to_int(); + fc.import_valid = split[5].to_int() != 0; + fc.import_group_file = split[6].strip_edges(); + fc.script_class_name = split[7].get_slice("<>", 0); + fc.script_class_extends = split[7].get_slice("<>", 1); + fc.script_class_icon_path = split[7].get_slice("<>", 2); + + String deps = split[8].strip_edges(); if (deps.length()) { Vector<String> dp = deps.split("<>"); for (int i = 0; i < dp.size(); i++) { @@ -368,6 +388,7 @@ bool EditorFileSystem::_test_for_reimport(const String &p_path, bool p_only_impo Vector<String> dest_files; String dest_md5 = ""; int version = 0; + bool found_uid = false; while (true) { assign = Variant(); @@ -395,6 +416,8 @@ bool EditorFileSystem::_test_for_reimport(const String &p_path, bool p_only_impo version = value; } else if (assign == "importer") { importer_name = value; + } else if (assign == "uid") { + found_uid = true; } else if (!p_only_imported_files) { if (assign == "source_file") { source_file = value; @@ -414,6 +437,10 @@ bool EditorFileSystem::_test_for_reimport(const String &p_path, bool p_only_impo return false; //keep mode, do not reimport } + if (!found_uid) { + return true; //UUID not found, old format, reimport. + } + Ref<ResourceImporter> importer = ResourceFormatImporter::get_singleton()->get_importer_by_name(importer_name); if (importer->get_format_version() > version) { @@ -457,8 +484,8 @@ bool EditorFileSystem::_test_for_reimport(const String &p_path, bool p_only_impo memdelete(md5s); //imported files are gone, reimport - for (List<String>::Element *E = to_check.front(); E; E = E->next()) { - if (!FileAccess::exists(E->get())) { + for (const String &E : to_check) { + if (!FileAccess::exists(E)) { return true; } } @@ -497,9 +524,7 @@ bool EditorFileSystem::_update_scan_actions() { Vector<String> reimports; Vector<String> reloads; - for (List<ItemAction>::Element *E = scan_actions.front(); E; E = E->next()) { - ItemAction &ia = E->get(); - + for (const ItemAction &ia : scan_actions) { switch (ia.action) { case ItemAction::ACTION_NONE: { } break; @@ -582,6 +607,9 @@ bool EditorFileSystem::_update_scan_actions() { if (reimports.size()) { reimport_files(reimports); + } else { + //reimport files will update the uid cache file so if nothing was reimported, update it manually + ResourceUID::get_singleton()->update_cache(); } if (first_scan) { @@ -592,7 +620,7 @@ bool EditorFileSystem::_update_scan_actions() { } if (reloads.size()) { - emit_signal("resources_reload", reloads); + emit_signal(SNAME("resources_reload"), reloads); } scan_actions.clear(); @@ -623,8 +651,8 @@ void EditorFileSystem::scan() { new_filesystem = nullptr; _update_scan_actions(); scanning = false; - emit_signal("filesystem_changed"); - emit_signal("sources_changed", sources_changed.size() > 0); + emit_signal(SNAME("filesystem_changed")); + emit_signal(SNAME("sources_changed"), sources_changed.size() > 0); _queue_update_script_classes(); first_scan = false; } else { @@ -756,6 +784,7 @@ void EditorFileSystem::_scan_new_dir(EditorFileSystemDirectory *p_dir, DirAccess if (fc && fc->modification_time == mt && fc->import_modification_time == import_mt && !_test_for_reimport(path, true)) { fi->type = fc->type; + fi->uid = fc->uid; fi->deps = fc->deps; fi->modified_time = fc->modification_time; fi->import_modified_time = fc->import_modification_time; @@ -781,8 +810,14 @@ void EditorFileSystem::_scan_new_dir(EditorFileSystemDirectory *p_dir, DirAccess //note: I think this should not happen any longer.. } + if (fc->uid == ResourceUID::INVALID_ID) { + // imported files should always have a UUID, so attempt to fetch it. + fi->uid = ResourceLoader::get_resource_uid(path); + } + } else { fi->type = ResourceFormatImporter::get_singleton()->get_resource_type(path); + fi->uid = ResourceFormatImporter::get_singleton()->get_resource_uid(path); fi->import_group_file = ResourceFormatImporter::get_singleton()->get_import_group_file(path); fi->script_class_name = _get_global_script_class(fi->type, path, &fi->script_class_extends, &fi->script_class_icon_path); fi->modified_time = 0; @@ -799,6 +834,7 @@ void EditorFileSystem::_scan_new_dir(EditorFileSystemDirectory *p_dir, DirAccess if (fc && fc->modification_time == mt) { //not imported, so just update type if changed fi->type = fc->type; + fi->uid = fc->uid; fi->modified_time = fc->modification_time; fi->deps = fc->deps; fi->import_modified_time = 0; @@ -809,6 +845,7 @@ void EditorFileSystem::_scan_new_dir(EditorFileSystemDirectory *p_dir, DirAccess } else { //new or modified time fi->type = ResourceLoader::get_resource_type(path); + fi->uid = ResourceLoader::get_resource_uid(path); fi->script_class_name = _get_global_script_class(fi->type, path, &fi->script_class_extends, &fi->script_class_icon_path); fi->deps = _get_dependencies(path); fi->modified_time = mt; @@ -817,6 +854,14 @@ void EditorFileSystem::_scan_new_dir(EditorFileSystemDirectory *p_dir, DirAccess } } + if (fi->uid != ResourceUID::INVALID_ID) { + if (ResourceUID::get_singleton()->has_id(fi->uid)) { + ResourceUID::get_singleton()->set_id(fi->uid, path); + } else { + ResourceUID::get_singleton()->add_id(fi->uid, path); + } + } + for (int i = 0; i < ScriptServer::get_language_count(); i++) { ScriptLanguage *lang = ScriptServer::get_language(i); if (lang->supports_documentation() && fi->type == lang->get_type()) { @@ -1027,8 +1072,8 @@ void EditorFileSystem::_delete_internal_files(String p_file) { List<String> paths; ResourceFormatImporter::get_singleton()->get_internal_resource_path_list(p_file, &paths); DirAccess *da = DirAccess::create(DirAccess::ACCESS_RESOURCES); - for (List<String>::Element *E = paths.front(); E; E = E->next()) { - da->remove(E->get()); + for (const String &E : paths) { + da->remove(E); } da->remove(p_file + ".import"); memdelete(da); @@ -1073,12 +1118,12 @@ void EditorFileSystem::scan_changes() { scan_total = 0; _scan_fs_changes(filesystem, sp); if (_update_scan_actions()) { - emit_signal("filesystem_changed"); + emit_signal(SNAME("filesystem_changed")); } } scanning_changes = false; scanning_changes_done = true; - emit_signal("sources_changed", sources_changed.size() > 0); + emit_signal(SNAME("sources_changed"), sources_changed.size() > 0); } else { ERR_FAIL_COND(thread_sources.is_started()); set_process(true); @@ -1092,7 +1137,7 @@ void EditorFileSystem::scan_changes() { void EditorFileSystem::_notification(int p_what) { switch (p_what) { case NOTIFICATION_ENTER_TREE: { - call_deferred("scan"); //this should happen after every editor node entered the tree + call_deferred(SNAME("scan")); //this should happen after every editor node entered the tree } break; case NOTIFICATION_EXIT_TREE: { @@ -1128,9 +1173,9 @@ void EditorFileSystem::_notification(int p_what) { thread_sources.wait_to_finish(); if (_update_scan_actions()) { - emit_signal("filesystem_changed"); + emit_signal(SNAME("filesystem_changed")); } - emit_signal("sources_changed", sources_changed.size() > 0); + emit_signal(SNAME("sources_changed"), sources_changed.size() > 0); _queue_update_script_classes(); first_scan = false; } @@ -1144,8 +1189,8 @@ void EditorFileSystem::_notification(int p_what) { new_filesystem = nullptr; thread.wait_to_finish(); _update_scan_actions(); - emit_signal("filesystem_changed"); - emit_signal("sources_changed", sources_changed.size() > 0); + emit_signal(SNAME("filesystem_changed")); + emit_signal(SNAME("sources_changed"), sources_changed.size() > 0); _queue_update_script_classes(); first_scan = false; } @@ -1181,7 +1226,7 @@ void EditorFileSystem::_save_filesystem_cache(EditorFileSystemDirectory *p_dir, if (p_dir->files[i]->import_group_file != String()) { group_file_cache.insert(p_dir->files[i]->import_group_file); } - String s = p_dir->files[i]->file + "::" + p_dir->files[i]->type + "::" + itos(p_dir->files[i]->modified_time) + "::" + itos(p_dir->files[i]->import_modified_time) + "::" + itos(p_dir->files[i]->import_valid) + "::" + p_dir->files[i]->import_group_file + "::" + p_dir->files[i]->script_class_name + "<>" + p_dir->files[i]->script_class_extends + "<>" + p_dir->files[i]->script_class_icon_path; + String s = p_dir->files[i]->file + "::" + p_dir->files[i]->type + "::" + itos(p_dir->files[i]->uid) + "::" + itos(p_dir->files[i]->modified_time) + "::" + itos(p_dir->files[i]->import_modified_time) + "::" + itos(p_dir->files[i]->import_valid) + "::" + p_dir->files[i]->import_group_file + "::" + p_dir->files[i]->script_class_name + "<>" + p_dir->files[i]->script_class_extends + "<>" + p_dir->files[i]->script_class_icon_path; s += "::"; for (int j = 0; j < p_dir->files[i]->deps.size(); j++) { if (j > 0) { @@ -1368,8 +1413,8 @@ Vector<String> EditorFileSystem::_get_dependencies(const String &p_path) { ResourceLoader::get_dependencies(p_path, &deps); Vector<String> ret; - for (List<String>::Element *E = deps.front(); E; E = E->next()) { - ret.push_back(E->get()); + for (const String &E : deps) { + ret.push_back(E); } return ret; @@ -1445,7 +1490,7 @@ void EditorFileSystem::_queue_update_script_classes() { } update_script_classes_queued.set(); - call_deferred("update_script_classes"); + call_deferred(SNAME("update_script_classes")); } void EditorFileSystem::update_file(const String &p_file) { @@ -1462,16 +1507,22 @@ void EditorFileSystem::update_file(const String &p_file) { //was removed _delete_internal_files(p_file); if (cpos != -1) { // Might've never been part of the editor file system (*.* files deleted in Open dialog). + if (fs->files[cpos]->uid != ResourceUID::INVALID_ID) { + if (ResourceUID::get_singleton()->has_id(fs->files[cpos]->uid)) { + ResourceUID::get_singleton()->remove_id(fs->files[cpos]->uid); + } + } memdelete(fs->files[cpos]); fs->files.remove(cpos); } - call_deferred("emit_signal", "filesystem_changed"); //update later + call_deferred(SNAME("emit_signal"), "filesystem_changed"); //update later _queue_update_script_classes(); return; } String type = ResourceLoader::get_resource_type(p_file); + ResourceUID::ID uid = ResourceLoader::get_resource_uid(p_file); if (cpos == -1) { // The file did not exist, it was added. @@ -1504,16 +1555,26 @@ void EditorFileSystem::update_file(const String &p_file) { } fs->files[cpos]->type = type; + fs->files[cpos]->uid = uid; fs->files[cpos]->script_class_name = _get_global_script_class(type, p_file, &fs->files[cpos]->script_class_extends, &fs->files[cpos]->script_class_icon_path); fs->files[cpos]->import_group_file = ResourceLoader::get_import_group_file(p_file); fs->files[cpos]->modified_time = FileAccess::get_modified_time(p_file); fs->files[cpos]->deps = _get_dependencies(p_file); fs->files[cpos]->import_valid = ResourceLoader::is_import_valid(p_file); + if (uid != ResourceUID::INVALID_ID) { + if (ResourceUID::get_singleton()->has_id(uid)) { + ResourceUID::get_singleton()->set_id(uid, p_file); + } else { + ResourceUID::get_singleton()->add_id(uid, p_file); + } + + ResourceUID::get_singleton()->update_cache(); + } // Update preview EditorResourcePreview::get_singleton()->check_for_invalidation(p_file); - call_deferred("emit_signal", "filesystem_changed"); //update later + call_deferred(SNAME("emit_signal"), "filesystem_changed"); //update later _queue_update_script_classes(); } @@ -1532,7 +1593,6 @@ Error EditorFileSystem::_reimport_group(const String &p_group_file, const Vector ERR_CONTINUE(file_importer_name == String()); if (importer_name != String() && importer_name != file_importer_name) { - print_line("one importer '" + importer_name + "' the other '" + file_importer_name + "'."); EditorNode::get_singleton()->show_warning(vformat(TTR("There are multiple importers for different types pointing to file %s, import aborted"), p_group_file)); ERR_FAIL_V(ERR_FILE_CORRUPT); } @@ -1549,15 +1609,14 @@ Error EditorFileSystem::_reimport_group(const String &p_group_file, const Vector List<ResourceImporter::ImportOption> options; importer->get_import_options(&options); //set default values - for (List<ResourceImporter::ImportOption>::Element *E = options.front(); E; E = E->next()) { - source_file_options[p_files[i]][E->get().option.name] = E->get().default_value; + for (const ResourceImporter::ImportOption &E : options) { + source_file_options[p_files[i]][E.option.name] = E.default_value; } if (config->has_section("params")) { List<String> sk; config->get_section_keys("params", &sk); - for (List<String>::Element *E = sk.front(); E; E = E->next()) { - String param = E->get(); + for (const String ¶m : sk) { Variant value = config->get_value("params", param); //override with whathever is in file source_file_options[p_files[i]][param] = value; @@ -1631,9 +1690,9 @@ Error EditorFileSystem::_reimport_group(const String &p_group_file, const Vector List<ResourceImporter::ImportOption> options; importer->get_import_options(&options); //set default values - for (List<ResourceImporter::ImportOption>::Element *F = options.front(); F; F = F->next()) { - String base = F->get().option.name; - Variant v = F->get().default_value; + for (const ResourceImporter::ImportOption &F : options) { + String base = F.option.name; + Variant v = F.default_value; if (source_file_options[file].has(base)) { v = source_file_options[file][base]; } @@ -1702,6 +1761,8 @@ void EditorFileSystem::_reimport_file(const String &p_file, const Map<StringName params = *p_custom_options; } + ResourceUID::ID uid = ResourceUID::INVALID_ID; + if (FileAccess::exists(p_file + ".import")) { //use existing if (p_custom_options == nullptr) { @@ -1712,12 +1773,20 @@ void EditorFileSystem::_reimport_file(const String &p_file, const Map<StringName if (cf->has_section("params")) { List<String> sk; cf->get_section_keys("params", &sk); - for (List<String>::Element *E = sk.front(); E; E = E->next()) { - params[E->get()] = cf->get_value("params", E->get()); + for (const String &E : sk) { + params[E] = cf->get_value("params", E); } } - if (p_custom_importer == String() && cf->has_section("remap")) { - importer_name = cf->get_value("remap", "importer"); + + if (cf->has_section("remap")) { + if (p_custom_importer == String()) { + importer_name = cf->get_value("remap", "importer"); + } + + if (cf->has_section_key("remap", "uid")) { + String uidt = cf->get_value("remap", "uid"); + uid = ResourceUID::get_singleton()->text_to_id(uidt); + } } } } @@ -1754,9 +1823,9 @@ void EditorFileSystem::_reimport_file(const String &p_file, const Map<StringName List<ResourceImporter::ImportOption> opts; importer->get_import_options(&opts); - for (List<ResourceImporter::ImportOption>::Element *E = opts.front(); E; E = E->next()) { - if (!params.has(E->get().option.name)) { //this one is not present - params[E->get().option.name] = E->get().default_value; + for (const ResourceImporter::ImportOption &E : opts) { + if (!params.has(E.option.name)) { //this one is not present + params[E.option.name] = E.default_value; } } @@ -1766,8 +1835,8 @@ void EditorFileSystem::_reimport_file(const String &p_file, const Map<StringName List<Variant> v; d.get_key_list(&v); - for (List<Variant>::Element *E = v.front(); E; E = E->next()) { - params[E->get()] = d[E->get()]; + for (const Variant &E : v) { + params[E] = d[E]; } } @@ -1800,6 +1869,12 @@ void EditorFileSystem::_reimport_file(const String &p_file, const Map<StringName f->store_line("type=\"" + importer->get_resource_type() + "\""); } + if (uid == ResourceUID::INVALID_ID) { + uid = ResourceUID::get_singleton()->create_id(); + } + + f->store_line("uid=\"" + ResourceUID::get_singleton()->id_to_text(uid) + "\""); //store in readable format + Vector<String> dest_paths; if (err == OK) { @@ -1807,10 +1882,10 @@ void EditorFileSystem::_reimport_file(const String &p_file, const Map<StringName //no path } else if (import_variants.size()) { //import with variants - for (List<String>::Element *E = import_variants.front(); E; E = E->next()) { - String path = base_path.c_escape() + "." + E->get() + "." + importer->get_save_extension(); + for (const String &E : import_variants) { + String path = base_path.c_escape() + "." + E + "." + importer->get_save_extension(); - f->store_line("path." + E->get() + "=\"" + path + "\""); + f->store_line("path." + E + "=\"" + path + "\""); dest_paths.push_back(path); } } else { @@ -1833,9 +1908,9 @@ void EditorFileSystem::_reimport_file(const String &p_file, const Map<StringName if (gen_files.size()) { Array genf; - for (List<String>::Element *E = gen_files.front(); E; E = E->next()) { - genf.push_back(E->get()); - dest_paths.push_back(E->get()); + for (const String &E : gen_files) { + genf.push_back(E); + dest_paths.push_back(E); } String value; @@ -1859,8 +1934,8 @@ void EditorFileSystem::_reimport_file(const String &p_file, const Map<StringName //store options in provided order, to avoid file changing. Order is also important because first match is accepted first. - for (List<ResourceImporter::ImportOption>::Element *E = opts.front(); E; E = E->next()) { - String base = E->get().option.name; + for (const ResourceImporter::ImportOption &E : opts) { + String base = E.option.name; String value; VariantWriter::write_to_string(params[base], value); f->store_line(base + "=" + value); @@ -1885,8 +1960,15 @@ void EditorFileSystem::_reimport_file(const String &p_file, const Map<StringName fs->files[cpos]->import_modified_time = FileAccess::get_modified_time(p_file + ".import"); fs->files[cpos]->deps = _get_dependencies(p_file); fs->files[cpos]->type = importer->get_resource_type(); + fs->files[cpos]->uid = uid; fs->files[cpos]->import_valid = ResourceLoader::is_import_valid(p_file); + if (ResourceUID::get_singleton()->has_id(uid)) { + ResourceUID::get_singleton()->set_id(uid, p_file); + } else { + ResourceUID::get_singleton()->add_id(uid, p_file); + } + //if file is currently up, maybe the source it was loaded from changed, so import math must be updated for it //to reload properly if (ResourceCache::has(p_file)) { @@ -1937,11 +2019,18 @@ void EditorFileSystem::reimport_files(const Vector<String> &p_files) { Set<String> groups_to_reimport; for (int i = 0; i < p_files.size(); i++) { - String group_file = ResourceFormatImporter::get_singleton()->get_import_group_file(p_files[i]); + String file = p_files[i]; + + ResourceUID::ID uid = ResourceUID::get_singleton()->text_to_id(file); + if (uid != ResourceUID::INVALID_ID && ResourceUID::get_singleton()->has_id(uid)) { + file = ResourceUID::get_singleton()->get_id_path(uid); + } + + String group_file = ResourceFormatImporter::get_singleton()->get_import_group_file(file); - if (group_file_cache.has(p_files[i])) { + if (group_file_cache.has(file)) { //maybe the file itself is a group! - groups_to_reimport.insert(p_files[i]); + groups_to_reimport.insert(file); //groups do not belong to grups group_file = String(); } else if (group_file != String()) { @@ -1950,15 +2039,15 @@ void EditorFileSystem::reimport_files(const Vector<String> &p_files) { } else { //it's a regular file ImportFile ifile; - ifile.path = p_files[i]; - ResourceFormatImporter::get_singleton()->get_import_order_threads_and_importer(p_files[i], ifile.order, ifile.threaded, ifile.importer); + ifile.path = file; + ResourceFormatImporter::get_singleton()->get_import_order_threads_and_importer(file, ifile.order, ifile.threaded, ifile.importer); reimport_files.push_back(ifile); } //group may have changed, so also update group reference EditorFileSystemDirectory *fs = nullptr; int cpos = -1; - if (_find_file(p_files[i], &fs, cpos)) { + if (_find_file(file, &fs, cpos)) { fs->files.write[cpos]->import_group_file = group_file; } } @@ -2023,13 +2112,15 @@ void EditorFileSystem::reimport_files(const Vector<String> &p_files) { } } + ResourceUID::get_singleton()->update_cache(); //after reimporting, update the cache + _save_filesystem_cache(); importing = false; if (!is_scanning()) { - emit_signal("filesystem_changed"); + emit_signal(SNAME("filesystem_changed")); } - emit_signal("resources_reimported", p_files); + emit_signal(SNAME("resources_reimported"), p_files); } Error EditorFileSystem::_resource_import(const String &p_path) { @@ -2080,9 +2171,8 @@ void EditorFileSystem::_move_group_files(EditorFileSystemDirectory *efd, const S List<String> sk; config->get_section_keys("params", &sk); - for (List<String>::Element *E = sk.front(); E; E = E->next()) { + for (const String ¶m : sk) { //not very clean, but should work - String param = E->get(); String value = config->get_value("params", param); if (value == p_group_file) { config->set_value("params", param, p_new_location); @@ -2108,6 +2198,30 @@ void EditorFileSystem::move_group_file(const String &p_path, const String &p_new } } +ResourceUID::ID EditorFileSystem::_resource_saver_get_resource_id_for_path(const String &p_path, bool p_generate) { + if (!p_path.is_resource_file() || p_path.begins_with("res://.godot")) { + //saved externally (configuration file) or internal file, do not assign an ID. + return ResourceUID::INVALID_ID; + } + + EditorFileSystemDirectory *fs = nullptr; + int cpos = -1; + + if (!singleton->_find_file(p_path, &fs, cpos)) { + if (p_generate) { + return ResourceUID::get_singleton()->create_id(); //just create a new one, we will be notified of save anyway and fetch the right UUID at that time, to keep things simple. + } else { + return ResourceUID::INVALID_ID; + } + } else if (fs->files[cpos]->uid != ResourceUID::INVALID_ID) { + return fs->files[cpos]->uid; + } else if (p_generate) { + return ResourceUID::get_singleton()->create_id(); //just create a new one, we will be notified of save anyway and fetch the right UUID at that time, to keep things simple. + } else { + return ResourceUID::INVALID_ID; + } +} + void EditorFileSystem::_bind_methods() { ClassDB::bind_method(D_METHOD("get_filesystem"), &EditorFileSystem::get_filesystem); ClassDB::bind_method(D_METHOD("is_scanning"), &EditorFileSystem::is_scanning); @@ -2131,14 +2245,14 @@ void EditorFileSystem::_update_extensions() { List<String> extensionsl; ResourceLoader::get_recognized_extensions_for_type("", &extensionsl); - for (List<String>::Element *E = extensionsl.front(); E; E = E->next()) { - valid_extensions.insert(E->get()); + for (const String &E : extensionsl) { + valid_extensions.insert(E); } extensionsl.clear(); ResourceFormatImporter::get_singleton()->get_recognized_extensions(&extensionsl); - for (List<String>::Element *E = extensionsl.front(); E; E = E->next()) { - import_extensions.insert(E->get()); + for (const String &E : extensionsl) { + import_extensions.insert(E); } } @@ -2169,8 +2283,11 @@ EditorFileSystem::EditorFileSystem() { scan_changes_pending = false; revalidate_import_files = false; import_threads.init(); + ResourceUID::get_singleton()->clear(); //will be updated on scan + ResourceSaver::set_get_resource_id_for_path(_resource_saver_get_resource_id_for_path); } EditorFileSystem::~EditorFileSystem() { import_threads.finish(); + ResourceSaver::set_get_resource_id_for_path(nullptr); } diff --git a/editor/editor_file_system.h b/editor/editor_file_system.h index 37eee13c16..9dce29d09c 100644 --- a/editor/editor_file_system.h +++ b/editor/editor_file_system.h @@ -55,6 +55,7 @@ class EditorFileSystemDirectory : public Object { struct FileInfo { String file; StringName type; + ResourceUID::ID uid = ResourceUID::INVALID_ID; uint64_t modified_time = 0; uint64_t import_modified_time = 0; bool import_valid = false; @@ -159,6 +160,7 @@ class EditorFileSystem : public Node { /* Used for reading the filesystem cache file */ struct FileCache { String type; + ResourceUID::ID uid = ResourceUID::INVALID_ID; uint64_t modification_time = 0; uint64_t import_modification_time = 0; Vector<String> deps; @@ -251,6 +253,8 @@ class EditorFileSystem : public Node { void _reimport_thread(uint32_t p_index, ImportThreadData *p_import_data); + static ResourceUID::ID _resource_saver_get_resource_id_for_path(const String &p_path, bool p_generate); + protected: void _notification(int p_what); static void _bind_methods(); diff --git a/editor/editor_folding.cpp b/editor/editor_folding.cpp index 5d6c415d39..29e3236ac2 100644 --- a/editor/editor_folding.cpp +++ b/editor/editor_folding.cpp @@ -109,10 +109,10 @@ void EditorFolding::_fill_folds(const Node *p_root, const Node *p_node, Array &p List<PropertyInfo> plist; p_node->get_property_list(&plist); - for (List<PropertyInfo>::Element *E = plist.front(); E; E = E->next()) { - if (E->get().usage & PROPERTY_USAGE_EDITOR) { - if (E->get().type == Variant::OBJECT) { - RES res = p_node->get(E->get().name); + for (const PropertyInfo &E : plist) { + if (E.usage & PROPERTY_USAGE_EDITOR) { + if (E.type == Variant::OBJECT) { + RES res = p_node->get(E.name); if (res.is_valid() && !resources.has(res) && res->get_path() != String() && !res->get_path().is_resource_file()) { Vector<String> res_unfolds = _get_unfolds(res.ptr()); resource_folds.push_back(res->get_path()); @@ -228,41 +228,41 @@ void EditorFolding::_do_object_unfolds(Object *p_object, Set<RES> &resources) { Set<String> unfold_group; - for (List<PropertyInfo>::Element *E = plist.front(); E; E = E->next()) { - if (E->get().usage & PROPERTY_USAGE_CATEGORY) { + for (const PropertyInfo &E : plist) { + if (E.usage & PROPERTY_USAGE_CATEGORY) { group = ""; group_base = ""; } - if (E->get().usage & PROPERTY_USAGE_GROUP) { - group = E->get().name; - group_base = E->get().hint_string; + if (E.usage & PROPERTY_USAGE_GROUP) { + group = E.name; + group_base = E.hint_string; if (group_base.ends_with("_")) { group_base = group_base.substr(0, group_base.length() - 1); } } //can unfold - if (E->get().usage & PROPERTY_USAGE_EDITOR) { + if (E.usage & PROPERTY_USAGE_EDITOR) { if (group != "") { //group - if (group_base == String() || E->get().name.begins_with(group_base)) { - bool can_revert = EditorPropertyRevert::can_property_revert(p_object, E->get().name); + if (group_base == String() || E.name.begins_with(group_base)) { + bool can_revert = EditorPropertyRevert::can_property_revert(p_object, E.name); if (can_revert) { unfold_group.insert(group); } } } else { //path - int last = E->get().name.rfind("/"); + int last = E.name.rfind("/"); if (last != -1) { - bool can_revert = EditorPropertyRevert::can_property_revert(p_object, E->get().name); + bool can_revert = EditorPropertyRevert::can_property_revert(p_object, E.name); if (can_revert) { - unfold_group.insert(E->get().name.substr(0, last)); + unfold_group.insert(E.name.substr(0, last)); } } } - if (E->get().type == Variant::OBJECT) { - RES res = p_object->get(E->get().name); - print_line("res: " + String(E->get().name) + " valid " + itos(res.is_valid())); + if (E.type == Variant::OBJECT) { + RES res = p_object->get(E.name); + print_line("res: " + String(E.name) + " valid " + itos(res.is_valid())); if (res.is_valid()) { print_line("path " + res->get_path()); } diff --git a/editor/editor_fonts.cpp b/editor/editor_fonts.cpp index 8968e562c1..1e3db1a7b0 100644 --- a/editor/editor_fonts.cpp +++ b/editor/editor_fonts.cpp @@ -37,19 +37,34 @@ #include "scene/resources/default_theme/default_theme.h" #include "scene/resources/font.h" -#define MAKE_FALLBACKS(m_name) \ - m_name->add_data(FontArabic); \ - m_name->add_data(FontBengali); \ - m_name->add_data(FontGeorgian); \ - m_name->add_data(FontMalayalam); \ - m_name->add_data(FontOriya); \ - m_name->add_data(FontSinhala); \ - m_name->add_data(FontTamil); \ - m_name->add_data(FontTelugu); \ - m_name->add_data(FontHebrew); \ - m_name->add_data(FontThai); \ - m_name->add_data(FontHindi); \ - m_name->add_data(FontJapanese); \ +#define MAKE_FALLBACKS(m_name) \ + m_name->add_data(FontArabic); \ + m_name->add_data(FontBengali); \ + m_name->add_data(FontDevanagari); \ + m_name->add_data(FontGeorgian); \ + m_name->add_data(FontHebrew); \ + m_name->add_data(FontMalayalam); \ + m_name->add_data(FontOriya); \ + m_name->add_data(FontSinhala); \ + m_name->add_data(FontTamil); \ + m_name->add_data(FontTelugu); \ + m_name->add_data(FontThai); \ + m_name->add_data(FontJapanese); \ + m_name->add_data(FontFallback); + +#define MAKE_FALLBACKS_BOLD(m_name) \ + m_name->add_data(FontArabicBold); \ + m_name->add_data(FontBengaliBold); \ + m_name->add_data(FontDevanagariBold); \ + m_name->add_data(FontGeorgianBold); \ + m_name->add_data(FontHebrewBold); \ + m_name->add_data(FontMalayalamBold); \ + m_name->add_data(FontOriyaBold); \ + m_name->add_data(FontSinhalaBold); \ + m_name->add_data(FontTamilBold); \ + m_name->add_data(FontTeluguBold); \ + m_name->add_data(FontThaiBold); \ + m_name->add_data(FontJapanese); \ m_name->add_data(FontFallback); // the custom spacings might only work with Noto Sans @@ -77,7 +92,7 @@ } \ m_name->set_spacing(Font::SPACING_TOP, -EDSCALE); \ m_name->set_spacing(Font::SPACING_BOTTOM, -EDSCALE); \ - MAKE_FALLBACKS(m_name); + MAKE_FALLBACKS_BOLD(m_name); #define MAKE_SOURCE_FONT(m_name) \ Ref<Font> m_name; \ @@ -175,36 +190,22 @@ void editor_register_fonts(Ref<Theme> p_theme) { memdelete(dir); - /* Droid Sans */ + /* Noto Sans UI */ Ref<FontData> DefaultFont; DefaultFont.instantiate(); - DefaultFont->load_memory(_font_NotoSansUI_Regular, _font_NotoSansUI_Regular_size, "ttf", default_font_size); + DefaultFont->load_memory(_font_NotoSans_Regular, _font_NotoSans_Regular_size, "ttf", default_font_size); DefaultFont->set_antialiased(font_antialiased); DefaultFont->set_hinting(font_hinting); DefaultFont->set_force_autohinter(true); //just looks better..i think? Ref<FontData> DefaultFontBold; DefaultFontBold.instantiate(); - DefaultFontBold->load_memory(_font_NotoSansUI_Bold, _font_NotoSansUI_Bold_size, "ttf", default_font_size); + DefaultFontBold->load_memory(_font_NotoSans_Bold, _font_NotoSans_Bold_size, "ttf", default_font_size); DefaultFontBold->set_antialiased(font_antialiased); DefaultFontBold->set_hinting(font_hinting); DefaultFontBold->set_force_autohinter(true); // just looks better..i think? - Ref<FontData> FontFallback; - FontFallback.instantiate(); - FontFallback->load_memory(_font_DroidSansFallback, _font_DroidSansFallback_size, "ttf", default_font_size); - FontFallback->set_antialiased(font_antialiased); - FontFallback->set_hinting(font_hinting); - FontFallback->set_force_autohinter(true); //just looks better..i think? - - Ref<FontData> FontJapanese; - FontJapanese.instantiate(); - FontJapanese->load_memory(_font_DroidSansJapanese, _font_DroidSansJapanese_size, "ttf", default_font_size); - FontJapanese->set_antialiased(font_antialiased); - FontJapanese->set_hinting(font_hinting); - FontJapanese->set_force_autohinter(true); //just looks better..i think? - Ref<FontData> FontArabic; FontArabic.instantiate(); FontArabic->load_memory(_font_NotoNaskhArabicUI_Regular, _font_NotoNaskhArabicUI_Regular_size, "ttf", default_font_size); @@ -212,13 +213,41 @@ void editor_register_fonts(Ref<Theme> p_theme) { FontArabic->set_hinting(font_hinting); FontArabic->set_force_autohinter(true); //just looks better..i think? + Ref<FontData> FontArabicBold; + FontArabicBold.instantiate(); + FontArabicBold->load_memory(_font_NotoNaskhArabicUI_Bold, _font_NotoNaskhArabicUI_Bold_size, "ttf", default_font_size); + FontArabicBold->set_antialiased(font_antialiased); + FontArabicBold->set_hinting(font_hinting); + FontArabicBold->set_force_autohinter(true); //just looks better..i think? + Ref<FontData> FontBengali; FontBengali.instantiate(); - FontBengali->load_memory(_font_NotoSansBengali_Regular, _font_NotoSansBengali_Regular_size, "ttf", default_font_size); + FontBengali->load_memory(_font_NotoSansBengaliUI_Regular, _font_NotoSansBengaliUI_Regular_size, "ttf", default_font_size); FontBengali->set_antialiased(font_antialiased); FontBengali->set_hinting(font_hinting); FontBengali->set_force_autohinter(true); //just looks better..i think? + Ref<FontData> FontBengaliBold; + FontBengaliBold.instantiate(); + FontBengaliBold->load_memory(_font_NotoSansBengaliUI_Bold, _font_NotoSansBengaliUI_Bold_size, "ttf", default_font_size); + FontBengaliBold->set_antialiased(font_antialiased); + FontBengaliBold->set_hinting(font_hinting); + FontBengaliBold->set_force_autohinter(true); //just looks better..i think? + + Ref<FontData> FontDevanagari; + FontDevanagari.instantiate(); + FontDevanagari->load_memory(_font_NotoSansDevanagariUI_Regular, _font_NotoSansDevanagariUI_Regular_size, "ttf", default_font_size); + FontDevanagari->set_antialiased(font_antialiased); + FontDevanagari->set_hinting(font_hinting); + FontDevanagari->set_force_autohinter(true); //just looks better..i think? + + Ref<FontData> FontDevanagariBold; + FontDevanagariBold.instantiate(); + FontDevanagariBold->load_memory(_font_NotoSansDevanagariUI_Bold, _font_NotoSansDevanagariUI_Bold_size, "ttf", default_font_size); + FontDevanagariBold->set_antialiased(font_antialiased); + FontDevanagariBold->set_hinting(font_hinting); + FontDevanagariBold->set_force_autohinter(true); //just looks better..i think? + Ref<FontData> FontGeorgian; FontGeorgian.instantiate(); FontGeorgian->load_memory(_font_NotoSansGeorgian_Regular, _font_NotoSansGeorgian_Regular_size, "ttf", default_font_size); @@ -226,6 +255,13 @@ void editor_register_fonts(Ref<Theme> p_theme) { FontGeorgian->set_hinting(font_hinting); FontGeorgian->set_force_autohinter(true); //just looks better..i think? + Ref<FontData> FontGeorgianBold; + FontGeorgianBold.instantiate(); + FontGeorgianBold->load_memory(_font_NotoSansGeorgian_Bold, _font_NotoSansGeorgian_Bold_size, "ttf", default_font_size); + FontGeorgianBold->set_antialiased(font_antialiased); + FontGeorgianBold->set_hinting(font_hinting); + FontGeorgianBold->set_force_autohinter(true); //just looks better..i think? + Ref<FontData> FontHebrew; FontHebrew.instantiate(); FontHebrew->load_memory(_font_NotoSansHebrew_Regular, _font_NotoSansHebrew_Regular_size, "ttf", default_font_size); @@ -233,6 +269,13 @@ void editor_register_fonts(Ref<Theme> p_theme) { FontHebrew->set_hinting(font_hinting); FontHebrew->set_force_autohinter(true); //just looks better..i think? + Ref<FontData> FontHebrewBold; + FontHebrewBold.instantiate(); + FontHebrewBold->load_memory(_font_NotoSansHebrew_Bold, _font_NotoSansHebrew_Bold_size, "ttf", default_font_size); + FontHebrewBold->set_antialiased(font_antialiased); + FontHebrewBold->set_hinting(font_hinting); + FontHebrewBold->set_force_autohinter(true); //just looks better..i think? + Ref<FontData> FontMalayalam; FontMalayalam.instantiate(); FontMalayalam->load_memory(_font_NotoSansMalayalamUI_Regular, _font_NotoSansMalayalamUI_Regular_size, "ttf", default_font_size); @@ -240,6 +283,13 @@ void editor_register_fonts(Ref<Theme> p_theme) { FontMalayalam->set_hinting(font_hinting); FontMalayalam->set_force_autohinter(true); //just looks better..i think? + Ref<FontData> FontMalayalamBold; + FontMalayalamBold.instantiate(); + FontMalayalamBold->load_memory(_font_NotoSansMalayalamUI_Bold, _font_NotoSansMalayalamUI_Bold_size, "ttf", default_font_size); + FontMalayalamBold->set_antialiased(font_antialiased); + FontMalayalamBold->set_hinting(font_hinting); + FontMalayalamBold->set_force_autohinter(true); //just looks better..i think? + Ref<FontData> FontOriya; FontOriya.instantiate(); FontOriya->load_memory(_font_NotoSansOriyaUI_Regular, _font_NotoSansOriyaUI_Regular_size, "ttf", default_font_size); @@ -247,6 +297,13 @@ void editor_register_fonts(Ref<Theme> p_theme) { FontOriya->set_hinting(font_hinting); FontOriya->set_force_autohinter(true); //just looks better..i think? + Ref<FontData> FontOriyaBold; + FontOriyaBold.instantiate(); + FontOriyaBold->load_memory(_font_NotoSansOriyaUI_Bold, _font_NotoSansOriyaUI_Bold_size, "ttf", default_font_size); + FontOriyaBold->set_antialiased(font_antialiased); + FontOriyaBold->set_hinting(font_hinting); + FontOriyaBold->set_force_autohinter(true); //just looks better..i think? + Ref<FontData> FontSinhala; FontSinhala.instantiate(); FontSinhala->load_memory(_font_NotoSansSinhalaUI_Regular, _font_NotoSansSinhalaUI_Regular_size, "ttf", default_font_size); @@ -254,6 +311,13 @@ void editor_register_fonts(Ref<Theme> p_theme) { FontSinhala->set_hinting(font_hinting); FontSinhala->set_force_autohinter(true); //just looks better..i think? + Ref<FontData> FontSinhalaBold; + FontSinhalaBold.instantiate(); + FontSinhalaBold->load_memory(_font_NotoSansSinhalaUI_Bold, _font_NotoSansSinhalaUI_Bold_size, "ttf", default_font_size); + FontSinhalaBold->set_antialiased(font_antialiased); + FontSinhalaBold->set_hinting(font_hinting); + FontSinhalaBold->set_force_autohinter(true); //just looks better..i think? + Ref<FontData> FontTamil; FontTamil.instantiate(); FontTamil->load_memory(_font_NotoSansTamilUI_Regular, _font_NotoSansTamilUI_Regular_size, "ttf", default_font_size); @@ -261,6 +325,13 @@ void editor_register_fonts(Ref<Theme> p_theme) { FontTamil->set_hinting(font_hinting); FontTamil->set_force_autohinter(true); //just looks better..i think? + Ref<FontData> FontTamilBold; + FontTamilBold.instantiate(); + FontTamilBold->load_memory(_font_NotoSansTamilUI_Bold, _font_NotoSansTamilUI_Bold_size, "ttf", default_font_size); + FontTamilBold->set_antialiased(font_antialiased); + FontTamilBold->set_hinting(font_hinting); + FontTamilBold->set_force_autohinter(true); //just looks better..i think? + Ref<FontData> FontTelugu; FontTelugu.instantiate(); FontTelugu->load_memory(_font_NotoSansTeluguUI_Regular, _font_NotoSansTeluguUI_Regular_size, "ttf", default_font_size); @@ -268,6 +339,13 @@ void editor_register_fonts(Ref<Theme> p_theme) { FontTelugu->set_hinting(font_hinting); FontTelugu->set_force_autohinter(true); //just looks better..i think? + Ref<FontData> FontTeluguBold; + FontTeluguBold.instantiate(); + FontTeluguBold->load_memory(_font_NotoSansTeluguUI_Bold, _font_NotoSansTeluguUI_Bold_size, "ttf", default_font_size); + FontTeluguBold->set_antialiased(font_antialiased); + FontTeluguBold->set_hinting(font_hinting); + FontTeluguBold->set_force_autohinter(true); //just looks better..i think? + Ref<FontData> FontThai; FontThai.instantiate(); FontThai->load_memory(_font_NotoSansThaiUI_Regular, _font_NotoSansThaiUI_Regular_size, "ttf", default_font_size); @@ -275,12 +353,30 @@ void editor_register_fonts(Ref<Theme> p_theme) { FontThai->set_hinting(font_hinting); FontThai->set_force_autohinter(true); //just looks better..i think? - Ref<FontData> FontHindi; - FontHindi.instantiate(); - FontHindi->load_memory(_font_NotoSansDevanagariUI_Regular, _font_NotoSansDevanagariUI_Regular_size, "ttf", default_font_size); - FontHindi->set_antialiased(font_antialiased); - FontHindi->set_hinting(font_hinting); - FontHindi->set_force_autohinter(true); //just looks better..i think? + Ref<FontData> FontThaiBold; + FontThaiBold.instantiate(); + FontThaiBold->load_memory(_font_NotoSansThaiUI_Bold, _font_NotoSansThaiUI_Bold_size, "ttf", default_font_size); + FontThaiBold->set_antialiased(font_antialiased); + FontThaiBold->set_hinting(font_hinting); + FontThaiBold->set_force_autohinter(true); //just looks better..i think? + + /* Droid Sans Fallback */ + + Ref<FontData> FontFallback; + FontFallback.instantiate(); + FontFallback->load_memory(_font_DroidSansFallback, _font_DroidSansFallback_size, "ttf", default_font_size); + FontFallback->set_antialiased(font_antialiased); + FontFallback->set_hinting(font_hinting); + FontFallback->set_force_autohinter(true); //just looks better..i think? + + /* Droid Sans Japanese */ + + Ref<FontData> FontJapanese; + FontJapanese.instantiate(); + FontJapanese->load_memory(_font_DroidSansJapanese, _font_DroidSansJapanese_size, "ttf", default_font_size); + FontJapanese->set_antialiased(font_antialiased); + FontJapanese->set_hinting(font_hinting); + FontJapanese->set_force_autohinter(true); //just looks better..i think? /* Hack */ diff --git a/editor/editor_help.cpp b/editor/editor_help.cpp index 16db465a4a..569a28215c 100644 --- a/editor/editor_help.cpp +++ b/editor/editor_help.cpp @@ -43,16 +43,16 @@ DocTools *EditorHelp::doc = nullptr; void EditorHelp::_init_colors() { - title_color = get_theme_color("accent_color", "Editor"); - text_color = get_theme_color("default_color", "RichTextLabel"); - headline_color = get_theme_color("headline_color", "EditorHelp"); + title_color = get_theme_color(SNAME("accent_color"), SNAME("Editor")); + text_color = get_theme_color(SNAME("default_color"), SNAME("RichTextLabel")); + headline_color = get_theme_color(SNAME("headline_color"), SNAME("EditorHelp")); base_type_color = title_color.lerp(text_color, 0.5); comment_color = text_color * Color(1, 1, 1, 0.6); symbol_color = comment_color; value_color = text_color * Color(1, 1, 1, 0.6); qualifier_color = text_color * Color(1, 1, 1, 0.8); - type_color = get_theme_color("accent_color", "Editor").lerp(text_color, 0.5); - class_desc->add_theme_color_override("selection_color", get_theme_color("accent_color", "Editor") * Color(1, 1, 1, 0.4)); + type_color = get_theme_color(SNAME("accent_color"), SNAME("Editor")).lerp(text_color, 0.5); + class_desc->add_theme_color_override("selection_color", get_theme_color(SNAME("accent_color"), SNAME("Editor")) * Color(1, 1, 1, 0.4)); class_desc->add_theme_constant_override("line_separation", Math::round(5 * EDSCALE)); } @@ -78,10 +78,10 @@ void EditorHelp::_class_desc_select(const String &p_select) { } else { class_name = "@GlobalScope"; } - emit_signal("go_to_help", "class_enum:" + class_name + ":" + select); + emit_signal(SNAME("go_to_help"), "class_enum:" + class_name + ":" + select); return; } else if (p_select.begins_with("#")) { - emit_signal("go_to_help", "class_name:" + p_select.substr(1, p_select.length())); + emit_signal(SNAME("go_to_help"), "class_name:" + p_select.substr(1, p_select.length())); return; } else if (p_select.begins_with("@")) { int tag_end = p_select.find(" "); @@ -112,7 +112,7 @@ void EditorHelp::_class_desc_select(const String &p_select) { } if (link.find(".") != -1) { - emit_signal("go_to_help", topic + ":" + link.get_slice(".", 0) + ":" + link.get_slice(".", 1)); + emit_signal(SNAME("go_to_help"), topic + ":" + link.get_slice(".", 0) + ":" + link.get_slice(".", 1)); } else { if (table->has(link)) { // Found in the current page @@ -125,7 +125,7 @@ void EditorHelp::_class_desc_select(const String &p_select) { for (int i = 0; i < cd.constants.size(); i++) { if (cd.constants[i].enumeration == link) { // Found in @GlobalScope - emit_signal("go_to_help", topic + ":@GlobalScope:" + link); + emit_signal(SNAME("go_to_help"), topic + ":@GlobalScope:" + link); break; } } @@ -136,7 +136,7 @@ void EditorHelp::_class_desc_select(const String &p_select) { for (int i = 0; i < cd.constants.size(); i++) { if (cd.constants[i].name == link) { // Found in @GlobalScope - emit_signal("go_to_help", topic + ":@GlobalScope:" + link); + emit_signal(SNAME("go_to_help"), topic + ":@GlobalScope:" + link); break; } } @@ -154,12 +154,12 @@ void EditorHelp::_class_desc_input(const Ref<InputEvent> &p_input) { void EditorHelp::_class_desc_resized() { // Add extra horizontal margins for better readability. // The margins increase as the width of the editor help container increases. - Ref<Font> doc_code_font = get_theme_font("doc_source", "EditorFonts"); - int font_size = get_theme_font_size("doc_source_size", "EditorFonts"); + Ref<Font> doc_code_font = get_theme_font(SNAME("doc_source"), SNAME("EditorFonts")); + int font_size = get_theme_font_size(SNAME("doc_source_size"), SNAME("EditorFonts")); real_t char_width = doc_code_font->get_char_size('x', 0, font_size).width; const int display_margin = MAX(30 * EDSCALE, get_parent_anchorable_rect().size.width - char_width * 120 * EDSCALE) * 0.5; - Ref<StyleBox> class_desc_stylebox = EditorNode::get_singleton()->get_theme_base()->get_theme_stylebox("normal", "RichTextLabel")->duplicate(); + Ref<StyleBox> class_desc_stylebox = EditorNode::get_singleton()->get_theme_base()->get_theme_stylebox(SNAME("normal"), SNAME("RichTextLabel"))->duplicate(); class_desc_stylebox->set_default_margin(SIDE_LEFT, display_margin); class_desc_stylebox->set_default_margin(SIDE_RIGHT, display_margin); class_desc->add_theme_style_override("normal", class_desc_stylebox); @@ -179,8 +179,8 @@ void EditorHelp::_add_type(const String &p_type, const String &p_enum) { t = p_enum.get_slice(".", 0); } } - const Color text_color = get_theme_color("default_color", "RichTextLabel"); - const Color type_color = get_theme_color("accent_color", "Editor").lerp(text_color, 0.5); + const Color text_color = get_theme_color(SNAME("default_color"), SNAME("RichTextLabel")); + const Color type_color = get_theme_color(SNAME("accent_color"), SNAME("Editor")).lerp(text_color, 0.5); class_desc->push_color(type_color); bool add_array = false; if (can_ref) { @@ -344,10 +344,10 @@ void EditorHelp::_update_doc() { DocData::ClassDoc cd = doc->class_list[edited_class]; //make a copy, so we can sort without worrying - Ref<Font> doc_font = get_theme_font("doc", "EditorFonts"); - Ref<Font> doc_bold_font = get_theme_font("doc_bold", "EditorFonts"); - Ref<Font> doc_title_font = get_theme_font("doc_title", "EditorFonts"); - Ref<Font> doc_code_font = get_theme_font("doc_source", "EditorFonts"); + Ref<Font> doc_font = get_theme_font(SNAME("doc"), SNAME("EditorFonts")); + Ref<Font> doc_bold_font = get_theme_font(SNAME("doc_bold"), SNAME("EditorFonts")); + Ref<Font> doc_title_font = get_theme_font(SNAME("doc_title"), SNAME("EditorFonts")); + Ref<Font> doc_code_font = get_theme_font(SNAME("doc_source"), SNAME("EditorFonts")); String link_color_text = title_color.to_html(false); // Class name @@ -1177,7 +1177,7 @@ void EditorHelp::_update_doc() { if (!cd.properties[i].description.strip_edges().is_empty()) { _add_text(DTR(cd.properties[i].description)); } else { - class_desc->add_image(get_theme_icon("Error", "EditorIcons")); + class_desc->add_image(get_theme_icon(SNAME("Error"), SNAME("EditorIcons"))); class_desc->add_text(" "); class_desc->push_color(comment_color); if (cd.is_script_doc) { @@ -1232,7 +1232,7 @@ void EditorHelp::_update_doc() { if (!methods_filtered[i].description.strip_edges().is_empty()) { _add_text(DTR(methods_filtered[i].description)); } else { - class_desc->add_image(get_theme_icon("Error", "EditorIcons")); + class_desc->add_image(get_theme_icon(SNAME("Error"), SNAME("EditorIcons"))); class_desc->add_text(" "); class_desc->push_color(comment_color); if (cd.is_script_doc) { @@ -1319,21 +1319,21 @@ void EditorHelp::_help_callback(const String &p_topic) { } } - class_desc->call_deferred("scroll_to_line", line); + class_desc->call_deferred(SNAME("scroll_to_line"), line); } static void _add_text_to_rt(const String &p_bbcode, RichTextLabel *p_rt) { DocTools *doc = EditorHelp::get_doc_data(); String base_path; - Ref<Font> doc_font = p_rt->get_theme_font("doc", "EditorFonts"); - Ref<Font> doc_bold_font = p_rt->get_theme_font("doc_bold", "EditorFonts"); - Ref<Font> doc_code_font = p_rt->get_theme_font("doc_source", "EditorFonts"); - Ref<Font> doc_kbd_font = p_rt->get_theme_font("doc_keyboard", "EditorFonts"); + Ref<Font> doc_font = p_rt->get_theme_font(SNAME("doc"), SNAME("EditorFonts")); + Ref<Font> doc_bold_font = p_rt->get_theme_font(SNAME("doc_bold"), SNAME("EditorFonts")); + Ref<Font> doc_code_font = p_rt->get_theme_font(SNAME("doc_source"), SNAME("EditorFonts")); + Ref<Font> doc_kbd_font = p_rt->get_theme_font(SNAME("doc_keyboard"), SNAME("EditorFonts")); - Color headline_color = p_rt->get_theme_color("headline_color", "EditorHelp"); - Color accent_color = p_rt->get_theme_color("accent_color", "Editor"); - Color property_color = p_rt->get_theme_color("property_color", "Editor"); + Color headline_color = p_rt->get_theme_color(SNAME("headline_color"), SNAME("EditorHelp")); + Color accent_color = p_rt->get_theme_color(SNAME("accent_color"), SNAME("Editor")); + Color property_color = p_rt->get_theme_color(SNAME("property_color"), SNAME("Editor")); Color link_color = accent_color.lerp(headline_color, 0.8); Color code_color = accent_color.lerp(headline_color, 0.6); Color kbd_color = accent_color.lerp(property_color, 0.6); @@ -1667,7 +1667,7 @@ EditorHelp::EditorHelp() { class_desc = memnew(RichTextLabel); add_child(class_desc); class_desc->set_v_size_flags(SIZE_EXPAND_FILL); - class_desc->add_theme_color_override("selection_color", get_theme_color("accent_color", "Editor") * Color(1, 1, 1, 0.4)); + class_desc->add_theme_color_override("selection_color", get_theme_color(SNAME("accent_color"), SNAME("Editor")) * Color(1, 1, 1, 0.4)); class_desc->connect("meta_clicked", callable_mp(this, &EditorHelp::_class_desc_select)); class_desc->connect("gui_input", callable_mp(this, &EditorHelp::_class_desc_input)); @@ -1693,7 +1693,7 @@ EditorHelp::~EditorHelp() { void EditorHelpBit::_go_to_help(String p_what) { EditorNode::get_singleton()->set_visible_editor(EditorNode::EDITOR_SCRIPT); ScriptEditor::get_singleton()->goto_help(p_what); - emit_signal("request_hide"); + emit_signal(SNAME("request_hide")); } void EditorHelpBit::_meta_clicked(String p_select) { @@ -1733,7 +1733,7 @@ void EditorHelpBit::_notification(int p_what) { } break; case EditorSettings::NOTIFICATION_EDITOR_SETTINGS_CHANGED: { - rich_text->add_theme_color_override("selection_color", get_theme_color("accent_color", "Editor") * Color(1, 1, 1, 0.4)); + rich_text->add_theme_color_override("selection_color", get_theme_color(SNAME("accent_color"), SNAME("Editor")) * Color(1, 1, 1, 0.4)); } break; default: break; @@ -1750,7 +1750,7 @@ EditorHelpBit::EditorHelpBit() { rich_text = memnew(RichTextLabel); add_child(rich_text); rich_text->connect("meta_clicked", callable_mp(this, &EditorHelpBit::_meta_clicked)); - rich_text->add_theme_color_override("selection_color", get_theme_color("accent_color", "Editor") * Color(1, 1, 1, 0.4)); + rich_text->add_theme_color_override("selection_color", get_theme_color(SNAME("accent_color"), SNAME("Editor")) * Color(1, 1, 1, 0.4)); rich_text->set_override_selected_font_color(false); set_custom_minimum_size(Size2(0, 70 * EDSCALE)); } @@ -1812,13 +1812,13 @@ void FindBar::_notification(int p_what) { switch (p_what) { case NOTIFICATION_ENTER_TREE: case NOTIFICATION_THEME_CHANGED: { - find_prev->set_icon(get_theme_icon("MoveUp", "EditorIcons")); - find_next->set_icon(get_theme_icon("MoveDown", "EditorIcons")); - hide_button->set_normal_texture(get_theme_icon("Close", "EditorIcons")); - hide_button->set_hover_texture(get_theme_icon("Close", "EditorIcons")); - hide_button->set_pressed_texture(get_theme_icon("Close", "EditorIcons")); + find_prev->set_icon(get_theme_icon(SNAME("MoveUp"), SNAME("EditorIcons"))); + find_next->set_icon(get_theme_icon(SNAME("MoveDown"), SNAME("EditorIcons"))); + hide_button->set_normal_texture(get_theme_icon(SNAME("Close"), SNAME("EditorIcons"))); + hide_button->set_hover_texture(get_theme_icon(SNAME("Close"), SNAME("EditorIcons"))); + hide_button->set_pressed_texture(get_theme_icon(SNAME("Close"), SNAME("EditorIcons"))); hide_button->set_custom_minimum_size(hide_button->get_normal_texture()->get_size()); - matches_label->add_theme_color_override("font_color", results_count > 0 ? get_theme_color("font_color", "Label") : get_theme_color("error_color", "Editor")); + matches_label->add_theme_color_override("font_color", results_count > 0 ? get_theme_color(SNAME("font_color"), SNAME("Label")) : get_theme_color(SNAME("error_color"), SNAME("Editor"))); } break; case NOTIFICATION_VISIBILITY_CHANGED: { set_process_unhandled_input(is_visible_in_tree()); @@ -1891,7 +1891,7 @@ void FindBar::_update_matches_label() { } else { matches_label->show(); - matches_label->add_theme_color_override("font_color", results_count > 0 ? get_theme_color("font_color", "Label") : get_theme_color("error_color", "Editor")); + matches_label->add_theme_color_override("font_color", results_count > 0 ? get_theme_color(SNAME("font_color"), SNAME("Label")) : get_theme_color(SNAME("error_color"), SNAME("Editor"))); matches_label->set_text(vformat(results_count == 1 ? TTR("%d match.") : TTR("%d matches."), results_count)); } } diff --git a/editor/editor_help_search.cpp b/editor/editor_help_search.cpp index a9bbb92079..fabbf97f49 100644 --- a/editor/editor_help_search.cpp +++ b/editor/editor_help_search.cpp @@ -36,11 +36,11 @@ #include "editor_scale.h" void EditorHelpSearch::_update_icons() { - search_box->set_right_icon(results_tree->get_theme_icon("Search", "EditorIcons")); + search_box->set_right_icon(results_tree->get_theme_icon(SNAME("Search"), SNAME("EditorIcons"))); search_box->set_clear_button_enabled(true); - search_box->add_theme_icon_override("right_icon", results_tree->get_theme_icon("Search", "EditorIcons")); - case_sensitive_button->set_icon(results_tree->get_theme_icon("MatchCase", "EditorIcons")); - hierarchy_button->set_icon(results_tree->get_theme_icon("ClassList", "EditorIcons")); + search_box->add_theme_icon_override("right_icon", results_tree->get_theme_icon(SNAME("Search"), SNAME("EditorIcons"))); + case_sensitive_button->set_icon(results_tree->get_theme_icon(SNAME("MatchCase"), SNAME("EditorIcons"))); + hierarchy_button->set_icon(results_tree->get_theme_icon(SNAME("ClassList"), SNAME("EditorIcons"))); if (is_visible()) { _update_results(); @@ -95,7 +95,7 @@ void EditorHelpSearch::_confirmed() { // Activate the script editor and emit the signal with the documentation link to display. EditorNode::get_singleton()->set_visible_editor(EditorNode::EDITOR_SCRIPT); - emit_signal("go_to_help", item->get_metadata(0)); + emit_signal(SNAME("go_to_help"), item->get_metadata(0)); hide(); } @@ -104,7 +104,7 @@ void EditorHelpSearch::_notification(int p_what) { switch (p_what) { case NOTIFICATION_VISIBILITY_CHANGED: { if (!is_visible()) { - results_tree->call_deferred("clear"); // Wait for the Tree's mouse event propagation. + results_tree->call_deferred(SNAME("clear")); // Wait for the Tree's mouse event propagation. get_ok_button()->set_disabled(true); EditorSettings::get_singleton()->set_project_metadata("dialog_bounds", "search_help", Rect2(get_position(), get_size())); } @@ -506,7 +506,7 @@ TreeItem *EditorHelpSearch::Runner::_create_class_item(TreeItem *p_parent, const if (ui_service->has_theme_icon(p_doc->name, "EditorIcons")) { icon = ui_service->get_theme_icon(p_doc->name, "EditorIcons"); } else if (ClassDB::class_exists(p_doc->name) && ClassDB::is_parent_class(p_doc->name, "Object")) { - icon = ui_service->get_theme_icon("Object", "EditorIcons"); + icon = ui_service->get_theme_icon(SNAME("Object"), SNAME("EditorIcons")); } String tooltip = p_doc->brief_description.strip_edges(); @@ -580,10 +580,10 @@ TreeItem *EditorHelpSearch::Runner::_create_member_item(TreeItem *p_parent, cons Ref<Texture2D> icon; String text; if (search_flags & SEARCH_SHOW_HIERARCHY) { - icon = ui_service->get_theme_icon(p_icon, "EditorIcons"); + icon = ui_service->get_theme_icon(p_icon, SNAME("EditorIcons")); text = p_text; } else { - icon = ui_service->get_theme_icon(p_icon, "EditorIcons"); + icon = ui_service->get_theme_icon(p_icon, SNAME("EditorIcons")); /*// In flat mode, show the class icon. if (ui_service->has_icon(p_class_name, "EditorIcons")) icon = ui_service->get_icon(p_class_name, "EditorIcons"); @@ -621,6 +621,6 @@ EditorHelpSearch::Runner::Runner(Control *p_icon_service, Tree *p_results_tree, results_tree(p_results_tree), term((p_search_flags & SEARCH_CASE_SENSITIVE) == 0 ? p_term.strip_edges().to_lower() : p_term.strip_edges()), search_flags(p_search_flags), - empty_icon(ui_service->get_theme_icon("ArrowRight", "EditorIcons")), - disabled_color(ui_service->get_theme_color("disabled_font_color", "Editor")) { + empty_icon(ui_service->get_theme_icon(SNAME("ArrowRight"), SNAME("EditorIcons"))), + disabled_color(ui_service->get_theme_color(SNAME("disabled_font_color"), SNAME("Editor"))) { } diff --git a/editor/editor_inspector.cpp b/editor/editor_inspector.cpp index 4dd57cb1a8..4a3413d9ef 100644 --- a/editor/editor_inspector.cpp +++ b/editor/editor_inspector.cpp @@ -41,8 +41,8 @@ Size2 EditorProperty::get_minimum_size() const { Size2 ms; - Ref<Font> font = get_theme_font("font", "Tree"); - int font_size = get_theme_font_size("font_size", "Tree"); + Ref<Font> font = get_theme_font(SNAME("font"), SNAME("Tree")); + int font_size = get_theme_font_size(SNAME("font_size"), SNAME("Tree")); ms.height = font->get_height(font_size); for (int i = 0; i < get_child_count(); i++) { @@ -66,22 +66,22 @@ Size2 EditorProperty::get_minimum_size() const { } if (keying) { - Ref<Texture2D> key = get_theme_icon("Key", "EditorIcons"); - ms.width += key->get_width() + get_theme_constant("hseparator", "Tree"); + Ref<Texture2D> key = get_theme_icon(SNAME("Key"), SNAME("EditorIcons")); + ms.width += key->get_width() + get_theme_constant(SNAME("hseparator"), SNAME("Tree")); } if (deletable) { - Ref<Texture2D> key = get_theme_icon("Close", "EditorIcons"); - ms.width += key->get_width() + get_theme_constant("hseparator", "Tree"); + Ref<Texture2D> key = get_theme_icon(SNAME("Close"), SNAME("EditorIcons")); + ms.width += key->get_width() + get_theme_constant(SNAME("hseparator"), SNAME("Tree")); } if (checkable) { - Ref<Texture2D> check = get_theme_icon("checked", "CheckBox"); - ms.width += check->get_width() + get_theme_constant("hseparation", "CheckBox") + get_theme_constant("hseparator", "Tree"); + Ref<Texture2D> check = get_theme_icon(SNAME("checked"), SNAME("CheckBox")); + ms.width += check->get_width() + get_theme_constant(SNAME("hseparation"), SNAME("CheckBox")) + get_theme_constant(SNAME("hseparator"), SNAME("Tree")); } if (bottom_editor != nullptr && bottom_editor->is_visible()) { - ms.height += get_theme_constant("vseparation"); + ms.height += get_theme_constant(SNAME("vseparation")); Size2 bems = bottom_editor->get_combined_minimum_size(); //bems.width += get_constant("item_margin", "Tree"); ms.height += bems.height; @@ -96,7 +96,7 @@ void EditorProperty::emit_changed(const StringName &p_property, const Variant &p const Variant *argptrs[4] = { &args[0], &args[1], &args[2], &args[3] }; cache[p_property] = p_value; - emit_signal("property_changed", (const Variant **)argptrs, 4); + emit_signal(SNAME("property_changed"), (const Variant **)argptrs, 4); } void EditorProperty::_notification(int p_what) { @@ -110,8 +110,8 @@ void EditorProperty::_notification(int p_what) { { int child_room = size.width * (1.0 - split_ratio); - Ref<Font> font = get_theme_font("font", "Tree"); - int font_size = get_theme_font_size("font_size", "Tree"); + Ref<Font> font = get_theme_font(SNAME("font"), SNAME("Tree")); + int font_size = get_theme_font_size(SNAME("font_size"), SNAME("Tree")); int height = font->get_height(font_size); bool no_children = true; @@ -149,21 +149,21 @@ void EditorProperty::_notification(int p_what) { if (bottom_editor) { int m = 0; //get_constant("item_margin", "Tree"); - bottom_rect = Rect2(m, rect.size.height + get_theme_constant("vseparation"), size.width - m, bottom_editor->get_combined_minimum_size().height); + bottom_rect = Rect2(m, rect.size.height + get_theme_constant(SNAME("vseparation")), size.width - m, bottom_editor->get_combined_minimum_size().height); } if (keying) { Ref<Texture2D> key; if (use_keying_next()) { - key = get_theme_icon("KeyNext", "EditorIcons"); + key = get_theme_icon(SNAME("KeyNext"), SNAME("EditorIcons")); } else { - key = get_theme_icon("Key", "EditorIcons"); + key = get_theme_icon(SNAME("Key"), SNAME("EditorIcons")); } - rect.size.x -= key->get_width() + get_theme_constant("hseparator", "Tree"); + rect.size.x -= key->get_width() + get_theme_constant(SNAME("hseparator"), SNAME("Tree")); if (is_layout_rtl()) { - rect.position.x += key->get_width() + get_theme_constant("hseparator", "Tree"); + rect.position.x += key->get_width() + get_theme_constant(SNAME("hseparator"), SNAME("Tree")); } if (no_children) { @@ -174,12 +174,12 @@ void EditorProperty::_notification(int p_what) { if (deletable) { Ref<Texture2D> close; - close = get_theme_icon("Close", "EditorIcons"); + close = get_theme_icon(SNAME("Close"), SNAME("EditorIcons")); - rect.size.x -= close->get_width() + get_theme_constant("hseparator", "Tree"); + rect.size.x -= close->get_width() + get_theme_constant(SNAME("hseparator"), SNAME("Tree")); if (is_layout_rtl()) { - rect.position.x += close->get_width() + get_theme_constant("hseparator", "Tree"); + rect.position.x += close->get_width() + get_theme_constant(SNAME("hseparator"), SNAME("Tree")); } if (no_children) { @@ -214,9 +214,9 @@ void EditorProperty::_notification(int p_what) { } if (p_what == NOTIFICATION_DRAW) { - Ref<Font> font = get_theme_font("font", "Tree"); - int font_size = get_theme_font_size("font_size", "Tree"); - Color dark_color = get_theme_color("dark_color_2", "Editor"); + Ref<Font> font = get_theme_font(SNAME("font"), SNAME("Tree")); + int font_size = get_theme_font_size(SNAME("font_size"), SNAME("Tree")); + Color dark_color = get_theme_color(SNAME("dark_color_2"), SNAME("Editor")); bool rtl = is_layout_rtl(); Size2 size = get_size(); @@ -228,9 +228,9 @@ void EditorProperty::_notification(int p_what) { Ref<StyleBox> sb; if (selected) { - sb = get_theme_stylebox("bg_selected"); + sb = get_theme_stylebox(SNAME("bg_selected")); } else { - sb = get_theme_stylebox("bg"); + sb = get_theme_stylebox(SNAME("bg")); } draw_style_box(sb, Rect2(Vector2(), size)); @@ -244,23 +244,23 @@ void EditorProperty::_notification(int p_what) { Color color; if (draw_red) { - color = get_theme_color("error_color"); + color = get_theme_color(SNAME("error_color")); } else { - color = get_theme_color("property_color"); + color = get_theme_color(SNAME("property_color")); } if (label.find(".") != -1) { color.a = 0.5; //this should be un-hacked honestly, as it's used for editor overrides } - int ofs = get_theme_constant("font_offset"); + int ofs = get_theme_constant(SNAME("font_offset")); int text_limit = text_size; if (checkable) { Ref<Texture2D> checkbox; if (checked) { - checkbox = get_theme_icon("GuiChecked", "EditorIcons"); + checkbox = get_theme_icon(SNAME("GuiChecked"), SNAME("EditorIcons")); } else { - checkbox = get_theme_icon("GuiUnchecked", "EditorIcons"); + checkbox = get_theme_icon(SNAME("GuiUnchecked"), SNAME("EditorIcons")); } Color color2(1, 1, 1); @@ -275,16 +275,16 @@ void EditorProperty::_notification(int p_what) { } else { draw_texture(checkbox, check_rect.position, color2); } - ofs += get_theme_constant("hseparator", "Tree") + checkbox->get_width() + get_theme_constant("hseparation", "CheckBox"); + ofs += get_theme_constant(SNAME("hseparator"), SNAME("Tree")) + checkbox->get_width() + get_theme_constant(SNAME("hseparation"), SNAME("CheckBox")); text_limit -= ofs; } else { check_rect = Rect2(); } if (can_revert) { - Ref<Texture2D> reload_icon = get_theme_icon("ReloadSmall", "EditorIcons"); - text_limit -= reload_icon->get_width() + get_theme_constant("hseparator", "Tree") * 2; - revert_rect = Rect2(text_limit + get_theme_constant("hseparator", "Tree"), (size.height - reload_icon->get_height()) / 2, reload_icon->get_width(), reload_icon->get_height()); + Ref<Texture2D> reload_icon = get_theme_icon(SNAME("ReloadSmall"), SNAME("EditorIcons")); + text_limit -= reload_icon->get_width() + get_theme_constant(SNAME("hseparator"), SNAME("Tree")) * 2; + revert_rect = Rect2(text_limit + get_theme_constant(SNAME("hseparator"), SNAME("Tree")), (size.height - reload_icon->get_height()) / 2, reload_icon->get_width(), reload_icon->get_height()); Color color2(1, 1, 1); if (revert_hover) { @@ -312,12 +312,12 @@ void EditorProperty::_notification(int p_what) { Ref<Texture2D> key; if (use_keying_next()) { - key = get_theme_icon("KeyNext", "EditorIcons"); + key = get_theme_icon(SNAME("KeyNext"), SNAME("EditorIcons")); } else { - key = get_theme_icon("Key", "EditorIcons"); + key = get_theme_icon(SNAME("Key"), SNAME("EditorIcons")); } - ofs = size.width - key->get_width() - get_theme_constant("hseparator", "Tree"); + ofs = size.width - key->get_width() - get_theme_constant(SNAME("hseparator"), SNAME("Tree")); Color color2(1, 1, 1); if (keying_hover) { @@ -339,9 +339,9 @@ void EditorProperty::_notification(int p_what) { if (deletable) { Ref<Texture2D> close; - close = get_theme_icon("Close", "EditorIcons"); + close = get_theme_icon(SNAME("Close"), SNAME("EditorIcons")); - ofs = size.width - close->get_width() - get_theme_constant("hseparator", "Tree"); + ofs = size.width - close->get_width() - get_theme_constant(SNAME("hseparator"), SNAME("Tree")); Color color2(1, 1, 1); if (delete_hover) { @@ -493,6 +493,7 @@ bool EditorPropertyRevert::is_node_property_different(Node *p_node, const Varian if (ss.is_valid()) { found_state = true; + break; } if (node == edited_scene) { //just in case @@ -506,59 +507,71 @@ bool EditorPropertyRevert::is_node_property_different(Node *p_node, const Varian } } - if (p_current.get_type() == Variant::FLOAT && p_orig.get_type() == Variant::FLOAT) { - float a = p_current; - float b = p_orig; + return is_property_value_different(p_current, p_orig); +} - return !Math::is_equal_approx(a, b); //this must be done because, as some scenes save as text, there might be a tiny difference in floats due to numerical error +bool EditorPropertyRevert::is_property_value_different(const Variant &p_a, const Variant &p_b) { + if (p_a.get_type() == Variant::FLOAT && p_b.get_type() == Variant::FLOAT) { + //this must be done because, as some scenes save as text, there might be a tiny difference in floats due to numerical error + return !Math::is_equal_approx((float)p_a, (float)p_b); + } else { + return p_a != p_b; } - - return bool(Variant::evaluate(Variant::OP_NOT_EQUAL, p_current, p_orig)); } -bool EditorPropertyRevert::can_property_revert(Object *p_object, const StringName &p_property) { - bool has_revert = false; +Variant EditorPropertyRevert::get_property_revert_value(Object *p_object, const StringName &p_property) { + // If the object implements property_can_revert, rely on that completely + // (i.e. don't then try to revert to default value - the property_get_revert implementation + // can do that if so desired) + if (p_object->has_method("property_can_revert") && p_object->call("property_can_revert", p_property)) { + return p_object->call("property_get_revert", p_property); + } + Ref<Script> scr = p_object->get_script(); Node *node = Object::cast_to<Node>(p_object); - if (node && EditorPropertyRevert::may_node_be_in_instance(node)) { - //check for difference including instantiation - Variant vorig; - if (EditorPropertyRevert::get_instantiated_node_original_property(node, p_property, vorig)) { - Variant v = p_object->get(p_property); - - if (EditorPropertyRevert::is_node_property_different(node, v, vorig)) { - has_revert = true; + //if this node is an instance or inherits, but it has a script attached which is unrelated + //to the one set for the parent and also has a default value for the property, consider that + //has precedence over the value from the parent, because that is an explicit source of defaults + //closer in the tree to the current node + bool ignore_parent = false; + if (scr.is_valid()) { + Variant sorig; + if (EditorPropertyRevert::get_instantiated_node_original_property(node, "script", sorig) && !scr->inherits_script(sorig)) { + Variant dummy; + if (scr->get_property_default_value(p_property, dummy)) { + ignore_parent = true; + } } } - } else { - //check for difference against default class value instead - Variant default_value = ClassDB::class_get_default_property_value(p_object->get_class_name(), p_property); - if (default_value != Variant() && default_value != p_object->get(p_property)) { - has_revert = true; + + if (!ignore_parent) { + //check for difference including instantiation + Variant vorig; + if (EditorPropertyRevert::get_instantiated_node_original_property(node, p_property, vorig)) { + return vorig; + } } } - // If the object implements property_can_revert, rely on that completely - // (i.e. don't then try to revert to default value - the property_get_revert implementation - // can do that if so desired) - if (p_object->has_method("property_can_revert")) { - has_revert = p_object->call("property_can_revert", p_property).operator bool(); - } else { - if (!has_revert && !p_object->get_script().is_null()) { - Ref<Script> scr = p_object->get_script(); - if (scr.is_valid()) { - Variant orig_value; - if (scr->get_property_default_value(p_property, orig_value)) { - if (orig_value != p_object->get(p_property)) { - has_revert = true; - } - } - } + if (scr.is_valid()) { + Variant orig_value; + if (scr->get_property_default_value(p_property, orig_value)) { + return orig_value; } } - return has_revert; + //report default class value instead + return ClassDB::class_get_default_property_value(p_object->get_class_name(), p_property); +} + +bool EditorPropertyRevert::can_property_revert(Object *p_object, const StringName &p_property) { + Variant revert_value = EditorPropertyRevert::get_property_revert_value(p_object, p_property); + if (revert_value.get_type() == Variant::NIL) { + return false; + } + Variant current_value = p_object->get(p_property); + return EditorPropertyRevert::is_property_value_different(current_value, revert_value); } void EditorProperty::update_reload_status() { @@ -646,7 +659,7 @@ void EditorProperty::_focusable_focused(int p_index) { selected_focusable = p_index; update(); if (!already_selected && selected) { - emit_signal("selected", property, selected_focusable); + emit_signal(SNAME("selected"), property, selected_focusable); } } @@ -667,7 +680,7 @@ void EditorProperty::select(int p_focusable) { } if (!already_selected && selected) { - emit_signal("selected", property, selected_focusable); + emit_signal(SNAME("selected"), property, selected_focusable); } } @@ -732,12 +745,12 @@ void EditorProperty::_gui_input(const Ref<InputEvent> &p_event) { if (!selected && selectable) { selected = true; - emit_signal("selected", property, -1); + emit_signal(SNAME("selected"), property, -1); update(); } if (keying_rect.has_point(mpos)) { - emit_signal("property_keyed", property, use_keying_next()); + emit_signal(SNAME("property_keyed"), property, use_keying_next()); if (use_keying_next()) { if (property == "frame_coords" && (object->is_class("Sprite2D") || object->is_class("Sprite3D"))) { @@ -748,58 +761,28 @@ void EditorProperty::_gui_input(const Ref<InputEvent> &p_event) { new_coords.y++; } - call_deferred("emit_changed", property, new_coords, "", false); + call_deferred(SNAME("emit_changed"), property, new_coords, "", false); } else { - call_deferred("emit_changed", property, object->get(property).operator int64_t() + 1, "", false); + call_deferred(SNAME("emit_changed"), property, object->get(property).operator int64_t() + 1, "", false); } - call_deferred("_update_property"); + call_deferred(SNAME("_update_property")); } } if (delete_rect.has_point(mpos)) { - emit_signal("property_deleted", property); + emit_signal(SNAME("property_deleted"), property); } if (revert_rect.has_point(mpos)) { - Variant vorig; - - Node *node = Object::cast_to<Node>(object); - if (node && EditorPropertyRevert::may_node_be_in_instance(node) && EditorPropertyRevert::get_instantiated_node_original_property(node, property, vorig)) { - emit_changed(property, vorig.duplicate(true)); - update_property(); - return; - } - - if (object->call("property_can_revert", property).operator bool()) { - Variant rev = object->call("property_get_revert", property); - emit_changed(property, rev); - update_property(); - return; - } - - if (!object->get_script().is_null()) { - Ref<Script> scr = object->get_script(); - if (scr.is_valid()) { - Variant orig_value; - if (scr->get_property_default_value(property, orig_value)) { - emit_changed(property, orig_value); - update_property(); - return; - } - } - } - - Variant default_value = ClassDB::class_get_default_property_value(object->get_class_name(), property); - if (default_value != Variant()) { - emit_changed(property, default_value); - update_property(); - return; - } + Variant revert_value = EditorPropertyRevert::get_property_revert_value(object, property); + emit_changed(property, revert_value); + update_property(); } + if (check_rect.has_point(mpos)) { checked = !checked; update(); - emit_signal("property_checked", property, checked); + emit_signal(SNAME("property_checked"), property, checked); } } } @@ -889,7 +872,7 @@ void EditorProperty::set_object_and_property(Object *p_object, const StringName Control *EditorProperty::make_custom_tooltip(const String &p_text) const { tooltip_text = p_text; EditorHelpBit *help_bit = memnew(EditorHelpBit); - //help_bit->add_theme_style_override("panel", get_theme_stylebox("panel", "TooltipPanel")); + //help_bit->add_theme_style_override("panel", get_theme_stylebox(SNAME("panel"), SNAME("TooltipPanel"))); help_bit->get_rich_text()->set_fixed_size_to_width(360 * EDSCALE); String text; @@ -1076,14 +1059,14 @@ void EditorInspectorPlugin::_bind_methods() { void EditorInspectorCategory::_notification(int p_what) { if (p_what == NOTIFICATION_DRAW) { - Ref<StyleBox> sb = get_theme_stylebox("prop_category_style", "Editor"); + Ref<StyleBox> sb = get_theme_stylebox(SNAME("prop_category_style"), SNAME("Editor")); draw_style_box(sb, Rect2(Vector2(), get_size())); - Ref<Font> font = get_theme_font("bold", "EditorFonts"); - int font_size = get_theme_font_size("bold_size", "EditorFonts"); + Ref<Font> font = get_theme_font(SNAME("bold"), SNAME("EditorFonts")); + int font_size = get_theme_font_size(SNAME("bold_size"), SNAME("EditorFonts")); - int hs = get_theme_constant("hseparation", "Tree"); + int hs = get_theme_constant(SNAME("hseparation"), SNAME("Tree")); int w = font->get_string_size(label, font_size).width; if (icon.is_valid()) { @@ -1097,7 +1080,7 @@ void EditorInspectorCategory::_notification(int p_what) { ofs += hs + icon->get_width(); } - Color color = get_theme_color("font_color", "Tree"); + Color color = get_theme_color(SNAME("font_color"), SNAME("Tree")); draw_string(font, Point2(ofs, font->get_ascent(font_size) + (get_size().height - font->get_height(font_size)) / 2).floor(), label, HALIGN_LEFT, get_size().width, font_size, color); } } @@ -1105,7 +1088,7 @@ void EditorInspectorCategory::_notification(int p_what) { Control *EditorInspectorCategory::make_custom_tooltip(const String &p_text) const { tooltip_text = p_text; EditorHelpBit *help_bit = memnew(EditorHelpBit); - help_bit->add_theme_style_override("panel", get_theme_stylebox("panel", "TooltipPanel")); + help_bit->add_theme_style_override("panel", get_theme_stylebox(SNAME("panel"), SNAME("TooltipPanel"))); help_bit->get_rich_text()->set_fixed_size_to_width(360 * EDSCALE); PackedStringArray slices = p_text.split("::", false); @@ -1126,8 +1109,8 @@ Control *EditorInspectorCategory::make_custom_tooltip(const String &p_text) cons } Size2 EditorInspectorCategory::get_minimum_size() const { - Ref<Font> font = get_theme_font("font", "Tree"); - int font_size = get_theme_font_size("font_size", "Tree"); + Ref<Font> font = get_theme_font(SNAME("font"), SNAME("Tree")); + int font_size = get_theme_font_size(SNAME("font_size"), SNAME("Tree")); Size2 ms; ms.width = 1; @@ -1135,7 +1118,7 @@ Size2 EditorInspectorCategory::get_minimum_size() const { if (icon.is_valid()) { ms.height = MAX(icon->get_height(), ms.height); } - ms.height += get_theme_constant("vseparation", "Tree"); + ms.height += get_theme_constant(SNAME("vseparation"), SNAME("Tree")); return ms; } @@ -1163,19 +1146,19 @@ void EditorInspectorSection::_test_unfold() { void EditorInspectorSection::_notification(int p_what) { if (p_what == NOTIFICATION_SORT_CHILDREN) { - Ref<Font> font = get_theme_font("bold", "EditorFonts"); - int font_size = get_theme_font_size("bold_size", "EditorFonts"); + Ref<Font> font = get_theme_font(SNAME("bold"), SNAME("EditorFonts")); + int font_size = get_theme_font_size(SNAME("bold_size"), SNAME("EditorFonts")); Ref<Texture2D> arrow; if (foldable) { if (object->editor_is_section_unfolded(section)) { - arrow = get_theme_icon("arrow", "Tree"); + arrow = get_theme_icon(SNAME("arrow"), SNAME("Tree")); } else { if (is_layout_rtl()) { - arrow = get_theme_icon("arrow_collapsed_mirrored", "Tree"); + arrow = get_theme_icon(SNAME("arrow_collapsed_mirrored"), SNAME("Tree")); } else { - arrow = get_theme_icon("arrow_collapsed", "Tree"); + arrow = get_theme_icon(SNAME("arrow_collapsed"), SNAME("Tree")); } } } @@ -1188,11 +1171,11 @@ void EditorInspectorSection::_notification(int p_what) { offset.y = MAX(offset.y, arrow->get_height()); } - offset.y += get_theme_constant("vseparation", "Tree"); + offset.y += get_theme_constant(SNAME("vseparation"), SNAME("Tree")); if (is_layout_rtl()) { - rect = Rect2(offset, size - offset - Vector2(get_theme_constant("inspector_margin", "Editor"), 0)); + rect = Rect2(offset, size - offset - Vector2(get_theme_constant(SNAME("inspector_margin"), SNAME("Editor")), 0)); } else { - offset.x += get_theme_constant("inspector_margin", "Editor"); + offset.x += get_theme_constant(SNAME("inspector_margin"), SNAME("Editor")); rect = Rect2(offset, size - offset); } @@ -1221,24 +1204,24 @@ void EditorInspectorSection::_notification(int p_what) { if (foldable) { if (object->editor_is_section_unfolded(section)) { - arrow = get_theme_icon("arrow", "Tree"); + arrow = get_theme_icon(SNAME("arrow"), SNAME("Tree")); } else { if (is_layout_rtl()) { - arrow = get_theme_icon("arrow_collapsed_mirrored", "Tree"); + arrow = get_theme_icon(SNAME("arrow_collapsed_mirrored"), SNAME("Tree")); } else { - arrow = get_theme_icon("arrow_collapsed", "Tree"); + arrow = get_theme_icon(SNAME("arrow_collapsed"), SNAME("Tree")); } } } - Ref<Font> font = get_theme_font("bold", "EditorFonts"); - int font_size = get_theme_font_size("bold_size", "EditorFonts"); + Ref<Font> font = get_theme_font(SNAME("bold"), SNAME("EditorFonts")); + int font_size = get_theme_font_size(SNAME("bold_size"), SNAME("EditorFonts")); int h = font->get_height(font_size); if (arrow.is_valid()) { h = MAX(h, arrow->get_height()); } - h += get_theme_constant("vseparation", "Tree"); + h += get_theme_constant(SNAME("vseparation"), SNAME("Tree")); Color c = bg_color; c.a *= 0.4; @@ -1246,7 +1229,7 @@ void EditorInspectorSection::_notification(int p_what) { const int arrow_margin = 2; const int arrow_width = arrow.is_valid() ? arrow->get_width() : 0; - Color color = get_theme_color("font_color"); + Color color = get_theme_color(SNAME("font_color")); float text_width = get_size().width - Math::round(arrow_width + arrow_margin * EDSCALE); draw_string(font, Point2(rtl ? 0 : Math::round(arrow_width + arrow_margin * EDSCALE), font->get_ascent(font_size) + (h - font->get_height(font_size)) / 2).floor(), label, rtl ? HALIGN_RIGHT : HALIGN_LEFT, text_width, font_size, color); @@ -1259,7 +1242,7 @@ void EditorInspectorSection::_notification(int p_what) { } if (dropping && !vbox->is_visible_in_tree()) { - Color accent_color = get_theme_color("accent_color", "Editor"); + Color accent_color = get_theme_color(SNAME("accent_color"), SNAME("Editor")); draw_rect(Rect2(Point2(), get_size()), accent_color, false); } } @@ -1319,10 +1302,10 @@ Size2 EditorInspectorSection::get_minimum_size() const { ms.height = MAX(ms.height, minsize.height); } - Ref<Font> font = get_theme_font("font", "Tree"); - int font_size = get_theme_font_size("font_size", "Tree"); - ms.height += font->get_height(font_size) + get_theme_constant("vseparation", "Tree"); - ms.width += get_theme_constant("inspector_margin", "Editor"); + Ref<Font> font = get_theme_font(SNAME("font"), SNAME("Tree")); + int font_size = get_theme_font_size(SNAME("font_size"), SNAME("Tree")); + ms.height += font->get_height(font_size) + get_theme_constant(SNAME("vseparation"), SNAME("Tree")); + ms.width += get_theme_constant(SNAME("inspector_margin"), SNAME("Editor")); return ms; } @@ -1358,8 +1341,8 @@ void EditorInspectorSection::_gui_input(const Ref<InputEvent> &p_event) { Ref<InputEventMouseButton> mb = p_event; if (mb.is_valid() && mb->is_pressed() && mb->get_button_index() == MOUSE_BUTTON_LEFT) { - Ref<Font> font = get_theme_font("font", "Tree"); - int font_size = get_theme_font_size("font_size", "Tree"); + Ref<Font> font = get_theme_font(SNAME("font"), SNAME("Tree")); + int font_size = get_theme_font_size(SNAME("font_size"), SNAME("Tree")); if (mb->get_position().y > font->get_height(font_size)) { //clicked outside return; } @@ -1508,9 +1491,9 @@ String EditorInspector::get_selected_path() const { } void EditorInspector::_parse_added_editors(VBoxContainer *current_vbox, Ref<EditorInspectorPlugin> ped) { - for (List<EditorInspectorPlugin::AddedEditor>::Element *F = ped->added_editors.front(); F; F = F->next()) { - EditorProperty *ep = Object::cast_to<EditorProperty>(F->get().property_editor); - current_vbox->add_child(F->get().property_editor); + for (const EditorInspectorPlugin::AddedEditor &F : ped->added_editors) { + EditorProperty *ep = Object::cast_to<EditorProperty>(F.property_editor); + current_vbox->add_child(F.property_editor); if (ep) { ep->object = object; @@ -1524,19 +1507,19 @@ void EditorInspector::_parse_added_editors(VBoxContainer *current_vbox, Ref<Edit ep->connect("resource_selected", callable_mp(this, &EditorInspector::_resource_selected), varray(), CONNECT_DEFERRED); ep->connect("object_id_selected", callable_mp(this, &EditorInspector::_object_id_selected), varray(), CONNECT_DEFERRED); - if (F->get().properties.size()) { - if (F->get().properties.size() == 1) { + if (F.properties.size()) { + if (F.properties.size() == 1) { //since it's one, associate: - ep->property = F->get().properties[0]; + ep->property = F.properties[0]; ep->property_usage = 0; } - if (F->get().label != String()) { - ep->set_label(F->get().label); + if (F.label != String()) { + ep->set_label(F.label); } - for (int i = 0; i < F->get().properties.size(); i++) { - String prop = F->get().properties[i]; + for (int i = 0; i < F.properties.size(); i++) { + String prop = F.properties[i]; if (!editor_property_map.has(prop)) { editor_property_map[prop] = List<EditorProperty *>(); @@ -1646,10 +1629,9 @@ void EditorInspector::update_tree() { item_path[""] = main_vbox; - Color sscolor = get_theme_color("prop_subsection", "Editor"); + Color sscolor = get_theme_color(SNAME("prop_subsection"), SNAME("Editor")); - for (List<Ref<EditorInspectorPlugin>>::Element *E = valid_plugins.front(); E; E = E->next()) { - Ref<EditorInspectorPlugin> ped = E->get(); + for (Ref<EditorInspectorPlugin> &ped : valid_plugins) { ped->parse_begin(object); _parse_added_editors(main_vbox, ped); } @@ -1720,8 +1702,8 @@ void EditorInspector::update_tree() { } s = s->get_base_script(); } - if (category->icon.is_null() && has_theme_icon(base_type, "EditorIcons")) { - category->icon = get_theme_icon(base_type, "EditorIcons"); + if (category->icon.is_null() && has_theme_icon(base_type, SNAME("EditorIcons"))) { + category->icon = get_theme_icon(base_type, SNAME("EditorIcons")); } } if (category->icon.is_null()) { @@ -1746,8 +1728,7 @@ void EditorInspector::update_tree() { category->set_tooltip(p.name + "::" + (class_descr_cache[type2] == "" ? "" : class_descr_cache[type2])); } - for (List<Ref<EditorInspectorPlugin>>::Element *E = valid_plugins.front(); E; E = E->next()) { - Ref<EditorInspectorPlugin> ped = E->get(); + for (Ref<EditorInspectorPlugin> &ped : valid_plugins) { ped->parse_category(object, p.name); _parse_added_editors(main_vbox, ped); } @@ -1948,36 +1929,35 @@ void EditorInspector::update_tree() { doc_hint = descr; } - for (List<Ref<EditorInspectorPlugin>>::Element *E = valid_plugins.front(); E; E = E->next()) { - Ref<EditorInspectorPlugin> ped = E->get(); + for (Ref<EditorInspectorPlugin> &ped : valid_plugins) { bool exclusive = ped->parse_property(object, p.type, p.name, p.hint, p.hint_string, p.usage, wide_editors); List<EditorInspectorPlugin::AddedEditor> editors = ped->added_editors; //make a copy, since plugins may be used again in a sub-inspector ped->added_editors.clear(); - for (List<EditorInspectorPlugin::AddedEditor>::Element *F = editors.front(); F; F = F->next()) { - EditorProperty *ep = Object::cast_to<EditorProperty>(F->get().property_editor); + for (const EditorInspectorPlugin::AddedEditor &F : editors) { + EditorProperty *ep = Object::cast_to<EditorProperty>(F.property_editor); if (ep) { //set all this before the control gets the ENTER_TREE notification ep->object = object; - if (F->get().properties.size()) { - if (F->get().properties.size() == 1) { + if (F.properties.size()) { + if (F.properties.size() == 1) { //since it's one, associate: - ep->property = F->get().properties[0]; + ep->property = F.properties[0]; ep->property_usage = p.usage; //and set label? } - if (F->get().label != String()) { - ep->set_label(F->get().label); + if (F.label != String()) { + ep->set_label(F.label); } else { - //use existin one + // Use the existing one. ep->set_label(name); } - for (int i = 0; i < F->get().properties.size(); i++) { - String prop = F->get().properties[i]; + for (int i = 0; i < F.properties.size(); i++) { + String prop = F.properties[i]; if (!editor_property_map.has(prop)) { editor_property_map[prop] = List<EditorProperty *>(); @@ -1995,7 +1975,7 @@ void EditorInspector::update_tree() { ep->set_deletable(deletable_properties); } - current_vbox->add_child(F->get().property_editor); + current_vbox->add_child(F.property_editor); if (ep) { ep->connect("property_changed", callable_mp(this, &EditorInspector::_property_changed)); @@ -2031,8 +2011,7 @@ void EditorInspector::update_tree() { } } - for (List<Ref<EditorInspectorPlugin>>::Element *E = valid_plugins.front(); E; E = E->next()) { - Ref<EditorInspectorPlugin> ped = E->get(); + for (Ref<EditorInspectorPlugin> &ped : valid_plugins) { ped->parse_end(); _parse_added_editors(main_vbox, ped); } @@ -2045,10 +2024,10 @@ void EditorInspector::update_property(const String &p_prop) { return; } - for (List<EditorProperty *>::Element *E = editor_property_map[p_prop].front(); E; E = E->next()) { - E->get()->update_property(); - E->get()->update_reload_status(); - E->get()->update_cache(); + for (EditorProperty *E : editor_property_map[p_prop]) { + E->update_property(); + E->update_reload_status(); + E->update_cache(); } } @@ -2157,24 +2136,24 @@ bool EditorInspector::is_using_folding() { } void EditorInspector::collapse_all_folding() { - for (List<EditorInspectorSection *>::Element *E = sections.front(); E; E = E->next()) { - E->get()->fold(); + for (EditorInspectorSection *E : sections) { + E->fold(); } for (Map<StringName, List<EditorProperty *>>::Element *F = editor_property_map.front(); F; F = F->next()) { - for (List<EditorProperty *>::Element *E = F->get().front(); E; E = E->next()) { - E->get()->collapse_all_folding(); + for (EditorProperty *E : F->get()) { + E->collapse_all_folding(); } } } void EditorInspector::expand_all_folding() { - for (List<EditorInspectorSection *>::Element *E = sections.front(); E; E = E->next()) { - E->get()->unfold(); + for (EditorInspectorSection *E : sections) { + E->unfold(); } for (Map<StringName, List<EditorProperty *>>::Element *F = editor_property_map.front(); F; F = F->next()) { - for (List<EditorProperty *>::Element *E = F->get().front(); E; E = E->next()) { - E->get()->expand_all_folding(); + for (EditorProperty *E : F->get()) { + E->expand_all_folding(); } } } @@ -2205,7 +2184,7 @@ void EditorInspector::_update_inspector_bg() { count_subinspectors = MIN(15, count_subinspectors); add_theme_style_override("bg", get_theme_stylebox("sub_inspector_bg" + itos(count_subinspectors), "Editor")); } else { - add_theme_style_override("bg", get_theme_stylebox("bg", "Tree")); + add_theme_style_override("bg", get_theme_stylebox(SNAME("bg"), SNAME("Tree"))); } } void EditorInspector::set_sub_inspector(bool p_enable) { @@ -2239,9 +2218,9 @@ void EditorInspector::_edit_request_change(Object *p_object, const String &p_pro void EditorInspector::_edit_set(const String &p_name, const Variant &p_value, bool p_refresh_all, const String &p_changed_field) { if (autoclear && editor_property_map.has(p_name)) { - for (List<EditorProperty *>::Element *E = editor_property_map[p_name].front(); E; E = E->next()) { - if (E->get()->is_checkable()) { - E->get()->set_checked(true); + for (EditorProperty *E : editor_property_map[p_name]) { + if (E->is_checkable()) { + E->set_checked(true); } } } @@ -2261,7 +2240,7 @@ void EditorInspector::_edit_set(const String &p_name, const Variant &p_value, bo _edit_request_change(object, p_name); emit_signal(_prop_edited, p_name); } else { - undo_redo->create_action(TTR("Set") + " " + p_name, UndoRedo::MERGE_ENDS); + undo_redo->create_action(vformat(TTR("Set %s"), p_name), UndoRedo::MERGE_ENDS); undo_redo->add_do_property(object, p_name, p_value); undo_redo->add_undo_property(object, p_name, object->get(p_name)); @@ -2308,8 +2287,8 @@ void EditorInspector::_edit_set(const String &p_name, const Variant &p_value, bo } if (editor_property_map.has(p_name)) { - for (List<EditorProperty *>::Element *E = editor_property_map[p_name].front(); E; E = E->next()) { - E->get()->update_reload_status(); + for (EditorProperty *E : editor_property_map[p_name]) { + E->update_reload_status(); } } } @@ -2328,7 +2307,7 @@ void EditorInspector::_property_changed(const String &p_path, const Variant &p_v } if (restart_request_props.has(p_path)) { - emit_signal("restart_requested"); + emit_signal(SNAME("restart_requested")); } } @@ -2350,7 +2329,7 @@ void EditorInspector::_multiple_properties_changed(Vector<String> p_paths, Array for (int i = 0; i < p_paths.size(); i++) { _edit_set(p_paths[i], p_values[i], false, ""); if (restart_request_props.has(p_paths[i])) { - emit_signal("restart_requested"); + emit_signal(SNAME("restart_requested")); } } changing++; @@ -2363,16 +2342,15 @@ void EditorInspector::_property_keyed(const String &p_path, bool p_advance) { return; } - emit_signal("property_keyed", p_path, object->get(p_path), p_advance); //second param is deprecated + emit_signal(SNAME("property_keyed"), p_path, object->get(p_path), p_advance); //second param is deprecated } void EditorInspector::_property_deleted(const String &p_path) { - print_line("deleted pressed?"); if (!object) { return; } - emit_signal("property_deleted", p_path); //second param is deprecated + emit_signal(SNAME("property_deleted"), p_path); //second param is deprecated } void EditorInspector::_property_keyed_with_value(const String &p_path, const Variant &p_value, bool p_advance) { @@ -2380,7 +2358,7 @@ void EditorInspector::_property_keyed_with_value(const String &p_path, const Var return; } - emit_signal("property_keyed", p_path, p_value, p_advance); //second param is deprecated + emit_signal(SNAME("property_keyed"), p_path, p_value, p_advance); //second param is deprecated } void EditorInspector::_property_checked(const String &p_path, bool p_checked) { @@ -2396,10 +2374,10 @@ void EditorInspector::_property_checked(const String &p_path, bool p_checked) { Variant to_create; List<PropertyInfo> pinfo; object->get_property_list(&pinfo); - for (List<PropertyInfo>::Element *E = pinfo.front(); E; E = E->next()) { - if (E->get().name == p_path) { + for (const PropertyInfo &E : pinfo) { + if (E.name == p_path) { Callable::CallError ce; - Variant::construct(E->get().type, to_create, nullptr, 0, ce); + Variant::construct(E.type, to_create, nullptr, 0, ce); break; } } @@ -2407,15 +2385,15 @@ void EditorInspector::_property_checked(const String &p_path, bool p_checked) { } if (editor_property_map.has(p_path)) { - for (List<EditorProperty *>::Element *E = editor_property_map[p_path].front(); E; E = E->next()) { - E->get()->update_property(); - E->get()->update_reload_status(); - E->get()->update_cache(); + for (EditorProperty *E : editor_property_map[p_path]) { + E->update_property(); + E->update_reload_status(); + E->update_cache(); } } } else { - emit_signal("property_toggled", p_path, p_checked); + emit_signal(SNAME("property_toggled"), p_path, p_checked); } } @@ -2427,22 +2405,22 @@ void EditorInspector::_property_selected(const String &p_path, int p_focusable) if (F->key() == property_selected) { continue; } - for (List<EditorProperty *>::Element *E = F->get().front(); E; E = E->next()) { - if (E->get()->is_selected()) { - E->get()->deselect(); + for (EditorProperty *E : F->get()) { + if (E->is_selected()) { + E->deselect(); } } } - emit_signal("property_selected", p_path); + emit_signal(SNAME("property_selected"), p_path); } void EditorInspector::_object_id_selected(const String &p_path, ObjectID p_id) { - emit_signal("object_id_selected", p_id); + emit_signal(SNAME("object_id_selected"), p_id); } void EditorInspector::_resource_selected(const String &p_path, RES p_resource) { - emit_signal("resource_selected", p_resource, p_path); + emit_signal(SNAME("resource_selected"), p_resource, p_path); } void EditorInspector::_node_removed(Node *p_node) { @@ -2479,18 +2457,18 @@ void EditorInspector::_notification(int p_what) { if (p_what == NOTIFICATION_PROCESS) { if (update_scroll_request >= 0) { - get_v_scrollbar()->call_deferred("set_value", update_scroll_request); + get_v_scrollbar()->call_deferred(SNAME("set_value"), update_scroll_request); update_scroll_request = -1; } if (refresh_countdown > 0) { refresh_countdown -= get_process_delta_time(); if (refresh_countdown <= 0) { for (Map<StringName, List<EditorProperty *>>::Element *F = editor_property_map.front(); F; F = F->next()) { - for (List<EditorProperty *>::Element *E = F->get().front(); E; E = E->next()) { - if (!E->get()->is_cache_valid()) { - E->get()->update_property(); - E->get()->update_reload_status(); - E->get()->update_cache(); + for (EditorProperty *E : F->get()) { + if (!E->is_cache_valid()) { + E->update_property(); + E->update_reload_status(); + E->update_cache(); } } } @@ -2509,10 +2487,10 @@ void EditorInspector::_notification(int p_what) { while (pending.size()) { StringName prop = pending.front()->get(); if (editor_property_map.has(prop)) { - for (List<EditorProperty *>::Element *E = editor_property_map[prop].front(); E; E = E->next()) { - E->get()->update_property(); - E->get()->update_reload_status(); - E->get()->update_cache(); + for (EditorProperty *E : editor_property_map[prop]) { + E->update_property(); + E->update_reload_status(); + E->update_cache(); } } pending.erase(pending.front()); @@ -2600,8 +2578,7 @@ void EditorInspector::_update_script_class_properties(const Object &p_object, Li } Set<StringName> added; - for (List<Ref<Script>>::Element *E = classes.front(); E; E = E->next()) { - Ref<Script> s = E->get(); + for (const Ref<Script> &s : classes) { String path = s->get_path(); String name = EditorNode::get_editor_data().script_class_get_name(path); if (name.is_empty()) { diff --git a/editor/editor_inspector.h b/editor/editor_inspector.h index ee70bd4397..2bb856dc81 100644 --- a/editor/editor_inspector.h +++ b/editor/editor_inspector.h @@ -42,6 +42,8 @@ public: static bool may_node_be_in_instance(Node *p_node); static bool get_instantiated_node_original_property(Node *p_node, const StringName &p_prop, Variant &value); static bool is_node_property_different(Node *p_node, const Variant &p_current, const Variant &p_orig); + static bool is_property_value_different(const Variant &p_a, const Variant &p_b); + static Variant get_property_revert_value(Object *p_object, const StringName &p_property); static bool can_property_revert(Object *p_object, const StringName &p_property); }; diff --git a/editor/editor_layouts_dialog.cpp b/editor/editor_layouts_dialog.cpp index 437841ccc1..0c8660c216 100644 --- a/editor/editor_layouts_dialog.cpp +++ b/editor/editor_layouts_dialog.cpp @@ -70,10 +70,10 @@ void EditorLayoutsDialog::ok_pressed() { if (layout_names->is_anything_selected()) { Vector<int> const selected_items = layout_names->get_selected_items(); for (int i = 0; i < selected_items.size(); ++i) { - emit_signal("name_confirmed", layout_names->get_item_text(selected_items[i])); + emit_signal(SNAME("name_confirmed"), layout_names->get_item_text(selected_items[i])); } } else if (name->is_visible() && name->get_text() != "") { - emit_signal("name_confirmed", name->get_text()); + emit_signal(SNAME("name_confirmed"), name->get_text()); } } @@ -92,8 +92,8 @@ void EditorLayoutsDialog::_post_popup() { List<String> layouts; config.ptr()->get_sections(&layouts); - for (List<String>::Element *E = layouts.front(); E; E = E->next()) { - layout_names->add_item(**E); + for (const String &E : layouts) { + layout_names->add_item(E); } } diff --git a/editor/editor_log.cpp b/editor/editor_log.cpp index b3e90236a6..2cb73664f5 100644 --- a/editor/editor_log.cpp +++ b/editor/editor_log.cpp @@ -57,35 +57,43 @@ void EditorLog::_error_handler(void *p_self, const char *p_func, const char *p_f } } +void EditorLog::_update_theme() { + Ref<Font> normal_font = get_theme_font(SNAME("output_source"), SNAME("EditorFonts")); + if (normal_font.is_valid()) { + log->add_theme_font_override("normal_font", normal_font); + } + + log->add_theme_font_size_override("normal_font_size", get_theme_font_size(SNAME("output_source_size"), SNAME("EditorFonts"))); + log->add_theme_color_override("selection_color", get_theme_color(SNAME("accent_color"), SNAME("Editor")) * Color(1, 1, 1, 0.4)); + + Ref<Font> bold_font = get_theme_font(SNAME("bold"), SNAME("EditorFonts")); + if (bold_font.is_valid()) { + log->add_theme_font_override("bold_font", bold_font); + } + + type_filter_map[MSG_TYPE_STD]->toggle_button->set_icon(get_theme_icon(SNAME("Popup"), SNAME("EditorIcons"))); + type_filter_map[MSG_TYPE_ERROR]->toggle_button->set_icon(get_theme_icon(SNAME("StatusError"), SNAME("EditorIcons"))); + type_filter_map[MSG_TYPE_WARNING]->toggle_button->set_icon(get_theme_icon(SNAME("StatusWarning"), SNAME("EditorIcons"))); + type_filter_map[MSG_TYPE_EDITOR]->toggle_button->set_icon(get_theme_icon(SNAME("Edit"), SNAME("EditorIcons"))); + + clear_button->set_icon(get_theme_icon(SNAME("Clear"), SNAME("EditorIcons"))); + copy_button->set_icon(get_theme_icon(SNAME("ActionCopy"), SNAME("EditorIcons"))); + collapse_button->set_icon(get_theme_icon(SNAME("CombineLines"), SNAME("EditorIcons"))); + show_search_button->set_icon(get_theme_icon(SNAME("Search"), SNAME("EditorIcons"))); +} + void EditorLog::_notification(int p_what) { - if (p_what == NOTIFICATION_ENTER_TREE) { - //button->set_icon(get_icon("Console","EditorIcons")); - log->add_theme_font_override("normal_font", get_theme_font("output_source", "EditorFonts")); - log->add_theme_font_size_override("normal_font_size", get_theme_font_size("output_source_size", "EditorFonts")); - log->add_theme_color_override("selection_color", get_theme_color("accent_color", "Editor") * Color(1, 1, 1, 0.4)); - log->add_theme_font_override("bold_font", get_theme_font("bold", "EditorFonts")); - - type_filter_map[MSG_TYPE_STD]->toggle_button->set_icon(get_theme_icon("Popup", "EditorIcons")); - type_filter_map[MSG_TYPE_ERROR]->toggle_button->set_icon(get_theme_icon("StatusError", "EditorIcons")); - type_filter_map[MSG_TYPE_WARNING]->toggle_button->set_icon(get_theme_icon("StatusWarning", "EditorIcons")); - type_filter_map[MSG_TYPE_EDITOR]->toggle_button->set_icon(get_theme_icon("Edit", "EditorIcons")); - - clear_button->set_icon(get_theme_icon("Clear", "EditorIcons")); - copy_button->set_icon(get_theme_icon("ActionCopy", "EditorIcons")); - collapse_button->set_icon(get_theme_icon("CombineLines", "EditorIcons")); - show_search_button->set_icon(get_theme_icon("Search", "EditorIcons")); - - _load_state(); - - } else if (p_what == NOTIFICATION_THEME_CHANGED) { - Ref<Font> df_output_code = get_theme_font("output_source", "EditorFonts"); - if (df_output_code.is_valid()) { - if (log != nullptr) { - log->add_theme_font_override("normal_font", get_theme_font("output_source", "EditorFonts")); - log->add_theme_font_size_override("normal_font_size", get_theme_font_size("output_source_size", "EditorFonts")); - log->add_theme_color_override("selection_color", get_theme_color("accent_color", "Editor") * Color(1, 1, 1, 0.4)); - } - } + switch (p_what) { + case NOTIFICATION_ENTER_TREE: { + _update_theme(); + _load_state(); + } break; + case NOTIFICATION_THEME_CHANGED: { + _update_theme(); + _rebuild_log(); + } break; + default: + break; } } @@ -242,22 +250,22 @@ void EditorLog::_add_log_line(LogMessage &p_message, bool p_replace_previous) { case MSG_TYPE_STD: { } break; case MSG_TYPE_ERROR: { - log->push_color(get_theme_color("error_color", "Editor")); - Ref<Texture2D> icon = get_theme_icon("Error", "EditorIcons"); + log->push_color(get_theme_color(SNAME("error_color"), SNAME("Editor"))); + Ref<Texture2D> icon = get_theme_icon(SNAME("Error"), SNAME("EditorIcons")); log->add_image(icon); log->add_text(" "); tool_button->set_icon(icon); } break; case MSG_TYPE_WARNING: { - log->push_color(get_theme_color("warning_color", "Editor")); - Ref<Texture2D> icon = get_theme_icon("Warning", "EditorIcons"); + log->push_color(get_theme_color(SNAME("warning_color"), SNAME("Editor"))); + Ref<Texture2D> icon = get_theme_icon(SNAME("Warning"), SNAME("EditorIcons")); log->add_image(icon); log->add_text(" "); tool_button->set_icon(icon); } break; case MSG_TYPE_EDITOR: { // Distinguish editor messages from messages printed by the project - log->push_color(get_theme_color("font_color", "Editor") * Color(1, 1, 1, 0.6)); + log->push_color(get_theme_color(SNAME("font_color"), SNAME("Editor")) * Color(1, 1, 1, 0.6)); } break; } @@ -336,7 +344,7 @@ EditorLog::EditorLog() { search_box = memnew(LineEdit); search_box->set_h_size_flags(Control::SIZE_EXPAND_FILL); search_box->set_placeholder(TTR("Filter messages")); - search_box->set_right_icon(get_theme_icon("Search", "EditorIcons")); + search_box->set_right_icon(get_theme_icon(SNAME("Search"), SNAME("EditorIcons"))); search_box->set_clear_button_enabled(true); search_box->set_visible(true); search_box->connect("text_changed", callable_mp(this, &EditorLog::_search_changed)); @@ -398,22 +406,22 @@ EditorLog::EditorLog() { vb_right->add_child(memnew(HSeparator)); LogFilter *std_filter = memnew(LogFilter(MSG_TYPE_STD)); - std_filter->initialize_button("Toggle visibility of standard output messages.", callable_mp(this, &EditorLog::_set_filter_active)); + std_filter->initialize_button(TTR("Toggle visibility of standard output messages."), callable_mp(this, &EditorLog::_set_filter_active)); vb_right->add_child(std_filter->toggle_button); type_filter_map.insert(MSG_TYPE_STD, std_filter); LogFilter *error_filter = memnew(LogFilter(MSG_TYPE_ERROR)); - error_filter->initialize_button("Toggle visibility of errors.", callable_mp(this, &EditorLog::_set_filter_active)); + error_filter->initialize_button(TTR("Toggle visibility of errors."), callable_mp(this, &EditorLog::_set_filter_active)); vb_right->add_child(error_filter->toggle_button); type_filter_map.insert(MSG_TYPE_ERROR, error_filter); LogFilter *warning_filter = memnew(LogFilter(MSG_TYPE_WARNING)); - warning_filter->initialize_button("Toggle visibility of warnings.", callable_mp(this, &EditorLog::_set_filter_active)); + warning_filter->initialize_button(TTR("Toggle visibility of warnings."), callable_mp(this, &EditorLog::_set_filter_active)); vb_right->add_child(warning_filter->toggle_button); type_filter_map.insert(MSG_TYPE_WARNING, warning_filter); LogFilter *editor_filter = memnew(LogFilter(MSG_TYPE_EDITOR)); - editor_filter->initialize_button("Toggle visibility of editor messages.", callable_mp(this, &EditorLog::_set_filter_active)); + editor_filter->initialize_button(TTR("Toggle visibility of editor messages."), callable_mp(this, &EditorLog::_set_filter_active)); vb_right->add_child(editor_filter->toggle_button); type_filter_map.insert(MSG_TYPE_EDITOR, editor_filter); diff --git a/editor/editor_log.h b/editor/editor_log.h index 3b6476634a..6cbf4bedee 100644 --- a/editor/editor_log.h +++ b/editor/editor_log.h @@ -163,6 +163,8 @@ private: void _save_state(); void _load_state(); + void _update_theme(); + protected: static void _bind_methods(); void _notification(int p_what); diff --git a/editor/editor_node.cpp b/editor/editor_node.cpp index 4d52414748..2dfad8f05a 100644 --- a/editor/editor_node.cpp +++ b/editor/editor_node.cpp @@ -31,7 +31,6 @@ #include "editor_node.h" #include "core/config/project_settings.h" -#include "core/core_bind.h" #include "core/extension/native_extension_manager.h" #include "core/input/input.h" #include "core/io/config_file.h" @@ -168,6 +167,7 @@ #include "editor/plugins/sprite_2d_editor_plugin.h" #include "editor/plugins/sprite_frames_editor_plugin.h" #include "editor/plugins/style_box_editor_plugin.h" +#include "editor/plugins/sub_viewport_preview_editor_plugin.h" #include "editor/plugins/text_editor.h" #include "editor/plugins/texture_3d_editor_plugin.h" #include "editor/plugins/texture_editor_plugin.h" @@ -316,7 +316,7 @@ void EditorNode::_update_scene_tabs() { disambiguate_filenames(full_path_names, disambiguated_scene_names); scene_tabs->clear_tabs(); - Ref<Texture2D> script_icon = gui_base->get_theme_icon("Script", "EditorIcons"); + Ref<Texture2D> script_icon = gui_base->get_theme_icon(SNAME("Script"), SNAME("EditorIcons")); for (int i = 0; i < editor_data.get_edited_scene_count(); i++) { Node *type_node = editor_data.get_edited_scene_root(i); Ref<Texture2D> icon; @@ -427,7 +427,7 @@ void EditorNode::_unhandled_input(const Ref<InputEvent> &p_event) { } else if (ED_IS_SHORTCUT("editor/editor_script", p_event)) { _editor_select(EDITOR_SCRIPT); } else if (ED_IS_SHORTCUT("editor/editor_help", p_event)) { - emit_signal("request_help_search", ""); + emit_signal(SNAME("request_help_search"), ""); } else if (ED_IS_SHORTCUT("editor/editor_assetlib", p_event) && StreamPeerSSL::is_available()) { _editor_select(EDITOR_ASSETLIB); } else if (ED_IS_SHORTCUT("editor/editor_next", p_event)) { @@ -508,6 +508,9 @@ void EditorNode::_update_from_settings() { float lod_threshold = GLOBAL_GET("rendering/mesh_lod/lod_change/threshold_pixels"); scene_root->set_lod_threshold(lod_threshold); + + RS::get_singleton()->decals_set_filter(RS::DecalFilter(int(GLOBAL_GET("rendering/textures/decals/filter")))); + RS::get_singleton()->light_projectors_set_filter(RS::LightProjectorFilter(int(GLOBAL_GET("rendering/textures/light_projectors/filter")))); } void EditorNode::_notification(int p_what) { @@ -553,7 +556,7 @@ void EditorNode::_notification(int p_what) { if (settings_changed) { _update_from_settings(); settings_changed = false; - emit_signal("project_settings_changed"); + emit_signal(SNAME("project_settings_changed")); } } break; @@ -642,17 +645,17 @@ void EditorNode::_notification(int p_what) { theme_base->set_theme(theme); gui_base->set_theme(theme); - gui_base->add_theme_style_override("panel", gui_base->get_theme_stylebox("Background", "EditorStyles")); - scene_root_parent->add_theme_style_override("panel", gui_base->get_theme_stylebox("Content", "EditorStyles")); - bottom_panel->add_theme_style_override("panel", gui_base->get_theme_stylebox("panel", "TabContainer")); - scene_tabs->add_theme_style_override("tab_selected", gui_base->get_theme_stylebox("SceneTabFG", "EditorStyles")); - scene_tabs->add_theme_style_override("tab_unselected", gui_base->get_theme_stylebox("SceneTabBG", "EditorStyles")); + gui_base->add_theme_style_override("panel", gui_base->get_theme_stylebox(SNAME("Background"), SNAME("EditorStyles"))); + scene_root_parent->add_theme_style_override("panel", gui_base->get_theme_stylebox(SNAME("Content"), SNAME("EditorStyles"))); + bottom_panel->add_theme_style_override("panel", gui_base->get_theme_stylebox(SNAME("panel"), SNAME("TabContainer"))); + scene_tabs->add_theme_style_override("tab_selected", gui_base->get_theme_stylebox(SNAME("SceneTabFG"), SNAME("EditorStyles"))); + scene_tabs->add_theme_style_override("tab_unselected", gui_base->get_theme_stylebox(SNAME("SceneTabBG"), SNAME("EditorStyles"))); - file_menu->add_theme_style_override("hover", gui_base->get_theme_stylebox("MenuHover", "EditorStyles")); - project_menu->add_theme_style_override("hover", gui_base->get_theme_stylebox("MenuHover", "EditorStyles")); - debug_menu->add_theme_style_override("hover", gui_base->get_theme_stylebox("MenuHover", "EditorStyles")); - settings_menu->add_theme_style_override("hover", gui_base->get_theme_stylebox("MenuHover", "EditorStyles")); - help_menu->add_theme_style_override("hover", gui_base->get_theme_stylebox("MenuHover", "EditorStyles")); + file_menu->add_theme_style_override("hover", gui_base->get_theme_stylebox(SNAME("MenuHover"), SNAME("EditorStyles"))); + project_menu->add_theme_style_override("hover", gui_base->get_theme_stylebox(SNAME("MenuHover"), SNAME("EditorStyles"))); + debug_menu->add_theme_style_override("hover", gui_base->get_theme_stylebox(SNAME("MenuHover"), SNAME("EditorStyles"))); + settings_menu->add_theme_style_override("hover", gui_base->get_theme_stylebox(SNAME("MenuHover"), SNAME("EditorStyles"))); + help_menu->add_theme_style_override("hover", gui_base->get_theme_stylebox(SNAME("MenuHover"), SNAME("EditorStyles"))); if (EDITOR_GET("interface/scene_tabs/resize_if_many_tabs")) { scene_tabs->set_min_width(int(EDITOR_GET("interface/scene_tabs/minimum_width")) * EDSCALE); @@ -665,7 +668,7 @@ void EditorNode::_notification(int p_what) { // debugger area if (EditorDebuggerNode::get_singleton()->is_visible()) { - bottom_panel->add_theme_style_override("panel", gui_base->get_theme_stylebox("BottomPanelDebuggerOverride", "EditorStyles")); + bottom_panel->add_theme_style_override("panel", gui_base->get_theme_stylebox(SNAME("BottomPanelDebuggerOverride"), SNAME("EditorStyles"))); } // update_icons @@ -683,17 +686,17 @@ void EditorNode::_notification(int p_what) { _build_icon_type_cache(); - play_button->set_icon(gui_base->get_theme_icon("MainPlay", "EditorIcons")); - play_scene_button->set_icon(gui_base->get_theme_icon("PlayScene", "EditorIcons")); - play_custom_scene_button->set_icon(gui_base->get_theme_icon("PlayCustom", "EditorIcons")); - pause_button->set_icon(gui_base->get_theme_icon("Pause", "EditorIcons")); - stop_button->set_icon(gui_base->get_theme_icon("Stop", "EditorIcons")); + play_button->set_icon(gui_base->get_theme_icon(SNAME("MainPlay"), SNAME("EditorIcons"))); + play_scene_button->set_icon(gui_base->get_theme_icon(SNAME("PlayScene"), SNAME("EditorIcons"))); + play_custom_scene_button->set_icon(gui_base->get_theme_icon(SNAME("PlayCustom"), SNAME("EditorIcons"))); + pause_button->set_icon(gui_base->get_theme_icon(SNAME("Pause"), SNAME("EditorIcons"))); + stop_button->set_icon(gui_base->get_theme_icon(SNAME("Stop"), SNAME("EditorIcons"))); - prev_scene->set_icon(gui_base->get_theme_icon("PrevScene", "EditorIcons")); - distraction_free->set_icon(gui_base->get_theme_icon("DistractionFree", "EditorIcons")); - scene_tab_add->set_icon(gui_base->get_theme_icon("Add", "EditorIcons")); + prev_scene->set_icon(gui_base->get_theme_icon(SNAME("PrevScene"), SNAME("EditorIcons"))); + distraction_free->set_icon(gui_base->get_theme_icon(SNAME("DistractionFree"), SNAME("EditorIcons"))); + scene_tab_add->set_icon(gui_base->get_theme_icon(SNAME("Add"), SNAME("EditorIcons"))); - bottom_panel_raise->set_icon(gui_base->get_theme_icon("ExpandBottomDock", "EditorIcons")); + bottom_panel_raise->set_icon(gui_base->get_theme_icon(SNAME("ExpandBottomDock"), SNAME("EditorIcons"))); // clear_button->set_icon(gui_base->get_icon("Close", "EditorIcons")); don't have access to that node. needs to become a class property if (gui_base->is_layout_rtl()) { @@ -705,19 +708,19 @@ void EditorNode::_notification(int p_what) { } PopupMenu *p = help_menu->get_popup(); - p->set_item_icon(p->get_item_index(HELP_SEARCH), gui_base->get_theme_icon("HelpSearch", "EditorIcons")); - p->set_item_icon(p->get_item_index(HELP_DOCS), gui_base->get_theme_icon("Instance", "EditorIcons")); - p->set_item_icon(p->get_item_index(HELP_QA), gui_base->get_theme_icon("Instance", "EditorIcons")); - p->set_item_icon(p->get_item_index(HELP_REPORT_A_BUG), gui_base->get_theme_icon("Instance", "EditorIcons")); - p->set_item_icon(p->get_item_index(HELP_SUGGEST_A_FEATURE), gui_base->get_theme_icon("Instance", "EditorIcons")); - p->set_item_icon(p->get_item_index(HELP_SEND_DOCS_FEEDBACK), gui_base->get_theme_icon("Instance", "EditorIcons")); - p->set_item_icon(p->get_item_index(HELP_COMMUNITY), gui_base->get_theme_icon("Instance", "EditorIcons")); - p->set_item_icon(p->get_item_index(HELP_ABOUT), gui_base->get_theme_icon("Godot", "EditorIcons")); - p->set_item_icon(p->get_item_index(HELP_SUPPORT_GODOT_DEVELOPMENT), gui_base->get_theme_icon("Heart", "EditorIcons")); + p->set_item_icon(p->get_item_index(HELP_SEARCH), gui_base->get_theme_icon(SNAME("HelpSearch"), SNAME("EditorIcons"))); + p->set_item_icon(p->get_item_index(HELP_DOCS), gui_base->get_theme_icon(SNAME("Instance"), SNAME("EditorIcons"))); + p->set_item_icon(p->get_item_index(HELP_QA), gui_base->get_theme_icon(SNAME("Instance"), SNAME("EditorIcons"))); + p->set_item_icon(p->get_item_index(HELP_REPORT_A_BUG), gui_base->get_theme_icon(SNAME("Instance"), SNAME("EditorIcons"))); + p->set_item_icon(p->get_item_index(HELP_SUGGEST_A_FEATURE), gui_base->get_theme_icon(SNAME("Instance"), SNAME("EditorIcons"))); + p->set_item_icon(p->get_item_index(HELP_SEND_DOCS_FEEDBACK), gui_base->get_theme_icon(SNAME("Instance"), SNAME("EditorIcons"))); + p->set_item_icon(p->get_item_index(HELP_COMMUNITY), gui_base->get_theme_icon(SNAME("Instance"), SNAME("EditorIcons"))); + p->set_item_icon(p->get_item_index(HELP_ABOUT), gui_base->get_theme_icon(SNAME("Godot"), SNAME("EditorIcons"))); + p->set_item_icon(p->get_item_index(HELP_SUPPORT_GODOT_DEVELOPMENT), gui_base->get_theme_icon(SNAME("Heart"), SNAME("EditorIcons"))); for (int i = 0; i < main_editor_buttons.size(); i++) { - main_editor_buttons.write[i]->add_theme_font_override("font", gui_base->get_theme_font("main_button_font", "EditorFonts")); - main_editor_buttons.write[i]->add_theme_font_size_override("font_size", gui_base->get_theme_font_size("main_button_font_size", "EditorFonts")); + main_editor_buttons.write[i]->add_theme_font_override("font", gui_base->get_theme_font(SNAME("main_button_font"), SNAME("EditorFonts"))); + main_editor_buttons.write[i]->add_theme_font_size_override("font_size", gui_base->get_theme_font_size(SNAME("main_button_font_size"), SNAME("EditorFonts"))); } _update_update_spinner(); @@ -794,8 +797,8 @@ void EditorNode::_resources_changed(const Vector<String> &p_resources) { } if (changed.size()) { - for (List<Ref<Resource>>::Element *E = changed.front(); E; E = E->next()) { - E->get()->reload_from_file(); + for (Ref<Resource> &res : changed) { + res->reload_from_file(); } } } @@ -911,8 +914,8 @@ void EditorNode::_resources_reimported(const Vector<String> &p_resources) { } } - for (List<String>::Element *E = scenes.front(); E; E = E->next()) { - reload_scene(E->get()); + for (const String &E : scenes) { + reload_scene(E); } scene_tabs->set_current_tab(current_tab); @@ -923,7 +926,7 @@ void EditorNode::_sources_changed(bool p_exist) { waiting_for_first_scan = false; // Reload the global shader variables, but this time - // loading texures, as they are now properly imported. + // loading textures, as they are now properly imported. RenderingServer::get_singleton()->global_variables_load_settings(true); // Start preview thread now that it's safe. @@ -972,7 +975,7 @@ void EditorNode::_scan_external_changes() { } if (need_reload) { - disk_changed->call_deferred("popup_centered_ratio", 0.5); + disk_changed->call_deferred(SNAME("popup_centered_ratio"), 0.5); } } @@ -1105,7 +1108,7 @@ void EditorNode::save_resource_in_path(const Ref<Resource> &p_resource, const St } ((Resource *)p_resource.ptr())->set_path(path); - emit_signal("resource_saved", p_resource); + emit_signal(SNAME("resource_saved"), p_resource); editor_data.notify_resource_saved(p_resource); } @@ -1140,13 +1143,13 @@ void EditorNode::save_resource_as(const Ref<Resource> &p_resource, const String file->clear_filters(); List<String> preferred; - for (List<String>::Element *E = extensions.front(); E; E = E->next()) { - if (p_resource->is_class("Script") && (E->get() == "tres" || E->get() == "res")) { + for (const String &E : extensions) { + if (p_resource->is_class("Script") && (E == "tres" || E == "res")) { //this serves no purpose and confused people continue; } - file->add_filter("*." + E->get() + " ; " + E->get().to_upper()); - preferred.push_back(E->get()); + file->add_filter("*." + E + " ; " + E.to_upper()); + preferred.push_back(E); } // Lowest priority extension List<String>::Element *res_element = preferred.find("res"); @@ -1165,7 +1168,8 @@ void EditorNode::save_resource_as(const Ref<Resource> &p_resource, const String file->set_current_file(p_resource->get_path().get_file()); } else { if (extensions.size()) { - file->set_current_file("new_" + p_resource->get_class().to_lower() + "." + preferred.front()->get().to_lower()); + String resource_name_snake_case = p_resource->get_class().camelcase_to_underscore(); + file->set_current_file("new_" + resource_name_snake_case + "." + preferred.front()->get().to_lower()); } else { file->set_current_file(String()); } @@ -1181,7 +1185,8 @@ void EditorNode::save_resource_as(const Ref<Resource> &p_resource, const String } else if (preferred.size()) { String existing; if (extensions.size()) { - existing = "new_" + p_resource->get_class().to_lower() + "." + preferred.front()->get().to_lower(); + String resource_name_snake_case = p_resource->get_class().camelcase_to_underscore(); + existing = "new_" + resource_name_snake_case + "." + preferred.front()->get().to_lower(); } file->set_current_path(existing); } @@ -1256,10 +1261,10 @@ void EditorNode::_get_scene_metadata(const String &p_file) { cf->get_section_keys("editor_states", &esl); Dictionary md; - for (List<String>::Element *E = esl.front(); E; E = E->next()) { - Variant st = cf->get_value("editor_states", E->get()); + for (const String &E : esl) { + Variant st = cf->get_value("editor_states", E); if (st.get_type() != Variant::NIL) { - md[E->get()] = st; + md[E] = st; } } @@ -1292,8 +1297,8 @@ void EditorNode::_set_scene_metadata(const String &p_file, int p_idx) { List<Variant> keys; md.get_key_list(&keys); - for (List<Variant>::Element *E = keys.front(); E; E = E->next()) { - cf->set_value("editor_states", E->get(), md[E->get()]); + for (const Variant &E : keys) { + cf->set_value("editor_states", E, md[E]); } Error err = cf->save(path); @@ -1331,14 +1336,14 @@ bool EditorNode::_find_and_save_edited_subresources(Object *obj, Map<RES, bool> bool ret_changed = false; List<PropertyInfo> pi; obj->get_property_list(&pi); - for (List<PropertyInfo>::Element *E = pi.front(); E; E = E->next()) { - if (!(E->get().usage & PROPERTY_USAGE_STORAGE)) { + for (const PropertyInfo &E : pi) { + if (!(E.usage & PROPERTY_USAGE_STORAGE)) { continue; } - switch (E->get().type) { + switch (E.type) { case Variant::OBJECT: { - RES res = obj->get(E->get().name); + RES res = obj->get(E.name); if (_find_and_save_resource(res, processed, flags)) { ret_changed = true; @@ -1346,7 +1351,7 @@ bool EditorNode::_find_and_save_edited_subresources(Object *obj, Map<RES, bool> } break; case Variant::ARRAY: { - Array varray = obj->get(E->get().name); + Array varray = obj->get(E.name); int len = varray.size(); for (int i = 0; i < len; i++) { const Variant &v = varray.get(i); @@ -1358,11 +1363,11 @@ bool EditorNode::_find_and_save_edited_subresources(Object *obj, Map<RES, bool> } break; case Variant::DICTIONARY: { - Dictionary d = obj->get(E->get().name); + Dictionary d = obj->get(E.name); List<Variant> keys; d.get_key_list(&keys); - for (List<Variant>::Element *F = keys.front(); F; F = F->next()) { - Variant v = d[F->get()]; + for (const Variant &F : keys) { + Variant v = d[F]; RES res = v; if (_find_and_save_resource(res, processed, flags)) { ret_changed = true; @@ -1517,9 +1522,9 @@ static bool _find_edited_resources(const Ref<Resource> &p_resource, Set<Ref<Reso p_resource->get_property_list(&plist); - for (List<PropertyInfo>::Element *E = plist.front(); E; E = E->next()) { - if (E->get().type == Variant::OBJECT && E->get().usage & PROPERTY_USAGE_STORAGE && !(E->get().usage & PROPERTY_USAGE_RESOURCE_NOT_PERSISTENT)) { - RES res = p_resource->get(E->get().name); + for (const PropertyInfo &E : plist) { + if (E.type == Variant::OBJECT && E.usage & PROPERTY_USAGE_STORAGE && !(E.usage & PROPERTY_USAGE_RESOURCE_NOT_PERSISTENT)) { + RES res = p_resource->get(E.name); if (res.is_null()) { continue; } @@ -1548,12 +1553,11 @@ int EditorNode::_save_external_resources() { int saved = 0; List<Ref<Resource>> cached; ResourceCache::get_cached_resources(&cached); - for (List<Ref<Resource>>::Element *E = cached.front(); E; E = E->next()) { - Ref<Resource> res = E->get(); + for (const Ref<Resource> &res : cached) { if (!res->get_path().is_resource_file()) { continue; } - //not only check if this resourec is edited, check contained subresources too + //not only check if this resource is edited, check contained subresources too if (_find_edited_resources(res, edited_subresources)) { ResourceSaver::save(res->get_path(), res, flg); saved++; @@ -1639,8 +1643,8 @@ void EditorNode::_save_scene(String p_file, int idx) { editor_data.save_editor_external_data(); - for (List<Ref<AnimatedValuesBackup>>::Element *E = anim_backups.front(); E; E = E->next()) { - E->get()->restore(); + for (Ref<AnimatedValuesBackup> &E : anim_backups) { + E->restore(); } if (err == OK) { @@ -1881,8 +1885,8 @@ void EditorNode::_dialog_action(String p_file) { // erase List<String> keys; config->get_section_keys(p_file, &keys); - for (List<String>::Element *E = keys.front(); E; E = E->next()) { - config->set_value(p_file, E->get(), Variant()); + for (const String &E : keys) { + config->set_value(p_file, E, Variant()); } config->save(EditorSettings::get_singleton()->get_editor_layouts_config()); @@ -2217,11 +2221,11 @@ void EditorNode::_run(bool p_current, const String &p_custom) { } play_button->set_pressed(false); - play_button->set_icon(gui_base->get_theme_icon("MainPlay", "EditorIcons")); + play_button->set_icon(gui_base->get_theme_icon(SNAME("MainPlay"), SNAME("EditorIcons"))); play_scene_button->set_pressed(false); - play_scene_button->set_icon(gui_base->get_theme_icon("PlayScene", "EditorIcons")); + play_scene_button->set_icon(gui_base->get_theme_icon(SNAME("PlayScene"), SNAME("EditorIcons"))); play_custom_scene_button->set_pressed(false); - play_custom_scene_button->set_icon(gui_base->get_theme_icon("PlayCustom", "EditorIcons")); + play_custom_scene_button->set_icon(gui_base->get_theme_icon(SNAME("PlayCustom"), SNAME("EditorIcons"))); String run_filename; String args; @@ -2294,17 +2298,17 @@ void EditorNode::_run(bool p_current, const String &p_custom) { return; } - emit_signal("play_pressed"); + emit_signal(SNAME("play_pressed")); if (p_current) { play_scene_button->set_pressed(true); - play_scene_button->set_icon(gui_base->get_theme_icon("Reload", "EditorIcons")); + play_scene_button->set_icon(gui_base->get_theme_icon(SNAME("Reload"), SNAME("EditorIcons"))); } else if (p_custom != "") { run_custom_filename = p_custom; play_custom_scene_button->set_pressed(true); - play_custom_scene_button->set_icon(gui_base->get_theme_icon("Reload", "EditorIcons")); + play_custom_scene_button->set_icon(gui_base->get_theme_icon(SNAME("Reload"), SNAME("EditorIcons"))); } else { play_button->set_pressed(true); - play_button->set_icon(gui_base->get_theme_icon("Reload", "EditorIcons")); + play_button->set_icon(gui_base->get_theme_icon(SNAME("Reload"), SNAME("EditorIcons"))); } stop_button->set_disabled(false); @@ -2324,11 +2328,14 @@ void EditorNode::_run_native(const Ref<EditorExportPreset> &p_preset) { } EditorDebuggerNode::get_singleton()->start(p_preset->get_platform()->get_debug_protocol()); - emit_signal("play_pressed"); + emit_signal(SNAME("play_pressed")); editor_run.run_native_notify(); } } +void EditorNode::_android_build_source_selected(const String &p_file) { + export_template_manager->install_android_template_from_file(p_file); +} void EditorNode::_menu_option_confirm(int p_option, bool p_confirmed) { if (!p_confirmed) { //this may be a hack.. current_option = (MenuOptions)p_option; @@ -2527,8 +2534,8 @@ void EditorNode::_menu_option_confirm(int p_option, bool p_confirmed) { Ref<MeshLibrary> ml(memnew(MeshLibrary)); ResourceSaver::get_recognized_extensions(ml, &extensions); file_export_lib->clear_filters(); - for (List<String>::Element *E = extensions.front(); E; E = E->next()) { - file_export_lib->add_filter("*." + E->get()); + for (const String &E : extensions) { + file_export_lib->add_filter("*." + E); } file_export_lib->popup_file_dialog(); @@ -2636,11 +2643,11 @@ void EditorNode::_menu_option_confirm(int p_option, bool p_confirmed) { editor_run.stop(); run_custom_filename.clear(); play_button->set_pressed(false); - play_button->set_icon(gui_base->get_theme_icon("MainPlay", "EditorIcons")); + play_button->set_icon(gui_base->get_theme_icon(SNAME("MainPlay"), SNAME("EditorIcons"))); play_scene_button->set_pressed(false); - play_scene_button->set_icon(gui_base->get_theme_icon("PlayScene", "EditorIcons")); + play_scene_button->set_icon(gui_base->get_theme_icon(SNAME("PlayScene"), SNAME("EditorIcons"))); play_custom_scene_button->set_pressed(false); - play_custom_scene_button->set_icon(gui_base->get_theme_icon("PlayCustom", "EditorIcons")); + play_custom_scene_button->set_icon(gui_base->get_theme_icon(SNAME("PlayCustom"), SNAME("EditorIcons"))); stop_button->set_disabled(true); if (bool(EDITOR_GET("run/output/always_close_output_on_stop"))) { @@ -2652,7 +2659,7 @@ void EditorNode::_menu_option_confirm(int p_option, bool p_confirmed) { } } EditorDebuggerNode::get_singleton()->stop(); - emit_signal("stop_pressed"); + emit_signal(SNAME("stop_pressed")); } break; @@ -2753,6 +2760,10 @@ void EditorNode::_menu_option_confirm(int p_option, bool p_confirmed) { export_template_manager->popup_manager(); } break; + case SETTINGS_INSTALL_ANDROID_BUILD_TEMPLATE: { + custom_build_manage_templates->hide(); + file_android_build_source->popup_centered_ratio(); + } break; case SETTINGS_MANAGE_FEATURE_PROFILES: { feature_profile_manager->popup_centered_clamped(Size2(900, 800) * EDSCALE, 0.8); } break; @@ -2786,7 +2797,7 @@ void EditorNode::_menu_option_confirm(int p_option, bool p_confirmed) { } break; case HELP_SEARCH: { - emit_signal("request_help_search", ""); + emit_signal(SNAME("request_help_search"), ""); } break; case HELP_DOCS: { OS::get_singleton()->shell_open("https://docs.godotengine.org/"); @@ -3060,8 +3071,8 @@ void EditorNode::add_editor_plugin(EditorPlugin *p_editor, bool p_config_changed tb->set_icon(singleton->gui_base->get_theme_icon(p_editor->get_name(), "EditorIcons")); } - tb->add_theme_font_override("font", singleton->gui_base->get_theme_font("main_button_font", "EditorFonts")); - tb->add_theme_font_size_override("font_size", singleton->gui_base->get_theme_font_size("main_button_font_size", "EditorFonts")); + tb->add_theme_font_override("font", singleton->gui_base->get_theme_font(SNAME("main_button_font"), SNAME("EditorFonts"))); + tb->add_theme_font_size_override("font_size", singleton->gui_base->get_theme_font_size(SNAME("main_button_font_size"), SNAME("EditorFonts"))); tb->set_name(p_editor->get_name()); singleton->main_editor_buttons.push_back(tb); @@ -3359,7 +3370,7 @@ void EditorNode::set_current_scene(int p_idx) { editor_folding.load_scene_folding(editor_data.get_edited_scene_root(p_idx), editor_data.get_scene_path(p_idx)); } - call_deferred("_clear_undo_history"); + call_deferred(SNAME("_clear_undo_history")); } changing_scene = true; @@ -3396,7 +3407,7 @@ void EditorNode::set_current_scene(int p_idx) { _update_title(); - call_deferred("_set_main_scene_state", state, get_edited_scene()); //do after everything else is done setting up + call_deferred(SNAME("_set_main_scene_state"), state, get_edited_scene()); //do after everything else is done setting up } bool EditorNode::is_scene_open(const String &p_path) { @@ -3643,7 +3654,7 @@ void EditorNode::_add_to_recent_scenes(const String &p_scene) { void EditorNode::_open_recent_scene(int p_idx) { if (p_idx == recent_scenes->get_item_count() - 1) { EditorSettings::get_singleton()->set_project_metadata("recent_files", "scenes", Array()); - call_deferred("_update_recent_scenes"); + call_deferred(SNAME("_update_recent_scenes")); } else { Array rc = EditorSettings::get_singleton()->get_project_metadata("recent_files", "scenes", Array()); ERR_FAIL_INDEX(p_idx, rc.size()); @@ -3705,7 +3716,7 @@ void EditorNode::add_io_error(const String &p_error) { void EditorNode::_load_error_notify(void *p_ud, const String &p_text) { EditorNode *en = (EditorNode *)p_ud; - en->load_errors->add_image(en->gui_base->get_theme_icon("Error", "EditorIcons")); + en->load_errors->add_image(en->gui_base->get_theme_icon(SNAME("Error"), SNAME("EditorIcons"))); en->load_errors->add_text(p_text + "\n"); en->load_error_dialog->popup_centered_ratio(0.5); } @@ -3932,7 +3943,7 @@ Ref<Texture2D> EditorNode::get_object_icon(const Object *p_object, const String } if (p_fallback.length()) { - return gui_base->get_theme_icon(p_fallback, "EditorIcons"); + return gui_base->get_theme_icon(p_fallback, SNAME("EditorIcons")); } return nullptr; @@ -3973,12 +3984,12 @@ Ref<Texture2D> EditorNode::get_class_icon(const String &p_class, const String &p } } - if (gui_base->has_theme_icon(p_class, "EditorIcons")) { - return gui_base->get_theme_icon(p_class, "EditorIcons"); + if (gui_base->has_theme_icon(p_class, SNAME("EditorIcons"))) { + return gui_base->get_theme_icon(p_class, SNAME("EditorIcons")); } - if (p_fallback.length() && gui_base->has_theme_icon(p_fallback, "EditorIcons")) { - return gui_base->get_theme_icon(p_fallback, "EditorIcons"); + if (p_fallback.length() && gui_base->has_theme_icon(p_fallback, SNAME("EditorIcons"))) { + return gui_base->get_theme_icon(p_fallback, SNAME("EditorIcons")); } return nullptr; @@ -4045,11 +4056,11 @@ void EditorNode::_build_icon_type_cache() { List<StringName> tl; StringName ei = "EditorIcons"; theme_base->get_theme()->get_icon_list(ei, &tl); - for (List<StringName>::Element *E = tl.front(); E; E = E->next()) { - if (!ClassDB::class_exists(E->get())) { + for (const StringName &E : tl) { + if (!ClassDB::class_exists(E)) { continue; } - icon_type_cache[E->get()] = theme_base->get_theme()->get_icon(E->get(), ei); + icon_type_cache[E] = theme_base->get_theme()->get_icon(E, ei); } } @@ -4282,7 +4293,7 @@ void EditorNode::_dock_select_draw() { Color used = Color(0.6, 0.6, 0.6, 0.8); Color used_selected = Color(0.8, 0.8, 0.8, 0.8); - Color tab_selected = theme_base->get_theme_color("mono_color", "Editor"); + Color tab_selected = theme_base->get_theme_color(SNAME("mono_color"), SNAME("Editor")); Color unused = used; unused.a = 0.4; Color unusable = unused; @@ -4774,9 +4785,7 @@ void EditorNode::_update_layouts_menu() { List<String> layouts; config.ptr()->get_sections(&layouts); - for (List<String>::Element *E = layouts.front(); E; E = E->next()) { - String layout = E->get(); - + for (const String &layout : layouts) { if (layout == TTR("Default")) { editor_layouts->remove_item(editor_layouts->get_item_index(SETTINGS_LAYOUT_DEFAULT)); overridden_default_layout = editor_layouts->get_item_count(); @@ -5045,9 +5054,9 @@ void EditorNode::_bottom_panel_switch(bool p_enable, int p_idx) { bottom_panel_items[i].control->set_visible(i == p_idx); } if (EditorDebuggerNode::get_singleton() == bottom_panel_items[p_idx].control) { // this is the debug panel which uses tabs, so the top section should be smaller - bottom_panel->add_theme_style_override("panel", gui_base->get_theme_stylebox("BottomPanelDebuggerOverride", "EditorStyles")); + bottom_panel->add_theme_style_override("panel", gui_base->get_theme_stylebox(SNAME("BottomPanelDebuggerOverride"), SNAME("EditorStyles"))); } else { - bottom_panel->add_theme_style_override("panel", gui_base->get_theme_stylebox("panel", "TabContainer")); + bottom_panel->add_theme_style_override("panel", gui_base->get_theme_stylebox(SNAME("panel"), SNAME("TabContainer"))); } center_split->set_dragger_visibility(SplitContainer::DRAGGER_VISIBLE); center_split->set_collapsed(false); @@ -5057,7 +5066,7 @@ void EditorNode::_bottom_panel_switch(bool p_enable, int p_idx) { bottom_panel_raise->show(); } else { - bottom_panel->add_theme_style_override("panel", gui_base->get_theme_stylebox("panel", "TabContainer")); + bottom_panel->add_theme_style_override("panel", gui_base->get_theme_stylebox(SNAME("panel"), SNAME("TabContainer"))); bottom_panel_items[p_idx].button->set_pressed(false); bottom_panel_items[p_idx].control->set_visible(false); center_split->set_dragger_visibility(SplitContainer::DRAGGER_HIDDEN); @@ -5146,7 +5155,7 @@ Variant EditorNode::drag_resource(const Ref<Resource> &p_res, Control *p_from) { { //todo make proper previews - Ref<ImageTexture> texture = gui_base->get_theme_icon("FileBigThumb", "EditorIcons"); + Ref<ImageTexture> texture = gui_base->get_theme_icon(SNAME("FileBigThumb"), SNAME("EditorIcons")); Ref<Image> img = texture->get_image(); img = img->duplicate(); img->resize(48, 48); //meh @@ -5198,10 +5207,10 @@ Variant EditorNode::drag_files_and_dirs(const Vector<String> &p_paths, Control * if (p_paths[i].ends_with("/")) { label->set_text(p_paths[i].substr(0, p_paths[i].length() - 1).get_file()); - icon->set_texture(gui_base->get_theme_icon("Folder", "EditorIcons")); + icon->set_texture(gui_base->get_theme_icon(SNAME("Folder"), SNAME("EditorIcons"))); } else { label->set_text(p_paths[i].get_file()); - icon->set_texture(gui_base->get_theme_icon("File", "EditorIcons")); + icon->set_texture(gui_base->get_theme_icon(SNAME("File"), SNAME("EditorIcons"))); } icon->set_stretch_mode(TextureRect::STRETCH_KEEP_CENTERED); icon->set_size(Size2(16, 16)); @@ -5326,27 +5335,6 @@ void EditorNode::_file_access_close_error_notify(const String &p_str) { } void EditorNode::reload_scene(const String &p_path) { - /* - * No longer necessary since scenes now reset and reload their internal resource if needed. - //first of all, reload internal textures, materials, meshes, etc. as they might have changed on disk - - List<Ref<Resource>> cached; - ResourceCache::get_cached_resources(&cached); - List<Ref<Resource>> to_clear; //clear internal resources from previous scene from being used - for (List<Ref<Resource>>::Element *E = cached.front(); E; E = E->next()) { - if (E->get()->get_path().begins_with(p_path + "::")) { //subresources of existing scene - to_clear.push_back(E->get()); - } - } - - //so reload reloads everything, clear subresources of previous scene - while (to_clear.front()) { - to_clear.front()->get()->set_path(""); - to_clear.pop_front(); - } - - */ - int scene_idx = -1; for (int i = 0; i < editor_data.get_edited_scene_count(); i++) { if (editor_data.get_scene_path(i) == p_path) { @@ -5473,7 +5461,7 @@ void EditorNode::_update_video_driver_color() { if (video_driver->get_text() == "GLES2") { video_driver->add_theme_color_override("font_color", Color::hex(0x5586a4ff)); } else if (video_driver->get_text() == "Vulkan") { - video_driver->add_theme_color_override("font_color", theme_base->get_theme_color("vulkan_color", "Editor")); + video_driver->add_theme_color_override("font_color", theme_base->get_theme_color(SNAME("vulkan_color"), SNAME("Editor"))); } } @@ -5903,7 +5891,7 @@ EditorNode::EditorNode() { theme_base->set_theme(theme); gui_base->set_theme(theme); - gui_base->add_theme_style_override("panel", gui_base->get_theme_stylebox("Background", "EditorStyles")); + gui_base->add_theme_style_override("panel", gui_base->get_theme_stylebox(SNAME("Background"), SNAME("EditorStyles"))); resource_preview = memnew(EditorResourcePreview); add_child(resource_preview); @@ -6084,8 +6072,8 @@ EditorNode::EditorNode() { tab_preview_panel->add_child(tab_preview); scene_tabs = memnew(Tabs); - scene_tabs->add_theme_style_override("tab_selected", gui_base->get_theme_stylebox("SceneTabFG", "EditorStyles")); - scene_tabs->add_theme_style_override("tab_unselected", gui_base->get_theme_stylebox("SceneTabBG", "EditorStyles")); + scene_tabs->add_theme_style_override("tab_selected", gui_base->get_theme_stylebox(SNAME("SceneTabFG"), SNAME("EditorStyles"))); + scene_tabs->add_theme_style_override("tab_unselected", gui_base->get_theme_stylebox(SNAME("SceneTabBG"), SNAME("EditorStyles"))); scene_tabs->set_select_with_rmb(true); scene_tabs->add_tab("unsaved"); scene_tabs->set_tab_align(Tabs::ALIGN_LEFT); @@ -6119,7 +6107,7 @@ EditorNode::EditorNode() { #endif distraction_free->set_tooltip(TTR("Toggle distraction-free mode.")); distraction_free->connect("pressed", callable_mp(this, &EditorNode::_toggle_distraction_free_mode)); - distraction_free->set_icon(gui_base->get_theme_icon("DistractionFree", "EditorIcons")); + distraction_free->set_icon(gui_base->get_theme_icon(SNAME("DistractionFree"), SNAME("EditorIcons"))); distraction_free->set_toggle_mode(true); scene_tab_add = memnew(Button); @@ -6127,13 +6115,13 @@ EditorNode::EditorNode() { tabbar_container->add_child(scene_tab_add); tabbar_container->add_child(distraction_free); scene_tab_add->set_tooltip(TTR("Add a new scene.")); - scene_tab_add->set_icon(gui_base->get_theme_icon("Add", "EditorIcons")); + scene_tab_add->set_icon(gui_base->get_theme_icon(SNAME("Add"), SNAME("EditorIcons"))); scene_tab_add->add_theme_color_override("icon_normal_color", Color(0.6f, 0.6f, 0.6f, 0.8f)); scene_tab_add->connect("pressed", callable_mp(this, &EditorNode::_menu_option), make_binds(FILE_NEW_SCENE)); scene_root_parent = memnew(PanelContainer); scene_root_parent->set_custom_minimum_size(Size2(0, 80) * EDSCALE); - scene_root_parent->add_theme_style_override("panel", gui_base->get_theme_stylebox("Content", "EditorStyles")); + scene_root_parent->add_theme_style_override("panel", gui_base->get_theme_stylebox(SNAME("Content"), SNAME("EditorStyles"))); scene_root_parent->set_draw_behind_parent(true); srt->add_child(scene_root_parent); scene_root_parent->set_v_size_flags(Control::SIZE_EXPAND_FILL); @@ -6157,12 +6145,12 @@ EditorNode::EditorNode() { file_menu->set_flat(false); file_menu->set_switch_on_hover(true); file_menu->set_text(TTR("Scene")); - file_menu->add_theme_style_override("hover", gui_base->get_theme_stylebox("MenuHover", "EditorStyles")); + file_menu->add_theme_style_override("hover", gui_base->get_theme_stylebox(SNAME("MenuHover"), SNAME("EditorStyles"))); left_menu_hb->add_child(file_menu); prev_scene = memnew(Button); prev_scene->set_flat(true); - prev_scene->set_icon(gui_base->get_theme_icon("PrevScene", "EditorIcons")); + prev_scene->set_icon(gui_base->get_theme_icon(SNAME("PrevScene"), SNAME("EditorIcons"))); prev_scene->set_tooltip(TTR("Go to previously opened scene.")); prev_scene->set_disabled(true); prev_scene->connect("pressed", callable_mp(this, &EditorNode::_menu_option), make_binds(FILE_OPEN_PREV)); @@ -6261,7 +6249,7 @@ EditorNode::EditorNode() { project_menu->set_switch_on_hover(true); project_menu->set_tooltip(TTR("Miscellaneous project or scene-wide tools.")); project_menu->set_text(TTR("Project")); - project_menu->add_theme_style_override("hover", gui_base->get_theme_stylebox("MenuHover", "EditorStyles")); + project_menu->add_theme_style_override("hover", gui_base->get_theme_stylebox(SNAME("MenuHover"), SNAME("EditorStyles"))); left_menu_hb->add_child(project_menu); p = project_menu->get_popup(); @@ -6295,7 +6283,7 @@ EditorNode::EditorNode() { tool_menu->add_item(TTR("Orphan Resource Explorer..."), TOOLS_ORPHAN_RESOURCES); p->add_separator(); - p->add_item(TTR("Reload Current Project"), RUN_RELOAD_CURRENT_PROJECT); + p->add_shortcut(ED_SHORTCUT("editor/reload_current_project", TTR("Reload Current Project")), RUN_RELOAD_CURRENT_PROJECT); #ifdef OSX_ENABLED p->add_shortcut(ED_SHORTCUT("editor/quit_to_project_list", TTR("Quit to Project List"), KEY_MASK_SHIFT + KEY_MASK_ALT + KEY_Q), RUN_PROJECT_MANAGER, true); #else @@ -6312,7 +6300,7 @@ EditorNode::EditorNode() { debug_menu->set_flat(false); debug_menu->set_switch_on_hover(true); debug_menu->set_text(TTR("Debug")); - debug_menu->add_theme_style_override("hover", gui_base->get_theme_stylebox("MenuHover", "EditorStyles")); + debug_menu->add_theme_style_override("hover", gui_base->get_theme_stylebox(SNAME("MenuHover"), SNAME("EditorStyles"))); left_menu_hb->add_child(debug_menu); menu_hb->add_spacer(); @@ -6321,7 +6309,7 @@ EditorNode::EditorNode() { settings_menu->set_flat(false); settings_menu->set_switch_on_hover(true); settings_menu->set_text(TTR("Editor")); - settings_menu->add_theme_style_override("hover", gui_base->get_theme_stylebox("MenuHover", "EditorStyles")); + settings_menu->add_theme_style_override("hover", gui_base->get_theme_stylebox(SNAME("MenuHover"), SNAME("EditorStyles"))); left_menu_hb->add_child(settings_menu); p = settings_menu->get_popup(); @@ -6374,26 +6362,26 @@ EditorNode::EditorNode() { help_menu->set_flat(false); help_menu->set_switch_on_hover(true); help_menu->set_text(TTR("Help")); - help_menu->add_theme_style_override("hover", gui_base->get_theme_stylebox("MenuHover", "EditorStyles")); + help_menu->add_theme_style_override("hover", gui_base->get_theme_stylebox(SNAME("MenuHover"), SNAME("EditorStyles"))); left_menu_hb->add_child(help_menu); p = help_menu->get_popup(); p->connect("id_pressed", callable_mp(this, &EditorNode::_menu_option)); #ifdef OSX_ENABLED - p->add_icon_shortcut(gui_base->get_theme_icon("HelpSearch", "EditorIcons"), ED_SHORTCUT("editor/editor_help", TTR("Search Help"), KEY_MASK_ALT | KEY_SPACE), HELP_SEARCH); + p->add_icon_shortcut(gui_base->get_theme_icon(SNAME("HelpSearch"), SNAME("EditorIcons")), ED_SHORTCUT("editor/editor_help", TTR("Search Help"), KEY_MASK_ALT | KEY_SPACE), HELP_SEARCH); #else - p->add_icon_shortcut(gui_base->get_theme_icon("HelpSearch", "EditorIcons"), ED_SHORTCUT("editor/editor_help", TTR("Search Help"), KEY_F1), HELP_SEARCH); + p->add_icon_shortcut(gui_base->get_theme_icon(SNAME("HelpSearch"), SNAME("EditorIcons")), ED_SHORTCUT("editor/editor_help", TTR("Search Help"), KEY_F1), HELP_SEARCH); #endif p->add_separator(); - p->add_icon_shortcut(gui_base->get_theme_icon("Instance", "EditorIcons"), ED_SHORTCUT("editor/online_docs", TTR("Online Documentation")), HELP_DOCS); - p->add_icon_shortcut(gui_base->get_theme_icon("Instance", "EditorIcons"), ED_SHORTCUT("editor/q&a", TTR("Questions & Answers")), HELP_QA); - p->add_icon_shortcut(gui_base->get_theme_icon("Instance", "EditorIcons"), ED_SHORTCUT("editor/report_a_bug", TTR("Report a Bug")), HELP_REPORT_A_BUG); - p->add_icon_shortcut(gui_base->get_theme_icon("Instance", "EditorIcons"), ED_SHORTCUT("editor/suggest_a_feature", TTR("Suggest a Feature")), HELP_SUGGEST_A_FEATURE); - p->add_icon_shortcut(gui_base->get_theme_icon("Instance", "EditorIcons"), ED_SHORTCUT("editor/send_docs_feedback", TTR("Send Docs Feedback")), HELP_SEND_DOCS_FEEDBACK); - p->add_icon_shortcut(gui_base->get_theme_icon("Instance", "EditorIcons"), ED_SHORTCUT("editor/community", TTR("Community")), HELP_COMMUNITY); + p->add_icon_shortcut(gui_base->get_theme_icon(SNAME("Instance"), SNAME("EditorIcons")), ED_SHORTCUT("editor/online_docs", TTR("Online Documentation")), HELP_DOCS); + p->add_icon_shortcut(gui_base->get_theme_icon(SNAME("Instance"), SNAME("EditorIcons")), ED_SHORTCUT("editor/q&a", TTR("Questions & Answers")), HELP_QA); + p->add_icon_shortcut(gui_base->get_theme_icon(SNAME("Instance"), SNAME("EditorIcons")), ED_SHORTCUT("editor/report_a_bug", TTR("Report a Bug")), HELP_REPORT_A_BUG); + p->add_icon_shortcut(gui_base->get_theme_icon(SNAME("Instance"), SNAME("EditorIcons")), ED_SHORTCUT("editor/suggest_a_feature", TTR("Suggest a Feature")), HELP_SUGGEST_A_FEATURE); + p->add_icon_shortcut(gui_base->get_theme_icon(SNAME("Instance"), SNAME("EditorIcons")), ED_SHORTCUT("editor/send_docs_feedback", TTR("Send Docs Feedback")), HELP_SEND_DOCS_FEEDBACK); + p->add_icon_shortcut(gui_base->get_theme_icon(SNAME("Instance"), SNAME("EditorIcons")), ED_SHORTCUT("editor/community", TTR("Community")), HELP_COMMUNITY); p->add_separator(); - p->add_icon_shortcut(gui_base->get_theme_icon("Godot", "EditorIcons"), ED_SHORTCUT("editor/about", TTR("About Godot")), HELP_ABOUT); - p->add_icon_shortcut(gui_base->get_theme_icon("Heart", "EditorIcons"), ED_SHORTCUT("editor/support_development", TTR("Support Godot Development")), HELP_SUPPORT_GODOT_DEVELOPMENT); + p->add_icon_shortcut(gui_base->get_theme_icon(SNAME("Godot"), SNAME("EditorIcons")), ED_SHORTCUT("editor/about", TTR("About Godot")), HELP_ABOUT); + p->add_icon_shortcut(gui_base->get_theme_icon(SNAME("Heart"), SNAME("EditorIcons")), ED_SHORTCUT("editor/support_development", TTR("Support Godot Development")), HELP_SUPPORT_GODOT_DEVELOPMENT); HBoxContainer *play_hb = memnew(HBoxContainer); menu_hb->add_child(play_hb); @@ -6402,7 +6390,7 @@ EditorNode::EditorNode() { play_button->set_flat(true); play_hb->add_child(play_button); play_button->set_toggle_mode(true); - play_button->set_icon(gui_base->get_theme_icon("MainPlay", "EditorIcons")); + play_button->set_icon(gui_base->get_theme_icon(SNAME("MainPlay"), SNAME("EditorIcons"))); play_button->set_focus_mode(Control::FOCUS_NONE); play_button->connect("pressed", callable_mp(this, &EditorNode::_menu_option), make_binds(RUN_PLAY)); play_button->set_tooltip(TTR("Play the project.")); @@ -6415,7 +6403,7 @@ EditorNode::EditorNode() { pause_button = memnew(Button); pause_button->set_flat(true); pause_button->set_toggle_mode(true); - pause_button->set_icon(gui_base->get_theme_icon("Pause", "EditorIcons")); + pause_button->set_icon(gui_base->get_theme_icon(SNAME("Pause"), SNAME("EditorIcons"))); pause_button->set_focus_mode(Control::FOCUS_NONE); pause_button->set_tooltip(TTR("Pause the scene execution for debugging.")); pause_button->set_disabled(true); @@ -6430,7 +6418,7 @@ EditorNode::EditorNode() { stop_button->set_flat(true); play_hb->add_child(stop_button); stop_button->set_focus_mode(Control::FOCUS_NONE); - stop_button->set_icon(gui_base->get_theme_icon("Stop", "EditorIcons")); + stop_button->set_icon(gui_base->get_theme_icon(SNAME("Stop"), SNAME("EditorIcons"))); stop_button->connect("pressed", callable_mp(this, &EditorNode::_menu_option), make_binds(RUN_STOP)); stop_button->set_tooltip(TTR("Stop the scene.")); stop_button->set_disabled(true); @@ -6449,7 +6437,7 @@ EditorNode::EditorNode() { play_hb->add_child(play_scene_button); play_scene_button->set_toggle_mode(true); play_scene_button->set_focus_mode(Control::FOCUS_NONE); - play_scene_button->set_icon(gui_base->get_theme_icon("PlayScene", "EditorIcons")); + play_scene_button->set_icon(gui_base->get_theme_icon(SNAME("PlayScene"), SNAME("EditorIcons"))); play_scene_button->connect("pressed", callable_mp(this, &EditorNode::_menu_option), make_binds(RUN_PLAY_SCENE)); play_scene_button->set_tooltip(TTR("Play the edited scene.")); #ifdef OSX_ENABLED @@ -6463,7 +6451,7 @@ EditorNode::EditorNode() { play_hb->add_child(play_custom_scene_button); play_custom_scene_button->set_toggle_mode(true); play_custom_scene_button->set_focus_mode(Control::FOCUS_NONE); - play_custom_scene_button->set_icon(gui_base->get_theme_icon("PlayCustom", "EditorIcons")); + play_custom_scene_button->set_icon(gui_base->get_theme_icon(SNAME("PlayCustom"), SNAME("EditorIcons"))); play_custom_scene_button->connect("pressed", callable_mp(this, &EditorNode::_menu_option), make_binds(RUN_PLAY_CUSTOM_SCENE)); play_custom_scene_button->set_tooltip(TTR("Play custom scene")); #ifdef OSX_ENABLED @@ -6479,8 +6467,8 @@ EditorNode::EditorNode() { video_driver = memnew(OptionButton); video_driver->set_focus_mode(Control::FOCUS_NONE); video_driver->connect("item_selected", callable_mp(this, &EditorNode::_video_driver_selected)); - video_driver->add_theme_font_override("font", gui_base->get_theme_font("bold", "EditorFonts")); - video_driver->add_theme_font_size_override("font_size", gui_base->get_theme_font_size("bold_size", "EditorFonts")); + video_driver->add_theme_font_override("font", gui_base->get_theme_font(SNAME("bold"), SNAME("EditorFonts"))); + video_driver->add_theme_font_size_override("font_size", gui_base->get_theme_font_size(SNAME("bold_size"), SNAME("EditorFonts"))); // TODO: Show again when OpenGL is ported. video_driver->set_visible(false); right_menu_hb->add_child(video_driver); @@ -6522,7 +6510,7 @@ EditorNode::EditorNode() { update_spinner = memnew(MenuButton); update_spinner->set_tooltip(TTR("Spins when the editor window redraws.")); right_menu_hb->add_child(update_spinner); - update_spinner->set_icon(gui_base->get_theme_icon("Progress1", "EditorIcons")); + update_spinner->set_icon(gui_base->get_theme_icon(SNAME("Progress1"), SNAME("EditorIcons"))); update_spinner->get_popup()->connect("id_pressed", callable_mp(this, &EditorNode::_menu_option)); p = update_spinner->get_popup(); p->add_radio_check_item(TTR("Update Continuously"), SETTINGS_UPDATE_CONTINUOUSLY); @@ -6599,7 +6587,7 @@ EditorNode::EditorNode() { // Bottom panels bottom_panel = memnew(PanelContainer); - bottom_panel->add_theme_style_override("panel", gui_base->get_theme_stylebox("panel", "TabContainer")); + bottom_panel->add_theme_style_override("panel", gui_base->get_theme_stylebox(SNAME("panel"), SNAME("TabContainer"))); center_split->add_child(bottom_panel); center_split->set_dragger_visibility(SplitContainer::DRAGGER_HIDDEN); @@ -6642,7 +6630,7 @@ EditorNode::EditorNode() { bottom_panel_raise = memnew(Button); bottom_panel_raise->set_flat(true); - bottom_panel_raise->set_icon(gui_base->get_theme_icon("ExpandBottomDock", "EditorIcons")); + bottom_panel_raise->set_icon(gui_base->get_theme_icon(SNAME("ExpandBottomDock"), SNAME("EditorIcons"))); bottom_panel_raise->set_shortcut(ED_SHORTCUT("editor/bottom_panel_expand", TTR("Expand Bottom Panel"), KEY_MASK_SHIFT | KEY_F12)); @@ -6678,9 +6666,18 @@ EditorNode::EditorNode() { custom_build_manage_templates = memnew(ConfirmationDialog); custom_build_manage_templates->set_text(TTR("Android build template is missing, please install relevant templates.")); custom_build_manage_templates->get_ok_button()->set_text(TTR("Manage Templates")); + custom_build_manage_templates->add_button(TTR("Install from file"))->connect("pressed", callable_mp(this, &EditorNode::_menu_option), varray(SETTINGS_INSTALL_ANDROID_BUILD_TEMPLATE)); custom_build_manage_templates->connect("confirmed", callable_mp(this, &EditorNode::_menu_option), varray(SETTINGS_MANAGE_EXPORT_TEMPLATES)); gui_base->add_child(custom_build_manage_templates); + file_android_build_source = memnew(EditorFileDialog); + file_android_build_source->set_title(TTR("Select android sources file")); + file_android_build_source->set_access(EditorFileDialog::ACCESS_FILESYSTEM); + file_android_build_source->set_file_mode(EditorFileDialog::FILE_MODE_OPEN_FILE); + file_android_build_source->add_filter("*.zip"); + file_android_build_source->connect("file_selected", callable_mp(this, &EditorNode::_android_build_source_selected)); + gui_base->add_child(file_android_build_source); + install_android_build_template = memnew(ConfirmationDialog); install_android_build_template->set_text(TTR("This will set up your project for custom Android builds by installing the source template to \"res://android/build\".\nYou can then apply modifications and build your own custom APK on export (adding modules, changing the AndroidManifest.xml, etc.).\nNote that in order to make custom builds instead of using pre-built APKs, the \"Use Custom Build\" option should be enabled in the Android export preset.")); install_android_build_template->get_ok_button()->set_text(TTR("Install")); @@ -6722,8 +6719,8 @@ EditorNode::EditorNode() { file_script->set_file_mode(EditorFileDialog::FILE_MODE_OPEN_FILE); List<String> sexts; ResourceLoader::get_recognized_extensions_for_type("Script", &sexts); - for (List<String>::Element *E = sexts.front(); E; E = E->next()) { - file_script->add_filter("*." + E->get()); + for (const String &E : sexts) { + file_script->add_filter("*." + E); } gui_base->add_child(file_script); file_script->connect("file_selected", callable_mp(this, &EditorNode::_dialog_action)); @@ -6841,6 +6838,7 @@ EditorNode::EditorNode() { add_editor_plugin(memnew(MaterialEditorPlugin(this))); add_editor_plugin(memnew(GPUParticlesCollisionSDFEditorPlugin(this))); add_editor_plugin(memnew(InputEventEditorPlugin(this))); + add_editor_plugin(memnew(SubViewportPreviewEditorPlugin(this))); for (int i = 0; i < EditorPlugins::get_plugin_count(); i++) { add_editor_plugin(EditorPlugins::create(i, this)); diff --git a/editor/editor_node.h b/editor/editor_node.h index 07bed6999b..6b91856a59 100644 --- a/editor/editor_node.h +++ b/editor/editor_node.h @@ -181,6 +181,7 @@ private: SETTINGS_EDITOR_CONFIG_FOLDER, SETTINGS_MANAGE_EXPORT_TEMPLATES, SETTINGS_MANAGE_FEATURE_PROFILES, + SETTINGS_INSTALL_ANDROID_BUILD_TEMPLATE, SETTINGS_PICK_MAIN_SCENE, SETTINGS_TOGGLE_CONSOLE, SETTINGS_TOGGLE_FULLSCREEN, @@ -327,6 +328,7 @@ private: EditorFileDialog *file_templates; EditorFileDialog *file_export_lib; EditorFileDialog *file_script; + EditorFileDialog *file_android_build_source; CheckBox *file_export_lib_merge; String current_path; MenuButton *update_spinner; @@ -455,6 +457,8 @@ private: void _menu_confirm_current(); void _menu_option_confirm(int p_option, bool p_confirmed); + void _android_build_source_selected(const String &p_file); + void _request_screenshot(); void _screenshot(bool p_use_utc = false); void _save_screenshot(NodePath p_path); diff --git a/editor/editor_path.cpp b/editor/editor_path.cpp index 63281ae1aa..f3b3eedccc 100644 --- a/editor/editor_path.cpp +++ b/editor/editor_path.cpp @@ -40,15 +40,15 @@ void EditorPath::_add_children_to_popup(Object *p_obj, int p_depth) { List<PropertyInfo> pinfo; p_obj->get_property_list(&pinfo); - for (List<PropertyInfo>::Element *E = pinfo.front(); E; E = E->next()) { - if (!(E->get().usage & PROPERTY_USAGE_EDITOR)) { + for (const PropertyInfo &E : pinfo) { + if (!(E.usage & PROPERTY_USAGE_EDITOR)) { continue; } - if (E->get().hint != PROPERTY_HINT_RESOURCE_TYPE) { + if (E.hint != PROPERTY_HINT_RESOURCE_TYPE) { continue; } - Variant value = p_obj->get(E->get().name); + Variant value = p_obj->get(E.name); if (value.get_type() != Variant::OBJECT) { continue; } @@ -60,7 +60,7 @@ void EditorPath::_add_children_to_popup(Object *p_obj, int p_depth) { Ref<Texture2D> icon = EditorNode::get_singleton()->get_object_icon(obj); String proper_name = ""; - Vector<String> name_parts = E->get().name.split("/"); + Vector<String> name_parts = E.name.split("/"); for (int i = 0; i < name_parts.size(); i++) { if (i > 0) { @@ -180,8 +180,8 @@ void EditorPath::_notification(int p_what) { case NOTIFICATION_THEME_CHANGED: { update_path(); - sub_objects_icon->set_texture(get_theme_icon("select_arrow", "Tree")); - current_object_label->add_theme_font_override("font", get_theme_font("main", "EditorFonts")); + sub_objects_icon->set_texture(get_theme_icon(SNAME("select_arrow"), SNAME("Tree"))); + current_object_label->add_theme_font_override("font", get_theme_font(SNAME("main"), SNAME("EditorFonts"))); } break; case NOTIFICATION_READY: { diff --git a/editor/editor_plugin.cpp b/editor/editor_plugin.cpp index 63de06d5e2..07e9357e67 100644 --- a/editor/editor_plugin.cpp +++ b/editor/editor_plugin.cpp @@ -532,7 +532,7 @@ void EditorPlugin::set_force_draw_over_forwarding_enabled() { } void EditorPlugin::notify_scene_changed(const Node *scn_root) { - emit_signal("scene_changed", scn_root); + emit_signal(SNAME("scene_changed"), scn_root); } void EditorPlugin::notify_main_screen_changed(const String &screen_name) { @@ -540,16 +540,16 @@ void EditorPlugin::notify_main_screen_changed(const String &screen_name) { return; } - emit_signal("main_screen_changed", screen_name); + emit_signal(SNAME("main_screen_changed"), screen_name); last_main_screen_name = screen_name; } void EditorPlugin::notify_scene_closed(const String &scene_filepath) { - emit_signal("scene_closed", scene_filepath); + emit_signal(SNAME("scene_closed"), scene_filepath); } void EditorPlugin::notify_resource_saved(const Ref<Resource> &p_resource) { - emit_signal("resource_saved", p_resource); + emit_signal(SNAME("resource_saved"), p_resource); } bool EditorPlugin::forward_canvas_gui_input(const Ref<InputEvent> &p_event) { @@ -729,13 +729,13 @@ void EditorPlugin::remove_translation_parser_plugin(const Ref<EditorTranslationP void EditorPlugin::add_import_plugin(const Ref<EditorImportPlugin> &p_importer) { ERR_FAIL_COND(!p_importer.is_valid()); ResourceFormatImporter::get_singleton()->add_importer(p_importer); - EditorFileSystem::get_singleton()->call_deferred("scan"); + EditorFileSystem::get_singleton()->call_deferred(SNAME("scan")); } void EditorPlugin::remove_import_plugin(const Ref<EditorImportPlugin> &p_importer) { ERR_FAIL_COND(!p_importer.is_valid()); ResourceFormatImporter::get_singleton()->remove_importer(p_importer); - EditorFileSystem::get_singleton()->call_deferred("scan"); + EditorFileSystem::get_singleton()->call_deferred(SNAME("scan")); } void EditorPlugin::add_export_plugin(const Ref<EditorExportPlugin> &p_exporter) { @@ -854,7 +854,7 @@ void EditorPlugin::remove_debugger_plugin(const Ref<Script> &p_script) { } void EditorPlugin::_editor_project_settings_changed() { - emit_signal("project_settings_changed"); + emit_signal(SNAME("project_settings_changed")); } void EditorPlugin::_notification(int p_what) { if (p_what == NOTIFICATION_ENTER_TREE) { diff --git a/editor/editor_plugin_settings.cpp b/editor/editor_plugin_settings.cpp index a16a2f327e..aa313f0c50 100644 --- a/editor/editor_plugin_settings.cpp +++ b/editor/editor_plugin_settings.cpp @@ -108,7 +108,7 @@ void EditorPluginSettings::update_plugins() { bool is_active = EditorNode::get_singleton()->is_addon_plugin_enabled(path); item->set_checked(3, is_active); item->set_editable(3, true); - item->add_button(4, get_theme_icon("Edit", "EditorIcons"), BUTTON_PLUGIN_EDIT, false, TTR("Edit Plugin")); + item->add_button(4, get_theme_icon(SNAME("Edit"), SNAME("EditorIcons")), BUTTON_PLUGIN_EDIT, false, TTR("Edit Plugin")); } } } @@ -208,11 +208,11 @@ EditorPluginSettings::EditorPluginSettings() { plugin_list->set_v_size_flags(SIZE_EXPAND_FILL); plugin_list->set_columns(5); plugin_list->set_column_titles_visible(true); - plugin_list->set_column_title(0, TTR("Name:")); - plugin_list->set_column_title(1, TTR("Version:")); - plugin_list->set_column_title(2, TTR("Author:")); - plugin_list->set_column_title(3, TTR("Status:")); - plugin_list->set_column_title(4, TTR("Edit:")); + plugin_list->set_column_title(0, TTR("Name")); + plugin_list->set_column_title(1, TTR("Version")); + plugin_list->set_column_title(2, TTR("Author")); + plugin_list->set_column_title(3, TTR("Status")); + plugin_list->set_column_title(4, TTR("Edit")); plugin_list->set_column_expand(0, true); plugin_list->set_column_clip_content(0, true); plugin_list->set_column_expand(1, false); diff --git a/editor/editor_properties.cpp b/editor/editor_properties.cpp index ebd8d6427b..df763d5bf0 100644 --- a/editor/editor_properties.cpp +++ b/editor/editor_properties.cpp @@ -147,10 +147,10 @@ void EditorPropertyMultilineText::_notification(int p_what) { switch (p_what) { case NOTIFICATION_THEME_CHANGED: case NOTIFICATION_ENTER_TREE: { - Ref<Texture2D> df = get_theme_icon("DistractionFree", "EditorIcons"); + Ref<Texture2D> df = get_theme_icon(SNAME("DistractionFree"), SNAME("EditorIcons")); open_big_text->set_icon(df); - Ref<Font> font = get_theme_font("font", "Label"); - int font_size = get_theme_font_size("font_size", "Label"); + Ref<Font> font = get_theme_font(SNAME("font"), SNAME("Label")); + int font_size = get_theme_font_size(SNAME("font_size"), SNAME("Label")); text->set_custom_minimum_size(Vector2(0, font->get_height(font_size) * 6)); } break; @@ -276,9 +276,9 @@ void EditorPropertyTextEnum::_notification(int p_what) { switch (p_what) { case NOTIFICATION_ENTER_TREE: case NOTIFICATION_THEME_CHANGED: - edit_button->set_icon(get_theme_icon("Edit", "EditorIcons")); - accept_button->set_icon(get_theme_icon("ImportCheck", "EditorIcons")); - cancel_button->set_icon(get_theme_icon("ImportFail", "EditorIcons")); + edit_button->set_icon(get_theme_icon(SNAME("Edit"), SNAME("EditorIcons"))); + accept_button->set_icon(get_theme_icon(SNAME("ImportCheck"), SNAME("EditorIcons"))); + cancel_button->set_icon(get_theme_icon(SNAME("ImportFail"), SNAME("EditorIcons"))); break; } } @@ -386,7 +386,7 @@ void EditorPropertyPath::set_save_mode() { void EditorPropertyPath::_notification(int p_what) { if (p_what == NOTIFICATION_ENTER_TREE || p_what == NOTIFICATION_THEME_CHANGED) { - path_edit->set_icon(get_theme_icon("Folder", "EditorIcons")); + path_edit->set_icon(get_theme_icon(SNAME("Folder"), SNAME("EditorIcons"))); } } @@ -699,8 +699,8 @@ public: int hovered_index; virtual Size2 get_minimum_size() const override { - Ref<Font> font = get_theme_font("font", "Label"); - int font_size = get_theme_font_size("font_size", "Label"); + Ref<Font> font = get_theme_font(SNAME("font"), SNAME("Label")); + int font_size = get_theme_font_size(SNAME("font_size"), SNAME("Label")); return Vector2(0, font->get_height(font_size) * 2); } @@ -737,7 +737,7 @@ public: value |= (1 << hovered_index); } - emit_signal("flag_changed", value); + emit_signal(SNAME("flag_changed"), value); update(); } } @@ -753,7 +753,7 @@ public: const int h = bsize * 2 + 1; const int vofs = (rect.size.height - h) / 2; - Color color = get_theme_color("highlight_color", "Editor"); + Color color = get_theme_color(SNAME("highlight_color"), SNAME("Editor")); for (int i = 0; i < 2; i++) { Point2 ofs(4, vofs); if (i == 1) { @@ -957,7 +957,7 @@ EditorPropertyInteger::EditorPropertyInteger() { ///////////////////// OBJECT ID ///////////////////////// void EditorPropertyObjectID::_edit_pressed() { - emit_signal("object_id_selected", get_edited_property(), get_edited_object()->get(get_edited_property())); + emit_signal(SNAME("object_id_selected"), get_edited_property(), get_edited_object()->get(get_edited_property())); } void EditorPropertyObjectID::update_property() { @@ -1112,14 +1112,14 @@ void EditorPropertyEasing::_draw_easing() { const float exp = get_edited_object()->get(get_edited_property()); - const Ref<Font> f = get_theme_font("font", "Label"); - int font_size = get_theme_font_size("font_size", "Label"); - const Color font_color = get_theme_color("font_color", "Label"); + const Ref<Font> f = get_theme_font(SNAME("font"), SNAME("Label")); + int font_size = get_theme_font_size(SNAME("font_size"), SNAME("Label")); + const Color font_color = get_theme_color(SNAME("font_color"), SNAME("Label")); Color line_color; if (dragging) { - line_color = get_theme_color("accent_color", "Editor"); + line_color = get_theme_color(SNAME("accent_color"), SNAME("Editor")); } else { - line_color = get_theme_color("font_color", "Label") * Color(1, 1, 1, 0.9); + line_color = get_theme_color(SNAME("font_color"), SNAME("Label")) * Color(1, 1, 1, 0.9); } Vector<Point2> points; @@ -1205,15 +1205,15 @@ void EditorPropertyEasing::_notification(int p_what) { case NOTIFICATION_THEME_CHANGED: case NOTIFICATION_ENTER_TREE: { preset->clear(); - preset->add_icon_item(get_theme_icon("CurveConstant", "EditorIcons"), "Zero", EASING_ZERO); - preset->add_icon_item(get_theme_icon("CurveLinear", "EditorIcons"), "Linear", EASING_LINEAR); - preset->add_icon_item(get_theme_icon("CurveIn", "EditorIcons"), "In", EASING_IN); - preset->add_icon_item(get_theme_icon("CurveOut", "EditorIcons"), "Out", EASING_OUT); + preset->add_icon_item(get_theme_icon(SNAME("CurveConstant"), SNAME("EditorIcons")), "Zero", EASING_ZERO); + preset->add_icon_item(get_theme_icon(SNAME("CurveLinear"), SNAME("EditorIcons")), "Linear", EASING_LINEAR); + preset->add_icon_item(get_theme_icon(SNAME("CurveIn"), SNAME("EditorIcons")), "In", EASING_IN); + preset->add_icon_item(get_theme_icon(SNAME("CurveOut"), SNAME("EditorIcons")), "Out", EASING_OUT); if (full) { - preset->add_icon_item(get_theme_icon("CurveInOut", "EditorIcons"), "In-Out", EASING_IN_OUT); - preset->add_icon_item(get_theme_icon("CurveOutIn", "EditorIcons"), "Out-In", EASING_OUT_IN); + preset->add_icon_item(get_theme_icon(SNAME("CurveInOut"), SNAME("EditorIcons")), "In-Out", EASING_IN_OUT); + preset->add_icon_item(get_theme_icon(SNAME("CurveOutIn"), SNAME("EditorIcons")), "Out-In", EASING_OUT_IN); } - easing_draw->set_custom_minimum_size(Size2(0, get_theme_font("font", "Label")->get_height(get_theme_font_size("font_size", "Label")) * 2)); + easing_draw->set_custom_minimum_size(Size2(0, get_theme_font(SNAME("font"), SNAME("Label"))->get_height(get_theme_font_size(SNAME("font_size"), SNAME("Label"))) * 2)); } break; } } @@ -1273,7 +1273,7 @@ void EditorPropertyVector2::update_property() { void EditorPropertyVector2::_notification(int p_what) { if (p_what == NOTIFICATION_ENTER_TREE || p_what == NOTIFICATION_THEME_CHANGED) { - Color base = get_theme_color("accent_color", "Editor"); + Color base = get_theme_color(SNAME("accent_color"), SNAME("Editor")); for (int i = 0; i < 2; i++) { Color c = base; c.set_hsv(float(i) / 3.0 + 0.05, c.get_s() * 0.75, c.get_v()); @@ -1360,7 +1360,7 @@ void EditorPropertyRect2::update_property() { void EditorPropertyRect2::_notification(int p_what) { if (p_what == NOTIFICATION_ENTER_TREE || p_what == NOTIFICATION_THEME_CHANGED) { - Color base = get_theme_color("accent_color", "Editor"); + Color base = get_theme_color(SNAME("accent_color"), SNAME("Editor")); for (int i = 0; i < 4; i++) { Color c = base; c.set_hsv(float(i % 2) / 3.0 + 0.05, c.get_s() * 0.75, c.get_v()); @@ -1482,7 +1482,7 @@ Vector3 EditorPropertyVector3::get_vector() { void EditorPropertyVector3::_notification(int p_what) { if (p_what == NOTIFICATION_ENTER_TREE || p_what == NOTIFICATION_THEME_CHANGED) { - Color base = get_theme_color("accent_color", "Editor"); + Color base = get_theme_color(SNAME("accent_color"), SNAME("Editor")); for (int i = 0; i < 3; i++) { Color c = base; c.set_hsv(float(i) / 3.0 + 0.05, c.get_s() * 0.75, c.get_v()); @@ -1565,7 +1565,7 @@ void EditorPropertyVector2i::update_property() { void EditorPropertyVector2i::_notification(int p_what) { if (p_what == NOTIFICATION_ENTER_TREE || p_what == NOTIFICATION_THEME_CHANGED) { - Color base = get_theme_color("accent_color", "Editor"); + Color base = get_theme_color(SNAME("accent_color"), SNAME("Editor")); for (int i = 0; i < 2; i++) { Color c = base; c.set_hsv(float(i) / 3.0 + 0.05, c.get_s() * 0.75, c.get_v()); @@ -1652,7 +1652,7 @@ void EditorPropertyRect2i::update_property() { void EditorPropertyRect2i::_notification(int p_what) { if (p_what == NOTIFICATION_ENTER_TREE || p_what == NOTIFICATION_THEME_CHANGED) { - Color base = get_theme_color("accent_color", "Editor"); + Color base = get_theme_color(SNAME("accent_color"), SNAME("Editor")); for (int i = 0; i < 4; i++) { Color c = base; c.set_hsv(float(i % 2) / 3.0 + 0.05, c.get_s() * 0.75, c.get_v()); @@ -1747,7 +1747,7 @@ void EditorPropertyVector3i::update_property() { void EditorPropertyVector3i::_notification(int p_what) { if (p_what == NOTIFICATION_ENTER_TREE || p_what == NOTIFICATION_THEME_CHANGED) { - Color base = get_theme_color("accent_color", "Editor"); + Color base = get_theme_color(SNAME("accent_color"), SNAME("Editor")); for (int i = 0; i < 3; i++) { Color c = base; c.set_hsv(float(i) / 3.0 + 0.05, c.get_s() * 0.75, c.get_v()); @@ -1833,7 +1833,7 @@ void EditorPropertyPlane::update_property() { void EditorPropertyPlane::_notification(int p_what) { if (p_what == NOTIFICATION_ENTER_TREE || p_what == NOTIFICATION_THEME_CHANGED) { - Color base = get_theme_color("accent_color", "Editor"); + Color base = get_theme_color(SNAME("accent_color"), SNAME("Editor")); for (int i = 0; i < 3; i++) { Color c = base; c.set_hsv(float(i) / 3.0 + 0.05, c.get_s() * 0.75, c.get_v()); @@ -1920,7 +1920,7 @@ void EditorPropertyQuaternion::update_property() { void EditorPropertyQuaternion::_notification(int p_what) { if (p_what == NOTIFICATION_ENTER_TREE || p_what == NOTIFICATION_THEME_CHANGED) { - Color base = get_theme_color("accent_color", "Editor"); + Color base = get_theme_color(SNAME("accent_color"), SNAME("Editor")); for (int i = 0; i < 3; i++) { Color c = base; c.set_hsv(float(i) / 3.0 + 0.05, c.get_s() * 0.75, c.get_v()); @@ -2010,7 +2010,7 @@ void EditorPropertyAABB::update_property() { void EditorPropertyAABB::_notification(int p_what) { if (p_what == NOTIFICATION_ENTER_TREE || p_what == NOTIFICATION_THEME_CHANGED) { - Color base = get_theme_color("accent_color", "Editor"); + Color base = get_theme_color(SNAME("accent_color"), SNAME("Editor")); for (int i = 0; i < 6; i++) { Color c = base; c.set_hsv(float(i % 3) / 3.0 + 0.05, c.get_s() * 0.75, c.get_v()); @@ -2087,7 +2087,7 @@ void EditorPropertyTransform2D::update_property() { void EditorPropertyTransform2D::_notification(int p_what) { if (p_what == NOTIFICATION_ENTER_TREE || p_what == NOTIFICATION_THEME_CHANGED) { - Color base = get_theme_color("accent_color", "Editor"); + Color base = get_theme_color(SNAME("accent_color"), SNAME("Editor")); for (int i = 0; i < 6; i++) { Color c = base; c.set_hsv(float(i % 2) / 3.0 + 0.05, c.get_s() * 0.75, c.get_v()); @@ -2169,7 +2169,7 @@ void EditorPropertyBasis::update_property() { void EditorPropertyBasis::_notification(int p_what) { if (p_what == NOTIFICATION_ENTER_TREE || p_what == NOTIFICATION_THEME_CHANGED) { - Color base = get_theme_color("accent_color", "Editor"); + Color base = get_theme_color(SNAME("accent_color"), SNAME("Editor")); for (int i = 0; i < 9; i++) { Color c = base; c.set_hsv(float(i % 3) / 3.0 + 0.05, c.get_s() * 0.75, c.get_v()); @@ -2259,7 +2259,7 @@ void EditorPropertyTransform3D::update_using_transform(Transform3D p_transform) void EditorPropertyTransform3D::_notification(int p_what) { if (p_what == NOTIFICATION_ENTER_TREE || p_what == NOTIFICATION_THEME_CHANGED) { - Color base = get_theme_color("accent_color", "Editor"); + Color base = get_theme_color(SNAME("accent_color"), SNAME("Editor")); for (int i = 0; i < 12; i++) { Color c = base; c.set_hsv(float(i % 3) / 3.0 + 0.05, c.get_s() * 0.75, c.get_v()); @@ -2475,7 +2475,7 @@ void EditorPropertyNodePath::setup(const NodePath &p_base_hint, Vector<StringNam void EditorPropertyNodePath::_notification(int p_what) { if (p_what == NOTIFICATION_ENTER_TREE || p_what == NOTIFICATION_THEME_CHANGED) { - Ref<Texture2D> t = get_theme_icon("Clear", "EditorIcons"); + Ref<Texture2D> t = get_theme_icon(SNAME("Clear"), SNAME("EditorIcons")); clear->set_icon(t); } } @@ -2527,7 +2527,7 @@ void EditorPropertyResource::_resource_selected(const RES &p_resource) { get_edited_object()->editor_set_section_unfold(get_edited_property(), unfold); update_property(); } else { - emit_signal("resource_selected", get_edited_property(), p_resource); + emit_signal(SNAME("resource_selected"), get_edited_property(), p_resource); } } @@ -2580,22 +2580,22 @@ void EditorPropertyResource::_resource_changed(const RES &p_resource) { } void EditorPropertyResource::_sub_inspector_property_keyed(const String &p_property, const Variant &p_value, bool) { - emit_signal("property_keyed_with_value", String(get_edited_property()) + ":" + p_property, p_value, false); + emit_signal(SNAME("property_keyed_with_value"), String(get_edited_property()) + ":" + p_property, p_value, false); } void EditorPropertyResource::_sub_inspector_resource_selected(const RES &p_resource, const String &p_property) { - emit_signal("resource_selected", String(get_edited_property()) + ":" + p_property, p_resource); + emit_signal(SNAME("resource_selected"), String(get_edited_property()) + ":" + p_property, p_resource); } void EditorPropertyResource::_sub_inspector_object_id_selected(int p_id) { - emit_signal("object_id_selected", get_edited_property(), p_id); + emit_signal(SNAME("object_id_selected"), get_edited_property(), p_id); } void EditorPropertyResource::_open_editor_pressed() { RES res = get_edited_object()->get(get_edited_property()); if (res.is_valid()) { // May clear the editor so do it deferred. - EditorNode::get_singleton()->call_deferred("edit_item_resource", res); + EditorNode::get_singleton()->call_deferred(SNAME("edit_item_resource"), res); } } @@ -2651,18 +2651,18 @@ void EditorPropertyResource::_update_property_bg() { } count_subinspectors = MIN(15, count_subinspectors); - add_theme_color_override("property_color", get_theme_color("sub_inspector_property_color", "Editor")); + add_theme_color_override("property_color", get_theme_color(SNAME("sub_inspector_property_color"), SNAME("Editor"))); add_theme_style_override("bg_selected", get_theme_stylebox("sub_inspector_property_bg_selected" + itos(count_subinspectors), "Editor")); add_theme_style_override("bg", get_theme_stylebox("sub_inspector_property_bg" + itos(count_subinspectors), "Editor")); - add_theme_constant_override("font_offset", get_theme_constant("sub_inspector_font_offset", "Editor")); + add_theme_constant_override("font_offset", get_theme_constant(SNAME("sub_inspector_font_offset"), SNAME("Editor"))); add_theme_constant_override("vseparation", 0); } else { - add_theme_color_override("property_color", get_theme_color("property_color", "EditorProperty")); - add_theme_style_override("bg_selected", get_theme_stylebox("bg_selected", "EditorProperty")); - add_theme_style_override("bg", get_theme_stylebox("bg", "EditorProperty")); - add_theme_constant_override("vseparation", get_theme_constant("vseparation", "EditorProperty")); - add_theme_constant_override("font_offset", get_theme_constant("font_offset", "EditorProperty")); + add_theme_color_override("property_color", get_theme_color(SNAME("property_color"), SNAME("EditorProperty"))); + add_theme_style_override("bg_selected", get_theme_stylebox(SNAME("bg_selected"), SNAME("EditorProperty"))); + add_theme_style_override("bg", get_theme_stylebox(SNAME("bg"), SNAME("EditorProperty"))); + add_theme_constant_override("vseparation", get_theme_constant(SNAME("vseparation"), SNAME("EditorProperty"))); + add_theme_constant_override("font_offset", get_theme_constant(SNAME("font_offset"), SNAME("EditorProperty"))); } updating_theme = false; @@ -2760,7 +2760,7 @@ void EditorPropertyResource::update_property() { // Open editor directly and hide other such editors which are currently open. _open_editor_pressed(); if (is_inside_tree()) { - get_tree()->call_deferred("call_group", "_editor_resource_properties", "_fold_other_editors", this); + get_tree()->call_deferred(SNAME("call_group"), "_editor_resource_properties", "_fold_other_editors", this); } opened_editor = true; } diff --git a/editor/editor_properties_array_dict.cpp b/editor/editor_properties_array_dict.cpp index 3216728be1..596f515067 100644 --- a/editor/editor_properties_array_dict.cpp +++ b/editor/editor_properties_array_dict.cpp @@ -30,16 +30,18 @@ #include "editor_properties_array_dict.h" +#include "core/input/input.h" #include "core/io/marshalls.h" +#include "editor/editor_node.h" #include "editor/editor_scale.h" #include "editor_properties.h" bool EditorPropertyArrayObject::_set(const StringName &p_name, const Variant &p_value) { - String pn = p_name; + String name = p_name; - if (pn.begins_with("indices")) { - int idx = pn.get_slicec('/', 1).to_int(); - array.set(idx, p_value); + if (name.begins_with("indices")) { + int index = name.get_slicec('/', 1).to_int(); + array.set(index, p_value); return true; } @@ -47,12 +49,12 @@ bool EditorPropertyArrayObject::_set(const StringName &p_name, const Variant &p_ } bool EditorPropertyArrayObject::_get(const StringName &p_name, Variant &r_ret) const { - String pn = p_name; + String name = p_name; - if (pn.begins_with("indices")) { - int idx = pn.get_slicec('/', 1).to_int(); + if (name.begins_with("indices")) { + int index = name.get_slicec('/', 1).to_int(); bool valid; - r_ret = array.get(idx, &valid); + r_ret = array.get(index, &valid); if (r_ret.get_type() == Variant::OBJECT && Object::cast_to<EncodedObjectAsID>(r_ret)) { r_ret = Object::cast_to<EncodedObjectAsID>(r_ret)->get_object_id(); } @@ -77,21 +79,21 @@ EditorPropertyArrayObject::EditorPropertyArrayObject() { /////////////////// bool EditorPropertyDictionaryObject::_set(const StringName &p_name, const Variant &p_value) { - String pn = p_name; + String name = p_name; - if (pn == "new_item_key") { + if (name == "new_item_key") { new_item_key = p_value; return true; } - if (pn == "new_item_value") { + if (name == "new_item_value") { new_item_value = p_value; return true; } - if (pn.begins_with("indices")) { - int idx = pn.get_slicec('/', 1).to_int(); - Variant key = dict.get_key_at_index(idx); + if (name.begins_with("indices")) { + int index = name.get_slicec('/', 1).to_int(); + Variant key = dict.get_key_at_index(index); dict[key] = p_value; return true; } @@ -100,21 +102,21 @@ bool EditorPropertyDictionaryObject::_set(const StringName &p_name, const Varian } bool EditorPropertyDictionaryObject::_get(const StringName &p_name, Variant &r_ret) const { - String pn = p_name; + String name = p_name; - if (pn == "new_item_key") { + if (name == "new_item_key") { r_ret = new_item_key; return true; } - if (pn == "new_item_value") { + if (name == "new_item_value") { r_ret = new_item_value; return true; } - if (pn.begins_with("indices")) { - int idx = pn.get_slicec('/', 1).to_int(); - Variant key = dict.get_key_at_index(idx); + if (name.begins_with("indices")) { + int index = name.get_slicec('/', 1).to_int(); + Variant key = dict.get_key_at_index(index); r_ret = dict[key]; if (r_ret.get_type() == Variant::OBJECT && Object::cast_to<EncodedObjectAsID>(r_ret)) { r_ret = Object::cast_to<EncodedObjectAsID>(r_ret)->get_object_id(); @@ -157,13 +159,13 @@ EditorPropertyDictionaryObject::EditorPropertyDictionaryObject() { void EditorPropertyArray::_property_changed(const String &p_property, Variant p_value, const String &p_name, bool p_changing) { if (p_property.begins_with("indices")) { - int idx = p_property.get_slice("/", 1).to_int(); + int index = p_property.get_slice("/", 1).to_int(); Variant array = object->get_array(); - array.set(idx, p_value); + array.set(index, p_value); emit_changed(get_edited_property(), array, "", true); if (array.get_type() == Variant::ARRAY) { - array = array.call("duplicate"); //dupe, so undo/redo works better + array = array.call("duplicate"); // Duplicate, so undo/redo works better. } object->set_array(array); } @@ -171,7 +173,7 @@ void EditorPropertyArray::_property_changed(const String &p_property, Variant p_ void EditorPropertyArray::_change_type(Object *p_button, int p_index) { Button *button = Object::cast_to<Button>(p_button); - changing_type_idx = p_index; + changing_type_index = p_index; Rect2 rect = button->get_screen_rect(); change_type->set_as_minsize(); change_type->set_position(rect.position + rect.size - Vector2(change_type->get_contents_minimum_size().x, 0)); @@ -180,7 +182,7 @@ void EditorPropertyArray::_change_type(Object *p_button, int p_index) { void EditorPropertyArray::_change_type_menu(int p_index) { if (p_index == Variant::VARIANT_MAX) { - _remove_pressed(changing_type_idx); + _remove_pressed(changing_type_index); return; } @@ -188,12 +190,12 @@ void EditorPropertyArray::_change_type_menu(int p_index) { Callable::CallError ce; Variant::construct(Variant::Type(p_index), value, nullptr, 0, ce); Variant array = object->get_array(); - array.set(changing_type_idx, value); + array.set(changing_type_index, value); emit_changed(get_edited_property(), array, "", true); if (array.get_type() == Variant::ARRAY) { - array = array.call("duplicate"); //dupe, so undo/redo works better + array = array.call("duplicate"); // Duplicate, so undo/redo works better. } object->set_array(array); @@ -201,7 +203,7 @@ void EditorPropertyArray::_change_type_menu(int p_index) { } void EditorPropertyArray::_object_id_selected(const StringName &p_property, ObjectID p_id) { - emit_signal("object_id_selected", p_property, p_id); + emit_signal(SNAME("object_id_selected"), p_property, p_id); } void EditorPropertyArray::update_property() { @@ -213,7 +215,7 @@ void EditorPropertyArray::update_property() { arrtype = "Array"; } break; - // arrays + // Arrays. case Variant::PACKED_BYTE_ARRAY: { arrtype = "PackedByteArray"; } break; @@ -256,7 +258,12 @@ void EditorPropertyArray::update_property() { return; } - edit->set_text(arrtype + " (size " + itos(array.call("size")) + ")"); + int size = array.call("size"); + int pages = MAX(0, size - 1) / page_length + 1; + page_index = MIN(page_index, pages - 1); + int offset = page_index * page_length; + + edit->set_text(arrtype + " (size " + itos(size) + ")"); bool unfolded = get_edited_object()->editor_is_section_unfolded(get_edited_property()); if (edit->is_pressed() != unfolded) { @@ -270,50 +277,50 @@ void EditorPropertyArray::update_property() { vbox = memnew(VBoxContainer); add_child(vbox); set_bottom_editor(vbox); - HBoxContainer *hbc = memnew(HBoxContainer); - vbox->add_child(hbc); + + HBoxContainer *hbox = memnew(HBoxContainer); + vbox->add_child(hbox); + Label *label = memnew(Label(TTR("Size: "))); label->set_h_size_flags(SIZE_EXPAND_FILL); - hbc->add_child(label); - length = memnew(EditorSpinSlider); - length->set_step(1); - length->set_max(1000000); - length->set_h_size_flags(SIZE_EXPAND_FILL); - hbc->add_child(length); - length->connect("value_changed", callable_mp(this, &EditorPropertyArray::_length_changed)); - - page_hb = memnew(HBoxContainer); - vbox->add_child(page_hb); - label = memnew(Label(TTR("Page: "))); - label->set_h_size_flags(SIZE_EXPAND_FILL); - page_hb->add_child(label); - page = memnew(EditorSpinSlider); - page->set_step(1); - page_hb->add_child(page); - page->set_h_size_flags(SIZE_EXPAND_FILL); - page->connect("value_changed", callable_mp(this, &EditorPropertyArray::_page_changed)); - } else { - //bye bye children of the box - while (vbox->get_child_count() > 2) { - vbox->get_child(2)->queue_delete(); // button still needed after pressed is called - vbox->remove_child(vbox->get_child(2)); - } - } + hbox->add_child(label); - int len = array.call("size"); + size_slider = memnew(EditorSpinSlider); + size_slider->set_step(1); + size_slider->set_max(1000000); + size_slider->set_h_size_flags(SIZE_EXPAND_FILL); + size_slider->connect("value_changed", callable_mp(this, &EditorPropertyArray::_length_changed)); + hbox->add_child(size_slider); - length->set_value(len); + page_hbox = memnew(HBoxContainer); + vbox->add_child(page_hbox); - int pages = MAX(0, len - 1) / page_len + 1; + label = memnew(Label(TTR("Page: "))); + label->set_h_size_flags(SIZE_EXPAND_FILL); + page_hbox->add_child(label); - page->set_max(pages); - page_idx = MIN(page_idx, pages - 1); - page->set_value(page_idx); - page_hb->set_visible(pages > 1); + page_slider = memnew(EditorSpinSlider); + page_slider->set_step(1); + page_slider->set_h_size_flags(SIZE_EXPAND_FILL); + page_slider->connect("value_changed", callable_mp(this, &EditorPropertyArray::_page_changed)); + page_hbox->add_child(page_slider); + } else { + // Bye bye children of the box. + for (int i = vbox->get_child_count() - 1; i >= 2; i--) { + Node *child = vbox->get_child(i); + if (child == reorder_selected_element_hbox) { + continue; // Don't remove the property that the user is moving. + } - int offset = page_idx * page_len; + child->queue_delete(); // Button still needed after pressed is called. + vbox->remove_child(child); + } + } - int amount = MIN(len - offset, page_len); + size_slider->set_value(size); + page_slider->set_max(pages); + page_slider->set_value(page_index); + page_hbox->set_visible(pages > 1); if (array.get_type() == Variant::ARRAY) { array = array.call("duplicate"); @@ -321,7 +328,31 @@ void EditorPropertyArray::update_property() { object->set_array(array); + int amount = MIN(size - offset, page_length); for (int i = 0; i < amount; i++) { + bool reorder_is_from_current_page = reorder_from_index / page_length == page_index; + if (reorder_is_from_current_page && i == reorder_from_index % page_length) { + // Don't duplicate the property that the user is moving. + continue; + } + if (!reorder_is_from_current_page && i == reorder_to_index % page_length) { + // Don't create the property the moving property will take the place of, + // e.g. (if page_length == 20) don't create element 20 if dragging an item from + // the first page to the second page because element 20 would become element 19. + continue; + } + + HBoxContainer *hbox = memnew(HBoxContainer); + vbox->add_child(hbox); + + Button *reorder_button = memnew(Button); + reorder_button->set_icon(get_theme_icon(SNAME("TripleBar"), SNAME("EditorIcons"))); + reorder_button->set_default_cursor_shape(Control::CURSOR_MOVE); + reorder_button->connect("gui_input", callable_mp(this, &EditorPropertyArray::_reorder_button_gui_input)); + reorder_button->connect("button_down", callable_mp(this, &EditorPropertyArray::_reorder_button_down), varray(i + offset)); + reorder_button->connect("button_up", callable_mp(this, &EditorPropertyArray::_reorder_button_up)); + hbox->add_child(reorder_button); + String prop_name = "indices/" + itos(i + offset); EditorProperty *prop = nullptr; @@ -346,29 +377,29 @@ void EditorPropertyArray::update_property() { prop->connect("property_changed", callable_mp(this, &EditorPropertyArray::_property_changed)); prop->connect("object_id_selected", callable_mp(this, &EditorPropertyArray::_object_id_selected)); prop->set_h_size_flags(SIZE_EXPAND_FILL); - - HBoxContainer *hb = memnew(HBoxContainer); - - vbox->add_child(hb); - hb->add_child(prop); + hbox->add_child(prop); bool is_untyped_array = array.get_type() == Variant::ARRAY && subtype == Variant::NIL; if (is_untyped_array) { Button *edit = memnew(Button); - edit->set_icon(get_theme_icon("Edit", "EditorIcons")); - hb->add_child(edit); + edit->set_icon(get_theme_icon(SNAME("Edit"), SNAME("EditorIcons"))); + hbox->add_child(edit); edit->connect("pressed", callable_mp(this, &EditorPropertyArray::_change_type), varray(edit, i + offset)); } else { Button *remove = memnew(Button); - remove->set_icon(get_theme_icon("Remove", "EditorIcons")); + remove->set_icon(get_theme_icon(SNAME("Remove"), SNAME("EditorIcons"))); remove->connect("pressed", callable_mp(this, &EditorPropertyArray::_remove_pressed), varray(i + offset)); - hb->add_child(remove); + hbox->add_child(remove); } prop->update_property(); } + if (reorder_to_index % page_length > 0) { + vbox->move_child(vbox->get_child(2), reorder_to_index % page_length + 2); + } + updating = false; } else { @@ -384,18 +415,13 @@ void EditorPropertyArray::_remove_pressed(int p_index) { Variant array = object->get_array(); array.call("remove", p_index); - if (array.get_type() == Variant::ARRAY) { - array = array.call("duplicate"); - } - emit_changed(get_edited_property(), array, "", false); - object->set_array(array); update_property(); } void EditorPropertyArray::_button_draw() { if (dropping) { - Color color = get_theme_color("accent_color", "Editor"); + Color color = get_theme_color(SNAME("accent_color"), SNAME("Editor")); edit->draw_rect(Rect2(Point2(), edit->get_size()), color, false); } } @@ -414,14 +440,14 @@ bool EditorPropertyArray::_is_drop_valid(const Dictionary &p_drag_data) const { for (int j = 0; j < allowed_type.get_slice_count(","); j++) { String at = allowed_type.get_slice(",", j).strip_edges(); - // Fail if one of the files is not of allowed type + // Fail if one of the files is not of allowed type. if (!ClassDB::is_parent_class(ftype, at)) { return false; } } } - // If no files fail, drop is valid + // If no files fail, drop is valid. return true; } @@ -442,13 +468,13 @@ void EditorPropertyArray::drop_data_fw(const Point2 &p_point, const Variant &p_d Variant array = object->get_array(); - // Handle the case where array is not initialised yet + // Handle the case where array is not initialised yet. if (!array.is_array()) { Callable::CallError ce; Variant::construct(array_type, array, nullptr, 0, ce); } - // Loop the file array and add to existing array + // Loop the file array and add to existing array. for (int i = 0; i < files.size(); i++) { String file = files[i]; @@ -504,7 +530,7 @@ void EditorPropertyArray::_page_changed(double p_page) { if (updating) { return; } - page_idx = p_page; + page_index = p_page; update_property(); } @@ -530,10 +556,10 @@ void EditorPropertyArray::_length_changed(double p_page) { } } } - array = array.call("duplicate"); //dupe, so undo/redo works better + array = array.call("duplicate"); // Duplicate, so undo/redo works better. } else { int size = array.call("size"); - // Pool*Array don't initialize their elements, have to do it manually + // Pool*Array don't initialize their elements, have to do it manually. for (int i = previous_size; i < size; i++) { Callable::CallError ce; Variant r; @@ -551,7 +577,7 @@ void EditorPropertyArray::setup(Variant::Type p_array_type, const String &p_hint array_type = p_array_type; // The format of p_hint_string is: - // subType/subTypeHint:nextSubtype ... etc + // subType/subTypeHint:nextSubtype ... etc. if (array_type == Variant::ARRAY && !p_hint_string.is_empty()) { int hint_subtype_separator = p_hint_string.find(":"); if (hint_subtype_separator >= 0) { @@ -568,6 +594,73 @@ void EditorPropertyArray::setup(Variant::Type p_array_type, const String &p_hint } } +void EditorPropertyArray::_reorder_button_gui_input(const Ref<InputEvent> &p_event) { + if (reorder_from_index < 0) { + return; + } + + Ref<InputEventMouseMotion> mm = p_event; + if (mm.is_valid()) { + Variant array = object->get_array(); + int size = array.call("size"); + + if ((reorder_to_index == 0 && mm->get_relative().y < 0.0f) || (reorder_to_index == size - 1 && mm->get_relative().y > 0.0f)) { + return; + } + + reorder_mouse_y_delta += mm->get_relative().y; + float required_y_distance = 20.0f * EDSCALE; + if (ABS(reorder_mouse_y_delta) > required_y_distance) { + int direction = reorder_mouse_y_delta > 0.0f ? 1 : -1; + reorder_mouse_y_delta -= required_y_distance * direction; + + reorder_to_index += direction; + if ((direction < 0 && reorder_to_index % page_length == page_length - 1) || (direction > 0 && reorder_to_index % page_length == 0)) { + // Automatically move to the next/previous page. + page_slider->set_value(page_index + direction); + } + vbox->move_child(reorder_selected_element_hbox, reorder_to_index % page_length + 2); + // Ensure the moving element is visible. + EditorNode::get_singleton()->get_inspector()->ensure_control_visible(reorder_selected_element_hbox); + } + } +} + +void EditorPropertyArray::_reorder_button_down(int p_index) { + reorder_from_index = p_index; + reorder_to_index = p_index; + reorder_selected_element_hbox = Object::cast_to<HBoxContainer>(vbox->get_child(p_index % page_length + 2)); + reorder_selected_button = Object::cast_to<Button>(reorder_selected_element_hbox->get_child(0)); + // Ideally it'd to be able to show the mouse but I had issues with + // Control's `mouse_exit()`/`mouse_entered()` signals not getting called. + Input::get_singleton()->set_mouse_mode(Input::MOUSE_MODE_CAPTURED); +} + +void EditorPropertyArray::_reorder_button_up() { + if (reorder_from_index != reorder_to_index) { + // Move the element. + Variant array = object->get_array(); + + Variant value_to_move = array.get(reorder_from_index); + array.call("remove", reorder_from_index); + array.call("insert", reorder_to_index, value_to_move); + + emit_changed(get_edited_property(), array, "", false); + object->set_array(array); + update_property(); + } + + reorder_from_index = -1; + reorder_to_index = -1; + reorder_mouse_y_delta = 0.0f; + + Input::get_singleton()->set_mouse_mode(Input::MOUSE_MODE_VISIBLE); + reorder_selected_button->warp_mouse(reorder_selected_button->get_size() / 2.0f); + + reorder_selected_element_hbox = nullptr; + reorder_selected_button = nullptr; +} + void EditorPropertyArray::_bind_methods() { ClassDB::bind_method(D_METHOD("_can_drop_data_fw"), &EditorPropertyArray::can_drop_data_fw); ClassDB::bind_method(D_METHOD("_drop_data_fw"), &EditorPropertyArray::drop_data_fw); @@ -575,7 +668,7 @@ void EditorPropertyArray::_bind_methods() { EditorPropertyArray::EditorPropertyArray() { object.instantiate(); - page_len = int(EDITOR_GET("interface/inspector/max_array_dictionary_items_per_page")); + page_length = int(EDITOR_GET("interface/inspector/max_array_dictionary_items_per_page")); edit = memnew(Button); edit->set_h_size_flags(SIZE_EXPAND_FILL); edit->set_clip_text(true); @@ -586,8 +679,8 @@ EditorPropertyArray::EditorPropertyArray() { add_child(edit); add_focusable(edit); vbox = nullptr; - page = nullptr; - length = nullptr; + page_slider = nullptr; + size_slider = nullptr; updating = false; change_type = memnew(PopupMenu); add_child(change_type); @@ -599,7 +692,7 @@ EditorPropertyArray::EditorPropertyArray() { } change_type->add_separator(); change_type->add_item(TTR("Remove Item"), Variant::VARIANT_MAX); - changing_type_idx = -1; + changing_type_index = -1; subtype = Variant::NIL; subtype_hint = PROPERTY_HINT_NONE; @@ -616,14 +709,14 @@ void EditorPropertyDictionary::_property_changed(const String &p_property, Varia } else if (p_property == "new_item_value") { object->set_new_item_value(p_value); } else if (p_property.begins_with("indices")) { - int idx = p_property.get_slice("/", 1).to_int(); + int index = p_property.get_slice("/", 1).to_int(); Dictionary dict = object->get_dict(); - Variant key = dict.get_key_at_index(idx); + Variant key = dict.get_key_at_index(index); dict[key] = p_value; emit_changed(get_edited_property(), dict, "", true); - dict = dict.duplicate(); //dupe, so undo/redo works better + dict = dict.duplicate(); // Duplicate, so undo/redo works better\. object->set_dict(dict); } } @@ -635,7 +728,7 @@ void EditorPropertyDictionary::_change_type(Object *p_button, int p_index) { change_type->set_as_minsize(); change_type->set_position(rect.position + rect.size - Vector2(change_type->get_contents_minimum_size().x, 0)); change_type->popup(); - changing_type_idx = p_index; + changing_type_index = p_index; } void EditorPropertyDictionary::_add_key_value() { @@ -652,17 +745,17 @@ void EditorPropertyDictionary::_add_key_value() { emit_changed(get_edited_property(), dict, "", false); - dict = dict.duplicate(); //dupe, so undo/redo works better + dict = dict.duplicate(); // Duplicate, so undo/redo works better. object->set_dict(dict); update_property(); } void EditorPropertyDictionary::_change_type_menu(int p_index) { - if (changing_type_idx < 0) { + if (changing_type_index < 0) { Variant value; Callable::CallError ce; Variant::construct(Variant::Type(p_index), value, nullptr, 0, ce); - if (changing_type_idx == -1) { + if (changing_type_index == -1) { object->set_new_item_key(value); } else { object->set_new_item_value(value); @@ -677,16 +770,16 @@ void EditorPropertyDictionary::_change_type_menu(int p_index) { Variant value; Callable::CallError ce; Variant::construct(Variant::Type(p_index), value, nullptr, 0, ce); - Variant key = dict.get_key_at_index(changing_type_idx); + Variant key = dict.get_key_at_index(changing_type_index); dict[key] = value; } else { - Variant key = dict.get_key_at_index(changing_type_idx); + Variant key = dict.get_key_at_index(changing_type_index); dict.erase(key); } emit_changed(get_edited_property(), dict, "", false); - dict = dict.duplicate(); //dupe, so undo/redo works better + dict = dict.duplicate(); // Duplicate, so undo/redo works better\. object->set_dict(dict); update_property(); } @@ -695,7 +788,7 @@ void EditorPropertyDictionary::update_property() { Variant updated_val = get_edited_object()->get(get_edited_property()); if (updated_val.get_type() == Variant::NIL) { - edit->set_text("Dictionary (Nil)"); //This provides symmetry with the array property. + edit->set_text("Dictionary (Nil)"); // This provides symmetry with the array property. edit->set_pressed(false); if (vbox) { set_bottom_editor(nullptr); @@ -722,16 +815,16 @@ void EditorPropertyDictionary::update_property() { add_child(vbox); set_bottom_editor(vbox); - page_hb = memnew(HBoxContainer); - vbox->add_child(page_hb); + page_hbox = memnew(HBoxContainer); + vbox->add_child(page_hbox); Label *label = memnew(Label(TTR("Page: "))); label->set_h_size_flags(SIZE_EXPAND_FILL); - page_hb->add_child(label); - page = memnew(EditorSpinSlider); - page->set_step(1); - page_hb->add_child(page); - page->set_h_size_flags(SIZE_EXPAND_FILL); - page->connect("value_changed", callable_mp(this, &EditorPropertyDictionary::_page_changed)); + page_hbox->add_child(label); + page_slider = memnew(EditorSpinSlider); + page_slider->set_step(1); + page_hbox->add_child(page_slider); + page_slider->set_h_size_flags(SIZE_EXPAND_FILL); + page_slider->connect("value_changed", callable_mp(this, &EditorPropertyDictionary::_page_changed)); } else { // Queue children for deletion, deleting immediately might cause errors. for (int i = 1; i < vbox->get_child_count(); i++) { @@ -739,18 +832,18 @@ void EditorPropertyDictionary::update_property() { } } - int len = dict.size(); + int size = dict.size(); - int pages = MAX(0, len - 1) / page_len + 1; + int pages = MAX(0, size - 1) / page_length + 1; - page->set_max(pages); - page_idx = MIN(page_idx, pages - 1); - page->set_value(page_idx); - page_hb->set_visible(pages > 1); + page_slider->set_max(pages); + page_index = MIN(page_index, pages - 1); + page_slider->set_value(page_index); + page_hbox->set_visible(pages > 1); - int offset = page_idx * page_len; + int offset = page_index * page_length; - int amount = MIN(len - offset, page_len); + int amount = MIN(size - offset, page_length); dict = dict.duplicate(); @@ -782,7 +875,7 @@ void EditorPropertyDictionary::update_property() { } break; - // atomic types + // Atomic types. case Variant::BOOL: { prop = memnew(EditorPropertyCheck); @@ -803,7 +896,7 @@ void EditorPropertyDictionary::update_property() { } break; - // math types + // Math types. case Variant::VECTOR2: { EditorPropertyVector2 *editor = memnew(EditorPropertyVector2); editor->setup(-100000, 100000, 0.001, true); @@ -877,7 +970,7 @@ void EditorPropertyDictionary::update_property() { } break; - // misc types + // Miscellaneous types. case Variant::COLOR: { prop = memnew(EditorPropertyColor); @@ -919,7 +1012,7 @@ void EditorPropertyDictionary::update_property() { prop = editor; } break; - // arrays + // Arrays. case Variant::PACKED_BYTE_ARRAY: { EditorPropertyArray *editor = memnew(EditorPropertyArray); editor->setup(Variant::PACKED_BYTE_ARRAY); @@ -977,7 +1070,7 @@ void EditorPropertyDictionary::update_property() { for (int j = 0; j < 4; j++) { flat->set_default_margin(Side(j), 2 * EDSCALE); } - flat->set_bg_color(get_theme_color("prop_subsection", "Editor")); + flat->set_bg_color(get_theme_color(SNAME("prop_subsection"), SNAME("Editor"))); pc->add_theme_style_override("panel", flat); add_vbox = memnew(VBoxContainer); @@ -1003,17 +1096,17 @@ void EditorPropertyDictionary::update_property() { prop->connect("property_changed", callable_mp(this, &EditorPropertyDictionary::_property_changed)); prop->connect("object_id_selected", callable_mp(this, &EditorPropertyDictionary::_object_id_selected)); - HBoxContainer *hb = memnew(HBoxContainer); + HBoxContainer *hbox = memnew(HBoxContainer); if (add_vbox) { - add_vbox->add_child(hb); + add_vbox->add_child(hbox); } else { - vbox->add_child(hb); + vbox->add_child(hbox); } - hb->add_child(prop); + hbox->add_child(prop); prop->set_h_size_flags(SIZE_EXPAND_FILL); Button *edit = memnew(Button); - edit->set_icon(get_theme_icon("Edit", "EditorIcons")); - hb->add_child(edit); + edit->set_icon(get_theme_icon(SNAME("Edit"), SNAME("EditorIcons"))); + hbox->add_child(edit); edit->connect("pressed", callable_mp(this, &EditorPropertyDictionary::_change_type), varray(edit, change_index)); prop->update_property(); @@ -1038,7 +1131,7 @@ void EditorPropertyDictionary::update_property() { } void EditorPropertyDictionary::_object_id_selected(const StringName &p_property, ObjectID p_id) { - emit_signal("object_id_selected", p_property, p_id); + emit_signal(SNAME("object_id_selected"), p_property, p_id); } void EditorPropertyDictionary::_notification(int p_what) { @@ -1060,7 +1153,7 @@ void EditorPropertyDictionary::_page_changed(double p_page) { if (updating) { return; } - page_idx = p_page; + page_index = p_page; update_property(); } @@ -1069,7 +1162,7 @@ void EditorPropertyDictionary::_bind_methods() { EditorPropertyDictionary::EditorPropertyDictionary() { object.instantiate(); - page_len = int(EDITOR_GET("interface/inspector/max_array_dictionary_items_per_page")); + page_length = int(EDITOR_GET("interface/inspector/max_array_dictionary_items_per_page")); edit = memnew(Button); edit->set_h_size_flags(SIZE_EXPAND_FILL); edit->set_clip_text(true); @@ -1078,7 +1171,7 @@ EditorPropertyDictionary::EditorPropertyDictionary() { add_child(edit); add_focusable(edit); vbox = nullptr; - page = nullptr; + page_slider = nullptr; updating = false; change_type = memnew(PopupMenu); add_child(change_type); @@ -1090,5 +1183,5 @@ EditorPropertyDictionary::EditorPropertyDictionary() { } change_type->add_separator(); change_type->add_item(TTR("Remove Item"), Variant::VARIANT_MAX); - changing_type_idx = -1; + changing_type_index = -1; } diff --git a/editor/editor_properties_array_dict.h b/editor/editor_properties_array_dict.h index aa2d8744b1..7547d57346 100644 --- a/editor/editor_properties_array_dict.h +++ b/editor/editor_properties_array_dict.h @@ -84,19 +84,25 @@ class EditorPropertyArray : public EditorProperty { bool dropping; Ref<EditorPropertyArrayObject> object; - int page_len = 20; - int page_idx = 0; - int changing_type_idx; + int page_length = 20; + int page_index = 0; + int changing_type_index; Button *edit; VBoxContainer *vbox; - EditorSpinSlider *length; - EditorSpinSlider *page; - HBoxContainer *page_hb; + EditorSpinSlider *size_slider; + EditorSpinSlider *page_slider; + HBoxContainer *page_hbox; Variant::Type array_type; Variant::Type subtype; PropertyHint subtype_hint; String subtype_hint_string; + int reorder_from_index = -1; + int reorder_to_index = -1; + float reorder_mouse_y_delta = 0.0f; + HBoxContainer *reorder_selected_element_hbox = nullptr; + Button *reorder_selected_button = nullptr; + void _page_changed(double p_page); void _length_changed(double p_page); void _edit_pressed(); @@ -112,6 +118,10 @@ class EditorPropertyArray : public EditorProperty { bool can_drop_data_fw(const Point2 &p_point, const Variant &p_data, Control *p_from) const; void drop_data_fw(const Point2 &p_point, const Variant &p_data, Control *p_from); + void _reorder_button_gui_input(const Ref<InputEvent> &p_event); + void _reorder_button_down(int p_index); + void _reorder_button_up(); + protected: static void _bind_methods(); void _notification(int p_what); @@ -129,14 +139,14 @@ class EditorPropertyDictionary : public EditorProperty { bool updating; Ref<EditorPropertyDictionaryObject> object; - int page_len = 20; - int page_idx = 0; - int changing_type_idx; + int page_length = 20; + int page_index = 0; + int changing_type_index; Button *edit; VBoxContainer *vbox; - EditorSpinSlider *length; - EditorSpinSlider *page; - HBoxContainer *page_hb; + EditorSpinSlider *size_slider; + EditorSpinSlider *page_slider; + HBoxContainer *page_hbox; void _page_changed(double p_page); void _edit_pressed(); diff --git a/editor/editor_resource_picker.cpp b/editor/editor_resource_picker.cpp index 4d9865622c..9977f5f42c 100644 --- a/editor/editor_resource_picker.cpp +++ b/editor/editor_resource_picker.cpp @@ -76,7 +76,7 @@ void EditorResourcePicker::_update_resource_preview(const String &p_path, const } if (p_preview.is_valid()) { - preview_rect->set_offset(SIDE_LEFT, assign_button->get_icon()->get_width() + assign_button->get_theme_stylebox("normal")->get_default_margin(SIDE_LEFT) + get_theme_constant("hseparation", "Button")); + preview_rect->set_offset(SIDE_LEFT, assign_button->get_icon()->get_width() + assign_button->get_theme_stylebox(SNAME("normal"))->get_default_margin(SIDE_LEFT) + get_theme_constant(SNAME("hseparation"), SNAME("Button"))); if (type == "GradientTexture") { preview_rect->set_stretch_mode(TextureRect::STRETCH_SCALE); @@ -100,7 +100,7 @@ void EditorResourcePicker::_resource_selected() { return; } - emit_signal("resource_selected", edited_resource); + emit_signal(SNAME("resource_selected"), edited_resource); } void EditorResourcePicker::_file_selected(const String &p_path) { @@ -125,7 +125,7 @@ void EditorResourcePicker::_file_selected(const String &p_path) { } edited_resource = loaded_resource; - emit_signal("resource_changed", edited_resource); + emit_signal(SNAME("resource_changed"), edited_resource); _update_resource(); } @@ -141,20 +141,21 @@ void EditorResourcePicker::_update_menu() { } void EditorResourcePicker::_update_menu_items() { + _ensure_resource_menu(); edit_menu->clear(); // Add options for creating specific subtypes of the base resource type. set_create_options(edit_menu); // Add an option to load a resource from a file. - edit_menu->add_icon_item(get_theme_icon("Load", "EditorIcons"), TTR("Load"), OBJ_MENU_LOAD); + edit_menu->add_icon_item(get_theme_icon(SNAME("Load"), SNAME("EditorIcons")), TTR("Load"), OBJ_MENU_LOAD); // Add options for changing existing value of the resource. if (edited_resource.is_valid()) { - edit_menu->add_icon_item(get_theme_icon("Edit", "EditorIcons"), TTR("Edit"), OBJ_MENU_EDIT); - edit_menu->add_icon_item(get_theme_icon("Clear", "EditorIcons"), TTR("Clear"), OBJ_MENU_CLEAR); - edit_menu->add_icon_item(get_theme_icon("Duplicate", "EditorIcons"), TTR("Make Unique"), OBJ_MENU_MAKE_UNIQUE); - edit_menu->add_icon_item(get_theme_icon("Save", "EditorIcons"), TTR("Save"), OBJ_MENU_SAVE); + edit_menu->add_icon_item(get_theme_icon(SNAME("Edit"), SNAME("EditorIcons")), TTR("Edit"), OBJ_MENU_EDIT); + edit_menu->add_icon_item(get_theme_icon(SNAME("Clear"), SNAME("EditorIcons")), TTR("Clear"), OBJ_MENU_CLEAR); + edit_menu->add_icon_item(get_theme_icon(SNAME("Duplicate"), SNAME("EditorIcons")), TTR("Make Unique"), OBJ_MENU_MAKE_UNIQUE); + edit_menu->add_icon_item(get_theme_icon(SNAME("Save"), SNAME("EditorIcons")), TTR("Save"), OBJ_MENU_SAVE); if (edited_resource->get_path().is_resource_file()) { edit_menu->add_separator(); @@ -199,10 +200,10 @@ void EditorResourcePicker::_update_menu_items() { for (int i = 0; i < conversions.size(); i++) { String what = conversions[i]->converts_to(); Ref<Texture2D> icon; - if (has_theme_icon(what, "EditorIcons")) { - icon = get_theme_icon(what, "EditorIcons"); + if (has_theme_icon(what, SNAME("EditorIcons"))) { + icon = get_theme_icon(what, SNAME("EditorIcons")); } else { - icon = get_theme_icon(what, "Resource"); + icon = get_theme_icon(what, SNAME("Resource")); } edit_menu->add_icon_item(icon, vformat(TTR("Convert to %s"), what), CONVERT_BASE_ID + i); @@ -220,8 +221,8 @@ void EditorResourcePicker::_edit_menu_cbk(int p_which) { } Set<String> valid_extensions; - for (List<String>::Element *E = extensions.front(); E; E = E->next()) { - valid_extensions.insert(E->get()); + for (const String &E : extensions) { + valid_extensions.insert(E); } if (!file_dialog) { @@ -241,13 +242,13 @@ void EditorResourcePicker::_edit_menu_cbk(int p_which) { case OBJ_MENU_EDIT: { if (edited_resource.is_valid()) { - emit_signal("resource_selected", edited_resource); + emit_signal(SNAME("resource_selected"), edited_resource); } } break; case OBJ_MENU_CLEAR: { edited_resource = RES(); - emit_signal("resource_changed", edited_resource); + emit_signal(SNAME("resource_changed"), edited_resource); _update_resource(); } break; @@ -259,9 +260,8 @@ void EditorResourcePicker::_edit_menu_cbk(int p_which) { List<PropertyInfo> property_list; edited_resource->get_property_list(&property_list); List<Pair<String, Variant>> propvalues; - for (List<PropertyInfo>::Element *E = property_list.front(); E; E = E->next()) { + for (const PropertyInfo &pi : property_list) { Pair<String, Variant> p; - PropertyInfo &pi = E->get(); if (pi.usage & PROPERTY_USAGE_STORAGE) { p.first = pi.name; p.second = edited_resource->get(pi.name); @@ -275,13 +275,12 @@ void EditorResourcePicker::_edit_menu_cbk(int p_which) { Ref<Resource> unique_resource = Ref<Resource>(Object::cast_to<Resource>(inst)); ERR_FAIL_COND(unique_resource.is_null()); - for (List<Pair<String, Variant>>::Element *E = propvalues.front(); E; E = E->next()) { - Pair<String, Variant> &p = E->get(); + for (const Pair<String, Variant> &p : propvalues) { unique_resource->set(p.first, p.second); } edited_resource = unique_resource; - emit_signal("resource_changed", edited_resource); + emit_signal(SNAME("resource_changed"), edited_resource); _update_resource(); } break; @@ -298,7 +297,7 @@ void EditorResourcePicker::_edit_menu_cbk(int p_which) { case OBJ_MENU_PASTE: { edited_resource = EditorSettings::get_singleton()->get_resource_clipboard(); - emit_signal("resource_changed", edited_resource); + emit_signal(SNAME("resource_changed"), edited_resource); _update_resource(); } break; @@ -323,7 +322,7 @@ void EditorResourcePicker::_edit_menu_cbk(int p_which) { ERR_FAIL_INDEX(to_type, conversions.size()); edited_resource = conversions[to_type]->convert(edited_resource); - emit_signal("resource_changed", edited_resource); + emit_signal(SNAME("resource_changed"), edited_resource); _update_resource(); break; } @@ -353,13 +352,14 @@ void EditorResourcePicker::_edit_menu_cbk(int p_which) { ERR_BREAK(!resp); edited_resource = RES(resp); - emit_signal("resource_changed", edited_resource); + emit_signal(SNAME("resource_changed"), edited_resource); _update_resource(); } break; } } void EditorResourcePicker::set_create_options(Object *p_menu_node) { + _ensure_resource_menu(); // If a subclass implements this method, use it to replace all create items. if (get_script_instance() && get_script_instance()->has_method("_set_create_options")) { get_script_instance()->call("_set_create_options", p_menu_node); @@ -402,7 +402,7 @@ void EditorResourcePicker::set_create_options(Object *p_menu_node) { inheritors_array.push_back(t); if (!icon.is_valid()) { - icon = get_theme_icon(has_theme_icon(t, "EditorIcons") ? t : "Object", "EditorIcons"); + icon = get_theme_icon(has_theme_icon(t, SNAME("EditorIcons")) ? t : String("Object"), SNAME("EditorIcons")); } int id = TYPE_BASE_ID + idx; @@ -427,7 +427,7 @@ bool EditorResourcePicker::handle_menu_selected(int p_which) { void EditorResourcePicker::_button_draw() { if (dropping) { - Color color = get_theme_color("accent_color", "Editor"); + Color color = get_theme_color(SNAME("accent_color"), SNAME("Editor")); assign_button->draw_rect(Rect2(Point2(), assign_button->get_size()), color, false); } } @@ -465,13 +465,13 @@ void EditorResourcePicker::_get_allowed_types(bool p_with_convert, Set<String> * List<StringName> inheriters; ClassDB::get_inheriters_from_class(base, &inheriters); - for (List<StringName>::Element *E = inheriters.front(); E; E = E->next()) { - p_vector->insert(E->get()); + for (const StringName &E : inheriters) { + p_vector->insert(E); } - for (List<StringName>::Element *E = global_classes.front(); E; E = E->next()) { - if (EditorNode::get_editor_data().script_class_is_parent(E->get(), base)) { - p_vector->insert(E->get()); + for (const StringName &E : global_classes) { + if (EditorNode::get_editor_data().script_class_is_parent(E, base)) { + p_vector->insert(E); } } @@ -505,7 +505,9 @@ bool EditorResourcePicker::_is_drop_valid(const Dictionary &p_drag_data) const { Ref<Resource> res; if (drag_data.has("type") && String(drag_data["type"]) == "script_list_element") { ScriptEditorBase *se = Object::cast_to<ScriptEditorBase>(drag_data["script_list_element"]); - res = se->get_edited_resource(); + if (se) { + res = se->get_edited_resource(); + } } else if (drag_data.has("type") && String(drag_data["type"]) == "resource") { res = drag_data["resource"]; } @@ -571,7 +573,9 @@ void EditorResourcePicker::drop_data_fw(const Point2 &p_point, const Variant &p_ Ref<Resource> dropped_resource; if (drag_data.has("type") && String(drag_data["type"]) == "script_list_element") { ScriptEditorBase *se = Object::cast_to<ScriptEditorBase>(drag_data["script_list_element"]); - dropped_resource = se->get_edited_resource(); + if (se) { + dropped_resource = se->get_edited_resource(); + } } else if (drag_data.has("type") && String(drag_data["type"]) == "resource") { dropped_resource = drag_data["resource"]; } @@ -618,7 +622,7 @@ void EditorResourcePicker::drop_data_fw(const Point2 &p_point, const Variant &p_ } edited_resource = dropped_resource; - emit_signal("resource_changed", edited_resource); + emit_signal(SNAME("resource_changed"), edited_resource); _update_resource(); } } @@ -659,11 +663,11 @@ void EditorResourcePicker::_notification(int p_what) { [[fallthrough]]; } case NOTIFICATION_THEME_CHANGED: { - edit_button->set_icon(get_theme_icon("select_arrow", "Tree")); + edit_button->set_icon(get_theme_icon(SNAME("select_arrow"), SNAME("Tree"))); } break; case NOTIFICATION_DRAW: { - draw_style_box(get_theme_stylebox("bg", "Tree"), Rect2(Point2(), get_size())); + draw_style_box(get_theme_stylebox(SNAME("bg"), SNAME("Tree")), Rect2(Point2(), get_size())); } break; case NOTIFICATION_DRAG_BEGIN: { @@ -783,6 +787,15 @@ bool EditorResourcePicker::is_editable() const { return editable; } +void EditorResourcePicker::_ensure_resource_menu() { + if (edit_menu) { + return; + } + edit_menu = memnew(PopupMenu); + add_child(edit_menu); + edit_menu->connect("id_pressed", callable_mp(this, &EditorResourcePicker::_edit_menu_cbk)); + edit_menu->connect("popup_hide", callable_mp((BaseButton *)edit_button, &BaseButton::set_pressed), varray(false)); +} EditorResourcePicker::EditorResourcePicker() { assign_button = memnew(Button); assign_button->set_flat(true); @@ -808,10 +821,6 @@ EditorResourcePicker::EditorResourcePicker() { edit_button->connect("pressed", callable_mp(this, &EditorResourcePicker::_update_menu)); add_child(edit_button); edit_button->connect("gui_input", callable_mp(this, &EditorResourcePicker::_button_input)); - edit_menu = memnew(PopupMenu); - add_child(edit_menu); - edit_menu->connect("id_pressed", callable_mp(this, &EditorResourcePicker::_edit_menu_cbk)); - edit_menu->connect("popup_hide", callable_mp((BaseButton *)edit_button, &BaseButton::set_pressed), varray(false)); } void EditorScriptPicker::set_create_options(Object *p_menu_node) { @@ -820,8 +829,8 @@ void EditorScriptPicker::set_create_options(Object *p_menu_node) { return; } - menu_node->add_icon_item(get_theme_icon("ScriptCreate", "EditorIcons"), TTR("New Script"), OBJ_MENU_NEW_SCRIPT); - menu_node->add_icon_item(get_theme_icon("ScriptExtend", "EditorIcons"), TTR("Extend Script"), OBJ_MENU_EXTEND_SCRIPT); + menu_node->add_icon_item(get_theme_icon(SNAME("ScriptCreate"), SNAME("EditorIcons")), TTR("New Script"), OBJ_MENU_NEW_SCRIPT); + menu_node->add_icon_item(get_theme_icon(SNAME("ScriptExtend"), SNAME("EditorIcons")), TTR("Extend Script"), OBJ_MENU_EXTEND_SCRIPT); menu_node->add_separator(); } diff --git a/editor/editor_resource_picker.h b/editor/editor_resource_picker.h index 9a4b945bc7..82a4817dfc 100644 --- a/editor/editor_resource_picker.h +++ b/editor/editor_resource_picker.h @@ -67,7 +67,7 @@ class EditorResourcePicker : public HBoxContainer { CONVERT_BASE_ID = 1000, }; - PopupMenu *edit_menu; + PopupMenu *edit_menu = nullptr; void _update_resource(); void _update_resource_preview(const String &p_path, const Ref<Texture2D> &p_preview, const Ref<Texture2D> &p_small_preview, ObjectID p_obj); @@ -90,6 +90,8 @@ class EditorResourcePicker : public HBoxContainer { bool can_drop_data_fw(const Point2 &p_point, const Variant &p_data, Control *p_from) const; void drop_data_fw(const Point2 &p_point, const Variant &p_data, Control *p_from); + void _ensure_resource_menu(); + protected: static void _bind_methods(); void _notification(int p_what); diff --git a/editor/editor_resource_preview.cpp b/editor/editor_resource_preview.cpp index f904ae80a7..7f4ee7848f 100644 --- a/editor/editor_resource_preview.cpp +++ b/editor/editor_resource_preview.cpp @@ -161,7 +161,7 @@ void EditorResourcePreview::_generate_preview(Ref<ImageTexture> &r_texture, Ref< } r_texture = generated; - int small_thumbnail_size = EditorNode::get_singleton()->get_theme_base()->get_theme_icon("Object", "EditorIcons")->get_width(); // Kind of a workaround to retrieve the default icon size + int small_thumbnail_size = EditorNode::get_singleton()->get_theme_base()->get_theme_icon(SNAME("Object"), SNAME("EditorIcons"))->get_width(); // Kind of a workaround to retrieve the default icon size if (preview_generators[i]->can_generate_small_preview()) { Ref<Texture2D> generated_small; @@ -419,7 +419,7 @@ void EditorResourcePreview::check_for_invalidation(const String &p_path) { } if (call_invalidated) { //do outside mutex - call_deferred("emit_signal", "preview_invalidated", p_path); + call_deferred(SNAME("emit_signal"), "preview_invalidated", p_path); } } diff --git a/editor/editor_run.cpp b/editor/editor_run.cpp index 5e6d2ab69c..8a7ec9aa82 100644 --- a/editor/editor_run.cpp +++ b/editor/editor_run.cpp @@ -228,8 +228,8 @@ Error EditorRun::run(const String &p_scene, const String &p_custom_args, const L } printf("Running: %s", exec.utf8().get_data()); - for (List<String>::Element *E = args.front(); E; E = E->next()) { - printf(" %s", E->get().utf8().get_data()); + for (const String &E : args) { + printf(" %s", E.utf8().get_data()); }; printf("\n"); @@ -250,8 +250,8 @@ Error EditorRun::run(const String &p_scene, const String &p_custom_args, const L } bool EditorRun::has_child_process(OS::ProcessID p_pid) const { - for (const List<OS::ProcessID>::Element *E = pids.front(); E; E = E->next()) { - if (E->get() == p_pid) { + for (const OS::ProcessID &E : pids) { + if (E == p_pid) { return true; } } @@ -267,9 +267,10 @@ void EditorRun::stop_child_process(OS::ProcessID p_pid) { void EditorRun::stop() { if (status != STATUS_STOP && pids.size() > 0) { - for (List<OS::ProcessID>::Element *E = pids.front(); E; E = E->next()) { - OS::get_singleton()->kill(E->get()); + for (const OS::ProcessID &E : pids) { + OS::get_singleton()->kill(E); } + pids.clear(); } status = STATUS_STOP; diff --git a/editor/editor_run_native.cpp b/editor/editor_run_native.cpp index a604022391..e115cd77e1 100644 --- a/editor/editor_run_native.cpp +++ b/editor/editor_run_native.cpp @@ -127,7 +127,7 @@ void EditorRunNative::_run_native(int p_idx, int p_platform) { return; } - emit_signal("native_run", preset); + emit_signal(SNAME("native_run"), preset); int flags = 0; diff --git a/editor/editor_sectioned_inspector.cpp b/editor/editor_sectioned_inspector.cpp index 6bfb17f9c2..751cc7a574 100644 --- a/editor/editor_sectioned_inspector.cpp +++ b/editor/editor_sectioned_inspector.cpp @@ -76,8 +76,7 @@ class SectionedInspectorFilter : public Object { List<PropertyInfo> pinfo; edited->get_property_list(&pinfo); - for (List<PropertyInfo>::Element *E = pinfo.front(); E; E = E->next()) { - PropertyInfo pi = E->get(); + for (PropertyInfo &pi : pinfo) { int sp = pi.name.find("/"); 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 @@ -221,9 +220,7 @@ void SectionedInspector::update_category_list() { filter = search_box->get_text(); } - for (List<PropertyInfo>::Element *E = pinfo.front(); E; E = E->next()) { - PropertyInfo pi = E->get(); - + for (PropertyInfo &pi : pinfo) { if (pi.usage & PROPERTY_USAGE_CATEGORY) { continue; } else if (!(pi.usage & PROPERTY_USAGE_EDITOR) || (restrict_to_basic && !(pi.usage & PROPERTY_USAGE_EDITOR_BASIC_SETTING))) { @@ -250,8 +247,8 @@ void SectionedInspector::update_category_list() { for (int i = 0; i < sc; i++) { TreeItem *parent = section_map[metasection]; - //parent->set_custom_bg_color(0, get_theme_color("prop_subsection", "Editor")); - parent->set_custom_font(0, get_theme_font("bold", "EditorFonts")); + //parent->set_custom_bg_color(0, get_theme_color(SNAME("prop_subsection"), SNAME("Editor"))); + parent->set_custom_font(0, get_theme_font(SNAME("bold"), SNAME("EditorFonts"))); if (i > 0) { metasection += "/" + sectionarr[i]; diff --git a/editor/editor_settings.cpp b/editor/editor_settings.cpp index b6f889268f..df4469b6fe 100644 --- a/editor/editor_settings.cpp +++ b/editor/editor_settings.cpp @@ -63,7 +63,7 @@ bool EditorSettings::_set(const StringName &p_name, const Variant &p_value) { bool changed = _set_only(p_name, p_value); if (changed) { - emit_signal("settings_changed"); + emit_signal(SNAME("settings_changed")); } return true; } @@ -759,8 +759,7 @@ void EditorSettings::_load_defaults(Ref<ConfigFile> p_extra_config) { List<String> keys; p_extra_config->get_section_keys("presets", &keys); - for (List<String>::Element *E = keys.front(); E; E = E->next()) { - String key = E->get(); + for (const String &key : keys) { Variant val = p_extra_config->get_value("presets", key); set(key, val); } @@ -815,8 +814,7 @@ bool EditorSettings::_save_text_editor_theme(String p_file) { props.get_key_list(&keys); keys.sort(); - for (const List<String>::Element *E = keys.front(); E; E = E->next()) { - const String &key = E->get(); + for (const String &key : keys) { if (key.begins_with("text_editor/highlighting/") && key.find("color") >= 0) { cf->set_value(theme_section, key.replace("text_editor/highlighting/", ""), ((Color)props[key].variant).to_html()); } @@ -1015,15 +1013,13 @@ void EditorSettings::setup_network() { String selected = "127.0.0.1"; // Check that current remote_host is a valid interface address and populate hints. - for (List<IPAddress>::Element *E = local_ip.front(); E; E = E->next()) { - String ip = E->get(); - + for (const IPAddress &ip : local_ip) { // link-local IPv6 addresses don't work, skipping them - if (ip.begins_with("fe80:0:0:0:")) { // fe80::/64 + if (String(ip).begins_with("fe80:0:0:0:")) { // fe80::/64 continue; } // Same goes for IPv4 link-local (APIPA) addresses. - if (ip.begins_with("169.254.")) { // 169.254.0.0/16 + if (String(ip).begins_with("169.254.")) { // 169.254.0.0/16 continue; } // Select current IP (found) @@ -1303,8 +1299,8 @@ void EditorSettings::list_text_editor_themes() { memdelete(d); custom_themes.sort(); - for (List<String>::Element *E = custom_themes.front(); E; E = E->next()) { - themes += "," + E->get(); + for (const String &E : custom_themes) { + themes += "," + E; } } add_property_hint(PropertyInfo(Variant::STRING, "text_editor/theme/color_theme", PROPERTY_HINT_ENUM, themes)); @@ -1332,8 +1328,7 @@ void EditorSettings::load_text_editor_theme() { List<String> keys; cf->get_section_keys("color_theme", &keys); - for (List<String>::Element *E = keys.front(); E; E = E->next()) { - String key = E->get(); + for (const String &key : keys) { String val = cf->get_value("color_theme", key); // don't load if it's not already there! @@ -1344,7 +1339,7 @@ void EditorSettings::load_text_editor_theme() { } } } - emit_signal("settings_changed"); + emit_signal(SNAME("settings_changed")); // if it doesn't load just use what is currently loaded } @@ -1434,7 +1429,7 @@ float EditorSettings::get_auto_display_scale() const { return DisplayServer::get_singleton()->screen_get_max_scale(); #else const int screen = DisplayServer::get_singleton()->window_get_current_screen(); - // Use the smallest dimension to use a correct display scale on portait displays. + // Use the smallest dimension to use a correct display scale on portrait displays. const int smallest_dimension = MIN(DisplayServer::get_singleton()->screen_get_size(screen).x, DisplayServer::get_singleton()->screen_get_size(screen).y); if (DisplayServer::get_singleton()->screen_get_dpi(screen) >= 192 && smallest_dimension >= 1400) { // hiDPI display. @@ -1585,8 +1580,8 @@ void EditorSettings::set_builtin_action_override(const String &p_name, const Arr int event_idx = 0; // Check equality of each event. - for (List<Ref<InputEvent>>::Element *E = builtin_events.front(); E; E = E->next()) { - if (!E->get()->is_match(p_events[event_idx])) { + for (const Ref<InputEvent> &E : builtin_events) { + if (!E->is_match(p_events[event_idx])) { same_as_builtin = false; break; } @@ -1615,8 +1610,8 @@ const Array EditorSettings::get_builtin_action_overrides(const String &p_name) c Array event_array; List<Ref<InputEvent>> events_list = AO->get(); - for (List<Ref<InputEvent>>::Element *E = events_list.front(); E; E = E->next()) { - event_array.push_back(E->get()); + for (const Ref<InputEvent> &E : events_list) { + event_array.push_back(E); } return event_array; } diff --git a/editor/editor_spin_slider.cpp b/editor/editor_spin_slider.cpp index aa4a394d30..58ab7d3cef 100644 --- a/editor/editor_spin_slider.cpp +++ b/editor/editor_spin_slider.cpp @@ -88,7 +88,7 @@ void EditorSpinSlider::_gui_input(const Ref<InputEvent> &p_event) { } } else if (mb->get_button_index() == MOUSE_BUTTON_WHEEL_UP || mb->get_button_index() == MOUSE_BUTTON_WHEEL_DOWN) { if (grabber->is_visible()) { - call_deferred("update"); + call_deferred(SNAME("update")); } } } @@ -185,6 +185,27 @@ void EditorSpinSlider::_grabber_gui_input(const Ref<InputEvent> &p_event) { } } +void EditorSpinSlider::_update_value_input_stylebox() { + if (!value_input) { + return; + } + // Add a left margin to the stylebox to make the number align with the Label + // when it's edited. The LineEdit "focus" stylebox uses the "normal" stylebox's + // default margins. + Ref<StyleBoxFlat> stylebox = + EditorNode::get_singleton()->get_theme_base()->get_theme_stylebox(SNAME("normal"), SNAME("LineEdit"))->duplicate(); + // EditorSpinSliders with a label have more space on the left, so add an + // higher margin to match the location where the text begins. + // The margin values below were determined by empirical testing. + if (is_layout_rtl()) { + stylebox->set_default_margin(SIDE_LEFT, 0); + stylebox->set_default_margin(SIDE_RIGHT, (get_label() != String() ? 23 : 16) * EDSCALE); + } else { + stylebox->set_default_margin(SIDE_LEFT, (get_label() != String() ? 23 : 16) * EDSCALE); + stylebox->set_default_margin(SIDE_RIGHT, 0); + } + value_input->add_theme_style_override("normal", stylebox); +} void EditorSpinSlider::_notification(int p_what) { if (p_what == NOTIFICATION_WM_WINDOW_FOCUS_OUT || p_what == NOTIFICATION_WM_WINDOW_FOCUS_IN || @@ -197,23 +218,8 @@ void EditorSpinSlider::_notification(int p_what) { } } - if (p_what == NOTIFICATION_READY) { - // Add a left margin to the stylebox to make the number align with the Label - // when it's edited. The LineEdit "focus" stylebox uses the "normal" stylebox's - // default margins. - Ref<StyleBoxFlat> stylebox = - EditorNode::get_singleton()->get_theme_base()->get_theme_stylebox("normal", "LineEdit")->duplicate(); - // EditorSpinSliders with a label have more space on the left, so add an - // higher margin to match the location where the text begins. - // The margin values below were determined by empirical testing. - if (is_layout_rtl()) { - stylebox->set_default_margin(SIDE_LEFT, 0); - stylebox->set_default_margin(SIDE_RIGHT, (get_label() != String() ? 23 : 16) * EDSCALE); - } else { - stylebox->set_default_margin(SIDE_LEFT, (get_label() != String() ? 23 : 16) * EDSCALE); - stylebox->set_default_margin(SIDE_RIGHT, 0); - } - value_input->add_theme_style_override("normal", stylebox); + if (p_what == NOTIFICATION_READY || p_what == NOTIFICATION_THEME_CHANGED) { + _update_value_input_stylebox(); } if (p_what == NOTIFICATION_DRAW) { @@ -223,19 +229,19 @@ void EditorSpinSlider::_notification(int p_what) { bool rtl = is_layout_rtl(); Vector2 size = get_size(); - Ref<StyleBox> sb = get_theme_stylebox("normal", "LineEdit"); + Ref<StyleBox> sb = get_theme_stylebox(SNAME("normal"), SNAME("LineEdit")); if (!flat) { draw_style_box(sb, Rect2(Vector2(), size)); } - Ref<Font> font = get_theme_font("font", "LineEdit"); - int font_size = get_theme_font_size("font_size", "LineEdit"); + Ref<Font> font = get_theme_font(SNAME("font"), SNAME("LineEdit")); + int font_size = get_theme_font_size(SNAME("font_size"), SNAME("LineEdit")); int sep_base = 4 * EDSCALE; int sep = sep_base + sb->get_offset().x; //make it have the same margin on both sides, looks better int label_width = font->get_string_size(label, font_size).width; int number_width = size.width - sb->get_minimum_size().width - label_width - sep; - Ref<Texture2D> updown = get_theme_icon("updown", "SpinBox"); + Ref<Texture2D> updown = get_theme_icon(SNAME("updown"), SNAME("SpinBox")); if (get_step() == 1) { number_width -= updown->get_width(); @@ -245,7 +251,7 @@ void EditorSpinSlider::_notification(int p_what) { int vofs = (size.height - font->get_height(font_size)) / 2 + font->get_ascent(font_size); - Color fc = get_theme_color("font_color", "LineEdit"); + Color fc = get_theme_color(SNAME("font_color"), SNAME("LineEdit")); Color lc; if (use_custom_label_color) { lc = custom_label_color; @@ -254,7 +260,7 @@ void EditorSpinSlider::_notification(int p_what) { } if (flat && label != String()) { - Color label_bg_color = get_theme_color("dark_color_3", "Editor"); + Color label_bg_color = get_theme_color(SNAME("dark_color_3"), SNAME("Editor")); if (rtl) { draw_rect(Rect2(Vector2(size.width - (sb->get_offset().x * 2 + label_width), 0), Vector2(sb->get_offset().x * 2 + label_width, size.height)), label_bg_color); } else { @@ -263,7 +269,7 @@ void EditorSpinSlider::_notification(int p_what) { } if (has_focus()) { - Ref<StyleBox> focus = get_theme_stylebox("focus", "LineEdit"); + Ref<StyleBox> focus = get_theme_stylebox(SNAME("focus"), SNAME("LineEdit")); draw_style_box(focus, Rect2(Vector2(), size)); } @@ -301,7 +307,7 @@ void EditorSpinSlider::_notification(int p_what) { TS->free(num_rid); if (get_step() == 1) { - Ref<Texture2D> updown2 = get_theme_icon("updown", "SpinBox"); + Ref<Texture2D> updown2 = get_theme_icon(SNAME("updown"), SNAME("SpinBox")); int updown_vofs = (size.height - updown2->get_height()) / 2; if (rtl) { updown_offset = sb->get_margin(SIDE_LEFT); @@ -332,7 +338,7 @@ void EditorSpinSlider::_notification(int p_what) { grabbing_spinner_mouse_pos = get_global_position() + grabber_rect.position + grabber_rect.size * 0.5; - bool display_grabber = (mouse_over_spin || mouse_over_grabber) && !grabbing_spinner && !value_input_popup->is_visible(); + bool display_grabber = (mouse_over_spin || mouse_over_grabber) && !grabbing_spinner && !(value_input_popup && value_input_popup->is_visible()); if (grabber->is_visible() != display_grabber) { if (display_grabber) { grabber->show(); @@ -344,9 +350,9 @@ void EditorSpinSlider::_notification(int p_what) { if (display_grabber) { Ref<Texture2D> grabber_tex; if (mouse_over_grabber) { - grabber_tex = get_theme_icon("grabber_highlight", "HSlider"); + grabber_tex = get_theme_icon(SNAME("grabber_highlight"), SNAME("HSlider")); } else { - grabber_tex = get_theme_icon("grabber", "HSlider"); + grabber_tex = get_theme_icon(SNAME("grabber"), SNAME("HSlider")); } if (grabber->get_texture() != grabber_tex) { @@ -383,10 +389,15 @@ void EditorSpinSlider::_notification(int p_what) { } } +LineEdit *EditorSpinSlider::get_line_edit() { + _ensure_input_popup(); + return value_input; +} + Size2 EditorSpinSlider::get_minimum_size() const { - Ref<StyleBox> sb = get_theme_stylebox("normal", "LineEdit"); - Ref<Font> font = get_theme_font("font", "LineEdit"); - int font_size = get_theme_font_size("font_size", "LineEdit"); + Ref<StyleBox> sb = get_theme_stylebox(SNAME("normal"), SNAME("LineEdit")); + Ref<Font> font = get_theme_font(SNAME("font"), SNAME("LineEdit")); + int font_size = get_theme_font_size(SNAME("font_size"), SNAME("LineEdit")); Size2 ms = sb->get_minimum_size(); ms.height += font->get_height(font_size); @@ -445,7 +456,9 @@ void EditorSpinSlider::_evaluate_input_text() { //text_submitted signal void EditorSpinSlider::_value_input_submitted(const String &p_text) { value_input_just_closed = true; - value_input_popup->hide(); + if (value_input_popup) { + value_input_popup->hide(); + } } //modal_closed signal @@ -457,7 +470,7 @@ void EditorSpinSlider::_value_input_closed() { //focus_exited signal void EditorSpinSlider::_value_focus_exited() { // discontinue because the focus_exit was caused by right-click context menu - if (value_input->get_menu()->is_visible()) { + if (value_input->is_menu_visible()) { return; } @@ -468,7 +481,9 @@ void EditorSpinSlider::_value_focus_exited() { // -> modal_close was not called // -> need to close/hide manually if (!value_input_just_closed) { //value_input_just_closed should do the same - value_input_popup->hide(); + if (value_input_popup) { + value_input_popup->hide(); + } //tab was pressed } else { //enter, click, esc @@ -509,13 +524,14 @@ void EditorSpinSlider::set_custom_label_color(bool p_use_custom_label_color, Col } void EditorSpinSlider::_focus_entered() { + _ensure_input_popup(); Rect2 gr = get_screen_rect(); value_input->set_text(get_text_value()); value_input_popup->set_position(gr.position); value_input_popup->set_size(gr.size); - value_input_popup->call_deferred("popup"); - value_input->call_deferred("grab_focus"); - value_input->call_deferred("select_all"); + value_input_popup->call_deferred(SNAME("popup")); + value_input->call_deferred(SNAME("grab_focus")); + value_input->call_deferred(SNAME("select_all")); value_input->set_focus_next(find_next_valid_focus()->get_path()); value_input->set_focus_previous(find_prev_valid_focus()->get_path()); } @@ -541,6 +557,23 @@ void EditorSpinSlider::_bind_methods() { ADD_PROPERTY(PropertyInfo(Variant::BOOL, "flat"), "set_flat", "is_flat"); } +void EditorSpinSlider::_ensure_input_popup() { + if (value_input_popup) { + return; + } + value_input_popup = memnew(Popup); + add_child(value_input_popup); + value_input = memnew(LineEdit); + value_input_popup->add_child(value_input); + value_input_popup->set_wrap_controls(true); + value_input->set_anchors_and_offsets_preset(PRESET_WIDE); + value_input_popup->connect("popup_hide", callable_mp(this, &EditorSpinSlider::_value_input_closed)); + value_input->connect("text_submitted", callable_mp(this, &EditorSpinSlider::_value_input_submitted)); + value_input->connect("focus_exited", callable_mp(this, &EditorSpinSlider::_value_focus_exited)); + if (is_inside_tree()) { + _update_value_input_stylebox(); + } +} EditorSpinSlider::EditorSpinSlider() { flat = false; grabbing_spinner_attempt = false; @@ -563,15 +596,6 @@ EditorSpinSlider::EditorSpinSlider() { mousewheel_over_grabber = false; grabbing_grabber = false; grabber_range = 1; - value_input_popup = memnew(Popup); - add_child(value_input_popup); - value_input = memnew(LineEdit); - value_input_popup->add_child(value_input); - value_input_popup->set_wrap_controls(true); - value_input->set_anchors_and_offsets_preset(PRESET_WIDE); - value_input_popup->connect("popup_hide", callable_mp(this, &EditorSpinSlider::_value_input_closed)); - value_input->connect("text_submitted", callable_mp(this, &EditorSpinSlider::_value_input_submitted)); - value_input->connect("focus_exited", callable_mp(this, &EditorSpinSlider::_value_focus_exited)); value_input_just_closed = false; hide_slider = false; read_only = false; diff --git a/editor/editor_spin_slider.h b/editor/editor_spin_slider.h index c30ff30390..5b99f88505 100644 --- a/editor/editor_spin_slider.h +++ b/editor/editor_spin_slider.h @@ -63,9 +63,9 @@ class EditorSpinSlider : public Range { Vector2 grabbing_spinner_mouse_pos; double pre_grab_value; - Popup *value_input_popup; - LineEdit *value_input; - bool value_input_just_closed; + Popup *value_input_popup = nullptr; + LineEdit *value_input = nullptr; + bool value_input_just_closed = false; void _grabber_gui_input(const Ref<InputEvent> &p_event); void _value_input_closed(); @@ -79,6 +79,9 @@ class EditorSpinSlider : public Range { void _evaluate_input_text(); + void _update_value_input_stylebox(); + void _ensure_input_popup(); + protected: void _notification(int p_what); void _gui_input(const Ref<InputEvent> &p_event); @@ -109,7 +112,7 @@ public: void set_custom_label_color(bool p_use_custom_label_color, Color p_custom_label_color); void setup_and_show() { _focus_entered(); } - LineEdit *get_line_edit() { return value_input; } + LineEdit *get_line_edit(); virtual Size2 get_minimum_size() const override; EditorSpinSlider(); diff --git a/editor/editor_themes.cpp b/editor/editor_themes.cpp index 986fc147f9..f0cc1530ab 100644 --- a/editor/editor_themes.cpp +++ b/editor/editor_themes.cpp @@ -380,6 +380,7 @@ Ref<Theme> create_editor_theme(const Ref<Theme> p_theme) { const Color font_color = mono_color.lerp(base_color, 0.25); const Color font_hover_color = mono_color.lerp(base_color, 0.125); const Color font_disabled_color = Color(mono_color.r, mono_color.g, mono_color.b, 0.3); + const Color font_readonly_color = Color(mono_color.r, mono_color.g, mono_color.b, 0.65); const Color selection_color = accent_color * Color(1, 1, 1, 0.4); const Color disabled_color = mono_color.inverted().lerp(base_color, 0.7); const Color disabled_bg_color = mono_color.inverted().lerp(base_color, 0.9); @@ -582,6 +583,10 @@ Ref<Theme> create_editor_theme(const Ref<Theme> p_theme) { // Focus theme->set_stylebox("Focus", "EditorStyles", style_widget_focus); + // Use a less opaque color to be less distracting for the 2D and 3D editor viewports. + Ref<StyleBoxFlat> style_widget_focus_viewport = style_widget_focus->duplicate(); + style_widget_focus_viewport->set_border_color(accent_color * Color(1, 1, 1, 0.5)); + theme->set_stylebox("FocusViewport", "EditorStyles", style_widget_focus_viewport); // Menu Ref<StyleBoxFlat> style_menu = style_widget->duplicate(); @@ -996,7 +1001,7 @@ Ref<Theme> create_editor_theme(const Ref<Theme> p_theme) { theme->set_stylebox("DebuggerPanel", "EditorStyles", style_panel_debugger); Ref<StyleBoxFlat> style_panel_invisible_top = style_content_panel->duplicate(); - int stylebox_offset = theme->get_font("tab_selected", "TabContainer")->get_height(theme->get_font_size("tab_selected", "TabContainer")) + theme->get_stylebox("tab_selected", "TabContainer")->get_minimum_size().height + theme->get_stylebox("panel", "TabContainer")->get_default_margin(SIDE_TOP); + int stylebox_offset = theme->get_font("tab_selected", "TabContainer")->get_height(theme->get_font_size("tab_selected", "TabContainer")) + theme->get_stylebox(SNAME("tab_selected"), SNAME("TabContainer"))->get_minimum_size().height + theme->get_stylebox(SNAME("panel"), SNAME("TabContainer"))->get_default_margin(SIDE_TOP); style_panel_invisible_top->set_expand_margin_size(SIDE_TOP, -stylebox_offset); style_panel_invisible_top->set_default_margin(SIDE_TOP, 0); theme->set_stylebox("BottomPanelDebuggerOverride", "EditorStyles", style_panel_invisible_top); @@ -1026,6 +1031,7 @@ Ref<Theme> create_editor_theme(const Ref<Theme> p_theme) { theme->set_color("read_only", "LineEdit", font_disabled_color); theme->set_color("font_color", "LineEdit", font_color); theme->set_color("font_selected_color", "LineEdit", mono_color); + theme->set_color("font_uneditable_color", "LineEdit", font_readonly_color); theme->set_color("caret_color", "LineEdit", font_color); theme->set_color("selection_color", "LineEdit", selection_color); theme->set_color("clear_button_color", "LineEdit", font_color); @@ -1085,17 +1091,16 @@ Ref<Theme> create_editor_theme(const Ref<Theme> p_theme) { style_window_title->set_corner_radius(CORNER_TOP_RIGHT, 0); // Prevent visible line between window title and body. style_window_title->set_expand_margin_size(SIDE_BOTTOM, 2 * EDSCALE); - theme->set_stylebox("panel", "Window", style_window_title); Ref<StyleBoxFlat> style_window = style_popup->duplicate(); style_window->set_border_color(base_color); style_window->set_border_width(SIDE_TOP, 24 * EDSCALE); style_window->set_expand_margin_size(SIDE_TOP, 24 * EDSCALE); - theme->set_stylebox("panel_window", "Window", style_window); + theme->set_stylebox("embedded_border", "Window", style_window); theme->set_color("title_color", "Window", font_color); theme->set_icon("close", "Window", theme->get_icon("GuiClose", "EditorIcons")); - theme->set_icon("close_highlight", "Window", theme->get_icon("GuiClose", "EditorIcons")); + theme->set_icon("close_pressed", "Window", theme->get_icon("GuiClose", "EditorIcons")); theme->set_constant("close_h_ofs", "Window", 22 * EDSCALE); theme->set_constant("close_v_ofs", "Window", 20 * EDSCALE); theme->set_constant("title_height", "Window", 24 * EDSCALE); @@ -1111,6 +1116,9 @@ Ref<Theme> create_editor_theme(const Ref<Theme> p_theme) { theme->set_stylebox("panel", "ProjectSettingsEditor", style_complex_window); theme->set_stylebox("panel", "EditorAbout", style_complex_window); + // AcceptDialog + theme->set_stylebox("panel", "AcceptDialog", style_window_title); + // HScrollBar Ref<Texture2D> empty_icon = memnew(ImageTexture); @@ -1189,7 +1197,7 @@ Ref<Theme> create_editor_theme(const Ref<Theme> p_theme) { style_tooltip->set_default_margin(SIDE_TOP, default_margin_size * EDSCALE * 0.5); style_tooltip->set_default_margin(SIDE_RIGHT, default_margin_size * EDSCALE); style_tooltip->set_default_margin(SIDE_BOTTOM, default_margin_size * EDSCALE * 0.5); - style_tooltip->set_bg_color(mono_color.inverted() * Color(1, 1, 1, 0.8)); + style_tooltip->set_bg_color(mono_color.inverted() * Color(1, 1, 1, 0.9)); style_tooltip->set_border_width_all(0); theme->set_color("font_color", "TooltipLabel", font_hover_color); theme->set_color("font_color_shadow", "TooltipLabel", Color(0, 0, 0, 0)); @@ -1365,6 +1373,10 @@ Ref<Theme> create_editor_theme(const Ref<Theme> p_theme) { theme_preview_picker_sb->set_border_color(accent_color); theme_preview_picker_sb->set_border_width_all(1.0 * EDSCALE); theme->set_stylebox("preview_picker_overlay", "ThemeEditor", theme_preview_picker_sb); + Color theme_preview_picker_label_bg_color = accent_color; + theme_preview_picker_label_bg_color.set_v(0.5); + Ref<StyleBoxFlat> theme_preview_picker_label_sb = make_flat_stylebox(theme_preview_picker_label_bg_color, 4.0, 1.0, 4.0, 3.0); + theme->set_stylebox("preview_picker_label", "ThemeEditor", theme_preview_picker_label_sb); // adaptive script theme constants // for comments and elements with lower relevance diff --git a/editor/editor_zoom_widget.cpp b/editor/editor_zoom_widget.cpp index 44751a480a..420aeb03fe 100644 --- a/editor/editor_zoom_widget.cpp +++ b/editor/editor_zoom_widget.cpp @@ -52,17 +52,17 @@ void EditorZoomWidget::_update_zoom_label() { void EditorZoomWidget::_button_zoom_minus() { set_zoom_by_increments(-6, Input::get_singleton()->is_key_pressed(KEY_ALT)); - emit_signal("zoom_changed", zoom); + emit_signal(SNAME("zoom_changed"), zoom); } void EditorZoomWidget::_button_zoom_reset() { set_zoom(1.0 * MAX(1, EDSCALE)); - emit_signal("zoom_changed", zoom); + emit_signal(SNAME("zoom_changed"), zoom); } void EditorZoomWidget::_button_zoom_plus() { set_zoom_by_increments(6, Input::get_singleton()->is_key_pressed(KEY_ALT)); - emit_signal("zoom_changed", zoom); + emit_signal(SNAME("zoom_changed"), zoom); } float EditorZoomWidget::get_zoom() { @@ -145,8 +145,8 @@ void EditorZoomWidget::_notification(int p_what) { switch (p_what) { case NOTIFICATION_ENTER_TREE: case NOTIFICATION_THEME_CHANGED: - zoom_minus->set_icon(get_theme_icon("ZoomLess", "EditorIcons")); - zoom_plus->set_icon(get_theme_icon("ZoomMore", "EditorIcons")); + zoom_minus->set_icon(get_theme_icon(SNAME("ZoomLess"), SNAME("EditorIcons"))); + zoom_plus->set_icon(get_theme_icon(SNAME("ZoomMore"), SNAME("EditorIcons"))); break; default: break; diff --git a/editor/export_template_manager.cpp b/editor/export_template_manager.cpp index 112a9e92a8..699957897f 100644 --- a/editor/export_template_manager.cpp +++ b/editor/export_template_manager.cpp @@ -106,8 +106,8 @@ void ExportTemplateManager::_update_template_status() { TreeItem *ti = installed_table->create_item(installed_root); ti->set_text(0, version_string); - ti->add_button(0, get_theme_icon("Folder", "EditorIcons"), OPEN_TEMPLATE_FOLDER, false, TTR("Open the folder containing these templates.")); - ti->add_button(0, get_theme_icon("Remove", "EditorIcons"), UNINSTALL_TEMPLATE, false, TTR("Uninstall these templates.")); + ti->add_button(0, get_theme_icon(SNAME("Folder"), SNAME("EditorIcons")), OPEN_TEMPLATE_FOLDER, false, TTR("Open the folder containing these templates.")); + ti->add_button(0, get_theme_icon(SNAME("Remove"), SNAME("EditorIcons")), UNINSTALL_TEMPLATE, false, TTR("Uninstall these templates.")); } } @@ -352,9 +352,9 @@ void ExportTemplateManager::_set_current_progress_status(const String &p_status, download_progress_label->set_text(p_status); if (p_error) { - download_progress_label->add_theme_color_override("font_color", get_theme_color("error_color", "Editor")); + download_progress_label->add_theme_color_override("font_color", get_theme_color(SNAME("error_color"), SNAME("Editor"))); } else { - download_progress_label->add_theme_color_override("font_color", get_theme_color("font_color", "Label")); + download_progress_label->add_theme_color_override("font_color", get_theme_color(SNAME("font_color"), SNAME("Label"))); } } @@ -630,6 +630,12 @@ bool ExportTemplateManager::can_install_android_template() { } Error ExportTemplateManager::install_android_template() { + const String &templates_path = EditorSettings::get_singleton()->get_templates_dir().plus_file(VERSION_FULL_CONFIG); + const String &source_zip = templates_path.plus_file("android_source.zip"); + ERR_FAIL_COND_V(!FileAccess::exists(source_zip), ERR_CANT_OPEN); + return install_android_template_from_file(source_zip); +} +Error ExportTemplateManager::install_android_template_from_file(const String &p_file) { // To support custom Android builds, we install the Java source code and buildsystem // from android_source.zip to the project's res://android folder. @@ -662,14 +668,10 @@ Error ExportTemplateManager::install_android_template() { // Uncompress source template. - const String &templates_path = EditorSettings::get_singleton()->get_templates_dir().plus_file(VERSION_FULL_CONFIG); - const String &source_zip = templates_path.plus_file("android_source.zip"); - ERR_FAIL_COND_V(!FileAccess::exists(source_zip), ERR_CANT_OPEN); - FileAccess *src_f = nullptr; zlib_filefunc_def io = zipio_create_io_from_file(&src_f); - unzFile pkg = unzOpen2(source_zip.utf8().get_data(), &io); + unzFile pkg = unzOpen2(p_file.utf8().get_data(), &io); ERR_FAIL_COND_V_MSG(!pkg, ERR_CANT_OPEN, "Android sources not in ZIP format."); int ret = unzGoToFirstFile(pkg); @@ -737,11 +739,11 @@ void ExportTemplateManager::_notification(int p_what) { switch (p_what) { case NOTIFICATION_ENTER_TREE: case NOTIFICATION_THEME_CHANGED: { - current_value->add_theme_font_override("font", get_theme_font("main", "EditorFonts")); - current_missing_label->add_theme_color_override("font_color", get_theme_color("error_color", "Editor")); - current_installed_label->add_theme_color_override("font_color", get_theme_color("disabled_font_color", "Editor")); + current_value->add_theme_font_override("font", get_theme_font(SNAME("main"), SNAME("EditorFonts"))); + current_missing_label->add_theme_color_override("font_color", get_theme_color(SNAME("error_color"), SNAME("Editor"))); + current_installed_label->add_theme_color_override("font_color", get_theme_color(SNAME("disabled_font_color"), SNAME("Editor"))); - mirror_options_button->set_icon(get_theme_icon("GuiTabMenu", "EditorIcons")); + mirror_options_button->set_icon(get_theme_icon(SNAME("GuiTabMenu"), SNAME("EditorIcons"))); } break; case NOTIFICATION_VISIBILITY_CHANGED: { diff --git a/editor/export_template_manager.h b/editor/export_template_manager.h index f145c6c0f5..ebadb88c36 100644 --- a/editor/export_template_manager.h +++ b/editor/export_template_manager.h @@ -124,6 +124,8 @@ public: bool can_install_android_template(); Error install_android_template(); + Error install_android_template_from_file(const String &p_file); + void popup_manager(); ExportTemplateManager(); diff --git a/editor/filesystem_dock.cpp b/editor/filesystem_dock.cpp index 3dc854d6bd..daee61c2dd 100644 --- a/editor/filesystem_dock.cpp +++ b/editor/filesystem_dock.cpp @@ -50,9 +50,9 @@ Ref<Texture2D> FileSystemDock::_get_tree_item_icon(bool p_is_valid, String p_file_type) { Ref<Texture2D> file_icon; if (!p_is_valid) { - file_icon = get_theme_icon("ImportFail", "EditorIcons"); + file_icon = get_theme_icon(SNAME("ImportFail"), SNAME("EditorIcons")); } else { - file_icon = (has_theme_icon(p_file_type, "EditorIcons")) ? get_theme_icon(p_file_type, "EditorIcons") : get_theme_icon("File", "EditorIcons"); + file_icon = (has_theme_icon(p_file_type, SNAME("EditorIcons"))) ? get_theme_icon(p_file_type, SNAME("EditorIcons")) : get_theme_icon(SNAME("File"), SNAME("EditorIcons")); } return file_icon; } @@ -69,8 +69,8 @@ bool FileSystemDock::_create_tree(TreeItem *p_parent, EditorFileSystemDirectory subdirectory_item->set_text(0, dname); subdirectory_item->set_structured_text_bidi_override(0, STRUCTURED_TEXT_FILE); - subdirectory_item->set_icon(0, get_theme_icon("Folder", "EditorIcons")); - subdirectory_item->set_icon_modulate(0, get_theme_color("folder_icon_modulate", "FileDialog")); + subdirectory_item->set_icon(0, get_theme_icon(SNAME("Folder"), SNAME("EditorIcons"))); + subdirectory_item->set_icon_modulate(0, get_theme_color(SNAME("folder_icon_modulate"), SNAME("FileDialog"))); subdirectory_item->set_selectable(0, true); String lpath = p_dir->get_path(); subdirectory_item->set_metadata(0, lpath); @@ -135,9 +135,7 @@ bool FileSystemDock::_create_tree(TreeItem *p_parent, EditorFileSystemDirectory _sort_file_info_list(file_list); // Build the tree. - for (List<FileInfo>::Element *E = file_list.front(); E; E = E->next()) { - FileInfo fi = E->get(); - + for (const FileInfo &fi : file_list) { TreeItem *file_item = tree->create_item(subdirectory_item); file_item->set_text(0, fi.name); file_item->set_structured_text_bidi_override(0, STRUCTURED_TEXT_FILE); @@ -149,7 +147,7 @@ bool FileSystemDock::_create_tree(TreeItem *p_parent, EditorFileSystemDirectory file_item->set_as_cursor(0); } if (main_scene == file_metadata) { - file_item->set_custom_color(0, get_theme_color("accent_color", "Editor")); + file_item->set_custom_color(0, get_theme_color(SNAME("accent_color"), SNAME("Editor"))); } Array udata; udata.push_back(tree_update_id); @@ -215,7 +213,7 @@ void FileSystemDock::_update_tree(const Vector<String> &p_uncollapsed_paths, boo // Handles the favorites. TreeItem *favorites = tree->create_item(root); - favorites->set_icon(0, get_theme_icon("Favorites", "EditorIcons")); + favorites->set_icon(0, get_theme_icon(SNAME("Favorites"), SNAME("EditorIcons"))); favorites->set_text(0, TTR("Favorites:")); favorites->set_metadata(0, "Favorites"); favorites->set_collapsed(p_uncollapsed_paths.find("Favorites") < 0); @@ -227,8 +225,8 @@ void FileSystemDock::_update_tree(const Vector<String> &p_uncollapsed_paths, boo continue; } - Ref<Texture2D> folder_icon = get_theme_icon("Folder", "EditorIcons"); - const Color folder_color = get_theme_color("folder_icon_modulate", "FileDialog"); + Ref<Texture2D> folder_icon = get_theme_icon(SNAME("Folder"), SNAME("EditorIcons")); + const Color folder_color = get_theme_color(SNAME("folder_icon_modulate"), SNAME("FileDialog")); String text; Ref<Texture2D> icon; @@ -248,7 +246,7 @@ void FileSystemDock::_update_tree(const Vector<String> &p_uncollapsed_paths, boo if (dir) { icon = _get_tree_item_icon(dir->get_file_import_is_valid(index), dir->get_file_type(index)); } else { - icon = get_theme_icon("File", "EditorIcons"); + icon = get_theme_icon(SNAME("File"), SNAME("EditorIcons")); } color = Color(1, 1, 1); } @@ -339,28 +337,28 @@ void FileSystemDock::_notification(int p_what) { String ei = "EditorIcons"; - button_reload->set_icon(get_theme_icon("Reload", ei)); - button_toggle_display_mode->set_icon(get_theme_icon("Panels2", ei)); + button_reload->set_icon(get_theme_icon(SNAME("Reload"), ei)); + button_toggle_display_mode->set_icon(get_theme_icon(SNAME("Panels2"), ei)); button_file_list_display_mode->connect("pressed", callable_mp(this, &FileSystemDock::_toggle_file_display)); files->connect("item_activated", callable_mp(this, &FileSystemDock::_file_list_activate_file)); button_hist_next->connect("pressed", callable_mp(this, &FileSystemDock::_fw_history)); button_hist_prev->connect("pressed", callable_mp(this, &FileSystemDock::_bw_history)); - tree_search_box->set_right_icon(get_theme_icon("Search", ei)); + tree_search_box->set_right_icon(get_theme_icon(SNAME("Search"), ei)); tree_search_box->set_clear_button_enabled(true); - tree_button_sort->set_icon(get_theme_icon("Sort", ei)); + tree_button_sort->set_icon(get_theme_icon(SNAME("Sort"), ei)); - file_list_search_box->set_right_icon(get_theme_icon("Search", ei)); + file_list_search_box->set_right_icon(get_theme_icon(SNAME("Search"), ei)); file_list_search_box->set_clear_button_enabled(true); - file_list_button_sort->set_icon(get_theme_icon("Sort", ei)); + file_list_button_sort->set_icon(get_theme_icon(SNAME("Sort"), ei)); if (is_layout_rtl()) { - button_hist_next->set_icon(get_theme_icon("Back", ei)); - button_hist_prev->set_icon(get_theme_icon("Forward", ei)); + button_hist_next->set_icon(get_theme_icon(SNAME("Back"), ei)); + button_hist_prev->set_icon(get_theme_icon(SNAME("Forward"), ei)); } else { - button_hist_next->set_icon(get_theme_icon("Forward", ei)); - button_hist_prev->set_icon(get_theme_icon("Back", ei)); + button_hist_next->set_icon(get_theme_icon(SNAME("Forward"), ei)); + button_hist_prev->set_icon(get_theme_icon(SNAME("Back"), ei)); } file_list_popup->connect("id_pressed", callable_mp(this, &FileSystemDock::_file_list_rmb_option)); tree_popup->connect("id_pressed", callable_mp(this, &FileSystemDock::_tree_rmb_option)); @@ -412,28 +410,28 @@ void FileSystemDock::_notification(int p_what) { case EditorSettings::NOTIFICATION_EDITOR_SETTINGS_CHANGED: { // Update icons. String ei = "EditorIcons"; - button_reload->set_icon(get_theme_icon("Reload", ei)); - button_toggle_display_mode->set_icon(get_theme_icon("Panels2", ei)); + button_reload->set_icon(get_theme_icon(SNAME("Reload"), ei)); + button_toggle_display_mode->set_icon(get_theme_icon(SNAME("Panels2"), ei)); if (is_layout_rtl()) { - button_hist_next->set_icon(get_theme_icon("Back", ei)); - button_hist_prev->set_icon(get_theme_icon("Forward", ei)); + button_hist_next->set_icon(get_theme_icon(SNAME("Back"), ei)); + button_hist_prev->set_icon(get_theme_icon(SNAME("Forward"), ei)); } else { - button_hist_next->set_icon(get_theme_icon("Forward", ei)); - button_hist_prev->set_icon(get_theme_icon("Back", ei)); + button_hist_next->set_icon(get_theme_icon(SNAME("Forward"), ei)); + button_hist_prev->set_icon(get_theme_icon(SNAME("Back"), ei)); } if (file_list_display_mode == FILE_LIST_DISPLAY_LIST) { - button_file_list_display_mode->set_icon(get_theme_icon("FileThumbnail", "EditorIcons")); + button_file_list_display_mode->set_icon(get_theme_icon(SNAME("FileThumbnail"), SNAME("EditorIcons"))); } else { - button_file_list_display_mode->set_icon(get_theme_icon("FileList", "EditorIcons")); + button_file_list_display_mode->set_icon(get_theme_icon(SNAME("FileList"), SNAME("EditorIcons"))); } - tree_search_box->set_right_icon(get_theme_icon("Search", ei)); + tree_search_box->set_right_icon(get_theme_icon(SNAME("Search"), ei)); tree_search_box->set_clear_button_enabled(true); - tree_button_sort->set_icon(get_theme_icon("Sort", ei)); + tree_button_sort->set_icon(get_theme_icon(SNAME("Sort"), ei)); - file_list_search_box->set_right_icon(get_theme_icon("Search", ei)); + file_list_search_box->set_right_icon(get_theme_icon(SNAME("Search"), ei)); file_list_search_box->set_clear_button_enabled(true); - file_list_button_sort->set_icon(get_theme_icon("Sort", ei)); + file_list_button_sort->set_icon(get_theme_icon(SNAME("Sort"), ei)); // Update always show folders. bool new_always_show_folders = bool(EditorSettings::get_singleton()->get("docks/filesystem/always_show_folders")); @@ -451,7 +449,7 @@ void FileSystemDock::_notification(int p_what) { void FileSystemDock::_tree_multi_selected(Object *p_item, int p_column, bool p_selected) { // Update the import dock. import_dock_needs_update = true; - call_deferred("_update_import_dock"); + call_deferred(SNAME("_update_import_dock")); // Return if we don't select something new. if (!p_selected) { @@ -581,17 +579,17 @@ void FileSystemDock::_tree_thumbnail_done(const String &p_path, const Ref<Textur void FileSystemDock::_toggle_file_display() { _set_file_display(file_list_display_mode != FILE_LIST_DISPLAY_LIST); - emit_signal("display_mode_changed"); + emit_signal(SNAME("display_mode_changed")); } void FileSystemDock::_set_file_display(bool p_active) { if (p_active) { file_list_display_mode = FILE_LIST_DISPLAY_LIST; - button_file_list_display_mode->set_icon(get_theme_icon("FileThumbnail", "EditorIcons")); + button_file_list_display_mode->set_icon(get_theme_icon(SNAME("FileThumbnail"), SNAME("EditorIcons"))); button_file_list_display_mode->set_tooltip(TTR("View items as a grid of thumbnails.")); } else { file_list_display_mode = FILE_LIST_DISPLAY_THUMBNAILS; - button_file_list_display_mode->set_icon(get_theme_icon("FileList", "EditorIcons")); + button_file_list_display_mode->set_icon(get_theme_icon(SNAME("FileList"), SNAME("EditorIcons"))); button_file_list_display_mode->set_tooltip(TTR("View items as a list.")); } @@ -733,13 +731,13 @@ void FileSystemDock::_update_file_list(bool p_keep_selection) { files->set_fixed_icon_size(Size2(thumbnail_size, thumbnail_size)); if (thumbnail_size < 64) { - folder_thumbnail = get_theme_icon("FolderMediumThumb", ei); - file_thumbnail = get_theme_icon("FileMediumThumb", ei); - file_thumbnail_broken = get_theme_icon("FileDeadMediumThumb", ei); + folder_thumbnail = get_theme_icon(SNAME("FolderMediumThumb"), ei); + file_thumbnail = get_theme_icon(SNAME("FileMediumThumb"), ei); + file_thumbnail_broken = get_theme_icon(SNAME("FileDeadMediumThumb"), ei); } else { - folder_thumbnail = get_theme_icon("FolderBigThumb", ei); - file_thumbnail = get_theme_icon("FileBigThumb", ei); - file_thumbnail_broken = get_theme_icon("FileDeadBigThumb", ei); + folder_thumbnail = get_theme_icon(SNAME("FolderBigThumb"), ei); + file_thumbnail = get_theme_icon(SNAME("FileBigThumb"), ei); + file_thumbnail_broken = get_theme_icon(SNAME("FileDeadBigThumb"), ei); } } else { // No thumbnails. @@ -750,8 +748,8 @@ void FileSystemDock::_update_file_list(bool p_keep_selection) { files->set_fixed_icon_size(Size2()); } - Ref<Texture2D> folder_icon = (use_thumbnails) ? folder_thumbnail : get_theme_icon("folder", "FileDialog"); - const Color folder_color = get_theme_color("folder_icon_modulate", "FileDialog"); + Ref<Texture2D> folder_icon = (use_thumbnails) ? folder_thumbnail : get_theme_icon(SNAME("folder"), SNAME("FileDialog")); + const Color folder_color = get_theme_color(SNAME("folder_icon_modulate"), SNAME("FileDialog")); // Build the FileInfo list. List<FileInfo> file_list; @@ -869,8 +867,8 @@ void FileSystemDock::_update_file_list(bool p_keep_selection) { // Fills the ItemList control node from the FileInfos. String main_scene = ProjectSettings::get_singleton()->get("application/run/main_scene"); String oi = "Object"; - for (List<FileInfo>::Element *E = file_list.front(); E; E = E->next()) { - FileInfo *finfo = &(E->get()); + for (FileInfo &E : file_list) { + FileInfo *finfo = &(E); String fname = finfo->name; String fpath = finfo->path; String ftype = finfo->type; @@ -885,7 +883,7 @@ void FileSystemDock::_update_file_list(bool p_keep_selection) { type_icon = (has_theme_icon(ftype, ei)) ? get_theme_icon(ftype, ei) : get_theme_icon(oi, ei); big_icon = file_thumbnail; } else { - type_icon = get_theme_icon("ImportFail", ei); + type_icon = get_theme_icon(SNAME("ImportFail"), ei); big_icon = file_thumbnail_broken; tooltip += "\n" + TTR("Status: Import of file failed. Please fix file and reimport manually."); } @@ -905,7 +903,7 @@ void FileSystemDock::_update_file_list(bool p_keep_selection) { } if (fpath == main_scene) { - files->set_item_custom_fg_color(item_index, get_theme_color("accent_color", "Editor")); + files->set_item_custom_fg_color(item_index, get_theme_color(SNAME("accent_color"), SNAME("Editor"))); } // Generate the preview. @@ -966,8 +964,8 @@ void FileSystemDock::_select_file(const String &p_path, bool p_select_in_favorit List<String> importer_exts; ResourceImporterScene::get_singleton()->get_recognized_extensions(&importer_exts); String extension = fpath.get_extension(); - for (List<String>::Element *E = importer_exts.front(); E; E = E->next()) { - if (extension.nocasecmp_to(E->get()) == 0) { + for (const String &E : importer_exts) { + if (extension.nocasecmp_to(E) == 0) { is_imported = true; break; } @@ -1189,11 +1187,11 @@ void FileSystemDock::_try_move_item(const FileOrFolder &p_item, const String &p_ for (int i = 0; i < file_changed_paths.size(); ++i) { p_file_renames[file_changed_paths[i]] = file_changed_paths[i].replace_first(old_path, new_path); print_verbose(" Remap: " + file_changed_paths[i] + " -> " + p_file_renames[file_changed_paths[i]]); - emit_signal("files_moved", file_changed_paths[i], p_file_renames[file_changed_paths[i]]); + emit_signal(SNAME("files_moved"), file_changed_paths[i], p_file_renames[file_changed_paths[i]]); } for (int i = 0; i < folder_changed_paths.size(); ++i) { p_folder_renames[folder_changed_paths[i]] = folder_changed_paths[i].replace_first(old_path, new_path); - emit_signal("folder_moved", folder_changed_paths[i], p_folder_renames[folder_changed_paths[i]].substr(0, p_folder_renames[folder_changed_paths[i]].length() - 1)); + emit_signal(SNAME("folder_moved"), folder_changed_paths[i], p_folder_renames[folder_changed_paths[i]].substr(0, p_folder_renames[folder_changed_paths[i]].length() - 1)); } } else { EditorNode::get_singleton()->add_io_error(TTR("Error moving:") + "\n" + old_path + "\n"); @@ -1239,9 +1237,7 @@ void FileSystemDock::_update_resource_paths_after_move(const Map<String, String> List<Ref<Resource>> cached; ResourceCache::get_cached_resources(&cached); - for (List<Ref<Resource>>::Element *E = cached.front(); E; E = E->next()) { - Ref<Resource> r = E->get(); - + for (Ref<Resource> &r : cached) { String base_path = r->get_path(); String extra_path; int sep_pos = r->get_path().find("::"); @@ -1317,16 +1313,16 @@ void FileSystemDock::_update_project_settings_after_move(const Map<String, Strin // Also search for the file in autoload, as they are stored differently from normal files. List<PropertyInfo> property_list; ProjectSettings::get_singleton()->get_property_list(&property_list); - for (const List<PropertyInfo>::Element *E = property_list.front(); E; E = E->next()) { - if (E->get().name.begins_with("autoload/")) { + for (const PropertyInfo &E : property_list) { + if (E.name.begins_with("autoload/")) { // If the autoload resource paths has a leading "*", it indicates that it is a Singleton, // so we have to handle both cases when updating. - String autoload = GLOBAL_GET(E->get().name); + String autoload = GLOBAL_GET(E.name); String autoload_singleton = autoload.substr(1, autoload.length()); if (p_renames.has(autoload)) { - ProjectSettings::get_singleton()->set_setting(E->get().name, p_renames[autoload]); + ProjectSettings::get_singleton()->set_setting(E.name, p_renames[autoload]); } else if (autoload.begins_with("*") && p_renames.has(autoload_singleton)) { - ProjectSettings::get_singleton()->set_setting(E->get().name, "*" + p_renames[autoload_singleton]); + ProjectSettings::get_singleton()->set_setting(E.name, "*" + p_renames[autoload_singleton]); } } } @@ -1417,8 +1413,8 @@ void FileSystemDock::_make_scene_confirm() { ResourceSaver::get_recognized_extensions(sd, &extensions); bool extension_correct = false; - for (List<String>::Element *E = extensions.front(); E; E = E->next()) { - if (E->get() == extension) { + for (const String &E : extensions) { + if (E == extension) { extension_correct = true; break; } @@ -1442,7 +1438,7 @@ void FileSystemDock::_make_scene_confirm() { } void FileSystemDock::_file_removed(String p_file) { - emit_signal("file_removed", p_file); + emit_signal(SNAME("file_removed"), p_file); // Find the closest parent directory available, in case multiple items were deleted along the same path. path = p_file.get_base_dir(); @@ -1455,7 +1451,7 @@ void FileSystemDock::_file_removed(String p_file) { } void FileSystemDock::_folder_removed(String p_folder) { - emit_signal("folder_removed", p_folder); + emit_signal(SNAME("folder_removed"), p_folder); // Find the closest parent directory available, in case multiple items were deleted along the same path. path = p_folder.get_base_dir(); @@ -1762,7 +1758,7 @@ void FileSystemDock::_file_option(int p_option, const Vector<String> &p_selected case FILE_INHERIT: { // Create a new scene inherited from the selected one. if (p_selected.size() == 1) { - emit_signal("inherit", p_selected[0]); + emit_signal(SNAME("inherit"), p_selected[0]); } } break; @@ -1786,7 +1782,7 @@ void FileSystemDock::_file_option(int p_option, const Vector<String> &p_selected } } if (!paths.is_empty()) { - emit_signal("instance", paths); + emit_signal(SNAME("instance"), paths); } } break; @@ -2019,7 +2015,7 @@ void FileSystemDock::_rescan() { void FileSystemDock::_toggle_split_mode(bool p_active) { set_display_mode(p_active ? DISPLAY_MODE_SPLIT : DISPLAY_MODE_TREE_ONLY); - emit_signal("display_mode_changed"); + emit_signal(SNAME("display_mode_changed")); } void FileSystemDock::fix_dependencies(const String &p_for_file) { @@ -2404,28 +2400,28 @@ void FileSystemDock::_file_and_folders_fill_popup(PopupMenu *p_popup, Vector<Str if (all_files) { if (all_files_scenes) { if (filenames.size() == 1) { - p_popup->add_icon_item(get_theme_icon("Load", "EditorIcons"), TTR("Open Scene"), FILE_OPEN); - p_popup->add_icon_item(get_theme_icon("CreateNewSceneFrom", "EditorIcons"), TTR("New Inherited Scene"), FILE_INHERIT); + p_popup->add_icon_item(get_theme_icon(SNAME("Load"), SNAME("EditorIcons")), TTR("Open Scene"), FILE_OPEN); + p_popup->add_icon_item(get_theme_icon(SNAME("CreateNewSceneFrom"), SNAME("EditorIcons")), TTR("New Inherited Scene"), FILE_INHERIT); if (ProjectSettings::get_singleton()->get("application/run/main_scene") != filenames[0]) { - p_popup->add_icon_item(get_theme_icon("PlayScene", "EditorIcons"), TTR("Set As Main Scene"), FILE_MAIN_SCENE); + p_popup->add_icon_item(get_theme_icon(SNAME("PlayScene"), SNAME("EditorIcons")), TTR("Set As Main Scene"), FILE_MAIN_SCENE); } } else { - p_popup->add_icon_item(get_theme_icon("Load", "EditorIcons"), TTR("Open Scenes"), FILE_OPEN); + p_popup->add_icon_item(get_theme_icon(SNAME("Load"), SNAME("EditorIcons")), TTR("Open Scenes"), FILE_OPEN); } - p_popup->add_icon_item(get_theme_icon("Instance", "EditorIcons"), TTR("Instance"), FILE_INSTANCE); + p_popup->add_icon_item(get_theme_icon(SNAME("Instance"), SNAME("EditorIcons")), TTR("Instance"), FILE_INSTANCE); p_popup->add_separator(); } else if (filenames.size() == 1) { - p_popup->add_icon_item(get_theme_icon("Load", "EditorIcons"), TTR("Open"), FILE_OPEN); + p_popup->add_icon_item(get_theme_icon(SNAME("Load"), SNAME("EditorIcons")), TTR("Open"), FILE_OPEN); p_popup->add_separator(); } } if (p_paths.size() >= 1) { if (!all_favorites) { - p_popup->add_icon_item(get_theme_icon("Favorites", "EditorIcons"), TTR("Add to Favorites"), FILE_ADD_FAVORITE); + p_popup->add_icon_item(get_theme_icon(SNAME("Favorites"), SNAME("EditorIcons")), TTR("Add to Favorites"), FILE_ADD_FAVORITE); } if (!all_not_favorites) { - p_popup->add_icon_item(get_theme_icon("NonFavorite", "EditorIcons"), TTR("Remove from Favorites"), FILE_REMOVE_FAVORITE); + p_popup->add_icon_item(get_theme_icon(SNAME("NonFavorite"), SNAME("EditorIcons")), TTR("Remove from Favorites"), FILE_REMOVE_FAVORITE); } p_popup->add_separator(); } @@ -2438,36 +2434,36 @@ void FileSystemDock::_file_and_folders_fill_popup(PopupMenu *p_popup, Vector<Str } } else if (all_folders && foldernames.size() > 0) { - p_popup->add_icon_item(get_theme_icon("Load", "EditorIcons"), TTR("Open"), FILE_OPEN); + p_popup->add_icon_item(get_theme_icon(SNAME("Load"), SNAME("EditorIcons")), TTR("Open"), FILE_OPEN); p_popup->add_separator(); } if (p_paths.size() == 1) { - p_popup->add_icon_shortcut(get_theme_icon("ActionCopy", "EditorIcons"), ED_GET_SHORTCUT("filesystem_dock/copy_path"), FILE_COPY_PATH); + p_popup->add_icon_shortcut(get_theme_icon(SNAME("ActionCopy"), SNAME("EditorIcons")), ED_GET_SHORTCUT("filesystem_dock/copy_path"), FILE_COPY_PATH); if (p_paths[0] != "res://") { - p_popup->add_icon_shortcut(get_theme_icon("Rename", "EditorIcons"), ED_GET_SHORTCUT("filesystem_dock/rename"), FILE_RENAME); - p_popup->add_icon_shortcut(get_theme_icon("Duplicate", "EditorIcons"), ED_GET_SHORTCUT("filesystem_dock/duplicate"), FILE_DUPLICATE); + p_popup->add_icon_shortcut(get_theme_icon(SNAME("Rename"), SNAME("EditorIcons")), ED_GET_SHORTCUT("filesystem_dock/rename"), FILE_RENAME); + p_popup->add_icon_shortcut(get_theme_icon(SNAME("Duplicate"), SNAME("EditorIcons")), ED_GET_SHORTCUT("filesystem_dock/duplicate"), FILE_DUPLICATE); } } if (p_paths.size() > 1 || p_paths[0] != "res://") { - p_popup->add_icon_item(get_theme_icon("MoveUp", "EditorIcons"), TTR("Move To..."), FILE_MOVE); - p_popup->add_icon_shortcut(get_theme_icon("Remove", "EditorIcons"), ED_GET_SHORTCUT("filesystem_dock/delete"), FILE_REMOVE); + p_popup->add_icon_item(get_theme_icon(SNAME("MoveUp"), SNAME("EditorIcons")), TTR("Move To..."), FILE_MOVE); + p_popup->add_icon_shortcut(get_theme_icon(SNAME("Remove"), SNAME("EditorIcons")), ED_GET_SHORTCUT("filesystem_dock/delete"), FILE_REMOVE); } if (p_paths.size() == 1) { p_popup->add_separator(); if (p_display_path_dependent_options) { - p_popup->add_icon_item(get_theme_icon("Folder", "EditorIcons"), TTR("New Folder..."), FILE_NEW_FOLDER); - p_popup->add_icon_item(get_theme_icon("PackedScene", "EditorIcons"), TTR("New Scene..."), FILE_NEW_SCENE); - p_popup->add_icon_item(get_theme_icon("Script", "EditorIcons"), TTR("New Script..."), FILE_NEW_SCRIPT); - p_popup->add_icon_item(get_theme_icon("Object", "EditorIcons"), TTR("New Resource..."), FILE_NEW_RESOURCE); + p_popup->add_icon_item(get_theme_icon(SNAME("Folder"), SNAME("EditorIcons")), TTR("New Folder..."), FILE_NEW_FOLDER); + p_popup->add_icon_item(get_theme_icon(SNAME("PackedScene"), SNAME("EditorIcons")), TTR("New Scene..."), FILE_NEW_SCENE); + p_popup->add_icon_item(get_theme_icon(SNAME("Script"), SNAME("EditorIcons")), TTR("New Script..."), FILE_NEW_SCRIPT); + p_popup->add_icon_item(get_theme_icon(SNAME("Object"), SNAME("EditorIcons")), TTR("New Resource..."), FILE_NEW_RESOURCE); p_popup->add_separator(); } String fpath = p_paths[0]; String item_text = fpath.ends_with("/") ? TTR("Open in File Manager") : TTR("Show in File Manager"); - p_popup->add_icon_item(get_theme_icon("Filesystem", "EditorIcons"), item_text, FILE_SHOW_IN_EXPLORER); + p_popup->add_icon_item(get_theme_icon(SNAME("Filesystem"), SNAME("EditorIcons")), item_text, FILE_SHOW_IN_EXPLORER); } } @@ -2478,8 +2474,8 @@ void FileSystemDock::_tree_rmb_select(const Vector2 &p_pos) { tree_popup->clear(); if (paths.size() == 1) { if (paths[0].ends_with("/")) { - tree_popup->add_icon_item(get_theme_icon("GuiTreeArrowDown", "EditorIcons"), TTR("Expand All"), FOLDER_EXPAND_ALL); - tree_popup->add_icon_item(get_theme_icon("GuiTreeArrowRight", "EditorIcons"), TTR("Collapse All"), FOLDER_COLLAPSE_ALL); + tree_popup->add_icon_item(get_theme_icon(SNAME("GuiTreeArrowDown"), SNAME("EditorIcons")), TTR("Expand All"), FOLDER_EXPAND_ALL); + tree_popup->add_icon_item(get_theme_icon(SNAME("GuiTreeArrowRight"), SNAME("EditorIcons")), TTR("Collapse All"), FOLDER_COLLAPSE_ALL); tree_popup->add_separator(); } } @@ -2498,10 +2494,10 @@ void FileSystemDock::_tree_rmb_empty(const Vector2 &p_pos) { path = "res://"; tree_popup->clear(); tree_popup->set_size(Size2(1, 1)); - tree_popup->add_icon_item(get_theme_icon("Folder", "EditorIcons"), TTR("New Folder..."), FILE_NEW_FOLDER); - tree_popup->add_icon_item(get_theme_icon("PackedScene", "EditorIcons"), TTR("New Scene..."), FILE_NEW_SCENE); - tree_popup->add_icon_item(get_theme_icon("Script", "EditorIcons"), TTR("New Script..."), FILE_NEW_SCRIPT); - tree_popup->add_icon_item(get_theme_icon("Object", "EditorIcons"), TTR("New Resource..."), FILE_NEW_RESOURCE); + tree_popup->add_icon_item(get_theme_icon(SNAME("Folder"), SNAME("EditorIcons")), TTR("New Folder..."), FILE_NEW_FOLDER); + tree_popup->add_icon_item(get_theme_icon(SNAME("PackedScene"), SNAME("EditorIcons")), TTR("New Scene..."), FILE_NEW_SCENE); + tree_popup->add_icon_item(get_theme_icon(SNAME("Script"), SNAME("EditorIcons")), TTR("New Script..."), FILE_NEW_SCRIPT); + tree_popup->add_icon_item(get_theme_icon(SNAME("Object"), SNAME("EditorIcons")), TTR("New Resource..."), FILE_NEW_RESOURCE); tree_popup->set_position(tree->get_global_position() + p_pos); tree_popup->popup(); } @@ -2543,12 +2539,12 @@ void FileSystemDock::_file_list_rmb_pressed(const Vector2 &p_pos) { file_list_popup->clear(); file_list_popup->set_size(Size2(1, 1)); - file_list_popup->add_icon_item(get_theme_icon("Folder", "EditorIcons"), TTR("New Folder..."), FILE_NEW_FOLDER); - file_list_popup->add_icon_item(get_theme_icon("PackedScene", "EditorIcons"), TTR("New Scene..."), FILE_NEW_SCENE); - file_list_popup->add_icon_item(get_theme_icon("Script", "EditorIcons"), TTR("New Script..."), FILE_NEW_SCRIPT); - file_list_popup->add_icon_item(get_theme_icon("Object", "EditorIcons"), TTR("New Resource..."), FILE_NEW_RESOURCE); + file_list_popup->add_icon_item(get_theme_icon(SNAME("Folder"), SNAME("EditorIcons")), TTR("New Folder..."), FILE_NEW_FOLDER); + file_list_popup->add_icon_item(get_theme_icon(SNAME("PackedScene"), SNAME("EditorIcons")), TTR("New Scene..."), FILE_NEW_SCENE); + file_list_popup->add_icon_item(get_theme_icon(SNAME("Script"), SNAME("EditorIcons")), TTR("New Script..."), FILE_NEW_SCRIPT); + file_list_popup->add_icon_item(get_theme_icon(SNAME("Object"), SNAME("EditorIcons")), TTR("New Resource..."), FILE_NEW_RESOURCE); file_list_popup->add_separator(); - file_list_popup->add_icon_item(get_theme_icon("Filesystem", "EditorIcons"), TTR("Open in File Manager"), FILE_SHOW_IN_EXPLORER); + file_list_popup->add_icon_item(get_theme_icon(SNAME("Filesystem"), SNAME("EditorIcons")), TTR("Open in File Manager"), FILE_SHOW_IN_EXPLORER); file_list_popup->set_position(files->get_global_position() + p_pos); file_list_popup->popup(); } @@ -2572,7 +2568,7 @@ void FileSystemDock::_file_multi_selected(int p_index, bool p_selected) { // Update the import dock. import_dock_needs_update = true; - call_deferred("_update_import_dock"); + call_deferred(SNAME("_update_import_dock")); } void FileSystemDock::_tree_gui_input(Ref<InputEvent> p_event) { diff --git a/editor/find_in_files.cpp b/editor/find_in_files.cpp index cb8de09a9a..9444706fd2 100644 --- a/editor/find_in_files.cpp +++ b/editor/find_in_files.cpp @@ -116,12 +116,12 @@ void FindInFiles::_notification(int p_notification) { void FindInFiles::start() { if (_pattern == "") { print_verbose("Nothing to search, pattern is empty"); - emit_signal(SIGNAL_FINISHED); + emit_signal(SNAME(SIGNAL_FINISHED)); return; } if (_extension_filter.size() == 0) { print_verbose("Nothing to search, filter matches no files"); - emit_signal(SIGNAL_FINISHED); + emit_signal(SNAME(SIGNAL_FINISHED)); return; } @@ -201,7 +201,7 @@ void FindInFiles::_iterate() { set_process(false); _current_dir = ""; _searching = false; - emit_signal(SIGNAL_FINISHED); + emit_signal(SNAME(SIGNAL_FINISHED)); } } @@ -228,6 +228,11 @@ void FindInFiles::_scan_dir(String path, PackedStringArray &out_folders) { break; } + // If there is a .gdignore file in the directory, don't bother searching it + if (file == ".gdignore") { + break; + } + // Ignore special dirs (such as .git and .import) if (file == "." || file == ".." || file.begins_with(".")) { continue; @@ -267,7 +272,7 @@ void FindInFiles::_scan_file(String fpath) { String line = f->get_line(); while (find_next(line, _pattern, end, _match_case, _whole_words, begin, end)) { - emit_signal(SIGNAL_RESULT_FOUND, fpath, line_number, begin, end, line); + emit_signal(SNAME(SIGNAL_RESULT_FOUND), fpath, line_number, begin, end, line); } } @@ -457,7 +462,7 @@ void FindInFilesDialog::_notification(int p_what) { if (p_what == NOTIFICATION_VISIBILITY_CHANGED) { if (is_visible()) { // Doesn't work more than once if not deferred... - _search_text_line_edit->call_deferred("grab_focus"); + _search_text_line_edit->call_deferred(SNAME("grab_focus")); _search_text_line_edit->select_all(); // Extensions might have changed in the meantime, we clean them and instance them again. for (int i = 0; i < _filters_container->get_child_count(); i++) { @@ -487,10 +492,10 @@ void FindInFilesDialog::custom_action(const String &p_action) { _filters_preferences[cb->get_text()] = cb->is_pressed(); } if (p_action == "find") { - emit_signal(SIGNAL_FIND_REQUESTED); + emit_signal(SNAME(SIGNAL_FIND_REQUESTED)); hide(); } else if (p_action == "replace") { - emit_signal(SIGNAL_REPLACE_REQUESTED); + emit_signal(SNAME(SIGNAL_REPLACE_REQUESTED)); hide(); } } @@ -565,8 +570,8 @@ FindInFilesPanel::FindInFilesPanel() { hbc->add_child(find_label); _search_text_label = memnew(Label); - _search_text_label->add_theme_font_override("font", EditorNode::get_singleton()->get_gui_base()->get_theme_font("source", "EditorFonts")); - _search_text_label->add_theme_font_size_override("font_size", EditorNode::get_singleton()->get_gui_base()->get_theme_font_size("source_size", "EditorFonts")); + _search_text_label->add_theme_font_override("font", EditorNode::get_singleton()->get_gui_base()->get_theme_font(SNAME("source"), SNAME("EditorFonts"))); + _search_text_label->add_theme_font_size_override("font_size", EditorNode::get_singleton()->get_gui_base()->get_theme_font_size(SNAME("source_size"), SNAME("EditorFonts"))); hbc->add_child(_search_text_label); _progress_bar = memnew(ProgressBar); @@ -594,8 +599,8 @@ FindInFilesPanel::FindInFilesPanel() { } _results_display = memnew(Tree); - _results_display->add_theme_font_override("font", EditorNode::get_singleton()->get_gui_base()->get_theme_font("source", "EditorFonts")); - _results_display->add_theme_font_size_override("font_size", EditorNode::get_singleton()->get_gui_base()->get_theme_font_size("source_size", "EditorFonts")); + _results_display->add_theme_font_override("font", EditorNode::get_singleton()->get_gui_base()->get_theme_font(SNAME("source"), SNAME("EditorFonts"))); + _results_display->add_theme_font_size_override("font_size", EditorNode::get_singleton()->get_gui_base()->get_theme_font_size(SNAME("source_size"), SNAME("EditorFonts"))); _results_display->set_v_size_flags(SIZE_EXPAND_FILL); _results_display->connect("item_selected", callable_mp(this, &FindInFilesPanel::_on_result_selected)); _results_display->connect("item_edited", callable_mp(this, &FindInFilesPanel::_on_item_edited)); @@ -688,8 +693,8 @@ void FindInFilesPanel::_notification(int p_what) { if (p_what == NOTIFICATION_PROCESS) { _progress_bar->set_as_ratio(_finder->get_progress()); } else if (p_what == NOTIFICATION_THEME_CHANGED) { - _search_text_label->add_theme_font_override("font", get_theme_font("source", "EditorFonts")); - _results_display->add_theme_font_override("font", get_theme_font("source", "EditorFonts")); + _search_text_label->add_theme_font_override("font", get_theme_font(SNAME("source"), SNAME("EditorFonts"))); + _results_display->add_theme_font_override("font", get_theme_font(SNAME("source"), SNAME("EditorFonts"))); } } @@ -754,8 +759,8 @@ void FindInFilesPanel::draw_result_text(Object *item_obj, Rect2 rect) { } Result r = E->value(); String item_text = item->get_text(_with_replace ? 1 : 0); - Ref<Font> font = _results_display->get_theme_font("font"); - int font_size = _results_display->get_theme_font_size("font_size"); + Ref<Font> font = _results_display->get_theme_font(SNAME("font")); + int font_size = _results_display->get_theme_font_size(SNAME("font_size")); Rect2 match_rect = rect; match_rect.position.x += font->get_string_size(item_text.left(r.begin_trimmed), font_size).x; @@ -764,7 +769,7 @@ void FindInFilesPanel::draw_result_text(Object *item_obj, Rect2 rect) { match_rect.size.y -= 2 * EDSCALE; // Use the inverted accent color to help match rectangles stand out even on the currently selected line. - _results_display->draw_rect(match_rect, get_theme_color("accent_color", "Editor").inverted() * Color(1, 1, 1, 0.5)); + _results_display->draw_rect(match_rect, get_theme_color(SNAME("accent_color"), SNAME("Editor")).inverted() * Color(1, 1, 1, 0.5)); // Text is drawn by Tree already. } @@ -773,11 +778,11 @@ void FindInFilesPanel::_on_item_edited() { TreeItem *item = _results_display->get_selected(); if (item->is_checked(0)) { - item->set_custom_color(1, _results_display->get_theme_color("font_color")); + item->set_custom_color(1, _results_display->get_theme_color(SNAME("font_color"))); } else { // Grey out - Color color = _results_display->get_theme_color("font_color"); + Color color = _results_display->get_theme_color(SNAME("font_color")); color.a /= 2.0; item->set_custom_color(1, color); } @@ -823,7 +828,7 @@ void FindInFilesPanel::_on_result_selected() { TreeItem *file_item = item->get_parent(); String fpath = file_item->get_metadata(0); - emit_signal(SIGNAL_RESULT_SELECTED, fpath, r.line_number, r.begin, r.end); + emit_signal(SNAME(SIGNAL_RESULT_SELECTED), fpath, r.line_number, r.begin, r.end); } void FindInFilesPanel::_on_replace_text_changed(String text) { @@ -860,7 +865,7 @@ void FindInFilesPanel::_on_replace_all_clicked() { // Hide replace bar so we can't trigger the action twice without doing a new search _replace_container->hide(); - emit_signal(SIGNAL_FILES_MODIFIED, modified_files); + emit_signal(SNAME(SIGNAL_FILES_MODIFIED), modified_files); } // Same as get_line, but preserves line ending characters diff --git a/editor/groups_editor.cpp b/editor/groups_editor.cpp index 76fbee7490..113306fc8a 100644 --- a/editor/groups_editor.cpp +++ b/editor/groups_editor.cpp @@ -94,7 +94,7 @@ void GroupDialog::_load_nodes(Node *p_current) { if (!_can_edit(p_current, selected_group)) { node->set_selectable(0, false); - node->set_custom_color(0, groups->get_theme_color("disabled_font_color", "Editor")); + node->set_custom_color(0, groups->get_theme_color(SNAME("disabled_font_color"), SNAME("Editor"))); } } @@ -204,7 +204,7 @@ void GroupDialog::_add_group(String p_name) { TreeItem *new_group = groups->create_item(groups_root); new_group->set_text(0, name); - new_group->add_button(0, groups->get_theme_icon("Remove", "EditorIcons"), 0); + new_group->add_button(0, groups->get_theme_icon(SNAME("Remove"), SNAME("EditorIcons")), 0); new_group->set_editable(0, true); new_group->select(0); groups->ensure_cursor_is_visible(); @@ -240,8 +240,7 @@ void GroupDialog::_group_renamed() { List<Node *> nodes; scene_tree->get_nodes_in_group(selected_group, &nodes); bool removed_all = true; - for (List<Node *>::Element *E = nodes.front(); E; E = E->next()) { - Node *node = E->get(); + for (Node *node : nodes) { if (_can_edit(node, selected_group)) { undo_redo->add_do_method(node, "remove_from_group", selected_group); undo_redo->add_undo_method(node, "remove_from_group", name); @@ -286,11 +285,11 @@ void GroupDialog::_load_groups(Node *p_current) { List<Node::GroupInfo> gi; p_current->get_groups(&gi); - for (List<Node::GroupInfo>::Element *E = gi.front(); E; E = E->next()) { - if (!E->get().persistent) { + for (const Node::GroupInfo &E : gi) { + if (!E.persistent) { continue; } - _add_group(E->get().name); + _add_group(E.name); } for (int i = 0; i < p_current->get_child_count(); i++) { @@ -311,10 +310,10 @@ void GroupDialog::_delete_group_pressed(Object *p_item, int p_column, int p_id) List<Node *> nodes; scene_tree->get_nodes_in_group(name, &nodes); bool removed_all = true; - for (List<Node *>::Element *E = nodes.front(); E; E = E->next()) { - if (_can_edit(E->get(), name)) { - undo_redo->add_do_method(E->get(), "remove_from_group", name); - undo_redo->add_undo_method(E->get(), "add_to_group", name, true); + for (Node *E : nodes) { + if (_can_edit(E, name)) { + undo_redo->add_do_method(E, "remove_from_group", name); + undo_redo->add_undo_method(E, "add_to_group", name, true); } else { removed_all = false; } @@ -365,16 +364,16 @@ void GroupDialog::_notification(int p_what) { case Control::NOTIFICATION_LAYOUT_DIRECTION_CHANGED: case NOTIFICATION_ENTER_TREE: { if (is_layout_rtl()) { - add_button->set_icon(groups->get_theme_icon("Back", "EditorIcons")); - remove_button->set_icon(groups->get_theme_icon("Forward", "EditorIcons")); + add_button->set_icon(groups->get_theme_icon(SNAME("Back"), SNAME("EditorIcons"))); + remove_button->set_icon(groups->get_theme_icon(SNAME("Forward"), SNAME("EditorIcons"))); } else { - add_button->set_icon(groups->get_theme_icon("Forward", "EditorIcons")); - remove_button->set_icon(groups->get_theme_icon("Back", "EditorIcons")); + add_button->set_icon(groups->get_theme_icon(SNAME("Forward"), SNAME("EditorIcons"))); + remove_button->set_icon(groups->get_theme_icon(SNAME("Back"), SNAME("EditorIcons"))); } - add_filter->set_right_icon(groups->get_theme_icon("Search", "EditorIcons")); + add_filter->set_right_icon(groups->get_theme_icon(SNAME("Search"), SNAME("EditorIcons"))); add_filter->set_clear_button_enabled(true); - remove_filter->set_right_icon(groups->get_theme_icon("Search", "EditorIcons")); + remove_filter->set_right_icon(groups->get_theme_icon(SNAME("Search"), SNAME("EditorIcons"))); remove_filter->set_clear_button_enabled(true); } break; } @@ -628,8 +627,7 @@ void GroupsEditor::update_tree() { TreeItem *root = tree->create_item(); - for (List<GroupInfo>::Element *E = groups.front(); E; E = E->next()) { - Node::GroupInfo gi = E->get(); + for (const GroupInfo &gi : groups) { if (!gi.persistent) { continue; } @@ -655,7 +653,7 @@ void GroupsEditor::update_tree() { TreeItem *item = tree->create_item(root); item->set_text(0, gi.name); if (can_be_deleted) { - item->add_button(0, get_theme_icon("Remove", "EditorIcons"), 0); + item->add_button(0, get_theme_icon(SNAME("Remove"), SNAME("EditorIcons")), 0); } else { item->set_selectable(0, false); } diff --git a/editor/icons/ImmediateGeometry3D.svg b/editor/icons/ImmediateGeometry3D.svg deleted file mode 100644 index ec5a392a68..0000000000 --- a/editor/icons/ImmediateGeometry3D.svg +++ /dev/null @@ -1 +0,0 @@ -<svg height="16" viewBox="0 0 16 16" width="16" xmlns="http://www.w3.org/2000/svg"><path d="m2.9208 1046.4c-.26373.3-.4204.7296-.4204 1.2383 0 1.6277-3.1381-.1781-.33757 2.6703.88382.899 2.6544.6701 3.5382-.2288.88384-.899.88382-2.3565 0-3.2554-1.1002-1.1191-2.2001-1.0845-2.7803-.4244zm2.3802-1.6103 2.4005 2.4416 6.8014-6.9177c.66286-.6742.66286-1.7673 0-2.4415-.66288-.6741-1.7376-.6741-2.4005 0z" fill="#fc7f7f" transform="translate(0 -1036.4)"/></svg> diff --git a/editor/icons/TripleBar.svg b/editor/icons/TripleBar.svg new file mode 100644 index 0000000000..2b521e6c15 --- /dev/null +++ b/editor/icons/TripleBar.svg @@ -0,0 +1 @@ +<svg width="16" height="16" viewBox="0 0 16 16" xmlns="http://www.w3.org/2000/svg"><path d="m1.9375 4h12.062zm0 4h12.062zm0 4h12.062z" fill="none" stroke="#e0e0e0" stroke-opacity=".99608" stroke-width=".92823"/></svg> diff --git a/editor/import/editor_import_collada.cpp b/editor/import/editor_import_collada.cpp index ddf89f077b..b615c73422 100644 --- a/editor/import/editor_import_collada.cpp +++ b/editor/import/editor_import_collada.cpp @@ -894,8 +894,8 @@ Error ColladaImport::_create_mesh_surfaces(bool p_optimize, Ref<EditorSceneImpor surftool->add_vertex(vertex_array[k].vertex); } - for (List<int>::Element *E = indices_list.front(); E; E = E->next()) { - surftool->add_index(E->get()); + for (int &E : indices_list) { + surftool->add_index(E); } if (!normal_src) { diff --git a/editor/import/editor_importer_bake_reset.cpp b/editor/import/editor_importer_bake_reset.cpp new file mode 100644 index 0000000000..939c47faa4 --- /dev/null +++ b/editor/import/editor_importer_bake_reset.cpp @@ -0,0 +1,223 @@ +/*************************************************************************/ +/* editor_importer_bake_reset.cpp */ +/*************************************************************************/ +/* This file is part of: */ +/* GODOT ENGINE */ +/* https://godotengine.org */ +/*************************************************************************/ +/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2021 Godot Engine contributors (cf. AUTHORS.md). */ +/* */ +/* 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. */ +/*************************************************************************/ + +#include "editor/import/editor_importer_bake_reset.h" + +#include "core/error/error_macros.h" +#include "core/math/transform_3d.h" +#include "editor/import/scene_importer_mesh_node_3d.h" +#include "resource_importer_scene.h" +#include "scene/3d/mesh_instance_3d.h" +#include "scene/3d/node_3d.h" +#include "scene/3d/skeleton_3d.h" +#include "scene/animation/animation_player.h" + +// Given that an engineering team has made a reference character, one wants ten animators to create animations. +// Currently, a tech artist needs to combine the ten files into one exported gltf2 to import into Godot Engine. +// We bake the RESET animation and then set it to identity, +// so that rigs with corresponding RESET animation can have their animations transferred with ease. +// +// The original algorithm for the code was used to change skeleton bone rolls to be parent to child. +// +// Reference https://github.com/godotengine/godot-proposals/issues/2961 +void BakeReset::_bake_animation_pose(Node *scene, const String &p_bake_anim) { + Map<StringName, BakeResetRestBone> r_rest_bones; + Vector<Node3D *> r_meshes; + List<Node *> queue; + queue.push_back(scene); + while (!queue.is_empty()) { + List<Node *>::Element *E = queue.front(); + Node *node = E->get(); + AnimationPlayer *ap = Object::cast_to<AnimationPlayer>(node); + // Step 1: import scene with animations into the rest bones data structure. + _fetch_reset_animation(ap, r_rest_bones, p_bake_anim); + + int child_count = node->get_child_count(); + for (int i = 0; i < child_count; i++) { + queue.push_back(node->get_child(i)); + } + queue.pop_front(); + } + + queue.push_back(scene); + while (!queue.is_empty()) { + List<Node *>::Element *E = queue.front(); + Node *node = E->get(); + EditorSceneImporterMeshNode3D *editor_mesh_3d = scene->cast_to<EditorSceneImporterMeshNode3D>(node); + MeshInstance3D *mesh_3d = scene->cast_to<MeshInstance3D>(node); + if (scene->cast_to<Skeleton3D>(node)) { + Skeleton3D *skeleton = Object::cast_to<Skeleton3D>(node); + + // Step 2: Bake the RESET animation from the RestBone to the skeleton. + _fix_skeleton(skeleton, r_rest_bones); + } + if (editor_mesh_3d) { + NodePath path = editor_mesh_3d->get_skeleton_path(); + if (!path.is_empty() && editor_mesh_3d->get_node_or_null(path) && Object::cast_to<Skeleton3D>(editor_mesh_3d->get_node_or_null(path))) { + r_meshes.push_back(editor_mesh_3d); + } + } else if (mesh_3d) { + NodePath path = mesh_3d->get_skeleton_path(); + if (!path.is_empty() && mesh_3d->get_node_or_null(path) && Object::cast_to<Skeleton3D>(mesh_3d->get_node_or_null(path))) { + r_meshes.push_back(mesh_3d); + } + } + int child_count = node->get_child_count(); + for (int i = 0; i < child_count; i++) { + queue.push_back(node->get_child(i)); + } + queue.pop_front(); + } + + queue.push_back(scene); + while (!queue.is_empty()) { + List<Node *>::Element *E = queue.front(); + Node *node = E->get(); + AnimationPlayer *ap = Object::cast_to<AnimationPlayer>(node); + if (ap) { + // Step 3: Key all RESET animation frames to identity. + _align_animations(ap, r_rest_bones); + } + + int child_count = node->get_child_count(); + for (int i = 0; i < child_count; i++) { + queue.push_back(node->get_child(i)); + } + queue.pop_front(); + } +} + +void BakeReset::_align_animations(AnimationPlayer *p_ap, const Map<StringName, BakeResetRestBone> &r_rest_bones) { + ERR_FAIL_NULL(p_ap); + List<StringName> anim_names; + p_ap->get_animation_list(&anim_names); + for (List<StringName>::Element *anim_i = anim_names.front(); anim_i; anim_i = anim_i->next()) { + Ref<Animation> a = p_ap->get_animation(anim_i->get()); + ERR_CONTINUE(a.is_null()); + for (Map<StringName, BakeResetRestBone>::Element *rest_bone_i = r_rest_bones.front(); rest_bone_i; rest_bone_i = rest_bone_i->next()) { + int track = a->find_track(NodePath(rest_bone_i->key())); + if (track == -1) { + continue; + } + int new_track = a->add_track(Animation::TYPE_TRANSFORM3D); + NodePath new_path = NodePath(rest_bone_i->key()); + BakeResetRestBone rest_bone = rest_bone_i->get(); + a->track_set_path(new_track, new_path); + for (int key_i = 0; key_i < a->track_get_key_count(track); key_i++) { + Vector3 loc; + Quaternion rot; + Vector3 scale; + Error err = a->transform_track_get_key(track, key_i, &loc, &rot, &scale); + ERR_CONTINUE(err); + real_t time = a->track_get_key_time(track, key_i); + rot.normalize(); + loc = loc - rest_bone.loc; + rot = rest_bone.rest_delta.get_rotation_quaternion().inverse() * rot; + rot.normalize(); + scale = Vector3(1, 1, 1) - (rest_bone.rest_delta.get_scale() - scale); + // Apply the reverse of the rest changes to make the key be close to identity transform. + a->transform_track_insert_key(new_track, time, loc, rot, scale); + } + a->remove_track(track); + } + } +} + +void BakeReset::_fetch_reset_animation(AnimationPlayer *p_ap, Map<StringName, BakeResetRestBone> &r_rest_bones, const String &p_bake_anim) { + ERR_FAIL_NULL(p_ap); + List<StringName> anim_names; + p_ap->get_animation_list(&anim_names); + Node *root = p_ap->get_owner(); + ERR_FAIL_NULL(root); + Ref<Animation> a = p_ap->get_animation(p_bake_anim); + ERR_FAIL_NULL(a); + for (int32_t track = 0; track < a->get_track_count(); track++) { + NodePath path = a->track_get_path(track); + String string_path = path; + Skeleton3D *skeleton = root->cast_to<Skeleton3D>(root->get_node(string_path.get_slice(":", 0))); + if (!skeleton) { + continue; + } + String bone_name = string_path.get_slice(":", 1); + for (int key_i = 0; key_i < a->track_get_key_count(track); key_i++) { + Vector3 loc; + Quaternion rot; + Vector3 scale; + Error err = a->transform_track_get_key(track, key_i, &loc, &rot, &scale); + ERR_CONTINUE(err); + rot.normalize(); + Basis rot_basis = Basis(rot, scale); + BakeResetRestBone rest_bone; + rest_bone.rest_delta = rot_basis; + rest_bone.loc = loc; + // Store the animation into the RestBone. + r_rest_bones[StringName(String(skeleton->get_owner()->get_path_to(skeleton)) + ":" + bone_name)] = rest_bone; + break; + } + } +} + +void BakeReset::_fix_skeleton(Skeleton3D *p_skeleton, Map<StringName, BakeReset::BakeResetRestBone> &r_rest_bones) { + int bone_count = p_skeleton->get_bone_count(); + + // First iterate through all the bones and update the RestBone. + for (int j = 0; j < bone_count; j++) { + StringName final_path = String(p_skeleton->get_owner()->get_path_to(p_skeleton)) + String(":") + p_skeleton->get_bone_name(j); + BakeResetRestBone &rest_bone = r_rest_bones[final_path]; + rest_bone.rest_local = p_skeleton->get_bone_rest(j); + } + for (int i = 0; i < bone_count; i++) { + int parent_bone = p_skeleton->get_bone_parent(i); + String path = p_skeleton->get_owner()->get_path_to(p_skeleton); + StringName final_path = String(path) + String(":") + p_skeleton->get_bone_name(parent_bone); + if (parent_bone >= 0) { + r_rest_bones[path].children.push_back(i); + } + } + + // When we apply transform to a bone, we also have to move all of its children in the opposite direction. + for (int i = 0; i < bone_count; i++) { + StringName final_path = String(p_skeleton->get_owner()->get_path_to(p_skeleton)) + String(":") + p_skeleton->get_bone_name(i); + r_rest_bones[final_path].rest_local = r_rest_bones[final_path].rest_local * Transform3D(r_rest_bones[final_path].rest_delta, r_rest_bones[final_path].loc); + // Iterate through the children and move in the opposite direction. + for (int j = 0; j < r_rest_bones[final_path].children.size(); j++) { + int child_index = r_rest_bones[final_path].children[j]; + StringName children_path = String(p_skeleton->get_name()) + String(":") + p_skeleton->get_bone_name(child_index); + r_rest_bones[children_path].rest_local = Transform3D(r_rest_bones[final_path].rest_delta, r_rest_bones[final_path].loc).affine_inverse() * r_rest_bones[children_path].rest_local; + } + } + + for (int i = 0; i < bone_count; i++) { + StringName final_path = String(p_skeleton->get_owner()->get_path_to(p_skeleton)) + String(":") + p_skeleton->get_bone_name(i); + ERR_CONTINUE(!r_rest_bones.has(final_path)); + Transform3D rest_transform = r_rest_bones[final_path].rest_local; + p_skeleton->set_bone_rest(i, rest_transform); + } +} diff --git a/editor/import/editor_importer_bake_reset.h b/editor/import/editor_importer_bake_reset.h new file mode 100644 index 0000000000..e36ae86181 --- /dev/null +++ b/editor/import/editor_importer_bake_reset.h @@ -0,0 +1,54 @@ +/*************************************************************************/ +/* editor_importer_bake_reset.h */ +/*************************************************************************/ +/* This file is part of: */ +/* GODOT ENGINE */ +/* https://godotengine.org */ +/*************************************************************************/ +/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2021 Godot Engine contributors (cf. AUTHORS.md). */ +/* */ +/* 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 RESOURCE_IMPORTER_BAKE_RESET_H +#define RESOURCE_IMPORTER_BAKE_RESET_H + +#include "scene/main/node.h" + +class Skeleton3D; +class AnimationPlayer; +class BakeReset { + struct BakeResetRestBone { + Transform3D rest_local; + Basis rest_delta; + Vector3 loc; + Vector<int> children; + }; + +public: + void _bake_animation_pose(Node *scene, const String &p_bake_anim); + +private: + void _fix_skeleton(Skeleton3D *p_skeleton, Map<StringName, BakeReset::BakeResetRestBone> &r_rest_bones); + void _align_animations(AnimationPlayer *p_ap, const Map<StringName, BakeResetRestBone> &r_rest_bones); + void _fetch_reset_animation(AnimationPlayer *p_ap, Map<StringName, BakeResetRestBone> &r_rest_bones, const String &p_bake_anim); +}; +#endif diff --git a/editor/import/resource_importer_obj.cpp b/editor/import/resource_importer_obj.cpp index 01603c0a6a..34bc0a7d8d 100644 --- a/editor/import/resource_importer_obj.cpp +++ b/editor/import/resource_importer_obj.cpp @@ -438,17 +438,16 @@ Node *EditorOBJImporter::import_scene(const String &p_path, uint32_t p_flags, in Node3D *scene = memnew(Node3D); - for (List<Ref<Mesh>>::Element *E = meshes.front(); E; E = E->next()) { + for (const Ref<Mesh> &m : meshes) { Ref<EditorSceneImporterMesh> mesh; mesh.instantiate(); - Ref<Mesh> m = E->get(); for (int i = 0; i < m->get_surface_count(); i++) { mesh->add_surface(m->surface_get_primitive_type(i), m->surface_get_arrays(i), Array(), Dictionary(), m->surface_get_material(i)); } EditorSceneImporterMeshNode3D *mi = memnew(EditorSceneImporterMeshNode3D); mi->set_mesh(mesh); - mi->set_name(E->get()->get_name()); + mi->set_name(m->get_name()); scene->add_child(mi); mi->set_owner(scene); } diff --git a/editor/import/resource_importer_scene.cpp b/editor/import/resource_importer_scene.cpp index c14b948dae..1e642462dc 100644 --- a/editor/import/resource_importer_scene.cpp +++ b/editor/import/resource_importer_scene.cpp @@ -32,6 +32,7 @@ #include "core/io/resource_saver.h" #include "editor/editor_node.h" +#include "editor/import/editor_importer_bake_reset.h" #include "editor/import/scene_import_settings.h" #include "editor/import/scene_importer_mesh_node_3d.h" #include "scene/3d/area_3d.h" @@ -312,8 +313,8 @@ Node *ResourceImporterScene::_pre_fix_node(Node *p_node, Node *p_root, Map<Ref<E List<StringName> anims; ap->get_animation_list(&anims); - for (List<StringName>::Element *E = anims.front(); E; E = E->next()) { - Ref<Animation> anim = ap->get_animation(E->get()); + for (const StringName &E : anims) { + Ref<Animation> anim = ap->get_animation(E); ERR_CONTINUE(anim.is_null()); for (int i = 0; i < anim->get_track_count(); i++) { NodePath path = anim->track_get_path(i); @@ -328,14 +329,14 @@ Node *ResourceImporterScene::_pre_fix_node(Node *p_node, Node *p_root, Map<Ref<E } } - String animname = E->get(); + String animname = E; const int loop_string_count = 3; static const char *loop_strings[loop_string_count] = { "loops", "loop", "cycle" }; for (int i = 0; i < loop_string_count; i++) { if (_teststr(animname, loop_strings[i])) { anim->set_loop(true); animname = _fixstr(animname, loop_strings[i]); - ap->rename_animation(E->get(), animname); + ap->rename_animation(E, animname); } } } @@ -659,9 +660,9 @@ Node *ResourceImporterScene::_post_fix_node(Node *p_node, Node *p_root, Map<Ref< } int idx = 0; - for (List<Ref<Shape3D>>::Element *E = shapes.front(); E; E = E->next()) { + for (const Ref<Shape3D> &E : shapes) { CollisionShape3D *cshape = memnew(CollisionShape3D); - cshape->set_shape(E->get()); + cshape->set_shape(E); base->add_child(cshape); cshape->set_owner(base->get_owner()); @@ -712,9 +713,9 @@ Node *ResourceImporterScene::_post_fix_node(Node *p_node, Node *p_root, Map<Ref< //fill node settings for this node with default values List<ImportOption> iopts; get_internal_import_options(INTERNAL_IMPORT_CATEGORY_ANIMATION_NODE, &iopts); - for (List<ImportOption>::Element *E = iopts.front(); E; E = E->next()) { - if (!node_settings.has(E->get().option.name)) { - node_settings[E->get().option.name] = E->get().default_value; + for (const ImportOption &E : iopts) { + if (!node_settings.has(E.option.name)) { + node_settings[E.option.name] = E.default_value; } } } @@ -756,8 +757,7 @@ Node *ResourceImporterScene::_post_fix_node(Node *p_node, Node *p_root, Map<Ref< } else { List<StringName> anims; ap->get_animation_list(&anims); - for (List<StringName>::Element *E = anims.front(); E; E = E->next()) { - String name = E->get(); + for (const StringName &name : anims) { Ref<Animation> anim = ap->get_animation(name); if (p_animation_data.has(name)) { Dictionary anim_settings = p_animation_data[name]; @@ -765,9 +765,9 @@ Node *ResourceImporterScene::_post_fix_node(Node *p_node, Node *p_root, Map<Ref< //fill with default values List<ImportOption> iopts; get_internal_import_options(INTERNAL_IMPORT_CATEGORY_ANIMATION, &iopts); - for (List<ImportOption>::Element *F = iopts.front(); F; F = F->next()) { - if (!anim_settings.has(F->get().option.name)) { - anim_settings[F->get().option.name] = F->get().default_value; + for (const ImportOption &F : iopts) { + if (!anim_settings.has(F.option.name)) { + anim_settings[F.option.name] = F.default_value; } } } @@ -936,8 +936,8 @@ void ResourceImporterScene::_create_clips(AnimationPlayer *anim, const Array &p_ void ResourceImporterScene::_optimize_animations(AnimationPlayer *anim, float p_max_lin_error, float p_max_ang_error, float p_max_angle) { List<StringName> anim_names; anim->get_animation_list(&anim_names); - for (List<StringName>::Element *E = anim_names.front(); E; E = E->next()) { - Ref<Animation> a = anim->get_animation(E->get()); + for (const StringName &E : anim_names) { + Ref<Animation> a = anim->get_animation(E); a->optimize(p_max_lin_error, p_max_ang_error, Math::deg2rad(p_max_angle)); } } @@ -1046,11 +1046,11 @@ void ResourceImporterScene::get_import_options(List<ImportOption> *r_options, in String script_ext_hint; - for (List<String>::Element *E = script_extentions.front(); E; E = E->next()) { + for (const String &E : script_extentions) { if (script_ext_hint != "") { script_ext_hint += ","; } - script_ext_hint += "*." + E->get(); + script_ext_hint += "*." + E; } r_options->push_back(ImportOption(PropertyInfo(Variant::FLOAT, "nodes/root_scale", PROPERTY_HINT_RANGE, "0.001,1000,0.001"), 1.0)); @@ -1061,6 +1061,7 @@ void ResourceImporterScene::get_import_options(List<ImportOption> *r_options, in r_options->push_back(ImportOption(PropertyInfo(Variant::FLOAT, "meshes/lightmap_texel_size", PROPERTY_HINT_RANGE, "0.001,100,0.001"), 0.1)); r_options->push_back(ImportOption(PropertyInfo(Variant::BOOL, "skins/use_named_skins"), true)); r_options->push_back(ImportOption(PropertyInfo(Variant::BOOL, "animation/import"), true)); + r_options->push_back(ImportOption(PropertyInfo(Variant::BOOL, "animation/bake_reset_animation"), true)); r_options->push_back(ImportOption(PropertyInfo(Variant::FLOAT, "animation/fps", PROPERTY_HINT_RANGE, "1,120,1"), 15)); r_options->push_back(ImportOption(PropertyInfo(Variant::STRING, "import_script/path", PROPERTY_HINT_FILE, script_ext_hint), "")); @@ -1089,9 +1090,9 @@ Node *ResourceImporterScene::import_scene_from_other_importer(EditorSceneImporte List<String> extensions; E->get()->get_extensions(&extensions); - for (List<String>::Element *F = extensions.front(); F; F = F->next()) { - if (F->get().to_lower() == ext) { - importer = E->get(); + for (const String &F : extensions) { + if (F.to_lower() == ext) { + importer = E; break; } } @@ -1119,9 +1120,9 @@ Ref<Animation> ResourceImporterScene::import_animation_from_other_importer(Edito List<String> extensions; E->get()->get_extensions(&extensions); - for (List<String>::Element *F = extensions.front(); F; F = F->next()) { - if (F->get().to_lower() == ext) { - importer = E->get(); + for (const String &F : extensions) { + if (F.to_lower() == ext) { + importer = E; break; } } @@ -1291,9 +1292,9 @@ void ResourceImporterScene::_generate_meshes(Node *p_node, const Dictionary &p_m } void ResourceImporterScene::_add_shapes(Node *p_node, const List<Ref<Shape3D>> &p_shapes) { - for (const List<Ref<Shape3D>>::Element *E = p_shapes.front(); E; E = E->next()) { + for (const Ref<Shape3D> &E : p_shapes) { CollisionShape3D *cshape = memnew(CollisionShape3D); - cshape->set_shape(E->get()); + cshape->set_shape(E); p_node->add_child(cshape); cshape->set_owner(p_node->get_owner()); @@ -1311,8 +1312,8 @@ Node *ResourceImporterScene::pre_import(const String &p_source_file) { List<String> extensions; E->get()->get_extensions(&extensions); - for (List<String>::Element *F = extensions.front(); F; F = F->next()) { - if (F->get().to_lower() == ext) { + for (const String &F : extensions) { + if (F.to_lower() == ext) { importer = E->get(); break; } @@ -1351,8 +1352,8 @@ Error ResourceImporterScene::import(const String &p_source_file, const String &p List<String> extensions; E->get()->get_extensions(&extensions); - for (List<String>::Element *F = extensions.front(); F; F = F->next()) { - if (F->get().to_lower() == ext) { + for (const String &F : extensions) { + if (F.to_lower() == ext) { importer = E->get(); break; } @@ -1411,6 +1412,11 @@ Error ResourceImporterScene::import(const String &p_source_file, const String &p _pre_fix_node(scene, scene, collision_map); _post_fix_node(scene, scene, collision_map, scanned_meshes, node_data, material_data, animation_data, fps); + bool use_bake_reset_animation = p_options["animation/bake_reset_animation"]; + if (use_bake_reset_animation) { + BakeReset bake_reset; + bake_reset._bake_animation_pose(scene, "RESET"); + } String root_type = p_options["nodes/root_type"]; root_type = root_type.split(" ")[0]; // full root_type is "ClassName (filename.gd)" for a script global class. diff --git a/editor/import/resource_importer_scene.h b/editor/import/resource_importer_scene.h index c6e5836a23..781beff689 100644 --- a/editor/import/resource_importer_scene.h +++ b/editor/import/resource_importer_scene.h @@ -155,7 +155,8 @@ public: virtual void get_import_options(List<ImportOption> *r_options, int p_preset = 0) const override; virtual bool get_option_visibility(const String &p_option, const Map<StringName, Variant> &p_options) const override; - virtual int get_import_order() const override { return 100; } //after everything + // Import scenes *after* everything else (such as textures). + virtual int get_import_order() const override { return ResourceImporter::IMPORT_ORDER_SCENE; } Node *_pre_fix_node(Node *p_node, Node *p_root, Map<Ref<EditorSceneImporterMesh>, List<Ref<Shape3D>>> &collision_map); Node *_post_fix_node(Node *p_node, Node *p_root, Map<Ref<EditorSceneImporterMesh>, List<Ref<Shape3D>>> &collision_map, Set<Ref<EditorSceneImporterMesh>> &r_scanned_meshes, const Dictionary &p_node_data, const Dictionary &p_material_data, const Dictionary &p_animation_data, float p_animation_fps); diff --git a/editor/import/scene_import_settings.cpp b/editor/import/scene_import_settings.cpp index f9f47ec4f4..19a8f209bb 100644 --- a/editor/import/scene_import_settings.cpp +++ b/editor/import/scene_import_settings.cpp @@ -71,9 +71,9 @@ class SceneImportSettingsData : public Object { return false; } void _get_property_list(List<PropertyInfo> *p_list) const { - for (const List<ResourceImporter::ImportOption>::Element *E = options.front(); E; E = E->next()) { - if (ResourceImporterScene::get_singleton()->get_internal_option_visibility(category, E->get().option.name, current)) { - p_list->push_back(E->get().option); + for (const ResourceImporter::ImportOption &E : options) { + if (ResourceImporterScene::get_singleton()->get_internal_option_visibility(category, E.option.name, current)) { + p_list->push_back(E.option); } } } @@ -105,7 +105,7 @@ void SceneImportSettings::_fill_material(Tree *p_tree, const Ref<Material> &p_ma MaterialData &material_data = material_map[import_id]; - Ref<Texture2D> icon = get_theme_icon("StandardMaterial3D", "EditorIcons"); + Ref<Texture2D> icon = get_theme_icon(SNAME("StandardMaterial3D"), SNAME("EditorIcons")); TreeItem *item = p_tree->create_item(p_parent); item->set_text(0, p_material->get_name()); @@ -161,7 +161,7 @@ void SceneImportSettings::_fill_mesh(Tree *p_tree, const Ref<Mesh> &p_mesh, Tree MeshData &mesh_data = mesh_map[import_id]; - Ref<Texture2D> icon = get_theme_icon("Mesh", "EditorIcons"); + Ref<Texture2D> icon = get_theme_icon(SNAME("Mesh"), SNAME("EditorIcons")); TreeItem *item = p_tree->create_item(p_parent); item->set_text(0, p_mesh->get_name()); @@ -211,7 +211,7 @@ void SceneImportSettings::_fill_animation(Tree *p_tree, const Ref<Animation> &p_ AnimationData &animation_data = animation_map[p_name]; - Ref<Texture2D> icon = get_theme_icon("Animation", "EditorIcons"); + Ref<Texture2D> icon = get_theme_icon(SNAME("Animation"), SNAME("EditorIcons")); TreeItem *item = p_tree->create_item(p_parent); item->set_text(0, p_name); @@ -255,17 +255,17 @@ void SceneImportSettings::_fill_scene(Node *p_node, TreeItem *p_parent_item) { String type = p_node->get_class(); - if (!has_theme_icon(type, "EditorIcons")) { + if (!has_theme_icon(type, SNAME("EditorIcons"))) { type = "Node3D"; } - Ref<Texture2D> icon = get_theme_icon(type, "EditorIcons"); + Ref<Texture2D> icon = get_theme_icon(type, SNAME("EditorIcons")); TreeItem *item = scene_tree->create_item(p_parent_item); item->set_text(0, p_node->get_name()); if (p_node == scene) { - icon = get_theme_icon("PackedScene", "EditorIcons"); + icon = get_theme_icon(SNAME("PackedScene"), SNAME("EditorIcons")); item->set_text(0, "Scene"); } @@ -305,8 +305,8 @@ void SceneImportSettings::_fill_scene(Node *p_node, TreeItem *p_parent_item) { if (anim_node) { List<StringName> animations; anim_node->get_animation_list(&animations); - for (List<StringName>::Element *E = animations.front(); E; E = E->next()) { - _fill_animation(scene_tree, anim_node->get_animation(E->get()), E->get(), item); + for (const StringName &E : animations) { + _fill_animation(scene_tree, anim_node->get_animation(E), E, item); } } @@ -394,8 +394,8 @@ void SceneImportSettings::_load_default_subresource_settings(Map<StringName, Var d = d[p_import_id]; List<ResourceImporterScene::ImportOption> options; ResourceImporterScene::get_singleton()->get_internal_import_options(p_category, &options); - for (List<ResourceImporterScene::ImportOption>::Element *E = options.front(); E; E = E->next()) { - String key = E->get().option.name; + for (const ResourceImporterScene::ImportOption &E : options) { + String key = E.option.name; if (d.has(key)) { settings[key] = d[key]; } @@ -440,12 +440,12 @@ void SceneImportSettings::open_settings(const String &p_path) { if (err == OK) { List<String> keys; config->get_section_keys("params", &keys); - for (List<String>::Element *E = keys.front(); E; E = E->next()) { - Variant value = config->get_value("params", E->get()); - if (E->get() == "_subresources") { + for (const String &E : keys) { + Variant value = config->get_value("params", E); + if (E == "_subresources") { base_subresource_settings = value; } else { - defaults[E->get()] = value; + defaults[E] = value; } } } @@ -605,13 +605,13 @@ void SceneImportSettings::_select(Tree *p_from, String p_type, String p_id) { scene_import_settings_data->defaults.clear(); scene_import_settings_data->current.clear(); - for (List<ResourceImporter::ImportOption>::Element *E = options.front(); E; E = E->next()) { - scene_import_settings_data->defaults[E->get().option.name] = E->get().default_value; + for (const ResourceImporter::ImportOption &E : options) { + scene_import_settings_data->defaults[E.option.name] = E.default_value; //needed for visibility toggling (fails if something is missing) - if (scene_import_settings_data->settings->has(E->get().option.name)) { - scene_import_settings_data->current[E->get().option.name] = (*scene_import_settings_data->settings)[E->get().option.name]; + if (scene_import_settings_data->settings->has(E.option.name)) { + scene_import_settings_data->current[E.option.name] = (*scene_import_settings_data->settings)[E.option.name]; } else { - scene_import_settings_data->current[E->get().option.name] = E->get().default_value; + scene_import_settings_data->current[E.option.name] = E.default_value; } } scene_import_settings_data->options = options; @@ -795,11 +795,11 @@ void SceneImportSettings::_save_path_changed(const String &p_path) { if (FileAccess::exists(p_path)) { save_path_item->set_text(2, "Warning: File exists"); save_path_item->set_tooltip(2, TTR("Existing file with the same name will be replaced.")); - save_path_item->set_icon(2, get_theme_icon("StatusWarning", "EditorIcons")); + save_path_item->set_icon(2, get_theme_icon(SNAME("StatusWarning"), SNAME("EditorIcons"))); } else { save_path_item->set_text(2, "Will create new File"); - save_path_item->set_icon(2, get_theme_icon("StatusSuccess", "EditorIcons")); + save_path_item->set_icon(2, get_theme_icon(SNAME("StatusSuccess"), SNAME("EditorIcons"))); } } @@ -829,7 +829,7 @@ void SceneImportSettings::_save_dir_callback(const String &p_path) { String name = md.material_node->get_text(0); item->set_cell_mode(0, TreeItem::CELL_MODE_CHECK); - item->set_icon(0, get_theme_icon("StandardMaterial3D", "EditorIcons")); + item->set_icon(0, get_theme_icon(SNAME("StandardMaterial3D"), SNAME("EditorIcons"))); item->set_text(0, name); if (md.has_import_id) { @@ -851,20 +851,20 @@ void SceneImportSettings::_save_dir_callback(const String &p_path) { if (FileAccess::exists(path)) { item->set_text(2, "Warning: File exists"); item->set_tooltip(2, TTR("Existing file with the same name will be replaced.")); - item->set_icon(2, get_theme_icon("StatusWarning", "EditorIcons")); + item->set_icon(2, get_theme_icon(SNAME("StatusWarning"), SNAME("EditorIcons"))); } else { item->set_text(2, "Will create new File"); - item->set_icon(2, get_theme_icon("StatusSuccess", "EditorIcons")); + item->set_icon(2, get_theme_icon(SNAME("StatusSuccess"), SNAME("EditorIcons"))); } - item->add_button(1, get_theme_icon("Folder", "EditorIcons")); + item->add_button(1, get_theme_icon(SNAME("Folder"), SNAME("EditorIcons"))); } } else { item->set_text(2, "No import ID"); item->set_tooltip(2, TTR("Material has no name nor any other way to identify on re-import.\nPlease name it or ensure it is exported with an unique ID.")); - item->set_icon(2, get_theme_icon("StatusError", "EditorIcons")); + item->set_icon(2, get_theme_icon(SNAME("StatusError"), SNAME("EditorIcons"))); } save_path_items.push_back(item); @@ -882,7 +882,7 @@ void SceneImportSettings::_save_dir_callback(const String &p_path) { String name = md.mesh_node->get_text(0); item->set_cell_mode(0, TreeItem::CELL_MODE_CHECK); - item->set_icon(0, get_theme_icon("Mesh", "EditorIcons")); + item->set_icon(0, get_theme_icon(SNAME("Mesh"), SNAME("EditorIcons"))); item->set_text(0, name); if (md.has_import_id) { @@ -904,20 +904,20 @@ void SceneImportSettings::_save_dir_callback(const String &p_path) { if (FileAccess::exists(path)) { item->set_text(2, "Warning: File exists"); item->set_tooltip(2, TTR("Existing file with the same name will be replaced on import.")); - item->set_icon(2, get_theme_icon("StatusWarning", "EditorIcons")); + item->set_icon(2, get_theme_icon(SNAME("StatusWarning"), SNAME("EditorIcons"))); } else { item->set_text(2, "Will save to new File"); - item->set_icon(2, get_theme_icon("StatusSuccess", "EditorIcons")); + item->set_icon(2, get_theme_icon(SNAME("StatusSuccess"), SNAME("EditorIcons"))); } - item->add_button(1, get_theme_icon("Folder", "EditorIcons")); + item->add_button(1, get_theme_icon(SNAME("Folder"), SNAME("EditorIcons"))); } } else { item->set_text(2, "No import ID"); item->set_tooltip(2, TTR("Mesh has no name nor any other way to identify on re-import.\nPlease name it or ensure it is exported with an unique ID.")); - item->set_icon(2, get_theme_icon("StatusError", "EditorIcons")); + item->set_icon(2, get_theme_icon(SNAME("StatusError"), SNAME("EditorIcons"))); } save_path_items.push_back(item); @@ -935,7 +935,7 @@ void SceneImportSettings::_save_dir_callback(const String &p_path) { String name = ad.scene_node->get_text(0); item->set_cell_mode(0, TreeItem::CELL_MODE_CHECK); - item->set_icon(0, get_theme_icon("Animation", "EditorIcons")); + item->set_icon(0, get_theme_icon(SNAME("Animation"), SNAME("EditorIcons"))); item->set_text(0, name); if (ad.settings.has("save_to_file/enabled") && bool(ad.settings["save_to_file/enabled"])) { @@ -956,14 +956,14 @@ void SceneImportSettings::_save_dir_callback(const String &p_path) { if (FileAccess::exists(path)) { item->set_text(2, "Warning: File exists"); item->set_tooltip(2, TTR("Existing file with the same name will be replaced on import.")); - item->set_icon(2, get_theme_icon("StatusWarning", "EditorIcons")); + item->set_icon(2, get_theme_icon(SNAME("StatusWarning"), SNAME("EditorIcons"))); } else { item->set_text(2, "Will save to new File"); - item->set_icon(2, get_theme_icon("StatusSuccess", "EditorIcons")); + item->set_icon(2, get_theme_icon(SNAME("StatusSuccess"), SNAME("EditorIcons"))); } - item->add_button(1, get_theme_icon("Folder", "EditorIcons")); + item->add_button(1, get_theme_icon(SNAME("Folder"), SNAME("EditorIcons"))); } save_path_items.push_back(item); diff --git a/editor/import/scene_importer_mesh.cpp b/editor/import/scene_importer_mesh.cpp index f8e93df382..0d14347225 100644 --- a/editor/import/scene_importer_mesh.cpp +++ b/editor/import/scene_importer_mesh.cpp @@ -79,11 +79,11 @@ void EditorSceneImporterMesh::add_surface(Mesh::PrimitiveType p_primitive, const List<Variant> lods; p_lods.get_key_list(&lods); - for (List<Variant>::Element *E = lods.front(); E; E = E->next()) { - ERR_CONTINUE(!E->get().is_num()); + for (const Variant &E : lods) { + ERR_CONTINUE(!E.is_num()); Surface::LOD lod; - lod.distance = E->get(); - lod.indices = p_lods[E->get()]; + lod.distance = E; + lod.indices = p_lods[E]; ERR_CONTINUE(lod.indices.size() == 0); s.lods.push_back(lod); } diff --git a/editor/import_defaults_editor.cpp b/editor/import_defaults_editor.cpp index 43b97eb910..25bca1d4f4 100644 --- a/editor/import_defaults_editor.cpp +++ b/editor/import_defaults_editor.cpp @@ -61,9 +61,9 @@ protected: if (importer.is_null()) { return; } - for (const List<PropertyInfo>::Element *E = properties.front(); E; E = E->next()) { - if (importer->get_option_visibility(E->get().name, values)) { - p_list->push_back(E->get()); + for (const PropertyInfo &E : properties) { + if (importer->get_option_visibility(E.name, values)) { + p_list->push_back(E); } } } @@ -98,7 +98,7 @@ void ImportDefaultsEditor::_save() { ProjectSettings::get_singleton()->set("importer_defaults/" + settings->importer->get_importer_name(), Variant()); } - emit_signal("project_settings_changed"); + emit_signal(SNAME("project_settings_changed")); } } @@ -106,9 +106,9 @@ void ImportDefaultsEditor::_update_importer() { List<Ref<ResourceImporter>> importer_list; ResourceFormatImporter::get_singleton()->get_importers(&importer_list); Ref<ResourceImporter> importer; - for (List<Ref<ResourceImporter>>::Element *E = importer_list.front(); E; E = E->next()) { - if (E->get()->get_visible_name() == importers->get_item_text(importers->get_selected())) { - importer = E->get(); + for (const Ref<ResourceImporter> &E : importer_list) { + if (E->get_visible_name() == importers->get_item_text(importers->get_selected())) { + importer = E; break; } } @@ -125,14 +125,14 @@ void ImportDefaultsEditor::_update_importer() { d = ProjectSettings::get_singleton()->get("importer_defaults/" + importer->get_importer_name()); } - for (List<ResourceImporter::ImportOption>::Element *E = options.front(); E; E = E->next()) { - settings->properties.push_back(E->get().option); - if (d.has(E->get().option.name)) { - settings->values[E->get().option.name] = d[E->get().option.name]; + for (const ResourceImporter::ImportOption &E : options) { + settings->properties.push_back(E.option); + if (d.has(E.option.name)) { + settings->values[E.option.name] = d[E.option.name]; } else { - settings->values[E->get().option.name] = E->get().default_value; + settings->values[E.option.name] = E.default_value; } - settings->default_values[E->get().option.name] = E->get().default_value; + settings->default_values[E.option.name] = E.default_value; } save_defaults->set_disabled(false); @@ -166,8 +166,8 @@ void ImportDefaultsEditor::clear() { List<Ref<ResourceImporter>> importer_list; ResourceFormatImporter::get_singleton()->get_importers(&importer_list); Vector<String> names; - for (List<Ref<ResourceImporter>>::Element *E = importer_list.front(); E; E = E->next()) { - String vn = E->get()->get_visible_name(); + for (const Ref<ResourceImporter> &E : importer_list) { + String vn = E->get_visible_name(); names.push_back(vn); } names.sort(); diff --git a/editor/import_dock.cpp b/editor/import_dock.cpp index 6fa9864830..648e60a554 100644 --- a/editor/import_dock.cpp +++ b/editor/import_dock.cpp @@ -65,14 +65,14 @@ public: return false; } void _get_property_list(List<PropertyInfo> *p_list) const { - for (const List<PropertyInfo>::Element *E = properties.front(); E; E = E->next()) { - if (!importer->get_option_visibility(E->get().name, values)) { + for (const PropertyInfo &E : properties) { + if (!importer->get_option_visibility(E.name, values)) { continue; } - PropertyInfo pi = E->get(); + PropertyInfo pi = E; if (checking) { pi.usage |= PROPERTY_USAGE_CHECKABLE; - if (checked.has(E->get().name)) { + if (checked.has(E.name)) { pi.usage |= PROPERTY_USAGE_CHECKED; } } @@ -111,18 +111,18 @@ void ImportDock::set_edit_path(const String &p_path) { ResourceFormatImporter::get_singleton()->get_importers_for_extension(p_path.get_extension(), &importers); List<Pair<String, String>> importer_names; - for (List<Ref<ResourceImporter>>::Element *E = importers.front(); E; E = E->next()) { - importer_names.push_back(Pair<String, String>(E->get()->get_visible_name(), E->get()->get_importer_name())); + for (const Ref<ResourceImporter> &E : importers) { + importer_names.push_back(Pair<String, String>(E->get_visible_name(), E->get_importer_name())); } importer_names.sort_custom<PairSort<String, String>>(); import_as->clear(); - for (List<Pair<String, String>>::Element *E = importer_names.front(); E; E = E->next()) { - import_as->add_item(E->get().first); - import_as->set_item_metadata(import_as->get_item_count() - 1, E->get().second); - if (E->get().second == importer_name) { + for (const Pair<String, String> &E : importer_names) { + import_as->add_item(E.first); + import_as->set_item_metadata(import_as->get_item_count() - 1, E.second); + if (E.second == importer_name) { import_as->select(import_as->get_item_count() - 1); } } @@ -153,12 +153,12 @@ void ImportDock::_update_options(const Ref<ConfigFile> &p_config) { params->checking = params->paths.size() > 1; params->checked.clear(); - for (List<ResourceImporter::ImportOption>::Element *E = options.front(); E; E = E->next()) { - params->properties.push_back(E->get().option); - if (p_config.is_valid() && p_config->has_section_key("params", E->get().option.name)) { - params->values[E->get().option.name] = p_config->get_value("params", E->get().option.name); + for (const ResourceImporter::ImportOption &E : options) { + params->properties.push_back(E.option); + if (p_config.is_valid() && p_config->has_section_key("params", E.option.name)) { + params->values[E.option.name] = p_config->get_value("params", E.option.name); } else { - params->values[E->get().option.name] = E->get().default_value; + params->values[E.option.name] = E.default_value; } } @@ -201,17 +201,17 @@ void ImportDock::set_edit_multiple_paths(const Vector<String> &p_paths) { List<String> keys; config->get_section_keys("params", &keys); - for (List<String>::Element *E = keys.front(); E; E = E->next()) { - if (!value_frequency.has(E->get())) { - value_frequency[E->get()] = Dictionary(); + for (const String &E : keys) { + if (!value_frequency.has(E)) { + value_frequency[E] = Dictionary(); } - Variant value = config->get_value("params", E->get()); + Variant value = config->get_value("params", E); - if (value_frequency[E->get()].has(value)) { - value_frequency[E->get()][value] = int(value_frequency[E->get()][value]) + 1; + if (value_frequency[E].has(value)) { + value_frequency[E][value] = int(value_frequency[E][value]) + 1; } else { - value_frequency[E->get()][value] = 1; + value_frequency[E][value] = 1; } } } @@ -226,25 +226,25 @@ void ImportDock::set_edit_multiple_paths(const Vector<String> &p_paths) { params->checking = true; params->checked.clear(); - for (List<ResourceImporter::ImportOption>::Element *E = options.front(); E; E = E->next()) { - params->properties.push_back(E->get().option); + for (const ResourceImporter::ImportOption &E : options) { + params->properties.push_back(E.option); - if (value_frequency.has(E->get().option.name)) { - Dictionary d = value_frequency[E->get().option.name]; + if (value_frequency.has(E.option.name)) { + Dictionary d = value_frequency[E.option.name]; int freq = 0; List<Variant> v; d.get_key_list(&v); Variant value; - for (List<Variant>::Element *F = v.front(); F; F = F->next()) { - int f = d[F->get()]; + for (const Variant &F : v) { + int f = d[F]; if (f > freq) { - value = F->get(); + value = F; } } - params->values[E->get().option.name] = value; + params->values[E.option.name] = value; } else { - params->values[E->get().option.name] = E->get().default_value; + params->values[E.option.name] = E.default_value; } } @@ -254,18 +254,18 @@ void ImportDock::set_edit_multiple_paths(const Vector<String> &p_paths) { ResourceFormatImporter::get_singleton()->get_importers_for_extension(p_paths[0].get_extension(), &importers); List<Pair<String, String>> importer_names; - for (List<Ref<ResourceImporter>>::Element *E = importers.front(); E; E = E->next()) { - importer_names.push_back(Pair<String, String>(E->get()->get_visible_name(), E->get()->get_importer_name())); + for (const Ref<ResourceImporter> &E : importers) { + importer_names.push_back(Pair<String, String>(E->get_visible_name(), E->get_importer_name())); } importer_names.sort_custom<PairSort<String, String>>(); import_as->clear(); - for (List<Pair<String, String>>::Element *E = importer_names.front(); E; E = E->next()) { - import_as->add_item(E->get().first); - import_as->set_item_metadata(import_as->get_item_count() - 1, E->get().second); - if (E->get().second == params->importer->get_importer_name()) { + for (const Pair<String, String> &E : importer_names) { + import_as->add_item(E.first); + import_as->set_item_metadata(import_as->get_item_count() - 1, E.second); + if (E.second == params->importer->get_importer_name()) { import_as->select(import_as->get_item_count() - 1); } } @@ -345,8 +345,8 @@ void ImportDock::_preset_selected(int p_idx) { case ITEM_SET_AS_DEFAULT: { Dictionary d; - for (const List<PropertyInfo>::Element *E = params->properties.front(); E; E = E->next()) { - d[E->get().name] = params->values[E->get().name]; + for (const PropertyInfo &E : params->properties) { + d[E.name] = params->values[E.name]; } ProjectSettings::get_singleton()->set("importer_defaults/" + params->importer->get_importer_name(), d); @@ -363,10 +363,10 @@ void ImportDock::_preset_selected(int p_idx) { if (params->checking) { params->checked.clear(); } - for (List<Variant>::Element *E = v.front(); E; E = E->next()) { - params->values[E->get()] = d[E->get()]; + for (const Variant &E : v) { + params->values[E] = d[E]; if (params->checking) { - params->checked.insert(E->get()); + params->checked.insert(E); } } params->update(); @@ -384,10 +384,10 @@ void ImportDock::_preset_selected(int p_idx) { if (params->checking) { params->checked.clear(); } - for (List<ResourceImporter::ImportOption>::Element *E = options.front(); E; E = E->next()) { - params->values[E->get().option.name] = E->get().default_value; + for (const ResourceImporter::ImportOption &E : options) { + params->values[E.option.name] = E.default_value; if (params->checking) { - params->checked.insert(E->get().option.name); + params->checked.insert(E.option.name); } } params->update(); @@ -486,9 +486,9 @@ void ImportDock::_reimport() { if (params->checking && config->get_value("remap", "importer") == params->importer->get_importer_name()) { //update only what is edited (checkboxes) if the importer is the same - for (List<PropertyInfo>::Element *E = params->properties.front(); E; E = E->next()) { - if (params->checked.has(E->get().name)) { - config->set_value("params", E->get().name, params->values[E->get().name]); + for (const PropertyInfo &E : params->properties) { + if (params->checked.has(E.name)) { + config->set_value("params", E.name, params->values[E.name]); } } } else { @@ -498,8 +498,8 @@ void ImportDock::_reimport() { config->erase_section("params"); } - for (List<PropertyInfo>::Element *E = params->properties.front(); E; E = E->next()) { - config->set_value("params", E->get().name, params->values[E->get().name]); + for (const PropertyInfo &E : params->properties) { + config->set_value("params", E.name, params->values[E.name]); } } @@ -526,18 +526,18 @@ void ImportDock::_reimport() { } EditorFileSystem::get_singleton()->reimport_files(params->paths); - EditorFileSystem::get_singleton()->emit_signal("filesystem_changed"); //it changed, so force emitting the signal + EditorFileSystem::get_singleton()->emit_signal(SNAME("filesystem_changed")); //it changed, so force emitting the signal } void ImportDock::_notification(int p_what) { switch (p_what) { case EditorSettings::NOTIFICATION_EDITOR_SETTINGS_CHANGED: { - imported->add_theme_style_override("normal", get_theme_stylebox("normal", "LineEdit")); + imported->add_theme_style_override("normal", get_theme_stylebox(SNAME("normal"), SNAME("LineEdit"))); } break; case NOTIFICATION_ENTER_TREE: { import_opts->edit(params); - label_warning->add_theme_color_override("font_color", get_theme_color("warning_color", "Editor")); + label_warning->add_theme_color_override("font_color", get_theme_color(SNAME("warning_color"), SNAME("Editor"))); } break; } } @@ -563,7 +563,7 @@ void ImportDock::initialize_import_options() const { ImportDock::ImportDock() { set_name("Import"); imported = memnew(Label); - imported->add_theme_style_override("normal", EditorNode::get_singleton()->get_gui_base()->get_theme_stylebox("normal", "LineEdit")); + imported->add_theme_style_override("normal", EditorNode::get_singleton()->get_gui_base()->get_theme_stylebox(SNAME("normal"), SNAME("LineEdit"))); imported->set_clip_text(true); add_child(imported); HBoxContainer *hb = memnew(HBoxContainer); diff --git a/editor/inspector_dock.cpp b/editor/inspector_dock.cpp index e8c01d0e0c..a566afb597 100644 --- a/editor/inspector_dock.cpp +++ b/editor/inspector_dock.cpp @@ -63,7 +63,7 @@ void InspectorDock::_menu_option(int p_option) { case OBJECT_REQUEST_HELP: { if (current) { editor->set_visible_editor(EditorNode::EDITOR_SCRIPT); - emit_signal("request_help", current->get_class()); + emit_signal(SNAME("request_help"), current->get_class()); } } break; @@ -87,12 +87,12 @@ void InspectorDock::_menu_option(int p_option) { List<PropertyInfo> props; current->get_property_list(&props); Map<RES, RES> duplicates; - for (List<PropertyInfo>::Element *E = props.front(); E; E = E->next()) { - if (!(E->get().usage & PROPERTY_USAGE_STORAGE)) { + for (const PropertyInfo &E : props) { + if (!(E.usage & PROPERTY_USAGE_STORAGE)) { continue; } - Variant v = current->get(E->get().name); + Variant v = current->get(E.name); if (v.is_ref()) { REF ref = v; if (ref.is_valid()) { @@ -103,8 +103,8 @@ void InspectorDock::_menu_option(int p_option) { } res = duplicates[res]; - current->set(E->get().name, res); - editor->get_inspector()->update_property(E->get().name); + current->set(E.name, res); + editor->get_inspector()->update_property(E.name); } } } @@ -216,7 +216,7 @@ void InspectorDock::_prepare_history() { history_menu->get_popup()->clear(); - Ref<Texture2D> base_icon = get_theme_icon("Object", "EditorIcons"); + Ref<Texture2D> base_icon = get_theme_icon(SNAME("Object"), SNAME("EditorIcons")); Set<ObjectID> already; for (int i = editor_history->get_history_len() - 1; i >= history_to; i--) { ObjectID id = editor_history->get_history_obj(i); @@ -337,27 +337,27 @@ void InspectorDock::_notification(int p_what) { case EditorSettings::NOTIFICATION_EDITOR_SETTINGS_CHANGED: { set_theme(editor->get_gui_base()->get_theme()); - resource_new_button->set_icon(get_theme_icon("New", "EditorIcons")); - resource_load_button->set_icon(get_theme_icon("Load", "EditorIcons")); - resource_save_button->set_icon(get_theme_icon("Save", "EditorIcons")); - resource_extra_button->set_icon(get_theme_icon("GuiTabMenu", "EditorIcons")); + resource_new_button->set_icon(get_theme_icon(SNAME("New"), SNAME("EditorIcons"))); + resource_load_button->set_icon(get_theme_icon(SNAME("Load"), SNAME("EditorIcons"))); + resource_save_button->set_icon(get_theme_icon(SNAME("Save"), SNAME("EditorIcons"))); + resource_extra_button->set_icon(get_theme_icon(SNAME("GuiTabMenuHl"), SNAME("EditorIcons"))); PopupMenu *resource_extra_popup = resource_extra_button->get_popup(); - resource_extra_popup->set_item_icon(resource_extra_popup->get_item_index(RESOURCE_EDIT_CLIPBOARD), get_theme_icon("ActionPaste", "EditorIcons")); - resource_extra_popup->set_item_icon(resource_extra_popup->get_item_index(RESOURCE_COPY), get_theme_icon("ActionCopy", "EditorIcons")); + resource_extra_popup->set_item_icon(resource_extra_popup->get_item_index(RESOURCE_EDIT_CLIPBOARD), get_theme_icon(SNAME("ActionPaste"), SNAME("EditorIcons"))); + resource_extra_popup->set_item_icon(resource_extra_popup->get_item_index(RESOURCE_COPY), get_theme_icon(SNAME("ActionCopy"), SNAME("EditorIcons"))); if (is_layout_rtl()) { - backward_button->set_icon(get_theme_icon("Forward", "EditorIcons")); - forward_button->set_icon(get_theme_icon("Back", "EditorIcons")); + backward_button->set_icon(get_theme_icon(SNAME("Forward"), SNAME("EditorIcons"))); + forward_button->set_icon(get_theme_icon(SNAME("Back"), SNAME("EditorIcons"))); } else { - backward_button->set_icon(get_theme_icon("Back", "EditorIcons")); - forward_button->set_icon(get_theme_icon("Forward", "EditorIcons")); + backward_button->set_icon(get_theme_icon(SNAME("Back"), SNAME("EditorIcons"))); + forward_button->set_icon(get_theme_icon(SNAME("Forward"), SNAME("EditorIcons"))); } - history_menu->set_icon(get_theme_icon("History", "EditorIcons")); - object_menu->set_icon(get_theme_icon("Tools", "EditorIcons")); - warning->set_icon(get_theme_icon("NodeWarning", "EditorIcons")); - warning->add_theme_color_override("font_color", get_theme_color("warning_color", "Editor")); + history_menu->set_icon(get_theme_icon(SNAME("History"), SNAME("EditorIcons"))); + object_menu->set_icon(get_theme_icon(SNAME("Tools"), SNAME("EditorIcons"))); + warning->set_icon(get_theme_icon(SNAME("NodeWarning"), SNAME("EditorIcons"))); + warning->add_theme_color_override("font_color", get_theme_color(SNAME("warning_color"), SNAME("Editor"))); } break; } } @@ -409,6 +409,7 @@ void InspectorDock::update(Object *p_object) { current = p_object; if (!p_object) { + open_docs_button->set_disabled(true); object_menu->set_disabled(true); warning->hide(); search->set_editable(false); @@ -424,7 +425,7 @@ void InspectorDock::update(Object *p_object) { editor_path->enable_path(); resource_save_button->set_disabled(!is_resource); - open_docs_button->set_visible(is_resource || is_node); + open_docs_button->set_disabled(!is_resource && !is_node); PopupMenu *resource_extra_popup = resource_extra_button->get_popup(); resource_extra_popup->set_item_disabled(resource_extra_popup->get_item_index(RESOURCE_COPY), !is_resource); @@ -433,8 +434,8 @@ void InspectorDock::update(Object *p_object) { PopupMenu *p = object_menu->get_popup(); p->clear(); - p->add_icon_shortcut(get_theme_icon("GuiTreeArrowDown", "EditorIcons"), ED_SHORTCUT("property_editor/expand_all", TTR("Expand All")), EXPAND_ALL); - p->add_icon_shortcut(get_theme_icon("GuiTreeArrowRight", "EditorIcons"), ED_SHORTCUT("property_editor/collapse_all", TTR("Collapse All")), COLLAPSE_ALL); + p->add_icon_shortcut(get_theme_icon(SNAME("GuiTreeArrowDown"), SNAME("EditorIcons")), ED_SHORTCUT("property_editor/expand_all", TTR("Expand All")), EXPAND_ALL); + p->add_icon_shortcut(get_theme_icon(SNAME("GuiTreeArrowRight"), SNAME("EditorIcons")), ED_SHORTCUT("property_editor/collapse_all", TTR("Collapse All")), COLLAPSE_ALL); p->add_separator(); p->add_shortcut(ED_SHORTCUT("property_editor/copy_params", TTR("Copy Properties")), OBJECT_COPY_PARAMS); @@ -499,7 +500,7 @@ InspectorDock::InspectorDock(EditorNode *p_editor, EditorData &p_editor_data) { resource_new_button = memnew(Button); resource_new_button->set_flat(true); resource_new_button->set_tooltip(TTR("Create a new resource in memory and edit it.")); - resource_new_button->set_icon(get_theme_icon("New", "EditorIcons")); + resource_new_button->set_icon(get_theme_icon(SNAME("New"), SNAME("EditorIcons"))); general_options_hb->add_child(resource_new_button); resource_new_button->connect("pressed", callable_mp(this, &InspectorDock::_new_resource)); resource_new_button->set_focus_mode(Control::FOCUS_NONE); @@ -507,14 +508,14 @@ InspectorDock::InspectorDock(EditorNode *p_editor, EditorData &p_editor_data) { resource_load_button = memnew(Button); resource_load_button->set_flat(true); resource_load_button->set_tooltip(TTR("Load an existing resource from disk and edit it.")); - resource_load_button->set_icon(get_theme_icon("Load", "EditorIcons")); + resource_load_button->set_icon(get_theme_icon(SNAME("Load"), SNAME("EditorIcons"))); general_options_hb->add_child(resource_load_button); resource_load_button->connect("pressed", callable_mp(this, &InspectorDock::_open_resource_selector)); resource_load_button->set_focus_mode(Control::FOCUS_NONE); resource_save_button = memnew(MenuButton); resource_save_button->set_tooltip(TTR("Save the currently edited resource.")); - resource_save_button->set_icon(get_theme_icon("Save", "EditorIcons")); + resource_save_button->set_icon(get_theme_icon(SNAME("Save"), SNAME("EditorIcons"))); general_options_hb->add_child(resource_save_button); resource_save_button->get_popup()->add_item(TTR("Save"), RESOURCE_SAVE); resource_save_button->get_popup()->add_item(TTR("Save As..."), RESOURCE_SAVE_AS); @@ -523,10 +524,11 @@ InspectorDock::InspectorDock(EditorNode *p_editor, EditorData &p_editor_data) { resource_save_button->set_disabled(true); resource_extra_button = memnew(MenuButton); - resource_extra_button->set_icon(get_theme_icon("GuiTabMenu", "EditorIcons")); + resource_extra_button->set_icon(get_theme_icon(SNAME("GuiTabMenuHl"), SNAME("EditorIcons"))); + resource_extra_button->set_tooltip(TTR("Extra resource options.")); general_options_hb->add_child(resource_extra_button); - resource_extra_button->get_popup()->add_icon_shortcut(get_theme_icon("ActionPaste", "EditorIcons"), ED_SHORTCUT("property_editor/paste_resource", TTR("Edit Resource from Clipboard")), RESOURCE_EDIT_CLIPBOARD); - resource_extra_button->get_popup()->add_icon_shortcut(get_theme_icon("ActionCopy", "EditorIcons"), ED_SHORTCUT("property_editor/copy_resource", TTR("Copy Resource")), RESOURCE_COPY); + resource_extra_button->get_popup()->add_icon_shortcut(get_theme_icon(SNAME("ActionPaste"), SNAME("EditorIcons")), ED_SHORTCUT("property_editor/paste_resource", TTR("Edit Resource from Clipboard")), RESOURCE_EDIT_CLIPBOARD); + resource_extra_button->get_popup()->add_icon_shortcut(get_theme_icon(SNAME("ActionCopy"), SNAME("EditorIcons")), ED_SHORTCUT("property_editor/copy_resource", TTR("Copy Resource")), RESOURCE_COPY); resource_extra_button->get_popup()->set_item_disabled(1, true); resource_extra_button->get_popup()->add_separator(); resource_extra_button->get_popup()->add_shortcut(ED_SHORTCUT("property_editor/unref_resource", TTR("Make Resource Built-In")), RESOURCE_MAKE_BUILT_IN); @@ -539,9 +541,9 @@ InspectorDock::InspectorDock(EditorNode *p_editor, EditorData &p_editor_data) { backward_button->set_flat(true); general_options_hb->add_child(backward_button); if (is_layout_rtl()) { - backward_button->set_icon(get_theme_icon("Forward", "EditorIcons")); + backward_button->set_icon(get_theme_icon(SNAME("Forward"), SNAME("EditorIcons"))); } else { - backward_button->set_icon(get_theme_icon("Back", "EditorIcons")); + backward_button->set_icon(get_theme_icon(SNAME("Back"), SNAME("EditorIcons"))); } backward_button->set_tooltip(TTR("Go to the previous edited object in history.")); backward_button->set_disabled(true); @@ -551,9 +553,9 @@ InspectorDock::InspectorDock(EditorNode *p_editor, EditorData &p_editor_data) { forward_button->set_flat(true); general_options_hb->add_child(forward_button); if (is_layout_rtl()) { - forward_button->set_icon(get_theme_icon("Back", "EditorIcons")); + forward_button->set_icon(get_theme_icon(SNAME("Back"), SNAME("EditorIcons"))); } else { - forward_button->set_icon(get_theme_icon("Forward", "EditorIcons")); + forward_button->set_icon(get_theme_icon(SNAME("Forward"), SNAME("EditorIcons"))); } forward_button->set_tooltip(TTR("Go to the next edited object in history.")); forward_button->set_disabled(true); @@ -561,7 +563,7 @@ InspectorDock::InspectorDock(EditorNode *p_editor, EditorData &p_editor_data) { history_menu = memnew(MenuButton); history_menu->set_tooltip(TTR("History of recently edited objects.")); - history_menu->set_icon(get_theme_icon("History", "EditorIcons")); + history_menu->set_icon(get_theme_icon(SNAME("History"), SNAME("EditorIcons"))); general_options_hb->add_child(history_menu); history_menu->connect("about_to_popup", callable_mp(this, &InspectorDock::_prepare_history)); history_menu->get_popup()->connect("id_pressed", callable_mp(this, &InspectorDock::_select_history)); @@ -574,9 +576,9 @@ InspectorDock::InspectorDock(EditorNode *p_editor, EditorData &p_editor_data) { open_docs_button = memnew(Button); open_docs_button->set_flat(true); - open_docs_button->set_visible(false); + open_docs_button->set_disabled(true); open_docs_button->set_tooltip(TTR("Open documentation for this object.")); - open_docs_button->set_icon(get_theme_icon("HelpSearch", "EditorIcons")); + open_docs_button->set_icon(get_theme_icon(SNAME("HelpSearch"), SNAME("EditorIcons"))); open_docs_button->set_shortcut(ED_SHORTCUT("property_editor/open_help", TTR("Open Documentation"))); subresource_hb->add_child(open_docs_button); open_docs_button->connect("pressed", callable_mp(this, &InspectorDock::_menu_option), varray(OBJECT_REQUEST_HELP)); @@ -592,13 +594,13 @@ InspectorDock::InspectorDock(EditorNode *p_editor, EditorData &p_editor_data) { search = memnew(LineEdit); search->set_h_size_flags(Control::SIZE_EXPAND_FILL); search->set_placeholder(TTR("Filter properties")); - search->set_right_icon(get_theme_icon("Search", "EditorIcons")); + search->set_right_icon(get_theme_icon(SNAME("Search"), SNAME("EditorIcons"))); search->set_clear_button_enabled(true); property_tools_hb->add_child(search); object_menu = memnew(MenuButton); object_menu->set_shortcut_context(this); - object_menu->set_icon(get_theme_icon("Tools", "EditorIcons")); + object_menu->set_icon(get_theme_icon(SNAME("Tools"), SNAME("EditorIcons"))); property_tools_hb->add_child(object_menu); object_menu->set_tooltip(TTR("Manage object properties.")); object_menu->get_popup()->connect("id_pressed", callable_mp(this, &InspectorDock::_menu_option)); @@ -606,8 +608,8 @@ InspectorDock::InspectorDock(EditorNode *p_editor, EditorData &p_editor_data) { warning = memnew(Button); add_child(warning); warning->set_text(TTR("Changes may be lost!")); - warning->set_icon(get_theme_icon("NodeWarning", "EditorIcons")); - warning->add_theme_color_override("font_color", get_theme_color("warning_color", "Editor")); + warning->set_icon(get_theme_icon(SNAME("NodeWarning"), SNAME("EditorIcons"))); + warning->add_theme_color_override("font_color", get_theme_color(SNAME("warning_color"), SNAME("Editor"))); warning->set_clip_text(true); warning->hide(); warning->connect("pressed", callable_mp(this, &InspectorDock::_warning_pressed)); diff --git a/editor/localization_editor.cpp b/editor/localization_editor.cpp index 977ca83671..3fe1aa557d 100644 --- a/editor/localization_editor.cpp +++ b/editor/localization_editor.cpp @@ -43,15 +43,15 @@ void LocalizationEditor::_notification(int p_what) { List<String> tfn; ResourceLoader::get_recognized_extensions_for_type("Translation", &tfn); - for (List<String>::Element *E = tfn.front(); E; E = E->next()) { - translation_file_open->add_filter("*." + E->get()); + for (const String &E : tfn) { + translation_file_open->add_filter("*." + E); } List<String> rfn; ResourceLoader::get_recognized_extensions_for_type("Resource", &rfn); - for (List<String>::Element *E = rfn.front(); E; E = E->next()) { - translation_res_file_open_dialog->add_filter("*." + E->get()); - translation_res_option_file_open_dialog->add_filter("*." + E->get()); + for (const String &E : rfn) { + translation_res_file_open_dialog->add_filter("*." + E); + translation_res_option_file_open_dialog->add_filter("*." + E); } _update_pot_file_extensions(); @@ -176,7 +176,7 @@ void LocalizationEditor::_translation_res_select() { return; } - call_deferred("update_translations"); + call_deferred(SNAME("update_translations")); } void LocalizationEditor::_translation_res_option_changed() { @@ -371,15 +371,10 @@ void LocalizationEditor::_translation_filter_mode_changed(int p_mode) { void LocalizationEditor::_pot_add(const PackedStringArray &p_paths) { PackedStringArray pot_translations = ProjectSettings::get_singleton()->get("internationalization/locale/translations_pot_files"); - for (int i = 0; i < p_paths.size(); i++) { - for (int j = 0; j < pot_translations.size(); j++) { - if (pot_translations[j] == p_paths[i]) { - continue; //exists - } + if (!pot_translations.has(p_paths[i])) { + pot_translations.push_back(p_paths[i]); } - - pot_translations.push_back(p_paths[i]); } undo_redo->create_action(vformat(TTR("Add %d file(s) for POT generation"), p_paths.size())); @@ -430,8 +425,8 @@ void LocalizationEditor::_update_pot_file_extensions() { pot_file_open_dialog->clear_filters(); List<String> translation_parse_file_extensions; EditorTranslationParser::get_singleton()->get_recognized_extensions(&translation_parse_file_extensions); - for (List<String>::Element *E = translation_parse_file_extensions.front(); E; E = E->next()) { - pot_file_open_dialog->add_filter("*." + E->get()); + for (const String &E : translation_parse_file_extensions) { + pot_file_open_dialog->add_filter("*." + E); } } @@ -453,7 +448,7 @@ void LocalizationEditor::update_translations() { t->set_text(0, translations[i].replace_first("res://", "")); t->set_tooltip(0, translations[i]); t->set_metadata(0, i); - t->add_button(0, get_theme_icon("Remove", "EditorIcons"), 0, false, TTR("Remove")); + t->add_button(0, get_theme_icon(SNAME("Remove"), SNAME("EditorIcons")), 0, false, TTR("Remove")); } } @@ -560,8 +555,8 @@ void LocalizationEditor::update_translations() { List<Variant> rk; remaps.get_key_list(&rk); Vector<String> keys; - for (List<Variant>::Element *E = rk.front(); E; E = E->next()) { - keys.push_back(E->get()); + for (const Variant &E : rk) { + keys.push_back(E); } keys.sort(); @@ -571,7 +566,7 @@ void LocalizationEditor::update_translations() { t->set_text(0, keys[i].replace_first("res://", "")); t->set_tooltip(0, keys[i]); t->set_metadata(0, keys[i]); - t->add_button(0, get_theme_icon("Remove", "EditorIcons"), 0, false, TTR("Remove")); + t->add_button(0, get_theme_icon(SNAME("Remove"), SNAME("EditorIcons")), 0, false, TTR("Remove")); if (keys[i] == remap_selected) { t->select(0); translation_res_option_add_button->set_disabled(false); @@ -588,7 +583,7 @@ void LocalizationEditor::update_translations() { t2->set_text(0, path.replace_first("res://", "")); t2->set_tooltip(0, path); t2->set_metadata(0, j); - t2->add_button(0, get_theme_icon("Remove", "EditorIcons"), 0, false, TTR("Remove")); + t2->add_button(0, get_theme_icon(SNAME("Remove"), SNAME("EditorIcons")), 0, false, TTR("Remove")); t2->set_cell_mode(1, TreeItem::CELL_MODE_RANGE); t2->set_text(1, langnames); t2->set_editable(1, true); @@ -621,7 +616,7 @@ void LocalizationEditor::update_translations() { t->set_text(0, pot_translations[i].replace_first("res://", "")); t->set_tooltip(0, pot_translations[i]); t->set_metadata(0, i); - t->add_button(0, get_theme_icon("Remove", "EditorIcons"), 0, false, TTR("Remove")); + t->add_button(0, get_theme_icon(SNAME("Remove"), SNAME("EditorIcons")), 0, false, TTR("Remove")); } } diff --git a/editor/multi_node_edit.cpp b/editor/multi_node_edit.cpp index b714109af7..fd4a4334fc 100644 --- a/editor/multi_node_edit.cpp +++ b/editor/multi_node_edit.cpp @@ -52,12 +52,12 @@ bool MultiNodeEdit::_set_impl(const StringName &p_name, const Variant &p_value, UndoRedo *ur = EditorNode::get_undo_redo(); ur->create_action(TTR("MultiNode Set") + " " + String(name), UndoRedo::MERGE_ENDS); - for (const List<NodePath>::Element *E = nodes.front(); E; E = E->next()) { - if (!es->has_node(E->get())) { + for (const NodePath &E : nodes) { + if (!es->has_node(E)) { continue; } - Node *n = es->get_node(E->get()); + Node *n = es->get_node(E); if (!n) { continue; } @@ -98,12 +98,12 @@ bool MultiNodeEdit::_get(const StringName &p_name, Variant &r_ret) const { name = "script"; } - for (const List<NodePath>::Element *E = nodes.front(); E; E = E->next()) { - if (!es->has_node(E->get())) { + for (const NodePath &E : nodes) { + if (!es->has_node(E)) { continue; } - const Node *n = es->get_node(E->get()); + const Node *n = es->get_node(E); if (!n) { continue; } @@ -130,12 +130,12 @@ void MultiNodeEdit::_get_property_list(List<PropertyInfo> *p_list) const { List<PLData *> data_list; - for (const List<NodePath>::Element *E = nodes.front(); E; E = E->next()) { - if (!es->has_node(E->get())) { + for (const NodePath &E : nodes) { + if (!es->has_node(E)) { continue; } - Node *n = es->get_node(E->get()); + Node *n = es->get_node(E); if (!n) { continue; } @@ -143,30 +143,30 @@ void MultiNodeEdit::_get_property_list(List<PropertyInfo> *p_list) const { List<PropertyInfo> plist; n->get_property_list(&plist, true); - for (List<PropertyInfo>::Element *F = plist.front(); F; F = F->next()) { - if (F->get().name == "script") { + for (const PropertyInfo &F : plist) { + if (F.name == "script") { continue; //added later manually, since this is intercepted before being set (check Variant Object::get() ) } - if (!usage.has(F->get().name)) { + if (!usage.has(F.name)) { PLData pld; pld.uses = 0; - pld.info = F->get(); - usage[F->get().name] = pld; - data_list.push_back(usage.getptr(F->get().name)); + pld.info = F; + usage[F.name] = pld; + data_list.push_back(usage.getptr(F.name)); } // Make sure only properties with the same exact PropertyInfo data will appear - if (usage[F->get().name].info == F->get()) { - usage[F->get().name].uses++; + if (usage[F.name].info == F) { + usage[F.name].uses++; } } nc++; } - for (List<PLData *>::Element *E = data_list.front(); E; E = E->next()) { - if (nc == E->get()->uses) { - p_list->push_back(E->get()->info); + for (const PLData *E : data_list) { + if (nc == E->uses) { + p_list->push_back(E->info); } } diff --git a/editor/node_dock.cpp b/editor/node_dock.cpp index 95a2d81e00..532413897b 100644 --- a/editor/node_dock.cpp +++ b/editor/node_dock.cpp @@ -52,8 +52,8 @@ void NodeDock::_bind_methods() { void NodeDock::_notification(int p_what) { if (p_what == NOTIFICATION_ENTER_TREE || p_what == NOTIFICATION_THEME_CHANGED) { - connections_button->set_icon(get_theme_icon("Signals", "EditorIcons")); - groups_button->set_icon(get_theme_icon("Groups", "EditorIcons")); + connections_button->set_icon(get_theme_icon(SNAME("Signals"), SNAME("EditorIcons"))); + groups_button->set_icon(get_theme_icon(SNAME("Groups"), SNAME("EditorIcons"))); } } diff --git a/editor/plugin_config_dialog.cpp b/editor/plugin_config_dialog.cpp index f55d77d782..5fe466140b 100644 --- a/editor/plugin_config_dialog.cpp +++ b/editor/plugin_config_dialog.cpp @@ -29,6 +29,7 @@ /*************************************************************************/ #include "plugin_config_dialog.h" + #include "core/io/config_file.h" #include "core/io/dir_access.h" #include "editor/editor_node.h" @@ -112,7 +113,7 @@ void PluginConfigDialog::_on_confirmed() { } #endif - emit_signal("plugin_ready", script.operator->(), active_edit->is_pressed() ? _to_absolute_plugin_path(subfolder_edit->get_text()) : ""); + emit_signal(SNAME("plugin_ready"), script.operator->(), active_edit->is_pressed() ? _to_absolute_plugin_path(subfolder_edit->get_text()) : ""); } else { EditorNode::get_singleton()->get_project_settings()->update_plugins(); } @@ -126,7 +127,51 @@ void PluginConfigDialog::_on_cancelled() { void PluginConfigDialog::_on_required_text_changed(const String &) { int lang_idx = script_option_edit->get_selected(); String ext = ScriptServer::get_language(lang_idx)->get_extension(); - get_ok_button()->set_disabled(script_edit->get_text().get_basename().is_empty() || script_edit->get_text().get_extension() != ext || name_edit->get_text().is_empty()); + + Ref<Texture2D> valid_icon = get_theme_icon(SNAME("StatusSuccess"), SNAME("EditorIcons")); + Ref<Texture2D> invalid_icon = get_theme_icon(SNAME("StatusWarning"), SNAME("EditorIcons")); + + // Set variables to assume all is valid + bool is_valid = true; + name_validation->set_texture(valid_icon); + subfolder_validation->set_texture(valid_icon); + script_validation->set_texture(valid_icon); + name_validation->set_tooltip(""); + subfolder_validation->set_tooltip(""); + script_validation->set_tooltip(""); + + // Change valid status to invalid depending on conditions. + Vector<String> errors; + if (name_edit->get_text().is_empty()) { + is_valid = false; + name_validation->set_texture(invalid_icon); + name_validation->set_tooltip(TTR("Plugin name cannot not be blank.")); + } + if (script_edit->get_text().get_extension() != ext) { + is_valid = false; + script_validation->set_texture(invalid_icon); + script_validation->set_tooltip(vformat(TTR("Script extension must match chosen language extension (.%s)."), ext)); + } + if (script_edit->get_text().get_basename().is_empty()) { + is_valid = false; + script_validation->set_texture(invalid_icon); + script_validation->set_tooltip(TTR("Script name cannot not be blank.")); + } + if (subfolder_edit->get_text().is_empty()) { + is_valid = false; + subfolder_validation->set_texture(invalid_icon); + subfolder_validation->set_tooltip(TTR("Subfolder cannot be blank.")); + } else { + DirAccessRef dir = DirAccess::create(DirAccess::ACCESS_RESOURCES); + String path = "res://addons/" + subfolder_edit->get_text(); + if (dir->dir_exists(path) && !_edit_mode) { // Only show this error if in "create" mode. + is_valid = false; + subfolder_validation->set_texture(invalid_icon); + subfolder_validation->set_tooltip(TTR("Subfolder cannot be one which already exists.")); + } + } + + get_ok_button()->set_disabled(!is_valid); } String PluginConfigDialog::_to_absolute_plugin_path(const String &p_plugin_name) { @@ -162,19 +207,22 @@ void PluginConfigDialog::config(const String &p_config_path) { _edit_mode = true; active_edit->hide(); - Object::cast_to<Label>(active_edit->get_parent()->get_child(active_edit->get_index() - 1))->hide(); + Object::cast_to<Label>(active_edit->get_parent()->get_child(active_edit->get_index() - 2))->hide(); subfolder_edit->hide(); - Object::cast_to<Label>(subfolder_edit->get_parent()->get_child(subfolder_edit->get_index() - 1))->hide(); + Object::cast_to<Label>(subfolder_edit->get_parent()->get_child(subfolder_edit->get_index() - 2))->hide(); set_title(TTR("Edit a Plugin")); } else { _clear_fields(); _edit_mode = false; active_edit->show(); - Object::cast_to<Label>(active_edit->get_parent()->get_child(active_edit->get_index() - 1))->show(); + Object::cast_to<Label>(active_edit->get_parent()->get_child(active_edit->get_index() - 2))->show(); subfolder_edit->show(); - Object::cast_to<Label>(subfolder_edit->get_parent()->get_child(subfolder_edit->get_index() - 1))->show(); + Object::cast_to<Label>(subfolder_edit->get_parent()->get_child(subfolder_edit->get_index() - 2))->show(); set_title(TTR("Create a Plugin")); } + // Simulate text changing so the errors populate. + _on_required_text_changed(""); + get_ok_button()->set_disabled(!_edit_mode); get_ok_button()->set_text(_edit_mode ? TTR("Update") : TTR("Create")); } @@ -187,56 +235,88 @@ PluginConfigDialog::PluginConfigDialog() { get_ok_button()->set_disabled(true); set_hide_on_ok(true); + VBoxContainer *vbox = memnew(VBoxContainer); + vbox->set_h_size_flags(Control::SIZE_EXPAND_FILL); + vbox->set_v_size_flags(Control::SIZE_EXPAND_FILL); + add_child(vbox); + GridContainer *grid = memnew(GridContainer); - grid->set_columns(2); - add_child(grid); + grid->set_columns(3); + vbox->add_child(grid); + // Plugin Name Label *name_lb = memnew(Label); name_lb->set_text(TTR("Plugin Name:")); grid->add_child(name_lb); + name_validation = memnew(TextureRect); + name_validation->set_v_size_flags(Control::SIZE_SHRINK_CENTER); + grid->add_child(name_validation); + name_edit = memnew(LineEdit); name_edit->connect("text_changed", callable_mp(this, &PluginConfigDialog::_on_required_text_changed)); name_edit->set_placeholder("MyPlugin"); grid->add_child(name_edit); + // Subfolder Label *subfolder_lb = memnew(Label); subfolder_lb->set_text(TTR("Subfolder:")); grid->add_child(subfolder_lb); + subfolder_validation = memnew(TextureRect); + subfolder_validation->set_v_size_flags(Control::SIZE_SHRINK_CENTER); + grid->add_child(subfolder_validation); + subfolder_edit = memnew(LineEdit); subfolder_edit->set_placeholder("\"my_plugin\" -> res://addons/my_plugin"); + subfolder_edit->connect("text_changed", callable_mp(this, &PluginConfigDialog::_on_required_text_changed)); grid->add_child(subfolder_edit); + // Description Label *desc_lb = memnew(Label); desc_lb->set_text(TTR("Description:")); grid->add_child(desc_lb); + Control *desc_spacer = memnew(Control); + grid->add_child(desc_spacer); + desc_edit = memnew(TextEdit); desc_edit->set_custom_minimum_size(Size2(400, 80) * EDSCALE); desc_edit->set_wrap_enabled(true); grid->add_child(desc_edit); + // Author Label *author_lb = memnew(Label); author_lb->set_text(TTR("Author:")); grid->add_child(author_lb); + Control *author_spacer = memnew(Control); + grid->add_child(author_spacer); + author_edit = memnew(LineEdit); author_edit->set_placeholder("Godette"); grid->add_child(author_edit); + // Version Label *version_lb = memnew(Label); version_lb->set_text(TTR("Version:")); grid->add_child(version_lb); + Control *version_spacer = memnew(Control); + grid->add_child(version_spacer); + version_edit = memnew(LineEdit); version_edit->set_placeholder("1.0"); grid->add_child(version_edit); + // Language dropdown Label *script_option_lb = memnew(Label); script_option_lb->set_text(TTR("Language:")); grid->add_child(script_option_lb); + Control *script_opt_spacer = memnew(Control); + grid->add_child(script_opt_spacer); + script_option_edit = memnew(OptionButton); int default_lang = 0; for (int i = 0; i < ScriptServer::get_language_count(); i++) { @@ -251,20 +331,29 @@ PluginConfigDialog::PluginConfigDialog() { script_option_edit->select(default_lang); grid->add_child(script_option_edit); + // Plugin Script Name Label *script_lb = memnew(Label); script_lb->set_text(TTR("Script Name:")); grid->add_child(script_lb); + script_validation = memnew(TextureRect); + script_validation->set_v_size_flags(Control::SIZE_SHRINK_CENTER); + grid->add_child(script_validation); + script_edit = memnew(LineEdit); script_edit->connect("text_changed", callable_mp(this, &PluginConfigDialog::_on_required_text_changed)); script_edit->set_placeholder("\"plugin.gd\" -> res://addons/my_plugin/plugin.gd"); grid->add_child(script_edit); + // Activate now checkbox // TODO Make this option work better with languages like C#. Right now, it does not work because the C# project must be compiled first. Label *active_lb = memnew(Label); active_lb->set_text(TTR("Activate now?")); grid->add_child(active_lb); + Control *active_spacer = memnew(Control); + grid->add_child(active_spacer); + active_edit = memnew(CheckBox); active_edit->set_pressed(true); grid->add_child(active_edit); diff --git a/editor/plugin_config_dialog.h b/editor/plugin_config_dialog.h index f49f14c881..ad5b96735f 100644 --- a/editor/plugin_config_dialog.h +++ b/editor/plugin_config_dialog.h @@ -36,6 +36,7 @@ #include "scene/gui/line_edit.h" #include "scene/gui/option_button.h" #include "scene/gui/text_edit.h" +#include "scene/gui/texture_rect.h" class PluginConfigDialog : public ConfirmationDialog { GDCLASS(PluginConfigDialog, ConfirmationDialog); @@ -49,6 +50,10 @@ class PluginConfigDialog : public ConfirmationDialog { LineEdit *script_edit; CheckBox *active_edit; + TextureRect *name_validation; + TextureRect *subfolder_validation; + TextureRect *script_validation; + bool _edit_mode; void _clear_fields(); diff --git a/editor/plugins/abstract_polygon_2d_editor.cpp b/editor/plugins/abstract_polygon_2d_editor.cpp index e6f7ec1fbf..df01ecd1be 100644 --- a/editor/plugins/abstract_polygon_2d_editor.cpp +++ b/editor/plugins/abstract_polygon_2d_editor.cpp @@ -150,9 +150,9 @@ void AbstractPolygon2DEditor::_notification(int p_what) { case NOTIFICATION_READY: { disable_polygon_editing(false, String()); - button_create->set_icon(EditorNode::get_singleton()->get_gui_base()->get_theme_icon("CurveCreate", "EditorIcons")); - button_edit->set_icon(EditorNode::get_singleton()->get_gui_base()->get_theme_icon("CurveEdit", "EditorIcons")); - button_delete->set_icon(EditorNode::get_singleton()->get_gui_base()->get_theme_icon("CurveDelete", "EditorIcons")); + button_create->set_icon(EditorNode::get_singleton()->get_gui_base()->get_theme_icon(SNAME("CurveCreate"), SNAME("EditorIcons"))); + button_edit->set_icon(EditorNode::get_singleton()->get_gui_base()->get_theme_icon(SNAME("CurveEdit"), SNAME("EditorIcons"))); + button_delete->set_icon(EditorNode::get_singleton()->get_gui_base()->get_theme_icon(SNAME("CurveDelete"), SNAME("EditorIcons"))); button_edit->set_pressed(true); get_tree()->connect("node_removed", callable_mp(this, &AbstractPolygon2DEditor::_node_removed)); @@ -477,7 +477,7 @@ void AbstractPolygon2DEditor::forward_canvas_draw_over_viewport(Control *p_overl Transform2D xform = canvas_item_editor->get_canvas_transform() * _get_node()->get_global_transform(); // All polygon points are sharp, so use the sharp handle icon - const Ref<Texture2D> handle = get_theme_icon("EditorPathSharpHandle", "EditorIcons"); + const Ref<Texture2D> handle = get_theme_icon(SNAME("EditorPathSharpHandle"), SNAME("EditorIcons")); const Vertex active_point = get_active_point(); const int n_polygons = _get_polygon_count(); @@ -550,8 +550,8 @@ void AbstractPolygon2DEditor::forward_canvas_draw_over_viewport(Control *p_overl p_overlay->draw_texture(handle, point - handle->get_size() * 0.5, modulate); if (vertex == hover_point) { - Ref<Font> font = get_theme_font("font", "Label"); - int font_size = get_theme_font_size("font_size", "Label"); + Ref<Font> font = get_theme_font(SNAME("font"), SNAME("Label")); + int font_size = get_theme_font_size(SNAME("font_size"), SNAME("Label")); String num = String::num(vertex.vertex); Size2 num_size = font->get_string_size(num, font_size); p_overlay->draw_string(font, point - num_size * 0.5, num, HALIGN_LEFT, -1, font_size, Color(1.0, 1.0, 1.0, 0.5)); @@ -560,7 +560,7 @@ void AbstractPolygon2DEditor::forward_canvas_draw_over_viewport(Control *p_overl } if (edge_point.valid()) { - Ref<Texture2D> add_handle = get_theme_icon("EditorHandleAdd", "EditorIcons"); + Ref<Texture2D> add_handle = get_theme_icon(SNAME("EditorHandleAdd"), SNAME("EditorIcons")); p_overlay->draw_texture(add_handle, edge_point.pos - add_handle->get_size() * 0.5); } } diff --git a/editor/plugins/animation_blend_space_1d_editor.cpp b/editor/plugins/animation_blend_space_1d_editor.cpp index b6dd9474d3..ad2d9866fa 100644 --- a/editor/plugins/animation_blend_space_1d_editor.cpp +++ b/editor/plugins/animation_blend_space_1d_editor.cpp @@ -72,22 +72,22 @@ void AnimationNodeBlendSpace1DEditor::_blend_space_gui_input(const Ref<InputEven List<StringName> names; ap->get_animation_list(&names); - for (List<StringName>::Element *E = names.front(); E; E = E->next()) { - animations_menu->add_icon_item(get_theme_icon("Animation", "EditorIcons"), E->get()); - animations_to_add.push_back(E->get()); + for (const StringName &E : names) { + animations_menu->add_icon_item(get_theme_icon(SNAME("Animation"), SNAME("EditorIcons")), E); + animations_to_add.push_back(E); } } } - for (List<StringName>::Element *E = classes.front(); E; E = E->next()) { - String name = String(E->get()).replace_first("AnimationNode", ""); + for (const StringName &E : classes) { + String name = String(E).replace_first("AnimationNode", ""); if (name == "Animation") { continue; } int idx = menu->get_item_count(); menu->add_item(vformat("Add %s", name), idx); - menu->set_item_metadata(idx, E->get()); + menu->set_item_metadata(idx, E); } Ref<AnimationNode> clipb = EditorSettings::get_singleton()->get_resource_clipboard(); @@ -196,19 +196,19 @@ void AnimationNodeBlendSpace1DEditor::_blend_space_gui_input(const Ref<InputEven } void AnimationNodeBlendSpace1DEditor::_blend_space_draw() { - Color linecolor = get_theme_color("font_color", "Label"); + Color linecolor = get_theme_color(SNAME("font_color"), SNAME("Label")); Color linecolor_soft = linecolor; linecolor_soft.a *= 0.5; - Ref<Font> font = get_theme_font("font", "Label"); - int font_size = get_theme_font_size("font_size", "Label"); - Ref<Texture2D> icon = get_theme_icon("KeyValue", "EditorIcons"); - Ref<Texture2D> icon_selected = get_theme_icon("KeySelected", "EditorIcons"); + Ref<Font> font = get_theme_font(SNAME("font"), SNAME("Label")); + int font_size = get_theme_font_size(SNAME("font_size"), SNAME("Label")); + Ref<Texture2D> icon = get_theme_icon(SNAME("KeyValue"), SNAME("EditorIcons")); + Ref<Texture2D> icon_selected = get_theme_icon(SNAME("KeySelected"), SNAME("EditorIcons")); Size2 s = blend_space_draw->get_size(); if (blend_space_draw->has_focus()) { - Color color = get_theme_color("accent_color", "Editor"); + Color color = get_theme_color(SNAME("accent_color"), SNAME("Editor")); blend_space_draw->draw_rect(Rect2(Point2(), s), color, false); } @@ -279,7 +279,7 @@ void AnimationNodeBlendSpace1DEditor::_blend_space_draw() { { Color color; if (tool_blend->is_pressed()) { - color = get_theme_color("accent_color", "Editor"); + color = get_theme_color(SNAME("accent_color"), SNAME("Editor")); } else { color = linecolor; color.a *= 0.5; @@ -373,8 +373,8 @@ void AnimationNodeBlendSpace1DEditor::_add_menu_type(int p_index) { open_file->clear_filters(); List<String> filters; ResourceLoader::get_recognized_extensions_for_type("AnimationRootNode", &filters); - for (List<String>::Element *E = filters.front(); E; E = E->next()) { - open_file->add_filter("*." + E->get()); + for (const String &E : filters) { + open_file->add_filter("*." + E); } open_file->popup_file_dialog(); return; @@ -529,15 +529,15 @@ void AnimationNodeBlendSpace1DEditor::_open_editor() { void AnimationNodeBlendSpace1DEditor::_notification(int p_what) { if (p_what == NOTIFICATION_ENTER_TREE || p_what == NOTIFICATION_THEME_CHANGED) { - error_panel->add_theme_style_override("panel", get_theme_stylebox("bg", "Tree")); - error_label->add_theme_color_override("font_color", get_theme_color("error_color", "Editor")); - panel->add_theme_style_override("panel", get_theme_stylebox("bg", "Tree")); - tool_blend->set_icon(get_theme_icon("EditPivot", "EditorIcons")); - tool_select->set_icon(get_theme_icon("ToolSelect", "EditorIcons")); - tool_create->set_icon(get_theme_icon("EditKey", "EditorIcons")); - tool_erase->set_icon(get_theme_icon("Remove", "EditorIcons")); - snap->set_icon(get_theme_icon("SnapGrid", "EditorIcons")); - open_editor->set_icon(get_theme_icon("Edit", "EditorIcons")); + error_panel->add_theme_style_override("panel", get_theme_stylebox(SNAME("bg"), SNAME("Tree"))); + error_label->add_theme_color_override("font_color", get_theme_color(SNAME("error_color"), SNAME("Editor"))); + panel->add_theme_style_override("panel", get_theme_stylebox(SNAME("bg"), SNAME("Tree"))); + tool_blend->set_icon(get_theme_icon(SNAME("EditPivot"), SNAME("EditorIcons"))); + tool_select->set_icon(get_theme_icon(SNAME("ToolSelect"), SNAME("EditorIcons"))); + tool_create->set_icon(get_theme_icon(SNAME("EditKey"), SNAME("EditorIcons"))); + tool_erase->set_icon(get_theme_icon(SNAME("Remove"), SNAME("EditorIcons"))); + snap->set_icon(get_theme_icon(SNAME("SnapGrid"), SNAME("EditorIcons"))); + open_editor->set_icon(get_theme_icon(SNAME("Edit"), SNAME("EditorIcons"))); } if (p_what == NOTIFICATION_PROCESS) { diff --git a/editor/plugins/animation_blend_space_2d_editor.cpp b/editor/plugins/animation_blend_space_2d_editor.cpp index 359df95bce..49fcac512b 100644 --- a/editor/plugins/animation_blend_space_2d_editor.cpp +++ b/editor/plugins/animation_blend_space_2d_editor.cpp @@ -96,21 +96,21 @@ void AnimationNodeBlendSpace2DEditor::_blend_space_gui_input(const Ref<InputEven if (ap) { List<StringName> names; ap->get_animation_list(&names); - for (List<StringName>::Element *E = names.front(); E; E = E->next()) { - animations_menu->add_icon_item(get_theme_icon("Animation", "EditorIcons"), E->get()); - animations_to_add.push_back(E->get()); + for (const StringName &E : names) { + animations_menu->add_icon_item(get_theme_icon(SNAME("Animation"), SNAME("EditorIcons")), E); + animations_to_add.push_back(E); } } } - for (List<StringName>::Element *E = classes.front(); E; E = E->next()) { - String name = String(E->get()).replace_first("AnimationNode", ""); + for (const StringName &E : classes) { + String name = String(E).replace_first("AnimationNode", ""); if (name == "Animation") { continue; // nope } int idx = menu->get_item_count(); menu->add_item(vformat("Add %s", name), idx); - menu->set_item_metadata(idx, E->get()); + menu->set_item_metadata(idx, E); } Ref<AnimationNode> clipb = EditorSettings::get_singleton()->get_resource_clipboard(); @@ -295,8 +295,8 @@ void AnimationNodeBlendSpace2DEditor::_add_menu_type(int p_index) { open_file->clear_filters(); List<String> filters; ResourceLoader::get_recognized_extensions_for_type("AnimationRootNode", &filters); - for (List<String>::Element *E = filters.front(); E; E = E->next()) { - open_file->add_filter("*." + E->get()); + for (const String &E : filters) { + open_file->add_filter("*." + E); } open_file->popup_file_dialog(); return; @@ -392,18 +392,18 @@ void AnimationNodeBlendSpace2DEditor::_tool_switch(int p_tool) { } void AnimationNodeBlendSpace2DEditor::_blend_space_draw() { - Color linecolor = get_theme_color("font_color", "Label"); + Color linecolor = get_theme_color(SNAME("font_color"), SNAME("Label")); Color linecolor_soft = linecolor; linecolor_soft.a *= 0.5; - Ref<Font> font = get_theme_font("font", "Label"); - int font_size = get_theme_font_size("font_size", "Label"); - Ref<Texture2D> icon = get_theme_icon("KeyValue", "EditorIcons"); - Ref<Texture2D> icon_selected = get_theme_icon("KeySelected", "EditorIcons"); + Ref<Font> font = get_theme_font(SNAME("font"), SNAME("Label")); + int font_size = get_theme_font_size(SNAME("font_size"), SNAME("Label")); + Ref<Texture2D> icon = get_theme_icon(SNAME("KeyValue"), SNAME("EditorIcons")); + Ref<Texture2D> icon_selected = get_theme_icon(SNAME("KeySelected"), SNAME("EditorIcons")); Size2 s = blend_space_draw->get_size(); if (blend_space_draw->has_focus()) { - Color color = get_theme_color("accent_color", "Editor"); + Color color = get_theme_color(SNAME("accent_color"), SNAME("Editor")); blend_space_draw->draw_rect(Rect2(Point2(), s), color, false); } blend_space_draw->draw_line(Point2(1, 0), Point2(1, s.height - 1), linecolor); @@ -483,7 +483,7 @@ void AnimationNodeBlendSpace2DEditor::_blend_space_draw() { Color color; if (i == selected_triangle) { - color = get_theme_color("accent_color", "Editor"); + color = get_theme_color(SNAME("accent_color"), SNAME("Editor")); color.a *= 0.5; } else { color = linecolor; @@ -543,7 +543,7 @@ void AnimationNodeBlendSpace2DEditor::_blend_space_draw() { { Color color; if (tool_blend->is_pressed()) { - color = get_theme_color("accent_color", "Editor"); + color = get_theme_color(SNAME("accent_color"), SNAME("Editor")); } else { color = linecolor; color.a *= 0.5; @@ -733,21 +733,21 @@ void AnimationNodeBlendSpace2DEditor::_edit_point_pos(double) { void AnimationNodeBlendSpace2DEditor::_notification(int p_what) { if (p_what == NOTIFICATION_ENTER_TREE || p_what == NOTIFICATION_THEME_CHANGED) { - error_panel->add_theme_style_override("panel", get_theme_stylebox("bg", "Tree")); - error_label->add_theme_color_override("font_color", get_theme_color("error_color", "Editor")); - panel->add_theme_style_override("panel", get_theme_stylebox("bg", "Tree")); - tool_blend->set_icon(get_theme_icon("EditPivot", "EditorIcons")); - tool_select->set_icon(get_theme_icon("ToolSelect", "EditorIcons")); - tool_create->set_icon(get_theme_icon("EditKey", "EditorIcons")); - tool_triangle->set_icon(get_theme_icon("ToolTriangle", "EditorIcons")); - tool_erase->set_icon(get_theme_icon("Remove", "EditorIcons")); - snap->set_icon(get_theme_icon("SnapGrid", "EditorIcons")); - open_editor->set_icon(get_theme_icon("Edit", "EditorIcons")); - auto_triangles->set_icon(get_theme_icon("AutoTriangle", "EditorIcons")); + error_panel->add_theme_style_override("panel", get_theme_stylebox(SNAME("bg"), SNAME("Tree"))); + error_label->add_theme_color_override("font_color", get_theme_color(SNAME("error_color"), SNAME("Editor"))); + panel->add_theme_style_override("panel", get_theme_stylebox(SNAME("bg"), SNAME("Tree"))); + tool_blend->set_icon(get_theme_icon(SNAME("EditPivot"), SNAME("EditorIcons"))); + tool_select->set_icon(get_theme_icon(SNAME("ToolSelect"), SNAME("EditorIcons"))); + tool_create->set_icon(get_theme_icon(SNAME("EditKey"), SNAME("EditorIcons"))); + tool_triangle->set_icon(get_theme_icon(SNAME("ToolTriangle"), SNAME("EditorIcons"))); + tool_erase->set_icon(get_theme_icon(SNAME("Remove"), SNAME("EditorIcons"))); + snap->set_icon(get_theme_icon(SNAME("SnapGrid"), SNAME("EditorIcons"))); + open_editor->set_icon(get_theme_icon(SNAME("Edit"), SNAME("EditorIcons"))); + auto_triangles->set_icon(get_theme_icon(SNAME("AutoTriangle"), SNAME("EditorIcons"))); interpolation->clear(); - interpolation->add_icon_item(get_theme_icon("TrackContinuous", "EditorIcons"), "", 0); - interpolation->add_icon_item(get_theme_icon("TrackDiscrete", "EditorIcons"), "", 1); - interpolation->add_icon_item(get_theme_icon("TrackCapture", "EditorIcons"), "", 2); + interpolation->add_icon_item(get_theme_icon(SNAME("TrackContinuous"), SNAME("EditorIcons")), "", 0); + interpolation->add_icon_item(get_theme_icon(SNAME("TrackDiscrete"), SNAME("EditorIcons")), "", 1); + interpolation->add_icon_item(get_theme_icon(SNAME("TrackCapture"), SNAME("EditorIcons")), "", 2); } if (p_what == NOTIFICATION_PROCESS) { diff --git a/editor/plugins/animation_blend_tree_editor_plugin.cpp b/editor/plugins/animation_blend_tree_editor_plugin.cpp index dcde89f177..69206daea8 100644 --- a/editor/plugins/animation_blend_tree_editor_plugin.cpp +++ b/editor/plugins/animation_blend_tree_editor_plugin.cpp @@ -89,7 +89,7 @@ Size2 AnimationNodeBlendTreeEditor::get_minimum_size() const { void AnimationNodeBlendTreeEditor::_property_changed(const StringName &p_property, const Variant &p_value, const String &p_field, bool p_changing) { AnimationTree *tree = AnimationTreeEditor::get_singleton()->get_tree(); updating = true; - undo_redo->create_action(TTR("Parameter Changed") + ": " + String(p_property), UndoRedo::MERGE_ENDS); + undo_redo->create_action(TTR("Parameter Changed:") + " " + String(p_property), UndoRedo::MERGE_ENDS); undo_redo->add_do_property(tree, p_property, p_value); undo_redo->add_undo_property(tree, p_property, tree->get(p_property)); undo_redo->add_do_method(this, "_update_graph"); @@ -121,46 +121,46 @@ void AnimationNodeBlendTreeEditor::_update_graph() { List<StringName> nodes; blend_tree->get_node_list(&nodes); - for (List<StringName>::Element *E = nodes.front(); E; E = E->next()) { + for (const StringName &E : nodes) { GraphNode *node = memnew(GraphNode); graph->add_child(node); - Ref<AnimationNode> agnode = blend_tree->get_node(E->get()); + Ref<AnimationNode> agnode = blend_tree->get_node(E); - node->set_position_offset(blend_tree->get_node_position(E->get()) * EDSCALE); + node->set_position_offset(blend_tree->get_node_position(E) * EDSCALE); node->set_title(agnode->get_caption()); - node->set_name(E->get()); + node->set_name(E); int base = 0; - if (String(E->get()) != "output") { + if (String(E) != "output") { LineEdit *name = memnew(LineEdit); - name->set_text(E->get()); + name->set_text(E); name->set_expand_to_text_length_enabled(true); node->add_child(name); - node->set_slot(0, false, 0, Color(), true, 0, get_theme_color("font_color", "Label")); + node->set_slot(0, false, 0, Color(), true, 0, get_theme_color(SNAME("font_color"), SNAME("Label"))); name->connect("text_submitted", callable_mp(this, &AnimationNodeBlendTreeEditor::_node_renamed), varray(agnode), CONNECT_DEFERRED); name->connect("focus_exited", callable_mp(this, &AnimationNodeBlendTreeEditor::_node_renamed_focus_out), varray(name, agnode), CONNECT_DEFERRED); base = 1; node->set_show_close_button(true); - node->connect("close_request", callable_mp(this, &AnimationNodeBlendTreeEditor::_delete_request), varray(E->get()), CONNECT_DEFERRED); + node->connect("close_request", callable_mp(this, &AnimationNodeBlendTreeEditor::_delete_request), varray(E), CONNECT_DEFERRED); } for (int i = 0; i < agnode->get_input_count(); i++) { Label *in_name = memnew(Label); node->add_child(in_name); in_name->set_text(agnode->get_input_name(i)); - node->set_slot(base + i, true, 0, get_theme_color("font_color", "Label"), false, 0, Color()); + node->set_slot(base + i, true, 0, get_theme_color(SNAME("font_color"), SNAME("Label")), false, 0, Color()); } List<PropertyInfo> pinfo; agnode->get_parameter_list(&pinfo); - for (List<PropertyInfo>::Element *F = pinfo.front(); F; F = F->next()) { - if (!(F->get().usage & PROPERTY_USAGE_EDITOR)) { + for (const PropertyInfo &F : pinfo) { + if (!(F.usage & PROPERTY_USAGE_EDITOR)) { continue; } - String base_path = AnimationTreeEditor::get_singleton()->get_base_path() + String(E->get()) + "/" + F->get().name; - EditorProperty *prop = EditorInspector::instantiate_property_editor(AnimationTreeEditor::get_singleton()->get_tree(), F->get().type, base_path, F->get().hint, F->get().hint_string, F->get().usage); + String base_path = AnimationTreeEditor::get_singleton()->get_base_path() + String(E) + "/" + F.name; + EditorProperty *prop = EditorInspector::instantiate_property_editor(AnimationTreeEditor::get_singleton()->get_tree(), F.type, base_path, F.hint, F.hint_string, F.usage); if (prop) { prop->set_object_and_property(AnimationTreeEditor::get_singleton()->get_tree(), base_path); prop->update_property(); @@ -171,15 +171,15 @@ void AnimationNodeBlendTreeEditor::_update_graph() { } } - node->connect("dragged", callable_mp(this, &AnimationNodeBlendTreeEditor::_node_dragged), varray(E->get())); + node->connect("dragged", callable_mp(this, &AnimationNodeBlendTreeEditor::_node_dragged), varray(E)); if (AnimationTreeEditor::get_singleton()->can_edit(agnode)) { node->add_child(memnew(HSeparator)); Button *open_in_editor = memnew(Button); open_in_editor->set_text(TTR("Open Editor")); - open_in_editor->set_icon(get_theme_icon("Edit", "EditorIcons")); + open_in_editor->set_icon(get_theme_icon(SNAME("Edit"), SNAME("EditorIcons"))); node->add_child(open_in_editor); - open_in_editor->connect("pressed", callable_mp(this, &AnimationNodeBlendTreeEditor::_open_in_editor), varray(E->get()), CONNECT_DEFERRED); + open_in_editor->connect("pressed", callable_mp(this, &AnimationNodeBlendTreeEditor::_open_in_editor), varray(E), CONNECT_DEFERRED); open_in_editor->set_h_size_flags(SIZE_SHRINK_CENTER); } @@ -187,9 +187,9 @@ void AnimationNodeBlendTreeEditor::_update_graph() { node->add_child(memnew(HSeparator)); Button *edit_filters = memnew(Button); edit_filters->set_text(TTR("Edit Filters")); - edit_filters->set_icon(get_theme_icon("AnimationFilter", "EditorIcons")); + edit_filters->set_icon(get_theme_icon(SNAME("AnimationFilter"), SNAME("EditorIcons"))); node->add_child(edit_filters); - edit_filters->connect("pressed", callable_mp(this, &AnimationNodeBlendTreeEditor::_edit_filters), varray(E->get()), CONNECT_DEFERRED); + edit_filters->connect("pressed", callable_mp(this, &AnimationNodeBlendTreeEditor::_edit_filters), varray(E), CONNECT_DEFERRED); edit_filters->set_h_size_flags(SIZE_SHRINK_CENTER); } @@ -197,7 +197,7 @@ void AnimationNodeBlendTreeEditor::_update_graph() { if (anim.is_valid()) { MenuButton *mb = memnew(MenuButton); mb->set_text(anim->get_animation()); - mb->set_icon(get_theme_icon("Animation", "EditorIcons")); + mb->set_icon(get_theme_icon(SNAME("Animation"), SNAME("EditorIcons"))); Array options; node->add_child(memnew(HSeparator)); @@ -212,9 +212,9 @@ void AnimationNodeBlendTreeEditor::_update_graph() { List<StringName> anims; ap->get_animation_list(&anims); - for (List<StringName>::Element *F = anims.front(); F; F = F->next()) { - mb->get_popup()->add_item(F->get()); - options.push_back(F->get()); + for (const StringName &F : anims) { + mb->get_popup()->add_item(F); + options.push_back(F); } if (ap->has_animation(anim->get_animation())) { @@ -225,13 +225,13 @@ void AnimationNodeBlendTreeEditor::_update_graph() { pb->set_percent_visible(false); pb->set_custom_minimum_size(Vector2(0, 14) * EDSCALE); - animations[E->get()] = pb; + animations[E] = pb; node->add_child(pb); - mb->get_popup()->connect("index_pressed", callable_mp(this, &AnimationNodeBlendTreeEditor::_anim_selected), varray(options, E->get()), CONNECT_DEFERRED); + mb->get_popup()->connect("index_pressed", callable_mp(this, &AnimationNodeBlendTreeEditor::_anim_selected), varray(options, E), CONNECT_DEFERRED); } - Ref<StyleBoxFlat> sb = node->get_theme_stylebox("frame", "GraphNode"); + Ref<StyleBoxFlat> sb = node->get_theme_stylebox(SNAME("frame"), SNAME("GraphNode")); Color c = sb->get_border_color(); Color mono_color = ((c.r + c.g + c.b) / 3) < 0.7 ? Color(1.0, 1.0, 1.0) : Color(0.0, 0.0, 0.0); mono_color.a = 0.85; @@ -246,10 +246,10 @@ void AnimationNodeBlendTreeEditor::_update_graph() { List<AnimationNodeBlendTree::NodeConnection> connections; blend_tree->get_node_connections(&connections); - for (List<AnimationNodeBlendTree::NodeConnection>::Element *E = connections.front(); E; E = E->next()) { - StringName from = E->get().output_node; - StringName to = E->get().input_node; - int to_idx = E->get().input_index; + for (const AnimationNodeBlendTree::NodeConnection &E : connections) { + StringName from = E.output_node; + StringName to = E.input_node; + int to_idx = E.input_index; graph->connect_node(from, 0, to, to_idx); } @@ -274,8 +274,8 @@ void AnimationNodeBlendTreeEditor::_add_node(int p_idx) { open_file->clear_filters(); List<String> filters; ResourceLoader::get_recognized_extensions_for_type("AnimationNode", &filters); - for (List<String>::Element *E = filters.front(); E; E = E->next()) { - open_file->add_filter("*." + E->get()); + for (const String &E : filters) { + open_file->add_filter("*." + E); } open_file->popup_file_dialog(); return; @@ -394,9 +394,9 @@ void AnimationNodeBlendTreeEditor::_delete_request(const String &p_which) { List<AnimationNodeBlendTree::NodeConnection> conns; blend_tree->get_node_connections(&conns); - for (List<AnimationNodeBlendTree::NodeConnection>::Element *E = conns.front(); E; E = E->next()) { - if (E->get().output_node == p_which || E->get().input_node == p_which) { - undo_redo->add_undo_method(blend_tree.ptr(), "connect_node", E->get().input_node, E->get().input_index, E->get().output_node); + for (const AnimationNodeBlendTree::NodeConnection &E : conns) { + if (E.output_node == p_which || E.input_node == p_which) { + undo_redo->add_undo_method(blend_tree.ptr(), "connect_node", E.input_node, E.input_index, E.output_node); } } @@ -423,8 +423,8 @@ void AnimationNodeBlendTreeEditor::_delete_nodes_request() { undo_redo->create_action(TTR("Delete Node(s)")); - for (List<StringName>::Element *F = to_erase.front(); F; F = F->next()) { - _delete_request(F->get()); + for (const StringName &F : to_erase) { + _delete_request(F); } undo_redo->commit_action(); @@ -517,8 +517,8 @@ bool AnimationNodeBlendTreeEditor::_update_filters(const Ref<AnimationNode> &ano List<StringName> animations; player->get_animation_list(&animations); - for (List<StringName>::Element *E = animations.front(); E; E = E->next()) { - Ref<Animation> anim = player->get_animation(E->get()); + for (const StringName &E : animations) { + Ref<Animation> anim = player->get_animation(E); for (int i = 0; i < anim->get_track_count(); i++) { String track_path = anim->track_get_path(i); paths.insert(track_path); @@ -617,7 +617,7 @@ bool AnimationNodeBlendTreeEditor::_update_filters(const Ref<AnimationNode> &ano ti->set_text(0, F->get()); ti->set_selectable(0, false); ti->set_editable(0, false); - ti->set_icon(0, get_theme_icon("BoneAttachment3D", "EditorIcons")); + ti->set_icon(0, get_theme_icon(SNAME("BoneAttachment3D"), SNAME("EditorIcons"))); } else { ti = parenthood[accum]; } @@ -628,7 +628,7 @@ bool AnimationNodeBlendTreeEditor::_update_filters(const Ref<AnimationNode> &ano ti->set_cell_mode(0, TreeItem::CELL_MODE_CHECK); ti->set_text(0, concat); ti->set_checked(0, anode->is_path_filtered(path)); - ti->set_icon(0, get_theme_icon("BoneAttachment3D", "EditorIcons")); + ti->set_icon(0, get_theme_icon(SNAME("BoneAttachment3D"), SNAME("EditorIcons"))); ti->set_metadata(0, path); } else { @@ -690,8 +690,8 @@ void AnimationNodeBlendTreeEditor::_removed_from_graph() { void AnimationNodeBlendTreeEditor::_notification(int p_what) { if (p_what == NOTIFICATION_ENTER_TREE || p_what == NOTIFICATION_THEME_CHANGED) { - error_panel->add_theme_style_override("panel", get_theme_stylebox("bg", "Tree")); - error_label->add_theme_color_override("font_color", get_theme_color("error_color", "Editor")); + error_panel->add_theme_style_override("panel", get_theme_stylebox(SNAME("bg"), SNAME("Tree"))); + error_label->add_theme_color_override("font_color", get_theme_color(SNAME("error_color"), SNAME("Editor"))); if (p_what == NOTIFICATION_THEME_CHANGED && is_visible_in_tree()) { _update_graph(); @@ -718,13 +718,13 @@ void AnimationNodeBlendTreeEditor::_notification(int p_what) { List<AnimationNodeBlendTree::NodeConnection> conns; blend_tree->get_node_connections(&conns); - for (List<AnimationNodeBlendTree::NodeConnection>::Element *E = conns.front(); E; E = E->next()) { + for (const AnimationNodeBlendTree::NodeConnection &E : conns) { float activity = 0; - StringName path = AnimationTreeEditor::get_singleton()->get_base_path() + E->get().input_node; + StringName path = AnimationTreeEditor::get_singleton()->get_base_path() + E.input_node; if (AnimationTreeEditor::get_singleton()->get_tree() && !AnimationTreeEditor::get_singleton()->get_tree()->is_state_invalid()) { - activity = AnimationTreeEditor::get_singleton()->get_tree()->get_connection_activity(path, E->get().input_index); + activity = AnimationTreeEditor::get_singleton()->get_tree()->get_connection_activity(path, E.input_index); } - graph->set_connection_activity(E->get().output_node, 0, E->get().input_node, E->get().input_index, activity); + graph->set_connection_activity(E.output_node, 0, E.input_node, E.input_index, activity); } AnimationTree *graph_player = AnimationTreeEditor::get_singleton()->get_tree(); @@ -741,7 +741,7 @@ void AnimationNodeBlendTreeEditor::_notification(int p_what) { Ref<Animation> anim = player->get_animation(an->get_animation()); if (anim.is_valid()) { E->get()->set_max(anim->get_length()); - //StringName path = AnimationTreeEditor::get_singleton()->get_base_path() + E->get().input_node; + //StringName path = AnimationTreeEditor::get_singleton()->get_base_path() + E.input_node; StringName time_path = AnimationTreeEditor::get_singleton()->get_base_path() + String(E->key()) + "/time"; E->get()->set_value(AnimationTreeEditor::get_singleton()->get_tree()->get(time_path)); } @@ -828,10 +828,10 @@ void AnimationNodeBlendTreeEditor::_node_renamed(const String &p_text, Ref<Anima List<AnimationNodeBlendTree::NodeConnection> connections; blend_tree->get_node_connections(&connections); - for (List<AnimationNodeBlendTree::NodeConnection>::Element *E = connections.front(); E; E = E->next()) { - StringName from = E->get().output_node; - StringName to = E->get().input_node; - int to_idx = E->get().input_index; + for (const AnimationNodeBlendTree::NodeConnection &E : connections) { + StringName from = E.output_node; + StringName to = E.input_node; + int to_idx = E.input_index; graph->connect_node(from, 0, to, to_idx); } diff --git a/editor/plugins/animation_player_editor_plugin.cpp b/editor/plugins/animation_player_editor_plugin.cpp index 2b92943f7e..681c3e7195 100644 --- a/editor/plugins/animation_player_editor_plugin.cpp +++ b/editor/plugins/animation_player_editor_plugin.cpp @@ -99,23 +99,23 @@ void AnimationPlayerEditor::_notification(int p_what) { get_tree()->connect("node_removed", callable_mp(this, &AnimationPlayerEditor::_node_removed)); - add_theme_style_override("panel", editor->get_gui_base()->get_theme_stylebox("panel", "Panel")); + add_theme_style_override("panel", editor->get_gui_base()->get_theme_stylebox(SNAME("panel"), SNAME("Panel"))); } break; case EditorSettings::NOTIFICATION_EDITOR_SETTINGS_CHANGED: { - add_theme_style_override("panel", editor->get_gui_base()->get_theme_stylebox("panel", "Panel")); + add_theme_style_override("panel", editor->get_gui_base()->get_theme_stylebox(SNAME("panel"), SNAME("Panel"))); } break; case NOTIFICATION_TRANSLATION_CHANGED: case NOTIFICATION_LAYOUT_DIRECTION_CHANGED: case NOTIFICATION_THEME_CHANGED: { - autoplay->set_icon(get_theme_icon("AutoPlay", "EditorIcons")); + autoplay->set_icon(get_theme_icon(SNAME("AutoPlay"), SNAME("EditorIcons"))); - play->set_icon(get_theme_icon("PlayStart", "EditorIcons")); - play_from->set_icon(get_theme_icon("Play", "EditorIcons")); - play_bw->set_icon(get_theme_icon("PlayStartBackwards", "EditorIcons")); - play_bw_from->set_icon(get_theme_icon("PlayBackwards", "EditorIcons")); + play->set_icon(get_theme_icon(SNAME("PlayStart"), SNAME("EditorIcons"))); + play_from->set_icon(get_theme_icon(SNAME("Play"), SNAME("EditorIcons"))); + play_bw->set_icon(get_theme_icon(SNAME("PlayStartBackwards"), SNAME("EditorIcons"))); + play_bw_from->set_icon(get_theme_icon(SNAME("PlayBackwards"), SNAME("EditorIcons"))); - autoplay_icon = get_theme_icon("AutoPlay", "EditorIcons"); - reset_icon = get_theme_icon("Reload", "EditorIcons"); + autoplay_icon = get_theme_icon(SNAME("AutoPlay"), SNAME("EditorIcons")); + reset_icon = get_theme_icon(SNAME("Reload"), SNAME("EditorIcons")); { Ref<Image> autoplay_img = autoplay_icon->get_image(); Ref<Image> reset_img = reset_icon->get_image(); @@ -128,17 +128,17 @@ void AnimationPlayerEditor::_notification(int p_what) { autoplay_reset_icon.instantiate(); autoplay_reset_icon->create_from_image(autoplay_reset_img); } - stop->set_icon(get_theme_icon("Stop", "EditorIcons")); + stop->set_icon(get_theme_icon(SNAME("Stop"), SNAME("EditorIcons"))); - onion_toggle->set_icon(get_theme_icon("Onion", "EditorIcons")); - onion_skinning->set_icon(get_theme_icon("GuiTabMenuHl", "EditorIcons")); + onion_toggle->set_icon(get_theme_icon(SNAME("Onion"), SNAME("EditorIcons"))); + onion_skinning->set_icon(get_theme_icon(SNAME("GuiTabMenuHl"), SNAME("EditorIcons"))); - pin->set_icon(get_theme_icon("Pin", "EditorIcons")); + pin->set_icon(get_theme_icon(SNAME("Pin"), SNAME("EditorIcons"))); - tool_anim->add_theme_style_override("normal", get_theme_stylebox("normal", "Button")); - track_editor->get_edit_menu()->add_theme_style_override("normal", get_theme_stylebox("normal", "Button")); + tool_anim->add_theme_style_override("normal", get_theme_stylebox(SNAME("normal"), SNAME("Button"))); + track_editor->get_edit_menu()->add_theme_style_override("normal", get_theme_stylebox(SNAME("normal"), SNAME("Button"))); -#define ITEM_ICON(m_item, m_icon) tool_anim->get_popup()->set_item_icon(tool_anim->get_popup()->get_item_index(m_item), get_theme_icon(m_icon, "EditorIcons")) +#define ITEM_ICON(m_item, m_icon) tool_anim->get_popup()->set_item_icon(tool_anim->get_popup()->get_item_index(m_item), get_theme_icon(SNAME(m_icon), SNAME("EditorIcons"))) ITEM_ICON(TOOL_NEW_ANIM, "New"); ITEM_ICON(TOOL_LOAD_ANIM, "Load"); @@ -350,8 +350,8 @@ void AnimationPlayerEditor::_animation_load() { List<String> extensions; ResourceLoader::get_recognized_extensions_for_type("Animation", &extensions); - for (List<String>::Element *E = extensions.front(); E; E = E->next()) { - file->add_filter("*." + E->get() + " ; " + E->get().to_upper()); + for (const String &E : extensions) { + file->add_filter("*." + E + " ; " + E.to_upper()); } file->popup_file_dialog(); @@ -373,7 +373,7 @@ void AnimationPlayerEditor::_animation_save_in_path(const Ref<Resource> &p_resou } ((Resource *)p_resource.ptr())->set_path(path); - editor->emit_signal("resource_saved", p_resource); + editor->emit_signal(SNAME("resource_saved"), p_resource); } void AnimationPlayerEditor::_animation_save(const Ref<Resource> &p_resource) { @@ -408,7 +408,8 @@ void AnimationPlayerEditor::_animation_save_as(const Ref<Resource> &p_resource) if (p_resource->get_name() != "") { path = p_resource->get_name() + "." + extensions.front()->get().to_lower(); } else { - path = "new_" + p_resource->get_class().to_lower() + "." + extensions.front()->get().to_lower(); + String resource_name_snake_case = p_resource->get_class().camelcase_to_underscore(); + path = "new_" + resource_name_snake_case + "." + extensions.front()->get().to_lower(); } } } @@ -584,8 +585,7 @@ void AnimationPlayerEditor::_animation_blend() { blend_editor.next->clear(); blend_editor.next->add_item("", i); - for (List<StringName>::Element *E = anims.front(); E; E = E->next()) { - String to = E->get(); + for (const StringName &to : anims) { TreeItem *blend = blend_editor.tree->create_item(root); blend->set_editable(0, false); blend->set_editable(1, true); @@ -830,20 +830,20 @@ void AnimationPlayerEditor::_update_player() { } int active_idx = -1; - for (List<StringName>::Element *E = animlist.front(); E; E = E->next()) { + for (const StringName &E : animlist) { Ref<Texture2D> icon; - if (E->get() == player->get_autoplay()) { - if (E->get() == "RESET") { + if (E == player->get_autoplay()) { + if (E == "RESET") { icon = autoplay_reset_icon; } else { icon = autoplay_icon; } - } else if (E->get() == "RESET") { + } else if (E == "RESET") { icon = reset_icon; } - animation->add_icon_item(icon, E->get()); + animation->add_icon_item(icon, E); - if (player->get_assigned_animation() == E->get()) { + if (player->get_assigned_animation() == E) { active_idx = animation->get_item_count() - 1; } } @@ -966,9 +966,9 @@ void AnimationPlayerEditor::_animation_duplicate() { Ref<Animation> new_anim = memnew(Animation); List<PropertyInfo> plist; anim->get_property_list(&plist); - for (List<PropertyInfo>::Element *E = plist.front(); E; E = E->next()) { - if (E->get().usage & PROPERTY_USAGE_STORAGE) { - new_anim->set(E->get().name, anim->get(E->get().name)); + for (const PropertyInfo &E : plist) { + if (E.usage & PROPERTY_USAGE_STORAGE) { + new_anim->set(E.name, anim->get(E.name)); } } new_anim->set_path(""); @@ -1324,11 +1324,11 @@ void AnimationPlayerEditor::_prepare_onion_layers_1() { } // And go to next step afterwards. - call_deferred("_prepare_onion_layers_2"); + call_deferred(SNAME("_prepare_onion_layers_2")); } void AnimationPlayerEditor::_prepare_onion_layers_1_deferred() { - call_deferred("_prepare_onion_layers_1"); + call_deferred(SNAME("_prepare_onion_layers_1")); } void AnimationPlayerEditor::_prepare_onion_layers_2() { @@ -1733,27 +1733,27 @@ AnimationPlayerEditor::AnimationPlayerEditor(EditorNode *p_editor, AnimationPlay onion.capture.material = Ref<ShaderMaterial>(memnew(ShaderMaterial)); onion.capture.shader = Ref<Shader>(memnew(Shader)); - onion.capture.shader->set_code(" \ - shader_type canvas_item; \ - \ - uniform vec4 bkg_color; \ - uniform vec4 dir_color; \ - uniform bool differences_only; \ - uniform sampler2D present; \ - \ - float zero_if_equal(vec4 a, vec4 b) { \ - return smoothstep(0.0, 0.005, length(a.rgb - b.rgb) / sqrt(3.0)); \ - } \ - \ - void fragment() { \ - vec4 capture_samp = texture(TEXTURE, UV); \ - vec4 present_samp = texture(present, UV); \ - float bkg_mask = zero_if_equal(capture_samp, bkg_color); \ - float diff_mask = 1.0 - zero_if_equal(present_samp, bkg_color); \ - diff_mask = min(1.0, diff_mask + float(!differences_only)); \ - COLOR = vec4(capture_samp.rgb * dir_color.rgb, bkg_mask * diff_mask); \ - } \ - "); + onion.capture.shader->set_code(R"( +shader_type canvas_item; + +uniform vec4 bkg_color; +uniform vec4 dir_color; +uniform bool differences_only; +uniform sampler2D present; + +float zero_if_equal(vec4 a, vec4 b) { + return smoothstep(0.0, 0.005, length(a.rgb - b.rgb) / sqrt(3.0)); +} + +void fragment() { + vec4 capture_samp = texture(TEXTURE, UV); + vec4 present_samp = texture(present, UV); + float bkg_mask = zero_if_equal(capture_samp, bkg_color); + float diff_mask = 1.0 - zero_if_equal(present_samp, bkg_color); + diff_mask = min(1.0, diff_mask + float(!differences_only)); + COLOR = vec4(capture_samp.rgb * dir_color.rgb, bkg_mask * diff_mask); +} +)"); RS::get_singleton()->material_set_shader(onion.capture.material->get_rid(), onion.capture.shader->get_rid()); } diff --git a/editor/plugins/animation_state_machine_editor.cpp b/editor/plugins/animation_state_machine_editor.cpp index 94e526922d..a1f96f21bf 100644 --- a/editor/plugins/animation_state_machine_editor.cpp +++ b/editor/plugins/animation_state_machine_editor.cpp @@ -93,21 +93,21 @@ void AnimationNodeStateMachineEditor::_state_machine_gui_input(const Ref<InputEv if (ap) { List<StringName> names; ap->get_animation_list(&names); - for (List<StringName>::Element *E = names.front(); E; E = E->next()) { - animations_menu->add_icon_item(get_theme_icon("Animation", "EditorIcons"), E->get()); - animations_to_add.push_back(E->get()); + for (const StringName &E : names) { + animations_menu->add_icon_item(get_theme_icon(SNAME("Animation"), SNAME("EditorIcons")), E); + animations_to_add.push_back(E); } } } - for (List<StringName>::Element *E = classes.front(); E; E = E->next()) { - String name = String(E->get()).replace_first("AnimationNode", ""); + for (const StringName &E : classes) { + String name = String(E).replace_first("AnimationNode", ""); if (name == "Animation") { continue; // nope } int idx = menu->get_item_count(); menu->add_item(vformat("Add %s", name), idx); - menu->set_item_metadata(idx, E->get()); + menu->set_item_metadata(idx, E); } Ref<AnimationNode> clipb = EditorSettings::get_singleton()->get_resource_clipboard(); @@ -145,7 +145,7 @@ void AnimationNodeStateMachineEditor::_state_machine_gui_input(const Ref<InputEv if (node_rects[i].name.has_point(mb->get_position())) { //edit name - Ref<StyleBox> line_sb = get_theme_stylebox("normal", "LineEdit"); + Ref<StyleBox> line_sb = get_theme_stylebox(SNAME("normal"), SNAME("LineEdit")); Rect2 edit_rect = node_rects[i].name; edit_rect.position -= line_sb->get_offset(); @@ -163,7 +163,7 @@ void AnimationNodeStateMachineEditor::_state_machine_gui_input(const Ref<InputEv } if (node_rects[i].edit.has_point(mb->get_position())) { //edit name - call_deferred("_open_editor", node_rects[i].node_name); + call_deferred(SNAME("_open_editor"), node_rects[i].node_name); return; } @@ -318,24 +318,24 @@ void AnimationNodeStateMachineEditor::_state_machine_gui_input(const Ref<InputEv float best_d_x = 1e20; float best_d_y = 1e20; - for (List<StringName>::Element *E = nodes.front(); E; E = E->next()) { - if (E->get() == selected_node) { + for (const StringName &E : nodes) { + if (E == selected_node) { continue; } - Vector2 npos = state_machine->get_node_position(E->get()); + Vector2 npos = state_machine->get_node_position(E); float d_x = ABS(npos.x - cpos.x); if (d_x < MIN(5, best_d_x)) { drag_ofs.x -= cpos.x - npos.x; best_d_x = d_x; - snap_x = E->get(); + snap_x = E; } float d_y = ABS(npos.y - cpos.y); if (d_y < MIN(5, best_d_y)) { drag_ofs.y -= cpos.y - npos.y; best_d_y = d_y; - snap_y = E->get(); + snap_y = E; } } } @@ -409,8 +409,8 @@ void AnimationNodeStateMachineEditor::_add_menu_type(int p_index) { open_file->clear_filters(); List<String> filters; ResourceLoader::get_recognized_extensions_for_type("AnimationRootNode", &filters); - for (List<String>::Element *E = filters.front(); E; E = E->next()) { - open_file->add_filter("*." + E->get()); + for (const String &E : filters) { + open_file->add_filter("*." + E); } open_file->popup_file_dialog(); return; @@ -487,9 +487,9 @@ void AnimationNodeStateMachineEditor::_add_animation_type(int p_index) { } void AnimationNodeStateMachineEditor::_connection_draw(const Vector2 &p_from, const Vector2 &p_to, AnimationNodeStateMachineTransition::SwitchMode p_mode, bool p_enabled, bool p_selected, bool p_travel, bool p_auto_advance) { - Color linecolor = get_theme_color("font_color", "Label"); + Color linecolor = get_theme_color(SNAME("font_color"), SNAME("Label")); Color icon_color(1, 1, 1); - Color accent = get_theme_color("accent_color", "Editor"); + Color accent = get_theme_color(SNAME("accent_color"), SNAME("Editor")); if (!p_enabled) { linecolor.a *= 0.2; @@ -498,12 +498,12 @@ void AnimationNodeStateMachineEditor::_connection_draw(const Vector2 &p_from, co } Ref<Texture2D> icons[6] = { - get_theme_icon("TransitionImmediateBig", "EditorIcons"), - get_theme_icon("TransitionSyncBig", "EditorIcons"), - get_theme_icon("TransitionEndBig", "EditorIcons"), - get_theme_icon("TransitionImmediateAutoBig", "EditorIcons"), - get_theme_icon("TransitionSyncAutoBig", "EditorIcons"), - get_theme_icon("TransitionEndAutoBig", "EditorIcons") + get_theme_icon(SNAME("TransitionImmediateBig"), SNAME("EditorIcons")), + get_theme_icon(SNAME("TransitionSyncBig"), SNAME("EditorIcons")), + get_theme_icon(SNAME("TransitionEndBig"), SNAME("EditorIcons")), + get_theme_icon(SNAME("TransitionImmediateAutoBig"), SNAME("EditorIcons")), + get_theme_icon(SNAME("TransitionSyncAutoBig"), SNAME("EditorIcons")), + get_theme_icon(SNAME("TransitionEndAutoBig"), SNAME("EditorIcons")) }; if (p_selected) { @@ -555,19 +555,19 @@ void AnimationNodeStateMachineEditor::_clip_dst_line_to_rect(Vector2 &r_from, Ve void AnimationNodeStateMachineEditor::_state_machine_draw() { Ref<AnimationNodeStateMachinePlayback> playback = AnimationTreeEditor::get_singleton()->get_tree()->get(AnimationTreeEditor::get_singleton()->get_base_path() + "playback"); - Ref<StyleBox> style = get_theme_stylebox("state_machine_frame", "GraphNode"); - Ref<StyleBox> style_selected = get_theme_stylebox("state_machine_selectedframe", "GraphNode"); - - Ref<Font> font = get_theme_font("title_font", "GraphNode"); - int font_size = get_theme_font_size("title_font_size", "GraphNode"); - Color font_color = get_theme_color("title_color", "GraphNode"); - Ref<Texture2D> play = get_theme_icon("Play", "EditorIcons"); - Ref<Texture2D> auto_play = get_theme_icon("AutoPlay", "EditorIcons"); - Ref<Texture2D> edit = get_theme_icon("Edit", "EditorIcons"); - Color accent = get_theme_color("accent_color", "Editor"); - Color linecolor = get_theme_color("font_color", "Label"); + Ref<StyleBox> style = get_theme_stylebox(SNAME("state_machine_frame"), SNAME("GraphNode")); + Ref<StyleBox> style_selected = get_theme_stylebox(SNAME("state_machine_selectedframe"), SNAME("GraphNode")); + + Ref<Font> font = get_theme_font(SNAME("title_font"), SNAME("GraphNode")); + int font_size = get_theme_font_size(SNAME("title_font_size"), SNAME("GraphNode")); + Color font_color = get_theme_color(SNAME("title_color"), SNAME("GraphNode")); + Ref<Texture2D> play = get_theme_icon(SNAME("Play"), SNAME("EditorIcons")); + Ref<Texture2D> auto_play = get_theme_icon(SNAME("AutoPlay"), SNAME("EditorIcons")); + Ref<Texture2D> edit = get_theme_icon(SNAME("Edit"), SNAME("EditorIcons")); + Color accent = get_theme_color(SNAME("accent_color"), SNAME("Editor")); + Color linecolor = get_theme_color(SNAME("font_color"), SNAME("Label")); linecolor.a *= 0.3; - Ref<StyleBox> playing_overlay = get_theme_stylebox("position", "GraphNode"); + Ref<StyleBox> playing_overlay = get_theme_stylebox(SNAME("position"), SNAME("GraphNode")); bool playing = false; StringName current; @@ -606,11 +606,11 @@ void AnimationNodeStateMachineEditor::_state_machine_draw() { } //pre pass nodes so we know the rectangles - for (List<StringName>::Element *E = nodes.front(); E; E = E->next()) { - Ref<AnimationNode> anode = state_machine->get_node(E->get()); - String name = E->get(); + for (const StringName &E : nodes) { + Ref<AnimationNode> anode = state_machine->get_node(E); + String name = E; bool needs_editor = EditorNode::get_singleton()->item_has_editor(anode.ptr()); - Ref<StyleBox> sb = E->get() == selected_node ? style_selected : style; + Ref<StyleBox> sb = E == selected_node ? style_selected : style; Size2 s = sb->get_minimum_size(); int strsize = font->get_string_size(name, font_size).width; @@ -622,8 +622,8 @@ void AnimationNodeStateMachineEditor::_state_machine_draw() { } Vector2 offset; - offset += state_machine->get_node_position(E->get()) * EDSCALE; - if (selected_node == E->get() && dragging_selected) { + offset += state_machine->get_node_position(E) * EDSCALE; + if (selected_node == E && dragging_selected) { offset += drag_ofs; } offset -= s / 2; @@ -633,7 +633,7 @@ void AnimationNodeStateMachineEditor::_state_machine_draw() { NodeRect nr; nr.node = Rect2(offset, s); - nr.node_name = E->get(); + nr.node_name = E; scroll_range = scroll_range.merge(nr.node); //merge with range @@ -667,7 +667,7 @@ void AnimationNodeStateMachineEditor::_state_machine_draw() { _connection_draw(from, to, AnimationNodeStateMachineTransition::SwitchMode(transition_mode->get_selected()), true, false, false, false); } - Ref<Texture2D> tr_reference_icon = get_theme_icon("TransitionImmediateBig", "EditorIcons"); + Ref<Texture2D> tr_reference_icon = get_theme_icon(SNAME("TransitionImmediateBig"), SNAME("EditorIcons")); float tr_bidi_offset = int(tr_reference_icon->get_height() * 0.8); //draw transition lines @@ -857,7 +857,7 @@ void AnimationNodeStateMachineEditor::_state_machine_pos_draw() { float pos = CLAMP(play_pos, 0, len); float c = pos / len; - Color fg = get_theme_color("font_color", "Label"); + Color fg = get_theme_color(SNAME("font_color"), SNAME("Label")); Color bg = fg; bg.a *= 0.3; @@ -882,26 +882,26 @@ void AnimationNodeStateMachineEditor::_update_graph() { void AnimationNodeStateMachineEditor::_notification(int p_what) { if (p_what == NOTIFICATION_ENTER_TREE || p_what == NOTIFICATION_THEME_CHANGED || p_what == NOTIFICATION_LAYOUT_DIRECTION_CHANGED || p_what == NOTIFICATION_TRANSLATION_CHANGED) { - error_panel->add_theme_style_override("panel", get_theme_stylebox("bg", "Tree")); - error_label->add_theme_color_override("font_color", get_theme_color("error_color", "Editor")); - panel->add_theme_style_override("panel", get_theme_stylebox("bg", "Tree")); + error_panel->add_theme_style_override("panel", get_theme_stylebox(SNAME("bg"), SNAME("Tree"))); + error_label->add_theme_color_override("font_color", get_theme_color(SNAME("error_color"), SNAME("Editor"))); + panel->add_theme_style_override("panel", get_theme_stylebox(SNAME("bg"), SNAME("Tree"))); - tool_select->set_icon(get_theme_icon("ToolSelect", "EditorIcons")); - tool_create->set_icon(get_theme_icon("ToolAddNode", "EditorIcons")); - tool_connect->set_icon(get_theme_icon("ToolConnect", "EditorIcons")); + tool_select->set_icon(get_theme_icon(SNAME("ToolSelect"), SNAME("EditorIcons"))); + tool_create->set_icon(get_theme_icon(SNAME("ToolAddNode"), SNAME("EditorIcons"))); + tool_connect->set_icon(get_theme_icon(SNAME("ToolConnect"), SNAME("EditorIcons"))); transition_mode->clear(); - transition_mode->add_icon_item(get_theme_icon("TransitionImmediate", "EditorIcons"), TTR("Immediate")); - transition_mode->add_icon_item(get_theme_icon("TransitionSync", "EditorIcons"), TTR("Sync")); - transition_mode->add_icon_item(get_theme_icon("TransitionEnd", "EditorIcons"), TTR("At End")); + transition_mode->add_icon_item(get_theme_icon(SNAME("TransitionImmediate"), SNAME("EditorIcons")), TTR("Immediate")); + transition_mode->add_icon_item(get_theme_icon(SNAME("TransitionSync"), SNAME("EditorIcons")), TTR("Sync")); + transition_mode->add_icon_item(get_theme_icon(SNAME("TransitionEnd"), SNAME("EditorIcons")), TTR("At End")); - tool_erase->set_icon(get_theme_icon("Remove", "EditorIcons")); - tool_autoplay->set_icon(get_theme_icon("AutoPlay", "EditorIcons")); - tool_end->set_icon(get_theme_icon("AutoEnd", "EditorIcons")); + tool_erase->set_icon(get_theme_icon(SNAME("Remove"), SNAME("EditorIcons"))); + tool_autoplay->set_icon(get_theme_icon(SNAME("AutoPlay"), SNAME("EditorIcons"))); + tool_end->set_icon(get_theme_icon(SNAME("AutoEnd"), SNAME("EditorIcons"))); play_mode->clear(); - play_mode->add_icon_item(get_theme_icon("PlayTravel", "EditorIcons"), TTR("Travel")); - play_mode->add_icon_item(get_theme_icon("Play", "EditorIcons"), TTR("Immediate")); + play_mode->add_icon_item(get_theme_icon(SNAME("PlayTravel"), SNAME("EditorIcons")), TTR("Travel")); + play_mode->add_icon_item(get_theme_icon(SNAME("Play"), SNAME("EditorIcons")), TTR("Immediate")); } if (p_what == NOTIFICATION_PROCESS) { diff --git a/editor/plugins/animation_tree_editor_plugin.cpp b/editor/plugins/animation_tree_editor_plugin.cpp index e90665f84d..cd84be0c25 100644 --- a/editor/plugins/animation_tree_editor_plugin.cpp +++ b/editor/plugins/animation_tree_editor_plugin.cpp @@ -79,7 +79,7 @@ void AnimationTreeEditor::_update_path() { group.instantiate(); Button *b = memnew(Button); - b->set_text("Root"); + b->set_text(TTR("Root")); b->set_toggle_mode(true); b->set_button_group(group); b->set_pressed(true); @@ -215,8 +215,8 @@ Vector<String> AnimationTreeEditor::get_animation_list() { List<StringName> anims; ap->get_animation_list(&anims); Vector<String> ret; - for (List<StringName>::Element *E = anims.front(); E; E = E->next()) { - ret.push_back(E->get()); + for (const StringName &E : anims) { + ret.push_back(E); } return ret; diff --git a/editor/plugins/asset_library_editor_plugin.cpp b/editor/plugins/asset_library_editor_plugin.cpp index 596b2a6527..785bab42cf 100644 --- a/editor/plugins/asset_library_editor_plugin.cpp +++ b/editor/plugins/asset_library_editor_plugin.cpp @@ -58,7 +58,7 @@ void EditorAssetLibraryItem::set_image(int p_type, int p_index, const Ref<Textur void EditorAssetLibraryItem::_notification(int p_what) { if (p_what == NOTIFICATION_ENTER_TREE) { - icon->set_normal_texture(get_theme_icon("ProjectIconLoading", "EditorIcons")); + icon->set_normal_texture(get_theme_icon(SNAME("ProjectIconLoading"), SNAME("EditorIcons"))); category->add_theme_color_override("font_color", Color(0.5, 0.5, 0.5)); author->add_theme_color_override("font_color", Color(0.5, 0.5, 0.5)); price->add_theme_color_override("font_color", Color(0.5, 0.5, 0.5)); @@ -66,15 +66,15 @@ void EditorAssetLibraryItem::_notification(int p_what) { } void EditorAssetLibraryItem::_asset_clicked() { - emit_signal("asset_selected", asset_id); + emit_signal(SNAME("asset_selected"), asset_id); } void EditorAssetLibraryItem::_category_clicked() { - emit_signal("category_selected", category_id); + emit_signal(SNAME("category_selected"), category_id); } void EditorAssetLibraryItem::_author_clicked() { - emit_signal("author_selected", author_id); + emit_signal(SNAME("author_selected"), author_id); } void EditorAssetLibraryItem::_bind_methods() { @@ -144,7 +144,7 @@ void EditorAssetLibraryItemDescription::set_image(int p_type, int p_index, const for (int i = 0; i < preview_images.size(); i++) { if (preview_images[i].id == p_index) { if (preview_images[i].is_video) { - Ref<Image> overlay = previews->get_theme_icon("PlayOverlay", "EditorIcons")->get_image(); + Ref<Image> overlay = previews->get_theme_icon(SNAME("PlayOverlay"), SNAME("EditorIcons"))->get_image(); Ref<Image> thumbnail = p_image->get_image(); thumbnail = thumbnail->duplicate(); Point2 overlay_pos = Point2((thumbnail->get_width() - overlay->get_width()) / 2, (thumbnail->get_height() - overlay->get_height()) / 2); @@ -185,7 +185,7 @@ void EditorAssetLibraryItemDescription::set_image(int p_type, int p_index, const void EditorAssetLibraryItemDescription::_notification(int p_what) { switch (p_what) { case NOTIFICATION_ENTER_TREE: { - previews_bg->add_theme_style_override("panel", previews->get_theme_stylebox("normal", "TextEdit")); + previews_bg->add_theme_style_override("panel", previews->get_theme_stylebox(SNAME("normal"), SNAME("TextEdit"))); } break; } } @@ -240,12 +240,12 @@ void EditorAssetLibraryItemDescription::add_preview(int p_id, bool p_video, cons preview.video_link = p_url; preview.is_video = p_video; preview.button = memnew(Button); - preview.button->set_icon(previews->get_theme_icon("ThumbnailWait", "EditorIcons")); + preview.button->set_icon(previews->get_theme_icon(SNAME("ThumbnailWait"), SNAME("EditorIcons"))); preview.button->set_toggle_mode(true); preview.button->connect("pressed", callable_mp(this, &EditorAssetLibraryItemDescription::_preview_click), varray(p_id)); preview_hb->add_child(preview.button); if (!p_video) { - preview.image = previews->get_theme_icon("ThumbnailWait", "EditorIcons"); + preview.image = previews->get_theme_icon(SNAME("ThumbnailWait"), SNAME("EditorIcons")); } preview_images.push_back(preview); if (preview_images.size() == 1 && !p_video) { @@ -379,7 +379,7 @@ void EditorAssetLibraryItemDownload::configure(const String &p_title, int p_asse icon->set_texture(p_preview); asset_id = p_asset_id; if (!p_preview.is_valid()) { - icon->set_texture(get_theme_icon("FileBrokenBigThumb", "EditorIcons")); + icon->set_texture(get_theme_icon(SNAME("FileBrokenBigThumb"), SNAME("EditorIcons"))); } host = p_download_url; sha256 = p_sha256_hash; @@ -390,8 +390,8 @@ void EditorAssetLibraryItemDownload::_notification(int p_what) { switch (p_what) { // FIXME: The editor crashes if 'NOTICATION_THEME_CHANGED' is used. case NOTIFICATION_ENTER_TREE: { - add_theme_style_override("panel", get_theme_stylebox("panel", "TabContainer")); - dismiss->set_normal_texture(get_theme_icon("Close", "EditorIcons")); + add_theme_style_override("panel", get_theme_stylebox(SNAME("panel"), SNAME("TabContainer"))); + dismiss->set_normal_texture(get_theme_icon(SNAME("Close"), SNAME("EditorIcons"))); } break; case NOTIFICATION_PROCESS: { // Make the progress bar visible again when retrying the download. @@ -455,7 +455,7 @@ void EditorAssetLibraryItemDownload::_install() { String file = download->get_download_file(); if (external_install) { - emit_signal("install_asset", file, title->get_text()); + emit_signal(SNAME("install_asset"), file, title->get_text()); return; } @@ -553,8 +553,8 @@ EditorAssetLibraryItemDownload::EditorAssetLibraryItemDownload() { void EditorAssetLibrary::_notification(int p_what) { switch (p_what) { case NOTIFICATION_READY: { - error_tr->set_texture(get_theme_icon("Error", "EditorIcons")); - filter->set_right_icon(get_theme_icon("Search", "EditorIcons")); + error_tr->set_texture(get_theme_icon(SNAME("Error"), SNAME("EditorIcons"))); + filter->set_right_icon(get_theme_icon(SNAME("Search"), SNAME("EditorIcons"))); filter->set_clear_button_enabled(true); error_label->raise(); @@ -588,10 +588,10 @@ void EditorAssetLibrary::_notification(int p_what) { } break; case NOTIFICATION_THEME_CHANGED: { - library_scroll_bg->add_theme_style_override("panel", get_theme_stylebox("bg", "Tree")); - downloads_scroll->add_theme_style_override("bg", get_theme_stylebox("bg", "Tree")); - error_tr->set_texture(get_theme_icon("Error", "EditorIcons")); - filter->set_right_icon(get_theme_icon("Search", "EditorIcons")); + library_scroll_bg->add_theme_style_override("panel", get_theme_stylebox(SNAME("bg"), SNAME("Tree"))); + downloads_scroll->add_theme_style_override("bg", get_theme_stylebox(SNAME("bg"), SNAME("Tree"))); + error_tr->set_texture(get_theme_icon(SNAME("Error"), SNAME("EditorIcons"))); + filter->set_right_icon(get_theme_icon(SNAME("Search"), SNAME("EditorIcons"))); filter->set_clear_button_enabled(true); } break; @@ -603,12 +603,11 @@ void EditorAssetLibrary::_notification(int p_what) { void EditorAssetLibrary::_update_repository_options() { Dictionary default_urls; - default_urls["godotengine.org"] = "https://godotengine.org/asset-library/api"; - default_urls["localhost"] = "http://127.0.0.1/asset-library/api"; + default_urls["godotengine.org (Official)"] = "https://godotengine.org/asset-library/api"; Dictionary available_urls = _EDITOR_DEF("asset_library/available_urls", default_urls, true); repository->clear(); Array keys = available_urls.keys(); - for (int i = 0; i < available_urls.size(); i++) { + for (int i = 0; i < keys.size(); i++) { String key = keys[i]; repository->add_item(key); repository->set_item_metadata(i, available_urls[key]); @@ -773,7 +772,7 @@ void EditorAssetLibrary::_image_update(bool use_cache, bool final, const PackedB } if (!image_set && final) { - obj->call("set_image", image_queue[p_queue_id].image_type, image_queue[p_queue_id].image_index, get_theme_icon("FileBrokenBigThumb", "EditorIcons")); + obj->call("set_image", image_queue[p_queue_id].image_type, image_queue[p_queue_id].image_index, get_theme_icon(SNAME("FileBrokenBigThumb"), SNAME("EditorIcons"))); } } } @@ -816,7 +815,7 @@ void EditorAssetLibrary::_image_request_completed(int p_status, int p_code, cons WARN_PRINT("Error getting image file from URL: " + image_queue[p_queue_id].image_url); Object *obj = ObjectDB::get_instance(image_queue[p_queue_id].target); if (obj) { - obj->call("set_image", image_queue[p_queue_id].image_type, image_queue[p_queue_id].image_index, get_theme_icon("FileBrokenBigThumb", "EditorIcons")); + obj->call("set_image", image_queue[p_queue_id].image_type, image_queue[p_queue_id].image_index, get_theme_icon(SNAME("FileBrokenBigThumb"), SNAME("EditorIcons"))); } } @@ -1315,7 +1314,7 @@ void EditorAssetLibrary::_manage_plugins() { } void EditorAssetLibrary::_install_external_asset(String p_zip_path, String p_title) { - emit_signal("install_asset", p_zip_path, p_title); + emit_signal(SNAME("install_asset"), p_zip_path, p_title); } void EditorAssetLibrary::disable_community_support() { @@ -1490,7 +1489,7 @@ EditorAssetLibrary::EditorAssetLibrary(bool p_templates_only) { error_hb = memnew(HBoxContainer); library_main->add_child(error_hb); error_label = memnew(Label); - error_label->add_theme_color_override("color", get_theme_color("error_color", "Editor")); + error_label->add_theme_color_override("color", get_theme_color(SNAME("error_color"), SNAME("Editor"))); error_hb->add_child(error_label); error_tr = memnew(TextureRect); error_tr->set_v_size_flags(Control::SIZE_SHRINK_CENTER); diff --git a/editor/plugins/audio_stream_editor_plugin.cpp b/editor/plugins/audio_stream_editor_plugin.cpp index 3b54b30b54..482c08f50a 100644 --- a/editor/plugins/audio_stream_editor_plugin.cpp +++ b/editor/plugins/audio_stream_editor_plugin.cpp @@ -43,10 +43,10 @@ void AudioStreamEditor::_notification(int p_what) { } if (p_what == NOTIFICATION_THEME_CHANGED || p_what == NOTIFICATION_ENTER_TREE) { - _play_button->set_icon(get_theme_icon("MainPlay", "EditorIcons")); - _stop_button->set_icon(get_theme_icon("Stop", "EditorIcons")); - _preview->set_color(get_theme_color("dark_color_2", "Editor")); - set_color(get_theme_color("dark_color_1", "Editor")); + _play_button->set_icon(get_theme_icon(SNAME("MainPlay"), SNAME("EditorIcons"))); + _stop_button->set_icon(get_theme_icon(SNAME("Stop"), SNAME("EditorIcons"))); + _preview->set_color(get_theme_color(SNAME("dark_color_2"), SNAME("Editor"))); + set_color(get_theme_color(SNAME("dark_color_1"), SNAME("Editor"))); _indicator->update(); _preview->update(); @@ -86,7 +86,7 @@ void AudioStreamEditor::_draw_preview() { } Vector<Color> color; - color.push_back(get_theme_color("contrast_color_2", "Editor")); + color.push_back(get_theme_color(SNAME("contrast_color_2"), SNAME("Editor"))); RS::get_singleton()->canvas_item_add_multiline(_preview->get_canvas_item(), lines, color); } @@ -109,25 +109,25 @@ void AudioStreamEditor::_play() { // '_pausing' variable indicates that we want to pause the audio player, not stop it. See '_on_finished()'. _pausing = true; _player->stop(); - _play_button->set_icon(get_theme_icon("MainPlay", "EditorIcons")); + _play_button->set_icon(get_theme_icon(SNAME("MainPlay"), SNAME("EditorIcons"))); set_process(false); } else { _player->play(_current); - _play_button->set_icon(get_theme_icon("Pause", "EditorIcons")); + _play_button->set_icon(get_theme_icon(SNAME("Pause"), SNAME("EditorIcons"))); set_process(true); } } void AudioStreamEditor::_stop() { _player->stop(); - _play_button->set_icon(get_theme_icon("MainPlay", "EditorIcons")); + _play_button->set_icon(get_theme_icon(SNAME("MainPlay"), SNAME("EditorIcons"))); _current = 0; _indicator->update(); set_process(false); } void AudioStreamEditor::_on_finished() { - _play_button->set_icon(get_theme_icon("MainPlay", "EditorIcons")); + _play_button->set_icon(get_theme_icon(SNAME("MainPlay"), SNAME("EditorIcons"))); if (!_pausing) { _current = 0; _indicator->update(); @@ -145,11 +145,11 @@ void AudioStreamEditor::_draw_indicator() { Rect2 rect = _preview->get_rect(); float len = stream->get_length(); float ofs_x = _current / len * rect.size.width; - const Color color = get_theme_color("accent_color", "Editor"); + const Color color = get_theme_color(SNAME("accent_color"), SNAME("Editor")); _indicator->draw_line(Point2(ofs_x, 0), Point2(ofs_x, rect.size.height), color, Math::round(2 * EDSCALE)); _indicator->draw_texture( - get_theme_icon("TimelineIndicator", "EditorIcons"), - Point2(ofs_x - get_theme_icon("TimelineIndicator", "EditorIcons")->get_width() * 0.5, 0), + get_theme_icon(SNAME("TimelineIndicator"), SNAME("EditorIcons")), + Point2(ofs_x - get_theme_icon(SNAME("TimelineIndicator"), SNAME("EditorIcons"))->get_width() * 0.5, 0), color); _current_label->set_text(String::num(_current, 2).pad_decimals(2) + " /"); @@ -243,14 +243,14 @@ AudioStreamEditor::AudioStreamEditor() { _current_label = memnew(Label); _current_label->set_align(Label::ALIGN_RIGHT); _current_label->set_h_size_flags(SIZE_EXPAND_FILL); - _current_label->add_theme_font_override("font", EditorNode::get_singleton()->get_gui_base()->get_theme_font("status_source", "EditorFonts")); - _current_label->add_theme_font_size_override("font_size", EditorNode::get_singleton()->get_gui_base()->get_theme_font_size("status_source_size", "EditorFonts")); + _current_label->add_theme_font_override("font", EditorNode::get_singleton()->get_gui_base()->get_theme_font(SNAME("status_source"), SNAME("EditorFonts"))); + _current_label->add_theme_font_size_override("font_size", EditorNode::get_singleton()->get_gui_base()->get_theme_font_size(SNAME("status_source_size"), SNAME("EditorFonts"))); _current_label->set_modulate(Color(1, 1, 1, 0.5)); hbox->add_child(_current_label); _duration_label = memnew(Label); - _duration_label->add_theme_font_override("font", EditorNode::get_singleton()->get_gui_base()->get_theme_font("status_source", "EditorFonts")); - _duration_label->add_theme_font_size_override("font_size", EditorNode::get_singleton()->get_gui_base()->get_theme_font_size("status_source_size", "EditorFonts")); + _duration_label->add_theme_font_override("font", EditorNode::get_singleton()->get_gui_base()->get_theme_font(SNAME("status_source"), SNAME("EditorFonts"))); + _duration_label->add_theme_font_size_override("font_size", EditorNode::get_singleton()->get_gui_base()->get_theme_font_size(SNAME("status_source_size"), SNAME("EditorFonts"))); hbox->add_child(_duration_label); } diff --git a/editor/plugins/canvas_item_editor_plugin.cpp b/editor/plugins/canvas_item_editor_plugin.cpp index bd9847ea95..cf9e94bd3b 100644 --- a/editor/plugins/canvas_item_editor_plugin.cpp +++ b/editor/plugins/canvas_item_editor_plugin.cpp @@ -301,8 +301,8 @@ void CanvasItemEditor::_snap_other_nodes( // Check if the element is in the exception bool exception = false; - for (List<const CanvasItem *>::Element *E = p_exceptions.front(); E; E = E->next()) { - if (E->get() == p_current) { + for (const CanvasItem *&E : p_exceptions) { + if (E == p_current) { exception = true; break; } @@ -399,8 +399,8 @@ Point2 CanvasItemEditor::snap_point(Point2 p_target, unsigned int p_modes, unsig if ((is_snap_active && snap_other_nodes && (p_modes & SNAP_OTHER_NODES)) || (p_forced_modes & SNAP_OTHER_NODES)) { Transform2D to_snap_transform = Transform2D(); List<const CanvasItem *> exceptions = List<const CanvasItem *>(); - for (List<CanvasItem *>::Element *E = p_other_nodes_exceptions.front(); E; E = E->next()) { - exceptions.push_back(E->get()); + for (const CanvasItem *E : p_other_nodes_exceptions) { + exceptions.push_back(E); } if (p_self_canvas_item) { exceptions.push_back(p_self_canvas_item); @@ -527,8 +527,7 @@ Rect2 CanvasItemEditor::_get_encompassing_rect_from_list(List<CanvasItem *> p_li Rect2 rect = Rect2(canvas_item->get_global_transform_with_canvas().xform(canvas_item->_edit_get_rect().position + canvas_item->_edit_get_rect().size / 2), Size2()); // Expand with the other ones - for (List<CanvasItem *>::Element *E = p_list.front(); E; E = E->next()) { - CanvasItem *canvas_item2 = E->get(); + for (CanvasItem *canvas_item2 : p_list) { Transform2D xform = canvas_item2->get_global_transform_with_canvas(); Rect2 current_rect = canvas_item2->_edit_get_rect(); @@ -760,9 +759,9 @@ List<CanvasItem *> CanvasItemEditor::_get_edited_canvas_items(bool retreive_lock if (remove_canvas_item_if_parent_in_selection) { List<CanvasItem *> filtered_selection; - for (List<CanvasItem *>::Element *E = selection.front(); E; E = E->next()) { - if (!selection.find(E->get()->get_parent())) { - filtered_selection.push_back(E->get()); + for (CanvasItem *E : selection) { + if (!selection.find(E->get_parent())) { + filtered_selection.push_back(E); } } return filtered_selection; @@ -800,8 +799,7 @@ Vector2 CanvasItemEditor::_position_to_anchor(const Control *p_control, Vector2 } void CanvasItemEditor::_save_canvas_item_state(List<CanvasItem *> p_canvas_items, bool save_bones) { - for (List<CanvasItem *>::Element *E = p_canvas_items.front(); E; E = E->next()) { - CanvasItem *canvas_item = E->get(); + for (CanvasItem *canvas_item : p_canvas_items) { CanvasItemEditorSelectedItem *se = editor_selection->get_node_editor_data<CanvasItemEditorSelectedItem>(canvas_item); if (se) { se->undo_state = canvas_item->_edit_get_state(); @@ -816,8 +814,7 @@ void CanvasItemEditor::_save_canvas_item_state(List<CanvasItem *> p_canvas_items } void CanvasItemEditor::_restore_canvas_item_state(List<CanvasItem *> p_canvas_items, bool restore_bones) { - for (List<CanvasItem *>::Element *E = drag_selection.front(); E; E = E->next()) { - CanvasItem *canvas_item = E->get(); + for (CanvasItem *canvas_item : drag_selection) { CanvasItemEditorSelectedItem *se = editor_selection->get_node_editor_data<CanvasItemEditorSelectedItem>(canvas_item); canvas_item->_edit_set_state(se->undo_state); } @@ -825,8 +822,7 @@ void CanvasItemEditor::_restore_canvas_item_state(List<CanvasItem *> p_canvas_it void CanvasItemEditor::_commit_canvas_item_state(List<CanvasItem *> p_canvas_items, String action_name, bool commit_bones) { List<CanvasItem *> modified_canvas_items; - for (List<CanvasItem *>::Element *E = p_canvas_items.front(); E; E = E->next()) { - CanvasItem *canvas_item = E->get(); + for (CanvasItem *canvas_item : p_canvas_items) { Dictionary old_state = editor_selection->get_node_editor_data<CanvasItemEditorSelectedItem>(canvas_item)->undo_state; Dictionary new_state = canvas_item->_edit_get_state(); @@ -840,17 +836,16 @@ void CanvasItemEditor::_commit_canvas_item_state(List<CanvasItem *> p_canvas_ite } undo_redo->create_action(action_name); - for (List<CanvasItem *>::Element *E = modified_canvas_items.front(); E; E = E->next()) { - CanvasItem *canvas_item = E->get(); + for (CanvasItem *canvas_item : modified_canvas_items) { CanvasItemEditorSelectedItem *se = editor_selection->get_node_editor_data<CanvasItemEditorSelectedItem>(canvas_item); if (se) { undo_redo->add_do_method(canvas_item, "_edit_set_state", canvas_item->_edit_get_state()); undo_redo->add_undo_method(canvas_item, "_edit_set_state", se->undo_state); if (commit_bones) { - for (List<Dictionary>::Element *F = se->pre_drag_bones_undo_state.front(); F; F = F->next()) { + for (const Dictionary &F : se->pre_drag_bones_undo_state) { canvas_item = Object::cast_to<CanvasItem>(canvas_item->get_parent()); undo_redo->add_do_method(canvas_item, "_edit_set_state", canvas_item->_edit_get_state()); - undo_redo->add_undo_method(canvas_item, "_edit_set_state", F->get()); + undo_redo->add_undo_method(canvas_item, "_edit_set_state", F); } } } @@ -903,7 +898,7 @@ void CanvasItemEditor::_node_created(Node *p_node) { c->_edit_set_position(xform.xform(node_create_position)); } - call_deferred("_reset_create_position"); // Defer the call in case more than one node is added. + call_deferred(SNAME("_reset_create_position")); // Defer the call in case more than one node is added. } void CanvasItemEditor::_reset_create_position() { @@ -1197,7 +1192,17 @@ bool CanvasItemEditor::_gui_input_zoom_or_pan(const Ref<InputEvent> &p_event, bo Ref<InputEventKey> k = p_event; if (k.is_valid()) { if (k->is_pressed()) { - if (ED_GET_SHORTCUT("canvas_item_editor/zoom_100_percent")->is_shortcut(p_event)) { + if (ED_GET_SHORTCUT("canvas_item_editor/zoom_3.125_percent")->is_shortcut(p_event)) { + _update_zoom((1.0 / 32.0) * MAX(1, EDSCALE)); + } else if (ED_GET_SHORTCUT("canvas_item_editor/zoom_6.25_percent")->is_shortcut(p_event)) { + _update_zoom((1.0 / 16.0) * MAX(1, EDSCALE)); + } else if (ED_GET_SHORTCUT("canvas_item_editor/zoom_12.5_percent")->is_shortcut(p_event)) { + _update_zoom((1.0 / 8.0) * MAX(1, EDSCALE)); + } else if (ED_GET_SHORTCUT("canvas_item_editor/zoom_25_percent")->is_shortcut(p_event)) { + _update_zoom((1.0 / 4.0) * MAX(1, EDSCALE)); + } else if (ED_GET_SHORTCUT("canvas_item_editor/zoom_50_percent")->is_shortcut(p_event)) { + _update_zoom((1.0 / 2.0) * MAX(1, EDSCALE)); + } else if (ED_GET_SHORTCUT("canvas_item_editor/zoom_100_percent")->is_shortcut(p_event)) { _update_zoom(1.0 * MAX(1, EDSCALE)); } else if (ED_GET_SHORTCUT("canvas_item_editor/zoom_200_percent")->is_shortcut(p_event)) { _update_zoom(2.0 * MAX(1, EDSCALE)); @@ -1294,8 +1299,7 @@ bool CanvasItemEditor::_gui_input_pivot(const Ref<InputEvent> &p_event) { // Filters the selection with nodes that allow setting the pivot drag_selection = List<CanvasItem *>(); - for (List<CanvasItem *>::Element *E = selection.front(); E; E = E->next()) { - CanvasItem *canvas_item = E->get(); + for (CanvasItem *canvas_item : selection) { if (canvas_item->_edit_use_pivot()) { drag_selection.push_back(canvas_item); } @@ -1311,8 +1315,7 @@ bool CanvasItemEditor::_gui_input_pivot(const Ref<InputEvent> &p_event) { } else { new_pos = snap_point(drag_from, SNAP_OTHER_NODES | SNAP_GRID | SNAP_PIXEL, 0, nullptr, drag_selection); } - for (List<CanvasItem *>::Element *E = drag_selection.front(); E; E = E->next()) { - CanvasItem *canvas_item = E->get(); + for (CanvasItem *canvas_item : drag_selection) { canvas_item->_edit_set_pivot(canvas_item->get_global_transform_with_canvas().affine_inverse().xform(new_pos)); } @@ -1333,8 +1336,7 @@ bool CanvasItemEditor::_gui_input_pivot(const Ref<InputEvent> &p_event) { } else { new_pos = snap_point(drag_to, SNAP_OTHER_NODES | SNAP_GRID | SNAP_PIXEL); } - for (List<CanvasItem *>::Element *E = drag_selection.front(); E; E = E->next()) { - CanvasItem *canvas_item = E->get(); + for (CanvasItem *canvas_item : drag_selection) { canvas_item->_edit_set_pivot(canvas_item->get_global_transform_with_canvas().affine_inverse().xform(new_pos)); } return true; @@ -1377,8 +1379,8 @@ bool CanvasItemEditor::_gui_input_rotate(const Ref<InputEvent> &p_event) { List<CanvasItem *> selection = _get_edited_canvas_items(); // Remove not movable nodes - for (List<CanvasItem *>::Element *E = selection.front(); E; E = E->next()) { - if (!_is_node_movable(E->get(), true)) { + for (CanvasItem *E : selection) { + if (!_is_node_movable(E, true)) { selection.erase(E); } } @@ -1404,8 +1406,7 @@ bool CanvasItemEditor::_gui_input_rotate(const Ref<InputEvent> &p_event) { // Rotate the node if (m.is_valid()) { _restore_canvas_item_state(drag_selection); - for (List<CanvasItem *>::Element *E = drag_selection.front(); E; E = E->next()) { - CanvasItem *canvas_item = E->get(); + for (CanvasItem *canvas_item : drag_selection) { drag_to = transform.affine_inverse().xform(m->get_position()); //Rotate the opposite way if the canvas item's compounded scale has an uneven number of negative elements bool opposite = (canvas_item->get_global_transform().get_scale().sign().dot(canvas_item->get_transform().get_scale().sign()) == 0); @@ -2011,11 +2012,13 @@ bool CanvasItemEditor::_gui_input_move(const Ref<InputEvent> &p_event) { drag_to = transform.affine_inverse().xform(m->get_position()); Point2 previous_pos; - if (drag_selection.size() == 1) { - Transform2D xform = drag_selection[0]->get_global_transform_with_canvas() * drag_selection[0]->get_transform().affine_inverse(); - previous_pos = xform.xform(drag_selection[0]->_edit_get_position()); - } else { - previous_pos = _get_encompassing_rect_from_list(drag_selection).position; + if (!drag_selection.is_empty()) { + if (drag_selection.size() == 1) { + Transform2D xform = drag_selection[0]->get_global_transform_with_canvas() * drag_selection[0]->get_transform().affine_inverse(); + previous_pos = xform.xform(drag_selection[0]->_edit_get_position()); + } else { + previous_pos = _get_encompassing_rect_from_list(drag_selection).position; + } } Point2 new_pos = snap_point(previous_pos + (drag_to - drag_from), SNAP_GRID | SNAP_GUIDES | SNAP_PIXEL | SNAP_NODE_PARENT | SNAP_NODE_ANCHORS | SNAP_OTHER_NODES, 0, nullptr, drag_selection); @@ -2036,8 +2039,7 @@ bool CanvasItemEditor::_gui_input_move(const Ref<InputEvent> &p_event) { } int index = 0; - for (List<CanvasItem *>::Element *E = drag_selection.front(); E; E = E->next()) { - CanvasItem *canvas_item = E->get(); + for (CanvasItem *canvas_item : drag_selection) { Transform2D xform = canvas_item->get_global_transform_with_canvas().affine_inverse() * canvas_item->get_transform(); canvas_item->_edit_set_position(canvas_item->_edit_get_position() + xform.xform(new_pos) - xform.xform(previous_pos)); @@ -2152,8 +2154,7 @@ bool CanvasItemEditor::_gui_input_move(const Ref<InputEvent> &p_event) { } int index = 0; - for (List<CanvasItem *>::Element *E = drag_selection.front(); E; E = E->next()) { - CanvasItem *canvas_item = E->get(); + for (CanvasItem *canvas_item : drag_selection) { Transform2D xform = canvas_item->get_global_transform_with_canvas().affine_inverse() * canvas_item->get_transform(); canvas_item->_edit_set_position(canvas_item->_edit_get_position() + xform.xform(new_pos) - xform.xform(previous_pos)); @@ -2205,7 +2206,7 @@ bool CanvasItemEditor::_gui_input_select(const Ref<InputEvent> &p_event) { // Popup the selection menu list Point2 click = transform.affine_inverse().xform(b->get_position()); - _get_canvas_items_at_pos(click, selection_results, b->is_alt_pressed() && tool != TOOL_LIST_SELECT); + _get_canvas_items_at_pos(click, selection_results, b->is_alt_pressed() && tool == TOOL_SELECT); if (selection_results.size() == 1) { CanvasItem *item = selection_results[0].item; @@ -2324,7 +2325,7 @@ bool CanvasItemEditor::_gui_input_select(const Ref<InputEvent> &p_event) { } if (m.is_valid()) { Point2 click = transform.affine_inverse().xform(m->get_position()); - bool movement_threshold_passed = drag_start_origin.distance_to(click) > 10 * EDSCALE; + bool movement_threshold_passed = drag_start_origin.distance_to(click) > (8 * MAX(1, EDSCALE)) / zoom; if (m.is_valid() && movement_threshold_passed) { List<CanvasItem *> selection2 = _get_edited_canvas_items(); @@ -2365,8 +2366,8 @@ bool CanvasItemEditor::_gui_input_select(const Ref<InputEvent> &p_event) { if (selitems.size() == 1 && editor_selection->get_selected_node_list().is_empty()) { editor->push_item(selitems[0]); } - for (List<CanvasItem *>::Element *E = selitems.front(); E; E = E->next()) { - editor_selection->add_node(E->get()); + for (CanvasItem *E : selitems) { + editor_selection->add_node(E); } } @@ -2529,7 +2530,7 @@ void CanvasItemEditor::_gui_input_viewport(const Ref<InputEvent> &p_event) { // Grab focus if (!viewport->has_focus() && (!get_focus_owner() || !get_focus_owner()->is_text_field())) { - viewport->call_deferred("grab_focus"); + viewport->call_deferred(SNAME("grab_focus")); } } @@ -2617,10 +2618,10 @@ void CanvasItemEditor::_update_cursor() { } void CanvasItemEditor::_draw_text_at_position(Point2 p_position, String p_string, Side p_side) { - Color color = get_theme_color("font_color", "Editor"); + Color color = get_theme_color(SNAME("font_color"), SNAME("Editor")); color.a = 0.8; - Ref<Font> font = get_theme_font("font", "Label"); - int font_size = get_theme_font_size("font_size", "Label"); + Ref<Font> font = get_theme_font(SNAME("font"), SNAME("Label")); + int font_size = get_theme_font_size(SNAME("font_size"), SNAME("Label")); Size2 text_size = font->get_string_size(p_string, font_size); switch (p_side) { case SIDE_LEFT: @@ -2656,7 +2657,7 @@ void CanvasItemEditor::_draw_percentage_at_position(float p_value, Point2 p_posi void CanvasItemEditor::_draw_focus() { // Draw the focus around the base viewport if (viewport->has_focus()) { - get_theme_stylebox("Focus", "EditorStyles")->draw(viewport->get_canvas_item(), Rect2(Point2(), viewport->get_size())); + get_theme_stylebox(SNAME("FocusViewport"), SNAME("EditorStyles"))->draw(viewport->get_canvas_item(), Rect2(Point2(), viewport->get_size())); } } @@ -2688,21 +2689,21 @@ void CanvasItemEditor::_draw_guides() { } // Dragged guide - Color text_color = get_theme_color("font_color", "Editor"); + Color text_color = get_theme_color(SNAME("font_color"), SNAME("Editor")); Color outline_color = text_color.inverted(); const float outline_size = 2; if (drag_type == DRAG_DOUBLE_GUIDE || drag_type == DRAG_V_GUIDE) { String str = TS->format_number(vformat("%d px", Math::round(xform.affine_inverse().xform(dragged_guide_pos).x))); - Ref<Font> font = get_theme_font("bold", "EditorFonts"); - int font_size = get_theme_font_size("bold_size", "EditorFonts"); + Ref<Font> font = get_theme_font(SNAME("bold"), SNAME("EditorFonts")); + int font_size = get_theme_font_size(SNAME("bold_size"), SNAME("EditorFonts")); Size2 text_size = font->get_string_size(str, font_size); viewport->draw_string(font, Point2(dragged_guide_pos.x + 10, RULER_WIDTH + text_size.y / 2 + 10), str, HALIGN_LEFT, -1, font_size, text_color, outline_size, outline_color); viewport->draw_line(Point2(dragged_guide_pos.x, 0), Point2(dragged_guide_pos.x, viewport->get_size().y), guide_color, Math::round(EDSCALE)); } if (drag_type == DRAG_DOUBLE_GUIDE || drag_type == DRAG_H_GUIDE) { String str = TS->format_number(vformat("%d px", Math::round(xform.affine_inverse().xform(dragged_guide_pos).y))); - Ref<Font> font = get_theme_font("bold", "EditorFonts"); - int font_size = get_theme_font_size("bold_size", "EditorFonts"); + Ref<Font> font = get_theme_font(SNAME("bold"), SNAME("EditorFonts")); + int font_size = get_theme_font_size(SNAME("bold_size"), SNAME("EditorFonts")); Size2 text_size = font->get_string_size(str, font_size); viewport->draw_string(font, Point2(RULER_WIDTH + 10, dragged_guide_pos.y + text_size.y / 2 + 10), str, HALIGN_LEFT, -1, font_size, text_color, outline_size, outline_color); viewport->draw_line(Point2(0, dragged_guide_pos.y), Point2(viewport->get_size().x, dragged_guide_pos.y), guide_color, Math::round(EDSCALE)); @@ -2724,12 +2725,12 @@ void CanvasItemEditor::_draw_smart_snapping() { } void CanvasItemEditor::_draw_rulers() { - Color bg_color = get_theme_color("dark_color_2", "Editor"); - Color graduation_color = get_theme_color("font_color", "Editor").lerp(bg_color, 0.5); - Color font_color = get_theme_color("font_color", "Editor"); + Color bg_color = get_theme_color(SNAME("dark_color_2"), SNAME("Editor")); + Color graduation_color = get_theme_color(SNAME("font_color"), SNAME("Editor")).lerp(bg_color, 0.5); + Color font_color = get_theme_color(SNAME("font_color"), SNAME("Editor")); font_color.a = 0.8; - Ref<Font> font = get_theme_font("rulers", "EditorFonts"); - int font_size = get_theme_font_size("rulers_size", "EditorFonts"); + Ref<Font> font = get_theme_font(SNAME("rulers"), SNAME("EditorFonts")); + int font_size = get_theme_font_size(SNAME("rulers_size"), SNAME("EditorFonts")); // The rule transform Transform2D ruler_transform = Transform2D(); @@ -2890,7 +2891,7 @@ void CanvasItemEditor::_draw_ruler_tool() { } if (ruler_tool_active) { - Color ruler_primary_color = get_theme_color("accent_color", "Editor"); + Color ruler_primary_color = get_theme_color(SNAME("accent_color"), SNAME("Editor")); Color ruler_secondary_color = ruler_primary_color; ruler_secondary_color.a = 0.5; @@ -2907,9 +2908,9 @@ void CanvasItemEditor::_draw_ruler_tool() { viewport->draw_line(corner, end, ruler_secondary_color, Math::round(EDSCALE)); } - Ref<Font> font = get_theme_font("bold", "EditorFonts"); - int font_size = get_theme_font_size("bold_size", "EditorFonts"); - Color font_color = get_theme_color("font_color", "Editor"); + Ref<Font> font = get_theme_font(SNAME("bold"), SNAME("EditorFonts")); + int font_size = get_theme_font_size(SNAME("bold_size"), SNAME("EditorFonts")); + Color font_color = get_theme_color(SNAME("font_color"), SNAME("Editor")); Color font_secondary_color = font_color; font_secondary_color.set_v(font_secondary_color.get_v() > 0.5 ? 0.7 : 0.3); Color outline_color = font_color.inverted(); @@ -2922,7 +2923,7 @@ void CanvasItemEditor::_draw_ruler_tool() { Point2 text_pos = (begin + end) / 2 - Vector2(text_width / 2, text_height / 2); text_pos.x = CLAMP(text_pos.x, text_width / 2, viewport->get_rect().size.x - text_width * 1.5); text_pos.y = CLAMP(text_pos.y, text_height * 1.5, viewport->get_rect().size.y - text_height * 1.5); - viewport->draw_string(font, text_pos, TS->format_number(vformat("%.2f " + TTR("px"), length_vector.length())), HALIGN_LEFT, -1, font_size, font_color, outline_size, outline_color); + viewport->draw_string(font, text_pos, TS->format_number(vformat("%.1f px", length_vector.length())), HALIGN_LEFT, -1, font_size, font_color, outline_size, outline_color); if (draw_secondary_lines) { const float horizontal_angle_rad = atan2(length_vector.y, length_vector.x); @@ -2932,16 +2933,16 @@ void CanvasItemEditor::_draw_ruler_tool() { Point2 text_pos2 = text_pos; text_pos2.x = begin.x < text_pos.x ? MIN(text_pos.x - text_width, begin.x - text_width / 2) : MAX(text_pos.x + text_width, begin.x - text_width / 2); - viewport->draw_string(font, text_pos2, TS->format_number(vformat("%.2f " + TTR("px"), length_vector.y)), HALIGN_LEFT, -1, font_size, font_secondary_color, outline_size, outline_color); + viewport->draw_string(font, text_pos2, TS->format_number(vformat("%.1f px", length_vector.y)), HALIGN_LEFT, -1, font_size, font_secondary_color, outline_size, outline_color); Point2 v_angle_text_pos = Point2(); v_angle_text_pos.x = CLAMP(begin.x - angle_text_width / 2, angle_text_width / 2, viewport->get_rect().size.x - angle_text_width); v_angle_text_pos.y = begin.y < end.y ? MIN(text_pos2.y - 2 * text_height, begin.y - text_height * 0.5) : MAX(text_pos2.y + text_height * 3, begin.y + text_height * 1.5); - viewport->draw_string(font, v_angle_text_pos, TS->format_number(vformat("%d " + TTR("deg"), vertical_angle)), HALIGN_LEFT, -1, font_size, font_secondary_color, outline_size, outline_color); + viewport->draw_string(font, v_angle_text_pos, TS->format_number(vformat(String::utf8("%d°"), vertical_angle)), HALIGN_LEFT, -1, font_size, font_secondary_color, outline_size, outline_color); text_pos2 = text_pos; text_pos2.y = end.y < text_pos.y ? MIN(text_pos.y - text_height * 2, end.y - text_height / 2) : MAX(text_pos.y + text_height * 2, end.y - text_height / 2); - viewport->draw_string(font, text_pos2, TS->format_number(vformat("%.2f " + TTR("px"), length_vector.x)), HALIGN_LEFT, -1, font_size, font_secondary_color, outline_size, outline_color); + viewport->draw_string(font, text_pos2, TS->format_number(vformat("%.1f px", length_vector.x)), HALIGN_LEFT, -1, font_size, font_secondary_color, outline_size, outline_color); Point2 h_angle_text_pos = Point2(); h_angle_text_pos.x = CLAMP(end.x - angle_text_width / 2, angle_text_width / 2, viewport->get_rect().size.x - angle_text_width); @@ -2958,7 +2959,7 @@ void CanvasItemEditor::_draw_ruler_tool() { h_angle_text_pos.y = MIN(text_pos.y - height_multiplier * text_height, MIN(end.y - text_height * 0.5, text_pos2.y - height_multiplier * text_height)); } } - viewport->draw_string(font, h_angle_text_pos, TS->format_number(vformat("%d " + TTR("deg"), horizontal_angle)), HALIGN_LEFT, -1, font_size, font_secondary_color, outline_size, outline_color); + viewport->draw_string(font, h_angle_text_pos, TS->format_number(vformat(String::utf8("%d°"), horizontal_angle)), HALIGN_LEFT, -1, font_size, font_secondary_color, outline_size, outline_color); // Angle arcs int arc_point_count = 8; @@ -3010,8 +3011,8 @@ void CanvasItemEditor::_draw_ruler_tool() { } } else { if (grid_snap_active) { - Ref<Texture2D> position_icon = get_theme_icon("EditorPosition", "EditorIcons"); - viewport->draw_texture(get_theme_icon("EditorPosition", "EditorIcons"), (ruler_tool_origin - view_offset) * zoom - position_icon->get_size() / 2); + Ref<Texture2D> position_icon = get_theme_icon(SNAME("EditorPosition"), SNAME("EditorIcons")); + viewport->draw_texture(get_theme_icon(SNAME("EditorPosition"), SNAME("EditorIcons")), (ruler_tool_origin - view_offset) * zoom - position_icon->get_size() / 2); } } } @@ -3229,17 +3230,17 @@ void CanvasItemEditor::_draw_control_helpers(Control *control) { } void CanvasItemEditor::_draw_selection() { - Ref<Texture2D> pivot_icon = get_theme_icon("EditorPivot", "EditorIcons"); - Ref<Texture2D> position_icon = get_theme_icon("EditorPosition", "EditorIcons"); - Ref<Texture2D> previous_position_icon = get_theme_icon("EditorPositionPrevious", "EditorIcons"); + Ref<Texture2D> pivot_icon = get_theme_icon(SNAME("EditorPivot"), SNAME("EditorIcons")); + Ref<Texture2D> position_icon = get_theme_icon(SNAME("EditorPosition"), SNAME("EditorIcons")); + Ref<Texture2D> previous_position_icon = get_theme_icon(SNAME("EditorPositionPrevious"), SNAME("EditorIcons")); RID ci = viewport->get_canvas_item(); List<CanvasItem *> selection = _get_edited_canvas_items(true, false); bool single = selection.size() == 1; - for (List<CanvasItem *>::Element *E = selection.front(); E; E = E->next()) { - CanvasItem *canvas_item = Object::cast_to<CanvasItem>(E->get()); + for (CanvasItem *E : selection) { + CanvasItem *canvas_item = Object::cast_to<CanvasItem>(E); CanvasItemEditorSelectedItem *se = editor_selection->get_node_editor_data<CanvasItemEditorSelectedItem>(canvas_item); bool item_locked = canvas_item->has_meta("_edit_lock_"); @@ -3357,16 +3358,16 @@ void CanvasItemEditor::_draw_selection() { points.push_back(Vector2(move_factor.x * EDSCALE, -5 * EDSCALE)); points.push_back(Vector2((move_factor.x + 10) * EDSCALE, 0)); - viewport->draw_colored_polygon(points, get_theme_color("axis_x_color", "Editor")); - viewport->draw_line(Point2(), Point2(move_factor.x * EDSCALE, 0), get_theme_color("axis_x_color", "Editor"), Math::round(EDSCALE)); + viewport->draw_colored_polygon(points, get_theme_color(SNAME("axis_x_color"), SNAME("Editor"))); + viewport->draw_line(Point2(), Point2(move_factor.x * EDSCALE, 0), get_theme_color(SNAME("axis_x_color"), SNAME("Editor")), Math::round(EDSCALE)); 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)); - viewport->draw_colored_polygon(points, get_theme_color("axis_y_color", "Editor")); - viewport->draw_line(Point2(), Point2(0, move_factor.y * EDSCALE), get_theme_color("axis_y_color", "Editor"), Math::round(EDSCALE)); + viewport->draw_colored_polygon(points, get_theme_color(SNAME("axis_y_color"), SNAME("Editor"))); + viewport->draw_line(Point2(), Point2(0, move_factor.y * EDSCALE), get_theme_color(SNAME("axis_y_color"), SNAME("Editor")), Math::round(EDSCALE)); viewport->draw_set_transform_matrix(viewport->get_transform()); } @@ -3396,12 +3397,12 @@ void CanvasItemEditor::_draw_selection() { 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("axis_x_color", "Editor")); - viewport->draw_line(Point2(), Point2(scale_factor.x * EDSCALE, 0), get_theme_color("axis_x_color", "Editor"), Math::round(EDSCALE)); + viewport->draw_rect(x_handle_rect, get_theme_color(SNAME("axis_x_color"), SNAME("Editor"))); + viewport->draw_line(Point2(), Point2(scale_factor.x * EDSCALE, 0), get_theme_color(SNAME("axis_x_color"), SNAME("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("axis_y_color", "Editor")); - viewport->draw_line(Point2(), Point2(0, scale_factor.y * EDSCALE), get_theme_color("axis_y_color", "Editor"), Math::round(EDSCALE)); + viewport->draw_rect(y_handle_rect, get_theme_color(SNAME("axis_y_color"), SNAME("Editor"))); + viewport->draw_line(Point2(), Point2(0, scale_factor.y * EDSCALE), get_theme_color(SNAME("axis_y_color"), SNAME("Editor")), Math::round(EDSCALE)); viewport->draw_set_transform_matrix(viewport->get_transform()); } @@ -3416,11 +3417,11 @@ void CanvasItemEditor::_draw_selection() { viewport->draw_rect( Rect2(bsfrom, bsto - bsfrom), - get_theme_color("box_selection_fill_color", "Editor")); + get_theme_color(SNAME("box_selection_fill_color"), SNAME("Editor"))); viewport->draw_rect( Rect2(bsfrom, bsto - bsfrom), - get_theme_color("box_selection_stroke_color", "Editor"), + get_theme_color(SNAME("box_selection_stroke_color"), SNAME("Editor")), false, Math::round(EDSCALE)); } @@ -3430,7 +3431,7 @@ void CanvasItemEditor::_draw_selection() { viewport->draw_line( transform.xform(drag_rotation_center), transform.xform(drag_to), - get_theme_color("accent_color", "Editor") * Color(1, 1, 1, 0.6), + get_theme_color(SNAME("accent_color"), SNAME("Editor")) * Color(1, 1, 1, 0.6), Math::round(2 * EDSCALE)); } } @@ -3478,8 +3479,8 @@ void CanvasItemEditor::_draw_straight_line(Point2 p_from, Point2 p_to, Color p_c void CanvasItemEditor::_draw_axis() { if (show_origin) { - _draw_straight_line(Point2(), Point2(1, 0), get_theme_color("axis_x_color", "Editor") * Color(1, 1, 1, 0.75)); - _draw_straight_line(Point2(), Point2(0, 1), get_theme_color("axis_y_color", "Editor") * Color(1, 1, 1, 0.75)); + _draw_straight_line(Point2(), Point2(1, 0), get_theme_color(SNAME("axis_x_color"), SNAME("Editor")) * Color(1, 1, 1, 0.75)); + _draw_straight_line(Point2(), Point2(0, 1), get_theme_color(SNAME("axis_y_color"), SNAME("Editor")) * Color(1, 1, 1, 0.75)); } if (show_viewport) { @@ -3533,7 +3534,7 @@ void CanvasItemEditor::_draw_invisible_nodes_positions(Node *p_node, const Trans Transform2D xform = transform * canvas_xform * parent_xform; // Draw the node's position - Ref<Texture2D> position_icon = get_theme_icon("EditorPositionUnselected", "EditorIcons"); + Ref<Texture2D> position_icon = get_theme_icon(SNAME("EditorPositionUnselected"), SNAME("EditorIcons")); Transform2D unscaled_transform = (xform * canvas_item->get_transform().affine_inverse() * canvas_item->_edit_get_transform()).orthonormalized(); Transform2D simple_xform = viewport->get_transform() * unscaled_transform; viewport->draw_set_transform_matrix(simple_xform); @@ -3549,16 +3550,16 @@ void CanvasItemEditor::_draw_hover() { Ref<Texture2D> node_icon = hovering_results[i].icon; String node_name = hovering_results[i].name; - Ref<Font> font = get_theme_font("font", "Label"); - int font_size = get_theme_font_size("font_size", "Label"); + Ref<Font> font = get_theme_font(SNAME("font"), SNAME("Label")); + int font_size = get_theme_font_size(SNAME("font_size"), SNAME("Label")); Size2 node_name_size = font->get_string_size(node_name); Size2 item_size = Size2(node_icon->get_size().x + 4 + node_name_size.x, MAX(node_icon->get_size().y, node_name_size.y - 3)); Point2 pos = transform.xform(hovering_results[i].position) - Point2(0, item_size.y) + (Point2(node_icon->get_size().x, -node_icon->get_size().y) / 4); // Rectify the position to avoid overlapping items - for (List<Rect2>::Element *E = previous_rects.front(); E; E = E->next()) { - if (E->get().intersects(Rect2(pos, item_size))) { - pos.y = E->get().get_position().y - item_size.y; + for (const Rect2 &E : previous_rects) { + if (E.intersects(Rect2(pos, item_size))) { + pos.y = E.get_position().y - item_size.y; } } @@ -3603,13 +3604,13 @@ void CanvasItemEditor::_draw_locks_and_groups(Node *p_node, const Transform2D &p if (canvas_item) { float offset = 0; - Ref<Texture2D> lock = get_theme_icon("LockViewport", "EditorIcons"); + Ref<Texture2D> lock = get_theme_icon(SNAME("LockViewport"), SNAME("EditorIcons")); if (p_node->has_meta("_edit_lock_") && show_edit_locks) { lock->draw(viewport_canvas_item, (transform * canvas_xform * parent_xform).xform(Point2(0, 0)) + Point2(offset, 0)); offset += lock->get_size().x; } - Ref<Texture2D> group = get_theme_icon("GroupViewport", "EditorIcons"); + Ref<Texture2D> group = get_theme_icon(SNAME("GroupViewport"), SNAME("EditorIcons")); if (canvas_item->has_meta("_edit_group_") && show_edit_locks) { group->draw(viewport_canvas_item, (transform * canvas_xform * parent_xform).xform(Point2(0, 0)) + Point2(offset, 0)); //offset += group->get_size().x; @@ -3632,14 +3633,14 @@ void CanvasItemEditor::_draw_viewport() { all_locked = false; all_group = false; } else { - for (List<Node *>::Element *E = selection.front(); E; E = E->next()) { - if (Object::cast_to<CanvasItem>(E->get()) && !Object::cast_to<CanvasItem>(E->get())->has_meta("_edit_lock_")) { + for (Node *E : selection) { + if (Object::cast_to<CanvasItem>(E) && !Object::cast_to<CanvasItem>(E)->has_meta("_edit_lock_")) { all_locked = false; break; } } - for (List<Node *>::Element *E = selection.front(); E; E = E->next()) { - if (Object::cast_to<CanvasItem>(E->get()) && !Object::cast_to<CanvasItem>(E->get())->has_meta("_edit_group_")) { + for (Node *E : selection) { + if (Object::cast_to<CanvasItem>(E) && !Object::cast_to<CanvasItem>(E)->has_meta("_edit_group_")) { all_group = false; break; } @@ -3706,8 +3707,7 @@ void CanvasItemEditor::_notification(int p_what) { // Update the viewport if the canvas_item changes List<CanvasItem *> selection = _get_edited_canvas_items(true); - for (List<CanvasItem *>::Element *E = selection.front(); E; E = E->next()) { - CanvasItem *canvas_item = E->get(); + for (CanvasItem *canvas_item : selection) { CanvasItemEditorSelectedItem *se = editor_selection->get_node_editor_data<CanvasItemEditorSelectedItem>(canvas_item); Rect2 rect; @@ -3809,7 +3809,7 @@ void CanvasItemEditor::_notification(int p_what) { } if (p_what == NOTIFICATION_ENTER_TREE) { - select_sb->set_texture(get_theme_icon("EditorRect2D", "EditorIcons")); + select_sb->set_texture(get_theme_icon(SNAME("EditorRect2D"), SNAME("EditorIcons"))); for (int i = 0; i < 4; i++) { select_sb->set_margin_size(Side(i), 4); select_sb->set_default_margin(Side(i), 4); @@ -3819,92 +3819,95 @@ void CanvasItemEditor::_notification(int p_what) { _keying_changed(); } else if (p_what == EditorSettings::NOTIFICATION_EDITOR_SETTINGS_CHANGED) { - select_sb->set_texture(get_theme_icon("EditorRect2D", "EditorIcons")); + select_sb->set_texture(get_theme_icon(SNAME("EditorRect2D"), SNAME("EditorIcons"))); } if (p_what == NOTIFICATION_ENTER_TREE || p_what == EditorSettings::NOTIFICATION_EDITOR_SETTINGS_CHANGED) { - select_button->set_icon(get_theme_icon("ToolSelect", "EditorIcons")); - list_select_button->set_icon(get_theme_icon("ListSelect", "EditorIcons")); - move_button->set_icon(get_theme_icon("ToolMove", "EditorIcons")); - scale_button->set_icon(get_theme_icon("ToolScale", "EditorIcons")); - rotate_button->set_icon(get_theme_icon("ToolRotate", "EditorIcons")); - smart_snap_button->set_icon(get_theme_icon("Snap", "EditorIcons")); - grid_snap_button->set_icon(get_theme_icon("SnapGrid", "EditorIcons")); - snap_config_menu->set_icon(get_theme_icon("GuiTabMenuHl", "EditorIcons")); - skeleton_menu->set_icon(get_theme_icon("Bone", "EditorIcons")); - override_camera_button->set_icon(get_theme_icon("Camera2D", "EditorIcons")); - pan_button->set_icon(get_theme_icon("ToolPan", "EditorIcons")); - ruler_button->set_icon(get_theme_icon("Ruler", "EditorIcons")); - pivot_button->set_icon(get_theme_icon("EditPivot", "EditorIcons")); - select_handle = get_theme_icon("EditorHandle", "EditorIcons"); - anchor_handle = get_theme_icon("EditorControlAnchor", "EditorIcons"); - lock_button->set_icon(get_theme_icon("Lock", "EditorIcons")); - unlock_button->set_icon(get_theme_icon("Unlock", "EditorIcons")); - group_button->set_icon(get_theme_icon("Group", "EditorIcons")); - ungroup_button->set_icon(get_theme_icon("Ungroup", "EditorIcons")); - key_loc_button->set_icon(get_theme_icon("KeyPosition", "EditorIcons")); - key_rot_button->set_icon(get_theme_icon("KeyRotation", "EditorIcons")); - key_scale_button->set_icon(get_theme_icon("KeyScale", "EditorIcons")); - key_insert_button->set_icon(get_theme_icon("Key", "EditorIcons")); - key_auto_insert_button->set_icon(get_theme_icon("AutoKey", "EditorIcons")); + select_button->set_icon(get_theme_icon(SNAME("ToolSelect"), SNAME("EditorIcons"))); + list_select_button->set_icon(get_theme_icon(SNAME("ListSelect"), SNAME("EditorIcons"))); + move_button->set_icon(get_theme_icon(SNAME("ToolMove"), SNAME("EditorIcons"))); + scale_button->set_icon(get_theme_icon(SNAME("ToolScale"), SNAME("EditorIcons"))); + rotate_button->set_icon(get_theme_icon(SNAME("ToolRotate"), SNAME("EditorIcons"))); + smart_snap_button->set_icon(get_theme_icon(SNAME("Snap"), SNAME("EditorIcons"))); + grid_snap_button->set_icon(get_theme_icon(SNAME("SnapGrid"), SNAME("EditorIcons"))); + snap_config_menu->set_icon(get_theme_icon(SNAME("GuiTabMenuHl"), SNAME("EditorIcons"))); + skeleton_menu->set_icon(get_theme_icon(SNAME("Bone"), SNAME("EditorIcons"))); + override_camera_button->set_icon(get_theme_icon(SNAME("Camera2D"), SNAME("EditorIcons"))); + pan_button->set_icon(get_theme_icon(SNAME("ToolPan"), SNAME("EditorIcons"))); + ruler_button->set_icon(get_theme_icon(SNAME("Ruler"), SNAME("EditorIcons"))); + pivot_button->set_icon(get_theme_icon(SNAME("EditPivot"), SNAME("EditorIcons"))); + select_handle = get_theme_icon(SNAME("EditorHandle"), SNAME("EditorIcons")); + anchor_handle = get_theme_icon(SNAME("EditorControlAnchor"), SNAME("EditorIcons")); + lock_button->set_icon(get_theme_icon(SNAME("Lock"), SNAME("EditorIcons"))); + unlock_button->set_icon(get_theme_icon(SNAME("Unlock"), SNAME("EditorIcons"))); + group_button->set_icon(get_theme_icon(SNAME("Group"), SNAME("EditorIcons"))); + ungroup_button->set_icon(get_theme_icon(SNAME("Ungroup"), SNAME("EditorIcons"))); + key_loc_button->set_icon(get_theme_icon(SNAME("KeyPosition"), SNAME("EditorIcons"))); + key_rot_button->set_icon(get_theme_icon(SNAME("KeyRotation"), SNAME("EditorIcons"))); + key_scale_button->set_icon(get_theme_icon(SNAME("KeyScale"), SNAME("EditorIcons"))); + key_insert_button->set_icon(get_theme_icon(SNAME("Key"), SNAME("EditorIcons"))); + key_auto_insert_button->set_icon(get_theme_icon(SNAME("AutoKey"), SNAME("EditorIcons"))); // Use a different color for the active autokey icon to make them easier // to distinguish from the other key icons at the top. On a light theme, // the icon will be dark, so we need to lighten it before blending it // with the red color. const Color key_auto_color = EditorSettings::get_singleton()->is_dark_theme() ? Color(1, 1, 1) : Color(4.25, 4.25, 4.25); key_auto_insert_button->add_theme_color_override("icon_pressed_color", key_auto_color.lerp(Color(1, 0, 0), 0.55)); - animation_menu->set_icon(get_theme_icon("GuiTabMenuHl", "EditorIcons")); + animation_menu->set_icon(get_theme_icon(SNAME("GuiTabMenuHl"), SNAME("EditorIcons"))); + + _update_context_menu_stylebox(); + + presets_menu->set_icon(get_theme_icon(SNAME("ControlLayout"), SNAME("EditorIcons"))); - presets_menu->set_icon(get_theme_icon("ControlLayout", "EditorIcons")); PopupMenu *p = presets_menu->get_popup(); p->clear(); - p->add_icon_item(get_theme_icon("ControlAlignTopLeft", "EditorIcons"), TTR("Top Left"), ANCHORS_AND_OFFSETS_PRESET_TOP_LEFT); - p->add_icon_item(get_theme_icon("ControlAlignTopRight", "EditorIcons"), TTR("Top Right"), ANCHORS_AND_OFFSETS_PRESET_TOP_RIGHT); - p->add_icon_item(get_theme_icon("ControlAlignBottomRight", "EditorIcons"), TTR("Bottom Right"), ANCHORS_AND_OFFSETS_PRESET_BOTTOM_RIGHT); - p->add_icon_item(get_theme_icon("ControlAlignBottomLeft", "EditorIcons"), TTR("Bottom Left"), ANCHORS_AND_OFFSETS_PRESET_BOTTOM_LEFT); + p->add_icon_item(get_theme_icon(SNAME("ControlAlignTopLeft"), SNAME("EditorIcons")), TTR("Top Left"), ANCHORS_AND_OFFSETS_PRESET_TOP_LEFT); + p->add_icon_item(get_theme_icon(SNAME("ControlAlignTopRight"), SNAME("EditorIcons")), TTR("Top Right"), ANCHORS_AND_OFFSETS_PRESET_TOP_RIGHT); + p->add_icon_item(get_theme_icon(SNAME("ControlAlignBottomRight"), SNAME("EditorIcons")), TTR("Bottom Right"), ANCHORS_AND_OFFSETS_PRESET_BOTTOM_RIGHT); + p->add_icon_item(get_theme_icon(SNAME("ControlAlignBottomLeft"), SNAME("EditorIcons")), TTR("Bottom Left"), ANCHORS_AND_OFFSETS_PRESET_BOTTOM_LEFT); p->add_separator(); - p->add_icon_item(get_theme_icon("ControlAlignLeftCenter", "EditorIcons"), TTR("Center Left"), ANCHORS_AND_OFFSETS_PRESET_CENTER_LEFT); - p->add_icon_item(get_theme_icon("ControlAlignTopCenter", "EditorIcons"), TTR("Center Top"), ANCHORS_AND_OFFSETS_PRESET_CENTER_TOP); - p->add_icon_item(get_theme_icon("ControlAlignRightCenter", "EditorIcons"), TTR("Center Right"), ANCHORS_AND_OFFSETS_PRESET_CENTER_RIGHT); - p->add_icon_item(get_theme_icon("ControlAlignBottomCenter", "EditorIcons"), TTR("Center Bottom"), ANCHORS_AND_OFFSETS_PRESET_CENTER_BOTTOM); - p->add_icon_item(get_theme_icon("ControlAlignCenter", "EditorIcons"), TTR("Center"), ANCHORS_AND_OFFSETS_PRESET_CENTER); + p->add_icon_item(get_theme_icon(SNAME("ControlAlignLeftCenter"), SNAME("EditorIcons")), TTR("Center Left"), ANCHORS_AND_OFFSETS_PRESET_CENTER_LEFT); + p->add_icon_item(get_theme_icon(SNAME("ControlAlignTopCenter"), SNAME("EditorIcons")), TTR("Center Top"), ANCHORS_AND_OFFSETS_PRESET_CENTER_TOP); + p->add_icon_item(get_theme_icon(SNAME("ControlAlignRightCenter"), SNAME("EditorIcons")), TTR("Center Right"), ANCHORS_AND_OFFSETS_PRESET_CENTER_RIGHT); + p->add_icon_item(get_theme_icon(SNAME("ControlAlignBottomCenter"), SNAME("EditorIcons")), TTR("Center Bottom"), ANCHORS_AND_OFFSETS_PRESET_CENTER_BOTTOM); + p->add_icon_item(get_theme_icon(SNAME("ControlAlignCenter"), SNAME("EditorIcons")), TTR("Center"), ANCHORS_AND_OFFSETS_PRESET_CENTER); p->add_separator(); - p->add_icon_item(get_theme_icon("ControlAlignLeftWide", "EditorIcons"), TTR("Left Wide"), ANCHORS_AND_OFFSETS_PRESET_LEFT_WIDE); - p->add_icon_item(get_theme_icon("ControlAlignTopWide", "EditorIcons"), TTR("Top Wide"), ANCHORS_AND_OFFSETS_PRESET_TOP_WIDE); - p->add_icon_item(get_theme_icon("ControlAlignRightWide", "EditorIcons"), TTR("Right Wide"), ANCHORS_AND_OFFSETS_PRESET_RIGHT_WIDE); - p->add_icon_item(get_theme_icon("ControlAlignBottomWide", "EditorIcons"), TTR("Bottom Wide"), ANCHORS_AND_OFFSETS_PRESET_BOTTOM_WIDE); - p->add_icon_item(get_theme_icon("ControlVcenterWide", "EditorIcons"), TTR("VCenter Wide"), ANCHORS_AND_OFFSETS_PRESET_VCENTER_WIDE); - p->add_icon_item(get_theme_icon("ControlHcenterWide", "EditorIcons"), TTR("HCenter Wide"), ANCHORS_AND_OFFSETS_PRESET_HCENTER_WIDE); + p->add_icon_item(get_theme_icon(SNAME("ControlAlignLeftWide"), SNAME("EditorIcons")), TTR("Left Wide"), ANCHORS_AND_OFFSETS_PRESET_LEFT_WIDE); + p->add_icon_item(get_theme_icon(SNAME("ControlAlignTopWide"), SNAME("EditorIcons")), TTR("Top Wide"), ANCHORS_AND_OFFSETS_PRESET_TOP_WIDE); + p->add_icon_item(get_theme_icon(SNAME("ControlAlignRightWide"), SNAME("EditorIcons")), TTR("Right Wide"), ANCHORS_AND_OFFSETS_PRESET_RIGHT_WIDE); + p->add_icon_item(get_theme_icon(SNAME("ControlAlignBottomWide"), SNAME("EditorIcons")), TTR("Bottom Wide"), ANCHORS_AND_OFFSETS_PRESET_BOTTOM_WIDE); + p->add_icon_item(get_theme_icon(SNAME("ControlVcenterWide"), SNAME("EditorIcons")), TTR("VCenter Wide"), ANCHORS_AND_OFFSETS_PRESET_VCENTER_WIDE); + p->add_icon_item(get_theme_icon(SNAME("ControlHcenterWide"), SNAME("EditorIcons")), TTR("HCenter Wide"), ANCHORS_AND_OFFSETS_PRESET_HCENTER_WIDE); p->add_separator(); - p->add_icon_item(get_theme_icon("ControlAlignWide", "EditorIcons"), TTR("Full Rect"), ANCHORS_AND_OFFSETS_PRESET_WIDE); - p->add_icon_item(get_theme_icon("Anchor", "EditorIcons"), TTR("Keep Ratio"), ANCHORS_AND_OFFSETS_PRESET_KEEP_RATIO); + p->add_icon_item(get_theme_icon(SNAME("ControlAlignWide"), SNAME("EditorIcons")), TTR("Full Rect"), ANCHORS_AND_OFFSETS_PRESET_WIDE); + p->add_icon_item(get_theme_icon(SNAME("Anchor"), SNAME("EditorIcons")), TTR("Keep Ratio"), ANCHORS_AND_OFFSETS_PRESET_KEEP_RATIO); p->add_separator(); p->add_submenu_item(TTR("Anchors only"), "Anchors"); - p->set_item_icon(21, get_theme_icon("Anchor", "EditorIcons")); + p->set_item_icon(21, get_theme_icon(SNAME("Anchor"), SNAME("EditorIcons"))); anchors_popup->clear(); - anchors_popup->add_icon_item(get_theme_icon("ControlAlignTopLeft", "EditorIcons"), TTR("Top Left"), ANCHORS_PRESET_TOP_LEFT); - anchors_popup->add_icon_item(get_theme_icon("ControlAlignTopRight", "EditorIcons"), TTR("Top Right"), ANCHORS_PRESET_TOP_RIGHT); - anchors_popup->add_icon_item(get_theme_icon("ControlAlignBottomRight", "EditorIcons"), TTR("Bottom Right"), ANCHORS_PRESET_BOTTOM_RIGHT); - anchors_popup->add_icon_item(get_theme_icon("ControlAlignBottomLeft", "EditorIcons"), TTR("Bottom Left"), ANCHORS_PRESET_BOTTOM_LEFT); + anchors_popup->add_icon_item(get_theme_icon(SNAME("ControlAlignTopLeft"), SNAME("EditorIcons")), TTR("Top Left"), ANCHORS_PRESET_TOP_LEFT); + anchors_popup->add_icon_item(get_theme_icon(SNAME("ControlAlignTopRight"), SNAME("EditorIcons")), TTR("Top Right"), ANCHORS_PRESET_TOP_RIGHT); + anchors_popup->add_icon_item(get_theme_icon(SNAME("ControlAlignBottomRight"), SNAME("EditorIcons")), TTR("Bottom Right"), ANCHORS_PRESET_BOTTOM_RIGHT); + anchors_popup->add_icon_item(get_theme_icon(SNAME("ControlAlignBottomLeft"), SNAME("EditorIcons")), TTR("Bottom Left"), ANCHORS_PRESET_BOTTOM_LEFT); anchors_popup->add_separator(); - anchors_popup->add_icon_item(get_theme_icon("ControlAlignLeftCenter", "EditorIcons"), TTR("Center Left"), ANCHORS_PRESET_CENTER_LEFT); - anchors_popup->add_icon_item(get_theme_icon("ControlAlignTopCenter", "EditorIcons"), TTR("Center Top"), ANCHORS_PRESET_CENTER_TOP); - anchors_popup->add_icon_item(get_theme_icon("ControlAlignRightCenter", "EditorIcons"), TTR("Center Right"), ANCHORS_PRESET_CENTER_RIGHT); - anchors_popup->add_icon_item(get_theme_icon("ControlAlignBottomCenter", "EditorIcons"), TTR("Center Bottom"), ANCHORS_PRESET_CENTER_BOTTOM); - anchors_popup->add_icon_item(get_theme_icon("ControlAlignCenter", "EditorIcons"), TTR("Center"), ANCHORS_PRESET_CENTER); + anchors_popup->add_icon_item(get_theme_icon(SNAME("ControlAlignLeftCenter"), SNAME("EditorIcons")), TTR("Center Left"), ANCHORS_PRESET_CENTER_LEFT); + anchors_popup->add_icon_item(get_theme_icon(SNAME("ControlAlignTopCenter"), SNAME("EditorIcons")), TTR("Center Top"), ANCHORS_PRESET_CENTER_TOP); + anchors_popup->add_icon_item(get_theme_icon(SNAME("ControlAlignRightCenter"), SNAME("EditorIcons")), TTR("Center Right"), ANCHORS_PRESET_CENTER_RIGHT); + anchors_popup->add_icon_item(get_theme_icon(SNAME("ControlAlignBottomCenter"), SNAME("EditorIcons")), TTR("Center Bottom"), ANCHORS_PRESET_CENTER_BOTTOM); + anchors_popup->add_icon_item(get_theme_icon(SNAME("ControlAlignCenter"), SNAME("EditorIcons")), TTR("Center"), ANCHORS_PRESET_CENTER); anchors_popup->add_separator(); - anchors_popup->add_icon_item(get_theme_icon("ControlAlignLeftWide", "EditorIcons"), TTR("Left Wide"), ANCHORS_PRESET_LEFT_WIDE); - anchors_popup->add_icon_item(get_theme_icon("ControlAlignTopWide", "EditorIcons"), TTR("Top Wide"), ANCHORS_PRESET_TOP_WIDE); - anchors_popup->add_icon_item(get_theme_icon("ControlAlignRightWide", "EditorIcons"), TTR("Right Wide"), ANCHORS_PRESET_RIGHT_WIDE); - anchors_popup->add_icon_item(get_theme_icon("ControlAlignBottomWide", "EditorIcons"), TTR("Bottom Wide"), ANCHORS_PRESET_BOTTOM_WIDE); - anchors_popup->add_icon_item(get_theme_icon("ControlVcenterWide", "EditorIcons"), TTR("VCenter Wide"), ANCHORS_PRESET_VCENTER_WIDE); - anchors_popup->add_icon_item(get_theme_icon("ControlHcenterWide", "EditorIcons"), TTR("HCenter Wide"), ANCHORS_PRESET_HCENTER_WIDE); + anchors_popup->add_icon_item(get_theme_icon(SNAME("ControlAlignLeftWide"), SNAME("EditorIcons")), TTR("Left Wide"), ANCHORS_PRESET_LEFT_WIDE); + anchors_popup->add_icon_item(get_theme_icon(SNAME("ControlAlignTopWide"), SNAME("EditorIcons")), TTR("Top Wide"), ANCHORS_PRESET_TOP_WIDE); + anchors_popup->add_icon_item(get_theme_icon(SNAME("ControlAlignRightWide"), SNAME("EditorIcons")), TTR("Right Wide"), ANCHORS_PRESET_RIGHT_WIDE); + anchors_popup->add_icon_item(get_theme_icon(SNAME("ControlAlignBottomWide"), SNAME("EditorIcons")), TTR("Bottom Wide"), ANCHORS_PRESET_BOTTOM_WIDE); + anchors_popup->add_icon_item(get_theme_icon(SNAME("ControlVcenterWide"), SNAME("EditorIcons")), TTR("VCenter Wide"), ANCHORS_PRESET_VCENTER_WIDE); + anchors_popup->add_icon_item(get_theme_icon(SNAME("ControlHcenterWide"), SNAME("EditorIcons")), TTR("HCenter Wide"), ANCHORS_PRESET_HCENTER_WIDE); anchors_popup->add_separator(); - anchors_popup->add_icon_item(get_theme_icon("ControlAlignWide", "EditorIcons"), TTR("Full Rect"), ANCHORS_PRESET_WIDE); + anchors_popup->add_icon_item(get_theme_icon(SNAME("ControlAlignWide"), SNAME("EditorIcons")), TTR("Full Rect"), ANCHORS_PRESET_WIDE); - anchor_mode_button->set_icon(get_theme_icon("Anchor", "EditorIcons")); + anchor_mode_button->set_icon(get_theme_icon(SNAME("Anchor"), SNAME("EditorIcons"))); } if (p_what == NOTIFICATION_VISIBILITY_CHANGED) { @@ -3922,8 +3925,8 @@ void CanvasItemEditor::_selection_changed() { int nbValidControls = 0; int nbAnchorsMode = 0; List<Node *> selection = editor_selection->get_selected_node_list(); - for (List<Node *>::Element *E = selection.front(); E; E = E->next()) { - Control *control = Object::cast_to<Control>(E->get()); + for (Node *E : selection) { + Control *control = Object::cast_to<Control>(E); if (!control) { continue; } @@ -3956,6 +3959,18 @@ void CanvasItemEditor::edit(CanvasItem *p_canvas_item) { } } +void CanvasItemEditor::_update_context_menu_stylebox() { + // This must be called when the theme changes to follow the new accent color. + Ref<StyleBoxFlat> context_menu_stylebox = memnew(StyleBoxFlat); + const Color accent_color = EditorNode::get_singleton()->get_gui_base()->get_theme_color("accent_color", "Editor"); + context_menu_stylebox->set_bg_color(accent_color * Color(1, 1, 1, 0.1)); + // Add an underline to the StyleBox, but prevent its minimum vertical size from changing. + context_menu_stylebox->set_border_color(accent_color); + context_menu_stylebox->set_border_width(SIDE_BOTTOM, Math::round(2 * EDSCALE)); + context_menu_stylebox->set_default_margin(SIDE_BOTTOM, 0); + context_menu_container->add_theme_style_override("panel", context_menu_stylebox); +} + void CanvasItemEditor::_update_scrollbars() { updating_scroll = true; @@ -4091,8 +4106,8 @@ void CanvasItemEditor::_set_anchors_and_offsets_preset(Control::LayoutPreset p_p undo_redo->create_action(TTR("Change Anchors and Offsets")); - for (List<Node *>::Element *E = selection.front(); E; E = E->next()) { - Control *control = Object::cast_to<Control>(E->get()); + for (Node *E : selection) { + Control *control = Object::cast_to<Control>(E); if (control) { undo_redo->add_do_method(control, "set_anchors_preset", p_preset); switch (p_preset) { @@ -4132,8 +4147,8 @@ void CanvasItemEditor::_set_anchors_and_offsets_to_keep_ratio() { undo_redo->create_action(TTR("Change Anchors and Offsets")); - for (List<Node *>::Element *E = selection.front(); E; E = E->next()) { - Control *control = Object::cast_to<Control>(E->get()); + for (Node *E : selection) { + Control *control = Object::cast_to<Control>(E); if (control) { Point2 top_left_anchor = _position_to_anchor(control, Point2()); Point2 bottom_right_anchor = _position_to_anchor(control, control->get_size()); @@ -4159,8 +4174,8 @@ void CanvasItemEditor::_set_anchors_preset(Control::LayoutPreset p_preset) { List<Node *> selection = editor_selection->get_selected_node_list(); undo_redo->create_action(TTR("Change Anchors")); - for (List<Node *>::Element *E = selection.front(); E; E = E->next()) { - Control *control = Object::cast_to<Control>(E->get()); + for (Node *E : selection) { + Control *control = Object::cast_to<Control>(E); if (control) { undo_redo->add_do_method(control, "set_anchors_preset", p_preset); undo_redo->add_undo_method(control, "_edit_set_state", control->_edit_get_state()); @@ -4285,15 +4300,15 @@ void CanvasItemEditor::_insert_animation_keys(bool p_location, bool p_rotation, } if (has_chain && ik_chain.size()) { - for (List<Node2D *>::Element *F = ik_chain.front(); F; F = F->next()) { + for (Node2D *&F : ik_chain) { if (key_pos) { - AnimationPlayerEditor::singleton->get_track_editor()->insert_node_value_key(F->get(), "position", F->get()->get_position(), p_on_existing); + AnimationPlayerEditor::singleton->get_track_editor()->insert_node_value_key(F, "position", F->get_position(), p_on_existing); } if (key_rot) { - AnimationPlayerEditor::singleton->get_track_editor()->insert_node_value_key(F->get(), "rotation", F->get()->get_rotation(), p_on_existing); + AnimationPlayerEditor::singleton->get_track_editor()->insert_node_value_key(F, "rotation", F->get_rotation(), p_on_existing); } if (key_scale) { - AnimationPlayerEditor::singleton->get_track_editor()->insert_node_value_key(F->get(), "scale", F->get()->get_scale(), p_on_existing); + AnimationPlayerEditor::singleton->get_track_editor()->insert_node_value_key(F, "scale", F->get_scale(), p_on_existing); } } } @@ -4317,8 +4332,8 @@ void CanvasItemEditor::_insert_animation_keys(bool p_location, bool p_rotation, void CanvasItemEditor::_button_toggle_anchor_mode(bool p_status) { List<CanvasItem *> selection = _get_edited_canvas_items(false, false); - for (List<CanvasItem *>::Element *E = selection.front(); E; E = E->next()) { - Control *control = Object::cast_to<Control>(E->get()); + for (CanvasItem *E : selection) { + Control *control = Object::cast_to<Control>(E); if (!control || Object::cast_to<Container>(control->get_parent())) { continue; } @@ -4431,13 +4446,13 @@ void CanvasItemEditor::_popup_callback(int p_op) { } break; case SKELETON_SHOW_BONES: { List<Node *> selection = editor_selection->get_selected_node_list(); - for (List<Node *>::Element *E = selection.front(); E; E = E->next()) { + for (Node *E : selection) { // Add children nodes so they are processed - for (int child = 0; child < E->get()->get_child_count(); child++) { - selection.push_back(E->get()->get_child(child)); + for (int child = 0; child < E->get_child_count(); child++) { + selection.push_back(E->get_child(child)); } - Bone2D *bone_2d = Object::cast_to<Bone2D>(E->get()); + Bone2D *bone_2d = Object::cast_to<Bone2D>(E); if (!bone_2d || !bone_2d->is_inside_tree()) { continue; } @@ -4467,8 +4482,8 @@ void CanvasItemEditor::_popup_callback(int p_op) { undo_redo->create_action(TTR("Lock Selected")); List<Node *> selection = editor_selection->get_selected_node_list(); - for (List<Node *>::Element *E = selection.front(); E; E = E->next()) { - CanvasItem *canvas_item = Object::cast_to<CanvasItem>(E->get()); + for (Node *E : selection) { + CanvasItem *canvas_item = Object::cast_to<CanvasItem>(E); if (!canvas_item || !canvas_item->is_inside_tree()) { continue; } @@ -4489,8 +4504,8 @@ void CanvasItemEditor::_popup_callback(int p_op) { undo_redo->create_action(TTR("Unlock Selected")); List<Node *> selection = editor_selection->get_selected_node_list(); - for (List<Node *>::Element *E = selection.front(); E; E = E->next()) { - CanvasItem *canvas_item = Object::cast_to<CanvasItem>(E->get()); + for (Node *E : selection) { + CanvasItem *canvas_item = Object::cast_to<CanvasItem>(E); if (!canvas_item || !canvas_item->is_inside_tree()) { continue; } @@ -4511,8 +4526,8 @@ void CanvasItemEditor::_popup_callback(int p_op) { undo_redo->create_action(TTR("Group Selected")); List<Node *> selection = editor_selection->get_selected_node_list(); - for (List<Node *>::Element *E = selection.front(); E; E = E->next()) { - CanvasItem *canvas_item = Object::cast_to<CanvasItem>(E->get()); + for (Node *E : selection) { + CanvasItem *canvas_item = Object::cast_to<CanvasItem>(E); if (!canvas_item || !canvas_item->is_inside_tree()) { continue; } @@ -4533,8 +4548,8 @@ void CanvasItemEditor::_popup_callback(int p_op) { undo_redo->create_action(TTR("Ungroup Selected")); List<Node *> selection = editor_selection->get_selected_node_list(); - for (List<Node *>::Element *E = selection.front(); E; E = E->next()) { - CanvasItem *canvas_item = Object::cast_to<CanvasItem>(E->get()); + for (Node *E : selection) { + CanvasItem *canvas_item = Object::cast_to<CanvasItem>(E); if (!canvas_item || !canvas_item->is_inside_tree()) { continue; } @@ -4701,14 +4716,14 @@ void CanvasItemEditor::_popup_callback(int p_op) { } undo_redo->create_action(TTR("Paste Pose")); - for (List<PoseClipboard>::Element *E = pose_clipboard.front(); E; E = E->next()) { - Node2D *n2d = Object::cast_to<Node2D>(ObjectDB::get_instance(E->get().id)); + for (const PoseClipboard &E : pose_clipboard) { + Node2D *n2d = Object::cast_to<Node2D>(ObjectDB::get_instance(E.id)); if (!n2d) { continue; } - undo_redo->add_do_method(n2d, "set_position", E->get().pos); - undo_redo->add_do_method(n2d, "set_rotation", E->get().rot); - undo_redo->add_do_method(n2d, "set_scale", E->get().scale); + undo_redo->add_do_method(n2d, "set_position", E.pos); + undo_redo->add_do_method(n2d, "set_rotation", E.rot); + undo_redo->add_do_method(n2d, "set_scale", E.scale); undo_redo->add_undo_method(n2d, "set_position", n2d->get_position()); undo_redo->add_undo_method(n2d, "set_rotation", n2d->get_rotation()); undo_redo->add_undo_method(n2d, "set_scale", n2d->get_scale()); @@ -4889,7 +4904,7 @@ void CanvasItemEditor::_focus_selection(int p_op) { zoom *= 0.90; viewport->update(); zoom_widget->set_zoom(zoom); - call_deferred("_popup_callback", VIEW_CENTER_TO_SELECTION); + call_deferred(SNAME("_popup_callback"), VIEW_CENTER_TO_SELECTION); } } } @@ -5129,11 +5144,11 @@ void CanvasItemEditor::remove_control_from_info_overlay(Control *p_control) { void CanvasItemEditor::add_control_to_menu_panel(Control *p_control) { ERR_FAIL_COND(!p_control); - hb->add_child(p_control); + hbc_context_menu->add_child(p_control); } void CanvasItemEditor::remove_control_from_menu_panel(Control *p_control) { - hb->remove_child(p_control); + hbc_context_menu->remove_child(p_control); } HSplitContainer *CanvasItemEditor::get_palette_split() { @@ -5215,8 +5230,8 @@ CanvasItemEditor::CanvasItemEditor(EditorNode *p_editor) { editor->get_scene_tree_dock()->connect("node_created", callable_mp(this, &CanvasItemEditor::_node_created)); editor->get_scene_tree_dock()->connect("add_node_used", callable_mp(this, &CanvasItemEditor::_reset_create_position)); - editor->call_deferred("connect", "play_pressed", Callable(this, "_update_override_camera_button"), make_binds(true)); - editor->call_deferred("connect", "stop_pressed", Callable(this, "_update_override_camera_button"), make_binds(false)); + editor->call_deferred(SNAME("connect"), "play_pressed", Callable(this, "_update_override_camera_button"), make_binds(true)); + editor->call_deferred(SNAME("connect"), "stop_pressed", Callable(this, "_update_override_camera_button"), make_binds(false)); hb = memnew(HBoxContainer); add_child(hb); @@ -5276,9 +5291,9 @@ CanvasItemEditor::CanvasItemEditor(EditorNode *p_editor) { warning_child_of_container = memnew(Label); warning_child_of_container->hide(); warning_child_of_container->set_text(TTR("Warning: Children of a container get their position and size determined only by their parent.")); - warning_child_of_container->add_theme_color_override("font_color", EditorNode::get_singleton()->get_gui_base()->get_theme_color("warning_color", "Editor")); - warning_child_of_container->add_theme_font_override("font", EditorNode::get_singleton()->get_gui_base()->get_theme_font("main", "EditorFonts")); - warning_child_of_container->add_theme_font_size_override("font_size", EditorNode::get_singleton()->get_gui_base()->get_theme_font_size("main_size", "EditorFonts")); + warning_child_of_container->add_theme_color_override("font_color", EditorNode::get_singleton()->get_gui_base()->get_theme_color(SNAME("warning_color"), SNAME("Editor"))); + warning_child_of_container->add_theme_font_override("font", EditorNode::get_singleton()->get_gui_base()->get_theme_font(SNAME("main"), SNAME("EditorFonts"))); + warning_child_of_container->add_theme_font_size_override("font_size", EditorNode::get_singleton()->get_gui_base()->get_theme_font_size(SNAME("main_size"), SNAME("EditorFonts"))); add_control_to_info_overlay(warning_child_of_container); h_scroll = memnew(HScrollBar); @@ -5315,7 +5330,7 @@ CanvasItemEditor::CanvasItemEditor(EditorNode *p_editor) { select_button->set_pressed(true); select_button->set_shortcut(ED_SHORTCUT("canvas_item_editor/select_mode", TTR("Select Mode"), KEY_Q)); select_button->set_shortcut_context(this); - select_button->set_tooltip(keycode_get_string(KEY_MASK_CMD) + TTR("Drag: Rotate") + "\n" + TTR("Alt+Drag: Move") + "\n" + TTR("Press 'v' to Change Pivot, 'Shift+v' to Drag Pivot (while moving).") + "\n" + TTR("Alt+RMB: Depth list selection")); + select_button->set_tooltip(keycode_get_string(KEY_MASK_CMD) + TTR("Drag: Rotate selected node around pivot.") + "\n" + TTR("Alt+Drag: Move selected node.") + "\n" + TTR("V: Set selected node's pivot position.") + "\n" + TTR("Alt+RMB: Show list of all nodes at position clicked, including locked.") + "\n" + keycode_get_string(KEY_MASK_CMD) + TTR("RMB: Add node at position clicked.")); hb->add_child(memnew(VSeparator)); @@ -5353,7 +5368,7 @@ CanvasItemEditor::CanvasItemEditor(EditorNode *p_editor) { hb->add_child(list_select_button); list_select_button->set_toggle_mode(true); list_select_button->connect("pressed", callable_mp(this, &CanvasItemEditor::_button_tool_select), make_binds(TOOL_LIST_SELECT)); - list_select_button->set_tooltip(TTR("Show a list of all objects at the position clicked\n(same as Alt+RMB in select mode).")); + list_select_button->set_tooltip(TTR("Show list of selectable nodes at position clicked.")); pivot_button = memnew(Button); pivot_button->set_flat(true); @@ -5438,7 +5453,7 @@ CanvasItemEditor::CanvasItemEditor(EditorNode *p_editor) { hb->add_child(lock_button); lock_button->connect("pressed", callable_mp(this, &CanvasItemEditor::_popup_callback), varray(LOCK_SELECTED)); - lock_button->set_tooltip(TTR("Lock the selected object in place (can't be moved).")); + lock_button->set_tooltip(TTR("Lock selected node, preventing selection and movement.")); // Define the shortcut globally (without a context) so that it works if the Scene tree dock is currently focused. lock_button->set_shortcut(ED_SHORTCUT("editor/lock_selected_nodes", TTR("Lock Selected Node(s)"), KEY_MASK_CMD | KEY_L)); @@ -5446,7 +5461,7 @@ CanvasItemEditor::CanvasItemEditor(EditorNode *p_editor) { unlock_button->set_flat(true); hb->add_child(unlock_button); unlock_button->connect("pressed", callable_mp(this, &CanvasItemEditor::_popup_callback), varray(UNLOCK_SELECTED)); - unlock_button->set_tooltip(TTR("Unlock the selected object (can be moved).")); + unlock_button->set_tooltip(TTR("Unlock selected node, allowing selection and movement.")); // Define the shortcut globally (without a context) so that it works if the Scene tree dock is currently focused. unlock_button->set_shortcut(ED_SHORTCUT("editor/unlock_selected_nodes", TTR("Unlock Selected Node(s)"), KEY_MASK_CMD | KEY_MASK_SHIFT | KEY_L)); @@ -5518,10 +5533,21 @@ CanvasItemEditor::CanvasItemEditor(EditorNode *p_editor) { p->add_separator(); p->add_check_shortcut(ED_SHORTCUT("canvas_item_editor/preview_canvas_scale", TTR("Preview Canvas Scale"), KEY_MASK_SHIFT | KEY_MASK_CMD | KEY_P), PREVIEW_CANVAS_SCALE); + hb->add_child(memnew(VSeparator)); + + context_menu_container = memnew(PanelContainer); + hbc_context_menu = memnew(HBoxContainer); + context_menu_container->add_child(hbc_context_menu); + // Use a custom stylebox to make contextual menu items stand out from the rest. + // This helps with editor usability as contextual menu items change when selecting nodes, + // even though it may not be immediately obvious at first. + hb->add_child(context_menu_container); + _update_context_menu_stylebox(); + presets_menu = memnew(MenuButton); presets_menu->set_shortcut_context(this); presets_menu->set_text(TTR("Layout")); - hb->add_child(presets_menu); + hbc_context_menu->add_child(presets_menu); presets_menu->hide(); presets_menu->set_switch_on_hover(true); @@ -5535,17 +5561,18 @@ CanvasItemEditor::CanvasItemEditor(EditorNode *p_editor) { anchor_mode_button = memnew(Button); anchor_mode_button->set_flat(true); - hb->add_child(anchor_mode_button); + hbc_context_menu->add_child(anchor_mode_button); anchor_mode_button->set_toggle_mode(true); anchor_mode_button->hide(); anchor_mode_button->connect("toggled", callable_mp(this, &CanvasItemEditor::_button_toggle_anchor_mode)); animation_hb = memnew(HBoxContainer); - hb->add_child(animation_hb); + hbc_context_menu->add_child(animation_hb); animation_hb->add_child(memnew(VSeparator)); animation_hb->hide(); key_loc_button = memnew(Button); + key_loc_button->set_flat(true); key_loc_button->set_toggle_mode(true); key_loc_button->set_pressed(true); key_loc_button->set_focus_mode(FOCUS_NONE); @@ -5554,6 +5581,7 @@ CanvasItemEditor::CanvasItemEditor(EditorNode *p_editor) { animation_hb->add_child(key_loc_button); key_rot_button = memnew(Button); + key_rot_button->set_flat(true); key_rot_button->set_toggle_mode(true); key_rot_button->set_pressed(true); key_rot_button->set_focus_mode(FOCUS_NONE); @@ -5562,6 +5590,7 @@ CanvasItemEditor::CanvasItemEditor(EditorNode *p_editor) { animation_hb->add_child(key_rot_button); key_scale_button = memnew(Button); + key_scale_button->set_flat(true); key_scale_button->set_toggle_mode(true); key_scale_button->set_focus_mode(FOCUS_NONE); key_scale_button->connect("pressed", callable_mp(this, &CanvasItemEditor::_popup_callback), varray(ANIM_INSERT_SCALE)); @@ -5569,6 +5598,7 @@ CanvasItemEditor::CanvasItemEditor(EditorNode *p_editor) { animation_hb->add_child(key_scale_button); key_insert_button = memnew(Button); + key_insert_button->set_flat(true); key_insert_button->set_focus_mode(FOCUS_NONE); key_insert_button->connect("pressed", callable_mp(this, &CanvasItemEditor::_popup_callback), varray(ANIM_INSERT_KEY)); key_insert_button->set_tooltip(TTR("Insert keys (based on mask).")); @@ -5615,8 +5645,8 @@ CanvasItemEditor::CanvasItemEditor(EditorNode *p_editor) { add_node_menu = memnew(PopupMenu); add_child(add_node_menu); - add_node_menu->add_icon_item(editor->get_scene_tree_dock()->get_theme_icon("Add", "EditorIcons"), TTR("Add Node Here")); - add_node_menu->add_icon_item(editor->get_scene_tree_dock()->get_theme_icon("Instance", "EditorIcons"), TTR("Instance Scene Here")); + add_node_menu->add_icon_item(editor->get_scene_tree_dock()->get_theme_icon(SNAME("Add"), SNAME("EditorIcons")), TTR("Add Node Here")); + add_node_menu->add_icon_item(editor->get_scene_tree_dock()->get_theme_icon(SNAME("Instance"), SNAME("EditorIcons")), TTR("Instance Scene Here")); add_node_menu->connect("id_pressed", callable_mp(this, &CanvasItemEditor::_add_node_pressed)); multiply_grid_step_shortcut = ED_SHORTCUT("canvas_item_editor/multiply_grid_step", TTR("Multiply grid step by 2"), KEY_KP_MULTIPLY); @@ -5630,6 +5660,11 @@ CanvasItemEditor::CanvasItemEditor(EditorNode *p_editor) { // those shortcuts one by one. // Resetting zoom to 100% is a duplicate shortcut of `canvas_item_editor/reset_zoom`, // but it ensures both 1 and Ctrl + 0 can be used to reset zoom. + ED_SHORTCUT("canvas_item_editor/zoom_3.125_percent", TTR("Zoom to 3.125%"), KEY_MASK_SHIFT | KEY_5); + ED_SHORTCUT("canvas_item_editor/zoom_6.25_percent", TTR("Zoom to 6.25%"), KEY_MASK_SHIFT | KEY_4); + ED_SHORTCUT("canvas_item_editor/zoom_12.5_percent", TTR("Zoom to 12.5%"), KEY_MASK_SHIFT | KEY_3); + ED_SHORTCUT("canvas_item_editor/zoom_25_percent", TTR("Zoom to 25%"), KEY_MASK_SHIFT | KEY_2); + ED_SHORTCUT("canvas_item_editor/zoom_50_percent", TTR("Zoom to 50%"), KEY_MASK_SHIFT | KEY_1); ED_SHORTCUT("canvas_item_editor/zoom_100_percent", TTR("Zoom to 100%"), KEY_1); ED_SHORTCUT("canvas_item_editor/zoom_200_percent", TTR("Zoom to 200%"), KEY_2); ED_SHORTCUT("canvas_item_editor/zoom_400_percent", TTR("Zoom to 400%"), KEY_3); @@ -5639,7 +5674,7 @@ CanvasItemEditor::CanvasItemEditor(EditorNode *p_editor) { set_process_unhandled_key_input(true); // Update the menus' checkboxes - call_deferred("set_state", get_state()); + call_deferred(SNAME("set_state"), get_state()); } CanvasItemEditor *CanvasItemEditor::singleton = nullptr; @@ -5730,11 +5765,14 @@ void CanvasItemEditorViewport::_create_preview(const Vector<String> &files) cons preview_node->add_child(sprite); label->show(); label_desc->show(); + label_desc->set_text(TTR("Drag and drop to add as child of current scene's root node.\nHold Ctrl when dropping to add as child of selected node.\nHold Shift when dropping to add as sibling of selected node.\nHold Alt when dropping to add as a different node type.")); } else { if (scene.is_valid()) { Node *instance = scene->instantiate(); if (instance) { preview_node->add_child(instance); + label_desc->show(); + label_desc->set_text(TTR("Drag and drop to add as child of current scene's root node.\nHold Ctrl when dropping to add as child of selected node.\nHold Shift when dropping to add as sibling of selected node.")); } } } @@ -5804,14 +5842,14 @@ void CanvasItemEditorViewport::_create_nodes(Node *parent, Node *child, String & String property = "texture"; List<PropertyInfo> props; child->get_property_list(&props); - for (const List<PropertyInfo>::Element *E = props.front(); E; E = E->next()) { - if (E->get().name == "config/texture") { // Particles2D + for (const PropertyInfo &E : props) { + if (E.name == "config/texture") { // Particles2D property = "config/texture"; break; - } else if (E->get().name == "texture/texture") { // Polygon2D + } else if (E.name == "texture/texture") { // Polygon2D property = "texture/texture"; break; - } else if (E->get().name == "normal") { // TouchScreenButton + } else if (E.name == "normal") { // TouchScreenButton property = "normal"; break; } @@ -6033,6 +6071,7 @@ bool CanvasItemEditorViewport::_only_packed_scenes_selected() const { void CanvasItemEditorViewport::drop_data(const Point2 &p_point, const Variant &p_data) { bool is_shift = Input::get_singleton()->is_key_pressed(KEY_SHIFT); + bool is_ctrl = Input::get_singleton()->is_key_pressed(KEY_CTRL); bool is_alt = Input::get_singleton()->is_key_pressed(KEY_ALT); selected_files.clear(); @@ -6044,24 +6083,25 @@ void CanvasItemEditorViewport::drop_data(const Point2 &p_point, const Variant &p return; } - List<Node *> list = editor->get_editor_selection()->get_selected_node_list(); - if (list.size() == 0) { - Node *root_node = editor->get_edited_scene(); + List<Node *> selected_nodes = editor->get_editor_selection()->get_selected_node_list(); + Node *root_node = editor->get_edited_scene(); + if (selected_nodes.size() > 0) { + Node *selected_node = selected_nodes[0]; + target_node = root_node; + if (is_ctrl) { + target_node = selected_node; + } else if (is_shift && selected_node != root_node) { + target_node = selected_node->get_parent(); + } + } else { if (root_node) { - list.push_back(root_node); + target_node = root_node; } else { drop_pos = p_point; target_node = nullptr; } } - if (list.size() > 0) { - target_node = list[0]; - if (is_shift && target_node != editor->get_edited_scene()) { - target_node = target_node->get_parent(); - } - } - drop_pos = p_point; if (is_alt && !_only_packed_scenes_selected()) { @@ -6075,7 +6115,7 @@ void CanvasItemEditorViewport::_notification(int p_what) { switch (p_what) { case NOTIFICATION_ENTER_TREE: { connect("mouse_exited", callable_mp(this, &CanvasItemEditorViewport::_on_mouse_exit)); - label->add_theme_color_override("font_color", get_theme_color("warning_color", "Editor")); + label->add_theme_color_override("font_color", get_theme_color(SNAME("warning_color"), SNAME("Editor"))); } break; case NOTIFICATION_EXIT_TREE: { disconnect("mouse_exited", callable_mp(this, &CanvasItemEditorViewport::_on_mouse_exit)); @@ -6142,7 +6182,6 @@ CanvasItemEditorViewport::CanvasItemEditorViewport(EditorNode *p_node, CanvasIte canvas_item_editor->get_controls_container()->add_child(label); label_desc = memnew(Label); - label_desc->set_text(TTR("Drag & drop + Shift : Add node as sibling\nDrag & drop + Alt : Change node type")); label_desc->add_theme_color_override("font_color", Color(0.6f, 0.6f, 0.6f, 1)); label_desc->add_theme_color_override("font_shadow_color", Color(0.2f, 0.2f, 0.2f, 1)); label_desc->add_theme_constant_override("shadow_as_outline", 1 * EDSCALE); diff --git a/editor/plugins/canvas_item_editor_plugin.h b/editor/plugins/canvas_item_editor_plugin.h index 7b64d0cb5d..d466032588 100644 --- a/editor/plugins/canvas_item_editor_plugin.h +++ b/editor/plugins/canvas_item_editor_plugin.h @@ -230,6 +230,10 @@ private: HScrollBar *h_scroll; VScrollBar *v_scroll; HBoxContainer *hb; + // Used for secondary menu items which are displayed depending on the currently selected node + // (such as MeshInstance's "Mesh" menu). + PanelContainer *context_menu_container; + HBoxContainer *hbc_context_menu; Map<Control *, Timer *> popup_temporarily_timers; @@ -535,6 +539,7 @@ private: HSplitContainer *palette_split; VSplitContainer *bottom_split; + void _update_context_menu_stylebox(); void _popup_warning_temporarily(Control *p_control, const float p_duration); void _popup_warning_depop(Control *p_control); diff --git a/editor/plugins/collision_polygon_3d_editor_plugin.cpp b/editor/plugins/collision_polygon_3d_editor_plugin.cpp index 6f90d278bd..5d5f78e0dc 100644 --- a/editor/plugins/collision_polygon_3d_editor_plugin.cpp +++ b/editor/plugins/collision_polygon_3d_editor_plugin.cpp @@ -42,8 +42,8 @@ void CollisionPolygon3DEditor::_notification(int p_what) { switch (p_what) { case NOTIFICATION_READY: { - button_create->set_icon(get_theme_icon("Edit", "EditorIcons")); - button_edit->set_icon(get_theme_icon("MovePoint", "EditorIcons")); + button_create->set_icon(get_theme_icon(SNAME("Edit"), SNAME("EditorIcons"))); + button_edit->set_icon(get_theme_icon(SNAME("MovePoint"), SNAME("EditorIcons"))); button_edit->set_pressed(true); get_tree()->connect("node_removed", callable_mp(this, &CollisionPolygon3DEditor::_node_removed)); @@ -531,7 +531,7 @@ CollisionPolygon3DEditor::CollisionPolygon3DEditor(EditorNode *p_editor) { handle_material->set_transparency(StandardMaterial3D::TRANSPARENCY_ALPHA); handle_material->set_flag(StandardMaterial3D::FLAG_ALBEDO_FROM_VERTEX_COLOR, true); handle_material->set_flag(StandardMaterial3D::FLAG_SRGB_VERTEX_COLOR, true); - Ref<Texture2D> handle = editor->get_gui_base()->get_theme_icon("Editor3DHandle", "EditorIcons"); + Ref<Texture2D> handle = editor->get_gui_base()->get_theme_icon(SNAME("Editor3DHandle"), SNAME("EditorIcons")); handle_material->set_point_size(handle->get_width()); handle_material->set_texture(StandardMaterial3D::TEXTURE_ALBEDO, handle); diff --git a/editor/plugins/collision_shape_2d_editor_plugin.cpp b/editor/plugins/collision_shape_2d_editor_plugin.cpp index c38458c37f..2c2adc2672 100644 --- a/editor/plugins/collision_shape_2d_editor_plugin.cpp +++ b/editor/plugins/collision_shape_2d_editor_plugin.cpp @@ -31,6 +31,7 @@ #include "collision_shape_2d_editor_plugin.h" #include "canvas_item_editor_plugin.h" +#include "core/os/keyboard.h" #include "scene/resources/capsule_shape_2d.h" #include "scene/resources/circle_shape_2d.h" #include "scene/resources/concave_polygon_shape_2d.h" @@ -97,7 +98,7 @@ Variant CollisionShape2DEditor::get_handle_value(int idx) const { case RECTANGLE_SHAPE: { Ref<RectangleShape2D> rect = node->get_shape(); - if (idx < 3) { + if (idx < 8) { return rect->get_size().abs(); } @@ -176,16 +177,26 @@ void CollisionShape2DEditor::set_handle(int idx, Point2 &p_point) { } break; case RECTANGLE_SHAPE: { - if (idx < 3) { + if (idx < 8) { Ref<RectangleShape2D> rect = node->get_shape(); + Vector2 size = (Point2)original; - Vector2 size = rect->get_size(); - if (idx == 2) { - size = p_point * 2; + if (RECT_HANDLES[idx].x != 0) { + size.x = p_point.x * RECT_HANDLES[idx].x * 2; + } + if (RECT_HANDLES[idx].y != 0) { + size.y = p_point.y * RECT_HANDLES[idx].y * 2; + } + + if (Input::get_singleton()->is_key_pressed(KEY_ALT)) { + rect->set_size(size.abs()); + node->set_global_position(original_transform.get_origin()); } else { - size[idx] = p_point[idx] * 2; + rect->set_size(((Point2)original + (size - (Point2)original) * 0.5).abs()); + Point2 pos = original_transform.affine_inverse().xform(original_transform.get_origin()); + pos += (size - (Point2)original) * 0.5 * RECT_HANDLES[idx] * 0.5; + node->set_global_position(original_transform.xform(pos)); } - rect->set_size(size.abs()); canvas_item_editor->update_viewport(); } @@ -280,8 +291,10 @@ void CollisionShape2DEditor::commit_handle(int idx, Variant &p_org) { Ref<RectangleShape2D> rect = node->get_shape(); undo_redo->add_do_method(rect.ptr(), "set_size", rect->get_size()); + undo_redo->add_do_method(node, "set_global_transform", node->get_global_transform()); undo_redo->add_do_method(canvas_item_editor, "update_viewport"); undo_redo->add_undo_method(rect.ptr(), "set_size", p_org); + undo_redo->add_undo_method(node, "set_global_transform", original_transform); undo_redo->add_undo_method(canvas_item_editor, "update_viewport"); } break; @@ -342,6 +355,8 @@ bool CollisionShape2DEditor::forward_canvas_gui_input(const Ref<InputEvent> &p_e } original = get_handle_value(edit_handle); + original_transform = node->get_global_transform(); + last_point = original; pressed = true; return true; @@ -369,13 +384,26 @@ bool CollisionShape2DEditor::forward_canvas_gui_input(const Ref<InputEvent> &p_e } Vector2 cpoint = canvas_item_editor->snap_point(canvas_item_editor->get_canvas_transform().affine_inverse().xform(mm->get_position())); - cpoint = node->get_global_transform().affine_inverse().xform(cpoint); + cpoint = original_transform.affine_inverse().xform(cpoint); + last_point = cpoint; set_handle(edit_handle, cpoint); return true; } + Ref<InputEventKey> k = p_event; + + if (k.is_valid()) { + if (edit_handle == -1 || !pressed || k->is_echo()) { + return false; + } + + if (shape_type == RECTANGLE_SHAPE && k->get_keycode() == KEY_ALT) { + set_handle(edit_handle, last_point); // Update handle when Alt key is toggled. + } + } + return false; } @@ -430,7 +458,7 @@ void CollisionShape2DEditor::forward_canvas_draw_over_viewport(Control *p_overla Transform2D gt = canvas_item_editor->get_canvas_transform() * node->get_global_transform(); - Ref<Texture2D> h = get_theme_icon("EditorHandle", "EditorIcons"); + Ref<Texture2D> h = get_theme_icon(SNAME("EditorHandle"), SNAME("EditorIcons")); Vector2 size = h->get_size() * 0.5; handles.clear(); @@ -492,15 +520,12 @@ void CollisionShape2DEditor::forward_canvas_draw_over_viewport(Control *p_overla case RECTANGLE_SHAPE: { Ref<RectangleShape2D> shape = node->get_shape(); - handles.resize(3); + handles.resize(8); Vector2 ext = shape->get_size() / 2; - handles.write[0] = Point2(ext.x, 0); - handles.write[1] = Point2(0, ext.y); - handles.write[2] = Point2(ext.x, ext.y); - - p_overlay->draw_texture(h, gt.xform(handles[0]) - size); - p_overlay->draw_texture(h, gt.xform(handles[1]) - size); - p_overlay->draw_texture(h, gt.xform(handles[2]) - size); + for (int i = 0; i < handles.size(); i++) { + handles.write[i] = RECT_HANDLES[i] * ext; + p_overlay->draw_texture(h, gt.xform(handles[i]) - size); + } } break; diff --git a/editor/plugins/collision_shape_2d_editor_plugin.h b/editor/plugins/collision_shape_2d_editor_plugin.h index 054db1a61b..7db6bd22aa 100644 --- a/editor/plugins/collision_shape_2d_editor_plugin.h +++ b/editor/plugins/collision_shape_2d_editor_plugin.h @@ -52,6 +52,17 @@ class CollisionShape2DEditor : public Control { SEGMENT_SHAPE }; + const Point2 RECT_HANDLES[8] = { + Point2(1, 0), + Point2(1, 1), + Point2(0, 1), + Point2(-1, 1), + Point2(-1, 0), + Point2(-1, -1), + Point2(0, -1), + Point2(1, -1), + }; + EditorNode *editor; UndoRedo *undo_redo; CanvasItemEditor *canvas_item_editor; @@ -63,6 +74,8 @@ class CollisionShape2DEditor : public Control { int edit_handle; bool pressed; Variant original; + Transform2D original_transform; + Point2 last_point; Variant get_handle_value(int idx) const; void set_handle(int idx, Point2 &p_point); diff --git a/editor/plugins/cpu_particles_2d_editor_plugin.cpp b/editor/plugins/cpu_particles_2d_editor_plugin.cpp index 6a56cd31d1..6f246c1661 100644 --- a/editor/plugins/cpu_particles_2d_editor_plugin.cpp +++ b/editor/plugins/cpu_particles_2d_editor_plugin.cpp @@ -224,7 +224,7 @@ void CPUParticles2DEditorPlugin::_generate_emission_mask() { void CPUParticles2DEditorPlugin::_notification(int p_what) { if (p_what == NOTIFICATION_ENTER_TREE) { menu->get_popup()->connect("id_pressed", callable_mp(this, &CPUParticles2DEditorPlugin::_menu_callback)); - menu->set_icon(epoints->get_theme_icon("CPUParticles2D", "EditorIcons")); + menu->set_icon(epoints->get_theme_icon(SNAME("CPUParticles2D"), SNAME("EditorIcons"))); file->connect("file_selected", callable_mp(this, &CPUParticles2DEditorPlugin::_file_selected)); } } @@ -253,8 +253,8 @@ CPUParticles2DEditorPlugin::CPUParticles2DEditorPlugin(EditorNode *p_node) { file = memnew(EditorFileDialog); List<String> ext; ImageLoader::get_recognized_extensions(&ext); - for (List<String>::Element *E = ext.front(); E; E = E->next()) { - file->add_filter("*." + E->get() + "; " + E->get().to_upper()); + for (const String &E : ext) { + file->add_filter("*." + E + "; " + E.to_upper()); } file->set_file_mode(EditorFileDialog::FILE_MODE_OPEN_FILE); toolbar->add_child(file); diff --git a/editor/plugins/cpu_particles_3d_editor_plugin.cpp b/editor/plugins/cpu_particles_3d_editor_plugin.cpp index f41ccfa86b..fc52cd0f99 100644 --- a/editor/plugins/cpu_particles_3d_editor_plugin.cpp +++ b/editor/plugins/cpu_particles_3d_editor_plugin.cpp @@ -41,7 +41,7 @@ void CPUParticles3DEditor::_node_removed(Node *p_node) { void CPUParticles3DEditor::_notification(int p_notification) { if (p_notification == NOTIFICATION_ENTER_TREE) { - options->set_icon(get_theme_icon("CPUParticles3D", "EditorIcons")); + options->set_icon(get_theme_icon(SNAME("CPUParticles3D"), SNAME("EditorIcons"))); } } diff --git a/editor/plugins/curve_editor_plugin.cpp b/editor/plugins/curve_editor_plugin.cpp index 706243fe25..07ff0eb346 100644 --- a/editor/plugins/curve_editor_plugin.cpp +++ b/editor/plugins/curve_editor_plugin.cpp @@ -393,7 +393,8 @@ int CurveEditor::get_point_at(Vector2 pos) const { } const Curve &curve = **_curve_ref; - const float r = _hover_radius * _hover_radius; + const float true_hover_radius = Math::round(_hover_radius * EDSCALE); + const float r = true_hover_radius * true_hover_radius; for (int i = 0; i < curve.get_point_count(); ++i) { Vector2 p = get_view_pos(curve.get_point_position(i)); @@ -519,8 +520,8 @@ void CurveEditor::set_hover_point_index(int index) { } void CurveEditor::update_view_transform() { - Ref<Font> font = get_theme_font("font", "Label"); - int font_size = get_theme_font_size("font_size", "Label"); + Ref<Font> font = get_theme_font(SNAME("font"), SNAME("Label")); + int font_size = get_theme_font_size(SNAME("font_size"), SNAME("Label")); const real_t margin = font->get_height(font_size) + 2 * EDSCALE; @@ -558,7 +559,7 @@ Vector2 CurveEditor::get_tangent_view_pos(int i, TangentIndex tangent) const { Vector2 point_pos = get_view_pos(_curve_ref->get_point_position(i)); Vector2 control_pos = get_view_pos(_curve_ref->get_point_position(i) + dir); - return point_pos + _tangents_length * (control_pos - point_pos).normalized(); + return point_pos + Math::round(_tangents_length * EDSCALE) * (control_pos - point_pos).normalized(); } Vector2 CurveEditor::get_view_pos(Vector2 world_pos) const { @@ -635,7 +636,7 @@ void CurveEditor::_draw() { // Background Vector2 view_size = get_rect().size; - draw_style_box(get_theme_stylebox("bg", "Tree"), Rect2(Point2(), view_size)); + draw_style_box(get_theme_stylebox(SNAME("bg"), SNAME("Tree")), Rect2(Point2(), view_size)); // Grid @@ -644,8 +645,8 @@ void CurveEditor::_draw() { Vector2 min_edge = get_world_pos(Vector2(0, view_size.y)); Vector2 max_edge = get_world_pos(Vector2(view_size.x, 0)); - const Color grid_color0 = get_theme_color("mono_color", "Editor") * Color(1, 1, 1, 0.15); - const Color grid_color1 = get_theme_color("mono_color", "Editor") * Color(1, 1, 1, 0.07); + const Color grid_color0 = get_theme_color(SNAME("mono_color"), SNAME("Editor")) * Color(1, 1, 1, 0.15); + const Color grid_color1 = get_theme_color(SNAME("mono_color"), SNAME("Editor")) * Color(1, 1, 1, 0.07); draw_line(Vector2(min_edge.x, curve.get_min_value()), Vector2(max_edge.x, curve.get_min_value()), grid_color0); draw_line(Vector2(max_edge.x, curve.get_max_value()), Vector2(min_edge.x, curve.get_max_value()), grid_color0); draw_line(Vector2(0, min_edge.y), Vector2(0, max_edge.y), grid_color0); @@ -665,10 +666,10 @@ void CurveEditor::_draw() { draw_set_transform_matrix(Transform2D()); - Ref<Font> font = get_theme_font("font", "Label"); - int font_size = get_theme_font_size("font_size", "Label"); + Ref<Font> font = get_theme_font(SNAME("font"), SNAME("Label")); + int font_size = get_theme_font_size(SNAME("font_size"), SNAME("Label")); float font_height = font->get_height(font_size); - Color text_color = get_theme_color("font_color", "Editor"); + Color text_color = get_theme_color(SNAME("font_color"), SNAME("Editor")); { // X axis @@ -695,7 +696,7 @@ void CurveEditor::_draw() { // Draw tangents for current point if (_selected_point >= 0) { - const Color tangent_color = get_theme_color("accent_color", "Editor"); + const Color tangent_color = get_theme_color(SNAME("accent_color"), SNAME("Editor")); int i = _selected_point; Vector2 pos = curve.get_point_position(i); @@ -703,13 +704,13 @@ void CurveEditor::_draw() { if (i != 0) { Vector2 control_pos = get_tangent_view_pos(i, TANGENT_LEFT); draw_line(get_view_pos(pos), control_pos, tangent_color, Math::round(EDSCALE)); - draw_rect(Rect2(control_pos, Vector2(1, 1)).grow(2), tangent_color); + draw_rect(Rect2(control_pos, Vector2(1, 1)).grow(Math::round(2 * EDSCALE)), tangent_color); } if (i != curve.get_point_count() - 1) { Vector2 control_pos = get_tangent_view_pos(i, TANGENT_RIGHT); draw_line(get_view_pos(pos), control_pos, tangent_color, Math::round(EDSCALE)); - draw_rect(Rect2(control_pos, Vector2(1, 1)).grow(2), tangent_color); + draw_rect(Rect2(control_pos, Vector2(1, 1)).grow(Math::round(2 * EDSCALE)), tangent_color); } } @@ -717,8 +718,8 @@ void CurveEditor::_draw() { draw_set_transform_matrix(_world_to_view); - const Color line_color = get_theme_color("font_color", "Editor"); - const Color edge_line_color = get_theme_color("highlight_color", "Editor"); + const Color line_color = get_theme_color(SNAME("font_color"), SNAME("Editor")); + const Color edge_line_color = get_theme_color(SNAME("highlight_color"), SNAME("Editor")); CanvasItemPlotCurve plot_func(*this, line_color, edge_line_color); plot_curve_accurate(curve, 4.f / view_size.x, plot_func); @@ -727,12 +728,12 @@ void CurveEditor::_draw() { draw_set_transform_matrix(Transform2D()); - const Color point_color = get_theme_color("font_color", "Editor"); - const Color selected_point_color = get_theme_color("accent_color", "Editor"); + const Color point_color = get_theme_color(SNAME("font_color"), SNAME("Editor")); + const Color selected_point_color = get_theme_color(SNAME("accent_color"), SNAME("Editor")); for (int i = 0; i < curve.get_point_count(); ++i) { Vector2 pos = curve.get_point_position(i); - draw_rect(Rect2(get_view_pos(pos), Vector2(1, 1)).grow(3), i == _selected_point ? selected_point_color : point_color); + draw_rect(Rect2(get_view_pos(pos), Vector2(1, 1)).grow(Math::round(3 * EDSCALE)), i == _selected_point ? selected_point_color : point_color); // TODO Circles are prettier. Needs a fix! Or a texture //draw_circle(pos, 2, point_color); } @@ -742,7 +743,7 @@ void CurveEditor::_draw() { if (_hover_point != -1) { const Color hover_color = line_color; Vector2 pos = curve.get_point_position(_hover_point); - draw_rect(Rect2(get_view_pos(pos), Vector2(1, 1)).grow(_hover_radius), hover_color, false, Math::round(EDSCALE)); + draw_rect(Rect2(get_view_pos(pos), Vector2(1, 1)).grow(Math::round(_hover_radius * EDSCALE)), hover_color, false, Math::round(EDSCALE)); } // Help text diff --git a/editor/plugins/editor_debugger_plugin.cpp b/editor/plugins/editor_debugger_plugin.cpp index 85114d88ae..89073b7189 100644 --- a/editor/plugins/editor_debugger_plugin.cpp +++ b/editor/plugins/editor_debugger_plugin.cpp @@ -34,18 +34,18 @@ void EditorDebuggerPlugin::_breaked(bool p_really_did, bool p_can_debug) { if (p_really_did) { - emit_signal("breaked", p_can_debug); + emit_signal(SNAME("breaked"), p_can_debug); } else { - emit_signal("continued"); + emit_signal(SNAME("continued")); } } void EditorDebuggerPlugin::_started() { - emit_signal("started"); + emit_signal(SNAME("started")); } void EditorDebuggerPlugin::_stopped() { - emit_signal("stopped"); + emit_signal(SNAME("stopped")); } void EditorDebuggerPlugin::_bind_methods() { diff --git a/editor/plugins/editor_preview_plugins.cpp b/editor/plugins/editor_preview_plugins.cpp index a233d66d82..81c340e9a4 100644 --- a/editor/plugins/editor_preview_plugins.cpp +++ b/editor/plugins/editor_preview_plugins.cpp @@ -490,11 +490,11 @@ Ref<Texture2D> EditorScriptPreviewPlugin::generate(const RES &p_from, const Size Set<String> control_flow_keywords; Set<String> keywords; - for (List<String>::Element *E = kwors.front(); E; E = E->next()) { - if (scr->get_language()->is_control_flow_keyword(E->get())) { - control_flow_keywords.insert(E->get()); + for (const String &E : kwors) { + if (scr->get_language()->is_control_flow_keyword(E)) { + control_flow_keywords.insert(E); } else { - keywords.insert(E->get()); + keywords.insert(E); } } diff --git a/editor/plugins/font_editor_plugin.cpp b/editor/plugins/font_editor_plugin.cpp index e385a84087..22c9cc9ab1 100644 --- a/editor/plugins/font_editor_plugin.cpp +++ b/editor/plugins/font_editor_plugin.cpp @@ -34,7 +34,7 @@ void FontDataPreview::_notification(int p_what) { if (p_what == NOTIFICATION_DRAW) { - Color text_color = get_theme_color("font_color", "Label"); + Color text_color = get_theme_color(SNAME("font_color"), SNAME("Label")); Color line_color = text_color; line_color.a *= 0.6; Vector2 pos = (get_size() - line->get_size()) / 2; @@ -127,7 +127,7 @@ FontDataPreview::FontDataPreview() { void FontDataEditor::_notification(int p_what) { if (p_what == NOTIFICATION_SORT_CHILDREN) { int split_width = get_name_split_ratio() * get_size().width; - button->set_size(Size2(get_theme_icon("Add", "EditorIcons")->get_width(), get_size().height)); + button->set_size(Size2(get_theme_icon(SNAME("Add"), SNAME("EditorIcons"))->get_width(), get_size().height)); if (is_layout_rtl()) { if (le != nullptr) { fit_child_in_rect(le, Rect2(Vector2(split_width, 0), Size2(split_width, get_size().height))); @@ -145,7 +145,7 @@ void FontDataEditor::_notification(int p_what) { } if (p_what == NOTIFICATION_DRAW) { int split_width = get_name_split_ratio() * get_size().width; - Color dark_color = get_theme_color("dark_color_2", "Editor"); + Color dark_color = get_theme_color(SNAME("dark_color_2"), SNAME("Editor")); if (is_layout_rtl()) { draw_rect(Rect2(Vector2(0, 0), Size2(split_width, get_size().height)), dark_color); } else { @@ -154,9 +154,9 @@ void FontDataEditor::_notification(int p_what) { } if (p_what == NOTIFICATION_THEME_CHANGED) { if (le != nullptr) { - button->set_icon(get_theme_icon("Add", "EditorIcons")); + button->set_icon(get_theme_icon(SNAME("Add"), SNAME("EditorIcons"))); } else { - button->set_icon(get_theme_icon("Remove", "EditorIcons")); + button->set_icon(get_theme_icon(SNAME("Remove"), SNAME("EditorIcons"))); } queue_sort(); } @@ -187,12 +187,12 @@ void FontDataEditor::init_lang_add() { le->set_editable(true); add_child(le); - button->set_icon(get_theme_icon("Add", "EditorIcons")); + button->set_icon(get_theme_icon(SNAME("Add"), SNAME("EditorIcons"))); button->connect("pressed", callable_mp(this, &FontDataEditor::add_lang)); } void FontDataEditor::init_lang_edit() { - button->set_icon(get_theme_icon("Remove", "EditorIcons")); + button->set_icon(get_theme_icon(SNAME("Remove"), SNAME("EditorIcons"))); button->connect("pressed", callable_mp(this, &FontDataEditor::remove_lang)); chk->connect("toggled", callable_mp(this, &FontDataEditor::toggle_lang)); } @@ -204,12 +204,12 @@ void FontDataEditor::init_script_add() { le->set_editable(true); add_child(le); - button->set_icon(get_theme_icon("Add", "EditorIcons")); + button->set_icon(get_theme_icon(SNAME("Add"), SNAME("EditorIcons"))); button->connect("pressed", callable_mp(this, &FontDataEditor::add_script)); } void FontDataEditor::init_script_edit() { - button->set_icon(get_theme_icon("Remove", "EditorIcons")); + button->set_icon(get_theme_icon(SNAME("Remove"), SNAME("EditorIcons"))); button->connect("pressed", callable_mp(this, &FontDataEditor::remove_script)); chk->connect("toggled", callable_mp(this, &FontDataEditor::toggle_script)); } diff --git a/editor/plugins/gpu_particles_2d_editor_plugin.cpp b/editor/plugins/gpu_particles_2d_editor_plugin.cpp index 37f900280b..5184e837ce 100644 --- a/editor/plugins/gpu_particles_2d_editor_plugin.cpp +++ b/editor/plugins/gpu_particles_2d_editor_plugin.cpp @@ -329,7 +329,7 @@ void GPUParticles2DEditorPlugin::_generate_emission_mask() { void GPUParticles2DEditorPlugin::_notification(int p_what) { if (p_what == NOTIFICATION_ENTER_TREE) { menu->get_popup()->connect("id_pressed", callable_mp(this, &GPUParticles2DEditorPlugin::_menu_callback)); - menu->set_icon(menu->get_theme_icon("GPUParticles2D", "EditorIcons")); + menu->set_icon(menu->get_theme_icon(SNAME("GPUParticles2D"), SNAME("EditorIcons"))); file->connect("file_selected", callable_mp(this, &GPUParticles2DEditorPlugin::_file_selected)); } } @@ -361,8 +361,8 @@ GPUParticles2DEditorPlugin::GPUParticles2DEditorPlugin(EditorNode *p_node) { file = memnew(EditorFileDialog); List<String> ext; ImageLoader::get_recognized_extensions(&ext); - for (List<String>::Element *E = ext.front(); E; E = E->next()) { - file->add_filter("*." + E->get() + "; " + E->get().to_upper()); + for (const String &E : ext) { + file->add_filter("*." + E + "; " + E.to_upper()); } file->set_file_mode(EditorFileDialog::FILE_MODE_OPEN_FILE); toolbar->add_child(file); diff --git a/editor/plugins/gpu_particles_3d_editor_plugin.cpp b/editor/plugins/gpu_particles_3d_editor_plugin.cpp index 571bcf9c4a..8576082597 100644 --- a/editor/plugins/gpu_particles_3d_editor_plugin.cpp +++ b/editor/plugins/gpu_particles_3d_editor_plugin.cpp @@ -230,7 +230,7 @@ void GPUParticles3DEditor::_node_removed(Node *p_node) { void GPUParticles3DEditor::_notification(int p_notification) { if (p_notification == NOTIFICATION_ENTER_TREE) { - options->set_icon(options->get_popup()->get_theme_icon("GPUParticles3D", "EditorIcons")); + options->set_icon(options->get_popup()->get_theme_icon(SNAME("GPUParticles3D"), SNAME("EditorIcons"))); get_tree()->connect("node_removed", callable_mp(this, &GPUParticles3DEditor::_node_removed)); } } diff --git a/editor/plugins/gpu_particles_collision_sdf_editor_plugin.cpp b/editor/plugins/gpu_particles_collision_sdf_editor_plugin.cpp index a2dee4a1dc..a4436525fb 100644 --- a/editor/plugins/gpu_particles_collision_sdf_editor_plugin.cpp +++ b/editor/plugins/gpu_particles_collision_sdf_editor_plugin.cpp @@ -83,13 +83,13 @@ void GPUParticlesCollisionSDFEditorPlugin::_notification(int p_what) { Color color; if (size_mb <= 16.0 + CMP_EPSILON) { // Fast. - color = bake_info->get_theme_color("success_color", "Editor"); + color = bake_info->get_theme_color(SNAME("success_color"), SNAME("Editor")); } else if (size_mb <= 64.0 + CMP_EPSILON) { // Medium. - color = bake_info->get_theme_color("warning_color", "Editor"); + color = bake_info->get_theme_color(SNAME("warning_color"), SNAME("Editor")); } else { // Slow. - color = bake_info->get_theme_color("error_color", "Editor"); + color = bake_info->get_theme_color(SNAME("error_color"), SNAME("Editor")); } bake_info->add_theme_color_override("font_color", color); @@ -131,7 +131,7 @@ void GPUParticlesCollisionSDFEditorPlugin::_sdf_save_path_and_bake(const String if (col_sdf) { Ref<Image> bake_img = col_sdf->bake(); if (bake_img.is_null()) { - EditorNode::get_singleton()->show_warning("Bake Error."); + EditorNode::get_singleton()->show_warning(TTR("Bake Error.")); return; } @@ -174,7 +174,7 @@ GPUParticlesCollisionSDFEditorPlugin::GPUParticlesCollisionSDFEditorPlugin(Edito bake_hb->hide(); bake = memnew(Button); bake->set_flat(true); - bake->set_icon(editor->get_gui_base()->get_theme_icon("Bake", "EditorIcons")); + bake->set_icon(editor->get_gui_base()->get_theme_icon(SNAME("Bake"), SNAME("EditorIcons"))); bake->set_text(TTR("Bake SDF")); bake->connect("pressed", callable_mp(this, &GPUParticlesCollisionSDFEditorPlugin::_bake)); bake_hb->add_child(bake); diff --git a/editor/plugins/input_event_editor_plugin.cpp b/editor/plugins/input_event_editor_plugin.cpp index f1aa10844b..d3d2de92f5 100644 --- a/editor/plugins/input_event_editor_plugin.cpp +++ b/editor/plugins/input_event_editor_plugin.cpp @@ -86,7 +86,7 @@ InputEventConfigContainer::InputEventConfigContainer() { mc->add_child(hb); open_config_button = memnew(Button); - open_config_button->set_text("Configure"); + open_config_button->set_text(TTR("Configure")); open_config_button->connect("pressed", callable_mp(this, &InputEventConfigContainer::_configure_pressed)); hb->add_child(open_config_button); diff --git a/editor/plugins/item_list_editor_plugin.cpp b/editor/plugins/item_list_editor_plugin.cpp index 1ea6630622..3207a989bd 100644 --- a/editor/plugins/item_list_editor_plugin.cpp +++ b/editor/plugins/item_list_editor_plugin.cpp @@ -243,8 +243,8 @@ void ItemListEditor::_node_removed(Node *p_node) { void ItemListEditor::_notification(int p_notification) { if (p_notification == NOTIFICATION_ENTER_TREE || p_notification == NOTIFICATION_THEME_CHANGED) { - add_button->set_icon(get_theme_icon("Add", "EditorIcons")); - del_button->set_icon(get_theme_icon("Remove", "EditorIcons")); + add_button->set_icon(get_theme_icon(SNAME("Add"), SNAME("EditorIcons"))); + del_button->set_icon(get_theme_icon(SNAME("Remove"), SNAME("EditorIcons"))); } else if (p_notification == NOTIFICATION_READY) { get_tree()->connect("node_removed", callable_mp(this, &ItemListEditor::_node_removed)); } diff --git a/editor/plugins/lightmap_gi_editor_plugin.cpp b/editor/plugins/lightmap_gi_editor_plugin.cpp index 484fdabfe1..b4a70cd31d 100644 --- a/editor/plugins/lightmap_gi_editor_plugin.cpp +++ b/editor/plugins/lightmap_gi_editor_plugin.cpp @@ -119,7 +119,7 @@ LightmapGIEditorPlugin::LightmapGIEditorPlugin(EditorNode *p_node) { editor = p_node; bake = memnew(Button); bake->set_flat(true); - bake->set_icon(editor->get_gui_base()->get_theme_icon("Bake", "EditorIcons")); + bake->set_icon(editor->get_gui_base()->get_theme_icon(SNAME("Bake"), SNAME("EditorIcons"))); bake->set_text(TTR("Bake Lightmaps")); bake->hide(); bake->connect("pressed", Callable(this, "_bake")); diff --git a/editor/plugins/material_editor_plugin.cpp b/editor/plugins/material_editor_plugin.cpp index 17a634ee14..94966d4fe6 100644 --- a/editor/plugins/material_editor_plugin.cpp +++ b/editor/plugins/material_editor_plugin.cpp @@ -42,22 +42,22 @@ void MaterialEditor::_notification(int p_what) { if (first_enter) { //it's in propertyeditor so.. could be moved around - light_1_switch->set_normal_texture(get_theme_icon("MaterialPreviewLight1", "EditorIcons")); - light_1_switch->set_pressed_texture(get_theme_icon("MaterialPreviewLight1Off", "EditorIcons")); - light_2_switch->set_normal_texture(get_theme_icon("MaterialPreviewLight2", "EditorIcons")); - light_2_switch->set_pressed_texture(get_theme_icon("MaterialPreviewLight2Off", "EditorIcons")); + light_1_switch->set_normal_texture(get_theme_icon(SNAME("MaterialPreviewLight1"), SNAME("EditorIcons"))); + light_1_switch->set_pressed_texture(get_theme_icon(SNAME("MaterialPreviewLight1Off"), SNAME("EditorIcons"))); + light_2_switch->set_normal_texture(get_theme_icon(SNAME("MaterialPreviewLight2"), SNAME("EditorIcons"))); + light_2_switch->set_pressed_texture(get_theme_icon(SNAME("MaterialPreviewLight2Off"), SNAME("EditorIcons"))); - sphere_switch->set_normal_texture(get_theme_icon("MaterialPreviewSphereOff", "EditorIcons")); - sphere_switch->set_pressed_texture(get_theme_icon("MaterialPreviewSphere", "EditorIcons")); - box_switch->set_normal_texture(get_theme_icon("MaterialPreviewCubeOff", "EditorIcons")); - box_switch->set_pressed_texture(get_theme_icon("MaterialPreviewCube", "EditorIcons")); + sphere_switch->set_normal_texture(get_theme_icon(SNAME("MaterialPreviewSphereOff"), SNAME("EditorIcons"))); + sphere_switch->set_pressed_texture(get_theme_icon(SNAME("MaterialPreviewSphere"), SNAME("EditorIcons"))); + box_switch->set_normal_texture(get_theme_icon(SNAME("MaterialPreviewCubeOff"), SNAME("EditorIcons"))); + box_switch->set_pressed_texture(get_theme_icon(SNAME("MaterialPreviewCube"), SNAME("EditorIcons"))); first_enter = false; } } if (p_what == NOTIFICATION_DRAW) { - Ref<Texture2D> checkerboard = get_theme_icon("Checkerboard", "EditorIcons"); + Ref<Texture2D> checkerboard = get_theme_icon(SNAME("Checkerboard"), SNAME("EditorIcons")); Size2 size = get_size(); draw_texture_rect(checkerboard, Rect2(Point2(), size), true); @@ -265,15 +265,15 @@ Ref<Resource> StandardMaterial3DConversionPlugin::convert(const Ref<Resource> &p List<PropertyInfo> params; RS::get_singleton()->shader_get_param_list(mat->get_shader_rid(), ¶ms); - for (List<PropertyInfo>::Element *E = params.front(); E; E = E->next()) { + for (const PropertyInfo &E : params) { // Texture parameter has to be treated specially since StandardMaterial3D saved it // as RID but ShaderMaterial needs Texture itself - Ref<Texture2D> texture = mat->get_texture_by_name(E->get().name); + Ref<Texture2D> texture = mat->get_texture_by_name(E.name); if (texture.is_valid()) { - smat->set_shader_param(E->get().name, texture); + smat->set_shader_param(E.name, texture); } else { - Variant value = RS::get_singleton()->material_get_param(mat->get_rid(), E->get().name); - smat->set_shader_param(E->get().name, value); + Variant value = RS::get_singleton()->material_get_param(mat->get_rid(), E.name); + smat->set_shader_param(E.name, value); } } @@ -309,9 +309,9 @@ Ref<Resource> ParticlesMaterialConversionPlugin::convert(const Ref<Resource> &p_ List<PropertyInfo> params; RS::get_singleton()->shader_get_param_list(mat->get_shader_rid(), ¶ms); - for (List<PropertyInfo>::Element *E = params.front(); E; E = E->next()) { - Variant value = RS::get_singleton()->material_get_param(mat->get_rid(), E->get().name); - smat->set_shader_param(E->get().name, value); + for (const PropertyInfo &E : params) { + Variant value = RS::get_singleton()->material_get_param(mat->get_rid(), E.name); + smat->set_shader_param(E.name, value); } smat->set_render_priority(mat->get_render_priority()); @@ -346,9 +346,9 @@ Ref<Resource> CanvasItemMaterialConversionPlugin::convert(const Ref<Resource> &p List<PropertyInfo> params; RS::get_singleton()->shader_get_param_list(mat->get_shader_rid(), ¶ms); - for (List<PropertyInfo>::Element *E = params.front(); E; E = E->next()) { - Variant value = RS::get_singleton()->material_get_param(mat->get_rid(), E->get().name); - smat->set_shader_param(E->get().name, value); + for (const PropertyInfo &E : params) { + Variant value = RS::get_singleton()->material_get_param(mat->get_rid(), E.name); + smat->set_shader_param(E.name, value); } smat->set_render_priority(mat->get_render_priority()); @@ -383,9 +383,9 @@ Ref<Resource> ProceduralSkyMaterialConversionPlugin::convert(const Ref<Resource> List<PropertyInfo> params; RS::get_singleton()->shader_get_param_list(mat->get_shader_rid(), ¶ms); - for (List<PropertyInfo>::Element *E = params.front(); E; E = E->next()) { - Variant value = RS::get_singleton()->material_get_param(mat->get_rid(), E->get().name); - smat->set_shader_param(E->get().name, value); + for (const PropertyInfo &E : params) { + Variant value = RS::get_singleton()->material_get_param(mat->get_rid(), E.name); + smat->set_shader_param(E.name, value); } smat->set_render_priority(mat->get_render_priority()); @@ -420,9 +420,9 @@ Ref<Resource> PanoramaSkyMaterialConversionPlugin::convert(const Ref<Resource> & List<PropertyInfo> params; RS::get_singleton()->shader_get_param_list(mat->get_shader_rid(), ¶ms); - for (List<PropertyInfo>::Element *E = params.front(); E; E = E->next()) { - Variant value = RS::get_singleton()->material_get_param(mat->get_rid(), E->get().name); - smat->set_shader_param(E->get().name, value); + for (const PropertyInfo &E : params) { + Variant value = RS::get_singleton()->material_get_param(mat->get_rid(), E.name); + smat->set_shader_param(E.name, value); } smat->set_render_priority(mat->get_render_priority()); @@ -457,9 +457,9 @@ Ref<Resource> PhysicalSkyMaterialConversionPlugin::convert(const Ref<Resource> & List<PropertyInfo> params; RS::get_singleton()->shader_get_param_list(mat->get_shader_rid(), ¶ms); - for (List<PropertyInfo>::Element *E = params.front(); E; E = E->next()) { - Variant value = RS::get_singleton()->material_get_param(mat->get_rid(), E->get().name); - smat->set_shader_param(E->get().name, value); + for (const PropertyInfo &E : params) { + Variant value = RS::get_singleton()->material_get_param(mat->get_rid(), E.name); + smat->set_shader_param(E.name, value); } smat->set_render_priority(mat->get_render_priority()); diff --git a/editor/plugins/mesh_editor_plugin.cpp b/editor/plugins/mesh_editor_plugin.cpp index fcc6b84efb..39ab3215ff 100644 --- a/editor/plugins/mesh_editor_plugin.cpp +++ b/editor/plugins/mesh_editor_plugin.cpp @@ -55,10 +55,10 @@ void MeshEditor::_notification(int p_what) { if (first_enter) { //it's in propertyeditor so. could be moved around - light_1_switch->set_normal_texture(get_theme_icon("MaterialPreviewLight1", "EditorIcons")); - light_1_switch->set_pressed_texture(get_theme_icon("MaterialPreviewLight1Off", "EditorIcons")); - light_2_switch->set_normal_texture(get_theme_icon("MaterialPreviewLight2", "EditorIcons")); - light_2_switch->set_pressed_texture(get_theme_icon("MaterialPreviewLight2Off", "EditorIcons")); + light_1_switch->set_normal_texture(get_theme_icon(SNAME("MaterialPreviewLight1"), SNAME("EditorIcons"))); + light_1_switch->set_pressed_texture(get_theme_icon(SNAME("MaterialPreviewLight1Off"), SNAME("EditorIcons"))); + light_2_switch->set_normal_texture(get_theme_icon(SNAME("MaterialPreviewLight2"), SNAME("EditorIcons"))); + light_2_switch->set_pressed_texture(get_theme_icon(SNAME("MaterialPreviewLight2Off"), SNAME("EditorIcons"))); first_enter = false; } } diff --git a/editor/plugins/mesh_instance_3d_editor_plugin.cpp b/editor/plugins/mesh_instance_3d_editor_plugin.cpp index 7434accc1a..9a2b222f21 100644 --- a/editor/plugins/mesh_instance_3d_editor_plugin.cpp +++ b/editor/plugins/mesh_instance_3d_editor_plugin.cpp @@ -90,8 +90,8 @@ void MeshInstance3DEditor::_menu_option(int p_option) { ur->create_action(TTR("Create Static Trimesh Body")); - for (List<Node *>::Element *E = selection.front(); E; E = E->next()) { - MeshInstance3D *instance = Object::cast_to<MeshInstance3D>(E->get()); + for (Node *E : selection) { + MeshInstance3D *instance = Object::cast_to<MeshInstance3D>(E); if (!instance) { continue; } @@ -332,7 +332,7 @@ void MeshInstance3DEditor::_create_uv_lines(int p_layer) { Vector<Vector2> uv = a[p_layer == 0 ? Mesh::ARRAY_TEX_UV : Mesh::ARRAY_TEX_UV2]; if (uv.size() == 0) { - err_dialog->set_text(TTR("Model has no UV in this layer")); + err_dialog->set_text(vformat(TTR("Mesh has no UV in layer %d."), p_layer + 1)); err_dialog->popup_centered(); return; } @@ -382,9 +382,10 @@ void MeshInstance3DEditor::_debug_uv_draw() { } debug_uv->set_clip_contents(true); - debug_uv->draw_rect(Rect2(Vector2(), debug_uv->get_size()), Color(0.2, 0.2, 0.0)); + debug_uv->draw_rect(Rect2(Vector2(), debug_uv->get_size()), get_theme_color(SNAME("dark_color_3"), SNAME("Editor"))); debug_uv->draw_set_transform(Vector2(), 0, debug_uv->get_size()); - debug_uv->draw_multiline(uv_lines, Color(1.0, 0.8, 0.7)); + // Use a translucent color to allow overlapping triangles to be visible. + debug_uv->draw_multiline(uv_lines, get_theme_color(SNAME("mono_color"), SNAME("Editor")) * Color(1, 1, 1, 0.5), Math::round(EDSCALE)); } void MeshInstance3DEditor::_create_outline_mesh() { @@ -441,7 +442,7 @@ MeshInstance3DEditor::MeshInstance3DEditor() { Node3DEditor::get_singleton()->add_control_to_menu_panel(options); options->set_text(TTR("Mesh")); - options->set_icon(EditorNode::get_singleton()->get_gui_base()->get_theme_icon("MeshInstance3D", "EditorIcons")); + options->set_icon(EditorNode::get_singleton()->get_gui_base()->get_theme_icon(SNAME("MeshInstance3D"), SNAME("EditorIcons"))); options->get_popup()->add_item(TTR("Create Trimesh Static Body"), MENU_OPTION_CREATE_STATIC_TRIMESH_BODY); options->get_popup()->set_item_tooltip(options->get_popup()->get_item_count() - 1, TTR("Creates a StaticBody3D and assigns a polygon-based collision shape to it automatically.\nThis is the most accurate (but slowest) option for collision detection.")); diff --git a/editor/plugins/mesh_library_editor_plugin.cpp b/editor/plugins/mesh_library_editor_plugin.cpp index 5d1d29cbc8..b3f92c9d95 100644 --- a/editor/plugins/mesh_library_editor_plugin.cpp +++ b/editor/plugins/mesh_library_editor_plugin.cpp @@ -122,23 +122,23 @@ void MeshLibraryEditor::_import_scene(Node *p_scene, Ref<MeshLibrary> p_library, List<uint32_t> shapes; sb->get_shape_owners(&shapes); - for (List<uint32_t>::Element *E = shapes.front(); E; E = E->next()) { - if (sb->is_shape_owner_disabled(E->get())) { + for (uint32_t &E : shapes) { + if (sb->is_shape_owner_disabled(E)) { continue; } - //Transform3D shape_transform = sb->shape_owner_get_transform(E->get()); + //Transform3D shape_transform = sb->shape_owner_get_transform(E); //shape_transform.set_origin(shape_transform.get_origin() - phys_offset); - for (int k = 0; k < sb->shape_owner_get_shape_count(E->get()); k++) { - Ref<Shape3D> collision = sb->shape_owner_get_shape(E->get(), k); + for (int k = 0; k < sb->shape_owner_get_shape_count(E); k++) { + Ref<Shape3D> collision = sb->shape_owner_get_shape(E, k); if (!collision.is_valid()) { continue; } MeshLibrary::ShapeData shape_data; shape_data.shape = collision; - shape_data.local_transform = sb->get_transform() * sb->shape_owner_get_transform(E->get()); + shape_data.local_transform = sb->get_transform() * sb->shape_owner_get_transform(E); collisions.push_back(shape_data); } } @@ -254,7 +254,7 @@ MeshLibraryEditor::MeshLibraryEditor(EditorNode *p_editor) { Node3DEditor::get_singleton()->add_control_to_menu_panel(menu); menu->set_position(Point2(1, 1)); menu->set_text(TTR("Mesh Library")); - menu->set_icon(EditorNode::get_singleton()->get_gui_base()->get_theme_icon("MeshLibrary", "EditorIcons")); + menu->set_icon(EditorNode::get_singleton()->get_gui_base()->get_theme_icon(SNAME("MeshLibrary"), SNAME("EditorIcons"))); menu->get_popup()->add_item(TTR("Add Item"), MENU_OPTION_ADD_ITEM); menu->get_popup()->add_item(TTR("Remove Selected Item"), MENU_OPTION_REMOVE_ITEM); menu->get_popup()->add_separator(); diff --git a/editor/plugins/multimesh_editor_plugin.cpp b/editor/plugins/multimesh_editor_plugin.cpp index 48b885930f..5514bccabb 100644 --- a/editor/plugins/multimesh_editor_plugin.cpp +++ b/editor/plugins/multimesh_editor_plugin.cpp @@ -268,7 +268,7 @@ MultiMeshEditor::MultiMeshEditor() { Node3DEditor::get_singleton()->add_control_to_menu_panel(options); options->set_text("MultiMesh"); - options->set_icon(EditorNode::get_singleton()->get_gui_base()->get_theme_icon("MultiMeshInstance3D", "EditorIcons")); + options->set_icon(EditorNode::get_singleton()->get_gui_base()->get_theme_icon(SNAME("MultiMeshInstance3D"), SNAME("EditorIcons"))); options->get_popup()->add_item(TTR("Populate Surface")); options->get_popup()->connect("id_pressed", callable_mp(this, &MultiMeshEditor::_menu_option)); diff --git a/editor/node_3d_editor_gizmos.cpp b/editor/plugins/node_3d_editor_gizmos.cpp index 2a399f4b03..2138f943da 100644 --- a/editor/node_3d_editor_gizmos.cpp +++ b/editor/plugins/node_3d_editor_gizmos.cpp @@ -33,7 +33,9 @@ #include "core/math/convex_hull.h" #include "core/math/geometry_2d.h" #include "core/math/geometry_3d.h" +#include "editor/plugins/node_3d_editor_plugin.h" #include "scene/3d/audio_stream_player_3d.h" +#include "scene/3d/camera_3d.h" #include "scene/3d/collision_polygon_3d.h" #include "scene/3d/collision_shape_3d.h" #include "scene/3d/cpu_particles_3d.h" @@ -106,58 +108,122 @@ void EditorNode3DGizmo::clear() { void EditorNode3DGizmo::redraw() { if (get_script_instance() && get_script_instance()->has_method("_redraw")) { get_script_instance()->call("_redraw"); - return; + } else { + ERR_FAIL_COND(!gizmo_plugin); + gizmo_plugin->redraw(this); } - ERR_FAIL_COND(!gizmo_plugin); - gizmo_plugin->redraw(this); + if (Node3DEditor::get_singleton()->is_current_selected_gizmo(this)) { + Node3DEditor::get_singleton()->update_transform_gizmo(); + } } -String EditorNode3DGizmo::get_handle_name(int p_idx) const { +String EditorNode3DGizmo::get_handle_name(int p_id) const { if (get_script_instance() && get_script_instance()->has_method("_get_handle_name")) { - return get_script_instance()->call("_get_handle_name", p_idx); + return get_script_instance()->call("_get_handle_name", p_id); } ERR_FAIL_COND_V(!gizmo_plugin, ""); - return gizmo_plugin->get_handle_name(this, p_idx); + return gizmo_plugin->get_handle_name(this, p_id); } -bool EditorNode3DGizmo::is_handle_highlighted(int p_idx) const { +bool EditorNode3DGizmo::is_handle_highlighted(int p_id) const { if (get_script_instance() && get_script_instance()->has_method("_is_handle_highlighted")) { - return get_script_instance()->call("_is_handle_highlighted", p_idx); + return get_script_instance()->call("_is_handle_highlighted", p_id); } ERR_FAIL_COND_V(!gizmo_plugin, false); - return gizmo_plugin->is_handle_highlighted(this, p_idx); + return gizmo_plugin->is_handle_highlighted(this, p_id); } -Variant EditorNode3DGizmo::get_handle_value(int p_idx) { +Variant EditorNode3DGizmo::get_handle_value(int p_id) const { if (get_script_instance() && get_script_instance()->has_method("_get_handle_value")) { - return get_script_instance()->call("_get_handle_value", p_idx); + return get_script_instance()->call("_get_handle_value", p_id); } ERR_FAIL_COND_V(!gizmo_plugin, Variant()); - return gizmo_plugin->get_handle_value(this, p_idx); + return gizmo_plugin->get_handle_value(this, p_id); } -void EditorNode3DGizmo::set_handle(int p_idx, Camera3D *p_camera, const Point2 &p_point) { +void EditorNode3DGizmo::set_handle(int p_id, Camera3D *p_camera, const Point2 &p_point) const { if (get_script_instance() && get_script_instance()->has_method("_set_handle")) { - get_script_instance()->call("_set_handle", p_idx, p_camera, p_point); + get_script_instance()->call("_set_handle", p_id, p_camera, p_point); return; } ERR_FAIL_COND(!gizmo_plugin); - gizmo_plugin->set_handle(this, p_idx, p_camera, p_point); + gizmo_plugin->set_handle(this, p_id, p_camera, p_point); } -void EditorNode3DGizmo::commit_handle(int p_idx, const Variant &p_restore, bool p_cancel) { +void EditorNode3DGizmo::commit_handle(int p_id, const Variant &p_restore, bool p_cancel) const { if (get_script_instance() && get_script_instance()->has_method("_commit_handle")) { - get_script_instance()->call("_commit_handle", p_idx, p_restore, p_cancel); + get_script_instance()->call("_commit_handle", p_id, p_restore, p_cancel); + return; + } + + ERR_FAIL_COND(!gizmo_plugin); + gizmo_plugin->commit_handle(this, p_id, p_restore, p_cancel); +} + +int EditorNode3DGizmo::subgizmos_intersect_ray(Camera3D *p_camera, const Vector2 &p_point) const { + if (get_script_instance() && get_script_instance()->has_method("_subgizmos_intersect_ray")) { + return get_script_instance()->call("_subgizmos_intersect_ray", p_camera, p_point); + } + + ERR_FAIL_COND_V(!gizmo_plugin, -1); + return gizmo_plugin->subgizmos_intersect_ray(this, p_camera, p_point); +} + +Vector<int> EditorNode3DGizmo::subgizmos_intersect_frustum(const Camera3D *p_camera, const Vector<Plane> &p_frustum) const { + if (get_script_instance() && get_script_instance()->has_method("_subgizmos_intersect_frustum")) { + Array frustum; + for (int i = 0; i < p_frustum.size(); i++) { + frustum[i] = p_frustum[i]; + } + return get_script_instance()->call("_subgizmos_intersect_frustum", p_camera, frustum); + } + + ERR_FAIL_COND_V(!gizmo_plugin, Vector<int>()); + return gizmo_plugin->subgizmos_intersect_frustum(this, p_camera, p_frustum); +} + +Transform3D EditorNode3DGizmo::get_subgizmo_transform(int p_id) const { + if (get_script_instance() && get_script_instance()->has_method("_get_subgizmo_transform")) { + return get_script_instance()->call("_get_subgizmo_transform", p_id); + } + + ERR_FAIL_COND_V(!gizmo_plugin, Transform3D()); + return gizmo_plugin->get_subgizmo_transform(this, p_id); +} + +void EditorNode3DGizmo::set_subgizmo_transform(int p_id, Transform3D p_transform) const { + if (get_script_instance() && get_script_instance()->has_method("_set_subgizmo_transform")) { + get_script_instance()->call("_set_subgizmo_transform", p_id, p_transform); return; } ERR_FAIL_COND(!gizmo_plugin); - gizmo_plugin->commit_handle(this, p_idx, p_restore, p_cancel); + gizmo_plugin->set_subgizmo_transform(this, p_id, p_transform); +} + +void EditorNode3DGizmo::commit_subgizmos(const Vector<int> &p_ids, const Vector<Transform3D> &p_restore, bool p_cancel) const { + if (get_script_instance() && get_script_instance()->has_method("_commit_subgizmos")) { + Array ids; + for (int i = 0; i < p_ids.size(); i++) { + ids[i] = p_ids[i]; + } + + Array restore; + for (int i = 0; i < p_restore.size(); i++) { + restore[i] = p_restore[i]; + } + + get_script_instance()->call("_commit_subgizmos", ids, restore, p_cancel); + return; + } + + ERR_FAIL_COND(!gizmo_plugin); + gizmo_plugin->commit_subgizmos(this, p_ids, p_restore, p_cancel); } void EditorNode3DGizmo::set_spatial_node(Node3D *p_node) { @@ -180,17 +246,17 @@ void EditorNode3DGizmo::Instance::create_instance(Node3D *p_base, bool p_hidden) RS::get_singleton()->instance_geometry_set_flag(instance, RS::INSTANCE_FLAG_IGNORE_OCCLUSION_CULLING, true); } -void EditorNode3DGizmo::add_mesh(const Ref<ArrayMesh> &p_mesh, bool p_billboard, const Ref<SkinReference> &p_skin_reference, const Ref<Material> &p_material) { +void EditorNode3DGizmo::add_mesh(const Ref<ArrayMesh> &p_mesh, const Ref<Material> &p_material, const Transform3D &p_xform, const Ref<SkinReference> &p_skin_reference) { ERR_FAIL_COND(!spatial_node); Instance ins; - ins.billboard = p_billboard; ins.mesh = p_mesh; ins.skin_reference = p_skin_reference; ins.material = p_material; + ins.xform = p_xform; if (valid) { ins.create_instance(spatial_node, hidden); - RS::get_singleton()->instance_set_transform(ins.instance, spatial_node->get_global_transform()); + RS::get_singleton()->instance_set_transform(ins.instance, spatial_node->get_global_transform() * ins.xform); if (ins.material.is_valid()) { RS::get_singleton()->instance_geometry_set_material_override(ins.instance, p_material->get_rid()); } @@ -245,7 +311,6 @@ void EditorNode3DGizmo::add_vertices(const Vector<Vector3> &p_vertices, const Re } } - ins.billboard = p_billboard; ins.mesh = mesh; if (valid) { ins.create_instance(spatial_node, hidden); @@ -307,8 +372,6 @@ void EditorNode3DGizmo::add_unscaled_billboard(const Ref<Material> &p_material, mesh->set_custom_aabb(AABB(Vector3(-selectable_icon_size, -selectable_icon_size, -selectable_icon_size) * 100.0f, Vector3(selectable_icon_size, selectable_icon_size, selectable_icon_size) * 200.0f)); ins.mesh = mesh; - ins.unscaled = true; - ins.billboard = true; if (valid) { ins.create_instance(spatial_node, hidden); RS::get_singleton()->instance_set_transform(ins.instance, spatial_node->get_global_transform()); @@ -331,7 +394,7 @@ void EditorNode3DGizmo::add_collision_segments(const Vector<Vector3> &p_lines) { } } -void EditorNode3DGizmo::add_handles(const Vector<Vector3> &p_handles, const Ref<Material> &p_material, bool p_billboard, bool p_secondary) { +void EditorNode3DGizmo::add_handles(const Vector<Vector3> &p_handles, const Ref<Material> &p_material, const Vector<int> &p_ids, bool p_billboard, bool p_secondary) { billboard_handle = p_billboard; if (!is_selected() || !is_editable()) { @@ -340,8 +403,16 @@ void EditorNode3DGizmo::add_handles(const Vector<Vector3> &p_handles, const Ref< ERR_FAIL_COND(!spatial_node); - Instance ins; + if (p_ids.is_empty()) { + ERR_FAIL_COND_MSG((!handles.is_empty() && !handle_ids.is_empty()) || (!secondary_handles.is_empty() && !secondary_handle_ids.is_empty()), "Fail"); + } else { + ERR_FAIL_COND_MSG(handles.size() != handle_ids.size() || secondary_handles.size() != secondary_handle_ids.size(), "Fail"); + } + bool is_current_hover_gizmo = Node3DEditor::get_singleton()->get_current_hover_gizmo() == this; + int current_hover_handle = Node3DEditor::get_singleton()->get_current_hover_gizmo_handle(); + + Instance ins; Ref<ArrayMesh> mesh = memnew(ArrayMesh); Array a; @@ -357,7 +428,8 @@ void EditorNode3DGizmo::add_handles(const Vector<Vector3> &p_handles, const Ref< col = Color(0, 0, 1, 0.9); } - if (Node3DEditor::get_singleton()->get_over_gizmo_handle() != i) { + int id = p_ids.is_empty() ? i : p_ids[i]; + if (!is_current_hover_gizmo || current_hover_handle != id) { col.a = 0.8; } @@ -379,29 +451,31 @@ void EditorNode3DGizmo::add_handles(const Vector<Vector3> &p_handles, const Ref< } ins.mesh = mesh; - ins.billboard = p_billboard; ins.extra_margin = true; if (valid) { ins.create_instance(spatial_node, hidden); RS::get_singleton()->instance_set_transform(ins.instance, spatial_node->get_global_transform()); } instances.push_back(ins); - if (!p_secondary) { - int chs = handles.size(); - handles.resize(chs + p_handles.size()); - for (int i = 0; i < p_handles.size(); i++) { - handles.write[i + chs] = p_handles[i]; - } - } else { - int chs = secondary_handles.size(); - secondary_handles.resize(chs + p_handles.size()); - for (int i = 0; i < p_handles.size(); i++) { - secondary_handles.write[i + chs] = p_handles[i]; + + Vector<Vector3> &h = p_secondary ? secondary_handles : handles; + int current_size = h.size(); + h.resize(current_size + p_handles.size()); + for (int i = 0; i < p_handles.size(); i++) { + h.write[current_size + i] = p_handles[i]; + } + + if (!p_ids.is_empty()) { + Vector<int> &ids = p_secondary ? secondary_handle_ids : handle_ids; + current_size = ids.size(); + ids.resize(current_size + p_ids.size()); + for (int i = 0; i < p_ids.size(); i++) { + ids.write[current_size + i] = p_ids[i]; } } } -void EditorNode3DGizmo::add_solid_box(Ref<Material> &p_material, Vector3 p_size, Vector3 p_position) { +void EditorNode3DGizmo::add_solid_box(Ref<Material> &p_material, Vector3 p_size, Vector3 p_position, const Transform3D &p_xform) { ERR_FAIL_COND(!spatial_node); BoxMesh box_mesh; @@ -419,8 +493,7 @@ void EditorNode3DGizmo::add_solid_box(Ref<Material> &p_material, Vector3 p_size, Ref<ArrayMesh> m = memnew(ArrayMesh); m->add_surface_from_arrays(box_mesh.surface_get_primitive_type(0), arrays); - m->surface_set_material(0, p_material); - add_mesh(m); + add_mesh(m, p_material, p_xform); } bool EditorNode3DGizmo::intersect_frustum(const Camera3D *p_camera, const Vector<Plane> &p_frustum) { @@ -485,13 +558,15 @@ bool EditorNode3DGizmo::intersect_frustum(const Camera3D *p_camera, const Vector Transform3D it = t.affine_inverse(); Vector<Plane> transformed_frustum; + int plane_count = p_frustum.size(); + transformed_frustum.resize(plane_count); - for (int i = 0; i < p_frustum.size(); i++) { - transformed_frustum.push_back(it.xform(p_frustum[i])); + for (int i = 0; i < plane_count; i++) { + transformed_frustum.write[i] = it.xform(p_frustum[i]); } - Vector<Vector3> convex_points = Geometry3D::compute_convex_mesh_points(p_frustum.ptr(), p_frustum.size()); - if (collision_mesh->inside_convex_shape(transformed_frustum.ptr(), transformed_frustum.size(), convex_points.ptr(), convex_points.size(), mesh_scale)) { + Vector<Vector3> convex_points = Geometry3D::compute_convex_mesh_points(transformed_frustum.ptr(), plane_count); + if (collision_mesh->inside_convex_shape(transformed_frustum.ptr(), plane_count, convex_points.ptr(), convex_points.size(), mesh_scale)) { return true; } } @@ -499,70 +574,77 @@ bool EditorNode3DGizmo::intersect_frustum(const Camera3D *p_camera, const Vector return false; } -bool EditorNode3DGizmo::intersect_ray(Camera3D *p_camera, const Point2 &p_point, Vector3 &r_pos, Vector3 &r_normal, int *r_gizmo_handle, bool p_sec_first) { - ERR_FAIL_COND_V(!spatial_node, false); - ERR_FAIL_COND_V(!valid, false); +void EditorNode3DGizmo::handles_intersect_ray(Camera3D *p_camera, const Vector2 &p_point, bool p_shift_pressed, int &r_id) { + r_id = -1; - if (hidden && !gizmo_plugin->is_selectable_when_hidden()) { - return false; + ERR_FAIL_COND(!spatial_node); + ERR_FAIL_COND(!valid); + + if (hidden) { + return; } - if (r_gizmo_handle && !hidden) { - Transform3D t = spatial_node->get_global_transform(); - if (billboard_handle) { - t.set_look_at(t.origin, t.origin - p_camera->get_transform().basis.get_axis(2), p_camera->get_transform().basis.get_axis(1)); - } + Transform3D camera_xform = p_camera->get_global_transform(); + Transform3D t = spatial_node->get_global_transform(); + if (billboard_handle) { + t.set_look_at(t.origin, t.origin - camera_xform.basis.get_axis(2), camera_xform.basis.get_axis(1)); + } - float min_d = 1e20; - int idx = -1; + float min_d = 1e20; - for (int i = 0; i < secondary_handles.size(); i++) { - Vector3 hpos = t.xform(secondary_handles[i]); - Vector2 p = p_camera->unproject_position(hpos); + for (int i = 0; i < secondary_handles.size(); i++) { + Vector3 hpos = t.xform(secondary_handles[i]); + Vector2 p = p_camera->unproject_position(hpos); - if (p.distance_to(p_point) < HANDLE_HALF_SIZE) { - real_t dp = p_camera->get_transform().origin.distance_to(hpos); - if (dp < min_d) { - r_pos = t.xform(hpos); - r_normal = p_camera->get_transform().basis.get_axis(2); - min_d = dp; - idx = i + handles.size(); + if (p.distance_to(p_point) < HANDLE_HALF_SIZE) { + real_t dp = p_camera->get_transform().origin.distance_to(hpos); + if (dp < min_d) { + min_d = dp; + if (secondary_handle_ids.is_empty()) { + r_id = i; + } else { + r_id = secondary_handle_ids[i]; } } } + } - if (p_sec_first && idx != -1) { - *r_gizmo_handle = idx; - return true; - } + if (r_id != -1 && p_shift_pressed) { + return; + } - min_d = 1e20; + min_d = 1e20; - for (int i = 0; i < handles.size(); i++) { - Vector3 hpos = t.xform(handles[i]); - Vector2 p = p_camera->unproject_position(hpos); + for (int i = 0; i < handles.size(); i++) { + Vector3 hpos = t.xform(handles[i]); + Vector2 p = p_camera->unproject_position(hpos); - if (p.distance_to(p_point) < HANDLE_HALF_SIZE) { - real_t dp = p_camera->get_transform().origin.distance_to(hpos); - if (dp < min_d) { - r_pos = t.xform(hpos); - r_normal = p_camera->get_transform().basis.get_axis(2); - min_d = dp; - idx = i; + if (p.distance_to(p_point) < HANDLE_HALF_SIZE) { + real_t dp = p_camera->get_transform().origin.distance_to(hpos); + if (dp < min_d) { + min_d = dp; + if (handle_ids.is_empty()) { + r_id = i; + } else { + r_id = handle_ids[i]; } } } + } +} - if (idx >= 0) { - *r_gizmo_handle = idx; - return true; - } +bool EditorNode3DGizmo::intersect_ray(Camera3D *p_camera, const Point2 &p_point, Vector3 &r_pos, Vector3 &r_normal) { + ERR_FAIL_COND_V(!spatial_node, false); + ERR_FAIL_COND_V(!valid, false); + + if (hidden && !gizmo_plugin->is_selectable_when_hidden()) { + return false; } if (selectable_icon_size > 0.0f) { Transform3D t = spatial_node->get_global_transform(); Vector3 camera_position = p_camera->get_camera_transform().origin; - if (camera_position.distance_squared_to(t.origin) > 0.01) { + if (!camera_position.is_equal_approx(t.origin)) { t.set_look_at(t.origin, camera_position); } @@ -578,7 +660,7 @@ bool EditorNode3DGizmo::intersect_ray(Camera3D *p_camera, const Point2 &p_point, Transform3D orig_camera_transform = p_camera->get_camera_transform(); - if (orig_camera_transform.origin.distance_squared_to(t.origin) > 0.01 && + if (!orig_camera_transform.origin.is_equal_approx(t.origin) && ABS(orig_camera_transform.basis.get_axis(Vector3::AXIS_Z).dot(Vector3(0, 1, 0))) < 0.99) { p_camera->look_at(t.origin); } @@ -674,6 +756,25 @@ bool EditorNode3DGizmo::intersect_ray(Camera3D *p_camera, const Point2 &p_point, return false; } +bool EditorNode3DGizmo::is_subgizmo_selected(int p_id) const { + Node3DEditor *ed = Node3DEditor::get_singleton(); + ERR_FAIL_COND_V(!ed, false); + return ed->is_current_selected_gizmo(this) && ed->is_subgizmo_selected(p_id); +} + +Vector<int> EditorNode3DGizmo::get_subgizmo_selection() const { + Vector<int> ret; + + Node3DEditor *ed = Node3DEditor::get_singleton(); + ERR_FAIL_COND_V(!ed, ret); + + if (ed->is_current_selected_gizmo(this)) { + ret = ed->get_subgizmo_selection(); + } + + return ret; +} + void EditorNode3DGizmo::create() { ERR_FAIL_COND(!spatial_node); ERR_FAIL_COND(valid); @@ -690,7 +791,7 @@ void EditorNode3DGizmo::transform() { ERR_FAIL_COND(!spatial_node); ERR_FAIL_COND(!valid); for (int i = 0; i < instances.size(); i++) { - RS::get_singleton()->instance_set_transform(instances[i].instance, spatial_node->get_global_transform()); + RS::get_singleton()->instance_set_transform(instances[i].instance, spatial_node->get_global_transform() * instances[i].xform); } } @@ -724,38 +825,46 @@ void EditorNode3DGizmo::set_plugin(EditorNode3DGizmoPlugin *p_plugin) { void EditorNode3DGizmo::_bind_methods() { ClassDB::bind_method(D_METHOD("add_lines", "lines", "material", "billboard", "modulate"), &EditorNode3DGizmo::add_lines, DEFVAL(false), DEFVAL(Color(1, 1, 1))); - ClassDB::bind_method(D_METHOD("add_mesh", "mesh", "billboard", "skeleton", "material"), &EditorNode3DGizmo::add_mesh, DEFVAL(false), DEFVAL(Ref<SkinReference>()), DEFVAL(Variant())); + ClassDB::bind_method(D_METHOD("add_mesh", "mesh", "material", "transform", "skeleton"), &EditorNode3DGizmo::add_mesh, DEFVAL(Variant()), DEFVAL(Transform3D()), DEFVAL(Ref<SkinReference>())); ClassDB::bind_method(D_METHOD("add_collision_segments", "segments"), &EditorNode3DGizmo::add_collision_segments); ClassDB::bind_method(D_METHOD("add_collision_triangles", "triangles"), &EditorNode3DGizmo::add_collision_triangles); ClassDB::bind_method(D_METHOD("add_unscaled_billboard", "material", "default_scale", "modulate"), &EditorNode3DGizmo::add_unscaled_billboard, DEFVAL(1), DEFVAL(Color(1, 1, 1))); - ClassDB::bind_method(D_METHOD("add_handles", "handles", "material", "billboard", "secondary"), &EditorNode3DGizmo::add_handles, DEFVAL(false), DEFVAL(false)); + ClassDB::bind_method(D_METHOD("add_handles", "handles", "material", "ids", "billboard", "secondary"), &EditorNode3DGizmo::add_handles, DEFVAL(false), DEFVAL(false)); ClassDB::bind_method(D_METHOD("set_spatial_node", "node"), &EditorNode3DGizmo::_set_spatial_node); ClassDB::bind_method(D_METHOD("get_spatial_node"), &EditorNode3DGizmo::get_spatial_node); ClassDB::bind_method(D_METHOD("get_plugin"), &EditorNode3DGizmo::get_plugin); ClassDB::bind_method(D_METHOD("clear"), &EditorNode3DGizmo::clear); ClassDB::bind_method(D_METHOD("set_hidden", "hidden"), &EditorNode3DGizmo::set_hidden); + ClassDB::bind_method(D_METHOD("is_subgizmo_selected"), &EditorNode3DGizmo::is_subgizmo_selected); + ClassDB::bind_method(D_METHOD("get_subgizmo_selection"), &EditorNode3DGizmo::get_subgizmo_selection); BIND_VMETHOD(MethodInfo("_redraw")); - BIND_VMETHOD(MethodInfo(Variant::STRING, "_get_handle_name", PropertyInfo(Variant::INT, "index"))); - BIND_VMETHOD(MethodInfo(Variant::BOOL, "_is_handle_highlighted", PropertyInfo(Variant::INT, "index"))); + BIND_VMETHOD(MethodInfo(Variant::STRING, "_get_handle_name", PropertyInfo(Variant::INT, "id"))); + BIND_VMETHOD(MethodInfo(Variant::BOOL, "_is_handle_highlighted", PropertyInfo(Variant::INT, "id"))); - MethodInfo hvget(Variant::NIL, "_get_handle_value", PropertyInfo(Variant::INT, "index")); + MethodInfo hvget(Variant::NIL, "_get_handle_value", PropertyInfo(Variant::INT, "id")); hvget.return_val.usage |= PROPERTY_USAGE_NIL_IS_VARIANT; BIND_VMETHOD(hvget); - BIND_VMETHOD(MethodInfo("_set_handle", PropertyInfo(Variant::INT, "index"), PropertyInfo(Variant::OBJECT, "camera", PROPERTY_HINT_RESOURCE_TYPE, "Camera3D"), PropertyInfo(Variant::VECTOR2, "point"))); - MethodInfo cm = MethodInfo("_commit_handle", PropertyInfo(Variant::INT, "index"), PropertyInfo(Variant::NIL, "restore"), PropertyInfo(Variant::BOOL, "cancel")); + BIND_VMETHOD(MethodInfo("_set_handle", PropertyInfo(Variant::INT, "id"), PropertyInfo(Variant::OBJECT, "camera", PROPERTY_HINT_RESOURCE_TYPE, "Camera3D"), PropertyInfo(Variant::VECTOR2, "point"))); + MethodInfo cm = MethodInfo("_commit_handle", PropertyInfo(Variant::INT, "id"), PropertyInfo(Variant::NIL, "restore"), PropertyInfo(Variant::BOOL, "cancel")); cm.default_arguments.push_back(false); BIND_VMETHOD(cm); + + BIND_VMETHOD(MethodInfo(Variant::INT, "_subgizmos_intersect_ray", PropertyInfo(Variant::OBJECT, "camera", PROPERTY_HINT_RESOURCE_TYPE, "Camera3D"), PropertyInfo(Variant::VECTOR2, "point"))); + BIND_VMETHOD(MethodInfo(Variant::PACKED_INT32_ARRAY, "_subgizmos_intersect_frustum", PropertyInfo(Variant::OBJECT, "camera", PROPERTY_HINT_RESOURCE_TYPE, "Camera3D"), PropertyInfo(Variant::ARRAY, "frustum"))); + BIND_VMETHOD(MethodInfo(Variant::TRANSFORM3D, "_get_subgizmo_transform", PropertyInfo(Variant::INT, "id"))); + BIND_VMETHOD(MethodInfo("_set_subgizmo_transform", PropertyInfo(Variant::INT, "id"), PropertyInfo(Variant::TRANSFORM3D, "transform"))); + MethodInfo cs = MethodInfo("_commit_subgizmos", PropertyInfo(Variant::PACKED_INT32_ARRAY, "ids"), PropertyInfo(Variant::ARRAY, "restore"), PropertyInfo(Variant::BOOL, "cancel")); + cs.default_arguments.push_back(false); + BIND_VMETHOD(cs); } EditorNode3DGizmo::EditorNode3DGizmo() { valid = false; billboard_handle = false; hidden = false; - base = nullptr; selected = false; - instantiated = false; spatial_node = nullptr; gizmo_plugin = nullptr; selectable_icon_size = -1.0f; @@ -768,10 +877,362 @@ EditorNode3DGizmo::~EditorNode3DGizmo() { clear(); } -Vector3 EditorNode3DGizmo::get_handle_pos(int p_idx) const { - ERR_FAIL_INDEX_V(p_idx, handles.size(), Vector3()); +///// + +void EditorNode3DGizmoPlugin::create_material(const String &p_name, const Color &p_color, bool p_billboard, bool p_on_top, bool p_use_vertex_color) { + Color instantiated_color = EDITOR_DEF("editors/3d_gizmos/gizmo_colors/instantiated", Color(0.7, 0.7, 0.7, 0.6)); + + Vector<Ref<StandardMaterial3D>> mats; + + for (int i = 0; i < 4; i++) { + bool selected = i % 2 == 1; + bool instantiated = i < 2; + + Ref<StandardMaterial3D> material = Ref<StandardMaterial3D>(memnew(StandardMaterial3D)); - return handles[p_idx]; + Color color = instantiated ? instantiated_color : p_color; + + if (!selected) { + color.a *= 0.3; + } + + material->set_albedo(color); + material->set_shading_mode(StandardMaterial3D::SHADING_MODE_UNSHADED); + material->set_transparency(StandardMaterial3D::TRANSPARENCY_ALPHA); + material->set_render_priority(StandardMaterial3D::RENDER_PRIORITY_MIN + 1); + material->set_cull_mode(StandardMaterial3D::CULL_DISABLED); + + if (p_use_vertex_color) { + material->set_flag(StandardMaterial3D::FLAG_ALBEDO_FROM_VERTEX_COLOR, true); + material->set_flag(StandardMaterial3D::FLAG_SRGB_VERTEX_COLOR, true); + } + + if (p_billboard) { + material->set_billboard_mode(StandardMaterial3D::BILLBOARD_ENABLED); + } + + if (p_on_top && selected) { + material->set_on_top_of_alpha(); + } + + mats.push_back(material); + } + + materials[p_name] = mats; +} + +void EditorNode3DGizmoPlugin::create_icon_material(const String &p_name, const Ref<Texture2D> &p_texture, bool p_on_top, const Color &p_albedo) { + Color instantiated_color = EDITOR_DEF("editors/3d_gizmos/gizmo_colors/instantiated", Color(0.7, 0.7, 0.7, 0.6)); + + Vector<Ref<StandardMaterial3D>> icons; + + for (int i = 0; i < 4; i++) { + bool selected = i % 2 == 1; + bool instantiated = i < 2; + + Ref<StandardMaterial3D> icon = Ref<StandardMaterial3D>(memnew(StandardMaterial3D)); + + Color color = instantiated ? instantiated_color : p_albedo; + + if (!selected) { + color.a *= 0.85; + } + + icon->set_albedo(color); + + icon->set_shading_mode(StandardMaterial3D::SHADING_MODE_UNSHADED); + icon->set_flag(StandardMaterial3D::FLAG_ALBEDO_FROM_VERTEX_COLOR, true); + icon->set_flag(StandardMaterial3D::FLAG_SRGB_VERTEX_COLOR, true); + icon->set_cull_mode(StandardMaterial3D::CULL_DISABLED); + icon->set_depth_draw_mode(StandardMaterial3D::DEPTH_DRAW_DISABLED); + icon->set_transparency(StandardMaterial3D::TRANSPARENCY_ALPHA); + icon->set_texture(StandardMaterial3D::TEXTURE_ALBEDO, p_texture); + icon->set_flag(StandardMaterial3D::FLAG_FIXED_SIZE, true); + icon->set_billboard_mode(StandardMaterial3D::BILLBOARD_ENABLED); + icon->set_render_priority(StandardMaterial3D::RENDER_PRIORITY_MIN); + + if (p_on_top && selected) { + icon->set_on_top_of_alpha(); + } + + icons.push_back(icon); + } + + materials[p_name] = icons; +} + +void EditorNode3DGizmoPlugin::create_handle_material(const String &p_name, bool p_billboard, const Ref<Texture2D> &p_icon) { + Ref<StandardMaterial3D> handle_material = Ref<StandardMaterial3D>(memnew(StandardMaterial3D)); + + handle_material->set_shading_mode(StandardMaterial3D::SHADING_MODE_UNSHADED); + handle_material->set_flag(StandardMaterial3D::FLAG_USE_POINT_SIZE, true); + Ref<Texture2D> handle_t = p_icon != nullptr ? p_icon : Node3DEditor::get_singleton()->get_theme_icon(SNAME("Editor3DHandle"), SNAME("EditorIcons")); + handle_material->set_point_size(handle_t->get_width()); + handle_material->set_texture(StandardMaterial3D::TEXTURE_ALBEDO, handle_t); + handle_material->set_albedo(Color(1, 1, 1)); + handle_material->set_flag(StandardMaterial3D::FLAG_ALBEDO_FROM_VERTEX_COLOR, true); + handle_material->set_flag(StandardMaterial3D::FLAG_SRGB_VERTEX_COLOR, true); + handle_material->set_on_top_of_alpha(); + if (p_billboard) { + handle_material->set_billboard_mode(StandardMaterial3D::BILLBOARD_ENABLED); + handle_material->set_on_top_of_alpha(); + } + handle_material->set_transparency(StandardMaterial3D::TRANSPARENCY_ALPHA); + + materials[p_name] = Vector<Ref<StandardMaterial3D>>(); + materials[p_name].push_back(handle_material); +} + +void EditorNode3DGizmoPlugin::add_material(const String &p_name, Ref<StandardMaterial3D> p_material) { + materials[p_name] = Vector<Ref<StandardMaterial3D>>(); + materials[p_name].push_back(p_material); +} + +Ref<StandardMaterial3D> EditorNode3DGizmoPlugin::get_material(const String &p_name, const Ref<EditorNode3DGizmo> &p_gizmo) { + ERR_FAIL_COND_V(!materials.has(p_name), Ref<StandardMaterial3D>()); + ERR_FAIL_COND_V(materials[p_name].size() == 0, Ref<StandardMaterial3D>()); + + if (p_gizmo.is_null() || materials[p_name].size() == 1) { + return materials[p_name][0]; + } + + int index = (p_gizmo->is_selected() ? 1 : 0) + (p_gizmo->is_editable() ? 2 : 0); + + Ref<StandardMaterial3D> mat = materials[p_name][index]; + + if (current_state == ON_TOP && p_gizmo->is_selected()) { + mat->set_flag(StandardMaterial3D::FLAG_DISABLE_DEPTH_TEST, true); + } else { + mat->set_flag(StandardMaterial3D::FLAG_DISABLE_DEPTH_TEST, false); + } + + return mat; +} + +String EditorNode3DGizmoPlugin::get_gizmo_name() const { + if (get_script_instance() && get_script_instance()->has_method("_get_gizmo_name")) { + return get_script_instance()->call("_get_gizmo_name"); + } + return TTR("Nameless gizmo"); +} + +int EditorNode3DGizmoPlugin::get_priority() const { + if (get_script_instance() && get_script_instance()->has_method("_get_priority")) { + return get_script_instance()->call("_get_priority"); + } + return 0; +} + +Ref<EditorNode3DGizmo> EditorNode3DGizmoPlugin::get_gizmo(Node3D *p_spatial) { + if (get_script_instance() && get_script_instance()->has_method("_get_gizmo")) { + return get_script_instance()->call("_get_gizmo", p_spatial); + } + + Ref<EditorNode3DGizmo> ref = create_gizmo(p_spatial); + + if (ref.is_null()) { + return ref; + } + + ref->set_plugin(this); + ref->set_spatial_node(p_spatial); + ref->set_hidden(current_state == HIDDEN); + + current_gizmos.push_back(ref.ptr()); + return ref; +} + +void EditorNode3DGizmoPlugin::_bind_methods() { +#define GIZMO_REF PropertyInfo(Variant::OBJECT, "gizmo", PROPERTY_HINT_RESOURCE_TYPE, "EditorNode3DGizmo") + + BIND_VMETHOD(MethodInfo(Variant::BOOL, "_has_gizmo", PropertyInfo(Variant::OBJECT, "spatial", PROPERTY_HINT_RESOURCE_TYPE, "Node3D"))); + BIND_VMETHOD(MethodInfo(GIZMO_REF, "_create_gizmo", PropertyInfo(Variant::OBJECT, "spatial", PROPERTY_HINT_RESOURCE_TYPE, "Node3D"))); + + ClassDB::bind_method(D_METHOD("create_material", "name", "color", "billboard", "on_top", "use_vertex_color"), &EditorNode3DGizmoPlugin::create_material, DEFVAL(false), DEFVAL(false), DEFVAL(false)); + ClassDB::bind_method(D_METHOD("create_icon_material", "name", "texture", "on_top", "color"), &EditorNode3DGizmoPlugin::create_icon_material, DEFVAL(false), DEFVAL(Color(1, 1, 1, 1))); + ClassDB::bind_method(D_METHOD("create_handle_material", "name", "billboard", "texture"), &EditorNode3DGizmoPlugin::create_handle_material, DEFVAL(false), DEFVAL(Variant())); + ClassDB::bind_method(D_METHOD("add_material", "name", "material"), &EditorNode3DGizmoPlugin::add_material); + + ClassDB::bind_method(D_METHOD("get_material", "name", "gizmo"), &EditorNode3DGizmoPlugin::get_material, DEFVAL(Ref<EditorNode3DGizmo>())); + + BIND_VMETHOD(MethodInfo(Variant::STRING, "_get_gizmo_name")); + BIND_VMETHOD(MethodInfo(Variant::INT, "_get_priority")); + BIND_VMETHOD(MethodInfo(Variant::BOOL, "_can_be_hidden")); + BIND_VMETHOD(MethodInfo(Variant::BOOL, "_is_selectable_when_hidden")); + + BIND_VMETHOD(MethodInfo("_redraw", GIZMO_REF)); + BIND_VMETHOD(MethodInfo(Variant::STRING, "_get_handle_name", GIZMO_REF, PropertyInfo(Variant::INT, "id"))); + BIND_VMETHOD(MethodInfo(Variant::BOOL, "_is_handle_highlighted", GIZMO_REF, PropertyInfo(Variant::INT, "id"))); + + MethodInfo hvget(Variant::NIL, "_get_handle_value", GIZMO_REF, PropertyInfo(Variant::INT, "id")); + hvget.return_val.usage |= PROPERTY_USAGE_NIL_IS_VARIANT; + BIND_VMETHOD(hvget); + + BIND_VMETHOD(MethodInfo("_set_handle", GIZMO_REF, PropertyInfo(Variant::INT, "id"), PropertyInfo(Variant::OBJECT, "camera", PROPERTY_HINT_RESOURCE_TYPE, "Camera3D"), PropertyInfo(Variant::VECTOR2, "point"))); + MethodInfo cm = MethodInfo("_commit_handle", GIZMO_REF, PropertyInfo(Variant::INT, "id"), PropertyInfo(Variant::NIL, "restore"), PropertyInfo(Variant::BOOL, "cancel")); + cm.default_arguments.push_back(false); + BIND_VMETHOD(cm); + + BIND_VMETHOD(MethodInfo(Variant::INT, "_subgizmos_intersect_ray", GIZMO_REF, PropertyInfo(Variant::OBJECT, "camera", PROPERTY_HINT_RESOURCE_TYPE, "Camera3D"), PropertyInfo(Variant::VECTOR2, "point"))); + BIND_VMETHOD(MethodInfo(Variant::PACKED_INT32_ARRAY, "_subgizmos_intersect_frustum", GIZMO_REF, PropertyInfo(Variant::OBJECT, "camera", PROPERTY_HINT_RESOURCE_TYPE, "Camera3D"), PropertyInfo(Variant::ARRAY, "frustum"))); + BIND_VMETHOD(MethodInfo(Variant::TRANSFORM3D, "_get_subgizmo_transform", GIZMO_REF, PropertyInfo(Variant::INT, "id"))); + BIND_VMETHOD(MethodInfo("_set_subgizmo_transform", GIZMO_REF, PropertyInfo(Variant::INT, "id"), PropertyInfo(Variant::TRANSFORM3D, "transform"))); + MethodInfo cs = MethodInfo("_commit_subgizmos", GIZMO_REF, PropertyInfo(Variant::PACKED_INT32_ARRAY, "ids"), PropertyInfo(Variant::ARRAY, "restore"), PropertyInfo(Variant::BOOL, "cancel")); + cs.default_arguments.push_back(false); + BIND_VMETHOD(cs); + +#undef GIZMO_REF +} + +bool EditorNode3DGizmoPlugin::has_gizmo(Node3D *p_spatial) { + if (get_script_instance() && get_script_instance()->has_method("_has_gizmo")) { + return get_script_instance()->call("_has_gizmo", p_spatial); + } + return false; +} + +Ref<EditorNode3DGizmo> EditorNode3DGizmoPlugin::create_gizmo(Node3D *p_spatial) { + if (get_script_instance() && get_script_instance()->has_method("_create_gizmo")) { + return get_script_instance()->call("_create_gizmo", p_spatial); + } + + Ref<EditorNode3DGizmo> ref; + if (has_gizmo(p_spatial)) { + ref.instantiate(); + } + return ref; +} + +bool EditorNode3DGizmoPlugin::can_be_hidden() const { + if (get_script_instance() && get_script_instance()->has_method("_can_be_hidden")) { + return get_script_instance()->call("_can_be_hidden"); + } + return true; +} + +bool EditorNode3DGizmoPlugin::is_selectable_when_hidden() const { + if (get_script_instance() && get_script_instance()->has_method("_is_selectable_when_hidden")) { + return get_script_instance()->call("_is_selectable_when_hidden"); + } + return false; +} + +void EditorNode3DGizmoPlugin::redraw(EditorNode3DGizmo *p_gizmo) { + if (get_script_instance() && get_script_instance()->has_method("_redraw")) { + Ref<EditorNode3DGizmo> ref(p_gizmo); + get_script_instance()->call("_redraw", ref); + } +} + +bool EditorNode3DGizmoPlugin::is_handle_highlighted(const EditorNode3DGizmo *p_gizmo, int p_id) const { + if (get_script_instance() && get_script_instance()->has_method("_is_handle_highlighted")) { + return get_script_instance()->call("_is_handle_highlighted", p_gizmo, p_id); + } + return false; +} + +String EditorNode3DGizmoPlugin::get_handle_name(const EditorNode3DGizmo *p_gizmo, int p_id) const { + if (get_script_instance() && get_script_instance()->has_method("_get_handle_name")) { + return get_script_instance()->call("_get_handle_name", p_gizmo, p_id); + } + return ""; +} + +Variant EditorNode3DGizmoPlugin::get_handle_value(const EditorNode3DGizmo *p_gizmo, int p_id) const { + if (get_script_instance() && get_script_instance()->has_method("_get_handle_value")) { + return get_script_instance()->call("_get_handle_value", p_gizmo, p_id); + } + return Variant(); +} + +void EditorNode3DGizmoPlugin::set_handle(const EditorNode3DGizmo *p_gizmo, int p_id, Camera3D *p_camera, const Point2 &p_point) const { + if (get_script_instance() && get_script_instance()->has_method("_set_handle")) { + get_script_instance()->call("_set_handle", p_gizmo, p_id, p_camera, p_point); + } +} + +void EditorNode3DGizmoPlugin::commit_handle(const EditorNode3DGizmo *p_gizmo, int p_id, const Variant &p_restore, bool p_cancel) const { + if (get_script_instance() && get_script_instance()->has_method("_commit_handle")) { + get_script_instance()->call("_commit_handle", p_gizmo, p_id, p_restore, p_cancel); + } +} + +int EditorNode3DGizmoPlugin::subgizmos_intersect_ray(const EditorNode3DGizmo *p_gizmo, Camera3D *p_camera, const Vector2 &p_point) const { + if (get_script_instance() && get_script_instance()->has_method("_subgizmos_intersect_ray")) { + return get_script_instance()->call("_subgizmos_intersect_ray", p_camera, p_point); + } + return -1; +} + +Vector<int> EditorNode3DGizmoPlugin::subgizmos_intersect_frustum(const EditorNode3DGizmo *p_gizmo, const Camera3D *p_camera, const Vector<Plane> &p_frustum) const { + if (get_script_instance() && get_script_instance()->has_method("_subgizmos_intersect_frustum")) { + Array frustum; + for (int i = 0; i < p_frustum.size(); i++) { + frustum[i] = p_frustum[i]; + } + return get_script_instance()->call("_subgizmos_intersect_frustum", p_camera, frustum); + } + + return Vector<int>(); +} + +Transform3D EditorNode3DGizmoPlugin::get_subgizmo_transform(const EditorNode3DGizmo *p_gizmo, int p_id) const { + if (get_script_instance() && get_script_instance()->has_method("_get_subgizmo_transform")) { + return get_script_instance()->call("_get_subgizmo_transform", p_id); + } + + return Transform3D(); +} + +void EditorNode3DGizmoPlugin::set_subgizmo_transform(const EditorNode3DGizmo *p_gizmo, int p_id, Transform3D p_transform) const { + if (get_script_instance() && get_script_instance()->has_method("_set_subgizmo_transform")) { + get_script_instance()->call("_set_subgizmo_transform", p_id, p_transform); + } +} + +void EditorNode3DGizmoPlugin::commit_subgizmos(const EditorNode3DGizmo *p_gizmo, const Vector<int> &p_ids, const Vector<Transform3D> &p_restore, bool p_cancel) const { + if (get_script_instance() && get_script_instance()->has_method("_commit_subgizmos")) { + Array ids; + for (int i = 0; i < p_ids.size(); i++) { + ids[i] = p_ids[i]; + } + + Array restore; + for (int i = 0; i < p_restore.size(); i++) { + restore[i] = p_restore[i]; + } + + get_script_instance()->call("_commit_subgizmos", ids, restore, p_cancel); + } +} + +void EditorNode3DGizmoPlugin::set_state(int p_state) { + current_state = p_state; + for (int i = 0; i < current_gizmos.size(); ++i) { + current_gizmos[i]->set_hidden(current_state == HIDDEN); + } +} + +int EditorNode3DGizmoPlugin::get_state() const { + return current_state; +} + +void EditorNode3DGizmoPlugin::unregister_gizmo(EditorNode3DGizmo *p_gizmo) { + current_gizmos.erase(p_gizmo); +} + +EditorNode3DGizmoPlugin::EditorNode3DGizmoPlugin() { + current_state = VISIBLE; +} + +EditorNode3DGizmoPlugin::~EditorNode3DGizmoPlugin() { + for (int i = 0; i < current_gizmos.size(); ++i) { + current_gizmos[i]->set_plugin(nullptr); + current_gizmos[i]->get_spatial_node()->remove_gizmo(current_gizmos[i]); + } + if (Node3DEditor::get_singleton()) { + Node3DEditor::get_singleton()->update_all_gizmos(); + } } //// light gizmo @@ -782,9 +1243,9 @@ Light3DGizmoPlugin::Light3DGizmoPlugin() { create_material("lines_secondary", Color(1, 1, 1, 0.35), false, false, true); create_material("lines_billboard", Color(1, 1, 1), true, false, true); - create_icon_material("light_directional_icon", Node3DEditor::get_singleton()->get_theme_icon("GizmoDirectionalLight", "EditorIcons")); - create_icon_material("light_omni_icon", Node3DEditor::get_singleton()->get_theme_icon("GizmoLight", "EditorIcons")); - create_icon_material("light_spot_icon", Node3DEditor::get_singleton()->get_theme_icon("GizmoSpotLight", "EditorIcons")); + create_icon_material("light_directional_icon", Node3DEditor::get_singleton()->get_theme_icon(SNAME("GizmoDirectionalLight"), SNAME("EditorIcons"))); + create_icon_material("light_omni_icon", Node3DEditor::get_singleton()->get_theme_icon(SNAME("GizmoLight"), SNAME("EditorIcons"))); + create_icon_material("light_spot_icon", Node3DEditor::get_singleton()->get_theme_icon(SNAME("GizmoSpotLight"), SNAME("EditorIcons"))); create_handle_material("handles"); create_handle_material("handles_billboard", true); @@ -802,20 +1263,20 @@ int Light3DGizmoPlugin::get_priority() const { return -1; } -String Light3DGizmoPlugin::get_handle_name(const EditorNode3DGizmo *p_gizmo, int p_idx) const { - if (p_idx == 0) { +String Light3DGizmoPlugin::get_handle_name(const EditorNode3DGizmo *p_gizmo, int p_id) const { + if (p_id == 0) { return "Radius"; } else { return "Aperture"; } } -Variant Light3DGizmoPlugin::get_handle_value(EditorNode3DGizmo *p_gizmo, int p_idx) const { +Variant Light3DGizmoPlugin::get_handle_value(const EditorNode3DGizmo *p_gizmo, int p_id) const { Light3D *light = Object::cast_to<Light3D>(p_gizmo->get_spatial_node()); - if (p_idx == 0) { + if (p_id == 0) { return light->get_param(Light3D::PARAM_RANGE); } - if (p_idx == 1) { + if (p_id == 1) { return light->get_param(Light3D::PARAM_SPOT_ANGLE); } @@ -849,7 +1310,7 @@ static float _find_closest_angle_to_half_pi_arc(const Vector3 &p_from, const Vec return Math::rad2deg(a); } -void Light3DGizmoPlugin::set_handle(EditorNode3DGizmo *p_gizmo, int p_idx, Camera3D *p_camera, const Point2 &p_point) { +void Light3DGizmoPlugin::set_handle(const EditorNode3DGizmo *p_gizmo, int p_id, Camera3D *p_camera, const Point2 &p_point) const { Light3D *light = Object::cast_to<Light3D>(p_gizmo->get_spatial_node()); Transform3D gt = light->get_global_transform(); Transform3D gi = gt.affine_inverse(); @@ -858,7 +1319,7 @@ void Light3DGizmoPlugin::set_handle(EditorNode3DGizmo *p_gizmo, int p_idx, Camer Vector3 ray_dir = p_camera->project_ray_normal(p_point); Vector3 s[2] = { gi.xform(ray_from), gi.xform(ray_from + ray_dir * 4096) }; - if (p_idx == 0) { + if (p_id == 0) { if (Object::cast_to<SpotLight3D>(light)) { Vector3 ra, rb; Geometry3D::get_closest_points_between_segments(Vector3(), Vector3(0, 0, -4096), s[0], s[1], ra, rb); @@ -887,24 +1348,24 @@ void Light3DGizmoPlugin::set_handle(EditorNode3DGizmo *p_gizmo, int p_idx, Camer } } - } else if (p_idx == 1) { + } else if (p_id == 1) { float a = _find_closest_angle_to_half_pi_arc(s[0], s[1], light->get_param(Light3D::PARAM_RANGE), gt); light->set_param(Light3D::PARAM_SPOT_ANGLE, CLAMP(a, 0.01, 89.99)); } } -void Light3DGizmoPlugin::commit_handle(EditorNode3DGizmo *p_gizmo, int p_idx, const Variant &p_restore, bool p_cancel) { +void Light3DGizmoPlugin::commit_handle(const EditorNode3DGizmo *p_gizmo, int p_id, const Variant &p_restore, bool p_cancel) const { Light3D *light = Object::cast_to<Light3D>(p_gizmo->get_spatial_node()); if (p_cancel) { - light->set_param(p_idx == 0 ? Light3D::PARAM_RANGE : Light3D::PARAM_SPOT_ANGLE, p_restore); + light->set_param(p_id == 0 ? Light3D::PARAM_RANGE : Light3D::PARAM_SPOT_ANGLE, p_restore); - } else if (p_idx == 0) { + } else if (p_id == 0) { UndoRedo *ur = Node3DEditor::get_singleton()->get_undo_redo(); ur->create_action(TTR("Change Light Radius")); ur->add_do_method(light, "set_param", Light3D::PARAM_RANGE, light->get_param(Light3D::PARAM_RANGE)); ur->add_undo_method(light, "set_param", Light3D::PARAM_RANGE, p_restore); ur->commit_action(); - } else if (p_idx == 1) { + } else if (p_id == 1) { UndoRedo *ur = Node3DEditor::get_singleton()->get_undo_redo(); ur->create_action(TTR("Change Light Radius")); ur->add_do_method(light, "set_param", Light3D::PARAM_SPOT_ANGLE, light->get_param(Light3D::PARAM_SPOT_ANGLE)); @@ -996,7 +1457,7 @@ void Light3DGizmoPlugin::redraw(EditorNode3DGizmo *p_gizmo) { Vector<Vector3> handles; handles.push_back(Vector3(r, 0, 0)); - p_gizmo->add_handles(handles, get_material("handles_billboard"), true); + p_gizmo->add_handles(handles, get_material("handles_billboard"), Vector<int>(), true); } if (Object::cast_to<SpotLight3D>(light)) { @@ -1050,7 +1511,7 @@ void Light3DGizmoPlugin::redraw(EditorNode3DGizmo *p_gizmo) { AudioStreamPlayer3DGizmoPlugin::AudioStreamPlayer3DGizmoPlugin() { Color gizmo_color = EDITOR_DEF("editors/3d_gizmos/gizmo_colors/stream_player_3d", Color(0.4, 0.8, 1)); - create_icon_material("stream_player_3d_icon", Node3DEditor::get_singleton()->get_theme_icon("Gizmo3DSamplePlayer", "EditorIcons")); + create_icon_material("stream_player_3d_icon", Node3DEditor::get_singleton()->get_theme_icon(SNAME("Gizmo3DSamplePlayer"), SNAME("EditorIcons"))); create_material("stream_player_3d_material_primary", gizmo_color); create_material("stream_player_3d_material_secondary", gizmo_color * Color(1, 1, 1, 0.35)); create_handle_material("handles"); @@ -1068,16 +1529,16 @@ int AudioStreamPlayer3DGizmoPlugin::get_priority() const { return -1; } -String AudioStreamPlayer3DGizmoPlugin::get_handle_name(const EditorNode3DGizmo *p_gizmo, int p_idx) const { +String AudioStreamPlayer3DGizmoPlugin::get_handle_name(const EditorNode3DGizmo *p_gizmo, int p_id) const { return "Emission Radius"; } -Variant AudioStreamPlayer3DGizmoPlugin::get_handle_value(EditorNode3DGizmo *p_gizmo, int p_idx) const { +Variant AudioStreamPlayer3DGizmoPlugin::get_handle_value(const EditorNode3DGizmo *p_gizmo, int p_id) const { AudioStreamPlayer3D *player = Object::cast_to<AudioStreamPlayer3D>(p_gizmo->get_spatial_node()); return player->get_emission_angle(); } -void AudioStreamPlayer3DGizmoPlugin::set_handle(EditorNode3DGizmo *p_gizmo, int p_idx, Camera3D *p_camera, const Point2 &p_point) { +void AudioStreamPlayer3DGizmoPlugin::set_handle(const EditorNode3DGizmo *p_gizmo, int p_id, Camera3D *p_camera, const Point2 &p_point) const { AudioStreamPlayer3D *player = Object::cast_to<AudioStreamPlayer3D>(p_gizmo->get_spatial_node()); Transform3D gt = player->get_global_transform(); @@ -1114,7 +1575,7 @@ void AudioStreamPlayer3DGizmoPlugin::set_handle(EditorNode3DGizmo *p_gizmo, int } } -void AudioStreamPlayer3DGizmoPlugin::commit_handle(EditorNode3DGizmo *p_gizmo, int p_idx, const Variant &p_restore, bool p_cancel) { +void AudioStreamPlayer3DGizmoPlugin::commit_handle(const EditorNode3DGizmo *p_gizmo, int p_id, const Variant &p_restore, bool p_cancel) const { AudioStreamPlayer3D *player = Object::cast_to<AudioStreamPlayer3D>(p_gizmo->get_spatial_node()); if (p_cancel) { @@ -1203,7 +1664,7 @@ int Camera3DGizmoPlugin::get_priority() const { return -1; } -String Camera3DGizmoPlugin::get_handle_name(const EditorNode3DGizmo *p_gizmo, int p_idx) const { +String Camera3DGizmoPlugin::get_handle_name(const EditorNode3DGizmo *p_gizmo, int p_id) const { Camera3D *camera = Object::cast_to<Camera3D>(p_gizmo->get_spatial_node()); if (camera->get_projection() == Camera3D::PROJECTION_PERSPECTIVE) { @@ -1213,7 +1674,7 @@ String Camera3DGizmoPlugin::get_handle_name(const EditorNode3DGizmo *p_gizmo, in } } -Variant Camera3DGizmoPlugin::get_handle_value(EditorNode3DGizmo *p_gizmo, int p_idx) const { +Variant Camera3DGizmoPlugin::get_handle_value(const EditorNode3DGizmo *p_gizmo, int p_id) const { Camera3D *camera = Object::cast_to<Camera3D>(p_gizmo->get_spatial_node()); if (camera->get_projection() == Camera3D::PROJECTION_PERSPECTIVE) { @@ -1223,7 +1684,7 @@ Variant Camera3DGizmoPlugin::get_handle_value(EditorNode3DGizmo *p_gizmo, int p_ } } -void Camera3DGizmoPlugin::set_handle(EditorNode3DGizmo *p_gizmo, int p_idx, Camera3D *p_camera, const Point2 &p_point) { +void Camera3DGizmoPlugin::set_handle(const EditorNode3DGizmo *p_gizmo, int p_id, Camera3D *p_camera, const Point2 &p_point) const { Camera3D *camera = Object::cast_to<Camera3D>(p_gizmo->get_spatial_node()); Transform3D gt = camera->get_global_transform(); @@ -1252,7 +1713,7 @@ void Camera3DGizmoPlugin::set_handle(EditorNode3DGizmo *p_gizmo, int p_idx, Came } } -void Camera3DGizmoPlugin::commit_handle(EditorNode3DGizmo *p_gizmo, int p_idx, const Variant &p_restore, bool p_cancel) { +void Camera3DGizmoPlugin::commit_handle(const EditorNode3DGizmo *p_gizmo, int p_id, const Variant &p_restore, bool p_cancel) const { Camera3D *camera = Object::cast_to<Camera3D>(p_gizmo->get_spatial_node()); if (camera->get_projection() == Camera3D::PROJECTION_PERSPECTIVE) { @@ -1558,7 +2019,7 @@ Position3DGizmoPlugin::Position3DGizmoPlugin() { // Use a darkened axis color for the negative axis. // This makes it possible to see in which direction the Position3D node is rotated // (which can be important depending on how it's used). - const Color color_x = EditorNode::get_singleton()->get_gui_base()->get_theme_color("axis_x_color", "Editor"); + const Color color_x = EditorNode::get_singleton()->get_gui_base()->get_theme_color(SNAME("axis_x_color"), SNAME("Editor")); cursor_colors.push_back(color_x); cursor_colors.push_back(color_x); // FIXME: Use less strong darkening factor once GH-48573 is fixed. @@ -1566,13 +2027,13 @@ Position3DGizmoPlugin::Position3DGizmoPlugin() { cursor_colors.push_back(color_x.lerp(Color(0, 0, 0), 0.75)); cursor_colors.push_back(color_x.lerp(Color(0, 0, 0), 0.75)); - const Color color_y = EditorNode::get_singleton()->get_gui_base()->get_theme_color("axis_y_color", "Editor"); + const Color color_y = EditorNode::get_singleton()->get_gui_base()->get_theme_color(SNAME("axis_y_color"), SNAME("Editor")); cursor_colors.push_back(color_y); cursor_colors.push_back(color_y); cursor_colors.push_back(color_y.lerp(Color(0, 0, 0), 0.75)); cursor_colors.push_back(color_y.lerp(Color(0, 0, 0), 0.75)); - const Color color_z = EditorNode::get_singleton()->get_gui_base()->get_theme_color("axis_z_color", "Editor"); + const Color color_z = EditorNode::get_singleton()->get_gui_base()->get_theme_color(SNAME("axis_z_color"), SNAME("Editor")); cursor_colors.push_back(color_z); cursor_colors.push_back(color_z); cursor_colors.push_back(color_z.lerp(Color(0, 0, 0), 0.75)); @@ -1761,7 +2222,7 @@ void Skeleton3DGizmoPlugin::redraw(EditorNode3DGizmo *p_gizmo) { } Ref<ArrayMesh> m = surface_tool->commit(); - p_gizmo->add_mesh(m, false, skel->register_skin(Ref<Skin>())); + p_gizmo->add_mesh(m, Ref<Material>(), Transform3D(), skel->register_skin(Ref<Skin>())); } //// @@ -2102,23 +2563,23 @@ void SoftBody3DGizmoPlugin::redraw(EditorNode3DGizmo *p_gizmo) { p_gizmo->add_collision_triangles(tm); } -String SoftBody3DGizmoPlugin::get_handle_name(const EditorNode3DGizmo *p_gizmo, int p_idx) const { +String SoftBody3DGizmoPlugin::get_handle_name(const EditorNode3DGizmo *p_gizmo, int p_id) const { return "SoftBody3D pin point"; } -Variant SoftBody3DGizmoPlugin::get_handle_value(EditorNode3DGizmo *p_gizmo, int p_idx) const { +Variant SoftBody3DGizmoPlugin::get_handle_value(const EditorNode3DGizmo *p_gizmo, int p_id) const { SoftBody3D *soft_body = Object::cast_to<SoftBody3D>(p_gizmo->get_spatial_node()); - return Variant(soft_body->is_point_pinned(p_idx)); + return Variant(soft_body->is_point_pinned(p_id)); } -void SoftBody3DGizmoPlugin::commit_handle(EditorNode3DGizmo *p_gizmo, int p_idx, const Variant &p_restore, bool p_cancel) { +void SoftBody3DGizmoPlugin::commit_handle(const EditorNode3DGizmo *p_gizmo, int p_id, const Variant &p_restore, bool p_cancel) const { SoftBody3D *soft_body = Object::cast_to<SoftBody3D>(p_gizmo->get_spatial_node()); - soft_body->pin_point_toggle(p_idx); + soft_body->pin_point_toggle(p_id); } -bool SoftBody3DGizmoPlugin::is_handle_highlighted(const EditorNode3DGizmo *p_gizmo, int idx) const { +bool SoftBody3DGizmoPlugin::is_handle_highlighted(const EditorNode3DGizmo *p_gizmo, int p_id) const { SoftBody3D *soft_body = Object::cast_to<SoftBody3D>(p_gizmo->get_spatial_node()); - return soft_body->is_point_pinned(idx); + return soft_body->is_point_pinned(p_id); } /////////// @@ -2143,8 +2604,8 @@ int VisibleOnScreenNotifier3DGizmoPlugin::get_priority() const { return -1; } -String VisibleOnScreenNotifier3DGizmoPlugin::get_handle_name(const EditorNode3DGizmo *p_gizmo, int p_idx) const { - switch (p_idx) { +String VisibleOnScreenNotifier3DGizmoPlugin::get_handle_name(const EditorNode3DGizmo *p_gizmo, int p_id) const { + switch (p_id) { case 0: return "Size X"; case 1: @@ -2162,20 +2623,20 @@ String VisibleOnScreenNotifier3DGizmoPlugin::get_handle_name(const EditorNode3DG return ""; } -Variant VisibleOnScreenNotifier3DGizmoPlugin::get_handle_value(EditorNode3DGizmo *p_gizmo, int p_idx) const { +Variant VisibleOnScreenNotifier3DGizmoPlugin::get_handle_value(const EditorNode3DGizmo *p_gizmo, int p_id) const { VisibleOnScreenNotifier3D *notifier = Object::cast_to<VisibleOnScreenNotifier3D>(p_gizmo->get_spatial_node()); return notifier->get_aabb(); } -void VisibleOnScreenNotifier3DGizmoPlugin::set_handle(EditorNode3DGizmo *p_gizmo, int p_idx, Camera3D *p_camera, const Point2 &p_point) { +void VisibleOnScreenNotifier3DGizmoPlugin::set_handle(const EditorNode3DGizmo *p_gizmo, int p_id, Camera3D *p_camera, const Point2 &p_point) const { VisibleOnScreenNotifier3D *notifier = Object::cast_to<VisibleOnScreenNotifier3D>(p_gizmo->get_spatial_node()); Transform3D gt = notifier->get_global_transform(); Transform3D gi = gt.affine_inverse(); - bool move = p_idx >= 3; - p_idx = p_idx % 3; + bool move = p_id >= 3; + p_id = p_id % 3; AABB aabb = notifier->get_aabb(); Vector3 ray_from = p_camera->project_ray_origin(p_point); @@ -2186,25 +2647,25 @@ void VisibleOnScreenNotifier3DGizmoPlugin::set_handle(EditorNode3DGizmo *p_gizmo Vector3 ofs = aabb.position + aabb.size * 0.5; Vector3 axis; - axis[p_idx] = 1.0; + axis[p_id] = 1.0; if (move) { Vector3 ra, rb; Geometry3D::get_closest_points_between_segments(ofs - axis * 4096, ofs + axis * 4096, sg[0], sg[1], ra, rb); - float d = ra[p_idx]; + float d = ra[p_id]; if (Node3DEditor::get_singleton()->is_snap_enabled()) { d = Math::snapped(d, Node3DEditor::get_singleton()->get_translate_snap()); } - aabb.position[p_idx] = d - 1.0 - aabb.size[p_idx] * 0.5; + aabb.position[p_id] = d - 1.0 - aabb.size[p_id] * 0.5; notifier->set_aabb(aabb); } else { Vector3 ra, rb; Geometry3D::get_closest_points_between_segments(ofs, ofs + axis * 4096, sg[0], sg[1], ra, rb); - float d = ra[p_idx] - ofs[p_idx]; + float d = ra[p_id] - ofs[p_id]; if (Node3DEditor::get_singleton()->is_snap_enabled()) { d = Math::snapped(d, Node3DEditor::get_singleton()->get_translate_snap()); } @@ -2213,13 +2674,13 @@ void VisibleOnScreenNotifier3DGizmoPlugin::set_handle(EditorNode3DGizmo *p_gizmo d = 0.001; } //resize - aabb.position[p_idx] = (aabb.position[p_idx] + aabb.size[p_idx] * 0.5) - d; - aabb.size[p_idx] = d * 2; + aabb.position[p_id] = (aabb.position[p_id] + aabb.size[p_id] * 0.5) - d; + aabb.size[p_id] = d * 2; notifier->set_aabb(aabb); } } -void VisibleOnScreenNotifier3DGizmoPlugin::commit_handle(EditorNode3DGizmo *p_gizmo, int p_idx, const Variant &p_restore, bool p_cancel) { +void VisibleOnScreenNotifier3DGizmoPlugin::commit_handle(const EditorNode3DGizmo *p_gizmo, int p_id, const Variant &p_restore, bool p_cancel) const { VisibleOnScreenNotifier3D *notifier = Object::cast_to<VisibleOnScreenNotifier3D>(p_gizmo->get_spatial_node()); if (p_cancel) { @@ -2284,7 +2745,7 @@ void VisibleOnScreenNotifier3DGizmoPlugin::redraw(EditorNode3DGizmo *p_gizmo) { //// CPUParticles3DGizmoPlugin::CPUParticles3DGizmoPlugin() { - create_icon_material("particles_icon", Node3DEditor::get_singleton()->get_theme_icon("GizmoCPUParticles3D", "EditorIcons")); + create_icon_material("particles_icon", Node3DEditor::get_singleton()->get_theme_icon(SNAME("GizmoCPUParticles3D"), SNAME("EditorIcons"))); } bool CPUParticles3DGizmoPlugin::has_gizmo(Node3D *p_spatial) { @@ -2315,7 +2776,7 @@ GPUParticles3DGizmoPlugin::GPUParticles3DGizmoPlugin() { create_material("particles_material", gizmo_color); gizmo_color.a = 0.1; create_material("particles_solid_material", gizmo_color); - create_icon_material("particles_icon", Node3DEditor::get_singleton()->get_theme_icon("GizmoGPUParticles3D", "EditorIcons")); + create_icon_material("particles_icon", Node3DEditor::get_singleton()->get_theme_icon(SNAME("GizmoGPUParticles3D"), SNAME("EditorIcons"))); create_handle_material("handles"); } @@ -2335,8 +2796,8 @@ bool GPUParticles3DGizmoPlugin::is_selectable_when_hidden() const { return true; } -String GPUParticles3DGizmoPlugin::get_handle_name(const EditorNode3DGizmo *p_gizmo, int p_idx) const { - switch (p_idx) { +String GPUParticles3DGizmoPlugin::get_handle_name(const EditorNode3DGizmo *p_gizmo, int p_id) const { + switch (p_id) { case 0: return "Size X"; case 1: @@ -2354,19 +2815,19 @@ String GPUParticles3DGizmoPlugin::get_handle_name(const EditorNode3DGizmo *p_giz return ""; } -Variant GPUParticles3DGizmoPlugin::get_handle_value(EditorNode3DGizmo *p_gizmo, int p_idx) const { +Variant GPUParticles3DGizmoPlugin::get_handle_value(const EditorNode3DGizmo *p_gizmo, int p_id) const { GPUParticles3D *particles = Object::cast_to<GPUParticles3D>(p_gizmo->get_spatial_node()); return particles->get_visibility_aabb(); } -void GPUParticles3DGizmoPlugin::set_handle(EditorNode3DGizmo *p_gizmo, int p_idx, Camera3D *p_camera, const Point2 &p_point) { +void GPUParticles3DGizmoPlugin::set_handle(const EditorNode3DGizmo *p_gizmo, int p_id, Camera3D *p_camera, const Point2 &p_point) const { GPUParticles3D *particles = Object::cast_to<GPUParticles3D>(p_gizmo->get_spatial_node()); Transform3D gt = particles->get_global_transform(); Transform3D gi = gt.affine_inverse(); - bool move = p_idx >= 3; - p_idx = p_idx % 3; + bool move = p_id >= 3; + p_id = p_id % 3; AABB aabb = particles->get_visibility_aabb(); Vector3 ray_from = p_camera->project_ray_origin(p_point); @@ -2377,25 +2838,25 @@ void GPUParticles3DGizmoPlugin::set_handle(EditorNode3DGizmo *p_gizmo, int p_idx Vector3 ofs = aabb.position + aabb.size * 0.5; Vector3 axis; - axis[p_idx] = 1.0; + axis[p_id] = 1.0; if (move) { Vector3 ra, rb; Geometry3D::get_closest_points_between_segments(ofs - axis * 4096, ofs + axis * 4096, sg[0], sg[1], ra, rb); - float d = ra[p_idx]; + float d = ra[p_id]; if (Node3DEditor::get_singleton()->is_snap_enabled()) { d = Math::snapped(d, Node3DEditor::get_singleton()->get_translate_snap()); } - aabb.position[p_idx] = d - 1.0 - aabb.size[p_idx] * 0.5; + aabb.position[p_id] = d - 1.0 - aabb.size[p_id] * 0.5; particles->set_visibility_aabb(aabb); } else { Vector3 ra, rb; Geometry3D::get_closest_points_between_segments(ofs, ofs + axis * 4096, sg[0], sg[1], ra, rb); - float d = ra[p_idx] - ofs[p_idx]; + float d = ra[p_id] - ofs[p_id]; if (Node3DEditor::get_singleton()->is_snap_enabled()) { d = Math::snapped(d, Node3DEditor::get_singleton()->get_translate_snap()); } @@ -2404,13 +2865,13 @@ void GPUParticles3DGizmoPlugin::set_handle(EditorNode3DGizmo *p_gizmo, int p_idx d = 0.001; } //resize - aabb.position[p_idx] = (aabb.position[p_idx] + aabb.size[p_idx] * 0.5) - d; - aabb.size[p_idx] = d * 2; + aabb.position[p_id] = (aabb.position[p_id] + aabb.size[p_id] * 0.5) - d; + aabb.size[p_id] = d * 2; particles->set_visibility_aabb(aabb); } } -void GPUParticles3DGizmoPlugin::commit_handle(EditorNode3DGizmo *p_gizmo, int p_idx, const Variant &p_restore, bool p_cancel) { +void GPUParticles3DGizmoPlugin::commit_handle(const EditorNode3DGizmo *p_gizmo, int p_id, const Variant &p_restore, bool p_cancel) const { GPUParticles3D *particles = Object::cast_to<GPUParticles3D>(p_gizmo->get_spatial_node()); if (p_cancel) { @@ -2475,8 +2936,6 @@ void GPUParticles3DGizmoPlugin::redraw(EditorNode3DGizmo *p_gizmo) { //// -//// - GPUParticlesCollision3DGizmoPlugin::GPUParticlesCollision3DGizmoPlugin() { Color gizmo_color = EDITOR_DEF("editors/3d_gizmos/gizmo_colors/particle_collision", Color(0.5, 0.7, 1)); create_material("shape_material", gizmo_color); @@ -2498,7 +2957,7 @@ int GPUParticlesCollision3DGizmoPlugin::get_priority() const { return -1; } -String GPUParticlesCollision3DGizmoPlugin::get_handle_name(const EditorNode3DGizmo *p_gizmo, int p_idx) const { +String GPUParticlesCollision3DGizmoPlugin::get_handle_name(const EditorNode3DGizmo *p_gizmo, int p_id) const { const Node3D *cs = p_gizmo->get_spatial_node(); if (Object::cast_to<GPUParticlesCollisionSphere>(cs) || Object::cast_to<GPUParticlesAttractorSphere>(cs)) { @@ -2512,7 +2971,7 @@ String GPUParticlesCollision3DGizmoPlugin::get_handle_name(const EditorNode3DGiz return ""; } -Variant GPUParticlesCollision3DGizmoPlugin::get_handle_value(EditorNode3DGizmo *p_gizmo, int p_idx) const { +Variant GPUParticlesCollision3DGizmoPlugin::get_handle_value(const EditorNode3DGizmo *p_gizmo, int p_id) const { const Node3D *cs = p_gizmo->get_spatial_node(); if (Object::cast_to<GPUParticlesCollisionSphere>(cs) || Object::cast_to<GPUParticlesAttractorSphere>(cs)) { @@ -2526,7 +2985,7 @@ Variant GPUParticlesCollision3DGizmoPlugin::get_handle_value(EditorNode3DGizmo * return Variant(); } -void GPUParticlesCollision3DGizmoPlugin::set_handle(EditorNode3DGizmo *p_gizmo, int p_idx, Camera3D *p_camera, const Point2 &p_point) { +void GPUParticlesCollision3DGizmoPlugin::set_handle(const EditorNode3DGizmo *p_gizmo, int p_id, Camera3D *p_camera, const Point2 &p_point) const { Node3D *sn = p_gizmo->get_spatial_node(); Transform3D gt = sn->get_global_transform(); @@ -2554,10 +3013,10 @@ void GPUParticlesCollision3DGizmoPlugin::set_handle(EditorNode3DGizmo *p_gizmo, if (Object::cast_to<GPUParticlesCollisionBox>(sn) || Object::cast_to<GPUParticlesAttractorBox>(sn) || Object::cast_to<GPUParticlesAttractorVectorField>(sn) || Object::cast_to<GPUParticlesCollisionSDF>(sn) || Object::cast_to<GPUParticlesCollisionHeightField>(sn)) { Vector3 axis; - axis[p_idx] = 1.0; + axis[p_id] = 1.0; Vector3 ra, rb; Geometry3D::get_closest_points_between_segments(Vector3(), axis * 4096, sg[0], sg[1], ra, rb); - float d = ra[p_idx]; + float d = ra[p_id]; if (Node3DEditor::get_singleton()->is_snap_enabled()) { d = Math::snapped(d, Node3DEditor::get_singleton()->get_translate_snap()); } @@ -2567,12 +3026,12 @@ void GPUParticlesCollision3DGizmoPlugin::set_handle(EditorNode3DGizmo *p_gizmo, } Vector3 he = sn->call("get_extents"); - he[p_idx] = d; + he[p_id] = d; sn->call("set_extents", he); } } -void GPUParticlesCollision3DGizmoPlugin::commit_handle(EditorNode3DGizmo *p_gizmo, int p_idx, const Variant &p_restore, bool p_cancel) { +void GPUParticlesCollision3DGizmoPlugin::commit_handle(const EditorNode3DGizmo *p_gizmo, int p_id, const Variant &p_restore, bool p_cancel) const { Node3D *sn = p_gizmo->get_spatial_node(); if (Object::cast_to<GPUParticlesCollisionSphere>(sn) || Object::cast_to<GPUParticlesAttractorSphere>(sn)) { @@ -2746,7 +3205,7 @@ ReflectionProbeGizmoPlugin::ReflectionProbeGizmoPlugin() { gizmo_color.a = 0.1; create_material("reflection_probe_solid_material", gizmo_color); - create_icon_material("reflection_probe_icon", Node3DEditor::get_singleton()->get_theme_icon("GizmoReflectionProbe", "EditorIcons")); + create_icon_material("reflection_probe_icon", Node3DEditor::get_singleton()->get_theme_icon(SNAME("GizmoReflectionProbe"), SNAME("EditorIcons"))); create_handle_material("handles"); } @@ -2762,8 +3221,8 @@ int ReflectionProbeGizmoPlugin::get_priority() const { return -1; } -String ReflectionProbeGizmoPlugin::get_handle_name(const EditorNode3DGizmo *p_gizmo, int p_idx) const { - switch (p_idx) { +String ReflectionProbeGizmoPlugin::get_handle_name(const EditorNode3DGizmo *p_gizmo, int p_id) const { + switch (p_id) { case 0: return "Extents X"; case 1: @@ -2781,18 +3240,18 @@ String ReflectionProbeGizmoPlugin::get_handle_name(const EditorNode3DGizmo *p_gi return ""; } -Variant ReflectionProbeGizmoPlugin::get_handle_value(EditorNode3DGizmo *p_gizmo, int p_idx) const { +Variant ReflectionProbeGizmoPlugin::get_handle_value(const EditorNode3DGizmo *p_gizmo, int p_id) const { ReflectionProbe *probe = Object::cast_to<ReflectionProbe>(p_gizmo->get_spatial_node()); return AABB(probe->get_extents(), probe->get_origin_offset()); } -void ReflectionProbeGizmoPlugin::set_handle(EditorNode3DGizmo *p_gizmo, int p_idx, Camera3D *p_camera, const Point2 &p_point) { +void ReflectionProbeGizmoPlugin::set_handle(const EditorNode3DGizmo *p_gizmo, int p_id, Camera3D *p_camera, const Point2 &p_point) const { ReflectionProbe *probe = Object::cast_to<ReflectionProbe>(p_gizmo->get_spatial_node()); Transform3D gt = probe->get_global_transform(); Transform3D gi = gt.affine_inverse(); - if (p_idx < 3) { + if (p_id < 3) { Vector3 extents = probe->get_extents(); Vector3 ray_from = p_camera->project_ray_origin(p_point); @@ -2801,11 +3260,11 @@ void ReflectionProbeGizmoPlugin::set_handle(EditorNode3DGizmo *p_gizmo, int p_id Vector3 sg[2] = { gi.xform(ray_from), gi.xform(ray_from + ray_dir * 16384) }; Vector3 axis; - axis[p_idx] = 1.0; + axis[p_id] = 1.0; Vector3 ra, rb; Geometry3D::get_closest_points_between_segments(Vector3(), axis * 16384, sg[0], sg[1], ra, rb); - float d = ra[p_idx]; + float d = ra[p_id]; if (Node3DEditor::get_singleton()->is_snap_enabled()) { d = Math::snapped(d, Node3DEditor::get_singleton()->get_translate_snap()); } @@ -2814,13 +3273,13 @@ void ReflectionProbeGizmoPlugin::set_handle(EditorNode3DGizmo *p_gizmo, int p_id d = 0.001; } - extents[p_idx] = d; + extents[p_id] = d; probe->set_extents(extents); } else { - p_idx -= 3; + p_id -= 3; Vector3 origin = probe->get_origin_offset(); - origin[p_idx] = 0; + origin[p_id] = 0; Vector3 ray_from = p_camera->project_ray_origin(p_point); Vector3 ray_dir = p_camera->project_ray_normal(p_point); @@ -2828,22 +3287,22 @@ void ReflectionProbeGizmoPlugin::set_handle(EditorNode3DGizmo *p_gizmo, int p_id Vector3 sg[2] = { gi.xform(ray_from), gi.xform(ray_from + ray_dir * 16384) }; Vector3 axis; - axis[p_idx] = 1.0; + axis[p_id] = 1.0; Vector3 ra, rb; Geometry3D::get_closest_points_between_segments(origin - axis * 16384, origin + axis * 16384, sg[0], sg[1], ra, rb); // Adjust the actual position to account for the gizmo handle position - float d = ra[p_idx] + 0.25; + float d = ra[p_id] + 0.25; if (Node3DEditor::get_singleton()->is_snap_enabled()) { d = Math::snapped(d, Node3DEditor::get_singleton()->get_translate_snap()); } - origin[p_idx] = d; + origin[p_id] = d; probe->set_origin_offset(origin); } } -void ReflectionProbeGizmoPlugin::commit_handle(EditorNode3DGizmo *p_gizmo, int p_idx, const Variant &p_restore, bool p_cancel) { +void ReflectionProbeGizmoPlugin::commit_handle(const EditorNode3DGizmo *p_gizmo, int p_id, const Variant &p_restore, bool p_cancel) const { ReflectionProbe *probe = Object::cast_to<ReflectionProbe>(p_gizmo->get_spatial_node()); AABB restore = p_restore; @@ -2947,8 +3406,8 @@ int DecalGizmoPlugin::get_priority() const { return -1; } -String DecalGizmoPlugin::get_handle_name(const EditorNode3DGizmo *p_gizmo, int p_idx) const { - switch (p_idx) { +String DecalGizmoPlugin::get_handle_name(const EditorNode3DGizmo *p_gizmo, int p_id) const { + switch (p_id) { case 0: return "Extents X"; case 1: @@ -2960,12 +3419,12 @@ String DecalGizmoPlugin::get_handle_name(const EditorNode3DGizmo *p_gizmo, int p return ""; } -Variant DecalGizmoPlugin::get_handle_value(EditorNode3DGizmo *p_gizmo, int p_idx) const { +Variant DecalGizmoPlugin::get_handle_value(const EditorNode3DGizmo *p_gizmo, int p_id) const { Decal *decal = Object::cast_to<Decal>(p_gizmo->get_spatial_node()); return decal->get_extents(); } -void DecalGizmoPlugin::set_handle(EditorNode3DGizmo *p_gizmo, int p_idx, Camera3D *p_camera, const Point2 &p_point) { +void DecalGizmoPlugin::set_handle(const EditorNode3DGizmo *p_gizmo, int p_id, Camera3D *p_camera, const Point2 &p_point) const { Decal *decal = Object::cast_to<Decal>(p_gizmo->get_spatial_node()); Transform3D gt = decal->get_global_transform(); @@ -2979,11 +3438,11 @@ void DecalGizmoPlugin::set_handle(EditorNode3DGizmo *p_gizmo, int p_idx, Camera3 Vector3 sg[2] = { gi.xform(ray_from), gi.xform(ray_from + ray_dir * 16384) }; Vector3 axis; - axis[p_idx] = 1.0; + axis[p_id] = 1.0; Vector3 ra, rb; Geometry3D::get_closest_points_between_segments(Vector3(), axis * 16384, sg[0], sg[1], ra, rb); - float d = ra[p_idx]; + float d = ra[p_id]; if (Node3DEditor::get_singleton()->is_snap_enabled()) { d = Math::snapped(d, Node3DEditor::get_singleton()->get_translate_snap()); } @@ -2992,11 +3451,11 @@ void DecalGizmoPlugin::set_handle(EditorNode3DGizmo *p_gizmo, int p_idx, Camera3 d = 0.001; } - extents[p_idx] = d; + extents[p_id] = d; decal->set_extents(extents); } -void DecalGizmoPlugin::commit_handle(EditorNode3DGizmo *p_gizmo, int p_idx, const Variant &p_restore, bool p_cancel) { +void DecalGizmoPlugin::commit_handle(const EditorNode3DGizmo *p_gizmo, int p_id, const Variant &p_restore, bool p_cancel) const { Decal *decal = Object::cast_to<Decal>(p_gizmo->get_spatial_node()); Vector3 restore = p_restore; @@ -3055,7 +3514,6 @@ void DecalGizmoPlugin::redraw(EditorNode3DGizmo *p_gizmo) { Ref<Material> material = get_material("decal_material", p_gizmo); p_gizmo->add_lines(lines, material); - p_gizmo->add_handles(handles, get_material("handles")); } @@ -3072,7 +3530,7 @@ VoxelGIGizmoPlugin::VoxelGIGizmoPlugin() { gizmo_color.a = 0.05; create_material("voxel_gi_solid_material", gizmo_color); - create_icon_material("voxel_gi_icon", Node3DEditor::get_singleton()->get_theme_icon("GizmoVoxelGI", "EditorIcons")); + create_icon_material("voxel_gi_icon", Node3DEditor::get_singleton()->get_theme_icon(SNAME("GizmoVoxelGI"), SNAME("EditorIcons"))); create_handle_material("handles"); } @@ -3088,8 +3546,8 @@ int VoxelGIGizmoPlugin::get_priority() const { return -1; } -String VoxelGIGizmoPlugin::get_handle_name(const EditorNode3DGizmo *p_gizmo, int p_idx) const { - switch (p_idx) { +String VoxelGIGizmoPlugin::get_handle_name(const EditorNode3DGizmo *p_gizmo, int p_id) const { + switch (p_id) { case 0: return "Extents X"; case 1: @@ -3101,12 +3559,12 @@ String VoxelGIGizmoPlugin::get_handle_name(const EditorNode3DGizmo *p_gizmo, int return ""; } -Variant VoxelGIGizmoPlugin::get_handle_value(EditorNode3DGizmo *p_gizmo, int p_idx) const { +Variant VoxelGIGizmoPlugin::get_handle_value(const EditorNode3DGizmo *p_gizmo, int p_id) const { VoxelGI *probe = Object::cast_to<VoxelGI>(p_gizmo->get_spatial_node()); return probe->get_extents(); } -void VoxelGIGizmoPlugin::set_handle(EditorNode3DGizmo *p_gizmo, int p_idx, Camera3D *p_camera, const Point2 &p_point) { +void VoxelGIGizmoPlugin::set_handle(const EditorNode3DGizmo *p_gizmo, int p_id, Camera3D *p_camera, const Point2 &p_point) const { VoxelGI *probe = Object::cast_to<VoxelGI>(p_gizmo->get_spatial_node()); Transform3D gt = probe->get_global_transform(); @@ -3120,11 +3578,11 @@ void VoxelGIGizmoPlugin::set_handle(EditorNode3DGizmo *p_gizmo, int p_idx, Camer Vector3 sg[2] = { gi.xform(ray_from), gi.xform(ray_from + ray_dir * 16384) }; Vector3 axis; - axis[p_idx] = 1.0; + axis[p_id] = 1.0; Vector3 ra, rb; Geometry3D::get_closest_points_between_segments(Vector3(), axis * 16384, sg[0], sg[1], ra, rb); - float d = ra[p_idx]; + float d = ra[p_id]; if (Node3DEditor::get_singleton()->is_snap_enabled()) { d = Math::snapped(d, Node3DEditor::get_singleton()->get_translate_snap()); } @@ -3133,11 +3591,11 @@ void VoxelGIGizmoPlugin::set_handle(EditorNode3DGizmo *p_gizmo, int p_idx, Camer d = 0.001; } - extents[p_idx] = d; + extents[p_id] = d; probe->set_extents(extents); } -void VoxelGIGizmoPlugin::commit_handle(EditorNode3DGizmo *p_gizmo, int p_idx, const Variant &p_restore, bool p_cancel) { +void VoxelGIGizmoPlugin::commit_handle(const EditorNode3DGizmo *p_gizmo, int p_id, const Variant &p_restore, bool p_cancel) const { VoxelGI *probe = Object::cast_to<VoxelGI>(p_gizmo->get_spatial_node()); Vector3 restore = p_restore; @@ -3254,21 +3712,21 @@ LightmapGIGizmoPlugin::LightmapGIGizmoPlugin() { add_material("lightmap_probe_material", mat); - create_icon_material("baked_indirect_light_icon", Node3DEditor::get_singleton()->get_theme_icon("GizmoLightmapGI", "EditorIcons")); + create_icon_material("baked_indirect_light_icon", Node3DEditor::get_singleton()->get_theme_icon(SNAME("GizmoLightmapGI"), SNAME("EditorIcons"))); } -String LightmapGIGizmoPlugin::get_handle_name(const EditorNode3DGizmo *p_gizmo, int p_idx) const { +String LightmapGIGizmoPlugin::get_handle_name(const EditorNode3DGizmo *p_gizmo, int p_id) const { return ""; } -Variant LightmapGIGizmoPlugin::get_handle_value(EditorNode3DGizmo *p_gizmo, int p_idx) const { +Variant LightmapGIGizmoPlugin::get_handle_value(const EditorNode3DGizmo *p_gizmo, int p_id) const { return Variant(); } -void LightmapGIGizmoPlugin::set_handle(EditorNode3DGizmo *p_gizmo, int p_idx, Camera3D *p_camera, const Point2 &p_point) { +void LightmapGIGizmoPlugin::set_handle(const EditorNode3DGizmo *p_gizmo, int p_id, Camera3D *p_camera, const Point2 &p_point) const { } -void LightmapGIGizmoPlugin::commit_handle(EditorNode3DGizmo *p_gizmo, int p_idx, const Variant &p_restore, bool p_cancel) { +void LightmapGIGizmoPlugin::commit_handle(const EditorNode3DGizmo *p_gizmo, int p_id, const Variant &p_restore, bool p_cancel) const { } bool LightmapGIGizmoPlugin::has_gizmo(Node3D *p_spatial) { @@ -3439,18 +3897,18 @@ LightmapProbeGizmoPlugin::LightmapProbeGizmoPlugin() { create_material("lightprobe_lines", gizmo_color); } -String LightmapProbeGizmoPlugin::get_handle_name(const EditorNode3DGizmo *p_gizmo, int p_idx) const { +String LightmapProbeGizmoPlugin::get_handle_name(const EditorNode3DGizmo *p_gizmo, int p_id) const { return ""; } -Variant LightmapProbeGizmoPlugin::get_handle_value(EditorNode3DGizmo *p_gizmo, int p_idx) const { +Variant LightmapProbeGizmoPlugin::get_handle_value(const EditorNode3DGizmo *p_gizmo, int p_id) const { return Variant(); } -void LightmapProbeGizmoPlugin::set_handle(EditorNode3DGizmo *p_gizmo, int p_idx, Camera3D *p_camera, const Point2 &p_point) { +void LightmapProbeGizmoPlugin::set_handle(const EditorNode3DGizmo *p_gizmo, int p_id, Camera3D *p_camera, const Point2 &p_point) const { } -void LightmapProbeGizmoPlugin::commit_handle(EditorNode3DGizmo *p_gizmo, int p_idx, const Variant &p_restore, bool p_cancel) { +void LightmapProbeGizmoPlugin::commit_handle(const EditorNode3DGizmo *p_gizmo, int p_id, const Variant &p_restore, bool p_cancel) const { } bool LightmapProbeGizmoPlugin::has_gizmo(Node3D *p_spatial) { @@ -3555,8 +4013,7 @@ void CollisionObject3DGizmoPlugin::redraw(EditorNode3DGizmo *p_gizmo) { List<uint32_t> owners; co->get_shape_owners(&owners); - for (List<uint32_t>::Element *E = owners.front(); E; E = E->next()) { - uint32_t owner_id = E->get(); + for (uint32_t &owner_id : owners) { Transform3D xform = co->shape_owner_get_transform(owner_id); Object *owner = co->shape_owner_get_owner(owner_id); // Exclude CollisionShape3D and CollisionPolygon3D as they have their gizmo. @@ -3570,7 +4027,7 @@ void CollisionObject3DGizmoPlugin::redraw(EditorNode3DGizmo *p_gizmo) { SurfaceTool st; st.append_from(s->get_debug_mesh(), 0, xform); - p_gizmo->add_mesh(st.commit(), false, Ref<SkinReference>(), material); + p_gizmo->add_mesh(st.commit(), material); p_gizmo->add_collision_segments(s->get_debug_mesh_lines()); } } @@ -3600,7 +4057,7 @@ int CollisionShape3DGizmoPlugin::get_priority() const { return -1; } -String CollisionShape3DGizmoPlugin::get_handle_name(const EditorNode3DGizmo *p_gizmo, int p_idx) const { +String CollisionShape3DGizmoPlugin::get_handle_name(const EditorNode3DGizmo *p_gizmo, int p_id) const { const CollisionShape3D *cs = Object::cast_to<CollisionShape3D>(p_gizmo->get_spatial_node()); Ref<Shape3D> s = cs->get_shape(); @@ -3617,11 +4074,11 @@ String CollisionShape3DGizmoPlugin::get_handle_name(const EditorNode3DGizmo *p_g } if (Object::cast_to<CapsuleShape3D>(*s)) { - return p_idx == 0 ? "Radius" : "Height"; + return p_id == 0 ? "Radius" : "Height"; } if (Object::cast_to<CylinderShape3D>(*s)) { - return p_idx == 0 ? "Radius" : "Height"; + return p_id == 0 ? "Radius" : "Height"; } if (Object::cast_to<RayShape3D>(*s)) { @@ -3631,7 +4088,7 @@ String CollisionShape3DGizmoPlugin::get_handle_name(const EditorNode3DGizmo *p_g return ""; } -Variant CollisionShape3DGizmoPlugin::get_handle_value(EditorNode3DGizmo *p_gizmo, int p_idx) const { +Variant CollisionShape3DGizmoPlugin::get_handle_value(const EditorNode3DGizmo *p_gizmo, int p_id) const { CollisionShape3D *cs = Object::cast_to<CollisionShape3D>(p_gizmo->get_spatial_node()); Ref<Shape3D> s = cs->get_shape(); @@ -3651,12 +4108,12 @@ Variant CollisionShape3DGizmoPlugin::get_handle_value(EditorNode3DGizmo *p_gizmo if (Object::cast_to<CapsuleShape3D>(*s)) { Ref<CapsuleShape3D> cs2 = s; - return p_idx == 0 ? cs2->get_radius() : cs2->get_height(); + return p_id == 0 ? cs2->get_radius() : cs2->get_height(); } if (Object::cast_to<CylinderShape3D>(*s)) { Ref<CylinderShape3D> cs2 = s; - return p_idx == 0 ? cs2->get_radius() : cs2->get_height(); + return p_id == 0 ? cs2->get_radius() : cs2->get_height(); } if (Object::cast_to<RayShape3D>(*s)) { @@ -3667,7 +4124,7 @@ Variant CollisionShape3DGizmoPlugin::get_handle_value(EditorNode3DGizmo *p_gizmo return Variant(); } -void CollisionShape3DGizmoPlugin::set_handle(EditorNode3DGizmo *p_gizmo, int p_idx, Camera3D *p_camera, const Point2 &p_point) { +void CollisionShape3DGizmoPlugin::set_handle(const EditorNode3DGizmo *p_gizmo, int p_id, Camera3D *p_camera, const Point2 &p_point) const { CollisionShape3D *cs = Object::cast_to<CollisionShape3D>(p_gizmo->get_spatial_node()); Ref<Shape3D> s = cs->get_shape(); @@ -3717,11 +4174,11 @@ void CollisionShape3DGizmoPlugin::set_handle(EditorNode3DGizmo *p_gizmo, int p_i if (Object::cast_to<BoxShape3D>(*s)) { Vector3 axis; - axis[p_idx] = 1.0; + axis[p_id] = 1.0; Ref<BoxShape3D> bs = s; Vector3 ra, rb; Geometry3D::get_closest_points_between_segments(Vector3(), axis * 4096, sg[0], sg[1], ra, rb); - float d = ra[p_idx]; + float d = ra[p_id]; if (Node3DEditor::get_singleton()->is_snap_enabled()) { d = Math::snapped(d, Node3DEditor::get_singleton()->get_translate_snap()); } @@ -3731,18 +4188,18 @@ void CollisionShape3DGizmoPlugin::set_handle(EditorNode3DGizmo *p_gizmo, int p_i } Vector3 he = bs->get_size(); - he[p_idx] = d * 2; + he[p_id] = d * 2; bs->set_size(he); } if (Object::cast_to<CapsuleShape3D>(*s)) { Vector3 axis; - axis[p_idx == 0 ? 0 : 2] = 1.0; + axis[p_id == 0 ? 0 : 2] = 1.0; Ref<CapsuleShape3D> cs2 = s; Vector3 ra, rb; Geometry3D::get_closest_points_between_segments(Vector3(), axis * 4096, sg[0], sg[1], ra, rb); float d = axis.dot(ra); - if (p_idx == 1) { + if (p_id == 1) { d -= cs2->get_radius(); } @@ -3754,16 +4211,16 @@ void CollisionShape3DGizmoPlugin::set_handle(EditorNode3DGizmo *p_gizmo, int p_i d = 0.001; } - if (p_idx == 0) { + if (p_id == 0) { cs2->set_radius(d); - } else if (p_idx == 1) { + } else if (p_id == 1) { cs2->set_height(d * 2.0); } } if (Object::cast_to<CylinderShape3D>(*s)) { Vector3 axis; - axis[p_idx == 0 ? 0 : 1] = 1.0; + axis[p_id == 0 ? 0 : 1] = 1.0; Ref<CylinderShape3D> cs2 = s; Vector3 ra, rb; Geometry3D::get_closest_points_between_segments(Vector3(), axis * 4096, sg[0], sg[1], ra, rb); @@ -3776,15 +4233,15 @@ void CollisionShape3DGizmoPlugin::set_handle(EditorNode3DGizmo *p_gizmo, int p_i d = 0.001; } - if (p_idx == 0) { + if (p_id == 0) { cs2->set_radius(d); - } else if (p_idx == 1) { + } else if (p_id == 1) { cs2->set_height(d * 2.0); } } } -void CollisionShape3DGizmoPlugin::commit_handle(EditorNode3DGizmo *p_gizmo, int p_idx, const Variant &p_restore, bool p_cancel) { +void CollisionShape3DGizmoPlugin::commit_handle(const EditorNode3DGizmo *p_gizmo, int p_id, const Variant &p_restore, bool p_cancel) const { CollisionShape3D *cs = Object::cast_to<CollisionShape3D>(p_gizmo->get_spatial_node()); Ref<Shape3D> s = cs->get_shape(); @@ -3823,7 +4280,7 @@ void CollisionShape3DGizmoPlugin::commit_handle(EditorNode3DGizmo *p_gizmo, int if (Object::cast_to<CapsuleShape3D>(*s)) { Ref<CapsuleShape3D> ss = s; if (p_cancel) { - if (p_idx == 0) { + if (p_id == 0) { ss->set_radius(p_restore); } else { ss->set_height(p_restore); @@ -3832,7 +4289,7 @@ void CollisionShape3DGizmoPlugin::commit_handle(EditorNode3DGizmo *p_gizmo, int } UndoRedo *ur = Node3DEditor::get_singleton()->get_undo_redo(); - if (p_idx == 0) { + if (p_id == 0) { ur->create_action(TTR("Change Capsule Shape Radius")); ur->add_do_method(ss.ptr(), "set_radius", ss->get_radius()); ur->add_undo_method(ss.ptr(), "set_radius", p_restore); @@ -3848,7 +4305,7 @@ void CollisionShape3DGizmoPlugin::commit_handle(EditorNode3DGizmo *p_gizmo, int if (Object::cast_to<CylinderShape3D>(*s)) { Ref<CylinderShape3D> ss = s; if (p_cancel) { - if (p_idx == 0) { + if (p_id == 0) { ss->set_radius(p_restore); } else { ss->set_height(p_restore); @@ -3857,7 +4314,7 @@ void CollisionShape3DGizmoPlugin::commit_handle(EditorNode3DGizmo *p_gizmo, int } UndoRedo *ur = Node3DEditor::get_singleton()->get_undo_redo(); - if (p_idx == 0) { + if (p_id == 0) { ur->create_action(TTR("Change Cylinder Shape Radius")); ur->add_do_method(ss.ptr(), "set_radius", ss->get_radius()); ur->add_undo_method(ss.ptr(), "set_radius", p_restore); @@ -4153,7 +4610,7 @@ void CollisionShape3DGizmoPlugin::redraw(EditorNode3DGizmo *p_gizmo) { if (Object::cast_to<ConcavePolygonShape3D>(*s)) { Ref<ConcavePolygonShape3D> cs2 = s; Ref<ArrayMesh> mesh = cs2->get_debug_mesh(); - p_gizmo->add_mesh(mesh, false, Ref<SkinReference>(), material); + p_gizmo->add_mesh(mesh, material); p_gizmo->add_collision_segments(cs2->get_debug_mesh_lines()); } @@ -4174,7 +4631,7 @@ void CollisionShape3DGizmoPlugin::redraw(EditorNode3DGizmo *p_gizmo) { Ref<HeightMapShape3D> hms = s; Ref<ArrayMesh> mesh = hms->get_debug_mesh(); - p_gizmo->add_mesh(mesh, false, Ref<SkinReference>(), material); + p_gizmo->add_mesh(mesh, material); } } @@ -4289,9 +4746,7 @@ void NavigationRegion3DGizmoPlugin::redraw(EditorNode3DGizmo *p_gizmo) { Vector3 *tw = tmeshfaces.ptrw(); int tidx = 0; - for (List<Face3>::Element *E = faces.front(); E; E = E->next()) { - const Face3 &f = E->get(); - + for (const Face3 &f : faces) { for (int j = 0; j < 3; j++) { tw[tidx++] = f.vertex[j]; _EdgeKey ek; @@ -4589,7 +5044,7 @@ Joint3DGizmoPlugin::Joint3DGizmoPlugin() { update_timer->set_wait_time(1.0 / 120.0); update_timer->connect("timeout", callable_mp(this, &Joint3DGizmoPlugin::incremental_update_gizmos)); update_timer->set_autostart(true); - EditorNode::get_singleton()->call_deferred("add_child", update_timer); + EditorNode::get_singleton()->call_deferred(SNAME("add_child"), update_timer); } void Joint3DGizmoPlugin::incremental_update_gizmos() { diff --git a/editor/node_3d_editor_gizmos.h b/editor/plugins/node_3d_editor_gizmos.h index 6f071859ec..61ee3a95a9 100644 --- a/editor/node_3d_editor_gizmos.h +++ b/editor/plugins/node_3d_editor_gizmos.h @@ -28,13 +28,156 @@ /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ /*************************************************************************/ -#ifndef SPATIAL_EDITOR_GIZMOS_H -#define SPATIAL_EDITOR_GIZMOS_H +#ifndef NODE_3D_EDITOR_GIZMOS_H +#define NODE_3D_EDITOR_GIZMOS_H -#include "editor/plugins/node_3d_editor_plugin.h" -#include "scene/3d/camera_3d.h" +#include "core/templates/ordered_hash_map.h" +#include "scene/3d/node_3d.h" +#include "scene/3d/skeleton_3d.h" class Camera3D; +class Timer; +class EditorNode3DGizmoPlugin; + +class EditorNode3DGizmo : public Node3DGizmo { + GDCLASS(EditorNode3DGizmo, Node3DGizmo); + + struct Instance { + RID instance; + Ref<ArrayMesh> mesh; + Ref<Material> material; + Ref<SkinReference> skin_reference; + bool extra_margin = false; + Transform3D xform; + + void create_instance(Node3D *p_base, bool p_hidden = false); + }; + + bool selected; + + Vector<Vector3> collision_segments; + Ref<TriangleMesh> collision_mesh; + + Vector<Vector3> handles; + Vector<int> handle_ids; + Vector<Vector3> secondary_handles; + Vector<int> secondary_handle_ids; + + float selectable_icon_size; + bool billboard_handle; + + bool valid; + bool hidden; + Vector<Instance> instances; + Node3D *spatial_node; + + void _set_spatial_node(Node *p_node) { set_spatial_node(Object::cast_to<Node3D>(p_node)); } + +protected: + static void _bind_methods(); + + EditorNode3DGizmoPlugin *gizmo_plugin; + +public: + void add_lines(const Vector<Vector3> &p_lines, const Ref<Material> &p_material, bool p_billboard = false, const Color &p_modulate = Color(1, 1, 1)); + void add_vertices(const Vector<Vector3> &p_vertices, const Ref<Material> &p_material, Mesh::PrimitiveType p_primitive_type, bool p_billboard = false, const Color &p_modulate = Color(1, 1, 1)); + void add_mesh(const Ref<ArrayMesh> &p_mesh, const Ref<Material> &p_material = Ref<Material>(), const Transform3D &p_xform = Transform3D(), const Ref<SkinReference> &p_skin_reference = Ref<SkinReference>()); + void add_collision_segments(const Vector<Vector3> &p_lines); + void add_collision_triangles(const Ref<TriangleMesh> &p_tmesh); + void add_unscaled_billboard(const Ref<Material> &p_material, float p_scale = 1, const Color &p_modulate = Color(1, 1, 1)); + void add_handles(const Vector<Vector3> &p_handles, const Ref<Material> &p_material, const Vector<int> &p_ids = Vector<int>(), bool p_billboard = false, bool p_secondary = false); + void add_solid_box(Ref<Material> &p_material, Vector3 p_size, Vector3 p_position = Vector3(), const Transform3D &p_xform = Transform3D()); + + virtual bool is_handle_highlighted(int p_id) const; + virtual String get_handle_name(int p_id) const; + virtual Variant get_handle_value(int p_id) const; + virtual void set_handle(int p_id, Camera3D *p_camera, const Point2 &p_point) const; + virtual void commit_handle(int p_id, const Variant &p_restore, bool p_cancel = false) const; + + virtual int subgizmos_intersect_ray(Camera3D *p_camera, const Vector2 &p_point) const; + virtual Vector<int> subgizmos_intersect_frustum(const Camera3D *p_camera, const Vector<Plane> &p_frustum) const; + virtual Transform3D get_subgizmo_transform(int p_id) const; + virtual void set_subgizmo_transform(int p_id, Transform3D p_transform) const; + virtual void commit_subgizmos(const Vector<int> &p_ids, const Vector<Transform3D> &p_restore, bool p_cancel = false) const; + + void set_selected(bool p_selected) { selected = p_selected; } + bool is_selected() const { return selected; } + + void set_spatial_node(Node3D *p_node); + Node3D *get_spatial_node() const { return spatial_node; } + Ref<EditorNode3DGizmoPlugin> get_plugin() const { return gizmo_plugin; } + bool intersect_frustum(const Camera3D *p_camera, const Vector<Plane> &p_frustum); + void handles_intersect_ray(Camera3D *p_camera, const Vector2 &p_point, bool p_shift_pressed, int &r_id); + bool intersect_ray(Camera3D *p_camera, const Point2 &p_point, Vector3 &r_pos, Vector3 &r_normal); + bool is_subgizmo_selected(int p_id) const; + Vector<int> get_subgizmo_selection() const; + + virtual void clear() override; + virtual void create() override; + virtual void transform() override; + virtual void redraw() override; + virtual void free() override; + + virtual bool is_editable() const; + + void set_hidden(bool p_hidden); + void set_plugin(EditorNode3DGizmoPlugin *p_plugin); + + EditorNode3DGizmo(); + ~EditorNode3DGizmo(); +}; + +class EditorNode3DGizmoPlugin : public Resource { + GDCLASS(EditorNode3DGizmoPlugin, Resource); + +public: + static const int VISIBLE = 0; + static const int HIDDEN = 1; + static const int ON_TOP = 2; + +protected: + int current_state; + List<EditorNode3DGizmo *> current_gizmos; + HashMap<String, Vector<Ref<StandardMaterial3D>>> materials; + + static void _bind_methods(); + virtual bool has_gizmo(Node3D *p_spatial); + virtual Ref<EditorNode3DGizmo> create_gizmo(Node3D *p_spatial); + +public: + void create_material(const String &p_name, const Color &p_color, bool p_billboard = false, bool p_on_top = false, bool p_use_vertex_color = false); + void create_icon_material(const String &p_name, const Ref<Texture2D> &p_texture, bool p_on_top = false, const Color &p_albedo = Color(1, 1, 1, 1)); + void create_handle_material(const String &p_name, bool p_billboard = false, const Ref<Texture2D> &p_texture = nullptr); + void add_material(const String &p_name, Ref<StandardMaterial3D> p_material); + + Ref<StandardMaterial3D> get_material(const String &p_name, const Ref<EditorNode3DGizmo> &p_gizmo = Ref<EditorNode3DGizmo>()); + + virtual String get_gizmo_name() const; + virtual int get_priority() const; + virtual bool can_be_hidden() const; + virtual bool is_selectable_when_hidden() const; + + virtual void redraw(EditorNode3DGizmo *p_gizmo); + virtual bool is_handle_highlighted(const EditorNode3DGizmo *p_gizmo, int p_id) const; + virtual String get_handle_name(const EditorNode3DGizmo *p_gizmo, int p_id) const; + virtual Variant get_handle_value(const EditorNode3DGizmo *p_gizmo, int p_id) const; + virtual void set_handle(const EditorNode3DGizmo *p_gizmo, int p_id, Camera3D *p_camera, const Point2 &p_point) const; + virtual void commit_handle(const EditorNode3DGizmo *p_gizmo, int p_id, const Variant &p_restore, bool p_cancel = false) const; + + virtual int subgizmos_intersect_ray(const EditorNode3DGizmo *p_gizmo, Camera3D *p_camera, const Vector2 &p_point) const; + virtual Vector<int> subgizmos_intersect_frustum(const EditorNode3DGizmo *p_gizmo, const Camera3D *p_camera, const Vector<Plane> &p_frustum) const; + virtual Transform3D get_subgizmo_transform(const EditorNode3DGizmo *p_gizmo, int p_id) const; + virtual void set_subgizmo_transform(const EditorNode3DGizmo *p_gizmo, int p_id, Transform3D p_transform) const; + virtual void commit_subgizmos(const EditorNode3DGizmo *p_gizmo, const Vector<int> &p_ids, const Vector<Transform3D> &p_restore, bool p_cancel = false) const; + + Ref<EditorNode3DGizmo> get_gizmo(Node3D *p_spatial); + void set_state(int p_state); + int get_state() const; + void unregister_gizmo(EditorNode3DGizmo *p_gizmo); + + EditorNode3DGizmoPlugin(); + virtual ~EditorNode3DGizmoPlugin(); +}; class Light3DGizmoPlugin : public EditorNode3DGizmoPlugin { GDCLASS(Light3DGizmoPlugin, EditorNode3DGizmoPlugin); @@ -44,10 +187,10 @@ public: String get_gizmo_name() const override; int get_priority() const override; - String get_handle_name(const EditorNode3DGizmo *p_gizmo, int p_idx) const override; - Variant get_handle_value(EditorNode3DGizmo *p_gizmo, int p_idx) const override; - void set_handle(EditorNode3DGizmo *p_gizmo, int p_idx, Camera3D *p_camera, const Point2 &p_point) override; - void commit_handle(EditorNode3DGizmo *p_gizmo, int p_idx, const Variant &p_restore, bool p_cancel = false) override; + String get_handle_name(const EditorNode3DGizmo *p_gizmo, int p_id) const override; + Variant get_handle_value(const EditorNode3DGizmo *p_gizmo, int p_id) const override; + void set_handle(const EditorNode3DGizmo *p_gizmo, int p_id, Camera3D *p_camera, const Point2 &p_point) const override; + void commit_handle(const EditorNode3DGizmo *p_gizmo, int p_id, const Variant &p_restore, bool p_cancel = false) const override; void redraw(EditorNode3DGizmo *p_gizmo) override; Light3DGizmoPlugin(); @@ -61,10 +204,10 @@ public: String get_gizmo_name() const override; int get_priority() const override; - String get_handle_name(const EditorNode3DGizmo *p_gizmo, int p_idx) const override; - Variant get_handle_value(EditorNode3DGizmo *p_gizmo, int p_idx) const override; - void set_handle(EditorNode3DGizmo *p_gizmo, int p_idx, Camera3D *p_camera, const Point2 &p_point) override; - void commit_handle(EditorNode3DGizmo *p_gizmo, int p_idx, const Variant &p_restore, bool p_cancel = false) override; + String get_handle_name(const EditorNode3DGizmo *p_gizmo, int p_id) const override; + Variant get_handle_value(const EditorNode3DGizmo *p_gizmo, int p_id) const override; + void set_handle(const EditorNode3DGizmo *p_gizmo, int p_id, Camera3D *p_camera, const Point2 &p_point) const override; + void commit_handle(const EditorNode3DGizmo *p_gizmo, int p_id, const Variant &p_restore, bool p_cancel = false) const override; void redraw(EditorNode3DGizmo *p_gizmo) override; AudioStreamPlayer3DGizmoPlugin(); @@ -78,10 +221,10 @@ public: String get_gizmo_name() const override; int get_priority() const override; - String get_handle_name(const EditorNode3DGizmo *p_gizmo, int p_idx) const override; - Variant get_handle_value(EditorNode3DGizmo *p_gizmo, int p_idx) const override; - void set_handle(EditorNode3DGizmo *p_gizmo, int p_idx, Camera3D *p_camera, const Point2 &p_point) override; - void commit_handle(EditorNode3DGizmo *p_gizmo, int p_idx, const Variant &p_restore, bool p_cancel = false) override; + String get_handle_name(const EditorNode3DGizmo *p_gizmo, int p_id) const override; + Variant get_handle_value(const EditorNode3DGizmo *p_gizmo, int p_id) const override; + void set_handle(const EditorNode3DGizmo *p_gizmo, int p_id, Camera3D *p_camera, const Point2 &p_point) const override; + void commit_handle(const EditorNode3DGizmo *p_gizmo, int p_id, const Variant &p_restore, bool p_cancel = false) const override; void redraw(EditorNode3DGizmo *p_gizmo) override; Camera3DGizmoPlugin(); @@ -210,10 +353,10 @@ public: bool is_selectable_when_hidden() const override; void redraw(EditorNode3DGizmo *p_gizmo) override; - String get_handle_name(const EditorNode3DGizmo *p_gizmo, int p_idx) const override; - Variant get_handle_value(EditorNode3DGizmo *p_gizmo, int p_idx) const override; - void commit_handle(EditorNode3DGizmo *p_gizmo, int p_idx, const Variant &p_restore, bool p_cancel) override; - bool is_handle_highlighted(const EditorNode3DGizmo *p_gizmo, int idx) const override; + String get_handle_name(const EditorNode3DGizmo *p_gizmo, int p_id) const override; + Variant get_handle_value(const EditorNode3DGizmo *p_gizmo, int p_id) const override; + void commit_handle(const EditorNode3DGizmo *p_gizmo, int p_id, const Variant &p_restore, bool p_cancel = false) const override; + bool is_handle_highlighted(const EditorNode3DGizmo *p_gizmo, int p_id) const override; SoftBody3DGizmoPlugin(); }; @@ -227,10 +370,10 @@ public: int get_priority() const override; void redraw(EditorNode3DGizmo *p_gizmo) override; - String get_handle_name(const EditorNode3DGizmo *p_gizmo, int p_idx) const override; - Variant get_handle_value(EditorNode3DGizmo *p_gizmo, int p_idx) const override; - void set_handle(EditorNode3DGizmo *p_gizmo, int p_idx, Camera3D *p_camera, const Point2 &p_point) override; - void commit_handle(EditorNode3DGizmo *p_gizmo, int p_idx, const Variant &p_restore, bool p_cancel = false) override; + String get_handle_name(const EditorNode3DGizmo *p_gizmo, int p_id) const override; + Variant get_handle_value(const EditorNode3DGizmo *p_gizmo, int p_id) const override; + void set_handle(const EditorNode3DGizmo *p_gizmo, int p_id, Camera3D *p_camera, const Point2 &p_point) const override; + void commit_handle(const EditorNode3DGizmo *p_gizmo, int p_id, const Variant &p_restore, bool p_cancel = false) const override; VisibleOnScreenNotifier3DGizmoPlugin(); }; @@ -257,10 +400,10 @@ public: bool is_selectable_when_hidden() const override; void redraw(EditorNode3DGizmo *p_gizmo) override; - String get_handle_name(const EditorNode3DGizmo *p_gizmo, int p_idx) const override; - Variant get_handle_value(EditorNode3DGizmo *p_gizmo, int p_idx) const override; - void set_handle(EditorNode3DGizmo *p_gizmo, int p_idx, Camera3D *p_camera, const Point2 &p_point) override; - void commit_handle(EditorNode3DGizmo *p_gizmo, int p_idx, const Variant &p_restore, bool p_cancel = false) override; + String get_handle_name(const EditorNode3DGizmo *p_gizmo, int p_id) const override; + Variant get_handle_value(const EditorNode3DGizmo *p_gizmo, int p_id) const override; + void set_handle(const EditorNode3DGizmo *p_gizmo, int p_id, Camera3D *p_camera, const Point2 &p_point) const override; + void commit_handle(const EditorNode3DGizmo *p_gizmo, int p_id, const Variant &p_restore, bool p_cancel = false) const override; GPUParticles3DGizmoPlugin(); }; @@ -274,10 +417,10 @@ public: int get_priority() const override; void redraw(EditorNode3DGizmo *p_gizmo) override; - String get_handle_name(const EditorNode3DGizmo *p_gizmo, int p_idx) const override; - Variant get_handle_value(EditorNode3DGizmo *p_gizmo, int p_idx) const override; - void set_handle(EditorNode3DGizmo *p_gizmo, int p_idx, Camera3D *p_camera, const Point2 &p_point) override; - void commit_handle(EditorNode3DGizmo *p_gizmo, int p_idx, const Variant &p_restore, bool p_cancel = false) override; + String get_handle_name(const EditorNode3DGizmo *p_gizmo, int p_id) const override; + Variant get_handle_value(const EditorNode3DGizmo *p_gizmo, int p_id) const override; + void set_handle(const EditorNode3DGizmo *p_gizmo, int p_id, Camera3D *p_camera, const Point2 &p_point) const override; + void commit_handle(const EditorNode3DGizmo *p_gizmo, int p_id, const Variant &p_restore, bool p_cancel = false) const override; GPUParticlesCollision3DGizmoPlugin(); }; @@ -291,10 +434,10 @@ public: int get_priority() const override; void redraw(EditorNode3DGizmo *p_gizmo) override; - String get_handle_name(const EditorNode3DGizmo *p_gizmo, int p_idx) const override; - Variant get_handle_value(EditorNode3DGizmo *p_gizmo, int p_idx) const override; - void set_handle(EditorNode3DGizmo *p_gizmo, int p_idx, Camera3D *p_camera, const Point2 &p_point) override; - void commit_handle(EditorNode3DGizmo *p_gizmo, int p_idx, const Variant &p_restore, bool p_cancel = false) override; + String get_handle_name(const EditorNode3DGizmo *p_gizmo, int p_id) const override; + Variant get_handle_value(const EditorNode3DGizmo *p_gizmo, int p_id) const override; + void set_handle(const EditorNode3DGizmo *p_gizmo, int p_id, Camera3D *p_camera, const Point2 &p_point) const override; + void commit_handle(const EditorNode3DGizmo *p_gizmo, int p_id, const Variant &p_restore, bool p_cancel = false) const override; ReflectionProbeGizmoPlugin(); }; @@ -308,10 +451,10 @@ public: int get_priority() const override; void redraw(EditorNode3DGizmo *p_gizmo) override; - String get_handle_name(const EditorNode3DGizmo *p_gizmo, int p_idx) const override; - Variant get_handle_value(EditorNode3DGizmo *p_gizmo, int p_idx) const override; - void set_handle(EditorNode3DGizmo *p_gizmo, int p_idx, Camera3D *p_camera, const Point2 &p_point) override; - void commit_handle(EditorNode3DGizmo *p_gizmo, int p_idx, const Variant &p_restore, bool p_cancel = false) override; + String get_handle_name(const EditorNode3DGizmo *p_gizmo, int p_id) const override; + Variant get_handle_value(const EditorNode3DGizmo *p_gizmo, int p_id) const override; + void set_handle(const EditorNode3DGizmo *p_gizmo, int p_id, Camera3D *p_camera, const Point2 &p_point) const override; + void commit_handle(const EditorNode3DGizmo *p_gizmo, int p_id, const Variant &p_restore, bool p_cancel = false) const override; DecalGizmoPlugin(); }; @@ -325,10 +468,10 @@ public: int get_priority() const override; void redraw(EditorNode3DGizmo *p_gizmo) override; - String get_handle_name(const EditorNode3DGizmo *p_gizmo, int p_idx) const override; - Variant get_handle_value(EditorNode3DGizmo *p_gizmo, int p_idx) const override; - void set_handle(EditorNode3DGizmo *p_gizmo, int p_idx, Camera3D *p_camera, const Point2 &p_point) override; - void commit_handle(EditorNode3DGizmo *p_gizmo, int p_idx, const Variant &p_restore, bool p_cancel = false) override; + String get_handle_name(const EditorNode3DGizmo *p_gizmo, int p_id) const override; + Variant get_handle_value(const EditorNode3DGizmo *p_gizmo, int p_id) const override; + void set_handle(const EditorNode3DGizmo *p_gizmo, int p_id, Camera3D *p_camera, const Point2 &p_point) const override; + void commit_handle(const EditorNode3DGizmo *p_gizmo, int p_id, const Variant &p_restore, bool p_cancel = false) const override; VoxelGIGizmoPlugin(); }; @@ -342,10 +485,10 @@ public: int get_priority() const override; void redraw(EditorNode3DGizmo *p_gizmo) override; - String get_handle_name(const EditorNode3DGizmo *p_gizmo, int p_idx) const override; - Variant get_handle_value(EditorNode3DGizmo *p_gizmo, int p_idx) const override; - void set_handle(EditorNode3DGizmo *p_gizmo, int p_idx, Camera3D *p_camera, const Point2 &p_point) override; - void commit_handle(EditorNode3DGizmo *p_gizmo, int p_idx, const Variant &p_restore, bool p_cancel = false) override; + String get_handle_name(const EditorNode3DGizmo *p_gizmo, int p_id) const override; + Variant get_handle_value(const EditorNode3DGizmo *p_gizmo, int p_id) const override; + void set_handle(const EditorNode3DGizmo *p_gizmo, int p_id, Camera3D *p_camera, const Point2 &p_point) const override; + void commit_handle(const EditorNode3DGizmo *p_gizmo, int p_id, const Variant &p_restore, bool p_cancel = false) const override; LightmapGIGizmoPlugin(); }; @@ -359,10 +502,10 @@ public: int get_priority() const override; void redraw(EditorNode3DGizmo *p_gizmo) override; - String get_handle_name(const EditorNode3DGizmo *p_gizmo, int p_idx) const override; - Variant get_handle_value(EditorNode3DGizmo *p_gizmo, int p_idx) const override; - void set_handle(EditorNode3DGizmo *p_gizmo, int p_idx, Camera3D *p_camera, const Point2 &p_point) override; - void commit_handle(EditorNode3DGizmo *p_gizmo, int p_idx, const Variant &p_restore, bool p_cancel = false) override; + String get_handle_name(const EditorNode3DGizmo *p_gizmo, int p_id) const override; + Variant get_handle_value(const EditorNode3DGizmo *p_gizmo, int p_id) const override; + void set_handle(const EditorNode3DGizmo *p_gizmo, int p_id, Camera3D *p_camera, const Point2 &p_point) const override; + void commit_handle(const EditorNode3DGizmo *p_gizmo, int p_id, const Variant &p_restore, bool p_cancel = false) const override; LightmapProbeGizmoPlugin(); }; @@ -388,10 +531,10 @@ public: int get_priority() const override; void redraw(EditorNode3DGizmo *p_gizmo) override; - String get_handle_name(const EditorNode3DGizmo *p_gizmo, int p_idx) const override; - Variant get_handle_value(EditorNode3DGizmo *p_gizmo, int p_idx) const override; - void set_handle(EditorNode3DGizmo *p_gizmo, int p_idx, Camera3D *p_camera, const Point2 &p_point) override; - void commit_handle(EditorNode3DGizmo *p_gizmo, int p_idx, const Variant &p_restore, bool p_cancel = false) override; + String get_handle_name(const EditorNode3DGizmo *p_gizmo, int p_id) const override; + Variant get_handle_value(const EditorNode3DGizmo *p_gizmo, int p_id) const override; + void set_handle(const EditorNode3DGizmo *p_gizmo, int p_id, Camera3D *p_camera, const Point2 &p_point) const override; + void commit_handle(const EditorNode3DGizmo *p_gizmo, int p_id, const Variant &p_restore, bool p_cancel = false) const override; CollisionShape3DGizmoPlugin(); }; @@ -489,4 +632,4 @@ public: Joint3DGizmoPlugin(); }; -#endif // SPATIAL_EDITOR_GIZMOS_H +#endif // NODE_3D_EDITOR_GIZMOS_H diff --git a/editor/plugins/node_3d_editor_plugin.cpp b/editor/plugins/node_3d_editor_plugin.cpp index 3532473e17..af04c9566a 100644 --- a/editor/plugins/node_3d_editor_plugin.cpp +++ b/editor/plugins/node_3d_editor_plugin.cpp @@ -35,20 +35,20 @@ #include "core/math/camera_matrix.h" #include "core/math/math_funcs.h" #include "core/os/keyboard.h" -#include "core/string/print_string.h" #include "core/templates/sort_array.h" #include "editor/debugger/editor_debugger_node.h" #include "editor/editor_node.h" -#include "editor/editor_scale.h" #include "editor/editor_settings.h" -#include "editor/node_3d_editor_gizmos.h" #include "editor/plugins/animation_player_editor_plugin.h" +#include "editor/plugins/node_3d_editor_gizmos.h" #include "editor/plugins/script_editor_plugin.h" #include "scene/3d/camera_3d.h" #include "scene/3d/collision_shape_3d.h" +#include "scene/3d/light_3d.h" #include "scene/3d/mesh_instance_3d.h" #include "scene/3d/physics_body_3d.h" #include "scene/3d/visual_instance_3d.h" +#include "scene/3d/world_environment.h" #include "scene/gui/center_container.h" #include "scene/gui/subviewport_container.h" #include "scene/resources/packed_scene.h" @@ -58,7 +58,6 @@ #define GIZMO_ARROW_SIZE 0.35 #define GIZMO_RING_HALF_WIDTH 0.1 -#define GIZMO_SCALE_DEFAULT 0.15 #define GIZMO_PLANE_SIZE 0.2 #define GIZMO_PLANE_DST 0.3 #define GIZMO_CIRCLE_SIZE 1.1 @@ -92,9 +91,9 @@ void ViewportRotationControl::_notification(int p_what) { axis_menu_options.push_back(Node3DEditorViewport::VIEW_FRONT); axis_colors.clear(); - axis_colors.push_back(get_theme_color("axis_x_color", "Editor")); - axis_colors.push_back(get_theme_color("axis_y_color", "Editor")); - axis_colors.push_back(get_theme_color("axis_z_color", "Editor")); + axis_colors.push_back(get_theme_color(SNAME("axis_x_color"), SNAME("Editor"))); + axis_colors.push_back(get_theme_color(SNAME("axis_y_color"), SNAME("Editor"))); + axis_colors.push_back(get_theme_color(SNAME("axis_z_color"), SNAME("Editor"))); update(); if (!is_connected("mouse_exited", callable_mp(this, &ViewportRotationControl::_on_mouse_exited))) { @@ -143,7 +142,7 @@ void ViewportRotationControl::_draw_axis(const Axis2D &p_axis) { if (front) { String axis_name = direction == 0 ? "X" : (direction == 1 ? "Y" : "Z"); draw_circle(p_axis.screen_point, AXIS_CIRCLE_RADIUS, c); - draw_char(get_theme_font("rotation_control", "EditorFonts"), p_axis.screen_point + Vector2i(-4, 5) * EDSCALE, axis_name, "", get_theme_font_size("rotation_control_size", "EditorFonts"), Color(0.3, 0.3, 0.3)); + draw_char(get_theme_font(SNAME("rotation_control"), SNAME("EditorFonts")), p_axis.screen_point + Vector2i(-4, 5) * EDSCALE, axis_name, "", get_theme_font_size(SNAME("rotation_control_size"), SNAME("EditorFonts")), Color(0.3, 0.3, 0.3)); } else { draw_circle(p_axis.screen_point, AXIS_CIRCLE_RADIUS * (0.55 + (0.2 * (1.0 + p_axis.z_axis))), c); } @@ -436,16 +435,29 @@ Vector3 Node3DEditorViewport::_get_ray(const Vector2 &p_pos) const { } void Node3DEditorViewport::_clear_selected() { - editor_selection->clear(); -} - -void Node3DEditorViewport::_select_clicked(bool p_append, bool p_single, bool p_allow_locked) { - if (clicked.is_null()) { - return; + _edit.gizmo = Ref<EditorNode3DGizmo>(); + _edit.gizmo_handle = -1; + _edit.gizmo_initial_value = Variant(); + + Node3D *selected = spatial_editor->get_single_selected_node(); + Node3DEditorSelectedItem *se = selected ? editor_selection->get_node_editor_data<Node3DEditorSelectedItem>(selected) : nullptr; + + if (se && se->gizmo.is_valid()) { + se->subgizmos.clear(); + se->gizmo->redraw(); + se->gizmo.unref(); + spatial_editor->update_transform_gizmo(); + } else { + editor_selection->clear(); + Node3DEditor::get_singleton()->edit(nullptr); } +} - Node *node = Object::cast_to<Node>(ObjectDB::get_instance(clicked)); +void Node3DEditorViewport::_select_clicked(bool p_allow_locked) { + Node *node = Object::cast_to<Node3D>(ObjectDB::get_instance(clicked)); Node3D *selected = Object::cast_to<Node3D>(node); + clicked = ObjectID(); + if (!selected) { return; } @@ -462,43 +474,27 @@ void Node3DEditorViewport::_select_clicked(bool p_append, bool p_single, bool p_ } if (p_allow_locked || !_is_node_locked(selected)) { - _select(selected, clicked_wants_append, true); - } -} - -void Node3DEditorViewport::_select(Node *p_node, bool p_append, bool p_single) { - // Add or remove a single node from the selection - if (p_append && p_single) { - if (editor_selection->is_selected(p_node)) { - // Already in the selection, remove it from the selected nodes - editor_selection->remove_node(p_node); + if (clicked_wants_append) { + if (editor_selection->is_selected(selected)) { + editor_selection->remove_node(selected); + } else { + editor_selection->add_node(selected); + } } else { - // Add the item to the selection - editor_selection->add_node(p_node); - } - } else if (p_append && !p_single) { - // Add the item to the selection - editor_selection->add_node(p_node); - } else { - // No append; single select - editor_selection->clear(); - editor_selection->add_node(p_node); - // Reselect - if (Engine::get_singleton()->is_editor_hint()) { - editor->call("edit_node", p_node); + if (!editor_selection->is_selected(selected)) { + editor_selection->clear(); + editor_selection->add_node(selected); + editor->edit_node(selected); + } } - } - if (editor_selection->get_selected_node_list().size() == 1) { - editor->push_item(editor_selection->get_selected_node_list()[0]); + if (editor_selection->get_selected_node_list().size() == 1) { + editor->edit_node(editor_selection->get_selected_node_list()[0]); + } } } -ObjectID Node3DEditorViewport::_select_ray(const Point2 &p_pos, bool p_append, bool &r_includes_current, int *r_gizmo_handle, bool p_alt_select) { - if (r_gizmo_handle) { - *r_gizmo_handle = -1; - } - +ObjectID Node3DEditorViewport::_select_ray(const Point2 &p_pos) { Vector3 ray = _get_ray(p_pos); Vector3 pos = _get_ray_pos(p_pos); Vector2 shrinked_pos = p_pos / subviewport_container->get_stretch_shrink(); @@ -514,7 +510,6 @@ ObjectID Node3DEditorViewport::_select_ray(const Point2 &p_pos, bool p_append, b ObjectID closest; Node *item = nullptr; float closest_dist = 1e20; - int selected_handle = -1; for (int i = 0; i < instances.size(); i++) { Node3D *spat = Object::cast_to<Node3D>(ObjectDB::get_instance(instances[i])); @@ -523,38 +518,40 @@ ObjectID Node3DEditorViewport::_select_ray(const Point2 &p_pos, bool p_append, b continue; } - Ref<EditorNode3DGizmo> seg = spat->get_gizmo(); + Vector<Ref<Node3DGizmo>> gizmos = spat->get_gizmos(); - if ((!seg.is_valid()) || found_gizmos.has(seg)) { - continue; - } + for (int j = 0; j < gizmos.size(); j++) { + Ref<EditorNode3DGizmo> seg = gizmos[j]; - found_gizmos.insert(seg); - Vector3 point; - Vector3 normal; + if ((!seg.is_valid()) || found_gizmos.has(seg)) { + continue; + } - int handle = -1; - bool inters = seg->intersect_ray(camera, shrinked_pos, point, normal, &handle, p_alt_select); + found_gizmos.insert(seg); + Vector3 point; + Vector3 normal; - if (!inters) { - continue; - } + bool inters = seg->intersect_ray(camera, shrinked_pos, point, normal); - float dist = pos.distance_to(point); + if (!inters) { + continue; + } - if (dist < 0) { - continue; - } + float dist = pos.distance_to(point); - if (dist < closest_dist) { - item = Object::cast_to<Node>(spat); - if (item != edited_scene) { - item = edited_scene->get_deepest_editable_node(item); + if (dist < 0) { + continue; } - closest = item->get_instance_id(); - closest_dist = dist; - selected_handle = handle; + if (dist < closest_dist) { + item = Object::cast_to<Node>(spat); + if (item != edited_scene) { + item = edited_scene->get_deepest_editable_node(item); + } + + closest = item->get_instance_id(); + closest_dist = dist; + } } } @@ -562,23 +559,15 @@ ObjectID Node3DEditorViewport::_select_ray(const Point2 &p_pos, bool p_append, b return ObjectID(); } - if (!editor_selection->is_selected(item) || (r_gizmo_handle && selected_handle >= 0)) { - if (r_gizmo_handle) { - *r_gizmo_handle = selected_handle; - } - } - return closest; } -void Node3DEditorViewport::_find_items_at_pos(const Point2 &p_pos, bool &r_includes_current, Vector<_RayResult> &results, bool p_alt_select) { +void Node3DEditorViewport::_find_items_at_pos(const Point2 &p_pos, Vector<_RayResult> &r_results, bool p_include_locked_nodes) { Vector3 ray = _get_ray(p_pos); Vector3 pos = _get_ray_pos(p_pos); Vector<ObjectID> instances = RenderingServer::get_singleton()->instances_cull_ray(pos, ray, get_tree()->get_root()->get_world_3d()->get_scenario()); - Set<Ref<EditorNode3DGizmo>> found_gizmos; - - r_includes_current = false; + Set<Node3D *> found_nodes; for (int i = 0; i < instances.size(); i++) { Node3D *spat = Object::cast_to<Node3D>(ObjectDB::get_instance(instances[i])); @@ -587,49 +576,48 @@ void Node3DEditorViewport::_find_items_at_pos(const Point2 &p_pos, bool &r_inclu continue; } - Ref<EditorNode3DGizmo> seg = spat->get_gizmo(); - - if (!seg.is_valid()) { + if (found_nodes.has(spat)) { continue; } - if (found_gizmos.has(seg)) { + if (!p_include_locked_nodes && _is_node_locked(spat)) { continue; } - found_gizmos.insert(seg); - Vector3 point; - Vector3 normal; + Vector<Ref<Node3DGizmo>> gizmos = spat->get_gizmos(); + for (int j = 0; j < gizmos.size(); j++) { + Ref<EditorNode3DGizmo> seg = gizmos[j]; - int handle = -1; - bool inters = seg->intersect_ray(camera, p_pos, point, normal, nullptr, p_alt_select); + if (!seg.is_valid()) { + continue; + } - if (!inters) { - continue; - } + Vector3 point; + Vector3 normal; - float dist = pos.distance_to(point); + bool inters = seg->intersect_ray(camera, p_pos, point, normal); - if (dist < 0) { - continue; - } + if (!inters) { + continue; + } - if (editor_selection->is_selected(spat)) { - r_includes_current = true; - } + float dist = pos.distance_to(point); - _RayResult res; - res.item = spat; - res.depth = dist; - res.handle = handle; - results.push_back(res); - } + if (dist < 0) { + continue; + } - if (results.is_empty()) { - return; + found_nodes.insert(spat); + + _RayResult res; + res.item = spat; + res.depth = dist; + r_results.push_back(res); + break; + } } - results.sort(); + r_results.sort(); } Vector3 Node3DEditorViewport::_get_screen_to_space(const Vector3 &p_vector3) { @@ -652,6 +640,9 @@ Vector3 Node3DEditorViewport::_get_screen_to_space(const Vector3 &p_vector3) { void Node3DEditorViewport::_select_region() { if (cursor.region_begin == cursor.region_end) { + if (!clicked_wants_append) { + _clear_selected(); + } return; //nothing really } @@ -698,7 +689,66 @@ void Node3DEditorViewport::_select_region() { far.d += get_zfar(); frustum.push_back(far); + if (spatial_editor->get_single_selected_node()) { + Node3D *single_selected = spatial_editor->get_single_selected_node(); + Node3DEditorSelectedItem *se = editor_selection->get_node_editor_data<Node3DEditorSelectedItem>(single_selected); + + Ref<EditorNode3DGizmo> old_gizmo; + if (!clicked_wants_append) { + se->subgizmos.clear(); + old_gizmo = se->gizmo; + se->gizmo.unref(); + } + + bool found_subgizmos = false; + Vector<Ref<Node3DGizmo>> gizmos = single_selected->get_gizmos(); + for (int j = 0; j < gizmos.size(); j++) { + Ref<EditorNode3DGizmo> seg = gizmos[j]; + if (!seg.is_valid()) { + continue; + } + + if (se->gizmo.is_valid() && se->gizmo != seg) { + continue; + } + + Vector<int> subgizmos = seg->subgizmos_intersect_frustum(camera, frustum); + if (!subgizmos.is_empty()) { + se->gizmo = seg; + for (int i = 0; i < subgizmos.size(); i++) { + int subgizmo_id = subgizmos[i]; + if (!se->subgizmos.has(subgizmo_id)) { + se->subgizmos.insert(subgizmo_id, se->gizmo->get_subgizmo_transform(subgizmo_id)); + } + } + found_subgizmos = true; + break; + } + } + + if (!clicked_wants_append || found_subgizmos) { + if (se->gizmo.is_valid()) { + se->gizmo->redraw(); + } + + if (old_gizmo != se->gizmo && old_gizmo.is_valid()) { + old_gizmo->redraw(); + } + + spatial_editor->update_transform_gizmo(); + } + + if (found_subgizmos) { + return; + } + } + + if (!clicked_wants_append) { + _clear_selected(); + } + Vector<ObjectID> instances = RenderingServer::get_singleton()->instances_cull_convex(frustum, get_tree()->get_root()->get_world_3d()->get_scenario()); + Set<Node3D *> found_nodes; Vector<Node *> selected; Node *edited_scene = get_tree()->get_edited_scene_root(); @@ -709,6 +759,12 @@ void Node3DEditorViewport::_select_region() { continue; } + if (found_nodes.has(sp)) { + continue; + } + + found_nodes.insert(sp); + Node *item = Object::cast_to<Node>(sp); if (item != edited_scene) { item = edited_scene->get_deepest_editable_node(item); @@ -727,28 +783,31 @@ void Node3DEditorViewport::_select_region() { item = sel; } - if (selected.find(item) != -1) { - continue; - } - if (_is_node_locked(item)) { continue; } - Ref<EditorNode3DGizmo> seg = sp->get_gizmo(); + Vector<Ref<Node3DGizmo>> gizmos = sp->get_gizmos(); + for (int j = 0; j < gizmos.size(); j++) { + Ref<EditorNode3DGizmo> seg = gizmos[j]; + if (!seg.is_valid()) { + continue; + } - if (!seg.is_valid()) { - continue; + if (seg->intersect_frustum(camera, frustum)) { + selected.push_back(item); + } } + } - if (seg->intersect_frustum(camera, frustum)) { - selected.push_back(item); + for (int i = 0; i < selected.size(); i++) { + if (!editor_selection->is_selected(selected[i])) { + editor_selection->add_node(selected[i]); } } - bool single = selected.size() == 1; - for (int i = 0; i < selected.size(); i++) { - _select(selected[i], true, single); + if (editor_selection->get_selected_node_list().size() == 1) { + editor->edit_node(editor_selection->get_selected_node_list()[0]); } } @@ -775,21 +834,34 @@ void Node3DEditorViewport::_compute_edit(const Point2 &p_point) { spatial_editor->update_transform_gizmo(); _edit.center = spatial_editor->get_gizmo_transform().origin; - List<Node *> &selection = editor_selection->get_selected_node_list(); + Node3D *selected = spatial_editor->get_single_selected_node(); + Node3DEditorSelectedItem *se = selected ? editor_selection->get_node_editor_data<Node3DEditorSelectedItem>(selected) : nullptr; - for (List<Node *>::Element *E = selection.front(); E; E = E->next()) { - Node3D *sp = Object::cast_to<Node3D>(E->get()); - if (!sp) { - continue; + if (se && se->gizmo.is_valid()) { + for (Map<int, Transform3D>::Element *E = se->subgizmos.front(); E; E = E->next()) { + int subgizmo_id = E->key(); + se->subgizmos[subgizmo_id] = se->gizmo->get_subgizmo_transform(subgizmo_id); } + se->original_local = selected->get_transform(); + se->original = selected->get_global_transform(); + } else { + List<Node *> &selection = editor_selection->get_selected_node_list(); - Node3DEditorSelectedItem *se = editor_selection->get_node_editor_data<Node3DEditorSelectedItem>(sp); - if (!se) { - continue; - } + for (List<Node *>::Element *E = selection.front(); E; E = E->next()) { + Node3D *sp = Object::cast_to<Node3D>(E->get()); + if (!sp) { + continue; + } + + Node3DEditorSelectedItem *sel_item = editor_selection->get_node_editor_data<Node3DEditorSelectedItem>(sp); + + if (!sel_item) { + continue; + } - se->original = se->sp->get_global_gizmo_transform(); - se->original_local = se->sp->get_local_gizmo_transform(); + sel_item->original_local = sel_item->sp->get_local_gizmo_transform(); + sel_item->original = sel_item->sp->get_global_gizmo_transform(); + } } } @@ -825,7 +897,7 @@ static int _get_key_modifier(Ref<InputEventWithModifiers> e) { return 0; } -bool Node3DEditorViewport::_gizmo_select(const Vector2 &p_screenpos, bool p_highlight_only) { +bool Node3DEditorViewport::_transform_gizmo_select(const Vector2 &p_screenpos, bool p_highlight_only) { if (!spatial_editor->is_gizmo_visible()) { return false; } @@ -870,14 +942,18 @@ bool Node3DEditorViewport::_gizmo_select(const Vector2 &p_screenpos, bool p_high Vector3 ivec2 = gt.basis.get_axis((i + 1) % 3).normalized(); Vector3 ivec3 = gt.basis.get_axis((i + 2) % 3).normalized(); - Vector3 grabber_pos = gt.origin + (ivec2 + ivec3) * gs * (GIZMO_PLANE_SIZE + GIZMO_PLANE_DST); + // Allow some tolerance to make the plane easier to click, + // even if the click is actually slightly outside the plane. + const Vector3 grabber_pos = gt.origin + (ivec2 + ivec3) * gs * (GIZMO_PLANE_SIZE + GIZMO_PLANE_DST * 0.6667); Vector3 r; Plane plane(gt.origin, gt.basis.get_axis(i).normalized()); if (plane.intersects_ray(ray_pos, ray, &r)) { float dist = r.distance_to(grabber_pos); - if (dist < (gs * GIZMO_PLANE_SIZE)) { + // Allow some tolerance to make the plane easier to click, + // even if the click is actually slightly outside the plane. + if (dist < (gs * GIZMO_PLANE_SIZE * 1.5)) { float d = ray_pos.distance_to(r); if (d < col_d) { col_d = d; @@ -970,14 +1046,18 @@ bool Node3DEditorViewport::_gizmo_select(const Vector2 &p_screenpos, bool p_high Vector3 ivec2 = gt.basis.get_axis((i + 1) % 3).normalized(); Vector3 ivec3 = gt.basis.get_axis((i + 2) % 3).normalized(); - Vector3 grabber_pos = gt.origin + (ivec2 + ivec3) * gs * (GIZMO_PLANE_SIZE + GIZMO_PLANE_DST); + // Allow some tolerance to make the plane easier to click, + // even if the click is actually slightly outside the plane. + Vector3 grabber_pos = gt.origin + (ivec2 + ivec3) * gs * (GIZMO_PLANE_SIZE + GIZMO_PLANE_DST * 0.6667); Vector3 r; Plane plane(gt.origin, gt.basis.get_axis(i).normalized()); if (plane.intersects_ray(ray_pos, ray, &r)) { float dist = r.distance_to(grabber_pos); - if (dist < (gs * GIZMO_PLANE_SIZE)) { + // Allow some tolerance to make the plane easier to click, + // even if the click is actually slightly outside the plane. + if (dist < (gs * GIZMO_PLANE_SIZE * 1.5)) { float d = ray_pos.distance_to(r); if (d < col_d) { col_d = d; @@ -1011,6 +1091,88 @@ bool Node3DEditorViewport::_gizmo_select(const Vector2 &p_screenpos, bool p_high return false; } +void Node3DEditorViewport::_transform_gizmo_apply(Node3D *p_node, const Transform3D &p_transform, bool p_local) { + if (p_transform.basis.determinant() == 0) { + return; + } + + if (p_local) { + p_node->set_transform(p_transform); + } else { + p_node->set_global_transform(p_transform); + } +} + +Transform3D Node3DEditorViewport::_compute_transform(TransformMode p_mode, const Transform3D &p_original, const Transform3D &p_original_local, Vector3 p_motion, double p_extra, bool p_local) { + switch (p_mode) { + case TRANSFORM_SCALE: { + if (p_local) { + Basis g = p_original.basis.orthonormalized(); + Vector3 local_motion = g.inverse().xform(p_motion); + + if (_edit.snap || spatial_editor->is_snap_enabled()) { + local_motion.snap(Vector3(p_extra, p_extra, p_extra)); + } + + Vector3 local_scale = p_original_local.basis.get_scale() * (local_motion + Vector3(1, 1, 1)); + Transform3D local_t = p_original_local; + local_t.basis.set_euler_scale(p_original_local.basis.get_rotation_euler(), local_scale); + return local_t; + } else { + Transform3D base = Transform3D(Basis(), _edit.center); + if (_edit.snap || spatial_editor->is_snap_enabled()) { + p_motion.snap(Vector3(p_extra, p_extra, p_extra)); + } + + Transform3D r; + r.basis.scale(p_motion + Vector3(1, 1, 1)); + return base * (r * (base.inverse() * p_original)); + } + } + case TRANSFORM_TRANSLATE: { + if (p_local) { + if (_edit.snap || spatial_editor->is_snap_enabled()) { + Basis g = p_original.basis.orthonormalized(); + Vector3 local_motion = g.inverse().xform(p_motion); + local_motion.snap(Vector3(p_extra, p_extra, p_extra)); + + p_motion = g.xform(local_motion); + } + + } else { + if (_edit.snap || spatial_editor->is_snap_enabled()) { + p_motion.snap(Vector3(p_extra, p_extra, p_extra)); + } + } + + // Apply translation + Transform3D t = p_original; + t.origin += p_motion; + return t; + } + case TRANSFORM_ROTATE: { + if (p_local) { + Basis rot = Basis(p_motion, p_extra); + + Vector3 scale = p_original_local.basis.get_scale(); + Vector3 euler = (p_original_local.get_basis().orthonormalized() * rot).get_euler(); + Transform3D t; + t.basis.set_euler_scale(euler, scale); + t.origin = p_original_local.origin; + return t; + } else { + Transform3D r; + r.basis.rotate(p_motion, p_extra); + Transform3D base = Transform3D(Basis(), _edit.center); + return base * r * base.inverse() * p_original; + } + } + default: { + ERR_FAIL_V_MSG(Transform3D(), "Invalid mode in '_compute_transform'"); + } + } +} + void Node3DEditorViewport::_surface_mouse_enter() { if (!surface->has_focus() && (!get_focus_owner() || !get_focus_owner()->is_text_field())) { surface->grab_focus(); @@ -1034,7 +1196,7 @@ bool Node3DEditorViewport ::_is_node_locked(const Node *p_node) { } void Node3DEditorViewport::_list_select(Ref<InputEventMouseButton> b) { - _find_items_at_pos(b->get_position(), clicked_includes_current, selection_results, b->is_shift_pressed()); + _find_items_at_pos(b->get_position(), selection_results, spatial_editor->get_tool_mode() == Node3DEditor::TOOL_MODE_SELECT); Node *scene = editor->get_edited_scene(); @@ -1054,10 +1216,8 @@ void Node3DEditorViewport::_list_select(Ref<InputEventMouseButton> b) { selection_results.clear(); if (clicked.is_valid()) { - _select_clicked(clicked_wants_append, true, spatial_editor->get_tool_mode() != Node3DEditor::TOOL_MODE_LIST_SELECT); - clicked = ObjectID(); + _select_clicked(spatial_editor->get_tool_mode() == Node3DEditor::TOOL_MODE_SELECT); } - } else if (!selection_results.is_empty()) { NodePath root_path = get_tree()->get_edited_scene_root()->get_path(); StringName root_name = root_path.get_name(root_path.get_name_count() - 1); @@ -1131,7 +1291,7 @@ void Node3DEditorViewport::_sinput(const Ref<InputEvent> &p_event) { Ref<InputEventMouseButton> b = p_event; if (b.is_valid()) { - emit_signal("clicked", this); + emit_signal(SNAME("clicked"), this); float zoom_factor = 1 + (ZOOM_FREELOOK_MULTIPLIER - 1) * b->get_factor(); switch (b->get_button_index()) { @@ -1175,8 +1335,8 @@ void Node3DEditorViewport::_sinput(const Ref<InputEvent> &p_event) { List<Node *> &selection = editor_selection->get_selected_node_list(); - for (List<Node *>::Element *E = selection.front(); E; E = E->next()) { - Node3D *sp = Object::cast_to<Node3D>(E->get()); + for (Node *E : selection) { + Node3D *sp = Object::cast_to<Node3D>(E); if (!sp) { continue; } @@ -1186,7 +1346,20 @@ void Node3DEditorViewport::_sinput(const Ref<InputEvent> &p_event) { continue; } - sp->set_global_transform(se->original); + if (se->gizmo.is_valid()) { + Vector<int> ids; + Vector<Transform3D> restore; + + for (Map<int, Transform3D>::Element *GE = se->subgizmos.front(); GE; GE = GE->next()) { + ids.push_back(GE->key()); + restore.push_back(GE->value()); + } + + se->gizmo->commit_subgizmos(ids, restore, true); + spatial_editor->update_transform_gizmo(); + } else { + sp->set_global_transform(se->original); + } } surface->update(); set_message(TTR("Transform Aborted."), 3); @@ -1258,37 +1431,92 @@ void Node3DEditorViewport::_sinput(const Ref<InputEvent> &p_event) { _edit.snap = spatial_editor->is_snap_enabled(); _edit.mode = TRANSFORM_NONE; - //gizmo has priority over everything - - bool can_select_gizmos = true; + bool can_select_gizmos = spatial_editor->get_single_selected_node(); { int idx = view_menu->get_popup()->get_item_index(VIEW_GIZMOS); - can_select_gizmos = view_menu->get_popup()->is_item_checked(idx); + can_select_gizmos = can_select_gizmos && view_menu->get_popup()->is_item_checked(idx); } - if (can_select_gizmos && spatial_editor->get_selected()) { - Ref<EditorNode3DGizmo> seg = spatial_editor->get_selected()->get_gizmo(); - if (seg.is_valid()) { - int handle = -1; - Vector3 point; - Vector3 normal; - bool inters = seg->intersect_ray(camera, _edit.mouse_pos, point, normal, &handle, b->is_shift_pressed()); - if (inters && handle != -1) { + // Gizmo handles + if (can_select_gizmos) { + Vector<Ref<Node3DGizmo>> gizmos = spatial_editor->get_single_selected_node()->get_gizmos(); + + bool intersected_handle = false; + for (int i = 0; i < gizmos.size(); i++) { + Ref<EditorNode3DGizmo> seg = gizmos[i]; + + if ((!seg.is_valid())) { + continue; + } + + int gizmo_handle = -1; + seg->handles_intersect_ray(camera, _edit.mouse_pos, b->is_shift_pressed(), gizmo_handle); + if (gizmo_handle != -1) { _edit.gizmo = seg; - _edit.gizmo_handle = handle; - _edit.gizmo_initial_value = seg->get_handle_value(handle); + _edit.gizmo_handle = gizmo_handle; + _edit.gizmo_initial_value = seg->get_handle_value(gizmo_handle); + intersected_handle = true; break; } } + + if (intersected_handle) { + break; + } } - if (_gizmo_select(_edit.mouse_pos)) { + // Transform gizmo + if (_transform_gizmo_select(_edit.mouse_pos)) { break; } + // Subgizmos + if (can_select_gizmos) { + Node3DEditorSelectedItem *se = editor_selection->get_node_editor_data<Node3DEditorSelectedItem>(spatial_editor->get_single_selected_node()); + Vector<Ref<Node3DGizmo>> gizmos = spatial_editor->get_single_selected_node()->get_gizmos(); + + bool intersected_subgizmo = false; + for (int i = 0; i < gizmos.size(); i++) { + Ref<EditorNode3DGizmo> seg = gizmos[i]; + + if ((!seg.is_valid())) { + continue; + } + + int subgizmo_id = seg->subgizmos_intersect_ray(camera, _edit.mouse_pos); + if (subgizmo_id != -1) { + ERR_CONTINUE(!se); + if (b->is_shift_pressed()) { + if (se->subgizmos.has(subgizmo_id)) { + se->subgizmos.erase(subgizmo_id); + } else { + se->subgizmos.insert(subgizmo_id, seg->get_subgizmo_transform(subgizmo_id)); + } + } else { + se->subgizmos.clear(); + se->subgizmos.insert(subgizmo_id, seg->get_subgizmo_transform(subgizmo_id)); + } + + if (se->subgizmos.is_empty()) { + se->gizmo = Ref<EditorNode3DGizmo>(); + } else { + se->gizmo = seg; + } + + seg->redraw(); + spatial_editor->update_transform_gizmo(); + intersected_subgizmo = true; + break; + } + } + + if (intersected_subgizmo) { + break; + } + } + clicked = ObjectID(); - clicked_includes_current = false; if ((spatial_editor->get_tool_mode() == Node3DEditor::TOOL_MODE_SELECT && b->is_command_pressed()) || spatial_editor->get_tool_mode() == Node3DEditor::TOOL_MODE_ROTATE) { /* HANDLE ROTATION */ @@ -1321,40 +1549,19 @@ void Node3DEditorViewport::_sinput(const Ref<InputEvent> &p_event) { break; } - // todo scale - - int gizmo_handle = -1; - - clicked = _select_ray(b->get_position(), b->is_shift_pressed(), clicked_includes_current, &gizmo_handle, b->is_shift_pressed()); + clicked = _select_ray(b->get_position()); //clicking is always deferred to either move or release clicked_wants_append = b->is_shift_pressed(); if (clicked.is_null()) { - if (!clicked_wants_append) { - _clear_selected(); - } - //default to regionselect cursor.region_select = true; cursor.region_begin = b->get_position(); cursor.region_end = b->get_position(); } - if (clicked.is_valid() && gizmo_handle >= 0) { - Node3D *spa = Object::cast_to<Node3D>(ObjectDB::get_instance(clicked)); - if (spa) { - Ref<EditorNode3DGizmo> seg = spa->get_gizmo(); - if (seg.is_valid()) { - _edit.gizmo = seg; - _edit.gizmo_handle = gizmo_handle; - _edit.gizmo_initial_value = seg->get_handle_value(gizmo_handle); - break; - } - } - } - surface->update(); } else { if (_edit.gizmo.is_valid()) { @@ -1362,47 +1569,63 @@ void Node3DEditorViewport::_sinput(const Ref<InputEvent> &p_event) { _edit.gizmo = Ref<EditorNode3DGizmo>(); break; } + if (clicked.is_valid()) { - _select_clicked(clicked_wants_append, true); - // Processing was deferred. - clicked = ObjectID(); + _select_clicked(false); } if (cursor.region_select) { - if (!clicked_wants_append) { - _clear_selected(); - } - _select_region(); cursor.region_select = false; surface->update(); } if (_edit.mode != TRANSFORM_NONE) { - static const char *_transform_name[4] = { "None", "Rotate", "Translate", "Scale" }; - undo_redo->create_action(_transform_name[_edit.mode]); + Node3D *selected = spatial_editor->get_single_selected_node(); + Node3DEditorSelectedItem *se = selected ? editor_selection->get_node_editor_data<Node3DEditorSelectedItem>(selected) : nullptr; - List<Node *> &selection = editor_selection->get_selected_node_list(); + if (se && se->gizmo.is_valid()) { + Vector<int> ids; + Vector<Transform3D> restore; - for (List<Node *>::Element *E = selection.front(); E; E = E->next()) { - Node3D *sp = Object::cast_to<Node3D>(E->get()); - if (!sp) { - continue; + for (Map<int, Transform3D>::Element *GE = se->subgizmos.front(); GE; GE = GE->next()) { + ids.push_back(GE->key()); + restore.push_back(GE->value()); } - Node3DEditorSelectedItem *se = editor_selection->get_node_editor_data<Node3DEditorSelectedItem>(sp); - if (!se) { - continue; - } + se->gizmo->commit_subgizmos(ids, restore, false); + spatial_editor->update_transform_gizmo(); + } else { + static const char *_transform_name[4] = { + TTRC("None"), + TTRC("Rotate"), + // TRANSLATORS: This refers to the movement that changes the position of an object. + TTRC("Translate"), + TTRC("Scale"), + }; + undo_redo->create_action(TTRGET(_transform_name[_edit.mode])); + + List<Node *> &selection = editor_selection->get_selected_node_list(); + + for (List<Node *>::Element *E = selection.front(); E; E = E->next()) { + Node3D *sp = Object::cast_to<Node3D>(E->get()); + if (!sp) { + continue; + } + + Node3DEditorSelectedItem *sel_item = editor_selection->get_node_editor_data<Node3DEditorSelectedItem>(sp); + if (!sel_item) { + continue; + } - undo_redo->add_do_method(sp, "set_global_transform", sp->get_global_gizmo_transform()); - undo_redo->add_undo_method(sp, "set_global_transform", se->original); + undo_redo->add_do_method(sp, "set_global_transform", sp->get_global_gizmo_transform()); + undo_redo->add_undo_method(sp, "set_global_transform", sel_item->original); + } + undo_redo->commit_action(); } - undo_redo->commit_action(); _edit.mode = TRANSFORM_NONE; set_message(""); } - surface->update(); } @@ -1417,31 +1640,39 @@ void Node3DEditorViewport::_sinput(const Ref<InputEvent> &p_event) { if (m.is_valid()) { _edit.mouse_pos = m->get_position(); - if (spatial_editor->get_selected()) { - Ref<EditorNode3DGizmo> seg = spatial_editor->get_selected()->get_gizmo(); - if (seg.is_valid()) { - int selected_handle = -1; - - int handle = -1; - Vector3 point; - Vector3 normal; - bool inters = seg->intersect_ray(camera, _edit.mouse_pos, point, normal, &handle, false); - if (inters && handle != -1) { - selected_handle = handle; + if (spatial_editor->get_single_selected_node()) { + Vector<Ref<Node3DGizmo>> gizmos = spatial_editor->get_single_selected_node()->get_gizmos(); + + Ref<EditorNode3DGizmo> found_gizmo; + int found_handle = -1; + + for (int i = 0; i < gizmos.size(); i++) { + Ref<EditorNode3DGizmo> seg = gizmos[i]; + if (!seg.is_valid()) { + continue; } - if (selected_handle != spatial_editor->get_over_gizmo_handle()) { - spatial_editor->set_over_gizmo_handle(selected_handle); - spatial_editor->get_selected()->update_gizmo(); - if (selected_handle != -1) { - spatial_editor->select_gizmo_highlight_axis(-1); - } + seg->handles_intersect_ray(camera, _edit.mouse_pos, false, found_handle); + + if (found_handle != -1) { + found_gizmo = seg; + break; } } + + if (found_gizmo.is_valid()) { + spatial_editor->select_gizmo_highlight_axis(-1); + } + + if (found_gizmo != spatial_editor->get_current_hover_gizmo() || found_handle != spatial_editor->get_current_hover_gizmo_handle()) { + spatial_editor->set_current_hover_gizmo(found_gizmo); + spatial_editor->set_current_hover_gizmo_handle(found_handle); + spatial_editor->get_single_selected_node()->update_gizmos(); + } } - if (spatial_editor->get_over_gizmo_handle() == -1 && !(m->get_button_mask() & 1) && !_edit.gizmo.is_valid()) { - _gizmo_select(_edit.mouse_pos, true); + if (spatial_editor->get_current_hover_gizmo().is_null() && !(m->get_button_mask() & 1) && !_edit.gizmo.is_valid()) { + _transform_gizmo_select(_edit.mouse_pos, true); } NavigationScheme nav_scheme = (NavigationScheme)EditorSettings::get_singleton()->get("editors/3d/navigation/navigation_scheme").operator int(); @@ -1463,13 +1694,8 @@ void Node3DEditorViewport::_sinput(const Ref<InputEvent> &p_event) { } else if (nav_scheme == NAVIGATION_MODO && m->is_alt_pressed()) { nav_mode = NAVIGATION_ORBIT; } else { - bool movement_threshold_passed = _edit.original_mouse_pos.distance_to(_edit.mouse_pos) > 10 * EDSCALE; + const bool movement_threshold_passed = _edit.original_mouse_pos.distance_to(_edit.mouse_pos) > 8 * EDSCALE; if (clicked.is_valid() && movement_threshold_passed) { - if (!clicked_includes_current) { - _select_clicked(clicked_wants_append, true); - // Processing was deferred. - } - _compute_edit(_edit.mouse_pos); clicked = ObjectID(); @@ -1564,8 +1790,6 @@ void Node3DEditorViewport::_sinput(const Ref<InputEvent> &p_event) { motion = Vector3(scale, scale, scale); } - List<Node *> &selection = editor_selection->get_selected_node_list(); - // Disable local transformation for TRANSFORM_VIEW bool local_coords = (spatial_editor->are_local_coords_enabled() && _edit.plane != TRANSFORM_VIEW); @@ -1578,8 +1802,9 @@ void Node3DEditorViewport::_sinput(const Ref<InputEvent> &p_event) { set_message(TTR("Scaling: ") + "(" + String::num(motion_snapped.x, snap_step_decimals) + ", " + String::num(motion_snapped.y, snap_step_decimals) + ", " + String::num(motion_snapped.z, snap_step_decimals) + ")"); - for (List<Node *>::Element *E = selection.front(); E; E = E->next()) { - Node3D *sp = Object::cast_to<Node3D>(E->get()); + List<Node *> &selection = editor_selection->get_selected_node_list(); + for (Node *E : selection) { + Node3D *sp = Object::cast_to<Node3D>(E); if (!sp) { continue; } @@ -1593,44 +1818,22 @@ void Node3DEditorViewport::_sinput(const Ref<InputEvent> &p_event) { continue; } - Transform3D original = se->original; - Transform3D original_local = se->original_local; - Transform3D base = Transform3D(Basis(), _edit.center); - Transform3D t; - Vector3 local_scale; - - if (local_coords) { - Basis g = original.basis.orthonormalized(); - Vector3 local_motion = g.inverse().xform(motion); - - if (_edit.snap || spatial_editor->is_snap_enabled()) { - local_motion.snap(Vector3(snap, snap, snap)); + if (se->gizmo.is_valid()) { + for (Map<int, Transform3D>::Element *GE = se->subgizmos.front(); GE; GE = GE->next()) { + Transform3D xform = GE->get(); + Transform3D new_xform = _compute_transform(TRANSFORM_SCALE, se->original * xform, xform, motion, snap, local_coords); + if (!local_coords) { + new_xform = se->original.affine_inverse() * new_xform; + } + se->gizmo->set_subgizmo_transform(GE->key(), new_xform); } - - local_scale = original_local.basis.get_scale() * (local_motion + Vector3(1, 1, 1)); - - // Prevent scaling to 0 it would break the gizmo - Basis check = original_local.basis; - check.scale(local_scale); - if (check.determinant() != 0) { - // Apply scale - sp->set_scale(local_scale); - } - } else { - if (_edit.snap || spatial_editor->is_snap_enabled()) { - motion.snap(Vector3(snap, snap, snap)); - } - - Transform3D r; - r.basis.scale(motion + Vector3(1, 1, 1)); - t = base * (r * (base.inverse() * original)); - - // Apply scale - sp->set_global_transform(t); + Transform3D new_xform = _compute_transform(TRANSFORM_SCALE, se->original, se->original_local, motion, snap, local_coords); + _transform_gizmo_apply(se->sp, new_xform, local_coords); } } + spatial_editor->update_transform_gizmo(); surface->update(); } break; @@ -1687,8 +1890,6 @@ void Node3DEditorViewport::_sinput(const Ref<InputEvent> &p_event) { } } - List<Node *> &selection = editor_selection->get_selected_node_list(); - // Disable local transformation for TRANSFORM_VIEW bool local_coords = (spatial_editor->are_local_coords_enabled() && _edit.plane != TRANSFORM_VIEW); @@ -1700,8 +1901,9 @@ void Node3DEditorViewport::_sinput(const Ref<InputEvent> &p_event) { set_message(TTR("Translating: ") + "(" + String::num(motion_snapped.x, snap_step_decimals) + ", " + String::num(motion_snapped.y, snap_step_decimals) + ", " + String::num(motion_snapped.z, snap_step_decimals) + ")"); - for (List<Node *>::Element *E = selection.front(); E; E = E->next()) { - Node3D *sp = Object::cast_to<Node3D>(E->get()); + List<Node *> &selection = editor_selection->get_selected_node_list(); + for (Node *E : selection) { + Node3D *sp = Object::cast_to<Node3D>(E); if (!sp) { continue; } @@ -1715,30 +1917,20 @@ void Node3DEditorViewport::_sinput(const Ref<InputEvent> &p_event) { continue; } - Transform3D original = se->original; - Transform3D t; - - if (local_coords) { - if (_edit.snap || spatial_editor->is_snap_enabled()) { - Basis g = original.basis.orthonormalized(); - Vector3 local_motion = g.inverse().xform(motion); - local_motion.snap(Vector3(snap, snap, snap)); - - motion = g.xform(local_motion); + if (se->gizmo.is_valid()) { + for (Map<int, Transform3D>::Element *GE = se->subgizmos.front(); GE; GE = GE->next()) { + Transform3D xform = GE->get(); + Transform3D new_xform = _compute_transform(TRANSFORM_TRANSLATE, se->original * xform, xform, motion, snap, local_coords); + new_xform = se->original.affine_inverse() * new_xform; + se->gizmo->set_subgizmo_transform(GE->key(), new_xform); } - } else { - if (_edit.snap || spatial_editor->is_snap_enabled()) { - motion.snap(Vector3(snap, snap, snap)); - } + Transform3D new_xform = _compute_transform(TRANSFORM_TRANSLATE, se->original, se->original_local, motion, snap, local_coords); + _transform_gizmo_apply(se->sp, new_xform, false); } - - // Apply translation - t = original; - t.origin += motion; - sp->set_global_transform(t); } + spatial_editor->update_transform_gizmo(); surface->update(); } break; @@ -1792,12 +1984,11 @@ void Node3DEditorViewport::_sinput(const Ref<InputEvent> &p_event) { set_message(vformat(TTR("Rotating %s degrees."), String::num(angle, snap_step_decimals))); angle = Math::deg2rad(angle); - List<Node *> &selection = editor_selection->get_selected_node_list(); - bool local_coords = (spatial_editor->are_local_coords_enabled() && _edit.plane != TRANSFORM_VIEW); // Disable local transformation for TRANSFORM_VIEW - for (List<Node *>::Element *E = selection.front(); E; E = E->next()) { - Node3D *sp = Object::cast_to<Node3D>(E->get()); + List<Node *> &selection = editor_selection->get_selected_node_list(); + for (Node *E : selection) { + Node3D *sp = Object::cast_to<Node3D>(E); if (!sp) { continue; } @@ -1811,32 +2002,24 @@ void Node3DEditorViewport::_sinput(const Ref<InputEvent> &p_event) { continue; } - Transform3D t; - - if (local_coords) { - Transform3D original_local = se->original_local; - Basis rot = Basis(axis, angle); - - t.basis = original_local.get_basis().orthonormalized() * rot; - t.origin = original_local.origin; - - // Apply rotation - sp->set_transform(t); - sp->set_scale(original_local.basis.get_scale()); // re-apply original scale + Vector3 compute_axis = local_coords ? axis : plane.normal; + if (se->gizmo.is_valid()) { + for (Map<int, Transform3D>::Element *GE = se->subgizmos.front(); GE; GE = GE->next()) { + Transform3D xform = GE->get(); + Transform3D new_xform = _compute_transform(TRANSFORM_ROTATE, se->original * xform, xform, compute_axis, angle, local_coords); + if (!local_coords) { + new_xform = se->original.affine_inverse() * new_xform; + } + se->gizmo->set_subgizmo_transform(GE->key(), new_xform); + } } else { - Transform3D original = se->original; - Transform3D r; - Transform3D base = Transform3D(Basis(), _edit.center); - - r.basis.rotate(plane.normal, angle); - t = base * r * base.inverse() * original; - - // Apply rotation - sp->set_global_transform(t); + Transform3D new_xform = _compute_transform(TRANSFORM_ROTATE, se->original, se->original_local, compute_axis, angle, local_coords); + _transform_gizmo_apply(se->sp, new_xform, local_coords); } } + spatial_editor->update_transform_gizmo(); surface->update(); } break; @@ -2035,13 +2218,13 @@ void Node3DEditorViewport::_sinput(const Ref<InputEvent> &p_event) { List<Node *> &selection = editor_selection->get_selected_node_list(); - for (List<Node *>::Element *E = selection.front(); E; E = E->next()) { - Node3D *sp = Object::cast_to<Node3D>(E->get()); + for (Node *E : selection) { + Node3D *sp = Object::cast_to<Node3D>(E); if (!sp) { continue; } - spatial_editor->emit_signal("transform_key_request", sp, "", sp->get_transform()); + spatial_editor->emit_signal(SNAME("transform_key_request"), sp, "", sp->get_transform()); } set_message(TTR("Animation Key Inserted.")); @@ -2057,7 +2240,7 @@ void Node3DEditorViewport::_sinput(const Ref<InputEvent> &p_event) { if (k->get_keycode() == KEY_SPACE) { if (!k->is_pressed()) { - emit_signal("toggle_maximize_view", this); + emit_signal(SNAME("toggle_maximize_view"), this); } } } @@ -2411,12 +2594,12 @@ void Node3DEditorViewport::_notification(int p_what) { } else { set_freelook_active(false); } - call_deferred("update_transform_gizmo_view"); + call_deferred(SNAME("update_transform_gizmo_view")); rotation_control->set_visible(EditorSettings::get_singleton()->get("editors/3d/navigation/show_viewport_rotation_gizmo")); } if (p_what == NOTIFICATION_RESIZED) { - call_deferred("update_transform_gizmo_view"); + call_deferred(SNAME("update_transform_gizmo_view")); } if (p_what == NOTIFICATION_PROCESS) { @@ -2434,7 +2617,7 @@ void Node3DEditorViewport::_notification(int p_what) { Node *scene_root = editor->get_scene_tree_dock()->get_editor_data()->get_edited_scene_root(); if (previewing_cinema && scene_root != nullptr) { - Camera3D *cam = scene_root->get_viewport()->get_camera(); + Camera3D *cam = scene_root->get_viewport()->get_camera_3d(); if (cam != nullptr && cam != previewing) { //then switch the viewport's camera to the scene's viewport camera if (previewing != nullptr) { @@ -2629,31 +2812,31 @@ void Node3DEditorViewport::_notification(int p_what) { } if (p_what == NOTIFICATION_THEME_CHANGED) { - view_menu->set_icon(get_theme_icon("GuiTabMenuHl", "EditorIcons")); - preview_camera->set_icon(get_theme_icon("Camera3D", "EditorIcons")); + view_menu->set_icon(get_theme_icon(SNAME("GuiTabMenuHl"), SNAME("EditorIcons"))); + preview_camera->set_icon(get_theme_icon(SNAME("Camera3D"), SNAME("EditorIcons"))); - view_menu->add_theme_style_override("normal", editor->get_gui_base()->get_theme_stylebox("Information3dViewport", "EditorStyles")); - view_menu->add_theme_style_override("hover", editor->get_gui_base()->get_theme_stylebox("Information3dViewport", "EditorStyles")); - view_menu->add_theme_style_override("pressed", editor->get_gui_base()->get_theme_stylebox("Information3dViewport", "EditorStyles")); - view_menu->add_theme_style_override("focus", editor->get_gui_base()->get_theme_stylebox("Information3dViewport", "EditorStyles")); - view_menu->add_theme_style_override("disabled", editor->get_gui_base()->get_theme_stylebox("Information3dViewport", "EditorStyles")); + view_menu->add_theme_style_override("normal", editor->get_gui_base()->get_theme_stylebox(SNAME("Information3dViewport"), SNAME("EditorStyles"))); + view_menu->add_theme_style_override("hover", editor->get_gui_base()->get_theme_stylebox(SNAME("Information3dViewport"), SNAME("EditorStyles"))); + view_menu->add_theme_style_override("pressed", editor->get_gui_base()->get_theme_stylebox(SNAME("Information3dViewport"), SNAME("EditorStyles"))); + view_menu->add_theme_style_override("focus", editor->get_gui_base()->get_theme_stylebox(SNAME("Information3dViewport"), SNAME("EditorStyles"))); + view_menu->add_theme_style_override("disabled", editor->get_gui_base()->get_theme_stylebox(SNAME("Information3dViewport"), SNAME("EditorStyles"))); - preview_camera->add_theme_style_override("normal", editor->get_gui_base()->get_theme_stylebox("Information3dViewport", "EditorStyles")); - preview_camera->add_theme_style_override("hover", editor->get_gui_base()->get_theme_stylebox("Information3dViewport", "EditorStyles")); - preview_camera->add_theme_style_override("pressed", editor->get_gui_base()->get_theme_stylebox("Information3dViewport", "EditorStyles")); - preview_camera->add_theme_style_override("focus", editor->get_gui_base()->get_theme_stylebox("Information3dViewport", "EditorStyles")); - preview_camera->add_theme_style_override("disabled", editor->get_gui_base()->get_theme_stylebox("Information3dViewport", "EditorStyles")); + preview_camera->add_theme_style_override("normal", editor->get_gui_base()->get_theme_stylebox(SNAME("Information3dViewport"), SNAME("EditorStyles"))); + preview_camera->add_theme_style_override("hover", editor->get_gui_base()->get_theme_stylebox(SNAME("Information3dViewport"), SNAME("EditorStyles"))); + preview_camera->add_theme_style_override("pressed", editor->get_gui_base()->get_theme_stylebox(SNAME("Information3dViewport"), SNAME("EditorStyles"))); + preview_camera->add_theme_style_override("focus", editor->get_gui_base()->get_theme_stylebox(SNAME("Information3dViewport"), SNAME("EditorStyles"))); + preview_camera->add_theme_style_override("disabled", editor->get_gui_base()->get_theme_stylebox(SNAME("Information3dViewport"), SNAME("EditorStyles"))); - frame_time_gradient->set_color(0, get_theme_color("success_color", "Editor")); - frame_time_gradient->set_color(1, get_theme_color("warning_color", "Editor")); - frame_time_gradient->set_color(2, get_theme_color("error_color", "Editor")); + frame_time_gradient->set_color(0, get_theme_color(SNAME("success_color"), SNAME("Editor"))); + frame_time_gradient->set_color(1, get_theme_color(SNAME("warning_color"), SNAME("Editor"))); + frame_time_gradient->set_color(2, get_theme_color(SNAME("error_color"), SNAME("Editor"))); - info_label->add_theme_style_override("normal", editor->get_gui_base()->get_theme_stylebox("Information3dViewport", "EditorStyles")); - cpu_time_label->add_theme_style_override("normal", editor->get_gui_base()->get_theme_stylebox("Information3dViewport", "EditorStyles")); - gpu_time_label->add_theme_style_override("normal", editor->get_gui_base()->get_theme_stylebox("Information3dViewport", "EditorStyles")); - fps_label->add_theme_style_override("normal", editor->get_gui_base()->get_theme_stylebox("Information3dViewport", "EditorStyles")); - cinema_label->add_theme_style_override("normal", editor->get_gui_base()->get_theme_stylebox("Information3dViewport", "EditorStyles")); - locked_label->add_theme_style_override("normal", editor->get_gui_base()->get_theme_stylebox("Information3dViewport", "EditorStyles")); + info_label->add_theme_style_override("normal", editor->get_gui_base()->get_theme_stylebox(SNAME("Information3dViewport"), SNAME("EditorStyles"))); + cpu_time_label->add_theme_style_override("normal", editor->get_gui_base()->get_theme_stylebox(SNAME("Information3dViewport"), SNAME("EditorStyles"))); + gpu_time_label->add_theme_style_override("normal", editor->get_gui_base()->get_theme_stylebox(SNAME("Information3dViewport"), SNAME("EditorStyles"))); + fps_label->add_theme_style_override("normal", editor->get_gui_base()->get_theme_stylebox(SNAME("Information3dViewport"), SNAME("EditorStyles"))); + cinema_label->add_theme_style_override("normal", editor->get_gui_base()->get_theme_stylebox(SNAME("Information3dViewport"), SNAME("EditorStyles"))); + locked_label->add_theme_style_override("normal", editor->get_gui_base()->get_theme_stylebox(SNAME("Information3dViewport"), SNAME("EditorStyles"))); } } @@ -2694,7 +2877,7 @@ void Node3DEditorViewport::_draw() { if (surface->has_focus()) { Size2 size = surface->get_size(); Rect2 r = Rect2(Point2(), size); - get_theme_stylebox("Focus", "EditorStyles")->draw(surface->get_canvas_item(), r); + get_theme_stylebox(SNAME("FocusViewport"), SNAME("EditorStyles"))->draw(surface->get_canvas_item(), r); } if (cursor.region_select) { @@ -2702,11 +2885,11 @@ void Node3DEditorViewport::_draw() { surface->draw_rect( selection_rect, - get_theme_color("box_selection_fill_color", "Editor")); + get_theme_color(SNAME("box_selection_fill_color"), SNAME("Editor"))); surface->draw_rect( selection_rect, - get_theme_color("box_selection_stroke_color", "Editor"), + get_theme_color(SNAME("box_selection_stroke_color"), SNAME("Editor")), false, Math::round(EDSCALE)); } @@ -2714,8 +2897,8 @@ void Node3DEditorViewport::_draw() { RID ci = surface->get_canvas_item(); if (message_time > 0) { - Ref<Font> font = get_theme_font("font", "Label"); - int font_size = get_theme_font_size("font_size", "Label"); + Ref<Font> font = get_theme_font(SNAME("font"), SNAME("Label")); + int font_size = get_theme_font_size(SNAME("font_size"), SNAME("Label")); Point2 msgpos = Point2(5, get_size().y - 20); font->draw_string(ci, msgpos + Point2(1, 1), message, HALIGN_LEFT, -1, font_size, Color(0, 0, 0, 0.8)); font->draw_string(ci, msgpos + Point2(-1, -1), message, HALIGN_LEFT, -1, font_size, Color(0, 0, 0, 0.8)); @@ -2728,21 +2911,19 @@ void Node3DEditorViewport::_draw() { Color handle_color; switch (_edit.plane) { case TRANSFORM_X_AXIS: - handle_color = get_theme_color("axis_x_color", "Editor"); + handle_color = get_theme_color(SNAME("axis_x_color"), SNAME("Editor")); break; case TRANSFORM_Y_AXIS: - handle_color = get_theme_color("axis_y_color", "Editor"); + handle_color = get_theme_color(SNAME("axis_y_color"), SNAME("Editor")); break; case TRANSFORM_Z_AXIS: - handle_color = get_theme_color("axis_z_color", "Editor"); + handle_color = get_theme_color(SNAME("axis_z_color"), SNAME("Editor")); break; default: - handle_color = get_theme_color("accent_color", "Editor"); + handle_color = get_theme_color(SNAME("accent_color"), SNAME("Editor")); break; } - handle_color.a = 1.0; - const float brightness = 1.3; - handle_color *= Color(brightness, brightness, brightness); + handle_color = handle_color.from_hsv(handle_color.get_h(), 0.25, 1.0, 1); RenderingServer::get_singleton()->canvas_item_add_line( ci, @@ -2794,9 +2975,9 @@ void Node3DEditorViewport::_draw() { draw_indicator_bar( *surface, 1.0 - logscale_t, - get_theme_icon("ViewportSpeed", "EditorIcons"), - get_theme_font("font", "Label"), - get_theme_font_size("font_size", "Label"), + get_theme_icon(SNAME("ViewportSpeed"), SNAME("EditorIcons")), + get_theme_font(SNAME("font"), SNAME("Label")), + get_theme_font_size(SNAME("font_size"), SNAME("Label")), vformat("%s u/s", String::num(freelook_speed).pad_decimals(precision))); } @@ -2816,9 +2997,9 @@ void Node3DEditorViewport::_draw() { draw_indicator_bar( *surface, logscale_t, - get_theme_icon("ViewportZoom", "EditorIcons"), - get_theme_font("font", "Label"), - get_theme_font_size("font_size", "Label"), + get_theme_icon(SNAME("ViewportZoom"), SNAME("EditorIcons")), + get_theme_font(SNAME("font"), SNAME("Label")), + get_theme_font_size(SNAME("font_size"), SNAME("Label")), vformat("%s u", String::num(cursor.distance).pad_decimals(precision))); } } @@ -2901,8 +3082,8 @@ void Node3DEditorViewport::_menu_option(int p_option) { undo_redo->create_action(TTR("Align Transform with View")); - for (List<Node *>::Element *E = selection.front(); E; E = E->next()) { - Node3D *sp = Object::cast_to<Node3D>(E->get()); + for (Node *E : selection) { + Node3D *sp = Object::cast_to<Node3D>(E); if (!sp) { continue; } @@ -2937,8 +3118,8 @@ void Node3DEditorViewport::_menu_option(int p_option) { List<Node *> &selection = editor_selection->get_selected_node_list(); undo_redo->create_action(TTR("Align Rotation with View")); - for (List<Node *>::Element *E = selection.front(); E; E = E->next()) { - Node3D *sp = Object::cast_to<Node3D>(E->get()); + for (Node *E : selection) { + Node3D *sp = Object::cast_to<Node3D>(E); if (!sp) { continue; } @@ -2972,7 +3153,7 @@ void Node3DEditorViewport::_menu_option(int p_option) { view_menu->get_popup()->set_item_checked(view_menu->get_popup()->get_item_index(VIEW_ORTHOGONAL), false); orthogonal = false; auto_orthogonal = false; - call_deferred("update_transform_gizmo_view"); + call_deferred(SNAME("update_transform_gizmo_view")); _update_name(); } break; @@ -2981,7 +3162,7 @@ void Node3DEditorViewport::_menu_option(int p_option) { view_menu->get_popup()->set_item_checked(view_menu->get_popup()->get_item_index(VIEW_ORTHOGONAL), true); orthogonal = true; auto_orthogonal = false; - call_deferred("update_transform_gizmo_view"); + call_deferred(SNAME("update_transform_gizmo_view")); _update_name(); } break; @@ -3306,8 +3487,7 @@ void Node3DEditorViewport::_selection_result_pressed(int p_result) { clicked = selection_results[p_result].item->get_instance_id(); if (clicked.is_valid()) { - _select_clicked(clicked_wants_append, true, spatial_editor->get_tool_mode() != Node3DEditor::TOOL_MODE_LIST_SELECT); - clicked = ObjectID(); + _select_clicked(spatial_editor->get_tool_mode() == Node3DEditor::TOOL_MODE_SELECT); } } @@ -3334,7 +3514,7 @@ void Node3DEditorViewport::update_transform_gizmo_view() { Transform3D camera_xform = camera->get_transform(); - if (xform.origin.distance_squared_to(camera_xform.origin) < 0.01) { + if (xform.origin.is_equal_approx(camera_xform.origin)) { for (int i = 0; i < 3; i++) { RenderingServer::get_singleton()->instance_set_visible(move_gizmo_instance[i], false); RenderingServer::get_singleton()->instance_set_visible(move_plane_gizmo_instance[i], false); @@ -3591,8 +3771,8 @@ void Node3DEditorViewport::focus_selection() { List<Node *> &selection = editor_selection->get_selected_node_list(); - for (List<Node *>::Element *E = selection.front(); E; E = E->next()) { - Node3D *sp = Object::cast_to<Node3D>(E->get()); + for (Node *E : selection) { + Node3D *sp = Object::cast_to<Node3D>(E); if (!sp) { continue; } @@ -3602,6 +3782,13 @@ void Node3DEditorViewport::focus_selection() { continue; } + if (se->gizmo.is_valid()) { + for (Map<int, Transform3D>::Element *GE = se->subgizmos.front(); GE; GE = GE->next()) { + center += se->gizmo->get_subgizmo_transform(GE->key()).origin; + count++; + } + } + center += sp->get_global_gizmo_transform().origin; count++; } @@ -3625,58 +3812,16 @@ Vector3 Node3DEditorViewport::_get_instance_position(const Point2 &p_pos) const Vector3 world_ray = _get_ray(p_pos); Vector3 world_pos = _get_ray_pos(p_pos); - Vector<ObjectID> instances = RenderingServer::get_singleton()->instances_cull_ray(world_pos, world_ray, get_tree()->get_root()->get_world_3d()->get_scenario()); - Set<Ref<EditorNode3DGizmo>> found_gizmos; - - float closest_dist = MAX_DISTANCE; - Vector3 point = world_pos + world_ray * MAX_DISTANCE; - Vector3 normal = Vector3(0.0, 0.0, 0.0); - - for (int i = 0; i < instances.size(); i++) { - MeshInstance3D *mesh_instance = Object::cast_to<MeshInstance3D>(ObjectDB::get_instance(instances[i])); - - if (!mesh_instance) { - continue; - } - - Ref<EditorNode3DGizmo> seg = mesh_instance->get_gizmo(); - - if ((!seg.is_valid()) || found_gizmos.has(seg)) { - continue; - } - - found_gizmos.insert(seg); - - Vector3 hit_point; - Vector3 hit_normal; - bool inters = seg->intersect_ray(camera, p_pos, hit_point, hit_normal, nullptr, false); - - if (!inters) { - continue; - } - - float dist = world_pos.distance_to(hit_point); - if (dist < 0) { - continue; - } + PhysicsDirectSpaceState3D *ss = get_tree()->get_root()->get_world_3d()->get_direct_space_state(); + PhysicsDirectSpaceState3D::RayResult result; - if (dist < closest_dist) { - closest_dist = dist; - point = hit_point; - normal = hit_normal; - } + if (ss->intersect_ray(world_pos, world_pos + world_ray * MAX_DISTANCE, result)) { + point = result.position; } - Vector3 offset = Vector3(); - for (int i = 0; i < 3; i++) { - if (normal[i] > 0.0) { - offset[i] = (preview_bounds->get_size()[i] - (preview_bounds->get_size()[i] + preview_bounds->get_position()[i])); - } else if (normal[i] < 0.0) { - offset[i] = -(preview_bounds->get_size()[i] + preview_bounds->get_position()[i]); - } - } - return point + offset; + + return point; } AABB Node3DEditorViewport::_calculate_spatial_bounds(const Node3D *p_parent, bool p_exclude_top_level_transform) { @@ -3927,6 +4072,7 @@ void Node3DEditorViewport::drop_data_fw(const Point2 &p_point, const Variant &p_ } bool is_shift = Input::get_singleton()->is_key_pressed(KEY_SHIFT); + bool is_ctrl = Input::get_singleton()->is_key_pressed(KEY_CTRL); selected_files.clear(); Dictionary d = p_data; @@ -3934,29 +4080,32 @@ void Node3DEditorViewport::drop_data_fw(const Point2 &p_point, const Variant &p_ selected_files = d["files"]; } - List<Node *> list = editor->get_editor_selection()->get_selected_node_list(); - if (list.size() == 0) { - Node *root_node = editor->get_edited_scene(); + List<Node *> selected_nodes = editor->get_editor_selection()->get_selected_node_list(); + Node *root_node = editor->get_edited_scene(); + if (selected_nodes.size() == 1) { + Node *selected_node = selected_nodes[0]; + target_node = root_node; + if (is_ctrl) { + target_node = selected_node; + } else if (is_shift && selected_node != root_node) { + target_node = selected_node->get_parent(); + } + } else if (selected_nodes.size() == 0) { if (root_node) { - list.push_back(root_node); + target_node = root_node; } else { - accept->set_text(TTR("No parent to instance a child at.")); + accept->set_text(TTR("Cannot drag and drop into scene with no root node.")); accept->popup_centered(); _remove_preview(); return; } - } - if (list.size() != 1) { - accept->set_text(TTR("This operation requires a single selected node.")); + } else { + accept->set_text(TTR("Cannot drag and drop into multiple selected nodes.")); accept->popup_centered(); _remove_preview(); return; } - target_node = list[0]; - if (is_shift && target_node != editor->get_edited_scene()) { - target_node = target_node->get_parent(); - } drop_pos = p_point; _perform_drop_data(); @@ -3968,9 +4117,8 @@ Node3DEditorViewport::Node3DEditorViewport(Node3DEditor *p_spatial_editor, Edito _edit.mode = TRANSFORM_NONE; _edit.plane = TRANSFORM_VIEW; - _edit.edited_gizmo = 0; _edit.snap = true; - _edit.gizmo_handle = 0; + _edit.gizmo_handle = -1; index = p_index; editor = p_editor; @@ -3978,7 +4126,6 @@ Node3DEditorViewport::Node3DEditorViewport(Node3DEditor *p_spatial_editor, Edito editor_selection = editor->get_editor_selection(); undo_redo = editor->get_undo_redo(); - clicked_includes_current = false; orthogonal = false; auto_orthogonal = false; lock_rotation = false; @@ -4001,7 +4148,7 @@ Node3DEditorViewport::Node3DEditorViewport(Node3DEditor *p_spatial_editor, Edito surface->set_anchors_and_offsets_preset(Control::PRESET_WIDE); surface->set_clip_contents(true); camera = memnew(Camera3D); - camera->set_disable_gizmo(true); + camera->set_disable_gizmos(true); camera->set_cull_mask(((1 << 20) - 1) | (1 << (GIZMO_BASE_LAYER + p_index)) | (1 << GIZMO_EDIT_LAYER) | (1 << GIZMO_GRID_LAYER) | (1 << MISC_TOOL_LAYER)); viewport->add_child(camera); camera->make_current(); @@ -4130,6 +4277,7 @@ Node3DEditorViewport::Node3DEditorViewport(Node3DEditor *p_spatial_editor, Edito preview_camera = memnew(CheckBox); preview_camera->set_text(TTR("Preview")); + preview_camera->set_shortcut(ED_SHORTCUT("spatial_editor/toggle_camera_preview", TTR("Toggle Camera Preview"), KEY_MASK_CMD | KEY_P)); vbox->add_child(preview_camera); preview_camera->set_h_size_flags(0); preview_camera->hide(); @@ -4247,8 +4395,8 @@ void Node3DEditorViewportContainer::_gui_input(const Ref<InputEvent> &p_event) { if (mb->is_pressed()) { Vector2 size = get_size(); - int h_sep = get_theme_constant("separation", "HSplitContainer"); - int v_sep = get_theme_constant("separation", "VSplitContainer"); + int h_sep = get_theme_constant(SNAME("separation"), SNAME("HSplitContainer")); + int v_sep = get_theme_constant(SNAME("separation"), SNAME("VSplitContainer")); int mid_w = size.width * ratio_h; int mid_h = size.height * ratio_v; @@ -4293,8 +4441,8 @@ void Node3DEditorViewportContainer::_gui_input(const Ref<InputEvent> &p_event) { if (view == VIEW_USE_3_VIEWPORTS || view == VIEW_USE_3_VIEWPORTS_ALT || view == VIEW_USE_4_VIEWPORTS) { Vector2 size = get_size(); - int h_sep = get_theme_constant("separation", "HSplitContainer"); - int v_sep = get_theme_constant("separation", "VSplitContainer"); + int h_sep = get_theme_constant(SNAME("separation"), SNAME("HSplitContainer")); + int v_sep = get_theme_constant(SNAME("separation"), SNAME("VSplitContainer")); int mid_w = size.width * ratio_h; int mid_h = size.height * ratio_v; @@ -4333,18 +4481,18 @@ void Node3DEditorViewportContainer::_notification(int p_what) { } if (p_what == NOTIFICATION_DRAW && mouseover) { - Ref<Texture2D> h_grabber = get_theme_icon("grabber", "HSplitContainer"); - Ref<Texture2D> v_grabber = get_theme_icon("grabber", "VSplitContainer"); + Ref<Texture2D> h_grabber = get_theme_icon(SNAME("grabber"), SNAME("HSplitContainer")); + Ref<Texture2D> v_grabber = get_theme_icon(SNAME("grabber"), SNAME("VSplitContainer")); - Ref<Texture2D> hdiag_grabber = get_theme_icon("GuiViewportHdiagsplitter", "EditorIcons"); - Ref<Texture2D> vdiag_grabber = get_theme_icon("GuiViewportVdiagsplitter", "EditorIcons"); - Ref<Texture2D> vh_grabber = get_theme_icon("GuiViewportVhsplitter", "EditorIcons"); + Ref<Texture2D> hdiag_grabber = get_theme_icon(SNAME("GuiViewportHdiagsplitter"), SNAME("EditorIcons")); + Ref<Texture2D> vdiag_grabber = get_theme_icon(SNAME("GuiViewportVdiagsplitter"), SNAME("EditorIcons")); + Ref<Texture2D> vh_grabber = get_theme_icon(SNAME("GuiViewportVhsplitter"), SNAME("EditorIcons")); Vector2 size = get_size(); - int h_sep = get_theme_constant("separation", "HSplitContainer"); + int h_sep = get_theme_constant(SNAME("separation"), SNAME("HSplitContainer")); - int v_sep = get_theme_constant("separation", "VSplitContainer"); + int v_sep = get_theme_constant(SNAME("separation"), SNAME("VSplitContainer")); int mid_w = size.width * ratio_h; int mid_h = size.height * ratio_v; @@ -4430,9 +4578,9 @@ void Node3DEditorViewportContainer::_notification(int p_what) { } return; } - int h_sep = get_theme_constant("separation", "HSplitContainer"); + int h_sep = get_theme_constant(SNAME("separation"), SNAME("HSplitContainer")); - int v_sep = get_theme_constant("separation", "VSplitContainer"); + int v_sep = get_theme_constant(SNAME("separation"), SNAME("VSplitContainer")); int mid_w = size.width * ratio_h; int mid_h = size.height * ratio_v; @@ -4570,43 +4718,54 @@ void Node3DEditor::select_gizmo_highlight_axis(int p_axis) { } void Node3DEditor::update_transform_gizmo() { - List<Node *> &selection = editor_selection->get_selected_node_list(); - AABB center; - bool first = true; + int count = 0; + bool local_gizmo_coords = are_local_coords_enabled(); + Vector3 gizmo_center; Basis gizmo_basis; - bool local_gizmo_coords = are_local_coords_enabled(); - for (List<Node *>::Element *E = selection.front(); E; E = E->next()) { - Node3D *sp = Object::cast_to<Node3D>(E->get()); - if (!sp) { - continue; - } + Node3DEditorSelectedItem *se = selected ? editor_selection->get_node_editor_data<Node3DEditorSelectedItem>(selected) : nullptr; - Node3DEditorSelectedItem *se = editor_selection->get_node_editor_data<Node3DEditorSelectedItem>(sp); - if (!se) { - continue; + if (se && se->gizmo.is_valid()) { + for (Map<int, Transform3D>::Element *E = se->subgizmos.front(); E; E = E->next()) { + Transform3D xf = se->sp->get_global_transform() * se->gizmo->get_subgizmo_transform(E->key()); + gizmo_center += xf.origin; + if (count == 0 && local_gizmo_coords) { + gizmo_basis = xf.basis; + gizmo_basis.orthonormalize(); + } + count++; } + } else { + List<Node *> &selection = editor_selection->get_selected_node_list(); + for (List<Node *>::Element *E = selection.front(); E; E = E->next()) { + Node3D *sp = Object::cast_to<Node3D>(E->get()); + if (!sp) { + continue; + } + + if (sp->has_meta("_edit_lock_")) { + continue; + } - Transform3D xf = se->sp->get_global_gizmo_transform(); + Node3DEditorSelectedItem *sel_item = editor_selection->get_node_editor_data<Node3DEditorSelectedItem>(sp); + if (!sel_item) { + continue; + } - if (first) { - center.position = xf.origin; - first = false; - if (local_gizmo_coords) { + Transform3D xf = sel_item->sp->get_global_transform(); + gizmo_center += xf.origin; + if (count == 0 && local_gizmo_coords) { gizmo_basis = xf.basis; gizmo_basis.orthonormalize(); } - } else { - center.expand_to(xf.origin); - gizmo_basis = Basis(); + count++; } } - Vector3 pcenter = center.position + center.size * 0.5; - gizmo.visible = !first; - gizmo.transform.origin = pcenter; - gizmo.transform.basis = gizmo_basis; + gizmo.visible = count > 0; + gizmo.transform.origin = (count > 0) ? gizmo_center / count : Vector3(); + gizmo.transform.basis = (count == 1) ? gizmo_basis : Basis(); for (uint32_t i = 0; i < VIEWPORTS_COUNT; i++) { viewports[i]->update_transform_gizmo_view(); @@ -4617,7 +4776,7 @@ void _update_all_gizmos(Node *p_node) { for (int i = p_node->get_child_count() - 1; 0 <= i; --i) { Node3D *spatial_node = Object::cast_to<Node3D>(p_node->get_child(i)); if (spatial_node) { - spatial_node->update_gizmo(); + spatial_node->update_gizmos(); } _update_all_gizmos(p_node->get_child(i)); @@ -4651,7 +4810,9 @@ Object *Node3DEditor::_get_editor_data(Object *p_what) { RS::get_singleton()->instance_geometry_set_cast_shadows_setting( si->sbox_instance, RS::SHADOW_CASTING_SETTING_OFF); - RS::get_singleton()->instance_set_layer_mask(si->sbox_instance, 1 << Node3DEditorViewport::MISC_TOOL_LAYER); + // Use the Edit layer to hide the selection box when View Gizmos is disabled, since it is a bit distracting. + // It's still possible to approximately guess what is selected by looking at the manipulation gizmo position. + RS::get_singleton()->instance_set_layer_mask(si->sbox_instance, 1 << Node3DEditorViewport::GIZMO_EDIT_LAYER); RS::get_singleton()->instance_geometry_set_flag(si->sbox_instance, RS::INSTANCE_FLAG_IGNORE_OCCLUSION_CULLING, true); si->sbox_instance_xray = RenderingServer::get_singleton()->instance_create2( selection_box_xray->get_rid(), @@ -4659,7 +4820,9 @@ Object *Node3DEditor::_get_editor_data(Object *p_what) { RS::get_singleton()->instance_geometry_set_cast_shadows_setting( si->sbox_instance_xray, RS::SHADOW_CASTING_SETTING_OFF); - RS::get_singleton()->instance_set_layer_mask(si->sbox_instance_xray, 1 << Node3DEditorViewport::MISC_TOOL_LAYER); + // Use the Edit layer to hide the selection box when View Gizmos is disabled, since it is a bit distracting. + // It's still possible to approximately guess what is selected by looking at the manipulation gizmo position. + RS::get_singleton()->instance_set_layer_mask(si->sbox_instance_xray, 1 << Node3DEditorViewport::GIZMO_EDIT_LAYER); RS::get_singleton()->instance_geometry_set_flag(si->sbox_instance, RS::INSTANCE_FLAG_IGNORE_OCCLUSION_CULLING, true); return si; @@ -4936,22 +5099,38 @@ void Node3DEditor::set_state(const Dictionary &p_state) { void Node3DEditor::edit(Node3D *p_spatial) { if (p_spatial != selected) { if (selected) { - Ref<EditorNode3DGizmo> seg = selected->get_gizmo(); - if (seg.is_valid()) { + Vector<Ref<Node3DGizmo>> gizmos = selected->get_gizmos(); + for (int i = 0; i < gizmos.size(); i++) { + Ref<EditorNode3DGizmo> seg = gizmos[i]; + if (!seg.is_valid()) { + continue; + } seg->set_selected(false); - selected->update_gizmo(); } + + Node3DEditorSelectedItem *se = editor_selection->get_node_editor_data<Node3DEditorSelectedItem>(selected); + if (se) { + se->gizmo.unref(); + se->subgizmos.clear(); + } + + selected->update_gizmos(); } selected = p_spatial; - over_gizmo_handle = -1; + current_hover_gizmo = Ref<EditorNode3DGizmo>(); + current_hover_gizmo_handle = -1; if (selected) { - Ref<EditorNode3DGizmo> seg = selected->get_gizmo(); - if (seg.is_valid()) { + Vector<Ref<Node3DGizmo>> gizmos = selected->get_gizmos(); + for (int i = 0; i < gizmos.size(); i++) { + Ref<EditorNode3DGizmo> seg = gizmos[i]; + if (!seg.is_valid()) { + continue; + } seg->set_selected(true); - selected->update_gizmo(); } + selected->update_gizmos(); } } } @@ -4989,8 +5168,8 @@ void Node3DEditor::_xform_dialog_action() { List<Node *> &selection = editor_selection->get_selected_node_list(); - for (List<Node *>::Element *E = selection.front(); E; E = E->next()) { - Node3D *sp = Object::cast_to<Node3D>(E->get()); + for (Node *E : selection) { + Node3D *sp = Object::cast_to<Node3D>(E); if (!sp) { continue; } @@ -5050,13 +5229,13 @@ void Node3DEditor::_menu_gizmo_toggled(int p_option) { const int state = gizmos_menu->get_item_state(idx); switch (state) { case EditorNode3DGizmoPlugin::VISIBLE: - gizmos_menu->set_item_icon(idx, view_menu->get_popup()->get_theme_icon("visibility_visible")); + gizmos_menu->set_item_icon(idx, view_menu->get_popup()->get_theme_icon(SNAME("visibility_visible"))); break; case EditorNode3DGizmoPlugin::ON_TOP: - gizmos_menu->set_item_icon(idx, view_menu->get_popup()->get_theme_icon("visibility_xray")); + gizmos_menu->set_item_icon(idx, view_menu->get_popup()->get_theme_icon(SNAME("visibility_xray"))); break; case EditorNode3DGizmoPlugin::HIDDEN: - gizmos_menu->set_item_icon(idx, view_menu->get_popup()->get_theme_icon("visibility_hidden")); + gizmos_menu->set_item_icon(idx, view_menu->get_popup()->get_theme_icon(SNAME("visibility_hidden"))); break; } @@ -5226,8 +5405,8 @@ void Node3DEditor::_menu_item_pressed(int p_option) { List<Node *> &selection = editor_selection->get_selected_node_list(); - for (List<Node *>::Element *E = selection.front(); E; E = E->next()) { - Node3D *spatial = Object::cast_to<Node3D>(E->get()); + for (Node *E : selection) { + Node3D *spatial = Object::cast_to<Node3D>(E); if (!spatial || !spatial->is_inside_tree()) { continue; } @@ -5251,8 +5430,8 @@ void Node3DEditor::_menu_item_pressed(int p_option) { List<Node *> &selection = editor_selection->get_selected_node_list(); - for (List<Node *>::Element *E = selection.front(); E; E = E->next()) { - Node3D *spatial = Object::cast_to<Node3D>(E->get()); + for (Node *E : selection) { + Node3D *spatial = Object::cast_to<Node3D>(E); if (!spatial || !spatial->is_inside_tree()) { continue; } @@ -5276,8 +5455,8 @@ void Node3DEditor::_menu_item_pressed(int p_option) { List<Node *> &selection = editor_selection->get_selected_node_list(); - for (List<Node *>::Element *E = selection.front(); E; E = E->next()) { - Node3D *spatial = Object::cast_to<Node3D>(E->get()); + for (Node *E : selection) { + Node3D *spatial = Object::cast_to<Node3D>(E); if (!spatial || !spatial->is_inside_tree()) { continue; } @@ -5300,8 +5479,8 @@ void Node3DEditor::_menu_item_pressed(int p_option) { undo_redo->create_action(TTR("Ungroup Selected")); List<Node *> &selection = editor_selection->get_selected_node_list(); - for (List<Node *>::Element *E = selection.front(); E; E = E->next()) { - Node3D *spatial = Object::cast_to<Node3D>(E->get()); + for (Node *E : selection) { + Node3D *spatial = Object::cast_to<Node3D>(E); if (!spatial || !spatial->is_inside_tree()) { continue; } @@ -5343,13 +5522,13 @@ void Node3DEditor::_init_indicators() { Color origin_color; switch (i) { case 0: - origin_color = get_theme_color("axis_x_color", "Editor"); + origin_color = get_theme_color(SNAME("axis_x_color"), SNAME("Editor")); break; case 1: - origin_color = get_theme_color("axis_y_color", "Editor"); + origin_color = get_theme_color(SNAME("axis_y_color"), SNAME("Editor")); break; case 2: - origin_color = get_theme_color("axis_z_color", "Editor"); + origin_color = get_theme_color(SNAME("axis_z_color"), SNAME("Editor")); break; default: origin_color = Color(); @@ -5377,35 +5556,37 @@ void Node3DEditor::_init_indicators() { } Ref<Shader> grid_shader = memnew(Shader); - grid_shader->set_code( - "\n" - "shader_type spatial; \n" - "render_mode unshaded; \n" - "uniform bool orthogonal; \n" - "uniform float grid_size; \n" - "\n" - "void vertex() { \n" - " // From FLAG_SRGB_VERTEX_COLOR \n" - " if (!OUTPUT_IS_SRGB) { \n" - " COLOR.rgb = mix(pow((COLOR.rgb + vec3(0.055)) * (1.0 / (1.0 + 0.055)), vec3(2.4)), COLOR.rgb * (1.0 / 12.92), lessThan(COLOR.rgb, vec3(0.04045))); \n" - " } \n" - "} \n" - "\n" - "void fragment() { \n" - " ALBEDO = COLOR.rgb; \n" - " vec3 dir = orthogonal ? -vec3(0, 0, 1) : VIEW; \n" - " float angle_fade = abs(dot(dir, NORMAL)); \n" - " angle_fade = smoothstep(0.05, 0.2, angle_fade); \n" - " \n" - " vec3 world_pos = (CAMERA_MATRIX * vec4(VERTEX, 1.0)).xyz; \n" - " vec3 world_normal = (CAMERA_MATRIX * vec4(NORMAL, 0.0)).xyz; \n" - " vec3 camera_world_pos = CAMERA_MATRIX[3].xyz; \n" - " vec3 camera_world_pos_on_plane = camera_world_pos * (1.0 - world_normal); \n" - " float dist_fade = 1.0 - (distance(world_pos, camera_world_pos_on_plane) / grid_size); \n" - " dist_fade = smoothstep(0.02, 0.3, dist_fade); \n" - " \n" - " ALPHA = COLOR.a * dist_fade * angle_fade; \n" - "}"); + grid_shader->set_code(R"( +shader_type spatial; + +render_mode unshaded; + +uniform bool orthogonal; +uniform float grid_size; + +void vertex() { + // From FLAG_SRGB_VERTEX_COLOR. + if (!OUTPUT_IS_SRGB) { + COLOR.rgb = mix(pow((COLOR.rgb + vec3(0.055)) * (1.0 / (1.0 + 0.055)), vec3(2.4)), COLOR.rgb * (1.0 / 12.92), lessThan(COLOR.rgb, vec3(0.04045))); + } +} + +void fragment() { + ALBEDO = COLOR.rgb; + vec3 dir = orthogonal ? -vec3(0, 0, 1) : VIEW; + float angle_fade = abs(dot(dir, NORMAL)); + angle_fade = smoothstep(0.05, 0.2, angle_fade); + + vec3 world_pos = (CAMERA_MATRIX * vec4(VERTEX, 1.0)).xyz; + vec3 world_normal = (CAMERA_MATRIX * vec4(NORMAL, 0.0)).xyz; + vec3 camera_world_pos = CAMERA_MATRIX[3].xyz; + vec3 camera_world_pos_on_plane = camera_world_pos * (1.0 - world_normal); + float dist_fade = 1.0 - (distance(world_pos, camera_world_pos_on_plane) / grid_size); + dist_fade = smoothstep(0.02, 0.3, dist_fade); + + ALPHA = COLOR.a * dist_fade * angle_fade; +} +)"); for (int i = 0; i < 3; i++) { grid_mat[i].instantiate(); @@ -5444,13 +5625,13 @@ void Node3DEditor::_init_indicators() { Color col; switch (i) { case 0: - col = get_theme_color("axis_x_color", "Editor"); + col = get_theme_color(SNAME("axis_x_color"), SNAME("Editor")); break; case 1: - col = get_theme_color("axis_y_color", "Editor"); + col = get_theme_color(SNAME("axis_y_color"), SNAME("Editor")); break; case 2: - col = get_theme_color("axis_z_color", "Editor"); + col = get_theme_color(SNAME("axis_z_color"), SNAME("Editor")); break; default: col = Color(); @@ -5473,8 +5654,7 @@ void Node3DEditor::_init_indicators() { gizmo_color[i] = mat; Ref<StandardMaterial3D> mat_hl = mat->duplicate(); - const float brightness = 1.3; - const Color albedo = Color(col.r * brightness, col.g * brightness, col.b * brightness); + const Color albedo = col.from_hsv(col.get_h(), 0.25, 1.0, 1); mat_hl->set_albedo(albedo); gizmo_color_hl[i] = mat_hl; @@ -5581,7 +5761,7 @@ void Node3DEditor::_init_indicators() { surftool->begin(Mesh::PRIMITIVE_TRIANGLES); int n = 128; // number of circle segments - int m = 6; // number of thickness segments + int m = 3; // number of thickness segments real_t step = Math_TAU / n; for (int j = 0; j < n; ++j) { @@ -5617,33 +5797,35 @@ void Node3DEditor::_init_indicators() { Ref<Shader> rotate_shader = memnew(Shader); - rotate_shader->set_code( - "\n" - "shader_type spatial; \n" - "render_mode unshaded, depth_test_disabled; \n" - "uniform vec4 albedo; \n" - "\n" - "mat3 orthonormalize(mat3 m) { \n" - " vec3 x = normalize(m[0]); \n" - " vec3 y = normalize(m[1] - x * dot(x, m[1])); \n" - " vec3 z = m[2] - x * dot(x, m[2]); \n" - " z = normalize(z - y * (dot(y,m[2]))); \n" - " return mat3(x,y,z); \n" - "} \n" - "\n" - "void vertex() { \n" - " mat3 mv = orthonormalize(mat3(MODELVIEW_MATRIX)); \n" - " vec3 n = mv * VERTEX; \n" - " float orientation = dot(vec3(0,0,-1),n); \n" - " if (orientation <= 0.005) { \n" - " VERTEX += NORMAL*0.02; \n" - " } \n" - "} \n" - "\n" - "void fragment() { \n" - " ALBEDO = albedo.rgb; \n" - " ALPHA = albedo.a; \n" - "}"); + rotate_shader->set_code(R"( +shader_type spatial; + +render_mode unshaded, depth_test_disabled; + +uniform vec4 albedo; + +mat3 orthonormalize(mat3 m) { + vec3 x = normalize(m[0]); + vec3 y = normalize(m[1] - x * dot(x, m[1])); + vec3 z = m[2] - x * dot(x, m[2]); + z = normalize(z - y * (dot(y,m[2]))); + return mat3(x,y,z); +} + +void vertex() { + mat3 mv = orthonormalize(mat3(MODELVIEW_MATRIX)); + vec3 n = mv * VERTEX; + float orientation = dot(vec3(0, 0, -1), n); + if (orientation <= 0.005) { + VERTEX += NORMAL * 0.02; + } +} + +void fragment() { + ALBEDO = albedo.rgb; + ALPHA = albedo.a; +} +)"); Ref<ShaderMaterial> rotate_mat = memnew(ShaderMaterial); rotate_mat->set_render_priority(Material::RENDER_PRIORITY_MAX); @@ -5663,34 +5845,36 @@ void Node3DEditor::_init_indicators() { Ref<ShaderMaterial> border_mat = rotate_mat->duplicate(); Ref<Shader> border_shader = memnew(Shader); - border_shader->set_code( - "\n" - "shader_type spatial; \n" - "render_mode unshaded, depth_test_disabled; \n" - "uniform vec4 albedo; \n" - "\n" - "mat3 orthonormalize(mat3 m) { \n" - " vec3 x = normalize(m[0]); \n" - " vec3 y = normalize(m[1] - x * dot(x, m[1])); \n" - " vec3 z = m[2] - x * dot(x, m[2]); \n" - " z = normalize(z - y * (dot(y,m[2]))); \n" - " return mat3(x,y,z); \n" - "} \n" - "\n" - "void vertex() { \n" - " mat3 mv = orthonormalize(mat3(MODELVIEW_MATRIX)); \n" - " mv = inverse(mv); \n" - " VERTEX += NORMAL*0.008; \n" - " vec3 camera_dir_local = mv * vec3(0,0,1); \n" - " vec3 camera_up_local = mv * vec3(0,1,0); \n" - " mat3 rotation_matrix = mat3(cross(camera_dir_local, camera_up_local), camera_up_local, camera_dir_local); \n" - " VERTEX = rotation_matrix * VERTEX; \n" - "} \n" - "\n" - "void fragment() { \n" - " ALBEDO = albedo.rgb; \n" - " ALPHA = albedo.a; \n" - "}"); + border_shader->set_code(R"( +shader_type spatial; + +render_mode unshaded, depth_test_disabled; + +uniform vec4 albedo; + +mat3 orthonormalize(mat3 m) { + vec3 x = normalize(m[0]); + vec3 y = normalize(m[1] - x * dot(x, m[1])); + vec3 z = m[2] - x * dot(x, m[2]); + z = normalize(z - y * (dot(y,m[2]))); + return mat3(x,y,z); +} + +void vertex() { + mat3 mv = orthonormalize(mat3(MODELVIEW_MATRIX)); + mv = inverse(mv); + VERTEX += NORMAL*0.008; + vec3 camera_dir_local = mv * vec3(0,0,1); + vec3 camera_up_local = mv * vec3(0,1,0); + mat3 rotation_matrix = mat3(cross(camera_dir_local, camera_up_local), camera_up_local, camera_dir_local); + VERTEX = rotation_matrix * VERTEX; +} + +void fragment() { + ALBEDO = albedo.rgb; + ALPHA = albedo.a; +} +)"); border_mat->set_shader(border_shader); border_mat->set_shader_param("albedo", Color(0.75, 0.75, 0.75, col.a / 3.0)); @@ -5785,7 +5969,7 @@ void Node3DEditor::_init_indicators() { surftool->commit(scale_plane_gizmo[i]); Ref<StandardMaterial3D> plane_mat_hl = plane_mat->duplicate(); - plane_mat_hl->set_albedo(Color(col.r * 1.3, col.g * 1.3, col.b * 1.3)); + plane_mat_hl->set_albedo(col.from_hsv(col.get_h(), 0.25, 1.0, 1)); plane_gizmo_color_hl[i] = plane_mat_hl; // needed, so we can draw planes from both sides } } @@ -5794,6 +5978,18 @@ void Node3DEditor::_init_indicators() { _generate_selection_boxes(); } +void Node3DEditor::_update_context_menu_stylebox() { + // This must be called when the theme changes to follow the new accent color. + Ref<StyleBoxFlat> context_menu_stylebox = memnew(StyleBoxFlat); + const Color accent_color = EditorNode::get_singleton()->get_gui_base()->get_theme_color("accent_color", "Editor"); + context_menu_stylebox->set_bg_color(accent_color * Color(1, 1, 1, 0.1)); + // Add an underline to the StyleBox, but prevent its minimum vertical size from changing. + context_menu_stylebox->set_border_color(accent_color); + context_menu_stylebox->set_border_width(SIDE_BOTTOM, Math::round(2 * EDSCALE)); + context_menu_stylebox->set_default_margin(SIDE_BOTTOM, 0); + context_menu_container->add_theme_style_override("panel", context_menu_stylebox); +} + void Node3DEditor::_update_gizmos_menu() { gizmos_menu->clear(); @@ -5810,13 +6006,13 @@ void Node3DEditor::_update_gizmos_menu() { TTR("Click to toggle between visibility states.\n\nOpen eye: Gizmo is visible.\nClosed eye: Gizmo is hidden.\nHalf-open eye: Gizmo is also visible through opaque surfaces (\"x-ray\").")); switch (plugin_state) { case EditorNode3DGizmoPlugin::VISIBLE: - gizmos_menu->set_item_icon(idx, gizmos_menu->get_theme_icon("visibility_visible")); + gizmos_menu->set_item_icon(idx, gizmos_menu->get_theme_icon(SNAME("visibility_visible"))); break; case EditorNode3DGizmoPlugin::ON_TOP: - gizmos_menu->set_item_icon(idx, gizmos_menu->get_theme_icon("visibility_xray")); + gizmos_menu->set_item_icon(idx, gizmos_menu->get_theme_icon(SNAME("visibility_xray"))); break; case EditorNode3DGizmoPlugin::HIDDEN: - gizmos_menu->set_item_icon(idx, gizmos_menu->get_theme_icon("visibility_hidden")); + gizmos_menu->set_item_icon(idx, gizmos_menu->get_theme_icon(SNAME("visibility_hidden"))); break; } } @@ -5831,13 +6027,13 @@ void Node3DEditor::_update_gizmos_menu_theme() { const int idx = gizmos_menu->get_item_index(i); switch (plugin_state) { case EditorNode3DGizmoPlugin::VISIBLE: - gizmos_menu->set_item_icon(idx, gizmos_menu->get_theme_icon("visibility_visible")); + gizmos_menu->set_item_icon(idx, gizmos_menu->get_theme_icon(SNAME("visibility_visible"))); break; case EditorNode3DGizmoPlugin::ON_TOP: - gizmos_menu->set_item_icon(idx, gizmos_menu->get_theme_icon("visibility_xray")); + gizmos_menu->set_item_icon(idx, gizmos_menu->get_theme_icon(SNAME("visibility_xray"))); break; case EditorNode3DGizmoPlugin::HIDDEN: - gizmos_menu->set_item_icon(idx, gizmos_menu->get_theme_icon("visibility_hidden")); + gizmos_menu->set_item_icon(idx, gizmos_menu->get_theme_icon(SNAME("visibility_hidden"))); break; } } @@ -6017,13 +6213,27 @@ void Node3DEditor::update_grid() { _init_grid(); } -bool Node3DEditor::is_any_freelook_active() const { - for (unsigned int i = 0; i < VIEWPORTS_COUNT; ++i) { - if (viewports[i]->is_freelook_active()) { - return true; +void Node3DEditor::_selection_changed() { + _refresh_menu_icons(); + if (selected && editor_selection->get_selected_node_list().size() != 1) { + Vector<Ref<Node3DGizmo>> gizmos = selected->get_gizmos(); + for (int i = 0; i < gizmos.size(); i++) { + Ref<EditorNode3DGizmo> seg = gizmos[i]; + if (!seg.is_valid()) { + continue; + } + seg->set_selected(false); + } + + Node3DEditorSelectedItem *se = editor_selection->get_node_editor_data<Node3DEditorSelectedItem>(selected); + if (se) { + se->gizmo.unref(); + se->subgizmos.clear(); } + selected->update_gizmos(); + selected = nullptr; } - return false; + update_transform_gizmo(); } void Node3DEditor::_refresh_menu_icons() { @@ -6036,14 +6246,14 @@ void Node3DEditor::_refresh_menu_icons() { all_locked = false; all_grouped = false; } else { - for (List<Node *>::Element *E = selection.front(); E; E = E->next()) { - if (Object::cast_to<Node3D>(E->get()) && !Object::cast_to<Node3D>(E->get())->has_meta("_edit_lock_")) { + for (Node *E : selection) { + if (Object::cast_to<Node3D>(E) && !Object::cast_to<Node3D>(E)->has_meta("_edit_lock_")) { all_locked = false; break; } } - for (List<Node *>::Element *E = selection.front(); E; E = E->next()) { - if (Object::cast_to<Node3D>(E->get()) && !Object::cast_to<Node3D>(E->get())->has_meta("_edit_group_")) { + for (Node *E : selection) { + if (Object::cast_to<Node3D>(E) && !Object::cast_to<Node3D>(E)->has_meta("_edit_group_")) { all_grouped = false; break; } @@ -6096,8 +6306,8 @@ void Node3DEditor::snap_selected_nodes_to_floor() { List<Node *> &selection = editor_selection->get_selected_node_list(); Dictionary snap_data; - for (List<Node *>::Element *E = selection.front(); E; E = E->next()) { - Node3D *sp = Object::cast_to<Node3D>(E->get()); + for (Node *E : selection) { + Node3D *sp = Object::cast_to<Node3D>(E); if (sp) { Vector3 from = Vector3(); Vector3 position_offset = Vector3(); @@ -6244,7 +6454,7 @@ void Node3DEditor::_add_sun_to_scene(bool p_already_added_environment) { ERR_FAIL_COND(!base); Node *new_sun = preview_sun->duplicate(); - undo_redo->create_action("Add Preview Sun to Scene"); + undo_redo->create_action(TTR("Add Preview Sun to Scene")); undo_redo->add_do_method(base, "add_child", new_sun); // Move to the beginning of the scene tree since more "global" nodes // generally look better when placed at the top. @@ -6274,7 +6484,7 @@ void Node3DEditor::_add_environment_to_scene(bool p_already_added_sun) { WorldEnvironment *new_env = memnew(WorldEnvironment); new_env->set_environment(preview_environment->get_environment()->duplicate(true)); - undo_redo->create_action("Add Preview Environment to Scene"); + undo_redo->create_action(TTR("Add Preview Environment to Scene")); undo_redo->add_do_method(base, "add_child", new_env); // Move to the beginning of the scene tree since more "global" nodes // generally look better when placed at the top. @@ -6285,101 +6495,122 @@ void Node3DEditor::_add_environment_to_scene(bool p_already_added_sun) { undo_redo->commit_action(); } +void Node3DEditor::_update_theme() { + tool_button[Node3DEditor::TOOL_MODE_SELECT]->set_icon(get_theme_icon(SNAME("ToolSelect"), SNAME("EditorIcons"))); + tool_button[Node3DEditor::TOOL_MODE_MOVE]->set_icon(get_theme_icon(SNAME("ToolMove"), SNAME("EditorIcons"))); + tool_button[Node3DEditor::TOOL_MODE_ROTATE]->set_icon(get_theme_icon(SNAME("ToolRotate"), SNAME("EditorIcons"))); + tool_button[Node3DEditor::TOOL_MODE_SCALE]->set_icon(get_theme_icon(SNAME("ToolScale"), SNAME("EditorIcons"))); + tool_button[Node3DEditor::TOOL_MODE_LIST_SELECT]->set_icon(get_theme_icon(SNAME("ListSelect"), SNAME("EditorIcons"))); + tool_button[Node3DEditor::TOOL_LOCK_SELECTED]->set_icon(get_theme_icon(SNAME("Lock"), SNAME("EditorIcons"))); + tool_button[Node3DEditor::TOOL_UNLOCK_SELECTED]->set_icon(get_theme_icon(SNAME("Unlock"), SNAME("EditorIcons"))); + tool_button[Node3DEditor::TOOL_GROUP_SELECTED]->set_icon(get_theme_icon(SNAME("Group"), SNAME("EditorIcons"))); + tool_button[Node3DEditor::TOOL_UNGROUP_SELECTED]->set_icon(get_theme_icon(SNAME("Ungroup"), SNAME("EditorIcons"))); + + tool_option_button[Node3DEditor::TOOL_OPT_LOCAL_COORDS]->set_icon(get_theme_icon(SNAME("Object"), SNAME("EditorIcons"))); + tool_option_button[Node3DEditor::TOOL_OPT_USE_SNAP]->set_icon(get_theme_icon(SNAME("Snap"), SNAME("EditorIcons"))); + tool_option_button[Node3DEditor::TOOL_OPT_OVERRIDE_CAMERA]->set_icon(get_theme_icon(SNAME("Camera3D"), SNAME("EditorIcons"))); + + view_menu->get_popup()->set_item_icon(view_menu->get_popup()->get_item_index(MENU_VIEW_USE_1_VIEWPORT), get_theme_icon(SNAME("Panels1"), SNAME("EditorIcons"))); + view_menu->get_popup()->set_item_icon(view_menu->get_popup()->get_item_index(MENU_VIEW_USE_2_VIEWPORTS), get_theme_icon(SNAME("Panels2"), SNAME("EditorIcons"))); + view_menu->get_popup()->set_item_icon(view_menu->get_popup()->get_item_index(MENU_VIEW_USE_2_VIEWPORTS_ALT), get_theme_icon(SNAME("Panels2Alt"), SNAME("EditorIcons"))); + view_menu->get_popup()->set_item_icon(view_menu->get_popup()->get_item_index(MENU_VIEW_USE_3_VIEWPORTS), get_theme_icon(SNAME("Panels3"), SNAME("EditorIcons"))); + view_menu->get_popup()->set_item_icon(view_menu->get_popup()->get_item_index(MENU_VIEW_USE_3_VIEWPORTS_ALT), get_theme_icon(SNAME("Panels3Alt"), SNAME("EditorIcons"))); + view_menu->get_popup()->set_item_icon(view_menu->get_popup()->get_item_index(MENU_VIEW_USE_4_VIEWPORTS), get_theme_icon(SNAME("Panels4"), SNAME("EditorIcons"))); + + sun_button->set_icon(get_theme_icon(SNAME("DirectionalLight3D"), SNAME("EditorIcons"))); + environ_button->set_icon(get_theme_icon(SNAME("WorldEnvironment"), SNAME("EditorIcons"))); + sun_environ_settings->set_icon(get_theme_icon(SNAME("GuiTabMenuHl"), SNAME("EditorIcons"))); + + sun_title->add_theme_font_override("font", get_theme_font(SNAME("title_font"), SNAME("Window"))); + environ_title->add_theme_font_override("font", get_theme_font(SNAME("title_font"), SNAME("Window"))); +} + void Node3DEditor::_notification(int p_what) { - if (p_what == NOTIFICATION_READY) { - tool_button[Node3DEditor::TOOL_MODE_SELECT]->set_icon(get_theme_icon("ToolSelect", "EditorIcons")); - tool_button[Node3DEditor::TOOL_MODE_MOVE]->set_icon(get_theme_icon("ToolMove", "EditorIcons")); - tool_button[Node3DEditor::TOOL_MODE_ROTATE]->set_icon(get_theme_icon("ToolRotate", "EditorIcons")); - tool_button[Node3DEditor::TOOL_MODE_SCALE]->set_icon(get_theme_icon("ToolScale", "EditorIcons")); - tool_button[Node3DEditor::TOOL_MODE_LIST_SELECT]->set_icon(get_theme_icon("ListSelect", "EditorIcons")); - tool_button[Node3DEditor::TOOL_LOCK_SELECTED]->set_icon(get_theme_icon("Lock", "EditorIcons")); - tool_button[Node3DEditor::TOOL_UNLOCK_SELECTED]->set_icon(get_theme_icon("Unlock", "EditorIcons")); - tool_button[Node3DEditor::TOOL_GROUP_SELECTED]->set_icon(get_theme_icon("Group", "EditorIcons")); - tool_button[Node3DEditor::TOOL_UNGROUP_SELECTED]->set_icon(get_theme_icon("Ungroup", "EditorIcons")); - - tool_option_button[Node3DEditor::TOOL_OPT_LOCAL_COORDS]->set_icon(get_theme_icon("Object", "EditorIcons")); - tool_option_button[Node3DEditor::TOOL_OPT_USE_SNAP]->set_icon(get_theme_icon("Snap", "EditorIcons")); - tool_option_button[Node3DEditor::TOOL_OPT_OVERRIDE_CAMERA]->set_icon(get_theme_icon("Camera3D", "EditorIcons")); - - view_menu->get_popup()->set_item_icon(view_menu->get_popup()->get_item_index(MENU_VIEW_USE_1_VIEWPORT), get_theme_icon("Panels1", "EditorIcons")); - view_menu->get_popup()->set_item_icon(view_menu->get_popup()->get_item_index(MENU_VIEW_USE_2_VIEWPORTS), get_theme_icon("Panels2", "EditorIcons")); - view_menu->get_popup()->set_item_icon(view_menu->get_popup()->get_item_index(MENU_VIEW_USE_2_VIEWPORTS_ALT), get_theme_icon("Panels2Alt", "EditorIcons")); - view_menu->get_popup()->set_item_icon(view_menu->get_popup()->get_item_index(MENU_VIEW_USE_3_VIEWPORTS), get_theme_icon("Panels3", "EditorIcons")); - view_menu->get_popup()->set_item_icon(view_menu->get_popup()->get_item_index(MENU_VIEW_USE_3_VIEWPORTS_ALT), get_theme_icon("Panels3Alt", "EditorIcons")); - view_menu->get_popup()->set_item_icon(view_menu->get_popup()->get_item_index(MENU_VIEW_USE_4_VIEWPORTS), get_theme_icon("Panels4", "EditorIcons")); - - _menu_item_pressed(MENU_VIEW_USE_1_VIEWPORT); - - _refresh_menu_icons(); - - get_tree()->connect("node_removed", callable_mp(this, &Node3DEditor::_node_removed)); - get_tree()->connect("node_added", callable_mp(this, &Node3DEditor::_node_added)); - EditorNode::get_singleton()->get_scene_tree_dock()->get_tree_editor()->connect("node_changed", callable_mp(this, &Node3DEditor::_refresh_menu_icons)); - editor_selection->connect("selection_changed", callable_mp(this, &Node3DEditor::_refresh_menu_icons)); - - editor->connect("stop_pressed", callable_mp(this, &Node3DEditor::_update_camera_override_button), make_binds(false)); - editor->connect("play_pressed", callable_mp(this, &Node3DEditor::_update_camera_override_button), make_binds(true)); - - sun_button->set_icon(get_theme_icon("DirectionalLight3D", "EditorIcons")); - environ_button->set_icon(get_theme_icon("WorldEnvironment", "EditorIcons")); - sun_environ_settings->set_icon(get_theme_icon("GuiTabMenuHl", "EditorIcons")); + switch (p_what) { + case NOTIFICATION_READY: { + _menu_item_pressed(MENU_VIEW_USE_1_VIEWPORT); - _update_preview_environment(); - sun_title->add_theme_font_override("font", get_theme_font("title_font", "Window")); - environ_title->add_theme_font_override("font", get_theme_font("title_font", "Window")); + _refresh_menu_icons(); - sun_state->set_custom_minimum_size(sun_vb->get_combined_minimum_size()); - environ_state->set_custom_minimum_size(environ_vb->get_combined_minimum_size()); - } else if (p_what == NOTIFICATION_ENTER_TREE) { - _register_all_gizmos(); - _update_gizmos_menu(); - _init_indicators(); - } else if (p_what == NOTIFICATION_THEME_CHANGED) { - _update_gizmos_menu_theme(); - sun_title->add_theme_font_override("font", get_theme_font("title_font", "Window")); - environ_title->add_theme_font_override("font", get_theme_font("title_font", "Window")); - } else if (p_what == NOTIFICATION_EXIT_TREE) { - _finish_indicators(); - } else if (p_what == EditorSettings::NOTIFICATION_EDITOR_SETTINGS_CHANGED) { - tool_button[Node3DEditor::TOOL_MODE_SELECT]->set_icon(get_theme_icon("ToolSelect", "EditorIcons")); - tool_button[Node3DEditor::TOOL_MODE_MOVE]->set_icon(get_theme_icon("ToolMove", "EditorIcons")); - tool_button[Node3DEditor::TOOL_MODE_ROTATE]->set_icon(get_theme_icon("ToolRotate", "EditorIcons")); - tool_button[Node3DEditor::TOOL_MODE_SCALE]->set_icon(get_theme_icon("ToolScale", "EditorIcons")); - tool_button[Node3DEditor::TOOL_MODE_LIST_SELECT]->set_icon(get_theme_icon("ListSelect", "EditorIcons")); - tool_button[Node3DEditor::TOOL_LOCK_SELECTED]->set_icon(get_theme_icon("Lock", "EditorIcons")); - tool_button[Node3DEditor::TOOL_UNLOCK_SELECTED]->set_icon(get_theme_icon("Unlock", "EditorIcons")); - tool_button[Node3DEditor::TOOL_GROUP_SELECTED]->set_icon(get_theme_icon("Group", "EditorIcons")); - tool_button[Node3DEditor::TOOL_UNGROUP_SELECTED]->set_icon(get_theme_icon("Ungroup", "EditorIcons")); - - tool_option_button[Node3DEditor::TOOL_OPT_LOCAL_COORDS]->set_icon(get_theme_icon("Object", "EditorIcons")); - tool_option_button[Node3DEditor::TOOL_OPT_USE_SNAP]->set_icon(get_theme_icon("Snap", "EditorIcons")); - - view_menu->get_popup()->set_item_icon(view_menu->get_popup()->get_item_index(MENU_VIEW_USE_1_VIEWPORT), get_theme_icon("Panels1", "EditorIcons")); - view_menu->get_popup()->set_item_icon(view_menu->get_popup()->get_item_index(MENU_VIEW_USE_2_VIEWPORTS), get_theme_icon("Panels2", "EditorIcons")); - view_menu->get_popup()->set_item_icon(view_menu->get_popup()->get_item_index(MENU_VIEW_USE_2_VIEWPORTS_ALT), get_theme_icon("Panels2Alt", "EditorIcons")); - view_menu->get_popup()->set_item_icon(view_menu->get_popup()->get_item_index(MENU_VIEW_USE_3_VIEWPORTS), get_theme_icon("Panels3", "EditorIcons")); - view_menu->get_popup()->set_item_icon(view_menu->get_popup()->get_item_index(MENU_VIEW_USE_3_VIEWPORTS_ALT), get_theme_icon("Panels3Alt", "EditorIcons")); - view_menu->get_popup()->set_item_icon(view_menu->get_popup()->get_item_index(MENU_VIEW_USE_4_VIEWPORTS), get_theme_icon("Panels4", "EditorIcons")); - - // Update grid color by rebuilding grid. - _finish_grid(); - _init_grid(); - } else if (p_what == NOTIFICATION_VISIBILITY_CHANGED) { - if (!is_visible() && tool_option_button[TOOL_OPT_OVERRIDE_CAMERA]->is_pressed()) { - EditorDebuggerNode *debugger = EditorDebuggerNode::get_singleton(); + get_tree()->connect("node_removed", callable_mp(this, &Node3DEditor::_node_removed)); + get_tree()->connect("node_added", callable_mp(this, &Node3DEditor::_node_added)); + EditorNode::get_singleton()->get_scene_tree_dock()->get_tree_editor()->connect("node_changed", callable_mp(this, &Node3DEditor::_refresh_menu_icons)); + editor_selection->connect("selection_changed", callable_mp(this, &Node3DEditor::_selection_changed)); + + editor->connect("stop_pressed", callable_mp(this, &Node3DEditor::_update_camera_override_button), make_binds(false)); + editor->connect("play_pressed", callable_mp(this, &Node3DEditor::_update_camera_override_button), make_binds(true)); + + _update_preview_environment(); + + sun_state->set_custom_minimum_size(sun_vb->get_combined_minimum_size()); + environ_state->set_custom_minimum_size(environ_vb->get_combined_minimum_size()); + } break; + case NOTIFICATION_ENTER_TREE: { + _update_theme(); + _register_all_gizmos(); + _update_gizmos_menu(); + _init_indicators(); + } break; + case NOTIFICATION_EXIT_TREE: { + _finish_indicators(); + } break; + case NOTIFICATION_THEME_CHANGED: { + _update_theme(); + _update_gizmos_menu_theme(); + _update_context_menu_stylebox(); + sun_title->add_theme_font_override("font", get_theme_font(SNAME("title_font"), SNAME("Window"))); + environ_title->add_theme_font_override("font", get_theme_font(SNAME("title_font"), SNAME("Window"))); + } break; + case EditorSettings::NOTIFICATION_EDITOR_SETTINGS_CHANGED: { + // Update grid color by rebuilding grid. + _finish_grid(); + _init_grid(); + } break; + case NOTIFICATION_VISIBILITY_CHANGED: { + if (!is_visible() && tool_option_button[TOOL_OPT_OVERRIDE_CAMERA]->is_pressed()) { + EditorDebuggerNode *debugger = EditorDebuggerNode::get_singleton(); + + debugger->set_camera_override(EditorDebuggerNode::OVERRIDE_NONE); + tool_option_button[TOOL_OPT_OVERRIDE_CAMERA]->set_pressed(false); + } + } break; + } +} + +bool Node3DEditor::is_subgizmo_selected(int p_id) { + Node3DEditorSelectedItem *se = selected ? editor_selection->get_node_editor_data<Node3DEditorSelectedItem>(selected) : nullptr; + if (se) { + return se->subgizmos.has(p_id); + } + return false; +} + +bool Node3DEditor::is_current_selected_gizmo(const EditorNode3DGizmo *p_gizmo) { + Node3DEditorSelectedItem *se = selected ? editor_selection->get_node_editor_data<Node3DEditorSelectedItem>(selected) : nullptr; + if (se) { + return se->gizmo == p_gizmo; + } + return false; +} - debugger->set_camera_override(EditorDebuggerNode::OVERRIDE_NONE); - tool_option_button[TOOL_OPT_OVERRIDE_CAMERA]->set_pressed(false); +Vector<int> Node3DEditor::get_subgizmo_selection() { + Node3DEditorSelectedItem *se = selected ? editor_selection->get_node_editor_data<Node3DEditorSelectedItem>(selected) : nullptr; + + Vector<int> ret; + if (se) { + for (Map<int, Transform3D>::Element *E = se->subgizmos.front(); E; E = E->next()) { + ret.push_back(E->key()); } } + return ret; } void Node3DEditor::add_control_to_menu_panel(Control *p_control) { - hbc_menu->add_child(p_control); + hbc_context_menu->add_child(p_control); } void Node3DEditor::remove_control_from_menu_panel(Control *p_control) { - hbc_menu->remove_child(p_control); + hbc_context_menu->remove_child(p_control); } void Node3DEditor::set_can_preview(Camera3D *p_preview) { @@ -6401,23 +6632,43 @@ void Node3DEditor::_request_gizmo(Object *p_obj) { if (!sp) { return; } - if (editor->get_edited_scene() && (sp == editor->get_edited_scene() || (sp->get_owner() && editor->get_edited_scene()->is_ancestor_of(sp)))) { - Ref<EditorNode3DGizmo> seg; + bool is_selected = (sp == selected); + + if (editor->get_edited_scene() && (sp == editor->get_edited_scene() || (sp->get_owner() && editor->get_edited_scene()->is_ancestor_of(sp)))) { for (int i = 0; i < gizmo_plugins_by_priority.size(); ++i) { - seg = gizmo_plugins_by_priority.write[i]->get_gizmo(sp); + Ref<EditorNode3DGizmo> seg = gizmo_plugins_by_priority.write[i]->get_gizmo(sp); if (seg.is_valid()) { - sp->set_gizmo(seg); + sp->add_gizmo(seg); - if (sp == selected) { - seg->set_selected(true); - selected->update_gizmo(); + if (is_selected != seg->is_selected()) { + seg->set_selected(is_selected); } - - break; } } + sp->update_gizmos(); + } +} + +void Node3DEditor::_clear_subgizmo_selection(Object *p_obj) { + Node3D *sp = nullptr; + if (p_obj) { + sp = Object::cast_to<Node3D>(p_obj); + } else { + sp = selected; + } + + if (!sp) { + return; + } + + Node3DEditorSelectedItem *se = editor_selection->get_node_editor_data<Node3DEditorSelectedItem>(sp); + if (se) { + se->subgizmos.clear(); + se->gizmo.unref(); + sp->update_gizmos(); + update_transform_gizmo(); } } @@ -6506,7 +6757,13 @@ void Node3DEditor::_node_removed(Node *p_node) { } if (p_node == selected) { + Node3DEditorSelectedItem *se = editor_selection->get_node_editor_data<Node3DEditorSelectedItem>(selected); + if (se) { + se->gizmo.unref(); + se->subgizmos.clear(); + } selected = nullptr; + update_transform_gizmo(); } } @@ -6544,6 +6801,7 @@ void Node3DEditor::_bind_methods() { ClassDB::bind_method("_unhandled_key_input", &Node3DEditor::_unhandled_key_input); ClassDB::bind_method("_get_editor_data", &Node3DEditor::_get_editor_data); ClassDB::bind_method("_request_gizmo", &Node3DEditor::_request_gizmo); + ClassDB::bind_method("_clear_subgizmo_selection", &Node3DEditor::_clear_subgizmo_selection); ClassDB::bind_method("_refresh_menu_icons", &Node3DEditor::_refresh_menu_icons); ADD_SIGNAL(MethodInfo("transform_key_request")); @@ -6759,8 +7017,7 @@ Node3DEditor::Node3DEditor(EditorNode *p_editor) { tool_button[TOOL_MODE_SELECT]->connect("pressed", callable_mp(this, &Node3DEditor::_menu_item_pressed), button_binds); tool_button[TOOL_MODE_SELECT]->set_shortcut(ED_SHORTCUT("spatial_editor/tool_select", TTR("Select Mode"), KEY_Q)); tool_button[TOOL_MODE_SELECT]->set_shortcut_context(this); - tool_button[TOOL_MODE_SELECT]->set_tooltip(keycode_get_string(KEY_MASK_CMD) + TTR("Drag: Rotate\nAlt+Drag: Move\nAlt+RMB: Depth list selection")); - + tool_button[TOOL_MODE_SELECT]->set_tooltip(keycode_get_string(KEY_MASK_CMD) + TTR("Drag: Rotate selected node around pivot.") + "\n" + TTR("Alt+RMB: Show list of all nodes at position clicked, including locked.")); hbc_menu->add_child(memnew(VSeparator)); tool_button[TOOL_MODE_MOVE] = memnew(Button); @@ -6798,14 +7055,14 @@ Node3DEditor::Node3DEditor(EditorNode *p_editor) { tool_button[TOOL_MODE_LIST_SELECT]->set_flat(true); button_binds.write[0] = MENU_TOOL_LIST_SELECT; tool_button[TOOL_MODE_LIST_SELECT]->connect("pressed", callable_mp(this, &Node3DEditor::_menu_item_pressed), button_binds); - tool_button[TOOL_MODE_LIST_SELECT]->set_tooltip(TTR("Show a list of all objects at the position clicked\n(same as Alt+RMB in select mode).")); + tool_button[TOOL_MODE_LIST_SELECT]->set_tooltip(TTR("Show list of selectable nodes at position clicked.")); tool_button[TOOL_LOCK_SELECTED] = memnew(Button); hbc_menu->add_child(tool_button[TOOL_LOCK_SELECTED]); tool_button[TOOL_LOCK_SELECTED]->set_flat(true); button_binds.write[0] = MENU_LOCK_SELECTED; tool_button[TOOL_LOCK_SELECTED]->connect("pressed", callable_mp(this, &Node3DEditor::_menu_item_pressed), button_binds); - tool_button[TOOL_LOCK_SELECTED]->set_tooltip(TTR("Lock the selected object in place (can't be moved).")); + tool_button[TOOL_LOCK_SELECTED]->set_tooltip(TTR("Lock selected node, preventing selection and movement.")); // Define the shortcut globally (without a context) so that it works if the Scene tree dock is currently focused. tool_button[TOOL_LOCK_SELECTED]->set_shortcut(ED_SHORTCUT("editor/lock_selected_nodes", TTR("Lock Selected Node(s)"), KEY_MASK_CMD | KEY_L)); @@ -6814,7 +7071,7 @@ Node3DEditor::Node3DEditor(EditorNode *p_editor) { tool_button[TOOL_UNLOCK_SELECTED]->set_flat(true); button_binds.write[0] = MENU_UNLOCK_SELECTED; tool_button[TOOL_UNLOCK_SELECTED]->connect("pressed", callable_mp(this, &Node3DEditor::_menu_item_pressed), button_binds); - tool_button[TOOL_UNLOCK_SELECTED]->set_tooltip(TTR("Unlock the selected object (can be moved).")); + tool_button[TOOL_UNLOCK_SELECTED]->set_tooltip(TTR("Unlock selected node, allowing selection and movement.")); // Define the shortcut globally (without a context) so that it works if the Scene tree dock is currently focused. tool_button[TOOL_UNLOCK_SELECTED]->set_shortcut(ED_SHORTCUT("editor/unlock_selected_nodes", TTR("Unlock Selected Node(s)"), KEY_MASK_CMD | KEY_MASK_SHIFT | KEY_L)); @@ -6936,6 +7193,17 @@ Node3DEditor::Node3DEditor(EditorNode *p_editor) { view_menu->set_shortcut_context(this); hbc_menu->add_child(view_menu); + hbc_menu->add_child(memnew(VSeparator)); + + context_menu_container = memnew(PanelContainer); + hbc_context_menu = memnew(HBoxContainer); + context_menu_container->add_child(hbc_context_menu); + // Use a custom stylebox to make contextual menu items stand out from the rest. + // This helps with editor usability as contextual menu items change when selecting nodes, + // even though it may not be immediately obvious at first. + hbc_menu->add_child(context_menu_container); + _update_context_menu_stylebox(); + p = view_menu->get_popup(); accept = memnew(AcceptDialog); @@ -7120,7 +7388,7 @@ Node3DEditor::Node3DEditor(EditorNode *p_editor) { EditorSettings::get_singleton()->add_property_hint(PropertyInfo(Variant::FLOAT, "editors/3d/manipulator_gizmo_opacity", PROPERTY_HINT_RANGE, "0,1,0.01")); EDITOR_DEF("editors/3d/navigation/show_viewport_rotation_gizmo", true); - over_gizmo_handle = -1; + current_hover_gizmo_handle = -1; { //sun popup @@ -7151,9 +7419,21 @@ Node3DEditor::Node3DEditor(EditorNode *p_editor) { sun_direction->connect("draw", callable_mp(this, &Node3DEditor::_sun_direction_draw)); sun_direction->set_default_cursor_shape(CURSOR_MOVE); - String sun_dir_shader_code = "shader_type canvas_item; uniform vec3 sun_direction; uniform vec3 sun_color; void fragment() { vec3 n; n.xy = UV * 2.0 - 1.0; n.z = sqrt(max(0.0, 1.0 - dot(n.xy, n.xy))); COLOR.rgb = dot(n,sun_direction) * sun_color; COLOR.a = 1.0 - smoothstep(0.99,1.0,length(n.xy)); }"; sun_direction_shader.instantiate(); - sun_direction_shader->set_code(sun_dir_shader_code); + sun_direction_shader->set_code(R"( +shader_type canvas_item; + +uniform vec3 sun_direction; +uniform vec3 sun_color; + +void fragment() { + vec3 n; + n.xy = UV * 2.0 - 1.0; + n.z = sqrt(max(0.0, 1.0 - dot(n.xy, n.xy))); + COLOR.rgb = dot(n, sun_direction) * sun_color; + COLOR.a = 1.0 - smoothstep(0.99, 1.0, length(n.xy)); +} +)"); sun_direction_material.instantiate(); sun_direction_material->set_shader(sun_direction_shader); sun_direction_material->set_shader_param("sun_direction", Vector3(0, 0, 1)); @@ -7422,303 +7702,3 @@ Node3DEditorPlugin::Node3DEditorPlugin(EditorNode *p_node) { Node3DEditorPlugin::~Node3DEditorPlugin() { } - -void EditorNode3DGizmoPlugin::create_material(const String &p_name, const Color &p_color, bool p_billboard, bool p_on_top, bool p_use_vertex_color) { - Color instantiated_color = EDITOR_DEF("editors/3d_gizmos/gizmo_colors/instantiated", Color(0.7, 0.7, 0.7, 0.6)); - - Vector<Ref<StandardMaterial3D>> mats; - - for (int i = 0; i < 4; i++) { - bool selected = i % 2 == 1; - bool instantiated = i < 2; - - Ref<StandardMaterial3D> material = Ref<StandardMaterial3D>(memnew(StandardMaterial3D)); - - Color color = instantiated ? instantiated_color : p_color; - - if (!selected) { - color.a *= 0.3; - } - - material->set_albedo(color); - material->set_shading_mode(StandardMaterial3D::SHADING_MODE_UNSHADED); - material->set_transparency(StandardMaterial3D::TRANSPARENCY_ALPHA); - material->set_render_priority(StandardMaterial3D::RENDER_PRIORITY_MIN + 1); - material->set_cull_mode(StandardMaterial3D::CULL_DISABLED); - - if (p_use_vertex_color) { - material->set_flag(StandardMaterial3D::FLAG_ALBEDO_FROM_VERTEX_COLOR, true); - material->set_flag(StandardMaterial3D::FLAG_SRGB_VERTEX_COLOR, true); - } - - if (p_billboard) { - material->set_billboard_mode(StandardMaterial3D::BILLBOARD_ENABLED); - } - - if (p_on_top && selected) { - material->set_on_top_of_alpha(); - } - - mats.push_back(material); - } - - materials[p_name] = mats; -} - -void EditorNode3DGizmoPlugin::create_icon_material(const String &p_name, const Ref<Texture2D> &p_texture, bool p_on_top, const Color &p_albedo) { - Color instantiated_color = EDITOR_DEF("editors/3d_gizmos/gizmo_colors/instantiated", Color(0.7, 0.7, 0.7, 0.6)); - - Vector<Ref<StandardMaterial3D>> icons; - - for (int i = 0; i < 4; i++) { - bool selected = i % 2 == 1; - bool instantiated = i < 2; - - Ref<StandardMaterial3D> icon = Ref<StandardMaterial3D>(memnew(StandardMaterial3D)); - - Color color = instantiated ? instantiated_color : p_albedo; - - if (!selected) { - color.a *= 0.85; - } - - icon->set_albedo(color); - - icon->set_shading_mode(StandardMaterial3D::SHADING_MODE_UNSHADED); - icon->set_flag(StandardMaterial3D::FLAG_ALBEDO_FROM_VERTEX_COLOR, true); - icon->set_flag(StandardMaterial3D::FLAG_SRGB_VERTEX_COLOR, true); - icon->set_cull_mode(StandardMaterial3D::CULL_DISABLED); - icon->set_depth_draw_mode(StandardMaterial3D::DEPTH_DRAW_DISABLED); - icon->set_transparency(StandardMaterial3D::TRANSPARENCY_ALPHA); - icon->set_texture(StandardMaterial3D::TEXTURE_ALBEDO, p_texture); - icon->set_flag(StandardMaterial3D::FLAG_FIXED_SIZE, true); - icon->set_billboard_mode(StandardMaterial3D::BILLBOARD_ENABLED); - icon->set_render_priority(StandardMaterial3D::RENDER_PRIORITY_MIN); - - if (p_on_top && selected) { - icon->set_on_top_of_alpha(); - } - - icons.push_back(icon); - } - - materials[p_name] = icons; -} - -void EditorNode3DGizmoPlugin::create_handle_material(const String &p_name, bool p_billboard, const Ref<Texture2D> &p_icon) { - Ref<StandardMaterial3D> handle_material = Ref<StandardMaterial3D>(memnew(StandardMaterial3D)); - - handle_material->set_shading_mode(StandardMaterial3D::SHADING_MODE_UNSHADED); - handle_material->set_flag(StandardMaterial3D::FLAG_USE_POINT_SIZE, true); - Ref<Texture2D> handle_t = p_icon != nullptr ? p_icon : Node3DEditor::get_singleton()->get_theme_icon("Editor3DHandle", "EditorIcons"); - handle_material->set_point_size(handle_t->get_width()); - handle_material->set_texture(StandardMaterial3D::TEXTURE_ALBEDO, handle_t); - handle_material->set_albedo(Color(1, 1, 1)); - handle_material->set_flag(StandardMaterial3D::FLAG_ALBEDO_FROM_VERTEX_COLOR, true); - handle_material->set_flag(StandardMaterial3D::FLAG_SRGB_VERTEX_COLOR, true); - handle_material->set_on_top_of_alpha(); - if (p_billboard) { - handle_material->set_billboard_mode(StandardMaterial3D::BILLBOARD_ENABLED); - handle_material->set_on_top_of_alpha(); - } - handle_material->set_transparency(StandardMaterial3D::TRANSPARENCY_ALPHA); - - materials[p_name] = Vector<Ref<StandardMaterial3D>>(); - materials[p_name].push_back(handle_material); -} - -void EditorNode3DGizmoPlugin::add_material(const String &p_name, Ref<StandardMaterial3D> p_material) { - materials[p_name] = Vector<Ref<StandardMaterial3D>>(); - materials[p_name].push_back(p_material); -} - -Ref<StandardMaterial3D> EditorNode3DGizmoPlugin::get_material(const String &p_name, const Ref<EditorNode3DGizmo> &p_gizmo) { - ERR_FAIL_COND_V(!materials.has(p_name), Ref<StandardMaterial3D>()); - ERR_FAIL_COND_V(materials[p_name].size() == 0, Ref<StandardMaterial3D>()); - - if (p_gizmo.is_null() || materials[p_name].size() == 1) { - return materials[p_name][0]; - } - - int index = (p_gizmo->is_selected() ? 1 : 0) + (p_gizmo->is_editable() ? 2 : 0); - - Ref<StandardMaterial3D> mat = materials[p_name][index]; - - if (current_state == ON_TOP && p_gizmo->is_selected()) { - mat->set_flag(StandardMaterial3D::FLAG_DISABLE_DEPTH_TEST, true); - } else { - mat->set_flag(StandardMaterial3D::FLAG_DISABLE_DEPTH_TEST, false); - } - - return mat; -} - -String EditorNode3DGizmoPlugin::get_gizmo_name() const { - if (get_script_instance() && get_script_instance()->has_method("_get_gizmo_name")) { - return get_script_instance()->call("_get_gizmo_name"); - } - return TTR("Nameless gizmo"); -} - -int EditorNode3DGizmoPlugin::get_priority() const { - if (get_script_instance() && get_script_instance()->has_method("_get_priority")) { - return get_script_instance()->call("_get_priority"); - } - return 0; -} - -Ref<EditorNode3DGizmo> EditorNode3DGizmoPlugin::get_gizmo(Node3D *p_spatial) { - if (get_script_instance() && get_script_instance()->has_method("get_gizmo")) { - return get_script_instance()->call("get_gizmo", p_spatial); - } - - Ref<EditorNode3DGizmo> ref = create_gizmo(p_spatial); - - if (ref.is_null()) { - return ref; - } - - ref->set_plugin(this); - ref->set_spatial_node(p_spatial); - ref->set_hidden(current_state == HIDDEN); - - current_gizmos.push_back(ref.ptr()); - return ref; -} - -void EditorNode3DGizmoPlugin::_bind_methods() { -#define GIZMO_REF PropertyInfo(Variant::OBJECT, "gizmo", PROPERTY_HINT_RESOURCE_TYPE, "EditorNode3DGizmo") - - BIND_VMETHOD(MethodInfo(Variant::BOOL, "_has_gizmo", PropertyInfo(Variant::OBJECT, "spatial", PROPERTY_HINT_RESOURCE_TYPE, "Node3D"))); - BIND_VMETHOD(MethodInfo(GIZMO_REF, "_create_gizmo", PropertyInfo(Variant::OBJECT, "spatial", PROPERTY_HINT_RESOURCE_TYPE, "Node3D"))); - - ClassDB::bind_method(D_METHOD("create_material", "name", "color", "billboard", "on_top", "use_vertex_color"), &EditorNode3DGizmoPlugin::create_material, DEFVAL(false), DEFVAL(false), DEFVAL(false)); - ClassDB::bind_method(D_METHOD("create_icon_material", "name", "texture", "on_top", "color"), &EditorNode3DGizmoPlugin::create_icon_material, DEFVAL(false), DEFVAL(Color(1, 1, 1, 1))); - ClassDB::bind_method(D_METHOD("create_handle_material", "name", "billboard", "texture"), &EditorNode3DGizmoPlugin::create_handle_material, DEFVAL(false), DEFVAL(Variant())); - ClassDB::bind_method(D_METHOD("add_material", "name", "material"), &EditorNode3DGizmoPlugin::add_material); - - ClassDB::bind_method(D_METHOD("get_material", "name", "gizmo"), &EditorNode3DGizmoPlugin::get_material, DEFVAL(Ref<EditorNode3DGizmo>())); - - BIND_VMETHOD(MethodInfo(Variant::STRING, "_get_gizmo_name")); - BIND_VMETHOD(MethodInfo(Variant::INT, "_get_priority")); - BIND_VMETHOD(MethodInfo(Variant::BOOL, "_can_be_hidden")); - BIND_VMETHOD(MethodInfo(Variant::BOOL, "_is_selectable_when_hidden")); - - BIND_VMETHOD(MethodInfo("_redraw", GIZMO_REF)); - BIND_VMETHOD(MethodInfo(Variant::STRING, "_get_handle_name", GIZMO_REF, PropertyInfo(Variant::INT, "index"))); - - MethodInfo hvget(Variant::NIL, "_get_handle_value", GIZMO_REF, PropertyInfo(Variant::INT, "index")); - hvget.return_val.usage |= PROPERTY_USAGE_NIL_IS_VARIANT; - BIND_VMETHOD(hvget); - - BIND_VMETHOD(MethodInfo("_set_handle", GIZMO_REF, PropertyInfo(Variant::INT, "index"), PropertyInfo(Variant::OBJECT, "camera", PROPERTY_HINT_RESOURCE_TYPE, "Camera3D"), PropertyInfo(Variant::VECTOR2, "point"))); - MethodInfo cm = MethodInfo("_commit_handle", GIZMO_REF, PropertyInfo(Variant::INT, "index"), PropertyInfo(Variant::NIL, "restore"), PropertyInfo(Variant::BOOL, "cancel")); - cm.default_arguments.push_back(false); - BIND_VMETHOD(cm); - - BIND_VMETHOD(MethodInfo(Variant::BOOL, "_is_handle_highlighted", GIZMO_REF, PropertyInfo(Variant::INT, "index"))); - -#undef GIZMO_REF -} - -bool EditorNode3DGizmoPlugin::has_gizmo(Node3D *p_spatial) { - if (get_script_instance() && get_script_instance()->has_method("_has_gizmo")) { - return get_script_instance()->call("_has_gizmo", p_spatial); - } - return false; -} - -Ref<EditorNode3DGizmo> EditorNode3DGizmoPlugin::create_gizmo(Node3D *p_spatial) { - if (get_script_instance() && get_script_instance()->has_method("_create_gizmo")) { - return get_script_instance()->call("_create_gizmo", p_spatial); - } - - Ref<EditorNode3DGizmo> ref; - if (has_gizmo(p_spatial)) { - ref.instantiate(); - } - return ref; -} - -bool EditorNode3DGizmoPlugin::can_be_hidden() const { - if (get_script_instance() && get_script_instance()->has_method("_can_be_hidden")) { - return get_script_instance()->call("_can_be_hidden"); - } - return true; -} - -bool EditorNode3DGizmoPlugin::is_selectable_when_hidden() const { - if (get_script_instance() && get_script_instance()->has_method("_is_selectable_when_hidden")) { - return get_script_instance()->call("_is_selectable_when_hidden"); - } - return false; -} - -void EditorNode3DGizmoPlugin::redraw(EditorNode3DGizmo *p_gizmo) { - if (get_script_instance() && get_script_instance()->has_method("_redraw")) { - Ref<EditorNode3DGizmo> ref(p_gizmo); - get_script_instance()->call("_redraw", ref); - } -} - -String EditorNode3DGizmoPlugin::get_handle_name(const EditorNode3DGizmo *p_gizmo, int p_idx) const { - if (get_script_instance() && get_script_instance()->has_method("_get_handle_name")) { - return get_script_instance()->call("_get_handle_name", p_gizmo, p_idx); - } - return ""; -} - -Variant EditorNode3DGizmoPlugin::get_handle_value(EditorNode3DGizmo *p_gizmo, int p_idx) const { - if (get_script_instance() && get_script_instance()->has_method("_get_handle_value")) { - return get_script_instance()->call("_get_handle_value", p_gizmo, p_idx); - } - return Variant(); -} - -void EditorNode3DGizmoPlugin::set_handle(EditorNode3DGizmo *p_gizmo, int p_idx, Camera3D *p_camera, const Point2 &p_point) { - if (get_script_instance() && get_script_instance()->has_method("_set_handle")) { - get_script_instance()->call("_set_handle", p_gizmo, p_idx, p_camera, p_point); - } -} - -void EditorNode3DGizmoPlugin::commit_handle(EditorNode3DGizmo *p_gizmo, int p_idx, const Variant &p_restore, bool p_cancel) { - if (get_script_instance() && get_script_instance()->has_method("_commit_handle")) { - get_script_instance()->call("_commit_handle", p_gizmo, p_idx, p_restore, p_cancel); - } -} - -bool EditorNode3DGizmoPlugin::is_handle_highlighted(const EditorNode3DGizmo *p_gizmo, int p_idx) const { - if (get_script_instance() && get_script_instance()->has_method("_is_handle_highlighted")) { - return get_script_instance()->call("_is_handle_highlighted", p_gizmo, p_idx); - } - return false; -} - -void EditorNode3DGizmoPlugin::set_state(int p_state) { - current_state = p_state; - for (int i = 0; i < current_gizmos.size(); ++i) { - current_gizmos[i]->set_hidden(current_state == HIDDEN); - } -} - -int EditorNode3DGizmoPlugin::get_state() const { - return current_state; -} - -void EditorNode3DGizmoPlugin::unregister_gizmo(EditorNode3DGizmo *p_gizmo) { - current_gizmos.erase(p_gizmo); -} - -EditorNode3DGizmoPlugin::EditorNode3DGizmoPlugin() { - current_state = VISIBLE; -} - -EditorNode3DGizmoPlugin::~EditorNode3DGizmoPlugin() { - for (int i = 0; i < current_gizmos.size(); ++i) { - current_gizmos[i]->set_plugin(nullptr); - current_gizmos[i]->get_spatial_node()->set_gizmo(nullptr); - } - if (Node3DEditor::get_singleton()) { - Node3DEditor::get_singleton()->update_all_gizmos(); - } -} diff --git a/editor/plugins/node_3d_editor_plugin.h b/editor/plugins/node_3d_editor_plugin.h index a195a0eee0..6ac3345daf 100644 --- a/editor/plugins/node_3d_editor_plugin.h +++ b/editor/plugins/node_3d_editor_plugin.h @@ -34,6 +34,7 @@ #include "editor/editor_node.h" #include "editor/editor_plugin.h" #include "editor/editor_scale.h" +#include "editor/plugins/node_3d_editor_gizmos.h" #include "scene/3d/light_3d.h" #include "scene/3d/visual_instance_3d.h" #include "scene/3d/world_environment.h" @@ -43,96 +44,10 @@ class Camera3D; class Node3DEditor; -class EditorNode3DGizmoPlugin; class Node3DEditorViewport; class SubViewportContainer; - -class EditorNode3DGizmo : public Node3DGizmo { - GDCLASS(EditorNode3DGizmo, Node3DGizmo); - - bool selected; - bool instantiated; - -public: - void set_selected(bool p_selected) { selected = p_selected; } - bool is_selected() const { return selected; } - - struct Instance { - RID instance; - Ref<ArrayMesh> mesh; - Ref<Material> material; - Ref<SkinReference> skin_reference; - RID skeleton; - bool billboard = false; - bool unscaled = false; - bool can_intersect = false; - bool extra_margin = false; - - void create_instance(Node3D *p_base, bool p_hidden = false); - }; - - Vector<Vector3> collision_segments; - Ref<TriangleMesh> collision_mesh; - - struct Handle { - Vector3 pos; - bool billboard = false; - }; - - Vector<Vector3> handles; - Vector<Vector3> secondary_handles; - float selectable_icon_size; - bool billboard_handle; - - bool valid; - bool hidden; - Node3D *base; - Vector<Instance> instances; - Node3D *spatial_node; - EditorNode3DGizmoPlugin *gizmo_plugin; - - void _set_spatial_node(Node *p_node) { set_spatial_node(Object::cast_to<Node3D>(p_node)); } - -protected: - static void _bind_methods(); - -public: - void add_lines(const Vector<Vector3> &p_lines, const Ref<Material> &p_material, bool p_billboard = false, const Color &p_modulate = Color(1, 1, 1)); - void add_vertices(const Vector<Vector3> &p_vertices, const Ref<Material> &p_material, Mesh::PrimitiveType p_primitive_type, bool p_billboard = false, const Color &p_modulate = Color(1, 1, 1)); - void add_mesh(const Ref<ArrayMesh> &p_mesh, bool p_billboard = false, const Ref<SkinReference> &p_skin_reference = Ref<SkinReference>(), const Ref<Material> &p_material = Ref<Material>()); - void add_collision_segments(const Vector<Vector3> &p_lines); - void add_collision_triangles(const Ref<TriangleMesh> &p_tmesh); - void add_unscaled_billboard(const Ref<Material> &p_material, float p_scale = 1, const Color &p_modulate = Color(1, 1, 1)); - void add_handles(const Vector<Vector3> &p_handles, const Ref<Material> &p_material, bool p_billboard = false, bool p_secondary = false); - void add_solid_box(Ref<Material> &p_material, Vector3 p_size, Vector3 p_position = Vector3()); - - virtual bool is_handle_highlighted(int p_idx) const; - virtual String get_handle_name(int p_idx) const; - virtual Variant get_handle_value(int p_idx); - virtual void set_handle(int p_idx, Camera3D *p_camera, const Point2 &p_point); - virtual void commit_handle(int p_idx, const Variant &p_restore, bool p_cancel = false); - - void set_spatial_node(Node3D *p_node); - Node3D *get_spatial_node() const { return spatial_node; } - Ref<EditorNode3DGizmoPlugin> get_plugin() const { return gizmo_plugin; } - Vector3 get_handle_pos(int p_idx) const; - bool intersect_frustum(const Camera3D *p_camera, const Vector<Plane> &p_frustum); - bool intersect_ray(Camera3D *p_camera, const Point2 &p_point, Vector3 &r_pos, Vector3 &r_normal, int *r_gizmo_handle = nullptr, bool p_sec_first = false); - - virtual void clear() override; - virtual void create() override; - virtual void transform() override; - virtual void redraw() override; - virtual void free() override; - - virtual bool is_editable() const; - - void set_hidden(bool p_hidden); - void set_plugin(EditorNode3DGizmoPlugin *p_plugin); - - EditorNode3DGizmo(); - ~EditorNode3DGizmo(); -}; +class DirectionalLight3D; +class WorldEnvironment; class ViewportRotationControl : public Control { GDCLASS(ViewportRotationControl, Control); @@ -307,17 +222,15 @@ private: struct _RayResult { Node3D *item = nullptr; float depth = 0; - int handle = 0; _FORCE_INLINE_ bool operator<(const _RayResult &p_rr) const { return depth < p_rr.depth; } }; void _update_name(); void _compute_edit(const Point2 &p_point); void _clear_selected(); - void _select_clicked(bool p_append, bool p_single, bool p_allow_locked = false); - void _select(Node *p_node, bool p_append, bool p_single); - ObjectID _select_ray(const Point2 &p_pos, bool p_append, bool &r_includes_current, int *r_gizmo_handle = nullptr, bool p_alt_select = false); - void _find_items_at_pos(const Point2 &p_pos, bool &r_includes_current, Vector<_RayResult> &results, bool p_alt_select = false); + void _select_clicked(bool p_allow_locked); + ObjectID _select_ray(const Point2 &p_pos); + void _find_items_at_pos(const Point2 &p_pos, Vector<_RayResult> &r_results, bool p_include_locked); Vector3 _get_ray_pos(const Vector2 &p_pos) const; Vector3 _get_ray(const Vector2 &p_pos) const; Point2 _point_to_screen(const Vector3 &p_point); @@ -329,7 +242,8 @@ private: Vector3 _get_screen_to_space(const Vector3 &p_vector3); void _select_region(); - bool _gizmo_select(const Vector2 &p_screenpos, bool p_highlight_only = false); + bool _transform_gizmo_select(const Vector2 &p_screenpos, bool p_highlight_only = false); + void _transform_gizmo_apply(Node3D *p_node, const Transform3D &p_transform, bool p_local); void _nav_pan(Ref<InputEventWithModifiers> p_event, const Vector2 &p_relative); void _nav_zoom(Ref<InputEventWithModifiers> p_event, const Vector2 &p_relative); @@ -342,7 +256,6 @@ private: ObjectID clicked; Vector<_RayResult> selection_results; - bool clicked_includes_current; bool clicked_wants_append; PopupMenu *selection_menu; @@ -383,15 +296,12 @@ private: Vector3 click_ray; Vector3 click_ray_pos; Vector3 center; - Vector3 orig_gizmo_pos; - int edited_gizmo = 0; Point2 mouse_pos; Point2 original_mouse_pos; bool snap = false; Ref<EditorNode3DGizmo> gizmo; int gizmo_handle = 0; Variant gizmo_initial_value; - Vector3 gizmo_initial_pos; } _edit; struct Cursor { @@ -472,6 +382,8 @@ private: void _project_settings_changed(); + Transform3D _compute_transform(TransformMode p_mode, const Transform3D &p_original, const Transform3D &p_original_local, Vector3 p_motion, double p_extra, bool p_local); + protected: void _notification(int p_what); static void _bind_methods(); @@ -494,7 +406,7 @@ public: AcceptDialog *p_accept); SubViewport *get_viewport_node() { return viewport; } - Camera3D *get_camera() { return camera; } // return the default camera object. + Camera3D *get_camera_3d() { return camera; } // return the default camera object. Node3DEditorViewport(Node3DEditor *p_spatial_editor, EditorNode *p_editor, int p_index); ~Node3DEditorViewport(); @@ -512,6 +424,8 @@ public: Node3D *sp; RID sbox_instance; RID sbox_instance_xray; + Ref<EditorNode3DGizmo> gizmo; + Map<int, Transform3D> subgizmos; // map ID -> initial transform Node3DEditorSelectedItem() { sp = nullptr; @@ -617,7 +531,9 @@ private: Ref<StandardMaterial3D> plane_gizmo_color_hl[3]; Ref<ShaderMaterial> rotate_gizmo_color_hl[3]; - int over_gizmo_handle; + Ref<Node3DGizmo> current_hover_gizmo; + int current_hover_gizmo_handle; + float snap_translate_value; float snap_rotate_value; float snap_scale_value; @@ -688,7 +604,6 @@ private: LineEdit *snap_translate; LineEdit *snap_rotate; LineEdit *snap_scale; - PanelContainer *menu_panel; LineEdit *xform_translate[3]; LineEdit *xform_rotate[3]; @@ -710,6 +625,10 @@ private: void _update_camera_override_viewport(Object *p_viewport); HBoxContainer *hbc_menu; + // Used for secondary menu items which are displayed depending on the currently selected node + // (such as MeshInstance's "Mesh" menu). + PanelContainer *context_menu_container; + HBoxContainer *hbc_context_menu; void _generate_selection_boxes(); UndoRedo *undo_redo; @@ -717,6 +636,7 @@ private: int camera_override_viewport_id; void _init_indicators(); + void _update_context_menu_stylebox(); void _update_gizmos_menu(); void _update_gizmos_menu_theme(); void _init_grid(); @@ -734,6 +654,7 @@ private: Node3D *selected; void _request_gizmo(Object *p_obj); + void _clear_subgizmo_selection(Object *p_obj = nullptr); static Node3DEditor *singleton; @@ -746,8 +667,7 @@ private: Node3DEditor(); - bool is_any_freelook_active() const; - + void _selection_changed(); void _refresh_menu_icons(); // Preview Sun and Environment @@ -808,6 +728,8 @@ private: void _add_sun_to_scene(bool p_already_added_environment = false); void _add_environment_to_scene(bool p_already_added_sun = false); + void _update_theme(); + protected: void _notification(int p_what); //void _gui_input(InputEvent p_event); @@ -861,10 +783,16 @@ public: VSplitContainer *get_shader_split(); HSplitContainer *get_palette_split(); - Node3D *get_selected() { return selected; } + Node3D *get_single_selected_node() { return selected; } + bool is_current_selected_gizmo(const EditorNode3DGizmo *p_gizmo); + bool is_subgizmo_selected(int p_id); + Vector<int> get_subgizmo_selection(); + + Ref<EditorNode3DGizmo> get_current_hover_gizmo() const { return current_hover_gizmo; } + void set_current_hover_gizmo(Ref<EditorNode3DGizmo> p_gizmo) { current_hover_gizmo = p_gizmo; } - int get_over_gizmo_handle() const { return over_gizmo_handle; } - void set_over_gizmo_handle(int idx) { over_gizmo_handle = idx; } + void set_current_hover_gizmo_handle(int p_id) { current_hover_gizmo_handle = p_id; } + int get_current_hover_gizmo_handle() const { return current_hover_gizmo_handle; } void set_can_preview(Camera3D *p_preview); @@ -907,50 +835,4 @@ public: ~Node3DEditorPlugin(); }; -class EditorNode3DGizmoPlugin : public Resource { - GDCLASS(EditorNode3DGizmoPlugin, Resource); - -public: - static const int VISIBLE = 0; - static const int HIDDEN = 1; - static const int ON_TOP = 2; - -protected: - int current_state; - List<EditorNode3DGizmo *> current_gizmos; - HashMap<String, Vector<Ref<StandardMaterial3D>>> materials; - - static void _bind_methods(); - virtual bool has_gizmo(Node3D *p_spatial); - virtual Ref<EditorNode3DGizmo> create_gizmo(Node3D *p_spatial); - -public: - void create_material(const String &p_name, const Color &p_color, bool p_billboard = false, bool p_on_top = false, bool p_use_vertex_color = false); - void create_icon_material(const String &p_name, const Ref<Texture2D> &p_texture, bool p_on_top = false, const Color &p_albedo = Color(1, 1, 1, 1)); - void create_handle_material(const String &p_name, bool p_billboard = false, const Ref<Texture2D> &p_texture = nullptr); - void add_material(const String &p_name, Ref<StandardMaterial3D> p_material); - - Ref<StandardMaterial3D> get_material(const String &p_name, const Ref<EditorNode3DGizmo> &p_gizmo = Ref<EditorNode3DGizmo>()); - - virtual String get_gizmo_name() const; - virtual int get_priority() const; - virtual bool can_be_hidden() const; - virtual bool is_selectable_when_hidden() const; - - virtual void redraw(EditorNode3DGizmo *p_gizmo); - virtual String get_handle_name(const EditorNode3DGizmo *p_gizmo, int p_idx) const; - virtual Variant get_handle_value(EditorNode3DGizmo *p_gizmo, int p_idx) const; - virtual void set_handle(EditorNode3DGizmo *p_gizmo, int p_idx, Camera3D *p_camera, const Point2 &p_point); - virtual void commit_handle(EditorNode3DGizmo *p_gizmo, int p_idx, const Variant &p_restore, bool p_cancel = false); - virtual bool is_handle_highlighted(const EditorNode3DGizmo *p_gizmo, int p_idx) const; - - Ref<EditorNode3DGizmo> get_gizmo(Node3D *p_spatial); - void set_state(int p_state); - int get_state() const; - void unregister_gizmo(EditorNode3DGizmo *p_gizmo); - - EditorNode3DGizmoPlugin(); - virtual ~EditorNode3DGizmoPlugin(); -}; - #endif // NODE_3D_EDITOR_PLUGIN_H diff --git a/editor/plugins/occluder_instance_3d_editor_plugin.cpp b/editor/plugins/occluder_instance_3d_editor_plugin.cpp index b0cafd83be..ab88b9f00d 100644 --- a/editor/plugins/occluder_instance_3d_editor_plugin.cpp +++ b/editor/plugins/occluder_instance_3d_editor_plugin.cpp @@ -98,7 +98,7 @@ OccluderInstance3DEditorPlugin::OccluderInstance3DEditorPlugin(EditorNode *p_nod editor = p_node; bake = memnew(Button); bake->set_flat(true); - bake->set_icon(editor->get_gui_base()->get_theme_icon("Bake", "EditorIcons")); + bake->set_icon(editor->get_gui_base()->get_theme_icon(SNAME("Bake"), SNAME("EditorIcons"))); bake->set_text(TTR("Bake Occluders")); bake->hide(); bake->connect("pressed", Callable(this, "_bake")); diff --git a/editor/plugins/ot_features_plugin.cpp b/editor/plugins/ot_features_plugin.cpp index 2ac90762e3..fd42bce06e 100644 --- a/editor/plugins/ot_features_plugin.cpp +++ b/editor/plugins/ot_features_plugin.cpp @@ -49,10 +49,10 @@ void OpenTypeFeaturesEditor::update_property() { void OpenTypeFeaturesEditor::_notification(int p_what) { if (p_what == NOTIFICATION_ENTER_TREE || p_what == NOTIFICATION_THEME_CHANGED) { - Color base = get_theme_color("accent_color", "Editor"); + Color base = get_theme_color(SNAME("accent_color"), SNAME("Editor")); - button->set_icon(get_theme_icon("Remove", "EditorIcons")); - button->set_size(get_theme_icon("Remove", "EditorIcons")->get_size()); + button->set_icon(get_theme_icon(SNAME("Remove"), SNAME("EditorIcons"))); + button->set_size(get_theme_icon(SNAME("Remove"), SNAME("EditorIcons"))->get_size()); spin->set_custom_label_color(true, base); } } @@ -106,7 +106,7 @@ void OpenTypeFeaturesAdd::update_property() { bool have_ss = false; bool have_cv = false; bool have_cu = false; - Dictionary features = Object::cast_to<Control>(get_edited_object())->get_theme_font("font")->get_feature_list(); + Dictionary features = Object::cast_to<Control>(get_edited_object())->get_theme_font(SNAME("font"))->get_feature_list(); for (const Variant *ftr = features.next(nullptr); ftr != nullptr; ftr = features.next(ftr)) { String ftr_name = TS->tag_to_name(*ftr); if (ftr_name.begins_with("stylistic_set_")) { @@ -142,8 +142,8 @@ void OpenTypeFeaturesAdd::_features_menu() { void OpenTypeFeaturesAdd::_notification(int p_what) { if (p_what == NOTIFICATION_THEME_CHANGED || p_what == NOTIFICATION_ENTER_TREE) { set_label(""); - button->set_icon(get_theme_icon("Add", "EditorIcons")); - button->set_size(get_theme_icon("Add", "EditorIcons")->get_size()); + button->set_icon(get_theme_icon(SNAME("Add"), SNAME("EditorIcons"))); + button->set_size(get_theme_icon(SNAME("Add"), SNAME("EditorIcons"))->get_size()); } } diff --git a/editor/plugins/path_2d_editor_plugin.cpp b/editor/plugins/path_2d_editor_plugin.cpp index 838e67b5e7..8866e8c53e 100644 --- a/editor/plugins/path_2d_editor_plugin.cpp +++ b/editor/plugins/path_2d_editor_plugin.cpp @@ -364,12 +364,12 @@ void Path2DEditor::forward_canvas_draw_over_viewport(Control *p_overlay) { Transform2D xform = canvas_item_editor->get_canvas_transform() * node->get_global_transform(); - const Ref<Texture2D> path_sharp_handle = get_theme_icon("EditorPathSharpHandle", "EditorIcons"); - const Ref<Texture2D> path_smooth_handle = get_theme_icon("EditorPathSmoothHandle", "EditorIcons"); + const Ref<Texture2D> path_sharp_handle = get_theme_icon(SNAME("EditorPathSharpHandle"), SNAME("EditorIcons")); + const Ref<Texture2D> path_smooth_handle = get_theme_icon(SNAME("EditorPathSmoothHandle"), SNAME("EditorIcons")); // Both handle icons must be of the same size const Size2 handle_size = path_sharp_handle->get_size(); - const Ref<Texture2D> curve_handle = get_theme_icon("EditorCurveHandle", "EditorIcons"); + const Ref<Texture2D> curve_handle = get_theme_icon(SNAME("EditorCurveHandle"), SNAME("EditorIcons")); const Size2 curve_handle_size = curve_handle->get_size(); Ref<Curve2D> curve = node->get_curve(); @@ -411,7 +411,7 @@ void Path2DEditor::forward_canvas_draw_over_viewport(Control *p_overlay) { } if (on_edge) { - Ref<Texture2D> add_handle = get_theme_icon("EditorHandleAdd", "EditorIcons"); + Ref<Texture2D> add_handle = get_theme_icon(SNAME("EditorHandleAdd"), SNAME("EditorIcons")); p_overlay->draw_texture(add_handle, edge_point - add_handle->get_size() * 0.5); } } @@ -481,7 +481,7 @@ void Path2DEditor::_mode_selected(int p_mode) { Vector2 begin = node->get_curve()->get_point_position(0); Vector2 end = node->get_curve()->get_point_position(node->get_curve()->get_point_count() - 1); - if (begin.distance_to(end) < CMP_EPSILON) { + if (begin.is_equal_approx(end)) { return; } @@ -534,7 +534,7 @@ Path2DEditor::Path2DEditor(EditorNode *p_editor) { base_hb->add_child(sep); curve_edit = memnew(Button); curve_edit->set_flat(true); - curve_edit->set_icon(EditorNode::get_singleton()->get_gui_base()->get_theme_icon("CurveEdit", "EditorIcons")); + curve_edit->set_icon(EditorNode::get_singleton()->get_gui_base()->get_theme_icon(SNAME("CurveEdit"), SNAME("EditorIcons"))); curve_edit->set_toggle_mode(true); curve_edit->set_focus_mode(Control::FOCUS_NONE); curve_edit->set_tooltip(TTR("Select Points") + "\n" + TTR("Shift+Drag: Select Control Points") + "\n" + keycode_get_string(KEY_MASK_CMD) + TTR("Click: Add Point") + "\n" + TTR("Left Click: Split Segment (in curve)") + "\n" + TTR("Right Click: Delete Point")); @@ -542,7 +542,7 @@ Path2DEditor::Path2DEditor(EditorNode *p_editor) { base_hb->add_child(curve_edit); curve_edit_curve = memnew(Button); curve_edit_curve->set_flat(true); - curve_edit_curve->set_icon(EditorNode::get_singleton()->get_gui_base()->get_theme_icon("CurveCurve", "EditorIcons")); + curve_edit_curve->set_icon(EditorNode::get_singleton()->get_gui_base()->get_theme_icon(SNAME("CurveCurve"), SNAME("EditorIcons"))); curve_edit_curve->set_toggle_mode(true); curve_edit_curve->set_focus_mode(Control::FOCUS_NONE); curve_edit_curve->set_tooltip(TTR("Select Control Points (Shift+Drag)")); @@ -550,7 +550,7 @@ Path2DEditor::Path2DEditor(EditorNode *p_editor) { base_hb->add_child(curve_edit_curve); curve_create = memnew(Button); curve_create->set_flat(true); - curve_create->set_icon(EditorNode::get_singleton()->get_gui_base()->get_theme_icon("CurveCreate", "EditorIcons")); + curve_create->set_icon(EditorNode::get_singleton()->get_gui_base()->get_theme_icon(SNAME("CurveCreate"), SNAME("EditorIcons"))); curve_create->set_toggle_mode(true); curve_create->set_focus_mode(Control::FOCUS_NONE); curve_create->set_tooltip(TTR("Add Point (in empty space)")); @@ -558,7 +558,7 @@ Path2DEditor::Path2DEditor(EditorNode *p_editor) { base_hb->add_child(curve_create); curve_del = memnew(Button); curve_del->set_flat(true); - curve_del->set_icon(EditorNode::get_singleton()->get_gui_base()->get_theme_icon("CurveDelete", "EditorIcons")); + curve_del->set_icon(EditorNode::get_singleton()->get_gui_base()->get_theme_icon(SNAME("CurveDelete"), SNAME("EditorIcons"))); curve_del->set_toggle_mode(true); curve_del->set_focus_mode(Control::FOCUS_NONE); curve_del->set_tooltip(TTR("Delete Point")); @@ -566,7 +566,7 @@ Path2DEditor::Path2DEditor(EditorNode *p_editor) { base_hb->add_child(curve_del); curve_close = memnew(Button); curve_close->set_flat(true); - curve_close->set_icon(EditorNode::get_singleton()->get_gui_base()->get_theme_icon("CurveClose", "EditorIcons")); + curve_close->set_icon(EditorNode::get_singleton()->get_gui_base()->get_theme_icon(SNAME("CurveClose"), SNAME("EditorIcons"))); curve_close->set_focus_mode(Control::FOCUS_NONE); curve_close->set_tooltip(TTR("Close Curve")); curve_close->connect("pressed", callable_mp(this, &Path2DEditor::_mode_selected), varray(ACTION_CLOSE)); diff --git a/editor/plugins/path_3d_editor_plugin.cpp b/editor/plugins/path_3d_editor_plugin.cpp index 82b51f8a06..63b89aea35 100644 --- a/editor/plugins/path_3d_editor_plugin.cpp +++ b/editor/plugins/path_3d_editor_plugin.cpp @@ -36,20 +36,20 @@ #include "node_3d_editor_plugin.h" #include "scene/resources/curve.h" -String Path3DGizmo::get_handle_name(int p_idx) const { +String Path3DGizmo::get_handle_name(int p_id) const { Ref<Curve3D> c = path->get_curve(); if (c.is_null()) { return ""; } - if (p_idx < c->get_point_count()) { - return TTR("Curve Point #") + itos(p_idx); + if (p_id < c->get_point_count()) { + return TTR("Curve Point #") + itos(p_id); } - p_idx = p_idx - c->get_point_count() + 1; + p_id = p_id - c->get_point_count() + 1; - int idx = p_idx / 2; - int t = p_idx % 2; + int idx = p_id / 2; + int t = p_id % 2; String n = TTR("Curve Point #") + itos(idx); if (t == 0) { n += " In"; @@ -60,21 +60,21 @@ String Path3DGizmo::get_handle_name(int p_idx) const { return n; } -Variant Path3DGizmo::get_handle_value(int p_idx) { +Variant Path3DGizmo::get_handle_value(int p_id) const { Ref<Curve3D> c = path->get_curve(); if (c.is_null()) { return Variant(); } - if (p_idx < c->get_point_count()) { - original = c->get_point_position(p_idx); + if (p_id < c->get_point_count()) { + original = c->get_point_position(p_id); return original; } - p_idx = p_idx - c->get_point_count() + 1; + p_id = p_id - c->get_point_count() + 1; - int idx = p_idx / 2; - int t = p_idx % 2; + int idx = p_id / 2; + int t = p_id % 2; Vector3 ofs; if (t == 0) { @@ -88,7 +88,7 @@ Variant Path3DGizmo::get_handle_value(int p_idx) { return ofs; } -void Path3DGizmo::set_handle(int p_idx, Camera3D *p_camera, const Point2 &p_point) { +void Path3DGizmo::set_handle(int p_id, Camera3D *p_camera, const Point2 &p_point) const { Ref<Curve3D> c = path->get_curve(); if (c.is_null()) { return; @@ -100,7 +100,7 @@ void Path3DGizmo::set_handle(int p_idx, Camera3D *p_camera, const Point2 &p_poin Vector3 ray_dir = p_camera->project_ray_normal(p_point); // Setting curve point positions - if (p_idx < c->get_point_count()) { + if (p_id < c->get_point_count()) { Plane p(gt.xform(original), p_camera->get_transform().basis.get_axis(2)); Vector3 inters; @@ -112,16 +112,16 @@ void Path3DGizmo::set_handle(int p_idx, Camera3D *p_camera, const Point2 &p_poin } Vector3 local = gi.xform(inters); - c->set_point_position(p_idx, local); + c->set_point_position(p_id, local); } return; } - p_idx = p_idx - c->get_point_count() + 1; + p_id = p_id - c->get_point_count() + 1; - int idx = p_idx / 2; - int t = p_idx % 2; + int idx = p_id / 2; + int t = p_id % 2; Vector3 base = c->get_point_position(idx); @@ -157,7 +157,7 @@ void Path3DGizmo::set_handle(int p_idx, Camera3D *p_camera, const Point2 &p_poin } } -void Path3DGizmo::commit_handle(int p_idx, const Variant &p_restore, bool p_cancel) { +void Path3DGizmo::commit_handle(int p_id, const Variant &p_restore, bool p_cancel) const { Ref<Curve3D> c = path->get_curve(); if (c.is_null()) { return; @@ -165,27 +165,27 @@ void Path3DGizmo::commit_handle(int p_idx, const Variant &p_restore, bool p_canc UndoRedo *ur = Node3DEditor::get_singleton()->get_undo_redo(); - if (p_idx < c->get_point_count()) { + if (p_id < c->get_point_count()) { if (p_cancel) { - c->set_point_position(p_idx, p_restore); + c->set_point_position(p_id, p_restore); return; } ur->create_action(TTR("Set Curve Point Position")); - ur->add_do_method(c.ptr(), "set_point_position", p_idx, c->get_point_position(p_idx)); - ur->add_undo_method(c.ptr(), "set_point_position", p_idx, p_restore); + ur->add_do_method(c.ptr(), "set_point_position", p_id, c->get_point_position(p_id)); + ur->add_undo_method(c.ptr(), "set_point_position", p_id, p_restore); ur->commit_action(); return; } - p_idx = p_idx - c->get_point_count() + 1; + p_id = p_id - c->get_point_count() + 1; - int idx = p_idx / 2; - int t = p_idx % 2; + int idx = p_id / 2; + int t = p_id % 2; if (t == 0) { if (p_cancel) { - c->set_point_in(p_idx, p_restore); + c->set_point_in(p_id, p_restore); return; } @@ -282,7 +282,7 @@ void Path3DGizmo::redraw() { add_handles(handles, handles_material); } if (sec_handles.size()) { - add_handles(sec_handles, sec_handles_material, false, true); + add_handles(sec_handles, sec_handles_material, Vector<int>(), false, true); } } } @@ -453,14 +453,14 @@ void Path3DEditorPlugin::edit(Object *p_object) { path = Object::cast_to<Path3D>(p_object); if (path) { if (path->get_curve().is_valid()) { - path->get_curve()->emit_signal("changed"); + path->get_curve()->emit_signal(SNAME("changed")); } } } else { Path3D *pre = path; path = nullptr; if (pre) { - pre->get_curve()->emit_signal("changed"); + pre->get_curve()->emit_signal(SNAME("changed")); } } //collision_polygon_editor->edit(Object::cast_to<Node>(p_object)); @@ -490,7 +490,7 @@ void Path3DEditorPlugin::make_visible(bool p_visible) { Path3D *pre = path; path = nullptr; if (pre && pre->get_curve().is_valid()) { - pre->get_curve()->emit_signal("changed"); + pre->get_curve()->emit_signal(SNAME("changed")); } } } @@ -562,7 +562,7 @@ Path3DEditorPlugin::Path3DEditorPlugin(EditorNode *p_node) { Node3DEditor::get_singleton()->add_control_to_menu_panel(sep); curve_edit = memnew(Button); curve_edit->set_flat(true); - curve_edit->set_icon(EditorNode::get_singleton()->get_gui_base()->get_theme_icon("CurveEdit", "EditorIcons")); + curve_edit->set_icon(EditorNode::get_singleton()->get_gui_base()->get_theme_icon(SNAME("CurveEdit"), SNAME("EditorIcons"))); curve_edit->set_toggle_mode(true); curve_edit->hide(); curve_edit->set_focus_mode(Control::FOCUS_NONE); @@ -570,7 +570,7 @@ Path3DEditorPlugin::Path3DEditorPlugin(EditorNode *p_node) { Node3DEditor::get_singleton()->add_control_to_menu_panel(curve_edit); curve_create = memnew(Button); curve_create->set_flat(true); - curve_create->set_icon(EditorNode::get_singleton()->get_gui_base()->get_theme_icon("CurveCreate", "EditorIcons")); + curve_create->set_icon(EditorNode::get_singleton()->get_gui_base()->get_theme_icon(SNAME("CurveCreate"), SNAME("EditorIcons"))); curve_create->set_toggle_mode(true); curve_create->hide(); curve_create->set_focus_mode(Control::FOCUS_NONE); @@ -578,7 +578,7 @@ Path3DEditorPlugin::Path3DEditorPlugin(EditorNode *p_node) { Node3DEditor::get_singleton()->add_control_to_menu_panel(curve_create); curve_del = memnew(Button); curve_del->set_flat(true); - curve_del->set_icon(EditorNode::get_singleton()->get_gui_base()->get_theme_icon("CurveDelete", "EditorIcons")); + curve_del->set_icon(EditorNode::get_singleton()->get_gui_base()->get_theme_icon(SNAME("CurveDelete"), SNAME("EditorIcons"))); curve_del->set_toggle_mode(true); curve_del->hide(); curve_del->set_focus_mode(Control::FOCUS_NONE); @@ -586,7 +586,7 @@ Path3DEditorPlugin::Path3DEditorPlugin(EditorNode *p_node) { Node3DEditor::get_singleton()->add_control_to_menu_panel(curve_del); curve_close = memnew(Button); curve_close->set_flat(true); - curve_close->set_icon(EditorNode::get_singleton()->get_gui_base()->get_theme_icon("CurveClose", "EditorIcons")); + curve_close->set_icon(EditorNode::get_singleton()->get_gui_base()->get_theme_icon(SNAME("CurveClose"), SNAME("EditorIcons"))); curve_close->hide(); curve_close->set_focus_mode(Control::FOCUS_NONE); curve_close->set_tooltip(TTR("Close Curve")); @@ -644,6 +644,6 @@ Path3DGizmoPlugin::Path3DGizmoPlugin() { Color path_color = EDITOR_DEF("editors/3d_gizmos/gizmo_colors/path", Color(0.5, 0.5, 1.0, 0.8)); create_material("path_material", path_color); create_material("path_thin_material", Color(0.5, 0.5, 0.5)); - create_handle_material("handles", false, Node3DEditor::get_singleton()->get_theme_icon("EditorPathSmoothHandle", "EditorIcons")); - create_handle_material("sec_handles", false, Node3DEditor::get_singleton()->get_theme_icon("EditorCurveHandle", "EditorIcons")); + create_handle_material("handles", false, Node3DEditor::get_singleton()->get_theme_icon(SNAME("EditorPathSmoothHandle"), SNAME("EditorIcons"))); + create_handle_material("sec_handles", false, Node3DEditor::get_singleton()->get_theme_icon(SNAME("EditorCurveHandle"), SNAME("EditorIcons"))); } diff --git a/editor/plugins/path_3d_editor_plugin.h b/editor/plugins/path_3d_editor_plugin.h index 13870d7591..5902500526 100644 --- a/editor/plugins/path_3d_editor_plugin.h +++ b/editor/plugins/path_3d_editor_plugin.h @@ -31,7 +31,9 @@ #ifndef PATH_EDITOR_PLUGIN_H #define PATH_EDITOR_PLUGIN_H -#include "editor/node_3d_editor_gizmos.h" +#include "editor/editor_plugin.h" +#include "editor/plugins/node_3d_editor_gizmos.h" +#include "scene/3d/camera_3d.h" #include "scene/3d/path_3d.h" class Path3DGizmo : public EditorNode3DGizmo { @@ -44,9 +46,9 @@ class Path3DGizmo : public EditorNode3DGizmo { public: virtual String get_handle_name(int p_idx) const override; - virtual Variant get_handle_value(int p_idx) override; - virtual void set_handle(int p_idx, Camera3D *p_camera, const Point2 &p_point) override; - virtual void commit_handle(int p_idx, const Variant &p_restore, bool p_cancel = false) override; + virtual Variant get_handle_value(int p_id) const override; + virtual void set_handle(int p_id, Camera3D *p_camera, const Point2 &p_point) const override; + virtual void commit_handle(int p_id, const Variant &p_restore, bool p_cancel = false) const override; virtual void redraw() override; Path3DGizmo(Path3D *p_path = nullptr); diff --git a/editor/plugins/physical_bone_3d_editor_plugin.cpp b/editor/plugins/physical_bone_3d_editor_plugin.cpp index 4b52512933..f92f50f826 100644 --- a/editor/plugins/physical_bone_3d_editor_plugin.cpp +++ b/editor/plugins/physical_bone_3d_editor_plugin.cpp @@ -60,7 +60,7 @@ PhysicalBone3DEditor::PhysicalBone3DEditor(EditorNode *p_editor) : spatial_editor_hb->add_child(button_transform_joint); button_transform_joint->set_text(TTR("Move Joint")); - button_transform_joint->set_icon(Node3DEditor::get_singleton()->get_theme_icon("PhysicalBone3D", "EditorIcons")); + button_transform_joint->set_icon(Node3DEditor::get_singleton()->get_theme_icon(SNAME("PhysicalBone3D"), SNAME("EditorIcons"))); button_transform_joint->set_toggle_mode(true); button_transform_joint->connect("toggled", callable_mp(this, &PhysicalBone3DEditor::_on_toggle_button_transform_joint)); diff --git a/editor/plugins/polygon_2d_editor_plugin.cpp b/editor/plugins/polygon_2d_editor_plugin.cpp index 1a13a028c8..b420372eff 100644 --- a/editor/plugins/polygon_2d_editor_plugin.cpp +++ b/editor/plugins/polygon_2d_editor_plugin.cpp @@ -64,27 +64,27 @@ void Polygon2DEditor::_notification(int p_what) { switch (p_what) { case NOTIFICATION_ENTER_TREE: case NOTIFICATION_THEME_CHANGED: { - uv_edit_draw->add_theme_style_override("panel", get_theme_stylebox("bg", "Tree")); - bone_scroll->add_theme_style_override("bg", get_theme_stylebox("bg", "Tree")); + uv_edit_draw->add_theme_style_override("panel", get_theme_stylebox(SNAME("bg"), SNAME("Tree"))); + bone_scroll->add_theme_style_override("bg", get_theme_stylebox(SNAME("bg"), SNAME("Tree"))); } break; case NOTIFICATION_READY: { - button_uv->set_icon(get_theme_icon("Uv", "EditorIcons")); - - uv_button[UV_MODE_CREATE]->set_icon(get_theme_icon("Edit", "EditorIcons")); - uv_button[UV_MODE_CREATE_INTERNAL]->set_icon(get_theme_icon("EditInternal", "EditorIcons")); - uv_button[UV_MODE_REMOVE_INTERNAL]->set_icon(get_theme_icon("RemoveInternal", "EditorIcons")); - uv_button[UV_MODE_EDIT_POINT]->set_icon(get_theme_icon("ToolSelect", "EditorIcons")); - uv_button[UV_MODE_MOVE]->set_icon(get_theme_icon("ToolMove", "EditorIcons")); - uv_button[UV_MODE_ROTATE]->set_icon(get_theme_icon("ToolRotate", "EditorIcons")); - uv_button[UV_MODE_SCALE]->set_icon(get_theme_icon("ToolScale", "EditorIcons")); - uv_button[UV_MODE_ADD_POLYGON]->set_icon(get_theme_icon("Edit", "EditorIcons")); - uv_button[UV_MODE_REMOVE_POLYGON]->set_icon(get_theme_icon("Close", "EditorIcons")); - uv_button[UV_MODE_PAINT_WEIGHT]->set_icon(get_theme_icon("Bucket", "EditorIcons")); - uv_button[UV_MODE_CLEAR_WEIGHT]->set_icon(get_theme_icon("Clear", "EditorIcons")); - - b_snap_grid->set_icon(get_theme_icon("Grid", "EditorIcons")); - b_snap_enable->set_icon(get_theme_icon("SnapGrid", "EditorIcons")); - uv_icon_zoom->set_texture(get_theme_icon("Zoom", "EditorIcons")); + button_uv->set_icon(get_theme_icon(SNAME("Uv"), SNAME("EditorIcons"))); + + uv_button[UV_MODE_CREATE]->set_icon(get_theme_icon(SNAME("Edit"), SNAME("EditorIcons"))); + uv_button[UV_MODE_CREATE_INTERNAL]->set_icon(get_theme_icon(SNAME("EditInternal"), SNAME("EditorIcons"))); + uv_button[UV_MODE_REMOVE_INTERNAL]->set_icon(get_theme_icon(SNAME("RemoveInternal"), SNAME("EditorIcons"))); + uv_button[UV_MODE_EDIT_POINT]->set_icon(get_theme_icon(SNAME("ToolSelect"), SNAME("EditorIcons"))); + uv_button[UV_MODE_MOVE]->set_icon(get_theme_icon(SNAME("ToolMove"), SNAME("EditorIcons"))); + uv_button[UV_MODE_ROTATE]->set_icon(get_theme_icon(SNAME("ToolRotate"), SNAME("EditorIcons"))); + uv_button[UV_MODE_SCALE]->set_icon(get_theme_icon(SNAME("ToolScale"), SNAME("EditorIcons"))); + uv_button[UV_MODE_ADD_POLYGON]->set_icon(get_theme_icon(SNAME("Edit"), SNAME("EditorIcons"))); + uv_button[UV_MODE_REMOVE_POLYGON]->set_icon(get_theme_icon(SNAME("Close"), SNAME("EditorIcons"))); + uv_button[UV_MODE_PAINT_WEIGHT]->set_icon(get_theme_icon(SNAME("Bucket"), SNAME("EditorIcons"))); + uv_button[UV_MODE_CLEAR_WEIGHT]->set_icon(get_theme_icon(SNAME("Clear"), SNAME("EditorIcons"))); + + b_snap_grid->set_icon(get_theme_icon(SNAME("Grid"), SNAME("EditorIcons"))); + b_snap_enable->set_icon(get_theme_icon(SNAME("SnapGrid"), SNAME("EditorIcons"))); + uv_icon_zoom->set_texture(get_theme_icon(SNAME("Zoom"), SNAME("EditorIcons"))); uv_vscroll->set_anchors_and_offsets_preset(PRESET_RIGHT_WIDE); uv_hscroll->set_anchors_and_offsets_preset(PRESET_BOTTOM_WIDE); @@ -1015,7 +1015,7 @@ void Polygon2DEditor::_uv_draw() { } // All UV points are sharp, so use the sharp handle icon - Ref<Texture2D> handle = get_theme_icon("EditorPathSharpHandle", "EditorIcons"); + Ref<Texture2D> handle = get_theme_icon(SNAME("EditorPathSharpHandle"), SNAME("EditorIcons")); Color poly_line_color = Color(0.9, 0.5, 0.5); if (polygons.size() || polygon_create.size()) { diff --git a/editor/plugins/resource_preloader_editor_plugin.cpp b/editor/plugins/resource_preloader_editor_plugin.cpp index 488aa8c861..cbea2405b8 100644 --- a/editor/plugins/resource_preloader_editor_plugin.cpp +++ b/editor/plugins/resource_preloader_editor_plugin.cpp @@ -40,7 +40,7 @@ void ResourcePreloaderEditor::_gui_input(Ref<InputEvent> p_event) { void ResourcePreloaderEditor::_notification(int p_what) { if (p_what == NOTIFICATION_ENTER_TREE) { - load->set_icon(get_theme_icon("Folder", "EditorIcons")); + load->set_icon(get_theme_icon(SNAME("Folder"), SNAME("EditorIcons"))); } if (p_what == NOTIFICATION_READY) { @@ -181,21 +181,21 @@ void ResourcePreloaderEditor::_update_library() { preloader->get_resource_list(&rnames); List<String> names; - for (List<StringName>::Element *E = rnames.front(); E; E = E->next()) { - names.push_back(E->get()); + for (const StringName &E : rnames) { + names.push_back(E); } names.sort(); - for (List<String>::Element *E = names.front(); E; E = E->next()) { + for (const String &E : names) { TreeItem *ti = tree->create_item(root); ti->set_cell_mode(0, TreeItem::CELL_MODE_STRING); ti->set_editable(0, true); ti->set_selectable(0, true); - ti->set_text(0, E->get()); - ti->set_metadata(0, E->get()); + ti->set_text(0, E); + ti->set_metadata(0, E); - RES r = preloader->get_resource(E->get()); + RES r = preloader->get_resource(E); ERR_CONTINUE(r.is_null()); @@ -208,11 +208,11 @@ void ResourcePreloaderEditor::_update_library() { ti->set_selectable(1, false); if (type == "PackedScene") { - ti->add_button(1, get_theme_icon("InstanceOptions", "EditorIcons"), BUTTON_OPEN_SCENE, false, TTR("Open in Editor")); + ti->add_button(1, get_theme_icon(SNAME("InstanceOptions"), SNAME("EditorIcons")), BUTTON_OPEN_SCENE, false, TTR("Open in Editor")); } else { - ti->add_button(1, get_theme_icon("Load", "EditorIcons"), BUTTON_EDIT_RESOURCE, false, TTR("Open in Editor")); + ti->add_button(1, get_theme_icon(SNAME("Load"), SNAME("EditorIcons")), BUTTON_EDIT_RESOURCE, false, TTR("Open in Editor")); } - ti->add_button(1, get_theme_icon("Remove", "EditorIcons"), BUTTON_REMOVE, false, TTR("Remove")); + ti->add_button(1, get_theme_icon(SNAME("Remove"), SNAME("EditorIcons")), BUTTON_REMOVE, false, TTR("Remove")); } //player->add_resource("default",resource); diff --git a/editor/plugins/root_motion_editor_plugin.cpp b/editor/plugins/root_motion_editor_plugin.cpp index 120b0bc0bb..ed91f174d1 100644 --- a/editor/plugins/root_motion_editor_plugin.cpp +++ b/editor/plugins/root_motion_editor_plugin.cpp @@ -70,8 +70,8 @@ void EditorPropertyRootMotion::_node_assign() { List<StringName> animations; player->get_animation_list(&animations); - for (List<StringName>::Element *E = animations.front(); E; E = E->next()) { - Ref<Animation> anim = player->get_animation(E->get()); + for (const StringName &E : animations) { + Ref<Animation> anim = player->get_animation(E); for (int i = 0; i < anim->get_track_count(); i++) { paths.insert(anim->track_get_path(i)); } @@ -149,7 +149,7 @@ void EditorPropertyRootMotion::_node_assign() { ti->set_text(0, F->get()); ti->set_selectable(0, true); ti->set_editable(0, false); - ti->set_icon(0, get_theme_icon("BoneAttachment3D", "EditorIcons")); + ti->set_icon(0, get_theme_icon(SNAME("BoneAttachment3D"), SNAME("EditorIcons"))); ti->set_metadata(0, accum); } else { ti = parenthood[accum]; @@ -158,7 +158,7 @@ void EditorPropertyRootMotion::_node_assign() { ti->set_selectable(0, true); ti->set_text(0, concat); - ti->set_icon(0, get_theme_icon("BoneAttachment3D", "EditorIcons")); + ti->set_icon(0, get_theme_icon(SNAME("BoneAttachment3D"), SNAME("EditorIcons"))); ti->set_metadata(0, path); if (path == current) { ti->select(0); @@ -234,7 +234,7 @@ void EditorPropertyRootMotion::setup(const NodePath &p_base_hint) { void EditorPropertyRootMotion::_notification(int p_what) { if (p_what == NOTIFICATION_ENTER_TREE || p_what == NOTIFICATION_THEME_CHANGED) { - Ref<Texture2D> t = get_theme_icon("Clear", "EditorIcons"); + Ref<Texture2D> t = get_theme_icon(SNAME("Clear"), SNAME("EditorIcons")); clear->set_icon(t); } } diff --git a/editor/plugins/script_editor_plugin.cpp b/editor/plugins/script_editor_plugin.cpp index 498d5b0711..668a15da37 100644 --- a/editor/plugins/script_editor_plugin.cpp +++ b/editor/plugins/script_editor_plugin.cpp @@ -103,8 +103,8 @@ void EditorStandardSyntaxHighlighter::_update_cache() { const Color type_color = EDITOR_GET("text_editor/highlighting/engine_type_color"); List<StringName> types; ClassDB::get_class_list(&types); - for (List<StringName>::Element *E = types.front(); E; E = E->next()) { - String n = E->get(); + for (const StringName &E : types) { + String n = E; if (n.begins_with("_")) { n = n.substr(1, n.length()); } @@ -115,8 +115,8 @@ void EditorStandardSyntaxHighlighter::_update_cache() { const Color usertype_color = EDITOR_GET("text_editor/highlighting/user_type_color"); List<StringName> global_classes; ScriptServer::get_global_class_list(&global_classes); - for (List<StringName>::Element *E = global_classes.front(); E; E = E->next()) { - highlighter->add_keyword_color(E->get(), usertype_color); + for (const StringName &E : global_classes) { + highlighter->add_keyword_color(E, usertype_color); } /* Autoloads. */ @@ -134,8 +134,8 @@ void EditorStandardSyntaxHighlighter::_update_cache() { const Color basetype_color = EDITOR_GET("text_editor/highlighting/base_type_color"); List<String> core_types; script->get_language()->get_core_type_words(&core_types); - for (List<String>::Element *E = core_types.front(); E; E = E->next()) { - highlighter->add_keyword_color(E->get(), basetype_color); + for (const String &E : core_types) { + highlighter->add_keyword_color(E, basetype_color); } /* Reserved words. */ @@ -143,11 +143,11 @@ void EditorStandardSyntaxHighlighter::_update_cache() { const Color control_flow_keyword_color = EDITOR_GET("text_editor/highlighting/control_flow_keyword_color"); List<String> keywords; script->get_language()->get_reserved_words(&keywords); - for (List<String>::Element *E = keywords.front(); E; E = E->next()) { - if (script->get_language()->is_control_flow_keyword(E->get())) { - highlighter->add_keyword_color(E->get(), control_flow_keyword_color); + for (const String &E : keywords) { + if (script->get_language()->is_control_flow_keyword(E)) { + highlighter->add_keyword_color(E, control_flow_keyword_color); } else { - highlighter->add_keyword_color(E->get(), keyword_color); + highlighter->add_keyword_color(E, keyword_color); } } @@ -157,9 +157,9 @@ void EditorStandardSyntaxHighlighter::_update_cache() { if (instance_base != StringName()) { List<PropertyInfo> plist; ClassDB::get_property_list(instance_base, &plist); - for (List<PropertyInfo>::Element *E = plist.front(); E; E = E->next()) { - String name = E->get().name; - if (E->get().usage & PROPERTY_USAGE_CATEGORY || E->get().usage & PROPERTY_USAGE_GROUP || E->get().usage & PROPERTY_USAGE_SUBGROUP) { + for (const PropertyInfo &E : plist) { + String name = E.name; + if (E.usage & PROPERTY_USAGE_CATEGORY || E.usage & PROPERTY_USAGE_GROUP || E.usage & PROPERTY_USAGE_SUBGROUP) { continue; } if (name.find("/") != -1) { @@ -170,8 +170,8 @@ void EditorStandardSyntaxHighlighter::_update_cache() { List<String> clist; ClassDB::get_integer_constant_list(instance_base, &clist); - for (List<String>::Element *E = clist.front(); E; E = E->next()) { - highlighter->add_member_keyword_color(E->get(), member_variable_color); + for (const String &E : clist) { + highlighter->add_member_keyword_color(E, member_variable_color); } } @@ -179,8 +179,7 @@ void EditorStandardSyntaxHighlighter::_update_cache() { const Color comment_color = EDITOR_GET("text_editor/highlighting/comment_color"); List<String> comments; script->get_language()->get_comment_delimiters(&comments); - for (List<String>::Element *E = comments.front(); E; E = E->next()) { - String comment = E->get(); + for (const String &comment : comments) { String beg = comment.get_slice(" ", 0); String end = comment.get_slice_count(" ") > 1 ? comment.get_slice(" ", 1) : String(); highlighter->add_color_region(beg, end, comment_color, end == ""); @@ -190,8 +189,7 @@ void EditorStandardSyntaxHighlighter::_update_cache() { const Color string_color = EDITOR_GET("text_editor/highlighting/string_color"); List<String> strings; script->get_language()->get_string_delimiters(&strings); - for (List<String>::Element *E = strings.front(); E; E = E->next()) { - String string = E->get(); + for (const String &string : strings) { String beg = string.get_slice(" ", 0); String end = string.get_slice_count(" ") > 1 ? string.get_slice(" ", 1) : String(); highlighter->add_color_region(beg, end, string_color, end == ""); @@ -355,7 +353,7 @@ void ScriptEditorQuickOpen::_confirmed() { } int line = ti->get_text(0).get_slice(":", 1).to_int(); - emit_signal("goto_line", line - 1); + emit_signal(SNAME("goto_line"), line - 1); hide(); } @@ -368,7 +366,7 @@ void ScriptEditorQuickOpen::_notification(int p_what) { [[fallthrough]]; } case NOTIFICATION_VISIBILITY_CHANGED: { - search_box->set_right_icon(search_options->get_theme_icon("Search", "EditorIcons")); + search_box->set_right_icon(search_options->get_theme_icon(SNAME("Search"), SNAME("EditorIcons"))); } break; case NOTIFICATION_EXIT_TREE: { disconnect("confirmed", callable_mp(this, &ScriptEditorQuickOpen::_confirmed)); @@ -577,7 +575,7 @@ void ScriptEditor::_go_to_tab(int p_idx) { } if (Object::cast_to<EditorHelp>(c)) { script_name_label->set_text(Object::cast_to<EditorHelp>(c)->get_class()); - script_icon->set_texture(get_theme_icon("Help", "EditorIcons")); + script_icon->set_texture(get_theme_icon(SNAME("Help"), SNAME("EditorIcons"))); if (is_visible_in_tree()) { Object::cast_to<EditorHelp>(c)->set_focused(); } @@ -631,7 +629,7 @@ void ScriptEditor::_open_recent_script(int p_idx) { // clear button if (p_idx == recent_scripts->get_item_count() - 1) { EditorSettings::get_singleton()->set_project_metadata("recent_files", "scripts", Array()); - call_deferred("_update_recent_scripts"); + call_deferred(SNAME("_update_recent_scripts")); return; } @@ -946,7 +944,7 @@ void ScriptEditor::_res_saved_callback(const Ref<Resource> &p_res) { _update_script_names(); if (!pending_auto_reload && auto_reload_running_scripts) { - call_deferred("_live_auto_reload_running_scripts"); + call_deferred(SNAME("_live_auto_reload_running_scripts")); pending_auto_reload = true; } } @@ -997,7 +995,7 @@ bool ScriptEditor::_test_script_times_on_disk(RES p_for_script) { script_editor->_reload_scripts(); need_reload = false; } else { - disk_changed->call_deferred("popup_centered_ratio", 0.5); + disk_changed->call_deferred(SNAME("popup_centered_ratio"), 0.5); } } @@ -1155,7 +1153,7 @@ void ScriptEditor::_menu_option(int p_option) { if (ResourceLoader::get_resource_type(res_path) == "PackedScene") { if (!EditorNode::get_singleton()->is_scene_open(res_path)) { EditorNode::get_singleton()->load_scene(res_path); - script_editor->call_deferred("_menu_option", p_option); + script_editor->call_deferred(SNAME("_menu_option"), p_option); previous_scripts.push_back(path); //repeat the operation return; } @@ -1486,23 +1484,23 @@ void ScriptEditor::_notification(int p_what) { case NOTIFICATION_TRANSLATION_CHANGED: case NOTIFICATION_LAYOUT_DIRECTION_CHANGED: case NOTIFICATION_THEME_CHANGED: { - help_search->set_icon(get_theme_icon("HelpSearch", "EditorIcons")); - site_search->set_icon(get_theme_icon("Instance", "EditorIcons")); + help_search->set_icon(get_theme_icon(SNAME("HelpSearch"), SNAME("EditorIcons"))); + site_search->set_icon(get_theme_icon(SNAME("Instance"), SNAME("EditorIcons"))); if (is_layout_rtl()) { - script_forward->set_icon(get_theme_icon("Back", "EditorIcons")); - script_back->set_icon(get_theme_icon("Forward", "EditorIcons")); + script_forward->set_icon(get_theme_icon(SNAME("Back"), SNAME("EditorIcons"))); + script_back->set_icon(get_theme_icon(SNAME("Forward"), SNAME("EditorIcons"))); } else { - script_forward->set_icon(get_theme_icon("Forward", "EditorIcons")); - script_back->set_icon(get_theme_icon("Back", "EditorIcons")); + script_forward->set_icon(get_theme_icon(SNAME("Forward"), SNAME("EditorIcons"))); + script_back->set_icon(get_theme_icon(SNAME("Back"), SNAME("EditorIcons"))); } - members_overview_alphabeta_sort_button->set_icon(get_theme_icon("Sort", "EditorIcons")); + members_overview_alphabeta_sort_button->set_icon(get_theme_icon(SNAME("Sort"), SNAME("EditorIcons"))); - filter_scripts->set_right_icon(get_theme_icon("Search", "EditorIcons")); - filter_methods->set_right_icon(get_theme_icon("Search", "EditorIcons")); + filter_scripts->set_right_icon(get_theme_icon(SNAME("Search"), SNAME("EditorIcons"))); + filter_methods->set_right_icon(get_theme_icon(SNAME("Search"), SNAME("EditorIcons"))); - filename->add_theme_style_override("normal", editor->get_gui_base()->get_theme_stylebox("normal", "LineEdit")); + filename->add_theme_style_override("normal", editor->get_gui_base()->get_theme_stylebox(SNAME("normal"), SNAME("LineEdit"))); recent_scripts->set_as_minsize(); @@ -1576,11 +1574,11 @@ void ScriptEditor::edited_scene_changed() { } void ScriptEditor::notify_script_close(const Ref<Script> &p_script) { - emit_signal("script_close", p_script); + emit_signal(SNAME("script_close"), p_script); } void ScriptEditor::notify_script_changed(const Ref<Script> &p_script) { - emit_signal("editor_script_changed", p_script); + emit_signal(SNAME("editor_script_changed"), p_script); } void ScriptEditor::get_breakpoints(List<String> *p_breakpoints) { @@ -1796,8 +1794,8 @@ void ScriptEditor::_update_script_colors() { bool script_temperature_enabled = EditorSettings::get_singleton()->get("text_editor/script_list/script_temperature_enabled"); int hist_size = EditorSettings::get_singleton()->get("text_editor/script_list/script_temperature_history_size"); - Color hot_color = get_theme_color("accent_color", "Editor"); - Color cold_color = get_theme_color("font_color", "Editor"); + Color hot_color = get_theme_color(SNAME("accent_color"), SNAME("Editor")); + Color cold_color = get_theme_color(SNAME("font_color"), SNAME("Editor")); for (int i = 0; i < script_list->get_item_count(); i++) { int c = script_list->get_item_metadata(i); @@ -1946,7 +1944,7 @@ void ScriptEditor::_update_script_names() { EditorHelp *eh = Object::cast_to<EditorHelp>(tab_container->get_child(i)); if (eh) { String name = eh->get_class(); - Ref<Texture2D> icon = get_theme_icon("Help", "EditorIcons"); + Ref<Texture2D> icon = get_theme_icon(SNAME("Help"), SNAME("EditorIcons")); String tooltip = vformat(TTR("%s Class Reference"), name); _ScriptEditorItemData sd; @@ -2554,8 +2552,8 @@ void ScriptEditor::_tree_changed() { } waiting_update_names = true; - call_deferred("_update_script_names"); - call_deferred("_update_script_connections"); + call_deferred(SNAME("_update_script_names")); + call_deferred(SNAME("_update_script_connections")); } void ScriptEditor::_script_split_dragged(float) { @@ -2581,7 +2579,7 @@ Variant ScriptEditor::get_drag_data_fw(const Point2 &p_point, Control *p_from) { EditorHelp *eh = Object::cast_to<EditorHelp>(cur_node); if (eh) { preview_name = eh->get_class(); - preview_icon = get_theme_icon("Help", "EditorIcons"); + preview_icon = get_theme_icon(SNAME("Help"), SNAME("EditorIcons")); } if (!preview_icon.is_null()) { @@ -3362,7 +3360,7 @@ ScriptEditor::ScriptEditor(EditorNode *p_editor) { filename = memnew(Label); filename->set_clip_text(true); filename->set_h_size_flags(SIZE_EXPAND_FILL); - filename->add_theme_style_override("normal", EditorNode::get_singleton()->get_gui_base()->get_theme_stylebox("normal", "LineEdit")); + filename->add_theme_style_override("normal", EditorNode::get_singleton()->get_gui_base()->get_theme_stylebox(SNAME("normal"), SNAME("LineEdit"))); buttons_hbox->add_child(filename); members_overview_alphabeta_sort_button = memnew(Button); @@ -3612,8 +3610,8 @@ ScriptEditor::ScriptEditor(EditorNode *p_editor) { ScriptServer::edit_request_func = _open_script_request; - add_theme_style_override("panel", editor->get_gui_base()->get_theme_stylebox("ScriptEditorPanel", "EditorStyles")); - tab_container->add_theme_style_override("panel", editor->get_gui_base()->get_theme_stylebox("ScriptEditor", "EditorStyles")); + add_theme_style_override("panel", editor->get_gui_base()->get_theme_stylebox(SNAME("ScriptEditorPanel"), SNAME("EditorStyles"))); + tab_container->add_theme_style_override("panel", editor->get_gui_base()->get_theme_stylebox(SNAME("ScriptEditor"), SNAME("EditorStyles"))); } ScriptEditor::~ScriptEditor() { diff --git a/editor/plugins/script_text_editor.cpp b/editor/plugins/script_text_editor.cpp index cc0fbcc634..65459d159d 100644 --- a/editor/plugins/script_text_editor.cpp +++ b/editor/plugins/script_text_editor.cpp @@ -50,9 +50,7 @@ void ConnectionInfoDialog::popup_connections(String p_method, Vector<Node *> p_n List<Connection> all_connections; p_nodes[i]->get_signals_connected_to_this(&all_connections); - for (List<Connection>::Element *E = all_connections.front(); E; E = E->next()) { - Connection connection = E->get(); - + for (const Connection &connection : all_connections) { if (connection.callable.get_method() != p_method) { continue; } @@ -66,7 +64,7 @@ void ConnectionInfoDialog::popup_connections(String p_method, Vector<Node *> p_n node_item->set_text(1, connection.signal.get_name()); Control *p = Object::cast_to<Control>(get_parent()); - node_item->set_icon(1, p->get_theme_icon("Slot", "EditorIcons")); + node_item->set_icon(1, p->get_theme_icon(SNAME("Slot"), SNAME("EditorIcons"))); node_item->set_selectable(1, false); node_item->set_editable(1, false); @@ -116,8 +114,8 @@ Vector<String> ScriptTextEditor::get_functions() { if (script->get_language()->validate(text, script->get_path(), &fnc)) { //if valid rewrite functions to latest functions.clear(); - for (List<String>::Element *E = fnc.front(); E; E = E->next()) { - functions.push_back(E->get()); + for (const String &E : fnc) { + functions.push_back(E); } } @@ -147,7 +145,7 @@ void ScriptTextEditor::set_edited_resource(const RES &p_res) { code_editor->get_text_editor()->clear_undo_history(); code_editor->get_text_editor()->tag_saved_version(); - emit_signal("name_changed"); + emit_signal(SNAME("name_changed")); code_editor->update_line_and_column(); } @@ -203,8 +201,7 @@ void ScriptTextEditor::_set_theme_for_script() { List<String> strings; script->get_language()->get_string_delimiters(&strings); text_edit->clear_string_delimiters(); - for (List<String>::Element *E = strings.front(); E; E = E->next()) { - String string = E->get(); + for (const String &string : strings) { String beg = string.get_slice(" ", 0); String end = string.get_slice_count(" ") > 1 ? string.get_slice(" ", 1) : String(); text_edit->add_string_delimiter(beg, end, end == ""); @@ -213,8 +210,7 @@ void ScriptTextEditor::_set_theme_for_script() { List<String> comments; script->get_language()->get_comment_delimiters(&comments); text_edit->clear_comment_delimiters(); - for (List<String>::Element *E = comments.front(); E; E = E->next()) { - String comment = E->get(); + for (const String &comment : comments) { String beg = comment.get_slice(" ", 0); String end = comment.get_slice_count(" ") > 1 ? comment.get_slice(" ", 1) : String(); text_edit->add_comment_delimiter(beg, end, end == ""); @@ -417,8 +413,8 @@ void ScriptTextEditor::_validate_script() { } functions.clear(); - for (List<String>::Element *E = fnc.front(); E; E = E->next()) { - functions.push_back(E->get()); + for (const String &E : fnc) { + functions.push_back(E); } script_is_valid = true; } @@ -432,15 +428,13 @@ void ScriptTextEditor::_validate_script() { Node *base = get_tree()->get_edited_scene_root(); if (base && missing_connections.size() > 0) { warnings_panel->push_table(1); - for (List<Connection>::Element *E = missing_connections.front(); E; E = E->next()) { - Connection connection = E->get(); - + for (const Connection &connection : missing_connections) { String base_path = base->get_name(); String source_path = base == connection.signal.get_object() ? base_path : base_path + "/" + base->get_path_to(Object::cast_to<Node>(connection.signal.get_object())); String target_path = base == connection.callable.get_object() ? base_path : base_path + "/" + base->get_path_to(Object::cast_to<Node>(connection.callable.get_object())); warnings_panel->push_cell(); - warnings_panel->push_color(warnings_panel->get_theme_color("warning_color", "Editor")); + warnings_panel->push_color(warnings_panel->get_theme_color(SNAME("warning_color"), SNAME("Editor"))); warnings_panel->add_text(vformat(TTR("Missing connected method '%s' for signal '%s' from node '%s' to node '%s'."), connection.callable.get_method(), connection.signal.get_name(), source_path, target_path)); warnings_panel->pop(); // Color. warnings_panel->pop(); // Cell. @@ -456,16 +450,14 @@ void ScriptTextEditor::_validate_script() { // Add script warnings. warnings_panel->push_table(3); - for (List<ScriptLanguage::Warning>::Element *E = warnings.front(); E; E = E->next()) { - ScriptLanguage::Warning w = E->get(); - + for (const ScriptLanguage::Warning &w : warnings) { Dictionary ignore_meta; ignore_meta["line"] = w.start_line; ignore_meta["code"] = w.string_code.to_lower(); warnings_panel->push_cell(); warnings_panel->push_meta(ignore_meta); warnings_panel->push_color( - warnings_panel->get_theme_color("accent_color", "Editor").lerp(warnings_panel->get_theme_color("mono_color", "Editor"), 0.5)); + warnings_panel->get_theme_color(SNAME("accent_color"), SNAME("Editor")).lerp(warnings_panel->get_theme_color(SNAME("mono_color"), SNAME("Editor")), 0.5)); warnings_panel->add_text(TTR("[Ignore]")); warnings_panel->pop(); // Color. warnings_panel->pop(); // Meta ignore. @@ -473,7 +465,7 @@ void ScriptTextEditor::_validate_script() { warnings_panel->push_cell(); warnings_panel->push_meta(w.start_line - 1); - warnings_panel->push_color(warnings_panel->get_theme_color("warning_color", "Editor")); + warnings_panel->push_color(warnings_panel->get_theme_color(SNAME("warning_color"), SNAME("Editor"))); warnings_panel->add_text(TTR("Line") + " " + itos(w.start_line)); warnings_panel->add_text(" (" + w.string_code + "):"); warnings_panel->pop(); // Color. @@ -488,12 +480,10 @@ void ScriptTextEditor::_validate_script() { errors_panel->clear(); errors_panel->push_table(2); - for (List<ScriptLanguage::ScriptError>::Element *E = errors.front(); E; E = E->next()) { - ScriptLanguage::ScriptError err = E->get(); - + for (const ScriptLanguage::ScriptError &err : errors) { errors_panel->push_cell(); errors_panel->push_meta(err.line - 1); - errors_panel->push_color(warnings_panel->get_theme_color("error_color", "Editor")); + errors_panel->push_color(warnings_panel->get_theme_color(SNAME("error_color"), SNAME("Editor"))); errors_panel->add_text(TTR("Line") + " " + itos(err.line) + ":"); errors_panel->pop(); // Color. errors_panel->pop(); // Meta goto. @@ -511,8 +501,8 @@ void ScriptTextEditor::_validate_script() { if (errors.is_empty()) { te->set_line_background_color(i, Color(0, 0, 0, 0)); } else { - for (List<ScriptLanguage::ScriptError>::Element *E = errors.front(); E; E = E->next()) { - bool error_line = i == E->get().line - 1; + for (const ScriptLanguage::ScriptError &E : errors) { + bool error_line = i == E.line - 1; te->set_line_background_color(i, error_line ? marked_line_color : Color(0, 0, 0, 0)); if (error_line) { break; @@ -535,8 +525,8 @@ void ScriptTextEditor::_validate_script() { } } - emit_signal("name_changed"); - emit_signal("edited_script_changed"); + emit_signal(SNAME("name_changed")); + emit_signal(SNAME("edited_script_changed")); } void ScriptTextEditor::_update_bookmark_list() { @@ -725,7 +715,7 @@ void ScriptTextEditor::_breakpoint_item_pressed(int p_idx) { _edit_option(breakpoints_menu->get_item_id(p_idx)); } else { code_editor->goto_line(breakpoints_menu->get_item_metadata(p_idx)); - code_editor->get_text_editor()->call_deferred("center_viewport_to_cursor"); //Need to be deferred, because goto uses call_deferred(). + code_editor->get_text_editor()->call_deferred(SNAME("center_viewport_to_cursor")); //Need to be deferred, because goto uses call_deferred(). } } @@ -760,14 +750,14 @@ void ScriptTextEditor::_lookup_symbol(const String &p_symbol, int p_row, int p_c switch (result.type) { case ScriptLanguage::LookupResult::RESULT_SCRIPT_LOCATION: { if (result.script.is_valid()) { - emit_signal("request_open_script_at_line", result.script, result.location - 1); + emit_signal(SNAME("request_open_script_at_line"), result.script, result.location - 1); } else { - emit_signal("request_save_history"); + emit_signal(SNAME("request_save_history")); goto_line_centered(result.location - 1); } } break; case ScriptLanguage::LookupResult::RESULT_CLASS: { - emit_signal("go_to_help", "class_name:" + result.class_name); + emit_signal(SNAME("go_to_help"), "class_name:" + result.class_name); } break; case ScriptLanguage::LookupResult::RESULT_CLASS_CONSTANT: { StringName cname = result.class_name; @@ -782,11 +772,11 @@ void ScriptTextEditor::_lookup_symbol(const String &p_symbol, int p_row, int p_c } } - emit_signal("go_to_help", "class_constant:" + result.class_name + ":" + result.class_member); + emit_signal(SNAME("go_to_help"), "class_constant:" + result.class_name + ":" + result.class_member); } break; case ScriptLanguage::LookupResult::RESULT_CLASS_PROPERTY: { - emit_signal("go_to_help", "class_property:" + result.class_name + ":" + result.class_member); + emit_signal(SNAME("go_to_help"), "class_property:" + result.class_name + ":" + result.class_member); } break; case ScriptLanguage::LookupResult::RESULT_CLASS_METHOD: { @@ -801,7 +791,7 @@ void ScriptTextEditor::_lookup_symbol(const String &p_symbol, int p_row, int p_c } } - emit_signal("go_to_help", "class_method:" + result.class_name + ":" + result.class_member); + emit_signal(SNAME("go_to_help"), "class_method:" + result.class_name + ":" + result.class_member); } break; case ScriptLanguage::LookupResult::RESULT_CLASS_ENUM: { @@ -817,11 +807,11 @@ void ScriptTextEditor::_lookup_symbol(const String &p_symbol, int p_row, int p_c } } - emit_signal("go_to_help", "class_enum:" + result.class_name + ":" + result.class_member); + emit_signal(SNAME("go_to_help"), "class_enum:" + result.class_name + ":" + result.class_member); } break; case ScriptLanguage::LookupResult::RESULT_CLASS_TBD_GLOBALSCOPE: { - emit_signal("go_to_help", "class_global:" + result.class_name + ":" + result.class_member); + emit_signal(SNAME("go_to_help"), "class_global:" + result.class_name + ":" + result.class_member); } break; } } else if (ProjectSettings::get_singleton()->has_autoload(p_symbol)) { @@ -910,8 +900,7 @@ void ScriptTextEditor::_update_connected_methods() { List<Connection> connections; nodes[i]->get_signals_connected_to_this(&connections); - for (List<Connection>::Element *E = connections.front(); E; E = E->next()) { - Connection connection = E->get(); + for (const Connection &connection : connections) { if (!(connection.flags & CONNECT_PERSIST)) { continue; } @@ -934,7 +923,7 @@ void ScriptTextEditor::_update_connected_methods() { if (name == connection.callable.get_method()) { line = functions[j].get_slice(":", 1).to_int() - 1; text_edit->set_line_gutter_metadata(line, connection_gutter, connection.callable.get_method()); - text_edit->set_line_gutter_icon(line, connection_gutter, get_parent_control()->get_theme_icon("Slot", "EditorIcons")); + text_edit->set_line_gutter_icon(line, connection_gutter, get_parent_control()->get_theme_icon(SNAME("Slot"), SNAME("EditorIcons"))); text_edit->set_line_gutter_clickable(line, connection_gutter, true); methods_found.insert(connection.callable.get_method()); break; @@ -1004,27 +993,27 @@ void ScriptTextEditor::_edit_option(int p_op) { switch (p_op) { case EDIT_UNDO: { tx->undo(); - tx->call_deferred("grab_focus"); + tx->call_deferred(SNAME("grab_focus")); } break; case EDIT_REDO: { tx->redo(); - tx->call_deferred("grab_focus"); + tx->call_deferred(SNAME("grab_focus")); } break; case EDIT_CUT: { tx->cut(); - tx->call_deferred("grab_focus"); + tx->call_deferred(SNAME("grab_focus")); } break; case EDIT_COPY: { tx->copy(); - tx->call_deferred("grab_focus"); + tx->call_deferred(SNAME("grab_focus")); } break; case EDIT_PASTE: { tx->paste(); - tx->call_deferred("grab_focus"); + tx->call_deferred(SNAME("grab_focus")); } break; case EDIT_SELECT_ALL: { tx->select_all(); - tx->call_deferred("grab_focus"); + tx->call_deferred(SNAME("grab_focus")); } break; case EDIT_MOVE_LINE_UP: { code_editor->move_lines_up(); @@ -1163,12 +1152,12 @@ void ScriptTextEditor::_edit_option(int p_op) { // Yep, because it doesn't make sense to instance this dialog for every single script open... // So this will be delegated to the ScriptEditor. - emit_signal("search_in_files_requested", selected_text); + emit_signal(SNAME("search_in_files_requested"), selected_text); } break; case REPLACE_IN_FILES: { String selected_text = code_editor->get_text_editor()->get_selection_text(); - emit_signal("replace_in_files_requested", selected_text); + emit_signal(SNAME("replace_in_files_requested"), selected_text); } break; case SEARCH_LOCATE_FUNCTION: { quick_open->popup_dialog(get_functions()); @@ -1262,7 +1251,7 @@ void ScriptTextEditor::_edit_option(int p_op) { text = tx->get_word_under_cursor(); } if (text != "") { - emit_signal("request_help", text); + emit_signal(SNAME("request_help"), text); } } break; case LOOKUP_SYMBOL: { @@ -1286,8 +1275,7 @@ void ScriptTextEditor::_edit_option_toggle_inline_comment() { List<String> comment_delimiters; script->get_language()->get_comment_delimiters(&comment_delimiters); - for (List<String>::Element *E = comment_delimiters.front(); E; E = E->next()) { - String script_delimiter = E->get(); + for (const String &script_delimiter : comment_delimiters) { if (script_delimiter.find(" ") == -1) { delimiter = script_delimiter; break; @@ -1686,16 +1674,16 @@ void ScriptTextEditor::_enable_code_editor() { editor_box->add_child(warnings_panel); warnings_panel->add_theme_font_override( - "normal_font", EditorNode::get_singleton()->get_gui_base()->get_theme_font("main", "EditorFonts")); + "normal_font", EditorNode::get_singleton()->get_gui_base()->get_theme_font(SNAME("main"), SNAME("EditorFonts"))); warnings_panel->add_theme_font_size_override( - "normal_font_size", EditorNode::get_singleton()->get_gui_base()->get_theme_font_size("main_size", "EditorFonts")); + "normal_font_size", EditorNode::get_singleton()->get_gui_base()->get_theme_font_size(SNAME("main_size"), SNAME("EditorFonts"))); warnings_panel->connect("meta_clicked", callable_mp(this, &ScriptTextEditor::_warning_clicked)); editor_box->add_child(errors_panel); errors_panel->add_theme_font_override( - "normal_font", EditorNode::get_singleton()->get_gui_base()->get_theme_font("main", "EditorFonts")); + "normal_font", EditorNode::get_singleton()->get_gui_base()->get_theme_font(SNAME("main"), SNAME("EditorFonts"))); errors_panel->add_theme_font_size_override( - "normal_font_size", EditorNode::get_singleton()->get_gui_base()->get_theme_font_size("main_size", "EditorFonts")); + "normal_font_size", EditorNode::get_singleton()->get_gui_base()->get_theme_font_size(SNAME("main_size"), SNAME("EditorFonts"))); errors_panel->connect("meta_clicked", callable_mp(this, &ScriptTextEditor::_error_clicked)); add_child(context_menu); @@ -1819,7 +1807,7 @@ ScriptTextEditor::ScriptTextEditor() { code_editor->get_text_editor()->set_gutter_name(connection_gutter, "connection_gutter"); code_editor->get_text_editor()->set_gutter_draw(connection_gutter, false); code_editor->get_text_editor()->set_gutter_overwritable(connection_gutter, true); - code_editor->get_text_editor()->set_gutter_type(connection_gutter, TextEdit::GUTTER_TPYE_ICON); + code_editor->get_text_editor()->set_gutter_type(connection_gutter, TextEdit::GUTTER_TYPE_ICON); warnings_panel = memnew(RichTextLabel); warnings_panel->set_custom_minimum_size(Size2(0, 100 * EDSCALE)); diff --git a/editor/plugins/shader_editor_plugin.cpp b/editor/plugins/shader_editor_plugin.cpp index c1216a9732..2c45b96106 100644 --- a/editor/plugins/shader_editor_plugin.cpp +++ b/editor/plugins/shader_editor_plugin.cpp @@ -63,8 +63,8 @@ void ShaderTextEditor::set_edited_shader(const Ref<Shader> &p_shader) { get_text_editor()->set_text(p_shader->get_code()); get_text_editor()->clear_undo_history(); - get_text_editor()->call_deferred("set_h_scroll", 0); - get_text_editor()->call_deferred("set_v_scroll", 0); + get_text_editor()->call_deferred(SNAME("set_h_scroll"), 0); + get_text_editor()->call_deferred(SNAME("set_v_scroll"), 0); _validate_script(); _line_col_changed(); @@ -118,11 +118,11 @@ void ShaderTextEditor::_load_theme_settings() { const Color keyword_color = EDITOR_GET("text_editor/highlighting/keyword_color"); const Color control_flow_keyword_color = EDITOR_GET("text_editor/highlighting/control_flow_keyword_color"); - for (List<String>::Element *E = keywords.front(); E; E = E->next()) { - if (ShaderLanguage::is_control_flow_keyword(E->get())) { - syntax_highlighter->add_keyword_color(E->get(), control_flow_keyword_color); + for (const String &E : keywords) { + if (ShaderLanguage::is_control_flow_keyword(E)) { + syntax_highlighter->add_keyword_color(E, control_flow_keyword_color); } else { - syntax_highlighter->add_keyword_color(E->get(), keyword_color); + syntax_highlighter->add_keyword_color(E, keyword_color); } } @@ -144,8 +144,8 @@ void ShaderTextEditor::_load_theme_settings() { const Color member_variable_color = EDITOR_GET("text_editor/highlighting/member_variable_color"); - for (List<String>::Element *E = built_ins.front(); E; E = E->next()) { - syntax_highlighter->add_keyword_color(E->get(), member_variable_color); + for (const String &E : built_ins) { + syntax_highlighter->add_keyword_color(E, member_variable_color); } // Colorize comments. @@ -160,8 +160,8 @@ void ShaderTextEditor::_load_theme_settings() { if (warnings_panel) { // Warnings panel - warnings_panel->add_theme_font_override("normal_font", EditorNode::get_singleton()->get_gui_base()->get_theme_font("main", "EditorFonts")); - warnings_panel->add_theme_font_size_override("normal_font_size", EditorNode::get_singleton()->get_gui_base()->get_theme_font_size("main_size", "EditorFonts")); + warnings_panel->add_theme_font_override("normal_font", EditorNode::get_singleton()->get_gui_base()->get_theme_font(SNAME("main"), SNAME("EditorFonts"))); + warnings_panel->add_theme_font_size_override("normal_font_size", EditorNode::get_singleton()->get_gui_base()->get_theme_font_size(SNAME("main_size"), SNAME("EditorFonts"))); } } @@ -242,7 +242,7 @@ void ShaderTextEditor::_validate_script() { } else { set_warning_count(0); } - emit_signal("script_changed"); + emit_signal(SNAME("script_changed")); } void ShaderTextEditor::_update_warning_panel() { @@ -266,7 +266,7 @@ void ShaderTextEditor::_update_warning_panel() { // First cell. warnings_panel->push_cell(); warnings_panel->push_meta(w.get_line() - 1); - warnings_panel->push_color(warnings_panel->get_theme_color("warning_color", "Editor")); + warnings_panel->push_color(warnings_panel->get_theme_color(SNAME("warning_color"), SNAME("Editor"))); warnings_panel->add_text(TTR("Line") + " " + itos(w.get_line())); warnings_panel->add_text(" (" + w.get_name() + "):"); warnings_panel->pop(); // Color. @@ -380,7 +380,7 @@ void ShaderEditor::_menu_option(int p_option) { } break; } if (p_option != SEARCH_FIND && p_option != SEARCH_REPLACE && p_option != SEARCH_GOTO_LINE) { - shader_editor->get_text_editor()->call_deferred("grab_focus"); + shader_editor->get_text_editor()->call_deferred(SNAME("grab_focus")); } } @@ -484,7 +484,7 @@ void ShaderEditor::_check_for_external_edit() { if (use_autoreload) { _reload_shader_from_disk(); } else { - disk_changed->call_deferred("popup_centered"); + disk_changed->call_deferred(SNAME("popup_centered")); } } } @@ -728,7 +728,7 @@ ShaderEditor::ShaderEditor(EditorNode *p_node) { help_menu = memnew(MenuButton); help_menu->set_text(TTR("Help")); help_menu->set_switch_on_hover(true); - help_menu->get_popup()->add_icon_item(p_node->get_gui_base()->get_theme_icon("Instance", "EditorIcons"), TTR("Online Docs"), HELP_DOCS); + help_menu->get_popup()->add_icon_item(p_node->get_gui_base()->get_theme_icon(SNAME("Instance"), SNAME("EditorIcons")), TTR("Online Docs"), HELP_DOCS); help_menu->get_popup()->connect("id_pressed", callable_mp(this, &ShaderEditor::_menu_option)); add_child(main_container); @@ -737,7 +737,7 @@ ShaderEditor::ShaderEditor(EditorNode *p_node) { hbc->add_child(edit_menu); hbc->add_child(goto_menu); hbc->add_child(help_menu); - hbc->add_theme_style_override("panel", p_node->get_gui_base()->get_theme_stylebox("ScriptEditorPanel", "EditorStyles")); + hbc->add_theme_style_override("panel", p_node->get_gui_base()->get_theme_stylebox(SNAME("ScriptEditorPanel"), SNAME("EditorStyles"))); VSplitContainer *editor_box = memnew(VSplitContainer); main_container->add_child(editor_box); @@ -770,7 +770,7 @@ ShaderEditor::ShaderEditor(EditorNode *p_node) { disk_changed->add_child(vbc); Label *dl = memnew(Label); - dl->set_text(TTR("This shader has been modified on on disk.\nWhat action should be taken?")); + dl->set_text(TTR("This shader has been modified on disk.\nWhat action should be taken?")); vbc->add_child(dl); disk_changed->connect("confirmed", callable_mp(this, &ShaderEditor::_reload_shader_from_disk)); diff --git a/editor/plugins/shader_file_editor_plugin.cpp b/editor/plugins/shader_file_editor_plugin.cpp index 85ccc5b798..1e62261244 100644 --- a/editor/plugins/shader_file_editor_plugin.cpp +++ b/editor/plugins/shader_file_editor_plugin.cpp @@ -55,7 +55,7 @@ void ShaderFileEditor::_version_selected(int p_option) { RD::ShaderStage stage = RD::SHADER_STAGE_MAX; int first_found = -1; - Ref<RDShaderBytecode> bytecode = shader_file->get_bytecode(version_txt); + Ref<RDShaderSPIRV> bytecode = shader_file->get_spirv(version_txt); ERR_FAIL_COND(bytecode.is_null()); for (int i = 0; i < RD::SHADER_STAGE_MAX; i++) { @@ -66,9 +66,9 @@ void ShaderFileEditor::_version_selected(int p_option) { Ref<Texture2D> icon; if (bytecode->get_stage_compile_error(RD::ShaderStage(i)) != String()) { - icon = get_theme_icon("ImportFail", "EditorIcons"); + icon = get_theme_icon(SNAME("ImportFail"), SNAME("EditorIcons")); } else { - icon = get_theme_icon("ImportCheck", "EditorIcons"); + icon = get_theme_icon(SNAME("ImportCheck"), SNAME("EditorIcons")); } stages[i]->set_icon(icon); @@ -95,7 +95,7 @@ void ShaderFileEditor::_version_selected(int p_option) { String error = bytecode->get_stage_compile_error(stage); - error_text->push_font(get_theme_font("source", "EditorFonts")); + error_text->push_font(get_theme_font(SNAME("source"), SNAME("EditorFonts"))); if (error == String()) { error_text->add_text(TTR("Shader stage compiled without errors.")); @@ -111,7 +111,7 @@ void ShaderFileEditor::_update_options() { stage_hb->hide(); versions->hide(); error_text->clear(); - error_text->push_font(get_theme_font("source", "EditorFonts")); + error_text->push_font(get_theme_font(SNAME("source"), SNAME("EditorFonts"))); error_text->add_text(vformat(TTR("File structure for '%s' contains unrecoverable errors:\n\n"), shader_file->get_path().get_file())); error_text->add_text(shader_file->get_base_error()); return; @@ -142,7 +142,7 @@ void ShaderFileEditor::_update_options() { Ref<Texture2D> icon; - Ref<RDShaderBytecode> bytecode = shader_file->get_bytecode(version_list[i]); + Ref<RDShaderSPIRV> bytecode = shader_file->get_spirv(version_list[i]); ERR_FAIL_COND(bytecode.is_null()); bool failed = false; @@ -154,9 +154,9 @@ void ShaderFileEditor::_update_options() { } if (failed) { - icon = get_theme_icon("ImportFail", "EditorIcons"); + icon = get_theme_icon(SNAME("ImportFail"), SNAME("EditorIcons")); } else { - icon = get_theme_icon("ImportCheck", "EditorIcons"); + icon = get_theme_icon(SNAME("ImportCheck"), SNAME("EditorIcons")); } versions->add_item(title, icon); @@ -175,7 +175,7 @@ void ShaderFileEditor::_update_options() { return; } - Ref<RDShaderBytecode> bytecode = shader_file->get_bytecode(current_version); + Ref<RDShaderSPIRV> bytecode = shader_file->get_spirv(current_version); ERR_FAIL_COND(bytecode.is_null()); int first_valid = -1; int current = -1; diff --git a/editor/plugins/skeleton_2d_editor_plugin.cpp b/editor/plugins/skeleton_2d_editor_plugin.cpp index 44916e1d46..7ef680d7ef 100644 --- a/editor/plugins/skeleton_2d_editor_plugin.cpp +++ b/editor/plugins/skeleton_2d_editor_plugin.cpp @@ -96,7 +96,7 @@ Skeleton2DEditor::Skeleton2DEditor() { CanvasItemEditor::get_singleton()->add_control_to_menu_panel(options); options->set_text(TTR("Skeleton2D")); - options->set_icon(EditorNode::get_singleton()->get_gui_base()->get_theme_icon("Skeleton2D", "EditorIcons")); + options->set_icon(EditorNode::get_singleton()->get_gui_base()->get_theme_icon(SNAME("Skeleton2D"), SNAME("EditorIcons"))); options->get_popup()->add_item(TTR("Make Rest Pose (From Bones)"), MENU_OPTION_MAKE_REST); options->get_popup()->add_separator(); diff --git a/editor/plugins/skeleton_3d_editor_plugin.cpp b/editor/plugins/skeleton_3d_editor_plugin.cpp index 0b04c2e50e..4202d8b611 100644 --- a/editor/plugins/skeleton_3d_editor_plugin.cpp +++ b/editor/plugins/skeleton_3d_editor_plugin.cpp @@ -44,7 +44,7 @@ #include "scene/resources/sphere_shape_3d.h" void BoneTransformEditor::create_editors() { - const Color section_color = get_theme_color("prop_subsection", "Editor"); + const Color section_color = get_theme_color(SNAME("prop_subsection"), SNAME("Editor")); section = memnew(EditorInspectorSection); section->setup("trf_properties", label, this, section_color, true); @@ -53,7 +53,7 @@ void BoneTransformEditor::create_editors() { key_button = memnew(Button); key_button->set_text(TTR("Key Transform")); key_button->set_visible(keyable); - key_button->set_icon(get_theme_icon("Key", "EditorIcons")); + key_button->set_icon(get_theme_icon(SNAME("Key"), SNAME("EditorIcons"))); key_button->set_flat(true); section->get_vbox()->add_child(key_button); @@ -113,19 +113,19 @@ void BoneTransformEditor::_notification(int p_what) { [[fallthrough]]; } case NOTIFICATION_SORT_CHILDREN: { - const Ref<Font> font = get_theme_font("font", "Tree"); - int font_size = get_theme_font_size("font_size", "Tree"); + const Ref<Font> font = get_theme_font(SNAME("font"), SNAME("Tree")); + int font_size = get_theme_font_size(SNAME("font_size"), SNAME("Tree")); Point2 buffer; - buffer.x += get_theme_constant("inspector_margin", "Editor"); + buffer.x += get_theme_constant(SNAME("inspector_margin"), SNAME("Editor")); buffer.y += font->get_height(font_size); - buffer.y += get_theme_constant("vseparation", "Tree"); + buffer.y += get_theme_constant(SNAME("vseparation"), SNAME("Tree")); const float vector_height = translation_property->get_size().y; const float transform_height = transform_property->get_size().y; const float button_height = key_button->get_size().y; - const float width = get_size().x - get_theme_constant("inspector_margin", "Editor"); + const float width = get_size().x - get_theme_constant(SNAME("inspector_margin"), SNAME("Editor")); Vector<Rect2> input_rects; if (keyable && section->get_vbox()->is_visible()) { input_rects.push_back(Rect2(key_button->get_position() + buffer, Size2(width, button_height))); @@ -155,7 +155,7 @@ void BoneTransformEditor::_notification(int p_what) { break; } case NOTIFICATION_DRAW: { - const Color dark_color = get_theme_color("dark_color_2", "Editor"); + const Color dark_color = get_theme_color(SNAME("dark_color_2"), SNAME("Editor")); for (int i = 0; i < 5; ++i) { draw_rect(background_rects[i], dark_color); @@ -552,7 +552,7 @@ void Skeleton3DEditor::update_joint_tree() { items.insert(-1, root); const Vector<int> &joint_porder = skeleton->get_bone_process_orders(); - Ref<Texture> bone_icon = get_theme_icon("BoneAttachment3D", "EditorIcons"); + Ref<Texture> bone_icon = get_theme_icon(SNAME("BoneAttachment3D"), SNAME("EditorIcons")); for (int i = 0; i < joint_porder.size(); ++i) { const int b_idx = joint_porder[i]; @@ -584,13 +584,13 @@ void Skeleton3DEditor::create_editors() { Node3DEditor::get_singleton()->add_control_to_menu_panel(options); options->set_text(TTR("Skeleton3D")); - options->set_icon(EditorNode::get_singleton()->get_gui_base()->get_theme_icon("Skeleton3D", "EditorIcons")); + options->set_icon(EditorNode::get_singleton()->get_gui_base()->get_theme_icon(SNAME("Skeleton3D"), SNAME("EditorIcons"))); options->get_popup()->add_item(TTR("Create physical skeleton"), MENU_OPTION_CREATE_PHYSICAL_SKELETON); options->get_popup()->connect("id_pressed", callable_mp(this, &Skeleton3DEditor::_on_click_option)); - const Color section_color = get_theme_color("prop_subsection", "Editor"); + const Color section_color = get_theme_color(SNAME("prop_subsection"), SNAME("Editor")); EditorInspectorSection *bones_section = memnew(EditorInspectorSection); bones_section->setup("bones", "Bones", skeleton, section_color, true); diff --git a/editor/plugins/skeleton_ik_3d_editor_plugin.cpp b/editor/plugins/skeleton_ik_3d_editor_plugin.cpp index 2da49c1c0b..85632cf481 100644 --- a/editor/plugins/skeleton_ik_3d_editor_plugin.cpp +++ b/editor/plugins/skeleton_ik_3d_editor_plugin.cpp @@ -83,7 +83,7 @@ void SkeletonIK3DEditorPlugin::_bind_methods() { SkeletonIK3DEditorPlugin::SkeletonIK3DEditorPlugin(EditorNode *p_node) { editor = p_node; play_btn = memnew(Button); - play_btn->set_icon(editor->get_gui_base()->get_theme_icon("Play", "EditorIcons")); + play_btn->set_icon(editor->get_gui_base()->get_theme_icon(SNAME("Play"), SNAME("EditorIcons"))); play_btn->set_text(TTR("Play IK")); play_btn->set_toggle_mode(true); play_btn->hide(); diff --git a/editor/plugins/sprite_2d_editor_plugin.cpp b/editor/plugins/sprite_2d_editor_plugin.cpp index ef328bcfe2..0f889ce33d 100644 --- a/editor/plugins/sprite_2d_editor_plugin.cpp +++ b/editor/plugins/sprite_2d_editor_plugin.cpp @@ -506,7 +506,7 @@ Sprite2DEditor::Sprite2DEditor() { CanvasItemEditor::get_singleton()->add_control_to_menu_panel(options); options->set_text(TTR("Sprite2D")); - options->set_icon(EditorNode::get_singleton()->get_gui_base()->get_theme_icon("Sprite2D", "EditorIcons")); + options->set_icon(EditorNode::get_singleton()->get_gui_base()->get_theme_icon(SNAME("Sprite2D"), SNAME("EditorIcons"))); options->get_popup()->add_item(TTR("Convert to Mesh2D"), MENU_OPTION_CONVERT_TO_MESH_2D); options->get_popup()->add_item(TTR("Convert to Polygon2D"), MENU_OPTION_CONVERT_TO_POLYGON_2D); @@ -521,7 +521,7 @@ Sprite2DEditor::Sprite2DEditor() { debug_uv_dialog = memnew(ConfirmationDialog); debug_uv_dialog->get_ok_button()->set_text(TTR("Create Mesh2D")); - debug_uv_dialog->set_title("Mesh 2D Preview"); + debug_uv_dialog->set_title(TTR("Mesh 2D Preview")); VBoxContainer *vb = memnew(VBoxContainer); debug_uv_dialog->add_child(vb); ScrollContainer *scroll = memnew(ScrollContainer); diff --git a/editor/plugins/sprite_frames_editor_plugin.cpp b/editor/plugins/sprite_frames_editor_plugin.cpp index 70c7b3072b..42f7d23da2 100644 --- a/editor/plugins/sprite_frames_editor_plugin.cpp +++ b/editor/plugins/sprite_frames_editor_plugin.cpp @@ -65,13 +65,11 @@ void SpriteFramesEditor::_sheet_preview_draw() { int x = i * width; split_sheet_preview->draw_line(Point2(x, 0), Point2(x, size.height), Color(1, 1, 1, a)); split_sheet_preview->draw_line(Point2(x + 1, 0), Point2(x + 1, size.height), Color(0, 0, 0, a)); - - for (int j = 1; j < v; j++) { - int y = j * height; - - split_sheet_preview->draw_line(Point2(0, y), Point2(size.width, y), Color(1, 1, 1, a)); - split_sheet_preview->draw_line(Point2(0, y + 1), Point2(size.width, y + 1), Color(0, 0, 0, a)); - } + } + for (int i = 1; i < v; i++) { + int y = i * height; + split_sheet_preview->draw_line(Point2(0, y), Point2(size.width, y), Color(1, 1, 1, a)); + split_sheet_preview->draw_line(Point2(0, y + 1), Point2(size.width, y + 1), Color(0, 0, 0, a)); } if (frames_selected.size() == 0) { @@ -80,7 +78,7 @@ void SpriteFramesEditor::_sheet_preview_draw() { return; } - Color accent = get_theme_color("accent_color", "Editor"); + Color accent = get_theme_color(SNAME("accent_color"), SNAME("Editor")); for (Set<int>::Element *E = frames_selected.front(); E; E = E->next()) { int idx = E->get(); @@ -308,27 +306,27 @@ void SpriteFramesEditor::_prepare_sprite_sheet(const String &p_file) { void SpriteFramesEditor::_notification(int p_what) { switch (p_what) { case NOTIFICATION_ENTER_TREE: { - load->set_icon(get_theme_icon("Load", "EditorIcons")); - load_sheet->set_icon(get_theme_icon("SpriteSheet", "EditorIcons")); - copy->set_icon(get_theme_icon("ActionCopy", "EditorIcons")); - paste->set_icon(get_theme_icon("ActionPaste", "EditorIcons")); - empty->set_icon(get_theme_icon("InsertBefore", "EditorIcons")); - empty2->set_icon(get_theme_icon("InsertAfter", "EditorIcons")); - move_up->set_icon(get_theme_icon("MoveLeft", "EditorIcons")); - move_down->set_icon(get_theme_icon("MoveRight", "EditorIcons")); - _delete->set_icon(get_theme_icon("Remove", "EditorIcons")); - zoom_out->set_icon(get_theme_icon("ZoomLess", "EditorIcons")); - zoom_reset->set_icon(get_theme_icon("ZoomReset", "EditorIcons")); - zoom_in->set_icon(get_theme_icon("ZoomMore", "EditorIcons")); - new_anim->set_icon(get_theme_icon("New", "EditorIcons")); - remove_anim->set_icon(get_theme_icon("Remove", "EditorIcons")); - split_sheet_zoom_out->set_icon(get_theme_icon("ZoomLess", "EditorIcons")); - split_sheet_zoom_reset->set_icon(get_theme_icon("ZoomReset", "EditorIcons")); - split_sheet_zoom_in->set_icon(get_theme_icon("ZoomMore", "EditorIcons")); + load->set_icon(get_theme_icon(SNAME("Load"), SNAME("EditorIcons"))); + load_sheet->set_icon(get_theme_icon(SNAME("SpriteSheet"), SNAME("EditorIcons"))); + copy->set_icon(get_theme_icon(SNAME("ActionCopy"), SNAME("EditorIcons"))); + paste->set_icon(get_theme_icon(SNAME("ActionPaste"), SNAME("EditorIcons"))); + empty->set_icon(get_theme_icon(SNAME("InsertBefore"), SNAME("EditorIcons"))); + empty2->set_icon(get_theme_icon(SNAME("InsertAfter"), SNAME("EditorIcons"))); + move_up->set_icon(get_theme_icon(SNAME("MoveLeft"), SNAME("EditorIcons"))); + move_down->set_icon(get_theme_icon(SNAME("MoveRight"), SNAME("EditorIcons"))); + _delete->set_icon(get_theme_icon(SNAME("Remove"), SNAME("EditorIcons"))); + zoom_out->set_icon(get_theme_icon(SNAME("ZoomLess"), SNAME("EditorIcons"))); + zoom_reset->set_icon(get_theme_icon(SNAME("ZoomReset"), SNAME("EditorIcons"))); + zoom_in->set_icon(get_theme_icon(SNAME("ZoomMore"), SNAME("EditorIcons"))); + new_anim->set_icon(get_theme_icon(SNAME("New"), SNAME("EditorIcons"))); + remove_anim->set_icon(get_theme_icon(SNAME("Remove"), SNAME("EditorIcons"))); + split_sheet_zoom_out->set_icon(get_theme_icon(SNAME("ZoomLess"), SNAME("EditorIcons"))); + split_sheet_zoom_reset->set_icon(get_theme_icon(SNAME("ZoomReset"), SNAME("EditorIcons"))); + split_sheet_zoom_in->set_icon(get_theme_icon(SNAME("ZoomMore"), SNAME("EditorIcons"))); [[fallthrough]]; } case NOTIFICATION_THEME_CHANGED: { - split_sheet_scroll->add_theme_style_override("bg", get_theme_stylebox("bg", "Tree")); + split_sheet_scroll->add_theme_style_override("bg", get_theme_stylebox(SNAME("bg"), SNAME("Tree"))); } break; case NOTIFICATION_READY: { add_theme_constant_override("autohide", 1); // Fixes the dragger always showing up. @@ -367,8 +365,8 @@ void SpriteFramesEditor::_file_load_request(const Vector<String> &p_path, int p_ int count = 0; - for (List<Ref<Texture2D>>::Element *E = resources.front(); E; E = E->next()) { - undo_redo->add_do_method(frames, "add_frame", edited_anim, E->get(), p_at_pos == -1 ? -1 : p_at_pos + count); + for (const Ref<Texture2D> &E : resources) { + undo_redo->add_do_method(frames, "add_frame", edited_anim, E, p_at_pos == -1 ? -1 : p_at_pos + count); undo_redo->add_undo_method(frames, "remove_frame", edited_anim, p_at_pos == -1 ? fc : p_at_pos); count++; } @@ -626,10 +624,10 @@ void SpriteFramesEditor::_animation_name_edited() { undo_redo->add_do_method(frames, "rename_animation", edited_anim, name); undo_redo->add_undo_method(frames, "rename_animation", name, edited_anim); - for (List<Node *>::Element *E = nodes.front(); E; E = E->next()) { - String current = E->get()->call("get_animation"); - undo_redo->add_do_method(E->get(), "set_animation", name); - undo_redo->add_undo_method(E->get(), "set_animation", edited_anim); + for (Node *E : nodes) { + String current = E->call("get_animation"); + undo_redo->add_do_method(E, "set_animation", name); + undo_redo->add_undo_method(E, "set_animation", edited_anim); } undo_redo->add_do_method(this, "_update_library"); @@ -657,10 +655,10 @@ void SpriteFramesEditor::_animation_add() { undo_redo->add_do_method(this, "_update_library"); undo_redo->add_undo_method(this, "_update_library"); - for (List<Node *>::Element *E = nodes.front(); E; E = E->next()) { - String current = E->get()->call("get_animation"); - undo_redo->add_do_method(E->get(), "set_animation", name); - undo_redo->add_undo_method(E->get(), "set_animation", current); + for (Node *E : nodes) { + String current = E->call("get_animation"); + undo_redo->add_do_method(E, "set_animation", name); + undo_redo->add_undo_method(E, "set_animation", current); } edited_anim = name; @@ -790,8 +788,8 @@ void SpriteFramesEditor::_update_library(bool p_skip_selector) { anim_names.sort_custom<StringName::AlphCompare>(); - for (List<StringName>::Element *E = anim_names.front(); E; E = E->next()) { - String name = E->get(); + for (const StringName &E : anim_names) { + String name = E; TreeItem *it = animations->create_item(anim_root); @@ -800,7 +798,7 @@ void SpriteFramesEditor::_update_library(bool p_skip_selector) { it->set_text(0, name); it->set_editable(0, true); - if (E->get() == edited_anim) { + if (E == edited_anim) { it->select(0); } } diff --git a/editor/plugins/sub_viewport_preview_editor_plugin.cpp b/editor/plugins/sub_viewport_preview_editor_plugin.cpp new file mode 100644 index 0000000000..75c47bda2e --- /dev/null +++ b/editor/plugins/sub_viewport_preview_editor_plugin.cpp @@ -0,0 +1,50 @@ +/*************************************************************************/ +/* sub_viewport_preview_editor_plugin.cpp */ +/*************************************************************************/ +/* This file is part of: */ +/* GODOT ENGINE */ +/* https://godotengine.org */ +/*************************************************************************/ +/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2021 Godot Engine contributors (cf. AUTHORS.md). */ +/* */ +/* 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. */ +/*************************************************************************/ + +#include "sub_viewport_preview_editor_plugin.h" + +bool EditorInspectorPluginSubViewportPreview::can_handle(Object *p_object) { + return Object::cast_to<SubViewport>(p_object) != nullptr; +} + +void EditorInspectorPluginSubViewportPreview::parse_begin(Object *p_object) { + SubViewport *sub_viewport = Object::cast_to<SubViewport>(p_object); + + TexturePreview *sub_viewport_preview = memnew(TexturePreview(sub_viewport->get_texture(), false)); + // Otherwise `sub_viewport_preview`'s `texture_display` doesn't update properly when `sub_viewport`'s size changes. + sub_viewport->connect("size_changed", callable_mp((CanvasItem *)sub_viewport_preview->get_texture_display(), &CanvasItem::update)); + add_custom_control(sub_viewport_preview); +} + +SubViewportPreviewEditorPlugin::SubViewportPreviewEditorPlugin(EditorNode *p_node) { + Ref<EditorInspectorPluginSubViewportPreview> plugin; + plugin.instantiate(); + add_inspector_plugin(plugin); +} diff --git a/editor/plugins/sub_viewport_preview_editor_plugin.h b/editor/plugins/sub_viewport_preview_editor_plugin.h new file mode 100644 index 0000000000..03b8b678d1 --- /dev/null +++ b/editor/plugins/sub_viewport_preview_editor_plugin.h @@ -0,0 +1,56 @@ +/*************************************************************************/ +/* sub_viewport_preview_editor_plugin.h */ +/*************************************************************************/ +/* This file is part of: */ +/* GODOT ENGINE */ +/* https://godotengine.org */ +/*************************************************************************/ +/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2021 Godot Engine contributors (cf. AUTHORS.md). */ +/* */ +/* 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 SUB_VIEWPORT_PREVIEW_EDITOR_PLUGIN_H +#define SUB_VIEWPORT_PREVIEW_EDITOR_PLUGIN_H + +#include "editor/editor_node.h" +#include "editor/editor_plugin.h" +#include "editor/plugins/texture_editor_plugin.h" +#include "scene/main/viewport.h" + +class EditorInspectorPluginSubViewportPreview : public EditorInspectorPluginTexture { + GDCLASS(EditorInspectorPluginSubViewportPreview, EditorInspectorPluginTexture); + +public: + virtual bool can_handle(Object *p_object) override; + virtual void parse_begin(Object *p_object) override; +}; + +class SubViewportPreviewEditorPlugin : public EditorPlugin { + GDCLASS(SubViewportPreviewEditorPlugin, EditorPlugin); + +public: + virtual String get_name() const override { return "SubViewportPreview"; } + + SubViewportPreviewEditorPlugin(EditorNode *p_node); +}; + +#endif // SUB_VIEWPORT_PREVIEW_EDITOR_PLUGIN_H diff --git a/editor/plugins/text_editor.cpp b/editor/plugins/text_editor.cpp index 5766646f7d..faf287b9bd 100644 --- a/editor/plugins/text_editor.cpp +++ b/editor/plugins/text_editor.cpp @@ -100,7 +100,7 @@ void TextEditor::set_edited_resource(const RES &p_res) { code_editor->get_text_editor()->clear_undo_history(); code_editor->get_text_editor()->tag_saved_version(); - emit_signal("name_changed"); + emit_signal(SNAME("name_changed")); code_editor->update_line_and_column(); } @@ -149,8 +149,8 @@ void TextEditor::reload_text() { } void TextEditor::_validate_script() { - emit_signal("name_changed"); - emit_signal("edited_script_changed"); + emit_signal(SNAME("name_changed")); + emit_signal(SNAME("edited_script_changed")); } void TextEditor::_update_bookmark_list() { @@ -291,27 +291,27 @@ void TextEditor::_edit_option(int p_op) { switch (p_op) { case EDIT_UNDO: { tx->undo(); - tx->call_deferred("grab_focus"); + tx->call_deferred(SNAME("grab_focus")); } break; case EDIT_REDO: { tx->redo(); - tx->call_deferred("grab_focus"); + tx->call_deferred(SNAME("grab_focus")); } break; case EDIT_CUT: { tx->cut(); - tx->call_deferred("grab_focus"); + tx->call_deferred(SNAME("grab_focus")); } break; case EDIT_COPY: { tx->copy(); - tx->call_deferred("grab_focus"); + tx->call_deferred(SNAME("grab_focus")); } break; case EDIT_PASTE: { tx->paste(); - tx->call_deferred("grab_focus"); + tx->call_deferred(SNAME("grab_focus")); } break; case EDIT_SELECT_ALL: { tx->select_all(); - tx->call_deferred("grab_focus"); + tx->call_deferred(SNAME("grab_focus")); } break; case EDIT_MOVE_LINE_UP: { code_editor->move_lines_up(); @@ -378,12 +378,12 @@ void TextEditor::_edit_option(int p_op) { // Yep, because it doesn't make sense to instance this dialog for every single script open... // So this will be delegated to the ScriptEditor. - emit_signal("search_in_files_requested", selected_text); + emit_signal(SNAME("search_in_files_requested"), selected_text); } break; case REPLACE_IN_FILES: { String selected_text = code_editor->get_text_editor()->get_selection_text(); - emit_signal("replace_in_files_requested", selected_text); + emit_signal(SNAME("replace_in_files_requested"), selected_text); } break; case SEARCH_GOTO_LINE: { goto_line_dialog->popup_find_line(tx); diff --git a/editor/plugins/texture_3d_editor_plugin.cpp b/editor/plugins/texture_3d_editor_plugin.cpp index 696aa88e23..3987cdd6a0 100644 --- a/editor/plugins/texture_3d_editor_plugin.cpp +++ b/editor/plugins/texture_3d_editor_plugin.cpp @@ -50,7 +50,7 @@ void Texture3DEditor::_notification(int p_what) { } if (p_what == NOTIFICATION_DRAW) { - Ref<Texture2D> checkerboard = get_theme_icon("Checkerboard", "EditorIcons"); + Ref<Texture2D> checkerboard = get_theme_icon(SNAME("Checkerboard"), SNAME("EditorIcons")); Size2 size = get_size(); draw_texture_rect(checkerboard, Rect2(Point2(), size), true); @@ -77,16 +77,17 @@ void Texture3DEditor::_update_material() { } void Texture3DEditor::_make_shaders() { - String shader_3d = "" - "shader_type canvas_item;\n" - "uniform sampler3D tex;\n" - "uniform float layer;\n" - "void fragment() {\n" - " COLOR = textureLod(tex,vec3(UV,layer),0.0);\n" - "}"; - shader.instantiate(); - shader->set_code(shader_3d); + shader->set_code(R"( +shader_type canvas_item; + +uniform sampler3D tex; +uniform float layer; + +void fragment() { + COLOR = textureLod(tex, vec3(UV, layer), 0.0); +} +)"); material.instantiate(); material->set_shader(shader); } diff --git a/editor/plugins/texture_editor_plugin.cpp b/editor/plugins/texture_editor_plugin.cpp index 10b942d9ee..44db06bcfd 100644 --- a/editor/plugins/texture_editor_plugin.cpp +++ b/editor/plugins/texture_editor_plugin.cpp @@ -30,132 +30,86 @@ #include "texture_editor_plugin.h" -#include "core/config/project_settings.h" -#include "core/io/resource_loader.h" -#include "editor/editor_settings.h" +#include "editor/editor_scale.h" -void TextureEditor::_gui_input(Ref<InputEvent> p_event) { +TextureRect *TexturePreview::get_texture_display() { + return texture_display; } -void TextureEditor::_notification(int p_what) { - if (p_what == NOTIFICATION_READY) { - //get_scene()->connect("node_removed",this,"_node_removed"); +void TexturePreview::_notification(int p_what) { + switch (p_what) { + case NOTIFICATION_ENTER_TREE: + case NOTIFICATION_THEME_CHANGED: { + if (!is_inside_tree()) { + // TODO: This is a workaround because `NOTIFICATION_THEME_CHANGED` + // is getting called for some reason when the `TexturePreview` is + // getting destroyed, which causes `get_theme_font()` to return `nullptr`. + // See https://github.com/godotengine/godot/issues/50743. + break; + } + + if (metadata_label) { + Ref<Font> metadata_label_font = get_theme_font(SNAME("expression"), SNAME("EditorFonts")); + metadata_label->add_theme_font_override("font", metadata_label_font); + } + + checkerboard->set_texture(get_theme_icon(SNAME("Checkerboard"), SNAME("EditorIcons"))); + } break; } +} - if (p_what == NOTIFICATION_DRAW) { - Ref<Texture2D> checkerboard = get_theme_icon("Checkerboard", "EditorIcons"); - Size2 size = get_size(); - - draw_texture_rect(checkerboard, Rect2(Point2(), size), true); - - int tex_width = texture->get_width() * size.height / texture->get_height(); - int tex_height = size.height; - - if (tex_width > size.width) { - tex_width = size.width; - tex_height = texture->get_height() * tex_width / texture->get_width(); - } - - // Prevent the texture from being unpreviewable after the rescale, so that we can still see something - if (tex_height <= 0) { - tex_height = 1; - } - if (tex_width <= 0) { - tex_width = 1; - } - - int ofs_x = (size.width - tex_width) / 2; - int ofs_y = (size.height - tex_height) / 2; - - if (Object::cast_to<CurveTexture>(*texture)) { - // In the case of CurveTextures we know they are 1 in height, so fill the preview to see the gradient - ofs_y = 0; - tex_height = size.height; - } else if (Object::cast_to<GradientTexture>(*texture)) { - ofs_y = size.height / 4.0; - tex_height = size.height / 2.0; - } +TexturePreview::TexturePreview(Ref<Texture2D> p_texture, bool p_show_metadata) { + checkerboard = memnew(TextureRect); + checkerboard->set_stretch_mode(TextureRect::STRETCH_TILE); + checkerboard->set_texture_repeat(CanvasItem::TEXTURE_REPEAT_ENABLED); + checkerboard->set_custom_minimum_size(Size2(0.0, 256.0) * EDSCALE); + add_child(checkerboard); - draw_texture_rect(texture, Rect2(ofs_x, ofs_y, tex_width, tex_height)); + texture_display = memnew(TextureRect); + texture_display->set_texture(p_texture); + texture_display->set_anchors_preset(TextureRect::PRESET_WIDE); + texture_display->set_stretch_mode(TextureRect::STRETCH_KEEP_ASPECT_CENTERED); + texture_display->set_expand(true); + add_child(texture_display); - Ref<Font> font = get_theme_font("font", "Label"); - int font_size = get_theme_font_size("font_size", "Label"); + if (p_show_metadata) { + metadata_label = memnew(Label); String format; - if (Object::cast_to<ImageTexture>(*texture)) { - format = Image::get_format_name(Object::cast_to<ImageTexture>(*texture)->get_format()); - } else if (Object::cast_to<StreamTexture2D>(*texture)) { - format = Image::get_format_name(Object::cast_to<StreamTexture2D>(*texture)->get_format()); + if (Object::cast_to<ImageTexture>(*p_texture)) { + format = Image::get_format_name(Object::cast_to<ImageTexture>(*p_texture)->get_format()); + } else if (Object::cast_to<StreamTexture2D>(*p_texture)) { + format = Image::get_format_name(Object::cast_to<StreamTexture2D>(*p_texture)->get_format()); } else { - format = texture->get_class(); + format = p_texture->get_class(); } - String text = itos(texture->get_width()) + "x" + itos(texture->get_height()) + " " + format; - Size2 rect = font->get_string_size(text, font_size); + metadata_label->set_text(itos(p_texture->get_width()) + "x" + itos(p_texture->get_height()) + " " + format); - Vector2 draw_from = size - rect + Size2(-2, font->get_ascent(font_size) - 2); - if (draw_from.x < 0) { - draw_from.x = 0; - } + // It's okay that these colors are static since the grid color is static too. + metadata_label->add_theme_color_override("font_color", Color::named("white")); + metadata_label->add_theme_color_override("font_color_shadow", Color::named("black")); - draw_string(font, draw_from + Vector2(2, 2), text, HALIGN_LEFT, size.width, font_size, Color(0, 0, 0, 0.5)); - draw_string(font, draw_from - Vector2(2, 2), text, HALIGN_LEFT, size.width, font_size, Color(0, 0, 0, 0.5)); - draw_string(font, draw_from, text, HALIGN_LEFT, size.width, font_size, Color(1, 1, 1, 1)); - } -} + metadata_label->add_theme_font_size_override("font_size", 16 * EDSCALE); + metadata_label->add_theme_color_override("font_outline_color", Color::named("black")); + metadata_label->add_theme_constant_override("outline_size", 2 * EDSCALE); -void TextureEditor::_texture_changed() { - if (!is_visible()) { - return; - } - update(); -} + metadata_label->add_theme_constant_override("shadow_as_outline", 1); + metadata_label->set_h_size_flags(Control::SIZE_SHRINK_END); + metadata_label->set_v_size_flags(Control::SIZE_SHRINK_END); -void TextureEditor::edit(Ref<Texture2D> p_texture) { - if (!texture.is_null()) { - texture->disconnect("changed", callable_mp(this, &TextureEditor::_texture_changed)); + add_child(metadata_label); } - - texture = p_texture; - - if (!texture.is_null()) { - texture->connect("changed", callable_mp(this, &TextureEditor::_texture_changed)); - update(); - } else { - hide(); - } -} - -void TextureEditor::_bind_methods() { - ClassDB::bind_method(D_METHOD("_gui_input"), &TextureEditor::_gui_input); } -TextureEditor::TextureEditor() { - set_texture_repeat(TextureRepeat::TEXTURE_REPEAT_ENABLED); - set_custom_minimum_size(Size2(1, 150)); -} - -TextureEditor::~TextureEditor() { - if (!texture.is_null()) { - texture->disconnect("changed", callable_mp(this, &TextureEditor::_texture_changed)); - } -} - -// bool EditorInspectorPluginTexture::can_handle(Object *p_object) { return Object::cast_to<ImageTexture>(p_object) != nullptr || Object::cast_to<AtlasTexture>(p_object) != nullptr || Object::cast_to<StreamTexture2D>(p_object) != nullptr || Object::cast_to<AnimatedTexture>(p_object) != nullptr; } void EditorInspectorPluginTexture::parse_begin(Object *p_object) { - Texture2D *texture = Object::cast_to<Texture2D>(p_object); - if (!texture) { - return; - } - Ref<Texture2D> m(texture); + Ref<Texture> texture(Object::cast_to<Texture>(p_object)); - TextureEditor *editor = memnew(TextureEditor); - editor->edit(m); - add_custom_control(editor); + add_custom_control(memnew(TexturePreview(texture, true))); } TextureEditorPlugin::TextureEditorPlugin(EditorNode *p_node) { diff --git a/editor/plugins/texture_editor_plugin.h b/editor/plugins/texture_editor_plugin.h index ebe8882194..36a5513ea6 100644 --- a/editor/plugins/texture_editor_plugin.h +++ b/editor/plugins/texture_editor_plugin.h @@ -35,21 +35,21 @@ #include "editor/editor_plugin.h" #include "scene/resources/texture.h" -class TextureEditor : public Control { - GDCLASS(TextureEditor, Control); +class TexturePreview : public MarginContainer { + GDCLASS(TexturePreview, MarginContainer); - Ref<Texture2D> texture; +private: + TextureRect *texture_display = nullptr; + + TextureRect *checkerboard = nullptr; + Label *metadata_label = nullptr; protected: void _notification(int p_what); - void _gui_input(Ref<InputEvent> p_event); - void _texture_changed(); - static void _bind_methods(); public: - void edit(Ref<Texture2D> p_texture); - TextureEditor(); - ~TextureEditor(); + TextureRect *get_texture_display(); + TexturePreview(Ref<Texture2D> p_texture, bool p_show_metadata); }; class EditorInspectorPluginTexture : public EditorInspectorPlugin { diff --git a/editor/plugins/texture_layered_editor_plugin.cpp b/editor/plugins/texture_layered_editor_plugin.cpp index 3f46cd64a2..80359452ac 100644 --- a/editor/plugins/texture_layered_editor_plugin.cpp +++ b/editor/plugins/texture_layered_editor_plugin.cpp @@ -58,7 +58,7 @@ void TextureLayeredEditor::_notification(int p_what) { } if (p_what == NOTIFICATION_DRAW) { - Ref<Texture2D> checkerboard = get_theme_icon("Checkerboard", "EditorIcons"); + Ref<Texture2D> checkerboard = get_theme_icon(SNAME("Checkerboard"), SNAME("EditorIcons")); Size2 size = get_size(); draw_texture_rect(checkerboard, Rect2(Point2(), size), true); @@ -104,43 +104,46 @@ void TextureLayeredEditor::_update_material() { } void TextureLayeredEditor::_make_shaders() { - String shader_2d_array = "" - "shader_type canvas_item;\n" - "uniform sampler2DArray tex;\n" - "uniform float layer;\n" - "void fragment() {\n" - " COLOR = textureLod(tex,vec3(UV,layer),0.0);\n" - "}"; - shaders[0].instantiate(); - shaders[0]->set_code(shader_2d_array); - - String shader_cube = "" - "shader_type canvas_item;\n" - "uniform samplerCube tex;\n" - "uniform vec3 normal;\n" - "uniform mat3 rot;\n" - "void fragment() {\n" - " vec3 n = rot * normalize(vec3(normal.xy*(UV * 2.0 - 1.0),normal.z));\n" - " COLOR = textureLod(tex,n,0.0);\n" - "}"; + shaders[0]->set_code(R"( +shader_type canvas_item; + +uniform sampler2DArray tex; +uniform float layer; + +void fragment() { + COLOR = textureLod(tex, vec3(UV, layer), 0.0); +} +)"); shaders[1].instantiate(); - shaders[1]->set_code(shader_cube); - - String shader_cube_array = "" - "shader_type canvas_item;\n" - "uniform samplerCubeArray tex;\n" - "uniform vec3 normal;\n" - "uniform mat3 rot;\n" - "uniform float layer;\n" - "void fragment() {\n" - " vec3 n = rot * normalize(vec3(normal.xy*(UV * 2.0 - 1.0),normal.z));\n" - " COLOR = textureLod(tex,vec4(n,layer),0.0);\n" - "}"; + shaders[1]->set_code(R"( +shader_type canvas_item; + +uniform samplerCube tex; +uniform vec3 normal; +uniform mat3 rot; + +void fragment() { + vec3 n = rot * normalize(vec3(normal.xy * (UV * 2.0 - 1.0), normal.z)); + COLOR = textureLod(tex, n, 0.0); +} +)"); shaders[2].instantiate(); - shaders[2]->set_code(shader_cube_array); + shaders[2]->set_code(R"( +shader_type canvas_item; + +uniform samplerCubeArray tex; +uniform vec3 normal; +uniform mat3 rot; +uniform float layer; + +void fragment() { + vec3 n = rot * normalize(vec3(normal.xy * (UV * 2.0 - 1.0), normal.z)); + COLOR = textureLod(tex, vec4(n, layer), 0.0); +} +)"); for (int i = 0; i < 3; i++) { materials[i].instantiate(); diff --git a/editor/plugins/texture_region_editor_plugin.cpp b/editor/plugins/texture_region_editor_plugin.cpp index d0ba68138b..b277f2ab42 100644 --- a/editor/plugins/texture_region_editor_plugin.cpp +++ b/editor/plugins/texture_region_editor_plugin.cpp @@ -47,14 +47,14 @@ void draw_margin_line(Control *edit_draw, Vector2 from, Vector2 to) { edit_draw->draw_line( from, to, - EditorNode::get_singleton()->get_theme_base()->get_theme_color("mono_color", "Editor").inverted() * Color(1, 1, 1, 0.5), + EditorNode::get_singleton()->get_theme_base()->get_theme_color(SNAME("mono_color"), SNAME("Editor")).inverted() * Color(1, 1, 1, 0.5), Math::round(2 * EDSCALE)); while ((to - from).length_squared() > 200) { edit_draw->draw_line( from, from + line, - EditorNode::get_singleton()->get_theme_base()->get_theme_color("mono_color", "Editor"), + EditorNode::get_singleton()->get_theme_base()->get_theme_color(SNAME("mono_color"), SNAME("Editor")), Math::round(2 * EDSCALE)); from += line * 2; @@ -144,8 +144,7 @@ void TextureRegionEditor::_region_draw() { } } } else if (snap_mode == SNAP_AUTOSLICE) { - for (List<Rect2>::Element *E = autoslice_cache.front(); E; E = E->next()) { - Rect2 r = E->get(); + for (const Rect2 &r : autoslice_cache) { Vector2 endpoints[4] = { mtx.basis_xform(r.position), mtx.basis_xform(r.position + Vector2(r.size.x, 0)), @@ -159,7 +158,7 @@ void TextureRegionEditor::_region_draw() { } } - Ref<Texture2D> select_handle = get_theme_icon("EditorHandle", "EditorIcons"); + Ref<Texture2D> select_handle = get_theme_icon(SNAME("EditorHandle"), SNAME("EditorIcons")); Rect2 scroll_rect(Point2(), base_tex->get_size()); @@ -175,7 +174,7 @@ void TextureRegionEditor::_region_draw() { mtx.basis_xform(raw_endpoints[2]), mtx.basis_xform(raw_endpoints[3]) }; - Color color = get_theme_color("mono_color", "Editor"); + Color color = get_theme_color(SNAME("mono_color"), SNAME("Editor")); for (int i = 0; i < 4; i++) { int prev = (i + 3) % 4; int next = (i + 1) % 4; @@ -328,9 +327,9 @@ void TextureRegionEditor::_region_input(const Ref<InputEvent> &p_input) { } if (edited_margin < 0 && snap_mode == SNAP_AUTOSLICE) { Vector2 point = mtx.affine_inverse().xform(Vector2(mb->get_position().x, mb->get_position().y)); - for (List<Rect2>::Element *E = autoslice_cache.front(); E; E = E->next()) { - if (E->get().has_point(point)) { - rect = E->get(); + for (const Rect2 &E : autoslice_cache) { + if (E.has_point(point)) { + rect = E; if (Input::get_singleton()->is_key_pressed(KEY_CTRL) && !(Input::get_singleton()->is_key_pressed(KEY_SHIFT | KEY_ALT))) { Rect2 r; if (node_sprite) { @@ -749,12 +748,12 @@ void TextureRegionEditor::_update_autoslice() { for (int x = 0; x < texture->get_width(); x++) { if (texture->is_pixel_opaque(x, y)) { bool found = false; - for (List<Rect2>::Element *E = autoslice_cache.front(); E; E = E->next()) { - Rect2 grown = E->get().grow(1.5); + for (Rect2 &E : autoslice_cache) { + Rect2 grown = E.grow(1.5); if (grown.has_point(Point2(x, y))) { - E->get().expand_to(Point2(x, y)); - E->get().expand_to(Point2(x + 1, y + 1)); - x = E->get().position.x + E->get().size.x - 1; + E.expand_to(Point2(x, y)); + E.expand_to(Point2(x + 1, y + 1)); + x = E.position.x + E.size.x - 1; bool merged = true; while (merged) { merged = false; @@ -764,12 +763,12 @@ void TextureRegionEditor::_update_autoslice() { autoslice_cache.erase(F->prev()); queue_erase = false; } - if (F == E) { + if (F->get() == E) { continue; } - if (E->get().grow(1).intersects(F->get())) { - E->get().expand_to(F->get().position); - E->get().expand_to(F->get().position + F->get().size); + if (E.grow(1).intersects(F->get())) { + E.expand_to(F->get().position); + E.expand_to(F->get().position + F->get().size); if (F->prev()) { F = F->prev(); autoslice_cache.erase(F->next()); @@ -799,12 +798,12 @@ void TextureRegionEditor::_notification(int p_what) { switch (p_what) { case NOTIFICATION_ENTER_TREE: case NOTIFICATION_THEME_CHANGED: { - edit_draw->add_theme_style_override("panel", get_theme_stylebox("bg", "Tree")); + edit_draw->add_theme_style_override("panel", get_theme_stylebox(SNAME("bg"), SNAME("Tree"))); } break; case NOTIFICATION_READY: { - zoom_out->set_icon(get_theme_icon("ZoomLess", "EditorIcons")); - zoom_reset->set_icon(get_theme_icon("ZoomReset", "EditorIcons")); - zoom_in->set_icon(get_theme_icon("ZoomMore", "EditorIcons")); + zoom_out->set_icon(get_theme_icon(SNAME("ZoomLess"), SNAME("EditorIcons"))); + zoom_reset->set_icon(get_theme_icon(SNAME("ZoomReset"), SNAME("EditorIcons"))); + zoom_in->set_icon(get_theme_icon(SNAME("ZoomMore"), SNAME("EditorIcons"))); vscroll->set_anchors_and_offsets_preset(PRESET_RIGHT_WIDE); hscroll->set_anchors_and_offsets_preset(PRESET_BOTTOM_WIDE); diff --git a/editor/plugins/theme_editor_plugin.cpp b/editor/plugins/theme_editor_plugin.cpp index 0a8a0dcdce..0929a629f8 100644 --- a/editor/plugins/theme_editor_plugin.cpp +++ b/editor/plugins/theme_editor_plugin.cpp @@ -65,8 +65,8 @@ void ThemeItemImportTree::_update_items_tree() { tree_icon_items.clear(); tree_stylebox_items.clear(); - for (List<StringName>::Element *E = types.front(); E; E = E->next()) { - String type_name = (String)E->get(); + for (const StringName &E : types) { + String type_name = (String)E; TreeItem *type_node = import_items_tree->create_item(root); type_node->set_meta("_can_be_imported", false); @@ -89,12 +89,12 @@ void ThemeItemImportTree::_update_items_tree() { names.clear(); filtered_names.clear(); - base_theme->get_theme_item_list(dt, E->get(), &names); + base_theme->get_theme_item_list(dt, E, &names); bool data_type_has_filtered_items = false; - for (List<StringName>::Element *F = names.front(); F; F = F->next()) { - String item_name = (String)F->get(); + for (const StringName &F : names) { + String item_name = (String)F; bool is_item_matching_filter = (item_name.findn(filter_text) > -1); if (!filter_text.is_empty() && !is_matching_filter && !is_item_matching_filter) { continue; @@ -105,7 +105,7 @@ void ThemeItemImportTree::_update_items_tree() { has_filtered_items = true; data_type_has_filtered_items = true; } - filtered_names.push_back(F->get()); + filtered_names.push_back(F); } if (filtered_names.size() == 0) { @@ -127,7 +127,7 @@ void ThemeItemImportTree::_update_items_tree() { switch (dt) { case Theme::DATA_TYPE_COLOR: - data_type_node->set_icon(0, get_theme_icon("Color", "EditorIcons")); + data_type_node->set_icon(0, get_theme_icon(SNAME("Color"), SNAME("EditorIcons"))); data_type_node->set_text(0, TTR("Colors")); item_list = &tree_color_items; @@ -135,7 +135,7 @@ void ThemeItemImportTree::_update_items_tree() { break; case Theme::DATA_TYPE_CONSTANT: - data_type_node->set_icon(0, get_theme_icon("MemberConstant", "EditorIcons")); + data_type_node->set_icon(0, get_theme_icon(SNAME("MemberConstant"), SNAME("EditorIcons"))); data_type_node->set_text(0, TTR("Constants")); item_list = &tree_constant_items; @@ -143,7 +143,7 @@ void ThemeItemImportTree::_update_items_tree() { break; case Theme::DATA_TYPE_FONT: - data_type_node->set_icon(0, get_theme_icon("Font", "EditorIcons")); + data_type_node->set_icon(0, get_theme_icon(SNAME("Font"), SNAME("EditorIcons"))); data_type_node->set_text(0, TTR("Fonts")); item_list = &tree_font_items; @@ -151,7 +151,7 @@ void ThemeItemImportTree::_update_items_tree() { break; case Theme::DATA_TYPE_FONT_SIZE: - data_type_node->set_icon(0, get_theme_icon("FontSize", "EditorIcons")); + data_type_node->set_icon(0, get_theme_icon(SNAME("FontSize"), SNAME("EditorIcons"))); data_type_node->set_text(0, TTR("Font Sizes")); item_list = &tree_font_size_items; @@ -159,7 +159,7 @@ void ThemeItemImportTree::_update_items_tree() { break; case Theme::DATA_TYPE_ICON: - data_type_node->set_icon(0, get_theme_icon("ImageTexture", "EditorIcons")); + data_type_node->set_icon(0, get_theme_icon(SNAME("ImageTexture"), SNAME("EditorIcons"))); data_type_node->set_text(0, TTR("Icons")); item_list = &tree_icon_items; @@ -167,7 +167,7 @@ void ThemeItemImportTree::_update_items_tree() { break; case Theme::DATA_TYPE_STYLEBOX: - data_type_node->set_icon(0, get_theme_icon("StyleBoxFlat", "EditorIcons")); + data_type_node->set_icon(0, get_theme_icon(SNAME("StyleBoxFlat"), SNAME("EditorIcons"))); data_type_node->set_text(0, TTR("Styleboxes")); item_list = &tree_stylebox_items; @@ -182,10 +182,10 @@ void ThemeItemImportTree::_update_items_tree() { bool data_type_any_checked_with_data = false; filtered_names.sort_custom<StringName::AlphCompare>(); - for (List<StringName>::Element *F = filtered_names.front(); F; F = F->next()) { + for (const StringName &F : filtered_names) { TreeItem *item_node = import_items_tree->create_item(data_type_node); item_node->set_meta("_can_be_imported", true); - item_node->set_text(0, F->get()); + item_node->set_text(0, F); item_node->set_cell_mode(IMPORT_ITEM, TreeItem::CELL_MODE_CHECK); item_node->set_checked(IMPORT_ITEM, false); item_node->set_editable(IMPORT_ITEM, true); @@ -754,7 +754,7 @@ void ThemeItemImportTree::_import_selected() { return; } - // Prevent changes from immediatelly being reported while the operation is still ongoing. + // Prevent changes from immediately being reported while the operation is still ongoing. edited_theme->_freeze_change_propagation(); ProgressDialog::get_singleton()->add_task("import_theme_items", TTR("Importing Theme Items"), selected_items.size() + 2); @@ -821,7 +821,7 @@ void ThemeItemImportTree::_import_selected() { ProgressDialog::get_singleton()->task_step("import_theme_items", TTR("Finalizing"), idx++); ProgressDialog::get_singleton()->end_task("import_theme_items"); - emit_signal("items_imported"); + emit_signal(SNAME("items_imported")); } void ThemeItemImportTree::set_edited_theme(const Ref<Theme> &p_theme) { @@ -854,47 +854,47 @@ void ThemeItemImportTree::_notification(int p_what) { switch (p_what) { case NOTIFICATION_ENTER_TREE: case NOTIFICATION_THEME_CHANGED: { - select_icons_warning_icon->set_texture(get_theme_icon("StatusWarning", "EditorIcons")); - select_icons_warning->add_theme_color_override("font_color", get_theme_color("disabled_font_color", "Editor")); + select_icons_warning_icon->set_texture(get_theme_icon(SNAME("StatusWarning"), SNAME("EditorIcons"))); + select_icons_warning->add_theme_color_override("font_color", get_theme_color(SNAME("disabled_font_color"), SNAME("Editor"))); // Bottom panel buttons. - import_collapse_types_button->set_icon(get_theme_icon("CollapseTree", "EditorIcons")); - import_expand_types_button->set_icon(get_theme_icon("ExpandTree", "EditorIcons")); + import_collapse_types_button->set_icon(get_theme_icon(SNAME("CollapseTree"), SNAME("EditorIcons"))); + import_expand_types_button->set_icon(get_theme_icon(SNAME("ExpandTree"), SNAME("EditorIcons"))); - import_select_all_button->set_icon(get_theme_icon("ThemeSelectAll", "EditorIcons")); - import_select_full_button->set_icon(get_theme_icon("ThemeSelectFull", "EditorIcons")); - import_deselect_all_button->set_icon(get_theme_icon("ThemeDeselectAll", "EditorIcons")); + import_select_all_button->set_icon(get_theme_icon(SNAME("ThemeSelectAll"), SNAME("EditorIcons"))); + import_select_full_button->set_icon(get_theme_icon(SNAME("ThemeSelectFull"), SNAME("EditorIcons"))); + import_deselect_all_button->set_icon(get_theme_icon(SNAME("ThemeDeselectAll"), SNAME("EditorIcons"))); // Side panel buttons. - select_colors_icon->set_texture(get_theme_icon("Color", "EditorIcons")); - deselect_all_colors_button->set_icon(get_theme_icon("ThemeDeselectAll", "EditorIcons")); - select_all_colors_button->set_icon(get_theme_icon("ThemeSelectAll", "EditorIcons")); - select_full_colors_button->set_icon(get_theme_icon("ThemeSelectFull", "EditorIcons")); - - select_constants_icon->set_texture(get_theme_icon("MemberConstant", "EditorIcons")); - deselect_all_constants_button->set_icon(get_theme_icon("ThemeDeselectAll", "EditorIcons")); - select_all_constants_button->set_icon(get_theme_icon("ThemeSelectAll", "EditorIcons")); - select_full_constants_button->set_icon(get_theme_icon("ThemeSelectFull", "EditorIcons")); - - select_fonts_icon->set_texture(get_theme_icon("Font", "EditorIcons")); - deselect_all_fonts_button->set_icon(get_theme_icon("ThemeDeselectAll", "EditorIcons")); - select_all_fonts_button->set_icon(get_theme_icon("ThemeSelectAll", "EditorIcons")); - select_full_fonts_button->set_icon(get_theme_icon("ThemeSelectFull", "EditorIcons")); - - select_font_sizes_icon->set_texture(get_theme_icon("FontSize", "EditorIcons")); - deselect_all_font_sizes_button->set_icon(get_theme_icon("ThemeDeselectAll", "EditorIcons")); - select_all_font_sizes_button->set_icon(get_theme_icon("ThemeSelectAll", "EditorIcons")); - select_full_font_sizes_button->set_icon(get_theme_icon("ThemeSelectFull", "EditorIcons")); - - select_icons_icon->set_texture(get_theme_icon("ImageTexture", "EditorIcons")); - deselect_all_icons_button->set_icon(get_theme_icon("ThemeDeselectAll", "EditorIcons")); - select_all_icons_button->set_icon(get_theme_icon("ThemeSelectAll", "EditorIcons")); - select_full_icons_button->set_icon(get_theme_icon("ThemeSelectFull", "EditorIcons")); - - select_styleboxes_icon->set_texture(get_theme_icon("StyleBoxFlat", "EditorIcons")); - deselect_all_styleboxes_button->set_icon(get_theme_icon("ThemeDeselectAll", "EditorIcons")); - select_all_styleboxes_button->set_icon(get_theme_icon("ThemeSelectAll", "EditorIcons")); - select_full_styleboxes_button->set_icon(get_theme_icon("ThemeSelectFull", "EditorIcons")); + select_colors_icon->set_texture(get_theme_icon(SNAME("Color"), SNAME("EditorIcons"))); + deselect_all_colors_button->set_icon(get_theme_icon(SNAME("ThemeDeselectAll"), SNAME("EditorIcons"))); + select_all_colors_button->set_icon(get_theme_icon(SNAME("ThemeSelectAll"), SNAME("EditorIcons"))); + select_full_colors_button->set_icon(get_theme_icon(SNAME("ThemeSelectFull"), SNAME("EditorIcons"))); + + select_constants_icon->set_texture(get_theme_icon(SNAME("MemberConstant"), SNAME("EditorIcons"))); + deselect_all_constants_button->set_icon(get_theme_icon(SNAME("ThemeDeselectAll"), SNAME("EditorIcons"))); + select_all_constants_button->set_icon(get_theme_icon(SNAME("ThemeSelectAll"), SNAME("EditorIcons"))); + select_full_constants_button->set_icon(get_theme_icon(SNAME("ThemeSelectFull"), SNAME("EditorIcons"))); + + select_fonts_icon->set_texture(get_theme_icon(SNAME("Font"), SNAME("EditorIcons"))); + deselect_all_fonts_button->set_icon(get_theme_icon(SNAME("ThemeDeselectAll"), SNAME("EditorIcons"))); + select_all_fonts_button->set_icon(get_theme_icon(SNAME("ThemeSelectAll"), SNAME("EditorIcons"))); + select_full_fonts_button->set_icon(get_theme_icon(SNAME("ThemeSelectFull"), SNAME("EditorIcons"))); + + select_font_sizes_icon->set_texture(get_theme_icon(SNAME("FontSize"), SNAME("EditorIcons"))); + deselect_all_font_sizes_button->set_icon(get_theme_icon(SNAME("ThemeDeselectAll"), SNAME("EditorIcons"))); + select_all_font_sizes_button->set_icon(get_theme_icon(SNAME("ThemeSelectAll"), SNAME("EditorIcons"))); + select_full_font_sizes_button->set_icon(get_theme_icon(SNAME("ThemeSelectFull"), SNAME("EditorIcons"))); + + select_icons_icon->set_texture(get_theme_icon(SNAME("ImageTexture"), SNAME("EditorIcons"))); + deselect_all_icons_button->set_icon(get_theme_icon(SNAME("ThemeDeselectAll"), SNAME("EditorIcons"))); + select_all_icons_button->set_icon(get_theme_icon(SNAME("ThemeSelectAll"), SNAME("EditorIcons"))); + select_full_icons_button->set_icon(get_theme_icon(SNAME("ThemeSelectFull"), SNAME("EditorIcons"))); + + select_styleboxes_icon->set_texture(get_theme_icon(SNAME("StyleBoxFlat"), SNAME("EditorIcons"))); + deselect_all_styleboxes_button->set_icon(get_theme_icon(SNAME("ThemeDeselectAll"), SNAME("EditorIcons"))); + select_all_styleboxes_button->set_icon(get_theme_icon(SNAME("ThemeSelectAll"), SNAME("EditorIcons"))); + select_full_styleboxes_button->set_icon(get_theme_icon(SNAME("ThemeSelectFull"), SNAME("EditorIcons"))); } break; } } @@ -1236,16 +1236,16 @@ void ThemeItemEditorDialog::_update_edit_types() { bool item_reselected = false; edit_type_list->clear(); int e_idx = 0; - for (List<StringName>::Element *E = theme_types.front(); E; E = E->next()) { + for (const StringName &E : theme_types) { Ref<Texture2D> item_icon; - if (E->get() == "") { - item_icon = get_theme_icon("NodeDisabled", "EditorIcons"); + if (E == "") { + item_icon = get_theme_icon(SNAME("NodeDisabled"), SNAME("EditorIcons")); } else { - item_icon = EditorNode::get_singleton()->get_class_icon(E->get(), "NodeDisabled"); + item_icon = EditorNode::get_singleton()->get_class_icon(E, "NodeDisabled"); } - edit_type_list->add_item(E->get(), item_icon); + edit_type_list->add_item(E, item_icon); - if (E->get() == edited_item_type) { + if (E == edited_item_type) { edit_type_list->select(e_idx); item_reselected = true; } @@ -1313,16 +1313,16 @@ void ThemeItemEditorDialog::_update_edit_item_tree(String p_item_type) { if (names.size() > 0) { TreeItem *color_root = edit_items_tree->create_item(root); color_root->set_metadata(0, Theme::DATA_TYPE_COLOR); - color_root->set_icon(0, get_theme_icon("Color", "EditorIcons")); + color_root->set_icon(0, get_theme_icon(SNAME("Color"), SNAME("EditorIcons"))); color_root->set_text(0, TTR("Colors")); - color_root->add_button(0, get_theme_icon("Clear", "EditorIcons"), ITEMS_TREE_REMOVE_DATA_TYPE, false, TTR("Remove All Color Items")); + color_root->add_button(0, get_theme_icon(SNAME("Clear"), SNAME("EditorIcons")), ITEMS_TREE_REMOVE_DATA_TYPE, false, TTR("Remove All Color Items")); names.sort_custom<StringName::AlphCompare>(); - for (List<StringName>::Element *E = names.front(); E; E = E->next()) { + for (const StringName &E : names) { TreeItem *item = edit_items_tree->create_item(color_root); - item->set_text(0, E->get()); - item->add_button(0, get_theme_icon("Edit", "EditorIcons"), ITEMS_TREE_RENAME_ITEM, false, TTR("Rename Item")); - item->add_button(0, get_theme_icon("Remove", "EditorIcons"), ITEMS_TREE_REMOVE_ITEM, false, TTR("Remove Item")); + item->set_text(0, E); + item->add_button(0, get_theme_icon(SNAME("Edit"), SNAME("EditorIcons")), ITEMS_TREE_RENAME_ITEM, false, TTR("Rename Item")); + item->add_button(0, get_theme_icon(SNAME("Remove"), SNAME("EditorIcons")), ITEMS_TREE_REMOVE_ITEM, false, TTR("Remove Item")); } } } @@ -1334,16 +1334,16 @@ void ThemeItemEditorDialog::_update_edit_item_tree(String p_item_type) { if (names.size() > 0) { TreeItem *constant_root = edit_items_tree->create_item(root); constant_root->set_metadata(0, Theme::DATA_TYPE_CONSTANT); - constant_root->set_icon(0, get_theme_icon("MemberConstant", "EditorIcons")); + constant_root->set_icon(0, get_theme_icon(SNAME("MemberConstant"), SNAME("EditorIcons"))); constant_root->set_text(0, TTR("Constants")); - constant_root->add_button(0, get_theme_icon("Clear", "EditorIcons"), ITEMS_TREE_REMOVE_DATA_TYPE, false, TTR("Remove All Constant Items")); + constant_root->add_button(0, get_theme_icon(SNAME("Clear"), SNAME("EditorIcons")), ITEMS_TREE_REMOVE_DATA_TYPE, false, TTR("Remove All Constant Items")); names.sort_custom<StringName::AlphCompare>(); - for (List<StringName>::Element *E = names.front(); E; E = E->next()) { + for (const StringName &E : names) { TreeItem *item = edit_items_tree->create_item(constant_root); - item->set_text(0, E->get()); - item->add_button(0, get_theme_icon("Edit", "EditorIcons"), ITEMS_TREE_RENAME_ITEM, false, TTR("Rename Item")); - item->add_button(0, get_theme_icon("Remove", "EditorIcons"), ITEMS_TREE_REMOVE_ITEM, false, TTR("Remove Item")); + item->set_text(0, E); + item->add_button(0, get_theme_icon(SNAME("Edit"), SNAME("EditorIcons")), ITEMS_TREE_RENAME_ITEM, false, TTR("Rename Item")); + item->add_button(0, get_theme_icon(SNAME("Remove"), SNAME("EditorIcons")), ITEMS_TREE_REMOVE_ITEM, false, TTR("Remove Item")); } } } @@ -1355,16 +1355,16 @@ void ThemeItemEditorDialog::_update_edit_item_tree(String p_item_type) { if (names.size() > 0) { TreeItem *font_root = edit_items_tree->create_item(root); font_root->set_metadata(0, Theme::DATA_TYPE_FONT); - font_root->set_icon(0, get_theme_icon("Font", "EditorIcons")); + font_root->set_icon(0, get_theme_icon(SNAME("Font"), SNAME("EditorIcons"))); font_root->set_text(0, TTR("Fonts")); - font_root->add_button(0, get_theme_icon("Clear", "EditorIcons"), ITEMS_TREE_REMOVE_DATA_TYPE, false, TTR("Remove All Font Items")); + font_root->add_button(0, get_theme_icon(SNAME("Clear"), SNAME("EditorIcons")), ITEMS_TREE_REMOVE_DATA_TYPE, false, TTR("Remove All Font Items")); names.sort_custom<StringName::AlphCompare>(); - for (List<StringName>::Element *E = names.front(); E; E = E->next()) { + for (const StringName &E : names) { TreeItem *item = edit_items_tree->create_item(font_root); - item->set_text(0, E->get()); - item->add_button(0, get_theme_icon("Edit", "EditorIcons"), ITEMS_TREE_RENAME_ITEM, false, TTR("Rename Item")); - item->add_button(0, get_theme_icon("Remove", "EditorIcons"), ITEMS_TREE_REMOVE_ITEM, false, TTR("Remove Item")); + item->set_text(0, E); + item->add_button(0, get_theme_icon(SNAME("Edit"), SNAME("EditorIcons")), ITEMS_TREE_RENAME_ITEM, false, TTR("Rename Item")); + item->add_button(0, get_theme_icon(SNAME("Remove"), SNAME("EditorIcons")), ITEMS_TREE_REMOVE_ITEM, false, TTR("Remove Item")); } } } @@ -1376,16 +1376,16 @@ void ThemeItemEditorDialog::_update_edit_item_tree(String p_item_type) { if (names.size() > 0) { TreeItem *font_size_root = edit_items_tree->create_item(root); font_size_root->set_metadata(0, Theme::DATA_TYPE_FONT_SIZE); - font_size_root->set_icon(0, get_theme_icon("FontSize", "EditorIcons")); + font_size_root->set_icon(0, get_theme_icon(SNAME("FontSize"), SNAME("EditorIcons"))); font_size_root->set_text(0, TTR("Font Sizes")); - font_size_root->add_button(0, get_theme_icon("Clear", "EditorIcons"), ITEMS_TREE_REMOVE_DATA_TYPE, false, TTR("Remove All Font Size Items")); + font_size_root->add_button(0, get_theme_icon(SNAME("Clear"), SNAME("EditorIcons")), ITEMS_TREE_REMOVE_DATA_TYPE, false, TTR("Remove All Font Size Items")); names.sort_custom<StringName::AlphCompare>(); - for (List<StringName>::Element *E = names.front(); E; E = E->next()) { + for (const StringName &E : names) { TreeItem *item = edit_items_tree->create_item(font_size_root); - item->set_text(0, E->get()); - item->add_button(0, get_theme_icon("Edit", "EditorIcons"), ITEMS_TREE_RENAME_ITEM, false, TTR("Rename Item")); - item->add_button(0, get_theme_icon("Remove", "EditorIcons"), ITEMS_TREE_REMOVE_ITEM, false, TTR("Remove Item")); + item->set_text(0, E); + item->add_button(0, get_theme_icon(SNAME("Edit"), SNAME("EditorIcons")), ITEMS_TREE_RENAME_ITEM, false, TTR("Rename Item")); + item->add_button(0, get_theme_icon(SNAME("Remove"), SNAME("EditorIcons")), ITEMS_TREE_REMOVE_ITEM, false, TTR("Remove Item")); } } } @@ -1397,16 +1397,16 @@ void ThemeItemEditorDialog::_update_edit_item_tree(String p_item_type) { if (names.size() > 0) { TreeItem *icon_root = edit_items_tree->create_item(root); icon_root->set_metadata(0, Theme::DATA_TYPE_ICON); - icon_root->set_icon(0, get_theme_icon("ImageTexture", "EditorIcons")); + icon_root->set_icon(0, get_theme_icon(SNAME("ImageTexture"), SNAME("EditorIcons"))); icon_root->set_text(0, TTR("Icons")); - icon_root->add_button(0, get_theme_icon("Clear", "EditorIcons"), ITEMS_TREE_REMOVE_DATA_TYPE, false, TTR("Remove All Icon Items")); + icon_root->add_button(0, get_theme_icon(SNAME("Clear"), SNAME("EditorIcons")), ITEMS_TREE_REMOVE_DATA_TYPE, false, TTR("Remove All Icon Items")); names.sort_custom<StringName::AlphCompare>(); - for (List<StringName>::Element *E = names.front(); E; E = E->next()) { + for (const StringName &E : names) { TreeItem *item = edit_items_tree->create_item(icon_root); - item->set_text(0, E->get()); - item->add_button(0, get_theme_icon("Edit", "EditorIcons"), ITEMS_TREE_RENAME_ITEM, false, TTR("Rename Item")); - item->add_button(0, get_theme_icon("Remove", "EditorIcons"), ITEMS_TREE_REMOVE_ITEM, false, TTR("Remove Item")); + item->set_text(0, E); + item->add_button(0, get_theme_icon(SNAME("Edit"), SNAME("EditorIcons")), ITEMS_TREE_RENAME_ITEM, false, TTR("Rename Item")); + item->add_button(0, get_theme_icon(SNAME("Remove"), SNAME("EditorIcons")), ITEMS_TREE_REMOVE_ITEM, false, TTR("Remove Item")); } } } @@ -1418,16 +1418,16 @@ void ThemeItemEditorDialog::_update_edit_item_tree(String p_item_type) { if (names.size() > 0) { TreeItem *stylebox_root = edit_items_tree->create_item(root); stylebox_root->set_metadata(0, Theme::DATA_TYPE_STYLEBOX); - stylebox_root->set_icon(0, get_theme_icon("StyleBoxFlat", "EditorIcons")); + stylebox_root->set_icon(0, get_theme_icon(SNAME("StyleBoxFlat"), SNAME("EditorIcons"))); stylebox_root->set_text(0, TTR("Styleboxes")); - stylebox_root->add_button(0, get_theme_icon("Clear", "EditorIcons"), ITEMS_TREE_REMOVE_DATA_TYPE, false, TTR("Remove All StyleBox Items")); + stylebox_root->add_button(0, get_theme_icon(SNAME("Clear"), SNAME("EditorIcons")), ITEMS_TREE_REMOVE_DATA_TYPE, false, TTR("Remove All StyleBox Items")); names.sort_custom<StringName::AlphCompare>(); - for (List<StringName>::Element *E = names.front(); E; E = E->next()) { + for (const StringName &E : names) { TreeItem *item = edit_items_tree->create_item(stylebox_root); - item->set_text(0, E->get()); - item->add_button(0, get_theme_icon("Edit", "EditorIcons"), ITEMS_TREE_RENAME_ITEM, false, TTR("Rename Item")); - item->add_button(0, get_theme_icon("Remove", "EditorIcons"), ITEMS_TREE_REMOVE_ITEM, false, TTR("Remove Item")); + item->set_text(0, E); + item->add_button(0, get_theme_icon(SNAME("Edit"), SNAME("EditorIcons")), ITEMS_TREE_RENAME_ITEM, false, TTR("Rename Item")); + item->add_button(0, get_theme_icon(SNAME("Remove"), SNAME("EditorIcons")), ITEMS_TREE_REMOVE_ITEM, false, TTR("Remove Item")); } } } @@ -1459,13 +1459,16 @@ void ThemeItemEditorDialog::_item_tree_button_pressed(Object *p_item, int p_colu _update_edit_item_tree(edited_item_type); } -void ThemeItemEditorDialog::_add_theme_type() { - edited_theme->add_icon_type(edit_add_type_value->get_text()); - edited_theme->add_stylebox_type(edit_add_type_value->get_text()); - edited_theme->add_font_type(edit_add_type_value->get_text()); - edited_theme->add_font_size_type(edit_add_type_value->get_text()); - edited_theme->add_color_type(edit_add_type_value->get_text()); - edited_theme->add_constant_type(edit_add_type_value->get_text()); +void ThemeItemEditorDialog::_add_theme_type(const String &p_new_text) { + const String new_type = edit_add_type_value->get_text().strip_edges(); + edit_add_type_value->clear(); + + edited_theme->add_icon_type(new_type); + edited_theme->add_stylebox_type(new_type); + edited_theme->add_font_type(new_type); + edited_theme->add_font_size_type(new_type); + edited_theme->add_color_type(new_type); + edited_theme->add_constant_type(new_type); _update_edit_types(); // Force emit a change so that other parts of the editor can update. @@ -1500,12 +1503,12 @@ void ThemeItemEditorDialog::_add_theme_item(Theme::DataType p_data_type, String void ThemeItemEditorDialog::_remove_data_type_items(Theme::DataType p_data_type, String p_item_type) { List<StringName> names; - // Prevent changes from immediatelly being reported while the operation is still ongoing. + // Prevent changes from immediately being reported while the operation is still ongoing. edited_theme->_freeze_change_propagation(); edited_theme->get_theme_item_list(p_data_type, p_item_type, &names); - for (List<StringName>::Element *E = names.front(); E; E = E->next()) { - edited_theme->clear_theme_item(p_data_type, E->get(), p_item_type); + for (const StringName &E : names) { + edited_theme->clear_theme_item(p_data_type, E, p_item_type); } // Allow changes to be reported now that the operation is finished. @@ -1515,7 +1518,7 @@ void ThemeItemEditorDialog::_remove_data_type_items(Theme::DataType p_data_type, void ThemeItemEditorDialog::_remove_class_items() { List<StringName> names; - // Prevent changes from immediatelly being reported while the operation is still ongoing. + // Prevent changes from immediately being reported while the operation is still ongoing. edited_theme->_freeze_change_propagation(); for (int dt = 0; dt < Theme::DATA_TYPE_MAX; dt++) { @@ -1523,9 +1526,9 @@ void ThemeItemEditorDialog::_remove_class_items() { names.clear(); Theme::get_default()->get_theme_item_list(data_type, edited_item_type, &names); - for (List<StringName>::Element *E = names.front(); E; E = E->next()) { - if (edited_theme->has_theme_item_nocheck(data_type, E->get(), edited_item_type)) { - edited_theme->clear_theme_item(data_type, E->get(), edited_item_type); + for (const StringName &E : names) { + if (edited_theme->has_theme_item_nocheck(data_type, E, edited_item_type)) { + edited_theme->clear_theme_item(data_type, E, edited_item_type); } } } @@ -1539,7 +1542,7 @@ void ThemeItemEditorDialog::_remove_class_items() { void ThemeItemEditorDialog::_remove_custom_items() { List<StringName> names; - // Prevent changes from immediatelly being reported while the operation is still ongoing. + // Prevent changes from immediately being reported while the operation is still ongoing. edited_theme->_freeze_change_propagation(); for (int dt = 0; dt < Theme::DATA_TYPE_MAX; dt++) { @@ -1547,9 +1550,9 @@ void ThemeItemEditorDialog::_remove_custom_items() { names.clear(); edited_theme->get_theme_item_list(data_type, edited_item_type, &names); - for (List<StringName>::Element *E = names.front(); E; E = E->next()) { - if (!Theme::get_default()->has_theme_item_nocheck(data_type, E->get(), edited_item_type)) { - edited_theme->clear_theme_item(data_type, E->get(), edited_item_type); + for (const StringName &E : names) { + if (!Theme::get_default()->has_theme_item_nocheck(data_type, E, edited_item_type)) { + edited_theme->clear_theme_item(data_type, E, edited_item_type); } } } @@ -1563,7 +1566,7 @@ void ThemeItemEditorDialog::_remove_custom_items() { void ThemeItemEditorDialog::_remove_all_items() { List<StringName> names; - // Prevent changes from immediatelly being reported while the operation is still ongoing. + // Prevent changes from immediately being reported while the operation is still ongoing. edited_theme->_freeze_change_propagation(); for (int dt = 0; dt < Theme::DATA_TYPE_MAX; dt++) { @@ -1571,8 +1574,8 @@ void ThemeItemEditorDialog::_remove_all_items() { names.clear(); edited_theme->get_theme_item_list(data_type, edited_item_type, &names); - for (List<StringName>::Element *E = names.front(); E; E = E->next()) { - edited_theme->clear_theme_item(data_type, E->get(), edited_item_type); + for (const StringName &E : names) { + edited_theme->clear_theme_item(data_type, E, edited_item_type); } } @@ -1718,21 +1721,21 @@ void ThemeItemEditorDialog::_notification(int p_what) { [[fallthrough]]; } case NOTIFICATION_THEME_CHANGED: { - edit_items_add_color->set_icon(get_theme_icon("Color", "EditorIcons")); - edit_items_add_constant->set_icon(get_theme_icon("MemberConstant", "EditorIcons")); - edit_items_add_font->set_icon(get_theme_icon("Font", "EditorIcons")); - edit_items_add_font_size->set_icon(get_theme_icon("FontSize", "EditorIcons")); - edit_items_add_icon->set_icon(get_theme_icon("ImageTexture", "EditorIcons")); - edit_items_add_stylebox->set_icon(get_theme_icon("StyleBoxFlat", "EditorIcons")); + edit_items_add_color->set_icon(get_theme_icon(SNAME("Color"), SNAME("EditorIcons"))); + edit_items_add_constant->set_icon(get_theme_icon(SNAME("MemberConstant"), SNAME("EditorIcons"))); + edit_items_add_font->set_icon(get_theme_icon(SNAME("Font"), SNAME("EditorIcons"))); + edit_items_add_font_size->set_icon(get_theme_icon(SNAME("FontSize"), SNAME("EditorIcons"))); + edit_items_add_icon->set_icon(get_theme_icon(SNAME("ImageTexture"), SNAME("EditorIcons"))); + edit_items_add_stylebox->set_icon(get_theme_icon(SNAME("StyleBoxFlat"), SNAME("EditorIcons"))); - edit_items_remove_class->set_icon(get_theme_icon("Control", "EditorIcons")); - edit_items_remove_custom->set_icon(get_theme_icon("ThemeRemoveCustomItems", "EditorIcons")); - edit_items_remove_all->set_icon(get_theme_icon("ThemeRemoveAllItems", "EditorIcons")); + edit_items_remove_class->set_icon(get_theme_icon(SNAME("Control"), SNAME("EditorIcons"))); + edit_items_remove_custom->set_icon(get_theme_icon(SNAME("ThemeRemoveCustomItems"), SNAME("EditorIcons"))); + edit_items_remove_all->set_icon(get_theme_icon(SNAME("ThemeRemoveAllItems"), SNAME("EditorIcons"))); - import_another_theme_button->set_icon(get_theme_icon("Folder", "EditorIcons")); + import_another_theme_button->set_icon(get_theme_icon(SNAME("Folder"), SNAME("EditorIcons"))); - tc->add_theme_style_override("tab_selected", get_theme_stylebox("tab_selected_odd", "TabContainer")); - tc->add_theme_style_override("panel", get_theme_stylebox("panel_odd", "TabContainer")); + tc->add_theme_style_override("tab_selected", get_theme_stylebox(SNAME("tab_selected_odd"), SNAME("TabContainer"))); + tc->add_theme_style_override("panel", get_theme_stylebox(SNAME("panel_odd"), SNAME("TabContainer"))); } break; } } @@ -1776,11 +1779,12 @@ ThemeItemEditorDialog::ThemeItemEditorDialog() { edit_dialog_side_vb->add_child(edit_add_type_hb); edit_add_type_value = memnew(LineEdit); edit_add_type_value->set_h_size_flags(Control::SIZE_EXPAND_FILL); + edit_add_type_value->connect("text_submitted", callable_mp(this, &ThemeItemEditorDialog::_add_theme_type)); edit_add_type_hb->add_child(edit_add_type_value); Button *edit_add_type_button = memnew(Button); edit_add_type_button->set_text(TTR("Add")); edit_add_type_hb->add_child(edit_add_type_button); - edit_add_type_button->connect("pressed", callable_mp(this, &ThemeItemEditorDialog::_add_theme_type)); + edit_add_type_button->connect("pressed", callable_mp(this, &ThemeItemEditorDialog::_add_theme_type), varray("")); VBoxContainer *edit_items_vb = memnew(VBoxContainer); edit_items_vb->set_h_size_flags(Control::SIZE_EXPAND_FILL); @@ -1923,8 +1927,8 @@ ThemeItemEditorDialog::ThemeItemEditorDialog() { import_another_theme_dialog->set_title(TTR("Select Another Theme Resource:")); List<String> ext; ResourceLoader::get_recognized_extensions_for_type("Theme", &ext); - for (List<String>::Element *E = ext.front(); E; E = E->next()) { - import_another_theme_dialog->add_filter("*." + E->get() + "; Theme Resource"); + for (const String &E : ext) { + import_another_theme_dialog->add_filter("*." + E + "; Theme Resource"); } import_another_file_hb->add_child(import_another_theme_dialog); import_another_theme_dialog->connect("file_selected", callable_mp(this, &ThemeItemEditorDialog::_select_another_theme_cbk)); @@ -1951,7 +1955,7 @@ void ThemeTypeDialog::_dialog_about_to_show() { } void ThemeTypeDialog::ok_pressed() { - emit_signal("type_selected", add_type_filter->get_text().strip_edges()); + emit_signal(SNAME("type_selected"), add_type_filter->get_text().strip_edges()); } void ThemeTypeDialog::_update_add_type_options(const String &p_filter) { @@ -1965,26 +1969,26 @@ void ThemeTypeDialog::_update_add_type_options(const String &p_filter) { names.sort_custom<StringName::AlphCompare>(); Vector<StringName> unique_names; - for (List<StringName>::Element *E = names.front(); E; E = E->next()) { + for (const StringName &E : names) { // Filter out undesired values. - if (!p_filter.is_subsequence_ofi(String(E->get()))) { + if (!p_filter.is_subsequence_ofi(String(E))) { continue; } // Skip duplicate values. - if (unique_names.has(E->get())) { + if (unique_names.has(E)) { continue; } - unique_names.append(E->get()); + unique_names.append(E); Ref<Texture2D> item_icon; - if (E->get() == "") { - item_icon = get_theme_icon("NodeDisabled", "EditorIcons"); + if (E == "") { + item_icon = get_theme_icon(SNAME("NodeDisabled"), SNAME("EditorIcons")); } else { - item_icon = EditorNode::get_singleton()->get_class_icon(E->get(), "NodeDisabled"); + item_icon = EditorNode::get_singleton()->get_class_icon(E, "NodeDisabled"); } - add_type_options->add_item(E->get(), item_icon); + add_type_options->add_item(E, item_icon); } } @@ -1997,12 +2001,12 @@ void ThemeTypeDialog::_add_type_options_cbk(int p_index) { } void ThemeTypeDialog::_add_type_dialog_entered(const String &p_value) { - emit_signal("type_selected", p_value.strip_edges()); + emit_signal(SNAME("type_selected"), p_value.strip_edges()); hide(); } void ThemeTypeDialog::_add_type_dialog_activated(int p_index) { - emit_signal("type_selected", add_type_options->get_item_text(p_index)); + emit_signal(SNAME("type_selected"), add_type_options->get_item_text(p_index)); hide(); } @@ -2015,6 +2019,12 @@ void ThemeTypeDialog::_notification(int p_what) { case NOTIFICATION_THEME_CHANGED: { _update_add_type_options(); } break; + + case NOTIFICATION_VISIBILITY_CHANGED: { + if (is_visible()) { + add_type_filter->grab_focus(); + } + } break; } } @@ -2122,16 +2132,16 @@ void ThemeTypeEditor::_update_type_list() { bool item_reselected = false; int e_idx = 0; - for (List<StringName>::Element *E = theme_types.front(); E; E = E->next()) { + for (const StringName &E : theme_types) { Ref<Texture2D> item_icon; - if (E->get() == "") { - item_icon = get_theme_icon("NodeDisabled", "EditorIcons"); + if (E == "") { + item_icon = get_theme_icon(SNAME("NodeDisabled"), SNAME("EditorIcons")); } else { - item_icon = EditorNode::get_singleton()->get_class_icon(E->get(), "NodeDisabled"); + item_icon = EditorNode::get_singleton()->get_class_icon(E, "NodeDisabled"); } - theme_type_list->add_icon_item(item_icon, E->get()); + theme_type_list->add_icon_item(item_icon, E); - if (E->get() == edited_type) { + if (E == edited_type) { theme_type_list->select(e_idx); item_reselected = true; } @@ -2172,8 +2182,8 @@ OrderedHashMap<StringName, bool> ThemeTypeEditor::_get_type_items(String p_type_ (Theme::get_default().operator->()->*get_list_func)(default_type, &names); names.sort_custom<StringName::AlphCompare>(); - for (List<StringName>::Element *E = names.front(); E; E = E->next()) { - items[E->get()] = false; + for (const StringName &E : names) { + items[E] = false; } } @@ -2181,8 +2191,8 @@ OrderedHashMap<StringName, bool> ThemeTypeEditor::_get_type_items(String p_type_ names.clear(); (edited_theme.operator->()->*get_list_func)(p_type_name, &names); names.sort_custom<StringName::AlphCompare>(); - for (List<StringName>::Element *E = names.front(); E; E = E->next()) { - items[E->get()] = true; + for (const StringName &E : names) { + items[E] = true; } } @@ -2193,8 +2203,8 @@ OrderedHashMap<StringName, bool> ThemeTypeEditor::_get_type_items(String p_type_ keys.sort_custom<StringName::AlphCompare>(); OrderedHashMap<StringName, bool> ordered_items; - for (List<StringName>::Element *E = keys.front(); E; E = E->next()) { - ordered_items[E->get()] = items[E->get()]; + for (const StringName &E : keys) { + ordered_items[E] = items[E]; } return ordered_items; @@ -2224,21 +2234,21 @@ HBoxContainer *ThemeTypeEditor::_create_property_control(Theme::DataType p_data_ item_name_edit->hide(); Button *item_rename_button = memnew(Button); - item_rename_button->set_icon(get_theme_icon("Edit", "EditorIcons")); + item_rename_button->set_icon(get_theme_icon(SNAME("Edit"), SNAME("EditorIcons"))); item_rename_button->set_tooltip(TTR("Rename Item")); item_rename_button->set_flat(true); item_name_container->add_child(item_rename_button); item_rename_button->connect("pressed", callable_mp(this, &ThemeTypeEditor::_item_rename_cbk), varray(p_data_type, p_item_name, item_name_container)); Button *item_remove_button = memnew(Button); - item_remove_button->set_icon(get_theme_icon("Remove", "EditorIcons")); + item_remove_button->set_icon(get_theme_icon(SNAME("Remove"), SNAME("EditorIcons"))); item_remove_button->set_tooltip(TTR("Remove Item")); item_remove_button->set_flat(true); item_name_container->add_child(item_remove_button); item_remove_button->connect("pressed", callable_mp(this, &ThemeTypeEditor::_item_remove_cbk), varray(p_data_type, p_item_name)); Button *item_rename_confirm_button = memnew(Button); - item_rename_confirm_button->set_icon(get_theme_icon("ImportCheck", "EditorIcons")); + item_rename_confirm_button->set_icon(get_theme_icon(SNAME("ImportCheck"), SNAME("EditorIcons"))); item_rename_confirm_button->set_tooltip(TTR("Confirm Item Rename")); item_rename_confirm_button->set_flat(true); item_name_container->add_child(item_rename_confirm_button); @@ -2246,17 +2256,17 @@ HBoxContainer *ThemeTypeEditor::_create_property_control(Theme::DataType p_data_ item_rename_confirm_button->hide(); Button *item_rename_cancel_button = memnew(Button); - item_rename_cancel_button->set_icon(get_theme_icon("ImportFail", "EditorIcons")); + item_rename_cancel_button->set_icon(get_theme_icon(SNAME("ImportFail"), SNAME("EditorIcons"))); item_rename_cancel_button->set_tooltip(TTR("Cancel Item Rename")); item_rename_cancel_button->set_flat(true); item_name_container->add_child(item_rename_cancel_button); item_rename_cancel_button->connect("pressed", callable_mp(this, &ThemeTypeEditor::_item_rename_canceled), varray(p_data_type, p_item_name, item_name_container)); item_rename_cancel_button->hide(); } else { - item_name->add_theme_color_override("font_color", get_theme_color("disabled_font_color", "Editor")); + item_name->add_theme_color_override("font_color", get_theme_color(SNAME("disabled_font_color"), SNAME("Editor"))); Button *item_override_button = memnew(Button); - item_override_button->set_icon(get_theme_icon("Add", "EditorIcons")); + item_override_button->set_icon(get_theme_icon(SNAME("Add"), SNAME("EditorIcons"))); item_override_button->set_tooltip(TTR("Override Item")); item_override_button->set_flat(true); item_name_container->add_child(item_override_button); @@ -2465,7 +2475,7 @@ void ThemeTypeEditor::_update_type_items() { pin_leader_button->set_flat(true); pin_leader_button->set_toggle_mode(true); pin_leader_button->set_pressed(true); - pin_leader_button->set_icon(get_theme_icon("Pin", "EditorIcons")); + pin_leader_button->set_icon(get_theme_icon(SNAME("Pin"), SNAME("EditorIcons"))); pin_leader_button->set_tooltip(TTR("Unpin this StyleBox as a main style.")); item_control->add_child(pin_leader_button); pin_leader_button->connect("pressed", callable_mp(this, &ThemeTypeEditor::_unpin_leading_stylebox)); @@ -2510,7 +2520,7 @@ void ThemeTypeEditor::_update_type_items() { Button *pin_leader_button = memnew(Button); pin_leader_button->set_flat(true); pin_leader_button->set_toggle_mode(true); - pin_leader_button->set_icon(get_theme_icon("Pin", "EditorIcons")); + pin_leader_button->set_icon(get_theme_icon(SNAME("Pin"), SNAME("EditorIcons"))); pin_leader_button->set_tooltip(TTR("Pin this StyleBox as a main style. Editing its properties will update the same properties in all other StyleBoxes of this type.")); item_control->add_child(pin_leader_button); pin_leader_button->connect("pressed", callable_mp(this, &ThemeTypeEditor::_pin_leading_stylebox), varray(item_editor, E.key())); @@ -2564,60 +2574,60 @@ void ThemeTypeEditor::_add_default_type_items() { } updating = true; - // Prevent changes from immediatelly being reported while the operation is still ongoing. + // Prevent changes from immediately being reported while the operation is still ongoing. edited_theme->_freeze_change_propagation(); { names.clear(); Theme::get_default()->get_icon_list(default_type, &names); - for (List<StringName>::Element *E = names.front(); E; E = E->next()) { - if (!edited_theme->has_icon(E->get(), edited_type)) { - edited_theme->set_icon(E->get(), edited_type, Ref<Texture2D>()); + for (const StringName &E : names) { + if (!edited_theme->has_icon(E, edited_type)) { + edited_theme->set_icon(E, edited_type, Ref<Texture2D>()); } } } { names.clear(); Theme::get_default()->get_stylebox_list(default_type, &names); - for (List<StringName>::Element *E = names.front(); E; E = E->next()) { - if (!edited_theme->has_stylebox(E->get(), edited_type)) { - edited_theme->set_stylebox(E->get(), edited_type, Ref<StyleBox>()); + for (const StringName &E : names) { + if (!edited_theme->has_stylebox(E, edited_type)) { + edited_theme->set_stylebox(E, edited_type, Ref<StyleBox>()); } } } { names.clear(); Theme::get_default()->get_font_list(default_type, &names); - for (List<StringName>::Element *E = names.front(); E; E = E->next()) { - if (!edited_theme->has_font(E->get(), edited_type)) { - edited_theme->set_font(E->get(), edited_type, Ref<Font>()); + for (const StringName &E : names) { + if (!edited_theme->has_font(E, edited_type)) { + edited_theme->set_font(E, edited_type, Ref<Font>()); } } } { names.clear(); Theme::get_default()->get_font_size_list(default_type, &names); - for (List<StringName>::Element *E = names.front(); E; E = E->next()) { - if (!edited_theme->has_font_size(E->get(), edited_type)) { - edited_theme->set_font_size(E->get(), edited_type, Theme::get_default()->get_font_size(E->get(), default_type)); + for (const StringName &E : names) { + if (!edited_theme->has_font_size(E, edited_type)) { + edited_theme->set_font_size(E, edited_type, Theme::get_default()->get_font_size(E, default_type)); } } } { names.clear(); Theme::get_default()->get_color_list(default_type, &names); - for (List<StringName>::Element *E = names.front(); E; E = E->next()) { - if (!edited_theme->has_color(E->get(), edited_type)) { - edited_theme->set_color(E->get(), edited_type, Theme::get_default()->get_color(E->get(), default_type)); + for (const StringName &E : names) { + if (!edited_theme->has_color(E, edited_type)) { + edited_theme->set_color(E, edited_type, Theme::get_default()->get_color(E, default_type)); } } } { names.clear(); Theme::get_default()->get_constant_list(default_type, &names); - for (List<StringName>::Element *E = names.front(); E; E = E->next()) { - if (!edited_theme->has_constant(E->get(), edited_type)) { - edited_theme->set_constant(E->get(), edited_type, Theme::get_default()->get_constant(E->get(), default_type)); + for (const StringName &E : names) { + if (!edited_theme->has_constant(E, edited_type)) { + edited_theme->set_constant(E, edited_type, Theme::get_default()->get_constant(E, default_type)); } } } @@ -2866,18 +2876,18 @@ void ThemeTypeEditor::_update_stylebox_from_leading() { return; } - // Prevent changes from immediatelly being reported while the operation is still ongoing. + // Prevent changes from immediately being reported while the operation is still ongoing. edited_theme->_freeze_change_propagation(); List<StringName> names; edited_theme->get_stylebox_list(edited_type, &names); List<Ref<StyleBox>> styleboxes; - for (List<StringName>::Element *E = names.front(); E; E = E->next()) { - if (E->get() == leading_stylebox.item_name) { + for (const StringName &E : names) { + if (E == leading_stylebox.item_name) { continue; } - Ref<StyleBox> sb = edited_theme->get_stylebox(E->get(), edited_type); + Ref<StyleBox> sb = edited_theme->get_stylebox(E, edited_type); if (sb->get_class() == leading_stylebox.stylebox->get_class()) { styleboxes.push_back(sb); } @@ -2885,20 +2895,20 @@ void ThemeTypeEditor::_update_stylebox_from_leading() { List<PropertyInfo> props; leading_stylebox.stylebox->get_property_list(&props); - for (List<PropertyInfo>::Element *E = props.front(); E; E = E->next()) { - if (!(E->get().usage & PROPERTY_USAGE_STORAGE)) { + for (const PropertyInfo &E : props) { + if (!(E.usage & PROPERTY_USAGE_STORAGE)) { continue; } - Variant value = leading_stylebox.stylebox->get(E->get().name); - Variant ref_value = leading_stylebox.ref_stylebox->get(E->get().name); + Variant value = leading_stylebox.stylebox->get(E.name); + Variant ref_value = leading_stylebox.ref_stylebox->get(E.name); if (value == ref_value) { continue; } - for (List<Ref<StyleBox>>::Element *F = styleboxes.front(); F; F = F->next()) { - Ref<StyleBox> sb = F->get(); - sb->set(E->get().name, value); + for (const Ref<StyleBox> &F : styleboxes) { + Ref<StyleBox> sb = F; + sb->set(E.name, value); } } @@ -2936,20 +2946,20 @@ void ThemeTypeEditor::_notification(int p_what) { switch (p_what) { case NOTIFICATION_ENTER_TREE: case NOTIFICATION_THEME_CHANGED: { - add_type_button->set_icon(get_theme_icon("Add", "EditorIcons")); + add_type_button->set_icon(get_theme_icon(SNAME("Add"), SNAME("EditorIcons"))); - data_type_tabs->set_tab_icon(0, get_theme_icon("Color", "EditorIcons")); - data_type_tabs->set_tab_icon(1, get_theme_icon("MemberConstant", "EditorIcons")); - data_type_tabs->set_tab_icon(2, get_theme_icon("Font", "EditorIcons")); - data_type_tabs->set_tab_icon(3, get_theme_icon("FontSize", "EditorIcons")); - data_type_tabs->set_tab_icon(4, get_theme_icon("ImageTexture", "EditorIcons")); - data_type_tabs->set_tab_icon(5, get_theme_icon("StyleBoxFlat", "EditorIcons")); - data_type_tabs->set_tab_icon(6, get_theme_icon("Tools", "EditorIcons")); + data_type_tabs->set_tab_icon(0, get_theme_icon(SNAME("Color"), SNAME("EditorIcons"))); + data_type_tabs->set_tab_icon(1, get_theme_icon(SNAME("MemberConstant"), SNAME("EditorIcons"))); + data_type_tabs->set_tab_icon(2, get_theme_icon(SNAME("Font"), SNAME("EditorIcons"))); + data_type_tabs->set_tab_icon(3, get_theme_icon(SNAME("FontSize"), SNAME("EditorIcons"))); + data_type_tabs->set_tab_icon(4, get_theme_icon(SNAME("ImageTexture"), SNAME("EditorIcons"))); + data_type_tabs->set_tab_icon(5, get_theme_icon(SNAME("StyleBoxFlat"), SNAME("EditorIcons"))); + data_type_tabs->set_tab_icon(6, get_theme_icon(SNAME("Tools"), SNAME("EditorIcons"))); - data_type_tabs->add_theme_style_override("tab_selected", get_theme_stylebox("tab_selected_odd", "TabContainer")); - data_type_tabs->add_theme_style_override("panel", get_theme_stylebox("panel_odd", "TabContainer")); + data_type_tabs->add_theme_style_override("tab_selected", get_theme_stylebox(SNAME("tab_selected_odd"), SNAME("TabContainer"))); + data_type_tabs->add_theme_style_override("panel", get_theme_stylebox(SNAME("panel_odd"), SNAME("TabContainer"))); - type_variation_button->set_icon(get_theme_icon("Add", "EditorIcons")); + type_variation_button->set_icon(get_theme_icon(SNAME("Add"), SNAME("EditorIcons"))); } break; } } @@ -3102,7 +3112,7 @@ void ThemeEditor::edit(const Ref<Theme> &p_theme) { preview_tab->set_preview_theme(p_theme); } - theme_name->set_text(TTR("Theme") + ": " + theme->get_path().get_file()); + theme_name->set_text(TTR("Theme:") + " " + theme->get_path().get_file()); } Ref<Theme> ThemeEditor::get_edited_theme() { @@ -3133,7 +3143,7 @@ void ThemeEditor::_preview_scene_dialog_cbk(const String &p_path) { return; } - _add_preview_tab(preview_tab, p_path.get_file(), get_theme_icon("PackedScene", "EditorIcons")); + _add_preview_tab(preview_tab, p_path.get_file(), get_theme_icon(SNAME("PackedScene"), SNAME("EditorIcons"))); preview_tab->connect("scene_invalidated", callable_mp(this, &ThemeEditor::_remove_preview_tab_invalid), varray(preview_tab)); preview_tab->connect("scene_reloaded", callable_mp(this, &ThemeEditor::_update_preview_tab), varray(preview_tab)); } @@ -3143,7 +3153,7 @@ void ThemeEditor::_add_preview_tab(ThemeEditorPreview *p_preview_tab, const Stri preview_tabs->add_tab(p_preview_name, p_icon); preview_tabs_content->add_child(p_preview_tab); - preview_tabs->set_tab_right_button(preview_tabs->get_tab_count() - 1, EditorNode::get_singleton()->get_gui_base()->get_theme_icon("close", "Tabs")); + preview_tabs->set_tab_right_button(preview_tabs->get_tab_count() - 1, EditorNode::get_singleton()->get_gui_base()->get_theme_icon(SNAME("close"), SNAME("Tabs"))); p_preview_tab->connect("control_picked", callable_mp(this, &ThemeEditor::_preview_control_picked)); preview_tabs->set_current_tab(preview_tabs->get_tab_count() - 1); @@ -3206,11 +3216,11 @@ void ThemeEditor::_notification(int p_what) { switch (p_what) { case NOTIFICATION_ENTER_TREE: case NOTIFICATION_THEME_CHANGED: { - preview_tabs->add_theme_style_override("tab_selected", get_theme_stylebox("ThemeEditorPreviewFG", "EditorStyles")); - preview_tabs->add_theme_style_override("tab_unselected", get_theme_stylebox("ThemeEditorPreviewBG", "EditorStyles")); - preview_tabs_content->add_theme_style_override("panel", get_theme_stylebox("panel_odd", "TabContainer")); + preview_tabs->add_theme_style_override("tab_selected", get_theme_stylebox(SNAME("ThemeEditorPreviewFG"), SNAME("EditorStyles"))); + preview_tabs->add_theme_style_override("tab_unselected", get_theme_stylebox(SNAME("ThemeEditorPreviewBG"), SNAME("EditorStyles"))); + preview_tabs_content->add_theme_style_override("panel", get_theme_stylebox(SNAME("panel_odd"), SNAME("TabContainer"))); - add_preview_button->set_icon(get_theme_icon("Add", "EditorIcons")); + add_preview_button->set_icon(get_theme_icon(SNAME("Add"), SNAME("EditorIcons"))); } break; } } @@ -3220,7 +3230,7 @@ ThemeEditor::ThemeEditor() { add_child(top_menu); theme_name = memnew(Label); - theme_name->set_text(TTR("Theme") + ": "); + theme_name->set_text(TTR("Theme:")); theme_name->set_theme_type_variation("HeaderSmall"); top_menu->add_child(theme_name); @@ -3291,15 +3301,15 @@ ThemeEditor::ThemeEditor() { preview_scene_dialog->set_title(TTR("Select UI Scene:")); List<String> ext; ResourceLoader::get_recognized_extensions_for_type("PackedScene", &ext); - for (List<String>::Element *E = ext.front(); E; E = E->next()) { - preview_scene_dialog->add_filter("*." + E->get() + "; Scene"); + for (const String &E : ext) { + preview_scene_dialog->add_filter("*." + E + "; Scene"); } main_hs->add_child(preview_scene_dialog); preview_scene_dialog->connect("file_selected", callable_mp(this, &ThemeEditor::_preview_scene_dialog_cbk)); theme_type_editor = memnew(ThemeTypeEditor); main_hs->add_child(theme_type_editor); - theme_type_editor->set_custom_minimum_size(Size2(360, 0) * EDSCALE); + theme_type_editor->set_custom_minimum_size(Size2(280, 0) * EDSCALE); } void ThemeEditorPlugin::edit(Object *p_node) { @@ -3333,12 +3343,12 @@ bool ThemeEditorPlugin::handles(Object *p_node) const { List<StringName> names; edited_theme->get_font_type_list(&types); - for (List<StringName>::Element *E = types.front(); E; E = E->next()) { + for (const StringName &E : types) { names.clear(); - edited_theme->get_font_list(E->get(), &names); + edited_theme->get_font_list(E, &names); - for (List<StringName>::Element *F = names.front(); F; F = F->next()) { - if (font_item == edited_theme->get_font(F->get(), E->get())) { + for (const StringName &F : names) { + if (font_item == edited_theme->get_font(F, E)) { belongs_to_theme = true; break; } @@ -3350,12 +3360,12 @@ bool ThemeEditorPlugin::handles(Object *p_node) const { List<StringName> names; edited_theme->get_stylebox_type_list(&types); - for (List<StringName>::Element *E = types.front(); E; E = E->next()) { + for (const StringName &E : types) { names.clear(); - edited_theme->get_stylebox_list(E->get(), &names); + edited_theme->get_stylebox_list(E, &names); - for (List<StringName>::Element *F = names.front(); F; F = F->next()) { - if (stylebox_item == edited_theme->get_stylebox(F->get(), E->get())) { + for (const StringName &F : names) { + if (stylebox_item == edited_theme->get_stylebox(F, E)) { belongs_to_theme = true; break; } @@ -3367,12 +3377,12 @@ bool ThemeEditorPlugin::handles(Object *p_node) const { List<StringName> names; edited_theme->get_icon_type_list(&types); - for (List<StringName>::Element *E = types.front(); E; E = E->next()) { + for (const StringName &E : types) { names.clear(); - edited_theme->get_icon_list(E->get(), &names); + edited_theme->get_icon_list(E, &names); - for (List<StringName>::Element *F = names.front(); F; F = F->next()) { - if (icon_item == edited_theme->get_icon(F->get(), E->get())) { + for (const StringName &F : names) { + if (icon_item == edited_theme->get_icon(F, E)) { belongs_to_theme = true; break; } diff --git a/editor/plugins/theme_editor_plugin.h b/editor/plugins/theme_editor_plugin.h index 3c114a375a..e78b244a42 100644 --- a/editor/plugins/theme_editor_plugin.h +++ b/editor/plugins/theme_editor_plugin.h @@ -239,7 +239,7 @@ class ThemeItemEditorDialog : public AcceptDialog { void _update_edit_item_tree(String p_item_type); void _item_tree_button_pressed(Object *p_item, int p_column, int p_id); - void _add_theme_type(); + void _add_theme_type(const String &p_new_text); void _add_theme_item(Theme::DataType p_data_type, String p_item_name, String p_item_type); void _remove_data_type_items(Theme::DataType p_data_type, String p_item_type); void _remove_class_items(); diff --git a/editor/plugins/theme_editor_preview.cpp b/editor/plugins/theme_editor_preview.cpp index 5ea46771ba..801ee0eac2 100644 --- a/editor/plugins/theme_editor_preview.cpp +++ b/editor/plugins/theme_editor_preview.cpp @@ -76,7 +76,7 @@ void ThemeEditorPreview::_picker_button_cbk() { Control *ThemeEditorPreview::_find_hovered_control(Control *p_parent, Vector2 p_mouse_position) { Control *found = nullptr; - for (int i = 0; i < p_parent->get_child_count(); i++) { + for (int i = p_parent->get_child_count() - 1; i >= 0; i--) { Control *cc = Object::cast_to<Control>(p_parent->get_child(i)); if (!cc || !cc->is_visible()) { continue; @@ -105,12 +105,35 @@ void ThemeEditorPreview::_draw_picker_overlay() { return; } - picker_overlay->draw_rect(Rect2(Vector2(0.0, 0.0), picker_overlay->get_size()), get_theme_color("preview_picker_overlay_color", "ThemeEditor")); + picker_overlay->draw_rect(Rect2(Vector2(0.0, 0.0), picker_overlay->get_size()), theme_cache.preview_picker_overlay_color); if (hovered_control) { Rect2 highlight_rect = hovered_control->get_global_rect(); highlight_rect.position = picker_overlay->get_global_transform().affine_inverse().xform(highlight_rect.position); + picker_overlay->draw_style_box(theme_cache.preview_picker_overlay, highlight_rect); - picker_overlay->draw_style_box(get_theme_stylebox("preview_picker_overlay", "ThemeEditor"), highlight_rect); + String highlight_name = hovered_control->get_theme_type_variation(); + if (highlight_name == StringName()) { + highlight_name = hovered_control->get_class_name(); + } + + Rect2 highlight_label_rect = highlight_rect; + highlight_label_rect.size = theme_cache.preview_picker_font->get_string_size(highlight_name); + + int margin_top = theme_cache.preview_picker_label->get_margin(SIDE_TOP); + int margin_left = theme_cache.preview_picker_label->get_margin(SIDE_LEFT); + int margin_bottom = theme_cache.preview_picker_label->get_margin(SIDE_BOTTOM); + int margin_right = theme_cache.preview_picker_label->get_margin(SIDE_RIGHT); + highlight_label_rect.size.x += margin_left + margin_right; + highlight_label_rect.size.y += margin_top + margin_bottom; + + highlight_label_rect.position.x = CLAMP(highlight_label_rect.position.x, 0.0, picker_overlay->get_size().width); + highlight_label_rect.position.y = CLAMP(highlight_label_rect.position.y, 0.0, picker_overlay->get_size().height); + picker_overlay->draw_style_box(theme_cache.preview_picker_label, highlight_label_rect); + + Point2 label_pos = highlight_label_rect.position; + label_pos.y += highlight_label_rect.size.y - margin_bottom; + label_pos.x += margin_left; + picker_overlay->draw_string(theme_cache.preview_picker_font, label_pos, highlight_name); } } @@ -128,7 +151,7 @@ void ThemeEditorPreview::_gui_input_picker_overlay(const Ref<InputEvent> &p_even theme_type = hovered_control->get_class_name(); } - emit_signal("control_picked", theme_type); + emit_signal(SNAME("control_picked"), theme_type); picker_button->set_pressed(false); picker_overlay->set_visible(false); } @@ -143,6 +166,11 @@ void ThemeEditorPreview::_gui_input_picker_overlay(const Ref<InputEvent> &p_even } } +void ThemeEditorPreview::_reset_picker_overlay() { + hovered_control = nullptr; + picker_overlay->update(); +} + void ThemeEditorPreview::_notification(int p_what) { switch (p_what) { case NOTIFICATION_ENTER_TREE: { @@ -154,7 +182,12 @@ void ThemeEditorPreview::_notification(int p_what) { [[fallthrough]]; } case NOTIFICATION_THEME_CHANGED: { - picker_button->set_icon(get_theme_icon("ColorPick", "EditorIcons")); + picker_button->set_icon(get_theme_icon(SNAME("ColorPick"), SNAME("EditorIcons"))); + + theme_cache.preview_picker_overlay = get_theme_stylebox(SNAME("preview_picker_overlay"), SNAME("ThemeEditor")); + theme_cache.preview_picker_overlay_color = get_theme_color(SNAME("preview_picker_overlay_color"), SNAME("ThemeEditor")); + theme_cache.preview_picker_label = get_theme_stylebox(SNAME("preview_picker_label"), SNAME("ThemeEditor")); + theme_cache.preview_picker_font = get_theme_font(SNAME("status_source"), SNAME("EditorFonts")); } break; case NOTIFICATION_PROCESS: { time_left -= get_process_delta_time(); @@ -213,12 +246,14 @@ ThemeEditorPreview::ThemeEditorPreview() { preview_overlay = memnew(MarginContainer); preview_overlay->set_mouse_filter(MOUSE_FILTER_IGNORE); + preview_overlay->set_clip_contents(true); preview_body->add_child(preview_overlay); picker_overlay = memnew(Control); add_preview_overlay(picker_overlay); picker_overlay->connect("draw", callable_mp(this, &ThemeEditorPreview::_draw_picker_overlay)); picker_overlay->connect("gui_input", callable_mp(this, &ThemeEditorPreview::_gui_input_picker_overlay)); + picker_overlay->connect("mouse_exited", callable_mp(this, &ThemeEditorPreview::_reset_picker_overlay)); } DefaultThemeEditorPreview::DefaultThemeEditorPreview() { @@ -393,7 +428,7 @@ void SceneThemeEditorPreview::_reload_scene() { if (loaded_scene->get_path().is_empty() || !ResourceLoader::exists(loaded_scene->get_path())) { EditorNode::get_singleton()->show_warning(TTR("Invalid path, the PackedScene resource was probably moved or removed.")); - emit_signal("scene_invalidated"); + emit_signal(SNAME("scene_invalidated")); return; } @@ -406,19 +441,19 @@ void SceneThemeEditorPreview::_reload_scene() { Node *instance = loaded_scene->instantiate(); if (!instance || !Object::cast_to<Control>(instance)) { EditorNode::get_singleton()->show_warning(TTR("Invalid PackedScene resource, must have a Control node at its root.")); - emit_signal("scene_invalidated"); + emit_signal(SNAME("scene_invalidated")); return; } preview_content->add_child(instance); - emit_signal("scene_reloaded"); + emit_signal(SNAME("scene_reloaded")); } void SceneThemeEditorPreview::_notification(int p_what) { switch (p_what) { case NOTIFICATION_ENTER_TREE: case NOTIFICATION_THEME_CHANGED: { - reload_scene_button->set_icon(get_theme_icon("Reload", "EditorIcons")); + reload_scene_button->set_icon(get_theme_icon(SNAME("Reload"), SNAME("EditorIcons"))); } break; } } diff --git a/editor/plugins/theme_editor_preview.h b/editor/plugins/theme_editor_preview.h index efb7e424d4..4e1b149e70 100644 --- a/editor/plugins/theme_editor_preview.h +++ b/editor/plugins/theme_editor_preview.h @@ -60,6 +60,13 @@ class ThemeEditorPreview : public VBoxContainer { Control *picker_overlay; Control *hovered_control = nullptr; + struct ThemeCache { + Ref<StyleBox> preview_picker_overlay; + Color preview_picker_overlay_color; + Ref<StyleBox> preview_picker_label; + Ref<Font> preview_picker_font; + } theme_cache; + double time_left = 0; void _propagate_redraw(Control *p_at); @@ -71,6 +78,7 @@ class ThemeEditorPreview : public VBoxContainer { void _draw_picker_overlay(); void _gui_input_picker_overlay(const Ref<InputEvent> &p_event); + void _reset_picker_overlay(); protected: HBoxContainer *preview_toolbar; diff --git a/editor/plugins/tiles/atlas_merging_dialog.cpp b/editor/plugins/tiles/atlas_merging_dialog.cpp new file mode 100644 index 0000000000..d54906c98c --- /dev/null +++ b/editor/plugins/tiles/atlas_merging_dialog.cpp @@ -0,0 +1,320 @@ +/*************************************************************************/ +/* atlas_merging_dialog.cpp */ +/*************************************************************************/ +/* This file is part of: */ +/* GODOT ENGINE */ +/* https://godotengine.org */ +/*************************************************************************/ +/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2021 Godot Engine contributors (cf. AUTHORS.md). */ +/* */ +/* 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. */ +/*************************************************************************/ + +#include "atlas_merging_dialog.h" + +#include "editor/editor_scale.h" + +#include "scene/gui/control.h" +#include "scene/gui/split_container.h" + +void AtlasMergingDialog::_property_changed(const StringName &p_property, const Variant &p_value, const String &p_field, bool p_changing) { + _set(p_property, p_value); +} + +void AtlasMergingDialog::_generate_merged(Vector<Ref<TileSetAtlasSource>> p_atlas_sources, int p_max_columns) { + merged.instantiate(); + merged_mapping.clear(); + + if (p_atlas_sources.size() >= 2) { + Ref<Image> output_image; + output_image.instantiate(); + output_image->create(1, 1, false, Image::FORMAT_RGBA8); + + // Compute the new texture region size. + Vector2i new_texture_region_size; + for (int source_index = 0; source_index < p_atlas_sources.size(); source_index++) { + Ref<TileSetAtlasSource> atlas_source = p_atlas_sources[source_index]; + new_texture_region_size = new_texture_region_size.max(atlas_source->get_texture_region_size()); + } + + // Generate the merged TileSetAtlasSource. + Vector2i atlas_offset; + int line_height = 0; + for (int source_index = 0; source_index < p_atlas_sources.size(); source_index++) { + Ref<TileSetAtlasSource> atlas_source = p_atlas_sources[source_index]; + merged_mapping.push_back(Map<Vector2i, Vector2i>()); + + // Layout the tiles. + Vector2i atlas_size; + + for (int tile_index = 0; tile_index < atlas_source->get_tiles_count(); tile_index++) { + Vector2i tile_id = atlas_source->get_tile_id(tile_index); + atlas_size = atlas_size.max(tile_id + atlas_source->get_tile_size_in_atlas(tile_id)); + + Rect2i new_tile_rect_in_altas = Rect2i(atlas_offset + tile_id, atlas_source->get_tile_size_in_atlas(tile_id)); + + // Create tiles and alternatives, then copy their properties. + for (int alternative_index = 0; alternative_index < atlas_source->get_alternative_tiles_count(tile_id); alternative_index++) { + int alternative_id = atlas_source->get_alternative_tile_id(tile_id, alternative_index); + if (alternative_id == 0) { + merged->create_tile(new_tile_rect_in_altas.position, new_tile_rect_in_altas.size); + } else { + merged->create_alternative_tile(new_tile_rect_in_altas.position, alternative_index); + } + + // Copy the properties. + TileData *original_tile_data = Object::cast_to<TileData>(atlas_source->get_tile_data(tile_id, alternative_id)); + List<PropertyInfo> properties; + original_tile_data->get_property_list(&properties); + for (List<PropertyInfo>::Element *E = properties.front(); E; E = E->next()) { + const StringName &property_name = E->get().name; + merged->set(property_name, original_tile_data->get(property_name)); + } + + // Add to the mapping. + merged_mapping[source_index][tile_id] = new_tile_rect_in_altas.position; + } + + // Copy the texture. + Rect2i src_rect = atlas_source->get_tile_texture_region(tile_id); + Rect2 dst_rect_wide = Rect2i(new_tile_rect_in_altas.position * new_texture_region_size, new_tile_rect_in_altas.size * new_texture_region_size); + if (dst_rect_wide.get_end().x > output_image->get_width() || dst_rect_wide.get_end().y > output_image->get_height()) { + output_image->crop(MAX(dst_rect_wide.get_end().x, output_image->get_width()), MAX(dst_rect_wide.get_end().y, output_image->get_height())); + } + output_image->blit_rect(atlas_source->get_texture()->get_image(), src_rect, (dst_rect_wide.get_position() + dst_rect_wide.get_end()) / 2 - src_rect.size / 2); + } + + // Compute the atlas offset. + line_height = MAX(atlas_size.y, line_height); + atlas_offset.x += atlas_size.x; + if (atlas_offset.x >= p_max_columns) { + atlas_offset.x = 0; + atlas_offset.y += line_height; + line_height = 0; + } + } + + Ref<ImageTexture> output_image_texture; + output_image_texture.instantiate(); + output_image_texture->create_from_image(output_image); + + merged->set_texture(output_image_texture); + merged->set_texture_region_size(new_texture_region_size); + } +} + +void AtlasMergingDialog::_update_texture() { + Vector<int> selected = atlas_merging_atlases_list->get_selected_items(); + if (selected.size() >= 2) { + Vector<Ref<TileSetAtlasSource>> to_merge; + for (int i = 0; i < selected.size(); i++) { + int source_id = atlas_merging_atlases_list->get_item_metadata(selected[i]); + to_merge.push_back(tile_set->get_source(source_id)); + } + _generate_merged(to_merge, next_line_after_column); + preview->set_texture(merged->get_texture()); + preview->show(); + select_2_atlases_label->hide(); + get_ok_button()->set_disabled(false); + merge_button->set_disabled(false); + } else { + _generate_merged(Vector<Ref<TileSetAtlasSource>>(), next_line_after_column); + preview->set_texture(Ref<Texture2D>()); + preview->hide(); + select_2_atlases_label->show(); + get_ok_button()->set_disabled(true); + merge_button->set_disabled(true); + } +} + +void AtlasMergingDialog::_merge_confirmed(String p_path) { + ERR_FAIL_COND(!merged.is_valid()); + + Ref<ImageTexture> output_image_texture = merged->get_texture(); + output_image_texture->get_image()->save_png(p_path); + + Ref<Texture2D> new_texture_resource = ResourceLoader::load(p_path, "Texture2D"); + merged->set_texture(new_texture_resource); + + undo_redo->create_action(TTR("Merge TileSetAtlasSource")); + int next_id = tile_set->get_next_source_id(); + undo_redo->add_do_method(*tile_set, "add_source", merged, next_id); + undo_redo->add_undo_method(*tile_set, "remove_source", next_id); + + if (delete_original_atlases) { + // Delete originals if needed. + Vector<int> selected = atlas_merging_atlases_list->get_selected_items(); + for (int i = 0; i < selected.size(); i++) { + int source_id = atlas_merging_atlases_list->get_item_metadata(selected[i]); + Ref<TileSetAtlasSource> tas = tile_set->get_source(source_id); + undo_redo->add_do_method(*tile_set, "remove_source", source_id); + undo_redo->add_undo_method(*tile_set, "add_source", tas, source_id); + + // Add the tile proxies. + for (int tile_index = 0; tile_index < tas->get_tiles_count(); tile_index++) { + Vector2i tile_id = tas->get_tile_id(tile_index); + undo_redo->add_do_method(*tile_set, "set_coords_level_tile_proxy", source_id, tile_id, next_id, merged_mapping[i][tile_id]); + if (tile_set->has_coords_level_tile_proxy(source_id, tile_id)) { + Array a = tile_set->get_coords_level_tile_proxy(source_id, tile_id); + undo_redo->add_undo_method(*tile_set, "set_coords_level_tile_proxy", a[0], a[1]); + } else { + undo_redo->add_undo_method(*tile_set, "remove_coords_level_tile_proxy", source_id, tile_id); + } + } + } + } + undo_redo->commit_action(); + commited_actions_count++; + + hide(); +} + +void AtlasMergingDialog::ok_pressed() { + delete_original_atlases = false; + editor_file_dialog->popup_file_dialog(); +} + +void AtlasMergingDialog::cancel_pressed() { + for (int i = 0; i < commited_actions_count; i++) { + undo_redo->undo(); + } + commited_actions_count = 0; +} + +void AtlasMergingDialog::custom_action(const String &p_action) { + if (p_action == "merge") { + delete_original_atlases = true; + editor_file_dialog->popup_file_dialog(); + } +} + +bool AtlasMergingDialog::_set(const StringName &p_name, const Variant &p_value) { + if (p_name == "next_line_after_column" && p_value.get_type() == Variant::INT) { + next_line_after_column = p_value; + _update_texture(); + return true; + } + return false; +} + +bool AtlasMergingDialog::_get(const StringName &p_name, Variant &r_ret) const { + if (p_name == "next_line_after_column") { + r_ret = next_line_after_column; + return true; + } + return false; +} + +void AtlasMergingDialog::update_tile_set(Ref<TileSet> p_tile_set) { + ERR_FAIL_COND(!p_tile_set.is_valid()); + tile_set = p_tile_set; + + atlas_merging_atlases_list->clear(); + for (int i = 0; i < p_tile_set->get_source_count(); i++) { + int source_id = p_tile_set->get_source_id(i); + Ref<TileSetAtlasSource> atlas_source = p_tile_set->get_source(source_id); + if (atlas_source.is_valid()) { + Ref<Texture2D> texture = atlas_source->get_texture(); + if (texture.is_valid()) { + String item_text = vformat("%s (id:%d)", texture->get_path().get_file(), source_id); + atlas_merging_atlases_list->add_item(item_text, texture); + atlas_merging_atlases_list->set_item_metadata(atlas_merging_atlases_list->get_item_count() - 1, source_id); + } + } + } + + get_ok_button()->set_disabled(true); + merge_button->set_disabled(true); + + commited_actions_count = 0; +} + +AtlasMergingDialog::AtlasMergingDialog() { + // Atlas merging window. + set_title(TTR("Atlas Merging")); + set_hide_on_ok(false); + + // Ok buttons + get_ok_button()->set_text(TTR("Merge (Keep original Atlases)")); + get_ok_button()->set_disabled(true); + merge_button = add_button(TTR("Merge"), true, "merge"); + merge_button->set_disabled(true); + + HSplitContainer *atlas_merging_h_split_container = memnew(HSplitContainer); + atlas_merging_h_split_container->set_h_size_flags(Control::SIZE_EXPAND_FILL); + atlas_merging_h_split_container->set_v_size_flags(Control::SIZE_EXPAND_FILL); + add_child(atlas_merging_h_split_container); + + // Atlas sources item list. + atlas_merging_atlases_list = memnew(ItemList); + atlas_merging_atlases_list->set_fixed_icon_size(Size2i(60, 60) * EDSCALE); + atlas_merging_atlases_list->set_h_size_flags(Control::SIZE_EXPAND_FILL); + atlas_merging_atlases_list->set_v_size_flags(Control::SIZE_EXPAND_FILL); + atlas_merging_atlases_list->set_texture_filter(CanvasItem::TEXTURE_FILTER_NEAREST); + atlas_merging_atlases_list->set_custom_minimum_size(Size2(100, 200)); + atlas_merging_atlases_list->set_select_mode(ItemList::SELECT_MULTI); + atlas_merging_atlases_list->connect("multi_selected", callable_mp(this, &AtlasMergingDialog::_update_texture).unbind(2)); + atlas_merging_h_split_container->add_child(atlas_merging_atlases_list); + + VBoxContainer *atlas_merging_right_panel = memnew(VBoxContainer); + atlas_merging_right_panel->set_h_size_flags(Control::SIZE_EXPAND_FILL); + atlas_merging_h_split_container->add_child(atlas_merging_right_panel); + + // Settings. + Label *settings_label = memnew(Label); + settings_label->set_text(TTR("Settings:")); + atlas_merging_right_panel->add_child(settings_label); + + columns_editor_property = memnew(EditorPropertyInteger); + columns_editor_property->set_label(TTR("Next Line After Column")); + columns_editor_property->set_object_and_property(this, "next_line_after_column"); + columns_editor_property->update_property(); + columns_editor_property->connect("property_changed", callable_mp(this, &AtlasMergingDialog::_property_changed)); + atlas_merging_right_panel->add_child(columns_editor_property); + + // Preview. + Label *preview_label = memnew(Label); + preview_label->set_text(TTR("Preview:")); + atlas_merging_right_panel->add_child(preview_label); + + preview = memnew(TextureRect); + preview->set_h_size_flags(Control::SIZE_EXPAND_FILL); + preview->set_v_size_flags(Control::SIZE_EXPAND_FILL); + preview->set_expand(true); + preview->hide(); + preview->set_stretch_mode(TextureRect::STRETCH_KEEP_ASPECT_CENTERED); + atlas_merging_right_panel->add_child(preview); + + select_2_atlases_label = memnew(Label); + select_2_atlases_label->set_h_size_flags(Control::SIZE_EXPAND_FILL); + select_2_atlases_label->set_v_size_flags(Control::SIZE_EXPAND_FILL); + select_2_atlases_label->set_align(Label::ALIGN_CENTER); + select_2_atlases_label->set_valign(Label::VALIGN_CENTER); + select_2_atlases_label->set_text(TTR("Please select two atlases or more.")); + atlas_merging_right_panel->add_child(select_2_atlases_label); + + // The file dialog to choose the texture path. + editor_file_dialog = memnew(EditorFileDialog); + editor_file_dialog->set_file_mode(EditorFileDialog::FILE_MODE_SAVE_FILE); + editor_file_dialog->add_filter("*.png"); + editor_file_dialog->connect("file_selected", callable_mp(this, &AtlasMergingDialog::_merge_confirmed)); + add_child(editor_file_dialog); +} diff --git a/editor/plugins/tiles/atlas_merging_dialog.h b/editor/plugins/tiles/atlas_merging_dialog.h new file mode 100644 index 0000000000..7cb54bc17e --- /dev/null +++ b/editor/plugins/tiles/atlas_merging_dialog.h @@ -0,0 +1,86 @@ +/*************************************************************************/ +/* atlas_merging_dialog.h */ +/*************************************************************************/ +/* This file is part of: */ +/* GODOT ENGINE */ +/* https://godotengine.org */ +/*************************************************************************/ +/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2021 Godot Engine contributors (cf. AUTHORS.md). */ +/* */ +/* 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 ATLAS_MERGING_DIALOG_H +#define ATLAS_MERGING_DIALOG_H + +#include "editor/editor_node.h" +#include "editor/editor_properties.h" + +#include "scene/gui/dialogs.h" +#include "scene/gui/item_list.h" +#include "scene/gui/texture_rect.h" +#include "scene/resources/tile_set.h" + +class AtlasMergingDialog : public ConfirmationDialog { + GDCLASS(AtlasMergingDialog, ConfirmationDialog); + +private: + int commited_actions_count = 0; + bool delete_original_atlases = true; + Ref<TileSetAtlasSource> merged; + LocalVector<Map<Vector2i, Vector2i>> merged_mapping; + Ref<TileSet> tile_set; + + UndoRedo *undo_redo = EditorNode::get_singleton()->get_undo_redo(); + + // Settings. + int next_line_after_column = 30; + + // GUI. + ItemList *atlas_merging_atlases_list; + EditorPropertyVector2i *texture_region_size_editor_property; + EditorPropertyInteger *columns_editor_property; + TextureRect *preview; + Label *select_2_atlases_label; + EditorFileDialog *editor_file_dialog; + Button *merge_button; + + void _property_changed(const StringName &p_property, const Variant &p_value, const String &p_field, bool p_changing); + + void _generate_merged(Vector<Ref<TileSetAtlasSource>> p_atlas_sources, int p_max_columns); + void _update_texture(); + void _merge_confirmed(String p_path); + +protected: + virtual void ok_pressed() override; + virtual void cancel_pressed() override; + virtual void custom_action(const String &) override; + + bool _set(const StringName &p_name, const Variant &p_value); + bool _get(const StringName &p_name, Variant &r_ret) const; + +public: + void update_tile_set(Ref<TileSet> p_tile_set); + + AtlasMergingDialog(); +}; + +#endif // ATLAS_MERGING_DIALOG_H diff --git a/editor/plugins/tiles/tile_atlas_view.cpp b/editor/plugins/tiles/tile_atlas_view.cpp index 374a255df3..84e40e2ffa 100644 --- a/editor/plugins/tiles/tile_atlas_view.cpp +++ b/editor/plugins/tiles/tile_atlas_view.cpp @@ -41,25 +41,31 @@ #include "editor/editor_settings.h" void TileAtlasView::_gui_input(const Ref<InputEvent> &p_event) { - bool ctrl = Input::get_singleton()->is_key_pressed(KEY_CTRL); - Ref<InputEventMouseButton> mb = p_event; if (mb.is_valid()) { drag_type = DRAG_TYPE_NONE; - if (ctrl && mb->is_pressed() && mb->get_button_index() == MOUSE_BUTTON_WHEEL_DOWN) { - // Zoom out - zoom_widget->set_zoom_by_increments(-2); - emit_signal("transform_changed", zoom_widget->get_zoom(), panning); - _update_zoom_and_panning(true); - accept_event(); - } - if (ctrl && mb->is_pressed() && mb->get_button_index() == MOUSE_BUTTON_WHEEL_UP) { - // Zoom in - zoom_widget->set_zoom_by_increments(2); - emit_signal("transform_changed", zoom_widget->get_zoom(), panning); - _update_zoom_and_panning(true); - accept_event(); + Vector2i scroll_vec = Vector2((mb->get_button_index() == MOUSE_BUTTON_WHEEL_LEFT) - (mb->get_button_index() == MOUSE_BUTTON_WHEEL_RIGHT), (mb->get_button_index() == MOUSE_BUTTON_WHEEL_UP) - (mb->get_button_index() == MOUSE_BUTTON_WHEEL_DOWN)); + if (scroll_vec != Vector2()) { + if (mb->is_ctrl_pressed()) { + if (mb->is_shift_pressed()) { + panning.x += 32 * mb->get_factor() * scroll_vec.y; + panning.y += 32 * mb->get_factor() * scroll_vec.x; + } else { + panning.y += 32 * mb->get_factor() * scroll_vec.y; + panning.x += 32 * mb->get_factor() * scroll_vec.x; + } + + emit_signal(SNAME("transform_changed"), zoom_widget->get_zoom(), panning); + _update_zoom_and_panning(true); + accept_event(); + + } else if (!mb->is_shift_pressed()) { + zoom_widget->set_zoom_by_increments(scroll_vec.y * 2); + emit_signal(SNAME("transform_changed"), zoom_widget->get_zoom(), panning); + _update_zoom_and_panning(true); + accept_event(); + } } if (mb->get_button_index() == MOUSE_BUTTON_MIDDLE || mb->get_button_index() == MOUSE_BUTTON_RIGHT) { @@ -77,7 +83,7 @@ void TileAtlasView::_gui_input(const Ref<InputEvent> &p_event) { if (drag_type == DRAG_TYPE_PAN) { panning += mm->get_relative(); _update_zoom_and_panning(); - emit_signal("transform_changed", zoom_widget->get_zoom(), panning); + emit_signal(SNAME("transform_changed"), zoom_widget->get_zoom(), panning); accept_event(); } } @@ -176,14 +182,14 @@ void TileAtlasView::_update_zoom_and_panning(bool p_zoom_on_mouse_pos) { void TileAtlasView::_zoom_widget_changed() { _update_zoom_and_panning(); - emit_signal("transform_changed", zoom_widget->get_zoom(), panning); + emit_signal(SNAME("transform_changed"), zoom_widget->get_zoom(), panning); } void TileAtlasView::_center_view() { panning = Vector2(); button_center_view->set_disabled(true); _update_zoom_and_panning(); - emit_signal("transform_changed", zoom_widget->get_zoom(), panning); + emit_signal(SNAME("transform_changed"), zoom_widget->get_zoom(), panning); } void TileAtlasView::_base_tiles_root_control_gui_input(const Ref<InputEvent> &p_event) { @@ -382,13 +388,13 @@ void TileAtlasView::_draw_alternatives() { } void TileAtlasView::_draw_background_left() { - Ref<Texture2D> texture = get_theme_icon("Checkerboard", "EditorIcons"); + Ref<Texture2D> texture = get_theme_icon(SNAME("Checkerboard"), SNAME("EditorIcons")); background_left->set_size(base_tiles_root_control->get_custom_minimum_size()); background_left->draw_texture_rect(texture, Rect2(Vector2(), background_left->get_size()), true); } void TileAtlasView::_draw_background_right() { - Ref<Texture2D> texture = get_theme_icon("Checkerboard", "EditorIcons"); + Ref<Texture2D> texture = get_theme_icon(SNAME("Checkerboard"), SNAME("EditorIcons")); background_right->set_size(alternative_tiles_root_control->get_custom_minimum_size()); background_right->draw_texture_rect(texture, Rect2(Vector2(), background_right->get_size()), true); } @@ -535,7 +541,7 @@ void TileAtlasView::update() { void TileAtlasView::_notification(int p_what) { switch (p_what) { case NOTIFICATION_READY: - button_center_view->set_icon(get_theme_icon("CenterView", "EditorIcons")); + button_center_view->set_icon(get_theme_icon(SNAME("CenterView"), SNAME("EditorIcons"))); break; } } @@ -564,11 +570,12 @@ TileAtlasView::TileAtlasView() { zoom_widget->connect("zoom_changed", callable_mp(this, &TileAtlasView::_zoom_widget_changed).unbind(1)); button_center_view = memnew(Button); - button_center_view->set_icon(get_theme_icon("CenterView", "EditorIcons")); + button_center_view->set_icon(get_theme_icon(SNAME("CenterView"), SNAME("EditorIcons"))); button_center_view->set_anchors_and_offsets_preset(Control::PRESET_TOP_RIGHT, Control::PRESET_MODE_MINSIZE, 5); button_center_view->connect("pressed", callable_mp(this, &TileAtlasView::_center_view)); button_center_view->set_flat(true); button_center_view->set_disabled(true); + button_center_view->set_tooltip(TTR("Center View")); add_child(button_center_view); center_container = memnew(CenterContainer); diff --git a/editor/plugins/tiles/tile_atlas_view.h b/editor/plugins/tiles/tile_atlas_view.h index bafc2b3985..b2046f4322 100644 --- a/editor/plugins/tiles/tile_atlas_view.h +++ b/editor/plugins/tiles/tile_atlas_view.h @@ -47,7 +47,7 @@ class TileAtlasView : public Control { private: TileSet *tile_set; TileSetAtlasSource *tile_set_atlas_source; - int source_id = -1; + int source_id = TileSet::INVALID_SOURCE; enum DragType { DRAG_TYPE_NONE, diff --git a/editor/plugins/tiles/tile_data_editors.cpp b/editor/plugins/tiles/tile_data_editors.cpp index d9d0e48fb3..bab55df65a 100644 --- a/editor/plugins/tiles/tile_data_editors.cpp +++ b/editor/plugins/tiles/tile_data_editors.cpp @@ -113,8 +113,8 @@ void GenericTilePolygonEditor::_base_control_draw() { real_t grab_threshold = EDITOR_GET("editors/poly_editor/point_grab_radius"); Color grid_color = EditorSettings::get_singleton()->get("editors/tiles_editor/grid_color"); - const Ref<Texture2D> handle = get_theme_icon("EditorPathSharpHandle", "EditorIcons"); - const Ref<Texture2D> add_handle = get_theme_icon("EditorHandleAdd", "EditorIcons"); + const Ref<Texture2D> handle = get_theme_icon(SNAME("EditorPathSharpHandle"), SNAME("EditorIcons")); + const Ref<Texture2D> add_handle = get_theme_icon(SNAME("EditorHandleAdd"), SNAME("EditorIcons")); Size2 tile_size = tile_set->get_tile_size(); @@ -195,8 +195,8 @@ void GenericTilePolygonEditor::_base_control_draw() { // Draw the text on top of the selected point. if (tinted_polygon_index >= 0) { - Ref<Font> font = get_theme_font("font", "Label"); - int font_size = get_theme_font_size("font_size", "Label"); + Ref<Font> font = get_theme_font(SNAME("font"), SNAME("Label")); + int font_size = get_theme_font_size(SNAME("font_size"), SNAME("Label")); String text = multiple_polygon_mode ? vformat("%d:%d", tinted_polygon_index, tinted_point_index) : vformat("%d", tinted_point_index); Size2 text_size = font->get_string_size(text, font_size); base_control->draw_string(font, xform.xform(polygons[tinted_polygon_index][tinted_point_index]) - text_size * 0.5, text, HALIGN_LEFT, -1, font_size, Color(1.0, 1.0, 1.0, 0.5)); @@ -413,7 +413,7 @@ void GenericTilePolygonEditor::_base_control_gui_input(Ref<InputEvent> p_event) undo_redo->add_undo_method(this, "remove_polygon", added); undo_redo->add_undo_method(base_control, "update"); undo_redo->commit_action(false); - emit_signal("polygons_changed"); + emit_signal(SNAME("polygons_changed")); } else { // Create a new point. drag_type = DRAG_TYPE_CREATE_POINT; @@ -460,7 +460,7 @@ void GenericTilePolygonEditor::_base_control_gui_input(Ref<InputEvent> p_event) undo_redo->add_do_method(base_control, "update"); undo_redo->add_undo_method(base_control, "update"); undo_redo->commit_action(false); - emit_signal("polygons_changed"); + emit_signal(SNAME("polygons_changed")); } } } else { @@ -471,7 +471,7 @@ void GenericTilePolygonEditor::_base_control_gui_input(Ref<InputEvent> p_event) undo_redo->add_undo_method(this, "set_polygon", drag_polygon_index, drag_old_polygon); undo_redo->add_undo_method(base_control, "update"); undo_redo->commit_action(false); - emit_signal("polygons_changed"); + emit_signal(SNAME("polygons_changed")); } else if (drag_type == DRAG_TYPE_CREATE_POINT) { Point2 point = xform.affine_inverse().xform(mb->get_position()); float distance = grab_threshold * 2; @@ -507,7 +507,7 @@ void GenericTilePolygonEditor::_base_control_gui_input(Ref<InputEvent> p_event) undo_redo->add_do_method(base_control, "update"); undo_redo->add_undo_method(base_control, "update"); undo_redo->commit_action(false); - emit_signal("polygons_changed"); + emit_signal(SNAME("polygons_changed")); } else { drag_type = DRAG_TYPE_PAN; drag_last_pos = mb->get_position(); @@ -615,12 +615,12 @@ void GenericTilePolygonEditor::set_multiple_polygon_mode(bool p_multiple_polygon void GenericTilePolygonEditor::_notification(int p_what) { switch (p_what) { case NOTIFICATION_READY: - button_create->set_icon(EditorNode::get_singleton()->get_gui_base()->get_theme_icon("CurveCreate", "EditorIcons")); - button_edit->set_icon(EditorNode::get_singleton()->get_gui_base()->get_theme_icon("CurveEdit", "EditorIcons")); - button_delete->set_icon(EditorNode::get_singleton()->get_gui_base()->get_theme_icon("CurveDelete", "EditorIcons")); - button_center_view->set_icon(EditorNode::get_singleton()->get_gui_base()->get_theme_icon("CenterView", "EditorIcons")); - button_pixel_snap->set_icon(EditorNode::get_singleton()->get_gui_base()->get_theme_icon("Snap", "EditorIcons")); - button_advanced_menu->set_icon(EditorNode::get_singleton()->get_gui_base()->get_theme_icon("GuiTabMenu", "EditorIcons")); + button_create->set_icon(EditorNode::get_singleton()->get_gui_base()->get_theme_icon(SNAME("CurveCreate"), SNAME("EditorIcons"))); + button_edit->set_icon(EditorNode::get_singleton()->get_gui_base()->get_theme_icon(SNAME("CurveEdit"), SNAME("EditorIcons"))); + button_delete->set_icon(EditorNode::get_singleton()->get_gui_base()->get_theme_icon(SNAME("CurveDelete"), SNAME("EditorIcons"))); + button_center_view->set_icon(EditorNode::get_singleton()->get_gui_base()->get_theme_icon(SNAME("CenterView"), SNAME("EditorIcons"))); + button_pixel_snap->set_icon(EditorNode::get_singleton()->get_gui_base()->get_theme_icon(SNAME("Snap"), SNAME("EditorIcons"))); + button_advanced_menu->set_icon(EditorNode::get_singleton()->get_gui_base()->get_theme_icon(SNAME("GuiTabMenu"), SNAME("EditorIcons"))); break; } } @@ -702,7 +702,7 @@ GenericTilePolygonEditor::GenericTilePolygonEditor() { root->add_child(editor_zoom_widget); button_center_view = memnew(Button); - button_center_view->set_icon(EditorNode::get_singleton()->get_gui_base()->get_theme_icon("CenterView", "EditorIcons")); + button_center_view->set_icon(EditorNode::get_singleton()->get_gui_base()->get_theme_icon(SNAME("CenterView"), SNAME("EditorIcons"))); button_center_view->set_anchors_and_offsets_preset(Control::PRESET_TOP_RIGHT, Control::PRESET_MODE_MINSIZE, 5); button_center_view->connect("pressed", callable_mp(this, &GenericTilePolygonEditor::_center_view)); button_center_view->set_flat(true); @@ -963,7 +963,7 @@ void TileDataDefaultEditor::draw_over_tile(CanvasItem *p_canvas_item, Transform2 Rect2 rect = p_transform.xform(Rect2(Vector2(-size / 2, -size / 2), Vector2(size, size))); p_canvas_item->draw_rect(rect, value); } else { - Ref<Font> font = TileSetEditor::get_singleton()->get_theme_font("bold", "EditorFonts"); + Ref<Font> font = TileSetEditor::get_singleton()->get_theme_font(SNAME("bold"), SNAME("EditorFonts")); String text; switch (value.get_type()) { case Variant::INT: @@ -1039,9 +1039,9 @@ void TileDataDefaultEditor::_notification(int p_what) { switch (p_what) { case NOTIFICATION_ENTER_TREE: case NOTIFICATION_THEME_CHANGED: - picker_button->set_icon(get_theme_icon("ColorPick", "EditorIcons")); - tile_bool_checked = get_theme_icon("TileChecked", "EditorIcons"); - tile_bool_unchecked = get_theme_icon("TileUnchecked", "EditorIcons"); + picker_button->set_icon(get_theme_icon(SNAME("ColorPick"), SNAME("EditorIcons"))); + tile_bool_checked = get_theme_icon(SNAME("TileChecked"), SNAME("EditorIcons")); + tile_bool_unchecked = get_theme_icon(SNAME("TileUnchecked"), SNAME("EditorIcons")); break; default: break; @@ -1050,7 +1050,7 @@ void TileDataDefaultEditor::_notification(int p_what) { TileDataDefaultEditor::TileDataDefaultEditor() { label = memnew(Label); - label->set_text("Painting:"); + label->set_text(TTR("Painting:")); add_child(label); toolbar->add_child(memnew(VSeparator)); @@ -1099,7 +1099,7 @@ void TileDataPositionEditor::draw_over_tile(CanvasItem *p_canvas_item, Transform Color selection_color = Color().from_hsv(Math::fposmod(grid_color.get_h() + 0.5, 1.0), grid_color.get_s(), grid_color.get_v(), 1.0); color = selection_color; } - Ref<Texture2D> position_icon = TileSetEditor::get_singleton()->get_theme_icon("EditorPosition", "EditorIcons"); + Ref<Texture2D> position_icon = TileSetEditor::get_singleton()->get_theme_icon(SNAME("EditorPosition"), SNAME("EditorIcons")); p_canvas_item->draw_texture(position_icon, p_transform.xform(Vector2(value)) - position_icon->get_size() / 2, color); } @@ -1113,7 +1113,7 @@ void TileDataYSortEditor::draw_over_tile(CanvasItem *p_canvas_item, Transform2D Color selection_color = Color().from_hsv(Math::fposmod(grid_color.get_h() + 0.5, 1.0), grid_color.get_s(), grid_color.get_v(), 1.0); color = selection_color; } - Ref<Texture2D> position_icon = TileSetEditor::get_singleton()->get_theme_icon("EditorPosition", "EditorIcons"); + Ref<Texture2D> position_icon = TileSetEditor::get_singleton()->get_theme_icon(SNAME("EditorPosition"), SNAME("EditorIcons")); p_canvas_item->draw_texture(position_icon, p_transform.xform(Vector2(0, tile_data->get_y_sort_origin())) - position_icon->get_size() / 2, color); } @@ -1244,7 +1244,7 @@ void TileDataCollisionEditor::_polygons_changed() { } } - // Remove uneeded properties and their editors. + // Remove unneeded properties and their editors. for (int i = polygon_editor->get_polygon_count(); dummy_object->has_dummy_property(vformat("polygon_%d_one_way", i)); i++) { dummy_object->remove_dummy_property(vformat("polygon_%d_one_way", i)); } @@ -1458,7 +1458,7 @@ void TileDataTerrainsEditor::_property_value_changed(StringName p_property, Vari } _update_terrain_selector(); } - emit_signal("needs_redraw"); + emit_signal(SNAME("needs_redraw")); } void TileDataTerrainsEditor::_tile_set_changed() { @@ -1521,7 +1521,7 @@ void TileDataTerrainsEditor::forward_draw_over_atlas(TileAtlasView *p_tile_atlas } // Dim terrains with wrong terrain set. - Ref<Font> font = TileSetEditor::get_singleton()->get_theme_font("bold", "EditorFonts"); + Ref<Font> font = TileSetEditor::get_singleton()->get_theme_font(SNAME("bold"), SNAME("EditorFonts")); for (int i = 0; i < p_tile_set_atlas_source->get_tiles_count(); i++) { Vector2i coords = p_tile_set_atlas_source->get_tile_id(i); if (coords != hovered_coords) { @@ -1693,7 +1693,7 @@ void TileDataTerrainsEditor::forward_draw_over_alternatives(TileAtlasView *p_til } // Dim terrains with wrong terrain set. - Ref<Font> font = TileSetEditor::get_singleton()->get_theme_font("bold", "EditorFonts"); + Ref<Font> font = TileSetEditor::get_singleton()->get_theme_font(SNAME("bold"), SNAME("EditorFonts")); for (int i = 0; i < p_tile_set_atlas_source->get_tiles_count(); i++) { Vector2i coords = p_tile_set_atlas_source->get_tile_id(i); for (int j = 1; j < p_tile_set_atlas_source->get_alternative_tiles_count(coords); j++) { @@ -2303,7 +2303,7 @@ void TileDataTerrainsEditor::_notification(int p_what) { switch (p_what) { case NOTIFICATION_ENTER_TREE: case NOTIFICATION_THEME_CHANGED: - picker_button->set_icon(get_theme_icon("ColorPick", "EditorIcons")); + picker_button->set_icon(get_theme_icon(SNAME("ColorPick"), SNAME("EditorIcons"))); break; default: break; diff --git a/editor/plugins/tiles/tile_map_editor.cpp b/editor/plugins/tiles/tile_map_editor.cpp index 86bd115ac2..e70aed8ed6 100644 --- a/editor/plugins/tiles/tile_map_editor.cpp +++ b/editor/plugins/tiles/tile_map_editor.cpp @@ -47,27 +47,20 @@ void TileMapEditorTilesPlugin::_notification(int p_what) { switch (p_what) { case NOTIFICATION_ENTER_TREE: case NOTIFICATION_THEME_CHANGED: - select_tool_button->set_icon(get_theme_icon("ToolSelect", "EditorIcons")); - paint_tool_button->set_icon(get_theme_icon("Edit", "EditorIcons")); - line_tool_button->set_icon(get_theme_icon("CurveLinear", "EditorIcons")); - rect_tool_button->set_icon(get_theme_icon("Rectangle", "EditorIcons")); - bucket_tool_button->set_icon(get_theme_icon("Bucket", "EditorIcons")); + select_tool_button->set_icon(get_theme_icon(SNAME("ToolSelect"), SNAME("EditorIcons"))); + paint_tool_button->set_icon(get_theme_icon(SNAME("Edit"), SNAME("EditorIcons"))); + line_tool_button->set_icon(get_theme_icon(SNAME("CurveLinear"), SNAME("EditorIcons"))); + rect_tool_button->set_icon(get_theme_icon(SNAME("Rectangle"), SNAME("EditorIcons"))); + bucket_tool_button->set_icon(get_theme_icon(SNAME("Bucket"), SNAME("EditorIcons"))); - picker_button->set_icon(get_theme_icon("ColorPick", "EditorIcons")); - erase_button->set_icon(get_theme_icon("Eraser", "EditorIcons")); + picker_button->set_icon(get_theme_icon(SNAME("ColorPick"), SNAME("EditorIcons"))); + erase_button->set_icon(get_theme_icon(SNAME("Eraser"), SNAME("EditorIcons"))); - toggle_grid_button->set_icon(get_theme_icon("Grid", "EditorIcons")); - - missing_atlas_texture_icon = get_theme_icon("TileSet", "EditorIcons"); - - toggle_grid_button->set_pressed(EditorSettings::get_singleton()->get("editors/tiles_editor/display_grid")); + missing_atlas_texture_icon = get_theme_icon(SNAME("TileSet"), SNAME("EditorIcons")); break; case NOTIFICATION_VISIBILITY_CHANGED: _stop_dragging(); break; - case EditorSettings::NOTIFICATION_EDITOR_SETTINGS_CHANGED: - toggle_grid_button->set_pressed(EditorSettings::get_singleton()->get("editors/tiles_editor/display_grid")); - break; } } @@ -85,10 +78,6 @@ void TileMapEditorTilesPlugin::_on_scattering_spinbox_changed(double p_value) { scattering = p_value; } -void TileMapEditorTilesPlugin::_on_grid_toggled(bool p_pressed) { - EditorSettings::get_singleton()->set("editors/tiles_editor/display_grid", p_pressed); -} - void TileMapEditorTilesPlugin::_update_toolbar() { // Stop draggig if needed. _stop_dragging(); @@ -168,22 +157,22 @@ void TileMapEditorTilesPlugin::_update_tile_set_sources_list() { if (atlas_source) { texture = atlas_source->get_texture(); if (texture.is_valid()) { - item_text = vformat("%s (id:%d)", texture->get_path().get_file(), source_id); + item_text = vformat("%s (ID: %d)", texture->get_path().get_file(), source_id); } else { - item_text = vformat("No Texture Atlas Source (id:%d)", source_id); + item_text = vformat("No Texture Atlas Source (ID: %d)", source_id); } } // Scene collection source. TileSetScenesCollectionSource *scene_collection_source = Object::cast_to<TileSetScenesCollectionSource>(source); if (scene_collection_source) { - texture = get_theme_icon("PackedScene", "EditorIcons"); - item_text = vformat(TTR("Scene Collection Source (id:%d)"), source_id); + texture = get_theme_icon(SNAME("PackedScene"), SNAME("EditorIcons")); + item_text = vformat(TTR("Scene Collection Source (ID: %d)"), source_id); } // Use default if not valid. if (item_text.is_empty()) { - item_text = vformat(TTR("Unknown Type Source (id:%d)"), source_id); + item_text = vformat(TTR("Unknown Type Source (ID: %d)"), source_id); } if (!texture.is_valid()) { texture = missing_atlas_texture_icon; @@ -200,11 +189,11 @@ void TileMapEditorTilesPlugin::_update_tile_set_sources_list() { } else { sources_list->set_current(0); } - sources_list->emit_signal("item_selected", sources_list->get_current()); + sources_list->emit_signal(SNAME("item_selected"), sources_list->get_current()); } // Synchronize - TilesEditor::get_singleton()->set_atlas_sources_lists_current(sources_list->get_current()); + TilesEditor::get_singleton()->set_sources_lists_current(sources_list->get_current()); } void TileMapEditorTilesPlugin::_update_bottom_panel() { @@ -302,11 +291,11 @@ void TileMapEditorTilesPlugin::_update_scenes_collection_view() { int item_index = 0; if (scene.is_valid()) { - item_index = scene_tiles_list->add_item(vformat("%s (path:%s id:%d)", scene->get_path().get_file().get_basename(), scene->get_path(), scene_id)); + item_index = scene_tiles_list->add_item(vformat("%s (Path: %s, ID: %d)", scene->get_path().get_file().get_basename(), scene->get_path(), scene_id)); Variant udata = i; EditorResourcePreview::get_singleton()->queue_edited_resource_preview(scene, this, "_scene_thumbnail_done", udata); } else { - item_index = scene_tiles_list->add_item(TTR("Tile with Invalid Scene"), get_theme_icon("PackedScene", "EditorIcons")); + item_index = scene_tiles_list->add_item(TTR("Tile with Invalid Scene"), get_theme_icon(SNAME("PackedScene"), SNAME("EditorIcons"))); } scene_tiles_list->set_item_metadata(item_index, scene_id); @@ -410,7 +399,7 @@ bool TileMapEditorTilesPlugin::forward_canvas_gui_input(const Ref<InputEvent> &p if (!tile_map_selection.is_empty()) { undo_redo->create_action(TTR("Delete tiles")); for (Set<Vector2i>::Element *E = tile_map_selection.front(); E; E = E->next()) { - undo_redo->add_do_method(tile_map, "set_cell", E->get(), -1, TileSetSource::INVALID_ATLAS_COORDS, TileSetSource::INVALID_TILE_ALTERNATIVE); + undo_redo->add_do_method(tile_map, "set_cell", E->get(), TileSet::INVALID_SOURCE, TileSetSource::INVALID_ATLAS_COORDS, TileSetSource::INVALID_TILE_ALTERNATIVE); undo_redo->add_undo_method(tile_map, "set_cell", E->get(), tile_map->get_cell_source_id(E->get()), tile_map->get_cell_atlas_coords(E->get()), tile_map->get_cell_alternative_tile(E->get())); } undo_redo->add_undo_method(this, "_set_tile_map_selection", _get_tile_map_selection()); @@ -441,7 +430,7 @@ bool TileMapEditorTilesPlugin::forward_canvas_gui_input(const Ref<InputEvent> &p if (!tile_map_selection.is_empty()) { undo_redo->create_action(TTR("Delete tiles")); for (Set<Vector2i>::Element *E = tile_map_selection.front(); E; E = E->next()) { - undo_redo->add_do_method(tile_map, "set_cell", E->get(), -1, TileSetSource::INVALID_ATLAS_COORDS, TileSetSource::INVALID_TILE_ALTERNATIVE); + undo_redo->add_do_method(tile_map, "set_cell", E->get(), TileSet::INVALID_SOURCE, TileSetSource::INVALID_ATLAS_COORDS, TileSetSource::INVALID_TILE_ALTERNATIVE); undo_redo->add_undo_method(tile_map, "set_cell", E->get(), tile_map->get_cell_source_id(E->get()), tile_map->get_cell_atlas_coords(E->get()), tile_map->get_cell_alternative_tile(E->get())); } undo_redo->add_undo_method(this, "_set_tile_map_selection", _get_tile_map_selection()); @@ -462,12 +451,12 @@ bool TileMapEditorTilesPlugin::forward_canvas_gui_input(const Ref<InputEvent> &p case DRAG_TYPE_PAINT: { Map<Vector2i, TileMapCell> to_draw = _draw_line(drag_start_mouse_pos, drag_last_mouse_pos, mpos); for (Map<Vector2i, TileMapCell>::Element *E = to_draw.front(); E; E = E->next()) { - if (!erase_button->is_pressed() && E->get().source_id == -1) { + if (!erase_button->is_pressed() && E->get().source_id == TileSet::INVALID_SOURCE) { continue; } Vector2i coords = E->key(); if (!drag_modified.has(coords)) { - drag_modified.insert(coords, TileMapCell(tile_map->get_cell_source_id(coords), tile_map->get_cell_atlas_coords(coords), tile_map->get_cell_alternative_tile(coords))); + drag_modified.insert(coords, tile_map->get_cell(coords)); } tile_map->set_cell(coords, E->get().source_id, E->get().get_atlas_coords(), E->get().alternative_tile); } @@ -478,12 +467,12 @@ bool TileMapEditorTilesPlugin::forward_canvas_gui_input(const Ref<InputEvent> &p if (!drag_modified.has(line[i])) { Map<Vector2i, TileMapCell> to_draw = _draw_bucket_fill(line[i], bucket_continuous_checkbox->is_pressed()); for (Map<Vector2i, TileMapCell>::Element *E = to_draw.front(); E; E = E->next()) { - if (!erase_button->is_pressed() && E->get().source_id == -1) { + if (!erase_button->is_pressed() && E->get().source_id == TileSet::INVALID_SOURCE) { continue; } Vector2i coords = E->key(); if (!drag_modified.has(coords)) { - drag_modified.insert(coords, TileMapCell(tile_map->get_cell_source_id(coords), tile_map->get_cell_atlas_coords(coords), tile_map->get_cell_alternative_tile(coords))); + drag_modified.insert(coords, tile_map->get_cell(coords)); } tile_map->set_cell(coords, E->get().source_id, E->get().get_atlas_coords(), E->get().alternative_tile); } @@ -516,8 +505,8 @@ bool TileMapEditorTilesPlugin::forward_canvas_gui_input(const Ref<InputEvent> &p drag_modified.clear(); for (Set<Vector2i>::Element *E = tile_map_selection.front(); E; E = E->next()) { Vector2i coords = E->get(); - drag_modified.insert(coords, TileMapCell(tile_map->get_cell_source_id(coords), tile_map->get_cell_atlas_coords(coords), tile_map->get_cell_alternative_tile(coords))); - tile_map->set_cell(coords, -1, TileSetSource::INVALID_ATLAS_COORDS, TileSetSource::INVALID_TILE_ALTERNATIVE); + drag_modified.insert(coords, tile_map->get_cell(coords)); + tile_map->set_cell(coords, TileSet::INVALID_SOURCE, TileSetSource::INVALID_ATLAS_COORDS, TileSetSource::INVALID_TILE_ALTERNATIVE); } } else { // Select tiles @@ -536,12 +525,12 @@ bool TileMapEditorTilesPlugin::forward_canvas_gui_input(const Ref<InputEvent> &p drag_modified.clear(); Map<Vector2i, TileMapCell> to_draw = _draw_line(drag_start_mouse_pos, mpos, mpos); for (Map<Vector2i, TileMapCell>::Element *E = to_draw.front(); E; E = E->next()) { - if (!erase_button->is_pressed() && E->get().source_id == -1) { + if (!erase_button->is_pressed() && E->get().source_id == TileSet::INVALID_SOURCE) { continue; } Vector2i coords = E->key(); if (!drag_modified.has(coords)) { - drag_modified.insert(coords, TileMapCell(tile_map->get_cell_source_id(coords), tile_map->get_cell_atlas_coords(coords), tile_map->get_cell_alternative_tile(coords))); + drag_modified.insert(coords, tile_map->get_cell(coords)); } tile_map->set_cell(coords, E->get().source_id, E->get().get_atlas_coords(), E->get().alternative_tile); } @@ -562,12 +551,12 @@ bool TileMapEditorTilesPlugin::forward_canvas_gui_input(const Ref<InputEvent> &p if (!drag_modified.has(line[i])) { Map<Vector2i, TileMapCell> to_draw = _draw_bucket_fill(line[i], bucket_continuous_checkbox->is_pressed()); for (Map<Vector2i, TileMapCell>::Element *E = to_draw.front(); E; E = E->next()) { - if (!erase_button->is_pressed() && E->get().source_id == -1) { + if (!erase_button->is_pressed() && E->get().source_id == TileSet::INVALID_SOURCE) { continue; } Vector2i coords = E->key(); if (!drag_modified.has(coords)) { - drag_modified.insert(coords, TileMapCell(tile_map->get_cell_source_id(coords), tile_map->get_cell_atlas_coords(coords), tile_map->get_cell_alternative_tile(coords))); + drag_modified.insert(coords, tile_map->get_cell(coords)); } tile_map->set_cell(coords, E->get().source_id, E->get().get_atlas_coords(), E->get().alternative_tile); } @@ -634,7 +623,7 @@ void TileMapEditorTilesPlugin::forward_canvas_draw_over_viewport(Control *p_over for (int x = rect.position.x; x < rect.get_end().x; x++) { for (int y = rect.position.y; y < rect.get_end().y; y++) { Vector2i coords = Vector2i(x, y); - if (tile_map->get_cell_source_id(coords) != -1) { + if (tile_map->get_cell_source_id(coords) != TileSet::INVALID_SOURCE) { Rect2 cell_region = xform.xform(Rect2(tile_map->map_to_world(coords) - tile_shape_size / 2, tile_shape_size)); tile_set->draw_tile_shape(p_overlay, cell_region, Color(1.0, 1.0, 1.0), false); } @@ -648,7 +637,7 @@ void TileMapEditorTilesPlugin::forward_canvas_draw_over_viewport(Control *p_over for (int x = rect.position.x; x < rect.get_end().x; x++) { for (int y = rect.position.y; y < rect.get_end().y; y++) { Vector2i coords = Vector2i(x, y); - if (tile_map->get_cell_source_id(coords) != -1) { + if (tile_map->get_cell_source_id(coords) != TileSet::INVALID_SOURCE) { to_draw.insert(coords); } } @@ -871,7 +860,7 @@ Map<Vector2i, TileMapCell> TileMapEditorTilesPlugin::_draw_line(Vector2 p_start_ // Get or create the pattern. TileMapPattern erase_pattern; - erase_pattern.set_cell(Vector2i(0, 0), -1, TileSetSource::INVALID_ATLAS_COORDS, TileSetSource::INVALID_TILE_ALTERNATIVE); + erase_pattern.set_cell(Vector2i(0, 0), TileSet::INVALID_SOURCE, TileSetSource::INVALID_ATLAS_COORDS, TileSetSource::INVALID_TILE_ALTERNATIVE); TileMapPattern *pattern = erase_button->is_pressed() ? &erase_pattern : selection_pattern; Map<Vector2i, TileMapCell> output; @@ -923,7 +912,7 @@ Map<Vector2i, TileMapCell> TileMapEditorTilesPlugin::_draw_rect(Vector2i p_start // Get or create the pattern. TileMapPattern erase_pattern; - erase_pattern.set_cell(Vector2i(0, 0), -1, TileSetSource::INVALID_ATLAS_COORDS, TileSetSource::INVALID_TILE_ALTERNATIVE); + erase_pattern.set_cell(Vector2i(0, 0), TileSet::INVALID_SOURCE, TileSetSource::INVALID_ATLAS_COORDS, TileSetSource::INVALID_TILE_ALTERNATIVE); TileMapPattern *pattern = erase_button->is_pressed() ? &erase_pattern : selection_pattern; // Compute the offset to align things to the bottom or right. @@ -974,7 +963,7 @@ Map<Vector2i, TileMapCell> TileMapEditorTilesPlugin::_draw_bucket_fill(Vector2i // Get or create the pattern. TileMapPattern erase_pattern; - erase_pattern.set_cell(Vector2i(0, 0), -1, TileSetSource::INVALID_ATLAS_COORDS, TileSetSource::INVALID_TILE_ALTERNATIVE); + erase_pattern.set_cell(Vector2i(0, 0), TileSet::INVALID_SOURCE, TileSetSource::INVALID_ATLAS_COORDS, TileSetSource::INVALID_TILE_ALTERNATIVE); TileMapPattern *pattern = erase_button->is_pressed() ? &erase_pattern : selection_pattern; Map<Vector2i, TileMapCell> output; @@ -983,7 +972,7 @@ Map<Vector2i, TileMapCell> TileMapEditorTilesPlugin::_draw_bucket_fill(Vector2i // If we are filling empty tiles, compute the tilemap boundaries. Rect2i boundaries; - if (source.source_id == -1) { + if (source.source_id == TileSet::INVALID_SOURCE) { boundaries = tile_map->get_used_rect(); } @@ -999,7 +988,7 @@ Map<Vector2i, TileMapCell> TileMapEditorTilesPlugin::_draw_bucket_fill(Vector2i if (source.source_id == tile_map->get_cell_source_id(coords) && source.get_atlas_coords() == tile_map->get_cell_atlas_coords(coords) && source.alternative_tile == tile_map->get_cell_alternative_tile(coords) && - (source.source_id != -1 || boundaries.has_point(coords))) { + (source.source_id != TileSet::INVALID_SOURCE || boundaries.has_point(coords))) { if (!erase_button->is_pressed() && random_tile_checkbox->is_pressed()) { // Paint a random tile. output.insert(coords, _pick_random_tile(pattern)); @@ -1027,7 +1016,7 @@ Map<Vector2i, TileMapCell> TileMapEditorTilesPlugin::_draw_bucket_fill(Vector2i } else { // Replace all tiles like the source. TypedArray<Vector2i> to_check; - if (source.source_id == -1) { + if (source.source_id == TileSet::INVALID_SOURCE) { Rect2i rect = tile_map->get_used_rect(); if (rect.size.x <= 0 || rect.size.y <= 0) { rect = Rect2i(p_coords, Vector2i(1, 1)); @@ -1045,7 +1034,7 @@ Map<Vector2i, TileMapCell> TileMapEditorTilesPlugin::_draw_bucket_fill(Vector2i if (source.source_id == tile_map->get_cell_source_id(coords) && source.get_atlas_coords() == tile_map->get_cell_atlas_coords(coords) && source.alternative_tile == tile_map->get_cell_alternative_tile(coords) && - (source.source_id != -1 || boundaries.has_point(coords))) { + (source.source_id != TileSet::INVALID_SOURCE || boundaries.has_point(coords))) { if (!erase_button->is_pressed() && random_tile_checkbox->is_pressed()) { // Paint a random tile. output.insert(coords, _pick_random_tile(pattern)); @@ -1102,7 +1091,7 @@ void TileMapEditorTilesPlugin::_stop_dragging() { tile_map_selection.erase(coords); } } else { - if (tile_map->get_cell_source_id(coords) != -1) { + if (tile_map->get_cell_source_id(coords) != TileSet::INVALID_SOURCE) { tile_map_selection.insert(coords); } } @@ -1173,7 +1162,7 @@ void TileMapEditorTilesPlugin::_stop_dragging() { for (int x = rect.position.x; x < rect.get_end().x; x++) { for (int y = rect.position.y; y < rect.get_end().y; y++) { Vector2i coords = Vector2i(x, y); - if (tile_map->get_cell_source_id(coords) != -1) { + if (tile_map->get_cell_source_id(coords) != TileSet::INVALID_SOURCE) { coords_array.push_back(coords); } } @@ -1198,7 +1187,7 @@ void TileMapEditorTilesPlugin::_stop_dragging() { Map<Vector2i, TileMapCell> to_draw = _draw_line(drag_start_mouse_pos, drag_start_mouse_pos, mpos); undo_redo->create_action(TTR("Paint tiles")); for (Map<Vector2i, TileMapCell>::Element *E = to_draw.front(); E; E = E->next()) { - if (!erase_button->is_pressed() && E->get().source_id == -1) { + if (!erase_button->is_pressed() && E->get().source_id == TileSet::INVALID_SOURCE) { continue; } undo_redo->add_do_method(tile_map, "set_cell", E->key(), E->get().source_id, E->get().get_atlas_coords(), E->get().alternative_tile); @@ -1210,7 +1199,7 @@ void TileMapEditorTilesPlugin::_stop_dragging() { Map<Vector2i, TileMapCell> to_draw = _draw_rect(tile_map->world_to_map(drag_start_mouse_pos), tile_map->world_to_map(mpos)); undo_redo->create_action(TTR("Paint tiles")); for (Map<Vector2i, TileMapCell>::Element *E = to_draw.front(); E; E = E->next()) { - if (!erase_button->is_pressed() && E->get().source_id == -1) { + if (!erase_button->is_pressed() && E->get().source_id == TileSet::INVALID_SOURCE) { continue; } undo_redo->add_do_method(tile_map, "set_cell", E->key(), E->get().source_id, E->get().get_atlas_coords(), E->get().alternative_tile); @@ -1221,9 +1210,6 @@ void TileMapEditorTilesPlugin::_stop_dragging() { case DRAG_TYPE_BUCKET: { undo_redo->create_action(TTR("Paint tiles")); for (Map<Vector2i, TileMapCell>::Element *E = drag_modified.front(); E; E = E->next()) { - if (!erase_button->is_pressed() && E->get().source_id == -1) { - continue; - } undo_redo->add_do_method(tile_map, "set_cell", E->key(), tile_map->get_cell_source_id(E->key()), tile_map->get_cell_atlas_coords(E->key()), tile_map->get_cell_alternative_tile(E->key())); undo_redo->add_undo_method(tile_map, "set_cell", E->key(), E->get().source_id, E->get().get_atlas_coords(), E->get().alternative_tile); } @@ -1249,7 +1235,7 @@ void TileMapEditorTilesPlugin::_stop_dragging() { void TileMapEditorTilesPlugin::_update_fix_selected_and_hovered() { TileMap *tile_map = Object::cast_to<TileMap>(ObjectDB::get_instance(tile_map_id)); if (!tile_map) { - hovered_tile.source_id = -1; + hovered_tile.source_id = TileSet::INVALID_SOURCE; hovered_tile.set_atlas_coords(TileSetSource::INVALID_ATLAS_COORDS); hovered_tile.alternative_tile = TileSetSource::INVALID_TILE_ALTERNATIVE; tile_set_selection.clear(); @@ -1260,7 +1246,7 @@ void TileMapEditorTilesPlugin::_update_fix_selected_and_hovered() { Ref<TileSet> tile_set = tile_map->get_tileset(); if (!tile_set.is_valid()) { - hovered_tile.source_id = -1; + hovered_tile.source_id = TileSet::INVALID_SOURCE; hovered_tile.set_atlas_coords(TileSetSource::INVALID_ATLAS_COORDS); hovered_tile.alternative_tile = TileSetSource::INVALID_TILE_ALTERNATIVE; tile_set_selection.clear(); @@ -1271,7 +1257,7 @@ void TileMapEditorTilesPlugin::_update_fix_selected_and_hovered() { int source_index = sources_list->get_current(); if (source_index < 0 || source_index >= sources_list->get_item_count()) { - hovered_tile.source_id = -1; + hovered_tile.source_id = TileSet::INVALID_SOURCE; hovered_tile.set_atlas_coords(TileSetSource::INVALID_ATLAS_COORDS); hovered_tile.alternative_tile = TileSetSource::INVALID_TILE_ALTERNATIVE; tile_set_selection.clear(); @@ -1287,7 +1273,7 @@ void TileMapEditorTilesPlugin::_update_fix_selected_and_hovered() { !tile_set->has_source(hovered_tile.source_id) || !tile_set->get_source(hovered_tile.source_id)->has_tile(hovered_tile.get_atlas_coords()) || !tile_set->get_source(hovered_tile.source_id)->has_alternative_tile(hovered_tile.get_atlas_coords(), hovered_tile.alternative_tile)) { - hovered_tile.source_id = -1; + hovered_tile.source_id = TileSet::INVALID_SOURCE; hovered_tile.set_atlas_coords(TileSetSource::INVALID_ATLAS_COORDS); hovered_tile.alternative_tile = TileSetSource::INVALID_TILE_ALTERNATIVE; } @@ -1403,7 +1389,7 @@ void TileMapEditorTilesPlugin::_update_tileset_selection_from_selection_pattern( TypedArray<Vector2i> used_cells = selection_pattern->get_used_cells(); for (int i = 0; i < used_cells.size(); i++) { Vector2i coords = used_cells[i]; - if (selection_pattern->get_cell_source_id(coords) != -1) { + if (selection_pattern->get_cell_source_id(coords) != TileSet::INVALID_SOURCE) { tile_set_selection.insert(TileMapCell(selection_pattern->get_cell_source_id(coords), selection_pattern->get_cell_atlas_coords(coords), selection_pattern->get_cell_alternative_tile(coords))); } } @@ -1475,7 +1461,7 @@ void TileMapEditorTilesPlugin::_tile_atlas_control_draw() { } void TileMapEditorTilesPlugin::_tile_atlas_control_mouse_exited() { - hovered_tile.source_id = -1; + hovered_tile.source_id = TileSet::INVALID_SOURCE; hovered_tile.set_atlas_coords(TileSetSource::INVALID_ATLAS_COORDS); hovered_tile.alternative_tile = TileSetSource::INVALID_TILE_ALTERNATIVE; tile_set_dragging_selection = false; @@ -1634,7 +1620,7 @@ void TileMapEditorTilesPlugin::_tile_alternatives_control_draw() { } void TileMapEditorTilesPlugin::_tile_alternatives_control_mouse_exited() { - hovered_tile.source_id = -1; + hovered_tile.source_id = TileSet::INVALID_SOURCE; hovered_tile.set_atlas_coords(TileSetSource::INVALID_ATLAS_COORDS); hovered_tile.alternative_tile = TileSetSource::INVALID_TILE_ALTERNATIVE; tile_set_dragging_selection = false; @@ -1770,7 +1756,7 @@ TileMapEditorTilesPlugin::TileMapEditorTilesPlugin() { paint_tool_button->set_flat(true); paint_tool_button->set_toggle_mode(true); paint_tool_button->set_button_group(tool_buttons_group); - paint_tool_button->set_shortcut(ED_SHORTCUT("tiles_editor/paint_tool", "Paint", KEY_E)); + paint_tool_button->set_shortcut(ED_SHORTCUT("tiles_editor/paint_tool", "Paint", KEY_D)); paint_tool_button->connect("pressed", callable_mp(this, &TileMapEditorTilesPlugin::_update_toolbar)); tilemap_tiles_tools_buttons->add_child(paint_tool_button); @@ -1856,18 +1842,6 @@ TileMapEditorTilesPlugin::TileMapEditorTilesPlugin() { _on_random_tile_checkbox_toggled(false); - // Wide empty separation control. - Control *h_empty_space = memnew(Control); - h_empty_space->set_h_size_flags(SIZE_EXPAND_FILL); - toolbar->add_child(h_empty_space); - - // Grid toggle. - toggle_grid_button = memnew(Button); - toggle_grid_button->set_flat(true); - toggle_grid_button->set_toggle_mode(true); - toggle_grid_button->connect("toggled", callable_mp(this, &TileMapEditorTilesPlugin::_on_grid_toggled)); - toolbar->add_child(toggle_grid_button); - // Default tool. paint_tool_button->set_pressed(true); _update_toolbar(); @@ -1897,8 +1871,8 @@ TileMapEditorTilesPlugin::TileMapEditorTilesPlugin() { sources_list->set_texture_filter(CanvasItem::TEXTURE_FILTER_NEAREST); sources_list->connect("item_selected", callable_mp(this, &TileMapEditorTilesPlugin::_update_fix_selected_and_hovered).unbind(1)); sources_list->connect("item_selected", callable_mp(this, &TileMapEditorTilesPlugin::_update_bottom_panel).unbind(1)); - sources_list->connect("item_selected", callable_mp(TilesEditor::get_singleton(), &TilesEditor::set_atlas_sources_lists_current)); - sources_list->connect("visibility_changed", callable_mp(TilesEditor::get_singleton(), &TilesEditor::synchronize_atlas_sources_list), varray(sources_list)); + sources_list->connect("item_selected", callable_mp(TilesEditor::get_singleton(), &TilesEditor::set_sources_lists_current)); + sources_list->connect("visibility_changed", callable_mp(TilesEditor::get_singleton(), &TilesEditor::synchronize_sources_list), varray(sources_list)); atlas_sources_split_container->add_child(sources_list); // Tile atlas source. @@ -1955,9 +1929,9 @@ void TileMapEditorTerrainsPlugin::_notification(int p_what) { switch (p_what) { case NOTIFICATION_ENTER_TREE: case NOTIFICATION_THEME_CHANGED: - paint_tool_button->set_icon(get_theme_icon("Edit", "EditorIcons")); - picker_button->set_icon(get_theme_icon("ColorPick", "EditorIcons")); - erase_button->set_icon(get_theme_icon("Eraser", "EditorIcons")); + paint_tool_button->set_icon(get_theme_icon(SNAME("Edit"), SNAME("EditorIcons"))); + picker_button->set_icon(get_theme_icon(SNAME("ColorPick"), SNAME("EditorIcons"))); + erase_button->set_icon(get_theme_icon(SNAME("Eraser"), SNAME("EditorIcons"))); break; } } @@ -2967,7 +2941,7 @@ void TileMapEditorTerrainsPlugin::_update_terrains_cache() { } TileMapCell empty_cell; - empty_cell.source_id = -1; + empty_cell.source_id = TileSet::INVALID_SOURCE; empty_cell.set_atlas_coords(TileSetSource::INVALID_ATLAS_COORDS); empty_cell.alternative_tile = TileSetSource::INVALID_TILE_ALTERNATIVE; per_terrain_terrains_tile_patterns_tiles[i][empty_pattern].insert(empty_cell); @@ -2995,13 +2969,13 @@ void TileMapEditorTerrainsPlugin::_update_terrains_tree() { TreeItem *terrain_set_tree_item = terrains_tree->create_item(); String matches; if (tile_set->get_terrain_set_mode(terrain_set_index) == TileSet::TERRAIN_MODE_MATCH_CORNERS_AND_SIDES) { - terrain_set_tree_item->set_icon(0, get_theme_icon("TerrainMatchCornersAndSides", "EditorIcons")); + terrain_set_tree_item->set_icon(0, get_theme_icon(SNAME("TerrainMatchCornersAndSides"), SNAME("EditorIcons"))); matches = String(TTR("Matches Corners and Sides")); } else if (tile_set->get_terrain_set_mode(terrain_set_index) == TileSet::TERRAIN_MODE_MATCH_CORNERS) { - terrain_set_tree_item->set_icon(0, get_theme_icon("TerrainMatchCorners", "EditorIcons")); + terrain_set_tree_item->set_icon(0, get_theme_icon(SNAME("TerrainMatchCorners"), SNAME("EditorIcons"))); matches = String(TTR("Matches Corners Only")); } else { - terrain_set_tree_item->set_icon(0, get_theme_icon("TerrainMatchSides", "EditorIcons")); + terrain_set_tree_item->set_icon(0, get_theme_icon(SNAME("TerrainMatchSides"), SNAME("EditorIcons"))); matches = String(TTR("Matches Sides Only")); } terrain_set_tree_item->set_text(0, vformat("Terrain Set %d (%s)", terrain_set_index, matches)); @@ -3187,8 +3161,11 @@ void TileMapEditor::_notification(int p_what) { switch (p_what) { case NOTIFICATION_ENTER_TREE: case NOTIFICATION_THEME_CHANGED: - missing_tile_texture = get_theme_icon("StatusWarning", "EditorIcons"); - warning_pattern_texture = get_theme_icon("WarningPattern", "EditorIcons"); + missing_tile_texture = get_theme_icon(SNAME("StatusWarning"), SNAME("EditorIcons")); + warning_pattern_texture = get_theme_icon(SNAME("WarningPattern"), SNAME("EditorIcons")); + advanced_menu_button->set_icon(get_theme_icon(SNAME("Tools"), SNAME("EditorIcons"))); + toggle_grid_button->set_icon(get_theme_icon(SNAME("Grid"), SNAME("EditorIcons"))); + toggle_grid_button->set_pressed(EditorSettings::get_singleton()->get("editors/tiles_editor/display_grid")); break; case NOTIFICATION_INTERNAL_PROCESS: if (is_visible_in_tree() && tileset_changed_needs_update) { @@ -3198,6 +3175,44 @@ void TileMapEditor::_notification(int p_what) { tileset_changed_needs_update = false; } break; + case EditorSettings::NOTIFICATION_EDITOR_SETTINGS_CHANGED: + toggle_grid_button->set_pressed(EditorSettings::get_singleton()->get("editors/tiles_editor/display_grid")); + break; + } +} + +void TileMapEditor::_on_grid_toggled(bool p_pressed) { + EditorSettings::get_singleton()->set("editors/tiles_editor/display_grid", p_pressed); +} + +void TileMapEditor::_advanced_menu_button_id_pressed(int p_id) { + TileMap *tile_map = Object::cast_to<TileMap>(ObjectDB::get_instance(tile_map_id)); + if (!tile_map) { + return; + } + + Ref<TileSet> tile_set = tile_map->get_tileset(); + if (!tile_set.is_valid()) { + return; + } + + if (p_id == 0) { // Replace Tile Proxies + undo_redo->create_action(TTR("Replace Tiles with Proxies")); + TypedArray<Vector2i> used_cells = tile_map->get_used_cells(); + for (int i = 0; i < used_cells.size(); i++) { + Vector2i cell_coords = used_cells[i]; + TileMapCell from = tile_map->get_cell(cell_coords); + Array to_array = tile_set->map_tile_proxy(from.source_id, from.get_atlas_coords(), from.alternative_tile); + TileMapCell to; + to.source_id = to_array[0]; + to.set_atlas_coords(to_array[1]); + to.alternative_tile = to_array[2]; + if (from != to) { + undo_redo->add_do_method(tile_map, "set_cell", cell_coords, to.source_id, to.get_atlas_coords(), to.alternative_tile); + undo_redo->add_undo_method(tile_map, "set_cell", cell_coords, from.source_id, from.get_atlas_coords(), from.alternative_tile); + } + } + undo_redo->commit_action(); } } @@ -3348,7 +3363,6 @@ void TileMapEditor::forward_canvas_draw_over_viewport(Control *p_overlay) { Vector2i tile_shape_size = tile_set->get_tile_size(); // Draw tiles with invalid IDs in the grid. - float icon_ratio = MIN(missing_tile_texture->get_size().x / tile_set->get_tile_size().x, missing_tile_texture->get_size().y / tile_set->get_tile_size().y) / 3; TypedArray<Vector2i> used_cells = tile_map->get_used_cells(); for (int i = 0; i < used_cells.size(); i++) { Vector2i coords = used_cells[i]; @@ -3364,25 +3378,33 @@ void TileMapEditor::forward_canvas_draw_over_viewport(Control *p_overlay) { if (!source || !source->has_tile(tile_atlas_coords) || !source->has_alternative_tile(tile_atlas_coords, tile_alternative_tile)) { // Generate a random color from the hashed values of the tiles. - Array to_hash; - to_hash.push_back(tile_source_id); - to_hash.push_back(tile_atlas_coords); - to_hash.push_back(tile_alternative_tile); - uint32_t hash = RandomPCG(to_hash.hash()).rand(); - - Color color; - color = color.from_hsv( - (float)((hash >> 24) & 0xFF) / 256.0, - Math::lerp(0.5, 1.0, (float)((hash >> 16) & 0xFF) / 256.0), - Math::lerp(0.5, 1.0, (float)((hash >> 8) & 0xFF) / 256.0), - 0.8); - - // Draw the scaled tile. - Rect2 cell_region = xform.xform(Rect2(tile_map->map_to_world(coords) - Vector2(tile_shape_size) / 2, Vector2(tile_shape_size))); - tile_set->draw_tile_shape(p_overlay, cell_region, color, true, warning_pattern_texture); + Array a = tile_set->map_tile_proxy(tile_source_id, tile_atlas_coords, tile_alternative_tile); + if (int(a[0]) == tile_source_id && Vector2i(a[1]) == tile_atlas_coords && int(a[2]) == tile_alternative_tile) { + // Only display the pattern if we have no proxy tile. + Array to_hash; + to_hash.push_back(tile_source_id); + to_hash.push_back(tile_atlas_coords); + to_hash.push_back(tile_alternative_tile); + uint32_t hash = RandomPCG(to_hash.hash()).rand(); + + Color color; + color = color.from_hsv( + (float)((hash >> 24) & 0xFF) / 256.0, + Math::lerp(0.5, 1.0, (float)((hash >> 16) & 0xFF) / 256.0), + Math::lerp(0.5, 1.0, (float)((hash >> 8) & 0xFF) / 256.0), + 0.8); + + // Draw the scaled tile. + Rect2 cell_region = xform.xform(Rect2(tile_map->map_to_world(coords) - Vector2(tile_shape_size) / 2, Vector2(tile_shape_size))); + tile_set->draw_tile_shape(p_overlay, cell_region, color, true, warning_pattern_texture); + } // Draw the warning icon. - Rect2 rect = Rect2(xform.xform(tile_map->map_to_world(coords)) - (icon_ratio * missing_tile_texture->get_size() * xform.get_scale() / 2), icon_ratio * missing_tile_texture->get_size() * xform.get_scale()); + int min_axis = missing_tile_texture->get_size().min_axis(); + Vector2 icon_size; + icon_size[min_axis] = tile_set->get_tile_size()[min_axis] / 3; + icon_size[(min_axis + 1) % 2] = (icon_size[min_axis] * missing_tile_texture->get_size()[(min_axis + 1) % 2] / missing_tile_texture->get_size()[min_axis]); + Rect2 rect = Rect2(xform.xform(tile_map->map_to_world(coords)) - (icon_size * xform.get_scale() / 2), icon_size * xform.get_scale()); p_overlay->draw_texture_rect(missing_tile_texture, rect); } } @@ -3438,7 +3460,7 @@ void TileMapEditor::forward_canvas_draw_over_viewport(Control *p_overlay) { } // Draw the IDs for debug. - /*Ref<Font> font = get_theme_font("font", "Label"); + /*Ref<Font> font = get_theme_font(SNAME("font"), SNAME("Label")); for (int x = displayed_rect.position.x; x < (displayed_rect.position.x + displayed_rect.size.x); x++) { for (int y = displayed_rect.position.y; y < (displayed_rect.position.y + displayed_rect.size.y); y++) { p_overlay->draw_string(font, xform.xform(tile_map->map_to_world(Vector2(x, y))) + Vector2i(-tile_shape_size.x / 2, 0), vformat("%s", Vector2(x, y))); @@ -3502,6 +3524,26 @@ TileMapEditor::TileMapEditor() { tilemap_toolbar->add_child(tile_map_editor_plugins[i]->get_toolbar()); } + // Wide empty separation control. + Control *h_empty_space = memnew(Control); + h_empty_space->set_h_size_flags(SIZE_EXPAND_FILL); + tilemap_toolbar->add_child(h_empty_space); + + // Grid toggle. + toggle_grid_button = memnew(Button); + toggle_grid_button->set_flat(true); + toggle_grid_button->set_toggle_mode(true); + toggle_grid_button->set_tooltip(TTR("Toggle grid visibility.")); + toggle_grid_button->connect("toggled", callable_mp(this, &TileMapEditor::_on_grid_toggled)); + tilemap_toolbar->add_child(toggle_grid_button); + + // Advanced settings menu button. + advanced_menu_button = memnew(MenuButton); + advanced_menu_button->set_flat(true); + advanced_menu_button->get_popup()->add_item(TTR("Automatically Replace Tiles with Proxies")); + advanced_menu_button->get_popup()->connect("id_pressed", callable_mp(this, &TileMapEditor::_advanced_menu_button_id_pressed)); + tilemap_toolbar->add_child(advanced_menu_button); + missing_tileset_label = memnew(Label); missing_tileset_label->set_text(TTR("The edited TileMap node has no TileSet resource.")); missing_tileset_label->set_h_size_flags(SIZE_EXPAND_FILL); diff --git a/editor/plugins/tiles/tile_map_editor.h b/editor/plugins/tiles/tile_map_editor.h index a6f4ec3021..236774a06b 100644 --- a/editor/plugins/tiles/tile_map_editor.h +++ b/editor/plugins/tiles/tile_map_editor.h @@ -82,9 +82,6 @@ private: void _on_random_tile_checkbox_toggled(bool p_pressed); void _on_scattering_spinbox_changed(double p_value); - Button *toggle_grid_button; - void _on_grid_toggled(bool p_pressed); - void _update_toolbar(); ///// Tilemap editing. ///// @@ -300,6 +297,7 @@ class TileMapEditor : public VBoxContainer { GDCLASS(TileMapEditor, VBoxContainer); private: + UndoRedo *undo_redo = EditorNode::get_undo_redo(); bool tileset_changed_needs_update = false; ObjectID tile_map_id; @@ -309,6 +307,12 @@ private: // Toolbar. HBoxContainer *tilemap_toolbar; + Button *toggle_grid_button; + void _on_grid_toggled(bool p_pressed); + + MenuButton *advanced_menu_button; + void _advanced_menu_button_id_pressed(int p_id); + // Bottom panel Label *missing_tileset_label; Tabs *tabs; diff --git a/editor/plugins/tiles/tile_proxies_manager_dialog.cpp b/editor/plugins/tiles/tile_proxies_manager_dialog.cpp new file mode 100644 index 0000000000..9e47a44b34 --- /dev/null +++ b/editor/plugins/tiles/tile_proxies_manager_dialog.cpp @@ -0,0 +1,476 @@ +/*************************************************************************/ +/* tile_proxies_manager_dialog.cpp */ +/*************************************************************************/ +/* This file is part of: */ +/* GODOT ENGINE */ +/* https://godotengine.org */ +/*************************************************************************/ +/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2021 Godot Engine contributors (cf. AUTHORS.md). */ +/* */ +/* 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. */ +/*************************************************************************/ + +#include "tile_proxies_manager_dialog.h" + +#include "editor/editor_scale.h" + +void TileProxiesManagerDialog::_right_clicked(int p_item, Vector2 p_local_mouse_pos, Object *p_item_list) { + ItemList *item_list = Object::cast_to<ItemList>(p_item_list); + popup_menu->set_size(Vector2(1, 1)); + popup_menu->set_position(get_position() + item_list->get_global_mouse_position()); + popup_menu->popup(); +} + +void TileProxiesManagerDialog::_menu_id_pressed(int p_id) { + if (p_id == 0) { + // Delete. + _delete_selected_bindings(); + } +} + +void TileProxiesManagerDialog::_delete_selected_bindings() { + undo_redo->create_action(TTR("Remove Tile Proxies")); + + Vector<int> source_level_selected = source_level_list->get_selected_items(); + for (int i = 0; i < source_level_selected.size(); i++) { + int key = source_level_list->get_item_metadata(source_level_selected[i]); + int val = tile_set->get_source_level_tile_proxy(key); + undo_redo->add_do_method(*tile_set, "remove_source_level_tile_proxy", key); + undo_redo->add_undo_method(*tile_set, "set_source_level_tile_proxy", key, val); + } + + Vector<int> coords_level_selected = coords_level_list->get_selected_items(); + for (int i = 0; i < coords_level_selected.size(); i++) { + Array key = coords_level_list->get_item_metadata(coords_level_selected[i]); + Array val = tile_set->get_coords_level_tile_proxy(key[0], key[1]); + undo_redo->add_do_method(*tile_set, "remove_coords_level_tile_proxy", key[0], key[1]); + undo_redo->add_undo_method(*tile_set, "set_coords_level_tile_proxy", key[0], key[1], val[0], val[1]); + } + + Vector<int> alternative_level_selected = alternative_level_list->get_selected_items(); + for (int i = 0; i < alternative_level_selected.size(); i++) { + Array key = alternative_level_list->get_item_metadata(alternative_level_selected[i]); + Array val = tile_set->get_coords_level_tile_proxy(key[0], key[1]); + undo_redo->add_do_method(*tile_set, "remove_alternative_level_tile_proxy", key[0], key[1], key[2]); + undo_redo->add_undo_method(*tile_set, "set_alternative_level_tile_proxy", key[0], key[1], key[2], val[0], val[1], val[2]); + } + undo_redo->add_do_method(this, "_update_lists"); + undo_redo->add_undo_method(this, "_update_lists"); + undo_redo->commit_action(); + + commited_actions_count += 1; +} + +void TileProxiesManagerDialog::_update_lists() { + source_level_list->clear(); + coords_level_list->clear(); + alternative_level_list->clear(); + + Array proxies = tile_set->get_source_level_tile_proxies(); + for (int i = 0; i < proxies.size(); i++) { + Array proxy = proxies[i]; + String text = vformat("%s", proxy[0]).rpad(5) + "-> " + vformat("%s", proxy[1]); + int id = source_level_list->add_item(text); + source_level_list->set_item_metadata(id, proxy[0]); + } + + proxies = tile_set->get_coords_level_tile_proxies(); + for (int i = 0; i < proxies.size(); i++) { + Array proxy = proxies[i]; + String text = vformat("%s, %s", proxy[0], proxy[1]).rpad(17) + "-> " + vformat("%s, %s", proxy[2], proxy[3]); + int id = coords_level_list->add_item(text); + coords_level_list->set_item_metadata(id, proxy.slice(0, 2)); + } + + proxies = tile_set->get_alternative_level_tile_proxies(); + for (int i = 0; i < proxies.size(); i++) { + Array proxy = proxies[i]; + String text = vformat("%s, %s, %s", proxy[0], proxy[1], proxy[2]).rpad(24) + "-> " + vformat("%s, %s, %s", proxy[3], proxy[4], proxy[5]); + int id = alternative_level_list->add_item(text); + alternative_level_list->set_item_metadata(id, proxy.slice(0, 3)); + } +} + +void TileProxiesManagerDialog::_update_enabled_property_editors() { + if (from.source_id == TileSet::INVALID_SOURCE) { + from.set_atlas_coords(TileSetSource::INVALID_ATLAS_COORDS); + to.set_atlas_coords(TileSetSource::INVALID_ATLAS_COORDS); + from.alternative_tile = TileSetSource::INVALID_TILE_ALTERNATIVE; + to.alternative_tile = TileSetSource::INVALID_TILE_ALTERNATIVE; + coords_from_property_editor->hide(); + coords_to_property_editor->hide(); + alternative_from_property_editor->hide(); + alternative_to_property_editor->hide(); + } else if (from.get_atlas_coords().x == -1 || from.get_atlas_coords().y == -1) { + from.alternative_tile = TileSetSource::INVALID_TILE_ALTERNATIVE; + to.alternative_tile = TileSetSource::INVALID_TILE_ALTERNATIVE; + coords_from_property_editor->show(); + coords_to_property_editor->show(); + alternative_from_property_editor->hide(); + alternative_to_property_editor->hide(); + } else { + coords_from_property_editor->show(); + coords_to_property_editor->show(); + alternative_from_property_editor->show(); + alternative_to_property_editor->show(); + } + + source_from_property_editor->update_property(); + source_to_property_editor->update_property(); + coords_from_property_editor->update_property(); + coords_to_property_editor->update_property(); + alternative_from_property_editor->update_property(); + alternative_to_property_editor->update_property(); +} + +void TileProxiesManagerDialog::_property_changed(const String &p_path, const Variant &p_value, const String &p_name, bool p_changing) { + _set(p_path, p_value); +} + +void TileProxiesManagerDialog::_add_button_pressed() { + if (from.source_id != TileSet::INVALID_SOURCE && to.source_id != TileSet::INVALID_SOURCE) { + Vector2i from_coords = from.get_atlas_coords(); + Vector2i to_coords = to.get_atlas_coords(); + if (from_coords.x >= 0 && from_coords.y >= 0 && to_coords.x >= 0 && to_coords.y >= 0) { + if (from.alternative_tile != TileSetSource::INVALID_TILE_ALTERNATIVE && to.alternative_tile != TileSetSource::INVALID_TILE_ALTERNATIVE) { + undo_redo->create_action(TTR("Create Alternative-level Tile Proxy")); + undo_redo->add_do_method(*tile_set, "set_alternative_level_tile_proxy", from.source_id, from.get_atlas_coords(), from.alternative_tile, to.source_id, to.get_atlas_coords(), to.alternative_tile); + if (tile_set->has_alternative_level_tile_proxy(from.source_id, from.get_atlas_coords(), from.alternative_tile)) { + Array a = tile_set->get_alternative_level_tile_proxy(from.source_id, from.get_atlas_coords(), from.alternative_tile); + undo_redo->add_undo_method(*tile_set, "set_alternative_level_tile_proxy", to.source_id, to.get_atlas_coords(), to.alternative_tile, a[0], a[1], a[2]); + } else { + undo_redo->add_undo_method(*tile_set, "remove_alternative_level_tile_proxy", from.source_id, from.get_atlas_coords(), from.alternative_tile); + } + } else { + undo_redo->create_action(TTR("Create Coords-level Tile Proxy")); + undo_redo->add_do_method(*tile_set, "set_coords_level_tile_proxy", from.source_id, from.get_atlas_coords(), to.source_id, to.get_atlas_coords()); + if (tile_set->has_coords_level_tile_proxy(from.source_id, from.get_atlas_coords())) { + Array a = tile_set->get_coords_level_tile_proxy(from.source_id, from.get_atlas_coords()); + undo_redo->add_undo_method(*tile_set, "set_coords_level_tile_proxy", to.source_id, to.get_atlas_coords(), a[0], a[1]); + } else { + undo_redo->add_undo_method(*tile_set, "remove_coords_level_tile_proxy", from.source_id, from.get_atlas_coords()); + } + } + } else { + undo_redo->create_action(TTR("Create source-level Tile Proxy")); + undo_redo->add_do_method(*tile_set, "set_source_level_tile_proxy", from.source_id, to.source_id); + if (tile_set->has_source_level_tile_proxy(from.source_id)) { + undo_redo->add_undo_method(*tile_set, "set_source_level_tile_proxy", to.source_id, tile_set->get_source_level_tile_proxy(from.source_id)); + } else { + undo_redo->add_undo_method(*tile_set, "remove_source_level_tile_proxy", from.source_id); + } + } + undo_redo->add_do_method(this, "_update_lists"); + undo_redo->add_undo_method(this, "_update_lists"); + undo_redo->commit_action(); + commited_actions_count++; + } +} + +void TileProxiesManagerDialog::_clear_invalid_button_pressed() { + undo_redo->create_action(TTR("Delete All Invalid Tile Proxies")); + + undo_redo->add_do_method(*tile_set, "cleanup_invalid_tile_proxies"); + + Array proxies = tile_set->get_source_level_tile_proxies(); + for (int i = 0; i < proxies.size(); i++) { + Array proxy = proxies[i]; + undo_redo->add_undo_method(*tile_set, "set_source_level_tile_proxy", proxy[0], proxy[1]); + } + + proxies = tile_set->get_coords_level_tile_proxies(); + for (int i = 0; i < proxies.size(); i++) { + Array proxy = proxies[i]; + undo_redo->add_undo_method(*tile_set, "set_coords_level_tile_proxy", proxy[0], proxy[1], proxy[2], proxy[3]); + } + + proxies = tile_set->get_alternative_level_tile_proxies(); + for (int i = 0; i < proxies.size(); i++) { + Array proxy = proxies[i]; + undo_redo->add_undo_method(*tile_set, "set_alternative_level_tile_proxy", proxy[0], proxy[1], proxy[2], proxy[3], proxy[4], proxy[5]); + } + undo_redo->add_do_method(this, "_update_lists"); + undo_redo->add_undo_method(this, "_update_lists"); + undo_redo->commit_action(); +} + +void TileProxiesManagerDialog::_clear_all_button_pressed() { + undo_redo->create_action(TTR("Delete All Tile Proxies")); + + undo_redo->add_do_method(*tile_set, "clear_tile_proxies"); + + Array proxies = tile_set->get_source_level_tile_proxies(); + for (int i = 0; i < proxies.size(); i++) { + Array proxy = proxies[i]; + undo_redo->add_undo_method(*tile_set, "set_source_level_tile_proxy", proxy[0], proxy[1]); + } + + proxies = tile_set->get_coords_level_tile_proxies(); + for (int i = 0; i < proxies.size(); i++) { + Array proxy = proxies[i]; + undo_redo->add_undo_method(*tile_set, "set_coords_level_tile_proxy", proxy[0], proxy[1], proxy[2], proxy[3]); + } + + proxies = tile_set->get_alternative_level_tile_proxies(); + for (int i = 0; i < proxies.size(); i++) { + Array proxy = proxies[i]; + undo_redo->add_undo_method(*tile_set, "set_alternative_level_tile_proxy", proxy[0], proxy[1], proxy[2], proxy[3], proxy[4], proxy[5]); + } + undo_redo->add_do_method(this, "_update_lists"); + undo_redo->add_undo_method(this, "_update_lists"); + undo_redo->commit_action(); +} + +bool TileProxiesManagerDialog::_set(const StringName &p_name, const Variant &p_value) { + if (p_name == "from_source") { + from.source_id = MAX(int(p_value), -1); + } else if (p_name == "from_coords") { + from.set_atlas_coords(Vector2i(p_value).max(Vector2i(-1, -1))); + } else if (p_name == "from_alternative") { + from.alternative_tile = MAX(int(p_value), -1); + } else if (p_name == "to_source") { + to.source_id = MAX(int(p_value), 0); + } else if (p_name == "to_coords") { + to.set_atlas_coords(Vector2i(p_value).max(Vector2i(0, 0))); + } else if (p_name == "to_alternative") { + to.alternative_tile = MAX(int(p_value), 0); + } else { + return false; + } + _update_enabled_property_editors(); + return true; +} + +bool TileProxiesManagerDialog::_get(const StringName &p_name, Variant &r_ret) const { + if (p_name == "from_source") { + r_ret = from.source_id; + } else if (p_name == "from_coords") { + r_ret = from.get_atlas_coords(); + } else if (p_name == "from_alternative") { + r_ret = from.alternative_tile; + } else if (p_name == "to_source") { + r_ret = to.source_id; + } else if (p_name == "to_coords") { + r_ret = to.get_atlas_coords(); + } else if (p_name == "to_alternative") { + r_ret = to.alternative_tile; + } else { + return false; + } + return true; +} + +void TileProxiesManagerDialog::_unhandled_key_input(Ref<InputEvent> p_event) { + ERR_FAIL_COND(p_event.is_null()); + + if (p_event->is_pressed() && !p_event->is_echo() && (Object::cast_to<InputEventKey>(p_event.ptr()) || Object::cast_to<InputEventJoypadButton>(p_event.ptr()) || Object::cast_to<InputEventAction>(*p_event))) { + if (!is_inside_tree() || !is_visible()) { + return; + } + + if (popup_menu->activate_item_by_event(p_event, false)) { + set_input_as_handled(); + } + } +} + +void TileProxiesManagerDialog::cancel_pressed() { + for (int i = 0; i < commited_actions_count; i++) { + undo_redo->undo(); + } + commited_actions_count = 0; +} + +void TileProxiesManagerDialog::_bind_methods() { + ClassDB::bind_method(D_METHOD("_update_lists"), &TileProxiesManagerDialog::_update_lists); + ClassDB::bind_method(D_METHOD("_unhandled_key_input"), &TileProxiesManagerDialog::_unhandled_key_input); +} + +void TileProxiesManagerDialog::update_tile_set(Ref<TileSet> p_tile_set) { + ERR_FAIL_COND(!p_tile_set.is_valid()); + tile_set = p_tile_set; + commited_actions_count = 0; + _update_lists(); +} + +TileProxiesManagerDialog::TileProxiesManagerDialog() { + // Tile proxy management window. + set_title(TTR("Tile Proxies Management")); + set_process_unhandled_key_input(true); + + to.source_id = 0; + to.set_atlas_coords(Vector2i()); + to.alternative_tile = 0; + + VBoxContainer *vbox_container = memnew(VBoxContainer); + vbox_container->set_h_size_flags(Control::SIZE_EXPAND_FILL); + vbox_container->set_v_size_flags(Control::SIZE_EXPAND_FILL); + add_child(vbox_container); + + Label *source_level_label = memnew(Label); + source_level_label->set_text(TTR("Source-level proxies")); + vbox_container->add_child(source_level_label); + + source_level_list = memnew(ItemList); + source_level_list->set_v_size_flags(Control::SIZE_EXPAND_FILL); + source_level_list->set_select_mode(ItemList::SELECT_MULTI); + source_level_list->set_allow_rmb_select(true); + source_level_list->connect("item_rmb_selected", callable_mp(this, &TileProxiesManagerDialog::_right_clicked), varray(source_level_list)); + vbox_container->add_child(source_level_list); + + Label *coords_level_label = memnew(Label); + coords_level_label->set_text(TTR("Coords-level proxies")); + vbox_container->add_child(coords_level_label); + + coords_level_list = memnew(ItemList); + coords_level_list->set_v_size_flags(Control::SIZE_EXPAND_FILL); + coords_level_list->set_select_mode(ItemList::SELECT_MULTI); + coords_level_list->set_allow_rmb_select(true); + coords_level_list->connect("item_rmb_selected", callable_mp(this, &TileProxiesManagerDialog::_right_clicked), varray(coords_level_list)); + vbox_container->add_child(coords_level_list); + + Label *alternative_level_label = memnew(Label); + alternative_level_label->set_text(TTR("Alternative-level proxies")); + vbox_container->add_child(alternative_level_label); + + alternative_level_list = memnew(ItemList); + alternative_level_list->set_v_size_flags(Control::SIZE_EXPAND_FILL); + alternative_level_list->set_select_mode(ItemList::SELECT_MULTI); + alternative_level_list->set_allow_rmb_select(true); + alternative_level_list->connect("item_rmb_selected", callable_mp(this, &TileProxiesManagerDialog::_right_clicked), varray(alternative_level_list)); + vbox_container->add_child(alternative_level_list); + + popup_menu = memnew(PopupMenu); + popup_menu->add_shortcut(ED_GET_SHORTCUT("ui_text_delete")); + popup_menu->connect("id_pressed", callable_mp(this, &TileProxiesManagerDialog::_menu_id_pressed)); + add_child(popup_menu); + + // Add proxy panel. + HSeparator *h_separator = memnew(HSeparator); + vbox_container->add_child(h_separator); + + Label *add_label = memnew(Label); + add_label->set_text(TTR("Add a new tile proxy:")); + vbox_container->add_child(add_label); + + HBoxContainer *hboxcontainer = memnew(HBoxContainer); + vbox_container->add_child(hboxcontainer); + + // From + VBoxContainer *vboxcontainer_from = memnew(VBoxContainer); + vboxcontainer_from->set_h_size_flags(Control::SIZE_EXPAND_FILL); + hboxcontainer->add_child(vboxcontainer_from); + + source_from_property_editor = memnew(EditorPropertyInteger); + source_from_property_editor->set_label(TTR("From Source")); + source_from_property_editor->set_object_and_property(this, "from_source"); + source_from_property_editor->connect("property_changed", callable_mp(this, &TileProxiesManagerDialog::_property_changed)); + source_from_property_editor->set_selectable(false); + source_from_property_editor->set_h_size_flags(Control::SIZE_EXPAND_FILL); + source_from_property_editor->setup(-1, 99999, 1, true, false); + vboxcontainer_from->add_child(source_from_property_editor); + + coords_from_property_editor = memnew(EditorPropertyVector2i); + coords_from_property_editor->set_label(TTR("From Coords")); + coords_from_property_editor->set_object_and_property(this, "from_coords"); + coords_from_property_editor->connect("property_changed", callable_mp(this, &TileProxiesManagerDialog::_property_changed)); + coords_from_property_editor->set_selectable(false); + coords_from_property_editor->set_h_size_flags(Control::SIZE_EXPAND_FILL); + coords_from_property_editor->setup(-1, 99999, true); + coords_from_property_editor->hide(); + vboxcontainer_from->add_child(coords_from_property_editor); + + alternative_from_property_editor = memnew(EditorPropertyInteger); + alternative_from_property_editor->set_label(TTR("From Alternative")); + alternative_from_property_editor->set_object_and_property(this, "from_alternative"); + alternative_from_property_editor->connect("property_changed", callable_mp(this, &TileProxiesManagerDialog::_property_changed)); + alternative_from_property_editor->set_selectable(false); + alternative_from_property_editor->set_h_size_flags(Control::SIZE_EXPAND_FILL); + alternative_from_property_editor->setup(-1, 99999, 1, true, false); + alternative_from_property_editor->hide(); + vboxcontainer_from->add_child(alternative_from_property_editor); + + // To + VBoxContainer *vboxcontainer_to = memnew(VBoxContainer); + vboxcontainer_to->set_h_size_flags(Control::SIZE_EXPAND_FILL); + hboxcontainer->add_child(vboxcontainer_to); + + source_to_property_editor = memnew(EditorPropertyInteger); + source_to_property_editor->set_label(TTR("To Source")); + source_to_property_editor->set_object_and_property(this, "to_source"); + source_to_property_editor->connect("property_changed", callable_mp(this, &TileProxiesManagerDialog::_property_changed)); + source_to_property_editor->set_selectable(false); + source_to_property_editor->set_h_size_flags(Control::SIZE_EXPAND_FILL); + source_to_property_editor->setup(-1, 99999, 1, true, false); + vboxcontainer_to->add_child(source_to_property_editor); + + coords_to_property_editor = memnew(EditorPropertyVector2i); + coords_to_property_editor->set_label(TTR("To Coords")); + coords_to_property_editor->set_object_and_property(this, "to_coords"); + coords_to_property_editor->connect("property_changed", callable_mp(this, &TileProxiesManagerDialog::_property_changed)); + coords_to_property_editor->set_selectable(false); + coords_to_property_editor->set_h_size_flags(Control::SIZE_EXPAND_FILL); + coords_to_property_editor->setup(-1, 99999, true); + coords_to_property_editor->hide(); + vboxcontainer_to->add_child(coords_to_property_editor); + + alternative_to_property_editor = memnew(EditorPropertyInteger); + alternative_to_property_editor->set_label(TTR("To Alternative")); + alternative_to_property_editor->set_object_and_property(this, "to_alternative"); + alternative_to_property_editor->connect("property_changed", callable_mp(this, &TileProxiesManagerDialog::_property_changed)); + alternative_to_property_editor->set_selectable(false); + alternative_to_property_editor->set_h_size_flags(Control::SIZE_EXPAND_FILL); + alternative_to_property_editor->setup(-1, 99999, 1, true, false); + alternative_to_property_editor->hide(); + vboxcontainer_to->add_child(alternative_to_property_editor); + + Button *add_button = memnew(Button); + add_button->set_text(TTR("Add")); + add_button->set_h_size_flags(Control::SIZE_SHRINK_CENTER); + add_button->connect("pressed", callable_mp(this, &TileProxiesManagerDialog::_add_button_pressed)); + vbox_container->add_child(add_button); + + h_separator = memnew(HSeparator); + vbox_container->add_child(h_separator); + + // Generic actions. + Label *generic_actions_label = memnew(Label); + generic_actions_label->set_text(TTR("Global actions:")); + vbox_container->add_child(generic_actions_label); + + hboxcontainer = memnew(HBoxContainer); + vbox_container->add_child(hboxcontainer); + + Button *clear_invalid_button = memnew(Button); + clear_invalid_button->set_text(TTR("Clear Invalid")); + clear_invalid_button->set_h_size_flags(Control::SIZE_SHRINK_CENTER); + clear_invalid_button->connect("pressed", callable_mp(this, &TileProxiesManagerDialog::_clear_invalid_button_pressed)); + hboxcontainer->add_child(clear_invalid_button); + + Button *clear_all_button = memnew(Button); + clear_all_button->set_text(TTR("Clear All")); + clear_all_button->set_h_size_flags(Control::SIZE_SHRINK_CENTER); + clear_all_button->connect("pressed", callable_mp(this, &TileProxiesManagerDialog::_clear_all_button_pressed)); + hboxcontainer->add_child(clear_all_button); + + h_separator = memnew(HSeparator); + vbox_container->add_child(h_separator); +} diff --git a/editor/plugins/tiles/tile_proxies_manager_dialog.h b/editor/plugins/tiles/tile_proxies_manager_dialog.h new file mode 100644 index 0000000000..f6898e960b --- /dev/null +++ b/editor/plugins/tiles/tile_proxies_manager_dialog.h @@ -0,0 +1,90 @@ +/*************************************************************************/ +/* tile_proxies_manager_dialog.h */ +/*************************************************************************/ +/* This file is part of: */ +/* GODOT ENGINE */ +/* https://godotengine.org */ +/*************************************************************************/ +/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2021 Godot Engine contributors (cf. AUTHORS.md). */ +/* */ +/* 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 TILE_PROXIES_MANAGER_DIALOG_H +#define TILE_PROXIES_MANAGER_DIALOG_H + +#include "editor/editor_node.h" +#include "editor/editor_properties.h" + +#include "scene/gui/dialogs.h" +#include "scene/gui/item_list.h" +#include "scene/resources/tile_set.h" + +class TileProxiesManagerDialog : public ConfirmationDialog { + GDCLASS(TileProxiesManagerDialog, ConfirmationDialog); + +private: + int commited_actions_count = 0; + Ref<TileSet> tile_set; + + UndoRedo *undo_redo = EditorNode::get_singleton()->get_undo_redo(); + + TileMapCell from; + TileMapCell to; + + // GUI + ItemList *source_level_list; + ItemList *coords_level_list; + ItemList *alternative_level_list; + + EditorPropertyInteger *source_from_property_editor; + EditorPropertyVector2i *coords_from_property_editor; + EditorPropertyInteger *alternative_from_property_editor; + EditorPropertyInteger *source_to_property_editor; + EditorPropertyVector2i *coords_to_property_editor; + EditorPropertyInteger *alternative_to_property_editor; + + PopupMenu *popup_menu; + void _right_clicked(int p_item, Vector2 p_local_mouse_pos, Object *p_item_list); + void _menu_id_pressed(int p_id); + void _delete_selected_bindings(); + void _update_lists(); + void _update_enabled_property_editors(); + void _property_changed(const String &p_path, const Variant &p_value, const String &p_name, bool p_changing); + void _add_button_pressed(); + + void _clear_invalid_button_pressed(); + void _clear_all_button_pressed(); + +protected: + bool _set(const StringName &p_name, const Variant &p_value); + bool _get(const StringName &p_name, Variant &r_ret) const; + void _unhandled_key_input(Ref<InputEvent> p_event); + virtual void cancel_pressed() override; + static void _bind_methods(); + +public: + void update_tile_set(Ref<TileSet> p_tile_set); + + TileProxiesManagerDialog(); +}; + +#endif // TILE_PROXIES_MANAGER_DIALOG_H diff --git a/editor/plugins/tiles/tile_set_atlas_source_editor.cpp b/editor/plugins/tiles/tile_set_atlas_source_editor.cpp index 9d849a0df5..432f48fa85 100644 --- a/editor/plugins/tiles/tile_set_atlas_source_editor.cpp +++ b/editor/plugins/tiles/tile_set_atlas_source_editor.cpp @@ -58,7 +58,7 @@ void TileSetAtlasSourceEditor::TileSetAtlasSourceProxyObject::set_id(int p_id) { int previous_source = source_id; source_id = p_id; // source_id must be updated before, because it's used by the source list update. tile_set->set_source_id(previous_source, p_id); - emit_signal("changed", "id"); + emit_signal(SNAME("changed"), "id"); } int TileSetAtlasSourceEditor::TileSetAtlasSourceProxyObject::get_id() { @@ -69,7 +69,7 @@ bool TileSetAtlasSourceEditor::TileSetAtlasSourceProxyObject::_set(const StringN bool valid = false; tile_set_atlas_source->set(p_name, p_value, &valid); if (valid) { - emit_signal("changed", String(p_name).utf8().get_data()); + emit_signal(SNAME("changed"), String(p_name).utf8().get_data()); } return valid; } @@ -148,14 +148,14 @@ bool TileSetAtlasSourceEditor::AtlasTileProxyObject::_set(const StringName &p_na tile_set_atlas_source->move_tile_in_atlas(coords, as_vector2i); tiles.clear(); tiles.insert({ as_vector2i, 0 }); - emit_signal("changed", "atlas_coords"); + emit_signal(SNAME("changed"), "atlas_coords"); return true; } else if (alternative == 0 && p_name == "size_in_atlas") { Vector2i as_vector2i = Vector2i(p_value); ERR_FAIL_COND_V(!tile_set_atlas_source->can_move_tile_in_atlas(coords, TileSetSource::INVALID_ATLAS_COORDS, as_vector2i), false); tile_set_atlas_source->move_tile_in_atlas(coords, TileSetSource::INVALID_ATLAS_COORDS, as_vector2i); - emit_signal("changed", "size_in_atlas"); + emit_signal(SNAME("changed"), "size_in_atlas"); return true; } else if (alternative > 0 && p_name == "alternative_id") { int as_int = int(p_value); @@ -172,7 +172,7 @@ bool TileSetAtlasSourceEditor::AtlasTileProxyObject::_set(const StringName &p_na tiles.insert({ coords, as_int }); // tiles must be updated before. tile_set_atlas_source->set_alternative_tile_id(coords, previous_alternative_tile, as_int); - emit_signal("changed", "alternative_id"); + emit_signal(SNAME("changed"), "alternative_id"); return true; } } @@ -191,7 +191,7 @@ bool TileSetAtlasSourceEditor::AtlasTileProxyObject::_set(const StringName &p_na } if (any_valid) { - emit_signal("changed", String(p_name).utf8().get_data()); + emit_signal(SNAME("changed"), String(p_name).utf8().get_data()); } return any_valid; @@ -303,9 +303,9 @@ void TileSetAtlasSourceEditor::AtlasTileProxyObject::_get_property_list(List<Pro } // Add only properties that are common to all tiles. - for (List<PLData *>::Element *E = data_list.front(); E; E = E->next()) { - if (E->get()->uses == tiles.size()) { - p_list->push_back(E->get()->property_info); + for (const PLData *E : data_list) { + if (E->uses == tiles.size()) { + p_list->push_back(E->property_info); } } } @@ -453,7 +453,7 @@ void TileSetAtlasSourceEditor::_update_tile_data_editors() { tile_data_editors_tree->add_theme_constant_override("vseparation", 1); tile_data_editors_tree->add_theme_constant_override("hseparation", 3); - Color group_color = get_theme_color("prop_category", "Editor"); + Color group_color = get_theme_color(SNAME("prop_category"), SNAME("Editor")); // List of editors. // --- Rendering --- @@ -660,26 +660,26 @@ void TileSetAtlasSourceEditor::_update_current_tile_data_editor() { } void TileSetAtlasSourceEditor::_tile_data_editor_dropdown_button_draw() { - if (!has_theme_icon("arrow", "OptionButton")) { + if (!has_theme_icon(SNAME("arrow"), SNAME("OptionButton"))) { return; } RID ci = tile_data_editor_dropdown_button->get_canvas_item(); - Ref<Texture2D> arrow = Control::get_theme_icon("arrow", "OptionButton"); + Ref<Texture2D> arrow = Control::get_theme_icon(SNAME("arrow"), SNAME("OptionButton")); Color clr = Color(1, 1, 1); - if (get_theme_constant("modulate_arrow")) { + if (get_theme_constant(SNAME("modulate_arrow"))) { switch (tile_data_editor_dropdown_button->get_draw_mode()) { case BaseButton::DRAW_PRESSED: - clr = get_theme_color("font_pressed_color"); + clr = get_theme_color(SNAME("font_pressed_color")); break; case BaseButton::DRAW_HOVER: - clr = get_theme_color("font_hover_color"); + clr = get_theme_color(SNAME("font_hover_color")); break; case BaseButton::DRAW_DISABLED: - clr = get_theme_color("font_disabled_color"); + clr = get_theme_color(SNAME("font_disabled_color")); break; default: - clr = get_theme_color("font_color"); + clr = get_theme_color(SNAME("font_color")); } } @@ -687,9 +687,9 @@ void TileSetAtlasSourceEditor::_tile_data_editor_dropdown_button_draw() { Point2 ofs; if (is_layout_rtl()) { - ofs = Point2(get_theme_constant("arrow_margin", "OptionButton"), int(Math::abs((size.height - arrow->get_height()) / 2))); + ofs = Point2(get_theme_constant(SNAME("arrow_margin"), SNAME("OptionButton")), int(Math::abs((size.height - arrow->get_height()) / 2))); } else { - ofs = Point2(size.width - arrow->get_width() - get_theme_constant("arrow_margin", "OptionButton"), int(Math::abs((size.height - arrow->get_height()) / 2))); + ofs = Point2(size.width - arrow->get_width() - get_theme_constant(SNAME("arrow_margin"), SNAME("OptionButton")), int(Math::abs((size.height - arrow->get_height()) / 2))); } arrow->draw(ci, ofs, clr); } @@ -702,7 +702,7 @@ void TileSetAtlasSourceEditor::_tile_data_editor_dropdown_button_pressed() { } void TileSetAtlasSourceEditor::_tile_data_editors_tree_selected() { - tile_data_editors_popup->call_deferred("hide"); + tile_data_editors_popup->call_deferred(SNAME("hide")); _update_current_tile_data_editor(); tile_atlas_control->update(); tile_atlas_control_unscaled->update(); @@ -740,12 +740,12 @@ void TileSetAtlasSourceEditor::_update_atlas_view() { Button *button = memnew(Button); alternative_tiles_control->add_child(button); button->set_flat(true); - button->set_icon(get_theme_icon("Add", "EditorIcons")); + button->set_icon(get_theme_icon(SNAME("Add"), SNAME("EditorIcons"))); button->add_theme_style_override("normal", memnew(StyleBoxEmpty)); button->add_theme_style_override("hover", memnew(StyleBoxEmpty)); button->add_theme_style_override("focus", memnew(StyleBoxEmpty)); button->add_theme_style_override("pressed", memnew(StyleBoxEmpty)); - button->connect("pressed", callable_mp(tile_set_atlas_source, &TileSetAtlasSource::create_alternative_tile), varray(tile_id, -1)); + button->connect("pressed", callable_mp(tile_set_atlas_source, &TileSetAtlasSource::create_alternative_tile), varray(tile_id, TileSetSource::INVALID_TILE_ALTERNATIVE)); button->set_rect(Rect2(Vector2(pos.x, pos.y + (y_increment - texture_region_base_size.y) / 2.0), Vector2(texture_region_base_size_min, texture_region_base_size_min))); button->set_expand_icon(true); @@ -1858,7 +1858,7 @@ void TileSetAtlasSourceEditor::_atlas_source_proxy_object_changed(String p_what) if (p_what == "texture" && !atlas_source_proxy_object->get("texture").is_null()) { confirm_auto_create_tiles->popup_centered(); } else if (p_what == "id") { - emit_signal("source_id_changed", atlas_source_proxy_object->get_id()); + emit_signal(SNAME("source_id_changed"), atlas_source_proxy_object->get_id()); } } @@ -2049,16 +2049,16 @@ void TileSetAtlasSourceEditor::_notification(int p_what) { switch (p_what) { case NOTIFICATION_ENTER_TREE: case NOTIFICATION_THEME_CHANGED: - tool_setup_atlas_source_button->set_icon(get_theme_icon("Tools", "EditorIcons")); - tool_select_button->set_icon(get_theme_icon("ToolSelect", "EditorIcons")); - tool_paint_button->set_icon(get_theme_icon("CanvasItem", "EditorIcons")); + tool_setup_atlas_source_button->set_icon(get_theme_icon(SNAME("Tools"), SNAME("EditorIcons"))); + tool_select_button->set_icon(get_theme_icon(SNAME("ToolSelect"), SNAME("EditorIcons"))); + tool_paint_button->set_icon(get_theme_icon(SNAME("CanvasItem"), SNAME("EditorIcons"))); - tools_settings_erase_button->set_icon(get_theme_icon("Eraser", "EditorIcons")); + tools_settings_erase_button->set_icon(get_theme_icon(SNAME("Eraser"), SNAME("EditorIcons"))); - tool_advanced_menu_buttom->set_icon(get_theme_icon("GuiTabMenu", "EditorIcons")); + tool_advanced_menu_buttom->set_icon(get_theme_icon(SNAME("GuiTabMenuHl"), SNAME("EditorIcons"))); - resize_handle = get_theme_icon("EditorHandle", "EditorIcons"); - resize_handle_disabled = get_theme_icon("EditorHandleDisabled", "EditorIcons"); + resize_handle = get_theme_icon(SNAME("EditorHandle"), SNAME("EditorIcons")); + resize_handle_disabled = get_theme_icon(SNAME("EditorHandleDisabled"), SNAME("EditorIcons")); break; case NOTIFICATION_INTERNAL_PROCESS: if (tile_set_atlas_source_changed_needs_update) { @@ -2176,7 +2176,7 @@ TileSetAtlasSourceEditor::TileSetAtlasSourceEditor() { // -- Dialogs -- confirm_auto_create_tiles = memnew(AcceptDialog); - confirm_auto_create_tiles->set_title(TTR("Create tiles automatically in non-transparent texture regions?")); + confirm_auto_create_tiles->set_title(TTR("Auto Create Tiles in Non-Transparent Texture Regions?")); confirm_auto_create_tiles->set_text(TTR("The atlas's texture was modified.\nWould you like to automatically create tiles in the atlas?")); confirm_auto_create_tiles->get_ok_button()->set_text(TTR("Yes")); confirm_auto_create_tiles->add_cancel_button()->set_text(TTR("No")); @@ -2202,7 +2202,7 @@ TileSetAtlasSourceEditor::TileSetAtlasSourceEditor() { tool_setup_atlas_source_button->set_toggle_mode(true); tool_setup_atlas_source_button->set_pressed(true); tool_setup_atlas_source_button->set_button_group(tools_button_group); - tool_setup_atlas_source_button->set_tooltip(TTR("Atlas Setup. Add/Remove tiles tool (use the shift key to create big tiles, control for rectangle editing).")); + tool_setup_atlas_source_button->set_tooltip(TTR("Atlas setup. Add/Remove tiles tool (use the shift key to create big tiles, control for rectangle editing).")); toolbox->add_child(tool_setup_atlas_source_button); tool_select_button = memnew(Button); diff --git a/editor/plugins/tiles/tile_set_atlas_source_editor.h b/editor/plugins/tiles/tile_set_atlas_source_editor.h index dbb0756a16..501416c340 100644 --- a/editor/plugins/tiles/tile_set_atlas_source_editor.h +++ b/editor/plugins/tiles/tile_set_atlas_source_editor.h @@ -65,7 +65,7 @@ private: private: Ref<TileSet> tile_set; TileSetAtlasSource *tile_set_atlas_source = nullptr; - int source_id = -1; + int source_id = TileSet::INVALID_SOURCE; protected: bool _set(const StringName &p_name, const Variant &p_value); @@ -108,7 +108,7 @@ private: Ref<TileSet> tile_set; TileSetAtlasSource *tile_set_atlas_source = nullptr; - int tile_set_atlas_source_id = -1; + int tile_set_atlas_source_id = TileSet::INVALID_SOURCE; UndoRedo *undo_redo = EditorNode::get_undo_redo(); diff --git a/editor/plugins/tiles/tile_set_editor.cpp b/editor/plugins/tiles/tile_set_editor.cpp index 2c2ebd107f..ba98a7d6b3 100644 --- a/editor/plugins/tiles/tile_set_editor.cpp +++ b/editor/plugins/tiles/tile_set_editor.cpp @@ -50,7 +50,7 @@ void TileSetEditor::drop_data_fw(const Point2 &p_point, const Variant &p_data, C if (p_from == sources_list) { // Handle dropping a texture in the list of atlas resources. - int source_id = -1; + int source_id = TileSet::INVALID_SOURCE; int added = 0; Dictionary d = p_data; Vector<String> files = d["files"]; @@ -77,7 +77,7 @@ void TileSetEditor::drop_data_fw(const Point2 &p_point, const Variant &p_data, C } // Update the selected source (thus triggering an update). - _update_atlas_sources_list(source_id); + _update_sources_list(source_id); } } @@ -114,11 +114,11 @@ bool TileSetEditor::can_drop_data_fw(const Point2 &p_point, const Variant &p_dat return false; } -void TileSetEditor::_update_atlas_sources_list(int force_selected_id) { +void TileSetEditor::_update_sources_list(int force_selected_id) { ERR_FAIL_COND(!tile_set.is_valid()); // Get the previously selected id. - int old_selected = -1; + int old_selected = TileSet::INVALID_SOURCE; if (sources_list->get_current() >= 0) { int source_id = sources_list->get_item_metadata(sources_list->get_current()); if (tile_set->has_source(source_id)) { @@ -126,7 +126,7 @@ void TileSetEditor::_update_atlas_sources_list(int force_selected_id) { } } - int to_select = -1; + int to_select = TileSet::INVALID_SOURCE; if (force_selected_id >= 0) { to_select = force_selected_id; } else if (old_selected >= 0) { @@ -159,7 +159,7 @@ void TileSetEditor::_update_atlas_sources_list(int force_selected_id) { // Scene collection source. TileSetScenesCollectionSource *scene_collection_source = Object::cast_to<TileSetScenesCollectionSource>(source); if (scene_collection_source) { - texture = get_theme_icon("PackedScene", "EditorIcons"); + texture = get_theme_icon(SNAME("PackedScene"), SNAME("EditorIcons")); item_text = vformat(TTR("Scene Collection Source (id:%d)"), source_id); } @@ -181,7 +181,7 @@ void TileSetEditor::_update_atlas_sources_list(int force_selected_id) { if ((int)sources_list->get_item_metadata(i) == to_select) { sources_list->set_current(i); if (old_selected != to_select) { - sources_list->emit_signal("item_selected", sources_list->get_current()); + sources_list->emit_signal(SNAME("item_selected"), sources_list->get_current()); } break; } @@ -192,7 +192,7 @@ void TileSetEditor::_update_atlas_sources_list(int force_selected_id) { if (sources_list->get_current() < 0 && sources_list->get_item_count() > 0) { sources_list->set_current(0); if (old_selected != int(sources_list->get_item_metadata(0))) { - sources_list->emit_signal("item_selected", sources_list->get_current()); + sources_list->emit_signal(SNAME("item_selected"), sources_list->get_current()); } } @@ -200,7 +200,7 @@ void TileSetEditor::_update_atlas_sources_list(int force_selected_id) { _source_selected(sources_list->get_current()); // Synchronize the lists. - TilesEditor::get_singleton()->set_atlas_sources_lists_current(sources_list->get_current()); + TilesEditor::get_singleton()->set_sources_lists_current(sources_list->get_current()); } void TileSetEditor::_source_selected(int p_source_index) { @@ -235,6 +235,23 @@ void TileSetEditor::_source_selected(int p_source_index) { } } +void TileSetEditor::_source_delete_pressed() { + ERR_FAIL_COND(!tile_set.is_valid()); + + // Update the selected source. + int to_delete = sources_list->get_item_metadata(sources_list->get_current()); + + Ref<TileSetSource> source = tile_set->get_source(to_delete); + + // Remove the source. + undo_redo->create_action(TTR("Remove source")); + undo_redo->add_do_method(*tile_set, "remove_source", to_delete); + undo_redo->add_undo_method(*tile_set, "add_source", source, to_delete); + undo_redo->commit_action(); + + _update_sources_list(); +} + void TileSetEditor::_source_add_id_pressed(int p_id_pressed) { ERR_FAIL_COND(!tile_set.is_valid()); @@ -251,7 +268,7 @@ void TileSetEditor::_source_add_id_pressed(int p_id_pressed) { undo_redo->add_undo_method(*tile_set, "remove_source", source_id); undo_redo->commit_action(); - _update_atlas_sources_list(source_id); + _update_sources_list(source_id); } break; case 1: { int source_id = tile_set->get_next_source_id(); @@ -264,44 +281,43 @@ void TileSetEditor::_source_add_id_pressed(int p_id_pressed) { undo_redo->add_undo_method(*tile_set, "remove_source", source_id); undo_redo->commit_action(); - _update_atlas_sources_list(source_id); + _update_sources_list(source_id); } break; default: ERR_FAIL(); } } -void TileSetEditor::_source_delete_pressed() { +void TileSetEditor::_sources_advanced_menu_id_pressed(int p_id_pressed) { ERR_FAIL_COND(!tile_set.is_valid()); - // Update the selected source. - int to_delete = sources_list->get_item_metadata(sources_list->get_current()); - - Ref<TileSetSource> source = tile_set->get_source(to_delete); - - // Remove the source. - undo_redo->create_action(TTR("Remove source")); - undo_redo->add_do_method(*tile_set, "remove_source", to_delete); - undo_redo->add_undo_method(*tile_set, "add_source", source, to_delete); - undo_redo->commit_action(); - - _update_atlas_sources_list(); + switch (p_id_pressed) { + case 0: { + atlas_merging_dialog->update_tile_set(tile_set); + atlas_merging_dialog->popup_centered_ratio(0.5); + } break; + case 1: { + tile_proxies_manager_dialog->update_tile_set(tile_set); + tile_proxies_manager_dialog->popup_centered_ratio(0.5); + } break; + } } void TileSetEditor::_notification(int p_what) { switch (p_what) { case NOTIFICATION_ENTER_TREE: case NOTIFICATION_THEME_CHANGED: - sources_delete_button->set_icon(get_theme_icon("Remove", "EditorIcons")); - sources_add_button->set_icon(get_theme_icon("Add", "EditorIcons")); - missing_texture_texture = get_theme_icon("TileSet", "EditorIcons"); + sources_delete_button->set_icon(get_theme_icon(SNAME("Remove"), SNAME("EditorIcons"))); + sources_add_button->set_icon(get_theme_icon(SNAME("Add"), SNAME("EditorIcons"))); + sources_advanced_menu_button->set_icon(get_theme_icon(SNAME("GuiTabMenuHl"), SNAME("EditorIcons"))); + missing_texture_texture = get_theme_icon(SNAME("TileSet"), SNAME("EditorIcons")); break; case NOTIFICATION_INTERNAL_PROCESS: if (tile_set_changed_needs_update) { if (tile_set.is_valid()) { tile_set->set_edited(true); } - _update_atlas_sources_list(); + _update_sources_list(); tile_set_changed_needs_update = false; } break; @@ -414,7 +430,7 @@ void TileSetEditor::edit(Ref<TileSet> p_tile_set) { // Add the listener again. if (tile_set.is_valid()) { tile_set->connect("changed", callable_mp(this, &TileSetEditor::_tile_set_changed)); - _update_atlas_sources_list(); + _update_sources_list(); } tile_set_atlas_source_editor->hide(); @@ -447,8 +463,8 @@ TileSetEditor::TileSetEditor() { sources_list->set_h_size_flags(SIZE_EXPAND_FILL); sources_list->set_v_size_flags(SIZE_EXPAND_FILL); sources_list->connect("item_selected", callable_mp(this, &TileSetEditor::_source_selected)); - sources_list->connect("item_selected", callable_mp(TilesEditor::get_singleton(), &TilesEditor::set_atlas_sources_lists_current)); - sources_list->connect("visibility_changed", callable_mp(TilesEditor::get_singleton(), &TilesEditor::synchronize_atlas_sources_list), varray(sources_list)); + sources_list->connect("item_selected", callable_mp(TilesEditor::get_singleton(), &TilesEditor::set_sources_lists_current)); + sources_list->connect("visibility_changed", callable_mp(TilesEditor::get_singleton(), &TilesEditor::synchronize_sources_list), varray(sources_list)); sources_list->set_texture_filter(CanvasItem::TEXTURE_FILTER_NEAREST); sources_list->set_drag_forwarding(this); split_container_left_side->add_child(sources_list); @@ -470,6 +486,19 @@ TileSetEditor::TileSetEditor() { sources_add_button->get_popup()->connect("id_pressed", callable_mp(this, &TileSetEditor::_source_add_id_pressed)); sources_bottom_actions->add_child(sources_add_button); + sources_advanced_menu_button = memnew(MenuButton); + sources_advanced_menu_button->set_flat(true); + sources_advanced_menu_button->get_popup()->add_item(TTR("Open Atlas Merging Tool")); + sources_advanced_menu_button->get_popup()->add_item(TTR("Manage Tile Proxies")); + sources_advanced_menu_button->get_popup()->connect("id_pressed", callable_mp(this, &TileSetEditor::_sources_advanced_menu_id_pressed)); + sources_bottom_actions->add_child(sources_advanced_menu_button); + + atlas_merging_dialog = memnew(AtlasMergingDialog); + add_child(atlas_merging_dialog); + + tile_proxies_manager_dialog = memnew(TileProxiesManagerDialog); + add_child(tile_proxies_manager_dialog); + // Right side container. VBoxContainer *split_container_right_side = memnew(VBoxContainer); split_container_right_side->set_h_size_flags(SIZE_EXPAND_FILL); @@ -489,7 +518,7 @@ TileSetEditor::TileSetEditor() { tile_set_atlas_source_editor = memnew(TileSetAtlasSourceEditor); tile_set_atlas_source_editor->set_h_size_flags(SIZE_EXPAND_FILL); tile_set_atlas_source_editor->set_v_size_flags(SIZE_EXPAND_FILL); - tile_set_atlas_source_editor->connect("source_id_changed", callable_mp(this, &TileSetEditor::_update_atlas_sources_list)); + tile_set_atlas_source_editor->connect("source_id_changed", callable_mp(this, &TileSetEditor::_update_sources_list)); split_container_right_side->add_child(tile_set_atlas_source_editor); tile_set_atlas_source_editor->hide(); @@ -497,7 +526,7 @@ TileSetEditor::TileSetEditor() { tile_set_scenes_collection_source_editor = memnew(TileSetScenesCollectionSourceEditor); tile_set_scenes_collection_source_editor->set_h_size_flags(SIZE_EXPAND_FILL); tile_set_scenes_collection_source_editor->set_v_size_flags(SIZE_EXPAND_FILL); - tile_set_scenes_collection_source_editor->connect("source_id_changed", callable_mp(this, &TileSetEditor::_update_atlas_sources_list)); + tile_set_scenes_collection_source_editor->connect("source_id_changed", callable_mp(this, &TileSetEditor::_update_sources_list)); split_container_right_side->add_child(tile_set_scenes_collection_source_editor); tile_set_scenes_collection_source_editor->hide(); diff --git a/editor/plugins/tiles/tile_set_editor.h b/editor/plugins/tiles/tile_set_editor.h index 9e50aca62f..970e3fabb6 100644 --- a/editor/plugins/tiles/tile_set_editor.h +++ b/editor/plugins/tiles/tile_set_editor.h @@ -31,8 +31,10 @@ #ifndef TILE_SET_EDITOR_H #define TILE_SET_EDITOR_H +#include "atlas_merging_dialog.h" #include "scene/gui/box_container.h" #include "scene/resources/tile_set.h" +#include "tile_proxies_manager_dialog.h" #include "tile_set_atlas_source_editor.h" #include "tile_set_scenes_collection_source_editor.h" @@ -51,16 +53,21 @@ private: UndoRedo *undo_redo = EditorNode::get_undo_redo(); - void _update_atlas_sources_list(int force_selected_id = -1); + void _update_sources_list(int force_selected_id = -1); - // -- Sources management -- + // Sources management. Button *sources_delete_button; MenuButton *sources_add_button; + MenuButton *sources_advanced_menu_button; ItemList *sources_list; Ref<Texture2D> missing_texture_texture; void _source_selected(int p_source_index); - void _source_add_id_pressed(int p_id_pressed); void _source_delete_pressed(); + void _source_add_id_pressed(int p_id_pressed); + void _sources_advanced_menu_id_pressed(int p_id_pressed); + + AtlasMergingDialog *atlas_merging_dialog; + TileProxiesManagerDialog *tile_proxies_manager_dialog; void _tile_set_changed(); diff --git a/editor/plugins/tiles/tile_set_scenes_collection_source_editor.cpp b/editor/plugins/tiles/tile_set_scenes_collection_source_editor.cpp index 568d4ca8d7..f74b3bf9c2 100644 --- a/editor/plugins/tiles/tile_set_scenes_collection_source_editor.cpp +++ b/editor/plugins/tiles/tile_set_scenes_collection_source_editor.cpp @@ -48,7 +48,7 @@ void TileSetScenesCollectionSourceEditor::TileSetScenesCollectionProxyObject::se int previous_source = source_id; source_id = p_id; // source_id must be updated before, because it's used by the source list update. tile_set->set_source_id(previous_source, p_id); - emit_signal("changed", "id"); + emit_signal(SNAME("changed"), "id"); } int TileSetScenesCollectionSourceEditor::TileSetScenesCollectionProxyObject::get_id() { @@ -59,7 +59,7 @@ bool TileSetScenesCollectionSourceEditor::TileSetScenesCollectionProxyObject::_s bool valid = false; tile_set_scenes_collection_source->set(p_name, p_value, &valid); if (valid) { - emit_signal("changed", String(p_name).utf8().get_data()); + emit_signal(SNAME("changed"), String(p_name).utf8().get_data()); } return valid; } @@ -120,7 +120,7 @@ bool TileSetScenesCollectionSourceEditor::SceneTileProxyObject::_set(const Strin ERR_FAIL_COND_V(tile_set_scenes_collection_source->has_scene_tile_id(as_int), false); tile_set_scenes_collection_source->set_scene_tile_id(scene_id, as_int); scene_id = as_int; - emit_signal("changed", "id"); + emit_signal(SNAME("changed"), "id"); for (int i = 0; i < tile_set_scenes_collection_source_editor->scene_tiles_list->get_item_count(); i++) { if (int(tile_set_scenes_collection_source_editor->scene_tiles_list->get_item_metadata(i)) == scene_id) { tile_set_scenes_collection_source_editor->scene_tiles_list->select(i); @@ -130,11 +130,11 @@ bool TileSetScenesCollectionSourceEditor::SceneTileProxyObject::_set(const Strin return true; } else if (p_name == "scene") { tile_set_scenes_collection_source->set_scene_tile_scene(scene_id, p_value); - emit_signal("changed", "scene"); + emit_signal(SNAME("changed"), "scene"); return true; } else if (p_name == "display_placeholder") { tile_set_scenes_collection_source->set_scene_tile_display_placeholder(scene_id, p_value); - emit_signal("changed", "display_placeholder"); + emit_signal(SNAME("changed"), "display_placeholder"); return true; } @@ -186,7 +186,7 @@ void TileSetScenesCollectionSourceEditor::SceneTileProxyObject::_bind_methods() void TileSetScenesCollectionSourceEditor::_scenes_collection_source_proxy_object_changed(String p_what) { if (p_what == "id") { - emit_signal("source_id_changed", scenes_collection_source_proxy_object->get_id()); + emit_signal(SNAME("source_id_changed"), scenes_collection_source_proxy_object->get_id()); } } @@ -284,7 +284,7 @@ void TileSetScenesCollectionSourceEditor::_update_scenes_list() { Variant udata = i; EditorResourcePreview::get_singleton()->queue_edited_resource_preview(scene, this, "_scene_thumbnail_done", udata); } else { - item_index = scene_tiles_list->add_item(TTR("Tile with Invalid Scene"), get_theme_icon("PackedScene", "EditorIcons")); + item_index = scene_tiles_list->add_item(TTR("Tile with Invalid Scene"), get_theme_icon(SNAME("PackedScene"), SNAME("EditorIcons"))); } scene_tiles_list->set_item_metadata(item_index, scene_id); @@ -307,8 +307,8 @@ void TileSetScenesCollectionSourceEditor::_notification(int p_what) { switch (p_what) { case NOTIFICATION_ENTER_TREE: case NOTIFICATION_THEME_CHANGED: - scene_tile_add_button->set_icon(get_theme_icon("Add", "EditorIcons")); - scene_tile_delete_button->set_icon(get_theme_icon("Remove", "EditorIcons")); + scene_tile_add_button->set_icon(get_theme_icon(SNAME("Add"), SNAME("EditorIcons"))); + scene_tile_delete_button->set_icon(get_theme_icon(SNAME("Remove"), SNAME("EditorIcons"))); _update_scenes_list(); break; case NOTIFICATION_INTERNAL_PROCESS: diff --git a/editor/plugins/tiles/tiles_editor_plugin.cpp b/editor/plugins/tiles/tiles_editor_plugin.cpp index fb111efc17..79b869b511 100644 --- a/editor/plugins/tiles/tiles_editor_plugin.cpp +++ b/editor/plugins/tiles/tiles_editor_plugin.cpp @@ -50,7 +50,7 @@ void TilesEditor::_notification(int p_what) { switch (p_what) { case NOTIFICATION_ENTER_TREE: case NOTIFICATION_THEME_CHANGED: { - tileset_tilemap_switch_button->set_icon(get_theme_icon("TileSet", "EditorIcons")); + tileset_tilemap_switch_button->set_icon(get_theme_icon(SNAME("TileSet"), SNAME("EditorIcons"))); } break; case NOTIFICATION_INTERNAL_PROCESS: { if (tile_map_changed_needs_update) { @@ -118,11 +118,11 @@ void TilesEditor::_update_editors() { CanvasItemEditor::get_singleton()->update_viewport(); } -void TilesEditor::set_atlas_sources_lists_current(int p_current) { +void TilesEditor::set_sources_lists_current(int p_current) { atlas_sources_lists_current = p_current; } -void TilesEditor::synchronize_atlas_sources_list(Object *p_current) { +void TilesEditor::synchronize_sources_list(Object *p_current) { ItemList *item_list = Object::cast_to<ItemList>(p_current); ERR_FAIL_COND(!item_list); @@ -131,7 +131,7 @@ void TilesEditor::synchronize_atlas_sources_list(Object *p_current) { item_list->deselect_all(); } else { item_list->set_current(atlas_sources_lists_current); - item_list->emit_signal("item_selected", atlas_sources_lists_current); + item_list->emit_signal(SNAME("item_selected"), atlas_sources_lists_current); } } } diff --git a/editor/plugins/tiles/tiles_editor_plugin.h b/editor/plugins/tiles/tiles_editor_plugin.h index 6cc6f51598..f976d68938 100644 --- a/editor/plugins/tiles/tiles_editor_plugin.h +++ b/editor/plugins/tiles/tiles_editor_plugin.h @@ -76,8 +76,8 @@ public: void forward_canvas_draw_over_viewport(Control *p_overlay) { tilemap_editor->forward_canvas_draw_over_viewport(p_overlay); } // To synchronize the atlas sources lists. - void set_atlas_sources_lists_current(int p_current); - void synchronize_atlas_sources_list(Object *p_current); + void set_sources_lists_current(int p_current); + void synchronize_sources_list(Object *p_current); void set_atlas_view_transform(float p_zoom, Vector2 p_scroll); void synchronize_atlas_view(Object *p_current); diff --git a/editor/plugins/version_control_editor_plugin.cpp b/editor/plugins/version_control_editor_plugin.cpp index 49729812a8..a9a36427db 100644 --- a/editor/plugins/version_control_editor_plugin.cpp +++ b/editor/plugins/version_control_editor_plugin.cpp @@ -165,7 +165,7 @@ void VersionControlEditorPlugin::_refresh_stage_area() { _refresh_file_diff(); } } - commit_status->set_text("New changes detected"); + commit_status->set_text(TTR("New changes detected")); } } else { WARN_PRINT("No VCS addon is initialized. Select a Version Control Addon from Project menu."); @@ -185,11 +185,11 @@ void VersionControlEditorPlugin::_stage_selected() { while (file_entry) { if (file_entry->is_checked(0)) { EditorVCSInterface::get_singleton()->stage_file(file_entry->get_metadata(0)); - file_entry->set_icon_modulate(0, EditorNode::get_singleton()->get_gui_base()->get_theme_color("success_color", "Editor")); + file_entry->set_icon_modulate(0, EditorNode::get_singleton()->get_gui_base()->get_theme_color(SNAME("success_color"), SNAME("Editor"))); staged_files_count++; } else { EditorVCSInterface::get_singleton()->unstage_file(file_entry->get_metadata(0)); - file_entry->set_icon_modulate(0, EditorNode::get_singleton()->get_gui_base()->get_theme_color("error_color", "Editor")); + file_entry->set_icon_modulate(0, EditorNode::get_singleton()->get_gui_base()->get_theme_color(SNAME("error_color"), SNAME("Editor"))); } file_entry = file_entry->get_next(); @@ -211,7 +211,7 @@ void VersionControlEditorPlugin::_stage_all() { TreeItem *file_entry = root->get_first_child(); while (file_entry) { EditorVCSInterface::get_singleton()->stage_file(file_entry->get_metadata(0)); - file_entry->set_icon_modulate(0, EditorNode::get_singleton()->get_gui_base()->get_theme_color("success_color", "Editor")); + file_entry->set_icon_modulate(0, EditorNode::get_singleton()->get_gui_base()->get_theme_color(SNAME("success_color"), SNAME("Editor"))); file_entry->set_checked(0, true); staged_files_count++; @@ -236,16 +236,16 @@ void VersionControlEditorPlugin::_display_file_diff(String p_file_path) { diff_file_name->set_text(p_file_path); diff->clear(); - diff->push_font(EditorNode::get_singleton()->get_gui_base()->get_theme_font("source", "EditorFonts")); + diff->push_font(EditorNode::get_singleton()->get_gui_base()->get_theme_font(SNAME("source"), SNAME("EditorFonts"))); for (int i = 0; i < diff_content.size(); i++) { Dictionary line_result = diff_content[i]; if (line_result["status"] == "+") { - diff->push_color(EditorNode::get_singleton()->get_gui_base()->get_theme_color("success_color", "Editor")); + diff->push_color(EditorNode::get_singleton()->get_gui_base()->get_theme_color(SNAME("success_color"), SNAME("Editor"))); } else if (line_result["status"] == "-") { - diff->push_color(EditorNode::get_singleton()->get_gui_base()->get_theme_color("error_color", "Editor")); + diff->push_color(EditorNode::get_singleton()->get_gui_base()->get_theme_color(SNAME("error_color"), SNAME("Editor"))); } else { - diff->push_color(EditorNode::get_singleton()->get_gui_base()->get_theme_color("font_color", "Label")); + diff->push_color(EditorNode::get_singleton()->get_gui_base()->get_theme_color(SNAME("font_color"), SNAME("Label"))); } diff->add_text((String)line_result["content"]); @@ -271,9 +271,9 @@ void VersionControlEditorPlugin::_clear_file_diff() { void VersionControlEditorPlugin::_update_stage_status() { String status; if (staged_files_count == 1) { - status = "Stage contains 1 file"; + status = TTR("Stage contains 1 file"); } else { - status = "Stage contains " + String::num_int64(staged_files_count) + " files"; + status = vformat(TTR("Stage contains %d files"), staged_files_count); } commit_status->set_text(status); } @@ -281,9 +281,9 @@ void VersionControlEditorPlugin::_update_stage_status() { void VersionControlEditorPlugin::_update_commit_status() { String status; if (staged_files_count == 1) { - status = "Committed 1 file"; + status = TTR("Committed 1 file"); } else { - status = "Committed " + String::num_int64(staged_files_count) + " files "; + status = vformat(TTR("Committed %d files"), staged_files_count); } commit_status->set_text(status); staged_files_count = 0; @@ -431,7 +431,7 @@ VersionControlEditorPlugin::VersionControlEditorPlugin() { refresh_button = memnew(Button); refresh_button->set_tooltip(TTR("Detect new changes")); refresh_button->set_text(TTR("Refresh")); - refresh_button->set_icon(EditorNode::get_singleton()->get_gui_base()->get_theme_icon("Reload", "EditorIcons")); + refresh_button->set_icon(EditorNode::get_singleton()->get_gui_base()->get_theme_icon(SNAME("Reload"), SNAME("EditorIcons"))); refresh_button->connect("pressed", callable_mp(this, &VersionControlEditorPlugin::_refresh_stage_area)); stage_tools->add_child(refresh_button); @@ -456,11 +456,11 @@ VersionControlEditorPlugin::VersionControlEditorPlugin() { change_type_to_strings[CHANGE_TYPE_DELETED] = TTR("Deleted"); change_type_to_strings[CHANGE_TYPE_TYPECHANGE] = TTR("Typechange"); - change_type_to_color[CHANGE_TYPE_NEW] = EditorNode::get_singleton()->get_gui_base()->get_theme_color("success_color", "Editor"); - change_type_to_color[CHANGE_TYPE_MODIFIED] = EditorNode::get_singleton()->get_gui_base()->get_theme_color("warning_color", "Editor"); - change_type_to_color[CHANGE_TYPE_RENAMED] = EditorNode::get_singleton()->get_gui_base()->get_theme_color("disabled_font_color", "Editor"); - change_type_to_color[CHANGE_TYPE_DELETED] = EditorNode::get_singleton()->get_gui_base()->get_theme_color("error_color", "Editor"); - change_type_to_color[CHANGE_TYPE_TYPECHANGE] = EditorNode::get_singleton()->get_gui_base()->get_theme_color("font_color", "Editor"); + change_type_to_color[CHANGE_TYPE_NEW] = EditorNode::get_singleton()->get_gui_base()->get_theme_color(SNAME("success_color"), SNAME("Editor")); + change_type_to_color[CHANGE_TYPE_MODIFIED] = EditorNode::get_singleton()->get_gui_base()->get_theme_color(SNAME("warning_color"), SNAME("Editor")); + change_type_to_color[CHANGE_TYPE_RENAMED] = EditorNode::get_singleton()->get_gui_base()->get_theme_color(SNAME("disabled_font_color"), SNAME("Editor")); + change_type_to_color[CHANGE_TYPE_DELETED] = EditorNode::get_singleton()->get_gui_base()->get_theme_color(SNAME("error_color"), SNAME("Editor")); + change_type_to_color[CHANGE_TYPE_TYPECHANGE] = EditorNode::get_singleton()->get_gui_base()->get_theme_color(SNAME("font_color"), SNAME("Editor")); stage_buttons = memnew(HSplitContainer); stage_buttons->set_dragger_visibility(SplitContainer::DRAGGER_HIDDEN_COLLAPSED); @@ -527,7 +527,7 @@ VersionControlEditorPlugin::VersionControlEditorPlugin() { diff_refresh_button = memnew(Button); diff_refresh_button->set_tooltip(TTR("Detect changes in file diff")); - diff_refresh_button->set_icon(EditorNode::get_singleton()->get_gui_base()->get_theme_icon("Reload", "EditorIcons")); + diff_refresh_button->set_icon(EditorNode::get_singleton()->get_gui_base()->get_theme_icon(SNAME("Reload"), SNAME("EditorIcons"))); diff_refresh_button->connect("pressed", callable_mp(this, &VersionControlEditorPlugin::_refresh_file_diff)); diff_hbc->add_child(diff_refresh_button); diff --git a/editor/plugins/visual_shader_editor_plugin.cpp b/editor/plugins/visual_shader_editor_plugin.cpp index f438d9bab8..add75d47fd 100644 --- a/editor/plugins/visual_shader_editor_plugin.cpp +++ b/editor/plugins/visual_shader_editor_plugin.cpp @@ -110,7 +110,7 @@ void VisualShaderGraphPlugin::_bind_methods() { ClassDB::bind_method("set_uniform_name", &VisualShaderGraphPlugin::set_uniform_name); ClassDB::bind_method("set_expression", &VisualShaderGraphPlugin::set_expression); ClassDB::bind_method("update_curve", &VisualShaderGraphPlugin::update_curve); - ClassDB::bind_method("update_curve3", &VisualShaderGraphPlugin::update_curve3); + ClassDB::bind_method("update_curve_xyz", &VisualShaderGraphPlugin::update_curve_xyz); ClassDB::bind_method("update_constant", &VisualShaderGraphPlugin::update_constant); } @@ -164,7 +164,7 @@ void VisualShaderGraphPlugin::show_port_preview(VisualShader::Type p_type, int p } void VisualShaderGraphPlugin::update_node_deferred(VisualShader::Type p_type, int p_node_id) { - call_deferred("update_node", p_type, p_node_id); + call_deferred(SNAME("update_node"), p_type, p_node_id); } void VisualShaderGraphPlugin::update_node(VisualShader::Type p_type, int p_node_id) { @@ -219,12 +219,12 @@ void VisualShaderGraphPlugin::update_curve(int p_node_id) { } } -void VisualShaderGraphPlugin::update_curve3(int p_node_id) { +void VisualShaderGraphPlugin::update_curve_xyz(int p_node_id) { if (links.has(p_node_id) && links[p_node_id].curve_editors[0] && links[p_node_id].curve_editors[1] && links[p_node_id].curve_editors[2]) { - if (((VisualShaderNodeCurve3Texture *)links[p_node_id].visual_node)->get_texture().is_valid()) { - links[p_node_id].curve_editors[0]->set_curve(((VisualShaderNodeCurve3Texture *)links[p_node_id].visual_node)->get_texture()->get_curve_x()); - links[p_node_id].curve_editors[1]->set_curve(((VisualShaderNodeCurve3Texture *)links[p_node_id].visual_node)->get_texture()->get_curve_y()); - links[p_node_id].curve_editors[2]->set_curve(((VisualShaderNodeCurve3Texture *)links[p_node_id].visual_node)->get_texture()->get_curve_z()); + if (((VisualShaderNodeCurveXYZTexture *)links[p_node_id].visual_node)->get_texture().is_valid()) { + links[p_node_id].curve_editors[0]->set_curve(((VisualShaderNodeCurveXYZTexture *)links[p_node_id].visual_node)->get_texture()->get_curve_x()); + links[p_node_id].curve_editors[1]->set_curve(((VisualShaderNodeCurveXYZTexture *)links[p_node_id].visual_node)->get_texture()->get_curve_y()); + links[p_node_id].curve_editors[2]->set_curve(((VisualShaderNodeCurveXYZTexture *)links[p_node_id].visual_node)->get_texture()->get_curve_z()); } } } @@ -335,9 +335,9 @@ void VisualShaderGraphPlugin::register_uniform_name(int p_node_id, LineEdit *p_u } void VisualShaderGraphPlugin::update_theme() { - vector_expanded_color[0] = VisualShaderEditor::get_singleton()->get_theme_color("axis_x_color", "Editor"); // red - vector_expanded_color[1] = VisualShaderEditor::get_singleton()->get_theme_color("axis_y_color", "Editor"); // green - vector_expanded_color[2] = VisualShaderEditor::get_singleton()->get_theme_color("axis_z_color", "Editor"); // blue + vector_expanded_color[0] = VisualShaderEditor::get_singleton()->get_theme_color(SNAME("axis_x_color"), SNAME("Editor")); // red + vector_expanded_color[1] = VisualShaderEditor::get_singleton()->get_theme_color(SNAME("axis_y_color"), SNAME("Editor")); // green + vector_expanded_color[2] = VisualShaderEditor::get_singleton()->get_theme_color(SNAME("axis_z_color"), SNAME("Editor")); // blue } void VisualShaderGraphPlugin::add_node(VisualShader::Type p_type, int p_id) { @@ -465,7 +465,7 @@ void VisualShaderGraphPlugin::add_node(VisualShader::Type p_type, int p_id) { vsnode->remove_meta("shader_type"); if (custom_editor) { if (vsnode->is_show_prop_names()) { - custom_editor->call_deferred("_show_prop_names", true); + custom_editor->call_deferred(SNAME("_show_prop_names"), true); } break; } @@ -483,10 +483,10 @@ void VisualShaderGraphPlugin::add_node(VisualShader::Type p_type, int p_id) { custom_editor = hbox; } - Ref<VisualShaderNodeCurve3Texture> curve3 = vsnode; - if (curve3.is_valid()) { - if (curve3->get_texture().is_valid() && !curve3->get_texture()->is_connected("changed", callable_mp(VisualShaderEditor::get_singleton()->get_graph_plugin(), &VisualShaderGraphPlugin::update_curve3))) { - curve3->get_texture()->connect("changed", callable_mp(VisualShaderEditor::get_singleton()->get_graph_plugin(), &VisualShaderGraphPlugin::update_curve3), varray(p_id)); + Ref<VisualShaderNodeCurveXYZTexture> curve_xyz = vsnode; + if (curve_xyz.is_valid()) { + if (curve_xyz->get_texture().is_valid() && !curve_xyz->get_texture()->is_connected("changed", callable_mp(VisualShaderEditor::get_singleton()->get_graph_plugin(), &VisualShaderGraphPlugin::update_curve_xyz))) { + curve_xyz->get_texture()->connect("changed", callable_mp(VisualShaderEditor::get_singleton()->get_graph_plugin(), &VisualShaderGraphPlugin::update_curve_xyz), varray(p_id)); } HBoxContainer *hbox = memnew(HBoxContainer); @@ -518,7 +518,7 @@ void VisualShaderGraphPlugin::add_node(VisualShader::Type p_type, int p_id) { port_offset++; node->add_child(custom_editor); - bool is_curve = curve.is_valid() || curve3.is_valid(); + bool is_curve = curve.is_valid() || curve_xyz.is_valid(); if (is_curve) { VisualShaderEditor::get_singleton()->graph->add_child(node); @@ -526,8 +526,8 @@ void VisualShaderGraphPlugin::add_node(VisualShader::Type p_type, int p_id) { TextureButton *preview = memnew(TextureButton); preview->set_toggle_mode(true); - preview->set_normal_texture(VisualShaderEditor::get_singleton()->get_theme_icon("GuiVisibilityHidden", "EditorIcons")); - preview->set_pressed_texture(VisualShaderEditor::get_singleton()->get_theme_icon("GuiVisibilityVisible", "EditorIcons")); + preview->set_normal_texture(VisualShaderEditor::get_singleton()->get_theme_icon(SNAME("GuiVisibilityHidden"), SNAME("EditorIcons"))); + preview->set_pressed_texture(VisualShaderEditor::get_singleton()->get_theme_icon(SNAME("GuiVisibilityVisible"), SNAME("EditorIcons"))); preview->set_v_size_flags(Control::SIZE_SHRINK_CENTER); register_output_port(p_id, 0, preview); @@ -551,14 +551,14 @@ void VisualShaderGraphPlugin::add_node(VisualShader::Type p_type, int p_id) { } } - if (curve3.is_valid()) { + if (curve_xyz.is_valid()) { CurveEditor *curve_editor_x = memnew(CurveEditor); node->add_child(curve_editor_x); register_curve_editor(p_id, 0, curve_editor_x); curve_editor_x->set_custom_minimum_size(Size2(300, 0)); curve_editor_x->set_h_size_flags(Control::SIZE_EXPAND_FILL); - if (curve3->get_texture().is_valid()) { - curve_editor_x->set_curve(curve3->get_texture()->get_curve_x()); + if (curve_xyz->get_texture().is_valid()) { + curve_editor_x->set_curve(curve_xyz->get_texture()->get_curve_x()); } CurveEditor *curve_editor_y = memnew(CurveEditor); @@ -566,8 +566,8 @@ void VisualShaderGraphPlugin::add_node(VisualShader::Type p_type, int p_id) { register_curve_editor(p_id, 1, curve_editor_y); curve_editor_y->set_custom_minimum_size(Size2(300, 0)); curve_editor_y->set_h_size_flags(Control::SIZE_EXPAND_FILL); - if (curve3->get_texture().is_valid()) { - curve_editor_y->set_curve(curve3->get_texture()->get_curve_y()); + if (curve_xyz->get_texture().is_valid()) { + curve_editor_y->set_curve(curve_xyz->get_texture()->get_curve_y()); } CurveEditor *curve_editor_z = memnew(CurveEditor); @@ -575,8 +575,8 @@ void VisualShaderGraphPlugin::add_node(VisualShader::Type p_type, int p_id) { register_curve_editor(p_id, 2, curve_editor_z); curve_editor_z->set_custom_minimum_size(Size2(300, 0)); curve_editor_z->set_h_size_flags(Control::SIZE_EXPAND_FILL); - if (curve3->get_texture().is_valid()) { - curve_editor_z->set_curve(curve3->get_texture()->get_curve_z()); + if (curve_xyz->get_texture().is_valid()) { + curve_editor_z->set_curve(curve_xyz->get_texture()->get_curve_z()); } } @@ -585,7 +585,7 @@ void VisualShaderGraphPlugin::add_node(VisualShader::Type p_type, int p_id) { VisualShaderNode::PortType port_right = vsnode->get_output_port_type(0); node->set_slot(0, true, port_left, type_color[port_left], true, port_right, type_color[port_right]); - VisualShaderEditor::get_singleton()->call_deferred("_set_node_size", (int)p_type, p_id, size); + VisualShaderEditor::get_singleton()->call_deferred(SNAME("_set_node_size"), (int)p_type, p_id, size); } if (vsnode->is_use_prop_slots()) { @@ -666,8 +666,8 @@ void VisualShaderGraphPlugin::add_node(VisualShader::Type p_type, int p_id) { if (valid_left) { name_left = vsnode->get_input_port_name(i); port_left = vsnode->get_input_port_type(i); - for (List<VisualShader::Connection>::Element *E = connections.front(); E; E = E->next()) { - if (E->get().to_node == p_id && E->get().to_port == j) { + for (const VisualShader::Connection &E : connections) { + if (E.to_node == p_id && E.to_port == j) { port_left_used = true; } } @@ -733,7 +733,7 @@ void VisualShaderGraphPlugin::add_node(VisualShader::Type p_type, int p_id) { name_box->connect("focus_exited", callable_mp(VisualShaderEditor::get_singleton(), &VisualShaderEditor::_port_name_focus_out), varray(name_box, p_id, i, false), CONNECT_DEFERRED); Button *remove_btn = memnew(Button); - remove_btn->set_icon(EditorNode::get_singleton()->get_gui_base()->get_theme_icon("Remove", "EditorIcons")); + remove_btn->set_icon(EditorNode::get_singleton()->get_gui_base()->get_theme_icon(SNAME("Remove"), SNAME("EditorIcons"))); remove_btn->set_tooltip(TTR("Remove") + " " + name_left); remove_btn->connect("pressed", callable_mp(VisualShaderEditor::get_singleton(), &VisualShaderEditor::_remove_input_port), varray(p_id, i), CONNECT_DEFERRED); hb->add_child(remove_btn); @@ -746,7 +746,7 @@ void VisualShaderGraphPlugin::add_node(VisualShader::Type p_type, int p_id) { if (vsnode->get_input_port_default_hint(i) != "" && !port_left_used) { Label *hint_label = memnew(Label); hint_label->set_text("[" + vsnode->get_input_port_default_hint(i) + "]"); - hint_label->add_theme_color_override("font_color", VisualShaderEditor::get_singleton()->get_theme_color("font_readonly_color", "TextEdit")); + hint_label->add_theme_color_override("font_color", VisualShaderEditor::get_singleton()->get_theme_color(SNAME("font_readonly_color"), SNAME("TextEdit"))); hint_label->add_theme_style_override("normal", label_style); hb->add_child(hint_label); } @@ -760,7 +760,7 @@ void VisualShaderGraphPlugin::add_node(VisualShader::Type p_type, int p_id) { if (valid_right) { if (is_group) { Button *remove_btn = memnew(Button); - remove_btn->set_icon(EditorNode::get_singleton()->get_gui_base()->get_theme_icon("Remove", "EditorIcons")); + remove_btn->set_icon(EditorNode::get_singleton()->get_gui_base()->get_theme_icon(SNAME("Remove"), SNAME("EditorIcons"))); remove_btn->set_tooltip(TTR("Remove") + " " + name_left); remove_btn->connect("pressed", callable_mp(VisualShaderEditor::get_singleton(), &VisualShaderEditor::_remove_output_port), varray(p_id, i), CONNECT_DEFERRED); hb->add_child(remove_btn); @@ -796,8 +796,8 @@ void VisualShaderGraphPlugin::add_node(VisualShader::Type p_type, int p_id) { if (vsnode->is_output_port_expandable(i)) { TextureButton *expand = memnew(TextureButton); expand->set_toggle_mode(true); - expand->set_normal_texture(VisualShaderEditor::get_singleton()->get_theme_icon("GuiTreeArrowDown", "EditorIcons")); - expand->set_pressed_texture(VisualShaderEditor::get_singleton()->get_theme_icon("GuiTreeArrowRight", "EditorIcons")); + expand->set_normal_texture(VisualShaderEditor::get_singleton()->get_theme_icon(SNAME("GuiTreeArrowDown"), SNAME("EditorIcons"))); + expand->set_pressed_texture(VisualShaderEditor::get_singleton()->get_theme_icon(SNAME("GuiTreeArrowRight"), SNAME("EditorIcons"))); expand->set_v_size_flags(Control::SIZE_SHRINK_CENTER); expand->set_pressed(vsnode->_is_output_port_expanded(i)); expand->connect("pressed", callable_mp(VisualShaderEditor::get_singleton(), &VisualShaderEditor::_expand_output_port), varray(p_id, i, !vsnode->_is_output_port_expanded(i)), CONNECT_DEFERRED); @@ -806,8 +806,8 @@ void VisualShaderGraphPlugin::add_node(VisualShader::Type p_type, int p_id) { if (visual_shader->get_shader_type() == VisualShader::TYPE_FRAGMENT && port_right != VisualShaderNode::PORT_TYPE_TRANSFORM && port_right != VisualShaderNode::PORT_TYPE_SAMPLER) { TextureButton *preview = memnew(TextureButton); preview->set_toggle_mode(true); - preview->set_normal_texture(VisualShaderEditor::get_singleton()->get_theme_icon("GuiVisibilityHidden", "EditorIcons")); - preview->set_pressed_texture(VisualShaderEditor::get_singleton()->get_theme_icon("GuiVisibilityVisible", "EditorIcons")); + preview->set_normal_texture(VisualShaderEditor::get_singleton()->get_theme_icon(SNAME("GuiVisibilityHidden"), SNAME("EditorIcons"))); + preview->set_pressed_texture(VisualShaderEditor::get_singleton()->get_theme_icon(SNAME("GuiVisibilityVisible"), SNAME("EditorIcons"))); preview->set_v_size_flags(Control::SIZE_SHRINK_CENTER); register_output_port(p_id, j, preview); @@ -873,7 +873,7 @@ void VisualShaderGraphPlugin::add_node(VisualShader::Type p_type, int p_id) { String error = vsnode->get_warning(visual_shader->get_mode(), p_type); if (error != String()) { Label *error_label = memnew(Label); - error_label->add_theme_color_override("font_color", VisualShaderEditor::get_singleton()->get_theme_color("error_color", "Editor")); + error_label->add_theme_color_override("font_color", VisualShaderEditor::get_singleton()->get_theme_color(SNAME("error_color"), SNAME("Editor"))); error_label->set_text(error); node->add_child(error_label); } @@ -899,16 +899,16 @@ void VisualShaderGraphPlugin::add_node(VisualShader::Type p_type, int p_id) { expression_box->set_syntax_highlighter(expression_syntax_highlighter); expression_box->add_theme_color_override("background_color", background_color); - for (List<String>::Element *E = VisualShaderEditor::get_singleton()->keyword_list.front(); E; E = E->next()) { - if (ShaderLanguage::is_control_flow_keyword(E->get())) { - expression_syntax_highlighter->add_keyword_color(E->get(), control_flow_keyword_color); + for (const String &E : VisualShaderEditor::get_singleton()->keyword_list) { + if (ShaderLanguage::is_control_flow_keyword(E)) { + expression_syntax_highlighter->add_keyword_color(E, control_flow_keyword_color); } else { - expression_syntax_highlighter->add_keyword_color(E->get(), keyword_color); + expression_syntax_highlighter->add_keyword_color(E, keyword_color); } } - expression_box->add_theme_font_override("font", VisualShaderEditor::get_singleton()->get_theme_font("expression", "EditorFonts")); - expression_box->add_theme_font_size_override("font_size", VisualShaderEditor::get_singleton()->get_theme_font_size("expression_size", "EditorFonts")); + expression_box->add_theme_font_override("font", VisualShaderEditor::get_singleton()->get_theme_font(SNAME("expression"), SNAME("EditorFonts"))); + expression_box->add_theme_font_size_override("font_size", VisualShaderEditor::get_singleton()->get_theme_font_size(SNAME("expression_size"), SNAME("EditorFonts"))); expression_box->add_theme_color_override("font_color", text_color); expression_syntax_highlighter->set_number_color(number_color); expression_syntax_highlighter->set_symbol_color(symbol_color); @@ -935,7 +935,7 @@ void VisualShaderGraphPlugin::add_node(VisualShader::Type p_type, int p_id) { } VisualShaderEditor::get_singleton()->_update_created_node(node); if (is_resizable) { - VisualShaderEditor::get_singleton()->call_deferred("_set_node_size", (int)p_type, p_id, size); + VisualShaderEditor::get_singleton()->call_deferred(SNAME("_set_node_size"), (int)p_type, p_id, size); } } } @@ -961,7 +961,7 @@ void VisualShaderGraphPlugin::connect_nodes(VisualShader::Type p_type, int p_fro void VisualShaderGraphPlugin::disconnect_nodes(VisualShader::Type p_type, int p_from_node, int p_from_port, int p_to_node, int p_to_port) { if (visual_shader->get_shader_type() == p_type) { VisualShaderEditor::get_singleton()->graph->disconnect_node(itos(p_from_node), p_from_port, itos(p_to_node), p_to_port); - for (List<VisualShader::Connection>::Element *E = connections.front(); E; E = E->next()) { + for (const List<VisualShader::Connection>::Element *E = connections.front(); E; E = E->next()) { if (E->get().from_node == p_from_node && E->get().from_port == p_from_port && E->get().to_node == p_to_node && E->get().to_port == p_to_port) { connections.erase(E); break; @@ -1211,8 +1211,8 @@ void VisualShaderEditor::_update_options_menu() { bool is_first_item = true; - Color unsupported_color = get_theme_color("error_color", "Editor"); - Color supported_color = get_theme_color("warning_color", "Editor"); + Color unsupported_color = get_theme_color(SNAME("error_color"), SNAME("Editor")); + Color supported_color = get_theme_color(SNAME("warning_color"), SNAME("Editor")); static bool low_driver = ProjectSettings::get_singleton()->get("rendering/driver/driver_name") == "GLES2"; @@ -1285,22 +1285,22 @@ void VisualShaderEditor::_update_options_menu() { } switch (options[i].return_type) { case VisualShaderNode::PORT_TYPE_SCALAR: - item->set_icon(0, EditorNode::get_singleton()->get_gui_base()->get_theme_icon("float", "EditorIcons")); + item->set_icon(0, EditorNode::get_singleton()->get_gui_base()->get_theme_icon(SNAME("float"), SNAME("EditorIcons"))); break; case VisualShaderNode::PORT_TYPE_SCALAR_INT: - item->set_icon(0, EditorNode::get_singleton()->get_gui_base()->get_theme_icon("int", "EditorIcons")); + item->set_icon(0, EditorNode::get_singleton()->get_gui_base()->get_theme_icon(SNAME("int"), SNAME("EditorIcons"))); break; case VisualShaderNode::PORT_TYPE_VECTOR: - item->set_icon(0, EditorNode::get_singleton()->get_gui_base()->get_theme_icon("Vector3", "EditorIcons")); + item->set_icon(0, EditorNode::get_singleton()->get_gui_base()->get_theme_icon(SNAME("Vector3"), SNAME("EditorIcons"))); break; case VisualShaderNode::PORT_TYPE_BOOLEAN: - item->set_icon(0, EditorNode::get_singleton()->get_gui_base()->get_theme_icon("bool", "EditorIcons")); + item->set_icon(0, EditorNode::get_singleton()->get_gui_base()->get_theme_icon(SNAME("bool"), SNAME("EditorIcons"))); break; case VisualShaderNode::PORT_TYPE_TRANSFORM: - item->set_icon(0, EditorNode::get_singleton()->get_gui_base()->get_theme_icon("Transform3D", "EditorIcons")); + item->set_icon(0, EditorNode::get_singleton()->get_gui_base()->get_theme_icon(SNAME("Transform3D"), SNAME("EditorIcons"))); break; case VisualShaderNode::PORT_TYPE_SAMPLER: - item->set_icon(0, EditorNode::get_singleton()->get_gui_base()->get_theme_icon("ImageTexture", "EditorIcons")); + item->set_icon(0, EditorNode::get_singleton()->get_gui_base()->get_theme_icon(SNAME("ImageTexture"), SNAME("EditorIcons"))); break; default: break; @@ -1349,12 +1349,12 @@ void VisualShaderEditor::_draw_color_over_button(Object *obj, Color p_color) { return; } - Ref<StyleBox> normal = get_theme_stylebox("normal", "Button"); + Ref<StyleBox> normal = get_theme_stylebox(SNAME("normal"), SNAME("Button")); button->draw_rect(Rect2(normal->get_offset(), button->get_size() - normal->get_minimum_size()), p_color); } void VisualShaderEditor::_update_created_node(GraphNode *node) { - const Ref<StyleBoxFlat> sb = node->get_theme_stylebox("frame", "GraphNode"); + const Ref<StyleBoxFlat> sb = node->get_theme_stylebox(SNAME("frame"), SNAME("GraphNode")); Color c = sb->get_border_color(); const Color mono_color = ((c.r + c.g + c.b) / 3) < 0.7 ? Color(1.0, 1.0, 1.0, 0.85) : Color(0.0, 0.0, 0.0, 0.85); c = mono_color; @@ -1470,11 +1470,11 @@ void VisualShaderEditor::_update_graph() { graph_plugin->make_dirty(false); - for (List<VisualShader::Connection>::Element *E = connections.front(); E; E = E->next()) { - int from = E->get().from_node; - int from_idx = E->get().from_port; - int to = E->get().to_node; - int to_idx = E->get().to_port; + for (const VisualShader::Connection &E : connections) { + int from = E.from_node; + int from_idx = E.from_port; + int to = E.to_node; + int to_idx = E.to_port; graph->connect_node(itos(from), from_idx, itos(to), to_idx); } @@ -1634,11 +1634,11 @@ void VisualShaderEditor::_expand_output_port(int p_node, int p_port, bool p_expa List<VisualShader::Connection> conns; visual_shader->get_node_connections(type, &conns); - for (List<VisualShader::Connection>::Element *E = conns.front(); E; E = E->next()) { - int from_node = E->get().from_node; - int from_port = E->get().from_port; - int to_node = E->get().to_node; - int to_port = E->get().to_port; + for (const VisualShader::Connection &E : conns) { + int from_node = E.from_node; + int from_port = E.from_port; + int to_node = E.to_node; + int to_port = E.to_port; if (from_node == p_node) { if (p_expand) { @@ -1708,11 +1708,11 @@ void VisualShaderEditor::_remove_input_port(int p_node, int p_port) { List<VisualShader::Connection> conns; visual_shader->get_node_connections(type, &conns); - for (List<VisualShader::Connection>::Element *E = conns.front(); E; E = E->next()) { - int from_node = E->get().from_node; - int from_port = E->get().from_port; - int to_node = E->get().to_node; - int to_port = E->get().to_port; + for (const VisualShader::Connection &E : conns) { + int from_node = E.from_node; + int from_port = E.from_port; + int to_node = E.to_node; + int to_port = E.to_port; if (to_node == p_node) { if (to_port == p_port) { @@ -1757,11 +1757,11 @@ void VisualShaderEditor::_remove_output_port(int p_node, int p_port) { List<VisualShader::Connection> conns; visual_shader->get_node_connections(type, &conns); - for (List<VisualShader::Connection>::Element *E = conns.front(); E; E = E->next()) { - int from_node = E->get().from_node; - int from_port = E->get().from_port; - int to_node = E->get().to_node; - int to_port = E->get().to_port; + for (const VisualShader::Connection &E : conns) { + int from_node = E.from_node; + int from_port = E.from_port; + int to_node = E.to_node; + int to_port = E.to_port; if (from_node == p_node) { if (from_port == p_port) { @@ -2470,12 +2470,12 @@ void VisualShaderEditor::_add_node(int p_idx, int p_op_idx, String p_resource_pa VisualShaderNodeCurveTexture *curve = Object::cast_to<VisualShaderNodeCurveTexture>(vsnode.ptr()); if (curve) { - graph_plugin->call_deferred("update_curve", id_to_use); + graph_plugin->call_deferred(SNAME("update_curve"), id_to_use); } - VisualShaderNodeCurve3Texture *curve3 = Object::cast_to<VisualShaderNodeCurve3Texture>(vsnode.ptr()); - if (curve3) { - graph_plugin->call_deferred("update_curve3", id_to_use); + VisualShaderNodeCurveXYZTexture *curve_xyz = Object::cast_to<VisualShaderNodeCurveXYZTexture>(vsnode.ptr()); + if (curve_xyz) { + graph_plugin->call_deferred(SNAME("update_curve_xyz"), id_to_use); } if (p_resource_path.is_empty()) { @@ -2486,7 +2486,7 @@ void VisualShaderEditor::_add_node(int p_idx, int p_op_idx, String p_resource_pa VisualShaderNodeTexture *texture2d = Object::cast_to<VisualShaderNodeTexture>(vsnode.ptr()); VisualShaderNodeTexture3D *texture3d = Object::cast_to<VisualShaderNodeTexture3D>(vsnode.ptr()); - if (texture2d || texture3d || curve || curve3) { + if (texture2d || texture3d || curve || curve_xyz) { undo_redo->add_do_method(vsnode.ptr(), "set_texture", ResourceLoader::load(p_resource_path)); return; } @@ -2508,7 +2508,7 @@ void VisualShaderEditor::_node_dragged(const Vector2 &p_from, const Vector2 &p_t VisualShader::Type type = get_current_shader_type(); drag_buffer.push_back({ type, p_node, p_from, p_to }); if (!drag_dirty) { - call_deferred("_nodes_dragged"); + call_deferred(SNAME("_nodes_dragged")); } drag_dirty = true; } @@ -2518,11 +2518,11 @@ void VisualShaderEditor::_nodes_dragged() { undo_redo->create_action(TTR("Node(s) Moved")); - for (List<DragOp>::Element *E = drag_buffer.front(); E; E = E->next()) { - undo_redo->add_do_method(visual_shader.ptr(), "set_node_position", E->get().type, E->get().node, E->get().to); - undo_redo->add_undo_method(visual_shader.ptr(), "set_node_position", E->get().type, E->get().node, E->get().from); - undo_redo->add_do_method(graph_plugin.ptr(), "set_node_position", E->get().type, E->get().node, E->get().to); - undo_redo->add_undo_method(graph_plugin.ptr(), "set_node_position", E->get().type, E->get().node, E->get().from); + for (const DragOp &E : drag_buffer) { + undo_redo->add_do_method(visual_shader.ptr(), "set_node_position", E.type, E.node, E.to); + undo_redo->add_undo_method(visual_shader.ptr(), "set_node_position", E.type, E.node, E.from); + undo_redo->add_do_method(graph_plugin.ptr(), "set_node_position", E.type, E.node, E.to); + undo_redo->add_undo_method(graph_plugin.ptr(), "set_node_position", E.type, E.node, E.from); } drag_buffer.clear(); @@ -2544,12 +2544,12 @@ void VisualShaderEditor::_connection_request(const String &p_from, int p_from_in List<VisualShader::Connection> conns; visual_shader->get_node_connections(type, &conns); - for (List<VisualShader::Connection>::Element *E = conns.front(); E; E = E->next()) { - if (E->get().to_node == to && E->get().to_port == p_to_index) { - undo_redo->add_do_method(visual_shader.ptr(), "disconnect_nodes", type, E->get().from_node, E->get().from_port, E->get().to_node, E->get().to_port); - undo_redo->add_undo_method(visual_shader.ptr(), "connect_nodes", type, E->get().from_node, E->get().from_port, E->get().to_node, E->get().to_port); - undo_redo->add_do_method(graph_plugin.ptr(), "disconnect_nodes", type, E->get().from_node, E->get().from_port, E->get().to_node, E->get().to_port); - undo_redo->add_undo_method(graph_plugin.ptr(), "connect_nodes", type, E->get().from_node, E->get().from_port, E->get().to_node, E->get().to_port); + for (const VisualShader::Connection &E : conns) { + if (E.to_node == to && E.to_port == p_to_index) { + undo_redo->add_do_method(visual_shader.ptr(), "disconnect_nodes", type, E.from_node, E.from_port, E.to_node, E.to_port); + 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); } } @@ -2597,22 +2597,22 @@ void VisualShaderEditor::_delete_nodes(int p_type, const List<int> &p_nodes) { List<VisualShader::Connection> conns; visual_shader->get_node_connections(type, &conns); - for (const List<int>::Element *F = p_nodes.front(); F; F = F->next()) { - for (List<VisualShader::Connection>::Element *E = conns.front(); E; E = E->next()) { - if (E->get().from_node == F->get() || E->get().to_node == F->get()) { - undo_redo->add_do_method(graph_plugin.ptr(), "disconnect_nodes", type, E->get().from_node, E->get().from_port, E->get().to_node, E->get().to_port); + for (const int &F : p_nodes) { + for (const VisualShader::Connection &E : conns) { + if (E.from_node == F || E.to_node == F) { + undo_redo->add_do_method(graph_plugin.ptr(), "disconnect_nodes", type, E.from_node, E.from_port, E.to_node, E.to_port); } } } Set<String> uniform_names; - for (const List<int>::Element *F = p_nodes.front(); F; F = F->next()) { - Ref<VisualShaderNode> node = visual_shader->get_node(type, F->get()); + for (const int &F : p_nodes) { + Ref<VisualShaderNode> node = visual_shader->get_node(type, F); - undo_redo->add_do_method(visual_shader.ptr(), "remove_node", type, F->get()); - undo_redo->add_undo_method(visual_shader.ptr(), "add_node", type, node, visual_shader->get_node_position(type, F->get()), F->get()); - undo_redo->add_undo_method(graph_plugin.ptr(), "add_node", type, F->get()); + undo_redo->add_do_method(visual_shader.ptr(), "remove_node", type, F); + undo_redo->add_undo_method(visual_shader.ptr(), "add_node", type, node, visual_shader->get_node_position(type, F), F); + undo_redo->add_undo_method(graph_plugin.ptr(), "add_node", type, F); undo_redo->add_do_method(this, "_clear_buffer"); undo_redo->add_undo_method(this, "_clear_buffer"); @@ -2638,28 +2638,28 @@ void VisualShaderEditor::_delete_nodes(int p_type, const List<int> &p_nodes) { } List<VisualShader::Connection> used_conns; - for (const List<int>::Element *F = p_nodes.front(); F; F = F->next()) { - for (List<VisualShader::Connection>::Element *E = conns.front(); E; E = E->next()) { - if (E->get().from_node == F->get() || E->get().to_node == F->get()) { + for (const int &F : p_nodes) { + for (const VisualShader::Connection &E : conns) { + if (E.from_node == F || E.to_node == F) { bool cancel = false; for (List<VisualShader::Connection>::Element *R = used_conns.front(); R; R = R->next()) { - if (R->get().from_node == E->get().from_node && R->get().from_port == E->get().from_port && R->get().to_node == E->get().to_node && R->get().to_port == E->get().to_port) { + if (R->get().from_node == E.from_node && R->get().from_port == E.from_port && R->get().to_node == E.to_node && R->get().to_port == E.to_port) { cancel = true; // to avoid ERR_ALREADY_EXISTS warning break; } } if (!cancel) { - undo_redo->add_undo_method(visual_shader.ptr(), "connect_nodes", type, E->get().from_node, E->get().from_port, E->get().to_node, E->get().to_port); - undo_redo->add_undo_method(graph_plugin.ptr(), "connect_nodes", type, E->get().from_node, E->get().from_port, E->get().to_node, E->get().to_port); - used_conns.push_back(E->get()); + 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_undo_method(graph_plugin.ptr(), "connect_nodes", type, E.from_node, E.from_port, E.to_node, E.to_port); + used_conns.push_back(E); } } } } // delete nodes from the graph - for (const List<int>::Element *F = p_nodes.front(); F; F = F->next()) { - undo_redo->add_do_method(graph_plugin.ptr(), "remove_node", type, F->get()); + for (const int &F : p_nodes) { + undo_redo->add_do_method(graph_plugin.ptr(), "remove_node", type, F); } // update uniform refs if any uniform has been deleted @@ -3032,7 +3032,7 @@ void VisualShaderEditor::_show_members_dialog(bool at_mouse_pos) { members_dialog->set_position(members_dialog->get_position() - Point2(difference, 0)); } - node_filter->call_deferred("grab_focus"); // still not visible + node_filter->call_deferred(SNAME("grab_focus")); // still not visible node_filter->select_all(); } @@ -3075,11 +3075,11 @@ void VisualShaderEditor::_notification(int p_what) { } if (p_what == NOTIFICATION_ENTER_TREE || p_what == NOTIFICATION_THEME_CHANGED) { - highend_label->set_modulate(get_theme_color("vulkan_color", "Editor")); + highend_label->set_modulate(get_theme_color(SNAME("vulkan_color"), SNAME("Editor"))); - node_filter->set_right_icon(Control::get_theme_icon("Search", "EditorIcons")); + node_filter->set_right_icon(Control::get_theme_icon(SNAME("Search"), SNAME("EditorIcons"))); - preview_shader->set_icon(Control::get_theme_icon("Shader", "EditorIcons")); + preview_shader->set_icon(Control::get_theme_icon(SNAME("Shader"), SNAME("EditorIcons"))); { Color background_color = EDITOR_GET("text_editor/highlighting/background_color"); @@ -3094,16 +3094,16 @@ void VisualShaderEditor::_notification(int p_what) { preview_text->add_theme_color_override("background_color", background_color); - for (List<String>::Element *E = keyword_list.front(); E; E = E->next()) { - if (ShaderLanguage::is_control_flow_keyword(E->get())) { - syntax_highlighter->add_keyword_color(E->get(), control_flow_keyword_color); + for (const String &E : keyword_list) { + if (ShaderLanguage::is_control_flow_keyword(E)) { + syntax_highlighter->add_keyword_color(E, control_flow_keyword_color); } else { - syntax_highlighter->add_keyword_color(E->get(), keyword_color); + syntax_highlighter->add_keyword_color(E, keyword_color); } } - preview_text->add_theme_font_override("font", get_theme_font("expression", "EditorFonts")); - preview_text->add_theme_font_size_override("font_size", get_theme_font_size("expression_size", "EditorFonts")); + preview_text->add_theme_font_override("font", get_theme_font(SNAME("expression"), SNAME("EditorFonts"))); + preview_text->add_theme_font_size_override("font_size", get_theme_font_size(SNAME("expression_size"), SNAME("EditorFonts"))); preview_text->add_theme_color_override("font_color", text_color); syntax_highlighter->set_number_color(number_color); syntax_highlighter->set_symbol_color(symbol_color); @@ -3117,13 +3117,13 @@ void VisualShaderEditor::_notification(int p_what) { preview_text->add_comment_delimiter("/*", "*/", false); preview_text->add_comment_delimiter("//", "", true); - error_panel->add_theme_style_override("panel", get_theme_stylebox("panel", "Panel")); - error_label->add_theme_font_override("font", get_theme_font("status_source", "EditorFonts")); - error_label->add_theme_font_size_override("font_size", get_theme_font_size("status_source_size", "EditorFonts")); - error_label->add_theme_color_override("font_color", get_theme_color("error_color", "Editor")); + error_panel->add_theme_style_override("panel", get_theme_stylebox(SNAME("panel"), SNAME("Panel"))); + error_label->add_theme_font_override("font", get_theme_font(SNAME("status_source"), SNAME("EditorFonts"))); + error_label->add_theme_font_size_override("font_size", get_theme_font_size(SNAME("status_source_size"), SNAME("EditorFonts"))); + error_label->add_theme_color_override("font_color", get_theme_color(SNAME("error_color"), SNAME("Editor"))); } - tools->set_icon(EditorNode::get_singleton()->get_gui_base()->get_theme_icon("Tools", "EditorIcons")); + tools->set_icon(EditorNode::get_singleton()->get_gui_base()->get_theme_icon(SNAME("Tools"), SNAME("EditorIcons"))); if (p_what == NOTIFICATION_THEME_CHANGED && is_visible_in_tree()) { _update_graph(); @@ -3206,9 +3206,9 @@ void VisualShaderEditor::_dup_paste_nodes(int p_type, int p_pasted_type, List<in Map<int, int> connection_remap; Set<int> unsupported_set; - for (List<int>::Element *E = r_nodes.front(); E; E = E->next()) { - connection_remap[E->get()] = id_from; - Ref<VisualShaderNode> node = visual_shader->get_node(pasted_type, E->get()); + for (int &E : r_nodes) { + connection_remap[E] = id_from; + Ref<VisualShaderNode> node = visual_shader->get_node(pasted_type, E); bool unsupported = false; for (int i = 0; i < add_options.size(); i++) { @@ -3220,13 +3220,13 @@ void VisualShaderEditor::_dup_paste_nodes(int p_type, int p_pasted_type, List<in } } if (unsupported) { - unsupported_set.insert(E->get()); + unsupported_set.insert(E); continue; } Ref<VisualShaderNode> dupli = node->duplicate(); - undo_redo->add_do_method(visual_shader.ptr(), "add_node", type, dupli, visual_shader->get_node_position(pasted_type, E->get()) + p_offset, id_from); + undo_redo->add_do_method(visual_shader.ptr(), "add_node", type, dupli, visual_shader->get_node_position(pasted_type, E) + p_offset, id_from); undo_redo->add_do_method(graph_plugin.ptr(), "add_node", type, id_from); // duplicate size, inputs and outputs if node is group @@ -3249,19 +3249,19 @@ void VisualShaderEditor::_dup_paste_nodes(int p_type, int p_pasted_type, List<in List<VisualShader::Connection> conns; visual_shader->get_node_connections(pasted_type, &conns); - for (List<VisualShader::Connection>::Element *E = conns.front(); E; E = E->next()) { - if (unsupported_set.has(E->get().from_node) || unsupported_set.has(E->get().to_node)) { + for (const VisualShader::Connection &E : conns) { + if (unsupported_set.has(E.from_node) || unsupported_set.has(E.to_node)) { continue; } - if (connection_remap.has(E->get().from_node) && connection_remap.has(E->get().to_node)) { - undo_redo->add_do_method(visual_shader.ptr(), "connect_nodes", type, connection_remap[E->get().from_node], E->get().from_port, connection_remap[E->get().to_node], E->get().to_port); - undo_redo->add_do_method(graph_plugin.ptr(), "connect_nodes", type, connection_remap[E->get().from_node], E->get().from_port, connection_remap[E->get().to_node], E->get().to_port); - undo_redo->add_undo_method(graph_plugin.ptr(), "disconnect_nodes", type, connection_remap[E->get().from_node], E->get().from_port, connection_remap[E->get().to_node], E->get().to_port); + if (connection_remap.has(E.from_node) && connection_remap.has(E.to_node)) { + undo_redo->add_do_method(visual_shader.ptr(), "connect_nodes", type, connection_remap[E.from_node], E.from_port, connection_remap[E.to_node], E.to_port); + undo_redo->add_do_method(graph_plugin.ptr(), "connect_nodes", type, connection_remap[E.from_node], E.from_port, connection_remap[E.to_node], E.to_port); + undo_redo->add_undo_method(graph_plugin.ptr(), "disconnect_nodes", type, connection_remap[E.from_node], E.from_port, connection_remap[E.to_node], E.to_port); } } id_from = base_id; - for (List<int>::Element *E = r_nodes.front(); E; E = E->next()) { + for (int i = 0; i < r_nodes.size(); i++) { undo_redo->add_undo_method(visual_shader.ptr(), "remove_node", type, id_from); undo_redo->add_undo_method(graph_plugin.ptr(), "remove_node", type, id_from); id_from++; @@ -3399,17 +3399,17 @@ void VisualShaderEditor::_input_select_item(Ref<VisualShaderNodeInput> p_input, if (type_changed) { List<VisualShader::Connection> conns; visual_shader->get_node_connections(type, &conns); - for (List<VisualShader::Connection>::Element *E = conns.front(); E; E = E->next()) { - if (E->get().from_node == id) { - if (visual_shader->is_port_types_compatible(p_input->get_input_type_by_name(p_name), visual_shader->get_node(type, E->get().to_node)->get_input_port_type(E->get().to_port))) { - undo_redo->add_do_method(visual_shader.ptr(), "connect_nodes", type, E->get().from_node, E->get().from_port, E->get().to_node, E->get().to_port); - undo_redo->add_undo_method(visual_shader.ptr(), "connect_nodes", type, E->get().from_node, E->get().from_port, E->get().to_node, E->get().to_port); + for (const VisualShader::Connection &E : conns) { + if (E.from_node == id) { + if (visual_shader->is_port_types_compatible(p_input->get_input_type_by_name(p_name), visual_shader->get_node(type, E.to_node)->get_input_port_type(E.to_port))) { + undo_redo->add_do_method(visual_shader.ptr(), "connect_nodes", type, E.from_node, E.from_port, E.to_node, E.to_port); + undo_redo->add_undo_method(visual_shader.ptr(), "connect_nodes", type, E.from_node, E.from_port, E.to_node, E.to_port); continue; } - undo_redo->add_do_method(visual_shader.ptr(), "disconnect_nodes", type, E->get().from_node, E->get().from_port, E->get().to_node, E->get().to_port); - undo_redo->add_undo_method(visual_shader.ptr(), "connect_nodes", type, E->get().from_node, E->get().from_port, E->get().to_node, E->get().to_port); - undo_redo->add_do_method(graph_plugin.ptr(), "disconnect_nodes", type, E->get().from_node, E->get().from_port, E->get().to_node, E->get().to_port); - undo_redo->add_undo_method(graph_plugin.ptr(), "connect_nodes", type, E->get().from_node, E->get().from_port, E->get().to_node, E->get().to_port); + undo_redo->add_do_method(visual_shader.ptr(), "disconnect_nodes", type, E.from_node, E.from_port, E.to_node, E.to_port); + 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); } } } @@ -3445,15 +3445,15 @@ void VisualShaderEditor::_uniform_select_item(Ref<VisualShaderNodeUniformRef> p_ if (type_changed) { List<VisualShader::Connection> conns; visual_shader->get_node_connections(type, &conns); - for (List<VisualShader::Connection>::Element *E = conns.front(); E; E = E->next()) { - if (E->get().from_node == id) { - if (visual_shader->is_port_types_compatible(p_uniform_ref->get_uniform_type_by_name(p_name), visual_shader->get_node(type, E->get().to_node)->get_input_port_type(E->get().to_port))) { + for (const VisualShader::Connection &E : conns) { + if (E.from_node == id) { + if (visual_shader->is_port_types_compatible(p_uniform_ref->get_uniform_type_by_name(p_name), visual_shader->get_node(type, E.to_node)->get_input_port_type(E.to_port))) { continue; } - undo_redo->add_do_method(visual_shader.ptr(), "disconnect_nodes", type, E->get().from_node, E->get().from_port, E->get().to_node, E->get().to_port); - undo_redo->add_undo_method(visual_shader.ptr(), "connect_nodes", type, E->get().from_node, E->get().from_port, E->get().to_node, E->get().to_port); - undo_redo->add_do_method(graph_plugin.ptr(), "disconnect_nodes", type, E->get().from_node, E->get().from_port, E->get().to_node, E->get().to_port); - undo_redo->add_undo_method(graph_plugin.ptr(), "connect_nodes", type, E->get().from_node, E->get().from_port, E->get().to_node, E->get().to_port); + undo_redo->add_do_method(visual_shader.ptr(), "disconnect_nodes", type, E.from_node, E.from_port, E.to_node, E.to_port); + 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); } } } @@ -3681,10 +3681,10 @@ void VisualShaderEditor::drop_data_fw(const Point2 &p_point, const Variant &p_da saved_node_pos = p_point + Vector2(0, i * 250 * EDSCALE); saved_node_pos_dirty = true; _add_node(curve_node_option_idx, -1, arr[i], i); - } else if (type == "Curve3Texture") { + } else if (type == "CurveXYZTexture") { saved_node_pos = p_point + Vector2(0, i * 250 * EDSCALE); saved_node_pos_dirty = true; - _add_node(curve3_node_option_idx, -1, arr[i], i); + _add_node(curve_xyz_node_option_idx, -1, arr[i], i); } else if (ClassDB::get_parent_class(type) == "Texture2D") { saved_node_pos = p_point + Vector2(0, i * 250 * EDSCALE); saved_node_pos_dirty = true; @@ -4406,8 +4406,8 @@ VisualShaderEditor::VisualShaderEditor() { add_options.push_back(AddOption("CubeMap", "Textures", "Functions", "VisualShaderNodeCubemap", TTR("Perform the cubic texture lookup."), -1, -1)); curve_node_option_idx = add_options.size(); add_options.push_back(AddOption("CurveTexture", "Textures", "Functions", "VisualShaderNodeCurveTexture", TTR("Perform the curve texture lookup."), -1, -1)); - curve3_node_option_idx = add_options.size(); - add_options.push_back(AddOption("CurveTexture3", "Textures", "Functions", "VisualShaderNodeCurve3Texture", TTR("Perform the ternary curve texture lookup."), -1, -1)); + curve_xyz_node_option_idx = add_options.size(); + add_options.push_back(AddOption("CurveXYZTexture", "Textures", "Functions", "VisualShaderNodeCurveXYZTexture", TTR("Perform the three components curve texture lookup."), -1, -1)); texture2d_node_option_idx = add_options.size(); add_options.push_back(AddOption("Texture2D", "Textures", "Functions", "VisualShaderNodeTexture", TTR("Perform the 2D texture lookup."), -1, -1)); texture2d_array_node_option_idx = add_options.size(); @@ -4605,18 +4605,18 @@ public: } void _item_selected(int p_item) { - VisualShaderEditor::get_singleton()->call_deferred("_input_select_item", input, get_item_text(p_item)); + VisualShaderEditor::get_singleton()->call_deferred(SNAME("_input_select_item"), input, get_item_text(p_item)); } void setup(const Ref<VisualShaderNodeInput> &p_input) { input = p_input; Ref<Texture2D> type_icon[6] = { - EditorNode::get_singleton()->get_gui_base()->get_theme_icon("float", "EditorIcons"), - EditorNode::get_singleton()->get_gui_base()->get_theme_icon("int", "EditorIcons"), - EditorNode::get_singleton()->get_gui_base()->get_theme_icon("Vector3", "EditorIcons"), - EditorNode::get_singleton()->get_gui_base()->get_theme_icon("bool", "EditorIcons"), - EditorNode::get_singleton()->get_gui_base()->get_theme_icon("Transform3D", "EditorIcons"), - EditorNode::get_singleton()->get_gui_base()->get_theme_icon("ImageTexture", "EditorIcons"), + EditorNode::get_singleton()->get_gui_base()->get_theme_icon(SNAME("float"), SNAME("EditorIcons")), + EditorNode::get_singleton()->get_gui_base()->get_theme_icon(SNAME("int"), SNAME("EditorIcons")), + EditorNode::get_singleton()->get_gui_base()->get_theme_icon(SNAME("Vector3"), SNAME("EditorIcons")), + EditorNode::get_singleton()->get_gui_base()->get_theme_icon(SNAME("bool"), SNAME("EditorIcons")), + EditorNode::get_singleton()->get_gui_base()->get_theme_icon(SNAME("Transform3D"), SNAME("EditorIcons")), + EditorNode::get_singleton()->get_gui_base()->get_theme_icon(SNAME("ImageTexture"), SNAME("EditorIcons")), }; add_item("[None]"); @@ -4649,20 +4649,20 @@ public: } void _item_selected(int p_item) { - VisualShaderEditor::get_singleton()->call_deferred("_uniform_select_item", uniform_ref, get_item_text(p_item)); + VisualShaderEditor::get_singleton()->call_deferred(SNAME("_uniform_select_item"), uniform_ref, get_item_text(p_item)); } void setup(const Ref<VisualShaderNodeUniformRef> &p_uniform_ref) { uniform_ref = p_uniform_ref; Ref<Texture2D> type_icon[7] = { - EditorNode::get_singleton()->get_gui_base()->get_theme_icon("float", "EditorIcons"), - EditorNode::get_singleton()->get_gui_base()->get_theme_icon("int", "EditorIcons"), - EditorNode::get_singleton()->get_gui_base()->get_theme_icon("bool", "EditorIcons"), - EditorNode::get_singleton()->get_gui_base()->get_theme_icon("Vector3", "EditorIcons"), - EditorNode::get_singleton()->get_gui_base()->get_theme_icon("Transform3D", "EditorIcons"), - EditorNode::get_singleton()->get_gui_base()->get_theme_icon("Color", "EditorIcons"), - EditorNode::get_singleton()->get_gui_base()->get_theme_icon("ImageTexture", "EditorIcons"), + EditorNode::get_singleton()->get_gui_base()->get_theme_icon(SNAME("float"), SNAME("EditorIcons")), + EditorNode::get_singleton()->get_gui_base()->get_theme_icon(SNAME("int"), SNAME("EditorIcons")), + EditorNode::get_singleton()->get_gui_base()->get_theme_icon(SNAME("bool"), SNAME("EditorIcons")), + EditorNode::get_singleton()->get_gui_base()->get_theme_icon(SNAME("Vector3"), SNAME("EditorIcons")), + EditorNode::get_singleton()->get_gui_base()->get_theme_icon(SNAME("Transform3D"), SNAME("EditorIcons")), + EditorNode::get_singleton()->get_gui_base()->get_theme_icon(SNAME("Color"), SNAME("EditorIcons")), + EditorNode::get_singleton()->get_gui_base()->get_theme_icon(SNAME("ImageTexture"), SNAME("EditorIcons")), }; add_item("[None]"); @@ -4697,7 +4697,7 @@ public: UndoRedo *undo_redo = EditorNode::get_singleton()->get_undo_redo(); updating = true; - undo_redo->create_action(TTR("Edit Visual Property") + ": " + p_property, UndoRedo::MERGE_ENDS); + undo_redo->create_action(TTR("Edit Visual Property:") + " " + p_property, UndoRedo::MERGE_ENDS); undo_redo->add_do_property(node.ptr(), p_property, p_value); undo_redo->add_undo_property(node.ptr(), p_property, node->get(p_property)); @@ -4825,10 +4825,10 @@ Control *VisualShaderNodePluginDefault::create_editor(const Ref<Resource> &p_par Vector<PropertyInfo> pinfo; - for (List<PropertyInfo>::Element *E = props.front(); E; E = E->next()) { + for (const PropertyInfo &E : props) { for (int i = 0; i < properties.size(); i++) { - if (E->get().name == String(properties[i])) { - pinfo.push_back(E->get()); + if (E.name == String(properties[i])) { + pinfo.push_back(E); } } } @@ -4870,7 +4870,7 @@ Control *VisualShaderNodePluginDefault::create_editor(const Ref<Resource> &p_par void EditorPropertyShaderMode::_option_selected(int p_which) { //will not use this, instead will do all the logic setting manually - //emit_signal("property_changed", get_edited_property(), p_which); + //emit_signal(SNAME("property_changed"), get_edited_property(), p_which); Ref<VisualShader> visual_shader(Object::cast_to<VisualShader>(get_edited_object())); @@ -4894,9 +4894,9 @@ void EditorPropertyShaderMode::_option_selected(int p_which) { VisualShader::Type type = VisualShader::Type(i); List<VisualShader::Connection> conns; visual_shader->get_node_connections(type, &conns); - for (List<VisualShader::Connection>::Element *E = conns.front(); E; E = E->next()) { - if (E->get().to_node == VisualShader::NODE_ID_OUTPUT) { - undo_redo->add_undo_method(visual_shader.ptr(), "connect_nodes", type, E->get().from_node, E->get().from_port, E->get().to_node, E->get().to_port); + for (const VisualShader::Connection &E : conns) { + if (E.to_node == VisualShader::NODE_ID_OUTPUT) { + undo_redo->add_undo_method(visual_shader.ptr(), "connect_nodes", type, E.from_node, E.from_port, E.to_node, E.to_port); } } } @@ -4918,9 +4918,9 @@ void EditorPropertyShaderMode::_option_selected(int p_which) { List<PropertyInfo> props; visual_shader->get_property_list(&props); - for (List<PropertyInfo>::Element *E = props.front(); E; E = E->next()) { - if (E->get().name.begins_with("flags/") || E->get().name.begins_with("modes/")) { - undo_redo->add_undo_property(visual_shader.ptr(), E->get().name, visual_shader->get(E->get().name)); + for (const PropertyInfo &E : props) { + if (E.name.begins_with("flags/") || E.name.begins_with("modes/")) { + undo_redo->add_undo_property(visual_shader.ptr(), E.name, visual_shader->get(E.name)); } } @@ -5024,8 +5024,8 @@ void VisualShaderNodePortPreview::_shader_changed() { if (src_mat && src_mat->get_shader().is_valid()) { List<PropertyInfo> params; src_mat->get_shader()->get_param_list(¶ms); - for (List<PropertyInfo>::Element *E = params.front(); E; E = E->next()) { - material->set(E->get().name, src_mat->get(E->get().name)); + for (const PropertyInfo &E : params) { + material->set(E.name, src_mat->get(E.name)); } } } diff --git a/editor/plugins/visual_shader_editor_plugin.h b/editor/plugins/visual_shader_editor_plugin.h index 2b354db7b3..f53726edb9 100644 --- a/editor/plugins/visual_shader_editor_plugin.h +++ b/editor/plugins/visual_shader_editor_plugin.h @@ -117,7 +117,7 @@ public: void update_uniform_refs(); void set_uniform_name(VisualShader::Type p_type, int p_node_id, const String &p_name); void update_curve(int p_node_id); - void update_curve3(int p_node_id); + void update_curve_xyz(int p_node_id); void update_constant(VisualShader::Type p_type, int p_node_id); void set_expression(VisualShader::Type p_type, int p_node_id, const String &p_expression); int get_constant_index(float p_constant) const; @@ -290,7 +290,7 @@ class VisualShaderEditor : public VBoxContainer { int texture3d_node_option_idx; int custom_node_option_idx; int curve_node_option_idx; - int curve3_node_option_idx; + int curve_xyz_node_option_idx; List<String> keyword_list; List<VisualShaderNodeUniformRef> uniform_refs; diff --git a/editor/plugins/voxel_gi_editor_plugin.cpp b/editor/plugins/voxel_gi_editor_plugin.cpp index 162379a49d..5bbc0c9dd5 100644 --- a/editor/plugins/voxel_gi_editor_plugin.cpp +++ b/editor/plugins/voxel_gi_editor_plugin.cpp @@ -81,13 +81,13 @@ void VoxelGIEditorPlugin::_notification(int p_what) { Color color; if (size_mb <= 16.0 + CMP_EPSILON) { // Fast. - color = bake_info->get_theme_color("success_color", "Editor"); + color = bake_info->get_theme_color(SNAME("success_color"), SNAME("Editor")); } else if (size_mb <= 64.0 + CMP_EPSILON) { // Medium. - color = bake_info->get_theme_color("warning_color", "Editor"); + color = bake_info->get_theme_color(SNAME("warning_color"), SNAME("Editor")); } else { // Slow. - color = bake_info->get_theme_color("error_color", "Editor"); + color = bake_info->get_theme_color(SNAME("error_color"), SNAME("Editor")); } bake_info->add_theme_color_override("font_color", color); @@ -143,7 +143,7 @@ VoxelGIEditorPlugin::VoxelGIEditorPlugin(EditorNode *p_node) { bake_hb->hide(); bake = memnew(Button); bake->set_flat(true); - bake->set_icon(editor->get_gui_base()->get_theme_icon("Bake", "EditorIcons")); + bake->set_icon(editor->get_gui_base()->get_theme_icon(SNAME("Bake"), SNAME("EditorIcons"))); bake->set_text(TTR("Bake GI Probe")); bake->connect("pressed", callable_mp(this, &VoxelGIEditorPlugin::_bake)); bake_hb->add_child(bake); diff --git a/editor/progress_dialog.cpp b/editor/progress_dialog.cpp index 0b6a3798b3..3441060fad 100644 --- a/editor/progress_dialog.cpp +++ b/editor/progress_dialog.cpp @@ -139,7 +139,7 @@ void ProgressDialog::_popup() { Size2 ms = main->get_combined_minimum_size(); ms.width = MAX(500 * EDSCALE, ms.width); - Ref<StyleBox> style = main->get_theme_stylebox("panel", "PopupMenu"); + Ref<StyleBox> style = main->get_theme_stylebox(SNAME("panel"), SNAME("PopupMenu")); ms += style->get_minimum_size(); main->set_offset(SIDE_LEFT, style->get_margin(SIDE_LEFT)); main->set_offset(SIDE_RIGHT, -style->get_margin(SIDE_RIGHT)); diff --git a/editor/project_export.cpp b/editor/project_export.cpp index b639a74132..14158b02c8 100644 --- a/editor/project_export.cpp +++ b/editor/project_export.cpp @@ -49,8 +49,8 @@ #include "servers/display_server.h" void ProjectExportDialog::_theme_changed() { - duplicate_preset->set_icon(presets->get_theme_icon("Duplicate", "EditorIcons")); - delete_preset->set_icon(presets->get_theme_icon("Remove", "EditorIcons")); + duplicate_preset->set_icon(presets->get_theme_icon(SNAME("Duplicate"), SNAME("EditorIcons"))); + delete_preset->set_icon(presets->get_theme_icon(SNAME("Remove"), SNAME("EditorIcons"))); } void ProjectExportDialog::_notification(int p_what) { @@ -61,8 +61,8 @@ void ProjectExportDialog::_notification(int p_what) { } } break; case NOTIFICATION_READY: { - duplicate_preset->set_icon(presets->get_theme_icon("Duplicate", "EditorIcons")); - delete_preset->set_icon(presets->get_theme_icon("Remove", "EditorIcons")); + duplicate_preset->set_icon(presets->get_theme_icon(SNAME("Duplicate"), SNAME("EditorIcons"))); + delete_preset->set_icon(presets->get_theme_icon(SNAME("Remove"), SNAME("EditorIcons"))); connect("confirmed", callable_mp(this, &ProjectExportDialog::_export_pck_zip)); _update_export_all(); } break; @@ -340,8 +340,8 @@ void ProjectExportDialog::_update_feature_list() { } } - for (List<String>::Element *E = features.front(); E; E = E->next()) { - fset.insert(E->get()); + for (const String &E : features) { + fset.insert(E); } custom_feature_display->clear(); @@ -567,8 +567,8 @@ void ProjectExportDialog::_duplicate_preset() { preset->set_exclude_filter(current->get_exclude_filter()); preset->set_custom_features(current->get_custom_features()); - for (const List<PropertyInfo>::Element *E = current->get_properties().front(); E; E = E->next()) { - preset->set(E->get().name, current->get(E->get().name)); + for (const PropertyInfo &E : current->get_properties()) { + preset->set(E.name, current->get(E.name)); } EditorExport::get_singleton()->add_export_preset(preset); @@ -730,7 +730,7 @@ void ProjectExportDialog::_fill_resource_tree() { bool ProjectExportDialog::_fill_tree(EditorFileSystemDirectory *p_dir, TreeItem *p_item, Ref<EditorExportPreset> ¤t, bool p_only_scenes) { p_item->set_cell_mode(0, TreeItem::CELL_MODE_CHECK); - p_item->set_icon(0, presets->get_theme_icon("folder", "FileDialog")); + p_item->set_icon(0, presets->get_theme_icon(SNAME("folder"), SNAME("FileDialog"))); p_item->set_text(0, p_dir->get_name() + "/"); p_item->set_editable(0, true); p_item->set_metadata(0, p_dir->get_path()); @@ -1153,7 +1153,7 @@ ProjectExportDialog::ProjectExportDialog() { enc_directory = memnew(CheckButton); enc_directory->connect("toggled", callable_mp(this, &ProjectExportDialog::_enc_directory_changed)); - enc_directory->set_text("Encrypt Index (File Names and Info)"); + enc_directory->set_text(TTR("Encrypt Index (File Names and Info)")); sec_vb->add_child(enc_directory); enc_in_filters = memnew(LineEdit); @@ -1171,8 +1171,8 @@ ProjectExportDialog::ProjectExportDialog() { script_key = memnew(LineEdit); script_key->connect("text_changed", callable_mp(this, &ProjectExportDialog::_script_encryption_key_changed)); script_key_error = memnew(Label); - script_key_error->set_text("- " + TTR("Invalid Encryption Key (must be 64 hexadecimal characters long)")); - script_key_error->add_theme_color_override("font_color", EditorNode::get_singleton()->get_gui_base()->get_theme_color("error_color", "Editor")); + script_key_error->set_text(String::utf8("• ") + TTR("Invalid Encryption Key (must be 64 hexadecimal characters long)")); + script_key_error->add_theme_color_override("font_color", EditorNode::get_singleton()->get_gui_base()->get_theme_color(SNAME("error_color"), SNAME("Editor"))); sec_vb->add_margin_child(TTR("Encryption Key (256-bits as hexadecimal):"), script_key); sec_vb->add_child(script_key_error); sections->add_child(sec_vb); @@ -1219,7 +1219,7 @@ ProjectExportDialog::ProjectExportDialog() { export_all_dialog = memnew(ConfirmationDialog); add_child(export_all_dialog); - export_all_dialog->set_title("Export All"); + export_all_dialog->set_title(TTR("Export All")); export_all_dialog->set_text(TTR("Choose an export mode:")); export_all_dialog->get_ok_button()->hide(); export_all_dialog->add_button(TTR("Debug"), true, "debug"); @@ -1241,7 +1241,7 @@ ProjectExportDialog::ProjectExportDialog() { export_error = memnew(Label); main_vb->add_child(export_error); export_error->hide(); - export_error->add_theme_color_override("font_color", EditorNode::get_singleton()->get_gui_base()->get_theme_color("error_color", "Editor")); + export_error->add_theme_color_override("font_color", EditorNode::get_singleton()->get_gui_base()->get_theme_color(SNAME("error_color"), SNAME("Editor"))); export_templates_error = memnew(HBoxContainer); main_vb->add_child(export_templates_error); @@ -1249,11 +1249,11 @@ ProjectExportDialog::ProjectExportDialog() { Label *export_error2 = memnew(Label); export_templates_error->add_child(export_error2); - export_error2->add_theme_color_override("font_color", EditorNode::get_singleton()->get_gui_base()->get_theme_color("error_color", "Editor")); - export_error2->set_text(" - " + TTR("Export templates for this platform are missing:") + " "); + export_error2->add_theme_color_override("font_color", EditorNode::get_singleton()->get_gui_base()->get_theme_color(SNAME("error_color"), SNAME("Editor"))); + export_error2->set_text(String::utf8("• ") + TTR("Export templates for this platform are missing:") + " "); error_dialog = memnew(AcceptDialog); - error_dialog->set_title("Error"); + error_dialog->set_title(TTR("Error")); error_dialog->set_text(TTR("Export templates for this platform are missing/corrupted:") + " "); main_vb->add_child(error_dialog); error_dialog->hide(); diff --git a/editor/project_manager.cpp b/editor/project_manager.cpp index 50a763f05a..8d425a1e51 100644 --- a/editor/project_manager.cpp +++ b/editor/project_manager.cpp @@ -113,20 +113,20 @@ private: switch (p_type) { case MESSAGE_ERROR: { - msg->add_theme_color_override("font_color", msg->get_theme_color("error_color", "Editor")); + msg->add_theme_color_override("font_color", msg->get_theme_color(SNAME("error_color"), SNAME("Editor"))); msg->set_modulate(Color(1, 1, 1, 1)); - new_icon = msg->get_theme_icon("StatusError", "EditorIcons"); + new_icon = msg->get_theme_icon(SNAME("StatusError"), SNAME("EditorIcons")); } break; case MESSAGE_WARNING: { - msg->add_theme_color_override("font_color", msg->get_theme_color("warning_color", "Editor")); + msg->add_theme_color_override("font_color", msg->get_theme_color(SNAME("warning_color"), SNAME("Editor"))); msg->set_modulate(Color(1, 1, 1, 1)); - new_icon = msg->get_theme_icon("StatusWarning", "EditorIcons"); + new_icon = msg->get_theme_icon(SNAME("StatusWarning"), SNAME("EditorIcons")); } break; case MESSAGE_SUCCESS: { msg->set_modulate(Color(1, 1, 1, 0)); - new_icon = msg->get_theme_icon("StatusSuccess", "EditorIcons"); + new_icon = msg->get_theme_icon(SNAME("StatusSuccess"), SNAME("EditorIcons")); } break; } @@ -336,9 +336,9 @@ private: project_path->set_text(sp); _path_text_changed(sp); if (p.ends_with(".zip")) { - install_path->call_deferred("grab_focus"); + install_path->call_deferred(SNAME("grab_focus")); } else { - get_ok_button()->call_deferred("grab_focus"); + get_ok_button()->call_deferred(SNAME("grab_focus")); } } @@ -346,14 +346,14 @@ private: String sp = p_path.simplify_path(); project_path->set_text(sp); _path_text_changed(sp); - get_ok_button()->call_deferred("grab_focus"); + get_ok_button()->call_deferred(SNAME("grab_focus")); } void _install_path_selected(const String &p_path) { String sp = p_path.simplify_path(); install_path->set_text(sp); _path_text_changed(sp); - get_ok_button()->call_deferred("grab_focus"); + get_ok_button()->call_deferred(SNAME("grab_focus")); } void _browse_path() { @@ -448,7 +448,7 @@ private: } hide(); - emit_signal("projects_updated"); + emit_signal(SNAME("projects_updated")); } else { if (mode == MODE_IMPORT) { @@ -474,13 +474,7 @@ private: return; } ProjectSettings::CustomMap initial_settings; - if (rasterizer_button_group->get_pressed_button()->get_meta("driver_name") == "Vulkan") { - initial_settings["rendering/driver/driver_name"] = "Vulkan"; - } else { - initial_settings["rendering/driver/driver_name"] = "GLES2"; - initial_settings["rendering/textures/vram_compression/import_etc2"] = false; - initial_settings["rendering/textures/vram_compression/import_etc"] = true; - } + initial_settings["rendering/vulkan/rendering/back_end"] = rasterizer_button_group->get_pressed_button()->get_meta(SNAME("driver_name")); initial_settings["application/config/name"] = project_name->get_text().strip_edges(); initial_settings["application/config/icon"] = "res://icon.png"; initial_settings["rendering/environment/defaults/default_environment"] = "res://default_env.tres"; @@ -494,13 +488,13 @@ private: if (!f) { set_message(TTR("Couldn't create project.godot in project path."), MESSAGE_ERROR); } else { - f->store_line("[gd_resource type=\"Environment\" load_steps=2 format=2]"); + f->store_line("[gd_resource type=\"Environment\" load_steps=2 format=3]"); f->store_line(""); - f->store_line("[sub_resource type=\"Sky\" id=1]"); + f->store_line("[sub_resource type=\"Sky\" id=\"1\"]"); f->store_line(""); f->store_line("[resource]"); f->store_line("background_mode = 2"); - f->store_line("sky = SubResource( 1 )"); + f->store_line("sky = SubResource( \"1\" )"); memdelete(f); } } @@ -617,7 +611,7 @@ private: EditorSettings::get_singleton()->save(); hide(); - emit_signal("project_created", dir); + emit_signal(SNAME("project_created"), dir); } } @@ -640,11 +634,11 @@ private: project_name->clear(); _text_changed(""); - if (status_rect->get_texture() == msg->get_theme_icon("StatusError", "EditorIcons")) { + if (status_rect->get_texture() == msg->get_theme_icon(SNAME("StatusError"), SNAME("EditorIcons"))) { msg->show(); } - if (install_status_rect->get_texture() == msg->get_theme_icon("StatusError", "EditorIcons")) { + if (install_status_rect->get_texture() == msg->get_theme_icon(SNAME("StatusError"), SNAME("EditorIcons"))) { msg->show(); } } @@ -715,7 +709,7 @@ public: _text_changed(proj); } - project_name->call_deferred("grab_focus"); + project_name->call_deferred(SNAME("grab_focus")); create_dir->hide(); @@ -758,8 +752,8 @@ public: name_container->show(); install_path_container->hide(); rasterizer_container->show(); - project_name->call_deferred("grab_focus"); - project_name->call_deferred("select_all"); + project_name->call_deferred(SNAME("grab_focus")); + project_name->call_deferred(SNAME("select_all")); } else if (mode == MODE_INSTALL) { set_title(TTR("Install Project:") + " " + zip_title); @@ -869,37 +863,36 @@ public: rshb->add_child(rvb); Button *rs_button = memnew(CheckBox); rs_button->set_button_group(rasterizer_button_group); - rs_button->set_text(TTR("Vulkan")); - rs_button->set_meta("driver_name", "Vulkan"); + rs_button->set_text(TTR("Vulkan Clustered")); + rs_button->set_meta(SNAME("driver_name"), 0); // Vulkan backend "Forward Clustered" rs_button->set_pressed(true); rvb->add_child(rs_button); l = memnew(Label); - l->set_text(TTR("- Higher visual quality\n- More accurate API, which produces very fast code\n- Some features not implemented yet - work in progress\n- Incompatible with older hardware\n- Not recommended for web and mobile games")); + l->set_text( + String::utf8("• ") + TTR("Supports desktop platforms only.") + + String::utf8("\n• ") + TTR("Advanced 3D graphics available.") + + String::utf8("\n• ") + TTR("Can scale to large complex scenes.") + + String::utf8("\n• ") + TTR("Slower rendering of simple scenes.")); l->set_modulate(Color(1, 1, 1, 0.7)); rvb->add_child(l); rshb->add_child(memnew(VSeparator)); - const String gles2_unsupported_tooltip = - TTR("The GLES2 renderer is currently unavailable, as it needs to be reworked for Godot 4.0.\nUse Godot 3.2 if you need GLES2 support."); - rvb = memnew(VBoxContainer); rvb->set_h_size_flags(Control::SIZE_EXPAND_FILL); rshb->add_child(rvb); rs_button = memnew(CheckBox); rs_button->set_button_group(rasterizer_button_group); - rs_button->set_text(TTR("OpenGL ES 2.0 (currently unavailable)")); - rs_button->set_meta("driver_name", "GLES2"); - rs_button->set_disabled(true); - rs_button->set_tooltip(gles2_unsupported_tooltip); + rs_button->set_text(TTR("Vulkan Mobile")); + rs_button->set_meta(SNAME("driver_name"), 1); // Vulkan backend "Forward Mobile" rvb->add_child(rs_button); l = memnew(Label); - l->set_text(TTR("- Lower visual quality\n- Some features not available\n- Works on most hardware\n- Recommended for web and mobile games")); + l->set_text( + String::utf8("• ") + TTR("Supports desktop + mobile platforms.") + + String::utf8("\n• ") + TTR("Less advanced 3D graphics.") + + String::utf8("\n• ") + TTR("Less scalable for complex scenes.") + + String::utf8("\n• ") + TTR("Faster rendering of simple scenes.")); l->set_modulate(Color(1, 1, 1, 0.7)); - // Also set the tooltip on the label so it appears when hovering either the checkbox or label. - l->set_tooltip(gles2_unsupported_tooltip); - // Required for the tooltip to show. - l->set_mouse_filter(Control::MOUSE_FILTER_STOP); rvb->add_child(l); l = memnew(Label); @@ -966,7 +959,7 @@ public: } break; case NOTIFICATION_DRAW: { if (hover) { - draw_style_box(get_theme_stylebox("hover", "Tree"), Rect2(Point2(), get_size())); + draw_style_box(get_theme_stylebox(SNAME("hover"), SNAME("Tree")), Rect2(Point2(), get_size())); } } break; } @@ -1141,7 +1134,7 @@ void ProjectList::_notification(int p_what) { void ProjectList::load_project_icon(int p_index) { Item &item = _projects.write[p_index]; - Ref<Texture2D> default_icon = get_theme_icon("DefaultProjectIcon", "EditorIcons"); + Ref<Texture2D> default_icon = get_theme_icon(SNAME("DefaultProjectIcon"), SNAME("EditorIcons")); Ref<Texture2D> icon; if (item.icon != "") { Ref<Image> img; @@ -1238,16 +1231,16 @@ void ProjectList::load_projects() { Set<String> favorites; // Find favourites... - for (List<PropertyInfo>::Element *E = properties.front(); E; E = E->next()) { - String property_key = E->get().name; + for (const PropertyInfo &E : properties) { + String property_key = E.name; if (property_key.begins_with("favorite_projects/")) { favorites.insert(property_key); } } - for (List<PropertyInfo>::Element *E = properties.front(); E; E = E->next()) { + for (const PropertyInfo &E : properties) { // This is actually something like "projects/C:::Documents::Godot::Projects::MyGame" - String property_key = E->get().name; + String property_key = E.name; if (!property_key.begins_with("projects/")) { continue; } @@ -1327,8 +1320,8 @@ void ProjectList::create_project_item_control(int p_index) { Item &item = _projects.write[p_index]; ERR_FAIL_COND(item.control != nullptr); // Already created - Ref<Texture2D> favorite_icon = get_theme_icon("Favorites", "EditorIcons"); - Color font_color = get_theme_color("font_color", "Tree"); + Ref<Texture2D> favorite_icon = get_theme_icon(SNAME("Favorites"), SNAME("EditorIcons")); + Color font_color = get_theme_color(SNAME("font_color"), SNAME("Tree")); ProjectListItemControl *hb = memnew(ProjectListItemControl); hb->connect("draw", callable_mp(this, &ProjectList::_panel_draw), varray(hb)); @@ -1353,7 +1346,7 @@ void ProjectList::create_project_item_control(int p_index) { TextureRect *tf = memnew(TextureRect); // The project icon may not be loaded by the time the control is displayed, // so use a loading placeholder. - tf->set_texture(get_theme_icon("ProjectIconLoading", "EditorIcons")); + tf->set_texture(get_theme_icon(SNAME("ProjectIconLoading"), SNAME("EditorIcons"))); tf->set_v_size_flags(SIZE_SHRINK_CENTER); if (item.missing) { tf->set_modulate(Color(1, 1, 1, 0.5)); @@ -1372,8 +1365,8 @@ void ProjectList::create_project_item_control(int p_index) { ec->set_mouse_filter(MOUSE_FILTER_PASS); vb->add_child(ec); Label *title = memnew(Label(!item.missing ? item.project_name : TTR("Missing Project"))); - title->add_theme_font_override("font", get_theme_font("title", "EditorFonts")); - title->add_theme_font_size_override("font_size", get_theme_font_size("title_size", "EditorFonts")); + title->add_theme_font_override("font", get_theme_font(SNAME("title"), SNAME("EditorFonts"))); + title->add_theme_font_size_override("font_size", get_theme_font_size(SNAME("title_size"), SNAME("EditorFonts"))); title->add_theme_color_override("font_color", font_color); title->set_clip_text(true); vb->add_child(title); @@ -1582,8 +1575,8 @@ int ProjectList::refresh_project(const String &dir_path) { String favorite_property_key = "favorite_projects/" + project_key; bool found = false; - for (List<PropertyInfo>::Element *E = properties.front(); E; E = E->next()) { - String prop = E->get().name; + for (const PropertyInfo &E : properties) { + String prop = E.name; if (!found && prop == property_key) { found = true; } else if (!is_favourite && prop == favorite_property_key) { @@ -1726,15 +1719,15 @@ void ProjectList::_panel_draw(Node *p_hb) { Control *hb = Object::cast_to<Control>(p_hb); if (is_layout_rtl() && get_v_scrollbar()->is_visible_in_tree()) { - hb->draw_line(Point2(get_v_scrollbar()->get_minimum_size().x, hb->get_size().y + 1), Point2(hb->get_size().x, hb->get_size().y + 1), get_theme_color("guide_color", "Tree")); + hb->draw_line(Point2(get_v_scrollbar()->get_minimum_size().x, hb->get_size().y + 1), Point2(hb->get_size().x, hb->get_size().y + 1), get_theme_color(SNAME("guide_color"), SNAME("Tree"))); } else { - hb->draw_line(Point2(0, hb->get_size().y + 1), Point2(hb->get_size().x, hb->get_size().y + 1), get_theme_color("guide_color", "Tree")); + hb->draw_line(Point2(0, hb->get_size().y + 1), Point2(hb->get_size().x, hb->get_size().y + 1), get_theme_color(SNAME("guide_color"), SNAME("Tree"))); } String key = _projects[p_hb->get_index()].project_key; if (_selected_project_keys.has(key)) { - hb->draw_style_box(get_theme_stylebox("selected", "Tree"), Rect2(Point2(), hb->get_size())); + hb->draw_style_box(get_theme_stylebox(SNAME("selected"), SNAME("Tree")), Rect2(Point2(), hb->get_size())); } } @@ -1765,10 +1758,10 @@ void ProjectList::_panel_input(const Ref<InputEvent> &p_ev, Node *p_hb) { select_project(clicked_index); } - emit_signal(SIGNAL_SELECTION_CHANGED); + emit_signal(SNAME(SIGNAL_SELECTION_CHANGED)); if (!mb->is_ctrl_pressed() && mb->is_double_click()) { - emit_signal(SIGNAL_PROJECT_ASK_OPEN); + emit_signal(SNAME(SIGNAL_PROJECT_ASK_OPEN)); } } } @@ -1826,7 +1819,7 @@ void ProjectManager::_notification(int p_what) { update(); } break; case NOTIFICATION_ENTER_TREE: { - search_box->set_right_icon(get_theme_icon("Search", "EditorIcons")); + search_box->set_right_icon(get_theme_icon(SNAME("Search"), SNAME("EditorIcons"))); search_box->set_clear_button_enabled(true); Engine::get_singleton()->set_editor_hint(false); @@ -2188,9 +2181,9 @@ void ProjectManager::_scan_begin(const String &p_base) { _scan_dir(p_base, &projects); print_line("Found " + itos(projects.size()) + " projects."); - for (List<String>::Element *E = projects.front(); E; E = E->next()) { - String proj = get_project_key_from_path(E->get()); - EditorSettings::get_singleton()->set("projects/" + proj, E->get()); + for (const String &E : projects) { + String proj = get_project_key_from_path(E); + EditorSettings::get_singleton()->set("projects/" + proj, E); } EditorSettings::get_singleton()->save(); _load_recent_projects(); @@ -2446,7 +2439,7 @@ ProjectManager::ProjectManager() { Panel *panel = memnew(Panel); add_child(panel); panel->set_anchors_and_offsets_preset(Control::PRESET_WIDE); - panel->add_theme_style_override("panel", get_theme_stylebox("Background", "EditorStyles")); + panel->add_theme_style_override("panel", get_theme_stylebox(SNAME("Background"), SNAME("EditorStyles"))); VBoxContainer *vb = memnew(VBoxContainer); panel->add_child(vb); @@ -2484,7 +2477,7 @@ ProjectManager::ProjectManager() { hb->add_child(search_box); loading_label = memnew(Label(TTR("Loading, please wait..."))); - loading_label->add_theme_font_override("font", get_theme_font("bold", "EditorFonts")); + loading_label->add_theme_font_override("font", get_theme_font(SNAME("bold"), SNAME("EditorFonts"))); loading_label->set_h_size_flags(Control::SIZE_EXPAND_FILL); hb->add_child(loading_label); // Hide the label but make it still take up space. This prevents reflows when showing the label. @@ -2510,7 +2503,7 @@ ProjectManager::ProjectManager() { } PanelContainer *pc = memnew(PanelContainer); - pc->add_theme_style_override("panel", get_theme_stylebox("bg", "Tree")); + pc->add_theme_style_override("panel", get_theme_stylebox(SNAME("bg"), SNAME("Tree"))); pc->set_v_size_flags(Control::SIZE_EXPAND_FILL); search_tree_vb->add_child(pc); @@ -2618,15 +2611,14 @@ ProjectManager::ProjectManager() { language_btn = memnew(OptionButton); language_btn->set_flat(true); - language_btn->set_icon(get_theme_icon("Environment", "EditorIcons")); + language_btn->set_icon(get_theme_icon(SNAME("Environment"), SNAME("EditorIcons"))); language_btn->set_focus_mode(Control::FOCUS_NONE); language_btn->connect("item_selected", callable_mp(this, &ProjectManager::_language_selected)); Vector<String> editor_languages; List<PropertyInfo> editor_settings_properties; EditorSettings::get_singleton()->get_property_list(&editor_settings_properties); - for (List<PropertyInfo>::Element *E = editor_settings_properties.front(); E; E = E->next()) { - PropertyInfo &pi = E->get(); + for (const PropertyInfo &pi : editor_settings_properties) { if (pi.name == "interface/editor/editor_language") { editor_languages = pi.hint_string.split(","); break; diff --git a/editor/project_settings_editor.cpp b/editor/project_settings_editor.cpp index e76d757516..b8ccab78dd 100644 --- a/editor/project_settings_editor.cpp +++ b/editor/project_settings_editor.cpp @@ -229,16 +229,16 @@ void ProjectSettingsEditor::_add_feature_overrides() { for (int i = 0; i < ee->get_export_platform_count(); i++) { List<String> p; ee->get_export_platform(i)->get_platform_features(&p); - for (List<String>::Element *E = p.front(); E; E = E->next()) { - presets.insert(E->get()); + for (const String &E : p) { + presets.insert(E); } } for (int i = 0; i < ee->get_export_preset_count(); i++) { List<String> p; ee->get_export_preset(i)->get_platform()->get_preset_features(ee->get_export_preset(i), &p); - for (List<String>::Element *E = p.front(); E; E = E->next()) { - presets.insert(E->get()); + for (const String &E : p) { + presets.insert(E); } String custom = ee->get_export_preset(i)->get_custom_features(); @@ -391,8 +391,7 @@ void ProjectSettingsEditor::_action_reordered(const String &p_action_name, const undo_redo->create_action(TTR("Update Input Action Order")); - for (List<PropertyInfo>::Element *E = props.front(); E; E = E->next()) { - PropertyInfo prop = E->get(); + for (const PropertyInfo &prop : props) { // Skip builtins and non-inputs if (ProjectSettings::get_singleton()->is_builtin_setting(prop.name) || !prop.name.begins_with("input/")) { continue; @@ -444,9 +443,9 @@ void ProjectSettingsEditor::_update_action_map_editor() { List<PropertyInfo> props; ProjectSettings::get_singleton()->get_property_list(&props); - const Ref<Texture2D> builtin_icon = get_theme_icon("PinPressed", "EditorIcons"); - for (List<PropertyInfo>::Element *E = props.front(); E; E = E->next()) { - const String property_name = E->get().name; + const Ref<Texture2D> builtin_icon = get_theme_icon(SNAME("PinPressed"), SNAME("EditorIcons")); + for (const PropertyInfo &E : props) { + const String property_name = E.name; if (!property_name.begins_with("input/")) { continue; @@ -483,18 +482,18 @@ void ProjectSettingsEditor::_notification(int p_what) { case NOTIFICATION_ENTER_TREE: { inspector->edit(ps); - search_box->set_right_icon(get_theme_icon("Search", "EditorIcons")); + search_box->set_right_icon(get_theme_icon(SNAME("Search"), SNAME("EditorIcons"))); search_box->set_clear_button_enabled(true); - restart_close_button->set_icon(get_theme_icon("Close", "EditorIcons")); - restart_container->add_theme_style_override("panel", get_theme_stylebox("bg", "Tree")); - restart_icon->set_texture(get_theme_icon("StatusWarning", "EditorIcons")); - restart_label->add_theme_color_override("font_color", get_theme_color("warning_color", "Editor")); + restart_close_button->set_icon(get_theme_icon(SNAME("Close"), SNAME("EditorIcons"))); + restart_container->add_theme_style_override("panel", get_theme_stylebox(SNAME("bg"), SNAME("Tree"))); + restart_icon->set_texture(get_theme_icon(SNAME("StatusWarning"), SNAME("EditorIcons"))); + restart_label->add_theme_color_override("font_color", get_theme_color(SNAME("warning_color"), SNAME("Editor"))); _update_action_map_editor(); } break; case EditorSettings::NOTIFICATION_EDITOR_SETTINGS_CHANGED: { - search_box->set_right_icon(get_theme_icon("Search", "EditorIcons")); + search_box->set_right_icon(get_theme_icon(SNAME("Search"), SNAME("EditorIcons"))); search_box->set_clear_button_enabled(true); } break; } diff --git a/editor/property_editor.cpp b/editor/property_editor.cpp index ab710a1c21..7338588d56 100644 --- a/editor/property_editor.cpp +++ b/editor/property_editor.cpp @@ -119,16 +119,16 @@ void CustomPropertyEditor::_menu_option(int p_which) { } v = val; - emit_signal("variant_changed"); + emit_signal(SNAME("variant_changed")); } else if (hint == PROPERTY_HINT_ENUM) { v = menu->get_item_metadata(p_which); - emit_signal("variant_changed"); + emit_signal(SNAME("variant_changed")); } } break; case Variant::STRING: { if (hint == PROPERTY_HINT_ENUM) { v = hint_text.get_slice(",", p_which); - emit_signal("variant_changed"); + emit_signal(SNAME("variant_changed")); } } break; case Variant::OBJECT: { @@ -143,8 +143,8 @@ void CustomPropertyEditor::_menu_option(int p_which) { } Set<String> valid_extensions; - for (List<String>::Element *E = extensions.front(); E; E = E->next()) { - valid_extensions.insert(E->get()); + for (const String &E : extensions) { + valid_extensions.insert(E); } file->clear_filters(); @@ -159,13 +159,13 @@ void CustomPropertyEditor::_menu_option(int p_which) { REF r = v; if (!r.is_null()) { - emit_signal("resource_edit_request"); + emit_signal(SNAME("resource_edit_request")); hide(); } } break; case OBJ_MENU_CLEAR: { v = Variant(); - emit_signal("variant_changed"); + emit_signal(SNAME("variant_changed")); hide(); } break; @@ -179,9 +179,8 @@ void CustomPropertyEditor::_menu_option(int p_which) { res_orig->get_property_list(&property_list); List<Pair<String, Variant>> propvalues; - for (List<PropertyInfo>::Element *E = property_list.front(); E; E = E->next()) { + for (const PropertyInfo &pi : property_list) { Pair<String, Variant> p; - PropertyInfo &pi = E->get(); if (pi.usage & PROPERTY_USAGE_STORAGE) { p.first = pi.name; p.second = res_orig->get(pi.name); @@ -198,13 +197,12 @@ void CustomPropertyEditor::_menu_option(int p_which) { ERR_FAIL_COND(res.is_null()); - for (List<Pair<String, Variant>>::Element *E = propvalues.front(); E; E = E->next()) { - Pair<String, Variant> &p = E->get(); + for (const Pair<String, Variant> &p : propvalues) { res->set(p.first, p.second); } v = res; - emit_signal("variant_changed"); + emit_signal(SNAME("variant_changed")); hide(); } break; @@ -214,7 +212,7 @@ void CustomPropertyEditor::_menu_option(int p_which) { } break; case OBJ_MENU_PASTE: { v = EditorSettings::get_singleton()->get_resource_clipboard(); - emit_signal("variant_changed"); + emit_signal(SNAME("variant_changed")); } break; case OBJ_MENU_NEW_SCRIPT: { @@ -248,7 +246,7 @@ void CustomPropertyEditor::_menu_option(int p_which) { Ref<Resource> new_res = conversions[to_type]->convert(v); v = new_res; - emit_signal("variant_changed"); + emit_signal(SNAME("variant_changed")); break; } ERR_FAIL_COND(inheritors_array.is_empty()); @@ -281,7 +279,7 @@ void CustomPropertyEditor::_menu_option(int p_which) { } v = obj; - emit_signal("variant_changed"); + emit_signal(SNAME("variant_changed")); } break; } @@ -544,8 +542,8 @@ bool CustomPropertyEditor::edit(Object *p_owner, const String &p_name, Variant:: text_edit->set_text(v); text_edit->deselect(); - int button_margin = text_edit->get_theme_constant("button_margin", "Dialogs"); - int margin = text_edit->get_theme_constant("margin", "Dialogs"); + int button_margin = text_edit->get_theme_constant(SNAME("button_margin"), SNAME("Dialogs")); + int margin = text_edit->get_theme_constant(SNAME("margin"), SNAME("Dialogs")); action_buttons[0]->set_anchor(SIDE_LEFT, Control::ANCHOR_END); action_buttons[0]->set_anchor(SIDE_TOP, Control::ANCHOR_END); @@ -1016,13 +1014,13 @@ void CustomPropertyEditor::_file_selected(String p_file) { case Variant::STRING: { if (hint == PROPERTY_HINT_FILE || hint == PROPERTY_HINT_DIR) { v = ProjectSettings::get_singleton()->localize_path(p_file); - emit_signal("variant_changed"); + emit_signal(SNAME("variant_changed")); hide(); } if (hint == PROPERTY_HINT_GLOBAL_FILE || hint == PROPERTY_HINT_GLOBAL_DIR) { v = p_file; - emit_signal("variant_changed"); + emit_signal(SNAME("variant_changed")); hide(); } @@ -1037,7 +1035,7 @@ void CustomPropertyEditor::_file_selected(String p_file) { break; } v = res; - emit_signal("variant_changed"); + emit_signal(SNAME("variant_changed")); hide(); } break; default: { @@ -1070,7 +1068,7 @@ void CustomPropertyEditor::_type_create_selected(int p_idx) { } v = newval; - emit_signal("variant_changed"); + emit_signal(SNAME("variant_changed")); easing_draw->update(); } else if (type == Variant::OBJECT) { @@ -1092,14 +1090,14 @@ void CustomPropertyEditor::_type_create_selected(int p_idx) { ERR_FAIL_COND(!Object::cast_to<Resource>(obj)); v = obj; - emit_signal("variant_changed"); + emit_signal(SNAME("variant_changed")); hide(); } } void CustomPropertyEditor::_color_changed(const Color &p_color) { v = p_color; - emit_signal("variant_changed"); + emit_signal(SNAME("variant_changed")); } void CustomPropertyEditor::_node_path_selected(NodePath p_path) { @@ -1115,7 +1113,7 @@ void CustomPropertyEditor::_node_path_selected(NodePath p_path) { vt->set_viewport_path_in_scene(get_tree()->get_edited_scene_root()->get_path_to(to_node)); vt->setup_local_to_scene(); v = vt; - emit_signal("variant_changed"); + emit_signal(SNAME("variant_changed")); return; } @@ -1140,8 +1138,8 @@ void CustomPropertyEditor::_node_path_selected(NodePath p_path) { } if (!node) { v = p_path; - emit_signal("variant_changed"); - call_deferred("hide"); //to not mess with dialogs + emit_signal(SNAME("variant_changed")); + call_deferred(SNAME("hide")); //to not mess with dialogs return; } @@ -1152,8 +1150,8 @@ void CustomPropertyEditor::_node_path_selected(NodePath p_path) { } v = p_path; - emit_signal("variant_changed"); - call_deferred("hide"); //to not mess with dialogs + emit_signal(SNAME("variant_changed")); + call_deferred(SNAME("hide")); //to not mess with dialogs } void CustomPropertyEditor::_action_pressed(int p_which) { @@ -1164,7 +1162,7 @@ void CustomPropertyEditor::_action_pressed(int p_which) { switch (type) { case Variant::BOOL: { v = checks20[0]->is_pressed(); - emit_signal("variant_changed"); + emit_signal(SNAME("variant_changed")); } break; case Variant::INT: { if (hint == PROPERTY_HINT_LAYERS_2D_PHYSICS || @@ -1181,7 +1179,7 @@ void CustomPropertyEditor::_action_pressed(int p_which) { } v = f; - emit_signal("variant_changed"); + emit_signal(SNAME("variant_changed")); } } break; @@ -1218,7 +1216,7 @@ void CustomPropertyEditor::_action_pressed(int p_which) { file->popup_file_dialog(); } else { v = ""; - emit_signal("variant_changed"); + emit_signal(SNAME("variant_changed")); hide(); } @@ -1234,7 +1232,7 @@ void CustomPropertyEditor::_action_pressed(int p_which) { file->popup_file_dialog(); } else { v = ""; - emit_signal("variant_changed"); + emit_signal(SNAME("variant_changed")); hide(); } } @@ -1248,7 +1246,7 @@ void CustomPropertyEditor::_action_pressed(int p_which) { } else if (p_which == 1) { v = NodePath(); - emit_signal("variant_changed"); + emit_signal(SNAME("variant_changed")); hide(); } else if (p_which == 2) { if (owner->is_class("Node") && (v.get_type() == Variant::NODE_PATH) && Object::cast_to<Node>(owner)->has_node(v)) { @@ -1282,7 +1280,7 @@ void CustomPropertyEditor::_action_pressed(int p_which) { ERR_BREAK(!Object::cast_to<Resource>(obj)); v = obj; - emit_signal("variant_changed"); + emit_signal(SNAME("variant_changed")); hide(); } } else if (p_which == 1) { @@ -1293,8 +1291,8 @@ void CustomPropertyEditor::_action_pressed(int p_which) { ResourceLoader::get_recognized_extensions_for_type(type, &extensions); file->clear_filters(); - for (List<String>::Element *E = extensions.front(); E; E = E->next()) { - file->add_filter("*." + E->get() + " ; " + E->get().to_upper()); + for (const String &E : extensions) { + file->add_filter("*." + E + " ; " + E.to_upper()); } file->popup_file_dialog(); @@ -1303,13 +1301,13 @@ void CustomPropertyEditor::_action_pressed(int p_which) { RES r = v; if (!r.is_null()) { - emit_signal("resource_edit_request"); + emit_signal(SNAME("resource_edit_request")); hide(); } } else if (p_which == 3) { v = Variant(); - emit_signal("variant_changed"); + emit_signal(SNAME("variant_changed")); hide(); } else if (p_which == 4) { Ref<Resource> res_orig = v; @@ -1321,9 +1319,8 @@ void CustomPropertyEditor::_action_pressed(int p_which) { res_orig->get_property_list(&property_list); List<Pair<String, Variant>> propvalues; - for (List<PropertyInfo>::Element *E = property_list.front(); E; E = E->next()) { + for (const PropertyInfo &pi : property_list) { Pair<String, Variant> p; - PropertyInfo &pi = E->get(); if (pi.usage & PROPERTY_USAGE_STORAGE) { p.first = pi.name; p.second = res_orig->get(pi.name); @@ -1336,13 +1333,12 @@ void CustomPropertyEditor::_action_pressed(int p_which) { ERR_FAIL_COND(res.is_null()); - for (List<Pair<String, Variant>>::Element *E = propvalues.front(); E; E = E->next()) { - Pair<String, Variant> &p = E->get(); + for (const Pair<String, Variant> &p : propvalues) { res->set(p.first, p.second); } v = res; - emit_signal("variant_changed"); + emit_signal(SNAME("variant_changed")); hide(); } @@ -1386,7 +1382,7 @@ void CustomPropertyEditor::_drag_easing(const Ref<InputEvent> &p_ev) { v = val; easing_draw->update(); - emit_signal("variant_changed"); + emit_signal(SNAME("variant_changed")); } } @@ -1396,7 +1392,7 @@ void CustomPropertyEditor::_draw_easing() { Size2 s = easing_draw->get_size(); Rect2 r(Point2(), s); r = r.grow(3); - easing_draw->get_theme_stylebox("normal", "LineEdit")->draw(ci, r); + easing_draw->get_theme_stylebox(SNAME("normal"), SNAME("LineEdit"))->draw(ci, r); int points = 48; @@ -1404,9 +1400,9 @@ void CustomPropertyEditor::_draw_easing() { float exp = v; bool flip = hint_text == "attenuation"; - Ref<Font> f = easing_draw->get_theme_font("font", "Label"); - int font_size = easing_draw->get_theme_font_size("font_size", "Label"); - Color color = easing_draw->get_theme_color("font_color", "Label"); + Ref<Font> f = easing_draw->get_theme_font(SNAME("font"), SNAME("Label")); + int font_size = easing_draw->get_theme_font_size(SNAME("font_size"), SNAME("Label")); + Color color = easing_draw->get_theme_color(SNAME("font_color"), SNAME("Label")); for (int i = 1; i <= points; i++) { float ifl = i / float(points); @@ -1428,17 +1424,17 @@ void CustomPropertyEditor::_draw_easing() { void CustomPropertyEditor::_text_edit_changed() { v = text_edit->get_text(); - emit_signal("variant_changed"); + emit_signal(SNAME("variant_changed")); } void CustomPropertyEditor::_create_dialog_callback() { v = create_dialog->get_selected_type(); - emit_signal("variant_changed"); + emit_signal(SNAME("variant_changed")); } void CustomPropertyEditor::_create_selected_property(const String &p_prop) { v = p_prop; - emit_signal("variant_changed"); + emit_signal(SNAME("variant_changed")); } void CustomPropertyEditor::_modified(String p_string) { @@ -1463,7 +1459,7 @@ void CustomPropertyEditor::_modified(String p_string) { } if (v != prev_v) { - emit_signal("variant_changed"); + emit_signal(SNAME("variant_changed")); } } break; case Variant::FLOAT: { @@ -1471,14 +1467,14 @@ void CustomPropertyEditor::_modified(String p_string) { String text = TS->parse_number(value_editor[0]->get_text()); v = _parse_real_expression(text); if (v != prev_v) { - emit_signal("variant_changed"); + emit_signal(SNAME("variant_changed")); } } } break; case Variant::STRING: { v = value_editor[0]->get_text(); - emit_signal("variant_changed"); + emit_signal(SNAME("variant_changed")); } break; case Variant::VECTOR2: { Vector2 vec; @@ -1603,7 +1599,7 @@ void CustomPropertyEditor::_modified(String p_string) { case Variant::NODE_PATH: { v = NodePath(value_editor[0]->get_text()); if (v != prev_v) { - emit_signal("variant_changed"); + emit_signal(SNAME("variant_changed")); } } break; case Variant::DICTIONARY: { @@ -1642,15 +1638,15 @@ real_t CustomPropertyEditor::_parse_real_expression(String text) { void CustomPropertyEditor::_emit_changed_whole_or_field() { if (!Input::get_singleton()->is_key_pressed(KEY_SHIFT)) { - emit_signal("variant_changed"); + emit_signal(SNAME("variant_changed")); } else { - emit_signal("variant_field_changed", field_names[focused_value_editor]); + emit_signal(SNAME("variant_field_changed"), field_names[focused_value_editor]); } } void CustomPropertyEditor::_range_modified(double p_value) { v = p_value; - emit_signal("variant_changed"); + emit_signal(SNAME("variant_changed")); } void CustomPropertyEditor::_focus_enter() { @@ -1684,7 +1680,7 @@ void CustomPropertyEditor::_focus_exit() { } void CustomPropertyEditor::config_action_buttons(const List<String> &p_strings) { - Ref<StyleBox> sb = action_buttons[0]->get_theme_stylebox("panel"); + Ref<StyleBox> sb = action_buttons[0]->get_theme_stylebox(SNAME("panel")); int margin_top = sb->get_margin(SIDE_TOP); int margin_left = sb->get_margin(SIDE_LEFT); int margin_bottom = sb->get_margin(SIDE_BOTTOM); diff --git a/editor/property_selector.cpp b/editor/property_selector.cpp index 00652c02c8..a1deae92a4 100644 --- a/editor/property_selector.cpp +++ b/editor/property_selector.cpp @@ -119,77 +119,80 @@ void PropertySelector::_update_search() { bool found = false; Ref<Texture2D> type_icons[Variant::VARIANT_MAX] = { - search_options->get_theme_icon("Variant", "EditorIcons"), - search_options->get_theme_icon("bool", "EditorIcons"), - search_options->get_theme_icon("int", "EditorIcons"), - search_options->get_theme_icon("float", "EditorIcons"), - search_options->get_theme_icon("String", "EditorIcons"), - search_options->get_theme_icon("Vector2", "EditorIcons"), - search_options->get_theme_icon("Vector2i", "EditorIcons"), - search_options->get_theme_icon("Rect2", "EditorIcons"), - search_options->get_theme_icon("Rect2i", "EditorIcons"), - search_options->get_theme_icon("Vector3", "EditorIcons"), - search_options->get_theme_icon("Vector3i", "EditorIcons"), - search_options->get_theme_icon("Transform2D", "EditorIcons"), - search_options->get_theme_icon("Plane", "EditorIcons"), - search_options->get_theme_icon("Quaternion", "EditorIcons"), - search_options->get_theme_icon("AABB", "EditorIcons"), - search_options->get_theme_icon("Basis", "EditorIcons"), - search_options->get_theme_icon("Transform3D", "EditorIcons"), - search_options->get_theme_icon("Color", "EditorIcons"), - search_options->get_theme_icon("NodePath", "EditorIcons"), - search_options->get_theme_icon("RID", "EditorIcons"), - search_options->get_theme_icon("MiniObject", "EditorIcons"), - search_options->get_theme_icon("Callable", "EditorIcons"), - search_options->get_theme_icon("Signal", "EditorIcons"), - search_options->get_theme_icon("Dictionary", "EditorIcons"), - search_options->get_theme_icon("Array", "EditorIcons"), - search_options->get_theme_icon("PackedByteArray", "EditorIcons"), - search_options->get_theme_icon("PackedInt32Array", "EditorIcons"), - search_options->get_theme_icon("PackedFloat32Array", "EditorIcons"), - search_options->get_theme_icon("PackedStringArray", "EditorIcons"), - search_options->get_theme_icon("PackedVector2Array", "EditorIcons"), - search_options->get_theme_icon("PackedVector3Array", "EditorIcons"), - search_options->get_theme_icon("PackedColorArray", "EditorIcons") + search_options->get_theme_icon(SNAME("Variant"), SNAME("EditorIcons")), + search_options->get_theme_icon(SNAME("bool"), SNAME("EditorIcons")), + search_options->get_theme_icon(SNAME("int"), SNAME("EditorIcons")), + search_options->get_theme_icon(SNAME("float"), SNAME("EditorIcons")), + search_options->get_theme_icon(SNAME("String"), SNAME("EditorIcons")), + search_options->get_theme_icon(SNAME("Vector2"), SNAME("EditorIcons")), + search_options->get_theme_icon(SNAME("Vector2i"), SNAME("EditorIcons")), + search_options->get_theme_icon(SNAME("Rect2"), SNAME("EditorIcons")), + search_options->get_theme_icon(SNAME("Rect2i"), SNAME("EditorIcons")), + search_options->get_theme_icon(SNAME("Vector3"), SNAME("EditorIcons")), + search_options->get_theme_icon(SNAME("Vector3i"), SNAME("EditorIcons")), + search_options->get_theme_icon(SNAME("Transform2D"), SNAME("EditorIcons")), + search_options->get_theme_icon(SNAME("Plane"), SNAME("EditorIcons")), + search_options->get_theme_icon(SNAME("Quaternion"), SNAME("EditorIcons")), + search_options->get_theme_icon(SNAME("AABB"), SNAME("EditorIcons")), + search_options->get_theme_icon(SNAME("Basis"), SNAME("EditorIcons")), + search_options->get_theme_icon(SNAME("Transform3D"), SNAME("EditorIcons")), + search_options->get_theme_icon(SNAME("Color"), SNAME("EditorIcons")), + search_options->get_theme_icon(SNAME("StringName"), SNAME("EditorIcons")), + search_options->get_theme_icon(SNAME("NodePath"), SNAME("EditorIcons")), + search_options->get_theme_icon(SNAME("RID"), SNAME("EditorIcons")), + search_options->get_theme_icon(SNAME("MiniObject"), SNAME("EditorIcons")), + search_options->get_theme_icon(SNAME("Callable"), SNAME("EditorIcons")), + search_options->get_theme_icon(SNAME("Signal"), SNAME("EditorIcons")), + search_options->get_theme_icon(SNAME("Dictionary"), SNAME("EditorIcons")), + search_options->get_theme_icon(SNAME("Array"), SNAME("EditorIcons")), + search_options->get_theme_icon(SNAME("PackedByteArray"), SNAME("EditorIcons")), + search_options->get_theme_icon(SNAME("PackedInt32Array"), SNAME("EditorIcons")), + search_options->get_theme_icon(SNAME("PackedInt64Array"), SNAME("EditorIcons")), + search_options->get_theme_icon(SNAME("PackedFloat32Array"), SNAME("EditorIcons")), + search_options->get_theme_icon(SNAME("PackedFloat64Array"), SNAME("EditorIcons")), + search_options->get_theme_icon(SNAME("PackedStringArray"), SNAME("EditorIcons")), + search_options->get_theme_icon(SNAME("PackedVector2Array"), SNAME("EditorIcons")), + search_options->get_theme_icon(SNAME("PackedVector3Array"), SNAME("EditorIcons")), + search_options->get_theme_icon(SNAME("PackedColorArray"), SNAME("EditorIcons")) }; - for (List<PropertyInfo>::Element *E = props.front(); E; E = E->next()) { - if (E->get().usage == PROPERTY_USAGE_CATEGORY) { + for (const PropertyInfo &E : props) { + if (E.usage == PROPERTY_USAGE_CATEGORY) { if (category && category->get_first_child() == nullptr) { memdelete(category); //old category was unused } category = search_options->create_item(root); - category->set_text(0, E->get().name); + category->set_text(0, E.name); category->set_selectable(0, false); Ref<Texture2D> icon; - if (E->get().name == "Script Variables") { - icon = search_options->get_theme_icon("Script", "EditorIcons"); + if (E.name == "Script Variables") { + icon = search_options->get_theme_icon(SNAME("Script"), SNAME("EditorIcons")); } else { - icon = EditorNode::get_singleton()->get_class_icon(E->get().name); + icon = EditorNode::get_singleton()->get_class_icon(E.name); } category->set_icon(0, icon); continue; } - if (!(E->get().usage & PROPERTY_USAGE_EDITOR) && !(E->get().usage & PROPERTY_USAGE_SCRIPT_VARIABLE)) { + if (!(E.usage & PROPERTY_USAGE_EDITOR) && !(E.usage & PROPERTY_USAGE_SCRIPT_VARIABLE)) { continue; } - if (search_box->get_text() != String() && E->get().name.findn(search_text) == -1) { + if (search_box->get_text() != String() && E.name.findn(search_text) == -1) { continue; } - if (type_filter.size() && type_filter.find(E->get().type) == -1) { + if (type_filter.size() && type_filter.find(E.type) == -1) { continue; } TreeItem *item = search_options->create_item(category ? category : root); - item->set_text(0, E->get().name); - item->set_metadata(0, E->get().name); - item->set_icon(0, type_icons[E->get().type]); + item->set_text(0, E.name); + item->set_metadata(0, E.name); + item->set_icon(0, type_icons[E.type]); - if (!found && search_box->get_text() != String() && E->get().name.findn(search_text) != -1) { + if (!found && search_box->get_text() != String() && E.name.findn(search_text) != -1) { item->select(0); found = true; } @@ -228,20 +231,20 @@ void PropertySelector::_update_search() { bool found = false; bool script_methods = false; - for (List<MethodInfo>::Element *E = methods.front(); E; E = E->next()) { - if (E->get().name.begins_with("*")) { + for (MethodInfo &mi : methods) { + if (mi.name.begins_with("*")) { if (category && category->get_first_child() == nullptr) { memdelete(category); //old category was unused } category = search_options->create_item(root); - category->set_text(0, E->get().name.replace_first("*", "")); + category->set_text(0, mi.name.replace_first("*", "")); category->set_selectable(0, false); Ref<Texture2D> icon; script_methods = false; - String rep = E->get().name.replace("*", ""); - if (E->get().name == "*Script Methods") { - icon = search_options->get_theme_icon("Script", "EditorIcons"); + String rep = mi.name.replace("*", ""); + if (mi.name == "*Script Methods") { + icon = search_options->get_theme_icon(SNAME("Script"), SNAME("EditorIcons")); script_methods = true; } else { icon = EditorNode::get_singleton()->get_class_icon(rep); @@ -251,16 +254,16 @@ void PropertySelector::_update_search() { continue; } - String name = E->get().name.get_slice(":", 0); - if (!script_methods && name.begins_with("_") && !(E->get().flags & METHOD_FLAG_VIRTUAL)) { + String name = mi.name.get_slice(":", 0); + if (!script_methods && name.begins_with("_") && !(mi.flags & METHOD_FLAG_VIRTUAL)) { continue; } - if (virtuals_only && !(E->get().flags & METHOD_FLAG_VIRTUAL)) { + if (virtuals_only && !(mi.flags & METHOD_FLAG_VIRTUAL)) { continue; } - if (!virtuals_only && (E->get().flags & METHOD_FLAG_VIRTUAL)) { + if (!virtuals_only && (mi.flags & METHOD_FLAG_VIRTUAL)) { continue; } @@ -270,8 +273,6 @@ void PropertySelector::_update_search() { TreeItem *item = search_options->create_item(category ? category : root); - MethodInfo mi = E->get(); - String desc; if (mi.name.find(":") != -1) { desc = mi.name.get_slice(":", 1) + " "; @@ -303,11 +304,11 @@ void PropertySelector::_update_search() { desc += ")"; - if (E->get().flags & METHOD_FLAG_CONST) { + if (mi.flags & METHOD_FLAG_CONST) { desc += " const"; } - if (E->get().flags & METHOD_FLAG_VIRTUAL) { + if (mi.flags & METHOD_FLAG_VIRTUAL) { desc += " virtual"; } @@ -334,7 +335,7 @@ void PropertySelector::_confirmed() { if (!ti) { return; } - emit_signal("selected", ti->get_metadata(0)); + emit_signal(SNAME("selected"), ti->get_metadata(0)); hide(); } diff --git a/editor/quick_open.cpp b/editor/quick_open.cpp index e8e13bab21..bda7540a23 100644 --- a/editor/quick_open.cpp +++ b/editor/quick_open.cpp @@ -64,7 +64,7 @@ void EditorQuickOpen::_build_search_cache(EditorFileSystemDirectory *p_efsd) { // Store refs to used icons. String ext = file.get_extension(); if (!icons.has(ext)) { - icons.insert(ext, get_theme_icon((has_theme_icon(file_type, "EditorIcons") ? file_type : "Object"), "EditorIcons")); + icons.insert(ext, get_theme_icon((has_theme_icon(file_type, SNAME("EditorIcons")) ? file_type : String("Object")), SNAME("EditorIcons"))); } } } @@ -140,7 +140,7 @@ void EditorQuickOpen::_confirmed() { return; } _cleanup(); - emit_signal("quick_open"); + emit_signal(SNAME("quick_open")); hide(); } @@ -228,7 +228,7 @@ void EditorQuickOpen::_notification(int p_what) { } void EditorQuickOpen::_theme_changed() { - search_box->set_right_icon(search_options->get_theme_icon("Search", "EditorIcons")); + search_box->set_right_icon(search_options->get_theme_icon(SNAME("Search"), SNAME("EditorIcons"))); } void EditorQuickOpen::_bind_methods() { diff --git a/editor/rename_dialog.cpp b/editor/rename_dialog.cpp index 0f15d4b119..d86e2656d4 100644 --- a/editor/rename_dialog.cpp +++ b/editor/rename_dialog.cpp @@ -35,12 +35,18 @@ #include "editor_scale.h" #include "editor_settings.h" #include "editor_themes.h" -#include "modules/regex/regex.h" #include "plugins/script_editor_plugin.h" #include "scene/gui/control.h" #include "scene/gui/label.h" #include "scene/gui/tab_container.h" +#include "modules/modules_enabled.gen.h" +#ifdef MODULE_REGEX_ENABLED +#include "modules/regex/regex.h" +#else +#error "Can't build editor rename dialog without RegEx module." +#endif + RenameDialog::RenameDialog(SceneTreeEditor *p_scene_tree_editor, UndoRedo *p_undo_redo) { scene_tree_editor = p_scene_tree_editor; undo_redo = p_undo_redo; @@ -385,11 +391,11 @@ void RenameDialog::_update_preview(String new_text) { if (new_name == preview_node->get_name()) { // New name is identical to the old one. Don't color it as much to avoid distracting the user. - const Color accent_color = EditorNode::get_singleton()->get_gui_base()->get_theme_color("accent_color", "Editor"); - const Color text_color = EditorNode::get_singleton()->get_gui_base()->get_theme_color("default_color", "RichTextLabel"); + const Color accent_color = EditorNode::get_singleton()->get_gui_base()->get_theme_color(SNAME("accent_color"), SNAME("Editor")); + const Color text_color = EditorNode::get_singleton()->get_gui_base()->get_theme_color(SNAME("default_color"), SNAME("RichTextLabel")); lbl_preview->add_theme_color_override("font_color", accent_color.lerp(text_color, 0.5)); } else { - lbl_preview->add_theme_color_override("font_color", EditorNode::get_singleton()->get_gui_base()->get_theme_color("success_color", "Editor")); + lbl_preview->add_theme_color_override("font_color", EditorNode::get_singleton()->get_gui_base()->get_theme_color(SNAME("success_color"), SNAME("Editor"))); } } @@ -475,7 +481,7 @@ void RenameDialog::_error_handler(void *p_self, const char *p_func, const char * self->has_errors = true; self->lbl_preview_title->set_text(TTR("Regular Expression Error:")); - self->lbl_preview->add_theme_color_override("font_color", EditorNode::get_singleton()->get_gui_base()->get_theme_color("error_color", "Editor")); + self->lbl_preview->add_theme_color_override("font_color", EditorNode::get_singleton()->get_gui_base()->get_theme_color(SNAME("error_color"), SNAME("Editor"))); self->lbl_preview->set_text(vformat(TTR("At character %s"), err_str)); } @@ -588,7 +594,7 @@ void RenameDialog::rename() { continue; } - scene_tree_editor->emit_signal("node_prerename", n, new_name); + scene_tree_editor->emit_signal(SNAME("node_prerename"), n, new_name); undo_redo->add_do_method(scene_tree_editor, "_rename_node", n->get_instance_id(), new_name); undo_redo->add_undo_method(scene_tree_editor, "_rename_node", n->get_instance_id(), n->get_name()); } diff --git a/editor/reparent_dialog.cpp b/editor/reparent_dialog.cpp index aab046c235..f862260212 100644 --- a/editor/reparent_dialog.cpp +++ b/editor/reparent_dialog.cpp @@ -50,7 +50,7 @@ void ReparentDialog::_cancel() { void ReparentDialog::_reparent() { if (tree->get_selected()) { - emit_signal("reparent", tree->get_selected()->get_path(), keep_transform->is_pressed()); + emit_signal(SNAME("reparent"), tree->get_selected()->get_path(), keep_transform->is_pressed()); hide(); } } diff --git a/editor/scene_tree_dock.cpp b/editor/scene_tree_dock.cpp index 166b82d744..c4d47c7594 100644 --- a/editor/scene_tree_dock.cpp +++ b/editor/scene_tree_dock.cpp @@ -229,7 +229,7 @@ void SceneTreeDock::_perform_instantiate_scenes(const Vector<String> &p_files, N editor_data->get_undo_redo().commit_action(); editor->push_item(instances[instances.size() - 1]); for (int i = 0; i < instances.size(); i++) { - emit_signal("node_created", instances[i]); + emit_signal(SNAME("node_created"), instances[i]); } } @@ -263,8 +263,8 @@ void SceneTreeDock::_replace_with_branch_scene(const String &p_file, Node *base) List<Node *> owned; base->get_owned_by(base->get_owner(), &owned); Array owners; - for (List<Node *>::Element *F = owned.front(); F; F = F->next()) { - owners.push_back(F->get()); + for (Node *F : owned) { + owners.push_back(F); } undo_redo->add_do_method(instantiated_scene, "set_owner", edited_scene); undo_redo->add_undo_method(this, "_set_owners", edited_scene, owners); @@ -385,7 +385,7 @@ void SceneTreeDock::_tool_selected(int p_tool, bool p_confirm_override) { create_dialog->popup_create(true); if (!p_confirm_override) { - emit_signal("add_node_used"); + emit_signal(SNAME("add_node_used")); } } break; case TOOL_INSTANTIATE: { @@ -402,7 +402,7 @@ void SceneTreeDock::_tool_selected(int p_tool, bool p_confirm_override) { quick_open->popup_dialog("PackedScene", true); quick_open->set_title(TTR("Instantiate Child Scene")); if (!p_confirm_override) { - emit_signal("add_node_used"); + emit_signal(SNAME("add_node_used")); } } break; case TOOL_EXPAND_COLLAPSE: { @@ -441,8 +441,7 @@ void SceneTreeDock::_tool_selected(int p_tool, bool p_confirm_override) { selection.sort_custom<Node::Comparator>(); - for (List<Node *>::Element *E = selection.front(); E; E = E->next()) { - Node *node = E->get(); + for (Node *node : selection) { Map<const Node *, Node *> duplimap; Node *dup = node->duplicate_from_editor(duplimap); @@ -462,8 +461,8 @@ void SceneTreeDock::_tool_selected(int p_tool, bool p_confirm_override) { bool has_cycle = false; if (edited_scene->get_filename() != String()) { - for (List<Node *>::Element *E = node_clipboard.front(); E; E = E->next()) { - if (edited_scene->get_filename() == E->get()->get_filename()) { + for (Node *E : node_clipboard) { + if (edited_scene->get_filename() == E->get_filename()) { has_cycle = true; break; } @@ -496,16 +495,15 @@ void SceneTreeDock::_tool_selected(int p_tool, bool p_confirm_override) { if (target_scene != clipboard_source_scene) { if (!clipboard_resource_remap.has(target_scene)) { Map<RES, RES> remap; - for (List<Node *>::Element *E = node_clipboard.front(); E; E = E->next()) { - _create_remap_for_node(E->get(), remap); + for (Node *E : node_clipboard) { + _create_remap_for_node(E, remap); } clipboard_resource_remap[target_scene] = remap; } resource_remap = clipboard_resource_remap[target_scene]; } - for (List<Node *>::Element *E = node_clipboard.front(); E; E = E->next()) { - Node *node = E->get(); + for (Node *node : node_clipboard) { Map<const Node *, Node *> duplimap; Node *dup = node->duplicate_from_editor(duplimap, resource_remap); @@ -544,6 +542,11 @@ void SceneTreeDock::_tool_selected(int p_tool, bool p_confirm_override) { break; } + if (reset_create_dialog) { + create_dialog->set_base_type("Node"); + reset_create_dialog = false; + } + Node *selected = scene_tree->get_selected(); if (!selected && !editor_selection->get_selected_node_list().is_empty()) { selected = editor_selection->get_selected_node_list().front()->get(); @@ -622,8 +625,8 @@ void SceneTreeDock::_tool_selected(int p_tool, bool p_confirm_override) { int lowest_id = common_parent->get_child_count() - 1; int highest_id = 0; - for (List<Node *>::Element *E = selection.front(); E; E = E->next()) { - int index = E->get()->get_index(); + for (Node *E : selection) { + int index = E->get_index(); if (index > highest_id) { highest_id = index; @@ -632,7 +635,7 @@ void SceneTreeDock::_tool_selected(int p_tool, bool p_confirm_override) { lowest_id = index; } - if (E->get()->get_parent() != common_parent) { + if (E->get_parent() != common_parent) { common_parent = nullptr; } } @@ -699,8 +702,7 @@ void SceneTreeDock::_tool_selected(int p_tool, bool p_confirm_override) { Node *add_below_node = selection.back()->get(); - for (List<Node *>::Element *E = selection.front(); E; E = E->next()) { - Node *node = E->get(); + for (Node *node : selection) { Node *parent = node->get_parent(); List<Node *> owned; @@ -719,11 +721,11 @@ void SceneTreeDock::_tool_selected(int p_tool, bool p_confirm_override) { editor_data->get_undo_redo().add_do_method(add_below_node, "add_sibling", dup); - for (List<Node *>::Element *F = owned.front(); F; F = F->next()) { - if (!duplimap.has(F->get())) { + for (Node *F : owned) { + if (!duplimap.has(F)) { continue; } - Node *d = duplimap[F->get()]; + Node *d = duplimap[F]; editor_data->get_undo_redo().add_do_method(d, "set_owner", node->get_owner()); } editor_data->get_undo_redo().add_do_method(editor_selection, "add_node", dup); @@ -766,8 +768,8 @@ void SceneTreeDock::_tool_selected(int p_tool, bool p_confirm_override) { List<Node *> nodes = editor_selection->get_selected_node_list(); Set<Node *> nodeset; - for (List<Node *>::Element *E = nodes.front(); E; E = E->next()) { - nodeset.insert(E->get()); + for (Node *E : nodes) { + nodeset.insert(E); } reparent_dialog->set_current(nodeset); reparent_dialog->popup_centered_clamped(Size2(350, 700) * EDSCALE); @@ -1057,7 +1059,7 @@ void SceneTreeDock::_tool_selected(int p_tool, bool p_confirm_override) { if (e) { Node *node = e->get(); if (node) { - scene_tree->emit_signal("open", node->get_filename()); + scene_tree->emit_signal(SNAME("open"), node->get_filename()); } } } break; @@ -1090,7 +1092,7 @@ void SceneTreeDock::_tool_selected(int p_tool, bool p_confirm_override) { if (e) { Node *node = e->get(); if (node && node->get_scene_inherited_state().is_valid()) { - scene_tree->emit_signal("open", node->get_scene_inherited_state()->get_path()); + scene_tree->emit_signal(SNAME("open"), node->get_scene_inherited_state()->get_path()); } } } break; @@ -1157,6 +1159,19 @@ void SceneTreeDock::_tool_selected(int p_tool, bool p_confirm_override) { } } +void SceneTreeDock::_property_selected(int p_idx) { + ERR_FAIL_NULL(property_drop_node); + _perform_property_drop(property_drop_node, menu_properties->get_item_metadata(p_idx), ResourceLoader::load(resource_drop_path)); + property_drop_node = nullptr; +} + +void SceneTreeDock::_perform_property_drop(Node *p_node, String p_property, RES p_res) { + editor_data->get_undo_redo().create_action(vformat(TTR("Set %s"), p_property)); + editor_data->get_undo_redo().add_do_property(p_node, p_property, p_res); + editor_data->get_undo_redo().add_undo_property(p_node, p_property, p_node->get(p_property)); + editor_data->get_undo_redo().commit_action(); +} + void SceneTreeDock::add_root_node(Node *p_node) { editor_data->get_undo_redo().create_action(TTR("New Scene Root")); editor_data->get_undo_redo().add_do_method(editor, "set_edited_scene", p_node); @@ -1198,12 +1213,12 @@ void SceneTreeDock::_notification(int p_what) { spatial_editor_plugin->get_spatial_editor()->connect("item_lock_status_changed", Callable(scene_tree, "_update_tree")); spatial_editor_plugin->get_spatial_editor()->connect("item_group_status_changed", Callable(scene_tree, "_update_tree")); - button_add->set_icon(get_theme_icon("Add", "EditorIcons")); - button_instance->set_icon(get_theme_icon("Instance", "EditorIcons")); - button_create_script->set_icon(get_theme_icon("ScriptCreate", "EditorIcons")); - button_detach_script->set_icon(get_theme_icon("ScriptRemove", "EditorIcons")); + button_add->set_icon(get_theme_icon(SNAME("Add"), SNAME("EditorIcons"))); + button_instance->set_icon(get_theme_icon(SNAME("Instance"), SNAME("EditorIcons"))); + button_create_script->set_icon(get_theme_icon(SNAME("ScriptCreate"), SNAME("EditorIcons"))); + button_detach_script->set_icon(get_theme_icon(SNAME("ScriptRemove"), SNAME("EditorIcons"))); - filter->set_right_icon(get_theme_icon("Search", "EditorIcons")); + filter->set_right_icon(get_theme_icon(SNAME("Search"), SNAME("EditorIcons"))); filter->set_clear_button_enabled(true); // create_root_dialog @@ -1218,7 +1233,7 @@ void SceneTreeDock::_notification(int p_what) { Button *node_shortcuts_toggle = memnew(Button); node_shortcuts_toggle->set_flat(true); node_shortcuts_toggle->set_name("NodeShortcutsToggle"); - node_shortcuts_toggle->set_icon(get_theme_icon("Favorites", "EditorIcons")); + node_shortcuts_toggle->set_icon(get_theme_icon(SNAME("Favorites"), SNAME("EditorIcons"))); node_shortcuts_toggle->set_toggle_mode(true); node_shortcuts_toggle->set_tooltip(TTR("Switch to Favorite Nodes")); node_shortcuts_toggle->set_pressed(EDITOR_GET("_use_favorites_root_selection")); @@ -1238,19 +1253,19 @@ void SceneTreeDock::_notification(int p_what) { button_2d = memnew(Button); beginner_node_shortcuts->add_child(button_2d); button_2d->set_text(TTR("2D Scene")); - button_2d->set_icon(get_theme_icon("Node2D", "EditorIcons")); + button_2d->set_icon(get_theme_icon(SNAME("Node2D"), SNAME("EditorIcons"))); button_2d->connect("pressed", callable_mp(this, &SceneTreeDock::_tool_selected), make_binds(TOOL_CREATE_2D_SCENE, false)); button_3d = memnew(Button); beginner_node_shortcuts->add_child(button_3d); button_3d->set_text(TTR("3D Scene")); - button_3d->set_icon(get_theme_icon("Node3D", "EditorIcons")); + button_3d->set_icon(get_theme_icon(SNAME("Node3D"), SNAME("EditorIcons"))); button_3d->connect("pressed", callable_mp(this, &SceneTreeDock::_tool_selected), make_binds(TOOL_CREATE_3D_SCENE, false)); button_ui = memnew(Button); beginner_node_shortcuts->add_child(button_ui); button_ui->set_text(TTR("User Interface")); - button_ui->set_icon(get_theme_icon("Control", "EditorIcons")); + button_ui->set_icon(get_theme_icon(SNAME("Control"), SNAME("EditorIcons"))); button_ui->connect("pressed", callable_mp(this, &SceneTreeDock::_tool_selected), make_binds(TOOL_CREATE_USER_INTERFACE, false)); VBoxContainer *favorite_node_shortcuts = memnew(VBoxContainer); @@ -1260,7 +1275,7 @@ void SceneTreeDock::_notification(int p_what) { button_custom = memnew(Button); node_shortcuts->add_child(button_custom); button_custom->set_text(TTR("Other Node")); - button_custom->set_icon(get_theme_icon("Add", "EditorIcons")); + button_custom->set_icon(get_theme_icon(SNAME("Add"), SNAME("EditorIcons"))); button_custom->connect("pressed", callable_bind(callable_mp(this, &SceneTreeDock::_tool_selected), TOOL_NEW, false)); node_shortcuts->add_spacer(); @@ -1276,16 +1291,16 @@ void SceneTreeDock::_notification(int p_what) { clear_inherit_confirm->disconnect("confirmed", callable_mp(this, &SceneTreeDock::_tool_selected)); } break; case EditorSettings::NOTIFICATION_EDITOR_SETTINGS_CHANGED: { - button_add->set_icon(get_theme_icon("Add", "EditorIcons")); - button_instance->set_icon(get_theme_icon("Instance", "EditorIcons")); - button_create_script->set_icon(get_theme_icon("ScriptCreate", "EditorIcons")); - button_detach_script->set_icon(get_theme_icon("ScriptRemove", "EditorIcons")); - button_2d->set_icon(get_theme_icon("Node2D", "EditorIcons")); - button_3d->set_icon(get_theme_icon("Node3D", "EditorIcons")); - button_ui->set_icon(get_theme_icon("Control", "EditorIcons")); - button_custom->set_icon(get_theme_icon("Add", "EditorIcons")); - - filter->set_right_icon(get_theme_icon("Search", "EditorIcons")); + button_add->set_icon(get_theme_icon(SNAME("Add"), SNAME("EditorIcons"))); + button_instance->set_icon(get_theme_icon(SNAME("Instance"), SNAME("EditorIcons"))); + button_create_script->set_icon(get_theme_icon(SNAME("ScriptCreate"), SNAME("EditorIcons"))); + button_detach_script->set_icon(get_theme_icon(SNAME("ScriptRemove"), SNAME("EditorIcons"))); + button_2d->set_icon(get_theme_icon(SNAME("Node2D"), SNAME("EditorIcons"))); + button_3d->set_icon(get_theme_icon(SNAME("Node3D"), SNAME("EditorIcons"))); + button_ui->set_icon(get_theme_icon(SNAME("Control"), SNAME("EditorIcons"))); + button_custom->set_icon(get_theme_icon(SNAME("Add"), SNAME("EditorIcons"))); + + filter->set_right_icon(get_theme_icon(SNAME("Search"), SNAME("EditorIcons"))); filter->set_clear_button_enabled(true); } break; case NOTIFICATION_PROCESS: { @@ -1366,30 +1381,25 @@ void SceneTreeDock::_set_owners(Node *p_owner, const Array &p_nodes) { } } -void SceneTreeDock::_fill_path_renames(Vector<StringName> base_path, Vector<StringName> new_base_path, Node *p_node, List<Pair<NodePath, NodePath>> *p_renames) { +void SceneTreeDock::_fill_path_renames(Vector<StringName> base_path, Vector<StringName> new_base_path, Node *p_node, Map<Node *, NodePath> *p_renames) { base_path.push_back(p_node->get_name()); if (new_base_path.size()) { new_base_path.push_back(p_node->get_name()); } - NodePath from(base_path, true); - NodePath to; + NodePath new_path; if (new_base_path.size()) { - to = NodePath(new_base_path, true); + new_path = NodePath(new_base_path, true); } - Pair<NodePath, NodePath> npp; - npp.first = from; - npp.second = to; - - p_renames->push_back(npp); + p_renames->insert(p_node, new_path); for (int i = 0; i < p_node->get_child_count(); i++) { _fill_path_renames(base_path, new_base_path, p_node->get_child(i), p_renames); } } -void SceneTreeDock::fill_path_renames(Node *p_node, Node *p_new_parent, List<Pair<NodePath, NodePath>> *p_renames) { +void SceneTreeDock::fill_path_renames(Node *p_node, Node *p_new_parent, Map<Node *, NodePath> *p_renames) { Vector<StringName> base_path; Node *n = p_node->get_parent(); while (n) { @@ -1412,50 +1422,41 @@ void SceneTreeDock::fill_path_renames(Node *p_node, Node *p_new_parent, List<Pai _fill_path_renames(base_path, new_base_path, p_node, p_renames); } -bool SceneTreeDock::_update_node_path(const NodePath &p_root_path, NodePath &r_node_path, List<Pair<NodePath, NodePath>> *p_renames) { - NodePath root_path_new = p_root_path; - for (List<Pair<NodePath, NodePath>>::Element *F = p_renames->front(); F; F = F->next()) { - if (p_root_path == F->get().first) { - root_path_new = F->get().second; - break; - } - } - - // Goes through all paths to check if it's matching. - for (List<Pair<NodePath, NodePath>>::Element *F = p_renames->front(); F; F = F->next()) { - NodePath rel_path_old = p_root_path.rel_path_to(F->get().first); +bool SceneTreeDock::_update_node_path(Node *p_root_node, NodePath &r_node_path, Map<Node *, NodePath> *p_renames) const { + Node *target_node = p_root_node->get_node_or_null(r_node_path); + ERR_FAIL_NULL_V_MSG(target_node, false, "Found invalid node path '" + String(r_node_path) + "' on node '" + String(scene_root->get_path_to(p_root_node)) + "'"); - // If old path detected, then it needs to be replaced with the new one. - if (r_node_path == rel_path_old) { - NodePath rel_path_new = F->get().second; + // Try to find the target node in modified node paths. + Map<Node *, NodePath>::Element *found_node_path = p_renames->find(target_node); + if (found_node_path) { + Map<Node *, NodePath>::Element *found_root_path = p_renames->find(p_root_node); + NodePath root_path_new = found_root_path ? found_root_path->get() : p_root_node->get_path(); + r_node_path = root_path_new.rel_path_to(found_node_path->get()); - // If not empty, get new relative path. - if (!rel_path_new.is_empty()) { - rel_path_new = root_path_new.rel_path_to(rel_path_new); - } + return true; + } - r_node_path = rel_path_new; - return true; + // Update the path if the base node has changed and has not been deleted. + Map<Node *, NodePath>::Element *found_root_path = p_renames->find(p_root_node); + if (found_root_path) { + NodePath root_path_new = found_root_path->get(); + if (!root_path_new.is_empty()) { + NodePath old_abs_path = NodePath(String(p_root_node->get_path()).plus_file(r_node_path)); + old_abs_path.simplify(); + r_node_path = root_path_new.rel_path_to(old_abs_path); } - // Update the node itself if it has a valid node path and has not been deleted. - if (p_root_path == F->get().first && r_node_path != NodePath() && F->get().second != NodePath()) { - NodePath abs_path = NodePath(String(root_path_new).plus_file(r_node_path)).simplified(); - NodePath rel_path_new = F->get().second.rel_path_to(abs_path); - - r_node_path = rel_path_new; - return true; - } + return true; } return false; } -bool SceneTreeDock::_check_node_path_recursive(const NodePath &p_root_path, Variant &r_variant, List<Pair<NodePath, NodePath>> *p_renames) { +bool SceneTreeDock::_check_node_path_recursive(Node *p_root_node, Variant &r_variant, Map<Node *, NodePath> *p_renames) const { switch (r_variant.get_type()) { case Variant::NODE_PATH: { NodePath node_path = r_variant; - if (_update_node_path(p_root_path, node_path, p_renames)) { + if (!node_path.is_empty() && _update_node_path(p_root_node, node_path, p_renames)) { r_variant = node_path; return true; } @@ -1466,7 +1467,7 @@ bool SceneTreeDock::_check_node_path_recursive(const NodePath &p_root_path, Vari bool updated = false; for (int i = 0; i < a.size(); i++) { Variant value = a[i]; - if (_check_node_path_recursive(p_root_path, value, p_renames)) { + if (_check_node_path_recursive(p_root_node, value, p_renames)) { if (!updated) { a = a.duplicate(); // Need to duplicate for undo-redo to work. updated = true; @@ -1485,7 +1486,7 @@ bool SceneTreeDock::_check_node_path_recursive(const NodePath &p_root_path, Vari bool updated = false; for (int i = 0; i < d.size(); i++) { Variant value = d.get_value_at_index(i); - if (_check_node_path_recursive(p_root_path, value, p_renames)) { + if (_check_node_path_recursive(p_root_node, value, p_renames)) { if (!updated) { d = d.duplicate(); // Need to duplicate for undo-redo to work. updated = true; @@ -1506,7 +1507,7 @@ bool SceneTreeDock::_check_node_path_recursive(const NodePath &p_root_path, Vari return false; } -void SceneTreeDock::perform_node_renames(Node *p_base, List<Pair<NodePath, NodePath>> *p_renames, Map<Ref<Animation>, Set<int>> *r_rem_anims) { +void SceneTreeDock::perform_node_renames(Node *p_base, Map<Node *, NodePath> *p_renames, Map<Ref<Animation>, Set<int>> *r_rem_anims) { Map<Ref<Animation>, Set<int>> rem_anims; if (!r_rem_anims) { r_rem_anims = &rem_anims; @@ -1520,19 +1521,24 @@ void SceneTreeDock::perform_node_renames(Node *p_base, List<Pair<NodePath, NodeP return; } + // No renaming if base node is deleted. + Map<Node *, NodePath>::Element *found_base_path = p_renames->find(p_base); + if (found_base_path && found_base_path->get().is_empty()) { + return; + } + // Renaming node paths used in node properties. List<PropertyInfo> properties; p_base->get_property_list(&properties); - NodePath base_root_path = p_base->get_path(); - for (List<PropertyInfo>::Element *E = properties.front(); E; E = E->next()) { - if (!(E->get().usage & (PROPERTY_USAGE_STORAGE | PROPERTY_USAGE_EDITOR))) { + for (const PropertyInfo &E : properties) { + if (!(E.usage & (PROPERTY_USAGE_STORAGE | PROPERTY_USAGE_EDITOR))) { continue; } - String propertyname = E->get().name; + String propertyname = E.name; Variant old_variant = p_base->get(propertyname); Variant updated_variant = old_variant; - if (_check_node_path_recursive(base_root_path, updated_variant, p_renames)) { + if (_check_node_path_recursive(p_base, updated_variant, p_renames)) { editor_data->get_undo_redo().add_do_property(p_base, propertyname, updated_variant); editor_data->get_undo_redo().add_undo_property(p_base, propertyname, old_variant); p_base->set(propertyname, updated_variant); @@ -1548,21 +1554,11 @@ void SceneTreeDock::perform_node_renames(Node *p_base, List<Pair<NodePath, NodeP Node *root = ap->get_node(ap->get_root()); if (root) { - NodePath root_path = root->get_path(); - NodePath new_root_path = root_path; - - for (List<Pair<NodePath, NodePath>>::Element *E = p_renames->front(); E; E = E->next()) { - if (E->get().first == root_path) { - new_root_path = E->get().second; - break; - } - } - - if (new_root_path != NodePath()) { - //will not be erased - - for (List<StringName>::Element *E = anims.front(); E; E = E->next()) { - Ref<Animation> anim = ap->get_animation(E->get()); + Map<Node *, NodePath>::Element *found_root_path = p_renames->find(root); + NodePath new_root_path = found_root_path ? found_root_path->get() : root->get_path(); + if (!new_root_path.is_empty()) { // No renaming if root node is deleted. + for (const StringName &E : anims) { + Ref<Animation> anim = ap->get_animation(E); if (!r_rem_anims->has(anim)) { r_rem_anims->insert(anim, Set<int>()); Set<int> &ran = r_rem_anims->find(anim)->get(); @@ -1584,47 +1580,44 @@ void SceneTreeDock::perform_node_renames(Node *p_base, List<Pair<NodePath, NodeP continue; } - NodePath old_np = n->get_path(); - if (!ran.has(i)) { continue; //channel was removed } - for (List<Pair<NodePath, NodePath>>::Element *F = p_renames->front(); F; F = F->next()) { - if (F->get().first == old_np) { - if (F->get().second == NodePath()) { - //will be erased - - int idx = 0; - Set<int>::Element *EI = ran.front(); - ERR_FAIL_COND(!EI); //bug - while (EI->get() != i) { - idx++; - EI = EI->next(); - ERR_FAIL_COND(!EI); //another bug - } - - editor_data->get_undo_redo().add_do_method(anim.ptr(), "remove_track", idx); - editor_data->get_undo_redo().add_undo_method(anim.ptr(), "add_track", anim->track_get_type(i), idx); - editor_data->get_undo_redo().add_undo_method(anim.ptr(), "track_set_path", idx, track_np); - editor_data->get_undo_redo().add_undo_method(anim.ptr(), "track_set_interpolation_type", idx, anim->track_get_interpolation_type(i)); - for (int j = 0; j < anim->track_get_key_count(i); j++) { - editor_data->get_undo_redo().add_undo_method(anim.ptr(), "track_insert_key", idx, anim->track_get_key_time(i, j), anim->track_get_key_value(i, j), anim->track_get_key_transition(i, j)); - } - - ran.erase(i); //byebye channel - - } else { - //will be renamed - NodePath rel_path = new_root_path.rel_path_to(F->get().second); - - NodePath new_path = NodePath(rel_path.get_names(), track_np.get_subnames(), false); - if (new_path == track_np) { - continue; //bleh - } - editor_data->get_undo_redo().add_do_method(anim.ptr(), "track_set_path", i, new_path); - editor_data->get_undo_redo().add_undo_method(anim.ptr(), "track_set_path", i, track_np); + Map<Node *, NodePath>::Element *found_path = p_renames->find(n); + if (found_path) { + if (found_path->get() == NodePath()) { + //will be erased + + int idx = 0; + Set<int>::Element *EI = ran.front(); + ERR_FAIL_COND(!EI); //bug + while (EI->get() != i) { + idx++; + EI = EI->next(); + ERR_FAIL_COND(!EI); //another bug } + + editor_data->get_undo_redo().add_do_method(anim.ptr(), "remove_track", idx); + editor_data->get_undo_redo().add_undo_method(anim.ptr(), "add_track", anim->track_get_type(i), idx); + editor_data->get_undo_redo().add_undo_method(anim.ptr(), "track_set_path", idx, track_np); + editor_data->get_undo_redo().add_undo_method(anim.ptr(), "track_set_interpolation_type", idx, anim->track_get_interpolation_type(i)); + for (int j = 0; j < anim->track_get_key_count(i); j++) { + editor_data->get_undo_redo().add_undo_method(anim.ptr(), "track_insert_key", idx, anim->track_get_key_time(i, j), anim->track_get_key_value(i, j), anim->track_get_key_transition(i, j)); + } + + ran.erase(i); //byebye channel + + } else { + //will be renamed + NodePath rel_path = new_root_path.rel_path_to(found_path->get()); + + NodePath new_path = NodePath(rel_path.get_names(), track_np.get_subnames(), false); + if (new_path == track_np) { + continue; //bleh + } + editor_data->get_undo_redo().add_do_method(anim.ptr(), "track_set_path", i, new_path); + editor_data->get_undo_redo().add_undo_method(anim.ptr(), "track_set_path", i, track_np); } } } @@ -1639,7 +1632,7 @@ void SceneTreeDock::perform_node_renames(Node *p_base, List<Pair<NodePath, NodeP } void SceneTreeDock::_node_prerenamed(Node *p_node, const String &p_new_name) { - List<Pair<NodePath, NodePath>> path_renames; + Map<Node *, NodePath> path_renames; Vector<StringName> base_path; Node *n = p_node->get_parent(); @@ -1654,10 +1647,8 @@ void SceneTreeDock::_node_prerenamed(Node *p_node, const String &p_new_name) { new_base_path.push_back(p_new_name); - Pair<NodePath, NodePath> npp; - npp.first = NodePath(base_path, true); - npp.second = NodePath(new_base_path, true); - path_renames.push_back(npp); + NodePath new_path(new_base_path, true); + path_renames[p_node] = new_path; for (int i = 0; i < p_node->get_child_count(); i++) { _fill_path_renames(base_path, new_base_path, p_node->get_child(i), &path_renames); @@ -1669,8 +1660,8 @@ void SceneTreeDock::_node_prerenamed(Node *p_node, const String &p_new_name) { bool SceneTreeDock::_validate_no_foreign() { List<Node *> selection = editor_selection->get_selected_node_list(); - for (List<Node *>::Element *E = selection.front(); E; E = E->next()) { - if (E->get() != edited_scene && E->get()->get_owner() != edited_scene) { + for (Node *E : selection) { + if (E != edited_scene && E->get_owner() != edited_scene) { accept->set_text(TTR("Can't operate on nodes from a foreign scene!")); accept->popup_centered(); return false; @@ -1679,11 +1670,11 @@ bool SceneTreeDock::_validate_no_foreign() { // When edited_scene inherits from another one the root Node will be the parent Scene, // we don't want to consider that Node a foreign one otherwise we would not be able to // delete it. - if (edited_scene->get_scene_inherited_state().is_valid() && edited_scene == E->get()) { + if (edited_scene->get_scene_inherited_state().is_valid() && edited_scene == E) { continue; } - if (edited_scene->get_scene_inherited_state().is_valid() && edited_scene->get_scene_inherited_state()->find_node_by_path(edited_scene->get_path_to(E->get())) >= 0) { + if (edited_scene->get_scene_inherited_state().is_valid() && edited_scene->get_scene_inherited_state()->find_node_by_path(edited_scene->get_path_to(E)) >= 0) { accept->set_text(TTR("Can't operate on nodes the current scene inherits from!")); accept->popup_centered(); return false; @@ -1696,8 +1687,8 @@ bool SceneTreeDock::_validate_no_foreign() { bool SceneTreeDock::_validate_no_instance() { List<Node *> selection = editor_selection->get_selected_node_list(); - for (List<Node *>::Element *E = selection.front(); E; E = E->next()) { - if (E->get() != edited_scene && E->get()->get_filename() != "") { + for (Node *E : selection) { + if (E != edited_scene && E->get_filename() != "") { accept->set_text(TTR("This operation can't be done on instantiated scenes.")); accept->popup_centered(); return false; @@ -1719,8 +1710,8 @@ void SceneTreeDock::_node_reparent(NodePath p_path, bool p_keep_global_xform) { Vector<Node *> nodes; - for (List<Node *>::Element *E = selection.front(); E; E = E->next()) { - nodes.push_back(E->get()); + for (Node *E : selection) { + nodes.push_back(E); } _do_reparent(new_parent, -1, nodes, p_keep_global_xform); @@ -1762,7 +1753,7 @@ void SceneTreeDock::_do_reparent(Node *p_new_parent, int p_position_in_parent, V editor_data->get_undo_redo().create_action(TTR("Reparent Node")); - List<Pair<NodePath, NodePath>> path_renames; + Map<Node *, NodePath> path_renames; Vector<StringName> former_names; int inc = 0; @@ -1777,8 +1768,8 @@ void SceneTreeDock::_do_reparent(Node *p_new_parent, int p_position_in_parent, V List<Node *> owned; node->get_owned_by(node->get_owner(), &owned); Array owners; - for (List<Node *>::Element *E = owned.front(); E; E = E->next()) { - owners.push_back(E->get()); + for (Node *E : owned) { + owners.push_back(E); } if (new_parent == node->get_parent() && node->get_index() < p_position_in_parent + ni) { @@ -1799,21 +1790,24 @@ void SceneTreeDock::_do_reparent(Node *p_new_parent, int p_position_in_parent, V // Name was modified, fix the path renames. if (old_name.casecmp_to(new_name) != 0) { // Fix the to name to have the new name. - NodePath old_new_name = path_renames[ni].second; - NodePath new_path; - - Vector<StringName> unfixed_new_names = old_new_name.get_names(); - Vector<StringName> fixed_new_names; + Map<Node *, NodePath>::Element *found_path = path_renames.find(node); + if (found_path) { + NodePath old_new_name = found_path->get(); - // Get last name and replace with fixed new name. - for (int a = 0; a < (unfixed_new_names.size() - 1); a++) { - fixed_new_names.push_back(unfixed_new_names[a]); - } - fixed_new_names.push_back(new_name); + Vector<StringName> unfixed_new_names = old_new_name.get_names(); + Vector<StringName> fixed_new_names; - NodePath fixed_node_path = NodePath(fixed_new_names, true); + // Get last name and replace with fixed new name. + for (int a = 0; a < (unfixed_new_names.size() - 1); a++) { + fixed_new_names.push_back(unfixed_new_names[a]); + } + fixed_new_names.push_back(new_name); - path_renames[ni].second = fixed_node_path; + NodePath fixed_node_path = NodePath(fixed_new_names, true); + path_renames[node] = fixed_node_path; + } else { + ERR_PRINT("Internal error. Can't find renamed path for node '" + node->get_path() + "'"); + } } editor_data->get_undo_redo().add_do_method(ed, "live_debug_reparent_node", edited_scene->get_path_to(node), edited_scene->get_path_to(new_parent), new_name, p_position_in_parent + inc); @@ -1850,8 +1844,8 @@ void SceneTreeDock::_do_reparent(Node *p_new_parent, int p_position_in_parent, V List<Node *> owned; node->get_owned_by(node->get_owner(), &owned); Array owners; - for (List<Node *>::Element *E = owned.front(); E; E = E->next()) { - owners.push_back(E->get()); + for (Node *E : owned) { + owners.push_back(E); } int child_pos = node->get_index(); @@ -1931,10 +1925,10 @@ void SceneTreeDock::_script_created(Ref<Script> p_script) { } editor_data->get_undo_redo().create_action(TTR("Attach Script")); - for (List<Node *>::Element *E = selected.front(); E; E = E->next()) { - Ref<Script> existing = E->get()->get_script(); - editor_data->get_undo_redo().add_do_method(E->get(), "set_script", p_script); - editor_data->get_undo_redo().add_undo_method(E->get(), "set_script", existing); + for (Node *E : selected) { + Ref<Script> existing = E->get_script(); + editor_data->get_undo_redo().add_do_method(E, "set_script", p_script); + editor_data->get_undo_redo().add_undo_method(E, "set_script", existing); editor_data->get_undo_redo().add_do_method(this, "_update_script_button"); editor_data->get_undo_redo().add_undo_method(this, "_update_script_button"); } @@ -2009,8 +2003,8 @@ void SceneTreeDock::_delete_confirm(bool p_cut) { bool entire_scene = false; - for (List<Node *>::Element *E = remove_list.front(); E; E = E->next()) { - if (E->get() == edited_scene) { + for (Node *E : remove_list) { + if (E == edited_scene) { entire_scene = true; } } @@ -2024,11 +2018,10 @@ void SceneTreeDock::_delete_confirm(bool p_cut) { } else { remove_list.sort_custom<Node::Comparator>(); //sort nodes to keep positions - List<Pair<NodePath, NodePath>> path_renames; + Map<Node *, NodePath> path_renames; //delete from animation - for (List<Node *>::Element *E = remove_list.front(); E; E = E->next()) { - Node *n = E->get(); + for (Node *n : remove_list) { if (!n->is_inside_tree() || !n->get_parent()) { continue; } @@ -2038,8 +2031,7 @@ void SceneTreeDock::_delete_confirm(bool p_cut) { perform_node_renames(nullptr, &path_renames); //delete for read - for (List<Node *>::Element *E = remove_list.front(); E; E = E->next()) { - Node *n = E->get(); + for (Node *n : remove_list) { if (!n->is_inside_tree() || !n->get_parent()) { continue; } @@ -2047,8 +2039,8 @@ void SceneTreeDock::_delete_confirm(bool p_cut) { List<Node *> owned; n->get_owned_by(n->get_owner(), &owned); Array owners; - for (List<Node *>::Element *F = owned.front(); F; F = F->next()) { - owners.push_back(F->get()); + for (Node *F : owned) { + owners.push_back(F); } editor_data->get_undo_redo().add_do_method(n->get_parent(), "remove_child", n); @@ -2172,7 +2164,7 @@ void SceneTreeDock::_do_create(Node *p_parent) { ct->set_size(ms); } - emit_signal("node_created", c); + emit_signal(SNAME("node_created"), c); } void SceneTreeDock::_create() { @@ -2201,8 +2193,7 @@ void SceneTreeDock::_create() { UndoRedo *ur = EditorNode::get_singleton()->get_undo_redo(); ur->create_action(TTR("Change type of node(s)")); - for (List<Node *>::Element *E = selection.front(); E; E = E->next()) { - Node *n = E->get(); + for (Node *n : selection) { ERR_FAIL_COND(!n); Variant c = create_dialog->instance_selected(); @@ -2259,8 +2250,8 @@ void SceneTreeDock::_create() { _do_create(parent); Vector<Node *> nodes; - for (List<Node *>::Element *E = selection.front(); E; E = E->next()) { - nodes.push_back(E->get()); + for (Node *E : selection) { + nodes.push_back(E); } // This works because editor_selection was cleared and populated with last created node in _do_create() @@ -2268,7 +2259,7 @@ void SceneTreeDock::_create() { _do_reparent(last_created, -1, nodes, true); } - scene_tree->get_scene_tree()->call_deferred("grab_focus"); + scene_tree->get_scene_tree()->call_deferred(SNAME("grab_focus")); } void SceneTreeDock::replace_node(Node *p_node, Node *p_by_node, bool p_keep_properties, bool p_remove_old) { @@ -2280,13 +2271,13 @@ void SceneTreeDock::replace_node(Node *p_node, Node *p_by_node, bool p_keep_prop List<PropertyInfo> pinfo; n->get_property_list(&pinfo); - for (List<PropertyInfo>::Element *E = pinfo.front(); E; E = E->next()) { - if (!(E->get().usage & PROPERTY_USAGE_STORAGE)) { + for (const PropertyInfo &E : pinfo) { + if (!(E.usage & PROPERTY_USAGE_STORAGE)) { continue; } - if (E->get().name == "__meta__") { - Dictionary metadata = n->get(E->get().name); + if (E.name == "__meta__") { + Dictionary metadata = n->get(E.name); if (metadata.has("_editor_description_")) { newnode->set_meta("_editor_description_", metadata["_editor_description_"]); } @@ -2303,8 +2294,8 @@ void SceneTreeDock::replace_node(Node *p_node, Node *p_by_node, bool p_keep_prop continue; } - if (default_oldnode->get(E->get().name) != n->get(E->get().name)) { - newnode->set(E->get().name, n->get(E->get().name)); + if (default_oldnode->get(E.name) != n->get(E.name)) { + newnode->set(E.name, n->get(E.name)); } } @@ -2317,12 +2308,11 @@ void SceneTreeDock::replace_node(Node *p_node, Node *p_by_node, bool p_keep_prop List<MethodInfo> sl; n->get_signal_list(&sl); - for (List<MethodInfo>::Element *E = sl.front(); E; E = E->next()) { + for (const MethodInfo &E : sl) { List<Object::Connection> cl; - n->get_signal_connection_list(E->get().name, &cl); + n->get_signal_connection_list(E.name, &cl); - for (List<Object::Connection>::Element *F = cl.front(); F; F = F->next()) { - Object::Connection &c = F->get(); + for (const Object::Connection &c : cl) { if (!(c.flags & Object::CONNECT_PERSIST)) { continue; } @@ -2515,9 +2505,51 @@ void SceneTreeDock::_files_dropped(Vector<String> p_files, NodePath p_to, int p_ Node *node = get_node(p_to); ERR_FAIL_COND(!node); - int to_pos = -1; - _normalize_drop(node, to_pos, p_type); - _perform_instantiate_scenes(p_files, node, to_pos); + if (scene_tree->get_scene_tree()->get_drop_mode_flags() & Tree::DROP_MODE_INBETWEEN) { + // Dropped PackedScene, instance it. + int to_pos = -1; + _normalize_drop(node, to_pos, p_type); + _perform_instantiate_scenes(p_files, node, to_pos); + } else { + String res_path = p_files[0]; + StringName res_type = EditorFileSystem::get_singleton()->get_file_type(res_path); + List<String> valid_properties; + + List<PropertyInfo> pinfo; + node->get_property_list(&pinfo); + + for (const PropertyInfo &p : pinfo) { + if (!(p.usage & PROPERTY_USAGE_EDITOR) || !(p.usage & PROPERTY_USAGE_STORAGE) || p.hint != PROPERTY_HINT_RESOURCE_TYPE) { + continue; + } + Vector<String> valid_types = p.hint_string.split(","); + + for (const String &prop_type : valid_types) { + if (res_type == prop_type || ClassDB::is_parent_class(res_type, prop_type) || EditorNode::get_editor_data().script_class_is_parent(res_type, prop_type)) { + valid_properties.push_back(p.name); + break; + } + } + } + + if (valid_properties.size() > 1) { + property_drop_node = node; + resource_drop_path = res_path; + + bool capitalize = bool(EDITOR_GET("interface/inspector/capitalize_properties")); + menu_properties->clear(); + for (const String &p : valid_properties) { + menu_properties->add_item(capitalize ? p.capitalize() : p); + menu_properties->set_item_metadata(menu_properties->get_item_count() - 1, p); + } + + menu_properties->set_size(Size2(1, 1)); + menu_properties->set_position(get_screen_position() + get_local_mouse_position()); + menu_properties->popup(); + } else if (!valid_properties.is_empty()) { + _perform_property_drop(node, valid_properties[0], ResourceLoader::load(res_path)); + } + } } void SceneTreeDock::_script_dropped(String p_file, NodePath p_to) { @@ -2547,8 +2579,8 @@ void SceneTreeDock::_nodes_dragged(Array p_nodes, NodePath p_to, int p_type) { } Vector<Node *> nodes; - for (List<Node *>::Element *E = selection.front(); E; E = E->next()) { - nodes.push_back(E->get()); + for (Node *E : selection) { + nodes.push_back(E); } int to_pos = -1; @@ -2564,15 +2596,15 @@ void SceneTreeDock::_add_children_to_popup(Object *p_obj, int p_depth) { List<PropertyInfo> pinfo; p_obj->get_property_list(&pinfo); - for (List<PropertyInfo>::Element *E = pinfo.front(); E; E = E->next()) { - if (!(E->get().usage & PROPERTY_USAGE_EDITOR)) { + for (const PropertyInfo &E : pinfo) { + if (!(E.usage & PROPERTY_USAGE_EDITOR)) { continue; } - if (E->get().hint != PROPERTY_HINT_RESOURCE_TYPE) { + if (E.hint != PROPERTY_HINT_RESOURCE_TYPE) { continue; } - Variant value = p_obj->get(E->get().name); + Variant value = p_obj->get(E.name); if (value.get_type() != Variant::OBJECT) { continue; } @@ -2587,7 +2619,7 @@ void SceneTreeDock::_add_children_to_popup(Object *p_obj, int p_depth) { menu->add_submenu_item(TTR("Sub-Resources"), "Sub-Resources"); } int index = menu_subresources->get_item_count(); - menu_subresources->add_icon_item(icon, E->get().name.capitalize(), EDIT_SUBRESOURCE_BASE + subresources.size()); + menu_subresources->add_icon_item(icon, E.name.capitalize(), EDIT_SUBRESOURCE_BASE + subresources.size()); menu_subresources->set_item_h_offset(index, p_depth * 10 * EDSCALE); subresources.push_back(obj->get_instance_id()); @@ -2599,8 +2631,8 @@ void SceneTreeDock::_tree_rmb(const Vector2 &p_menu_pos) { if (!EditorNode::get_singleton()->get_edited_scene()) { menu->clear(); if (profile_allow_editing) { - menu->add_icon_shortcut(get_theme_icon("Add", "EditorIcons"), ED_GET_SHORTCUT("scene_tree/add_child_node"), TOOL_NEW); - menu->add_icon_shortcut(get_theme_icon("Instance", "EditorIcons"), ED_GET_SHORTCUT("scene_tree/instance_scene"), TOOL_INSTANTIATE); + menu->add_icon_shortcut(get_theme_icon(SNAME("Add"), SNAME("EditorIcons")), ED_GET_SHORTCUT("scene_tree/add_child_node"), TOOL_NEW); + menu->add_icon_shortcut(get_theme_icon(SNAME("Instance"), SNAME("EditorIcons")), ED_GET_SHORTCUT("scene_tree/instance_scene"), TOOL_INSTANTIATE); } menu->set_size(Size2(1, 1)); @@ -2632,10 +2664,10 @@ void SceneTreeDock::_tree_rmb(const Vector2 &p_menu_pos) { menu->add_separator(); } - menu->add_icon_shortcut(get_theme_icon("Add", "EditorIcons"), ED_GET_SHORTCUT("scene_tree/add_child_node"), TOOL_NEW); - menu->add_icon_shortcut(get_theme_icon("Instance", "EditorIcons"), ED_GET_SHORTCUT("scene_tree/instance_scene"), TOOL_INSTANTIATE); + menu->add_icon_shortcut(get_theme_icon(SNAME("Add"), SNAME("EditorIcons")), ED_GET_SHORTCUT("scene_tree/add_child_node"), TOOL_NEW); + menu->add_icon_shortcut(get_theme_icon(SNAME("Instance"), SNAME("EditorIcons")), ED_GET_SHORTCUT("scene_tree/instance_scene"), TOOL_INSTANTIATE); } - menu->add_icon_shortcut(get_theme_icon("Collapse", "EditorIcons"), ED_GET_SHORTCUT("scene_tree/expand_collapse_all"), TOOL_EXPAND_COLLAPSE); + menu->add_icon_shortcut(get_theme_icon(SNAME("Collapse"), SNAME("EditorIcons")), ED_GET_SHORTCUT("scene_tree/expand_collapse_all"), TOOL_EXPAND_COLLAPSE); menu->add_separator(); existing_script = selected->get_script(); @@ -2659,18 +2691,18 @@ void SceneTreeDock::_tree_rmb(const Vector2 &p_menu_pos) { if (full_selection.size() == 1) { add_separator = true; - menu->add_icon_shortcut(get_theme_icon("ScriptCreate", "EditorIcons"), ED_GET_SHORTCUT("scene_tree/attach_script"), TOOL_ATTACH_SCRIPT); + menu->add_icon_shortcut(get_theme_icon(SNAME("ScriptCreate"), SNAME("EditorIcons")), ED_GET_SHORTCUT("scene_tree/attach_script"), TOOL_ATTACH_SCRIPT); if (existing_script.is_valid()) { - menu->add_icon_shortcut(get_theme_icon("ScriptExtend", "EditorIcons"), ED_GET_SHORTCUT("scene_tree/extend_script"), TOOL_EXTEND_SCRIPT); + menu->add_icon_shortcut(get_theme_icon(SNAME("ScriptExtend"), SNAME("EditorIcons")), ED_GET_SHORTCUT("scene_tree/extend_script"), TOOL_EXTEND_SCRIPT); } } if (existing_script.is_valid() && existing_script_removable) { add_separator = true; - menu->add_icon_shortcut(get_theme_icon("ScriptRemove", "EditorIcons"), ED_GET_SHORTCUT("scene_tree/detach_script"), TOOL_DETACH_SCRIPT); + menu->add_icon_shortcut(get_theme_icon(SNAME("ScriptRemove"), SNAME("EditorIcons")), ED_GET_SHORTCUT("scene_tree/detach_script"), TOOL_DETACH_SCRIPT); } else if (full_selection.size() > 1) { bool script_exists = false; - for (List<Node *>::Element *E = full_selection.front(); E; E = E->next()) { - if (!E->get()->get_script().is_null()) { + for (Node *E : full_selection) { + if (!E->get_script().is_null()) { script_exists = true; break; } @@ -2678,7 +2710,7 @@ void SceneTreeDock::_tree_rmb(const Vector2 &p_menu_pos) { if (script_exists) { add_separator = true; - menu->add_icon_shortcut(get_theme_icon("ScriptRemove", "EditorIcons"), ED_GET_SHORTCUT("scene_tree/detach_script"), TOOL_DETACH_SCRIPT); + menu->add_icon_shortcut(get_theme_icon(SNAME("ScriptRemove"), SNAME("EditorIcons")), ED_GET_SHORTCUT("scene_tree/detach_script"), TOOL_DETACH_SCRIPT); } } @@ -2689,41 +2721,41 @@ void SceneTreeDock::_tree_rmb(const Vector2 &p_menu_pos) { if (profile_allow_editing) { if (full_selection.size() == 1) { - menu->add_icon_shortcut(get_theme_icon("Rename", "EditorIcons"), ED_GET_SHORTCUT("scene_tree/rename"), TOOL_RENAME); + menu->add_icon_shortcut(get_theme_icon(SNAME("Rename"), SNAME("EditorIcons")), ED_GET_SHORTCUT("scene_tree/rename"), TOOL_RENAME); } bool can_replace = true; - for (List<Node *>::Element *E = selection.front(); E; E = E->next()) { - if (E->get() != edited_scene && (E->get()->get_owner() != edited_scene || E->get()->get_filename() != "")) { + for (Node *E : selection) { + if (E != edited_scene && (E->get_owner() != edited_scene || E->get_filename() != "")) { can_replace = false; break; } } if (can_replace) { - menu->add_icon_shortcut(get_theme_icon("Reload", "EditorIcons"), ED_GET_SHORTCUT("scene_tree/change_node_type"), TOOL_REPLACE); + menu->add_icon_shortcut(get_theme_icon(SNAME("Reload"), SNAME("EditorIcons")), ED_GET_SHORTCUT("scene_tree/change_node_type"), TOOL_REPLACE); } if (scene_tree->get_selected() != edited_scene) { menu->add_separator(); - menu->add_icon_shortcut(get_theme_icon("MoveUp", "EditorIcons"), ED_GET_SHORTCUT("scene_tree/move_up"), TOOL_MOVE_UP); - menu->add_icon_shortcut(get_theme_icon("MoveDown", "EditorIcons"), ED_GET_SHORTCUT("scene_tree/move_down"), TOOL_MOVE_DOWN); - menu->add_icon_shortcut(get_theme_icon("Duplicate", "EditorIcons"), ED_GET_SHORTCUT("scene_tree/duplicate"), TOOL_DUPLICATE); - menu->add_icon_shortcut(get_theme_icon("Reparent", "EditorIcons"), ED_GET_SHORTCUT("scene_tree/reparent"), TOOL_REPARENT); - menu->add_icon_shortcut(get_theme_icon("ReparentToNewNode", "EditorIcons"), ED_GET_SHORTCUT("scene_tree/reparent_to_new_node"), TOOL_REPARENT_TO_NEW_NODE); + menu->add_icon_shortcut(get_theme_icon(SNAME("MoveUp"), SNAME("EditorIcons")), ED_GET_SHORTCUT("scene_tree/move_up"), TOOL_MOVE_UP); + menu->add_icon_shortcut(get_theme_icon(SNAME("MoveDown"), SNAME("EditorIcons")), ED_GET_SHORTCUT("scene_tree/move_down"), TOOL_MOVE_DOWN); + menu->add_icon_shortcut(get_theme_icon(SNAME("Duplicate"), SNAME("EditorIcons")), ED_GET_SHORTCUT("scene_tree/duplicate"), TOOL_DUPLICATE); + menu->add_icon_shortcut(get_theme_icon(SNAME("Reparent"), SNAME("EditorIcons")), ED_GET_SHORTCUT("scene_tree/reparent"), TOOL_REPARENT); + menu->add_icon_shortcut(get_theme_icon(SNAME("ReparentToNewNode"), SNAME("EditorIcons")), ED_GET_SHORTCUT("scene_tree/reparent_to_new_node"), TOOL_REPARENT_TO_NEW_NODE); if (selection.size() == 1) { - menu->add_icon_shortcut(get_theme_icon("NewRoot", "EditorIcons"), ED_GET_SHORTCUT("scene_tree/make_root"), TOOL_MAKE_ROOT); + menu->add_icon_shortcut(get_theme_icon(SNAME("NewRoot"), SNAME("EditorIcons")), ED_GET_SHORTCUT("scene_tree/make_root"), TOOL_MAKE_ROOT); } } } if (selection.size() == 1) { if (profile_allow_editing) { menu->add_separator(); - menu->add_icon_shortcut(get_theme_icon("CreateNewSceneFrom", "EditorIcons"), ED_GET_SHORTCUT("scene_tree/save_branch_as_scene"), TOOL_NEW_SCENE_FROM); + menu->add_icon_shortcut(get_theme_icon(SNAME("CreateNewSceneFrom"), SNAME("EditorIcons")), ED_GET_SHORTCUT("scene_tree/save_branch_as_scene"), TOOL_NEW_SCENE_FROM); } if (full_selection.size() == 1) { menu->add_separator(); - menu->add_icon_shortcut(get_theme_icon("CopyNodePath", "EditorIcons"), ED_GET_SHORTCUT("scene_tree/copy_node_path"), TOOL_COPY_NODE_PATH); + menu->add_icon_shortcut(get_theme_icon(SNAME("CopyNodePath"), SNAME("EditorIcons")), ED_GET_SHORTCUT("scene_tree/copy_node_path"), TOOL_COPY_NODE_PATH); } bool is_external = (selection[0]->get_filename() != ""); @@ -2735,7 +2767,7 @@ void SceneTreeDock::_tree_rmb(const Vector2 &p_menu_pos) { if (profile_allow_editing) { menu->add_item(TTR("Clear Inheritance"), TOOL_SCENE_CLEAR_INHERITANCE); } - menu->add_icon_item(get_theme_icon("Load", "EditorIcons"), TTR("Open in Editor"), TOOL_SCENE_OPEN_INHERITED); + menu->add_icon_item(get_theme_icon(SNAME("Load"), SNAME("EditorIcons")), TTR("Open in Editor"), TOOL_SCENE_OPEN_INHERITED); } else if (!is_top_level) { menu->add_separator(); bool editable = EditorNode::get_singleton()->get_edited_scene()->is_editable_instance(selection[0]); @@ -2745,7 +2777,7 @@ void SceneTreeDock::_tree_rmb(const Vector2 &p_menu_pos) { menu->add_check_item(TTR("Load As Placeholder"), TOOL_SCENE_USE_PLACEHOLDER); menu->add_item(TTR("Make Local"), TOOL_SCENE_MAKE_LOCAL); } - menu->add_icon_item(get_theme_icon("Load", "EditorIcons"), TTR("Open in Editor"), TOOL_SCENE_OPEN); + menu->add_icon_item(get_theme_icon(SNAME("Load"), SNAME("EditorIcons")), TTR("Open in Editor"), TOOL_SCENE_OPEN); if (profile_allow_editing) { menu->set_item_checked(menu->get_item_idx_from_text(TTR("Editable Children")), editable); menu->set_item_checked(menu->get_item_idx_from_text(TTR("Load As Placeholder")), placeholder); @@ -2757,14 +2789,14 @@ void SceneTreeDock::_tree_rmb(const Vector2 &p_menu_pos) { if (profile_allow_editing && selection.size() > 1) { //this is not a commonly used action, it makes no sense for it to be where it was nor always present. menu->add_separator(); - menu->add_icon_shortcut(get_theme_icon("Rename", "EditorIcons"), ED_GET_SHORTCUT("scene_tree/batch_rename"), TOOL_BATCH_RENAME); + menu->add_icon_shortcut(get_theme_icon(SNAME("Rename"), SNAME("EditorIcons")), ED_GET_SHORTCUT("scene_tree/batch_rename"), TOOL_BATCH_RENAME); } menu->add_separator(); - menu->add_icon_item(get_theme_icon("Help", "EditorIcons"), TTR("Open Documentation"), TOOL_OPEN_DOCUMENTATION); + menu->add_icon_item(get_theme_icon(SNAME("Help"), SNAME("EditorIcons")), TTR("Open Documentation"), TOOL_OPEN_DOCUMENTATION); if (profile_allow_editing) { menu->add_separator(); - menu->add_icon_shortcut(get_theme_icon("Remove", "EditorIcons"), ED_SHORTCUT("scene_tree/delete", TTR("Delete Node(s)"), KEY_DELETE), TOOL_ERASE); + menu->add_icon_shortcut(get_theme_icon(SNAME("Remove"), SNAME("EditorIcons")), ED_SHORTCUT("scene_tree/delete", TTR("Delete Node(s)"), KEY_DELETE), TOOL_ERASE); } menu->set_size(Size2(1, 1)); menu->set_position(p_menu_pos); @@ -2906,7 +2938,7 @@ void SceneTreeDock::_remote_tree_selected() { edit_remote->set_pressed(true); edit_local->set_pressed(false); - emit_signal("remote_tree_selected"); + emit_signal(SNAME("remote_tree_selected")); } void SceneTreeDock::_local_tree_selected() { @@ -3007,8 +3039,8 @@ void SceneTreeDock::_feature_profile_changed() { } void SceneTreeDock::_clear_clipboard() { - for (List<Node *>::Element *E = node_clipboard.front(); E; E = E->next()) { - memdelete(E->get()); + for (Node *E : node_clipboard) { + memdelete(E); } node_clipboard.clear(); clipboard_resource_remap.clear(); @@ -3019,18 +3051,18 @@ void SceneTreeDock::_create_remap_for_node(Node *p_node, Map<RES, RES> &r_remap) p_node->get_property_list(&props); bool is_instantiated = EditorPropertyRevert::may_node_be_in_instance(p_node); - for (List<PropertyInfo>::Element *E = props.front(); E; E = E->next()) { - if (!(E->get().usage & PROPERTY_USAGE_STORAGE)) { + for (const PropertyInfo &E : props) { + if (!(E.usage & PROPERTY_USAGE_STORAGE)) { continue; } - Variant v = p_node->get(E->get().name); + Variant v = p_node->get(E.name); if (v.is_ref()) { RES res = v; if (res.is_valid()) { if (is_instantiated) { Variant orig; - if (EditorPropertyRevert::get_instantiated_node_original_property(p_node, E->get().name, orig)) { + if (EditorPropertyRevert::get_instantiated_node_original_property(p_node, E.name, orig)) { if (!EditorPropertyRevert::is_node_property_different(p_node, v, orig)) { continue; } @@ -3055,12 +3087,12 @@ void SceneTreeDock::_create_remap_for_resource(RES p_resource, Map<RES, RES> &r_ List<PropertyInfo> props; p_resource->get_property_list(&props); - for (List<PropertyInfo>::Element *E = props.front(); E; E = E->next()) { - if (!(E->get().usage & PROPERTY_USAGE_STORAGE)) { + for (const PropertyInfo &E : props) { + if (!(E.usage & PROPERTY_USAGE_STORAGE)) { continue; } - Variant v = p_resource->get(E->get().name); + Variant v = p_resource->get(E.name); if (v.is_ref()) { RES res = v; if (res.is_valid()) { @@ -3276,6 +3308,10 @@ SceneTreeDock::SceneTreeDock(EditorNode *p_editor, Node *p_scene_root, EditorSel first_enter = true; restore_script_editor_on_drag = false; + menu_properties = memnew(PopupMenu); + add_child(menu_properties); + menu_properties->connect("id_pressed", callable_mp(this, &SceneTreeDock::_property_selected)); + clear_inherit_confirm = memnew(ConfirmationDialog); clear_inherit_confirm->set_text(TTR("Clear Inheritance? (No Undo!)")); clear_inherit_confirm->get_ok_button()->set_text(TTR("Clear")); diff --git a/editor/scene_tree_dock.h b/editor/scene_tree_dock.h index 08d992d465..4952122cb7 100644 --- a/editor/scene_tree_dock.h +++ b/editor/scene_tree_dock.h @@ -123,8 +123,13 @@ class SceneTreeDock : public VBoxContainer { HBoxContainer *tool_hbc; void _tool_selected(int p_tool, bool p_confirm_override = false); + void _property_selected(int p_idx); void _node_collapsed(Object *p_obj); + Node *property_drop_node = nullptr; + String resource_drop_path; + void _perform_property_drop(Node *p_node, String p_property, RES p_res); + EditorData *editor_data; EditorSelection *editor_selection; @@ -147,6 +152,7 @@ class SceneTreeDock : public VBoxContainer { PopupMenu *menu; PopupMenu *menu_subresources; + PopupMenu *menu_properties; ConfirmationDialog *clear_inherit_confirm; bool first_enter; @@ -211,7 +217,7 @@ class SceneTreeDock : public VBoxContainer { void _selection_changed(); void _update_script_button(); - void _fill_path_renames(Vector<StringName> base_path, Vector<StringName> new_base_path, Node *p_node, List<Pair<NodePath, NodePath>> *p_renames); + void _fill_path_renames(Vector<StringName> base_path, Vector<StringName> new_base_path, Node *p_node, Map<Node *, NodePath> *p_renames); void _normalize_drop(Node *&to_node, int &to_pos, int p_type); @@ -247,8 +253,8 @@ class SceneTreeDock : public VBoxContainer { static SceneTreeDock *singleton; static void _update_configuration_warning(); - static bool _update_node_path(const NodePath &p_root_path, NodePath &r_node_path, List<Pair<NodePath, NodePath>> *p_renames); - static bool _check_node_path_recursive(const NodePath &p_root_path, Variant &r_variant, List<Pair<NodePath, NodePath>> *p_renames); + bool _update_node_path(Node *p_root_node, NodePath &r_node_path, Map<Node *, NodePath> *p_renames) const; + bool _check_node_path_recursive(Node *p_root_node, Variant &r_variant, Map<Node *, NodePath> *p_renames) const; protected: void _notification(int p_what); @@ -266,8 +272,8 @@ public: void instantiate(const String &p_file); void instantiate_scenes(const Vector<String> &p_files, Node *p_parent = nullptr); void set_selected(Node *p_node, bool p_emit_selected = false); - void fill_path_renames(Node *p_node, Node *p_new_parent, List<Pair<NodePath, NodePath>> *p_renames); - void perform_node_renames(Node *p_base, List<Pair<NodePath, NodePath>> *p_renames, Map<Ref<Animation>, Set<int>> *r_rem_anims = nullptr); + void fill_path_renames(Node *p_node, Node *p_new_parent, Map<Node *, NodePath> *p_renames); + void perform_node_renames(Node *p_base, Map<Node *, NodePath> *p_renames, Map<Ref<Animation>, Set<int>> *r_rem_anims = nullptr); SceneTreeEditor *get_tree_editor() { return scene_tree; } EditorData *get_editor_data() { return editor_data; } diff --git a/editor/scene_tree_editor.cpp b/editor/scene_tree_editor.cpp index b2c66ee1e7..83b0203f32 100644 --- a/editor/scene_tree_editor.cpp +++ b/editor/scene_tree_editor.cpp @@ -63,15 +63,15 @@ void SceneTreeEditor::_cell_button_pressed(Object *p_item, int p_column, int p_i if (p_id == BUTTON_SUBSCENE) { if (n == get_scene_node()) { if (n && n->get_scene_inherited_state().is_valid()) { - emit_signal("open", n->get_scene_inherited_state()->get_path()); + emit_signal(SNAME("open"), n->get_scene_inherited_state()->get_path()); } } else { - emit_signal("open", n->get_filename()); + emit_signal(SNAME("open"), n->get_filename()); } } else if (p_id == BUTTON_SCRIPT) { Ref<Script> script_typed = n->get_script(); if (!script_typed.is_null()) { - emit_signal("open_script", script_typed); + emit_signal(SNAME("open_script"), script_typed); } } else if (p_id == BUTTON_VISIBILITY) { @@ -79,8 +79,7 @@ void SceneTreeEditor::_cell_button_pressed(Object *p_item, int p_column, int p_i _toggle_visible(n); List<Node *> selection = editor_selection->get_selected_node_list(); if (selection.size() > 1 && selection.find(n) != nullptr) { - for (List<Node *>::Element *E = selection.front(); E; E = E->next()) { - Node *nv = E->get(); + for (Node *nv : selection) { ERR_FAIL_COND(!nv); if (nv == n) { continue; @@ -197,19 +196,19 @@ bool SceneTreeEditor::_add_nodes(Node *p_node, TreeItem *p_parent, bool p_scroll item->set_metadata(0, p_node->get_path()); if (connect_to_script_mode) { - Color accent = get_theme_color("accent_color", "Editor"); + Color accent = get_theme_color(SNAME("accent_color"), SNAME("Editor")); Ref<Script> script = p_node->get_script(); if (!script.is_null() && EditorNode::get_singleton()->get_object_custom_type_base(p_node) != script) { //has script - item->add_button(0, get_theme_icon("Script", "EditorIcons"), BUTTON_SCRIPT); + item->add_button(0, get_theme_icon(SNAME("Script"), SNAME("EditorIcons")), BUTTON_SCRIPT); } else { //has no script (or script is a custom type) - item->set_custom_color(0, get_theme_color("disabled_font_color", "Editor")); + item->set_custom_color(0, get_theme_color(SNAME("disabled_font_color"), SNAME("Editor"))); item->set_selectable(0, false); if (!script.is_null()) { // make sure to mark the script if a custom type - item->add_button(0, get_theme_icon("Script", "EditorIcons"), BUTTON_SCRIPT); + item->add_button(0, get_theme_icon(SNAME("Script"), SNAME("EditorIcons")), BUTTON_SCRIPT); item->set_button_disabled(0, item->get_button_count(0) - 1, true); } @@ -226,7 +225,7 @@ bool SceneTreeEditor::_add_nodes(Node *p_node, TreeItem *p_parent, bool p_scroll } } else if (part_of_subscene) { if (valid_types.size() == 0) { - item->set_custom_color(0, get_theme_color("disabled_font_color", "Editor")); + item->set_custom_color(0, get_theme_color(SNAME("disabled_font_color"), SNAME("Editor"))); } } else if (marked.has(p_node)) { String node_name = p_node->get_name(); @@ -235,15 +234,15 @@ bool SceneTreeEditor::_add_nodes(Node *p_node, TreeItem *p_parent, bool p_scroll } item->set_text(0, node_name); item->set_selectable(0, marked_selectable); - item->set_custom_color(0, get_theme_color("accent_color", "Editor")); + item->set_custom_color(0, get_theme_color(SNAME("accent_color"), SNAME("Editor"))); } else if (!p_node->can_process()) { - item->set_custom_color(0, get_theme_color("disabled_font_color", "Editor")); + item->set_custom_color(0, get_theme_color(SNAME("disabled_font_color"), SNAME("Editor"))); } else if (!marked_selectable && !marked_children_selectable) { Node *node = p_node; while (node) { if (marked.has(node)) { item->set_selectable(0, false); - item->set_custom_color(0, get_theme_color("error_color", "Editor")); + item->set_custom_color(0, get_theme_color(SNAME("error_color"), SNAME("Editor"))); break; } node = node->get_parent(); @@ -254,7 +253,7 @@ bool SceneTreeEditor::_add_nodes(Node *p_node, TreeItem *p_parent, bool p_scroll String warning = p_node->get_configuration_warnings_as_string(); if (!warning.is_empty()) { - item->add_button(0, get_theme_icon("NodeWarning", "EditorIcons"), BUTTON_WARNING, false, TTR("Node configuration warning:") + "\n" + warning); + item->add_button(0, get_theme_icon(SNAME("NodeWarning"), SNAME("EditorIcons")), BUTTON_WARNING, false, TTR("Node configuration warning:") + "\n" + warning); } int num_connections = p_node->get_persistent_signal_connection_count(); @@ -279,11 +278,11 @@ bool SceneTreeEditor::_add_nodes(Node *p_node, TreeItem *p_parent, bool p_scroll Ref<Texture2D> icon_temp; SceneTreeEditorButton signal_temp = BUTTON_SIGNALS; if (num_connections >= 1 && num_groups >= 1) { - icon_temp = get_theme_icon("SignalsAndGroups", "EditorIcons"); + icon_temp = get_theme_icon(SNAME("SignalsAndGroups"), SNAME("EditorIcons")); } else if (num_connections >= 1) { - icon_temp = get_theme_icon("Signals", "EditorIcons"); + icon_temp = get_theme_icon(SNAME("Signals"), SNAME("EditorIcons")); } else if (num_groups >= 1) { - icon_temp = get_theme_icon("Groups", "EditorIcons"); + icon_temp = get_theme_icon(SNAME("Groups"), SNAME("EditorIcons")); signal_temp = BUTTON_GROUPS; } @@ -293,7 +292,7 @@ bool SceneTreeEditor::_add_nodes(Node *p_node, TreeItem *p_parent, bool p_scroll } if (p_node == get_scene_node() && p_node->get_scene_inherited_state().is_valid()) { - item->add_button(0, get_theme_icon("InstanceOptions", "EditorIcons"), BUTTON_SUBSCENE, false, TTR("Open in Editor")); + item->add_button(0, get_theme_icon(SNAME("InstanceOptions"), SNAME("EditorIcons")), BUTTON_SUBSCENE, false, TTR("Open in Editor")); String tooltip = TTR("Inherits:") + " " + p_node->get_scene_inherited_state()->get_path() + "\n" + TTR("Type:") + " " + p_node->get_class(); if (p_node->get_editor_description() != String()) { @@ -302,7 +301,7 @@ bool SceneTreeEditor::_add_nodes(Node *p_node, TreeItem *p_parent, bool p_scroll item->set_tooltip(0, tooltip); } else if (p_node != get_scene_node() && p_node->get_filename() != "" && can_open_instance) { - item->add_button(0, get_theme_icon("InstanceOptions", "EditorIcons"), BUTTON_SUBSCENE, false, TTR("Open in Editor")); + item->add_button(0, get_theme_icon(SNAME("InstanceOptions"), SNAME("EditorIcons")), BUTTON_SUBSCENE, false, TTR("Open in Editor")); String tooltip = TTR("Instance:") + " " + p_node->get_filename() + "\n" + TTR("Type:") + " " + p_node->get_class(); if (p_node->get_editor_description() != String()) { @@ -332,7 +331,7 @@ bool SceneTreeEditor::_add_nodes(Node *p_node, TreeItem *p_parent, bool p_scroll Ref<Script> script = p_node->get_script(); if (!script.is_null()) { - item->add_button(0, get_theme_icon("Script", "EditorIcons"), BUTTON_SCRIPT, false, TTR("Open Script:") + " " + script->get_path()); + item->add_button(0, get_theme_icon(SNAME("Script"), SNAME("EditorIcons")), BUTTON_SCRIPT, false, TTR("Open Script:") + " " + script->get_path()); if (EditorNode::get_singleton()->get_object_custom_type_base(p_node) == script) { item->set_button_color(0, item->get_button_count(0) - 1, Color(1, 1, 1, 0.5)); } @@ -341,19 +340,19 @@ bool SceneTreeEditor::_add_nodes(Node *p_node, TreeItem *p_parent, bool p_scroll if (p_node->is_class("CanvasItem")) { bool is_locked = p_node->has_meta("_edit_lock_"); //_edit_group_ if (is_locked) { - item->add_button(0, get_theme_icon("Lock", "EditorIcons"), BUTTON_LOCK, false, TTR("Node is locked.\nClick to unlock it.")); + item->add_button(0, get_theme_icon(SNAME("Lock"), SNAME("EditorIcons")), BUTTON_LOCK, false, TTR("Node is locked.\nClick to unlock it.")); } bool is_grouped = p_node->has_meta("_edit_group_"); if (is_grouped) { - item->add_button(0, get_theme_icon("Group", "EditorIcons"), BUTTON_GROUP, false, TTR("Children are not selectable.\nClick to make selectable.")); + item->add_button(0, get_theme_icon(SNAME("Group"), SNAME("EditorIcons")), BUTTON_GROUP, false, TTR("Children are not selectable.\nClick to make selectable.")); } bool v = p_node->call("is_visible"); if (v) { - item->add_button(0, get_theme_icon("GuiVisibilityVisible", "EditorIcons"), BUTTON_VISIBILITY, false, TTR("Toggle Visibility")); + item->add_button(0, get_theme_icon(SNAME("GuiVisibilityVisible"), SNAME("EditorIcons")), BUTTON_VISIBILITY, false, TTR("Toggle Visibility")); } else { - item->add_button(0, get_theme_icon("GuiVisibilityHidden", "EditorIcons"), BUTTON_VISIBILITY, false, TTR("Toggle Visibility")); + item->add_button(0, get_theme_icon(SNAME("GuiVisibilityHidden"), SNAME("EditorIcons")), BUTTON_VISIBILITY, false, TTR("Toggle Visibility")); } if (!p_node->is_connected("visibility_changed", callable_mp(this, &SceneTreeEditor::_node_visibility_changed))) { @@ -364,19 +363,19 @@ bool SceneTreeEditor::_add_nodes(Node *p_node, TreeItem *p_parent, bool p_scroll } else if (p_node->is_class("Node3D")) { bool is_locked = p_node->has_meta("_edit_lock_"); if (is_locked) { - item->add_button(0, get_theme_icon("Lock", "EditorIcons"), BUTTON_LOCK, false, TTR("Node is locked.\nClick to unlock it.")); + item->add_button(0, get_theme_icon(SNAME("Lock"), SNAME("EditorIcons")), BUTTON_LOCK, false, TTR("Node is locked.\nClick to unlock it.")); } bool is_grouped = p_node->has_meta("_edit_group_"); if (is_grouped) { - item->add_button(0, get_theme_icon("Group", "EditorIcons"), BUTTON_GROUP, false, TTR("Children are not selectable.\nClick to make selectable.")); + item->add_button(0, get_theme_icon(SNAME("Group"), SNAME("EditorIcons")), BUTTON_GROUP, false, TTR("Children are not selectable.\nClick to make selectable.")); } bool v = p_node->call("is_visible"); if (v) { - item->add_button(0, get_theme_icon("GuiVisibilityVisible", "EditorIcons"), BUTTON_VISIBILITY, false, TTR("Toggle Visibility")); + item->add_button(0, get_theme_icon(SNAME("GuiVisibilityVisible"), SNAME("EditorIcons")), BUTTON_VISIBILITY, false, TTR("Toggle Visibility")); } else { - item->add_button(0, get_theme_icon("GuiVisibilityHidden", "EditorIcons"), BUTTON_VISIBILITY, false, TTR("Toggle Visibility")); + item->add_button(0, get_theme_icon(SNAME("GuiVisibilityHidden"), SNAME("EditorIcons")), BUTTON_VISIBILITY, false, TTR("Toggle Visibility")); } if (!p_node->is_connected("visibility_changed", callable_mp(this, &SceneTreeEditor::_node_visibility_changed))) { @@ -388,7 +387,7 @@ bool SceneTreeEditor::_add_nodes(Node *p_node, TreeItem *p_parent, bool p_scroll bool is_pinned = AnimationPlayerEditor::singleton->get_player() == p_node && AnimationPlayerEditor::singleton->is_pinned(); if (is_pinned) { - item->add_button(0, get_theme_icon("Pin", "EditorIcons"), BUTTON_PIN, false, TTR("AnimationPlayer is pinned.\nClick to unpin.")); + item->add_button(0, get_theme_icon(SNAME("Pin"), SNAME("EditorIcons")), BUTTON_PIN, false, TTR("AnimationPlayer is pinned.\nClick to unpin.")); } } } @@ -429,7 +428,7 @@ bool SceneTreeEditor::_add_nodes(Node *p_node, TreeItem *p_parent, bool p_scroll if (!valid) { //item->set_selectable(0,marked_selectable); - item->set_custom_color(0, get_theme_color("disabled_font_color", "Editor")); + item->set_custom_color(0, get_theme_color(SNAME("disabled_font_color"), SNAME("Editor"))); item->set_selectable(0, false); } } @@ -475,9 +474,9 @@ void SceneTreeEditor::_node_visibility_changed(Node *p_node) { } if (visible) { - item->set_button(0, idx, get_theme_icon("GuiVisibilityVisible", "EditorIcons")); + item->set_button(0, idx, get_theme_icon(SNAME("GuiVisibilityVisible"), SNAME("EditorIcons"))); } else { - item->set_button(0, idx, get_theme_icon("GuiVisibilityHidden", "EditorIcons")); + item->set_button(0, idx, get_theme_icon(SNAME("GuiVisibilityHidden"), SNAME("EditorIcons"))); } _update_visibility_color(p_node, item); @@ -526,7 +525,11 @@ void SceneTreeEditor::_node_removed(Node *p_node) { } void SceneTreeEditor::_node_renamed(Node *p_node) { - emit_signal("node_renamed"); + if (!get_scene_node()->is_ancestor_of(p_node)) { + return; + } + + emit_signal(SNAME("node_renamed")); if (!tree_dirty) { MessageQueue::get_singleton()->push_call(this, "_update_tree"); @@ -633,7 +636,7 @@ void SceneTreeEditor::_deselect_items() { // Clear currently selected items in scene tree dock. if (editor_selection) { editor_selection->clear(); - emit_signal("node_changed"); + emit_signal(SNAME("node_changed")); } } @@ -660,12 +663,9 @@ void SceneTreeEditor::_cell_multi_selected(Object *p_object, int p_cell, bool p_ editor_selection->remove_node(n); } - // Selection changed to be single node, so emit "selected" (for single node) rather than "changed" (for multiple nodes) - if (editor_selection->get_selected_nodes().size() == 1) { - selected = editor_selection->get_selected_node_list()[0]; - emit_signal("node_selected"); - } else { - emit_signal("node_changed"); + // Emitted "selected" in _selected_changed() when select single node, so select multiple node emit "changed" + if (editor_selection->get_selected_nodes().size() > 1) { + emit_signal(SNAME("node_changed")); } } @@ -812,10 +812,10 @@ void SceneTreeEditor::_renamed() { if (!undo_redo) { n->set_name(new_name); which->set_metadata(0, n->get_path()); - emit_signal("node_renamed"); + emit_signal(SNAME("node_renamed")); } else { undo_redo->create_action(TTR("Rename Node")); - emit_signal("node_prerename", n, new_name); + emit_signal(SNAME("node_prerename"), n, new_name); undo_redo->add_do_method(this, "_rename_node", n->get_instance_id(), new_name); undo_redo->add_undo_method(this, "_rename_node", n->get_instance_id(), n->get_name()); undo_redo->commit_action(); @@ -992,7 +992,7 @@ Variant SceneTreeEditor::get_drag_data_fw(const Point2 &p_point, Control *p_from drag_data["nodes"] = objs; tree->set_drop_mode_flags(Tree::DROP_MODE_INBETWEEN | Tree::DROP_MODE_ON_ITEM); - emit_signal("nodes_dragged"); + emit_signal(SNAME("nodes_dragged")); return drag_data; } @@ -1033,15 +1033,24 @@ bool SceneTreeEditor::can_drop_data_fw(const Point2 &p_point, const Variant &p_d return true; } + bool scene_drop = true; for (int i = 0; i < files.size(); i++) { String file = files[i]; String ftype = EditorFileSystem::get_singleton()->get_file_type(file); if (ftype != "PackedScene") { - return false; + scene_drop = false; + break; } } - tree->set_drop_mode_flags(Tree::DROP_MODE_INBETWEEN | Tree::DROP_MODE_ON_ITEM); //so it works.. + if (scene_drop) { + tree->set_drop_mode_flags(Tree::DROP_MODE_INBETWEEN | Tree::DROP_MODE_ON_ITEM); + } else { + if (files.size() > 1) { + return false; + } + tree->set_drop_mode_flags(Tree::DROP_MODE_ON_ITEM); + } return true; } @@ -1084,7 +1093,7 @@ void SceneTreeEditor::drop_data_fw(const Point2 &p_point, const Variant &p_data, if (String(d["type"]) == "nodes") { Array nodes = d["nodes"]; - emit_signal("nodes_rearranged", nodes, np, section); + emit_signal(SNAME("nodes_rearranged"), nodes, np, section); } if (String(d["type"]) == "files") { @@ -1092,9 +1101,9 @@ void SceneTreeEditor::drop_data_fw(const Point2 &p_point, const Variant &p_data, String ftype = EditorFileSystem::get_singleton()->get_file_type(files[0]); if (_is_script_type(ftype)) { - emit_signal("script_dropped", files[0], np); + emit_signal(SNAME("script_dropped"), files[0], np); } else { - emit_signal("files_dropped", files, np, section); + emit_signal(SNAME("files_dropped"), files, np, section); } } @@ -1103,14 +1112,14 @@ void SceneTreeEditor::drop_data_fw(const Point2 &p_point, const Variant &p_data, if (se) { String sp = se->get_edited_resource()->get_path(); if (_is_script_type(EditorFileSystem::get_singleton()->get_file_type(sp))) { - emit_signal("script_dropped", sp, np); + emit_signal(SNAME("script_dropped"), sp, np); } } } } void SceneTreeEditor::_rmb_select(const Vector2 &p_pos) { - emit_signal("rmb_pressed", tree->get_screen_transform().xform(p_pos)); + emit_signal(SNAME("rmb_pressed"), tree->get_screen_transform().xform(p_pos)); } void SceneTreeEditor::update_warning() { @@ -1246,7 +1255,7 @@ void SceneTreeDialog::_notification(int p_what) { } break; case NOTIFICATION_ENTER_TREE: { connect("confirmed", callable_mp(this, &SceneTreeDialog::_select)); - filter->set_right_icon(tree->get_theme_icon("Search", "EditorIcons")); + filter->set_right_icon(tree->get_theme_icon(SNAME("Search"), SNAME("EditorIcons"))); filter->set_clear_button_enabled(true); } break; case NOTIFICATION_EXIT_TREE: { @@ -1261,7 +1270,7 @@ void SceneTreeDialog::_cancel() { void SceneTreeDialog::_select() { if (tree->get_selected()) { - emit_signal("selected", tree->get_selected()->get_path()); + emit_signal(SNAME("selected"), tree->get_selected()->get_path()); hide(); } } diff --git a/editor/script_create_dialog.cpp b/editor/script_create_dialog.cpp index b5028096e0..4cbc859e0c 100644 --- a/editor/script_create_dialog.cpp +++ b/editor/script_create_dialog.cpp @@ -46,7 +46,7 @@ void ScriptCreateDialog::_notification(int p_what) { case NOTIFICATION_THEME_CHANGED: { for (int i = 0; i < ScriptServer::get_language_count(); i++) { String lang = ScriptServer::get_language(i)->get_type(); - Ref<Texture2D> lang_icon = get_theme_icon(lang, "EditorIcons"); + Ref<Texture2D> lang_icon = get_theme_icon(lang, SNAME("EditorIcons")); if (lang_icon.is_valid()) { language_menu->set_item_icon(i, lang_icon); } @@ -65,10 +65,10 @@ void ScriptCreateDialog::_notification(int p_what) { language_menu->select(default_language); } - path_button->set_icon(get_theme_icon("Folder", "EditorIcons")); - parent_browse_button->set_icon(get_theme_icon("Folder", "EditorIcons")); - parent_search_button->set_icon(get_theme_icon("ClassList", "EditorIcons")); - status_panel->add_theme_style_override("panel", get_theme_stylebox("bg", "Tree")); + path_button->set_icon(get_theme_icon(SNAME("Folder"), SNAME("EditorIcons"))); + parent_browse_button->set_icon(get_theme_icon(SNAME("Folder"), SNAME("EditorIcons"))); + parent_search_button->set_icon(get_theme_icon(SNAME("ClassList"), SNAME("EditorIcons"))); + status_panel->add_theme_style_override("panel", get_theme_stylebox(SNAME("bg"), SNAME("Tree"))); } break; } } @@ -205,12 +205,12 @@ String ScriptCreateDialog::_validate_path(const String &p_path, bool p_file_must bool found = false; bool match = false; int index = 0; - for (List<String>::Element *E = extensions.front(); E; E = E->next()) { - if (E->get().nocasecmp_to(extension) == 0) { + for (const String &E : extensions) { + if (E.nocasecmp_to(extension) == 0) { //FIXME (?) - changing language this way doesn't update controls, needs rework //language_menu->select(index); // change Language option by extension found = true; - if (E->get() == ScriptServer::get_language(language_menu->get_selected())->get_extension()) { + if (E == ScriptServer::get_language(language_menu->get_selected())->get_extension()) { match = true; } break; @@ -326,7 +326,7 @@ void ScriptCreateDialog::_create_new() { } } - emit_signal("script_created", scr); + emit_signal(SNAME("script_created"), scr); hide(); } @@ -339,7 +339,7 @@ void ScriptCreateDialog::_load_exist() { return; } - emit_signal("script_created", p_script); + emit_signal(SNAME("script_created"), p_script); hide(); } @@ -373,8 +373,8 @@ void ScriptCreateDialog::_lang_changed(int l) { ScriptServer::get_language(m)->get_recognized_extensions(&extensions); } - for (List<String>::Element *E = extensions.front(); E; E = E->next()) { - if (E->get().nocasecmp_to(extension) == 0) { + for (const String &E : extensions) { + if (E.nocasecmp_to(extension) == 0) { path = path.get_basename() + selected_ext; _path_changed(path); break; @@ -448,7 +448,7 @@ void ScriptCreateDialog::_lang_changed(int l) { override_info += ", "; } } - template_menu->set_item_icon(extended.id, get_theme_icon("Override", "EditorIcons")); + template_menu->set_item_icon(extended.id, get_theme_icon(SNAME("Override"), SNAME("EditorIcons"))); template_menu->get_popup()->set_item_tooltip(extended.id, override_info.as_string()); } // Reselect last selected template @@ -534,8 +534,8 @@ void ScriptCreateDialog::_browse_path(bool browse_parent, bool p_save) { int lang = language_menu->get_selected(); ScriptServer::get_language(lang)->get_recognized_extensions(&extensions); - for (List<String>::Element *E = extensions.front(); E; E = E->next()) { - file_browse->add_filter("*." + E->get()); + for (const String &E : extensions) { + file_browse->add_filter("*." + E); } file_browse->set_current_path(file_path->get_text()); @@ -604,20 +604,20 @@ void ScriptCreateDialog::_path_submitted(const String &p_path) { } void ScriptCreateDialog::_msg_script_valid(bool valid, const String &p_msg) { - error_label->set_text("- " + p_msg); + error_label->set_text(String::utf8("• ") + p_msg); if (valid) { - error_label->add_theme_color_override("font_color", get_theme_color("success_color", "Editor")); + error_label->add_theme_color_override("font_color", get_theme_color(SNAME("success_color"), SNAME("Editor"))); } else { - error_label->add_theme_color_override("font_color", get_theme_color("error_color", "Editor")); + error_label->add_theme_color_override("font_color", get_theme_color(SNAME("error_color"), SNAME("Editor"))); } } void ScriptCreateDialog::_msg_path_valid(bool valid, const String &p_msg) { - path_error_label->set_text("- " + p_msg); + path_error_label->set_text(String::utf8("• ") + p_msg); if (valid) { - path_error_label->add_theme_color_override("font_color", get_theme_color("success_color", "Editor")); + path_error_label->add_theme_color_override("font_color", get_theme_color(SNAME("success_color"), SNAME("Editor"))); } else { - path_error_label->add_theme_color_override("font_color", get_theme_color("error_color", "Editor")); + path_error_label->add_theme_color_override("font_color", get_theme_color(SNAME("error_color"), SNAME("Editor"))); } } diff --git a/editor/settings_config_dialog.cpp b/editor/settings_config_dialog.cpp index c2c99ed17f..b3ec0c96c4 100644 --- a/editor/settings_config_dialog.cpp +++ b/editor/settings_config_dialog.cpp @@ -176,15 +176,15 @@ void EditorSettingsDialog::_unhandled_input(const Ref<InputEvent> &p_event) { } void EditorSettingsDialog::_update_icons() { - search_box->set_right_icon(shortcuts->get_theme_icon("Search", "EditorIcons")); + search_box->set_right_icon(shortcuts->get_theme_icon(SNAME("Search"), SNAME("EditorIcons"))); search_box->set_clear_button_enabled(true); - shortcut_search_box->set_right_icon(shortcuts->get_theme_icon("Search", "EditorIcons")); + shortcut_search_box->set_right_icon(shortcuts->get_theme_icon(SNAME("Search"), SNAME("EditorIcons"))); shortcut_search_box->set_clear_button_enabled(true); - restart_close_button->set_icon(shortcuts->get_theme_icon("Close", "EditorIcons")); - restart_container->add_theme_style_override("panel", shortcuts->get_theme_stylebox("bg", "Tree")); - restart_icon->set_texture(shortcuts->get_theme_icon("StatusWarning", "EditorIcons")); - restart_label->add_theme_color_override("font_color", shortcuts->get_theme_color("warning_color", "Editor")); + restart_close_button->set_icon(shortcuts->get_theme_icon(SNAME("Close"), SNAME("EditorIcons"))); + restart_container->add_theme_style_override("panel", shortcuts->get_theme_stylebox(SNAME("bg"), SNAME("Tree"))); + restart_icon->set_texture(shortcuts->get_theme_icon(SNAME("StatusWarning"), SNAME("EditorIcons"))); + restart_label->add_theme_color_override("font_color", shortcuts->get_theme_color(SNAME("warning_color"), SNAME("Editor"))); } void EditorSettingsDialog::_event_config_confirmed() { @@ -253,8 +253,8 @@ void EditorSettingsDialog::_update_shortcuts() { if (collapsed.has("Common")) { common_section->set_collapsed(collapsed["Common"]); } - common_section->set_custom_bg_color(0, shortcuts->get_theme_color("prop_subsection", "Editor")); - common_section->set_custom_bg_color(1, shortcuts->get_theme_color("prop_subsection", "Editor")); + common_section->set_custom_bg_color(0, shortcuts->get_theme_color(SNAME("prop_subsection"), SNAME("Editor"))); + common_section->set_custom_bg_color(1, shortcuts->get_theme_color(SNAME("prop_subsection"), SNAME("Editor"))); // Get the action map for the editor, and add each item to the "Common" section. OrderedHashMap<StringName, InputMap::Action> action_map = InputMap::get_singleton()->get_action_map(); @@ -303,16 +303,16 @@ void EditorSettingsDialog::_update_shortcuts() { item->set_text(1, events_display_string); if (!same_as_defaults) { - item->add_button(1, shortcuts->get_theme_icon("Reload", "EditorIcons"), 2); + item->add_button(1, shortcuts->get_theme_icon(SNAME("Reload"), SNAME("EditorIcons")), 2); } if (events_display_string == "None") { // Fade out unassigned shortcut labels for easier visual grepping. - item->set_custom_color(1, shortcuts->get_theme_color("font_color", "Label") * Color(1, 1, 1, 0.5)); + item->set_custom_color(1, shortcuts->get_theme_color(SNAME("font_color"), SNAME("Label")) * Color(1, 1, 1, 0.5)); } - item->add_button(1, shortcuts->get_theme_icon("Edit", "EditorIcons"), 0); - item->add_button(1, shortcuts->get_theme_icon("Close", "EditorIcons"), 1); + item->add_button(1, shortcuts->get_theme_icon(SNAME("Edit"), SNAME("EditorIcons")), 0); + item->add_button(1, shortcuts->get_theme_icon(SNAME("Close"), SNAME("EditorIcons")), 1); item->set_tooltip(0, action_name); item->set_tooltip(1, events_display_string); item->set_metadata(0, "Common"); @@ -324,15 +324,15 @@ void EditorSettingsDialog::_update_shortcuts() { List<String> slist; EditorSettings::get_singleton()->get_shortcut_list(&slist); - for (List<String>::Element *E = slist.front(); E; E = E->next()) { - Ref<Shortcut> sc = EditorSettings::get_singleton()->get_shortcut(E->get()); + for (const String &E : slist) { + Ref<Shortcut> sc = EditorSettings::get_singleton()->get_shortcut(E); if (!sc->has_meta("original")) { continue; } Ref<InputEvent> original = sc->get_meta("original"); - String section_name = E->get().get_slice("/", 0); + String section_name = E.get_slice("/", 0); TreeItem *section; @@ -349,8 +349,8 @@ void EditorSettingsDialog::_update_shortcuts() { } sections[section_name] = section; - section->set_custom_bg_color(0, shortcuts->get_theme_color("prop_subsection", "Editor")); - section->set_custom_bg_color(1, shortcuts->get_theme_color("prop_subsection", "Editor")); + section->set_custom_bg_color(0, shortcuts->get_theme_color(SNAME("prop_subsection"), SNAME("Editor"))); + section->set_custom_bg_color(1, shortcuts->get_theme_color(SNAME("prop_subsection"), SNAME("Editor"))); } // Don't match unassigned shortcuts when searching for assigned keys in search results. @@ -362,18 +362,18 @@ void EditorSettingsDialog::_update_shortcuts() { item->set_text(1, sc->get_as_text()); if (!sc->is_shortcut(original) && !(sc->get_shortcut().is_null() && original.is_null())) { - item->add_button(1, shortcuts->get_theme_icon("Reload", "EditorIcons"), 2); + item->add_button(1, shortcuts->get_theme_icon(SNAME("Reload"), SNAME("EditorIcons")), 2); } if (sc->get_as_text() == "None") { // Fade out unassigned shortcut labels for easier visual grepping. - item->set_custom_color(1, shortcuts->get_theme_color("font_color", "Label") * Color(1, 1, 1, 0.5)); + item->set_custom_color(1, shortcuts->get_theme_color(SNAME("font_color"), SNAME("Label")) * Color(1, 1, 1, 0.5)); } - item->add_button(1, shortcuts->get_theme_icon("Edit", "EditorIcons"), 0); - item->add_button(1, shortcuts->get_theme_icon("Close", "EditorIcons"), 1); - item->set_tooltip(0, E->get()); - item->set_metadata(0, E->get()); + item->add_button(1, shortcuts->get_theme_icon(SNAME("Edit"), SNAME("EditorIcons")), 0); + item->add_button(1, shortcuts->get_theme_icon(SNAME("Close"), SNAME("EditorIcons")), 1); + item->set_tooltip(0, E); + item->set_metadata(0, E); } } @@ -403,10 +403,9 @@ void EditorSettingsDialog::_shortcut_button_pressed(Object *p_item, int p_column List<Ref<InputEvent>> defaults = InputMap::get_singleton()->get_builtins()[current_action]; // Convert the list to an array, and only keep key events as this is for the editor. - for (List<Ref<InputEvent>>::Element *E = defaults.front(); E; E = E->next()) { - Ref<InputEventKey> k = E->get(); + for (const Ref<InputEvent> &k : defaults) { if (k.is_valid()) { - events.append(E->get()); + events.append(k); } } @@ -426,7 +425,7 @@ void EditorSettingsDialog::_shortcut_button_pressed(Object *p_item, int p_column if (button_idx == SHORTCUT_EDIT) { // If editing, add a button which can be used to add an additional event. - action_popup->add_icon_item(get_theme_icon("Add", "EditorIcons"), TTR("Add")); + action_popup->add_icon_item(get_theme_icon(SNAME("Add"), SNAME("EditorIcons")), TTR("Add")); } action_popup->set_position(get_position() + get_mouse_position()); diff --git a/editor/shader_globals_editor.cpp b/editor/shader_globals_editor.cpp index 1893c6b6bb..d504d3b137 100644 --- a/editor/shader_globals_editor.cpp +++ b/editor/shader_globals_editor.cpp @@ -66,7 +66,7 @@ class ShaderGlobalsEditorInterface : public Object { GDCLASS(ShaderGlobalsEditorInterface, Object) void _var_changed() { - emit_signal("var_changed"); + emit_signal(SNAME("var_changed")); } protected: @@ -84,7 +84,7 @@ protected: UndoRedo *undo_redo = EditorNode::get_singleton()->get_undo_redo(); - undo_redo->create_action("Set Shader Global Variable"); + undo_redo->create_action(TTR("Set Shader Global Variable")); undo_redo->add_do_method(RS::get_singleton(), "global_variable_set", p_name, p_value); undo_redo->add_undo_method(RS::get_singleton(), "global_variable_set", p_name, existing); RS::GlobalVariableType type = RS::get_singleton()->global_variable_get_type(p_name); @@ -110,7 +110,6 @@ protected: undo_redo->commit_action(); block_update = false; - print_line("all good?"); return true; } @@ -395,7 +394,7 @@ void ShaderGlobalsEditor::_variable_added() { Variant value = create_var(RS::GlobalVariableType(variable_type->get_selected())); - undo_redo->create_action("Add Shader Global Variable"); + undo_redo->create_action(TTR("Add Shader Global Variable")); undo_redo->add_do_method(RS::get_singleton(), "global_variable_add", var, RS::GlobalVariableType(variable_type->get_selected()), value); undo_redo->add_undo_method(RS::get_singleton(), "global_variable_remove", var); Dictionary gv; @@ -410,10 +409,9 @@ void ShaderGlobalsEditor::_variable_added() { } void ShaderGlobalsEditor::_variable_deleted(const String &p_variable) { - print_line("deleted " + p_variable); UndoRedo *undo_redo = EditorNode::get_singleton()->get_undo_redo(); - undo_redo->create_action("Add Shader Global Variable"); + undo_redo->create_action(TTR("Add Shader Global Variable")); undo_redo->add_do_method(RS::get_singleton(), "global_variable_remove", p_variable); undo_redo->add_undo_method(RS::get_singleton(), "global_variable_add", p_variable, RS::get_singleton()->global_variable_get_type(p_variable), RS::get_singleton()->global_variable_get(p_variable)); @@ -425,7 +423,7 @@ void ShaderGlobalsEditor::_variable_deleted(const String &p_variable) { } void ShaderGlobalsEditor::_changed() { - emit_signal("globals_changed"); + emit_signal(SNAME("globals_changed")); if (!interface->block_update) { interface->notify_property_list_changed(); } @@ -439,7 +437,6 @@ void ShaderGlobalsEditor::_bind_methods() { void ShaderGlobalsEditor::_notification(int p_what) { if (p_what == NOTIFICATION_VISIBILITY_CHANGED) { if (is_visible_in_tree()) { - print_line("OK load settings in globalseditor"); inspector->edit(interface); } } diff --git a/editor/translations/af.po b/editor/translations/af.po index bb7e7ca553..6a74789da2 100644 --- a/editor/translations/af.po +++ b/editor/translations/af.po @@ -5251,8 +5251,8 @@ msgstr "" #: editor/plugins/baked_lightmap_editor_plugin.cpp msgid "" -"No meshes to bake. Make sure they contain an UV2 channel and that the 'Bake " -"Light' flag is on." +"No meshes to bake. Make sure they contain an UV2 channel and that the 'Use " +"In Baked Light' and 'Generate Lightmap' flags are on." msgstr "" #: editor/plugins/baked_lightmap_editor_plugin.cpp diff --git a/editor/translations/ar.po b/editor/translations/ar.po index 6d8db6f47b..b851db361f 100644 --- a/editor/translations/ar.po +++ b/editor/translations/ar.po @@ -52,12 +52,13 @@ # ILG - Game <moegypt277@gmail.com>, 2021. # Hatim Jamal <hatimjamal8@gmail.com>, 2021. # HASSAN GAMER - حسن جيمر <gamerhassan55@gmail.com>, 2021. +# abubakrAlsaab <madeinsudan19@gmail.com>, 2021. msgid "" msgstr "" "Project-Id-Version: Godot Engine editor\n" "POT-Creation-Date: \n" -"PO-Revision-Date: 2021-07-09 14:32+0000\n" -"Last-Translator: HASSAN GAMER - حسن جيمر <gamerhassan55@gmail.com>\n" +"PO-Revision-Date: 2021-07-16 05:47+0000\n" +"Last-Translator: abubakrAlsaab <madeinsudan19@gmail.com>\n" "Language-Team: Arabic <https://hosted.weblate.org/projects/godot-engine/" "godot/ar/>\n" "Language: ar\n" @@ -66,7 +67,7 @@ msgstr "" "Content-Transfer-Encoding: 8bit\n" "Plural-Forms: nplurals=6; plural=n==0 ? 0 : n==1 ? 1 : n==2 ? 2 : n%100>=3 " "&& n%100<=10 ? 3 : n%100>=11 ? 4 : 5;\n" -"X-Generator: Weblate 4.8-dev\n" +"X-Generator: Weblate 4.7.2-dev\n" #: core/math/expression.cpp modules/gdscript/gdscript_functions.cpp #: modules/visual_script/visual_script_builtin_funcs.cpp @@ -3021,7 +3022,7 @@ msgstr "حول" #: editor/editor_node.cpp msgid "Support Godot Development" -msgstr "" +msgstr "إدعم تطوير محرك غو-دوت" #: editor/editor_node.cpp msgid "Play the project." @@ -5215,9 +5216,10 @@ msgstr "" "الضوء المعدة مسبقا." #: editor/plugins/baked_lightmap_editor_plugin.cpp +#, fuzzy msgid "" -"No meshes to bake. Make sure they contain an UV2 channel and that the 'Bake " -"Light' flag is on." +"No meshes to bake. Make sure they contain an UV2 channel and that the 'Use " +"In Baked Light' and 'Generate Lightmap' flags are on." msgstr "" "لايوجد ميش لكي يتم تجهيزة. تاكد من انه يحتوي على منفذ UV2 و ان زر الضوء " "'المعد' مفعل." @@ -5342,7 +5344,7 @@ msgstr "تعديل حجم العقدة \"Node2D \"%s إلى (s, %s%)" #: editor/plugins/canvas_item_editor_plugin.cpp msgid "Resize Control \"%s\" to (%d, %d)" -msgstr "" +msgstr "تغيير حجم عنصر التحكم \"٪ s\" إلى (٪ d،٪ d)" #: editor/plugins/canvas_item_editor_plugin.cpp #, fuzzy @@ -7566,6 +7568,7 @@ msgstr "تدوير الرؤية مقفول" msgid "" "To zoom further, change the camera's clipping planes (View -> Settings...)" msgstr "" +"للتكبير بشكل أكبر ، قم بتغيير مستويات اقتصاص الكاميرا (عرض -> الإعدادات ...)" #: editor/plugins/spatial_editor_plugin.cpp msgid "" @@ -9536,7 +9539,7 @@ msgstr "" #: editor/plugins/visual_shader_editor_plugin.cpp msgid "A reference to an existing uniform." -msgstr "" +msgstr "إشارة إلى زي موحد موجود." #: editor/plugins/visual_shader_editor_plugin.cpp msgid "(Fragment/Light mode only) Scalar derivative function." @@ -9903,7 +9906,7 @@ msgstr "OpenGL ES 3.0" #: editor/project_manager.cpp msgid "Not supported by your GPU drivers." -msgstr "" +msgstr "غير مدعوم من قبل برامج تشغيل GPU(اجهزة اارسوم) الخاصة بك." #: editor/project_manager.cpp msgid "" @@ -10959,6 +10962,9 @@ msgid "" "every time it updates.\n" "Switch back to the Local scene tree dock to improve performance." msgstr "" +"إذا تم تحديده ، فسيؤدي شجرة المشهد إلى توقف المشروع في كل مرة يتم فيها " +"تحديثه.\n" +"قم بالتبديل مرة أخرى إلى رصيف شجرة المشهد المحلي لتحسين الأداء." #: editor/scene_tree_dock.cpp msgid "Local" @@ -11657,11 +11663,11 @@ msgstr "" #: modules/lightmapper_cpu/lightmapper_cpu.cpp msgid "Begin Bake" -msgstr "" +msgstr "ابدأ الخبز (دمج تاثير الضوء في الصورة )" #: modules/lightmapper_cpu/lightmapper_cpu.cpp msgid "Preparing data structures" -msgstr "" +msgstr "تحضير هياكل البيانات" #: modules/lightmapper_cpu/lightmapper_cpu.cpp #, fuzzy @@ -12192,7 +12198,7 @@ msgstr "اختر جهازاً من القائمة" #: platform/android/export/export.cpp msgid "Unable to find the 'apksigner' tool." -msgstr "" +msgstr "تعذر العثور على أداة توقيع تطبيق اندرويد\"apksigner\"." #: platform/android/export/export.cpp msgid "" diff --git a/editor/translations/az.po b/editor/translations/az.po index 054bc9263d..be05c12c5c 100644 --- a/editor/translations/az.po +++ b/editor/translations/az.po @@ -5056,8 +5056,8 @@ msgstr "" #: editor/plugins/baked_lightmap_editor_plugin.cpp msgid "" -"No meshes to bake. Make sure they contain an UV2 channel and that the 'Bake " -"Light' flag is on." +"No meshes to bake. Make sure they contain an UV2 channel and that the 'Use " +"In Baked Light' and 'Generate Lightmap' flags are on." msgstr "" #: editor/plugins/baked_lightmap_editor_plugin.cpp diff --git a/editor/translations/bg.po b/editor/translations/bg.po index 7bf3d40805..9759e3d1e5 100644 --- a/editor/translations/bg.po +++ b/editor/translations/bg.po @@ -5042,9 +5042,10 @@ msgstr "" "Запазете сцената и опитайте отново." #: editor/plugins/baked_lightmap_editor_plugin.cpp +#, fuzzy msgid "" -"No meshes to bake. Make sure they contain an UV2 channel and that the 'Bake " -"Light' flag is on." +"No meshes to bake. Make sure they contain an UV2 channel and that the 'Use " +"In Baked Light' and 'Generate Lightmap' flags are on." msgstr "" "Няма полигонни мрежи за изпичане. Уверете се, че те съдържат канал UV2 и че " "флагът „Изпичане на светлината“ е включен." diff --git a/editor/translations/bn.po b/editor/translations/bn.po index 70a66820fb..f4a10f7dea 100644 --- a/editor/translations/bn.po +++ b/editor/translations/bn.po @@ -5526,8 +5526,8 @@ msgstr "" #: editor/plugins/baked_lightmap_editor_plugin.cpp msgid "" -"No meshes to bake. Make sure they contain an UV2 channel and that the 'Bake " -"Light' flag is on." +"No meshes to bake. Make sure they contain an UV2 channel and that the 'Use " +"In Baked Light' and 'Generate Lightmap' flags are on." msgstr "" #: editor/plugins/baked_lightmap_editor_plugin.cpp diff --git a/editor/translations/br.po b/editor/translations/br.po index 9d1e52e009..0fe39331f9 100644 --- a/editor/translations/br.po +++ b/editor/translations/br.po @@ -5000,8 +5000,8 @@ msgstr "" #: editor/plugins/baked_lightmap_editor_plugin.cpp msgid "" -"No meshes to bake. Make sure they contain an UV2 channel and that the 'Bake " -"Light' flag is on." +"No meshes to bake. Make sure they contain an UV2 channel and that the 'Use " +"In Baked Light' and 'Generate Lightmap' flags are on." msgstr "" #: editor/plugins/baked_lightmap_editor_plugin.cpp diff --git a/editor/translations/ca.po b/editor/translations/ca.po index 1032b7cdeb..40429cc0e0 100644 --- a/editor/translations/ca.po +++ b/editor/translations/ca.po @@ -5277,9 +5277,10 @@ msgstr "" "camí des de les propietats de BakedLightmap." #: editor/plugins/baked_lightmap_editor_plugin.cpp +#, fuzzy msgid "" -"No meshes to bake. Make sure they contain an UV2 channel and that the 'Bake " -"Light' flag is on." +"No meshes to bake. Make sure they contain an UV2 channel and that the 'Use " +"In Baked Light' and 'Generate Lightmap' flags are on." msgstr "" "Cap Malla per precalcular. Comproveu que disposin d'un canal d'UV2 i que " "l'indicador 'Bake Light' és activat." diff --git a/editor/translations/cs.po b/editor/translations/cs.po index 3aaf91d758..281bc500f2 100644 --- a/editor/translations/cs.po +++ b/editor/translations/cs.po @@ -30,8 +30,8 @@ msgid "" msgstr "" "Project-Id-Version: Godot Engine editor\n" "POT-Creation-Date: \n" -"PO-Revision-Date: 2021-06-25 02:57+0000\n" -"Last-Translator: Vojtěch Šamla <auzkok@seznam.cz>\n" +"PO-Revision-Date: 2021-07-26 14:18+0000\n" +"Last-Translator: Zbyněk <zbynek.fiala@gmail.com>\n" "Language-Team: Czech <https://hosted.weblate.org/projects/godot-engine/godot/" "cs/>\n" "Language: cs\n" @@ -39,7 +39,7 @@ msgstr "" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" "Plural-Forms: nplurals=3; plural=(n==1) ? 0 : (n>=2 && n<=4) ? 1 : 2;\n" -"X-Generator: Weblate 4.7.1-dev\n" +"X-Generator: Weblate 4.7.2-dev\n" #: core/math/expression.cpp modules/gdscript/gdscript_functions.cpp #: modules/visual_script/visual_script_builtin_funcs.cpp @@ -5139,7 +5139,7 @@ msgstr "Poslední" #: editor/plugins/asset_library_editor_plugin.cpp msgid "All" -msgstr "Všechny" +msgstr "všichni" #: editor/plugins/asset_library_editor_plugin.cpp msgid "No results for \"%s\"." @@ -5194,9 +5194,10 @@ msgstr "" "Uložte scénu a zkuste to znovu." #: editor/plugins/baked_lightmap_editor_plugin.cpp +#, fuzzy msgid "" -"No meshes to bake. Make sure they contain an UV2 channel and that the 'Bake " -"Light' flag is on." +"No meshes to bake. Make sure they contain an UV2 channel and that the 'Use " +"In Baked Light' and 'Generate Lightmap' flags are on." msgstr "" "Žádné sítě k zapečení. Ujistěte se, že obsahují kanál UV2 a že je nastaven " "příznak \"Zapéct světlo\"." @@ -10546,7 +10547,7 @@ msgstr "Hodnota, o kterou se počítadlo zvýší za každý uzel" #: editor/rename_dialog.cpp msgid "Padding" -msgstr "Odsazení" +msgstr "Zarovnávání" #: editor/rename_dialog.cpp msgid "" diff --git a/editor/translations/da.po b/editor/translations/da.po index 9e09250fbc..c86ec25b4b 100644 --- a/editor/translations/da.po +++ b/editor/translations/da.po @@ -5390,8 +5390,8 @@ msgstr "" #: editor/plugins/baked_lightmap_editor_plugin.cpp msgid "" -"No meshes to bake. Make sure they contain an UV2 channel and that the 'Bake " -"Light' flag is on." +"No meshes to bake. Make sure they contain an UV2 channel and that the 'Use " +"In Baked Light' and 'Generate Lightmap' flags are on." msgstr "" #: editor/plugins/baked_lightmap_editor_plugin.cpp diff --git a/editor/translations/de.po b/editor/translations/de.po index bbf72f815b..954f8426f8 100644 --- a/editor/translations/de.po +++ b/editor/translations/de.po @@ -5289,9 +5289,10 @@ msgstr "" "Ein Speichern der Szene sollte dieses Problem beheben." #: editor/plugins/baked_lightmap_editor_plugin.cpp +#, fuzzy msgid "" -"No meshes to bake. Make sure they contain an UV2 channel and that the 'Bake " -"Light' flag is on." +"No meshes to bake. Make sure they contain an UV2 channel and that the 'Use " +"In Baked Light' and 'Generate Lightmap' flags are on." msgstr "" "Keine Meshes zum vorrendern vorhanden. Meshes, die vorgerendert werden " "sollen, müssen einen UV2-Kanal beinhalten und die ‚Bake Light‘-Option " diff --git a/editor/translations/editor.pot b/editor/translations/editor.pot index a0f4654639..ae7b6b37dc 100644 --- a/editor/translations/editor.pot +++ b/editor/translations/editor.pot @@ -4980,8 +4980,8 @@ msgstr "" #: editor/plugins/baked_lightmap_editor_plugin.cpp msgid "" -"No meshes to bake. Make sure they contain an UV2 channel and that the 'Bake " -"Light' flag is on." +"No meshes to bake. Make sure they contain an UV2 channel and that the 'Use " +"In Baked Light' and 'Generate Lightmap' flags are on." msgstr "" #: editor/plugins/baked_lightmap_editor_plugin.cpp @@ -6979,7 +6979,7 @@ msgstr "" #: editor/plugins/shader_editor_plugin.cpp msgid "" -"This shader has been modified on on disk.\n" +"This shader has been modified on disk.\n" "What action should be taken?" msgstr "" diff --git a/editor/translations/el.po b/editor/translations/el.po index 035a82f99f..40d8ab46cc 100644 --- a/editor/translations/el.po +++ b/editor/translations/el.po @@ -5239,9 +5239,10 @@ msgstr "" "Αποθηκεύστε τη σκηνή σας και δοκιμάστε ξανα." #: editor/plugins/baked_lightmap_editor_plugin.cpp +#, fuzzy msgid "" -"No meshes to bake. Make sure they contain an UV2 channel and that the 'Bake " -"Light' flag is on." +"No meshes to bake. Make sure they contain an UV2 channel and that the 'Use " +"In Baked Light' and 'Generate Lightmap' flags are on." msgstr "" "Δεν υπάρχουν πλέγματα για προετοιμασία. Σιγουρευτείτε ότι εμπεριέχουν κανάλι " "UV2 και πως η σημαία 'Bake Light' είναι ενεργοποιημένη." diff --git a/editor/translations/eo.po b/editor/translations/eo.po index 0523742303..38c72380da 100644 --- a/editor/translations/eo.po +++ b/editor/translations/eo.po @@ -5204,8 +5204,8 @@ msgstr "" #: editor/plugins/baked_lightmap_editor_plugin.cpp msgid "" -"No meshes to bake. Make sure they contain an UV2 channel and that the 'Bake " -"Light' flag is on." +"No meshes to bake. Make sure they contain an UV2 channel and that the 'Use " +"In Baked Light' and 'Generate Lightmap' flags are on." msgstr "" #: editor/plugins/baked_lightmap_editor_plugin.cpp diff --git a/editor/translations/es.po b/editor/translations/es.po index 5953536c60..e09d1df8c7 100644 --- a/editor/translations/es.po +++ b/editor/translations/es.po @@ -72,7 +72,7 @@ msgid "" msgstr "" "Project-Id-Version: Godot Engine editor\n" "POT-Creation-Date: \n" -"PO-Revision-Date: 2021-07-05 21:41+0000\n" +"PO-Revision-Date: 2021-07-16 05:47+0000\n" "Last-Translator: Erick Figueroa <querecuto@hotmail.com>\n" "Language-Team: Spanish <https://hosted.weblate.org/projects/godot-engine/" "godot/es/>\n" @@ -81,7 +81,7 @@ msgstr "" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" "Plural-Forms: nplurals=2; plural=n != 1;\n" -"X-Generator: Weblate 4.8-dev\n" +"X-Generator: Weblate 4.7.2-dev\n" #: core/math/expression.cpp modules/gdscript/gdscript_functions.cpp #: modules/visual_script/visual_script_builtin_funcs.cpp @@ -1205,7 +1205,7 @@ msgstr "Desarrollador Principal" #. you do not have to keep it in your translation. #: editor/editor_about.cpp msgid "Project Manager " -msgstr "Gestor del Proyecto " +msgstr "Administrador de Proyectos " #: editor/editor_about.cpp msgid "Developers" @@ -3078,7 +3078,7 @@ msgstr "Apoyar el desarrollo de Godot" #: editor/editor_node.cpp msgid "Play the project." -msgstr "Reproducir el proyecto." +msgstr "Ejecutar el proyecto." #: editor/editor_node.cpp msgid "Play" @@ -5293,9 +5293,10 @@ msgstr "" "Guarda tu escena e inténtalo de nuevo." #: editor/plugins/baked_lightmap_editor_plugin.cpp +#, fuzzy msgid "" -"No meshes to bake. Make sure they contain an UV2 channel and that the 'Bake " -"Light' flag is on." +"No meshes to bake. Make sure they contain an UV2 channel and that the 'Use " +"In Baked Light' and 'Generate Lightmap' flags are on." msgstr "" "No hay mallas para hacer bake. Asegúrate que contengan un canal UV2 y que la " "opción de 'Bake Light' está activada." @@ -10154,8 +10155,8 @@ msgid "" "The interface will update after restarting the editor or project manager." msgstr "" "Idioma cambiado.\n" -"La interfaz se actualizará después de reiniciar el editor o el gestor de " -"proyectos." +"La interfaz se actualizará después de reiniciar el editor o el administrador " +"de proyectos." #: editor/project_manager.cpp msgid "" @@ -11737,7 +11738,7 @@ msgstr "Eliminar Rotación del Cursor" #: modules/gridmap/grid_map_editor_plugin.cpp msgid "Paste Selects" -msgstr "Pegar Selecciona" +msgstr "Pegar Seleccionados" #: modules/gridmap/grid_map_editor_plugin.cpp msgid "Clear Selection" diff --git a/editor/translations/es_AR.po b/editor/translations/es_AR.po index d1fe06a565..33c29d9c6e 100644 --- a/editor/translations/es_AR.po +++ b/editor/translations/es_AR.po @@ -5237,9 +5237,10 @@ msgstr "" "Guardá tu escena e inténtalo de nuevo." #: editor/plugins/baked_lightmap_editor_plugin.cpp +#, fuzzy msgid "" -"No meshes to bake. Make sure they contain an UV2 channel and that the 'Bake " -"Light' flag is on." +"No meshes to bake. Make sure they contain an UV2 channel and that the 'Use " +"In Baked Light' and 'Generate Lightmap' flags are on." msgstr "" "No hay meshes para hacer bake. Asegúrate que contienen un canal UV2 y que el " "flag 'Bake Light' esta activado." diff --git a/editor/translations/et.po b/editor/translations/et.po index 05a414f5a9..fd534943b1 100644 --- a/editor/translations/et.po +++ b/editor/translations/et.po @@ -10,7 +10,7 @@ msgid "" msgstr "" "Project-Id-Version: Godot Engine editor\n" -"PO-Revision-Date: 2021-05-10 15:32+0000\n" +"PO-Revision-Date: 2021-07-16 05:47+0000\n" "Last-Translator: Kritzmensch <streef.gtx@gmail.com>\n" "Language-Team: Estonian <https://hosted.weblate.org/projects/godot-engine/" "godot/et/>\n" @@ -18,7 +18,7 @@ msgstr "" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8-bit\n" "Plural-Forms: nplurals=2; plural=n != 1;\n" -"X-Generator: Weblate 4.7-dev\n" +"X-Generator: Weblate 4.7.2-dev\n" #: core/math/expression.cpp modules/gdscript/gdscript_functions.cpp #: modules/visual_script/visual_script_builtin_funcs.cpp @@ -1090,7 +1090,7 @@ msgstr "Suur tänu Godot kogukonnalt!" #: editor/editor_about.cpp editor/editor_node.cpp editor/project_manager.cpp msgid "Click to copy." -msgstr "" +msgstr "Klõpsa, et kopeerida." #: editor/editor_about.cpp msgid "Godot Engine contributors" @@ -5039,8 +5039,8 @@ msgstr "" #: editor/plugins/baked_lightmap_editor_plugin.cpp msgid "" -"No meshes to bake. Make sure they contain an UV2 channel and that the 'Bake " -"Light' flag is on." +"No meshes to bake. Make sure they contain an UV2 channel and that the 'Use " +"In Baked Light' and 'Generate Lightmap' flags are on." msgstr "" #: editor/plugins/baked_lightmap_editor_plugin.cpp @@ -7244,7 +7244,7 @@ msgstr "Kuva tavaliselt" #: editor/plugins/spatial_editor_plugin.cpp msgid "Display Wireframe" -msgstr "Kuva traadiraamina" +msgstr "Kuva traatraamina" #: editor/plugins/spatial_editor_plugin.cpp msgid "Display Overdraw" diff --git a/editor/translations/eu.po b/editor/translations/eu.po index 87c91de10e..f9f2d97348 100644 --- a/editor/translations/eu.po +++ b/editor/translations/eu.po @@ -5012,8 +5012,8 @@ msgstr "" #: editor/plugins/baked_lightmap_editor_plugin.cpp msgid "" -"No meshes to bake. Make sure they contain an UV2 channel and that the 'Bake " -"Light' flag is on." +"No meshes to bake. Make sure they contain an UV2 channel and that the 'Use " +"In Baked Light' and 'Generate Lightmap' flags are on." msgstr "" #: editor/plugins/baked_lightmap_editor_plugin.cpp diff --git a/editor/translations/fa.po b/editor/translations/fa.po index ddccfeaebe..ab4157565e 100644 --- a/editor/translations/fa.po +++ b/editor/translations/fa.po @@ -5191,8 +5191,8 @@ msgstr "" #: editor/plugins/baked_lightmap_editor_plugin.cpp msgid "" -"No meshes to bake. Make sure they contain an UV2 channel and that the 'Bake " -"Light' flag is on." +"No meshes to bake. Make sure they contain an UV2 channel and that the 'Use " +"In Baked Light' and 'Generate Lightmap' flags are on." msgstr "" #: editor/plugins/baked_lightmap_editor_plugin.cpp diff --git a/editor/translations/fi.po b/editor/translations/fi.po index 834d1894e3..1007ee660b 100644 --- a/editor/translations/fi.po +++ b/editor/translations/fi.po @@ -5195,9 +5195,10 @@ msgstr "" "Tallenna skenesi ja yritä uudelleen." #: editor/plugins/baked_lightmap_editor_plugin.cpp +#, fuzzy msgid "" -"No meshes to bake. Make sure they contain an UV2 channel and that the 'Bake " -"Light' flag is on." +"No meshes to bake. Make sure they contain an UV2 channel and that the 'Use " +"In Baked Light' and 'Generate Lightmap' flags are on." msgstr "" "Ei meshejä kehitettävänä. Varmista, että ne sisältävät UV2-kanavan, ja että " "'Bake Light' asetus on päällä." diff --git a/editor/translations/fil.po b/editor/translations/fil.po index 892968821b..b23a43088c 100644 --- a/editor/translations/fil.po +++ b/editor/translations/fil.po @@ -4998,8 +4998,8 @@ msgstr "" #: editor/plugins/baked_lightmap_editor_plugin.cpp msgid "" -"No meshes to bake. Make sure they contain an UV2 channel and that the 'Bake " -"Light' flag is on." +"No meshes to bake. Make sure they contain an UV2 channel and that the 'Use " +"In Baked Light' and 'Generate Lightmap' flags are on." msgstr "" #: editor/plugins/baked_lightmap_editor_plugin.cpp diff --git a/editor/translations/fr.po b/editor/translations/fr.po index 6fad70a7c2..d4ded02294 100644 --- a/editor/translations/fr.po +++ b/editor/translations/fr.po @@ -85,8 +85,8 @@ msgid "" msgstr "" "Project-Id-Version: Godot Engine editor\n" "POT-Creation-Date: \n" -"PO-Revision-Date: 2021-07-01 14:33+0000\n" -"Last-Translator: Clément Topy <topy72.mine@gmail.com>\n" +"PO-Revision-Date: 2021-07-16 05:47+0000\n" +"Last-Translator: Pierre Caye <pierrecaye@laposte.net>\n" "Language-Team: French <https://hosted.weblate.org/projects/godot-engine/" "godot/fr/>\n" "Language: fr\n" @@ -94,7 +94,7 @@ msgstr "" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" "Plural-Forms: nplurals=2; plural=n > 1;\n" -"X-Generator: Weblate 4.8-dev\n" +"X-Generator: Weblate 4.7.2-dev\n" #: core/math/expression.cpp modules/gdscript/gdscript_functions.cpp #: modules/visual_script/visual_script_builtin_funcs.cpp @@ -5258,7 +5258,7 @@ msgstr "Dernier" #: editor/plugins/asset_library_editor_plugin.cpp msgid "All" -msgstr "Tout" +msgstr "All" #: editor/plugins/asset_library_editor_plugin.cpp msgid "No results for \"%s\"." @@ -5314,11 +5314,12 @@ msgstr "" #: editor/plugins/baked_lightmap_editor_plugin.cpp msgid "" -"No meshes to bake. Make sure they contain an UV2 channel and that the 'Bake " -"Light' flag is on." +"No meshes to bake. Make sure they contain an UV2 channel and that the 'Use " +"In Baked Light' and 'Generate Lightmap' flags are on." msgstr "" -"Aucun maillage à transférer. Assurez-vous qu'ils contiennent un canal UV2 et " -"que l'indicateur « Bake Light » est activé." +"Aucun maillage à précalculer. Assurez-vous qu'ils contiennent un canal UV2 " +"et que les propriétés « Use In Bake Light » et « Generate Lightmap » soient " +"activées." #: editor/plugins/baked_lightmap_editor_plugin.cpp msgid "Failed creating lightmap images, make sure path is writable." diff --git a/editor/translations/ga.po b/editor/translations/ga.po index 8168c1a440..9db93e38f8 100644 --- a/editor/translations/ga.po +++ b/editor/translations/ga.po @@ -4995,8 +4995,8 @@ msgstr "" #: editor/plugins/baked_lightmap_editor_plugin.cpp msgid "" -"No meshes to bake. Make sure they contain an UV2 channel and that the 'Bake " -"Light' flag is on." +"No meshes to bake. Make sure they contain an UV2 channel and that the 'Use " +"In Baked Light' and 'Generate Lightmap' flags are on." msgstr "" #: editor/plugins/baked_lightmap_editor_plugin.cpp diff --git a/editor/translations/gl.po b/editor/translations/gl.po index 016a3ab589..68e7b47599 100644 --- a/editor/translations/gl.po +++ b/editor/translations/gl.po @@ -5162,8 +5162,8 @@ msgstr "" #: editor/plugins/baked_lightmap_editor_plugin.cpp msgid "" -"No meshes to bake. Make sure they contain an UV2 channel and that the 'Bake " -"Light' flag is on." +"No meshes to bake. Make sure they contain an UV2 channel and that the 'Use " +"In Baked Light' and 'Generate Lightmap' flags are on." msgstr "" #: editor/plugins/baked_lightmap_editor_plugin.cpp diff --git a/editor/translations/he.po b/editor/translations/he.po index 5dc30a6cc2..a989a8aad0 100644 --- a/editor/translations/he.po +++ b/editor/translations/he.po @@ -5214,9 +5214,10 @@ msgstr "" "ממאפייני BakedLightmap." #: editor/plugins/baked_lightmap_editor_plugin.cpp +#, fuzzy msgid "" -"No meshes to bake. Make sure they contain an UV2 channel and that the 'Bake " -"Light' flag is on." +"No meshes to bake. Make sure they contain an UV2 channel and that the 'Use " +"In Baked Light' and 'Generate Lightmap' flags are on." msgstr "אין רשתות לאפייה. ודא/י שהם מכילים ערוץ UV2 והדגל 'Bake Light' מאופשר." #: editor/plugins/baked_lightmap_editor_plugin.cpp diff --git a/editor/translations/hi.po b/editor/translations/hi.po index db1dcd67e6..70187feed0 100644 --- a/editor/translations/hi.po +++ b/editor/translations/hi.po @@ -5137,8 +5137,8 @@ msgstr "" #: editor/plugins/baked_lightmap_editor_plugin.cpp msgid "" -"No meshes to bake. Make sure they contain an UV2 channel and that the 'Bake " -"Light' flag is on." +"No meshes to bake. Make sure they contain an UV2 channel and that the 'Use " +"In Baked Light' and 'Generate Lightmap' flags are on." msgstr "" #: editor/plugins/baked_lightmap_editor_plugin.cpp diff --git a/editor/translations/hr.po b/editor/translations/hr.po index d737bb04b7..c62d3f3eb5 100644 --- a/editor/translations/hr.po +++ b/editor/translations/hr.po @@ -9,7 +9,7 @@ msgid "" msgstr "" "Project-Id-Version: Godot Engine editor\n" -"PO-Revision-Date: 2021-04-11 22:02+0000\n" +"PO-Revision-Date: 2021-07-16 05:47+0000\n" "Last-Translator: LeoClose <leoclose575@gmail.com>\n" "Language-Team: Croatian <https://hosted.weblate.org/projects/godot-engine/" "godot/hr/>\n" @@ -18,7 +18,7 @@ msgstr "" "Content-Transfer-Encoding: 8-bit\n" "Plural-Forms: nplurals=3; plural=n%10==1 && n%100!=11 ? 0 : n%10>=2 && n" "%10<=4 && (n%100<10 || n%100>=20) ? 1 : 2;\n" -"X-Generator: Weblate 4.6-dev\n" +"X-Generator: Weblate 4.7.2-dev\n" #: core/math/expression.cpp modules/gdscript/gdscript_functions.cpp #: modules/visual_script/visual_script_builtin_funcs.cpp @@ -41,7 +41,7 @@ msgstr "Neispravan unos %i (nije uspio) u izrazu" #: core/math/expression.cpp msgid "self can't be used because instance is null (not passed)" -msgstr "self nije moguće koristiti jer je jedinka null (nije uspio)" +msgstr "self se ne može koristiti jer instanca je null (nije prosljeđena)" #: core/math/expression.cpp msgid "Invalid operands to operator %s, %s and %s." @@ -1716,7 +1716,7 @@ msgstr "Novo" #: editor/editor_feature_profile.cpp editor/editor_node.cpp #: editor/project_manager.cpp msgid "Import" -msgstr "Uvoz" +msgstr "Uvezi" #: editor/editor_feature_profile.cpp editor/project_export.cpp msgid "Export" @@ -2861,7 +2861,7 @@ msgstr "Zajednica" #: editor/editor_node.cpp msgid "About" -msgstr "" +msgstr "U vezi s" #: editor/editor_node.cpp msgid "Support Godot Development" @@ -5009,8 +5009,8 @@ msgstr "" #: editor/plugins/baked_lightmap_editor_plugin.cpp msgid "" -"No meshes to bake. Make sure they contain an UV2 channel and that the 'Bake " -"Light' flag is on." +"No meshes to bake. Make sure they contain an UV2 channel and that the 'Use " +"In Baked Light' and 'Generate Lightmap' flags are on." msgstr "" #: editor/plugins/baked_lightmap_editor_plugin.cpp diff --git a/editor/translations/hu.po b/editor/translations/hu.po index 85933dc05d..7a2e35e37b 100644 --- a/editor/translations/hu.po +++ b/editor/translations/hu.po @@ -5180,9 +5180,10 @@ msgstr "" "tulajdonságaiból." #: editor/plugins/baked_lightmap_editor_plugin.cpp +#, fuzzy msgid "" -"No meshes to bake. Make sure they contain an UV2 channel and that the 'Bake " -"Light' flag is on." +"No meshes to bake. Make sure they contain an UV2 channel and that the 'Use " +"In Baked Light' and 'Generate Lightmap' flags are on." msgstr "" "Nincs mesh, amibe adatokat süthetne. Bizonyosodjon meg arról, hogy " "tartalmaznak egy UV2 csatornát, és hogy a 'Fény Besütése' opció be van " diff --git a/editor/translations/id.po b/editor/translations/id.po index e1029fc231..4dce64fd92 100644 --- a/editor/translations/id.po +++ b/editor/translations/id.po @@ -5210,9 +5210,10 @@ msgstr "" "Simpan skena Anda dan coba lagi." #: editor/plugins/baked_lightmap_editor_plugin.cpp +#, fuzzy msgid "" -"No meshes to bake. Make sure they contain an UV2 channel and that the 'Bake " -"Light' flag is on." +"No meshes to bake. Make sure they contain an UV2 channel and that the 'Use " +"In Baked Light' and 'Generate Lightmap' flags are on." msgstr "" "Tidak ada mesh-mesh untuk di bake. Pastikan mereka punya kanal UV2 dan 'Bake " "Cahaya' menyala." diff --git a/editor/translations/is.po b/editor/translations/is.po index fc1423d841..c7d7023690 100644 --- a/editor/translations/is.po +++ b/editor/translations/is.po @@ -5051,8 +5051,8 @@ msgstr "" #: editor/plugins/baked_lightmap_editor_plugin.cpp msgid "" -"No meshes to bake. Make sure they contain an UV2 channel and that the 'Bake " -"Light' flag is on." +"No meshes to bake. Make sure they contain an UV2 channel and that the 'Use " +"In Baked Light' and 'Generate Lightmap' flags are on." msgstr "" #: editor/plugins/baked_lightmap_editor_plugin.cpp diff --git a/editor/translations/it.po b/editor/translations/it.po index 60c362c63a..f1de95dac6 100644 --- a/editor/translations/it.po +++ b/editor/translations/it.po @@ -59,12 +59,13 @@ # Alessandro Mandelli <mandelli.alessandro@ngi.it>, 2021. # Jusef Azzolina <rosarioazzolina33@gmail.com>, 2021. # Daniele Basso <tiziodcaio@gmail.com>, 2021. +# Riteo Siuga <riteo@posteo.net>, 2021. msgid "" msgstr "" "Project-Id-Version: Godot Engine editor\n" "POT-Creation-Date: \n" -"PO-Revision-Date: 2021-06-15 19:34+0000\n" -"Last-Translator: Riteo Siuga <lorenzocerqua@tutanota.com>\n" +"PO-Revision-Date: 2021-07-26 14:18+0000\n" +"Last-Translator: Riteo Siuga <riteo@posteo.net>\n" "Language-Team: Italian <https://hosted.weblate.org/projects/godot-engine/" "godot/it/>\n" "Language: it\n" @@ -72,7 +73,7 @@ msgstr "" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" "Plural-Forms: nplurals=2; plural=n != 1;\n" -"X-Generator: Weblate 4.7-dev\n" +"X-Generator: Weblate 4.7.2-dev\n" #: core/math/expression.cpp modules/gdscript/gdscript_functions.cpp #: modules/visual_script/visual_script_builtin_funcs.cpp @@ -876,6 +877,7 @@ msgid "Deferred" msgstr "Differita" #: editor/connections_dialog.cpp +#, fuzzy msgid "" "Defers the signal, storing it in a queue and only firing it at idle time." msgstr "" @@ -1172,7 +1174,7 @@ msgstr "Grazie dalla comunità di Godot!" #: editor/editor_about.cpp editor/editor_node.cpp editor/project_manager.cpp msgid "Click to copy." -msgstr "" +msgstr "Clicca per copiare." #: editor/editor_about.cpp msgid "Godot Engine contributors" @@ -2348,7 +2350,7 @@ msgid "" msgstr "" "Questa scena non può essere salvata perché contiene un'istanziazione " "ciclica.\n" -"Riprovare ad eseguire il salvataggio dopo aver risolto il problema." +"Riprovare a eseguire il salvataggio dopo aver risolto il problema." #: editor/editor_node.cpp msgid "" @@ -2962,7 +2964,7 @@ msgstr "" #: editor/editor_node.cpp msgid "Synchronize Scene Changes" -msgstr "Sincronizza i cambi della scena" +msgstr "Sincronizza i cambiamenti delle scene" #: editor/editor_node.cpp msgid "" @@ -2978,9 +2980,10 @@ msgstr "" #: editor/editor_node.cpp msgid "Synchronize Script Changes" -msgstr "Sincronizza Modifiche Script" +msgstr "Sincronizza le modifiche degli script" #: editor/editor_node.cpp +#, fuzzy msgid "" "When this option is enabled, any script that is saved will be reloaded in " "the running project.\n" @@ -2989,7 +2992,7 @@ msgid "" msgstr "" "Quando questa opzione è abilitata, qualsiasi script salvato verrà ricaricato " "nel progetto in esecuzione.\n" -"Quando usato in remoto su un dispositivo, essa risulta più efficate " +"Quando usato in remoto su un dispositivo, essa risulta più efficace " "abilitando l'opzione \"network filesystem\"." #: editor/editor_node.cpp editor/script_create_dialog.cpp @@ -3062,6 +3065,7 @@ msgid "Report a Bug" msgstr "Segnala un problema" #: editor/editor_node.cpp +#, fuzzy msgid "Send Docs Feedback" msgstr "Valuta la documentazione" @@ -3078,6 +3082,7 @@ msgid "Support Godot Development" msgstr "Supporta lo sviluppo di Godot" #: editor/editor_node.cpp +#, fuzzy msgid "Play the project." msgstr "Esegui il progetto." @@ -3091,7 +3096,7 @@ msgstr "Metti in pausa l'esecuzione della scena per eseguire il debug." #: editor/editor_node.cpp msgid "Pause Scene" -msgstr "Pausa scena" +msgstr "Pausa la scena" #: editor/editor_node.cpp msgid "Stop the scene." @@ -3115,7 +3120,7 @@ msgstr "Avvia una scena personalizzata" #: editor/editor_node.cpp msgid "Changing the video driver requires restarting the editor." -msgstr "Il cambiamento dei driver video necessita il riavvio dell'editor." +msgstr "Il cambiamento dei driver video necessita di un riavvio dell'editor." #: editor/editor_node.cpp editor/project_settings_editor.cpp #: editor/settings_config_dialog.cpp @@ -3131,6 +3136,7 @@ msgid "Update Continuously" msgstr "Aggiorna continuamente" #: editor/editor_node.cpp +#, fuzzy msgid "Update When Changed" msgstr "Aggiorna quando modificata" @@ -3209,16 +3215,17 @@ msgid "Template Package" msgstr "Pacchetto di modelli" #: editor/editor_node.cpp +#, fuzzy msgid "Export Library" msgstr "Esporta Libreria" #: editor/editor_node.cpp msgid "Merge With Existing" -msgstr "Unisci Con Esistente" +msgstr "Unisci con una esistente" #: editor/editor_node.cpp msgid "Open & Run a Script" -msgstr "Apri ed Esegui uno Script" +msgstr "Apri ed esegui uno script" #: editor/editor_node.cpp msgid "" @@ -3244,7 +3251,7 @@ msgstr "Nuova ereditata" #: editor/editor_node.cpp msgid "Load Errors" -msgstr "Carica errori" +msgstr "Errori di caricamento" #: editor/editor_node.cpp editor/plugins/tile_map_editor_plugin.cpp msgid "Select" @@ -3252,27 +3259,28 @@ msgstr "Seleziona" #: editor/editor_node.cpp msgid "Open 2D Editor" -msgstr "Apri Editor 2D" +msgstr "Apri l'editor 2D" #: editor/editor_node.cpp msgid "Open 3D Editor" -msgstr "Apri Editor 3D" +msgstr "Apri l'editor 3D" #: editor/editor_node.cpp msgid "Open Script Editor" -msgstr "Apri Editor degli script" +msgstr "Apri l'editor degli script" #: editor/editor_node.cpp editor/project_manager.cpp +#, fuzzy msgid "Open Asset Library" -msgstr "Apri Libreria degli Asset" +msgstr "Apri la libreria degli Asset" #: editor/editor_node.cpp msgid "Open the next Editor" -msgstr "Apri l'Editor successivo" +msgstr "Apri l'editor successivo" #: editor/editor_node.cpp msgid "Open the previous Editor" -msgstr "Apri l'Editor precedente" +msgstr "Apri l'editor precedente" #: editor/editor_node.h msgid "Warning!" @@ -3284,7 +3292,7 @@ msgstr "Nessuna sottorisorsa trovata." #: editor/editor_plugin.cpp msgid "Creating Mesh Previews" -msgstr "Creazione Anteprime Mesh" +msgstr "Creando le anteprime delle mesh" #: editor/editor_plugin.cpp msgid "Thumbnail..." @@ -3292,11 +3300,11 @@ msgstr "Miniatura..." #: editor/editor_plugin_settings.cpp msgid "Main Script:" -msgstr "Script Principale:" +msgstr "Script principale:" #: editor/editor_plugin_settings.cpp msgid "Edit Plugin" -msgstr "Modifica estensione" +msgstr "Modifica l'estensione" #: editor/editor_plugin_settings.cpp msgid "Installed Plugins:" @@ -3328,32 +3336,37 @@ msgid "Measure:" msgstr "Misura:" #: editor/editor_profiler.cpp +#, fuzzy msgid "Frame Time (sec)" -msgstr "Tempo Frame (sec)" +msgstr "Tempo fotogramma (sec)" #: editor/editor_profiler.cpp +#, fuzzy msgid "Average Time (sec)" -msgstr "Tempo Medio (sec)" +msgstr "Tempo medio (sec)" #: editor/editor_profiler.cpp +#, fuzzy msgid "Frame %" -msgstr "Frame %" +msgstr "% fotogramma" #: editor/editor_profiler.cpp +#, fuzzy msgid "Physics Frame %" -msgstr "Fotogramma della Fisica %" +msgstr "% fotogramma fisico" #: editor/editor_profiler.cpp msgid "Inclusive" msgstr "Inclusivo" #: editor/editor_profiler.cpp +#, fuzzy msgid "Self" msgstr "Se stesso" #: editor/editor_profiler.cpp msgid "Frame #:" -msgstr "Frame #:" +msgstr "Fotogramma #:" #: editor/editor_profiler.cpp msgid "Time" @@ -3365,7 +3378,7 @@ msgstr "Chiamate" #: editor/editor_properties.cpp msgid "Edit Text:" -msgstr "Modifica Testo:" +msgstr "Modifica il testo:" #: editor/editor_properties.cpp editor/script_create_dialog.cpp msgid "On" @@ -3389,55 +3402,57 @@ msgstr "Assegna..." #: editor/editor_properties.cpp msgid "Invalid RID" -msgstr "RID Invalido" +msgstr "RID non valido" #: editor/editor_properties.cpp msgid "" "The selected resource (%s) does not match any type expected for this " "property (%s)." msgstr "" -"La risorsa selezionata (%s) non corrisponde ad alcun tipo atteso per questa " -"proprietà (%s)." +"La risorsa selezionata (%s) non corrisponde ad alcun tipo previsto per " +"questa proprietà (%s)." #: editor/editor_properties.cpp msgid "" "Can't create a ViewportTexture on resources saved as a file.\n" "Resource needs to belong to a scene." msgstr "" -"Impossibile creare ViewportTexture da risorse salvate come file.\n" -"La risorsa deve appartenere ad una scena." +"Impossibile creare un ViewportTexture su delle risorse salvate come file.\n" +"Esse devono appartenere a una scena." #: editor/editor_properties.cpp +#, fuzzy msgid "" "Can't create a ViewportTexture on this resource because it's not set as " "local to scene.\n" "Please switch on the 'local to scene' property on it (and all resources " "containing it up to a node)." msgstr "" -"Impossibile creare ViewportTexture da questa risorsa perché non è definita " -"localmente in una scena.\n" -"Per favore attivare la proprietà \"local to scene\" sulla risorsa (e su " -"tutte le risorse che la contengono, fino al nodo che le utilizza)." +"Impossibile creare un VieportTexture su questa risorsa perché non è stata " +"impostata come locale alla scena.\n" +"Per favore attivare la properietà \"local to scene\" su di essa (e su tutte " +"quelle che la contengono fino ad arrivare a un nodo)." #: editor/editor_properties.cpp editor/property_editor.cpp msgid "Pick a Viewport" -msgstr "Scegli una Vista" +msgstr "Selezionare una vista" #: editor/editor_properties.cpp editor/property_editor.cpp msgid "New Script" -msgstr "Nuovo Script" +msgstr "Nuovo script" #: editor/editor_properties.cpp editor/scene_tree_dock.cpp msgid "Extend Script" -msgstr "Estendi Script" +msgstr "Estendi script" #: editor/editor_properties.cpp editor/property_editor.cpp msgid "New %s" msgstr "Nuovo %s" #: editor/editor_properties.cpp editor/property_editor.cpp +#, fuzzy msgid "Make Unique" -msgstr "Rendi Unico" +msgstr "Rendi unico" #: editor/editor_properties.cpp #: editor/plugins/animation_blend_space_1d_editor.cpp @@ -3455,11 +3470,12 @@ msgstr "Incolla" #: editor/editor_properties.cpp editor/property_editor.cpp msgid "Convert To %s" -msgstr "Converti In %s" +msgstr "Converti in %s" #: editor/editor_properties.cpp editor/property_editor.cpp +#, fuzzy msgid "Selected node is not a Viewport!" -msgstr "Il nodo selezionato non è una Viewport!" +msgstr "Il nodo selezionato non è un Viewport!" #: editor/editor_properties_array_dict.cpp msgid "Size: " @@ -3472,19 +3488,19 @@ msgstr "Pagina: " #: editor/editor_properties_array_dict.cpp #: editor/plugins/theme_editor_plugin.cpp msgid "Remove Item" -msgstr "Rimuovi Elemento" +msgstr "Rimuovi l'elemento" #: editor/editor_properties_array_dict.cpp msgid "New Key:" -msgstr "Nuova Chiave:" +msgstr "Nuova chiave:" #: editor/editor_properties_array_dict.cpp msgid "New Value:" -msgstr "Nuovo Valore:" +msgstr "Nuovo valore:" #: editor/editor_properties_array_dict.cpp msgid "Add Key/Value Pair" -msgstr "Aggiungi Coppia Chiave/Valore" +msgstr "Aggiungi una coppia chiave/valore" #: editor/editor_run_native.cpp msgid "" @@ -3492,13 +3508,15 @@ msgid "" "Please add a runnable preset in the Export menu or define an existing preset " "as runnable." msgstr "" -"Nessuna esportazione eseguibile trovata per questa piattaforma.\n" -"Per favore, aggiungi un preset eseguibile nel menù Export oppure definisci " -"un preset già esistente come \"eseguibile\"." +"Nessuna preimpostazione di esportazione eseguibile trovata per questa " +"piattaforma.\n" +"Per favore, aggiungerne una nel menù di esportazione o impostarne una già " +"esistente come eseguibile." #: editor/editor_run_script.cpp +#, fuzzy msgid "Write your logic in the _run() method." -msgstr "Scrivi la logica nel metodo _run()." +msgstr "Inserire la logica dello script nel metodo _run()." #: editor/editor_run_script.cpp msgid "There is an edited scene already." @@ -4499,7 +4517,7 @@ msgstr "Rimuovi Triangolo BlendSpace2D" #: editor/plugins/animation_blend_space_2d_editor.cpp msgid "BlendSpace2D does not belong to an AnimationTree node." -msgstr "BlendSpace2D non appartiene ad un nodo AnimationTree." +msgstr "BlendSpace2D non appartiene a un nodo AnimationTree." #: editor/plugins/animation_blend_space_2d_editor.cpp msgid "No triangles exist, so no blending can take place." @@ -5292,9 +5310,10 @@ msgstr "" "Salva la scena e riprova." #: editor/plugins/baked_lightmap_editor_plugin.cpp +#, fuzzy msgid "" -"No meshes to bake. Make sure they contain an UV2 channel and that the 'Bake " -"Light' flag is on." +"No meshes to bake. Make sure they contain an UV2 channel and that the 'Use " +"In Baked Light' and 'Generate Lightmap' flags are on." msgstr "" "Nessuna mesh da preprocessare. Assicurarsi che contengano un canale UV2 e " "che la spunta \"Bake Light\" sia abilitata." @@ -6658,7 +6677,7 @@ msgstr "Spostare il giunto" #: editor/plugins/polygon_2d_editor_plugin.cpp msgid "" "The skeleton property of the Polygon2D does not point to a Skeleton2D node" -msgstr "La proprietà scheletro del Polygon2D non punta ad un nodo Skeleton2D" +msgstr "La proprietà scheletro del Polygon2D non punta a un nodo Skeleton2D" #: editor/plugins/polygon_2d_editor_plugin.cpp msgid "Sync Bones" @@ -6914,7 +6933,7 @@ msgstr "Preloader Risorsa" #: editor/plugins/root_motion_editor_plugin.cpp msgid "AnimationTree has no path set to an AnimationPlayer" -msgstr "AnimationTree non ha nessun percorso impostato ad un AnimationPlayer" +msgstr "AnimationTree non ha nessun percorso impostato a un AnimationPlayer" #: editor/plugins/root_motion_editor_plugin.cpp msgid "Path to AnimationPlayer is invalid" @@ -6982,10 +7001,11 @@ msgid "Script is not in tool mode, will not be able to run." msgstr "Lo script non è in modalità tool, non sarà possibile eseguirlo." #: editor/plugins/script_editor_plugin.cpp +#, fuzzy msgid "" "To run this script, it must inherit EditorScript and be set to tool mode." msgstr "" -"Per eseguire questo script, esso deve ereditare EditorScript ed essere " +"Per eseguire questo script, esso deve ereditare da EditorScript ed essere " "impostato in modalità tool." #: editor/plugins/script_editor_plugin.cpp @@ -9322,8 +9342,9 @@ msgid "Finds the nearest even integer to the parameter." msgstr "Trova il numero intero pari più vicino al parametro." #: editor/plugins/visual_shader_editor_plugin.cpp +#, fuzzy msgid "Clamps the value between 0.0 and 1.0." -msgstr "Blocca il valore tra 0.0 ed 1.0." +msgstr "Blocca il valore tra 0.0 e 1.0." #: editor/plugins/visual_shader_editor_plugin.cpp msgid "Extracts the sign of the parameter." @@ -9342,6 +9363,7 @@ msgid "Returns the square root of the parameter." msgstr "Restituisce la radice quadrata del parametro." #: editor/plugins/visual_shader_editor_plugin.cpp +#, fuzzy msgid "" "SmoothStep function( scalar(edge0), scalar(edge1), scalar(x) ).\n" "\n" @@ -9353,7 +9375,7 @@ msgstr "" "\n" "Restituisce 0.0 se \"x\" è più piccolo di \"edge0\", o 1.0 se \"x\" è più " "grande di \"edge1\". Altrimenti, il valore di ritorno è interpolato tra 0.0 " -"ed 1.0 usando i polinomi di Hermite." +"e 1.0 usando i polinomi di Hermite." #: editor/plugins/visual_shader_editor_plugin.cpp msgid "" @@ -9430,6 +9452,7 @@ msgid "Transform function." msgstr "Funzione di trasformazione." #: editor/plugins/visual_shader_editor_plugin.cpp +#, fuzzy msgid "" "Calculate the outer product of a pair of vectors.\n" "\n" @@ -9513,6 +9536,7 @@ msgid "Calculates the dot product of two vectors." msgstr "Calcola il prodotto scalare di due vettori." #: editor/plugins/visual_shader_editor_plugin.cpp +#, fuzzy msgid "" "Returns the vector that points in the same direction as a reference vector. " "The function has three vector parameters : N, the vector to orient, I, the " @@ -9562,6 +9586,7 @@ msgid "Returns the vector that points in the direction of refraction." msgstr "Restituisce un vettore che punta nella direzione della refrazione." #: editor/plugins/visual_shader_editor_plugin.cpp +#, fuzzy msgid "" "SmoothStep function( vector(edge0), vector(edge1), vector(x) ).\n" "\n" @@ -9571,11 +9596,12 @@ msgid "" msgstr "" "SmoothStep function( vector(edge0), vector(edge1), vector(x) ).\n" "\n" -"Restituisce 0.0 se \"x\" è minore di \"edge0\", ed 1.0 se \"x\" è più grande " -"di \"edge1\". Altrimenti, il valore di ritorno è interpolato tra 0.0 ed 1.0 " +"Restituisce 0.0 se \"x\" è minore di \"edge0\", e 1.0 se \"x\" è più grande " +"di \"edge1\". Altrimenti, il valore di ritorno è interpolato tra 0.0 e 1.0 " "usando i polinomiali di Hermite." #: editor/plugins/visual_shader_editor_plugin.cpp +#, fuzzy msgid "" "SmoothStep function( scalar(edge0), scalar(edge1), vector(x) ).\n" "\n" @@ -9585,8 +9611,8 @@ msgid "" msgstr "" "SmoothStep function( scalar(edge0), scalar(edge1), vector(x) ).\n" "\n" -"Restituisce 0.0 se \"x\" è minore di \"edge0\", ed 1.0 se \"x\" è più grande " -"di \"edge1\". Altrimenti, il valore di ritorno è interpolato tra 0.0 ed 1.0 " +"Restituisce 0.0 se \"x\" è minore di \"edge0\", e 1.0 se \"x\" è più grande " +"di \"edge1\". Altrimenti, il valore di ritorno è interpolato tra 0.0 e 1.0 " "usando i polinomiali di Hermite." #: editor/plugins/visual_shader_editor_plugin.cpp @@ -9638,13 +9664,14 @@ msgid "Vector uniform." msgstr "Uniforme vettore." #: editor/plugins/visual_shader_editor_plugin.cpp +#, fuzzy msgid "" "Custom Godot Shader Language expression, with custom amount of input and " "output ports. This is a direct injection of code into the vertex/fragment/" "light function, do not use it to write the function declarations inside." msgstr "" "Una espressione del Custom Godot Shader Language, con quantità " -"personalizzabile di porte input ed output. Questa è una iniezione diretta di " +"personalizzabile di porte input e output. Questa è una iniezione diretta di " "codice nella funzione vertex/fragment/light. Non usarla per scrivere le " "dichiarazione della funzione all'interno." @@ -9654,7 +9681,7 @@ msgid "" "direction of camera (pass associated inputs to it)." msgstr "" "Restituisce il decadimento in base al prodotto scalare della normale della " -"superfice e direzione della telecamera (passa gli input associati ad essa)." +"superfice e direzione della telecamera (passa gli input associati a essa)." #: editor/plugins/visual_shader_editor_plugin.cpp msgid "" @@ -9669,8 +9696,9 @@ msgstr "" "dichiarare varianti, uniformi e costanti." #: editor/plugins/visual_shader_editor_plugin.cpp +#, fuzzy msgid "A reference to an existing uniform." -msgstr "Un riferimento ad una uniform esistente." +msgstr "Un riferimento a una uniform esistente." #: editor/plugins/visual_shader_editor_plugin.cpp msgid "(Fragment/Light mode only) Scalar derivative function." @@ -9713,20 +9741,22 @@ msgstr "" "differenziazione locale." #: editor/plugins/visual_shader_editor_plugin.cpp +#, fuzzy msgid "" "(Fragment/Light mode only) (Vector) Sum of absolute derivative in 'x' and " "'y'." msgstr "" "(Soltanto modalità Fragment/Light) (Vettore) Somma delle derivate assolute " -"in \"x\" ed \"y\"." +"in \"x\" e \"y\"." #: editor/plugins/visual_shader_editor_plugin.cpp +#, fuzzy msgid "" "(Fragment/Light mode only) (Scalar) Sum of absolute derivative in 'x' and " "'y'." msgstr "" "(Soltanto modalità Fragment/Light) (Scalare) Somma delle derivate assolute " -"in \"x\" ed \"y\"." +"in \"x\" e \"y\"." #: editor/plugins/visual_shader_editor_plugin.cpp msgid "VisualShader" @@ -9757,13 +9787,14 @@ msgstr "" "I template di esportazione sembrano essere mancanti o non validi." #: editor/project_export.cpp +#, fuzzy msgid "" "Failed to export the project for platform '%s'.\n" "This might be due to a configuration issue in the export preset or your " "export settings." msgstr "" "Impossibile esportare il progetto per la piattaforma \"%s\".\n" -"Questo potrebbe essere dovuto ad un problema di configurazione nel preset di " +"Questo potrebbe essere dovuto a un problema di configurazione nel preset di " "esportazione o nelle impostazioni di esportazione." #: editor/project_export.cpp @@ -12264,7 +12295,7 @@ msgstr "L'oggetto base non è un Nodo!" #: modules/visual_script/visual_script_func_nodes.cpp msgid "Path does not lead Node!" -msgstr "Il percorso non conduce ad un Nodo!" +msgstr "Il percorso non conduce a un Nodo!" #: modules/visual_script/visual_script_func_nodes.cpp msgid "Invalid index property name '%s' in node %s." @@ -12676,7 +12707,7 @@ msgid "" "CollisionObject2D derived node. Please only use it as a child of Area2D, " "StaticBody2D, RigidBody2D, KinematicBody2D, etc. to give them a shape." msgstr "" -"CollisionPolygon2D serve a fornire una forma di collisione ad un nodo " +"CollisionPolygon2D serve a fornire una forma di collisione a un nodo " "derivato di CollisionObject2D. Si prega di utilizzarlo solamente come figlio " "di Area2D, StaticBody2D, RigidBody2D, KinematicBody2D, etc. in modo da " "dargli una forma." @@ -12698,13 +12729,14 @@ msgstr "" "costruzione \"Segmenti\"." #: scene/2d/collision_shape_2d.cpp +#, fuzzy msgid "" "CollisionShape2D only serves to provide a collision shape to a " "CollisionObject2D derived node. Please only use it as a child of Area2D, " "StaticBody2D, RigidBody2D, KinematicBody2D, etc. to give them a shape." msgstr "" -"CollisionShape2D serve a fornire una forma di collisione ad un nodo derivato " -"di CollisionObject2D. Si prega di utilizzarlo solamente come figlio di " +"CollisionShape2D serve a fornire una forma di collisione a un nodo derivato " +"da CollisionObject2D. Si prega di utilizzarlo solamente come figlio di " "Area2D, StaticBody2D, RigidBody2D, KinematicBody2D, etc. in modo da dargli " "una forma." @@ -12840,9 +12872,9 @@ msgstr "" "Modifica invece la dimensione nelle forme di collisione figlie." #: scene/2d/remote_transform_2d.cpp +#, fuzzy msgid "Path property must point to a valid Node2D node to work." -msgstr "" -"La proprietà path deve puntare ad un nodo Node2D valido per funzionare." +msgstr "La proprietà path deve puntare a un nodo Node2D valido per funzionare." #: scene/2d/skeleton_2d.cpp msgid "This Bone2D chain should end at a Skeleton2D node." @@ -12888,11 +12920,12 @@ msgid "ARVRController must have an ARVROrigin node as its parent." msgstr "ARVRController deve avere un nodo ARVROrigin come genitore." #: scene/3d/arvr_nodes.cpp +#, fuzzy msgid "" "The controller ID must not be 0 or this controller won't be bound to an " "actual controller." msgstr "" -"L'id del controller non deve essere 0 o non verrà associato ad un controller " +"L'id del controller non deve essere 0 o non verrà associato a un controller " "attuale." #: scene/3d/arvr_nodes.cpp @@ -12900,11 +12933,12 @@ msgid "ARVRAnchor must have an ARVROrigin node as its parent." msgstr "ARVRAnchor deve avere un nodo ARVROrigin come genitore." #: scene/3d/arvr_nodes.cpp +#, fuzzy msgid "" "The anchor ID must not be 0 or this anchor won't be bound to an actual " "anchor." msgstr "" -"L'ID dell'ancora non deve essere 0 oppure non verrà associato ad un'ancora " +"L'ID dell'ancora non deve essere 0 oppure non verrà associato a un'ancora " "attuale." #: scene/3d/arvr_nodes.cpp @@ -12947,28 +12981,29 @@ msgstr "" "definire la sua forma." #: scene/3d/collision_polygon.cpp +#, fuzzy msgid "" "CollisionPolygon only serves to provide a collision shape to a " "CollisionObject derived node. Please only use it as a child of Area, " "StaticBody, RigidBody, KinematicBody, etc. to give them a shape." msgstr "" -"CollisionPolygon serve solamente a fornire una forma di collisione ad un " -"nodo derivato di CollisionObject. Si prega di usarlo solamente come figlio " -"di Area, StaticBody, RigidBody, KinematicBody, etc. in modo da dargli una " -"forma." +"CollisionPolygon serve solamente a fornire una forma di collisione a un nodo " +"derivato da CollisionObject. Si prega di usarlo solamente come figlio di " +"Area, StaticBody, RigidBody, KinematicBody, etc. in modo da dargli una forma." #: scene/3d/collision_polygon.cpp msgid "An empty CollisionPolygon has no effect on collision." msgstr "Un CollisionPolygon vuoto non ha effetti in collisione." #: scene/3d/collision_shape.cpp +#, fuzzy msgid "" "CollisionShape only serves to provide a collision shape to a CollisionObject " "derived node. Please only use it as a child of Area, StaticBody, RigidBody, " "KinematicBody, etc. to give them a shape." msgstr "" -"CollisionShape serve a fornire una forma di collisione ad un nodo derivato " -"di CollisionObject. Si prega di utilizzarlo solamente come figlio di Area, " +"CollisionShape serve a fornire una forma di collisione a un nodo derivato da " +"CollisionObject. Si prega di utilizzarlo solamente come figlio di Area, " "StaticBody, RigidBody, KinematicBody, etc. in modo da dargli una forma." #: scene/3d/collision_shape.cpp @@ -13288,13 +13323,14 @@ msgid "If \"Exp Edit\" is enabled, \"Min Value\" must be greater than 0." msgstr "Se \"Exp Edit\" è abilitato, \"Min Value\" deve essere maggiore di 0." #: scene/gui/scroll_container.cpp +#, fuzzy msgid "" "ScrollContainer is intended to work with a single child control.\n" "Use a container as child (VBox, HBox, etc.), or a Control and set the custom " "minimum size manually." msgstr "" "ScrollContainer è inteso per funzionare con un singolo figlio di controllo.\n" -"Usa un container come figlio (VBox, HBox, ect.), oppure un nodo Control ed " +"Usa un container come figlio (VBox, HBox, ect.), oppure un nodo Control e " "imposta la dimensione minima personalizzata manualmente." #: scene/gui/tree.cpp diff --git a/editor/translations/ja.po b/editor/translations/ja.po index 1fd770fe13..45977a890f 100644 --- a/editor/translations/ja.po +++ b/editor/translations/ja.po @@ -5214,9 +5214,10 @@ msgstr "" "シーンを保存してから再度行ってください。" #: editor/plugins/baked_lightmap_editor_plugin.cpp +#, fuzzy msgid "" -"No meshes to bake. Make sure they contain an UV2 channel and that the 'Bake " -"Light' flag is on." +"No meshes to bake. Make sure they contain an UV2 channel and that the 'Use " +"In Baked Light' and 'Generate Lightmap' flags are on." msgstr "" "ベイクするメッシュがありません。メッシュに UV2チャンネルが含まれてお" "り、'Bake Light' フラグがオンになっていることを確認してください。" diff --git a/editor/translations/ka.po b/editor/translations/ka.po index 587624651a..7a108d6f95 100644 --- a/editor/translations/ka.po +++ b/editor/translations/ka.po @@ -5176,8 +5176,8 @@ msgstr "" #: editor/plugins/baked_lightmap_editor_plugin.cpp msgid "" -"No meshes to bake. Make sure they contain an UV2 channel and that the 'Bake " -"Light' flag is on." +"No meshes to bake. Make sure they contain an UV2 channel and that the 'Use " +"In Baked Light' and 'Generate Lightmap' flags are on." msgstr "" #: editor/plugins/baked_lightmap_editor_plugin.cpp diff --git a/editor/translations/km.po b/editor/translations/km.po index fe396cf590..33e9b00daf 100644 --- a/editor/translations/km.po +++ b/editor/translations/km.po @@ -4986,8 +4986,8 @@ msgstr "" #: editor/plugins/baked_lightmap_editor_plugin.cpp msgid "" -"No meshes to bake. Make sure they contain an UV2 channel and that the 'Bake " -"Light' flag is on." +"No meshes to bake. Make sure they contain an UV2 channel and that the 'Use " +"In Baked Light' and 'Generate Lightmap' flags are on." msgstr "" #: editor/plugins/baked_lightmap_editor_plugin.cpp diff --git a/editor/translations/ko.po b/editor/translations/ko.po index ec9fed24ca..877f572f48 100644 --- a/editor/translations/ko.po +++ b/editor/translations/ko.po @@ -27,7 +27,7 @@ msgid "" msgstr "" "Project-Id-Version: Godot Engine editor\n" "POT-Creation-Date: \n" -"PO-Revision-Date: 2021-06-20 13:35+0000\n" +"PO-Revision-Date: 2021-07-16 05:47+0000\n" "Last-Translator: Myeongjin Lee <aranet100@gmail.com>\n" "Language-Team: Korean <https://hosted.weblate.org/projects/godot-engine/" "godot/ko/>\n" @@ -36,7 +36,7 @@ msgstr "" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" "Plural-Forms: nplurals=1; plural=0;\n" -"X-Generator: Weblate 4.7\n" +"X-Generator: Weblate 4.7.2-dev\n" #: core/math/expression.cpp modules/gdscript/gdscript_functions.cpp #: modules/visual_script/visual_script_builtin_funcs.cpp @@ -5182,9 +5182,10 @@ msgstr "" "당신의 씬을 저장하고 다시 시도하세요." #: editor/plugins/baked_lightmap_editor_plugin.cpp +#, fuzzy msgid "" -"No meshes to bake. Make sure they contain an UV2 channel and that the 'Bake " -"Light' flag is on." +"No meshes to bake. Make sure they contain an UV2 channel and that the 'Use " +"In Baked Light' and 'Generate Lightmap' flags are on." msgstr "" "라이트맵을 구울 메시가 없습니다. 메시가 UV2 채널을 갖고 있고 'Bake Light' 플" "래그가 켜져 있는지 확인해주세요." diff --git a/editor/translations/lt.po b/editor/translations/lt.po index 6df1f44cfb..f4043f1de2 100644 --- a/editor/translations/lt.po +++ b/editor/translations/lt.po @@ -5145,8 +5145,8 @@ msgstr "" #: editor/plugins/baked_lightmap_editor_plugin.cpp msgid "" -"No meshes to bake. Make sure they contain an UV2 channel and that the 'Bake " -"Light' flag is on." +"No meshes to bake. Make sure they contain an UV2 channel and that the 'Use " +"In Baked Light' and 'Generate Lightmap' flags are on." msgstr "" #: editor/plugins/baked_lightmap_editor_plugin.cpp diff --git a/editor/translations/lv.po b/editor/translations/lv.po index 8c8a0011c7..a4c8d10715 100644 --- a/editor/translations/lv.po +++ b/editor/translations/lv.po @@ -5038,8 +5038,8 @@ msgstr "" #: editor/plugins/baked_lightmap_editor_plugin.cpp msgid "" -"No meshes to bake. Make sure they contain an UV2 channel and that the 'Bake " -"Light' flag is on." +"No meshes to bake. Make sure they contain an UV2 channel and that the 'Use " +"In Baked Light' and 'Generate Lightmap' flags are on." msgstr "" #: editor/plugins/baked_lightmap_editor_plugin.cpp diff --git a/editor/translations/mi.po b/editor/translations/mi.po index 36a93be0ee..5a847e6594 100644 --- a/editor/translations/mi.po +++ b/editor/translations/mi.po @@ -4978,8 +4978,8 @@ msgstr "" #: editor/plugins/baked_lightmap_editor_plugin.cpp msgid "" -"No meshes to bake. Make sure they contain an UV2 channel and that the 'Bake " -"Light' flag is on." +"No meshes to bake. Make sure they contain an UV2 channel and that the 'Use " +"In Baked Light' and 'Generate Lightmap' flags are on." msgstr "" #: editor/plugins/baked_lightmap_editor_plugin.cpp diff --git a/editor/translations/mk.po b/editor/translations/mk.po index 7e5aa06f3c..001542b888 100644 --- a/editor/translations/mk.po +++ b/editor/translations/mk.po @@ -4985,8 +4985,8 @@ msgstr "" #: editor/plugins/baked_lightmap_editor_plugin.cpp msgid "" -"No meshes to bake. Make sure they contain an UV2 channel and that the 'Bake " -"Light' flag is on." +"No meshes to bake. Make sure they contain an UV2 channel and that the 'Use " +"In Baked Light' and 'Generate Lightmap' flags are on." msgstr "" #: editor/plugins/baked_lightmap_editor_plugin.cpp diff --git a/editor/translations/ml.po b/editor/translations/ml.po index 3919011ade..f7bc8349bc 100644 --- a/editor/translations/ml.po +++ b/editor/translations/ml.po @@ -4993,8 +4993,8 @@ msgstr "" #: editor/plugins/baked_lightmap_editor_plugin.cpp msgid "" -"No meshes to bake. Make sure they contain an UV2 channel and that the 'Bake " -"Light' flag is on." +"No meshes to bake. Make sure they contain an UV2 channel and that the 'Use " +"In Baked Light' and 'Generate Lightmap' flags are on." msgstr "" #: editor/plugins/baked_lightmap_editor_plugin.cpp diff --git a/editor/translations/mr.po b/editor/translations/mr.po index 4d81595cb1..66157f77d1 100644 --- a/editor/translations/mr.po +++ b/editor/translations/mr.po @@ -4985,8 +4985,8 @@ msgstr "" #: editor/plugins/baked_lightmap_editor_plugin.cpp msgid "" -"No meshes to bake. Make sure they contain an UV2 channel and that the 'Bake " -"Light' flag is on." +"No meshes to bake. Make sure they contain an UV2 channel and that the 'Use " +"In Baked Light' and 'Generate Lightmap' flags are on." msgstr "" #: editor/plugins/baked_lightmap_editor_plugin.cpp diff --git a/editor/translations/ms.po b/editor/translations/ms.po index 6226d644a3..d8714d6196 100644 --- a/editor/translations/ms.po +++ b/editor/translations/ms.po @@ -14,7 +14,7 @@ msgid "" msgstr "" "Project-Id-Version: Godot Engine editor\n" "POT-Creation-Date: \n" -"PO-Revision-Date: 2021-05-29 13:49+0000\n" +"PO-Revision-Date: 2021-07-23 12:59+0000\n" "Last-Translator: Keviindran Ramachandran <keviinx@yahoo.com>\n" "Language-Team: Malay <https://hosted.weblate.org/projects/godot-engine/godot/" "ms/>\n" @@ -23,7 +23,7 @@ msgstr "" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" "Plural-Forms: nplurals=1; plural=0;\n" -"X-Generator: Weblate 4.7-dev\n" +"X-Generator: Weblate 4.7.2-dev\n" #: core/math/expression.cpp modules/gdscript/gdscript_functions.cpp #: modules/visual_script/visual_script_builtin_funcs.cpp @@ -459,7 +459,7 @@ msgstr "Kunci Gerak Anim" #: editor/animation_track_editor.cpp #: modules/visual_script/visual_script_editor.cpp msgid "Clipboard is empty!" -msgstr "" +msgstr "Papan klip kosong!" #: editor/animation_track_editor.cpp msgid "Paste Tracks" @@ -1122,7 +1122,7 @@ msgstr "Terima kasih dari komuniti Godot!" #: editor/editor_about.cpp editor/editor_node.cpp editor/project_manager.cpp msgid "Click to copy." -msgstr "" +msgstr "Klik untuk salin." #: editor/editor_about.cpp msgid "Godot Engine contributors" @@ -1624,16 +1624,15 @@ msgstr "" "GLES3. Aktifkan 'Import Etc 2' atau 'Import Pvrtc' dalam Tetapan Projek." #: editor/editor_export.cpp -#, fuzzy msgid "" "Target platform requires 'PVRTC' texture compression for the driver fallback " "to GLES2.\n" "Enable 'Import Pvrtc' in Project Settings, or disable 'Driver Fallback " "Enabled'." msgstr "" -"Platform sasaran memerlukan pemampatan tekstur 'ETC' untuk sandaran pemandu " +"Platform sasaran memerlukan pemampatan tekstur 'PVRTC' untuk sandaran driver " "ke GLES2.\n" -"Aktifkan 'Import Etc' dalam Tetapan Projek, atau nyahaktifkan 'Driver " +"Aktifkan 'Import Pvrtc' dalam Tetapan Projek, atau nyahaktifkan 'Driver " "Fallback Enabled'." #: editor/editor_export.cpp platform/android/export/export.cpp @@ -2335,9 +2334,8 @@ msgid "Layout name not found!" msgstr "Nama susun atur tidak dijumpai!" #: editor/editor_node.cpp -#, fuzzy msgid "Restored the Default layout to its base settings." -msgstr "Tata letak lalai telah dipulihkan ke tetapan asas." +msgstr "Susun atur lalai telah dipulihkan ke tetapan asas." #: editor/editor_node.cpp msgid "" @@ -4501,34 +4499,34 @@ msgstr "Tetapkan kedudukan pengadunan dalam ruang" #: editor/plugins/animation_blend_space_1d_editor.cpp #: editor/plugins/animation_blend_space_2d_editor.cpp msgid "Select and move points, create points with RMB." -msgstr "" +msgstr "Pilih dan pindahkan titik-titik, cipta titik-titik dengan RMB." #: editor/plugins/animation_blend_space_1d_editor.cpp #: editor/plugins/animation_blend_space_2d_editor.cpp scene/gui/graph_edit.cpp msgid "Enable snap and show grid." -msgstr "" +msgstr "Aktifkan snap dan tunjukkan grid." #: editor/plugins/animation_blend_space_1d_editor.cpp #: editor/plugins/animation_blend_space_2d_editor.cpp msgid "Point" -msgstr "" +msgstr "Titik" #: editor/plugins/animation_blend_space_1d_editor.cpp #: editor/plugins/animation_blend_space_2d_editor.cpp #: editor/plugins/animation_blend_tree_editor_plugin.cpp msgid "Open Editor" -msgstr "" +msgstr "Buka Editor" #: editor/plugins/animation_blend_space_1d_editor.cpp #: editor/plugins/animation_blend_space_2d_editor.cpp #: editor/plugins/animation_blend_tree_editor_plugin.cpp #: editor/plugins/animation_state_machine_editor.cpp msgid "Open Animation Node" -msgstr "" +msgstr "Buka Nod Animasi" #: editor/plugins/animation_blend_space_2d_editor.cpp msgid "Triangle already exists." -msgstr "" +msgstr "Segi tiga sudah wujud." #: editor/plugins/animation_blend_space_2d_editor.cpp #, fuzzy @@ -4537,39 +4535,40 @@ msgstr "Anim Tambah Trek" #: editor/plugins/animation_blend_space_2d_editor.cpp msgid "Change BlendSpace2D Limits" -msgstr "" +msgstr "Tukar Had-had BlendSpace2D" #: editor/plugins/animation_blend_space_2d_editor.cpp msgid "Change BlendSpace2D Labels" -msgstr "" +msgstr "Tukar Label-label BlendSpace2D" #: editor/plugins/animation_blend_space_2d_editor.cpp msgid "Remove BlendSpace2D Point" -msgstr "" +msgstr "Keluarkan Titik BlendSpace2D" #: editor/plugins/animation_blend_space_2d_editor.cpp msgid "Remove BlendSpace2D Triangle" -msgstr "" +msgstr "Keluarkan Segi tiga BlendSpace2D" #: editor/plugins/animation_blend_space_2d_editor.cpp +#, fuzzy msgid "BlendSpace2D does not belong to an AnimationTree node." -msgstr "" +msgstr "BlendSpace2D bukan milik nod AnimationTree." #: editor/plugins/animation_blend_space_2d_editor.cpp msgid "No triangles exist, so no blending can take place." -msgstr "" +msgstr "Tiada segi tiga-segi tiga wujud, jadi tiada pengadunan boleh berlaku." #: editor/plugins/animation_blend_space_2d_editor.cpp msgid "Toggle Auto Triangles" -msgstr "" +msgstr "Togol Segi Tiga Auto" #: editor/plugins/animation_blend_space_2d_editor.cpp msgid "Create triangles by connecting points." -msgstr "" +msgstr "Cipta segi tiga dengan menhubungkan titik-titik." #: editor/plugins/animation_blend_space_2d_editor.cpp msgid "Erase points and triangles." -msgstr "" +msgstr "Padamkan titik-titik dan segi tiga-segi tiga." #: editor/plugins/animation_blend_space_2d_editor.cpp msgid "Generate blend triangles automatically (instead of manually)" @@ -5334,8 +5333,8 @@ msgstr "" #: editor/plugins/baked_lightmap_editor_plugin.cpp msgid "" -"No meshes to bake. Make sure they contain an UV2 channel and that the 'Bake " -"Light' flag is on." +"No meshes to bake. Make sure they contain an UV2 channel and that the 'Use " +"In Baked Light' and 'Generate Lightmap' flags are on." msgstr "" #: editor/plugins/baked_lightmap_editor_plugin.cpp diff --git a/editor/translations/nb.po b/editor/translations/nb.po index 042ee8d26f..c36274abba 100644 --- a/editor/translations/nb.po +++ b/editor/translations/nb.po @@ -5427,8 +5427,8 @@ msgstr "" #: editor/plugins/baked_lightmap_editor_plugin.cpp msgid "" -"No meshes to bake. Make sure they contain an UV2 channel and that the 'Bake " -"Light' flag is on." +"No meshes to bake. Make sure they contain an UV2 channel and that the 'Use " +"In Baked Light' and 'Generate Lightmap' flags are on." msgstr "" #: editor/plugins/baked_lightmap_editor_plugin.cpp diff --git a/editor/translations/nl.po b/editor/translations/nl.po index 2410cd5ad0..296291e435 100644 --- a/editor/translations/nl.po +++ b/editor/translations/nl.po @@ -46,12 +46,13 @@ # T-rex08 <ipadtriceratops@gmail.com>, 2021. # Dwarffish <hoogvlietjohan@gmail.com>, 2021. # Arthur de Roos <arthur.de.roos@gmail.com>, 2021. +# Vancha March <tjipkevdh@gmail.com>, 2021. msgid "" msgstr "" "Project-Id-Version: Godot Engine editor\n" "POT-Creation-Date: \n" -"PO-Revision-Date: 2021-06-05 08:32+0000\n" -"Last-Translator: Stijn Hinlopen <f.a.hinlopen@gmail.com>\n" +"PO-Revision-Date: 2021-07-26 14:18+0000\n" +"Last-Translator: Vancha March <tjipkevdh@gmail.com>\n" "Language-Team: Dutch <https://hosted.weblate.org/projects/godot-engine/godot/" "nl/>\n" "Language: nl\n" @@ -59,7 +60,7 @@ msgstr "" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" "Plural-Forms: nplurals=2; plural=n != 1;\n" -"X-Generator: Weblate 4.7-dev\n" +"X-Generator: Weblate 4.7.2-dev\n" #: core/math/expression.cpp modules/gdscript/gdscript_functions.cpp #: modules/visual_script/visual_script_builtin_funcs.cpp @@ -1162,7 +1163,7 @@ msgstr "Bedankt van de Godot gemeenschap!" #: editor/editor_about.cpp editor/editor_node.cpp editor/project_manager.cpp msgid "Click to copy." -msgstr "" +msgstr "Klik om te kopiëren." #: editor/editor_about.cpp msgid "Godot Engine contributors" @@ -5243,9 +5244,10 @@ msgstr "" "Sla uw scène op en probeer opnieuw." #: editor/plugins/baked_lightmap_editor_plugin.cpp +#, fuzzy msgid "" -"No meshes to bake. Make sure they contain an UV2 channel and that the 'Bake " -"Light' flag is on." +"No meshes to bake. Make sure they contain an UV2 channel and that the 'Use " +"In Baked Light' and 'Generate Lightmap' flags are on." msgstr "" "Geen meshes om te bakken. Zorg ervoor dat ze een UV2 kanaal bevatten en dat " "'Bake Light' vlag aan staat." diff --git a/editor/translations/or.po b/editor/translations/or.po index 87528cdac5..c1d191a4a5 100644 --- a/editor/translations/or.po +++ b/editor/translations/or.po @@ -4984,8 +4984,8 @@ msgstr "" #: editor/plugins/baked_lightmap_editor_plugin.cpp msgid "" -"No meshes to bake. Make sure they contain an UV2 channel and that the 'Bake " -"Light' flag is on." +"No meshes to bake. Make sure they contain an UV2 channel and that the 'Use " +"In Baked Light' and 'Generate Lightmap' flags are on." msgstr "" #: editor/plugins/baked_lightmap_editor_plugin.cpp diff --git a/editor/translations/pl.po b/editor/translations/pl.po index 3c51593e02..d933e8f92b 100644 --- a/editor/translations/pl.po +++ b/editor/translations/pl.po @@ -52,8 +52,8 @@ msgid "" msgstr "" "Project-Id-Version: Godot Engine editor\n" "POT-Creation-Date: \n" -"PO-Revision-Date: 2021-07-05 14:32+0000\n" -"Last-Translator: Rafal Brozio <rafal.brozio@gmail.com>\n" +"PO-Revision-Date: 2021-07-16 05:47+0000\n" +"Last-Translator: Tomek <kobewi4e@gmail.com>\n" "Language-Team: Polish <https://hosted.weblate.org/projects/godot-engine/" "godot/pl/>\n" "Language: pl\n" @@ -62,7 +62,7 @@ msgstr "" "Content-Transfer-Encoding: 8bit\n" "Plural-Forms: nplurals=3; plural=n==1 ? 0 : n%10>=2 && n%10<=4 && (n%100<10 " "|| n%100>=20) ? 1 : 2;\n" -"X-Generator: Weblate 4.8-dev\n" +"X-Generator: Weblate 4.7.2-dev\n" #: core/math/expression.cpp modules/gdscript/gdscript_functions.cpp #: modules/visual_script/visual_script_builtin_funcs.cpp @@ -5229,9 +5229,10 @@ msgstr "" "Zapisz scenę i spróbuj ponownie." #: editor/plugins/baked_lightmap_editor_plugin.cpp +#, fuzzy msgid "" -"No meshes to bake. Make sure they contain an UV2 channel and that the 'Bake " -"Light' flag is on." +"No meshes to bake. Make sure they contain an UV2 channel and that the 'Use " +"In Baked Light' and 'Generate Lightmap' flags are on." msgstr "" "Brak siatek do cieniowania. Upewnij się, że zawierają kanał UV2 i że flaga " "\"Bake Light\" jest ustawiona." @@ -5760,7 +5761,7 @@ msgstr "Powiększ do zaznaczenia" #: editor/plugins/canvas_item_editor_plugin.cpp msgid "Preview Canvas Scale" -msgstr "Skala płótna podglądu" +msgstr "Podejrzyj skalę płótna" #: editor/plugins/canvas_item_editor_plugin.cpp msgid "Translation mask for inserting keys." diff --git a/editor/translations/pr.po b/editor/translations/pr.po index 675c9cf506..9b586ad756 100644 --- a/editor/translations/pr.po +++ b/editor/translations/pr.po @@ -5153,8 +5153,8 @@ msgstr "" #: editor/plugins/baked_lightmap_editor_plugin.cpp msgid "" -"No meshes to bake. Make sure they contain an UV2 channel and that the 'Bake " -"Light' flag is on." +"No meshes to bake. Make sure they contain an UV2 channel and that the 'Use " +"In Baked Light' and 'Generate Lightmap' flags are on." msgstr "" #: editor/plugins/baked_lightmap_editor_plugin.cpp diff --git a/editor/translations/pt.po b/editor/translations/pt.po index 17b1861821..6eb24001a5 100644 --- a/editor/translations/pt.po +++ b/editor/translations/pt.po @@ -5209,9 +5209,10 @@ msgstr "" "Guarde a sua cena e tente novamente." #: editor/plugins/baked_lightmap_editor_plugin.cpp +#, fuzzy msgid "" -"No meshes to bake. Make sure they contain an UV2 channel and that the 'Bake " -"Light' flag is on." +"No meshes to bake. Make sure they contain an UV2 channel and that the 'Use " +"In Baked Light' and 'Generate Lightmap' flags are on." msgstr "" "Não há malhas para consolidar. Assegure-se que contêm um canal UV2 e que a " "referência 'Bake Light' flag está on." diff --git a/editor/translations/pt_BR.po b/editor/translations/pt_BR.po index e79dd0fa19..01f6220bbd 100644 --- a/editor/translations/pt_BR.po +++ b/editor/translations/pt_BR.po @@ -5320,9 +5320,10 @@ msgstr "" "Salve sua cena e tente novamente." #: editor/plugins/baked_lightmap_editor_plugin.cpp +#, fuzzy msgid "" -"No meshes to bake. Make sure they contain an UV2 channel and that the 'Bake " -"Light' flag is on." +"No meshes to bake. Make sure they contain an UV2 channel and that the 'Use " +"In Baked Light' and 'Generate Lightmap' flags are on." msgstr "" "Não há malhas para preparar. Certifique-se de que elas possuem um canal UV2 " "e que a propriedade \"Preparar Luz\" está habilitada." diff --git a/editor/translations/ro.po b/editor/translations/ro.po index 7ac06fc1b1..3b5af5fe1a 100644 --- a/editor/translations/ro.po +++ b/editor/translations/ro.po @@ -5218,9 +5218,10 @@ msgstr "" "cale de salvare din proprietățile BakedLightmap." #: editor/plugins/baked_lightmap_editor_plugin.cpp +#, fuzzy msgid "" -"No meshes to bake. Make sure they contain an UV2 channel and that the 'Bake " -"Light' flag is on." +"No meshes to bake. Make sure they contain an UV2 channel and that the 'Use " +"In Baked Light' and 'Generate Lightmap' flags are on." msgstr "" "Nicio structură pentru procesare. Asigură-te că acestea conțin un canal UV2 " "și că opțiunea 'Procesează Lumina' este pornită." diff --git a/editor/translations/ru.po b/editor/translations/ru.po index 4b56d21383..e02b70b16d 100644 --- a/editor/translations/ru.po +++ b/editor/translations/ru.po @@ -97,12 +97,13 @@ # Bualma Show <appleaidar6@gmail.com>, 2021. # enderlorde <madel.laboratories@gmail.com>, 2021. # Олег Довгер <oleg.a.dovger@gmail.com>, 2021. +# Anna Malinovskaia <tacitcoast@gmail.com>, 2021. msgid "" msgstr "" "Project-Id-Version: Godot Engine editor\n" "POT-Creation-Date: \n" -"PO-Revision-Date: 2021-07-13 06:13+0000\n" -"Last-Translator: Danil Alexeev <danil@alexeev.xyz>\n" +"PO-Revision-Date: 2021-07-19 09:34+0000\n" +"Last-Translator: Anna Malinovskaia <tacitcoast@gmail.com>\n" "Language-Team: Russian <https://hosted.weblate.org/projects/godot-engine/" "godot/ru/>\n" "Language: ru\n" @@ -5286,9 +5287,10 @@ msgstr "" "Сохраните сцену и попробуйте ещё раз." #: editor/plugins/baked_lightmap_editor_plugin.cpp +#, fuzzy msgid "" -"No meshes to bake. Make sure they contain an UV2 channel and that the 'Bake " -"Light' flag is on." +"No meshes to bake. Make sure they contain an UV2 channel and that the 'Use " +"In Baked Light' and 'Generate Lightmap' flags are on." msgstr "" "Нет полисеток для запекания. Убедитесь, что они содержат канал UV2 и что " "флаг «Запекание света» включён." diff --git a/editor/translations/si.po b/editor/translations/si.po index a5586af274..36abdd4774 100644 --- a/editor/translations/si.po +++ b/editor/translations/si.po @@ -5024,8 +5024,8 @@ msgstr "" #: editor/plugins/baked_lightmap_editor_plugin.cpp msgid "" -"No meshes to bake. Make sure they contain an UV2 channel and that the 'Bake " -"Light' flag is on." +"No meshes to bake. Make sure they contain an UV2 channel and that the 'Use " +"In Baked Light' and 'Generate Lightmap' flags are on." msgstr "" #: editor/plugins/baked_lightmap_editor_plugin.cpp diff --git a/editor/translations/sk.po b/editor/translations/sk.po index d97e1321ef..cb56bb037e 100644 --- a/editor/translations/sk.po +++ b/editor/translations/sk.po @@ -5183,9 +5183,10 @@ msgstr "" "na uloženie so BakedLightmap vlastností." #: editor/plugins/baked_lightmap_editor_plugin.cpp +#, fuzzy msgid "" -"No meshes to bake. Make sure they contain an UV2 channel and that the 'Bake " -"Light' flag is on." +"No meshes to bake. Make sure they contain an UV2 channel and that the 'Use " +"In Baked Light' and 'Generate Lightmap' flags are on." msgstr "" "Žiadne mesh-e na bake. Uistite sa že obsahujú UV2 channel a je na ňom 'Bake " "Light' vlajka." diff --git a/editor/translations/sl.po b/editor/translations/sl.po index 07bd33c389..42f0bfc2cb 100644 --- a/editor/translations/sl.po +++ b/editor/translations/sl.po @@ -5419,9 +5419,10 @@ msgstr "" "shranitev iz lastnosti Zapečene Svetlobne karte." #: editor/plugins/baked_lightmap_editor_plugin.cpp +#, fuzzy msgid "" -"No meshes to bake. Make sure they contain an UV2 channel and that the 'Bake " -"Light' flag is on." +"No meshes to bake. Make sure they contain an UV2 channel and that the 'Use " +"In Baked Light' and 'Generate Lightmap' flags are on." msgstr "" "Brez modelov za peko. Poskrbi, da vsebujejo kanal UV2 in da je vključena " "oznaka 'Zapeči Svetlobo'." diff --git a/editor/translations/sq.po b/editor/translations/sq.po index 49a42b5553..f054de99bd 100644 --- a/editor/translations/sq.po +++ b/editor/translations/sq.po @@ -5273,8 +5273,8 @@ msgstr "" #: editor/plugins/baked_lightmap_editor_plugin.cpp msgid "" -"No meshes to bake. Make sure they contain an UV2 channel and that the 'Bake " -"Light' flag is on." +"No meshes to bake. Make sure they contain an UV2 channel and that the 'Use " +"In Baked Light' and 'Generate Lightmap' flags are on." msgstr "" #: editor/plugins/baked_lightmap_editor_plugin.cpp diff --git a/editor/translations/sr_Cyrl.po b/editor/translations/sr_Cyrl.po index 53fb04b3e4..5d4f6cab1b 100644 --- a/editor/translations/sr_Cyrl.po +++ b/editor/translations/sr_Cyrl.po @@ -5682,8 +5682,8 @@ msgstr "" #: editor/plugins/baked_lightmap_editor_plugin.cpp #, fuzzy msgid "" -"No meshes to bake. Make sure they contain an UV2 channel and that the 'Bake " -"Light' flag is on." +"No meshes to bake. Make sure they contain an UV2 channel and that the 'Use " +"In Baked Light' and 'Generate Lightmap' flags are on." msgstr "" "Нема мрежа за печење. Провери да ли садрже UV2 канал и да је опција 'Изпеци " "Светла' укључена." diff --git a/editor/translations/sr_Latn.po b/editor/translations/sr_Latn.po index 0a90379b41..49f7cd7f3e 100644 --- a/editor/translations/sr_Latn.po +++ b/editor/translations/sr_Latn.po @@ -5048,8 +5048,8 @@ msgstr "" #: editor/plugins/baked_lightmap_editor_plugin.cpp msgid "" -"No meshes to bake. Make sure they contain an UV2 channel and that the 'Bake " -"Light' flag is on." +"No meshes to bake. Make sure they contain an UV2 channel and that the 'Use " +"In Baked Light' and 'Generate Lightmap' flags are on." msgstr "" #: editor/plugins/baked_lightmap_editor_plugin.cpp diff --git a/editor/translations/sv.po b/editor/translations/sv.po index 0c5db25a9a..79c1c4a1b9 100644 --- a/editor/translations/sv.po +++ b/editor/translations/sv.po @@ -5277,8 +5277,8 @@ msgstr "" #: editor/plugins/baked_lightmap_editor_plugin.cpp msgid "" -"No meshes to bake. Make sure they contain an UV2 channel and that the 'Bake " -"Light' flag is on." +"No meshes to bake. Make sure they contain an UV2 channel and that the 'Use " +"In Baked Light' and 'Generate Lightmap' flags are on." msgstr "" #: editor/plugins/baked_lightmap_editor_plugin.cpp diff --git a/editor/translations/ta.po b/editor/translations/ta.po index 0c9022b097..45eef9a8f6 100644 --- a/editor/translations/ta.po +++ b/editor/translations/ta.po @@ -5033,8 +5033,8 @@ msgstr "" #: editor/plugins/baked_lightmap_editor_plugin.cpp msgid "" -"No meshes to bake. Make sure they contain an UV2 channel and that the 'Bake " -"Light' flag is on." +"No meshes to bake. Make sure they contain an UV2 channel and that the 'Use " +"In Baked Light' and 'Generate Lightmap' flags are on." msgstr "" #: editor/plugins/baked_lightmap_editor_plugin.cpp diff --git a/editor/translations/te.po b/editor/translations/te.po index 8274d5520f..47338f3f28 100644 --- a/editor/translations/te.po +++ b/editor/translations/te.po @@ -4987,8 +4987,8 @@ msgstr "" #: editor/plugins/baked_lightmap_editor_plugin.cpp msgid "" -"No meshes to bake. Make sure they contain an UV2 channel and that the 'Bake " -"Light' flag is on." +"No meshes to bake. Make sure they contain an UV2 channel and that the 'Use " +"In Baked Light' and 'Generate Lightmap' flags are on." msgstr "" #: editor/plugins/baked_lightmap_editor_plugin.cpp diff --git a/editor/translations/th.po b/editor/translations/th.po index e9c2a80a49..fc38c35df9 100644 --- a/editor/translations/th.po +++ b/editor/translations/th.po @@ -5125,9 +5125,10 @@ msgstr "" "ลองบันทึกฉากของคุณแล้วลองอีกครั้ง" #: editor/plugins/baked_lightmap_editor_plugin.cpp +#, fuzzy msgid "" -"No meshes to bake. Make sure they contain an UV2 channel and that the 'Bake " -"Light' flag is on." +"No meshes to bake. Make sure they contain an UV2 channel and that the 'Use " +"In Baked Light' and 'Generate Lightmap' flags are on." msgstr "" "ไม่มีพื้นผิวให้สร้าง lightmap กรุณาตรวจสอบว่าพื้นผิวมี UV2 และได้เปิดใช้งาน 'Bake Light'" diff --git a/editor/translations/tr.po b/editor/translations/tr.po index 578d7b48d0..4f3eb3ff60 100644 --- a/editor/translations/tr.po +++ b/editor/translations/tr.po @@ -5250,9 +5250,10 @@ msgstr "" "Sahneyi kaydedip tekrar deneyin." #: editor/plugins/baked_lightmap_editor_plugin.cpp +#, fuzzy msgid "" -"No meshes to bake. Make sure they contain an UV2 channel and that the 'Bake " -"Light' flag is on." +"No meshes to bake. Make sure they contain an UV2 channel and that the 'Use " +"In Baked Light' and 'Generate Lightmap' flags are on." msgstr "" "Pişirilecek örüntüler yok. Örüntülerin UV2 kanalı içerdiğinden ve 'Bake " "Light' bayrağınının açık olduğundan emin olun." diff --git a/editor/translations/tt.po b/editor/translations/tt.po index 3e63f2369d..d5d41b7879 100644 --- a/editor/translations/tt.po +++ b/editor/translations/tt.po @@ -4987,8 +4987,8 @@ msgstr "" #: editor/plugins/baked_lightmap_editor_plugin.cpp msgid "" -"No meshes to bake. Make sure they contain an UV2 channel and that the 'Bake " -"Light' flag is on." +"No meshes to bake. Make sure they contain an UV2 channel and that the 'Use " +"In Baked Light' and 'Generate Lightmap' flags are on." msgstr "" #: editor/plugins/baked_lightmap_editor_plugin.cpp diff --git a/editor/translations/tzm.po b/editor/translations/tzm.po index 0b0ce7d01e..fdb092c6a4 100644 --- a/editor/translations/tzm.po +++ b/editor/translations/tzm.po @@ -4985,8 +4985,8 @@ msgstr "" #: editor/plugins/baked_lightmap_editor_plugin.cpp msgid "" -"No meshes to bake. Make sure they contain an UV2 channel and that the 'Bake " -"Light' flag is on." +"No meshes to bake. Make sure they contain an UV2 channel and that the 'Use " +"In Baked Light' and 'Generate Lightmap' flags are on." msgstr "" #: editor/plugins/baked_lightmap_editor_plugin.cpp diff --git a/editor/translations/uk.po b/editor/translations/uk.po index 50508c5df3..66c69938f6 100644 --- a/editor/translations/uk.po +++ b/editor/translations/uk.po @@ -5222,9 +5222,10 @@ msgstr "" "Збережіть вашу сцену і повторіть спробу." #: editor/plugins/baked_lightmap_editor_plugin.cpp +#, fuzzy msgid "" -"No meshes to bake. Make sure they contain an UV2 channel and that the 'Bake " -"Light' flag is on." +"No meshes to bake. Make sure they contain an UV2 channel and that the 'Use " +"In Baked Light' and 'Generate Lightmap' flags are on." msgstr "" "Немає полісеток для запікання. Переконайтеся, що вони містять канал UV2 і що " "прапор 'Запікання світла' включений." diff --git a/editor/translations/ur_PK.po b/editor/translations/ur_PK.po index 0a213a2bdf..5476915ea5 100644 --- a/editor/translations/ur_PK.po +++ b/editor/translations/ur_PK.po @@ -5091,8 +5091,8 @@ msgstr "" #: editor/plugins/baked_lightmap_editor_plugin.cpp msgid "" -"No meshes to bake. Make sure they contain an UV2 channel and that the 'Bake " -"Light' flag is on." +"No meshes to bake. Make sure they contain an UV2 channel and that the 'Use " +"In Baked Light' and 'Generate Lightmap' flags are on." msgstr "" #: editor/plugins/baked_lightmap_editor_plugin.cpp diff --git a/editor/translations/vi.po b/editor/translations/vi.po index 0104d05502..4267f19def 100644 --- a/editor/translations/vi.po +++ b/editor/translations/vi.po @@ -5156,8 +5156,8 @@ msgstr "" #: editor/plugins/baked_lightmap_editor_plugin.cpp msgid "" -"No meshes to bake. Make sure they contain an UV2 channel and that the 'Bake " -"Light' flag is on." +"No meshes to bake. Make sure they contain an UV2 channel and that the 'Use " +"In Baked Light' and 'Generate Lightmap' flags are on." msgstr "" #: editor/plugins/baked_lightmap_editor_plugin.cpp diff --git a/editor/translations/zh_CN.po b/editor/translations/zh_CN.po index 4393cb4e08..c5b0c34c74 100644 --- a/editor/translations/zh_CN.po +++ b/editor/translations/zh_CN.po @@ -83,7 +83,7 @@ msgid "" msgstr "" "Project-Id-Version: Chinese (Simplified) (Godot Engine)\n" "POT-Creation-Date: 2018-01-20 12:15+0200\n" -"PO-Revision-Date: 2021-07-13 06:13+0000\n" +"PO-Revision-Date: 2021-07-23 12:59+0000\n" "Last-Translator: Haoyu Qiu <timothyqiu32@gmail.com>\n" "Language-Team: Chinese (Simplified) <https://hosted.weblate.org/projects/" "godot-engine/godot/zh_Hans/>\n" @@ -1172,7 +1172,7 @@ msgstr "改变字典值" #: editor/editor_about.cpp msgid "Thanks from the Godot community!" -msgstr "Godot 社区感谢你!" +msgstr "Godot 社区感谢大家!" #: editor/editor_about.cpp editor/editor_node.cpp editor/project_manager.cpp msgid "Click to copy." @@ -5171,9 +5171,10 @@ msgstr "" "BakedLightmap 属性。" #: editor/plugins/baked_lightmap_editor_plugin.cpp +#, fuzzy msgid "" -"No meshes to bake. Make sure they contain an UV2 channel and that the 'Bake " -"Light' flag is on." +"No meshes to bake. Make sure they contain an UV2 channel and that the 'Use " +"In Baked Light' and 'Generate Lightmap' flags are on." msgstr "没有可烘焙的网格。请确保网格包含 UV2 通道并且勾选 “Bake Light” 选项。" #: editor/plugins/baked_lightmap_editor_plugin.cpp @@ -7338,7 +7339,7 @@ msgstr "顶视图。" #: editor/plugins/spatial_editor_plugin.cpp msgid "Bottom View." -msgstr "仰视图。" +msgstr "底视图。" #: editor/plugins/spatial_editor_plugin.cpp msgid "Bottom" @@ -7547,11 +7548,11 @@ msgstr "使用吸附" #: editor/plugins/spatial_editor_plugin.cpp msgid "Bottom View" -msgstr "仰视图" +msgstr "底视图" #: editor/plugins/spatial_editor_plugin.cpp msgid "Top View" -msgstr "俯视图" +msgstr "顶视图" #: editor/plugins/spatial_editor_plugin.cpp msgid "Rear View" @@ -7559,7 +7560,7 @@ msgstr "后视图" #: editor/plugins/spatial_editor_plugin.cpp msgid "Front View" -msgstr "正视图" +msgstr "前视图" #: editor/plugins/spatial_editor_plugin.cpp msgid "Left View" @@ -8240,7 +8241,7 @@ msgstr "新建自动图块" #: editor/plugins/tile_set_editor_plugin.cpp msgid "New Atlas" -msgstr "新建合集" +msgstr "新建图集" #: editor/plugins/tile_set_editor_plugin.cpp msgid "Next Coordinate" diff --git a/editor/translations/zh_HK.po b/editor/translations/zh_HK.po index 28a69ee289..69a8998437 100644 --- a/editor/translations/zh_HK.po +++ b/editor/translations/zh_HK.po @@ -5380,8 +5380,8 @@ msgstr "" #: editor/plugins/baked_lightmap_editor_plugin.cpp msgid "" -"No meshes to bake. Make sure they contain an UV2 channel and that the 'Bake " -"Light' flag is on." +"No meshes to bake. Make sure they contain an UV2 channel and that the 'Use " +"In Baked Light' and 'Generate Lightmap' flags are on." msgstr "" #: editor/plugins/baked_lightmap_editor_plugin.cpp diff --git a/editor/translations/zh_TW.po b/editor/translations/zh_TW.po index f65d628d63..2d04a07157 100644 --- a/editor/translations/zh_TW.po +++ b/editor/translations/zh_TW.po @@ -5118,9 +5118,10 @@ msgstr "" "請保存場景並重試。" #: editor/plugins/baked_lightmap_editor_plugin.cpp +#, fuzzy msgid "" -"No meshes to bake. Make sure they contain an UV2 channel and that the 'Bake " -"Light' flag is on." +"No meshes to bake. Make sure they contain an UV2 channel and that the 'Use " +"In Baked Light' and 'Generate Lightmap' flags are on." msgstr "" "無可烘焙之網格。請確保這些網格包含 UV2 通道並已開啟「Bake Light」旗標。" diff --git a/main/main.cpp b/main/main.cpp index 0651f4b93f..02c3dffd11 100644 --- a/main/main.cpp +++ b/main/main.cpp @@ -986,11 +986,13 @@ Error Main::setup(const char *execpath, int argc, char *argv[], bool p_second_ph } else if (I->get() == "-d" || I->get() == "--debug") { debug_uri = "local://"; OS::get_singleton()->_debug_stdout = true; -#if defined(DEBUG_ENABLED) && !defined(SERVER_ENABLED) +#if defined(DEBUG_ENABLED) } else if (I->get() == "--debug-collisions") { debug_collisions = true; } else if (I->get() == "--debug-navigation") { debug_navigation = true; + } else if (I->get() == "--debug-stringnames") { + StringName::set_debug_stringnames(true); #endif } else if (I->get() == "--remote-debug") { if (I->next()) { @@ -1078,7 +1080,7 @@ Error Main::setup(const char *execpath, int argc, char *argv[], bool p_second_ph #else const String error_msg = "Error: Couldn't load project data at path \"" + project_path + "\". Is the .pck file missing?\nIf you've renamed the executable, the associated .pck file should also be renamed to match the executable's name (without the extension).\n"; OS::get_singleton()->print("%s", error_msg.ascii().get_data()); - DisplayServer::get_singleton()->alert(error_msg); + OS::get_singleton()->alert(error_msg); goto error; #endif @@ -1087,6 +1089,8 @@ Error Main::setup(const char *execpath, int argc, char *argv[], bool p_second_ph // Initialize user data dir. OS::get_singleton()->ensure_user_data_dir(); + ResourceUID::get_singleton()->load_from_cache(); // load UUIDs from cache. + GLOBAL_DEF("memory/limits/multithreaded_server/rid_pool_prealloc", 60); ProjectSettings::get_singleton()->set_custom_property_info("memory/limits/multithreaded_server/rid_pool_prealloc", PropertyInfo(Variant::INT, @@ -2013,6 +2017,7 @@ bool Main::start() { // Let's throw an error gently. The code leading to this is pretty brittle so // this might end up triggered by valid usage, in which case we'll have to // fine-tune further. + OS::get_singleton()->alert("Couldn't detect whether to run the editor, the project manager or a specific project. Aborting."); ERR_FAIL_V_MSG(false, "Couldn't detect whether to run the editor, the project manager or a specific project. Aborting."); } #endif @@ -2042,9 +2047,8 @@ bool Main::start() { if (obj) { memdelete(obj); } - ERR_FAIL_V_MSG(false, - vformat("Can't load the script \"%s\" as it doesn't inherit from SceneTree or MainLoop.", - script)); + OS::get_singleton()->alert(vformat("Can't load the script \"%s\" as it doesn't inherit from SceneTree or MainLoop.", script)); + ERR_FAIL_V_MSG(false, vformat("Can't load the script \"%s\" as it doesn't inherit from SceneTree or MainLoop.", script)); } script_loop->set_initialize_script(script_res); @@ -2063,7 +2067,7 @@ bool Main::start() { if (obj) { memdelete(obj); } - DisplayServer::get_singleton()->alert("Error: Invalid MainLoop script base type: " + script_base); + OS::get_singleton()->alert("Error: Invalid MainLoop script base type: " + script_base); ERR_FAIL_V_MSG(false, vformat("The global class %s does not inherit from SceneTree or MainLoop.", main_loop_type)); } script_loop->set_initialize_script(script_res); @@ -2077,7 +2081,7 @@ bool Main::start() { if (!main_loop) { if (!ClassDB::class_exists(main_loop_type)) { - DisplayServer::get_singleton()->alert("Error: MainLoop type doesn't exist: " + main_loop_type); + OS::get_singleton()->alert("Error: MainLoop type doesn't exist: " + main_loop_type); return false; } else { Object *ml = ClassDB::instantiate(main_loop_type); @@ -2167,8 +2171,8 @@ bool Main::start() { } } - for (List<Node *>::Element *E = to_add.front(); E; E = E->next()) { - sml->get_root()->add_child(E->get()); + for (Node *E : to_add) { + sml->get_root()->add_child(E); } } } diff --git a/main/main_timer_sync.cpp b/main/main_timer_sync.cpp index 93448d0904..94e62bea97 100644 --- a/main/main_timer_sync.cpp +++ b/main/main_timer_sync.cpp @@ -30,7 +30,7 @@ #include "main_timer_sync.h" -void MainFrameTime::clamp_process_step(float min_process_step, float max_process_step) { +void MainFrameTime::clamp_process_step(double min_process_step, double max_process_step) { if (process_step < min_process_step) { process_step = min_process_step; } else if (process_step > max_process_step) { @@ -43,25 +43,25 @@ void MainFrameTime::clamp_process_step(float min_process_step, float max_process // returns the fraction of p_physics_step required for the timer to overshoot // before advance_core considers changing the physics_steps return from // the typical values as defined by typical_physics_steps -float MainTimerSync::get_physics_jitter_fix() { +double MainTimerSync::get_physics_jitter_fix() { return Engine::get_singleton()->get_physics_jitter_fix(); } // gets our best bet for the average number of physics steps per render frame // return value: number of frames back this data is consistent -int MainTimerSync::get_average_physics_steps(float &p_min, float &p_max) { +int MainTimerSync::get_average_physics_steps(double &p_min, double &p_max) { p_min = typical_physics_steps[0]; p_max = p_min + 1; for (int i = 1; i < CONTROL_STEPS; ++i) { - const float typical_lower = typical_physics_steps[i]; - const float current_min = typical_lower / (i + 1); + const double typical_lower = typical_physics_steps[i]; + const double current_min = typical_lower / (i + 1); if (current_min > p_max) { return i; // bail out of further restrictions would void the interval } else if (current_min > p_min) { p_min = current_min; } - const float current_max = (typical_lower + 1) / (i + 1); + const double current_max = (typical_lower + 1) / (i + 1); if (current_max < p_min) { return i; } else if (current_max < p_max) { @@ -73,7 +73,7 @@ int MainTimerSync::get_average_physics_steps(float &p_min, float &p_max) { } // advance physics clock by p_process_step, return appropriate number of steps to simulate -MainFrameTime MainTimerSync::advance_core(float p_physics_step, int p_physics_fps, float p_process_step) { +MainFrameTime MainTimerSync::advance_core(double p_physics_step, int p_physics_fps, double p_process_step) { MainFrameTime ret; ret.process_step = p_process_step; @@ -146,7 +146,7 @@ MainFrameTime MainTimerSync::advance_core(float p_physics_step, int p_physics_fp } // calls advance_core, keeps track of deficit it adds to animaption_step, make sure the deficit sum stays close to zero -MainFrameTime MainTimerSync::advance_checked(float p_physics_step, int p_physics_fps, float p_process_step) { +MainFrameTime MainTimerSync::advance_checked(double p_physics_step, int p_physics_fps, double p_process_step) { if (fixed_fps != -1) { p_process_step = 1.0 / fixed_fps; } @@ -163,7 +163,7 @@ MainFrameTime MainTimerSync::advance_checked(float p_physics_step, int p_physics // first, least important clamping: keep ret.process_step consistent with typical_physics_steps. // this smoothes out the process steps and culls small but quick variations. { - float min_average_physics_steps, max_average_physics_steps; + double min_average_physics_steps, max_average_physics_steps; int consistent_steps = get_average_physics_steps(min_average_physics_steps, max_average_physics_steps); if (consistent_steps > 3) { ret.clamp_process_step(min_average_physics_steps * p_physics_step, max_average_physics_steps * p_physics_step); @@ -171,7 +171,7 @@ MainFrameTime MainTimerSync::advance_checked(float p_physics_step, int p_physics } // second clamping: keep abs(time_deficit) < jitter_fix * frame_slise - float max_clock_deviation = get_physics_jitter_fix() * p_physics_step; + double max_clock_deviation = get_physics_jitter_fix() * p_physics_step; ret.clamp_process_step(p_process_step - max_clock_deviation, p_process_step + max_clock_deviation); // last clamping: make sure time_accum is between 0 and p_physics_step for consistency between physics and process @@ -191,7 +191,7 @@ MainFrameTime MainTimerSync::advance_checked(float p_physics_step, int p_physics } // determine wall clock step since last iteration -float MainTimerSync::get_cpu_process_step() { +double MainTimerSync::get_cpu_process_step() { uint64_t cpu_ticks_elapsed = current_cpu_ticks_usec - last_cpu_ticks_usec; last_cpu_ticks_usec = current_cpu_ticks_usec; @@ -220,8 +220,8 @@ void MainTimerSync::set_fixed_fps(int p_fixed_fps) { } // advance one physics frame, return timesteps to take -MainFrameTime MainTimerSync::advance(float p_physics_step, int p_physics_fps) { - float cpu_process_step = get_cpu_process_step(); +MainFrameTime MainTimerSync::advance(double p_physics_step, int p_physics_fps) { + double cpu_process_step = get_cpu_process_step(); return advance_checked(p_physics_step, p_physics_fps, cpu_process_step); } diff --git a/main/main_timer_sync.h b/main/main_timer_sync.h index 884978bf96..abdec18f6d 100644 --- a/main/main_timer_sync.h +++ b/main/main_timer_sync.h @@ -34,11 +34,11 @@ #include "core/config/engine.h" struct MainFrameTime { - float process_step; // delta time to advance during process() + double process_step; // delta time to advance during process() int physics_steps; // number of times to iterate the physics engine - float interpolation_fraction; // fraction through the current physics tick + double interpolation_fraction; // fraction through the current physics tick - void clamp_process_step(float min_process_step, float max_process_step); + void clamp_process_step(double min_process_step, double max_process_step); }; class MainTimerSync { @@ -47,10 +47,10 @@ class MainTimerSync { uint64_t current_cpu_ticks_usec = 0; // logical game time since last physics timestep - float time_accum = 0; + double time_accum = 0; // current difference between wall clock time and reported sum of process_steps - float time_deficit = 0; + double time_deficit = 0; // number of frames back for keeping accumulated physics steps roughly constant. // value of 12 chosen because that is what is required to make 144 Hz monitors @@ -70,20 +70,20 @@ protected: // returns the fraction of p_physics_step required for the timer to overshoot // before advance_core considers changing the physics_steps return from // the typical values as defined by typical_physics_steps - float get_physics_jitter_fix(); + double get_physics_jitter_fix(); // gets our best bet for the average number of physics steps per render frame // return value: number of frames back this data is consistent - int get_average_physics_steps(float &p_min, float &p_max); + int get_average_physics_steps(double &p_min, double &p_max); // advance physics clock by p_process_step, return appropriate number of steps to simulate - MainFrameTime advance_core(float p_physics_step, int p_physics_fps, float p_process_step); + MainFrameTime advance_core(double p_physics_step, int p_physics_fps, double p_process_step); // calls advance_core, keeps track of deficit it adds to animaption_step, make sure the deficit sum stays close to zero - MainFrameTime advance_checked(float p_physics_step, int p_physics_fps, float p_process_step); + MainFrameTime advance_checked(double p_physics_step, int p_physics_fps, double p_process_step); // determine wall clock step since last iteration - float get_cpu_process_step(); + double get_cpu_process_step(); public: MainTimerSync(); @@ -96,7 +96,7 @@ public: void set_fixed_fps(int p_fixed_fps); // advance one frame, return timesteps to take - MainFrameTime advance(float p_physics_step, int p_physics_fps); + MainFrameTime advance(double p_physics_step, int p_physics_fps); }; #endif // MAIN_TIMER_SYNC_H diff --git a/main/performance.cpp b/main/performance.cpp index 9f5be7b8c4..f9ff34c05d 100644 --- a/main/performance.cpp +++ b/main/performance.cpp @@ -77,7 +77,7 @@ void Performance::_bind_methods() { BIND_ENUM_CONSTANT(MONITOR_MAX); } -float Performance::_get_node_count() const { +int Performance::_get_node_count() const { MainLoop *ml = OS::get_singleton()->get_main_loop(); SceneTree *sml = Object::cast_to<SceneTree>(ml); if (!sml) { @@ -118,7 +118,7 @@ String Performance::get_monitor_name(Monitor p_monitor) const { return names[p_monitor]; } -float Performance::get_monitor(Monitor p_monitor) const { +double Performance::get_monitor(Monitor p_monitor) const { switch (p_monitor) { case TIME_FPS: return Engine::get_singleton()->get_frames_per_second(); @@ -207,11 +207,11 @@ Performance::MonitorType Performance::get_monitor_type(Monitor p_monitor) const return types[p_monitor]; } -void Performance::set_process_time(float p_pt) { +void Performance::set_process_time(double p_pt) { _process_time = p_pt; } -void Performance::set_physics_process_time(float p_pt) { +void Performance::set_physics_process_time(double p_pt) { _physics_process_time = p_pt; } diff --git a/main/performance.h b/main/performance.h index 174b3500d1..4653051ebb 100644 --- a/main/performance.h +++ b/main/performance.h @@ -43,10 +43,10 @@ class Performance : public Object { static Performance *singleton; static void _bind_methods(); - float _get_node_count() const; + int _get_node_count() const; - float _process_time; - float _physics_process_time; + double _process_time; + double _physics_process_time; class MonitorCall { Callable _callable; @@ -96,13 +96,13 @@ public: MONITOR_TYPE_TIME }; - float get_monitor(Monitor p_monitor) const; + double get_monitor(Monitor p_monitor) const; String get_monitor_name(Monitor p_monitor) const; MonitorType get_monitor_type(Monitor p_monitor) const; - void set_process_time(float p_pt); - void set_physics_process_time(float p_pt); + void set_process_time(double p_pt); + void set_physics_process_time(double p_pt); void add_custom_monitor(const StringName &p_id, const Callable &p_callable, const Vector<Variant> &p_args); void remove_custom_monitor(const StringName &p_id); diff --git a/methods.py b/methods.py index fd9978657e..12f9db37e7 100644 --- a/methods.py +++ b/methods.py @@ -61,10 +61,9 @@ def add_module_version_string(self, s): def update_version(module_version_string=""): - build_name = "custom_build" if os.getenv("BUILD_NAME") != None: - build_name = os.getenv("BUILD_NAME") + build_name = str(os.getenv("BUILD_NAME")) print("Using custom build name: " + build_name) import version @@ -79,7 +78,13 @@ def update_version(module_version_string=""): f.write("#define VERSION_MAJOR " + str(version.major) + "\n") f.write("#define VERSION_MINOR " + str(version.minor) + "\n") f.write("#define VERSION_PATCH " + str(version.patch) + "\n") - f.write('#define VERSION_STATUS "' + str(version.status) + '"\n') + # For dev snapshots (alpha, beta, RC, etc.) we do not commit status change to Git, + # so this define provides a way to override it without having to modify the source. + godot_status = str(version.status) + if os.getenv("GODOT_VERSION_STATUS") != None: + godot_status = str(os.getenv("GODOT_VERSION_STATUS")) + print("Using version status '%s', overriding the original '%s'.".format(godot_status, str(version.status))) + f.write('#define VERSION_STATUS "' + godot_status + '"\n') f.write('#define VERSION_BUILD "' + str(build_name) + '"\n') f.write('#define VERSION_MODULE_CONFIG "' + str(version.module_config) + module_version_string + '"\n') f.write("#define VERSION_YEAR " + str(version.year) + "\n") diff --git a/misc/dist/linux/org.godotengine.Godot.xml b/misc/dist/linux/org.godotengine.Godot.xml index e51179cd61..d4452018c4 100644 --- a/misc/dist/linux/org.godotengine.Godot.xml +++ b/misc/dist/linux/org.godotengine.Godot.xml @@ -2,20 +2,21 @@ <mime-info xmlns="http://www.freedesktop.org/standards/shared-mime-info"> <mime-type type="application/x-godot-project"> <comment>Godot Engine project</comment> - <icon name="x-godot-project" /> - <glob pattern="*.godot"/> + <sub-class-of type="text/plain"/> + <icon name="x-godot-project"/> + <glob pattern="project.godot"/> </mime-type> <mime-type type="application/x-godot-resource"> <comment>Godot Engine resource</comment> - <icon name="x-godot-resource" /> + <icon name="x-godot-resource"/> <glob pattern="*.res"/> <glob pattern="*.tres"/> </mime-type> <mime-type type="application/x-godot-scene"> <comment>Godot Engine scene</comment> - <icon name="x-godot-scene" /> + <icon name="x-godot-scene"/> <glob pattern="*.scn"/> <glob pattern="*.tscn"/> <glob pattern="*.escn"/> @@ -23,13 +24,15 @@ <mime-type type="application/x-godot-shader"> <comment>Godot Engine shader</comment> - <icon name="x-godot-shader" /> + <sub-class-of type="text/plain"/> + <icon name="x-godot-shader"/> <glob pattern="*.gdshader"/> </mime-type> <mime-type type="application/x-gdscript"> <comment>GDScript script</comment> - <icon name="x-gdscript" /> + <sub-class-of type="text/plain"/> + <icon name="x-gdscript"/> <glob pattern="*.gd"/> </mime-type> </mime-info> diff --git a/misc/dist/windows/modpath.pas b/misc/dist/windows/modpath.pas index c55ec60163..ab09f18254 100644 --- a/misc/dist/windows/modpath.pas +++ b/misc/dist/windows/modpath.pas @@ -144,7 +144,7 @@ begin end; end; -// Split a string into an array using passed delimeter +// Split a string into an array using passed delimiter. procedure MPExplode(var Dest: TArrayOfString; Text: String; Separator: String); var i: Integer; diff --git a/misc/scripts/check_ci_log.py b/misc/scripts/check_ci_log.py index 56c32b154c..2c75b83bd7 100755 --- a/misc/scripts/check_ci_log.py +++ b/misc/scripts/check_ci_log.py @@ -5,7 +5,7 @@ import sys if len(sys.argv) < 2: print("ERROR: You must run program with file name as argument.") - sys.exit(1) + sys.exit(50) fname = sys.argv[1] @@ -17,7 +17,7 @@ file_contents = fileread.read() if file_contents.find("ERROR: AddressSanitizer:") != -1: print("FATAL ERROR: An incorrectly used memory was found.") - sys.exit(1) + sys.exit(51) # There is also possible, that program crashed with or without backtrace. @@ -27,7 +27,7 @@ if ( or file_contents.find("Segmentation fault (core dumped)") != -1 ): print("FATAL ERROR: Godot has been crashed.") - sys.exit(1) + sys.exit(52) # Finding memory leaks in Godot is quite difficult, because we need to take into # account leaks also in external libraries. They are usually provided without @@ -38,7 +38,7 @@ if ( if file_contents.find("ERROR: LeakSanitizer:") != -1: if file_contents.find("#4 0x") != -1: print("ERROR: Memory leak was found") - sys.exit(1) + sys.exit(53) # It may happen that Godot detects leaking nodes/resources and removes them, so # this possibility should also be handled as a potential error, even if @@ -46,7 +46,7 @@ if file_contents.find("ERROR: LeakSanitizer:") != -1: if file_contents.find("ObjectDB instances leaked at exit") != -1: print("ERROR: Memory leak was found") - sys.exit(1) + sys.exit(54) # In test project may be put several assert functions which will control if # project is executed with right parameters etc. which normally will not stop @@ -54,7 +54,7 @@ if file_contents.find("ObjectDB instances leaked at exit") != -1: if file_contents.find("Assertion failed") != -1: print("ERROR: Assertion failed in project, check execution log for more info") - sys.exit(1) + sys.exit(55) # For now Godot leaks a lot of rendering stuff so for now we just show info # about it and this needs to be re-enabled after fixing this memory leaks. diff --git a/misc/scripts/make_tarball.sh b/misc/scripts/make_tarball.sh new file mode 100755 index 0000000000..9e02b80af1 --- /dev/null +++ b/misc/scripts/make_tarball.sh @@ -0,0 +1,66 @@ +#!/bin/sh + +if [ ! -e "version.py" ]; then + echo "This script should be ran from the root folder of the Godot repository." + exit 1 +fi + +while getopts "h?sv:g:" opt; do + case "$opt" in + h|\?) + echo "Usage: $0 [OPTIONS...]" + echo + echo " -s script friendly file name (godot.tar.gz)" + echo " -v godot version for file name (e.g. 4.0-stable)" + echo " -g git treeish to archive (e.g. master)" + echo + exit 1 + ;; + s) + script_friendly_name=1 + ;; + v) + godot_version=$OPTARG + ;; + g) + git_treeish=$OPTARG + ;; + esac +done + +if [ ! -z "$git_treeish" ]; then + HEAD=$(git rev-parse $git_treeish) +else + HEAD=$(git rev-parse HEAD) +fi + +if [ ! -z "$script_friendly_name" ]; then + NAME=godot +else + if [ ! -z "$godot_version" ]; then + NAME=godot-$godot_version + else + NAME=godot-$HEAD + fi +fi + +CURDIR=$(pwd) +TMPDIR=$(mktemp -d -t godot-XXXXXX) + +echo "Generating tarball for revision $HEAD with folder name '$NAME'." +echo +echo "The tarball will be written to the parent folder:" +echo " $(dirname $CURDIR)/$NAME.tar.gz" + +git archive $HEAD --prefix=$NAME/ -o $TMPDIR/$NAME.tar + +# Adding custom .git/HEAD to tarball so that we can generate VERSION_HASH. +cd $TMPDIR +mkdir -p $NAME/.git +echo $HEAD > $NAME/.git/HEAD +tar -uf $NAME.tar $NAME + +cd $CURDIR +gzip -c $TMPDIR/$NAME.tar > ../$NAME.tar.gz + +rm -rf $TMPDIR diff --git a/modules/bullet/godot_result_callbacks.cpp b/modules/bullet/godot_result_callbacks.cpp index e92b6c189c..399b102284 100644 --- a/modules/bullet/godot_result_callbacks.cpp +++ b/modules/bullet/godot_result_callbacks.cpp @@ -47,17 +47,12 @@ bool godotContactAddedCallback(btManifoldPoint &cp, const btCollisionObjectWrapp return true; } -bool GodotFilterCallback::test_collision_filters(uint32_t body0_collision_layer, uint32_t body0_collision_mask, uint32_t body1_collision_layer, uint32_t body1_collision_mask) { - return body0_collision_layer & body1_collision_mask || body1_collision_layer & body0_collision_mask; -} - bool GodotFilterCallback::needBroadphaseCollision(btBroadphaseProxy *proxy0, btBroadphaseProxy *proxy1) const { - return GodotFilterCallback::test_collision_filters(proxy0->m_collisionFilterGroup, proxy0->m_collisionFilterMask, proxy1->m_collisionFilterGroup, proxy1->m_collisionFilterMask); + return (proxy0->m_collisionFilterGroup & proxy1->m_collisionFilterMask) || (proxy1->m_collisionFilterGroup & proxy0->m_collisionFilterMask); } bool GodotClosestRayResultCallback::needsCollision(btBroadphaseProxy *proxy0) const { - const bool needs = GodotFilterCallback::test_collision_filters(m_collisionFilterGroup, m_collisionFilterMask, proxy0->m_collisionFilterGroup, proxy0->m_collisionFilterMask); - if (needs) { + if (proxy0->m_collisionFilterGroup & m_collisionFilterMask) { btCollisionObject *btObj = static_cast<btCollisionObject *>(proxy0->m_clientObject); CollisionObjectBullet *gObj = static_cast<CollisionObjectBullet *>(btObj->getUserPointer()); @@ -90,8 +85,7 @@ bool GodotAllConvexResultCallback::needsCollision(btBroadphaseProxy *proxy0) con return false; } - const bool needs = GodotFilterCallback::test_collision_filters(m_collisionFilterGroup, m_collisionFilterMask, proxy0->m_collisionFilterGroup, proxy0->m_collisionFilterMask); - if (needs) { + if (proxy0->m_collisionFilterGroup & m_collisionFilterMask) { btCollisionObject *btObj = static_cast<btCollisionObject *>(proxy0->m_clientObject); CollisionObjectBullet *gObj = static_cast<CollisionObjectBullet *>(btObj->getUserPointer()); if (m_exclude->has(gObj->get_self())) { @@ -123,8 +117,7 @@ btScalar GodotAllConvexResultCallback::addSingleResult(btCollisionWorld::LocalCo } bool GodotKinClosestConvexResultCallback::needsCollision(btBroadphaseProxy *proxy0) const { - const bool needs = GodotFilterCallback::test_collision_filters(m_collisionFilterGroup, m_collisionFilterMask, proxy0->m_collisionFilterGroup, proxy0->m_collisionFilterMask); - if (needs) { + if (proxy0->m_collisionFilterGroup & m_collisionFilterMask) { btCollisionObject *btObj = static_cast<btCollisionObject *>(proxy0->m_clientObject); CollisionObjectBullet *gObj = static_cast<CollisionObjectBullet *>(btObj->getUserPointer()); if (gObj == m_self_object) { @@ -150,8 +143,7 @@ bool GodotKinClosestConvexResultCallback::needsCollision(btBroadphaseProxy *prox } bool GodotClosestConvexResultCallback::needsCollision(btBroadphaseProxy *proxy0) const { - const bool needs = GodotFilterCallback::test_collision_filters(m_collisionFilterGroup, m_collisionFilterMask, proxy0->m_collisionFilterGroup, proxy0->m_collisionFilterMask); - if (needs) { + if (proxy0->m_collisionFilterGroup & m_collisionFilterMask) { btCollisionObject *btObj = static_cast<btCollisionObject *>(proxy0->m_clientObject); CollisionObjectBullet *gObj = static_cast<CollisionObjectBullet *>(btObj->getUserPointer()); @@ -188,8 +180,7 @@ bool GodotAllContactResultCallback::needsCollision(btBroadphaseProxy *proxy0) co return false; } - const bool needs = GodotFilterCallback::test_collision_filters(m_collisionFilterGroup, m_collisionFilterMask, proxy0->m_collisionFilterGroup, proxy0->m_collisionFilterMask); - if (needs) { + if (proxy0->m_collisionFilterGroup & m_collisionFilterMask) { btCollisionObject *btObj = static_cast<btCollisionObject *>(proxy0->m_clientObject); CollisionObjectBullet *gObj = static_cast<CollisionObjectBullet *>(btObj->getUserPointer()); @@ -244,8 +235,7 @@ bool GodotContactPairContactResultCallback::needsCollision(btBroadphaseProxy *pr return false; } - const bool needs = GodotFilterCallback::test_collision_filters(m_collisionFilterGroup, m_collisionFilterMask, proxy0->m_collisionFilterGroup, proxy0->m_collisionFilterMask); - if (needs) { + if (proxy0->m_collisionFilterGroup & m_collisionFilterMask) { btCollisionObject *btObj = static_cast<btCollisionObject *>(proxy0->m_clientObject); CollisionObjectBullet *gObj = static_cast<CollisionObjectBullet *>(btObj->getUserPointer()); @@ -287,8 +277,7 @@ btScalar GodotContactPairContactResultCallback::addSingleResult(btManifoldPoint } bool GodotRestInfoContactResultCallback::needsCollision(btBroadphaseProxy *proxy0) const { - const bool needs = GodotFilterCallback::test_collision_filters(m_collisionFilterGroup, m_collisionFilterMask, proxy0->m_collisionFilterGroup, proxy0->m_collisionFilterMask); - if (needs) { + if (proxy0->m_collisionFilterGroup & m_collisionFilterMask) { btCollisionObject *btObj = static_cast<btCollisionObject *>(proxy0->m_clientObject); CollisionObjectBullet *gObj = static_cast<CollisionObjectBullet *>(btObj->getUserPointer()); diff --git a/modules/bullet/godot_result_callbacks.h b/modules/bullet/godot_result_callbacks.h index f92665f3e4..9216322108 100644 --- a/modules/bullet/godot_result_callbacks.h +++ b/modules/bullet/godot_result_callbacks.h @@ -47,8 +47,6 @@ bool godotContactAddedCallback(btManifoldPoint &cp, const btCollisionObjectWrapp /// This class is required to implement custom collision behaviour in the broadphase struct GodotFilterCallback : public btOverlapFilterCallback { - static bool test_collision_filters(uint32_t body0_collision_layer, uint32_t body0_collision_mask, uint32_t body1_collision_layer, uint32_t body1_collision_mask); - // return true when pairs need collision virtual bool needBroadphaseCollision(btBroadphaseProxy *proxy0, btBroadphaseProxy *proxy1) const; }; diff --git a/modules/bullet/space_bullet.cpp b/modules/bullet/space_bullet.cpp index 33dd9ef56d..583900e6bc 100644 --- a/modules/bullet/space_bullet.cpp +++ b/modules/bullet/space_bullet.cpp @@ -1093,7 +1093,6 @@ private: const btCollisionObject *self_collision_object; uint32_t collision_layer = 0; - uint32_t collision_mask = 0; struct CompoundLeafCallback : btDbvt::ICollide { private: @@ -1123,10 +1122,9 @@ public: Vector<BroadphaseResult> results; public: - RecoverPenetrationBroadPhaseCallback(const btCollisionObject *p_self_collision_object, uint32_t p_collision_layer, uint32_t p_collision_mask, btVector3 p_aabb_min, btVector3 p_aabb_max) : + RecoverPenetrationBroadPhaseCallback(const btCollisionObject *p_self_collision_object, uint32_t p_collision_layer, btVector3 p_aabb_min, btVector3 p_aabb_max) : self_collision_object(p_self_collision_object), - collision_layer(p_collision_layer), - collision_mask(p_collision_mask) { + collision_layer(p_collision_layer) { bounds = btDbvtVolume::FromMM(p_aabb_min, p_aabb_max); } @@ -1135,7 +1133,7 @@ public: virtual bool process(const btBroadphaseProxy *proxy) { btCollisionObject *co = static_cast<btCollisionObject *>(proxy->m_clientObject); if (co->getInternalType() <= btCollisionObject::CO_RIGID_BODY) { - if (self_collision_object != proxy->m_clientObject && GodotFilterCallback::test_collision_filters(collision_layer, collision_mask, proxy->m_collisionFilterGroup, proxy->m_collisionFilterMask)) { + if (self_collision_object != proxy->m_clientObject && (proxy->collision_layer & m_collisionFilterMask)) { if (co->getCollisionShape()->isCompound()) { const btCompoundShape *cs = static_cast<btCompoundShape *>(co->getCollisionShape()); @@ -1218,7 +1216,7 @@ bool SpaceBullet::recover_from_penetration(RigidBodyBullet *p_body, const btTran } // Perform broadphase test - RecoverPenetrationBroadPhaseCallback recover_broad_result(p_body->get_bt_collision_object(), p_body->get_collision_layer(), p_body->get_collision_mask(), aabb_min, aabb_max); + RecoverPenetrationBroadPhaseCallback recover_broad_result(p_body->get_bt_collision_object(), p_body->get_collision_layer(), aabb_min, aabb_max); dynamicsWorld->getBroadphase()->aabbTest(aabb_min, aabb_max, recover_broad_result); bool penetration = false; @@ -1409,7 +1407,7 @@ int SpaceBullet::recover_from_penetration_ray(RigidBodyBullet *p_body, const btT } // Perform broadphase test - RecoverPenetrationBroadPhaseCallback recover_broad_result(p_body->get_bt_collision_object(), p_body->get_collision_layer(), p_body->get_collision_mask(), aabb_min, aabb_max); + RecoverPenetrationBroadPhaseCallback recover_broad_result(p_body->get_bt_collision_object(), p_body->get_collision_layer(), aabb_min, aabb_max); dynamicsWorld->getBroadphase()->aabbTest(aabb_min, aabb_max, recover_broad_result); int ray_count = 0; diff --git a/modules/camera/camera_osx.h b/modules/camera/camera_osx.h index 964b7c1edc..84274f0bf6 100644 --- a/modules/camera/camera_osx.h +++ b/modules/camera/camera_osx.h @@ -32,7 +32,7 @@ #define CAMERAOSX_H ///@TODO this is a near duplicate of CameraIOS, we should find a way to combine those to minimize code duplication!!!! -// If you fix something here, make sure you fix it there as wel! +// If you fix something here, make sure you fix it there as well! #include "servers/camera_server.h" diff --git a/modules/camera/camera_osx.mm b/modules/camera/camera_osx.mm index 6bc56add20..4875eb578a 100644 --- a/modules/camera/camera_osx.mm +++ b/modules/camera/camera_osx.mm @@ -29,7 +29,7 @@ /*************************************************************************/ ///@TODO this is a near duplicate of CameraIOS, we should find a way to combine those to minimize code duplication!!!! -// If you fix something here, make sure you fix it there as wel! +// If you fix something here, make sure you fix it there as well! #include "camera_osx.h" #include "servers/camera/camera_feed.h" diff --git a/modules/csg/csg.cpp b/modules/csg/csg.cpp index 5a37486568..cb82b65307 100644 --- a/modules/csg/csg.cpp +++ b/modules/csg/csg.cpp @@ -42,7 +42,7 @@ inline static bool is_snapable(const Vector3 &p_point1, const Vector3 &p_point2, inline static Vector2 interpolate_segment_uv(const Vector2 p_segement_points[2], const Vector2 p_uvs[2], const Vector2 &p_interpolation_point) { float segment_length = (p_segement_points[1] - p_segement_points[0]).length(); - if (segment_length < CMP_EPSILON) { + if (p_segement_points[0].is_equal_approx(p_segement_points[1])) { return p_uvs[0]; } @@ -53,13 +53,13 @@ inline static Vector2 interpolate_segment_uv(const Vector2 p_segement_points[2], } inline static Vector2 interpolate_triangle_uv(const Vector2 p_vertices[3], const Vector2 p_uvs[3], const Vector2 &p_interpolation_point) { - if (p_interpolation_point.distance_squared_to(p_vertices[0]) < CMP_EPSILON2) { + if (p_interpolation_point.is_equal_approx(p_vertices[0])) { return p_uvs[0]; } - if (p_interpolation_point.distance_squared_to(p_vertices[1]) < CMP_EPSILON2) { + if (p_interpolation_point.is_equal_approx(p_vertices[1])) { return p_uvs[1]; } - if (p_interpolation_point.distance_squared_to(p_vertices[2]) < CMP_EPSILON2) { + if (p_interpolation_point.is_equal_approx(p_vertices[2])) { return p_uvs[2]; } @@ -530,8 +530,8 @@ void CSGBrushOperation::MeshMerge::_add_distance(List<real_t> &r_intersectionsA, List<real_t> &intersections = p_from_B ? r_intersectionsB : r_intersectionsA; // Check if distance exists. - for (const List<real_t>::Element *E = intersections.front(); E; E = E->next()) { - if (Math::is_equal_approx(**E, p_distance)) { + for (const real_t E : intersections) { + if (Math::is_equal_approx(E, p_distance)) { return; } } @@ -589,7 +589,7 @@ bool CSGBrushOperation::MeshMerge::_bvh_inside(FaceBVH *facebvhptr, int p_max_de Vector3 intersection_point; // Check if faces are co-planar. - if ((current_normal - face_normal).length_squared() < CMP_EPSILON2 && + if (current_normal.is_equal_approx(face_normal) && is_point_in_triangle(face_center, current_points)) { // Only add an intersection if not a B face. if (!face.from_b) { diff --git a/modules/csg/csg_gizmos.cpp b/modules/csg/csg_gizmos.cpp index 37a7d96de5..42f8b9f163 100644 --- a/modules/csg/csg_gizmos.cpp +++ b/modules/csg/csg_gizmos.cpp @@ -29,6 +29,8 @@ /*************************************************************************/ #include "csg_gizmos.h" +#include "editor/plugins/node_3d_editor_plugin.h" +#include "scene/3d/camera_3d.h" /////////// @@ -48,7 +50,7 @@ CSGShape3DGizmoPlugin::CSGShape3DGizmoPlugin() { create_handle_material("handles"); } -String CSGShape3DGizmoPlugin::get_handle_name(const EditorNode3DGizmo *p_gizmo, int p_idx) const { +String CSGShape3DGizmoPlugin::get_handle_name(const EditorNode3DGizmo *p_gizmo, int p_id) const { CSGShape3D *cs = Object::cast_to<CSGShape3D>(p_gizmo->get_spatial_node()); if (Object::cast_to<CSGSphere3D>(cs)) { @@ -60,17 +62,17 @@ String CSGShape3DGizmoPlugin::get_handle_name(const EditorNode3DGizmo *p_gizmo, } if (Object::cast_to<CSGCylinder3D>(cs)) { - return p_idx == 0 ? "Radius" : "Height"; + return p_id == 0 ? "Radius" : "Height"; } if (Object::cast_to<CSGTorus3D>(cs)) { - return p_idx == 0 ? "InnerRadius" : "OuterRadius"; + return p_id == 0 ? "InnerRadius" : "OuterRadius"; } return ""; } -Variant CSGShape3DGizmoPlugin::get_handle_value(EditorNode3DGizmo *p_gizmo, int p_idx) const { +Variant CSGShape3DGizmoPlugin::get_handle_value(const EditorNode3DGizmo *p_gizmo, int p_id) const { CSGShape3D *cs = Object::cast_to<CSGShape3D>(p_gizmo->get_spatial_node()); if (Object::cast_to<CSGSphere3D>(cs)) { @@ -85,18 +87,18 @@ Variant CSGShape3DGizmoPlugin::get_handle_value(EditorNode3DGizmo *p_gizmo, int if (Object::cast_to<CSGCylinder3D>(cs)) { CSGCylinder3D *s = Object::cast_to<CSGCylinder3D>(cs); - return p_idx == 0 ? s->get_radius() : s->get_height(); + return p_id == 0 ? s->get_radius() : s->get_height(); } if (Object::cast_to<CSGTorus3D>(cs)) { CSGTorus3D *s = Object::cast_to<CSGTorus3D>(cs); - return p_idx == 0 ? s->get_inner_radius() : s->get_outer_radius(); + return p_id == 0 ? s->get_inner_radius() : s->get_outer_radius(); } return Variant(); } -void CSGShape3DGizmoPlugin::set_handle(EditorNode3DGizmo *p_gizmo, int p_idx, Camera3D *p_camera, const Point2 &p_point) { +void CSGShape3DGizmoPlugin::set_handle(const EditorNode3DGizmo *p_gizmo, int p_id, Camera3D *p_camera, const Point2 &p_point) const { CSGShape3D *cs = Object::cast_to<CSGShape3D>(p_gizmo->get_spatial_node()); Transform3D gt = cs->get_global_transform(); @@ -129,10 +131,16 @@ void CSGShape3DGizmoPlugin::set_handle(EditorNode3DGizmo *p_gizmo, int p_idx, Ca CSGBox3D *s = Object::cast_to<CSGBox3D>(cs); Vector3 axis; - axis[p_idx] = 1.0; + axis[p_id] = 1.0; Vector3 ra, rb; Geometry3D::get_closest_points_between_segments(Vector3(), axis * 4096, sg[0], sg[1], ra, rb); - float d = ra[p_idx]; + float d = ra[p_id]; + + if (Math::is_nan(d)) { + // The handle is perpendicular to the camera. + return; + } + if (Node3DEditor::get_singleton()->is_snap_enabled()) { d = Math::snapped(d, Node3DEditor::get_singleton()->get_translate_snap()); } @@ -142,7 +150,7 @@ void CSGShape3DGizmoPlugin::set_handle(EditorNode3DGizmo *p_gizmo, int p_idx, Ca } Vector3 h = s->get_size(); - h[p_idx] = d * 2; + h[p_id] = d * 2; s->set_size(h); } @@ -150,7 +158,7 @@ void CSGShape3DGizmoPlugin::set_handle(EditorNode3DGizmo *p_gizmo, int p_idx, Ca CSGCylinder3D *s = Object::cast_to<CSGCylinder3D>(cs); Vector3 axis; - axis[p_idx == 0 ? 0 : 1] = 1.0; + axis[p_id == 0 ? 0 : 1] = 1.0; Vector3 ra, rb; Geometry3D::get_closest_points_between_segments(Vector3(), axis * 4096, sg[0], sg[1], ra, rb); float d = axis.dot(ra); @@ -162,9 +170,9 @@ void CSGShape3DGizmoPlugin::set_handle(EditorNode3DGizmo *p_gizmo, int p_idx, Ca d = 0.001; } - if (p_idx == 0) { + if (p_id == 0) { s->set_radius(d); - } else if (p_idx == 1) { + } else if (p_id == 1) { s->set_height(d * 2.0); } } @@ -185,15 +193,15 @@ void CSGShape3DGizmoPlugin::set_handle(EditorNode3DGizmo *p_gizmo, int p_idx, Ca d = 0.001; } - if (p_idx == 0) { + if (p_id == 0) { s->set_inner_radius(d); - } else if (p_idx == 1) { + } else if (p_id == 1) { s->set_outer_radius(d); } } } -void CSGShape3DGizmoPlugin::commit_handle(EditorNode3DGizmo *p_gizmo, int p_idx, const Variant &p_restore, bool p_cancel) { +void CSGShape3DGizmoPlugin::commit_handle(const EditorNode3DGizmo *p_gizmo, int p_id, const Variant &p_restore, bool p_cancel) const { CSGShape3D *cs = Object::cast_to<CSGShape3D>(p_gizmo->get_spatial_node()); if (Object::cast_to<CSGSphere3D>(cs)) { @@ -227,7 +235,7 @@ void CSGShape3DGizmoPlugin::commit_handle(EditorNode3DGizmo *p_gizmo, int p_idx, if (Object::cast_to<CSGCylinder3D>(cs)) { CSGCylinder3D *s = Object::cast_to<CSGCylinder3D>(cs); if (p_cancel) { - if (p_idx == 0) { + if (p_id == 0) { s->set_radius(p_restore); } else { s->set_height(p_restore); @@ -236,7 +244,7 @@ void CSGShape3DGizmoPlugin::commit_handle(EditorNode3DGizmo *p_gizmo, int p_idx, } UndoRedo *ur = Node3DEditor::get_singleton()->get_undo_redo(); - if (p_idx == 0) { + if (p_id == 0) { ur->create_action(TTR("Change Cylinder Radius")); ur->add_do_method(s, "set_radius", s->get_radius()); ur->add_undo_method(s, "set_radius", p_restore); @@ -252,7 +260,7 @@ void CSGShape3DGizmoPlugin::commit_handle(EditorNode3DGizmo *p_gizmo, int p_idx, if (Object::cast_to<CSGTorus3D>(cs)) { CSGTorus3D *s = Object::cast_to<CSGTorus3D>(cs); if (p_cancel) { - if (p_idx == 0) { + if (p_id == 0) { s->set_inner_radius(p_restore); } else { s->set_outer_radius(p_restore); @@ -261,7 +269,7 @@ void CSGShape3DGizmoPlugin::commit_handle(EditorNode3DGizmo *p_gizmo, int p_idx, } UndoRedo *ur = Node3DEditor::get_singleton()->get_undo_redo(); - if (p_idx == 0) { + if (p_id == 0) { ur->create_action(TTR("Change Torus Inner Radius")); ur->add_do_method(s, "set_inner_radius", s->get_inner_radius()); ur->add_undo_method(s, "set_inner_radius", p_restore); @@ -356,7 +364,7 @@ void CSGShape3DGizmoPlugin::redraw(EditorNode3DGizmo *p_gizmo) { break; } - p_gizmo->add_mesh(mesh, false, Ref<SkinReference>(), solid_material); + p_gizmo->add_mesh(mesh, solid_material); } if (Object::cast_to<CSGSphere3D>(cs)) { diff --git a/modules/csg/csg_gizmos.h b/modules/csg/csg_gizmos.h index 8f7da35de3..847313c0b4 100644 --- a/modules/csg/csg_gizmos.h +++ b/modules/csg/csg_gizmos.h @@ -33,22 +33,22 @@ #include "csg_shape.h" #include "editor/editor_plugin.h" -#include "editor/node_3d_editor_gizmos.h" +#include "editor/plugins/node_3d_editor_gizmos.h" class CSGShape3DGizmoPlugin : public EditorNode3DGizmoPlugin { GDCLASS(CSGShape3DGizmoPlugin, EditorNode3DGizmoPlugin); public: - bool has_gizmo(Node3D *p_spatial) override; - String get_gizmo_name() const override; - int get_priority() const override; - bool is_selectable_when_hidden() const override; - void redraw(EditorNode3DGizmo *p_gizmo) override; - - String get_handle_name(const EditorNode3DGizmo *p_gizmo, int p_idx) const override; - Variant get_handle_value(EditorNode3DGizmo *p_gizmo, int p_idx) const override; - void set_handle(EditorNode3DGizmo *p_gizmo, int p_idx, Camera3D *p_camera, const Point2 &p_point) override; - void commit_handle(EditorNode3DGizmo *p_gizmo, int p_idx, const Variant &p_restore, bool p_cancel) override; + virtual bool has_gizmo(Node3D *p_spatial) override; + virtual String get_gizmo_name() const override; + virtual int get_priority() const override; + virtual bool is_selectable_when_hidden() const override; + virtual void redraw(EditorNode3DGizmo *p_gizmo) override; + + virtual String get_handle_name(const EditorNode3DGizmo *p_gizmo, int p_id) const override; + virtual Variant get_handle_value(const EditorNode3DGizmo *p_gizmo, int p_id) const override; + virtual void set_handle(const EditorNode3DGizmo *p_gizmo, int p_id, Camera3D *p_camera, const Point2 &p_point) const override; + virtual void commit_handle(const EditorNode3DGizmo *p_gizmo, int p_id, const Variant &p_restore, bool p_cancel) const override; CSGShape3DGizmoPlugin(); }; diff --git a/modules/csg/csg_shape.cpp b/modules/csg/csg_shape.cpp index fd8b213293..b47fa35f1a 100644 --- a/modules/csg/csg_shape.cpp +++ b/modules/csg/csg_shape.cpp @@ -140,7 +140,7 @@ void CSGShape3D::_make_dirty() { if (parent) { parent->_make_dirty(); } else if (!dirty) { - call_deferred("_update_shape"); + call_deferred(SNAME("_update_shape")); } dirty = true; @@ -548,7 +548,7 @@ void CSGShape3D::_notification(int p_what) { void CSGShape3D::set_operation(Operation p_operation) { operation = p_operation; _make_dirty(); - update_gizmo(); + update_gizmos(); } CSGShape3D::Operation CSGShape3D::get_operation() const { @@ -778,7 +778,7 @@ CSGBrush *CSGMesh3D::_build_brush() { } } - bool flat = normal[0].distance_to(normal[1]) < CMP_EPSILON && normal[0].distance_to(normal[2]) < CMP_EPSILON; + bool flat = normal[0].is_equal_approx(normal[1]) && normal[0].is_equal_approx(normal[2]); vw[as + j + 0] = vertex[0]; vw[as + j + 1] = vertex[1]; @@ -820,7 +820,7 @@ CSGBrush *CSGMesh3D::_build_brush() { } } - bool flat = normal[0].distance_to(normal[1]) < CMP_EPSILON && normal[0].distance_to(normal[2]) < CMP_EPSILON; + bool flat = normal[0].is_equal_approx(normal[1]) && normal[0].is_equal_approx(normal[2]); vw[as + j + 0] = vertex[0]; vw[as + j + 1] = vertex[1]; @@ -845,7 +845,7 @@ CSGBrush *CSGMesh3D::_build_brush() { void CSGMesh3D::_mesh_changed() { _make_dirty(); - update_gizmo(); + update_gizmos(); } void CSGMesh3D::set_material(const Ref<Material> &p_material) { @@ -923,36 +923,40 @@ CSGBrush *CSGSphere3D::_build_brush() { Ref<Material> *materialsw = materials.ptrw(); bool *invertw = invert.ptrw(); - const double lat_step = 1.0 / rings; - const double lon_step = 1.0 / radial_segments; + // We want to follow an order that's convenient for UVs. + // For latitude step we start at the top and move down like in an image. + const double latitude_step = -Math_PI / rings; + const double longitude_step = Math_TAU / radial_segments; int face = 0; - for (int i = 1; i <= rings; i++) { - double lat0 = Math_PI * (0.5 - (i - 1) * lat_step); - double c0 = Math::cos(lat0); - double s0 = Math::sin(lat0); - double v0 = double(i - 1) / rings; - - double lat1 = Math_PI * (0.5 - i * lat_step); - double c1 = Math::cos(lat1); - double s1 = Math::sin(lat1); - double v1 = double(i) / rings; - - for (int j = 1; j <= radial_segments; j++) { - double lng0 = Math_TAU * (0.5 - (j - 1) * lon_step); - double x0 = Math::cos(lng0); - double y0 = Math::sin(lng0); - double u0 = double(j - 1) / radial_segments; - - double lng1 = Math_TAU * (0.5 - j * lon_step); - double x1 = Math::cos(lng1); - double y1 = Math::sin(lng1); - double u1 = double(j) / radial_segments; + for (int i = 0; i < rings; i++) { + double latitude0 = latitude_step * i + Math_TAU / 4; + double cos0 = Math::cos(latitude0); + double sin0 = Math::sin(latitude0); + double v0 = double(i) / rings; + + double latitude1 = latitude_step * (i + 1) + Math_TAU / 4; + double cos1 = Math::cos(latitude1); + double sin1 = Math::sin(latitude1); + double v1 = double(i + 1) / rings; + + for (int j = 0; j < radial_segments; j++) { + double longitude0 = longitude_step * j; + // We give sin to X and cos to Z on purpose. + // This allows UVs to be CCW on +X so it maps to images well. + double x0 = Math::sin(longitude0); + double z0 = Math::cos(longitude0); + double u0 = double(j) / radial_segments; + + double longitude1 = longitude_step * (j + 1); + double x1 = Math::sin(longitude1); + double z1 = Math::cos(longitude1); + double u1 = double(j + 1) / radial_segments; Vector3 v[4] = { - Vector3(x0 * c0, s0, y0 * c0) * radius, - Vector3(x1 * c0, s0, y1 * c0) * radius, - Vector3(x1 * c1, s1, y1 * c1) * radius, - Vector3(x0 * c1, s1, y0 * c1) * radius, + Vector3(x0 * cos0, sin0, z0 * cos0) * radius, + Vector3(x1 * cos0, sin0, z1 * cos0) * radius, + Vector3(x1 * cos1, sin1, z1 * cos1) * radius, + Vector3(x0 * cos1, sin1, z0 * cos1) * radius, }; Vector2 u[4] = { @@ -962,8 +966,8 @@ CSGBrush *CSGSphere3D::_build_brush() { Vector2(u0, v1), }; - if (i < rings) { - //face 1 + // Draw the first face, but skip this at the north pole (i == 0). + if (i > 0) { facesw[face * 3 + 0] = v[0]; facesw[face * 3 + 1] = v[1]; facesw[face * 3 + 2] = v[2]; @@ -979,8 +983,8 @@ CSGBrush *CSGSphere3D::_build_brush() { face++; } - if (i > 1) { - //face 2 + // Draw the second face, but skip this at the south pole (i == rings - 1). + if (i < rings - 1) { facesw[face * 3 + 0] = v[2]; facesw[face * 3 + 1] = v[3]; facesw[face * 3 + 2] = v[0]; @@ -1034,7 +1038,7 @@ void CSGSphere3D::set_radius(const float p_radius) { ERR_FAIL_COND(p_radius <= 0); radius = p_radius; _make_dirty(); - update_gizmo(); + update_gizmos(); } float CSGSphere3D::get_radius() const { @@ -1044,7 +1048,7 @@ float CSGSphere3D::get_radius() const { void CSGSphere3D::set_radial_segments(const int p_radial_segments) { radial_segments = p_radial_segments > 4 ? p_radial_segments : 4; _make_dirty(); - update_gizmo(); + update_gizmos(); } int CSGSphere3D::get_radial_segments() const { @@ -1054,7 +1058,7 @@ int CSGSphere3D::get_radial_segments() const { void CSGSphere3D::set_rings(const int p_rings) { rings = p_rings > 1 ? p_rings : 1; _make_dirty(); - update_gizmo(); + update_gizmos(); } int CSGSphere3D::get_rings() const { @@ -1203,7 +1207,7 @@ void CSGBox3D::_bind_methods() { void CSGBox3D::set_size(const Vector3 &p_size) { size = p_size; _make_dirty(); - update_gizmo(); + update_gizmos(); } Vector3 CSGBox3D::get_size() const { @@ -1213,7 +1217,7 @@ Vector3 CSGBox3D::get_size() const { void CSGBox3D::set_material(const Ref<Material> &p_material) { material = p_material; _make_dirty(); - update_gizmo(); + update_gizmos(); } Ref<Material> CSGBox3D::get_material() const { @@ -1384,7 +1388,7 @@ void CSGCylinder3D::_bind_methods() { void CSGCylinder3D::set_radius(const float p_radius) { radius = p_radius; _make_dirty(); - update_gizmo(); + update_gizmos(); } float CSGCylinder3D::get_radius() const { @@ -1394,7 +1398,7 @@ float CSGCylinder3D::get_radius() const { void CSGCylinder3D::set_height(const float p_height) { height = p_height; _make_dirty(); - update_gizmo(); + update_gizmos(); } float CSGCylinder3D::get_height() const { @@ -1405,7 +1409,7 @@ void CSGCylinder3D::set_sides(const int p_sides) { ERR_FAIL_COND(p_sides < 3); sides = p_sides; _make_dirty(); - update_gizmo(); + update_gizmos(); } int CSGCylinder3D::get_sides() const { @@ -1415,7 +1419,7 @@ int CSGCylinder3D::get_sides() const { void CSGCylinder3D::set_cone(const bool p_cone) { cone = p_cone; _make_dirty(); - update_gizmo(); + update_gizmos(); } bool CSGCylinder3D::is_cone() const { @@ -1603,7 +1607,7 @@ void CSGTorus3D::_bind_methods() { void CSGTorus3D::set_inner_radius(const float p_inner_radius) { inner_radius = p_inner_radius; _make_dirty(); - update_gizmo(); + update_gizmos(); } float CSGTorus3D::get_inner_radius() const { @@ -1613,7 +1617,7 @@ float CSGTorus3D::get_inner_radius() const { void CSGTorus3D::set_outer_radius(const float p_outer_radius) { outer_radius = p_outer_radius; _make_dirty(); - update_gizmo(); + update_gizmos(); } float CSGTorus3D::get_outer_radius() const { @@ -1624,7 +1628,7 @@ void CSGTorus3D::set_sides(const int p_sides) { ERR_FAIL_COND(p_sides < 3); sides = p_sides; _make_dirty(); - update_gizmo(); + update_gizmos(); } int CSGTorus3D::get_sides() const { @@ -1635,7 +1639,7 @@ void CSGTorus3D::set_ring_sides(const int p_ring_sides) { ERR_FAIL_COND(p_ring_sides < 3); ring_sides = p_ring_sides; _make_dirty(); - update_gizmo(); + update_gizmos(); } int CSGTorus3D::get_ring_sides() const { @@ -2172,7 +2176,7 @@ void CSGPolygon3D::_validate_property(PropertyInfo &property) const { void CSGPolygon3D::_path_changed() { _make_dirty(); - update_gizmo(); + update_gizmos(); } void CSGPolygon3D::_path_exited() { @@ -2248,7 +2252,7 @@ void CSGPolygon3D::_bind_methods() { void CSGPolygon3D::set_polygon(const Vector<Vector2> &p_polygon) { polygon = p_polygon; _make_dirty(); - update_gizmo(); + update_gizmos(); } Vector<Vector2> CSGPolygon3D::get_polygon() const { @@ -2258,7 +2262,7 @@ Vector<Vector2> CSGPolygon3D::get_polygon() const { void CSGPolygon3D::set_mode(Mode p_mode) { mode = p_mode; _make_dirty(); - update_gizmo(); + update_gizmos(); notify_property_list_changed(); } @@ -2270,7 +2274,7 @@ void CSGPolygon3D::set_depth(const float p_depth) { ERR_FAIL_COND(p_depth < 0.001); depth = p_depth; _make_dirty(); - update_gizmo(); + update_gizmos(); } float CSGPolygon3D::get_depth() const { @@ -2290,7 +2294,7 @@ void CSGPolygon3D::set_spin_degrees(const float p_spin_degrees) { ERR_FAIL_COND(p_spin_degrees < 0.01 || p_spin_degrees > 360); spin_degrees = p_spin_degrees; _make_dirty(); - update_gizmo(); + update_gizmos(); } float CSGPolygon3D::get_spin_degrees() const { @@ -2301,7 +2305,7 @@ void CSGPolygon3D::set_spin_sides(const int p_spin_sides) { ERR_FAIL_COND(p_spin_sides < 3); spin_sides = p_spin_sides; _make_dirty(); - update_gizmo(); + update_gizmos(); } int CSGPolygon3D::get_spin_sides() const { @@ -2311,7 +2315,7 @@ int CSGPolygon3D::get_spin_sides() const { void CSGPolygon3D::set_path_node(const NodePath &p_path) { path_node = p_path; _make_dirty(); - update_gizmo(); + update_gizmos(); } NodePath CSGPolygon3D::get_path_node() const { @@ -2322,7 +2326,7 @@ void CSGPolygon3D::set_path_interval(float p_interval) { ERR_FAIL_COND_MSG(p_interval < 0.001, "Path interval cannot be smaller than 0.001."); path_interval = p_interval; _make_dirty(); - update_gizmo(); + update_gizmos(); } float CSGPolygon3D::get_path_interval() const { @@ -2332,7 +2336,7 @@ float CSGPolygon3D::get_path_interval() const { void CSGPolygon3D::set_path_rotation(PathRotation p_rotation) { path_rotation = p_rotation; _make_dirty(); - update_gizmo(); + update_gizmos(); } CSGPolygon3D::PathRotation CSGPolygon3D::get_path_rotation() const { @@ -2342,7 +2346,7 @@ CSGPolygon3D::PathRotation CSGPolygon3D::get_path_rotation() const { void CSGPolygon3D::set_path_local(bool p_enable) { path_local = p_enable; _make_dirty(); - update_gizmo(); + update_gizmos(); } bool CSGPolygon3D::is_path_local() const { @@ -2352,7 +2356,7 @@ bool CSGPolygon3D::is_path_local() const { void CSGPolygon3D::set_path_joined(bool p_enable) { path_joined = p_enable; _make_dirty(); - update_gizmo(); + update_gizmos(); } bool CSGPolygon3D::is_path_joined() const { diff --git a/modules/csg/doc_classes/CSGShape3D.xml b/modules/csg/doc_classes/CSGShape3D.xml index 01ec46e707..f42ce8c379 100644 --- a/modules/csg/doc_classes/CSGShape3D.xml +++ b/modules/csg/doc_classes/CSGShape3D.xml @@ -10,55 +10,43 @@ </tutorials> <methods> <method name="get_collision_layer_bit" qualifiers="const"> - <return type="bool"> - </return> - <argument index="0" name="bit" type="int"> - </argument> + <return type="bool" /> + <argument index="0" name="bit" type="int" /> <description> Returns an individual bit on the collision mask. </description> </method> <method name="get_collision_mask_bit" qualifiers="const"> - <return type="bool"> - </return> - <argument index="0" name="bit" type="int"> - </argument> + <return type="bool" /> + <argument index="0" name="bit" type="int" /> <description> Returns an individual bit on the collision mask. </description> </method> <method name="get_meshes" qualifiers="const"> - <return type="Array"> - </return> + <return type="Array" /> <description> Returns an [Array] with two elements, the first is the [Transform3D] of this node and the second is the root [Mesh] of this node. Only works when this node is the root shape. </description> </method> <method name="is_root_shape" qualifiers="const"> - <return type="bool"> - </return> + <return type="bool" /> <description> Returns [code]true[/code] if this is a root shape and is thus the object that is rendered. </description> </method> <method name="set_collision_layer_bit"> - <return type="void"> - </return> - <argument index="0" name="bit" type="int"> - </argument> - <argument index="1" name="value" type="bool"> - </argument> + <return type="void" /> + <argument index="0" name="bit" type="int" /> + <argument index="1" name="value" type="bool" /> <description> Sets individual bits on the layer mask. Use this if you only need to change one layer's value. </description> </method> <method name="set_collision_mask_bit"> - <return type="void"> - </return> - <argument index="0" name="bit" type="int"> - </argument> - <argument index="1" name="value" type="bool"> - </argument> + <return type="void" /> + <argument index="0" name="bit" type="int" /> + <argument index="1" name="value" type="bool" /> <description> Sets individual bits on the collision mask. Use this if you only need to change one layer's value. </description> diff --git a/modules/enet/config.py b/modules/enet/config.py index 3662b2d94e..9102c74579 100644 --- a/modules/enet/config.py +++ b/modules/enet/config.py @@ -9,6 +9,8 @@ def configure(env): def get_doc_classes(): return [ "ENetMultiplayerPeer", + "ENetConnection", + "ENetPacketPeer", ] diff --git a/modules/enet/doc_classes/ENetConnection.xml b/modules/enet/doc_classes/ENetConnection.xml new file mode 100644 index 0000000000..c2a85ffdf8 --- /dev/null +++ b/modules/enet/doc_classes/ENetConnection.xml @@ -0,0 +1,194 @@ +<?xml version="1.0" encoding="UTF-8" ?> +<class name="ENetConnection" inherits="RefCounted" version="4.0"> + <brief_description> + A wrapper class for an [url=http://enet.bespin.org/group__host.html]ENetHost[/url]. + </brief_description> + <description> + ENet's purpose is to provide a relatively thin, simple and robust network communication layer on top of UDP (User Datagram Protocol). + </description> + <tutorials> + <link title="API documentation on the ENet website">http://enet.bespin.org/usergroup0.html</link> + </tutorials> + <methods> + <method name="bandwidth_limit"> + <return type="void" /> + <argument index="0" name="in_bandwidth" type="int" default="0" /> + <argument index="1" name="out_bandwidth" type="int" default="0" /> + <description> + Adjusts the bandwidth limits of a host. + </description> + </method> + <method name="broadcast"> + <return type="void" /> + <argument index="0" name="channel" type="int" /> + <argument index="1" name="packet" type="PackedByteArray" /> + <argument index="2" name="flags" type="int" /> + <description> + Queues a [code]packet[/code] to be sent to all peers associated with the host over the specified [code]channel[/code]. See [ENetPacketPeer] [code]FLAG_*[/code] constants for available packet flags. + </description> + </method> + <method name="channel_limit"> + <return type="void" /> + <argument index="0" name="limit" type="int" /> + <description> + Limits the maximum allowed channels of future incoming connections. + </description> + </method> + <method name="compress"> + <return type="void" /> + <argument index="0" name="mode" type="int" enum="ENetConnection.CompressionMode" /> + <description> + Sets the compression method used for network packets. These have different tradeoffs of compression speed versus bandwidth, you may need to test which one works best for your use case if you use compression at all. + [b]Note:[/b] Most games' network design involve sending many small packets frequently (smaller than 4 KB each). If in doubt, it is recommended to keep the default compression algorithm as it works best on these small packets. + </description> + </method> + <method name="connect_to_host"> + <return type="ENetPacketPeer" /> + <argument index="0" name="address" type="String" /> + <argument index="1" name="port" type="int" /> + <argument index="2" name="channels" type="int" default="0" /> + <argument index="3" name="data" type="int" default="0" /> + <description> + Initiates a connection to a foreign [code]address[/code] using the specified [code]port[/code] and allocting the requested [code]channels[/code]. Optional [code]data[/code] can be passed during connection in the form of a 32 bit integer. + Note: You must call either [method create_host] or [method create_host_bound] before calling this method. + </description> + </method> + <method name="create_host"> + <return type="int" enum="Error" /> + <argument index="0" name="max_peers" type="int" default="32" /> + <argument index="1" name="max_channels" type="int" default="0" /> + <argument index="2" name="in_bandwidth" type="int" default="0" /> + <argument index="3" name="out_bandwidth" type="int" default="0" /> + <description> + Create an ENetHost that will allow up to [code]max_peers[/code] connected peers, each allocating up to [code]max_channels[/code] channels, optionally limiting bandwith to [code]in_bandwidth[/code] and [code]out_bandwidth[/code]. + </description> + </method> + <method name="create_host_bound"> + <return type="int" enum="Error" /> + <argument index="0" name="bind_address" type="String" /> + <argument index="1" name="bind_port" type="int" /> + <argument index="2" name="max_peers" type="int" default="32" /> + <argument index="3" name="max_channels" type="int" default="0" /> + <argument index="4" name="in_bandwidth" type="int" default="0" /> + <argument index="5" name="out_bandwidth" type="int" default="0" /> + <description> + Create an ENetHost like [method create_host] which is also bound to the given [code]bind_address[/code] and [code]bind_port[/code]. + </description> + </method> + <method name="destroy"> + <return type="void" /> + <description> + Destroys the host and all resources associated with it. + </description> + </method> + <method name="dtls_client_setup"> + <return type="int" enum="Error" /> + <argument index="0" name="certificate" type="X509Certificate" /> + <argument index="1" name="hostname" type="String" /> + <argument index="2" name="verify" type="bool" default="true" /> + <description> + Configure this ENetHost to use the custom Godot extension allowing DTLS encryption for ENet clients. Call this before [method connect_to_host] to have ENet connect using DTLS with [code]certificate[/code] and [code]hostname[/code] verification. Verification can be optionally turned off via the [code]verify[/code] parameter. + </description> + </method> + <method name="dtls_server_setup"> + <return type="int" enum="Error" /> + <argument index="0" name="key" type="CryptoKey" /> + <argument index="1" name="certificate" type="X509Certificate" /> + <description> + Configure this ENetHost to use the custom Godot extension allowing DTLS encryption for ENet servers. Call this right after [method create_host_bound] to have ENet expect peers to connect using DTLS. + </description> + </method> + <method name="flush"> + <return type="void" /> + <description> + Sends any queued packets on the host specified to its designated peers. + </description> + </method> + <method name="get_local_port" qualifiers="const"> + <return type="int" /> + <description> + Returns the local port to which this peer is bound. + </description> + </method> + <method name="get_max_channels" qualifiers="const"> + <return type="int" /> + <description> + Returns the maximum number of channels allowed for connected peers. + </description> + </method> + <method name="get_peers"> + <return type="Array" /> + <description> + Returns the list of peers associated with this host. + Note: This list might include some peers that are not fully connected or are still being disconnected. + </description> + </method> + <method name="pop_statistic"> + <return type="float" /> + <argument index="0" name="statistic" type="int" enum="ENetConnection.HostStatistic" /> + <description> + Returns and resets host statistics. See [enum HostStatistic] for more info. + </description> + </method> + <method name="refuse_new_connections"> + <return type="void" /> + <argument index="0" name="refuse" type="bool" /> + <description> + Configures the DTLS server to automatically drop new connections. + Note: This method is only relevant after calling [method dtls_server_setup]. + </description> + </method> + <method name="service"> + <return type="Array" /> + <argument index="0" name="timeout" type="int" default="0" /> + <description> + Waits for events on the host specified and shuttles packets between the host and its peers. The returned [Array] will have 4 elements. An [enum EventType], the [ENetPacketPeer] which generated the event, the event associated data (if any), the event associated channel (if any). If the generated event is [constant EVENT_RECEIVE], the received packet will be queued to the associated [ENetPacketPeer]. + Call this function regularly to handle connections, disconnections, and to receive new packets. + </description> + </method> + </methods> + <constants> + <constant name="COMPRESS_NONE" value="0" enum="CompressionMode"> + No compression. This uses the most bandwidth, but has the upside of requiring the fewest CPU resources. This option may also be used to make network debugging using tools like Wireshark easier. + </constant> + <constant name="COMPRESS_RANGE_CODER" value="1" enum="CompressionMode"> + ENet's built-in range encoding. Works well on small packets, but is not the most efficient algorithm on packets larger than 4 KB. + </constant> + <constant name="COMPRESS_FASTLZ" value="2" enum="CompressionMode"> + [url=http://fastlz.org/]FastLZ[/url] compression. This option uses less CPU resources compared to [constant COMPRESS_ZLIB], at the expense of using more bandwidth. + </constant> + <constant name="COMPRESS_ZLIB" value="3" enum="CompressionMode"> + [url=https://www.zlib.net/]Zlib[/url] compression. This option uses less bandwidth compared to [constant COMPRESS_FASTLZ], at the expense of using more CPU resources. + </constant> + <constant name="COMPRESS_ZSTD" value="4" enum="CompressionMode"> + [url=https://facebook.github.io/zstd/]Zstandard[/url] compression. Note that this algorithm is not very efficient on packets smaller than 4 KB. Therefore, it's recommended to use other compression algorithms in most cases. + </constant> + <constant name="EVENT_ERROR" value="-1" enum="EventType"> + An error occurred during [method service]. You will likely need to [method destroy] the host and recreate it. + </constant> + <constant name="EVENT_NONE" value="0" enum="EventType"> + No event occurred within the specified time limit. + </constant> + <constant name="EVENT_CONNECT" value="1" enum="EventType"> + A connection request initiated by enet_host_connect has completed. The array will contain the peer which successfully connected. + </constant> + <constant name="EVENT_DISCONNECT" value="2" enum="EventType"> + A peer has disconnected. This event is generated on a successful completion of a disconnect initiated by [method ENetPacketPeer.peer_disconnect], if a peer has timed out, or if a connection request intialized by [method connect_to_host] has timed out. The array will contain the peer which disconnected. The data field contains user supplied data describing the disconnection, or 0, if none is available. + </constant> + <constant name="EVENT_RECEIVE" value="3" enum="EventType"> + A packet has been received from a peer. The array will contain the peer which sent the packet, the channel number upon which the packet was received, and the received packet. + </constant> + <constant name="HOST_TOTAL_SENT_DATA" value="0" enum="HostStatistic"> + Total data sent. + </constant> + <constant name="HOST_TOTAL_SENT_PACKETS" value="1" enum="HostStatistic"> + Total UDP packets sent. + </constant> + <constant name="HOST_TOTAL_RECEIVED_DATA" value="2" enum="HostStatistic"> + Total data received. + </constant> + <constant name="HOST_TOTAL_RECEIVED_PACKETS" value="3" enum="HostStatistic"> + Total UDP packets received. + </constant> + </constants> +</class> diff --git a/modules/enet/doc_classes/ENetMultiplayerPeer.xml b/modules/enet/doc_classes/ENetMultiplayerPeer.xml index 5b2c72dce4..3a37b396a4 100644 --- a/modules/enet/doc_classes/ENetMultiplayerPeer.xml +++ b/modules/enet/doc_classes/ENetMultiplayerPeer.xml @@ -1,11 +1,10 @@ <?xml version="1.0" encoding="UTF-8" ?> <class name="ENetMultiplayerPeer" inherits="MultiplayerPeer" version="4.0"> <brief_description> - PacketPeer implementation using the [url=http://enet.bespin.org/index.html]ENet[/url] library. + A MultiplayerPeer implementation using the [url=http://enet.bespin.org/index.html]ENet[/url] library. </brief_description> <description> - A PacketPeer implementation that should be passed to [member MultiplayerAPI.network_peer] after being initialized as either a client or server. Events can then be handled by connecting to [SceneTree] signals. - ENet's purpose is to provide a relatively thin, simple and robust network communication layer on top of UDP (User Datagram Protocol). + A MultiplayerPeer implementation that should be passed to [member MultiplayerAPI.network_peer] after being initialized as either a client, server, or mesh. Events can then be handled by connecting to [MultiplayerAPI] signals. See [ENetConnection] for more information on the ENet library wrapper. [b]Note:[/b] ENet only uses UDP, not TCP. When forwarding the server port to make your server accessible on the public Internet, you only need to forward the server port in UDP. You can use the [UPNP] class to try to forward the server port automatically when starting the server. </description> <tutorials> @@ -13,182 +12,77 @@ <link title="API documentation on the ENet website">http://enet.bespin.org/usergroup0.html</link> </tutorials> <methods> - <method name="close_connection"> - <return type="void"> - </return> - <argument index="0" name="wait_usec" type="int" default="100"> - </argument> + <method name="add_mesh_peer"> + <return type="int" enum="Error" /> + <argument index="0" name="peer_id" type="int" /> + <argument index="1" name="host" type="ENetConnection" /> <description> - Closes the connection. Ignored if no connection is currently established. If this is a server it tries to notify all clients before forcibly disconnecting them. If this is a client it simply closes the connection to the server. + Add a new remote peer with the given [code]peer_id[/code] connected to the given [code]host[/code]. + Note: The [code]host[/code] must have exactly one peer in the [constant ENetPacketPeer.STATE_CONNECTED] state. </description> </method> - <method name="create_client"> - <return type="int" enum="Error"> - </return> - <argument index="0" name="address" type="String"> - </argument> - <argument index="1" name="port" type="int"> - </argument> - <argument index="2" name="in_bandwidth" type="int" default="0"> - </argument> - <argument index="3" name="out_bandwidth" type="int" default="0"> - </argument> - <argument index="4" name="local_port" type="int" default="0"> - </argument> - <description> - Create client that connects to a server at [code]address[/code] using specified [code]port[/code]. The given address needs to be either a fully qualified domain name (e.g. [code]"www.example.com"[/code]) or an IP address in IPv4 or IPv6 format (e.g. [code]"192.168.1.1"[/code]). The [code]port[/code] is the port the server is listening on. The [code]in_bandwidth[/code] and [code]out_bandwidth[/code] parameters can be used to limit the incoming and outgoing bandwidth to the given number of bytes per second. The default of 0 means unlimited bandwidth. Note that ENet will strategically drop packets on specific sides of a connection between peers to ensure the peer's bandwidth is not overwhelmed. The bandwidth parameters also determine the window size of a connection which limits the amount of reliable packets that may be in transit at any given time. Returns [constant OK] if a client was created, [constant ERR_ALREADY_IN_USE] if this ENetMultiplayerPeer instance already has an open connection (in which case you need to call [method close_connection] first) or [constant ERR_CANT_CREATE] if the client could not be created. If [code]local_port[/code] is specified, the client will also listen to the given port; this is useful for some NAT traversal techniques. - </description> - </method> - <method name="create_server"> - <return type="int" enum="Error"> - </return> - <argument index="0" name="port" type="int"> - </argument> - <argument index="1" name="max_clients" type="int" default="32"> - </argument> - <argument index="2" name="in_bandwidth" type="int" default="0"> - </argument> - <argument index="3" name="out_bandwidth" type="int" default="0"> - </argument> - <description> - Create server that listens to connections via [code]port[/code]. The port needs to be an available, unused port between 0 and 65535. Note that ports below 1024 are privileged and may require elevated permissions depending on the platform. To change the interface the server listens on, use [method set_bind_ip]. The default IP is the wildcard [code]"*"[/code], which listens on all available interfaces. [code]max_clients[/code] is the maximum number of clients that are allowed at once, any number up to 4095 may be used, although the achievable number of simultaneous clients may be far lower and depends on the application. For additional details on the bandwidth parameters, see [method create_client]. Returns [constant OK] if a server was created, [constant ERR_ALREADY_IN_USE] if this ENetMultiplayerPeer instance already has an open connection (in which case you need to call [method close_connection] first) or [constant ERR_CANT_CREATE] if the server could not be created. - </description> - </method> - <method name="disconnect_peer"> - <return type="void"> - </return> - <argument index="0" name="id" type="int"> - </argument> - <argument index="1" name="now" type="bool" default="false"> - </argument> - <description> - Disconnect the given peer. If "now" is set to [code]true[/code], the connection will be closed immediately without flushing queued messages. - </description> - </method> - <method name="get_last_packet_channel" qualifiers="const"> - <return type="int"> - </return> + <method name="close_connection"> + <return type="void" /> + <argument index="0" name="wait_usec" type="int" default="100" /> <description> - Returns the channel of the last packet fetched via [method PacketPeer.get_packet]. + Closes the connection. Ignored if no connection is currently established. If this is a server it tries to notify all clients before forcibly disconnecting them. If this is a client it simply closes the connection to the server. </description> </method> - <method name="get_local_port" qualifiers="const"> - <return type="int"> - </return> + <method name="create_client"> + <return type="int" enum="Error" /> + <argument index="0" name="address" type="String" /> + <argument index="1" name="port" type="int" /> + <argument index="2" name="channel_count" type="int" default="0" /> + <argument index="3" name="in_bandwidth" type="int" default="0" /> + <argument index="4" name="out_bandwidth" type="int" default="0" /> + <argument index="5" name="local_port" type="int" default="0" /> <description> - Returns the local port to which this peer is bound. + Create client that connects to a server at [code]address[/code] using specified [code]port[/code]. The given address needs to be either a fully qualified domain name (e.g. [code]"www.example.com"[/code]) or an IP address in IPv4 or IPv6 format (e.g. [code]"192.168.1.1"[/code]). The [code]port[/code] is the port the server is listening on. The [code]channel_count[/code] parameter can be used to specify the number of ENet channels allocated for the connection. The [code]in_bandwidth[/code] and [code]out_bandwidth[/code] parameters can be used to limit the incoming and outgoing bandwidth to the given number of bytes per second. The default of 0 means unlimited bandwidth. Note that ENet will strategically drop packets on specific sides of a connection between peers to ensure the peer's bandwidth is not overwhelmed. The bandwidth parameters also determine the window size of a connection which limits the amount of reliable packets that may be in transit at any given time. Returns [constant OK] if a client was created, [constant ERR_ALREADY_IN_USE] if this ENetMultiplayerPeer instance already has an open connection (in which case you need to call [method close_connection] first) or [constant ERR_CANT_CREATE] if the client could not be created. If [code]local_port[/code] is specified, the client will also listen to the given port; this is useful for some NAT traversal techniques. </description> </method> - <method name="get_packet_channel" qualifiers="const"> - <return type="int"> - </return> + <method name="create_mesh"> + <return type="int" enum="Error" /> + <argument index="0" name="unique_id" type="int" /> <description> - Returns the channel of the next packet that will be retrieved via [method PacketPeer.get_packet]. + Initialize this [MultiplayerPeer] in mesh mode. The provided [code]unique_id[/code] will be used as the local peer network unique ID once assigned as the [member MultiplayerAPI.network_peer]. In the mesh configuration you will need to set up each new peer manually using [ENetConnection] before calling [method add_mesh_peer]. While this technique is more advanced, it allows for better control over the connection process (e.g. when dealing with NAT punch-through) and for better distribution of the network load (which would otherwise be more taxing on the server). </description> </method> - <method name="get_peer_address" qualifiers="const"> - <return type="String"> - </return> - <argument index="0" name="id" type="int"> - </argument> + <method name="create_server"> + <return type="int" enum="Error" /> + <argument index="0" name="port" type="int" /> + <argument index="1" name="max_clients" type="int" default="32" /> + <argument index="2" name="max_channels" type="int" default="0" /> + <argument index="3" name="in_bandwidth" type="int" default="0" /> + <argument index="4" name="out_bandwidth" type="int" default="0" /> <description> - Returns the IP address of the given peer. + Create server that listens to connections via [code]port[/code]. The port needs to be an available, unused port between 0 and 65535. Note that ports below 1024 are privileged and may require elevated permissions depending on the platform. To change the interface the server listens on, use [method set_bind_ip]. The default IP is the wildcard [code]"*"[/code], which listens on all available interfaces. [code]max_clients[/code] is the maximum number of clients that are allowed at once, any number up to 4095 may be used, although the achievable number of simultaneous clients may be far lower and depends on the application. For additional details on the bandwidth parameters, see [method create_client]. Returns [constant OK] if a server was created, [constant ERR_ALREADY_IN_USE] if this ENetMultiplayerPeer instance already has an open connection (in which case you need to call [method close_connection] first) or [constant ERR_CANT_CREATE] if the server could not be created. </description> </method> - <method name="get_peer_port" qualifiers="const"> - <return type="int"> - </return> - <argument index="0" name="id" type="int"> - </argument> + <method name="get_peer" qualifiers="const"> + <return type="ENetPacketPeer" /> + <argument index="0" name="id" type="int" /> <description> - Returns the remote port of the given peer. + Return the [ENetPacketPeer] associated to the given [code]id[/code]. </description> </method> <method name="set_bind_ip"> - <return type="void"> - </return> - <argument index="0" name="ip" type="String"> - </argument> + <return type="void" /> + <argument index="0" name="ip" type="String" /> <description> The IP used when creating a server. This is set to the wildcard [code]"*"[/code] by default, which binds to all available interfaces. The given IP needs to be in IPv4 or IPv6 address format, for example: [code]"192.168.1.1"[/code]. </description> </method> - <method name="set_dtls_certificate"> - <return type="void"> - </return> - <argument index="0" name="certificate" type="X509Certificate"> - </argument> - <description> - Configure the [X509Certificate] to use when [member use_dtls] is [code]true[/code]. For servers, you must also setup the [CryptoKey] via [method set_dtls_key]. - </description> - </method> - <method name="set_dtls_key"> - <return type="void"> - </return> - <argument index="0" name="key" type="CryptoKey"> - </argument> - <description> - Configure the [CryptoKey] to use when [member use_dtls] is [code]true[/code]. Remember to also call [method set_dtls_certificate] to setup your [X509Certificate]. - </description> - </method> - <method name="set_peer_timeout"> - <return type="void"> - </return> - <argument index="0" name="id" type="int"> - </argument> - <argument index="1" name="timeout_limit" type="int"> - </argument> - <argument index="2" name="timeout_min" type="int"> - </argument> - <argument index="3" name="timeout_max" type="int"> - </argument> - <description> - Sets the timeout parameters for a peer. The timeout parameters control how and when a peer will timeout from a failure to acknowledge reliable traffic. Timeout values are expressed in milliseconds. - The [code]timeout_limit[/code] is a factor that, multiplied by a value based on the average round trip time, will determine the timeout limit for a reliable packet. When that limit is reached, the timeout will be doubled, and the peer will be disconnected if that limit has reached [code]timeout_min[/code]. The [code]timeout_max[/code] parameter, on the other hand, defines a fixed timeout for which any packet must be acknowledged or the peer will be dropped. - </description> - </method> </methods> <members> - <member name="always_ordered" type="bool" setter="set_always_ordered" getter="is_always_ordered" default="false"> - Enforce ordered packets when using [constant MultiplayerPeer.TRANSFER_MODE_UNRELIABLE] (thus behaving similarly to [constant MultiplayerPeer.TRANSFER_MODE_UNRELIABLE_ORDERED]). This is the only way to use ordering with the RPC system. - </member> - <member name="channel_count" type="int" setter="set_channel_count" getter="get_channel_count" default="3"> - The number of channels to be used by ENet. Channels are used to separate different kinds of data. In reliable or ordered mode, for example, the packet delivery order is ensured on a per-channel basis. This is done to combat latency and reduces ordering restrictions on packets. The delivery status of a packet in one channel won't stall the delivery of other packets in another channel. - </member> - <member name="compression_mode" type="int" setter="set_compression_mode" getter="get_compression_mode" enum="ENetMultiplayerPeer.CompressionMode" default="0"> - The compression method used for network packets. These have different tradeoffs of compression speed versus bandwidth, you may need to test which one works best for your use case if you use compression at all. - </member> - <member name="dtls_verify" type="bool" setter="set_dtls_verify_enabled" getter="is_dtls_verify_enabled" default="true"> - Enable or disable certificate verification when [member use_dtls] [code]true[/code]. + <member name="host" type="ENetConnection" setter="" getter="get_host"> + The underlying [ENetConnection] created after [method create_client] and [method create_server]. </member> <member name="refuse_new_connections" type="bool" setter="set_refuse_new_connections" getter="is_refusing_new_connections" override="true" default="false" /> <member name="server_relay" type="bool" setter="set_server_relay_enabled" getter="is_server_relay_enabled" default="true"> Enable or disable the server feature that notifies clients of other peers' connection/disconnection, and relays messages between them. When this option is [code]false[/code], clients won't be automatically notified of other peers and won't be able to send them packets through the server. </member> - <member name="transfer_channel" type="int" setter="set_transfer_channel" getter="get_transfer_channel" default="-1"> - Set the default channel to be used to transfer data. By default, this value is [code]-1[/code] which means that ENet will only use 2 channels: one for reliable packets, and one for unreliable packets. The channel [code]0[/code] is reserved and cannot be used. Setting this member to any value between [code]0[/code] and [member channel_count] (excluded) will force ENet to use that channel for sending data. See [member channel_count] for more information about ENet channels. - </member> <member name="transfer_mode" type="int" setter="set_transfer_mode" getter="get_transfer_mode" override="true" enum="MultiplayerPeer.TransferMode" default="2" /> - <member name="use_dtls" type="bool" setter="set_dtls_enabled" getter="is_dtls_enabled" default="false"> - When enabled, the client or server created by this peer, will use [PacketPeerDTLS] instead of raw UDP sockets for communicating with the remote peer. This will make the communication encrypted with DTLS at the cost of higher resource usage and potentially larger packet size. - Note: When creating a DTLS server, make sure you setup the key/certificate pair via [method set_dtls_key] and [method set_dtls_certificate]. For DTLS clients, have a look at the [member dtls_verify] option, and configure the certificate accordingly via [method set_dtls_certificate]. - </member> </members> <constants> - <constant name="COMPRESS_NONE" value="0" enum="CompressionMode"> - No compression. This uses the most bandwidth, but has the upside of requiring the fewest CPU resources. - </constant> - <constant name="COMPRESS_RANGE_CODER" value="1" enum="CompressionMode"> - ENet's built-in range encoding. - </constant> - <constant name="COMPRESS_FASTLZ" value="2" enum="CompressionMode"> - [url=http://fastlz.org/]FastLZ[/url] compression. This option uses less CPU resources compared to [constant COMPRESS_ZLIB], at the expense of using more bandwidth. - </constant> - <constant name="COMPRESS_ZLIB" value="3" enum="CompressionMode"> - [url=https://www.zlib.net/]Zlib[/url] compression. This option uses less bandwidth compared to [constant COMPRESS_FASTLZ], at the expense of using more CPU resources. - </constant> - <constant name="COMPRESS_ZSTD" value="4" enum="CompressionMode"> - [url=https://facebook.github.io/zstd/]Zstandard[/url] compression. - </constant> </constants> </class> diff --git a/modules/enet/doc_classes/ENetPacketPeer.xml b/modules/enet/doc_classes/ENetPacketPeer.xml new file mode 100644 index 0000000000..8f0693fb01 --- /dev/null +++ b/modules/enet/doc_classes/ENetPacketPeer.xml @@ -0,0 +1,183 @@ +<?xml version="1.0" encoding="UTF-8" ?> +<class name="ENetPacketPeer" inherits="PacketPeer" version="4.0"> + <brief_description> + A wrapper class for an [url=http://enet.bespin.org/group__peer.html]ENetPeer[/url]. + </brief_description> + <description> + A PacketPeer implementation representing a peer of an [ENetConnection]. + This class cannot be instantiated directly but can be retrieved during [method ENetConnection.service] or via [method ENetConnection.get_peers]. + </description> + <tutorials> + <link title="API documentation on the ENet website">http://enet.bespin.org/usergroup0.html</link> + </tutorials> + <methods> + <method name="get_channels" qualifiers="const"> + <return type="int" /> + <description> + Returns the number of channels allocated for communication with peer. + </description> + </method> + <method name="get_state" qualifiers="const"> + <return type="int" enum="ENetPacketPeer.PeerState" /> + <description> + Returns the current peer state. See [enum PeerState]. + </description> + </method> + <method name="get_statistic"> + <return type="float" /> + <argument index="0" name="statistic" type="int" enum="ENetPacketPeer.PeerStatistic" /> + <description> + Returns the requested [code]statistic[/code] for this peer. See [enum PeerStatistic]. + </description> + </method> + <method name="is_active" qualifiers="const"> + <return type="bool" /> + <description> + Returns [code]true[/code] if the peer is currently active (i.e. the associated [ENetConnection] is still valid). + </description> + </method> + <method name="peer_disconnect"> + <return type="void" /> + <argument index="0" name="data" type="int" default="0" /> + <description> + Request a disconnection from a peer. An [constant ENetConnection.EVENT_DISCONNECT] will be generated during [method ENetConnection.service] once the disconnection is complete. + </description> + </method> + <method name="peer_disconnect_later"> + <return type="void" /> + <argument index="0" name="data" type="int" default="0" /> + <description> + Request a disconnection from a peer, but only after all queued outgoing packets are sent. An [constant ENetConnection.EVENT_DISCONNECT] will be generated during [method ENetConnection.service] once the disconnection is complete. + </description> + </method> + <method name="peer_disconnect_now"> + <return type="void" /> + <argument index="0" name="data" type="int" default="0" /> + <description> + Force an immediate disconnection from a peer. No [constant ENetConnection.EVENT_DISCONNECT] will be generated. The foreign peer is not guaranteed to receive the disconnect notification, and is reset immediately upon return from this function. + </description> + </method> + <method name="ping"> + <return type="void" /> + <description> + Sends a ping request to a peer. ENet automatically pings all connected peers at regular intervals, however, this function may be called to ensure more frequent ping requests. + </description> + </method> + <method name="ping_interval"> + <return type="void" /> + <argument index="0" name="ping_interval" type="int" /> + <description> + Sets the [code]ping_interval[/code] in milliseconds at which pings will be sent to a peer. Pings are used both to monitor the liveness of the connection and also to dynamically adjust the throttle during periods of low traffic so that the throttle has reasonable responsiveness during traffic spikes. + </description> + </method> + <method name="reset"> + <return type="void" /> + <description> + Forcefully disconnects a peer. The foreign host represented by the peer is not notified of the disconnection and will timeout on its connection to the local host. + </description> + </method> + <method name="send"> + <return type="int" enum="Error" /> + <argument index="0" name="channel" type="int" /> + <argument index="1" name="packet" type="PackedByteArray" /> + <argument index="2" name="flags" type="int" /> + <description> + Queues a [code]packet[/code] to be sent over the specified [code]channel[/code]. See [code]FLAG_*[/code] constants for available packet flags. + </description> + </method> + <method name="set_timeout"> + <return type="void" /> + <argument index="0" name="timeout" type="int" /> + <argument index="1" name="timeout_min" type="int" /> + <argument index="2" name="timeout_max" type="int" /> + <description> + Sets the timeout parameters for a peer. The timeout parameters control how and when a peer will timeout from a failure to acknowledge reliable traffic. Timeout values are expressed in milliseconds. + The [code]timeout_limit[/code] is a factor that, multiplied by a value based on the average round trip time, will determine the timeout limit for a reliable packet. When that limit is reached, the timeout will be doubled, and the peer will be disconnected if that limit has reached [code]timeout_min[/code]. The [code]timeout_max[/code] parameter, on the other hand, defines a fixed timeout for which any packet must be acknowledged or the peer will be dropped. + </description> + </method> + <method name="throttle_configure"> + <return type="void" /> + <argument index="0" name="interval" type="int" /> + <argument index="1" name="acceleration" type="int" /> + <argument index="2" name="deceleration" type="int" /> + <description> + Configures throttle parameter for a peer. + Unreliable packets are dropped by ENet in response to the varying conditions of the Internet connection to the peer. The throttle represents a probability that an unreliable packet should not be dropped and thus sent by ENet to the peer. By measuring fluctuations in round trip times of reliable packets over the specified [code]interval[/code], ENet will either increase the probably by the amount specified in the [code]acceleration[/code] parameter, or decrease it by the amount specified in the [code]deceleration[/code] parameter (both are ratios to [constant PACKET_THROTTLE_SCALE]). + When the throttle has a value of [constant PACKET_THROTTLE_SCALE], no unreliable packets are dropped by ENet, and so 100% of all unreliable packets will be sent. + When the throttle has a value of 0, all unreliable packets are dropped by ENet, and so 0% of all unreliable packets will be sent. + Intermediate values for the throttle represent intermediate probabilities between 0% and 100% of unreliable packets being sent. The bandwidth limits of the local and foreign hosts are taken into account to determine a sensible limit for the throttle probability above which it should not raise even in the best of conditions. + </description> + </method> + </methods> + <constants> + <constant name="STATE_DISCONNECTED" value="0" enum="PeerState"> + </constant> + <constant name="STATE_CONNECTING" value="1" enum="PeerState"> + </constant> + <constant name="STATE_ACKNOWLEDGING_CONNECT" value="2" enum="PeerState"> + </constant> + <constant name="STATE_CONNECTION_PENDING" value="3" enum="PeerState"> + </constant> + <constant name="STATE_CONNECTION_SUCCEEDED" value="4" enum="PeerState"> + </constant> + <constant name="STATE_CONNECTED" value="5" enum="PeerState"> + </constant> + <constant name="STATE_DISCONNECT_LATER" value="6" enum="PeerState"> + </constant> + <constant name="STATE_DISCONNECTING" value="7" enum="PeerState"> + </constant> + <constant name="STATE_ACKNOWLEDGING_DISCONNECT" value="8" enum="PeerState"> + </constant> + <constant name="STATE_ZOMBIE" value="9" enum="PeerState"> + </constant> + <constant name="PEER_PACKET_LOSS" value="0" enum="PeerStatistic"> + Mean packet loss of reliable packets as a ratio with respect to the [constant PACKET_LOSS_SCALE]. + </constant> + <constant name="PEER_PACKET_LOSS_VARIANCE" value="1" enum="PeerStatistic"> + Packet loss variance. + </constant> + <constant name="PEER_PACKET_LOSS_EPOCH" value="2" enum="PeerStatistic"> + </constant> + <constant name="PEER_ROUND_TRIP_TIME" value="3" enum="PeerStatistic"> + Mean packet round trip time for reliable packets. + </constant> + <constant name="PEER_ROUND_TRIP_TIME_VARIANCE" value="4" enum="PeerStatistic"> + Variance of the mean round trip time. + </constant> + <constant name="PEER_LAST_ROUND_TRIP_TIME" value="5" enum="PeerStatistic"> + Last recorded round trip time for a reliable packet. + </constant> + <constant name="PEER_LAST_ROUND_TRIP_TIME_VARIANCE" value="6" enum="PeerStatistic"> + Variance of the last trip time recorded. + </constant> + <constant name="PEER_PACKET_THROTTLE" value="7" enum="PeerStatistic"> + </constant> + <constant name="PEER_PACKET_THROTTLE_LIMIT" value="8" enum="PeerStatistic"> + </constant> + <constant name="PEER_PACKET_THROTTLE_COUNTER" value="9" enum="PeerStatistic"> + </constant> + <constant name="PEER_PACKET_THROTTLE_EPOCH" value="10" enum="PeerStatistic"> + </constant> + <constant name="PEER_PACKET_THROTTLE_ACCELERATION" value="11" enum="PeerStatistic"> + </constant> + <constant name="PEER_PACKET_THROTTLE_DECELERATION" value="12" enum="PeerStatistic"> + </constant> + <constant name="PEER_PACKET_THROTTLE_INTERVAL" value="13" enum="PeerStatistic"> + </constant> + <constant name="PACKET_LOSS_SCALE" value="65536"> + The reference scale for packet loss. See [method get_statistic] and [constant PEER_PACKET_LOSS]. + </constant> + <constant name="PACKET_THROTTLE_SCALE" value="32"> + The reference value for throttle configuration. See [method throttle_configure]. + </constant> + <constant name="FLAG_RELIABLE" value="1"> + Mark the packet to be sent as reliable. + </constant> + <constant name="FLAG_UNSEQUENCED" value="2"> + Mark the packet to be sent unsequenced (unreliable). + </constant> + <constant name="FLAG_UNRELIABLE_FRAGMENT" value="8"> + Mark the packet to be sent unreliable even if the packet is too big and needs fragmentation (increasing the chance of it being dropped). + </constant> + </constants> +</class> diff --git a/modules/enet/enet_connection.cpp b/modules/enet/enet_connection.cpp new file mode 100644 index 0000000000..e833264d6a --- /dev/null +++ b/modules/enet/enet_connection.cpp @@ -0,0 +1,470 @@ +/*************************************************************************/ +/* enet_connection.cpp */ +/*************************************************************************/ +/* This file is part of: */ +/* GODOT ENGINE */ +/* https://godotengine.org */ +/*************************************************************************/ +/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2021 Godot Engine contributors (cf. AUTHORS.md). */ +/* */ +/* 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. */ +/*************************************************************************/ + +#include "enet_connection.h" + +#include "enet_packet_peer.h" + +#include "core/io/compression.h" +#include "core/io/ip.h" + +void ENetConnection::broadcast(enet_uint8 p_channel, ENetPacket *p_packet) { + ERR_FAIL_COND_MSG(!host, "The ENetConnection instance isn't currently active."); + ERR_FAIL_COND_MSG(p_channel >= host->channelLimit, vformat("Unable to send packet on channel %d, max channels: %d", p_channel, (int)host->channelLimit)); + enet_host_broadcast(host, p_channel, p_packet); +} + +Error ENetConnection::create_host_bound(const IPAddress &p_bind_address, int p_port, int p_max_peers, int p_max_channels, int p_in_bandwidth, int p_out_bandwidth) { + ERR_FAIL_COND_V_MSG(!p_bind_address.is_valid() && !p_bind_address.is_wildcard(), ERR_INVALID_PARAMETER, "Invalid bind IP."); + ERR_FAIL_COND_V_MSG(p_port < 0 || p_port > 65535, ERR_INVALID_PARAMETER, "The local port number must be between 0 and 65535 (inclusive)."); + + ENetAddress address; + memset(&address, 0, sizeof(address)); + address.port = p_port; +#ifdef GODOT_ENET + if (p_bind_address.is_wildcard()) { + address.wildcard = 1; + } else { + enet_address_set_ip(&address, p_bind_address.get_ipv6(), 16); + } +#else + if (p_bind_address.is_wildcard()) { + address.host = 0; + } else { + ERR_FAIL_COND_V(!p_bind_address.is_ipv4(), ERR_INVALID_PARAMETER); + address.host = *(uint32_t *)p_bind_address.get_ipv4(); + } +#endif + return _create(&address, p_max_peers, p_max_channels, p_in_bandwidth, p_out_bandwidth); +} + +Error ENetConnection::create_host(int p_max_peers, int p_max_channels, int p_in_bandwidth, int p_out_bandwidth) { + return _create(nullptr, p_max_peers, p_max_channels, p_in_bandwidth, p_out_bandwidth); +} + +void ENetConnection::destroy() { + ERR_FAIL_COND_MSG(!host, "Host already destroyed"); + for (List<Ref<ENetPacketPeer>>::Element *E = peers.front(); E; E = E->next()) { + E->get()->_on_disconnect(); + } + peers.clear(); + enet_host_destroy(host); + host = nullptr; +} + +Ref<ENetPacketPeer> ENetConnection::connect_to_host(const String &p_address, int p_port, int p_channels, int p_data) { + Ref<ENetPacketPeer> out; + ERR_FAIL_COND_V_MSG(!host, out, "The ENetConnection instance isn't currently active."); + ERR_FAIL_COND_V_MSG(peers.size(), out, "The ENetConnection is already connected to a peer."); + ERR_FAIL_COND_V_MSG(p_port < 1 || p_port > 65535, out, "The remote port number must be between 1 and 65535 (inclusive)."); + + IPAddress ip; + if (p_address.is_valid_ip_address()) { + ip = p_address; + } else { +#ifdef GODOT_ENET + ip = IP::get_singleton()->resolve_hostname(p_address); +#else + ip = IP::get_singleton()->resolve_hostname(p_address, IP::TYPE_IPV4); +#endif + ERR_FAIL_COND_V_MSG(!ip.is_valid(), out, "Couldn't resolve the server IP address or domain name."); + } + + ENetAddress address; +#ifdef GODOT_ENET + enet_address_set_ip(&address, ip.get_ipv6(), 16); +#else + ERR_FAIL_COND_V_MSG(!ip.is_ipv4(), out, "Connecting to an IPv6 server isn't supported when using vanilla ENet. Recompile Godot with the bundled ENet library."); + address.host = *(uint32_t *)ip.get_ipv4(); +#endif + address.port = p_port; + + // Initiate connection, allocating enough channels + ENetPeer *peer = enet_host_connect(host, &address, p_channels > 0 ? p_channels : ENET_PROTOCOL_MAXIMUM_CHANNEL_COUNT, p_data); + + if (peer == nullptr) { + return nullptr; + } + out = Ref<ENetPacketPeer>(memnew(ENetPacketPeer(peer))); + peers.push_back(out); + return out; +} + +ENetConnection::EventType ENetConnection::service(int p_timeout, Event &r_event) { + ERR_FAIL_COND_V_MSG(!host, EVENT_ERROR, "The ENetConnection instance isn't currently active."); + ERR_FAIL_COND_V(r_event.peer.is_valid(), EVENT_ERROR); + + // Drop peers that have already been disconnected. + // NOTE: Forcibly disconnected peers (i.e. peers disconnected via + // enet_peer_disconnect*) do not trigger DISCONNECTED events. + List<Ref<ENetPacketPeer>>::Element *E = peers.front(); + while (E) { + if (!E->get()->is_active()) { + peers.erase(E->get()); + } + E = E->next(); + } + + ENetEvent event; + int ret = enet_host_service(host, &event, p_timeout); + + if (ret < 0) { + return EVENT_ERROR; + } else if (ret == 0) { + return EVENT_NONE; + } + switch (event.type) { + case ENET_EVENT_TYPE_CONNECT: { + if (event.peer->data == nullptr) { + Ref<ENetPacketPeer> pp = memnew(ENetPacketPeer(event.peer)); + peers.push_back(pp); + } + r_event.peer = Ref<ENetPacketPeer>((ENetPacketPeer *)event.peer->data); + r_event.data = event.data; + return EVENT_CONNECT; + } break; + case ENET_EVENT_TYPE_DISCONNECT: { + // A peer disconnected. + if (event.peer->data != nullptr) { + Ref<ENetPacketPeer> pp = Ref<ENetPacketPeer>((ENetPacketPeer *)event.peer->data); + pp->_on_disconnect(); + peers.erase(pp); + r_event.peer = pp; + r_event.data = event.data; + return EVENT_DISCONNECT; + } + return EVENT_ERROR; + } break; + case ENET_EVENT_TYPE_RECEIVE: { + // Packet reveived. + if (event.peer->data != nullptr) { + Ref<ENetPacketPeer> pp = Ref<ENetPacketPeer>((ENetPacketPeer *)event.peer->data); + r_event.peer = Ref<ENetPacketPeer>((ENetPacketPeer *)event.peer->data); + r_event.channel_id = event.channelID; + r_event.packet = event.packet; + return EVENT_RECEIVE; + } + return EVENT_ERROR; + } break; + case ENET_EVENT_TYPE_NONE: + return EVENT_NONE; + default: + return EVENT_NONE; + } +} + +void ENetConnection::flush() { + ERR_FAIL_COND_MSG(!host, "The ENetConnection instance isn't currently active."); + enet_host_flush(host); +} + +void ENetConnection::bandwidth_limit(int p_in_bandwidth, int p_out_bandwidth) { + ERR_FAIL_COND_MSG(!host, "The ENetConnection instance isn't currently active."); + enet_host_bandwidth_limit(host, p_in_bandwidth, p_out_bandwidth); +} + +void ENetConnection::channel_limit(int p_max_channels) { + ERR_FAIL_COND_MSG(!host, "The ENetConnection instance isn't currently active."); + enet_host_channel_limit(host, p_max_channels); +} + +void ENetConnection::bandwidth_throttle() { + ERR_FAIL_COND_MSG(!host, "The ENetConnection instance isn't currently active."); + enet_host_bandwidth_throttle(host); +} + +void ENetConnection::compress(CompressionMode p_mode) { + ERR_FAIL_COND_MSG(!host, "The ENetConnection instance isn't currently active."); + Compressor::setup(host, p_mode); +} + +double ENetConnection::pop_statistic(HostStatistic p_stat) { + ERR_FAIL_COND_V_MSG(!host, 0, "The ENetConnection instance isn't currently active."); + uint32_t *ptr = nullptr; + switch (p_stat) { + case HOST_TOTAL_SENT_DATA: + ptr = &(host->totalSentData); + break; + case HOST_TOTAL_SENT_PACKETS: + ptr = &(host->totalSentPackets); + break; + case HOST_TOTAL_RECEIVED_DATA: + ptr = &(host->totalReceivedData); + break; + case HOST_TOTAL_RECEIVED_PACKETS: + ptr = &(host->totalReceivedPackets); + break; + } + ERR_FAIL_COND_V_MSG(ptr == nullptr, 0, "Invalid statistic: " + itos(p_stat)); + uint32_t ret = *ptr; + *ptr = 0; + return ret; +} + +int ENetConnection::get_max_channels() const { + ERR_FAIL_COND_V_MSG(!host, 0, "The ENetConnection instance isn't currently active."); + return host->channelLimit; +} + +int ENetConnection::get_local_port() const { + ERR_FAIL_COND_V_MSG(!host, 0, "The ENetConnection instance isn't currently active."); + ERR_FAIL_COND_V_MSG(!(host->socket), 0, "The ENetConnection instance isn't currently bound"); + ENetAddress address; + ERR_FAIL_COND_V_MSG(enet_socket_get_address(host->socket, &address), 0, "Unable to get socket address"); + return address.port; +} + +void ENetConnection::get_peers(List<Ref<ENetPacketPeer>> &r_peers) { + for (const Ref<ENetPacketPeer> &I : peers) { + r_peers.push_back(I); + } +} + +Array ENetConnection::_get_peers() { + ERR_FAIL_COND_V_MSG(!host, Array(), "The ENetConnection instance isn't currently active."); + Array out; + for (const Ref<ENetPacketPeer> &I : peers) { + out.push_back(I); + } + return out; +} + +Error ENetConnection::dtls_server_setup(Ref<CryptoKey> p_key, Ref<X509Certificate> p_cert) { +#ifdef GODOT_ENET + ERR_FAIL_COND_V_MSG(!host, ERR_UNCONFIGURED, "The ENetConnection instance isn't currently active."); + return enet_host_dtls_server_setup(host, p_key.ptr(), p_cert.ptr()) ? FAILED : OK; +#else + ERR_FAIL_V_MSG(ERR_UNAVAILABLE, "ENet DTLS support not available in this build."); +#endif +} + +void ENetConnection::refuse_new_connections(bool p_refuse) { +#ifdef GODOT_ENET + ERR_FAIL_COND_MSG(!host, "The ENetConnection instance isn't currently active."); + enet_host_refuse_new_connections(host, p_refuse); +#else + ERR_FAIL_MSG("ENet DTLS support not available in this build."); +#endif +} + +Error ENetConnection::dtls_client_setup(Ref<X509Certificate> p_cert, const String &p_hostname, bool p_verify) { +#ifdef GODOT_ENET + ERR_FAIL_COND_V_MSG(!host, ERR_UNCONFIGURED, "The ENetConnection instance isn't currently active."); + return enet_host_dtls_client_setup(host, p_cert.ptr(), p_verify, p_hostname.utf8().get_data()) ? FAILED : OK; +#else + ERR_FAIL_V_MSG(ERR_UNAVAILABLE, "ENet DTLS support not available in this build."); +#endif +} + +Error ENetConnection::_create(ENetAddress *p_address, int p_max_peers, int p_max_channels, int p_in_bandwidth, int p_out_bandwidth) { + ERR_FAIL_COND_V_MSG(host != nullptr, ERR_ALREADY_IN_USE, "The ENetConnection instance is already active."); + ERR_FAIL_COND_V_MSG(p_max_peers < 1 || p_max_peers > 4095, ERR_INVALID_PARAMETER, "The number of clients must be set between 1 and 4095 (inclusive)."); + ERR_FAIL_COND_V_MSG(p_max_channels < 0 || p_max_channels > ENET_PROTOCOL_MAXIMUM_CHANNEL_COUNT, ERR_INVALID_PARAMETER, "Invalid channel count. Must be between 0 and 255 (0 means maximum, i.e. 255)"); + ERR_FAIL_COND_V_MSG(p_in_bandwidth < 0, ERR_INVALID_PARAMETER, "The incoming bandwidth limit must be greater than or equal to 0 (0 disables the limit)."); + ERR_FAIL_COND_V_MSG(p_out_bandwidth < 0, ERR_INVALID_PARAMETER, "The outgoing bandwidth limit must be greater than or equal to 0 (0 disables the limit)."); + + host = enet_host_create(p_address /* the address to bind the server host to */, + p_max_peers /* allow up to p_max_peers connections */, + p_max_channels /* allow up to p_max_channel to be used */, + p_in_bandwidth /* limit incoming bandwidth if > 0 */, + p_out_bandwidth /* limit outgoing bandwidth if > 0 */); + + ERR_FAIL_COND_V_MSG(!host, ERR_CANT_CREATE, "Couldn't create an ENet host."); + return OK; +} + +Array ENetConnection::_service(int p_timeout) { + Array out; + Event event; + Ref<ENetPacketPeer> peer; + EventType ret = service(p_timeout, event); + out.push_back(ret); + out.push_back(event.peer); + out.push_back(event.data); + out.push_back(event.channel_id); + if (event.packet && event.peer.is_valid()) { + event.peer->_queue_packet(event.packet); + } + return out; +} + +void ENetConnection::_broadcast(int p_channel, PackedByteArray p_packet, int p_flags) { + ERR_FAIL_COND_MSG(!host, "The ENetConnection instance isn't currently active."); + ERR_FAIL_COND_MSG(p_channel < 0 || p_channel > (int)host->channelLimit, "Invalid channel"); + ERR_FAIL_COND_MSG(p_flags & ~ENetPacketPeer::FLAG_ALLOWED, "Invalid flags"); + ENetPacket *pkt = enet_packet_create(p_packet.ptr(), p_packet.size(), p_flags); + broadcast(p_channel, pkt); +} + +void ENetConnection::_bind_methods() { + ClassDB::bind_method(D_METHOD("create_host_bound", "bind_address", "bind_port", "max_peers", "max_channels", "in_bandwidth", "out_bandwidth"), &ENetConnection::create_host_bound, DEFVAL(32), DEFVAL(0), DEFVAL(0), DEFVAL(0)); + ClassDB::bind_method(D_METHOD("create_host", "max_peers", "max_channels", "in_bandwidth", "out_bandwidth"), &ENetConnection::create_host, DEFVAL(32), DEFVAL(0), DEFVAL(0), DEFVAL(0)); + ClassDB::bind_method(D_METHOD("destroy"), &ENetConnection::destroy); + ClassDB::bind_method(D_METHOD("connect_to_host", "address", "port", "channels", "data"), &ENetConnection::connect_to_host, DEFVAL(0), DEFVAL(0)); + ClassDB::bind_method(D_METHOD("service", "timeout"), &ENetConnection::_service, DEFVAL(0)); + ClassDB::bind_method(D_METHOD("flush"), &ENetConnection::flush); + ClassDB::bind_method(D_METHOD("bandwidth_limit", "in_bandwidth", "out_bandwidth"), &ENetConnection::bandwidth_limit, DEFVAL(0), DEFVAL(0)); + ClassDB::bind_method(D_METHOD("channel_limit", "limit"), &ENetConnection::channel_limit); + ClassDB::bind_method(D_METHOD("broadcast", "channel", "packet", "flags"), &ENetConnection::_broadcast); + ClassDB::bind_method(D_METHOD("compress", "mode"), &ENetConnection::compress); + ClassDB::bind_method(D_METHOD("dtls_server_setup", "key", "certificate"), &ENetConnection::dtls_server_setup); + ClassDB::bind_method(D_METHOD("dtls_client_setup", "certificate", "hostname", "verify"), &ENetConnection::dtls_client_setup, DEFVAL(true)); + ClassDB::bind_method(D_METHOD("refuse_new_connections", "refuse"), &ENetConnection::refuse_new_connections); + ClassDB::bind_method(D_METHOD("pop_statistic", "statistic"), &ENetConnection::pop_statistic); + ClassDB::bind_method(D_METHOD("get_max_channels"), &ENetConnection::get_max_channels); + ClassDB::bind_method(D_METHOD("get_local_port"), &ENetConnection::get_local_port); + ClassDB::bind_method(D_METHOD("get_peers"), &ENetConnection::_get_peers); + + BIND_ENUM_CONSTANT(COMPRESS_NONE); + BIND_ENUM_CONSTANT(COMPRESS_RANGE_CODER); + BIND_ENUM_CONSTANT(COMPRESS_FASTLZ); + BIND_ENUM_CONSTANT(COMPRESS_ZLIB); + BIND_ENUM_CONSTANT(COMPRESS_ZSTD); + + BIND_ENUM_CONSTANT(EVENT_ERROR); + BIND_ENUM_CONSTANT(EVENT_NONE); + BIND_ENUM_CONSTANT(EVENT_CONNECT); + BIND_ENUM_CONSTANT(EVENT_DISCONNECT); + BIND_ENUM_CONSTANT(EVENT_RECEIVE); + + BIND_ENUM_CONSTANT(HOST_TOTAL_SENT_DATA); + BIND_ENUM_CONSTANT(HOST_TOTAL_SENT_PACKETS); + BIND_ENUM_CONSTANT(HOST_TOTAL_RECEIVED_DATA); + BIND_ENUM_CONSTANT(HOST_TOTAL_RECEIVED_PACKETS); +} + +ENetConnection::~ENetConnection() { + if (host) { + destroy(); + } +} + +size_t ENetConnection::Compressor::enet_compress(void *context, const ENetBuffer *inBuffers, size_t inBufferCount, size_t inLimit, enet_uint8 *outData, size_t outLimit) { + Compressor *compressor = (Compressor *)(context); + + if (size_t(compressor->src_mem.size()) < inLimit) { + compressor->src_mem.resize(inLimit); + } + + int total = inLimit; + int ofs = 0; + while (total) { + for (size_t i = 0; i < inBufferCount; i++) { + int to_copy = MIN(total, int(inBuffers[i].dataLength)); + memcpy(&compressor->src_mem.write[ofs], inBuffers[i].data, to_copy); + ofs += to_copy; + total -= to_copy; + } + } + + Compression::Mode mode; + + switch (compressor->mode) { + case COMPRESS_FASTLZ: { + mode = Compression::MODE_FASTLZ; + } break; + case COMPRESS_ZLIB: { + mode = Compression::MODE_DEFLATE; + } break; + case COMPRESS_ZSTD: { + mode = Compression::MODE_ZSTD; + } break; + default: { + ERR_FAIL_V_MSG(0, vformat("Invalid ENet compression mode: %d", compressor->mode)); + } + } + + int req_size = Compression::get_max_compressed_buffer_size(ofs, mode); + if (compressor->dst_mem.size() < req_size) { + compressor->dst_mem.resize(req_size); + } + int ret = Compression::compress(compressor->dst_mem.ptrw(), compressor->src_mem.ptr(), ofs, mode); + + if (ret < 0) { + return 0; + } + + if (ret > int(outLimit)) { + return 0; // Do not bother + } + + memcpy(outData, compressor->dst_mem.ptr(), ret); + + return ret; +} + +size_t ENetConnection::Compressor::enet_decompress(void *context, const enet_uint8 *inData, size_t inLimit, enet_uint8 *outData, size_t outLimit) { + Compressor *compressor = (Compressor *)(context); + int ret = -1; + switch (compressor->mode) { + case COMPRESS_FASTLZ: { + ret = Compression::decompress(outData, outLimit, inData, inLimit, Compression::MODE_FASTLZ); + } break; + case COMPRESS_ZLIB: { + ret = Compression::decompress(outData, outLimit, inData, inLimit, Compression::MODE_DEFLATE); + } break; + case COMPRESS_ZSTD: { + ret = Compression::decompress(outData, outLimit, inData, inLimit, Compression::MODE_ZSTD); + } break; + default: { + } + } + if (ret < 0) { + return 0; + } else { + return ret; + } +} + +void ENetConnection::Compressor::setup(ENetHost *p_host, CompressionMode p_mode) { + ERR_FAIL_COND(!p_host); + switch (p_mode) { + case COMPRESS_NONE: { + enet_host_compress(p_host, nullptr); + } break; + case COMPRESS_RANGE_CODER: { + enet_host_compress_with_range_coder(p_host); + } break; + case COMPRESS_FASTLZ: + case COMPRESS_ZLIB: + case COMPRESS_ZSTD: { + Compressor *compressor = memnew(Compressor(p_mode)); + enet_host_compress(p_host, &(compressor->enet_compressor)); + } break; + } +} + +ENetConnection::Compressor::Compressor(CompressionMode p_mode) { + mode = p_mode; + enet_compressor.context = this; + enet_compressor.compress = enet_compress; + enet_compressor.decompress = enet_decompress; + enet_compressor.destroy = enet_compressor_destroy; +} diff --git a/modules/enet/enet_connection.h b/modules/enet/enet_connection.h new file mode 100644 index 0000000000..0f7744953e --- /dev/null +++ b/modules/enet/enet_connection.h @@ -0,0 +1,138 @@ +/*************************************************************************/ +/* enet_connection.h */ +/*************************************************************************/ +/* This file is part of: */ +/* GODOT ENGINE */ +/* https://godotengine.org */ +/*************************************************************************/ +/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2021 Godot Engine contributors (cf. AUTHORS.md). */ +/* */ +/* 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 ENET_CONNECTION_H +#define ENET_CONNECTION_H + +#include "core/object/ref_counted.h" + +#include "core/crypto/crypto.h" +#include "enet_packet_peer.h" + +#include <enet/enet.h> + +class ENetConnection : public RefCounted { + GDCLASS(ENetConnection, RefCounted); + +public: + enum CompressionMode { + COMPRESS_NONE = 0, + COMPRESS_RANGE_CODER, + COMPRESS_FASTLZ, + COMPRESS_ZLIB, + COMPRESS_ZSTD, + }; + + enum HostStatistic { + HOST_TOTAL_SENT_DATA, + HOST_TOTAL_SENT_PACKETS, + HOST_TOTAL_RECEIVED_DATA, + HOST_TOTAL_RECEIVED_PACKETS, + }; + + enum EventType { + EVENT_ERROR = -1, + EVENT_NONE = 0, + EVENT_CONNECT, + EVENT_DISCONNECT, + EVENT_RECEIVE, + }; + + struct Event { + Ref<ENetPacketPeer> peer; + enet_uint8 channel_id = 0; + enet_uint32 data = 0; + ENetPacket *packet = nullptr; + }; + +protected: + static void _bind_methods(); + +private: + ENetHost *host = nullptr; + List<Ref<ENetPacketPeer>> peers; + + Error _create(ENetAddress *p_address, int p_max_peers, int p_max_channels, int p_in_bandwidth, int p_out_bandwidth); + Array _service(int p_timeout = 0); + void _broadcast(int p_channel, PackedByteArray p_packet, int p_flags); + Array _get_peers(); + + class Compressor { + private: + CompressionMode mode = COMPRESS_NONE; + Vector<uint8_t> src_mem; + Vector<uint8_t> dst_mem; + ENetCompressor enet_compressor; + + Compressor(CompressionMode mode); + + static size_t enet_compress(void *context, const ENetBuffer *inBuffers, size_t inBufferCount, size_t inLimit, enet_uint8 *outData, size_t outLimit); + static size_t enet_decompress(void *context, const enet_uint8 *inData, size_t inLimit, enet_uint8 *outData, size_t outLimit); + static void enet_compressor_destroy(void *context) { + memdelete((Compressor *)context); + } + + public: + static void setup(ENetHost *p_host, CompressionMode p_mode); + }; + +public: + void broadcast(enet_uint8 p_channel, ENetPacket *p_packet); + Error create_host_bound(const IPAddress &p_bind_address = IPAddress("*"), int p_port = 0, int p_max_peers = 32, int p_max_channels = 0, int p_in_bandwidth = 0, int p_out_bandwidth = 0); + Error create_host(int p_max_peers = 32, int p_max_channels = 0, int p_in_bandwidth = 0, int p_out_bandwidth = 0); + void destroy(); + Ref<ENetPacketPeer> connect_to_host(const String &p_address, int p_port, int p_channels, int p_data = 0); + EventType service(int p_timeout, Event &r_event); + void flush(); + void bandwidth_limit(int p_in_bandwidth = 0, int p_out_bandwidth = 0); + void channel_limit(int p_max_channels); + void bandwidth_throttle(); + void compress(CompressionMode p_mode); + double pop_statistic(HostStatistic p_stat); + int get_max_channels() const; + + // Extras + void get_peers(List<Ref<ENetPacketPeer>> &r_peers); + int get_local_port() const; + + // Godot additions + Error dtls_server_setup(Ref<CryptoKey> p_key, Ref<X509Certificate> p_cert); + Error dtls_client_setup(Ref<X509Certificate> p_cert, const String &p_hostname, bool p_verify = true); + void refuse_new_connections(bool p_refuse); + + ENetConnection() {} + ~ENetConnection(); +}; + +VARIANT_ENUM_CAST(ENetConnection::CompressionMode); +VARIANT_ENUM_CAST(ENetConnection::EventType); +VARIANT_ENUM_CAST(ENetConnection::HostStatistic); + +#endif // ENET_CONNECTION_H diff --git a/modules/enet/enet_multiplayer_peer.cpp b/modules/enet/enet_multiplayer_peer.cpp index a9726426ad..28b6bb035a 100644 --- a/modules/enet/enet_multiplayer_peer.cpp +++ b/modules/enet/enet_multiplayer_peer.cpp @@ -46,458 +46,375 @@ void ENetMultiplayerPeer::set_target_peer(int p_peer) { } int ENetMultiplayerPeer::get_packet_peer() const { - ERR_FAIL_COND_V_MSG(!active, 1, "The multiplayer instance isn't currently active."); + ERR_FAIL_COND_V_MSG(!_is_active(), 1, "The multiplayer instance isn't currently active."); ERR_FAIL_COND_V(incoming_packets.size() == 0, 1); return incoming_packets.front()->get().from; } -int ENetMultiplayerPeer::get_packet_channel() const { - ERR_FAIL_COND_V_MSG(!active, -1, "The multiplayer instance isn't currently active."); - ERR_FAIL_COND_V(incoming_packets.size() == 0, -1); - - return incoming_packets.front()->get().channel; -} - -int ENetMultiplayerPeer::get_last_packet_channel() const { - ERR_FAIL_COND_V_MSG(!active, -1, "The multiplayer instance isn't currently active."); - ERR_FAIL_COND_V(!current_packet.packet, -1); +Error ENetMultiplayerPeer::create_server(int p_port, int p_max_clients, int p_max_channels, int p_in_bandwidth, int p_out_bandwidth) { + ERR_FAIL_COND_V_MSG(_is_active(), ERR_ALREADY_IN_USE, "The multiplayer instance is already active."); + Ref<ENetConnection> host; + host.instantiate(); + Error err = host->create_host_bound(bind_ip, p_port, p_max_clients, 0, p_max_channels > 0 ? p_max_channels + SYSCH_MAX : 0, p_out_bandwidth); + if (err != OK) { + return err; + } - return current_packet.channel; + active_mode = MODE_SERVER; + refuse_connections = false; + unique_id = 1; + connection_status = CONNECTION_CONNECTED; + hosts[0] = host; + return OK; } -Error ENetMultiplayerPeer::create_server(int p_port, int p_max_clients, int p_in_bandwidth, int p_out_bandwidth) { - ERR_FAIL_COND_V_MSG(active, ERR_ALREADY_IN_USE, "The multiplayer instance is already active."); - ERR_FAIL_COND_V_MSG(p_port < 0 || p_port > 65535, ERR_INVALID_PARAMETER, "The local port number must be between 0 and 65535 (inclusive)."); - ERR_FAIL_COND_V_MSG(p_max_clients < 1 || p_max_clients > 4095, ERR_INVALID_PARAMETER, "The number of clients must be set between 1 and 4095 (inclusive)."); - ERR_FAIL_COND_V_MSG(p_in_bandwidth < 0, ERR_INVALID_PARAMETER, "The incoming bandwidth limit must be greater than or equal to 0 (0 disables the limit)."); - ERR_FAIL_COND_V_MSG(p_out_bandwidth < 0, ERR_INVALID_PARAMETER, "The outgoing bandwidth limit must be greater than or equal to 0 (0 disables the limit)."); - ERR_FAIL_COND_V(dtls_enabled && (dtls_key.is_null() || dtls_cert.is_null()), ERR_INVALID_PARAMETER); - - ENetAddress address; - memset(&address, 0, sizeof(address)); - -#ifdef GODOT_ENET - if (bind_ip.is_wildcard()) { - address.wildcard = 1; +Error ENetMultiplayerPeer::create_client(const String &p_address, int p_port, int p_channel_count, int p_in_bandwidth, int p_out_bandwidth, int p_local_port) { + ERR_FAIL_COND_V_MSG(_is_active(), ERR_ALREADY_IN_USE, "The multiplayer instance is already active."); + Ref<ENetConnection> host; + host.instantiate(); + Error err; + if (p_local_port) { + err = host->create_host_bound(bind_ip, p_local_port, 1, 0, p_in_bandwidth, p_out_bandwidth); } else { - enet_address_set_ip(&address, bind_ip.get_ipv6(), 16); + err = host->create_host(1, 0, p_in_bandwidth, p_out_bandwidth); } -#else - if (bind_ip.is_wildcard()) { - address.host = 0; - } else { - ERR_FAIL_COND_V(!bind_ip.is_ipv4(), ERR_INVALID_PARAMETER); - address.host = *(uint32_t *)bind_ip.get_ipv4(); + if (err != OK) { + return err; } -#endif - address.port = p_port; - host = enet_host_create(&address /* the address to bind the server host to */, - p_max_clients /* allow up to 32 clients and/or outgoing connections */, - channel_count /* allow up to channel_count to be used */, - p_in_bandwidth /* limit incoming bandwidth if > 0 */, - p_out_bandwidth /* limit outgoing bandwidth if > 0 */); + unique_id = generate_unique_id(); - ERR_FAIL_COND_V_MSG(!host, ERR_CANT_CREATE, "Couldn't create an ENet multiplayer server."); -#ifdef GODOT_ENET - if (dtls_enabled) { - enet_host_dtls_server_setup(host, dtls_key.ptr(), dtls_cert.ptr()); + Ref<ENetPacketPeer> peer = host->connect_to_host(p_address, p_port, p_channel_count > 0 ? p_channel_count + SYSCH_MAX : 0, unique_id); + if (peer.is_null()) { + host->destroy(); + ERR_FAIL_V_MSG(ERR_CANT_CREATE, "Couldn't connect to the ENet multiplayer server."); } - enet_host_refuse_new_connections(host, refuse_connections); -#endif - _setup_compressor(); - active = true; - server = true; + // Need to wait for CONNECT event. + connection_status = CONNECTION_CONNECTING; + active_mode = MODE_CLIENT; refuse_connections = false; - unique_id = 1; + peers[1] = peer; + hosts[0] = host; + + return OK; +} + +Error ENetMultiplayerPeer::create_mesh(int p_id) { + ERR_FAIL_COND_V_MSG(p_id <= 0, ERR_INVALID_PARAMETER, "The unique ID must be greater then 0"); + ERR_FAIL_COND_V_MSG(_is_active(), ERR_ALREADY_IN_USE, "The multiplayer instance is already active."); + active_mode = MODE_MESH; + refuse_connections = false; + unique_id = p_id; connection_status = CONNECTION_CONNECTED; return OK; } -Error ENetMultiplayerPeer::create_client(const String &p_address, int p_port, int p_in_bandwidth, int p_out_bandwidth, int p_local_port) { - ERR_FAIL_COND_V_MSG(active, ERR_ALREADY_IN_USE, "The multiplayer instance is already active."); - ERR_FAIL_COND_V_MSG(p_port < 1 || p_port > 65535, ERR_INVALID_PARAMETER, "The remote port number must be between 1 and 65535 (inclusive)."); - ERR_FAIL_COND_V_MSG(p_local_port < 0 || p_local_port > 65535, ERR_INVALID_PARAMETER, "The local port number must be between 0 and 65535 (inclusive)."); - ERR_FAIL_COND_V_MSG(p_in_bandwidth < 0, ERR_INVALID_PARAMETER, "The incoming bandwidth limit must be greater than or equal to 0 (0 disables the limit)."); - ERR_FAIL_COND_V_MSG(p_out_bandwidth < 0, ERR_INVALID_PARAMETER, "The outgoing bandwidth limit must be greater than or equal to 0 (0 disables the limit)."); - ENetAddress c_client; +Error ENetMultiplayerPeer::add_mesh_peer(int p_id, Ref<ENetConnection> p_host) { + ERR_FAIL_COND_V(p_host.is_null(), ERR_INVALID_PARAMETER); + ERR_FAIL_COND_V_MSG(active_mode != MODE_MESH, ERR_UNCONFIGURED, "The multiplayer instance is not configured as a mesh. Call 'create_mesh' first."); + List<Ref<ENetPacketPeer>> host_peers; + p_host->get_peers(host_peers); + ERR_FAIL_COND_V_MSG(host_peers.size() != 1 || host_peers[0]->get_state() != ENetPacketPeer::STATE_CONNECTED, ERR_INVALID_PARAMETER, "The provided host must have excatly one peer in the connected state."); + hosts[p_id] = p_host; + peers[p_id] = host_peers[0]; + emit_signal(SNAME("peer_connected"), p_id); + return OK; +} -#ifdef GODOT_ENET - if (bind_ip.is_wildcard()) { - c_client.wildcard = 1; - } else { - enet_address_set_ip(&c_client, bind_ip.get_ipv6(), 16); - } -#else - if (bind_ip.is_wildcard()) { - c_client.host = 0; - } else { - ERR_FAIL_COND_V_MSG(!bind_ip.is_ipv4(), ERR_INVALID_PARAMETER, "Wildcard IP addresses are only permitted in IPv4, not IPv6."); - c_client.host = *(uint32_t *)bind_ip.get_ipv4(); +bool ENetMultiplayerPeer::_poll_server() { + for (const KeyValue<int, Ref<ENetPacketPeer>> &E : peers) { + if (!(E.value->is_active())) { + emit_signal(SNAME("peer_disconnected"), E.value->get_meta(SNAME("_net_id"))); + peers.erase(E.key); + } } -#endif - - c_client.port = p_local_port; - - host = enet_host_create(&c_client /* create a client host */, - 1 /* only allow 1 outgoing connection */, - channel_count /* allow up to channel_count to be used */, - p_in_bandwidth /* limit incoming bandwidth if > 0 */, - p_out_bandwidth /* limit outgoing bandwidth if > 0 */); - - ERR_FAIL_COND_V_MSG(!host, ERR_CANT_CREATE, "Couldn't create the ENet client host."); -#ifdef GODOT_ENET - if (dtls_enabled) { - enet_host_dtls_client_setup(host, dtls_cert.ptr(), dtls_verify, p_address.utf8().get_data()); + ENetConnection::Event event; + ENetConnection::EventType ret = hosts[0]->service(0, event); + if (ret == ENetConnection::EVENT_ERROR) { + return true; } - enet_host_refuse_new_connections(host, refuse_connections); -#endif + switch (ret) { + case ENetConnection::EVENT_CONNECT: { + if (refuse_connections) { + event.peer->reset(); + return false; + } + // Client joined with invalid ID, probably trying to exploit us. + if (event.data < 2 || peers.has((int)event.data)) { + event.peer->reset(); + return false; + } + int id = event.data; + event.peer->set_meta(SNAME("_net_id"), id); + peers[id] = event.peer; - _setup_compressor(); + emit_signal(SNAME("peer_connected"), id); + if (server_relay) { + _notify_peers(id, true); + } + return false; + } + case ENetConnection::EVENT_DISCONNECT: { + int id = event.peer->get_meta(SNAME("_net_id")); + if (!peers.has(id)) { + // Never fully connected. + return false; + } - IPAddress ip; - if (p_address.is_valid_ip_address()) { - ip = p_address; - } else { -#ifdef GODOT_ENET - ip = IP::get_singleton()->resolve_hostname(p_address); -#else - ip = IP::get_singleton()->resolve_hostname(p_address, IP::TYPE_IPV4); -#endif + emit_signal(SNAME("peer_disconnected"), id); + peers.erase(id); + if (!server_relay) { + _notify_peers(id, false); + } + return false; + } + case ENetConnection::EVENT_RECEIVE: { + if (event.channel_id == SYSCH_CONFIG) { + _destroy_unused(event.packet); + ERR_FAIL_V_MSG(false, "Only server can send config messages"); + } else { + if (event.packet->dataLength < 8) { + _destroy_unused(event.packet); + ERR_FAIL_V_MSG(false, "Invalid packet size"); + } - ERR_FAIL_COND_V_MSG(!ip.is_valid(), ERR_CANT_RESOLVE, "Couldn't resolve the server IP address or domain name."); - } + uint32_t source = decode_uint32(&event.packet->data[0]); + int target = decode_uint32(&event.packet->data[4]); - ENetAddress address; -#ifdef GODOT_ENET - enet_address_set_ip(&address, ip.get_ipv6(), 16); -#else - ERR_FAIL_COND_V_MSG(!ip.is_ipv4(), ERR_INVALID_PARAMETER, "Connecting to an IPv6 server isn't supported when using vanilla ENet. Recompile Godot with the bundled ENet library."); - address.host = *(uint32_t *)ip.get_ipv4(); -#endif - address.port = p_port; + uint32_t id = event.peer->get_meta(SNAME("_net_id")); + // Someone is cheating and trying to fake the source! + if (source != id) { + _destroy_unused(event.packet); + ERR_FAIL_V_MSG(false, "Someone is cheating and trying to fake the source!"); + } - unique_id = _gen_unique_id(); + Packet packet; + packet.packet = event.packet; + packet.channel = event.channel_id; + packet.from = id; - // Initiate connection, allocating enough channels - ENetPeer *peer = enet_host_connect(host, &address, channel_count, unique_id); + // Even if relaying is disabled, these targets are valid as incoming packets. + if (target == 1 || target == 0 || target < -1) { + packet.packet->referenceCount++; + incoming_packets.push_back(packet); + } - if (peer == nullptr) { - enet_host_destroy(host); - ERR_FAIL_COND_V_MSG(!peer, ERR_CANT_CREATE, "Couldn't connect to the ENet multiplayer server."); + if (server_relay && target != 1) { + packet.packet->referenceCount++; + _relay(source, target, event.channel_id, event.packet); + packet.packet->referenceCount--; + _destroy_unused(event.packet); + } + // Destroy packet later + } + return false; + } + default: + return true; } - - // Technically safe to ignore the peer or anything else. - - connection_status = CONNECTION_CONNECTING; - active = true; - server = false; - refuse_connections = false; - - return OK; } -void ENetMultiplayerPeer::poll() { - ERR_FAIL_COND_MSG(!active, "The multiplayer instance isn't currently active."); - - _pop_current_packet(); - - ENetEvent event; - /* Keep servicing until there are no available events left in queue. */ - while (true) { - if (!host || !active) { // Might have been disconnected while emitting a notification - return; +bool ENetMultiplayerPeer::_poll_client() { + if (peers.has(1) && !peers[1]->is_active()) { + if (connection_status == CONNECTION_CONNECTED) { + // Client just disconnected from server. + emit_signal(SNAME("server_disconnected")); + } else { + emit_signal(SNAME("connection_failed")); } - - int ret = enet_host_service(host, &event, 0); - - if (ret < 0) { - // Error, do something? - break; - } else if (ret == 0) { - break; + close_connection(); + return true; + } + ENetConnection::Event event; + ENetConnection::EventType ret = hosts[0]->service(0, event); + if (ret == ENetConnection::EVENT_ERROR) { + return true; + } + switch (ret) { + case ENetConnection::EVENT_CONNECT: { + emit_signal(SNAME("peer_connected"), 1); + connection_status = CONNECTION_CONNECTED; + emit_signal(SNAME("connection_succeeded")); + return false; + } + case ENetConnection::EVENT_DISCONNECT: { + if (connection_status == CONNECTION_CONNECTED) { + // Client just disconnected from server. + emit_signal(SNAME("server_disconnected")); + } else { + emit_signal(SNAME("connection_failed")); + } + close_connection(); + return true; } + case ENetConnection::EVENT_RECEIVE: { + if (event.channel_id == SYSCH_CONFIG) { + // Config message + if (event.packet->dataLength != 8) { + _destroy_unused(event.packet); + ERR_FAIL_V(false); + } - switch (event.type) { - case ENET_EVENT_TYPE_CONNECT: { - // Store any relevant client information here. + int msg = decode_uint32(&event.packet->data[0]); + int id = decode_uint32(&event.packet->data[4]); - if (server && refuse_connections) { - enet_peer_reset(event.peer); - break; - } + switch (msg) { + case SYSMSG_ADD_PEER: { + peers[id] = Ref<ENetPacketPeer>(); + emit_signal(SNAME("peer_connected"), id); - // A client joined with an invalid ID (negative values, 0, and 1 are reserved). - // Probably trying to exploit us. - if (server && ((int)event.data < 2 || peer_map.has((int)event.data))) { - enet_peer_reset(event.peer); - ERR_CONTINUE(true); + } break; + case SYSMSG_REMOVE_PEER: { + peers.erase(id); + emit_signal(SNAME("peer_disconnected"), id); + } break; + } + _destroy_unused(event.packet); + } else { + if (event.packet->dataLength < 8) { + _destroy_unused(event.packet); + ERR_FAIL_V_MSG(false, "Invalid packet size"); } - int *new_id = memnew(int); - *new_id = event.data; + uint32_t source = decode_uint32(&event.packet->data[0]); + Packet packet; + packet.packet = event.packet; + packet.from = source; + packet.channel = event.channel_id; - if (*new_id == 0) { // Data zero is sent by server (ENet won't let you configure this). Server is always 1. - *new_id = 1; - } + packet.packet->referenceCount++; + incoming_packets.push_back(packet); + // Destroy packet later + } + return false; + } + default: + return true; + } +} - event.peer->data = new_id; - - peer_map[*new_id] = event.peer; - - connection_status = CONNECTION_CONNECTED; // If connecting, this means it connected to something! - - emit_signal("peer_connected", *new_id); - - if (server) { - // Do not notify other peers when server_relay is disabled. - if (!server_relay) { - break; - } - - // Someone connected, notify all the peers available - for (Map<int, ENetPeer *>::Element *E = peer_map.front(); E; E = E->next()) { - if (E->key() == *new_id) { - continue; - } - // Send existing peers to new peer - ENetPacket *packet = enet_packet_create(nullptr, 8, ENET_PACKET_FLAG_RELIABLE); - encode_uint32(SYSMSG_ADD_PEER, &packet->data[0]); - encode_uint32(E->key(), &packet->data[4]); - enet_peer_send(event.peer, SYSCH_CONFIG, packet); - // Send the new peer to existing peers - packet = enet_packet_create(nullptr, 8, ENET_PACKET_FLAG_RELIABLE); - encode_uint32(SYSMSG_ADD_PEER, &packet->data[0]); - encode_uint32(*new_id, &packet->data[4]); - enet_peer_send(E->get(), SYSCH_CONFIG, packet); - } - } else { - emit_signal("connection_succeeded"); +bool ENetMultiplayerPeer::_poll_mesh() { + for (const KeyValue<int, Ref<ENetPacketPeer>> &E : peers) { + if (!(E.value->is_active())) { + emit_signal(SNAME("peer_disconnected"), E.key); + peers.erase(E.key); + if (hosts.has(E.key)) { + hosts.erase(E.key); + } + } + } + bool should_stop = true; + for (KeyValue<int, Ref<ENetConnection>> &E : hosts) { + ENetConnection::Event event; + ENetConnection::EventType ret = E.value->service(0, event); + if (ret == ENetConnection::EVENT_ERROR) { + if (peers.has(E.key)) { + emit_signal(SNAME("peer_disconnected"), E.key); + peers.erase(E.key); + } + hosts.erase(E.key); + continue; + } + switch (ret) { + case ENetConnection::EVENT_CONNECT: + should_stop = false; + event.peer->reset(); + break; + case ENetConnection::EVENT_DISCONNECT: + should_stop = false; + if (peers.has(E.key)) { + emit_signal(SNAME("peer_disconnected"), E.key); + peers.erase(E.key); + } + hosts.erase(E.key); + break; + case ENetConnection::EVENT_RECEIVE: { + should_stop = false; + if (event.packet->dataLength < 8) { + _destroy_unused(event.packet); + ERR_CONTINUE_MSG(true, "Invalid packet size"); } + Packet packet; + packet.packet = event.packet; + packet.from = E.key; + packet.channel = event.channel_id; + + packet.packet->referenceCount++; + incoming_packets.push_back(packet); } break; - case ENET_EVENT_TYPE_DISCONNECT: { - // Reset the peer's client information. + default: + break; // Nothing to do + } + } + return should_stop; +} - int *id = (int *)event.peer->data; +void ENetMultiplayerPeer::poll() { + ERR_FAIL_COND_MSG(!_is_active(), "The multiplayer instance isn't currently active."); - if (!id) { - if (!server) { - emit_signal("connection_failed"); - } - // Never fully connected. - break; - } + _pop_current_packet(); - if (!server) { - // Client just disconnected from server. - emit_signal("server_disconnected"); - close_connection(); + while (true) { + switch (active_mode) { + case MODE_CLIENT: + if (_poll_client()) { return; - } else if (server_relay) { - // Server just received a client disconnect and is in relay mode, notify everyone else. - for (Map<int, ENetPeer *>::Element *E = peer_map.front(); E; E = E->next()) { - if (E->key() == *id) { - continue; - } - - ENetPacket *packet = enet_packet_create(nullptr, 8, ENET_PACKET_FLAG_RELIABLE); - encode_uint32(SYSMSG_REMOVE_PEER, &packet->data[0]); - encode_uint32(*id, &packet->data[4]); - enet_peer_send(E->get(), SYSCH_CONFIG, packet); - } } - - emit_signal("peer_disconnected", *id); - peer_map.erase(*id); - memdelete(id); - } break; - case ENET_EVENT_TYPE_RECEIVE: { - if (event.channelID == SYSCH_CONFIG) { - // Some config message - ERR_CONTINUE(event.packet->dataLength < 8); - - // Only server can send config messages - ERR_CONTINUE(server); - - int msg = decode_uint32(&event.packet->data[0]); - int id = decode_uint32(&event.packet->data[4]); - - switch (msg) { - case SYSMSG_ADD_PEER: { - peer_map[id] = nullptr; - emit_signal("peer_connected", id); - - } break; - case SYSMSG_REMOVE_PEER: { - peer_map.erase(id); - emit_signal("peer_disconnected", id); - } break; - } - - enet_packet_destroy(event.packet); - } else if (event.channelID < channel_count) { - Packet packet; - packet.packet = event.packet; - - uint32_t *id = (uint32_t *)event.peer->data; - - ERR_CONTINUE(event.packet->dataLength < 8); - - uint32_t source = decode_uint32(&event.packet->data[0]); - int target = decode_uint32(&event.packet->data[4]); - - packet.from = source; - packet.channel = event.channelID; - - if (server) { - // Someone is cheating and trying to fake the source! - ERR_CONTINUE(source != *id); - - packet.from = *id; - - if (target == 1) { - // To myself and only myself - incoming_packets.push_back(packet); - } else if (!server_relay) { - // When relaying is disabled, other destinations will only be processed by the server. - if (target == 0 || target < -1) { - incoming_packets.push_back(packet); - } - continue; - } else if (target == 0) { - // Re-send to everyone but sender :| - - incoming_packets.push_back(packet); - // And make copies for sending - for (Map<int, ENetPeer *>::Element *E = peer_map.front(); E; E = E->next()) { - if (uint32_t(E->key()) == source) { // Do not resend to self - continue; - } - - ENetPacket *packet2 = enet_packet_create(packet.packet->data, packet.packet->dataLength, packet.packet->flags); - - enet_peer_send(E->get(), event.channelID, packet2); - } - - } else if (target < 0) { - // To all but one - - // And make copies for sending - for (Map<int, ENetPeer *>::Element *E = peer_map.front(); E; E = E->next()) { - if (uint32_t(E->key()) == source || E->key() == -target) { // Do not resend to self, also do not send to excluded - continue; - } - - ENetPacket *packet2 = enet_packet_create(packet.packet->data, packet.packet->dataLength, packet.packet->flags); - - enet_peer_send(E->get(), event.channelID, packet2); - } - - if (-target != 1) { - // Server is not excluded - incoming_packets.push_back(packet); - } else { - // Server is excluded, erase packet - enet_packet_destroy(packet.packet); - } - - } else { - // To someone else, specifically - ERR_CONTINUE(!peer_map.has(target)); - enet_peer_send(peer_map[target], event.channelID, packet.packet); - } - } else { - incoming_packets.push_back(packet); - } - - // Destroy packet later - } else { - ERR_CONTINUE(true); + break; + case MODE_SERVER: + if (_poll_server()) { + return; } - - } break; - case ENET_EVENT_TYPE_NONE: { - // Do nothing - } break; + break; + case MODE_MESH: + if (_poll_mesh()) { + return; + } + break; + default: + return; } } } bool ENetMultiplayerPeer::is_server() const { - ERR_FAIL_COND_V_MSG(!active, false, "The multiplayer instance isn't currently active."); - - return server; + return active_mode == MODE_SERVER; } void ENetMultiplayerPeer::close_connection(uint32_t wait_usec) { - ERR_FAIL_COND_MSG(!active, "The multiplayer instance isn't currently active."); + ERR_FAIL_COND_MSG(!_is_active(), "The multiplayer instance isn't currently active."); _pop_current_packet(); bool peers_disconnected = false; - for (Map<int, ENetPeer *>::Element *E = peer_map.front(); E; E = E->next()) { - if (E->get()) { - enet_peer_disconnect_now(E->get(), unique_id); - int *id = (int *)(E->get()->data); - memdelete(id); + for (KeyValue<int, Ref<ENetPacketPeer>> &E : peers) { + if (E.value.is_valid() && E.value->get_state() == ENetPacketPeer::STATE_CONNECTED) { + E.value->peer_disconnect_now(unique_id); peers_disconnected = true; } } if (peers_disconnected) { - enet_host_flush(host); + for (KeyValue<int, Ref<ENetConnection>> &E : hosts) { + E.value->flush(); + } if (wait_usec > 0) { OS::get_singleton()->delay_usec(wait_usec); // Wait for disconnection packets to send } } - enet_host_destroy(host); - active = false; + active_mode = MODE_NONE; incoming_packets.clear(); - peer_map.clear(); - unique_id = 1; // Server is 1 + peers.clear(); + hosts.clear(); + unique_id = 0; connection_status = CONNECTION_DISCONNECTED; } -void ENetMultiplayerPeer::disconnect_peer(int p_peer, bool now) { - ERR_FAIL_COND_MSG(!active, "The multiplayer instance isn't currently active."); - ERR_FAIL_COND_MSG(!is_server(), "Can't disconnect a peer when not acting as a server."); - ERR_FAIL_COND_MSG(!peer_map.has(p_peer), vformat("Peer ID %d not found in the list of peers.", p_peer)); - - if (now) { - int *id = (int *)peer_map[p_peer]->data; - enet_peer_disconnect_now(peer_map[p_peer], 0); - - // enet_peer_disconnect_now doesn't generate ENET_EVENT_TYPE_DISCONNECT, - // notify everyone else, send disconnect signal & remove from peer_map like in poll() - if (server_relay) { - for (Map<int, ENetPeer *>::Element *E = peer_map.front(); E; E = E->next()) { - if (E->key() == p_peer) { - continue; - } - - ENetPacket *packet = enet_packet_create(nullptr, 8, ENET_PACKET_FLAG_RELIABLE); - encode_uint32(SYSMSG_REMOVE_PEER, &packet->data[0]); - encode_uint32(p_peer, &packet->data[4]); - enet_peer_send(E->get(), SYSCH_CONFIG, packet); - } - } - - if (id) { - memdelete(id); - } - - emit_signal("peer_disconnected", p_peer); - peer_map.erase(p_peer); - } else { - enet_peer_disconnect_later(peer_map[p_peer], 0); - } -} - int ENetMultiplayerPeer::get_available_packet_count() const { return incoming_packets.size(); } @@ -517,19 +434,17 @@ Error ENetMultiplayerPeer::get_packet(const uint8_t **r_buffer, int &r_buffer_si } Error ENetMultiplayerPeer::put_packet(const uint8_t *p_buffer, int p_buffer_size) { - ERR_FAIL_COND_V_MSG(!active, ERR_UNCONFIGURED, "The multiplayer instance isn't currently active."); + ERR_FAIL_COND_V_MSG(!_is_active(), ERR_UNCONFIGURED, "The multiplayer instance isn't currently active."); ERR_FAIL_COND_V_MSG(connection_status != CONNECTION_CONNECTED, ERR_UNCONFIGURED, "The multiplayer instance isn't currently connected to any server or client."); + ERR_FAIL_COND_V_MSG(target_peer != 0 && !peers.has(ABS(target_peer)), ERR_INVALID_PARAMETER, vformat("Invalid target peer: %d", target_peer)); + ERR_FAIL_COND_V(active_mode == MODE_CLIENT && !peers.has(1), ERR_BUG); int packet_flags = 0; int channel = SYSCH_RELIABLE; switch (transfer_mode) { case TRANSFER_MODE_UNRELIABLE: { - if (always_ordered) { - packet_flags = 0; - } else { - packet_flags = ENET_PACKET_FLAG_UNSEQUENCED; - } + packet_flags = ENET_PACKET_FLAG_UNSEQUENCED; channel = SYSCH_UNRELIABLE; } break; case TRANSFER_MODE_UNRELIABLE_ORDERED: { @@ -542,52 +457,55 @@ Error ENetMultiplayerPeer::put_packet(const uint8_t *p_buffer, int p_buffer_size } break; } - if (transfer_channel > SYSCH_CONFIG) { - channel = transfer_channel; - } - - Map<int, ENetPeer *>::Element *E = nullptr; - - if (target_peer != 0) { - E = peer_map.find(ABS(target_peer)); - ERR_FAIL_COND_V_MSG(!E, ERR_INVALID_PARAMETER, vformat("Invalid target peer: %d", target_peer)); - } - ENetPacket *packet = enet_packet_create(nullptr, p_buffer_size + 8, packet_flags); encode_uint32(unique_id, &packet->data[0]); // Source ID encode_uint32(target_peer, &packet->data[4]); // Dest ID memcpy(&packet->data[8], p_buffer, p_buffer_size); - if (server) { + if (is_server()) { if (target_peer == 0) { - enet_host_broadcast(host, channel, packet); - } else if (target_peer < 0) { - // Send to all but one - // and make copies for sending + hosts[0]->broadcast(channel, packet); + } else if (target_peer < 0) { + // Send to all but one and make copies for sending. int exclude = -target_peer; - - for (Map<int, ENetPeer *>::Element *F = peer_map.front(); F; F = F->next()) { - if (F->key() == exclude) { // Exclude packet + for (KeyValue<int, Ref<ENetPacketPeer>> &E : peers) { + if (E.key == exclude) { continue; } + E.value->send(channel, packet); + } + _destroy_unused(packet); + } else { + peers[target_peer]->send(channel, packet); + } + ERR_FAIL_COND_V(!hosts.has(0), ERR_BUG); + hosts[0]->flush(); - ENetPacket *packet2 = enet_packet_create(packet->data, packet->dataLength, packet_flags); + } else if (active_mode == MODE_CLIENT) { + peers[1]->send(channel, packet); // Send to server for broadcast. + ERR_FAIL_COND_V(!hosts.has(0), ERR_BUG); + hosts[0]->flush(); - enet_peer_send(F->get(), channel, packet2); + } else { + if (target_peer <= 0) { + int exclude = ABS(target_peer); + for (KeyValue<int, Ref<ENetPacketPeer>> &E : peers) { + if (E.key == exclude) { + continue; + } + E.value->send(channel, packet); + ERR_CONTINUE(!hosts.has(E.key)); + hosts[E.key]->flush(); } - - enet_packet_destroy(packet); // Original packet no longer needed + _destroy_unused(packet); } else { - enet_peer_send(E->get(), channel, packet); + peers[target_peer]->send(channel, packet); + ERR_FAIL_COND_V(!hosts.has(target_peer), ERR_BUG); + hosts[target_peer]->flush(); } - } else { - ERR_FAIL_COND_V(!peer_map.has(1), ERR_BUG); - enet_peer_send(peer_map[1], channel, packet); // Send to server for broadcast } - enet_host_flush(host); - return OK; } @@ -597,7 +515,8 @@ int ENetMultiplayerPeer::get_max_packet_size() const { void ENetMultiplayerPeer::_pop_current_packet() { if (current_packet.packet) { - enet_packet_destroy(current_packet.packet); + current_packet.packet->referenceCount--; + _destroy_unused(current_packet.packet); current_packet.packet = nullptr; current_packet.from = 0; current_packet.channel = -1; @@ -608,37 +527,18 @@ MultiplayerPeer::ConnectionStatus ENetMultiplayerPeer::get_connection_status() c return connection_status; } -uint32_t ENetMultiplayerPeer::_gen_unique_id() const { - uint32_t hash = 0; - - while (hash == 0 || hash == 1) { - hash = hash_djb2_one_32( - (uint32_t)OS::get_singleton()->get_ticks_usec()); - hash = hash_djb2_one_32( - (uint32_t)OS::get_singleton()->get_unix_time(), hash); - hash = hash_djb2_one_32( - (uint32_t)OS::get_singleton()->get_user_data_dir().hash64(), hash); - hash = hash_djb2_one_32( - (uint32_t)((uint64_t)this), hash); // Rely on ASLR heap - hash = hash_djb2_one_32( - (uint32_t)((uint64_t)&hash), hash); // Rely on ASLR stack - - hash = hash & 0x7FFFFFFF; // Make it compatible with unsigned, since negative ID is used for exclusion - } - - return hash; -} - int ENetMultiplayerPeer::get_unique_id() const { - ERR_FAIL_COND_V_MSG(!active, 0, "The multiplayer instance isn't currently active."); + ERR_FAIL_COND_V_MSG(!_is_active(), 0, "The multiplayer instance isn't currently active."); return unique_id; } void ENetMultiplayerPeer::set_refuse_new_connections(bool p_enable) { refuse_connections = p_enable; #ifdef GODOT_ENET - if (active) { - enet_host_refuse_new_connections(host, p_enable); + if (_is_active()) { + for (KeyValue<int, Ref<ENetConnection>> &E : hosts) { + E.value->refuse_new_connections(p_enable); + } } #endif } @@ -647,244 +547,122 @@ bool ENetMultiplayerPeer::is_refusing_new_connections() const { return refuse_connections; } -void ENetMultiplayerPeer::set_compression_mode(CompressionMode p_mode) { - compression_mode = p_mode; +void ENetMultiplayerPeer::set_server_relay_enabled(bool p_enabled) { + ERR_FAIL_COND_MSG(_is_active(), "Server relaying can't be toggled while the multiplayer instance is active."); + + server_relay = p_enabled; } -ENetMultiplayerPeer::CompressionMode ENetMultiplayerPeer::get_compression_mode() const { - return compression_mode; +bool ENetMultiplayerPeer::is_server_relay_enabled() const { + return server_relay; } -size_t ENetMultiplayerPeer::enet_compress(void *context, const ENetBuffer *inBuffers, size_t inBufferCount, size_t inLimit, enet_uint8 *outData, size_t outLimit) { - ENetMultiplayerPeer *enet = (ENetMultiplayerPeer *)(context); +Ref<ENetConnection> ENetMultiplayerPeer::get_host() const { + ERR_FAIL_COND_V(!_is_active(), nullptr); + ERR_FAIL_COND_V(active_mode == MODE_MESH, nullptr); + return hosts[0]; +} - if (size_t(enet->src_compressor_mem.size()) < inLimit) { - enet->src_compressor_mem.resize(inLimit); - } +Ref<ENetPacketPeer> ENetMultiplayerPeer::get_peer(int p_id) const { + ERR_FAIL_COND_V(!_is_active(), nullptr); + ERR_FAIL_COND_V(!peers.has(p_id), nullptr); + ERR_FAIL_COND_V(active_mode == MODE_CLIENT && p_id != 1, nullptr); + return peers[p_id]; +} - int total = inLimit; - int ofs = 0; - while (total) { - for (size_t i = 0; i < inBufferCount; i++) { - int to_copy = MIN(total, int(inBuffers[i].dataLength)); - memcpy(&enet->src_compressor_mem.write[ofs], inBuffers[i].data, to_copy); - ofs += to_copy; - total -= to_copy; - } +void ENetMultiplayerPeer::_destroy_unused(ENetPacket *p_packet) { + if (p_packet->referenceCount == 0) { + enet_packet_destroy(p_packet); } +} - Compression::Mode mode; +void ENetMultiplayerPeer::_relay(int p_from, int p_to, enet_uint8 p_channel, ENetPacket *p_packet) { + if (p_to == 0) { + // Re-send to everyone but sender :| + for (KeyValue<int, Ref<ENetPacketPeer>> &E : peers) { + if (E.key == p_from) { + continue; + } - switch (enet->compression_mode) { - case COMPRESS_FASTLZ: { - mode = Compression::MODE_FASTLZ; - } break; - case COMPRESS_ZLIB: { - mode = Compression::MODE_DEFLATE; - } break; - case COMPRESS_ZSTD: { - mode = Compression::MODE_ZSTD; - } break; - default: { - ERR_FAIL_V_MSG(0, vformat("Invalid ENet compression mode: %d", enet->compression_mode)); + E.value->send(p_channel, p_packet); } - } - - int req_size = Compression::get_max_compressed_buffer_size(ofs, mode); - if (enet->dst_compressor_mem.size() < req_size) { - enet->dst_compressor_mem.resize(req_size); - } - int ret = Compression::compress(enet->dst_compressor_mem.ptrw(), enet->src_compressor_mem.ptr(), ofs, mode); - - if (ret < 0) { - return 0; - } - - if (ret > int(outLimit)) { - return 0; // Do not bother - } - - memcpy(outData, enet->dst_compressor_mem.ptr(), ret); - - return ret; -} + } else if (p_to < 0) { + // Re-send to everyone but excluded and sender. + for (KeyValue<int, Ref<ENetPacketPeer>> &E : peers) { + if (E.key == p_from || E.key == -p_to) { // Do not resend to self, also do not send to excluded + continue; + } -size_t ENetMultiplayerPeer::enet_decompress(void *context, const enet_uint8 *inData, size_t inLimit, enet_uint8 *outData, size_t outLimit) { - ENetMultiplayerPeer *enet = (ENetMultiplayerPeer *)(context); - int ret = -1; - switch (enet->compression_mode) { - case COMPRESS_FASTLZ: { - ret = Compression::decompress(outData, outLimit, inData, inLimit, Compression::MODE_FASTLZ); - } break; - case COMPRESS_ZLIB: { - ret = Compression::decompress(outData, outLimit, inData, inLimit, Compression::MODE_DEFLATE); - } break; - case COMPRESS_ZSTD: { - ret = Compression::decompress(outData, outLimit, inData, inLimit, Compression::MODE_ZSTD); - } break; - default: { + E.value->send(p_channel, p_packet); } - } - if (ret < 0) { - return 0; } else { - return ret; + // To someone else, specifically + ERR_FAIL_COND(!peers.has(p_to)); + ENetPacket *packet = enet_packet_create(p_packet->data, p_packet->dataLength, p_packet->flags); + peers[p_to]->send(p_channel, packet); } } -void ENetMultiplayerPeer::_setup_compressor() { - switch (compression_mode) { - case COMPRESS_NONE: { - enet_host_compress(host, nullptr); - } break; - case COMPRESS_RANGE_CODER: { - enet_host_compress_with_range_coder(host); - } break; - case COMPRESS_FASTLZ: - case COMPRESS_ZLIB: - case COMPRESS_ZSTD: { - enet_host_compress(host, &enet_compressor); - } break; +void ENetMultiplayerPeer::_notify_peers(int p_id, bool p_connected) { + if (p_connected) { + ERR_FAIL_COND(!peers.has(p_id)); + // Someone connected, notify all the peers available. + Ref<ENetPacketPeer> peer = peers[p_id]; + ENetPacket *packet = enet_packet_create(nullptr, 8, ENET_PACKET_FLAG_RELIABLE); + encode_uint32(SYSMSG_ADD_PEER, &packet->data[0]); + encode_uint32(p_id, &packet->data[4]); + for (KeyValue<int, Ref<ENetPacketPeer>> &E : peers) { + if (E.key == p_id) { + continue; + } + // Send new peer to existing peer. + E.value->send(SYSCH_CONFIG, packet); + // Send existing peer to new peer. + // This packet will be automatically destroyed by ENet after send. + ENetPacket *packet2 = enet_packet_create(nullptr, 8, ENET_PACKET_FLAG_RELIABLE); + encode_uint32(SYSMSG_ADD_PEER, &packet2->data[0]); + encode_uint32(E.key, &packet2->data[4]); + peer->send(SYSCH_CONFIG, packet2); + } + _destroy_unused(packet); + } else { + // Server just received a client disconnect and is in relay mode, notify everyone else. + ENetPacket *packet = enet_packet_create(nullptr, 8, ENET_PACKET_FLAG_RELIABLE); + encode_uint32(SYSMSG_REMOVE_PEER, &packet->data[0]); + encode_uint32(p_id, &packet->data[4]); + for (KeyValue<int, Ref<ENetPacketPeer>> &E : peers) { + if (E.key == p_id) { + continue; + } + E.value->send(SYSCH_CONFIG, packet); + } + _destroy_unused(packet); } } -void ENetMultiplayerPeer::enet_compressor_destroy(void *context) { - // Nothing to do -} - -IPAddress ENetMultiplayerPeer::get_peer_address(int p_peer_id) const { - ERR_FAIL_COND_V_MSG(!peer_map.has(p_peer_id), IPAddress(), vformat("Peer ID %d not found in the list of peers.", p_peer_id)); - ERR_FAIL_COND_V_MSG(!is_server() && p_peer_id != 1, IPAddress(), "Can't get the address of peers other than the server (ID -1) when acting as a client."); - ERR_FAIL_COND_V_MSG(peer_map[p_peer_id] == nullptr, IPAddress(), vformat("Peer ID %d found in the list of peers, but is null.", p_peer_id)); - - IPAddress out; -#ifdef GODOT_ENET - out.set_ipv6((uint8_t *)&(peer_map[p_peer_id]->address.host)); -#else - out.set_ipv4((uint8_t *)&(peer_map[p_peer_id]->address.host)); -#endif - - return out; -} - -int ENetMultiplayerPeer::get_peer_port(int p_peer_id) const { - ERR_FAIL_COND_V_MSG(!peer_map.has(p_peer_id), 0, vformat("Peer ID %d not found in the list of peers.", p_peer_id)); - ERR_FAIL_COND_V_MSG(!is_server() && p_peer_id != 1, 0, "Can't get the address of peers other than the server (ID -1) when acting as a client."); - ERR_FAIL_COND_V_MSG(peer_map[p_peer_id] == nullptr, 0, vformat("Peer ID %d found in the list of peers, but is null.", p_peer_id)); -#ifdef GODOT_ENET - return peer_map[p_peer_id]->address.port; -#else - return peer_map[p_peer_id]->address.port; -#endif -} - -int ENetMultiplayerPeer::get_local_port() const { - ERR_FAIL_COND_V_MSG(!active || !host, 0, "The multiplayer instance isn't currently active."); - return host->address.port; -} - -void ENetMultiplayerPeer::set_peer_timeout(int p_peer_id, int p_timeout_limit, int p_timeout_min, int p_timeout_max) { - ERR_FAIL_COND_MSG(!peer_map.has(p_peer_id), vformat("Peer ID %d not found in the list of peers.", p_peer_id)); - ERR_FAIL_COND_MSG(!is_server() && p_peer_id != 1, "Can't change the timeout of peers other then the server when acting as a client."); - ERR_FAIL_COND_MSG(peer_map[p_peer_id] == nullptr, vformat("Peer ID %d found in the list of peers, but is null.", p_peer_id)); - ERR_FAIL_COND_MSG(p_timeout_limit > p_timeout_min || p_timeout_min > p_timeout_max, "Timeout limit must be less than minimum timeout, which itself must be less then maximum timeout"); - enet_peer_timeout(peer_map[p_peer_id], p_timeout_limit, p_timeout_min, p_timeout_max); -} - -void ENetMultiplayerPeer::set_transfer_channel(int p_channel) { - ERR_FAIL_COND_MSG(p_channel < -1 || p_channel >= channel_count, vformat("The transfer channel must be set between 0 and %d, inclusive (got %d).", channel_count - 1, p_channel)); - ERR_FAIL_COND_MSG(p_channel == SYSCH_CONFIG, vformat("The channel %d is reserved.", SYSCH_CONFIG)); - transfer_channel = p_channel; -} - -int ENetMultiplayerPeer::get_transfer_channel() const { - return transfer_channel; -} - -void ENetMultiplayerPeer::set_channel_count(int p_channel) { - ERR_FAIL_COND_MSG(active, "The channel count can't be set while the multiplayer instance is active."); - ERR_FAIL_COND_MSG(p_channel < SYSCH_MAX, vformat("The channel count must be greater than or equal to %d to account for reserved channels (got %d).", SYSCH_MAX, p_channel)); - channel_count = p_channel; -} - -int ENetMultiplayerPeer::get_channel_count() const { - return channel_count; -} - -void ENetMultiplayerPeer::set_always_ordered(bool p_ordered) { - always_ordered = p_ordered; -} - -bool ENetMultiplayerPeer::is_always_ordered() const { - return always_ordered; -} - -void ENetMultiplayerPeer::set_server_relay_enabled(bool p_enabled) { - ERR_FAIL_COND_MSG(active, "Server relaying can't be toggled while the multiplayer instance is active."); - - server_relay = p_enabled; -} - -bool ENetMultiplayerPeer::is_server_relay_enabled() const { - return server_relay; -} - void ENetMultiplayerPeer::_bind_methods() { - ClassDB::bind_method(D_METHOD("create_server", "port", "max_clients", "in_bandwidth", "out_bandwidth"), &ENetMultiplayerPeer::create_server, DEFVAL(32), DEFVAL(0), DEFVAL(0)); - ClassDB::bind_method(D_METHOD("create_client", "address", "port", "in_bandwidth", "out_bandwidth", "local_port"), &ENetMultiplayerPeer::create_client, DEFVAL(0), DEFVAL(0), DEFVAL(0)); + ClassDB::bind_method(D_METHOD("create_server", "port", "max_clients", "max_channels", "in_bandwidth", "out_bandwidth"), &ENetMultiplayerPeer::create_server, DEFVAL(32), DEFVAL(0), DEFVAL(0), DEFVAL(0)); + ClassDB::bind_method(D_METHOD("create_client", "address", "port", "channel_count", "in_bandwidth", "out_bandwidth", "local_port"), &ENetMultiplayerPeer::create_client, DEFVAL(0), DEFVAL(0), DEFVAL(0), DEFVAL(0)); + ClassDB::bind_method(D_METHOD("create_mesh", "unique_id"), &ENetMultiplayerPeer::create_mesh); + ClassDB::bind_method(D_METHOD("add_mesh_peer", "peer_id", "host"), &ENetMultiplayerPeer::add_mesh_peer); ClassDB::bind_method(D_METHOD("close_connection", "wait_usec"), &ENetMultiplayerPeer::close_connection, DEFVAL(100)); - ClassDB::bind_method(D_METHOD("disconnect_peer", "id", "now"), &ENetMultiplayerPeer::disconnect_peer, DEFVAL(false)); - ClassDB::bind_method(D_METHOD("set_compression_mode", "mode"), &ENetMultiplayerPeer::set_compression_mode); - ClassDB::bind_method(D_METHOD("get_compression_mode"), &ENetMultiplayerPeer::get_compression_mode); ClassDB::bind_method(D_METHOD("set_bind_ip", "ip"), &ENetMultiplayerPeer::set_bind_ip); - ClassDB::bind_method(D_METHOD("set_dtls_enabled", "enabled"), &ENetMultiplayerPeer::set_dtls_enabled); - ClassDB::bind_method(D_METHOD("is_dtls_enabled"), &ENetMultiplayerPeer::is_dtls_enabled); - ClassDB::bind_method(D_METHOD("set_dtls_key", "key"), &ENetMultiplayerPeer::set_dtls_key); - ClassDB::bind_method(D_METHOD("set_dtls_certificate", "certificate"), &ENetMultiplayerPeer::set_dtls_certificate); - ClassDB::bind_method(D_METHOD("set_dtls_verify_enabled", "enabled"), &ENetMultiplayerPeer::set_dtls_verify_enabled); - ClassDB::bind_method(D_METHOD("is_dtls_verify_enabled"), &ENetMultiplayerPeer::is_dtls_verify_enabled); - ClassDB::bind_method(D_METHOD("get_peer_address", "id"), &ENetMultiplayerPeer::get_peer_address); - ClassDB::bind_method(D_METHOD("get_peer_port", "id"), &ENetMultiplayerPeer::get_peer_port); - ClassDB::bind_method(D_METHOD("get_local_port"), &ENetMultiplayerPeer::get_local_port); - ClassDB::bind_method(D_METHOD("set_peer_timeout", "id", "timeout_limit", "timeout_min", "timeout_max"), &ENetMultiplayerPeer::set_peer_timeout); - - ClassDB::bind_method(D_METHOD("get_packet_channel"), &ENetMultiplayerPeer::get_packet_channel); - ClassDB::bind_method(D_METHOD("get_last_packet_channel"), &ENetMultiplayerPeer::get_last_packet_channel); - ClassDB::bind_method(D_METHOD("set_transfer_channel", "channel"), &ENetMultiplayerPeer::set_transfer_channel); - ClassDB::bind_method(D_METHOD("get_transfer_channel"), &ENetMultiplayerPeer::get_transfer_channel); - ClassDB::bind_method(D_METHOD("set_channel_count", "channels"), &ENetMultiplayerPeer::set_channel_count); - ClassDB::bind_method(D_METHOD("get_channel_count"), &ENetMultiplayerPeer::get_channel_count); - ClassDB::bind_method(D_METHOD("set_always_ordered", "ordered"), &ENetMultiplayerPeer::set_always_ordered); - ClassDB::bind_method(D_METHOD("is_always_ordered"), &ENetMultiplayerPeer::is_always_ordered); + ClassDB::bind_method(D_METHOD("set_server_relay_enabled", "enabled"), &ENetMultiplayerPeer::set_server_relay_enabled); ClassDB::bind_method(D_METHOD("is_server_relay_enabled"), &ENetMultiplayerPeer::is_server_relay_enabled); + ClassDB::bind_method(D_METHOD("get_host"), &ENetMultiplayerPeer::get_host); + ClassDB::bind_method(D_METHOD("get_peer", "id"), &ENetMultiplayerPeer::get_peer); - ADD_PROPERTY(PropertyInfo(Variant::INT, "compression_mode", PROPERTY_HINT_ENUM, "None,Range Coder,FastLZ,ZLib,ZStd"), "set_compression_mode", "get_compression_mode"); - ADD_PROPERTY(PropertyInfo(Variant::INT, "transfer_channel"), "set_transfer_channel", "get_transfer_channel"); - ADD_PROPERTY(PropertyInfo(Variant::INT, "channel_count"), "set_channel_count", "get_channel_count"); - ADD_PROPERTY(PropertyInfo(Variant::BOOL, "always_ordered"), "set_always_ordered", "is_always_ordered"); ADD_PROPERTY(PropertyInfo(Variant::BOOL, "server_relay"), "set_server_relay_enabled", "is_server_relay_enabled"); - ADD_PROPERTY(PropertyInfo(Variant::BOOL, "dtls_verify"), "set_dtls_verify_enabled", "is_dtls_verify_enabled"); - ADD_PROPERTY(PropertyInfo(Variant::BOOL, "use_dtls"), "set_dtls_enabled", "is_dtls_enabled"); - - BIND_ENUM_CONSTANT(COMPRESS_NONE); - BIND_ENUM_CONSTANT(COMPRESS_RANGE_CODER); - BIND_ENUM_CONSTANT(COMPRESS_FASTLZ); - BIND_ENUM_CONSTANT(COMPRESS_ZLIB); - BIND_ENUM_CONSTANT(COMPRESS_ZSTD); + ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "host", PROPERTY_HINT_RESOURCE_TYPE, "ENetConnection", PROPERTY_USAGE_NONE), "", "get_host"); } ENetMultiplayerPeer::ENetMultiplayerPeer() { - enet_compressor.context = this; - enet_compressor.compress = enet_compress; - enet_compressor.decompress = enet_decompress; - enet_compressor.destroy = enet_compressor_destroy; - bind_ip = IPAddress("*"); } ENetMultiplayerPeer::~ENetMultiplayerPeer() { - if (active) { + if (_is_active()) { close_connection(); } } @@ -896,31 +674,3 @@ void ENetMultiplayerPeer::set_bind_ip(const IPAddress &p_ip) { bind_ip = p_ip; } - -void ENetMultiplayerPeer::set_dtls_enabled(bool p_enabled) { - ERR_FAIL_COND(active); - dtls_enabled = p_enabled; -} - -bool ENetMultiplayerPeer::is_dtls_enabled() const { - return dtls_enabled; -} - -void ENetMultiplayerPeer::set_dtls_verify_enabled(bool p_enabled) { - ERR_FAIL_COND(active); - dtls_verify = p_enabled; -} - -bool ENetMultiplayerPeer::is_dtls_verify_enabled() const { - return dtls_verify; -} - -void ENetMultiplayerPeer::set_dtls_key(Ref<CryptoKey> p_key) { - ERR_FAIL_COND(active); - dtls_key = p_key; -} - -void ENetMultiplayerPeer::set_dtls_certificate(Ref<X509Certificate> p_cert) { - ERR_FAIL_COND(active); - dtls_cert = p_cert; -} diff --git a/modules/enet/enet_multiplayer_peer.h b/modules/enet/enet_multiplayer_peer.h index e6d45eb16a..703396d0cb 100644 --- a/modules/enet/enet_multiplayer_peer.h +++ b/modules/enet/enet_multiplayer_peer.h @@ -32,23 +32,14 @@ #define NETWORKED_MULTIPLAYER_ENET_H #include "core/crypto/crypto.h" -#include "core/io/compression.h" #include "core/io/multiplayer_peer.h" +#include "enet_connection.h" #include <enet/enet.h> class ENetMultiplayerPeer : public MultiplayerPeer { GDCLASS(ENetMultiplayerPeer, MultiplayerPeer); -public: - enum CompressionMode { - COMPRESS_NONE, - COMPRESS_RANGE_CODER, - COMPRESS_FASTLZ, - COMPRESS_ZLIB, - COMPRESS_ZSTD - }; - private: enum { SYSMSG_ADD_PEER, @@ -62,27 +53,27 @@ private: SYSCH_MAX }; - bool active = false; - bool server = false; + enum Mode { + MODE_NONE, + MODE_SERVER, + MODE_CLIENT, + MODE_MESH, + }; + + Mode active_mode = MODE_NONE; uint32_t unique_id = 0; int target_peer = 0; TransferMode transfer_mode = TRANSFER_MODE_RELIABLE; - int transfer_channel = -1; - int channel_count = SYSCH_MAX; - bool always_ordered = false; - - ENetEvent event; - ENetPeer *peer = nullptr; - ENetHost *host = nullptr; bool refuse_connections = false; bool server_relay = true; ConnectionStatus connection_status = CONNECTION_DISCONNECTED; - Map<int, ENetPeer *> peer_map; + Map<int, Ref<ENetConnection>> hosts; + Map<int, Ref<ENetPacketPeer>> peers; struct Packet { ENetPacket *packet = nullptr; @@ -90,31 +81,21 @@ private: int channel = 0; }; - CompressionMode compression_mode = COMPRESS_NONE; - List<Packet> incoming_packets; Packet current_packet; - uint32_t _gen_unique_id() const; void _pop_current_packet(); - - Vector<uint8_t> src_compressor_mem; - Vector<uint8_t> dst_compressor_mem; - - ENetCompressor enet_compressor; - static size_t enet_compress(void *context, const ENetBuffer *inBuffers, size_t inBufferCount, size_t inLimit, enet_uint8 *outData, size_t outLimit); - static size_t enet_decompress(void *context, const enet_uint8 *inData, size_t inLimit, enet_uint8 *outData, size_t outLimit); - static void enet_compressor_destroy(void *context); - void _setup_compressor(); + bool _poll_server(); + bool _poll_client(); + bool _poll_mesh(); + void _relay(int p_from, int p_to, enet_uint8 p_channel, ENetPacket *p_packet); + void _notify_peers(int p_id, bool p_connected); + void _destroy_unused(ENetPacket *p_packet); + _FORCE_INLINE_ bool _is_active() const { return active_mode != MODE_NONE; } IPAddress bind_ip; - bool dtls_enabled = false; - Ref<CryptoKey> dtls_key; - Ref<X509Certificate> dtls_cert; - bool dtls_verify = true; - protected: static void _bind_methods(); @@ -125,13 +106,10 @@ public: virtual int get_packet_peer() const override; - virtual IPAddress get_peer_address(int p_peer_id) const; - virtual int get_peer_port(int p_peer_id) const; - virtual int get_local_port() const; - void set_peer_timeout(int p_peer_id, int p_timeout_limit, int p_timeout_min, int p_timeout_max); - - Error create_server(int p_port, int p_max_clients = 32, int p_in_bandwidth = 0, int p_out_bandwidth = 0); - Error create_client(const String &p_address, int p_port, int p_in_bandwidth = 0, int p_out_bandwidth = 0, int p_local_port = 0); + Error create_server(int p_port, int p_max_clients = 32, int p_max_channels = 0, int p_in_bandwidth = 0, int p_out_bandwidth = 0); + Error create_client(const String &p_address, int p_port, int p_channel_count = 0, int p_in_bandwidth = 0, int p_out_bandwidth = 0, int p_local_port = 0); + Error create_mesh(int p_id); + Error add_mesh_peer(int p_id, Ref<ENetConnection> p_host); void close_connection(uint32_t wait_usec = 100); @@ -154,32 +132,15 @@ public: virtual int get_unique_id() const override; - void set_compression_mode(CompressionMode p_mode); - CompressionMode get_compression_mode() const; - - int get_packet_channel() const; - int get_last_packet_channel() const; - void set_transfer_channel(int p_channel); - int get_transfer_channel() const; - void set_channel_count(int p_channel); - int get_channel_count() const; - void set_always_ordered(bool p_ordered); - bool is_always_ordered() const; + void set_bind_ip(const IPAddress &p_ip); void set_server_relay_enabled(bool p_enabled); bool is_server_relay_enabled() const; + Ref<ENetConnection> get_host() const; + Ref<ENetPacketPeer> get_peer(int p_id) const; + ENetMultiplayerPeer(); ~ENetMultiplayerPeer(); - - void set_bind_ip(const IPAddress &p_ip); - void set_dtls_enabled(bool p_enabled); - bool is_dtls_enabled() const; - void set_dtls_verify_enabled(bool p_enabled); - bool is_dtls_verify_enabled() const; - void set_dtls_key(Ref<CryptoKey> p_key); - void set_dtls_certificate(Ref<X509Certificate> p_cert); }; -VARIANT_ENUM_CAST(ENetMultiplayerPeer::CompressionMode); - #endif // NETWORKED_MULTIPLAYER_ENET_H diff --git a/modules/enet/enet_packet_peer.cpp b/modules/enet/enet_packet_peer.cpp new file mode 100644 index 0000000000..d7d2ec9ebe --- /dev/null +++ b/modules/enet/enet_packet_peer.cpp @@ -0,0 +1,263 @@ +/*************************************************************************/ +/* enet_packet_peer.cpp */ +/*************************************************************************/ +/* This file is part of: */ +/* GODOT ENGINE */ +/* https://godotengine.org */ +/*************************************************************************/ +/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2021 Godot Engine contributors (cf. AUTHORS.md). */ +/* */ +/* 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. */ +/*************************************************************************/ + +#include "enet_packet_peer.h" + +void ENetPacketPeer::peer_disconnect(int p_data) { + ERR_FAIL_COND(!peer); + enet_peer_disconnect(peer, p_data); +} + +void ENetPacketPeer::peer_disconnect_later(int p_data) { + ERR_FAIL_COND(!peer); + enet_peer_disconnect_later(peer, p_data); +} + +void ENetPacketPeer::peer_disconnect_now(int p_data) { + ERR_FAIL_COND(!peer); + enet_peer_disconnect_now(peer, p_data); + _on_disconnect(); +} + +void ENetPacketPeer::ping() { + ERR_FAIL_COND(!peer); + enet_peer_ping(peer); +} + +void ENetPacketPeer::ping_interval(int p_interval) { + ERR_FAIL_COND(!peer); + enet_peer_ping_interval(peer, p_interval); +} + +int ENetPacketPeer::send(uint8_t p_channel, ENetPacket *p_packet) { + ERR_FAIL_COND_V(peer == nullptr, -1); + ERR_FAIL_COND_V(p_packet == nullptr, -1); + ERR_FAIL_COND_V_MSG(p_channel >= peer->channelCount, -1, vformat("Unable to send packet on channel %d, max channels: %d", p_channel, (int)peer->channelCount)); + return enet_peer_send(peer, p_channel, p_packet); +} + +void ENetPacketPeer::reset() { + ERR_FAIL_COND_MSG(peer == nullptr, "Peer not connected"); + enet_peer_reset(peer); + _on_disconnect(); +} + +void ENetPacketPeer::throttle_configure(int p_interval, int p_acceleration, int p_deceleration) { + ERR_FAIL_COND_MSG(peer == nullptr, "Peer not connected"); + enet_peer_throttle_configure(peer, p_interval, p_acceleration, p_deceleration); +} + +void ENetPacketPeer::set_timeout(int p_timeout, int p_timeout_min, int p_timeout_max) { + ERR_FAIL_COND_MSG(peer == nullptr, "Peer not connected"); + ERR_FAIL_COND_MSG(p_timeout > p_timeout_min || p_timeout_min > p_timeout_max, "Timeout limit must be less than minimum timeout, which itself must be less then maximum timeout"); + enet_peer_timeout(peer, p_timeout, p_timeout_min, p_timeout_max); +} + +int ENetPacketPeer::get_max_packet_size() const { + return 1 << 24; +} + +int ENetPacketPeer::get_available_packet_count() const { + return packet_queue.size(); +} + +Error ENetPacketPeer::get_packet(const uint8_t **r_buffer, int &r_buffer_size) { + ERR_FAIL_COND_V(!peer, ERR_UNCONFIGURED); + ERR_FAIL_COND_V(!packet_queue.size(), ERR_UNAVAILABLE); + if (last_packet) { + enet_packet_destroy(last_packet); + last_packet = nullptr; + } + last_packet = packet_queue.front()->get(); + packet_queue.pop_front(); + *r_buffer = (const uint8_t *)(last_packet->data); + r_buffer_size = last_packet->dataLength; + return OK; +} + +Error ENetPacketPeer::put_packet(const uint8_t *p_buffer, int p_buffer_size) { + ERR_FAIL_COND_V(!peer, ERR_UNCONFIGURED); + ENetPacket *packet = enet_packet_create(p_buffer, p_buffer_size, ENET_PACKET_FLAG_RELIABLE); + return send(0, packet) < 0 ? FAILED : OK; +} + +IPAddress ENetPacketPeer::get_remote_address() const { + ERR_FAIL_COND_V(!peer, IPAddress()); + IPAddress out; +#ifdef GODOT_ENET + out.set_ipv6((uint8_t *)&(peer->address.host)); +#else + out.set_ipv4((uint8_t *)&(peer->address.host)); +#endif + return out; +} + +int ENetPacketPeer::get_remote_port() const { + ERR_FAIL_COND_V(!peer, 0); + return peer->address.port; +} + +bool ENetPacketPeer::is_active() const { + return peer != nullptr; +} + +double ENetPacketPeer::get_statistic(PeerStatistic p_stat) { + ERR_FAIL_COND_V(!peer, 0); + switch (p_stat) { + case PEER_PACKET_LOSS: + return peer->packetLoss; + case PEER_PACKET_LOSS_VARIANCE: + return peer->packetLossVariance; + case PEER_PACKET_LOSS_EPOCH: + return peer->packetLossEpoch; + case PEER_ROUND_TRIP_TIME: + return peer->roundTripTime; + case PEER_ROUND_TRIP_TIME_VARIANCE: + return peer->roundTripTimeVariance; + case PEER_LAST_ROUND_TRIP_TIME: + return peer->lastRoundTripTime; + case PEER_LAST_ROUND_TRIP_TIME_VARIANCE: + return peer->lastRoundTripTimeVariance; + case PEER_PACKET_THROTTLE: + return peer->packetThrottle; + case PEER_PACKET_THROTTLE_LIMIT: + return peer->packetThrottleLimit; + case PEER_PACKET_THROTTLE_COUNTER: + return peer->packetThrottleCounter; + case PEER_PACKET_THROTTLE_EPOCH: + return peer->packetThrottleEpoch; + case PEER_PACKET_THROTTLE_ACCELERATION: + return peer->packetThrottleAcceleration; + case PEER_PACKET_THROTTLE_DECELERATION: + return peer->packetThrottleDeceleration; + case PEER_PACKET_THROTTLE_INTERVAL: + return peer->packetThrottleInterval; + } + ERR_FAIL_V(0); +} + +ENetPacketPeer::PeerState ENetPacketPeer::get_state() const { + if (!is_active()) { + return STATE_DISCONNECTED; + } + return (PeerState)peer->state; +} + +int ENetPacketPeer::get_channels() const { + ERR_FAIL_COND_V_MSG(!peer, 0, "The ENetConnection instance isn't currently active."); + return peer->channelCount; +} + +void ENetPacketPeer::_on_disconnect() { + if (peer) { + peer->data = nullptr; + } + peer = nullptr; +} + +void ENetPacketPeer::_queue_packet(ENetPacket *p_packet) { + ERR_FAIL_COND(!peer); + packet_queue.push_back(p_packet); +} + +Error ENetPacketPeer::_send(int p_channel, PackedByteArray p_packet, int p_flags) { + ERR_FAIL_COND_V_MSG(peer == nullptr, ERR_UNCONFIGURED, "Peer not connected"); + ERR_FAIL_COND_V_MSG(p_channel < 0 || p_channel > (int)peer->channelCount, ERR_INVALID_PARAMETER, "Invalid channel"); + ERR_FAIL_COND_V_MSG(p_flags & ~FLAG_ALLOWED, ERR_INVALID_PARAMETER, "Invalid flags"); + ENetPacket *packet = enet_packet_create(p_packet.ptr(), p_packet.size(), p_flags); + return send(p_channel, packet) == 0 ? OK : FAILED; +} + +void ENetPacketPeer::_bind_methods() { + ClassDB::bind_method(D_METHOD("peer_disconnect", "data"), &ENetPacketPeer::peer_disconnect, DEFVAL(0)); + ClassDB::bind_method(D_METHOD("peer_disconnect_later", "data"), &ENetPacketPeer::peer_disconnect_later, DEFVAL(0)); + ClassDB::bind_method(D_METHOD("peer_disconnect_now", "data"), &ENetPacketPeer::peer_disconnect_now, DEFVAL(0)); + + ClassDB::bind_method(D_METHOD("ping"), &ENetPacketPeer::ping); + ClassDB::bind_method(D_METHOD("ping_interval", "ping_interval"), &ENetPacketPeer::ping_interval); + ClassDB::bind_method(D_METHOD("reset"), &ENetPacketPeer::reset); + ClassDB::bind_method(D_METHOD("send", "channel", "packet", "flags"), &ENetPacketPeer::_send); + ClassDB::bind_method(D_METHOD("throttle_configure", "interval", "acceleration", "deceleration"), &ENetPacketPeer::throttle_configure); + ClassDB::bind_method(D_METHOD("set_timeout", "timeout", "timeout_min", "timeout_max"), &ENetPacketPeer::set_timeout); + ClassDB::bind_method(D_METHOD("get_statistic", "statistic"), &ENetPacketPeer::get_statistic); + ClassDB::bind_method(D_METHOD("get_state"), &ENetPacketPeer::get_state); + ClassDB::bind_method(D_METHOD("get_channels"), &ENetPacketPeer::get_channels); + ClassDB::bind_method(D_METHOD("is_active"), &ENetPacketPeer::is_active); + + BIND_ENUM_CONSTANT(STATE_DISCONNECTED); + BIND_ENUM_CONSTANT(STATE_CONNECTING); + BIND_ENUM_CONSTANT(STATE_ACKNOWLEDGING_CONNECT); + BIND_ENUM_CONSTANT(STATE_CONNECTION_PENDING); + BIND_ENUM_CONSTANT(STATE_CONNECTION_SUCCEEDED); + BIND_ENUM_CONSTANT(STATE_CONNECTED); + BIND_ENUM_CONSTANT(STATE_DISCONNECT_LATER); + BIND_ENUM_CONSTANT(STATE_DISCONNECTING); + BIND_ENUM_CONSTANT(STATE_ACKNOWLEDGING_DISCONNECT); + BIND_ENUM_CONSTANT(STATE_ZOMBIE); + + BIND_ENUM_CONSTANT(PEER_PACKET_LOSS); + BIND_ENUM_CONSTANT(PEER_PACKET_LOSS_VARIANCE); + BIND_ENUM_CONSTANT(PEER_PACKET_LOSS_EPOCH); + BIND_ENUM_CONSTANT(PEER_ROUND_TRIP_TIME); + BIND_ENUM_CONSTANT(PEER_ROUND_TRIP_TIME_VARIANCE); + BIND_ENUM_CONSTANT(PEER_LAST_ROUND_TRIP_TIME); + BIND_ENUM_CONSTANT(PEER_LAST_ROUND_TRIP_TIME_VARIANCE); + BIND_ENUM_CONSTANT(PEER_PACKET_THROTTLE); + BIND_ENUM_CONSTANT(PEER_PACKET_THROTTLE_LIMIT); + BIND_ENUM_CONSTANT(PEER_PACKET_THROTTLE_COUNTER); + BIND_ENUM_CONSTANT(PEER_PACKET_THROTTLE_EPOCH); + BIND_ENUM_CONSTANT(PEER_PACKET_THROTTLE_ACCELERATION); + BIND_ENUM_CONSTANT(PEER_PACKET_THROTTLE_DECELERATION); + BIND_ENUM_CONSTANT(PEER_PACKET_THROTTLE_INTERVAL); + + BIND_CONSTANT(PACKET_LOSS_SCALE); + BIND_CONSTANT(PACKET_THROTTLE_SCALE); + + BIND_CONSTANT(FLAG_RELIABLE); + BIND_CONSTANT(FLAG_UNSEQUENCED); + BIND_CONSTANT(FLAG_UNRELIABLE_FRAGMENT); +} + +ENetPacketPeer::ENetPacketPeer(ENetPeer *p_peer) { + peer = p_peer; + peer->data = this; +} + +ENetPacketPeer::~ENetPacketPeer() { + _on_disconnect(); + if (last_packet) { + enet_packet_destroy(last_packet); + last_packet = nullptr; + } + for (List<ENetPacket *>::Element *E = packet_queue.front(); E; E = E->next()) { + enet_packet_destroy(E->get()); + } + packet_queue.clear(); +} diff --git a/modules/enet/enet_packet_peer.h b/modules/enet/enet_packet_peer.h new file mode 100644 index 0000000000..9af004de2f --- /dev/null +++ b/modules/enet/enet_packet_peer.h @@ -0,0 +1,131 @@ +/*************************************************************************/ +/* enet_packet_peer.h */ +/*************************************************************************/ +/* This file is part of: */ +/* GODOT ENGINE */ +/* https://godotengine.org */ +/*************************************************************************/ +/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2021 Godot Engine contributors (cf. AUTHORS.md). */ +/* */ +/* 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 ENET_PACKET_PEER_H +#define ENET_PACKET_PEER_H + +#include "core/io/packet_peer.h" + +#include <enet/enet.h> + +class ENetPacketPeer : public PacketPeer { + GDCLASS(ENetPacketPeer, PacketPeer); + +private: + ENetPeer *peer = nullptr; + List<ENetPacket *> packet_queue; + ENetPacket *last_packet = nullptr; + + static void _bind_methods(); + Error _send(int p_channel, PackedByteArray p_packet, int p_flags); + +protected: + friend class ENetConnection; + // Internally used by ENetConnection during service, destroy, etc. + void _on_disconnect(); + void _queue_packet(ENetPacket *p_packet); + +public: + enum { + PACKET_THROTTLE_SCALE = ENET_PEER_PACKET_THROTTLE_SCALE, + PACKET_LOSS_SCALE = ENET_PEER_PACKET_LOSS_SCALE, + }; + + enum { + FLAG_RELIABLE = ENET_PACKET_FLAG_RELIABLE, + FLAG_UNSEQUENCED = ENET_PACKET_FLAG_UNSEQUENCED, + FLAG_UNRELIABLE_FRAGMENT = ENET_PACKET_FLAG_UNRELIABLE_FRAGMENT, + FLAG_ALLOWED = ENET_PACKET_FLAG_RELIABLE | ENET_PACKET_FLAG_UNSEQUENCED | ENET_PACKET_FLAG_UNRELIABLE_FRAGMENT, + }; + + enum PeerState { + STATE_DISCONNECTED = ENET_PEER_STATE_DISCONNECTED, + STATE_CONNECTING = ENET_PEER_STATE_CONNECTING, + STATE_ACKNOWLEDGING_CONNECT = ENET_PEER_STATE_ACKNOWLEDGING_CONNECT, + STATE_CONNECTION_PENDING = ENET_PEER_STATE_CONNECTION_PENDING, + STATE_CONNECTION_SUCCEEDED = ENET_PEER_STATE_CONNECTION_SUCCEEDED, + STATE_CONNECTED = ENET_PEER_STATE_CONNECTED, + STATE_DISCONNECT_LATER = ENET_PEER_STATE_DISCONNECT_LATER, + STATE_DISCONNECTING = ENET_PEER_STATE_DISCONNECTING, + STATE_ACKNOWLEDGING_DISCONNECT = ENET_PEER_STATE_ACKNOWLEDGING_DISCONNECT, + STATE_ZOMBIE = ENET_PEER_STATE_ZOMBIE, + }; + + enum PeerStatistic { + PEER_PACKET_LOSS, + PEER_PACKET_LOSS_VARIANCE, + PEER_PACKET_LOSS_EPOCH, + PEER_ROUND_TRIP_TIME, + PEER_ROUND_TRIP_TIME_VARIANCE, + PEER_LAST_ROUND_TRIP_TIME, + PEER_LAST_ROUND_TRIP_TIME_VARIANCE, + PEER_PACKET_THROTTLE, + PEER_PACKET_THROTTLE_LIMIT, + PEER_PACKET_THROTTLE_COUNTER, + PEER_PACKET_THROTTLE_EPOCH, + PEER_PACKET_THROTTLE_ACCELERATION, + PEER_PACKET_THROTTLE_DECELERATION, + PEER_PACKET_THROTTLE_INTERVAL, + }; + + int get_max_packet_size() const override; + int get_available_packet_count() const override; + Error get_packet(const uint8_t **r_buffer, int &r_buffer_size) override; ///< buffer is GONE after next get_packet + Error put_packet(const uint8_t *p_buffer, int p_buffer_size) override; + + void peer_disconnect(int p_data = 0); + void peer_disconnect_later(int p_data = 0); + void peer_disconnect_now(int p_data = 0); + + void ping(); + void ping_interval(int p_interval); + void reset(); + int send(uint8_t p_channel, ENetPacket *p_packet); + void throttle_configure(int interval, int acceleration, int deceleration); + void set_timeout(int p_timeout, int p_timeout_min, int p_timeout_max); + double get_statistic(PeerStatistic p_stat); + PeerState get_state() const; + int get_channels() const; + + // Extras + IPAddress get_remote_address() const; + int get_remote_port() const; + + // Used by ENetMultiplayer (TODO use meta? If only they where StringNames) + bool is_active() const; + + ENetPacketPeer(ENetPeer *p_peer); + ~ENetPacketPeer(); +}; + +VARIANT_ENUM_CAST(ENetPacketPeer::PeerState); +VARIANT_ENUM_CAST(ENetPacketPeer::PeerStatistic); + +#endif // ENET_PACKET_PEER_H diff --git a/modules/enet/register_types.cpp b/modules/enet/register_types.cpp index 38870316e4..7570f5b643 100644 --- a/modules/enet/register_types.cpp +++ b/modules/enet/register_types.cpp @@ -30,7 +30,9 @@ #include "register_types.h" #include "core/error/error_macros.h" +#include "enet_connection.h" #include "enet_multiplayer_peer.h" +#include "enet_packet_peer.h" static bool enet_ok = false; @@ -42,6 +44,8 @@ void register_enet_types() { } GDREGISTER_CLASS(ENetMultiplayerPeer); + GDREGISTER_VIRTUAL_CLASS(ENetPacketPeer); + GDREGISTER_CLASS(ENetConnection); } void unregister_enet_types() { diff --git a/modules/fbx/data/fbx_material.cpp b/modules/fbx/data/fbx_material.cpp index cf5d70fa5b..fb6c67f7b9 100644 --- a/modules/fbx/data/fbx_material.cpp +++ b/modules/fbx/data/fbx_material.cpp @@ -29,6 +29,10 @@ /*************************************************************************/ #include "fbx_material.h" + +// FIXME: Shouldn't depend on core_bind.h! Use DirAccessRef like the rest of +// the engine instead of _Directory. +#include "core/core_bind.h" #include "scene/resources/material.h" #include "scene/resources/texture.h" #include "tools/validation_tools.h" diff --git a/modules/fbx/data/fbx_mesh_data.cpp b/modules/fbx/data/fbx_mesh_data.cpp index 0d33b8e7c6..8b4b1e08b3 100644 --- a/modules/fbx/data/fbx_mesh_data.cpp +++ b/modules/fbx/data/fbx_mesh_data.cpp @@ -525,7 +525,7 @@ void FBXMeshData::reorganize_vertices( } const Vector3 vert_poly_normal = *nrml_arr->getptr(*pid); - if ((this_vert_poly_normal - vert_poly_normal).length_squared() > CMP_EPSILON) { + if (!vert_poly_normal.is_equal_approx(this_vert_poly_normal)) { // Yes this polygon need duplication. need_duplication = true; break; @@ -586,7 +586,7 @@ void FBXMeshData::reorganize_vertices( continue; } const Vector2 vert_poly_uv = *uvs->getptr(*pid); - if (((*this_vert_poly_uv) - vert_poly_uv).length_squared() > CMP_EPSILON) { + if (!vert_poly_uv.is_equal_approx(*this_vert_poly_uv)) { // Yes this polygon need duplication. need_duplication = true; break; diff --git a/modules/fbx/data/import_state.h b/modules/fbx/data/import_state.h index 83bc43faff..9ba60eaacf 100644 --- a/modules/fbx/data/import_state.h +++ b/modules/fbx/data/import_state.h @@ -37,7 +37,6 @@ #include "pivot_transform.h" -#include "core/core_bind.h" #include "core/io/resource_importer.h" #include "core/templates/vector.h" #include "editor/import/resource_importer_scene.h" diff --git a/modules/fbx/editor_scene_importer_fbx.h b/modules/fbx/editor_scene_importer_fbx.h index 4bb2c9d21b..4a3b78480b 100644 --- a/modules/fbx/editor_scene_importer_fbx.h +++ b/modules/fbx/editor_scene_importer_fbx.h @@ -36,7 +36,6 @@ #include "data/import_state.h" #include "tools/import_utils.h" -#include "core/core_bind.h" #include "core/io/resource_importer.h" #include "core/string/ustring.h" #include "core/templates/local_vector.h" diff --git a/modules/fbx/fbx_parser/ByteSwapper.h b/modules/fbx/fbx_parser/ByteSwapper.h index 5c16383974..08d38147d5 100644 --- a/modules/fbx/fbx_parser/ByteSwapper.h +++ b/modules/fbx/fbx_parser/ByteSwapper.h @@ -70,7 +70,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ---------------------------------------------------------------------- */ -/** @file Helper class tp perform various byte oder swappings +/** @file Helper class tp perform various byte order swappings (e.g. little to big endian) */ #ifndef BYTE_SWAPPER_H #define BYTE_SWAPPER_H diff --git a/modules/fbx/fbx_parser/FBXDocument.cpp b/modules/fbx/fbx_parser/FBXDocument.cpp index 89c69d2ee8..92c62e68b5 100644 --- a/modules/fbx/fbx_parser/FBXDocument.cpp +++ b/modules/fbx/fbx_parser/FBXDocument.cpp @@ -198,7 +198,7 @@ ObjectPtr LazyObject::LoadObject() { object.reset(new ModelLimbNode(id, element, doc, name)); } else if (strcmp(classtag.c_str(), "IKEffector") && strcmp(classtag.c_str(), "FKEffector")) { - // FK and IK effectors are not supporte + // FK and IK effectors are not supported. object.reset(new Model(id, element, doc, name)); } } else if (!strncmp(obtype, "Material", length)) { diff --git a/modules/gdnative/doc_classes/GDNative.xml b/modules/gdnative/doc_classes/GDNative.xml index 4f1530598c..e4c5d34a2c 100644 --- a/modules/gdnative/doc_classes/GDNative.xml +++ b/modules/gdnative/doc_classes/GDNative.xml @@ -8,26 +8,20 @@ </tutorials> <methods> <method name="call_native"> - <return type="Variant"> - </return> - <argument index="0" name="calling_type" type="StringName"> - </argument> - <argument index="1" name="procedure_name" type="StringName"> - </argument> - <argument index="2" name="arguments" type="Array"> - </argument> + <return type="Variant" /> + <argument index="0" name="calling_type" type="StringName" /> + <argument index="1" name="procedure_name" type="StringName" /> + <argument index="2" name="arguments" type="Array" /> <description> </description> </method> <method name="initialize"> - <return type="bool"> - </return> + <return type="bool" /> <description> </description> </method> <method name="terminate"> - <return type="bool"> - </return> + <return type="bool" /> <description> </description> </method> diff --git a/modules/gdnative/doc_classes/GDNativeLibrary.xml b/modules/gdnative/doc_classes/GDNativeLibrary.xml index 05cda05f9f..f84d4e60f3 100644 --- a/modules/gdnative/doc_classes/GDNativeLibrary.xml +++ b/modules/gdnative/doc_classes/GDNativeLibrary.xml @@ -12,15 +12,13 @@ </tutorials> <methods> <method name="get_current_dependencies" qualifiers="const"> - <return type="PackedStringArray"> - </return> + <return type="PackedStringArray" /> <description> Returns paths to all dependency libraries for the current platform and architecture. </description> </method> <method name="get_current_library_path" qualifiers="const"> - <return type="String"> - </return> + <return type="String" /> <description> Returns the path to the dynamic library file for the current platform and architecture. </description> diff --git a/modules/gdnative/doc_classes/NativeScript.xml b/modules/gdnative/doc_classes/NativeScript.xml index f2e9cac6dc..397d12a3a9 100644 --- a/modules/gdnative/doc_classes/NativeScript.xml +++ b/modules/gdnative/doc_classes/NativeScript.xml @@ -8,42 +8,34 @@ </tutorials> <methods> <method name="get_class_documentation" qualifiers="const"> - <return type="String"> - </return> + <return type="String" /> <description> Returns the documentation string that was previously set with [code]godot_nativescript_set_class_documentation[/code]. </description> </method> <method name="get_method_documentation" qualifiers="const"> - <return type="String"> - </return> - <argument index="0" name="method" type="StringName"> - </argument> + <return type="String" /> + <argument index="0" name="method" type="StringName" /> <description> Returns the documentation string that was previously set with [code]godot_nativescript_set_method_documentation[/code]. </description> </method> <method name="get_property_documentation" qualifiers="const"> - <return type="String"> - </return> - <argument index="0" name="path" type="StringName"> - </argument> + <return type="String" /> + <argument index="0" name="path" type="StringName" /> <description> Returns the documentation string that was previously set with [code]godot_nativescript_set_property_documentation[/code]. </description> </method> <method name="get_signal_documentation" qualifiers="const"> - <return type="String"> - </return> - <argument index="0" name="signal_name" type="StringName"> - </argument> + <return type="String" /> + <argument index="0" name="signal_name" type="StringName" /> <description> Returns the documentation string that was previously set with [code]godot_nativescript_set_signal_documentation[/code]. </description> </method> <method name="new" qualifiers="vararg"> - <return type="Variant"> - </return> + <return type="Variant" /> <description> Constructs a new object of the base type with a script of this type already attached. [i]Note[/i]: Any arguments passed to this function will be ignored and not passed to the native constructor function. This will change with in a future API extension. diff --git a/modules/gdnative/doc_classes/PluginScript.xml b/modules/gdnative/doc_classes/PluginScript.xml index 9616101090..8e28187482 100644 --- a/modules/gdnative/doc_classes/PluginScript.xml +++ b/modules/gdnative/doc_classes/PluginScript.xml @@ -8,8 +8,7 @@ </tutorials> <methods> <method name="new" qualifiers="vararg"> - <return type="Variant"> - </return> + <return type="Variant" /> <description> Returns a new instance of the script. </description> diff --git a/modules/gdnative/doc_classes/VideoStreamGDNative.xml b/modules/gdnative/doc_classes/VideoStreamGDNative.xml index 153988bad8..8b1a3210df 100644 --- a/modules/gdnative/doc_classes/VideoStreamGDNative.xml +++ b/modules/gdnative/doc_classes/VideoStreamGDNative.xml @@ -11,17 +11,14 @@ </tutorials> <methods> <method name="get_file"> - <return type="String"> - </return> + <return type="String" /> <description> Returns the video file handled by this [VideoStreamGDNative]. </description> </method> <method name="set_file"> - <return type="void"> - </return> - <argument index="0" name="file" type="String"> - </argument> + <return type="void" /> + <argument index="0" name="file" type="String" /> <description> Sets the video file that this [VideoStreamGDNative] resource handles. The supported extensions depend on the GDNative plugins used to expose video formats. </description> diff --git a/modules/gdnative/gdnative.cpp b/modules/gdnative/gdnative.cpp index 1ff591a87f..9445fac1c6 100644 --- a/modules/gdnative/gdnative.cpp +++ b/modules/gdnative/gdnative.cpp @@ -129,9 +129,7 @@ void GDNativeLibrary::_get_property_list(List<PropertyInfo> *p_list) const { config_file->get_section_keys("entry", &entry_key_list); } - for (List<String>::Element *E = entry_key_list.front(); E; E = E->next()) { - String key = E->get(); - + for (const String &key : entry_key_list) { PropertyInfo prop; prop.type = Variant::STRING; @@ -147,9 +145,7 @@ void GDNativeLibrary::_get_property_list(List<PropertyInfo> *p_list) const { config_file->get_section_keys("dependencies", &dependency_key_list); } - for (List<String>::Element *E = dependency_key_list.front(); E; E = E->next()) { - String key = E->get(); - + for (const String &key : dependency_key_list) { PropertyInfo prop; prop.type = Variant::STRING; @@ -175,9 +171,7 @@ void GDNativeLibrary::set_config_file(Ref<ConfigFile> p_config_file) { p_config_file->get_section_keys("entry", &entry_keys); } - for (List<String>::Element *E = entry_keys.front(); E; E = E->next()) { - String key = E->get(); - + for (const String &key : entry_keys) { Vector<String> tags = key.split("."); bool skip = false; @@ -207,9 +201,7 @@ void GDNativeLibrary::set_config_file(Ref<ConfigFile> p_config_file) { p_config_file->get_section_keys("dependencies", &dependency_keys); } - for (List<String>::Element *E = dependency_keys.front(); E; E = E->next()) { - String key = E->get(); - + for (const String &key : dependency_keys) { Vector<String> tags = key.split("."); bool skip = false; diff --git a/modules/gdnative/gdnative/variant.cpp b/modules/gdnative/gdnative/variant.cpp index cfb57137bb..1d75ea206c 100644 --- a/modules/gdnative/gdnative/variant.cpp +++ b/modules/gdnative/gdnative/variant.cpp @@ -915,8 +915,8 @@ void GDAPI godot_variant_get_builtin_method_list(godot_variant_type p_type, godo List<StringName> list; Variant::get_builtin_method_list((Variant::Type)p_type, &list); int i = 0; - for (const List<StringName>::Element *E = list.front(); E; E = E->next()) { - memnew_placement_custom(&r_list[i], StringName, StringName(E->get())); + for (const StringName &E : list) { + memnew_placement_custom(&r_list[i], StringName, StringName(E)); } } @@ -970,8 +970,8 @@ void GDAPI godot_variant_get_member_list(godot_variant_type p_type, godot_string List<StringName> members; Variant::get_member_list((Variant::Type)p_type, &members); int i = 0; - for (const List<StringName>::Element *E = members.front(); E; E = E->next()) { - memnew_placement_custom(&r_list[i++], StringName, StringName(E->get())); + for (const StringName &E : members) { + memnew_placement_custom(&r_list[i++], StringName, StringName(E)); } } @@ -1075,8 +1075,8 @@ void GDAPI godot_variant_get_constants_list(godot_variant_type p_type, godot_str List<StringName> constants; int i = 0; Variant::get_constants_for_type((Variant::Type)p_type, &constants); - for (const List<StringName>::Element *E = constants.front(); E; E = E->next()) { - memnew_placement_custom(&r_list[i++], StringName, StringName(E->get())); + for (const StringName &E : constants) { + memnew_placement_custom(&r_list[i++], StringName, StringName(E)); } } @@ -1227,8 +1227,8 @@ void GDAPI godot_variant_get_utility_function_list(godot_string_name *r_function godot_string_name *func = r_functions; Variant::get_utility_function_list(&functions); - for (const List<StringName>::Element *E = functions.front(); E; E = E->next()) { - memnew_placement_custom(func++, StringName, StringName(E->get())); + for (const StringName &E : functions) { + memnew_placement_custom(func++, StringName, StringName(E)); } } diff --git a/modules/gdnative/gdnative_library_editor_plugin.cpp b/modules/gdnative/gdnative_library_editor_plugin.cpp index bdbf151393..f965bcd014 100644 --- a/modules/gdnative/gdnative_library_editor_plugin.cpp +++ b/modules/gdnative/gdnative_library_editor_plugin.cpp @@ -74,9 +74,9 @@ void GDNativeLibraryEditor::_update_tree() { platform->set_text(0, E->get().name); platform->set_metadata(0, E->get().library_extension); - platform->set_custom_bg_color(0, get_theme_color("prop_category", "Editor")); - platform->set_custom_bg_color(1, get_theme_color("prop_category", "Editor")); - platform->set_custom_bg_color(2, get_theme_color("prop_category", "Editor")); + platform->set_custom_bg_color(0, get_theme_color(SNAME("prop_category"), SNAME("Editor"))); + platform->set_custom_bg_color(1, get_theme_color(SNAME("prop_category"), SNAME("Editor"))); + platform->set_custom_bg_color(2, get_theme_color(SNAME("prop_category"), SNAME("Editor"))); platform->set_selectable(0, false); platform->set_expand_right(0, true); @@ -87,31 +87,31 @@ void GDNativeLibraryEditor::_update_tree() { bit->set_text(0, it->get()); bit->set_metadata(0, target); bit->set_selectable(0, false); - bit->set_custom_bg_color(0, get_theme_color("prop_subsection", "Editor")); + bit->set_custom_bg_color(0, get_theme_color(SNAME("prop_subsection"), SNAME("Editor"))); - bit->add_button(1, get_theme_icon("Folder", "EditorIcons"), BUTTON_SELECT_LIBRARY, false, TTR("Select the dynamic library for this entry")); + bit->add_button(1, get_theme_icon(SNAME("Folder"), SNAME("EditorIcons")), BUTTON_SELECT_LIBRARY, false, TTR("Select the dynamic library for this entry")); String file = entry_configs[target].library; if (!file.is_empty()) { - bit->add_button(1, get_theme_icon("Clear", "EditorIcons"), BUTTON_CLEAR_LIBRARY, false, TTR("Clear")); + bit->add_button(1, get_theme_icon(SNAME("Clear"), SNAME("EditorIcons")), BUTTON_CLEAR_LIBRARY, false, TTR("Clear")); } bit->set_text(1, file); - bit->add_button(2, get_theme_icon("Folder", "EditorIcons"), BUTTON_SELECT_DEPENDENCES, false, TTR("Select dependencies of the library for this entry")); + bit->add_button(2, get_theme_icon(SNAME("Folder"), SNAME("EditorIcons")), BUTTON_SELECT_DEPENDENCES, false, TTR("Select dependencies of the library for this entry")); Array files = entry_configs[target].dependencies; if (files.size()) { - bit->add_button(2, get_theme_icon("Clear", "EditorIcons"), BUTTON_CLEAR_DEPENDENCES, false, TTR("Clear")); + bit->add_button(2, get_theme_icon(SNAME("Clear"), SNAME("EditorIcons")), BUTTON_CLEAR_DEPENDENCES, false, TTR("Clear")); } bit->set_text(2, Variant(files)); - bit->add_button(3, get_theme_icon("MoveUp", "EditorIcons"), BUTTON_MOVE_UP, false, TTR("Move Up")); - bit->add_button(3, get_theme_icon("MoveDown", "EditorIcons"), BUTTON_MOVE_DOWN, false, TTR("Move Down")); - bit->add_button(3, get_theme_icon("Remove", "EditorIcons"), BUTTON_ERASE_ENTRY, false, TTR("Remove current entry")); + bit->add_button(3, get_theme_icon(SNAME("MoveUp"), SNAME("EditorIcons")), BUTTON_MOVE_UP, false, TTR("Move Up")); + bit->add_button(3, get_theme_icon(SNAME("MoveDown"), SNAME("EditorIcons")), BUTTON_MOVE_DOWN, false, TTR("Move Down")); + bit->add_button(3, get_theme_icon(SNAME("Remove"), SNAME("EditorIcons")), BUTTON_ERASE_ENTRY, false, TTR("Remove current entry")); } TreeItem *new_arch = tree->create_item(platform); new_arch->set_text(0, TTR("Double click to create a new entry")); new_arch->set_text_align(0, TreeItem::ALIGN_CENTER); - new_arch->set_custom_color(0, get_theme_color("accent_color", "Editor")); + new_arch->set_custom_color(0, get_theme_color(SNAME("accent_color"), SNAME("Editor"))); new_arch->set_expand_right(0, true); new_arch->set_metadata(1, E->key()); diff --git a/modules/gdnative/include/net/godot_webrtc.h b/modules/gdnative/include/net/godot_webrtc.h index 25aa72dae1..52006e56ec 100644 --- a/modules/gdnative/include/net/godot_webrtc.h +++ b/modules/gdnative/include/net/godot_webrtc.h @@ -37,8 +37,8 @@ extern "C" { #endif -#define GODOT_NET_WEBRTC_API_MAJOR 3 -#define GODOT_NET_WEBRTC_API_MINOR 2 +#define GODOT_NET_WEBRTC_API_MAJOR 4 +#define GODOT_NET_WEBRTC_API_MINOR 0 /* Library Interface (used to set default GDNative WebRTC implementation */ typedef struct { @@ -101,6 +101,7 @@ typedef struct { int (*get_max_retransmits)(const void *); const char *(*get_protocol)(const void *); bool (*is_negotiated)(const void *); + int (*get_buffered_amount)(const void *); godot_error (*poll)(void *); void (*close)(void *); diff --git a/modules/gdnative/include/text/godot_text.h b/modules/gdnative/include/text/godot_text.h index 5c59de7c06..6428f2f149 100644 --- a/modules/gdnative/include/text/godot_text.h +++ b/modules/gdnative/include/text/godot_text.h @@ -150,7 +150,7 @@ typedef struct { godot_packed_glyph_array (*shaped_text_sort_logical)(void *, godot_rid *); godot_packed_vector2i_array (*shaped_text_get_line_breaks_adv)(void *, godot_rid *, godot_packed_float32_array *, int, bool, uint8_t); godot_packed_vector2i_array (*shaped_text_get_line_breaks)(void *, godot_rid *, float, int, uint8_t); - godot_packed_vector2i_array (*shaped_text_get_word_breaks)(void *, godot_rid *); + godot_packed_vector2i_array (*shaped_text_get_word_breaks)(void *, godot_rid *, int); godot_array (*shaped_text_get_objects)(void *, godot_rid *); godot_rect2 (*shaped_text_get_object_rect)(void *, godot_rid *, const godot_variant *); godot_vector2 (*shaped_text_get_size)(void *, godot_rid *); diff --git a/modules/gdnative/nativescript/api_generator.cpp b/modules/gdnative/nativescript/api_generator.cpp index 477bc9f74d..df0f29277e 100644 --- a/modules/gdnative/nativescript/api_generator.cpp +++ b/modules/gdnative/nativescript/api_generator.cpp @@ -425,11 +425,11 @@ List<ClassAPI> generate_c_api_classes() { List<EnumAPI> enums; List<StringName> enum_names; ClassDB::get_enum_list(class_name, &enum_names, true); - for (List<StringName>::Element *E = enum_names.front(); E; E = E->next()) { + for (const StringName &E : enum_names) { List<StringName> value_names; EnumAPI enum_api; - enum_api.name = E->get(); - ClassDB::get_enum_constants(class_name, E->get(), &value_names, true); + enum_api.name = E; + ClassDB::get_enum_constants(class_name, E, &value_names, true); for (List<StringName>::Element *val_e = value_names.front(); val_e; val_e = val_e->next()) { int int_val = ClassDB::get_integer_constant(class_name, val_e->get(), nullptr); enum_api.values.push_back(Pair<int, String>(int_val, val_e->get())); @@ -459,8 +459,8 @@ List<ClassAPI> generate_c_builtin_api_types() { List<StringName> utility_functions; Variant::get_utility_function_list(&utility_functions); - for (const List<StringName>::Element *E = utility_functions.front(); E; E = E->next()) { - const StringName &function_name = E->get(); + for (const StringName &E : utility_functions) { + const StringName &function_name = E; MethodAPI function_api; function_api.method_name = function_name; @@ -521,8 +521,8 @@ List<ClassAPI> generate_c_builtin_api_types() { List<StringName> methods; Variant::get_builtin_method_list(type, &methods); - for (const List<StringName>::Element *E = methods.front(); E; E = E->next()) { - const StringName &method_name = E->get(); + for (const StringName &E : methods) { + const StringName &method_name = E; MethodAPI method_api; @@ -578,8 +578,8 @@ List<ClassAPI> generate_c_builtin_api_types() { List<StringName> constants; Variant::get_constants_for_type(type, &constants); - for (const List<StringName>::Element *E = constants.front(); E; E = E->next()) { - const StringName &constant_name = E->get(); + for (const StringName &E : constants) { + const StringName &constant_name = E; ConstantAPI constant_api; constant_api.constant_name = constant_name; @@ -593,8 +593,8 @@ List<ClassAPI> generate_c_builtin_api_types() { List<StringName> members; Variant::get_member_list(type, &members); - for (const List<StringName>::Element *E = members.front(); E; E = E->next()) { - const StringName &member_name = E->get(); + for (const StringName &E : members) { + const StringName &member_name = E; PropertyAPI member_api; member_api.name = member_name; diff --git a/modules/gdnative/nativescript/nativescript.cpp b/modules/gdnative/nativescript/nativescript.cpp index d7943827c2..f3a0e9603f 100644 --- a/modules/gdnative/nativescript/nativescript.cpp +++ b/modules/gdnative/nativescript/nativescript.cpp @@ -98,10 +98,10 @@ void NativeScript::_update_placeholder(PlaceHolderScriptInstance *p_placeholder) List<PropertyInfo> info; get_script_property_list(&info); Map<StringName, Variant> values; - for (List<PropertyInfo>::Element *E = info.front(); E; E = E->next()) { + for (const PropertyInfo &E : info) { Variant value; - get_property_default_value(E->get().name, value); - values[E->get().name] = value; + get_property_default_value(E.name, value); + values[E.name] = value; } p_placeholder->update(info, values); diff --git a/modules/gdnative/register_types.cpp b/modules/gdnative/register_types.cpp index 8e5ae29ed9..a41c4f7b19 100644 --- a/modules/gdnative/register_types.cpp +++ b/modules/gdnative/register_types.cpp @@ -79,9 +79,7 @@ void GDNativeExportPlugin::_export_file(const String &p_path, const String &p_ty List<String> entry_keys; config->get_section_keys("entry", &entry_keys); - for (List<String>::Element *E = entry_keys.front(); E; E = E->next()) { - String key = E->get(); - + for (const String &key : entry_keys) { Vector<String> tags = key.split("."); bool skip = false; @@ -112,9 +110,7 @@ void GDNativeExportPlugin::_export_file(const String &p_path, const String &p_ty List<String> dependency_keys; config->get_section_keys("dependencies", &dependency_keys); - for (List<String>::Element *E = dependency_keys.front(); E; E = E->next()) { - String key = E->get(); - + for (const String &key : dependency_keys) { Vector<String> tags = key.split("."); bool skip = false; @@ -149,9 +145,7 @@ void GDNativeExportPlugin::_export_file(const String &p_path, const String &p_ty List<String> entry_keys; config->get_section_keys("entry", &entry_keys); - for (List<String>::Element *E = entry_keys.front(); E; E = E->next()) { - String key = E->get(); - + for (const String &key : entry_keys) { Vector<String> tags = key.split("."); bool skip = false; diff --git a/modules/gdnative/tests/test_variant.h b/modules/gdnative/tests/test_variant.h index 2850036604..c506882283 100644 --- a/modules/gdnative/tests/test_variant.h +++ b/modules/gdnative/tests/test_variant.h @@ -191,8 +191,8 @@ TEST_CASE("[GDNative Variant] Get utility function list") { godot_string_name *cur = c_list; - for (const List<StringName>::Element *E = cpp_list.front(); E; E = E->next()) { - const StringName &cpp_name = E->get(); + for (const StringName &E : cpp_list) { + const StringName &cpp_name = E; StringName *c_name = (StringName *)cur++; CHECK(*c_name == cpp_name); diff --git a/modules/gdnative/text/text_server_gdnative.cpp b/modules/gdnative/text/text_server_gdnative.cpp index 392121c3a9..81dd570bcb 100644 --- a/modules/gdnative/text/text_server_gdnative.cpp +++ b/modules/gdnative/text/text_server_gdnative.cpp @@ -555,15 +555,15 @@ Vector<Vector2i> TextServerGDNative::shaped_text_get_line_breaks(RID p_shaped, f } } -Vector<Vector2i> TextServerGDNative::shaped_text_get_word_breaks(RID p_shaped) const { +Vector<Vector2i> TextServerGDNative::shaped_text_get_word_breaks(RID p_shaped, int p_grapheme_flags) const { ERR_FAIL_COND_V(interface == nullptr, Vector<Vector2i>()); if (interface->shaped_text_get_word_breaks != nullptr) { - godot_packed_vector2i_array result = interface->shaped_text_get_word_breaks(data, (godot_rid *)&p_shaped); + godot_packed_vector2i_array result = interface->shaped_text_get_word_breaks(data, (godot_rid *)&p_shaped, p_grapheme_flags); Vector<Vector2i> breaks = *(Vector<Vector2i> *)&result; godot_packed_vector2i_array_destroy(&result); return breaks; } else { - return TextServer::shaped_text_get_word_breaks(p_shaped); + return TextServer::shaped_text_get_word_breaks(p_shaped, p_grapheme_flags); } } diff --git a/modules/gdnative/text/text_server_gdnative.h b/modules/gdnative/text/text_server_gdnative.h index d613a7ec00..7a0725f3d9 100644 --- a/modules/gdnative/text/text_server_gdnative.h +++ b/modules/gdnative/text/text_server_gdnative.h @@ -178,7 +178,7 @@ public: virtual Vector<Glyph> shaped_text_sort_logical(RID p_shaped) override; virtual Vector<Vector2i> shaped_text_get_line_breaks_adv(RID p_shaped, const Vector<float> &p_width, int p_start = 0, bool p_once = true, uint8_t /*TextBreakFlag*/ p_break_flags = BREAK_MANDATORY | BREAK_WORD_BOUND) const override; virtual Vector<Vector2i> shaped_text_get_line_breaks(RID p_shaped, float p_width, int p_start = 0, uint8_t p_break_flags = BREAK_MANDATORY | BREAK_WORD_BOUND) const override; - virtual Vector<Vector2i> shaped_text_get_word_breaks(RID p_shaped) const override; + virtual Vector<Vector2i> shaped_text_get_word_breaks(RID p_shaped, int p_grapheme_flags = GRAPHEME_IS_SPACE | GRAPHEME_IS_PUNCTUATION) const override; virtual Array shaped_text_get_objects(RID p_shaped) const override; virtual Rect2 shaped_text_get_object_rect(RID p_shaped, Variant p_key) const override; diff --git a/modules/gdscript/doc_classes/@GDScript.xml b/modules/gdscript/doc_classes/@GDScript.xml index 839aa6b3c6..51b3452a3a 100644 --- a/modules/gdscript/doc_classes/@GDScript.xml +++ b/modules/gdscript/doc_classes/@GDScript.xml @@ -11,16 +11,11 @@ </tutorials> <methods> <method name="Color8"> - <return type="Color"> - </return> - <argument index="0" name="r8" type="int"> - </argument> - <argument index="1" name="g8" type="int"> - </argument> - <argument index="2" name="b8" type="int"> - </argument> - <argument index="3" name="a8" type="int" default="255"> - </argument> + <return type="Color" /> + <argument index="0" name="r8" type="int" /> + <argument index="1" name="g8" type="int" /> + <argument index="2" name="b8" type="int" /> + <argument index="3" name="a8" type="int" default="255" /> <description> Returns a color constructed from integer red, green, blue, and alpha channels. Each channel should have 8 bits of information ranging from 0 to 255. [code]r8[/code] red channel @@ -33,12 +28,9 @@ </description> </method> <method name="assert"> - <return type="void"> - </return> - <argument index="0" name="condition" type="bool"> - </argument> - <argument index="1" name="message" type="String" default=""""> - </argument> + <return type="void" /> + <argument index="0" name="condition" type="bool" /> + <argument index="1" name="message" type="String" default="""" /> <description> Asserts that the [code]condition[/code] is [code]true[/code]. If the [code]condition[/code] is [code]false[/code], an error is generated. When running from the editor, the running project will also be paused until you resume it. This can be used as a stronger form of [method @GlobalScope.push_error] for reporting errors to project developers or add-on users. [b]Note:[/b] For performance reasons, the code inside [method assert] is only executed in debug builds or when running the project from the editor. Don't include code that has side effects in an [method assert] call. Otherwise, the project will behave differently when exported in release mode. @@ -54,10 +46,8 @@ </description> </method> <method name="char"> - <return type="String"> - </return> - <argument index="0" name="char" type="int"> - </argument> + <return type="String" /> + <argument index="0" name="char" type="int" /> <description> Returns a character as a String of the given Unicode code point (which is compatible with ASCII code). [codeblock] @@ -68,12 +58,9 @@ </description> </method> <method name="convert"> - <return type="Variant"> - </return> - <argument index="0" name="what" type="Variant"> - </argument> - <argument index="1" name="type" type="int"> - </argument> + <return type="Variant" /> + <argument index="0" name="what" type="Variant" /> + <argument index="1" name="type" type="int" /> <description> Converts from a type to another in the best way possible. The [code]type[/code] parameter uses the [enum Variant.Type] values. [codeblock] @@ -87,17 +74,14 @@ </description> </method> <method name="dict2inst"> - <return type="Object"> - </return> - <argument index="0" name="dictionary" type="Dictionary"> - </argument> + <return type="Object" /> + <argument index="0" name="dictionary" type="Dictionary" /> <description> Converts a dictionary (previously created with [method inst2dict]) back to an instance. Useful for deserializing. </description> </method> <method name="get_stack"> - <return type="Array"> - </return> + <return type="Array" /> <description> Returns an array of dictionaries representing the current call stack. [codeblock] @@ -117,10 +101,8 @@ </description> </method> <method name="inst2dict"> - <return type="Dictionary"> - </return> - <argument index="0" name="instance" type="Object"> - </argument> + <return type="Dictionary" /> + <argument index="0" name="instance" type="Object" /> <description> Returns the passed instance converted to a dictionary (useful for serializing). [codeblock] @@ -138,10 +120,8 @@ </description> </method> <method name="len"> - <return type="int"> - </return> - <argument index="0" name="var" type="Variant"> - </argument> + <return type="int" /> + <argument index="0" name="var" type="Variant" /> <description> Returns length of Variant [code]var[/code]. Length is the character count of String, element count of Array, size of Dictionary, etc. [b]Note:[/b] Generates a fatal error if Variant can not provide a length. @@ -152,10 +132,8 @@ </description> </method> <method name="load"> - <return type="Resource"> - </return> - <argument index="0" name="path" type="String"> - </argument> + <return type="Resource" /> + <argument index="0" name="path" type="String" /> <description> Loads a resource from the filesystem located at [code]path[/code]. The resource is loaded on the method call (unless it's referenced already elsewhere, e.g. in another script or in the scene), which might cause slight delay, especially when loading scenes. To avoid unnecessary delays when loading something multiple times, either store the resource in a variable or use [method preload]. [b]Note:[/b] Resource paths can be obtained by right-clicking on a resource in the FileSystem dock and choosing "Copy Path" or by dragging the file from the FileSystem dock into the script. @@ -168,10 +146,8 @@ </description> </method> <method name="preload"> - <return type="Resource"> - </return> - <argument index="0" name="path" type="String"> - </argument> + <return type="Resource" /> + <argument index="0" name="path" type="String" /> <description> Returns a [Resource] from the filesystem located at [code]path[/code]. The resource is loaded during script parsing, i.e. is loaded with the script and [method preload] effectively acts as a reference to that resource. Note that the method requires a constant path. If you want to load a resource from a dynamic/variable path, use [method load]. [b]Note:[/b] Resource paths can be obtained by right clicking on a resource in the Assets Panel and choosing "Copy Path" or by dragging the file from the FileSystem dock into the script. @@ -182,15 +158,13 @@ </description> </method> <method name="print_debug" qualifiers="vararg"> - <return type="void"> - </return> + <return type="void" /> <description> Like [method @GlobalScope.print], but prints only when used in debug mode. </description> </method> <method name="print_stack"> - <return type="void"> - </return> + <return type="void" /> <description> Prints a stack track at code location, only works when running with debugger turned on. Output in the console would look something like this: @@ -200,8 +174,7 @@ </description> </method> <method name="range" qualifiers="vararg"> - <return type="Array"> - </return> + <return type="Array" /> <description> Returns an array with the given range. Range can be 1 argument N (0 to N-1), two arguments (initial, final-1) or three arguments (initial, final-1, increment). [codeblock] @@ -218,8 +191,7 @@ </description> </method> <method name="str" qualifiers="vararg"> - <return type="String"> - </return> + <return type="String" /> <description> Converts one or more arguments to string in the best way possible. [codeblock] @@ -231,26 +203,26 @@ </description> </method> <method name="type_exists"> - <return type="bool"> - </return> - <argument index="0" name="type" type="StringName"> - </argument> + <return type="bool" /> + <argument index="0" name="type" type="StringName" /> <description> </description> </method> </methods> <constants> <constant name="PI" value="3.14159265358979"> - Constant that represents how many times the diameter of a circle fits around its perimeter. This is equivalent to [code]TAU / 2[/code]. + Constant that represents how many times the diameter of a circle fits around its perimeter. This is equivalent to [code]TAU / 2[/code], or 180 degrees in rotations. </constant> <constant name="TAU" value="6.28318530717959"> - The circle constant, the circumference of the unit circle in radians. + The circle constant, the circumference of the unit circle in radians. This is equivalent to [code]PI * 2[/code], or 360 degrees in rotations. </constant> <constant name="INF" value="inf"> - Positive infinity. For negative infinity, use -INF. + Positive floating-point infinity. This is the result of floating-point division when the divisor is [code]0.0[/code]. For negative infinity, use [code]-INF[/code]. Dividing by [code]-0.0[/code] will result in negative infinity if the numerator is positive, so dividing by [code]0.0[/code] is not the same as dividing by [code]-0.0[/code] (despite [code]0.0 == -0.0[/code] returning [code]true[/code]). + [b]Note:[/b] Numeric infinity is only a concept with floating-point numbers, and has no equivalent for integers. Dividing an integer number by [code]0[/code] will not result in [constant INF] and will result in a run-time error instead. </constant> <constant name="NAN" value="nan"> - "Not a Number", an invalid value. [code]NaN[/code] has special properties, including that it is not equal to itself. It is output by some invalid operations, such as dividing zero by zero. + "Not a Number", an invalid floating-point value. [constant NAN] has special properties, including that it is not equal to itself ([code]NAN == NAN[/code] returns [code]false[/code]). It is output by some invalid operations, such as dividing floating-point [code]0.0[/code] by [code]0.0[/code]. + [b]Note:[/b] "Not a Number" is only a concept with floating-point numbers, and has no equivalent for integers. Dividing an integer [code]0[/code] by [code]0[/code] will not result in [constant NAN] and will result in a run-time error instead. </constant> </constants> </class> diff --git a/modules/gdscript/doc_classes/GDScript.xml b/modules/gdscript/doc_classes/GDScript.xml index 631a102130..72738f027a 100644 --- a/modules/gdscript/doc_classes/GDScript.xml +++ b/modules/gdscript/doc_classes/GDScript.xml @@ -12,15 +12,13 @@ </tutorials> <methods> <method name="get_as_byte_code" qualifiers="const"> - <return type="PackedByteArray"> - </return> + <return type="PackedByteArray" /> <description> Returns byte code for the script source code. </description> </method> <method name="new" qualifiers="vararg"> - <return type="Variant"> - </return> + <return type="Variant" /> <description> Returns a new instance of the script. For example: diff --git a/modules/gdscript/editor/gdscript_highlighter.cpp b/modules/gdscript/editor/gdscript_highlighter.cpp index 79ec9eb65f..ed8b0a4690 100644 --- a/modules/gdscript/editor/gdscript_highlighter.cpp +++ b/modules/gdscript/editor/gdscript_highlighter.cpp @@ -448,7 +448,7 @@ void GDScriptSyntaxHighlighter::_update_cache() { color_regions.clear(); color_region_cache.clear(); - font_color = text_edit->get_theme_color("font_color"); + font_color = text_edit->get_theme_color(SNAME("font_color")); symbol_color = EDITOR_GET("text_editor/highlighting/symbol_color"); function_color = EDITOR_GET("text_editor/highlighting/function_color"); number_color = EDITOR_GET("text_editor/highlighting/number_color"); @@ -458,8 +458,8 @@ void GDScriptSyntaxHighlighter::_update_cache() { const Color types_color = EDITOR_GET("text_editor/highlighting/engine_type_color"); List<StringName> types; ClassDB::get_class_list(&types); - for (List<StringName>::Element *E = types.front(); E; E = E->next()) { - String n = E->get(); + for (const StringName &E : types) { + String n = E; if (n.begins_with("_")) { n = n.substr(1, n.length()); } @@ -470,8 +470,8 @@ void GDScriptSyntaxHighlighter::_update_cache() { const Color usertype_color = EDITOR_GET("text_editor/highlighting/user_type_color"); List<StringName> global_classes; ScriptServer::get_global_class_list(&global_classes); - for (List<StringName>::Element *E = global_classes.front(); E; E = E->next()) { - keywords[String(E->get())] = usertype_color; + for (const StringName &E : global_classes) { + keywords[String(E)] = usertype_color; } /* Autoloads. */ @@ -489,8 +489,8 @@ void GDScriptSyntaxHighlighter::_update_cache() { const Color basetype_color = EDITOR_GET("text_editor/highlighting/base_type_color"); List<String> core_types; gdscript->get_core_type_words(&core_types); - for (List<String>::Element *E = core_types.front(); E; E = E->next()) { - keywords[E->get()] = basetype_color; + for (const String &E : core_types) { + keywords[E] = basetype_color; } /* Reserved words. */ @@ -498,11 +498,11 @@ void GDScriptSyntaxHighlighter::_update_cache() { const Color control_flow_keyword_color = EDITOR_GET("text_editor/highlighting/control_flow_keyword_color"); List<String> keyword_list; gdscript->get_reserved_words(&keyword_list); - for (List<String>::Element *E = keyword_list.front(); E; E = E->next()) { - if (gdscript->is_control_flow_keyword(E->get())) { - keywords[E->get()] = control_flow_keyword_color; + for (const String &E : keyword_list) { + if (gdscript->is_control_flow_keyword(E)) { + keywords[E] = control_flow_keyword_color; } else { - keywords[E->get()] = keyword_color; + keywords[E] = keyword_color; } } @@ -510,8 +510,7 @@ void GDScriptSyntaxHighlighter::_update_cache() { const Color comment_color = EDITOR_GET("text_editor/highlighting/comment_color"); List<String> comments; gdscript->get_comment_delimiters(&comments); - for (List<String>::Element *E = comments.front(); E; E = E->next()) { - String comment = E->get(); + for (const String &comment : comments) { String beg = comment.get_slice(" ", 0); String end = comment.get_slice_count(" ") > 1 ? comment.get_slice(" ", 1) : String(); add_color_region(beg, end, comment_color, end == ""); @@ -521,8 +520,7 @@ void GDScriptSyntaxHighlighter::_update_cache() { const Color string_color = EDITOR_GET("text_editor/highlighting/string_color"); List<String> strings; gdscript->get_string_delimiters(&strings); - for (List<String>::Element *E = strings.front(); E; E = E->next()) { - String string = E->get(); + for (const String &string : strings) { String beg = string.get_slice(" ", 0); String end = string.get_slice_count(" ") > 1 ? string.get_slice(" ", 1) : String(); add_color_region(beg, end, string_color, end == ""); @@ -536,9 +534,9 @@ void GDScriptSyntaxHighlighter::_update_cache() { if (instance_base != StringName()) { List<PropertyInfo> plist; ClassDB::get_property_list(instance_base, &plist); - for (List<PropertyInfo>::Element *E = plist.front(); E; E = E->next()) { - String name = E->get().name; - if (E->get().usage & PROPERTY_USAGE_CATEGORY || E->get().usage & PROPERTY_USAGE_GROUP || E->get().usage & PROPERTY_USAGE_SUBGROUP) { + for (const PropertyInfo &E : plist) { + String name = E.name; + if (E.usage & PROPERTY_USAGE_CATEGORY || E.usage & PROPERTY_USAGE_GROUP || E.usage & PROPERTY_USAGE_SUBGROUP) { continue; } if (name.find("/") != -1) { @@ -549,8 +547,8 @@ void GDScriptSyntaxHighlighter::_update_cache() { List<String> clist; ClassDB::get_integer_constant_list(instance_base, &clist); - for (List<String>::Element *E = clist.front(); E; E = E->next()) { - member_keywords[E->get()] = member_variable_color; + for (const String &E : clist) { + member_keywords[E] = member_variable_color; } } } diff --git a/modules/gdscript/editor/gdscript_translation_parser_plugin.h b/modules/gdscript/editor/gdscript_translation_parser_plugin.h index fcf438422a..caa80fc24c 100644 --- a/modules/gdscript/editor/gdscript_translation_parser_plugin.h +++ b/modules/gdscript/editor/gdscript_translation_parser_plugin.h @@ -34,7 +34,6 @@ #include "core/templates/set.h" #include "editor/editor_translation_parser.h" #include "modules/gdscript/gdscript_parser.h" -#include "modules/regex/regex.h" class GDScriptEditorTranslationParserPlugin : public EditorTranslationParserPlugin { GDCLASS(GDScriptEditorTranslationParserPlugin, EditorTranslationParserPlugin); diff --git a/modules/gdscript/gdscript.cpp b/modules/gdscript/gdscript.cpp index 8b12b1eae4..8957b00a1b 100644 --- a/modules/gdscript/gdscript.cpp +++ b/modules/gdscript/gdscript.cpp @@ -291,8 +291,8 @@ void GDScript::_get_script_property_list(List<PropertyInfo> *r_list, bool p_incl sptr = sptr->_base; } - for (List<PropertyInfo>::Element *E = props.front(); E; E = E->next()) { - r_list->push_back(E->get()); + for (const PropertyInfo &E : props) { + r_list->push_back(E); } } @@ -401,8 +401,8 @@ void GDScript::_update_exports_values(Map<StringName, Variant> &values, List<Pro values[E->key()] = E->get(); } - for (List<PropertyInfo>::Element *E = members_cache.front(); E; E = E->next()) { - propnames.push_back(E->get()); + for (const PropertyInfo &E : members_cache) { + propnames.push_back(E); } } @@ -861,8 +861,7 @@ Error GDScript::reload(bool p_keep_state) { } } #ifdef DEBUG_ENABLED - for (const List<GDScriptWarning>::Element *E = parser.get_warnings().front(); E; E = E->next()) { - const GDScriptWarning &warning = E->get(); + for (const GDScriptWarning &warning : parser.get_warnings()) { if (EngineDebugger::is_active()) { Vector<ScriptLanguage::StackInfo> si; EngineDebugger::get_script_debugger()->send_error("", get_path(), warning.start_line, warning.get_name(), warning.get_message(), ERR_HANDLER_WARNING, si); @@ -1165,15 +1164,11 @@ void GDScript::_init_rpc_methods_properties() { while (cscript) { // RPC Methods for (Map<StringName, GDScriptFunction *>::Element *E = cscript->member_functions.front(); E; E = E->next()) { - if (E->get()->get_rpc_mode() != MultiplayerAPI::RPC_MODE_DISABLED) { - MultiplayerAPI::RPCConfig nd; - nd.name = E->key(); - nd.rpc_mode = E->get()->get_rpc_mode(); - // TODO - nd.transfer_mode = MultiplayerPeer::TRANSFER_MODE_RELIABLE; - nd.channel = 0; - if (-1 == rpc_functions.find(nd)) { - rpc_functions.push_back(nd); + MultiplayerAPI::RPCConfig config = E->get()->get_rpc_config(); + if (config.rpc_mode != MultiplayerAPI::RPC_MODE_DISABLED) { + config.name = E->get()->get_name(); + if (rpc_functions.find(config) == -1) { + rpc_functions.push_back(config); } } } @@ -1449,8 +1444,8 @@ void GDScriptInstance::get_property_list(List<PropertyInfo> *p_properties) const sptr = sptr->_base; } - for (List<PropertyInfo>::Element *E = props.front(); E; E = E->next()) { - p_properties->push_back(E->get()); + for (const PropertyInfo &E : props) { + p_properties->push_back(E); } } @@ -1641,33 +1636,32 @@ void GDScriptLanguage::init() { _add_global(StaticCString::create("PI"), Math_PI); _add_global(StaticCString::create("TAU"), Math_TAU); - _add_global(StaticCString::create("INF"), Math_INF); - _add_global(StaticCString::create("NAN"), Math_NAN); + _add_global(StaticCString::create("INF"), INFINITY); + _add_global(StaticCString::create("NAN"), NAN); //populate native classes List<StringName> class_list; ClassDB::get_class_list(&class_list); - for (List<StringName>::Element *E = class_list.front(); E; E = E->next()) { - StringName n = E->get(); + for (const StringName &n : class_list) { String s = String(n); if (s.begins_with("_")) { - n = s.substr(1, s.length()); + s = s.substr(1, s.length()); } - if (globals.has(n)) { + if (globals.has(s)) { continue; } - Ref<GDScriptNativeClass> nc = memnew(GDScriptNativeClass(E->get())); - _add_global(n, nc); + Ref<GDScriptNativeClass> nc = memnew(GDScriptNativeClass(n)); + _add_global(s, nc); } //populate singletons List<Engine::Singleton> singletons; Engine::get_singleton()->get_singletons(&singletons); - for (List<Engine::Singleton>::Element *E = singletons.front(); E; E = E->next()) { - _add_global(E->get().name, E->get().ptr); + for (const Engine::Singleton &E : singletons) { + _add_global(E.name, E.ptr); } #ifdef TESTS_ENABLED @@ -1810,10 +1804,10 @@ void GDScriptLanguage::reload_all_scripts() { scripts.sort_custom<GDScriptDepSort>(); //update in inheritance dependency order - for (List<Ref<GDScript>>::Element *E = scripts.front(); E; E = E->next()) { - print_verbose("GDScript: Reloading: " + E->get()->get_path()); - E->get()->load_source_code(E->get()->get_path()); - E->get()->reload(true); + for (Ref<GDScript> &script : scripts) { + print_verbose("GDScript: Reloading: " + script->get_path()); + script->load_source_code(script->get_path()); + script->reload(true); } #endif } @@ -1842,21 +1836,21 @@ void GDScriptLanguage::reload_tool_script(const Ref<Script> &p_script, bool p_so scripts.sort_custom<GDScriptDepSort>(); //update in inheritance dependency order - for (List<Ref<GDScript>>::Element *E = scripts.front(); E; E = E->next()) { - bool reload = E->get() == p_script || to_reload.has(E->get()->get_base()); + for (Ref<GDScript> &script : scripts) { + bool reload = script == p_script || to_reload.has(script->get_base()); if (!reload) { continue; } - to_reload.insert(E->get(), Map<ObjectID, List<Pair<StringName, Variant>>>()); + to_reload.insert(script, Map<ObjectID, List<Pair<StringName, Variant>>>()); if (!p_soft_reload) { //save state and remove script from instances - Map<ObjectID, List<Pair<StringName, Variant>>> &map = to_reload[E->get()]; + Map<ObjectID, List<Pair<StringName, Variant>>> &map = to_reload[script]; - while (E->get()->instances.front()) { - Object *obj = E->get()->instances.front()->get(); + while (script->instances.front()) { + Object *obj = script->instances.front()->get(); //save instance info List<Pair<StringName, Variant>> state; if (obj->get_script_instance()) { @@ -1869,8 +1863,8 @@ void GDScriptLanguage::reload_tool_script(const Ref<Script> &p_script, bool p_so //same thing for placeholders #ifdef TOOLS_ENABLED - while (E->get()->placeholders.size()) { - Object *obj = E->get()->placeholders.front()->get()->get_owner(); + while (script->placeholders.size()) { + Object *obj = script->placeholders.front()->get()->get_owner(); //save instance info if (obj->get_script_instance()) { @@ -1880,13 +1874,13 @@ void GDScriptLanguage::reload_tool_script(const Ref<Script> &p_script, bool p_so obj->set_script(Variant()); } else { // no instance found. Let's remove it so we don't loop forever - E->get()->placeholders.erase(E->get()->placeholders.front()->get()); + script->placeholders.erase(script->placeholders.front()->get()); } } #endif - for (Map<ObjectID, List<Pair<StringName, Variant>>>::Element *F = E->get()->pending_reload_state.front(); F; F = F->next()) { + for (Map<ObjectID, List<Pair<StringName, Variant>>>::Element *F = script->pending_reload_state.front(); F; F = F->next()) { map[F->key()] = F->get(); //pending to reload, use this one instead } } @@ -2029,8 +2023,8 @@ void GDScriptLanguage::get_reserved_words(List<String> *p_words) const { List<StringName> functions; GDScriptUtilityFunctions::get_function_list(&functions); - for (const List<StringName>::Element *E = functions.front(); E; E = E->next()) { - p_words->push_back(String(E->get())); + for (const StringName &E : functions) { + p_words->push_back(String(E)); } } @@ -2300,8 +2294,8 @@ void ResourceFormatLoaderGDScript::get_dependencies(const String &p_path, List<S return; } - for (const List<String>::Element *E = parser.get_dependencies().front(); E; E = E->next()) { - p_dependencies->push_back(E->get()); + for (const String &E : parser.get_dependencies()) { + p_dependencies->push_back(E); } } diff --git a/modules/gdscript/gdscript.h b/modules/gdscript/gdscript.h index 078b7a2fd0..24809ad5fd 100644 --- a/modules/gdscript/gdscript.h +++ b/modules/gdscript/gdscript.h @@ -64,7 +64,6 @@ class GDScript : public Script { int index = 0; StringName setter; StringName getter; - MultiplayerAPI::RPCMode rpc_mode; GDScriptDataType data_type; }; diff --git a/modules/gdscript/gdscript_analyzer.cpp b/modules/gdscript/gdscript_analyzer.cpp index e7fb33a6a7..ab37e54cf1 100644 --- a/modules/gdscript/gdscript_analyzer.cpp +++ b/modules/gdscript/gdscript_analyzer.cpp @@ -115,8 +115,8 @@ static GDScriptParser::DataType make_native_enum_type(const StringName &p_native StringName real_native_name = GDScriptParser::get_real_class_name(p_native_class); ClassDB::get_enum_constants(real_native_name, p_enum_name, &enum_values); - for (const List<StringName>::Element *E = enum_values.front(); E != nullptr; E = E->next()) { - type.enum_values[E->get()] = ClassDB::get_integer_constant(real_native_name, E->get()); + for (const StringName &E : enum_values) { + type.enum_values[E] = ClassDB::get_integer_constant(real_native_name, E); } return type; @@ -573,8 +573,8 @@ void GDScriptAnalyzer::resolve_class_interface(GDScriptParser::ClassNode *p_clas member.variable->set_datatype(datatype); // Apply annotations. - for (List<GDScriptParser::AnnotationNode *>::Element *E = member.variable->annotations.front(); E; E = E->next()) { - E->get()->apply(parser, member.variable); + for (GDScriptParser::AnnotationNode *&E : member.variable->annotations) { + E->apply(parser, member.variable); } } break; case GDScriptParser::ClassNode::Member::CONSTANT: { @@ -622,8 +622,8 @@ void GDScriptAnalyzer::resolve_class_interface(GDScriptParser::ClassNode *p_clas member.constant->set_datatype(datatype); // Apply annotations. - for (List<GDScriptParser::AnnotationNode *>::Element *E = member.constant->annotations.front(); E; E = E->next()) { - E->get()->apply(parser, member.constant); + for (GDScriptParser::AnnotationNode *&E : member.constant->annotations) { + E->apply(parser, member.constant); } } break; case GDScriptParser::ClassNode::Member::SIGNAL: { @@ -641,8 +641,8 @@ void GDScriptAnalyzer::resolve_class_interface(GDScriptParser::ClassNode *p_clas member.signal->set_datatype(signal_type); // Apply annotations. - for (List<GDScriptParser::AnnotationNode *>::Element *E = member.signal->annotations.front(); E; E = E->next()) { - E->get()->apply(parser, member.signal); + for (GDScriptParser::AnnotationNode *&E : member.signal->annotations) { + E->apply(parser, member.signal); } } break; case GDScriptParser::ClassNode::Member::ENUM: { @@ -688,8 +688,8 @@ void GDScriptAnalyzer::resolve_class_interface(GDScriptParser::ClassNode *p_clas member.m_enum->set_datatype(enum_type); // Apply annotations. - for (List<GDScriptParser::AnnotationNode *>::Element *E = member.m_enum->annotations.front(); E; E = E->next()) { - E->get()->apply(parser, member.m_enum); + for (GDScriptParser::AnnotationNode *&E : member.m_enum->annotations) { + E->apply(parser, member.m_enum); } } break; case GDScriptParser::ClassNode::Member::FUNCTION: @@ -761,8 +761,8 @@ void GDScriptAnalyzer::resolve_class_body(GDScriptParser::ClassNode *p_class) { resolve_function_body(member.function); // Apply annotations. - for (List<GDScriptParser::AnnotationNode *>::Element *E = member.function->annotations.front(); E; E = E->next()) { - E->get()->apply(parser, member.function); + for (GDScriptParser::AnnotationNode *&E : member.function->annotations) { + E->apply(parser, member.function); } } @@ -1927,9 +1927,7 @@ void GDScriptAnalyzer::reduce_call(GDScriptParser::CallNode *p_call, bool is_awa Variant::get_constructor_list(builtin_type, &constructors); bool match = false; - for (const List<MethodInfo>::Element *E = constructors.front(); E != nullptr; E = E->next()) { - const MethodInfo &info = E->get(); - + for (const MethodInfo &info : constructors) { if (p_call->arguments.size() < info.arguments.size() - info.default_arguments.size()) { continue; } @@ -2326,8 +2324,7 @@ void GDScriptAnalyzer::reduce_identifier_from_base(GDScriptParser::IdentifierNod Variant::construct(base.builtin_type, dummy, nullptr, 0, temp); List<PropertyInfo> properties; dummy.get_property_list(&properties); - for (const List<PropertyInfo>::Element *E = properties.front(); E != nullptr; E = E->next()) { - const PropertyInfo &prop = E->get(); + for (const PropertyInfo &prop : properties) { if (prop.name == name) { p_identifier->set_datatype(type_from_property(prop)); return; @@ -3125,8 +3122,8 @@ GDScriptParser::DataType GDScriptAnalyzer::type_from_variant(const Variant &p_va GDScriptParser::ClassNode *found = ref->get_parser()->head; // It should be okay to assume this exists, since we have a complete script already. - for (const List<StringName>::Element *E = class_chain.front(); E; E = E->next()) { - found = found->get_member(E->get()).m_class; + for (const StringName &E : class_chain) { + found = found->get_member(E).m_class; } result.class_type = found; @@ -3222,9 +3219,9 @@ bool GDScriptAnalyzer::get_function_signature(GDScriptParser::Node *p_source, GD List<MethodInfo> methods; dummy.get_method_list(&methods); - for (const List<MethodInfo>::Element *E = methods.front(); E != nullptr; E = E->next()) { - if (E->get().name == p_function) { - return function_signature_from_info(E->get(), r_return_type, r_par_types, r_default_arg_count, r_static, r_vararg); + for (const MethodInfo &E : methods) { + if (E.name == p_function) { + return function_signature_from_info(E, r_return_type, r_par_types, r_default_arg_count, r_static, r_vararg); } } @@ -3321,8 +3318,8 @@ bool GDScriptAnalyzer::function_signature_from_info(const MethodInfo &p_info, GD r_default_arg_count = p_info.default_arguments.size(); r_vararg = (p_info.flags & METHOD_FLAG_VARARG) != 0; - for (const List<PropertyInfo>::Element *E = p_info.arguments.front(); E != nullptr; E = E->next()) { - r_par_types.push_back(type_from_property(E->get())); + for (const PropertyInfo &E : p_info.arguments) { + r_par_types.push_back(type_from_property(E)); } return true; } @@ -3330,8 +3327,8 @@ bool GDScriptAnalyzer::function_signature_from_info(const MethodInfo &p_info, GD bool GDScriptAnalyzer::validate_call_arg(const MethodInfo &p_method, const GDScriptParser::CallNode *p_call) { List<GDScriptParser::DataType> arg_types; - for (const List<PropertyInfo>::Element *E = p_method.arguments.front(); E != nullptr; E = E->next()) { - arg_types.push_back(type_from_property(E->get())); + for (const PropertyInfo &E : p_method.arguments) { + arg_types.push_back(type_from_property(E)); } return validate_call_arg(arg_types, p_method.default_arguments.size(), (p_method.flags & METHOD_FLAG_VARARG) != 0, p_call); @@ -3658,11 +3655,11 @@ Error GDScriptAnalyzer::resolve_program() { List<String> parser_keys; depended_parsers.get_key_list(&parser_keys); - for (const List<String>::Element *E = parser_keys.front(); E != nullptr; E = E->next()) { - if (depended_parsers[E->get()].is_null()) { + for (const String &E : parser_keys) { + if (depended_parsers[E].is_null()) { return ERR_PARSE_ERROR; } - depended_parsers[E->get()]->raise_status(GDScriptParserRef::FULLY_SOLVED); + depended_parsers[E]->raise_status(GDScriptParserRef::FULLY_SOLVED); } return parser->errors.is_empty() ? OK : ERR_PARSE_ERROR; } diff --git a/modules/gdscript/gdscript_byte_codegen.cpp b/modules/gdscript/gdscript_byte_codegen.cpp index 5a297cc50a..5958326315 100644 --- a/modules/gdscript/gdscript_byte_codegen.cpp +++ b/modules/gdscript/gdscript_byte_codegen.cpp @@ -155,7 +155,7 @@ void GDScriptByteCodeGenerator::end_parameters() { function->default_arguments.reverse(); } -void GDScriptByteCodeGenerator::write_start(GDScript *p_script, const StringName &p_function_name, bool p_static, MultiplayerAPI::RPCMode p_rpc_mode, const GDScriptDataType &p_return_type) { +void GDScriptByteCodeGenerator::write_start(GDScript *p_script, const StringName &p_function_name, bool p_static, MultiplayerAPI::RPCConfig p_rpc_config, const GDScriptDataType &p_return_type) { function = memnew(GDScriptFunction); debug_stack = EngineDebugger::is_active(); @@ -170,7 +170,7 @@ void GDScriptByteCodeGenerator::write_start(GDScript *p_script, const StringName function->_static = p_static; function->return_type = p_return_type; - function->rpc_mode = p_rpc_mode; + function->rpc_config = p_rpc_config; function->_argument_count = 0; } @@ -1459,8 +1459,8 @@ void GDScriptByteCodeGenerator::write_endfor() { } // Patch break statements. - for (const List<int>::Element *E = current_breaks_to_patch.back()->get().front(); E; E = E->next()) { - patch_jump(E->get()); + for (const int &E : current_breaks_to_patch.back()->get()) { + patch_jump(E); } current_breaks_to_patch.pop_back(); @@ -1494,8 +1494,8 @@ void GDScriptByteCodeGenerator::write_endwhile() { while_jmp_addrs.pop_back(); // Patch break statements. - for (const List<int>::Element *E = current_breaks_to_patch.back()->get().front(); E; E = E->next()) { - patch_jump(E->get()); + for (const int &E : current_breaks_to_patch.back()->get()) { + patch_jump(E); } current_breaks_to_patch.pop_back(); } @@ -1506,8 +1506,8 @@ void GDScriptByteCodeGenerator::start_match() { void GDScriptByteCodeGenerator::start_match_branch() { // Patch continue statements. - for (const List<int>::Element *E = match_continues_to_patch.back()->get().front(); E; E = E->next()) { - patch_jump(E->get()); + for (const int &E : match_continues_to_patch.back()->get()) { + patch_jump(E); } match_continues_to_patch.pop_back(); // Start a new list for next branch. @@ -1516,8 +1516,8 @@ void GDScriptByteCodeGenerator::start_match_branch() { void GDScriptByteCodeGenerator::end_match() { // Patch continue statements. - for (const List<int>::Element *E = match_continues_to_patch.back()->get().front(); E; E = E->next()) { - patch_jump(E->get()); + for (const int &E : match_continues_to_patch.back()->get()) { + patch_jump(E); } match_continues_to_patch.pop_back(); } diff --git a/modules/gdscript/gdscript_byte_codegen.h b/modules/gdscript/gdscript_byte_codegen.h index b1f3cd5fb3..3d6fb291ad 100644 --- a/modules/gdscript/gdscript_byte_codegen.h +++ b/modules/gdscript/gdscript_byte_codegen.h @@ -419,7 +419,7 @@ public: virtual void start_block() override; virtual void end_block() override; - virtual void write_start(GDScript *p_script, const StringName &p_function_name, bool p_static, MultiplayerAPI::RPCMode p_rpc_mode, const GDScriptDataType &p_return_type) override; + virtual void write_start(GDScript *p_script, const StringName &p_function_name, bool p_static, MultiplayerAPI::RPCConfig p_rpc_config, const GDScriptDataType &p_return_type) override; virtual GDScriptFunction *write_end() override; #ifdef DEBUG_ENABLED diff --git a/modules/gdscript/gdscript_codegen.h b/modules/gdscript/gdscript_codegen.h index cac6544f03..ecc86c37f3 100644 --- a/modules/gdscript/gdscript_codegen.h +++ b/modules/gdscript/gdscript_codegen.h @@ -80,7 +80,7 @@ public: virtual void start_block() = 0; virtual void end_block() = 0; - virtual void write_start(GDScript *p_script, const StringName &p_function_name, bool p_static, MultiplayerAPI::RPCMode p_rpc_mode, const GDScriptDataType &p_return_type) = 0; + virtual void write_start(GDScript *p_script, const StringName &p_function_name, bool p_static, MultiplayerAPI::RPCConfig p_rpc_config, const GDScriptDataType &p_return_type) = 0; virtual GDScriptFunction *write_end() = 0; #ifdef DEBUG_ENABLED diff --git a/modules/gdscript/gdscript_compiler.cpp b/modules/gdscript/gdscript_compiler.cpp index 7fa8e9c067..7c9d08b782 100644 --- a/modules/gdscript/gdscript_compiler.cpp +++ b/modules/gdscript/gdscript_compiler.cpp @@ -981,8 +981,7 @@ GDScriptCodeGenerator::Address GDScriptCompiler::_parse_expression(CodeGen &code assigned = prev_base; // Set back the values into their bases. - for (List<ChainInfo>::Element *E = set_chain.front(); E; E = E->next()) { - const ChainInfo &info = E->get(); + for (const ChainInfo &info : set_chain) { if (!info.is_named) { gen->write_set(info.base, info.key, assigned); if (info.key.mode == GDScriptCodeGenerator::Address::TEMPORARY) { @@ -1859,7 +1858,7 @@ GDScriptFunction *GDScriptCompiler::_parse_function(Error &r_error, GDScript *p_ StringName func_name; bool is_static = false; - MultiplayerAPI::RPCMode rpc_mode = MultiplayerAPI::RPC_MODE_DISABLED; + MultiplayerAPI::RPCConfig rpc_config; GDScriptDataType return_type; return_type.has_type = true; return_type.kind = GDScriptDataType::BUILTIN; @@ -1872,7 +1871,7 @@ GDScriptFunction *GDScriptCompiler::_parse_function(Error &r_error, GDScript *p_ func_name = "<anonymous lambda>"; } is_static = p_func->is_static; - rpc_mode = p_func->rpc_mode; + rpc_config = p_func->rpc_config; return_type = _gdtype_from_datatype(p_func->get_datatype(), p_script); } else { if (p_for_ready) { @@ -1883,7 +1882,7 @@ GDScriptFunction *GDScriptCompiler::_parse_function(Error &r_error, GDScript *p_ } codegen.function_name = func_name; - codegen.generator->write_start(p_script, func_name, is_static, rpc_mode, return_type); + codegen.generator->write_start(p_script, func_name, is_static, rpc_config, return_type); int optional_parameters = 0; @@ -2088,7 +2087,7 @@ Error GDScriptCompiler::_parse_setter_getter(GDScript *p_script, const GDScriptP return_type = _gdtype_from_datatype(p_variable->get_datatype(), p_script); } - codegen.generator->write_start(p_script, func_name, false, p_variable->rpc_mode, return_type); + codegen.generator->write_start(p_script, func_name, false, MultiplayerAPI::RPCConfig(), return_type); if (p_is_setter) { uint32_t par_addr = codegen.generator->add_parameter(p_variable->setter_parameter->name, false, _gdtype_from_datatype(p_variable->get_datatype())); @@ -2268,7 +2267,6 @@ Error GDScriptCompiler::_parse_class_level(GDScript *p_script, const GDScriptPar } break; } - minfo.rpc_mode = variable->rpc_mode; minfo.data_type = _gdtype_from_datatype(variable->get_datatype(), p_script); PropertyInfo prop_info = minfo.data_type; diff --git a/modules/gdscript/gdscript_editor.cpp b/modules/gdscript/gdscript_editor.cpp index c1a7bedbc8..2a93bb620b 100644 --- a/modules/gdscript/gdscript_editor.cpp +++ b/modules/gdscript/gdscript_editor.cpp @@ -141,8 +141,8 @@ bool GDScriptLanguage::validate(const String &p_script, const String &p_path, Li } #ifdef DEBUG_ENABLED if (r_warnings) { - for (const List<GDScriptWarning>::Element *E = parser.get_warnings().front(); E; E = E->next()) { - const GDScriptWarning &warn = E->get(); + for (const GDScriptWarning &E : parser.get_warnings()) { + const GDScriptWarning &warn = E; ScriptLanguage::Warning w; w.start_line = warn.start_line; w.end_line = warn.end_line; @@ -157,8 +157,8 @@ bool GDScriptLanguage::validate(const String &p_script, const String &p_path, Li #endif if (err) { if (r_errors) { - for (const List<GDScriptParser::ParserError>::Element *E = parser.get_errors().front(); E; E = E->next()) { - const GDScriptParser::ParserError &pe = E->get(); + for (const GDScriptParser::ParserError &E : parser.get_errors()) { + const GDScriptParser::ParserError &pe = E; ScriptLanguage::ScriptError e; e.line = pe.line; e.column = pe.column; @@ -319,9 +319,9 @@ void GDScriptLanguage::debug_get_stack_level_locals(int p_level, List<String> *p List<Pair<StringName, int>> locals; f->debug_get_stack_member_state(*_call_stack[l].line, &locals); - for (List<Pair<StringName, int>>::Element *E = locals.front(); E; E = E->next()) { - p_locals->push_back(E->get().first); - p_values->push_back(_call_stack[l].stack[E->get().second]); + for (const Pair<StringName, int> &E : locals) { + p_locals->push_back(E.first); + p_values->push_back(_call_stack[l].stack[E.second]); } } @@ -421,8 +421,8 @@ void GDScriptLanguage::get_public_functions(List<MethodInfo> *p_functions) const List<StringName> functions; GDScriptUtilityFunctions::get_function_list(&functions); - for (const List<StringName>::Element *E = functions.front(); E; E = E->next()) { - p_functions->push_back(GDScriptUtilityFunctions::get_function_info(E->get())); + for (const StringName &E : functions) { + p_functions->push_back(GDScriptUtilityFunctions::get_function_info(E)); } // Not really "functions", but show in documentation. @@ -457,12 +457,12 @@ void GDScriptLanguage::get_public_constants(List<Pair<String, Variant>> *p_const Pair<String, Variant> infinity; infinity.first = "INF"; - infinity.second = Math_INF; + infinity.second = INFINITY; p_constants->push_back(infinity); Pair<String, Variant> nan; nan.first = "NAN"; - nan.second = Math_NAN; + nan.second = NAN; p_constants->push_back(nan); } @@ -548,7 +548,7 @@ static String _make_arguments_hint(const MethodInfo &p_info, int p_arg_idx, bool int def_args = p_info.arguments.size() - p_info.default_arguments.size(); int i = 0; - for (const List<PropertyInfo>::Element *E = p_info.arguments.front(); E; E = E->next()) { + for (const PropertyInfo &E : p_info.arguments) { if (i > 0) { arghint += ", "; } @@ -556,7 +556,7 @@ static String _make_arguments_hint(const MethodInfo &p_info, int p_arg_idx, bool if (i == p_arg_idx) { arghint += String::chr(0xFFFF); } - arghint += E->get().name + ": " + _get_visual_datatype(E->get(), true); + arghint += E.name + ": " + _get_visual_datatype(E, true); if (i - def_args >= 0) { arghint += String(" = ") + p_info.default_arguments[i - def_args].get_construct_string(); @@ -662,11 +662,11 @@ static void _find_annotation_arguments(const GDScriptParser::AnnotationNode *p_a r_result.insert(node.display, node); List<StringName> node_types; ClassDB::get_inheriters_from_class("Node", &node_types); - for (const List<StringName>::Element *E = node_types.front(); E != nullptr; E = E->next()) { - if (!ClassDB::is_class_exposed(E->get())) { + for (const StringName &E : node_types) { + if (!ClassDB::is_class_exposed(E)) { continue; } - ScriptCodeCompletionOption option(E->get(), ScriptCodeCompletionOption::KIND_CLASS); + ScriptCodeCompletionOption option(E, ScriptCodeCompletionOption::KIND_CLASS); r_result.insert(option.display, option); } } @@ -675,9 +675,9 @@ static void _find_annotation_arguments(const GDScriptParser::AnnotationNode *p_a static void _list_available_types(bool p_inherit_only, GDScriptParser::CompletionContext &p_context, Map<String, ScriptCodeCompletionOption> &r_result) { List<StringName> native_types; ClassDB::get_class_list(&native_types); - for (const List<StringName>::Element *E = native_types.front(); E != nullptr; E = E->next()) { - if (ClassDB::is_class_exposed(E->get()) && !Engine::get_singleton()->has_singleton(E->get())) { - ScriptCodeCompletionOption option(E->get(), ScriptCodeCompletionOption::KIND_CLASS); + for (const StringName &E : native_types) { + if (ClassDB::is_class_exposed(E) && !Engine::get_singleton()->has_singleton(E)) { + ScriptCodeCompletionOption option(E, ScriptCodeCompletionOption::KIND_CLASS); r_result.insert(option.display, option); } } @@ -687,8 +687,8 @@ static void _list_available_types(bool p_inherit_only, GDScriptParser::Completio // Native enums from base class List<StringName> enums; ClassDB::get_enum_list(p_context.current_class->base_type.native_type, &enums); - for (const List<StringName>::Element *E = enums.front(); E != nullptr; E = E->next()) { - ScriptCodeCompletionOption option(E->get(), ScriptCodeCompletionOption::KIND_ENUM); + for (const StringName &E : enums) { + ScriptCodeCompletionOption option(E, ScriptCodeCompletionOption::KIND_ENUM); r_result.insert(option.display, option); } } @@ -725,8 +725,8 @@ static void _list_available_types(bool p_inherit_only, GDScriptParser::Completio // Global scripts List<StringName> global_classes; ScriptServer::get_global_class_list(&global_classes); - for (const List<StringName>::Element *E = global_classes.front(); E != nullptr; E = E->next()) { - ScriptCodeCompletionOption option(E->get(), ScriptCodeCompletionOption::KIND_CLASS); + for (const StringName &E : global_classes) { + ScriptCodeCompletionOption option(E, ScriptCodeCompletionOption::KIND_CLASS); r_result.insert(option.display, option); } @@ -865,8 +865,8 @@ static void _find_identifiers_in_base(const GDScriptCompletionIdentifier &p_base if (!_static) { List<PropertyInfo> members; scr->get_script_property_list(&members); - for (List<PropertyInfo>::Element *E = members.front(); E; E = E->next()) { - ScriptCodeCompletionOption option(E->get().name, ScriptCodeCompletionOption::KIND_MEMBER); + for (const PropertyInfo &E : members) { + ScriptCodeCompletionOption option(E.name, ScriptCodeCompletionOption::KIND_MEMBER); r_result.insert(option.display, option); } } @@ -879,20 +879,20 @@ static void _find_identifiers_in_base(const GDScriptCompletionIdentifier &p_base List<MethodInfo> signals; scr->get_script_signal_list(&signals); - for (List<MethodInfo>::Element *E = signals.front(); E; E = E->next()) { - ScriptCodeCompletionOption option(E->get().name, ScriptCodeCompletionOption::KIND_SIGNAL); + for (const MethodInfo &E : signals) { + ScriptCodeCompletionOption option(E.name, ScriptCodeCompletionOption::KIND_SIGNAL); r_result.insert(option.display, option); } } List<MethodInfo> methods; scr->get_script_method_list(&methods); - for (List<MethodInfo>::Element *E = methods.front(); E; E = E->next()) { - if (E->get().name.begins_with("@")) { + for (const MethodInfo &E : methods) { + if (E.name.begins_with("@")) { continue; } - ScriptCodeCompletionOption option(E->get().name, ScriptCodeCompletionOption::KIND_FUNCTION); - if (E->get().arguments.size()) { + ScriptCodeCompletionOption option(E.name, ScriptCodeCompletionOption::KIND_FUNCTION); + if (E.arguments.size()) { option.insert_text += "("; } else { option.insert_text += "()"; @@ -920,22 +920,22 @@ static void _find_identifiers_in_base(const GDScriptCompletionIdentifier &p_base if (!p_only_functions) { List<String> constants; ClassDB::get_integer_constant_list(type, &constants); - for (List<String>::Element *E = constants.front(); E; E = E->next()) { - ScriptCodeCompletionOption option(E->get(), ScriptCodeCompletionOption::KIND_CONSTANT); + for (const String &E : constants) { + ScriptCodeCompletionOption option(E, ScriptCodeCompletionOption::KIND_CONSTANT); r_result.insert(option.display, option); } if (!_static || Engine::get_singleton()->has_singleton(type)) { List<PropertyInfo> pinfo; ClassDB::get_property_list(type, &pinfo); - for (List<PropertyInfo>::Element *E = pinfo.front(); E; E = E->next()) { - if (E->get().usage & (PROPERTY_USAGE_GROUP | PROPERTY_USAGE_CATEGORY)) { + for (const PropertyInfo &E : pinfo) { + if (E.usage & (PROPERTY_USAGE_GROUP | PROPERTY_USAGE_CATEGORY)) { continue; } - if (E->get().name.find("/") != -1) { + if (E.name.find("/") != -1) { continue; } - ScriptCodeCompletionOption option(E->get().name, ScriptCodeCompletionOption::KIND_MEMBER); + ScriptCodeCompletionOption option(E.name, ScriptCodeCompletionOption::KIND_MEMBER); r_result.insert(option.display, option); } } @@ -945,12 +945,12 @@ static void _find_identifiers_in_base(const GDScriptCompletionIdentifier &p_base List<MethodInfo> methods; bool is_autocompleting_getters = GLOBAL_GET("debug/gdscript/completion/autocomplete_setters_and_getters").booleanize(); ClassDB::get_method_list(type, &methods, false, !is_autocompleting_getters); - for (List<MethodInfo>::Element *E = methods.front(); E; E = E->next()) { - if (E->get().name.begins_with("_")) { + for (const MethodInfo &E : methods) { + if (E.name.begins_with("_")) { continue; } - ScriptCodeCompletionOption option(E->get().name, ScriptCodeCompletionOption::KIND_FUNCTION); - if (E->get().arguments.size()) { + ScriptCodeCompletionOption option(E.name, ScriptCodeCompletionOption::KIND_FUNCTION); + if (E.arguments.size()) { option.insert_text += "("; } else { option.insert_text += "()"; @@ -977,9 +977,9 @@ static void _find_identifiers_in_base(const GDScriptCompletionIdentifier &p_base tmp.get_property_list(&members); } - for (List<PropertyInfo>::Element *E = members.front(); E; E = E->next()) { - if (String(E->get().name).find("/") == -1) { - ScriptCodeCompletionOption option(E->get().name, ScriptCodeCompletionOption::KIND_MEMBER); + for (const PropertyInfo &E : members) { + if (String(E.name).find("/") == -1) { + ScriptCodeCompletionOption option(E.name, ScriptCodeCompletionOption::KIND_MEMBER); r_result.insert(option.display, option); } } @@ -987,9 +987,9 @@ static void _find_identifiers_in_base(const GDScriptCompletionIdentifier &p_base List<MethodInfo> methods; tmp.get_method_list(&methods); - for (const List<MethodInfo>::Element *E = methods.front(); E; E = E->next()) { - ScriptCodeCompletionOption option(E->get().name, ScriptCodeCompletionOption::KIND_FUNCTION); - if (E->get().arguments.size()) { + for (const MethodInfo &E : methods) { + ScriptCodeCompletionOption option(E.name, ScriptCodeCompletionOption::KIND_FUNCTION); + if (E.arguments.size()) { option.insert_text += "("; } else { option.insert_text += "()"; @@ -1019,9 +1019,9 @@ static void _find_identifiers(GDScriptParser::CompletionContext &p_context, bool List<StringName> functions; GDScriptUtilityFunctions::get_function_list(&functions); - for (const List<StringName>::Element *E = functions.front(); E; E = E->next()) { - MethodInfo function = GDScriptUtilityFunctions::get_function_info(E->get()); - ScriptCodeCompletionOption option(String(E->get()), ScriptCodeCompletionOption::KIND_FUNCTION); + for (const StringName &E : functions) { + MethodInfo function = GDScriptUtilityFunctions::get_function_info(E); + ScriptCodeCompletionOption option(String(E), ScriptCodeCompletionOption::KIND_FUNCTION); if (function.arguments.size() || (function.flags & METHOD_FLAG_VARARG)) { option.insert_text += "("; } else { @@ -1768,9 +1768,9 @@ static bool _guess_identifier_type(GDScriptParser::CompletionContext &p_context, StringName real_native = GDScriptParser::get_real_class_name(base_type.native_type); MethodInfo info; if (ClassDB::get_method_info(real_native, p_context.current_function->identifier->name, &info)) { - for (const List<PropertyInfo>::Element *E = info.arguments.front(); E; E = E->next()) { - if (E->get().name == p_identifier) { - r_type = _type_from_property(E->get()); + for (const PropertyInfo &E : info.arguments) { + if (E.name == p_identifier) { + r_type = _type_from_property(E); return true; } } @@ -1932,8 +1932,7 @@ static bool _guess_identifier_type_from_base(GDScriptParser::CompletionContext & if (!is_static) { List<PropertyInfo> members; scr->get_script_property_list(&members); - for (const List<PropertyInfo>::Element *E = members.front(); E; E = E->next()) { - const PropertyInfo &prop = E->get(); + for (const PropertyInfo &prop : members) { if (prop.name == p_identifier) { r_type = _type_from_property(prop); return true; @@ -2096,8 +2095,7 @@ static bool _guess_method_return_type_from_base(GDScriptParser::CompletionContex if (scr.is_valid()) { List<MethodInfo> methods; scr->get_script_method_list(&methods); - for (List<MethodInfo>::Element *E = methods.front(); E; E = E->next()) { - MethodInfo &mi = E->get(); + for (const MethodInfo &mi : methods) { if (mi.name == p_method) { r_type = _type_from_property(mi.return_val); return true; @@ -2137,8 +2135,7 @@ static bool _guess_method_return_type_from_base(GDScriptParser::CompletionContex List<MethodInfo> methods; tmp.get_method_list(&methods); - for (List<MethodInfo>::Element *E = methods.front(); E; E = E->next()) { - MethodInfo &mi = E->get(); + for (const MethodInfo &mi : methods) { if (mi.name == p_method) { r_type = _type_from_property(mi.return_val); return true; @@ -2183,8 +2180,8 @@ static void _find_enumeration_candidates(GDScriptParser::CompletionContext &p_co List<StringName> enum_constants; ClassDB::get_enum_constants(class_name, enum_name, &enum_constants); - for (List<StringName>::Element *E = enum_constants.front(); E; E = E->next()) { - String candidate = class_name + "." + E->get(); + for (const StringName &E : enum_constants) { + String candidate = class_name + "." + E; ScriptCodeCompletionOption option(candidate, ScriptCodeCompletionOption::KIND_ENUM); r_result.insert(option.display, option); } @@ -2228,8 +2225,8 @@ static void _find_call_arguments(GDScriptParser::CompletionContext &p_context, c if (obj) { List<String> options; obj->get_argument_options(p_method, p_argidx, &options); - for (List<String>::Element *F = options.front(); F; F = F->next()) { - ScriptCodeCompletionOption option(F->get(), ScriptCodeCompletionOption::KIND_FUNCTION); + for (const String &F : options) { + ScriptCodeCompletionOption option(F, ScriptCodeCompletionOption::KIND_FUNCTION); r_result.insert(option.display, option); } } @@ -2250,8 +2247,8 @@ static void _find_call_arguments(GDScriptParser::CompletionContext &p_context, c List<PropertyInfo> props; ProjectSettings::get_singleton()->get_property_list(&props); - for (List<PropertyInfo>::Element *E = props.front(); E; E = E->next()) { - String s = E->get().name; + for (const PropertyInfo &E : props) { + String s = E.name; if (!s.begins_with("autoload/")) { continue; } @@ -2266,8 +2263,8 @@ static void _find_call_arguments(GDScriptParser::CompletionContext &p_context, c // Get input actions List<PropertyInfo> props; ProjectSettings::get_singleton()->get_property_list(&props); - for (List<PropertyInfo>::Element *E = props.front(); E; E = E->next()) { - String s = E->get().name; + for (const PropertyInfo &E : props) { + String s = E.name; if (!s.begins_with("input/")) { continue; } @@ -2291,9 +2288,9 @@ static void _find_call_arguments(GDScriptParser::CompletionContext &p_context, c List<MethodInfo> methods; base.get_method_list(&methods); - for (List<MethodInfo>::Element *E = methods.front(); E; E = E->next()) { - if (E->get().name == p_method) { - r_arghint = _make_arguments_hint(E->get(), p_argidx); + for (const MethodInfo &E : methods) { + if (E.name == p_method) { + r_arghint = _make_arguments_hint(E, p_argidx); return; } } @@ -2340,14 +2337,14 @@ static void _find_call_arguments(GDScriptParser::CompletionContext &p_context, c Variant::get_constructor_list(GDScriptParser::get_builtin_type(call->function_name), &constructors); int i = 0; - for (List<MethodInfo>::Element *E = constructors.front(); E; E = E->next()) { - if (p_argidx >= E->get().arguments.size()) { + for (const MethodInfo &E : constructors) { + if (p_argidx >= E.arguments.size()) { continue; } if (i > 0) { r_arghint += "\n"; } - r_arghint += _make_arguments_hint(E->get(), p_argidx); + r_arghint += _make_arguments_hint(E, p_argidx); i++; } return; @@ -2406,9 +2403,9 @@ static void _find_call_arguments(GDScriptParser::CompletionContext &p_context, c case GDScriptParser::COMPLETION_ANNOTATION: { List<MethodInfo> annotations; parser.get_annotation_list(&annotations); - for (const List<MethodInfo>::Element *E = annotations.front(); E != nullptr; E = E->next()) { - ScriptCodeCompletionOption option(E->get().name.substr(1), ScriptCodeCompletionOption::KIND_PLAIN_TEXT); - if (E->get().arguments.size() > 0) { + for (const MethodInfo &E : annotations) { + ScriptCodeCompletionOption option(E.name.substr(1), ScriptCodeCompletionOption::KIND_PLAIN_TEXT); + if (E.arguments.size() > 0) { option.insert_text += "("; } options.insert(option.display, option); @@ -2426,10 +2423,10 @@ static void _find_call_arguments(GDScriptParser::CompletionContext &p_context, c case GDScriptParser::COMPLETION_BUILT_IN_TYPE_CONSTANT: { List<StringName> constants; Variant::get_constants_for_type(completion_context.builtin_type, &constants); - for (const List<StringName>::Element *E = constants.front(); E != nullptr; E = E->next()) { - ScriptCodeCompletionOption option(E->get(), ScriptCodeCompletionOption::KIND_CONSTANT); + for (const StringName &E : constants) { + ScriptCodeCompletionOption option(E, ScriptCodeCompletionOption::KIND_CONSTANT); bool valid = false; - Variant default_value = Variant::get_constant_value(completion_context.builtin_type, E->get(), &valid); + Variant default_value = Variant::get_constant_value(completion_context.builtin_type, E, &valid); if (valid) { option.default_value = default_value; } @@ -2606,8 +2603,7 @@ static void _find_call_arguments(GDScriptParser::CompletionContext &p_context, c List<MethodInfo> virtual_methods; ClassDB::get_virtual_methods(class_name, &virtual_methods); - for (List<MethodInfo>::Element *E = virtual_methods.front(); E; E = E->next()) { - MethodInfo &mi = E->get(); + for (const MethodInfo &mi : virtual_methods) { String method_hint = mi.name; if (method_hint.find(":") != -1) { method_hint = method_hint.get_slice(":", 0); @@ -2656,8 +2652,8 @@ static void _find_call_arguments(GDScriptParser::CompletionContext &p_context, c List<String> opts; p_owner->get_argument_options("get_node", 0, &opts); - for (List<String>::Element *E = opts.front(); E; E = E->next()) { - String opt = E->get().strip_edges(); + for (const String &E : opts) { + String opt = E.strip_edges(); if (opt.is_quoted()) { r_forced = true; String idopt = opt.unquote(); @@ -2841,8 +2837,8 @@ static Error _lookup_symbol_from_base(const GDScriptParser::DataType &p_base, co List<MethodInfo> virtual_methods; ClassDB::get_virtual_methods(class_name, &virtual_methods, true); - for (List<MethodInfo>::Element *E = virtual_methods.front(); E; E = E->next()) { - if (E->get().name == p_symbol) { + for (const MethodInfo &E : virtual_methods) { + if (E.name == p_symbol) { r_result.type = ScriptLanguage::LookupResult::RESULT_CLASS_METHOD; r_result.class_name = base_type.native_type; r_result.class_member = p_symbol; @@ -2860,8 +2856,8 @@ static Error _lookup_symbol_from_base(const GDScriptParser::DataType &p_base, co List<String> constants; ClassDB::get_integer_constant_list(class_name, &constants, true); - for (List<String>::Element *E = constants.front(); E; E = E->next()) { - if (E->get() == p_symbol) { + for (const String &E : constants) { + if (E == p_symbol) { r_result.type = ScriptLanguage::LookupResult::RESULT_CLASS_CONSTANT; r_result.class_name = base_type.native_type; r_result.class_member = p_symbol; diff --git a/modules/gdscript/gdscript_function.cpp b/modules/gdscript/gdscript_function.cpp index 78399114a5..876c508689 100644 --- a/modules/gdscript/gdscript_function.cpp +++ b/modules/gdscript/gdscript_function.cpp @@ -94,8 +94,7 @@ struct _GDFKCS { void GDScriptFunction::debug_get_stack_member_state(int p_line, List<Pair<StringName, int>> *r_stackvars) const { int oc = 0; Map<StringName, _GDFKC> sdmap; - for (const List<StackDebug>::Element *E = stack_debug.front(); E; E = E->next()) { - const StackDebug &sd = E->get(); + for (const StackDebug &sd : stack_debug) { if (sd.line > p_line) { break; } @@ -131,10 +130,10 @@ void GDScriptFunction::debug_get_stack_member_state(int p_line, List<Pair<String stackpositions.sort(); - for (List<_GDFKCS>::Element *E = stackpositions.front(); E; E = E->next()) { + for (_GDFKCS &E : stackpositions) { Pair<StringName, int> p; - p.first = E->get().id; - p.second = E->get().pos; + p.first = E.id; + p.second = E.pos; r_stackvars->push_back(p); } } @@ -262,9 +261,9 @@ Variant GDScriptFunctionState::resume(const Variant &p_arg) { if (completed) { if (first_state.is_valid()) { - first_state->emit_signal("completed", ret); + first_state->emit_signal(SNAME("completed"), ret); } else { - emit_signal("completed", ret); + emit_signal(SNAME("completed"), ret); } #ifdef DEBUG_ENABLED diff --git a/modules/gdscript/gdscript_function.h b/modules/gdscript/gdscript_function.h index 553c2ecc01..9e5ef0f632 100644 --- a/modules/gdscript/gdscript_function.h +++ b/modules/gdscript/gdscript_function.h @@ -472,7 +472,7 @@ private: int _initial_line = 0; bool _static = false; - MultiplayerAPI::RPCMode rpc_mode = MultiplayerAPI::RPC_MODE_DISABLED; + MultiplayerAPI::RPCConfig rpc_config; GDScript *_script = nullptr; @@ -592,7 +592,7 @@ public: void disassemble(const Vector<String> &p_code_lines) const; #endif - _FORCE_INLINE_ MultiplayerAPI::RPCMode get_rpc_mode() const { return rpc_mode; } + _FORCE_INLINE_ MultiplayerAPI::RPCConfig get_rpc_config() const { return rpc_config; } GDScriptFunction(); ~GDScriptFunction(); }; diff --git a/modules/gdscript/gdscript_parser.cpp b/modules/gdscript/gdscript_parser.cpp index 1a22820c63..466ddb4b10 100644 --- a/modules/gdscript/gdscript_parser.cpp +++ b/modules/gdscript/gdscript_parser.cpp @@ -136,8 +136,8 @@ void GDScriptParser::cleanup() { void GDScriptParser::get_annotation_list(List<MethodInfo> *r_annotations) const { List<StringName> keys; valid_annotations.get_key_list(&keys); - for (const List<StringName>::Element *E = keys.front(); E != nullptr; E = E->next()) { - r_annotations->push_back(valid_annotations[E->get()].info); + for (const StringName &E : keys) { + r_annotations->push_back(valid_annotations[E].info); } } @@ -168,12 +168,7 @@ GDScriptParser::GDScriptParser() { register_annotation(MethodInfo("@export_flags_3d_physics"), AnnotationInfo::VARIABLE, &GDScriptParser::export_annotations<PROPERTY_HINT_LAYERS_3D_PHYSICS, Variant::INT>); register_annotation(MethodInfo("@export_flags_3d_navigation"), AnnotationInfo::VARIABLE, &GDScriptParser::export_annotations<PROPERTY_HINT_LAYERS_3D_NAVIGATION, Variant::INT>); // Networking. - register_annotation(MethodInfo("@remote"), AnnotationInfo::VARIABLE | AnnotationInfo::FUNCTION, &GDScriptParser::network_annotations<MultiplayerAPI::RPC_MODE_REMOTE>); - register_annotation(MethodInfo("@master"), AnnotationInfo::VARIABLE | AnnotationInfo::FUNCTION, &GDScriptParser::network_annotations<MultiplayerAPI::RPC_MODE_MASTER>); - register_annotation(MethodInfo("@puppet"), AnnotationInfo::VARIABLE | AnnotationInfo::FUNCTION, &GDScriptParser::network_annotations<MultiplayerAPI::RPC_MODE_PUPPET>); - register_annotation(MethodInfo("@remotesync"), AnnotationInfo::VARIABLE | AnnotationInfo::FUNCTION, &GDScriptParser::network_annotations<MultiplayerAPI::RPC_MODE_REMOTESYNC>); - register_annotation(MethodInfo("@mastersync"), AnnotationInfo::VARIABLE | AnnotationInfo::FUNCTION, &GDScriptParser::network_annotations<MultiplayerAPI::RPC_MODE_MASTERSYNC>); - register_annotation(MethodInfo("@puppetsync"), AnnotationInfo::VARIABLE | AnnotationInfo::FUNCTION, &GDScriptParser::network_annotations<MultiplayerAPI::RPC_MODE_PUPPETSYNC>); + register_annotation(MethodInfo("@rpc", { Variant::STRING, "mode" }, { Variant::STRING, "sync" }, { Variant::STRING, "transfer_mode" }, { Variant::INT, "transfer_channel" }), AnnotationInfo::FUNCTION, &GDScriptParser::network_annotations<MultiplayerAPI::RPC_MODE_MASTER>, 4, true); // TODO: Warning annotations. } @@ -253,7 +248,7 @@ void GDScriptParser::push_warning(const Node *p_source, GDScriptWarning::Code p_ warning.rightmost_column = p_source->rightmost_column; List<GDScriptWarning>::Element *before = nullptr; - for (List<GDScriptWarning>::Element *E = warnings.front(); E != nullptr; E = E->next()) { + for (List<GDScriptWarning>::Element *E = warnings.front(); E; E = E->next()) { if (E->get().start_line > warning.start_line) { break; } @@ -1337,8 +1332,7 @@ GDScriptParser::AnnotationNode *GDScriptParser::parse_annotation(uint32_t p_vali } void GDScriptParser::clear_unused_annotations() { - for (const List<AnnotationNode *>::Element *E = annotation_stack.front(); E != nullptr; E = E->next()) { - AnnotationNode *annotation = E->get(); + for (const AnnotationNode *annotation : annotation_stack) { push_error(vformat(R"(Annotation "%s" does not precedes a valid target, so it will have no effect.)", annotation->name), annotation); } @@ -1801,8 +1795,8 @@ GDScriptParser::MatchBranchNode *GDScriptParser::parse_match_branch() { List<StringName> binds; branch->patterns[0]->binds.get_key_list(&binds); - for (List<StringName>::Element *E = binds.front(); E != nullptr; E = E->next()) { - SuiteNode::Local local(branch->patterns[0]->binds[E->get()], current_function); + for (const StringName &E : binds) { + SuiteNode::Local local(branch->patterns[0]->binds[E], current_function); suite->add_local(local); } } @@ -2128,10 +2122,10 @@ GDScriptParser::ExpressionNode *GDScriptParser::parse_builtin_constant(Expressio constant->value = Math_TAU; break; case GDScriptTokenizer::Token::CONST_INF: - constant->value = Math_INF; + constant->value = INFINITY; break; case GDScriptTokenizer::Token::CONST_NAN: - constant->value = Math_NAN; + constant->value = NAN; break; default: return nullptr; // Unreachable. @@ -3430,27 +3424,60 @@ template <MultiplayerAPI::RPCMode t_mode> bool GDScriptParser::network_annotations(const AnnotationNode *p_annotation, Node *p_node) { ERR_FAIL_COND_V_MSG(p_node->type != Node::VARIABLE && p_node->type != Node::FUNCTION, false, vformat(R"("%s" annotation can only be applied to variables and functions.)", p_annotation->name)); - switch (p_node->type) { - case Node::VARIABLE: { - VariableNode *variable = static_cast<VariableNode *>(p_node); - if (variable->rpc_mode != MultiplayerAPI::RPC_MODE_DISABLED) { - push_error(R"(RPC annotations can only be used once per variable.)", p_annotation); + MultiplayerAPI::RPCConfig rpc_config; + rpc_config.rpc_mode = t_mode; + for (int i = 0; i < p_annotation->resolved_arguments.size(); i++) { + if (i == 0) { + String mode = p_annotation->resolved_arguments[i].operator String(); + if (mode == "any") { + rpc_config.rpc_mode = MultiplayerAPI::RPC_MODE_REMOTE; + } else if (mode == "master") { + rpc_config.rpc_mode = MultiplayerAPI::RPC_MODE_MASTER; + } else if (mode == "puppet") { + rpc_config.rpc_mode = MultiplayerAPI::RPC_MODE_PUPPET; + } else { + push_error(R"(Invalid RPC mode. Must be one of: 'any', 'master', or 'puppet')", p_annotation); + return false; } - variable->rpc_mode = t_mode; - break; + } else if (i == 1) { + String sync = p_annotation->resolved_arguments[i].operator String(); + if (sync == "sync") { + rpc_config.sync = true; + } else if (sync == "nosync") { + rpc_config.sync = false; + } else { + push_error(R"(Invalid RPC sync mode. Must be one of: 'sync' or 'nosync')", p_annotation); + return false; + } + } else if (i == 2) { + String mode = p_annotation->resolved_arguments[i].operator String(); + if (mode == "reliable") { + rpc_config.transfer_mode = MultiplayerPeer::TRANSFER_MODE_RELIABLE; + } else if (mode == "unreliable") { + rpc_config.transfer_mode = MultiplayerPeer::TRANSFER_MODE_UNRELIABLE; + } else if (mode == "ordered") { + rpc_config.transfer_mode = MultiplayerPeer::TRANSFER_MODE_UNRELIABLE_ORDERED; + } else { + push_error(R"(Invalid RPC transfer mode. Must be one of: 'reliable', 'unreliable', 'ordered')", p_annotation); + return false; + } + } else if (i == 3) { + rpc_config.channel = p_annotation->resolved_arguments[i].operator int(); } + } + switch (p_node->type) { case Node::FUNCTION: { FunctionNode *function = static_cast<FunctionNode *>(p_node); - if (function->rpc_mode != MultiplayerAPI::RPC_MODE_DISABLED) { + if (function->rpc_config.rpc_mode != MultiplayerAPI::RPC_MODE_DISABLED) { push_error(R"(RPC annotations can only be used once per function.)", p_annotation); + return false; } - function->rpc_mode = t_mode; + function->rpc_config = rpc_config; break; } default: return false; // Unreachable. } - return true; } @@ -3590,7 +3617,7 @@ void GDScriptParser::TreePrinter::push_text(const String &p_text) { printed += p_text; } -void GDScriptParser::TreePrinter::print_annotation(AnnotationNode *p_annotation) { +void GDScriptParser::TreePrinter::print_annotation(const AnnotationNode *p_annotation) { push_text(p_annotation->name); push_text(" ("); for (int i = 0; i < p_annotation->arguments.size(); i++) { @@ -3965,8 +3992,8 @@ void GDScriptParser::TreePrinter::print_for(ForNode *p_for) { } void GDScriptParser::TreePrinter::print_function(FunctionNode *p_function, const String &p_context) { - for (const List<AnnotationNode *>::Element *E = p_function->annotations.front(); E != nullptr; E = E->next()) { - print_annotation(E->get()); + for (const AnnotationNode *E : p_function->annotations) { + print_annotation(E); } push_text(p_context); push_text(" "); @@ -4305,8 +4332,8 @@ void GDScriptParser::TreePrinter::print_unary_op(UnaryOpNode *p_unary_op) { } void GDScriptParser::TreePrinter::print_variable(VariableNode *p_variable) { - for (const List<AnnotationNode *>::Element *E = p_variable->annotations.front(); E != nullptr; E = E->next()) { - print_annotation(E->get()); + for (const AnnotationNode *E : p_variable->annotations) { + print_annotation(E); } push_text("Variable "); diff --git a/modules/gdscript/gdscript_parser.h b/modules/gdscript/gdscript_parser.h index 9e0b60a407..6a227a55e5 100644 --- a/modules/gdscript/gdscript_parser.h +++ b/modules/gdscript/gdscript_parser.h @@ -729,7 +729,7 @@ public: SuiteNode *body = nullptr; bool is_static = false; bool is_coroutine = false; - MultiplayerAPI::RPCMode rpc_mode = MultiplayerAPI::RPC_MODE_DISABLED; + MultiplayerAPI::RPCConfig rpc_config; MethodInfo info; LambdaNode *source_lambda = nullptr; #ifdef TOOLS_ENABLED @@ -1117,7 +1117,6 @@ public: bool exported = false; bool onready = false; PropertyInfo export_info; - MultiplayerAPI::RPCMode rpc_mode = MultiplayerAPI::RPC_MODE_DISABLED; int assignments = 0; int usages = 0; bool use_conversion_assign = false; @@ -1432,7 +1431,7 @@ public: void push_line(const String &p_line = String()); void push_text(const String &p_text); - void print_annotation(AnnotationNode *p_annotation); + void print_annotation(const AnnotationNode *p_annotation); void print_array(ArrayNode *p_array); void print_assert(AssertNode *p_assert); void print_assignment(AssignmentNode *p_assignment); diff --git a/modules/gdscript/gdscript_utility_functions.cpp b/modules/gdscript/gdscript_utility_functions.cpp index 64c629662c..62531473c3 100644 --- a/modules/gdscript/gdscript_utility_functions.cpp +++ b/modules/gdscript/gdscript_utility_functions.cpp @@ -706,8 +706,8 @@ bool GDScriptUtilityFunctions::function_exists(const StringName &p_function) { } void GDScriptUtilityFunctions::get_function_list(List<StringName> *r_functions) { - for (const List<StringName>::Element *E = utility_function_name_table.front(); E; E = E->next()) { - r_functions->push_back(E->get()); + for (const StringName &E : utility_function_name_table) { + r_functions->push_back(E); } } diff --git a/modules/gdscript/language_server/gdscript_extend_parser.cpp b/modules/gdscript/language_server/gdscript_extend_parser.cpp index f817964a3c..d106b3b541 100644 --- a/modules/gdscript/language_server/gdscript_extend_parser.cpp +++ b/modules/gdscript/language_server/gdscript_extend_parser.cpp @@ -39,8 +39,7 @@ void ExtendGDScriptParser::update_diagnostics() { diagnostics.clear(); const List<ParserError> &errors = get_errors(); - for (const List<ParserError>::Element *E = errors.front(); E != nullptr; E = E->next()) { - const ParserError &error = E->get(); + for (const ParserError &error : errors) { lsp::Diagnostic diagnostic; diagnostic.severity = lsp::DiagnosticSeverity::Error; diagnostic.message = error.message; @@ -61,8 +60,7 @@ void ExtendGDScriptParser::update_diagnostics() { } const List<GDScriptWarning> &warnings = get_warnings(); - for (const List<GDScriptWarning>::Element *E = warnings.front(); E; E = E->next()) { - const GDScriptWarning &warning = E->get(); + for (const GDScriptWarning &warning : warnings) { lsp::Diagnostic diagnostic; diagnostic.severity = lsp::DiagnosticSeverity::Warning; diagnostic.message = "(" + warning.get_name() + "): " + warning.get_message(); @@ -152,9 +150,9 @@ void ExtendGDScriptParser::parse_class_symbol(const GDScriptParser::ClassNode *p } r_symbol.kind = lsp::SymbolKind::Class; r_symbol.deprecated = false; - r_symbol.range.start.line = LINE_NUMBER_TO_INDEX(p_class->start_line); - r_symbol.range.start.character = LINE_NUMBER_TO_INDEX(p_class->start_column); - r_symbol.range.end.line = LINE_NUMBER_TO_INDEX(p_class->end_line); + r_symbol.range.start.line = p_class->start_line; + r_symbol.range.start.character = p_class->start_column; + r_symbol.range.end.line = lines.size(); r_symbol.selectionRange.start.line = r_symbol.range.start.line; r_symbol.detail = "class " + r_symbol.name; bool is_root_class = &r_symbol == &class_symbol; @@ -167,7 +165,7 @@ void ExtendGDScriptParser::parse_class_symbol(const GDScriptParser::ClassNode *p case ClassNode::Member::VARIABLE: { lsp::DocumentSymbol symbol; symbol.name = m.variable->identifier->name; - symbol.kind = lsp::SymbolKind::Variable; + symbol.kind = m.variable->property == VariableNode::PropertyStyle::PROP_NONE ? lsp::SymbolKind::Variable : lsp::SymbolKind::Property; symbol.deprecated = false; symbol.range.start.line = LINE_NUMBER_TO_INDEX(m.variable->start_line); symbol.range.start.character = LINE_NUMBER_TO_INDEX(m.variable->start_column); @@ -319,7 +317,7 @@ void ExtendGDScriptParser::parse_function_symbol(const GDScriptParser::FunctionN const String uri = get_uri(); r_symbol.name = p_func->identifier->name; - r_symbol.kind = lsp::SymbolKind::Function; + r_symbol.kind = p_func->is_static ? lsp::SymbolKind::Function : lsp::SymbolKind::Method; r_symbol.detail = "func " + String(p_func->identifier->name) + "("; r_symbol.deprecated = false; r_symbol.range.start.line = LINE_NUMBER_TO_INDEX(p_func->start_line); @@ -467,8 +465,8 @@ String ExtendGDScriptParser::parse_documentation(int p_line, bool p_docs_down) { } String doc; - for (List<String>::Element *E = doc_lines.front(); E; E = E->next()) { - doc += E->get() + "\n"; + for (const String &E : doc_lines) { + doc += E + "\n"; } return doc; } @@ -695,7 +693,9 @@ Dictionary ExtendGDScriptParser::dump_function_api(const GDScriptParser::Functio ERR_FAIL_NULL_V(p_func, func); func["name"] = p_func->identifier->name; func["return_type"] = p_func->get_datatype().to_string(); - func["rpc_mode"] = p_func->rpc_mode; + func["rpc_mode"] = p_func->rpc_config.rpc_mode; + func["rpc_transfer_mode"] = p_func->rpc_config.transfer_mode; + func["rpc_transfer_channel"] = p_func->rpc_config.channel; Array parameters; for (int i = 0; i < p_func->parameters.size(); i++) { Dictionary arg; diff --git a/modules/gdscript/language_server/gdscript_language_protocol.h b/modules/gdscript/language_server/gdscript_language_protocol.h index 969c38eab6..5a2dd55c46 100644 --- a/modules/gdscript/language_server/gdscript_language_protocol.h +++ b/modules/gdscript/language_server/gdscript_language_protocol.h @@ -28,8 +28,8 @@ /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ /*************************************************************************/ -#ifndef GDSCRIPT_PROTOCAL_SERVER_H -#define GDSCRIPT_PROTOCAL_SERVER_H +#ifndef GDSCRIPT_LANGUAGE_PROTOCOL_H +#define GDSCRIPT_LANGUAGE_PROTOCOL_H #include "core/io/stream_peer.h" #include "core/io/stream_peer_tcp.h" @@ -37,7 +37,13 @@ #include "gdscript_text_document.h" #include "gdscript_workspace.h" #include "lsp.hpp" + +#include "modules/modules_enabled.gen.h" +#ifdef MODULE_JSONRPC_ENABLED #include "modules/jsonrpc/jsonrpc.h" +#else +#error "Can't build GDScript LSP without JSONRPC module." +#endif #define LSP_MAX_BUFFER_SIZE 4194304 #define LSP_MAX_CLIENTS 8 @@ -108,4 +114,4 @@ public: GDScriptLanguageProtocol(); }; -#endif +#endif // GDSCRIPT_LANGUAGE_PROTOCOL_H diff --git a/modules/gdscript/language_server/gdscript_text_document.cpp b/modules/gdscript/language_server/gdscript_text_document.cpp index 59d2e6c8fa..69ddbe5d1e 100644 --- a/modules/gdscript/language_server/gdscript_text_document.cpp +++ b/modules/gdscript/language_server/gdscript_text_document.cpp @@ -157,8 +157,7 @@ Array GDScriptTextDocument::completion(const Dictionary &p_params) { int i = 0; arr.resize(options.size()); - for (const List<ScriptCodeCompletionOption>::Element *E = options.front(); E; E = E->next()) { - const ScriptCodeCompletionOption &option = E->get(); + for (const ScriptCodeCompletionOption &option : options) { lsp::CompletionItem item; item.label = option.display; item.data = request_data; @@ -294,8 +293,8 @@ Array GDScriptTextDocument::documentLink(const Dictionary &p_params) { List<lsp::DocumentLink> links; GDScriptLanguageProtocol::get_singleton()->get_workspace()->resolve_document_links(params.textDocument.uri, links); - for (const List<lsp::DocumentLink>::Element *E = links.front(); E; E = E->next()) { - ret.push_back(E->get().to_json()); + for (const lsp::DocumentLink &E : links) { + ret.push_back(E.to_json()); } return ret; } @@ -322,8 +321,8 @@ Variant GDScriptTextDocument::hover(const Dictionary &p_params) { Array contents; List<const lsp::DocumentSymbol *> list; GDScriptLanguageProtocol::get_singleton()->get_workspace()->resolve_related_symbols(params, list); - for (List<const lsp::DocumentSymbol *>::Element *E = list.front(); E; E = E->next()) { - if (const lsp::DocumentSymbol *s = E->get()) { + for (const lsp::DocumentSymbol *&E : list) { + if (const lsp::DocumentSymbol *s = E) { contents.push_back(s->render().value); } } @@ -373,7 +372,7 @@ Variant GDScriptTextDocument::declaration(const Dictionary &p_params) { id = "class_global:" + symbol->native_class + ":" + symbol->name; break; } - call_deferred("show_native_symbol_in_editor", id); + call_deferred(SNAME("show_native_symbol_in_editor"), id); } else { notify_client_show_symbol(symbol); } @@ -410,7 +409,7 @@ void GDScriptTextDocument::sync_script_content(const String &p_path, const Strin } void GDScriptTextDocument::show_native_symbol_in_editor(const String &p_symbol_id) { - ScriptEditor::get_singleton()->call_deferred("_help_class_goto", p_symbol_id); + ScriptEditor::get_singleton()->call_deferred(SNAME("_help_class_goto"), p_symbol_id); DisplayServer::get_singleton()->window_move_to_foreground(); } @@ -430,8 +429,8 @@ Array GDScriptTextDocument::find_symbols(const lsp::TextDocumentPositionParams & } else if (GDScriptLanguageProtocol::get_singleton()->is_smart_resolve_enabled()) { List<const lsp::DocumentSymbol *> list; GDScriptLanguageProtocol::get_singleton()->get_workspace()->resolve_related_symbols(p_location, list); - for (List<const lsp::DocumentSymbol *>::Element *E = list.front(); E; E = E->next()) { - if (const lsp::DocumentSymbol *s = E->get()) { + for (const lsp::DocumentSymbol *&E : list) { + if (const lsp::DocumentSymbol *s = E) { if (!s->uri.is_empty()) { lsp::Location location; location.uri = s->uri; diff --git a/modules/gdscript/language_server/gdscript_workspace.cpp b/modules/gdscript/language_server/gdscript_workspace.cpp index 1915c92cbf..e6c819b22f 100644 --- a/modules/gdscript/language_server/gdscript_workspace.cpp +++ b/modules/gdscript/language_server/gdscript_workspace.cpp @@ -119,8 +119,7 @@ const lsp::DocumentSymbol *GDScriptWorkspace::get_script_symbol(const String &p_ void GDScriptWorkspace::reload_all_workspace_scripts() { List<String> paths; list_script_files("res://", paths); - for (List<String>::Element *E = paths.front(); E; E = E->next()) { - const String &path = E->get(); + for (const String &path : paths) { Error err; String content = FileAccess::get_file_as_string(path, &err); ERR_CONTINUE(err != OK); @@ -559,8 +558,8 @@ const lsp::DocumentSymbol *GDScriptWorkspace::resolve_native_symbol(const lsp::N void GDScriptWorkspace::resolve_document_links(const String &p_uri, List<lsp::DocumentLink> &r_list) { if (const ExtendGDScriptParser *parser = get_parse_successed_script(get_file_path(p_uri))) { const List<lsp::DocumentLink> &links = parser->get_document_links(); - for (const List<lsp::DocumentLink>::Element *E = links.front(); E; E = E->next()) { - r_list.push_back(E->get()); + for (const lsp::DocumentLink &E : links) { + r_list.push_back(E); } } } @@ -587,8 +586,7 @@ Error GDScriptWorkspace::resolve_signature(const lsp::TextDocumentPositionParams GDScriptLanguageProtocol::get_singleton()->get_workspace()->resolve_related_symbols(text_pos, symbols); } - for (List<const lsp::DocumentSymbol *>::Element *E = symbols.front(); E; E = E->next()) { - const lsp::DocumentSymbol *symbol = E->get(); + for (const lsp::DocumentSymbol *const &symbol : symbols) { if (symbol->kind == lsp::SymbolKind::Method || symbol->kind == lsp::SymbolKind::Function) { lsp::SignatureInformation signature_info; signature_info.label = symbol->detail; diff --git a/modules/gdscript/language_server/lsp.hpp b/modules/gdscript/language_server/lsp.hpp index a7dcfdb22d..0138f132ad 100644 --- a/modules/gdscript/language_server/lsp.hpp +++ b/modules/gdscript/language_server/lsp.hpp @@ -1018,32 +1018,32 @@ struct CompletionList { * A symbol kind. */ namespace SymbolKind { -static const int File = 0; -static const int Module = 1; -static const int Namespace = 2; -static const int Package = 3; -static const int Class = 4; -static const int Method = 5; -static const int Property = 6; -static const int Field = 7; -static const int Constructor = 8; -static const int Enum = 9; -static const int Interface = 10; -static const int Function = 11; -static const int Variable = 12; -static const int Constant = 13; -static const int String = 14; -static const int Number = 15; -static const int Boolean = 16; -static const int Array = 17; -static const int Object = 18; -static const int Key = 19; -static const int Null = 20; -static const int EnumMember = 21; -static const int Struct = 22; -static const int Event = 23; -static const int Operator = 24; -static const int TypeParameter = 25; +static const int File = 1; +static const int Module = 2; +static const int Namespace = 3; +static const int Package = 4; +static const int Class = 5; +static const int Method = 6; +static const int Property = 7; +static const int Field = 8; +static const int Constructor = 9; +static const int Enum = 10; +static const int Interface = 11; +static const int Function = 12; +static const int Variable = 13; +static const int Constant = 14; +static const int String = 15; +static const int Number = 16; +static const int Boolean = 17; +static const int Array = 18; +static const int Object = 19; +static const int Key = 20; +static const int Null = 21; +static const int EnumMember = 22; +static const int Struct = 23; +static const int Event = 24; +static const int Operator = 25; +static const int TypeParameter = 26; }; // namespace SymbolKind /** diff --git a/modules/gdscript/tests/gdscript_test_runner.cpp b/modules/gdscript/tests/gdscript_test_runner.cpp index b7faebb4ef..03a48bf071 100644 --- a/modules/gdscript/tests/gdscript_test_runner.cpp +++ b/modules/gdscript/tests/gdscript_test_runner.cpp @@ -295,7 +295,7 @@ void GDScriptTestRunner::handle_cmdline() { String test_cmd = "--gdscript-test"; String gen_cmd = "--gdscript-generate-tests"; - for (List<String>::Element *E = cmdline_args.front(); E != nullptr; E = E->next()) { + for (List<String>::Element *E = cmdline_args.front(); E; E = E->next()) { String &cmd = E->get(); if (cmd == test_cmd || cmd == gen_cmd) { if (E->next() == nullptr) { @@ -440,8 +440,8 @@ GDScriptTest::TestResult GDScriptTest::execute_test_code(bool p_is_generating) { result.output = get_text_for_status(result.status) + "\n"; const List<GDScriptParser::ParserError> &errors = parser.get_errors(); - for (const List<GDScriptParser::ParserError>::Element *E = errors.front(); E; E = E->next()) { - result.output += E->get().message + "\n"; // TODO: line, column? + for (const GDScriptParser::ParserError &E : errors) { + result.output += E.message + "\n"; // TODO: line, column? break; // Only the first error since the following might be cascading. } if (!p_is_generating) { @@ -459,8 +459,8 @@ GDScriptTest::TestResult GDScriptTest::execute_test_code(bool p_is_generating) { result.output = get_text_for_status(result.status) + "\n"; const List<GDScriptParser::ParserError> &errors = parser.get_errors(); - for (const List<GDScriptParser::ParserError>::Element *E = errors.front(); E; E = E->next()) { - result.output += E->get().message + "\n"; // TODO: line, column? + for (const GDScriptParser::ParserError &E : errors) { + result.output += E.message + "\n"; // TODO: line, column? break; // Only the first error since the following might be cascading. } if (!p_is_generating) { @@ -470,8 +470,8 @@ GDScriptTest::TestResult GDScriptTest::execute_test_code(bool p_is_generating) { } StringBuilder warning_string; - for (const List<GDScriptWarning>::Element *E = parser.get_warnings().front(); E != nullptr; E = E->next()) { - const GDScriptWarning warning = E->get(); + for (const GDScriptWarning &E : parser.get_warnings()) { + const GDScriptWarning warning = E; warning_string.append(">> WARNING"); warning_string.append("\n>> Line: "); warning_string.append(itos(warning.start_line)); diff --git a/modules/gdscript/tests/test_gdscript.cpp b/modules/gdscript/tests/test_gdscript.cpp index 7aa5895981..52e9d92223 100644 --- a/modules/gdscript/tests/test_gdscript.cpp +++ b/modules/gdscript/tests/test_gdscript.cpp @@ -113,8 +113,7 @@ static void test_parser(const String &p_code, const String &p_script_path, const if (err != OK) { const List<GDScriptParser::ParserError> &errors = parser.get_errors(); - for (const List<GDScriptParser::ParserError>::Element *E = errors.front(); E != nullptr; E = E->next()) { - const GDScriptParser::ParserError &error = E->get(); + for (const GDScriptParser::ParserError &error : errors) { print_line(vformat("%02d:%02d: %s", error.line, error.column, error.message)); } } @@ -124,8 +123,7 @@ static void test_parser(const String &p_code, const String &p_script_path, const if (err != OK) { const List<GDScriptParser::ParserError> &errors = parser.get_errors(); - for (const List<GDScriptParser::ParserError>::Element *E = errors.front(); E != nullptr; E = E->next()) { - const GDScriptParser::ParserError &error = E->get(); + for (const GDScriptParser::ParserError &error : errors) { print_line(vformat("%02d:%02d: %s", error.line, error.column, error.message)); } } @@ -143,8 +141,7 @@ static void test_compiler(const String &p_code, const String &p_script_path, con if (err != OK) { print_line("Error in parser:"); const List<GDScriptParser::ParserError> &errors = parser.get_errors(); - for (const List<GDScriptParser::ParserError>::Element *E = errors.front(); E != nullptr; E = E->next()) { - const GDScriptParser::ParserError &error = E->get(); + for (const GDScriptParser::ParserError &error : errors) { print_line(vformat("%02d:%02d: %s", error.line, error.column, error.message)); } return; @@ -156,8 +153,7 @@ static void test_compiler(const String &p_code, const String &p_script_path, con if (err != OK) { print_line("Error in analyzer:"); const List<GDScriptParser::ParserError> &errors = parser.get_errors(); - for (const List<GDScriptParser::ParserError>::Element *E = errors.front(); E != nullptr; E = E->next()) { - const GDScriptParser::ParserError &error = E->get(); + for (const GDScriptParser::ParserError &error : errors) { print_line(vformat("%02d:%02d: %s", error.line, error.column, error.message)); } return; diff --git a/modules/glslang/register_types.cpp b/modules/glslang/register_types.cpp index 730c6b89f7..dd545ff431 100644 --- a/modules/glslang/register_types.cpp +++ b/modules/glslang/register_types.cpp @@ -193,7 +193,7 @@ void preregister_glslang_types() { // initialize in case it's not initialized. This is done once per thread // and it's safe to call multiple times glslang::InitializeProcess(); - RenderingDevice::shader_set_compile_function(_compile_shader_glsl); + RenderingDevice::shader_set_compile_to_spirv_function(_compile_shader_glsl); RenderingDevice::shader_set_get_cache_key_function(_get_cache_key_function_glsl); } diff --git a/modules/gltf/doc_classes/GLTFSkeleton.xml b/modules/gltf/doc_classes/GLTFSkeleton.xml index 40563c9ac6..6e83cec252 100644 --- a/modules/gltf/doc_classes/GLTFSkeleton.xml +++ b/modules/gltf/doc_classes/GLTFSkeleton.xml @@ -8,50 +8,40 @@ </tutorials> <methods> <method name="get_bone_attachment"> - <return type="BoneAttachment3D"> - </return> - <argument index="0" name="idx" type="int"> - </argument> + <return type="BoneAttachment3D" /> + <argument index="0" name="idx" type="int" /> <description> </description> </method> <method name="get_bone_attachment_count"> - <return type="int"> - </return> + <return type="int" /> <description> </description> </method> <method name="get_godot_bone_node"> - <return type="Dictionary"> - </return> + <return type="Dictionary" /> <description> </description> </method> <method name="get_godot_skeleton"> - <return type="Skeleton3D"> - </return> + <return type="Skeleton3D" /> <description> </description> </method> <method name="get_unique_names"> - <return type="Array"> - </return> + <return type="Array" /> <description> </description> </method> <method name="set_godot_bone_node"> - <return type="void"> - </return> - <argument index="0" name="godot_bone_node" type="Dictionary"> - </argument> + <return type="void" /> + <argument index="0" name="godot_bone_node" type="Dictionary" /> <description> </description> </method> <method name="set_unique_names"> - <return type="void"> - </return> - <argument index="0" name="unique_names" type="Array"> - </argument> + <return type="void" /> + <argument index="0" name="unique_names" type="Array" /> <description> </description> </method> diff --git a/modules/gltf/doc_classes/GLTFSkin.xml b/modules/gltf/doc_classes/GLTFSkin.xml index e20e127e52..107ca960cd 100644 --- a/modules/gltf/doc_classes/GLTFSkin.xml +++ b/modules/gltf/doc_classes/GLTFSkin.xml @@ -8,44 +8,35 @@ </tutorials> <methods> <method name="get_inverse_binds"> - <return type="Array"> - </return> + <return type="Array" /> <description> </description> </method> <method name="get_joint_i_to_bone_i"> - <return type="Dictionary"> - </return> + <return type="Dictionary" /> <description> </description> </method> <method name="get_joint_i_to_name"> - <return type="Dictionary"> - </return> + <return type="Dictionary" /> <description> </description> </method> <method name="set_inverse_binds"> - <return type="void"> - </return> - <argument index="0" name="inverse_binds" type="Array"> - </argument> + <return type="void" /> + <argument index="0" name="inverse_binds" type="Array" /> <description> </description> </method> <method name="set_joint_i_to_bone_i"> - <return type="void"> - </return> - <argument index="0" name="joint_i_to_bone_i" type="Dictionary"> - </argument> + <return type="void" /> + <argument index="0" name="joint_i_to_bone_i" type="Dictionary" /> <description> </description> </method> <method name="set_joint_i_to_name"> - <return type="void"> - </return> - <argument index="0" name="joint_i_to_name" type="Dictionary"> - </argument> + <return type="void" /> + <argument index="0" name="joint_i_to_name" type="Dictionary" /> <description> </description> </method> diff --git a/modules/gltf/doc_classes/GLTFState.xml b/modules/gltf/doc_classes/GLTFState.xml index a7b5b7b43e..ae976fc04c 100644 --- a/modules/gltf/doc_classes/GLTFState.xml +++ b/modules/gltf/doc_classes/GLTFState.xml @@ -8,236 +8,185 @@ </tutorials> <methods> <method name="get_accessors"> - <return type="Array"> - </return> + <return type="Array" /> <description> </description> </method> <method name="get_animation_player"> - <return type="AnimationPlayer"> - </return> - <argument index="0" name="idx" type="int"> - </argument> + <return type="AnimationPlayer" /> + <argument index="0" name="idx" type="int" /> <description> </description> </method> <method name="get_animation_players_count"> - <return type="int"> - </return> - <argument index="0" name="idx" type="int"> - </argument> + <return type="int" /> + <argument index="0" name="idx" type="int" /> <description> </description> </method> <method name="get_animations"> - <return type="Array"> - </return> + <return type="Array" /> <description> </description> </method> <method name="get_buffer_views"> - <return type="Array"> - </return> + <return type="Array" /> <description> </description> </method> <method name="get_cameras"> - <return type="Array"> - </return> + <return type="Array" /> <description> </description> </method> <method name="get_images"> - <return type="Array"> - </return> + <return type="Array" /> <description> </description> </method> <method name="get_lights"> - <return type="Array"> - </return> + <return type="Array" /> <description> </description> </method> <method name="get_materials"> - <return type="Array"> - </return> + <return type="Array" /> <description> </description> </method> <method name="get_meshes"> - <return type="Array"> - </return> + <return type="Array" /> <description> </description> </method> <method name="get_nodes"> - <return type="Array"> - </return> + <return type="Array" /> <description> </description> </method> <method name="get_scene_node"> - <return type="Node"> - </return> - <argument index="0" name="idx" type="int"> - </argument> + <return type="Node" /> + <argument index="0" name="idx" type="int" /> <description> </description> </method> <method name="get_skeleton_to_node"> - <return type="Dictionary"> - </return> + <return type="Dictionary" /> <description> </description> </method> <method name="get_skeletons"> - <return type="Array"> - </return> + <return type="Array" /> <description> </description> </method> <method name="get_skins"> - <return type="Array"> - </return> + <return type="Array" /> <description> </description> </method> <method name="get_textures"> - <return type="Array"> - </return> + <return type="Array" /> <description> </description> </method> <method name="get_unique_animation_names"> - <return type="Array"> - </return> + <return type="Array" /> <description> </description> </method> <method name="get_unique_names"> - <return type="Array"> - </return> + <return type="Array" /> <description> </description> </method> <method name="set_accessors"> - <return type="void"> - </return> - <argument index="0" name="accessors" type="Array"> - </argument> + <return type="void" /> + <argument index="0" name="accessors" type="Array" /> <description> </description> </method> <method name="set_animations"> - <return type="void"> - </return> - <argument index="0" name="animations" type="Array"> - </argument> + <return type="void" /> + <argument index="0" name="animations" type="Array" /> <description> </description> </method> <method name="set_buffer_views"> - <return type="void"> - </return> - <argument index="0" name="buffer_views" type="Array"> - </argument> + <return type="void" /> + <argument index="0" name="buffer_views" type="Array" /> <description> </description> </method> <method name="set_cameras"> - <return type="void"> - </return> - <argument index="0" name="cameras" type="Array"> - </argument> + <return type="void" /> + <argument index="0" name="cameras" type="Array" /> <description> </description> </method> <method name="set_images"> - <return type="void"> - </return> - <argument index="0" name="images" type="Array"> - </argument> + <return type="void" /> + <argument index="0" name="images" type="Array" /> <description> </description> </method> <method name="set_lights"> - <return type="void"> - </return> - <argument index="0" name="lights" type="Array"> - </argument> + <return type="void" /> + <argument index="0" name="lights" type="Array" /> <description> </description> </method> <method name="set_materials"> - <return type="void"> - </return> - <argument index="0" name="materials" type="Array"> - </argument> + <return type="void" /> + <argument index="0" name="materials" type="Array" /> <description> </description> </method> <method name="set_meshes"> - <return type="void"> - </return> - <argument index="0" name="meshes" type="Array"> - </argument> + <return type="void" /> + <argument index="0" name="meshes" type="Array" /> <description> </description> </method> <method name="set_nodes"> - <return type="void"> - </return> - <argument index="0" name="nodes" type="Array"> - </argument> + <return type="void" /> + <argument index="0" name="nodes" type="Array" /> <description> </description> </method> <method name="set_skeleton_to_node"> - <return type="void"> - </return> - <argument index="0" name="skeleton_to_node" type="Dictionary"> - </argument> + <return type="void" /> + <argument index="0" name="skeleton_to_node" type="Dictionary" /> <description> </description> </method> <method name="set_skeletons"> - <return type="void"> - </return> - <argument index="0" name="skeletons" type="Array"> - </argument> + <return type="void" /> + <argument index="0" name="skeletons" type="Array" /> <description> </description> </method> <method name="set_skins"> - <return type="void"> - </return> - <argument index="0" name="skins" type="Array"> - </argument> + <return type="void" /> + <argument index="0" name="skins" type="Array" /> <description> </description> </method> <method name="set_textures"> - <return type="void"> - </return> - <argument index="0" name="textures" type="Array"> - </argument> + <return type="void" /> + <argument index="0" name="textures" type="Array" /> <description> </description> </method> <method name="set_unique_animation_names"> - <return type="void"> - </return> - <argument index="0" name="unique_animation_names" type="Array"> - </argument> + <return type="void" /> + <argument index="0" name="unique_animation_names" type="Array" /> <description> </description> </method> <method name="set_unique_names"> - <return type="void"> - </return> - <argument index="0" name="unique_names" type="Array"> - </argument> + <return type="void" /> + <argument index="0" name="unique_names" type="Array" /> <description> </description> </method> diff --git a/modules/gltf/doc_classes/PackedSceneGLTF.xml b/modules/gltf/doc_classes/PackedSceneGLTF.xml index a22111e9b7..d0136c6402 100644 --- a/modules/gltf/doc_classes/PackedSceneGLTF.xml +++ b/modules/gltf/doc_classes/PackedSceneGLTF.xml @@ -8,44 +8,29 @@ </tutorials> <methods> <method name="export_gltf"> - <return type="int" enum="Error"> - </return> - <argument index="0" name="node" type="Node"> - </argument> - <argument index="1" name="path" type="String"> - </argument> - <argument index="2" name="flags" type="int" default="0"> - </argument> - <argument index="3" name="bake_fps" type="float" default="1000.0"> - </argument> + <return type="int" enum="Error" /> + <argument index="0" name="node" type="Node" /> + <argument index="1" name="path" type="String" /> + <argument index="2" name="flags" type="int" default="0" /> + <argument index="3" name="bake_fps" type="float" default="1000.0" /> <description> </description> </method> <method name="import_gltf_scene"> - <return type="Node"> - </return> - <argument index="0" name="path" type="String"> - </argument> - <argument index="1" name="flags" type="int" default="0"> - </argument> - <argument index="2" name="bake_fps" type="float" default="1000.0"> - </argument> - <argument index="3" name="state" type="GLTFState" default="null"> - </argument> + <return type="Node" /> + <argument index="0" name="path" type="String" /> + <argument index="1" name="flags" type="int" default="0" /> + <argument index="2" name="bake_fps" type="float" default="1000.0" /> + <argument index="3" name="state" type="GLTFState" default="null" /> <description> </description> </method> <method name="pack_gltf"> - <return type="void"> - </return> - <argument index="0" name="path" type="String"> - </argument> - <argument index="1" name="flags" type="int" default="0"> - </argument> - <argument index="2" name="bake_fps" type="float" default="1000.0"> - </argument> - <argument index="3" name="state" type="GLTFState" default="null"> - </argument> + <return type="void" /> + <argument index="0" name="path" type="String" /> + <argument index="1" name="flags" type="int" default="0" /> + <argument index="2" name="bake_fps" type="float" default="1000.0" /> + <argument index="3" name="state" type="GLTFState" default="null" /> <description> </description> </method> diff --git a/modules/gltf/editor_scene_importer_gltf.cpp b/modules/gltf/editor_scene_importer_gltf.cpp index cef5278f03..eca1c85bf3 100644 --- a/modules/gltf/editor_scene_importer_gltf.cpp +++ b/modules/gltf/editor_scene_importer_gltf.cpp @@ -28,22 +28,14 @@ /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ /*************************************************************************/ -#include "core/crypto/crypto_core.h" -#include "core/io/file_access.h" -#include "core/math/disjoint_set.h" -#include "core/math/math_defs.h" -#include "core/os/os.h" -#include "editor/import/resource_importer_scene.h" -#include "modules/gltf/gltf_state.h" -#include "modules/regex/regex.h" -#include "scene/3d/bone_attachment_3d.h" -#include "scene/3d/camera_3d.h" -#include "scene/3d/mesh_instance_3d.h" -#include "scene/animation/animation_player.h" -#include "scene/resources/packed_scene.h" -#include "scene/resources/surface_tool.h" +#include "editor_scene_importer_gltf.h" + +#include "gltf_document.h" +#include "gltf_state.h" -#include "modules/gltf/editor_scene_importer_gltf.h" +#include "scene/3d/node_3d.h" +#include "scene/animation/animation_player.h" +#include "scene/resources/animation.h" uint32_t EditorSceneImporterGLTF::get_import_flags() const { return ImportFlags::IMPORT_SCENE | ImportFlags::IMPORT_ANIMATION; diff --git a/modules/gltf/editor_scene_importer_gltf.h b/modules/gltf/editor_scene_importer_gltf.h index 566d5cfd34..7bc5f594ed 100644 --- a/modules/gltf/editor_scene_importer_gltf.h +++ b/modules/gltf/editor_scene_importer_gltf.h @@ -31,28 +31,13 @@ #ifndef EDITOR_SCENE_IMPORTER_GLTF_H #define EDITOR_SCENE_IMPORTER_GLTF_H -#include "core/config/project_settings.h" -#include "core/object/object.h" -#include "core/templates/vector.h" +#include "gltf_state.h" + #include "editor/import/resource_importer_scene.h" -#include "modules/csg/csg_shape.h" -#include "modules/gridmap/grid_map.h" -#include "scene/3d/mesh_instance_3d.h" -#include "scene/3d/multimesh_instance_3d.h" -#include "scene/3d/node_3d.h" -#include "scene/3d/skeleton_3d.h" -#include "scene/animation/animation_player.h" -#include "scene/gui/check_box.h" #include "scene/main/node.h" #include "scene/resources/packed_scene.h" -#include "scene/resources/surface_tool.h" - -#include "gltf_document.h" -#include "gltf_state.h" -class AnimationPlayer; -class BoneAttachment; -class EditorSceneImporterMeshNode3D; +class Animation; #ifdef TOOLS_ENABLED class EditorSceneImporterGLTF : public EditorSceneImporter { diff --git a/modules/gltf/gltf_document.cpp b/modules/gltf/gltf_document.cpp index 660c2ab305..be44f66423 100644 --- a/modules/gltf/gltf_document.cpp +++ b/modules/gltf/gltf_document.cpp @@ -29,9 +29,7 @@ /*************************************************************************/ #include "gltf_document.h" -#include "core/error/error_list.h" -#include "core/error/error_macros.h" -#include "core/variant/variant.h" + #include "gltf_accessor.h" #include "gltf_animation.h" #include "gltf_camera.h" @@ -44,35 +42,33 @@ #include "gltf_state.h" #include "gltf_texture.h" -#include <stdio.h> -#include <stdlib.h> - -#include "core/core_bind.h" #include "core/crypto/crypto_core.h" +#include "core/io/dir_access.h" #include "core/io/file_access.h" #include "core/io/json.h" #include "core/math/disjoint_set.h" #include "core/variant/typed_array.h" +#include "core/variant/variant.h" #include "core/version.h" #include "core/version_hash.gen.h" #include "drivers/png/png_driver_common.h" #include "editor/import/resource_importer_scene.h" +#include "scene/2d/node_2d.h" +#include "scene/3d/camera_3d.h" +#include "scene/3d/multimesh_instance_3d.h" +#include "scene/animation/animation_player.h" +#include "scene/resources/surface_tool.h" + +#include "modules/modules_enabled.gen.h" #ifdef MODULE_CSG_ENABLED #include "modules/csg/csg_shape.h" #endif // MODULE_CSG_ENABLED #ifdef MODULE_GRIDMAP_ENABLED #include "modules/gridmap/grid_map.h" #endif // MODULE_GRIDMAP_ENABLED -#include "scene/2d/node_2d.h" -#include "scene/3d/bone_attachment_3d.h" -#include "scene/3d/camera_3d.h" -#include "scene/3d/mesh_instance_3d.h" -#include "scene/3d/multimesh_instance_3d.h" -#include "scene/3d/node_3d.h" -#include "scene/3d/skeleton_3d.h" -#include "scene/animation/animation_player.h" -#include "scene/main/node.h" -#include "scene/resources/surface_tool.h" + +#include <stdio.h> +#include <stdlib.h> #include <limits> Error GLTFDocument::serialize(Ref<GLTFState> state, Node *p_root, const String &p_path) { @@ -2800,7 +2796,7 @@ Error GLTFDocument::_parse_meshes(Ref<GLTFState> state) { mat = mat3d; } - import_mesh->add_surface(primitive, array, morphs, Dictionary(), mat); + import_mesh->add_surface(primitive, array, morphs, Dictionary(), mat, mat.is_valid() ? mat->get_name() : String()); } Vector<float> blend_weights; @@ -2873,16 +2869,13 @@ Error GLTFDocument::_serialize_images(Ref<GLTFState> state, const String &p_path name = itos(i); } name = _gen_unique_name(state, name); - name = name.pad_zeros(3); - Ref<_Directory> dir; - dir.instantiate(); + name = name.pad_zeros(3) + ".png"; String texture_dir = "textures"; String new_texture_dir = p_path.get_base_dir() + "/" + texture_dir; - dir->open(p_path.get_base_dir()); - if (!dir->dir_exists(new_texture_dir)) { - dir->make_dir(new_texture_dir); + DirAccessRef da = DirAccess::open(p_path.get_base_dir()); + if (!da->dir_exists(new_texture_dir)) { + da->make_dir(new_texture_dir); } - name = name + ".png"; image->save_png(new_texture_dir.plus_file(name)); d["uri"] = texture_dir.plus_file(name); } @@ -3009,24 +3002,31 @@ Error GLTFDocument::_parse_images(Ref<GLTFState> state, const String &p_base_pat Ref<Image> img; + // First we honor the mime types if they were defined. if (mimetype == "image/png") { // Load buffer as PNG. ERR_FAIL_COND_V(Image::_png_mem_loader_func == nullptr, ERR_UNAVAILABLE); img = Image::_png_mem_loader_func(data_ptr, data_size); } else if (mimetype == "image/jpeg") { // Loader buffer as JPEG. ERR_FAIL_COND_V(Image::_jpg_mem_loader_func == nullptr, ERR_UNAVAILABLE); img = Image::_jpg_mem_loader_func(data_ptr, data_size); - } else { - // We can land here if we got an URI with base64-encoded data with application/* MIME type, - // and the optional mimeType property was not defined to tell us how to handle this data (or was invalid). - // So let's try PNG first, then JPEG. + } + + // If we didn't pass the above tests, we attempt loading as PNG and then + // JPEG directly. + // This covers URIs with base64-encoded data with application/* type but + // no optional mimeType property, or bufferViews with a bogus mimeType + // (e.g. `image/jpeg` but the data is actually PNG). + // That's not *exactly* what the spec mandates but this lets us be + // lenient with bogus glb files which do exist in production. + if (img.is_null()) { // Try PNG first. ERR_FAIL_COND_V(Image::_png_mem_loader_func == nullptr, ERR_UNAVAILABLE); img = Image::_png_mem_loader_func(data_ptr, data_size); - if (img.is_null()) { - ERR_FAIL_COND_V(Image::_jpg_mem_loader_func == nullptr, ERR_UNAVAILABLE); - img = Image::_jpg_mem_loader_func(data_ptr, data_size); - } } - + if (img.is_null()) { // And then JPEG. + ERR_FAIL_COND_V(Image::_jpg_mem_loader_func == nullptr, ERR_UNAVAILABLE); + img = Image::_jpg_mem_loader_func(data_ptr, data_size); + } + // Now we've done our best, fix your scenes. if (img.is_null()) { ERR_PRINT(vformat("glTF: Couldn't load image index '%d' with its given mimetype: %s.", i, mimetype)); state->images.push_back(Ref<Texture2D>()); @@ -5538,7 +5538,10 @@ struct EditorSceneImporterGLTFInterpolate<Quaternion> { template <class T> T GLTFDocument::_interpolate_track(const Vector<float> &p_times, const Vector<T> &p_values, const float p_time, const GLTFAnimation::Interpolation p_interp) { ERR_FAIL_COND_V(!p_values.size(), T()); - ERR_FAIL_COND_V(p_times.size() != p_values.size(), p_values[0]); + if (p_times.size() != p_values.size()) { + ERR_PRINT_ONCE("The interpolated values are not corresponding to its times."); + return p_values[0]; + } //could use binary search, worth it? int idx = -1; for (int i = 0; i < p_times.size(); i++) { diff --git a/modules/gltf/gltf_document.h b/modules/gltf/gltf_document.h index 514373c4f0..3e8ea19045 100644 --- a/modules/gltf/gltf_document.h +++ b/modules/gltf/gltf_document.h @@ -31,11 +31,9 @@ #ifndef GLTF_DOCUMENT_H #define GLTF_DOCUMENT_H -#include "editor/import/resource_importer_scene.h" -#include "editor/import/scene_importer_mesh_node_3d.h" #include "gltf_animation.h" -#include "modules/modules_enabled.gen.h" -#include "scene/2d/node_2d.h" + +#include "editor/import/scene_importer_mesh_node_3d.h" #include "scene/3d/bone_attachment_3d.h" #include "scene/3d/light_3d.h" #include "scene/3d/mesh_instance_3d.h" @@ -45,6 +43,8 @@ #include "scene/resources/material.h" #include "scene/resources/texture.h" +#include "modules/modules_enabled.gen.h" + class GLTFState; class GLTFSkin; class GLTFNode; diff --git a/modules/gltf/gltf_state.h b/modules/gltf/gltf_state.h index ba6bf8a533..d8209523c5 100644 --- a/modules/gltf/gltf_state.h +++ b/modules/gltf/gltf_state.h @@ -31,9 +31,6 @@ #ifndef GLTF_STATE_H #define GLTF_STATE_H -#include "core/io/resource.h" -#include "core/templates/vector.h" -#include "editor_scene_importer_gltf.h" #include "gltf_accessor.h" #include "gltf_animation.h" #include "gltf_buffer_view.h" @@ -45,6 +42,9 @@ #include "gltf_skeleton.h" #include "gltf_skin.h" #include "gltf_texture.h" + +#include "core/io/resource.h" +#include "core/templates/vector.h" #include "scene/animation/animation_player.h" #include "scene/resources/texture.h" diff --git a/modules/gridmap/doc_classes/GridMap.xml b/modules/gridmap/doc_classes/GridMap.xml index a2c8e8eabf..8ea7384658 100644 --- a/modules/gridmap/doc_classes/GridMap.xml +++ b/modules/gridmap/doc_classes/GridMap.xml @@ -17,119 +17,93 @@ </tutorials> <methods> <method name="clear"> - <return type="void"> - </return> + <return type="void" /> <description> Clear all cells. </description> </method> <method name="clear_baked_meshes"> - <return type="void"> - </return> + <return type="void" /> <description> </description> </method> <method name="get_bake_mesh_instance"> - <return type="RID"> - </return> - <argument index="0" name="idx" type="int"> - </argument> + <return type="RID" /> + <argument index="0" name="idx" type="int" /> <description> </description> </method> <method name="get_bake_meshes"> - <return type="Array"> - </return> + <return type="Array" /> <description> Returns an array of [ArrayMesh]es and [Transform3D] references of all bake meshes that exist within the current GridMap. </description> </method> <method name="get_cell_item" qualifiers="const"> - <return type="int"> - </return> - <argument index="0" name="position" type="Vector3i"> - </argument> + <return type="int" /> + <argument index="0" name="position" type="Vector3i" /> <description> The [MeshLibrary] item index located at the given grid coordinates. If the cell is empty, [constant INVALID_CELL_ITEM] will be returned. </description> </method> <method name="get_cell_item_orientation" qualifiers="const"> - <return type="int"> - </return> - <argument index="0" name="position" type="Vector3i"> - </argument> + <return type="int" /> + <argument index="0" name="position" type="Vector3i" /> <description> The orientation of the cell at the given grid coordinates. [code]-1[/code] is returned if the cell is empty. </description> </method> <method name="get_collision_layer_bit" qualifiers="const"> - <return type="bool"> - </return> - <argument index="0" name="bit" type="int"> - </argument> + <return type="bool" /> + <argument index="0" name="bit" type="int" /> <description> Returns an individual bit on the [member collision_layer]. </description> </method> <method name="get_collision_mask_bit" qualifiers="const"> - <return type="bool"> - </return> - <argument index="0" name="bit" type="int"> - </argument> + <return type="bool" /> + <argument index="0" name="bit" type="int" /> <description> Returns an individual bit on the [member collision_mask]. </description> </method> <method name="get_meshes"> - <return type="Array"> - </return> + <return type="Array" /> <description> Returns an array of [Transform3D] and [Mesh] references corresponding to the non-empty cells in the grid. The transforms are specified in world space. </description> </method> <method name="get_used_cells" qualifiers="const"> - <return type="Array"> - </return> + <return type="Array" /> <description> Returns an array of [Vector3] with the non-empty cell coordinates in the grid map. </description> </method> <method name="make_baked_meshes"> - <return type="void"> - </return> - <argument index="0" name="gen_lightmap_uv" type="bool" default="false"> - </argument> - <argument index="1" name="lightmap_uv_texel_size" type="float" default="0.1"> - </argument> + <return type="void" /> + <argument index="0" name="gen_lightmap_uv" type="bool" default="false" /> + <argument index="1" name="lightmap_uv_texel_size" type="float" default="0.1" /> <description> </description> </method> <method name="map_to_world" qualifiers="const"> - <return type="Vector3"> - </return> - <argument index="0" name="map_position" type="Vector3i"> - </argument> + <return type="Vector3" /> + <argument index="0" name="map_position" type="Vector3i" /> <description> Returns the position of a grid cell in the GridMap's local coordinate space. </description> </method> <method name="resource_changed"> - <return type="void"> - </return> - <argument index="0" name="resource" type="Resource"> - </argument> + <return type="void" /> + <argument index="0" name="resource" type="Resource" /> <description> </description> </method> <method name="set_cell_item"> - <return type="void"> - </return> - <argument index="0" name="position" type="Vector3i"> - </argument> - <argument index="1" name="item" type="int"> - </argument> - <argument index="2" name="orientation" type="int" default="0"> - </argument> + <return type="void" /> + <argument index="0" name="position" type="Vector3i" /> + <argument index="1" name="item" type="int" /> + <argument index="2" name="orientation" type="int" default="0" /> <description> Sets the mesh index for the cell referenced by its grid coordinates. A negative item index such as [constant INVALID_CELL_ITEM] will clear the cell. @@ -137,46 +111,33 @@ </description> </method> <method name="set_clip"> - <return type="void"> - </return> - <argument index="0" name="enabled" type="bool"> - </argument> - <argument index="1" name="clipabove" type="bool" default="true"> - </argument> - <argument index="2" name="floor" type="int" default="0"> - </argument> - <argument index="3" name="axis" type="int" enum="Vector3.Axis" default="0"> - </argument> + <return type="void" /> + <argument index="0" name="enabled" type="bool" /> + <argument index="1" name="clipabove" type="bool" default="true" /> + <argument index="2" name="floor" type="int" default="0" /> + <argument index="3" name="axis" type="int" enum="Vector3.Axis" default="0" /> <description> </description> </method> <method name="set_collision_layer_bit"> - <return type="void"> - </return> - <argument index="0" name="bit" type="int"> - </argument> - <argument index="1" name="value" type="bool"> - </argument> + <return type="void" /> + <argument index="0" name="bit" type="int" /> + <argument index="1" name="value" type="bool" /> <description> Sets an individual bit on the [member collision_layer]. </description> </method> <method name="set_collision_mask_bit"> - <return type="void"> - </return> - <argument index="0" name="bit" type="int"> - </argument> - <argument index="1" name="value" type="bool"> - </argument> + <return type="void" /> + <argument index="0" name="bit" type="int" /> + <argument index="1" name="value" type="bool" /> <description> Sets an individual bit on the [member collision_mask]. </description> </method> <method name="world_to_map" qualifiers="const"> - <return type="Vector3i"> - </return> - <argument index="0" name="world_position" type="Vector3"> - </argument> + <return type="Vector3i" /> + <argument index="0" name="world_position" type="Vector3" /> <description> Returns the coordinates of the grid cell containing the given point. [code]pos[/code] should be in the GridMap's local coordinate space. @@ -223,8 +184,7 @@ </members> <signals> <signal name="cell_size_changed"> - <argument index="0" name="cell_size" type="Vector3"> - </argument> + <argument index="0" name="cell_size" type="Vector3" /> <description> Emitted when [member cell_size] changes. </description> diff --git a/modules/gridmap/grid_map.cpp b/modules/gridmap/grid_map.cpp index e9134b32d9..fea513c820 100644 --- a/modules/gridmap/grid_map.cpp +++ b/modules/gridmap/grid_map.cpp @@ -221,7 +221,7 @@ void GridMap::set_cell_size(const Vector3 &p_size) { ERR_FAIL_COND(p_size.x < 0.001 || p_size.y < 0.001 || p_size.z < 0.001); cell_size = p_size; _recreate_octant_data(); - emit_signal("cell_size_changed", cell_size); + emit_signal(SNAME("cell_size_changed"), cell_size); } Vector3 GridMap::get_cell_size() const { @@ -519,14 +519,14 @@ bool GridMap::_octant_update(const OctantKey &p_key) { RS::get_singleton()->multimesh_set_mesh(mm, mesh_library->get_item_mesh(E->key())->get_rid()); int idx = 0; - for (List<Pair<Transform3D, IndexKey>>::Element *F = E->get().front(); F; F = F->next()) { - RS::get_singleton()->multimesh_instance_set_transform(mm, idx, F->get().first); + for (const Pair<Transform3D, IndexKey> &F : E->get()) { + RS::get_singleton()->multimesh_instance_set_transform(mm, idx, F.first); #ifdef TOOLS_ENABLED Octant::MultimeshInstance::Item it; it.index = idx; - it.transform = F->get().first; - it.key = F->get().second; + it.transform = F.first; + it.key = F.second; mmi.items.push_back(it); #endif diff --git a/modules/gridmap/grid_map_editor_plugin.cpp b/modules/gridmap/grid_map_editor_plugin.cpp index d894425ce8..f101c43e89 100644 --- a/modules/gridmap/grid_map_editor_plugin.cpp +++ b/modules/gridmap/grid_map_editor_plugin.cpp @@ -497,8 +497,8 @@ void GridMapEditor::_fill_selection() { } void GridMapEditor::_clear_clipboard_data() { - for (List<ClipboardItem>::Element *E = clipboard_items.front(); E; E = E->next()) { - RenderingServer::get_singleton()->free(E->get().instance); + for (const ClipboardItem &E : clipboard_items) { + RenderingServer::get_singleton()->free(E.instance); } clipboard_items.clear(); @@ -552,9 +552,7 @@ void GridMapEditor::_update_paste_indicator() { RenderingServer::get_singleton()->instance_set_transform(paste_instance, node->get_global_transform() * xf); - for (List<ClipboardItem>::Element *E = clipboard_items.front(); E; E = E->next()) { - ClipboardItem &item = E->get(); - + for (const ClipboardItem &item : clipboard_items) { xf = Transform3D(); xf.origin = (paste_indicator.begin + (paste_indicator.current - paste_indicator.click) + center) * node->get_cell_size(); xf.basis = rot * xf.basis; @@ -578,9 +576,7 @@ void GridMapEditor::_do_paste() { Vector3 ofs = paste_indicator.current - paste_indicator.click; undo_redo->create_action(TTR("GridMap Paste Selection")); - for (List<ClipboardItem>::Element *E = clipboard_items.front(); E; E = E->next()) { - ClipboardItem &item = E->get(); - + for (const ClipboardItem &item : clipboard_items) { Vector3 position = rot.xform(item.grid_offset) + paste_indicator.begin + ofs; Basis orm; @@ -663,8 +659,7 @@ bool GridMapEditor::forward_spatial_input_event(Camera3D *p_camera, const Ref<In if ((mb->get_button_index() == MOUSE_BUTTON_RIGHT && input_action == INPUT_ERASE) || (mb->get_button_index() == MOUSE_BUTTON_LEFT && input_action == INPUT_PAINT)) { if (set_items.size()) { undo_redo->create_action(TTR("GridMap Paint")); - for (List<SetItem>::Element *E = set_items.front(); E; E = E->next()) { - const SetItem &si = E->get(); + for (const SetItem &si : set_items) { undo_redo->add_do_method(node, "set_cell_item", si.position, si.new_value, si.new_orientation); } for (List<SetItem>::Element *E = set_items.back(); E; E = E->prev()) { @@ -680,7 +675,7 @@ bool GridMapEditor::forward_spatial_input_event(Camera3D *p_camera, const Ref<In } if (mb->get_button_index() == MOUSE_BUTTON_LEFT && input_action == INPUT_SELECT) { - undo_redo->create_action("GridMap Selection"); + undo_redo->create_action(TTR("GridMap Selection")); undo_redo->add_do_method(this, "_set_selection", selection.active, selection.begin, selection.end); undo_redo->add_undo_method(this, "_set_selection", last_selection.active, last_selection.begin, last_selection.end); undo_redo->commit_action(); @@ -869,8 +864,8 @@ void GridMapEditor::update_palette() { int item = 0; - for (List<_CGMEItemSort>::Element *E = il.front(); E; E = E->next()) { - int id = E->get().id; + for (_CGMEItemSort &E : il) { + int id = E.id; String name = mesh_library->get_item_name(id); Ref<Texture2D> preview = mesh_library->get_item_preview(id); @@ -1077,8 +1072,8 @@ void GridMapEditor::_notification(int p_what) { } break; case NOTIFICATION_THEME_CHANGED: { - options->set_icon(get_theme_icon("GridMap", "EditorIcons")); - search_box->set_right_icon(get_theme_icon("Search", "EditorIcons")); + options->set_icon(get_theme_icon(SNAME("GridMap"), SNAME("EditorIcons"))); + search_box->set_right_icon(get_theme_icon(SNAME("Search"), SNAME("EditorIcons"))); } break; case NOTIFICATION_APPLICATION_FOCUS_OUT: { @@ -1239,7 +1234,7 @@ GridMapEditor::GridMapEditor(EditorNode *p_editor) { mode_thumbnail->set_flat(true); mode_thumbnail->set_toggle_mode(true); mode_thumbnail->set_pressed(true); - mode_thumbnail->set_icon(p_editor->get_gui_base()->get_theme_icon("FileThumbnail", "EditorIcons")); + mode_thumbnail->set_icon(p_editor->get_gui_base()->get_theme_icon(SNAME("FileThumbnail"), SNAME("EditorIcons"))); hb->add_child(mode_thumbnail); mode_thumbnail->connect("pressed", callable_mp(this, &GridMapEditor::_set_display_mode), varray(DISPLAY_THUMBNAIL)); @@ -1247,7 +1242,7 @@ GridMapEditor::GridMapEditor(EditorNode *p_editor) { mode_list->set_flat(true); mode_list->set_toggle_mode(true); mode_list->set_pressed(false); - mode_list->set_icon(p_editor->get_gui_base()->get_theme_icon("FileList", "EditorIcons")); + mode_list->set_icon(p_editor->get_gui_base()->get_theme_icon(SNAME("FileList"), SNAME("EditorIcons"))); hb->add_child(mode_list); mode_list->connect("pressed", callable_mp(this, &GridMapEditor::_set_display_mode), varray(DISPLAY_LIST)); diff --git a/modules/lightmapper_rd/lightmapper_rd.cpp b/modules/lightmapper_rd/lightmapper_rd.cpp index b75cf6502e..fe941e25e7 100644 --- a/modules/lightmapper_rd/lightmapper_rd.cpp +++ b/modules/lightmapper_rd/lightmapper_rd.cpp @@ -794,7 +794,7 @@ LightmapperRD::BakeError LightmapperRD::bake(BakeQuality p_quality, bool p_use_d } ERR_FAIL_COND_V(err != OK, BAKE_ERROR_LIGHTMAP_CANT_PRE_BAKE_MESHES); - RID rasterize_shader = rd->shader_create_from_bytecode(raster_shader->get_bytecode()); + RID rasterize_shader = rd->shader_create_from_spirv(raster_shader->get_spirv_stages()); ERR_FAIL_COND_V(rasterize_shader.is_null(), BAKE_ERROR_LIGHTMAP_CANT_PRE_BAKE_MESHES); //this is a bug check, though, should not happen @@ -945,27 +945,27 @@ LightmapperRD::BakeError LightmapperRD::bake(BakeQuality p_quality, bool p_use_d ERR_FAIL_COND_V(err != OK, BAKE_ERROR_LIGHTMAP_CANT_PRE_BAKE_MESHES); // Unoccluder - RID compute_shader_unocclude = rd->shader_create_from_bytecode(compute_shader->get_bytecode("unocclude")); + RID compute_shader_unocclude = rd->shader_create_from_spirv(compute_shader->get_spirv_stages("unocclude")); ERR_FAIL_COND_V(compute_shader_unocclude.is_null(), BAKE_ERROR_LIGHTMAP_CANT_PRE_BAKE_MESHES); // internal check, should not happen RID compute_shader_unocclude_pipeline = rd->compute_pipeline_create(compute_shader_unocclude); // Direct light - RID compute_shader_primary = rd->shader_create_from_bytecode(compute_shader->get_bytecode("primary")); + RID compute_shader_primary = rd->shader_create_from_spirv(compute_shader->get_spirv_stages("primary")); ERR_FAIL_COND_V(compute_shader_primary.is_null(), BAKE_ERROR_LIGHTMAP_CANT_PRE_BAKE_MESHES); // internal check, should not happen RID compute_shader_primary_pipeline = rd->compute_pipeline_create(compute_shader_primary); // Indirect light - RID compute_shader_secondary = rd->shader_create_from_bytecode(compute_shader->get_bytecode("secondary")); + RID compute_shader_secondary = rd->shader_create_from_spirv(compute_shader->get_spirv_stages("secondary")); ERR_FAIL_COND_V(compute_shader_secondary.is_null(), BAKE_ERROR_LIGHTMAP_CANT_PRE_BAKE_MESHES); //internal check, should not happen RID compute_shader_secondary_pipeline = rd->compute_pipeline_create(compute_shader_secondary); // Dilate - RID compute_shader_dilate = rd->shader_create_from_bytecode(compute_shader->get_bytecode("dilate")); + RID compute_shader_dilate = rd->shader_create_from_spirv(compute_shader->get_spirv_stages("dilate")); ERR_FAIL_COND_V(compute_shader_dilate.is_null(), BAKE_ERROR_LIGHTMAP_CANT_PRE_BAKE_MESHES); //internal check, should not happen RID compute_shader_dilate_pipeline = rd->compute_pipeline_create(compute_shader_dilate); // Light probes - RID compute_shader_light_probes = rd->shader_create_from_bytecode(compute_shader->get_bytecode("light_probes")); + RID compute_shader_light_probes = rd->shader_create_from_spirv(compute_shader->get_spirv_stages("light_probes")); ERR_FAIL_COND_V(compute_shader_light_probes.is_null(), BAKE_ERROR_LIGHTMAP_CANT_PRE_BAKE_MESHES); //internal check, should not happen RID compute_shader_light_probes_pipeline = rd->compute_pipeline_create(compute_shader_light_probes); @@ -1506,11 +1506,11 @@ LightmapperRD::BakeError LightmapperRD::bake(BakeQuality p_quality, bool p_use_d } ERR_FAIL_COND_V(err != OK, BAKE_ERROR_LIGHTMAP_CANT_PRE_BAKE_MESHES); - RID blendseams_line_raster_shader = rd->shader_create_from_bytecode(blendseams_shader->get_bytecode("lines")); + RID blendseams_line_raster_shader = rd->shader_create_from_spirv(blendseams_shader->get_spirv_stages("lines")); ERR_FAIL_COND_V(blendseams_line_raster_shader.is_null(), BAKE_ERROR_LIGHTMAP_CANT_PRE_BAKE_MESHES); - RID blendseams_triangle_raster_shader = rd->shader_create_from_bytecode(blendseams_shader->get_bytecode("triangles")); + RID blendseams_triangle_raster_shader = rd->shader_create_from_spirv(blendseams_shader->get_spirv_stages("triangles")); ERR_FAIL_COND_V(blendseams_triangle_raster_shader.is_null(), BAKE_ERROR_LIGHTMAP_CANT_PRE_BAKE_MESHES); diff --git a/modules/mbedtls/tests/test_crypto_mbedtls.cpp b/modules/mbedtls/tests/test_crypto_mbedtls.cpp index 4217497082..8762838883 100644 --- a/modules/mbedtls/tests/test_crypto_mbedtls.cpp +++ b/modules/mbedtls/tests/test_crypto_mbedtls.cpp @@ -28,7 +28,7 @@ /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ /*************************************************************************/ -#include "modules/mbedtls/tests/test_crypto_mbedtls.h" +#include "test_crypto_mbedtls.h" #include "modules/mbedtls/crypto_mbedtls.h" #include "tests/test_macros.h" diff --git a/modules/mono/.editorconfig b/modules/mono/.editorconfig new file mode 100644 index 0000000000..c9dcd7724e --- /dev/null +++ b/modules/mono/.editorconfig @@ -0,0 +1,14 @@ +[*.sln] +indent_style = tab + +[*.{csproj,props,targets,nuspec,resx}] +indent_style = space +indent_size = 2 + +[*.cs] +indent_style = space +indent_size = 4 +insert_final_newline = true +trim_trailing_whitespace = true +max_line_length = 120 +csharp_indent_case_contents_when_block = false diff --git a/modules/mono/class_db_api_json.cpp b/modules/mono/class_db_api_json.cpp index 25193a1352..0da06131af 100644 --- a/modules/mono/class_db_api_json.cpp +++ b/modules/mono/class_db_api_json.cpp @@ -50,8 +50,8 @@ void class_db_api_to_json(const String &p_output_file, ClassDB::APIType p_api) { //must be alphabetically sorted for hash to compute names.sort_custom<StringName::AlphCompare>(); - for (List<StringName>::Element *E = names.front(); E; E = E->next()) { - ClassDB::ClassInfo *t = ClassDB::classes.getptr(E->get()); + for (const StringName &E : names) { + ClassDB::ClassInfo *t = ClassDB::classes.getptr(E); ERR_FAIL_COND(!t); if (t->api != p_api || !t->exposed) { continue; @@ -84,11 +84,11 @@ void class_db_api_to_json(const String &p_output_file, ClassDB::APIType p_api) { Array methods; - for (List<StringName>::Element *F = snames.front(); F; F = F->next()) { + for (const StringName &F : snames) { Dictionary method_dict; methods.push_back(method_dict); - MethodBind *mb = t->method_map[F->get()]; + MethodBind *mb = t->method_map[F]; method_dict["name"] = mb->get_name(); method_dict["argument_count"] = mb->get_argument_count(); method_dict["return_type"] = mb->get_argument_type(-1); @@ -141,12 +141,12 @@ void class_db_api_to_json(const String &p_output_file, ClassDB::APIType p_api) { Array constants; - for (List<StringName>::Element *F = snames.front(); F; F = F->next()) { + for (const StringName &F : snames) { Dictionary constant_dict; constants.push_back(constant_dict); - constant_dict["name"] = F->get(); - constant_dict["value"] = t->constant_map[F->get()]; + constant_dict["name"] = F; + constant_dict["value"] = t->constant_map[F]; } if (!constants.is_empty()) { @@ -168,12 +168,12 @@ void class_db_api_to_json(const String &p_output_file, ClassDB::APIType p_api) { Array signals; - for (List<StringName>::Element *F = snames.front(); F; F = F->next()) { + for (const StringName &F : snames) { Dictionary signal_dict; signals.push_back(signal_dict); - MethodInfo &mi = t->signal_map[F->get()]; - signal_dict["name"] = F->get(); + MethodInfo &mi = t->signal_map[F]; + signal_dict["name"] = F; Array arguments; signal_dict["arguments"] = arguments; @@ -203,13 +203,13 @@ void class_db_api_to_json(const String &p_output_file, ClassDB::APIType p_api) { Array properties; - for (List<StringName>::Element *F = snames.front(); F; F = F->next()) { + for (const StringName &F : snames) { Dictionary property_dict; properties.push_back(property_dict); - ClassDB::PropertySetGet *psg = t->property_setget.getptr(F->get()); + ClassDB::PropertySetGet *psg = t->property_setget.getptr(F); - property_dict["name"] = F->get(); + property_dict["name"] = F; property_dict["setter"] = psg->setter; property_dict["getter"] = psg->getter; } @@ -222,15 +222,15 @@ void class_db_api_to_json(const String &p_output_file, ClassDB::APIType p_api) { Array property_list; //property list - for (List<PropertyInfo>::Element *F = t->property_list.front(); F; F = F->next()) { + for (const PropertyInfo &F : t->property_list) { Dictionary property_dict; property_list.push_back(property_dict); - property_dict["name"] = F->get().name; - property_dict["type"] = F->get().type; - property_dict["hint"] = F->get().hint; - property_dict["hint_string"] = F->get().hint_string; - property_dict["usage"] = F->get().usage; + property_dict["name"] = F.name; + property_dict["type"] = F.type; + property_dict["hint"] = F.hint; + property_dict["hint_string"] = F.hint_string; + property_dict["usage"] = F.usage; } if (!property_list.is_empty()) { diff --git a/modules/mono/csharp_script.cpp b/modules/mono/csharp_script.cpp index ff6a47f59b..15a5807370 100644 --- a/modules/mono/csharp_script.cpp +++ b/modules/mono/csharp_script.cpp @@ -145,8 +145,8 @@ void CSharpLanguage::finalize() { finalizing = true; // Make sure all script binding gchandles are released before finalizing GDMono - for (Map<Object *, CSharpScriptBinding>::Element *E = script_bindings.front(); E; E = E->next()) { - CSharpScriptBinding &script_binding = E->value(); + for (KeyValue<Object *, CSharpScriptBinding> &E : script_bindings) { + CSharpScriptBinding &script_binding = E.value; if (!script_binding.gchandle.is_released()) { script_binding.gchandle.release(); @@ -163,8 +163,8 @@ void CSharpLanguage::finalize() { script_bindings.clear(); #ifdef DEBUG_ENABLED - for (Map<ObjectID, int>::Element *E = unsafe_object_references.front(); E; E = E->next()) { - const ObjectID &id = E->key(); + for (const KeyValue<ObjectID, int> &E : unsafe_object_references) { + const ObjectID &id = E.key; Object *obj = ObjectDB::get_instance(id); if (obj) { @@ -864,8 +864,8 @@ void CSharpLanguage::reload_assemblies(bool p_soft_reload) { // We need to keep reference instances alive during reloading List<Ref<RefCounted>> rc_instances; - for (Map<Object *, CSharpScriptBinding>::Element *E = script_bindings.front(); E; E = E->next()) { - CSharpScriptBinding &script_binding = E->value(); + for (const KeyValue<Object *, CSharpScriptBinding> &E : script_bindings) { + const CSharpScriptBinding &script_binding = E.value; RefCounted *rc = Object::cast_to<RefCounted>(script_binding.owner); if (rc) { rc_instances.push_back(Ref<RefCounted>(rc)); @@ -874,9 +874,7 @@ void CSharpLanguage::reload_assemblies(bool p_soft_reload) { // As scripts are going to be reloaded, must proceed without locking here - for (List<Ref<CSharpScript>>::Element *E = scripts.front(); E; E = E->next()) { - Ref<CSharpScript> &script = E->get(); - + for (Ref<CSharpScript> &script : scripts) { to_reload.push_back(script); if (script->get_path().is_empty()) { @@ -887,8 +885,7 @@ void CSharpLanguage::reload_assemblies(bool p_soft_reload) { // Script::instances are deleted during managed object disposal, which happens on domain finalize. // Only placeholders are kept. Therefore we need to keep a copy before that happens. - for (Set<Object *>::Element *F = script->instances.front(); F; F = F->next()) { - Object *obj = F->get(); + for (Object *&obj : script->instances) { script->pending_reload_instances.insert(obj->get_instance_id()); RefCounted *rc = Object::cast_to<RefCounted>(obj); @@ -898,8 +895,8 @@ void CSharpLanguage::reload_assemblies(bool p_soft_reload) { } #ifdef TOOLS_ENABLED - for (Set<PlaceHolderScriptInstance *>::Element *F = script->placeholders.front(); F; F = F->next()) { - Object *obj = F->get()->get_owner(); + for (PlaceHolderScriptInstance *&script_instance : script->placeholders) { + Object *obj = script_instance->get_owner(); script->pending_reload_instances.insert(obj->get_instance_id()); RefCounted *rc = Object::cast_to<RefCounted>(obj); @@ -912,9 +909,7 @@ void CSharpLanguage::reload_assemblies(bool p_soft_reload) { // Save state and remove script from instances Map<ObjectID, CSharpScript::StateBackup> &owners_map = script->pending_reload_state; - for (Set<Object *>::Element *F = script->instances.front(); F; F = F->next()) { - Object *obj = F->get(); - + for (Object *&obj : script->instances) { ERR_CONTINUE(!obj->get_script_instance()); CSharpInstance *csi = static_cast<CSharpInstance *>(obj->get_script_instance()); @@ -936,9 +931,7 @@ void CSharpLanguage::reload_assemblies(bool p_soft_reload) { } // After the state of all instances is saved, clear scripts and script instances - for (List<Ref<CSharpScript>>::Element *E = scripts.front(); E; E = E->next()) { - Ref<CSharpScript> &script = E->get(); - + for (Ref<CSharpScript> &script : scripts) { while (script->instances.front()) { Object *obj = script->instances.front()->get(); obj->set_script(REF()); // Remove script and existing script instances (placeholder are not removed before domain reload) @@ -951,11 +944,9 @@ void CSharpLanguage::reload_assemblies(bool p_soft_reload) { if (gdmono->reload_scripts_domain() != OK) { // Failed to reload the scripts domain // Make sure to add the scripts back to their owners before returning - for (List<Ref<CSharpScript>>::Element *E = to_reload.front(); E; E = E->next()) { - Ref<CSharpScript> scr = E->get(); - - for (const Map<ObjectID, CSharpScript::StateBackup>::Element *F = scr->pending_reload_state.front(); F; F = F->next()) { - Object *obj = ObjectDB::get_instance(F->key()); + for (Ref<CSharpScript> &scr : to_reload) { + for (const KeyValue<ObjectID, CSharpScript::StateBackup> &F : scr->pending_reload_state) { + Object *obj = ObjectDB::get_instance(F.key); if (!obj) { continue; @@ -975,8 +966,8 @@ void CSharpLanguage::reload_assemblies(bool p_soft_reload) { #endif // Restore Variant properties state, it will be kept by the placeholder until the next script reloading - for (List<Pair<StringName, Variant>>::Element *G = scr->pending_reload_state[obj_id].properties.front(); G; G = G->next()) { - placeholder->property_set_fallback(G->get().first, G->get().second, nullptr); + for (const Pair<StringName, Variant> &G : scr->pending_reload_state[obj_id].properties) { + placeholder->property_set_fallback(G.first, G.second, nullptr); } scr->pending_reload_state.erase(obj_id); @@ -988,9 +979,7 @@ void CSharpLanguage::reload_assemblies(bool p_soft_reload) { List<Ref<CSharpScript>> to_reload_state; - for (List<Ref<CSharpScript>>::Element *E = to_reload.front(); E; E = E->next()) { - Ref<CSharpScript> script = E->get(); - + for (Ref<CSharpScript> &script : to_reload) { #ifdef TOOLS_ENABLED script->exports_invalidated = true; #endif @@ -1043,8 +1032,7 @@ void CSharpLanguage::reload_assemblies(bool p_soft_reload) { StringName native_name = NATIVE_GDMONOCLASS_NAME(script->native); { - for (Set<ObjectID>::Element *F = script->pending_reload_instances.front(); F; F = F->next()) { - ObjectID obj_id = F->get(); + for (const ObjectID &obj_id : script->pending_reload_instances) { Object *obj = ObjectDB::get_instance(obj_id); if (!obj) { @@ -1095,11 +1083,8 @@ void CSharpLanguage::reload_assemblies(bool p_soft_reload) { to_reload_state.push_back(script); } - for (List<Ref<CSharpScript>>::Element *E = to_reload_state.front(); E; E = E->next()) { - Ref<CSharpScript> script = E->get(); - - for (Set<ObjectID>::Element *F = script->pending_reload_instances.front(); F; F = F->next()) { - ObjectID obj_id = F->get(); + for (Ref<CSharpScript> &script : to_reload_state) { + for (const ObjectID &obj_id : script->pending_reload_instances) { Object *obj = ObjectDB::get_instance(obj_id); if (!obj) { @@ -1113,16 +1098,16 @@ void CSharpLanguage::reload_assemblies(bool p_soft_reload) { CSharpScript::StateBackup &state_backup = script->pending_reload_state[obj_id]; - for (List<Pair<StringName, Variant>>::Element *G = state_backup.properties.front(); G; G = G->next()) { - obj->get_script_instance()->set(G->get().first, G->get().second); + for (const Pair<StringName, Variant> &G : state_backup.properties) { + obj->get_script_instance()->set(G.first, G.second); } CSharpInstance *csi = CAST_CSHARP_INSTANCE(obj->get_script_instance()); if (csi) { - for (List<Pair<StringName, Array>>::Element *G = state_backup.event_signals.front(); G; G = G->next()) { - const StringName &name = G->get().first; - const Array &serialized_data = G->get().second; + for (const Pair<StringName, Array> &G : state_backup.event_signals) { + const StringName &name = G.first; + const Array &serialized_data = G.second; Map<StringName, CSharpScript::EventSignal>::Element *match = script->event_signals.find(name); @@ -1166,9 +1151,9 @@ void CSharpLanguage::reload_assemblies(bool p_soft_reload) { { MutexLock lock(ManagedCallable::instances_mutex); - for (Map<ManagedCallable *, Array>::Element *elem = ManagedCallable::instances_pending_reload.front(); elem; elem = elem->next()) { - ManagedCallable *managed_callable = elem->key(); - const Array &serialized_data = elem->value(); + for (const KeyValue<ManagedCallable *, Array> &elem : ManagedCallable::instances_pending_reload) { + ManagedCallable *managed_callable = elem.key; + const Array &serialized_data = elem.value; MonoObject *managed_serialized_data = GDMonoMarshal::variant_to_mono_object(serialized_data); MonoDelegate *delegate = nullptr; @@ -1312,8 +1297,8 @@ bool CSharpLanguage::debug_break(const String &p_error, bool p_allow_continue) { } void CSharpLanguage::_on_scripts_domain_unloaded() { - for (Map<Object *, CSharpScriptBinding>::Element *E = script_bindings.front(); E; E = E->next()) { - CSharpScriptBinding &script_binding = E->value(); + for (KeyValue<Object *, CSharpScriptBinding> &E : script_bindings) { + CSharpScriptBinding &script_binding = E.value; script_binding.gchandle.release(); script_binding.inited = false; } @@ -1738,12 +1723,12 @@ bool CSharpInstance::get(const StringName &p_name, Variant &r_ret) const { } void CSharpInstance::get_properties_state_for_reloading(List<Pair<StringName, Variant>> &r_state) { - List<PropertyInfo> pinfo; - get_property_list(&pinfo); + List<PropertyInfo> property_list; + get_property_list(&property_list); - for (List<PropertyInfo>::Element *E = pinfo.front(); E; E = E->next()) { + for (const PropertyInfo &prop_info : property_list) { Pair<StringName, Variant> state_pair; - state_pair.first = E->get().name; + state_pair.first = prop_info.name; ManagedType managedType; @@ -1766,8 +1751,8 @@ void CSharpInstance::get_event_signals_state_for_reloading(List<Pair<StringName, MonoObject *owner_managed = get_mono_object(); ERR_FAIL_NULL(owner_managed); - for (const Map<StringName, CSharpScript::EventSignal>::Element *E = script->event_signals.front(); E; E = E->next()) { - const CSharpScript::EventSignal &event_signal = E->value(); + for (const KeyValue<StringName, CSharpScript::EventSignal> &E : script->event_signals) { + const CSharpScript::EventSignal &event_signal = E.value; MonoDelegate *delegate_field_value = (MonoDelegate *)event_signal.field->get_value(owner_managed); if (!delegate_field_value) { @@ -1794,8 +1779,8 @@ void CSharpInstance::get_event_signals_state_for_reloading(List<Pair<StringName, } void CSharpInstance::get_property_list(List<PropertyInfo> *p_properties) const { - for (Map<StringName, PropertyInfo>::Element *E = script->member_info.front(); E; E = E->next()) { - p_properties->push_back(E->value()); + for (const KeyValue<StringName, PropertyInfo> &E : script->member_info) { + p_properties->push_back(E.value); } // Call _get_property_list @@ -2034,8 +2019,8 @@ void CSharpInstance::mono_object_disposed_baseref(MonoObject *p_obj, bool p_is_f } void CSharpInstance::connect_event_signals() { - for (const Map<StringName, CSharpScript::EventSignal>::Element *E = script->event_signals.front(); E; E = E->next()) { - const CSharpScript::EventSignal &event_signal = E->value(); + for (const KeyValue<StringName, CSharpScript::EventSignal> &E : script->event_signals) { + const CSharpScript::EventSignal &event_signal = E.value; StringName signal_name = event_signal.field->get_name(); @@ -2049,8 +2034,7 @@ void CSharpInstance::connect_event_signals() { } void CSharpInstance::disconnect_event_signals() { - for (const List<Callable>::Element *E = connected_event_signals.front(); E; E = E->next()) { - const Callable &callable = E->get(); + for (const Callable &callable : connected_event_signals) { const EventSignalCallable *event_signal_callable = static_cast<const EventSignalCallable *>(callable.get_custom()); owner->disconnect(event_signal_callable->get_signal(), callable); } @@ -2320,12 +2304,12 @@ void CSharpScript::_update_exports_values(Map<StringName, Variant> &values, List base_cache->_update_exports_values(values, propnames); } - for (Map<StringName, Variant>::Element *E = exported_members_defval_cache.front(); E; E = E->next()) { - values[E->key()] = E->get(); + for (const KeyValue<StringName, Variant> &E : exported_members_defval_cache) { + values[E.key] = E.value; } - for (List<PropertyInfo>::Element *E = exported_members_cache.front(); E; E = E->next()) { - propnames.push_back(E->get()); + for (const PropertyInfo &prop_info : exported_members_cache) { + propnames.push_back(prop_info); } } @@ -2556,8 +2540,8 @@ bool CSharpScript::_update_exports(PlaceHolderScriptInstance *p_instance_to_upda _update_exports_values(values, propnames); if (changed) { - for (Set<PlaceHolderScriptInstance *>::Element *E = placeholders.front(); E; E = E->next()) { - E->get()->update(propnames, values); + for (PlaceHolderScriptInstance *&script_instance : placeholders) { + script_instance->update(propnames, values); } } else { p_instance_to_update->update(propnames, values); @@ -3389,11 +3373,11 @@ bool CSharpScript::has_script_signal(const StringName &p_signal) const { } void CSharpScript::get_script_signal_list(List<MethodInfo> *r_signals) const { - for (const Map<StringName, Vector<SignalParameter>>::Element *E = _signals.front(); E; E = E->next()) { + for (const KeyValue<StringName, Vector<SignalParameter>> &E : _signals) { MethodInfo mi; - mi.name = E->key(); + mi.name = E.key; - const Vector<SignalParameter> ¶ms = E->value(); + const Vector<SignalParameter> ¶ms = E.value; for (int i = 0; i < params.size(); i++) { const SignalParameter ¶m = params[i]; @@ -3408,11 +3392,11 @@ void CSharpScript::get_script_signal_list(List<MethodInfo> *r_signals) const { r_signals->push_back(mi); } - for (const Map<StringName, EventSignal>::Element *E = event_signals.front(); E; E = E->next()) { + for (const KeyValue<StringName, EventSignal> &E : event_signals) { MethodInfo mi; - mi.name = E->key(); + mi.name = E.key; - const EventSignal &event_signal = E->value(); + const EventSignal &event_signal = E.value; const Vector<SignalParameter> ¶ms = event_signal.parameters; for (int i = 0; i < params.size(); i++) { const SignalParameter ¶m = params[i]; @@ -3452,8 +3436,8 @@ Ref<Script> CSharpScript::get_base_script() const { } void CSharpScript::get_script_property_list(List<PropertyInfo> *p_list) const { - for (Map<StringName, PropertyInfo>::Element *E = member_info.front(); E; E = E->next()) { - p_list->push_back(E->value()); + for (const KeyValue<StringName, PropertyInfo> &E : member_info) { + p_list->push_back(E.value); } } @@ -3472,15 +3456,6 @@ MultiplayerAPI::RPCMode CSharpScript::_member_get_rpc_mode(IMonoClassMember *p_m if (p_member->has_attribute(CACHED_CLASS(PuppetAttribute))) { return MultiplayerAPI::RPC_MODE_PUPPET; } - if (p_member->has_attribute(CACHED_CLASS(RemoteSyncAttribute))) { - return MultiplayerAPI::RPC_MODE_REMOTESYNC; - } - if (p_member->has_attribute(CACHED_CLASS(MasterSyncAttribute))) { - return MultiplayerAPI::RPC_MODE_MASTERSYNC; - } - if (p_member->has_attribute(CACHED_CLASS(PuppetSyncAttribute))) { - return MultiplayerAPI::RPC_MODE_PUPPETSYNC; - } return MultiplayerAPI::RPC_MODE_DISABLED; } @@ -3545,8 +3520,8 @@ CSharpScript::~CSharpScript() { void CSharpScript::get_members(Set<StringName> *p_members) { #if defined(TOOLS_ENABLED) || defined(DEBUG_ENABLED) if (p_members) { - for (Set<StringName>::Element *E = exported_members_names.front(); E; E = E->next()) { - p_members->insert(E->get()); + for (const StringName &member_name : exported_members_names) { + p_members->insert(member_name); } } #endif diff --git a/modules/mono/editor/Godot.NET.Sdk/Godot.SourceGenerators/Godot.SourceGenerators.csproj b/modules/mono/editor/Godot.NET.Sdk/Godot.SourceGenerators/Godot.SourceGenerators.csproj index 224d7e5b5a..11d8e0f72b 100644 --- a/modules/mono/editor/Godot.NET.Sdk/Godot.SourceGenerators/Godot.SourceGenerators.csproj +++ b/modules/mono/editor/Godot.NET.Sdk/Godot.SourceGenerators/Godot.SourceGenerators.csproj @@ -15,8 +15,9 @@ <PackageProjectUrl>$(RepositoryUrl)</PackageProjectUrl> <PackageLicenseExpression>MIT</PackageLicenseExpression> - <GeneratePackageOnBuild>true</GeneratePackageOnBuild> <!-- Generates a package at build --> - <IncludeBuildOutput>false</IncludeBuildOutput> <!-- Do not include the generator as a lib dependency --> + <GeneratePackageOnBuild>true</GeneratePackageOnBuild> + <!-- Do not include the generator as a lib dependency --> + <IncludeBuildOutput>false</IncludeBuildOutput> </PropertyGroup> <ItemGroup> <PackageReference Include="Microsoft.CodeAnalysis.CSharp" Version="3.8.0" PrivateAssets="all" /> diff --git a/modules/mono/editor/GodotTools/.gitignore b/modules/mono/editor/GodotTools/.gitignore index 48e2f914d8..a41d1c89b5 100644 --- a/modules/mono/editor/GodotTools/.gitignore +++ b/modules/mono/editor/GodotTools/.gitignore @@ -353,4 +353,3 @@ healthchecksdb # Backup folder for Package Reference Convert tool in Visual Studio 2017 MigrationBackup/ - diff --git a/modules/mono/editor/GodotTools/GodotTools.IdeMessaging.CLI/Program.cs b/modules/mono/editor/GodotTools/GodotTools.IdeMessaging.CLI/Program.cs index 4db71500da..450c4bf0cb 100644 --- a/modules/mono/editor/GodotTools/GodotTools.IdeMessaging.CLI/Program.cs +++ b/modules/mono/editor/GodotTools/GodotTools.IdeMessaging.CLI/Program.cs @@ -113,8 +113,7 @@ namespace GodotTools.IdeMessaging.CLI } } - ExitMainLoop: - + ExitMainLoop: await forwarder.WriteLineToOutput("Event=Quit"); } diff --git a/modules/mono/editor/GodotTools/GodotTools.ProjectEditor/DotNetSolution.cs b/modules/mono/editor/GodotTools/GodotTools.ProjectEditor/DotNetSolution.cs index cc0da44a13..284e94810a 100644 --- a/modules/mono/editor/GodotTools/GodotTools.ProjectEditor/DotNetSolution.cs +++ b/modules/mono/editor/GodotTools/GodotTools.ProjectEditor/DotNetSolution.cs @@ -150,8 +150,8 @@ EndProject"; {"Tools|Any CPU", "ExportRelease|Any CPU"} }; - var regex = new Regex(string.Join("|",dict.Keys.Select(Regex.Escape))); - var result = regex.Replace(input,m => dict[m.Value]); + var regex = new Regex(string.Join("|", dict.Keys.Select(Regex.Escape))); + var result = regex.Replace(input, m => dict[m.Value]); if (result != input) { diff --git a/modules/mono/editor/GodotTools/GodotTools/Export/AotBuilder.cs b/modules/mono/editor/GodotTools/GodotTools/Export/AotBuilder.cs index 5bb8d444c2..f69307104f 100644 --- a/modules/mono/editor/GodotTools/GodotTools/Export/AotBuilder.cs +++ b/modules/mono/editor/GodotTools/GodotTools/Export/AotBuilder.cs @@ -577,27 +577,27 @@ MONO_AOT_MODE_LAST = 1000, { case OS.Platforms.Windows: case OS.Platforms.UWP: - { - string arch = bits == "64" ? "x86_64" : "i686"; - return $"windows-{arch}"; - } + { + string arch = bits == "64" ? "x86_64" : "i686"; + return $"windows-{arch}"; + } case OS.Platforms.MacOS: - { - Debug.Assert(bits == null || bits == "64"); - string arch = "x86_64"; - return $"{platform}-{arch}"; - } + { + Debug.Assert(bits == null || bits == "64"); + string arch = "x86_64"; + return $"{platform}-{arch}"; + } case OS.Platforms.LinuxBSD: case OS.Platforms.Server: - { - string arch = bits == "64" ? "x86_64" : "i686"; - return $"linux-{arch}"; - } + { + string arch = bits == "64" ? "x86_64" : "i686"; + return $"linux-{arch}"; + } case OS.Platforms.Haiku: - { - string arch = bits == "64" ? "x86_64" : "i686"; - return $"{platform}-{arch}"; - } + { + string arch = bits == "64" ? "x86_64" : "i686"; + return $"{platform}-{arch}"; + } default: throw new NotSupportedException($"Platform not supported: {platform}"); } diff --git a/modules/mono/editor/GodotTools/GodotTools/Export/ExportPlugin.cs b/modules/mono/editor/GodotTools/GodotTools/Export/ExportPlugin.cs index 270be8b6bf..0b5aa72a81 100644 --- a/modules/mono/editor/GodotTools/GodotTools/Export/ExportPlugin.cs +++ b/modules/mono/editor/GodotTools/GodotTools/Export/ExportPlugin.cs @@ -76,9 +76,9 @@ namespace GodotTools.Export GlobalDef("mono/export/aot/use_interpreter", true); // --aot or --aot=opt1,opt2 (use 'mono --aot=help AuxAssembly.dll' to list AOT options) - GlobalDef("mono/export/aot/extra_aot_options", new string[] { }); + GlobalDef("mono/export/aot/extra_aot_options", Array.Empty<string>()); // --optimize/-O=opt1,opt2 (use 'mono --list-opt'' to list optimize options) - GlobalDef("mono/export/aot/extra_optimizer_options", new string[] { }); + GlobalDef("mono/export/aot/extra_optimizer_options", Array.Empty<string>()); GlobalDef("mono/export/aot/android_toolchain_path", ""); } @@ -188,7 +188,7 @@ namespace GodotTools.Export // However, at least in the case of 'WebAssembly.Net.Http' for some reason the BCL assemblies // reference a different version even though the assembly is the same, for some weird reason. - var wasmFrameworkAssemblies = new[] {"WebAssembly.Bindings", "WebAssembly.Net.WebSockets"}; + var wasmFrameworkAssemblies = new[] { "WebAssembly.Bindings", "WebAssembly.Net.WebSockets" }; foreach (string thisWasmFrameworkAssemblyName in wasmFrameworkAssemblies) { @@ -298,8 +298,8 @@ namespace GodotTools.Export LLVMOutputPath = "", FullAot = platform == OS.Platforms.iOS || (bool)(ProjectSettings.GetSetting("mono/export/aot/full_aot") ?? false), UseInterpreter = (bool)ProjectSettings.GetSetting("mono/export/aot/use_interpreter"), - ExtraAotOptions = (string[])ProjectSettings.GetSetting("mono/export/aot/extra_aot_options") ?? new string[] { }, - ExtraOptimizerOptions = (string[])ProjectSettings.GetSetting("mono/export/aot/extra_optimizer_options") ?? new string[] { }, + ExtraAotOptions = (string[])ProjectSettings.GetSetting("mono/export/aot/extra_aot_options") ?? Array.Empty<string>(), + ExtraOptimizerOptions = (string[])ProjectSettings.GetSetting("mono/export/aot/extra_optimizer_options") ?? Array.Empty<string>(), ToolchainPath = aotToolchainPath }; @@ -381,7 +381,7 @@ namespace GodotTools.Export private static bool PlatformHasTemplateDir(string platform) { // OSX export templates are contained in a zip, so we place our custom template inside it and let Godot do the rest. - return !new[] {OS.Platforms.MacOS, OS.Platforms.Android, OS.Platforms.iOS, OS.Platforms.HTML5}.Contains(platform); + return !new[] { OS.Platforms.MacOS, OS.Platforms.Android, OS.Platforms.iOS, OS.Platforms.HTML5 }.Contains(platform); } private static bool DeterminePlatformFromFeatures(IEnumerable<string> features, out string platform) @@ -430,7 +430,7 @@ namespace GodotTools.Export /// </summary> private static bool PlatformRequiresCustomBcl(string platform) { - if (new[] {OS.Platforms.Android, OS.Platforms.iOS, OS.Platforms.HTML5}.Contains(platform)) + if (new[] { OS.Platforms.Android, OS.Platforms.iOS, OS.Platforms.HTML5 }.Contains(platform)) return true; // The 'net_4_x' BCL is not compatible between Windows and the other platforms. diff --git a/modules/mono/editor/GodotTools/GodotTools/GodotSharpEditor.cs b/modules/mono/editor/GodotTools/GodotTools/GodotSharpEditor.cs index c71c44d79d..1faa6eeac0 100644 --- a/modules/mono/editor/GodotTools/GodotTools/GodotSharpEditor.cs +++ b/modules/mono/editor/GodotTools/GodotTools/GodotSharpEditor.cs @@ -26,8 +26,6 @@ namespace GodotTools private PopupMenu menuPopup; private AcceptDialog errorDialog; - private AcceptDialog aboutDialog; - private CheckBox aboutDialogCheckBox; private Button bottomPanelBtn; private Button toolBarBuildButton; @@ -130,13 +128,6 @@ namespace GodotTools toolBarBuildButton.Show(); } - private void _ShowAboutDialog() - { - bool showOnStart = (bool)editorSettings.GetSetting("mono/editor/show_info_on_start"); - aboutDialogCheckBox.Pressed = showOnStart; - aboutDialog.PopupCentered(); - } - private void _MenuOptionPressed(int id) { switch ((MenuOptions)id) @@ -144,9 +135,6 @@ namespace GodotTools case MenuOptions.CreateSln: CreateProjectSolution(); break; - case MenuOptions.AboutCSharp: - _ShowAboutDialog(); - break; case MenuOptions.SetupGodotNugetFallbackFolder: { try @@ -183,21 +171,11 @@ namespace GodotTools base._Ready(); MSBuildPanel.BuildOutputView.BuildStateChanged += BuildStateChanged; - - bool showInfoDialog = (bool)editorSettings.GetSetting("mono/editor/show_info_on_start"); - if (showInfoDialog) - { - aboutDialog.Exclusive = true; - _ShowAboutDialog(); - // Once shown a first time, it can be seen again via the Mono menu - it doesn't have to be exclusive from that time on. - aboutDialog.Exclusive = false; - } } private enum MenuOptions { CreateSln, - AboutCSharp, SetupGodotNugetFallbackFolder, } @@ -439,57 +417,6 @@ namespace GodotTools AddToolSubmenuItem("C#", menuPopup); - // TODO: Remove or edit this info dialog once Mono support is no longer in alpha - { - menuPopup.AddItem("About C# support".TTR(), (int)MenuOptions.AboutCSharp); - menuPopup.AddItem("Setup Godot NuGet Offline Packages".TTR(), (int)MenuOptions.SetupGodotNugetFallbackFolder); - aboutDialog = new AcceptDialog(); - editorBaseControl.AddChild(aboutDialog); - aboutDialog.Title = "Important: C# support is not feature-complete"; - - // We don't use DialogText as the default AcceptDialog Label doesn't play well with the TextureRect and CheckBox - // we'll add. Instead we add containers and a new autowrapped Label inside. - - // Main VBoxContainer (icon + label on top, checkbox at bottom) - var aboutVBox = new VBoxContainer(); - aboutDialog.AddChild(aboutVBox); - - // HBoxContainer for icon + label - var aboutHBox = new HBoxContainer(); - aboutVBox.AddChild(aboutHBox); - - var aboutIcon = new TextureRect(); - aboutIcon.Texture = aboutIcon.GetThemeIcon("NodeWarning", "EditorIcons"); - aboutHBox.AddChild(aboutIcon); - - var aboutLabel = new Label(); - aboutHBox.AddChild(aboutLabel); - aboutLabel.RectMinSize = new Vector2(600, 150) * EditorScale; - aboutLabel.SizeFlagsVertical = (int)Control.SizeFlags.ExpandFill; - aboutLabel.Autowrap = true; - aboutLabel.Text = - "C# support in Godot Engine is in late alpha stage and, while already usable, " + - "it is not meant for use in production.\n\n" + - "Projects can be exported to Linux, macOS, Windows, Android, iOS and HTML5, but not yet to UWP. " + - "Bugs and usability issues will be addressed gradually over future releases, " + - "potentially including compatibility breaking changes as new features are implemented for a better overall C# experience.\n\n" + - "If you experience issues with this Mono build, please report them on Godot's issue tracker with details about your system, MSBuild version, IDE, etc.:\n\n" + - " https://github.com/godotengine/godot/issues\n\n" + - "Your critical feedback at this stage will play a great role in shaping the C# support in future releases, so thank you!"; - - EditorDef("mono/editor/show_info_on_start", true); - - // CheckBox in main container - aboutDialogCheckBox = new CheckBox {Text = "Show this warning when starting the editor"}; - aboutDialogCheckBox.Toggled += enabled => - { - bool showOnStart = (bool)editorSettings.GetSetting("mono/editor/show_info_on_start"); - if (showOnStart != enabled) - editorSettings.SetSetting("mono/editor/show_info_on_start", enabled); - }; - aboutVBox.AddChild(aboutDialogCheckBox); - } - toolBarBuildButton = new Button { Text = "Build", diff --git a/modules/mono/editor/GodotTools/GodotTools/GodotTools.csproj b/modules/mono/editor/GodotTools/GodotTools/GodotTools.csproj index 3f14629b11..b9aa760f4d 100644 --- a/modules/mono/editor/GodotTools/GodotTools/GodotTools.csproj +++ b/modules/mono/editor/GodotTools/GodotTools/GodotTools.csproj @@ -3,7 +3,8 @@ <ProjectGuid>{27B00618-A6F2-4828-B922-05CAEB08C286}</ProjectGuid> <TargetFramework>net472</TargetFramework> <LangVersion>7.2</LangVersion> - <GodotApiConfiguration>Debug</GodotApiConfiguration> <!-- The Godot editor uses the Debug Godot API assemblies --> + <!-- The Godot editor uses the Debug Godot API assemblies --> + <GodotApiConfiguration>Debug</GodotApiConfiguration> <GodotSourceRootPath>$(SolutionDir)/../../../../</GodotSourceRootPath> <GodotOutputDataDir>$(GodotSourceRootPath)/bin/GodotSharp</GodotOutputDataDir> <GodotApiAssembliesDir>$(GodotOutputDataDir)/Api/$(GodotApiConfiguration)</GodotApiAssembliesDir> diff --git a/modules/mono/editor/GodotTools/GodotTools/Ides/Rider/RiderPathLocator.cs b/modules/mono/editor/GodotTools/GodotTools/Ides/Rider/RiderPathLocator.cs index 94fc5da425..821532f759 100644 --- a/modules/mono/editor/GodotTools/GodotTools/Ides/Rider/RiderPathLocator.cs +++ b/modules/mono/editor/GodotTools/GodotTools/Ides/Rider/RiderPathLocator.cs @@ -47,7 +47,7 @@ namespace GodotTools.Ides.Rider GD.PushWarning(e.Message); } - return new RiderInfo[0]; + return Array.Empty<RiderInfo>(); } private static RiderInfo[] CollectAllRiderPathsLinux() @@ -249,7 +249,7 @@ namespace GodotTools.Ides.Rider bool isMac) { if (!Directory.Exists(toolboxRiderRootPath)) - return new string[0]; + return Array.Empty<string>(); var channelDirs = Directory.GetDirectories(toolboxRiderRootPath); var paths = channelDirs.SelectMany(channelDir => @@ -295,7 +295,7 @@ namespace GodotTools.Ides.Rider Logger.Warn($"Failed to get RiderPath from {channelDir}", e); } - return new string[0]; + return Array.Empty<string>(); }) .Where(c => !string.IsNullOrEmpty(c)) .ToArray(); @@ -306,7 +306,7 @@ namespace GodotTools.Ides.Rider { var folder = new DirectoryInfo(Path.Combine(buildDir, dirName)); if (!folder.Exists) - return new string[0]; + return Array.Empty<string>(); if (!isMac) return new[] { Path.Combine(folder.FullName, searchPattern) }.Where(File.Exists).ToArray(); diff --git a/modules/mono/editor/GodotTools/GodotTools/Ides/Rider/RiderPathManager.cs b/modules/mono/editor/GodotTools/GodotTools/Ides/Rider/RiderPathManager.cs index ed25cdaa63..60dd565ef2 100644 --- a/modules/mono/editor/GodotTools/GodotTools/Ides/Rider/RiderPathManager.cs +++ b/modules/mono/editor/GodotTools/GodotTools/Ides/Rider/RiderPathManager.cs @@ -57,7 +57,7 @@ namespace GodotTools.Ides.Rider public static bool IsExternalEditorSetToRider(EditorSettings editorSettings) { - return editorSettings.HasSetting(EditorPathSettingName) && IsRider((string) editorSettings.GetSetting(EditorPathSettingName)); + return editorSettings.HasSetting(EditorPathSettingName) && IsRider((string)editorSettings.GetSetting(EditorPathSettingName)); } public static bool IsRider(string path) diff --git a/modules/mono/editor/GodotTools/GodotTools/Utils/OS.cs b/modules/mono/editor/GodotTools/GodotTools/Utils/OS.cs index e745966435..4624439665 100644 --- a/modules/mono/editor/GodotTools/GodotTools/Utils/OS.cs +++ b/modules/mono/editor/GodotTools/GodotTools/Utils/OS.cs @@ -74,10 +74,10 @@ namespace GodotTools.Utils } private static readonly IEnumerable<string> LinuxBSDPlatforms = - new[] {Names.Linux, Names.FreeBSD, Names.NetBSD, Names.BSD}; + new[] { Names.Linux, Names.FreeBSD, Names.NetBSD, Names.BSD }; private static readonly IEnumerable<string> UnixLikePlatforms = - new[] {Names.MacOS, Names.Server, Names.Haiku, Names.Android, Names.iOS} + new[] { Names.MacOS, Names.Server, Names.Haiku, Names.Android, Names.iOS } .Concat(LinuxBSDPlatforms).ToArray(); private static readonly Lazy<bool> _isWindows = new Lazy<bool>(() => IsOS(Names.Windows)); @@ -111,13 +111,22 @@ namespace GodotTools.Utils private static string PathWhichWindows([NotNull] string name) { - string[] windowsExts = Environment.GetEnvironmentVariable("PATHEXT")?.Split(PathSep) ?? new string[] { }; + string[] windowsExts = Environment.GetEnvironmentVariable("PATHEXT")?.Split(PathSep) ?? Array.Empty<string>(); string[] pathDirs = Environment.GetEnvironmentVariable("PATH")?.Split(PathSep); + char[] invalidPathChars = Path.GetInvalidPathChars(); var searchDirs = new List<string>(); if (pathDirs != null) - searchDirs.AddRange(pathDirs); + { + foreach (var pathDir in pathDirs) + { + if (pathDir.IndexOfAny(invalidPathChars) != -1) + continue; + + searchDirs.Add(pathDir); + } + } string nameExt = Path.GetExtension(name); bool hasPathExt = !string.IsNullOrEmpty(nameExt) && windowsExts.Contains(nameExt, StringComparer.OrdinalIgnoreCase); @@ -128,20 +137,29 @@ namespace GodotTools.Utils return searchDirs.Select(dir => Path.Combine(dir, name)).FirstOrDefault(File.Exists); return (from dir in searchDirs - select Path.Combine(dir, name) + select Path.Combine(dir, name) into path - from ext in windowsExts - select path + ext).FirstOrDefault(File.Exists); + from ext in windowsExts + select path + ext).FirstOrDefault(File.Exists); } private static string PathWhichUnix([NotNull] string name) { string[] pathDirs = Environment.GetEnvironmentVariable("PATH")?.Split(PathSep); + char[] invalidPathChars = Path.GetInvalidPathChars(); var searchDirs = new List<string>(); if (pathDirs != null) - searchDirs.AddRange(pathDirs); + { + foreach (var pathDir in pathDirs) + { + if (pathDir.IndexOfAny(invalidPathChars) != -1) + continue; + + searchDirs.Add(pathDir); + } + } searchDirs.Add(System.IO.Directory.GetCurrentDirectory()); // last in the list @@ -196,7 +214,7 @@ namespace GodotTools.Utils startInfo.UseShellExecute = false; - using (var process = new Process {StartInfo = startInfo}) + using (var process = new Process { StartInfo = startInfo }) { process.Start(); process.WaitForExit(); diff --git a/modules/mono/editor/bindings_generator.cpp b/modules/mono/editor/bindings_generator.cpp index 620b031ddb..632f7d61cc 100644 --- a/modules/mono/editor/bindings_generator.cpp +++ b/modules/mono/editor/bindings_generator.cpp @@ -416,8 +416,8 @@ String BindingsGenerator::bbcode_to_xml(const String &p_bbcode, const TypeInterf // Try to find as global enum constant const EnumInterface *target_ienum = nullptr; - for (const List<EnumInterface>::Element *E = global_enums.front(); E; E = E->next()) { - target_ienum = &E->get(); + for (const EnumInterface &ienum : global_enums) { + target_ienum = &ienum; target_iconst = find_constant_by_name(target_name, target_ienum->constants); if (target_iconst) { break; @@ -455,8 +455,8 @@ String BindingsGenerator::bbcode_to_xml(const String &p_bbcode, const TypeInterf // Try to find as enum constant in the current class const EnumInterface *target_ienum = nullptr; - for (const List<EnumInterface>::Element *E = target_itype->enums.front(); E; E = E->next()) { - target_ienum = &E->get(); + for (const EnumInterface &ienum : target_itype->enums) { + target_ienum = &ienum; target_iconst = find_constant_by_name(target_name, target_ienum->constants); if (target_iconst) { break; @@ -655,9 +655,7 @@ int BindingsGenerator::_determine_enum_prefix(const EnumInterface &p_ienum) { return 0; } - for (const List<ConstantInterface>::Element *E = p_ienum.constants.front()->next(); E; E = E->next()) { - const ConstantInterface &iconstant = E->get(); - + for (const ConstantInterface &iconstant : p_ienum.constants) { Vector<String> parts = iconstant.name.split("_", /* p_allow_empty: */ true); int i; @@ -682,12 +680,10 @@ int BindingsGenerator::_determine_enum_prefix(const EnumInterface &p_ienum) { void BindingsGenerator::_apply_prefix_to_enum_constants(BindingsGenerator::EnumInterface &p_ienum, int p_prefix_length) { if (p_prefix_length > 0) { - for (List<ConstantInterface>::Element *E = p_ienum.constants.front(); E; E = E->next()) { + for (ConstantInterface &iconstant : p_ienum.constants) { int curr_prefix_length = p_prefix_length; - ConstantInterface &curr_const = E->get(); - - String constant_name = curr_const.name; + String constant_name = iconstant.name; Vector<String> parts = constant_name.split("_", /* p_allow_empty: */ true); @@ -713,15 +709,13 @@ void BindingsGenerator::_apply_prefix_to_enum_constants(BindingsGenerator::EnumI constant_name += parts[i]; } - curr_const.proxy_name = snake_to_pascal_case(constant_name, true); + iconstant.proxy_name = snake_to_pascal_case(constant_name, true); } } } void BindingsGenerator::_generate_method_icalls(const TypeInterface &p_itype) { - for (const List<MethodInterface>::Element *E = p_itype.methods.front(); E; E = E->next()) { - const MethodInterface &imethod = E->get(); - + for (const MethodInterface &imethod : p_itype.methods) { if (imethod.is_virtual) { continue; } @@ -735,8 +729,8 @@ void BindingsGenerator::_generate_method_icalls(const TypeInterface &p_itype) { // Get arguments information int i = 0; - for (const List<ArgumentInterface>::Element *F = imethod.arguments.front(); F; F = F->next()) { - const TypeInterface *arg_type = _get_type_or_placeholder(F->get().type); + for (const ArgumentInterface &iarg : imethod.arguments) { + const TypeInterface *arg_type = _get_type_or_placeholder(iarg.type); im_sig += ", "; im_sig += arg_type->im_type_in; @@ -776,10 +770,10 @@ void BindingsGenerator::_generate_method_icalls(const TypeInterface &p_itype) { if (p_itype.api_type != ClassDB::API_EDITOR) { match->get().editor_only = false; } - method_icalls_map.insert(&E->get(), &match->get()); + method_icalls_map.insert(&imethod, &match->get()); } else { List<InternalCall>::Element *added = method_icalls.push_back(im_icall); - method_icalls_map.insert(&E->get(), &added->get()); + method_icalls_map.insert(&imethod, &added->get()); } } } @@ -859,9 +853,7 @@ void BindingsGenerator::_generate_global_constants(StringBuilder &p_output) { p_output.append("namespace " BINDINGS_NAMESPACE "\n" OPEN_BLOCK); p_output.append(INDENT1 "public static partial class " BINDINGS_GLOBAL_SCOPE_CLASS "\n" INDENT1 "{"); - for (const List<ConstantInterface>::Element *E = global_constants.front(); E; E = E->next()) { - const ConstantInterface &iconstant = E->get(); - + for (const ConstantInterface &iconstant : global_constants) { if (iconstant.const_doc && iconstant.const_doc->description.size()) { String xml_summary = bbcode_to_xml(fix_doc_description(iconstant.const_doc->description), nullptr); Vector<String> summary_lines = xml_summary.length() ? xml_summary.split("\n") : Vector<String>(); @@ -894,9 +886,7 @@ void BindingsGenerator::_generate_global_constants(StringBuilder &p_output) { // Enums - for (List<EnumInterface>::Element *E = global_enums.front(); E; E = E->next()) { - const EnumInterface &ienum = E->get(); - + for (const EnumInterface &ienum : global_enums) { CRASH_COND(ienum.constants.is_empty()); String enum_proxy_name = ienum.cname.operator String(); @@ -921,9 +911,8 @@ void BindingsGenerator::_generate_global_constants(StringBuilder &p_output) { p_output.append(enum_proxy_name); p_output.append("\n" INDENT1 OPEN_BLOCK); - for (const List<ConstantInterface>::Element *F = ienum.constants.front(); F; F = F->next()) { - const ConstantInterface &iconstant = F->get(); - + const ConstantInterface &last = ienum.constants.back()->get(); + for (const ConstantInterface &iconstant : ienum.constants) { if (iconstant.const_doc && iconstant.const_doc->description.size()) { String xml_summary = bbcode_to_xml(fix_doc_description(iconstant.const_doc->description), nullptr); Vector<String> summary_lines = xml_summary.length() ? xml_summary.split("\n") : Vector<String>(); @@ -945,7 +934,7 @@ void BindingsGenerator::_generate_global_constants(StringBuilder &p_output) { p_output.append(iconstant.proxy_name); p_output.append(" = "); p_output.append(itos(iconstant.value)); - p_output.append(F != ienum.constants.back() ? ",\n" : "\n"); + p_output.append(&iconstant != &last ? ",\n" : "\n"); } p_output.append(INDENT1 CLOSE_BLOCK); @@ -1053,11 +1042,11 @@ Error BindingsGenerator::generate_cs_core_project(const String &p_proj_dir) { cs_icalls_content.append(m_icall.im_sig + ");\n"); \ } - for (const List<InternalCall>::Element *E = core_custom_icalls.front(); E; E = E->next()) { - ADD_INTERNAL_CALL(E->get()); + for (const InternalCall &internal_call : core_custom_icalls) { + ADD_INTERNAL_CALL(internal_call); } - for (const List<InternalCall>::Element *E = method_icalls.front(); E; E = E->next()) { - ADD_INTERNAL_CALL(E->get()); + for (const InternalCall &internal_call : method_icalls) { + ADD_INTERNAL_CALL(internal_call); } #undef ADD_INTERNAL_CALL @@ -1161,11 +1150,11 @@ Error BindingsGenerator::generate_cs_editor_project(const String &p_proj_dir) { cs_icalls_content.append(m_icall.im_sig + ");\n"); \ } - for (const List<InternalCall>::Element *E = editor_custom_icalls.front(); E; E = E->next()) { - ADD_INTERNAL_CALL(E->get()); + for (const InternalCall &internal_call : editor_custom_icalls) { + ADD_INTERNAL_CALL(internal_call); } - for (const List<InternalCall>::Element *E = method_icalls.front(); E; E = E->next()) { - ADD_INTERNAL_CALL(E->get()); + for (const InternalCall &internal_call : method_icalls) { + ADD_INTERNAL_CALL(internal_call); } #undef ADD_INTERNAL_CALL @@ -1327,9 +1316,7 @@ Error BindingsGenerator::_generate_cs_type(const TypeInterface &itype, const Str // Add constants - for (const List<ConstantInterface>::Element *E = itype.constants.front(); E; E = E->next()) { - const ConstantInterface &iconstant = E->get(); - + for (const ConstantInterface &iconstant : itype.constants) { if (iconstant.const_doc && iconstant.const_doc->description.size()) { String xml_summary = bbcode_to_xml(fix_doc_description(iconstant.const_doc->description), &itype); Vector<String> summary_lines = xml_summary.length() ? xml_summary.split("\n") : Vector<String>(); @@ -1360,18 +1347,15 @@ Error BindingsGenerator::_generate_cs_type(const TypeInterface &itype, const Str // Add enums - for (const List<EnumInterface>::Element *E = itype.enums.front(); E; E = E->next()) { - const EnumInterface &ienum = E->get(); - + for (const EnumInterface &ienum : itype.enums) { ERR_FAIL_COND_V(ienum.constants.is_empty(), ERR_BUG); output.append(MEMBER_BEGIN "public enum "); output.append(ienum.cname.operator String()); output.append(MEMBER_BEGIN OPEN_BLOCK); - for (const List<ConstantInterface>::Element *F = ienum.constants.front(); F; F = F->next()) { - const ConstantInterface &iconstant = F->get(); - + const ConstantInterface &last = ienum.constants.back()->get(); + for (const ConstantInterface &iconstant : ienum.constants) { if (iconstant.const_doc && iconstant.const_doc->description.size()) { String xml_summary = bbcode_to_xml(fix_doc_description(iconstant.const_doc->description), &itype); Vector<String> summary_lines = xml_summary.length() ? xml_summary.split("\n") : Vector<String>(); @@ -1393,7 +1377,7 @@ Error BindingsGenerator::_generate_cs_type(const TypeInterface &itype, const Str output.append(iconstant.proxy_name); output.append(" = "); output.append(itos(iconstant.value)); - output.append(F != ienum.constants.back() ? ",\n" : "\n"); + output.append(&iconstant != &last ? ",\n" : "\n"); } output.append(INDENT2 CLOSE_BLOCK); @@ -1401,8 +1385,7 @@ Error BindingsGenerator::_generate_cs_type(const TypeInterface &itype, const Str // Add properties - for (const List<PropertyInterface>::Element *E = itype.properties.front(); E; E = E->next()) { - const PropertyInterface &iprop = E->get(); + for (const PropertyInterface &iprop : itype.properties) { Error prop_err = _generate_cs_property(itype, iprop, output); ERR_FAIL_COND_V_MSG(prop_err != OK, prop_err, "Failed to generate property '" + iprop.cname.operator String() + @@ -1463,15 +1446,13 @@ Error BindingsGenerator::_generate_cs_type(const TypeInterface &itype, const Str } int method_bind_count = 0; - for (const List<MethodInterface>::Element *E = itype.methods.front(); E; E = E->next()) { - const MethodInterface &imethod = E->get(); + for (const MethodInterface &imethod : itype.methods) { Error method_err = _generate_cs_method(itype, imethod, method_bind_count, output); ERR_FAIL_COND_V_MSG(method_err != OK, method_err, "Failed to generate method '" + imethod.name + "' for class '" + itype.name + "'."); } - for (const List<SignalInterface>::Element *E = itype.signals_.front(); E; E = E->next()) { - const SignalInterface &isignal = E->get(); + for (const SignalInterface &isignal : itype.signals_) { Error method_err = _generate_cs_signal(itype, isignal, output); ERR_FAIL_COND_V_MSG(method_err != OK, method_err, "Failed to generate signal '" + isignal.name + "' for class '" + itype.name + "'."); @@ -1678,8 +1659,8 @@ Error BindingsGenerator::_generate_cs_method(const BindingsGenerator::TypeInterf StringBuilder default_args_doc; // Retrieve information from the arguments - for (const List<ArgumentInterface>::Element *F = p_imethod.arguments.front(); F; F = F->next()) { - const ArgumentInterface &iarg = F->get(); + const ArgumentInterface &first = p_imethod.arguments.front()->get(); + for (const ArgumentInterface &iarg : p_imethod.arguments) { const TypeInterface *arg_type = _get_type_or_placeholder(iarg.type); ERR_FAIL_COND_V_MSG(arg_type->is_singleton, ERR_BUG, @@ -1699,7 +1680,7 @@ Error BindingsGenerator::_generate_cs_method(const BindingsGenerator::TypeInterf // Add the current arguments to the signature // If the argument has a default value which is not a constant, we will make it Nullable { - if (F != p_imethod.arguments.front()) { + if (&iarg != &first) { arguments_sig += ", "; } @@ -1754,7 +1735,12 @@ Error BindingsGenerator::_generate_cs_method(const BindingsGenerator::TypeInterf cs_in_statements += " : "; } - String def_arg = sformat(iarg.default_argument, arg_type->cs_type); + String cs_type = arg_type->cs_type; + if (cs_type.ends_with("[]")) { + cs_type = cs_type.substr(0, cs_type.length() - 2); + } + + String def_arg = sformat(iarg.default_argument, cs_type); cs_in_statements += def_arg; cs_in_statements += ";\n" INDENT3; @@ -1763,8 +1749,10 @@ Error BindingsGenerator::_generate_cs_method(const BindingsGenerator::TypeInterf // Apparently the name attribute must not include the @ String param_tag_name = iarg.name.begins_with("@") ? iarg.name.substr(1, iarg.name.length()) : iarg.name; + // Escape < and > in the attribute default value + String param_def_arg = def_arg.replacen("<", "<").replacen(">", ">"); - default_args_doc.append(MEMBER_BEGIN "/// <param name=\"" + param_tag_name + "\">If the parameter is null, then the default value is " + def_arg + "</param>"); + default_args_doc.append(MEMBER_BEGIN "/// <param name=\"" + param_tag_name + "\">If the parameter is null, then the default value is " + param_def_arg + "</param>"); } else { icall_params += arg_type->cs_in.is_empty() ? iarg.name : sformat(arg_type->cs_in, iarg.name); } @@ -1855,9 +1843,9 @@ Error BindingsGenerator::_generate_cs_method(const BindingsGenerator::TypeInterf p_output.append(p_imethod.name); p_output.append("\""); - for (const List<ArgumentInterface>::Element *F = p_imethod.arguments.front(); F; F = F->next()) { + for (const ArgumentInterface &iarg : p_imethod.arguments) { p_output.append(", "); - p_output.append(F->get().name); + p_output.append(iarg.name); } p_output.append(");\n" CLOSE_BLOCK_L2); @@ -1899,8 +1887,8 @@ Error BindingsGenerator::_generate_cs_signal(const BindingsGenerator::TypeInterf String arguments_sig; // Retrieve information from the arguments - for (const List<ArgumentInterface>::Element *F = p_isignal.arguments.front(); F; F = F->next()) { - const ArgumentInterface &iarg = F->get(); + const ArgumentInterface &first = p_isignal.arguments.front()->get(); + for (const ArgumentInterface &iarg : p_isignal.arguments) { const TypeInterface *arg_type = _get_type_or_placeholder(iarg.type); ERR_FAIL_COND_V_MSG(arg_type->is_singleton, ERR_BUG, @@ -1914,7 +1902,7 @@ Error BindingsGenerator::_generate_cs_signal(const BindingsGenerator::TypeInterf // Add the current arguments to the signature - if (F != p_isignal.arguments.front()) { + if (&iarg != &first) { arguments_sig += ", "; } @@ -2042,8 +2030,7 @@ Error BindingsGenerator::generate_glue(const String &p_output_dir) { String ctor_method(ICALL_PREFIX + itype.proxy_name + "_Ctor"); // Used only for derived types - for (const List<MethodInterface>::Element *E = itype.methods.front(); E; E = E->next()) { - const MethodInterface &imethod = E->get(); + for (const MethodInterface &imethod : itype.methods) { Error method_err = _generate_glue_method(itype, imethod, output); ERR_FAIL_COND_V_MSG(method_err != OK, method_err, "Failed to generate method '" + imethod.name + "' for class '" + itype.name + "'."); @@ -2114,20 +2101,20 @@ Error BindingsGenerator::generate_glue(const String &p_output_dir) { } bool tools_sequence = false; - for (const List<InternalCall>::Element *E = core_custom_icalls.front(); E; E = E->next()) { + for (const InternalCall &internal_call : core_custom_icalls) { if (tools_sequence) { - if (!E->get().editor_only) { + if (!internal_call.editor_only) { tools_sequence = false; output.append("#endif\n"); } } else { - if (E->get().editor_only) { + if (internal_call.editor_only) { output.append("#ifdef TOOLS_ENABLED\n"); tools_sequence = true; } } - ADD_INTERNAL_CALL_REGISTRATION(E->get()); + ADD_INTERNAL_CALL_REGISTRATION(internal_call); } if (tools_sequence) { @@ -2136,24 +2123,24 @@ Error BindingsGenerator::generate_glue(const String &p_output_dir) { } output.append("#ifdef TOOLS_ENABLED\n"); - for (const List<InternalCall>::Element *E = editor_custom_icalls.front(); E; E = E->next()) - ADD_INTERNAL_CALL_REGISTRATION(E->get()); + for (const InternalCall &internal_call : editor_custom_icalls) + ADD_INTERNAL_CALL_REGISTRATION(internal_call); output.append("#endif // TOOLS_ENABLED\n"); - for (const List<InternalCall>::Element *E = method_icalls.front(); E; E = E->next()) { + for (const InternalCall &internal_call : method_icalls) { if (tools_sequence) { - if (!E->get().editor_only) { + if (!internal_call.editor_only) { tools_sequence = false; output.append("#endif\n"); } } else { - if (E->get().editor_only) { + if (internal_call.editor_only) { output.append("#ifdef TOOLS_ENABLED\n"); tools_sequence = true; } } - ADD_INTERNAL_CALL_REGISTRATION(E->get()); + ADD_INTERNAL_CALL_REGISTRATION(internal_call); } if (tools_sequence) { @@ -2209,8 +2196,7 @@ Error BindingsGenerator::_generate_glue_method(const BindingsGenerator::TypeInte // Get arguments information int i = 0; - for (const List<ArgumentInterface>::Element *F = p_imethod.arguments.front(); F; F = F->next()) { - const ArgumentInterface &iarg = F->get(); + for (const ArgumentInterface &iarg : p_imethod.arguments) { const TypeInterface *arg_type = _get_type_or_placeholder(iarg.type); String c_param_name = "arg" + itos(i + 1); @@ -2623,9 +2609,7 @@ bool BindingsGenerator::_populate_object_type_interfaces() { Map<StringName, StringName> accessor_methods; - for (const List<PropertyInfo>::Element *E = property_list.front(); E; E = E->next()) { - const PropertyInfo &property = E->get(); - + for (const PropertyInfo &property : property_list) { if (property.usage & PROPERTY_USAGE_GROUP || property.usage & PROPERTY_USAGE_SUBGROUP || property.usage & PROPERTY_USAGE_CATEGORY) { continue; } @@ -2684,9 +2668,7 @@ bool BindingsGenerator::_populate_object_type_interfaces() { ClassDB::get_method_list(type_cname, &method_list, true); method_list.sort(); - for (List<MethodInfo>::Element *E = method_list.front(); E; E = E->next()) { - const MethodInfo &method_info = E->get(); - + for (const MethodInfo &method_info : method_list) { int argc = method_info.arguments.size(); if (method_info.name.is_empty()) { @@ -2840,9 +2822,7 @@ bool BindingsGenerator::_populate_object_type_interfaces() { // Classes starting with an underscore are ignored unless they're used as a property setter or getter if (!imethod.is_virtual && imethod.name[0] == '_') { - for (const List<PropertyInterface>::Element *F = itype.properties.front(); F; F = F->next()) { - const PropertyInterface &iprop = F->get(); - + for (const PropertyInterface &iprop : itype.properties) { if (iprop.setter == imethod.name || iprop.getter == imethod.name) { imethod.is_internal = true; itype.methods.push_back(imethod); @@ -2952,8 +2932,7 @@ bool BindingsGenerator::_populate_object_type_interfaces() { } EnumInterface ienum(enum_proxy_cname); const List<StringName> &enum_constants = enum_map.get(*k); - for (const List<StringName>::Element *E = enum_constants.front(); E; E = E->next()) { - const StringName &constant_cname = E->get(); + for (const StringName &constant_cname : enum_constants) { String constant_name = constant_cname.operator String(); int *value = class_info->constant_map.getptr(constant_cname); ERR_FAIL_NULL_V(value, false); @@ -2989,9 +2968,8 @@ bool BindingsGenerator::_populate_object_type_interfaces() { enum_types.insert(enum_itype.cname, enum_itype); } - for (const List<String>::Element *E = constants.front(); E; E = E->next()) { - const String &constant_name = E->get(); - int *value = class_info->constant_map.getptr(StringName(E->get())); + for (const String &constant_name : constants) { + int *value = class_info->constant_map.getptr(StringName(constant_name)); ERR_FAIL_NULL_V(value, false); ConstantInterface iconstant(constant_name, snake_to_pascal_case(constant_name, true), *value); @@ -3099,6 +3077,9 @@ bool BindingsGenerator::_arg_default_value_from_variant(const Variant &p_val, Ar r_iarg.default_argument = "null"; break; case Variant::ARRAY: + r_iarg.default_argument = "new %s { }"; + r_iarg.def_param_mode = ArgumentInterface::NULLABLE_REF; + break; case Variant::PACKED_BYTE_ARRAY: case Variant::PACKED_INT32_ARRAY: case Variant::PACKED_INT64_ARRAY: @@ -3108,7 +3089,7 @@ bool BindingsGenerator::_arg_default_value_from_variant(const Variant &p_val, Ar case Variant::PACKED_VECTOR2_ARRAY: case Variant::PACKED_VECTOR3_ARRAY: case Variant::PACKED_COLOR_ARRAY: - r_iarg.default_argument = "new %s {}"; + r_iarg.default_argument = "Array.Empty<%s>()"; r_iarg.def_param_mode = ArgumentInterface::NULLABLE_REF; break; case Variant::TRANSFORM2D: { @@ -3539,9 +3520,7 @@ void BindingsGenerator::_populate_global_constants() { } } - for (List<EnumInterface>::Element *E = global_enums.front(); E; E = E->next()) { - EnumInterface &ienum = E->get(); - + for (EnumInterface &ienum : global_enums) { TypeInterface enum_itype; enum_itype.is_enum = true; enum_itype.name = ienum.cname.operator String(); @@ -3571,13 +3550,13 @@ void BindingsGenerator::_populate_global_constants() { hardcoded_enums.push_back("Vector2i.Axis"); hardcoded_enums.push_back("Vector3.Axis"); hardcoded_enums.push_back("Vector3i.Axis"); - for (List<StringName>::Element *E = hardcoded_enums.front(); E; E = E->next()) { + for (const StringName &enum_cname : hardcoded_enums) { // These enums are not generated and must be written manually (e.g.: Vector3.Axis) // Here, we assume core types do not begin with underscore TypeInterface enum_itype; enum_itype.is_enum = true; - enum_itype.name = E->get().operator String(); - enum_itype.cname = E->get(); + enum_itype.name = enum_cname.operator String(); + enum_itype.cname = enum_cname; enum_itype.proxy_name = enum_itype.name; TypeInterface::postsetup_enum_type(enum_itype); enum_types.insert(enum_itype.cname, enum_itype); diff --git a/modules/mono/editor/bindings_generator.h b/modules/mono/editor/bindings_generator.h index 48c0e02723..a649181b20 100644 --- a/modules/mono/editor/bindings_generator.h +++ b/modules/mono/editor/bindings_generator.h @@ -357,9 +357,9 @@ class BindingsGenerator { List<SignalInterface> signals_; const MethodInterface *find_method_by_name(const StringName &p_cname) const { - for (const List<MethodInterface>::Element *E = methods.front(); E; E = E->next()) { - if (E->get().cname == p_cname) { - return &E->get(); + for (const MethodInterface &E : methods) { + if (E.cname == p_cname) { + return &E; } } @@ -367,9 +367,9 @@ class BindingsGenerator { } const PropertyInterface *find_property_by_name(const StringName &p_cname) const { - for (const List<PropertyInterface>::Element *E = properties.front(); E; E = E->next()) { - if (E->get().cname == p_cname) { - return &E->get(); + for (const PropertyInterface &E : properties) { + if (E.cname == p_cname) { + return &E; } } @@ -377,9 +377,9 @@ class BindingsGenerator { } const PropertyInterface *find_property_by_proxy_name(const String &p_proxy_name) const { - for (const List<PropertyInterface>::Element *E = properties.front(); E; E = E->next()) { - if (E->get().proxy_name == p_proxy_name) { - return &E->get(); + for (const PropertyInterface &E : properties) { + if (E.proxy_name == p_proxy_name) { + return &E; } } @@ -387,9 +387,9 @@ class BindingsGenerator { } const MethodInterface *find_method_by_proxy_name(const String &p_proxy_name) const { - for (const List<MethodInterface>::Element *E = methods.front(); E; E = E->next()) { - if (E->get().proxy_name == p_proxy_name) { - return &E->get(); + for (const MethodInterface &E : methods) { + if (E.proxy_name == p_proxy_name) { + return &E; } } @@ -613,9 +613,9 @@ class BindingsGenerator { } const ConstantInterface *find_constant_by_name(const String &p_name, const List<ConstantInterface> &p_constants) const { - for (const List<ConstantInterface>::Element *E = p_constants.front(); E; E = E->next()) { - if (E->get().name == p_name) { - return &E->get(); + for (const ConstantInterface &E : p_constants) { + if (E.name == p_name) { + return &E; } } diff --git a/modules/mono/editor/code_completion.cpp b/modules/mono/editor/code_completion.cpp index bbfba83e6f..b7b36a92d8 100644 --- a/modules/mono/editor/code_completion.cpp +++ b/modules/mono/editor/code_completion.cpp @@ -109,9 +109,7 @@ PackedStringArray get_code_completion(CompletionKind p_kind, const String &p_scr List<PropertyInfo> project_props; ProjectSettings::get_singleton()->get_property_list(&project_props); - for (List<PropertyInfo>::Element *E = project_props.front(); E; E = E->next()) { - const PropertyInfo &prop = E->get(); - + for (const PropertyInfo &prop : project_props) { if (!prop.name.begins_with("input/")) { continue; } @@ -125,8 +123,8 @@ PackedStringArray get_code_completion(CompletionKind p_kind, const String &p_scr // AutoLoads Map<StringName, ProjectSettings::AutoloadInfo> autoloads = ProjectSettings::get_singleton()->get_autoload_list(); - for (Map<StringName, ProjectSettings::AutoloadInfo>::Element *E = autoloads.front(); E; E = E->next()) { - const ProjectSettings::AutoloadInfo &info = E->value(); + for (const KeyValue<StringName, ProjectSettings::AutoloadInfo> &E : autoloads) { + const ProjectSettings::AutoloadInfo &info = E.value; suggestions.push_back(quoted("/root/" + String(info.name))); } } @@ -187,8 +185,8 @@ PackedStringArray get_code_completion(CompletionKind p_kind, const String &p_scr ClassDB::get_signal_list(native, &signals, /* p_no_inheritance: */ false); } - for (List<MethodInfo>::Element *E = signals.front(); E; E = E->next()) { - const String &signal = E->get().name; + for (const MethodInfo &E : signals) { + const String &signal = E.name; suggestions.push_back(quoted(signal)); } } break; @@ -199,8 +197,8 @@ PackedStringArray get_code_completion(CompletionKind p_kind, const String &p_scr List<StringName> sn; Theme::get_default()->get_color_list(base->get_class(), &sn); - for (List<StringName>::Element *E = sn.front(); E; E = E->next()) { - suggestions.push_back(quoted(E->get())); + for (const StringName &E : sn) { + suggestions.push_back(quoted(E)); } } } break; @@ -211,8 +209,8 @@ PackedStringArray get_code_completion(CompletionKind p_kind, const String &p_scr List<StringName> sn; Theme::get_default()->get_constant_list(base->get_class(), &sn); - for (List<StringName>::Element *E = sn.front(); E; E = E->next()) { - suggestions.push_back(quoted(E->get())); + for (const StringName &E : sn) { + suggestions.push_back(quoted(E)); } } } break; @@ -223,8 +221,8 @@ PackedStringArray get_code_completion(CompletionKind p_kind, const String &p_scr List<StringName> sn; Theme::get_default()->get_font_list(base->get_class(), &sn); - for (List<StringName>::Element *E = sn.front(); E; E = E->next()) { - suggestions.push_back(quoted(E->get())); + for (const StringName &E : sn) { + suggestions.push_back(quoted(E)); } } } break; @@ -235,8 +233,8 @@ PackedStringArray get_code_completion(CompletionKind p_kind, const String &p_scr List<StringName> sn; Theme::get_default()->get_font_size_list(base->get_class(), &sn); - for (List<StringName>::Element *E = sn.front(); E; E = E->next()) { - suggestions.push_back(quoted(E->get())); + for (const StringName &E : sn) { + suggestions.push_back(quoted(E)); } } } break; @@ -247,8 +245,8 @@ PackedStringArray get_code_completion(CompletionKind p_kind, const String &p_scr List<StringName> sn; Theme::get_default()->get_stylebox_list(base->get_class(), &sn); - for (List<StringName>::Element *E = sn.front(); E; E = E->next()) { - suggestions.push_back(quoted(E->get())); + for (const StringName &E : sn) { + suggestions.push_back(quoted(E)); } } } break; diff --git a/modules/mono/editor/editor_internal_calls.cpp b/modules/mono/editor/editor_internal_calls.cpp index 21efd58938..8164f459ca 100644 --- a/modules/mono/editor/editor_internal_calls.cpp +++ b/modules/mono/editor/editor_internal_calls.cpp @@ -241,7 +241,7 @@ MonoBoolean godot_icall_Internal_IsAssembliesReloadingNeeded() { void godot_icall_Internal_ReloadAssemblies(MonoBoolean p_soft_reload) { #ifdef GD_MONO_HOT_RELOAD - _GodotSharp::get_singleton()->call_deferred("_reload_assemblies", (bool)p_soft_reload); + _GodotSharp::get_singleton()->call_deferred(SNAME("_reload_assemblies"), (bool)p_soft_reload); #endif } diff --git a/modules/mono/glue/GodotSharp/GodotSharp/Core/AABB.cs b/modules/mono/glue/GodotSharp/GodotSharp/Core/AABB.cs index 2b641a8937..1a3b81487f 100644 --- a/modules/mono/glue/GodotSharp/GodotSharp/Core/AABB.cs +++ b/modules/mono/glue/GodotSharp/GodotSharp/Core/AABB.cs @@ -1,16 +1,10 @@ -// file: core/math/aabb.h -// commit: 7ad14e7a3e6f87ddc450f7e34621eb5200808451 -// file: core/math/aabb.cpp -// commit: bd282ff43f23fe845f29a3e25c8efc01bd65ffb0 -// file: core/variant_call.cpp -// commit: 5ad9be4c24e9d7dc5672fdc42cea896622fe5685 -using System; -using System.Runtime.InteropServices; #if REAL_T_IS_DOUBLE using real_t = System.Double; #else using real_t = System.Single; #endif +using System; +using System.Runtime.InteropServices; namespace Godot { @@ -676,20 +670,12 @@ namespace Godot public override string ToString() { - return String.Format("{0}, {1}", new object[] - { - _position.ToString(), - _size.ToString() - }); + return $"{_position}, {_size}"; } public string ToString(string format) { - return String.Format("{0}, {1}", new object[] - { - _position.ToString(format), - _size.ToString(format) - }); + return $"{_position.ToString(format)}, {_size.ToString(format)}"; } } } diff --git a/modules/mono/glue/GodotSharp/GodotSharp/Core/Array.cs b/modules/mono/glue/GodotSharp/GodotSharp/Core/Array.cs index ce613f7ef9..f52a767018 100644 --- a/modules/mono/glue/GodotSharp/GodotSharp/Core/Array.cs +++ b/modules/mono/glue/GodotSharp/GodotSharp/Core/Array.cs @@ -25,16 +25,30 @@ namespace Godot.Collections } } + /// <summary> + /// Wrapper around Godot's Array class, an array of Variant + /// typed elements allocated in the engine in C++. Useful when + /// interfacing with the engine. Otherwise prefer .NET collections + /// such as <see cref="System.Array"/> or <see cref="List{T}"/>. + /// </summary> public class Array : IList, IDisposable { ArraySafeHandle safeHandle; bool disposed = false; + /// <summary> + /// Constructs a new empty <see cref="Array"/>. + /// </summary> public Array() { safeHandle = new ArraySafeHandle(godot_icall_Array_Ctor()); } + /// <summary> + /// Constructs a new <see cref="Array"/> from the given collection's elements. + /// </summary> + /// <param name="collection">The collection of elements to construct from.</param> + /// <returns>A new Godot Array.</returns> public Array(IEnumerable collection) : this() { if (collection == null) @@ -44,6 +58,11 @@ namespace Godot.Collections Add(element); } + /// <summary> + /// Constructs a new <see cref="Array"/> from the given objects. + /// </summary> + /// <param name="array">The objects to put in the new array.</param> + /// <returns>A new Godot Array.</returns> public Array(params object[] array) : this() { if (array == null) @@ -71,21 +90,40 @@ namespace Godot.Collections return safeHandle.DangerousGetHandle(); } + /// <summary> + /// Duplicates this <see cref="Array"/>. + /// </summary> + /// <param name="deep">If true, performs a deep copy.</param> + /// <returns>A new Godot Array.</returns> public Array Duplicate(bool deep = false) { return new Array(godot_icall_Array_Duplicate(GetPtr(), deep)); } + /// <summary> + /// Resizes this <see cref="Array"/> to the given size. + /// </summary> + /// <param name="newSize">The new size of the array.</param> + /// <returns><see cref="Error.Ok"/> if successful, or an error code.</returns> public Error Resize(int newSize) { return godot_icall_Array_Resize(GetPtr(), newSize); } + /// <summary> + /// Shuffles the contents of this <see cref="Array"/> into a random order. + /// </summary> public void Shuffle() { godot_icall_Array_Shuffle(GetPtr()); } + /// <summary> + /// Concatenates these two <see cref="Array"/>s. + /// </summary> + /// <param name="left">The first array.</param> + /// <param name="right">The second array.</param> + /// <returns>A new Godot Array with the contents of both arrays.</returns> public static Array operator +(Array left, Array right) { return new Array(godot_icall_Array_Concatenate(left.GetPtr(), right.GetPtr())); @@ -93,6 +131,9 @@ namespace Godot.Collections // IDisposable + /// <summary> + /// Disposes of this <see cref="Array"/>. + /// </summary> public void Dispose() { if (disposed) @@ -109,38 +150,90 @@ namespace Godot.Collections // IList - public bool IsReadOnly => false; + bool IList.IsReadOnly => false; - public bool IsFixedSize => false; + bool IList.IsFixedSize => false; + /// <summary> + /// Returns the object at the given index. + /// </summary> + /// <value>The object at the given index.</value> public object this[int index] { get => godot_icall_Array_At(GetPtr(), index); set => godot_icall_Array_SetAt(GetPtr(), index, value); } + /// <summary> + /// Adds an object to the end of this <see cref="Array"/>. + /// This is the same as `append` or `push_back` in GDScript. + /// </summary> + /// <param name="value">The object to add.</param> + /// <returns>The new size after adding the object.</returns> public int Add(object value) => godot_icall_Array_Add(GetPtr(), value); + /// <summary> + /// Checks if this <see cref="Array"/> contains the given object. + /// </summary> + /// <param name="value">The item to look for.</param> + /// <returns>Whether or not this array contains the given object.</returns> public bool Contains(object value) => godot_icall_Array_Contains(GetPtr(), value); + /// <summary> + /// Erases all items from this <see cref="Array"/>. + /// </summary> public void Clear() => godot_icall_Array_Clear(GetPtr()); + /// <summary> + /// Searches this <see cref="Array"/> for an object + /// and returns its index or -1 if not found. + /// </summary> + /// <param name="value">The object to search for.</param> + /// <returns>The index of the object, or -1 if not found.</returns> public int IndexOf(object value) => godot_icall_Array_IndexOf(GetPtr(), value); + /// <summary> + /// Inserts a new object at a given position in the array. + /// The position must be a valid position of an existing item, + /// or the position at the end of the array. + /// Existing items will be moved to the right. + /// </summary> + /// <param name="index">The index to insert at.</param> + /// <param name="value">The object to insert.</param> public void Insert(int index, object value) => godot_icall_Array_Insert(GetPtr(), index, value); + /// <summary> + /// Removes the first occurrence of the specified value + /// from this <see cref="Array"/>. + /// </summary> + /// <param name="value">The value to remove.</param> public void Remove(object value) => godot_icall_Array_Remove(GetPtr(), value); + /// <summary> + /// Removes an element from this <see cref="Array"/> by index. + /// </summary> + /// <param name="index">The index of the element to remove.</param> public void RemoveAt(int index) => godot_icall_Array_RemoveAt(GetPtr(), index); // ICollection + /// <summary> + /// Returns the number of elements in this <see cref="Array"/>. + /// This is also known as the size or length of the array. + /// </summary> + /// <returns>The number of elements.</returns> public int Count => godot_icall_Array_Count(GetPtr()); - public object SyncRoot => this; + object ICollection.SyncRoot => this; - public bool IsSynchronized => false; + bool ICollection.IsSynchronized => false; + /// <summary> + /// Copies the elements of this <see cref="Array"/> to the given + /// untyped C# array, starting at the given index. + /// </summary> + /// <param name="array">The array to copy to.</param> + /// <param name="index">The index to start at.</param> public void CopyTo(System.Array array, int index) { if (array == null) @@ -155,6 +248,10 @@ namespace Godot.Collections // IEnumerable + /// <summary> + /// Gets an enumerator for this <see cref="Array"/>. + /// </summary> + /// <returns>An enumerator.</returns> public IEnumerator GetEnumerator() { int count = Count; @@ -165,6 +262,10 @@ namespace Godot.Collections } } + /// <summary> + /// Converts this <see cref="Array"/> to a string. + /// </summary> + /// <returns>A string representation of this array.</returns> public override string ToString() { return godot_icall_Array_ToString(GetPtr()); @@ -234,6 +335,13 @@ namespace Godot.Collections internal extern static string godot_icall_Array_ToString(IntPtr ptr); } + /// <summary> + /// Typed wrapper around Godot's Array class, an array of Variant + /// typed elements allocated in the engine in C++. Useful when + /// interfacing with the engine. Otherwise prefer .NET collections + /// such as arrays or <see cref="List{T}"/>. + /// </summary> + /// <typeparam name="T">The type of the array.</typeparam> public class Array<T> : IList<T>, ICollection<T>, IEnumerable<T> { Array objectArray; @@ -246,11 +354,19 @@ namespace Godot.Collections Array.godot_icall_Array_Generic_GetElementTypeInfo(typeof(T), out elemTypeEncoding, out elemTypeClass); } + /// <summary> + /// Constructs a new empty <see cref="Array{T}"/>. + /// </summary> public Array() { objectArray = new Array(); } + /// <summary> + /// Constructs a new <see cref="Array{T}"/> from the given collection's elements. + /// </summary> + /// <param name="collection">The collection of elements to construct from.</param> + /// <returns>A new Godot Array.</returns> public Array(IEnumerable<T> collection) { if (collection == null) @@ -259,6 +375,11 @@ namespace Godot.Collections objectArray = new Array(collection); } + /// <summary> + /// Constructs a new <see cref="Array{T}"/> from the given items. + /// </summary> + /// <param name="array">The items to put in the new array.</param> + /// <returns>A new Godot Array.</returns> public Array(params T[] array) : this() { if (array == null) @@ -268,6 +389,10 @@ namespace Godot.Collections objectArray = new Array(array); } + /// <summary> + /// Constructs a typed <see cref="Array{T}"/> from an untyped <see cref="Array"/>. + /// </summary> + /// <param name="array">The untyped array to construct from.</param> public Array(Array array) { objectArray = array; @@ -288,26 +413,49 @@ namespace Godot.Collections return objectArray.GetPtr(); } + /// <summary> + /// Converts this typed <see cref="Array{T}"/> to an untyped <see cref="Array"/>. + /// </summary> + /// <param name="from">The typed array to convert.</param> public static explicit operator Array(Array<T> from) { return from.objectArray; } + /// <summary> + /// Duplicates this <see cref="Array{T}"/>. + /// </summary> + /// <param name="deep">If true, performs a deep copy.</param> + /// <returns>A new Godot Array.</returns> public Array<T> Duplicate(bool deep = false) { return new Array<T>(objectArray.Duplicate(deep)); } + /// <summary> + /// Resizes this <see cref="Array{T}"/> to the given size. + /// </summary> + /// <param name="newSize">The new size of the array.</param> + /// <returns><see cref="Error.Ok"/> if successful, or an error code.</returns> public Error Resize(int newSize) { return objectArray.Resize(newSize); } + /// <summary> + /// Shuffles the contents of this <see cref="Array{T}"/> into a random order. + /// </summary> public void Shuffle() { objectArray.Shuffle(); } + /// <summary> + /// Concatenates these two <see cref="Array{T}"/>s. + /// </summary> + /// <param name="left">The first array.</param> + /// <param name="right">The second array.</param> + /// <returns>A new Godot Array with the contents of both arrays.</returns> public static Array<T> operator +(Array<T> left, Array<T> right) { return new Array<T>(left.objectArray + right.objectArray); @@ -315,22 +463,44 @@ namespace Godot.Collections // IList<T> + /// <summary> + /// Returns the value at the given index. + /// </summary> + /// <value>The value at the given index.</value> public T this[int index] { get { return (T)Array.godot_icall_Array_At_Generic(GetPtr(), index, elemTypeEncoding, elemTypeClass); } set { objectArray[index] = value; } } + /// <summary> + /// Searches this <see cref="Array{T}"/> for an item + /// and returns its index or -1 if not found. + /// </summary> + /// <param name="item">The item to search for.</param> + /// <returns>The index of the item, or -1 if not found.</returns> public int IndexOf(T item) { return objectArray.IndexOf(item); } + /// <summary> + /// Inserts a new item at a given position in the <see cref="Array{T}"/>. + /// The position must be a valid position of an existing item, + /// or the position at the end of the array. + /// Existing items will be moved to the right. + /// </summary> + /// <param name="index">The index to insert at.</param> + /// <param name="item">The item to insert.</param> public void Insert(int index, T item) { objectArray.Insert(index, item); } + /// <summary> + /// Removes an element from this <see cref="Array{T}"/> by index. + /// </summary> + /// <param name="index">The index of the element to remove.</param> public void RemoveAt(int index) { objectArray.RemoveAt(index); @@ -338,31 +508,53 @@ namespace Godot.Collections // ICollection<T> + /// <summary> + /// Returns the number of elements in this <see cref="Array{T}"/>. + /// This is also known as the size or length of the array. + /// </summary> + /// <returns>The number of elements.</returns> public int Count { get { return objectArray.Count; } } - public bool IsReadOnly - { - get { return objectArray.IsReadOnly; } - } + bool ICollection<T>.IsReadOnly => false; + /// <summary> + /// Adds an item to the end of this <see cref="Array{T}"/>. + /// This is the same as `append` or `push_back` in GDScript. + /// </summary> + /// <param name="item">The item to add.</param> + /// <returns>The new size after adding the item.</returns> public void Add(T item) { objectArray.Add(item); } + /// <summary> + /// Erases all items from this <see cref="Array{T}"/>. + /// </summary> public void Clear() { objectArray.Clear(); } + /// <summary> + /// Checks if this <see cref="Array{T}"/> contains the given item. + /// </summary> + /// <param name="item">The item to look for.</param> + /// <returns>Whether or not this array contains the given item.</returns> public bool Contains(T item) { return objectArray.Contains(item); } + /// <summary> + /// Copies the elements of this <see cref="Array{T}"/> to the given + /// C# array, starting at the given index. + /// </summary> + /// <param name="array">The C# array to copy to.</param> + /// <param name="arrayIndex">The index to start at.</param> public void CopyTo(T[] array, int arrayIndex) { if (array == null) @@ -386,6 +578,12 @@ namespace Godot.Collections } } + /// <summary> + /// Removes the first occurrence of the specified value + /// from this <see cref="Array{T}"/>. + /// </summary> + /// <param name="item">The value to remove.</param> + /// <returns>A bool indicating success or failure.</returns> public bool Remove(T item) { return Array.godot_icall_Array_Remove(GetPtr(), item); @@ -393,6 +591,10 @@ namespace Godot.Collections // IEnumerable<T> + /// <summary> + /// Gets an enumerator for this <see cref="Array{T}"/>. + /// </summary> + /// <returns>An enumerator.</returns> public IEnumerator<T> GetEnumerator() { int count = objectArray.Count; @@ -408,6 +610,10 @@ namespace Godot.Collections return GetEnumerator(); } + /// <summary> + /// Converts this <see cref="Array{T}"/> to a string. + /// </summary> + /// <returns>A string representation of this array.</returns> public override string ToString() => objectArray.ToString(); } } diff --git a/modules/mono/glue/GodotSharp/GodotSharp/Core/Attributes/RPCAttributes.cs b/modules/mono/glue/GodotSharp/GodotSharp/Core/Attributes/RPCAttributes.cs index 8fc430b6bc..6cec8773b2 100644 --- a/modules/mono/glue/GodotSharp/GodotSharp/Core/Attributes/RPCAttributes.cs +++ b/modules/mono/glue/GodotSharp/GodotSharp/Core/Attributes/RPCAttributes.cs @@ -2,21 +2,12 @@ using System; namespace Godot { - [AttributeUsage(AttributeTargets.Method | AttributeTargets.Field | AttributeTargets.Property)] + [AttributeUsage(AttributeTargets.Method)] public class RemoteAttribute : Attribute {} - [AttributeUsage(AttributeTargets.Method | AttributeTargets.Field | AttributeTargets.Property)] + [AttributeUsage(AttributeTargets.Method)] public class MasterAttribute : Attribute {} - [AttributeUsage(AttributeTargets.Method | AttributeTargets.Field | AttributeTargets.Property)] + [AttributeUsage(AttributeTargets.Method)] public class PuppetAttribute : Attribute {} - - [AttributeUsage(AttributeTargets.Method | AttributeTargets.Field | AttributeTargets.Property)] - public class RemoteSyncAttribute : Attribute {} - - [AttributeUsage(AttributeTargets.Method | AttributeTargets.Field | AttributeTargets.Property)] - public class MasterSyncAttribute : Attribute {} - - [AttributeUsage(AttributeTargets.Method | AttributeTargets.Field | AttributeTargets.Property)] - public class PuppetSyncAttribute : Attribute {} } diff --git a/modules/mono/glue/GodotSharp/GodotSharp/Core/Basis.cs b/modules/mono/glue/GodotSharp/GodotSharp/Core/Basis.cs index 5dbf5d5657..8271b43b48 100644 --- a/modules/mono/glue/GodotSharp/GodotSharp/Core/Basis.cs +++ b/modules/mono/glue/GodotSharp/GodotSharp/Core/Basis.cs @@ -1,10 +1,10 @@ -using System; -using System.Runtime.InteropServices; #if REAL_T_IS_DOUBLE using real_t = System.Double; #else using real_t = System.Single; #endif +using System; +using System.Runtime.InteropServices; namespace Godot { @@ -863,16 +863,12 @@ namespace Godot public override string ToString() { - return "[X: " + x.ToString() + - ", Y: " + y.ToString() + - ", Z: " + z.ToString() + "]"; + return $"[X: {x}, Y: {y}, Z: {z}]"; } public string ToString(string format) { - return "[X: " + x.ToString(format) + - ", Y: " + y.ToString(format) + - ", Z: " + z.ToString(format) + "]"; + return $"[X: {x.ToString(format)}, Y: {y.ToString(format)}, Z: {z.ToString(format)}]"; } } } diff --git a/modules/mono/glue/GodotSharp/GodotSharp/Core/Color.cs b/modules/mono/glue/GodotSharp/GodotSharp/Core/Color.cs index 155ffcff32..b9a98ba9c7 100644 --- a/modules/mono/glue/GodotSharp/GodotSharp/Core/Color.cs +++ b/modules/mono/glue/GodotSharp/GodotSharp/Core/Color.cs @@ -1010,12 +1010,12 @@ namespace Godot public override string ToString() { - return String.Format("({0}, {1}, {2}, {3})", r.ToString(), g.ToString(), b.ToString(), a.ToString()); + return $"({r}, {g}, {b}, {a})"; } public string ToString(string format) { - return String.Format("({0}, {1}, {2}, {3})", r.ToString(format), g.ToString(format), b.ToString(format), a.ToString(format)); + return $"({r.ToString(format)}, {g.ToString(format)}, {b.ToString(format)}, {a.ToString(format)})"; } } } diff --git a/modules/mono/glue/GodotSharp/GodotSharp/Core/Colors.cs b/modules/mono/glue/GodotSharp/GodotSharp/Core/Colors.cs index 4bb727bd35..d64c8b563e 100644 --- a/modules/mono/glue/GodotSharp/GodotSharp/Core/Colors.cs +++ b/modules/mono/glue/GodotSharp/GodotSharp/Core/Colors.cs @@ -1,4 +1,3 @@ -using System; using System.Collections.Generic; namespace Godot diff --git a/modules/mono/glue/GodotSharp/GodotSharp/Core/DelegateUtils.cs b/modules/mono/glue/GodotSharp/GodotSharp/Core/DelegateUtils.cs index 785e87a043..1dca9e6ea7 100644 --- a/modules/mono/glue/GodotSharp/GodotSharp/Core/DelegateUtils.cs +++ b/modules/mono/glue/GodotSharp/GodotSharp/Core/DelegateUtils.cs @@ -61,7 +61,7 @@ namespace Godot using (var stream = new MemoryStream()) using (var writer = new BinaryWriter(stream)) { - writer.Write((ulong) TargetKind.Static); + writer.Write((ulong)TargetKind.Static); SerializeType(writer, @delegate.GetType()); @@ -77,8 +77,8 @@ namespace Godot using (var stream = new MemoryStream()) using (var writer = new BinaryWriter(stream)) { - writer.Write((ulong) TargetKind.GodotObject); - writer.Write((ulong) godotObject.GetInstanceId()); + writer.Write((ulong)TargetKind.GodotObject); + writer.Write((ulong)godotObject.GetInstanceId()); SerializeType(writer, @delegate.GetType()); @@ -100,7 +100,7 @@ namespace Godot using (var stream = new MemoryStream()) using (var writer = new BinaryWriter(stream)) { - writer.Write((ulong) TargetKind.CompilerGenerated); + writer.Write((ulong)TargetKind.CompilerGenerated); SerializeType(writer, targetType); SerializeType(writer, @delegate.GetType()); @@ -149,14 +149,14 @@ namespace Godot int flags = 0; if (methodInfo.IsPublic) - flags |= (int) BindingFlags.Public; + flags |= (int)BindingFlags.Public; else - flags |= (int) BindingFlags.NonPublic; + flags |= (int)BindingFlags.NonPublic; if (methodInfo.IsStatic) - flags |= (int) BindingFlags.Static; + flags |= (int)BindingFlags.Static; else - flags |= (int) BindingFlags.Instance; + flags |= (int)BindingFlags.Instance; writer.Write(flags); @@ -238,7 +238,7 @@ namespace Godot } else { - if (TryDeserializeSingleDelegate((byte[]) elem, out Delegate oneDelegate)) + if (TryDeserializeSingleDelegate((byte[])elem, out Delegate oneDelegate)) delegates.Add(oneDelegate); } } @@ -257,7 +257,7 @@ namespace Godot using (var stream = new MemoryStream(buffer, writable: false)) using (var reader = new BinaryReader(stream)) { - var targetKind = (TargetKind) reader.ReadUInt64(); + var targetKind = (TargetKind)reader.ReadUInt64(); switch (targetKind) { @@ -353,11 +353,11 @@ namespace Godot parameterTypes[i] = parameterType; } - methodInfo = declaringType.GetMethod(methodName, (BindingFlags) flags, null, parameterTypes, null); + methodInfo = declaringType.GetMethod(methodName, (BindingFlags)flags, null, parameterTypes, null); return methodInfo != null && methodInfo.ReturnType == returnType; } - methodInfo = declaringType.GetMethod(methodName, (BindingFlags) flags); + methodInfo = declaringType.GetMethod(methodName, (BindingFlags)flags); return methodInfo != null && methodInfo.ReturnType == returnType; } diff --git a/modules/mono/glue/GodotSharp/GodotSharp/Core/DynamicObject.cs b/modules/mono/glue/GodotSharp/GodotSharp/Core/DynamicObject.cs index c4c911b863..0c21bcaa3f 100644 --- a/modules/mono/glue/GodotSharp/GodotSharp/Core/DynamicObject.cs +++ b/modules/mono/glue/GodotSharp/GodotSharp/Core/DynamicObject.cs @@ -1,4 +1,3 @@ - using System; using System.Collections.Generic; using System.Dynamic; diff --git a/modules/mono/glue/GodotSharp/GodotSharp/Core/GD.cs b/modules/mono/glue/GodotSharp/GodotSharp/Core/GD.cs index 6699c5992c..f8f5e27397 100644 --- a/modules/mono/glue/GodotSharp/GodotSharp/Core/GD.cs +++ b/modules/mono/glue/GodotSharp/GodotSharp/Core/GD.cs @@ -1,12 +1,11 @@ -using System; -using System.Collections.Generic; -using System.Runtime.CompilerServices; #if REAL_T_IS_DOUBLE using real_t = System.Double; #else using real_t = System.Single; - #endif +using System; +using System.Collections.Generic; +using System.Runtime.CompilerServices; // TODO: Add comments describing what this class does. It is not obvious. @@ -26,17 +25,7 @@ namespace Godot public static real_t Db2Linear(real_t db) { - return (real_t) Math.Exp(db * 0.11512925464970228420089957273422); - } - - public static real_t DecTime(real_t value, real_t amount, real_t step) - { - real_t sgn = Mathf.Sign(value); - real_t val = Mathf.Abs(value); - val -= amount * step; - if (val < 0) - val = 0; - return val * sgn; + return (real_t)Math.Exp(db * 0.11512925464970228420089957273422); } public static int Hash(object var) @@ -51,7 +40,7 @@ namespace Godot public static real_t Linear2Db(real_t linear) { - return (real_t) (Math.Log(linear) * 8.6858896380650365530225783783321); + return (real_t)(Math.Log(linear) * 8.6858896380650365530225783783321); } public static Resource Load(string path) @@ -76,7 +65,7 @@ namespace Godot public static void Print(params object[] what) { - godot_icall_GD_print(Array.ConvertAll(what ?? new object[]{"null"}, x => x != null ? x.ToString() : "null")); + godot_icall_GD_print(Array.ConvertAll(what ?? new object[] { "null" }, x => x != null ? x.ToString() : "null")); } public static void PrintStack() @@ -86,22 +75,22 @@ namespace Godot public static void PrintErr(params object[] what) { - godot_icall_GD_printerr(Array.ConvertAll(what ?? new object[]{"null"}, x => x != null ? x.ToString() : "null")); + godot_icall_GD_printerr(Array.ConvertAll(what ?? new object[] { "null" }, x => x != null ? x.ToString() : "null")); } public static void PrintRaw(params object[] what) { - godot_icall_GD_printraw(Array.ConvertAll(what ?? new object[]{"null"}, x => x != null ? x.ToString() : "null")); + godot_icall_GD_printraw(Array.ConvertAll(what ?? new object[] { "null" }, x => x != null ? x.ToString() : "null")); } public static void PrintS(params object[] what) { - godot_icall_GD_prints(Array.ConvertAll(what ?? new object[]{"null"}, x => x != null ? x.ToString() : "null")); + godot_icall_GD_prints(Array.ConvertAll(what ?? new object[] { "null" }, x => x != null ? x.ToString() : "null")); } public static void PrintT(params object[] what) { - godot_icall_GD_printt(Array.ConvertAll(what ?? new object[]{"null"}, x => x != null ? x.ToString() : "null")); + godot_icall_GD_printt(Array.ConvertAll(what ?? new object[] { "null" }, x => x != null ? x.ToString() : "null")); } public static float Randf() diff --git a/modules/mono/glue/GodotSharp/GodotSharp/Core/GodotTraceListener.cs b/modules/mono/glue/GodotSharp/GodotSharp/Core/GodotTraceListener.cs index f1a00ae0fa..a566b53659 100644 --- a/modules/mono/glue/GodotSharp/GodotSharp/Core/GodotTraceListener.cs +++ b/modules/mono/glue/GodotSharp/GodotSharp/Core/GodotTraceListener.cs @@ -1,4 +1,3 @@ -using System; using System.Diagnostics; namespace Godot diff --git a/modules/mono/glue/GodotSharp/GodotSharp/Core/GodotUnhandledExceptionEvent.cs b/modules/mono/glue/GodotSharp/GodotSharp/Core/GodotUnhandledExceptionEvent.cs index 702a6c76ba..729529d093 100644 --- a/modules/mono/glue/GodotSharp/GodotSharp/Core/GodotUnhandledExceptionEvent.cs +++ b/modules/mono/glue/GodotSharp/GodotSharp/Core/GodotUnhandledExceptionEvent.cs @@ -1,8 +1,4 @@ using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; namespace Godot { diff --git a/modules/mono/glue/GodotSharp/GodotSharp/Core/MarshalUtils.cs b/modules/mono/glue/GodotSharp/GodotSharp/Core/MarshalUtils.cs index c59d083080..f508211f68 100644 --- a/modules/mono/glue/GodotSharp/GodotSharp/Core/MarshalUtils.cs +++ b/modules/mono/glue/GodotSharp/GodotSharp/Core/MarshalUtils.cs @@ -1,12 +1,8 @@ using System; -using System.Collections; using System.Collections.Generic; namespace Godot { - using Array = Godot.Collections.Array; - using Dictionary = Godot.Collections.Dictionary; - static class MarshalUtils { /// <summary> diff --git a/modules/mono/glue/GodotSharp/GodotSharp/Core/Mathf.cs b/modules/mono/glue/GodotSharp/GodotSharp/Core/Mathf.cs index c3f372d415..213f84ad73 100644 --- a/modules/mono/glue/GodotSharp/GodotSharp/Core/Mathf.cs +++ b/modules/mono/glue/GodotSharp/GodotSharp/Core/Mathf.cs @@ -1,9 +1,9 @@ -using System; #if REAL_T_IS_DOUBLE using real_t = System.Double; #else using real_t = System.Single; #endif +using System; namespace Godot { @@ -14,13 +14,15 @@ namespace Godot /// <summary> /// The circle constant, the circumference of the unit circle in radians. /// </summary> - public const real_t Tau = (real_t) 6.2831853071795864769252867666M; // 6.2831855f and 6.28318530717959 + // 6.2831855f and 6.28318530717959 + public const real_t Tau = (real_t)6.2831853071795864769252867666M; /// <summary> /// Constant that represents how many times the diameter of a circle /// fits around its perimeter. This is equivalent to `Mathf.Tau / 2`. /// </summary> - public const real_t Pi = (real_t) 3.1415926535897932384626433833M; // 3.1415927f and 3.14159265358979 + // 3.1415927f and 3.14159265358979 + public const real_t Pi = (real_t)3.1415926535897932384626433833M; /// <summary> /// Positive infinity. For negative infinity, use `-Mathf.Inf`. @@ -34,8 +36,10 @@ namespace Godot /// </summary> public const real_t NaN = real_t.NaN; - private const real_t Deg2RadConst = (real_t) 0.0174532925199432957692369077M; // 0.0174532924f and 0.0174532925199433 - private const real_t Rad2DegConst = (real_t) 57.295779513082320876798154814M; // 57.29578f and 57.2957795130823 + // 0.0174532924f and 0.0174532925199433 + private const real_t Deg2RadConst = (real_t)0.0174532925199432957692369077M; + // 57.29578f and 57.2957795130823 + private const real_t Rad2DegConst = (real_t)57.295779513082320876798154814M; /// <summary> /// Returns the absolute value of `s` (i.e. positive value). @@ -515,7 +519,8 @@ namespace Godot /// <returns>One of three possible values: `1`, `-1`, or `0`.</returns> public static int Sign(int s) { - if (s == 0) return 0; + if (s == 0) + return 0; return s < 0 ? -1 : 1; } @@ -526,7 +531,8 @@ namespace Godot /// <returns>One of three possible values: `1`, `-1`, or `0`.</returns> public static int Sign(real_t s) { - if (s == 0) return 0; + if (s == 0) + return 0; return s < 0 ? -1 : 1; } diff --git a/modules/mono/glue/GodotSharp/GodotSharp/Core/MathfEx.cs b/modules/mono/glue/GodotSharp/GodotSharp/Core/MathfEx.cs index c2f4701b5f..0888e33090 100644 --- a/modules/mono/glue/GodotSharp/GodotSharp/Core/MathfEx.cs +++ b/modules/mono/glue/GodotSharp/GodotSharp/Core/MathfEx.cs @@ -1,10 +1,9 @@ -using System; - #if REAL_T_IS_DOUBLE using real_t = System.Double; #else using real_t = System.Single; #endif +using System; namespace Godot { @@ -15,12 +14,12 @@ namespace Godot /// <summary> /// The natural number `e`. /// </summary> - public const real_t E = (real_t) 2.7182818284590452353602874714M; // 2.7182817f and 2.718281828459045 + public const real_t E = (real_t)2.7182818284590452353602874714M; // 2.7182817f and 2.718281828459045 /// <summary> /// The square root of 2. /// </summary> - public const real_t Sqrt2 = (real_t) 1.4142135623730950488016887242M; // 1.4142136f and 1.414213562373095 + public const real_t Sqrt2 = (real_t)1.4142135623730950488016887242M; // 1.4142136f and 1.414213562373095 /// <summary> /// A very small number used for float comparison with error tolerance. diff --git a/modules/mono/glue/GodotSharp/GodotSharp/Core/Plane.cs b/modules/mono/glue/GodotSharp/GodotSharp/Core/Plane.cs index ad6ca51e8b..6972102730 100644 --- a/modules/mono/glue/GodotSharp/GodotSharp/Core/Plane.cs +++ b/modules/mono/glue/GodotSharp/GodotSharp/Core/Plane.cs @@ -1,10 +1,10 @@ -using System; -using System.Runtime.InteropServices; #if REAL_T_IS_DOUBLE using real_t = System.Double; #else using real_t = System.Single; #endif +using System; +using System.Runtime.InteropServices; namespace Godot { @@ -177,7 +177,7 @@ namespace Godot return null; } - return from + dir * -dist; + return from - (dir * dist); } /// <summary> @@ -206,7 +206,7 @@ namespace Godot return null; } - return begin + segment * -dist; + return begin - (segment * dist); } /// <summary> @@ -355,20 +355,12 @@ namespace Godot public override string ToString() { - return String.Format("{0}, {1}", new object[] - { - _normal.ToString(), - D.ToString() - }); + return $"{_normal}, {D}"; } public string ToString(string format) { - return String.Format("{0}, {1}", new object[] - { - _normal.ToString(format), - D.ToString(format) - }); + return $"{_normal.ToString(format)}, {D.ToString(format)}"; } } } diff --git a/modules/mono/glue/GodotSharp/GodotSharp/Core/Quaternion.cs b/modules/mono/glue/GodotSharp/GodotSharp/Core/Quaternion.cs index 817103994a..0fed55cc30 100644 --- a/modules/mono/glue/GodotSharp/GodotSharp/Core/Quaternion.cs +++ b/modules/mono/glue/GodotSharp/GodotSharp/Core/Quaternion.cs @@ -1,10 +1,10 @@ -using System; -using System.Runtime.InteropServices; #if REAL_T_IS_DOUBLE using real_t = System.Double; #else using real_t = System.Single; #endif +using System; +using System.Runtime.InteropServices; namespace Godot { @@ -547,12 +547,12 @@ namespace Godot public override string ToString() { - return String.Format("({0}, {1}, {2}, {3})", x.ToString(), y.ToString(), z.ToString(), w.ToString()); + return $"({x}, {y}, {z}, {w})"; } public string ToString(string format) { - return String.Format("({0}, {1}, {2}, {3})", x.ToString(format), y.ToString(format), z.ToString(format), w.ToString(format)); + return $"({x.ToString(format)}, {y.ToString(format)}, {z.ToString(format)}, {w.ToString(format)})"; } } } diff --git a/modules/mono/glue/GodotSharp/GodotSharp/Core/Rect2.cs b/modules/mono/glue/GodotSharp/GodotSharp/Core/Rect2.cs index 612fb64a3d..dec69c7f94 100644 --- a/modules/mono/glue/GodotSharp/GodotSharp/Core/Rect2.cs +++ b/modules/mono/glue/GodotSharp/GodotSharp/Core/Rect2.cs @@ -1,10 +1,10 @@ -using System; -using System.Runtime.InteropServices; #if REAL_T_IS_DOUBLE using real_t = System.Double; #else using real_t = System.Single; #endif +using System; +using System.Runtime.InteropServices; namespace Godot { @@ -405,20 +405,12 @@ namespace Godot public override string ToString() { - return String.Format("{0}, {1}", new object[] - { - _position.ToString(), - _size.ToString() - }); + return $"{_position}, {_size}"; } public string ToString(string format) { - return String.Format("{0}, {1}", new object[] - { - _position.ToString(format), - _size.ToString(format) - }); + return $"{_position.ToString(format)}, {_size.ToString(format)}"; } } } diff --git a/modules/mono/glue/GodotSharp/GodotSharp/Core/Rect2i.cs b/modules/mono/glue/GodotSharp/GodotSharp/Core/Rect2i.cs index c27af74866..7fb6614d2c 100644 --- a/modules/mono/glue/GodotSharp/GodotSharp/Core/Rect2i.cs +++ b/modules/mono/glue/GodotSharp/GodotSharp/Core/Rect2i.cs @@ -383,20 +383,12 @@ namespace Godot public override string ToString() { - return String.Format("{0}, {1}", new object[] - { - _position.ToString(), - _size.ToString() - }); + return $"{_position}, {_size}"; } public string ToString(string format) { - return String.Format("{0}, {1}", new object[] - { - _position.ToString(format), - _size.ToString(format) - }); + return $"{_position.ToString(format)}, {_size.ToString(format)}"; } } } diff --git a/modules/mono/glue/GodotSharp/GodotSharp/Core/StringExtensions.cs b/modules/mono/glue/GodotSharp/GodotSharp/Core/StringExtensions.cs index 98efa89ef0..d9665cbf2b 100644 --- a/modules/mono/glue/GodotSharp/GodotSharp/Core/StringExtensions.cs +++ b/modules/mono/glue/GodotSharp/GodotSharp/Core/StringExtensions.cs @@ -61,9 +61,9 @@ namespace Godot return string.Empty; } - // <summary> - // If the string is a path to a file, return the path to the file without the extension. - // </summary> + /// <summary> + /// If the string is a path to a file, return the path to the file without the extension. + /// </summary> public static string BaseName(this string instance) { int index = instance.LastIndexOf('.'); @@ -74,17 +74,17 @@ namespace Godot return instance; } - // <summary> - // Return true if the strings begins with the given string. - // </summary> + /// <summary> + /// Return <see langword="true"/> if the strings begins with the given string. + /// </summary> public static bool BeginsWith(this string instance, string text) { return instance.StartsWith(text); } - // <summary> - // Return the bigrams (pairs of consecutive letters) of this string. - // </summary> + /// <summary> + /// Return the bigrams (pairs of consecutive letters) of this string. + /// </summary> public static string[] Bigrams(this string instance) { var b = new string[instance.Length - 1]; @@ -124,12 +124,12 @@ namespace Godot instance = instance.Substring(2); } - return sign * Convert.ToInt32(instance, 2);; + return sign * Convert.ToInt32(instance, 2); } - // <summary> - // Return the amount of substrings in string. - // </summary> + /// <summary> + /// Return the amount of substrings in string. + /// </summary> public static int Count(this string instance, string what, bool caseSensitive = true, int from = 0, int to = 0) { if (what.Length == 0) @@ -187,9 +187,9 @@ namespace Godot return c; } - // <summary> - // Return a copy of the string with special characters escaped using the C language standard. - // </summary> + /// <summary> + /// Return a copy of the string with special characters escaped using the C language standard. + /// </summary> public static string CEscape(this string instance) { var sb = new StringBuilder(string.Copy(instance)); @@ -209,9 +209,10 @@ namespace Godot return sb.ToString(); } - // <summary> - // Return a copy of the string with escaped characters replaced by their meanings according to the C language standard. - // </summary> + /// <summary> + /// Return a copy of the string with escaped characters replaced by their meanings + /// according to the C language standard. + /// </summary> public static string CUnescape(this string instance) { var sb = new StringBuilder(string.Copy(instance)); @@ -231,9 +232,12 @@ namespace Godot return sb.ToString(); } - // <summary> - // Change the case of some letters. Replace underscores with spaces, convert all letters to lowercase then capitalize first and every letter following the space character. For [code]capitalize camelCase mixed_with_underscores[/code] it will return [code]Capitalize Camelcase Mixed With Underscores[/code]. - // </summary> + /// <summary> + /// Change the case of some letters. Replace underscores with spaces, convert all letters + /// to lowercase then capitalize first and every letter following the space character. + /// For <c>capitalize camelCase mixed_with_underscores</c> it will return + /// <c>Capitalize Camelcase Mixed With Underscores</c>. + /// </summary> public static string Capitalize(this string instance) { string aux = instance.Replace("_", " ").ToLower(); @@ -254,17 +258,17 @@ namespace Godot return cap; } - // <summary> - // Perform a case-sensitive comparison to another string, return -1 if less, 0 if equal and +1 if greater. - // </summary> + /// <summary> + /// Perform a case-sensitive comparison to another string, return -1 if less, 0 if equal and +1 if greater. + /// </summary> public static int CasecmpTo(this string instance, string to) { return instance.CompareTo(to, caseSensitive: true); } - // <summary> - // Perform a comparison to another string, return -1 if less, 0 if equal and +1 if greater. - // </summary> + /// <summary> + /// Perform a comparison to another string, return -1 if less, 0 if equal and +1 if greater. + /// </summary> public static int CompareTo(this string instance, string to, bool caseSensitive = true) { if (string.IsNullOrEmpty(instance)) @@ -316,25 +320,25 @@ namespace Godot } } - // <summary> - // Return true if the strings ends with the given string. - // </summary> + /// <summary> + /// Return <see langword="true"/> if the strings ends with the given string. + /// </summary> public static bool EndsWith(this string instance, string text) { return instance.EndsWith(text); } - // <summary> - // Erase [code]chars[/code] characters from the string starting from [code]pos[/code]. - // </summary> + /// <summary> + /// Erase <paramref name="chars"/> characters from the string starting from <paramref name="pos"/>. + /// </summary> public static void Erase(this StringBuilder instance, int pos, int chars) { instance.Remove(pos, chars); } - // <summary> - // If the string is a path to a file, return the extension. - // </summary> + /// <summary> + /// If the string is a path to a file, return the extension. + /// </summary> public static string Extension(this string instance) { int pos = instance.FindLast("."); @@ -345,14 +349,18 @@ namespace Godot return instance.Substring(pos + 1); } - /// <summary>Find the first occurrence of a substring. Optionally, the search starting position can be passed.</summary> + /// <summary> + /// Find the first occurrence of a substring. Optionally, the search starting position can be passed. + /// </summary> /// <returns>The starting position of the substring, or -1 if not found.</returns> public static int Find(this string instance, string what, int from = 0, bool caseSensitive = true) { return instance.IndexOf(what, from, caseSensitive ? StringComparison.Ordinal : StringComparison.OrdinalIgnoreCase); } - /// <summary>Find the first occurrence of a char. Optionally, the search starting position can be passed.</summary> + /// <summary> + /// Find the first occurrence of a char. Optionally, the search starting position can be passed. + /// </summary> /// <returns>The first instance of the char, or -1 if not found.</returns> public static int Find(this string instance, char what, int from = 0, bool caseSensitive = true) { @@ -375,16 +383,19 @@ namespace Godot return instance.LastIndexOf(what, from, caseSensitive ? StringComparison.Ordinal : StringComparison.OrdinalIgnoreCase); } - /// <summary>Find the first occurrence of a substring but search as case-insensitive. Optionally, the search starting position can be passed.</summary> + /// <summary> + /// Find the first occurrence of a substring but search as case-insensitive. + /// Optionally, the search starting position can be passed. + /// </summary> /// <returns>The starting position of the substring, or -1 if not found.</returns> public static int FindN(this string instance, string what, int from = 0) { return instance.IndexOf(what, from, StringComparison.OrdinalIgnoreCase); } - // <summary> - // If the string is a path to a file, return the base directory. - // </summary> + /// <summary> + /// If the string is a path to a file, return the base directory. + /// </summary> public static string GetBaseDir(this string instance) { int basepos = instance.Find("://"); @@ -419,9 +430,9 @@ namespace Godot return @base + rs.Substr(0, sep); } - // <summary> - // If the string is a path to a file, return the file and ignore the base directory. - // </summary> + /// <summary> + /// If the string is a path to a file, return the file and ignore the base directory. + /// </summary> public static string GetFile(this string instance) { int sep = Mathf.Max(instance.FindLast("/"), instance.FindLast("\\")); @@ -461,14 +472,14 @@ namespace Godot return Encoding.UTF8.GetString(bytes); } - // <summary> - // Hash the string and return a 32 bits unsigned integer. - // </summary> + /// <summary> + /// Hash the string and return a 32 bits unsigned integer. + /// </summary> public static uint Hash(this string instance) { uint hash = 5381; - foreach(uint c in instance) + foreach (uint c in instance) { hash = (hash << 5) + hash + c; // hash * 33 + c } @@ -553,17 +564,17 @@ namespace Godot return sign * int.Parse(instance, NumberStyles.HexNumber); } - // <summary> - // Insert a substring at a given position. - // </summary> + /// <summary> + /// Insert a substring at a given position. + /// </summary> public static string Insert(this string instance, int pos, string what) { return instance.Insert(pos, what); } - // <summary> - // If the string is a path to a file or directory, return true if the path is absolute. - // </summary> + /// <summary> + /// If the string is a path to a file or directory, return <see langword="true"/> if the path is absolute. + /// </summary> public static bool IsAbsPath(this string instance) { if (string.IsNullOrEmpty(instance)) @@ -574,17 +585,17 @@ namespace Godot return instance[0] == '/' || instance[0] == '\\'; } - // <summary> - // If the string is a path to a file or directory, return true if the path is relative. - // </summary> + /// <summary> + /// If the string is a path to a file or directory, return <see langword="true"/> if the path is relative. + /// </summary> public static bool IsRelPath(this string instance) { return !IsAbsPath(instance); } - // <summary> - // Check whether this string is a subsequence of the given string. - // </summary> + /// <summary> + /// Check whether this string is a subsequence of the given string. + /// </summary> public static bool IsSubsequenceOf(this string instance, string text, bool caseSensitive = true) { int len = instance.Length; @@ -625,34 +636,36 @@ namespace Godot return false; } - // <summary> - // Check whether this string is a subsequence of the given string, ignoring case differences. - // </summary> + /// <summary> + /// Check whether this string is a subsequence of the given string, ignoring case differences. + /// </summary> public static bool IsSubsequenceOfI(this string instance, string text) { return instance.IsSubsequenceOf(text, caseSensitive: false); } - // <summary> - // Check whether the string contains a valid float. - // </summary> + /// <summary> + /// Check whether the string contains a valid <see langword="float"/>. + /// </summary> public static bool IsValidFloat(this string instance) { float f; return float.TryParse(instance, out f); } - // <summary> - // Check whether the string contains a valid color in HTML notation. - // </summary> + /// <summary> + /// Check whether the string contains a valid color in HTML notation. + /// </summary> public static bool IsValidHtmlColor(this string instance) { return Color.HtmlIsValid(instance); } - // <summary> - // Check whether the string is a valid identifier. As is common in programming languages, a valid identifier may contain only letters, digits and underscores (_) and the first character may not be a digit. - // </summary> + /// <summary> + /// Check whether the string is a valid identifier. As is common in + /// programming languages, a valid identifier may contain only letters, + /// digits and underscores (_) and the first character may not be a digit. + /// </summary> public static bool IsValidIdentifier(this string instance) { int len = instance.Length; @@ -680,18 +693,18 @@ namespace Godot return true; } - // <summary> - // Check whether the string contains a valid integer. - // </summary> + /// <summary> + /// Check whether the string contains a valid integer. + /// </summary> public static bool IsValidInteger(this string instance) { int f; return int.TryParse(instance, out f); } - // <summary> - // Check whether the string contains a valid IP address. - // </summary> + /// <summary> + /// Check whether the string contains a valid IP address. + /// </summary> public static bool IsValidIPAddress(this string instance) { // TODO: Support IPv6 addresses @@ -714,9 +727,9 @@ namespace Godot return true; } - // <summary> - // Return a copy of the string with special characters escaped using the JSON standard. - // </summary> + /// <summary> + /// Return a copy of the string with special characters escaped using the JSON standard. + /// </summary> public static string JSONEscape(this string instance) { var sb = new StringBuilder(string.Copy(instance)); @@ -733,9 +746,9 @@ namespace Godot return sb.ToString(); } - // <summary> - // Return an amount of characters from the left of the string. - // </summary> + /// <summary> + /// Return an amount of characters from the left of the string. + /// </summary> public static string Left(this string instance, int pos) { if (pos <= 0) @@ -783,7 +796,8 @@ namespace Godot } /// <summary> - /// Do a simple expression match, where '*' matches zero or more arbitrary characters and '?' matches any single character except '.'. + /// Do a simple expression match, where '*' matches zero or more + /// arbitrary characters and '?' matches any single character except '.'. /// </summary> private static bool ExprMatch(this string instance, string expr, bool caseSensitive) { @@ -798,13 +812,17 @@ namespace Godot case '?': return instance.Length > 0 && instance[0] != '.' && ExprMatch(instance.Substring(1), expr.Substring(1), caseSensitive); default: - if (instance.Length == 0) return false; - return (caseSensitive ? instance[0] == expr[0] : char.ToUpper(instance[0]) == char.ToUpper(expr[0])) && ExprMatch(instance.Substring(1), expr.Substring(1), caseSensitive); + if (instance.Length == 0) + return false; + if (caseSensitive) + return instance[0] == expr[0]; + return (char.ToUpper(instance[0]) == char.ToUpper(expr[0])) && ExprMatch(instance.Substring(1), expr.Substring(1), caseSensitive); } } /// <summary> - /// Do a simple case sensitive expression match, using ? and * wildcards (see [method expr_match]). + /// Do a simple case sensitive expression match, using ? and * wildcards + /// (see <see cref="ExprMatch(string, string, bool)"/>). /// </summary> public static bool Match(this string instance, string expr, bool caseSensitive = true) { @@ -815,7 +833,8 @@ namespace Godot } /// <summary> - /// Do a simple case insensitive expression match, using ? and * wildcards (see [method expr_match]). + /// Do a simple case insensitive expression match, using ? and * wildcards + /// (see <see cref="ExprMatch(string, string, bool)"/>). /// </summary> public static bool MatchN(this string instance, string expr) { @@ -825,9 +844,9 @@ namespace Godot return instance.ExprMatch(expr, caseSensitive: false); } - // <summary> - // Return the MD5 hash of the string as an array of bytes. - // </summary> + /// <summary> + /// Return the MD5 hash of the string as an array of bytes. + /// </summary> public static byte[] MD5Buffer(this string instance) { return godot_icall_String_md5_buffer(instance); @@ -836,9 +855,9 @@ namespace Godot [MethodImpl(MethodImplOptions.InternalCall)] internal extern static byte[] godot_icall_String_md5_buffer(string str); - // <summary> - // Return the MD5 hash of the string as a string. - // </summary> + /// <summary> + /// Return the MD5 hash of the string as a string. + /// </summary> public static string MD5Text(this string instance) { return godot_icall_String_md5_text(instance); @@ -847,25 +866,25 @@ namespace Godot [MethodImpl(MethodImplOptions.InternalCall)] internal extern static string godot_icall_String_md5_text(string str); - // <summary> - // Perform a case-insensitive comparison to another string, return -1 if less, 0 if equal and +1 if greater. - // </summary> + /// <summary> + /// Perform a case-insensitive comparison to another string, return -1 if less, 0 if equal and +1 if greater. + /// </summary> public static int NocasecmpTo(this string instance, string to) { return instance.CompareTo(to, caseSensitive: false); } - // <summary> - // Return the character code at position [code]at[/code]. - // </summary> + /// <summary> + /// Return the character code at position <paramref name="at"/>. + /// </summary> public static int OrdAt(this string instance, int at) { return instance[at]; } - // <summary> - // Format a number to have an exact number of [code]digits[/code] after the decimal point. - // </summary> + /// <summary> + /// Format a number to have an exact number of <paramref name="digits"/> after the decimal point. + /// </summary> public static string PadDecimals(this string instance, int digits) { int c = instance.Find("."); @@ -899,9 +918,9 @@ namespace Godot return instance; } - // <summary> - // Format a number to have an exact number of [code]digits[/code] before the decimal point. - // </summary> + /// <summary> + /// Format a number to have an exact number of <paramref name="digits"/> before the decimal point. + /// </summary> public static string PadZeros(this string instance, int digits) { string s = instance; @@ -932,9 +951,10 @@ namespace Godot return s; } - // <summary> - // If the string is a path, this concatenates [code]file[/code] at the end of the string as a subpath. E.g. [code]"this/is".plus_file("path") == "this/is/path"[/code]. - // </summary> + /// <summary> + /// If the string is a path, this concatenates <paramref name="file"/> at the end of the string as a subpath. + /// E.g. <c>"this/is".PlusFile("path") == "this/is/path"</c>. + /// </summary> public static string PlusFile(this string instance, string file) { if (instance.Length > 0 && instance[instance.Length - 1] == '/') @@ -942,25 +962,25 @@ namespace Godot return instance + "/" + file; } - // <summary> - // Replace occurrences of a substring for different ones inside the string. - // </summary> + /// <summary> + /// Replace occurrences of a substring for different ones inside the string. + /// </summary> public static string Replace(this string instance, string what, string forwhat) { return instance.Replace(what, forwhat); } - // <summary> - // Replace occurrences of a substring for different ones inside the string, but search case-insensitive. - // </summary> + /// <summary> + /// Replace occurrences of a substring for different ones inside the string, but search case-insensitive. + /// </summary> public static string ReplaceN(this string instance, string what, string forwhat) { return Regex.Replace(instance, what, forwhat, RegexOptions.IgnoreCase); } - // <summary> - // Perform a search for a substring, but start from the end of the string instead of the beginning. - // </summary> + /// <summary> + /// Perform a search for a substring, but start from the end of the string instead of the beginning. + /// </summary> public static int RFind(this string instance, string what, int from = -1) { return godot_icall_String_rfind(instance, what, from); @@ -969,9 +989,10 @@ namespace Godot [MethodImpl(MethodImplOptions.InternalCall)] internal extern static int godot_icall_String_rfind(string str, string what, int from); - // <summary> - // Perform a search for a substring, but start from the end of the string instead of the beginning. Also search case-insensitive. - // </summary> + /// <summary> + /// Perform a search for a substring, but start from the end of the string instead of the beginning. + /// Also search case-insensitive. + /// </summary> public static int RFindN(this string instance, string what, int from = -1) { return godot_icall_String_rfindn(instance, what, from); @@ -980,9 +1001,9 @@ namespace Godot [MethodImpl(MethodImplOptions.InternalCall)] internal extern static int godot_icall_String_rfindn(string str, string what, int from); - // <summary> - // Return the right side of the string from a given position. - // </summary> + /// <summary> + /// Return the right side of the string from a given position. + /// </summary> public static string Right(this string instance, int pos) { if (pos >= instance.Length) @@ -1029,9 +1050,9 @@ namespace Godot [MethodImpl(MethodImplOptions.InternalCall)] internal extern static byte[] godot_icall_String_sha256_buffer(string str); - // <summary> - // Return the SHA-256 hash of the string as a string. - // </summary> + /// <summary> + /// Return the SHA-256 hash of the string as a string. + /// </summary> public static string SHA256Text(this string instance) { return godot_icall_String_sha256_text(instance); @@ -1040,9 +1061,10 @@ namespace Godot [MethodImpl(MethodImplOptions.InternalCall)] internal extern static string godot_icall_String_sha256_text(string str); - // <summary> - // Return the similarity index of the text compared to this string. 1 means totally similar and 0 means totally dissimilar. - // </summary> + /// <summary> + /// Return the similarity index of the text compared to this string. + /// 1 means totally similar and 0 means totally dissimilar. + /// </summary> public static float Similarity(this string instance, string text) { if (instance == text) @@ -1080,17 +1102,19 @@ namespace Godot return 2.0f * inter / sum; } - // <summary> - // Split the string by a divisor string, return an array of the substrings. Example "One,Two,Three" will return ["One","Two","Three"] if split by ",". - // </summary> + /// <summary> + /// Split the string by a divisor string, return an array of the substrings. + /// Example "One,Two,Three" will return ["One","Two","Three"] if split by ",". + /// </summary> public static string[] Split(this string instance, string divisor, bool allowEmpty = true) { - return instance.Split(new[] { divisor }, StringSplitOptions.RemoveEmptyEntries); + return instance.Split(new[] { divisor }, allowEmpty ? StringSplitOptions.None : StringSplitOptions.RemoveEmptyEntries); } - // <summary> - // Split the string in floats by using a divisor string, return an array of the substrings. Example "1,2.5,3" will return [1,2.5,3] if split by ",". - // </summary> + /// <summary> + /// Split the string in floats by using a divisor string, return an array of the substrings. + /// Example "1,2.5,3" will return [1,2.5,3] if split by ",". + /// </summary> public static float[] SplitFloats(this string instance, string divisor, bool allowEmpty = true) { var ret = new List<float>(); @@ -1122,9 +1146,10 @@ namespace Godot (char)30, (char)31, (char)32 }; - // <summary> - // Return a copy of the string stripped of any non-printable character at the beginning and the end. The optional arguments are used to toggle stripping on the left and right edges respectively. - // </summary> + /// <summary> + /// Return a copy of the string stripped of any non-printable character at the beginning and the end. + /// The optional arguments are used to toggle stripping on the left and right edges respectively. + /// </summary> public static string StripEdges(this string instance, bool left = true, bool right = true) { if (left) @@ -1137,58 +1162,62 @@ namespace Godot return instance.TrimEnd(_nonPrintable); } - // <summary> - // Return part of the string from the position [code]from[/code], with length [code]len[/code]. - // </summary> + /// <summary> + /// Return part of the string from the position <paramref name="from"/>, with length <paramref name="len"/>. + /// </summary> public static string Substr(this string instance, int from, int len) { int max = instance.Length - from; return instance.Substring(from, len > max ? max : len); } - // <summary> - // Convert the String (which is a character array) to PackedByteArray (which is an array of bytes). The conversion is speeded up in comparison to to_utf8() with the assumption that all the characters the String contains are only ASCII characters. - // </summary> + /// <summary> + /// Convert the String (which is a character array) to PackedByteArray (which is an array of bytes). + /// The conversion is speeded up in comparison to <see cref="ToUTF8(string)"/> with the assumption + /// that all the characters the String contains are only ASCII characters. + /// </summary> public static byte[] ToAscii(this string instance) { return Encoding.ASCII.GetBytes(instance); } - // <summary> - // Convert a string, containing a decimal number, into a [code]float[/code]. - // </summary> + /// <summary> + /// Convert a string, containing a decimal number, into a <see langword="float" />. + /// </summary> public static float ToFloat(this string instance) { return float.Parse(instance); } - // <summary> - // Convert a string, containing an integer number, into an [code]int[/code]. - // </summary> + /// <summary> + /// Convert a string, containing an integer number, into an <see langword="int" />. + /// </summary> public static int ToInt(this string instance) { return int.Parse(instance); } - // <summary> - // Return the string converted to lowercase. - // </summary> + /// <summary> + /// Return the string converted to lowercase. + /// </summary> public static string ToLower(this string instance) { return instance.ToLower(); } - // <summary> - // Return the string converted to uppercase. - // </summary> + /// <summary> + /// Return the string converted to uppercase. + /// </summary> public static string ToUpper(this string instance) { return instance.ToUpper(); } - // <summary> - // Convert the String (which is an array of characters) to PackedByteArray (which is an array of bytes). The conversion is a bit slower than to_ascii(), but supports all UTF-8 characters. Therefore, you should prefer this function over to_ascii(). - // </summary> + /// <summary> + /// Convert the String (which is an array of characters) to PackedByteArray (which is an array of bytes). + /// The conversion is a bit slower than <see cref="ToAscii(string)"/>, but supports all UTF-8 characters. + /// Therefore, you should prefer this function over <see cref="ToAscii(string)"/>. + /// </summary> public static byte[] ToUTF8(this string instance) { return Encoding.UTF8.GetBytes(instance); @@ -1221,17 +1250,18 @@ namespace Godot return Uri.EscapeDataString(instance); } - // <summary> - // Return a copy of the string with special characters escaped using the XML standard. - // </summary> + /// <summary> + /// Return a copy of the string with special characters escaped using the XML standard. + /// </summary> public static string XMLEscape(this string instance) { return SecurityElement.Escape(instance); } - // <summary> - // Return a copy of the string with escaped characters replaced by their meanings according to the XML standard. - // </summary> + /// <summary> + /// Return a copy of the string with escaped characters replaced by their meanings + /// according to the XML standard. + /// </summary> public static string XMLUnescape(this string instance) { return SecurityElement.FromString(instance).Text; diff --git a/modules/mono/glue/GodotSharp/GodotSharp/Core/Transform2D.cs b/modules/mono/glue/GodotSharp/GodotSharp/Core/Transform2D.cs index fe93592667..62a6fe6959 100644 --- a/modules/mono/glue/GodotSharp/GodotSharp/Core/Transform2D.cs +++ b/modules/mono/glue/GodotSharp/GodotSharp/Core/Transform2D.cs @@ -1,10 +1,10 @@ -using System; -using System.Runtime.InteropServices; #if REAL_T_IS_DOUBLE using real_t = System.Double; #else using real_t = System.Single; #endif +using System; +using System.Runtime.InteropServices; namespace Godot { @@ -492,16 +492,12 @@ namespace Godot public override string ToString() { - return "[X: " + x.ToString() + - ", Y: " + y.ToString() + - ", O: " + origin.ToString() + "]"; + return $"[X: {x}, Y: {y}, O: {origin}]"; } public string ToString(string format) { - return "[X: " + x.ToString(format) + - ", Y: " + y.ToString(format) + - ", O: " + origin.ToString(format) + "]"; + return $"[X: {x.ToString(format)}, Y: {y.ToString(format)}, O: {origin.ToString(format)}]"; } } } diff --git a/modules/mono/glue/GodotSharp/GodotSharp/Core/Transform3D.cs b/modules/mono/glue/GodotSharp/GodotSharp/Core/Transform3D.cs index 26b1a9e8b2..1b717fb4ae 100644 --- a/modules/mono/glue/GodotSharp/GodotSharp/Core/Transform3D.cs +++ b/modules/mono/glue/GodotSharp/GodotSharp/Core/Transform3D.cs @@ -1,10 +1,10 @@ -using System; -using System.Runtime.InteropServices; #if REAL_T_IS_DOUBLE using real_t = System.Double; #else using real_t = System.Single; #endif +using System; +using System.Runtime.InteropServices; namespace Godot { @@ -393,18 +393,12 @@ namespace Godot public override string ToString() { - return "[X: " + basis.x.ToString() + - ", Y: " + basis.y.ToString() + - ", Z: " + basis.z.ToString() + - ", O: " + origin.ToString() + "]"; + return $"[X: {basis.x}, Y: {basis.y}, Z: {basis.z}, O: {origin}]"; } public string ToString(string format) { - return "[X: " + basis.x.ToString(format) + - ", Y: " + basis.y.ToString(format) + - ", Z: " + basis.z.ToString(format) + - ", O: " + origin.ToString(format) + "]"; + return $"[X: {basis.x.ToString(format)}, Y: {basis.y.ToString(format)}, Z: {basis.z.ToString(format)}, O: {origin.ToString(format)}]"; } } } diff --git a/modules/mono/glue/GodotSharp/GodotSharp/Core/Vector2.cs b/modules/mono/glue/GodotSharp/GodotSharp/Core/Vector2.cs index af053bd263..8bb5e90a68 100644 --- a/modules/mono/glue/GodotSharp/GodotSharp/Core/Vector2.cs +++ b/modules/mono/glue/GodotSharp/GodotSharp/Core/Vector2.cs @@ -1,16 +1,10 @@ -// file: core/math/math_2d.h -// commit: 7ad14e7a3e6f87ddc450f7e34621eb5200808451 -// file: core/math/math_2d.cpp -// commit: 7ad14e7a3e6f87ddc450f7e34621eb5200808451 -// file: core/variant_call.cpp -// commit: 5ad9be4c24e9d7dc5672fdc42cea896622fe5685 -using System; -using System.Runtime.InteropServices; #if REAL_T_IS_DOUBLE using real_t = System.Double; #else using real_t = System.Single; #endif +using System; +using System.Runtime.InteropServices; namespace Godot { @@ -757,20 +751,12 @@ namespace Godot public override string ToString() { - return String.Format("({0}, {1})", new object[] - { - x.ToString(), - y.ToString() - }); + return $"({x}, {y})"; } public string ToString(string format) { - return String.Format("({0}, {1})", new object[] - { - x.ToString(format), - y.ToString(format) - }); + return $"({x.ToString(format)}, {y.ToString(format)})"; } } } diff --git a/modules/mono/glue/GodotSharp/GodotSharp/Core/Vector2i.cs b/modules/mono/glue/GodotSharp/GodotSharp/Core/Vector2i.cs index 9068593fd8..959f262f52 100644 --- a/modules/mono/glue/GodotSharp/GodotSharp/Core/Vector2i.cs +++ b/modules/mono/glue/GodotSharp/GodotSharp/Core/Vector2i.cs @@ -1,11 +1,10 @@ -using System; -using System.Runtime.InteropServices; - #if REAL_T_IS_DOUBLE using real_t = System.Double; #else using real_t = System.Single; #endif +using System; +using System.Runtime.InteropServices; namespace Godot { @@ -509,20 +508,12 @@ namespace Godot public override string ToString() { - return String.Format("({0}, {1})", new object[] - { - this.x.ToString(), - this.y.ToString() - }); + return $"({x}, {y})"; } public string ToString(string format) { - return String.Format("({0}, {1})", new object[] - { - this.x.ToString(format), - this.y.ToString(format) - }); + return $"({x.ToString(format)}, {y.ToString(format)})"; } } } diff --git a/modules/mono/glue/GodotSharp/GodotSharp/Core/Vector3.cs b/modules/mono/glue/GodotSharp/GodotSharp/Core/Vector3.cs index 31a9af2d9e..bdf64159e9 100644 --- a/modules/mono/glue/GodotSharp/GodotSharp/Core/Vector3.cs +++ b/modules/mono/glue/GodotSharp/GodotSharp/Core/Vector3.cs @@ -1,16 +1,10 @@ -// file: core/math/vector3.h -// commit: bd282ff43f23fe845f29a3e25c8efc01bd65ffb0 -// file: core/math/vector3.cpp -// commit: 7ad14e7a3e6f87ddc450f7e34621eb5200808451 -// file: core/variant_call.cpp -// commit: 5ad9be4c24e9d7dc5672fdc42cea896622fe5685 -using System; -using System.Runtime.InteropServices; #if REAL_T_IS_DOUBLE using real_t = System.Double; #else using real_t = System.Single; #endif +using System; +using System.Runtime.InteropServices; namespace Godot { @@ -851,22 +845,12 @@ namespace Godot public override string ToString() { - return String.Format("({0}, {1}, {2})", new object[] - { - x.ToString(), - y.ToString(), - z.ToString() - }); + return $"({x}, {y}, {z})"; } public string ToString(string format) { - return String.Format("({0}, {1}, {2})", new object[] - { - x.ToString(format), - y.ToString(format), - z.ToString(format) - }); + return $"({x.ToString(format)}, {y.ToString(format)}, {z.ToString(format)})"; } } } diff --git a/modules/mono/glue/GodotSharp/GodotSharp/Core/Vector3i.cs b/modules/mono/glue/GodotSharp/GodotSharp/Core/Vector3i.cs index e727afa3ff..c96a7cf1b0 100644 --- a/modules/mono/glue/GodotSharp/GodotSharp/Core/Vector3i.cs +++ b/modules/mono/glue/GodotSharp/GodotSharp/Core/Vector3i.cs @@ -1,11 +1,10 @@ -using System; -using System.Runtime.InteropServices; - #if REAL_T_IS_DOUBLE using real_t = System.Double; #else using real_t = System.Single; #endif +using System; +using System.Runtime.InteropServices; namespace Godot { @@ -512,22 +511,12 @@ namespace Godot public override string ToString() { - return String.Format("({0}, {1}, {2})", new object[] - { - this.x.ToString(), - this.y.ToString(), - this.z.ToString() - }); + return $"({x}, {y}, {z})"; } public string ToString(string format) { - return String.Format("({0}, {1}, {2})", new object[] - { - this.x.ToString(format), - this.y.ToString(format), - this.z.ToString(format) - }); + return $"({x.ToString(format)}, {y.ToString(format)}, {z.ToString(format)})"; } } } diff --git a/modules/mono/glue/base_object_glue.cpp b/modules/mono/glue/base_object_glue.cpp index 2d04cedb9b..a99dff8432 100644 --- a/modules/mono/glue/base_object_glue.cpp +++ b/modules/mono/glue/base_object_glue.cpp @@ -177,8 +177,8 @@ MonoArray *godot_icall_DynamicGodotObject_SetMemberList(Object *p_ptr) { MonoArray *result = mono_array_new(mono_domain_get(), CACHED_CLASS_RAW(String), property_list.size()); int i = 0; - for (List<PropertyInfo>::Element *E = property_list.front(); E; E = E->next()) { - MonoString *boxed = GDMonoMarshal::mono_string_from_godot(E->get().name); + for (const PropertyInfo &E : property_list) { + MonoString *boxed = GDMonoMarshal::mono_string_from_godot(E.name); mono_array_setref(result, i, boxed); i++; } diff --git a/modules/mono/mono_gd/gd_mono.cpp b/modules/mono/mono_gd/gd_mono.cpp index 02d875f669..299344bb93 100644 --- a/modules/mono/mono_gd/gd_mono.cpp +++ b/modules/mono/mono_gd/gd_mono.cpp @@ -100,8 +100,8 @@ void gd_mono_setup_runtime_main_args() { main_args.write[0] = execpath.ptrw(); int i = 1; - for (List<String>::Element *E = cmdline_args.front(); E; E = E->next()) { - CharString &stored = cmdline_args_utf8.push_back(E->get().utf8())->get(); + for (const String &E : cmdline_args) { + CharString &stored = cmdline_args_utf8.push_back(E.utf8())->get(); main_args.write[i] = stored.ptrw(); i++; } diff --git a/modules/mono/mono_gd/gd_mono_assembly.cpp b/modules/mono/mono_gd/gd_mono_assembly.cpp index 67d6f3ef29..67f38bf127 100644 --- a/modules/mono/mono_gd/gd_mono_assembly.cpp +++ b/modules/mono/mono_gd/gd_mono_assembly.cpp @@ -330,8 +330,8 @@ no_pdb: void GDMonoAssembly::unload() { ERR_FAIL_NULL(image); // Should not be called if already unloaded - for (Map<MonoClass *, GDMonoClass *>::Element *E = cached_raw.front(); E; E = E->next()) { - memdelete(E->value()); + for (const KeyValue<MonoClass *, GDMonoClass *> &E : cached_raw) { + memdelete(E.value); } cached_classes.clear(); diff --git a/modules/mono/mono_gd/gd_mono_cache.cpp b/modules/mono/mono_gd/gd_mono_cache.cpp index 341ca88728..0b36796d98 100644 --- a/modules/mono/mono_gd/gd_mono_cache.cpp +++ b/modules/mono/mono_gd/gd_mono_cache.cpp @@ -143,9 +143,6 @@ void CachedData::clear_godot_api_cache() { class_RemoteAttribute = nullptr; class_MasterAttribute = nullptr; class_PuppetAttribute = nullptr; - class_RemoteSyncAttribute = nullptr; - class_MasterSyncAttribute = nullptr; - class_PuppetSyncAttribute = nullptr; class_GodotMethodAttribute = nullptr; field_GodotMethodAttribute_methodName = nullptr; class_ScriptPathAttribute = nullptr; @@ -272,9 +269,6 @@ void update_godot_api_cache() { CACHE_CLASS_AND_CHECK(RemoteAttribute, GODOT_API_CLASS(RemoteAttribute)); CACHE_CLASS_AND_CHECK(MasterAttribute, GODOT_API_CLASS(MasterAttribute)); CACHE_CLASS_AND_CHECK(PuppetAttribute, GODOT_API_CLASS(PuppetAttribute)); - CACHE_CLASS_AND_CHECK(RemoteSyncAttribute, GODOT_API_CLASS(RemoteSyncAttribute)); - CACHE_CLASS_AND_CHECK(MasterSyncAttribute, GODOT_API_CLASS(MasterSyncAttribute)); - CACHE_CLASS_AND_CHECK(PuppetSyncAttribute, GODOT_API_CLASS(PuppetSyncAttribute)); CACHE_CLASS_AND_CHECK(GodotMethodAttribute, GODOT_API_CLASS(GodotMethodAttribute)); CACHE_FIELD_AND_CHECK(GodotMethodAttribute, methodName, CACHED_CLASS(GodotMethodAttribute)->get_field("methodName")); CACHE_CLASS_AND_CHECK(ScriptPathAttribute, GODOT_API_CLASS(ScriptPathAttribute)); diff --git a/modules/mono/mono_gd/gd_mono_cache.h b/modules/mono/mono_gd/gd_mono_cache.h index 3d867060f5..6d49da0af3 100644 --- a/modules/mono/mono_gd/gd_mono_cache.h +++ b/modules/mono/mono_gd/gd_mono_cache.h @@ -114,9 +114,6 @@ struct CachedData { GDMonoClass *class_RemoteAttribute; GDMonoClass *class_MasterAttribute; GDMonoClass *class_PuppetAttribute; - GDMonoClass *class_RemoteSyncAttribute; - GDMonoClass *class_MasterSyncAttribute; - GDMonoClass *class_PuppetSyncAttribute; GDMonoClass *class_GodotMethodAttribute; GDMonoField *field_GodotMethodAttribute_methodName; GDMonoClass *class_ScriptPathAttribute; diff --git a/modules/mono/mono_gd/gd_mono_class.cpp b/modules/mono/mono_gd/gd_mono_class.cpp index f9fddd931b..27b4ac7fa7 100644 --- a/modules/mono/mono_gd/gd_mono_class.cpp +++ b/modules/mono/mono_gd/gd_mono_class.cpp @@ -522,12 +522,12 @@ GDMonoClass::~GDMonoClass() { mono_custom_attrs_free(attributes); } - for (Map<StringName, GDMonoField *>::Element *E = fields.front(); E; E = E->next()) { - memdelete(E->value()); + for (const KeyValue<StringName, GDMonoField *> &E : fields) { + memdelete(E.value); } - for (Map<StringName, GDMonoProperty *>::Element *E = properties.front(); E; E = E->next()) { - memdelete(E->value()); + for (const KeyValue<StringName, GDMonoProperty *> &E : properties) { + memdelete(E.value); } { diff --git a/modules/navigation/godot_navigation_server.cpp b/modules/navigation/godot_navigation_server.cpp index df003cfe6f..fd965674d6 100644 --- a/modules/navigation/godot_navigation_server.cpp +++ b/modules/navigation/godot_navigation_server.cpp @@ -536,7 +536,7 @@ void GodotNavigationServer::process(real_t p_delta_time) { // Emit a signal if a map changed. const uint32_t new_map_update_id = active_maps[i]->get_map_update_id(); if (new_map_update_id != active_maps_update_id[i]) { - emit_signal("map_changed", active_maps[i]->get_self()); + emit_signal(SNAME("map_changed"), active_maps[i]->get_self()); active_maps_update_id[i] = new_map_update_id; } } diff --git a/modules/navigation/nav_map.cpp b/modules/navigation/nav_map.cpp index 41306f0687..3150ca0bc8 100644 --- a/modules/navigation/nav_map.cpp +++ b/modules/navigation/nav_map.cpp @@ -734,7 +734,7 @@ void NavMap::dispatch_callbacks() { void NavMap::clip_path(const std::vector<gd::NavigationPoly> &p_navigation_polys, Vector<Vector3> &path, const gd::NavigationPoly *from_poly, const Vector3 &p_to_point, const gd::NavigationPoly *p_to_poly) const { Vector3 from = path[path.size() - 1]; - if (from.distance_to(p_to_point) < CMP_EPSILON) { + if (from.is_equal_approx(p_to_point)) { return; } Plane cut_plane; @@ -752,10 +752,10 @@ void NavMap::clip_path(const std::vector<gd::NavigationPoly> &p_navigation_polys ERR_FAIL_COND(from_poly->back_navigation_poly_id == -1); from_poly = &p_navigation_polys[from_poly->back_navigation_poly_id]; - if (pathway_start.distance_to(pathway_end) > CMP_EPSILON) { + if (!pathway_start.is_equal_approx(pathway_end)) { Vector3 inters; if (cut_plane.intersects_segment(pathway_start, pathway_end, &inters)) { - if (inters.distance_to(p_to_point) > CMP_EPSILON && inters.distance_to(path[path.size() - 1]) > CMP_EPSILON) { + if (!inters.is_equal_approx(p_to_point) && !inters.is_equal_approx(path[path.size() - 1])) { path.push_back(inters); } } diff --git a/modules/navigation/navigation_mesh_editor_plugin.cpp b/modules/navigation/navigation_mesh_editor_plugin.cpp index aa9248d2a1..587e56f593 100644 --- a/modules/navigation/navigation_mesh_editor_plugin.cpp +++ b/modules/navigation/navigation_mesh_editor_plugin.cpp @@ -47,8 +47,8 @@ void NavigationMeshEditor::_node_removed(Node *p_node) { void NavigationMeshEditor::_notification(int p_option) { if (p_option == NOTIFICATION_ENTER_TREE) { - button_bake->set_icon(get_theme_icon("Bake", "EditorIcons")); - button_reset->set_icon(get_theme_icon("Reload", "EditorIcons")); + button_bake->set_icon(get_theme_icon(SNAME("Bake"), SNAME("EditorIcons"))); + button_reset->set_icon(get_theme_icon(SNAME("Reload"), SNAME("EditorIcons"))); } } @@ -65,7 +65,7 @@ void NavigationMeshEditor::_bake_pressed() { NavigationMeshGenerator::get_singleton()->clear(node->get_navigation_mesh()); NavigationMeshGenerator::get_singleton()->bake(node->get_navigation_mesh(), node); - node->update_gizmo(); + node->update_gizmos(); } void NavigationMeshEditor::_clear_pressed() { @@ -77,7 +77,7 @@ void NavigationMeshEditor::_clear_pressed() { bake_info->set_text(""); if (node) { - node->update_gizmo(); + node->update_gizmos(); } } diff --git a/modules/navigation/navigation_mesh_generator.cpp b/modules/navigation/navigation_mesh_generator.cpp index 0d8330c1da..41cd75fd22 100644 --- a/modules/navigation/navigation_mesh_generator.cpp +++ b/modules/navigation/navigation_mesh_generator.cpp @@ -47,12 +47,12 @@ #include "scene/resources/sphere_shape_3d.h" #include "scene/resources/world_margin_shape_3d.h" -#include "modules/modules_enabled.gen.h" #ifdef TOOLS_ENABLED #include "editor/editor_node.h" #include "editor/editor_settings.h" #endif +#include "modules/modules_enabled.gen.h" #ifdef MODULE_CSG_ENABLED #include "modules/csg/csg_shape.h" #endif @@ -514,11 +514,11 @@ void NavigationMeshGenerator::bake(Ref<NavigationMesh> p_nav_mesh, Node *p_node) } Transform3D navmesh_xform = Object::cast_to<Node3D>(p_node)->get_transform().affine_inverse(); - for (const List<Node *>::Element *E = parse_nodes.front(); E; E = E->next()) { + for (Node *E : parse_nodes) { int geometry_type = p_nav_mesh->get_parsed_geometry_type(); uint32_t collision_mask = p_nav_mesh->get_collision_mask(); bool recurse_children = p_nav_mesh->get_source_geometry_mode() != NavigationMesh::SOURCE_GEOMETRY_GROUPS_EXPLICIT; - _parse_geometry(navmesh_xform, E->get(), vertices, indices, geometry_type, collision_mask, recurse_children); + _parse_geometry(navmesh_xform, E, vertices, indices, geometry_type, collision_mask, recurse_children); } if (vertices.size() > 0 && indices.size() > 0) { diff --git a/modules/opensimplex/doc_classes/OpenSimplexNoise.xml b/modules/opensimplex/doc_classes/OpenSimplexNoise.xml index 4d45e41cc3..c470f3e1ab 100644 --- a/modules/opensimplex/doc_classes/OpenSimplexNoise.xml +++ b/modules/opensimplex/doc_classes/OpenSimplexNoise.xml @@ -25,90 +25,66 @@ </tutorials> <methods> <method name="get_image" qualifiers="const"> - <return type="Image"> - </return> - <argument index="0" name="width" type="int"> - </argument> - <argument index="1" name="height" type="int"> - </argument> - <argument index="2" name="noise_offset" type="Vector2" default="Vector2(0, 0)"> - </argument> + <return type="Image" /> + <argument index="0" name="width" type="int" /> + <argument index="1" name="height" type="int" /> + <argument index="2" name="noise_offset" type="Vector2" default="Vector2(0, 0)" /> <description> Generate a noise image in [constant Image.FORMAT_L8] format with the requested [code]width[/code] and [code]height[/code], based on the current noise parameters. If [code]noise_offset[/code] is specified, then the offset value is used as the coordinates of the top-left corner of the generated noise. </description> </method> <method name="get_noise_1d" qualifiers="const"> - <return type="float"> - </return> - <argument index="0" name="x" type="float"> - </argument> + <return type="float" /> + <argument index="0" name="x" type="float" /> <description> Returns the 1D noise value [code][-1,1][/code] at the given x-coordinate. [b]Note:[/b] This method actually returns the 2D noise value [code][-1,1][/code] with fixed y-coordinate value 0.0. </description> </method> <method name="get_noise_2d" qualifiers="const"> - <return type="float"> - </return> - <argument index="0" name="x" type="float"> - </argument> - <argument index="1" name="y" type="float"> - </argument> + <return type="float" /> + <argument index="0" name="x" type="float" /> + <argument index="1" name="y" type="float" /> <description> Returns the 2D noise value [code][-1,1][/code] at the given position. </description> </method> <method name="get_noise_2dv" qualifiers="const"> - <return type="float"> - </return> - <argument index="0" name="pos" type="Vector2"> - </argument> + <return type="float" /> + <argument index="0" name="pos" type="Vector2" /> <description> Returns the 2D noise value [code][-1,1][/code] at the given position. </description> </method> <method name="get_noise_3d" qualifiers="const"> - <return type="float"> - </return> - <argument index="0" name="x" type="float"> - </argument> - <argument index="1" name="y" type="float"> - </argument> - <argument index="2" name="z" type="float"> - </argument> + <return type="float" /> + <argument index="0" name="x" type="float" /> + <argument index="1" name="y" type="float" /> + <argument index="2" name="z" type="float" /> <description> Returns the 3D noise value [code][-1,1][/code] at the given position. </description> </method> <method name="get_noise_3dv" qualifiers="const"> - <return type="float"> - </return> - <argument index="0" name="pos" type="Vector3"> - </argument> + <return type="float" /> + <argument index="0" name="pos" type="Vector3" /> <description> Returns the 3D noise value [code][-1,1][/code] at the given position. </description> </method> <method name="get_noise_4d" qualifiers="const"> - <return type="float"> - </return> - <argument index="0" name="x" type="float"> - </argument> - <argument index="1" name="y" type="float"> - </argument> - <argument index="2" name="z" type="float"> - </argument> - <argument index="3" name="w" type="float"> - </argument> + <return type="float" /> + <argument index="0" name="x" type="float" /> + <argument index="1" name="y" type="float" /> + <argument index="2" name="z" type="float" /> + <argument index="3" name="w" type="float" /> <description> Returns the 4D noise value [code][-1,1][/code] at the given position. </description> </method> <method name="get_seamless_image" qualifiers="const"> - <return type="Image"> - </return> - <argument index="0" name="size" type="int"> - </argument> + <return type="Image" /> + <argument index="0" name="size" type="int" /> <description> Generate a tileable noise image in [constant Image.FORMAT_L8] format, based on the current noise parameters. Generated seamless images are always square ([code]size[/code] × [code]size[/code]). [b]Note:[/b] Seamless noise has a lower contrast compared to non-seamless noise. This is due to the way noise uses higher dimensions for generating seamless noise. diff --git a/modules/opensimplex/noise_texture.cpp b/modules/opensimplex/noise_texture.cpp index 66c52ffbf9..9db3f3d5fd 100644 --- a/modules/opensimplex/noise_texture.cpp +++ b/modules/opensimplex/noise_texture.cpp @@ -109,7 +109,7 @@ void NoiseTexture::_thread_done(const Ref<Image> &p_image) { void NoiseTexture::_thread_function(void *p_ud) { NoiseTexture *tex = (NoiseTexture *)p_ud; - tex->call_deferred("_thread_done", tex->_generate_texture()); + tex->call_deferred(SNAME("_thread_done"), tex->_generate_texture()); } void NoiseTexture::_queue_update() { @@ -118,7 +118,7 @@ void NoiseTexture::_queue_update() { } update_queued = true; - call_deferred("_update_texture"); + call_deferred(SNAME("_update_texture")); } Ref<Image> NoiseTexture::_generate_texture() { diff --git a/modules/regex/doc_classes/RegEx.xml b/modules/regex/doc_classes/RegEx.xml index 7f5a0dfecb..9c84974ff6 100644 --- a/modules/regex/doc_classes/RegEx.xml +++ b/modules/regex/doc_classes/RegEx.xml @@ -50,88 +50,67 @@ </tutorials> <methods> <method name="clear"> - <return type="void"> - </return> + <return type="void" /> <description> This method resets the state of the object, as if it was freshly created. Namely, it unassigns the regular expression of this object. </description> </method> <method name="compile"> - <return type="int" enum="Error"> - </return> - <argument index="0" name="pattern" type="String"> - </argument> + <return type="int" enum="Error" /> + <argument index="0" name="pattern" type="String" /> <description> Compiles and assign the search pattern to use. Returns [constant OK] if the compilation is successful. If an error is encountered, details are printed to standard output and an error is returned. </description> </method> <method name="get_group_count" qualifiers="const"> - <return type="int"> - </return> + <return type="int" /> <description> Returns the number of capturing groups in compiled pattern. </description> </method> <method name="get_names" qualifiers="const"> - <return type="Array"> - </return> + <return type="Array" /> <description> Returns an array of names of named capturing groups in the compiled pattern. They are ordered by appearance. </description> </method> <method name="get_pattern" qualifiers="const"> - <return type="String"> - </return> + <return type="String" /> <description> Returns the original search pattern that was compiled. </description> </method> <method name="is_valid" qualifiers="const"> - <return type="bool"> - </return> + <return type="bool" /> <description> Returns whether this object has a valid search pattern assigned. </description> </method> <method name="search" qualifiers="const"> - <return type="RegExMatch"> - </return> - <argument index="0" name="subject" type="String"> - </argument> - <argument index="1" name="offset" type="int" default="0"> - </argument> - <argument index="2" name="end" type="int" default="-1"> - </argument> + <return type="RegExMatch" /> + <argument index="0" name="subject" type="String" /> + <argument index="1" name="offset" type="int" default="0" /> + <argument index="2" name="end" type="int" default="-1" /> <description> Searches the text for the compiled pattern. Returns a [RegExMatch] container of the first matching result if found, otherwise [code]null[/code]. The region to search within can be specified without modifying where the start and end anchor would be. </description> </method> <method name="search_all" qualifiers="const"> - <return type="Array"> - </return> - <argument index="0" name="subject" type="String"> - </argument> - <argument index="1" name="offset" type="int" default="0"> - </argument> - <argument index="2" name="end" type="int" default="-1"> - </argument> + <return type="Array" /> + <argument index="0" name="subject" type="String" /> + <argument index="1" name="offset" type="int" default="0" /> + <argument index="2" name="end" type="int" default="-1" /> <description> Searches the text for the compiled pattern. Returns an array of [RegExMatch] containers for each non-overlapping result. If no results were found, an empty array is returned instead. The region to search within can be specified without modifying where the start and end anchor would be. </description> </method> <method name="sub" qualifiers="const"> - <return type="String"> - </return> - <argument index="0" name="subject" type="String"> - </argument> - <argument index="1" name="replacement" type="String"> - </argument> - <argument index="2" name="all" type="bool" default="false"> - </argument> - <argument index="3" name="offset" type="int" default="0"> - </argument> - <argument index="4" name="end" type="int" default="-1"> - </argument> + <return type="String" /> + <argument index="0" name="subject" type="String" /> + <argument index="1" name="replacement" type="String" /> + <argument index="2" name="all" type="bool" default="false" /> + <argument index="3" name="offset" type="int" default="0" /> + <argument index="4" name="end" type="int" default="-1" /> <description> Searches the text for the compiled pattern and replaces it with the specified string. Escapes and backreferences such as [code]$1[/code] and [code]$name[/code] are expanded and resolved. By default, only the first instance is replaced, but it can be changed for all instances (global replacement). The region to search within can be specified without modifying where the start and end anchor would be. </description> diff --git a/modules/regex/doc_classes/RegExMatch.xml b/modules/regex/doc_classes/RegExMatch.xml index 492519d3d9..3cde2836cc 100644 --- a/modules/regex/doc_classes/RegExMatch.xml +++ b/modules/regex/doc_classes/RegExMatch.xml @@ -10,37 +10,30 @@ </tutorials> <methods> <method name="get_end" qualifiers="const"> - <return type="int"> - </return> - <argument index="0" name="name" type="Variant" default="0"> - </argument> + <return type="int" /> + <argument index="0" name="name" type="Variant" default="0" /> <description> Returns the end position of the match within the source string. The end position of capturing groups can be retrieved by providing its group number as an integer or its string name (if it's a named group). The default value of 0 refers to the whole pattern. Returns -1 if the group did not match or doesn't exist. </description> </method> <method name="get_group_count" qualifiers="const"> - <return type="int"> - </return> + <return type="int" /> <description> Returns the number of capturing groups. </description> </method> <method name="get_start" qualifiers="const"> - <return type="int"> - </return> - <argument index="0" name="name" type="Variant" default="0"> - </argument> + <return type="int" /> + <argument index="0" name="name" type="Variant" default="0" /> <description> Returns the starting position of the match within the source string. The starting position of capturing groups can be retrieved by providing its group number as an integer or its string name (if it's a named group). The default value of 0 refers to the whole pattern. Returns -1 if the group did not match or doesn't exist. </description> </method> <method name="get_string" qualifiers="const"> - <return type="String"> - </return> - <argument index="0" name="name" type="Variant" default="0"> - </argument> + <return type="String" /> + <argument index="0" name="name" type="Variant" default="0" /> <description> Returns the substring of the match from the source string. Capturing groups can be retrieved by providing its group number as an integer or its string name (if it's a named group). The default value of 0 refers to the whole pattern. Returns an empty string if the group did not match or doesn't exist. diff --git a/modules/text_server_adv/dynamic_font_adv.h b/modules/text_server_adv/dynamic_font_adv.h index 1292966f0c..b3f97bb029 100644 --- a/modules/text_server_adv/dynamic_font_adv.h +++ b/modules/text_server_adv/dynamic_font_adv.h @@ -34,7 +34,6 @@ #include "font_adv.h" #include "modules/modules_enabled.gen.h" - #ifdef MODULE_FREETYPE_ENABLED #include <ft2build.h> diff --git a/modules/text_server_adv/text_server_adv.cpp b/modules/text_server_adv/text_server_adv.cpp index 72c5ccc699..fa4888f843 100644 --- a/modules/text_server_adv/text_server_adv.cpp +++ b/modules/text_server_adv/text_server_adv.cpp @@ -129,6 +129,10 @@ _FORCE_INLINE_ bool is_linebreak(char32_t p_char) { return (p_char >= 0x000a && p_char <= 0x000d) || (p_char == 0x0085) || (p_char == 0x2028) || (p_char == 0x2029); } +_FORCE_INLINE_ bool is_underscore(char32_t p_char) { + return (p_char == 0x005F); +} + /*************************************************************************/ String TextServerAdvanced::interface_name = "ICU / HarfBuzz / Graphite"; @@ -923,14 +927,14 @@ void TextServerAdvanced::font_set_oversampling(float p_oversampling) { oversampling = p_oversampling; List<RID> fonts; font_owner.get_owned_list(&fonts); - for (List<RID>::Element *E = fonts.front(); E; E = E->next()) { - font_owner.getornull(E->get())->clear_cache(); + for (const RID &E : fonts) { + font_owner.getornull(E)->clear_cache(); } List<RID> text_bufs; shaped_owner.get_owned_list(&text_bufs); - for (List<RID>::Element *E = text_bufs.front(); E; E = E->next()) { - invalidate(shaped_owner.getornull(E->get())); + for (const RID &E : text_bufs) { + invalidate(shaped_owner.getornull(E)); } } } @@ -1883,7 +1887,10 @@ bool TextServerAdvanced::shaped_text_update_breaks(RID p_shaped) { if (is_whitespace(c)) { sd_glyphs[i].flags |= GRAPHEME_IS_SPACE; } - if (u_ispunct(c)) { + if (is_underscore(c)) { + sd_glyphs[i].flags |= GRAPHEME_IS_UNDERSCORE; + } + if (u_ispunct(c) && c != 0x005F) { sd_glyphs[i].flags |= GRAPHEME_IS_PUNCTUATION; } if (breaks.has(sd->glyphs[i].start)) { diff --git a/modules/text_server_fb/dynamic_font_fb.h b/modules/text_server_fb/dynamic_font_fb.h index b34c8cbed5..82e59fa607 100644 --- a/modules/text_server_fb/dynamic_font_fb.h +++ b/modules/text_server_fb/dynamic_font_fb.h @@ -34,7 +34,6 @@ #include "font_fb.h" #include "modules/modules_enabled.gen.h" - #ifdef MODULE_FREETYPE_ENABLED #include <ft2build.h> diff --git a/modules/text_server_fb/text_server_fb.cpp b/modules/text_server_fb/text_server_fb.cpp index 576d130cc0..004cbc2bb3 100644 --- a/modules/text_server_fb/text_server_fb.cpp +++ b/modules/text_server_fb/text_server_fb.cpp @@ -46,7 +46,11 @@ _FORCE_INLINE_ bool is_linebreak(char32_t p_char) { } _FORCE_INLINE_ bool is_punct(char32_t p_char) { - return (p_char >= 0x0020 && p_char <= 0x002F) || (p_char >= 0x003A && p_char <= 0x0040) || (p_char >= 0x005B && p_char <= 0x0060) || (p_char >= 0x007B && p_char <= 0x007E) || (p_char >= 0x2000 && p_char <= 0x206F) || (p_char >= 0x3000 && p_char <= 0x303F); + return (p_char >= 0x0020 && p_char <= 0x002F) || (p_char >= 0x003A && p_char <= 0x0040) || (p_char >= 0x005B && p_char <= 0x005E) || (p_char == 0x0060) || (p_char >= 0x007B && p_char <= 0x007E) || (p_char >= 0x2000 && p_char <= 0x206F) || (p_char >= 0x3000 && p_char <= 0x303F); +} + +_FORCE_INLINE_ bool is_underscore(char32_t p_char) { + return (p_char == 0x005F); } /*************************************************************************/ @@ -469,8 +473,8 @@ void TextServerFallback::font_set_oversampling(float p_oversampling) { oversampling = p_oversampling; List<RID> fonts; font_owner.get_owned_list(&fonts); - for (List<RID>::Element *E = fonts.front(); E; E = E->next()) { - font_owner.getornull(E->get())->clear_cache(); + for (const RID &E : fonts) { + font_owner.getornull(E)->clear_cache(); } } } @@ -1108,6 +1112,9 @@ bool TextServerFallback::shaped_text_update_breaks(RID p_shaped) { if (is_punct(c)) { sd->glyphs.write[i].flags |= GRAPHEME_IS_PUNCTUATION; } + if (is_underscore(c)) { + sd->glyphs.write[i].flags |= GRAPHEME_IS_UNDERSCORE; + } if (is_whitespace(c) && !is_linebreak(c)) { sd->glyphs.write[i].flags |= GRAPHEME_IS_SPACE; sd->glyphs.write[i].flags |= GRAPHEME_IS_BREAK_SOFT; diff --git a/modules/theora/doc_classes/VideoStreamTheora.xml b/modules/theora/doc_classes/VideoStreamTheora.xml index cb8852d5ef..e7bf9b202d 100644 --- a/modules/theora/doc_classes/VideoStreamTheora.xml +++ b/modules/theora/doc_classes/VideoStreamTheora.xml @@ -11,17 +11,14 @@ </tutorials> <methods> <method name="get_file"> - <return type="String"> - </return> + <return type="String" /> <description> Returns the Ogg Theora video file handled by this [VideoStreamTheora]. </description> </method> <method name="set_file"> - <return type="void"> - </return> - <argument index="0" name="file" type="String"> - </argument> + <return type="void" /> + <argument index="0" name="file" type="String" /> <description> Sets the Ogg Theora video file that this [VideoStreamTheora] resource handles. The [code]file[/code] name should have the [code].ogv[/code] extension. </description> diff --git a/modules/upnp/doc_classes/UPNP.xml b/modules/upnp/doc_classes/UPNP.xml index 09a2c8a88c..5b1d9dbfd1 100644 --- a/modules/upnp/doc_classes/UPNP.xml +++ b/modules/upnp/doc_classes/UPNP.xml @@ -21,27 +21,19 @@ </tutorials> <methods> <method name="add_device"> - <return type="void"> - </return> - <argument index="0" name="device" type="UPNPDevice"> - </argument> + <return type="void" /> + <argument index="0" name="device" type="UPNPDevice" /> <description> Adds the given [UPNPDevice] to the list of discovered devices. </description> </method> <method name="add_port_mapping" qualifiers="const"> - <return type="int"> - </return> - <argument index="0" name="port" type="int"> - </argument> - <argument index="1" name="port_internal" type="int" default="0"> - </argument> - <argument index="2" name="desc" type="String" default=""""> - </argument> - <argument index="3" name="proto" type="String" default=""UDP""> - </argument> - <argument index="4" name="duration" type="int" default="0"> - </argument> + <return type="int" /> + <argument index="0" name="port" type="int" /> + <argument index="1" name="port_internal" type="int" default="0" /> + <argument index="2" name="desc" type="String" default="""" /> + <argument index="3" name="proto" type="String" default=""UDP"" /> + <argument index="4" name="duration" type="int" default="0" /> <description> Adds a mapping to forward the external [code]port[/code] (between 1 and 65535) on the default gateway (see [method get_gateway]) to the [code]internal_port[/code] on the local machine for the given protocol [code]proto[/code] (either [code]TCP[/code] or [code]UDP[/code], with UDP being the default). If a port mapping for the given port and protocol combination already exists on that gateway device, this method tries to overwrite it. If that is not desired, you can retrieve the gateway manually with [method get_gateway] and call [method add_port_mapping] on it, if any. If [code]internal_port[/code] is [code]0[/code] (the default), the same port number is used for both the external and the internal port (the [code]port[/code] value). @@ -50,32 +42,24 @@ </description> </method> <method name="clear_devices"> - <return type="void"> - </return> + <return type="void" /> <description> Clears the list of discovered devices. </description> </method> <method name="delete_port_mapping" qualifiers="const"> - <return type="int"> - </return> - <argument index="0" name="port" type="int"> - </argument> - <argument index="1" name="proto" type="String" default=""UDP""> - </argument> + <return type="int" /> + <argument index="0" name="port" type="int" /> + <argument index="1" name="proto" type="String" default=""UDP"" /> <description> Deletes the port mapping for the given port and protocol combination on the default gateway (see [method get_gateway]) if one exists. [code]port[/code] must be a valid port between 1 and 65535, [code]proto[/code] can be either [code]TCP[/code] or [code]UDP[/code]. See [enum UPNPResult] for possible return values. </description> </method> <method name="discover"> - <return type="int"> - </return> - <argument index="0" name="timeout" type="int" default="2000"> - </argument> - <argument index="1" name="ttl" type="int" default="2"> - </argument> - <argument index="2" name="device_filter" type="String" default=""InternetGatewayDevice""> - </argument> + <return type="int" /> + <argument index="0" name="timeout" type="int" default="2000" /> + <argument index="1" name="ttl" type="int" default="2" /> + <argument index="2" name="device_filter" type="String" default=""InternetGatewayDevice"" /> <description> Discovers local [UPNPDevice]s. Clears the list of previously discovered devices. Filters for IGD (InternetGatewayDevice) type devices by default, as those manage port forwarding. [code]timeout[/code] is the time to wait for responses in milliseconds. [code]ttl[/code] is the time-to-live; only touch this if you know what you're doing. @@ -83,51 +67,41 @@ </description> </method> <method name="get_device" qualifiers="const"> - <return type="UPNPDevice"> - </return> - <argument index="0" name="index" type="int"> - </argument> + <return type="UPNPDevice" /> + <argument index="0" name="index" type="int" /> <description> Returns the [UPNPDevice] at the given [code]index[/code]. </description> </method> <method name="get_device_count" qualifiers="const"> - <return type="int"> - </return> + <return type="int" /> <description> Returns the number of discovered [UPNPDevice]s. </description> </method> <method name="get_gateway" qualifiers="const"> - <return type="UPNPDevice"> - </return> + <return type="UPNPDevice" /> <description> Returns the default gateway. That is the first discovered [UPNPDevice] that is also a valid IGD (InternetGatewayDevice). </description> </method> <method name="query_external_address" qualifiers="const"> - <return type="String"> - </return> + <return type="String" /> <description> Returns the external [IP] address of the default gateway (see [method get_gateway]) as string. Returns an empty string on error. </description> </method> <method name="remove_device"> - <return type="void"> - </return> - <argument index="0" name="index" type="int"> - </argument> + <return type="void" /> + <argument index="0" name="index" type="int" /> <description> Removes the device at [code]index[/code] from the list of discovered devices. </description> </method> <method name="set_device"> - <return type="void"> - </return> - <argument index="0" name="index" type="int"> - </argument> - <argument index="1" name="device" type="UPNPDevice"> - </argument> + <return type="void" /> + <argument index="0" name="index" type="int" /> + <argument index="1" name="device" type="UPNPDevice" /> <description> Sets the device at [code]index[/code] from the list of discovered devices to [code]device[/code]. </description> diff --git a/modules/upnp/doc_classes/UPNPDevice.xml b/modules/upnp/doc_classes/UPNPDevice.xml index f7b5386d86..b7c2ff7dd7 100644 --- a/modules/upnp/doc_classes/UPNPDevice.xml +++ b/modules/upnp/doc_classes/UPNPDevice.xml @@ -10,43 +10,32 @@ </tutorials> <methods> <method name="add_port_mapping" qualifiers="const"> - <return type="int"> - </return> - <argument index="0" name="port" type="int"> - </argument> - <argument index="1" name="port_internal" type="int" default="0"> - </argument> - <argument index="2" name="desc" type="String" default=""""> - </argument> - <argument index="3" name="proto" type="String" default=""UDP""> - </argument> - <argument index="4" name="duration" type="int" default="0"> - </argument> + <return type="int" /> + <argument index="0" name="port" type="int" /> + <argument index="1" name="port_internal" type="int" default="0" /> + <argument index="2" name="desc" type="String" default="""" /> + <argument index="3" name="proto" type="String" default=""UDP"" /> + <argument index="4" name="duration" type="int" default="0" /> <description> Adds a port mapping to forward the given external port on this [UPNPDevice] for the given protocol to the local machine. See [method UPNP.add_port_mapping]. </description> </method> <method name="delete_port_mapping" qualifiers="const"> - <return type="int"> - </return> - <argument index="0" name="port" type="int"> - </argument> - <argument index="1" name="proto" type="String" default=""UDP""> - </argument> + <return type="int" /> + <argument index="0" name="port" type="int" /> + <argument index="1" name="proto" type="String" default=""UDP"" /> <description> Deletes the port mapping identified by the given port and protocol combination on this device. See [method UPNP.delete_port_mapping]. </description> </method> <method name="is_valid_gateway" qualifiers="const"> - <return type="bool"> - </return> + <return type="bool" /> <description> Returns [code]true[/code] if this is a valid IGD (InternetGatewayDevice) which potentially supports port forwarding. </description> </method> <method name="query_external_address" qualifiers="const"> - <return type="String"> - </return> + <return type="String" /> <description> Returns the external IP address of this [UPNPDevice] or an empty string. </description> diff --git a/modules/visual_script/doc_classes/VisualScript.xml b/modules/visual_script/doc_classes/VisualScript.xml index 9d51bd86a2..2327fc0009 100644 --- a/modules/visual_script/doc_classes/VisualScript.xml +++ b/modules/visual_script/doc_classes/VisualScript.xml @@ -13,456 +13,334 @@ </tutorials> <methods> <method name="add_custom_signal"> - <return type="void"> - </return> - <argument index="0" name="name" type="StringName"> - </argument> + <return type="void" /> + <argument index="0" name="name" type="StringName" /> <description> Add a custom signal with the specified name to the VisualScript. </description> </method> <method name="add_function"> - <return type="void"> - </return> - <argument index="0" name="name" type="StringName"> - </argument> - <argument index="1" name="func_node_id" type="int"> - </argument> + <return type="void" /> + <argument index="0" name="name" type="StringName" /> + <argument index="1" name="func_node_id" type="int" /> <description> Add a function with the specified name to the VisualScript, and assign the root [VisualScriptFunction] node's id as [code]func_node_id[/code]. </description> </method> <method name="add_node"> - <return type="void"> - </return> - <argument index="0" name="id" type="int"> - </argument> - <argument index="1" name="node" type="VisualScriptNode"> - </argument> - <argument index="2" name="position" type="Vector2" default="Vector2(0, 0)"> - </argument> + <return type="void" /> + <argument index="0" name="id" type="int" /> + <argument index="1" name="node" type="VisualScriptNode" /> + <argument index="2" name="position" type="Vector2" default="Vector2(0, 0)" /> <description> Add a node to the VisualScript. </description> </method> <method name="add_variable"> - <return type="void"> - </return> - <argument index="0" name="name" type="StringName"> - </argument> - <argument index="1" name="default_value" type="Variant" default="null"> - </argument> - <argument index="2" name="export" type="bool" default="false"> - </argument> + <return type="void" /> + <argument index="0" name="name" type="StringName" /> + <argument index="1" name="default_value" type="Variant" default="null" /> + <argument index="2" name="export" type="bool" default="false" /> <description> Add a variable to the VisualScript, optionally giving it a default value or marking it as exported. </description> </method> <method name="custom_signal_add_argument"> - <return type="void"> - </return> - <argument index="0" name="name" type="StringName"> - </argument> - <argument index="1" name="type" type="int" enum="Variant.Type"> - </argument> - <argument index="2" name="argname" type="String"> - </argument> - <argument index="3" name="index" type="int" default="-1"> - </argument> + <return type="void" /> + <argument index="0" name="name" type="StringName" /> + <argument index="1" name="type" type="int" enum="Variant.Type" /> + <argument index="2" name="argname" type="String" /> + <argument index="3" name="index" type="int" default="-1" /> <description> Add an argument to a custom signal added with [method add_custom_signal]. </description> </method> <method name="custom_signal_get_argument_count" qualifiers="const"> - <return type="int"> - </return> - <argument index="0" name="name" type="StringName"> - </argument> + <return type="int" /> + <argument index="0" name="name" type="StringName" /> <description> Get the count of a custom signal's arguments. </description> </method> <method name="custom_signal_get_argument_name" qualifiers="const"> - <return type="String"> - </return> - <argument index="0" name="name" type="StringName"> - </argument> - <argument index="1" name="argidx" type="int"> - </argument> + <return type="String" /> + <argument index="0" name="name" type="StringName" /> + <argument index="1" name="argidx" type="int" /> <description> Get the name of a custom signal's argument. </description> </method> <method name="custom_signal_get_argument_type" qualifiers="const"> - <return type="int" enum="Variant.Type"> - </return> - <argument index="0" name="name" type="StringName"> - </argument> - <argument index="1" name="argidx" type="int"> - </argument> + <return type="int" enum="Variant.Type" /> + <argument index="0" name="name" type="StringName" /> + <argument index="1" name="argidx" type="int" /> <description> Get the type of a custom signal's argument. </description> </method> <method name="custom_signal_remove_argument"> - <return type="void"> - </return> - <argument index="0" name="name" type="StringName"> - </argument> - <argument index="1" name="argidx" type="int"> - </argument> + <return type="void" /> + <argument index="0" name="name" type="StringName" /> + <argument index="1" name="argidx" type="int" /> <description> Remove a specific custom signal's argument. </description> </method> <method name="custom_signal_set_argument_name"> - <return type="void"> - </return> - <argument index="0" name="name" type="StringName"> - </argument> - <argument index="1" name="argidx" type="int"> - </argument> - <argument index="2" name="argname" type="String"> - </argument> + <return type="void" /> + <argument index="0" name="name" type="StringName" /> + <argument index="1" name="argidx" type="int" /> + <argument index="2" name="argname" type="String" /> <description> Rename a custom signal's argument. </description> </method> <method name="custom_signal_set_argument_type"> - <return type="void"> - </return> - <argument index="0" name="name" type="StringName"> - </argument> - <argument index="1" name="argidx" type="int"> - </argument> - <argument index="2" name="type" type="int" enum="Variant.Type"> - </argument> + <return type="void" /> + <argument index="0" name="name" type="StringName" /> + <argument index="1" name="argidx" type="int" /> + <argument index="2" name="type" type="int" enum="Variant.Type" /> <description> Change the type of a custom signal's argument. </description> </method> <method name="custom_signal_swap_argument"> - <return type="void"> - </return> - <argument index="0" name="name" type="StringName"> - </argument> - <argument index="1" name="argidx" type="int"> - </argument> - <argument index="2" name="withidx" type="int"> - </argument> + <return type="void" /> + <argument index="0" name="name" type="StringName" /> + <argument index="1" name="argidx" type="int" /> + <argument index="2" name="withidx" type="int" /> <description> Swap two of the arguments of a custom signal. </description> </method> <method name="data_connect"> - <return type="void"> - </return> - <argument index="0" name="from_node" type="int"> - </argument> - <argument index="1" name="from_port" type="int"> - </argument> - <argument index="2" name="to_node" type="int"> - </argument> - <argument index="3" name="to_port" type="int"> - </argument> + <return type="void" /> + <argument index="0" name="from_node" type="int" /> + <argument index="1" name="from_port" type="int" /> + <argument index="2" name="to_node" type="int" /> + <argument index="3" name="to_port" type="int" /> <description> Connect two data ports. The value of [code]from_node[/code]'s [code]from_port[/code] would be fed into [code]to_node[/code]'s [code]to_port[/code]. </description> </method> <method name="data_disconnect"> - <return type="void"> - </return> - <argument index="0" name="from_node" type="int"> - </argument> - <argument index="1" name="from_port" type="int"> - </argument> - <argument index="2" name="to_node" type="int"> - </argument> - <argument index="3" name="to_port" type="int"> - </argument> + <return type="void" /> + <argument index="0" name="from_node" type="int" /> + <argument index="1" name="from_port" type="int" /> + <argument index="2" name="to_node" type="int" /> + <argument index="3" name="to_port" type="int" /> <description> Disconnect two data ports previously connected with [method data_connect]. </description> </method> <method name="get_function_node_id" qualifiers="const"> - <return type="int"> - </return> - <argument index="0" name="name" type="StringName"> - </argument> + <return type="int" /> + <argument index="0" name="name" type="StringName" /> <description> Returns the id of a function's entry point node. </description> </method> <method name="get_node" qualifiers="const"> - <return type="VisualScriptNode"> - </return> - <argument index="0" name="id" type="int"> - </argument> + <return type="VisualScriptNode" /> + <argument index="0" name="id" type="int" /> <description> Returns a node given its id. </description> </method> <method name="get_node_position" qualifiers="const"> - <return type="Vector2"> - </return> - <argument index="0" name="id" type="int"> - </argument> + <return type="Vector2" /> + <argument index="0" name="id" type="int" /> <description> Returns a node's position in pixels. </description> </method> <method name="get_scroll" qualifiers="const"> - <return type="Vector2"> - </return> + <return type="Vector2" /> <description> Returns the current position of the center of the screen. </description> </method> <method name="get_variable_default_value" qualifiers="const"> - <return type="Variant"> - </return> - <argument index="0" name="name" type="StringName"> - </argument> + <return type="Variant" /> + <argument index="0" name="name" type="StringName" /> <description> Returns the default (initial) value of a variable. </description> </method> <method name="get_variable_export" qualifiers="const"> - <return type="bool"> - </return> - <argument index="0" name="name" type="StringName"> - </argument> + <return type="bool" /> + <argument index="0" name="name" type="StringName" /> <description> Returns whether a variable is exported. </description> </method> <method name="get_variable_info" qualifiers="const"> - <return type="Dictionary"> - </return> - <argument index="0" name="name" type="StringName"> - </argument> + <return type="Dictionary" /> + <argument index="0" name="name" type="StringName" /> <description> Returns the information for a given variable as a dictionary. The information includes its name, type, hint and usage. </description> </method> <method name="has_custom_signal" qualifiers="const"> - <return type="bool"> - </return> - <argument index="0" name="name" type="StringName"> - </argument> + <return type="bool" /> + <argument index="0" name="name" type="StringName" /> <description> Returns whether a signal exists with the specified name. </description> </method> <method name="has_data_connection" qualifiers="const"> - <return type="bool"> - </return> - <argument index="0" name="from_node" type="int"> - </argument> - <argument index="1" name="from_port" type="int"> - </argument> - <argument index="2" name="to_node" type="int"> - </argument> - <argument index="3" name="to_port" type="int"> - </argument> + <return type="bool" /> + <argument index="0" name="from_node" type="int" /> + <argument index="1" name="from_port" type="int" /> + <argument index="2" name="to_node" type="int" /> + <argument index="3" name="to_port" type="int" /> <description> Returns whether the specified data ports are connected. </description> </method> <method name="has_function" qualifiers="const"> - <return type="bool"> - </return> - <argument index="0" name="name" type="StringName"> - </argument> + <return type="bool" /> + <argument index="0" name="name" type="StringName" /> <description> Returns whether a function exists with the specified name. </description> </method> <method name="has_node" qualifiers="const"> - <return type="bool"> - </return> - <argument index="0" name="id" type="int"> - </argument> + <return type="bool" /> + <argument index="0" name="id" type="int" /> <description> Returns whether a node exists with the given id. </description> </method> <method name="has_sequence_connection" qualifiers="const"> - <return type="bool"> - </return> - <argument index="0" name="from_node" type="int"> - </argument> - <argument index="1" name="from_output" type="int"> - </argument> - <argument index="2" name="to_node" type="int"> - </argument> + <return type="bool" /> + <argument index="0" name="from_node" type="int" /> + <argument index="1" name="from_output" type="int" /> + <argument index="2" name="to_node" type="int" /> <description> Returns whether the specified sequence ports are connected. </description> </method> <method name="has_variable" qualifiers="const"> - <return type="bool"> - </return> - <argument index="0" name="name" type="StringName"> - </argument> + <return type="bool" /> + <argument index="0" name="name" type="StringName" /> <description> Returns whether a variable exists with the specified name. </description> </method> <method name="remove_custom_signal"> - <return type="void"> - </return> - <argument index="0" name="name" type="StringName"> - </argument> + <return type="void" /> + <argument index="0" name="name" type="StringName" /> <description> Remove a custom signal with the given name. </description> </method> <method name="remove_function"> - <return type="void"> - </return> - <argument index="0" name="name" type="StringName"> - </argument> + <return type="void" /> + <argument index="0" name="name" type="StringName" /> <description> Remove a specific function and its nodes from the script. </description> </method> <method name="remove_node"> - <return type="void"> - </return> - <argument index="0" name="id" type="int"> - </argument> + <return type="void" /> + <argument index="0" name="id" type="int" /> <description> Remove the node with the specified id. </description> </method> <method name="remove_variable"> - <return type="void"> - </return> - <argument index="0" name="name" type="StringName"> - </argument> + <return type="void" /> + <argument index="0" name="name" type="StringName" /> <description> Remove a variable with the given name. </description> </method> <method name="rename_custom_signal"> - <return type="void"> - </return> - <argument index="0" name="name" type="StringName"> - </argument> - <argument index="1" name="new_name" type="StringName"> - </argument> + <return type="void" /> + <argument index="0" name="name" type="StringName" /> + <argument index="1" name="new_name" type="StringName" /> <description> Change the name of a custom signal. </description> </method> <method name="rename_function"> - <return type="void"> - </return> - <argument index="0" name="name" type="StringName"> - </argument> - <argument index="1" name="new_name" type="StringName"> - </argument> + <return type="void" /> + <argument index="0" name="name" type="StringName" /> + <argument index="1" name="new_name" type="StringName" /> <description> Change the name of a function. </description> </method> <method name="rename_variable"> - <return type="void"> - </return> - <argument index="0" name="name" type="StringName"> - </argument> - <argument index="1" name="new_name" type="StringName"> - </argument> + <return type="void" /> + <argument index="0" name="name" type="StringName" /> + <argument index="1" name="new_name" type="StringName" /> <description> Change the name of a variable. </description> </method> <method name="sequence_connect"> - <return type="void"> - </return> - <argument index="0" name="from_node" type="int"> - </argument> - <argument index="1" name="from_output" type="int"> - </argument> - <argument index="2" name="to_node" type="int"> - </argument> + <return type="void" /> + <argument index="0" name="from_node" type="int" /> + <argument index="1" name="from_output" type="int" /> + <argument index="2" name="to_node" type="int" /> <description> Connect two sequence ports. The execution will flow from of [code]from_node[/code]'s [code]from_output[/code] into [code]to_node[/code]. Unlike [method data_connect], there isn't a [code]to_port[/code], since the target node can have only one sequence port. </description> </method> <method name="sequence_disconnect"> - <return type="void"> - </return> - <argument index="0" name="from_node" type="int"> - </argument> - <argument index="1" name="from_output" type="int"> - </argument> - <argument index="2" name="to_node" type="int"> - </argument> + <return type="void" /> + <argument index="0" name="from_node" type="int" /> + <argument index="1" name="from_output" type="int" /> + <argument index="2" name="to_node" type="int" /> <description> Disconnect two sequence ports previously connected with [method sequence_connect]. </description> </method> <method name="set_instance_base_type"> - <return type="void"> - </return> - <argument index="0" name="type" type="StringName"> - </argument> + <return type="void" /> + <argument index="0" name="type" type="StringName" /> <description> Set the base type of the script. </description> </method> <method name="set_node_position"> - <return type="void"> - </return> - <argument index="0" name="id" type="int"> - </argument> - <argument index="1" name="position" type="Vector2"> - </argument> + <return type="void" /> + <argument index="0" name="id" type="int" /> + <argument index="1" name="position" type="Vector2" /> <description> Set the node position in the VisualScript graph. </description> </method> <method name="set_scroll"> - <return type="void"> - </return> - <argument index="0" name="ofs" type="Vector2"> - </argument> + <return type="void" /> + <argument index="0" name="ofs" type="Vector2" /> <description> Set the screen center to the given position. </description> </method> <method name="set_variable_default_value"> - <return type="void"> - </return> - <argument index="0" name="name" type="StringName"> - </argument> - <argument index="1" name="value" type="Variant"> - </argument> + <return type="void" /> + <argument index="0" name="name" type="StringName" /> + <argument index="1" name="value" type="Variant" /> <description> Change the default (initial) value of a variable. </description> </method> <method name="set_variable_export"> - <return type="void"> - </return> - <argument index="0" name="name" type="StringName"> - </argument> - <argument index="1" name="enable" type="bool"> - </argument> + <return type="void" /> + <argument index="0" name="name" type="StringName" /> + <argument index="1" name="enable" type="bool" /> <description> Change whether a variable is exported. </description> </method> <method name="set_variable_info"> - <return type="void"> - </return> - <argument index="0" name="name" type="StringName"> - </argument> - <argument index="1" name="value" type="Dictionary"> - </argument> + <return type="void" /> + <argument index="0" name="name" type="StringName" /> + <argument index="1" name="value" type="Dictionary" /> <description> Set a variable's info, using the same format as [method get_variable_info]. </description> @@ -470,8 +348,7 @@ </methods> <signals> <signal name="node_ports_changed"> - <argument index="0" name="id" type="int"> - </argument> + <argument index="0" name="id" type="int" /> <description> Emitted when the ports of a node are changed. </description> diff --git a/modules/visual_script/doc_classes/VisualScriptBuiltinFunc.xml b/modules/visual_script/doc_classes/VisualScriptBuiltinFunc.xml index 219ffd01d3..195d766c1d 100644 --- a/modules/visual_script/doc_classes/VisualScriptBuiltinFunc.xml +++ b/modules/visual_script/doc_classes/VisualScriptBuiltinFunc.xml @@ -105,117 +105,114 @@ <constant name="MATH_MOVE_TOWARD" value="29" enum="BuiltinFunc"> Moves the number toward a value, based on the third input. </constant> - <constant name="MATH_DECTIME" value="30" enum="BuiltinFunc"> - Return the result of [code]value[/code] decreased by [code]step[/code] * [code]amount[/code]. - </constant> - <constant name="MATH_RANDOMIZE" value="31" enum="BuiltinFunc"> + <constant name="MATH_RANDOMIZE" value="30" enum="BuiltinFunc"> Randomize the seed (or the internal state) of the random number generator. Current implementation reseeds using a number based on time. </constant> - <constant name="MATH_RANDI" value="32" enum="BuiltinFunc"> + <constant name="MATH_RANDI" value="31" enum="BuiltinFunc"> Return a random 32 bits integer value. To obtain a random value between 0 to N (where N is smaller than 2^32 - 1), you can use it with the remainder function. </constant> - <constant name="MATH_RANDF" value="33" enum="BuiltinFunc"> + <constant name="MATH_RANDF" value="32" enum="BuiltinFunc"> Return a random floating-point value between 0 and 1. To obtain a random value between 0 to N, you can use it with multiplication. </constant> - <constant name="MATH_RANDF_RANGE" value="34" enum="BuiltinFunc"> + <constant name="MATH_RANDF_RANGE" value="33" enum="BuiltinFunc"> Return a random floating-point value between the two inputs. </constant> - <constant name="MATH_RANDI_RANGE" value="35" enum="BuiltinFunc"> + <constant name="MATH_RANDI_RANGE" value="34" enum="BuiltinFunc"> Return a random 32-bit integer value between the two inputs. </constant> - <constant name="MATH_SEED" value="36" enum="BuiltinFunc"> + <constant name="MATH_SEED" value="35" enum="BuiltinFunc"> Set the seed for the random number generator. </constant> - <constant name="MATH_RANDSEED" value="37" enum="BuiltinFunc"> + <constant name="MATH_RANDSEED" value="36" enum="BuiltinFunc"> Return a random value from the given seed, along with the new seed. </constant> - <constant name="MATH_DEG2RAD" value="38" enum="BuiltinFunc"> + <constant name="MATH_DEG2RAD" value="37" enum="BuiltinFunc"> Convert the input from degrees to radians. </constant> - <constant name="MATH_RAD2DEG" value="39" enum="BuiltinFunc"> + <constant name="MATH_RAD2DEG" value="38" enum="BuiltinFunc"> Convert the input from radians to degrees. </constant> - <constant name="MATH_LINEAR2DB" value="40" enum="BuiltinFunc"> + <constant name="MATH_LINEAR2DB" value="39" enum="BuiltinFunc"> Convert the input from linear volume to decibel volume. </constant> - <constant name="MATH_DB2LINEAR" value="41" enum="BuiltinFunc"> + <constant name="MATH_DB2LINEAR" value="40" enum="BuiltinFunc"> Convert the input from decibel volume to linear volume. </constant> - <constant name="MATH_POLAR2CARTESIAN" value="42" enum="BuiltinFunc"> + <constant name="MATH_POLAR2CARTESIAN" value="41" enum="BuiltinFunc"> Converts a 2D point expressed in the polar coordinate system (a distance from the origin [code]r[/code] and an angle [code]th[/code]) to the cartesian coordinate system (X and Y axis). </constant> - <constant name="MATH_CARTESIAN2POLAR" value="43" enum="BuiltinFunc"> + <constant name="MATH_CARTESIAN2POLAR" value="42" enum="BuiltinFunc"> Converts a 2D point expressed in the cartesian coordinate system (X and Y axis) to the polar coordinate system (a distance from the origin and an angle). </constant> - <constant name="MATH_WRAP" value="44" enum="BuiltinFunc"> + <constant name="MATH_WRAP" value="43" enum="BuiltinFunc"> </constant> - <constant name="MATH_WRAPF" value="45" enum="BuiltinFunc"> + <constant name="MATH_WRAPF" value="44" enum="BuiltinFunc"> </constant> - <constant name="LOGIC_MAX" value="46" enum="BuiltinFunc"> + <constant name="LOGIC_MAX" value="45" enum="BuiltinFunc"> Return the greater of the two numbers, also known as their maximum. </constant> - <constant name="LOGIC_MIN" value="47" enum="BuiltinFunc"> + <constant name="LOGIC_MIN" value="46" enum="BuiltinFunc"> Return the lesser of the two numbers, also known as their minimum. </constant> - <constant name="LOGIC_CLAMP" value="48" enum="BuiltinFunc"> + <constant name="LOGIC_CLAMP" value="47" enum="BuiltinFunc"> Return the input clamped inside the given range, ensuring the result is never outside it. Equivalent to [code]min(max(input, range_low), range_high)[/code]. </constant> - <constant name="LOGIC_NEAREST_PO2" value="49" enum="BuiltinFunc"> + <constant name="LOGIC_NEAREST_PO2" value="48" enum="BuiltinFunc"> Return the nearest power of 2 to the input. </constant> - <constant name="OBJ_WEAKREF" value="50" enum="BuiltinFunc"> + <constant name="OBJ_WEAKREF" value="49" enum="BuiltinFunc"> Create a [WeakRef] from the input. </constant> - <constant name="TYPE_CONVERT" value="51" enum="BuiltinFunc"> + <constant name="TYPE_CONVERT" value="50" enum="BuiltinFunc"> Convert between types. </constant> - <constant name="TYPE_OF" value="52" enum="BuiltinFunc"> + <constant name="TYPE_OF" value="51" enum="BuiltinFunc"> Return the type of the input as an integer. Check [enum Variant.Type] for the integers that might be returned. </constant> - <constant name="TYPE_EXISTS" value="53" enum="BuiltinFunc"> + <constant name="TYPE_EXISTS" value="52" enum="BuiltinFunc"> Checks if a type is registered in the [ClassDB]. </constant> - <constant name="TEXT_CHAR" value="54" enum="BuiltinFunc"> + <constant name="TEXT_CHAR" value="53" enum="BuiltinFunc"> Return a character with the given ascii value. </constant> - <constant name="TEXT_STR" value="55" enum="BuiltinFunc"> + <constant name="TEXT_STR" value="54" enum="BuiltinFunc"> Convert the input to a string. </constant> - <constant name="TEXT_PRINT" value="56" enum="BuiltinFunc"> + <constant name="TEXT_PRINT" value="55" enum="BuiltinFunc"> Print the given string to the output window. </constant> - <constant name="TEXT_PRINTERR" value="57" enum="BuiltinFunc"> + <constant name="TEXT_PRINTERR" value="56" enum="BuiltinFunc"> Print the given string to the standard error output. </constant> - <constant name="TEXT_PRINTRAW" value="58" enum="BuiltinFunc"> + <constant name="TEXT_PRINTRAW" value="57" enum="BuiltinFunc"> Print the given string to the standard output, without adding a newline. </constant> - <constant name="VAR_TO_STR" value="59" enum="BuiltinFunc"> + <constant name="VAR_TO_STR" value="58" enum="BuiltinFunc"> Serialize a [Variant] to a string. </constant> - <constant name="STR_TO_VAR" value="60" enum="BuiltinFunc"> + <constant name="STR_TO_VAR" value="59" enum="BuiltinFunc"> Deserialize a [Variant] from a string serialized using [constant VAR_TO_STR]. </constant> - <constant name="VAR_TO_BYTES" value="61" enum="BuiltinFunc"> + <constant name="VAR_TO_BYTES" value="60" enum="BuiltinFunc"> Serialize a [Variant] to a [PackedByteArray]. </constant> - <constant name="BYTES_TO_VAR" value="62" enum="BuiltinFunc"> + <constant name="BYTES_TO_VAR" value="61" enum="BuiltinFunc"> Deserialize a [Variant] from a [PackedByteArray] serialized using [constant VAR_TO_BYTES]. </constant> - <constant name="MATH_SMOOTHSTEP" value="63" enum="BuiltinFunc"> + <constant name="MATH_SMOOTHSTEP" value="62" enum="BuiltinFunc"> Return a number smoothly interpolated between the first two inputs, based on the third input. Similar to [constant MATH_LERP], but interpolates faster at the beginning and slower at the end. Using Hermite interpolation formula: [codeblock] var t = clamp((weight - from) / (to - from), 0.0, 1.0) return t * t * (3.0 - 2.0 * t) [/codeblock] </constant> - <constant name="MATH_POSMOD" value="64" enum="BuiltinFunc"> + <constant name="MATH_POSMOD" value="63" enum="BuiltinFunc"> </constant> - <constant name="MATH_LERP_ANGLE" value="65" enum="BuiltinFunc"> + <constant name="MATH_LERP_ANGLE" value="64" enum="BuiltinFunc"> </constant> - <constant name="TEXT_ORD" value="66" enum="BuiltinFunc"> + <constant name="TEXT_ORD" value="65" enum="BuiltinFunc"> </constant> - <constant name="FUNC_MAX" value="67" enum="BuiltinFunc"> + <constant name="FUNC_MAX" value="66" enum="BuiltinFunc"> Represents the size of the [enum BuiltinFunc] enum. </constant> </constants> diff --git a/modules/visual_script/doc_classes/VisualScriptConstructor.xml b/modules/visual_script/doc_classes/VisualScriptConstructor.xml index 2f162e78b6..4743594ec3 100644 --- a/modules/visual_script/doc_classes/VisualScriptConstructor.xml +++ b/modules/visual_script/doc_classes/VisualScriptConstructor.xml @@ -10,30 +10,24 @@ </tutorials> <methods> <method name="get_constructor" qualifiers="const"> - <return type="Dictionary"> - </return> + <return type="Dictionary" /> <description> </description> </method> <method name="get_constructor_type" qualifiers="const"> - <return type="int" enum="Variant.Type"> - </return> + <return type="int" enum="Variant.Type" /> <description> </description> </method> <method name="set_constructor"> - <return type="void"> - </return> - <argument index="0" name="constructor" type="Dictionary"> - </argument> + <return type="void" /> + <argument index="0" name="constructor" type="Dictionary" /> <description> </description> </method> <method name="set_constructor_type"> - <return type="void"> - </return> - <argument index="0" name="type" type="int" enum="Variant.Type"> - </argument> + <return type="void" /> + <argument index="0" name="type" type="int" enum="Variant.Type" /> <description> </description> </method> diff --git a/modules/visual_script/doc_classes/VisualScriptCustomNode.xml b/modules/visual_script/doc_classes/VisualScriptCustomNode.xml index 1c23b58507..8aa34f8cae 100644 --- a/modules/visual_script/doc_classes/VisualScriptCustomNode.xml +++ b/modules/visual_script/doc_classes/VisualScriptCustomNode.xml @@ -10,117 +10,122 @@ </tutorials> <methods> <method name="_get_caption" qualifiers="virtual"> - <return type="String"> - </return> + <return type="String" /> <description> Return the node's title. </description> </method> <method name="_get_category" qualifiers="virtual"> - <return type="String"> - </return> + <return type="String" /> <description> Return the node's category. </description> </method> <method name="_get_input_value_port_count" qualifiers="virtual"> - <return type="int"> - </return> + <return type="int" /> <description> Return the count of input value ports. </description> </method> + <method name="_get_input_value_port_hint" qualifiers="virtual"> + <return type="int" /> + <argument index="0" name="idx" type="int" /> + <description> + Return the specified input port's hint. See the [enum @GlobalScope.PropertyHint] hints. + </description> + </method> + <method name="_get_input_value_port_hint_string" qualifiers="virtual"> + <return type="String" /> + <argument index="0" name="idx" type="int" /> + <description> + Return the specified input port's hint string. + </description> + </method> <method name="_get_input_value_port_name" qualifiers="virtual"> - <return type="String"> - </return> - <argument index="0" name="idx" type="int"> - </argument> + <return type="String" /> + <argument index="0" name="idx" type="int" /> <description> Return the specified input port's name. </description> </method> <method name="_get_input_value_port_type" qualifiers="virtual"> - <return type="int"> - </return> - <argument index="0" name="idx" type="int"> - </argument> + <return type="int" /> + <argument index="0" name="idx" type="int" /> <description> Return the specified input port's type. See the [enum Variant.Type] values. </description> </method> <method name="_get_output_sequence_port_count" qualifiers="virtual"> - <return type="int"> - </return> + <return type="int" /> <description> Return the amount of output [b]sequence[/b] ports. </description> </method> <method name="_get_output_sequence_port_text" qualifiers="virtual"> - <return type="String"> - </return> - <argument index="0" name="idx" type="int"> - </argument> + <return type="String" /> + <argument index="0" name="idx" type="int" /> <description> Return the specified [b]sequence[/b] output's name. </description> </method> <method name="_get_output_value_port_count" qualifiers="virtual"> - <return type="int"> - </return> + <return type="int" /> <description> Return the amount of output value ports. </description> </method> + <method name="_get_output_value_port_hint" qualifiers="virtual"> + <return type="int" /> + <argument index="0" name="idx" type="int" /> + <description> + Return the specified output port's hint. See the [enum @GlobalScope.PropertyHint] hints. + </description> + </method> + <method name="_get_output_value_port_hint_string" qualifiers="virtual"> + <return type="String" /> + <argument index="0" name="idx" type="int" /> + <description> + Return the specified output port's hint string. + </description> + </method> <method name="_get_output_value_port_name" qualifiers="virtual"> - <return type="String"> - </return> - <argument index="0" name="idx" type="int"> - </argument> + <return type="String" /> + <argument index="0" name="idx" type="int" /> <description> - Return the specified output's name. + Return the specified output port's name. </description> </method> <method name="_get_output_value_port_type" qualifiers="virtual"> - <return type="int"> - </return> - <argument index="0" name="idx" type="int"> - </argument> + <return type="int" /> + <argument index="0" name="idx" type="int" /> <description> - Return the specified output's type. See the [enum Variant.Type] values. + Return the specified output port's type. See the [enum Variant.Type] values. </description> </method> <method name="_get_text" qualifiers="virtual"> - <return type="String"> - </return> + <return type="String" /> <description> Return the custom node's text, which is shown right next to the input [b]sequence[/b] port (if there is none, on the place that is usually taken by it). </description> </method> <method name="_get_working_memory_size" qualifiers="virtual"> - <return type="int"> - </return> + <return type="int" /> <description> Return the size of the custom node's working memory. See [method _step] for more details. </description> </method> <method name="_has_input_sequence_port" qualifiers="virtual"> - <return type="bool"> - </return> + <return type="bool" /> <description> Return whether the custom node has an input [b]sequence[/b] port. </description> </method> <method name="_step" qualifiers="virtual"> - <return type="Variant"> - </return> - <argument index="0" name="inputs" type="Array"> - </argument> - <argument index="1" name="outputs" type="Array"> - </argument> - <argument index="2" name="start_mode" type="int"> - </argument> - <argument index="3" name="working_mem" type="Array"> - </argument> + <return type="Variant" /> + <argument index="0" name="inputs" type="Array" /> + <argument index="1" name="outputs" type="Array" /> + <argument index="2" name="start_mode" type="int" /> + <argument index="3" name="working_mem" type="Array" /> <description> Execute the custom node's logic, returning the index of the output sequence port to use or a [String] when there is an error. The [code]inputs[/code] array contains the values of the input ports. diff --git a/modules/visual_script/doc_classes/VisualScriptEditor.xml b/modules/visual_script/doc_classes/VisualScriptEditor.xml index 186cd21239..9ea889c77b 100644 --- a/modules/visual_script/doc_classes/VisualScriptEditor.xml +++ b/modules/visual_script/doc_classes/VisualScriptEditor.xml @@ -8,25 +8,18 @@ </tutorials> <methods> <method name="add_custom_node"> - <return type="void"> - </return> - <argument index="0" name="name" type="String"> - </argument> - <argument index="1" name="category" type="String"> - </argument> - <argument index="2" name="script" type="Script"> - </argument> + <return type="void" /> + <argument index="0" name="name" type="String" /> + <argument index="1" name="category" type="String" /> + <argument index="2" name="script" type="Script" /> <description> Add a custom Visual Script node to the editor. It'll be placed under "Custom Nodes" with the [code]category[/code] as the parameter. </description> </method> <method name="remove_custom_node"> - <return type="void"> - </return> - <argument index="0" name="name" type="String"> - </argument> - <argument index="1" name="category" type="String"> - </argument> + <return type="void" /> + <argument index="0" name="name" type="String" /> + <argument index="1" name="category" type="String" /> <description> Remove a custom Visual Script node from the editor. Custom nodes already placed on scripts won't be removed. </description> diff --git a/modules/visual_script/doc_classes/VisualScriptExpression.xml b/modules/visual_script/doc_classes/VisualScriptExpression.xml index 5253f7bc7d..223adbbb96 100644 --- a/modules/visual_script/doc_classes/VisualScriptExpression.xml +++ b/modules/visual_script/doc_classes/VisualScriptExpression.xml @@ -1,8 +1,10 @@ <?xml version="1.0" encoding="UTF-8" ?> <class name="VisualScriptExpression" inherits="VisualScriptNode" version="4.0"> <brief_description> + A Visual Script node that can execute a custom expression. </brief_description> <description> + A Visual Script node that can execute a custom expression. Values can be provided for the input and the expression result can be retrieved from the output. </description> <tutorials> </tutorials> diff --git a/modules/visual_script/doc_classes/VisualScriptFunction.xml b/modules/visual_script/doc_classes/VisualScriptFunction.xml index 873d26a5be..652418bd64 100644 --- a/modules/visual_script/doc_classes/VisualScriptFunction.xml +++ b/modules/visual_script/doc_classes/VisualScriptFunction.xml @@ -1,8 +1,10 @@ <?xml version="1.0" encoding="UTF-8" ?> <class name="VisualScriptFunction" inherits="VisualScriptNode" version="4.0"> <brief_description> + A Visual Script node representing a function. </brief_description> <description> + [VisualScriptFunction] represents a function header. It is the starting point for the function body and can be used to tweak the function's properties (e.g. RPC mode). </description> <tutorials> </tutorials> diff --git a/modules/visual_script/doc_classes/VisualScriptFunctionCall.xml b/modules/visual_script/doc_classes/VisualScriptFunctionCall.xml index 48104afcf7..f0b666e57a 100644 --- a/modules/visual_script/doc_classes/VisualScriptFunctionCall.xml +++ b/modules/visual_script/doc_classes/VisualScriptFunctionCall.xml @@ -1,8 +1,10 @@ <?xml version="1.0" encoding="UTF-8" ?> <class name="VisualScriptFunctionCall" inherits="VisualScriptNode" version="4.0"> <brief_description> + A Visual Script node for calling a function. </brief_description> <description> + [VisualScriptFunctionCall] is created when you add or drag and drop a function onto the Visual Script graph. It allows to tweak parameters of the call, e.g. what object the function is called on. </description> <tutorials> </tutorials> @@ -10,46 +12,66 @@ </methods> <members> <member name="base_script" type="String" setter="set_base_script" getter="get_base_script"> + The script to be used when [member call_mode] is set to [constant CALL_MODE_INSTANCE]. </member> <member name="base_type" type="StringName" setter="set_base_type" getter="get_base_type" default="&"Object""> + The base type to be used when [member call_mode] is set to [constant CALL_MODE_INSTANCE]. </member> <member name="basic_type" type="int" setter="set_basic_type" getter="get_basic_type" enum="Variant.Type"> + The type to be used when [member call_mode] is set to [constant CALL_MODE_BASIC_TYPE]. </member> <member name="call_mode" type="int" setter="set_call_mode" getter="get_call_mode" enum="VisualScriptFunctionCall.CallMode" default="0"> + [code]call_mode[/code] determines the target object on which the method will be called. See [enum CallMode] for options. </member> <member name="function" type="StringName" setter="set_function" getter="get_function" default="&"""> + The name of the function to be called. </member> <member name="node_path" type="NodePath" setter="set_base_path" getter="get_base_path"> + The node path to use when [member call_mode] is set to [constant CALL_MODE_NODE_PATH]. </member> <member name="rpc_call_mode" type="int" setter="set_rpc_call_mode" getter="get_rpc_call_mode" enum="VisualScriptFunctionCall.RPCCallMode" default="0"> + The mode for RPC calls. See [method Node.rpc] for more details and [enum RPCCallMode] for available options. </member> <member name="singleton" type="StringName" setter="set_singleton" getter="get_singleton"> + The singleton to call the method on. Used when [member call_mode] is set to [constant CALL_MODE_SINGLETON]. </member> <member name="use_default_args" type="int" setter="set_use_default_args" getter="get_use_default_args"> + Number of default arguments that will be used when calling the function. Can't be higher than the number of available default arguments in the method's declaration. </member> <member name="validate" type="bool" setter="set_validate" getter="get_validate" default="true"> + If [code]false[/code], call errors (e.g. wrong number of arguments) will be ignored. </member> </members> <constants> <constant name="CALL_MODE_SELF" value="0" enum="CallMode"> + The method will be called on this [Object]. </constant> <constant name="CALL_MODE_NODE_PATH" value="1" enum="CallMode"> + The method will be called on the given [Node] in the scene tree. </constant> <constant name="CALL_MODE_INSTANCE" value="2" enum="CallMode"> + The method will be called on an instanced node with the given type and script. </constant> <constant name="CALL_MODE_BASIC_TYPE" value="3" enum="CallMode"> + The method will be called on a GDScript basic type (e.g. [Vector2]). </constant> <constant name="CALL_MODE_SINGLETON" value="4" enum="CallMode"> + The method will be called on a singleton. </constant> <constant name="RPC_DISABLED" value="0" enum="RPCCallMode"> + The method will be called locally. </constant> <constant name="RPC_RELIABLE" value="1" enum="RPCCallMode"> + The method will be called remotely. </constant> <constant name="RPC_UNRELIABLE" value="2" enum="RPCCallMode"> + The method will be called remotely using an unreliable protocol. </constant> <constant name="RPC_RELIABLE_TO_ID" value="3" enum="RPCCallMode"> + The method will be called remotely for the given peer. </constant> <constant name="RPC_UNRELIABLE_TO_ID" value="4" enum="RPCCallMode"> + The method will be called remotely for the given peer, using an unreliable protocol. </constant> </constants> </class> diff --git a/modules/visual_script/doc_classes/VisualScriptFunctionState.xml b/modules/visual_script/doc_classes/VisualScriptFunctionState.xml index 16c1629fe4..18c3826df8 100644 --- a/modules/visual_script/doc_classes/VisualScriptFunctionState.xml +++ b/modules/visual_script/doc_classes/VisualScriptFunctionState.xml @@ -1,36 +1,34 @@ <?xml version="1.0" encoding="UTF-8" ?> <class name="VisualScriptFunctionState" inherits="RefCounted" version="4.0"> <brief_description> + A Visual Script node representing a function state. </brief_description> <description> + [VisualScriptFunctionState] is returned from [VisualScriptYield] and can be used to resume a paused function call. </description> <tutorials> </tutorials> <methods> <method name="connect_to_signal"> - <return type="void"> - </return> - <argument index="0" name="obj" type="Object"> - </argument> - <argument index="1" name="signals" type="String"> - </argument> - <argument index="2" name="args" type="Array"> - </argument> + <return type="void" /> + <argument index="0" name="obj" type="Object" /> + <argument index="1" name="signals" type="String" /> + <argument index="2" name="args" type="Array" /> <description> + Connects this [VisualScriptFunctionState] to a signal in the given object to automatically resume when it's emitted. </description> </method> <method name="is_valid" qualifiers="const"> - <return type="bool"> - </return> + <return type="bool" /> <description> + Returns whether the function state is valid. </description> </method> <method name="resume"> - <return type="Variant"> - </return> - <argument index="0" name="args" type="Array" default="[]"> - </argument> + <return type="Variant" /> + <argument index="0" name="args" type="Array" default="[]" /> <description> + Resumes the function to run from the point it was yielded. </description> </method> </methods> diff --git a/modules/visual_script/doc_classes/VisualScriptGlobalConstant.xml b/modules/visual_script/doc_classes/VisualScriptGlobalConstant.xml index ef17bd8a28..87fdfd4e53 100644 --- a/modules/visual_script/doc_classes/VisualScriptGlobalConstant.xml +++ b/modules/visual_script/doc_classes/VisualScriptGlobalConstant.xml @@ -1,8 +1,10 @@ <?xml version="1.0" encoding="UTF-8" ?> <class name="VisualScriptGlobalConstant" inherits="VisualScriptNode" version="4.0"> <brief_description> + A Visual Script node returning a constant from [@GlobalScope]. </brief_description> <description> + A Visual Script node returning a constant from [@GlobalScope]. </description> <tutorials> </tutorials> @@ -10,6 +12,7 @@ </methods> <members> <member name="constant" type="int" setter="set_global_constant" getter="get_global_constant" default="0"> + The constant to be used. </member> </members> <constants> diff --git a/modules/visual_script/doc_classes/VisualScriptIndexGet.xml b/modules/visual_script/doc_classes/VisualScriptIndexGet.xml index bb1618a655..b348048298 100644 --- a/modules/visual_script/doc_classes/VisualScriptIndexGet.xml +++ b/modules/visual_script/doc_classes/VisualScriptIndexGet.xml @@ -1,8 +1,10 @@ <?xml version="1.0" encoding="UTF-8" ?> <class name="VisualScriptIndexGet" inherits="VisualScriptNode" version="4.0"> <brief_description> + A Visual Script node for getting a value from an array or a dictionary. </brief_description> <description> + [VisualScriptIndexGet] will return the value stored in an array or a dictionary under the given index. </description> <tutorials> </tutorials> diff --git a/modules/visual_script/doc_classes/VisualScriptIndexSet.xml b/modules/visual_script/doc_classes/VisualScriptIndexSet.xml index 4ff96f7211..d7fe7340ad 100644 --- a/modules/visual_script/doc_classes/VisualScriptIndexSet.xml +++ b/modules/visual_script/doc_classes/VisualScriptIndexSet.xml @@ -1,8 +1,10 @@ <?xml version="1.0" encoding="UTF-8" ?> <class name="VisualScriptIndexSet" inherits="VisualScriptNode" version="4.0"> <brief_description> + A Visual Script node for setting a value in an array or a dictionary. </brief_description> <description> + [VisualScriptIndexSet] will set the value stored in an array or a dictionary under the given index to the provided new value. </description> <tutorials> </tutorials> diff --git a/modules/visual_script/doc_classes/VisualScriptInputAction.xml b/modules/visual_script/doc_classes/VisualScriptInputAction.xml index 9ca67feacb..d6fa111500 100644 --- a/modules/visual_script/doc_classes/VisualScriptInputAction.xml +++ b/modules/visual_script/doc_classes/VisualScriptInputAction.xml @@ -1,8 +1,10 @@ <?xml version="1.0" encoding="UTF-8" ?> <class name="VisualScriptInputAction" inherits="VisualScriptNode" version="4.0"> <brief_description> + A Visual Script node returning a state of an action. </brief_description> <description> + [VisualScriptInputAction] can be used to check if an action is pressed or released. </description> <tutorials> </tutorials> @@ -10,18 +12,24 @@ </methods> <members> <member name="action" type="StringName" setter="set_action_name" getter="get_action_name" default="&"""> + Name of the action. </member> <member name="mode" type="int" setter="set_action_mode" getter="get_action_mode" enum="VisualScriptInputAction.Mode" default="0"> + State of the action to check. See [enum Mode] for options. </member> </members> <constants> <constant name="MODE_PRESSED" value="0" enum="Mode"> + [code]True[/code] if action is pressed. </constant> <constant name="MODE_RELEASED" value="1" enum="Mode"> + [code]True[/code] if action is released (i.e. not pressed). </constant> <constant name="MODE_JUST_PRESSED" value="2" enum="Mode"> + [code]True[/code] on the frame the action was pressed. </constant> <constant name="MODE_JUST_RELEASED" value="3" enum="Mode"> + [code]True[/code] on the frame the action was released. </constant> </constants> </class> diff --git a/modules/visual_script/doc_classes/VisualScriptLists.xml b/modules/visual_script/doc_classes/VisualScriptLists.xml index 8a7254b46a..d5bff1341a 100644 --- a/modules/visual_script/doc_classes/VisualScriptLists.xml +++ b/modules/visual_script/doc_classes/VisualScriptLists.xml @@ -10,83 +10,67 @@ </tutorials> <methods> <method name="add_input_data_port"> - <return type="void"> - </return> - <argument index="0" name="type" type="int" enum="Variant.Type"> - </argument> - <argument index="1" name="name" type="String"> - </argument> - <argument index="2" name="index" type="int"> - </argument> + <return type="void" /> + <argument index="0" name="type" type="int" enum="Variant.Type" /> + <argument index="1" name="name" type="String" /> + <argument index="2" name="index" type="int" /> <description> + Adds an input port to the Visual Script node. </description> </method> <method name="add_output_data_port"> - <return type="void"> - </return> - <argument index="0" name="type" type="int" enum="Variant.Type"> - </argument> - <argument index="1" name="name" type="String"> - </argument> - <argument index="2" name="index" type="int"> - </argument> + <return type="void" /> + <argument index="0" name="type" type="int" enum="Variant.Type" /> + <argument index="1" name="name" type="String" /> + <argument index="2" name="index" type="int" /> <description> + Adds an output port to the Visual Script node. </description> </method> <method name="remove_input_data_port"> - <return type="void"> - </return> - <argument index="0" name="index" type="int"> - </argument> + <return type="void" /> + <argument index="0" name="index" type="int" /> <description> + Removes an input port from the Visual Script node. </description> </method> <method name="remove_output_data_port"> - <return type="void"> - </return> - <argument index="0" name="index" type="int"> - </argument> + <return type="void" /> + <argument index="0" name="index" type="int" /> <description> + Removes an output port from the Visual Script node. </description> </method> <method name="set_input_data_port_name"> - <return type="void"> - </return> - <argument index="0" name="index" type="int"> - </argument> - <argument index="1" name="name" type="String"> - </argument> + <return type="void" /> + <argument index="0" name="index" type="int" /> + <argument index="1" name="name" type="String" /> <description> + Sets the name of an input port. </description> </method> <method name="set_input_data_port_type"> - <return type="void"> - </return> - <argument index="0" name="index" type="int"> - </argument> - <argument index="1" name="type" type="int" enum="Variant.Type"> - </argument> + <return type="void" /> + <argument index="0" name="index" type="int" /> + <argument index="1" name="type" type="int" enum="Variant.Type" /> <description> + Sets the type of an input port. </description> </method> <method name="set_output_data_port_name"> - <return type="void"> - </return> - <argument index="0" name="index" type="int"> - </argument> - <argument index="1" name="name" type="String"> - </argument> + <return type="void" /> + <argument index="0" name="index" type="int" /> + <argument index="1" name="name" type="String" /> <description> + Sets the name of an output port. </description> </method> <method name="set_output_data_port_type"> - <return type="void"> - </return> - <argument index="0" name="index" type="int"> - </argument> - <argument index="1" name="type" type="int" enum="Variant.Type"> - </argument> + <return type="void" /> + <argument index="0" name="index" type="int" /> + <argument index="1" name="type" type="int" enum="Variant.Type" /> <description> + Sets the type of an output port. </description> </method> </methods> diff --git a/modules/visual_script/doc_classes/VisualScriptNode.xml b/modules/visual_script/doc_classes/VisualScriptNode.xml index 82a023f3e4..23574a5ea8 100644 --- a/modules/visual_script/doc_classes/VisualScriptNode.xml +++ b/modules/visual_script/doc_classes/VisualScriptNode.xml @@ -10,35 +10,28 @@ </tutorials> <methods> <method name="get_default_input_value" qualifiers="const"> - <return type="Variant"> - </return> - <argument index="0" name="port_idx" type="int"> - </argument> + <return type="Variant" /> + <argument index="0" name="port_idx" type="int" /> <description> Returns the default value of a given port. The default value is used when nothing is connected to the port. </description> </method> <method name="get_visual_script" qualifiers="const"> - <return type="VisualScript"> - </return> + <return type="VisualScript" /> <description> Returns the [VisualScript] instance the node is bound to. </description> </method> <method name="ports_changed_notify"> - <return type="void"> - </return> + <return type="void" /> <description> Notify that the node's ports have changed. Usually used in conjunction with [VisualScriptCustomNode] . </description> </method> <method name="set_default_input_value"> - <return type="void"> - </return> - <argument index="0" name="port_idx" type="int"> - </argument> - <argument index="1" name="value" type="Variant"> - </argument> + <return type="void" /> + <argument index="0" name="port_idx" type="int" /> + <argument index="1" name="value" type="Variant" /> <description> Change the default value of a given port. </description> diff --git a/modules/visual_script/doc_classes/VisualScriptOperator.xml b/modules/visual_script/doc_classes/VisualScriptOperator.xml index c8ce0f2732..cbbefa7f71 100644 --- a/modules/visual_script/doc_classes/VisualScriptOperator.xml +++ b/modules/visual_script/doc_classes/VisualScriptOperator.xml @@ -1,6 +1,7 @@ <?xml version="1.0" encoding="UTF-8" ?> <class name="VisualScriptOperator" inherits="VisualScriptNode" version="4.0"> <brief_description> + A Visual Script node that performs an operation on two values. </brief_description> <description> [b]Input Ports:[/b] @@ -15,8 +16,10 @@ </methods> <members> <member name="operator" type="int" setter="set_operator" getter="get_operator" enum="Variant.Operator" default="6"> + The operation to be performed. See [enum Variant.Operator] for available options. </member> <member name="type" type="int" setter="set_typed" getter="get_typed" enum="Variant.Type" default="0"> + The type of the values for this operation. See [enum Variant.Type] for available options. </member> </members> <constants> diff --git a/modules/visual_script/doc_classes/VisualScriptPropertyGet.xml b/modules/visual_script/doc_classes/VisualScriptPropertyGet.xml index ff6c723a3e..c1bf443ea3 100644 --- a/modules/visual_script/doc_classes/VisualScriptPropertyGet.xml +++ b/modules/visual_script/doc_classes/VisualScriptPropertyGet.xml @@ -1,8 +1,10 @@ <?xml version="1.0" encoding="UTF-8" ?> <class name="VisualScriptPropertyGet" inherits="VisualScriptNode" version="4.0"> <brief_description> + A Visual Script node returning a value of a property from an [Object]. </brief_description> <description> + [VisualScriptPropertyGet] can return a value of any property from the current object or other objects. </description> <tutorials> </tutorials> @@ -10,28 +12,39 @@ </methods> <members> <member name="base_script" type="String" setter="set_base_script" getter="get_base_script"> + The script to be used when [member set_mode] is set to [constant CALL_MODE_INSTANCE]. </member> <member name="base_type" type="StringName" setter="set_base_type" getter="get_base_type" default="&"Object""> + The base type to be used when [member set_mode] is set to [constant CALL_MODE_INSTANCE]. </member> <member name="basic_type" type="int" setter="set_basic_type" getter="get_basic_type" enum="Variant.Type"> + The type to be used when [member set_mode] is set to [constant CALL_MODE_BASIC_TYPE]. </member> <member name="index" type="StringName" setter="set_index" getter="get_index"> + The indexed name of the property to retrieve. See [method Object.get_indexed] for details. </member> <member name="node_path" type="NodePath" setter="set_base_path" getter="get_base_path"> + The node path to use when [member set_mode] is set to [constant CALL_MODE_NODE_PATH]. </member> <member name="property" type="StringName" setter="set_property" getter="get_property" default="&"""> + The name of the property to retrieve. Changing this will clear [member index]. </member> <member name="set_mode" type="int" setter="set_call_mode" getter="get_call_mode" enum="VisualScriptPropertyGet.CallMode" default="0"> + [code]set_mode[/code] determines the target object from which the property will be retrieved. See [enum CallMode] for options. </member> </members> <constants> <constant name="CALL_MODE_SELF" value="0" enum="CallMode"> + The property will be retrieved from this [Object]. </constant> <constant name="CALL_MODE_NODE_PATH" value="1" enum="CallMode"> + The property will be retrieved from the given [Node] in the scene tree. </constant> <constant name="CALL_MODE_INSTANCE" value="2" enum="CallMode"> + The property will be retrieved from an instanced node with the given type and script. </constant> <constant name="CALL_MODE_BASIC_TYPE" value="3" enum="CallMode"> + The property will be retrieved from a GDScript basic type (e.g. [Vector2]). </constant> </constants> </class> diff --git a/modules/visual_script/doc_classes/VisualScriptPropertySet.xml b/modules/visual_script/doc_classes/VisualScriptPropertySet.xml index 71bfc4c8a5..75d6a63469 100644 --- a/modules/visual_script/doc_classes/VisualScriptPropertySet.xml +++ b/modules/visual_script/doc_classes/VisualScriptPropertySet.xml @@ -1,8 +1,10 @@ <?xml version="1.0" encoding="UTF-8" ?> <class name="VisualScriptPropertySet" inherits="VisualScriptNode" version="4.0"> <brief_description> + A Visual Script node that sets a property of an [Object]. </brief_description> <description> + [VisualScriptPropertySet] can set the value of any property from the current object or other objects. </description> <tutorials> </tutorials> @@ -10,52 +12,75 @@ </methods> <members> <member name="assign_op" type="int" setter="set_assign_op" getter="get_assign_op" enum="VisualScriptPropertySet.AssignOp" default="0"> + The additional operation to perform when assigning. See [enum AssignOp] for options. </member> <member name="base_script" type="String" setter="set_base_script" getter="get_base_script"> + The script to be used when [member set_mode] is set to [constant CALL_MODE_INSTANCE]. </member> <member name="base_type" type="StringName" setter="set_base_type" getter="get_base_type" default="&"Object""> + The base type to be used when [member set_mode] is set to [constant CALL_MODE_INSTANCE]. </member> <member name="basic_type" type="int" setter="set_basic_type" getter="get_basic_type" enum="Variant.Type"> + The type to be used when [member set_mode] is set to [constant CALL_MODE_BASIC_TYPE]. </member> <member name="index" type="StringName" setter="set_index" getter="get_index"> + The indexed name of the property to set. See [method Object.set_indexed] for details. </member> <member name="node_path" type="NodePath" setter="set_base_path" getter="get_base_path"> + The node path to use when [member set_mode] is set to [constant CALL_MODE_NODE_PATH]. </member> <member name="property" type="StringName" setter="set_property" getter="get_property" default="&"""> + The name of the property to set. Changing this will clear [member index]. </member> <member name="set_mode" type="int" setter="set_call_mode" getter="get_call_mode" enum="VisualScriptPropertySet.CallMode" default="0"> + [code]set_mode[/code] determines the target object on which the property will be set. See [enum CallMode] for options. </member> </members> <constants> <constant name="CALL_MODE_SELF" value="0" enum="CallMode"> + The property will be set on this [Object]. </constant> <constant name="CALL_MODE_NODE_PATH" value="1" enum="CallMode"> + The property will be set on the given [Node] in the scene tree. </constant> <constant name="CALL_MODE_INSTANCE" value="2" enum="CallMode"> + The property will be set on an instanced node with the given type and script. </constant> <constant name="CALL_MODE_BASIC_TYPE" value="3" enum="CallMode"> + The property will be set on a GDScript basic type (e.g. [Vector2]). </constant> <constant name="ASSIGN_OP_NONE" value="0" enum="AssignOp"> + The property will be assigned regularly. </constant> <constant name="ASSIGN_OP_ADD" value="1" enum="AssignOp"> + The value will be added to the property. Equivalent of doing [code]+=[/code]. </constant> <constant name="ASSIGN_OP_SUB" value="2" enum="AssignOp"> + The value will be subtracted from the property. Equivalent of doing [code]-=[/code]. </constant> <constant name="ASSIGN_OP_MUL" value="3" enum="AssignOp"> + The property will be multiplied by the value. Equivalent of doing [code]*=[/code]. </constant> <constant name="ASSIGN_OP_DIV" value="4" enum="AssignOp"> + The property will be divided by the value. Equivalent of doing [code]/=[/code]. </constant> <constant name="ASSIGN_OP_MOD" value="5" enum="AssignOp"> + A modulo operation will be performed on the property and the value. Equivalent of doing [code]%=[/code]. </constant> <constant name="ASSIGN_OP_SHIFT_LEFT" value="6" enum="AssignOp"> + The property will be binarly shifted to the left by the given value. Equivalent of doing [code]<<[/code]. </constant> <constant name="ASSIGN_OP_SHIFT_RIGHT" value="7" enum="AssignOp"> + The property will be binarly shifted to the right by the given value. Equivalent of doing [code]>>[/code]. </constant> <constant name="ASSIGN_OP_BIT_AND" value="8" enum="AssignOp"> + A binary [code]AND[/code] operation will be performed on the property. Equivalent of doing [code]&=[/code]. </constant> <constant name="ASSIGN_OP_BIT_OR" value="9" enum="AssignOp"> + A binary [code]OR[/code] operation will be performed on the property. Equivalent of doing [code]|=[/code]. </constant> <constant name="ASSIGN_OP_BIT_XOR" value="10" enum="AssignOp"> + A binary [code]XOR[/code] operation will be performed on the property. Equivalent of doing [code]^=[/code]. </constant> </constants> </class> diff --git a/modules/visual_script/doc_classes/VisualScriptSceneTree.xml b/modules/visual_script/doc_classes/VisualScriptSceneTree.xml index 191d4b6977..8cddd02c77 100644 --- a/modules/visual_script/doc_classes/VisualScriptSceneTree.xml +++ b/modules/visual_script/doc_classes/VisualScriptSceneTree.xml @@ -1,8 +1,10 @@ <?xml version="1.0" encoding="UTF-8" ?> <class name="VisualScriptSceneTree" inherits="VisualScriptNode" version="4.0"> <brief_description> + A Visual Script node for accessing [SceneTree] methods. </brief_description> <description> + A Visual Script node for accessing [SceneTree] methods. </description> <tutorials> </tutorials> diff --git a/modules/visual_script/doc_classes/VisualScriptSubCall.xml b/modules/visual_script/doc_classes/VisualScriptSubCall.xml index cb3b04b583..374e7d0f35 100644 --- a/modules/visual_script/doc_classes/VisualScriptSubCall.xml +++ b/modules/visual_script/doc_classes/VisualScriptSubCall.xml @@ -1,18 +1,19 @@ <?xml version="1.0" encoding="UTF-8" ?> <class name="VisualScriptSubCall" inherits="VisualScriptNode" version="4.0"> <brief_description> + Calls a method called [code]_subcall[/code] in this object. </brief_description> <description> + [VisualScriptSubCall] will call method named [code]_subcall[/code] in the current script. It will fail if the method doesn't exist or the provided arguments are wrong. </description> <tutorials> </tutorials> <methods> <method name="_subcall" qualifiers="virtual"> - <return type="Variant"> - </return> - <argument index="0" name="arguments" type="Variant"> - </argument> + <return type="Variant" /> + <argument index="0" name="arguments" type="Variant" /> <description> + Called by this node. </description> </method> </methods> diff --git a/modules/visual_script/doc_classes/VisualScriptTypeCast.xml b/modules/visual_script/doc_classes/VisualScriptTypeCast.xml index 9e3e020f2d..5dd1ad3421 100644 --- a/modules/visual_script/doc_classes/VisualScriptTypeCast.xml +++ b/modules/visual_script/doc_classes/VisualScriptTypeCast.xml @@ -1,8 +1,10 @@ <?xml version="1.0" encoding="UTF-8" ?> <class name="VisualScriptTypeCast" inherits="VisualScriptNode" version="4.0"> <brief_description> + A Visual Script node that casts the given value to another type. </brief_description> <description> + [VisualScriptTypeCast] will perform a type conversion to an [Object]-derived type. </description> <tutorials> </tutorials> @@ -10,8 +12,10 @@ </methods> <members> <member name="base_script" type="String" setter="set_base_script" getter="get_base_script" default=""""> + The target script class to be converted to. If none, only the [member base_type] will be used. </member> <member name="base_type" type="StringName" setter="set_base_type" getter="get_base_type" default="&"Object""> + The target type to be converted to. </member> </members> <constants> diff --git a/modules/visual_script/doc_classes/VisualScriptYield.xml b/modules/visual_script/doc_classes/VisualScriptYield.xml index 0a8d529a48..b04ab7b014 100644 --- a/modules/visual_script/doc_classes/VisualScriptYield.xml +++ b/modules/visual_script/doc_classes/VisualScriptYield.xml @@ -1,8 +1,10 @@ <?xml version="1.0" encoding="UTF-8" ?> <class name="VisualScriptYield" inherits="VisualScriptNode" version="4.0"> <brief_description> + A Visual Script node used to pause a function execution. </brief_description> <description> + [VisualScriptYield] will pause the function call and return [VisualScriptFunctionState], which can be used to resume the function. </description> <tutorials> </tutorials> @@ -10,16 +12,21 @@ </methods> <members> <member name="mode" type="int" setter="set_yield_mode" getter="get_yield_mode" enum="VisualScriptYield.YieldMode" default="1"> + The mode to use for yielding. See [enum YieldMode] for available options. </member> <member name="wait_time" type="float" setter="set_wait_time" getter="get_wait_time"> + The time to wait when [member mode] is set to [constant YIELD_WAIT]. </member> </members> <constants> <constant name="YIELD_FRAME" value="1" enum="YieldMode"> + Yields during an idle frame. </constant> <constant name="YIELD_PHYSICS_FRAME" value="2" enum="YieldMode"> + Yields during a physics frame. </constant> <constant name="YIELD_WAIT" value="3" enum="YieldMode"> + Yields a function and waits the given time. </constant> </constants> </class> diff --git a/modules/visual_script/doc_classes/VisualScriptYieldSignal.xml b/modules/visual_script/doc_classes/VisualScriptYieldSignal.xml index c59234433f..c6c3188d08 100644 --- a/modules/visual_script/doc_classes/VisualScriptYieldSignal.xml +++ b/modules/visual_script/doc_classes/VisualScriptYieldSignal.xml @@ -1,8 +1,10 @@ <?xml version="1.0" encoding="UTF-8" ?> <class name="VisualScriptYieldSignal" inherits="VisualScriptNode" version="4.0"> <brief_description> + A Visual Script node yielding for a signal. </brief_description> <description> + [VisualScriptYieldSignal] will pause the function execution until the provided signal is emitted. </description> <tutorials> </tutorials> @@ -10,20 +12,27 @@ </methods> <members> <member name="base_type" type="StringName" setter="set_base_type" getter="get_base_type" default="&"Object""> + The base type to be used when [member call_mode] is set to [constant CALL_MODE_INSTANCE]. </member> <member name="call_mode" type="int" setter="set_call_mode" getter="get_call_mode" enum="VisualScriptYieldSignal.CallMode" default="0"> + [code]call_mode[/code] determines the target object to wait for the signal emission. See [enum CallMode] for options. </member> <member name="node_path" type="NodePath" setter="set_base_path" getter="get_base_path"> + The node path to use when [member call_mode] is set to [constant CALL_MODE_NODE_PATH]. </member> <member name="signal" type="StringName" setter="set_signal" getter="get_signal" default="&"""> + The signal name to be waited for. </member> </members> <constants> <constant name="CALL_MODE_SELF" value="0" enum="CallMode"> + A signal from this [Object] will be used. </constant> <constant name="CALL_MODE_NODE_PATH" value="1" enum="CallMode"> + A signal from the given [Node] in the scene tree will be used. </constant> <constant name="CALL_MODE_INSTANCE" value="2" enum="CallMode"> + A signal from an instanced node with the given type will be used. </constant> </constants> </class> diff --git a/modules/visual_script/visual_script.cpp b/modules/visual_script/visual_script.cpp index c4b3f9ba44..7a2404fd80 100644 --- a/modules/visual_script/visual_script.cpp +++ b/modules/visual_script/visual_script.cpp @@ -46,7 +46,7 @@ bool VisualScriptNode::is_breakpoint() const { } void VisualScriptNode::ports_changed_notify() { - emit_signal("ports_changed"); + emit_signal(SNAME("ports_changed")); } void VisualScriptNode::set_default_input_value(int p_port, const Variant &p_value) { @@ -264,7 +264,7 @@ void VisualScript::_node_ports_changed(int p_id) { #ifdef TOOLS_ENABLED set_edited(true); // Something changed, let's set as edited. - emit_signal("node_ports_changed", p_id); + emit_signal(SNAME("node_ports_changed"), p_id); #endif } @@ -588,14 +588,14 @@ void VisualScript::rename_variable(const StringName &p_name, const StringName &p variables.erase(p_name); List<int> ids; get_node_list(&ids); - for (List<int>::Element *E = ids.front(); E; E = E->next()) { - Ref<VisualScriptVariableGet> nodeget = get_node(E->get()); + for (int &E : ids) { + Ref<VisualScriptVariableGet> nodeget = get_node(E); if (nodeget.is_valid()) { if (nodeget->get_variable() == p_name) { nodeget->set_variable(p_new_name); } } else { - Ref<VisualScriptVariableSet> nodeset = get_node(E->get()); + Ref<VisualScriptVariableSet> nodeset = get_node(E); if (nodeset.is_valid()) { if (nodeset->get_variable() == p_name) { nodeset->set_variable(p_new_name); @@ -715,9 +715,9 @@ int VisualScript::get_available_id() const { List<int> nds; nodes.get_key_list(&nds); int max = -1; - for (const List<int>::Element *E = nds.front(); E; E = E->next()) { - if (E->get() > max) { - max = E->get(); + for (const int &E : nds) { + if (E > max) { + max = E; } } return (max + 1); @@ -752,15 +752,15 @@ void VisualScript::_update_placeholders() { List<StringName> keys; variables.get_key_list(&keys); - for (List<StringName>::Element *E = keys.front(); E; E = E->next()) { - if (!variables[E->get()]._export) { + for (const StringName &E : keys) { + if (!variables[E]._export) { continue; } - PropertyInfo p = variables[E->get()].info; - p.name = String(E->get()); + PropertyInfo p = variables[E].info; + p.name = String(E); pinfo.push_back(p); - values[p.name] = variables[E->get()].default_value; + values[p.name] = variables[E].default_value; } for (Set<PlaceHolderScriptInstance *>::Element *E = placeholders.front(); E; E = E->next()) { @@ -783,15 +783,15 @@ ScriptInstance *VisualScript::instance_create(Object *p_this) { List<StringName> keys; variables.get_key_list(&keys); - for (const List<StringName>::Element *E = keys.front(); E; E = E->next()) { - if (!variables[E->get()]._export) { + for (const StringName &E : keys) { + if (!variables[E]._export) { continue; } - PropertyInfo p = variables[E->get()].info; - p.name = String(E->get()); + PropertyInfo p = variables[E].info; + p.name = String(E); pinfo.push_back(p); - values[p.name] = variables[E->get()].default_value; + values[p.name] = variables[E].default_value; } sins->update(pinfo, values); @@ -874,11 +874,11 @@ void VisualScript::get_script_method_list(List<MethodInfo> *p_list) const { List<StringName> funcs; functions.get_key_list(&funcs); - for (List<StringName>::Element *E = funcs.front(); E; E = E->next()) { + for (const StringName &E : funcs) { MethodInfo mi; - mi.name = E->get(); - if (functions[E->get()].func_id >= 0) { - Ref<VisualScriptFunction> func = nodes[functions[E->get()].func_id].node; + mi.name = E; + if (functions[E].func_id >= 0) { + Ref<VisualScriptFunction> func = nodes[functions[E].func_id].node; if (func.is_valid()) { for (int i = 0; i < func->get_argument_count(); i++) { PropertyInfo arg; @@ -928,10 +928,10 @@ void VisualScript::get_script_property_list(List<PropertyInfo> *p_list) const { List<StringName> vars; get_variable_list(&vars); - for (List<StringName>::Element *E = vars.front(); E; E = E->next()) { - //if (!variables[E->get()]._export) + for (const StringName &E : vars) { + //if (!variables[E]._export) // continue; - PropertyInfo pi = variables[E->get()].info; + PropertyInfo pi = variables[E].info; pi.usage |= PROPERTY_USAGE_SCRIPT_VARIABLE; p_list->push_back(pi); } @@ -945,8 +945,8 @@ int VisualScript::get_member_line(const StringName &p_member) const { bool VisualScript::are_subnodes_edited() const { List<int> keys; nodes.get_key_list(&keys); - for (const List<int>::Element *F = keys.front(); F; F = F->next()) { - if (nodes[F->get()].node->is_edited()) { + for (const int &F : keys) { + if (nodes[F].node->is_edited()) { return true; } } @@ -1017,13 +1017,13 @@ void VisualScript::_set_data(const Dictionary &p_data) { rpc_functions.clear(); List<StringName> fns; functions.get_key_list(&fns); - for (const List<StringName>::Element *E = fns.front(); E; E = E->next()) { - if (functions[E->get()].func_id >= 0 && nodes.has(functions[E->get()].func_id)) { - Ref<VisualScriptFunction> vsf = nodes[functions[E->get()].func_id].node; + for (const StringName &E : fns) { + if (functions[E].func_id >= 0 && nodes.has(functions[E].func_id)) { + Ref<VisualScriptFunction> vsf = nodes[functions[E].func_id].node; if (vsf.is_valid()) { if (vsf->get_rpc_mode() != MultiplayerAPI::RPC_MODE_DISABLED) { MultiplayerAPI::RPCConfig nd; - nd.name = E->get(); + nd.name = E; nd.rpc_mode = vsf->get_rpc_mode(); nd.transfer_mode = MultiplayerPeer::TRANSFER_MODE_RELIABLE; // TODO if (rpc_functions.find(nd) == -1) { @@ -1045,11 +1045,11 @@ Dictionary VisualScript::_get_data() const { Array vars; List<StringName> var_names; variables.get_key_list(&var_names); - for (const List<StringName>::Element *E = var_names.front(); E; E = E->next()) { - Dictionary var = _get_variable_info(E->get()); - var["name"] = E->get(); // Make sure it's the right one. - var["default_value"] = variables[E->get()].default_value; - var["export"] = variables[E->get()]._export; + for (const StringName &E : var_names) { + Dictionary var = _get_variable_info(E); + var["name"] = E; // Make sure it's the right one. + var["default_value"] = variables[E].default_value; + var["export"] = variables[E]._export; vars.push_back(var); } d["variables"] = vars; @@ -1073,10 +1073,10 @@ Dictionary VisualScript::_get_data() const { Array funcs; List<StringName> func_names; functions.get_key_list(&func_names); - for (const List<StringName>::Element *E = func_names.front(); E; E = E->next()) { + for (const StringName &E : func_names) { Dictionary func; - func["name"] = E->get(); - func["function_id"] = functions[E->get()].func_id; + func["name"] = E; + func["function_id"] = functions[E].func_id; funcs.push_back(func); } d["functions"] = funcs; @@ -1084,10 +1084,10 @@ Dictionary VisualScript::_get_data() const { Array nds; List<int> node_ids; nodes.get_key_list(&node_ids); - for (const List<int>::Element *F = node_ids.front(); F; F = F->next()) { - nds.push_back(F->get()); - nds.push_back(nodes[F->get()].pos); - nds.push_back(nodes[F->get()].node); + for (const int &F : node_ids) { + nds.push_back(F); + nds.push_back(nodes[F].pos); + nds.push_back(nodes[F].node); } d["nodes"] = nds; @@ -1202,8 +1202,8 @@ VisualScript::~VisualScript() { // Remove all nodes and stuff that hold data refs. List<int> nds; nodes.get_key_list(&nds); - for (const List<int>::Element *E = nds.front(); E; E = E->next()) { - remove_node(E->get()); + for (const int &E : nds) { + remove_node(E); } } @@ -1233,12 +1233,12 @@ bool VisualScriptInstance::get(const StringName &p_name, Variant &r_ret) const { void VisualScriptInstance::get_property_list(List<PropertyInfo> *p_properties) const { List<StringName> vars; script->variables.get_key_list(&vars); - for (const List<StringName>::Element *E = vars.front(); E; E = E->next()) { - if (!script->variables[E->get()]._export) { + for (const StringName &E : vars) { + if (!script->variables[E]._export) { continue; } - PropertyInfo p = script->variables[E->get()].info; - p.name = String(E->get()); + PropertyInfo p = script->variables[E].info; + p.name = String(E); p.usage |= PROPERTY_USAGE_SCRIPT_VARIABLE; p_properties->push_back(p); } @@ -1262,11 +1262,11 @@ Variant::Type VisualScriptInstance::get_property_type(const StringName &p_name, void VisualScriptInstance::get_method_list(List<MethodInfo> *p_list) const { List<StringName> fns; script->functions.get_key_list(&fns); - for (const List<StringName>::Element *E = fns.front(); E; E = E->next()) { + for (const StringName &E : fns) { MethodInfo mi; - mi.name = E->get(); - if (script->functions[E->get()].func_id >= 0 && script->nodes.has(script->functions[E->get()].func_id)) { - Ref<VisualScriptFunction> vsf = script->nodes[script->functions[E->get()].func_id].node; + mi.name = E; + if (script->functions[E].func_id >= 0 && script->nodes.has(script->functions[E].func_id)) { + Ref<VisualScriptFunction> vsf = script->nodes[script->functions[E].func_id].node; if (vsf.is_valid()) { for (int i = 0; i < vsf->get_argument_count(); i++) { PropertyInfo arg; @@ -1868,8 +1868,8 @@ void VisualScriptInstance::create(const Ref<VisualScript> &p_script, Object *p_o { List<StringName> keys; script->variables.get_key_list(&keys); - for (const List<StringName>::Element *E = keys.front(); E; E = E->next()) { - variables[E->get()] = script->variables[E->get()].default_value; + for (const StringName &E : keys) { + variables[E] = script->variables[E].default_value; } } @@ -1877,8 +1877,8 @@ void VisualScriptInstance::create(const Ref<VisualScript> &p_script, Object *p_o { List<StringName> keys; script->functions.get_key_list(&keys); - for (const List<StringName>::Element *E = keys.front(); E; E = E->next()) { - const VisualScript::Function vsfn = p_script->functions[E->get()]; + for (const StringName &E : keys) { + const VisualScript::Function vsfn = p_script->functions[E]; Function function; function.node = vsfn.func_id; function.max_stack = 0; @@ -1889,7 +1889,7 @@ void VisualScriptInstance::create(const Ref<VisualScript> &p_script, Object *p_o Map<StringName, int> local_var_indices; if (function.node < 0) { - VisualScriptLanguage::singleton->debug_break_parse(get_script()->get_path(), 0, "No start node in function: " + String(E->get())); + VisualScriptLanguage::singleton->debug_break_parse(get_script()->get_path(), 0, "No start node in function: " + String(E)); ERR_CONTINUE(function.node < 0); } @@ -1897,7 +1897,7 @@ void VisualScriptInstance::create(const Ref<VisualScript> &p_script, Object *p_o Ref<VisualScriptFunction> func_node = script->get_node(vsfn.func_id); if (func_node.is_null()) { - VisualScriptLanguage::singleton->debug_break_parse(get_script()->get_path(), 0, "No VisualScriptFunction typed start node in function: " + String(E->get())); + VisualScriptLanguage::singleton->debug_break_parse(get_script()->get_path(), 0, "No VisualScriptFunction typed start node in function: " + String(E)); } ERR_CONTINUE(!func_node.is_valid()); @@ -1938,12 +1938,12 @@ void VisualScriptInstance::create(const Ref<VisualScript> &p_script, Object *p_o while (!nd_queue.is_empty()) { int ky = nd_queue.front()->get(); dc_lut[ky].get_key_list(&dc_keys); - for (const List<int>::Element *F = dc_keys.front(); F; F = F->next()) { + for (const int &F : dc_keys) { VisualScript::DataConnection dc; - dc.from_node = dc_lut[ky][F->get()].first; - dc.from_port = dc_lut[ky][F->get()].second; + dc.from_node = dc_lut[ky][F].first; + dc.from_port = dc_lut[ky][F].second; dc.to_node = ky; - dc.to_port = F->get(); + dc.to_port = F; dataconns.insert(dc); nd_queue.push_back(dc.from_node); node_ids.insert(dc.from_node); @@ -2093,7 +2093,7 @@ void VisualScriptInstance::create(const Ref<VisualScript> &p_script, Object *p_o } } - functions[E->get()] = function; + functions[E] = function; } } } @@ -2467,10 +2467,10 @@ void VisualScriptLanguage::debug_get_stack_level_members(int p_level, List<Strin List<StringName> vars; vs->get_variable_list(&vars); - for (List<StringName>::Element *E = vars.front(); E; E = E->next()) { + for (const StringName &E : vars) { Variant v; - if (_call_stack[l].instance->get_variable(E->get(), &v)) { - p_members->push_back("variables/" + E->get()); + if (_call_stack[l].instance->get_variable(E, &v)) { + p_members->push_back("variables/" + E); p_values->push_back(v); } } diff --git a/modules/visual_script/visual_script_builtin_funcs.cpp b/modules/visual_script/visual_script_builtin_funcs.cpp index f17ad62531..c61c3ae272 100644 --- a/modules/visual_script/visual_script_builtin_funcs.cpp +++ b/modules/visual_script/visual_script_builtin_funcs.cpp @@ -68,7 +68,6 @@ const char *VisualScriptBuiltinFunc::func_name[VisualScriptBuiltinFunc::FUNC_MAX "inverse_lerp", "range_lerp", "move_toward", - "dectime", "randomize", "randi", "randf", @@ -206,7 +205,6 @@ int VisualScriptBuiltinFunc::get_func_argument_count(BuiltinFunc p_func) { case MATH_INVERSE_LERP: case MATH_SMOOTHSTEP: case MATH_MOVE_TOWARD: - case MATH_DECTIME: case MATH_WRAP: case MATH_WRAPF: case LOGIC_CLAMP: @@ -349,15 +347,6 @@ PropertyInfo VisualScriptBuiltinFunc::get_input_value_port_info(int p_idx) const return PropertyInfo(Variant::FLOAT, "delta"); } } break; - case MATH_DECTIME: { - if (p_idx == 0) { - return PropertyInfo(Variant::FLOAT, "value"); - } else if (p_idx == 1) { - return PropertyInfo(Variant::FLOAT, "amount"); - } else { - return PropertyInfo(Variant::FLOAT, "step"); - } - } break; case MATH_RANDOMIZE: case MATH_RANDI: case MATH_RANDF: { @@ -536,10 +525,6 @@ PropertyInfo VisualScriptBuiltinFunc::get_output_value_port_info(int p_idx) cons case MATH_RANGE_LERP: case MATH_SMOOTHSTEP: case MATH_MOVE_TOWARD: - case MATH_DECTIME: { - t = Variant::FLOAT; - - } break; case MATH_RANDOMIZE: { } break; case MATH_RANDI: { @@ -837,12 +822,6 @@ void VisualScriptBuiltinFunc::exec_func(BuiltinFunc p_func, const Variant **p_in VALIDATE_ARG_NUM(2); *r_return = Math::move_toward((double)*p_inputs[0], (double)*p_inputs[1], (double)*p_inputs[2]); } break; - case VisualScriptBuiltinFunc::MATH_DECTIME: { - VALIDATE_ARG_NUM(0); - VALIDATE_ARG_NUM(1); - VALIDATE_ARG_NUM(2); - *r_return = Math::dectime((double)*p_inputs[0], (double)*p_inputs[1], (double)*p_inputs[2]); - } break; case VisualScriptBuiltinFunc::MATH_RANDOMIZE: { Math::randomize(); @@ -1239,7 +1218,6 @@ void VisualScriptBuiltinFunc::_bind_methods() { BIND_ENUM_CONSTANT(MATH_INVERSE_LERP); BIND_ENUM_CONSTANT(MATH_RANGE_LERP); BIND_ENUM_CONSTANT(MATH_MOVE_TOWARD); - BIND_ENUM_CONSTANT(MATH_DECTIME); BIND_ENUM_CONSTANT(MATH_RANDOMIZE); BIND_ENUM_CONSTANT(MATH_RANDI); BIND_ENUM_CONSTANT(MATH_RANDF); @@ -1330,7 +1308,6 @@ void register_visual_script_builtin_func_node() { VisualScriptLanguage::singleton->add_register_func("functions/built_in/range_lerp", create_builtin_func_node<VisualScriptBuiltinFunc::MATH_RANGE_LERP>); VisualScriptLanguage::singleton->add_register_func("functions/built_in/smoothstep", create_builtin_func_node<VisualScriptBuiltinFunc::MATH_SMOOTHSTEP>); VisualScriptLanguage::singleton->add_register_func("functions/built_in/move_toward", create_builtin_func_node<VisualScriptBuiltinFunc::MATH_MOVE_TOWARD>); - VisualScriptLanguage::singleton->add_register_func("functions/built_in/dectime", create_builtin_func_node<VisualScriptBuiltinFunc::MATH_DECTIME>); VisualScriptLanguage::singleton->add_register_func("functions/built_in/randomize", create_builtin_func_node<VisualScriptBuiltinFunc::MATH_RANDOMIZE>); VisualScriptLanguage::singleton->add_register_func("functions/built_in/randi", create_builtin_func_node<VisualScriptBuiltinFunc::MATH_RANDI>); VisualScriptLanguage::singleton->add_register_func("functions/built_in/randf", create_builtin_func_node<VisualScriptBuiltinFunc::MATH_RANDF>); diff --git a/modules/visual_script/visual_script_builtin_funcs.h b/modules/visual_script/visual_script_builtin_funcs.h index 7196d4b46a..f59a7a0f0c 100644 --- a/modules/visual_script/visual_script_builtin_funcs.h +++ b/modules/visual_script/visual_script_builtin_funcs.h @@ -68,7 +68,6 @@ public: MATH_INVERSE_LERP, MATH_RANGE_LERP, MATH_MOVE_TOWARD, - MATH_DECTIME, MATH_RANDOMIZE, MATH_RANDI, MATH_RANDF, diff --git a/modules/visual_script/visual_script_editor.cpp b/modules/visual_script/visual_script_editor.cpp index 8712bfa06b..a802e8022d 100644 --- a/modules/visual_script/visual_script_editor.cpp +++ b/modules/visual_script/visual_script_editor.cpp @@ -62,7 +62,7 @@ protected: void _sig_changed() { notify_property_list_changed(); - emit_signal("changed"); + emit_signal(SNAME("changed")); } bool _set(const StringName &p_name, const Variant &p_value) { @@ -196,10 +196,10 @@ protected: void _var_changed() { notify_property_list_changed(); - emit_signal("changed"); + emit_signal(SNAME("changed")); } void _var_value_changed() { - emit_signal("changed"); + emit_signal(SNAME("changed")); } bool _set(const StringName &p_name, const Variant &p_value) { @@ -561,18 +561,16 @@ void VisualScriptEditor::_update_graph_connections() { List<VisualScript::SequenceConnection> sequence_conns; script->get_sequence_connection_list(&sequence_conns); - for (List<VisualScript::SequenceConnection>::Element *E = sequence_conns.front(); E; E = E->next()) { - graph->connect_node(itos(E->get().from_node), E->get().from_output, itos(E->get().to_node), 0); + for (const VisualScript::SequenceConnection &E : sequence_conns) { + graph->connect_node(itos(E.from_node), E.from_output, itos(E.to_node), 0); } List<VisualScript::DataConnection> data_conns; script->get_data_connection_list(&data_conns); - for (List<VisualScript::DataConnection>::Element *E = data_conns.front(); E; E = E->next()) { - VisualScript::DataConnection dc = E->get(); - - Ref<VisualScriptNode> from_node = script->get_node(E->get().from_node); - Ref<VisualScriptNode> to_node = script->get_node(E->get().to_node); + for (VisualScript::DataConnection &dc : data_conns) { + Ref<VisualScriptNode> from_node = script->get_node(dc.from_node); + Ref<VisualScriptNode> to_node = script->get_node(dc.to_node); if (to_node->has_input_sequence_port()) { dc.to_port++; @@ -580,7 +578,7 @@ void VisualScriptEditor::_update_graph_connections() { dc.from_port += from_node->get_output_sequence_port_count(); - graph->connect_node(itos(E->get().from_node), dc.from_port, itos(E->get().to_node), dc.to_port); + graph->connect_node(itos(dc.from_node), dc.from_port, itos(dc.to_node), dc.to_port); } } @@ -611,41 +609,44 @@ void VisualScriptEditor::_update_graph(int p_only_id) { select_func_text->hide(); Ref<Texture2D> type_icons[Variant::VARIANT_MAX] = { - Control::get_theme_icon("Variant", "EditorIcons"), - Control::get_theme_icon("bool", "EditorIcons"), - Control::get_theme_icon("int", "EditorIcons"), - Control::get_theme_icon("float", "EditorIcons"), - Control::get_theme_icon("String", "EditorIcons"), - Control::get_theme_icon("Vector2", "EditorIcons"), - Control::get_theme_icon("Vector2i", "EditorIcons"), - Control::get_theme_icon("Rect2", "EditorIcons"), - Control::get_theme_icon("Rect2i", "EditorIcons"), - Control::get_theme_icon("Vector3", "EditorIcons"), - Control::get_theme_icon("Vector3i", "EditorIcons"), - Control::get_theme_icon("Transform2D", "EditorIcons"), - Control::get_theme_icon("Plane", "EditorIcons"), - Control::get_theme_icon("Quaternion", "EditorIcons"), - Control::get_theme_icon("AABB", "EditorIcons"), - Control::get_theme_icon("Basis", "EditorIcons"), - Control::get_theme_icon("Transform3D", "EditorIcons"), - Control::get_theme_icon("Color", "EditorIcons"), - Control::get_theme_icon("NodePath", "EditorIcons"), - Control::get_theme_icon("RID", "EditorIcons"), - Control::get_theme_icon("MiniObject", "EditorIcons"), - Control::get_theme_icon("Callable", "EditorIcons"), - Control::get_theme_icon("Signal", "EditorIcons"), - Control::get_theme_icon("Dictionary", "EditorIcons"), - Control::get_theme_icon("Array", "EditorIcons"), - Control::get_theme_icon("PackedByteArray", "EditorIcons"), - Control::get_theme_icon("PackedInt32Array", "EditorIcons"), - Control::get_theme_icon("PackedFloat32Array", "EditorIcons"), - Control::get_theme_icon("PackedStringArray", "EditorIcons"), - Control::get_theme_icon("PackedVector2Array", "EditorIcons"), - Control::get_theme_icon("PackedVector3Array", "EditorIcons"), - Control::get_theme_icon("PackedColorArray", "EditorIcons") + Control::get_theme_icon(SNAME("Variant"), SNAME("EditorIcons")), + Control::get_theme_icon(SNAME("bool"), SNAME("EditorIcons")), + Control::get_theme_icon(SNAME("int"), SNAME("EditorIcons")), + Control::get_theme_icon(SNAME("float"), SNAME("EditorIcons")), + Control::get_theme_icon(SNAME("String"), SNAME("EditorIcons")), + Control::get_theme_icon(SNAME("Vector2"), SNAME("EditorIcons")), + Control::get_theme_icon(SNAME("Vector2i"), SNAME("EditorIcons")), + Control::get_theme_icon(SNAME("Rect2"), SNAME("EditorIcons")), + Control::get_theme_icon(SNAME("Rect2i"), SNAME("EditorIcons")), + Control::get_theme_icon(SNAME("Vector3"), SNAME("EditorIcons")), + Control::get_theme_icon(SNAME("Vector3i"), SNAME("EditorIcons")), + Control::get_theme_icon(SNAME("Transform2D"), SNAME("EditorIcons")), + Control::get_theme_icon(SNAME("Plane"), SNAME("EditorIcons")), + Control::get_theme_icon(SNAME("Quaternion"), SNAME("EditorIcons")), + Control::get_theme_icon(SNAME("AABB"), SNAME("EditorIcons")), + Control::get_theme_icon(SNAME("Basis"), SNAME("EditorIcons")), + Control::get_theme_icon(SNAME("Transform3D"), SNAME("EditorIcons")), + Control::get_theme_icon(SNAME("Color"), SNAME("EditorIcons")), + Control::get_theme_icon(SNAME("StringName"), SNAME("EditorIcons")), + Control::get_theme_icon(SNAME("NodePath"), SNAME("EditorIcons")), + Control::get_theme_icon(SNAME("RID"), SNAME("EditorIcons")), + Control::get_theme_icon(SNAME("MiniObject"), SNAME("EditorIcons")), + Control::get_theme_icon(SNAME("Callable"), SNAME("EditorIcons")), + Control::get_theme_icon(SNAME("Signal"), SNAME("EditorIcons")), + Control::get_theme_icon(SNAME("Dictionary"), SNAME("EditorIcons")), + Control::get_theme_icon(SNAME("Array"), SNAME("EditorIcons")), + Control::get_theme_icon(SNAME("PackedByteArray"), SNAME("EditorIcons")), + Control::get_theme_icon(SNAME("PackedInt32Array"), SNAME("EditorIcons")), + Control::get_theme_icon(SNAME("PackedInt64Array"), SNAME("EditorIcons")), + Control::get_theme_icon(SNAME("PackedFloat32Array"), SNAME("EditorIcons")), + Control::get_theme_icon(SNAME("PackedFloat64Array"), SNAME("EditorIcons")), + Control::get_theme_icon(SNAME("PackedStringArray"), SNAME("EditorIcons")), + Control::get_theme_icon(SNAME("PackedVector2Array"), SNAME("EditorIcons")), + Control::get_theme_icon(SNAME("PackedVector3Array"), SNAME("EditorIcons")), + Control::get_theme_icon(SNAME("PackedColorArray"), SNAME("EditorIcons")) }; - Ref<Texture2D> seq_port = Control::get_theme_icon("VisualShaderPort", "EditorIcons"); + Ref<Texture2D> seq_port = Control::get_theme_icon(SNAME("VisualShaderPort"), SNAME("EditorIcons")); List<int> node_ids; script->get_node_list(&node_ids); @@ -653,27 +654,27 @@ void VisualScriptEditor::_update_graph(int p_only_id) { script->get_node_list(&ids); StringName editor_icons = "EditorIcons"; - for (List<int>::Element *E = ids.front(); E; E = E->next()) { - if (p_only_id >= 0 && p_only_id != E->get()) { + for (int &E : ids) { + if (p_only_id >= 0 && p_only_id != E) { continue; } - Ref<VisualScriptNode> node = script->get_node(E->get()); - Vector2 pos = script->get_node_position(E->get()); + Ref<VisualScriptNode> node = script->get_node(E); + Vector2 pos = script->get_node_position(E); GraphNode *gnode = memnew(GraphNode); gnode->set_title(node->get_caption()); gnode->set_position_offset(pos * EDSCALE); - if (error_line == E->get()) { + if (error_line == E) { gnode->set_overlay(GraphNode::OVERLAY_POSITION); } else if (node->is_breakpoint()) { gnode->set_overlay(GraphNode::OVERLAY_BREAKPOINT); } gnode->set_meta("__vnode", node); - gnode->set_name(itos(E->get())); - gnode->connect("dragged", callable_mp(this, &VisualScriptEditor::_node_moved), varray(E->get())); - gnode->connect("close_request", callable_mp(this, &VisualScriptEditor::_remove_node), varray(E->get()), CONNECT_DEFERRED); + gnode->set_name(itos(E)); + gnode->connect("dragged", callable_mp(this, &VisualScriptEditor::_node_moved), varray(E)); + gnode->connect("close_request", callable_mp(this, &VisualScriptEditor::_remove_node), varray(E), CONNECT_DEFERRED); { Ref<VisualScriptFunction> v = node; @@ -693,7 +694,7 @@ void VisualScriptEditor::_update_graph(int p_only_id) { Button *btn = memnew(Button); btn->set_text(TTR("Add Input Port")); hbnc->add_child(btn); - btn->connect("pressed", callable_mp(this, &VisualScriptEditor::_add_input_port), varray(E->get()), CONNECT_DEFERRED); + btn->connect("pressed", callable_mp(this, &VisualScriptEditor::_add_input_port), varray(E), CONNECT_DEFERRED); } if (nd_list->is_output_port_editable()) { if (nd_list->is_input_port_editable()) { @@ -703,7 +704,7 @@ void VisualScriptEditor::_update_graph(int p_only_id) { Button *btn = memnew(Button); btn->set_text(TTR("Add Output Port")); hbnc->add_child(btn); - btn->connect("pressed", callable_mp(this, &VisualScriptEditor::_add_output_port), varray(E->get()), CONNECT_DEFERRED); + btn->connect("pressed", callable_mp(this, &VisualScriptEditor::_add_output_port), varray(E), CONNECT_DEFERRED); } gnode->add_child(hbnc); } else if (Object::cast_to<VisualScriptExpression>(node.ptr())) { @@ -711,9 +712,9 @@ void VisualScriptEditor::_update_graph(int p_only_id) { LineEdit *line_edit = memnew(LineEdit); line_edit->set_text(node->get_text()); line_edit->set_expand_to_text_length_enabled(true); - line_edit->add_theme_font_override("font", get_theme_font("source", "EditorFonts")); + line_edit->add_theme_font_override("font", get_theme_font(SNAME("source"), SNAME("EditorFonts"))); gnode->add_child(line_edit); - line_edit->connect("text_changed", callable_mp(this, &VisualScriptEditor::_expression_text_changed), varray(E->get())); + line_edit->connect("text_changed", callable_mp(this, &VisualScriptEditor::_expression_text_changed), varray(E)); } else { String text = node->get_text(); if (!text.is_empty()) { @@ -729,13 +730,13 @@ void VisualScriptEditor::_update_graph(int p_only_id) { gnode->set_comment(true); gnode->set_resizable(true); gnode->set_custom_minimum_size(vsc->get_size() * EDSCALE); - gnode->connect("resize_request", callable_mp(this, &VisualScriptEditor::_comment_node_resized), varray(E->get())); + gnode->connect("resize_request", callable_mp(this, &VisualScriptEditor::_comment_node_resized), varray(E)); } if (node_styles.has(node->get_category())) { Ref<StyleBoxFlat> sbf = node_styles[node->get_category()]; if (gnode->is_comment()) { - sbf = EditorNode::get_singleton()->get_theme_base()->get_theme()->get_stylebox("comment", "GraphNode"); + sbf = EditorNode::get_singleton()->get_theme_base()->get_theme()->get_stylebox(SNAME("comment"), SNAME("GraphNode")); } Color c = sbf->get_border_color(); @@ -748,7 +749,7 @@ void VisualScriptEditor::_update_graph(int p_only_id) { gnode->add_theme_style_override("frame", sbf); } - const Color mono_color = get_theme_color("mono_color", "Editor"); + const Color mono_color = get_theme_color(SNAME("mono_color"), SNAME("Editor")); int slot_idx = 0; @@ -832,8 +833,8 @@ void VisualScriptEditor::_update_graph(int p_only_id) { name_box->set_custom_minimum_size(Size2(60 * EDSCALE, 0)); name_box->set_text(left_name); name_box->set_expand_to_text_length_enabled(true); - name_box->connect("resized", callable_mp(this, &VisualScriptEditor::_update_node_size), varray(E->get())); - name_box->connect("focus_exited", callable_mp(this, &VisualScriptEditor::_port_name_focus_out), varray(name_box, E->get(), i, true)); + name_box->connect("resized", callable_mp(this, &VisualScriptEditor::_update_node_size), varray(E)); + name_box->connect("focus_exited", callable_mp(this, &VisualScriptEditor::_port_name_focus_out), varray(name_box, E, i, true)); } else { hbc->add_child(memnew(Label(left_name))); } @@ -846,18 +847,18 @@ void VisualScriptEditor::_update_graph(int p_only_id) { opbtn->select(left_type); opbtn->set_custom_minimum_size(Size2(100 * EDSCALE, 0)); hbc->add_child(opbtn); - opbtn->connect("item_selected", callable_mp(this, &VisualScriptEditor::_change_port_type), varray(E->get(), i, true), CONNECT_DEFERRED); + opbtn->connect("item_selected", callable_mp(this, &VisualScriptEditor::_change_port_type), varray(E, i, true), CONNECT_DEFERRED); } Button *rmbtn = memnew(Button); - rmbtn->set_icon(EditorNode::get_singleton()->get_gui_base()->get_theme_icon("Remove", "EditorIcons")); + rmbtn->set_icon(EditorNode::get_singleton()->get_gui_base()->get_theme_icon(SNAME("Remove"), SNAME("EditorIcons"))); hbc->add_child(rmbtn); - rmbtn->connect("pressed", callable_mp(this, &VisualScriptEditor::_remove_input_port), varray(E->get(), i), CONNECT_DEFERRED); + rmbtn->connect("pressed", callable_mp(this, &VisualScriptEditor::_remove_input_port), varray(E, i), CONNECT_DEFERRED); } else { hbc->add_child(memnew(Label(left_name))); } - if (left_type != Variant::NIL && !script->is_input_value_port_connected(E->get(), i)) { + if (left_type != Variant::NIL && !script->is_input_value_port_connected(E, i)) { PropertyInfo pi = node->get_input_value_port_info(i); Button *button = memnew(Button); Variant value = node->get_default_input_value(i); @@ -884,7 +885,7 @@ void VisualScriptEditor::_update_graph(int p_only_id) { } else { button->set_text(value); } - button->connect("pressed", callable_mp(this, &VisualScriptEditor::_default_value_edited), varray(button, E->get(), i)); + button->connect("pressed", callable_mp(this, &VisualScriptEditor::_default_value_edited), varray(button, E, i)); hbc2->add_child(button); } } else { @@ -906,9 +907,9 @@ void VisualScriptEditor::_update_graph(int p_only_id) { if (right_ok) { if (is_vslist) { Button *rmbtn = memnew(Button); - rmbtn->set_icon(EditorNode::get_singleton()->get_gui_base()->get_theme_icon("Remove", "EditorIcons")); + rmbtn->set_icon(EditorNode::get_singleton()->get_gui_base()->get_theme_icon(SNAME("Remove"), SNAME("EditorIcons"))); hbc->add_child(rmbtn); - rmbtn->connect("pressed", callable_mp(this, &VisualScriptEditor::_remove_output_port), varray(E->get(), i), CONNECT_DEFERRED); + rmbtn->connect("pressed", callable_mp(this, &VisualScriptEditor::_remove_output_port), varray(E, i), CONNECT_DEFERRED); if (nd_list->is_output_port_type_editable()) { OptionButton *opbtn = memnew(OptionButton); @@ -918,7 +919,7 @@ void VisualScriptEditor::_update_graph(int p_only_id) { opbtn->select(right_type); opbtn->set_custom_minimum_size(Size2(100 * EDSCALE, 0)); hbc->add_child(opbtn); - opbtn->connect("item_selected", callable_mp(this, &VisualScriptEditor::_change_port_type), varray(E->get(), i, false), CONNECT_DEFERRED); + opbtn->connect("item_selected", callable_mp(this, &VisualScriptEditor::_change_port_type), varray(E, i, false), CONNECT_DEFERRED); } if (nd_list->is_output_port_name_editable()) { @@ -927,8 +928,8 @@ void VisualScriptEditor::_update_graph(int p_only_id) { name_box->set_custom_minimum_size(Size2(60 * EDSCALE, 0)); name_box->set_text(right_name); name_box->set_expand_to_text_length_enabled(true); - name_box->connect("resized", callable_mp(this, &VisualScriptEditor::_update_node_size), varray(E->get())); - name_box->connect("focus_exited", callable_mp(this, &VisualScriptEditor::_port_name_focus_out), varray(name_box, E->get(), i, false)); + name_box->connect("resized", callable_mp(this, &VisualScriptEditor::_update_node_size), varray(E)); + name_box->connect("focus_exited", callable_mp(this, &VisualScriptEditor::_port_name_focus_out), varray(name_box, E, i, false)); } else { hbc->add_child(memnew(Label(right_name))); } @@ -950,7 +951,7 @@ void VisualScriptEditor::_update_graph(int p_only_id) { gnode->add_child(vbc); - bool dark_theme = get_theme_constant("dark_theme", "Editor"); + bool dark_theme = get_theme_constant(SNAME("dark_theme"), SNAME("Editor")); if (i < mixed_seq_ports) { gnode->set_slot(slot_idx, left_ok, left_type, _color_from_type(left_type, dark_theme), true, TYPE_SEQUENCE, mono_color, Ref<Texture2D>(), seq_port); } else { @@ -973,7 +974,7 @@ void VisualScriptEditor::_update_graph(int p_only_id) { graph->set_minimap_opacity(graph_minimap_opacity); // Use default_func instead of default_func for now I think that should be good stop gap solution to ensure not breaking anything. - graph->call_deferred("set_scroll_ofs", script->get_scroll() * EDSCALE); + graph->call_deferred(SNAME("set_scroll_ofs"), script->get_scroll() * EDSCALE); updating_graph = false; } @@ -983,7 +984,7 @@ void VisualScriptEditor::_change_port_type(int p_select, int p_id, int p_port, b return; } - undo_redo->create_action("Change Port Type"); + undo_redo->create_action(TTR("Change Port Type")); if (is_input) { undo_redo->add_do_method(vsn.ptr(), "set_input_data_port_type", p_port, Variant::Type(p_select)); undo_redo->add_undo_method(vsn.ptr(), "set_input_data_port_type", p_port, vsn->get_input_value_port_info(p_port).type); @@ -1015,7 +1016,7 @@ void VisualScriptEditor::_port_name_focus_out(const Node *p_name_box, int p_id, return; } - undo_redo->create_action("Change Port Name"); + undo_redo->create_action(TTR("Change Port Name")); if (is_input) { undo_redo->add_do_method(vsn.ptr(), "set_input_data_port_name", p_port, text); undo_redo->add_undo_method(vsn.ptr(), "set_input_data_port_name", p_port, vsn->get_input_value_port_info(p_port).name); @@ -1037,20 +1038,20 @@ void VisualScriptEditor::_update_members() { TreeItem *functions = members->create_item(root); functions->set_selectable(0, false); functions->set_text(0, TTR("Functions:")); - functions->add_button(0, Control::get_theme_icon("Override", "EditorIcons"), 1, false, TTR("Override an existing built-in function.")); - functions->add_button(0, Control::get_theme_icon("Add", "EditorIcons"), 0, false, TTR("Create a new function.")); - functions->set_custom_color(0, Control::get_theme_color("mono_color", "Editor")); + functions->add_button(0, Control::get_theme_icon(SNAME("Override"), SNAME("EditorIcons")), 1, false, TTR("Override an existing built-in function.")); + functions->add_button(0, Control::get_theme_icon(SNAME("Add"), SNAME("EditorIcons")), 0, false, TTR("Create a new function.")); + functions->set_custom_color(0, Control::get_theme_color(SNAME("mono_color"), SNAME("Editor"))); List<StringName> func_names; script->get_function_list(&func_names); func_names.sort_custom<StringName::AlphCompare>(); - for (List<StringName>::Element *E = func_names.front(); E; E = E->next()) { + for (const StringName &E : func_names) { TreeItem *ti = members->create_item(functions); - ti->set_text(0, E->get()); + ti->set_text(0, E); ti->set_selectable(0, true); - ti->set_metadata(0, E->get()); - ti->add_button(0, Control::get_theme_icon("Edit", "EditorIcons"), 0); - if (selected == E->get()) { + ti->set_metadata(0, E); + ti->add_button(0, Control::get_theme_icon(SNAME("Edit"), SNAME("EditorIcons")), 0); + if (selected == E) { ti->select(0); } } @@ -1058,58 +1059,58 @@ void VisualScriptEditor::_update_members() { TreeItem *variables = members->create_item(root); variables->set_selectable(0, false); variables->set_text(0, TTR("Variables:")); - variables->add_button(0, Control::get_theme_icon("Add", "EditorIcons"), -1, false, TTR("Create a new variable.")); - variables->set_custom_color(0, Control::get_theme_color("mono_color", "Editor")); + variables->add_button(0, Control::get_theme_icon(SNAME("Add"), SNAME("EditorIcons")), -1, false, TTR("Create a new variable.")); + variables->set_custom_color(0, Control::get_theme_color(SNAME("mono_color"), SNAME("Editor"))); Ref<Texture2D> type_icons[Variant::VARIANT_MAX] = { - Control::get_theme_icon("Variant", "EditorIcons"), - Control::get_theme_icon("bool", "EditorIcons"), - Control::get_theme_icon("int", "EditorIcons"), - Control::get_theme_icon("float", "EditorIcons"), - Control::get_theme_icon("String", "EditorIcons"), - Control::get_theme_icon("Vector2", "EditorIcons"), - Control::get_theme_icon("Vector2i", "EditorIcons"), - Control::get_theme_icon("Rect2", "EditorIcons"), - Control::get_theme_icon("Rect2i", "EditorIcons"), - Control::get_theme_icon("Vector3", "EditorIcons"), - Control::get_theme_icon("Vector3i", "EditorIcons"), - Control::get_theme_icon("Transform2D", "EditorIcons"), - Control::get_theme_icon("Plane", "EditorIcons"), - Control::get_theme_icon("Quaternion", "EditorIcons"), - Control::get_theme_icon("AABB", "EditorIcons"), - Control::get_theme_icon("Basis", "EditorIcons"), - Control::get_theme_icon("Transform3D", "EditorIcons"), - Control::get_theme_icon("Color", "EditorIcons"), - Control::get_theme_icon("NodePath", "EditorIcons"), - Control::get_theme_icon("RID", "EditorIcons"), - Control::get_theme_icon("MiniObject", "EditorIcons"), - Control::get_theme_icon("Callable", "EditorIcons"), - Control::get_theme_icon("Signal", "EditorIcons"), - Control::get_theme_icon("Dictionary", "EditorIcons"), - Control::get_theme_icon("Array", "EditorIcons"), - Control::get_theme_icon("PackedByteArray", "EditorIcons"), - Control::get_theme_icon("PackedInt32Array", "EditorIcons"), - Control::get_theme_icon("PackedFloat32Array", "EditorIcons"), - Control::get_theme_icon("PackedStringArray", "EditorIcons"), - Control::get_theme_icon("PackedVector2Array", "EditorIcons"), - Control::get_theme_icon("PackedVector3Array", "EditorIcons"), - Control::get_theme_icon("PackedColorArray", "EditorIcons") + Control::get_theme_icon(SNAME("Variant"), SNAME("EditorIcons")), + Control::get_theme_icon(SNAME("bool"), SNAME("EditorIcons")), + Control::get_theme_icon(SNAME("int"), SNAME("EditorIcons")), + Control::get_theme_icon(SNAME("float"), SNAME("EditorIcons")), + Control::get_theme_icon(SNAME("String"), SNAME("EditorIcons")), + Control::get_theme_icon(SNAME("Vector2"), SNAME("EditorIcons")), + Control::get_theme_icon(SNAME("Vector2i"), SNAME("EditorIcons")), + Control::get_theme_icon(SNAME("Rect2"), SNAME("EditorIcons")), + Control::get_theme_icon(SNAME("Rect2i"), SNAME("EditorIcons")), + Control::get_theme_icon(SNAME("Vector3"), SNAME("EditorIcons")), + Control::get_theme_icon(SNAME("Vector3i"), SNAME("EditorIcons")), + Control::get_theme_icon(SNAME("Transform2D"), SNAME("EditorIcons")), + Control::get_theme_icon(SNAME("Plane"), SNAME("EditorIcons")), + Control::get_theme_icon(SNAME("Quaternion"), SNAME("EditorIcons")), + Control::get_theme_icon(SNAME("AABB"), SNAME("EditorIcons")), + Control::get_theme_icon(SNAME("Basis"), SNAME("EditorIcons")), + Control::get_theme_icon(SNAME("Transform3D"), SNAME("EditorIcons")), + Control::get_theme_icon(SNAME("Color"), SNAME("EditorIcons")), + Control::get_theme_icon(SNAME("NodePath"), SNAME("EditorIcons")), + Control::get_theme_icon(SNAME("RID"), SNAME("EditorIcons")), + Control::get_theme_icon(SNAME("MiniObject"), SNAME("EditorIcons")), + Control::get_theme_icon(SNAME("Callable"), SNAME("EditorIcons")), + Control::get_theme_icon(SNAME("Signal"), SNAME("EditorIcons")), + Control::get_theme_icon(SNAME("Dictionary"), SNAME("EditorIcons")), + Control::get_theme_icon(SNAME("Array"), SNAME("EditorIcons")), + Control::get_theme_icon(SNAME("PackedByteArray"), SNAME("EditorIcons")), + Control::get_theme_icon(SNAME("PackedInt32Array"), SNAME("EditorIcons")), + Control::get_theme_icon(SNAME("PackedFloat32Array"), SNAME("EditorIcons")), + Control::get_theme_icon(SNAME("PackedStringArray"), SNAME("EditorIcons")), + Control::get_theme_icon(SNAME("PackedVector2Array"), SNAME("EditorIcons")), + Control::get_theme_icon(SNAME("PackedVector3Array"), SNAME("EditorIcons")), + Control::get_theme_icon(SNAME("PackedColorArray"), SNAME("EditorIcons")) }; List<StringName> var_names; script->get_variable_list(&var_names); - for (List<StringName>::Element *E = var_names.front(); E; E = E->next()) { + for (const StringName &E : var_names) { TreeItem *ti = members->create_item(variables); - ti->set_text(0, E->get()); + ti->set_text(0, E); - ti->set_suffix(0, "= " + _sanitized_variant_text(E->get())); - ti->set_icon(0, type_icons[script->get_variable_info(E->get()).type]); + ti->set_suffix(0, "= " + _sanitized_variant_text(E)); + ti->set_icon(0, type_icons[script->get_variable_info(E).type]); ti->set_selectable(0, true); ti->set_editable(0, true); - ti->set_metadata(0, E->get()); - if (selected == E->get()) { + ti->set_metadata(0, E); + if (selected == E) { ti->select(0); } } @@ -1117,30 +1118,30 @@ void VisualScriptEditor::_update_members() { TreeItem *_signals = members->create_item(root); _signals->set_selectable(0, false); _signals->set_text(0, TTR("Signals:")); - _signals->add_button(0, Control::get_theme_icon("Add", "EditorIcons"), -1, false, TTR("Create a new signal.")); - _signals->set_custom_color(0, Control::get_theme_color("mono_color", "Editor")); + _signals->add_button(0, Control::get_theme_icon(SNAME("Add"), SNAME("EditorIcons")), -1, false, TTR("Create a new signal.")); + _signals->set_custom_color(0, Control::get_theme_color(SNAME("mono_color"), SNAME("Editor"))); List<StringName> signal_names; script->get_custom_signal_list(&signal_names); - for (List<StringName>::Element *E = signal_names.front(); E; E = E->next()) { + for (const StringName &E : signal_names) { TreeItem *ti = members->create_item(_signals); - ti->set_text(0, E->get()); + ti->set_text(0, E); ti->set_selectable(0, true); ti->set_editable(0, true); - ti->set_metadata(0, E->get()); - if (selected == E->get()) { + ti->set_metadata(0, E); + if (selected == E) { ti->select(0); } } String base_type = script->get_instance_base_type(); String icon_type = base_type; - if (!Control::has_theme_icon(base_type, "EditorIcons")) { + if (!Control::has_theme_icon(base_type, SNAME("EditorIcons"))) { icon_type = "Object"; } base_type_select->set_text(base_type); - base_type_select->set_icon(Control::get_theme_icon(icon_type, "EditorIcons")); + base_type_select->set_icon(Control::get_theme_icon(icon_type, SNAME("EditorIcons"))); updating_members = false; } @@ -1234,8 +1235,8 @@ void VisualScriptEditor::_member_edited() { // Also fix all function calls. List<int> lst; script->get_node_list(&lst); - for (List<int>::Element *F = lst.front(); F; F = F->next()) { - Ref<VisualScriptFunctionCall> fncall = script->get_node(F->get()); + for (int &F : lst) { + Ref<VisualScriptFunctionCall> fncall = script->get_node(F); if (!fncall.is_valid()) { continue; } @@ -1366,7 +1367,7 @@ void VisualScriptEditor::_add_func_input() { hbox->add_child(type_box); Button *delete_button = memnew(Button); - delete_button->set_icon(EditorNode::get_singleton()->get_gui_base()->get_theme_icon("Remove", "EditorIcons")); + delete_button->set_icon(EditorNode::get_singleton()->get_gui_base()->get_theme_icon(SNAME("Remove"), SNAME("EditorIcons"))); delete_button->set_tooltip(vformat(TTR("Delete input port"))); hbox->add_child(delete_button); @@ -1569,13 +1570,13 @@ void VisualScriptEditor::_remove_output_port(int p_id, int p_port) { script->get_data_connection_list(&data_connections); HashMap<int, Set<int>> conn_map; - for (const List<VisualScript::DataConnection>::Element *E = data_connections.front(); E; E = E->next()) { - if (E->get().from_node == p_id && E->get().from_port == p_port) { + for (const VisualScript::DataConnection &E : data_connections) { + if (E.from_node == p_id && E.from_port == p_port) { // Push into the connections map. - if (!conn_map.has(E->get().to_node)) { - conn_map.set(E->get().to_node, Set<int>()); + if (!conn_map.has(E.to_node)) { + conn_map.set(E.to_node, Set<int>()); } - conn_map[E->get().to_node].insert(E->get().to_port); + conn_map[E.to_node].insert(E.to_port); } } @@ -1584,9 +1585,9 @@ void VisualScriptEditor::_remove_output_port(int p_id, int p_port) { List<int> keys; conn_map.get_key_list(&keys); - for (const List<int>::Element *E = keys.front(); E; E = E->next()) { - for (const Set<int>::Element *F = conn_map[E->get()].front(); F; F = F->next()) { - undo_redo->add_undo_method(script.ptr(), "data_connect", p_id, p_port, E->get(), F->get()); + for (const int &E : keys) { + for (const Set<int>::Element *F = conn_map[E].front(); F; F = F->next()) { + undo_redo->add_undo_method(script.ptr(), "data_connect", p_id, p_port, E, F); } } @@ -1639,8 +1640,8 @@ Vector2 VisualScriptEditor::_get_available_pos(bool p_centered, Vector2 p_pos) c bool exists = false; List<int> existing; script->get_node_list(&existing); - for (List<int>::Element *E = existing.front(); E; E = E->next()) { - Point2 pos = script->get_node_position(E->get()); + for (int &E : existing) { + Point2 pos = script->get_node_position(E); if (pos.distance_to(p_pos) < 50) { p_pos += Vector2(graph->get_snap(), graph->get_snap()); exists = true; @@ -1695,8 +1696,8 @@ void VisualScriptEditor::_on_nodes_delete() { undo_redo->create_action(TTR("Remove VisualScript Nodes")); - for (List<int>::Element *F = to_erase.front(); F; F = F->next()) { - int cr_node = F->get(); + for (int &F : to_erase) { + int cr_node = F; undo_redo->add_do_method(script.ptr(), "remove_node", cr_node); undo_redo->add_undo_method(script.ptr(), "add_node", cr_node, script->get_node(cr_node), script->get_node_position(cr_node)); @@ -1704,18 +1705,18 @@ void VisualScriptEditor::_on_nodes_delete() { List<VisualScript::SequenceConnection> sequence_conns; script->get_sequence_connection_list(&sequence_conns); - for (List<VisualScript::SequenceConnection>::Element *E = sequence_conns.front(); E; E = E->next()) { - if (E->get().from_node == cr_node || E->get().to_node == cr_node) { - undo_redo->add_undo_method(script.ptr(), "sequence_connect", E->get().from_node, E->get().from_output, E->get().to_node); + for (const VisualScript::SequenceConnection &E : sequence_conns) { + if (E.from_node == cr_node || E.to_node == cr_node) { + undo_redo->add_undo_method(script.ptr(), "sequence_connect", E.from_node, E.from_output, E.to_node); } } List<VisualScript::DataConnection> data_conns; script->get_data_connection_list(&data_conns); - for (List<VisualScript::DataConnection>::Element *E = data_conns.front(); E; E = E->next()) { - if (E->get().from_node == F->get() || E->get().to_node == F->get()) { - undo_redo->add_undo_method(script.ptr(), "data_connect", E->get().from_node, E->get().from_port, E->get().to_node, E->get().to_port); + for (const VisualScript::DataConnection &E : data_conns) { + if (E.from_node == F || E.to_node == F) { + undo_redo->add_undo_method(script.ptr(), "data_connect", E.from_node, E.from_port, E.to_node, E.to_port); } } } @@ -1764,17 +1765,17 @@ void VisualScriptEditor::_on_nodes_duplicate() { List<VisualScript::SequenceConnection> seqs; script->get_sequence_connection_list(&seqs); - for (List<VisualScript::SequenceConnection>::Element *E = seqs.front(); E; E = E->next()) { - if (to_duplicate.has(E->get().from_node) && to_duplicate.has(E->get().to_node)) { - undo_redo->add_do_method(script.ptr(), "sequence_connect", remap[E->get().from_node], E->get().from_output, remap[E->get().to_node]); + for (const VisualScript::SequenceConnection &E : seqs) { + if (to_duplicate.has(E.from_node) && to_duplicate.has(E.to_node)) { + undo_redo->add_do_method(script.ptr(), "sequence_connect", remap[E.from_node], E.from_output, remap[E.to_node]); } } List<VisualScript::DataConnection> data; script->get_data_connection_list(&data); - for (List<VisualScript::DataConnection>::Element *E = data.front(); E; E = E->next()) { - if (to_duplicate.has(E->get().from_node) && to_duplicate.has(E->get().to_node)) { - undo_redo->add_do_method(script.ptr(), "data_connect", remap[E->get().from_node], E->get().from_port, remap[E->get().to_node], E->get().to_port); + for (const VisualScript::DataConnection &E : data) { + if (to_duplicate.has(E.from_node) && to_duplicate.has(E.to_node)) { + undo_redo->add_do_method(script.ptr(), "data_connect", remap[E.from_node], E.from_port, remap[E.to_node], E.to_port); } } @@ -1900,8 +1901,8 @@ void VisualScriptEditor::_rename_function(const String &name, const String &new_ // Also fix all function calls. List<int> lst; script->get_node_list(&lst); - for (List<int>::Element *F = lst.front(); F; F = F->next()) { - Ref<VisualScriptFunctionCall> fncall = script->get_node(F->get()); + for (int &F : lst) { + Ref<VisualScriptFunctionCall> fncall = script->get_node(F); if (!fncall.is_valid()) { continue; } @@ -2172,6 +2173,11 @@ void VisualScriptEditor::drop_data_fw(const Point2 &p_point, const Variant &p_da } if (String(d["type"]) == "files") { +#ifdef OSX_ENABLED + bool use_preload = Input::get_singleton()->is_key_pressed(KEY_META); +#else + bool use_preload = Input::get_singleton()->is_key_pressed(KEY_CTRL); +#endif Vector2 pos = _get_pos_in_graph(p_point); Array files = d["files"]; @@ -2180,20 +2186,29 @@ void VisualScriptEditor::drop_data_fw(const Point2 &p_point, const Variant &p_da int new_id = script->get_available_id(); if (files.size()) { - undo_redo->create_action(TTR("Add Preload Node")); + undo_redo->create_action(TTR("Add Node(s)")); for (int i = 0; i < files.size(); i++) { Ref<Resource> res = ResourceLoader::load(files[i]); if (!res.is_valid()) { continue; } + Ref<Script> drop_script = ResourceLoader::load(files[i]); + if (drop_script.is_valid() && drop_script->is_tool() && drop_script->get_instance_base_type() == "VisualScriptCustomNode" && !use_preload) { + Ref<VisualScriptCustomNode> vscn; + vscn.instantiate(); + vscn->set_script(drop_script); + + undo_redo->add_do_method(script.ptr(), "add_node", new_id, vscn, pos); + undo_redo->add_undo_method(script.ptr(), "remove_node", new_id); + } else { + Ref<VisualScriptPreload> prnode; + prnode.instantiate(); + prnode->set_preload(res); - Ref<VisualScriptPreload> prnode; - prnode.instantiate(); - prnode->set_preload(res); - - undo_redo->add_do_method(script.ptr(), "add_node", new_id, prnode, pos); - undo_redo->add_undo_method(script.ptr(), "remove_node", new_id); + undo_redo->add_do_method(script.ptr(), "add_node", new_id, prnode, pos); + undo_redo->add_undo_method(script.ptr(), "remove_node", new_id); + } new_ids.push_back(new_id); new_id++; pos += Vector2(20, 20); @@ -2204,8 +2219,8 @@ void VisualScriptEditor::drop_data_fw(const Point2 &p_point, const Variant &p_da undo_redo->commit_action(); } - for (List<int>::Element *E = new_ids.front(); E; E = E->next()) { - Node *node = graph->get_node(itos(E->get())); + for (int &E : new_ids) { + Node *node = graph->get_node(itos(E)); if (node) { graph->set_selected(node); _node_selected(node); @@ -2234,41 +2249,35 @@ void VisualScriptEditor::drop_data_fw(const Point2 &p_point, const Variant &p_da undo_redo->create_action(TTR("Add Node(s) From Tree")); int base_id = script->get_available_id(); - if (nodes.size() > 1) { - use_node = true; - } - - for (int i = 0; i < nodes.size(); i++) { - NodePath np = nodes[i]; - Node *node = get_node(np); - if (!node) { - continue; - } + if (use_node || nodes.size() > 1) { + for (int i = 0; i < nodes.size(); i++) { + NodePath np = nodes[i]; + Node *node = get_node(np); + if (!node) { + continue; + } - Ref<VisualScriptNode> n; + Ref<VisualScriptNode> n; - if (use_node) { Ref<VisualScriptSceneNode> scene_node; scene_node.instantiate(); scene_node->set_node_path(sn->get_path_to(node)); n = scene_node; - } else { - // ! Doesn't work properly. - Ref<VisualScriptFunctionCall> call; - call.instantiate(); - call->set_call_mode(VisualScriptFunctionCall::CALL_MODE_NODE_PATH); - call->set_base_path(sn->get_path_to(node)); - call->set_base_type(node->get_class()); - n = call; - method_select->select_from_instance(node, "", true, node->get_class()); - selecting_method_id = base_id; - } - undo_redo->add_do_method(script.ptr(), "add_node", base_id, n, pos); - undo_redo->add_undo_method(script.ptr(), "remove_node", base_id); + undo_redo->add_do_method(script.ptr(), "add_node", base_id, n, pos); + undo_redo->add_undo_method(script.ptr(), "remove_node", base_id); + + base_id++; + pos += Vector2(25, 25); + } - base_id++; - pos += Vector2(25, 25); + } else { + NodePath np = nodes[0]; + Node *node = get_node(np); + drop_position = pos; + drop_node = node; + drop_path = sn->get_path_to(node); + new_connect_node_select->select_from_instance(node, "", false, node->get_class()); } undo_redo->add_do_method(this, "_update_graph"); undo_redo->add_undo_method(this, "_update_graph"); @@ -2387,21 +2396,13 @@ void VisualScriptEditor::drop_data_fw(const Point2 &p_point, const Variant &p_da } } -void VisualScriptEditor::_selected_method(const String &p_method, const String &p_type, const bool p_connecting) { - Ref<VisualScriptFunctionCall> vsfc = script->get_node(selecting_method_id); - if (!vsfc.is_valid()) { - return; - } - vsfc->set_function(p_method); -} - void VisualScriptEditor::_draw_color_over_button(Object *obj, Color p_color) { Button *button = Object::cast_to<Button>(obj); if (!button) { return; } - Ref<StyleBox> normal = get_theme_stylebox("normal", "Button"); + Ref<StyleBox> normal = get_theme_stylebox(SNAME("normal"), SNAME("Button")); button->draw_rect(Rect2(normal->get_offset(), button->get_size() - normal->get_minimum_size()), p_color); } @@ -2447,7 +2448,7 @@ void VisualScriptEditor::set_edited_resource(const RES &p_res) { script->connect("node_ports_changed", callable_mp(this, &VisualScriptEditor::_node_ports_changed)); _update_graph(); - call_deferred("_update_members"); + call_deferred(SNAME("_update_members")); } void VisualScriptEditor::enable_editor() { @@ -2481,7 +2482,7 @@ String VisualScriptEditor::get_name() { } Ref<Texture2D> VisualScriptEditor::get_theme_icon() { - return Control::get_theme_icon("VisualScript", "EditorIcons"); + return Control::get_theme_icon(SNAME("VisualScript"), SNAME("EditorIcons")); } bool VisualScriptEditor::is_unsaved() { @@ -2551,12 +2552,12 @@ void VisualScriptEditor::goto_line(int p_line, bool p_with_error) { List<StringName> functions; script->get_function_list(&functions); - for (List<StringName>::Element *E = functions.front(); E; E = E->next()) { + for (const StringName &E : functions) { if (script->has_node(p_line)) { _update_graph(); _update_members(); - call_deferred("call_deferred", "_center_on_node", E->get(), p_line); //editor might be just created and size might not exist yet + call_deferred(SNAME("call_deferred"), "_center_on_node", E, p_line); //editor might be just created and size might not exist yet return; } } @@ -2597,13 +2598,13 @@ Array VisualScriptEditor::get_breakpoints() { Array breakpoints; List<StringName> functions; script->get_function_list(&functions); - for (List<StringName>::Element *E = functions.front(); E; E = E->next()) { + for (int i = 0; i < functions.size(); i++) { List<int> nodes; script->get_node_list(&nodes); - for (List<int>::Element *F = nodes.front(); F; F = F->next()) { - Ref<VisualScriptNode> vsn = script->get_node(F->get()); + for (int &F : nodes) { + Ref<VisualScriptNode> vsn = script->get_node(F); if (vsn->is_breakpoint()) { - breakpoints.push_back(F->get() - 1); // Subtract 1 because breakpoints in text start from zero. + breakpoints.push_back(F - 1); // Subtract 1 because breakpoints in text start from zero. } } } @@ -2772,18 +2773,18 @@ void VisualScriptEditor::_remove_node(int p_id) { List<VisualScript::SequenceConnection> sequence_conns; script->get_sequence_connection_list(&sequence_conns); - for (List<VisualScript::SequenceConnection>::Element *E = sequence_conns.front(); E; E = E->next()) { - if (E->get().from_node == p_id || E->get().to_node == p_id) { - undo_redo->add_undo_method(script.ptr(), "sequence_connect", E->get().from_node, E->get().from_output, E->get().to_node); + for (const VisualScript::SequenceConnection &E : sequence_conns) { + if (E.from_node == p_id || E.to_node == p_id) { + undo_redo->add_undo_method(script.ptr(), "sequence_connect", E.from_node, E.from_output, E.to_node); } } List<VisualScript::DataConnection> data_conns; script->get_data_connection_list(&data_conns); - for (List<VisualScript::DataConnection>::Element *E = data_conns.front(); E; E = E->next()) { - if (E->get().from_node == p_id || E->get().to_node == p_id) { - undo_redo->add_undo_method(script.ptr(), "data_connect", E->get().from_node, E->get().from_port, E->get().to_node, E->get().to_port); + for (const VisualScript::DataConnection &E : data_conns) { + if (E.from_node == p_id || E.to_node == p_id) { + undo_redo->add_undo_method(script.ptr(), "data_connect", E.from_node, E.from_port, E.to_node, E.to_port); } } @@ -2801,9 +2802,9 @@ bool VisualScriptEditor::node_has_sequence_connections(int p_id) { List<VisualScript::SequenceConnection> sequence_conns; script->get_sequence_connection_list(&sequence_conns); - for (List<VisualScript::SequenceConnection>::Element *E = sequence_conns.front(); E; E = E->next()) { - int from = E->get().from_node; - int to = E->get().to_node; + for (const VisualScript::SequenceConnection &E : sequence_conns) { + int from = E.from_node; + int to = E.to_node; if (to == p_id || from == p_id) { return true; @@ -2836,6 +2837,20 @@ void VisualScriptEditor::_graph_connected(const String &p_from, int p_from_slot, ERR_FAIL_COND(from_seq != to_seq); + // Checking to prevent warnings. + if (from_seq) { + if (script->has_sequence_connection(p_from.to_int(), from_port, p_to.to_int())) { + return; + } + } else if (script->has_data_connection(p_from.to_int(), from_port, p_to.to_int(), to_port)) { + return; + } + + // Preventing connection to itself. + if (p_from.to_int() == p_to.to_int()) { + return; + } + // Do all the checks here. StringName func; // This the func where we store the one the nodes at the end of the resolution on having multiple nodes. @@ -2989,7 +3004,7 @@ VisualScriptNode::TypeGuess VisualScriptEditor::_guess_output_type(int p_port_ac Ref<VisualScriptNode> node = script->get_node(p_port_action_node); - if (!node.is_valid()) { + if (!node.is_valid() || node->get_output_value_port_count() <= p_port_action_output) { return tg; } @@ -3122,6 +3137,11 @@ void VisualScriptEditor::_selected_connect_node(const String &p_text, const Stri Set<int> vn; + if (drop_position != Vector2()) { + pos = drop_position; + } + drop_position = Vector2(); + bool port_node_exists = true; // if (func == StringName()) { @@ -3175,18 +3195,62 @@ void VisualScriptEditor::_selected_connect_node(const String &p_text, const Stri if (p_category == String("method")) { Ref<VisualScriptFunctionCall> n; n.instantiate(); + if (!drop_path.is_empty()) { + if (drop_path == ".") { + n->set_call_mode(VisualScriptFunctionCall::CALL_MODE_SELF); + } else { + n->set_call_mode(VisualScriptFunctionCall::CALL_MODE_NODE_PATH); + n->set_base_path(drop_path); + } + } + if (drop_node) { + n->set_base_type(drop_node->get_class()); + if (drop_node->get_script_instance()) { + n->set_base_script(drop_node->get_script_instance()->get_script()->get_path()); + } + } vnode = n; } else if (p_category == String("set")) { Ref<VisualScriptPropertySet> n; n.instantiate(); + if (!drop_path.is_empty()) { + if (drop_path == ".") { + n->set_call_mode(VisualScriptPropertySet::CALL_MODE_SELF); + } else { + n->set_call_mode(VisualScriptPropertySet::CALL_MODE_NODE_PATH); + n->set_base_path(drop_path); + } + } + if (drop_node) { + n->set_base_type(drop_node->get_class()); + if (drop_node->get_script_instance()) { + n->set_base_script(drop_node->get_script_instance()->get_script()->get_path()); + } + } vnode = n; script_prop_set = n; } else if (p_category == String("get")) { Ref<VisualScriptPropertyGet> n; n.instantiate(); n->set_property(p_text); + if (!drop_path.is_empty()) { + if (drop_path == ".") { + n->set_call_mode(VisualScriptPropertyGet::CALL_MODE_SELF); + } else { + n->set_call_mode(VisualScriptPropertyGet::CALL_MODE_NODE_PATH); + n->set_base_path(drop_path); + } + } + if (drop_node) { + n->set_base_type(drop_node->get_class()); + if (drop_node->get_script_instance()) { + n->set_base_script(drop_node->get_script_instance()->get_script()->get_path()); + } + } vnode = n; } + drop_path = String(); + drop_node = nullptr; if (p_category == String("action")) { if (p_text == "VisualScriptCondition") { @@ -3396,9 +3460,9 @@ void VisualScriptEditor::_selected_new_virtual_method(const String &p_text, cons List<MethodInfo> methods; bool found = false; ClassDB::get_virtual_methods(script->get_instance_base_type(), &methods); - for (List<MethodInfo>::Element *E = methods.front(); E; E = E->next()) { - if (E->get().name == name) { - minfo = E->get(); + for (const MethodInfo &E : methods) { + if (E.name == name) { + minfo = E; found = true; } } @@ -3547,9 +3611,9 @@ void VisualScriptEditor::_notification(int p_what) { return; } - edit_variable_edit->add_theme_style_override("bg", get_theme_stylebox("bg", "Tree")); - edit_signal_edit->add_theme_style_override("bg", get_theme_stylebox("bg", "Tree")); - func_input_scroll->add_theme_style_override("bg", get_theme_stylebox("bg", "Tree")); + edit_variable_edit->add_theme_style_override("bg", get_theme_stylebox(SNAME("bg"), SNAME("Tree"))); + edit_signal_edit->add_theme_style_override("bg", get_theme_stylebox(SNAME("bg"), SNAME("Tree"))); + func_input_scroll->add_theme_style_override("bg", get_theme_stylebox(SNAME("bg"), SNAME("Tree"))); Ref<Theme> tm = EditorNode::get_singleton()->get_theme_base()->get_theme(); @@ -3572,7 +3636,7 @@ void VisualScriptEditor::_notification(int p_what) { } for (Map<StringName, Color>::Element *E = node_colors.front(); E; E = E->next()) { - const Ref<StyleBoxFlat> sb = tm->get_stylebox("frame", "GraphNode"); + const Ref<StyleBoxFlat> sb = tm->get_stylebox(SNAME("frame"), SNAME("GraphNode")); if (!sb.is_null()) { Ref<StyleBoxFlat> frame_style = sb->duplicate(); @@ -3668,8 +3732,8 @@ void VisualScriptEditor::_menu_option(int p_what) { _update_graph(); - for (List<String>::Element *E = reselect.front(); E; E = E->next()) { - GraphNode *gn = Object::cast_to<GraphNode>(graph->get_node(E->get())); + for (const String &E : reselect) { + GraphNode *gn = Object::cast_to<GraphNode>(graph->get_node(E)); gn->set_selected(true); } @@ -3708,18 +3772,18 @@ void VisualScriptEditor::_menu_option(int p_what) { List<VisualScript::SequenceConnection> sequence_connections; script->get_sequence_connection_list(&sequence_connections); - for (List<VisualScript::SequenceConnection>::Element *E = sequence_connections.front(); E; E = E->next()) { - if (clipboard->nodes.has(E->get().from_node) && clipboard->nodes.has(E->get().to_node)) { - clipboard->sequence_connections.insert(E->get()); + for (const VisualScript::SequenceConnection &E : sequence_connections) { + if (clipboard->nodes.has(E.from_node) && clipboard->nodes.has(E.to_node)) { + clipboard->sequence_connections.insert(E); } } List<VisualScript::DataConnection> data_connections; script->get_data_connection_list(&data_connections); - for (List<VisualScript::DataConnection>::Element *E = data_connections.front(); E; E = E->next()) { - if (clipboard->nodes.has(E->get().from_node) && clipboard->nodes.has(E->get().to_node)) { - clipboard->data_connections.insert(E->get()); + for (const VisualScript::DataConnection &E : data_connections) { + if (clipboard->nodes.has(E.from_node) && clipboard->nodes.has(E.to_node)) { + clipboard->data_connections.insert(E); } } if (p_what == EDIT_CUT_NODES) { @@ -3745,8 +3809,8 @@ void VisualScriptEditor::_menu_option(int p_what) { { List<int> nodes; script->get_node_list(&nodes); - for (List<int>::Element *E = nodes.front(); E; E = E->next()) { - Vector2 pos = script->get_node_position(E->get()).snapped(Vector2(2, 2)); + for (int &E : nodes) { + Vector2 pos = script->get_node_position(E).snapped(Vector2(2, 2)); existing_positions.insert(pos); } } @@ -3869,22 +3933,22 @@ void VisualScriptEditor::_menu_option(int p_what) { // Pick the node with input sequence. Set<int> nodes_from; Set<int> nodes_to; - for (List<VisualScript::SequenceConnection>::Element *E = seqs.front(); E; E = E->next()) { - if (nodes.has(E->get().from_node) && nodes.has(E->get().to_node)) { - seqmove.insert(E->get()); - nodes_from.insert(E->get().from_node); - } else if (nodes.has(E->get().from_node) && !nodes.has(E->get().to_node)) { - seqext.insert(E->get()); - } else if (!nodes.has(E->get().from_node) && nodes.has(E->get().to_node)) { + for (const VisualScript::SequenceConnection &E : seqs) { + if (nodes.has(E.from_node) && nodes.has(E.to_node)) { + seqmove.insert(E); + nodes_from.insert(E.from_node); + } else if (nodes.has(E.from_node) && !nodes.has(E.to_node)) { + seqext.insert(E); + } else if (!nodes.has(E.from_node) && nodes.has(E.to_node)) { if (start_node == -1) { - seqext.insert(E->get()); - start_node = E->get().to_node; + seqext.insert(E); + start_node = E.to_node; } else { EditorNode::get_singleton()->show_warning(TTR("Try to only have one sequence input in selection.")); return; } } - nodes_to.insert(E->get().to_node); + nodes_to.insert(E.to_node); } // To use to add return nodes. @@ -3912,20 +3976,20 @@ void VisualScriptEditor::_menu_option(int p_what) { { List<VisualScript::DataConnection> dats; script->get_data_connection_list(&dats); - for (List<VisualScript::DataConnection>::Element *E = dats.front(); E; E = E->next()) { - if (nodes.has(E->get().from_node) && nodes.has(E->get().to_node)) { - datamove.insert(E->get()); - } else if (!nodes.has(E->get().from_node) && nodes.has(E->get().to_node)) { + for (const VisualScript::DataConnection &E : dats) { + if (nodes.has(E.from_node) && nodes.has(E.to_node)) { + datamove.insert(E); + } else if (!nodes.has(E.from_node) && nodes.has(E.to_node)) { // Add all these as inputs for the Function. - Ref<VisualScriptNode> node = script->get_node(E->get().to_node); + Ref<VisualScriptNode> node = script->get_node(E.to_node); if (node.is_valid()) { - dataext.insert(E->get()); - PropertyInfo pi = node->get_input_value_port_info(E->get().to_port); + dataext.insert(E); + PropertyInfo pi = node->get_input_value_port_info(E.to_port); inputs.push_back(pi.type); - input_connections.push_back(Pair<int, int>(E->get().to_node, E->get().to_port)); + input_connections.push_back(Pair<int, int>(E.to_node, E.to_port)); } - } else if (nodes.has(E->get().from_node) && !nodes.has(E->get().to_node)) { - dataext.insert(E->get()); + } else if (nodes.has(E.from_node) && !nodes.has(E.to_node)) { + dataext.insert(E); } } } @@ -4026,9 +4090,9 @@ void VisualScriptEditor::_menu_option(int p_what) { // but I hope that it will not be a problem considering that we won't be creating functions so frequently, // and cyclic connections would be a problem but hopefully we won't let them get to this point. void VisualScriptEditor::_get_ends(int p_node, const List<VisualScript::SequenceConnection> &p_seqs, const Set<int> &p_selected, Set<int> &r_end_nodes) { - for (const List<VisualScript::SequenceConnection>::Element *E = p_seqs.front(); E; E = E->next()) { - int from = E->get().from_node; - int to = E->get().to_node; + for (const VisualScript::SequenceConnection &E : p_seqs) { + int from = E.from_node; + int to = E.to_node; if (from == p_node && p_selected.has(to)) { // This is an interior connection move forward to the to node. @@ -4052,9 +4116,9 @@ void VisualScriptEditor::_member_rmb_selected(const Vector2 &p_pos) { TreeItem *root = members->get_root(); - Ref<Texture2D> del_icon = Control::get_theme_icon("Remove", "EditorIcons"); + Ref<Texture2D> del_icon = Control::get_theme_icon(SNAME("Remove"), SNAME("EditorIcons")); - Ref<Texture2D> edit_icon = Control::get_theme_icon("Edit", "EditorIcons"); + Ref<Texture2D> edit_icon = Control::get_theme_icon(SNAME("Edit"), SNAME("EditorIcons")); if (ti->get_parent() == root->get_first_child()) { member_type = MEMBER_FUNCTION; @@ -4102,16 +4166,16 @@ void VisualScriptEditor::_member_option(int p_option) { undo_redo->add_undo_method(script.ptr(), "add_node", fn_node, script->get_node(fn_node), script->get_node_position(fn_node)); List<VisualScript::SequenceConnection> seqcons; script->get_sequence_connection_list(&seqcons); - for (const List<VisualScript::SequenceConnection>::Element *E = seqcons.front(); E; E = E->next()) { - if (E->get().from_node == fn_node) { - undo_redo->add_undo_method(script.ptr(), "sequence_connect", fn_node, E->get().from_output, E->get().to_node); + for (const VisualScript::SequenceConnection &E : seqcons) { + if (E.from_node == fn_node) { + undo_redo->add_undo_method(script.ptr(), "sequence_connect", fn_node, E.from_output, E.to_node); } } List<VisualScript::DataConnection> datcons; script->get_data_connection_list(&datcons); - for (const List<VisualScript::DataConnection>::Element *E = datcons.front(); E; E = E->next()) { - if (E->get().from_node == fn_node) { - undo_redo->add_undo_method(script.ptr(), "data_connect", fn_node, E->get().from_port, E->get().to_node, E->get().to_port); + for (const VisualScript::DataConnection &E : datcons) { + if (E.from_node == fn_node) { + undo_redo->add_undo_method(script.ptr(), "data_connect", fn_node, E.from_port, E.to_node, E.to_port); } } undo_redo->add_do_method(this, "_update_members"); @@ -4223,7 +4287,7 @@ VisualScriptEditor::VisualScriptEditor() { members_section = memnew(VBoxContainer); // Add but wait until done setting up this. - ScriptEditor::get_singleton()->get_left_list_split()->call_deferred("add_child", members_section); + ScriptEditor::get_singleton()->get_left_list_split()->call_deferred(SNAME("add_child"), members_section); members_section->set_v_size_flags(SIZE_EXPAND_FILL); CheckButton *tool_script_check = memnew(CheckButton); @@ -4415,11 +4479,6 @@ VisualScriptEditor::VisualScriptEditor() { add_child(default_value_edit); default_value_edit->connect("variant_changed", callable_mp(this, &VisualScriptEditor::_default_value_changed)); - method_select = memnew(VisualScriptPropertySelector); - add_child(method_select); - method_select->connect("selected", callable_mp(this, &VisualScriptEditor::_selected_method)); - error_line = -1; - new_connect_node_select = memnew(VisualScriptPropertySelector); add_child(new_connect_node_select); new_connect_node_select->connect("selected", callable_mp(this, &VisualScriptEditor::_selected_connect_node)); @@ -4489,14 +4548,14 @@ void _VisualScriptEditor::add_custom_node(const String &p_name, const String &p_ String node_name = "custom/" + p_category + "/" + p_name; custom_nodes.insert(node_name, p_script); VisualScriptLanguage::singleton->add_register_func(node_name, &_VisualScriptEditor::create_node_custom); - emit_signal("custom_nodes_updated"); + emit_signal(SNAME("custom_nodes_updated")); } void _VisualScriptEditor::remove_custom_node(const String &p_name, const String &p_category) { String node_name = "custom/" + p_category + "/" + p_name; custom_nodes.erase(node_name); VisualScriptLanguage::singleton->remove_register_func(node_name); - emit_signal("custom_nodes_updated"); + emit_signal(SNAME("custom_nodes_updated")); } void _VisualScriptEditor::_bind_methods() { diff --git a/modules/visual_script/visual_script_editor.h b/modules/visual_script/visual_script_editor.h index 1f0f087be7..3b7ed3dba6 100644 --- a/modules/visual_script/visual_script_editor.h +++ b/modules/visual_script/visual_script_editor.h @@ -179,6 +179,9 @@ class VisualScriptEditor : public ScriptEditorBase { void connect_data(Ref<VisualScriptNode> vnode_old, Ref<VisualScriptNode> vnode, int new_id); + NodePath drop_path; + Node *drop_node = nullptr; + Vector2 drop_position; void _selected_connect_node(const String &p_text, const String &p_category, const bool p_connecting = true); void connect_seq(Ref<VisualScriptNode> vnode_old, Ref<VisualScriptNode> vnode_new, int new_id); @@ -270,9 +273,6 @@ class VisualScriptEditor : public ScriptEditorBase { void _graph_ofs_changed(const Vector2 &p_ofs); void _comment_node_resized(const Vector2 &p_new_size, int p_node); - int selecting_method_id; - void _selected_method(const String &p_method, const String &p_type, const bool p_connecting); - void _draw_color_over_button(Object *obj, Color p_color); void _button_resource_previewed(const String &p_path, const Ref<Texture2D> &p_preview, const Ref<Texture2D> &p_small_preview, Variant p_ud); diff --git a/modules/visual_script/visual_script_expression.cpp b/modules/visual_script/visual_script_expression.cpp index d63fbeb726..99b7275008 100644 --- a/modules/visual_script/visual_script_expression.cpp +++ b/modules/visual_script/visual_script_expression.cpp @@ -526,10 +526,10 @@ Error VisualScriptExpression::_get_token(Token &r_token) { r_token.value = Math_TAU; } else if (id == "INF") { r_token.type = TK_CONSTANT; - r_token.value = Math_INF; + r_token.value = INFINITY; } else if (id == "NAN") { r_token.type = TK_CONSTANT; - r_token.value = Math_NAN; + r_token.value = NAN; } else if (id == "not") { r_token.type = TK_OP_NOT; } else if (id == "or") { diff --git a/modules/visual_script/visual_script_flow_control.cpp b/modules/visual_script/visual_script_flow_control.cpp index af86f90b25..62a4f465cb 100644 --- a/modules/visual_script/visual_script_flow_control.cpp +++ b/modules/visual_script/visual_script_flow_control.cpp @@ -852,11 +852,11 @@ void VisualScriptTypeCast::_bind_methods() { } String script_ext_hint; - for (List<String>::Element *E = script_extensions.front(); E; E = E->next()) { + for (const String &E : script_extensions) { if (script_ext_hint != String()) { script_ext_hint += ","; } - script_ext_hint += "*." + E->get(); + script_ext_hint += "*." + E; } ADD_PROPERTY(PropertyInfo(Variant::STRING, "base_type", PROPERTY_HINT_TYPE_STRING, "Object"), "set_base_type", "get_base_type"); diff --git a/modules/visual_script/visual_script_func_nodes.cpp b/modules/visual_script/visual_script_func_nodes.cpp index 8f7b514881..6ba5ad4fd6 100644 --- a/modules/visual_script/visual_script_func_nodes.cpp +++ b/modules/visual_script/visual_script_func_nodes.cpp @@ -254,25 +254,32 @@ PropertyInfo VisualScriptFunctionCall::get_output_value_port_info(int p_idx) con } String VisualScriptFunctionCall::get_caption() const { - if (call_mode == CALL_MODE_SELF) { - return " " + String(function) + "()"; - } - if (call_mode == CALL_MODE_SINGLETON) { - return String(singleton) + ":" + String(function) + "()"; - } else if (call_mode == CALL_MODE_BASIC_TYPE) { - return Variant::get_type_name(basic_type) + "." + String(function) + "()"; - } else if (call_mode == CALL_MODE_NODE_PATH) { - return " [" + String(base_path.simplified()) + "]." + String(function) + "()"; - } else { - return " " + base_type + "." + String(function) + "()"; - } + return " " + String(function) + "()"; } String VisualScriptFunctionCall::get_text() const { + String text; + + if (call_mode == CALL_MODE_BASIC_TYPE) { + text = String("On ") + Variant::get_type_name(basic_type); + } else if (call_mode == CALL_MODE_INSTANCE) { + text = String("On ") + base_type; + } else if (call_mode == CALL_MODE_NODE_PATH) { + text = "[" + String(base_path.simplified()) + "]"; + } else if (call_mode == CALL_MODE_SELF) { + text = "On Self"; + } else if (call_mode == CALL_MODE_SINGLETON) { + text = String(singleton) + ":" + String(function) + "()"; + } + if (rpc_call_mode) { - return "RPC"; + text += " RPC"; + if (rpc_call_mode == RPC_UNRELIABLE || rpc_call_mode == RPC_UNRELIABLE_TO_ID) { + text += " UNREL"; + } } - return ""; + + return text; } void VisualScriptFunctionCall::set_basic_type(Variant::Type p_type) { @@ -531,11 +538,11 @@ void VisualScriptFunctionCall::_validate_property(PropertyInfo &property) const Engine::get_singleton()->get_singletons(&names); property.hint = PROPERTY_HINT_ENUM; String sl; - for (List<Engine::Singleton>::Element *E = names.front(); E; E = E->next()) { + for (const Engine::Singleton &E : names) { if (sl != String()) { sl += ","; } - sl += E->get().name; + sl += E.name; } property.hint_string = sl; } @@ -676,11 +683,11 @@ void VisualScriptFunctionCall::_bind_methods() { } String script_ext_hint; - for (List<String>::Element *E = script_extensions.front(); E; E = E->next()) { + for (const String &E : script_extensions) { if (script_ext_hint != String()) { script_ext_hint += ","; } - script_ext_hint += "*." + E->get(); + script_ext_hint += "*." + E; } ADD_PROPERTY(PropertyInfo(Variant::INT, "call_mode", PROPERTY_HINT_ENUM, "Self,Node Path,Instance,Basic Type,Singleton"), "set_call_mode", "get_call_mode"); @@ -901,11 +908,11 @@ static Ref<VisualScriptNode> create_function_call_node(const String &p_name) { ////////////////////////////////////////// int VisualScriptPropertySet::get_output_sequence_port_count() const { - return call_mode != CALL_MODE_BASIC_TYPE ? 1 : 0; + return 1; } bool VisualScriptPropertySet::has_input_sequence_port() const { - return call_mode != CALL_MODE_BASIC_TYPE; + return 1; } Node *VisualScriptPropertySet::_get_base_node() const { @@ -990,31 +997,33 @@ PropertyInfo VisualScriptPropertySet::get_input_value_port_info(int p_idx) const if (p_idx == 0) { PropertyInfo pi; pi.type = (call_mode == CALL_MODE_INSTANCE ? Variant::OBJECT : basic_type); - pi.name = (call_mode == CALL_MODE_INSTANCE ? String("instance") : Variant::get_type_name(basic_type).to_lower()); - _adjust_input_index(pi); + pi.name = "instance"; return pi; } } List<PropertyInfo> props; ClassDB::get_property_list(_get_base_type(), &props, false); - for (List<PropertyInfo>::Element *E = props.front(); E; E = E->next()) { - if (E->get().name == property) { - PropertyInfo pinfo = PropertyInfo(E->get().type, "value", PROPERTY_HINT_TYPE_STRING, E->get().hint_string); + for (const PropertyInfo &E : props) { + if (E.name == property) { + String detail_prop_name = property; + if (index != StringName()) { + detail_prop_name += "." + String(index); + } + PropertyInfo pinfo = PropertyInfo(E.type, detail_prop_name, PROPERTY_HINT_TYPE_STRING, E.hint_string); _adjust_input_index(pinfo); return pinfo; } } PropertyInfo pinfo = type_cache; - pinfo.name = "value"; _adjust_input_index(pinfo); return pinfo; } PropertyInfo VisualScriptPropertySet::get_output_value_port_info(int p_idx) const { if (call_mode == CALL_MODE_BASIC_TYPE) { - return PropertyInfo(basic_type, "out"); + return PropertyInfo(basic_type, "pass"); } else if (call_mode == CALL_MODE_INSTANCE) { return PropertyInfo(Variant::OBJECT, "pass", PROPERTY_HINT_TYPE_STRING, get_base_type()); } else { @@ -1036,17 +1045,18 @@ String VisualScriptPropertySet::get_caption() const { } String VisualScriptPropertySet::get_text() const { + if (!has_input_sequence_port()) { + return ""; + } if (call_mode == CALL_MODE_BASIC_TYPE) { return String("On ") + Variant::get_type_name(basic_type); + } else if (call_mode == CALL_MODE_INSTANCE) { + return String("On ") + base_type; + } else if (call_mode == CALL_MODE_NODE_PATH) { + return " [" + String(base_path.simplified()) + "]"; + } else { + return "On Self"; } - - static const char *cname[3] = { - "Self", - "Scene Node", - "Instance" - }; - - return String("On ") + cname[call_mode]; } void VisualScriptPropertySet::_update_base_type() { @@ -1125,9 +1135,9 @@ void VisualScriptPropertySet::_update_cache() { List<PropertyInfo> pinfo; v.get_property_list(&pinfo); - for (List<PropertyInfo>::Element *E = pinfo.front(); E; E = E->next()) { - if (E->get().name == property) { - type_cache = E->get(); + for (const PropertyInfo &E : pinfo) { + if (E.name == property) { + type_cache = E; } } @@ -1176,9 +1186,9 @@ void VisualScriptPropertySet::_update_cache() { script->get_script_property_list(&pinfo); } - for (List<PropertyInfo>::Element *E = pinfo.front(); E; E = E->next()) { - if (E->get().name == property) { - type_cache = E->get(); + for (const PropertyInfo &E : pinfo) { + if (E.name == property) { + type_cache = E; return; } } @@ -1344,8 +1354,8 @@ void VisualScriptPropertySet::_validate_property(PropertyInfo &property) const { List<PropertyInfo> plist; v.get_property_list(&plist); String options = ""; - for (List<PropertyInfo>::Element *E = plist.front(); E; E = E->next()) { - options += "," + E->get().name; + for (const PropertyInfo &E : plist) { + options += "," + E.name; } property.hint = PROPERTY_HINT_ENUM; @@ -1400,11 +1410,11 @@ void VisualScriptPropertySet::_bind_methods() { } String script_ext_hint; - for (List<String>::Element *E = script_extensions.front(); E; E = E->next()) { + for (const String &E : script_extensions) { if (script_ext_hint != String()) { script_ext_hint += ","; } - script_ext_hint += "*." + E->get(); + script_ext_hint += "*." + E; } ADD_PROPERTY(PropertyInfo(Variant::INT, "set_mode", PROPERTY_HINT_ENUM, "Self,Node Path,Instance,Basic Type"), "set_call_mode", "get_call_mode"); @@ -1707,7 +1717,9 @@ int VisualScriptPropertyGet::get_input_value_port_count() const { } int VisualScriptPropertyGet::get_output_value_port_count() const { - return 1; + int pc = (call_mode == CALL_MODE_BASIC_TYPE || call_mode == CALL_MODE_INSTANCE) ? 2 : 1; + + return pc; } String VisualScriptPropertyGet::get_output_sequence_port_text(int p_port) const { @@ -1727,33 +1739,46 @@ PropertyInfo VisualScriptPropertyGet::get_input_value_port_info(int p_idx) const } PropertyInfo VisualScriptPropertyGet::get_output_value_port_info(int p_idx) const { - List<PropertyInfo> props; - ClassDB::get_property_list(_get_base_type(), &props, false); - for (List<PropertyInfo>::Element *E = props.front(); E; E = E->next()) { - if (E->get().name == property) { - return PropertyInfo(E->get().type, "value." + String(index)); + if (call_mode == CALL_MODE_BASIC_TYPE && p_idx == 0) { + return PropertyInfo(basic_type, "pass"); + } else if (call_mode == CALL_MODE_INSTANCE && p_idx == 0) { + return PropertyInfo(Variant::OBJECT, "pass", PROPERTY_HINT_TYPE_STRING, get_base_type()); + } else { + List<PropertyInfo> props; + ClassDB::get_property_list(_get_base_type(), &props, false); + for (List<PropertyInfo>::Element *E = props.front(); E; E = E->next()) { + if (E->get().name == property) { + PropertyInfo pinfo = PropertyInfo(E->get().type, String(property) + "." + String(index), E->get().hint, E->get().hint_string); + _adjust_input_index(pinfo); + return pinfo; + } } } - return PropertyInfo(type_cache, "value"); + PropertyInfo pinfo = PropertyInfo(type_cache, "value"); + _adjust_input_index(pinfo); + return pinfo; } String VisualScriptPropertyGet::get_caption() const { - return String("Get ") + property; + String prop = String("Get ") + property; + if (index != StringName()) { + prop += "." + String(index); + } + + return prop; } String VisualScriptPropertyGet::get_text() const { if (call_mode == CALL_MODE_BASIC_TYPE) { return String("On ") + Variant::get_type_name(basic_type); + } else if (call_mode == CALL_MODE_INSTANCE) { + return String("On ") + base_type; + } else if (call_mode == CALL_MODE_NODE_PATH) { + return " [" + String(base_path.simplified()) + "]"; + } else { + return "On Self"; } - - static const char *cname[3] = { - "Self", - "Scene Node", - "Instance" - }; - - return String("On ") + cname[call_mode]; } void VisualScriptPropertyGet::set_base_type(const StringName &p_type) { @@ -1795,9 +1820,9 @@ void VisualScriptPropertyGet::_update_cache() { List<PropertyInfo> pinfo; v.get_property_list(&pinfo); - for (List<PropertyInfo>::Element *E = pinfo.front(); E; E = E->next()) { - if (E->get().name == property) { - type_cache = E->get().type; + for (const PropertyInfo &E : pinfo) { + if (E.name == property) { + type_cache = E.type; return; } } @@ -1933,6 +1958,19 @@ Variant::Type VisualScriptPropertyGet::_get_type_cache() const { return type_cache; } +void VisualScriptPropertyGet::_adjust_input_index(PropertyInfo &pinfo) const { + if (index != StringName()) { + Variant v; + Callable::CallError ce; + Variant::construct(pinfo.type, v, nullptr, 0, ce); + Variant i = v.get(index); + pinfo.type = i.get_type(); + pinfo.name = String(property) + "." + index; + } else { + pinfo.name = String(property); + } +} + void VisualScriptPropertyGet::set_index(const StringName &p_type) { if (index == p_type) { return; @@ -2021,8 +2059,8 @@ void VisualScriptPropertyGet::_validate_property(PropertyInfo &property) const { List<PropertyInfo> plist; v.get_property_list(&plist); String options = ""; - for (List<PropertyInfo>::Element *E = plist.front(); E; E = E->next()) { - options += "," + E->get().name; + for (const PropertyInfo &E : plist) { + options += "," + E.name; } property.hint = PROPERTY_HINT_ENUM; @@ -2074,11 +2112,11 @@ void VisualScriptPropertyGet::_bind_methods() { } String script_ext_hint; - for (List<String>::Element *E = script_extensions.front(); E; E = E->next()) { + for (const String &E : script_extensions) { if (script_ext_hint != String()) { script_ext_hint += ","; } - script_ext_hint += "." + E->get(); + script_ext_hint += "." + E; } ADD_PROPERTY(PropertyInfo(Variant::INT, "set_mode", PROPERTY_HINT_ENUM, "Self,Node Path,Instance,Basic Type"), "set_call_mode", "get_call_mode"); @@ -2159,15 +2197,17 @@ public: bool valid; Variant v = *p_inputs[0]; - *p_outputs[0] = v.get(property, &valid); + *p_outputs[1] = v.get(property, &valid); if (index != StringName()) { - *p_outputs[0] = p_outputs[0]->get_named(index, valid); + *p_outputs[1] = p_outputs[1]->get_named(index, valid); } if (!valid) { r_error.error = Callable::CallError::CALL_ERROR_INVALID_METHOD; r_error_str = RTR("Invalid index property name."); } + + *p_outputs[0] = v; }; } @@ -2283,11 +2323,11 @@ void VisualScriptEmitSignal::_validate_property(PropertyInfo &property) const { } String ml; - for (List<StringName>::Element *E = sigs.front(); E; E = E->next()) { + for (const StringName &E : sigs) { if (ml != String()) { ml += ","; } - ml += E->get(); + ml += E; } property.hint_string = ml; @@ -2378,8 +2418,8 @@ void register_visual_script_func_nodes() { List<MethodInfo> ml; vt.get_method_list(&ml); - for (List<MethodInfo>::Element *E = ml.front(); E; E = E->next()) { - VisualScriptLanguage::singleton->add_register_func("functions/by_type/" + type_name + "/" + E->get().name, create_basic_type_call_node); + for (const MethodInfo &E : ml) { + VisualScriptLanguage::singleton->add_register_func("functions/by_type/" + type_name + "/" + E.name, create_basic_type_call_node); } } } diff --git a/modules/visual_script/visual_script_func_nodes.h b/modules/visual_script/visual_script_func_nodes.h index eb17be1fbe..cca08455f9 100644 --- a/modules/visual_script/visual_script_func_nodes.h +++ b/modules/visual_script/visual_script_func_nodes.h @@ -272,6 +272,8 @@ private: void _set_type_cache(Variant::Type p_type); Variant::Type _get_type_cache() const; + void _adjust_input_index(PropertyInfo &pinfo) const; + protected: virtual void _validate_property(PropertyInfo &property) const override; diff --git a/modules/visual_script/visual_script_nodes.cpp b/modules/visual_script/visual_script_nodes.cpp index b93c710652..c517d89aa5 100644 --- a/modules/visual_script/visual_script_nodes.cpp +++ b/modules/visual_script/visual_script_nodes.cpp @@ -191,7 +191,10 @@ PropertyInfo VisualScriptFunction::get_input_value_port_info(int p_idx) const { } PropertyInfo VisualScriptFunction::get_output_value_port_info(int p_idx) const { - ERR_FAIL_INDEX_V(p_idx, arguments.size(), PropertyInfo()); + // Need to check it without ERR_FAIL_COND, to prevent warnings from appearing on node creation via dragging. + if (p_idx < 0 || p_idx >= arguments.size()) { + return PropertyInfo(); + } PropertyInfo out; out.type = arguments[p_idx].type; out.name = arguments[p_idx].name; @@ -1303,12 +1306,12 @@ void VisualScriptVariableGet::_validate_property(PropertyInfo &property) const { vs->get_variable_list(&vars); String vhint; - for (List<StringName>::Element *E = vars.front(); E; E = E->next()) { + for (const StringName &E : vars) { if (vhint != String()) { vhint += ","; } - vhint += E->get().operator String(); + vhint += E.operator String(); } property.hint = PROPERTY_HINT_ENUM; @@ -1413,12 +1416,12 @@ void VisualScriptVariableSet::_validate_property(PropertyInfo &property) const { vs->get_variable_list(&vars); String vhint; - for (List<StringName>::Element *E = vars.front(); E; E = E->next()) { + for (const StringName &E : vars) { if (vhint != String()) { vhint += ","; } - vhint += E->get().operator String(); + vhint += E.operator String(); } property.hint = PROPERTY_HINT_ENUM; @@ -1941,8 +1944,8 @@ void VisualScriptClassConstant::set_base_type(const StringName &p_which) { ClassDB::get_integer_constant_list(base_type, &constants, true); if (constants.size() > 0) { bool found_name = false; - for (List<String>::Element *E = constants.front(); E; E = E->next()) { - if (E->get() == name) { + for (const String &E : constants) { + if (E == name) { found_name = true; break; } @@ -1990,11 +1993,11 @@ void VisualScriptClassConstant::_validate_property(PropertyInfo &property) const ClassDB::get_integer_constant_list(base_type, &constants, true); property.hint_string = ""; - for (List<String>::Element *E = constants.front(); E; E = E->next()) { + for (const String &E : constants) { if (property.hint_string != String()) { property.hint_string += ","; } - property.hint_string += E->get(); + property.hint_string += E; } } } @@ -2075,8 +2078,8 @@ void VisualScriptBasicTypeConstant::set_basic_type(Variant::Type p_which) { Variant::get_constants_for_type(type, &constants); if (constants.size() > 0) { bool found_name = false; - for (List<StringName>::Element *E = constants.front(); E; E = E->next()) { - if (E->get() == name) { + for (const StringName &E : constants) { + if (E == name) { found_name = true; break; } @@ -2128,11 +2131,11 @@ void VisualScriptBasicTypeConstant::_validate_property(PropertyInfo &property) c return; } property.hint_string = ""; - for (List<StringName>::Element *E = constants.front(); E; E = E->next()) { + for (const StringName &E : constants) { if (property.hint_string != String()) { property.hint_string += ","; } - property.hint_string += String(E->get()); + property.hint_string += String(E); } } } @@ -2179,8 +2182,8 @@ double VisualScriptMathConstant::const_value[MATH_CONSTANT_MAX] = { Math_TAU, 2.71828182845904523536, Math::sqrt(2.0), - Math_INF, - Math_NAN + INFINITY, + NAN }; int VisualScriptMathConstant::get_output_sequence_port_count() const { @@ -2355,15 +2358,15 @@ void VisualScriptEngineSingleton::_validate_property(PropertyInfo &property) con Engine::get_singleton()->get_singletons(&singletons); - for (List<Engine::Singleton>::Element *E = singletons.front(); E; E = E->next()) { - if (E->get().name == "VS" || E->get().name == "PS" || E->get().name == "PS2D" || E->get().name == "AS" || E->get().name == "TS" || E->get().name == "SS" || E->get().name == "SS2D") { + for (const Engine::Singleton &E : singletons) { + if (E.name == "VS" || E.name == "PS" || E.name == "PS2D" || E.name == "AS" || E.name == "TS" || E.name == "SS" || E.name == "SS2D") { continue; //skip these, too simple named } if (cc != String()) { cc += ","; } - cc += E->get().name; + cc += E.name; } property.hint = PROPERTY_HINT_ENUM; @@ -2865,6 +2868,12 @@ PropertyInfo VisualScriptCustomNode::get_input_value_port_info(int p_idx) const if (get_script_instance() && get_script_instance()->has_method("_get_input_value_port_name")) { info.name = get_script_instance()->call("_get_input_value_port_name", p_idx); } + if (get_script_instance() && get_script_instance()->has_method("_get_input_value_port_hint")) { + info.hint = PropertyHint(int(get_script_instance()->call("_get_input_value_port_hint", p_idx))); + } + if (get_script_instance() && get_script_instance()->has_method("_get_input_value_port_hint_string")) { + info.hint_string = get_script_instance()->call("_get_input_value_port_hint_string", p_idx); + } return info; } @@ -2876,9 +2885,31 @@ PropertyInfo VisualScriptCustomNode::get_output_value_port_info(int p_idx) const if (get_script_instance() && get_script_instance()->has_method("_get_output_value_port_name")) { info.name = get_script_instance()->call("_get_output_value_port_name", p_idx); } + if (get_script_instance() && get_script_instance()->has_method("_get_output_value_port_hint")) { + info.hint = PropertyHint(int(get_script_instance()->call("_get_output_value_port_hint", p_idx))); + } + if (get_script_instance() && get_script_instance()->has_method("_get_output_value_port_hint_string")) { + info.hint_string = get_script_instance()->call("_get_output_value_port_hint_string", p_idx); + } return info; } +VisualScriptCustomNode::TypeGuess VisualScriptCustomNode::guess_output_type(TypeGuess *p_inputs, int p_output) const { + TypeGuess tg; + PropertyInfo pi = VisualScriptCustomNode::get_output_value_port_info(p_output); + tg.type = pi.type; + if (pi.type == Variant::OBJECT) { + if (pi.hint == PROPERTY_HINT_RESOURCE_TYPE) { + if (pi.hint_string.is_resource_file()) { + tg.script = ResourceLoader::load(pi.hint_string); + } else if (ClassDB::class_exists(pi.hint_string)) { + tg.gdclass = pi.hint_string; + } + } + } + return tg; +} + String VisualScriptCustomNode::get_caption() const { if (get_script_instance() && get_script_instance()->has_method("_get_caption")) { return get_script_instance()->call("_get_caption"); @@ -2987,7 +3018,7 @@ VisualScriptNodeInstance *VisualScriptCustomNode::instantiate(VisualScriptInstan } void VisualScriptCustomNode::_script_changed() { - call_deferred("ports_changed_notify"); + call_deferred(SNAME("ports_changed_notify")); } void VisualScriptCustomNode::_bind_methods() { @@ -3000,9 +3031,13 @@ void VisualScriptCustomNode::_bind_methods() { BIND_VMETHOD(MethodInfo(Variant::INT, "_get_input_value_port_type", PropertyInfo(Variant::INT, "idx"))); BIND_VMETHOD(MethodInfo(Variant::STRING, "_get_input_value_port_name", PropertyInfo(Variant::INT, "idx"))); + BIND_VMETHOD(MethodInfo(Variant::INT, "_get_input_value_port_hint", PropertyInfo(Variant::INT, "idx"))); + BIND_VMETHOD(MethodInfo(Variant::STRING, "_get_input_value_port_hint_string", PropertyInfo(Variant::INT, "idx"))); BIND_VMETHOD(MethodInfo(Variant::INT, "_get_output_value_port_type", PropertyInfo(Variant::INT, "idx"))); BIND_VMETHOD(MethodInfo(Variant::STRING, "_get_output_value_port_name", PropertyInfo(Variant::INT, "idx"))); + BIND_VMETHOD(MethodInfo(Variant::INT, "_get_output_value_port_hint", PropertyInfo(Variant::INT, "idx"))); + BIND_VMETHOD(MethodInfo(Variant::STRING, "_get_output_value_port_hint_string", PropertyInfo(Variant::INT, "idx"))); BIND_VMETHOD(MethodInfo(Variant::STRING, "_get_caption")); BIND_VMETHOD(MethodInfo(Variant::STRING, "_get_text")); @@ -3714,9 +3749,7 @@ void VisualScriptInputAction::_validate_property(PropertyInfo &property) const { ProjectSettings::get_singleton()->get_property_list(&pinfo); Vector<String> al; - for (List<PropertyInfo>::Element *E = pinfo.front(); E; E = E->next()) { - const PropertyInfo &pi = E->get(); - + for (const PropertyInfo &pi : pinfo) { if (!pi.name.begins_with("input/")) { continue; } @@ -3809,10 +3842,10 @@ void VisualScriptDeconstruct::_update_elements() { List<PropertyInfo> pinfo; v.get_property_list(&pinfo); - for (List<PropertyInfo>::Element *E = pinfo.front(); E; E = E->next()) { + for (const PropertyInfo &E : pinfo) { Element e; - e.name = E->get().name; - e.type = E->get().type; + e.name = E.name; + e.type = E.type; elements.push_back(e); } } @@ -3990,24 +4023,24 @@ void register_visual_script_nodes() { List<MethodInfo> constructors; Variant::get_constructor_list(Variant::Type(i), &constructors); - for (List<MethodInfo>::Element *E = constructors.front(); E; E = E->next()) { - if (E->get().arguments.size() > 0) { + for (const MethodInfo &E : constructors) { + if (E.arguments.size() > 0) { String name = "functions/constructors/" + Variant::get_type_name(Variant::Type(i)) + "("; - for (int j = 0; j < E->get().arguments.size(); j++) { + for (int j = 0; j < E.arguments.size(); j++) { if (j > 0) { name += ", "; } - if (E->get().arguments.size() == 1) { - name += Variant::get_type_name(E->get().arguments[j].type); + if (E.arguments.size() == 1) { + name += Variant::get_type_name(E.arguments[j].type); } else { - name += E->get().arguments[j].name; + name += E.arguments[j].name; } } name += ")"; VisualScriptLanguage::singleton->add_register_func(name, create_constructor_node); Pair<Variant::Type, MethodInfo> pair; pair.first = Variant::Type(i); - pair.second = E->get(); + pair.second = E; constructor_map[name] = pair; } } diff --git a/modules/visual_script/visual_script_nodes.h b/modules/visual_script/visual_script_nodes.h index b599b92b3a..2390e5c7bc 100644 --- a/modules/visual_script/visual_script_nodes.h +++ b/modules/visual_script/visual_script_nodes.h @@ -792,6 +792,8 @@ public: virtual VisualScriptNodeInstance *instantiate(VisualScriptInstance *p_instance) override; + virtual TypeGuess guess_output_type(TypeGuess *p_inputs, int p_output) const override; + void _script_changed(); VisualScriptCustomNode(); diff --git a/modules/visual_script/visual_script_property_selector.cpp b/modules/visual_script/visual_script_property_selector.cpp index 79addc5828..8bf1c6cbfa 100644 --- a/modules/visual_script/visual_script_property_selector.cpp +++ b/modules/visual_script/visual_script_property_selector.cpp @@ -93,43 +93,49 @@ void VisualScriptPropertySelector::_update_search() { base = ClassDB::get_parent_class_nocheck(base); } - for (List<StringName>::Element *E = base_list.front(); E; E = E->next()) { + for (const StringName &E : base_list) { List<MethodInfo> methods; List<PropertyInfo> props; TreeItem *category = nullptr; Ref<Texture2D> type_icons[Variant::VARIANT_MAX] = { - vbc->get_theme_icon("Variant", "EditorIcons"), - vbc->get_theme_icon("bool", "EditorIcons"), - vbc->get_theme_icon("int", "EditorIcons"), - vbc->get_theme_icon("float", "EditorIcons"), - vbc->get_theme_icon("String", "EditorIcons"), - vbc->get_theme_icon("Vector2", "EditorIcons"), - vbc->get_theme_icon("Rect2", "EditorIcons"), - vbc->get_theme_icon("Vector3", "EditorIcons"), - vbc->get_theme_icon("Transform2D", "EditorIcons"), - vbc->get_theme_icon("Plane", "EditorIcons"), - vbc->get_theme_icon("Quaternion", "EditorIcons"), - vbc->get_theme_icon("AABB", "EditorIcons"), - vbc->get_theme_icon("Basis", "EditorIcons"), - vbc->get_theme_icon("Transform3D", "EditorIcons"), - vbc->get_theme_icon("Color", "EditorIcons"), - vbc->get_theme_icon("Path", "EditorIcons"), - vbc->get_theme_icon("RID", "EditorIcons"), - vbc->get_theme_icon("Object", "EditorIcons"), - vbc->get_theme_icon("Dictionary", "EditorIcons"), - vbc->get_theme_icon("Array", "EditorIcons"), - vbc->get_theme_icon("PackedByteArray", "EditorIcons"), - vbc->get_theme_icon("PackedInt32Array", "EditorIcons"), - vbc->get_theme_icon("PackedFloat32Array", "EditorIcons"), - vbc->get_theme_icon("PackedInt64Array", "EditorIcons"), - vbc->get_theme_icon("PackedFloat64Array", "EditorIcons"), - vbc->get_theme_icon("PackedStringArray", "EditorIcons"), - vbc->get_theme_icon("PackedVector2Array", "EditorIcons"), - vbc->get_theme_icon("PackedVector3Array", "EditorIcons"), - vbc->get_theme_icon("PackedColorArray", "EditorIcons") + vbc->get_theme_icon(SNAME("Variant"), SNAME("EditorIcons")), + vbc->get_theme_icon(SNAME("bool"), SNAME("EditorIcons")), + vbc->get_theme_icon(SNAME("int"), SNAME("EditorIcons")), + vbc->get_theme_icon(SNAME("float"), SNAME("EditorIcons")), + vbc->get_theme_icon(SNAME("String"), SNAME("EditorIcons")), + vbc->get_theme_icon(SNAME("Vector2"), SNAME("EditorIcons")), + vbc->get_theme_icon(SNAME("Vector2i"), SNAME("EditorIcons")), + vbc->get_theme_icon(SNAME("Rect2"), SNAME("EditorIcons")), + vbc->get_theme_icon(SNAME("Rect2i"), SNAME("EditorIcons")), + vbc->get_theme_icon(SNAME("Vector3"), SNAME("EditorIcons")), + vbc->get_theme_icon(SNAME("Vector3i"), SNAME("EditorIcons")), + vbc->get_theme_icon(SNAME("Transform2D"), SNAME("EditorIcons")), + vbc->get_theme_icon(SNAME("Plane"), SNAME("EditorIcons")), + vbc->get_theme_icon(SNAME("Quaternion"), SNAME("EditorIcons")), + vbc->get_theme_icon(SNAME("AABB"), SNAME("EditorIcons")), + vbc->get_theme_icon(SNAME("Basis"), SNAME("EditorIcons")), + vbc->get_theme_icon(SNAME("Transform3D"), SNAME("EditorIcons")), + vbc->get_theme_icon(SNAME("Color"), SNAME("EditorIcons")), + vbc->get_theme_icon(SNAME("StringName"), SNAME("EditorIcons")), + vbc->get_theme_icon(SNAME("NodePath"), SNAME("EditorIcons")), + vbc->get_theme_icon(SNAME("RID"), SNAME("EditorIcons")), + vbc->get_theme_icon(SNAME("MiniObject"), SNAME("EditorIcons")), + vbc->get_theme_icon(SNAME("Callable"), SNAME("EditorIcons")), + vbc->get_theme_icon(SNAME("Signal"), SNAME("EditorIcons")), + vbc->get_theme_icon(SNAME("Dictionary"), SNAME("EditorIcons")), + vbc->get_theme_icon(SNAME("Array"), SNAME("EditorIcons")), + vbc->get_theme_icon(SNAME("PackedByteArray"), SNAME("EditorIcons")), + vbc->get_theme_icon(SNAME("PackedInt32Array"), SNAME("EditorIcons")), + vbc->get_theme_icon(SNAME("PackedInt64Array"), SNAME("EditorIcons")), + vbc->get_theme_icon(SNAME("PackedFloat32Array"), SNAME("EditorIcons")), + vbc->get_theme_icon(SNAME("PackedFloat64Array"), SNAME("EditorIcons")), + vbc->get_theme_icon(SNAME("PackedStringArray"), SNAME("EditorIcons")), + vbc->get_theme_icon(SNAME("PackedVector2Array"), SNAME("EditorIcons")), + vbc->get_theme_icon(SNAME("PackedVector3Array"), SNAME("EditorIcons")), + vbc->get_theme_icon(SNAME("PackedColorArray"), SNAME("EditorIcons")) }; { - String b = String(E->get()); + String b = String(E); category = search_options->create_item(root); if (category) { category->set_text(0, b.replace_first("*", "")); @@ -148,30 +154,30 @@ void VisualScriptPropertySelector::_update_search() { if (Object::cast_to<Script>(obj)) { Object::cast_to<Script>(obj)->get_script_property_list(&props); } else { - ClassDB::get_property_list(E->get(), &props, true); + ClassDB::get_property_list(E, &props, true); } } - for (List<PropertyInfo>::Element *F = props.front(); F; F = F->next()) { - if (!(F->get().usage & PROPERTY_USAGE_EDITOR) && !(F->get().usage & PROPERTY_USAGE_SCRIPT_VARIABLE)) { + for (const PropertyInfo &F : props) { + if (!(F.usage & PROPERTY_USAGE_EDITOR) && !(F.usage & PROPERTY_USAGE_SCRIPT_VARIABLE)) { continue; } - if (type_filter.size() && type_filter.find(F->get().type) == -1) { + if (type_filter.size() && type_filter.find(F.type) == -1) { continue; } // capitalize() also converts underscore to space, we'll match again both possible styles - String get_text_raw = String(vformat(TTR("Get %s"), F->get().name)); + String get_text_raw = String(vformat(TTR("Get %s"), F.name)); String get_text = get_text_raw.capitalize(); - String set_text_raw = String(vformat(TTR("Set %s"), F->get().name)); + String set_text_raw = String(vformat(TTR("Set %s"), F.name)); String set_text = set_text_raw.capitalize(); String input = search_box->get_text().capitalize(); if (input == String() || get_text_raw.findn(input) != -1 || get_text.findn(input) != -1) { TreeItem *item = search_options->create_item(category ? category : root); item->set_text(0, get_text); - item->set_metadata(0, F->get().name); - item->set_icon(0, type_icons[F->get().type]); + item->set_metadata(0, F.name); + item->set_icon(0, type_icons[F.type]); item->set_metadata(1, "get"); item->set_collapsed(true); item->set_selectable(0, true); @@ -183,8 +189,8 @@ void VisualScriptPropertySelector::_update_search() { if (input == String() || set_text_raw.findn(input) != -1 || set_text.findn(input) != -1) { TreeItem *item = search_options->create_item(category ? category : root); item->set_text(0, set_text); - item->set_metadata(0, F->get().name); - item->set_icon(0, type_icons[F->get().type]); + item->set_metadata(0, F.name); + item->set_icon(0, type_icons[F.type]); item->set_metadata(1, "set"); item->set_selectable(0, true); item->set_selectable(1, false); @@ -205,7 +211,7 @@ void VisualScriptPropertySelector::_update_search() { Object::cast_to<Script>(obj)->get_script_method_list(&methods); } - ClassDB::get_method_list(E->get(), &methods, true, true); + ClassDB::get_method_list(E, &methods, true, true); } } for (List<MethodInfo>::Element *M = methods.front(); M; M = M->next()) { @@ -253,7 +259,7 @@ void VisualScriptPropertySelector::_update_search() { TreeItem *item = search_options->create_item(category ? category : root); item->set_text(0, desc); - item->set_icon(0, vbc->get_theme_icon("MemberMethod", "EditorIcons")); + item->set_icon(0, vbc->get_theme_icon(SNAME("MemberMethod"), SNAME("EditorIcons"))); item->set_metadata(0, name); item->set_selectable(0, true); @@ -317,7 +323,7 @@ void VisualScriptPropertySelector::create_visualscript_item(const String &name, if (search_input == String() || text.findn(search_input) != -1) { TreeItem *item = search_options->create_item(root); item->set_text(0, text); - item->set_icon(0, vbc->get_theme_icon("VisualScript", "EditorIcons")); + item->set_icon(0, vbc->get_theme_icon(SNAME("VisualScript"), SNAME("EditorIcons"))); item->set_metadata(0, name); item->set_metadata(1, "action"); item->set_selectable(0, true); @@ -334,11 +340,11 @@ void VisualScriptPropertySelector::get_visual_node_names(const String &root_filt List<String> fnodes; VisualScriptLanguage::singleton->get_registered_node_names(&fnodes); - for (List<String>::Element *E = fnodes.front(); E; E = E->next()) { - if (!E->get().begins_with(root_filter)) { + for (const String &E : fnodes) { + if (!E.begins_with(root_filter)) { continue; } - Vector<String> path = E->get().split("/"); + Vector<String> path = E.split("/"); // check if the name has the filter bool in_filter = false; @@ -349,7 +355,7 @@ void VisualScriptPropertySelector::get_visual_node_names(const String &root_filt } else { in_filter = false; } - if (E->get().findn(tx_filters[i]) != -1) { + if (E.findn(tx_filters[i]) != -1) { in_filter = true; break; } @@ -360,7 +366,7 @@ void VisualScriptPropertySelector::get_visual_node_names(const String &root_filt bool in_modifier = p_modifiers.is_empty(); for (Set<String>::Element *F = p_modifiers.front(); F && in_modifier; F = F->next()) { - if (E->get().findn(F->get()) != -1) { + if (E.findn(F->get()) != -1) { in_modifier = true; } } @@ -369,7 +375,7 @@ void VisualScriptPropertySelector::get_visual_node_names(const String &root_filt } TreeItem *item = search_options->create_item(root); - Ref<VisualScriptNode> vnode = VisualScriptLanguage::singleton->create_node_from_name(E->get()); + Ref<VisualScriptNode> vnode = VisualScriptLanguage::singleton->create_node_from_name(E); Ref<VisualScriptOperator> vnode_operator = vnode; String type_name; if (vnode_operator.is_valid()) { @@ -401,9 +407,9 @@ void VisualScriptPropertySelector::get_visual_node_names(const String &root_filt } item->set_text(0, type_name + String("").join(desc)); - item->set_icon(0, vbc->get_theme_icon("VisualScript", "EditorIcons")); + item->set_icon(0, vbc->get_theme_icon(SNAME("VisualScript"), SNAME("EditorIcons"))); item->set_selectable(0, true); - item->set_metadata(0, E->get()); + item->set_metadata(0, E); item->set_selectable(0, true); item->set_metadata(1, "visualscript"); item->set_selectable(1, false); @@ -417,7 +423,7 @@ void VisualScriptPropertySelector::_confirmed() { if (!ti) { return; } - emit_signal("selected", ti->get_metadata(0), ti->get_metadata(1), ti->get_metadata(2)); + emit_signal(SNAME("selected"), ti->get_metadata(0), ti->get_metadata(1), ti->get_metadata(2)); set_visible(false); } diff --git a/modules/visual_script/visual_script_yield_nodes.cpp b/modules/visual_script/visual_script_yield_nodes.cpp index d8bc926a1d..9fa49b8a1d 100644 --- a/modules/visual_script/visual_script_yield_nodes.cpp +++ b/modules/visual_script/visual_script_yield_nodes.cpp @@ -438,21 +438,21 @@ void VisualScriptYieldSignal::_validate_property(PropertyInfo &property) const { ClassDB::get_signal_list(_get_base_type(), &methods); List<String> mstring; - for (List<MethodInfo>::Element *E = methods.front(); E; E = E->next()) { - if (E->get().name.begins_with("_")) { + for (const MethodInfo &E : methods) { + if (E.name.begins_with("_")) { continue; } - mstring.push_back(E->get().name.get_slice(":", 0)); + mstring.push_back(E.name.get_slice(":", 0)); } mstring.sort(); String ml; - for (List<String>::Element *E = mstring.front(); E; E = E->next()) { + for (const String &E : mstring) { if (ml != String()) { ml += ","; } - ml += E->get(); + ml += E; } property.hint_string = ml; diff --git a/modules/webm/doc_classes/VideoStreamWebm.xml b/modules/webm/doc_classes/VideoStreamWebm.xml index f3e13ba31a..3b9acfd873 100644 --- a/modules/webm/doc_classes/VideoStreamWebm.xml +++ b/modules/webm/doc_classes/VideoStreamWebm.xml @@ -12,17 +12,14 @@ </tutorials> <methods> <method name="get_file"> - <return type="String"> - </return> + <return type="String" /> <description> Returns the WebM video file handled by this [VideoStreamWebm]. </description> </method> <method name="set_file"> - <return type="void"> - </return> - <argument index="0" name="file" type="String"> - </argument> + <return type="void" /> + <argument index="0" name="file" type="String" /> <description> Sets the WebM video file that this [VideoStreamWebm] resource handles. The [code]file[/code] name should have the [code].webm[/code] extension. </description> diff --git a/modules/webrtc/doc_classes/WebRTCDataChannel.xml b/modules/webrtc/doc_classes/WebRTCDataChannel.xml index 5c90038b9a..cf5735bab5 100644 --- a/modules/webrtc/doc_classes/WebRTCDataChannel.xml +++ b/modules/webrtc/doc_classes/WebRTCDataChannel.xml @@ -8,81 +8,76 @@ </tutorials> <methods> <method name="close"> - <return type="void"> - </return> + <return type="void" /> <description> Closes this data channel, notifying the other peer. </description> </method> + <method name="get_buffered_amount" qualifiers="const"> + <return type="int" /> + <description> + Returns the number of bytes currently queued to be sent over this channel. + </description> + </method> <method name="get_id" qualifiers="const"> - <return type="int"> - </return> + <return type="int" /> <description> Returns the id assigned to this channel during creation (or auto-assigned during negotiation). If the channel is not negotiated out-of-band the id will only be available after the connection is established (will return [code]65535[/code] until then). </description> </method> <method name="get_label" qualifiers="const"> - <return type="String"> - </return> + <return type="String" /> <description> Returns the label assigned to this channel during creation. </description> </method> <method name="get_max_packet_life_time" qualifiers="const"> - <return type="int"> - </return> + <return type="int" /> <description> Returns the [code]maxPacketLifeTime[/code] value assigned to this channel during creation. Will be [code]65535[/code] if not specified. </description> </method> <method name="get_max_retransmits" qualifiers="const"> - <return type="int"> - </return> + <return type="int" /> <description> Returns the [code]maxRetransmits[/code] value assigned to this channel during creation. Will be [code]65535[/code] if not specified. </description> </method> <method name="get_protocol" qualifiers="const"> - <return type="String"> - </return> + <return type="String" /> <description> Returns the sub-protocol assigned to this channel during creation. An empty string if not specified. </description> </method> <method name="get_ready_state" qualifiers="const"> - <return type="int" enum="WebRTCDataChannel.ChannelState"> - </return> + <return type="int" enum="WebRTCDataChannel.ChannelState" /> <description> Returns the current state of this channel, see [enum ChannelState]. </description> </method> <method name="is_negotiated" qualifiers="const"> - <return type="bool"> - </return> + <return type="bool" /> <description> Returns [code]true[/code] if this channel was created with out-of-band configuration. </description> </method> <method name="is_ordered" qualifiers="const"> - <return type="bool"> - </return> + <return type="bool" /> <description> Returns [code]true[/code] if this channel was created with ordering enabled (default). </description> </method> <method name="poll"> - <return type="int" enum="Error"> - </return> + <return type="int" enum="Error" /> <description> Reserved, but not used for now. </description> </method> <method name="was_string_packet" qualifiers="const"> - <return type="bool"> - </return> + <return type="bool" /> <description> Returns [code]true[/code] if the last received packet was transferred as text. See [member write_mode]. </description> diff --git a/modules/webrtc/doc_classes/WebRTCMultiplayerPeer.xml b/modules/webrtc/doc_classes/WebRTCMultiplayerPeer.xml index 26c5bfa6ce..0c4a0d4ea0 100644 --- a/modules/webrtc/doc_classes/WebRTCMultiplayerPeer.xml +++ b/modules/webrtc/doc_classes/WebRTCMultiplayerPeer.xml @@ -12,58 +12,45 @@ </tutorials> <methods> <method name="add_peer"> - <return type="int" enum="Error"> - </return> - <argument index="0" name="peer" type="WebRTCPeerConnection"> - </argument> - <argument index="1" name="peer_id" type="int"> - </argument> - <argument index="2" name="unreliable_lifetime" type="int" default="1"> - </argument> + <return type="int" enum="Error" /> + <argument index="0" name="peer" type="WebRTCPeerConnection" /> + <argument index="1" name="peer_id" type="int" /> + <argument index="2" name="unreliable_lifetime" type="int" default="1" /> <description> Add a new peer to the mesh with the given [code]peer_id[/code]. The [WebRTCPeerConnection] must be in state [constant WebRTCPeerConnection.STATE_NEW]. Three channels will be created for reliable, unreliable, and ordered transport. The value of [code]unreliable_lifetime[/code] will be passed to the [code]maxPacketLifetime[/code] option when creating unreliable and ordered channels (see [method WebRTCPeerConnection.create_data_channel]). </description> </method> <method name="close"> - <return type="void"> - </return> + <return type="void" /> <description> Close all the add peer connections and channels, freeing all resources. </description> </method> <method name="get_peer"> - <return type="Dictionary"> - </return> - <argument index="0" name="peer_id" type="int"> - </argument> + <return type="Dictionary" /> + <argument index="0" name="peer_id" type="int" /> <description> Return a dictionary representation of the peer with given [code]peer_id[/code] with three keys. [code]connection[/code] containing the [WebRTCPeerConnection] to this peer, [code]channels[/code] an array of three [WebRTCDataChannel], and [code]connected[/code] a boolean representing if the peer connection is currently connected (all three channels are open). </description> </method> <method name="get_peers"> - <return type="Dictionary"> - </return> + <return type="Dictionary" /> <description> Returns a dictionary which keys are the peer ids and values the peer representation as in [method get_peer]. </description> </method> <method name="has_peer"> - <return type="bool"> - </return> - <argument index="0" name="peer_id" type="int"> - </argument> + <return type="bool" /> + <argument index="0" name="peer_id" type="int" /> <description> Returns [code]true[/code] if the given [code]peer_id[/code] is in the peers map (it might not be connected though). </description> </method> <method name="initialize"> - <return type="int" enum="Error"> - </return> - <argument index="0" name="peer_id" type="int"> - </argument> - <argument index="1" name="server_compatibility" type="bool" default="false"> - </argument> + <return type="int" enum="Error" /> + <argument index="0" name="peer_id" type="int" /> + <argument index="1" name="server_compatibility" type="bool" default="false" /> <description> Initialize the multiplayer peer with the given [code]peer_id[/code] (must be between 1 and 2147483647). If [code]server_compatibilty[/code] is [code]false[/code] (default), the multiplayer peer will be immediately in state [constant MultiplayerPeer.CONNECTION_CONNECTED] and [signal MultiplayerPeer.connection_succeeded] will not be emitted. @@ -71,10 +58,8 @@ </description> </method> <method name="remove_peer"> - <return type="void"> - </return> - <argument index="0" name="peer_id" type="int"> - </argument> + <return type="void" /> + <argument index="0" name="peer_id" type="int" /> <description> Remove the peer with given [code]peer_id[/code] from the mesh. If the peer was connected, and [signal MultiplayerPeer.peer_connected] was emitted for it, then [signal MultiplayerPeer.peer_disconnected] will be emitted. </description> diff --git a/modules/webrtc/doc_classes/WebRTCPeerConnection.xml b/modules/webrtc/doc_classes/WebRTCPeerConnection.xml index 62e524825d..f6f360503f 100644 --- a/modules/webrtc/doc_classes/WebRTCPeerConnection.xml +++ b/modules/webrtc/doc_classes/WebRTCPeerConnection.xml @@ -15,33 +15,25 @@ </tutorials> <methods> <method name="add_ice_candidate"> - <return type="int" enum="Error"> - </return> - <argument index="0" name="media" type="String"> - </argument> - <argument index="1" name="index" type="int"> - </argument> - <argument index="2" name="name" type="String"> - </argument> + <return type="int" enum="Error" /> + <argument index="0" name="media" type="String" /> + <argument index="1" name="index" type="int" /> + <argument index="2" name="name" type="String" /> <description> Add an ice candidate generated by a remote peer (and received over the signaling server). See [signal ice_candidate_created]. </description> </method> <method name="close"> - <return type="void"> - </return> + <return type="void" /> <description> Close the peer connection and all data channels associated with it. Note, you cannot reuse this object for a new connection unless you call [method initialize]. </description> </method> <method name="create_data_channel"> - <return type="WebRTCDataChannel"> - </return> - <argument index="0" name="label" type="String"> - </argument> + <return type="WebRTCDataChannel" /> + <argument index="0" name="label" type="String" /> <argument index="1" name="options" type="Dictionary" default="{ -}"> - </argument> +}" /> <description> Returns a new [WebRTCDataChannel] (or [code]null[/code] on failure) with given [code]label[/code] and optionally configured via the [code]options[/code] dictionary. This method can only be called when the connection is in state [constant STATE_NEW]. There are two ways to create a working data channel: either call [method create_data_channel] on only one of the peer and listen to [signal data_channel_received] on the other, or call [method create_data_channel] on both peers, with the same values, and the [code]negotiated[/code] option set to [code]true[/code]. @@ -63,26 +55,22 @@ </description> </method> <method name="create_offer"> - <return type="int" enum="Error"> - </return> + <return type="int" enum="Error" /> <description> Creates a new SDP offer to start a WebRTC connection with a remote peer. At least one [WebRTCDataChannel] must have been created before calling this method. If this functions returns [constant OK], [signal session_description_created] will be called when the session is ready to be sent. </description> </method> <method name="get_connection_state" qualifiers="const"> - <return type="int" enum="WebRTCPeerConnection.ConnectionState"> - </return> + <return type="int" enum="WebRTCPeerConnection.ConnectionState" /> <description> Returns the connection state. See [enum ConnectionState]. </description> </method> <method name="initialize"> - <return type="int" enum="Error"> - </return> + <return type="int" enum="Error" /> <argument index="0" name="configuration" type="Dictionary" default="{ -}"> - </argument> +}" /> <description> Re-initialize this peer connection, closing any previously active connection, and going back to state [constant STATE_NEW]. A dictionary of [code]options[/code] can be passed to configure the peer connection. Valid [code]options[/code] are: @@ -103,31 +91,24 @@ </description> </method> <method name="poll"> - <return type="int" enum="Error"> - </return> + <return type="int" enum="Error" /> <description> Call this method frequently (e.g. in [method Node._process] or [method Node._physics_process]) to properly receive signals. </description> </method> <method name="set_local_description"> - <return type="int" enum="Error"> - </return> - <argument index="0" name="type" type="String"> - </argument> - <argument index="1" name="sdp" type="String"> - </argument> + <return type="int" enum="Error" /> + <argument index="0" name="type" type="String" /> + <argument index="1" name="sdp" type="String" /> <description> Sets the SDP description of the local peer. This should be called in response to [signal session_description_created]. After calling this function the peer will start emitting [signal ice_candidate_created] (unless an [enum Error] different from [constant OK] is returned). </description> </method> <method name="set_remote_description"> - <return type="int" enum="Error"> - </return> - <argument index="0" name="type" type="String"> - </argument> - <argument index="1" name="sdp" type="String"> - </argument> + <return type="int" enum="Error" /> + <argument index="0" name="type" type="String" /> + <argument index="1" name="sdp" type="String" /> <description> Sets the SDP description of the remote peer. This should be called with the values generated by a remote peer and received over the signaling server. If [code]type[/code] is [code]offer[/code] the peer will emit [signal session_description_created] with the appropriate answer. @@ -137,29 +118,23 @@ </methods> <signals> <signal name="data_channel_received"> - <argument index="0" name="channel" type="Object"> - </argument> + <argument index="0" name="channel" type="Object" /> <description> Emitted when a new in-band channel is received, i.e. when the channel was created with [code]negotiated: false[/code] (default). The object will be an instance of [WebRTCDataChannel]. You must keep a reference of it or it will be closed automatically. See [method create_data_channel]. </description> </signal> <signal name="ice_candidate_created"> - <argument index="0" name="media" type="String"> - </argument> - <argument index="1" name="index" type="int"> - </argument> - <argument index="2" name="name" type="String"> - </argument> + <argument index="0" name="media" type="String" /> + <argument index="1" name="index" type="int" /> + <argument index="2" name="name" type="String" /> <description> Emitted when a new ICE candidate has been created. The three parameters are meant to be passed to the remote peer over the signaling server. </description> </signal> <signal name="session_description_created"> - <argument index="0" name="type" type="String"> - </argument> - <argument index="1" name="sdp" type="String"> - </argument> + <argument index="0" name="type" type="String" /> + <argument index="1" name="sdp" type="String" /> <description> Emitted after a successful call to [method create_offer] or [method set_remote_description] (when it generates an answer). The parameters are meant to be passed to [method set_local_description] on this object, and sent to the remote peer over the signaling server. </description> diff --git a/modules/webrtc/library_godot_webrtc.js b/modules/webrtc/library_godot_webrtc.js index 404a116716..a0a6c21be3 100644 --- a/modules/webrtc/library_godot_webrtc.js +++ b/modules/webrtc/library_godot_webrtc.js @@ -133,12 +133,12 @@ const GodotRTCDataChannel = { godot_js_rtc_datachannel_is_ordered__sig: 'ii', godot_js_rtc_datachannel_is_ordered: function (p_id) { - return IDHandler.get_prop(p_id, 'ordered', true); + return GodotRTCDataChannel.get_prop(p_id, 'ordered', true); }, godot_js_rtc_datachannel_id_get__sig: 'ii', godot_js_rtc_datachannel_id_get: function (p_id) { - return IDHandler.get_prop(p_id, 'id', 65535); + return GodotRTCDataChannel.get_prop(p_id, 'id', 65535); }, godot_js_rtc_datachannel_max_packet_lifetime_get__sig: 'ii', @@ -158,12 +158,17 @@ const GodotRTCDataChannel = { godot_js_rtc_datachannel_max_retransmits_get__sig: 'ii', godot_js_rtc_datachannel_max_retransmits_get: function (p_id) { - return IDHandler.get_prop(p_id, 'maxRetransmits', 65535); + return GodotRTCDataChannel.get_prop(p_id, 'maxRetransmits', 65535); }, godot_js_rtc_datachannel_is_negotiated__sig: 'ii', godot_js_rtc_datachannel_is_negotiated: function (p_id) { - return IDHandler.get_prop(p_id, 'negotiated', 65535); + return GodotRTCDataChannel.get_prop(p_id, 'negotiated', 65535); + }, + + godot_js_rtc_datachannel_get_buffered_amount__sig: 'ii', + godot_js_rtc_datachannel_get_buffered_amount: function (p_id) { + return GodotRTCDataChannel.get_prop(p_id, 'bufferedAmount', 0); }, godot_js_rtc_datachannel_label_get__sig: 'ii', diff --git a/modules/webrtc/webrtc_data_channel.cpp b/modules/webrtc/webrtc_data_channel.cpp index 004112f992..ca520a733d 100644 --- a/modules/webrtc/webrtc_data_channel.cpp +++ b/modules/webrtc/webrtc_data_channel.cpp @@ -46,6 +46,7 @@ void WebRTCDataChannel::_bind_methods() { ClassDB::bind_method(D_METHOD("get_max_retransmits"), &WebRTCDataChannel::get_max_retransmits); ClassDB::bind_method(D_METHOD("get_protocol"), &WebRTCDataChannel::get_protocol); ClassDB::bind_method(D_METHOD("is_negotiated"), &WebRTCDataChannel::is_negotiated); + ClassDB::bind_method(D_METHOD("get_buffered_amount"), &WebRTCDataChannel::get_buffered_amount); ADD_PROPERTY(PropertyInfo(Variant::INT, "write_mode", PROPERTY_HINT_ENUM), "set_write_mode", "get_write_mode"); diff --git a/modules/webrtc/webrtc_data_channel.h b/modules/webrtc/webrtc_data_channel.h index 20affc513f..809d35c6e3 100644 --- a/modules/webrtc/webrtc_data_channel.h +++ b/modules/webrtc/webrtc_data_channel.h @@ -70,6 +70,8 @@ public: virtual String get_protocol() const = 0; virtual bool is_negotiated() const = 0; + virtual int get_buffered_amount() const = 0; + virtual Error poll() = 0; virtual void close() = 0; diff --git a/modules/webrtc/webrtc_data_channel_gdnative.cpp b/modules/webrtc/webrtc_data_channel_gdnative.cpp index d4cf464c7c..10a3367557 100644 --- a/modules/webrtc/webrtc_data_channel_gdnative.cpp +++ b/modules/webrtc/webrtc_data_channel_gdnative.cpp @@ -31,6 +31,7 @@ #ifdef WEBRTC_GDNATIVE_ENABLED #include "webrtc_data_channel_gdnative.h" + #include "core/io/resource_loader.h" #include "modules/gdnative/nativescript/nativescript.h" @@ -110,6 +111,11 @@ bool WebRTCDataChannelGDNative::is_negotiated() const { return interface->is_negotiated(interface->data); } +int WebRTCDataChannelGDNative::get_buffered_amount() const { + ERR_FAIL_COND_V(interface == NULL, 0); + return interface->get_buffered_amount(interface->data); +} + Error WebRTCDataChannelGDNative::get_packet(const uint8_t **r_buffer, int &r_buffer_size) { ERR_FAIL_COND_V(interface == nullptr, ERR_UNCONFIGURED); return (Error)interface->get_packet(interface->data, r_buffer, &r_buffer_size); diff --git a/modules/webrtc/webrtc_data_channel_gdnative.h b/modules/webrtc/webrtc_data_channel_gdnative.h index 7e02a32046..5c80edd48c 100644 --- a/modules/webrtc/webrtc_data_channel_gdnative.h +++ b/modules/webrtc/webrtc_data_channel_gdnative.h @@ -60,6 +60,7 @@ public: virtual int get_max_retransmits() const override; virtual String get_protocol() const override; virtual bool is_negotiated() const override; + virtual int get_buffered_amount() const override; virtual Error poll() override; virtual void close() override; diff --git a/modules/webrtc/webrtc_data_channel_js.cpp b/modules/webrtc/webrtc_data_channel_js.cpp index dfbec80c86..31d6a0568c 100644 --- a/modules/webrtc/webrtc_data_channel_js.cpp +++ b/modules/webrtc/webrtc_data_channel_js.cpp @@ -46,6 +46,7 @@ extern int godot_js_rtc_datachannel_id_get(int p_id); extern int godot_js_rtc_datachannel_max_packet_lifetime_get(int p_id); extern int godot_js_rtc_datachannel_max_retransmits_get(int p_id); extern int godot_js_rtc_datachannel_is_negotiated(int p_id); +extern int godot_js_rtc_datachannel_get_buffered_amount(int p_id); extern char *godot_js_rtc_datachannel_label_get(int p_id); // Must free the returned string. extern char *godot_js_rtc_datachannel_protocol_get(int p_id); // Must free the returned string. extern void godot_js_rtc_datachannel_destroy(int p_id); @@ -181,6 +182,10 @@ bool WebRTCDataChannelJS::is_negotiated() const { return godot_js_rtc_datachannel_is_negotiated(_js_id); } +int WebRTCDataChannelJS::get_buffered_amount() const { + return godot_js_rtc_datachannel_get_buffered_amount(_js_id); +} + WebRTCDataChannelJS::WebRTCDataChannelJS() { } diff --git a/modules/webrtc/webrtc_data_channel_js.h b/modules/webrtc/webrtc_data_channel_js.h index db58ebccff..5cd6a32ed9 100644 --- a/modules/webrtc/webrtc_data_channel_js.h +++ b/modules/webrtc/webrtc_data_channel_js.h @@ -72,6 +72,7 @@ public: virtual int get_max_retransmits() const override; virtual String get_protocol() const override; virtual bool is_negotiated() const override; + virtual int get_buffered_amount() const override; virtual Error poll() override; virtual void close() override; diff --git a/modules/webrtc/webrtc_multiplayer_peer.cpp b/modules/webrtc/webrtc_multiplayer_peer.cpp index ac75f9e860..9b08a26aed 100644 --- a/modules/webrtc/webrtc_multiplayer_peer.cpp +++ b/modules/webrtc/webrtc_multiplayer_peer.cpp @@ -112,30 +112,30 @@ void WebRTCMultiplayerPeer::poll() { } } // Remove disconnected peers - for (List<int>::Element *E = remove.front(); E; E = E->next()) { - remove_peer(E->get()); - if (next_packet_peer == E->get()) { + for (int &E : remove) { + remove_peer(E); + if (next_packet_peer == E) { next_packet_peer = 0; } } // Signal newly connected peers - for (List<int>::Element *E = add.front(); E; E = E->next()) { + for (int &E : add) { // Already connected to server: simply notify new peer. // NOTE: Mesh is always connected. if (connection_status == CONNECTION_CONNECTED) { - emit_signal("peer_connected", E->get()); + emit_signal(SNAME("peer_connected"), E); } // Server emulation mode suppresses peer_conencted until server connects. - if (server_compat && E->get() == TARGET_PEER_SERVER) { + if (server_compat && E == TARGET_PEER_SERVER) { // Server connected. connection_status = CONNECTION_CONNECTED; - emit_signal("peer_connected", TARGET_PEER_SERVER); - emit_signal("connection_succeeded"); + emit_signal(SNAME("peer_connected"), TARGET_PEER_SERVER); + emit_signal(SNAME("connection_succeeded")); // Notify of all previously connected peers for (Map<int, Ref<ConnectedPeer>>::Element *F = peer_map.front(); F; F = F->next()) { if (F->key() != 1 && F->get()->connected) { - emit_signal("peer_connected", F->key()); + emit_signal(SNAME("peer_connected"), F->key()); } } break; // Because we already notified of all newly added peers. @@ -154,8 +154,8 @@ void WebRTCMultiplayerPeer::_find_next_peer() { } // After last. while (E) { - for (List<Ref<WebRTCDataChannel>>::Element *F = E->get()->channels.front(); F; F = F->next()) { - if (F->get()->get_available_packet_count()) { + for (const Ref<WebRTCDataChannel> &F : E->get()->channels) { + if (F->get_available_packet_count()) { next_packet_peer = E->key(); return; } @@ -165,8 +165,8 @@ void WebRTCMultiplayerPeer::_find_next_peer() { E = peer_map.front(); // Before last while (E) { - for (List<Ref<WebRTCDataChannel>>::Element *F = E->get()->channels.front(); F; F = F->next()) { - if (F->get()->get_available_packet_count()) { + for (const Ref<WebRTCDataChannel> &F : E->get()->channels) { + if (F->get_available_packet_count()) { next_packet_peer = E->key(); return; } @@ -213,8 +213,8 @@ int WebRTCMultiplayerPeer::get_unique_id() const { void WebRTCMultiplayerPeer::_peer_to_dict(Ref<ConnectedPeer> p_connected_peer, Dictionary &r_dict) { Array channels; - for (List<Ref<WebRTCDataChannel>>::Element *F = p_connected_peer->channels.front(); F; F = F->next()) { - channels.push_back(F->get()); + for (Ref<WebRTCDataChannel> &F : p_connected_peer->channels) { + channels.push_back(F); } r_dict["connection"] = p_connected_peer->connection; r_dict["connected"] = p_connected_peer->connected; @@ -283,9 +283,9 @@ void WebRTCMultiplayerPeer::remove_peer(int p_peer_id) { peer_map.erase(p_peer_id); if (peer->connected) { peer->connected = false; - emit_signal("peer_disconnected", p_peer_id); + emit_signal(SNAME("peer_disconnected"), p_peer_id); if (server_compat && p_peer_id == TARGET_PEER_SERVER) { - emit_signal("server_disconnected"); + emit_signal(SNAME("server_disconnected")); connection_status = CONNECTION_DISCONNECTED; } } @@ -297,9 +297,9 @@ Error WebRTCMultiplayerPeer::get_packet(const uint8_t **r_buffer, int &r_buffer_ _find_next_peer(); ERR_FAIL_V(ERR_UNAVAILABLE); } - for (List<Ref<WebRTCDataChannel>>::Element *E = peer_map[next_packet_peer]->channels.front(); E; E = E->next()) { - if (E->get()->get_available_packet_count()) { - Error err = E->get()->get_packet(r_buffer, r_buffer_size); + for (Ref<WebRTCDataChannel> &E : peer_map[next_packet_peer]->channels) { + if (E->get_available_packet_count()) { + Error err = E->get_packet(r_buffer, r_buffer_size); _find_next_peer(); return err; } @@ -357,8 +357,8 @@ int WebRTCMultiplayerPeer::get_available_packet_count() const { } int size = 0; for (Map<int, Ref<ConnectedPeer>>::Element *E = peer_map.front(); E; E = E->next()) { - for (List<Ref<WebRTCDataChannel>>::Element *F = E->get()->channels.front(); F; F = F->next()) { - size += F->get()->get_available_packet_count(); + for (const Ref<WebRTCDataChannel> &F : E->get()->channels) { + size += F->get_available_packet_count(); } } return size; diff --git a/modules/webrtc/webrtc_peer_connection_js.cpp b/modules/webrtc/webrtc_peer_connection_js.cpp index 8879f7d6ec..ed3459d5f8 100644 --- a/modules/webrtc/webrtc_peer_connection_js.cpp +++ b/modules/webrtc/webrtc_peer_connection_js.cpp @@ -34,17 +34,16 @@ #include "webrtc_data_channel_js.h" -#include "core/io/json.h" #include "emscripten.h" void WebRTCPeerConnectionJS::_on_ice_candidate(void *p_obj, const char *p_mid_name, int p_mline_idx, const char *p_candidate) { WebRTCPeerConnectionJS *peer = static_cast<WebRTCPeerConnectionJS *>(p_obj); - peer->emit_signal("ice_candidate_created", String(p_mid_name), p_mline_idx, String(p_candidate)); + peer->emit_signal(SNAME("ice_candidate_created"), String(p_mid_name), p_mline_idx, String(p_candidate)); } void WebRTCPeerConnectionJS::_on_session_created(void *p_obj, const char *p_type, const char *p_session) { WebRTCPeerConnectionJS *peer = static_cast<WebRTCPeerConnectionJS *>(p_obj); - peer->emit_signal("session_description_created", String(p_type), String(p_session)); + peer->emit_signal(SNAME("session_description_created"), String(p_type), String(p_session)); } void WebRTCPeerConnectionJS::_on_connection_state_changed(void *p_obj, int p_state) { @@ -58,7 +57,7 @@ void WebRTCPeerConnectionJS::_on_error(void *p_obj) { void WebRTCPeerConnectionJS::_on_data_channel(void *p_obj, int p_id) { WebRTCPeerConnectionJS *peer = static_cast<WebRTCPeerConnectionJS *>(p_obj); - peer->emit_signal("data_channel_received", Ref<WebRTCDataChannelJS>(new WebRTCDataChannelJS(p_id))); + peer->emit_signal(SNAME("data_channel_received"), Ref<WebRTCDataChannelJS>(new WebRTCDataChannelJS(p_id))); } void WebRTCPeerConnectionJS::close() { @@ -100,7 +99,7 @@ Error WebRTCPeerConnectionJS::initialize(Dictionary p_config) { } _conn_state = STATE_NEW; - String config = JSON::print(p_config); + String config = Variant(p_config).to_json_string(); _js_id = godot_js_rtc_pc_create(config.utf8().get_data(), this, &_on_connection_state_changed, &_on_ice_candidate, &_on_data_channel); return _js_id ? OK : FAILED; } @@ -108,7 +107,7 @@ Error WebRTCPeerConnectionJS::initialize(Dictionary p_config) { Ref<WebRTCDataChannel> WebRTCPeerConnectionJS::create_data_channel(String p_channel, Dictionary p_channel_config) { ERR_FAIL_COND_V(_conn_state != STATE_NEW, nullptr); - String config = JSON::print(p_channel_config); + String config = Variant(p_channel_config).to_json_string(); int id = godot_js_rtc_pc_datachannel_create(_js_id, p_channel.utf8().get_data(), config.utf8().get_data()); ERR_FAIL_COND_V(id == 0, nullptr); return memnew(WebRTCDataChannelJS(id)); diff --git a/modules/websocket/doc_classes/WebSocketClient.xml b/modules/websocket/doc_classes/WebSocketClient.xml index 40c0ad17ad..1549a907b4 100644 --- a/modules/websocket/doc_classes/WebSocketClient.xml +++ b/modules/websocket/doc_classes/WebSocketClient.xml @@ -13,16 +13,11 @@ </tutorials> <methods> <method name="connect_to_url"> - <return type="int" enum="Error"> - </return> - <argument index="0" name="url" type="String"> - </argument> - <argument index="1" name="protocols" type="PackedStringArray" default="PackedStringArray()"> - </argument> - <argument index="2" name="gd_mp_api" type="bool" default="false"> - </argument> - <argument index="3" name="custom_headers" type="PackedStringArray" default="PackedStringArray()"> - </argument> + <return type="int" enum="Error" /> + <argument index="0" name="url" type="String" /> + <argument index="1" name="protocols" type="PackedStringArray" default="PackedStringArray()" /> + <argument index="2" name="gd_mp_api" type="bool" default="false" /> + <argument index="3" name="custom_headers" type="PackedStringArray" default="PackedStringArray()" /> <description> Connects to the given URL requesting one of the given [code]protocols[/code] as sub-protocol. If the list empty (default), no sub-protocol will be requested. If [code]true[/code] is passed as [code]gd_mp_api[/code], the client will behave like a network peer for the [MultiplayerAPI], connections to non-Godot servers will not work, and [signal data_received] will not be emitted. @@ -33,26 +28,21 @@ </description> </method> <method name="disconnect_from_host"> - <return type="void"> - </return> - <argument index="0" name="code" type="int" default="1000"> - </argument> - <argument index="1" name="reason" type="String" default=""""> - </argument> + <return type="void" /> + <argument index="0" name="code" type="int" default="1000" /> + <argument index="1" name="reason" type="String" default="""" /> <description> Disconnects this client from the connected host. See [method WebSocketPeer.close] for more information. </description> </method> <method name="get_connected_host" qualifiers="const"> - <return type="String"> - </return> + <return type="String" /> <description> Return the IP address of the currently connected host. </description> </method> <method name="get_connected_port" qualifiers="const"> - <return type="int"> - </return> + <return type="int" /> <description> Return the IP port of the currently connected host. </description> @@ -70,8 +60,7 @@ </members> <signals> <signal name="connection_closed"> - <argument index="0" name="was_clean_close" type="bool"> - </argument> + <argument index="0" name="was_clean_close" type="bool" /> <description> Emitted when the connection to the server is closed. [code]was_clean_close[/code] will be [code]true[/code] if the connection was shutdown cleanly. </description> @@ -82,8 +71,7 @@ </description> </signal> <signal name="connection_established"> - <argument index="0" name="protocol" type="String"> - </argument> + <argument index="0" name="protocol" type="String" /> <description> Emitted when a connection with the server is established, [code]protocol[/code] will contain the sub-protocol agreed with the server. </description> @@ -95,10 +83,8 @@ </description> </signal> <signal name="server_close_request"> - <argument index="0" name="code" type="int"> - </argument> - <argument index="1" name="reason" type="String"> - </argument> + <argument index="0" name="code" type="int" /> + <argument index="1" name="reason" type="String" /> <description> Emitted when the server requests a clean close. You should keep polling until you get a [signal connection_closed] signal to achieve the clean close. See [method WebSocketPeer.close] for more details. </description> diff --git a/modules/websocket/doc_classes/WebSocketMultiplayerPeer.xml b/modules/websocket/doc_classes/WebSocketMultiplayerPeer.xml index ee1b60f739..cd41e9a1fb 100644 --- a/modules/websocket/doc_classes/WebSocketMultiplayerPeer.xml +++ b/modules/websocket/doc_classes/WebSocketMultiplayerPeer.xml @@ -10,25 +10,18 @@ </tutorials> <methods> <method name="get_peer" qualifiers="const"> - <return type="WebSocketPeer"> - </return> - <argument index="0" name="peer_id" type="int"> - </argument> + <return type="WebSocketPeer" /> + <argument index="0" name="peer_id" type="int" /> <description> Returns the [WebSocketPeer] associated to the given [code]peer_id[/code]. </description> </method> <method name="set_buffers"> - <return type="int" enum="Error"> - </return> - <argument index="0" name="input_buffer_size_kb" type="int"> - </argument> - <argument index="1" name="input_max_packets" type="int"> - </argument> - <argument index="2" name="output_buffer_size_kb" type="int"> - </argument> - <argument index="3" name="output_max_packets" type="int"> - </argument> + <return type="int" enum="Error" /> + <argument index="0" name="input_buffer_size_kb" type="int" /> + <argument index="1" name="input_max_packets" type="int" /> + <argument index="2" name="output_buffer_size_kb" type="int" /> + <argument index="3" name="output_max_packets" type="int" /> <description> Configures the buffer sizes for this WebSocket peer. Default values can be specified in the Project Settings under [code]network/limits[/code]. For server, values are meant per connected peer. The first two parameters define the size and queued packets limits of the input buffer, the last two of the output buffer. @@ -43,8 +36,7 @@ </members> <signals> <signal name="peer_packet"> - <argument index="0" name="peer_source" type="int"> - </argument> + <argument index="0" name="peer_source" type="int" /> <description> Emitted when a packet is received from a peer. [b]Note:[/b] This signal is only emitted when the client or server is configured to use Godot multiplayer API. diff --git a/modules/websocket/doc_classes/WebSocketPeer.xml b/modules/websocket/doc_classes/WebSocketPeer.xml index 5125956416..ab7ef6c4d0 100644 --- a/modules/websocket/doc_classes/WebSocketPeer.xml +++ b/modules/websocket/doc_classes/WebSocketPeer.xml @@ -11,12 +11,9 @@ </tutorials> <methods> <method name="close"> - <return type="void"> - </return> - <argument index="0" name="code" type="int" default="1000"> - </argument> - <argument index="1" name="reason" type="String" default=""""> - </argument> + <return type="void" /> + <argument index="0" name="code" type="int" default="1000" /> + <argument index="1" name="reason" type="String" default="""" /> <description> Closes this WebSocket connection. [code]code[/code] is the status code for the closure (see RFC 6455 section 7.4 for a list of valid status codes). [code]reason[/code] is the human readable reason for closing the connection (can be any UTF-8 string that's smaller than 123 bytes). [b]Note:[/b] To achieve a clean close, you will need to keep polling until either [signal WebSocketClient.connection_closed] or [signal WebSocketServer.client_disconnected] is received. @@ -24,57 +21,54 @@ </description> </method> <method name="get_connected_host" qualifiers="const"> - <return type="String"> - </return> + <return type="String" /> <description> Returns the IP address of the connected peer. [b]Note:[/b] Not available in the HTML5 export. </description> </method> <method name="get_connected_port" qualifiers="const"> - <return type="int"> - </return> + <return type="int" /> <description> Returns the remote port of the connected peer. [b]Note:[/b] Not available in the HTML5 export. </description> </method> + <method name="get_current_outbound_buffered_amount" qualifiers="const"> + <return type="int" /> + <description> + Returns the current amount of data in the outbound websocket buffer. [b]Note:[/b] HTML5 exports use WebSocket.bufferedAmount, while other platforms use an internal buffer. + </description> + </method> <method name="get_write_mode" qualifiers="const"> - <return type="int" enum="WebSocketPeer.WriteMode"> - </return> + <return type="int" enum="WebSocketPeer.WriteMode" /> <description> Gets the current selected write mode. See [enum WriteMode]. </description> </method> <method name="is_connected_to_host" qualifiers="const"> - <return type="bool"> - </return> + <return type="bool" /> <description> Returns [code]true[/code] if this peer is currently connected. </description> </method> <method name="set_no_delay"> - <return type="void"> - </return> - <argument index="0" name="enabled" type="bool"> - </argument> + <return type="void" /> + <argument index="0" name="enabled" type="bool" /> <description> Disable Nagle's algorithm on the underling TCP socket (default). See [method StreamPeerTCP.set_no_delay] for more information. [b]Note:[/b] Not available in the HTML5 export. </description> </method> <method name="set_write_mode"> - <return type="void"> - </return> - <argument index="0" name="mode" type="int" enum="WebSocketPeer.WriteMode"> - </argument> + <return type="void" /> + <argument index="0" name="mode" type="int" enum="WebSocketPeer.WriteMode" /> <description> Sets the socket to use the given [enum WriteMode]. </description> </method> <method name="was_string_packet" qualifiers="const"> - <return type="bool"> - </return> + <return type="bool" /> <description> Returns [code]true[/code] if the last received packet was sent as a text payload. See [enum WriteMode]. </description> diff --git a/modules/websocket/doc_classes/WebSocketServer.xml b/modules/websocket/doc_classes/WebSocketServer.xml index 26e09fd8b3..90182de4c2 100644 --- a/modules/websocket/doc_classes/WebSocketServer.xml +++ b/modules/websocket/doc_classes/WebSocketServer.xml @@ -12,61 +12,46 @@ </tutorials> <methods> <method name="disconnect_peer"> - <return type="void"> - </return> - <argument index="0" name="id" type="int"> - </argument> - <argument index="1" name="code" type="int" default="1000"> - </argument> - <argument index="2" name="reason" type="String" default=""""> - </argument> + <return type="void" /> + <argument index="0" name="id" type="int" /> + <argument index="1" name="code" type="int" default="1000" /> + <argument index="2" name="reason" type="String" default="""" /> <description> Disconnects the peer identified by [code]id[/code] from the server. See [method WebSocketPeer.close] for more information. </description> </method> <method name="get_peer_address" qualifiers="const"> - <return type="String"> - </return> - <argument index="0" name="id" type="int"> - </argument> + <return type="String" /> + <argument index="0" name="id" type="int" /> <description> Returns the IP address of the given peer. </description> </method> <method name="get_peer_port" qualifiers="const"> - <return type="int"> - </return> - <argument index="0" name="id" type="int"> - </argument> + <return type="int" /> + <argument index="0" name="id" type="int" /> <description> Returns the remote port of the given peer. </description> </method> <method name="has_peer" qualifiers="const"> - <return type="bool"> - </return> - <argument index="0" name="id" type="int"> - </argument> + <return type="bool" /> + <argument index="0" name="id" type="int" /> <description> Returns [code]true[/code] if a peer with the given ID is connected. </description> </method> <method name="is_listening" qualifiers="const"> - <return type="bool"> - </return> + <return type="bool" /> <description> Returns [code]true[/code] if the server is actively listening on a port. </description> </method> <method name="listen"> - <return type="int" enum="Error"> - </return> - <argument index="0" name="port" type="int"> - </argument> - <argument index="1" name="protocols" type="PackedStringArray" default="PackedStringArray()"> - </argument> - <argument index="2" name="gd_mp_api" type="bool" default="false"> - </argument> + <return type="int" enum="Error" /> + <argument index="0" name="port" type="int" /> + <argument index="1" name="protocols" type="PackedStringArray" default="PackedStringArray()" /> + <argument index="2" name="gd_mp_api" type="bool" default="false" /> <description> Starts listening on the given port. You can specify the desired subprotocols via the "protocols" array. If the list empty (default), no sub-protocol will be requested. @@ -75,8 +60,7 @@ </description> </method> <method name="stop"> - <return type="void"> - </return> + <return type="void" /> <description> Stops the server and clear its state. </description> @@ -101,37 +85,31 @@ </members> <signals> <signal name="client_close_request"> - <argument index="0" name="id" type="int"> - </argument> - <argument index="1" name="code" type="int"> - </argument> - <argument index="2" name="reason" type="String"> - </argument> + <argument index="0" name="id" type="int" /> + <argument index="1" name="code" type="int" /> + <argument index="2" name="reason" type="String" /> <description> Emitted when a client requests a clean close. You should keep polling until you get a [signal client_disconnected] signal with the same [code]id[/code] to achieve the clean close. See [method WebSocketPeer.close] for more details. </description> </signal> <signal name="client_connected"> - <argument index="0" name="id" type="int"> - </argument> - <argument index="1" name="protocol" type="String"> - </argument> + <argument index="0" name="id" type="int" /> + <argument index="1" name="protocol" type="String" /> + <argument index="2" name="resource_name" type="String" /> <description> - Emitted when a new client connects. "protocol" will be the sub-protocol agreed with the client. + Emitted when a new client connects. "protocol" will be the sub-protocol agreed with the client, and "resource_name" will be the resource name of the URI the peer used. + "resource_name" is a path (at the very least a single forward slash) and potentially a query string. </description> </signal> <signal name="client_disconnected"> - <argument index="0" name="id" type="int"> - </argument> - <argument index="1" name="was_clean_close" type="bool"> - </argument> + <argument index="0" name="id" type="int" /> + <argument index="1" name="was_clean_close" type="bool" /> <description> Emitted when a client disconnects. [code]was_clean_close[/code] will be [code]true[/code] if the connection was shutdown cleanly. </description> </signal> <signal name="data_received"> - <argument index="0" name="id" type="int"> - </argument> + <argument index="0" name="id" type="int" /> <description> Emitted when a new message is received. [b]Note:[/b] This signal is [i]not[/i] emitted when used as high-level multiplayer peer. diff --git a/modules/websocket/editor_debugger_server_websocket.h b/modules/websocket/editor_debugger_server_websocket.h index 2f73b98c3d..d9543bb647 100644 --- a/modules/websocket/editor_debugger_server_websocket.h +++ b/modules/websocket/editor_debugger_server_websocket.h @@ -28,12 +28,11 @@ /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ /*************************************************************************/ -#ifndef SCRIPT_EDITOR_DEBUGGER_WEBSOCKET_H -#define SCRIPT_EDITOR_DEBUGGER_WEBSOCKET_H - -#include "modules/websocket/websocket_server.h" +#ifndef EDITOR_DEBUGGER_SERVER_WEBSOCKET_H +#define EDITOR_DEBUGGER_SERVER_WEBSOCKET_H #include "editor/debugger/editor_debugger_server.h" +#include "modules/websocket/websocket_server.h" class EditorDebuggerServerWebSocket : public EditorDebuggerServer { GDCLASS(EditorDebuggerServerWebSocket, EditorDebuggerServer); @@ -59,4 +58,4 @@ public: ~EditorDebuggerServerWebSocket(); }; -#endif // SCRIPT_EDITOR_DEBUGGER_WEBSOCKET_H +#endif // EDITOR_DEBUGGER_SERVER_WEBSOCKET_H diff --git a/modules/websocket/emws_client.cpp b/modules/websocket/emws_client.cpp index 744053b6e2..5cd94e978f 100644 --- a/modules/websocket/emws_client.cpp +++ b/modules/websocket/emws_client.cpp @@ -79,7 +79,7 @@ Error EMWSClient::connect_to_host(String p_host, String p_path, uint16_t p_port, String str = "ws://"; if (p_custom_headers.size()) { - WARN_PRINT_ONCE("Custom headers are not supported in in HTML5 platform."); + WARN_PRINT_ONCE("Custom headers are not supported in HTML5 platform."); } if (p_ssl) { str = "wss://"; @@ -95,7 +95,7 @@ Error EMWSClient::connect_to_host(String p_host, String p_path, uint16_t p_port, return FAILED; } - static_cast<Ref<EMWSPeer>>(_peer)->set_sock(_js_id, _in_buf_size, _in_pkt_size); + static_cast<Ref<EMWSPeer>>(_peer)->set_sock(_js_id, _in_buf_size, _in_pkt_size, _out_buf_size); return OK; } @@ -136,6 +136,7 @@ int EMWSClient::get_max_packet_size() const { Error EMWSClient::set_buffers(int p_in_buffer, int p_in_packets, int p_out_buffer, int p_out_packets) { _in_buf_size = nearest_shift(p_in_buffer - 1) + 10; _in_pkt_size = nearest_shift(p_in_packets - 1); + _out_buf_size = nearest_shift(p_out_buffer - 1) + 10; return OK; } diff --git a/modules/websocket/emws_client.h b/modules/websocket/emws_client.h index ca2d7ed986..3b0b8395b9 100644 --- a/modules/websocket/emws_client.h +++ b/modules/websocket/emws_client.h @@ -45,6 +45,7 @@ private: bool _is_connecting = false; int _in_buf_size = DEF_BUF_SHIFT; int _in_pkt_size = DEF_PKT_SHIFT; + int _out_buf_size = DEF_BUF_SHIFT; static void _esws_on_connect(void *obj, char *proto); static void _esws_on_message(void *obj, const uint8_t *p_data, int p_data_size, int p_is_string); diff --git a/modules/websocket/emws_peer.cpp b/modules/websocket/emws_peer.cpp index 1ad3bdc825..69822f6ff3 100644 --- a/modules/websocket/emws_peer.cpp +++ b/modules/websocket/emws_peer.cpp @@ -33,10 +33,11 @@ #include "emws_peer.h" #include "core/io/ip.h" -void EMWSPeer::set_sock(int p_sock, unsigned int p_in_buf_size, unsigned int p_in_pkt_size) { +void EMWSPeer::set_sock(int p_sock, unsigned int p_in_buf_size, unsigned int p_in_pkt_size, unsigned int p_out_buf_size) { peer_sock = p_sock; _in_buffer.resize(p_in_pkt_size, p_in_buf_size); _packet_buffer.resize((1 << p_in_buf_size)); + _out_buf_size = p_out_buf_size; } void EMWSPeer::set_write_mode(WriteMode p_mode) { @@ -53,10 +54,13 @@ Error EMWSPeer::read_msg(const uint8_t *p_data, uint32_t p_size, bool p_is_strin } Error EMWSPeer::put_packet(const uint8_t *p_buffer, int p_buffer_size) { + ERR_FAIL_COND_V(_out_buf_size && (godot_js_websocket_buffered_amount(peer_sock) >= (1ULL << _out_buf_size)), ERR_OUT_OF_MEMORY); + int is_bin = write_mode == WebSocketPeer::WRITE_MODE_BINARY ? 1 : 0; + godot_js_websocket_send(peer_sock, p_buffer, p_buffer_size, is_bin); return OK; -}; +} Error EMWSPeer::get_packet(const uint8_t **r_buffer, int &r_buffer_size) { if (_in_buffer.packets_left() == 0) @@ -70,19 +74,26 @@ Error EMWSPeer::get_packet(const uint8_t **r_buffer, int &r_buffer_size) { r_buffer_size = read; return OK; -}; +} int EMWSPeer::get_available_packet_count() const { return _in_buffer.packets_left(); -}; +} + +int EMWSPeer::get_current_outbound_buffered_amount() const { + if (peer_sock != -1) { + return godot_js_websocket_buffered_amount(peer_sock); + } + return 0; +} bool EMWSPeer::was_string_packet() const { return _is_string; -}; +} bool EMWSPeer::is_connected_to_host() const { return peer_sock != -1; -}; +} void EMWSPeer::close(int p_code, String p_reason) { if (peer_sock != -1) { @@ -91,7 +102,7 @@ void EMWSPeer::close(int p_code, String p_reason) { _is_string = 0; _in_buffer.clear(); peer_sock = -1; -}; +} IPAddress EMWSPeer::get_connected_host() const { ERR_FAIL_V_MSG(IPAddress(), "Not supported in HTML5 export."); @@ -99,7 +110,7 @@ IPAddress EMWSPeer::get_connected_host() const { uint16_t EMWSPeer::get_connected_port() const { ERR_FAIL_V_MSG(0, "Not supported in HTML5 export."); -}; +} void EMWSPeer::set_no_delay(bool p_enabled) { ERR_FAIL_MSG("'set_no_delay' is not supported in HTML5 export."); @@ -107,10 +118,10 @@ void EMWSPeer::set_no_delay(bool p_enabled) { EMWSPeer::EMWSPeer() { close(); -}; +} EMWSPeer::~EMWSPeer() { close(); -}; +} #endif // JAVASCRIPT_ENABLED diff --git a/modules/websocket/emws_peer.h b/modules/websocket/emws_peer.h index 73e701720b..6e93ea31a2 100644 --- a/modules/websocket/emws_peer.h +++ b/modules/websocket/emws_peer.h @@ -48,6 +48,7 @@ typedef void (*WSOnError)(void *p_ref); extern int godot_js_websocket_create(void *p_ref, const char *p_url, const char *p_proto, WSOnOpen p_on_open, WSOnMessage p_on_message, WSOnError p_on_error, WSOnClose p_on_close); extern int godot_js_websocket_send(int p_id, const uint8_t *p_buf, int p_buf_len, int p_raw); +extern int godot_js_websocket_buffered_amount(int p_id); extern void godot_js_websocket_close(int p_id, int p_code, const char *p_reason); extern void godot_js_websocket_destroy(int p_id); } @@ -62,14 +63,16 @@ private: Vector<uint8_t> _packet_buffer; PacketBuffer<uint8_t> _in_buffer; uint8_t _is_string = 0; + int _out_buf_size = 0; public: Error read_msg(const uint8_t *p_data, uint32_t p_size, bool p_is_string); - void set_sock(int p_sock, unsigned int p_in_buf_size, unsigned int p_in_pkt_size); + void set_sock(int p_sock, unsigned int p_in_buf_size, unsigned int p_in_pkt_size, unsigned int p_out_buf_size); virtual int get_available_packet_count() const; virtual Error get_packet(const uint8_t **r_buffer, int &r_buffer_size); virtual Error put_packet(const uint8_t *p_buffer, int p_buffer_size); virtual int get_max_packet_size() const { return _packet_buffer.size(); }; + virtual int get_current_outbound_buffered_amount() const; virtual void close(int p_code = 1000, String p_reason = ""); virtual bool is_connected_to_host() const; diff --git a/modules/websocket/library_godot_websocket.js b/modules/websocket/library_godot_websocket.js index b182d1ecde..dd2fd1e94f 100644 --- a/modules/websocket/library_godot_websocket.js +++ b/modules/websocket/library_godot_websocket.js @@ -101,6 +101,15 @@ const GodotWebSocket = { return 0; }, + // Get current bufferedAmount + bufferedAmount: function (p_id) { + const ref = IDHandler.get(p_id); + if (!ref) { + return 0; // Godot object is gone. + } + return ref.bufferedAmount; + }, + create: function (socket, p_on_open, p_on_message, p_on_error, p_on_close) { const id = IDHandler.add(socket); socket.onopen = GodotWebSocket._onopen.bind(null, id, p_on_open); @@ -171,6 +180,11 @@ const GodotWebSocket = { return GodotWebSocket.send(p_id, out); }, + godot_js_websocket_buffered_amount__sig: 'ii', + godot_js_websocket_buffered_amount: function (p_id) { + return GodotWebSocket.bufferedAmount(p_id); + }, + godot_js_websocket_close__sig: 'viii', godot_js_websocket_close: function (p_id, p_code, p_reason) { const code = p_code; diff --git a/modules/websocket/remote_debugger_peer_websocket.h b/modules/websocket/remote_debugger_peer_websocket.h index 03c60fb480..590d925dcc 100644 --- a/modules/websocket/remote_debugger_peer_websocket.h +++ b/modules/websocket/remote_debugger_peer_websocket.h @@ -28,8 +28,8 @@ /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ /*************************************************************************/ -#ifndef SCRIPT_DEBUGGER_WEBSOCKET_H -#define SCRIPT_DEBUGGER_WEBSOCKET_H +#ifndef REMOTE_DEBUGGER_PEER_WEBSOCKET_H +#define REMOTE_DEBUGGER_PEER_WEBSOCKET_H #ifdef JAVASCRIPT_ENABLED #include "modules/websocket/emws_client.h" @@ -62,4 +62,4 @@ public: RemoteDebuggerPeerWebSocket(Ref<WebSocketPeer> p_peer = Ref<WebSocketPeer>()); }; -#endif // SCRIPT_DEBUGGER_WEBSOCKET_H +#endif // REMOTE_DEBUGGER_PEER_WEBSOCKET_H diff --git a/modules/websocket/websocket_client.cpp b/modules/websocket/websocket_client.cpp index af1dc8ff54..f7a8944745 100644 --- a/modules/websocket/websocket_client.cpp +++ b/modules/websocket/websocket_client.cpp @@ -86,7 +86,7 @@ void WebSocketClient::_on_peer_packet() { if (_is_multiplayer) { _process_multiplayer(get_peer(1), 1); } else { - emit_signal("data_received"); + emit_signal(SNAME("data_received")); } } @@ -94,27 +94,27 @@ void WebSocketClient::_on_connect(String p_protocol) { if (_is_multiplayer) { // need to wait for ID confirmation... } else { - emit_signal("connection_established", p_protocol); + emit_signal(SNAME("connection_established"), p_protocol); } } void WebSocketClient::_on_close_request(int p_code, String p_reason) { - emit_signal("server_close_request", p_code, p_reason); + emit_signal(SNAME("server_close_request"), p_code, p_reason); } void WebSocketClient::_on_disconnect(bool p_was_clean) { if (_is_multiplayer) { - emit_signal("connection_failed"); + emit_signal(SNAME("connection_failed")); } else { - emit_signal("connection_closed", p_was_clean); + emit_signal(SNAME("connection_closed"), p_was_clean); } } void WebSocketClient::_on_error() { if (_is_multiplayer) { - emit_signal("connection_failed"); + emit_signal(SNAME("connection_failed")); } else { - emit_signal("connection_error"); + emit_signal(SNAME("connection_error")); } } diff --git a/modules/websocket/websocket_multiplayer_peer.cpp b/modules/websocket/websocket_multiplayer_peer.cpp index 1beeb67b91..52d9a602a1 100644 --- a/modules/websocket/websocket_multiplayer_peer.cpp +++ b/modules/websocket/websocket_multiplayer_peer.cpp @@ -39,35 +39,15 @@ WebSocketMultiplayerPeer::~WebSocketMultiplayerPeer() { _clear(); } -int WebSocketMultiplayerPeer::_gen_unique_id() const { - uint32_t hash = 0; - - while (hash == 0 || hash == 1) { - hash = hash_djb2_one_32( - (uint32_t)OS::get_singleton()->get_ticks_usec()); - hash = hash_djb2_one_32( - (uint32_t)OS::get_singleton()->get_unix_time(), hash); - hash = hash_djb2_one_32( - (uint32_t)OS::get_singleton()->get_data_path().hash64(), hash); - hash = hash_djb2_one_32( - (uint32_t)((uint64_t)this), hash); //rely on aslr heap - hash = hash_djb2_one_32( - (uint32_t)((uint64_t)&hash), hash); //rely on aslr stack - hash = hash & 0x7FFFFFFF; // make it compatible with unsigned, since negative id is used for exclusion - } - - return hash; -} - void WebSocketMultiplayerPeer::_clear() { _peer_map.clear(); if (_current_packet.data != nullptr) { memfree(_current_packet.data); } - for (List<Packet>::Element *E = _incoming_packets.front(); E; E = E->next()) { - memfree(E->get().data); - E->get().data = nullptr; + for (Packet &E : _incoming_packets) { + memfree(E.data); + E.data = nullptr; } _incoming_packets.clear(); @@ -215,7 +195,7 @@ void WebSocketMultiplayerPeer::_store_pkt(int32_t p_source, int32_t p_dest, cons packet.destination = p_dest; memcpy(packet.data, &p_data[PROTO_SIZE], p_data_size); _incoming_packets.push_back(packet); - emit_signal("peer_packet", p_source); + emit_signal(SNAME("peer_packet"), p_source); } Error WebSocketMultiplayerPeer::_server_relay(int32_t p_from, int32_t p_to, const uint8_t *p_buffer, uint32_t p_buffer_size) { @@ -306,15 +286,15 @@ void WebSocketMultiplayerPeer::_process_multiplayer(Ref<WebSocketPeer> p_peer, u switch (type) { case SYS_ADD: // Add peer _peer_map[id] = Ref<WebSocketPeer>(); - emit_signal("peer_connected", id); + emit_signal(SNAME("peer_connected"), id); if (id == 1) { // We just connected to the server - emit_signal("connection_succeeded"); + emit_signal(SNAME("connection_succeeded")); } break; case SYS_DEL: // Remove peer _peer_map.erase(id); - emit_signal("peer_disconnected", id); + emit_signal(SNAME("peer_disconnected"), id); break; case SYS_ID: // Hello, server assigned ID _peer_id = id; diff --git a/modules/websocket/websocket_multiplayer_peer.h b/modules/websocket/websocket_multiplayer_peer.h index e3ccd1a795..4e80f876d6 100644 --- a/modules/websocket/websocket_multiplayer_peer.h +++ b/modules/websocket/websocket_multiplayer_peer.h @@ -75,7 +75,6 @@ protected: void _send_add(int32_t p_peer_id); void _send_sys(Ref<WebSocketPeer> p_peer, uint8_t p_type, int32_t p_peer_id); void _send_del(int32_t p_peer_id); - int _gen_unique_id() const; public: /* MultiplayerPeer */ diff --git a/modules/websocket/websocket_peer.cpp b/modules/websocket/websocket_peer.cpp index e77fdcfed2..ee13040821 100644 --- a/modules/websocket/websocket_peer.cpp +++ b/modules/websocket/websocket_peer.cpp @@ -47,6 +47,7 @@ void WebSocketPeer::_bind_methods() { ClassDB::bind_method(D_METHOD("get_connected_host"), &WebSocketPeer::get_connected_host); ClassDB::bind_method(D_METHOD("get_connected_port"), &WebSocketPeer::get_connected_port); ClassDB::bind_method(D_METHOD("set_no_delay", "enabled"), &WebSocketPeer::set_no_delay); + ClassDB::bind_method(D_METHOD("get_current_outbound_buffered_amount"), &WebSocketPeer::get_current_outbound_buffered_amount); BIND_ENUM_CONSTANT(WRITE_MODE_TEXT); BIND_ENUM_CONSTANT(WRITE_MODE_BINARY); diff --git a/modules/websocket/websocket_peer.h b/modules/websocket/websocket_peer.h index e9bb20f21f..517b8600d6 100644 --- a/modules/websocket/websocket_peer.h +++ b/modules/websocket/websocket_peer.h @@ -59,6 +59,7 @@ public: virtual uint16_t get_connected_port() const = 0; virtual bool was_string_packet() const = 0; virtual void set_no_delay(bool p_enabled) = 0; + virtual int get_current_outbound_buffered_amount() const = 0; WebSocketPeer(); ~WebSocketPeer(); diff --git a/modules/websocket/websocket_server.cpp b/modules/websocket/websocket_server.cpp index b996852f28..fb838109f3 100644 --- a/modules/websocket/websocket_server.cpp +++ b/modules/websocket/websocket_server.cpp @@ -71,7 +71,7 @@ void WebSocketServer::_bind_methods() { ADD_SIGNAL(MethodInfo("client_close_request", PropertyInfo(Variant::INT, "id"), PropertyInfo(Variant::INT, "code"), PropertyInfo(Variant::STRING, "reason"))); ADD_SIGNAL(MethodInfo("client_disconnected", PropertyInfo(Variant::INT, "id"), PropertyInfo(Variant::BOOL, "was_clean_close"))); - ADD_SIGNAL(MethodInfo("client_connected", PropertyInfo(Variant::INT, "id"), PropertyInfo(Variant::STRING, "protocol"))); + ADD_SIGNAL(MethodInfo("client_connected", PropertyInfo(Variant::INT, "id"), PropertyInfo(Variant::STRING, "protocol"), PropertyInfo(Variant::STRING, "resource_name"))); ADD_SIGNAL(MethodInfo("data_received", PropertyInfo(Variant::INT, "id"))); } @@ -137,17 +137,17 @@ void WebSocketServer::_on_peer_packet(int32_t p_peer_id) { if (_is_multiplayer) { _process_multiplayer(get_peer(p_peer_id), p_peer_id); } else { - emit_signal("data_received", p_peer_id); + emit_signal(SNAME("data_received"), p_peer_id); } } -void WebSocketServer::_on_connect(int32_t p_peer_id, String p_protocol) { +void WebSocketServer::_on_connect(int32_t p_peer_id, String p_protocol, String p_resource_name) { if (_is_multiplayer) { // Send add to clients _send_add(p_peer_id); - emit_signal("peer_connected", p_peer_id); + emit_signal(SNAME("peer_connected"), p_peer_id); } else { - emit_signal("client_connected", p_peer_id, p_protocol); + emit_signal(SNAME("client_connected"), p_peer_id, p_protocol, p_resource_name); } } @@ -155,12 +155,12 @@ void WebSocketServer::_on_disconnect(int32_t p_peer_id, bool p_was_clean) { if (_is_multiplayer) { // Send delete to clients _send_del(p_peer_id); - emit_signal("peer_disconnected", p_peer_id); + emit_signal(SNAME("peer_disconnected"), p_peer_id); } else { - emit_signal("client_disconnected", p_peer_id, p_was_clean); + emit_signal(SNAME("client_disconnected"), p_peer_id, p_was_clean); } } void WebSocketServer::_on_close_request(int32_t p_peer_id, int p_code, String p_reason) { - emit_signal("client_close_request", p_peer_id, p_code, p_reason); + emit_signal(SNAME("client_close_request"), p_peer_id, p_code, p_reason); } diff --git a/modules/websocket/websocket_server.h b/modules/websocket/websocket_server.h index 26864f3085..c4d651471f 100644 --- a/modules/websocket/websocket_server.h +++ b/modules/websocket/websocket_server.h @@ -63,7 +63,7 @@ public: virtual void disconnect_peer(int p_peer_id, int p_code = 1000, String p_reason = "") = 0; void _on_peer_packet(int32_t p_peer_id); - void _on_connect(int32_t p_peer_id, String p_protocol); + void _on_connect(int32_t p_peer_id, String p_protocol, String p_resource_name); void _on_disconnect(int32_t p_peer_id, bool p_was_clean); void _on_close_request(int32_t p_peer_id, int p_code, String p_reason); diff --git a/modules/websocket/wsl_peer.cpp b/modules/websocket/wsl_peer.cpp index 1dbadfed74..7f027e1c0d 100644 --- a/modules/websocket/wsl_peer.cpp +++ b/modules/websocket/wsl_peer.cpp @@ -205,7 +205,9 @@ void WSLPeer::make_context(PeerData *p_data, unsigned int p_in_buf_size, unsigne ERR_FAIL_COND(p_data == nullptr); _in_buffer.resize(p_in_pkt_size, p_in_buf_size); - _packet_buffer.resize((1 << MAX(p_in_buf_size, p_out_buf_size))); + _packet_buffer.resize(1 << p_in_buf_size); + _out_buf_size = p_out_buf_size; + _out_pkt_size = p_out_pkt_size; _data = p_data; _data->peer = this; @@ -239,6 +241,8 @@ void WSLPeer::poll() { Error WSLPeer::put_packet(const uint8_t *p_buffer, int p_buffer_size) { ERR_FAIL_COND_V(!is_connected_to_host(), FAILED); + ERR_FAIL_COND_V(_out_pkt_size && (wslay_event_get_queued_msg_count(_data->ctx) >= (1ULL << _out_pkt_size)), ERR_OUT_OF_MEMORY); + ERR_FAIL_COND_V(_out_buf_size && (wslay_event_get_queued_msg_length(_data->ctx) >= (1ULL << _out_buf_size)), ERR_OUT_OF_MEMORY); struct wslay_event_msg msg; // Should I use fragmented? msg.opcode = write_mode == WRITE_MODE_TEXT ? WSLAY_TEXT_FRAME : WSLAY_BINARY_FRAME; @@ -280,6 +284,12 @@ int WSLPeer::get_available_packet_count() const { return _in_buffer.packets_left(); } +int WSLPeer::get_current_outbound_buffered_amount() const { + ERR_FAIL_COND_V(!_data, 0); + + return wslay_event_get_queued_msg_length(_data->ctx); +} + bool WSLPeer::was_string_packet() const { return _is_string; } diff --git a/modules/websocket/wsl_peer.h b/modules/websocket/wsl_peer.h index f1ea98d384..260d4b183d 100644 --- a/modules/websocket/wsl_peer.h +++ b/modules/websocket/wsl_peer.h @@ -77,6 +77,9 @@ private: WriteMode write_mode = WRITE_MODE_BINARY; + int _out_buf_size = 0; + int _out_pkt_size = 0; + public: int close_code = -1; String close_reason; @@ -86,6 +89,7 @@ public: virtual Error get_packet(const uint8_t **r_buffer, int &r_buffer_size); virtual Error put_packet(const uint8_t *p_buffer, int p_buffer_size); virtual int get_max_packet_size() const { return _packet_buffer.size(); }; + virtual int get_current_outbound_buffered_amount() const; virtual void close_now(); virtual void close(int p_code = 1000, String p_reason = ""); diff --git a/modules/websocket/wsl_server.cpp b/modules/websocket/wsl_server.cpp index c889562732..7402bbb46e 100644 --- a/modules/websocket/wsl_server.cpp +++ b/modules/websocket/wsl_server.cpp @@ -34,7 +34,7 @@ #include "core/config/project_settings.h" #include "core/os/os.h" -bool WSLServer::PendingPeer::_parse_request(const Vector<String> p_protocols) { +bool WSLServer::PendingPeer::_parse_request(const Vector<String> p_protocols, String &r_resource_name) { Vector<String> psa = String((char *)req_buf).split("\r\n"); int len = psa.size(); ERR_FAIL_COND_V_MSG(len < 4, false, "Not enough response headers, got: " + itos(len) + ", expected >= 4."); @@ -45,6 +45,7 @@ bool WSLServer::PendingPeer::_parse_request(const Vector<String> p_protocols) { // Wrong protocol ERR_FAIL_COND_V_MSG(req[0] != "GET" || req[2] != "HTTP/1.1", false, "Invalid method or HTTP version."); + r_resource_name = req[1]; Map<String, String> headers; for (int i = 1; i < len; i++) { Vector<String> header = psa[i].split(":", false, 1); @@ -95,7 +96,7 @@ bool WSLServer::PendingPeer::_parse_request(const Vector<String> p_protocols) { return true; } -Error WSLServer::PendingPeer::do_handshake(const Vector<String> p_protocols, uint64_t p_timeout) { +Error WSLServer::PendingPeer::do_handshake(const Vector<String> p_protocols, uint64_t p_timeout, String &r_resource_name) { if (OS::get_singleton()->get_ticks_msec() - time > p_timeout) { print_verbose(vformat("WebSocket handshake timed out after %.3f seconds.", p_timeout * 0.001)); return ERR_TIMEOUT; @@ -130,7 +131,7 @@ Error WSLServer::PendingPeer::do_handshake(const Vector<String> p_protocols, uin int l = req_pos; if (l > 3 && r[l] == '\n' && r[l - 1] == '\r' && r[l - 2] == '\n' && r[l - 3] == '\r') { r[l - 3] = '\0'; - if (!_parse_request(p_protocols)) { + if (!_parse_request(p_protocols, r_resource_name)) { return FAILED; } String s = "HTTP/1.1 101 Switching Protocols\r\n"; @@ -189,15 +190,16 @@ void WSLServer::poll() { remove_ids.push_back(E->key()); } } - for (List<int>::Element *E = remove_ids.front(); E; E = E->next()) { - _peer_map.erase(E->get()); + for (int &E : remove_ids) { + _peer_map.erase(E); } remove_ids.clear(); List<Ref<PendingPeer>> remove_peers; - for (List<Ref<PendingPeer>>::Element *E = _pending.front(); E; E = E->next()) { - Ref<PendingPeer> ppeer = E->get(); - Error err = ppeer->do_handshake(_protocols, handshake_timeout); + for (const Ref<PendingPeer> &E : _pending) { + String resource_name; + Ref<PendingPeer> ppeer = E; + Error err = ppeer->do_handshake(_protocols, handshake_timeout, resource_name); if (err == ERR_BUSY) { continue; } else if (err != OK) { @@ -205,7 +207,7 @@ void WSLServer::poll() { continue; } // Creating new peer - int32_t id = _gen_unique_id(); + int32_t id = generate_unique_id(); WSLPeer::PeerData *data = memnew(struct WSLPeer::PeerData); data->obj = this; @@ -220,10 +222,10 @@ void WSLServer::poll() { _peer_map[id] = ws_peer; remove_peers.push_back(ppeer); - _on_connect(id, ppeer->protocol); + _on_connect(id, ppeer->protocol, resource_name); } - for (List<Ref<PendingPeer>>::Element *E = remove_peers.front(); E; E = E->next()) { - _pending.erase(E->get()); + for (const Ref<PendingPeer> &E : remove_peers) { + _pending.erase(E); } remove_peers.clear(); diff --git a/modules/websocket/wsl_server.h b/modules/websocket/wsl_server.h index a428c89f4f..93c8bd9604 100644 --- a/modules/websocket/wsl_server.h +++ b/modules/websocket/wsl_server.h @@ -46,7 +46,7 @@ class WSLServer : public WebSocketServer { private: class PendingPeer : public RefCounted { private: - bool _parse_request(const Vector<String> p_protocols); + bool _parse_request(const Vector<String> p_protocols, String &r_resource_name); public: Ref<StreamPeerTCP> tcp; @@ -62,7 +62,7 @@ private: CharString response; int response_sent = 0; - Error do_handshake(const Vector<String> p_protocols, uint64_t p_timeout); + Error do_handshake(const Vector<String> p_protocols, uint64_t p_timeout, String &r_resource_name); }; int _in_buf_size = DEF_BUF_SHIFT; diff --git a/modules/webxr/doc_classes/WebXRInterface.xml b/modules/webxr/doc_classes/WebXRInterface.xml index 9b3a063ef5..ff7c46bbae 100644 --- a/modules/webxr/doc_classes/WebXRInterface.xml +++ b/modules/webxr/doc_classes/WebXRInterface.xml @@ -88,17 +88,15 @@ - Using [XRController3D] nodes and their [signal XRController3D.button_pressed] and [signal XRController3D.button_released] signals. This is how controllers are typically handled in AR/VR apps in Godot, however, this will only work with advanced VR controllers like the Oculus Touch or Index controllers, for example. The buttons codes are defined by [url=https://immersive-web.github.io/webxr-gamepads-module/#xr-standard-gamepad-mapping]Section 3.3 of the WebXR Gamepads Module[/url]. - Using [method Node._unhandled_input] and [InputEventJoypadButton] or [InputEventJoypadMotion]. This works the same as normal joypads, except the [member InputEvent.device] starts at 100, so the left controller is 100 and the right controller is 101, and the button codes are also defined by [url=https://immersive-web.github.io/webxr-gamepads-module/#xr-standard-gamepad-mapping]Section 3.3 of the WebXR Gamepads Module[/url]. - Using the [signal select], [signal squeeze] and related signals. This method will work for both advanced VR controllers, and non-traditional "controllers" like a tap on the screen, a spoken voice command or a button press on the device itself. The [code]controller_id[/code] passed to these signals is the same id as used in [member XRController3D.controller_id]. - You can use one or all of these methods to allow your game or app to support a wider or narrower set of devices and input methods, or to allow more advanced interations with more advanced devices. + You can use one or all of these methods to allow your game or app to support a wider or narrower set of devices and input methods, or to allow more advanced interactions with more advanced devices. </description> <tutorials> <link title="How to make a VR game for WebXR with Godot">https://www.snopekgames.com/blog/2020/how-make-vr-game-webxr-godot</link> </tutorials> <methods> <method name="get_controller" qualifiers="const"> - <return type="XRPositionalTracker"> - </return> - <argument index="0" name="controller_id" type="int"> - </argument> + <return type="XRPositionalTracker" /> + <argument index="0" name="controller_id" type="int" /> <description> Gets an [XRPositionalTracker] for the given [code]controller_id[/code]. In the context of WebXR, a "controller" can be an advanced VR controller like the Oculus Touch or Index controllers, or even a tap on the screen, a spoken voice command or a button press on the device itself. When a non-traditional controller is used, interpret the position and orientation of the [XRPositionalTracker] as a ray pointing at the object the user wishes to interact with. @@ -112,10 +110,8 @@ </description> </method> <method name="is_session_supported"> - <return type="void"> - </return> - <argument index="0" name="session_mode" type="String"> - </argument> + <return type="void" /> + <argument index="0" name="session_mode" type="String" /> <description> Checks if the given [code]session_mode[/code] is supported by the user's browser. Possible values come from [url=https://developer.mozilla.org/en-US/docs/Web/API/XRSessionMode]WebXR's XRSessionMode[/url], including: [code]"immersive-vr"[/code], [code]"immersive-ar"[/code], and [code]"inline"[/code]. @@ -170,24 +166,21 @@ </description> </signal> <signal name="select"> - <argument index="0" name="controller_id" type="int"> - </argument> + <argument index="0" name="controller_id" type="int" /> <description> Emitted after one of the "controllers" has finished its "primary action". Use [method get_controller] to get more information about the controller. </description> </signal> <signal name="selectend"> - <argument index="0" name="controller_id" type="int"> - </argument> + <argument index="0" name="controller_id" type="int" /> <description> Emitted when one of the "controllers" has finished its "primary action". Use [method get_controller] to get more information about the controller. </description> </signal> <signal name="selectstart"> - <argument index="0" name="controller_id" type="int"> - </argument> + <argument index="0" name="controller_id" type="int" /> <description> Emitted when one of the "controllers" has started its "primary action". Use [method get_controller] to get more information about the controller. @@ -200,8 +193,7 @@ </description> </signal> <signal name="session_failed"> - <argument index="0" name="message" type="String"> - </argument> + <argument index="0" name="message" type="String" /> <description> Emitted by [method XRInterface.initialize] if the session fails to start. [code]message[/code] may optionally contain an error message from WebXR, or an empty string if no message is available. @@ -214,33 +206,28 @@ </description> </signal> <signal name="session_supported"> - <argument index="0" name="session_mode" type="String"> - </argument> - <argument index="1" name="supported" type="bool"> - </argument> + <argument index="0" name="session_mode" type="String" /> + <argument index="1" name="supported" type="bool" /> <description> Emitted by [method is_session_supported] to indicate if the given [code]session_mode[/code] is supported or not. </description> </signal> <signal name="squeeze"> - <argument index="0" name="controller_id" type="int"> - </argument> + <argument index="0" name="controller_id" type="int" /> <description> Emitted after one of the "controllers" has finished its "primary squeeze action". Use [method get_controller] to get more information about the controller. </description> </signal> <signal name="squeezeend"> - <argument index="0" name="controller_id" type="int"> - </argument> + <argument index="0" name="controller_id" type="int" /> <description> Emitted when one of the "controllers" has finished its "primary squeeze action". Use [method get_controller] to get more information about the controller. </description> </signal> <signal name="squeezestart"> - <argument index="0" name="controller_id" type="int"> - </argument> + <argument index="0" name="controller_id" type="int" /> <description> Emitted when one of the "controllers" has started its "primary squeeze action". Use [method get_controller] to get more information about the controller. diff --git a/modules/webxr/webxr_interface_js.cpp b/modules/webxr/webxr_interface_js.cpp index 2eab0cdb07..099e769303 100644 --- a/modules/webxr/webxr_interface_js.cpp +++ b/modules/webxr/webxr_interface_js.cpp @@ -35,6 +35,7 @@ #include "core/os/os.h" #include "emscripten.h" #include "godot_webxr.h" +#include "servers/rendering/renderer_compositor.h" #include <stdlib.h> void _emwebxr_on_session_supported(char *p_session_mode, int p_supported) { @@ -45,7 +46,7 @@ void _emwebxr_on_session_supported(char *p_session_mode, int p_supported) { ERR_FAIL_COND(interface.is_null()); String session_mode = String(p_session_mode); - interface->emit_signal("session_supported", session_mode, p_supported ? true : false); + interface->emit_signal(SNAME("session_supported"), session_mode, p_supported ? true : false); } void _emwebxr_on_session_started(char *p_reference_space_type) { @@ -57,7 +58,7 @@ void _emwebxr_on_session_started(char *p_reference_space_type) { String reference_space_type = String(p_reference_space_type); ((WebXRInterfaceJS *)interface.ptr())->_set_reference_space_type(reference_space_type); - interface->emit_signal("session_started"); + interface->emit_signal(SNAME("session_started")); } void _emwebxr_on_session_ended() { @@ -68,7 +69,7 @@ void _emwebxr_on_session_ended() { ERR_FAIL_COND(interface.is_null()); interface->uninitialize(); - interface->emit_signal("session_ended"); + interface->emit_signal(SNAME("session_ended")); } void _emwebxr_on_session_failed(char *p_message) { @@ -81,7 +82,7 @@ void _emwebxr_on_session_failed(char *p_message) { interface->uninitialize(); String message = String(p_message); - interface->emit_signal("session_failed", message); + interface->emit_signal(SNAME("session_failed"), message); } void _emwebxr_on_controller_changed() { @@ -202,8 +203,8 @@ int WebXRInterfaceJS::get_capabilities() const { return XRInterface::XR_STEREO | XRInterface::XR_MONO; }; -bool WebXRInterfaceJS::is_stereo() { - return godot_webxr_get_view_count() == 2; +uint32_t WebXRInterfaceJS::get_view_count() { + return godot_webxr_get_view_count(); }; bool WebXRInterfaceJS::is_initialized() const { @@ -376,6 +377,22 @@ void WebXRInterfaceJS::commit_for_eye(XRInterface::Eyes p_eye, RID p_render_targ return; } godot_webxr_commit_for_eye(p_eye); +} + +Vector<BlitToScreen> WebXRInterfaceJS::commit_views(RID p_render_target, const Rect2 &p_screen_rect) { + Vector<BlitToScreen> blit_to_screen; + + if (!initialized) { + return blit_to_screen; + } + + // @todo Refactor this to be based on "views" rather than "eyes". + godot_webxr_commit_for_eye(XRInterface::EYE_LEFT); + if (godot_webxr_get_view_count() > 1) { + godot_webxr_commit_for_eye(XRInterface::EYE_RIGHT); + } + + return blit_to_screen; }; void WebXRInterfaceJS::process() { @@ -425,7 +442,7 @@ void WebXRInterfaceJS::_update_tracker(int p_controller_id) { int *buttons = godot_webxr_get_controller_buttons(p_controller_id); if (buttons) { for (int i = 0; i < buttons[0]; i++) { - input->joy_button(p_controller_id + 100, i, *((float *)buttons + (i + 1))); + input->joy_button(p_controller_id + 100, (JoyButton)i, *((float *)buttons + (i + 1))); } free(buttons); } @@ -436,7 +453,7 @@ void WebXRInterfaceJS::_update_tracker(int p_controller_id) { Input::JoyAxisValue joy_axis; joy_axis.min = -1; joy_axis.value = *((float *)axes + (i + 1)); - input->joy_axis(p_controller_id + 100, i, joy_axis); + input->joy_axis(p_controller_id + 100, (JoyAxis)i, joy_axis); } free(axes); } diff --git a/modules/webxr/webxr_interface_js.h b/modules/webxr/webxr_interface_js.h index 723ab952cd..f9368582b7 100644 --- a/modules/webxr/webxr_interface_js.h +++ b/modules/webxr/webxr_interface_js.h @@ -83,12 +83,13 @@ public: virtual void uninitialize() override; virtual Size2 get_render_targetsize() override; - virtual bool is_stereo() override; + virtual uint32_t get_view_count() override; virtual Transform3D get_camera_transform() override; virtual Transform3D get_transform_for_view(uint32_t p_view, const Transform3D &p_cam_transform) override; virtual CameraMatrix get_projection_for_view(uint32_t p_view, real_t p_aspect, real_t p_z_near, real_t p_z_far) override; virtual unsigned int get_external_texture_for_eye(XRInterface::Eyes p_eye) override; virtual void commit_for_eye(XRInterface::Eyes p_eye, RID p_render_target, const Rect2 &p_screen_rect) override; + virtual Vector<BlitToScreen> commit_views(RID p_render_target, const Rect2 &p_screen_rect) override; virtual void process() override; virtual void notification(int p_what) override; diff --git a/platform/android/display_server_android.cpp b/platform/android/display_server_android.cpp index 1fcc3d4a5c..af8829324b 100644 --- a/platform/android/display_server_android.cpp +++ b/platform/android/display_server_android.cpp @@ -334,13 +334,6 @@ bool DisplayServerAndroid::can_any_window_draw() const { return true; } -void DisplayServerAndroid::alert(const String &p_alert, const String &p_title) { - GodotJavaWrapper *godot_java = OS_Android::get_singleton()->get_godot_java(); - ERR_FAIL_COND(!godot_java); - - godot_java->alert(p_alert, p_title); -} - void DisplayServerAndroid::process_events() { Input::get_singleton()->flush_accumulated_events(); } @@ -361,7 +354,7 @@ Vector<String> DisplayServerAndroid::get_rendering_drivers_func() { DisplayServer *DisplayServerAndroid::create_func(const String &p_rendering_driver, DisplayServer::WindowMode p_mode, DisplayServer::VSyncMode p_vsync_mode, uint32_t p_flags, const Vector2i &p_resolution, Error &r_error) { DisplayServer *ds = memnew(DisplayServerAndroid(p_rendering_driver, p_mode, p_vsync_mode, p_flags, p_resolution, r_error)); if (r_error != OK) { - ds->alert("Your video card driver does not support any of the supported Vulkan versions.", "Unable to initialize Video driver"); + OS::get_singleton()->alert("Your video card driver does not support any of the supported Vulkan versions.", "Unable to initialize Video driver"); } return ds; } diff --git a/platform/android/display_server_android.h b/platform/android/display_server_android.h index bd5bed31cd..9b9f5e99f6 100644 --- a/platform/android/display_server_android.h +++ b/platform/android/display_server_android.h @@ -129,71 +129,82 @@ private: public: static DisplayServerAndroid *get_singleton(); - virtual bool has_feature(Feature p_feature) const; - virtual String get_name() const; + virtual bool has_feature(Feature p_feature) const override; + virtual String get_name() const override; - virtual void clipboard_set(const String &p_text); - virtual String clipboard_get() const; + virtual void clipboard_set(const String &p_text) override; + virtual String clipboard_get() const override; - virtual void screen_set_keep_on(bool p_enable); - virtual bool screen_is_kept_on() const; + virtual void screen_set_keep_on(bool p_enable) override; + virtual bool screen_is_kept_on() const override; - virtual void screen_set_orientation(ScreenOrientation p_orientation, int p_screen = SCREEN_OF_MAIN_WINDOW); - virtual ScreenOrientation screen_get_orientation(int p_screen = SCREEN_OF_MAIN_WINDOW) const; + virtual void screen_set_orientation(ScreenOrientation p_orientation, int p_screen = SCREEN_OF_MAIN_WINDOW) override; + virtual ScreenOrientation screen_get_orientation(int p_screen = SCREEN_OF_MAIN_WINDOW) const override; - virtual int get_screen_count() const; - virtual Point2i screen_get_position(int p_screen = SCREEN_OF_MAIN_WINDOW) const; - virtual Size2i screen_get_size(int p_screen = SCREEN_OF_MAIN_WINDOW) const; - virtual Rect2i screen_get_usable_rect(int p_screen = SCREEN_OF_MAIN_WINDOW) const; - virtual int screen_get_dpi(int p_screen = SCREEN_OF_MAIN_WINDOW) const; - virtual bool screen_is_touchscreen(int p_screen = SCREEN_OF_MAIN_WINDOW) const; + virtual int get_screen_count() const override; + virtual Point2i screen_get_position(int p_screen = SCREEN_OF_MAIN_WINDOW) const override; + virtual Size2i screen_get_size(int p_screen = SCREEN_OF_MAIN_WINDOW) const override; + virtual Rect2i screen_get_usable_rect(int p_screen = SCREEN_OF_MAIN_WINDOW) const override; + virtual int screen_get_dpi(int p_screen = SCREEN_OF_MAIN_WINDOW) const override; + virtual bool screen_is_touchscreen(int p_screen = SCREEN_OF_MAIN_WINDOW) const override; - virtual void virtual_keyboard_show(const String &p_existing_text, const Rect2 &p_screen_rect = Rect2(), bool p_multiline = false, int p_max_length = -1, int p_cursor_start = -1, int p_cursor_end = -1); - virtual void virtual_keyboard_hide(); - virtual int virtual_keyboard_get_height() const; + virtual void virtual_keyboard_show(const String &p_existing_text, const Rect2 &p_screen_rect = Rect2(), bool p_multiline = false, int p_max_length = -1, int p_cursor_start = -1, int p_cursor_end = -1) override; + virtual void virtual_keyboard_hide() override; + virtual int virtual_keyboard_get_height() const override; - virtual void window_set_window_event_callback(const Callable &p_callable, WindowID p_window = MAIN_WINDOW_ID); - virtual void window_set_input_event_callback(const Callable &p_callable, WindowID p_window = MAIN_WINDOW_ID); - virtual void window_set_input_text_callback(const Callable &p_callable, WindowID p_window = MAIN_WINDOW_ID); - virtual void window_set_rect_changed_callback(const Callable &p_callable, WindowID p_window = MAIN_WINDOW_ID); - virtual void window_set_drop_files_callback(const Callable &p_callable, WindowID p_window = MAIN_WINDOW_ID); + virtual void window_set_window_event_callback(const Callable &p_callable, WindowID p_window = MAIN_WINDOW_ID) override; + virtual void window_set_input_event_callback(const Callable &p_callable, WindowID p_window = MAIN_WINDOW_ID) override; + virtual void window_set_input_text_callback(const Callable &p_callable, WindowID p_window = MAIN_WINDOW_ID) override; + virtual void window_set_rect_changed_callback(const Callable &p_callable, WindowID p_window = MAIN_WINDOW_ID) override; + virtual void window_set_drop_files_callback(const Callable &p_callable, WindowID p_window = MAIN_WINDOW_ID) override; void send_window_event(WindowEvent p_event) const; void send_input_event(const Ref<InputEvent> &p_event) const; void send_input_text(const String &p_text) const; - virtual Vector<WindowID> get_window_list() const; - virtual WindowID get_window_at_screen_position(const Point2i &p_position) const; - virtual void window_attach_instance_id(ObjectID p_instance, WindowID p_window = MAIN_WINDOW_ID); - virtual ObjectID window_get_attached_instance_id(WindowID p_window = MAIN_WINDOW_ID) const; - virtual void window_set_title(const String &p_title, WindowID p_window = MAIN_WINDOW_ID); - virtual int window_get_current_screen(WindowID p_window = MAIN_WINDOW_ID) const; - virtual void window_set_current_screen(int p_screen, WindowID p_window = MAIN_WINDOW_ID); - virtual Point2i window_get_position(WindowID p_window = MAIN_WINDOW_ID) const; - virtual void window_set_position(const Point2i &p_position, WindowID p_window = MAIN_WINDOW_ID); - virtual void window_set_transient(WindowID p_window, WindowID p_parent); - virtual void window_set_max_size(const Size2i p_size, WindowID p_window = MAIN_WINDOW_ID); - virtual Size2i window_get_max_size(WindowID p_window = MAIN_WINDOW_ID) const; - virtual void window_set_min_size(const Size2i p_size, WindowID p_window = MAIN_WINDOW_ID); - virtual Size2i window_get_min_size(WindowID p_window = MAIN_WINDOW_ID) const; - virtual void window_set_size(const Size2i p_size, WindowID p_window = MAIN_WINDOW_ID); - virtual Size2i window_get_size(WindowID p_window = MAIN_WINDOW_ID) const; - virtual Size2i window_get_real_size(WindowID p_window = MAIN_WINDOW_ID) const; - virtual void window_set_mode(WindowMode p_mode, WindowID p_window = MAIN_WINDOW_ID); - virtual WindowMode window_get_mode(WindowID p_window = MAIN_WINDOW_ID) const; - virtual bool window_is_maximize_allowed(WindowID p_window = MAIN_WINDOW_ID) const; - virtual void window_set_flag(WindowFlags p_flag, bool p_enabled, WindowID p_window = MAIN_WINDOW_ID); - virtual bool window_get_flag(WindowFlags p_flag, WindowID p_window = MAIN_WINDOW_ID) const; - virtual void window_request_attention(WindowID p_window = MAIN_WINDOW_ID); - virtual void window_move_to_foreground(WindowID p_window = MAIN_WINDOW_ID); - virtual bool window_can_draw(WindowID p_window = MAIN_WINDOW_ID) const; - virtual bool can_any_window_draw() const; - virtual void window_set_vsync_mode(DisplayServer::VSyncMode p_vsync_mode, WindowID p_window = MAIN_WINDOW_ID); - virtual DisplayServer::VSyncMode window_get_vsync_mode(WindowID p_vsync_mode) const; - - virtual void alert(const String &p_alert, const String &p_title); - - virtual void process_events(); + virtual Vector<WindowID> get_window_list() const override; + virtual WindowID get_window_at_screen_position(const Point2i &p_position) const override; + virtual void window_attach_instance_id(ObjectID p_instance, WindowID p_window = MAIN_WINDOW_ID) override; + virtual ObjectID window_get_attached_instance_id(WindowID p_window = MAIN_WINDOW_ID) const override; + virtual void window_set_title(const String &p_title, WindowID p_window = MAIN_WINDOW_ID) override; + + virtual int window_get_current_screen(WindowID p_window = MAIN_WINDOW_ID) const override; + virtual void window_set_current_screen(int p_screen, WindowID p_window = MAIN_WINDOW_ID) override; + + virtual Point2i window_get_position(WindowID p_window = MAIN_WINDOW_ID) const override; + virtual void window_set_position(const Point2i &p_position, WindowID p_window = MAIN_WINDOW_ID) override; + + virtual void window_set_transient(WindowID p_window, WindowID p_parent) override; + + virtual void window_set_max_size(const Size2i p_size, WindowID p_window = MAIN_WINDOW_ID) override; + virtual Size2i window_get_max_size(WindowID p_window = MAIN_WINDOW_ID) const override; + + virtual void window_set_min_size(const Size2i p_size, WindowID p_window = MAIN_WINDOW_ID) override; + virtual Size2i window_get_min_size(WindowID p_window = MAIN_WINDOW_ID) const override; + + virtual void window_set_size(const Size2i p_size, WindowID p_window = MAIN_WINDOW_ID) override; + virtual Size2i window_get_size(WindowID p_window = MAIN_WINDOW_ID) const override; + virtual Size2i window_get_real_size(WindowID p_window = MAIN_WINDOW_ID) const override; + + virtual void window_set_mode(WindowMode p_mode, WindowID p_window = MAIN_WINDOW_ID) override; + virtual WindowMode window_get_mode(WindowID p_window = MAIN_WINDOW_ID) const override; + + virtual bool window_is_maximize_allowed(WindowID p_window = MAIN_WINDOW_ID) const override; + + virtual void window_set_flag(WindowFlags p_flag, bool p_enabled, WindowID p_window = MAIN_WINDOW_ID) override; + virtual bool window_get_flag(WindowFlags p_flag, WindowID p_window = MAIN_WINDOW_ID) const override; + + virtual void window_request_attention(WindowID p_window = MAIN_WINDOW_ID) override; + virtual void window_move_to_foreground(WindowID p_window = MAIN_WINDOW_ID) override; + + virtual bool window_can_draw(WindowID p_window = MAIN_WINDOW_ID) const override; + + virtual bool can_any_window_draw() const override; + + virtual void window_set_vsync_mode(DisplayServer::VSyncMode p_vsync_mode, WindowID p_window = MAIN_WINDOW_ID) override; + virtual DisplayServer::VSyncMode window_get_vsync_mode(WindowID p_vsync_mode) const override; + + virtual void process_events() override; void process_accelerometer(const Vector3 &p_accelerometer); void process_gravity(const Vector3 &p_gravity); @@ -207,11 +218,11 @@ public: void process_joy_event(JoypadEvent p_event); void process_key_event(int p_keycode, int p_scancode, int p_unicode_char, bool p_pressed); - virtual void cursor_set_shape(CursorShape p_shape); - virtual CursorShape cursor_get_shape() const; + virtual void cursor_set_shape(CursorShape p_shape) override; + virtual CursorShape cursor_get_shape() const override; - void mouse_set_mode(MouseMode p_mode); - MouseMode mouse_get_mode() const; + virtual void mouse_set_mode(MouseMode p_mode) override; + virtual MouseMode mouse_get_mode() const override; static DisplayServer *create_func(const String &p_rendering_driver, WindowMode p_mode, DisplayServer::VSyncMode p_vsync_mode, uint32_t p_flags, const Vector2i &p_resolution, Error &r_error); static Vector<String> get_rendering_drivers_func(); @@ -220,8 +231,8 @@ public: void reset_window(); void notify_surface_changed(int p_width, int p_height); - virtual Point2i mouse_get_position() const; - virtual MouseButton mouse_get_button_state() const; + virtual Point2i mouse_get_position() const override; + virtual MouseButton mouse_get_button_state() const override; DisplayServerAndroid(const String &p_rendering_driver, WindowMode p_mode, DisplayServer::VSyncMode p_vsync_mode, uint32_t p_flags, const Vector2i &p_resolution, Error &r_error); ~DisplayServerAndroid(); diff --git a/platform/android/export/export.cpp b/platform/android/export/export.cpp index 6661698d3e..1795bbe523 100644 --- a/platform/android/export/export.cpp +++ b/platform/android/export/export.cpp @@ -1817,12 +1817,12 @@ public: MutexLock lock(device_lock); - EditorProgress ep("run", "Running on " + devices[p_device].name, 3); + EditorProgress ep("run", vformat(TTR("Running on %s"), devices[p_device].name), 3); String adb = get_adb_path(); // Export_temp APK. - if (ep.step("Exporting APK...", 0)) { + if (ep.step(TTR("Exporting APK..."), 0)) { return ERR_SKIP; } @@ -1857,7 +1857,7 @@ public: String package_name = p_preset->get("package/unique_name"); if (remove_prev) { - if (ep.step("Uninstalling...", 1)) { + if (ep.step(TTR("Uninstalling..."), 1)) { CLEANUP_AND_RETURN(ERR_SKIP); } @@ -1874,7 +1874,7 @@ public: } print_line("Installing to device (please wait...): " + devices[p_device].name); - if (ep.step("Installing to device, please wait...", 2)) { + if (ep.step(TTR("Installing to device, please wait..."), 2)) { CLEANUP_AND_RETURN(ERR_SKIP); } @@ -1889,7 +1889,7 @@ public: err = OS::get_singleton()->execute(adb, args, &output, &rv, true); print_verbose(output); if (err || rv != 0) { - EditorNode::add_io_error("Could not install to device: " + output); + EditorNode::add_io_error(vformat(TTR("Could not install to device: %s"), output)); CLEANUP_AND_RETURN(ERR_CANT_CREATE); } @@ -1945,7 +1945,7 @@ public: } } - if (ep.step("Running on device...", 3)) { + if (ep.step(TTR("Running on device..."), 3)) { CLEANUP_AND_RETURN(ERR_SKIP); } args.clear(); @@ -1967,7 +1967,7 @@ public: err = OS::get_singleton()->execute(adb, args, &output, &rv, true); print_verbose(output); if (err || rv != 0) { - EditorNode::add_io_error("Could not execute on device."); + EditorNode::add_io_error(TTR("Could not execute on device.")); CLEANUP_AND_RETURN(ERR_CANT_CREATE); } @@ -2064,11 +2064,12 @@ public: err += template_err; } } else { - r_missing_templates = !exists_export_template("android_source.zip", &err); - bool installed_android_build_template = FileAccess::exists("res://android/build/build.gradle"); if (!installed_android_build_template) { + r_missing_templates = !exists_export_template("android_source.zip", &err); err += TTR("Android build template not installed in the project. Install it from the Project menu.") + "\n"; + } else { + r_missing_templates = false; } valid = installed_android_build_template && !r_missing_templates; @@ -2325,7 +2326,7 @@ public: String apksigner = get_apksigner_path(); print_verbose("Starting signing of the " + export_label + " binary using " + apksigner); if (!FileAccess::exists(apksigner)) { - EditorNode::add_io_error("'apksigner' could not be found.\nPlease check the command is available in the Android SDK build-tools directory.\nThe resulting " + export_label + " is unsigned."); + EditorNode::add_io_error(vformat(TTR("'apksigner' could not be found.\nPlease check the command is available in the Android SDK build-tools directory.\nThe resulting %s is unsigned."), export_label)); return OK; } @@ -2343,7 +2344,7 @@ public: user = EditorSettings::get_singleton()->get("export/android/debug_keystore_user"); } - if (ep.step("Signing debug " + export_label + "...", 104)) { + if (ep.step(vformat(TTR("Signing debug %s..."), export_label), 104)) { return ERR_SKIP; } @@ -2352,13 +2353,13 @@ public: password = release_password; user = release_username; - if (ep.step("Signing release " + export_label + "...", 104)) { + if (ep.step(vformat(TTR("Signing release %s..."), export_label), 104)) { return ERR_SKIP; } } if (!FileAccess::exists(keystore)) { - EditorNode::add_io_error("Could not find keystore, unable to export."); + EditorNode::add_io_error(TTR("Could not find keystore, unable to export.")); return ERR_FILE_CANT_OPEN; } @@ -2382,11 +2383,11 @@ public: OS::get_singleton()->execute(apksigner, args, &output, &retval, true); print_verbose(output); if (retval) { - EditorNode::add_io_error("'apksigner' returned with error #" + itos(retval)); + EditorNode::add_io_error(vformat(TTR("'apksigner' returned with error #%d"), retval)); return ERR_CANT_CREATE; } - if (ep.step("Verifying " + export_label + "...", 105)) { + if (ep.step(vformat(TTR("Verifying %s..."), export_label), 105)) { return ERR_SKIP; } @@ -2402,7 +2403,7 @@ public: OS::get_singleton()->execute(apksigner, args, &output, &retval, true); print_verbose(output); if (retval) { - EditorNode::add_io_error("'apksigner' verification of " + export_label + " failed."); + EditorNode::add_io_error(vformat(TTR("'apksigner' verification of %s failed."), export_label)); return ERR_CANT_CREATE; } @@ -2465,7 +2466,7 @@ public: String src_apk; Error err; - EditorProgress ep("export", "Exporting for Android", 105, true); + EditorProgress ep("export", TTR("Exporting for Android"), 105, true); bool use_custom_build = bool(p_preset->get("custom_template/use_custom_build")); bool p_give_internet = p_flags & (DEBUG_FLAG_DUMB_CLIENT | DEBUG_FLAG_REMOTE_DEBUG); @@ -2514,7 +2515,7 @@ public: return ERR_UNCONFIGURED; } if (export_format > EXPORT_FORMAT_AAB || export_format < EXPORT_FORMAT_APK) { - EditorNode::add_io_error("Unsupported export format!\n"); + EditorNode::add_io_error(TTR("Unsupported export format!\n")); return ERR_UNCONFIGURED; //TODO: is this the right error? } @@ -2544,7 +2545,7 @@ public: String project_name = get_project_name(p_preset->get("package/name")); err = _create_project_name_strings_files(p_preset, project_name); //project name localization. if (err != OK) { - EditorNode::add_io_error("Unable to overwrite res://android/build/res/*.xml files with project name"); + EditorNode::add_io_error(TTR("Unable to overwrite res://android/build/res/*.xml files with project name")); } // Copies the project icon files into the appropriate Gradle project directory. _copy_icons_to_gradle_project(p_preset, processed_splash_config_xml, splash_image, splash_bg_color_image, main_image, foreground, background); @@ -2560,7 +2561,7 @@ public: user_data.debug = p_debug; err = export_project_files(p_preset, rename_and_store_file_in_gradle_project, &user_data, copy_gradle_so); if (err != OK) { - EditorNode::add_io_error("Could not export project files to gradle project\n"); + EditorNode::add_io_error(TTR("Could not export project files to gradle project\n")); return err; } if (user_data.libs.size() > 0) { @@ -2573,7 +2574,7 @@ public: print_verbose("Saving apk expansion file.."); err = save_apk_expansion_file(p_preset, p_path); if (err != OK) { - EditorNode::add_io_error("Could not write expansion package file!"); + EditorNode::add_io_error(TTR("Could not write expansion package file!")); return err; } } @@ -2660,7 +2661,7 @@ public: String release_username = p_preset->get("keystore/release_user"); String release_password = p_preset->get("keystore/release_password"); if (!FileAccess::exists(release_keystore)) { - EditorNode::add_io_error("Could not find keystore, unable to export."); + EditorNode::add_io_error(TTR("Could not find keystore, unable to export.")); return ERR_FILE_CANT_OPEN; } @@ -2724,7 +2725,7 @@ public: src_apk = find_export_template("android_release.apk"); } if (src_apk == "") { - EditorNode::add_io_error("Package not found: " + src_apk); + EditorNode::add_io_error(vformat(TTR("Package not found: %s"), src_apk)); return ERR_FILE_NOT_FOUND; } } @@ -2736,13 +2737,13 @@ public: FileAccess *src_f = nullptr; zlib_filefunc_def io = zipio_create_io_from_file(&src_f); - if (ep.step("Creating APK...", 0)) { + if (ep.step(TTR("Creating APK..."), 0)) { return ERR_SKIP; } unzFile pkg = unzOpen2(src_apk.utf8().get_data(), &io); if (!pkg) { - EditorNode::add_io_error("Could not find template APK to export:\n" + src_apk); + EditorNode::add_io_error(vformat(TTR("Could not find template APK to export:\n%s"), src_apk)); return ERR_FILE_NOT_FOUND; } @@ -2870,12 +2871,11 @@ public: if (!invalid_abis.is_empty()) { String unsupported_arch = String(", ").join(invalid_abis); - EditorNode::add_io_error("Missing libraries in the export template for the selected architectures: " + unsupported_arch + ".\n" + - "Please build a template with all required libraries, or uncheck the missing architectures in the export preset."); + EditorNode::add_io_error(vformat(TTR("Missing libraries in the export template for the selected architectures: %s.\nPlease build a template with all required libraries, or uncheck the missing architectures in the export preset."), unsupported_arch)); CLEANUP_AND_RETURN(ERR_FILE_NOT_FOUND); } - if (ep.step("Adding files...", 1)) { + if (ep.step(TTR("Adding files..."), 1)) { CLEANUP_AND_RETURN(ERR_SKIP); } err = OK; @@ -2889,7 +2889,7 @@ public: if (apk_expansion) { err = save_apk_expansion_file(p_preset, p_path); if (err != OK) { - EditorNode::add_io_error("Could not write expansion package file!"); + EditorNode::add_io_error(TTR("Could not write expansion package file!")); return err; } } else { @@ -2902,7 +2902,7 @@ public: if (err != OK) { unzClose(pkg); - EditorNode::add_io_error("Could not export project files"); + EditorNode::add_io_error(TTR("Could not export project files")); CLEANUP_AND_RETURN(ERR_SKIP); } @@ -2932,13 +2932,13 @@ public: // If we're not signing the apk, then the next step should be the last. const int next_step = should_sign ? 103 : 105; - if (ep.step("Aligning APK...", next_step)) { + if (ep.step(TTR("Aligning APK..."), next_step)) { CLEANUP_AND_RETURN(ERR_SKIP); } unzFile tmp_unaligned = unzOpen2(tmp_unaligned_path.utf8().get_data(), &io); if (!tmp_unaligned) { - EditorNode::add_io_error("Could not unzip temporary unaligned APK."); + EditorNode::add_io_error(TTR("Could not unzip temporary unaligned APK.")); CLEANUP_AND_RETURN(ERR_FILE_NOT_FOUND); } diff --git a/platform/android/java/app/gradle.properties b/platform/android/java/app/gradle.properties new file mode 100644 index 0000000000..19587bd81f --- /dev/null +++ b/platform/android/java/app/gradle.properties @@ -0,0 +1,25 @@ +# Godot custom build Gradle settings. +# These properties apply when running custom build from the Godot editor. +# NOTE: This should be kept in sync with 'godot/platform/android/java/gradle.properties' except +# where otherwise specified. + +# For more details on how to configure your build environment visit +# http://www.gradle.org/docs/current/userguide/build_environment.html + +android.enableJetifier=true +android.useAndroidX=true + +# Specifies the JVM arguments used for the daemon process. +# The setting is particularly useful for tweaking memory settings. +org.gradle.jvmargs=-Xmx4536m + +# When configured, Gradle will run in incubating parallel mode. +# This option should only be used with decoupled projects. More details, visit +# http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects +# org.gradle.parallel=true + +org.gradle.warning.mode=all + +# Enable resource optimizations for release build. +# NOTE: This is turned off for template release build in order to support the build legacy process. +android.enableResourceOptimizations=true diff --git a/platform/android/java/build.gradle b/platform/android/java/build.gradle index ee24a46d9f..87bb2ea218 100644 --- a/platform/android/java/build.gradle +++ b/platform/android/java/build.gradle @@ -115,7 +115,7 @@ task zipCustomBuild(type: Zip) { doFirst { logger.lifecycle("Generating Godot custom build template") } - from(fileTree(dir: 'app', excludes: ['**/build/**', '**/.gradle/**', '**/*.iml']), fileTree(dir: '.', includes: ['gradle.properties', 'gradlew', 'gradlew.bat', 'gradle/**'])) + from(fileTree(dir: 'app', excludes: ['**/build/**', '**/.gradle/**', '**/*.iml']), fileTree(dir: '.', includes: ['gradlew', 'gradlew.bat', 'gradle/**'])) include '**/*' archiveFileName = 'android_source.zip' destinationDirectory = file(binDir) diff --git a/platform/android/java/gradle.properties b/platform/android/java/gradle.properties index 6b3b62a9da..b51a19a005 100644 --- a/platform/android/java/gradle.properties +++ b/platform/android/java/gradle.properties @@ -1,4 +1,6 @@ # Project-wide Gradle settings. +# NOTE: This should be kept in sync with 'godot/platform/android/java/app/gradle.properties' except +# where otherwise specified. # IDE (e.g. Android Studio) users: # Gradle settings configured through the IDE *will override* @@ -20,3 +22,7 @@ org.gradle.jvmargs=-Xmx4536m # org.gradle.parallel=true org.gradle.warning.mode=all + +# Disable resource optimizations for template release build. +# NOTE: This is turned on for custom build in order to improve the release build. +android.enableResourceOptimizations=false diff --git a/platform/android/java/lib/src/com/google/android/vending/licensing/Obfuscator.java b/platform/android/java/lib/src/com/google/android/vending/licensing/Obfuscator.java index 008c150a8e..05b452d0c1 100644 --- a/platform/android/java/lib/src/com/google/android/vending/licensing/Obfuscator.java +++ b/platform/android/java/lib/src/com/google/android/vending/licensing/Obfuscator.java @@ -20,7 +20,7 @@ package com.google.android.vending.licensing; * Interface used as part of a {@link Policy} to allow application authors to obfuscate * licensing data that will be stored into a SharedPreferences file. * <p> - * Any transformation scheme must be reversable. Implementing classes may optionally implement an + * Any transformation scheme must be reversible. Implementing classes may optionally implement an * integrity check to further prevent modification to preference data. Implementing classes * should use device-specific information as a key in the obfuscation algorithm to prevent * obfuscated preferences from being shared among devices. diff --git a/platform/android/java_class_wrapper.cpp b/platform/android/java_class_wrapper.cpp index ed6b5c3e14..49891cd739 100644 --- a/platform/android/java_class_wrapper.cpp +++ b/platform/android/java_class_wrapper.cpp @@ -41,13 +41,13 @@ bool JavaClass::_call_method(JavaObject *p_instance, const StringName &p_method, ERR_FAIL_COND_V(env == nullptr, false); MethodInfo *method = nullptr; - for (List<MethodInfo>::Element *E = M->get().front(); E; E = E->next()) { - if (!p_instance && !E->get()._static) { + for (MethodInfo &E : M->get()) { + if (!p_instance && !E._static) { r_error.error = Callable::CallError::CALL_ERROR_INSTANCE_IS_NULL; continue; } - int pc = E->get().param_types.size(); + int pc = E.param_types.size(); if (pc > p_argcount) { r_error.error = Callable::CallError::CALL_ERROR_TOO_FEW_ARGUMENTS; r_error.argument = pc; @@ -58,7 +58,7 @@ bool JavaClass::_call_method(JavaObject *p_instance, const StringName &p_method, r_error.argument = pc; continue; } - uint32_t *ptypes = E->get().param_types.ptrw(); + uint32_t *ptypes = E.param_types.ptrw(); bool valid = true; for (int i = 0; i < pc; i++) { @@ -107,7 +107,7 @@ bool JavaClass::_call_method(JavaObject *p_instance, const StringName &p_method, if (Object::cast_to<JavaObject>(ref.ptr())) { Ref<JavaObject> jo = ref; //could be faster - jclass c = env->FindClass(E->get().param_sigs[i].operator String().utf8().get_data()); + jclass c = env->FindClass(E.param_sigs[i].operator String().utf8().get_data()); if (!c || !env->IsInstanceOf(jo->instance, c)) { arg_expected = Variant::OBJECT; } else { @@ -138,7 +138,7 @@ bool JavaClass::_call_method(JavaObject *p_instance, const StringName &p_method, if (!valid) continue; - method = &E->get(); + method = &E; break; } @@ -474,8 +474,8 @@ bool JavaClass::_call_method(JavaObject *p_instance, const StringName &p_method, } break; } - for (List<jobject>::Element *E = to_free.front(); E; E = E->next()) { - env->DeleteLocalRef(E->get()); + for (jobject &E : to_free) { + env->DeleteLocalRef(E); } return success; diff --git a/platform/android/java_godot_lib_jni.cpp b/platform/android/java_godot_lib_jni.cpp index 2eded01bf4..ce7a49e53c 100644 --- a/platform/android/java_godot_lib_jni.cpp +++ b/platform/android/java_godot_lib_jni.cpp @@ -438,8 +438,8 @@ JNIEXPORT void JNICALL Java_org_godotengine_godot_GodotLib_calldeferred(JNIEnv * env->DeleteLocalRef(obj); }; - static_assert(VARIANT_ARG_MAX == 5, "This code needs to be updated if VARIANT_ARG_MAX != 5"); - obj->call_deferred(str_method, args[0], args[1], args[2], args[3], args[4]); + static_assert(VARIANT_ARG_MAX == 8, "This code needs to be updated if VARIANT_ARG_MAX != 8"); + obj->call_deferred(str_method, args[0], args[1], args[2], args[3], args[4], args[5], args[6], args[7]); // something env->PopLocalFrame(nullptr); } @@ -451,7 +451,7 @@ JNIEXPORT void JNICALL Java_org_godotengine_godot_GodotLib_requestPermissionResu } if (os_android->get_main_loop()) { - os_android->get_main_loop()->emit_signal("on_request_permissions_result", permission, p_result == JNI_TRUE); + os_android->get_main_loop()->emit_signal(SNAME("on_request_permissions_result"), permission, p_result == JNI_TRUE); } } diff --git a/platform/android/os_android.cpp b/platform/android/os_android.cpp index 222976d948..792a390e36 100644 --- a/platform/android/os_android.cpp +++ b/platform/android/os_android.cpp @@ -71,6 +71,13 @@ public: virtual ~AndroidLogger() {} }; +void OS_Android::alert(const String &p_alert, const String &p_title) { + GodotJavaWrapper *godot_java = OS_Android::get_singleton()->get_godot_java(); + ERR_FAIL_COND(!godot_java); + + godot_java->alert(p_alert, p_title); +} + void OS_Android::initialize_core() { OS_Unix::initialize_core(); diff --git a/platform/android/os_android.h b/platform/android/os_android.h index 1e89e9211d..38f0f3edc7 100644 --- a/platform/android/os_android.h +++ b/platform/android/os_android.h @@ -86,6 +86,8 @@ public: virtual bool request_permissions() override; virtual Vector<String> get_granted_permissions() const override; + virtual void alert(const String &p_alert, const String &p_title) override; + virtual Error open_dynamic_library(const String p_path, void *&p_library_handle, bool p_also_set_library_path = false) override; virtual String get_name() const override; diff --git a/platform/android/plugin/godot_plugin_jni.cpp b/platform/android/plugin/godot_plugin_jni.cpp index cf0c02e2bf..6a20d5eafc 100644 --- a/platform/android/plugin/godot_plugin_jni.cpp +++ b/platform/android/plugin/godot_plugin_jni.cpp @@ -126,7 +126,7 @@ JNIEXPORT void JNICALL Java_org_godotengine_godot_plugin_GodotPlugin_nativeEmitS env->DeleteLocalRef(j_param); }; - singleton->emit_signal(signal_name, args, count); + singleton->emit_signal(SNAME(signal_name), args, count); } JNIEXPORT void JNICALL Java_org_godotengine_godot_plugin_GodotPlugin_nativeRegisterGDNativeLibraries(JNIEnv *env, jclass clazz, jobjectArray gdnlib_paths) { diff --git a/platform/iphone/display_server_iphone.h b/platform/iphone/display_server_iphone.h index 6f64130b23..8ba7a69a4f 100644 --- a/platform/iphone/display_server_iphone.h +++ b/platform/iphone/display_server_iphone.h @@ -119,8 +119,6 @@ public: virtual bool has_feature(Feature p_feature) const override; virtual String get_name() const override; - virtual void alert(const String &p_alert, const String &p_title = "ALERT!") override; - virtual int get_screen_count() const override; virtual Point2i screen_get_position(int p_screen = SCREEN_OF_MAIN_WINDOW) const override; virtual Size2i screen_get_size(int p_screen = SCREEN_OF_MAIN_WINDOW) const override; diff --git a/platform/iphone/display_server_iphone.mm b/platform/iphone/display_server_iphone.mm index bd95e2c703..b4f0a32027 100644 --- a/platform/iphone/display_server_iphone.mm +++ b/platform/iphone/display_server_iphone.mm @@ -320,12 +320,6 @@ String DisplayServerIPhone::get_name() const { return "iPhone"; } -void DisplayServerIPhone::alert(const String &p_alert, const String &p_title) { - const CharString utf8_alert = p_alert.utf8(); - const CharString utf8_title = p_title.utf8(); - iOS::alert(utf8_alert.get_data(), utf8_title.get_data()); -} - int DisplayServerIPhone::get_screen_count() const { return 1; } diff --git a/platform/iphone/export/export.cpp b/platform/iphone/export/export.cpp index 523dc555f1..f21a14e84b 100644 --- a/platform/iphone/export/export.cpp +++ b/platform/iphone/export/export.cpp @@ -368,6 +368,8 @@ void EditorExportPlatformIOS::get_export_options(List<ExportOption> *r_options) r_options->push_back(ExportOption(PropertyInfo(Variant::BOOL, "plugins/" + found_plugins[i].name), false)); } + Set<String> plist_keys; + for (int i = 0; i < found_plugins.size(); i++) { // Editable plugin plist values PluginConfigIOS plugin = found_plugins[i]; @@ -379,7 +381,10 @@ void EditorExportPlatformIOS::get_export_options(List<ExportOption> *r_options) switch (item.type) { case PluginConfigIOS::PlistItemType::STRING_INPUT: { String preset_name = "plugins_plist/" + key; - r_options->push_back(ExportOption(PropertyInfo(Variant::STRING, preset_name), item.value)); + if (!plist_keys.has(preset_name)) { + r_options->push_back(ExportOption(PropertyInfo(Variant::STRING, preset_name), item.value)); + plist_keys.insert(preset_name); + } } break; default: continue; diff --git a/platform/iphone/godot_view_gesture_recognizer.h b/platform/iphone/godot_view_gesture_recognizer.h index 48b2d5ffad..61438ef22f 100644 --- a/platform/iphone/godot_view_gesture_recognizer.h +++ b/platform/iphone/godot_view_gesture_recognizer.h @@ -28,7 +28,7 @@ /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ /*************************************************************************/ -// GLViewGestureRecognizer allows iOS gestures to work currectly by +// GLViewGestureRecognizer allows iOS gestures to work correctly by // emulating UIScrollView's UIScrollViewDelayedTouchesBeganGestureRecognizer. // It catches all gestures incoming to UIView and delays them for 150ms // (the same value used by UIScrollViewDelayedTouchesBeganGestureRecognizer) diff --git a/platform/iphone/os_iphone.h b/platform/iphone/os_iphone.h index f4ff909adf..8abc3b7ed5 100644 --- a/platform/iphone/os_iphone.h +++ b/platform/iphone/os_iphone.h @@ -92,13 +92,12 @@ public: void start(); + virtual void alert(const String &p_alert, const String &p_title = "ALERT!") override; + virtual Error open_dynamic_library(const String p_path, void *&p_library_handle, bool p_also_set_library_path = false) override; virtual Error close_dynamic_library(void *p_library_handle) override; virtual Error get_dynamic_library_symbol_handle(void *p_library_handle, const String p_name, void *&p_symbol_handle, bool p_optional = false) override; - virtual void alert(const String &p_alert, - const String &p_title = "ALERT!") override; - virtual String get_name() const override; virtual String get_model_name() const override; diff --git a/platform/iphone/os_iphone.mm b/platform/iphone/os_iphone.mm index 1f08901082..b69996ccf0 100644 --- a/platform/iphone/os_iphone.mm +++ b/platform/iphone/os_iphone.mm @@ -114,6 +114,12 @@ OSIPhone::OSIPhone(String p_data_dir) { OSIPhone::~OSIPhone() {} +void OSIPhone::alert(const String &p_alert, const String &p_title) { + const CharString utf8_alert = p_alert.utf8(); + const CharString utf8_title = p_title.utf8(); + iOS::alert(utf8_alert.get_data(), utf8_title.get_data()); +} + void OSIPhone::initialize_core() { OS_Unix::initialize_core(); @@ -221,12 +227,6 @@ Error OSIPhone::get_dynamic_library_symbol_handle(void *p_library_handle, const return OS_Unix::get_dynamic_library_symbol_handle(p_library_handle, p_name, p_symbol_handle, p_optional); } -void OSIPhone::alert(const String &p_alert, const String &p_title) { - const CharString utf8_alert = p_alert.utf8(); - const CharString utf8_title = p_title.utf8(); - iOS::alert(utf8_alert.get_data(), utf8_title.get_data()); -} - String OSIPhone::get_name() const { return "iOS"; }; diff --git a/platform/iphone/plugin/godot_plugin_config.h b/platform/iphone/plugin/godot_plugin_config.h index 06770260aa..f9c5d7e51f 100644 --- a/platform/iphone/plugin/godot_plugin_config.h +++ b/platform/iphone/plugin/godot_plugin_config.h @@ -252,6 +252,8 @@ static inline PluginConfigIOS load_plugin_config(Ref<ConfigFile> config_file, co return plugin_config; } + config_file->clear(); + Error err = config_file->load(path); if (err != OK) { diff --git a/platform/javascript/detect.py b/platform/javascript/detect.py index dacc442575..173b558b6d 100644 --- a/platform/javascript/detect.py +++ b/platform/javascript/detect.py @@ -38,7 +38,7 @@ def get_opts(): BoolVariable("use_safe_heap", "Use Emscripten SAFE_HEAP sanitizer", False), # eval() can be a security concern, so it can be disabled. BoolVariable("javascript_eval", "Enable JavaScript eval interface", True), - BoolVariable("threads_enabled", "Enable WebAssembly Threads support (limited browser support)", False), + BoolVariable("threads_enabled", "Enable WebAssembly Threads support (limited browser support)", True), BoolVariable("gdnative_enabled", "Enable WebAssembly GDNative support (produces bigger binaries)", False), BoolVariable("use_closure_compiler", "Use closure compiler to minimize JavaScript code", False), ] diff --git a/platform/javascript/display_server_javascript.cpp b/platform/javascript/display_server_javascript.cpp index f1b92264e2..8df81bb8cc 100644 --- a/platform/javascript/display_server_javascript.cpp +++ b/platform/javascript/display_server_javascript.cpp @@ -229,7 +229,7 @@ EM_BOOL DisplayServerJavaScript::mouse_button_callback(int p_event_type, const E } Input *input = Input::get_singleton(); - MouseButton mask = input->get_mouse_button_mask(); + int mask = input->get_mouse_button_mask(); MouseButton button_flag = MouseButton(1 << (ev->get_button_index() - 1)); if (ev->is_pressed()) { // Since the event is consumed, focus manually. The containing iframe, @@ -605,17 +605,17 @@ void DisplayServerJavaScript::process_joypads() { Input::JoyAxisValue joy_axis; joy_axis.min = 0; joy_axis.value = value; - int a = b == 6 ? JOY_AXIS_TRIGGER_LEFT : JOY_AXIS_TRIGGER_RIGHT; + JoyAxis a = b == 6 ? JOY_AXIS_TRIGGER_LEFT : JOY_AXIS_TRIGGER_RIGHT; input->joy_axis(idx, a, joy_axis); } else { - input->joy_button(idx, b, value); + input->joy_button(idx, (JoyButton)b, value); } } for (int a = 0; a < s_axes_num; a++) { Input::JoyAxisValue joy_axis; joy_axis.min = -1; joy_axis.value = s_axes[a]; - input->joy_axis(idx, a, joy_axis); + input->joy_axis(idx, (JoyAxis)a, joy_axis); } } } @@ -659,10 +659,6 @@ void DisplayServerJavaScript::send_window_event_callback(int p_notification) { } } -void DisplayServerJavaScript::alert(const String &p_alert, const String &p_title) { - godot_js_display_alert(p_alert.utf8().get_data()); -} - void DisplayServerJavaScript::set_icon(const Ref<Image> &p_icon) { ERR_FAIL_COND(p_icon.is_null()); Ref<Image> icon = p_icon; @@ -710,18 +706,18 @@ void DisplayServerJavaScript::_dispatch_input_event(const Ref<InputEvent> &p_eve } } -DisplayServer *DisplayServerJavaScript::create_func(const String &p_rendering_driver, DisplayServer::WindowMode p_mode, uint32_t p_flags, const Vector2i &p_resolution, Error &r_error) { - return memnew(DisplayServerJavaScript(p_rendering_driver, p_mode, p_flags, p_resolution, r_error)); +DisplayServer *DisplayServerJavaScript::create_func(const String &p_rendering_driver, WindowMode p_window_mode, VSyncMode p_vsync_mode, uint32_t p_flags, const Size2i &p_resolution, Error &r_error) { + return memnew(DisplayServerJavaScript(p_rendering_driver, p_window_mode, p_vsync_mode, p_flags, p_resolution, r_error)); } -DisplayServerJavaScript::DisplayServerJavaScript(const String &p_rendering_driver, WindowMode p_mode, uint32_t p_flags, const Vector2i &p_resolution, Error &r_error) { +DisplayServerJavaScript::DisplayServerJavaScript(const String &p_rendering_driver, WindowMode p_window_mode, VSyncMode p_vsync_mode, uint32_t p_flags, const Size2i &p_resolution, Error &r_error) { r_error = OK; // Always succeeds for now. // Ensure the canvas ID. godot_js_config_canvas_id_get(canvas_id, 256); // Handle contextmenu, webglcontextlost - godot_js_display_setup_canvas(p_resolution.x, p_resolution.y, p_mode == WINDOW_MODE_FULLSCREEN, OS::get_singleton()->is_hidpi_allowed() ? 1 : 0); + godot_js_display_setup_canvas(p_resolution.x, p_resolution.y, p_window_mode == WINDOW_MODE_FULLSCREEN, OS::get_singleton()->is_hidpi_allowed() ? 1 : 0); // Check if it's windows. swap_cancel_ok = godot_js_display_is_swap_ok_cancel() == 1; diff --git a/platform/javascript/display_server_javascript.h b/platform/javascript/display_server_javascript.h index ece38f1a95..bf5e229c9a 100644 --- a/platform/javascript/display_server_javascript.h +++ b/platform/javascript/display_server_javascript.h @@ -89,7 +89,7 @@ private: void process_joypads(); static Vector<String> get_rendering_drivers_func(); - static DisplayServer *create_func(const String &p_rendering_driver, DisplayServer::WindowMode p_mode, uint32_t p_flags, const Vector2i &p_resolution, Error &r_error); + static DisplayServer *create_func(const String &p_rendering_driver, WindowMode p_window_mode, VSyncMode p_vsync_mode, uint32_t p_flags, const Vector2i &p_resolution, Error &r_error); static void _dispatch_input_event(const Ref<InputEvent> &p_event); @@ -109,99 +109,98 @@ public: bool check_size_force_redraw(); // from DisplayServer - void alert(const String &p_alert, const String &p_title = "ALERT!") override; - bool has_feature(Feature p_feature) const override; - String get_name() const override; + virtual bool has_feature(Feature p_feature) const override; + virtual String get_name() const override; // cursor - void cursor_set_shape(CursorShape p_shape) override; - CursorShape cursor_get_shape() const override; - void cursor_set_custom_image(const RES &p_cursor, CursorShape p_shape = CURSOR_ARROW, const Vector2 &p_hotspot = Vector2()) override; + virtual void cursor_set_shape(CursorShape p_shape) override; + virtual CursorShape cursor_get_shape() const override; + virtual void cursor_set_custom_image(const RES &p_cursor, CursorShape p_shape = CURSOR_ARROW, const Vector2 &p_hotspot = Vector2()) override; // mouse - void mouse_set_mode(MouseMode p_mode) override; - MouseMode mouse_get_mode() const override; + virtual void mouse_set_mode(MouseMode p_mode) override; + virtual MouseMode mouse_get_mode() const override; // touch - bool screen_is_touchscreen(int p_screen = SCREEN_OF_MAIN_WINDOW) const override; + virtual bool screen_is_touchscreen(int p_screen = SCREEN_OF_MAIN_WINDOW) const override; // clipboard - void clipboard_set(const String &p_text) override; - String clipboard_get() const override; + virtual void clipboard_set(const String &p_text) override; + virtual String clipboard_get() const override; // screen - int get_screen_count() const override; - Point2i screen_get_position(int p_screen = SCREEN_OF_MAIN_WINDOW) const override; - Size2i screen_get_size(int p_screen = SCREEN_OF_MAIN_WINDOW) const override; - Rect2i screen_get_usable_rect(int p_screen = SCREEN_OF_MAIN_WINDOW) const override; - int screen_get_dpi(int p_screen = SCREEN_OF_MAIN_WINDOW) const override; - float screen_get_scale(int p_screen = SCREEN_OF_MAIN_WINDOW) const override; + virtual int get_screen_count() const override; + virtual Point2i screen_get_position(int p_screen = SCREEN_OF_MAIN_WINDOW) const override; + virtual Size2i screen_get_size(int p_screen = SCREEN_OF_MAIN_WINDOW) const override; + virtual Rect2i screen_get_usable_rect(int p_screen = SCREEN_OF_MAIN_WINDOW) const override; + virtual int screen_get_dpi(int p_screen = SCREEN_OF_MAIN_WINDOW) const override; + virtual float screen_get_scale(int p_screen = SCREEN_OF_MAIN_WINDOW) const override; - void virtual_keyboard_show(const String &p_existing_text, const Rect2 &p_screen_rect = Rect2(), bool p_multiline = false, int p_max_input_length = -1, int p_cursor_start = -1, int p_cursor_end = -1) override; - void virtual_keyboard_hide() override; + virtual void virtual_keyboard_show(const String &p_existing_text, const Rect2 &p_screen_rect = Rect2(), bool p_multiline = false, int p_max_input_length = -1, int p_cursor_start = -1, int p_cursor_end = -1) override; + virtual void virtual_keyboard_hide() override; // windows - Vector<DisplayServer::WindowID> get_window_list() const override; - WindowID get_window_at_screen_position(const Point2i &p_position) const override; + virtual Vector<DisplayServer::WindowID> get_window_list() const override; + virtual WindowID get_window_at_screen_position(const Point2i &p_position) const override; - void window_attach_instance_id(ObjectID p_instance, WindowID p_window = MAIN_WINDOW_ID) override; - ObjectID window_get_attached_instance_id(WindowID p_window = MAIN_WINDOW_ID) const override; + virtual void window_attach_instance_id(ObjectID p_instance, WindowID p_window = MAIN_WINDOW_ID) override; + virtual ObjectID window_get_attached_instance_id(WindowID p_window = MAIN_WINDOW_ID) const override; - void window_set_rect_changed_callback(const Callable &p_callable, WindowID p_window = MAIN_WINDOW_ID) override; + virtual void window_set_rect_changed_callback(const Callable &p_callable, WindowID p_window = MAIN_WINDOW_ID) override; - void window_set_window_event_callback(const Callable &p_callable, WindowID p_window = MAIN_WINDOW_ID) override; - void window_set_input_event_callback(const Callable &p_callable, WindowID p_window = MAIN_WINDOW_ID) override; - void window_set_input_text_callback(const Callable &p_callable, WindowID p_window = MAIN_WINDOW_ID) override; + virtual void window_set_window_event_callback(const Callable &p_callable, WindowID p_window = MAIN_WINDOW_ID) override; + virtual void window_set_input_event_callback(const Callable &p_callable, WindowID p_window = MAIN_WINDOW_ID) override; + virtual void window_set_input_text_callback(const Callable &p_callable, WindowID p_window = MAIN_WINDOW_ID) override; - void window_set_drop_files_callback(const Callable &p_callable, WindowID p_window = MAIN_WINDOW_ID) override; + virtual void window_set_drop_files_callback(const Callable &p_callable, WindowID p_window = MAIN_WINDOW_ID) override; - void window_set_title(const String &p_title, WindowID p_window = MAIN_WINDOW_ID) override; + virtual void window_set_title(const String &p_title, WindowID p_window = MAIN_WINDOW_ID) override; - int window_get_current_screen(WindowID p_window = MAIN_WINDOW_ID) const override; - void window_set_current_screen(int p_screen, WindowID p_window = MAIN_WINDOW_ID) override; + virtual int window_get_current_screen(WindowID p_window = MAIN_WINDOW_ID) const override; + virtual void window_set_current_screen(int p_screen, WindowID p_window = MAIN_WINDOW_ID) override; - Point2i window_get_position(WindowID p_window = MAIN_WINDOW_ID) const override; - void window_set_position(const Point2i &p_position, WindowID p_window = MAIN_WINDOW_ID) override; + virtual Point2i window_get_position(WindowID p_window = MAIN_WINDOW_ID) const override; + virtual void window_set_position(const Point2i &p_position, WindowID p_window = MAIN_WINDOW_ID) override; - void window_set_transient(WindowID p_window, WindowID p_parent) override; + virtual void window_set_transient(WindowID p_window, WindowID p_parent) override; - void window_set_max_size(const Size2i p_size, WindowID p_window = MAIN_WINDOW_ID) override; - Size2i window_get_max_size(WindowID p_window = MAIN_WINDOW_ID) const override; + virtual void window_set_max_size(const Size2i p_size, WindowID p_window = MAIN_WINDOW_ID) override; + virtual Size2i window_get_max_size(WindowID p_window = MAIN_WINDOW_ID) const override; - void window_set_min_size(const Size2i p_size, WindowID p_window = MAIN_WINDOW_ID) override; - Size2i window_get_min_size(WindowID p_window = MAIN_WINDOW_ID) const override; + virtual void window_set_min_size(const Size2i p_size, WindowID p_window = MAIN_WINDOW_ID) override; + virtual Size2i window_get_min_size(WindowID p_window = MAIN_WINDOW_ID) const override; - void window_set_size(const Size2i p_size, WindowID p_window = MAIN_WINDOW_ID) override; - Size2i window_get_size(WindowID p_window = MAIN_WINDOW_ID) const override; - Size2i window_get_real_size(WindowID p_window = MAIN_WINDOW_ID) const override; + virtual void window_set_size(const Size2i p_size, WindowID p_window = MAIN_WINDOW_ID) override; + virtual Size2i window_get_size(WindowID p_window = MAIN_WINDOW_ID) const override; + virtual Size2i window_get_real_size(WindowID p_window = MAIN_WINDOW_ID) const override; - void window_set_mode(WindowMode p_mode, WindowID p_window = MAIN_WINDOW_ID) override; - WindowMode window_get_mode(WindowID p_window = MAIN_WINDOW_ID) const override; + virtual void window_set_mode(WindowMode p_mode, WindowID p_window = MAIN_WINDOW_ID) override; + virtual WindowMode window_get_mode(WindowID p_window = MAIN_WINDOW_ID) const override; - bool window_is_maximize_allowed(WindowID p_window = MAIN_WINDOW_ID) const override; + virtual bool window_is_maximize_allowed(WindowID p_window = MAIN_WINDOW_ID) const override; - void window_set_flag(WindowFlags p_flag, bool p_enabled, WindowID p_window = MAIN_WINDOW_ID) override; - bool window_get_flag(WindowFlags p_flag, WindowID p_window = MAIN_WINDOW_ID) const override; + virtual void window_set_flag(WindowFlags p_flag, bool p_enabled, WindowID p_window = MAIN_WINDOW_ID) override; + virtual bool window_get_flag(WindowFlags p_flag, WindowID p_window = MAIN_WINDOW_ID) const override; - void window_request_attention(WindowID p_window = MAIN_WINDOW_ID) override; - void window_move_to_foreground(WindowID p_window = MAIN_WINDOW_ID) override; + virtual void window_request_attention(WindowID p_window = MAIN_WINDOW_ID) override; + virtual void window_move_to_foreground(WindowID p_window = MAIN_WINDOW_ID) override; - bool window_can_draw(WindowID p_window = MAIN_WINDOW_ID) const override; + virtual bool window_can_draw(WindowID p_window = MAIN_WINDOW_ID) const override; - bool can_any_window_draw() const override; + virtual bool can_any_window_draw() const override; // events - void process_events() override; + virtual void process_events() override; // icon - void set_icon(const Ref<Image> &p_icon) override; + virtual void set_icon(const Ref<Image> &p_icon) override; // others - bool get_swap_cancel_ok() override; - void swap_buffers() override; + virtual bool get_swap_cancel_ok() override; + virtual void swap_buffers() override; static void register_javascript_driver(); - DisplayServerJavaScript(const String &p_rendering_driver, WindowMode p_mode, uint32_t p_flags, const Vector2i &p_resolution, Error &r_error); + DisplayServerJavaScript(const String &p_rendering_driver, WindowMode p_window_mode, VSyncMode p_vsync_mode, uint32_t p_flags, const Size2i &p_resolution, Error &r_error); ~DisplayServerJavaScript(); }; diff --git a/platform/javascript/javascript_main.cpp b/platform/javascript/javascript_main.cpp index 40771d1882..a3f0dbaa45 100644 --- a/platform/javascript/javascript_main.cpp +++ b/platform/javascript/javascript_main.cpp @@ -97,7 +97,7 @@ extern EMSCRIPTEN_KEEPALIVE int godot_js_main(int argc, char *argv[]) { if (Main::is_project_manager() && FileAccess::exists("/tmp/preload.zip")) { PackedStringArray ps; ps.push_back("/tmp/preload.zip"); - os->get_main_loop()->emit_signal("files_dropped", ps, -1); + os->get_main_loop()->emit_signal(SNAME("files_dropped"), ps, -1); } #endif emscripten_set_main_loop(main_loop_callback, -1, false); diff --git a/platform/javascript/js/libs/audio.worklet.js b/platform/javascript/js/libs/audio.worklet.js index 6b3f80c6a9..866f845139 100644 --- a/platform/javascript/js/libs/audio.worklet.js +++ b/platform/javascript/js/libs/audio.worklet.js @@ -115,7 +115,7 @@ class GodotProcessor extends AudioWorkletProcessor { this.input = new RingBuffer(p_data[1], avail_in); this.output = new RingBuffer(p_data[2], avail_out); } else if (p_cmd === 'stop') { - this.runing = false; + this.running = false; this.output = null; this.input = null; } diff --git a/platform/javascript/os_javascript.cpp b/platform/javascript/os_javascript.cpp index 0b1650076c..76102d941b 100644 --- a/platform/javascript/os_javascript.cpp +++ b/platform/javascript/os_javascript.cpp @@ -31,13 +31,12 @@ #include "os_javascript.h" #include "core/debugger/engine_debugger.h" -#include "core/io/json.h" #include "drivers/unix/dir_access_unix.h" #include "drivers/unix/file_access_unix.h" #include "main/main.h" -#include "modules/modules_enabled.gen.h" #include "platform/javascript/display_server_javascript.h" +#include "modules/modules_enabled.gen.h" #ifdef MODULE_WEBSOCKET_ENABLED #include "modules/websocket/remote_debugger_peer_websocket.h" #endif @@ -48,6 +47,10 @@ #include "godot_js.h" +void OS_JavaScript::alert(const String &p_alert, const String &p_title) { + godot_js_display_alert(p_alert.utf8().get_data()); +} + // Lifecycle void OS_JavaScript::initialize() { OS_Unix::initialize_core(); @@ -112,10 +115,10 @@ Error OS_JavaScript::execute(const String &p_path, const List<String> &p_argumen Error OS_JavaScript::create_process(const String &p_path, const List<String> &p_arguments, ProcessID *r_child_id) { Array args; - for (const List<String>::Element *E = p_arguments.front(); E; E = E->next()) { - args.push_back(E->get()); + for (const String &E : p_arguments) { + args.push_back(E); } - String json_args = JSON::print(args); + String json_args = Variant(args).to_json_string(); int failed = godot_js_os_execute(json_args.utf8().get_data()); ERR_FAIL_COND_V_MSG(failed, ERR_UNAVAILABLE, "OS::execute() or create_process() must be implemented in JavaScript via 'engine.setOnExecute' if required."); return OK; diff --git a/platform/javascript/os_javascript.h b/platform/javascript/os_javascript.h index 81bb9c5f3d..efac2dbca7 100644 --- a/platform/javascript/os_javascript.h +++ b/platform/javascript/os_javascript.h @@ -89,6 +89,9 @@ public: String get_user_data_dir() const override; bool is_userfs_persistent() const override; + + void alert(const String &p_alert, const String &p_title = "ALERT!") override; + Error open_dynamic_library(const String p_path, void *&p_library_handle, bool p_also_set_library_path) override; void resume_audio(); diff --git a/platform/linuxbsd/display_server_x11.cpp b/platform/linuxbsd/display_server_x11.cpp index 8f0742041c..4a32dd9646 100644 --- a/platform/linuxbsd/display_server_x11.cpp +++ b/platform/linuxbsd/display_server_x11.cpp @@ -136,70 +136,6 @@ String DisplayServerX11::get_name() const { return "X11"; } -void DisplayServerX11::alert(const String &p_alert, const String &p_title) { - const char *message_programs[] = { "zenity", "kdialog", "Xdialog", "xmessage" }; - - String path = OS::get_singleton()->get_environment("PATH"); - Vector<String> path_elems = path.split(":", false); - String program; - - for (int i = 0; i < path_elems.size(); i++) { - for (uint64_t k = 0; k < sizeof(message_programs) / sizeof(char *); k++) { - String tested_path = path_elems[i].plus_file(message_programs[k]); - - if (FileAccess::exists(tested_path)) { - program = tested_path; - break; - } - } - - if (program.length()) { - break; - } - } - - List<String> args; - - if (program.ends_with("zenity")) { - args.push_back("--error"); - args.push_back("--width"); - args.push_back("500"); - args.push_back("--title"); - args.push_back(p_title); - args.push_back("--text"); - args.push_back(p_alert); - } - - if (program.ends_with("kdialog")) { - args.push_back("--error"); - args.push_back(p_alert); - args.push_back("--title"); - args.push_back(p_title); - } - - if (program.ends_with("Xdialog")) { - args.push_back("--title"); - args.push_back(p_title); - args.push_back("--msgbox"); - args.push_back(p_alert); - args.push_back("0"); - args.push_back("0"); - } - - if (program.ends_with("xmessage")) { - args.push_back("-center"); - args.push_back("-title"); - args.push_back(p_title); - args.push_back(p_alert); - } - - if (program.length()) { - OS::get_singleton()->execute(program, args); - } else { - print_line(p_alert); - } -} - void DisplayServerX11::_update_real_mouse_position(const WindowData &wd) { Window root_return, child_return; int root_x, root_y, win_x, win_y; @@ -871,7 +807,9 @@ DisplayServer::WindowID DisplayServerX11::create_sub_window(WindowMode p_mode, V void DisplayServerX11::show_window(WindowID p_id) { _THREAD_SAFE_METHOD_ - WindowData &wd = windows[p_id]; + const WindowData &wd = windows[p_id]; + + DEBUG_LOG_X11("show_window: %lu (%u) \n", wd.x11_window, p_id); XMapWindow(x11_display, wd.x11_window); } @@ -1095,6 +1033,8 @@ void DisplayServerX11::window_set_transient(WindowID p_window, WindowID p_parent WindowID prev_parent = wd_window.transient_parent; ERR_FAIL_COND(prev_parent == p_parent); + DEBUG_LOG_X11("window_set_transient: %lu (%u), prev_parent=%u, parent=%u\n", wd_window.x11_window, p_window, prev_parent, p_parent); + ERR_FAIL_COND_MSG(wd_window.on_top, "Windows with the 'on top' can't become transient."); if (p_parent == INVALID_WINDOW_ID) { //remove transient @@ -1109,10 +1049,10 @@ void DisplayServerX11::window_set_transient(WindowID p_window, WindowID p_parent XSetTransientForHint(x11_display, wd_window.x11_window, None); - // Set focus to parent sub window to avoid losing all focus with nested menus. + // Set focus to parent sub window to avoid losing all focus when closing a nested sub-menu. // RevertToPointerRoot is used to make sure we don't lose all focus in case // a subwindow and its parent are both destroyed. - if (wd_window.menu_type && !wd_window.no_focus) { + if (wd_window.menu_type && !wd_window.no_focus && wd_window.focused) { if (!wd_parent.no_focus) { XSetInputFocus(x11_display, wd_parent.x11_window, RevertToPointerRoot, CurrentTime); } @@ -2227,7 +2167,7 @@ void DisplayServerX11::_handle_key_event(WindowID p_window, XKeyEvent *p_event, // still works in half the cases. (won't handle deadkeys) // For more complex input methods (deadkeys and more advanced) // you have to use XmbLookupString (??). - // So.. then you have to chosse which of both results + // So then you have to choose which of both results // you want to keep. // This is a real bizarreness and cpu waster. @@ -3673,8 +3613,8 @@ Vector<String> DisplayServerX11::get_rendering_drivers_func() { DisplayServer *DisplayServerX11::create_func(const String &p_rendering_driver, WindowMode p_mode, VSyncMode p_vsync_mode, uint32_t p_flags, const Vector2i &p_resolution, Error &r_error) { DisplayServer *ds = memnew(DisplayServerX11(p_rendering_driver, p_mode, p_vsync_mode, p_flags, p_resolution, r_error)); if (r_error != OK) { - ds->alert("Your video card driver does not support any of the supported Vulkan versions.\n" - "Please update your drivers or if you have a very old or integrated GPU upgrade it.", + OS::get_singleton()->alert("Your video card driver does not support any of the supported Vulkan versions.\n" + "Please update your drivers or if you have a very old or integrated GPU upgrade it.", "Unable to initialize Video driver"); } return ds; @@ -3972,8 +3912,8 @@ DisplayServerX11::DisplayServerX11(const String &p_rendering_driver, WindowMode } if (!_refresh_device_info()) { - alert("Your system does not support XInput 2.\n" - "Please upgrade your distribution.", + OS::get_singleton()->alert("Your system does not support XInput 2.\n" + "Please upgrade your distribution.", "Unable to initialize XInput"); r_error = ERR_UNAVAILABLE; return; diff --git a/platform/linuxbsd/display_server_x11.h b/platform/linuxbsd/display_server_x11.h index c5cf5ee4cb..052c6d6b7b 100644 --- a/platform/linuxbsd/display_server_x11.h +++ b/platform/linuxbsd/display_server_x11.h @@ -277,114 +277,112 @@ protected: void _window_changed(XEvent *event); public: - virtual bool has_feature(Feature p_feature) const; - virtual String get_name() const; + virtual bool has_feature(Feature p_feature) const override; + virtual String get_name() const override; - virtual void alert(const String &p_alert, const String &p_title = "ALERT!"); + virtual void mouse_set_mode(MouseMode p_mode) override; + virtual MouseMode mouse_get_mode() const override; - virtual void mouse_set_mode(MouseMode p_mode); - virtual MouseMode mouse_get_mode() const; + virtual void mouse_warp_to_position(const Point2i &p_to) override; + virtual Point2i mouse_get_position() const override; + virtual Point2i mouse_get_absolute_position() const override; + virtual MouseButton mouse_get_button_state() const override; - virtual void mouse_warp_to_position(const Point2i &p_to); - virtual Point2i mouse_get_position() const; - virtual Point2i mouse_get_absolute_position() const; - virtual MouseButton mouse_get_button_state() const; + virtual void clipboard_set(const String &p_text) override; + virtual String clipboard_get() const override; - virtual void clipboard_set(const String &p_text); - virtual String clipboard_get() const; - - virtual int get_screen_count() const; - virtual Point2i screen_get_position(int p_screen = SCREEN_OF_MAIN_WINDOW) const; - virtual Size2i screen_get_size(int p_screen = SCREEN_OF_MAIN_WINDOW) const; - virtual Rect2i screen_get_usable_rect(int p_screen = SCREEN_OF_MAIN_WINDOW) const; - virtual int screen_get_dpi(int p_screen = SCREEN_OF_MAIN_WINDOW) const; - virtual bool screen_is_touchscreen(int p_screen = SCREEN_OF_MAIN_WINDOW) const; + virtual int get_screen_count() const override; + virtual Point2i screen_get_position(int p_screen = SCREEN_OF_MAIN_WINDOW) const override; + virtual Size2i screen_get_size(int p_screen = SCREEN_OF_MAIN_WINDOW) const override; + virtual Rect2i screen_get_usable_rect(int p_screen = SCREEN_OF_MAIN_WINDOW) const override; + virtual int screen_get_dpi(int p_screen = SCREEN_OF_MAIN_WINDOW) const override; + virtual bool screen_is_touchscreen(int p_screen = SCREEN_OF_MAIN_WINDOW) const override; #if defined(DBUS_ENABLED) - virtual void screen_set_keep_on(bool p_enable); - virtual bool screen_is_kept_on() const; + virtual void screen_set_keep_on(bool p_enable) override; + virtual bool screen_is_kept_on() const override; #endif - virtual Vector<DisplayServer::WindowID> get_window_list() const; + virtual Vector<DisplayServer::WindowID> get_window_list() const override; - virtual WindowID create_sub_window(WindowMode p_mode, VSyncMode p_vsync_mode, uint32_t p_flags, const Rect2i &p_rect = Rect2i()); - virtual void show_window(WindowID p_id); - virtual void delete_sub_window(WindowID p_id); + virtual WindowID create_sub_window(WindowMode p_mode, VSyncMode p_vsync_mode, uint32_t p_flags, const Rect2i &p_rect = Rect2i()) override; + virtual void show_window(WindowID p_id) override; + virtual void delete_sub_window(WindowID p_id) override; - virtual WindowID get_window_at_screen_position(const Point2i &p_position) const; + virtual WindowID get_window_at_screen_position(const Point2i &p_position) const override; - virtual void window_attach_instance_id(ObjectID p_instance, WindowID p_window = MAIN_WINDOW_ID); - virtual ObjectID window_get_attached_instance_id(WindowID p_window = MAIN_WINDOW_ID) const; + virtual void window_attach_instance_id(ObjectID p_instance, WindowID p_window = MAIN_WINDOW_ID) override; + virtual ObjectID window_get_attached_instance_id(WindowID p_window = MAIN_WINDOW_ID) const override; - virtual void window_set_title(const String &p_title, WindowID p_window = MAIN_WINDOW_ID); - virtual void window_set_mouse_passthrough(const Vector<Vector2> &p_region, WindowID p_window = MAIN_WINDOW_ID); + virtual void window_set_title(const String &p_title, WindowID p_window = MAIN_WINDOW_ID) override; + virtual void window_set_mouse_passthrough(const Vector<Vector2> &p_region, WindowID p_window = MAIN_WINDOW_ID) override; - virtual void window_set_rect_changed_callback(const Callable &p_callable, WindowID p_window = MAIN_WINDOW_ID); - virtual void window_set_window_event_callback(const Callable &p_callable, WindowID p_window = MAIN_WINDOW_ID); - virtual void window_set_input_event_callback(const Callable &p_callable, WindowID p_window = MAIN_WINDOW_ID); - virtual void window_set_input_text_callback(const Callable &p_callable, WindowID p_window = MAIN_WINDOW_ID); - virtual void window_set_drop_files_callback(const Callable &p_callable, WindowID p_window = MAIN_WINDOW_ID); + virtual void window_set_rect_changed_callback(const Callable &p_callable, WindowID p_window = MAIN_WINDOW_ID) override; + virtual void window_set_window_event_callback(const Callable &p_callable, WindowID p_window = MAIN_WINDOW_ID) override; + virtual void window_set_input_event_callback(const Callable &p_callable, WindowID p_window = MAIN_WINDOW_ID) override; + virtual void window_set_input_text_callback(const Callable &p_callable, WindowID p_window = MAIN_WINDOW_ID) override; + virtual void window_set_drop_files_callback(const Callable &p_callable, WindowID p_window = MAIN_WINDOW_ID) override; - virtual int window_get_current_screen(WindowID p_window = MAIN_WINDOW_ID) const; - virtual void window_set_current_screen(int p_screen, WindowID p_window = MAIN_WINDOW_ID); + virtual int window_get_current_screen(WindowID p_window = MAIN_WINDOW_ID) const override; + virtual void window_set_current_screen(int p_screen, WindowID p_window = MAIN_WINDOW_ID) override; - virtual Point2i window_get_position(WindowID p_window = MAIN_WINDOW_ID) const; - virtual void window_set_position(const Point2i &p_position, WindowID p_window = MAIN_WINDOW_ID); + virtual Point2i window_get_position(WindowID p_window = MAIN_WINDOW_ID) const override; + virtual void window_set_position(const Point2i &p_position, WindowID p_window = MAIN_WINDOW_ID) override; - virtual void window_set_max_size(const Size2i p_size, WindowID p_window = MAIN_WINDOW_ID); - virtual Size2i window_get_max_size(WindowID p_window = MAIN_WINDOW_ID) const; + virtual void window_set_max_size(const Size2i p_size, WindowID p_window = MAIN_WINDOW_ID) override; + virtual Size2i window_get_max_size(WindowID p_window = MAIN_WINDOW_ID) const override; - virtual void window_set_transient(WindowID p_window, WindowID p_parent); + virtual void window_set_transient(WindowID p_window, WindowID p_parent) override; - virtual void window_set_min_size(const Size2i p_size, WindowID p_window = MAIN_WINDOW_ID); - virtual Size2i window_get_min_size(WindowID p_window = MAIN_WINDOW_ID) const; + virtual void window_set_min_size(const Size2i p_size, WindowID p_window = MAIN_WINDOW_ID) override; + virtual Size2i window_get_min_size(WindowID p_window = MAIN_WINDOW_ID) const override; - virtual void window_set_size(const Size2i p_size, WindowID p_window = MAIN_WINDOW_ID); - virtual Size2i window_get_size(WindowID p_window = MAIN_WINDOW_ID) const; - virtual Size2i window_get_real_size(WindowID p_window = MAIN_WINDOW_ID) const; + virtual void window_set_size(const Size2i p_size, WindowID p_window = MAIN_WINDOW_ID) override; + virtual Size2i window_get_size(WindowID p_window = MAIN_WINDOW_ID) const override; + virtual Size2i window_get_real_size(WindowID p_window = MAIN_WINDOW_ID) const override; - virtual void window_set_mode(WindowMode p_mode, WindowID p_window = MAIN_WINDOW_ID); - virtual WindowMode window_get_mode(WindowID p_window = MAIN_WINDOW_ID) const; + virtual void window_set_mode(WindowMode p_mode, WindowID p_window = MAIN_WINDOW_ID) override; + virtual WindowMode window_get_mode(WindowID p_window = MAIN_WINDOW_ID) const override; - virtual bool window_is_maximize_allowed(WindowID p_window = MAIN_WINDOW_ID) const; + virtual bool window_is_maximize_allowed(WindowID p_window = MAIN_WINDOW_ID) const override; - virtual void window_set_flag(WindowFlags p_flag, bool p_enabled, WindowID p_window = MAIN_WINDOW_ID); - virtual bool window_get_flag(WindowFlags p_flag, WindowID p_window = MAIN_WINDOW_ID) const; + virtual void window_set_flag(WindowFlags p_flag, bool p_enabled, WindowID p_window = MAIN_WINDOW_ID) override; + virtual bool window_get_flag(WindowFlags p_flag, WindowID p_window = MAIN_WINDOW_ID) const override; - virtual void window_request_attention(WindowID p_window = MAIN_WINDOW_ID); + virtual void window_request_attention(WindowID p_window = MAIN_WINDOW_ID) override; - virtual void window_move_to_foreground(WindowID p_window = MAIN_WINDOW_ID); + virtual void window_move_to_foreground(WindowID p_window = MAIN_WINDOW_ID) override; - virtual bool window_can_draw(WindowID p_window = MAIN_WINDOW_ID) const; + virtual bool window_can_draw(WindowID p_window = MAIN_WINDOW_ID) const override; - virtual bool can_any_window_draw() const; + virtual bool can_any_window_draw() const override; - virtual void window_set_ime_active(const bool p_active, WindowID p_window = MAIN_WINDOW_ID); - virtual void window_set_ime_position(const Point2i &p_pos, WindowID p_window = MAIN_WINDOW_ID); + virtual void window_set_ime_active(const bool p_active, WindowID p_window = MAIN_WINDOW_ID) override; + virtual void window_set_ime_position(const Point2i &p_pos, WindowID p_window = MAIN_WINDOW_ID) override; virtual void window_set_vsync_mode(DisplayServer::VSyncMode p_vsync_mode, WindowID p_window = MAIN_WINDOW_ID) override; virtual DisplayServer::VSyncMode window_get_vsync_mode(WindowID p_vsync_mode) const override; - virtual void cursor_set_shape(CursorShape p_shape); - virtual CursorShape cursor_get_shape() const; - virtual void cursor_set_custom_image(const RES &p_cursor, CursorShape p_shape, const Vector2 &p_hotspot); + virtual void cursor_set_shape(CursorShape p_shape) override; + virtual CursorShape cursor_get_shape() const override; + virtual void cursor_set_custom_image(const RES &p_cursor, CursorShape p_shape, const Vector2 &p_hotspot) override; - virtual int keyboard_get_layout_count() const; - virtual int keyboard_get_current_layout() const; - virtual void keyboard_set_current_layout(int p_index); - virtual String keyboard_get_layout_language(int p_index) const; - virtual String keyboard_get_layout_name(int p_index) const; + virtual int keyboard_get_layout_count() const override; + virtual int keyboard_get_current_layout() const override; + virtual void keyboard_set_current_layout(int p_index) override; + virtual String keyboard_get_layout_language(int p_index) const override; + virtual String keyboard_get_layout_name(int p_index) const override; - virtual void process_events(); + virtual void process_events() override; - virtual void release_rendering_thread(); - virtual void make_rendering_thread(); - virtual void swap_buffers(); + virtual void release_rendering_thread() override; + virtual void make_rendering_thread() override; + virtual void swap_buffers() override; - virtual void set_context(Context p_context); + virtual void set_context(Context p_context) override; - virtual void set_native_icon(const String &p_filename); - virtual void set_icon(const Ref<Image> &p_icon); + virtual void set_native_icon(const String &p_filename) override; + virtual void set_icon(const Ref<Image> &p_icon) override; static DisplayServer *create_func(const String &p_rendering_driver, WindowMode p_mode, VSyncMode p_vsync_mode, uint32_t p_flags, const Vector2i &p_resolution, Error &r_error); static Vector<String> get_rendering_drivers_func(); diff --git a/platform/linuxbsd/os_linuxbsd.cpp b/platform/linuxbsd/os_linuxbsd.cpp index c6a2fa5be7..08630be8b0 100644 --- a/platform/linuxbsd/os_linuxbsd.cpp +++ b/platform/linuxbsd/os_linuxbsd.cpp @@ -51,6 +51,70 @@ #include <sys/types.h> #include <unistd.h> +void OS_LinuxBSD::alert(const String &p_alert, const String &p_title) { + const char *message_programs[] = { "zenity", "kdialog", "Xdialog", "xmessage" }; + + String path = get_environment("PATH"); + Vector<String> path_elems = path.split(":", false); + String program; + + for (int i = 0; i < path_elems.size(); i++) { + for (uint64_t k = 0; k < sizeof(message_programs) / sizeof(char *); k++) { + String tested_path = path_elems[i].plus_file(message_programs[k]); + + if (FileAccess::exists(tested_path)) { + program = tested_path; + break; + } + } + + if (program.length()) { + break; + } + } + + List<String> args; + + if (program.ends_with("zenity")) { + args.push_back("--error"); + args.push_back("--width"); + args.push_back("500"); + args.push_back("--title"); + args.push_back(p_title); + args.push_back("--text"); + args.push_back(p_alert); + } + + if (program.ends_with("kdialog")) { + args.push_back("--error"); + args.push_back(p_alert); + args.push_back("--title"); + args.push_back(p_title); + } + + if (program.ends_with("Xdialog")) { + args.push_back("--title"); + args.push_back(p_title); + args.push_back("--msgbox"); + args.push_back(p_alert); + args.push_back("0"); + args.push_back("0"); + } + + if (program.ends_with("xmessage")) { + args.push_back("-center"); + args.push_back("-title"); + args.push_back(p_title); + args.push_back(p_alert); + } + + if (program.length()) { + execute(program, args); + } else { + print_line(p_alert); + } +} + void OS_LinuxBSD::initialize() { crash_handler.initialize(); @@ -387,7 +451,7 @@ Error OS_LinuxBSD::move_to_trash(const String &p_path) { DirAccess *dir_access = DirAccess::create(DirAccess::ACCESS_FILESYSTEM); Error err = dir_access->make_dir_recursive(trash_path); - // Issue an error if trash can is not created proprely. + // Issue an error if trash can is not created properly. ERR_FAIL_COND_V_MSG(err != OK, err, "Could not create the trash path \"" + trash_path + "\""); err = dir_access->make_dir_recursive(trash_path + "/files"); ERR_FAIL_COND_V_MSG(err != OK, err, "Could not create the trash path \"" + trash_path + "\"/files"); @@ -425,7 +489,7 @@ Error OS_LinuxBSD::move_to_trash(const String &p_path) { // Generates the .trashinfo file OS::Date date = OS::get_singleton()->get_date(false); OS::Time time = OS::get_singleton()->get_time(false); - String timestamp = vformat("%04d-%02d-%02dT%02d:%02d:", date.year, date.month, date.day, time.hour, time.minute); + String timestamp = vformat("%04d-%02d-%02dT%02d:%02d:", date.year, (int)date.month, date.day, time.hour, time.minute); timestamp = vformat("%s%02d", timestamp, time.second); // vformat only supports up to 6 arguments. String trash_info = "[Trash Info]\nPath=" + p_path.uri_encode() + "\nDeletionDate=" + timestamp + "\n"; { diff --git a/platform/linuxbsd/os_linuxbsd.h b/platform/linuxbsd/os_linuxbsd.h index b6cf93c551..1e06587322 100644 --- a/platform/linuxbsd/os_linuxbsd.h +++ b/platform/linuxbsd/os_linuxbsd.h @@ -90,6 +90,8 @@ public: virtual String get_unique_id() const override; + virtual void alert(const String &p_alert, const String &p_title = "ALERT!") override; + virtual bool _check_internal_feature_support(const String &p_feature) override; void run(); diff --git a/platform/osx/detect.py b/platform/osx/detect.py index 317e79d0ea..2393f2ea10 100644 --- a/platform/osx/detect.py +++ b/platform/osx/detect.py @@ -24,6 +24,7 @@ def get_opts(): return [ ("osxcross_sdk", "OSXCross SDK version", "darwin16"), ("MACOS_SDK_PATH", "Path to the macOS SDK", ""), + ("VULKAN_SDK_PATH", "Path to the Vulkan SDK", ""), BoolVariable( "use_static_mvk", "Link MoltenVK statically as Level-0 driver (better portability) or use Vulkan ICD loader (enables" @@ -190,7 +191,7 @@ def configure(env): env.Append(CPPDEFINES=["VULKAN_ENABLED"]) env.Append(LINKFLAGS=["-framework", "Metal", "-framework", "QuartzCore", "-framework", "IOSurface"]) if env["use_static_mvk"]: - env.Append(LINKFLAGS=["-framework", "MoltenVK"]) + env.Append(LINKFLAGS=["-L$VULKAN_SDK_PATH/MoltenVK/MoltenVK.xcframework/macos-arm64_x86_64/", "-lMoltenVK"]) env["builtin_vulkan"] = False elif not env["builtin_vulkan"]: env.Append(LIBS=["vulkan"]) diff --git a/platform/osx/display_server_osx.h b/platform/osx/display_server_osx.h index c7b9e411b8..6b1b777224 100644 --- a/platform/osx/display_server_osx.h +++ b/platform/osx/display_server_osx.h @@ -60,6 +60,10 @@ class DisplayServerOSX : public DisplayServer { _THREAD_SAFE_CLASS_ public: + void _send_event(NSEvent *p_event); + NSMenu *_get_dock_menu() const; + void _menu_callback(id p_sender); + #if defined(OPENGL_ENABLED) ContextGL_OSX *context_gles2; #endif @@ -163,7 +167,6 @@ public: String rendering_driver; - id delegate; id autoreleasePool; CGEventSourceRef eventSource; @@ -207,7 +210,6 @@ public: virtual void global_menu_remove_item(const String &p_menu_root, int p_idx) override; virtual void global_menu_clear(const String &p_menu_root) override; - virtual void alert(const String &p_alert, const String &p_title = "ALERT!") override; virtual Error dialog_show(String p_title, String p_description, Vector<String> p_buttons, const Callable &p_callback) override; virtual Error dialog_input_text(String p_title, String p_description, String p_partial, const Callable &p_callback) override; diff --git a/platform/osx/display_server_osx.mm b/platform/osx/display_server_osx.mm index dec6da42fe..73aa013701 100644 --- a/platform/osx/display_server_osx.mm +++ b/platform/osx/display_server_osx.mm @@ -105,46 +105,6 @@ static NSCursor *_cursorFromSelector(SEL selector, SEL fallback = nil) { } /*************************************************************************/ -/* GodotApplication */ -/*************************************************************************/ - -@interface GodotApplication : NSApplication -@end - -@implementation GodotApplication - -- (void)sendEvent:(NSEvent *)event { - // special case handling of command-period, which is traditionally a special - // shortcut in macOS and doesn't arrive at our regular keyDown handler. - if ([event type] == NSEventTypeKeyDown) { - if (([event modifierFlags] & NSEventModifierFlagCommand) && [event keyCode] == 0x2f) { - Ref<InputEventKey> k; - k.instantiate(); - - _get_key_modifier_state([event modifierFlags], k); - k->set_window_id(DisplayServerOSX::INVALID_WINDOW_ID); - k->set_pressed(true); - k->set_keycode(KEY_PERIOD); - k->set_physical_keycode(KEY_PERIOD); - k->set_echo([event isARepeat]); - - Input::get_singleton()->accumulate_input_event(k); - } - } - - // From http://cocoadev.com/index.pl?GameKeyboardHandlingAlmost - // This works around an AppKit bug, where key up events while holding - // down the command key don't get sent to the key window. - if ([event type] == NSEventTypeKeyUp && ([event modifierFlags] & NSEventModifierFlagCommand)) { - [[self keyWindow] sendEvent:event]; - } else { - [super sendEvent:event]; - } -} - -@end - -/*************************************************************************/ /* GlobalMenuItem */ /*************************************************************************/ @@ -161,121 +121,6 @@ static NSCursor *_cursorFromSelector(SEL selector, SEL fallback = nil) { @end /*************************************************************************/ -/* GodotApplicationDelegate */ -/*************************************************************************/ - -@interface GodotApplicationDelegate : NSObject -- (void)forceUnbundledWindowActivationHackStep1; -- (void)forceUnbundledWindowActivationHackStep2; -- (void)forceUnbundledWindowActivationHackStep3; -@end - -@implementation GodotApplicationDelegate - -- (void)forceUnbundledWindowActivationHackStep1 { - // Step1: Switch focus to macOS Dock. - // Required to perform step 2, TransformProcessType will fail if app is already the in focus. - for (NSRunningApplication *app in [NSRunningApplication runningApplicationsWithBundleIdentifier:@"com.apple.dock"]) { - [app activateWithOptions:NSApplicationActivateIgnoringOtherApps]; - break; - } - [self performSelector:@selector(forceUnbundledWindowActivationHackStep2) withObject:nil afterDelay:0.02]; -} - -- (void)forceUnbundledWindowActivationHackStep2 { - // Step 2: Register app as foreground process. - ProcessSerialNumber psn = { 0, kCurrentProcess }; - (void)TransformProcessType(&psn, kProcessTransformToForegroundApplication); - [self performSelector:@selector(forceUnbundledWindowActivationHackStep3) withObject:nil afterDelay:0.02]; -} - -- (void)forceUnbundledWindowActivationHackStep3 { - // Step 3: Switch focus back to app window. - [[NSRunningApplication currentApplication] activateWithOptions:NSApplicationActivateIgnoringOtherApps]; -} - -- (void)applicationDidFinishLaunching:(NSNotification *)notice { - NSString *nsappname = [[[NSBundle mainBundle] infoDictionary] objectForKey:@"CFBundleName"]; - if (nsappname == nil) { - // If executable is not a bundled, macOS WindowServer won't register and activate app window correctly (menu and title bar are grayed out and input ignored). - [self performSelector:@selector(forceUnbundledWindowActivationHackStep1) withObject:nil afterDelay:0.02]; - } -} - -- (void)applicationDidResignActive:(NSNotification *)notification { - if (OS_OSX::get_singleton()->get_main_loop()) { - OS_OSX::get_singleton()->get_main_loop()->notification(MainLoop::NOTIFICATION_APPLICATION_FOCUS_OUT); - } -} - -- (void)applicationDidBecomeActive:(NSNotification *)notification { - if (OS_OSX::get_singleton()->get_main_loop()) { - OS_OSX::get_singleton()->get_main_loop()->notification(MainLoop::NOTIFICATION_APPLICATION_FOCUS_IN); - } -} - -- (void)globalMenuCallback:(id)sender { - if (![sender representedObject]) { - return; - } - - GlobalMenuItem *value = [sender representedObject]; - - if (value) { - if (value->checkable) { - if ([sender state] == NSControlStateValueOff) { - [sender setState:NSControlStateValueOn]; - } else { - [sender setState:NSControlStateValueOff]; - } - } - - if (value->callback != Callable()) { - Variant tag = value->meta; - Variant *tagp = &tag; - Variant ret; - Callable::CallError ce; - value->callback.call((const Variant **)&tagp, 1, ret, ce); - } - } -} - -- (NSMenu *)applicationDockMenu:(NSApplication *)sender { - return DS_OSX->dock_menu; -} - -- (BOOL)application:(NSApplication *)sender openFile:(NSString *)filename { - // Note: may be called called before main loop init! - char *utfs = strdup([filename UTF8String]); - ((OS_OSX *)(OS_OSX::get_singleton()))->open_with_filename.parse_utf8(utfs); - free(utfs); - -#ifdef TOOLS_ENABLED - // Open new instance - if (OS_OSX::get_singleton()->get_main_loop()) { - List<String> args; - args.push_back(((OS_OSX *)(OS_OSX::get_singleton()))->open_with_filename); - String exec = OS::get_singleton()->get_executable_path(); - OS::get_singleton()->create_process(exec, args); - } -#endif - return YES; -} - -- (NSApplicationTerminateReply)applicationShouldTerminate:(NSApplication *)sender { - DS_OSX->_send_window_event(DS_OSX->windows[DisplayServerOSX::MAIN_WINDOW_ID], DisplayServerOSX::WINDOW_EVENT_CLOSE_REQUEST); - return NSTerminateCancel; -} - -- (void)showAbout:(id)sender { - if (OS_OSX::get_singleton()->get_main_loop()) { - OS_OSX::get_singleton()->get_main_loop()->notification(MainLoop::NOTIFICATION_WM_ABOUT); - } -} - -@end - -/*************************************************************************/ /* GodotWindowDelegate */ /*************************************************************************/ @@ -1983,26 +1828,6 @@ void DisplayServerOSX::global_menu_clear(const String &p_menu_root) { } } -void DisplayServerOSX::alert(const String &p_alert, const String &p_title) { - _THREAD_SAFE_METHOD_ - - NSAlert *window = [[NSAlert alloc] init]; - NSString *ns_title = [NSString stringWithUTF8String:p_title.utf8().get_data()]; - NSString *ns_alert = [NSString stringWithUTF8String:p_alert.utf8().get_data()]; - - [window addButtonWithTitle:@"OK"]; - [window setMessageText:ns_title]; - [window setInformativeText:ns_alert]; - [window setAlertStyle:NSAlertStyleWarning]; - - id key_window = [[NSApplication sharedApplication] keyWindow]; - [window runModal]; - [window release]; - if (key_window) { - [key_window makeKeyAndOrderFront:nil]; - } -} - Error DisplayServerOSX::dialog_show(String p_title, String p_description, Vector<String> p_buttons, const Callable &p_callback) { _THREAD_SAFE_METHOD_ @@ -3375,6 +3200,56 @@ void DisplayServerOSX::_release_pressed_events() { } } +NSMenu *DisplayServerOSX::_get_dock_menu() const { + return dock_menu; +} + +void DisplayServerOSX::_menu_callback(id p_sender) { + if (![p_sender representedObject]) { + return; + } + + GlobalMenuItem *value = [p_sender representedObject]; + + if (value) { + if (value->checkable) { + if ([p_sender state] == NSControlStateValueOff) { + [p_sender setState:NSControlStateValueOn]; + } else { + [p_sender setState:NSControlStateValueOff]; + } + } + + if (value->callback != Callable()) { + Variant tag = value->meta; + Variant *tagp = &tag; + Variant ret; + Callable::CallError ce; + value->callback.call((const Variant **)&tagp, 1, ret, ce); + } + } +} + +void DisplayServerOSX::_send_event(NSEvent *p_event) { + // special case handling of command-period, which is traditionally a special + // shortcut in macOS and doesn't arrive at our regular keyDown handler. + if ([p_event type] == NSEventTypeKeyDown) { + if (([p_event modifierFlags] & NSEventModifierFlagCommand) && [p_event keyCode] == 0x2f) { + Ref<InputEventKey> k; + k.instantiate(); + + _get_key_modifier_state([p_event modifierFlags], k); + k->set_window_id(DisplayServerOSX::INVALID_WINDOW_ID); + k->set_pressed(true); + k->set_keycode(KEY_PERIOD); + k->set_physical_keycode(KEY_PERIOD); + k->set_echo([p_event isARepeat]); + + Input::get_singleton()->accumulate_input_event(k); + } + } +} + void DisplayServerOSX::_process_key_events() { Ref<InputEventKey> k; for (int i = 0; i < key_event_pos; i++) { @@ -3615,7 +3490,7 @@ ObjectID DisplayServerOSX::window_get_attached_instance_id(WindowID p_window) co DisplayServer *DisplayServerOSX::create_func(const String &p_rendering_driver, WindowMode p_mode, VSyncMode p_vsync_mode, uint32_t p_flags, const Vector2i &p_resolution, Error &r_error) { DisplayServer *ds = memnew(DisplayServerOSX(p_rendering_driver, p_mode, p_vsync_mode, p_flags, p_resolution, r_error)); if (r_error != OK) { - ds->alert("Your video card driver does not support any of the supported Metal versions.", "Unable to initialize Video driver"); + OS::get_singleton()->alert("Your video card driver does not support any of the supported Metal versions.", "Unable to initialize Video driver"); } return ds; } @@ -3785,12 +3660,6 @@ DisplayServerOSX::DisplayServerOSX(const String &p_rendering_driver, WindowMode CGEventSourceSetLocalEventsSuppressionInterval(eventSource, 0.0); - // Implicitly create shared NSApplication instance - [GodotApplication sharedApplication]; - - // In case we are unbundled, make us a proper UI application - [NSApp setActivationPolicy:NSApplicationActivationPolicyRegular]; - keyboard_layout_dirty = true; displays_arrangement_dirty = true; displays_scale_dirty = true; @@ -3804,9 +3673,6 @@ DisplayServerOSX::DisplayServerOSX(const String &p_rendering_driver, WindowMode // Register to be notified on displays arrangement changes CGDisplayRegisterReconfigurationCallback(displays_arrangement_changed, nullptr); - // Menu bar setup must go between sharedApplication above and - // finishLaunching below, in order to properly emulate the behavior - // of NSApplicationMain NSMenuItem *menu_item; NSString *title; @@ -3846,32 +3712,10 @@ DisplayServerOSX::DisplayServerOSX(const String &p_rendering_driver, WindowMode title = [NSString stringWithFormat:NSLocalizedString(@"Quit %@", nil), nsappname]; [apple_menu addItemWithTitle:title action:@selector(terminate:) keyEquivalent:@"q"]; - // Setup menu bar - NSMenu *main_menu = [[[NSMenu alloc] initWithTitle:@""] autorelease]; + // Add items to the menu bar + NSMenu *main_menu = [NSApp mainMenu]; menu_item = [main_menu addItemWithTitle:@"" action:nil keyEquivalent:@""]; [main_menu setSubmenu:apple_menu forItem:menu_item]; - [NSApp setMainMenu:main_menu]; - - [NSApp finishLaunching]; - - delegate = [[GodotApplicationDelegate alloc] init]; - ERR_FAIL_COND(!delegate); - [NSApp setDelegate:delegate]; - - //process application:openFile: event - while (true) { - NSEvent *event = [NSApp - nextEventMatchingMask:NSEventMaskAny - untilDate:[NSDate distantPast] - inMode:NSDefaultRunLoopMode - dequeue:YES]; - - if (event == nil) { - break; - } - - [NSApp sendEvent:event]; - } //!!!!!!!!!!!!!!!!!!!!!!!!!! //TODO - do Vulkan and GLES2 support checks, driver selection and fallback @@ -3924,8 +3768,6 @@ DisplayServerOSX::DisplayServerOSX(const String &p_rendering_driver, WindowMode RendererCompositorRD::make_current(); } #endif - - [NSApp activateIgnoringOtherApps:YES]; } DisplayServerOSX::~DisplayServerOSX() { diff --git a/platform/osx/export/export.cpp b/platform/osx/export/export.cpp index ea34b8a24e..131c4b821e 100644 --- a/platform/osx/export/export.cpp +++ b/platform/osx/export/export.cpp @@ -178,6 +178,7 @@ void EditorExportPlatformOSX::get_export_options(List<ExportOption> *r_options) r_options->push_back(ExportOption(PropertyInfo(Variant::BOOL, "codesign/entitlements/calendars"), false)); r_options->push_back(ExportOption(PropertyInfo(Variant::BOOL, "codesign/entitlements/photos_library"), false)); r_options->push_back(ExportOption(PropertyInfo(Variant::BOOL, "codesign/entitlements/apple_events"), false)); + r_options->push_back(ExportOption(PropertyInfo(Variant::BOOL, "codesign/entitlements/debugging"), false)); r_options->push_back(ExportOption(PropertyInfo(Variant::BOOL, "codesign/entitlements/app_sandbox/enabled"), false)); r_options->push_back(ExportOption(PropertyInfo(Variant::BOOL, "codesign/entitlements/app_sandbox/network_server"), false)); @@ -845,6 +846,10 @@ Error EditorExportPlatformOSX::export_project(const Ref<EditorExportPreset> &p_p ent_f->store_line("<key>com.apple.security.automation.apple-events</key>"); ent_f->store_line("<true/>"); } + if ((bool)p_preset->get("codesign/entitlements/debugging")) { + ent_f->store_line("<key>com.apple.security.get-task-allow</key>"); + ent_f->store_line("<true/>"); + } if ((bool)p_preset->get("codesign/entitlements/app_sandbox/enabled")) { ent_f->store_line("<key>com.apple.security.app-sandbox</key>"); diff --git a/platform/osx/joypad_osx.cpp b/platform/osx/joypad_osx.cpp index 126ebc1908..d778271350 100644 --- a/platform/osx/joypad_osx.cpp +++ b/platform/osx/joypad_osx.cpp @@ -286,8 +286,9 @@ bool JoypadOSX::configure_joypad(IOHIDDeviceRef p_device_ref, joypad *p_joy) { } if ((!refCF) || (!CFStringGetCString((CFStringRef)refCF, c_name, sizeof(c_name), kCFStringEncodingUTF8))) { name = "Unidentified Joypad"; + } else { + name = c_name; } - name = c_name; int id = input->get_unused_joy_id(); ERR_FAIL_COND_V(id == -1, false); diff --git a/platform/osx/os_osx.h b/platform/osx/os_osx.h index d57940775d..37d30add78 100644 --- a/platform/osx/os_osx.h +++ b/platform/osx/os_osx.h @@ -72,6 +72,8 @@ protected: public: virtual String get_name() const override; + virtual void alert(const String &p_alert, const String &p_title = "ALERT!") override; + virtual Error open_dynamic_library(const String p_path, void *&p_library_handle, bool p_also_set_library_path = false) override; virtual MainLoop *get_main_loop() const override; diff --git a/platform/osx/os_osx.mm b/platform/osx/os_osx.mm index b65d84d900..c458a0264a 100644 --- a/platform/osx/os_osx.mm +++ b/platform/osx/os_osx.mm @@ -41,6 +41,137 @@ #include <mach-o/dyld.h> #include <os/log.h> +#define DS_OSX ((DisplayServerOSX *)(DisplayServerOSX::get_singleton())) + +/*************************************************************************/ +/* GodotApplication */ +/*************************************************************************/ + +@interface GodotApplication : NSApplication +@end + +@implementation GodotApplication + +- (void)sendEvent:(NSEvent *)event { + if (DS_OSX) { + DS_OSX->_send_event(event); + } + + // From http://cocoadev.com/index.pl?GameKeyboardHandlingAlmost + // This works around an AppKit bug, where key up events while holding + // down the command key don't get sent to the key window. + if ([event type] == NSEventTypeKeyUp && ([event modifierFlags] & NSEventModifierFlagCommand)) { + [[self keyWindow] sendEvent:event]; + } else { + [super sendEvent:event]; + } +} + +@end + +/*************************************************************************/ +/* GodotApplicationDelegate */ +/*************************************************************************/ + +@interface GodotApplicationDelegate : NSObject +- (void)forceUnbundledWindowActivationHackStep1; +- (void)forceUnbundledWindowActivationHackStep2; +- (void)forceUnbundledWindowActivationHackStep3; +@end + +@implementation GodotApplicationDelegate + +- (void)forceUnbundledWindowActivationHackStep1 { + // Step1: Switch focus to macOS Dock. + // Required to perform step 2, TransformProcessType will fail if app is already the in focus. + for (NSRunningApplication *app in [NSRunningApplication runningApplicationsWithBundleIdentifier:@"com.apple.dock"]) { + [app activateWithOptions:NSApplicationActivateIgnoringOtherApps]; + break; + } + [self performSelector:@selector(forceUnbundledWindowActivationHackStep2) + withObject:nil + afterDelay:0.02]; +} + +- (void)forceUnbundledWindowActivationHackStep2 { + // Step 2: Register app as foreground process. + ProcessSerialNumber psn = { 0, kCurrentProcess }; + (void)TransformProcessType(&psn, kProcessTransformToForegroundApplication); + [self performSelector:@selector(forceUnbundledWindowActivationHackStep3) withObject:nil afterDelay:0.02]; +} + +- (void)forceUnbundledWindowActivationHackStep3 { + // Step 3: Switch focus back to app window. + [[NSRunningApplication currentApplication] activateWithOptions:NSApplicationActivateIgnoringOtherApps]; +} + +- (void)applicationDidFinishLaunching:(NSNotification *)notice { + NSString *nsappname = [[[NSBundle mainBundle] infoDictionary] objectForKey:@"CFBundleName"]; + if (nsappname == nil) { + // If executable is not a bundled, macOS WindowServer won't register and activate app window correctly (menu and title bar are grayed out and input ignored). + [self performSelector:@selector(forceUnbundledWindowActivationHackStep1) withObject:nil afterDelay:0.02]; + } +} + +- (void)applicationDidResignActive:(NSNotification *)notification { + if (OS::get_singleton()->get_main_loop()) { + OS::get_singleton()->get_main_loop()->notification(MainLoop::NOTIFICATION_APPLICATION_FOCUS_OUT); + } +} + +- (void)applicationDidBecomeActive:(NSNotification *)notification { + if (OS::get_singleton()->get_main_loop()) { + OS::get_singleton()->get_main_loop()->notification(MainLoop::NOTIFICATION_APPLICATION_FOCUS_IN); + } +} + +- (void)globalMenuCallback:(id)sender { + if (DS_OSX) { + return DS_OSX->_menu_callback(sender); + } +} + +- (NSMenu *)applicationDockMenu:(NSApplication *)sender { + if (DS_OSX) { + return DS_OSX->_get_dock_menu(); + } else { + return nullptr; + } +} + +- (BOOL)application:(NSApplication *)sender openFile:(NSString *)filename { + // Note: may be called called before main loop init! + char *utfs = strdup([filename UTF8String]); + ((OS_OSX *)OS_OSX::get_singleton())->open_with_filename.parse_utf8(utfs); + free(utfs); + +#ifdef TOOLS_ENABLED + // Open new instance + if (OS_OSX::get_singleton()->get_main_loop()) { + List<String> args; + args.push_back(((OS_OSX *)OS_OSX::get_singleton())->open_with_filename); + String exec = OS_OSX::get_singleton()->get_executable_path(); + OS_OSX::get_singleton()->create_process(exec, args); + } +#endif + return YES; +} + +- (NSApplicationTerminateReply)applicationShouldTerminate:(NSApplication *)sender { + if (DS_OSX) { + DS_OSX->_send_window_event(DS_OSX->windows[DisplayServerOSX::MAIN_WINDOW_ID], DisplayServerOSX::WINDOW_EVENT_CLOSE_REQUEST); + } + return NSTerminateCancel; +} + +- (void)showAbout:(id)sender { + if (OS_OSX::get_singleton()->get_main_loop()) { + OS_OSX::get_singleton()->get_main_loop()->notification(MainLoop::NOTIFICATION_WM_ABOUT); + } +} + +@end + /*************************************************************************/ /* OSXTerminalLogger */ /*************************************************************************/ @@ -119,6 +250,24 @@ String OS_OSX::get_unique_id() const { return serial_number; } +void OS_OSX::alert(const String &p_alert, const String &p_title) { + NSAlert *window = [[NSAlert alloc] init]; + NSString *ns_title = [NSString stringWithUTF8String:p_title.utf8().get_data()]; + NSString *ns_alert = [NSString stringWithUTF8String:p_alert.utf8().get_data()]; + + [window addButtonWithTitle:@"OK"]; + [window setMessageText:ns_title]; + [window setInformativeText:ns_alert]; + [window setAlertStyle:NSAlertStyleWarning]; + + id key_window = [[NSApplication sharedApplication] keyWindow]; + [window runModal]; + [window release]; + if (key_window) { + [key_window makeKeyAndOrderFront:nil]; + } +} + void OS_OSX::initialize_core() { OS_Unix::initialize_core(); @@ -220,7 +369,7 @@ String OS_OSX::get_cache_path() const { if (get_environment("XDG_CACHE_HOME").is_absolute_path()) { return get_environment("XDG_CACHE_HOME"); } else { - WARN_PRINT_ONCE("`XDG_CACHE_HOME` is a relative path. Ignoring its value and falling back to `$HOME/Libary/Caches` or `get_config_path()` per the XDG Base Directory specification."); + WARN_PRINT_ONCE("`XDG_CACHE_HOME` is a relative path. Ignoring its value and falling back to `$HOME/Library/Caches` or `get_config_path()` per the XDG Base Directory specification."); } } if (has_environment("HOME")) { @@ -372,6 +521,41 @@ OS_OSX::OS_OSX() { #endif DisplayServerOSX::register_osx_driver(); + + // Implicitly create shared NSApplication instance + [GodotApplication sharedApplication]; + + // In case we are unbundled, make us a proper UI application + [NSApp setActivationPolicy:NSApplicationActivationPolicyRegular]; + + // Menu bar setup must go between sharedApplication above and + // finishLaunching below, in order to properly emulate the behavior + // of NSApplicationMain + + NSMenu *main_menu = [[[NSMenu alloc] initWithTitle:@""] autorelease]; + [NSApp setMainMenu:main_menu]; + [NSApp finishLaunching]; + + id delegate = [[GodotApplicationDelegate alloc] init]; + ERR_FAIL_COND(!delegate); + [NSApp setDelegate:delegate]; + + //process application:openFile: event + while (true) { + NSEvent *event = [NSApp + nextEventMatchingMask:NSEventMaskAny + untilDate:[NSDate distantPast] + inMode:NSDefaultRunLoopMode + dequeue:YES]; + + if (event == nil) { + break; + } + + [NSApp sendEvent:event]; + } + + [NSApp activateIgnoringOtherApps:YES]; } bool OS_OSX::_check_internal_feature_support(const String &p_feature) { diff --git a/platform/uwp/export/export.cpp b/platform/uwp/export/export.cpp index 1075ae38ce..98925fd7fa 100644 --- a/platform/uwp/export/export.cpp +++ b/platform/uwp/export/export.cpp @@ -31,7 +31,6 @@ #include "export.h" #include "core/config/project_settings.h" -#include "core/core_bind.h" #include "core/crypto/crypto_core.h" #include "core/io/dir_access.h" #include "core/io/file_access.h" diff --git a/platform/windows/detect.py b/platform/windows/detect.py index 7772ba2dbe..287ece1d29 100644 --- a/platform/windows/detect.py +++ b/platform/windows/detect.py @@ -152,7 +152,7 @@ def setup_msvc_auto(env): env["TARGET_ARCH"] = None if env["bits"] != "default": env["TARGET_ARCH"] = {"32": "x86", "64": "x86_64"}[env["bits"]] - if env.has_key("msvc_version"): + if "msvc_version" in env: env["MSVC_VERSION"] = env["msvc_version"] env.Tool("msvc") env.Tool("mssdk") # we want the MS SDK @@ -171,7 +171,6 @@ def setup_mingw(env): """Set up env for use with mingw""" # Nothing to do here print("Using MinGW") - pass def configure_msvc(env, manual_msvc_config): diff --git a/platform/windows/display_server_windows.cpp b/platform/windows/display_server_windows.cpp index 4f64809abc..e78b23c509 100644 --- a/platform/windows/display_server_windows.cpp +++ b/platform/windows/display_server_windows.cpp @@ -79,10 +79,6 @@ String DisplayServerWindows::get_name() const { return "Windows"; } -void DisplayServerWindows::alert(const String &p_alert, const String &p_title) { - MessageBoxW(nullptr, (LPCWSTR)(p_alert.utf16().get_data()), (LPCWSTR)(p_title.utf16().get_data()), MB_OK | MB_ICONEXCLAMATION | MB_TASKMODAL); -} - void DisplayServerWindows::_set_mouse_mode_impl(MouseMode p_mode) { if (p_mode == MOUSE_MODE_CAPTURED || p_mode == MOUSE_MODE_CONFINED || p_mode == MOUSE_MODE_CONFINED_HIDDEN) { // Mouse is grabbed (captured or confined). @@ -3358,8 +3354,8 @@ Vector<String> DisplayServerWindows::get_rendering_drivers_func() { DisplayServer *DisplayServerWindows::create_func(const String &p_rendering_driver, WindowMode p_mode, VSyncMode p_vsync_mode, uint32_t p_flags, const Vector2i &p_resolution, Error &r_error) { DisplayServer *ds = memnew(DisplayServerWindows(p_rendering_driver, p_mode, p_vsync_mode, p_flags, p_resolution, r_error)); if (r_error != OK) { - ds->alert("Your video card driver does not support any of the supported Vulkan versions.\n" - "Please update your drivers or if you have a very old or integrated GPU upgrade it.", + OS::get_singleton()->alert("Your video card driver does not support any of the supported Vulkan versions.\n" + "Please update your drivers or if you have a very old or integrated GPU upgrade it.", "Unable to initialize Video driver"); } return ds; diff --git a/platform/windows/display_server_windows.h b/platform/windows/display_server_windows.h index 394bed79b0..06014fbabe 100644 --- a/platform/windows/display_server_windows.h +++ b/platform/windows/display_server_windows.h @@ -439,129 +439,127 @@ class DisplayServerWindows : public DisplayServer { public: LRESULT WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam); - virtual bool has_feature(Feature p_feature) const; - virtual String get_name() const; + virtual bool has_feature(Feature p_feature) const override; + virtual String get_name() const override; - virtual void alert(const String &p_alert, const String &p_title = "ALERT!"); + virtual void mouse_set_mode(MouseMode p_mode) override; + virtual MouseMode mouse_get_mode() const override; - virtual void mouse_set_mode(MouseMode p_mode); - virtual MouseMode mouse_get_mode() const; + virtual void mouse_warp_to_position(const Point2i &p_to) override; + virtual Point2i mouse_get_position() const override; + virtual MouseButton mouse_get_button_state() const override; - virtual void mouse_warp_to_position(const Point2i &p_to); - virtual Point2i mouse_get_position() const; - virtual MouseButton mouse_get_button_state() const; + virtual void clipboard_set(const String &p_text) override; + virtual String clipboard_get() const override; - virtual void clipboard_set(const String &p_text); - virtual String clipboard_get() const; + virtual int get_screen_count() const override; + virtual Point2i screen_get_position(int p_screen = SCREEN_OF_MAIN_WINDOW) const override; + virtual Size2i screen_get_size(int p_screen = SCREEN_OF_MAIN_WINDOW) const override; + virtual Rect2i screen_get_usable_rect(int p_screen = SCREEN_OF_MAIN_WINDOW) const override; + virtual int screen_get_dpi(int p_screen = SCREEN_OF_MAIN_WINDOW) const override; + virtual bool screen_is_touchscreen(int p_screen = SCREEN_OF_MAIN_WINDOW) const override; - virtual int get_screen_count() const; - virtual Point2i screen_get_position(int p_screen = SCREEN_OF_MAIN_WINDOW) const; - virtual Size2i screen_get_size(int p_screen = SCREEN_OF_MAIN_WINDOW) const; - virtual Rect2i screen_get_usable_rect(int p_screen = SCREEN_OF_MAIN_WINDOW) const; - virtual int screen_get_dpi(int p_screen = SCREEN_OF_MAIN_WINDOW) const; - virtual bool screen_is_touchscreen(int p_screen = SCREEN_OF_MAIN_WINDOW) const; - - virtual void screen_set_orientation(ScreenOrientation p_orientation, int p_screen = SCREEN_OF_MAIN_WINDOW); + virtual void screen_set_orientation(ScreenOrientation p_orientation, int p_screen = SCREEN_OF_MAIN_WINDOW) override; ScreenOrientation screen_get_orientation(int p_screen = SCREEN_OF_MAIN_WINDOW) const; - virtual void screen_set_keep_on(bool p_enable); //disable screensaver - virtual bool screen_is_kept_on() const; + virtual void screen_set_keep_on(bool p_enable) override; //disable screensaver + virtual bool screen_is_kept_on() const override; - virtual Vector<DisplayServer::WindowID> get_window_list() const; + virtual Vector<DisplayServer::WindowID> get_window_list() const override; - virtual WindowID create_sub_window(WindowMode p_mode, VSyncMode p_vsync_mode, uint32_t p_flags, const Rect2i &p_rect = Rect2i()); - virtual void show_window(WindowID p_window); - virtual void delete_sub_window(WindowID p_window); + virtual WindowID create_sub_window(WindowMode p_mode, VSyncMode p_vsync_mode, uint32_t p_flags, const Rect2i &p_rect = Rect2i()) override; + virtual void show_window(WindowID p_window) override; + virtual void delete_sub_window(WindowID p_window) override; - virtual WindowID get_window_at_screen_position(const Point2i &p_position) const; + virtual WindowID get_window_at_screen_position(const Point2i &p_position) const override; - virtual void window_attach_instance_id(ObjectID p_instance, WindowID p_window = MAIN_WINDOW_ID); - virtual ObjectID window_get_attached_instance_id(WindowID p_window = MAIN_WINDOW_ID) const; + virtual void window_attach_instance_id(ObjectID p_instance, WindowID p_window = MAIN_WINDOW_ID) override; + virtual ObjectID window_get_attached_instance_id(WindowID p_window = MAIN_WINDOW_ID) const override; - virtual void window_set_rect_changed_callback(const Callable &p_callable, WindowID p_window = MAIN_WINDOW_ID); + virtual void window_set_rect_changed_callback(const Callable &p_callable, WindowID p_window = MAIN_WINDOW_ID) override; - virtual void window_set_window_event_callback(const Callable &p_callable, WindowID p_window = MAIN_WINDOW_ID); - virtual void window_set_input_event_callback(const Callable &p_callable, WindowID p_window = MAIN_WINDOW_ID); - virtual void window_set_input_text_callback(const Callable &p_callable, WindowID p_window = MAIN_WINDOW_ID); + virtual void window_set_window_event_callback(const Callable &p_callable, WindowID p_window = MAIN_WINDOW_ID) override; + virtual void window_set_input_event_callback(const Callable &p_callable, WindowID p_window = MAIN_WINDOW_ID) override; + virtual void window_set_input_text_callback(const Callable &p_callable, WindowID p_window = MAIN_WINDOW_ID) override; - virtual void window_set_drop_files_callback(const Callable &p_callable, WindowID p_window = MAIN_WINDOW_ID); + virtual void window_set_drop_files_callback(const Callable &p_callable, WindowID p_window = MAIN_WINDOW_ID) override; - virtual void window_set_title(const String &p_title, WindowID p_window = MAIN_WINDOW_ID); - virtual void window_set_mouse_passthrough(const Vector<Vector2> &p_region, WindowID p_window = MAIN_WINDOW_ID); + virtual void window_set_title(const String &p_title, WindowID p_window = MAIN_WINDOW_ID) override; + virtual void window_set_mouse_passthrough(const Vector<Vector2> &p_region, WindowID p_window = MAIN_WINDOW_ID) override; - virtual int window_get_current_screen(WindowID p_window = MAIN_WINDOW_ID) const; - virtual void window_set_current_screen(int p_screen, WindowID p_window = MAIN_WINDOW_ID); + virtual int window_get_current_screen(WindowID p_window = MAIN_WINDOW_ID) const override; + virtual void window_set_current_screen(int p_screen, WindowID p_window = MAIN_WINDOW_ID) override; - virtual Point2i window_get_position(WindowID p_window = MAIN_WINDOW_ID) const; - virtual void window_set_position(const Point2i &p_position, WindowID p_window = MAIN_WINDOW_ID); + virtual Point2i window_get_position(WindowID p_window = MAIN_WINDOW_ID) const override; + virtual void window_set_position(const Point2i &p_position, WindowID p_window = MAIN_WINDOW_ID) override; - virtual void window_set_transient(WindowID p_window, WindowID p_parent); + virtual void window_set_transient(WindowID p_window, WindowID p_parent) override; - virtual void window_set_max_size(const Size2i p_size, WindowID p_window = MAIN_WINDOW_ID); - virtual Size2i window_get_max_size(WindowID p_window = MAIN_WINDOW_ID) const; + virtual void window_set_max_size(const Size2i p_size, WindowID p_window = MAIN_WINDOW_ID) override; + virtual Size2i window_get_max_size(WindowID p_window = MAIN_WINDOW_ID) const override; - virtual void window_set_min_size(const Size2i p_size, WindowID p_window = MAIN_WINDOW_ID); - virtual Size2i window_get_min_size(WindowID p_window = MAIN_WINDOW_ID) const; + virtual void window_set_min_size(const Size2i p_size, WindowID p_window = MAIN_WINDOW_ID) override; + virtual Size2i window_get_min_size(WindowID p_window = MAIN_WINDOW_ID) const override; - virtual void window_set_size(const Size2i p_size, WindowID p_window = MAIN_WINDOW_ID); - virtual Size2i window_get_size(WindowID p_window = MAIN_WINDOW_ID) const; - virtual Size2i window_get_real_size(WindowID p_window = MAIN_WINDOW_ID) const; //wtf is this? should probable use proper name + virtual void window_set_size(const Size2i p_size, WindowID p_window = MAIN_WINDOW_ID) override; + virtual Size2i window_get_size(WindowID p_window = MAIN_WINDOW_ID) const override; + virtual Size2i window_get_real_size(WindowID p_window = MAIN_WINDOW_ID) const override; //wtf is this? should probable use proper name - virtual void window_set_mode(WindowMode p_mode, WindowID p_window = MAIN_WINDOW_ID); - virtual WindowMode window_get_mode(WindowID p_window = MAIN_WINDOW_ID) const; + virtual void window_set_mode(WindowMode p_mode, WindowID p_window = MAIN_WINDOW_ID) override; + virtual WindowMode window_get_mode(WindowID p_window = MAIN_WINDOW_ID) const override; - virtual bool window_is_maximize_allowed(WindowID p_window = MAIN_WINDOW_ID) const; + virtual bool window_is_maximize_allowed(WindowID p_window = MAIN_WINDOW_ID) const override; - virtual void window_set_flag(WindowFlags p_flag, bool p_enabled, WindowID p_window = MAIN_WINDOW_ID); - virtual bool window_get_flag(WindowFlags p_flag, WindowID p_window = MAIN_WINDOW_ID) const; + virtual void window_set_flag(WindowFlags p_flag, bool p_enabled, WindowID p_window = MAIN_WINDOW_ID) override; + virtual bool window_get_flag(WindowFlags p_flag, WindowID p_window = MAIN_WINDOW_ID) const override; - virtual void window_request_attention(WindowID p_window = MAIN_WINDOW_ID); - virtual void window_move_to_foreground(WindowID p_window = MAIN_WINDOW_ID); + virtual void window_request_attention(WindowID p_window = MAIN_WINDOW_ID) override; + virtual void window_move_to_foreground(WindowID p_window = MAIN_WINDOW_ID) override; - virtual bool window_can_draw(WindowID p_window = MAIN_WINDOW_ID) const; + virtual bool window_can_draw(WindowID p_window = MAIN_WINDOW_ID) const override; - virtual bool can_any_window_draw() const; + virtual bool can_any_window_draw() const override; - virtual void window_set_ime_active(const bool p_active, WindowID p_window = MAIN_WINDOW_ID); - virtual void window_set_ime_position(const Point2i &p_pos, WindowID p_window = MAIN_WINDOW_ID); + virtual void window_set_ime_active(const bool p_active, WindowID p_window = MAIN_WINDOW_ID) override; + virtual void window_set_ime_position(const Point2i &p_pos, WindowID p_window = MAIN_WINDOW_ID) override; virtual void window_set_vsync_mode(DisplayServer::VSyncMode p_vsync_mode, WindowID p_window = MAIN_WINDOW_ID) override; virtual DisplayServer::VSyncMode window_get_vsync_mode(WindowID p_vsync_mode) const override; - virtual void console_set_visible(bool p_enabled); - virtual bool is_console_visible() const; + virtual void console_set_visible(bool p_enabled) override; + virtual bool is_console_visible() const override; - virtual void cursor_set_shape(CursorShape p_shape); - virtual CursorShape cursor_get_shape() const; - virtual void cursor_set_custom_image(const RES &p_cursor, CursorShape p_shape = CURSOR_ARROW, const Vector2 &p_hotspot = Vector2()); + virtual void cursor_set_shape(CursorShape p_shape) override; + virtual CursorShape cursor_get_shape() const override; + virtual void cursor_set_custom_image(const RES &p_cursor, CursorShape p_shape = CURSOR_ARROW, const Vector2 &p_hotspot = Vector2()) override; - virtual bool get_swap_cancel_ok(); + virtual bool get_swap_cancel_ok() override; - virtual void enable_for_stealing_focus(OS::ProcessID pid); + virtual void enable_for_stealing_focus(OS::ProcessID pid) override; - virtual int keyboard_get_layout_count() const; - virtual int keyboard_get_current_layout() const; - virtual void keyboard_set_current_layout(int p_index); - virtual String keyboard_get_layout_language(int p_index) const; - virtual String keyboard_get_layout_name(int p_index) const; + virtual int keyboard_get_layout_count() const override; + virtual int keyboard_get_current_layout() const override; + virtual void keyboard_set_current_layout(int p_index) override; + virtual String keyboard_get_layout_language(int p_index) const override; + virtual String keyboard_get_layout_name(int p_index) const override; - virtual int tablet_get_driver_count() const; - virtual String tablet_get_driver_name(int p_driver) const; - virtual String tablet_get_current_driver() const; - virtual void tablet_set_current_driver(const String &p_driver); + virtual int tablet_get_driver_count() const override; + virtual String tablet_get_driver_name(int p_driver) const override; + virtual String tablet_get_current_driver() const override; + virtual void tablet_set_current_driver(const String &p_driver) override; - virtual void process_events(); + virtual void process_events() override; - virtual void force_process_and_drop_events(); + virtual void force_process_and_drop_events() override; - virtual void release_rendering_thread(); - virtual void make_rendering_thread(); - virtual void swap_buffers(); + virtual void release_rendering_thread() override; + virtual void make_rendering_thread() override; + virtual void swap_buffers() override; - virtual void set_native_icon(const String &p_filename); - virtual void set_icon(const Ref<Image> &p_icon); + virtual void set_native_icon(const String &p_filename) override; + virtual void set_icon(const Ref<Image> &p_icon) override; - virtual void set_context(Context p_context); + virtual void set_context(Context p_context) override; static DisplayServer *create_func(const String &p_rendering_driver, WindowMode p_mode, VSyncMode p_vsync_mode, uint32_t p_flags, const Vector2i &p_resolution, Error &r_error); static Vector<String> get_rendering_drivers_func(); diff --git a/platform/windows/os_windows.cpp b/platform/windows/os_windows.cpp index 56d673afc3..2c8afaf7de 100644 --- a/platform/windows/os_windows.cpp +++ b/platform/windows/os_windows.cpp @@ -165,6 +165,10 @@ BOOL WINAPI HandlerRoutine(_In_ DWORD dwCtrlType) { } } +void OS_Windows::alert(const String &p_alert, const String &p_title) { + MessageBoxW(nullptr, (LPCWSTR)(p_alert.utf16().get_data()), (LPCWSTR)(p_title.utf16().get_data()), MB_OK | MB_ICONEXCLAMATION | MB_TASKMODAL); +} + void OS_Windows::initialize_debugging() { SetConsoleCtrlHandler(HandlerRoutine, TRUE); } @@ -407,8 +411,8 @@ String OS_Windows::_quote_command_line_argument(const String &p_text) const { Error OS_Windows::execute(const String &p_path, const List<String> &p_arguments, String *r_pipe, int *r_exitcode, bool read_stderr, Mutex *p_pipe_mutex) { String path = p_path.replace("/", "\\"); String command = _quote_command_line_argument(path); - for (const List<String>::Element *E = p_arguments.front(); E; E = E->next()) { - command += " " + _quote_command_line_argument(E->get()); + for (const String &E : p_arguments) { + command += " " + _quote_command_line_argument(E); } if (r_pipe) { @@ -463,8 +467,8 @@ Error OS_Windows::execute(const String &p_path, const List<String> &p_arguments, Error OS_Windows::create_process(const String &p_path, const List<String> &p_arguments, ProcessID *r_child_id) { String path = p_path.replace("/", "\\"); String command = _quote_command_line_argument(path); - for (const List<String>::Element *E = p_arguments.front(); E; E = E->next()) { - command += " " + _quote_command_line_argument(E->get()); + for (const String &E : p_arguments) { + command += " " + _quote_command_line_argument(E); } ProcessInfo pi; diff --git a/platform/windows/os_windows.h b/platform/windows/os_windows.h index 8f9ef254f1..ea0c263b78 100644 --- a/platform/windows/os_windows.h +++ b/platform/windows/os_windows.h @@ -108,6 +108,8 @@ protected: Map<ProcessID, ProcessInfo> *process_map; public: + virtual void alert(const String &p_alert, const String &p_title = "ALERT!") override; + virtual Error open_dynamic_library(const String p_path, void *&p_library_handle, bool p_also_set_library_path = false) override; virtual Error close_dynamic_library(void *p_library_handle) override; virtual Error get_dynamic_library_symbol_handle(void *p_library_handle, const String p_name, void *&p_symbol_handle, bool p_optional = false) override; diff --git a/scene/2d/animated_sprite_2d.cpp b/scene/2d/animated_sprite_2d.cpp index 9ee37670d1..da2ab6ada8 100644 --- a/scene/2d/animated_sprite_2d.cpp +++ b/scene/2d/animated_sprite_2d.cpp @@ -123,7 +123,7 @@ void AnimatedSprite2D::_validate_property(PropertyInfo &property) const { } property.hint_string += String(E->get()); - if (animation == E->get()) { + if (animation == E) { current_found = true; } } diff --git a/scene/2d/audio_stream_player_2d.cpp b/scene/2d/audio_stream_player_2d.cpp index 860ccfec64..4b96689613 100644 --- a/scene/2d/audio_stream_player_2d.cpp +++ b/scene/2d/audio_stream_player_2d.cpp @@ -255,7 +255,7 @@ void AudioStreamPlayer2D::_notification(int p_what) { //stop playing if no longer active if (!active.is_set()) { set_physics_process_internal(false); - emit_signal("finished"); + emit_signal(SNAME("finished")); } } } diff --git a/scene/2d/camera_2d.cpp b/scene/2d/camera_2d.cpp index f293081987..2219437c14 100644 --- a/scene/2d/camera_2d.cpp +++ b/scene/2d/camera_2d.cpp @@ -241,6 +241,10 @@ void Camera2D::_notification(int p_what) { viewport = get_viewport(); } + if (is_current()) { + viewport->_camera_2d_set(this); + } + canvas = get_canvas(); RID vp = viewport->get_viewport_rid(); @@ -259,6 +263,7 @@ void Camera2D::_notification(int p_what) { if (is_current()) { if (viewport && !(custom_viewport && !ObjectDB::get_instance(custom_viewport_id))) { viewport->set_canvas_transform(Transform2D()); + clear_current(); } } remove_from_group(group_name); @@ -392,18 +397,29 @@ Camera2D::Camera2DProcessCallback Camera2D::get_process_callback() const { void Camera2D::_make_current(Object *p_which) { if (p_which == this) { current = true; + if (is_inside_tree()) { + get_viewport()->_camera_2d_set(this); + update(); + } } else { current = false; + if (is_inside_tree()) { + if (get_viewport()->get_camera_2d() == this) { + get_viewport()->_camera_2d_set(nullptr); + } + update(); + } } } -void Camera2D::_set_current(bool p_current) { +void Camera2D::set_current(bool p_current) { if (p_current) { make_current(); + } else { + if (current) { + clear_current(); + } } - - current = p_current; - update(); } bool Camera2D::is_current() const { @@ -411,18 +427,19 @@ bool Camera2D::is_current() const { } void Camera2D::make_current() { - if (!is_inside_tree()) { - current = true; - } else { + if (is_inside_tree()) { get_tree()->call_group_flags(SceneTree::GROUP_CALL_REALTIME, group_name, "_make_current", this); + } else { + current = true; } _update_scroll(); } void Camera2D::clear_current() { - current = false; if (is_inside_tree()) { get_tree()->call_group_flags(SceneTree::GROUP_CALL_REALTIME, group_name, "_make_current", (Object *)nullptr); + } else { + current = false; } } @@ -466,8 +483,8 @@ void Camera2D::force_update_scroll() { } void Camera2D::reset_smoothing() { - smoothed_camera_pos = camera_pos; _update_scroll(); + smoothed_camera_pos = camera_pos; } void Camera2D::align() { @@ -659,17 +676,14 @@ void Camera2D::_bind_methods() { ClassDB::bind_method(D_METHOD("set_rotating", "rotating"), &Camera2D::set_rotating); ClassDB::bind_method(D_METHOD("is_rotating"), &Camera2D::is_rotating); - ClassDB::bind_method(D_METHOD("make_current"), &Camera2D::make_current); - ClassDB::bind_method(D_METHOD("clear_current"), &Camera2D::clear_current); - ClassDB::bind_method(D_METHOD("_make_current"), &Camera2D::_make_current); - ClassDB::bind_method(D_METHOD("_update_scroll"), &Camera2D::_update_scroll); ClassDB::bind_method(D_METHOD("set_process_callback", "mode"), &Camera2D::set_process_callback); ClassDB::bind_method(D_METHOD("get_process_callback"), &Camera2D::get_process_callback); - ClassDB::bind_method(D_METHOD("_set_current", "current"), &Camera2D::_set_current); + ClassDB::bind_method(D_METHOD("set_current", "current"), &Camera2D::set_current); ClassDB::bind_method(D_METHOD("is_current"), &Camera2D::is_current); + ClassDB::bind_method(D_METHOD("_make_current"), &Camera2D::_make_current); ClassDB::bind_method(D_METHOD("set_limit", "margin", "limit"), &Camera2D::set_limit); ClassDB::bind_method(D_METHOD("get_limit", "margin"), &Camera2D::get_limit); @@ -725,7 +739,7 @@ void Camera2D::_bind_methods() { ADD_PROPERTY(PropertyInfo(Variant::VECTOR2, "offset"), "set_offset", "get_offset"); ADD_PROPERTY(PropertyInfo(Variant::INT, "anchor_mode", PROPERTY_HINT_ENUM, "Fixed TopLeft,Drag Center"), "set_anchor_mode", "get_anchor_mode"); ADD_PROPERTY(PropertyInfo(Variant::BOOL, "rotating"), "set_rotating", "is_rotating"); - ADD_PROPERTY(PropertyInfo(Variant::BOOL, "current"), "_set_current", "is_current"); + ADD_PROPERTY(PropertyInfo(Variant::BOOL, "current"), "set_current", "is_current"); ADD_PROPERTY(PropertyInfo(Variant::VECTOR2, "zoom"), "set_zoom", "get_zoom"); ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "custom_viewport", PROPERTY_HINT_RESOURCE_TYPE, "Viewport", PROPERTY_USAGE_NONE), "set_custom_viewport", "get_custom_viewport"); ADD_PROPERTY(PropertyInfo(Variant::INT, "process_callback", PROPERTY_HINT_ENUM, "Physics,Idle"), "set_process_callback", "get_process_callback"); diff --git a/scene/2d/camera_2d.h b/scene/2d/camera_2d.h index 7494e526cc..95b49cf076 100644 --- a/scene/2d/camera_2d.h +++ b/scene/2d/camera_2d.h @@ -83,7 +83,7 @@ protected: void _update_scroll(); void _make_current(Object *p_which); - void _set_current(bool p_current); + void set_current(bool p_current); void _set_old_smoothing(real_t p_enable); diff --git a/scene/2d/collision_object_2d.cpp b/scene/2d/collision_object_2d.cpp index 93d154bb01..3ba3a4eec5 100644 --- a/scene/2d/collision_object_2d.cpp +++ b/scene/2d/collision_object_2d.cpp @@ -498,6 +498,20 @@ void CollisionObject2D::_mouse_exit() { emit_signal(SceneStringNames::get_singleton()->mouse_exited); } +void CollisionObject2D::_mouse_shape_enter(int p_shape) { + if (get_script_instance()) { + get_script_instance()->call(SceneStringNames::get_singleton()->_mouse_shape_enter, p_shape); + } + emit_signal(SceneStringNames::get_singleton()->mouse_shape_entered, p_shape); +} + +void CollisionObject2D::_mouse_shape_exit(int p_shape) { + if (get_script_instance()) { + get_script_instance()->call(SceneStringNames::get_singleton()->_mouse_shape_exit, p_shape); + } + emit_signal(SceneStringNames::get_singleton()->mouse_shape_exited, p_shape); +} + void CollisionObject2D::set_only_update_transform_changes(bool p_enable) { only_update_transform_changes = p_enable; } @@ -584,6 +598,8 @@ void CollisionObject2D::_bind_methods() { ADD_SIGNAL(MethodInfo("input_event", PropertyInfo(Variant::OBJECT, "viewport", PROPERTY_HINT_RESOURCE_TYPE, "Node"), PropertyInfo(Variant::OBJECT, "event", PROPERTY_HINT_RESOURCE_TYPE, "InputEvent"), PropertyInfo(Variant::INT, "shape_idx"))); ADD_SIGNAL(MethodInfo("mouse_entered")); ADD_SIGNAL(MethodInfo("mouse_exited")); + ADD_SIGNAL(MethodInfo("mouse_shape_entered", PropertyInfo(Variant::INT, "shape_idx"))); + ADD_SIGNAL(MethodInfo("mouse_shape_exited", PropertyInfo(Variant::INT, "shape_idx"))); ADD_PROPERTY(PropertyInfo(Variant::INT, "disable_mode", PROPERTY_HINT_ENUM, "Remove,MakeStatic,KeepActive"), "set_disable_mode", "get_disable_mode"); diff --git a/scene/2d/collision_object_2d.h b/scene/2d/collision_object_2d.h index 7a71affbb5..eca53eecfc 100644 --- a/scene/2d/collision_object_2d.h +++ b/scene/2d/collision_object_2d.h @@ -75,7 +75,7 @@ private: int total_subshapes = 0; Map<uint32_t, ShapeData> shapes; - bool only_update_transform_changes = false; //this is used for sync physics in CharacterBody2D + bool only_update_transform_changes = false; // This is used for sync to physics. void _apply_disabled(); void _apply_enabled(); @@ -92,6 +92,9 @@ protected: void _mouse_enter(); void _mouse_exit(); + void _mouse_shape_enter(int p_shape); + void _mouse_shape_exit(int p_shape); + void set_only_update_transform_changes(bool p_enable); bool is_only_update_transform_changes_enabled() const; diff --git a/scene/2d/cpu_particles_2d.cpp b/scene/2d/cpu_particles_2d.cpp index 24f3301ce1..a341ba69ac 100644 --- a/scene/2d/cpu_particles_2d.cpp +++ b/scene/2d/cpu_particles_2d.cpp @@ -463,10 +463,6 @@ Vector2 CPUParticles2D::get_gravity() const { } void CPUParticles2D::_validate_property(PropertyInfo &property) const { - if (property.name == "color" && color_ramp.is_valid()) { - property.usage = PROPERTY_USAGE_NONE; - } - if (property.name == "emission_sphere_radius" && emission_shape != EMISSION_SHAPE_SPHERE) { property.usage = PROPERTY_USAGE_NONE; } diff --git a/scene/2d/navigation_agent_2d.cpp b/scene/2d/navigation_agent_2d.cpp index f9cbdbf377..e9a95b680c 100644 --- a/scene/2d/navigation_agent_2d.cpp +++ b/scene/2d/navigation_agent_2d.cpp @@ -235,7 +235,7 @@ void NavigationAgent2D::_avoidance_done(Vector3 p_new_velocity) { } velocity_submitted = false; - emit_signal("velocity_computed", velocity); + emit_signal(SNAME("velocity_computed"), velocity); } TypedArray<String> NavigationAgent2D::get_configuration_warnings() const { @@ -287,7 +287,7 @@ void NavigationAgent2D::update_navigation() { navigation_path = NavigationServer2D::get_singleton()->map_get_path(agent_parent->get_world_2d()->get_navigation_map(), o, target_location, true, navigable_layers); navigation_finished = false; nav_path_index = 0; - emit_signal("path_changed"); + emit_signal(SNAME("path_changed")); } if (navigation_path.size() == 0) { @@ -303,7 +303,7 @@ void NavigationAgent2D::update_navigation() { _check_distance_to_target(); nav_path_index -= 1; navigation_finished = true; - emit_signal("navigation_finished"); + emit_signal(SNAME("navigation_finished")); break; } } @@ -313,7 +313,7 @@ void NavigationAgent2D::update_navigation() { void NavigationAgent2D::_check_distance_to_target() { if (!target_reached) { if (distance_to_target() < target_desired_distance) { - emit_signal("target_reached"); + emit_signal(SNAME("target_reached")); target_reached = true; } } diff --git a/scene/2d/physics_body_2d.cpp b/scene/2d/physics_body_2d.cpp index be619ed60d..9b4da2a77a 100644 --- a/scene/2d/physics_body_2d.cpp +++ b/scene/2d/physics_body_2d.cpp @@ -76,21 +76,21 @@ Ref<KinematicCollision2D> PhysicsBody2D::_move(const Vector2 &p_motion, bool p_i return Ref<KinematicCollision2D>(); } -bool PhysicsBody2D::move_and_collide(const Vector2 &p_motion, bool p_infinite_inertia, PhysicsServer2D::MotionResult &r_result, real_t p_margin, bool p_exclude_raycast_shapes, bool p_test_only, bool p_cancel_sliding) { +bool PhysicsBody2D::move_and_collide(const Vector2 &p_motion, bool p_infinite_inertia, PhysicsServer2D::MotionResult &r_result, real_t p_margin, bool p_exclude_raycast_shapes, bool p_test_only, bool p_cancel_sliding, const Set<RID> &p_exclude) { if (is_only_update_transform_changes_enabled()) { ERR_PRINT("Move functions do not work together with 'sync to physics' option. Please read the documentation."); } Transform2D gt = get_global_transform(); - bool colliding = PhysicsServer2D::get_singleton()->body_test_motion(get_rid(), gt, p_motion, p_infinite_inertia, p_margin, &r_result, p_exclude_raycast_shapes); + bool colliding = PhysicsServer2D::get_singleton()->body_test_motion(get_rid(), gt, p_motion, p_infinite_inertia, p_margin, &r_result, p_exclude_raycast_shapes, p_exclude); // Restore direction of motion to be along original motion, // in order to avoid sliding due to recovery, // but only if collision depth is low enough to avoid tunneling. - real_t motion_length = p_motion.length(); - if (motion_length > CMP_EPSILON) { + if (p_cancel_sliding) { + real_t motion_length = p_motion.length(); real_t precision = 0.001; - if (colliding && p_cancel_sliding) { + if (colliding) { // Can't just use margin as a threshold because collision depth is calculated on unsafe motion, // so even in normal resting cases the depth can be a bit more than the margin. precision += motion_length * (r_result.collision_unsafe_fraction - r_result.collision_safe_fraction); @@ -101,16 +101,21 @@ bool PhysicsBody2D::move_and_collide(const Vector2 &p_motion, bool p_infinite_in } if (p_cancel_sliding) { + // When motion is null, recovery is the resulting motion. + Vector2 motion_normal; + if (motion_length > CMP_EPSILON) { + motion_normal = p_motion / motion_length; + } + // Check depth of recovery. - Vector2 motion_normal = p_motion / motion_length; - real_t dot = r_result.motion.dot(motion_normal); - Vector2 recovery = r_result.motion - motion_normal * dot; + real_t projected_length = r_result.motion.dot(motion_normal); + Vector2 recovery = r_result.motion - motion_normal * projected_length; real_t recovery_length = recovery.length(); // Fixes cases where canceling slide causes the motion to go too deep into the ground, - // Becauses we're only taking rest information into account and not general recovery. + // because we're only taking rest information into account and not general recovery. if (recovery_length < (real_t)p_margin + precision) { // Apply adjustment to motion. - r_result.motion = motion_normal * dot; + r_result.motion = motion_normal * projected_length; r_result.remainder = p_motion - r_result.motion; } } @@ -140,8 +145,7 @@ TypedArray<PhysicsBody2D> PhysicsBody2D::get_collision_exceptions() { List<RID> exceptions; PhysicsServer2D::get_singleton()->body_get_collision_exceptions(get_rid(), &exceptions); Array ret; - for (List<RID>::Element *E = exceptions.front(); E; E = E->next()) { - RID body = E->get(); + for (const RID &body : exceptions) { ObjectID instance_id = PhysicsServer2D::get_singleton()->body_get_object_instance_id(body); Object *obj = ObjectDB::get_instance(instance_id); PhysicsBody2D *physics_body = Object::cast_to<PhysicsBody2D>(obj); @@ -224,6 +228,13 @@ void StaticBody2D::set_kinematic_motion_enabled(bool p_enabled) { set_body_mode(PhysicsServer2D::BODY_MODE_STATIC); } +#ifdef TOOLS_ENABLED + if (Engine::get_singleton()->is_editor_hint()) { + update_configuration_warnings(); + return; + } +#endif + _update_kinematic_motion(); } @@ -231,8 +242,75 @@ bool StaticBody2D::is_kinematic_motion_enabled() const { return kinematic_motion; } +void StaticBody2D::set_sync_to_physics(bool p_enable) { + if (sync_to_physics == p_enable) { + return; + } + + sync_to_physics = p_enable; + +#ifdef TOOLS_ENABLED + if (Engine::get_singleton()->is_editor_hint()) { + update_configuration_warnings(); + return; + } +#endif + + if (kinematic_motion) { + _update_kinematic_motion(); + } +} + +bool StaticBody2D::is_sync_to_physics_enabled() const { + return sync_to_physics; +} + +void StaticBody2D::_direct_state_changed(Object *p_state) { + if (!sync_to_physics) { + return; + } + + PhysicsDirectBodyState2D *state = Object::cast_to<PhysicsDirectBodyState2D>(p_state); + ERR_FAIL_NULL_MSG(state, "Method '_direct_state_changed' must receive a valid PhysicsDirectBodyState2D object as argument"); + + last_valid_transform = state->get_transform(); + set_notify_local_transform(false); + set_global_transform(last_valid_transform); + set_notify_local_transform(true); +} + +TypedArray<String> StaticBody2D::get_configuration_warnings() const { + TypedArray<String> warnings = PhysicsBody2D::get_configuration_warnings(); + + if (sync_to_physics && !kinematic_motion) { + warnings.push_back(TTR("Sync to physics works only when kinematic motion is enabled.")); + } + + return warnings; +} + void StaticBody2D::_notification(int p_what) { switch (p_what) { + case NOTIFICATION_ENTER_TREE: { + last_valid_transform = get_global_transform(); + } break; + + case NOTIFICATION_LOCAL_TRANSFORM_CHANGED: { + // Used by sync to physics, send the new transform to the physics... + Transform2D new_transform = get_global_transform(); + + real_t delta_time = get_physics_process_delta_time(); + new_transform.translate(constant_linear_velocity * delta_time); + new_transform.set_rotation(new_transform.get_rotation() + constant_angular_velocity * delta_time); + + PhysicsServer2D::get_singleton()->body_set_state(get_rid(), PhysicsServer2D::BODY_STATE_TRANSFORM, new_transform); + + // ... but then revert changes. + set_notify_local_transform(false); + set_global_transform(last_valid_transform); + set_notify_local_transform(true); + } break; + case NOTIFICATION_INTERNAL_PHYSICS_PROCESS: { #ifdef TOOLS_ENABLED if (Engine::get_singleton()->is_editor_hint()) { @@ -242,19 +320,23 @@ void StaticBody2D::_notification(int p_what) { ERR_FAIL_COND(!kinematic_motion); - real_t delta_time = get_physics_process_delta_time(); - Transform2D new_transform = get_global_transform(); + real_t delta_time = get_physics_process_delta_time(); new_transform.translate(constant_linear_velocity * delta_time); new_transform.set_rotation(new_transform.get_rotation() + constant_angular_velocity * delta_time); - PhysicsServer2D::get_singleton()->body_set_state(get_rid(), PhysicsServer2D::BODY_STATE_TRANSFORM, new_transform); + if (sync_to_physics) { + // Propagate transform change to node. + set_global_transform(new_transform); + } else { + PhysicsServer2D::get_singleton()->body_set_state(get_rid(), PhysicsServer2D::BODY_STATE_TRANSFORM, new_transform); - // Propagate transform change to node. - set_block_transform_notify(true); - set_global_transform(new_transform); - set_block_transform_notify(false); + // Propagate transform change to node. + set_block_transform_notify(true); + set_global_transform(new_transform); + set_block_transform_notify(false); + } } break; } } @@ -271,10 +353,14 @@ void StaticBody2D::_bind_methods() { ClassDB::bind_method(D_METHOD("set_physics_material_override", "physics_material_override"), &StaticBody2D::set_physics_material_override); ClassDB::bind_method(D_METHOD("get_physics_material_override"), &StaticBody2D::get_physics_material_override); + ClassDB::bind_method(D_METHOD("set_sync_to_physics", "enable"), &StaticBody2D::set_sync_to_physics); + ClassDB::bind_method(D_METHOD("is_sync_to_physics_enabled"), &StaticBody2D::is_sync_to_physics_enabled); + ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "physics_material_override", PROPERTY_HINT_RESOURCE_TYPE, "PhysicsMaterial"), "set_physics_material_override", "get_physics_material_override"); ADD_PROPERTY(PropertyInfo(Variant::VECTOR2, "constant_linear_velocity"), "set_constant_linear_velocity", "get_constant_linear_velocity"); ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "constant_angular_velocity"), "set_constant_angular_velocity", "get_constant_angular_velocity"); ADD_PROPERTY(PropertyInfo(Variant::BOOL, "kinematic_motion"), "set_kinematic_motion_enabled", "is_kinematic_motion_enabled"); + ADD_PROPERTY(PropertyInfo(Variant::BOOL, "sync_to_physics"), "set_sync_to_physics", "is_sync_to_physics_enabled"); } StaticBody2D::StaticBody2D() : @@ -298,14 +384,24 @@ void StaticBody2D::_update_kinematic_motion() { } #endif + if (kinematic_motion && sync_to_physics) { + PhysicsServer2D::get_singleton()->body_set_force_integration_callback(get_rid(), callable_mp(this, &StaticBody2D::_direct_state_changed)); + set_only_update_transform_changes(true); + set_notify_local_transform(true); + } else { + PhysicsServer2D::get_singleton()->body_set_force_integration_callback(get_rid(), Callable()); + set_only_update_transform_changes(false); + set_notify_local_transform(false); + } + + bool needs_physics_process = false; if (kinematic_motion) { if (!Math::is_zero_approx(constant_angular_velocity) || !constant_linear_velocity.is_equal_approx(Vector2())) { - set_physics_process_internal(true); - return; + needs_physics_process = true; } } - set_physics_process_internal(false); + set_physics_process_internal(needs_physics_process); } void RigidBody2D::_body_enter_tree(ObjectID p_id) { @@ -955,11 +1051,14 @@ void RigidBody2D::_reload_physics_characteristics() { void CharacterBody2D::move_and_slide() { Vector2 body_velocity_normal = linear_velocity.normalized(); - bool was_on_floor = on_floor; + // Hack in order to work with calling from _process as well as from _physics_process; calling from thread is risky + float delta = Engine::get_singleton()->is_in_physics_frame() ? get_physics_process_delta_time() : get_process_delta_time(); + Vector2 current_floor_velocity = floor_velocity; - if (on_floor && on_floor_body.is_valid()) { + + if ((on_floor || on_wall) && on_floor_body.is_valid()) { //this approach makes sure there is less delay between the actual body velocity and the one we saved PhysicsDirectBodyState2D *bs = PhysicsServer2D::get_singleton()->body_get_direct_state(on_floor_body); if (bs) { @@ -967,19 +1066,30 @@ void CharacterBody2D::move_and_slide() { } } - // Hack in order to work with calling from _process as well as from _physics_process; calling from thread is risky - Vector2 motion = (current_floor_velocity + linear_velocity) * (Engine::get_singleton()->is_in_physics_frame() ? get_physics_process_delta_time() : get_process_delta_time()); - + motion_results.clear(); on_floor = false; - on_floor_body = RID(); on_ceiling = false; on_wall = false; - motion_results.clear(); floor_normal = Vector2(); floor_velocity = Vector2(); - // No sliding on first attempt to keep floor motion stable when possible. - bool sliding_enabled = false; + if (current_floor_velocity != Vector2()) { + PhysicsServer2D::MotionResult floor_result; + Set<RID> exclude; + exclude.insert(on_floor_body); + if (move_and_collide(current_floor_velocity * delta, infinite_inertia, floor_result, true, false, false, false, exclude)) { + motion_results.push_back(floor_result); + _set_collision_direction(floor_result); + } + } + + on_floor_body = RID(); + Vector2 motion = linear_velocity * delta; + + // No sliding on first attempt to keep floor motion stable when possible, + // when stop on slope is enabled. + bool sliding_enabled = !stop_on_slope; + for (int iteration = 0; iteration < max_slides; ++iteration) { PhysicsServer2D::MotionResult result; bool found_collision = false; @@ -1003,31 +1113,19 @@ void CharacterBody2D::move_and_slide() { found_collision = true; motion_results.push_back(result); - - if (up_direction == Vector2()) { - //all is a wall - on_wall = true; - } else { - if (Math::acos(result.collision_normal.dot(up_direction)) <= floor_max_angle + FLOOR_ANGLE_THRESHOLD) { //floor - - on_floor = true; - floor_normal = result.collision_normal; - on_floor_body = result.collider; - floor_velocity = result.collider_velocity; - - if (stop_on_slope) { - if ((body_velocity_normal + up_direction).length() < 0.01) { - Transform2D gt = get_global_transform(); - gt.elements[2] -= result.motion.slide(up_direction); - set_global_transform(gt); - linear_velocity = Vector2(); - return; - } + _set_collision_direction(result); + + if (on_floor && stop_on_slope) { + if ((body_velocity_normal + up_direction).length() < 0.01) { + Transform2D gt = get_global_transform(); + if (result.motion.length() > margin) { + gt.elements[2] -= result.motion.slide(up_direction); + } else { + gt.elements[2] -= result.motion; } - } else if (Math::acos(result.collision_normal.dot(-up_direction)) <= floor_max_angle + FLOOR_ANGLE_THRESHOLD) { //ceiling - on_ceiling = true; - } else { - on_wall = true; + set_global_transform(gt); + linear_velocity = Vector2(); + return; } } @@ -1047,6 +1145,11 @@ void CharacterBody2D::move_and_slide() { } } + if (!on_floor && !on_wall) { + // Add last platform velocity when just left a moving platform. + linear_velocity += current_floor_velocity; + } + if (!was_on_floor || snap == Vector2()) { return; } @@ -1054,7 +1157,7 @@ void CharacterBody2D::move_and_slide() { // Apply snap. Transform2D gt = get_global_transform(); PhysicsServer2D::MotionResult result; - if (move_and_collide(snap, infinite_inertia, result, margin, false, true)) { + if (move_and_collide(snap, infinite_inertia, result, margin, false, true, false)) { bool apply = true; if (up_direction != Vector2()) { if (Math::acos(result.collision_normal.dot(up_direction)) <= floor_max_angle + FLOOR_ANGLE_THRESHOLD) { @@ -1065,9 +1168,12 @@ void CharacterBody2D::move_and_slide() { if (stop_on_slope) { // move and collide may stray the object a bit because of pre un-stucking, // so only ensure that motion happens on floor direction in this case. - result.motion = up_direction * up_direction.dot(result.motion); + if (result.motion.length() > margin) { + result.motion = up_direction * up_direction.dot(result.motion); + } else { + result.motion = Vector2(); + } } - } else { apply = false; } @@ -1080,6 +1186,26 @@ void CharacterBody2D::move_and_slide() { } } +void CharacterBody2D::_set_collision_direction(const PhysicsServer2D::MotionResult &p_result) { + if (up_direction == Vector2()) { + //all is a wall + on_wall = true; + } else { + if (Math::acos(p_result.collision_normal.dot(up_direction)) <= floor_max_angle + FLOOR_ANGLE_THRESHOLD) { //floor + on_floor = true; + floor_normal = p_result.collision_normal; + on_floor_body = p_result.collider; + floor_velocity = p_result.collider_velocity; + } else if (Math::acos(p_result.collision_normal.dot(-up_direction)) <= floor_max_angle + FLOOR_ANGLE_THRESHOLD) { //ceiling + on_ceiling = true; + } else { + on_wall = true; + on_floor_body = p_result.collider; + floor_velocity = p_result.collider_velocity; + } + } +} + bool CharacterBody2D::separate_raycast_shapes(PhysicsServer2D::MotionResult &r_result) { PhysicsServer2D::SeparationResult sep_res[8]; //max 8 rays @@ -1168,45 +1294,6 @@ Ref<KinematicCollision2D> CharacterBody2D::_get_slide_collision(int p_bounce) { return slide_colliders[p_bounce]; } -void CharacterBody2D::set_sync_to_physics(bool p_enable) { - if (sync_to_physics == p_enable) { - return; - } - sync_to_physics = p_enable; - - if (Engine::get_singleton()->is_editor_hint()) { - return; - } - - if (p_enable) { - PhysicsServer2D::get_singleton()->body_set_force_integration_callback(get_rid(), callable_mp(this, &CharacterBody2D::_direct_state_changed)); - set_only_update_transform_changes(true); - set_notify_local_transform(true); - } else { - PhysicsServer2D::get_singleton()->body_set_force_integration_callback(get_rid(), Callable()); - set_only_update_transform_changes(false); - set_notify_local_transform(false); - } -} - -bool CharacterBody2D::is_sync_to_physics_enabled() const { - return sync_to_physics; -} - -void CharacterBody2D::_direct_state_changed(Object *p_state) { - if (!sync_to_physics) { - return; - } - - PhysicsDirectBodyState2D *state = Object::cast_to<PhysicsDirectBodyState2D>(p_state); - ERR_FAIL_NULL_MSG(state, "Method '_direct_state_changed' must receive a valid PhysicsDirectBodyState2D object as argument"); - - last_valid_transform = state->get_transform(); - set_notify_local_transform(false); - set_global_transform(last_valid_transform); - set_notify_local_transform(true); -} - void CharacterBody2D::set_safe_margin(real_t p_margin) { margin = p_margin; } @@ -1266,8 +1353,6 @@ void CharacterBody2D::set_up_direction(const Vector2 &p_up_direction) { void CharacterBody2D::_notification(int p_what) { switch (p_what) { case NOTIFICATION_ENTER_TREE: { - last_valid_transform = get_global_transform(); - // Reset move_and_slide() data. on_floor = false; on_floor_body = RID(); @@ -1276,16 +1361,6 @@ void CharacterBody2D::_notification(int p_what) { motion_results.clear(); floor_velocity = Vector2(); } break; - - case NOTIFICATION_LOCAL_TRANSFORM_CHANGED: { - // Used by sync to physics, send the new transform to the physics. - Transform2D new_transform = get_global_transform(); - PhysicsServer2D::get_singleton()->body_set_state(get_rid(), PhysicsServer2D::BODY_STATE_TRANSFORM, new_transform); - // But then revert changes. - set_notify_local_transform(false); - set_global_transform(last_valid_transform); - set_notify_local_transform(true); - } break; } } @@ -1318,9 +1393,6 @@ void CharacterBody2D::_bind_methods() { ClassDB::bind_method(D_METHOD("get_slide_count"), &CharacterBody2D::get_slide_count); ClassDB::bind_method(D_METHOD("get_slide_collision", "slide_idx"), &CharacterBody2D::_get_slide_collision); - ClassDB::bind_method(D_METHOD("set_sync_to_physics", "enable"), &CharacterBody2D::set_sync_to_physics); - ClassDB::bind_method(D_METHOD("is_sync_to_physics_enabled"), &CharacterBody2D::is_sync_to_physics_enabled); - ADD_PROPERTY(PropertyInfo(Variant::VECTOR2, "linear_velocity"), "set_linear_velocity", "get_linear_velocity"); ADD_PROPERTY(PropertyInfo(Variant::BOOL, "stop_on_slope"), "set_stop_on_slope_enabled", "is_stop_on_slope_enabled"); ADD_PROPERTY(PropertyInfo(Variant::BOOL, "infinite_inertia"), "set_infinite_inertia_enabled", "is_infinite_inertia_enabled"); @@ -1329,7 +1401,6 @@ void CharacterBody2D::_bind_methods() { ADD_PROPERTY(PropertyInfo(Variant::VECTOR2, "snap"), "set_snap", "get_snap"); ADD_PROPERTY(PropertyInfo(Variant::VECTOR2, "up_direction"), "set_up_direction", "get_up_direction"); - ADD_PROPERTY(PropertyInfo(Variant::BOOL, "motion/sync_to_physics"), "set_sync_to_physics", "is_sync_to_physics_enabled"); ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "collision/safe_margin", PROPERTY_HINT_RANGE, "0.001,256,0.001"), "set_safe_margin", "get_safe_margin"); } diff --git a/scene/2d/physics_body_2d.h b/scene/2d/physics_body_2d.h index 5a5417eaf3..7a319aabc9 100644 --- a/scene/2d/physics_body_2d.h +++ b/scene/2d/physics_body_2d.h @@ -50,7 +50,7 @@ protected: Ref<KinematicCollision2D> _move(const Vector2 &p_motion, bool p_infinite_inertia = true, bool p_exclude_raycast_shapes = true, bool p_test_only = false, real_t p_margin = 0.08); public: - bool move_and_collide(const Vector2 &p_motion, bool p_infinite_inertia, PhysicsServer2D::MotionResult &r_result, real_t p_margin, bool p_exclude_raycast_shapes = true, bool p_test_only = false, bool p_cancel_sliding = true); + bool move_and_collide(const Vector2 &p_motion, bool p_infinite_inertia, PhysicsServer2D::MotionResult &r_result, real_t p_margin, bool p_exclude_raycast_shapes = true, bool p_test_only = false, bool p_cancel_sliding = true, const Set<RID> &p_exclude = Set<RID>()); bool test_move(const Transform2D &p_from, const Vector2 &p_motion, bool p_infinite_inertia = true, bool p_exclude_raycast_shapes = true, const Ref<KinematicCollision2D> &r_collision = Ref<KinematicCollision2D>(), real_t p_margin = 0.08); TypedArray<PhysicsBody2D> get_collision_exceptions(); @@ -69,6 +69,11 @@ class StaticBody2D : public PhysicsBody2D { Ref<PhysicsMaterial> physics_material_override; bool kinematic_motion = false; + bool sync_to_physics = false; + + Transform2D last_valid_transform; + + void _direct_state_changed(Object *p_state); protected: void _notification(int p_what); @@ -84,6 +89,8 @@ public: Vector2 get_constant_linear_velocity() const; real_t get_constant_angular_velocity() const; + virtual TypedArray<String> get_configuration_warnings() const override; + StaticBody2D(); private: @@ -93,6 +100,9 @@ private: void set_kinematic_motion_enabled(bool p_enabled); bool is_kinematic_motion_enabled() const; + + void set_sync_to_physics(bool p_enable); + bool is_sync_to_physics_enabled() const; }; class RigidBody2D : public PhysicsBody2D { @@ -243,7 +253,7 @@ public: TypedArray<Node2D> get_colliding_bodies() const; //function for script - TypedArray<String> get_configuration_warnings() const override; + virtual TypedArray<String> get_configuration_warnings() const override; RigidBody2D(); ~RigidBody2D(); @@ -276,7 +286,6 @@ private: bool on_floor = false; bool on_ceiling = false; bool on_wall = false; - bool sync_to_physics = false; Vector<PhysicsServer2D::MotionResult> motion_results; Vector<Ref<KinematicCollision2D>> slide_colliders; @@ -285,9 +294,6 @@ private: bool separate_raycast_shapes(PhysicsServer2D::MotionResult &r_result); - Transform2D last_valid_transform; - void _direct_state_changed(Object *p_state); - void set_safe_margin(real_t p_margin); real_t get_safe_margin() const; @@ -308,6 +314,7 @@ private: const Vector2 &get_up_direction() const; void set_up_direction(const Vector2 &p_up_direction); + void _set_collision_direction(const PhysicsServer2D::MotionResult &p_result); protected: void _notification(int p_what); @@ -328,9 +335,6 @@ public: int get_slide_count() const; PhysicsServer2D::MotionResult get_slide_collision(int p_bounce) const; - void set_sync_to_physics(bool p_enable); - bool is_sync_to_physics_enabled() const; - CharacterBody2D(); ~CharacterBody2D(); }; diff --git a/scene/2d/skeleton_2d.cpp b/scene/2d/skeleton_2d.cpp index 8f1f5fadbc..15cbdf535e 100644 --- a/scene/2d/skeleton_2d.cpp +++ b/scene/2d/skeleton_2d.cpp @@ -568,7 +568,7 @@ void Skeleton2D::_make_bone_setup_dirty() { } bone_setup_dirty = true; if (is_inside_tree()) { - call_deferred("_update_bone_setup"); + call_deferred(SNAME("_update_bone_setup")); } } @@ -597,7 +597,7 @@ void Skeleton2D::_update_bone_setup() { transform_dirty = true; _update_transform(); - emit_signal("bone_setup_changed"); + emit_signal(SNAME("bone_setup_changed")); } void Skeleton2D::_make_transform_dirty() { @@ -606,7 +606,7 @@ void Skeleton2D::_make_transform_dirty() { } transform_dirty = true; if (is_inside_tree()) { - call_deferred("_update_transform"); + call_deferred(SNAME("_update_transform")); } } diff --git a/scene/2d/tile_map.cpp b/scene/2d/tile_map.cpp index e39c8841cd..e9efa1cf84 100644 --- a/scene/2d/tile_map.cpp +++ b/scene/2d/tile_map.cpp @@ -58,7 +58,7 @@ void TileMapPattern::remove_cell(const Vector2i &p_coords, bool p_update_size) { } int TileMapPattern::get_cell_source_id(const Vector2i &p_coords) const { - ERR_FAIL_COND_V(!pattern.has(p_coords), -1); + ERR_FAIL_COND_V(!pattern.has(p_coords), TileSet::INVALID_SOURCE); return pattern[p_coords].source_id; } @@ -113,7 +113,7 @@ void TileMapPattern::clear() { }; void TileMapPattern::_bind_methods() { - ClassDB::bind_method(D_METHOD("set_cell", "coords", "source_id", "atlas_coords", "alternative_tile"), &TileMapPattern::set_cell, DEFVAL(-1), DEFVAL(TileSetSource::INVALID_ATLAS_COORDS), DEFVAL(TileSetSource::INVALID_TILE_ALTERNATIVE)); + ClassDB::bind_method(D_METHOD("set_cell", "coords", "source_id", "atlas_coords", "alternative_tile"), &TileMapPattern::set_cell, DEFVAL(TileSet::INVALID_SOURCE), DEFVAL(TileSetSource::INVALID_ATLAS_COORDS), DEFVAL(TileSetSource::INVALID_TILE_ALTERNATIVE)); ClassDB::bind_method(D_METHOD("has_cell", "coords"), &TileMapPattern::has_cell); ClassDB::bind_method(D_METHOD("remove_cell", "coords"), &TileMapPattern::remove_cell); ClassDB::bind_method(D_METHOD("get_cell_source_id", "coords"), &TileMapPattern::get_cell_source_id); @@ -299,7 +299,7 @@ void TileMap::set_tileset(const Ref<TileSet> &p_tileset) { _recreate_quadrants(); } - emit_signal("changed"); + emit_signal(SNAME("changed")); } int TileMap::get_quadrant_size() const { @@ -311,13 +311,13 @@ void TileMap::set_quadrant_size(int p_size) { quadrant_size = p_size; _recreate_quadrants(); - emit_signal("changed"); + emit_signal(SNAME("changed")); } void TileMap::set_collision_visibility_mode(TileMap::VisibilityMode p_show_collision) { show_collision = p_show_collision; _recreate_quadrants(); - emit_signal("changed"); + emit_signal(SNAME("changed")); } TileMap::VisibilityMode TileMap::get_collision_visibility_mode() { @@ -327,7 +327,7 @@ TileMap::VisibilityMode TileMap::get_collision_visibility_mode() { void TileMap::set_navigation_visibility_mode(TileMap::VisibilityMode p_show_navigation) { show_navigation = p_show_navigation; _recreate_quadrants(); - emit_signal("changed"); + emit_signal(SNAME("changed")); } TileMap::VisibilityMode TileMap::get_navigation_visibility_mode() { @@ -337,7 +337,7 @@ TileMap::VisibilityMode TileMap::get_navigation_visibility_mode() { void TileMap::set_y_sort_enabled(bool p_enable) { Node2D::set_y_sort_enabled(p_enable); _recreate_quadrants(); - emit_signal("changed"); + emit_signal(SNAME("changed")); } void TileMap::update_dirty_quadrants() { @@ -480,7 +480,7 @@ void TileMap::_make_all_quadrants_dirty(bool p_update) { return; } if (p_update) { - call_deferred("update_dirty_quadrants"); + call_deferred(SNAME("update_dirty_quadrants")); } } @@ -500,7 +500,7 @@ void TileMap::_make_quadrant_dirty(Map<Vector2i, TileMapQuadrant>::Element *Q, b } if (p_update) { - call_deferred("update_dirty_quadrants"); + call_deferred(SNAME("update_dirty_quadrants")); } } @@ -513,15 +513,15 @@ void TileMap::set_cell(const Vector2i &p_coords, int p_source_id, const Vector2i Vector2i atlas_coords = p_atlas_coords; int alternative_tile = p_alternative_tile; - if ((source_id == -1 || atlas_coords == TileSetSource::INVALID_ATLAS_COORDS || alternative_tile == TileSetSource::INVALID_TILE_ALTERNATIVE) && - (source_id != -1 || atlas_coords != TileSetSource::INVALID_ATLAS_COORDS || alternative_tile != TileSetSource::INVALID_TILE_ALTERNATIVE)) { + if ((source_id == TileSet::INVALID_SOURCE || atlas_coords == TileSetSource::INVALID_ATLAS_COORDS || alternative_tile == TileSetSource::INVALID_TILE_ALTERNATIVE) && + (source_id != TileSet::INVALID_SOURCE || atlas_coords != TileSetSource::INVALID_ATLAS_COORDS || alternative_tile != TileSetSource::INVALID_TILE_ALTERNATIVE)) { WARN_PRINT("Setting a cell a cell as empty requires both source_id, atlas_coord and alternative_tile to be set to their respective \"invalid\" values. Values were thus changes accordingly."); - source_id = -1; + source_id = TileSet::INVALID_SOURCE; atlas_coords = TileSetSource::INVALID_ATLAS_COORDS; alternative_tile = TileSetSource::INVALID_TILE_ALTERNATIVE; } - if (!E && source_id == -1) { + if (!E && source_id == TileSet::INVALID_SOURCE) { return; // Nothing to do, the tile is already empty. } @@ -530,7 +530,7 @@ void TileMap::set_cell(const Vector2i &p_coords, int p_source_id, const Vector2i Map<Vector2i, TileMapQuadrant>::Element *Q = quadrant_map.find(qk); - if (source_id == -1) { + if (source_id == TileSet::INVALID_SOURCE) { // Erase existing cell in the tile map. tile_map.erase(pk); @@ -579,18 +579,23 @@ void TileMap::set_cell(const Vector2i &p_coords, int p_source_id, const Vector2i } } -int TileMap::get_cell_source_id(const Vector2i &p_coords) const { +int TileMap::get_cell_source_id(const Vector2i &p_coords, bool p_use_proxies) const { // Get a cell source id from position const Map<Vector2i, TileMapCell>::Element *E = tile_map.find(p_coords); if (!E) { - return -1; + return TileSet::INVALID_SOURCE; + } + + if (p_use_proxies && tile_set.is_valid()) { + Array proxyed = tile_set->map_tile_proxy(E->get().source_id, E->get().get_atlas_coords(), E->get().alternative_tile); + return proxyed[0]; } return E->get().source_id; } -Vector2i TileMap::get_cell_atlas_coords(const Vector2i &p_coords) const { +Vector2i TileMap::get_cell_atlas_coords(const Vector2i &p_coords, bool p_use_proxies) const { // Get a cell source id from position const Map<Vector2i, TileMapCell>::Element *E = tile_map.find(p_coords); @@ -598,10 +603,15 @@ Vector2i TileMap::get_cell_atlas_coords(const Vector2i &p_coords) const { return TileSetSource::INVALID_ATLAS_COORDS; } + if (p_use_proxies && tile_set.is_valid()) { + Array proxyed = tile_set->map_tile_proxy(E->get().source_id, E->get().get_atlas_coords(), E->get().alternative_tile); + return proxyed[1]; + } + return E->get().get_atlas_coords(); } -int TileMap::get_cell_alternative_tile(const Vector2i &p_coords) const { +int TileMap::get_cell_alternative_tile(const Vector2i &p_coords, bool p_use_proxies) const { // Get a cell source id from position const Map<Vector2i, TileMapCell>::Element *E = tile_map.find(p_coords); @@ -609,6 +619,11 @@ int TileMap::get_cell_alternative_tile(const Vector2i &p_coords) const { return TileSetSource::INVALID_TILE_ALTERNATIVE; } + if (p_use_proxies && tile_set.is_valid()) { + Array proxyed = tile_set->map_tile_proxy(E->get().source_id, E->get().get_atlas_coords(), E->get().alternative_tile); + return proxyed[2]; + } + return E->get().alternative_tile; } @@ -697,11 +712,18 @@ void TileMap::set_pattern(Vector2i p_position, const TileMapPattern *p_pattern) } } -TileMapCell TileMap::get_cell(const Vector2i &p_coords) const { +TileMapCell TileMap::get_cell(const Vector2i &p_coords, bool p_use_proxies) const { if (!tile_map.has(p_coords)) { return TileMapCell(); } else { - return tile_map.find(p_coords)->get(); + TileMapCell c = tile_map.find(p_coords)->get(); + if (p_use_proxies && tile_set.is_valid()) { + Array proxyed = tile_set->map_tile_proxy(c.source_id, c.get_atlas_coords(), c.alternative_tile); + c.source_id = proxyed[0]; + c.set_atlas_coords(proxyed[1]); + c.alternative_tile = proxyed[2]; + } + return c; } } @@ -720,7 +742,7 @@ void TileMap::fix_invalid_tiles() { } } for (Set<Vector2i>::Element *E = coords.front(); E; E = E->next()) { - set_cell(E->get(), -1, TileSetSource::INVALID_ATLAS_COORDS, TileSetSource::INVALID_TILE_ALTERNATIVE); + set_cell(E->get(), TileSet::INVALID_SOURCE, TileSetSource::INVALID_ATLAS_COORDS, TileSetSource::INVALID_TILE_ALTERNATIVE); } } @@ -773,6 +795,7 @@ void TileMap::_set_tile_data(const Vector<int> &p_data) { const int *r = p_data.ptr(); int offset = (format >= FORMAT_2) ? 3 : 2; + ERR_FAIL_COND_MSG(c % offset != 0, "Corrupted tile data."); clear(); @@ -799,25 +822,28 @@ void TileMap::_set_tile_data(const Vector<int> &p_data) { SWAP(local[9], local[10]); } #endif + // Extracts position in TileMap. int16_t x = decode_uint16(&local[0]); int16_t y = decode_uint16(&local[2]); if (format == FORMAT_3) { uint16_t source_id = decode_uint16(&local[4]); uint16_t atlas_coords_x = decode_uint16(&local[6]); - uint16_t atlas_coords_y = decode_uint32(&local[8]); + uint16_t atlas_coords_y = decode_uint16(&local[8]); uint16_t alternative_tile = decode_uint16(&local[10]); set_cell(Vector2i(x, y), source_id, Vector2i(atlas_coords_x, atlas_coords_y), alternative_tile); } else { #ifndef DISABLE_DEPRECATED - uint32_t v = decode_uint32(&local[4]); - v &= (1 << 29) - 1; + // Previous decated format. - // We generate an alternative tile number out of the the flags - // An option should create the alternative in the tileset for compatibility + uint32_t v = decode_uint32(&local[4]); + // Extract the transform flags that used to be in the tilemap. bool flip_h = v & (1 << 29); bool flip_v = v & (1 << 30); bool transpose = v & (1 << 31); + v &= (1 << 29) - 1; + + // Extract autotile/atlas coords. int16_t coord_x = 0; int16_t coord_y = 0; if (format == FORMAT_2) { @@ -825,13 +851,17 @@ void TileMap::_set_tile_data(const Vector<int> &p_data) { coord_y = decode_uint16(&local[10]); } - int compatibility_alternative_tile = ((int)flip_h) + ((int)flip_v << 1) + ((int)transpose << 2); - if (tile_set.is_valid()) { - v = tile_set->compatibility_get_source_for_tile_id(v); + Array a = tile_set->compatibility_tilemap_map(v, Vector2i(coord_x, coord_y), flip_h, flip_v, transpose); + if (a.size() == 3) { + set_cell(Vector2i(x, y), a[0], a[1], a[2]); + } else { + ERR_PRINT(vformat("No valid tile in Tileset for: tile:%s coords:%s flip_h:%s flip_v:%s transpose:%s", v, Vector2i(coord_x, coord_y), flip_h, flip_v, transpose)); + } + } else { + int compatibility_alternative_tile = ((int)flip_h) + ((int)flip_v << 1) + ((int)transpose << 2); + set_cell(Vector2i(x, y), v, Vector2i(coord_x, coord_y), compatibility_alternative_tile); } - - set_cell(Vector2i(x, y), v, Vector2i(coord_x, coord_y), compatibility_alternative_tile); #endif } } @@ -1567,8 +1597,8 @@ void TileMap::set_light_mask(int p_light_mask) { // Occlusion: set light mask. CanvasItem::set_light_mask(p_light_mask); for (Map<Vector2i, TileMapQuadrant>::Element *E = quadrant_map.front(); E; E = E->next()) { - for (List<RID>::Element *F = E->get().canvas_items.front(); F; F = F->next()) { - RenderingServer::get_singleton()->canvas_item_set_light_mask(F->get(), get_light_mask()); + for (const RID &F : E->get().canvas_items) { + RenderingServer::get_singleton()->canvas_item_set_light_mask(F, get_light_mask()); } } } @@ -1580,8 +1610,8 @@ void TileMap::set_material(const Ref<Material> &p_material) { // Update material for the whole tilemap. for (Map<Vector2i, TileMapQuadrant>::Element *E = quadrant_map.front(); E; E = E->next()) { TileMapQuadrant &q = E->get(); - for (List<RID>::Element *F = q.canvas_items.front(); F; F = F->next()) { - RS::get_singleton()->canvas_item_set_use_parent_material(F->get(), get_use_parent_material() || get_material().is_valid()); + for (const RID &F : q.canvas_items) { + RS::get_singleton()->canvas_item_set_use_parent_material(F, get_use_parent_material() || get_material().is_valid()); } } } @@ -1593,8 +1623,8 @@ void TileMap::set_use_parent_material(bool p_use_parent_material) { // Update use_parent_material for the whole tilemap. for (Map<Vector2i, TileMapQuadrant>::Element *E = quadrant_map.front(); E; E = E->next()) { TileMapQuadrant &q = E->get(); - for (List<RID>::Element *F = q.canvas_items.front(); F; F = F->next()) { - RS::get_singleton()->canvas_item_set_use_parent_material(F->get(), get_use_parent_material() || get_material().is_valid()); + for (const RID &F : q.canvas_items) { + RS::get_singleton()->canvas_item_set_use_parent_material(F, get_use_parent_material() || get_material().is_valid()); } } } @@ -1604,8 +1634,8 @@ void TileMap::set_texture_filter(TextureFilter p_texture_filter) { CanvasItem::set_texture_filter(p_texture_filter); for (Map<Vector2i, TileMapQuadrant>::Element *F = quadrant_map.front(); F; F = F->next()) { TileMapQuadrant &q = F->get(); - for (List<RID>::Element *E = q.canvas_items.front(); E; E = E->next()) { - RenderingServer::get_singleton()->canvas_item_set_default_texture_filter(E->get(), RS::CanvasItemTextureFilter(p_texture_filter)); + for (const RID &E : q.canvas_items) { + RenderingServer::get_singleton()->canvas_item_set_default_texture_filter(E, RS::CanvasItemTextureFilter(p_texture_filter)); _make_quadrant_dirty(F); } } @@ -1616,8 +1646,8 @@ void TileMap::set_texture_repeat(CanvasItem::TextureRepeat p_texture_repeat) { CanvasItem::set_texture_repeat(p_texture_repeat); for (Map<Vector2i, TileMapQuadrant>::Element *F = quadrant_map.front(); F; F = F->next()) { TileMapQuadrant &q = F->get(); - for (List<RID>::Element *E = q.canvas_items.front(); E; E = E->next()) { - RenderingServer::get_singleton()->canvas_item_set_default_texture_repeat(E->get(), RS::CanvasItemTextureRepeat(p_texture_repeat)); + for (const RID &E : q.canvas_items) { + RenderingServer::get_singleton()->canvas_item_set_default_texture_repeat(E, RS::CanvasItemTextureRepeat(p_texture_repeat)); _make_quadrant_dirty(F); } } @@ -1727,10 +1757,10 @@ void TileMap::_bind_methods() { ClassDB::bind_method(D_METHOD("set_navigation_visibility_mode", "show_navigation"), &TileMap::set_navigation_visibility_mode); ClassDB::bind_method(D_METHOD("get_navigation_visibility_mode"), &TileMap::get_navigation_visibility_mode); - ClassDB::bind_method(D_METHOD("set_cell", "coords", "source_id", "atlas_coords", "alternative_tile"), &TileMap::set_cell, DEFVAL(-1), DEFVAL(TileSetSource::INVALID_ATLAS_COORDS), DEFVAL(TileSetSource::INVALID_TILE_ALTERNATIVE)); - ClassDB::bind_method(D_METHOD("get_cell_source_id", "coords"), &TileMap::get_cell_source_id); - ClassDB::bind_method(D_METHOD("get_cell_atlas_coords", "coords"), &TileMap::get_cell_atlas_coords); - ClassDB::bind_method(D_METHOD("get_cell_alternative_tile", "coords"), &TileMap::get_cell_alternative_tile); + ClassDB::bind_method(D_METHOD("set_cell", "coords", "source_id", "atlas_coords", "alternative_tile"), &TileMap::set_cell, DEFVAL(TileSet::INVALID_SOURCE), DEFVAL(TileSetSource::INVALID_ATLAS_COORDS), DEFVAL(TileSetSource::INVALID_TILE_ALTERNATIVE)); + ClassDB::bind_method(D_METHOD("get_cell_source_id", "coords", "use_proxies"), &TileMap::get_cell_source_id); + ClassDB::bind_method(D_METHOD("get_cell_atlas_coords", "coords", "use_proxies"), &TileMap::get_cell_atlas_coords); + ClassDB::bind_method(D_METHOD("get_cell_alternative_tile", "coords", "use_proxies"), &TileMap::get_cell_alternative_tile); ClassDB::bind_method(D_METHOD("fix_invalid_tiles"), &TileMap::fix_invalid_tiles); ClassDB::bind_method(D_METHOD("get_surrounding_tiles", "coords"), &TileMap::get_surrounding_tiles); @@ -1764,7 +1794,7 @@ void TileMap::_bind_methods() { } void TileMap::_tile_set_changed() { - emit_signal("changed"); + emit_signal(SNAME("changed")); _make_all_quadrants_dirty(true); } diff --git a/scene/2d/tile_map.h b/scene/2d/tile_map.h index 3001e6b471..9e35e73ad8 100644 --- a/scene/2d/tile_map.h +++ b/scene/2d/tile_map.h @@ -265,16 +265,16 @@ public: VisibilityMode get_navigation_visibility_mode(); void set_cell(const Vector2i &p_coords, int p_source_id = -1, const Vector2i p_atlas_coords = TileSetSource::INVALID_ATLAS_COORDS, int p_alternative_tile = TileSetSource::INVALID_TILE_ALTERNATIVE); - int get_cell_source_id(const Vector2i &p_coords) const; - Vector2i get_cell_atlas_coords(const Vector2i &p_coords) const; - int get_cell_alternative_tile(const Vector2i &p_coords) const; + int get_cell_source_id(const Vector2i &p_coords, bool p_use_proxies = false) const; + Vector2i get_cell_atlas_coords(const Vector2i &p_coords, bool p_use_proxies = false) const; + int get_cell_alternative_tile(const Vector2i &p_coords, bool p_use_proxies = false) const; TileMapPattern *get_pattern(TypedArray<Vector2i> p_coords_array); Vector2i map_pattern(Vector2i p_position_in_tilemap, Vector2i p_coords_in_pattern, const TileMapPattern *p_pattern); void set_pattern(Vector2i p_position, const TileMapPattern *p_pattern); // Not exposed to users - TileMapCell get_cell(const Vector2i &p_coords) const; + TileMapCell get_cell(const Vector2i &p_coords, bool p_use_proxies = false) const; Map<Vector2i, TileMapQuadrant> &get_quadrant_map(); int get_effective_quadrant_size() const; diff --git a/scene/2d/touch_screen_button.cpp b/scene/2d/touch_screen_button.cpp index 0a6393551c..7c345ad377 100644 --- a/scene/2d/touch_screen_button.cpp +++ b/scene/2d/touch_screen_button.cpp @@ -294,7 +294,7 @@ void TouchScreenButton::_press(int p_finger_pressed) { get_viewport()->input(iea, true); } - emit_signal("pressed"); + emit_signal(SNAME("pressed")); update(); } @@ -313,7 +313,7 @@ void TouchScreenButton::_release(bool p_exiting_tree) { } if (!p_exiting_tree) { - emit_signal("released"); + emit_signal(SNAME("released")); update(); } } diff --git a/scene/3d/audio_stream_player_3d.cpp b/scene/3d/audio_stream_player_3d.cpp index ba559b4ecb..bb8f9f8ccb 100644 --- a/scene/3d/audio_stream_player_3d.cpp +++ b/scene/3d/audio_stream_player_3d.cpp @@ -607,7 +607,7 @@ void AudioStreamPlayer3D::_notification(int p_what) { //stop playing if no longer active if (!active.is_set()) { set_physics_process_internal(false); - emit_signal("finished"); + emit_signal(SNAME("finished")); } } } @@ -794,7 +794,7 @@ uint32_t AudioStreamPlayer3D::get_area_mask() const { void AudioStreamPlayer3D::set_emission_angle_enabled(bool p_enable) { emission_angle_enabled = p_enable; - update_gizmo(); + update_gizmos(); } bool AudioStreamPlayer3D::is_emission_angle_enabled() const { @@ -804,7 +804,7 @@ bool AudioStreamPlayer3D::is_emission_angle_enabled() const { void AudioStreamPlayer3D::set_emission_angle(float p_angle) { ERR_FAIL_COND(p_angle < 0 || p_angle > 90); emission_angle = p_angle; - update_gizmo(); + update_gizmos(); } float AudioStreamPlayer3D::get_emission_angle() const { diff --git a/scene/3d/camera_3d.cpp b/scene/3d/camera_3d.cpp index 1ed8c0b4eb..2e962b96c3 100644 --- a/scene/3d/camera_3d.cpp +++ b/scene/3d/camera_3d.cpp @@ -85,14 +85,14 @@ void Camera3D::_update_camera() { // here goes listener stuff /* if (viewport_ptr && is_inside_scene() && is_current()) - get_viewport()->_camera_transform_changed_notify(); + get_viewport()->_camera_3d_transform_changed_notify(); */ if (get_tree()->is_node_being_edited(this) || !is_current()) { return; } - get_viewport()->_camera_transform_changed_notify(); + get_viewport()->_camera_3d_transform_changed_notify(); } void Camera3D::_notification(int p_what) { @@ -104,9 +104,9 @@ void Camera3D::_notification(int p_what) { viewport = get_viewport(); ERR_FAIL_COND(!viewport); - bool first_camera = viewport->_camera_add(this); + bool first_camera = viewport->_camera_3d_add(this); if (current || first_camera) { - viewport->_camera_set(this); + viewport->_camera_3d_set(this); } } break; @@ -128,7 +128,7 @@ void Camera3D::_notification(int p_what) { } if (viewport) { - viewport->_camera_remove(this); + viewport->_camera_3d_remove(this); viewport = nullptr; } @@ -164,7 +164,7 @@ void Camera3D::set_perspective(float p_fovy_degrees, float p_z_near, float p_z_f mode = PROJECTION_PERSPECTIVE; RenderingServer::get_singleton()->camera_set_perspective(camera, fov, near, far); - update_gizmo(); + update_gizmos(); force_change = false; } @@ -181,7 +181,7 @@ void Camera3D::set_orthogonal(float p_size, float p_z_near, float p_z_far) { force_change = false; RenderingServer::get_singleton()->camera_set_orthogonal(camera, size, near, far); - update_gizmo(); + update_gizmos(); } void Camera3D::set_frustum(float p_size, Vector2 p_offset, float p_z_near, float p_z_far) { @@ -198,7 +198,7 @@ void Camera3D::set_frustum(float p_size, Vector2 p_offset, float p_z_near, float force_change = false; RenderingServer::get_singleton()->camera_set_frustum(camera, size, frustum_offset, near, far); - update_gizmo(); + update_gizmos(); } void Camera3D::set_projection(Camera3D::Projection p_mode) { @@ -220,7 +220,7 @@ void Camera3D::make_current() { return; } - get_viewport()->_camera_set(this); + get_viewport()->_camera_3d_set(this); //get_scene()->call_group(SceneMainLoop::GROUP_CALL_REALTIME,camera_group,"_camera_make_current",this); } @@ -231,11 +231,11 @@ void Camera3D::clear_current(bool p_enable_next) { return; } - if (get_viewport()->get_camera() == this) { - get_viewport()->_camera_set(nullptr); + if (get_viewport()->get_camera_3d() == this) { + get_viewport()->_camera_3d_set(nullptr); if (p_enable_next) { - get_viewport()->_camera_make_next_current(this); + get_viewport()->_camera_3d_make_next_current(this); } } } @@ -250,7 +250,7 @@ void Camera3D::set_current(bool p_current) { bool Camera3D::is_current() const { if (is_inside_tree() && !get_tree()->is_node_being_edited(this)) { - return get_viewport()->get_camera() == this; + return get_viewport()->get_camera_3d() == this; } else { return current; } @@ -755,7 +755,7 @@ void ClippedCamera3D::_notification(int p_what) { } if (p_what == NOTIFICATION_LOCAL_TRANSFORM_CHANGED) { - update_gizmo(); + update_gizmos(); } } diff --git a/scene/3d/collision_object_3d.cpp b/scene/3d/collision_object_3d.cpp index 40e3f7c764..dd1f25da68 100644 --- a/scene/3d/collision_object_3d.cpp +++ b/scene/3d/collision_object_3d.cpp @@ -77,6 +77,10 @@ void CollisionObject3D::_notification(int p_what) { } break; case NOTIFICATION_TRANSFORM_CHANGED: { + if (only_update_transform_changes) { + return; + } + if (area) { PhysicsServer3D::get_singleton()->area_set_transform(rid, get_global_transform()); } else { @@ -284,6 +288,14 @@ void CollisionObject3D::set_body_mode(PhysicsServer3D::BodyMode p_mode) { PhysicsServer3D::get_singleton()->body_set_mode(rid, p_mode); } +void CollisionObject3D::set_only_update_transform_changes(bool p_enable) { + only_update_transform_changes = p_enable; +} + +bool CollisionObject3D::is_only_update_transform_changes_enabled() const { + return only_update_transform_changes; +} + void CollisionObject3D::_update_pickable() { if (!is_inside_tree()) { return; diff --git a/scene/3d/collision_object_3d.h b/scene/3d/collision_object_3d.h index a3a890db75..7c30a5cd98 100644 --- a/scene/3d/collision_object_3d.h +++ b/scene/3d/collision_object_3d.h @@ -74,6 +74,8 @@ private: Map<uint32_t, ShapeData> shapes; + bool only_update_transform_changes = false; // This is used for sync to physics. + bool capture_input_on_drag = false; bool ray_pickable = true; @@ -107,6 +109,9 @@ protected: void set_body_mode(PhysicsServer3D::BodyMode p_mode); + void set_only_update_transform_changes(bool p_enable); + bool is_only_update_transform_changes_enabled() const; + public: void set_collision_layer(uint32_t p_layer); uint32_t get_collision_layer() const; diff --git a/scene/3d/collision_polygon_3d.cpp b/scene/3d/collision_polygon_3d.cpp index 8a4f8b639b..42645f47d4 100644 --- a/scene/3d/collision_polygon_3d.cpp +++ b/scene/3d/collision_polygon_3d.cpp @@ -122,7 +122,7 @@ void CollisionPolygon3D::set_polygon(const Vector<Point2> &p_polygon) { _build_polygon(); } update_configuration_warnings(); - update_gizmo(); + update_gizmos(); } Vector<Point2> CollisionPolygon3D::get_polygon() const { @@ -136,7 +136,7 @@ AABB CollisionPolygon3D::get_item_rect() const { void CollisionPolygon3D::set_depth(real_t p_depth) { depth = p_depth; _build_polygon(); - update_gizmo(); + update_gizmos(); } real_t CollisionPolygon3D::get_depth() const { @@ -145,7 +145,7 @@ real_t CollisionPolygon3D::get_depth() const { void CollisionPolygon3D::set_disabled(bool p_disabled) { disabled = p_disabled; - update_gizmo(); + update_gizmos(); if (parent) { parent->shape_owner_set_disabled(owner_id, p_disabled); diff --git a/scene/3d/collision_shape_3d.cpp b/scene/3d/collision_shape_3d.cpp index be3fde8013..9643d33c86 100644 --- a/scene/3d/collision_shape_3d.cpp +++ b/scene/3d/collision_shape_3d.cpp @@ -117,7 +117,7 @@ void CollisionShape3D::_notification(int p_what) { } void CollisionShape3D::resource_changed(RES res) { - update_gizmo(); + update_gizmos(); } TypedArray<String> CollisionShape3D::get_configuration_warnings() const { @@ -166,7 +166,7 @@ void CollisionShape3D::set_shape(const Ref<Shape3D> &p_shape) { if (!shape.is_null()) { shape->register_owner(this); } - update_gizmo(); + update_gizmos(); if (parent) { parent->shape_owner_clear_shapes(owner_id); if (shape.is_valid()) { @@ -187,7 +187,7 @@ Ref<Shape3D> CollisionShape3D::get_shape() const { void CollisionShape3D::set_disabled(bool p_disabled) { disabled = p_disabled; - update_gizmo(); + update_gizmos(); if (parent) { parent->shape_owner_set_disabled(owner_id, p_disabled); } diff --git a/scene/3d/cpu_particles_3d.cpp b/scene/3d/cpu_particles_3d.cpp index 6dc865ec0e..60f8ad8f36 100644 --- a/scene/3d/cpu_particles_3d.cpp +++ b/scene/3d/cpu_particles_3d.cpp @@ -401,6 +401,22 @@ void CPUParticles3D::set_emission_colors(const Vector<Color> &p_colors) { emission_colors = p_colors; } +void CPUParticles3D::set_emission_ring_axis(Vector3 p_axis) { + emission_ring_axis = p_axis; +} + +void CPUParticles3D::set_emission_ring_height(float p_height) { + emission_ring_height = p_height; +} + +void CPUParticles3D::set_emission_ring_radius(float p_radius) { + emission_ring_radius = p_radius; +} + +void CPUParticles3D::set_emission_ring_inner_radius(float p_radius) { + emission_ring_inner_radius = p_radius; +} + float CPUParticles3D::get_emission_sphere_radius() const { return emission_sphere_radius; } @@ -421,6 +437,22 @@ Vector<Color> CPUParticles3D::get_emission_colors() const { return emission_colors; } +Vector3 CPUParticles3D::get_emission_ring_axis() const { + return emission_ring_axis; +} + +float CPUParticles3D::get_emission_ring_height() const { + return emission_ring_height; +} + +float CPUParticles3D::get_emission_ring_radius() const { + return emission_ring_radius; +} + +float CPUParticles3D::get_emission_ring_inner_radius() const { + return emission_ring_inner_radius; +} + CPUParticles3D::EmissionShape CPUParticles3D::get_emission_shape() const { return emission_shape; } @@ -434,10 +466,6 @@ Vector3 CPUParticles3D::get_gravity() const { } void CPUParticles3D::_validate_property(PropertyInfo &property) const { - if (property.name == "color" && color_ramp.is_valid()) { - property.usage = PROPERTY_USAGE_NONE; - } - if (property.name == "emission_sphere_radius" && emission_shape != EMISSION_SHAPE_SPHERE) { property.usage = PROPERTY_USAGE_NONE; } @@ -446,7 +474,7 @@ void CPUParticles3D::_validate_property(PropertyInfo &property) const { property.usage = PROPERTY_USAGE_NONE; } - if ((property.name == "emission_point_texture" || property.name == "emission_color_texture") && (emission_shape < EMISSION_SHAPE_POINTS)) { + if ((property.name == "emission_point_texture" || property.name == "emission_color_texture" || property.name == "emission_points") && (emission_shape != EMISSION_SHAPE_POINTS && (emission_shape != EMISSION_SHAPE_DIRECTED_POINTS))) { property.usage = PROPERTY_USAGE_NONE; } @@ -454,6 +482,10 @@ void CPUParticles3D::_validate_property(PropertyInfo &property) const { property.usage = PROPERTY_USAGE_NONE; } + if (property.name.begins_with("emission_ring_") && emission_shape != EMISSION_SHAPE_RING) { + property.usage = PROPERTY_USAGE_NONE; + } + if (property.name.begins_with("orbit_") && !particle_flags[PARTICLE_FLAG_DISABLE_Z]) { property.usage = PROPERTY_USAGE_NONE; } @@ -750,6 +782,21 @@ void CPUParticles3D::_particles_process(float p_delta) { p.base_color = emission_colors.get(random_idx); } } break; + case EMISSION_SHAPE_RING: { + float ring_random_angle = Math::randf() * 2.0 * Math_PI; + float ring_random_radius = Math::randf() * (emission_ring_radius - emission_ring_inner_radius) + emission_ring_inner_radius; + Vector3 axis = emission_ring_axis.normalized(); + Vector3 ortho_axis = Vector3(); + if (axis == Vector3(1.0, 0.0, 0.0)) { + ortho_axis = Vector3(0.0, 1.0, 0.0).cross(axis); + } else { + ortho_axis = Vector3(1.0, 0.0, 0.0).cross(axis); + } + ortho_axis = ortho_axis.normalized(); + ortho_axis.rotate(axis, ring_random_angle); + ortho_axis = ortho_axis.normalized(); + p.transform.origin = ortho_axis * ring_random_radius + (Math::randf() * emission_ring_height - emission_ring_height / 2.0) * axis; + } break; case EMISSION_SHAPE_MAX: { // Max value for validity check. break; } @@ -1007,7 +1054,7 @@ void CPUParticles3D::_update_particle_data_buffer() { sorter.sort(order, pc); } else if (draw_order == DRAW_ORDER_VIEW_DEPTH) { ERR_FAIL_NULL(get_viewport()); - Camera3D *c = get_viewport()->get_camera(); + Camera3D *c = get_viewport()->get_camera_3d(); if (c) { Vector3 dir = c->get_global_transform().basis.get_axis(2); //far away to close @@ -1340,18 +1387,34 @@ void CPUParticles3D::_bind_methods() { ClassDB::bind_method(D_METHOD("set_emission_colors", "array"), &CPUParticles3D::set_emission_colors); ClassDB::bind_method(D_METHOD("get_emission_colors"), &CPUParticles3D::get_emission_colors); + ClassDB::bind_method(D_METHOD("set_emission_ring_axis", "axis"), &CPUParticles3D::set_emission_ring_axis); + ClassDB::bind_method(D_METHOD("get_emission_ring_axis"), &CPUParticles3D::get_emission_ring_axis); + + ClassDB::bind_method(D_METHOD("set_emission_ring_height", "height"), &CPUParticles3D::set_emission_ring_height); + ClassDB::bind_method(D_METHOD("get_emission_ring_height"), &CPUParticles3D::get_emission_ring_height); + + ClassDB::bind_method(D_METHOD("set_emission_ring_radius", "radius"), &CPUParticles3D::set_emission_ring_radius); + ClassDB::bind_method(D_METHOD("get_emission_ring_radius"), &CPUParticles3D::get_emission_ring_radius); + + ClassDB::bind_method(D_METHOD("set_emission_ring_inner_radius", "inner_radius"), &CPUParticles3D::set_emission_ring_inner_radius); + ClassDB::bind_method(D_METHOD("get_emission_ring_inner_radius"), &CPUParticles3D::get_emission_ring_inner_radius); + ClassDB::bind_method(D_METHOD("get_gravity"), &CPUParticles3D::get_gravity); ClassDB::bind_method(D_METHOD("set_gravity", "accel_vec"), &CPUParticles3D::set_gravity); ClassDB::bind_method(D_METHOD("convert_from_particles", "particles"), &CPUParticles3D::convert_from_particles); ADD_GROUP("Emission Shape", "emission_"); - ADD_PROPERTY(PropertyInfo(Variant::INT, "emission_shape", PROPERTY_HINT_ENUM, "Point,Sphere,Box,Points,Directed Points", PROPERTY_USAGE_DEFAULT | PROPERTY_USAGE_UPDATE_ALL_IF_MODIFIED), "set_emission_shape", "get_emission_shape"); + ADD_PROPERTY(PropertyInfo(Variant::INT, "emission_shape", PROPERTY_HINT_ENUM, "Point,Sphere,Box,Points,Directed Points,Ring", PROPERTY_USAGE_DEFAULT | PROPERTY_USAGE_UPDATE_ALL_IF_MODIFIED), "set_emission_shape", "get_emission_shape"); ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "emission_sphere_radius", PROPERTY_HINT_RANGE, "0.01,128,0.01"), "set_emission_sphere_radius", "get_emission_sphere_radius"); ADD_PROPERTY(PropertyInfo(Variant::VECTOR3, "emission_box_extents"), "set_emission_box_extents", "get_emission_box_extents"); ADD_PROPERTY(PropertyInfo(Variant::PACKED_VECTOR3_ARRAY, "emission_points"), "set_emission_points", "get_emission_points"); ADD_PROPERTY(PropertyInfo(Variant::PACKED_VECTOR3_ARRAY, "emission_normals"), "set_emission_normals", "get_emission_normals"); ADD_PROPERTY(PropertyInfo(Variant::PACKED_COLOR_ARRAY, "emission_colors"), "set_emission_colors", "get_emission_colors"); + ADD_PROPERTY(PropertyInfo(Variant::VECTOR3, "emission_ring_axis"), "set_emission_ring_axis", "get_emission_ring_axis"); + ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "emission_ring_height"), "set_emission_ring_height", "get_emission_ring_height"); + ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "emission_ring_radius"), "set_emission_ring_radius", "get_emission_ring_radius"); + ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "emission_ring_inner_radius"), "set_emission_ring_inner_radius", "get_emission_ring_inner_radius"); ADD_GROUP("Particle Flags", "particle_flag_"); ADD_PROPERTYI(PropertyInfo(Variant::BOOL, "particle_flag_align_y"), "set_particle_flag", "get_particle_flag", PARTICLE_FLAG_ALIGN_Y_TO_VELOCITY); ADD_PROPERTYI(PropertyInfo(Variant::BOOL, "particle_flag_rotate_y"), "set_particle_flag", "get_particle_flag", PARTICLE_FLAG_ROTATE_Y); @@ -1437,6 +1500,7 @@ void CPUParticles3D::_bind_methods() { BIND_ENUM_CONSTANT(EMISSION_SHAPE_BOX); BIND_ENUM_CONSTANT(EMISSION_SHAPE_POINTS); BIND_ENUM_CONSTANT(EMISSION_SHAPE_DIRECTED_POINTS); + BIND_ENUM_CONSTANT(EMISSION_SHAPE_RING); BIND_ENUM_CONSTANT(EMISSION_SHAPE_MAX); } @@ -1465,6 +1529,10 @@ CPUParticles3D::CPUParticles3D() { set_emission_shape(EMISSION_SHAPE_POINT); set_emission_sphere_radius(1); set_emission_box_extents(Vector3(1, 1, 1)); + set_emission_ring_axis(Vector3(0, 0, 1.0)); + set_emission_ring_height(1); + set_emission_ring_radius(1); + set_emission_ring_inner_radius(0); set_gravity(Vector3(0, -9.8, 0)); diff --git a/scene/3d/cpu_particles_3d.h b/scene/3d/cpu_particles_3d.h index b35e659757..07d345ba2c 100644 --- a/scene/3d/cpu_particles_3d.h +++ b/scene/3d/cpu_particles_3d.h @@ -76,6 +76,7 @@ public: EMISSION_SHAPE_BOX, EMISSION_SHAPE_POINTS, EMISSION_SHAPE_DIRECTED_POINTS, + EMISSION_SHAPE_RING, EMISSION_SHAPE_MAX }; @@ -171,6 +172,10 @@ private: Vector<Vector3> emission_normals; Vector<Color> emission_colors; int emission_point_count = 0; + Vector3 emission_ring_axis; + float emission_ring_height; + float emission_ring_radius; + float emission_ring_inner_radius; Vector3 gravity = Vector3(0, -9.8, 0); @@ -268,6 +273,10 @@ public: void set_emission_normals(const Vector<Vector3> &p_normals); void set_emission_colors(const Vector<Color> &p_colors); void set_emission_point_count(int p_count); + void set_emission_ring_axis(Vector3 p_axis); + void set_emission_ring_height(float p_height); + void set_emission_ring_radius(float p_radius); + void set_emission_ring_inner_radius(float p_radius); EmissionShape get_emission_shape() const; float get_emission_sphere_radius() const; @@ -276,6 +285,10 @@ public: Vector<Vector3> get_emission_normals() const; Vector<Color> get_emission_colors() const; int get_emission_point_count() const; + Vector3 get_emission_ring_axis() const; + float get_emission_ring_height() const; + float get_emission_ring_radius() const; + float get_emission_ring_inner_radius() const; void set_gravity(const Vector3 &p_gravity); Vector3 get_gravity() const; diff --git a/scene/3d/decal.cpp b/scene/3d/decal.cpp index 5af7b8ca07..05f023721b 100644 --- a/scene/3d/decal.cpp +++ b/scene/3d/decal.cpp @@ -33,7 +33,7 @@ void Decal::set_extents(const Vector3 &p_extents) { extents = p_extents; RS::get_singleton()->decal_set_extents(decal, p_extents); - update_gizmo(); + update_gizmos(); } Vector3 Decal::get_extents() const { diff --git a/scene/3d/gpu_particles_3d.cpp b/scene/3d/gpu_particles_3d.cpp index f78027e6c7..44cd7c10d8 100644 --- a/scene/3d/gpu_particles_3d.cpp +++ b/scene/3d/gpu_particles_3d.cpp @@ -99,7 +99,7 @@ void GPUParticles3D::set_randomness_ratio(float p_ratio) { void GPUParticles3D::set_visibility_aabb(const AABB &p_aabb) { visibility_aabb = p_aabb; RS::get_singleton()->particles_set_custom_aabb(particles, visibility_aabb); - update_gizmo(); + update_gizmos(); } void GPUParticles3D::set_use_local_coordinates(bool p_enable) { diff --git a/scene/3d/gpu_particles_collision_3d.cpp b/scene/3d/gpu_particles_collision_3d.cpp index c1e71b9565..cc1b620025 100644 --- a/scene/3d/gpu_particles_collision_3d.cpp +++ b/scene/3d/gpu_particles_collision_3d.cpp @@ -73,7 +73,7 @@ void GPUParticlesCollisionSphere::_bind_methods() { void GPUParticlesCollisionSphere::set_radius(float p_radius) { radius = p_radius; RS::get_singleton()->particles_collision_set_sphere_radius(_get_collision(), radius); - update_gizmo(); + update_gizmos(); } float GPUParticlesCollisionSphere::get_radius() const { @@ -103,7 +103,7 @@ void GPUParticlesCollisionBox::_bind_methods() { void GPUParticlesCollisionBox::set_extents(const Vector3 &p_extents) { extents = p_extents; RS::get_singleton()->particles_collision_set_box_extents(_get_collision(), extents); - update_gizmo(); + update_gizmos(); } Vector3 GPUParticlesCollisionBox::get_extents() const { @@ -397,9 +397,7 @@ Ref<Image> GPUParticlesCollisionSDF::bake() { bake_step_function(0, "Finding Meshes"); } - for (List<PlotMesh>::Element *E = plot_meshes.front(); E; E = E->next()) { - const PlotMesh &pm = E->get(); - + for (const PlotMesh &pm : plot_meshes) { for (int i = 0; i < pm.mesh->get_surface_count(); i++) { if (pm.mesh->surface_get_primitive_type(i) != Mesh::PRIMITIVE_TRIANGLES) { continue; //only triangles @@ -545,7 +543,7 @@ float GPUParticlesCollisionSDF::get_thickness() const { void GPUParticlesCollisionSDF::set_extents(const Vector3 &p_extents) { extents = p_extents; RS::get_singleton()->particles_collision_set_box_extents(_get_collision(), extents); - update_gizmo(); + update_gizmos(); } Vector3 GPUParticlesCollisionSDF::get_extents() const { @@ -554,7 +552,7 @@ Vector3 GPUParticlesCollisionSDF::get_extents() const { void GPUParticlesCollisionSDF::set_resolution(Resolution p_resolution) { resolution = p_resolution; - update_gizmo(); + update_gizmos(); } GPUParticlesCollisionSDF::Resolution GPUParticlesCollisionSDF::get_resolution() const { @@ -596,7 +594,7 @@ void GPUParticlesCollisionHeightField::_notification(int p_what) { } if (follow_camera_mode && get_viewport()) { - Camera3D *cam = get_viewport()->get_camera(); + Camera3D *cam = get_viewport()->get_camera_3d(); if (cam) { Transform3D xform = get_global_transform(); Vector3 x_axis = xform.basis.get_axis(Vector3::AXIS_X).normalized(); @@ -680,7 +678,7 @@ float GPUParticlesCollisionHeightField::get_follow_camera_push_ratio() const { void GPUParticlesCollisionHeightField::set_extents(const Vector3 &p_extents) { extents = p_extents; RS::get_singleton()->particles_collision_set_box_extents(_get_collision(), extents); - update_gizmo(); + update_gizmos(); RS::get_singleton()->particles_collision_height_field_update(_get_collision()); } @@ -691,7 +689,7 @@ Vector3 GPUParticlesCollisionHeightField::get_extents() const { void GPUParticlesCollisionHeightField::set_resolution(Resolution p_resolution) { resolution = p_resolution; RS::get_singleton()->particles_collision_set_height_field_resolution(_get_collision(), RS::ParticlesCollisionHeightfieldResolution(resolution)); - update_gizmo(); + update_gizmos(); RS::get_singleton()->particles_collision_height_field_update(_get_collision()); } @@ -761,7 +759,7 @@ float GPUParticlesAttractor3D::get_attenuation() const { void GPUParticlesAttractor3D::set_directionality(float p_directionality) { directionality = p_directionality; RS::get_singleton()->particles_collision_set_attractor_directionality(collision, p_directionality); - update_gizmo(); + update_gizmos(); } float GPUParticlesAttractor3D::get_directionality() const { @@ -808,7 +806,7 @@ void GPUParticlesAttractorSphere::_bind_methods() { void GPUParticlesAttractorSphere::set_radius(float p_radius) { radius = p_radius; RS::get_singleton()->particles_collision_set_sphere_radius(_get_collision(), radius); - update_gizmo(); + update_gizmos(); } float GPUParticlesAttractorSphere::get_radius() const { @@ -838,7 +836,7 @@ void GPUParticlesAttractorBox::_bind_methods() { void GPUParticlesAttractorBox::set_extents(const Vector3 &p_extents) { extents = p_extents; RS::get_singleton()->particles_collision_set_box_extents(_get_collision(), extents); - update_gizmo(); + update_gizmos(); } Vector3 GPUParticlesAttractorBox::get_extents() const { @@ -872,7 +870,7 @@ void GPUParticlesAttractorVectorField::_bind_methods() { void GPUParticlesAttractorVectorField::set_extents(const Vector3 &p_extents) { extents = p_extents; RS::get_singleton()->particles_collision_set_box_extents(_get_collision(), extents); - update_gizmo(); + update_gizmos(); } Vector3 GPUParticlesAttractorVectorField::get_extents() const { diff --git a/scene/3d/light_3d.cpp b/scene/3d/light_3d.cpp index 8478821ba1..c2943a9606 100644 --- a/scene/3d/light_3d.cpp +++ b/scene/3d/light_3d.cpp @@ -45,7 +45,7 @@ void Light3D::set_param(Param p_param, float p_value) { RS::get_singleton()->light_set_param(light, RS::LightParam(p_param), p_value); if (p_param == PARAM_SPOT_ANGLE || p_param == PARAM_RANGE) { - update_gizmo(); + update_gizmos(); if (p_param == PARAM_SPOT_ANGLE) { update_configuration_warnings(); @@ -95,7 +95,7 @@ void Light3D::set_color(const Color &p_color) { color = p_color; RS::get_singleton()->light_set_color(light, p_color); // The gizmo color depends on the light color, so update it. - update_gizmo(); + update_gizmos(); } Color Light3D::get_color() const { diff --git a/scene/3d/lightmap_gi.cpp b/scene/3d/lightmap_gi.cpp index 66e3535fc4..0085c8933d 100644 --- a/scene/3d/lightmap_gi.cpp +++ b/scene/3d/lightmap_gi.cpp @@ -599,7 +599,7 @@ void LightmapGI::_gen_new_positions_from_octree(const GenProbesOctree *p_cell, f const Vector3 *pp = probe_positions.ptr(); bool exists = false; for (int j = 0; j < ppcount; j++) { - if (pp[j].distance_to(real_pos) < CMP_EPSILON) { + if (pp[j].is_equal_approx(real_pos)) { exists = true; break; } @@ -1250,7 +1250,7 @@ void LightmapGI::set_light_data(const Ref<LightmapGIData> &p_data) { } } - update_gizmo(); + update_gizmos(); } Ref<LightmapGIData> LightmapGI::get_light_data() const { diff --git a/scene/3d/mesh_instance_3d.cpp b/scene/3d/mesh_instance_3d.cpp index 28ccbd3e68..9ca1d55d0b 100644 --- a/scene/3d/mesh_instance_3d.cpp +++ b/scene/3d/mesh_instance_3d.cpp @@ -94,8 +94,8 @@ void MeshInstance3D::_get_property_list(List<PropertyInfo> *p_list) const { ls.sort(); - for (List<String>::Element *E = ls.front(); E; E = E->next()) { - p_list->push_back(PropertyInfo(Variant::FLOAT, E->get(), PROPERTY_HINT_RANGE, "-1,1,0.00001")); + for (const String &E : ls) { + p_list->push_back(PropertyInfo(Variant::FLOAT, E, PROPERTY_HINT_RANGE, "-1,1,0.00001")); } if (mesh.is_valid()) { @@ -133,7 +133,7 @@ void MeshInstance3D::set_mesh(const Ref<Mesh> &p_mesh) { set_base(RID()); } - update_gizmo(); + update_gizmos(); notify_property_list_changed(); } @@ -356,7 +356,7 @@ Ref<Material> MeshInstance3D::get_active_material(int p_surface) const { void MeshInstance3D::_mesh_changed() { ERR_FAIL_COND(mesh.is_null()); surface_override_materials.resize(mesh->get_surface_count()); - update_gizmo(); + update_gizmos(); } void MeshInstance3D::create_debug_tangents() { diff --git a/scene/3d/navigation_agent_3d.cpp b/scene/3d/navigation_agent_3d.cpp index 64cfe4dca7..f890ceeb95 100644 --- a/scene/3d/navigation_agent_3d.cpp +++ b/scene/3d/navigation_agent_3d.cpp @@ -242,7 +242,7 @@ void NavigationAgent3D::_avoidance_done(Vector3 p_new_velocity) { } velocity_submitted = false; - emit_signal("velocity_computed", p_new_velocity); + emit_signal(SNAME("velocity_computed"), p_new_velocity); } TypedArray<String> NavigationAgent3D::get_configuration_warnings() const { @@ -296,7 +296,7 @@ void NavigationAgent3D::update_navigation() { navigation_path = NavigationServer3D::get_singleton()->map_get_path(agent_parent->get_world_3d()->get_navigation_map(), o, target_location, true); navigation_finished = false; nav_path_index = 0; - emit_signal("path_changed"); + emit_signal(SNAME("path_changed")); } if (navigation_path.size() == 0) { @@ -312,7 +312,7 @@ void NavigationAgent3D::update_navigation() { _check_distance_to_target(); nav_path_index -= 1; navigation_finished = true; - emit_signal("navigation_finished"); + emit_signal(SNAME("navigation_finished")); break; } } @@ -322,7 +322,7 @@ void NavigationAgent3D::update_navigation() { void NavigationAgent3D::_check_distance_to_target() { if (!target_reached) { if (distance_to_target() < target_desired_distance) { - emit_signal("target_reached"); + emit_signal(SNAME("target_reached")); target_reached = true; } } diff --git a/scene/3d/navigation_region_3d.cpp b/scene/3d/navigation_region_3d.cpp index 0afad62404..2976dad39d 100644 --- a/scene/3d/navigation_region_3d.cpp +++ b/scene/3d/navigation_region_3d.cpp @@ -59,7 +59,7 @@ void NavigationRegion3D::set_enabled(bool p_enabled) { } } - update_gizmo(); + update_gizmos(); } bool NavigationRegion3D::is_enabled() const { @@ -132,9 +132,9 @@ void NavigationRegion3D::set_navigation_mesh(const Ref<NavigationMesh> &p_navmes Object::cast_to<MeshInstance3D>(debug_view)->set_mesh(navmesh->get_debug_mesh()); } - emit_signal("navigation_mesh_changed"); + emit_signal(SNAME("navigation_mesh_changed")); - update_gizmo(); + update_gizmos(); update_configuration_warnings(); } @@ -153,11 +153,11 @@ void _bake_navigation_mesh(void *p_user_data) { Ref<NavigationMesh> nav_mesh = args->nav_region->get_navigation_mesh()->duplicate(); NavigationServer3D::get_singleton()->region_bake_navmesh(nav_mesh, args->nav_region); - args->nav_region->call_deferred("_bake_finished", nav_mesh); + args->nav_region->call_deferred(SNAME("_bake_finished"), nav_mesh); memdelete(args); } else { ERR_PRINT("Can't bake the navigation mesh if the `NavigationMesh` resource doesn't exist"); - args->nav_region->call_deferred("_bake_finished", Ref<NavigationMesh>()); + args->nav_region->call_deferred(SNAME("_bake_finished"), Ref<NavigationMesh>()); memdelete(args); } } @@ -174,7 +174,7 @@ void NavigationRegion3D::bake_navigation_mesh() { void NavigationRegion3D::_bake_finished(Ref<NavigationMesh> p_nav_mesh) { set_navigation_mesh(p_nav_mesh); bake_thread.wait_to_finish(); - emit_signal("bake_finished"); + emit_signal(SNAME("bake_finished")); } TypedArray<String> NavigationRegion3D::get_configuration_warnings() const { @@ -211,7 +211,7 @@ void NavigationRegion3D::_bind_methods() { } void NavigationRegion3D::_navigation_changed() { - update_gizmo(); + update_gizmos(); update_configuration_warnings(); } diff --git a/scene/3d/node_3d.cpp b/scene/3d/node_3d.cpp index d6c6ec75b4..0daee69ee5 100644 --- a/scene/3d/node_3d.cpp +++ b/scene/3d/node_3d.cpp @@ -76,7 +76,7 @@ Node3DGizmo::Node3DGizmo() { void Node3D::_notify_dirty() { #ifdef TOOLS_ENABLED - if ((data.gizmo.is_valid() || data.notify_transform) && !data.ignore_notification && !xform_change.in_list()) { + if ((!data.gizmos.is_empty() || data.notify_transform) && !data.ignore_notification && !xform_change.in_list()) { #else if (data.notify_transform && !data.ignore_notification && !xform_change.in_list()) { @@ -103,14 +103,14 @@ void Node3D::_propagate_transform_changed(Node3D *p_origin) { data.children_lock++; - for (List<Node3D *>::Element *E = data.children.front(); E; E = E->next()) { - if (E->get()->data.top_level_active) { + for (Node3D *&E : data.children) { + if (E->data.top_level_active) { continue; //don't propagate to a top_level } - E->get()->_propagate_transform_changed(p_origin); + E->_propagate_transform_changed(p_origin); } #ifdef TOOLS_ENABLED - if ((data.gizmo.is_valid() || data.notify_transform) && !data.ignore_notification && !xform_change.in_list()) { + if ((!data.gizmos.is_empty() || data.notify_transform) && !data.ignore_notification && !xform_change.in_list()) { #else if (data.notify_transform && !data.ignore_notification && !xform_change.in_list()) { #endif @@ -181,15 +181,14 @@ void Node3D::_notification(int p_what) { } #ifdef TOOLS_ENABLED if (Engine::get_singleton()->is_editor_hint() && get_tree()->is_node_being_edited(this)) { - //get_scene()->call_group(SceneMainLoop::GROUP_CALL_REALTIME,SceneStringNames::get_singleton()->_spatial_editor_group,SceneStringNames::get_singleton()->_request_gizmo,this); get_tree()->call_group_flags(0, SceneStringNames::get_singleton()->_spatial_editor_group, SceneStringNames::get_singleton()->_request_gizmo, this); - if (!data.gizmo_disabled) { - if (data.gizmo.is_valid()) { - data.gizmo->create(); + if (!data.gizmos_disabled) { + for (int i = 0; i < data.gizmos.size(); i++) { + data.gizmos.write[i]->create(); if (is_visible_in_tree()) { - data.gizmo->redraw(); + data.gizmos.write[i]->redraw(); } - data.gizmo->transform(); + data.gizmos.write[i]->transform(); } } } @@ -198,10 +197,7 @@ void Node3D::_notification(int p_what) { } break; case NOTIFICATION_EXIT_WORLD: { #ifdef TOOLS_ENABLED - if (data.gizmo.is_valid()) { - data.gizmo->free(); - data.gizmo.unref(); - } + clear_gizmos(); #endif if (get_script_instance()) { @@ -215,8 +211,8 @@ void Node3D::_notification(int p_what) { case NOTIFICATION_TRANSFORM_CHANGED: { #ifdef TOOLS_ENABLED - if (data.gizmo.is_valid()) { - data.gizmo->transform(); + for (int i = 0; i < data.gizmos.size(); i++) { + data.gizmos.write[i]->transform(); } #endif } break; @@ -368,80 +364,119 @@ Vector3 Node3D::get_scale() const { return data.scale; } -void Node3D::update_gizmo() { +void Node3D::update_gizmos() { #ifdef TOOLS_ENABLED if (!is_inside_world()) { return; } - if (!data.gizmo.is_valid()) { - get_tree()->call_group_flags(SceneTree::GROUP_CALL_REALTIME, SceneStringNames::get_singleton()->_spatial_editor_group, SceneStringNames::get_singleton()->_request_gizmo, this); + + if (data.gizmos.is_empty()) { + return; } - if (!data.gizmo.is_valid()) { + data.gizmos_dirty = true; + MessageQueue::get_singleton()->push_callable(callable_mp(this, &Node3D::_update_gizmos)); +#endif +} + +void Node3D::clear_subgizmo_selection() { +#ifdef TOOLS_ENABLED + if (!is_inside_world()) { return; } - if (data.gizmo_dirty) { + + if (data.gizmos.is_empty()) { return; } - data.gizmo_dirty = true; - MessageQueue::get_singleton()->push_call(this, "_update_gizmo"); + + if (Engine::get_singleton()->is_editor_hint() && get_tree()->is_node_being_edited(this)) { + get_tree()->call_group_flags(0, SceneStringNames::get_singleton()->_spatial_editor_group, SceneStringNames::get_singleton()->_clear_subgizmo_selection, this); + } #endif } -void Node3D::set_gizmo(const Ref<Node3DGizmo> &p_gizmo) { +void Node3D::add_gizmo(Ref<Node3DGizmo> p_gizmo) { #ifdef TOOLS_ENABLED - if (data.gizmo_disabled) { + if (data.gizmos_disabled || p_gizmo.is_null()) { return; } - if (data.gizmo.is_valid() && is_inside_world()) { - data.gizmo->free(); - } - data.gizmo = p_gizmo; - if (data.gizmo.is_valid() && is_inside_world()) { - data.gizmo->create(); + data.gizmos.push_back(p_gizmo); + + if (p_gizmo.is_valid() && is_inside_world()) { + p_gizmo->create(); if (is_visible_in_tree()) { - data.gizmo->redraw(); + p_gizmo->redraw(); } - data.gizmo->transform(); + p_gizmo->transform(); } +#endif +} + +void Node3D::remove_gizmo(Ref<Node3DGizmo> p_gizmo) { +#ifdef TOOLS_ENABLED + int idx = data.gizmos.find(p_gizmo); + if (idx != -1) { + p_gizmo->free(); + data.gizmos.remove(idx); + } +#endif +} + +void Node3D::clear_gizmos() { +#ifdef TOOLS_ENABLED + for (int i = 0; i < data.gizmos.size(); i++) { + data.gizmos.write[i]->free(); + } + data.gizmos.clear(); +#endif +} + +Array Node3D::get_gizmos_bind() const { + Array ret; + +#ifdef TOOLS_ENABLED + for (int i = 0; i < data.gizmos.size(); i++) { + ret.push_back(Variant(data.gizmos[i].ptr())); + } #endif + + return ret; } -Ref<Node3DGizmo> Node3D::get_gizmo() const { +Vector<Ref<Node3DGizmo>> Node3D::get_gizmos() const { #ifdef TOOLS_ENABLED - return data.gizmo; + return data.gizmos; #else - return Ref<Node3DGizmo>(); + return Vector<Ref<Node3DGizmo>>(); #endif } -void Node3D::_update_gizmo() { +void Node3D::_update_gizmos() { #ifdef TOOLS_ENABLED - if (!is_inside_world()) { + if (data.gizmos_disabled || !is_inside_world() || !data.gizmos_dirty) { return; } - data.gizmo_dirty = false; - if (data.gizmo.is_valid()) { + data.gizmos_dirty = false; + for (int i = 0; i < data.gizmos.size(); i++) { if (is_visible_in_tree()) { - data.gizmo->redraw(); + data.gizmos.write[i]->redraw(); } else { - data.gizmo->clear(); + data.gizmos.write[i]->clear(); } } #endif } #ifdef TOOLS_ENABLED -void Node3D::set_disable_gizmo(bool p_enabled) { - data.gizmo_disabled = p_enabled; - if (!p_enabled && data.gizmo.is_valid()) { - data.gizmo = Ref<Node3DGizmo>(); +void Node3D::set_disable_gizmos(bool p_enabled) { + data.gizmos_disabled = p_enabled; + if (!p_enabled) { + clear_gizmos(); } } - #endif void Node3D::set_disable_scale(bool p_enabled) { @@ -486,13 +521,13 @@ void Node3D::_propagate_visibility_changed() { notification(NOTIFICATION_VISIBILITY_CHANGED); emit_signal(SceneStringNames::get_singleton()->visibility_changed); #ifdef TOOLS_ENABLED - if (data.gizmo.is_valid()) { - _update_gizmo(); + if (!data.gizmos.is_empty()) { + data.gizmos_dirty = true; + _update_gizmos(); } #endif - for (List<Node3D *>::Element *E = data.children.front(); E; E = E->next()) { - Node3D *c = E->get(); + for (Node3D *c : data.children) { if (!c || !c->data.visible) { continue; } @@ -717,8 +752,7 @@ void Node3D::_update_visibility_parent(bool p_update_root) { RS::get_singleton()->instance_set_visibility_parent(vi->get_instance(), data.visibility_parent); } - for (List<Node3D *>::Element *E = data.children.front(); E; E = E->next()) { - Node3D *c = E->get(); + for (Node3D *c : data.children) { c->_update_visibility_parent(false); } } @@ -758,11 +792,11 @@ void Node3D::_bind_methods() { ClassDB::bind_method(D_METHOD("set_visibility_parent", "path"), &Node3D::set_visibility_parent); ClassDB::bind_method(D_METHOD("get_visibility_parent"), &Node3D::get_visibility_parent); - ClassDB::bind_method(D_METHOD("_update_gizmo"), &Node3D::_update_gizmo); - - ClassDB::bind_method(D_METHOD("update_gizmo"), &Node3D::update_gizmo); - ClassDB::bind_method(D_METHOD("set_gizmo", "gizmo"), &Node3D::set_gizmo); - ClassDB::bind_method(D_METHOD("get_gizmo"), &Node3D::get_gizmo); + ClassDB::bind_method(D_METHOD("update_gizmos"), &Node3D::update_gizmos); + ClassDB::bind_method(D_METHOD("add_gizmo", "gizmo"), &Node3D::add_gizmo); + ClassDB::bind_method(D_METHOD("get_gizmos"), &Node3D::get_gizmos_bind); + ClassDB::bind_method(D_METHOD("clear_gizmos"), &Node3D::clear_gizmos); + ClassDB::bind_method(D_METHOD("clear_subgizmo_selection"), &Node3D::clear_subgizmo_selection); ClassDB::bind_method(D_METHOD("set_visible", "visible"), &Node3D::set_visible); ClassDB::bind_method(D_METHOD("is_visible"), &Node3D::is_visible); @@ -813,7 +847,6 @@ void Node3D::_bind_methods() { ADD_GROUP("Visibility", ""); ADD_PROPERTY(PropertyInfo(Variant::BOOL, "visible"), "set_visible", "is_visible"); ADD_PROPERTY(PropertyInfo(Variant::NODE_PATH, "visibility_parent", PROPERTY_HINT_NODE_PATH_VALID_TYPES, "GeometryInstance3D"), "set_visibility_parent", "get_visibility_parent"); - ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "gizmo", PROPERTY_HINT_RESOURCE_TYPE, "Node3DGizmo", PROPERTY_USAGE_NONE), "set_gizmo", "get_gizmo"); ADD_SIGNAL(MethodInfo("visibility_changed")); } diff --git a/scene/3d/node_3d.h b/scene/3d/node_3d.h index fe6324c796..282f4805cc 100644 --- a/scene/3d/node_3d.h +++ b/scene/3d/node_3d.h @@ -90,16 +90,16 @@ class Node3D : public Node { bool disable_scale = false; #ifdef TOOLS_ENABLED - Ref<Node3DGizmo> gizmo; - bool gizmo_disabled = false; - bool gizmo_dirty = false; + Vector<Ref<Node3DGizmo>> gizmos; + bool gizmos_disabled = false; + bool gizmos_dirty = false; #endif } data; NodePath visibility_parent_path; - void _update_gizmo(); + void _update_gizmos(); void _notify_dirty(); void _propagate_transform_changed(Node3D *p_origin); @@ -154,10 +154,14 @@ public: void set_disable_scale(bool p_enabled); bool is_scale_disabled() const; - void set_disable_gizmo(bool p_enabled); - void update_gizmo(); - void set_gizmo(const Ref<Node3DGizmo> &p_gizmo); - Ref<Node3DGizmo> get_gizmo() const; + void set_disable_gizmos(bool p_enabled); + void update_gizmos(); + void clear_subgizmo_selection(); + Vector<Ref<Node3DGizmo>> get_gizmos() const; + Array get_gizmos_bind() const; + void add_gizmo(Ref<Node3DGizmo> p_gizmo); + void remove_gizmo(Ref<Node3DGizmo> p_gizmo); + void clear_gizmos(); _FORCE_INLINE_ bool is_inside_world() const { return data.inside_world; } diff --git a/scene/3d/occluder_instance_3d.cpp b/scene/3d/occluder_instance_3d.cpp index 7b736e689c..3d1a27911b 100644 --- a/scene/3d/occluder_instance_3d.cpp +++ b/scene/3d/occluder_instance_3d.cpp @@ -173,12 +173,12 @@ void OccluderInstance3D::set_occluder(const Ref<Occluder3D> &p_occluder) { set_base(RID()); } - update_gizmo(); + update_gizmos(); update_configuration_warnings(); } void OccluderInstance3D::_occluder_changed() { - update_gizmo(); + update_gizmos(); update_configuration_warnings(); } diff --git a/scene/3d/path_3d.cpp b/scene/3d/path_3d.cpp index de115b35e3..6af2e7f879 100644 --- a/scene/3d/path_3d.cpp +++ b/scene/3d/path_3d.cpp @@ -38,10 +38,10 @@ void Path3D::_notification(int p_what) { void Path3D::_curve_changed() { if (is_inside_tree() && Engine::get_singleton()->is_editor_hint()) { - update_gizmo(); + update_gizmos(); } if (is_inside_tree()) { - emit_signal("curve_changed"); + emit_signal(SNAME("curve_changed")); } // update the configuration warnings of all children of type PathFollow diff --git a/scene/3d/physics_body_3d.cpp b/scene/3d/physics_body_3d.cpp index e7482d35e7..93ecb2cd3a 100644 --- a/scene/3d/physics_body_3d.cpp +++ b/scene/3d/physics_body_3d.cpp @@ -78,8 +78,7 @@ TypedArray<PhysicsBody3D> PhysicsBody3D::get_collision_exceptions() { List<RID> exceptions; PhysicsServer3D::get_singleton()->body_get_collision_exceptions(get_rid(), &exceptions); Array ret; - for (List<RID>::Element *E = exceptions.front(); E; E = E->next()) { - RID body = E->get(); + for (const RID &body : exceptions) { ObjectID instance_id = PhysicsServer3D::get_singleton()->body_get_object_instance_id(body); Object *obj = ObjectDB::get_instance(instance_id); PhysicsBody3D *physics_body = Object::cast_to<PhysicsBody3D>(obj); @@ -125,11 +124,11 @@ bool PhysicsBody3D::move_and_collide(const Vector3 &p_motion, bool p_infinite_in // Restore direction of motion to be along original motion, // in order to avoid sliding due to recovery, // but only if collision depth is low enough to avoid tunneling. - real_t motion_length = p_motion.length(); - if (motion_length > CMP_EPSILON) { - real_t precision = CMP_EPSILON; + if (p_cancel_sliding) { + real_t motion_length = p_motion.length(); + real_t precision = 0.001; - if (colliding && p_cancel_sliding) { + if (colliding) { // Can't just use margin as a threshold because collision depth is calculated on unsafe motion, // so even in normal resting cases the depth can be a bit more than the margin. precision += motion_length * (r_result.collision_unsafe_fraction - r_result.collision_safe_fraction); @@ -140,16 +139,21 @@ bool PhysicsBody3D::move_and_collide(const Vector3 &p_motion, bool p_infinite_in } if (p_cancel_sliding) { + // When motion is null, recovery is the resulting motion. + Vector3 motion_normal; + if (motion_length > CMP_EPSILON) { + motion_normal = p_motion / motion_length; + } + // Check depth of recovery. - Vector3 motion_normal = p_motion / motion_length; - real_t dot = r_result.motion.dot(motion_normal); - Vector3 recovery = r_result.motion - motion_normal * dot; + real_t projected_length = r_result.motion.dot(motion_normal); + Vector3 recovery = r_result.motion - motion_normal * projected_length; real_t recovery_length = recovery.length(); // Fixes cases where canceling slide causes the motion to go too deep into the ground, - // Becauses we're only taking rest information into account and not general recovery. + // because we're only taking rest information into account and not general recovery. if (recovery_length < (real_t)p_margin + precision) { // Apply adjustment to motion. - r_result.motion = motion_normal * dot; + r_result.motion = motion_normal * projected_length; r_result.remainder = p_motion - r_result.motion; } } @@ -238,6 +242,13 @@ void StaticBody3D::set_kinematic_motion_enabled(bool p_enabled) { set_body_mode(PhysicsServer3D::BODY_MODE_STATIC); } +#ifdef TOOLS_ENABLED + if (Engine::get_singleton()->is_editor_hint()) { + update_configuration_warnings(); + return; + } +#endif + _update_kinematic_motion(); } @@ -255,6 +266,57 @@ void StaticBody3D::set_constant_linear_velocity(const Vector3 &p_vel) { } } +void StaticBody3D::set_sync_to_physics(bool p_enable) { + if (sync_to_physics == p_enable) { + return; + } + + sync_to_physics = p_enable; + +#ifdef TOOLS_ENABLED + if (Engine::get_singleton()->is_editor_hint()) { + update_configuration_warnings(); + return; + } +#endif + + if (kinematic_motion) { + _update_kinematic_motion(); + } +} + +bool StaticBody3D::is_sync_to_physics_enabled() const { + return sync_to_physics; +} + +void StaticBody3D::_direct_state_changed(Object *p_state) { + PhysicsDirectBodyState3D *state = Object::cast_to<PhysicsDirectBodyState3D>(p_state); + ERR_FAIL_NULL_MSG(state, "Method '_direct_state_changed' must receive a valid PhysicsDirectBodyState3D object as argument"); + + linear_velocity = state->get_linear_velocity(); + angular_velocity = state->get_angular_velocity(); + + if (!sync_to_physics) { + return; + } + + last_valid_transform = state->get_transform(); + set_notify_local_transform(false); + set_global_transform(last_valid_transform); + set_notify_local_transform(true); + _on_transform_changed(); +} + +TypedArray<String> StaticBody3D::get_configuration_warnings() const { + TypedArray<String> warnings = PhysicsBody3D::get_configuration_warnings(); + + if (sync_to_physics && !kinematic_motion) { + warnings.push_back(TTR("Sync to physics works only when kinematic motion is enabled.")); + } + + return warnings; +} + void StaticBody3D::set_constant_angular_velocity(const Vector3 &p_vel) { constant_angular_velocity = p_vel; @@ -283,6 +345,34 @@ Vector3 StaticBody3D::get_angular_velocity() const { void StaticBody3D::_notification(int p_what) { switch (p_what) { + case NOTIFICATION_ENTER_TREE: { + last_valid_transform = get_global_transform(); + } break; + + case NOTIFICATION_LOCAL_TRANSFORM_CHANGED: { + // Used by sync to physics, send the new transform to the physics... + Transform3D new_transform = get_global_transform(); + + real_t delta_time = get_physics_process_delta_time(); + new_transform.origin += constant_linear_velocity * delta_time; + + real_t ang_vel = constant_angular_velocity.length(); + if (!Math::is_zero_approx(ang_vel)) { + Vector3 ang_vel_axis = constant_angular_velocity / ang_vel; + Basis rot(ang_vel_axis, ang_vel * delta_time); + new_transform.basis = rot * new_transform.basis; + new_transform.orthonormalize(); + } + + PhysicsServer3D::get_singleton()->body_set_state(get_rid(), PhysicsServer3D::BODY_STATE_TRANSFORM, new_transform); + + // ... but then revert changes. + set_notify_local_transform(false); + set_global_transform(last_valid_transform); + set_notify_local_transform(true); + _on_transform_changed(); + } break; + case NOTIFICATION_INTERNAL_PHYSICS_PROCESS: { #ifdef TOOLS_ENABLED if (Engine::get_singleton()->is_editor_hint()) { @@ -292,9 +382,9 @@ void StaticBody3D::_notification(int p_what) { ERR_FAIL_COND(!kinematic_motion); - real_t delta_time = get_physics_process_delta_time(); - Transform3D new_transform = get_global_transform(); + + real_t delta_time = get_physics_process_delta_time(); new_transform.origin += constant_linear_velocity * delta_time; real_t ang_vel = constant_angular_velocity.length(); @@ -305,13 +395,18 @@ void StaticBody3D::_notification(int p_what) { new_transform.orthonormalize(); } - PhysicsServer3D::get_singleton()->body_set_state(get_rid(), PhysicsServer3D::BODY_STATE_TRANSFORM, new_transform); + if (sync_to_physics) { + // Propagate transform change to node. + set_global_transform(new_transform); + } else { + PhysicsServer3D::get_singleton()->body_set_state(get_rid(), PhysicsServer3D::BODY_STATE_TRANSFORM, new_transform); - // Propagate transform change to node. - set_ignore_transform_notification(true); - set_global_transform(new_transform); - set_ignore_transform_notification(false); - _on_transform_changed(); + // Propagate transform change to node. + set_ignore_transform_notification(true); + set_global_transform(new_transform); + set_ignore_transform_notification(false); + _on_transform_changed(); + } } break; } } @@ -328,22 +423,14 @@ void StaticBody3D::_bind_methods() { ClassDB::bind_method(D_METHOD("set_physics_material_override", "physics_material_override"), &StaticBody3D::set_physics_material_override); ClassDB::bind_method(D_METHOD("get_physics_material_override"), &StaticBody3D::get_physics_material_override); + ClassDB::bind_method(D_METHOD("set_sync_to_physics", "enable"), &StaticBody3D::set_sync_to_physics); + ClassDB::bind_method(D_METHOD("is_sync_to_physics_enabled"), &StaticBody3D::is_sync_to_physics_enabled); + ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "physics_material_override", PROPERTY_HINT_RESOURCE_TYPE, "PhysicsMaterial"), "set_physics_material_override", "get_physics_material_override"); ADD_PROPERTY(PropertyInfo(Variant::VECTOR3, "constant_linear_velocity"), "set_constant_linear_velocity", "get_constant_linear_velocity"); ADD_PROPERTY(PropertyInfo(Variant::VECTOR3, "constant_angular_velocity"), "set_constant_angular_velocity", "get_constant_angular_velocity"); ADD_PROPERTY(PropertyInfo(Variant::BOOL, "kinematic_motion"), "set_kinematic_motion_enabled", "is_kinematic_motion_enabled"); -} - -void StaticBody3D::_direct_state_changed(Object *p_state) { -#ifdef DEBUG_ENABLED - PhysicsDirectBodyState3D *state = Object::cast_to<PhysicsDirectBodyState3D>(p_state); - ERR_FAIL_NULL_MSG(state, "Method '_direct_state_changed' must receive a valid PhysicsDirectBodyState3D object as argument"); -#else - PhysicsDirectBodyState3D *state = (PhysicsDirectBodyState3D *)p_state; //trust it -#endif - - linear_velocity = state->get_linear_velocity(); - angular_velocity = state->get_angular_velocity(); + ADD_PROPERTY(PropertyInfo(Variant::BOOL, "sync_to_physics"), "set_sync_to_physics", "is_sync_to_physics_enabled"); } StaticBody3D::StaticBody3D() : @@ -367,18 +454,26 @@ void StaticBody3D::_update_kinematic_motion() { } #endif + if (kinematic_motion && sync_to_physics) { + set_only_update_transform_changes(true); + set_notify_local_transform(true); + } else { + set_only_update_transform_changes(false); + set_notify_local_transform(false); + } + + bool needs_physics_process = false; if (kinematic_motion) { PhysicsServer3D::get_singleton()->body_set_force_integration_callback(get_rid(), callable_mp(this, &StaticBody3D::_direct_state_changed)); if (!constant_angular_velocity.is_equal_approx(Vector3()) || !constant_linear_velocity.is_equal_approx(Vector3())) { - set_physics_process_internal(true); - return; + needs_physics_process = true; } } else { PhysicsServer3D::get_singleton()->body_set_force_integration_callback(get_rid(), Callable()); } - set_physics_process_internal(false); + set_physics_process_internal(needs_physics_process); } void RigidBody3D::_body_enter_tree(ObjectID p_id) { @@ -1001,6 +1096,15 @@ void CharacterBody3D::move_and_slide() { } } + Vector3 current_floor_velocity = floor_velocity; + if (on_floor && on_floor_body.is_valid()) { + //this approach makes sure there is less delay between the actual body velocity and the one we saved + PhysicsDirectBodyState3D *bs = PhysicsServer3D::get_singleton()->body_get_direct_state(on_floor_body); + if (bs) { + current_floor_velocity = bs->get_linear_velocity(); + } + } + // Hack in order to work with calling from _process as well as from _physics_process; calling from thread is risky Vector3 motion = (floor_velocity + linear_velocity) * (Engine::get_singleton()->is_in_physics_frame() ? get_physics_process_delta_time() : get_process_delta_time()); @@ -1012,8 +1116,9 @@ void CharacterBody3D::move_and_slide() { floor_normal = Vector3(); floor_velocity = Vector3(); - // No sliding on first attempt to keep motion stable when possible. - bool sliding_enabled = false; + // No sliding on first attempt to keep floor motion stable when possible, + // when stop on slope is enabled. + bool sliding_enabled = !stop_on_slope; for (int iteration = 0; iteration < max_slides; ++iteration) { PhysicsServer3D::MotionResult result; bool found_collision = false; @@ -1052,7 +1157,11 @@ void CharacterBody3D::move_and_slide() { if (stop_on_slope) { if ((body_velocity_normal + up_direction).length() < 0.01) { Transform3D gt = get_global_transform(); - gt.origin -= result.motion.slide(up_direction); + if (result.motion.length() > margin) { + gt.origin -= result.motion.slide(up_direction); + } else { + gt.origin -= result.motion; + } set_global_transform(gt); linear_velocity = Vector3(); return; @@ -1094,7 +1203,7 @@ void CharacterBody3D::move_and_slide() { // Apply snap. Transform3D gt = get_global_transform(); PhysicsServer3D::MotionResult result; - if (move_and_collide(snap, infinite_inertia, result, margin, false, true)) { + if (move_and_collide(snap, infinite_inertia, result, margin, false, true, false)) { bool apply = true; if (up_direction != Vector3()) { if (Math::acos(result.collision_normal.dot(up_direction)) <= floor_max_angle + FLOOR_ANGLE_THRESHOLD) { @@ -1105,7 +1214,11 @@ void CharacterBody3D::move_and_slide() { if (stop_on_slope) { // move and collide may stray the object a bit because of pre un-stucking, // so only ensure that motion happens on floor direction in this case. - result.motion = result.motion.project(up_direction); + if (result.motion.length() > margin) { + result.motion = result.motion.project(up_direction); + } else { + result.motion = Vector3(); + } } } else { apply = false; //snapped with floor direction, but did not snap to a floor, do not snap. @@ -2067,9 +2180,7 @@ bool PhysicalBone3D::_set(const StringName &p_name, const Variant &p_value) { if (joint_data) { if (joint_data->_set(p_name, p_value, joint)) { #ifdef TOOLS_ENABLED - if (get_gizmo().is_valid()) { - get_gizmo()->redraw(); - } + update_gizmos(); #endif return true; } @@ -2257,9 +2368,7 @@ void PhysicalBone3D::_update_joint_offset() { set_ignore_transform_notification(false); #ifdef TOOLS_ENABLED - if (get_gizmo().is_valid()) { - get_gizmo()->redraw(); - } + update_gizmos(); #endif } @@ -2426,9 +2535,7 @@ void PhysicalBone3D::set_joint_type(JointType p_joint_type) { #ifdef TOOLS_ENABLED notify_property_list_changed(); - if (get_gizmo().is_valid()) { - get_gizmo()->redraw(); - } + update_gizmos(); #endif } diff --git a/scene/3d/physics_body_3d.h b/scene/3d/physics_body_3d.h index 9d45ce3799..0ef9c78f3b 100644 --- a/scene/3d/physics_body_3d.h +++ b/scene/3d/physics_body_3d.h @@ -82,13 +82,16 @@ class StaticBody3D : public PhysicsBody3D { Ref<PhysicsMaterial> physics_material_override; bool kinematic_motion = false; + bool sync_to_physics = false; + + Transform3D last_valid_transform; + + void _direct_state_changed(Object *p_state); protected: void _notification(int p_what); static void _bind_methods(); - void _direct_state_changed(Object *p_state); - public: void set_physics_material_override(const Ref<PhysicsMaterial> &p_physics_material_override); Ref<PhysicsMaterial> get_physics_material_override() const; @@ -102,6 +105,8 @@ public: virtual Vector3 get_linear_velocity() const override; virtual Vector3 get_angular_velocity() const override; + virtual TypedArray<String> get_configuration_warnings() const override; + StaticBody3D(); private: @@ -111,6 +116,9 @@ private: void set_kinematic_motion_enabled(bool p_enabled); bool is_kinematic_motion_enabled() const; + + void set_sync_to_physics(bool p_enable); + bool is_sync_to_physics_enabled() const; }; class RigidBody3D : public PhysicsBody3D { @@ -251,7 +259,7 @@ public: void apply_impulse(const Vector3 &p_impulse, const Vector3 &p_position = Vector3()); void apply_torque_impulse(const Vector3 &p_impulse); - TypedArray<String> get_configuration_warnings() const override; + virtual TypedArray<String> get_configuration_warnings() const override; RigidBody3D(); ~RigidBody3D(); diff --git a/scene/3d/physics_joint_3d.cpp b/scene/3d/physics_joint_3d.cpp index 01f10c171f..59440bd1a8 100644 --- a/scene/3d/physics_joint_3d.cpp +++ b/scene/3d/physics_joint_3d.cpp @@ -348,7 +348,7 @@ void HingeJoint3D::set_param(Param p_param, real_t p_value) { PhysicsServer3D::get_singleton()->hinge_joint_set_param(get_joint(), PhysicsServer3D::HingeJointParam(p_param), p_value); } - update_gizmo(); + update_gizmos(); } real_t HingeJoint3D::get_param(Param p_param) const { @@ -363,7 +363,7 @@ void HingeJoint3D::set_flag(Flag p_flag, bool p_value) { PhysicsServer3D::get_singleton()->hinge_joint_set_flag(get_joint(), PhysicsServer3D::HingeJointFlag(p_flag), p_value); } - update_gizmo(); + update_gizmos(); } bool HingeJoint3D::get_flag(Flag p_flag) const { @@ -497,7 +497,7 @@ void SliderJoint3D::set_param(Param p_param, real_t p_value) { if (is_configured()) { PhysicsServer3D::get_singleton()->slider_joint_set_param(get_joint(), PhysicsServer3D::SliderJointParam(p_param), p_value); } - update_gizmo(); + update_gizmos(); } real_t SliderJoint3D::get_param(Param p_param) const { @@ -602,7 +602,7 @@ void ConeTwistJoint3D::set_param(Param p_param, real_t p_value) { PhysicsServer3D::get_singleton()->cone_twist_joint_set_param(get_joint(), PhysicsServer3D::ConeTwistJointParam(p_param), p_value); } - update_gizmo(); + update_gizmos(); } real_t ConeTwistJoint3D::get_param(Param p_param) const { @@ -857,7 +857,7 @@ void Generic6DOFJoint3D::set_param_x(Param p_param, real_t p_value) { PhysicsServer3D::get_singleton()->generic_6dof_joint_set_param(get_joint(), Vector3::AXIS_X, PhysicsServer3D::G6DOFJointAxisParam(p_param), p_value); } - update_gizmo(); + update_gizmos(); } real_t Generic6DOFJoint3D::get_param_x(Param p_param) const { @@ -871,7 +871,7 @@ void Generic6DOFJoint3D::set_param_y(Param p_param, real_t p_value) { if (is_configured()) { PhysicsServer3D::get_singleton()->generic_6dof_joint_set_param(get_joint(), Vector3::AXIS_Y, PhysicsServer3D::G6DOFJointAxisParam(p_param), p_value); } - update_gizmo(); + update_gizmos(); } real_t Generic6DOFJoint3D::get_param_y(Param p_param) const { @@ -885,7 +885,7 @@ void Generic6DOFJoint3D::set_param_z(Param p_param, real_t p_value) { if (is_configured()) { PhysicsServer3D::get_singleton()->generic_6dof_joint_set_param(get_joint(), Vector3::AXIS_Z, PhysicsServer3D::G6DOFJointAxisParam(p_param), p_value); } - update_gizmo(); + update_gizmos(); } real_t Generic6DOFJoint3D::get_param_z(Param p_param) const { @@ -899,7 +899,7 @@ void Generic6DOFJoint3D::set_flag_x(Flag p_flag, bool p_enabled) { if (is_configured()) { PhysicsServer3D::get_singleton()->generic_6dof_joint_set_flag(get_joint(), Vector3::AXIS_X, PhysicsServer3D::G6DOFJointAxisFlag(p_flag), p_enabled); } - update_gizmo(); + update_gizmos(); } bool Generic6DOFJoint3D::get_flag_x(Flag p_flag) const { @@ -913,7 +913,7 @@ void Generic6DOFJoint3D::set_flag_y(Flag p_flag, bool p_enabled) { if (is_configured()) { PhysicsServer3D::get_singleton()->generic_6dof_joint_set_flag(get_joint(), Vector3::AXIS_Y, PhysicsServer3D::G6DOFJointAxisFlag(p_flag), p_enabled); } - update_gizmo(); + update_gizmos(); } bool Generic6DOFJoint3D::get_flag_y(Flag p_flag) const { @@ -927,7 +927,7 @@ void Generic6DOFJoint3D::set_flag_z(Flag p_flag, bool p_enabled) { if (is_configured()) { PhysicsServer3D::get_singleton()->generic_6dof_joint_set_flag(get_joint(), Vector3::AXIS_Z, PhysicsServer3D::G6DOFJointAxisFlag(p_flag), p_enabled); } - update_gizmo(); + update_gizmos(); } bool Generic6DOFJoint3D::get_flag_z(Flag p_flag) const { diff --git a/scene/3d/proximity_group_3d.cpp b/scene/3d/proximity_group_3d.cpp index 9d9fea68b0..c8c61a9f00 100644 --- a/scene/3d/proximity_group_3d.cpp +++ b/scene/3d/proximity_group_3d.cpp @@ -128,9 +128,10 @@ void ProximityGroup3D::broadcast(String p_method, Variant p_parameters) { void ProximityGroup3D::_proximity_group_broadcast(String p_method, Variant p_parameters) { if (dispatch_mode == MODE_PROXY) { + ERR_FAIL_COND(!is_inside_tree()); get_parent()->call(p_method, p_parameters); } else { - emit_signal("broadcast", p_method, p_parameters); + emit_signal(SNAME("broadcast"), p_method, p_parameters); } } diff --git a/scene/3d/ray_cast_3d.cpp b/scene/3d/ray_cast_3d.cpp index dfab3d4a17..7356ce478b 100644 --- a/scene/3d/ray_cast_3d.cpp +++ b/scene/3d/ray_cast_3d.cpp @@ -37,7 +37,7 @@ void RayCast3D::set_target_position(const Vector3 &p_point) { target_position = p_point; - update_gizmo(); + update_gizmos(); if (Engine::get_singleton()->is_editor_hint()) { if (is_inside_tree()) { @@ -102,7 +102,7 @@ Vector3 RayCast3D::get_collision_normal() const { void RayCast3D::set_enabled(bool p_enabled) { enabled = p_enabled; - update_gizmo(); + update_gizmos(); if (is_inside_tree() && !Engine::get_singleton()->is_editor_hint()) { set_physics_process_internal(p_enabled); @@ -366,7 +366,7 @@ void RayCast3D::_update_debug_shape_vertices() { void RayCast3D::set_debug_shape_thickness(const float p_debug_shape_thickness) { debug_shape_thickness = p_debug_shape_thickness; - update_gizmo(); + update_gizmos(); if (Engine::get_singleton()->is_editor_hint()) { if (is_inside_tree()) { diff --git a/scene/3d/reflection_probe.cpp b/scene/3d/reflection_probe.cpp index c289fc4fd7..719dbedd94 100644 --- a/scene/3d/reflection_probe.cpp +++ b/scene/3d/reflection_probe.cpp @@ -101,7 +101,7 @@ void ReflectionProbe::set_extents(const Vector3 &p_extents) { RS::get_singleton()->reflection_probe_set_extents(probe, extents); RS::get_singleton()->reflection_probe_set_origin_offset(probe, origin_offset); - update_gizmo(); + update_gizmos(); } Vector3 ReflectionProbe::get_extents() const { @@ -119,7 +119,7 @@ void ReflectionProbe::set_origin_offset(const Vector3 &p_extents) { RS::get_singleton()->reflection_probe_set_extents(probe, extents); RS::get_singleton()->reflection_probe_set_origin_offset(probe, origin_offset); - update_gizmo(); + update_gizmos(); } Vector3 ReflectionProbe::get_origin_offset() const { diff --git a/scene/3d/skeleton_3d.cpp b/scene/3d/skeleton_3d.cpp index fa3b16935c..9ce4c37457 100644 --- a/scene/3d/skeleton_3d.cpp +++ b/scene/3d/skeleton_3d.cpp @@ -264,8 +264,8 @@ void Skeleton3D::_notification(int p_what) { b.global_pose_override_amount = 0.0; } - for (List<ObjectID>::Element *E = b.nodes_bound.front(); E; E = E->next()) { - Object *obj = ObjectDB::get_instance(E->get()); + for (const ObjectID &E : b.nodes_bound) { + Object *obj = ObjectDB::get_instance(E); ERR_CONTINUE(!obj); Node3D *node_3d = Object::cast_to<Node3D>(obj); ERR_CONTINUE(!node_3d); @@ -404,7 +404,7 @@ void Skeleton3D::add_bone(const String &p_name) { process_order_dirty = true; version++; _make_dirty(); - update_gizmo(); + update_gizmos(); } int Skeleton3D::find_bone(const String &p_name) const { @@ -524,8 +524,8 @@ void Skeleton3D::bind_child_node_to_bone(int p_bone, Node *p_node) { ObjectID id = p_node->get_instance_id(); - for (const List<ObjectID>::Element *E = bones[p_bone].nodes_bound.front(); E; E = E->next()) { - if (E->get() == id) { + for (const ObjectID &E : bones[p_bone].nodes_bound) { + if (E == id) { return; // already here } } @@ -544,8 +544,8 @@ void Skeleton3D::unbind_child_node_from_bone(int p_bone, Node *p_node) { void Skeleton3D::get_bound_child_nodes_to_bone(int p_bone, List<Node *> *p_bound) const { ERR_FAIL_INDEX(p_bone, bones.size()); - for (const List<ObjectID>::Element *E = bones[p_bone].nodes_bound.front(); E; E = E->next()) { - Object *obj = ObjectDB::get_instance(E->get()); + for (const ObjectID &E : bones[p_bone].nodes_bound) { + Object *obj = ObjectDB::get_instance(E); ERR_CONTINUE(!obj); p_bound->push_back(Object::cast_to<Node>(obj)); } diff --git a/scene/3d/soft_body_3d.cpp b/scene/3d/soft_body_3d.cpp index efd8a2b50c..a7ff0842d2 100644 --- a/scene/3d/soft_body_3d.cpp +++ b/scene/3d/soft_body_3d.cpp @@ -425,8 +425,8 @@ void SoftBody3D::_draw_soft_mesh() { /// Necessary in order to render the mesh correctly (Soft body nodes are in global space) simulation_started = true; - call_deferred("set_as_top_level", true); - call_deferred("set_transform", Transform3D()); + call_deferred(SNAME("set_as_top_level"), true); + call_deferred(SNAME("set_transform"), Transform3D()); } _update_physics_server(); @@ -592,8 +592,7 @@ Array SoftBody3D::get_collision_exceptions() { List<RID> exceptions; PhysicsServer3D::get_singleton()->soft_body_get_collision_exceptions(physics_rid, &exceptions); Array ret; - for (List<RID>::Element *E = exceptions.front(); E; E = E->next()) { - RID body = E->get(); + for (const RID &body : exceptions) { ObjectID instance_id = PhysicsServer3D::get_singleton()->body_get_object_instance_id(body); Object *obj = ObjectDB::get_instance(instance_id); PhysicsBody3D *physics_body = Object::cast_to<PhysicsBody3D>(obj); diff --git a/scene/3d/spring_arm_3d.cpp b/scene/3d/spring_arm_3d.cpp index 1911e14d54..5e9265b4c3 100644 --- a/scene/3d/spring_arm_3d.cpp +++ b/scene/3d/spring_arm_3d.cpp @@ -84,7 +84,7 @@ real_t SpringArm3D::get_length() const { void SpringArm3D::set_length(real_t p_length) { if (is_inside_tree() && (Engine::get_singleton()->is_editor_hint() || get_tree()->is_debugging_collisions_hint())) { - update_gizmo(); + update_gizmos(); } spring_length = p_length; diff --git a/scene/3d/sprite_3d.cpp b/scene/3d/sprite_3d.cpp index 13f8002721..a901920dbe 100644 --- a/scene/3d/sprite_3d.cpp +++ b/scene/3d/sprite_3d.cpp @@ -60,8 +60,8 @@ void SpriteBase3D::_propagate_color_changed() { color_dirty = true; _queue_update(); - for (List<SpriteBase3D *>::Element *E = children.front(); E; E = E->next()) { - E->get()->_propagate_color_changed(); + for (SpriteBase3D *&E : children) { + E->_propagate_color_changed(); } } @@ -174,7 +174,7 @@ void SpriteBase3D::_queue_update() { } triangle_mesh.unref(); - update_gizmo(); + update_gizmos(); pending_update = true; call_deferred(SceneStringNames::get_singleton()->_im_update); @@ -583,10 +583,10 @@ void Sprite3D::_draw() { aabb.expand_to(vtx); } - float v_uv[2] = { uvs[i].x, uvs[i].y }; + float v_uv[2] = { (float)uvs[i].x, (float)uvs[i].y }; memcpy(&attribute_write_buffer[i * attrib_stride + mesh_surface_offsets[RS::ARRAY_TEX_UV]], v_uv, 8); - float v_vertex[3] = { vtx.x, vtx.y, vtx.z }; + float v_vertex[3] = { (float)vtx.x, (float)vtx.y, (float)vtx.z }; memcpy(&vertex_write_buffer[i * vertex_stride + mesh_surface_offsets[RS::ARRAY_VERTEX]], &v_vertex, sizeof(float) * 3); memcpy(&vertex_write_buffer[i * vertex_stride + mesh_surface_offsets[RS::ARRAY_NORMAL]], &v_normal, 4); @@ -949,10 +949,10 @@ void AnimatedSprite3D::_draw() { aabb.expand_to(vtx); } - float v_uv[2] = { uvs[i].x, uvs[i].y }; + float v_uv[2] = { (float)uvs[i].x, (float)uvs[i].y }; memcpy(&attribute_write_buffer[i * attrib_stride + mesh_surface_offsets[RS::ARRAY_TEX_UV]], v_uv, 8); - float v_vertex[3] = { vtx.x, vtx.y, vtx.z }; + float v_vertex[3] = { (float)vtx.x, (float)vtx.y, (float)vtx.z }; memcpy(&vertex_write_buffer[i * vertex_stride + mesh_surface_offsets[RS::ARRAY_VERTEX]], &v_vertex, sizeof(float) * 3); memcpy(&vertex_write_buffer[i * vertex_stride + mesh_surface_offsets[RS::ARRAY_NORMAL]], &v_normal, 4); memcpy(&vertex_write_buffer[i * vertex_stride + mesh_surface_offsets[RS::ARRAY_TANGENT]], &v_tangent, 4); @@ -996,7 +996,7 @@ void AnimatedSprite3D::_validate_property(PropertyInfo &property) const { } property.hint_string += String(E->get()); - if (animation == E->get()) { + if (animation == E) { current_found = true; } } diff --git a/scene/3d/vehicle_body_3d.cpp b/scene/3d/vehicle_body_3d.cpp index b0e37b81a5..92c0e09947 100644 --- a/scene/3d/vehicle_body_3d.cpp +++ b/scene/3d/vehicle_body_3d.cpp @@ -149,7 +149,7 @@ void VehicleWheel3D::_update(PhysicsDirectBodyState3D *s) { void VehicleWheel3D::set_radius(real_t p_radius) { m_wheelRadius = p_radius; - update_gizmo(); + update_gizmos(); } real_t VehicleWheel3D::get_radius() const { @@ -158,7 +158,7 @@ real_t VehicleWheel3D::get_radius() const { void VehicleWheel3D::set_suspension_rest_length(real_t p_length) { m_suspensionRestLength = p_length; - update_gizmo(); + update_gizmos(); } real_t VehicleWheel3D::get_suspension_rest_length() const { diff --git a/scene/3d/visible_on_screen_notifier_3d.cpp b/scene/3d/visible_on_screen_notifier_3d.cpp index 682bcec449..6a80aa3f45 100644 --- a/scene/3d/visible_on_screen_notifier_3d.cpp +++ b/scene/3d/visible_on_screen_notifier_3d.cpp @@ -63,7 +63,7 @@ void VisibleOnScreenNotifier3D::set_aabb(const AABB &p_aabb) { RS::get_singleton()->visibility_notifier_set_aabb(get_base(), aabb); - update_gizmo(); + update_gizmos(); } AABB VisibleOnScreenNotifier3D::get_aabb() const { diff --git a/scene/3d/visual_instance_3d.cpp b/scene/3d/visual_instance_3d.cpp index bd47af8100..c155819159 100644 --- a/scene/3d/visual_instance_3d.cpp +++ b/scene/3d/visual_instance_3d.cpp @@ -153,6 +153,7 @@ Ref<Material> GeometryInstance3D::get_material_override() const { void GeometryInstance3D::set_visibility_range_begin(float p_dist) { visibility_range_begin = p_dist; RS::get_singleton()->instance_geometry_set_visibility_range(get_instance(), visibility_range_begin, visibility_range_end, visibility_range_begin_margin, visibility_range_end_margin); + update_configuration_warnings(); } float GeometryInstance3D::get_visibility_range_begin() const { @@ -162,6 +163,7 @@ float GeometryInstance3D::get_visibility_range_begin() const { void GeometryInstance3D::set_visibility_range_end(float p_dist) { visibility_range_end = p_dist; RS::get_singleton()->instance_geometry_set_visibility_range(get_instance(), visibility_range_begin, visibility_range_end, visibility_range_begin_margin, visibility_range_end_margin); + update_configuration_warnings(); } float GeometryInstance3D::get_visibility_range_end() const { @@ -238,8 +240,7 @@ bool GeometryInstance3D::_get(const StringName &p_name, Variant &r_ret) const { void GeometryInstance3D::_get_property_list(List<PropertyInfo> *p_list) const { List<PropertyInfo> pinfo; RS::get_singleton()->instance_geometry_get_shader_parameter_list(get_instance(), &pinfo); - for (List<PropertyInfo>::Element *E = pinfo.front(); E; E = E->next()) { - PropertyInfo pi = E->get(); + for (PropertyInfo &pi : pinfo) { bool has_def_value = false; Variant def_value = RS::get_singleton()->instance_geometry_get_shader_parameter_default_value(get_instance(), pi.name); if (def_value.get_type() != Variant::NIL) { @@ -352,6 +353,16 @@ bool GeometryInstance3D::is_ignoring_occlusion_culling() { return ignore_occlusion_culling; } +TypedArray<String> GeometryInstance3D::get_configuration_warnings() const { + TypedArray<String> warnings = Node::get_configuration_warnings(); + + if (!Math::is_zero_approx(visibility_range_end) && visibility_range_end <= visibility_range_begin) { + warnings.push_back(TTR("The GeometryInstance3D visibility range's End distance is set to a non-zero value, but is lower than the Begin distance.\nThis means the GeometryInstance3D will never be visible.\nTo resolve this, set the End distance to 0 or to a value greater than the Begin distance.")); + } + + return warnings; +} + void GeometryInstance3D::_bind_methods() { ClassDB::bind_method(D_METHOD("set_material_override", "material"), &GeometryInstance3D::set_material_override); ClassDB::bind_method(D_METHOD("get_material_override"), &GeometryInstance3D::get_material_override); diff --git a/scene/3d/visual_instance_3d.h b/scene/3d/visual_instance_3d.h index 2d5699859b..97aac149a1 100644 --- a/scene/3d/visual_instance_3d.h +++ b/scene/3d/visual_instance_3d.h @@ -177,6 +177,7 @@ public: void set_ignore_occlusion_culling(bool p_enabled); bool is_ignoring_occlusion_culling(); + TypedArray<String> get_configuration_warnings() const override; GeometryInstance3D(); }; diff --git a/scene/3d/voxel_gi.cpp b/scene/3d/voxel_gi.cpp index 3da59ac4c0..5cf7522667 100644 --- a/scene/3d/voxel_gi.cpp +++ b/scene/3d/voxel_gi.cpp @@ -265,7 +265,7 @@ Ref<VoxelGIData> VoxelGI::get_probe_data() const { void VoxelGI::set_subdiv(Subdiv p_subdiv) { ERR_FAIL_INDEX(p_subdiv, SUBDIV_MAX); subdiv = p_subdiv; - update_gizmo(); + update_gizmos(); } VoxelGI::Subdiv VoxelGI::get_subdiv() const { @@ -274,7 +274,7 @@ VoxelGI::Subdiv VoxelGI::get_subdiv() const { void VoxelGI::set_extents(const Vector3 &p_extents) { extents = p_extents; - update_gizmo(); + update_gizmos(); } Vector3 VoxelGI::get_extents() const { @@ -384,14 +384,14 @@ void VoxelGI::bake(Node *p_from_node, bool p_create_visual_debug) { int pmc = 0; - for (List<PlotMesh>::Element *E = mesh_list.front(); E; E = E->next()) { + for (PlotMesh &E : mesh_list) { if (bake_step_function) { bake_step_function(pmc, RTR("Plotting Meshes") + " " + itos(pmc) + "/" + itos(mesh_list.size())); } pmc++; - baker.plot_mesh(E->get().local_xform, E->get().mesh, E->get().instance_materials, E->get().override_material); + baker.plot_mesh(E.local_xform, E.mesh, E.instance_materials, E.override_material); } if (bake_step_function) { bake_step_function(pmc++, RTR("Finishing Plot")); diff --git a/scene/3d/voxelizer.cpp b/scene/3d/voxelizer.cpp index 12f055c01d..f1b9708f91 100644 --- a/scene/3d/voxelizer.cpp +++ b/scene/3d/voxelizer.cpp @@ -36,17 +36,17 @@ #include <stdlib.h> static _FORCE_INLINE_ void get_uv_and_normal(const Vector3 &p_pos, const Vector3 *p_vtx, const Vector2 *p_uv, const Vector3 *p_normal, Vector2 &r_uv, Vector3 &r_normal) { - if (p_pos.distance_squared_to(p_vtx[0]) < CMP_EPSILON2) { + if (p_pos.is_equal_approx(p_vtx[0])) { r_uv = p_uv[0]; r_normal = p_normal[0]; return; } - if (p_pos.distance_squared_to(p_vtx[1]) < CMP_EPSILON2) { + if (p_pos.is_equal_approx(p_vtx[1])) { r_uv = p_uv[1]; r_normal = p_normal[1]; return; } - if (p_pos.distance_squared_to(p_vtx[2]) < CMP_EPSILON2) { + if (p_pos.is_equal_approx(p_vtx[2])) { r_uv = p_uv[2]; r_normal = p_normal[2]; return; diff --git a/scene/3d/xr_nodes.cpp b/scene/3d/xr_nodes.cpp index a91e712b0b..b04c7e2858 100644 --- a/scene/3d/xr_nodes.cpp +++ b/scene/3d/xr_nodes.cpp @@ -207,10 +207,10 @@ void XRController3D::_notification(int p_what) { bool is_pressed = Input::get_singleton()->is_joy_button_pressed(joy_id, (JoyButton)i); if (!was_pressed && is_pressed) { - emit_signal("button_pressed", i); + emit_signal(SNAME("button_pressed"), i); button_states += mask; } else if (was_pressed && !is_pressed) { - emit_signal("button_released", i); + emit_signal(SNAME("button_released"), i); button_states -= mask; }; @@ -225,7 +225,7 @@ void XRController3D::_notification(int p_what) { Ref<Mesh> trackerMesh = tracker->get_mesh(); if (mesh != trackerMesh) { mesh = trackerMesh; - emit_signal("mesh_updated", mesh); + emit_signal(SNAME("mesh_updated"), mesh); } }; }; break; @@ -422,7 +422,7 @@ void XRAnchor3D::_notification(int p_what) { Ref<Mesh> trackerMesh = tracker->get_mesh(); if (mesh != trackerMesh) { mesh = trackerMesh; - emit_signal("mesh_updated", mesh); + emit_signal(SNAME("mesh_updated"), mesh); } }; }; break; diff --git a/scene/animation/animation_blend_space_1d.cpp b/scene/animation/animation_blend_space_1d.cpp index 3818c7edd1..6e5d964b76 100644 --- a/scene/animation/animation_blend_space_1d.cpp +++ b/scene/animation/animation_blend_space_1d.cpp @@ -54,7 +54,7 @@ void AnimationNodeBlendSpace1D::_validate_property(PropertyInfo &property) const } void AnimationNodeBlendSpace1D::_tree_changed() { - emit_signal("tree_changed"); + emit_signal(SNAME("tree_changed")); } void AnimationNodeBlendSpace1D::_bind_methods() { @@ -120,7 +120,7 @@ void AnimationNodeBlendSpace1D::add_blend_point(const Ref<AnimationRootNode> &p_ blend_points[p_at_index].node->connect("tree_changed", callable_mp(this, &AnimationNodeBlendSpace1D::_tree_changed), varray(), CONNECT_REFERENCE_COUNTED); blend_points_used++; - emit_signal("tree_changed"); + emit_signal(SNAME("tree_changed")); } void AnimationNodeBlendSpace1D::set_blend_point_position(int p_point, float p_position) { @@ -140,7 +140,7 @@ void AnimationNodeBlendSpace1D::set_blend_point_node(int p_point, const Ref<Anim blend_points[p_point].node = p_node; blend_points[p_point].node->connect("tree_changed", callable_mp(this, &AnimationNodeBlendSpace1D::_tree_changed), varray(), CONNECT_REFERENCE_COUNTED); - emit_signal("tree_changed"); + emit_signal(SNAME("tree_changed")); } float AnimationNodeBlendSpace1D::get_blend_point_position(int p_point) const { @@ -164,7 +164,7 @@ void AnimationNodeBlendSpace1D::remove_blend_point(int p_point) { } blend_points_used--; - emit_signal("tree_changed"); + emit_signal(SNAME("tree_changed")); } int AnimationNodeBlendSpace1D::get_blend_point_count() const { diff --git a/scene/animation/animation_blend_space_2d.cpp b/scene/animation/animation_blend_space_2d.cpp index 0871423fbd..d88a9badf4 100644 --- a/scene/animation/animation_blend_space_2d.cpp +++ b/scene/animation/animation_blend_space_2d.cpp @@ -84,7 +84,7 @@ void AnimationNodeBlendSpace2D::add_blend_point(const Ref<AnimationRootNode> &p_ _queue_auto_triangles(); - emit_signal("tree_changed"); + emit_signal(SNAME("tree_changed")); } void AnimationNodeBlendSpace2D::set_blend_point_position(int p_point, const Vector2 &p_position) { @@ -103,7 +103,7 @@ void AnimationNodeBlendSpace2D::set_blend_point_node(int p_point, const Ref<Anim blend_points[p_point].node = p_node; blend_points[p_point].node->connect("tree_changed", callable_mp(this, &AnimationNodeBlendSpace2D::_tree_changed), varray(), CONNECT_REFERENCE_COUNTED); - emit_signal("tree_changed"); + emit_signal(SNAME("tree_changed")); } Vector2 AnimationNodeBlendSpace2D::get_blend_point_position(int p_point) const { @@ -143,7 +143,7 @@ void AnimationNodeBlendSpace2D::remove_blend_point(int p_point) { blend_points[i] = blend_points[i + 1]; } blend_points_used--; - emit_signal("tree_changed"); + emit_signal(SNAME("tree_changed")); } int AnimationNodeBlendSpace2D::get_blend_point_count() const { @@ -321,7 +321,7 @@ void AnimationNodeBlendSpace2D::_queue_auto_triangles() { } trianges_dirty = true; - call_deferred("_update_triangles"); + call_deferred(SNAME("_update_triangles")); } void AnimationNodeBlendSpace2D::_update_triangles() { @@ -332,7 +332,7 @@ void AnimationNodeBlendSpace2D::_update_triangles() { trianges_dirty = false; triangles.clear(); if (blend_points_used < 3) { - emit_signal("triangles_updated"); + emit_signal(SNAME("triangles_updated")); return; } @@ -347,7 +347,7 @@ void AnimationNodeBlendSpace2D::_update_triangles() { for (int i = 0; i < triangles.size(); i++) { add_triangle(triangles[i].points[0], triangles[i].points[1], triangles[i].points[2]); } - emit_signal("triangles_updated"); + emit_signal(SNAME("triangles_updated")); } Vector2 AnimationNodeBlendSpace2D::get_closest_point(const Vector2 &p_point) { @@ -387,19 +387,19 @@ Vector2 AnimationNodeBlendSpace2D::get_closest_point(const Vector2 &p_point) { } void AnimationNodeBlendSpace2D::_blend_triangle(const Vector2 &p_pos, const Vector2 *p_points, float *r_weights) { - if (p_pos.distance_squared_to(p_points[0]) < CMP_EPSILON2) { + if (p_pos.is_equal_approx(p_points[0])) { r_weights[0] = 1; r_weights[1] = 0; r_weights[2] = 0; return; } - if (p_pos.distance_squared_to(p_points[1]) < CMP_EPSILON2) { + if (p_pos.is_equal_approx(p_points[1])) { r_weights[0] = 0; r_weights[1] = 1; r_weights[2] = 0; return; } - if (p_pos.distance_squared_to(p_points[2]) < CMP_EPSILON2) { + if (p_pos.is_equal_approx(p_points[2])) { r_weights[0] = 0; r_weights[1] = 0; r_weights[2] = 1; @@ -586,7 +586,7 @@ Ref<AnimationNode> AnimationNodeBlendSpace2D::get_child_by_name(const StringName } void AnimationNodeBlendSpace2D::_tree_changed() { - emit_signal("tree_changed"); + emit_signal(SNAME("tree_changed")); } void AnimationNodeBlendSpace2D::set_blend_mode(BlendMode p_blend_mode) { diff --git a/scene/animation/animation_blend_tree.cpp b/scene/animation/animation_blend_tree.cpp index 6a988042b5..4bddae3b14 100644 --- a/scene/animation/animation_blend_tree.cpp +++ b/scene/animation/animation_blend_tree.cpp @@ -816,7 +816,7 @@ void AnimationNodeBlendTree::add_node(const StringName &p_name, Ref<AnimationNod nodes[p_name] = n; emit_changed(); - emit_signal("tree_changed"); + emit_signal(SNAME("tree_changed")); p_node->connect("tree_changed", callable_mp(this, &AnimationNodeBlendTree::_tree_changed), varray(), CONNECT_REFERENCE_COUNTED); p_node->connect("changed", callable_mp(this, &AnimationNodeBlendTree::_node_changed), varray(p_name), CONNECT_REFERENCE_COUNTED); @@ -896,7 +896,7 @@ void AnimationNodeBlendTree::remove_node(const StringName &p_name) { } emit_changed(); - emit_signal("tree_changed"); + emit_signal(SNAME("tree_changed")); } void AnimationNodeBlendTree::rename_node(const StringName &p_name, const StringName &p_new_name) { @@ -921,7 +921,7 @@ void AnimationNodeBlendTree::rename_node(const StringName &p_name, const StringN //connection must be done with new name nodes[p_new_name].node->connect("changed", callable_mp(this, &AnimationNodeBlendTree::_node_changed), varray(p_new_name), CONNECT_REFERENCE_COUNTED); - emit_signal("tree_changed"); + emit_signal(SNAME("tree_changed")); } void AnimationNodeBlendTree::connect_node(const StringName &p_input_node, int p_input_index, const StringName &p_output_node) { @@ -1089,10 +1089,10 @@ bool AnimationNodeBlendTree::_get(const StringName &p_name, Variant &r_ret) cons conns.resize(nc.size() * 3); int idx = 0; - for (List<NodeConnection>::Element *E = nc.front(); E; E = E->next()) { - conns[idx * 3 + 0] = E->get().input_node; - conns[idx * 3 + 1] = E->get().input_index; - conns[idx * 3 + 2] = E->get().output_node; + for (const NodeConnection &E : nc) { + conns[idx * 3 + 0] = E.input_node; + conns[idx * 3 + 1] = E.input_index; + conns[idx * 3 + 2] = E.output_node; idx++; } @@ -1110,8 +1110,8 @@ void AnimationNodeBlendTree::_get_property_list(List<PropertyInfo> *p_list) cons } names.sort_custom<StringName::AlphCompare>(); - for (List<StringName>::Element *E = names.front(); E; E = E->next()) { - String name = E->get(); + for (const StringName &E : names) { + String name = E; if (name != "output") { p_list->push_back(PropertyInfo(Variant::OBJECT, "nodes/" + name + "/node", PROPERTY_HINT_RESOURCE_TYPE, "AnimationNode", PROPERTY_USAGE_NOEDITOR)); } @@ -1125,11 +1125,11 @@ void AnimationNodeBlendTree::reset_state() { graph_offset = Vector2(); nodes.clear(); emit_changed(); - emit_signal("tree_changed"); + emit_signal(SNAME("tree_changed")); } void AnimationNodeBlendTree::_tree_changed() { - emit_signal("tree_changed"); + emit_signal(SNAME("tree_changed")); } void AnimationNodeBlendTree::_node_changed(const StringName &p_node) { diff --git a/scene/animation/animation_cache.cpp b/scene/animation/animation_cache.cpp index b8980fd56b..56743007e4 100644 --- a/scene/animation/animation_cache.cpp +++ b/scene/animation/animation_cache.cpp @@ -252,8 +252,8 @@ void AnimationCache::set_all(float p_time, float p_delta) { List<int> indices; animation->value_track_get_key_indices(i, p_time, p_delta, &indices); - for (List<int>::Element *E = indices.front(); E; E = E->next()) { - Variant v = animation->track_get_key_value(i, E->get()); + for (int &E : indices) { + Variant v = animation->track_get_key_value(i, E); set_track_value(i, v); } } @@ -263,9 +263,9 @@ void AnimationCache::set_all(float p_time, float p_delta) { List<int> indices; animation->method_track_get_key_indices(i, p_time, p_delta, &indices); - for (List<int>::Element *E = indices.front(); E; E = E->next()) { - Vector<Variant> args = animation->method_track_get_params(i, E->get()); - StringName name = animation->method_track_get_name(i, E->get()); + for (int &E : indices) { + Vector<Variant> args = animation->method_track_get_params(i, E); + StringName name = animation->method_track_get_name(i, E); Callable::CallError err; if (!args.size()) { diff --git a/scene/animation/animation_node_state_machine.cpp b/scene/animation/animation_node_state_machine.cpp index f494f5c163..bf53b554bf 100644 --- a/scene/animation/animation_node_state_machine.cpp +++ b/scene/animation/animation_node_state_machine.cpp @@ -57,7 +57,7 @@ void AnimationNodeStateMachineTransition::set_advance_condition(const StringName } else { advance_condition_name = StringName(); } - emit_signal("advance_condition_changed"); + emit_signal(SNAME("advance_condition_changed")); } StringName AnimationNodeStateMachineTransition::get_advance_condition() const { @@ -512,8 +512,8 @@ void AnimationNodeStateMachine::get_parameter_list(List<PropertyInfo> *r_list) c } advance_conditions.sort_custom<StringName::AlphCompare>(); - for (List<StringName>::Element *E = advance_conditions.front(); E; E = E->next()) { - r_list->push_back(PropertyInfo(Variant::BOOL, E->get())); + for (const StringName &E : advance_conditions) { + r_list->push_back(PropertyInfo(Variant::BOOL, E)); } } @@ -539,7 +539,7 @@ void AnimationNodeStateMachine::add_node(const StringName &p_name, Ref<Animation states[p_name] = state; emit_changed(); - emit_signal("tree_changed"); + emit_signal(SNAME("tree_changed")); p_node->connect("tree_changed", callable_mp(this, &AnimationNodeStateMachine::_tree_changed), varray(), CONNECT_REFERENCE_COUNTED); } @@ -559,7 +559,7 @@ void AnimationNodeStateMachine::replace_node(const StringName &p_name, Ref<Anima states[p_name].node = p_node; emit_changed(); - emit_signal("tree_changed"); + emit_signal(SNAME("tree_changed")); p_node->connect("tree_changed", callable_mp(this, &AnimationNodeStateMachine::_tree_changed), varray(), CONNECT_REFERENCE_COUNTED); } @@ -636,7 +636,7 @@ void AnimationNodeStateMachine::remove_node(const StringName &p_name) { }*/ emit_changed(); - emit_signal("tree_changed"); + emit_signal(SNAME("tree_changed")); } void AnimationNodeStateMachine::rename_node(const StringName &p_name, const StringName &p_new_name) { @@ -669,7 +669,7 @@ void AnimationNodeStateMachine::rename_node(const StringName &p_name, const Stri }*/ //path.clear(); //clear path - emit_signal("tree_changed"); + emit_signal(SNAME("tree_changed")); } void AnimationNodeStateMachine::get_node_list(List<StringName> *r_nodes) const { @@ -679,8 +679,8 @@ void AnimationNodeStateMachine::get_node_list(List<StringName> *r_nodes) const { } nodes.sort_custom<StringName::AlphCompare>(); - for (List<StringName>::Element *E = nodes.front(); E; E = E->next()) { - r_nodes->push_back(E->get()); + for (const StringName &E : nodes) { + r_nodes->push_back(E); } } @@ -902,8 +902,7 @@ void AnimationNodeStateMachine::_get_property_list(List<PropertyInfo> *p_list) c } names.sort_custom<StringName::AlphCompare>(); - for (List<StringName>::Element *E = names.front(); E; E = E->next()) { - String name = E->get(); + for (const StringName &name : names) { p_list->push_back(PropertyInfo(Variant::OBJECT, "states/" + name + "/node", PROPERTY_HINT_RESOURCE_TYPE, "AnimationNode", PROPERTY_USAGE_NOEDITOR)); p_list->push_back(PropertyInfo(Variant::VECTOR2, "states/" + name + "/position", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_NOEDITOR)); } @@ -923,7 +922,7 @@ void AnimationNodeStateMachine::reset_state() { graph_offset = Vector2(); emit_changed(); - emit_signal("tree_changed"); + emit_signal(SNAME("tree_changed")); } void AnimationNodeStateMachine::set_node_position(const StringName &p_name, const Vector2 &p_position) { @@ -937,7 +936,7 @@ Vector2 AnimationNodeStateMachine::get_node_position(const StringName &p_name) c } void AnimationNodeStateMachine::_tree_changed() { - emit_signal("tree_changed"); + emit_signal(SNAME("tree_changed")); } void AnimationNodeStateMachine::_bind_methods() { diff --git a/scene/animation/animation_player.cpp b/scene/animation/animation_player.cpp index 6154eef3cf..67b6205a65 100644 --- a/scene/animation/animation_player.cpp +++ b/scene/animation/animation_player.cpp @@ -176,8 +176,8 @@ void AnimationPlayer::_get_property_list(List<PropertyInfo> *p_list) const { anim_names.sort(); - for (List<PropertyInfo>::Element *E = anim_names.front(); E; E = E->next()) { - p_list->push_back(E->get()); + for (const PropertyInfo &E : anim_names) { + p_list->push_back(E); } p_list->push_back(PropertyInfo(Variant::ARRAY, "blend_times", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_NOEDITOR | PROPERTY_USAGE_INTERNAL)); @@ -485,8 +485,8 @@ void AnimationPlayer::_animation_process_animation(AnimationData *p_anim, float List<int> indices; a->value_track_get_key_indices(i, p_time, p_delta, &indices); - for (List<int>::Element *F = indices.front(); F; F = F->next()) { - Variant value = a->track_get_key_value(i, F->get()); + for (int &F : indices) { + Variant value = a->track_get_key_value(i, F); switch (pa->special) { case SP_NONE: { bool valid; @@ -544,9 +544,9 @@ void AnimationPlayer::_animation_process_animation(AnimationData *p_anim, float a->method_track_get_key_indices(i, p_time, p_delta, &indices); - for (List<int>::Element *E = indices.front(); E; E = E->next()) { - StringName method = a->method_track_get_name(i, E->get()); - Vector<Variant> params = a->method_track_get_params(i, E->get()); + for (int &E : indices) { + StringName method = a->method_track_get_name(i, E); + Vector<Variant> params = a->method_track_get_params(i, E); int s = params.size(); @@ -557,6 +557,7 @@ void AnimationPlayer::_animation_process_animation(AnimationData *p_anim, float } #endif + static_assert(VARIANT_ARG_MAX == 8, "This code needs to be updated if VARIANT_ARG_MAX != 8"); if (can_call) { if (method_call_mode == ANIMATION_METHOD_CALL_DEFERRED) { MessageQueue::get_singleton()->push_call( @@ -566,7 +567,10 @@ void AnimationPlayer::_animation_process_animation(AnimationData *p_anim, float s >= 2 ? params[1] : Variant(), s >= 3 ? params[2] : Variant(), s >= 4 ? params[3] : Variant(), - s >= 5 ? params[4] : Variant()); + s >= 5 ? params[4] : Variant(), + s >= 6 ? params[5] : Variant(), + s >= 7 ? params[6] : Variant(), + s >= 8 ? params[7] : Variant()); } else { nc->node->call( method, @@ -574,7 +578,10 @@ void AnimationPlayer::_animation_process_animation(AnimationData *p_anim, float s >= 2 ? params[1] : Variant(), s >= 3 ? params[2] : Variant(), s >= 4 ? params[3] : Variant(), - s >= 5 ? params[4] : Variant()); + s >= 5 ? params[4] : Variant(), + s >= 6 ? params[5] : Variant(), + s >= 7 ? params[6] : Variant(), + s >= 8 ? params[7] : Variant()); } } } @@ -1069,8 +1076,8 @@ void AnimationPlayer::get_animation_list(List<StringName> *p_animations) const { anims.sort(); - for (List<String>::Element *E = anims.front(); E; E = E->next()) { - p_animations->push_back(E->get()); + for (const String &E : anims) { + p_animations->push_back(E); } } @@ -1111,8 +1118,8 @@ void AnimationPlayer::queue(const StringName &p_name) { Vector<String> AnimationPlayer::get_queue() { Vector<String> ret; - for (List<StringName>::Element *E = queued.front(); E; E = E->next()) { - ret.push_back(E->get()); + for (const StringName &E : queued) { + ret.push_back(E); } return ret; @@ -1325,7 +1332,7 @@ float AnimationPlayer::get_current_animation_length() const { void AnimationPlayer::_animation_changed() { clear_caches(); - emit_signal("caches_cleared"); + emit_signal(SNAME("caches_cleared")); if (is_playing()) { playback.seeked = true; //need to restart stuff, like audio } @@ -1495,8 +1502,8 @@ void AnimationPlayer::get_argument_options(const StringName &p_function, int p_i if (p_idx == 0 && (p_function == "play" || p_function == "play_backwards" || p_function == "remove_animation" || p_function == "has_animation" || p_function == "queue")) { List<StringName> al; get_animation_list(&al); - for (List<StringName>::Element *E = al.front(); E; E = E->next()) { - r_options->push_back(quote_style + String(E->get()) + quote_style); + for (const StringName &E : al) { + r_options->push_back(quote_style + String(E) + quote_style); } } Node::get_argument_options(p_function, p_idx, r_options); diff --git a/scene/animation/animation_tree.cpp b/scene/animation/animation_tree.cpp index 1e07f83d09..e623309888 100644 --- a/scene/animation/animation_tree.cpp +++ b/scene/animation/animation_tree.cpp @@ -76,10 +76,10 @@ void AnimationNode::get_child_nodes(List<ChildNode> *r_child_nodes) { Dictionary cn = get_script_instance()->call("_get_child_nodes"); List<Variant> keys; cn.get_key_list(&keys); - for (List<Variant>::Element *E = keys.front(); E; E = E->next()) { + for (const Variant &E : keys) { ChildNode child; - child.name = E->get(); - child.node = cn[E->get()]; + child.name = E; + child.node = cn[E]; r_child_nodes->push_back(child); } } @@ -137,7 +137,7 @@ void AnimationNode::make_invalid(const String &p_reason) { if (state->invalid_reasons != String()) { state->invalid_reasons += "\n"; } - state->invalid_reasons += "- " + p_reason; + state->invalid_reasons += String::utf8("• ") + p_reason; } float AnimationNode::blend_input(int p_input, float p_time, bool p_seek, float p_blend, FilterAction p_filter, bool p_optimize) { @@ -536,8 +536,8 @@ bool AnimationTree::_update_caches(AnimationPlayer *player) { List<StringName> sname; player->get_animation_list(&sname); - for (List<StringName>::Element *E = sname.front(); E; E = E->next()) { - Ref<Animation> anim = player->get_animation(E->get()); + for (const StringName &E : sname) { + Ref<Animation> anim = player->get_animation(E); for (int i = 0; i < anim->get_track_count(); i++) { NodePath path = anim->track_get_path(i); Animation::TrackType track_type = anim->track_get_type(i); @@ -561,7 +561,7 @@ bool AnimationTree::_update_caches(AnimationPlayer *player) { Node *child = parent->get_node_and_resource(path, resource, leftover_path); if (!child) { - ERR_PRINT("AnimationTree: '" + String(E->get()) + "', couldn't resolve track: '" + String(path) + "'"); + ERR_PRINT("AnimationTree: '" + String(E) + "', couldn't resolve track: '" + String(path) + "'"); continue; } @@ -590,7 +590,7 @@ bool AnimationTree::_update_caches(AnimationPlayer *player) { Node3D *node_3d = Object::cast_to<Node3D>(child); if (!node_3d) { - ERR_PRINT("AnimationTree: '" + String(E->get()) + "', transform track does not point to Node3D: '" + String(path) + "'"); + ERR_PRINT("AnimationTree: '" + String(E) + "', transform track does not point to Node3D: '" + String(path) + "'"); continue; } @@ -816,9 +816,7 @@ void AnimationTree::_process_graph(float p_delta) { { bool can_call = is_inside_tree() && !Engine::get_singleton()->is_editor_hint(); - for (List<AnimationNode::AnimationState>::Element *E = state.animation_states.front(); E; E = E->next()) { - const AnimationNode::AnimationState &as = E->get(); - + for (const AnimationNode::AnimationState &as : state.animation_states) { Ref<Animation> a = as.animation; float time = as.time; float delta = as.delta; @@ -962,8 +960,8 @@ void AnimationTree::_process_graph(float p_delta) { List<int> indices; a->value_track_get_key_indices(i, time, delta, &indices); - for (List<int>::Element *F = indices.front(); F; F = F->next()) { - Variant value = a->track_get_key_value(i, F->get()); + for (int &F : indices) { + Variant value = a->track_get_key_value(i, F); t->object->set_indexed(t->subpath, value); } } @@ -979,12 +977,13 @@ void AnimationTree::_process_graph(float p_delta) { a->method_track_get_key_indices(i, time, delta, &indices); - for (List<int>::Element *F = indices.front(); F; F = F->next()) { - StringName method = a->method_track_get_name(i, F->get()); - Vector<Variant> params = a->method_track_get_params(i, F->get()); + for (int &F : indices) { + StringName method = a->method_track_get_name(i, F); + Vector<Variant> params = a->method_track_get_params(i, F); int s = params.size(); + static_assert(VARIANT_ARG_MAX == 8, "This code needs to be updated if VARIANT_ARG_MAX != 8"); ERR_CONTINUE(s > VARIANT_ARG_MAX); if (can_call) { t->object->call_deferred( @@ -993,7 +992,10 @@ void AnimationTree::_process_graph(float p_delta) { s >= 2 ? params[1] : Variant(), s >= 3 ? params[2] : Variant(), s >= 4 ? params[3] : Variant(), - s >= 5 ? params[4] : Variant()); + s >= 5 ? params[4] : Variant(), + s >= 6 ? params[5] : Variant(), + s >= 7 ? params[6] : Variant(), + s >= 8 ? params[7] : Variant()); } } @@ -1327,7 +1329,7 @@ void AnimationTree::_tree_changed() { return; } - call_deferred("_update_properties"); + call_deferred(SNAME("_update_properties")); properties_dirty = true; } @@ -1351,9 +1353,7 @@ void AnimationTree::_update_properties_for_node(const String &p_base_path, Ref<A List<PropertyInfo> plist; node->get_parameter_list(&plist); - for (List<PropertyInfo>::Element *E = plist.front(); E; E = E->next()) { - PropertyInfo pinfo = E->get(); - + for (PropertyInfo &pinfo : plist) { StringName key = pinfo.name; if (!property_map.has(p_base_path + key)) { @@ -1369,8 +1369,8 @@ void AnimationTree::_update_properties_for_node(const String &p_base_path, Ref<A List<AnimationNode::ChildNode> children; node->get_child_nodes(&children); - for (List<AnimationNode::ChildNode>::Element *E = children.front(); E; E = E->next()) { - _update_properties_for_node(p_base_path + E->get().name + "/", E->get().node); + for (const AnimationNode::ChildNode &E : children) { + _update_properties_for_node(p_base_path + E.name + "/", E.node); } } @@ -1424,17 +1424,17 @@ void AnimationTree::_get_property_list(List<PropertyInfo> *p_list) const { const_cast<AnimationTree *>(this)->_update_properties(); } - for (const List<PropertyInfo>::Element *E = properties.front(); E; E = E->next()) { - p_list->push_back(E->get()); + for (const PropertyInfo &E : properties) { + p_list->push_back(E); } } void AnimationTree::rename_parameter(const String &p_base, const String &p_new_base) { //rename values first - for (const List<PropertyInfo>::Element *E = properties.front(); E; E = E->next()) { - if (E->get().name.begins_with(p_base)) { - String new_name = E->get().name.replace_first(p_base, p_new_base); - property_map[new_name] = property_map[E->get().name]; + for (const PropertyInfo &E : properties) { + if (E.name.begins_with(p_base)) { + String new_name = E.name.replace_first(p_base, p_new_base); + property_map[new_name] = property_map[E.name]; } } diff --git a/scene/animation/tween.cpp b/scene/animation/tween.cpp index 7bf616e602..a57e986877 100644 --- a/scene/animation/tween.cpp +++ b/scene/animation/tween.cpp @@ -46,8 +46,8 @@ void Tween::start_tweeners() { ERR_FAIL_MSG("Tween without commands, aborting."); } - for (List<Ref<Tweener>>::Element *E = tweeners.write[current_step].front(); E; E = E->next()) { - E->get()->start(); + for (Ref<Tweener> &tweener : tweeners.write[current_step]) { + tweener->start(); } } @@ -253,18 +253,18 @@ bool Tween::step(float p_delta) { float step_delta = rem_delta; step_active = false; - for (List<Ref<Tweener>>::Element *E = tweeners.write[current_step].front(); E; E = E->next()) { + for (Ref<Tweener> &tweener : tweeners.write[current_step]) { // Modified inside Tweener.step(). float temp_delta = rem_delta; // Turns to true if any Tweener returns true (i.e. is still not finished). - step_active = E->get()->step(temp_delta) || step_active; + step_active = tweener->step(temp_delta) || step_active; step_delta = MIN(temp_delta, rem_delta); } rem_delta = step_delta; if (!step_active) { - emit_signal("step_finished", current_step); + emit_signal(SNAME("step_finished"), current_step); current_step++; if (current_step == tweeners.size()) { @@ -272,9 +272,9 @@ bool Tween::step(float p_delta) { if (loops_done == loops) { running = false; dead = true; - emit_signal("finished"); + emit_signal(SNAME("finished")); } else { - emit_signal("loop_finished", loops_done); + emit_signal(SNAME("loop_finished"), loops_done); current_step = 0; start_tweeners(); } @@ -690,7 +690,7 @@ bool PropertyTweener::step(float &r_delta) { } else { finished = true; r_delta = elapsed_time - delay - duration; - emit_signal("finished"); + emit_signal(SNAME("finished")); return false; } } @@ -745,7 +745,7 @@ bool IntervalTweener::step(float &r_delta) { } else { finished = true; r_delta = elapsed_time - duration; - emit_signal("finished"); + emit_signal(SNAME("finished")); return false; } } @@ -784,7 +784,7 @@ bool CallbackTweener::step(float &r_delta) { finished = true; r_delta = elapsed_time - delay; - emit_signal("finished"); + emit_signal(SNAME("finished")); return false; } @@ -854,7 +854,7 @@ bool MethodTweener::step(float &r_delta) { } else { finished = true; r_delta = elapsed_time - delay - duration; - emit_signal("finished"); + emit_signal(SNAME("finished")); return false; } } diff --git a/scene/audio/audio_stream_player.cpp b/scene/audio/audio_stream_player.cpp index 1478cbf69e..298d75b668 100644 --- a/scene/audio/audio_stream_player.cpp +++ b/scene/audio/audio_stream_player.cpp @@ -146,7 +146,7 @@ void AudioStreamPlayer::_notification(int p_what) { if (!active.is_set() || (setseek.get() < 0 && !stream_playback->is_playing())) { active.clear(); set_process_internal(false); - emit_signal("finished"); + emit_signal(SNAME("finished")); } } diff --git a/scene/debugger/scene_debugger.cpp b/scene/debugger/scene_debugger.cpp index 1e121ab6e5..ce2b320c96 100644 --- a/scene/debugger/scene_debugger.cpp +++ b/scene/debugger/scene_debugger.cpp @@ -145,12 +145,12 @@ Error SceneDebugger::parse_message(void *p_user, const String &p_msg, const Arra live_editor->_res_set_func(p_args[0], p_args[1], p_args[2]); } else if (p_msg == "live_node_call") { - ERR_FAIL_COND_V(p_args.size() < 7, ERR_INVALID_DATA); - live_editor->_node_call_func(p_args[0], p_args[1], p_args[2], p_args[3], p_args[4], p_args[5], p_args[6]); + ERR_FAIL_COND_V(p_args.size() < 10, ERR_INVALID_DATA); + live_editor->_node_call_func(p_args[0], p_args[1], p_args[2], p_args[3], p_args[4], p_args[5], p_args[6], p_args[7], p_args[8], p_args[9]); } else if (p_msg == "live_res_call") { - ERR_FAIL_COND_V(p_args.size() < 7, ERR_INVALID_DATA); - live_editor->_res_call_func(p_args[0], p_args[1], p_args[2], p_args[3], p_args[4], p_args[5], p_args[6]); + ERR_FAIL_COND_V(p_args.size() < 10, ERR_INVALID_DATA); + live_editor->_res_call_func(p_args[0], p_args[1], p_args[2], p_args[3], p_args[4], p_args[5], p_args[6], p_args[7], p_args[8], p_args[9]); } else if (p_msg == "live_create_node") { ERR_FAIL_COND_V(p_args.size() < 3, ERR_INVALID_DATA); @@ -292,9 +292,9 @@ SceneDebuggerObject::SceneDebuggerObject(ObjectID p_id) { // Add base object properties. List<PropertyInfo> pinfo; obj->get_property_list(&pinfo, true); - for (List<PropertyInfo>::Element *E = pinfo.front(); E; E = E->next()) { - if (E->get().usage & (PROPERTY_USAGE_EDITOR | PROPERTY_USAGE_CATEGORY)) { - properties.push_back(SceneDebuggerProperty(E->get(), obj->get(E->get().name))); + for (const PropertyInfo &E : pinfo) { + if (E.usage & (PROPERTY_USAGE_EDITOR | PROPERTY_USAGE_CATEGORY)) { + properties.push_back(SceneDebuggerProperty(E, obj->get(E.name))); } } } @@ -452,8 +452,7 @@ SceneDebuggerTree::SceneDebuggerTree(Node *p_root) { } void SceneDebuggerTree::serialize(Array &p_arr) { - for (List<RemoteNode>::Element *E = nodes.front(); E; E = E->next()) { - RemoteNode &n = E->get(); + for (const RemoteNode &n : nodes) { p_arr.push_back(n.child_count); p_arr.push_back(n.name); p_arr.push_back(n.type_name); diff --git a/scene/gui/base_button.cpp b/scene/gui/base_button.cpp index c1ae0479f5..75a4464a40 100644 --- a/scene/gui/base_button.cpp +++ b/scene/gui/base_button.cpp @@ -125,7 +125,7 @@ void BaseButton::_pressed() { get_script_instance()->call(SceneStringNames::get_singleton()->_pressed); } pressed(); - emit_signal("pressed"); + emit_signal(SNAME("pressed")); } void BaseButton::_toggled(bool p_pressed) { @@ -133,14 +133,14 @@ void BaseButton::_toggled(bool p_pressed) { get_script_instance()->call(SceneStringNames::get_singleton()->_toggled, p_pressed); } toggled(p_pressed); - emit_signal("toggled", p_pressed); + emit_signal(SNAME("toggled"), p_pressed); } void BaseButton::on_action_event(Ref<InputEvent> p_event) { if (p_event->is_pressed()) { status.press_attempt = true; status.pressing_inside = true; - emit_signal("button_down"); + emit_signal(SNAME("button_down")); } if (status.press_attempt && status.pressing_inside) { @@ -153,7 +153,7 @@ void BaseButton::on_action_event(Ref<InputEvent> p_event) { status.pressed = !status.pressed; _unpress_group(); if (button_group.is_valid()) { - button_group->emit_signal("pressed", this); + button_group->emit_signal(SNAME("pressed"), this); } _toggled(status.pressed); _pressed(); @@ -174,7 +174,7 @@ void BaseButton::on_action_event(Ref<InputEvent> p_event) { } status.press_attempt = false; status.pressing_inside = false; - emit_signal("button_up"); + emit_signal(SNAME("button_up")); } update(); @@ -218,7 +218,7 @@ void BaseButton::set_pressed(bool p_pressed) { if (p_pressed) { _unpress_group(); if (button_group.is_valid()) { - button_group->emit_signal("pressed", this); + button_group->emit_signal(SNAME("pressed"), this); } } _toggled(status.pressed); @@ -226,6 +226,18 @@ void BaseButton::set_pressed(bool p_pressed) { update(); } +void BaseButton::set_pressed_no_signal(bool p_pressed) { + if (!toggle_mode) { + return; + } + if (status.pressed == p_pressed) { + return; + } + status.pressed = p_pressed; + + update(); +} + bool BaseButton::is_pressing() const { return status.press_attempt; } @@ -399,6 +411,7 @@ void BaseButton::_bind_methods() { ClassDB::bind_method(D_METHOD("_unhandled_key_input"), &BaseButton::_unhandled_key_input); ClassDB::bind_method(D_METHOD("set_pressed", "pressed"), &BaseButton::set_pressed); ClassDB::bind_method(D_METHOD("is_pressed"), &BaseButton::is_pressed); + ClassDB::bind_method(D_METHOD("set_pressed_no_signal", "pressed"), &BaseButton::set_pressed_no_signal); ClassDB::bind_method(D_METHOD("is_hovered"), &BaseButton::is_hovered); ClassDB::bind_method(D_METHOD("set_toggle_mode", "enabled"), &BaseButton::set_toggle_mode); ClassDB::bind_method(D_METHOD("is_toggle_mode"), &BaseButton::is_toggle_mode); diff --git a/scene/gui/base_button.h b/scene/gui/base_button.h index 6c7a8f3433..d86b35daf0 100644 --- a/scene/gui/base_button.h +++ b/scene/gui/base_button.h @@ -98,7 +98,8 @@ public: bool is_pressing() const; ///< return whether button is pressed (toggled in) bool is_hovered() const; - void set_pressed(bool p_pressed); ///only works in toggle mode + void set_pressed(bool p_pressed); // Only works in toggle mode. + void set_pressed_no_signal(bool p_pressed); void set_toggle_mode(bool p_on); bool is_toggle_mode() const; diff --git a/scene/gui/box_container.cpp b/scene/gui/box_container.cpp index 40a49dbb58..a2f1d2b15a 100644 --- a/scene/gui/box_container.cpp +++ b/scene/gui/box_container.cpp @@ -43,7 +43,7 @@ void BoxContainer::_resort() { Size2i new_size = get_size(); - int sep = get_theme_constant("separation"); //,vertical?"VBoxContainer":"HBoxContainer"); + int sep = get_theme_constant(SNAME("separation")); //,vertical?"VBoxContainer":"HBoxContainer"); bool rtl = is_layout_rtl(); bool first = true; @@ -247,7 +247,7 @@ Size2 BoxContainer::get_minimum_size() const { /* Calculate MINIMUM SIZE */ Size2i minimum; - int sep = get_theme_constant("separation"); //,vertical?"VBoxContainer":"HBoxContainer"); + int sep = get_theme_constant(SNAME("separation")); //,vertical?"VBoxContainer":"HBoxContainer"); bool first = true; diff --git a/scene/gui/button.cpp b/scene/gui/button.cpp index bcc273114b..9cdf3bf210 100644 --- a/scene/gui/button.cpp +++ b/scene/gui/button.cpp @@ -41,8 +41,8 @@ Size2 Button::get_minimum_size() const { if (!expand_icon) { Ref<Texture2D> _icon; - if (icon.is_null() && has_theme_icon("icon")) { - _icon = Control::get_theme_icon("icon"); + if (icon.is_null() && has_theme_icon(SNAME("icon"))) { + _icon = Control::get_theme_icon(SNAME("icon")); } else { _icon = icon; } @@ -53,7 +53,7 @@ Size2 Button::get_minimum_size() const { if (icon_align != ALIGN_CENTER) { minsize.width += _icon->get_width(); if (xl_text != "") { - minsize.width += get_theme_constant("hseparation"); + minsize.width += get_theme_constant(SNAME("hseparation")); } } else { minsize.width = MAX(minsize.width, _icon->get_width()); @@ -61,12 +61,12 @@ Size2 Button::get_minimum_size() const { } } - Ref<Font> font = get_theme_font("font"); - float font_height = font->get_height(get_theme_font_size("font_size")); + Ref<Font> font = get_theme_font(SNAME("font")); + float font_height = font->get_height(get_theme_font_size(SNAME("font_size"))); minsize.height = MAX(font_height, minsize.height); - return get_theme_stylebox("normal")->get_minimum_size() + minsize; + return get_theme_stylebox(SNAME("normal"))->get_minimum_size() + minsize; } void Button::_set_internal_margin(Side p_side, float p_value) { @@ -79,7 +79,7 @@ void Button::_notification(int p_what) { update(); } break; case NOTIFICATION_TRANSLATION_CHANGED: { - xl_text = tr(text); + xl_text = atr(text); _shape(); minimum_size_changed(); @@ -97,43 +97,43 @@ void Button::_notification(int p_what) { Color color; Color color_icon(1, 1, 1, 1); - Ref<StyleBox> style = get_theme_stylebox("normal"); + Ref<StyleBox> style = get_theme_stylebox(SNAME("normal")); bool rtl = is_layout_rtl(); switch (get_draw_mode()) { case DRAW_NORMAL: { - if (rtl && has_theme_stylebox("normal_mirrored")) { - style = get_theme_stylebox("normal_mirrored"); + if (rtl && has_theme_stylebox(SNAME("normal_mirrored"))) { + style = get_theme_stylebox(SNAME("normal_mirrored")); } else { - style = get_theme_stylebox("normal"); + style = get_theme_stylebox(SNAME("normal")); } if (!flat) { style->draw(ci, Rect2(Point2(0, 0), size)); } - color = get_theme_color("font_color"); - if (has_theme_color("icon_normal_color")) { - color_icon = get_theme_color("icon_normal_color"); + color = get_theme_color(SNAME("font_color")); + if (has_theme_color(SNAME("icon_normal_color"))) { + color_icon = get_theme_color(SNAME("icon_normal_color")); } } break; case DRAW_HOVER_PRESSED: { - if (has_theme_stylebox("hover_pressed") && has_theme_stylebox_override("hover_pressed")) { - if (rtl && has_theme_stylebox("hover_pressed_mirrored")) { - style = get_theme_stylebox("hover_pressed_mirrored"); + if (has_theme_stylebox(SNAME("hover_pressed")) && has_theme_stylebox_override("hover_pressed")) { + if (rtl && has_theme_stylebox(SNAME("hover_pressed_mirrored"))) { + style = get_theme_stylebox(SNAME("hover_pressed_mirrored")); } else { - style = get_theme_stylebox("hover_pressed"); + style = get_theme_stylebox(SNAME("hover_pressed")); } if (!flat) { style->draw(ci, Rect2(Point2(0, 0), size)); } - if (has_theme_color("font_hover_pressed_color")) { - color = get_theme_color("font_hover_pressed_color"); + if (has_theme_color(SNAME("font_hover_pressed_color"))) { + color = get_theme_color(SNAME("font_hover_pressed_color")); } else { - color = get_theme_color("font_color"); + color = get_theme_color(SNAME("font_color")); } - if (has_theme_color("icon_hover_pressed_color")) { - color_icon = get_theme_color("icon_hover_pressed_color"); + if (has_theme_color(SNAME("icon_hover_pressed_color"))) { + color_icon = get_theme_color(SNAME("icon_hover_pressed_color")); } break; @@ -141,67 +141,67 @@ void Button::_notification(int p_what) { [[fallthrough]]; } case DRAW_PRESSED: { - if (rtl && has_theme_stylebox("pressed_mirrored")) { - style = get_theme_stylebox("pressed_mirrored"); + if (rtl && has_theme_stylebox(SNAME("pressed_mirrored"))) { + style = get_theme_stylebox(SNAME("pressed_mirrored")); } else { - style = get_theme_stylebox("pressed"); + style = get_theme_stylebox(SNAME("pressed")); } if (!flat) { style->draw(ci, Rect2(Point2(0, 0), size)); } - if (has_theme_color("font_pressed_color")) { - color = get_theme_color("font_pressed_color"); + if (has_theme_color(SNAME("font_pressed_color"))) { + color = get_theme_color(SNAME("font_pressed_color")); } else { - color = get_theme_color("font_color"); + color = get_theme_color(SNAME("font_color")); } - if (has_theme_color("icon_pressed_color")) { - color_icon = get_theme_color("icon_pressed_color"); + if (has_theme_color(SNAME("icon_pressed_color"))) { + color_icon = get_theme_color(SNAME("icon_pressed_color")); } } break; case DRAW_HOVER: { - if (rtl && has_theme_stylebox("hover_mirrored")) { - style = get_theme_stylebox("hover_mirrored"); + if (rtl && has_theme_stylebox(SNAME("hover_mirrored"))) { + style = get_theme_stylebox(SNAME("hover_mirrored")); } else { - style = get_theme_stylebox("hover"); + style = get_theme_stylebox(SNAME("hover")); } if (!flat) { style->draw(ci, Rect2(Point2(0, 0), size)); } - color = get_theme_color("font_hover_color"); - if (has_theme_color("icon_hover_color")) { - color_icon = get_theme_color("icon_hover_color"); + color = get_theme_color(SNAME("font_hover_color")); + if (has_theme_color(SNAME("icon_hover_color"))) { + color_icon = get_theme_color(SNAME("icon_hover_color")); } } break; case DRAW_DISABLED: { - if (rtl && has_theme_stylebox("disabled_mirrored")) { - style = get_theme_stylebox("disabled_mirrored"); + if (rtl && has_theme_stylebox(SNAME("disabled_mirrored"))) { + style = get_theme_stylebox(SNAME("disabled_mirrored")); } else { - style = get_theme_stylebox("disabled"); + style = get_theme_stylebox(SNAME("disabled")); } if (!flat) { style->draw(ci, Rect2(Point2(0, 0), size)); } - color = get_theme_color("font_disabled_color"); - if (has_theme_color("icon_disabled_color")) { - color_icon = get_theme_color("icon_disabled_color"); + color = get_theme_color(SNAME("font_disabled_color")); + if (has_theme_color(SNAME("icon_disabled_color"))) { + color_icon = get_theme_color(SNAME("icon_disabled_color")); } } break; } if (has_focus()) { - Ref<StyleBox> style2 = get_theme_stylebox("focus"); + Ref<StyleBox> style2 = get_theme_stylebox(SNAME("focus")); style2->draw(ci, Rect2(Point2(), size)); } Ref<Texture2D> _icon; - if (icon.is_null() && has_theme_icon("icon")) { - _icon = Control::get_theme_icon("icon"); + if (icon.is_null() && has_theme_icon(SNAME("icon"))) { + _icon = Control::get_theme_icon(SNAME("icon")); } else { _icon = icon; } @@ -234,21 +234,21 @@ void Button::_notification(int p_what) { if (icon_align_rtl_checked == ALIGN_LEFT) { style_offset.x = style->get_margin(SIDE_LEFT); if (_internal_margin[SIDE_LEFT] > 0) { - icon_ofs_region = _internal_margin[SIDE_LEFT] + get_theme_constant("hseparation"); + icon_ofs_region = _internal_margin[SIDE_LEFT] + get_theme_constant(SNAME("hseparation")); } } else if (icon_align_rtl_checked == ALIGN_CENTER) { style_offset.x = 0.0; } else if (icon_align_rtl_checked == ALIGN_RIGHT) { style_offset.x = -style->get_margin(SIDE_RIGHT); if (_internal_margin[SIDE_RIGHT] > 0) { - icon_ofs_region = -_internal_margin[SIDE_RIGHT] - get_theme_constant("hseparation"); + icon_ofs_region = -_internal_margin[SIDE_RIGHT] - get_theme_constant(SNAME("hseparation")); } } style_offset.y = style->get_margin(SIDE_TOP); if (expand_icon) { Size2 _size = get_size() - style->get_offset() * 2; - _size.width -= get_theme_constant("hseparation") + icon_ofs_region; + _size.width -= get_theme_constant(SNAME("hseparation")) + icon_ofs_region; if (!clip_text && icon_align_rtl_checked != ALIGN_CENTER) { _size.width -= text_buf->get_size().width; } @@ -276,7 +276,7 @@ void Button::_notification(int p_what) { } } - Point2 icon_ofs = !_icon.is_null() ? Point2(icon_region.size.width + get_theme_constant("hseparation"), 0) : Point2(); + Point2 icon_ofs = !_icon.is_null() ? Point2(icon_region.size.width + get_theme_constant(SNAME("hseparation")), 0) : Point2(); if (align_rtl_checked == ALIGN_CENTER && icon_align_rtl_checked == ALIGN_CENTER) { icon_ofs.x = 0.0; } @@ -286,10 +286,10 @@ void Button::_notification(int p_what) { int text_width = clip_text ? MIN(text_clip, text_buf->get_size().x) : text_buf->get_size().x; if (_internal_margin[SIDE_LEFT] > 0) { - text_clip -= _internal_margin[SIDE_LEFT] + get_theme_constant("hseparation"); + text_clip -= _internal_margin[SIDE_LEFT] + get_theme_constant(SNAME("hseparation")); } if (_internal_margin[SIDE_RIGHT] > 0) { - text_clip -= _internal_margin[SIDE_RIGHT] + get_theme_constant("hseparation"); + text_clip -= _internal_margin[SIDE_RIGHT] + get_theme_constant(SNAME("hseparation")); } Point2 text_ofs = (size - style->get_minimum_size() - icon_ofs - text_buf->get_size() - Point2(_internal_margin[SIDE_RIGHT] - _internal_margin[SIDE_LEFT], 0)) / 2.0; @@ -300,7 +300,7 @@ void Button::_notification(int p_what) { icon_ofs.x = 0.0; } if (_internal_margin[SIDE_LEFT] > 0) { - text_ofs.x = style->get_margin(SIDE_LEFT) + icon_ofs.x + _internal_margin[SIDE_LEFT] + get_theme_constant("hseparation"); + text_ofs.x = style->get_margin(SIDE_LEFT) + icon_ofs.x + _internal_margin[SIDE_LEFT] + get_theme_constant(SNAME("hseparation")); } else { text_ofs.x = style->get_margin(SIDE_LEFT) + icon_ofs.x; } @@ -317,7 +317,7 @@ void Button::_notification(int p_what) { } break; case ALIGN_RIGHT: { if (_internal_margin[SIDE_RIGHT] > 0) { - text_ofs.x = size.x - style->get_margin(SIDE_RIGHT) - text_width - _internal_margin[SIDE_RIGHT] - get_theme_constant("hseparation"); + text_ofs.x = size.x - style->get_margin(SIDE_RIGHT) - text_width - _internal_margin[SIDE_RIGHT] - get_theme_constant(SNAME("hseparation")); } else { text_ofs.x = size.x - style->get_margin(SIDE_RIGHT) - text_width; } @@ -328,8 +328,8 @@ void Button::_notification(int p_what) { } break; } - Color font_outline_color = get_theme_color("font_outline_color"); - int outline_size = get_theme_constant("outline_size"); + Color font_outline_color = get_theme_color(SNAME("font_outline_color")); + int outline_size = get_theme_constant(SNAME("outline_size")); if (outline_size > 0 && font_outline_color.a > 0) { text_buf->draw_outline(ci, text_ofs, outline_size, font_outline_color); } @@ -340,8 +340,8 @@ void Button::_notification(int p_what) { } void Button::_shape() { - Ref<Font> font = get_theme_font("font"); - int font_size = get_theme_font_size("font_size"); + Ref<Font> font = get_theme_font(SNAME("font")); + int font_size = get_theme_font_size(SNAME("font_size")); text_buf->clear(); if (text_direction == Control::TEXT_DIRECTION_INHERITED) { @@ -355,7 +355,7 @@ void Button::_shape() { void Button::set_text(const String &p_text) { if (text != p_text) { text = p_text; - xl_text = tr(text); + xl_text = atr(text); _shape(); update(); diff --git a/scene/gui/check_box.cpp b/scene/gui/check_box.cpp index c0650a8f3f..d93107df2d 100644 --- a/scene/gui/check_box.cpp +++ b/scene/gui/check_box.cpp @@ -33,12 +33,12 @@ #include "servers/rendering_server.h" Size2 CheckBox::get_icon_size() const { - Ref<Texture2D> checked = Control::get_theme_icon("checked"); - Ref<Texture2D> checked_disabled = Control::get_theme_icon("checked_disabled"); - Ref<Texture2D> unchecked = Control::get_theme_icon("unchecked"); - Ref<Texture2D> unchecked_disabled = Control::get_theme_icon("unchecked_disabled"); - Ref<Texture2D> radio_checked = Control::get_theme_icon("radio_checked"); - Ref<Texture2D> radio_unchecked = Control::get_theme_icon("radio_unchecked"); + Ref<Texture2D> checked = Control::get_theme_icon(SNAME("checked")); + Ref<Texture2D> checked_disabled = Control::get_theme_icon(SNAME("checked_disabled")); + Ref<Texture2D> unchecked = Control::get_theme_icon(SNAME("unchecked")); + Ref<Texture2D> unchecked_disabled = Control::get_theme_icon(SNAME("unchecked_disabled")); + Ref<Texture2D> radio_checked = Control::get_theme_icon(SNAME("radio_checked")); + Ref<Texture2D> radio_unchecked = Control::get_theme_icon(SNAME("radio_unchecked")); Size2 tex_size = Size2(0, 0); if (!checked.is_null()) { @@ -61,9 +61,9 @@ Size2 CheckBox::get_minimum_size() const { Size2 tex_size = get_icon_size(); minsize.width += tex_size.width; if (get_text().length() > 0) { - minsize.width += get_theme_constant("hseparation"); + minsize.width += get_theme_constant(SNAME("hseparation")); } - Ref<StyleBox> sb = get_theme_stylebox("normal"); + Ref<StyleBox> sb = get_theme_stylebox(SNAME("normal")); minsize.height = MAX(minsize.height, tex_size.height + sb->get_margin(SIDE_TOP) + sb->get_margin(SIDE_BOTTOM)); return minsize; @@ -83,7 +83,7 @@ void CheckBox::_notification(int p_what) { Ref<Texture2D> on = Control::get_theme_icon(vformat("%s%s", is_radio() ? "radio_checked" : "checked", is_disabled() ? "_disabled" : "")); Ref<Texture2D> off = Control::get_theme_icon(vformat("%s%s", is_radio() ? "radio_unchecked" : "unchecked", is_disabled() ? "_disabled" : "")); - Ref<StyleBox> sb = get_theme_stylebox("normal"); + Ref<StyleBox> sb = get_theme_stylebox(SNAME("normal")); Vector2 ofs; if (is_layout_rtl()) { @@ -91,7 +91,7 @@ void CheckBox::_notification(int p_what) { } else { ofs.x = sb->get_margin(SIDE_LEFT); } - ofs.y = int((get_size().height - get_icon_size().height) / 2) + get_theme_constant("check_vadjust"); + ofs.y = int((get_size().height - get_icon_size().height) / 2) + get_theme_constant(SNAME("check_vadjust")); if (is_pressed()) { on->draw(ci, ofs); diff --git a/scene/gui/check_button.cpp b/scene/gui/check_button.cpp index a8bf449355..162a256d23 100644 --- a/scene/gui/check_button.cpp +++ b/scene/gui/check_button.cpp @@ -52,9 +52,9 @@ Size2 CheckButton::get_minimum_size() const { Size2 tex_size = get_icon_size(); minsize.width += tex_size.width; if (get_text().length() > 0) { - minsize.width += get_theme_constant("hseparation"); + minsize.width += get_theme_constant(SNAME("hseparation")); } - Ref<StyleBox> sb = get_theme_stylebox("normal"); + Ref<StyleBox> sb = get_theme_stylebox(SNAME("normal")); minsize.height = MAX(minsize.height, tex_size.height + sb->get_margin(SIDE_TOP) + sb->get_margin(SIDE_BOTTOM)); return minsize; @@ -86,7 +86,7 @@ void CheckButton::_notification(int p_what) { off = Control::get_theme_icon(is_disabled() ? "off_disabled" : "off"); } - Ref<StyleBox> sb = get_theme_stylebox("normal"); + Ref<StyleBox> sb = get_theme_stylebox(SNAME("normal")); Vector2 ofs; Size2 tex_size = get_icon_size(); @@ -95,7 +95,7 @@ void CheckButton::_notification(int p_what) { } else { ofs.x = get_size().width - (tex_size.width + sb->get_margin(SIDE_RIGHT)); } - ofs.y = (get_size().height - tex_size.height) / 2 + get_theme_constant("check_vadjust"); + ofs.y = (get_size().height - tex_size.height) / 2 + get_theme_constant(SNAME("check_vadjust")); if (is_pressed()) { on->draw(ci, ofs); diff --git a/scene/gui/code_edit.cpp b/scene/gui/code_edit.cpp index ba1534ed5c..be5e0bf4e5 100644 --- a/scene/gui/code_edit.cpp +++ b/scene/gui/code_edit.cpp @@ -50,28 +50,28 @@ void CodeEdit::_notification(int p_what) { set_gutter_width(line_number_gutter, (line_number_digits + 1) * cache.font->get_char_size('0', 0, cache.font_size).width); set_gutter_width(fold_gutter, get_row_height() / 1.2); - breakpoint_color = get_theme_color("breakpoint_color"); - breakpoint_icon = get_theme_icon("breakpoint"); + breakpoint_color = get_theme_color(SNAME("breakpoint_color")); + breakpoint_icon = get_theme_icon(SNAME("breakpoint")); - bookmark_color = get_theme_color("bookmark_color"); - bookmark_icon = get_theme_icon("bookmark"); + bookmark_color = get_theme_color(SNAME("bookmark_color")); + bookmark_icon = get_theme_icon(SNAME("bookmark")); - executing_line_color = get_theme_color("executing_line_color"); - executing_line_icon = get_theme_icon("executing_line"); + executing_line_color = get_theme_color(SNAME("executing_line_color")); + executing_line_icon = get_theme_icon(SNAME("executing_line")); - line_number_color = get_theme_color("line_number_color"); + line_number_color = get_theme_color(SNAME("line_number_color")); - folding_color = get_theme_color("code_folding_color"); - can_fold_icon = get_theme_icon("can_fold"); - folded_icon = get_theme_icon("folded"); + folding_color = get_theme_color(SNAME("code_folding_color")); + can_fold_icon = get_theme_icon(SNAME("can_fold")); + folded_icon = get_theme_icon(SNAME("folded")); - code_completion_max_width = get_theme_constant("completion_max_width") * cache.font->get_char_size('x').x; - code_completion_max_lines = get_theme_constant("completion_lines"); - code_completion_scroll_width = get_theme_constant("completion_scroll_width"); - code_completion_scroll_color = get_theme_color("completion_scroll_color"); - code_completion_background_color = get_theme_color("completion_background_color"); - code_completion_selected_color = get_theme_color("completion_selected_color"); - code_completion_existing_color = get_theme_color("completion_existing_color"); + code_completion_max_width = get_theme_constant(SNAME("completion_max_width")) * cache.font->get_char_size('x').x; + code_completion_max_lines = get_theme_constant(SNAME("completion_lines")); + code_completion_scroll_width = get_theme_constant(SNAME("completion_scroll_width")); + code_completion_scroll_color = get_theme_color(SNAME("completion_scroll_color")); + code_completion_background_color = get_theme_color(SNAME("completion_background_color")); + code_completion_selected_color = get_theme_color(SNAME("completion_selected_color")); + code_completion_existing_color = get_theme_color(SNAME("completion_existing_color")); } break; case NOTIFICATION_DRAW: { RID ci = get_canvas_item(); @@ -81,11 +81,11 @@ void CodeEdit::_notification(int p_what) { bool code_completion_below = false; if (caret_visible && code_completion_active && code_completion_options.size() > 0) { - Ref<StyleBox> csb = get_theme_stylebox("completion"); + Ref<StyleBox> csb = get_theme_stylebox(SNAME("completion")); const int code_completion_options_count = code_completion_options.size(); const int lines = MIN(code_completion_options_count, code_completion_max_lines); - const int icon_hsep = get_theme_constant("hseparation", "ItemList"); + const int icon_hsep = get_theme_constant(SNAME("hseparation"), SNAME("ItemList")); const Size2 icon_area_size(row_height, row_height); code_completion_rect.size.width = code_completion_longest_line + icon_hsep + icon_area_size.width + 2; @@ -164,8 +164,8 @@ void CodeEdit::_notification(int p_what) { if (caret_visible && code_hint != "" && (!code_completion_active || (code_completion_below != code_hint_draw_below))) { const Ref<Font> font = cache.font; const int font_height = font->get_height(cache.font_size); - Ref<StyleBox> sb = get_theme_stylebox("panel", "TooltipPanel"); - Color font_color = get_theme_color("font_color", "TooltipLabel"); + Ref<StyleBox> sb = get_theme_stylebox(SNAME("panel"), SNAME("TooltipPanel")); + Color font_color = get_theme_color(SNAME("font_color"), SNAME("TooltipLabel")); Vector<String> code_hint_lines = code_hint.split("\n"); int line_count = code_hint_lines.size(); @@ -969,7 +969,7 @@ void CodeEdit::set_line_as_breakpoint(int p_line, bool p_breakpointed) { } else if (breakpointed_lines.has(p_line)) { breakpointed_lines.erase(p_line); } - emit_signal("breakpoint_toggled", p_line); + emit_signal(SNAME("breakpoint_toggled"), p_line); update(); } @@ -1551,7 +1551,7 @@ void CodeEdit::request_code_completion(bool p_force) { } if (p_force) { - emit_signal("request_code_completion"); + emit_signal(SNAME("request_code_completion")); return; } @@ -1559,9 +1559,9 @@ void CodeEdit::request_code_completion(bool p_force) { int ofs = CLAMP(cursor_get_column(), 0, line.length()); if (ofs > 0 && (is_in_string(cursor_get_line(), ofs) != -1 || _is_char(line[ofs - 1]) || code_completion_prefixes.has(String::chr(line[ofs - 1])))) { - emit_signal("request_code_completion"); + emit_signal(SNAME("request_code_completion")); } else if (ofs > 1 && line[ofs - 1] == ' ' && code_completion_prefixes.has(String::chr(line[ofs - 2]))) { - emit_signal("request_code_completion"); + emit_signal(SNAME("request_code_completion")); } } @@ -2128,7 +2128,7 @@ int CodeEdit::_is_in_delimiter(int p_line, int p_column, DelimiterType p_type) c int region = (p_line <= 0 || delimiter_cache[p_line - 1].size() < 1) ? -1 : delimiter_cache[p_line - 1].back()->value(); bool in_region = region != -1 && delimiters[region].type == p_type; for (Map<int, int>::Element *E = delimiter_cache[p_line].front(); E; E = E->next()) { - /* If column is specified, loop untill the key is larger then the column. */ + /* If column is specified, loop until the key is larger then the column. */ if (p_column != -1) { if (E->key() > p_column) { break; @@ -2138,7 +2138,7 @@ int CodeEdit::_is_in_delimiter(int p_line, int p_column, DelimiterType p_type) c continue; } - /* If no column, calulate if the entire line is a region */ + /* If no column, calculate if the entire line is a region */ /* excluding whitespace. */ const String line = get_line(p_line); if (!in_region) { @@ -2288,14 +2288,14 @@ void CodeEdit::_filter_code_completion_candidates() { TypedArray<Dictionary> completion_options_sources; completion_options_sources.resize(code_completion_option_sources.size()); int i = 0; - for (List<ScriptCodeCompletionOption>::Element *E = code_completion_option_sources.front(); E; E = E->next()) { + for (const ScriptCodeCompletionOption &E : code_completion_option_sources) { Dictionary option; - option["kind"] = E->get().kind; - option["display_text"] = E->get().display; - option["insert_text"] = E->get().insert_text; - option["font_color"] = E->get().font_color; - option["icon"] = E->get().icon; - option["default_value"] = E->get().default_value; + option["kind"] = E.kind; + option["display_text"] = E.display; + option["insert_text"] = E.insert_text; + option["font_color"] = E.font_color; + option["icon"] = E.icon; + option["default_value"] = E.default_value; completion_options_sources[i] = option; i++; } @@ -2406,9 +2406,7 @@ void CodeEdit::_filter_code_completion_candidates() { int max_width = 0; String string_to_complete_lower = string_to_complete.to_lower(); - for (List<ScriptCodeCompletionOption>::Element *E = code_completion_option_sources.front(); E; E = E->next()) { - ScriptCodeCompletionOption &option = E->get(); - + for (ScriptCodeCompletionOption &option : code_completion_option_sources) { if (single_quote && option.display.is_quoted()) { option.display = option.display.unquote().quote("'"); } @@ -2527,16 +2525,15 @@ void CodeEdit::_lines_edited_from(int p_from_line, int p_to_line) { int line_count = (p_to_line - p_from_line); List<int> breakpoints; breakpointed_lines.get_key_list(&breakpoints); - for (const List<int>::Element *E = breakpoints.front(); E; E = E->next()) { - int line = E->get(); + for (const int line : breakpoints) { if (line <= from_line) { continue; } breakpointed_lines.erase(line); - emit_signal("breakpoint_toggled", line); + emit_signal(SNAME("breakpoint_toggled"), line); if (line_count > 0 || line >= p_from_line) { - emit_signal("breakpoint_toggled", line + line_count); + emit_signal(SNAME("breakpoint_toggled"), line + line_count); breakpointed_lines[line + line_count] = true; continue; } @@ -2562,7 +2559,7 @@ CodeEdit::CodeEdit() { set_gutter_name(gutter_idx, "main_gutter"); set_gutter_draw(gutter_idx, false); set_gutter_overwritable(gutter_idx, true); - set_gutter_type(gutter_idx, GUTTER_TPYE_CUSTOM); + set_gutter_type(gutter_idx, GUTTER_TYPE_CUSTOM); set_gutter_custom_draw(gutter_idx, this, "_main_gutter_draw_callback"); gutter_idx++; @@ -2570,7 +2567,7 @@ CodeEdit::CodeEdit() { add_gutter(); set_gutter_name(gutter_idx, "line_numbers"); set_gutter_draw(gutter_idx, false); - set_gutter_type(gutter_idx, GUTTER_TPYE_CUSTOM); + set_gutter_type(gutter_idx, GUTTER_TYPE_CUSTOM); set_gutter_custom_draw(gutter_idx, this, "_line_number_draw_callback"); gutter_idx++; @@ -2578,7 +2575,7 @@ CodeEdit::CodeEdit() { add_gutter(); set_gutter_name(gutter_idx, "fold_gutter"); set_gutter_draw(gutter_idx, false); - set_gutter_type(gutter_idx, GUTTER_TPYE_CUSTOM); + set_gutter_type(gutter_idx, GUTTER_TYPE_CUSTOM); set_gutter_custom_draw(gutter_idx, this, "_fold_gutter_draw_callback"); gutter_idx++; diff --git a/scene/gui/color_picker.cpp b/scene/gui/color_picker.cpp index 659d14ae70..261480bcdd 100644 --- a/scene/gui/color_picker.cpp +++ b/scene/gui/color_picker.cpp @@ -45,14 +45,14 @@ List<Color> ColorPicker::preset_cache; void ColorPicker::_notification(int p_what) { switch (p_what) { case NOTIFICATION_THEME_CHANGED: { - btn_pick->set_icon(get_theme_icon("screen_picker", "ColorPicker")); - bt_add_preset->set_icon(get_theme_icon("add_preset")); + btn_pick->set_icon(get_theme_icon(SNAME("screen_picker"), SNAME("ColorPicker"))); + bt_add_preset->set_icon(get_theme_icon(SNAME("add_preset"))); _update_controls(); } break; case NOTIFICATION_ENTER_TREE: { - btn_pick->set_icon(get_theme_icon("screen_picker", "ColorPicker")); - bt_add_preset->set_icon(get_theme_icon("add_preset")); + btn_pick->set_icon(get_theme_icon(SNAME("screen_picker"), SNAME("ColorPicker"))); + bt_add_preset->set_icon(get_theme_icon(SNAME("add_preset"))); _update_controls(); _update_color(); @@ -75,13 +75,13 @@ void ColorPicker::_notification(int p_what) { } break; case NOTIFICATION_PARENTED: { for (int i = 0; i < 4; i++) { - set_offset((Side)i, get_offset((Side)i) + get_theme_constant("margin")); + set_offset((Side)i, get_offset((Side)i) + get_theme_constant(SNAME("margin"))); } } break; case NOTIFICATION_VISIBILITY_CHANGED: { Popup *p = Object::cast_to<Popup>(get_parent()); if (p) { - p->set_size(Size2(get_combined_minimum_size().width + get_theme_constant("margin") * 2, get_combined_minimum_size().height + get_theme_constant("margin") * 2)); + p->set_size(Size2(get_combined_minimum_size().width + get_theme_constant(SNAME("margin")) * 2, get_combined_minimum_size().height + get_theme_constant(SNAME("margin")) * 2)); } } break; case NOTIFICATION_WM_CLOSE_REQUEST: { @@ -97,43 +97,49 @@ Ref<Shader> ColorPicker::circle_shader; void ColorPicker::init_shaders() { wheel_shader.instantiate(); - wheel_shader->set_code( - "shader_type canvas_item;" - "void fragment() {" - " float x = UV.x - 0.5;" - " float y = UV.y - 0.5;" - " float a = atan(y, x);" - " x += 0.001;" - " y += 0.001;" - " float b = float(sqrt(x * x + y * y) < 0.5) * float(sqrt(x * x + y * y) > 0.42);" - " x -= 0.002;" - " float b2 = float(sqrt(x * x + y * y) < 0.5) * float(sqrt(x * x + y * y) > 0.42);" - " y -= 0.002;" - " float b3 = float(sqrt(x * x + y * y) < 0.5) * float(sqrt(x * x + y * y) > 0.42);" - " x += 0.002;" - " float b4 = float(sqrt(x * x + y * y) < 0.5) * float(sqrt(x * x + y * y) > 0.42);" - " COLOR = vec4(clamp((abs(fract(((a - TAU) / TAU) + vec3(3.0, 2.0, 1.0) / 3.0) * 6.0 - 3.0) - 1.0), 0.0, 1.0), (b + b2 + b3 + b4) / 4.00);" - "}"); + wheel_shader->set_code(R"( +shader_type canvas_item; + +void fragment() { + float x = UV.x - 0.5; + float y = UV.y - 0.5; + float a = atan(y, x); + x += 0.001; + y += 0.001; + float b = float(sqrt(x * x + y * y) < 0.5) * float(sqrt(x * x + y * y) > 0.42); + x -= 0.002; + float b2 = float(sqrt(x * x + y * y) < 0.5) * float(sqrt(x * x + y * y) > 0.42); + y -= 0.002; + float b3 = float(sqrt(x * x + y * y) < 0.5) * float(sqrt(x * x + y * y) > 0.42); + x += 0.002; + float b4 = float(sqrt(x * x + y * y) < 0.5) * float(sqrt(x * x + y * y) > 0.42); + + COLOR = vec4(clamp((abs(fract(((a - TAU) / TAU) + vec3(3.0, 2.0, 1.0) / 3.0) * 6.0 - 3.0) - 1.0), 0.0, 1.0), (b + b2 + b3 + b4) / 4.00); +} +)"); circle_shader.instantiate(); - circle_shader->set_code( - "shader_type canvas_item;" - "uniform float v = 1.0;" - "void fragment() {" - " float x = UV.x - 0.5;" - " float y = UV.y - 0.5;" - " float a = atan(y, x);" - " x += 0.001;" - " y += 0.001;" - " float b = float(sqrt(x * x + y * y) < 0.5);" - " x -= 0.002;" - " float b2 = float(sqrt(x * x + y * y) < 0.5);" - " y -= 0.002;" - " float b3 = float(sqrt(x * x + y * y) < 0.5);" - " x += 0.002;" - " float b4 = float(sqrt(x * x + y * y) < 0.5);" - " COLOR = vec4(mix(vec3(1.0), clamp(abs(fract(vec3((a - TAU) / TAU) + vec3(1.0, 2.0 / 3.0, 1.0 / 3.0)) * 6.0 - vec3(3.0)) - vec3(1.0), 0.0, 1.0), ((float(sqrt(x * x + y * y)) * 2.0)) / 1.0) * vec3(v), (b + b2 + b3 + b4) / 4.00);" - "}"); + circle_shader->set_code(R"( +shader_type canvas_item; + +uniform float v = 1.0; + +void fragment() { + float x = UV.x - 0.5; + float y = UV.y - 0.5; + float a = atan(y, x); + x += 0.001; + y += 0.001; + float b = float(sqrt(x * x + y * y) < 0.5); + x -= 0.002; + float b2 = float(sqrt(x * x + y * y) < 0.5); + y -= 0.002; + float b3 = float(sqrt(x * x + y * y) < 0.5); + x += 0.002; + float b4 = float(sqrt(x * x + y * y) < 0.5); + + COLOR = vec4(mix(vec3(1.0), clamp(abs(fract(vec3((a - TAU) / TAU) + vec3(1.0, 2.0 / 3.0, 1.0 / 3.0)) * 6.0 - vec3(3.0)) - vec3(1.0), 0.0, 1.0), ((float(sqrt(x * x + y * y)) * 2.0)) / 1.0) * vec3(v), (b + b2 + b3 + b4) / 4.00); +})"); } void ColorPicker::finish_shaders() { @@ -142,7 +148,7 @@ void ColorPicker::finish_shaders() { } void ColorPicker::set_focus_on_line_edit() { - c_text->call_deferred("grab_focus"); + c_text->call_deferred(SNAME("grab_focus")); } void ColorPicker::_update_controls() { @@ -180,7 +186,7 @@ void ColorPicker::_update_controls() { } } else { Ref<StyleBoxEmpty> style_box_empty(memnew(StyleBoxEmpty)); - Ref<Texture2D> bar_arrow = get_theme_icon("bar_arrow"); + Ref<Texture2D> bar_arrow = get_theme_icon(SNAME("bar_arrow")); for (int i = 0; i < 4; i++) { scroll[i]->add_theme_icon_override("grabber", bar_arrow); @@ -294,7 +300,7 @@ void ColorPicker::_value_changed(double) { } _set_pick_color(color, false); - emit_signal("color_changed", color); + emit_signal(SNAME("color_changed"), color); } void ColorPicker::_html_submitted(const String &p_html) { @@ -313,7 +319,7 @@ void ColorPicker::_html_submitted(const String &p_html) { } set_pick_color(color); - emit_signal("color_changed", color); + emit_signal(SNAME("color_changed"), color); } void ColorPicker::_update_color(bool p_update_sliders) { @@ -388,7 +394,7 @@ void ColorPicker::_text_type_toggled() { text_is_constructor = !text_is_constructor; if (text_is_constructor) { text_type->set_text(""); - text_type->set_icon(get_theme_icon("Script", "EditorIcons")); + text_type->set_icon(get_theme_icon(SNAME("Script"), SNAME("EditorIcons"))); c_text->set_editable(false); } else { @@ -537,7 +543,7 @@ void ColorPicker::_sample_input(const Ref<InputEvent> &p_event) { // Revert to the old color when left-clicking the old color sample. color = old_color; _update_color(); - emit_signal("color_changed", color); + emit_signal(SNAME("color_changed"), color); } } } @@ -554,28 +560,28 @@ void ColorPicker::_sample_draw() { const Rect2 rect_old = Rect2(Point2(), Size2(sample->get_size().width * 0.5, sample->get_size().height * 0.95)); if (display_old_color && old_color.a < 1.0) { - sample->draw_texture_rect(get_theme_icon("preset_bg", "ColorPicker"), rect_old, true); + sample->draw_texture_rect(get_theme_icon(SNAME("preset_bg"), SNAME("ColorPicker")), rect_old, true); } sample->draw_rect(rect_old, old_color); if (old_color.r > 1 || old_color.g > 1 || old_color.b > 1) { // Draw an indicator to denote that the old color is "overbright" and can't be displayed accurately in the preview. - sample->draw_texture(get_theme_icon("overbright_indicator", "ColorPicker"), Point2()); + sample->draw_texture(get_theme_icon(SNAME("overbright_indicator"), SNAME("ColorPicker")), Point2()); } } else { rect_new = Rect2(Point2(), Size2(sample->get_size().width, sample->get_size().height * 0.95)); } if (color.a < 1.0) { - sample->draw_texture_rect(get_theme_icon("preset_bg", "ColorPicker"), rect_new, true); + sample->draw_texture_rect(get_theme_icon(SNAME("preset_bg"), SNAME("ColorPicker")), rect_new, true); } sample->draw_rect(rect_new, color); if (color.r > 1 || color.g > 1 || color.b > 1) { // Draw an indicator to denote that the new color is "overbright" and can't be displayed accurately in the preview. - sample->draw_texture(get_theme_icon("overbright_indicator", "ColorPicker"), Point2(uv_edit->get_size().width * 0.5, 0)); + sample->draw_texture(get_theme_icon(SNAME("overbright_indicator"), SNAME("ColorPicker")), Point2(uv_edit->get_size().width * 0.5, 0)); } } @@ -649,7 +655,7 @@ void ColorPicker::_hsv_draw(int p_which, Control *c) { default: { } } - Ref<Texture2D> cursor = get_theme_icon("picker_cursor", "ColorPicker"); + Ref<Texture2D> cursor = get_theme_icon(SNAME("picker_cursor"), SNAME("ColorPicker")); int x; int y; if (picker_type == SHAPE_VHS_CIRCLE) { @@ -679,7 +685,7 @@ void ColorPicker::_hsv_draw(int p_which, Control *c) { } else if (p_which == 1) { if (picker_type == SHAPE_HSV_RECTANGLE) { - Ref<Texture2D> hue = get_theme_icon("color_hue", "ColorPicker"); + Ref<Texture2D> hue = get_theme_icon(SNAME("color_hue"), SNAME("ColorPicker")); c->draw_texture_rect(hue, Rect2(Point2(), c->get_size())); int y = c->get_size().y - c->get_size().y * (1.0 - h); Color col; @@ -728,7 +734,7 @@ void ColorPicker::_slider_draw(int p_which) { #endif if (p_which == 3) { - scroll[p_which]->draw_texture_rect(get_theme_icon("preset_bg", "ColorPicker"), Rect2(Point2(0, margin), Size2(size.x, margin)), true); + scroll[p_which]->draw_texture_rect(get_theme_icon(SNAME("preset_bg"), SNAME("ColorPicker")), Rect2(Point2(0, margin), Size2(size.x, margin)), true); left_color = color; left_color.a = 0; @@ -740,7 +746,7 @@ void ColorPicker::_slider_draw(int p_which) { } if (hsv_mode_enabled) { if (p_which == 0) { - Ref<Texture2D> hue = get_theme_icon("color_hue", "ColorPicker"); + Ref<Texture2D> hue = get_theme_icon(SNAME("color_hue"), SNAME("ColorPicker")); scroll[p_which]->draw_set_transform(Point2(), -Math_PI / 2, Size2(1.0, 1.0)); scroll[p_which]->draw_texture_rect(hue, Rect2(Vector2(margin * -2, 0), Vector2(scroll[p_which]->get_size().x, margin)), false, Color(1, 1, 1), true); return; @@ -826,10 +832,10 @@ void ColorPicker::_uv_input(const Ref<InputEvent> &p_event, Control *c) { set_pick_color(color); _update_color(); if (!deferred_mode_enabled) { - emit_signal("color_changed", color); + emit_signal(SNAME("color_changed"), color); } } else if (deferred_mode_enabled && !bev->is_pressed() && bev->get_button_index() == MOUSE_BUTTON_LEFT) { - emit_signal("color_changed", color); + emit_signal(SNAME("color_changed"), color); changing_color = false; spinning = false; } else { @@ -873,7 +879,7 @@ void ColorPicker::_uv_input(const Ref<InputEvent> &p_event, Control *c) { set_pick_color(color); _update_color(); if (!deferred_mode_enabled) { - emit_signal("color_changed", color); + emit_signal(SNAME("color_changed"), color); } } } @@ -898,9 +904,9 @@ void ColorPicker::_w_input(const Ref<InputEvent> &p_event) { set_pick_color(color); _update_color(); if (!deferred_mode_enabled) { - emit_signal("color_changed", color); + emit_signal(SNAME("color_changed"), color); } else if (!bev->is_pressed() && bev->get_button_index() == MOUSE_BUTTON_LEFT) { - emit_signal("color_changed", color); + emit_signal(SNAME("color_changed"), color); } } @@ -921,7 +927,7 @@ void ColorPicker::_w_input(const Ref<InputEvent> &p_event) { set_pick_color(color); _update_color(); if (!deferred_mode_enabled) { - emit_signal("color_changed", color); + emit_signal(SNAME("color_changed"), color); } } } @@ -941,12 +947,12 @@ void ColorPicker::_preset_input(const Ref<InputEvent> &p_event) { } set_pick_color(presets[index]); _update_color(); - emit_signal("color_changed", color); + emit_signal(SNAME("color_changed"), color); } else if (bev->is_pressed() && bev->get_button_index() == MOUSE_BUTTON_RIGHT && presets_enabled) { index = bev->get_position().x / (preset->get_size().x / presets.size()); Color clicked_preset = presets[index]; erase_preset(clicked_preset); - emit_signal("preset_removed", clicked_preset); + emit_signal(SNAME("preset_removed"), clicked_preset); bt_add_preset->show(); } } @@ -972,7 +978,7 @@ void ColorPicker::_screen_input(const Ref<InputEvent> &p_event) { Ref<InputEventMouseButton> bev = p_event; if (bev.is_valid() && bev->get_button_index() == MOUSE_BUTTON_LEFT && !bev->is_pressed()) { - emit_signal("color_changed", color); + emit_signal(SNAME("color_changed"), color); screen->hide(); } @@ -995,7 +1001,7 @@ void ColorPicker::_screen_input(const Ref<InputEvent> &p_event) { void ColorPicker::_add_preset_pressed() { add_preset(color); - emit_signal("preset_added", color); + emit_signal(SNAME("preset_added"), color); } void ColorPicker::_screen_pick_pressed() { @@ -1012,7 +1018,7 @@ void ColorPicker::_screen_pick_pressed() { screen->set_default_cursor_shape(CURSOR_POINTING_HAND); screen->connect("gui_input", callable_mp(this, &ColorPicker::_screen_input)); // It immediately toggles off in the first press otherwise. - screen->call_deferred("connect", "hidden", Callable(btn_pick, "set_pressed"), varray(false)); + screen->call_deferred(SNAME("connect"), "hidden", Callable(btn_pick, "set_pressed"), varray(false)); } screen->raise(); #ifndef _MSC_VER @@ -1048,7 +1054,7 @@ void ColorPicker::_focus_exit() { } void ColorPicker::_html_focus_exit() { - if (c_text->get_menu()->is_visible()) { + if (c_text->is_menu_visible()) { return; } _html_submitted(c_text->get_text()); @@ -1131,7 +1137,7 @@ ColorPicker::ColorPicker() : uv_edit->set_mouse_filter(MOUSE_FILTER_PASS); uv_edit->set_h_size_flags(SIZE_EXPAND_FILL); uv_edit->set_v_size_flags(SIZE_EXPAND_FILL); - uv_edit->set_custom_minimum_size(Size2(get_theme_constant("sv_width"), get_theme_constant("sv_height"))); + uv_edit->set_custom_minimum_size(Size2(get_theme_constant(SNAME("sv_width")), get_theme_constant(SNAME("sv_height")))); uv_edit->connect("draw", callable_mp(this, &ColorPicker::_hsv_draw), make_binds(0, uv_edit)); HBoxContainer *hb_smpl = memnew(HBoxContainer); @@ -1161,7 +1167,7 @@ ColorPicker::ColorPicker() : HBoxContainer *hbc = memnew(HBoxContainer); labels[i] = memnew(Label()); - labels[i]->set_custom_minimum_size(Size2(get_theme_constant("label_width"), 0)); + labels[i]->set_custom_minimum_size(Size2(get_theme_constant(SNAME("label_width")), 0)); labels[i]->set_v_size_flags(SIZE_SHRINK_CENTER); hbc->add_child(labels[i]); @@ -1220,7 +1226,7 @@ ColorPicker::ColorPicker() : wheel_edit->set_h_size_flags(SIZE_EXPAND_FILL); wheel_edit->set_v_size_flags(SIZE_EXPAND_FILL); - wheel_edit->set_custom_minimum_size(Size2(get_theme_constant("sv_width"), get_theme_constant("sv_height"))); + wheel_edit->set_custom_minimum_size(Size2(get_theme_constant(SNAME("sv_width")), get_theme_constant(SNAME("sv_height")))); hb_edit->add_child(wheel_edit); wheel_mat.instantiate(); @@ -1245,7 +1251,7 @@ ColorPicker::ColorPicker() : wheel_uv->connect("draw", callable_mp(this, &ColorPicker::_hsv_draw), make_binds(0, wheel_uv)); hb_edit->add_child(w_edit); - w_edit->set_custom_minimum_size(Size2(get_theme_constant("h_width"), 0)); + w_edit->set_custom_minimum_size(Size2(get_theme_constant(SNAME("h_width")), 0)); w_edit->set_h_size_flags(SIZE_FILL); w_edit->set_v_size_flags(SIZE_EXPAND_FILL); w_edit->connect("gui_input", callable_mp(this, &ColorPicker::_w_input)); @@ -1285,11 +1291,11 @@ void ColorPickerButton::_about_to_popup() { void ColorPickerButton::_color_changed(const Color &p_color) { color = p_color; update(); - emit_signal("color_changed", color); + emit_signal(SNAME("color_changed"), color); } void ColorPickerButton::_modal_closed() { - emit_signal("popup_closed"); + emit_signal(SNAME("popup_closed")); set_pressed(false); } @@ -1327,14 +1333,14 @@ void ColorPickerButton::pressed() { void ColorPickerButton::_notification(int p_what) { switch (p_what) { case NOTIFICATION_DRAW: { - const Ref<StyleBox> normal = get_theme_stylebox("normal"); + const Ref<StyleBox> normal = get_theme_stylebox(SNAME("normal")); const Rect2 r = Rect2(normal->get_offset(), get_size() - normal->get_minimum_size()); - draw_texture_rect(Control::get_theme_icon("bg", "ColorPickerButton"), r, true); + draw_texture_rect(Control::get_theme_icon(SNAME("bg"), SNAME("ColorPickerButton")), r, true); draw_rect(r, color); if (color.r > 1 || color.g > 1 || color.b > 1) { // Draw an indicator to denote that the color is "overbright" and can't be displayed accurately in the preview - draw_texture(Control::get_theme_icon("overbright_indicator", "ColorPicker"), normal->get_offset()); + draw_texture(Control::get_theme_icon(SNAME("overbright_indicator"), SNAME("ColorPicker")), normal->get_offset()); } } break; case NOTIFICATION_WM_CLOSE_REQUEST: { @@ -1399,7 +1405,7 @@ void ColorPickerButton::_update_picker() { picker->set_pick_color(color); picker->set_edit_alpha(edit_alpha); picker->set_display_old_color(true); - emit_signal("picker_created"); + emit_signal(SNAME("picker_created")); } } diff --git a/scene/gui/container.cpp b/scene/gui/container.cpp index dea69aae6b..c97434f69b 100644 --- a/scene/gui/container.cpp +++ b/scene/gui/container.cpp @@ -47,9 +47,9 @@ void Container::add_child_notify(Node *p_child) { return; } - control->connect("size_flags_changed", callable_mp(this, &Container::queue_sort)); - control->connect("minimum_size_changed", callable_mp(this, &Container::_child_minsize_changed)); - control->connect("visibility_changed", callable_mp(this, &Container::_child_minsize_changed)); + control->connect(SNAME("size_flags_changed"), callable_mp(this, &Container::queue_sort)); + control->connect(SNAME("minimum_size_changed"), callable_mp(this, &Container::_child_minsize_changed)); + control->connect(SNAME("visibility_changed"), callable_mp(this, &Container::_child_minsize_changed)); minimum_size_changed(); queue_sort(); diff --git a/scene/gui/control.cpp b/scene/gui/control.cpp index 718e754514..a2e6872da6 100644 --- a/scene/gui/control.cpp +++ b/scene/gui/control.cpp @@ -222,41 +222,42 @@ Transform2D Control::_get_internal_transform() const { bool Control::_set(const StringName &p_name, const Variant &p_value) { String name = p_name; - if (!name.begins_with("custom")) { + // Prefixes "custom_*" are supported for compatibility with 3.x. + if (!name.begins_with("theme_override") && !name.begins_with("custom")) { return false; } if (p_value.get_type() == Variant::NIL) { - if (name.begins_with("custom_icons/")) { + if (name.begins_with("theme_override_icons/") || name.begins_with("custom_icons/")) { String dname = name.get_slicec('/', 1); if (data.icon_override.has(dname)) { data.icon_override[dname]->disconnect("changed", callable_mp(this, &Control::_override_changed)); } data.icon_override.erase(dname); notification(NOTIFICATION_THEME_CHANGED); - } else if (name.begins_with("custom_styles/")) { + } else if (name.begins_with("theme_override_styles/") || name.begins_with("custom_styles/")) { String dname = name.get_slicec('/', 1); if (data.style_override.has(dname)) { data.style_override[dname]->disconnect("changed", callable_mp(this, &Control::_override_changed)); } data.style_override.erase(dname); notification(NOTIFICATION_THEME_CHANGED); - } else if (name.begins_with("custom_fonts/")) { + } else if (name.begins_with("theme_override_fonts/") || name.begins_with("custom_fonts/")) { String dname = name.get_slicec('/', 1); if (data.font_override.has(dname)) { data.font_override[dname]->disconnect("changed", callable_mp(this, &Control::_override_changed)); } data.font_override.erase(dname); notification(NOTIFICATION_THEME_CHANGED); - } else if (name.begins_with("custom_font_sizes/")) { + } else if (name.begins_with("theme_override_font_sizes/") || name.begins_with("custom_font_sizes/")) { String dname = name.get_slicec('/', 1); data.font_size_override.erase(dname); notification(NOTIFICATION_THEME_CHANGED); - } else if (name.begins_with("custom_colors/")) { + } else if (name.begins_with("theme_override_colors/") || name.begins_with("custom_colors/")) { String dname = name.get_slicec('/', 1); data.color_override.erase(dname); notification(NOTIFICATION_THEME_CHANGED); - } else if (name.begins_with("custom_constants/")) { + } else if (name.begins_with("theme_override_constants/") || name.begins_with("custom_constants/")) { String dname = name.get_slicec('/', 1); data.constant_override.erase(dname); notification(NOTIFICATION_THEME_CHANGED); @@ -265,22 +266,22 @@ bool Control::_set(const StringName &p_name, const Variant &p_value) { } } else { - if (name.begins_with("custom_icons/")) { + if (name.begins_with("theme_override_icons/") || name.begins_with("custom_icons/")) { String dname = name.get_slicec('/', 1); add_theme_icon_override(dname, p_value); - } else if (name.begins_with("custom_styles/")) { + } else if (name.begins_with("theme_override_styles/") || name.begins_with("custom_styles/")) { String dname = name.get_slicec('/', 1); add_theme_style_override(dname, p_value); - } else if (name.begins_with("custom_fonts/")) { + } else if (name.begins_with("theme_override_fonts/") || name.begins_with("custom_fonts/")) { String dname = name.get_slicec('/', 1); add_theme_font_override(dname, p_value); - } else if (name.begins_with("custom_font_sizes/")) { + } else if (name.begins_with("theme_override_font_sizes/") || name.begins_with("custom_font_sizes/")) { String dname = name.get_slicec('/', 1); add_theme_font_size_override(dname, p_value); - } else if (name.begins_with("custom_colors/")) { + } else if (name.begins_with("theme_override_colors/") || name.begins_with("custom_colors/")) { String dname = name.get_slicec('/', 1); add_theme_color_override(dname, p_value); - } else if (name.begins_with("custom_constants/")) { + } else if (name.begins_with("theme_override_constants/") || name.begins_with("custom_constants/")) { String dname = name.get_slicec('/', 1); add_theme_constant_override(dname, p_value); } else { @@ -307,27 +308,26 @@ void Control::_update_minimum_size() { bool Control::_get(const StringName &p_name, Variant &r_ret) const { String sname = p_name; - - if (!sname.begins_with("custom")) { + if (!sname.begins_with("theme_override")) { return false; } - if (sname.begins_with("custom_icons/")) { + if (sname.begins_with("theme_override_icons/")) { String name = sname.get_slicec('/', 1); r_ret = data.icon_override.has(name) ? Variant(data.icon_override[name]) : Variant(); - } else if (sname.begins_with("custom_styles/")) { + } else if (sname.begins_with("theme_override_styles/")) { String name = sname.get_slicec('/', 1); r_ret = data.style_override.has(name) ? Variant(data.style_override[name]) : Variant(); - } else if (sname.begins_with("custom_fonts/")) { + } else if (sname.begins_with("theme_override_fonts/")) { String name = sname.get_slicec('/', 1); r_ret = data.font_override.has(name) ? Variant(data.font_override[name]) : Variant(); - } else if (sname.begins_with("custom_font_sizes/")) { + } else if (sname.begins_with("theme_override_font_sizes/")) { String name = sname.get_slicec('/', 1); r_ret = data.font_size_override.has(name) ? Variant(data.font_size_override[name]) : Variant(); - } else if (sname.begins_with("custom_colors/")) { + } else if (sname.begins_with("theme_override_colors/")) { String name = sname.get_slicec('/', 1); r_ret = data.color_override.has(name) ? Variant(data.color_override[name]) : Variant(); - } else if (sname.begins_with("custom_constants/")) { + } else if (sname.begins_with("theme_override_constants/")) { String name = sname.get_slicec('/', 1); r_ret = data.constant_override.has(name) ? Variant(data.constant_override[name]) : Variant(); } else { @@ -340,76 +340,78 @@ bool Control::_get(const StringName &p_name, Variant &r_ret) const { void Control::_get_property_list(List<PropertyInfo> *p_list) const { Ref<Theme> theme = Theme::get_default(); + p_list->push_back(PropertyInfo(Variant::NIL, "Theme Overrides", PROPERTY_HINT_NONE, "theme_override_", PROPERTY_USAGE_GROUP)); + { List<StringName> names; - theme->get_icon_list(get_class_name(), &names); - for (List<StringName>::Element *E = names.front(); E; E = E->next()) { + theme->get_color_list(get_class_name(), &names); + for (const StringName &E : names) { uint32_t usage = PROPERTY_USAGE_EDITOR | PROPERTY_USAGE_CHECKABLE; - if (data.icon_override.has(E->get())) { + if (data.color_override.has(E)) { usage |= PROPERTY_USAGE_STORAGE | PROPERTY_USAGE_CHECKED; } - p_list->push_back(PropertyInfo(Variant::OBJECT, "custom_icons/" + E->get(), PROPERTY_HINT_RESOURCE_TYPE, "Texture2D", usage)); + p_list->push_back(PropertyInfo(Variant::COLOR, "theme_override_colors/" + E, PROPERTY_HINT_NONE, "", usage)); } } { List<StringName> names; - theme->get_stylebox_list(get_class_name(), &names); - for (List<StringName>::Element *E = names.front(); E; E = E->next()) { + theme->get_constant_list(get_class_name(), &names); + for (const StringName &E : names) { uint32_t usage = PROPERTY_USAGE_EDITOR | PROPERTY_USAGE_CHECKABLE; - if (data.style_override.has(E->get())) { + if (data.constant_override.has(E)) { usage |= PROPERTY_USAGE_STORAGE | PROPERTY_USAGE_CHECKED; } - p_list->push_back(PropertyInfo(Variant::OBJECT, "custom_styles/" + E->get(), PROPERTY_HINT_RESOURCE_TYPE, "StyleBox", usage)); + p_list->push_back(PropertyInfo(Variant::INT, "theme_override_constants/" + E, PROPERTY_HINT_RANGE, "-16384,16384", usage)); } } { List<StringName> names; theme->get_font_list(get_class_name(), &names); - for (List<StringName>::Element *E = names.front(); E; E = E->next()) { + for (const StringName &E : names) { uint32_t usage = PROPERTY_USAGE_EDITOR | PROPERTY_USAGE_CHECKABLE; - if (data.font_override.has(E->get())) { + if (data.font_override.has(E)) { usage |= PROPERTY_USAGE_STORAGE | PROPERTY_USAGE_CHECKED; } - p_list->push_back(PropertyInfo(Variant::OBJECT, "custom_fonts/" + E->get(), PROPERTY_HINT_RESOURCE_TYPE, "Font", usage)); + p_list->push_back(PropertyInfo(Variant::OBJECT, "theme_override_fonts/" + E, PROPERTY_HINT_RESOURCE_TYPE, "Font", usage)); } } { List<StringName> names; theme->get_font_size_list(get_class_name(), &names); - for (List<StringName>::Element *E = names.front(); E; E = E->next()) { + for (const StringName &E : names) { uint32_t usage = PROPERTY_USAGE_EDITOR | PROPERTY_USAGE_CHECKABLE; - if (data.font_size_override.has(E->get())) { + if (data.font_size_override.has(E)) { usage |= PROPERTY_USAGE_STORAGE | PROPERTY_USAGE_CHECKED; } - p_list->push_back(PropertyInfo(Variant::INT, "custom_font_sizes/" + E->get(), PROPERTY_HINT_NONE, "", usage)); + p_list->push_back(PropertyInfo(Variant::INT, "theme_override_font_sizes/" + E, PROPERTY_HINT_NONE, "", usage)); } } { List<StringName> names; - theme->get_color_list(get_class_name(), &names); - for (List<StringName>::Element *E = names.front(); E; E = E->next()) { + theme->get_icon_list(get_class_name(), &names); + for (const StringName &E : names) { uint32_t usage = PROPERTY_USAGE_EDITOR | PROPERTY_USAGE_CHECKABLE; - if (data.color_override.has(E->get())) { + if (data.icon_override.has(E)) { usage |= PROPERTY_USAGE_STORAGE | PROPERTY_USAGE_CHECKED; } - p_list->push_back(PropertyInfo(Variant::COLOR, "custom_colors/" + E->get(), PROPERTY_HINT_NONE, "", usage)); + p_list->push_back(PropertyInfo(Variant::OBJECT, "theme_override_icons/" + E, PROPERTY_HINT_RESOURCE_TYPE, "Texture2D", usage)); } } { List<StringName> names; - theme->get_constant_list(get_class_name(), &names); - for (List<StringName>::Element *E = names.front(); E; E = E->next()) { + theme->get_stylebox_list(get_class_name(), &names); + for (const StringName &E : names) { uint32_t usage = PROPERTY_USAGE_EDITOR | PROPERTY_USAGE_CHECKABLE; - if (data.constant_override.has(E->get())) { + if (data.style_override.has(E)) { usage |= PROPERTY_USAGE_STORAGE | PROPERTY_USAGE_CHECKED; } - p_list->push_back(PropertyInfo(Variant::INT, "custom_constants/" + E->get(), PROPERTY_HINT_RANGE, "-16384,16384", usage)); + p_list->push_back(PropertyInfo(Variant::OBJECT, "theme_override_styles/" + E, PROPERTY_HINT_RESOURCE_TYPE, "StyleBox", usage)); } } } @@ -428,14 +430,14 @@ void Control::_validate_property(PropertyInfo &property) const { Vector<StringName> unique_names; String hint_string; - for (List<StringName>::Element *E = names.front(); E; E = E->next()) { + for (const StringName &E : names) { // Skip duplicate values. - if (unique_names.has(E->get())) { + if (unique_names.has(E)) { continue; } - hint_string += String(E->get()) + ","; - unique_names.append(E->get()); + hint_string += String(E) + ","; + unique_names.append(E); } property.hint_string = hint_string; @@ -446,10 +448,16 @@ Control *Control::get_parent_control() const { return data.parent; } +Window *Control::get_parent_window() const { + return data.parent_window; +} + void Control::set_layout_direction(Control::LayoutDirection p_direction) { ERR_FAIL_INDEX((int)p_direction, 4); data.layout_dir = p_direction; + data.is_rtl_dirty = true; + propagate_notification(NOTIFICATION_LAYOUT_DIRECTION_CHANGED); } @@ -458,29 +466,49 @@ Control::LayoutDirection Control::get_layout_direction() const { } bool Control::is_layout_rtl() const { - if (data.layout_dir == LAYOUT_DIRECTION_INHERITED) { - Window *parent_window = Object::cast_to<Window>(get_parent()); - Control *parent_control = get_parent_control(); - if (parent_control) { - return parent_control->is_layout_rtl(); - } else if (parent_window) { - return parent_window->is_layout_rtl(); - } else { - if (GLOBAL_GET("internationalization/rendering/force_right_to_left_layout_direction")) { - return true; + if (data.is_rtl_dirty) { + const_cast<Control *>(this)->data.is_rtl_dirty = false; + if (data.layout_dir == LAYOUT_DIRECTION_INHERITED) { + Window *parent_window = get_parent_window(); + Control *parent_control = get_parent_control(); + if (parent_control) { + const_cast<Control *>(this)->data.is_rtl = parent_control->is_layout_rtl(); + } else if (parent_window) { + const_cast<Control *>(this)->data.is_rtl = parent_window->is_layout_rtl(); + } else { + if (GLOBAL_GET(SNAME("internationalization/rendering/force_right_to_left_layout_direction"))) { + const_cast<Control *>(this)->data.is_rtl = true; + } else { + String locale = TranslationServer::get_singleton()->get_tool_locale(); + const_cast<Control *>(this)->data.is_rtl = TS->is_locale_right_to_left(locale); + } } - String locale = TranslationServer::get_singleton()->get_tool_locale(); - return TS->is_locale_right_to_left(locale); - } - } else if (data.layout_dir == LAYOUT_DIRECTION_LOCALE) { - if (GLOBAL_GET("internationalization/rendering/force_right_to_left_layout_direction")) { - return true; + } else if (data.layout_dir == LAYOUT_DIRECTION_LOCALE) { + if (GLOBAL_GET(SNAME("internationalization/rendering/force_right_to_left_layout_direction"))) { + const_cast<Control *>(this)->data.is_rtl = true; + } else { + String locale = TranslationServer::get_singleton()->get_tool_locale(); + const_cast<Control *>(this)->data.is_rtl = TS->is_locale_right_to_left(locale); + } + } else { + const_cast<Control *>(this)->data.is_rtl = (data.layout_dir == LAYOUT_DIRECTION_RTL); } - String locale = TranslationServer::get_singleton()->get_tool_locale(); - return TS->is_locale_right_to_left(locale); - } else { - return (data.layout_dir == LAYOUT_DIRECTION_RTL); } + return data.is_rtl; +} + +void Control::set_auto_translate(bool p_enable) { + if (p_enable == data.auto_translate) { + return; + } + + data.auto_translate = p_enable; + + notification(MainLoop::NOTIFICATION_TRANSLATION_CHANGED); +} + +bool Control::is_auto_translating() const { + return data.auto_translate; } void Control::_clear_size_warning() { @@ -530,6 +558,7 @@ void Control::_notification(int p_notification) { } break; case NOTIFICATION_POST_ENTER_TREE: { data.minimum_size_valid = false; + data.is_rtl_dirty = true; _size_changed(); } break; case NOTIFICATION_EXIT_TREE: { @@ -543,6 +572,8 @@ void Control::_notification(int p_notification) { case NOTIFICATION_ENTER_CANVAS: { data.parent = Object::cast_to<Control>(get_parent()); + data.parent_window = Object::cast_to<Window>(get_parent()); + data.is_rtl_dirty = true; Node *parent = this; //meh Control *parent_control = nullptr; @@ -607,6 +638,8 @@ void Control::_notification(int p_notification) { data.parent = nullptr; data.parent_canvas_item = nullptr; + data.parent_window = nullptr; + data.is_rtl_dirty = true; } break; case NOTIFICATION_MOVED_IN_PARENT: { @@ -666,6 +699,7 @@ void Control::_notification(int p_notification) { } break; case NOTIFICATION_TRANSLATION_CHANGED: case NOTIFICATION_LAYOUT_DIRECTION_CHANGED: { + data.is_rtl_dirty = true; _size_changed(); } break; } @@ -787,13 +821,13 @@ T Control::get_theme_item_in_types(Control *p_theme_owner, Window *p_theme_owner Window *theme_owner_window = p_theme_owner_window; while (theme_owner || theme_owner_window) { - for (List<StringName>::Element *E = p_theme_types.front(); E; E = E->next()) { - if (theme_owner && theme_owner->data.theme->has_theme_item(p_data_type, p_name, E->get())) { - return theme_owner->data.theme->get_theme_item(p_data_type, p_name, E->get()); + for (const StringName &E : p_theme_types) { + if (theme_owner && theme_owner->data.theme->has_theme_item(p_data_type, p_name, E)) { + return theme_owner->data.theme->get_theme_item(p_data_type, p_name, E); } - if (theme_owner_window && theme_owner_window->theme->has_theme_item(p_data_type, p_name, E->get())) { - return theme_owner_window->theme->get_theme_item(p_data_type, p_name, E->get()); + if (theme_owner_window && theme_owner_window->theme->has_theme_item(p_data_type, p_name, E)) { + return theme_owner_window->theme->get_theme_item(p_data_type, p_name, E); } } @@ -816,17 +850,17 @@ T Control::get_theme_item_in_types(Control *p_theme_owner, Window *p_theme_owner // Secondly, check the project-defined Theme resource. if (Theme::get_project_default().is_valid()) { - for (List<StringName>::Element *E = p_theme_types.front(); E; E = E->next()) { - if (Theme::get_project_default()->has_theme_item(p_data_type, p_name, E->get())) { - return Theme::get_project_default()->get_theme_item(p_data_type, p_name, E->get()); + for (const StringName &E : p_theme_types) { + if (Theme::get_project_default()->has_theme_item(p_data_type, p_name, E)) { + return Theme::get_project_default()->get_theme_item(p_data_type, p_name, E); } } } // Lastly, fall back on the items defined in the default Theme, if they exist. - for (List<StringName>::Element *E = p_theme_types.front(); E; E = E->next()) { - if (Theme::get_default()->has_theme_item(p_data_type, p_name, E->get())) { - return Theme::get_default()->get_theme_item(p_data_type, p_name, E->get()); + for (const StringName &E : p_theme_types) { + if (Theme::get_default()->has_theme_item(p_data_type, p_name, E)) { + return Theme::get_default()->get_theme_item(p_data_type, p_name, E); } } // If they don't exist, use any type to return the default/empty value. @@ -842,12 +876,12 @@ bool Control::has_theme_item_in_types(Control *p_theme_owner, Window *p_theme_ow Window *theme_owner_window = p_theme_owner_window; while (theme_owner || theme_owner_window) { - for (List<StringName>::Element *E = p_theme_types.front(); E; E = E->next()) { - if (theme_owner && theme_owner->data.theme->has_theme_item(p_data_type, p_name, E->get())) { + for (const StringName &E : p_theme_types) { + if (theme_owner && theme_owner->data.theme->has_theme_item(p_data_type, p_name, E)) { return true; } - if (theme_owner_window && theme_owner_window->theme->has_theme_item(p_data_type, p_name, E->get())) { + if (theme_owner_window && theme_owner_window->theme->has_theme_item(p_data_type, p_name, E)) { return true; } } @@ -871,16 +905,16 @@ bool Control::has_theme_item_in_types(Control *p_theme_owner, Window *p_theme_ow // Secondly, check the project-defined Theme resource. if (Theme::get_project_default().is_valid()) { - for (List<StringName>::Element *E = p_theme_types.front(); E; E = E->next()) { - if (Theme::get_project_default()->has_theme_item(p_data_type, p_name, E->get())) { + for (const StringName &E : p_theme_types) { + if (Theme::get_project_default()->has_theme_item(p_data_type, p_name, E)) { return true; } } } // Lastly, fall back on the items defined in the default Theme, if they exist. - for (List<StringName>::Element *E = p_theme_types.front(); E; E = E->next()) { - if (Theme::get_default()->has_theme_item(p_data_type, p_name, E->get())) { + for (const StringName &E : p_theme_types) { + if (Theme::get_default()->has_theme_item(p_data_type, p_name, E)) { return true; } } @@ -1588,7 +1622,7 @@ void Control::set_rect(const Rect2 &p_rect) { void Control::_set_size(const Size2 &p_size) { #ifdef DEBUG_ENABLED if (data.size_warning && (data.anchor[SIDE_LEFT] != data.anchor[SIDE_RIGHT] || data.anchor[SIDE_TOP] != data.anchor[SIDE_BOTTOM])) { - WARN_PRINT("Nodes with non-equal opposite anchors will have their size overriden after _ready(). \nIf you want to set size, change the anchors or consider using set_deferred()."); + WARN_PRINT("Nodes with non-equal opposite anchors will have their size overridden after _ready(). \nIf you want to set size, change the anchors or consider using set_deferred()."); } #endif set_size(p_size); @@ -2574,8 +2608,8 @@ void Control::get_argument_options(const StringName &p_function, int p_idx, List } sn.sort_custom<StringName::AlphCompare>(); - for (List<StringName>::Element *E = sn.front(); E; E = E->next()) { - r_options->push_back(quote_style + E->get() + quote_style); + for (const StringName &E : sn) { + r_options->push_back(quote_style + E + quote_style); } } } @@ -2766,6 +2800,9 @@ void Control::_bind_methods() { ClassDB::bind_method(D_METHOD("get_layout_direction"), &Control::get_layout_direction); ClassDB::bind_method(D_METHOD("is_layout_rtl"), &Control::is_layout_rtl); + ClassDB::bind_method(D_METHOD("set_auto_translate", "enable"), &Control::set_auto_translate); + ClassDB::bind_method(D_METHOD("is_auto_translating"), &Control::is_auto_translating); + BIND_VMETHOD(MethodInfo("_structured_text_parser", PropertyInfo(Variant::ARRAY, "args"), PropertyInfo(Variant::STRING, "text"))); BIND_VMETHOD(MethodInfo("_gui_input", PropertyInfo(Variant::OBJECT, "event", PROPERTY_HINT_RESOURCE_TYPE, "InputEvent"))); @@ -2800,6 +2837,9 @@ void Control::_bind_methods() { ADD_GROUP("Layout Direction", "layout_"); ADD_PROPERTY(PropertyInfo(Variant::INT, "layout_direction", PROPERTY_HINT_ENUM, "Inherited,Locale,Left-to-Right,Right-to-Left"), "set_layout_direction", "get_layout_direction"); + ADD_GROUP("Auto Translate", ""); + ADD_PROPERTY(PropertyInfo(Variant::BOOL, "auto_translate"), "set_auto_translate", "is_auto_translating"); + ADD_GROUP("Rect", "rect_"); ADD_PROPERTY(PropertyInfo(Variant::VECTOR2, "rect_position", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_EDITOR), "_set_position", "get_position"); ADD_PROPERTY(PropertyInfo(Variant::VECTOR2, "rect_global_position", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_NONE), "_set_global_position", "get_global_position"); @@ -2830,10 +2870,10 @@ void Control::_bind_methods() { ADD_PROPERTY(PropertyInfo(Variant::INT, "size_flags_horizontal", PROPERTY_HINT_FLAGS, "Fill,Expand,Shrink Center,Shrink End"), "set_h_size_flags", "get_h_size_flags"); ADD_PROPERTY(PropertyInfo(Variant::INT, "size_flags_vertical", PROPERTY_HINT_FLAGS, "Fill,Expand,Shrink Center,Shrink End"), "set_v_size_flags", "get_v_size_flags"); ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "size_flags_stretch_ratio", PROPERTY_HINT_RANGE, "0,20,0.01,or_greater"), "set_stretch_ratio", "get_stretch_ratio"); + ADD_GROUP("Theme", "theme_"); ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "theme", PROPERTY_HINT_RESOURCE_TYPE, "Theme"), "set_theme", "get_theme"); ADD_PROPERTY(PropertyInfo(Variant::STRING, "theme_type_variation", PROPERTY_HINT_ENUM_SUGGESTION), "set_theme_type_variation", "get_theme_type_variation"); - ADD_GROUP("", ""); BIND_ENUM_CONSTANT(FOCUS_NONE); BIND_ENUM_CONSTANT(FOCUS_CLICK); diff --git a/scene/gui/control.h b/scene/gui/control.h index fb01295668..8d669c7a6d 100644 --- a/scene/gui/control.h +++ b/scene/gui/control.h @@ -179,6 +179,10 @@ private: GrowDirection v_grow = GROW_DIRECTION_END; LayoutDirection layout_dir = LAYOUT_DIRECTION_INHERITED; + bool is_rtl_dirty = true; + bool is_rtl = false; + + bool auto_translate = true; real_t rotation = 0.0; Vector2 scale = Vector2(1, 1); @@ -202,6 +206,7 @@ private: Ref<Theme> theme; Control *theme_owner = nullptr; Window *theme_owner_window = nullptr; + Window *parent_window = nullptr; StringName theme_type_variation; String tooltip; @@ -342,11 +347,16 @@ public: Size2 get_custom_minimum_size() const; Control *get_parent_control() const; + Window *get_parent_window() const; void set_layout_direction(LayoutDirection p_direction); LayoutDirection get_layout_direction() const; virtual bool is_layout_rtl() const; + void set_auto_translate(bool p_enable); + bool is_auto_translating() const; + _FORCE_INLINE_ String atr(const String p_string) const { return is_auto_translating() ? tr(p_string) : p_string; }; + /* POSITIONING */ void set_anchors_preset(LayoutPreset p_preset, bool p_keep_offsets = true); diff --git a/scene/gui/dialogs.cpp b/scene/gui/dialogs.cpp index 9d0a6a3380..da858e8e83 100644 --- a/scene/gui/dialogs.cpp +++ b/scene/gui/dialogs.cpp @@ -72,13 +72,10 @@ void AcceptDialog::_notification(int p_what) { parent_visible = nullptr; } } - } break; - case NOTIFICATION_THEME_CHANGED: { - bg->add_theme_style_override("panel", bg->get_theme_stylebox("panel", "AcceptDialog")); + bg->add_theme_style_override("panel", bg->get_theme_stylebox(SNAME("panel"), SNAME("AcceptDialog"))); } break; - case NOTIFICATION_EXIT_TREE: { if (parent_visible) { parent_visible->disconnect("focus_entered", callable_mp(this, &AcceptDialog::_parent_focused)); @@ -106,7 +103,7 @@ void AcceptDialog::_ok_pressed() { set_visible(false); } ok_pressed(); - emit_signal("confirmed"); + emit_signal(SNAME("confirmed")); } void AcceptDialog::_cancel_pressed() { @@ -116,9 +113,9 @@ void AcceptDialog::_cancel_pressed() { parent_visible = nullptr; } - call_deferred("hide"); + call_deferred(SNAME("hide")); - emit_signal("cancelled"); + emit_signal(SNAME("cancelled")); cancel_pressed(); @@ -168,7 +165,7 @@ void AcceptDialog::_update_child_rects() { if (label->get_text().is_empty()) { label_size.height = 0; } - int margin = hbc->get_theme_constant("margin", "Dialogs"); + int margin = hbc->get_theme_constant(SNAME("margin"), SNAME("Dialogs")); Size2 size = get_size(); Size2 hminsize = hbc->get_combined_minimum_size(); @@ -200,7 +197,7 @@ void AcceptDialog::_update_child_rects() { } Size2 AcceptDialog::_get_contents_minimum_size() const { - int margin = hbc->get_theme_constant("margin", "Dialogs"); + int margin = hbc->get_theme_constant(SNAME("margin"), SNAME("Dialogs")); Size2 minsize = label->get_combined_minimum_size(); for (int i = 0; i < get_child_count(); i++) { @@ -230,7 +227,7 @@ Size2 AcceptDialog::_get_contents_minimum_size() const { } void AcceptDialog::_custom_action(const String &p_action) { - emit_signal("custom_action", p_action); + emit_signal(SNAME("custom_action"), p_action); custom_action(p_action); } @@ -326,8 +323,8 @@ AcceptDialog::AcceptDialog() { hbc = memnew(HBoxContainer); - int margin = hbc->get_theme_constant("margin", "Dialogs"); - int button_margin = hbc->get_theme_constant("button_margin", "Dialogs"); + int margin = hbc->get_theme_constant(SNAME("margin"), SNAME("Dialogs")); + int button_margin = hbc->get_theme_constant(SNAME("button_margin"), SNAME("Dialogs")); label = memnew(Label); label->set_anchor(SIDE_RIGHT, Control::ANCHOR_END); diff --git a/scene/gui/file_dialog.cpp b/scene/gui/file_dialog.cpp index f8cee6daec..2e4204e171 100644 --- a/scene/gui/file_dialog.cpp +++ b/scene/gui/file_dialog.cpp @@ -49,9 +49,9 @@ VBoxContainer *FileDialog::get_vbox() { } void FileDialog::_theme_changed() { - Color font_color = vbox->get_theme_color("font_color", "Button"); - Color font_hover_color = vbox->get_theme_color("font_hover_color", "Button"); - Color font_pressed_color = vbox->get_theme_color("font_pressed_color", "Button"); + Color font_color = vbox->get_theme_color(SNAME("font_color"), SNAME("Button")); + Color font_hover_color = vbox->get_theme_color(SNAME("font_hover_color"), SNAME("Button")); + Color font_pressed_color = vbox->get_theme_color(SNAME("font_pressed_color"), SNAME("Button")); dir_up->add_theme_color_override("icon_normal_color", font_color); dir_up->add_theme_color_override("icon_hover_color", font_hover_color); @@ -81,16 +81,16 @@ void FileDialog::_notification(int p_what) { } } if (p_what == NOTIFICATION_ENTER_TREE) { - dir_up->set_icon(vbox->get_theme_icon("parent_folder", "FileDialog")); + dir_up->set_icon(vbox->get_theme_icon(SNAME("parent_folder"), SNAME("FileDialog"))); if (vbox->is_layout_rtl()) { - dir_prev->set_icon(vbox->get_theme_icon("forward_folder", "FileDialog")); - dir_next->set_icon(vbox->get_theme_icon("back_folder", "FileDialog")); + dir_prev->set_icon(vbox->get_theme_icon(SNAME("forward_folder"), SNAME("FileDialog"))); + dir_next->set_icon(vbox->get_theme_icon(SNAME("back_folder"), SNAME("FileDialog"))); } else { - dir_prev->set_icon(vbox->get_theme_icon("back_folder", "FileDialog")); - dir_next->set_icon(vbox->get_theme_icon("forward_folder", "FileDialog")); + dir_prev->set_icon(vbox->get_theme_icon(SNAME("back_folder"), SNAME("FileDialog"))); + dir_next->set_icon(vbox->get_theme_icon(SNAME("forward_folder"), SNAME("FileDialog"))); } - refresh->set_icon(vbox->get_theme_icon("reload", "FileDialog")); - show_hidden->set_icon(vbox->get_theme_icon("toggle_hidden", "FileDialog")); + refresh->set_icon(vbox->get_theme_icon(SNAME("reload"), SNAME("FileDialog"))); + show_hidden->set_icon(vbox->get_theme_icon(SNAME("toggle_hidden"), SNAME("FileDialog"))); _theme_changed(); } } @@ -170,7 +170,7 @@ void FileDialog::_file_submitted(const String &p_file) { void FileDialog::_save_confirm_pressed() { String f = dir_access->get_current_dir().plus_file(file->get_text()); - emit_signal("file_selected", f); + emit_signal(SNAME("file_selected"), f); hide(); } @@ -224,7 +224,7 @@ void FileDialog::_action_pressed() { } if (files.size()) { - emit_signal("files_selected", files); + emit_signal(SNAME("files_selected"), files); hide(); } @@ -234,7 +234,7 @@ void FileDialog::_action_pressed() { String f = dir_access->get_current_dir().plus_file(file->get_text()); if ((mode == FILE_MODE_OPEN_ANY || mode == FILE_MODE_OPEN_FILE) && dir_access->file_exists(f)) { - emit_signal("file_selected", f); + emit_signal(SNAME("file_selected"), f); hide(); } else if (mode == FILE_MODE_OPEN_ANY || mode == FILE_MODE_OPEN_DIR) { String path = dir_access->get_current_dir(); @@ -248,7 +248,7 @@ void FileDialog::_action_pressed() { } } - emit_signal("dir_selected", path); + emit_signal(SNAME("dir_selected"), path); hide(); } @@ -308,7 +308,7 @@ void FileDialog::_action_pressed() { confirm_save->set_text(TTRC("File exists, overwrite?")); confirm_save->popup_centered(Size2(200, 80)); } else { - emit_signal("file_selected", f); + emit_signal(SNAME("file_selected"), f); hide(); } } @@ -437,8 +437,8 @@ void FileDialog::_tree_item_activated() { if (mode == FILE_MODE_OPEN_FILE || mode == FILE_MODE_OPEN_FILES || mode == FILE_MODE_OPEN_DIR || mode == FILE_MODE_OPEN_ANY) { file->set_text(""); } - call_deferred("_update_file_list"); - call_deferred("_update_dir"); + call_deferred(SNAME("_update_file_list")); + call_deferred(SNAME("_update_dir")); _push_history(); } else { _action_pressed(); @@ -468,10 +468,10 @@ void FileDialog::update_file_list() { dir_access->list_dir_begin(); TreeItem *root = tree->create_item(); - Ref<Texture2D> folder = vbox->get_theme_icon("folder", "FileDialog"); - Ref<Texture2D> file_icon = vbox->get_theme_icon("file", "FileDialog"); - const Color folder_color = vbox->get_theme_color("folder_icon_modulate", "FileDialog"); - const Color file_color = vbox->get_theme_color("file_icon_modulate", "FileDialog"); + Ref<Texture2D> folder = vbox->get_theme_icon(SNAME("folder"), SNAME("FileDialog")); + Ref<Texture2D> file_icon = vbox->get_theme_icon(SNAME("file"), SNAME("FileDialog")); + const Color folder_color = vbox->get_theme_color(SNAME("folder_icon_modulate"), SNAME("FileDialog")); + const Color file_color = vbox->get_theme_color(SNAME("file_icon_modulate"), SNAME("FileDialog")); List<String> files; List<String> dirs; @@ -552,9 +552,9 @@ void FileDialog::update_file_list() { bool match = patterns.is_empty(); String match_str; - for (List<String>::Element *E = patterns.front(); E; E = E->next()) { - if (files.front()->get().matchn(E->get())) { - match_str = E->get(); + for (const String &E : patterns) { + if (files.front()->get().matchn(E)) { + match_str = E; match = true; break; } @@ -573,7 +573,7 @@ void FileDialog::update_file_list() { ti->set_icon_modulate(0, file_color); if (mode == FILE_MODE_OPEN_DIR) { - ti->set_custom_color(0, vbox->get_theme_color("files_disabled", "FileDialog")); + ti->set_custom_color(0, vbox->get_theme_color(SNAME("files_disabled"), SNAME("FileDialog"))); ti->set_selectable(0, false); } Dictionary d; diff --git a/scene/gui/gradient_edit.cpp b/scene/gui/gradient_edit.cpp index 7278ca6e94..83ecf1d534 100644 --- a/scene/gui/gradient_edit.cpp +++ b/scene/gui/gradient_edit.cpp @@ -101,7 +101,7 @@ void GradientEdit::_gui_input(const Ref<InputEvent> &p_event) { grabbed = -1; grabbing = false; update(); - emit_signal("ramp_changed"); + emit_signal(SNAME("ramp_changed")); accept_event(); } @@ -121,7 +121,7 @@ void GradientEdit::_gui_input(const Ref<InputEvent> &p_event) { grabbed = -1; grabbing = false; update(); - emit_signal("ramp_changed"); + emit_signal(SNAME("ramp_changed")); accept_event(); } } @@ -145,7 +145,7 @@ void GradientEdit::_gui_input(const Ref<InputEvent> &p_event) { } } - emit_signal("ramp_changed"); + emit_signal(SNAME("ramp_changed")); update(); } } @@ -214,13 +214,13 @@ void GradientEdit::_gui_input(const Ref<InputEvent> &p_event) { } } - emit_signal("ramp_changed"); + emit_signal(SNAME("ramp_changed")); } if (mb.is_valid() && mb->get_button_index() == 1 && !mb->is_pressed()) { if (grabbing) { grabbing = false; - emit_signal("ramp_changed"); + emit_signal(SNAME("ramp_changed")); } update(); } @@ -288,7 +288,7 @@ void GradientEdit::_gui_input(const Ref<InputEvent> &p_event) { } } - emit_signal("ramp_changed"); + emit_signal(SNAME("ramp_changed")); update(); } @@ -436,7 +436,7 @@ void GradientEdit::_color_changed(const Color &p_color) { } points.write[grabbed].color = p_color; update(); - emit_signal("ramp_changed"); + emit_signal(SNAME("ramp_changed")); } void GradientEdit::set_ramp(const Vector<float> &p_offsets, const Vector<Color> &p_colors) { diff --git a/scene/gui/graph_edit.cpp b/scene/gui/graph_edit.cpp index 39aa6749e7..1fac2b9129 100644 --- a/scene/gui/graph_edit.cpp +++ b/scene/gui/graph_edit.cpp @@ -162,7 +162,7 @@ void GraphEditMinimap::_gui_input(const Ref<InputEvent> &p_ev) { if (mb->is_pressed()) { is_pressing = true; - Ref<Texture2D> resizer = get_theme_icon("resizer"); + Ref<Texture2D> resizer = get_theme_icon(SNAME("resizer")); Rect2 resizer_hitbox = Rect2(Point2(), resizer->get_size()); if (resizer_hitbox.has_point(mb->get_position())) { is_resizing = true; @@ -217,8 +217,8 @@ Error GraphEdit::connect_node(const StringName &p_from, int p_from_port, const S } bool GraphEdit::is_node_connected(const StringName &p_from, int p_from_port, const StringName &p_to, int p_to_port) { - for (List<Connection>::Element *E = connections.front(); E; E = E->next()) { - if (E->get().from == p_from && E->get().from_port == p_from_port && E->get().to == p_to && E->get().to_port == p_to_port) { + for (const Connection &E : connections) { + if (E.from == p_from && E.from_port == p_from_port && E.to == p_to && E.to_port == p_to_port) { return true; } } @@ -227,7 +227,7 @@ bool GraphEdit::is_node_connected(const StringName &p_from, int p_from_port, con } void GraphEdit::disconnect_node(const StringName &p_from, int p_from_port, const StringName &p_to, int p_to_port) { - for (List<Connection>::Element *E = connections.front(); E; E = E->next()) { + for (const List<Connection>::Element *E = connections.front(); E; E = E->next()) { if (E->get().from == p_from && E->get().from_port == p_from_port && E->get().to == p_to && E->get().to_port == p_to_port) { connections.erase(E); top_layer->update(); @@ -257,7 +257,7 @@ Vector2 GraphEdit::get_scroll_ofs() const { void GraphEdit::_scroll_moved(double) { if (!awaiting_scroll_offset_update) { - call_deferred("_update_scroll_offset"); + call_deferred(SNAME("_update_scroll_offset")); awaiting_scroll_offset_update = true; } top_layer->update(); @@ -265,7 +265,7 @@ void GraphEdit::_scroll_moved(double) { update(); if (!setting_scroll_ofs) { //in godot, signals on change value are avoided as a convention - emit_signal("scroll_offset_changed", get_scroll_ofs()); + emit_signal(SNAME("scroll_offset_changed"), get_scroll_ofs()); } } @@ -345,7 +345,7 @@ void GraphEdit::_update_scroll() { set_block_minimum_size_adjust(false); if (!awaiting_scroll_offset_update) { - call_deferred("_update_scroll_offset"); + call_deferred(SNAME("_update_scroll_offset")); awaiting_scroll_offset_update = true; } @@ -371,7 +371,7 @@ void GraphEdit::_graph_node_raised(Node *p_gn) { move_child(connections_layer, first_not_comment); top_layer->raise(); - emit_signal("node_selected", p_gn); + emit_signal(SNAME("node_selected"), p_gn); } void GraphEdit::_graph_node_moved(Node *p_gn) { @@ -395,7 +395,7 @@ void GraphEdit::_graph_node_slot_updated(int p_index, Node *p_gn) { void GraphEdit::add_child_notify(Node *p_child) { Control::add_child_notify(p_child); - top_layer->call_deferred("raise"); // Top layer always on top! + top_layer->call_deferred(SNAME("raise")); // Top layer always on top! GraphNode *gn = Object::cast_to<GraphNode>(p_child); if (gn) { @@ -421,7 +421,7 @@ void GraphEdit::remove_child_notify(Node *p_child) { } if (top_layer != nullptr && is_inside_tree()) { - top_layer->call_deferred("raise"); // Top layer always on top! + top_layer->call_deferred(SNAME("raise")); // Top layer always on top! } GraphNode *gn = Object::cast_to<GraphNode>(p_child); @@ -442,14 +442,14 @@ void GraphEdit::remove_child_notify(Node *p_child) { void GraphEdit::_notification(int p_what) { if (p_what == NOTIFICATION_ENTER_TREE || p_what == NOTIFICATION_THEME_CHANGED) { - port_grab_distance_horizontal = get_theme_constant("port_grab_distance_horizontal"); - port_grab_distance_vertical = get_theme_constant("port_grab_distance_vertical"); - - zoom_minus->set_icon(get_theme_icon("minus")); - zoom_reset->set_icon(get_theme_icon("reset")); - zoom_plus->set_icon(get_theme_icon("more")); - snap_button->set_icon(get_theme_icon("snap")); - minimap_button->set_icon(get_theme_icon("minimap")); + port_grab_distance_horizontal = get_theme_constant(SNAME("port_grab_distance_horizontal")); + port_grab_distance_vertical = get_theme_constant(SNAME("port_grab_distance_vertical")); + + zoom_minus->set_icon(get_theme_icon(SNAME("minus"))); + zoom_reset->set_icon(get_theme_icon(SNAME("reset"))); + zoom_plus->set_icon(get_theme_icon(SNAME("more"))); + snap_button->set_icon(get_theme_icon(SNAME("snap"))); + minimap_button->set_icon(get_theme_icon(SNAME("minimap"))); } if (p_what == NOTIFICATION_READY) { Size2 hmin = h_scroll->get_combined_minimum_size(); @@ -466,7 +466,7 @@ void GraphEdit::_notification(int p_what) { v_scroll->set_anchor_and_offset(SIDE_BOTTOM, ANCHOR_END, 0); } if (p_what == NOTIFICATION_DRAW) { - draw_style_box(get_theme_stylebox("bg"), Rect2(Point2(), get_size())); + draw_style_box(get_theme_stylebox(SNAME("bg")), Rect2(Point2(), get_size())); if (is_using_snap()) { //draw grid @@ -479,8 +479,8 @@ void GraphEdit::_notification(int p_what) { Point2i from = (offset / float(snap)).floor(); Point2i len = (size / float(snap)).floor() + Vector2(1, 1); - Color grid_minor = get_theme_color("grid_minor"); - Color grid_major = get_theme_color("grid_major"); + Color grid_minor = get_theme_color(SNAME("grid_minor")); + Color grid_major = get_theme_color(SNAME("grid_major")); for (int i = from.x; i < from.x + len.x; i++) { Color color; @@ -518,7 +518,7 @@ void GraphEdit::_notification(int p_what) { } bool GraphEdit::_filter_input(const Point2 &p_point) { - Ref<Texture2D> port = get_theme_icon("port", "GraphNode"); + Ref<Texture2D> port = get_theme_icon(SNAME("port"), SNAME("GraphNode")); for (int i = get_child_count() - 1; i >= 0; i--) { GraphNode *gn = Object::cast_to<GraphNode>(get_child(i)); @@ -548,7 +548,7 @@ void GraphEdit::_top_layer_input(const Ref<InputEvent> &p_ev) { Ref<InputEventMouseButton> mb = p_ev; if (mb.is_valid() && mb->get_button_index() == MOUSE_BUTTON_LEFT && mb->is_pressed()) { connecting_valid = false; - Ref<Texture2D> port = get_theme_icon("port", "GraphNode"); + Ref<Texture2D> port = get_theme_icon(SNAME("port"), SNAME("GraphNode")); click_pos = mb->get_position() / zoom; for (int i = get_child_count() - 1; i >= 0; i--) { GraphNode *gn = Object::cast_to<GraphNode>(get_child(i)); @@ -561,20 +561,20 @@ void GraphEdit::_top_layer_input(const Ref<InputEvent> &p_ev) { if (is_in_hot_zone(pos / zoom, click_pos)) { if (valid_left_disconnect_types.has(gn->get_connection_output_type(j))) { //check disconnect - for (List<Connection>::Element *E = connections.front(); E; E = E->next()) { - if (E->get().from == gn->get_name() && E->get().from_port == j) { - Node *to = get_node(String(E->get().to)); + for (const Connection &E : connections) { + if (E.from == gn->get_name() && E.from_port == j) { + Node *to = get_node(String(E.to)); if (Object::cast_to<GraphNode>(to)) { - connecting_from = E->get().to; - connecting_index = E->get().to_port; + connecting_from = E.to; + connecting_index = E.to_port; connecting_out = false; - connecting_type = Object::cast_to<GraphNode>(to)->get_connection_input_type(E->get().to_port); - connecting_color = Object::cast_to<GraphNode>(to)->get_connection_input_color(E->get().to_port); + connecting_type = Object::cast_to<GraphNode>(to)->get_connection_input_type(E.to_port); + connecting_color = Object::cast_to<GraphNode>(to)->get_connection_input_color(E.to_port); connecting_target = false; connecting_to = pos; just_disconnected = true; - emit_signal("disconnection_request", E->get().from, E->get().from_port, E->get().to, E->get().to_port); + emit_signal(SNAME("disconnection_request"), E.from, E.from_port, E.to, E.to_port); to = get_node(String(connecting_from)); //maybe it was erased if (Object::cast_to<GraphNode>(to)) { connecting = true; @@ -603,20 +603,20 @@ void GraphEdit::_top_layer_input(const Ref<InputEvent> &p_ev) { if (is_in_hot_zone(pos / zoom, click_pos)) { if (right_disconnects || valid_right_disconnect_types.has(gn->get_connection_input_type(j))) { //check disconnect - for (List<Connection>::Element *E = connections.front(); E; E = E->next()) { - if (E->get().to == gn->get_name() && E->get().to_port == j) { - Node *fr = get_node(String(E->get().from)); + for (const Connection &E : connections) { + if (E.to == gn->get_name() && E.to_port == j) { + Node *fr = get_node(String(E.from)); if (Object::cast_to<GraphNode>(fr)) { - connecting_from = E->get().from; - connecting_index = E->get().from_port; + connecting_from = E.from; + connecting_index = E.from_port; connecting_out = true; - connecting_type = Object::cast_to<GraphNode>(fr)->get_connection_output_type(E->get().from_port); - connecting_color = Object::cast_to<GraphNode>(fr)->get_connection_output_color(E->get().from_port); + connecting_type = Object::cast_to<GraphNode>(fr)->get_connection_output_type(E.from_port); + connecting_color = Object::cast_to<GraphNode>(fr)->get_connection_output_color(E.from_port); connecting_target = false; connecting_to = pos; just_disconnected = true; - emit_signal("disconnection_request", E->get().from, E->get().from_port, E->get().to, E->get().to_port); + emit_signal(SNAME("disconnection_request"), E.from, E.from_port, E.to, E.to_port); fr = get_node(String(connecting_from)); //maybe it was erased if (Object::cast_to<GraphNode>(fr)) { connecting = true; @@ -652,7 +652,7 @@ void GraphEdit::_top_layer_input(const Ref<InputEvent> &p_ev) { connecting_valid = just_disconnected || click_pos.distance_to(connecting_to / zoom) > 20.0 * zoom; if (connecting_valid) { - Ref<Texture2D> port = get_theme_icon("port", "GraphNode"); + Ref<Texture2D> port = get_theme_icon(SNAME("port"), SNAME("GraphNode")); Vector2 mpos = mm->get_position() / zoom; for (int i = get_child_count() - 1; i >= 0; i--) { GraphNode *gn = Object::cast_to<GraphNode>(get_child(i)); @@ -701,7 +701,7 @@ void GraphEdit::_top_layer_input(const Ref<InputEvent> &p_ev) { SWAP(from, to); SWAP(from_slot, to_slot); } - emit_signal("connection_request", from, from_slot, to, to_slot); + emit_signal(SNAME("connection_request"), from, from_slot, to, to_slot); } else if (!just_disconnected) { String from = connecting_from; @@ -709,9 +709,9 @@ void GraphEdit::_top_layer_input(const Ref<InputEvent> &p_ev) { Vector2 ofs = Vector2(mb->get_position().x, mb->get_position().y); if (!connecting_out) { - emit_signal("connection_from_empty", from, from_slot, ofs); + emit_signal(SNAME("connection_from_empty"), from, from_slot, ofs); } else { - emit_signal("connection_to_empty", from, from_slot, ofs); + emit_signal(SNAME("connection_to_empty"), from, from_slot, ofs); } } } @@ -819,8 +819,8 @@ void GraphEdit::_draw_cos_line(CanvasItem *p_where, const Vector2 &p_from, const //cubic bezier code float diff = p_to.x - p_from.x; float cp_offset; - int cp_len = get_theme_constant("bezier_len_pos") * p_bezier_ratio; - int cp_neg_len = get_theme_constant("bezier_len_neg") * p_bezier_ratio; + int cp_len = get_theme_constant(SNAME("bezier_len_pos")) * p_bezier_ratio; + int cp_neg_len = get_theme_constant(SNAME("bezier_len_neg")) * p_bezier_ratio; if (diff > 0) { cp_offset = MIN(cp_len, diff * 0.5); @@ -849,7 +849,7 @@ void GraphEdit::_draw_cos_line(CanvasItem *p_where, const Vector2 &p_from, const } void GraphEdit::_connections_layer_draw() { - Color activity_color = get_theme_color("activity"); + Color activity_color = get_theme_color(SNAME("activity")); //draw connections List<List<Connection>::Element *> to_erase; for (List<Connection>::Element *E = connections.front(); E; E = E->next()) { @@ -934,8 +934,8 @@ void GraphEdit::_top_layer_draw() { } if (box_selecting) { - top_layer->draw_rect(box_selecting_rect, get_theme_color("selection_fill")); - top_layer->draw_rect(box_selecting_rect, get_theme_color("selection_stroke"), false); + top_layer->draw_rect(box_selecting_rect, get_theme_color(SNAME("selection_fill"))); + top_layer->draw_rect(box_selecting_rect, get_theme_color(SNAME("selection_stroke")), false); } } @@ -948,7 +948,7 @@ void GraphEdit::_minimap_draw() { // Draw the minimap background. Rect2 minimap_rect = Rect2(Point2(), minimap->get_size()); - minimap->draw_style_box(minimap->get_theme_stylebox("bg"), minimap_rect); + minimap->draw_style_box(minimap->get_theme_stylebox(SNAME("bg")), minimap_rect); Vector2 graph_offset = minimap->_get_graph_offset(); Vector2 minimap_offset = minimap->minimap_offset; @@ -964,7 +964,7 @@ void GraphEdit::_minimap_draw() { Vector2 node_size = minimap->_convert_from_graph_position(gn->get_size() * zoom); Rect2 node_rect = Rect2(node_position, node_size); - Ref<StyleBoxFlat> sb_minimap = minimap->get_theme_stylebox("node")->duplicate(); + Ref<StyleBoxFlat> sb_minimap = minimap->get_theme_stylebox(SNAME("node"))->duplicate(); // Override default values with colors provided by the GraphNode's stylebox, if possible. Ref<StyleBoxFlat> sbf = gn->get_theme_stylebox(gn->is_selected() ? "commentfocus" : "comment"); @@ -987,7 +987,7 @@ void GraphEdit::_minimap_draw() { Vector2 node_size = minimap->_convert_from_graph_position(gn->get_size() * zoom); Rect2 node_rect = Rect2(node_position, node_size); - Ref<StyleBoxFlat> sb_minimap = minimap->get_theme_stylebox("node")->duplicate(); + Ref<StyleBoxFlat> sb_minimap = minimap->get_theme_stylebox(SNAME("node"))->duplicate(); // Override default values with colors provided by the GraphNode's stylebox, if possible. Ref<StyleBoxFlat> sbf = gn->get_theme_stylebox(gn->is_selected() ? "selectedframe" : "frame"); @@ -1000,9 +1000,9 @@ void GraphEdit::_minimap_draw() { } // Draw node connections. - Color activity_color = get_theme_color("activity"); - for (List<Connection>::Element *E = connections.front(); E; E = E->next()) { - NodePath fromnp(E->get().from); + Color activity_color = get_theme_color(SNAME("activity")); + for (const Connection &E : connections) { + NodePath fromnp(E.from); Node *from = get_node(fromnp); if (!from) { @@ -1013,7 +1013,7 @@ void GraphEdit::_minimap_draw() { continue; } - NodePath tonp(E->get().to); + NodePath tonp(E.to); Node *to = get_node(tonp); if (!to) { continue; @@ -1023,27 +1023,27 @@ void GraphEdit::_minimap_draw() { continue; } - Vector2 from_slot_position = gfrom->get_position_offset() * zoom + gfrom->get_connection_output_position(E->get().from_port); + Vector2 from_slot_position = gfrom->get_position_offset() * zoom + gfrom->get_connection_output_position(E.from_port); Vector2 from_position = minimap->_convert_from_graph_position(from_slot_position - graph_offset) + minimap_offset; - Color from_color = gfrom->get_connection_output_color(E->get().from_port); - Vector2 to_slot_position = gto->get_position_offset() * zoom + gto->get_connection_input_position(E->get().to_port); + Color from_color = gfrom->get_connection_output_color(E.from_port); + Vector2 to_slot_position = gto->get_position_offset() * zoom + gto->get_connection_input_position(E.to_port); Vector2 to_position = minimap->_convert_from_graph_position(to_slot_position - graph_offset) + minimap_offset; - Color to_color = gto->get_connection_input_color(E->get().to_port); + Color to_color = gto->get_connection_input_color(E.to_port); - if (E->get().activity > 0) { - from_color = from_color.lerp(activity_color, E->get().activity); - to_color = to_color.lerp(activity_color, E->get().activity); + if (E.activity > 0) { + from_color = from_color.lerp(activity_color, E.activity); + to_color = to_color.lerp(activity_color, E.activity); } _draw_cos_line(minimap, from_position, to_position, from_color, to_color, 1.0, 0.5); } // Draw the "camera" viewport. Rect2 camera_rect = minimap->get_camera_rect(); - minimap->draw_style_box(minimap->get_theme_stylebox("camera"), camera_rect); + minimap->draw_style_box(minimap->get_theme_stylebox(SNAME("camera")), camera_rect); // Draw the resizer control. - Ref<Texture2D> resizer = minimap->get_theme_icon("resizer"); - Color resizer_color = minimap->get_theme_color("resizer_color"); + Ref<Texture2D> resizer = minimap->get_theme_icon(SNAME("resizer")); + Color resizer_color = minimap->get_theme_color(SNAME("resizer_color")); minimap->draw_texture(resizer, Point2(), resizer_color); } @@ -1070,7 +1070,7 @@ void GraphEdit::_gui_input(const Ref<InputEvent> &p_ev) { if (mm.is_valid() && dragging) { if (!moving_selection) { - emit_signal("begin_node_move"); + emit_signal(SNAME("begin_node_move")); moving_selection = true; } @@ -1113,17 +1113,17 @@ void GraphEdit::_gui_input(const Ref<InputEvent> &p_ev) { if (in_box) { if (!gn->is_selected() && box_selection_mode_additive) { - emit_signal("node_selected", gn); + emit_signal(SNAME("node_selected"), gn); } else if (gn->is_selected() && !box_selection_mode_additive) { - emit_signal("node_deselected", gn); + emit_signal(SNAME("node_deselected"), gn); } gn->set_selected(box_selection_mode_additive); } else { bool select = (previous_selected.find(gn) != nullptr); if (gn->is_selected() && !select) { - emit_signal("node_deselected", gn); + emit_signal(SNAME("node_deselected"), gn); } else if (!gn->is_selected() && select) { - emit_signal("node_selected", gn); + emit_signal(SNAME("node_selected"), gn); } gn->set_selected(select); } @@ -1146,9 +1146,9 @@ void GraphEdit::_gui_input(const Ref<InputEvent> &p_ev) { bool select = (previous_selected.find(gn) != nullptr); if (gn->is_selected() && !select) { - emit_signal("node_deselected", gn); + emit_signal(SNAME("node_deselected"), gn); } else if (!gn->is_selected() && select) { - emit_signal("node_selected", gn); + emit_signal(SNAME("node_selected"), gn); } gn->set_selected(select); } @@ -1160,7 +1160,7 @@ void GraphEdit::_gui_input(const Ref<InputEvent> &p_ev) { top_layer->update(); minimap->update(); } else { - emit_signal("popup_request", b->get_global_position()); + emit_signal(SNAME("popup_request"), b->get_global_position()); } } } @@ -1175,7 +1175,7 @@ void GraphEdit::_gui_input(const Ref<InputEvent> &p_ev) { Rect2 r = gn->get_rect(); r.size *= zoom; if (r.has_point(b->get_position())) { - emit_signal("node_deselected", gn); + emit_signal(SNAME("node_deselected"), gn); gn->set_selected(false); } } @@ -1192,7 +1192,7 @@ void GraphEdit::_gui_input(const Ref<InputEvent> &p_ev) { } if (moving_selection) { - emit_signal("end_node_move"); + emit_signal(SNAME("end_node_move")); moving_selection = false; } @@ -1238,7 +1238,7 @@ void GraphEdit::_gui_input(const Ref<InputEvent> &p_ev) { o_gn->set_selected(true); } else { if (o_gn->is_selected()) { - emit_signal("node_deselected", o_gn); + emit_signal(SNAME("node_deselected"), o_gn); } o_gn->set_selected(false); } @@ -1298,7 +1298,7 @@ void GraphEdit::_gui_input(const Ref<InputEvent> &p_ev) { continue; } if (gn2->is_selected()) { - emit_signal("node_deselected", gn2); + emit_signal(SNAME("node_deselected"), gn2); } gn2->set_selected(false); } @@ -1333,16 +1333,16 @@ void GraphEdit::_gui_input(const Ref<InputEvent> &p_ev) { if (p_ev->is_pressed()) { if (p_ev->is_action("ui_graph_duplicate")) { - emit_signal("duplicate_nodes_request"); + emit_signal(SNAME("duplicate_nodes_request")); accept_event(); } else if (p_ev->is_action("ui_copy")) { - emit_signal("copy_nodes_request"); + emit_signal(SNAME("copy_nodes_request")); accept_event(); } else if (p_ev->is_action("ui_paste")) { - emit_signal("paste_nodes_request"); + emit_signal(SNAME("paste_nodes_request")); accept_event(); } else if (p_ev->is_action("ui_graph_delete")) { - emit_signal("delete_nodes_request"); + emit_signal(SNAME("delete_nodes_request")); accept_event(); } } @@ -1360,15 +1360,15 @@ void GraphEdit::_gui_input(const Ref<InputEvent> &p_ev) { } void GraphEdit::set_connection_activity(const StringName &p_from, int p_from_port, const StringName &p_to, int p_to_port, float p_activity) { - for (List<Connection>::Element *E = connections.front(); E; E = E->next()) { - if (E->get().from == p_from && E->get().from_port == p_from_port && E->get().to == p_to && E->get().to_port == p_to_port) { - if (Math::is_equal_approx(E->get().activity, p_activity)) { + for (Connection &E : connections) { + if (E.from == p_from && E.from_port == p_from_port && E.to == p_to && E.to_port == p_to_port) { + if (Math::is_equal_approx(E.activity, p_activity)) { //update only if changed top_layer->update(); minimap->update(); connections_layer->update(); } - E->get().activity = p_activity; + E.activity = p_activity; return; } } @@ -1500,12 +1500,12 @@ Array GraphEdit::_get_connection_list() const { List<Connection> conns; get_connection_list(&conns); Array arr; - for (List<Connection>::Element *E = conns.front(); E; E = E->next()) { + for (const Connection &E : conns) { Dictionary d; - d["from"] = E->get().from; - d["from_port"] = E->get().from_port; - d["to"] = E->get().to; - d["to_port"] = E->get().to_port; + d["from"] = E.from; + d["from_port"] = E.from_port; + d["to"] = E.to; + d["to_port"] = E.to_port; arr.push_back(d); } return arr; diff --git a/scene/gui/graph_node.cpp b/scene/gui/graph_node.cpp index 836bffdf46..e85cefcb7b 100644 --- a/scene/gui/graph_node.cpp +++ b/scene/gui/graph_node.cpp @@ -180,9 +180,9 @@ void GraphNode::_resort() { /** First pass, determine minimum size AND amount of stretchable elements */ Size2i new_size = get_size(); - Ref<StyleBox> sb = get_theme_stylebox("frame"); + Ref<StyleBox> sb = get_theme_stylebox(SNAME("frame")); - int sep = get_theme_constant("separation"); + int sep = get_theme_constant(SNAME("separation")); bool first = true; int children_count = 0; @@ -323,8 +323,8 @@ void GraphNode::_resort() { bool GraphNode::has_point(const Point2 &p_point) const { if (comment) { - Ref<StyleBox> comment = get_theme_stylebox("comment"); - Ref<Texture2D> resizer = get_theme_icon("resizer"); + Ref<StyleBox> comment = get_theme_stylebox(SNAME("comment")); + Ref<Texture2D> resizer = get_theme_icon(SNAME("resizer")); if (Rect2(get_size() - resizer->get_size(), resizer->get_size()).has_point(p_point)) { return true; @@ -355,18 +355,18 @@ void GraphNode::_notification(int p_what) { //sb=sb->duplicate(); //sb->call("set_modulate",modulate); - Ref<Texture2D> port = get_theme_icon("port"); - Ref<Texture2D> close = get_theme_icon("close"); - Ref<Texture2D> resizer = get_theme_icon("resizer"); - int close_offset = get_theme_constant("close_offset"); - int close_h_offset = get_theme_constant("close_h_offset"); - Color close_color = get_theme_color("close_color"); - Color resizer_color = get_theme_color("resizer_color"); - int title_offset = get_theme_constant("title_offset"); - int title_h_offset = get_theme_constant("title_h_offset"); - Color title_color = get_theme_color("title_color"); + Ref<Texture2D> port = get_theme_icon(SNAME("port")); + Ref<Texture2D> close = get_theme_icon(SNAME("close")); + Ref<Texture2D> resizer = get_theme_icon(SNAME("resizer")); + int close_offset = get_theme_constant(SNAME("close_offset")); + int close_h_offset = get_theme_constant(SNAME("close_h_offset")); + Color close_color = get_theme_color(SNAME("close_color")); + Color resizer_color = get_theme_color(SNAME("resizer_color")); + int title_offset = get_theme_constant(SNAME("title_offset")); + int title_h_offset = get_theme_constant(SNAME("title_h_offset")); + Color title_color = get_theme_color(SNAME("title_color")); Point2i icofs = -port->get_size() * 0.5; - int edgeofs = get_theme_constant("port_offset"); + int edgeofs = get_theme_constant(SNAME("port_offset")); icofs.y += sb->get_margin(SIDE_TOP); draw_style_box(sb, Rect2(Point2(), get_size())); @@ -375,10 +375,10 @@ void GraphNode::_notification(int p_what) { case OVERLAY_DISABLED: { } break; case OVERLAY_BREAKPOINT: { - draw_style_box(get_theme_stylebox("breakpoint"), Rect2(Point2(), get_size())); + draw_style_box(get_theme_stylebox(SNAME("breakpoint")), Rect2(Point2(), get_size())); } break; case OVERLAY_POSITION: { - draw_style_box(get_theme_stylebox("position"), Rect2(Point2(), get_size())); + draw_style_box(get_theme_stylebox(SNAME("position")), Rect2(Point2(), get_size())); } break; } @@ -446,8 +446,8 @@ void GraphNode::_notification(int p_what) { } void GraphNode::_shape() { - Ref<Font> font = get_theme_font("title_font"); - int font_size = get_theme_font_size("title_font_size"); + Ref<Font> font = get_theme_font(SNAME("title_font")); + int font_size = get_theme_font_size(SNAME("title_font_size")); title_buf->clear(); if (text_direction == Control::TEXT_DIRECTION_INHERITED) { @@ -481,7 +481,7 @@ void GraphNode::set_slot(int p_idx, bool p_enable_left, int p_type_left, const C update(); connpos_dirty = true; - emit_signal("slot_updated", p_idx); + emit_signal(SNAME("slot_updated"), p_idx); } void GraphNode::clear_slot(int p_idx) { @@ -510,7 +510,7 @@ void GraphNode::set_slot_enabled_left(int p_idx, bool p_enable_left) { update(); connpos_dirty = true; - emit_signal("slot_updated", p_idx); + emit_signal(SNAME("slot_updated"), p_idx); } void GraphNode::set_slot_type_left(int p_idx, int p_type_left) { @@ -520,7 +520,7 @@ void GraphNode::set_slot_type_left(int p_idx, int p_type_left) { update(); connpos_dirty = true; - emit_signal("slot_updated", p_idx); + emit_signal(SNAME("slot_updated"), p_idx); } int GraphNode::get_slot_type_left(int p_idx) const { @@ -537,7 +537,7 @@ void GraphNode::set_slot_color_left(int p_idx, const Color &p_color_left) { update(); connpos_dirty = true; - emit_signal("slot_updated", p_idx); + emit_signal(SNAME("slot_updated"), p_idx); } Color GraphNode::get_slot_color_left(int p_idx) const { @@ -561,7 +561,7 @@ void GraphNode::set_slot_enabled_right(int p_idx, bool p_enable_right) { update(); connpos_dirty = true; - emit_signal("slot_updated", p_idx); + emit_signal(SNAME("slot_updated"), p_idx); } void GraphNode::set_slot_type_right(int p_idx, int p_type_right) { @@ -571,7 +571,7 @@ void GraphNode::set_slot_type_right(int p_idx, int p_type_right) { update(); connpos_dirty = true; - emit_signal("slot_updated", p_idx); + emit_signal(SNAME("slot_updated"), p_idx); } int GraphNode::get_slot_type_right(int p_idx) const { @@ -588,7 +588,7 @@ void GraphNode::set_slot_color_right(int p_idx, const Color &p_color_right) { update(); connpos_dirty = true; - emit_signal("slot_updated", p_idx); + emit_signal(SNAME("slot_updated"), p_idx); } Color GraphNode::get_slot_color_right(int p_idx) const { @@ -599,14 +599,14 @@ Color GraphNode::get_slot_color_right(int p_idx) const { } Size2 GraphNode::get_minimum_size() const { - int sep = get_theme_constant("separation"); - Ref<StyleBox> sb = get_theme_stylebox("frame"); + int sep = get_theme_constant(SNAME("separation")); + Ref<StyleBox> sb = get_theme_stylebox(SNAME("frame")); bool first = true; Size2 minsize; minsize.x = title_buf->get_size().x; if (show_close) { - Ref<Texture2D> close = get_theme_icon("close"); + Ref<Texture2D> close = get_theme_icon(SNAME("close")); minsize.x += sep + close->get_width(); } @@ -699,7 +699,7 @@ String GraphNode::get_language() const { void GraphNode::set_position_offset(const Vector2 &p_offset) { position_offset = p_offset; - emit_signal("position_offset_changed"); + emit_signal(SNAME("position_offset_changed")); update(); } @@ -720,7 +720,7 @@ void GraphNode::set_drag(bool p_drag) { if (p_drag) { drag_from = get_position_offset(); } else { - emit_signal("dragged", drag_from, get_position_offset()); //useful for undo/redo + emit_signal(SNAME("dragged"), drag_from, get_position_offset()); //useful for undo/redo } } @@ -738,10 +738,10 @@ bool GraphNode::is_close_button_visible() const { } void GraphNode::_connpos_update() { - int edgeofs = get_theme_constant("port_offset"); - int sep = get_theme_constant("separation"); + int edgeofs = get_theme_constant(SNAME("port_offset")); + int sep = get_theme_constant(SNAME("separation")); - Ref<StyleBox> sb = get_theme_stylebox("frame"); + Ref<StyleBox> sb = get_theme_stylebox(SNAME("frame")); conn_input_cache.clear(); conn_output_cache.clear(); int vofs = 0; @@ -875,12 +875,12 @@ void GraphNode::_gui_input(const Ref<InputEvent> &p_ev) { if (close_rect.size != Size2() && close_rect.has_point(mpos)) { //send focus to parent get_parent_control()->grab_focus(); - emit_signal("close_request"); + emit_signal(SNAME("close_request")); accept_event(); return; } - Ref<Texture2D> resizer = get_theme_icon("resizer"); + Ref<Texture2D> resizer = get_theme_icon(SNAME("resizer")); if (resizable && mpos.x > get_size().x - resizer->get_width() && mpos.y > get_size().y - resizer->get_height()) { resizing = true; @@ -890,7 +890,7 @@ void GraphNode::_gui_input(const Ref<InputEvent> &p_ev) { return; } - emit_signal("raise_request"); + emit_signal(SNAME("raise_request")); } if (!mb->is_pressed() && mb->get_button_index() == MOUSE_BUTTON_LEFT) { @@ -904,7 +904,7 @@ void GraphNode::_gui_input(const Ref<InputEvent> &p_ev) { Vector2 diff = mpos - resizing_from; - emit_signal("resize_request", resizing_from_size + diff); + emit_signal(SNAME("resize_request"), resizing_from_size + diff); } } diff --git a/scene/gui/grid_container.cpp b/scene/gui/grid_container.cpp index a54f5eef06..1107e3a4af 100644 --- a/scene/gui/grid_container.cpp +++ b/scene/gui/grid_container.cpp @@ -38,8 +38,8 @@ void GridContainer::_notification(int p_what) { Set<int> col_expanded; // Columns which have the SIZE_EXPAND flag set. Set<int> row_expanded; // Rows which have the SIZE_EXPAND flag set. - int hsep = get_theme_constant("hseparation"); - int vsep = get_theme_constant("vseparation"); + int hsep = get_theme_constant(SNAME("hseparation")); + int vsep = get_theme_constant(SNAME("vseparation")); int max_col = MIN(get_child_count(), columns); int max_row = ceil((float)get_child_count() / (float)columns); @@ -213,8 +213,8 @@ Size2 GridContainer::get_minimum_size() const { Map<int, int> col_minw; Map<int, int> row_minh; - int hsep = get_theme_constant("hseparation"); - int vsep = get_theme_constant("vseparation"); + int hsep = get_theme_constant(SNAME("hseparation")); + int vsep = get_theme_constant(SNAME("vseparation")); int max_row = 0; int max_col = 0; diff --git a/scene/gui/item_list.cpp b/scene/gui/item_list.cpp index b0d54bf8c9..fdf6181f1d 100644 --- a/scene/gui/item_list.cpp +++ b/scene/gui/item_list.cpp @@ -42,7 +42,7 @@ void ItemList::_shape(int p_idx) { } else { item.text_buf->set_direction((TextServer::Direction)item.text_direction); } - item.text_buf->add_string(item.text, get_theme_font("font"), get_theme_font_size("font_size"), item.opentype_features, (item.language != "") ? item.language : TranslationServer::get_singleton()->get_tool_locale()); + item.text_buf->add_string(item.text, get_theme_font(SNAME("font")), get_theme_font_size(SNAME("font_size")), item.opentype_features, (item.language != "") ? item.language : TranslationServer::get_singleton()->get_tool_locale()); if (icon_mode == ICON_MODE_TOP && max_text_lines > 0) { item.text_buf->set_flags(TextServer::BREAK_MANDATORY | TextServer::BREAK_WORD_BOUND | TextServer::BREAK_GRAPHEME_BOUND); } else { @@ -548,7 +548,7 @@ void ItemList::_gui_input(const Ref<InputEvent> &p_event) { if (defer_select_single >= 0 && mb.is_valid() && mb->get_button_index() == MOUSE_BUTTON_LEFT && !mb->is_pressed()) { select(defer_select_single, true); - emit_signal("multi_selected", defer_select_single, true); + emit_signal(SNAME("multi_selected"), defer_select_single, true); defer_select_single = -1; return; } @@ -556,7 +556,7 @@ void ItemList::_gui_input(const Ref<InputEvent> &p_event) { if (mb.is_valid() && (mb->get_button_index() == MOUSE_BUTTON_LEFT || (allow_rmb_select && mb->get_button_index() == MOUSE_BUTTON_RIGHT)) && mb->is_pressed()) { search_string = ""; //any mousepress cancels Vector2 pos = mb->get_position(); - Ref<StyleBox> bg = get_theme_stylebox("bg"); + Ref<StyleBox> bg = get_theme_stylebox(SNAME("bg")); pos -= bg->get_offset(); pos.y += scroll_bar->get_value(); @@ -583,7 +583,7 @@ void ItemList::_gui_input(const Ref<InputEvent> &p_event) { if (select_mode == SELECT_MULTI && items[i].selected && mb->is_command_pressed()) { deselect(i); - emit_signal("multi_selected", i, false); + emit_signal(SNAME("multi_selected"), i, false); } else if (select_mode == SELECT_MULTI && mb->is_shift_pressed() && current >= 0 && current < items.size() && current != i) { int from = current; @@ -595,12 +595,12 @@ void ItemList::_gui_input(const Ref<InputEvent> &p_event) { bool selected = !items[j].selected; select(j, false); if (selected) { - emit_signal("multi_selected", j, true); + emit_signal(SNAME("multi_selected"), j, true); } } if (mb->get_button_index() == MOUSE_BUTTON_RIGHT) { - emit_signal("item_rmb_selected", i, get_local_mouse_position()); + emit_signal(SNAME("item_rmb_selected"), i, get_local_mouse_position()); } } else { if (!mb->is_double_click() && !mb->is_command_pressed() && select_mode == SELECT_MULTI && items[i].selectable && !items[i].disabled && items[i].selected && mb->get_button_index() == MOUSE_BUTTON_LEFT) { @@ -609,7 +609,7 @@ void ItemList::_gui_input(const Ref<InputEvent> &p_event) { } if (items[i].selected && mb->get_button_index() == MOUSE_BUTTON_RIGHT) { - emit_signal("item_rmb_selected", i, get_local_mouse_position()); + emit_signal(SNAME("item_rmb_selected"), i, get_local_mouse_position()); } else { bool selected = items[i].selected; @@ -617,16 +617,16 @@ void ItemList::_gui_input(const Ref<InputEvent> &p_event) { if (!selected || allow_reselect) { if (select_mode == SELECT_SINGLE) { - emit_signal("item_selected", i); + emit_signal(SNAME("item_selected"), i); } else { - emit_signal("multi_selected", i, true); + emit_signal(SNAME("multi_selected"), i, true); } } if (mb->get_button_index() == MOUSE_BUTTON_RIGHT) { - emit_signal("item_rmb_selected", i, get_local_mouse_position()); + emit_signal(SNAME("item_rmb_selected"), i, get_local_mouse_position()); } else if (/*select_mode==SELECT_SINGLE &&*/ mb->is_double_click()) { - emit_signal("item_activated", i); + emit_signal(SNAME("item_activated"), i); } } } @@ -634,13 +634,13 @@ void ItemList::_gui_input(const Ref<InputEvent> &p_event) { return; } if (mb->get_button_index() == MOUSE_BUTTON_RIGHT) { - emit_signal("rmb_clicked", mb->get_position()); + emit_signal(SNAME("rmb_clicked"), mb->get_position()); return; } // Since closest is null, more likely we clicked on empty space, so send signal to interested controls. Allows, for example, implement items deselecting. - emit_signal("nothing_selected"); + emit_signal(SNAME("nothing_selected")); } if (mb.is_valid() && mb->get_button_index() == MOUSE_BUTTON_WHEEL_UP && mb->is_pressed()) { scroll_bar->set_value(scroll_bar->get_value() - scroll_bar->get_page() * mb->get_factor() / 8); @@ -661,7 +661,7 @@ void ItemList::_gui_input(const Ref<InputEvent> &p_event) { set_current(i); ensure_current_is_visible(); if (select_mode == SELECT_SINGLE) { - emit_signal("item_selected", current); + emit_signal(SNAME("item_selected"), current); } break; @@ -676,7 +676,7 @@ void ItemList::_gui_input(const Ref<InputEvent> &p_event) { set_current(current - current_columns); ensure_current_is_visible(); if (select_mode == SELECT_SINGLE) { - emit_signal("item_selected", current); + emit_signal(SNAME("item_selected"), current); } accept_event(); } @@ -691,7 +691,7 @@ void ItemList::_gui_input(const Ref<InputEvent> &p_event) { set_current(i); ensure_current_is_visible(); if (select_mode == SELECT_SINGLE) { - emit_signal("item_selected", current); + emit_signal(SNAME("item_selected"), current); } break; } @@ -705,7 +705,7 @@ void ItemList::_gui_input(const Ref<InputEvent> &p_event) { set_current(current + current_columns); ensure_current_is_visible(); if (select_mode == SELECT_SINGLE) { - emit_signal("item_selected", current); + emit_signal(SNAME("item_selected"), current); } accept_event(); } @@ -717,7 +717,7 @@ void ItemList::_gui_input(const Ref<InputEvent> &p_event) { set_current(current - current_columns * i); ensure_current_is_visible(); if (select_mode == SELECT_SINGLE) { - emit_signal("item_selected", current); + emit_signal(SNAME("item_selected"), current); } accept_event(); break; @@ -731,7 +731,7 @@ void ItemList::_gui_input(const Ref<InputEvent> &p_event) { set_current(current + current_columns * i); ensure_current_is_visible(); if (select_mode == SELECT_SINGLE) { - emit_signal("item_selected", current); + emit_signal(SNAME("item_selected"), current); } accept_event(); @@ -745,7 +745,7 @@ void ItemList::_gui_input(const Ref<InputEvent> &p_event) { set_current(current - 1); ensure_current_is_visible(); if (select_mode == SELECT_SINGLE) { - emit_signal("item_selected", current); + emit_signal(SNAME("item_selected"), current); } accept_event(); } @@ -756,7 +756,7 @@ void ItemList::_gui_input(const Ref<InputEvent> &p_event) { set_current(current + 1); ensure_current_is_visible(); if (select_mode == SELECT_SINGLE) { - emit_signal("item_selected", current); + emit_signal(SNAME("item_selected"), current); } accept_event(); } @@ -766,17 +766,17 @@ void ItemList::_gui_input(const Ref<InputEvent> &p_event) { if (current >= 0 && current < items.size()) { if (items[current].selectable && !items[current].disabled && !items[current].selected) { select(current, false); - emit_signal("multi_selected", current, true); + emit_signal(SNAME("multi_selected"), current, true); } else if (items[current].selected) { deselect(current); - emit_signal("multi_selected", current, false); + emit_signal(SNAME("multi_selected"), current, false); } } } else if (p_event->is_action("ui_accept")) { search_string = ""; //any mousepress cancels if (current >= 0 && current < items.size()) { - emit_signal("item_activated", current); + emit_signal(SNAME("item_activated"), current); } } else { Ref<InputEventKey> k = p_event; @@ -812,7 +812,7 @@ void ItemList::_gui_input(const Ref<InputEvent> &p_event) { set_current(i); ensure_current_is_visible(); if (select_mode == SELECT_SINGLE) { - emit_signal("item_selected", current); + emit_signal(SNAME("item_selected"), current); } break; } @@ -867,7 +867,7 @@ void ItemList::_notification(int p_what) { } if (p_what == NOTIFICATION_DRAW) { - Ref<StyleBox> bg = get_theme_stylebox("bg"); + Ref<StyleBox> bg = get_theme_stylebox(SNAME("bg")); int mw = scroll_bar->get_minimum_size().x; scroll_bar->set_anchor_and_offset(SIDE_LEFT, ANCHOR_END, -mw); @@ -884,24 +884,24 @@ void ItemList::_notification(int p_what) { draw_style_box(bg, Rect2(Point2(), size)); - int hseparation = get_theme_constant("hseparation"); - int vseparation = get_theme_constant("vseparation"); - int icon_margin = get_theme_constant("icon_margin"); - int line_separation = get_theme_constant("line_separation"); - Color font_outline_color = get_theme_color("font_outline_color"); - int outline_size = get_theme_constant("outline_size"); + int hseparation = get_theme_constant(SNAME("hseparation")); + int vseparation = get_theme_constant(SNAME("vseparation")); + int icon_margin = get_theme_constant(SNAME("icon_margin")); + int line_separation = get_theme_constant(SNAME("line_separation")); + Color font_outline_color = get_theme_color(SNAME("font_outline_color")); + int outline_size = get_theme_constant(SNAME("outline_size")); - Ref<StyleBox> sbsel = has_focus() ? get_theme_stylebox("selected_focus") : get_theme_stylebox("selected"); - Ref<StyleBox> cursor = has_focus() ? get_theme_stylebox("cursor") : get_theme_stylebox("cursor_unfocused"); + Ref<StyleBox> sbsel = has_focus() ? get_theme_stylebox(SNAME("selected_focus")) : get_theme_stylebox(SNAME("selected")); + Ref<StyleBox> cursor = has_focus() ? get_theme_stylebox(SNAME("cursor")) : get_theme_stylebox(SNAME("cursor_unfocused")); bool rtl = is_layout_rtl(); - Color guide_color = get_theme_color("guide_color"); - Color font_color = get_theme_color("font_color"); - Color font_selected_color = get_theme_color("font_selected_color"); + Color guide_color = get_theme_color(SNAME("guide_color")); + Color font_color = get_theme_color(SNAME("font_color")); + Color font_selected_color = get_theme_color(SNAME("font_selected_color")); if (has_focus()) { RenderingServer::get_singleton()->canvas_item_add_clip_ignore(get_canvas_item(), true); - draw_style_box(get_theme_stylebox("bg_focus"), Rect2(Point2(), size)); + draw_style_box(get_theme_stylebox(SNAME("bg_focus")), Rect2(Point2(), size)); RenderingServer::get_singleton()->canvas_item_add_clip_ignore(get_canvas_item(), false); } @@ -1299,7 +1299,7 @@ void ItemList::_scroll_changed(double) { int ItemList::get_item_at_position(const Point2 &p_pos, bool p_exact) const { Vector2 pos = p_pos; - Ref<StyleBox> bg = get_theme_stylebox("bg"); + Ref<StyleBox> bg = get_theme_stylebox(SNAME("bg")); pos -= bg->get_offset(); pos.y += scroll_bar->get_value(); @@ -1337,7 +1337,7 @@ bool ItemList::is_pos_at_end_of_items(const Point2 &p_pos) const { } Vector2 pos = p_pos; - Ref<StyleBox> bg = get_theme_stylebox("bg"); + Ref<StyleBox> bg = get_theme_stylebox(SNAME("bg")); pos -= bg->get_offset(); pos.y += scroll_bar->get_value(); diff --git a/scene/gui/label.cpp b/scene/gui/label.cpp index 78b9ad2569..1603989243 100644 --- a/scene/gui/label.cpp +++ b/scene/gui/label.cpp @@ -64,7 +64,7 @@ bool Label::is_uppercase() const { } int Label::get_line_height(int p_line) const { - Ref<Font> font = get_theme_font("font"); + Ref<Font> font = get_theme_font(SNAME("font")); if (p_line >= 0 && p_line < lines_rid.size()) { return TS->shaped_text_get_size(lines_rid[p_line]).y + font->get_spacing(Font::SPACING_TOP) + font->get_spacing(Font::SPACING_BOTTOM); } else if (lines_rid.size() > 0) { @@ -74,12 +74,12 @@ int Label::get_line_height(int p_line) const { } return h; } else { - return font->get_height(get_theme_font_size("font_size")); + return font->get_height(get_theme_font_size(SNAME("font_size"))); } } void Label::_shape() { - Ref<StyleBox> style = get_theme_stylebox("normal", "Label"); + Ref<StyleBox> style = get_theme_stylebox(SNAME("normal"), SNAME("Label")); int width = (get_size().width - style->get_minimum_size().width); if (dirty) { @@ -89,7 +89,7 @@ void Label::_shape() { } else { TS->shaped_text_set_direction(text_rid, (TextServer::Direction)text_direction); } - TS->shaped_text_add_string(text_rid, (uppercase) ? xl_text.to_upper() : xl_text, get_theme_font("font")->get_rids(), get_theme_font_size("font_size"), opentype_features, (language != "") ? language : TranslationServer::get_singleton()->get_tool_locale()); + TS->shaped_text_add_string(text_rid, (uppercase) ? xl_text.to_upper() : xl_text, get_theme_font(SNAME("font"))->get_rids(), get_theme_font_size(SNAME("font_size")), opentype_features, (language != "") ? language : TranslationServer::get_singleton()->get_tool_locale()); TS->shaped_text_set_bidi_override(text_rid, structured_text_parser(st_parser, st_args, xl_text)); dirty = false; lines_dirty = true; @@ -200,9 +200,9 @@ void Label::_shape() { } void Label::_update_visible() { - int line_spacing = get_theme_constant("line_spacing", "Label"); - Ref<StyleBox> style = get_theme_stylebox("normal", "Label"); - Ref<Font> font = get_theme_font("font"); + int line_spacing = get_theme_constant(SNAME("line_spacing"), SNAME("Label")); + Ref<StyleBox> style = get_theme_stylebox(SNAME("normal"), SNAME("Label")); + Ref<Font> font = get_theme_font(SNAME("font")); int lines_visible = lines_rid.size(); if (max_lines_visible >= 0 && lines_visible > max_lines_visible) { @@ -221,7 +221,7 @@ void Label::_update_visible() { void Label::_notification(int p_what) { if (p_what == NOTIFICATION_TRANSLATION_CHANGED) { - String new_text = tr(text); + String new_text = atr(text); if (new_text == xl_text) { return; //nothing new } @@ -244,15 +244,15 @@ void Label::_notification(int p_what) { Size2 string_size; Size2 size = get_size(); - Ref<StyleBox> style = get_theme_stylebox("normal"); - Ref<Font> font = get_theme_font("font"); - Color font_color = get_theme_color("font_color"); - Color font_shadow_color = get_theme_color("font_shadow_color"); - Point2 shadow_ofs(get_theme_constant("shadow_offset_x"), get_theme_constant("shadow_offset_y")); - int line_spacing = get_theme_constant("line_spacing"); - Color font_outline_color = get_theme_color("font_outline_color"); - int outline_size = get_theme_constant("outline_size"); - int shadow_outline_size = get_theme_constant("shadow_outline_size"); + Ref<StyleBox> style = get_theme_stylebox(SNAME("normal")); + Ref<Font> font = get_theme_font(SNAME("font")); + Color font_color = get_theme_color(SNAME("font_color")); + Color font_shadow_color = get_theme_color(SNAME("font_shadow_color")); + Point2 shadow_ofs(get_theme_constant(SNAME("shadow_offset_x")), get_theme_constant(SNAME("shadow_offset_y"))); + int line_spacing = get_theme_constant(SNAME("line_spacing")); + Color font_outline_color = get_theme_color(SNAME("font_outline_color")); + int outline_size = get_theme_constant(SNAME("outline_size")); + int shadow_outline_size = get_theme_constant(SNAME("shadow_outline_size")); bool rtl = is_layout_rtl(); style->draw(ci, Rect2(Point2(0, 0), get_size())); @@ -429,10 +429,10 @@ Size2 Label::get_minimum_size() const { Size2 min_size = minsize; - Ref<Font> font = get_theme_font("font"); - min_size.height = MAX(min_size.height, font->get_height(get_theme_font_size("font_size")) + font->get_spacing(Font::SPACING_TOP) + font->get_spacing(Font::SPACING_BOTTOM)); + Ref<Font> font = get_theme_font(SNAME("font")); + min_size.height = MAX(min_size.height, font->get_height(get_theme_font_size(SNAME("font_size"))) + font->get_spacing(Font::SPACING_TOP) + font->get_spacing(Font::SPACING_BOTTOM)); - Size2 min_style = get_theme_stylebox("normal")->get_minimum_size(); + Size2 min_style = get_theme_stylebox(SNAME("normal"))->get_minimum_size(); if (autowrap_mode != AUTOWRAP_OFF) { return Size2(1, (clip || overrun_behavior != OVERRUN_NO_TRIMMING) ? 1 : min_size.height) + min_style; } else { @@ -455,9 +455,9 @@ int Label::get_line_count() const { } int Label::get_visible_line_count() const { - Ref<Font> font = get_theme_font("font"); - Ref<StyleBox> style = get_theme_stylebox("normal"); - int line_spacing = get_theme_constant("line_spacing"); + Ref<Font> font = get_theme_font(SNAME("font")); + Ref<StyleBox> style = get_theme_stylebox(SNAME("normal")); + int line_spacing = get_theme_constant(SNAME("line_spacing")); int lines_visible = 0; float total_h = 0.0; for (int64_t i = lines_skipped; i < lines_rid.size(); i++) { @@ -509,7 +509,7 @@ void Label::set_text(const String &p_string) { return; } text = p_string; - xl_text = tr(p_string); + xl_text = atr(p_string); dirty = true; if (percent_visible < 1) { visible_chars = get_total_character_count() * percent_visible; diff --git a/scene/gui/line_edit.cpp b/scene/gui/line_edit.cpp index f2d0d9bb22..68e9171c15 100644 --- a/scene/gui/line_edit.cpp +++ b/scene/gui/line_edit.cpp @@ -227,9 +227,9 @@ void LineEdit::_gui_input(Ref<InputEvent> p_event) { return; } if (b->is_pressed() && b->get_button_index() == MOUSE_BUTTON_RIGHT && context_menu_enabled) { + _ensure_menu(); menu->set_position(get_screen_transform().xform(get_local_mouse_position())); menu->set_size(Vector2(1, 1)); - _generate_context_menu(); menu->popup(); grab_focus(); accept_event(); @@ -348,10 +348,10 @@ void LineEdit::_gui_input(Ref<InputEvent> p_event) { if (context_menu_enabled) { if (k->is_action("ui_menu", true)) { - Point2 pos = Point2(get_caret_pixel_pos().x, (get_size().y + get_theme_font("font")->get_height(get_theme_font_size("font_size"))) / 2); + _ensure_menu(); + Point2 pos = Point2(get_caret_pixel_pos().x, (get_size().y + get_theme_font(SNAME("font"))->get_height(get_theme_font_size(SNAME("font_size")))) / 2); menu->set_position(get_global_transform().xform(pos)); menu->set_size(Vector2(1, 1)); - _generate_context_menu(); menu->popup(); menu->grab_focus(); } @@ -359,7 +359,7 @@ void LineEdit::_gui_input(Ref<InputEvent> p_event) { // Default is ENTER and KP_ENTER. Cannot use ui_accept as default includes SPACE if (k->is_action("ui_text_submit", false)) { - emit_signal("text_submitted", text); + emit_signal(SNAME("text_submitted"), text); if (DisplayServer::get_singleton()->has_feature(DisplayServer::FEATURE_VIRTUAL_KEYBOARD) && virtual_keyboard_enabled) { DisplayServer::get_singleton()->virtual_keyboard_hide(); } @@ -567,8 +567,8 @@ bool LineEdit::_is_over_clear_button(const Point2 &p_pos) const { if (!clear_button_enabled || !has_point(p_pos)) { return false; } - Ref<Texture2D> icon = Control::get_theme_icon("clear"); - int x_ofs = get_theme_stylebox("normal")->get_offset().x; + Ref<Texture2D> icon = Control::get_theme_icon(SNAME("clear")); + int x_ofs = get_theme_stylebox(SNAME("normal"))->get_offset().x; return p_pos.x > get_size().width - icon->get_width() - x_ofs; } @@ -597,7 +597,7 @@ void LineEdit::_notification(int p_what) { update(); } break; case NOTIFICATION_TRANSLATION_CHANGED: { - placeholder_translated = tr(placeholder); + placeholder_translated = atr(placeholder); _shape(); update(); } break; @@ -612,7 +612,7 @@ void LineEdit::_notification(int p_what) { update(); } break; case NOTIFICATION_DRAW: { - if ((!has_focus() && !menu->has_focus() && !caret_force_displayed) || !window_has_focus) { + if ((!has_focus() && !(menu && menu->has_focus()) && !caret_force_displayed) || !window_has_focus) { draw_caret = false; } @@ -625,17 +625,17 @@ void LineEdit::_notification(int p_what) { RID ci = get_canvas_item(); - Ref<StyleBox> style = get_theme_stylebox("normal"); + Ref<StyleBox> style = get_theme_stylebox(SNAME("normal")); if (!is_editable()) { - style = get_theme_stylebox("read_only"); + style = get_theme_stylebox(SNAME("read_only")); draw_caret = false; } - Ref<Font> font = get_theme_font("font"); + Ref<Font> font = get_theme_font(SNAME("font")); style->draw(ci, Rect2(Point2(), size)); if (has_focus()) { - get_theme_stylebox("focus")->draw(ci, Rect2(Point2(), size)); + get_theme_stylebox(SNAME("focus"))->draw(ci, Rect2(Point2(), size)); } int x_ofs = 0; @@ -673,10 +673,10 @@ void LineEdit::_notification(int p_what) { int y_area = height - style->get_minimum_size().height; int y_ofs = style->get_offset().y + (y_area - text_height) / 2; - Color selection_color = get_theme_color("selection_color"); - Color font_color = is_editable() ? get_theme_color("font_color") : get_theme_color("font_uneditable_color"); - Color font_selected_color = get_theme_color("font_selected_color"); - Color caret_color = get_theme_color("caret_color"); + Color selection_color = get_theme_color(SNAME("selection_color")); + Color font_color = is_editable() ? get_theme_color(SNAME("font_color")) : get_theme_color(SNAME("font_uneditable_color")); + Color font_selected_color = get_theme_color(SNAME("font_selected_color")); + Color caret_color = get_theme_color(SNAME("caret_color")); // Draw placeholder color. if (using_placeholder) { @@ -685,13 +685,13 @@ void LineEdit::_notification(int p_what) { bool display_clear_icon = !using_placeholder && is_editable() && clear_button_enabled; if (right_icon.is_valid() || display_clear_icon) { - Ref<Texture2D> r_icon = display_clear_icon ? Control::get_theme_icon("clear") : right_icon; + Ref<Texture2D> r_icon = display_clear_icon ? Control::get_theme_icon(SNAME("clear")) : right_icon; Color color_icon(1, 1, 1, !is_editable() ? .5 * .9 : .9); if (display_clear_icon) { if (clear_button_status.press_attempt && clear_button_status.pressing_inside) { - color_icon = get_theme_color("clear_button_color_pressed"); + color_icon = get_theme_color(SNAME("clear_button_color_pressed")); } else { - color_icon = get_theme_color("clear_button_color"); + color_icon = get_theme_color(SNAME("clear_button_color")); } } @@ -738,8 +738,8 @@ void LineEdit::_notification(int p_what) { // Draw text. ofs.y += TS->shaped_text_get_ascent(text_rid); - Color font_outline_color = get_theme_color("font_outline_color"); - int outline_size = get_theme_constant("outline_size"); + Color font_outline_color = get_theme_color(SNAME("font_outline_color")); + int outline_size = get_theme_constant(SNAME("outline_size")); if (outline_size > 0 && font_outline_color.a > 0) { Vector2 oofs = ofs; for (int i = 0; i < gl_size; i++) { @@ -784,7 +784,7 @@ void LineEdit::_notification(int p_what) { if (l_caret == Rect2() && t_caret == Rect2()) { // No carets, add one at the start. - int h = get_theme_font("font")->get_height(get_theme_font_size("font_size")); + int h = get_theme_font(SNAME("font"))->get_height(get_theme_font_size(SNAME("font_size"))); int y = style->get_offset().y + (y_area - h) / 2; if (rtl) { l_dir = TextServer::DIRECTION_RTL; @@ -1006,7 +1006,7 @@ void LineEdit::shift_selection_check_post(bool p_shift) { } void LineEdit::set_caret_at_pixel_pos(int p_x) { - Ref<StyleBox> style = get_theme_stylebox("normal"); + Ref<StyleBox> style = get_theme_stylebox(SNAME("normal")); bool rtl = is_layout_rtl(); int x_ofs = 0; @@ -1039,7 +1039,7 @@ void LineEdit::set_caret_at_pixel_pos(int p_x) { bool using_placeholder = text.is_empty() && ime_text.is_empty(); bool display_clear_icon = !using_placeholder && is_editable() && clear_button_enabled; if (right_icon.is_valid() || display_clear_icon) { - Ref<Texture2D> r_icon = display_clear_icon ? Control::get_theme_icon("clear") : right_icon; + Ref<Texture2D> r_icon = display_clear_icon ? Control::get_theme_icon(SNAME("clear")) : right_icon; if (align == ALIGN_CENTER) { if (scroll_offset == 0) { x_ofs = MAX(style->get_margin(SIDE_LEFT), int(get_size().width - text_width - r_icon->get_width() - style->get_margin(SIDE_RIGHT) * 2) / 2); @@ -1054,7 +1054,7 @@ void LineEdit::set_caret_at_pixel_pos(int p_x) { } Vector2i LineEdit::get_caret_pixel_pos() { - Ref<StyleBox> style = get_theme_stylebox("normal"); + Ref<StyleBox> style = get_theme_stylebox(SNAME("normal")); bool rtl = is_layout_rtl(); int x_ofs = 0; @@ -1087,7 +1087,7 @@ Vector2i LineEdit::get_caret_pixel_pos() { bool using_placeholder = text.is_empty() && ime_text.is_empty(); bool display_clear_icon = !using_placeholder && is_editable() && clear_button_enabled; if (right_icon.is_valid() || display_clear_icon) { - Ref<Texture2D> r_icon = display_clear_icon ? Control::get_theme_icon("clear") : right_icon; + Ref<Texture2D> r_icon = display_clear_icon ? Control::get_theme_icon(SNAME("clear")) : right_icon; if (align == ALIGN_CENTER) { if (scroll_offset == 0) { x_ofs = MAX(style->get_margin(SIDE_LEFT), int(get_size().width - text_width - r_icon->get_width() - style->get_margin(SIDE_RIGHT) * 2) / 2); @@ -1252,10 +1252,12 @@ void LineEdit::set_text_direction(Control::TextDirection p_text_direction) { } _shape(); - menu_dir->set_item_checked(menu_dir->get_item_index(MENU_DIR_INHERITED), text_direction == TEXT_DIRECTION_INHERITED); - menu_dir->set_item_checked(menu_dir->get_item_index(MENU_DIR_AUTO), text_direction == TEXT_DIRECTION_AUTO); - menu_dir->set_item_checked(menu_dir->get_item_index(MENU_DIR_LTR), text_direction == TEXT_DIRECTION_LTR); - menu_dir->set_item_checked(menu_dir->get_item_index(MENU_DIR_RTL), text_direction == TEXT_DIRECTION_RTL); + if (menu_dir) { + menu_dir->set_item_checked(menu_dir->get_item_index(MENU_DIR_INHERITED), text_direction == TEXT_DIRECTION_INHERITED); + menu_dir->set_item_checked(menu_dir->get_item_index(MENU_DIR_AUTO), text_direction == TEXT_DIRECTION_AUTO); + menu_dir->set_item_checked(menu_dir->get_item_index(MENU_DIR_LTR), text_direction == TEXT_DIRECTION_LTR); + menu_dir->set_item_checked(menu_dir->get_item_index(MENU_DIR_RTL), text_direction == TEXT_DIRECTION_RTL); + } update(); } } @@ -1302,7 +1304,9 @@ String LineEdit::get_language() const { void LineEdit::set_draw_control_chars(bool p_draw_control_chars) { if (draw_control_chars != p_draw_control_chars) { draw_control_chars = p_draw_control_chars; - menu->set_item_checked(menu->get_item_index(MENU_DISPLAY_UCC), draw_control_chars); + if (menu && menu->get_item_index(MENU_DISPLAY_UCC) >= 0) { + menu->set_item_checked(menu->get_item_index(MENU_DISPLAY_UCC), draw_control_chars); + } _shape(); update(); } @@ -1360,7 +1364,7 @@ String LineEdit::get_text() const { void LineEdit::set_placeholder(String p_text) { placeholder = p_text; - placeholder_translated = tr(placeholder); + placeholder_translated = atr(placeholder); _shape(); update(); } @@ -1396,7 +1400,7 @@ void LineEdit::set_caret_column(int p_column) { return; } - Ref<StyleBox> style = get_theme_stylebox("normal"); + Ref<StyleBox> style = get_theme_stylebox(SNAME("normal")); bool rtl = is_layout_rtl(); int x_ofs = 0; @@ -1430,7 +1434,7 @@ void LineEdit::set_caret_column(int p_column) { bool using_placeholder = text.is_empty() && ime_text.is_empty(); bool display_clear_icon = !using_placeholder && is_editable() && clear_button_enabled; if (right_icon.is_valid() || display_clear_icon) { - Ref<Texture2D> r_icon = display_clear_icon ? Control::get_theme_icon("clear") : right_icon; + Ref<Texture2D> r_icon = display_clear_icon ? Control::get_theme_icon(SNAME("clear")) : right_icon; if (align == ALIGN_CENTER) { if (scroll_offset == 0) { x_ofs = MAX(style->get_margin(SIDE_LEFT), int(get_size().width - text_width - r_icon->get_width() - style->get_margin(SIDE_RIGHT) * 2) / 2); @@ -1474,7 +1478,7 @@ void LineEdit::insert_text_at_caret(String p_text) { // Truncate text to append to fit in max_length, if needed. int available_chars = max_length - text.length(); if (p_text.length() > available_chars) { - emit_signal("text_change_rejected", p_text.substr(available_chars)); + emit_signal(SNAME("text_change_rejected"), p_text.substr(available_chars)); p_text = p_text.substr(0, available_chars); } } @@ -1501,15 +1505,15 @@ void LineEdit::clear_internal() { } Size2 LineEdit::get_minimum_size() const { - Ref<StyleBox> style = get_theme_stylebox("normal"); - Ref<Font> font = get_theme_font("font"); - int font_size = get_theme_font_size("font_size"); + Ref<StyleBox> style = get_theme_stylebox(SNAME("normal")); + Ref<Font> font = get_theme_font(SNAME("font")); + int font_size = get_theme_font_size(SNAME("font_size")); Size2 min_size; // Minimum size of text. int em_space_size = font->get_char_size('M', 0, font_size).x; - min_size.width = get_theme_constant("minimum_character_width") * em_space_size; + min_size.width = get_theme_constant(SNAME("minimum_character_width")) * em_space_size; if (expand_to_text_length) { // Add a space because some fonts are too exact, and because caret needs a bit more when at the end. @@ -1522,7 +1526,7 @@ Size2 LineEdit::get_minimum_size() const { bool using_placeholder = text.is_empty() && ime_text.is_empty(); bool display_clear_icon = !using_placeholder && is_editable() && clear_button_enabled; if (right_icon.is_valid() || display_clear_icon) { - Ref<Texture2D> r_icon = display_clear_icon ? Control::get_theme_icon("clear") : right_icon; + Ref<Texture2D> r_icon = display_clear_icon ? Control::get_theme_icon(SNAME("clear")) : right_icon; min_size.width += r_icon->get_width(); min_size.height = MAX(min_size.height, r_icon->get_height()); } @@ -1596,7 +1600,6 @@ void LineEdit::set_editable(bool p_editable) { } editable = p_editable; - _generate_context_menu(); minimum_size_changed(); update(); @@ -1810,7 +1813,12 @@ bool LineEdit::is_context_menu_enabled() { return context_menu_enabled; } +bool LineEdit::is_menu_visible() const { + return menu && menu->is_visible(); +} + PopupMenu *LineEdit::get_menu() const { + const_cast<LineEdit *>(this)->_ensure_menu(); return menu; } @@ -1847,8 +1855,6 @@ bool LineEdit::is_clear_button_enabled() const { void LineEdit::set_shortcut_keys_enabled(bool p_enabled) { shortcut_keys_enabled = p_enabled; - - _generate_context_menu(); } bool LineEdit::is_shortcut_keys_enabled() const { @@ -1869,8 +1875,6 @@ void LineEdit::set_selecting_enabled(bool p_enabled) { if (!selecting_enabled) { deselect(); } - - _generate_context_menu(); } bool LineEdit::is_selecting_enabled() const { @@ -1897,7 +1901,7 @@ void LineEdit::_text_changed() { } void LineEdit::_emit_text_change() { - emit_signal("text_changed", text); + emit_signal(SNAME("text_changed"), text); text_changed_dirty = false; } @@ -1924,8 +1928,8 @@ void LineEdit::_shape() { } TS->shaped_text_set_preserve_control(text_rid, draw_control_chars); - const Ref<Font> &font = get_theme_font("font"); - int font_size = get_theme_font_size("font_size"); + const Ref<Font> &font = get_theme_font(SNAME("font")); + int font_size = get_theme_font_size(SNAME("font_size")); TS->shaped_text_add_string(text_rid, t, font->get_rids(), font_size, opentype_features, (language != "") ? language : TranslationServer::get_singleton()->get_tool_locale()); TS->shaped_text_set_bidi_override(text_rid, structured_text_parser(st_parser, st_args, t)); @@ -1941,12 +1945,12 @@ void LineEdit::_shape() { void LineEdit::_fit_to_width() { if (align == ALIGN_FILL) { - Ref<StyleBox> style = get_theme_stylebox("normal"); + Ref<StyleBox> style = get_theme_stylebox(SNAME("normal")); int t_width = get_size().width - style->get_margin(SIDE_RIGHT) - style->get_margin(SIDE_LEFT); bool using_placeholder = text.is_empty() && ime_text.is_empty(); bool display_clear_icon = !using_placeholder && is_editable() && clear_button_enabled; if (right_icon.is_valid() || display_clear_icon) { - Ref<Texture2D> r_icon = display_clear_icon ? Control::get_theme_icon("clear") : right_icon; + Ref<Texture2D> r_icon = display_clear_icon ? Control::get_theme_icon(SNAME("clear")) : right_icon; t_width -= r_icon->get_width(); } TS->shaped_text_fit_to_width(text_rid, MAX(t_width, full_width)); @@ -2007,35 +2011,6 @@ int LineEdit::_get_menu_action_accelerator(const String &p_action) { } } -void LineEdit::_generate_context_menu() { - // Reorganize context menu. - menu->clear(); - if (editable) { - menu->add_item(RTR("Cut"), MENU_CUT, is_shortcut_keys_enabled() ? _get_menu_action_accelerator("ui_cut") : 0); - } - menu->add_item(RTR("Copy"), MENU_COPY, is_shortcut_keys_enabled() ? _get_menu_action_accelerator("ui_copy") : 0); - if (editable) { - menu->add_item(RTR("Paste"), MENU_PASTE, is_shortcut_keys_enabled() ? _get_menu_action_accelerator("ui_paste") : 0); - } - menu->add_separator(); - if (is_selecting_enabled()) { - menu->add_item(RTR("Select All"), MENU_SELECT_ALL, is_shortcut_keys_enabled() ? _get_menu_action_accelerator("ui_text_select_all") : 0); - } - if (editable) { - menu->add_item(RTR("Clear"), MENU_CLEAR); - menu->add_separator(); - menu->add_item(RTR("Undo"), MENU_UNDO, is_shortcut_keys_enabled() ? _get_menu_action_accelerator("ui_undo") : 0); - menu->add_item(RTR("Redo"), MENU_REDO, is_shortcut_keys_enabled() ? _get_menu_action_accelerator("ui_redo") : 0); - } - menu->add_separator(); - menu->add_submenu_item(RTR("Text writing direction"), "DirMenu"); - menu->add_separator(); - menu->add_check_item(RTR("Display control characters"), MENU_DISPLAY_UCC); - if (editable) { - menu->add_submenu_item(RTR("Insert control character"), "CTLMenu"); - } -} - bool LineEdit::_set(const StringName &p_name, const Variant &p_value) { String str = p_name; if (str.begins_with("opentype_features/")) { @@ -2148,6 +2123,7 @@ void LineEdit::_bind_methods() { ClassDB::bind_method(D_METHOD("get_secret_character"), &LineEdit::get_secret_character); ClassDB::bind_method(D_METHOD("menu_option", "option"), &LineEdit::menu_option); ClassDB::bind_method(D_METHOD("get_menu"), &LineEdit::get_menu); + ClassDB::bind_method(D_METHOD("is_menu_visible"), &LineEdit::is_menu_visible); ClassDB::bind_method(D_METHOD("set_context_menu_enabled", "enable"), &LineEdit::set_context_menu_enabled); ClassDB::bind_method(D_METHOD("is_context_menu_enabled"), &LineEdit::is_context_menu_enabled); ClassDB::bind_method(D_METHOD("set_virtual_keyboard_enabled", "enable"), &LineEdit::set_virtual_keyboard_enabled); @@ -2230,6 +2206,79 @@ void LineEdit::_bind_methods() { ADD_PROPERTY(PropertyInfo(Variant::BOOL, "caret_mid_grapheme"), "set_caret_mid_grapheme_enabled", "is_caret_mid_grapheme_enabled"); } +void LineEdit::_ensure_menu() { + if (!menu) { + menu = memnew(PopupMenu); + add_child(menu); + + menu_dir = memnew(PopupMenu); + menu_dir->set_name("DirMenu"); + menu_dir->add_radio_check_item(RTR("Same as layout direction"), MENU_DIR_INHERITED); + menu_dir->add_radio_check_item(RTR("Auto-detect direction"), MENU_DIR_AUTO); + menu_dir->add_radio_check_item(RTR("Left-to-right"), MENU_DIR_LTR); + menu_dir->add_radio_check_item(RTR("Right-to-left"), MENU_DIR_RTL); + menu->add_child(menu_dir); + + menu_ctl = memnew(PopupMenu); + menu_ctl->set_name("CTLMenu"); + menu_ctl->add_item(RTR("Left-to-right mark (LRM)"), MENU_INSERT_LRM); + menu_ctl->add_item(RTR("Right-to-left mark (RLM)"), MENU_INSERT_RLM); + menu_ctl->add_item(RTR("Start of left-to-right embedding (LRE)"), MENU_INSERT_LRE); + menu_ctl->add_item(RTR("Start of right-to-left embedding (RLE)"), MENU_INSERT_RLE); + menu_ctl->add_item(RTR("Start of left-to-right override (LRO)"), MENU_INSERT_LRO); + menu_ctl->add_item(RTR("Start of right-to-left override (RLO)"), MENU_INSERT_RLO); + menu_ctl->add_item(RTR("Pop direction formatting (PDF)"), MENU_INSERT_PDF); + menu_ctl->add_separator(); + menu_ctl->add_item(RTR("Arabic letter mark (ALM)"), MENU_INSERT_ALM); + menu_ctl->add_item(RTR("Left-to-right isolate (LRI)"), MENU_INSERT_LRI); + menu_ctl->add_item(RTR("Right-to-left isolate (RLI)"), MENU_INSERT_RLI); + menu_ctl->add_item(RTR("First strong isolate (FSI)"), MENU_INSERT_FSI); + menu_ctl->add_item(RTR("Pop direction isolate (PDI)"), MENU_INSERT_PDI); + menu_ctl->add_separator(); + menu_ctl->add_item(RTR("Zero width joiner (ZWJ)"), MENU_INSERT_ZWJ); + menu_ctl->add_item(RTR("Zero width non-joiner (ZWNJ)"), MENU_INSERT_ZWNJ); + menu_ctl->add_item(RTR("Word joiner (WJ)"), MENU_INSERT_WJ); + menu_ctl->add_item(RTR("Soft hyphen (SHY)"), MENU_INSERT_SHY); + menu->add_child(menu_ctl); + + menu->connect("id_pressed", callable_mp(this, &LineEdit::menu_option)); + menu_dir->connect("id_pressed", callable_mp(this, &LineEdit::menu_option)); + menu_ctl->connect("id_pressed", callable_mp(this, &LineEdit::menu_option)); + } + + // Reorganize context menu. + menu->clear(); + if (editable) { + menu->add_item(RTR("Cut"), MENU_CUT, is_shortcut_keys_enabled() ? _get_menu_action_accelerator("ui_cut") : 0); + } + menu->add_item(RTR("Copy"), MENU_COPY, is_shortcut_keys_enabled() ? _get_menu_action_accelerator("ui_copy") : 0); + if (editable) { + menu->add_item(RTR("Paste"), MENU_PASTE, is_shortcut_keys_enabled() ? _get_menu_action_accelerator("ui_paste") : 0); + } + menu->add_separator(); + if (is_selecting_enabled()) { + menu->add_item(RTR("Select All"), MENU_SELECT_ALL, is_shortcut_keys_enabled() ? _get_menu_action_accelerator("ui_text_select_all") : 0); + } + if (editable) { + menu->add_item(RTR("Clear"), MENU_CLEAR); + menu->add_separator(); + menu->add_item(RTR("Undo"), MENU_UNDO, is_shortcut_keys_enabled() ? _get_menu_action_accelerator("ui_undo") : 0); + menu->add_item(RTR("Redo"), MENU_REDO, is_shortcut_keys_enabled() ? _get_menu_action_accelerator("ui_redo") : 0); + } + menu->add_separator(); + menu->add_submenu_item(RTR("Text writing direction"), "DirMenu"); + menu->add_separator(); + menu->add_check_item(RTR("Display control characters"), MENU_DISPLAY_UCC); + menu->set_item_checked(menu->get_item_index(MENU_DISPLAY_UCC), draw_control_chars); + if (editable) { + menu->add_submenu_item(RTR("Insert control character"), "CTLMenu"); + } + menu_dir->set_item_checked(menu_dir->get_item_index(MENU_DIR_INHERITED), text_direction == TEXT_DIRECTION_INHERITED); + menu_dir->set_item_checked(menu_dir->get_item_index(MENU_DIR_AUTO), text_direction == TEXT_DIRECTION_AUTO); + menu_dir->set_item_checked(menu_dir->get_item_index(MENU_DIR_LTR), text_direction == TEXT_DIRECTION_LTR); + menu_dir->set_item_checked(menu_dir->get_item_index(MENU_DIR_RTL), text_direction == TEXT_DIRECTION_RTL); +} + LineEdit::LineEdit() { text_rid = TS->create_shaped_text(); _create_undo_state(); @@ -2245,44 +2294,7 @@ LineEdit::LineEdit() { caret_blink_timer->connect("timeout", callable_mp(this, &LineEdit::_toggle_draw_caret)); set_caret_blink_enabled(false); - menu = memnew(PopupMenu); - add_child(menu); - - menu_dir = memnew(PopupMenu); - menu_dir->set_name("DirMenu"); - menu_dir->add_radio_check_item(RTR("Same as layout direction"), MENU_DIR_INHERITED); - menu_dir->add_radio_check_item(RTR("Auto-detect direction"), MENU_DIR_AUTO); - menu_dir->add_radio_check_item(RTR("Left-to-right"), MENU_DIR_LTR); - menu_dir->add_radio_check_item(RTR("Right-to-left"), MENU_DIR_RTL); - menu_dir->set_item_checked(menu_dir->get_item_index(MENU_DIR_INHERITED), true); - menu->add_child(menu_dir); - - menu_ctl = memnew(PopupMenu); - menu_ctl->set_name("CTLMenu"); - menu_ctl->add_item(RTR("Left-to-right mark (LRM)"), MENU_INSERT_LRM); - menu_ctl->add_item(RTR("Right-to-left mark (RLM)"), MENU_INSERT_RLM); - menu_ctl->add_item(RTR("Start of left-to-right embedding (LRE)"), MENU_INSERT_LRE); - menu_ctl->add_item(RTR("Start of right-to-left embedding (RLE)"), MENU_INSERT_RLE); - menu_ctl->add_item(RTR("Start of left-to-right override (LRO)"), MENU_INSERT_LRO); - menu_ctl->add_item(RTR("Start of right-to-left override (RLO)"), MENU_INSERT_RLO); - menu_ctl->add_item(RTR("Pop direction formatting (PDF)"), MENU_INSERT_PDF); - menu_ctl->add_separator(); - menu_ctl->add_item(RTR("Arabic letter mark (ALM)"), MENU_INSERT_ALM); - menu_ctl->add_item(RTR("Left-to-right isolate (LRI)"), MENU_INSERT_LRI); - menu_ctl->add_item(RTR("Right-to-left isolate (RLI)"), MENU_INSERT_RLI); - menu_ctl->add_item(RTR("First strong isolate (FSI)"), MENU_INSERT_FSI); - menu_ctl->add_item(RTR("Pop direction isolate (PDI)"), MENU_INSERT_PDI); - menu_ctl->add_separator(); - menu_ctl->add_item(RTR("Zero width joiner (ZWJ)"), MENU_INSERT_ZWJ); - menu_ctl->add_item(RTR("Zero width non-joiner (ZWNJ)"), MENU_INSERT_ZWNJ); - menu_ctl->add_item(RTR("Word joiner (WJ)"), MENU_INSERT_WJ); - menu_ctl->add_item(RTR("Soft hyphen (SHY)"), MENU_INSERT_SHY); - menu->add_child(menu_ctl); - set_editable(true); // Initialise to opposite first, so we get past the early-out in set_editable. - menu->connect("id_pressed", callable_mp(this, &LineEdit::menu_option)); - menu_dir->connect("id_pressed", callable_mp(this, &LineEdit::menu_option)); - menu_ctl->connect("id_pressed", callable_mp(this, &LineEdit::menu_option)); } LineEdit::~LineEdit() { diff --git a/scene/gui/line_edit.h b/scene/gui/line_edit.h index 12fec2f98b..c5c92d60aa 100644 --- a/scene/gui/line_edit.h +++ b/scene/gui/line_edit.h @@ -165,7 +165,6 @@ private: void _create_undo_state(); int _get_menu_action_accelerator(const String &p_action); - void _generate_context_menu(); void _shape(); void _fit_to_width(); @@ -198,6 +197,8 @@ private: void _backspace(bool p_word = false, bool p_all_to_left = false); void _delete(bool p_word = false, bool p_all_to_right = false); + void _ensure_menu(); + protected: void _notification(int p_what); static void _bind_methods(); @@ -222,6 +223,7 @@ public: void set_context_menu_enabled(bool p_enable); bool is_context_menu_enabled(); PopupMenu *get_menu() const; + bool is_menu_visible() const; void select(int p_from = 0, int p_to = -1); void select_all(); diff --git a/scene/gui/link_button.cpp b/scene/gui/link_button.cpp index ee0618a991..419d49bccf 100644 --- a/scene/gui/link_button.cpp +++ b/scene/gui/link_button.cpp @@ -32,8 +32,8 @@ #include "core/string/translation.h" void LinkButton::_shape() { - Ref<Font> font = get_theme_font("font"); - int font_size = get_theme_font_size("font_size"); + Ref<Font> font = get_theme_font(SNAME("font")); + int font_size = get_theme_font_size(SNAME("font_size")); text_buf->clear(); if (text_direction == Control::TEXT_DIRECTION_INHERITED) { @@ -158,41 +158,41 @@ void LinkButton::_notification(int p_what) { switch (get_draw_mode()) { case DRAW_NORMAL: { - color = get_theme_color("font_color"); + color = get_theme_color(SNAME("font_color")); do_underline = underline_mode == UNDERLINE_MODE_ALWAYS; } break; case DRAW_HOVER_PRESSED: case DRAW_PRESSED: { - if (has_theme_color("font_pressed_color")) { - color = get_theme_color("font_pressed_color"); + if (has_theme_color(SNAME("font_pressed_color"))) { + color = get_theme_color(SNAME("font_pressed_color")); } else { - color = get_theme_color("font_color"); + color = get_theme_color(SNAME("font_color")); } do_underline = underline_mode != UNDERLINE_MODE_NEVER; } break; case DRAW_HOVER: { - color = get_theme_color("font_hover_color"); + color = get_theme_color(SNAME("font_hover_color")); do_underline = underline_mode != UNDERLINE_MODE_NEVER; } break; case DRAW_DISABLED: { - color = get_theme_color("font_disabled_color"); + color = get_theme_color(SNAME("font_disabled_color")); do_underline = underline_mode == UNDERLINE_MODE_ALWAYS; } break; } if (has_focus()) { - Ref<StyleBox> style = get_theme_stylebox("focus"); + Ref<StyleBox> style = get_theme_stylebox(SNAME("focus")); style->draw(ci, Rect2(Point2(), size)); } int width = text_buf->get_line_width(); - Color font_outline_color = get_theme_color("font_outline_color"); - int outline_size = get_theme_constant("outline_size"); + Color font_outline_color = get_theme_color(SNAME("font_outline_color")); + int outline_size = get_theme_constant(SNAME("outline_size")); if (is_layout_rtl()) { if (outline_size > 0 && font_outline_color.a > 0) { text_buf->draw_outline(get_canvas_item(), Vector2(size.width - width, 0), outline_size, font_outline_color); @@ -206,7 +206,7 @@ void LinkButton::_notification(int p_what) { } if (do_underline) { - int underline_spacing = get_theme_constant("underline_spacing") + text_buf->get_line_underline_position(); + int underline_spacing = get_theme_constant(SNAME("underline_spacing")) + text_buf->get_line_underline_position(); int y = text_buf->get_line_ascent() + underline_spacing; if (is_layout_rtl()) { diff --git a/scene/gui/margin_container.cpp b/scene/gui/margin_container.cpp index 0e9610d0a3..50b4d192a9 100644 --- a/scene/gui/margin_container.cpp +++ b/scene/gui/margin_container.cpp @@ -31,10 +31,10 @@ #include "margin_container.h" Size2 MarginContainer::get_minimum_size() const { - int margin_left = get_theme_constant("margin_left"); - int margin_top = get_theme_constant("margin_top"); - int margin_right = get_theme_constant("margin_right"); - int margin_bottom = get_theme_constant("margin_bottom"); + int margin_left = get_theme_constant(SNAME("margin_left")); + int margin_top = get_theme_constant(SNAME("margin_top")); + int margin_right = get_theme_constant(SNAME("margin_right")); + int margin_bottom = get_theme_constant(SNAME("margin_bottom")); Size2 max; @@ -68,10 +68,10 @@ Size2 MarginContainer::get_minimum_size() const { void MarginContainer::_notification(int p_what) { switch (p_what) { case NOTIFICATION_SORT_CHILDREN: { - int margin_left = get_theme_constant("margin_left"); - int margin_top = get_theme_constant("margin_top"); - int margin_right = get_theme_constant("margin_right"); - int margin_bottom = get_theme_constant("margin_bottom"); + int margin_left = get_theme_constant(SNAME("margin_left")); + int margin_top = get_theme_constant(SNAME("margin_top")); + int margin_right = get_theme_constant(SNAME("margin_right")); + int margin_bottom = get_theme_constant(SNAME("margin_bottom")); Size2 s = get_size(); diff --git a/scene/gui/menu_button.cpp b/scene/gui/menu_button.cpp index 1e9baa77fc..cf1f41d0fc 100644 --- a/scene/gui/menu_button.cpp +++ b/scene/gui/menu_button.cpp @@ -55,6 +55,36 @@ void MenuButton::_unhandled_key_input(Ref<InputEvent> p_event) { } } +void MenuButton::_popup_visibility_changed(bool p_visible) { + set_pressed(p_visible); + + if (!p_visible) { + set_process_internal(false); + return; + } + + if (switch_on_hover) { + Window *window = Object::cast_to<Window>(get_viewport()); + if (window) { + mouse_pos_adjusted = window->get_position(); + + if (window->is_embedded()) { + Window *window_parent = Object::cast_to<Window>(window->get_parent()->get_viewport()); + while (window_parent) { + if (!window_parent->is_embedded()) { + mouse_pos_adjusted += window_parent->get_position(); + break; + } + + window_parent = Object::cast_to<Window>(window_parent->get_parent()->get_viewport()); + } + } + + set_process_internal(true); + } + } +} + void MenuButton::pressed() { Size2 size = get_size(); @@ -94,10 +124,22 @@ bool MenuButton::is_switch_on_hover() { } void MenuButton::_notification(int p_what) { - if (p_what == NOTIFICATION_VISIBILITY_CHANGED) { - if (!is_visible_in_tree()) { - popup->hide(); - } + switch (p_what) { + case NOTIFICATION_VISIBILITY_CHANGED: { + if (!is_visible_in_tree()) { + popup->hide(); + } + } break; + case NOTIFICATION_INTERNAL_PROCESS: { + Vector2i mouse_pos = DisplayServer::get_singleton()->mouse_get_position() - mouse_pos_adjusted; + MenuButton *menu_btn_other = Object::cast_to<MenuButton>(get_viewport()->gui_find_control(mouse_pos)); + + if (menu_btn_other && menu_btn_other != this && menu_btn_other->is_switch_on_hover() && !menu_btn_other->is_disabled() && + (get_parent()->is_ancestor_of(menu_btn_other) || menu_btn_other->get_parent()->is_ancestor_of(popup))) { + popup->hide(); + menu_btn_other->pressed(); + } + } break; } } @@ -130,8 +172,8 @@ MenuButton::MenuButton() { popup = memnew(PopupMenu); popup->hide(); add_child(popup); - popup->connect("about_to_popup", callable_mp((BaseButton *)this, &BaseButton::set_pressed), varray(true)); // For when switching from another MenuButton. - popup->connect("popup_hide", callable_mp((BaseButton *)this, &BaseButton::set_pressed), varray(false)); + popup->connect("about_to_popup", callable_mp(this, &MenuButton::_popup_visibility_changed), varray(true)); + popup->connect("popup_hide", callable_mp(this, &MenuButton::_popup_visibility_changed), varray(false)); } MenuButton::~MenuButton() { diff --git a/scene/gui/menu_button.h b/scene/gui/menu_button.h index fd9ae6021e..cc2ca117c4 100644 --- a/scene/gui/menu_button.h +++ b/scene/gui/menu_button.h @@ -42,11 +42,15 @@ class MenuButton : public Button { bool disable_shortcuts = false; PopupMenu *popup; + Vector2i mouse_pos_adjusted; + Array _get_items() const; void _set_items(const Array &p_items); void _gui_input(Ref<InputEvent> p_event) override; + void _popup_visibility_changed(bool p_visible); + protected: void _notification(int p_what); static void _bind_methods(); diff --git a/scene/gui/option_button.cpp b/scene/gui/option_button.cpp index e52b6917be..cd55f258b3 100644 --- a/scene/gui/option_button.cpp +++ b/scene/gui/option_button.cpp @@ -35,12 +35,12 @@ Size2 OptionButton::get_minimum_size() const { Size2 minsize = Button::get_minimum_size(); - if (has_theme_icon("arrow")) { - const Size2 padding = get_theme_stylebox("normal")->get_minimum_size(); - const Size2 arrow_size = Control::get_theme_icon("arrow")->get_size(); + if (has_theme_icon(SNAME("arrow"))) { + const Size2 padding = get_theme_stylebox(SNAME("normal"))->get_minimum_size(); + const Size2 arrow_size = Control::get_theme_icon(SNAME("arrow"))->get_size(); Size2 content_size = minsize - padding; - content_size.width += arrow_size.width + get_theme_constant("hseparation"); + content_size.width += arrow_size.width + get_theme_constant(SNAME("hseparation")); content_size.height = MAX(content_size.height, arrow_size.height); minsize = content_size + padding; @@ -52,26 +52,26 @@ Size2 OptionButton::get_minimum_size() const { void OptionButton::_notification(int p_what) { switch (p_what) { case NOTIFICATION_DRAW: { - if (!has_theme_icon("arrow")) { + if (!has_theme_icon(SNAME("arrow"))) { return; } RID ci = get_canvas_item(); - Ref<Texture2D> arrow = Control::get_theme_icon("arrow"); + Ref<Texture2D> arrow = Control::get_theme_icon(SNAME("arrow")); Color clr = Color(1, 1, 1); - if (get_theme_constant("modulate_arrow")) { + if (get_theme_constant(SNAME("modulate_arrow"))) { switch (get_draw_mode()) { case DRAW_PRESSED: - clr = get_theme_color("font_pressed_color"); + clr = get_theme_color(SNAME("font_pressed_color")); break; case DRAW_HOVER: - clr = get_theme_color("font_hover_color"); + clr = get_theme_color(SNAME("font_hover_color")); break; case DRAW_DISABLED: - clr = get_theme_color("font_disabled_color"); + clr = get_theme_color(SNAME("font_disabled_color")); break; default: - clr = get_theme_color("font_color"); + clr = get_theme_color(SNAME("font_color")); } } @@ -79,22 +79,22 @@ void OptionButton::_notification(int p_what) { Point2 ofs; if (is_layout_rtl()) { - ofs = Point2(get_theme_constant("arrow_margin"), int(Math::abs((size.height - arrow->get_height()) / 2))); + ofs = Point2(get_theme_constant(SNAME("arrow_margin")), int(Math::abs((size.height - arrow->get_height()) / 2))); } else { - ofs = Point2(size.width - arrow->get_width() - get_theme_constant("arrow_margin"), int(Math::abs((size.height - arrow->get_height()) / 2))); + ofs = Point2(size.width - arrow->get_width() - get_theme_constant(SNAME("arrow_margin")), int(Math::abs((size.height - arrow->get_height()) / 2))); } arrow->draw(ci, ofs, clr); } break; case NOTIFICATION_TRANSLATION_CHANGED: case NOTIFICATION_LAYOUT_DIRECTION_CHANGED: case NOTIFICATION_THEME_CHANGED: { - if (has_theme_icon("arrow")) { + if (has_theme_icon(SNAME("arrow"))) { if (is_layout_rtl()) { - _set_internal_margin(SIDE_LEFT, Control::get_theme_icon("arrow")->get_width()); + _set_internal_margin(SIDE_LEFT, Control::get_theme_icon(SNAME("arrow"))->get_width()); _set_internal_margin(SIDE_RIGHT, 0.f); } else { _set_internal_margin(SIDE_LEFT, 0.f); - _set_internal_margin(SIDE_RIGHT, Control::get_theme_icon("arrow")->get_width()); + _set_internal_margin(SIDE_RIGHT, Control::get_theme_icon(SNAME("arrow"))->get_width()); } } } break; @@ -107,7 +107,7 @@ void OptionButton::_notification(int p_what) { } void OptionButton::_focused(int p_which) { - emit_signal("item_focused", p_which); + emit_signal(SNAME("item_focused"), p_which); } void OptionButton::_selected(int p_which) { @@ -220,7 +220,7 @@ void OptionButton::_select(int p_which, bool p_emit) { set_icon(popup->get_item_icon(current)); if (is_inside_tree() && p_emit) { - emit_signal("item_selected", current); + emit_signal(SNAME("item_selected"), current); } } @@ -339,12 +339,12 @@ OptionButton::OptionButton() { set_toggle_mode(true); set_text_align(ALIGN_LEFT); if (is_layout_rtl()) { - if (has_theme_icon("arrow")) { - _set_internal_margin(SIDE_LEFT, Control::get_theme_icon("arrow")->get_width()); + if (has_theme_icon(SNAME("arrow"))) { + _set_internal_margin(SIDE_LEFT, Control::get_theme_icon(SNAME("arrow"))->get_width()); } } else { - if (has_theme_icon("arrow")) { - _set_internal_margin(SIDE_RIGHT, Control::get_theme_icon("arrow")->get_width()); + if (has_theme_icon(SNAME("arrow"))) { + _set_internal_margin(SIDE_RIGHT, Control::get_theme_icon(SNAME("arrow"))->get_width()); } } set_action_mode(ACTION_MODE_BUTTON_PRESS); diff --git a/scene/gui/panel.cpp b/scene/gui/panel.cpp index 995e985c3a..e8e7e3d997 100644 --- a/scene/gui/panel.cpp +++ b/scene/gui/panel.cpp @@ -35,7 +35,7 @@ void Panel::_notification(int p_what) { if (p_what == NOTIFICATION_DRAW) { RID ci = get_canvas_item(); - Ref<StyleBox> style = mode == MODE_BACKGROUND ? get_theme_stylebox("panel") : get_theme_stylebox("panel_fg"); + Ref<StyleBox> style = mode == MODE_BACKGROUND ? get_theme_stylebox(SNAME("panel")) : get_theme_stylebox(SNAME("panel_fg")); style->draw(ci, Rect2(Point2(), get_size())); } } diff --git a/scene/gui/panel_container.cpp b/scene/gui/panel_container.cpp index 11d822c5e1..d910e1e882 100644 --- a/scene/gui/panel_container.cpp +++ b/scene/gui/panel_container.cpp @@ -33,10 +33,10 @@ Size2 PanelContainer::get_minimum_size() const { Ref<StyleBox> style; - if (has_theme_stylebox("panel")) { - style = get_theme_stylebox("panel"); + if (has_theme_stylebox(SNAME("panel"))) { + style = get_theme_stylebox(SNAME("panel")); } else { - style = get_theme_stylebox("panel", "PanelContainer"); + style = get_theme_stylebox(SNAME("panel"), SNAME("PanelContainer")); } Size2 ms; @@ -65,10 +65,10 @@ void PanelContainer::_notification(int p_what) { RID ci = get_canvas_item(); Ref<StyleBox> style; - if (has_theme_stylebox("panel")) { - style = get_theme_stylebox("panel"); + if (has_theme_stylebox(SNAME("panel"))) { + style = get_theme_stylebox(SNAME("panel")); } else { - style = get_theme_stylebox("panel", "PanelContainer"); + style = get_theme_stylebox(SNAME("panel"), SNAME("PanelContainer")); } style->draw(ci, Rect2(Point2(), get_size())); @@ -77,10 +77,10 @@ void PanelContainer::_notification(int p_what) { if (p_what == NOTIFICATION_SORT_CHILDREN) { Ref<StyleBox> style; - if (has_theme_stylebox("panel")) { - style = get_theme_stylebox("panel"); + if (has_theme_stylebox(SNAME("panel"))) { + style = get_theme_stylebox(SNAME("panel")); } else { - style = get_theme_stylebox("panel", "PanelContainer"); + style = get_theme_stylebox(SNAME("panel"), SNAME("PanelContainer")); } Size2 size = get_size(); diff --git a/scene/gui/popup.cpp b/scene/gui/popup.cpp index 36bcca61a7..f7e7e1cd60 100644 --- a/scene/gui/popup.cpp +++ b/scene/gui/popup.cpp @@ -71,7 +71,8 @@ void Popup::_notification(int p_what) { _initialize_visible_parents(); } else { _deinitialize_visible_parents(); - emit_signal("popup_hide"); + emit_signal(SNAME("popup_hide")); + popped_up = false; } } break; @@ -103,9 +104,9 @@ void Popup::_close_pressed() { _deinitialize_visible_parents(); - call_deferred("hide"); + call_deferred(SNAME("hide")); - emit_signal("cancelled"); + emit_signal(SNAME("cancelled")); } void Popup::set_as_minsize() { diff --git a/scene/gui/popup_menu.cpp b/scene/gui/popup_menu.cpp index 2100707d2d..490548fce0 100644 --- a/scene/gui/popup_menu.cpp +++ b/scene/gui/popup_menu.cpp @@ -46,15 +46,15 @@ String PopupMenu::_get_accel_text(const Item &p_item) const { } Size2 PopupMenu::_get_contents_minimum_size() const { - int vseparation = get_theme_constant("vseparation"); - int hseparation = get_theme_constant("hseparation"); + int vseparation = get_theme_constant(SNAME("vseparation")); + int hseparation = get_theme_constant(SNAME("hseparation")); - Size2 minsize = get_theme_stylebox("panel")->get_minimum_size(); // Accounts for margin in the margin container + Size2 minsize = get_theme_stylebox(SNAME("panel"))->get_minimum_size(); // Accounts for margin in the margin container minsize.x += scroll_container->get_v_scrollbar()->get_size().width * 2; // Adds a buffer so that the scrollbar does not render over the top of content float max_w = 0.0; float icon_w = 0.0; - int check_w = MAX(get_theme_icon("checked")->get_width(), get_theme_icon("radio_checked")->get_width()) + hseparation; + int check_w = MAX(get_theme_icon(SNAME("checked"))->get_width(), get_theme_icon(SNAME("radio_checked"))->get_width()) + hseparation; int accel_max_w = 0; bool has_check = false; @@ -81,7 +81,7 @@ Size2 PopupMenu::_get_contents_minimum_size() const { } if (items[i].submenu != "") { - size.width += get_theme_icon("submenu")->get_width(); + size.width += get_theme_icon(SNAME("submenu"))->get_width(); } max_w = MAX(max_w, size.width); @@ -89,7 +89,7 @@ Size2 PopupMenu::_get_contents_minimum_size() const { minsize.height += size.height; } - int item_side_padding = get_theme_constant("item_start_padding") + get_theme_constant("item_end_padding"); + int item_side_padding = get_theme_constant(SNAME("item_start_padding")) + get_theme_constant(SNAME("item_end_padding")); minsize.width += max_w + icon_w + accel_max_w + item_side_padding; if (has_check) { @@ -112,24 +112,24 @@ int PopupMenu::_get_item_height(int p_item) const { int icon_height = items[p_item].get_icon_size().height; if (items[p_item].checkable_type) { - icon_height = MAX(icon_height, MAX(get_theme_icon("checked")->get_height(), get_theme_icon("radio_checked")->get_height())); + icon_height = MAX(icon_height, MAX(get_theme_icon(SNAME("checked"))->get_height(), get_theme_icon(SNAME("radio_checked"))->get_height())); } int text_height = items[p_item].text_buf->get_size().height; if (text_height == 0 && !items[p_item].separator) { - text_height = get_theme_font("font")->get_height(get_theme_font_size("font_size")); + text_height = get_theme_font(SNAME("font"))->get_height(get_theme_font_size(SNAME("font_size"))); } int separator_height = 0; if (items[p_item].separator) { - separator_height = MAX(get_theme_stylebox("separator")->get_minimum_size().height, MAX(get_theme_stylebox("labeled_separator_left")->get_minimum_size().height, get_theme_stylebox("labeled_separator_right")->get_minimum_size().height)); + separator_height = MAX(get_theme_stylebox(SNAME("separator"))->get_minimum_size().height, MAX(get_theme_stylebox(SNAME("labeled_separator_left"))->get_minimum_size().height, get_theme_stylebox(SNAME("labeled_separator_right"))->get_minimum_size().height)); } return MAX(separator_height, MAX(text_height, icon_height)); } int PopupMenu::_get_items_total_height() const { - int vsep = get_theme_constant("vseparation"); + int vsep = get_theme_constant(SNAME("vseparation")); // Get total height of all items by taking max of icon height and font height int items_total_height = 0; @@ -163,9 +163,9 @@ int PopupMenu::_get_mouse_over(const Point2 &p_over) const { return -1; } - Ref<StyleBox> style = get_theme_stylebox("panel"); // Accounts for margin in the margin container + Ref<StyleBox> style = get_theme_stylebox(SNAME("panel")); // Accounts for margin in the margin container - int vseparation = get_theme_constant("vseparation"); + int vseparation = get_theme_constant(SNAME("vseparation")); Point2 ofs = style->get_offset() + Point2(0, vseparation / 2); @@ -195,8 +195,8 @@ void PopupMenu::_activate_submenu(int p_over) { return; //already visible! } - Ref<StyleBox> style = get_theme_stylebox("panel"); - int vsep = get_theme_constant("vseparation"); + Ref<StyleBox> style = get_theme_stylebox(SNAME("panel")); + int vsep = get_theme_constant(SNAME("vseparation")); Point2 this_pos = get_position(); Rect2 this_rect(this_pos, get_size()); @@ -264,7 +264,7 @@ void PopupMenu::_gui_input(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("id_focused", i); + emit_signal(SNAME("id_focused"), i); _scroll_to_item(i); control->update(); set_input_as_handled(); @@ -278,7 +278,7 @@ void PopupMenu::_gui_input(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("id_focused", i); + emit_signal(SNAME("id_focused"), i); _scroll_to_item(i); control->update(); set_input_as_handled(); @@ -296,7 +296,7 @@ void PopupMenu::_gui_input(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("id_focused", i); + emit_signal(SNAME("id_focused"), i); _scroll_to_item(i); control->update(); set_input_as_handled(); @@ -310,7 +310,7 @@ void PopupMenu::_gui_input(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("id_focused", i); + emit_signal(SNAME("id_focused"), i); _scroll_to_item(i); control->update(); set_input_as_handled(); @@ -397,17 +397,17 @@ void PopupMenu::_gui_input(const Ref<InputEvent> &p_event) { Ref<InputEventMouseMotion> m = p_event; if (m.is_valid()) { - if (!item_clickable_area.has_point(m->get_position())) { - return; - } - - for (List<Rect2>::Element *E = autohide_areas.front(); E; E = E->next()) { - if (!Rect2(Point2(), get_size()).has_point(m->get_position()) && E->get().has_point(m->get_position())) { + for (const Rect2 &E : autohide_areas) { + if (!Rect2(Point2(), get_size()).has_point(m->get_position()) && E.has_point(m->get_position())) { _close_pressed(); return; } } + if (!item_clickable_area.has_point(m->get_position())) { + return; + } + int over = _get_mouse_over(m->get_position()); int id = (over < 0 || items[over].separator || items[over].disabled) ? -1 : (items[over].id >= 0 ? items[over].id : over); @@ -459,7 +459,7 @@ void PopupMenu::_gui_input(const Ref<InputEvent> &p_event) { if (items[i].text.findn(search_string) == 0) { mouse_over = i; - emit_signal("id_focused", i); + emit_signal(SNAME("id_focused"), i); _scroll_to_item(i); control->update(); set_input_as_handled(); @@ -474,37 +474,37 @@ void PopupMenu::_draw_items() { RID ci = control->get_canvas_item(); Size2 margin_size; - margin_size.width = margin_container->get_theme_constant("margin_right") + margin_container->get_theme_constant("margin_left"); - margin_size.height = margin_container->get_theme_constant("margin_top") + margin_container->get_theme_constant("margin_bottom"); + margin_size.width = margin_container->get_theme_constant(SNAME("margin_right")) + margin_container->get_theme_constant(SNAME("margin_left")); + margin_size.height = margin_container->get_theme_constant(SNAME("margin_top")) + margin_container->get_theme_constant(SNAME("margin_bottom")); // Space between the item content and the sides of popup menu. - int item_start_padding = get_theme_constant("item_start_padding"); - int item_end_padding = get_theme_constant("item_end_padding"); + int item_start_padding = get_theme_constant(SNAME("item_start_padding")); + int item_end_padding = get_theme_constant(SNAME("item_end_padding")); bool rtl = control->is_layout_rtl(); - Ref<StyleBox> style = get_theme_stylebox("panel"); - Ref<StyleBox> hover = get_theme_stylebox("hover"); + Ref<StyleBox> style = get_theme_stylebox(SNAME("panel")); + Ref<StyleBox> hover = get_theme_stylebox(SNAME("hover")); // In Item::checkable_type enum order (less the non-checkable member) - Ref<Texture2D> check[] = { get_theme_icon("checked"), get_theme_icon("radio_checked") }; - Ref<Texture2D> uncheck[] = { get_theme_icon("unchecked"), get_theme_icon("radio_unchecked") }; + Ref<Texture2D> check[] = { get_theme_icon(SNAME("checked")), get_theme_icon(SNAME("radio_checked")) }; + Ref<Texture2D> uncheck[] = { get_theme_icon(SNAME("unchecked")), get_theme_icon(SNAME("radio_unchecked")) }; Ref<Texture2D> submenu; if (rtl) { - submenu = get_theme_icon("submenu_mirrored"); + submenu = get_theme_icon(SNAME("submenu_mirrored")); } else { - submenu = get_theme_icon("submenu"); + submenu = get_theme_icon(SNAME("submenu")); } - Ref<StyleBox> separator = get_theme_stylebox("separator"); - Ref<StyleBox> labeled_separator_left = get_theme_stylebox("labeled_separator_left"); - Ref<StyleBox> labeled_separator_right = get_theme_stylebox("labeled_separator_right"); + Ref<StyleBox> separator = get_theme_stylebox(SNAME("separator")); + Ref<StyleBox> labeled_separator_left = get_theme_stylebox(SNAME("labeled_separator_left")); + Ref<StyleBox> labeled_separator_right = get_theme_stylebox(SNAME("labeled_separator_right")); - int vseparation = get_theme_constant("vseparation"); - int hseparation = get_theme_constant("hseparation"); - Color font_color = get_theme_color("font_color"); - Color font_disabled_color = get_theme_color("font_disabled_color"); - Color font_accelerator_color = get_theme_color("font_accelerator_color"); - Color font_hover_color = get_theme_color("font_hover_color"); - Color font_separator_color = get_theme_color("font_separator_color"); + int vseparation = get_theme_constant(SNAME("vseparation")); + int hseparation = get_theme_constant(SNAME("hseparation")); + Color font_color = get_theme_color(SNAME("font_color")); + Color font_disabled_color = get_theme_color(SNAME("font_disabled_color")); + Color font_accelerator_color = get_theme_color(SNAME("font_accelerator_color")); + Color font_hover_color = get_theme_color(SNAME("font_hover_color")); + Color font_separator_color = get_theme_color(SNAME("font_separator_color")); float scroll_width = scroll_container->get_v_scrollbar()->is_visible_in_tree() ? scroll_container->get_v_scrollbar()->get_size().width : 0; float display_width = control->get_size().width - scroll_width; @@ -525,7 +525,7 @@ void PopupMenu::_draw_items() { float check_ofs = 0.0; if (has_check) { - check_ofs = MAX(get_theme_icon("checked")->get_width(), get_theme_icon("radio_checked")->get_width()) + hseparation; + check_ofs = MAX(get_theme_icon(SNAME("checked"))->get_width(), get_theme_icon(SNAME("radio_checked"))->get_width()) + hseparation; } Point2 ofs = Point2(); @@ -606,8 +606,8 @@ void PopupMenu::_draw_items() { } // Text - Color font_outline_color = get_theme_color("font_outline_color"); - int outline_size = get_theme_constant("outline_size"); + Color font_outline_color = get_theme_color(SNAME("font_outline_color")); + int outline_size = get_theme_constant(SNAME("outline_size")); if (items[i].separator) { if (text != String()) { int center = (display_width - items[i].text_buf->get_size().width) / 2; @@ -657,7 +657,7 @@ void PopupMenu::_draw_items() { } void PopupMenu::_draw_background() { - Ref<StyleBox> style = get_theme_stylebox("panel"); + Ref<StyleBox> style = get_theme_stylebox(SNAME("panel")); RID ci2 = margin_container->get_canvas_item(); style->draw(ci2, Rect2(Point2(), margin_container->get_size())); } @@ -691,8 +691,8 @@ void PopupMenu::_shape_item(int p_item) { if (items.write[p_item].dirty) { items.write[p_item].text_buf->clear(); - Ref<Font> font = get_theme_font("font"); - int font_size = get_theme_font_size("font_size"); + Ref<Font> font = get_theme_font(SNAME("font")); + int font_size = get_theme_font_size(SNAME("font_size")); if (items[p_item].text_direction == Control::TEXT_DIRECTION_INHERITED) { items.write[p_item].text_buf->set_direction(is_layout_rtl() ? TextServer::DIRECTION_RTL : TextServer::DIRECTION_LTR); @@ -722,7 +722,7 @@ void PopupMenu::_notification(int p_what) { case Control::NOTIFICATION_LAYOUT_DIRECTION_CHANGED: case NOTIFICATION_TRANSLATION_CHANGED: { for (int i = 0; i < items.size(); i++) { - items.write[i].xl_text = tr(items[i].text); + items.write[i].xl_text = atr(items[i].text); items.write[i].dirty = true; _shape_item(i); } @@ -747,12 +747,12 @@ void PopupMenu::_notification(int p_what) { } break; case NOTIFICATION_INTERNAL_PROCESS: { //only used when using operating system windows - if (get_window_id() != DisplayServer::INVALID_WINDOW_ID && autohide_areas.size()) { + if (!is_embedded() && autohide_areas.size()) { Point2 mouse_pos = DisplayServer::get_singleton()->mouse_get_position(); mouse_pos -= get_position(); - for (List<Rect2>::Element *E = autohide_areas.front(); E; E = E->next()) { - if (!Rect2(Point2(), get_size()).has_point(mouse_pos) && E->get().has_point(mouse_pos)) { + for (const Rect2 &E : autohide_areas) { + if (!Rect2(Point2(), get_size()).has_point(mouse_pos) && E.has_point(mouse_pos)) { _close_pressed(); return; } @@ -786,12 +786,12 @@ void PopupMenu::_notification(int p_what) { set_process_internal(false); } else { - if (get_window_id() != DisplayServer::INVALID_WINDOW_ID) { + if (!is_embedded()) { set_process_internal(true); } // Set margin on the margin container - Ref<StyleBox> panel_style = get_theme_stylebox("panel"); + Ref<StyleBox> panel_style = get_theme_stylebox(SNAME("panel")); margin_container->add_theme_constant_override("margin_top", panel_style->get_margin(Side::SIDE_TOP)); margin_container->add_theme_constant_override("margin_bottom", panel_style->get_margin(Side::SIDE_BOTTOM)); margin_container->add_theme_constant_override("margin_left", panel_style->get_margin(Side::SIDE_LEFT)); @@ -807,7 +807,7 @@ void PopupMenu::_notification(int p_what) { #define ITEM_SETUP_WITH_ACCEL(p_label, p_id, p_accel) \ item.text = p_label; \ - item.xl_text = tr(p_label); \ + item.xl_text = atr(p_label); \ item.id = p_id == -1 ? items.size() : p_id; \ item.accel = p_accel; @@ -887,7 +887,7 @@ void PopupMenu::add_multistate_item(const String &p_label, int p_max_states, int ERR_FAIL_COND_MSG(p_shortcut.is_null(), "Cannot add item with invalid Shortcut."); \ _ref_shortcut(p_shortcut); \ item.text = p_shortcut->get_name(); \ - item.xl_text = tr(item.text); \ + item.xl_text = atr(item.text); \ item.id = p_id == -1 ? items.size() : p_id; \ item.shortcut = p_shortcut; \ item.shortcut_is_global = p_global; @@ -956,7 +956,7 @@ void PopupMenu::add_icon_radio_check_shortcut(const Ref<Texture2D> &p_icon, cons void PopupMenu::add_submenu_item(const String &p_label, const String &p_submenu, int p_id) { Item item; item.text = p_label; - item.xl_text = tr(p_label); + item.xl_text = atr(p_label); item.id = p_id == -1 ? items.size() : p_id; item.submenu = p_submenu; items.push_back(item); @@ -973,7 +973,7 @@ void PopupMenu::add_submenu_item(const String &p_label, const String &p_submenu, void PopupMenu::set_item_text(int p_idx, const String &p_text) { ERR_FAIL_INDEX(p_idx, items.size()); items.write[p_idx].text = p_text; - items.write[p_idx].xl_text = tr(p_text); + items.write[p_idx].xl_text = atr(p_text); _shape_item(p_idx); control->update(); @@ -1376,8 +1376,8 @@ void PopupMenu::activate_item(int p_item) { need_hide = false; } - emit_signal("id_pressed", id); - emit_signal("index_pressed", p_item); + emit_signal(SNAME("id_pressed"), id); + emit_signal(SNAME("index_pressed"), p_item); if (need_hide) { hide(); @@ -1402,7 +1402,7 @@ void PopupMenu::add_separator(const String &p_text, int p_id) { sep.id = p_id; if (p_text != String()) { sep.text = p_text; - sep.xl_text = tr(p_text); + sep.xl_text = atr(p_text); } items.push_back(sep); control->update(); diff --git a/scene/gui/popup_menu.h b/scene/gui/popup_menu.h index 74718395d3..aedc5d0155 100644 --- a/scene/gui/popup_menu.h +++ b/scene/gui/popup_menu.h @@ -140,7 +140,6 @@ class PopupMenu : public Popup { void _close_pressed(); protected: - friend class MenuButton; void _notification(int p_what); static void _bind_methods(); diff --git a/scene/gui/progress_bar.cpp b/scene/gui/progress_bar.cpp index 6e8dfd5994..2cfaaa2fde 100644 --- a/scene/gui/progress_bar.cpp +++ b/scene/gui/progress_bar.cpp @@ -32,10 +32,10 @@ #include "scene/resources/text_line.h" Size2 ProgressBar::get_minimum_size() const { - Ref<StyleBox> bg = get_theme_stylebox("bg"); - Ref<StyleBox> fg = get_theme_stylebox("fg"); - Ref<Font> font = get_theme_font("font"); - int font_size = get_theme_font_size("font_size"); + Ref<StyleBox> bg = get_theme_stylebox(SNAME("bg")); + Ref<StyleBox> fg = get_theme_stylebox(SNAME("fg")); + Ref<Font> font = get_theme_font(SNAME("font")); + int font_size = get_theme_font_size(SNAME("font_size")); Size2 minimum_size = bg->get_minimum_size(); minimum_size.height = MAX(minimum_size.height, fg->get_minimum_size().height); @@ -53,11 +53,11 @@ Size2 ProgressBar::get_minimum_size() const { void ProgressBar::_notification(int p_what) { if (p_what == NOTIFICATION_DRAW) { - Ref<StyleBox> bg = get_theme_stylebox("bg"); - Ref<StyleBox> fg = get_theme_stylebox("fg"); - Ref<Font> font = get_theme_font("font"); - int font_size = get_theme_font_size("font_size"); - Color font_color = get_theme_color("font_color"); + Ref<StyleBox> bg = get_theme_stylebox(SNAME("bg")); + Ref<StyleBox> fg = get_theme_stylebox(SNAME("fg")); + Ref<Font> font = get_theme_font(SNAME("font")); + int font_size = get_theme_font_size(SNAME("font_size")); + Color font_color = get_theme_color(SNAME("font_color")); draw_style_box(bg, Rect2(Point2(), get_size())); float r = get_as_ratio(); @@ -75,8 +75,8 @@ void ProgressBar::_notification(int p_what) { String txt = TS->format_number(itos(int(get_as_ratio() * 100))) + TS->percent_sign(); TextLine tl = TextLine(txt, font, font_size); Vector2 text_pos = (Point2(get_size().width - tl.get_size().x, get_size().height - tl.get_size().y) / 2).round(); - Color font_outline_color = get_theme_color("font_outline_color"); - int outline_size = get_theme_constant("outline_size"); + Color font_outline_color = get_theme_color(SNAME("font_outline_color")); + int outline_size = get_theme_constant(SNAME("outline_size")); if (outline_size > 0 && font_outline_color.a > 0) { tl.draw_outline(get_canvas_item(), text_pos, outline_size, font_outline_color); } diff --git a/scene/gui/range.cpp b/scene/gui/range.cpp index 4ea1e1eb9f..92d4261d8d 100644 --- a/scene/gui/range.cpp +++ b/scene/gui/range.cpp @@ -42,7 +42,7 @@ TypedArray<String> Range::get_configuration_warnings() const { void Range::_value_changed_notify() { _value_changed(shared->val); - emit_signal("value_changed", shared->val); + emit_signal(SNAME("value_changed"), shared->val); update(); } @@ -57,7 +57,7 @@ void Range::Shared::emit_value_changed() { } void Range::_changed_notify(const char *p_what) { - emit_signal("changed"); + emit_signal(SNAME("changed")); update(); } diff --git a/scene/gui/rich_text_label.cpp b/scene/gui/rich_text_label.cpp index f32ad2144a..3925e0c38e 100644 --- a/scene/gui/rich_text_label.cpp +++ b/scene/gui/rich_text_label.cpp @@ -136,7 +136,7 @@ RichTextLabel::Item *RichTextLabel::_get_prev_item(Item *p_item, bool p_free) co } Rect2 RichTextLabel::_get_text_rect() { - Ref<StyleBox> style = get_theme_stylebox("normal"); + Ref<StyleBox> style = get_theme_stylebox(SNAME("normal")); return Rect2(style->get_offset(), get_size() - style->get_minimum_size()); } @@ -229,8 +229,8 @@ void RichTextLabel::_resize_line(ItemFrame *p_frame, int p_line, const Ref<Font> switch (it->type) { case ITEM_TABLE: { ItemTable *table = static_cast<ItemTable *>(it); - int hseparation = get_theme_constant("table_hseparation"); - int vseparation = get_theme_constant("table_vseparation"); + int hseparation = get_theme_constant(SNAME("table_hseparation")); + int vseparation = get_theme_constant(SNAME("table_vseparation")); int col_count = table->columns.size(); for (int i = 0; i < col_count; i++) { @@ -238,9 +238,9 @@ void RichTextLabel::_resize_line(ItemFrame *p_frame, int p_line, const Ref<Font> } int idx = 0; - for (List<Item *>::Element *E = table->subitems.front(); E; E = E->next()) { - ERR_CONTINUE(E->get()->type != ITEM_FRAME); // Children should all be frames. - ItemFrame *frame = static_cast<ItemFrame *>(E->get()); + for (Item *E : table->subitems) { + ERR_CONTINUE(E->type != ITEM_FRAME); // Children should all be frames. + ItemFrame *frame = static_cast<ItemFrame *>(E); for (int i = 0; i < frame->lines.size(); i++) { _resize_line(frame, i, p_base_font, p_base_font_size, 1); } @@ -316,9 +316,9 @@ void RichTextLabel::_resize_line(ItemFrame *p_frame, int p_line, const Ref<Font> Vector2 offset; float row_height = 0.0; - for (List<Item *>::Element *E = table->subitems.front(); E; E = E->next()) { - ERR_CONTINUE(E->get()->type != ITEM_FRAME); // Children should all be frames. - ItemFrame *frame = static_cast<ItemFrame *>(E->get()); + for (Item *E : table->subitems) { + ERR_CONTINUE(E->type != ITEM_FRAME); // Children should all be frames. + ItemFrame *frame = static_cast<ItemFrame *>(E); int column = idx % col_count; @@ -458,8 +458,8 @@ void RichTextLabel::_shape_line(ItemFrame *p_frame, int p_line, const Ref<Font> } break; case ITEM_TABLE: { ItemTable *table = static_cast<ItemTable *>(it); - int hseparation = get_theme_constant("table_hseparation"); - int vseparation = get_theme_constant("table_vseparation"); + int hseparation = get_theme_constant(SNAME("table_hseparation")); + int vseparation = get_theme_constant(SNAME("table_vseparation")); int col_count = table->columns.size(); int t_char_count = 0; // Set minimums to zero. @@ -472,9 +472,9 @@ void RichTextLabel::_shape_line(ItemFrame *p_frame, int p_line, const Ref<Font> const int available_width = p_width - hseparation * (col_count - 1); int idx = 0; - for (List<Item *>::Element *E = table->subitems.front(); E; E = E->next()) { - ERR_CONTINUE(E->get()->type != ITEM_FRAME); // Children should all be frames. - ItemFrame *frame = static_cast<ItemFrame *>(E->get()); + for (Item *E : table->subitems) { + ERR_CONTINUE(E->type != ITEM_FRAME); // Children should all be frames. + ItemFrame *frame = static_cast<ItemFrame *>(E); int column = idx % col_count; for (int i = 0; i < frame->lines.size(); i++) { @@ -556,7 +556,7 @@ void RichTextLabel::_shape_line(ItemFrame *p_frame, int p_line, const Ref<Font> Vector2 offset; float row_height = 0.0; - for (List<Item *>::Element *E = table->subitems.front(); E; E = E->next()) { + for (const List<Item *>::Element *E = table->subitems.front(); E; E = E->next()) { ERR_CONTINUE(E->get()->type != ITEM_FRAME); // Children should all be frames. ItemFrame *frame = static_cast<ItemFrame *>(E->get()); @@ -672,11 +672,11 @@ int RichTextLabel::_draw_line(ItemFrame *p_frame, int p_line, const Vector2 &p_o if (prefix != "") { Ref<Font> font = _find_font(l.from); if (font.is_null()) { - font = get_theme_font("normal_font"); + font = get_theme_font(SNAME("normal_font")); } int font_size = _find_font_size(l.from); if (font_size == -1) { - font_size = get_theme_font_size("normal_font_size"); + font_size = get_theme_font_size(SNAME("normal_font_size")); } if (rtl) { float offx = 0.0f; @@ -775,16 +775,16 @@ int RichTextLabel::_draw_line(ItemFrame *p_frame, int p_line, const Vector2 &p_o } break; case ITEM_TABLE: { ItemTable *table = static_cast<ItemTable *>(it); - Color odd_row_bg = get_theme_color("table_odd_row_bg"); - Color even_row_bg = get_theme_color("table_even_row_bg"); - Color border = get_theme_color("table_border"); - int hseparation = get_theme_constant("table_hseparation"); + Color odd_row_bg = get_theme_color(SNAME("table_odd_row_bg")); + Color even_row_bg = get_theme_color(SNAME("table_even_row_bg")); + Color border = get_theme_color(SNAME("table_border")); + int hseparation = get_theme_constant(SNAME("table_hseparation")); int col_count = table->columns.size(); int row_count = table->rows.size(); int idx = 0; - for (List<Item *>::Element *E = table->subitems.front(); E; E = E->next()) { - ItemFrame *frame = static_cast<ItemFrame *>(E->get()); + for (Item *E : table->subitems) { + ItemFrame *frame = static_cast<ItemFrame *>(E); int col = idx % col_count; int row = idx / col_count; @@ -916,7 +916,7 @@ int RichTextLabel::_draw_line(ItemFrame *p_frame, int p_line, const Vector2 &p_o } } - Point2 shadow_ofs(get_theme_constant("shadow_offset_x"), get_theme_constant("shadow_offset_y")); + Point2 shadow_ofs(get_theme_constant(SNAME("shadow_offset_x")), get_theme_constant(SNAME("shadow_offset_y"))); // Draw glyph outlines. for (int j = 0; j < glyphs[i].repeat; j++) { @@ -940,8 +940,8 @@ int RichTextLabel::_draw_line(ItemFrame *p_frame, int p_line, const Vector2 &p_o _draw_fbg_boxes(ci, rid, fbg_line_off, it_from, it_to, chr_range.x, chr_range.y, 0); // Draw main text. - Color selection_fg = get_theme_color("font_selected_color"); - Color selection_bg = get_theme_color("selection_color"); + Color selection_fg = get_theme_color(SNAME("font_selected_color")); + Color selection_bg = get_theme_color(SNAME("selection_color")); int sel_start = -1; int sel_end = -1; @@ -1192,8 +1192,8 @@ float RichTextLabel::_find_click_in_line(ItemFrame *p_frame, int p_line, const V if (rect.has_point(p_click - p_ofs - off)) { switch (it->type) { case ITEM_TABLE: { - int hseparation = get_theme_constant("table_hseparation"); - int vseparation = get_theme_constant("table_vseparation"); + int hseparation = get_theme_constant(SNAME("table_hseparation")); + int vseparation = get_theme_constant(SNAME("table_vseparation")); ItemTable *table = static_cast<ItemTable *>(it); @@ -1203,8 +1203,8 @@ float RichTextLabel::_find_click_in_line(ItemFrame *p_frame, int p_line, const V int col_count = table->columns.size(); int row_count = table->rows.size(); - for (List<Item *>::Element *E = table->subitems.front(); E; E = E->next()) { - ItemFrame *frame = static_cast<ItemFrame *>(E->get()); + for (Item *E : table->subitems) { + ItemFrame *frame = static_cast<ItemFrame *>(E); int col = idx % col_count; int row = idx / col_count; @@ -1362,7 +1362,7 @@ void RichTextLabel::_notification(int p_what) { case NOTIFICATION_MOUSE_EXIT: { if (meta_hovering) { meta_hovering = nullptr; - emit_signal("meta_hover_ended", current_meta); + emit_signal(SNAME("meta_hover_ended"), current_meta); current_meta = false; update(); } @@ -1395,11 +1395,11 @@ void RichTextLabel::_notification(int p_what) { Size2 size = get_size(); Rect2 text_rect = _get_text_rect(); - draw_style_box(get_theme_stylebox("normal"), Rect2(Point2(), size)); + draw_style_box(get_theme_stylebox(SNAME("normal")), Rect2(Point2(), size)); if (has_focus()) { RenderingServer::get_singleton()->canvas_item_add_clip_ignore(ci, true); - draw_style_box(get_theme_stylebox("focus"), Rect2(Point2(), size)); + draw_style_box(get_theme_stylebox(SNAME("focus")), Rect2(Point2(), size)); RenderingServer::get_singleton()->canvas_item_add_clip_ignore(ci, false); } @@ -1419,13 +1419,13 @@ void RichTextLabel::_notification(int p_what) { if (from_line >= main->lines.size()) { break; //nothing to draw } - Ref<Font> base_font = get_theme_font("normal_font"); - Color base_color = get_theme_color("default_color"); - Color outline_color = get_theme_color("font_outline_color"); - int outline_size = get_theme_constant("outline_size"); - Color font_shadow_color = get_theme_color("font_shadow_color"); - bool use_outline = get_theme_constant("shadow_as_outline"); - Point2 shadow_ofs(get_theme_constant("shadow_offset_x"), get_theme_constant("shadow_offset_y")); + Ref<Font> base_font = get_theme_font(SNAME("normal_font")); + Color base_color = get_theme_color(SNAME("default_color")); + Color outline_color = get_theme_color(SNAME("font_outline_color")); + int outline_size = get_theme_constant(SNAME("outline_size")); + Color font_shadow_color = get_theme_color(SNAME("font_shadow_color")); + bool use_outline = get_theme_constant(SNAME("shadow_as_outline")); + Point2 shadow_ofs(get_theme_constant(SNAME("shadow_offset_x")), get_theme_constant(SNAME("shadow_offset_y"))); visible_paragraph_count = 0; visible_line_count = 0; @@ -1568,7 +1568,7 @@ void RichTextLabel::_gui_input(Ref<InputEvent> p_event) { Variant meta; if (!outside && _find_meta(c_item, &meta)) { //meta clicked - emit_signal("meta_clicked", meta); + emit_signal(SNAME("meta_clicked"), meta); } } } @@ -1611,11 +1611,11 @@ void RichTextLabel::_gui_input(Ref<InputEvent> p_event) { handled = true; } if (k->is_action("ui_up") && vscroll->is_visible_in_tree()) { - vscroll->set_value(vscroll->get_value() - get_theme_font("normal_font")->get_height(get_theme_font_size("normal_font_size"))); + vscroll->set_value(vscroll->get_value() - get_theme_font(SNAME("normal_font"))->get_height(get_theme_font_size(SNAME("normal_font_size")))); handled = true; } if (k->is_action("ui_down") && vscroll->is_visible_in_tree()) { - vscroll->set_value(vscroll->get_value() + get_theme_font("normal_font")->get_height(get_theme_font_size("normal_font_size"))); + vscroll->set_value(vscroll->get_value() + get_theme_font(SNAME("normal_font"))->get_height(get_theme_font_size(SNAME("normal_font_size")))); handled = true; } if (k->is_action("ui_home") && vscroll->is_visible_in_tree()) { @@ -1693,15 +1693,15 @@ void RichTextLabel::_gui_input(Ref<InputEvent> p_event) { if (c_item && !outside && _find_meta(c_item, &meta, &item_meta)) { if (meta_hovering != item_meta) { if (meta_hovering) { - emit_signal("meta_hover_ended", current_meta); + emit_signal(SNAME("meta_hover_ended"), current_meta); } meta_hovering = item_meta; current_meta = meta; - emit_signal("meta_hover_started", meta); + emit_signal(SNAME("meta_hover_started"), meta); } } else if (meta_hovering) { meta_hovering = nullptr; - emit_signal("meta_hover_ended", current_meta); + emit_signal(SNAME("meta_hover_ended"), current_meta); current_meta = false; } } @@ -2080,8 +2080,8 @@ bool RichTextLabel::_find_layout_subitem(Item *from, Item *to) { return true; } - for (List<Item *>::Element *E = from->subitems.front(); E; E = E->next()) { - bool layout = _find_layout_subitem(E->get(), to); + for (Item *E : from->subitems) { + bool layout = _find_layout_subitem(E, to); if (layout) { return true; @@ -2105,8 +2105,8 @@ void RichTextLabel::_validate_line_caches(ItemFrame *p_frame) { } Rect2 text_rect = _get_text_rect(); - Ref<Font> base_font = get_theme_font("normal_font"); - int base_font_size = get_theme_font_size("normal_font_size"); + Ref<Font> base_font = get_theme_font(SNAME("normal_font")); + int base_font_size = get_theme_font_size(SNAME("normal_font_size")); for (int i = p_frame->first_resized_line; i < p_frame->lines.size(); i++) { _resize_line(p_frame, i, base_font, base_font_size, text_rect.get_size().width - scroll_w); @@ -2140,8 +2140,8 @@ void RichTextLabel::_validate_line_caches(ItemFrame *p_frame) { } Rect2 text_rect = _get_text_rect(); - Ref<Font> base_font = get_theme_font("normal_font"); - int base_font_size = get_theme_font_size("normal_font_size"); + Ref<Font> base_font = get_theme_font(SNAME("normal_font")); + int base_font_size = get_theme_font_size(SNAME("normal_font_size")); int total_chars = (p_frame->first_invalid_line == 0) ? 0 : (p_frame->lines[p_frame->first_invalid_line].char_offset + p_frame->lines[p_frame->first_invalid_line].char_count); for (int i = p_frame->first_invalid_line; i < p_frame->lines.size(); i++) { @@ -2406,35 +2406,35 @@ void RichTextLabel::push_font(const Ref<Font> &p_font) { } void RichTextLabel::push_normal() { - Ref<Font> normal_font = get_theme_font("normal_font"); + Ref<Font> normal_font = get_theme_font(SNAME("normal_font")); ERR_FAIL_COND(normal_font.is_null()); push_font(normal_font); } void RichTextLabel::push_bold() { - Ref<Font> bold_font = get_theme_font("bold_font"); + Ref<Font> bold_font = get_theme_font(SNAME("bold_font")); ERR_FAIL_COND(bold_font.is_null()); push_font(bold_font); } void RichTextLabel::push_bold_italics() { - Ref<Font> bold_italics_font = get_theme_font("bold_italics_font"); + Ref<Font> bold_italics_font = get_theme_font(SNAME("bold_italics_font")); ERR_FAIL_COND(bold_italics_font.is_null()); push_font(bold_italics_font); } void RichTextLabel::push_italics() { - Ref<Font> italics_font = get_theme_font("italics_font"); + Ref<Font> italics_font = get_theme_font(SNAME("italics_font")); ERR_FAIL_COND(italics_font.is_null()); push_font(italics_font); } void RichTextLabel::push_mono() { - Ref<Font> mono_font = get_theme_font("mono_font"); + Ref<Font> mono_font = get_theme_font(SNAME("mono_font")); ERR_FAIL_COND(mono_font.is_null()); push_font(mono_font); @@ -2774,13 +2774,13 @@ Error RichTextLabel::append_bbcode(const String &p_bbcode) { int pos = 0; List<String> tag_stack; - Ref<Font> normal_font = get_theme_font("normal_font"); - Ref<Font> bold_font = get_theme_font("bold_font"); - Ref<Font> italics_font = get_theme_font("italics_font"); - Ref<Font> bold_italics_font = get_theme_font("bold_italics_font"); - Ref<Font> mono_font = get_theme_font("mono_font"); + Ref<Font> normal_font = get_theme_font(SNAME("normal_font")); + Ref<Font> bold_font = get_theme_font(SNAME("bold_font")); + Ref<Font> italics_font = get_theme_font(SNAME("italics_font")); + Ref<Font> bold_italics_font = get_theme_font(SNAME("bold_italics_font")); + Ref<Font> mono_font = get_theme_font(SNAME("mono_font")); - Color base_color = get_theme_color("default_color"); + Color base_color = get_theme_color(SNAME("default_color")); int indent_level = 0; @@ -3140,11 +3140,11 @@ Error RichTextLabel::append_bbcode(const String &p_bbcode) { tag_stack.push_front("url"); } else if (tag.begins_with("dropcap")) { Vector<String> subtag = tag.substr(5, tag.length()).split(" "); - Ref<Font> f = get_theme_font("normal_font"); - int fs = get_theme_font_size("normal_font_size") * 3; - Color color = get_theme_color("default_color"); - Color outline_color = get_theme_color("outline_color"); - int outline_size = get_theme_constant("outline_size"); + Ref<Font> f = get_theme_font(SNAME("normal_font")); + int fs = get_theme_font_size(SNAME("normal_font_size")) * 3; + Color color = get_theme_color(SNAME("default_color")); + Color outline_color = get_theme_color(SNAME("outline_color")); + int outline_size = get_theme_constant(SNAME("outline_size")); Rect2 dropcap_margins = Rect2(); for (int i = 0; i < subtag.size(); i++) { @@ -3448,8 +3448,8 @@ Error RichTextLabel::append_bbcode(const String &p_bbcode) { } Vector<ItemFX *> fx_items; - for (List<Item *>::Element *E = main->subitems.front(); E; E = E->next()) { - Item *subitem = static_cast<Item *>(E->get()); + for (Item *E : main->subitems) { + Item *subitem = static_cast<Item *>(E); _fetch_item_fx_stack(subitem, fx_items); if (fx_items.size()) { @@ -3719,9 +3719,9 @@ String RichTextLabel::_get_line_text(ItemFrame *p_frame, int p_line, Selection p ItemTable *table = static_cast<ItemTable *>(it); int idx = 0; int col_count = table->columns.size(); - for (List<Item *>::Element *E = table->subitems.front(); E; E = E->next()) { - ERR_CONTINUE(E->get()->type != ITEM_FRAME); // Children should all be frames. - ItemFrame *frame = static_cast<ItemFrame *>(E->get()); + for (Item *E : table->subitems) { + ERR_CONTINUE(E->type != ITEM_FRAME); // Children should all be frames. + ItemFrame *frame = static_cast<ItemFrame *>(E); int column = idx % col_count; for (int i = 0; i < frame->lines.size(); i++) { @@ -4168,7 +4168,7 @@ void RichTextLabel::set_fixed_size_to_width(int p_width) { } Size2 RichTextLabel::get_minimum_size() const { - Ref<StyleBox> style = get_theme_stylebox("normal"); + Ref<StyleBox> style = get_theme_stylebox(SNAME("normal")); Size2 size = style->get_minimum_size(); if (fixed_width != -1) { diff --git a/scene/gui/scroll_bar.cpp b/scene/gui/scroll_bar.cpp index 62276e3af0..ce04a0204b 100644 --- a/scene/gui/scroll_bar.cpp +++ b/scene/gui/scroll_bar.cpp @@ -46,7 +46,7 @@ void ScrollBar::_gui_input(Ref<InputEvent> p_event) { Ref<InputEventMouseMotion> m = p_event; if (!m.is_valid() || drag.active) { - emit_signal("scrolling"); + emit_signal(SNAME("scrolling")); } Ref<InputEventMouseButton> b = p_event; @@ -70,8 +70,8 @@ void ScrollBar::_gui_input(Ref<InputEvent> p_event) { if (b->is_pressed()) { double ofs = orientation == VERTICAL ? b->get_position().y : b->get_position().x; - Ref<Texture2D> decr = get_theme_icon("decrement"); - Ref<Texture2D> incr = get_theme_icon("increment"); + Ref<Texture2D> decr = get_theme_icon(SNAME("decrement")); + Ref<Texture2D> incr = get_theme_icon(SNAME("increment")); double decr_size = orientation == VERTICAL ? decr->get_height() : decr->get_width(); double incr_size = orientation == VERTICAL ? incr->get_height() : incr->get_width(); @@ -140,7 +140,7 @@ void ScrollBar::_gui_input(Ref<InputEvent> p_event) { if (drag.active) { double ofs = orientation == VERTICAL ? m->get_position().y : m->get_position().x; - Ref<Texture2D> decr = get_theme_icon("decrement"); + Ref<Texture2D> decr = get_theme_icon(SNAME("decrement")); double decr_size = orientation == VERTICAL ? decr->get_height() : decr->get_width(); ofs -= decr_size; @@ -150,8 +150,8 @@ void ScrollBar::_gui_input(Ref<InputEvent> p_event) { set_as_ratio(drag.value_at_click + diff); } else { double ofs = orientation == VERTICAL ? m->get_position().y : m->get_position().x; - Ref<Texture2D> decr = get_theme_icon("decrement"); - Ref<Texture2D> incr = get_theme_icon("increment"); + Ref<Texture2D> decr = get_theme_icon(SNAME("decrement")); + Ref<Texture2D> incr = get_theme_icon(SNAME("increment")); double decr_size = orientation == VERTICAL ? decr->get_height() : decr->get_width(); double incr_size = orientation == VERTICAL ? incr->get_height() : incr->get_width(); @@ -215,17 +215,17 @@ void ScrollBar::_notification(int p_what) { if (p_what == NOTIFICATION_DRAW) { RID ci = get_canvas_item(); - Ref<Texture2D> decr = highlight == HIGHLIGHT_DECR ? get_theme_icon("decrement_highlight") : get_theme_icon("decrement"); - Ref<Texture2D> incr = highlight == HIGHLIGHT_INCR ? get_theme_icon("increment_highlight") : get_theme_icon("increment"); - Ref<StyleBox> bg = has_focus() ? get_theme_stylebox("scroll_focus") : get_theme_stylebox("scroll"); + Ref<Texture2D> decr = highlight == HIGHLIGHT_DECR ? get_theme_icon(SNAME("decrement_highlight")) : get_theme_icon(SNAME("decrement")); + Ref<Texture2D> incr = highlight == HIGHLIGHT_INCR ? get_theme_icon(SNAME("increment_highlight")) : get_theme_icon(SNAME("increment")); + Ref<StyleBox> bg = has_focus() ? get_theme_stylebox(SNAME("scroll_focus")) : get_theme_stylebox(SNAME("scroll")); Ref<StyleBox> grabber; if (drag.active) { - grabber = get_theme_stylebox("grabber_pressed"); + grabber = get_theme_stylebox(SNAME("grabber_pressed")); } else if (highlight == HIGHLIGHT_RANGE) { - grabber = get_theme_stylebox("grabber_highlight"); + grabber = get_theme_stylebox(SNAME("grabber_highlight")); } else { - grabber = get_theme_stylebox("grabber"); + grabber = get_theme_stylebox(SNAME("grabber")); } Point2 ofs; @@ -389,7 +389,7 @@ void ScrollBar::_notification(int p_what) { } double ScrollBar::get_grabber_min_size() const { - Ref<StyleBox> grabber = get_theme_stylebox("grabber"); + Ref<StyleBox> grabber = get_theme_stylebox(SNAME("grabber")); Size2 gminsize = grabber->get_minimum_size() + grabber->get_center_size(); return (orientation == VERTICAL) ? gminsize.height : gminsize.width; } @@ -415,17 +415,17 @@ double ScrollBar::get_area_size() const { switch (orientation) { case VERTICAL: { double area = get_size().height; - area -= get_theme_stylebox("scroll")->get_minimum_size().height; - area -= get_theme_icon("increment")->get_height(); - area -= get_theme_icon("decrement")->get_height(); + area -= get_theme_stylebox(SNAME("scroll"))->get_minimum_size().height; + area -= get_theme_icon(SNAME("increment"))->get_height(); + area -= get_theme_icon(SNAME("decrement"))->get_height(); area -= get_grabber_min_size(); return area; } break; case HORIZONTAL: { double area = get_size().width; - area -= get_theme_stylebox("scroll")->get_minimum_size().width; - area -= get_theme_icon("increment")->get_width(); - area -= get_theme_icon("decrement")->get_width(); + area -= get_theme_stylebox(SNAME("scroll"))->get_minimum_size().width; + area -= get_theme_icon(SNAME("increment"))->get_width(); + area -= get_theme_icon(SNAME("decrement"))->get_width(); area -= get_grabber_min_size(); return area; } break; @@ -439,13 +439,13 @@ double ScrollBar::get_area_offset() const { double ofs = 0.0; if (orientation == VERTICAL) { - ofs += get_theme_stylebox("hscroll")->get_margin(SIDE_TOP); - ofs += get_theme_icon("decrement")->get_height(); + ofs += get_theme_stylebox(SNAME("hscroll"))->get_margin(SIDE_TOP); + ofs += get_theme_icon(SNAME("decrement"))->get_height(); } if (orientation == HORIZONTAL) { - ofs += get_theme_stylebox("hscroll")->get_margin(SIDE_LEFT); - ofs += get_theme_icon("decrement")->get_width(); + ofs += get_theme_stylebox(SNAME("hscroll"))->get_margin(SIDE_LEFT); + ofs += get_theme_icon(SNAME("decrement"))->get_width(); } return ofs; @@ -456,9 +456,9 @@ double ScrollBar::get_grabber_offset() const { } Size2 ScrollBar::get_minimum_size() const { - Ref<Texture2D> incr = get_theme_icon("increment"); - Ref<Texture2D> decr = get_theme_icon("decrement"); - Ref<StyleBox> bg = get_theme_stylebox("scroll"); + Ref<Texture2D> incr = get_theme_icon(SNAME("increment")); + Ref<Texture2D> decr = get_theme_icon(SNAME("decrement")); + Ref<StyleBox> bg = get_theme_stylebox(SNAME("scroll")); Size2 minsize; if (orientation == VERTICAL) { diff --git a/scene/gui/scroll_container.cpp b/scene/gui/scroll_container.cpp index 177f146b6a..eb5fc924da 100644 --- a/scene/gui/scroll_container.cpp +++ b/scene/gui/scroll_container.cpp @@ -33,7 +33,7 @@ #include "scene/main/window.h" Size2 ScrollContainer::get_minimum_size() const { - Ref<StyleBox> sb = get_theme_stylebox("bg"); + Ref<StyleBox> sb = get_theme_stylebox(SNAME("bg")); Size2 min_size; for (int i = 0; i < get_child_count(); i++) { @@ -77,7 +77,7 @@ void ScrollContainer::_cancel_drag() { drag_from = Vector2(); if (beyond_deadzone) { - emit_signal("scroll_ended"); + emit_signal(SNAME("scroll_ended")); propagate_notification(NOTIFICATION_SCROLL_END); beyond_deadzone = false; } @@ -173,7 +173,7 @@ void ScrollContainer::_gui_input(const Ref<InputEvent> &p_gui_input) { if (beyond_deadzone || (scroll_h && Math::abs(drag_accum.x) > deadzone) || (scroll_v && Math::abs(drag_accum.y) > deadzone)) { if (!beyond_deadzone) { propagate_notification(NOTIFICATION_SCROLL_BEGIN); - emit_signal("scroll_started"); + emit_signal(SNAME("scroll_started")); beyond_deadzone = true; // resetting drag_accum here ensures smooth scrolling after reaching deadzone @@ -260,7 +260,7 @@ void ScrollContainer::_update_dimensions() { Size2 size = get_size(); Point2 ofs; - Ref<StyleBox> sb = get_theme_stylebox("bg"); + Ref<StyleBox> sb = get_theme_stylebox(SNAME("bg")); size -= sb->get_minimum_size(); ofs += sb->get_offset(); bool rtl = is_layout_rtl(); @@ -319,7 +319,7 @@ void ScrollContainer::_update_dimensions() { void ScrollContainer::_notification(int p_what) { if (p_what == NOTIFICATION_ENTER_TREE || p_what == NOTIFICATION_THEME_CHANGED || p_what == NOTIFICATION_LAYOUT_DIRECTION_CHANGED || p_what == NOTIFICATION_TRANSLATION_CHANGED) { _updating_scrollbars = true; - call_deferred("_update_scrollbar_position"); + call_deferred(SNAME("_update_scrollbar_position")); }; if (p_what == NOTIFICATION_READY) { @@ -332,7 +332,7 @@ void ScrollContainer::_notification(int p_what) { }; if (p_what == NOTIFICATION_DRAW) { - Ref<StyleBox> sb = get_theme_stylebox("bg"); + Ref<StyleBox> sb = get_theme_stylebox(SNAME("bg")); draw_style_box(sb, Rect2(Vector2(), get_size())); update_scrollbars(); @@ -409,7 +409,7 @@ void ScrollContainer::_notification(int p_what) { void ScrollContainer::update_scrollbars() { Size2 size = get_size(); - Ref<StyleBox> sb = get_theme_stylebox("bg"); + Ref<StyleBox> sb = get_theme_stylebox(SNAME("bg")); size -= sb->get_minimum_size(); Size2 hmin; diff --git a/scene/gui/separator.cpp b/scene/gui/separator.cpp index 3cb8ccf135..1f3cb7aa24 100644 --- a/scene/gui/separator.cpp +++ b/scene/gui/separator.cpp @@ -33,9 +33,9 @@ Size2 Separator::get_minimum_size() const { Size2 ms(3, 3); if (orientation == VERTICAL) { - ms.x = get_theme_constant("separation"); + ms.x = get_theme_constant(SNAME("separation")); } else { // HORIZONTAL - ms.y = get_theme_constant("separation"); + ms.y = get_theme_constant(SNAME("separation")); } return ms; } @@ -44,7 +44,7 @@ void Separator::_notification(int p_what) { switch (p_what) { case NOTIFICATION_DRAW: { Size2i size = get_size(); - Ref<StyleBox> style = get_theme_stylebox("separator"); + Ref<StyleBox> style = get_theme_stylebox(SNAME("separator")); Size2i ssize = style->get_minimum_size() + style->get_center_size(); if (orientation == VERTICAL) { diff --git a/scene/gui/slider.cpp b/scene/gui/slider.cpp index 5947f3b99e..61b5325175 100644 --- a/scene/gui/slider.cpp +++ b/scene/gui/slider.cpp @@ -32,10 +32,10 @@ #include "core/os/keyboard.h" Size2 Slider::get_minimum_size() const { - Ref<StyleBox> style = get_theme_stylebox("slider"); + Ref<StyleBox> style = get_theme_stylebox(SNAME("slider")); Size2i ss = style->get_minimum_size() + style->get_center_size(); - Ref<Texture2D> grabber = get_theme_icon("grabber"); + Ref<Texture2D> grabber = get_theme_icon(SNAME("grabber")); Size2i rs = grabber->get_size(); if (orientation == HORIZONTAL) { @@ -89,7 +89,7 @@ void Slider::_gui_input(Ref<InputEvent> p_event) { if (mm.is_valid()) { if (grab.active) { Size2i size = get_size(); - Ref<Texture2D> grabber = get_theme_icon("grabber"); + Ref<Texture2D> grabber = get_theme_icon(SNAME("grabber")); float motion = (orientation == VERTICAL ? mm->get_position().y : mm->get_position().x) - grab.pos; if (orientation == VERTICAL) { motion = -motion; @@ -161,11 +161,11 @@ void Slider::_notification(int p_what) { case NOTIFICATION_DRAW: { RID ci = get_canvas_item(); Size2i size = get_size(); - Ref<StyleBox> style = get_theme_stylebox("slider"); + Ref<StyleBox> style = get_theme_stylebox(SNAME("slider")); bool highlighted = mouse_inside || has_focus(); Ref<StyleBox> grabber_area = get_theme_stylebox(highlighted ? "grabber_area_highlight" : "grabber_area"); Ref<Texture2D> grabber = get_theme_icon(editable ? (highlighted ? "grabber_highlight" : "grabber") : "grabber_disabled"); - Ref<Texture2D> tick = get_theme_icon("tick"); + Ref<Texture2D> tick = get_theme_icon(SNAME("tick")); double ratio = Math::is_nan(get_as_ratio()) ? 0 : get_as_ratio(); if (orientation == VERTICAL) { diff --git a/scene/gui/spin_box.cpp b/scene/gui/spin_box.cpp index 941dd30057..3f0368a4e2 100644 --- a/scene/gui/spin_box.cpp +++ b/scene/gui/spin_box.cpp @@ -170,7 +170,7 @@ void SpinBox::_gui_input(const Ref<InputEvent> &p_event) { void SpinBox::_line_edit_focus_exit() { // discontinue because the focus_exit was caused by right-click context menu - if (line_edit->get_menu()->is_visible()) { + if (line_edit->is_menu_visible()) { return; } @@ -188,7 +188,7 @@ inline void SpinBox::_adjust_width_for_icon(const Ref<Texture2D> &icon) { void SpinBox::_notification(int p_what) { if (p_what == NOTIFICATION_DRAW) { - Ref<Texture2D> updown = get_theme_icon("updown"); + Ref<Texture2D> updown = get_theme_icon(SNAME("updown")); _adjust_width_for_icon(updown); @@ -204,15 +204,15 @@ void SpinBox::_notification(int p_what) { } else if (p_what == NOTIFICATION_FOCUS_EXIT) { //_value_changed(0); } else if (p_what == NOTIFICATION_ENTER_TREE) { - _adjust_width_for_icon(get_theme_icon("updown")); + _adjust_width_for_icon(get_theme_icon(SNAME("updown"))); _value_changed(0); } else if (p_what == NOTIFICATION_EXIT_TREE) { _release_mouse(); } else if (p_what == NOTIFICATION_TRANSLATION_CHANGED) { _value_changed(0); } else if (p_what == NOTIFICATION_THEME_CHANGED) { - call_deferred("minimum_size_changed"); - get_line_edit()->call_deferred("minimum_size_changed"); + call_deferred(SNAME("minimum_size_changed")); + get_line_edit()->call_deferred(SNAME("minimum_size_changed")); } else if (p_what == NOTIFICATION_LAYOUT_DIRECTION_CHANGED || p_what == NOTIFICATION_TRANSLATION_CHANGED) { update(); } diff --git a/scene/gui/split_container.cpp b/scene/gui/split_container.cpp index 9796b32c6b..3114e5b7c0 100644 --- a/scene/gui/split_container.cpp +++ b/scene/gui/split_container.cpp @@ -76,8 +76,8 @@ void SplitContainer::_resort() { bool second_expanded = (vertical ? second->get_v_size_flags() : second->get_h_size_flags()) & SIZE_EXPAND; // Determine the separation between items - Ref<Texture2D> g = get_theme_icon("grabber"); - int sep = get_theme_constant("separation"); + Ref<Texture2D> g = get_theme_icon(SNAME("grabber")); + int sep = get_theme_constant(SNAME("separation")); sep = (dragger_visibility != DRAGGER_HIDDEN_COLLAPSED) ? MAX(sep, vertical ? g->get_height() : g->get_width()) : 0; // Compute the minimum size @@ -131,8 +131,8 @@ Size2 SplitContainer::get_minimum_size() const { /* Calculate MINIMUM SIZE */ Size2i minimum; - Ref<Texture2D> g = get_theme_icon("grabber"); - int sep = get_theme_constant("separation"); + Ref<Texture2D> g = get_theme_icon(SNAME("grabber")); + int sep = get_theme_constant(SNAME("separation")); sep = (dragger_visibility != DRAGGER_HIDDEN_COLLAPSED) ? MAX(sep, vertical ? g->get_height() : g->get_width()) : 0; for (int i = 0; i < 2; i++) { @@ -173,7 +173,7 @@ void SplitContainer::_notification(int p_what) { } break; case NOTIFICATION_MOUSE_EXIT: { mouse_inside = false; - if (get_theme_constant("autohide")) { + if (get_theme_constant(SNAME("autohide"))) { update(); } } break; @@ -182,7 +182,7 @@ void SplitContainer::_notification(int p_what) { return; } - if (collapsed || (!dragging && !mouse_inside && get_theme_constant("autohide"))) { + if (collapsed || (!dragging && !mouse_inside && get_theme_constant(SNAME("autohide")))) { return; } @@ -190,8 +190,8 @@ void SplitContainer::_notification(int p_what) { return; } - int sep = dragger_visibility != DRAGGER_HIDDEN_COLLAPSED ? get_theme_constant("separation") : 0; - Ref<Texture2D> tex = get_theme_icon("grabber"); + int sep = dragger_visibility != DRAGGER_HIDDEN_COLLAPSED ? get_theme_constant(SNAME("separation")) : 0; + Ref<Texture2D> tex = get_theme_icon(SNAME("grabber")); Size2 size = get_size(); if (vertical) { @@ -218,7 +218,7 @@ void SplitContainer::_gui_input(const Ref<InputEvent> &p_event) { if (mb.is_valid()) { if (mb->get_button_index() == MOUSE_BUTTON_LEFT) { if (mb->is_pressed()) { - int sep = get_theme_constant("separation"); + int sep = get_theme_constant(SNAME("separation")); if (vertical) { if (mb->get_position().y > middle_sep && mb->get_position().y < middle_sep + sep) { @@ -244,14 +244,14 @@ void SplitContainer::_gui_input(const Ref<InputEvent> &p_event) { if (mm.is_valid()) { bool mouse_inside_state = false; if (vertical) { - mouse_inside_state = mm->get_position().y > middle_sep && mm->get_position().y < middle_sep + get_theme_constant("separation"); + mouse_inside_state = mm->get_position().y > middle_sep && mm->get_position().y < middle_sep + get_theme_constant(SNAME("separation")); } else { - mouse_inside_state = mm->get_position().x > middle_sep && mm->get_position().x < middle_sep + get_theme_constant("separation"); + mouse_inside_state = mm->get_position().x > middle_sep && mm->get_position().x < middle_sep + get_theme_constant(SNAME("separation")); } if (mouse_inside != mouse_inside_state) { mouse_inside = mouse_inside_state; - if (get_theme_constant("autohide")) { + if (get_theme_constant(SNAME("autohide"))) { update(); } } @@ -267,7 +267,7 @@ void SplitContainer::_gui_input(const Ref<InputEvent> &p_event) { } should_clamp_split_offset = true; queue_sort(); - emit_signal("dragged", get_split_offset()); + emit_signal(SNAME("dragged"), get_split_offset()); } } @@ -277,7 +277,7 @@ Control::CursorShape SplitContainer::get_cursor_shape(const Point2 &p_pos) const } if (!collapsed && _getch(0) && _getch(1) && dragger_visibility == DRAGGER_VISIBLE) { - int sep = get_theme_constant("separation"); + int sep = get_theme_constant(SNAME("separation")); if (vertical) { if (p_pos.y > middle_sep && p_pos.y < middle_sep + sep) { diff --git a/scene/gui/tab_container.cpp b/scene/gui/tab_container.cpp index 133966013b..4b8c4b3e16 100644 --- a/scene/gui/tab_container.cpp +++ b/scene/gui/tab_container.cpp @@ -43,9 +43,9 @@ int TabContainer::_get_top_margin() const { } // Respect the minimum tab height. - Ref<StyleBox> tab_unselected = get_theme_stylebox("tab_unselected"); - Ref<StyleBox> tab_selected = get_theme_stylebox("tab_selected"); - Ref<StyleBox> tab_disabled = get_theme_stylebox("tab_disabled"); + Ref<StyleBox> tab_unselected = get_theme_stylebox(SNAME("tab_unselected")); + Ref<StyleBox> tab_selected = get_theme_stylebox(SNAME("tab_selected")); + Ref<StyleBox> tab_disabled = get_theme_stylebox(SNAME("tab_disabled")); int tab_height = MAX(MAX(tab_unselected->get_minimum_size().height, tab_selected->get_minimum_size().height), tab_disabled->get_minimum_size().height); @@ -88,11 +88,11 @@ void TabContainer::_gui_input(const Ref<InputEvent> &p_event) { } // Handle menu button. - Ref<Texture2D> menu = get_theme_icon("menu"); + Ref<Texture2D> menu = get_theme_icon(SNAME("menu")); if (is_layout_rtl()) { if (popup && pos.x < menu->get_width()) { - emit_signal("pre_popup_pressed"); + emit_signal(SNAME("pre_popup_pressed")); Vector2 popup_pos = get_screen_position(); popup_pos.y += menu->get_height(); @@ -103,7 +103,7 @@ void TabContainer::_gui_input(const Ref<InputEvent> &p_event) { } } else { if (popup && pos.x > size.width - menu->get_width()) { - emit_signal("pre_popup_pressed"); + emit_signal(SNAME("pre_popup_pressed")); Vector2 popup_pos = get_screen_position(); popup_pos.x += size.width - popup->get_size().width; @@ -129,8 +129,8 @@ void TabContainer::_gui_input(const Ref<InputEvent> &p_event) { popup_ofs = menu->get_width(); } - Ref<Texture2D> increment = get_theme_icon("increment"); - Ref<Texture2D> decrement = get_theme_icon("decrement"); + Ref<Texture2D> increment = get_theme_icon(SNAME("increment")); + Ref<Texture2D> decrement = get_theme_icon(SNAME("decrement")); if (is_layout_rtl()) { if (pos.x < popup_ofs + decrement->get_width()) { if (last_tab_cache < tabs.size() - 1) { @@ -203,7 +203,7 @@ void TabContainer::_gui_input(const Ref<InputEvent> &p_event) { return; } - Ref<Texture2D> menu = get_theme_icon("menu"); + Ref<Texture2D> menu = get_theme_icon(SNAME("menu")); if (popup) { if (is_layout_rtl()) { if (pos.x <= menu->get_width()) { @@ -248,8 +248,8 @@ void TabContainer::_gui_input(const Ref<InputEvent> &p_event) { popup_ofs = menu->get_width(); } - Ref<Texture2D> increment = get_theme_icon("increment"); - Ref<Texture2D> decrement = get_theme_icon("decrement"); + Ref<Texture2D> increment = get_theme_icon(SNAME("increment")); + Ref<Texture2D> decrement = get_theme_icon(SNAME("decrement")); if (is_layout_rtl()) { if (pos.x <= popup_ofs + decrement->get_width()) { @@ -289,10 +289,10 @@ void TabContainer::_notification(int p_what) { switch (p_what) { case NOTIFICATION_RESIZED: { Vector<Control *> tabs = _get_tabs(); - int side_margin = get_theme_constant("side_margin"); - Ref<Texture2D> menu = get_theme_icon("menu"); - Ref<Texture2D> increment = get_theme_icon("increment"); - Ref<Texture2D> decrement = get_theme_icon("decrement"); + int side_margin = get_theme_constant(SNAME("side_margin")); + Ref<Texture2D> menu = get_theme_icon(SNAME("menu")); + Ref<Texture2D> increment = get_theme_icon(SNAME("increment")); + Ref<Texture2D> decrement = get_theme_icon(SNAME("decrement")); int header_width = get_size().width - side_margin * 2; // Find the width of the header area. @@ -332,26 +332,26 @@ void TabContainer::_notification(int p_what) { bool rtl = is_layout_rtl(); // Draw only the tab area if the header is hidden. - Ref<StyleBox> panel = get_theme_stylebox("panel"); + Ref<StyleBox> panel = get_theme_stylebox(SNAME("panel")); if (!tabs_visible) { panel->draw(canvas, Rect2(0, 0, size.width, size.height)); return; } Vector<Control *> tabs = _get_tabs(); - Ref<StyleBox> tab_unselected = get_theme_stylebox("tab_unselected"); - Ref<StyleBox> tab_selected = get_theme_stylebox("tab_selected"); - Ref<StyleBox> tab_disabled = get_theme_stylebox("tab_disabled"); - Ref<Texture2D> increment = get_theme_icon("increment"); - Ref<Texture2D> increment_hl = get_theme_icon("increment_highlight"); - Ref<Texture2D> decrement = get_theme_icon("decrement"); - Ref<Texture2D> decrement_hl = get_theme_icon("decrement_highlight"); - Ref<Texture2D> menu = get_theme_icon("menu"); - Ref<Texture2D> menu_hl = get_theme_icon("menu_highlight"); - Color font_selected_color = get_theme_color("font_selected_color"); - Color font_unselected_color = get_theme_color("font_unselected_color"); - Color font_disabled_color = get_theme_color("font_disabled_color"); - int side_margin = get_theme_constant("side_margin"); + Ref<StyleBox> tab_unselected = get_theme_stylebox(SNAME("tab_unselected")); + Ref<StyleBox> tab_selected = get_theme_stylebox(SNAME("tab_selected")); + Ref<StyleBox> tab_disabled = get_theme_stylebox(SNAME("tab_disabled")); + Ref<Texture2D> increment = get_theme_icon(SNAME("increment")); + Ref<Texture2D> increment_hl = get_theme_icon(SNAME("increment_highlight")); + Ref<Texture2D> decrement = get_theme_icon(SNAME("decrement")); + Ref<Texture2D> decrement_hl = get_theme_icon(SNAME("decrement_highlight")); + Ref<Texture2D> menu = get_theme_icon(SNAME("menu")); + Ref<Texture2D> menu_hl = get_theme_icon(SNAME("menu_highlight")); + Color font_selected_color = get_theme_color(SNAME("font_selected_color")); + Color font_unselected_color = get_theme_color(SNAME("font_unselected_color")); + Color font_disabled_color = get_theme_color(SNAME("font_disabled_color")); + int side_margin = get_theme_constant(SNAME("side_margin")); // Find out start and width of the header area. int header_x = side_margin; @@ -529,7 +529,7 @@ void TabContainer::_notification(int p_what) { text_buf.write[i]->clear(); } _theme_changing = true; - call_deferred("_on_theme_changed"); // Wait until all changed theme. + call_deferred(SNAME("_on_theme_changed")); // Wait until all changed theme. } break; } } @@ -537,10 +537,10 @@ void TabContainer::_notification(int p_what) { void TabContainer::_draw_tab(Ref<StyleBox> &p_tab_style, Color &p_font_color, int p_index, float p_x) { Vector<Control *> tabs = _get_tabs(); RID canvas = get_canvas_item(); - Ref<Font> font = get_theme_font("font"); - Color font_outline_color = get_theme_color("font_outline_color"); - int outline_size = get_theme_constant("outline_size"); - int icon_text_distance = get_theme_constant("icon_separation"); + Ref<Font> font = get_theme_font(SNAME("font")); + Color font_outline_color = get_theme_color(SNAME("font_outline_color")); + int outline_size = get_theme_constant(SNAME("outline_size")); + int icon_text_distance = get_theme_constant(SNAME("icon_separation")); int tab_width = _get_tab_width(p_index); int header_height = _get_top_margin(); @@ -550,7 +550,7 @@ void TabContainer::_draw_tab(Ref<StyleBox> &p_tab_style, Color &p_font_color, in // Draw the tab contents. Control *control = Object::cast_to<Control>(tabs[p_index]); - String text = control->has_meta("_tab_name") ? String(tr(String(control->get_meta("_tab_name")))) : String(tr(control->get_name())); + String text = control->has_meta("_tab_name") ? String(atr(String(control->get_meta("_tab_name")))) : String(atr(control->get_name())); int x_content = tab_rect.position.x + p_tab_style->get_margin(SIDE_LEFT); int top_margin = p_tab_style->get_margin(SIDE_TOP); @@ -580,11 +580,12 @@ void TabContainer::_refresh_texts() { text_buf.clear(); Vector<Control *> tabs = _get_tabs(); bool rtl = is_layout_rtl(); - Ref<Font> font = get_theme_font("font"); - int font_size = get_theme_font_size("font_size"); + Ref<Font> font = get_theme_font(SNAME("font")); + int font_size = get_theme_font_size(SNAME("font_size")); for (int i = 0; i < tabs.size(); i++) { Control *control = Object::cast_to<Control>(tabs[i]); - String text = control->has_meta("_tab_name") ? String(tr(String(control->get_meta("_tab_name")))) : String(tr(control->get_name())); + String text = control->has_meta("_tab_name") ? String(atr(String(control->get_meta("_tab_name")))) : String(atr(control->get_name())); + Ref<TextLine> name; name.instantiate(); name->set_direction(rtl ? TextServer::DIRECTION_RTL : TextServer::DIRECTION_LTR); @@ -609,7 +610,7 @@ void TabContainer::_on_theme_changed() { } void TabContainer::_repaint() { - Ref<StyleBox> sb = get_theme_stylebox("panel"); + Ref<StyleBox> sb = get_theme_stylebox(SNAME("panel")); Vector<Control *> tabs = _get_tabs(); for (int i = 0; i < tabs.size(); i++) { Control *c = tabs[i]; @@ -646,9 +647,9 @@ int TabContainer::_get_tab_width(int p_index) const { } // Get the width of the text displayed on the tab. - Ref<Font> font = get_theme_font("font"); - int font_size = get_theme_font_size("font_size"); - String text = control->has_meta("_tab_name") ? String(tr(String(control->get_meta("_tab_name")))) : String(tr(control->get_name())); + Ref<Font> font = get_theme_font(SNAME("font")); + int font_size = get_theme_font_size(SNAME("font_size")); + String text = control->has_meta("_tab_name") ? String(atr(String(control->get_meta("_tab_name")))) : String(atr(control->get_name())); int width = font->get_string_size(text, font_size).width; // Add space for a tab icon. @@ -657,15 +658,15 @@ int TabContainer::_get_tab_width(int p_index) const { if (icon.is_valid()) { width += icon->get_width(); if (text != "") { - width += get_theme_constant("icon_separation"); + width += get_theme_constant(SNAME("icon_separation")); } } } // Respect a minimum size. - Ref<StyleBox> tab_unselected = get_theme_stylebox("tab_unselected"); - Ref<StyleBox> tab_selected = get_theme_stylebox("tab_selected"); - Ref<StyleBox> tab_disabled = get_theme_stylebox("tab_disabled"); + Ref<StyleBox> tab_unselected = get_theme_stylebox(SNAME("tab_unselected")); + Ref<StyleBox> tab_selected = get_theme_stylebox(SNAME("tab_selected")); + Ref<StyleBox> tab_disabled = get_theme_stylebox(SNAME("tab_disabled")); if (get_tab_disabled(p_index)) { width += tab_disabled->get_minimum_size().width; } else if (p_index == current) { @@ -715,7 +716,7 @@ void TabContainer::add_child_notify(Node *p_child) { c->hide(); } else { c->show(); - //call_deferred("set_current_tab",0); + //call_deferred(SNAME("set_current_tab"),0); first = true; current = 0; previous = 0; @@ -724,7 +725,7 @@ void TabContainer::add_child_notify(Node *p_child) { if (tabs_visible) { c->set_offset(SIDE_TOP, _get_top_margin()); } - Ref<StyleBox> sb = get_theme_stylebox("panel"); + Ref<StyleBox> sb = get_theme_stylebox(SNAME("panel")); c->set_offset(Side(SIDE_TOP), c->get_offset(Side(SIDE_TOP)) + sb->get_margin(Side(SIDE_TOP))); c->set_offset(Side(SIDE_LEFT), c->get_offset(Side(SIDE_LEFT)) + sb->get_margin(Side(SIDE_LEFT))); c->set_offset(Side(SIDE_RIGHT), c->get_offset(Side(SIDE_RIGHT)) - sb->get_margin(Side(SIDE_RIGHT))); @@ -732,13 +733,13 @@ void TabContainer::add_child_notify(Node *p_child) { update(); p_child->connect("renamed", callable_mp(this, &TabContainer::_child_renamed_callback)); if (first && is_inside_tree()) { - emit_signal("tab_changed", current); + emit_signal(SNAME("tab_changed"), current); } } void TabContainer::move_child_notify(Node *p_child) { Container::move_child_notify(p_child); - call_deferred("_update_current_tab"); + call_deferred(SNAME("_update_current_tab")); _refresh_texts(); update(); } @@ -756,11 +757,11 @@ void TabContainer::set_current_tab(int p_current) { _repaint(); if (pending_previous == current) { - emit_signal("tab_selected", current); + emit_signal(SNAME("tab_selected"), current); } else { previous = pending_previous; - emit_signal("tab_selected", current); - emit_signal("tab_changed", current); + emit_signal(SNAME("tab_selected"), current); + emit_signal(SNAME("tab_changed"), current); } update(); @@ -799,7 +800,7 @@ void TabContainer::remove_child_notify(Node *p_child) { return; } - call_deferred("_update_current_tab"); + call_deferred(SNAME("_update_current_tab")); p_child->disconnect("renamed", callable_mp(this, &TabContainer::_child_renamed_callback)); @@ -913,7 +914,7 @@ void TabContainer::drop_data(const Point2 &p_point, const Variant &p_data) { } move_child(moving_tabc, hover_now); set_current_tab(hover_now); - emit_signal("tab_changed", hover_now); + emit_signal(SNAME("tab_changed"), hover_now); } } } @@ -944,12 +945,12 @@ int TabContainer::get_tab_idx_at_point(const Point2 &p_point) const { Popup *popup = get_popup(); if (popup) { - Ref<Texture2D> menu = get_theme_icon("menu"); + Ref<Texture2D> menu = get_theme_icon(SNAME("menu")); button_ofs += menu->get_width(); } if (buttons_visible_cache) { - Ref<Texture2D> increment = get_theme_icon("increment"); - Ref<Texture2D> decrement = get_theme_icon("decrement"); + Ref<Texture2D> increment = get_theme_icon(SNAME("increment")); + Ref<Texture2D> decrement = get_theme_icon(SNAME("decrement")); button_ofs += increment->get_width() + decrement->get_width(); } if (px > size.width - button_ofs) { @@ -1136,17 +1137,17 @@ Size2 TabContainer::get_minimum_size() const { ms.y = MAX(ms.y, cms.y); } - Ref<StyleBox> tab_unselected = get_theme_stylebox("tab_unselected"); - Ref<StyleBox> tab_selected = get_theme_stylebox("tab_selected"); - Ref<StyleBox> tab_disabled = get_theme_stylebox("tab_disabled"); - Ref<Font> font = get_theme_font("font"); + Ref<StyleBox> tab_unselected = get_theme_stylebox(SNAME("tab_unselected")); + Ref<StyleBox> tab_selected = get_theme_stylebox(SNAME("tab_selected")); + Ref<StyleBox> tab_disabled = get_theme_stylebox(SNAME("tab_disabled")); + Ref<Font> font = get_theme_font(SNAME("font")); if (tabs_visible) { ms.y += MAX(MAX(tab_unselected->get_minimum_size().y, tab_selected->get_minimum_size().y), tab_disabled->get_minimum_size().y); ms.y += _get_top_margin(); } - Ref<StyleBox> sb = get_theme_stylebox("panel"); + Ref<StyleBox> sb = get_theme_stylebox(SNAME("panel")); ms += sb->get_minimum_size(); return ms; diff --git a/scene/gui/tabs.cpp b/scene/gui/tabs.cpp index 6f1cff9ec8..103860ad78 100644 --- a/scene/gui/tabs.cpp +++ b/scene/gui/tabs.cpp @@ -38,9 +38,9 @@ #include "scene/gui/texture_rect.h" Size2 Tabs::get_minimum_size() const { - Ref<StyleBox> tab_unselected = get_theme_stylebox("tab_unselected"); - Ref<StyleBox> tab_selected = get_theme_stylebox("tab_selected"); - Ref<StyleBox> tab_disabled = get_theme_stylebox("tab_disabled"); + Ref<StyleBox> tab_unselected = get_theme_stylebox(SNAME("tab_unselected")); + Ref<StyleBox> tab_selected = get_theme_stylebox(SNAME("tab_selected")); + Ref<StyleBox> tab_disabled = get_theme_stylebox(SNAME("tab_disabled")); int y_margin = MAX(MAX(tab_unselected->get_minimum_size().height, tab_selected->get_minimum_size().height), tab_disabled->get_minimum_size().height); @@ -51,7 +51,7 @@ Size2 Tabs::get_minimum_size() const { if (tex.is_valid()) { ms.height = MAX(ms.height, tex->get_size().height); if (tabs[i].text != "") { - ms.width += get_theme_constant("hseparation"); + ms.width += get_theme_constant(SNAME("hseparation")); } } @@ -69,15 +69,15 @@ Size2 Tabs::get_minimum_size() const { if (tabs[i].right_button.is_valid()) { Ref<Texture2D> rb = tabs[i].right_button; Size2 bms = rb->get_size(); - bms.width += get_theme_constant("hseparation"); + bms.width += get_theme_constant(SNAME("hseparation")); ms.width += bms.width; ms.height = MAX(bms.height + tab_unselected->get_minimum_size().height, ms.height); } if (cb_displaypolicy == CLOSE_BUTTON_SHOW_ALWAYS || (cb_displaypolicy == CLOSE_BUTTON_SHOW_ACTIVE_ONLY && i == current)) { - Ref<Texture2D> cb = get_theme_icon("close"); + Ref<Texture2D> cb = get_theme_icon(SNAME("close")); Size2 bms = cb->get_size(); - bms.width += get_theme_constant("hseparation"); + bms.width += get_theme_constant(SNAME("hseparation")); ms.width += bms.width; ms.height = MAX(bms.height + tab_unselected->get_minimum_size().height, ms.height); } @@ -100,8 +100,8 @@ void Tabs::_gui_input(const Ref<InputEvent> &p_event) { highlight_arrow = -1; if (buttons_visible) { - Ref<Texture2D> incr = get_theme_icon("increment"); - Ref<Texture2D> decr = get_theme_icon("decrement"); + Ref<Texture2D> incr = get_theme_icon(SNAME("increment")); + Ref<Texture2D> decr = get_theme_icon(SNAME("decrement")); if (is_layout_rtl()) { if (pos.x < decr->get_width()) { @@ -148,7 +148,7 @@ void Tabs::_gui_input(const Ref<InputEvent> &p_event) { if (rb_pressing && !mb->is_pressed() && mb->get_button_index() == MOUSE_BUTTON_LEFT) { if (rb_hover != -1) { //pressed - emit_signal("right_button_pressed", rb_hover); + emit_signal(SNAME("right_button_pressed"), rb_hover); } rb_pressing = false; @@ -158,7 +158,7 @@ void Tabs::_gui_input(const Ref<InputEvent> &p_event) { if (cb_pressing && !mb->is_pressed() && mb->get_button_index() == MOUSE_BUTTON_LEFT) { if (cb_hover != -1) { //pressed - emit_signal("tab_closed", cb_hover); + emit_signal(SNAME("tab_closed"), cb_hover); } cb_pressing = false; @@ -170,8 +170,8 @@ void Tabs::_gui_input(const Ref<InputEvent> &p_event) { Point2 pos(mb->get_position().x, mb->get_position().y); if (buttons_visible) { - Ref<Texture2D> incr = get_theme_icon("increment"); - Ref<Texture2D> decr = get_theme_icon("decrement"); + Ref<Texture2D> incr = get_theme_icon(SNAME("increment")); + Ref<Texture2D> decr = get_theme_icon(SNAME("decrement")); if (is_layout_rtl()) { if (pos.x < decr->get_width()) { @@ -229,17 +229,17 @@ void Tabs::_gui_input(const Ref<InputEvent> &p_event) { if (found != -1) { set_current_tab(found); - emit_signal("tab_clicked", found); + emit_signal(SNAME("tab_clicked"), found); } } } } void Tabs::_shape(int p_tab) { - Ref<Font> font = get_theme_font("font"); - int font_size = get_theme_font_size("font_size"); + Ref<Font> font = get_theme_font(SNAME("font")); + int font_size = get_theme_font_size(SNAME("font_size")); - tabs.write[p_tab].xl_text = tr(tabs[p_tab].text); + tabs.write[p_tab].xl_text = atr(tabs[p_tab].text); tabs.write[p_tab].text_buf->clear(); if (tabs[p_tab].text_direction == Control::TEXT_DIRECTION_INHERITED) { tabs.write[p_tab].text_buf->set_direction(is_layout_rtl() ? TextServer::DIRECTION_RTL : TextServer::DIRECTION_LTR); @@ -274,15 +274,15 @@ void Tabs::_notification(int p_what) { _update_cache(); RID ci = get_canvas_item(); - Ref<StyleBox> tab_unselected = get_theme_stylebox("tab_unselected"); - Ref<StyleBox> tab_selected = get_theme_stylebox("tab_selected"); - Ref<StyleBox> tab_disabled = get_theme_stylebox("tab_disabled"); - Color font_selected_color = get_theme_color("font_selected_color"); - Color font_unselected_color = get_theme_color("font_unselected_color"); - Color font_disabled_color = get_theme_color("font_disabled_color"); - Ref<Texture2D> close = get_theme_icon("close"); - Color font_outline_color = get_theme_color("font_outline_color"); - int outline_size = get_theme_constant("outline_size"); + Ref<StyleBox> tab_unselected = get_theme_stylebox(SNAME("tab_unselected")); + Ref<StyleBox> tab_selected = get_theme_stylebox(SNAME("tab_selected")); + Ref<StyleBox> tab_disabled = get_theme_stylebox(SNAME("tab_disabled")); + Color font_selected_color = get_theme_color(SNAME("font_selected_color")); + Color font_unselected_color = get_theme_color(SNAME("font_unselected_color")); + Color font_disabled_color = get_theme_color(SNAME("font_disabled_color")); + Ref<Texture2D> close = get_theme_icon(SNAME("close")); + Color font_outline_color = get_theme_color(SNAME("font_outline_color")); + int outline_size = get_theme_constant(SNAME("outline_size")); Vector2 size = get_size(); bool rtl = is_layout_rtl(); @@ -306,10 +306,10 @@ void Tabs::_notification(int p_what) { w = 0; } - Ref<Texture2D> incr = get_theme_icon("increment"); - Ref<Texture2D> decr = get_theme_icon("decrement"); - Ref<Texture2D> incr_hl = get_theme_icon("increment_highlight"); - Ref<Texture2D> decr_hl = get_theme_icon("decrement_highlight"); + Ref<Texture2D> incr = get_theme_icon(SNAME("increment")); + Ref<Texture2D> decr = get_theme_icon(SNAME("decrement")); + Ref<Texture2D> incr_hl = get_theme_icon(SNAME("increment_highlight")); + Ref<Texture2D> decr_hl = get_theme_icon(SNAME("decrement_highlight")); int limit = get_size().width; int limit_minus_buttons = get_size().width - incr->get_width() - decr->get_width(); @@ -363,7 +363,7 @@ void Tabs::_notification(int p_what) { icon->draw(ci, Point2i(w, sb->get_margin(SIDE_TOP) + ((sb_rect.size.y - sb_ms.y) - icon->get_height()) / 2)); } if (tabs[i].text != "") { - w += icon->get_width() + get_theme_constant("hseparation"); + w += icon->get_width() + get_theme_constant(SNAME("hseparation")); } } @@ -384,10 +384,10 @@ void Tabs::_notification(int p_what) { w += tabs[i].size_text; if (tabs[i].right_button.is_valid()) { - Ref<StyleBox> style = get_theme_stylebox("button"); + Ref<StyleBox> style = get_theme_stylebox(SNAME("button")); Ref<Texture2D> rb = tabs[i].right_button; - w += get_theme_constant("hseparation"); + w += get_theme_constant(SNAME("hseparation")); Rect2 rb_rect; rb_rect.size = style->get_minimum_size() + rb->get_size(); @@ -400,7 +400,7 @@ void Tabs::_notification(int p_what) { if (rb_hover == i) { if (rb_pressing) { - get_theme_stylebox("button_pressed")->draw(ci, rb_rect); + get_theme_stylebox(SNAME("button_pressed"))->draw(ci, rb_rect); } else { style->draw(ci, rb_rect); } @@ -416,10 +416,10 @@ void Tabs::_notification(int p_what) { } if (cb_displaypolicy == CLOSE_BUTTON_SHOW_ALWAYS || (cb_displaypolicy == CLOSE_BUTTON_SHOW_ACTIVE_ONLY && i == current)) { - Ref<StyleBox> style = get_theme_stylebox("button"); + Ref<StyleBox> style = get_theme_stylebox(SNAME("button")); Ref<Texture2D> cb = close; - w += get_theme_constant("hseparation"); + w += get_theme_constant(SNAME("hseparation")); Rect2 cb_rect; cb_rect.size = style->get_minimum_size() + cb->get_size(); @@ -432,7 +432,7 @@ void Tabs::_notification(int p_what) { if (!tabs[i].disabled && cb_hover == i) { if (cb_pressing) { - get_theme_stylebox("button_pressed")->draw(ci, cb_rect); + get_theme_stylebox(SNAME("button_pressed"))->draw(ci, cb_rect); } else { style->draw(ci, cb_rect); } @@ -503,7 +503,7 @@ void Tabs::set_current_tab(int p_current) { _update_cache(); update(); - emit_signal("tab_changed", p_current); + emit_signal(SNAME("tab_changed"), p_current); } int Tabs::get_current_tab() const { @@ -529,7 +529,7 @@ bool Tabs::get_offset_buttons_visible() const { void Tabs::set_tab_title(int p_tab, const String &p_title) { ERR_FAIL_INDEX(p_tab, tabs.size()); tabs.write[p_tab].text = p_title; - tabs.write[p_tab].xl_text = tr(p_title); + tabs.write[p_tab].xl_text = atr(p_title); _shape(p_tab); update(); minimum_size_changed(); @@ -659,7 +659,7 @@ void Tabs::_update_hover() { } if (hover != hover_now) { hover = hover_now; - emit_signal("tab_hovered", hover); + emit_signal(SNAME("tab_hovered"), hover); } if (hover_buttons == -1) { // no hover @@ -669,11 +669,11 @@ void Tabs::_update_hover() { } void Tabs::_update_cache() { - Ref<StyleBox> tab_disabled = get_theme_stylebox("tab_disabled"); - Ref<StyleBox> tab_unselected = get_theme_stylebox("tab_unselected"); - Ref<StyleBox> tab_selected = get_theme_stylebox("tab_selected"); - Ref<Texture2D> incr = get_theme_icon("increment"); - Ref<Texture2D> decr = get_theme_icon("decrement"); + Ref<StyleBox> tab_disabled = get_theme_stylebox(SNAME("tab_disabled")); + Ref<StyleBox> tab_unselected = get_theme_stylebox(SNAME("tab_unselected")); + Ref<StyleBox> tab_selected = get_theme_stylebox(SNAME("tab_selected")); + Ref<Texture2D> incr = get_theme_icon(SNAME("increment")); + Ref<Texture2D> decr = get_theme_icon(SNAME("decrement")); int limit_minus_buttons = get_size().width - incr->get_width() - decr->get_width(); int w = 0; @@ -712,12 +712,12 @@ void Tabs::_update_cache() { slen = m_width - (sb->get_margin(SIDE_LEFT) + sb->get_margin(SIDE_RIGHT)); if (tabs[i].icon.is_valid()) { slen -= tabs[i].icon->get_width(); - slen -= get_theme_constant("hseparation"); + slen -= get_theme_constant(SNAME("hseparation")); } if (cb_displaypolicy == CLOSE_BUTTON_SHOW_ALWAYS || (cb_displaypolicy == CLOSE_BUTTON_SHOW_ACTIVE_ONLY && i == current)) { - Ref<Texture2D> cb = get_theme_icon("close"); + Ref<Texture2D> cb = get_theme_icon(SNAME("close")); slen -= cb->get_width(); - slen -= get_theme_constant("hseparation"); + slen -= get_theme_constant(SNAME("hseparation")); } slen = MAX(slen, 1); lsize = m_width; @@ -742,10 +742,10 @@ void Tabs::_on_mouse_exited() { void Tabs::add_tab(const String &p_str, const Ref<Texture2D> &p_icon) { Tab t; t.text = p_str; - t.xl_text = tr(p_str); + t.xl_text = atr(p_str); t.text_buf.instantiate(); t.text_buf->set_direction(is_layout_rtl() ? TextServer::DIRECTION_RTL : TextServer::DIRECTION_LTR); - t.text_buf->add_string(t.xl_text, get_theme_font("font"), get_theme_font_size("font_size"), Dictionary(), TranslationServer::get_singleton()->get_tool_locale()); + t.text_buf->add_string(t.xl_text, get_theme_font(SNAME("font")), get_theme_font_size(SNAME("font_size")), Dictionary(), TranslationServer::get_singleton()->get_tool_locale()); t.icon = p_icon; t.disabled = false; t.ofs_cache = 0; @@ -753,7 +753,7 @@ void Tabs::add_tab(const String &p_str, const Ref<Texture2D> &p_icon) { tabs.push_back(t); _update_cache(); - call_deferred("_update_hover"); + call_deferred(SNAME("_update_hover")); update(); minimum_size_changed(); } @@ -762,7 +762,7 @@ void Tabs::clear_tabs() { tabs.clear(); current = 0; previous = 0; - call_deferred("_update_hover"); + call_deferred(SNAME("_update_hover")); update(); } @@ -773,7 +773,7 @@ void Tabs::remove_tab(int p_idx) { current--; } _update_cache(); - call_deferred("_update_hover"); + call_deferred(SNAME("_update_hover")); update(); minimum_size_changed(); @@ -870,7 +870,7 @@ void Tabs::drop_data(const Point2 &p_point, const Variant &p_data) { hover_now = get_tab_count() - 1; } move_tab(tab_from_id, hover_now); - emit_signal("reposition_active_tab_request", hover_now); + emit_signal(SNAME("reposition_active_tab_request"), hover_now); set_current_tab(hover_now); } else if (get_tabs_rearrange_group() != -1) { // drag and drop between Tabs @@ -887,7 +887,7 @@ void Tabs::drop_data(const Point2 &p_point, const Variant &p_data) { tabs.insert(hover_now, moving_tab); from_tabs->remove_tab(tab_from_id); set_current_tab(hover_now); - emit_signal("tab_changed", hover_now); + emit_signal(SNAME("tab_changed"), hover_now); _update_cache(); } } @@ -949,9 +949,9 @@ void Tabs::move_tab(int from, int to) { int Tabs::get_tab_width(int p_idx) const { ERR_FAIL_INDEX_V(p_idx, tabs.size(), 0); - Ref<StyleBox> tab_unselected = get_theme_stylebox("tab_unselected"); - Ref<StyleBox> tab_selected = get_theme_stylebox("tab_selected"); - Ref<StyleBox> tab_disabled = get_theme_stylebox("tab_disabled"); + Ref<StyleBox> tab_unselected = get_theme_stylebox(SNAME("tab_unselected")); + Ref<StyleBox> tab_selected = get_theme_stylebox(SNAME("tab_selected")); + Ref<StyleBox> tab_disabled = get_theme_stylebox(SNAME("tab_disabled")); int x = 0; @@ -959,7 +959,7 @@ int Tabs::get_tab_width(int p_idx) const { if (tex.is_valid()) { x += tex->get_width(); if (tabs[p_idx].text != "") { - x += get_theme_constant("hseparation"); + x += get_theme_constant(SNAME("hseparation")); } } @@ -976,13 +976,13 @@ int Tabs::get_tab_width(int p_idx) const { if (tabs[p_idx].right_button.is_valid()) { Ref<Texture2D> rb = tabs[p_idx].right_button; x += rb->get_width(); - x += get_theme_constant("hseparation"); + x += get_theme_constant(SNAME("hseparation")); } if (cb_displaypolicy == CLOSE_BUTTON_SHOW_ALWAYS || (cb_displaypolicy == CLOSE_BUTTON_SHOW_ACTIVE_ONLY && p_idx == current)) { - Ref<Texture2D> cb = get_theme_icon("close"); + Ref<Texture2D> cb = get_theme_icon(SNAME("close")); x += cb->get_width(); - x += get_theme_constant("hseparation"); + x += get_theme_constant(SNAME("hseparation")); } return x; @@ -993,8 +993,8 @@ void Tabs::_ensure_no_over_offset() { return; } - Ref<Texture2D> incr = get_theme_icon("increment"); - Ref<Texture2D> decr = get_theme_icon("decrement"); + Ref<Texture2D> incr = get_theme_icon(SNAME("increment")); + Ref<Texture2D> decr = get_theme_icon(SNAME("decrement")); int limit = get_size().width; int limit_minus_buttons = get_size().width - incr->get_width() - decr->get_width(); @@ -1034,8 +1034,8 @@ void Tabs::ensure_tab_visible(int p_idx) { } int prev_offset = offset; - Ref<Texture2D> incr = get_theme_icon("increment"); - Ref<Texture2D> decr = get_theme_icon("decrement"); + Ref<Texture2D> incr = get_theme_icon(SNAME("increment")); + Ref<Texture2D> decr = get_theme_icon(SNAME("decrement")); int limit = get_size().width; int limit_minus_buttons = get_size().width - incr->get_width() - decr->get_width(); diff --git a/scene/gui/text_edit.cpp b/scene/gui/text_edit.cpp index 6f96b530a6..be3edccc99 100644 --- a/scene/gui/text_edit.cpp +++ b/scene/gui/text_edit.cpp @@ -542,8 +542,8 @@ void TextEdit::_notification(int p_what) { } break; case NOTIFICATION_VISIBILITY_CHANGED: { if (is_visible()) { - call_deferred("_update_scrollbars"); - call_deferred("_update_wrap_at"); + call_deferred(SNAME("_update_scrollbars")); + call_deferred(SNAME("_update_wrap_at")); } } break; case NOTIFICATION_LAYOUT_DIRECTION_CHANGED: @@ -599,7 +599,7 @@ void TextEdit::_notification(int p_what) { Size2 size = get_size(); bool rtl = is_layout_rtl(); - if ((!has_focus() && !menu->has_focus()) || !window_has_focus) { + if ((!has_focus() && !(menu && menu->has_focus())) || !window_has_focus) { draw_caret = false; } @@ -1119,7 +1119,7 @@ void TextEdit::_notification(int p_what) { } tl->draw(ci, Point2(gutter_offset + ofs_x, yofs), get_line_gutter_item_color(line, g)); } break; - case GUTTER_TPYE_ICON: { + case GUTTER_TYPE_ICON: { const Ref<Texture2D> icon = get_line_gutter_icon(line, g); if (icon.is_null()) { break; @@ -1147,7 +1147,7 @@ void TextEdit::_notification(int p_what) { icon->draw_rect(ci, gutter_rect, false, get_line_gutter_item_color(line, g)); } break; - case GUTTER_TPYE_CUSTOM: { + case GUTTER_TYPE_CUSTOM: { if (gutter.custom_draw_obj.is_valid()) { Object *cdo = ObjectDB::get_instance(gutter.custom_draw_obj); if (cdo) { @@ -2361,7 +2361,7 @@ void TextEdit::_gui_input(const Ref<InputEvent> &p_gui_input) { } if (mpos.x > left_margin && mpos.x <= (left_margin + gutters[i].width) - 3) { - emit_signal("gutter_clicked", row, i); + emit_signal(SNAME("gutter_clicked"), row, i); return; } @@ -2470,9 +2470,9 @@ void TextEdit::_gui_input(const Ref<InputEvent> &p_gui_input) { } } + _ensure_menu(); menu->set_position(get_screen_transform().xform(mpos)); menu->set_size(Vector2(1, 1)); - _generate_context_menu(); menu->popup(); grab_focus(); } @@ -2482,7 +2482,7 @@ void TextEdit::_gui_input(const Ref<InputEvent> &p_gui_input) { int row, col; _get_mouse_pos(Point2i(mpos.x, mpos.y), row, col); - emit_signal("symbol_lookup", highlighted_word, row, col); + emit_signal(SNAME("symbol_lookup"), highlighted_word, row, col); return; } @@ -2524,7 +2524,7 @@ void TextEdit::_gui_input(const Ref<InputEvent> &p_gui_input) { if (!dragging_minimap && !dragging_selection && mm->is_command_pressed() && mm->get_button_mask() == 0) { String new_word = get_word_at_pos(mpos); if (new_word != highlighted_word) { - emit_signal("symbol_validate", new_word); + emit_signal(SNAME("symbol_validate"), new_word); } } else { if (highlighted_word != String()) { @@ -2575,7 +2575,7 @@ void TextEdit::_gui_input(const Ref<InputEvent> &p_gui_input) { if (select_identifiers_enabled) { if (k->is_pressed() && !dragging_minimap && !dragging_selection) { Point2 mp = _get_local_mouse_pos(); - emit_signal("symbol_validate", get_word_at_pos(mp)); + emit_signal(SNAME("symbol_validate"), get_word_at_pos(mp)); } else { set_highlighted_word(String()); } @@ -2709,9 +2709,9 @@ void TextEdit::_gui_input(const Ref<InputEvent> &p_gui_input) { // MISC. if (k->is_action("ui_menu", true)) { if (context_menu_enabled) { + _ensure_menu(); menu->set_position(get_screen_transform().xform(_get_cursor_pixel_pos())); menu->set_size(Vector2(1, 1)); - _generate_context_menu(); menu->popup(); menu->grab_focus(); } @@ -2990,7 +2990,7 @@ void TextEdit::_base_insert_text(int p_line, int p_char, const String &p_text, i } text_changed_dirty = true; } - emit_signal("lines_edited_from", p_line, r_end_line); + emit_signal(SNAME("lines_edited_from"), p_line, r_end_line); } String TextEdit::_base_get_text(int p_from_line, int p_from_column, int p_to_line, int p_to_column) const { @@ -3041,7 +3041,7 @@ void TextEdit::_base_remove_text(int p_from_line, int p_from_column, int p_to_li } text_changed_dirty = true; } - emit_signal("lines_edited_from", p_to_line, p_from_line); + emit_signal(SNAME("lines_edited_from"), p_to_line, p_from_line); } void TextEdit::_insert_text(int p_line, int p_char, const String &p_text, int *r_end_line, int *r_end_char) { @@ -3212,35 +3212,6 @@ int TextEdit::_get_menu_action_accelerator(const String &p_action) { } } -void TextEdit::_generate_context_menu() { - // Reorganize context menu. - menu->clear(); - if (!readonly) { - menu->add_item(RTR("Cut"), MENU_CUT, is_shortcut_keys_enabled() ? _get_menu_action_accelerator("ui_cut") : 0); - } - menu->add_item(RTR("Copy"), MENU_COPY, is_shortcut_keys_enabled() ? _get_menu_action_accelerator("ui_copy") : 0); - if (!readonly) { - menu->add_item(RTR("Paste"), MENU_PASTE, is_shortcut_keys_enabled() ? _get_menu_action_accelerator("ui_paste") : 0); - } - menu->add_separator(); - if (is_selecting_enabled()) { - menu->add_item(RTR("Select All"), MENU_SELECT_ALL, is_shortcut_keys_enabled() ? _get_menu_action_accelerator("ui_text_select_all") : 0); - } - if (!readonly) { - menu->add_item(RTR("Clear"), MENU_CLEAR); - menu->add_separator(); - menu->add_item(RTR("Undo"), MENU_UNDO, is_shortcut_keys_enabled() ? _get_menu_action_accelerator("ui_undo") : 0); - menu->add_item(RTR("Redo"), MENU_REDO, is_shortcut_keys_enabled() ? _get_menu_action_accelerator("ui_redo") : 0); - } - menu->add_separator(); - menu->add_submenu_item(RTR("Text writing direction"), "DirMenu"); - menu->add_separator(); - menu->add_check_item(RTR("Display control characters"), MENU_DISPLAY_UCC); - if (!readonly) { - menu->add_submenu_item(RTR("Insert control character"), "CTLMenu"); - } -} - int TextEdit::get_visible_rows() const { return _get_control_height() / get_row_height(); } @@ -3858,10 +3829,12 @@ void TextEdit::set_text_direction(Control::TextDirection p_text_direction) { text.set_direction_and_language(dir, (language != "") ? language : TranslationServer::get_singleton()->get_tool_locale()); text.invalidate_all(); - menu_dir->set_item_checked(menu_dir->get_item_index(MENU_DIR_INHERITED), text_direction == TEXT_DIRECTION_INHERITED); - menu_dir->set_item_checked(menu_dir->get_item_index(MENU_DIR_AUTO), text_direction == TEXT_DIRECTION_AUTO); - menu_dir->set_item_checked(menu_dir->get_item_index(MENU_DIR_LTR), text_direction == TEXT_DIRECTION_LTR); - menu_dir->set_item_checked(menu_dir->get_item_index(MENU_DIR_RTL), text_direction == TEXT_DIRECTION_RTL); + if (menu_dir) { + menu_dir->set_item_checked(menu_dir->get_item_index(MENU_DIR_INHERITED), text_direction == TEXT_DIRECTION_INHERITED); + menu_dir->set_item_checked(menu_dir->get_item_index(MENU_DIR_AUTO), text_direction == TEXT_DIRECTION_AUTO); + menu_dir->set_item_checked(menu_dir->get_item_index(MENU_DIR_LTR), text_direction == TEXT_DIRECTION_LTR); + menu_dir->set_item_checked(menu_dir->get_item_index(MENU_DIR_RTL), text_direction == TEXT_DIRECTION_RTL); + } update(); } } @@ -3917,7 +3890,9 @@ String TextEdit::get_language() const { void TextEdit::set_draw_control_chars(bool p_draw_control_chars) { if (draw_control_chars != p_draw_control_chars) { draw_control_chars = p_draw_control_chars; - menu->set_item_checked(menu->get_item_index(MENU_DISPLAY_UCC), draw_control_chars); + if (menu && menu->get_item_index(MENU_DISPLAY_UCC) >= 0) { + menu->set_item_checked(menu->get_item_index(MENU_DISPLAY_UCC), draw_control_chars); + } text.set_draw_control_chars(draw_control_chars); text.invalidate_all(); update(); @@ -3988,7 +3963,6 @@ void TextEdit::set_readonly(bool p_readonly) { } readonly = p_readonly; - _generate_context_menu(); update(); } @@ -4027,35 +4001,35 @@ void TextEdit::_toggle_draw_caret() { } void TextEdit::_update_caches() { - cache.style_normal = get_theme_stylebox("normal"); - cache.style_focus = get_theme_stylebox("focus"); - cache.style_readonly = get_theme_stylebox("read_only"); - cache.font = get_theme_font("font"); - cache.font_size = get_theme_font_size("font_size"); - cache.outline_color = get_theme_color("font_outline_color"); - cache.outline_size = get_theme_constant("outline_size"); - cache.caret_color = get_theme_color("caret_color"); - cache.caret_background_color = get_theme_color("caret_background_color"); - cache.font_color = get_theme_color("font_color"); - cache.font_selected_color = get_theme_color("font_selected_color"); - cache.font_readonly_color = get_theme_color("font_readonly_color"); - cache.selection_color = get_theme_color("selection_color"); - cache.current_line_color = get_theme_color("current_line_color"); - cache.line_length_guideline_color = get_theme_color("line_length_guideline_color"); - cache.code_folding_color = get_theme_color("code_folding_color", "CodeEdit"); - cache.brace_mismatch_color = get_theme_color("brace_mismatch_color"); - cache.word_highlighted_color = get_theme_color("word_highlighted_color"); - cache.search_result_color = get_theme_color("search_result_color"); - cache.search_result_border_color = get_theme_color("search_result_border_color"); - cache.background_color = get_theme_color("background_color"); + cache.style_normal = get_theme_stylebox(SNAME("normal")); + cache.style_focus = get_theme_stylebox(SNAME("focus")); + cache.style_readonly = get_theme_stylebox(SNAME("read_only")); + cache.font = get_theme_font(SNAME("font")); + cache.font_size = get_theme_font_size(SNAME("font_size")); + cache.outline_color = get_theme_color(SNAME("font_outline_color")); + cache.outline_size = get_theme_constant(SNAME("outline_size")); + cache.caret_color = get_theme_color(SNAME("caret_color")); + cache.caret_background_color = get_theme_color(SNAME("caret_background_color")); + cache.font_color = get_theme_color(SNAME("font_color")); + cache.font_selected_color = get_theme_color(SNAME("font_selected_color")); + cache.font_readonly_color = get_theme_color(SNAME("font_readonly_color")); + cache.selection_color = get_theme_color(SNAME("selection_color")); + cache.current_line_color = get_theme_color(SNAME("current_line_color")); + cache.line_length_guideline_color = get_theme_color(SNAME("line_length_guideline_color")); + cache.code_folding_color = get_theme_color(SNAME("code_folding_color"), SNAME("CodeEdit")); + cache.brace_mismatch_color = get_theme_color(SNAME("brace_mismatch_color")); + cache.word_highlighted_color = get_theme_color(SNAME("word_highlighted_color")); + cache.search_result_color = get_theme_color(SNAME("search_result_color")); + cache.search_result_border_color = get_theme_color(SNAME("search_result_border_color")); + cache.background_color = get_theme_color(SNAME("background_color")); #ifdef TOOLS_ENABLED - cache.line_spacing = get_theme_constant("line_spacing") * EDSCALE; + cache.line_spacing = get_theme_constant(SNAME("line_spacing")) * EDSCALE; #else - cache.line_spacing = get_theme_constant("line_spacing"); + cache.line_spacing = get_theme_constant(SNAME("line_spacing")); #endif - cache.tab_icon = get_theme_icon("tab"); - cache.space_icon = get_theme_icon("space"); - cache.folded_eol_icon = get_theme_icon("folded_eol_icon", "CodeEdit"); + cache.tab_icon = get_theme_icon(SNAME("tab")); + cache.space_icon = get_theme_icon(SNAME("space")); + cache.folded_eol_icon = get_theme_icon(SNAME("folded_eol_icon"), SNAME("CodeEdit")); TextServer::Direction dir; if (text_direction == Control::TEXT_DIRECTION_INHERITED) { @@ -4112,7 +4086,7 @@ void TextEdit::add_gutter(int p_at) { for (int i = 0; i < text.size() + 1; i++) { text.add_gutter(p_at); } - emit_signal("gutter_added"); + emit_signal(SNAME("gutter_added")); update(); } @@ -4124,7 +4098,7 @@ void TextEdit::remove_gutter(int p_gutter) { for (int i = 0; i < text.size() + 1; i++) { text.remove_gutter(p_gutter); } - emit_signal("gutter_removed"); + emit_signal(SNAME("gutter_removed")); update(); } @@ -4748,12 +4722,12 @@ bool TextEdit::search(const String &p_key, uint32_t p_search_flags, int p_from_l } void TextEdit::_cursor_changed_emit() { - emit_signal("cursor_changed"); + emit_signal(SNAME("cursor_changed")); cursor_changed_dirty = false; } void TextEdit::_text_changed_emit() { - emit_signal("text_changed"); + emit_signal(SNAME("text_changed")); text_changed_dirty = false; } @@ -5564,8 +5538,6 @@ bool TextEdit::is_context_menu_enabled() { void TextEdit::set_shortcut_keys_enabled(bool p_enabled) { shortcut_keys_enabled = p_enabled; - - _generate_context_menu(); } void TextEdit::set_virtual_keyboard_enabled(bool p_enable) { @@ -5578,8 +5550,6 @@ void TextEdit::set_selecting_enabled(bool p_enabled) { if (!selecting_enabled) { deselect(); } - - _generate_context_menu(); } bool TextEdit::is_selecting_enabled() const { @@ -5594,7 +5564,12 @@ bool TextEdit::is_virtual_keyboard_enabled() const { return virtual_keyboard_enabled; } +bool TextEdit::is_menu_visible() const { + return menu && menu->is_visible(); +} + PopupMenu *TextEdit::get_menu() const { + const_cast<TextEdit *>(this)->_ensure_menu(); return menu; } @@ -5782,8 +5757,8 @@ void TextEdit::_bind_methods() { /* Gutters. */ BIND_ENUM_CONSTANT(GUTTER_TYPE_STRING); - BIND_ENUM_CONSTANT(GUTTER_TPYE_ICON); - BIND_ENUM_CONSTANT(GUTTER_TPYE_CUSTOM); + BIND_ENUM_CONSTANT(GUTTER_TYPE_ICON); + BIND_ENUM_CONSTANT(GUTTER_TYPE_CUSTOM); ClassDB::bind_method(D_METHOD("add_gutter", "at"), &TextEdit::add_gutter, DEFVAL(-1)); ClassDB::bind_method(D_METHOD("remove_gutter", "gutter"), &TextEdit::remove_gutter); @@ -5833,6 +5808,7 @@ void TextEdit::_bind_methods() { ClassDB::bind_method(D_METHOD("menu_option", "option"), &TextEdit::menu_option); ClassDB::bind_method(D_METHOD("get_menu"), &TextEdit::get_menu); + ClassDB::bind_method(D_METHOD("is_menu_visible"), &TextEdit::is_menu_visible); ClassDB::bind_method(D_METHOD("draw_minimap", "draw"), &TextEdit::set_draw_minimap); ClassDB::bind_method(D_METHOD("is_drawing_minimap"), &TextEdit::is_drawing_minimap); @@ -5921,6 +5897,79 @@ void TextEdit::_bind_methods() { ProjectSettings::get_singleton()->set_custom_property_info("gui/common/text_edit_undo_stack_max_size", PropertyInfo(Variant::INT, "gui/common/text_edit_undo_stack_max_size", PROPERTY_HINT_RANGE, "0,10000,1,or_greater")); // No negative numbers. } +void TextEdit::_ensure_menu() { + if (!menu) { + menu = memnew(PopupMenu); + add_child(menu); + + menu_dir = memnew(PopupMenu); + menu_dir->set_name("DirMenu"); + menu_dir->add_radio_check_item(RTR("Same as layout direction"), MENU_DIR_INHERITED); + menu_dir->add_radio_check_item(RTR("Auto-detect direction"), MENU_DIR_AUTO); + menu_dir->add_radio_check_item(RTR("Left-to-right"), MENU_DIR_LTR); + menu_dir->add_radio_check_item(RTR("Right-to-left"), MENU_DIR_RTL); + menu->add_child(menu_dir); + + menu_ctl = memnew(PopupMenu); + menu_ctl->set_name("CTLMenu"); + menu_ctl->add_item(RTR("Left-to-right mark (LRM)"), MENU_INSERT_LRM); + menu_ctl->add_item(RTR("Right-to-left mark (RLM)"), MENU_INSERT_RLM); + menu_ctl->add_item(RTR("Start of left-to-right embedding (LRE)"), MENU_INSERT_LRE); + menu_ctl->add_item(RTR("Start of right-to-left embedding (RLE)"), MENU_INSERT_RLE); + menu_ctl->add_item(RTR("Start of left-to-right override (LRO)"), MENU_INSERT_LRO); + menu_ctl->add_item(RTR("Start of right-to-left override (RLO)"), MENU_INSERT_RLO); + menu_ctl->add_item(RTR("Pop direction formatting (PDF)"), MENU_INSERT_PDF); + menu_ctl->add_separator(); + menu_ctl->add_item(RTR("Arabic letter mark (ALM)"), MENU_INSERT_ALM); + menu_ctl->add_item(RTR("Left-to-right isolate (LRI)"), MENU_INSERT_LRI); + menu_ctl->add_item(RTR("Right-to-left isolate (RLI)"), MENU_INSERT_RLI); + menu_ctl->add_item(RTR("First strong isolate (FSI)"), MENU_INSERT_FSI); + menu_ctl->add_item(RTR("Pop direction isolate (PDI)"), MENU_INSERT_PDI); + menu_ctl->add_separator(); + menu_ctl->add_item(RTR("Zero width joiner (ZWJ)"), MENU_INSERT_ZWJ); + menu_ctl->add_item(RTR("Zero width non-joiner (ZWNJ)"), MENU_INSERT_ZWNJ); + menu_ctl->add_item(RTR("Word joiner (WJ)"), MENU_INSERT_WJ); + menu_ctl->add_item(RTR("Soft hyphen (SHY)"), MENU_INSERT_SHY); + menu->add_child(menu_ctl); + + menu->connect("id_pressed", callable_mp(this, &TextEdit::menu_option)); + menu_dir->connect("id_pressed", callable_mp(this, &TextEdit::menu_option)); + menu_ctl->connect("id_pressed", callable_mp(this, &TextEdit::menu_option)); + } + + // Reorganize context menu. + menu->clear(); + if (!readonly) { + menu->add_item(RTR("Cut"), MENU_CUT, is_shortcut_keys_enabled() ? _get_menu_action_accelerator("ui_cut") : 0); + } + menu->add_item(RTR("Copy"), MENU_COPY, is_shortcut_keys_enabled() ? _get_menu_action_accelerator("ui_copy") : 0); + if (!readonly) { + menu->add_item(RTR("Paste"), MENU_PASTE, is_shortcut_keys_enabled() ? _get_menu_action_accelerator("ui_paste") : 0); + } + menu->add_separator(); + if (is_selecting_enabled()) { + menu->add_item(RTR("Select All"), MENU_SELECT_ALL, is_shortcut_keys_enabled() ? _get_menu_action_accelerator("ui_text_select_all") : 0); + } + if (!readonly) { + menu->add_item(RTR("Clear"), MENU_CLEAR); + menu->add_separator(); + menu->add_item(RTR("Undo"), MENU_UNDO, is_shortcut_keys_enabled() ? _get_menu_action_accelerator("ui_undo") : 0); + menu->add_item(RTR("Redo"), MENU_REDO, is_shortcut_keys_enabled() ? _get_menu_action_accelerator("ui_redo") : 0); + } + menu->add_separator(); + menu->add_submenu_item(RTR("Text writing direction"), "DirMenu"); + menu->add_separator(); + menu->add_check_item(RTR("Display control characters"), MENU_DISPLAY_UCC); + menu->set_item_checked(menu->get_item_index(MENU_DISPLAY_UCC), draw_control_chars); + if (!readonly) { + menu->add_submenu_item(RTR("Insert control character"), "CTLMenu"); + } + menu_dir->set_item_checked(menu_dir->get_item_index(MENU_DIR_INHERITED), text_direction == TEXT_DIRECTION_INHERITED); + menu_dir->set_item_checked(menu_dir->get_item_index(MENU_DIR_AUTO), text_direction == TEXT_DIRECTION_AUTO); + menu_dir->set_item_checked(menu_dir->get_item_index(MENU_DIR_LTR), text_direction == TEXT_DIRECTION_LTR); + menu_dir->set_item_checked(menu_dir->get_item_index(MENU_DIR_RTL), text_direction == TEXT_DIRECTION_RTL); +} + TextEdit::TextEdit() { clear(); set_focus_mode(FOCUS_ALL); @@ -5960,44 +6009,7 @@ TextEdit::TextEdit() { undo_stack_max_size = GLOBAL_GET("gui/common/text_edit_undo_stack_max_size"); - menu = memnew(PopupMenu); - add_child(menu); - - menu_dir = memnew(PopupMenu); - menu_dir->set_name("DirMenu"); - menu_dir->add_radio_check_item(RTR("Same as layout direction"), MENU_DIR_INHERITED); - menu_dir->add_radio_check_item(RTR("Auto-detect direction"), MENU_DIR_AUTO); - menu_dir->add_radio_check_item(RTR("Left-to-right"), MENU_DIR_LTR); - menu_dir->add_radio_check_item(RTR("Right-to-left"), MENU_DIR_RTL); - menu_dir->set_item_checked(menu_dir->get_item_index(MENU_DIR_INHERITED), true); - menu->add_child(menu_dir); - - menu_ctl = memnew(PopupMenu); - menu_ctl->set_name("CTLMenu"); - menu_ctl->add_item(RTR("Left-to-right mark (LRM)"), MENU_INSERT_LRM); - menu_ctl->add_item(RTR("Right-to-left mark (RLM)"), MENU_INSERT_RLM); - menu_ctl->add_item(RTR("Start of left-to-right embedding (LRE)"), MENU_INSERT_LRE); - menu_ctl->add_item(RTR("Start of right-to-left embedding (RLE)"), MENU_INSERT_RLE); - menu_ctl->add_item(RTR("Start of left-to-right override (LRO)"), MENU_INSERT_LRO); - menu_ctl->add_item(RTR("Start of right-to-left override (RLO)"), MENU_INSERT_RLO); - menu_ctl->add_item(RTR("Pop direction formatting (PDF)"), MENU_INSERT_PDF); - menu_ctl->add_separator(); - menu_ctl->add_item(RTR("Arabic letter mark (ALM)"), MENU_INSERT_ALM); - menu_ctl->add_item(RTR("Left-to-right isolate (LRI)"), MENU_INSERT_LRI); - menu_ctl->add_item(RTR("Right-to-left isolate (RLI)"), MENU_INSERT_RLI); - menu_ctl->add_item(RTR("First strong isolate (FSI)"), MENU_INSERT_FSI); - menu_ctl->add_item(RTR("Pop direction isolate (PDI)"), MENU_INSERT_PDI); - menu_ctl->add_separator(); - menu_ctl->add_item(RTR("Zero width joiner (ZWJ)"), MENU_INSERT_ZWJ); - menu_ctl->add_item(RTR("Zero width non-joiner (ZWNJ)"), MENU_INSERT_ZWNJ); - menu_ctl->add_item(RTR("Word joiner (WJ)"), MENU_INSERT_WJ); - menu_ctl->add_item(RTR("Soft hyphen (SHY)"), MENU_INSERT_SHY); - menu->add_child(menu_ctl); - set_readonly(false); - menu->connect("id_pressed", callable_mp(this, &TextEdit::menu_option)); - menu_dir->connect("id_pressed", callable_mp(this, &TextEdit::menu_option)); - menu_ctl->connect("id_pressed", callable_mp(this, &TextEdit::menu_option)); } TextEdit::~TextEdit() { diff --git a/scene/gui/text_edit.h b/scene/gui/text_edit.h index dcd5c6d0f8..62d576b48a 100644 --- a/scene/gui/text_edit.h +++ b/scene/gui/text_edit.h @@ -44,8 +44,8 @@ class TextEdit : public Control { public: enum GutterType { GUTTER_TYPE_STRING, - GUTTER_TPYE_ICON, - GUTTER_TPYE_CUSTOM + GUTTER_TYPE_ICON, + GUTTER_TYPE_CUSTOM }; enum SelectionMode { @@ -336,8 +336,6 @@ private: bool shortcut_keys_enabled = true; bool virtual_keyboard_enabled = true; - void _generate_context_menu(); - int get_visible_rows() const; int get_total_visible_rows() const; @@ -410,9 +408,11 @@ private: Dictionary _search_bind(const String &p_key, uint32_t p_search_flags, int p_from_line, int p_from_column) const; - PopupMenu *menu; - PopupMenu *menu_dir; - PopupMenu *menu_ctl; + PopupMenu *menu = nullptr; + PopupMenu *menu_dir = nullptr; + PopupMenu *menu_ctl = nullptr; + + void _ensure_menu(); void _clear(); @@ -781,6 +781,7 @@ public: void set_virtual_keyboard_enabled(bool p_enable); bool is_virtual_keyboard_enabled() const; + bool is_menu_visible() const; PopupMenu *get_menu() const; String get_text_for_lookup_completion(); diff --git a/scene/gui/tree.cpp b/scene/gui/tree.cpp index 4d2cb81f23..09db3205d9 100644 --- a/scene/gui/tree.cpp +++ b/scene/gui/tree.cpp @@ -416,7 +416,7 @@ void TreeItem::set_collapsed(bool p_collapsed) { if (tree->select_mode == Tree::SELECT_MULTI) { tree->selected_item = this; - emit_signal("cell_selected"); + emit_signal(SNAME("cell_selected")); } else { select(tree->selected_col); } @@ -426,7 +426,7 @@ void TreeItem::set_collapsed(bool p_collapsed) { } _changed_notify(); - tree->emit_signal("item_collapsed", this); + tree->emit_signal(SNAME("item_collapsed"), this); } bool TreeItem::is_collapsed() { @@ -1215,62 +1215,62 @@ TreeItem::~TreeItem() { /**********************************************/ void Tree::update_cache() { - cache.font = get_theme_font("font"); - cache.font_size = get_theme_font_size("font_size"); - cache.tb_font = get_theme_font("title_button_font"); - cache.tb_font_size = get_theme_font_size("title_button_font_size"); - cache.bg = get_theme_stylebox("bg"); - cache.selected = get_theme_stylebox("selected"); - cache.selected_focus = get_theme_stylebox("selected_focus"); - cache.cursor = get_theme_stylebox("cursor"); - cache.cursor_unfocus = get_theme_stylebox("cursor_unfocused"); - cache.button_pressed = get_theme_stylebox("button_pressed"); - - cache.checked = get_theme_icon("checked"); - cache.unchecked = get_theme_icon("unchecked"); + cache.font = get_theme_font(SNAME("font")); + cache.font_size = get_theme_font_size(SNAME("font_size")); + cache.tb_font = get_theme_font(SNAME("title_button_font")); + cache.tb_font_size = get_theme_font_size(SNAME("title_button_font_size")); + cache.bg = get_theme_stylebox(SNAME("bg")); + cache.selected = get_theme_stylebox(SNAME("selected")); + cache.selected_focus = get_theme_stylebox(SNAME("selected_focus")); + cache.cursor = get_theme_stylebox(SNAME("cursor")); + cache.cursor_unfocus = get_theme_stylebox(SNAME("cursor_unfocused")); + cache.button_pressed = get_theme_stylebox(SNAME("button_pressed")); + + cache.checked = get_theme_icon(SNAME("checked")); + cache.unchecked = get_theme_icon(SNAME("unchecked")); if (is_layout_rtl()) { - cache.arrow_collapsed = get_theme_icon("arrow_collapsed_mirrored"); + cache.arrow_collapsed = get_theme_icon(SNAME("arrow_collapsed_mirrored")); } else { - cache.arrow_collapsed = get_theme_icon("arrow_collapsed"); - } - cache.arrow = get_theme_icon("arrow"); - cache.select_arrow = get_theme_icon("select_arrow"); - cache.updown = get_theme_icon("updown"); - - cache.custom_button = get_theme_stylebox("custom_button"); - cache.custom_button_hover = get_theme_stylebox("custom_button_hover"); - cache.custom_button_pressed = get_theme_stylebox("custom_button_pressed"); - cache.custom_button_font_highlight = get_theme_color("custom_button_font_highlight"); - - cache.font_color = get_theme_color("font_color"); - cache.font_selected_color = get_theme_color("font_selected_color"); - cache.drop_position_color = get_theme_color("drop_position_color"); - cache.hseparation = get_theme_constant("hseparation"); - cache.vseparation = get_theme_constant("vseparation"); - cache.item_margin = get_theme_constant("item_margin"); - cache.button_margin = get_theme_constant("button_margin"); - - cache.font_outline_color = get_theme_color("font_outline_color"); - cache.font_outline_size = get_theme_constant("outline_size"); - - cache.draw_guides = get_theme_constant("draw_guides"); - cache.guide_color = get_theme_color("guide_color"); - cache.draw_relationship_lines = get_theme_constant("draw_relationship_lines"); - cache.relationship_line_width = get_theme_constant("relationship_line_width"); - cache.parent_hl_line_width = get_theme_constant("parent_hl_line_width"); - cache.children_hl_line_width = get_theme_constant("children_hl_line_width"); - cache.parent_hl_line_margin = get_theme_constant("parent_hl_line_margin"); - cache.relationship_line_color = get_theme_color("relationship_line_color"); - cache.parent_hl_line_color = get_theme_color("parent_hl_line_color"); - cache.children_hl_line_color = get_theme_color("children_hl_line_color"); - - cache.scroll_border = get_theme_constant("scroll_border"); - cache.scroll_speed = get_theme_constant("scroll_speed"); - - cache.title_button = get_theme_stylebox("title_button_normal"); - cache.title_button_pressed = get_theme_stylebox("title_button_pressed"); - cache.title_button_hover = get_theme_stylebox("title_button_hover"); - cache.title_button_color = get_theme_color("title_button_color"); + cache.arrow_collapsed = get_theme_icon(SNAME("arrow_collapsed")); + } + cache.arrow = get_theme_icon(SNAME("arrow")); + cache.select_arrow = get_theme_icon(SNAME("select_arrow")); + cache.updown = get_theme_icon(SNAME("updown")); + + cache.custom_button = get_theme_stylebox(SNAME("custom_button")); + cache.custom_button_hover = get_theme_stylebox(SNAME("custom_button_hover")); + cache.custom_button_pressed = get_theme_stylebox(SNAME("custom_button_pressed")); + cache.custom_button_font_highlight = get_theme_color(SNAME("custom_button_font_highlight")); + + cache.font_color = get_theme_color(SNAME("font_color")); + cache.font_selected_color = get_theme_color(SNAME("font_selected_color")); + cache.drop_position_color = get_theme_color(SNAME("drop_position_color")); + cache.hseparation = get_theme_constant(SNAME("hseparation")); + cache.vseparation = get_theme_constant(SNAME("vseparation")); + cache.item_margin = get_theme_constant(SNAME("item_margin")); + cache.button_margin = get_theme_constant(SNAME("button_margin")); + + cache.font_outline_color = get_theme_color(SNAME("font_outline_color")); + cache.font_outline_size = get_theme_constant(SNAME("outline_size")); + + cache.draw_guides = get_theme_constant(SNAME("draw_guides")); + cache.guide_color = get_theme_color(SNAME("guide_color")); + cache.draw_relationship_lines = get_theme_constant(SNAME("draw_relationship_lines")); + cache.relationship_line_width = get_theme_constant(SNAME("relationship_line_width")); + cache.parent_hl_line_width = get_theme_constant(SNAME("parent_hl_line_width")); + cache.children_hl_line_width = get_theme_constant(SNAME("children_hl_line_width")); + cache.parent_hl_line_margin = get_theme_constant(SNAME("parent_hl_line_margin")); + cache.relationship_line_color = get_theme_color(SNAME("relationship_line_color")); + cache.parent_hl_line_color = get_theme_color(SNAME("parent_hl_line_color")); + cache.children_hl_line_color = get_theme_color(SNAME("children_hl_line_color")); + + cache.scroll_border = get_theme_constant(SNAME("scroll_border")); + cache.scroll_speed = get_theme_constant(SNAME("scroll_speed")); + + cache.title_button = get_theme_stylebox(SNAME("title_button_normal")); + cache.title_button_pressed = get_theme_stylebox(SNAME("title_button_pressed")); + cache.title_button_hover = get_theme_stylebox(SNAME("title_button_hover")); + cache.title_button_color = get_theme_color(SNAME("title_button_color")); v_scroll->set_custom_step(cache.font->get_height(cache.font_size)); } @@ -2075,7 +2075,7 @@ void Tree::select_single_item(TreeItem *p_selected, TreeItem *p_current, int p_c selected_item = p_selected; selected_col = 0; if (!emitted_row) { - emit_signal("item_selected"); + emit_signal(SNAME("item_selected")); emitted_row = true; } /* @@ -2095,28 +2095,28 @@ void Tree::select_single_item(TreeItem *p_selected, TreeItem *p_current, int p_c selected_item = p_selected; selected_col = i; - emit_signal("cell_selected"); + emit_signal(SNAME("cell_selected")); if (select_mode == SELECT_MULTI) { - emit_signal("multi_selected", p_current, i, true); + emit_signal(SNAME("multi_selected"), p_current, i, true); } else if (select_mode == SELECT_SINGLE) { - emit_signal("item_selected"); + emit_signal(SNAME("item_selected")); } } else if (select_mode == SELECT_MULTI && (selected_item != p_selected || selected_col != i)) { selected_item = p_selected; selected_col = i; - emit_signal("cell_selected"); + emit_signal(SNAME("cell_selected")); } } else { if (r_in_range && *r_in_range && !p_force_deselect) { if (!c.selected && c.selectable) { c.selected = true; - emit_signal("multi_selected", p_current, i, true); + emit_signal(SNAME("multi_selected"), p_current, i, true); } } else if (!r_in_range || p_force_deselect) { if (select_mode == SELECT_MULTI && c.selected) { - emit_signal("multi_selected", p_current, i, false); + emit_signal(SNAME("multi_selected"), p_current, i, false); } c.selected = false; } @@ -2184,7 +2184,7 @@ void Tree::_range_click_timeout() { } if (propagate_mouse_activated) { - emit_signal("item_activated"); + emit_signal(SNAME("item_activated")); propagate_mouse_activated = false; } @@ -2297,7 +2297,7 @@ int Tree::propagate_mouse_event(const Point2i &p_pos, int x_ofs, int y_ofs, int cache.click_column = col; cache.click_pos = get_global_mouse_position() - get_global_position(); update(); - //emit_signal("button_pressed"); + //emit_signal(SNAME("button_pressed")); return -1; } @@ -2318,15 +2318,15 @@ int Tree::propagate_mouse_event(const Point2i &p_pos, int x_ofs, int y_ofs, int if (select_mode == SELECT_MULTI && p_mod->is_command_pressed() && c.selectable) { if (!c.selected || p_button == MOUSE_BUTTON_RIGHT) { p_item->select(col); - emit_signal("multi_selected", p_item, col, true); + emit_signal(SNAME("multi_selected"), p_item, col, true); if (p_button == MOUSE_BUTTON_RIGHT) { - emit_signal("item_rmb_selected", get_local_mouse_position()); + emit_signal(SNAME("item_rmb_selected"), get_local_mouse_position()); } //p_item->selected_signal.call(col); } else { p_item->deselect(col); - emit_signal("multi_selected", p_item, col, false); + emit_signal(SNAME("multi_selected"), p_item, col, false); //p_item->deselected_signal.call(col); } @@ -2337,7 +2337,7 @@ int Tree::propagate_mouse_event(const Point2i &p_pos, int x_ofs, int y_ofs, int select_single_item(p_item, root, col, selected_item, &inrange); if (p_button == MOUSE_BUTTON_RIGHT) { - emit_signal("item_rmb_selected", get_local_mouse_position()); + emit_signal(SNAME("item_rmb_selected"), get_local_mouse_position()); } } else { int icount = _count_selected_items(root); @@ -2351,14 +2351,14 @@ int Tree::propagate_mouse_event(const Point2i &p_pos, int x_ofs, int y_ofs, int } if (p_button == MOUSE_BUTTON_RIGHT) { - emit_signal("item_rmb_selected", get_local_mouse_position()); + emit_signal(SNAME("item_rmb_selected"), get_local_mouse_position()); } } } /* if (!c.selected && select_mode==SELECT_MULTI) { - emit_signal("multi_selected",p_item,col,true); + emit_signal(SNAME("multi_selected"),p_item,col,true); } */ update(); @@ -2472,7 +2472,7 @@ int Tree::propagate_mouse_event(const Point2i &p_pos, int x_ofs, int y_ofs, int custom_popup_rect = Rect2i(get_global_position() + Point2i(col_ofs, _get_title_button_height() + y_ofs + item_h - cache.offset.y), Size2(get_column_width(col), item_h)); if (on_arrow || !p_item->cells[col].custom_button) { - emit_signal("custom_popup_edited", ((bool)(x >= (col_width - item_h / 2)))); + emit_signal(SNAME("custom_popup_edited"), ((bool)(x >= (col_width - item_h / 2)))); } if (!p_item->cells[col].custom_button || !on_arrow) { @@ -2524,7 +2524,7 @@ int Tree::propagate_mouse_event(const Point2i &p_pos, int x_ofs, int y_ofs, int } } if (p_item == root && p_button == MOUSE_BUTTON_RIGHT) { - emit_signal("empty_rmb", get_local_mouse_position()); + emit_signal(SNAME("empty_rmb"), get_local_mouse_position()); } } @@ -2630,7 +2630,7 @@ void Tree::_go_left() { } else { if (select_mode == SELECT_MULTI) { selected_col--; - emit_signal("cell_selected"); + emit_signal(SNAME("cell_selected")); } else { selected_item->select(selected_col - 1); } @@ -2651,7 +2651,7 @@ void Tree::_go_right() { } else { if (select_mode == SELECT_MULTI) { selected_col++; - emit_signal("cell_selected"); + emit_signal(SNAME("cell_selected")); } else { selected_item->select(selected_col + 1); } @@ -2684,7 +2684,7 @@ void Tree::_go_up() { return; } selected_item = prev; - emit_signal("cell_selected"); + emit_signal(SNAME("cell_selected")); update(); } else { int col = selected_col < 0 ? 0 : selected_col; @@ -2727,7 +2727,7 @@ void Tree::_go_down() { } selected_item = next; - emit_signal("cell_selected"); + emit_signal(SNAME("cell_selected")); update(); } else { int col = selected_col < 0 ? 0 : selected_col; @@ -2828,7 +2828,7 @@ void Tree::_gui_input(Ref<InputEvent> p_event) { if (select_mode == SELECT_MULTI) { selected_item = next; - emit_signal("cell_selected"); + emit_signal(SNAME("cell_selected")); update(); } else { while (next && !next->cells[selected_col].selectable) { @@ -2866,7 +2866,7 @@ void Tree::_gui_input(Ref<InputEvent> p_event) { if (select_mode == SELECT_MULTI) { selected_item = prev; - emit_signal("cell_selected"); + emit_signal(SNAME("cell_selected")); update(); } else { while (prev && !prev->cells[selected_col].selectable) { @@ -2882,7 +2882,7 @@ void Tree::_gui_input(Ref<InputEvent> p_event) { if (selected_item) { //bring up editor if possible if (!edit_selected()) { - emit_signal("item_activated"); + emit_signal(SNAME("item_activated")); incr_search.clear(); } } @@ -2894,10 +2894,10 @@ void Tree::_gui_input(Ref<InputEvent> p_event) { } if (selected_item->is_selected(selected_col)) { selected_item->deselect(selected_col); - emit_signal("multi_selected", selected_item, selected_col, false); + emit_signal(SNAME("multi_selected"), selected_item, selected_col, false); } else if (selected_item->is_selectable(selected_col)) { selected_item->select(selected_col); - emit_signal("multi_selected", selected_item, selected_col, true); + emit_signal(SNAME("multi_selected"), selected_item, selected_col, true); } } accept_event(); @@ -3081,7 +3081,7 @@ void Tree::_gui_input(Ref<InputEvent> p_event) { for (int i = 0; i < columns.size(); i++) { len += get_column_width(i); if (pos.x < len) { - emit_signal("column_title_pressed", i); + emit_signal(SNAME("column_title_pressed"), i); break; } } @@ -3108,10 +3108,10 @@ void Tree::_gui_input(Ref<InputEvent> p_event) { } if (rect.has_point(mpos)) { if (!edit_selected()) { - emit_signal("item_double_clicked"); + emit_signal(SNAME("item_double_clicked")); } } else { - emit_signal("item_double_clicked"); + emit_signal(SNAME("item_double_clicked")); } } pressing_for_editor = false; @@ -3120,7 +3120,7 @@ void Tree::_gui_input(Ref<InputEvent> p_event) { if (cache.click_type == Cache::CLICK_BUTTON && cache.click_item != nullptr) { // make sure in case of wrong reference after reconstructing whole TreeItems cache.click_item = get_item_at_position(cache.click_pos); - emit_signal("button_pressed", cache.click_item, cache.click_column, cache.click_id); + emit_signal(SNAME("button_pressed"), cache.click_item, cache.click_column, cache.click_id); } cache.click_type = Cache::CLICK_NONE; cache.click_index = -1; @@ -3180,7 +3180,7 @@ void Tree::_gui_input(Ref<InputEvent> p_event) { } if (!root || (!root->get_first_child() && hide_root)) { if (b->get_button_index() == MOUSE_BUTTON_RIGHT && allow_rmb_select) { - emit_signal("empty_tree_rmb_selected", get_local_mouse_position()); + emit_signal(SNAME("empty_tree_rmb_selected"), get_local_mouse_position()); } break; } @@ -3231,13 +3231,13 @@ void Tree::_gui_input(Ref<InputEvent> p_event) { if (b->get_button_index() == MOUSE_BUTTON_LEFT) { if (get_item_at_position(b->get_position()) == nullptr && !b->is_shift_pressed() && !b->is_ctrl_pressed() && !b->is_command_pressed()) { - emit_signal("nothing_selected"); + emit_signal(SNAME("nothing_selected")); } } } if (propagate_mouse_activated) { - emit_signal("item_activated"); + emit_signal(SNAME("item_activated")); propagate_mouse_activated = false; } @@ -3306,7 +3306,7 @@ bool Tree::edit_selected() { edited_item = s; edited_col = col; custom_popup_rect = Rect2i(get_global_position() + rect.position, rect.size); - emit_signal("custom_popup_edited", false); + emit_signal(SNAME("custom_popup_edited"), false); item_edited(col, s); return true; @@ -3542,8 +3542,8 @@ void Tree::_notification(int p_what) { RID ci = get_canvas_item(); Ref<StyleBox> bg = cache.bg; - Color font_outline_color = get_theme_color("font_outline_color"); - int outline_size = get_theme_constant("outline_size"); + Color font_outline_color = get_theme_color(SNAME("font_outline_color")); + int outline_size = get_theme_constant(SNAME("outline_size")); Point2 draw_ofs; draw_ofs += bg->get_offset(); @@ -3593,7 +3593,7 @@ void Tree::_notification(int p_what) { // Otherwise, section heading backgrounds can appear to be in front of the focus outline when scrolling. if (has_focus()) { RenderingServer::get_singleton()->canvas_item_add_clip_ignore(ci, true); - const Ref<StyleBox> bg_focus = get_theme_stylebox("bg_focus"); + const Ref<StyleBox> bg_focus = get_theme_stylebox(SNAME("bg_focus")); bg_focus->draw(ci, Rect2(Point2(), get_size())); RenderingServer::get_singleton()->canvas_item_add_clip_ignore(ci, false); } @@ -3694,9 +3694,9 @@ void Tree::item_edited(int p_column, TreeItem *p_item, bool p_lmb) { edited_item->cells.write[p_column].dirty = true; } if (p_lmb) { - emit_signal("item_edited"); + emit_signal(SNAME("item_edited")); } else { - emit_signal("item_rmb_edited"); + emit_signal(SNAME("item_rmb_edited")); } } @@ -3714,7 +3714,7 @@ void Tree::item_selected(int p_column, TreeItem *p_item) { } p_item->cells.write[p_column].selected = true; - //emit_signal("multi_selected",p_item,p_column,true); - NO this is for TreeItem::select + //emit_signal(SNAME("multi_selected"),p_item,p_column,true); - NO this is for TreeItem::select selected_col = p_column; if (!selected_item) { @@ -4075,7 +4075,7 @@ void Tree::ensure_cursor_is_visible() { if (cell_h > screen_h) { // Screen size is too small, maybe it was not resized yet. v_scroll->set_value(y_offset); } else if (y_offset + cell_h > v_scroll->get_value() + screen_h) { - v_scroll->call_deferred("set_value", y_offset - screen_h + cell_h); + v_scroll->call_deferred(SNAME("set_value"), y_offset - screen_h + cell_h); } else if (y_offset < v_scroll->get_value()) { v_scroll->set_value(y_offset); } @@ -4093,7 +4093,7 @@ void Tree::ensure_cursor_is_visible() { if (cell_w > screen_w) { h_scroll->set_value(x_offset); } else if (x_offset + cell_w > h_scroll->get_value() + screen_w) { - h_scroll->call_deferred("set_value", x_offset - screen_w + cell_w); + h_scroll->call_deferred(SNAME("set_value"), x_offset - screen_w + cell_w); } else if (x_offset < h_scroll->get_value()) { h_scroll->set_value(x_offset); } diff --git a/scene/main/canvas_item.cpp b/scene/main/canvas_item.cpp index f81a3ef630..0a76351885 100644 --- a/scene/main/canvas_item.cpp +++ b/scene/main/canvas_item.cpp @@ -128,24 +128,21 @@ void CanvasItemMaterial::_update_shader() { if (particles_animation) { code += "uniform int particles_anim_h_frames;\n"; code += "uniform int particles_anim_v_frames;\n"; - code += "uniform bool particles_anim_loop;\n"; + code += "uniform bool particles_anim_loop;\n\n"; code += "void vertex() {\n"; - - code += "\tfloat h_frames = float(particles_anim_h_frames);\n"; - code += "\tfloat v_frames = float(particles_anim_v_frames);\n"; - - code += "\tVERTEX.xy /= vec2(h_frames, v_frames);\n"; - - code += "\tfloat particle_total_frames = float(particles_anim_h_frames * particles_anim_v_frames);\n"; - code += "\tfloat particle_frame = floor(INSTANCE_CUSTOM.z * float(particle_total_frames));\n"; - code += "\tif (!particles_anim_loop) {\n"; - code += "\t\tparticle_frame = clamp(particle_frame, 0.0, particle_total_frames - 1.0);\n"; - code += "\t} else {\n"; - code += "\t\tparticle_frame = mod(particle_frame, particle_total_frames);\n"; - code += "\t}"; - code += "\tUV /= vec2(h_frames, v_frames);\n"; - code += "\tUV += vec2(mod(particle_frame, h_frames) / h_frames, floor(particle_frame / h_frames) / v_frames);\n"; + code += " float h_frames = float(particles_anim_h_frames);\n"; + code += " float v_frames = float(particles_anim_v_frames);\n"; + code += " VERTEX.xy /= vec2(h_frames, v_frames);\n"; + code += " float particle_total_frames = float(particles_anim_h_frames * particles_anim_v_frames);\n"; + code += " float particle_frame = floor(INSTANCE_CUSTOM.z * float(particle_total_frames));\n"; + code += " if (!particles_anim_loop) {\n"; + code += " particle_frame = clamp(particle_frame, 0.0, particle_total_frames - 1.0);\n"; + code += " } else {\n"; + code += " particle_frame = mod(particle_frame, particle_total_frames);\n"; + code += " }"; + code += " UV /= vec2(h_frames, v_frames);\n"; + code += " UV += vec2(mod(particle_frame, h_frames) / h_frames, floor(particle_frame / h_frames) / v_frames);\n"; code += "}\n"; } @@ -526,7 +523,7 @@ void CanvasItem::_enter_canvas() { get_viewport()->gui_reset_canvas_sort_index(); } - get_tree()->call_group_flags(SceneTree::GROUP_CALL_UNIQUE, group, "_top_level_raise_self"); + get_tree()->call_group_flags(SceneTree::GROUP_CALL_UNIQUE, group, SNAME("_top_level_raise_self")); } else { CanvasItem *parent = get_parent_item(); @@ -545,7 +542,7 @@ void CanvasItem::_exit_canvas() { notification(NOTIFICATION_EXIT_CANVAS, true); //reverse the notification RenderingServer::get_singleton()->canvas_item_set_parent(canvas_item, RID()); canvas_layer = nullptr; - group = ""; + group = StringName(); } void CanvasItem::_notification(int p_what) { @@ -591,7 +588,7 @@ void CanvasItem::_notification(int p_what) { break; } - if (group != "") { + if (group != StringName()) { get_tree()->call_group_flags(SceneTree::GROUP_CALL_UNIQUE, group, "_top_level_raise_self"); } else { CanvasItem *p = get_parent_item(); @@ -651,7 +648,7 @@ void CanvasItem::update() { pending_update = true; - MessageQueue::get_singleton()->push_call(this, "_update_callback"); + MessageQueue::get_singleton()->push_call(this, SNAME("_update_callback")); } void CanvasItem::set_modulate(const Color &p_modulate) { @@ -959,8 +956,7 @@ void CanvasItem::_notify_transform(CanvasItem *p_node) { } } - for (List<CanvasItem *>::Element *E = p_node->children_items.front(); E; E = E->next()) { - CanvasItem *ci = E->get(); + for (CanvasItem *ci : p_node->children_items) { if (ci->top_level) { continue; } @@ -1337,9 +1333,9 @@ void CanvasItem::_update_texture_filter_changed(bool p_propagate) { update(); if (p_propagate) { - for (List<CanvasItem *>::Element *E = children_items.front(); E; E = E->next()) { - if (!E->get()->top_level && E->get()->texture_filter == TEXTURE_FILTER_PARENT_NODE) { - E->get()->_update_texture_filter_changed(true); + for (CanvasItem *E : children_items) { + if (!E->top_level && E->texture_filter == TEXTURE_FILTER_PARENT_NODE) { + E->_update_texture_filter_changed(true); } } } @@ -1377,9 +1373,9 @@ void CanvasItem::_update_texture_repeat_changed(bool p_propagate) { RS::get_singleton()->canvas_item_set_default_texture_repeat(get_canvas_item(), texture_repeat_cache); update(); if (p_propagate) { - for (List<CanvasItem *>::Element *E = children_items.front(); E; E = E->next()) { - if (!E->get()->top_level && E->get()->texture_repeat == TEXTURE_REPEAT_PARENT_NODE) { - E->get()->_update_texture_repeat_changed(true); + for (CanvasItem *E : children_items) { + if (!E->top_level && E->texture_repeat == TEXTURE_REPEAT_PARENT_NODE) { + E->_update_texture_repeat_changed(true); } } } diff --git a/scene/main/canvas_item.h b/scene/main/canvas_item.h index afdd18d76b..f264764870 100644 --- a/scene/main/canvas_item.h +++ b/scene/main/canvas_item.h @@ -187,7 +187,7 @@ private: mutable SelfList<Node> xform_change; RID canvas_item; - String group; + StringName group; CanvasLayer *canvas_layer = nullptr; diff --git a/scene/main/http_request.cpp b/scene/main/http_request.cpp index 775dfa4c46..2c6cefa771 100644 --- a/scene/main/http_request.cpp +++ b/scene/main/http_request.cpp @@ -151,7 +151,7 @@ Error HTTPRequest::request_raw(const String &p_url, const Vector<String> &p_cust client->set_blocking_mode(false); err = _request(); if (err != OK) { - call_deferred("_request_done", RESULT_CANT_CONNECT, 0, PackedStringArray(), PackedByteArray()); + call_deferred(SNAME("_request_done"), RESULT_CANT_CONNECT, 0, PackedStringArray(), PackedByteArray()); return ERR_CANT_CONNECT; } @@ -167,7 +167,7 @@ void HTTPRequest::_thread_func(void *p_userdata) { Error err = hr->_request(); if (err != OK) { - hr->call_deferred("_request_done", RESULT_CANT_CONNECT, 0, PackedStringArray(), PackedByteArray()); + hr->call_deferred(SNAME("_request_done"), RESULT_CANT_CONNECT, 0, PackedStringArray(), PackedByteArray()); } else { while (!hr->thread_request_quit.is_set()) { bool exit = hr->_update_connection(); @@ -209,7 +209,7 @@ void HTTPRequest::cancel_request() { bool HTTPRequest::_handle_response(bool *ret_value) { if (!client->has_response()) { - call_deferred("_request_done", RESULT_NO_RESPONSE, 0, PackedStringArray(), PackedByteArray()); + call_deferred(SNAME("_request_done"), RESULT_NO_RESPONSE, 0, PackedStringArray(), PackedByteArray()); *ret_value = true; return true; } @@ -220,24 +220,24 @@ bool HTTPRequest::_handle_response(bool *ret_value) { client->get_response_headers(&rheaders); response_headers.resize(0); downloaded.set(0); - for (List<String>::Element *E = rheaders.front(); E; E = E->next()) { - response_headers.push_back(E->get()); + for (const String &E : rheaders) { + response_headers.push_back(E); } if (response_code == 301 || response_code == 302) { // Handle redirect if (max_redirects >= 0 && redirections >= max_redirects) { - call_deferred("_request_done", RESULT_REDIRECT_LIMIT_REACHED, response_code, response_headers, PackedByteArray()); + call_deferred(SNAME("_request_done"), RESULT_REDIRECT_LIMIT_REACHED, response_code, response_headers, PackedByteArray()); *ret_value = true; return true; } String new_request; - for (List<String>::Element *E = rheaders.front(); E; E = E->next()) { - if (E->get().findn("Location: ") != -1) { - new_request = E->get().substr(9, E->get().length()).strip_edges(); + for (const String &E : rheaders) { + if (E.findn("Location: ") != -1) { + new_request = E.substr(9, E.length()).strip_edges(); } } @@ -273,7 +273,7 @@ bool HTTPRequest::_handle_response(bool *ret_value) { bool HTTPRequest::_update_connection() { switch (client->get_status()) { case HTTPClient::STATUS_DISCONNECTED: { - call_deferred("_request_done", RESULT_CANT_CONNECT, 0, PackedStringArray(), PackedByteArray()); + call_deferred(SNAME("_request_done"), RESULT_CANT_CONNECT, 0, PackedStringArray(), PackedByteArray()); return true; // End it, since it's doing something } break; case HTTPClient::STATUS_RESOLVING: { @@ -282,7 +282,7 @@ bool HTTPRequest::_update_connection() { return false; } break; case HTTPClient::STATUS_CANT_RESOLVE: { - call_deferred("_request_done", RESULT_CANT_RESOLVE, 0, PackedStringArray(), PackedByteArray()); + call_deferred(SNAME("_request_done"), RESULT_CANT_RESOLVE, 0, PackedStringArray(), PackedByteArray()); return true; } break; @@ -292,7 +292,7 @@ bool HTTPRequest::_update_connection() { return false; } break; // Connecting to IP case HTTPClient::STATUS_CANT_CONNECT: { - call_deferred("_request_done", RESULT_CANT_CONNECT, 0, PackedStringArray(), PackedByteArray()); + call_deferred(SNAME("_request_done"), RESULT_CANT_CONNECT, 0, PackedStringArray(), PackedByteArray()); return true; } break; @@ -307,16 +307,16 @@ bool HTTPRequest::_update_connection() { return ret_value; } - call_deferred("_request_done", RESULT_SUCCESS, response_code, response_headers, PackedByteArray()); + call_deferred(SNAME("_request_done"), RESULT_SUCCESS, response_code, response_headers, PackedByteArray()); return true; } if (body_len < 0) { // Chunked transfer is done - call_deferred("_request_done", RESULT_SUCCESS, response_code, response_headers, body); + call_deferred(SNAME("_request_done"), RESULT_SUCCESS, response_code, response_headers, body); return true; } - call_deferred("_request_done", RESULT_CHUNKED_BODY_SIZE_MISMATCH, response_code, response_headers, PackedByteArray()); + call_deferred(SNAME("_request_done"), RESULT_CHUNKED_BODY_SIZE_MISMATCH, response_code, response_headers, PackedByteArray()); return true; // Request might have been done } else { @@ -325,7 +325,7 @@ bool HTTPRequest::_update_connection() { int size = request_data.size(); Error err = client->request(method, request_string, headers, size > 0 ? request_data.ptr() : nullptr, size); if (err != OK) { - call_deferred("_request_done", RESULT_CONNECTION_ERROR, 0, PackedStringArray(), PackedByteArray()); + call_deferred(SNAME("_request_done"), RESULT_CONNECTION_ERROR, 0, PackedStringArray(), PackedByteArray()); return true; } @@ -348,7 +348,7 @@ bool HTTPRequest::_update_connection() { } if (!client->is_response_chunked() && client->get_response_body_length() == 0) { - call_deferred("_request_done", RESULT_SUCCESS, response_code, response_headers, PackedByteArray()); + call_deferred(SNAME("_request_done"), RESULT_SUCCESS, response_code, response_headers, PackedByteArray()); return true; } @@ -357,14 +357,14 @@ bool HTTPRequest::_update_connection() { body_len = client->get_response_body_length(); if (body_size_limit >= 0 && body_len > body_size_limit) { - call_deferred("_request_done", RESULT_BODY_SIZE_LIMIT_EXCEEDED, response_code, response_headers, PackedByteArray()); + call_deferred(SNAME("_request_done"), RESULT_BODY_SIZE_LIMIT_EXCEEDED, response_code, response_headers, PackedByteArray()); return true; } if (download_to_file != String()) { file = FileAccess::open(download_to_file, FileAccess::WRITE); if (!file) { - call_deferred("_request_done", RESULT_DOWNLOAD_FILE_CANT_OPEN, response_code, response_headers, PackedByteArray()); + call_deferred(SNAME("_request_done"), RESULT_DOWNLOAD_FILE_CANT_OPEN, response_code, response_headers, PackedByteArray()); return true; } } @@ -383,7 +383,7 @@ bool HTTPRequest::_update_connection() { const uint8_t *r = chunk.ptr(); file->store_buffer(r, chunk.size()); if (file->get_error() != OK) { - call_deferred("_request_done", RESULT_DOWNLOAD_FILE_WRITE_ERROR, response_code, response_headers, PackedByteArray()); + call_deferred(SNAME("_request_done"), RESULT_DOWNLOAD_FILE_WRITE_ERROR, response_code, response_headers, PackedByteArray()); return true; } } else { @@ -392,18 +392,18 @@ bool HTTPRequest::_update_connection() { } if (body_size_limit >= 0 && downloaded.get() > body_size_limit) { - call_deferred("_request_done", RESULT_BODY_SIZE_LIMIT_EXCEEDED, response_code, response_headers, PackedByteArray()); + call_deferred(SNAME("_request_done"), RESULT_BODY_SIZE_LIMIT_EXCEEDED, response_code, response_headers, PackedByteArray()); return true; } if (body_len >= 0) { if (downloaded.get() == body_len) { - call_deferred("_request_done", RESULT_SUCCESS, response_code, response_headers, body); + call_deferred(SNAME("_request_done"), RESULT_SUCCESS, response_code, response_headers, body); return true; } } else if (client->get_status() == HTTPClient::STATUS_DISCONNECTED) { // We read till EOF, with no errors. Request is done. - call_deferred("_request_done", RESULT_SUCCESS, response_code, response_headers, body); + call_deferred(SNAME("_request_done"), RESULT_SUCCESS, response_code, response_headers, body); return true; } @@ -411,11 +411,11 @@ bool HTTPRequest::_update_connection() { } break; // Request resulted in body: break which must be read case HTTPClient::STATUS_CONNECTION_ERROR: { - call_deferred("_request_done", RESULT_CONNECTION_ERROR, 0, PackedStringArray(), PackedByteArray()); + call_deferred(SNAME("_request_done"), RESULT_CONNECTION_ERROR, 0, PackedStringArray(), PackedByteArray()); return true; } break; case HTTPClient::STATUS_SSL_HANDSHAKE_ERROR: { - call_deferred("_request_done", RESULT_SSL_HANDSHAKE_ERROR, 0, PackedStringArray(), PackedByteArray()); + call_deferred(SNAME("_request_done"), RESULT_SSL_HANDSHAKE_ERROR, 0, PackedStringArray(), PackedByteArray()); return true; } break; } @@ -463,7 +463,7 @@ void HTTPRequest::_request_done(int p_status, int p_code, const PackedStringArra data = &p_data; } - emit_signal("request_completed", p_status, p_code, p_headers, *data); + emit_signal(SNAME("request_completed"), p_status, p_code, p_headers, *data); } void HTTPRequest::_notification(int p_what) { @@ -563,7 +563,7 @@ int HTTPRequest::get_timeout() { void HTTPRequest::_timeout() { cancel_request(); - call_deferred("_request_done", RESULT_TIMEOUT, 0, PackedStringArray(), PackedByteArray()); + call_deferred(SNAME("_request_done"), RESULT_TIMEOUT, 0, PackedStringArray(), PackedByteArray()); } void HTTPRequest::_bind_methods() { diff --git a/scene/main/instance_placeholder.cpp b/scene/main/instance_placeholder.cpp index 89dac5f5a8..b5ba1899ec 100644 --- a/scene/main/instance_placeholder.cpp +++ b/scene/main/instance_placeholder.cpp @@ -42,9 +42,9 @@ bool InstancePlaceholder::_set(const StringName &p_name, const Variant &p_value) } bool InstancePlaceholder::_get(const StringName &p_name, Variant &r_ret) const { - for (const List<PropSet>::Element *E = stored_values.front(); E; E = E->next()) { - if (E->get().name == p_name) { - r_ret = E->get().value; + for (const PropSet &E : stored_values) { + if (E.name == p_name) { + r_ret = E.value; return true; } } @@ -52,10 +52,10 @@ bool InstancePlaceholder::_get(const StringName &p_name, Variant &r_ret) const { } void InstancePlaceholder::_get_property_list(List<PropertyInfo> *p_list) const { - for (const List<PropSet>::Element *E = stored_values.front(); E; E = E->next()) { + for (const PropSet &E : stored_values) { PropertyInfo pi; - pi.name = E->get().name; - pi.type = E->get().value.get_type(); + pi.name = E.name; + pi.type = E.value.get_type(); pi.usage = PROPERTY_USAGE_STORAGE; p_list->push_back(pi); @@ -95,8 +95,8 @@ Node *InstancePlaceholder::create_instance(bool p_replace, const Ref<PackedScene scene->set_name(get_name()); int pos = get_index(); - for (List<PropSet>::Element *E = stored_values.front(); E; E = E->next()) { - scene->set(E->get().name, E->get().value); + for (const PropSet &E : stored_values) { + scene->set(E.name, E.value); } if (p_replace) { @@ -114,10 +114,10 @@ Dictionary InstancePlaceholder::get_stored_values(bool p_with_order) { Dictionary ret; PackedStringArray order; - for (List<PropSet>::Element *E = stored_values.front(); E; E = E->next()) { - ret[E->get().name] = E->get().value; + for (const PropSet &E : stored_values) { + ret[E.name] = E.value; if (p_with_order) { - order.push_back(E->get().name); + order.push_back(E.name); } }; diff --git a/scene/main/node.cpp b/scene/main/node.cpp index 787b283e8c..f1e5574351 100644 --- a/scene/main/node.cpp +++ b/scene/main/node.cpp @@ -442,7 +442,7 @@ void Node::set_process_mode(ProcessMode p_mode) { // This is required for the editor to update the visibility of disabled nodes // It's very expensive during runtime to change, so editor-only if (Engine::get_singleton()->is_editor_hint()) { - get_tree()->emit_signal("tree_process_mode_changed"); + get_tree()->emit_signal(SNAME("tree_process_mode_changed")); } #endif } @@ -868,7 +868,7 @@ void Node::set_name(const String &p_name) { propagate_notification(NOTIFICATION_PATH_CHANGED); if (is_inside_tree()) { - emit_signal("renamed"); + emit_signal(SNAME("renamed")); get_tree()->node_renamed(this); get_tree()->tree_changed(); } @@ -1597,8 +1597,8 @@ Array Node::_get_groups() const { Array groups; List<GroupInfo> gi; get_groups(&gi); - for (List<GroupInfo>::Element *E = gi.front(); E; E = E->next()) { - groups.push_back(E->get().name); + for (const GroupInfo &E : gi) { + groups.push_back(E.name); } return groups; @@ -1822,6 +1822,18 @@ Node *Node::get_deepest_editable_node(Node *p_start_node) const { return node; } +String Node::to_string() { + if (get_script_instance()) { + bool valid; + String ret = get_script_instance()->to_string(&valid); + if (valid) { + return ret; + } + } + + return (get_name() ? String(get_name()) + ":" : "") + Object::to_string(); +} + void Node::set_scene_instance_state(const Ref<SceneState> &p_state) { data.instance_state = p_state; } @@ -1935,18 +1947,18 @@ Node *Node::_duplicate(int p_flags, Map<const Node *, Node *> *r_duplimap) const List<PropertyInfo> plist; N->get()->get_property_list(&plist); - for (List<PropertyInfo>::Element *E = plist.front(); E; E = E->next()) { - if (!(E->get().usage & PROPERTY_USAGE_STORAGE)) { + for (const PropertyInfo &E : plist) { + if (!(E.usage & PROPERTY_USAGE_STORAGE)) { continue; } - String name = E->get().name; + String name = E.name; if (name == script_property_name) { continue; } Variant value = N->get()->get(name).duplicate(true); - if (E->get().usage & PROPERTY_USAGE_DO_NOT_SHARE_ON_DUPLICATE) { + if (E.usage & PROPERTY_USAGE_DO_NOT_SHARE_ON_DUPLICATE) { Resource *res = Object::cast_to<Resource>(value); if (res) { // Duplicate only if it's a resource current_node->set(name, res->duplicate()); @@ -1971,14 +1983,14 @@ Node *Node::_duplicate(int p_flags, Map<const Node *, Node *> *r_duplimap) const if (p_flags & DUPLICATE_GROUPS) { List<GroupInfo> gi; get_groups(&gi); - for (List<GroupInfo>::Element *E = gi.front(); E; E = E->next()) { + for (const GroupInfo &E : gi) { #ifdef TOOLS_ENABLED - if ((p_flags & DUPLICATE_FROM_EDITOR) && !E->get().persistent) { + if ((p_flags & DUPLICATE_FROM_EDITOR) && !E.persistent) { continue; } #endif - node->add_to_group(E->get().name, E->get().persistent); + node->add_to_group(E.name, E.persistent); } } @@ -2002,21 +2014,21 @@ Node *Node::_duplicate(int p_flags, Map<const Node *, Node *> *r_duplimap) const } } - for (List<const Node *>::Element *E = hidden_roots.front(); E; E = E->next()) { - Node *parent = node->get_node(get_path_to(E->get()->data.parent)); + for (const Node *&E : hidden_roots) { + Node *parent = node->get_node(get_path_to(E->data.parent)); if (!parent) { memdelete(node); return nullptr; } - Node *dup = E->get()->_duplicate(p_flags, r_duplimap); + Node *dup = E->_duplicate(p_flags, r_duplimap); if (!dup) { memdelete(node); return nullptr; } parent->add_child(dup); - int pos = E->get()->get_index(); + int pos = E->get_index(); if (pos < parent->get_child_count() - 1) { parent->move_child(dup, pos); @@ -2061,17 +2073,17 @@ void Node::remap_node_resources(Node *p_node, const Map<RES, RES> &p_resource_re List<PropertyInfo> props; p_node->get_property_list(&props); - for (List<PropertyInfo>::Element *E = props.front(); E; E = E->next()) { - if (!(E->get().usage & PROPERTY_USAGE_STORAGE)) { + for (const PropertyInfo &E : props) { + if (!(E.usage & PROPERTY_USAGE_STORAGE)) { continue; } - Variant v = p_node->get(E->get().name); + Variant v = p_node->get(E.name); if (v.is_ref()) { RES res = v; if (res.is_valid()) { if (p_resource_remap.has(res)) { - p_node->set(E->get().name, p_resource_remap[res]); + p_node->set(E.name, p_resource_remap[res]); remap_nested_resources(res, p_resource_remap); } } @@ -2087,17 +2099,17 @@ void Node::remap_nested_resources(RES p_resource, const Map<RES, RES> &p_resourc List<PropertyInfo> props; p_resource->get_property_list(&props); - for (List<PropertyInfo>::Element *E = props.front(); E; E = E->next()) { - if (!(E->get().usage & PROPERTY_USAGE_STORAGE)) { + for (const PropertyInfo &E : props) { + if (!(E.usage & PROPERTY_USAGE_STORAGE)) { continue; } - Variant v = p_resource->get(E->get().name); + Variant v = p_resource->get(E.name); if (v.is_ref()) { RES res = v; if (res.is_valid()) { if (p_resource_remap.has(res)) { - p_resource->set(E->get().name, p_resource_remap[res]); + p_resource->set(E.name, p_resource_remap[res]); remap_nested_resources(res, p_resource_remap); } } @@ -2123,13 +2135,13 @@ void Node::_duplicate_signals(const Node *p_original, Node *p_copy) const { List<Connection> conns; n->get_all_signal_connections(&conns); - for (List<Connection>::Element *E = conns.front(); E; E = E->next()) { - if (E->get().flags & CONNECT_PERSIST) { + for (const Connection &E : conns) { + if (E.flags & CONNECT_PERSIST) { //user connected NodePath p = p_original->get_path_to(n); Node *copy = p_copy->get_node(p); - Node *target = Object::cast_to<Node>(E->get().callable.get_object()); + Node *target = Object::cast_to<Node>(E.callable.get_object()); if (!target) { continue; } @@ -2146,9 +2158,9 @@ void Node::_duplicate_signals(const Node *p_original, Node *p_copy) const { } if (copy && copytarget) { - const Callable copy_callable = Callable(copytarget, E->get().callable.get_method()); - if (!copy->is_connected(E->get().signal.get_name(), copy_callable)) { - copy->connect(E->get().signal.get_name(), copy_callable, E->get().binds, E->get().flags); + const Callable copy_callable = Callable(copytarget, E.callable.get_method()); + if (!copy->is_connected(E.signal.get_name(), copy_callable)) { + copy->connect(E.signal.get_name(), copy_callable, E.binds, E.flags); } } } @@ -2182,8 +2194,8 @@ void Node::replace_by(Node *p_node, bool p_keep_groups) { List<GroupInfo> groups; get_groups(&groups); - for (List<GroupInfo>::Element *E = groups.front(); E; E = E->next()) { - p_node->add_to_group(E->get().name, E->get().persistent); + for (const GroupInfo &E : groups) { + p_node->add_to_group(E.name, E.persistent); } } @@ -2229,9 +2241,7 @@ void Node::_replace_connections_target(Node *p_new_target) { List<Connection> cl; get_signals_connected_to_this(&cl); - for (List<Connection>::Element *E = cl.front(); E; E = E->next()) { - Connection &c = E->get(); - + for (const Connection &c : cl) { if (c.flags & CONNECT_PERSIST) { c.signal.get_object()->disconnect(c.signal.get_name(), Callable(this, c.callable.get_method())); bool valid = p_new_target->has_method(c.callable.get_method()) || Ref<Script>(p_new_target->get_script()).is_null() || Ref<Script>(p_new_target->get_script())->has_method(c.callable.get_method()); diff --git a/scene/main/node.h b/scene/main/node.h index c6727ce884..20315d7a86 100644 --- a/scene/main/node.h +++ b/scene/main/node.h @@ -329,6 +329,8 @@ public: bool is_editable_instance(const Node *p_node) const; Node *get_deepest_editable_node(Node *p_start_node) const; + virtual String to_string() override; + /* NOTIFICATIONS */ void propagate_notification(int p_notification); diff --git a/scene/main/scene_tree.cpp b/scene/main/scene_tree.cpp index fefe4c9f0d..dcbbebbc55 100644 --- a/scene/main/scene_tree.cpp +++ b/scene/main/scene_tree.cpp @@ -66,11 +66,11 @@ void SceneTreeTimer::_bind_methods() { ADD_SIGNAL(MethodInfo("timeout")); } -void SceneTreeTimer::set_time_left(float p_time) { +void SceneTreeTimer::set_time_left(double p_time) { time_left = p_time; } -float SceneTreeTimer::get_time_left() const { +double SceneTreeTimer::get_time_left() const { return time_left; } @@ -82,12 +82,19 @@ bool SceneTreeTimer::is_process_always() { return process_always; } +void SceneTreeTimer::set_ignore_time_scale(bool p_ignore) { + ignore_time_scale = p_ignore; +} + +bool SceneTreeTimer::is_ignore_time_scale() { + return ignore_time_scale; +} + void SceneTreeTimer::release_connections() { List<Connection> connections; get_all_signal_connections(&connections); - for (List<Connection>::Element *E = connections.front(); E; E = E->next()) { - Connection const &connection = E->get(); + for (const Connection &connection : connections) { disconnect(connection.signal.get_name(), connection.callable); } } @@ -169,8 +176,8 @@ void SceneTree::_flush_ugc() { v[i] = E->get()[i]; } - static_assert(VARIANT_ARG_MAX == 5, "This code needs to be updated if VARIANT_ARG_MAX != 5"); - call_group_flags(GROUP_CALL_REALTIME, E->key().group, E->key().call, v[0], v[1], v[2], v[3], v[4]); + static_assert(VARIANT_ARG_MAX == 8, "This code needs to be updated if VARIANT_ARG_MAX != 8"); + call_group_flags(GROUP_CALL_REALTIME, E->key().group, E->key().call, v[0], v[1], v[2], v[3], v[4], v[5], v[6], v[7]); unique_group_calls.erase(E); } @@ -396,7 +403,7 @@ void SceneTree::initialize() { MainLoop::initialize(); } -bool SceneTree::physics_process(float p_time) { +bool SceneTree::physics_process(double p_time) { root_lock++; current_frame++; @@ -406,11 +413,11 @@ bool SceneTree::physics_process(float p_time) { MainLoop::physics_process(p_time); physics_process_time = p_time; - emit_signal("physics_frame"); + emit_signal(SNAME("physics_frame")); - _notify_group_pause("physics_process_internal", Node::NOTIFICATION_INTERNAL_PHYSICS_PROCESS); - call_group_flags(GROUP_CALL_REALTIME, "_viewports", "_process_picking"); - _notify_group_pause("physics_process", Node::NOTIFICATION_PHYSICS_PROCESS); + _notify_group_pause(SNAME("physics_process_internal"), Node::NOTIFICATION_INTERNAL_PHYSICS_PROCESS); + call_group_flags(GROUP_CALL_REALTIME, SNAME("_picking_viewports"), SNAME("_process_picking")); + _notify_group_pause(SNAME("physics_process"), Node::NOTIFICATION_PHYSICS_PROCESS); _flush_ugc(); MessageQueue::get_singleton()->flush(); //small little hack @@ -425,7 +432,7 @@ bool SceneTree::physics_process(float p_time) { return _quit; } -bool SceneTree::process(float p_time) { +bool SceneTree::process(double p_time) { root_lock++; MainLoop::process(p_time); @@ -436,14 +443,14 @@ bool SceneTree::process(float p_time) { multiplayer->poll(); } - emit_signal("process_frame"); + emit_signal(SNAME("process_frame")); MessageQueue::get_singleton()->flush(); //small little hack flush_transform_notifications(); - _notify_group_pause("process_internal", Node::NOTIFICATION_INTERNAL_PROCESS); - _notify_group_pause("process", Node::NOTIFICATION_PROCESS); + _notify_group_pause(SNAME("process_internal"), Node::NOTIFICATION_INTERNAL_PROCESS); + _notify_group_pause(SNAME("process"), Node::NOTIFICATION_PROCESS); _flush_ugc(); MessageQueue::get_singleton()->flush(); //small little hack @@ -466,12 +473,17 @@ bool SceneTree::process(float p_time) { E = N; continue; } - float time_left = E->get()->get_time_left(); - time_left -= p_time; + + double time_left = E->get()->get_time_left(); + if (E->get()->is_ignore_time_scale()) { + time_left -= Engine::get_singleton()->get_process_step(); + } else { + time_left -= p_time; + } E->get()->set_time_left(time_left); if (time_left < 0) { - E->get()->emit_signal("timeout"); + E->get()->emit_signal(SNAME("timeout")); timers.erase(E); } if (E == L) { @@ -490,7 +502,7 @@ bool SceneTree::process(float p_time) { if (Engine::get_singleton()->is_editor_hint()) { //simple hack to reload fallback environment if it changed from editor - String env_path = ProjectSettings::get_singleton()->get("rendering/environment/defaults/default_environment"); + String env_path = ProjectSettings::get_singleton()->get(SNAME("rendering/environment/defaults/default_environment")); env_path = env_path.strip_edges(); //user may have added a space or two String cpath; Ref<Environment> fallback = get_root()->get_world_3d()->get_fallback_environment(); @@ -559,8 +571,8 @@ void SceneTree::finalize() { } // cleanup timers - for (List<Ref<SceneTreeTimer>>::Element *E = timers.front(); E; E = E->next()) { - E->get()->release_connections(); + for (Ref<SceneTreeTimer> &timer : timers) { + timer->release_connections(); } timers.clear(); } @@ -927,8 +939,8 @@ Variant SceneTree::_call_group_flags(const Variant **p_args, int p_argcount, Cal v[i] = *p_args[i + 3]; } - static_assert(VARIANT_ARG_MAX == 5, "This code needs to be updated if VARIANT_ARG_MAX != 5"); - call_group_flags(flags, group, method, v[0], v[1], v[2], v[3], v[4]); + static_assert(VARIANT_ARG_MAX == 8, "This code needs to be updated if VARIANT_ARG_MAX != 8"); + call_group_flags(flags, group, method, v[0], v[1], v[2], v[3], v[4], v[5], v[6], v[7]); return Variant(); } @@ -947,8 +959,8 @@ Variant SceneTree::_call_group(const Variant **p_args, int p_argcount, Callable: v[i] = *p_args[i + 2]; } - static_assert(VARIANT_ARG_MAX == 5, "This code needs to be updated if VARIANT_ARG_MAX != 5"); - call_group_flags(0, group, method, v[0], v[1], v[2], v[3], v[4]); + static_assert(VARIANT_ARG_MAX == 8, "This code needs to be updated if VARIANT_ARG_MAX != 8"); + call_group_flags(0, group, method, v[0], v[1], v[2], v[3], v[4], v[5], v[6], v[7]); return Variant(); } @@ -1097,7 +1109,7 @@ Error SceneTree::change_scene_to(const Ref<PackedScene> &p_scene) { ERR_FAIL_COND_V(!new_scene, ERR_CANT_CREATE); } - call_deferred("_change_scene", new_scene); + call_deferred(SNAME("_change_scene"), new_scene); return OK; } @@ -1112,7 +1124,7 @@ void SceneTree::add_current_scene(Node *p_current) { root->add_child(p_current); } -Ref<SceneTreeTimer> SceneTree::create_timer(float p_delay_sec, bool p_process_always) { +Ref<SceneTreeTimer> SceneTree::create_timer(double p_delay_sec, bool p_process_always) { Ref<SceneTreeTimer> stt; stt.instantiate(); stt->set_process_always(p_process_always); @@ -1134,8 +1146,8 @@ Array SceneTree::get_processed_tweens() { ret.resize(tweens.size()); int i = 0; - for (List<Ref<Tween>>::Element *E = tweens.front(); E; E = E->next()) { - ret[i] = E->get(); + for (const Ref<Tween> &tween : tweens) { + ret[i] = tween; i++; } @@ -1390,11 +1402,11 @@ SceneTree::SceneTree() { List<String> exts; ResourceLoader::get_recognized_extensions_for_type("Environment", &exts); String ext_hint; - for (List<String>::Element *E = exts.front(); E; E = E->next()) { + for (const String &E : exts) { if (ext_hint != String()) { ext_hint += ","; } - ext_hint += "*." + E->get(); + ext_hint += "*." + E; } // Get path. String env_path = GLOBAL_DEF("rendering/environment/defaults/default_environment", ""); diff --git a/scene/main/scene_tree.h b/scene/main/scene_tree.h index 0be0e185a5..cfb95bd6b5 100644 --- a/scene/main/scene_tree.h +++ b/scene/main/scene_tree.h @@ -52,19 +52,23 @@ class Tween; class SceneTreeTimer : public RefCounted { GDCLASS(SceneTreeTimer, RefCounted); - float time_left = 0.0; + double time_left = 0.0; bool process_always = true; + bool ignore_time_scale = false; protected: static void _bind_methods(); public: - void set_time_left(float p_time); - float get_time_left() const; + void set_time_left(double p_time); + double get_time_left() const; void set_process_always(bool p_process_always); bool is_process_always(); + void set_ignore_time_scale(bool p_ignore); + bool is_ignore_time_scale(); + void release_connections(); SceneTreeTimer(); @@ -87,8 +91,8 @@ private: Window *root = nullptr; uint64_t tree_version = 1; - float physics_process_time = 1.0; - float process_time = 1.0; + double physics_process_time = 1.0; + double process_time = 1.0; bool accept_quit = true; bool quit_on_go_back = true; @@ -233,8 +237,8 @@ public: virtual void initialize() override; - virtual bool physics_process(float p_time) override; - virtual bool process(float p_time) override; + virtual bool physics_process(double p_time) override; + virtual bool process(double p_time) override; virtual void finalize() override; @@ -243,8 +247,8 @@ public: void quit(int p_exit_code = EXIT_SUCCESS); - _FORCE_INLINE_ float get_physics_process_time() const { return physics_process_time; } - _FORCE_INLINE_ float get_process_time() const { return process_time; } + _FORCE_INLINE_ double get_physics_process_time() const { return physics_process_time; } + _FORCE_INLINE_ double get_process_time() const { return process_time; } #ifdef TOOLS_ENABLED bool is_node_being_edited(const Node *p_node) const; @@ -313,7 +317,7 @@ public: Error change_scene_to(const Ref<PackedScene> &p_scene); Error reload_current_scene(); - Ref<SceneTreeTimer> create_timer(float p_delay_sec, bool p_process_always = true); + Ref<SceneTreeTimer> create_timer(double p_delay_sec, bool p_process_always = true); Ref<Tween> create_tween(); Array get_processed_tweens(); diff --git a/scene/main/timer.cpp b/scene/main/timer.cpp index f52237251c..b5a2a30b3b 100644 --- a/scene/main/timer.cpp +++ b/scene/main/timer.cpp @@ -58,7 +58,7 @@ void Timer::_notification(int p_what) { stop(); } - emit_signal("timeout"); + emit_signal(SNAME("timeout")); } } break; @@ -74,19 +74,19 @@ void Timer::_notification(int p_what) { } else { stop(); } - emit_signal("timeout"); + emit_signal(SNAME("timeout")); } } break; } } -void Timer::set_wait_time(float p_time) { +void Timer::set_wait_time(double p_time) { ERR_FAIL_COND_MSG(p_time <= 0, "Time should be greater than zero."); wait_time = p_time; } -float Timer::get_wait_time() const { +double Timer::get_wait_time() const { return wait_time; } @@ -106,7 +106,7 @@ bool Timer::has_autostart() const { return autostart; } -void Timer::start(float p_time) { +void Timer::start(double p_time) { ERR_FAIL_COND_MSG(!is_inside_tree(), "Timer was not added to the SceneTree. Either add it or set autostart to true."); if (p_time > 0) { @@ -139,7 +139,7 @@ bool Timer::is_stopped() const { return get_time_left() <= 0; } -float Timer::get_time_left() const { +double Timer::get_time_left() const { return time_left > 0 ? time_left : 0; } diff --git a/scene/main/timer.h b/scene/main/timer.h index 3d9e21d7fc..2b9faddcb9 100644 --- a/scene/main/timer.h +++ b/scene/main/timer.h @@ -36,7 +36,7 @@ class Timer : public Node { GDCLASS(Timer, Node); - float wait_time = 1.0; + double wait_time = 1.0; bool one_shot = false; bool autostart = false; bool processing = false; @@ -54,8 +54,8 @@ public: TIMER_PROCESS_IDLE, }; - void set_wait_time(float p_time); - float get_wait_time() const; + void set_wait_time(double p_time); + double get_wait_time() const; void set_one_shot(bool p_one_shot); bool is_one_shot() const; @@ -63,7 +63,7 @@ public: void set_autostart(bool p_start); bool has_autostart() const; - void start(float p_time = -1); + void start(double p_time = -1); void stop(); void set_paused(bool p_paused); @@ -71,7 +71,7 @@ public: bool is_stopped() const; - float get_time_left() const; + double get_time_left() const; void set_timer_process_callback(TimerProcessCallback p_callback); TimerProcessCallback get_timer_process_callback() const; diff --git a/scene/main/viewport.cpp b/scene/main/viewport.cpp index 9a2e0c5230..8e7182df46 100644 --- a/scene/main/viewport.cpp +++ b/scene/main/viewport.cpp @@ -37,6 +37,7 @@ #include "core/os/os.h" #include "core/string/translation.h" +#include "scene/2d/camera_2d.h" #include "scene/2d/collision_object_2d.h" #include "scene/3d/camera_3d.h" #include "scene/3d/collision_object_3d.h" @@ -195,7 +196,7 @@ void Viewport::_collision_object_input_event(CollisionObject3D *p_object, Camera return; //discarded } } - p_object->_input_event(camera, p_input_event, p_pos, p_normal, p_shape); + p_object->_input_event(camera_3d, p_input_event, p_pos, p_normal, p_shape); physics_last_object_transform = object_transform; physics_last_camera_transform = camera_transform; physics_last_id = id; @@ -248,33 +249,32 @@ void Viewport::_sub_window_update(Window *p_window) { Rect2i r = Rect2i(p_window->get_position(), sw.window->get_size()); if (!p_window->get_flag(Window::FLAG_BORDERLESS)) { - Ref<StyleBox> panel = p_window->get_theme_stylebox("panel_window"); + Ref<StyleBox> panel = p_window->get_theme_stylebox(SNAME("embedded_border")); panel->draw(sw.canvas_item, r); // Draw the title bar text. - Ref<Font> title_font = p_window->get_theme_font("title_font"); - int font_size = p_window->get_theme_font_size("title_font_size"); - Color title_color = p_window->get_theme_color("title_color"); - int title_height = p_window->get_theme_constant("title_height"); - int close_h_ofs = p_window->get_theme_constant("close_h_ofs"); - int close_v_ofs = p_window->get_theme_constant("close_v_ofs"); - - TextLine title_text = TextLine(p_window->get_title(), title_font, font_size, Dictionary(), TranslationServer::get_singleton()->get_tool_locale()); + Ref<Font> title_font = p_window->get_theme_font(SNAME("title_font")); + int font_size = p_window->get_theme_font_size(SNAME("title_font_size")); + Color title_color = p_window->get_theme_color(SNAME("title_color")); + int title_height = p_window->get_theme_constant(SNAME("title_height")); + int close_h_ofs = p_window->get_theme_constant(SNAME("close_h_ofs")); + int close_v_ofs = p_window->get_theme_constant(SNAME("close_v_ofs")); + + TextLine title_text = TextLine(p_window->atr(p_window->get_title()), title_font, font_size, Dictionary(), TranslationServer::get_singleton()->get_tool_locale()); 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; int y = (-title_height - title_text.get_size().y) / 2; - Color font_outline_color = p_window->get_theme_color("title_outline_modulate"); - int outline_size = p_window->get_theme_constant("title_outline_size"); + Color font_outline_color = p_window->get_theme_color(SNAME("title_outline_modulate")); + int outline_size = p_window->get_theme_constant(SNAME("title_outline_size")); if (outline_size > 0 && font_outline_color.a > 0) { title_text.draw_outline(sw.canvas_item, r.position + Point2(x, y), outline_size, font_outline_color); } title_text.draw(sw.canvas_item, r.position + Point2(x, y), title_color); - bool hl = gui.subwindow_focused == sw.window && gui.subwindow_drag == SUB_WINDOW_DRAG_CLOSE && gui.subwindow_drag_close_inside; - - Ref<Texture2D> close_icon = p_window->get_theme_icon(hl ? "close_highlight" : "close"); + bool pressed = gui.subwindow_focused == sw.window && gui.subwindow_drag == SUB_WINDOW_DRAG_CLOSE && gui.subwindow_drag_close_inside; + Ref<Texture2D> close_icon = p_window->get_theme_icon(pressed ? "close_pressed" : "close"); close_icon->draw(sw.canvas_item, r.position + Vector2(r.size.width - close_h_ofs, -close_v_ofs)); } @@ -444,6 +444,7 @@ void Viewport::_notification(int p_what) { RenderingServer::get_singleton()->instance_set_base(contact_3d_debug_instance, contact_3d_debug_multimesh); RenderingServer::get_singleton()->instance_set_scenario(contact_3d_debug_instance, find_world_3d()->get_scenario()); //RenderingServer::get_singleton()->instance_geometry_set_flag(contact_3d_debug_instance, RS::INSTANCE_FLAG_VISIBLE_IN_ALL_ROOMS, true); + set_physics_process_internal(true); } } break; @@ -462,7 +463,7 @@ void Viewport::_notification(int p_what) { } } - if (cameras.size() && !camera) { + if (cameras.size() && !camera_3d) { //there are cameras but no current camera, pick first in tree and make it current Camera3D *first = nullptr; for (Set<Camera3D *>::Element *E = cameras.front(); E; E = E->next()) { @@ -477,10 +478,6 @@ void Viewport::_notification(int p_what) { } #endif - // Enable processing for tooltips, collision debugging, physics object picking, etc. - set_process_internal(true); - set_physics_process_internal(true); - } break; case NOTIFICATION_EXIT_TREE: { _gui_cancel_tooltip(); @@ -500,19 +497,10 @@ void Viewport::_notification(int p_what) { } remove_from_group("_viewports"); + set_physics_process_internal(false); RS::get_singleton()->viewport_set_active(viewport, false); RenderingServer::get_singleton()->viewport_set_parent_viewport(viewport, RID()); - - } break; - case NOTIFICATION_INTERNAL_PROCESS: { - if (gui.tooltip_timer >= 0) { - gui.tooltip_timer -= get_process_delta_time(); - if (gui.tooltip_timer < 0) { - _gui_show_tooltip(); - } - } - } break; case NOTIFICATION_INTERNAL_PHYSICS_PROCESS: { if (get_tree()->is_debugging_collisions_hint() && contact_2d_debug.is_valid()) { @@ -584,8 +572,7 @@ void Viewport::_process_picking() { // if no mouse event exists, create a motion one. This is necessary because objects or camera may have moved. // while this extra event is sent, it is checked if both camera and last object and last ID did not move. If nothing changed, the event is discarded to avoid flooding with unnecessary motion events every frame bool has_mouse_event = false; - for (List<Ref<InputEvent>>::Element *E = physics_picking_events.front(); E; E = E->next()) { - Ref<InputEventMouse> m = E->get(); + for (const Ref<InputEvent> &m : physics_picking_events) { if (m.is_valid()) { has_mouse_event = true; break; @@ -706,7 +693,6 @@ void Viewport::_process_picking() { bool send_event = true; if (is_mouse) { Map<ObjectID, uint64_t>::Element *F = physics_2d_mouseover.find(res[i].collider_id); - if (!F) { physics_2d_mouseover.insert(res[i].collider_id, frame); co->_mouse_enter(); @@ -717,6 +703,13 @@ void Viewport::_process_picking() { send_event = false; } } + Map<Pair<ObjectID, int>, uint64_t, PairSort<ObjectID, int>>::Element *SF = physics_2d_shape_mouseover.find(Pair(res[i].collider_id, res[i].shape)); + if (!SF) { + physics_2d_shape_mouseover.insert(Pair(res[i].collider_id, res[i].shape), frame); + co->_mouse_shape_enter(res[i].shape); + } else { + SF->get() = frame; + } } if (send_event) { @@ -728,25 +721,7 @@ void Viewport::_process_picking() { } if (is_mouse) { - List<Map<ObjectID, uint64_t>::Element *> to_erase; - - for (Map<ObjectID, uint64_t>::Element *E = physics_2d_mouseover.front(); E; E = E->next()) { - if (E->get() != frame) { - Object *o = ObjectDB::get_instance(E->key()); - if (o) { - CollisionObject2D *co = Object::cast_to<CollisionObject2D>(o); - if (co) { - co->_mouse_exit(); - } - } - to_erase.push_back(E); - } - } - - while (to_erase.size()) { - physics_2d_mouseover.erase(to_erase.front()->get()); - to_erase.pop_front(); - } + _cleanup_mouseover_colliders(false, false, frame); } } @@ -755,8 +730,8 @@ void Viewport::_process_picking() { if (physics_object_capture.is_valid()) { CollisionObject3D *co = Object::cast_to<CollisionObject3D>(ObjectDB::get_instance(physics_object_capture)); - if (co && camera) { - _collision_object_input_event(co, camera, ev, Vector3(), Vector3(), 0); + if (co && camera_3d) { + _collision_object_input_event(co, camera_3d, ev, Vector3(), Vector3(), 0); captured = true; if (mb.is_valid() && mb->get_button_index() == 1 && !mb->is_pressed()) { physics_object_capture = ObjectID(); @@ -773,16 +748,16 @@ void Viewport::_process_picking() { if (last_id.is_valid()) { if (ObjectDB::get_instance(last_id) && last_object) { //good, exists - _collision_object_input_event(last_object, camera, ev, result.position, result.normal, result.shape); + _collision_object_input_event(last_object, camera_3d, ev, result.position, result.normal, result.shape); if (last_object->get_capture_input_on_drag() && mb.is_valid() && mb->get_button_index() == 1 && mb->is_pressed()) { physics_object_capture = last_id; } } } } else { - if (camera) { - Vector3 from = camera->project_ray_origin(pos); - Vector3 dir = camera->project_ray_normal(pos); + if (camera_3d) { + Vector3 from = camera_3d->project_ray_origin(pos); + Vector3 dir = camera_3d->project_ray_normal(pos); PhysicsDirectSpaceState3D *space = PhysicsServer3D::get_singleton()->space_get_direct_state(find_world_3d()->get_space()); if (space) { @@ -790,8 +765,8 @@ void Viewport::_process_picking() { ObjectID new_collider; if (col) { CollisionObject3D *co = Object::cast_to<CollisionObject3D>(result.collider); - if (co && co->can_process()) { - _collision_object_input_event(co, camera, ev, result.position, result.normal, result.shape); + if (co) { + _collision_object_input_event(co, camera_3d, ev, result.position, result.normal, result.shape); last_object = co; last_id = result.collider_id; new_collider = last_id; @@ -859,7 +834,7 @@ void Viewport::_set_size(const Size2i &p_size, const Size2i &p_size_2d_override, update_canvas_items(); - emit_signal("size_changed"); + emit_signal(SNAME("size_changed")); } Size2i Viewport::_get_size() const { @@ -1045,64 +1020,68 @@ void Viewport::_listener_make_next_current(Listener3D *p_exclude) { } } else { // Attempt to reset listener to the camera position - if (camera != nullptr) { + if (camera_3d != nullptr) { _update_listener(); - _camera_transform_changed_notify(); + _camera_3d_transform_changed_notify(); } } } #endif -void Viewport::_camera_transform_changed_notify() { +void Viewport::_camera_3d_transform_changed_notify() { #ifndef _3D_DISABLED #endif } -void Viewport::_camera_set(Camera3D *p_camera) { +void Viewport::_camera_3d_set(Camera3D *p_camera) { #ifndef _3D_DISABLED - if (camera == p_camera) { + if (camera_3d == p_camera) { return; } - if (camera) { - camera->notification(Camera3D::NOTIFICATION_LOST_CURRENT); + if (camera_3d) { + camera_3d->notification(Camera3D::NOTIFICATION_LOST_CURRENT); } - camera = p_camera; + camera_3d = p_camera; if (!camera_override) { - if (camera) { - RenderingServer::get_singleton()->viewport_attach_camera(viewport, camera->get_camera()); + if (camera_3d) { + RenderingServer::get_singleton()->viewport_attach_camera(viewport, camera_3d->get_camera()); } else { RenderingServer::get_singleton()->viewport_attach_camera(viewport, RID()); } } - if (camera) { - camera->notification(Camera3D::NOTIFICATION_BECAME_CURRENT); + if (camera_3d) { + camera_3d->notification(Camera3D::NOTIFICATION_BECAME_CURRENT); } _update_listener(); - _camera_transform_changed_notify(); + _camera_3d_transform_changed_notify(); #endif } -bool Viewport::_camera_add(Camera3D *p_camera) { +void Viewport::_camera_2d_set(Camera2D *p_camera_2d) { + camera_2d = p_camera_2d; +} + +bool Viewport::_camera_3d_add(Camera3D *p_camera) { cameras.insert(p_camera); return cameras.size() == 1; } -void Viewport::_camera_remove(Camera3D *p_camera) { +void Viewport::_camera_3d_remove(Camera3D *p_camera) { cameras.erase(p_camera); - if (camera == p_camera) { - camera->notification(Camera3D::NOTIFICATION_LOST_CURRENT); - camera = nullptr; + if (camera_3d == p_camera) { + camera_3d->notification(Camera3D::NOTIFICATION_LOST_CURRENT); + camera_3d = nullptr; } } #ifndef _3D_DISABLED -void Viewport::_camera_make_next_current(Camera3D *p_exclude) { +void Viewport::_camera_3d_make_next_current(Camera3D *p_exclude) { for (Set<Camera3D *>::Element *E = cameras.front(); E; E = E->next()) { if (p_exclude == E->get()) { continue; @@ -1110,7 +1089,7 @@ void Viewport::_camera_make_next_current(Camera3D *p_exclude) { if (!E->get()->is_inside_tree()) { continue; } - if (camera != nullptr) { + if (camera_3d != nullptr) { return; } @@ -1299,8 +1278,12 @@ Listener3D *Viewport::get_listener() const { return listener; } -Camera3D *Viewport::get_camera() const { - return camera; +Camera3D *Viewport::get_camera_3d() const { + return camera_3d; +} + +Camera2D *Viewport::get_camera_2d() const { + return camera_2d; } void Viewport::enable_camera_override(bool p_enable) { @@ -1318,8 +1301,8 @@ void Viewport::enable_camera_override(bool p_enable) { if (p_enable) { RenderingServer::get_singleton()->viewport_attach_camera(viewport, camera_override.rid); - } else if (camera) { - RenderingServer::get_singleton()->viewport_attach_camera(viewport, camera->get_camera()); + } else if (camera_3d) { + RenderingServer::get_singleton()->viewport_attach_camera(viewport, camera_3d->get_camera()); } else { RenderingServer::get_singleton()->viewport_attach_camera(viewport, RID()); } @@ -1493,7 +1476,10 @@ void Viewport::_gui_sort_roots() { void Viewport::_gui_cancel_tooltip() { gui.tooltip_control = nullptr; - gui.tooltip_timer = -1; + if (gui.tooltip_timer.is_valid()) { + gui.tooltip_timer->release_connections(); + gui.tooltip_timer = Ref<SceneTreeTimer>(); + } if (gui.tooltip_popup) { gui.tooltip_popup->queue_delete(); gui.tooltip_popup = nullptr; @@ -1562,6 +1548,9 @@ void Viewport::_gui_show_tooltip() { return; } + // Popup window which houses the tooltip content. + TooltipPanel *panel = memnew(TooltipPanel); + // Controls can implement `make_custom_tooltip` to provide their own tooltip. // This should be a Control node which will be added as child to a TooltipPanel. Control *base_tooltip = tooltip_owner->make_custom_tooltip(tooltip_text); @@ -1569,13 +1558,14 @@ void Viewport::_gui_show_tooltip() { // If no custom tooltip is given, use a default implementation. if (!base_tooltip) { gui.tooltip_label = memnew(TooltipLabel); + gui.tooltip_label->set_auto_translate(gui.tooltip_control->is_auto_translating()); gui.tooltip_label->set_text(tooltip_text); base_tooltip = gui.tooltip_label; + panel->connect("mouse_entered", callable_mp(this, &Viewport::_gui_cancel_tooltip)); } base_tooltip->set_anchors_and_offsets_preset(Control::PRESET_WIDE); - TooltipPanel *panel = memnew(TooltipPanel); panel->set_transient(false); panel->set_flag(Window::FLAG_NO_FOCUS, true); panel->set_wrap_controls(true); @@ -1710,7 +1700,7 @@ void Viewport::_gui_call_notification(Control *p_control, int p_what) { //_unblock(); } -Control *Viewport::_gui_find_control(const Point2 &p_global) { +Control *Viewport::gui_find_control(const Point2 &p_global) { //aca va subwindows _gui_sort_roots(); @@ -1850,7 +1840,7 @@ void Viewport::_gui_input_event(Ref<InputEvent> p_event) { parent_xform=data.parent_canvas_item->get_global_transform(); */ - gui.mouse_focus = _gui_find_control(pos); + gui.mouse_focus = gui_find_control(pos); gui.last_mouse_focus = gui.mouse_focus; if (!gui.mouse_focus) { @@ -1991,7 +1981,7 @@ void Viewport::_gui_input_event(Ref<InputEvent> p_event) { if (gui.mouse_focus) { over = gui.mouse_focus; } else { - over = _gui_find_control(mpos); + over = gui_find_control(mpos); } if (gui.mouse_focus_mask == 0 && over != gui.mouse_over) { @@ -2074,7 +2064,7 @@ void Viewport::_gui_input_event(Ref<InputEvent> p_event) { if (gui.mouse_focus) { over = gui.mouse_focus; } else { - over = _gui_find_control(mpos); + over = gui_find_control(mpos); } if (over != gui.mouse_over) { @@ -2139,9 +2129,15 @@ void Viewport::_gui_input_event(Ref<InputEvent> p_event) { } if (can_tooltip && !is_tooltip_shown) { + if (gui.tooltip_timer.is_valid()) { + gui.tooltip_timer->release_connections(); + gui.tooltip_timer = Ref<SceneTreeTimer>(); + } gui.tooltip_control = over; gui.tooltip_pos = over->get_screen_transform().xform(pos); - gui.tooltip_timer = gui.tooltip_delay; + gui.tooltip_timer = get_tree()->create_timer(gui.tooltip_delay); + gui.tooltip_timer->set_ignore_time_scale(true); + gui.tooltip_timer->connect("timeout", callable_mp(this, &Viewport::_gui_show_tooltip)); } } @@ -2223,7 +2219,7 @@ void Viewport::_gui_input_event(Ref<InputEvent> p_event) { Window *sw = embedder->gui.sub_windows[i].window; Rect2 swrect = Rect2i(sw->get_position(), sw->get_size()); if (!sw->get_flag(Window::FLAG_BORDERLESS)) { - int title_height = sw->get_theme_constant("title_height"); + int title_height = sw->get_theme_constant(SNAME("title_height")); swrect.position.y -= title_height; swrect.size.y += title_height; } @@ -2261,7 +2257,7 @@ void Viewport::_gui_input_event(Ref<InputEvent> p_event) { Transform2D ai = (viewport_under->get_final_transform().affine_inverse() * viewport_under->_get_input_pre_xform()); viewport_pos = ai.xform(viewport_pos); //find control under at pos - gui.drag_mouse_over = viewport_under->_gui_find_control(viewport_pos); + gui.drag_mouse_over = viewport_under->gui_find_control(viewport_pos); if (gui.drag_mouse_over) { Transform2D localizer = gui.drag_mouse_over->get_global_transform_with_canvas().affine_inverse(); gui.drag_mouse_over_pos = localizer.xform(viewport_pos); @@ -2289,7 +2285,7 @@ void Viewport::_gui_input_event(Ref<InputEvent> p_event) { if (touch_event.is_valid()) { Size2 pos = touch_event->get_position(); if (touch_event->is_pressed()) { - Control *over = _gui_find_control(pos); + Control *over = gui_find_control(pos); if (over) { if (over->can_process()) { touch_event = touch_event->xformed_by(Transform2D()); //make a copy @@ -2324,7 +2320,7 @@ void Viewport::_gui_input_event(Ref<InputEvent> p_event) { Size2 pos = gesture_event->get_position(); - Control *over = _gui_find_control(pos); + Control *over = gui_find_control(pos); if (over) { if (over->can_process()) { gesture_event = gesture_event->xformed_by(Transform2D()); //make a copy @@ -2345,7 +2341,7 @@ void Viewport::_gui_input_event(Ref<InputEvent> p_event) { if (drag_event.is_valid()) { Control *over = gui.mouse_focus; if (!over) { - over = _gui_find_control(drag_event->get_position()); + over = gui_find_control(drag_event->get_position()); } if (over) { if (over->can_process()) { @@ -2572,7 +2568,7 @@ void Viewport::_gui_control_grab_focus(Control *p_control) { } get_tree()->call_group_flags(SceneTree::GROUP_CALL_REALTIME, "_viewports", "_gui_remove_focus_for_window", (Node *)get_base_window()); gui.key_focus = p_control; - emit_signal("gui_focus_changed", p_control); + emit_signal(SNAME("gui_focus_changed"), p_control); p_control->notification(Control::NOTIFICATION_FOCUS_ENTER); p_control->update(); } @@ -2607,20 +2603,41 @@ void Viewport::_drop_mouse_focus() { void Viewport::_drop_physics_mouseover(bool p_paused_only) { physics_has_last_mousepos = false; + _cleanup_mouseover_colliders(true, p_paused_only); + +#ifndef _3D_DISABLED + if (physics_object_over.is_valid()) { + CollisionObject3D *co = Object::cast_to<CollisionObject3D>(ObjectDB::get_instance(physics_object_over)); + if (co) { + if (!(p_paused_only && co->can_process())) { + co->_mouse_exit(); + physics_object_over = ObjectID(); + physics_object_capture = ObjectID(); + } + } + } +#endif +} + +void Viewport::_cleanup_mouseover_colliders(bool p_clean_all_frames, bool p_paused_only, uint64_t p_frame_reference) { List<Map<ObjectID, uint64_t>::Element *> to_erase; for (Map<ObjectID, uint64_t>::Element *E = physics_2d_mouseover.front(); E; E = E->next()) { + if (!p_clean_all_frames && E->get() == p_frame_reference) { + continue; + } + Object *o = ObjectDB::get_instance(E->key()); if (o) { CollisionObject2D *co = Object::cast_to<CollisionObject2D>(o); if (co) { - if (p_paused_only && co->can_process()) { + if (p_clean_all_frames && p_paused_only && co->can_process()) { continue; } co->_mouse_exit(); - to_erase.push_back(E); } } + to_erase.push_back(E); } while (to_erase.size()) { @@ -2628,18 +2645,31 @@ void Viewport::_drop_physics_mouseover(bool p_paused_only) { to_erase.pop_front(); } -#ifndef _3D_DISABLED - if (physics_object_over.is_valid()) { - CollisionObject3D *co = Object::cast_to<CollisionObject3D>(ObjectDB::get_instance(physics_object_over)); - if (co) { - if (!(p_paused_only && co->can_process())) { - co->_mouse_exit(); - physics_object_over = ObjectID(); - physics_object_capture = ObjectID(); + // Per-shape + List<Map<Pair<ObjectID, int>, uint64_t, PairSort<ObjectID, int>>::Element *> shapes_to_erase; + + for (Map<Pair<ObjectID, int>, uint64_t, PairSort<ObjectID, int>>::Element *E = physics_2d_shape_mouseover.front(); E; E = E->next()) { + if (!p_clean_all_frames && E->get() == p_frame_reference) { + continue; + } + + Object *o = ObjectDB::get_instance(E->key().first); + if (o) { + CollisionObject2D *co = Object::cast_to<CollisionObject2D>(o); + if (co) { + if (p_clean_all_frames && p_paused_only && co->can_process()) { + continue; + } + co->_mouse_shape_exit(E->key().second); } } + shapes_to_erase.push_back(E); + } + + while (shapes_to_erase.size()) { + physics_2d_shape_mouseover.erase(shapes_to_erase.front()->get()); + shapes_to_erase.pop_front(); } -#endif } Control *Viewport::_gui_get_focus_owner() { @@ -2648,7 +2678,7 @@ Control *Viewport::_gui_get_focus_owner() { void Viewport::_gui_grab_click_focus(Control *p_control) { gui.mouse_click_grabber = p_control; - call_deferred("_post_gui_grab_click_focus"); + call_deferred(SNAME("_post_gui_grab_click_focus")); } void Viewport::_post_gui_grab_click_focus() { @@ -2721,7 +2751,7 @@ Viewport::SubWindowResize Viewport::_sub_window_get_resize_margin(Window *p_subw Rect2i r = Rect2i(p_subwindow->get_position(), p_subwindow->get_size()); - int title_height = p_subwindow->get_theme_constant("title_height"); + int title_height = p_subwindow->get_theme_constant(SNAME("title_height")); r.position.y -= title_height; r.size.y += title_height; @@ -2733,7 +2763,7 @@ Viewport::SubWindowResize Viewport::_sub_window_get_resize_margin(Window *p_subw int dist_x = p_point.x < r.position.x ? (p_point.x - r.position.x) : (p_point.x > (r.position.x + r.size.x) ? (p_point.x - (r.position.x + r.size.x)) : 0); int dist_y = p_point.y < r.position.y ? (p_point.y - r.position.y) : (p_point.y > (r.position.y + r.size.y) ? (p_point.y - (r.position.y + r.size.y)) : 0); - int limit = p_subwindow->get_theme_constant("resize_margin"); + int limit = p_subwindow->get_theme_constant(SNAME("resize_margin")); if (ABS(dist_x) > limit) { return SUB_WINDOW_RESIZE_DISABLED; @@ -2815,7 +2845,7 @@ bool Viewport::_sub_windows_forward_input(const Ref<InputEvent> &p_event) { new_rect.position.x = 0; } - int title_height = gui.subwindow_focused->get_flag(Window::FLAG_BORDERLESS) ? 0 : gui.subwindow_focused->get_theme_constant("title_height"); + int title_height = gui.subwindow_focused->get_flag(Window::FLAG_BORDERLESS) ? 0 : gui.subwindow_focused->get_theme_constant(SNAME("title_height")); if (new_rect.position.y < title_height) { new_rect.position.y = title_height; @@ -2919,7 +2949,7 @@ bool Viewport::_sub_windows_forward_input(const Ref<InputEvent> &p_event) { if (!sw.window->get_flag(Window::FLAG_BORDERLESS)) { //check top bar - int title_height = sw.window->get_theme_constant("title_height"); + int title_height = sw.window->get_theme_constant(SNAME("title_height")); Rect2i title_bar = r; title_bar.position.y -= title_height; title_bar.size.y = title_height; @@ -2927,9 +2957,9 @@ bool Viewport::_sub_windows_forward_input(const Ref<InputEvent> &p_event) { if (title_bar.has_point(mb->get_position())) { click_on_window = true; - int close_h_ofs = sw.window->get_theme_constant("close_h_ofs"); - int close_v_ofs = sw.window->get_theme_constant("close_v_ofs"); - Ref<Texture2D> close_icon = sw.window->get_theme_icon("close"); + int close_h_ofs = sw.window->get_theme_constant(SNAME("close_h_ofs")); + int close_v_ofs = sw.window->get_theme_constant(SNAME("close_v_ofs")); + Ref<Texture2D> close_icon = sw.window->get_theme_icon(SNAME("close")); Rect2 close_rect; close_rect.position = Vector2(r.position.x + r.size.x - close_v_ofs, r.position.y - close_h_ofs); @@ -3147,8 +3177,13 @@ bool Viewport::is_using_own_world_3d() const { void Viewport::set_physics_object_picking(bool p_enable) { physics_object_picking = p_enable; - if (!physics_object_picking) { + if (physics_object_picking) { + add_to_group("_picking_viewports"); + } else { physics_picking_events.clear(); + if (is_in_group("_picking_viewports")) { + remove_from_group("_picking_viewports"); + } } } @@ -3517,7 +3552,8 @@ void Viewport::_bind_methods() { ClassDB::bind_method(D_METHOD("set_use_own_world_3d", "enable"), &Viewport::set_use_own_world_3d); ClassDB::bind_method(D_METHOD("is_using_own_world_3d"), &Viewport::is_using_own_world_3d); - ClassDB::bind_method(D_METHOD("get_camera"), &Viewport::get_camera); + ClassDB::bind_method(D_METHOD("get_camera_3d"), &Viewport::get_camera_3d); + ClassDB::bind_method(D_METHOD("get_camera_2d"), &Viewport::get_camera_2d); ClassDB::bind_method(D_METHOD("set_as_audio_listener", "enable"), &Viewport::set_as_audio_listener); ClassDB::bind_method(D_METHOD("is_audio_listener"), &Viewport::is_audio_listener); diff --git a/scene/main/viewport.h b/scene/main/viewport.h index 0f3bb8707d..b5c49a8a97 100644 --- a/scene/main/viewport.h +++ b/scene/main/viewport.h @@ -32,6 +32,7 @@ #define VIEWPORT_H #include "core/math/transform_2d.h" +#include "core/templates/pair.h" #include "scene/main/node.h" #include "scene/resources/texture.h" #include "scene/resources/world_2d.h" @@ -49,6 +50,7 @@ class Label; class Timer; class Viewport; class CollisionObject3D; +class SceneTreeTimer; class ViewportTexture : public Texture2D { GDCLASS(ViewportTexture, Texture2D); @@ -213,7 +215,8 @@ private: } } camera_override; - Camera3D *camera = nullptr; + Camera3D *camera_3d = nullptr; + Camera2D *camera_2d = nullptr; Set<Camera3D *> cameras; Set<CanvasLayer *> canvas_layers; @@ -261,7 +264,7 @@ private: Transform3D physics_last_camera_transform; ObjectID physics_last_id; bool physics_has_last_mousepos = false; - Vector2 physics_last_mousepos = Vector2(Math_INF, Math_INF); + Vector2 physics_last_mousepos = Vector2(INFINITY, INFINITY); struct { bool alt = false; bool control = false; @@ -276,7 +279,12 @@ private: bool handle_input_locally = true; bool local_input_handled = false; + // Collider to frame Map<ObjectID, uint64_t> physics_2d_mouseover; + // Collider & shape to frame + Map<Pair<ObjectID, int>, uint64_t, PairSort<ObjectID, int>> physics_2d_shape_mouseover; + // Cleans up colliders corresponding to old frames or all of them. + void _cleanup_mouseover_colliders(bool p_clean_all_frames, bool p_paused_only, uint64_t p_frame_reference = 0); Ref<World2D> world_2d; Ref<World3D> world_3d; @@ -366,7 +374,7 @@ private: bool drag_attempted = false; Variant drag_data; ObjectID drag_preview_id; - float tooltip_timer = -1.0; + Ref<SceneTreeTimer> tooltip_timer; float tooltip_delay = 0.0; Transform2D focus_inv_xform; bool roots_order_dirty = false; @@ -397,7 +405,6 @@ private: void _gui_call_notification(Control *p_control, int p_what); void _gui_sort_roots(); - Control *_gui_find_control(const Point2 &p_global); Control *_gui_find_control_at_pos(CanvasItem *p_node, const Point2 &p_global, const Transform2D &p_xform, Transform2D &r_inv_xform); void _gui_input_event(Ref<InputEvent> p_event); @@ -444,11 +451,14 @@ private: void _listener_make_next_current(Listener3D *p_exclude); friend class Camera3D; - void _camera_transform_changed_notify(); - void _camera_set(Camera3D *p_camera); - bool _camera_add(Camera3D *p_camera); //true if first - void _camera_remove(Camera3D *p_camera); - void _camera_make_next_current(Camera3D *p_exclude); + void _camera_3d_transform_changed_notify(); + void _camera_3d_set(Camera3D *p_camera); + bool _camera_3d_add(Camera3D *p_camera); //true if first + void _camera_3d_remove(Camera3D *p_camera); + void _camera_3d_make_next_current(Camera3D *p_exclude); + + friend class Camera2D; + void _camera_2d_set(Camera2D *p_camera_2d); friend class CanvasLayer; void _canvas_layer_add(CanvasLayer *p_canvas_layer); @@ -491,7 +501,8 @@ public: uint64_t get_processed_events_count() const { return event_count; } Listener3D *get_listener() const; - Camera3D *get_camera() const; + Camera3D *get_camera_3d() const; + Camera2D *get_camera_2d() const; void enable_camera_override(bool p_enable); bool is_camera_override_enabled() const; @@ -618,6 +629,8 @@ public: bool gui_is_dragging() const; + Control *gui_find_control(const Point2 &p_global); + void set_sdf_oversize(SDFOversize p_sdf_oversize); SDFOversize get_sdf_oversize() const; diff --git a/scene/main/window.cpp b/scene/main/window.cpp index c557fd0101..1f1da7cefb 100644 --- a/scene/main/window.cpp +++ b/scene/main/window.cpp @@ -42,9 +42,8 @@ void Window::set_title(const String &p_title) { if (embedder) { embedder->_sub_window_update(this); - } else if (window_id != DisplayServer::INVALID_WINDOW_ID) { - DisplayServer::get_singleton()->window_set_title(p_title, window_id); + DisplayServer::get_singleton()->window_set_title(atr(p_title), window_id); } } @@ -233,7 +232,7 @@ void Window::_make_window() { DisplayServer::get_singleton()->window_set_current_screen(current_screen, window_id); DisplayServer::get_singleton()->window_set_max_size(max_size, window_id); DisplayServer::get_singleton()->window_set_min_size(min_size, window_id); - DisplayServer::get_singleton()->window_set_title(tr(title), window_id); + DisplayServer::get_singleton()->window_set_title(atr(title), window_id); DisplayServer::get_singleton()->window_attach_instance_id(get_instance_id(), window_id); _update_window_size(); @@ -313,39 +312,39 @@ void Window::_event_callback(DisplayServer::WindowEvent p_event) { switch (p_event) { case DisplayServer::WINDOW_EVENT_MOUSE_ENTER: { _propagate_window_notification(this, NOTIFICATION_WM_MOUSE_ENTER); - emit_signal("mouse_entered"); + emit_signal(SNAME("mouse_entered")); DisplayServer::get_singleton()->cursor_set_shape(DisplayServer::CURSOR_ARROW); //restore cursor shape } break; case DisplayServer::WINDOW_EVENT_MOUSE_EXIT: { _propagate_window_notification(this, NOTIFICATION_WM_MOUSE_EXIT); - emit_signal("mouse_exited"); + emit_signal(SNAME("mouse_exited")); } break; case DisplayServer::WINDOW_EVENT_FOCUS_IN: { focused = true; _propagate_window_notification(this, NOTIFICATION_WM_WINDOW_FOCUS_IN); - emit_signal("focus_entered"); + emit_signal(SNAME("focus_entered")); } break; case DisplayServer::WINDOW_EVENT_FOCUS_OUT: { focused = false; _propagate_window_notification(this, NOTIFICATION_WM_WINDOW_FOCUS_OUT); - emit_signal("focus_exited"); + emit_signal(SNAME("focus_exited")); } break; case DisplayServer::WINDOW_EVENT_CLOSE_REQUEST: { if (exclusive_child != nullptr) { break; //has an exclusive child, can't get events until child is closed } _propagate_window_notification(this, NOTIFICATION_WM_CLOSE_REQUEST); - emit_signal("close_requested"); + emit_signal(SNAME("close_requested")); } break; case DisplayServer::WINDOW_EVENT_GO_BACK_REQUEST: { _propagate_window_notification(this, NOTIFICATION_WM_GO_BACK_REQUEST); - emit_signal("go_back_requested"); + emit_signal(SNAME("go_back_requested")); } break; case DisplayServer::WINDOW_EVENT_DPI_CHANGE: { _update_viewport_size(); _propagate_window_notification(this, NOTIFICATION_WM_DPI_CHANGE); - emit_signal("dpi_changed"); + emit_signal(SNAME("dpi_changed")); } break; } } @@ -700,93 +699,98 @@ Viewport *Window::_get_embedder() const { } void Window::_notification(int p_what) { - if (p_what == NOTIFICATION_ENTER_TREE) { - bool embedded = false; - { - embedder = _get_embedder(); - - if (embedder) { - embedded = true; - - if (!visible) { - embedder = nullptr; //not yet since not visible + switch (p_what) { + case NOTIFICATION_ENTER_TREE: { + bool embedded = false; + { + embedder = _get_embedder(); + + if (embedder) { + embedded = true; + + if (!visible) { + embedder = nullptr; //not yet since not visible + } } } - } - if (embedded) { - //create as embedded - if (embedder) { - embedder->_sub_window_register(this); - RS::get_singleton()->viewport_set_update_mode(get_viewport_rid(), RS::VIEWPORT_UPDATE_WHEN_PARENT_VISIBLE); - _update_window_size(); - } - - } else { - if (get_parent() == nullptr) { - //it's the root window! - visible = true; //always visible - window_id = DisplayServer::MAIN_WINDOW_ID; - DisplayServer::get_singleton()->window_attach_instance_id(get_instance_id(), window_id); - _update_from_window(); - //since this window already exists (created on start), we must update pos and size from it - { - position = DisplayServer::get_singleton()->window_get_position(window_id); - size = DisplayServer::get_singleton()->window_get_size(window_id); + if (embedded) { + //create as embedded + if (embedder) { + embedder->_sub_window_register(this); + RS::get_singleton()->viewport_set_update_mode(get_viewport_rid(), RS::VIEWPORT_UPDATE_WHEN_PARENT_VISIBLE); + _update_window_size(); } - _update_viewport_size(); //then feed back to the viewport - _update_window_callbacks(); - RS::get_singleton()->viewport_set_update_mode(get_viewport_rid(), RS::VIEWPORT_UPDATE_WHEN_VISIBLE); + } else { - //create - if (visible) { - _make_window(); + if (get_parent() == nullptr) { + //it's the root window! + visible = true; //always visible + window_id = DisplayServer::MAIN_WINDOW_ID; + DisplayServer::get_singleton()->window_attach_instance_id(get_instance_id(), window_id); + _update_from_window(); + //since this window already exists (created on start), we must update pos and size from it + { + position = DisplayServer::get_singleton()->window_get_position(window_id); + size = DisplayServer::get_singleton()->window_get_size(window_id); + } + _update_viewport_size(); //then feed back to the viewport + _update_window_callbacks(); + RS::get_singleton()->viewport_set_update_mode(get_viewport_rid(), RS::VIEWPORT_UPDATE_WHEN_VISIBLE); + } else { + //create + if (visible) { + _make_window(); + } } } - } - - if (transient) { - _make_transient(); - } - if (visible) { - notification(NOTIFICATION_VISIBILITY_CHANGED); - emit_signal(SceneStringNames::get_singleton()->visibility_changed); - RS::get_singleton()->viewport_set_active(get_viewport_rid(), true); - } - } - if (p_what == NOTIFICATION_READY) { - if (wrap_controls) { - _update_child_controls(); - } - } - - if (p_what == NOTIFICATION_TRANSLATION_CHANGED) { - child_controls_changed(); - } + if (transient) { + _make_transient(); + } + if (visible) { + notification(NOTIFICATION_VISIBILITY_CHANGED); + emit_signal(SceneStringNames::get_singleton()->visibility_changed); + RS::get_singleton()->viewport_set_active(get_viewport_rid(), true); + } + } break; + case NOTIFICATION_READY: { + if (wrap_controls) { + _update_child_controls(); + } + } break; + case NOTIFICATION_TRANSLATION_CHANGED: { + if (embedder) { + embedder->_sub_window_update(this); + } else if (window_id != DisplayServer::INVALID_WINDOW_ID) { + DisplayServer::get_singleton()->window_set_title(atr(title), window_id); + } - if (p_what == NOTIFICATION_EXIT_TREE) { - if (transient) { - _clear_transient(); - } + child_controls_changed(); + } break; + case NOTIFICATION_EXIT_TREE: { + if (transient) { + _clear_transient(); + } - if (!is_embedded() && window_id != DisplayServer::INVALID_WINDOW_ID) { - if (window_id == DisplayServer::MAIN_WINDOW_ID) { - RS::get_singleton()->viewport_set_update_mode(get_viewport_rid(), RS::VIEWPORT_UPDATE_DISABLED); - _update_window_callbacks(); + if (!is_embedded() && window_id != DisplayServer::INVALID_WINDOW_ID) { + if (window_id == DisplayServer::MAIN_WINDOW_ID) { + RS::get_singleton()->viewport_set_update_mode(get_viewport_rid(), RS::VIEWPORT_UPDATE_DISABLED); + _update_window_callbacks(); + } else { + _clear_window(); + } } else { - _clear_window(); - } - } else { - if (embedder) { - embedder->_sub_window_remove(this); - embedder = nullptr; - RS::get_singleton()->viewport_set_update_mode(get_viewport_rid(), RS::VIEWPORT_UPDATE_DISABLED); + if (embedder) { + embedder->_sub_window_remove(this); + embedder = nullptr; + RS::get_singleton()->viewport_set_update_mode(get_viewport_rid(), RS::VIEWPORT_UPDATE_DISABLED); + } + _update_viewport_size(); //called by clear and make, which does not happen here } - _update_viewport_size(); //called by clear and make, which does not happen here - } - RS::get_singleton()->viewport_set_active(get_viewport_rid(), false); + RS::get_singleton()->viewport_set_active(get_viewport_rid(), false); + } break; } } @@ -882,7 +886,7 @@ void Window::child_controls_changed() { } updating_child_controls = true; - call_deferred("_update_child_controls"); + call_deferred(SNAME("_update_child_controls")); } bool Window::_can_consume_input_events() const { @@ -925,7 +929,7 @@ void Window::_window_input_text(const String &p_text) { } void Window::_window_drop_files(const Vector<String> &p_files) { - emit_signal("files_dropped", p_files, current_screen); + emit_signal(SNAME("files_dropped"), p_files, current_screen); } Viewport *Window::get_parent_viewport() const { @@ -1043,7 +1047,7 @@ void Window::popup_centered_ratio(float p_ratio) { } void Window::popup(const Rect2i &p_screen_rect) { - emit_signal("about_to_popup"); + emit_signal(SNAME("about_to_popup")); // Update window size to calculate the actual window size based on contents minimum size and minimum size. _update_window_size(); @@ -1325,14 +1329,14 @@ bool Window::is_layout_rtl() const { if (parent) { return parent->is_layout_rtl(); } else { - if (GLOBAL_GET("internationalization/rendering/force_right_to_left_layout_direction")) { + if (GLOBAL_GET(SNAME("internationalization/rendering/force_right_to_left_layout_direction"))) { return true; } String locale = TranslationServer::get_singleton()->get_tool_locale(); return TS->is_locale_right_to_left(locale); } } else if (layout_dir == LAYOUT_DIRECTION_LOCALE) { - if (GLOBAL_GET("internationalization/rendering/force_right_to_left_layout_direction")) { + if (GLOBAL_GET(SNAME("internationalization/rendering/force_right_to_left_layout_direction"))) { return true; } String locale = TranslationServer::get_singleton()->get_tool_locale(); @@ -1342,6 +1346,20 @@ bool Window::is_layout_rtl() const { } } +void Window::set_auto_translate(bool p_enable) { + if (p_enable == auto_translate) { + return; + } + + auto_translate = p_enable; + + notification(MainLoop::NOTIFICATION_TRANSLATION_CHANGED); +} + +bool Window::is_auto_translating() const { + return auto_translate; +} + void Window::_validate_property(PropertyInfo &property) const { if (property.name == "theme_type_variation") { List<StringName> names; @@ -1356,14 +1374,14 @@ void Window::_validate_property(PropertyInfo &property) const { Vector<StringName> unique_names; String hint_string; - for (List<StringName>::Element *E = names.front(); E; E = E->next()) { + for (const StringName &E : names) { // Skip duplicate values. - if (unique_names.has(E->get())) { + if (unique_names.has(E)) { continue; } - hint_string += String(E->get()) + ","; - unique_names.append(E->get()); + hint_string += String(E) + ","; + unique_names.append(E); } property.hint_string = hint_string; @@ -1468,6 +1486,9 @@ void Window::_bind_methods() { ClassDB::bind_method(D_METHOD("get_layout_direction"), &Window::get_layout_direction); ClassDB::bind_method(D_METHOD("is_layout_rtl"), &Window::is_layout_rtl); + ClassDB::bind_method(D_METHOD("set_auto_translate", "enable"), &Window::set_auto_translate); + ClassDB::bind_method(D_METHOD("is_auto_translating"), &Window::is_auto_translating); + ClassDB::bind_method(D_METHOD("popup", "rect"), &Window::popup, DEFVAL(Rect2i())); ClassDB::bind_method(D_METHOD("popup_on_parent", "parent_rect"), &Window::popup_on_parent); ClassDB::bind_method(D_METHOD("popup_centered_ratio", "ratio"), &Window::popup_centered_ratio, DEFVAL(0.8)); @@ -1479,6 +1500,7 @@ void Window::_bind_methods() { ADD_PROPERTY(PropertyInfo(Variant::VECTOR2I, "size"), "set_size", "get_size"); ADD_PROPERTY(PropertyInfo(Variant::INT, "mode", PROPERTY_HINT_ENUM, "Windowed,Minimized,Maximized,Fullscreen"), "set_mode", "get_mode"); ADD_PROPERTY(PropertyInfo(Variant::STRING, "current_screen"), "set_current_screen", "get_current_screen"); + ADD_GROUP("Flags", ""); ADD_PROPERTY(PropertyInfo(Variant::BOOL, "visible"), "set_visible", "is_visible"); ADD_PROPERTY(PropertyInfo(Variant::BOOL, "wrap_controls"), "set_wrap_controls", "is_wrapping_controls"); @@ -1489,17 +1511,23 @@ void Window::_bind_methods() { ADD_PROPERTYI(PropertyInfo(Variant::BOOL, "always_on_top"), "set_flag", "get_flag", FLAG_ALWAYS_ON_TOP); ADD_PROPERTYI(PropertyInfo(Variant::BOOL, "transparent"), "set_flag", "get_flag", FLAG_TRANSPARENT); ADD_PROPERTYI(PropertyInfo(Variant::BOOL, "unfocusable"), "set_flag", "get_flag", FLAG_NO_FOCUS); + ADD_GROUP("Limits", ""); ADD_PROPERTY(PropertyInfo(Variant::VECTOR2I, "min_size"), "set_min_size", "get_min_size"); ADD_PROPERTY(PropertyInfo(Variant::VECTOR2I, "max_size"), "set_max_size", "get_max_size"); + ADD_GROUP("Content Scale", "content_scale_"); ADD_PROPERTY(PropertyInfo(Variant::VECTOR2I, "content_scale_size"), "set_content_scale_size", "get_content_scale_size"); ADD_PROPERTY(PropertyInfo(Variant::INT, "content_scale_mode", PROPERTY_HINT_ENUM, "Disabled,Canvas Items,Viewport"), "set_content_scale_mode", "get_content_scale_mode"); ADD_PROPERTY(PropertyInfo(Variant::INT, "content_scale_aspect", PROPERTY_HINT_ENUM, "Ignore,Keep,Keep Width,Keep Height,Expand"), "set_content_scale_aspect", "get_content_scale_aspect"); + ADD_GROUP("Theme", "theme_"); ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "theme", PROPERTY_HINT_RESOURCE_TYPE, "Theme"), "set_theme", "get_theme"); ADD_PROPERTY(PropertyInfo(Variant::STRING, "theme_type_variation", PROPERTY_HINT_ENUM_SUGGESTION), "set_theme_type_variation", "get_theme_type_variation"); + ADD_GROUP("Auto Translate", ""); + ADD_PROPERTY(PropertyInfo(Variant::BOOL, "auto_translate"), "set_auto_translate", "is_auto_translating"); + ADD_SIGNAL(MethodInfo("window_input", PropertyInfo(Variant::OBJECT, "event", PROPERTY_HINT_RESOURCE_TYPE, "InputEvent"))); ADD_SIGNAL(MethodInfo("files_dropped", PropertyInfo(Variant::PACKED_STRING_ARRAY, "files"))); ADD_SIGNAL(MethodInfo("mouse_entered")); diff --git a/scene/main/window.h b/scene/main/window.h index e92b5e22ed..7013694a06 100644 --- a/scene/main/window.h +++ b/scene/main/window.h @@ -103,6 +103,8 @@ private: LayoutDirection layout_dir = LAYOUT_DIRECTION_INHERITED; + bool auto_translate = true; + void _update_child_controls(); Size2i content_scale_size; @@ -256,6 +258,10 @@ public: LayoutDirection get_layout_direction() const; bool is_layout_rtl() const; + void set_auto_translate(bool p_enable); + bool is_auto_translating() const; + _FORCE_INLINE_ String atr(const String p_string) const { return is_auto_translating() ? tr(p_string) : p_string; }; + Rect2i get_usable_parent_rect() const; Ref<Texture2D> get_theme_icon(const StringName &p_name, const StringName &p_theme_type = StringName()) const; diff --git a/scene/register_scene_types.cpp b/scene/register_scene_types.cpp index 9efe5c58fc..8ede8e9a0b 100644 --- a/scene/register_scene_types.cpp +++ b/scene/register_scene_types.cpp @@ -586,7 +586,7 @@ void register_scene_types() { GDREGISTER_CLASS(VisualShaderNodeTransformDecompose); GDREGISTER_CLASS(VisualShaderNodeTexture); GDREGISTER_CLASS(VisualShaderNodeCurveTexture); - GDREGISTER_CLASS(VisualShaderNodeCurve3Texture); + GDREGISTER_CLASS(VisualShaderNodeCurveXYZTexture); GDREGISTER_VIRTUAL_CLASS(VisualShaderNodeSample3D); GDREGISTER_CLASS(VisualShaderNodeTexture2DArray); GDREGISTER_CLASS(VisualShaderNodeTexture3D); @@ -775,7 +775,7 @@ void register_scene_types() { GDREGISTER_CLASS(AtlasTexture); GDREGISTER_CLASS(MeshTexture); GDREGISTER_CLASS(CurveTexture); - GDREGISTER_CLASS(Curve3Texture); + GDREGISTER_CLASS(CurveXYZTexture); GDREGISTER_CLASS(GradientTexture); GDREGISTER_CLASS(ProxyTexture); GDREGISTER_CLASS(AnimatedTexture); @@ -909,7 +909,6 @@ void register_scene_types() { ClassDB::add_compatibility_class("Generic6DOFJoint", "Generic6DOFJoint3D"); ClassDB::add_compatibility_class("HeightMapShape", "HeightMapShape3D"); ClassDB::add_compatibility_class("HingeJoint", "HingeJoint3D"); - ClassDB::add_compatibility_class("ImmediateGeometry", "ImmediateGeometry3D"); ClassDB::add_compatibility_class("Joint", "Joint3D"); ClassDB::add_compatibility_class("KinematicBody", "CharacterBody3D"); ClassDB::add_compatibility_class("KinematicBody2D", "CharacterBody2D"); @@ -1085,6 +1084,10 @@ void unregister_scene_types() { BaseMaterial3D::finish_shaders(); #endif // _3D_DISABLED + PhysicalSkyMaterial::cleanup_shader(); + PanoramaSkyMaterial::cleanup_shader(); + ProceduralSkyMaterial::cleanup_shader(); + ParticlesMaterial::finish_shaders(); CanvasItemMaterial::finish_shaders(); ColorPicker::finish_shaders(); diff --git a/scene/resources/animation.h b/scene/resources/animation.h index 1484007333..920ee2e5ab 100644 --- a/scene/resources/animation.h +++ b/scene/resources/animation.h @@ -228,8 +228,8 @@ private: value_track_get_key_indices(p_track, p_time, p_delta, &idxs); Vector<int> idxr; - for (List<int>::Element *E = idxs.front(); E; E = E->next()) { - idxr.push_back(E->get()); + for (int &E : idxs) { + idxr.push_back(E); } return idxr; } @@ -238,8 +238,8 @@ private: method_track_get_key_indices(p_track, p_time, p_delta, &idxs); Vector<int> idxr; - for (List<int>::Element *E = idxs.front(); E; E = E->next()) { - idxr.push_back(E->get()); + for (int &E : idxs) { + idxr.push_back(E); } return idxr; } diff --git a/scene/resources/curve.cpp b/scene/resources/curve.cpp index 846da39221..c13db83d6d 100644 --- a/scene/resources/curve.cpp +++ b/scene/resources/curve.cpp @@ -286,7 +286,7 @@ void Curve::set_min_value(float p_min) { } // Note: min and max are indicative values, // it's still possible that existing points are out of range at this point. - emit_signal(SIGNAL_RANGE_CHANGED); + emit_signal(SNAME(SIGNAL_RANGE_CHANGED)); } void Curve::set_max_value(float p_max) { @@ -296,7 +296,7 @@ void Curve::set_max_value(float p_max) { _minmax_set_once |= 0b01; // second bit is "max set" _max_value = p_max; } - emit_signal(SIGNAL_RANGE_CHANGED); + emit_signal(SNAME(SIGNAL_RANGE_CHANGED)); } real_t Curve::interpolate(real_t offset) const { @@ -729,8 +729,8 @@ void Curve2D::_bake() const { Vector2 *w = baked_point_cache.ptrw(); int idx = 0; - for (List<Vector2>::Element *E = pointlist.front(); E; E = E->next()) { - w[idx] = E->get(); + for (const Vector2 &E : pointlist) { + w[idx] = E; idx++; } } @@ -1239,9 +1239,9 @@ void Curve3D::_bake() const { Vector3 prev_up = Vector3(0, 1, 0); Vector3 prev_forward = Vector3(0, 0, 1); - for (List<Plane>::Element *E = pointlist.front(); E; E = E->next()) { - w[idx] = E->get().normal; - wt[idx] = E->get().d; + for (const Plane &E : pointlist) { + w[idx] = E.normal; + wt[idx] = E.d; if (!up_vector_enabled) { idx++; diff --git a/scene/resources/default_theme/default_theme.cpp b/scene/resources/default_theme/default_theme.cpp index 1bbb84f43d..a4e126fcc6 100644 --- a/scene/resources/default_theme/default_theme.cpp +++ b/scene/resources/default_theme/default_theme.cpp @@ -571,10 +571,9 @@ void fill_default_theme(Ref<Theme> &theme, const Ref<Font> &default_font, const empty.instantiate(); theme->set_stylebox("bg", "ScrollContainer", empty); - // WindowDialog + // Window - theme->set_stylebox("panel", "Window", default_style); - theme->set_stylebox("window_panel", "Window", sb_expand(make_stylebox(popup_window_png, 10, 26, 10, 8), 8, 24, 8, 6)); + theme->set_stylebox("embedded_border", "Window", sb_expand(make_stylebox(popup_window_png, 10, 26, 10, 8), 8, 24, 8, 6)); theme->set_constant("scaleborder_size", "Window", 4 * scale); theme->set_font("title_font", "Window", large_font); @@ -588,10 +587,14 @@ void fill_default_theme(Ref<Theme> &theme, const Ref<Font> &default_font, const theme->set_constant("resize_margin", "Window", 4 * scale); theme->set_icon("close", "Window", make_icon(close_png)); - theme->set_icon("close_highlight", "Window", make_icon(close_hl_png)); + theme->set_icon("close_pressed", "Window", make_icon(close_hl_png)); theme->set_constant("close_h_ofs", "Window", 18 * scale); theme->set_constant("close_v_ofs", "Window", 18 * scale); + // AcceptDialog + + theme->set_stylebox("panel", "AcceptDialog", make_stylebox(dialog_bg_png, 0, 0, 0, 0)); + // File Dialog theme->set_icon("parent_folder", "FileDialog", make_icon(icon_parent_folder_png)); diff --git a/scene/resources/default_theme/dialog_bg.png b/scene/resources/default_theme/dialog_bg.png Binary files differnew file mode 100644 index 0000000000..a23a10b48a --- /dev/null +++ b/scene/resources/default_theme/dialog_bg.png diff --git a/scene/resources/default_theme/popup_window.png b/scene/resources/default_theme/popup_window.png Binary files differindex 174a29ef45..442084049d 100644 --- a/scene/resources/default_theme/popup_window.png +++ b/scene/resources/default_theme/popup_window.png diff --git a/scene/resources/default_theme/theme_data.h b/scene/resources/default_theme/theme_data.h index 7d747e3c9e..cdb1bc527b 100644 --- a/scene/resources/default_theme/theme_data.h +++ b/scene/resources/default_theme/theme_data.h @@ -70,6 +70,10 @@ static const unsigned char color_picker_sample_png[] = { 0x89, 0x50, 0x4e, 0x47, 0xd, 0xa, 0x1a, 0xa, 0x0, 0x0, 0x0, 0xd, 0x49, 0x48, 0x44, 0x52, 0x0, 0x0, 0x1, 0x0, 0x0, 0x0, 0x0, 0x14, 0x8, 0x0, 0x0, 0x0, 0x0, 0x47, 0x29, 0xbc, 0x83, 0x0, 0x0, 0x0, 0x3c, 0x49, 0x44, 0x41, 0x54, 0x78, 0xda, 0xed, 0xd5, 0x21, 0x11, 0x0, 0x30, 0xc, 0x4, 0xc1, 0xfa, 0x57, 0x53, 0x87, 0xed, 0x4, 0x45, 0xc4, 0xed, 0xa3, 0xc3, 0x4b, 0xfe, 0xbc, 0xd9, 0x9d, 0x35, 0x2b, 0xe, 0x0, 0x0, 0x0, 0x80, 0xed, 0x66, 0xc5, 0x1, 0x0, 0x0, 0x0, 0xe0, 0x6, 0x1, 0x0, 0x0, 0x90, 0x6, 0x70, 0x83, 0x0, 0x0, 0x0, 0x28, 0x3, 0x7c, 0x54, 0x93, 0xd6, 0xf1, 0xd1, 0x16, 0x8a, 0x17, 0x0, 0x0, 0x0, 0x0, 0x49, 0x45, 0x4e, 0x44, 0xae, 0x42, 0x60, 0x82 }; +static const unsigned char dialog_bg_png[] = { + 0x89, 0x50, 0x4e, 0x47, 0xd, 0xa, 0x1a, 0xa, 0x0, 0x0, 0x0, 0xd, 0x49, 0x48, 0x44, 0x52, 0x0, 0x0, 0x0, 0x16, 0x0, 0x0, 0x0, 0x26, 0x8, 0x3, 0x0, 0x0, 0x0, 0xf7, 0x10, 0x9b, 0xa4, 0x0, 0x0, 0x2, 0xf5, 0x7a, 0x54, 0x58, 0x74, 0x52, 0x61, 0x77, 0x20, 0x70, 0x72, 0x6f, 0x66, 0x69, 0x6c, 0x65, 0x20, 0x74, 0x79, 0x70, 0x65, 0x20, 0x65, 0x78, 0x69, 0x66, 0x0, 0x0, 0x78, 0xda, 0xb5, 0x95, 0x6d, 0x72, 0xe4, 0x28, 0xc, 0x86, 0xff, 0x73, 0x8a, 0x3d, 0x2, 0xfa, 0x42, 0x70, 0x1c, 0xc, 0xa6, 0x6a, 0x6f, 0xb0, 0xc7, 0x9f, 0x17, 0xec, 0x38, 0xd9, 0x4c, 0x57, 0xda, 0x49, 0xcf, 0x40, 0xb5, 0xa5, 0x92, 0x5, 0x12, 0x3c, 0x92, 0x3b, 0xec, 0xff, 0xfd, 0x3b, 0xc2, 0x3f, 0x18, 0xa4, 0x39, 0x6, 0x35, 0xcf, 0xa9, 0xa4, 0x14, 0x31, 0xb4, 0x68, 0xe1, 0xa, 0x25, 0xc7, 0xf7, 0xb1, 0x9f, 0xf2, 0xb0, 0x51, 0xd4, 0xf5, 0x5c, 0xa3, 0xe8, 0xf9, 0x8e, 0x22, 0x85, 0x8f, 0x2f, 0x2e, 0x8d, 0x21, 0x5, 0x52, 0xe, 0xa3, 0xbf, 0x2d, 0x90, 0xd3, 0xfe, 0xe6, 0x9f, 0x2e, 0x89, 0x8d, 0x1e, 0xbc, 0x20, 0xfb, 0xb4, 0x40, 0xae, 0x30, 0xfc, 0x31, 0xb0, 0xd7, 0xd3, 0xce, 0x91, 0xff, 0x97, 0x91, 0x7a, 0xb4, 0xf8, 0x71, 0xe4, 0xf7, 0xdf, 0x18, 0x3d, 0x8f, 0xb1, 0x1f, 0xa7, 0xab, 0x9a, 0x70, 0xd, 0xe9, 0x38, 0xd4, 0x11, 0x22, 0xbc, 0x6d, 0x3, 0xc7, 0xd, 0x5b, 0xc9, 0x5a, 0x96, 0x30, 0x1d, 0x3f, 0x83, 0xee, 0x6b, 0x16, 0xcc, 0x1c, 0x6b, 0x6c, 0xa4, 0xb1, 0xc7, 0x16, 0x37, 0xcc, 0x46, 0x85, 0x98, 0x24, 0xe, 0x52, 0xea, 0x81, 0x2a, 0xd, 0xda, 0xa9, 0x43, 0x36, 0x6a, 0xc8, 0x51, 0x79, 0x67, 0x87, 0x64, 0x6e, 0x2c, 0xcb, 0x96, 0xc5, 0xb9, 0x70, 0x93, 0x28, 0x24, 0x3a, 0x27, 0xd, 0x76, 0x29, 0xd2, 0x25, 0xb, 0x4b, 0xe3, 0x5d, 0x44, 0x34, 0x8, 0x5f, 0xb9, 0xd0, 0x8a, 0x5b, 0x56, 0xbc, 0x46, 0x19, 0x91, 0x3b, 0xc1, 0x95, 0x9, 0x9b, 0x11, 0x96, 0x7c, 0x39, 0xc3, 0x33, 0x87, 0x3b, 0x73, 0x8c, 0x16, 0x71, 0x47, 0x44, 0x38, 0x3d, 0x9d, 0x75, 0x81, 0xbc, 0x98, 0x27, 0x7, 0x9a, 0xd7, 0x28, 0xf3, 0x9, 0x37, 0x0, 0xa1, 0x71, 0x72, 0xb3, 0x75, 0xc1, 0x6f, 0xf3, 0x1a, 0xe1, 0x3, 0x58, 0x1, 0x41, 0x5b, 0xd7, 0x9c, 0x71, 0xc0, 0x1a, 0xb7, 0x63, 0x8b, 0xcd, 0xe8, 0xbd, 0xb6, 0x64, 0x15, 0x80, 0xc0, 0xcf, 0x20, 0x8f, 0xfa, 0x22, 0xef, 0x93, 0x1a, 0xaf, 0x2a, 0x51, 0xc4, 0x36, 0x24, 0x43, 0x2, 0x4, 0x31, 0x91, 0x18, 0x25, 0x8a, 0xce, 0xec, 0x44, 0x2a, 0x9c, 0x1, 0xa8, 0x22, 0x73, 0x16, 0xe5, 0xd, 0x4, 0xc8, 0x8c, 0x3b, 0x92, 0x64, 0x15, 0x49, 0x60, 0x93, 0x51, 0x47, 0x88, 0x8d, 0x35, 0x4e, 0xcb, 0x97, 0x8d, 0xf, 0x3b, 0x5a, 0x5, 0x7c, 0x4c, 0x92, 0x38, 0xd8, 0x14, 0xa9, 0x80, 0xa5, 0x6a, 0xa8, 0x1f, 0xd7, 0x8c, 0x1a, 0xaa, 0x26, 0xa6, 0x66, 0x96, 0xcc, 0x2d, 0x5b, 0xb1, 0x1a, 0x92, 0x24, 0x4d, 0x96, 0x52, 0xf2, 0x34, 0x7b, 0xae, 0xba, 0xb8, 0xba, 0x79, 0x72, 0xf7, 0xec, 0xc5, 0x6b, 0x96, 0xac, 0xd9, 0x72, 0xca, 0x9e, 0x73, 0x2e, 0xb9, 0x16, 0x2e, 0x82, 0x96, 0xb4, 0x92, 0x8a, 0x97, 0x5c, 0x4a, 0xa9, 0x15, 0x31, 0xab, 0x86, 0x6a, 0x15, 0xab, 0x2b, 0x3c, 0x6a, 0xdd, 0x78, 0x93, 0x4d, 0x37, 0xdb, 0xd2, 0xe6, 0x5b, 0xde, 0xca, 0x56, 0x1b, 0xca, 0xa7, 0x69, 0xb3, 0x96, 0x9a, 0xb7, 0xdc, 0x4a, 0xab, 0x9d, 0xbb, 0x74, 0xed, 0xd6, 0x53, 0xf7, 0x9e, 0x7b, 0xe9, 0x75, 0xa7, 0x1d, 0xa5, 0x14, 0x76, 0xdd, 0x6d, 0x4f, 0xbb, 0xef, 0x79, 0x2f, 0x7b, 0x1d, 0xa8, 0xb5, 0x21, 0x43, 0x87, 0x8d, 0x34, 0x7c, 0xe4, 0x51, 0x46, 0xbd, 0xa8, 0xd1, 0xd9, 0xb6, 0x9f, 0xe7, 0x37, 0xa8, 0xd1, 0x49, 0x8d, 0x17, 0xa9, 0xe9, 0xe7, 0x17, 0x35, 0x58, 0xdd, 0xe7, 0x46, 0x6b, 0xb, 0x9a, 0xdf, 0x19, 0x9b, 0xcc, 0x40, 0x8c, 0x95, 0x40, 0xdc, 0x27, 0x1, 0x14, 0x34, 0x4f, 0x66, 0x31, 0x93, 0x2a, 0x4f, 0x72, 0x93, 0x59, 0x2c, 0x8c, 0xae, 0x30, 0x46, 0x92, 0x36, 0xd9, 0x74, 0x8a, 0x35, 0x50, 0x2, 0x42, 0xdd, 0x89, 0x6d, 0xd0, 0xc5, 0xee, 0x9d, 0xdc, 0x6d, 0x6e, 0x1, 0x77, 0xfd, 0x8c, 0x1b, 0xdf, 0x21, 0x17, 0x26, 0xba, 0x3f, 0x40, 0x8e, 0xc3, 0x2e, 0x9f, 0xb8, 0x3d, 0xa0, 0xd6, 0xe7, 0x97, 0xb0, 0x2d, 0x62, 0x47, 0x17, 0xce, 0x3b, 0x8d, 0x82, 0xee, 0x83, 0x6f, 0xe5, 0x5c, 0x79, 0x53, 0x50, 0x5b, 0x5a, 0x7e, 0x55, 0xfe, 0x85, 0x8d, 0x68, 0x9, 0x1c, 0xe2, 0x67, 0x32, 0x3c, 0x7c, 0xa1, 0x6b, 0xe7, 0xf4, 0x1d, 0x25, 0xdc, 0x70, 0x42, 0xce, 0x65, 0x85, 0xb0, 0x2f, 0x94, 0x70, 0xc7, 0xe9, 0x37, 0xe5, 0x41, 0xd2, 0xe1, 0x47, 0xe7, 0x78, 0x90, 0x74, 0x40, 0x91, 0x8a, 0xa6, 0x74, 0x1a, 0x5b, 0xa7, 0x72, 0x86, 0xfe, 0xa6, 0x39, 0xdc, 0x72, 0x47, 0x97, 0x1b, 0xa1, 0xbf, 0xf0, 0x3f, 0x8c, 0xe, 0x7d, 0xa8, 0x84, 0x2f, 0xde, 0x7d, 0xad, 0x90, 0x1a, 0xdb, 0xc, 0xb1, 0x2d, 0x25, 0x5c, 0xda, 0x8b, 0x4a, 0x38, 0xb3, 0x2e, 0x15, 0xa7, 0x39, 0x8c, 0x38, 0x53, 0xeb, 0x67, 0xe8, 0xfb, 0xe6, 0x70, 0xdb, 0xfd, 0x49, 0xa9, 0x86, 0x17, 0xa9, 0x5f, 0x5c, 0xc2, 0x8b, 0xd4, 0x2f, 0x73, 0x78, 0x4e, 0xdd, 0x6e, 0xc9, 0x70, 0xd7, 0xf1, 0x59, 0x3d, 0x84, 0x17, 0xca, 0x88, 0x3e, 0xca, 0xf0, 0xd9, 0xf0, 0x53, 0xf9, 0xe7, 0x36, 0xf2, 0x81, 0x8f, 0x7b, 0x81, 0xf2, 0xb, 0x12, 0xea, 0xac, 0x15, 0x79, 0x70, 0x44, 0x63, 0x0, 0x0, 0x1, 0x68, 0x50, 0x4c, 0x54, 0x45, 0x0, 0x0, 0x0, 0xe8, 0xe5, 0xf1, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x1f, 0x1d, 0x22, 0x0, 0x0, 0x0, 0x1a, 0x19, 0x1c, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x20, 0x1e, 0x23, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x1f, 0x1d, 0x21, 0x17, 0x16, 0x19, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x21, 0x1f, 0x24, 0x1b, 0x1a, 0x1d, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x21, 0x1f, 0x24, 0x1e, 0x1c, 0x20, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x22, 0x20, 0x25, 0x20, 0x1e, 0x23, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x21, 0x1f, 0x24, 0x0, 0x0, 0x0, 0x21, 0x1f, 0x24, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x22, 0x20, 0x25, 0x0, 0x0, 0x0, 0x20, 0x20, 0x25, 0x20, 0x1d, 0x25, 0x20, 0x1d, 0x22, 0x1d, 0x1d, 0x22, 0x1d, 0x1d, 0x20, 0x1d, 0x1a, 0x20, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x32, 0x30, 0x38, 0xe8, 0xe5, 0xf1, 0xe5, 0xe2, 0xeb, 0xe3, 0xe1, 0xe8, 0xe1, 0xdf, 0xe7, 0xe0, 0xde, 0xe6, 0xdf, 0xdd, 0xe5, 0xde, 0xdc, 0xe4, 0xdd, 0xdb, 0xe3, 0xdc, 0xda, 0xe2, 0xda, 0xd8, 0xe0, 0xd9, 0xd7, 0xdf, 0xd7, 0xd6, 0xdf, 0xd6, 0xd4, 0xdd, 0xd5, 0xd3, 0xdc, 0xd4, 0xd1, 0xdb, 0xd3, 0xd0, 0xda, 0xd1, 0xce, 0xd8, 0xd0, 0xcd, 0xd7, 0xcf, 0xcd, 0xd7, 0xe2, 0xdf, 0xeb, 0x48, 0x46, 0x51, 0x42, 0x40, 0x4b, 0x40, 0x3e, 0x48, 0x40, 0x3d, 0x48, 0x48, 0x45, 0x50, 0x42, 0x3f, 0x4a, 0x3f, 0x3d, 0x48, 0x47, 0x44, 0x50, 0x41, 0x3f, 0x4a, 0x3f, 0x3d, 0x47, 0x41, 0x3e, 0x49, 0x3f, 0x3c, 0x47, 0x46, 0x43, 0x4f, 0x3e, 0x3c, 0x46, 0x40, 0x3e, 0x49, 0x3d, 0x3b, 0x46, 0x45, 0x43, 0x4e, 0x3d, 0x3b, 0x45, 0x44, 0x42, 0x4d, 0x3d, 0x3a, 0x45, 0x3e, 0x3c, 0x47, 0x3c, 0x3a, 0x44, 0x43, 0x42, 0x4c, 0x43, 0x40, 0x4c, 0x3e, 0x3b, 0x46, 0x3b, 0x39, 0x43, 0x43, 0x3f, 0x4c, 0x43, 0x3f, 0x4b, 0x3a, 0x38, 0x42, 0x42, 0x3e, 0x4b, 0x42, 0x3e, 0x49, 0x3a, 0x37, 0x41, 0x39, 0x37, 0x41, 0x3f, 0x3e, 0x48, 0x39, 0x37, 0x40, 0x38, 0x36, 0x40, 0x3e, 0x3d, 0x48, 0x38, 0x36, 0x3f, 0x3e, 0x3d, 0x47, 0x3a, 0x38, 0x41, 0x38, 0x35, 0x3f, 0x37, 0x35, 0x3e, 0x39, 0x36, 0x40, 0x37, 0x34, 0x3e, 0x3d, 0x3a, 0x46, 0x36, 0x34, 0x3d, 0x3d, 0x3a, 0x44, 0x37, 0x35, 0x3f, 0x35, 0x33, 0x3c, 0x6b, 0xff, 0x8f, 0xb1, 0x0, 0x0, 0x0, 0x1, 0x62, 0x4b, 0x47, 0x44, 0x0, 0x88, 0x5, 0x1d, 0x48, 0x0, 0x0, 0x0, 0x9, 0x70, 0x48, 0x59, 0x73, 0x0, 0x0, 0xb, 0x13, 0x0, 0x0, 0xb, 0x13, 0x1, 0x0, 0x9a, 0x9c, 0x18, 0x0, 0x0, 0x0, 0x7, 0x74, 0x49, 0x4d, 0x45, 0x7, 0xe5, 0x7, 0x1b, 0x17, 0x11, 0x18, 0xe6, 0xb9, 0x22, 0xac, 0x0, 0x0, 0x0, 0x3f, 0x49, 0x44, 0x41, 0x54, 0x28, 0xcf, 0x63, 0xf4, 0x64, 0xc0, 0x6, 0x98, 0x18, 0x68, 0x27, 0xcc, 0xc2, 0x88, 0x5d, 0x98, 0x99, 0x24, 0x61, 0x26, 0x52, 0x84, 0x71, 0xb9, 0x84, 0x89, 0x76, 0xc2, 0xb8, 0xac, 0x64, 0x21, 0x49, 0x35, 0x33, 0x15, 0x54, 0xe3, 0xa, 0x6f, 0x26, 0x6a, 0xa8, 0x26, 0xc9, 0x4a, 0xaa, 0x44, 0x3, 0x89, 0x89, 0x8d, 0x99, 0xee, 0xe9, 0x1b, 0x87, 0x30, 0x0, 0x20, 0x4, 0x0, 0xed, 0x48, 0xa7, 0x26, 0x6c, 0x0, 0x0, 0x0, 0x0, 0x49, 0x45, 0x4e, 0x44, 0xae, 0x42, 0x60, 0x82 +}; + static const unsigned char dropdown_png[] = { 0x89, 0x50, 0x4e, 0x47, 0xd, 0xa, 0x1a, 0xa, 0x0, 0x0, 0x0, 0xd, 0x49, 0x48, 0x44, 0x52, 0x0, 0x0, 0x0, 0x8, 0x0, 0x0, 0x0, 0x8, 0x8, 0x4, 0x0, 0x0, 0x0, 0x6e, 0x6, 0x76, 0x0, 0x0, 0x0, 0x0, 0x4c, 0x49, 0x44, 0x41, 0x54, 0x78, 0xda, 0x63, 0x60, 0x60, 0xf8, 0xc0, 0xcc, 0x0, 0x2, 0x60, 0x16, 0x98, 0x78, 0x67, 0x8, 0x81, 0x6f, 0x4d, 0xde, 0x9a, 0x0, 0x5, 0xde, 0x3a, 0x3d, 0xfc, 0x8f, 0x80, 0xaf, 0xba, 0x18, 0xde, 0x29, 0x2, 0x19, 0xbf, 0x61, 0x2, 0x6f, 0x62, 0x18, 0x3e, 0xb0, 0xbd, 0x97, 0x4, 0x32, 0xff, 0x80, 0xb9, 0xb1, 0x20, 0x93, 0xc0, 0x42, 0x8, 0x2e, 0x54, 0xe8, 0x9d, 0xdc, 0x9b, 0x54, 0x10, 0xb, 0x21, 0xc4, 0x4, 0x63, 0x1, 0x0, 0x86, 0x1f, 0x3b, 0x1e, 0x92, 0x22, 0x3f, 0x40, 0x0, 0x0, 0x0, 0x0, 0x49, 0x45, 0x4e, 0x44, 0xae, 0x42, 0x60, 0x82 }; @@ -283,7 +287,7 @@ static const unsigned char popup_bg_disabled_png[] = { }; static const unsigned char popup_window_png[] = { - 0x89, 0x50, 0x4e, 0x47, 0xd, 0xa, 0x1a, 0xa, 0x0, 0x0, 0x0, 0xd, 0x49, 0x48, 0x44, 0x52, 0x0, 0x0, 0x0, 0x2a, 0x0, 0x0, 0x0, 0x46, 0x8, 0x3, 0x0, 0x0, 0x0, 0x8d, 0x2b, 0xf6, 0x48, 0x0, 0x0, 0x1, 0x6b, 0x50, 0x4c, 0x54, 0x45, 0x0, 0x0, 0x0, 0xe8, 0xe5, 0xf1, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x1f, 0x1d, 0x22, 0x0, 0x0, 0x0, 0x1a, 0x19, 0x1c, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x20, 0x1e, 0x23, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x1f, 0x1d, 0x21, 0x17, 0x16, 0x19, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x21, 0x1f, 0x24, 0x1b, 0x1a, 0x1d, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x21, 0x1f, 0x24, 0x1e, 0x1c, 0x20, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x22, 0x20, 0x25, 0x20, 0x1e, 0x23, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x21, 0x1f, 0x24, 0x0, 0x0, 0x0, 0x21, 0x1f, 0x24, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x22, 0x20, 0x25, 0x0, 0x0, 0x0, 0x20, 0x20, 0x25, 0x20, 0x1d, 0x25, 0x20, 0x1d, 0x22, 0x1d, 0x1d, 0x22, 0x1d, 0x1d, 0x20, 0x1d, 0x1a, 0x20, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x32, 0x30, 0x38, 0xe8, 0xe5, 0xf1, 0xe5, 0xe2, 0xeb, 0xe3, 0xe1, 0xe8, 0xe1, 0xdf, 0xe7, 0xe0, 0xde, 0xe6, 0xdf, 0xdd, 0xe5, 0xde, 0xdc, 0xe4, 0xdd, 0xdb, 0xe3, 0xdc, 0xda, 0xe2, 0xda, 0xd8, 0xe0, 0xd9, 0xd7, 0xdf, 0xd7, 0xd6, 0xdf, 0xd6, 0xd4, 0xdd, 0xd5, 0xd3, 0xdc, 0xd4, 0xd1, 0xdb, 0xd3, 0xd0, 0xda, 0xd1, 0xce, 0xd8, 0xd0, 0xcd, 0xd7, 0xcf, 0xcd, 0xd7, 0xe2, 0xdf, 0xeb, 0x48, 0x46, 0x51, 0x42, 0x40, 0x4b, 0x40, 0x3e, 0x48, 0x40, 0x3d, 0x48, 0x48, 0x45, 0x50, 0x42, 0x3f, 0x4a, 0x3f, 0x3d, 0x48, 0x47, 0x44, 0x50, 0x41, 0x3f, 0x4a, 0x3f, 0x3d, 0x47, 0x41, 0x3e, 0x49, 0x3f, 0x3c, 0x47, 0x46, 0x43, 0x4f, 0x3e, 0x3c, 0x46, 0x40, 0x3e, 0x49, 0x3d, 0x3b, 0x46, 0x45, 0x43, 0x4e, 0x3d, 0x3b, 0x45, 0x44, 0x42, 0x4d, 0x3d, 0x3a, 0x45, 0x3e, 0x3c, 0x47, 0x3c, 0x3a, 0x44, 0x43, 0x42, 0x4c, 0x43, 0x40, 0x4c, 0x3e, 0x3b, 0x46, 0x3b, 0x39, 0x43, 0x43, 0x3f, 0x4c, 0x43, 0x3f, 0x4b, 0x3a, 0x38, 0x42, 0x42, 0x3e, 0x4b, 0x42, 0x3e, 0x49, 0x3a, 0x37, 0x41, 0x39, 0x37, 0x41, 0x3f, 0x3e, 0x48, 0x39, 0x37, 0x40, 0x38, 0x36, 0x40, 0x3e, 0x3d, 0x48, 0x38, 0x36, 0x3f, 0x3e, 0x3d, 0x47, 0x3a, 0x38, 0x41, 0x38, 0x35, 0x3f, 0x37, 0x35, 0x3e, 0x39, 0x36, 0x40, 0x37, 0x34, 0x3e, 0x3d, 0x3a, 0x46, 0x36, 0x34, 0x3d, 0x3d, 0x3a, 0x44, 0x37, 0x35, 0x3f, 0x35, 0x33, 0x3c, 0x46, 0x44, 0x4f, 0xac, 0xa5, 0x1, 0x25, 0x0, 0x0, 0x0, 0x33, 0x74, 0x52, 0x4e, 0x53, 0x0, 0xa2, 0x3, 0x9, 0x17, 0xc, 0x20, 0xf, 0x2a, 0x5e, 0x12, 0x30, 0x68, 0x46, 0x20, 0x4e, 0xa2, 0x7d, 0x3a, 0x4f, 0xa4, 0x7d, 0x3f, 0x25, 0x60, 0xc0, 0xb8, 0x57, 0x1d, 0xba, 0x59, 0xbd, 0x5b, 0x22, 0xbf, 0x5e, 0xc0, 0xc0, 0xc0, 0xc0, 0xc0, 0xc0, 0xa1, 0x9f, 0x9e, 0x52, 0x92, 0x15, 0x44, 0x7e, 0xd8, 0x5, 0xc7, 0xf4, 0xac, 0x0, 0x0, 0x1, 0x98, 0x49, 0x44, 0x41, 0x54, 0x78, 0xda, 0xed, 0xd6, 0x55, 0x9e, 0x14, 0x31, 0x10, 0x80, 0xf1, 0xb2, 0x20, 0x1d, 0xdc, 0x9d, 0x3b, 0x2c, 0xa7, 0x87, 0x4b, 0xe0, 0xee, 0xd0, 0x82, 0xcb, 0xea, 0xb4, 0x86, 0x79, 0x23, 0x93, 0xaa, 0xcc, 0xf, 0xd7, 0xfd, 0x9e, 0xff, 0xed, 0x1d, 0x21, 0xf8, 0xe2, 0xfe, 0x1c, 0x8a, 0x17, 0x32, 0xa1, 0xa2, 0x2b, 0x48, 0x66, 0xb8, 0xa2, 0x28, 0x10, 0x9a, 0xd1, 0xf7, 0x3d, 0x16, 0x66, 0xfa, 0x45, 0x74, 0x9b, 0xd2, 0x97, 0x52, 0xe2, 0x2f, 0xa6, 0x40, 0x5f, 0x4c, 0x1d, 0xf3, 0x97, 0x52, 0x5e, 0x46, 0xf7, 0xee, 0xe3, 0x88, 0x8a, 0x48, 0x9e, 0x8a, 0xec, 0x8c, 0x28, 0x2c, 0xa7, 0xf0, 0x99, 0xd2, 0x6e, 0xe7, 0x8e, 0x10, 0x9b, 0xd1, 0x11, 0xe7, 0xe, 0xd1, 0x17, 0x8e, 0x2, 0xe6, 0x55, 0xf8, 0x42, 0x4a, 0x74, 0x18, 0xbe, 0xf8, 0xac, 0x9b, 0x5f, 0x4a, 0xb7, 0x36, 0x20, 0xa5, 0xf9, 0x2f, 0x90, 0x50, 0x11, 0x36, 0x13, 0x49, 0xa9, 0xe7, 0x6c, 0x5e, 0xcf, 0x2e, 0x99, 0xf4, 0xd, 0xb8, 0x8c, 0x5, 0xa7, 0x28, 0x8, 0x98, 0x9, 0x68, 0xba, 0x41, 0x66, 0x1b, 0x8a, 0xa2, 0xb0, 0x4d, 0x59, 0x30, 0xa5, 0x94, 0xa3, 0x94, 0x52, 0x0, 0x6f, 0x53, 0x6f, 0x7c, 0x82, 0x16, 0xcc, 0x5a, 0x51, 0x14, 0xbd, 0x98, 0x79, 0x4c, 0x29, 0x72, 0xee, 0xac, 0x8c, 0xea, 0xac, 0xb9, 0x51, 0xa0, 0xce, 0xa, 0x44, 0x60, 0x46, 0xa4, 0x28, 0x2, 0x9b, 0x1, 0x2a, 0x5a, 0xa, 0x9a, 0x49, 0xa9, 0xe8, 0x79, 0x20, 0x33, 0x38, 0xaf, 0x68, 0xc5, 0x68, 0xc6, 0x95, 0xa2, 0xe7, 0x72, 0x67, 0x3d, 0x97, 0x52, 0x24, 0xcf, 0x66, 0x9e, 0x30, 0xa5, 0xef, 0x5a, 0x34, 0x6b, 0xdf, 0xa5, 0x14, 0xa4, 0x0, 0xb3, 0x42, 0x8c, 0xe5, 0x38, 0x37, 0xb4, 0x14, 0x3d, 0xd2, 0xda, 0xb4, 0x3d, 0xa2, 0x68, 0xe3, 0xc0, 0xcc, 0x35, 0x8a, 0x9e, 0x86, 0x4c, 0xa7, 0x15, 0x85, 0x9d, 0x6c, 0xb6, 0x13, 0x16, 0xe8, 0x54, 0x78, 0xbc, 0x8e, 0x60, 0x86, 0xd7, 0xd1, 0x17, 0xd3, 0x37, 0x6e, 0x48, 0x30, 0x4f, 0x70, 0x81, 0xbe, 0xed, 0x97, 0xd1, 0xfe, 0x6d, 0x44, 0xf7, 0xed, 0xa7, 0x63, 0x39, 0x79, 0x8c, 0xf6, 0xef, 0x8b, 0xe8, 0x61, 0xe6, 0x8d, 0x55, 0x5b, 0xae, 0x9e, 0x62, 0x3e, 0x1c, 0xd1, 0x3b, 0xf7, 0x9b, 0xc7, 0xfb, 0x9b, 0xab, 0x46, 0xcd, 0xab, 0x4b, 0xcd, 0xfd, 0x3b, 0x11, 0x1d, 0xe, 0x76, 0xf5, 0xc5, 0x2b, 0xe5, 0xf3, 0x67, 0x49, 0xcf, 0xcb, 0x2b, 0x8f, 0xea, 0xee, 0xe0, 0x10, 0xd1, 0xf0, 0xb2, 0x58, 0xb, 0x61, 0x75, 0xd6, 0x26, 0xcd, 0x56, 0x43, 0x58, 0x2b, 0x5e, 0x86, 0x88, 0x4e, 0x63, 0x33, 0x84, 0xf7, 0x1f, 0x26, 0xd5, 0x87, 0xf7, 0x61, 0x68, 0xc6, 0x29, 0xa2, 0x73, 0xdb, 0x5e, 0x2d, 0x57, 0x1f, 0xab, 0x56, 0xcb, 0xab, 0xed, 0x5c, 0xfe, 0xc4, 0x5d, 0xf1, 0x27, 0x1a, 0x8f, 0xba, 0x8d, 0xd7, 0xa0, 0x9a, 0x40, 0x0, 0x0, 0x0, 0x0, 0x49, 0x45, 0x4e, 0x44, 0xae, 0x42, 0x60, 0x82 + 0x89, 0x50, 0x4e, 0x47, 0xd, 0xa, 0x1a, 0xa, 0x0, 0x0, 0x0, 0xd, 0x49, 0x48, 0x44, 0x52, 0x0, 0x0, 0x0, 0x2a, 0x0, 0x0, 0x0, 0x48, 0x8, 0x3, 0x0, 0x0, 0x0, 0xb7, 0x21, 0x97, 0x38, 0x0, 0x0, 0x1, 0x71, 0x69, 0x43, 0x43, 0x50, 0x69, 0x63, 0x63, 0x0, 0x0, 0x28, 0x91, 0x75, 0x91, 0x3d, 0x4b, 0xc3, 0x50, 0x14, 0x86, 0xdf, 0xb6, 0x96, 0x8a, 0xad, 0x74, 0xd0, 0x41, 0xa4, 0x43, 0x86, 0x2a, 0xe, 0x2d, 0x14, 0x5, 0x71, 0xd4, 0x3a, 0x74, 0x29, 0x52, 0x6a, 0x5, 0xab, 0x2e, 0xc9, 0x6d, 0xd2, 0xa, 0x49, 0x1a, 0x6e, 0x52, 0xa4, 0xb8, 0xa, 0x2e, 0xe, 0x5, 0x7, 0xd1, 0xc5, 0xaf, 0xc1, 0x7f, 0xa0, 0xab, 0xe0, 0xaa, 0x20, 0x8, 0x8a, 0x20, 0xe2, 0xe2, 0x1f, 0xf0, 0x6b, 0x91, 0x12, 0xcf, 0x6d, 0xa, 0x2d, 0xd2, 0x9e, 0x70, 0x73, 0x1e, 0xde, 0x7b, 0xde, 0xc3, 0xbd, 0xe7, 0x2, 0xfe, 0xac, 0xce, 0xc, 0x7b, 0x20, 0x5, 0x18, 0xa6, 0xc3, 0xf3, 0x99, 0xb4, 0xb4, 0x5a, 0x5c, 0x93, 0x42, 0xef, 0x8, 0x21, 0x6, 0x1f, 0x82, 0x8, 0xcb, 0xcc, 0xb6, 0x16, 0x72, 0xb9, 0x2c, 0xfa, 0xc6, 0xcf, 0x23, 0x55, 0x52, 0x3c, 0x24, 0x45, 0xaf, 0xfe, 0x75, 0x3d, 0x23, 0x5c, 0x52, 0x6d, 0x6, 0xf8, 0x6, 0x89, 0x67, 0x99, 0xc5, 0x1d, 0xe2, 0x79, 0xe2, 0xec, 0x96, 0x63, 0x9, 0xde, 0x23, 0x1e, 0x65, 0x15, 0xb9, 0x44, 0x7c, 0x42, 0x9c, 0xe0, 0x74, 0x40, 0xe2, 0x5b, 0xa1, 0x2b, 0x1e, 0xbf, 0x9, 0x2e, 0x7b, 0xfc, 0x25, 0x98, 0x17, 0xf2, 0x8b, 0x80, 0x5f, 0xf4, 0x94, 0xca, 0x5d, 0xac, 0x74, 0x31, 0xab, 0x70, 0x83, 0x78, 0x8a, 0x38, 0x6e, 0xe8, 0x35, 0xd6, 0x3e, 0x8f, 0xb8, 0x49, 0x44, 0x35, 0x57, 0x96, 0x29, 0x8f, 0xd3, 0x8a, 0xc1, 0x46, 0x1e, 0x19, 0xa4, 0x21, 0x41, 0x41, 0xd, 0x9b, 0xd0, 0xe1, 0x20, 0x49, 0xd9, 0xa4, 0x99, 0xf5, 0xf6, 0xa5, 0x5a, 0xbe, 0x25, 0x54, 0xc9, 0xc3, 0xe8, 0x6f, 0xa1, 0xe, 0x4e, 0x8e, 0x32, 0x2a, 0xe4, 0x4d, 0x90, 0x5a, 0xa3, 0xae, 0x2a, 0x65, 0x8d, 0x74, 0x95, 0x3e, 0x1d, 0x75, 0x31, 0xf7, 0xff, 0xf3, 0xb4, 0xb5, 0x99, 0x69, 0xaf, 0x7b, 0x24, 0xd, 0x4, 0x5f, 0x5d, 0xf7, 0x73, 0x2, 0x8, 0xed, 0x3, 0xcd, 0x86, 0xeb, 0xfe, 0x9e, 0xba, 0x6e, 0xf3, 0xc, 0x8, 0xbc, 0x0, 0xd7, 0x66, 0xc7, 0x5f, 0xa5, 0x39, 0xcd, 0x7d, 0x93, 0xde, 0xe8, 0x68, 0xf1, 0x63, 0x20, 0xba, 0x3, 0x5c, 0xde, 0x74, 0x34, 0xe5, 0x0, 0xb8, 0xda, 0x5, 0xc6, 0x9e, 0x2d, 0x99, 0xcb, 0x2d, 0x29, 0x40, 0xcb, 0xaf, 0x69, 0xc0, 0xc7, 0x5, 0x30, 0x5c, 0x4, 0x46, 0xee, 0x81, 0xa1, 0x75, 0x6f, 0x56, 0xed, 0x7d, 0x9c, 0x3f, 0x1, 0x85, 0x6d, 0x7a, 0xa2, 0x3b, 0xe0, 0xf0, 0x8, 0x98, 0xa4, 0xfa, 0xe8, 0xc6, 0x1f, 0x7b, 0xde, 0x67, 0xcd, 0xda, 0x7, 0x3a, 0xfb, 0x0, 0x0, 0x0, 0x9, 0x70, 0x48, 0x59, 0x73, 0x0, 0x0, 0xb, 0x12, 0x0, 0x0, 0xb, 0x12, 0x1, 0xd2, 0xdd, 0x7e, 0xfc, 0x0, 0x0, 0x0, 0xa8, 0x50, 0x4c, 0x54, 0x45, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0xe8, 0xe5, 0xf1, 0x20, 0x1e, 0x23, 0x21, 0x1f, 0x24, 0x21, 0x1f, 0x24, 0x22, 0x20, 0x25, 0x1d, 0x1a, 0x20, 0x1d, 0x1d, 0x20, 0x1d, 0x1d, 0x22, 0x20, 0x1d, 0x22, 0x20, 0x1d, 0x25, 0x20, 0x20, 0x25, 0x22, 0x20, 0x25, 0xcf, 0xcd, 0xd7, 0xd0, 0xcd, 0xd7, 0xd1, 0xce, 0xd8, 0xd3, 0xd0, 0xda, 0xd4, 0xd1, 0xdb, 0xd5, 0xd3, 0xdc, 0xd6, 0xd4, 0xdd, 0xd7, 0xd6, 0xdf, 0xd9, 0xd7, 0xdf, 0xda, 0xd8, 0xe0, 0xdc, 0xda, 0xe2, 0xdd, 0xdb, 0xe3, 0xde, 0xdc, 0xe4, 0xdf, 0xdd, 0xe5, 0xe0, 0xde, 0xe6, 0xe1, 0xdf, 0xe7, 0xe2, 0xdf, 0xeb, 0xe3, 0xe1, 0xe8, 0xe5, 0xe2, 0xeb, 0xe8, 0xe5, 0xf1, 0xe8, 0x4e, 0x48, 0xd9, 0x0, 0x0, 0x0, 0x24, 0x74, 0x52, 0x4e, 0x53, 0x0, 0x3, 0x9, 0xc, 0xf, 0x15, 0x1d, 0x20, 0x22, 0x25, 0x30, 0x3a, 0x44, 0x52, 0x57, 0x59, 0x5b, 0x5e, 0x60, 0x7e, 0x92, 0x9e, 0x9f, 0xa1, 0xa2, 0xb8, 0xba, 0xbd, 0xbf, 0xc0, 0xc0, 0xc0, 0xc0, 0xc0, 0xc0, 0xc0, 0xf5, 0xb3, 0x97, 0xfb, 0x0, 0x0, 0x0, 0xea, 0x49, 0x44, 0x41, 0x54, 0x48, 0xc7, 0xed, 0x96, 0x31, 0xe, 0x83, 0x30, 0xc, 0x45, 0x6d, 0x93, 0xc2, 0xda, 0xb5, 0x13, 0xf7, 0x3f, 0x4a, 0xef, 0xd0, 0xa5, 0xc7, 0x28, 0x10, 0xff, 0xe, 0x4, 0x35, 0x88, 0xc6, 0x25, 0x48, 0x34, 0x2a, 0x6a, 0x16, 0x86, 0x3c, 0x7d, 0xbe, 0xfd, 0x49, 0x30, 0x51, 0xe1, 0xc5, 0xe1, 0xc1, 0xc2, 0xcc, 0xbc, 0xd8, 0x6, 0x0, 0x5, 0x22, 0x94, 0xa5, 0x72, 0xc2, 0x22, 0xb, 0x54, 0x15, 0x3a, 0x78, 0x5, 0x11, 0x91, 0x1b, 0xd1, 0xea, 0xd4, 0xf0, 0x1b, 0x59, 0x0, 0xc0, 0x83, 0x10, 0xa1, 0xe2, 0x9a, 0xba, 0x4d, 0x58, 0xbc, 0x13, 0x54, 0x23, 0x55, 0xe1, 0x36, 0x38, 0x5a, 0x14, 0xd3, 0xde, 0x64, 0x7c, 0x59, 0x40, 0x99, 0xc9, 0x27, 0x54, 0xdd, 0xe4, 0x4b, 0x26, 0x55, 0xa3, 0x49, 0x73, 0x55, 0x61, 0xc2, 0x3a, 0x94, 0xc8, 0x42, 0x27, 0x27, 0xaf, 0xc6, 0x7c, 0x4a, 0xcb, 0x85, 0xaa, 0xea, 0x34, 0x5a, 0xf7, 0xcc, 0xd8, 0xa0, 0x7a, 0x5c, 0x34, 0x23, 0x82, 0x1d, 0xd2, 0xda, 0x11, 0x3d, 0xaf, 0x45, 0xdd, 0x35, 0x89, 0x5c, 0x6, 0x1f, 0x9d, 0x2, 0xfb, 0xaa, 0x98, 0x1d, 0x98, 0x2, 0x68, 0x13, 0x32, 0x90, 0xf5, 0xd7, 0xdb, 0x6, 0xd4, 0x8, 0x0, 0xf4, 0xd, 0x3, 0xc5, 0xcb, 0xfa, 0xa5, 0xe, 0x1c, 0x34, 0xad, 0xff, 0xe7, 0x72, 0x44, 0x14, 0x40, 0x97, 0x46, 0x3a, 0x8c, 0x63, 0xcd, 0x9e, 0x69, 0x41, 0x2d, 0x34, 0x6c, 0xe6, 0xa3, 0xb0, 0x50, 0x64, 0xab, 0x86, 0x3f, 0x82, 0xb3, 0xc6, 0xc7, 0x7e, 0x88, 0x66, 0x42, 0x78, 0x82, 0x31, 0x94, 0x22, 0x77, 0xd4, 0x2d, 0xbe, 0x9e, 0x25, 0x9d, 0x7b, 0xb0, 0x59, 0x6d, 0x9f, 0xd7, 0x0, 0x0, 0x0, 0x0, 0x49, 0x45, 0x4e, 0x44, 0xae, 0x42, 0x60, 0x82 }; static const unsigned char progress_bar_png[] = { diff --git a/scene/resources/immediate_mesh.cpp b/scene/resources/immediate_mesh.cpp index ebe65605f8..05d1a7bf94 100644 --- a/scene/resources/immediate_mesh.cpp +++ b/scene/resources/immediate_mesh.cpp @@ -146,7 +146,7 @@ void ImmediateMesh::surface_add_vertex_2d(const Vector2 &p_vertex) { } void ImmediateMesh::surface_end() { ERR_FAIL_COND_MSG(!surface_active, "Not creating any surface. Use surface_begin() to do it."); - ERR_FAIL_COND_MSG(!vertices.size(), "No vertices were added, surface cant be created."); + ERR_FAIL_COND_MSG(!vertices.size(), "No vertices were added, surface can't be created."); uint32_t format = ARRAY_FORMAT_VERTEX; diff --git a/scene/resources/material.cpp b/scene/resources/material.cpp index a264c2d1eb..08f7274ff6 100644 --- a/scene/resources/material.cpp +++ b/scene/resources/material.cpp @@ -278,8 +278,8 @@ void ShaderMaterial::get_argument_options(const StringName &p_function, int p_id if (shader.is_valid()) { List<PropertyInfo> pl; shader->get_param_list(&pl); - for (List<PropertyInfo>::Element *E = pl.front(); E; E = E->next()) { - r_options->push_back(quote_style + E->get().name.replace_first("shader_param/", "") + quote_style); + for (const PropertyInfo &E : pl) { + r_options->push_back(quote_style + E.name.replace_first("shader_param/", "") + quote_style); } } } @@ -757,148 +757,148 @@ void BaseMaterial3D::_update_shader() { code += "void vertex() {\n"; if (flags[FLAG_SRGB_VERTEX_COLOR]) { - code += "\tif (!OUTPUT_IS_SRGB) {\n"; - code += "\t\tCOLOR.rgb = mix(pow((COLOR.rgb + vec3(0.055)) * (1.0 / (1.0 + 0.055)), vec3(2.4)), COLOR.rgb * (1.0 / 12.92), lessThan(COLOR.rgb, vec3(0.04045)));\n"; - code += "\t}\n"; + code += " if (!OUTPUT_IS_SRGB) {\n"; + code += " COLOR.rgb = mix(pow((COLOR.rgb + vec3(0.055)) * (1.0 / (1.0 + 0.055)), vec3(2.4)), COLOR.rgb * (1.0 / 12.92), lessThan(COLOR.rgb, vec3(0.04045)));\n"; + code += " }\n"; } if (flags[FLAG_USE_POINT_SIZE]) { - code += "\tPOINT_SIZE=point_size;\n"; + code += " POINT_SIZE=point_size;\n"; } if (shading_mode == SHADING_MODE_PER_VERTEX) { - code += "\tROUGHNESS=roughness;\n"; + code += " ROUGHNESS=roughness;\n"; } if (!flags[FLAG_UV1_USE_TRIPLANAR]) { - code += "\tUV=UV*uv1_scale.xy+uv1_offset.xy;\n"; + code += " UV=UV*uv1_scale.xy+uv1_offset.xy;\n"; } switch (billboard_mode) { case BILLBOARD_DISABLED: { } break; case BILLBOARD_ENABLED: { - code += "\tMODELVIEW_MATRIX = INV_CAMERA_MATRIX * mat4(CAMERA_MATRIX[0],CAMERA_MATRIX[1],CAMERA_MATRIX[2],WORLD_MATRIX[3]);\n"; + code += " MODELVIEW_MATRIX = INV_CAMERA_MATRIX * mat4(CAMERA_MATRIX[0],CAMERA_MATRIX[1],CAMERA_MATRIX[2],WORLD_MATRIX[3]);\n"; if (flags[FLAG_BILLBOARD_KEEP_SCALE]) { - code += "\tMODELVIEW_MATRIX = MODELVIEW_MATRIX * mat4(vec4(length(WORLD_MATRIX[0].xyz), 0.0, 0.0, 0.0),vec4(0.0, length(WORLD_MATRIX[1].xyz), 0.0, 0.0),vec4(0.0, 0.0, length(WORLD_MATRIX[2].xyz), 0.0),vec4(0.0, 0.0, 0.0, 1.0));\n"; + code += " MODELVIEW_MATRIX = MODELVIEW_MATRIX * mat4(vec4(length(WORLD_MATRIX[0].xyz), 0.0, 0.0, 0.0),vec4(0.0, length(WORLD_MATRIX[1].xyz), 0.0, 0.0),vec4(0.0, 0.0, length(WORLD_MATRIX[2].xyz), 0.0),vec4(0.0, 0.0, 0.0, 1.0));\n"; } } break; case BILLBOARD_FIXED_Y: { - code += "\tMODELVIEW_MATRIX = INV_CAMERA_MATRIX * mat4(CAMERA_MATRIX[0],WORLD_MATRIX[1],vec4(normalize(cross(CAMERA_MATRIX[0].xyz,WORLD_MATRIX[1].xyz)), 0.0),WORLD_MATRIX[3]);\n"; + code += " MODELVIEW_MATRIX = INV_CAMERA_MATRIX * mat4(CAMERA_MATRIX[0],WORLD_MATRIX[1],vec4(normalize(cross(CAMERA_MATRIX[0].xyz,WORLD_MATRIX[1].xyz)), 0.0),WORLD_MATRIX[3]);\n"; if (flags[FLAG_BILLBOARD_KEEP_SCALE]) { - code += "\tMODELVIEW_MATRIX = MODELVIEW_MATRIX * mat4(vec4(length(WORLD_MATRIX[0].xyz), 0.0, 0.0, 0.0),vec4(0.0, 1.0, 0.0, 0.0),vec4(0.0, 0.0, length(WORLD_MATRIX[2].xyz), 0.0), vec4(0.0, 0.0, 0.0, 1.0));\n"; + code += " MODELVIEW_MATRIX = MODELVIEW_MATRIX * mat4(vec4(length(WORLD_MATRIX[0].xyz), 0.0, 0.0, 0.0),vec4(0.0, 1.0, 0.0, 0.0),vec4(0.0, 0.0, length(WORLD_MATRIX[2].xyz), 0.0), vec4(0.0, 0.0, 0.0, 1.0));\n"; } else { - code += "\tMODELVIEW_MATRIX = MODELVIEW_MATRIX * mat4(vec4(1.0, 0.0, 0.0, 0.0),vec4(0.0, 1.0/length(WORLD_MATRIX[1].xyz), 0.0, 0.0), vec4(0.0, 0.0, 1.0, 0.0),vec4(0.0, 0.0, 0.0 ,1.0));\n"; + code += " MODELVIEW_MATRIX = MODELVIEW_MATRIX * mat4(vec4(1.0, 0.0, 0.0, 0.0),vec4(0.0, 1.0/length(WORLD_MATRIX[1].xyz), 0.0, 0.0), vec4(0.0, 0.0, 1.0, 0.0),vec4(0.0, 0.0, 0.0 ,1.0));\n"; } } break; case BILLBOARD_PARTICLES: { //make billboard - code += "\tmat4 mat_world = mat4(normalize(CAMERA_MATRIX[0])*length(WORLD_MATRIX[0]),normalize(CAMERA_MATRIX[1])*length(WORLD_MATRIX[0]),normalize(CAMERA_MATRIX[2])*length(WORLD_MATRIX[2]),WORLD_MATRIX[3]);\n"; + code += " mat4 mat_world = mat4(normalize(CAMERA_MATRIX[0])*length(WORLD_MATRIX[0]),normalize(CAMERA_MATRIX[1])*length(WORLD_MATRIX[0]),normalize(CAMERA_MATRIX[2])*length(WORLD_MATRIX[2]),WORLD_MATRIX[3]);\n"; //rotate by rotation - code += "\tmat_world = mat_world * mat4( vec4(cos(INSTANCE_CUSTOM.x),-sin(INSTANCE_CUSTOM.x), 0.0, 0.0), vec4(sin(INSTANCE_CUSTOM.x), cos(INSTANCE_CUSTOM.x), 0.0, 0.0),vec4(0.0, 0.0, 1.0, 0.0),vec4(0.0, 0.0, 0.0, 1.0));\n"; + code += " mat_world = mat_world * mat4( vec4(cos(INSTANCE_CUSTOM.x),-sin(INSTANCE_CUSTOM.x), 0.0, 0.0), vec4(sin(INSTANCE_CUSTOM.x), cos(INSTANCE_CUSTOM.x), 0.0, 0.0),vec4(0.0, 0.0, 1.0, 0.0),vec4(0.0, 0.0, 0.0, 1.0));\n"; //set modelview - code += "\tMODELVIEW_MATRIX = INV_CAMERA_MATRIX * mat_world;\n"; + code += " MODELVIEW_MATRIX = INV_CAMERA_MATRIX * mat_world;\n"; //handle animation - code += "\tfloat h_frames = float(particles_anim_h_frames);\n"; - code += "\tfloat v_frames = float(particles_anim_v_frames);\n"; - code += "\tfloat particle_total_frames = float(particles_anim_h_frames * particles_anim_v_frames);\n"; - code += "\tfloat particle_frame = floor(INSTANCE_CUSTOM.z * float(particle_total_frames));\n"; - code += "\tif (!particles_anim_loop) {\n"; - code += "\t\tparticle_frame = clamp(particle_frame, 0.0, particle_total_frames - 1.0);\n"; - code += "\t} else {\n"; - code += "\t\tparticle_frame = mod(particle_frame, particle_total_frames);\n"; - code += "\t}"; - code += "\tUV /= vec2(h_frames, v_frames);\n"; - code += "\tUV += vec2(mod(particle_frame, h_frames) / h_frames, floor(particle_frame / h_frames) / v_frames);\n"; + code += " float h_frames = float(particles_anim_h_frames);\n"; + code += " float v_frames = float(particles_anim_v_frames);\n"; + code += " float particle_total_frames = float(particles_anim_h_frames * particles_anim_v_frames);\n"; + code += " float particle_frame = floor(INSTANCE_CUSTOM.z * float(particle_total_frames));\n"; + code += " if (!particles_anim_loop) {\n"; + code += " particle_frame = clamp(particle_frame, 0.0, particle_total_frames - 1.0);\n"; + code += " } else {\n"; + code += " particle_frame = mod(particle_frame, particle_total_frames);\n"; + code += " }"; + code += " UV /= vec2(h_frames, v_frames);\n"; + code += " UV += vec2(mod(particle_frame, h_frames) / h_frames, floor(particle_frame / h_frames) / v_frames);\n"; } break; case BILLBOARD_MAX: break; // Internal value, skip. } if (flags[FLAG_FIXED_SIZE]) { - code += "\tif (PROJECTION_MATRIX[3][3] != 0.0) {\n"; + code += " if (PROJECTION_MATRIX[3][3] != 0.0) {\n"; //orthogonal matrix, try to do about the same //with viewport size - code += "\t\tfloat h = abs(1.0 / (2.0 * PROJECTION_MATRIX[1][1]));\n"; - code += "\t\tfloat sc = (h * 2.0); //consistent with Y-fov\n"; - code += "\t\tMODELVIEW_MATRIX[0]*=sc;\n"; - code += "\t\tMODELVIEW_MATRIX[1]*=sc;\n"; - code += "\t\tMODELVIEW_MATRIX[2]*=sc;\n"; - code += "\t} else {\n"; + code += " float h = abs(1.0 / (2.0 * PROJECTION_MATRIX[1][1]));\n"; + code += " float sc = (h * 2.0); //consistent with Y-fov\n"; + code += " MODELVIEW_MATRIX[0]*=sc;\n"; + code += " MODELVIEW_MATRIX[1]*=sc;\n"; + code += " MODELVIEW_MATRIX[2]*=sc;\n"; + code += " } else {\n"; //just scale by depth - code += "\t\tfloat sc = -(MODELVIEW_MATRIX)[3].z;\n"; - code += "\t\tMODELVIEW_MATRIX[0]*=sc;\n"; - code += "\t\tMODELVIEW_MATRIX[1]*=sc;\n"; - code += "\t\tMODELVIEW_MATRIX[2]*=sc;\n"; - code += "\t}\n"; + code += " float sc = -(MODELVIEW_MATRIX)[3].z;\n"; + code += " MODELVIEW_MATRIX[0]*=sc;\n"; + code += " MODELVIEW_MATRIX[1]*=sc;\n"; + code += " MODELVIEW_MATRIX[2]*=sc;\n"; + code += " }\n"; } if (detail_uv == DETAIL_UV_2 && !flags[FLAG_UV2_USE_TRIPLANAR]) { - code += "\tUV2=UV2*uv2_scale.xy+uv2_offset.xy;\n"; + code += " UV2=UV2*uv2_scale.xy+uv2_offset.xy;\n"; } if (flags[FLAG_UV1_USE_TRIPLANAR] || flags[FLAG_UV2_USE_TRIPLANAR]) { //generate tangent and binormal in world space - code += "\tTANGENT = vec3(0.0,0.0,-1.0) * abs(NORMAL.x);\n"; - code += "\tTANGENT+= vec3(1.0,0.0,0.0) * abs(NORMAL.y);\n"; - code += "\tTANGENT+= vec3(1.0,0.0,0.0) * abs(NORMAL.z);\n"; - code += "\tTANGENT = normalize(TANGENT);\n"; + code += " TANGENT = vec3(0.0,0.0,-1.0) * abs(NORMAL.x);\n"; + code += " TANGENT+= vec3(1.0,0.0,0.0) * abs(NORMAL.y);\n"; + code += " TANGENT+= vec3(1.0,0.0,0.0) * abs(NORMAL.z);\n"; + code += " TANGENT = normalize(TANGENT);\n"; - code += "\tBINORMAL = vec3(0.0,1.0,0.0) * abs(NORMAL.x);\n"; - code += "\tBINORMAL+= vec3(0.0,0.0,-1.0) * abs(NORMAL.y);\n"; - code += "\tBINORMAL+= vec3(0.0,1.0,0.0) * abs(NORMAL.z);\n"; - code += "\tBINORMAL = normalize(BINORMAL);\n"; + code += " BINORMAL = vec3(0.0,1.0,0.0) * abs(NORMAL.x);\n"; + code += " BINORMAL+= vec3(0.0,0.0,-1.0) * abs(NORMAL.y);\n"; + code += " BINORMAL+= vec3(0.0,1.0,0.0) * abs(NORMAL.z);\n"; + code += " BINORMAL = normalize(BINORMAL);\n"; } if (flags[FLAG_UV1_USE_TRIPLANAR]) { if (flags[FLAG_UV1_USE_WORLD_TRIPLANAR]) { - code += "\tuv1_power_normal=pow(abs(mat3(WORLD_MATRIX) * NORMAL),vec3(uv1_blend_sharpness));\n"; - code += "\tuv1_triplanar_pos = (WORLD_MATRIX * vec4(VERTEX, 1.0f)).xyz * uv1_scale + uv1_offset;\n"; + code += " uv1_power_normal=pow(abs(mat3(WORLD_MATRIX) * NORMAL),vec3(uv1_blend_sharpness));\n"; + code += " uv1_triplanar_pos = (WORLD_MATRIX * vec4(VERTEX, 1.0f)).xyz * uv1_scale + uv1_offset;\n"; } else { - code += "\tuv1_power_normal=pow(abs(NORMAL),vec3(uv1_blend_sharpness));\n"; - code += "\tuv1_triplanar_pos = VERTEX * uv1_scale + uv1_offset;\n"; + code += " uv1_power_normal=pow(abs(NORMAL),vec3(uv1_blend_sharpness));\n"; + code += " uv1_triplanar_pos = VERTEX * uv1_scale + uv1_offset;\n"; } - code += "\tuv1_power_normal/=dot(uv1_power_normal,vec3(1.0));\n"; - code += "\tuv1_triplanar_pos *= vec3(1.0,-1.0, 1.0);\n"; + code += " uv1_power_normal/=dot(uv1_power_normal,vec3(1.0));\n"; + code += " uv1_triplanar_pos *= vec3(1.0,-1.0, 1.0);\n"; } if (flags[FLAG_UV2_USE_TRIPLANAR]) { if (flags[FLAG_UV2_USE_WORLD_TRIPLANAR]) { - code += "\tuv2_power_normal=pow(abs(mat3(WORLD_MATRIX) * NORMAL), vec3(uv2_blend_sharpness));\n"; - code += "\tuv2_triplanar_pos = (WORLD_MATRIX * vec4(VERTEX, 1.0f)).xyz * uv2_scale + uv2_offset;\n"; + code += " uv2_power_normal=pow(abs(mat3(WORLD_MATRIX) * NORMAL), vec3(uv2_blend_sharpness));\n"; + code += " uv2_triplanar_pos = (WORLD_MATRIX * vec4(VERTEX, 1.0f)).xyz * uv2_scale + uv2_offset;\n"; } else { - code += "\tuv2_power_normal=pow(abs(NORMAL), vec3(uv2_blend_sharpness));\n"; - code += "\tuv2_triplanar_pos = VERTEX * uv2_scale + uv2_offset;\n"; + code += " uv2_power_normal=pow(abs(NORMAL), vec3(uv2_blend_sharpness));\n"; + code += " uv2_triplanar_pos = VERTEX * uv2_scale + uv2_offset;\n"; } - code += "\tuv2_power_normal/=dot(uv2_power_normal,vec3(1.0));\n"; - code += "\tuv2_triplanar_pos *= vec3(1.0,-1.0, 1.0);\n"; + code += " uv2_power_normal/=dot(uv2_power_normal,vec3(1.0));\n"; + code += " uv2_triplanar_pos *= vec3(1.0,-1.0, 1.0);\n"; } if (grow_enabled) { - code += "\tVERTEX+=NORMAL*grow;\n"; + code += " VERTEX+=NORMAL*grow;\n"; } code += "}\n"; code += "\n\n"; if (flags[FLAG_UV1_USE_TRIPLANAR] || flags[FLAG_UV2_USE_TRIPLANAR]) { code += "vec4 triplanar_texture(sampler2D p_sampler,vec3 p_weights,vec3 p_triplanar_pos) {\n"; - code += "\tvec4 samp=vec4(0.0);\n"; - code += "\tsamp+= texture(p_sampler,p_triplanar_pos.xy) * p_weights.z;\n"; - code += "\tsamp+= texture(p_sampler,p_triplanar_pos.xz) * p_weights.y;\n"; - code += "\tsamp+= texture(p_sampler,p_triplanar_pos.zy * vec2(-1.0,1.0)) * p_weights.x;\n"; - code += "\treturn samp;\n"; + code += " vec4 samp=vec4(0.0);\n"; + code += " samp+= texture(p_sampler,p_triplanar_pos.xy) * p_weights.z;\n"; + code += " samp+= texture(p_sampler,p_triplanar_pos.xz) * p_weights.y;\n"; + code += " samp+= texture(p_sampler,p_triplanar_pos.zy * vec2(-1.0,1.0)) * p_weights.x;\n"; + code += " return samp;\n"; code += "}\n"; } code += "\n\n"; code += "void fragment() {\n"; if (!flags[FLAG_UV1_USE_TRIPLANAR]) { - code += "\tvec2 base_uv = UV;\n"; + code += " vec2 base_uv = UV;\n"; } if ((features[FEATURE_DETAIL] && detail_uv == DETAIL_UV_2) || (features[FEATURE_AMBIENT_OCCLUSION] && flags[FLAG_AO_ON_UV2]) || (features[FEATURE_EMISSION] && flags[FLAG_EMISSION_ON_UV2])) { - code += "\tvec2 base_uv2 = UV2;\n"; + code += " vec2 base_uv2 = UV2;\n"; } if (features[FEATURE_HEIGHT_MAPPING] && flags[FLAG_UV1_USE_TRIPLANAR]) { @@ -916,317 +916,317 @@ void BaseMaterial3D::_update_shader() { } if (!RenderingServer::get_singleton()->is_low_end() && features[FEATURE_HEIGHT_MAPPING] && !flags[FLAG_UV1_USE_TRIPLANAR]) { //heightmap not supported with triplanar - code += "\t{\n"; - code += "\t\tvec3 view_dir = normalize(normalize(-VERTEX)*mat3(TANGENT*heightmap_flip.x,-BINORMAL*heightmap_flip.y,NORMAL));\n"; // binormal is negative due to mikktspace, flip 'unflips' it ;-) + code += " {\n"; + code += " vec3 view_dir = normalize(normalize(-VERTEX)*mat3(TANGENT*heightmap_flip.x,-BINORMAL*heightmap_flip.y,NORMAL));\n"; // binormal is negative due to mikktspace, flip 'unflips' it ;-) if (deep_parallax) { - code += "\t\tfloat num_layers = mix(float(heightmap_max_layers),float(heightmap_min_layers), abs(dot(vec3(0.0, 0.0, 1.0), view_dir)));\n"; - code += "\t\tfloat layer_depth = 1.0 / num_layers;\n"; - code += "\t\tfloat current_layer_depth = 0.0;\n"; - code += "\t\tvec2 P = view_dir.xy * heightmap_scale;\n"; - code += "\t\tvec2 delta = P / num_layers;\n"; - code += "\t\tvec2 ofs = base_uv;\n"; + code += " float num_layers = mix(float(heightmap_max_layers),float(heightmap_min_layers), abs(dot(vec3(0.0, 0.0, 1.0), view_dir)));\n"; + code += " float layer_depth = 1.0 / num_layers;\n"; + code += " float current_layer_depth = 0.0;\n"; + code += " vec2 P = view_dir.xy * heightmap_scale;\n"; + code += " vec2 delta = P / num_layers;\n"; + code += " vec2 ofs = base_uv;\n"; if (flags[FLAG_INVERT_HEIGHTMAP]) { - code += "\t\tfloat depth = texture(texture_heightmap, ofs).r;\n"; + code += " float depth = texture(texture_heightmap, ofs).r;\n"; } else { - code += "\t\tfloat depth = 1.0 - texture(texture_heightmap, ofs).r;\n"; + code += " float depth = 1.0 - texture(texture_heightmap, ofs).r;\n"; } - code += "\t\tfloat current_depth = 0.0;\n"; - code += "\t\twhile(current_depth < depth) {\n"; - code += "\t\t\tofs -= delta;\n"; + code += " float current_depth = 0.0;\n"; + code += " while(current_depth < depth) {\n"; + code += " ofs -= delta;\n"; if (flags[FLAG_INVERT_HEIGHTMAP]) { - code += "\t\t\tdepth = texture(texture_heightmap, ofs).r;\n"; + code += " depth = texture(texture_heightmap, ofs).r;\n"; } else { - code += "\t\t\tdepth = 1.0 - texture(texture_heightmap, ofs).r;\n"; + code += " depth = 1.0 - texture(texture_heightmap, ofs).r;\n"; } - code += "\t\t\tcurrent_depth += layer_depth;\n"; - code += "\t\t}\n"; - code += "\t\tvec2 prev_ofs = ofs + delta;\n"; - code += "\t\tfloat after_depth = depth - current_depth;\n"; + code += " current_depth += layer_depth;\n"; + code += " }\n"; + code += " vec2 prev_ofs = ofs + delta;\n"; + code += " float after_depth = depth - current_depth;\n"; if (flags[FLAG_INVERT_HEIGHTMAP]) { - code += "\t\tfloat before_depth = texture(texture_heightmap, prev_ofs).r - current_depth + layer_depth;\n"; + code += " float before_depth = texture(texture_heightmap, prev_ofs).r - current_depth + layer_depth;\n"; } else { - code += "\t\tfloat before_depth = ( 1.0 - texture(texture_heightmap, prev_ofs).r ) - current_depth + layer_depth;\n"; + code += " float before_depth = ( 1.0 - texture(texture_heightmap, prev_ofs).r ) - current_depth + layer_depth;\n"; } - code += "\t\tfloat weight = after_depth / (after_depth - before_depth);\n"; - code += "\t\tofs = mix(ofs,prev_ofs,weight);\n"; + code += " float weight = after_depth / (after_depth - before_depth);\n"; + code += " ofs = mix(ofs,prev_ofs,weight);\n"; } else { if (flags[FLAG_INVERT_HEIGHTMAP]) { - code += "\t\tfloat depth = texture(texture_heightmap, base_uv).r;\n"; + code += " float depth = texture(texture_heightmap, base_uv).r;\n"; } else { - code += "\t\tfloat depth = 1.0 - texture(texture_heightmap, base_uv).r;\n"; + code += " float depth = 1.0 - texture(texture_heightmap, base_uv).r;\n"; } - code += "\t\tvec2 ofs = base_uv - view_dir.xy / view_dir.z * (depth * heightmap_scale);\n"; + code += " vec2 ofs = base_uv - view_dir.xy / view_dir.z * (depth * heightmap_scale);\n"; } - code += "\t\tbase_uv=ofs;\n"; + code += " base_uv=ofs;\n"; if (features[FEATURE_DETAIL] && detail_uv == DETAIL_UV_2) { - code += "\t\tbase_uv2-=ofs;\n"; + code += " base_uv2-=ofs;\n"; } - code += "\t}\n"; + code += " }\n"; } if (flags[FLAG_USE_POINT_SIZE]) { - code += "\tvec4 albedo_tex = texture(texture_albedo,POINT_COORD);\n"; + code += " vec4 albedo_tex = texture(texture_albedo,POINT_COORD);\n"; } else { if (flags[FLAG_UV1_USE_TRIPLANAR]) { - code += "\tvec4 albedo_tex = triplanar_texture(texture_albedo,uv1_power_normal,uv1_triplanar_pos);\n"; + code += " vec4 albedo_tex = triplanar_texture(texture_albedo,uv1_power_normal,uv1_triplanar_pos);\n"; } else { - code += "\tvec4 albedo_tex = texture(texture_albedo,base_uv);\n"; + code += " vec4 albedo_tex = texture(texture_albedo,base_uv);\n"; } } if (flags[FLAG_ALBEDO_TEXTURE_FORCE_SRGB]) { - code += "\talbedo_tex.rgb = mix(pow((albedo_tex.rgb + vec3(0.055)) * (1.0 / (1.0 + 0.055)),vec3(2.4)),albedo_tex.rgb.rgb * (1.0 / 12.92),lessThan(albedo_tex.rgb,vec3(0.04045)));\n"; + code += " albedo_tex.rgb = mix(pow((albedo_tex.rgb + vec3(0.055)) * (1.0 / (1.0 + 0.055)),vec3(2.4)),albedo_tex.rgb.rgb * (1.0 / 12.92),lessThan(albedo_tex.rgb,vec3(0.04045)));\n"; } if (flags[FLAG_ALBEDO_FROM_VERTEX_COLOR]) { - code += "\talbedo_tex *= COLOR;\n"; + code += " albedo_tex *= COLOR;\n"; } - code += "\tALBEDO = albedo.rgb * albedo_tex.rgb;\n"; + code += " ALBEDO = albedo.rgb * albedo_tex.rgb;\n"; if (!orm) { if (flags[FLAG_UV1_USE_TRIPLANAR]) { - code += "\tfloat metallic_tex = dot(triplanar_texture(texture_metallic,uv1_power_normal,uv1_triplanar_pos),metallic_texture_channel);\n"; + code += " float metallic_tex = dot(triplanar_texture(texture_metallic,uv1_power_normal,uv1_triplanar_pos),metallic_texture_channel);\n"; } else { - code += "\tfloat metallic_tex = dot(texture(texture_metallic,base_uv),metallic_texture_channel);\n"; + code += " float metallic_tex = dot(texture(texture_metallic,base_uv),metallic_texture_channel);\n"; } - code += "\tMETALLIC = metallic_tex * metallic;\n"; + code += " METALLIC = metallic_tex * metallic;\n"; switch (roughness_texture_channel) { case TEXTURE_CHANNEL_RED: { - code += "\tvec4 roughness_texture_channel = vec4(1.0,0.0,0.0,0.0);\n"; + code += " vec4 roughness_texture_channel = vec4(1.0,0.0,0.0,0.0);\n"; } break; case TEXTURE_CHANNEL_GREEN: { - code += "\tvec4 roughness_texture_channel = vec4(0.0,1.0,0.0,0.0);\n"; + code += " vec4 roughness_texture_channel = vec4(0.0,1.0,0.0,0.0);\n"; } break; case TEXTURE_CHANNEL_BLUE: { - code += "\tvec4 roughness_texture_channel = vec4(0.0,0.0,1.0,0.0);\n"; + code += " vec4 roughness_texture_channel = vec4(0.0,0.0,1.0,0.0);\n"; } break; case TEXTURE_CHANNEL_ALPHA: { - code += "\tvec4 roughness_texture_channel = vec4(0.0,0.0,0.0,1.0);\n"; + code += " vec4 roughness_texture_channel = vec4(0.0,0.0,0.0,1.0);\n"; } break; case TEXTURE_CHANNEL_GRAYSCALE: { - code += "\tvec4 roughness_texture_channel = vec4(0.333333,0.333333,0.333333,0.0);\n"; + code += " vec4 roughness_texture_channel = vec4(0.333333,0.333333,0.333333,0.0);\n"; } break; case TEXTURE_CHANNEL_MAX: break; // Internal value, skip. } if (flags[FLAG_UV1_USE_TRIPLANAR]) { - code += "\tfloat roughness_tex = dot(triplanar_texture(texture_roughness,uv1_power_normal,uv1_triplanar_pos),roughness_texture_channel);\n"; + code += " float roughness_tex = dot(triplanar_texture(texture_roughness,uv1_power_normal,uv1_triplanar_pos),roughness_texture_channel);\n"; } else { - code += "\tfloat roughness_tex = dot(texture(texture_roughness,base_uv),roughness_texture_channel);\n"; + code += " float roughness_tex = dot(texture(texture_roughness,base_uv),roughness_texture_channel);\n"; } - code += "\tROUGHNESS = roughness_tex * roughness;\n"; - code += "\tSPECULAR = specular;\n"; + code += " ROUGHNESS = roughness_tex * roughness;\n"; + code += " SPECULAR = specular;\n"; } else { if (flags[FLAG_UV1_USE_TRIPLANAR]) { - code += "\tvec4 orm_tex = triplanar_texture(texture_orm,uv1_power_normal,uv1_triplanar_pos);\n"; + code += " vec4 orm_tex = triplanar_texture(texture_orm,uv1_power_normal,uv1_triplanar_pos);\n"; } else { - code += "\tvec4 orm_tex = texture(texture_orm,base_uv);\n"; + code += " vec4 orm_tex = texture(texture_orm,base_uv);\n"; } - code += "\tROUGHNESS = orm_tex.g;\n"; - code += "\tMETALLIC = orm_tex.b;\n"; + code += " ROUGHNESS = orm_tex.g;\n"; + code += " METALLIC = orm_tex.b;\n"; } if (features[FEATURE_NORMAL_MAPPING]) { if (flags[FLAG_UV1_USE_TRIPLANAR]) { - code += "\tNORMAL_MAP = triplanar_texture(texture_normal,uv1_power_normal,uv1_triplanar_pos).rgb;\n"; + code += " NORMAL_MAP = triplanar_texture(texture_normal,uv1_power_normal,uv1_triplanar_pos).rgb;\n"; } else { - code += "\tNORMAL_MAP = texture(texture_normal,base_uv).rgb;\n"; + code += " NORMAL_MAP = texture(texture_normal,base_uv).rgb;\n"; } - code += "\tNORMAL_MAP_DEPTH = normal_scale;\n"; + code += " NORMAL_MAP_DEPTH = normal_scale;\n"; } if (features[FEATURE_EMISSION]) { if (flags[FLAG_EMISSION_ON_UV2]) { if (flags[FLAG_UV2_USE_TRIPLANAR]) { - code += "\tvec3 emission_tex = triplanar_texture(texture_emission,uv2_power_normal,uv2_triplanar_pos).rgb;\n"; + code += " vec3 emission_tex = triplanar_texture(texture_emission,uv2_power_normal,uv2_triplanar_pos).rgb;\n"; } else { - code += "\tvec3 emission_tex = texture(texture_emission,base_uv2).rgb;\n"; + code += " vec3 emission_tex = texture(texture_emission,base_uv2).rgb;\n"; } } else { if (flags[FLAG_UV1_USE_TRIPLANAR]) { - code += "\tvec3 emission_tex = triplanar_texture(texture_emission,uv1_power_normal,uv1_triplanar_pos).rgb;\n"; + code += " vec3 emission_tex = triplanar_texture(texture_emission,uv1_power_normal,uv1_triplanar_pos).rgb;\n"; } else { - code += "\tvec3 emission_tex = texture(texture_emission,base_uv).rgb;\n"; + code += " vec3 emission_tex = texture(texture_emission,base_uv).rgb;\n"; } } if (emission_op == EMISSION_OP_ADD) { - code += "\tEMISSION = (emission.rgb+emission_tex)*emission_energy;\n"; + code += " EMISSION = (emission.rgb+emission_tex)*emission_energy;\n"; } else { - code += "\tEMISSION = (emission.rgb*emission_tex)*emission_energy;\n"; + code += " EMISSION = (emission.rgb*emission_tex)*emission_energy;\n"; } } if (features[FEATURE_REFRACTION]) { if (features[FEATURE_NORMAL_MAPPING]) { - code += "\tvec3 unpacked_normal = NORMAL_MAP;\n"; - code += "\tunpacked_normal.xy = unpacked_normal.xy * 2.0 - 1.0;\n"; - code += "\tunpacked_normal.z = sqrt(max(0.0, 1.0 - dot(unpacked_normal.xy, unpacked_normal.xy)));\n"; - code += "\tvec3 ref_normal = normalize( mix(NORMAL,TANGENT * unpacked_normal.x + BINORMAL * unpacked_normal.y + NORMAL * unpacked_normal.z,NORMAL_MAP_DEPTH) );\n"; + code += " vec3 unpacked_normal = NORMAL_MAP;\n"; + code += " unpacked_normal.xy = unpacked_normal.xy * 2.0 - 1.0;\n"; + code += " unpacked_normal.z = sqrt(max(0.0, 1.0 - dot(unpacked_normal.xy, unpacked_normal.xy)));\n"; + code += " vec3 ref_normal = normalize( mix(NORMAL,TANGENT * unpacked_normal.x + BINORMAL * unpacked_normal.y + NORMAL * unpacked_normal.z,NORMAL_MAP_DEPTH) );\n"; } else { - code += "\tvec3 ref_normal = NORMAL;\n"; + code += " vec3 ref_normal = NORMAL;\n"; } if (flags[FLAG_UV1_USE_TRIPLANAR]) { - code += "\tvec2 ref_ofs = SCREEN_UV - ref_normal.xy * dot(triplanar_texture(texture_refraction,uv1_power_normal,uv1_triplanar_pos),refraction_texture_channel) * refraction;\n"; + code += " vec2 ref_ofs = SCREEN_UV - ref_normal.xy * dot(triplanar_texture(texture_refraction,uv1_power_normal,uv1_triplanar_pos),refraction_texture_channel) * refraction;\n"; } else { - code += "\tvec2 ref_ofs = SCREEN_UV - ref_normal.xy * dot(texture(texture_refraction,base_uv),refraction_texture_channel) * refraction;\n"; + code += " vec2 ref_ofs = SCREEN_UV - ref_normal.xy * dot(texture(texture_refraction,base_uv),refraction_texture_channel) * refraction;\n"; } - code += "\tfloat ref_amount = 1.0 - albedo.a * albedo_tex.a;\n"; - code += "\tEMISSION += textureLod(SCREEN_TEXTURE,ref_ofs,ROUGHNESS * 8.0).rgb * ref_amount;\n"; - code += "\tALBEDO *= 1.0 - ref_amount;\n"; - code += "\tALPHA = 1.0;\n"; + code += " float ref_amount = 1.0 - albedo.a * albedo_tex.a;\n"; + code += " EMISSION += textureLod(SCREEN_TEXTURE,ref_ofs,ROUGHNESS * 8.0).rgb * ref_amount;\n"; + code += " ALBEDO *= 1.0 - ref_amount;\n"; + code += " ALPHA = 1.0;\n"; } else if (transparency != TRANSPARENCY_DISABLED || flags[FLAG_USE_SHADOW_TO_OPACITY] || (distance_fade == DISTANCE_FADE_PIXEL_ALPHA) || proximity_fade_enabled) { - code += "\tALPHA = albedo.a * albedo_tex.a;\n"; + code += " ALPHA = albedo.a * albedo_tex.a;\n"; } if (transparency == TRANSPARENCY_ALPHA_HASH) { - code += "\tALPHA_HASH_SCALE = alpha_hash_scale;\n"; + code += " ALPHA_HASH_SCALE = alpha_hash_scale;\n"; } else if (transparency == TRANSPARENCY_ALPHA_SCISSOR) { - code += "\tALPHA_SCISSOR_THRESHOLD = alpha_scissor_threshold;\n"; + code += " ALPHA_SCISSOR_THRESHOLD = alpha_scissor_threshold;\n"; } if (alpha_antialiasing_mode != ALPHA_ANTIALIASING_OFF && (transparency == TRANSPARENCY_ALPHA_HASH || transparency == TRANSPARENCY_ALPHA_SCISSOR)) { - code += "\tALPHA_ANTIALIASING_EDGE = alpha_antialiasing_edge;\n"; - code += "\tALPHA_TEXTURE_COORDINATE = UV * vec2(albedo_texture_size);\n"; + code += " ALPHA_ANTIALIASING_EDGE = alpha_antialiasing_edge;\n"; + code += " ALPHA_TEXTURE_COORDINATE = UV * vec2(albedo_texture_size);\n"; } if (proximity_fade_enabled) { - code += "\tfloat depth_tex = textureLod(DEPTH_TEXTURE,SCREEN_UV,0.0).r;\n"; - code += "\tvec4 world_pos = INV_PROJECTION_MATRIX * vec4(SCREEN_UV*2.0-1.0,depth_tex*2.0-1.0,1.0);\n"; - code += "\tworld_pos.xyz/=world_pos.w;\n"; - code += "\tALPHA*=clamp(1.0-smoothstep(world_pos.z+proximity_fade_distance,world_pos.z,VERTEX.z),0.0,1.0);\n"; + code += " float depth_tex = textureLod(DEPTH_TEXTURE,SCREEN_UV,0.0).r;\n"; + code += " vec4 world_pos = INV_PROJECTION_MATRIX * vec4(SCREEN_UV*2.0-1.0,depth_tex*2.0-1.0,1.0);\n"; + code += " world_pos.xyz/=world_pos.w;\n"; + code += " ALPHA*=clamp(1.0-smoothstep(world_pos.z+proximity_fade_distance,world_pos.z,VERTEX.z),0.0,1.0);\n"; } if (distance_fade != DISTANCE_FADE_DISABLED) { if ((distance_fade == DISTANCE_FADE_OBJECT_DITHER || distance_fade == DISTANCE_FADE_PIXEL_DITHER)) { if (!RenderingServer::get_singleton()->is_low_end()) { - code += "\t{\n"; + code += " {\n"; if (distance_fade == DISTANCE_FADE_OBJECT_DITHER) { - code += "\t\tfloat fade_distance = abs((INV_CAMERA_MATRIX * WORLD_MATRIX[3]).z);\n"; + code += " float fade_distance = abs((INV_CAMERA_MATRIX * WORLD_MATRIX[3]).z);\n"; } else { - code += "\t\tfloat fade_distance=-VERTEX.z;\n"; + code += " float fade_distance=-VERTEX.z;\n"; } - code += "\t\tfloat fade=clamp(smoothstep(distance_fade_min,distance_fade_max,fade_distance),0.0,1.0);\n"; - code += "\t\tint x = int(FRAGCOORD.x) % 4;\n"; - code += "\t\tint y = int(FRAGCOORD.y) % 4;\n"; - code += "\t\tint index = x + y * 4;\n"; - code += "\t\tfloat limit = 0.0;\n\n"; - code += "\t\tif (x < 8) {\n"; - code += "\t\t\tif (index == 0) limit = 0.0625;\n"; - code += "\t\t\tif (index == 1) limit = 0.5625;\n"; - code += "\t\t\tif (index == 2) limit = 0.1875;\n"; - code += "\t\t\tif (index == 3) limit = 0.6875;\n"; - code += "\t\t\tif (index == 4) limit = 0.8125;\n"; - code += "\t\t\tif (index == 5) limit = 0.3125;\n"; - code += "\t\t\tif (index == 6) limit = 0.9375;\n"; - code += "\t\t\tif (index == 7) limit = 0.4375;\n"; - code += "\t\t\tif (index == 8) limit = 0.25;\n"; - code += "\t\t\tif (index == 9) limit = 0.75;\n"; - code += "\t\t\tif (index == 10) limit = 0.125;\n"; - code += "\t\t\tif (index == 11) limit = 0.625;\n"; - code += "\t\t\tif (index == 12) limit = 1.0;\n"; - code += "\t\t\tif (index == 13) limit = 0.5;\n"; - code += "\t\t\tif (index == 14) limit = 0.875;\n"; - code += "\t\t\tif (index == 15) limit = 0.375;\n"; - code += "\t\t}\n\n"; - code += "\tif (fade < limit)\n"; - code += "\t\tdiscard;\n"; - code += "\t}\n\n"; + code += " float fade=clamp(smoothstep(distance_fade_min,distance_fade_max,fade_distance),0.0,1.0);\n"; + code += " int x = int(FRAGCOORD.x) % 4;\n"; + code += " int y = int(FRAGCOORD.y) % 4;\n"; + code += " int index = x + y * 4;\n"; + code += " float limit = 0.0;\n\n"; + code += " if (x < 8) {\n"; + code += " if (index == 0) limit = 0.0625;\n"; + code += " if (index == 1) limit = 0.5625;\n"; + code += " if (index == 2) limit = 0.1875;\n"; + code += " if (index == 3) limit = 0.6875;\n"; + code += " if (index == 4) limit = 0.8125;\n"; + code += " if (index == 5) limit = 0.3125;\n"; + code += " if (index == 6) limit = 0.9375;\n"; + code += " if (index == 7) limit = 0.4375;\n"; + code += " if (index == 8) limit = 0.25;\n"; + code += " if (index == 9) limit = 0.75;\n"; + code += " if (index == 10) limit = 0.125;\n"; + code += " if (index == 11) limit = 0.625;\n"; + code += " if (index == 12) limit = 1.0;\n"; + code += " if (index == 13) limit = 0.5;\n"; + code += " if (index == 14) limit = 0.875;\n"; + code += " if (index == 15) limit = 0.375;\n"; + code += " }\n\n"; + code += " if (fade < limit)\n"; + code += " discard;\n"; + code += " }\n\n"; } } else { - code += "\tALPHA*=clamp(smoothstep(distance_fade_min,distance_fade_max,-VERTEX.z),0.0,1.0);\n"; + code += " ALPHA*=clamp(smoothstep(distance_fade_min,distance_fade_max,-VERTEX.z),0.0,1.0);\n"; } } if (features[FEATURE_RIM]) { if (flags[FLAG_UV1_USE_TRIPLANAR]) { - code += "\tvec2 rim_tex = triplanar_texture(texture_rim,uv1_power_normal,uv1_triplanar_pos).xy;\n"; + code += " vec2 rim_tex = triplanar_texture(texture_rim,uv1_power_normal,uv1_triplanar_pos).xy;\n"; } else { - code += "\tvec2 rim_tex = texture(texture_rim,base_uv).xy;\n"; + code += " vec2 rim_tex = texture(texture_rim,base_uv).xy;\n"; } - code += "\tRIM = rim*rim_tex.x;"; - code += "\tRIM_TINT = rim_tint*rim_tex.y;\n"; + code += " RIM = rim*rim_tex.x;"; + code += " RIM_TINT = rim_tint*rim_tex.y;\n"; } if (features[FEATURE_CLEARCOAT]) { if (flags[FLAG_UV1_USE_TRIPLANAR]) { - code += "\tvec2 clearcoat_tex = triplanar_texture(texture_clearcoat,uv1_power_normal,uv1_triplanar_pos).xy;\n"; + code += " vec2 clearcoat_tex = triplanar_texture(texture_clearcoat,uv1_power_normal,uv1_triplanar_pos).xy;\n"; } else { - code += "\tvec2 clearcoat_tex = texture(texture_clearcoat,base_uv).xy;\n"; + code += " vec2 clearcoat_tex = texture(texture_clearcoat,base_uv).xy;\n"; } - code += "\tCLEARCOAT = clearcoat*clearcoat_tex.x;"; - code += "\tCLEARCOAT_GLOSS = clearcoat_gloss*clearcoat_tex.y;\n"; + code += " CLEARCOAT = clearcoat*clearcoat_tex.x;"; + code += " CLEARCOAT_GLOSS = clearcoat_gloss*clearcoat_tex.y;\n"; } if (features[FEATURE_ANISOTROPY]) { if (flags[FLAG_UV1_USE_TRIPLANAR]) { - code += "\tvec3 anisotropy_tex = triplanar_texture(texture_flowmap,uv1_power_normal,uv1_triplanar_pos).rga;\n"; + code += " vec3 anisotropy_tex = triplanar_texture(texture_flowmap,uv1_power_normal,uv1_triplanar_pos).rga;\n"; } else { - code += "\tvec3 anisotropy_tex = texture(texture_flowmap,base_uv).rga;\n"; + code += " vec3 anisotropy_tex = texture(texture_flowmap,base_uv).rga;\n"; } - code += "\tANISOTROPY = anisotropy_ratio*anisotropy_tex.b;\n"; - code += "\tANISOTROPY_FLOW = anisotropy_tex.rg*2.0-1.0;\n"; + code += " ANISOTROPY = anisotropy_ratio*anisotropy_tex.b;\n"; + code += " ANISOTROPY_FLOW = anisotropy_tex.rg*2.0-1.0;\n"; } if (features[FEATURE_AMBIENT_OCCLUSION]) { if (!orm) { if (flags[FLAG_AO_ON_UV2]) { if (flags[FLAG_UV2_USE_TRIPLANAR]) { - code += "\tAO = dot(triplanar_texture(texture_ambient_occlusion,uv2_power_normal,uv2_triplanar_pos),ao_texture_channel);\n"; + code += " AO = dot(triplanar_texture(texture_ambient_occlusion,uv2_power_normal,uv2_triplanar_pos),ao_texture_channel);\n"; } else { - code += "\tAO = dot(texture(texture_ambient_occlusion,base_uv2),ao_texture_channel);\n"; + code += " AO = dot(texture(texture_ambient_occlusion,base_uv2),ao_texture_channel);\n"; } } else { if (flags[FLAG_UV1_USE_TRIPLANAR]) { - code += "\tAO = dot(triplanar_texture(texture_ambient_occlusion,uv1_power_normal,uv1_triplanar_pos),ao_texture_channel);\n"; + code += " AO = dot(triplanar_texture(texture_ambient_occlusion,uv1_power_normal,uv1_triplanar_pos),ao_texture_channel);\n"; } else { - code += "\tAO = dot(texture(texture_ambient_occlusion,base_uv),ao_texture_channel);\n"; + code += " AO = dot(texture(texture_ambient_occlusion,base_uv),ao_texture_channel);\n"; } } } else { - code += "\tAO = orm_tex.r;\n"; + code += " AO = orm_tex.r;\n"; } - code += "\tAO_LIGHT_AFFECT = ao_light_affect;\n"; + code += " AO_LIGHT_AFFECT = ao_light_affect;\n"; } if (features[FEATURE_SUBSURFACE_SCATTERING]) { if (flags[FLAG_UV1_USE_TRIPLANAR]) { - code += "\tfloat sss_tex = triplanar_texture(texture_subsurface_scattering,uv1_power_normal,uv1_triplanar_pos).r;\n"; + code += " float sss_tex = triplanar_texture(texture_subsurface_scattering,uv1_power_normal,uv1_triplanar_pos).r;\n"; } else { - code += "\tfloat sss_tex = texture(texture_subsurface_scattering,base_uv).r;\n"; + code += " float sss_tex = texture(texture_subsurface_scattering,base_uv).r;\n"; } - code += "\tSSS_STRENGTH=subsurface_scattering_strength*sss_tex;\n"; + code += " SSS_STRENGTH=subsurface_scattering_strength*sss_tex;\n"; } if (features[FEATURE_SUBSURFACE_TRANSMITTANCE]) { if (flags[FLAG_UV1_USE_TRIPLANAR]) { - code += "\tvec4 trans_color_tex = triplanar_texture(texture_subsurface_transmittance,uv1_power_normal,uv1_triplanar_pos);\n"; + code += " vec4 trans_color_tex = triplanar_texture(texture_subsurface_transmittance,uv1_power_normal,uv1_triplanar_pos);\n"; } else { - code += "\tvec4 trans_color_tex = texture(texture_subsurface_transmittance,base_uv);\n"; + code += " vec4 trans_color_tex = texture(texture_subsurface_transmittance,base_uv);\n"; } - code += "\tSSS_TRANSMITTANCE_COLOR=transmittance_color*trans_color_tex;\n"; + code += " SSS_TRANSMITTANCE_COLOR=transmittance_color*trans_color_tex;\n"; - code += "\tSSS_TRANSMITTANCE_DEPTH=transmittance_depth;\n"; - code += "\tSSS_TRANSMITTANCE_BOOST=transmittance_boost;\n"; + code += " SSS_TRANSMITTANCE_DEPTH=transmittance_depth;\n"; + code += " SSS_TRANSMITTANCE_BOOST=transmittance_boost;\n"; } if (features[FEATURE_BACKLIGHT]) { if (flags[FLAG_UV1_USE_TRIPLANAR]) { - code += "\tvec3 backlight_tex = triplanar_texture(texture_backlight,uv1_power_normal,uv1_triplanar_pos).rgb;\n"; + code += " vec3 backlight_tex = triplanar_texture(texture_backlight,uv1_power_normal,uv1_triplanar_pos).rgb;\n"; } else { - code += "\tvec3 backlight_tex = texture(texture_backlight,base_uv).rgb;\n"; + code += " vec3 backlight_tex = texture(texture_backlight,base_uv).rgb;\n"; } - code += "\tBACKLIGHT = (backlight.rgb+backlight_tex);\n"; + code += " BACKLIGHT = (backlight.rgb+backlight_tex);\n"; } if (features[FEATURE_DETAIL]) { @@ -1234,41 +1234,41 @@ void BaseMaterial3D::_update_shader() { if (triplanar) { String tp_uv = detail_uv == DETAIL_UV_1 ? "uv1" : "uv2"; - code += "\tvec4 detail_tex = triplanar_texture(texture_detail_albedo," + tp_uv + "_power_normal," + tp_uv + "_triplanar_pos);\n"; - code += "\tvec4 detail_norm_tex = triplanar_texture(texture_detail_normal," + tp_uv + "_power_normal," + tp_uv + "_triplanar_pos);\n"; + code += " vec4 detail_tex = triplanar_texture(texture_detail_albedo," + tp_uv + "_power_normal," + tp_uv + "_triplanar_pos);\n"; + code += " vec4 detail_norm_tex = triplanar_texture(texture_detail_normal," + tp_uv + "_power_normal," + tp_uv + "_triplanar_pos);\n"; } else { String det_uv = detail_uv == DETAIL_UV_1 ? "base_uv" : "base_uv2"; - code += "\tvec4 detail_tex = texture(texture_detail_albedo," + det_uv + ");\n"; - code += "\tvec4 detail_norm_tex = texture(texture_detail_normal," + det_uv + ");\n"; + code += " vec4 detail_tex = texture(texture_detail_albedo," + det_uv + ");\n"; + code += " vec4 detail_norm_tex = texture(texture_detail_normal," + det_uv + ");\n"; } if (flags[FLAG_UV1_USE_TRIPLANAR]) { - code += "\tvec4 detail_mask_tex = triplanar_texture(texture_detail_mask,uv1_power_normal,uv1_triplanar_pos);\n"; + code += " vec4 detail_mask_tex = triplanar_texture(texture_detail_mask,uv1_power_normal,uv1_triplanar_pos);\n"; } else { - code += "\tvec4 detail_mask_tex = texture(texture_detail_mask,base_uv);\n"; + code += " vec4 detail_mask_tex = texture(texture_detail_mask,base_uv);\n"; } switch (detail_blend_mode) { case BLEND_MODE_MIX: { - code += "\tvec3 detail = mix(ALBEDO.rgb,detail_tex.rgb,detail_tex.a);\n"; + code += " vec3 detail = mix(ALBEDO.rgb,detail_tex.rgb,detail_tex.a);\n"; } break; case BLEND_MODE_ADD: { - code += "\tvec3 detail = mix(ALBEDO.rgb,ALBEDO.rgb+detail_tex.rgb,detail_tex.a);\n"; + code += " vec3 detail = mix(ALBEDO.rgb,ALBEDO.rgb+detail_tex.rgb,detail_tex.a);\n"; } break; case BLEND_MODE_SUB: { - code += "\tvec3 detail = mix(ALBEDO.rgb,ALBEDO.rgb-detail_tex.rgb,detail_tex.a);\n"; + code += " vec3 detail = mix(ALBEDO.rgb,ALBEDO.rgb-detail_tex.rgb,detail_tex.a);\n"; } break; case BLEND_MODE_MUL: { - code += "\tvec3 detail = mix(ALBEDO.rgb,ALBEDO.rgb*detail_tex.rgb,detail_tex.a);\n"; + code += " vec3 detail = mix(ALBEDO.rgb,ALBEDO.rgb*detail_tex.rgb,detail_tex.a);\n"; } break; case BLEND_MODE_MAX: break; // Internal value, skip. } - code += "\tvec3 detail_norm = mix(NORMAL_MAP,detail_norm_tex.rgb,detail_tex.a);\n"; - code += "\tNORMAL_MAP = mix(NORMAL_MAP,detail_norm,detail_mask_tex.r);\n"; - code += "\tALBEDO.rgb = mix(ALBEDO.rgb,detail,detail_mask_tex.r);\n"; + code += " vec3 detail_norm = mix(NORMAL_MAP,detail_norm_tex.rgb,detail_tex.a);\n"; + code += " NORMAL_MAP = mix(NORMAL_MAP,detail_norm,detail_mask_tex.r);\n"; + code += " ALBEDO.rgb = mix(ALBEDO.rgb,detail,detail_mask_tex.r);\n"; } code += "}\n"; diff --git a/scene/resources/navigation_mesh.cpp b/scene/resources/navigation_mesh.cpp index d2be2bdba1..ddc50c0490 100644 --- a/scene/resources/navigation_mesh.cpp +++ b/scene/resources/navigation_mesh.cpp @@ -329,9 +329,7 @@ Ref<Mesh> NavigationMesh::get_debug_mesh() { Vector3 *tw = tmeshfaces.ptrw(); int tidx = 0; - for (List<Face3>::Element *E = faces.front(); E; E = E->next()) { - const Face3 &f = E->get(); - + for (const Face3 &f : faces) { for (int j = 0; j < 3; j++) { tw[tidx++] = f.vertex[j]; _EdgeKey ek; @@ -366,8 +364,8 @@ Ref<Mesh> NavigationMesh::get_debug_mesh() { { Vector3 *w = varr.ptrw(); int idx = 0; - for (List<Vector3>::Element *E = lines.front(); E; E = E->next()) { - w[idx++] = E->get(); + for (const Vector3 &E : lines) { + w[idx++] = E; } } diff --git a/scene/resources/packed_scene.cpp b/scene/resources/packed_scene.cpp index 9bb2a4ddb8..eddbb9a842 100644 --- a/scene/resources/packed_scene.cpp +++ b/scene/resources/packed_scene.cpp @@ -206,8 +206,8 @@ Node *SceneState::instantiate(GenEditState p_edit_state) const { node->set(snames[nprops[j].name], props[nprops[j].value], &valid); //restore old state for new script, if exists - for (List<Pair<StringName, Variant>>::Element *E = old_state.front(); E; E = E->next()) { - node->set(E->get().first, E->get().second); + for (const Pair<StringName, Variant> &E : old_state) { + node->set(E.first, E.second); } } else { Variant value = props[nprops[j].value]; @@ -477,13 +477,13 @@ Error SceneState::_parse_node(Node *p_owner, Node *p_node, int p_parent_idx, Map script->update_exports(); } - for (List<PropertyInfo>::Element *E = plist.front(); E; E = E->next()) { - if (!(E->get().usage & PROPERTY_USAGE_STORAGE)) { + for (const PropertyInfo &E : plist) { + if (!(E.usage & PROPERTY_USAGE_STORAGE)) { continue; } - String name = E->get().name; - Variant value = p_node->get(E->get().name); + String name = E.name; + Variant value = p_node->get(E.name); bool isdefault = false; Variant default_value = ClassDB::class_get_default_property_value(type, name); @@ -497,7 +497,7 @@ Error SceneState::_parse_node(Node *p_owner, Node *p_node, int p_parent_idx, Map } // the version above makes more sense, because it does not rely on placeholder or usage flag // in the script, just the default value function. - // if (E->get().usage & PROPERTY_USAGE_SCRIPT_DEFAULT_VALUE) { + // if (E.usage & PROPERTY_USAGE_SCRIPT_DEFAULT_VALUE) { // isdefault = true; //is script default value // } @@ -507,7 +507,7 @@ Error SceneState::_parse_node(Node *p_owner, Node *p_node, int p_parent_idx, Map // only save what has been changed // only save changed properties in instance - if ((E->get().usage & PROPERTY_USAGE_NO_INSTANCE_STATE) || E->get().name == "__meta__") { + if ((E.usage & PROPERTY_USAGE_NO_INSTANCE_STATE) || E.name == "__meta__") { //property has requested that no instance state is saved, sorry //also, meta won't be overridden or saved continue; @@ -520,7 +520,7 @@ Error SceneState::_parse_node(Node *p_owner, Node *p_node, int p_parent_idx, Map //check all levels of pack to see if the property exists somewhere const PackState &ps = F->get(); - original = ps.state->get_property_value(ps.node, E->get().name, exists); + original = ps.state->get_property_value(ps.node, E.name, exists); if (exists) { break; } @@ -565,9 +565,7 @@ Error SceneState::_parse_node(Node *p_owner, Node *p_node, int p_parent_idx, Map List<Node::GroupInfo> groups; p_node->get_groups(&groups); - for (List<Node::GroupInfo>::Element *E = groups.front(); E; E = E->next()) { - Node::GroupInfo &gi = E->get(); - + for (const Node::GroupInfo &gi : groups) { if (!gi.persistent) { continue; } @@ -577,9 +575,9 @@ Error SceneState::_parse_node(Node *p_owner, Node *p_node, int p_parent_idx, Map */ bool skip = false; - for (List<PackState>::Element *F = pack_state_stack.front(); F; F = F->next()) { + for (const PackState &F : pack_state_stack) { //check all levels of pack to see if the group was added somewhere - const PackState &ps = F->get(); + const PackState &ps = F; if (ps.state->is_node_in_group(ps.node, gi.name)) { skip = true; break; @@ -679,14 +677,14 @@ Error SceneState::_parse_connections(Node *p_owner, Node *p_node, Map<StringName //ERR_FAIL_COND_V( !node_map.has(p_node), ERR_BUG); //NodeData &nd = nodes[node_map[p_node]]; - for (List<MethodInfo>::Element *E = _signals.front(); E; E = E->next()) { + for (const MethodInfo &E : _signals) { List<Node::Connection> conns; - p_node->get_signal_connection_list(E->get().name, &conns); + p_node->get_signal_connection_list(E.name, &conns); conns.sort(); - for (List<Node::Connection>::Element *F = conns.front(); F; F = F->next()) { - const Node::Connection &c = F->get(); + for (const Node::Connection &F : conns) { + const Node::Connection &c = F; if (!(c.flags & CONNECT_PERSIST)) { //only persistent connections get saved continue; diff --git a/scene/resources/particles_material.cpp b/scene/resources/particles_material.cpp index 2bde98abe0..7da9cb96ee 100644 --- a/scene/resources/particles_material.cpp +++ b/scene/resources/particles_material.cpp @@ -90,6 +90,10 @@ void ParticlesMaterial::init_shaders() { shader_names->emission_texture_points = "emission_texture_points"; shader_names->emission_texture_normal = "emission_texture_normal"; shader_names->emission_texture_color = "emission_texture_color"; + shader_names->emission_ring_axis = "emission_ring_axis"; + shader_names->emission_ring_height = "emission_ring_height"; + shader_names->emission_ring_radius = "emission_ring_radius"; + shader_names->emission_ring_inner_radius = "emission_ring_inner_radius"; shader_names->gravity = "gravity"; @@ -194,6 +198,12 @@ void ParticlesMaterial::_update_shader() { code += "uniform sampler2D emission_texture_color : hint_white;\n"; } } break; + case EMISSION_SHAPE_RING: { + code += "uniform vec3 " + shader_names->emission_ring_axis + ";\n"; + code += "uniform float " + shader_names->emission_ring_height + ";\n"; + code += "uniform float " + shader_names->emission_ring_radius + ";\n"; + code += "uniform float " + shader_names->emission_ring_inner_radius + ";\n"; + } break; case EMISSION_SHAPE_MAX: { // Max value for validity check. break; } @@ -396,6 +406,28 @@ void ParticlesMaterial::_update_shader() { } } } break; + case EMISSION_SHAPE_RING: { + code += " float ring_spawn_angle = rand_from_seed(alt_seed) * 2.0 * pi;\n"; + code += " float ring_random_radius = rand_from_seed(alt_seed) * (emission_ring_radius - emission_ring_inner_radius) + emission_ring_inner_radius;\n"; + code += " vec3 axis = normalize(emission_ring_axis);\n"; + code += " vec3 ortho_axis = vec3(0.0);\n"; + code += " if (axis == vec3(1.0, 0.0, 0.0)) {\n"; + code += " ortho_axis = cross(axis, vec3(0.0, 1.0, 0.0));\n"; + code += " } else {\n"; + code += " ortho_axis = cross(axis, vec3(1.0, 0.0, 0.0));\n"; + code += " }\n"; + code += " ortho_axis = normalize(ortho_axis);\n"; + code += " float s = sin(ring_spawn_angle);\n"; + code += " float c = cos(ring_spawn_angle);\n"; + code += " float oc = 1.0 - c;\n"; + code += " ortho_axis = mat3(\n"; + code += " vec3(c + axis.x * axis.x * oc, axis.x * axis.y * oc - axis.z * s, axis.x * axis.z *oc + axis.y * s),\n"; + code += " vec3(axis.x * axis.y * oc + s * axis.z, c + axis.y * axis.y * oc, axis.y * axis.z * oc - axis.x * s),\n"; + code += " vec3(axis.z * axis.x * oc - axis.y * s, axis.z * axis.y * oc + axis.x * s, c + axis.z * axis.z * oc)\n"; + code += " ) * ortho_axis;\n"; + code += " ortho_axis = normalize(ortho_axis);\n"; + code += " TRANSFORM[3].xyz = ortho_axis * ring_random_radius + (rand_from_seed(alt_seed) * emission_ring_height - emission_ring_height / 2.0) * axis;\n"; + } break; case EMISSION_SHAPE_MAX: { // Max value for validity check. break; } @@ -569,7 +601,7 @@ void ParticlesMaterial::_update_shader() { code += " vec4(1.250, -1.050, -0.203, 0.0),\n"; code += " vec4(0.000, 0.000, 0.000, 0.0)) * hue_rot_s;\n"; if (color_ramp.is_valid()) { - code += " COLOR = hue_rot_mat * textureLod(color_ramp, vec2(tv, 0.0), 0.0);\n"; + code += " COLOR = hue_rot_mat * textureLod(color_ramp, vec2(tv, 0.0), 0.0) * color_value;\n"; } else { code += " COLOR = hue_rot_mat * color_value;\n"; } @@ -990,6 +1022,26 @@ void ParticlesMaterial::set_emission_point_count(int p_count) { RenderingServer::get_singleton()->material_set_param(_get_material(), shader_names->emission_texture_point_count, p_count); } +void ParticlesMaterial::set_emission_ring_axis(Vector3 p_axis) { + emission_ring_axis = p_axis; + RenderingServer::get_singleton()->material_set_param(_get_material(), shader_names->emission_ring_axis, p_axis); +} + +void ParticlesMaterial::set_emission_ring_height(float p_height) { + emission_ring_height = p_height; + RenderingServer::get_singleton()->material_set_param(_get_material(), shader_names->emission_ring_height, p_height); +} + +void ParticlesMaterial::set_emission_ring_radius(float p_radius) { + emission_ring_radius = p_radius; + RenderingServer::get_singleton()->material_set_param(_get_material(), shader_names->emission_ring_radius, p_radius); +} + +void ParticlesMaterial::set_emission_ring_inner_radius(float p_radius) { + emission_ring_inner_radius = p_radius; + RenderingServer::get_singleton()->material_set_param(_get_material(), shader_names->emission_ring_inner_radius, p_radius); +} + ParticlesMaterial::EmissionShape ParticlesMaterial::get_emission_shape() const { return emission_shape; } @@ -1018,6 +1070,22 @@ int ParticlesMaterial::get_emission_point_count() const { return emission_point_count; } +Vector3 ParticlesMaterial::get_emission_ring_axis() const { + return emission_ring_axis; +} + +float ParticlesMaterial::get_emission_ring_height() const { + return emission_ring_height; +} + +float ParticlesMaterial::get_emission_ring_radius() const { + return emission_ring_radius; +} + +float ParticlesMaterial::get_emission_ring_inner_radius() const { + return emission_ring_inner_radius; +} + void ParticlesMaterial::set_gravity(const Vector3 &p_gravity) { gravity = p_gravity; Vector3 gset = gravity; @@ -1046,10 +1114,6 @@ RID ParticlesMaterial::get_shader_rid() const { } void ParticlesMaterial::_validate_property(PropertyInfo &property) const { - if (property.name == "color" && color_ramp.is_valid()) { - property.usage = PROPERTY_USAGE_NONE; - } - if (property.name == "emission_sphere_radius" && emission_shape != EMISSION_SHAPE_SPHERE) { property.usage = PROPERTY_USAGE_NONE; } @@ -1058,7 +1122,7 @@ void ParticlesMaterial::_validate_property(PropertyInfo &property) const { property.usage = PROPERTY_USAGE_NONE; } - if ((property.name == "emission_point_texture" || property.name == "emission_color_texture") && (emission_shape < EMISSION_SHAPE_POINTS)) { + if ((property.name == "emission_point_texture" || property.name == "emission_color_texture") && (emission_shape != EMISSION_SHAPE_POINTS && emission_shape != EMISSION_SHAPE_DIRECTED_POINTS)) { property.usage = PROPERTY_USAGE_NONE; } @@ -1070,6 +1134,10 @@ void ParticlesMaterial::_validate_property(PropertyInfo &property) const { property.usage = PROPERTY_USAGE_NONE; } + if (property.name.begins_with("emission_ring_") && emission_shape != EMISSION_SHAPE_RING) { + property.usage = PROPERTY_USAGE_NONE; + } + if (property.name == "sub_emitter_frequency" && sub_emitter_mode != SUB_EMITTER_CONSTANT) { property.usage = PROPERTY_USAGE_NONE; } @@ -1216,6 +1284,18 @@ void ParticlesMaterial::_bind_methods() { ClassDB::bind_method(D_METHOD("set_emission_point_count", "point_count"), &ParticlesMaterial::set_emission_point_count); ClassDB::bind_method(D_METHOD("get_emission_point_count"), &ParticlesMaterial::get_emission_point_count); + ClassDB::bind_method(D_METHOD("set_emission_ring_axis", "axis"), &ParticlesMaterial::set_emission_ring_axis); + ClassDB::bind_method(D_METHOD("get_emission_ring_axis"), &ParticlesMaterial::get_emission_ring_axis); + + ClassDB::bind_method(D_METHOD("set_emission_ring_height", "height"), &ParticlesMaterial::set_emission_ring_height); + ClassDB::bind_method(D_METHOD("get_emission_ring_height"), &ParticlesMaterial::get_emission_ring_height); + + ClassDB::bind_method(D_METHOD("set_emission_ring_radius", "radius"), &ParticlesMaterial::set_emission_ring_radius); + ClassDB::bind_method(D_METHOD("get_emission_ring_radius"), &ParticlesMaterial::get_emission_ring_radius); + + ClassDB::bind_method(D_METHOD("set_emission_ring_inner_radius", "inner_radius"), &ParticlesMaterial::set_emission_ring_inner_radius); + ClassDB::bind_method(D_METHOD("get_emission_ring_inner_radius"), &ParticlesMaterial::get_emission_ring_inner_radius); + ClassDB::bind_method(D_METHOD("get_gravity"), &ParticlesMaterial::get_gravity); ClassDB::bind_method(D_METHOD("set_gravity", "accel_vec"), &ParticlesMaterial::set_gravity); @@ -1253,13 +1333,17 @@ void ParticlesMaterial::_bind_methods() { ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "lifetime_randomness", PROPERTY_HINT_RANGE, "0,1,0.01"), "set_lifetime_randomness", "get_lifetime_randomness"); ADD_GROUP("Emission Shape", "emission_"); - ADD_PROPERTY(PropertyInfo(Variant::INT, "emission_shape", PROPERTY_HINT_ENUM, "Point,Sphere,Box,Points,Directed Points"), "set_emission_shape", "get_emission_shape"); + ADD_PROPERTY(PropertyInfo(Variant::INT, "emission_shape", PROPERTY_HINT_ENUM, "Point,Sphere,Box,Points,Directed Points,Ring"), "set_emission_shape", "get_emission_shape"); ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "emission_sphere_radius", PROPERTY_HINT_RANGE, "0.01,128,0.01,or_greater"), "set_emission_sphere_radius", "get_emission_sphere_radius"); ADD_PROPERTY(PropertyInfo(Variant::VECTOR3, "emission_box_extents"), "set_emission_box_extents", "get_emission_box_extents"); ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "emission_point_texture", PROPERTY_HINT_RESOURCE_TYPE, "Texture2D"), "set_emission_point_texture", "get_emission_point_texture"); ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "emission_normal_texture", PROPERTY_HINT_RESOURCE_TYPE, "Texture2D"), "set_emission_normal_texture", "get_emission_normal_texture"); ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "emission_color_texture", PROPERTY_HINT_RESOURCE_TYPE, "Texture2D"), "set_emission_color_texture", "get_emission_color_texture"); ADD_PROPERTY(PropertyInfo(Variant::INT, "emission_point_count", PROPERTY_HINT_RANGE, "0,1000000,1"), "set_emission_point_count", "get_emission_point_count"); + ADD_PROPERTY(PropertyInfo(Variant::VECTOR3, "emission_ring_axis"), "set_emission_ring_axis", "get_emission_ring_axis"); + ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "emission_ring_height"), "set_emission_ring_height", "get_emission_ring_height"); + ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "emission_ring_radius"), "set_emission_ring_radius", "get_emission_ring_radius"); + ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "emission_ring_inner_radius"), "set_emission_ring_inner_radius", "get_emission_ring_inner_radius"); ADD_GROUP("ParticleFlags", "particle_flag_"); ADD_PROPERTYI(PropertyInfo(Variant::BOOL, "particle_flag_align_y"), "set_particle_flag", "get_particle_flag", PARTICLE_FLAG_ALIGN_Y_TO_VELOCITY); ADD_PROPERTYI(PropertyInfo(Variant::BOOL, "particle_flag_rotate_y"), "set_particle_flag", "get_particle_flag", PARTICLE_FLAG_ROTATE_Y); @@ -1359,6 +1443,7 @@ void ParticlesMaterial::_bind_methods() { BIND_ENUM_CONSTANT(EMISSION_SHAPE_BOX); BIND_ENUM_CONSTANT(EMISSION_SHAPE_POINTS); BIND_ENUM_CONSTANT(EMISSION_SHAPE_DIRECTED_POINTS); + BIND_ENUM_CONSTANT(EMISSION_SHAPE_RING); BIND_ENUM_CONSTANT(EMISSION_SHAPE_MAX); BIND_ENUM_CONSTANT(SUB_EMITTER_DISABLED); @@ -1388,6 +1473,10 @@ ParticlesMaterial::ParticlesMaterial() : set_emission_shape(EMISSION_SHAPE_POINT); set_emission_sphere_radius(1); set_emission_box_extents(Vector3(1, 1, 1)); + set_emission_ring_axis(Vector3(0, 0, 1.0)); + set_emission_ring_height(1); + set_emission_ring_radius(1); + set_emission_ring_inner_radius(0); set_gravity(Vector3(0, -9.8, 0)); set_lifetime_randomness(0); diff --git a/scene/resources/particles_material.h b/scene/resources/particles_material.h index 3f874bd68c..8b0b26a3d1 100644 --- a/scene/resources/particles_material.h +++ b/scene/resources/particles_material.h @@ -74,6 +74,7 @@ public: EMISSION_SHAPE_BOX, EMISSION_SHAPE_POINTS, EMISSION_SHAPE_DIRECTED_POINTS, + EMISSION_SHAPE_RING, EMISSION_SHAPE_MAX }; @@ -195,6 +196,10 @@ private: StringName emission_texture_points; StringName emission_texture_normal; StringName emission_texture_color; + StringName emission_ring_axis; + StringName emission_ring_height; + StringName emission_ring_radius; + StringName emission_ring_inner_radius; StringName gravity; @@ -235,6 +240,10 @@ private: Ref<Texture2D> emission_point_texture; Ref<Texture2D> emission_normal_texture; Ref<Texture2D> emission_color_texture; + Vector3 emission_ring_axis; + float emission_ring_height; + float emission_ring_radius; + float emission_ring_inner_radius; int emission_point_count = 1; bool anim_loop; @@ -293,6 +302,10 @@ public: void set_emission_point_texture(const Ref<Texture2D> &p_points); void set_emission_normal_texture(const Ref<Texture2D> &p_normals); void set_emission_color_texture(const Ref<Texture2D> &p_colors); + void set_emission_ring_axis(Vector3 p_axis); + void set_emission_ring_height(float p_height); + void set_emission_ring_radius(float p_radius); + void set_emission_ring_inner_radius(float p_radius); void set_emission_point_count(int p_count); EmissionShape get_emission_shape() const; @@ -301,6 +314,10 @@ public: Ref<Texture2D> get_emission_point_texture() const; Ref<Texture2D> get_emission_normal_texture() const; Ref<Texture2D> get_emission_color_texture() const; + Vector3 get_emission_ring_axis() const; + float get_emission_ring_height() const; + float get_emission_ring_radius() const; + float get_emission_ring_inner_radius() const; int get_emission_point_count() const; void set_gravity(const Vector3 &p_gravity); diff --git a/scene/resources/resource_format_text.cpp b/scene/resources/resource_format_text.cpp index ee61e64ed3..250a2311a0 100644 --- a/scene/resources/resource_format_text.cpp +++ b/scene/resources/resource_format_text.cpp @@ -35,8 +35,9 @@ #include "core/io/resource_format_binary.h" #include "core/version.h" -//version 2: changed names for basis, aabb, Vectors, etc. -#define FORMAT_VERSION 2 +// Version 2: changed names for Basis, AABB, Vectors, etc. +// Version 3: new string ID for ext/subresources, breaks forward compat. +#define FORMAT_VERSION 3 #include "core/io/dir_access.h" #include "core/version.h" @@ -56,22 +57,23 @@ Ref<Resource> ResourceLoaderText::get_resource() { Error ResourceLoaderText::_parse_sub_resource_dummy(DummyReadData *p_data, VariantParser::Stream *p_stream, Ref<Resource> &r_res, int &line, String &r_err_str) { VariantParser::Token token; VariantParser::get_token(p_stream, token, line, r_err_str); - if (token.type != VariantParser::TK_NUMBER) { - r_err_str = "Expected number (sub-resource index)"; + if (token.type != VariantParser::TK_NUMBER && token.type != VariantParser::TK_STRING) { + r_err_str = "Expected number (old style) or string (sub-resource index)"; return ERR_PARSE_ERROR; } - int index = token.value; + String unique_id = token.value; - if (!p_data->resource_map.has(index)) { + if (!p_data->resource_map.has(unique_id)) { Ref<DummyResource> dr; dr.instantiate(); - dr->set_subindex(index); - p_data->resource_map[index] = dr; - p_data->resource_set.insert(dr); + dr->set_scene_unique_id(unique_id); + p_data->resource_map[unique_id] = dr; + uint32_t im_size = p_data->resource_index_map.size(); + p_data->resource_index_map.insert(dr, im_size); } - r_res = p_data->resource_map[index]; + r_res = p_data->resource_map[unique_id]; VariantParser::get_token(p_stream, token, line, r_err_str); if (token.type != VariantParser::TK_PARENTHESIS_CLOSE) { @@ -85,12 +87,12 @@ Error ResourceLoaderText::_parse_sub_resource_dummy(DummyReadData *p_data, Varia Error ResourceLoaderText::_parse_ext_resource_dummy(DummyReadData *p_data, VariantParser::Stream *p_stream, Ref<Resource> &r_res, int &line, String &r_err_str) { VariantParser::Token token; VariantParser::get_token(p_stream, token, line, r_err_str); - if (token.type != VariantParser::TK_NUMBER) { - r_err_str = "Expected number (sub-resource index)"; + if (token.type != VariantParser::TK_NUMBER && token.type != VariantParser::TK_STRING) { + r_err_str = "Expected number (old style sub-resource index) or String (ext-resource ID)"; return ERR_PARSE_ERROR; } - int id = token.value; + String id = token.value; ERR_FAIL_COND_V(!p_data->rev_external_resources.has(id), ERR_PARSE_ERROR); @@ -108,14 +110,14 @@ Error ResourceLoaderText::_parse_ext_resource_dummy(DummyReadData *p_data, Varia Error ResourceLoaderText::_parse_sub_resource(VariantParser::Stream *p_stream, Ref<Resource> &r_res, int &line, String &r_err_str) { VariantParser::Token token; VariantParser::get_token(p_stream, token, line, r_err_str); - if (token.type != VariantParser::TK_NUMBER) { - r_err_str = "Expected number (sub-resource index)"; + if (token.type != VariantParser::TK_NUMBER && token.type != VariantParser::TK_STRING) { + r_err_str = "Expected number (old style sub-resource index) or string"; return ERR_PARSE_ERROR; } - int index = token.value; - ERR_FAIL_COND_V(!int_resources.has(index), ERR_INVALID_PARAMETER); - r_res = int_resources[index]; + String id = token.value; + ERR_FAIL_COND_V(!int_resources.has(id), ERR_INVALID_PARAMETER); + r_res = int_resources[id]; VariantParser::get_token(p_stream, token, line, r_err_str); if (token.type != VariantParser::TK_PARENTHESIS_CLOSE) { @@ -129,16 +131,16 @@ Error ResourceLoaderText::_parse_sub_resource(VariantParser::Stream *p_stream, R Error ResourceLoaderText::_parse_ext_resource(VariantParser::Stream *p_stream, Ref<Resource> &r_res, int &line, String &r_err_str) { VariantParser::Token token; VariantParser::get_token(p_stream, token, line, r_err_str); - if (token.type != VariantParser::TK_NUMBER) { - r_err_str = "Expected number (sub-resource index)"; + if (token.type != VariantParser::TK_NUMBER && token.type != VariantParser::TK_STRING) { + r_err_str = "Expected number (old style sub-resource index) or String (ext-resource ID)"; return ERR_PARSE_ERROR; } - int id = token.value; + String id = token.value; if (!ignore_resource_parsing) { if (!ext_resources.has(id)) { - r_err_str = "Can't load cached ext-resource #" + itos(id); + r_err_str = "Can't load cached ext-resource id: " + id; return ERR_PARSE_ERROR; } @@ -409,7 +411,18 @@ Error ResourceLoaderText::load() { String path = next_tag.fields["path"]; String type = next_tag.fields["type"]; - int index = next_tag.fields["id"]; + String id = next_tag.fields["id"]; + + if (next_tag.fields.has("uid")) { + String uidt = next_tag.fields["uid"]; + ResourceUID::ID uid = ResourceUID::get_singleton()->text_to_id(uidt); + if (uid != ResourceUID::INVALID_ID && ResourceUID::get_singleton()->has_id(uid)) { + // If a UID is found and the path is valid, it will be used, otherwise, it falls back to the path. + path = ResourceUID::get_singleton()->get_id_path(uid); + } else { + WARN_PRINT(String(res_path + ":" + itos(lines) + " - ext_resource, invalid UUID: " + uidt + " - using text path instead: " + path).utf8().get_data()); + } + } if (path.find("://") == -1 && path.is_rel_path()) { // path is relative to file being loaded, so convert to a resource path @@ -453,14 +466,14 @@ Error ResourceLoaderText::load() { } else { #ifdef TOOLS_ENABLED //remember ID for saving - res->set_id_for_path(local_path, index); + res->set_id_for_path(local_path, id); #endif } er.cache = res; } - ext_resources[index] = er; + ext_resources[id] = er; error = VariantParser::parse_tag(&stream, lines, error_text, next_tag, &rp); @@ -489,15 +502,15 @@ Error ResourceLoaderText::load() { if (!next_tag.fields.has("id")) { error = ERR_FILE_CORRUPT; - error_text = "Missing 'index' in external resource tag"; + error_text = "Missing 'id' in external resource tag"; _printerr(); return error; } String type = next_tag.fields["type"]; - int id = next_tag.fields["id"]; + String id = next_tag.fields["id"]; - String path = local_path + "::" + itos(id); + String path = local_path + "::" + id; //bool exists=ResourceCache::has(path); @@ -575,7 +588,7 @@ Error ResourceLoaderText::load() { int_resources[id] = res; //always assign int resources if (do_assign && cache_mode != ResourceFormatLoader::CACHE_MODE_IGNORE) { res->set_path(path, cache_mode == ResourceFormatLoader::CACHE_MODE_REPLACE); - res->set_subindex(id); + res->set_scene_unique_id(id); } if (progress && resources_total > 0) { @@ -736,7 +749,7 @@ void ResourceLoaderText::get_dependencies(FileAccess *p_f, List<String> *p_depen if (!next_tag.fields.has("id")) { error = ERR_FILE_CORRUPT; - error_text = "Missing 'index' in external resource tag"; + error_text = "Missing 'id' in external resource tag"; _printerr(); return; } @@ -744,7 +757,18 @@ void ResourceLoaderText::get_dependencies(FileAccess *p_f, List<String> *p_depen String path = next_tag.fields["path"]; String type = next_tag.fields["type"]; - if (path.find("://") == -1 && path.is_rel_path()) { + bool using_uid = false; + if (next_tag.fields.has("uid")) { + //if uid exists, return uid in text format, not the path + String uidt = next_tag.fields["uid"]; + ResourceUID::ID uid = ResourceUID::get_singleton()->text_to_id(uidt); + if (uid != ResourceUID::INVALID_ID) { + path = ResourceUID::get_singleton()->id_to_text(uid); + using_uid = true; + } + } + + if (!using_uid && path.find("://") == -1 && path.is_rel_path()) { // path is relative to file being loaded, so convert to a resource path path = ProjectSettings::get_singleton()->localize_path(local_path.get_base_dir().plus_file(path)); } @@ -814,9 +838,17 @@ Error ResourceLoaderText::rename_dependencies(FileAccess *p_f, const String &p_p } String path = next_tag.fields["path"]; - int index = next_tag.fields["id"]; + String id = next_tag.fields["id"]; String type = next_tag.fields["type"]; + if (next_tag.fields.has("uid")) { + String uidt = next_tag.fields["uid"]; + ResourceUID::ID uid = ResourceUID::get_singleton()->text_to_id(uidt); + if (uid != ResourceUID::INVALID_ID && ResourceUID::get_singleton()->has_id(uid)) { + // If a UID is found and the path is valid, it will be used, otherwise, it falls back to the path. + path = ResourceUID::get_singleton()->get_id_path(uid); + } + } bool relative = false; if (!path.begins_with("res://")) { path = base_path.plus_file(path).simplify_path(); @@ -833,7 +865,14 @@ Error ResourceLoaderText::rename_dependencies(FileAccess *p_f, const String &p_p path = base_path.path_to_file(path); } - fw->store_line("[ext_resource path=\"" + path + "\" type=\"" + type + "\" id=" + itos(index) + "]"); + String s = "[ext_resource type=\"" + type + "\""; + + ResourceUID::ID uid = ResourceSaver::get_resource_id_for_path(path); + if (uid != ResourceUID::INVALID_ID) { + s += " uid=\"" + ResourceUID::get_singleton()->id_to_text(uid) + "\""; + } + s += " path=\"" + path + "\" id=\"" + id + "\"]"; + fw->store_line(s); // Bundled. tag_end = f->get_position(); } @@ -919,6 +958,12 @@ void ResourceLoaderText::open(FileAccess *p_f, bool p_skip_first_tag) { return; } + if (tag.fields.has("uid")) { + res_uid = ResourceUID::get_singleton()->text_to_id(tag.fields["uid"]); + } else { + res_uid = ResourceUID::INVALID_ID; + } + if (tag.fields.has("load_steps")) { resources_total = tag.fields["load_steps"]; } else { @@ -937,7 +982,6 @@ void ResourceLoaderText::open(FileAccess *p_f, bool p_skip_first_tag) { rp.ext_func = _parse_ext_resources; rp.sub_func = _parse_sub_resources; - rp.func = nullptr; rp.userdata = this; } @@ -974,7 +1018,12 @@ Error ResourceLoaderText::save_as_binary(FileAccess *p_f, const String &p_path) bs_save_unicode_string(wf.f, is_scene ? "PackedScene" : resource_type); wf->store_64(0); //offset to import metadata, this is no longer used - for (int i = 0; i < 14; i++) { + + f->store_32(ResourceFormatSaverBinaryInstance::FORMAT_FLAG_NAMED_SCENE_IDS | ResourceFormatSaverBinaryInstance::FORMAT_FLAG_UIDS); + + f->store_64(res_uid); + + for (int i = 0; i < 5; i++) { wf->store_32(0); // reserved } @@ -1015,17 +1064,23 @@ Error ResourceLoaderText::save_as_binary(FileAccess *p_f, const String &p_path) String path = next_tag.fields["path"]; String type = next_tag.fields["type"]; - int index = next_tag.fields["id"]; + String id = next_tag.fields["id"]; + ResourceUID::ID uid = ResourceUID::INVALID_ID; + if (next_tag.fields.has("uid")) { + String uidt = next_tag.fields["uid"]; + uid = ResourceUID::get_singleton()->text_to_id(uidt); + } bs_save_unicode_string(wf.f, type); bs_save_unicode_string(wf.f, path); + wf.f->store_64(uid); int lindex = dummy_read.external_resources.size(); Ref<DummyResource> dr; dr.instantiate(); dr->set_path("res://dummy" + itos(lindex)); //anything is good to detect it for saving as external dummy_read.external_resources[dr] = lindex; - dummy_read.rev_external_resources[index] = dr; + dummy_read.rev_external_resources[id] = dr; error = VariantParser::parse_tag(&stream, lines, error_text, next_tag, &rp); @@ -1069,7 +1124,7 @@ Error ResourceLoaderText::save_as_binary(FileAccess *p_f, const String &p_path) if (!next_tag.fields.has("id")) { error = ERR_FILE_CORRUPT; - error_text = "Missing 'index' in external resource tag"; + error_text = "Missing 'id' in external resource tag"; _printerr(); return error; } @@ -1114,7 +1169,7 @@ Error ResourceLoaderText::save_as_binary(FileAccess *p_f, const String &p_path) if (assign != String()) { Map<StringName, int> empty_string_map; //unused bs_save_unicode_string(wf2, assign, true); - ResourceFormatSaverBinaryInstance::write_variant(wf2, value, dummy_read.resource_set, dummy_read.external_resources, empty_string_map); + ResourceFormatSaverBinaryInstance::write_variant(wf2, value, dummy_read.resource_index_map, dummy_read.external_resources, empty_string_map); prop_count++; } else if (next_tag.name != String()) { @@ -1165,17 +1220,17 @@ Error ResourceLoaderText::save_as_binary(FileAccess *p_f, const String &p_path) int prop_count = 0; - for (List<PropertyInfo>::Element *E = props.front(); E; E = E->next()) { - if (!(E->get().usage & PROPERTY_USAGE_STORAGE)) { + for (const PropertyInfo &E : props) { + if (!(E.usage & PROPERTY_USAGE_STORAGE)) { continue; } - String name = E->get().name; + String name = E.name; Variant value = packed_scene->get(name); Map<StringName, int> empty_string_map; //unused bs_save_unicode_string(wf2, name, true); - ResourceFormatSaverBinaryInstance::write_variant(wf2, value, dummy_read.resource_set, dummy_read.external_resources, empty_string_map); + ResourceFormatSaverBinaryInstance::write_variant(wf2, value, dummy_read.resource_index_map, dummy_read.external_resources, empty_string_map); prop_count++; } @@ -1255,6 +1310,32 @@ String ResourceLoaderText::recognize(FileAccess *p_f) { return tag.fields["type"]; } +ResourceUID::ID ResourceLoaderText::get_uid(FileAccess *p_f) { + error = OK; + + lines = 1; + f = p_f; + + stream.f = f; + + ignore_resource_parsing = true; + + VariantParser::Tag tag; + Error err = VariantParser::parse_tag(&stream, lines, error_text, tag); + + if (err) { + _printerr(); + return ResourceUID::INVALID_ID; + } + + if (tag.fields.has("uid")) { //field is optional + String uidt = tag.fields["uid"]; + return ResourceUID::get_singleton()->text_to_id(uidt); + } + + return ResourceUID::INVALID_ID; +} + ///////////////////// RES ResourceFormatLoaderText::load(const String &p_path, const String &p_original_path, Error *r_error, bool p_use_sub_threads, float *r_progress, CacheMode p_cache_mode) { @@ -1275,7 +1356,6 @@ RES ResourceFormatLoaderText::load(const String &p_path, const String &p_origina loader.local_path = ProjectSettings::get_singleton()->localize_path(path); loader.progress = r_progress; loader.res_path = loader.local_path; - //loader.set_local_path( ProjectSettings::get_singleton()->localize_path(p_path) ); loader.open(f); err = loader.load(); if (r_error) { @@ -1318,7 +1398,7 @@ String ResourceFormatLoaderText::get_resource_type(const String &p_path) const { return String(); } - //for anyhting else must test.. + // ...for anything else must test... FileAccess *f = FileAccess::open(p_path, FileAccess::READ); if (!f) { @@ -1328,11 +1408,28 @@ String ResourceFormatLoaderText::get_resource_type(const String &p_path) const { ResourceLoaderText loader; loader.local_path = ProjectSettings::get_singleton()->localize_path(p_path); loader.res_path = loader.local_path; - //loader.set_local_path( ProjectSettings::get_singleton()->localize_path(p_path) ); String r = loader.recognize(f); return ClassDB::get_compatibility_remapped_class(r); } +ResourceUID::ID ResourceFormatLoaderText::get_resource_uid(const String &p_path) const { + String ext = p_path.get_extension().to_lower(); + + if (ext != "tscn" && ext != "tres") { + return ResourceUID::INVALID_ID; + } + + FileAccess *f = FileAccess::open(p_path, FileAccess::READ); + if (!f) { + return ResourceUID::INVALID_ID; //could not read + } + + ResourceLoaderText loader; + loader.local_path = ProjectSettings::get_singleton()->localize_path(p_path); + loader.res_path = loader.local_path; + return loader.get_uid(f); +} + void ResourceFormatLoaderText::get_dependencies(const String &p_path, List<String> *p_dependencies, bool p_add_types) { FileAccess *f = FileAccess::open(p_path, FileAccess::READ); if (!f) { @@ -1342,7 +1439,6 @@ void ResourceFormatLoaderText::get_dependencies(const String &p_path, List<Strin ResourceLoaderText loader; loader.local_path = ProjectSettings::get_singleton()->localize_path(p_path); loader.res_path = loader.local_path; - //loader.set_local_path( ProjectSettings::get_singleton()->localize_path(p_path) ); loader.get_dependencies(f, p_dependencies, p_add_types); } @@ -1355,7 +1451,6 @@ Error ResourceFormatLoaderText::rename_dependencies(const String &p_path, const ResourceLoaderText loader; loader.local_path = ProjectSettings::get_singleton()->localize_path(p_path); loader.res_path = loader.local_path; - //loader.set_local_path( ProjectSettings::get_singleton()->localize_path(p_path) ); return loader.rename_dependencies(f, p_path, p_map); } @@ -1371,7 +1466,6 @@ Error ResourceFormatLoaderText::convert_file_to_binary(const String &p_src_path, const String &path = p_src_path; loader.local_path = ProjectSettings::get_singleton()->localize_path(path); loader.res_path = loader.local_path; - //loader.set_local_path( ProjectSettings::get_singleton()->localize_path(p_path) ); loader.open(f); return loader.save_as_binary(f, p_dst_path); } @@ -1394,10 +1488,10 @@ String ResourceFormatSaverTextInstance::_write_resources(void *ud, const RES &p_ String ResourceFormatSaverTextInstance::_write_resource(const RES &res) { if (external_resources.has(res)) { - return "ExtResource( " + itos(external_resources[res]) + " )"; + return "ExtResource( \"" + external_resources[res] + "\" )"; } else { if (internal_resources.has(res)) { - return "SubResource( " + itos(internal_resources[res]) + " )"; + return "SubResource( \"" + internal_resources[res] + "\" )"; } else if (res->get_path().length() && res->get_path().find("::") == -1) { if (res->get_path() == local_path) { //circular reference attempt return "null"; @@ -1426,8 +1520,11 @@ void ResourceFormatSaverTextInstance::_find_resources(const Variant &p_variant, ERR_PRINT("Circular reference to resource being saved found: '" + local_path + "' will be null next time it's loaded."); return; } - int index = external_resources.size(); - external_resources[res] = index; + + // Use a numeric ID as a base, because they are sorted in natural order before saving. + // This increases the chances of thread loading to fetch them first. + String id = itos(external_resources.size() + 1) + "_" + Resource::generate_scene_unique_id(); + external_resources[res] = id; return; } @@ -1483,8 +1580,8 @@ void ResourceFormatSaverTextInstance::_find_resources(const Variant &p_variant, Dictionary d = p_variant; List<Variant> keys; d.get_key_list(&keys); - for (List<Variant>::Element *E = keys.front(); E; E = E->next()) { - Variant v = d[E->get()]; + for (const Variant &E : keys) { + Variant v = d[E]; _find_resources(v); } } break; @@ -1513,11 +1610,11 @@ Error ResourceFormatSaverTextInstance::save(const String &p_path, const RES &p_r takeover_paths = false; } - // save resources + // Save resources. _find_resources(p_resource, true); if (packed_scene.is_valid()) { - //add instances to external resources if saving a packed scene + // Add instances to external resources if saving a packed scene. for (int i = 0; i < packed_scene->get_state()->get_node_count(); i++) { if (packed_scene->get_state()->is_node_instance_placeholder(i)) { continue; @@ -1525,8 +1622,8 @@ Error ResourceFormatSaverTextInstance::save(const String &p_path, const RES &p_r Ref<PackedScene> instance = packed_scene->get_state()->get_node_instance(i); if (instance.is_valid() && !external_resources.has(instance)) { - int index = external_resources.size(); - external_resources[instance] = index; + int index = external_resources.size() + 1; + external_resources[instance] = itos(index) + "_" + Resource::generate_scene_unique_id(); // Keep the order for improved thread loading performance. } } } @@ -1537,64 +1634,74 @@ Error ResourceFormatSaverTextInstance::save(const String &p_path, const RES &p_r title += "type=\"" + p_resource->get_class() + "\" "; } int load_steps = saved_resources.size() + external_resources.size(); - /* - if (packed_scene.is_valid()) { - load_steps+=packed_scene->get_node_count(); - } - //no, better to not use load steps from nodes, no point to that - */ if (load_steps > 1) { title += "load_steps=" + itos(load_steps) + " "; } title += "format=" + itos(FORMAT_VERSION) + ""; + ResourceUID::ID uid = ResourceSaver::get_resource_id_for_path(local_path, true); + + if (uid != ResourceUID::INVALID_ID) { + title += " uid=\"" + ResourceUID::get_singleton()->id_to_text(uid) + "\""; + } + f->store_string(title); - f->store_line("]\n"); //one empty line + f->store_line("]\n"); // One empty line. } #ifdef TOOLS_ENABLED - //keep order from cached ids - Set<int> cached_ids_found; - for (Map<RES, int>::Element *E = external_resources.front(); E; E = E->next()) { - int cached_id = E->key()->get_id_for_path(local_path); - if (cached_id < 0 || cached_ids_found.has(cached_id)) { - E->get() = -1; //reset + // Keep order from cached ids. + Set<String> cached_ids_found; + for (Map<RES, String>::Element *E = external_resources.front(); E; E = E->next()) { + String cached_id = E->key()->get_id_for_path(local_path); + if (cached_id == "" || cached_ids_found.has(cached_id)) { + int sep_pos = E->get().find("_"); + if (sep_pos != -1) { + E->get() = E->get().substr(0, sep_pos + 1); // Keep the order found, for improved thread loading performance. + } else { + E->get() = ""; + } + } else { E->get() = cached_id; cached_ids_found.insert(cached_id); } } - //create IDs for non cached resources - for (Map<RES, int>::Element *E = external_resources.front(); E; E = E->next()) { - if (cached_ids_found.has(E->get())) { //already cached, go on + // Create IDs for non cached resources. + for (Map<RES, String>::Element *E = external_resources.front(); E; E = E->next()) { + if (cached_ids_found.has(E->get())) { // Already cached, go on. continue; } - int attempt = 1; //start from one, more readable format - while (cached_ids_found.has(attempt)) { - attempt++; + String attempt; + while (true) { + attempt = E->get() + Resource::generate_scene_unique_id(); + if (!cached_ids_found.has(attempt)) { + break; + } } cached_ids_found.insert(attempt); E->get() = attempt; - //update also in resource + // Update also in resource. Ref<Resource> res = E->key(); res->set_id_for_path(local_path, attempt); } #else - //make sure to start from one, as it makes format more readable - for (Map<RES, int>::Element *E = external_resources.front(); E; E = E->next()) { - E->get() = E->get() + 1; + // Make sure to start from one, as it makes format more readable. + int counter = 1; + for (Map<RES, String>::Element *E = external_resources.front(); E; E = E->next()) { + E->get() = itos(counter++); } #endif Vector<ResourceSort> sorted_er; - for (Map<RES, int>::Element *E = external_resources.front(); E; E = E->next()) { + for (Map<RES, String>::Element *E = external_resources.front(); E; E = E->next()) { ResourceSort rs; rs.resource = E->key(); - rs.index = E->get(); + rs.id = E->get(); sorted_er.push_back(rs); } @@ -1603,23 +1710,30 @@ Error ResourceFormatSaverTextInstance::save(const String &p_path, const RES &p_r for (int i = 0; i < sorted_er.size(); i++) { String p = sorted_er[i].resource->get_path(); - f->store_string("[ext_resource path=\"" + p + "\" type=\"" + sorted_er[i].resource->get_save_class() + "\" id=" + itos(sorted_er[i].index) + "]\n"); //bundled + String s = "[ext_resource type=\"" + sorted_er[i].resource->get_save_class() + "\""; + + ResourceUID::ID uid = ResourceSaver::get_resource_id_for_path(p, false); + if (uid != ResourceUID::INVALID_ID) { + s += " uid=\"" + ResourceUID::get_singleton()->id_to_text(uid) + "\""; + } + s += " path=\"" + p + "\" id=\"" + sorted_er[i].id + "\"]\n"; + f->store_string(s); // Bundled. } if (external_resources.size()) { - f->store_line(String()); //separate + f->store_line(String()); // Separate. } - Set<int> used_indices; + Set<String> used_unique_ids; for (List<RES>::Element *E = saved_resources.front(); E; E = E->next()) { RES res = E->get(); if (E->next() && (res->get_path() == "" || res->get_path().find("::") != -1)) { - if (res->get_subindex() != 0) { - if (used_indices.has(res->get_subindex())) { - res->set_subindex(0); //repeated + if (res->get_scene_unique_id() != "") { + if (used_unique_ids.has(res->get_scene_unique_id())) { + res->set_scene_unique_id(""); // Repeated. } else { - used_indices.insert(res->get_subindex()); + used_unique_ids.insert(res->get_scene_unique_id()); } } } @@ -1631,31 +1745,35 @@ Error ResourceFormatSaverTextInstance::save(const String &p_path, const RES &p_r bool main = (E->next() == nullptr); if (main && packed_scene.is_valid()) { - break; //save as a scene + break; // Save as a scene. } if (main) { f->store_line("[resource]"); } else { String line = "[sub_resource "; - if (res->get_subindex() == 0) { - int new_subindex = 1; - if (used_indices.size()) { - new_subindex = used_indices.back()->get() + 1; + if (res->get_scene_unique_id() == "") { + String new_id; + while (true) { + new_id = res->get_class() + "_" + Resource::generate_scene_unique_id(); + + if (!used_unique_ids.has(new_id)) { + break; + } } - res->set_subindex(new_subindex); - used_indices.insert(new_subindex); + res->set_scene_unique_id(new_id); + used_unique_ids.insert(new_id); } - int idx = res->get_subindex(); - line += "type=\"" + res->get_class() + "\" id=" + itos(idx); - f->store_line(line + "]"); + String id = res->get_scene_unique_id(); + line += "type=\"" + res->get_class() + "\" id=\"" + id; + f->store_line(line + "\"]"); if (takeover_paths) { - res->set_path(p_path + "::" + itos(idx), true); + res->set_path(p_path + "::" + id, true); } - internal_resources[res] = idx; + internal_resources[res] = id; #ifdef TOOLS_ENABLED res->set_edited(false); #endif @@ -1663,7 +1781,6 @@ Error ResourceFormatSaverTextInstance::save(const String &p_path, const RES &p_r List<PropertyInfo> property_list; res->get_property_list(&property_list); - //property_list.sort(); for (List<PropertyInfo>::Element *PE = property_list.front(); PE; PE = PE->next()) { if (skip_editor && PE->get().name.begins_with("__editor")) { continue; @@ -1704,7 +1821,7 @@ Error ResourceFormatSaverTextInstance::save(const String &p_path, const RES &p_r } if (packed_scene.is_valid()) { - //if this is a scene, save nodes and connections! + // If this is a scene, save nodes and connections! Ref<SceneState> state = packed_scene->get_state(); for (int i = 0; i < state->get_node_count(); i++) { StringName type = state->get_node_type(i); @@ -1812,7 +1929,6 @@ Error ResourceFormatSaverTextInstance::save(const String &p_path, const RES &p_r } f->close(); - //memdelete(f); return OK; } diff --git a/scene/resources/resource_format_text.h b/scene/resources/resource_format_text.h index f5d9cca859..373e71b2c4 100644 --- a/scene/resources/resource_format_text.h +++ b/scene/resources/resource_format_text.h @@ -58,10 +58,8 @@ class ResourceLoaderText { bool ignore_resource_parsing = false; - //Map<String,String> remaps; - - Map<int, ExtResource> ext_resources; - Map<int, RES> int_resources; + Map<String, ExtResource> ext_resources; + Map<String, RES> int_resources; int resources_total = 0; int resource_current = 0; @@ -76,8 +74,9 @@ class ResourceLoaderText { mutable int lines = 0; + ResourceUID::ID res_uid = ResourceUID::INVALID_ID; + Map<String, String> remaps; - //void _printerr(); static Error _parse_sub_resources(void *p_self, VariantParser::Stream *p_stream, Ref<Resource> &r_res, int &line, String &r_err_str) { return reinterpret_cast<ResourceLoaderText *>(p_self)->_parse_sub_resource(p_stream, r_res, line, r_err_str); } static Error _parse_ext_resources(void *p_self, VariantParser::Stream *p_stream, Ref<Resource> &r_res, int &line, String &r_err_str) { return reinterpret_cast<ResourceLoaderText *>(p_self)->_parse_ext_resource(p_stream, r_res, line, r_err_str); } @@ -92,9 +91,9 @@ class ResourceLoaderText { struct DummyReadData { Map<RES, int> external_resources; - Map<int, RES> rev_external_resources; - Set<RES> resource_set; - Map<int, RES> resource_map; + Map<String, RES> rev_external_resources; + Map<RES, int> resource_index_map; + Map<String, RES> resource_map; }; static Error _parse_sub_resource_dummys(void *p_self, VariantParser::Stream *p_stream, Ref<Resource> &r_res, int &line, String &r_err_str) { return _parse_sub_resource_dummy((DummyReadData *)(p_self), p_stream, r_res, line, r_err_str); } @@ -123,6 +122,7 @@ public: void open(FileAccess *p_f, bool p_skip_first_tag = false); String recognize(FileAccess *p_f); + ResourceUID::ID get_uid(FileAccess *p_f); void get_dependencies(FileAccess *p_f, List<String> *p_dependencies, bool p_add_types); Error rename_dependencies(FileAccess *p_f, const String &p_path, const Map<String, String> &p_map); @@ -139,6 +139,7 @@ public: virtual void get_recognized_extensions(List<String> *p_extensions) const; virtual bool handles_type(const String &p_type) const; virtual String get_resource_type(const String &p_path) const; + virtual ResourceUID::ID get_resource_uid(const String &p_path) const; virtual void get_dependencies(const String &p_path, List<String> *p_dependencies, bool p_add_types = false); virtual Error rename_dependencies(const String &p_path, const Map<String, String> &p_map); @@ -168,14 +169,14 @@ class ResourceFormatSaverTextInstance { Set<RES> resource_set; List<RES> saved_resources; - Map<RES, int> external_resources; - Map<RES, int> internal_resources; + Map<RES, String> external_resources; + Map<RES, String> internal_resources; struct ResourceSort { RES resource; - int index = 0; + String id; bool operator<(const ResourceSort &p_right) const { - return index < p_right.index; + return id.naturalnocasecmp_to(p_right.id) < 0; } }; diff --git a/scene/resources/shader.cpp b/scene/resources/shader.cpp index f19d08dbb1..424a54f344 100644 --- a/scene/resources/shader.cpp +++ b/scene/resources/shader.cpp @@ -72,13 +72,12 @@ void Shader::get_param_list(List<PropertyInfo> *p_params) const { params_cache.clear(); params_cache_dirty = false; - for (List<PropertyInfo>::Element *E = local.front(); E; E = E->next()) { - PropertyInfo pi = E->get(); + for (PropertyInfo &pi : local) { if (default_textures.has(pi.name)) { //do not show default textures continue; } pi.name = "shader_param/" + pi.name; - params_cache[pi.name] = E->get().name; + params_cache[pi.name] = pi.name; if (p_params) { //small little hack if (pi.type == Variant::RID) { diff --git a/scene/resources/sky_material.cpp b/scene/resources/sky_material.cpp index 89b3336118..ec00f9d7b7 100644 --- a/scene/resources/sky_material.cpp +++ b/scene/resources/sky_material.cpp @@ -30,6 +30,9 @@ #include "sky_material.h" +Mutex ProceduralSkyMaterial::shader_mutex; +RID ProceduralSkyMaterial::shader; + void ProceduralSkyMaterial::set_sky_top_color(const Color &p_sky_top) { sky_top_color = p_sky_top; RS::get_singleton()->material_set_param(_get_material(), "sky_top_color", sky_top_color.to_linear()); @@ -128,7 +131,17 @@ Shader::Mode ProceduralSkyMaterial::get_shader_mode() const { return Shader::MODE_SKY; } +RID ProceduralSkyMaterial::get_rid() const { + _update_shader(); + if (!shader_set) { + RS::get_singleton()->material_set_shader(_get_material(), shader); + shader_set = true; + } + return _get_material(); +} + RID ProceduralSkyMaterial::get_shader_rid() const { + _update_shader(); return shader; } @@ -180,72 +193,89 @@ void ProceduralSkyMaterial::_bind_methods() { ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "sun_curve", PROPERTY_HINT_EXP_EASING), "set_sun_curve", "get_sun_curve"); } -ProceduralSkyMaterial::ProceduralSkyMaterial() { - String code = "shader_type sky;\n\n"; - - code += "uniform vec4 sky_top_color : hint_color = vec4(0.35, 0.46, 0.71, 1.0);\n"; - code += "uniform vec4 sky_horizon_color : hint_color = vec4(0.55, 0.69, 0.81, 1.0);\n"; - code += "uniform float sky_curve : hint_range(0, 1) = 0.09;\n"; - code += "uniform float sky_energy = 1.0;\n\n"; - code += "uniform vec4 ground_bottom_color : hint_color = vec4(0.12, 0.12, 0.13, 1.0);\n"; - code += "uniform vec4 ground_horizon_color : hint_color = vec4(0.37, 0.33, 0.31, 1.0);\n"; - code += "uniform float ground_curve : hint_range(0, 1) = 0.02;\n"; - code += "uniform float ground_energy = 1.0;\n\n"; - code += "uniform float sun_angle_max = 1.74;\n"; - code += "uniform float sun_curve : hint_range(0, 1) = 0.05;\n\n"; - code += "void sky() {\n"; - code += "\tfloat v_angle = acos(clamp(EYEDIR.y, -1.0, 1.0));\n"; - code += "\tfloat c = (1.0 - v_angle / (PI * 0.5));\n"; - code += "\tvec3 sky = mix(sky_horizon_color.rgb, sky_top_color.rgb, clamp(1.0 - pow(1.0 - c, 1.0 / sky_curve), 0.0, 1.0));\n"; - code += "\tsky *= sky_energy;\n"; - code += "\tif (LIGHT0_ENABLED) {\n"; - code += "\t\tfloat sun_angle = acos(dot(LIGHT0_DIRECTION, EYEDIR));\n"; - code += "\t\tif (sun_angle < LIGHT0_SIZE) {\n"; - code += "\t\t\tsky = LIGHT0_COLOR * LIGHT0_ENERGY;\n"; - code += "\t\t} else if (sun_angle < sun_angle_max) {\n"; - code += "\t\t\tfloat c2 = (sun_angle - LIGHT0_SIZE) / (sun_angle_max - LIGHT0_SIZE);\n"; - code += "\t\t\tsky = mix(LIGHT0_COLOR * LIGHT0_ENERGY, sky, clamp(1.0 - pow(1.0 - c2, 1.0 / sun_curve), 0.0, 1.0));\n"; - code += "\t\t}\n"; - code += "\t}\n"; - code += "\tif (LIGHT1_ENABLED) {\n"; - code += "\t\tfloat sun_angle = acos(dot(LIGHT1_DIRECTION, EYEDIR));\n"; - code += "\t\tif (sun_angle < LIGHT1_SIZE) {\n"; - code += "\t\t\tsky = LIGHT1_COLOR * LIGHT1_ENERGY;\n"; - code += "\t\t} else if (sun_angle < sun_angle_max) {\n"; - code += "\t\t\tfloat c2 = (sun_angle - LIGHT1_SIZE) / (sun_angle_max - LIGHT1_SIZE);\n"; - code += "\t\t\tsky = mix(LIGHT1_COLOR * LIGHT1_ENERGY, sky, clamp(1.0 - pow(1.0 - c2, 1.0 / sun_curve), 0.0, 1.0));\n"; - code += "\t\t}\n"; - code += "\t}\n"; - code += "\tif (LIGHT2_ENABLED) {\n"; - code += "\t\tfloat sun_angle = acos(dot(LIGHT2_DIRECTION, EYEDIR));\n"; - code += "\t\tif (sun_angle < LIGHT2_SIZE) {\n"; - code += "\t\t\tsky = LIGHT2_COLOR * LIGHT2_ENERGY;\n"; - code += "\t\t} else if (sun_angle < sun_angle_max) {\n"; - code += "\t\t\tfloat c2 = (sun_angle - LIGHT2_SIZE) / (sun_angle_max - LIGHT2_SIZE);\n"; - code += "\t\t\tsky = mix(LIGHT2_COLOR * LIGHT2_ENERGY, sky, clamp(1.0 - pow(1.0 - c2, 1.0 / sun_curve), 0.0, 1.0));\n"; - code += "\t\t}\n"; - code += "\t}\n"; - code += "\tif (LIGHT3_ENABLED) {\n"; - code += "\t\tfloat sun_angle = acos(dot(LIGHT3_DIRECTION, EYEDIR));\n"; - code += "\t\tif (sun_angle < LIGHT3_SIZE) {\n"; - code += "\t\t\tsky = LIGHT3_COLOR * LIGHT3_ENERGY;\n"; - code += "\t\t} else if (sun_angle < sun_angle_max) {\n"; - code += "\t\t\tfloat c2 = (sun_angle - LIGHT3_SIZE) / (sun_angle_max - LIGHT3_SIZE);\n"; - code += "\t\t\tsky = mix(LIGHT3_COLOR * LIGHT3_ENERGY, sky, clamp(1.0 - pow(1.0 - c2, 1.0 / sun_curve), 0.0, 1.0));\n"; - code += "\t\t}\n"; - code += "\t}\n"; - code += "\tc = (v_angle - (PI * 0.5)) / (PI * 0.5);\n"; - code += "\tvec3 ground = mix(ground_horizon_color.rgb, ground_bottom_color.rgb, clamp(1.0 - pow(1.0 - c, 1.0 / ground_curve), 0.0, 1.0));\n"; - code += "\tground *= ground_energy;\n"; - code += "\tCOLOR = mix(ground, sky, step(0.0, EYEDIR.y));\n"; - code += "}\n"; - - shader = RS::get_singleton()->shader_create(); - - RS::get_singleton()->shader_set_code(shader, code); - - RS::get_singleton()->material_set_shader(_get_material(), shader); +void ProceduralSkyMaterial::cleanup_shader() { + if (shader.is_valid()) { + RS::get_singleton()->free(shader); + } +} + +void ProceduralSkyMaterial::_update_shader() { + shader_mutex.lock(); + if (shader.is_null()) { + shader = RS::get_singleton()->shader_create(); + + RS::get_singleton()->shader_set_code(shader, R"( +shader_type sky; + +uniform vec4 sky_top_color : hint_color = vec4(0.35, 0.46, 0.71, 1.0); +uniform vec4 sky_horizon_color : hint_color = vec4(0.55, 0.69, 0.81, 1.0); +uniform float sky_curve : hint_range(0, 1) = 0.09; +uniform float sky_energy = 1.0; +uniform vec4 ground_bottom_color : hint_color = vec4(0.12, 0.12, 0.13, 1.0); +uniform vec4 ground_horizon_color : hint_color = vec4(0.37, 0.33, 0.31, 1.0); +uniform float ground_curve : hint_range(0, 1) = 0.02; +uniform float ground_energy = 1.0; +uniform float sun_angle_max = 1.74; +uniform float sun_curve : hint_range(0, 1) = 0.05; + +void sky() { + float v_angle = acos(clamp(EYEDIR.y, -1.0, 1.0)); + float c = (1.0 - v_angle / (PI * 0.5)); + vec3 sky = mix(sky_horizon_color.rgb, sky_top_color.rgb, clamp(1.0 - pow(1.0 - c, 1.0 / sky_curve), 0.0, 1.0)); + sky *= sky_energy; + + if (LIGHT0_ENABLED) { + float sun_angle = acos(dot(LIGHT0_DIRECTION, EYEDIR)); + if (sun_angle < LIGHT0_SIZE) { + sky = LIGHT0_COLOR * LIGHT0_ENERGY; + } else if (sun_angle < sun_angle_max) { + float c2 = (sun_angle - LIGHT0_SIZE) / (sun_angle_max - LIGHT0_SIZE); + sky = mix(LIGHT0_COLOR * LIGHT0_ENERGY, sky, clamp(1.0 - pow(1.0 - c2, 1.0 / sun_curve), 0.0, 1.0)); + } + } + + if (LIGHT1_ENABLED) { + float sun_angle = acos(dot(LIGHT1_DIRECTION, EYEDIR)); + if (sun_angle < LIGHT1_SIZE) { + sky = LIGHT1_COLOR * LIGHT1_ENERGY; + } else if (sun_angle < sun_angle_max) { + float c2 = (sun_angle - LIGHT1_SIZE) / (sun_angle_max - LIGHT1_SIZE); + sky = mix(LIGHT1_COLOR * LIGHT1_ENERGY, sky, clamp(1.0 - pow(1.0 - c2, 1.0 / sun_curve), 0.0, 1.0)); + } + } + + if (LIGHT2_ENABLED) { + float sun_angle = acos(dot(LIGHT2_DIRECTION, EYEDIR)); + if (sun_angle < LIGHT2_SIZE) { + sky = LIGHT2_COLOR * LIGHT2_ENERGY; + } else if (sun_angle < sun_angle_max) { + float c2 = (sun_angle - LIGHT2_SIZE) / (sun_angle_max - LIGHT2_SIZE); + sky = mix(LIGHT2_COLOR * LIGHT2_ENERGY, sky, clamp(1.0 - pow(1.0 - c2, 1.0 / sun_curve), 0.0, 1.0)); + } + } + + if (LIGHT3_ENABLED) { + float sun_angle = acos(dot(LIGHT3_DIRECTION, EYEDIR)); + if (sun_angle < LIGHT3_SIZE) { + sky = LIGHT3_COLOR * LIGHT3_ENERGY; + } else if (sun_angle < sun_angle_max) { + float c2 = (sun_angle - LIGHT3_SIZE) / (sun_angle_max - LIGHT3_SIZE); + sky = mix(LIGHT3_COLOR * LIGHT3_ENERGY, sky, clamp(1.0 - pow(1.0 - c2, 1.0 / sun_curve), 0.0, 1.0)); + } + } + + c = (v_angle - (PI * 0.5)) / (PI * 0.5); + vec3 ground = mix(ground_horizon_color.rgb, ground_bottom_color.rgb, clamp(1.0 - pow(1.0 - c, 1.0 / ground_curve), 0.0, 1.0)); + ground *= ground_energy; + + COLOR = mix(ground, sky, step(0.0, EYEDIR.y)); +} +)"); + } + shader_mutex.unlock(); +} +ProceduralSkyMaterial::ProceduralSkyMaterial() { set_sky_top_color(Color(0.35, 0.46, 0.71)); set_sky_horizon_color(Color(0.55, 0.69, 0.81)); set_sky_curve(0.09); @@ -261,7 +291,6 @@ ProceduralSkyMaterial::ProceduralSkyMaterial() { } ProceduralSkyMaterial::~ProceduralSkyMaterial() { - RS::get_singleton()->free(shader); RS::get_singleton()->material_set_shader(_get_material(), RID()); } @@ -286,7 +315,17 @@ Shader::Mode PanoramaSkyMaterial::get_shader_mode() const { return Shader::MODE_SKY; } +RID PanoramaSkyMaterial::get_rid() const { + _update_shader(); + if (!shader_set) { + RS::get_singleton()->material_set_shader(_get_material(), shader); + shader_set = true; + } + return _get_material(); +} + RID PanoramaSkyMaterial::get_shader_rid() const { + _update_shader(); return shader; } @@ -297,23 +336,38 @@ void PanoramaSkyMaterial::_bind_methods() { ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "panorama", PROPERTY_HINT_RESOURCE_TYPE, "Texture2D"), "set_panorama", "get_panorama"); } -PanoramaSkyMaterial::PanoramaSkyMaterial() { - String code = "shader_type sky;\n\n"; +Mutex PanoramaSkyMaterial::shader_mutex; +RID PanoramaSkyMaterial::shader; + +void PanoramaSkyMaterial::cleanup_shader() { + if (shader.is_valid()) { + RS::get_singleton()->free(shader); + } +} + +void PanoramaSkyMaterial::_update_shader() { + shader_mutex.lock(); + if (shader.is_null()) { + shader = RS::get_singleton()->shader_create(); - code += "uniform sampler2D source_panorama : filter_linear;\n"; - code += "void sky() {\n"; - code += "\tCOLOR = texture(source_panorama, SKY_COORDS).rgb;\n"; - code += "}"; + RS::get_singleton()->shader_set_code(shader, R"( +shader_type sky; - shader = RS::get_singleton()->shader_create(); +uniform sampler2D source_panorama : filter_linear; - RS::get_singleton()->shader_set_code(shader, code); +void sky() { + COLOR = texture(source_panorama, SKY_COORDS).rgb; +} +)"); + } + + shader_mutex.unlock(); +} - RS::get_singleton()->material_set_shader(_get_material(), shader); +PanoramaSkyMaterial::PanoramaSkyMaterial() { } PanoramaSkyMaterial::~PanoramaSkyMaterial() { - RS::get_singleton()->free(shader); RS::get_singleton()->material_set_shader(_get_material(), RID()); } @@ -428,10 +482,23 @@ Shader::Mode PhysicalSkyMaterial::get_shader_mode() const { return Shader::MODE_SKY; } +RID PhysicalSkyMaterial::get_rid() const { + _update_shader(); + if (!shader_set) { + RS::get_singleton()->material_set_shader(_get_material(), shader); + shader_set = true; + } + return _get_material(); +} + RID PhysicalSkyMaterial::get_shader_rid() const { + _update_shader(); return shader; } +Mutex PhysicalSkyMaterial::shader_mutex; +RID PhysicalSkyMaterial::shader; + void PhysicalSkyMaterial::_bind_methods() { ClassDB::bind_method(D_METHOD("set_rayleigh_coefficient", "rayleigh"), &PhysicalSkyMaterial::set_rayleigh_coefficient); ClassDB::bind_method(D_METHOD("get_rayleigh_coefficient"), &PhysicalSkyMaterial::get_rayleigh_coefficient); @@ -483,106 +550,117 @@ void PhysicalSkyMaterial::_bind_methods() { ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "night_sky", PROPERTY_HINT_RESOURCE_TYPE, "Texture2D"), "set_night_sky", "get_night_sky"); } -PhysicalSkyMaterial::PhysicalSkyMaterial() { - String code = "shader_type sky;\n\n"; - - code += "uniform float rayleigh : hint_range(0, 64) = 2.0;\n"; - code += "uniform vec4 rayleigh_color : hint_color = vec4(0.056, 0.14, 0.3, 1.0);\n"; - code += "uniform float mie : hint_range(0, 1) = 0.005;\n"; - code += "uniform float mie_eccentricity : hint_range(-1, 1) = 0.8;\n"; - code += "uniform vec4 mie_color : hint_color = vec4(0.36, 0.56, 0.82, 1.0);\n\n"; - - code += "uniform float turbidity : hint_range(0, 1000) = 10.0;\n"; - code += "uniform float sun_disk_scale : hint_range(0, 360) = 1.0;\n"; - code += "uniform vec4 ground_color : hint_color = vec4(1.0);\n"; - code += "uniform float exposure : hint_range(0, 128) = 0.1;\n"; - code += "uniform float dither_strength : hint_range(0, 10) = 1.0;\n\n"; - - code += "uniform sampler2D night_sky : hint_black;"; - - code += "const vec3 UP = vec3( 0.0, 1.0, 0.0 );\n\n"; - - code += "// Sun constants\n"; - code += "const float SUN_ENERGY = 1000.0;\n\n"; - - code += "// optical length at zenith for molecules\n"; - code += "const float rayleigh_zenith_size = 8.4e3;\n"; - code += "const float mie_zenith_size = 1.25e3;\n\n"; - - code += "float henyey_greenstein(float cos_theta, float g) {\n"; - code += "\tconst float k = 0.0795774715459;\n"; - code += "\treturn k * (1.0 - g * g) / (pow(1.0 + g * g - 2.0 * g * cos_theta, 1.5));\n"; - code += "}\n\n"; - - code += "// From: https://www.shadertoy.com/view/4sfGzS credit to iq\n"; - code += "float hash(vec3 p) {\n"; - code += "\tp = fract( p * 0.3183099 + 0.1 );\n"; - code += "\tp *= 17.0;\n"; - code += "\treturn fract(p.x * p.y * p.z * (p.x + p.y + p.z));\n"; - code += "}\n\n"; - - code += "void sky() {\n"; - code += "\tif (LIGHT0_ENABLED) {\n"; - code += "\t\tfloat zenith_angle = clamp( dot(UP, normalize(LIGHT0_DIRECTION)), -1.0, 1.0 );\n"; - code += "\t\tfloat sun_energy = max(0.0, 1.0 - exp(-((PI * 0.5) - acos(zenith_angle)))) * SUN_ENERGY * LIGHT0_ENERGY;\n"; - code += "\t\tfloat sun_fade = 1.0 - clamp(1.0 - exp(LIGHT0_DIRECTION.y), 0.0, 1.0);\n\n"; - - code += "\t\t// rayleigh coefficients\n"; - code += "\t\tfloat rayleigh_coefficient = rayleigh - ( 1.0 * ( 1.0 - sun_fade ) );\n"; - code += "\t\tvec3 rayleigh_beta = rayleigh_coefficient * rayleigh_color.rgb * 0.0001;\n"; - code += "\t\t// mie coefficients from Preetham\n"; - code += "\t\tvec3 mie_beta = turbidity * mie * mie_color.rgb * 0.000434;\n\n"; - - code += "\t\t// optical length\n"; - code += "\t\tfloat zenith = acos(max(0.0, dot(UP, EYEDIR)));\n"; - code += "\t\tfloat optical_mass = 1.0 / (cos(zenith) + 0.15 * pow(93.885 - degrees(zenith), -1.253));\n"; - code += "\t\tfloat rayleigh_scatter = rayleigh_zenith_size * optical_mass;\n"; - code += "\t\tfloat mie_scatter = mie_zenith_size * optical_mass;\n\n"; - - code += "\t\t// light extinction based on thickness of atmosphere\n"; - code += "\t\tvec3 extinction = exp(-(rayleigh_beta * rayleigh_scatter + mie_beta * mie_scatter));\n\n"; - - code += "\t\t// in scattering\n"; - code += "\t\tfloat cos_theta = dot(EYEDIR, normalize(LIGHT0_DIRECTION));\n\n"; - - code += "\t\tfloat rayleigh_phase = (3.0 / (16.0 * PI)) * (1.0 + pow(cos_theta * 0.5 + 0.5, 2.0));\n"; - code += "\t\tvec3 betaRTheta = rayleigh_beta * rayleigh_phase;\n\n"; - - code += "\t\tfloat mie_phase = henyey_greenstein(cos_theta, mie_eccentricity);\n"; - code += "\t\tvec3 betaMTheta = mie_beta * mie_phase;\n\n"; - - code += "\t\tvec3 Lin = pow(sun_energy * ((betaRTheta + betaMTheta) / (rayleigh_beta + mie_beta)) * (1.0 - extinction), vec3(1.5));\n"; - code += "\t\t// Hack from https://github.com/mrdoob/three.js/blob/master/examples/jsm/objects/Sky.js\n"; - code += "\t\tLin *= mix(vec3(1.0), pow(sun_energy * ((betaRTheta + betaMTheta) / (rayleigh_beta + mie_beta)) * extinction, vec3(0.5)), clamp(pow(1.0 - zenith_angle, 5.0), 0.0, 1.0));\n\n"; - - code += "\t\t// Hack in the ground color\n"; - code += "\t\tLin *= mix(ground_color.rgb, vec3(1.0), smoothstep(-0.1, 0.1, dot(UP, EYEDIR)));\n\n"; - - code += "\t\t// Solar disk and out-scattering\n"; - code += "\t\tfloat sunAngularDiameterCos = cos(LIGHT0_SIZE * sun_disk_scale);\n"; - code += "\t\tfloat sunAngularDiameterCos2 = cos(LIGHT0_SIZE * sun_disk_scale*0.5);\n"; - code += "\t\tfloat sundisk = smoothstep(sunAngularDiameterCos, sunAngularDiameterCos2, cos_theta);\n"; - code += "\t\tvec3 L0 = (sun_energy * 1900.0 * extinction) * sundisk * LIGHT0_COLOR;\n"; - code += "\t\tL0 += texture(night_sky, SKY_COORDS).xyz * extinction;\n\n"; - - code += "\t\tvec3 color = (Lin + L0) * 0.04;\n"; - code += "\t\tCOLOR = pow(color, vec3(1.0 / (1.2 + (1.2 * sun_fade))));\n"; - code += "\t\tCOLOR *= exposure;\n"; - code += "\t\t// Make optional, eliminates banding\n"; - code += "\t\tCOLOR += (hash(EYEDIR * 1741.9782) * 0.08 - 0.04) * 0.016 * dither_strength;\n"; - code += "\t} else {\n"; - code += "\t\t// There is no sun, so display night_sky and nothing else\n"; - code += "\t\tCOLOR = texture(night_sky, SKY_COORDS).xyz * 0.04;\n"; - code += "\t\tCOLOR *= exposure;\n"; - code += "\t}\n"; - code += "}\n"; - - shader = RS::get_singleton()->shader_create(); - - RS::get_singleton()->shader_set_code(shader, code); - - RS::get_singleton()->material_set_shader(_get_material(), shader); +void PhysicalSkyMaterial::cleanup_shader() { + if (shader.is_valid()) { + RS::get_singleton()->free(shader); + } +} + +void PhysicalSkyMaterial::_update_shader() { + shader_mutex.lock(); + if (shader.is_null()) { + shader = RS::get_singleton()->shader_create(); + + RS::get_singleton()->shader_set_code(shader, R"( +shader_type sky; + +uniform float rayleigh : hint_range(0, 64) = 2.0; +uniform vec4 rayleigh_color : hint_color = vec4(0.056, 0.14, 0.3, 1.0); +uniform float mie : hint_range(0, 1) = 0.005; +uniform float mie_eccentricity : hint_range(-1, 1) = 0.8; +uniform vec4 mie_color : hint_color = vec4(0.36, 0.56, 0.82, 1.0); +uniform float turbidity : hint_range(0, 1000) = 10.0; +uniform float sun_disk_scale : hint_range(0, 360) = 1.0; +uniform vec4 ground_color : hint_color = vec4(1.0); +uniform float exposure : hint_range(0, 128) = 0.1; +uniform float dither_strength : hint_range(0, 10) = 1.0; + +uniform sampler2D night_sky : hint_black; + +const vec3 UP = vec3( 0.0, 1.0, 0.0 ); + +// Sun constants +const float SUN_ENERGY = 1000.0; + +// Optical length at zenith for molecules. +const float rayleigh_zenith_size = 8.4e3; +const float mie_zenith_size = 1.25e3; + +float henyey_greenstein(float cos_theta, float g) { + const float k = 0.0795774715459; + return k * (1.0 - g * g) / (pow(1.0 + g * g - 2.0 * g * cos_theta, 1.5)); +} + +// From: https://www.shadertoy.com/view/4sfGzS credit to iq +float hash(vec3 p) { + p = fract( p * 0.3183099 + 0.1 ); + p *= 17.0; + return fract(p.x * p.y * p.z * (p.x + p.y + p.z)); +} + +void sky() { + if (LIGHT0_ENABLED) { + float zenith_angle = clamp( dot(UP, normalize(LIGHT0_DIRECTION)), -1.0, 1.0 ); + float sun_energy = max(0.0, 1.0 - exp(-((PI * 0.5) - acos(zenith_angle)))) * SUN_ENERGY * LIGHT0_ENERGY; + float sun_fade = 1.0 - clamp(1.0 - exp(LIGHT0_DIRECTION.y), 0.0, 1.0); + + // Rayleigh coefficients. + float rayleigh_coefficient = rayleigh - ( 1.0 * ( 1.0 - sun_fade ) ); + vec3 rayleigh_beta = rayleigh_coefficient * rayleigh_color.rgb * 0.0001; + // mie coefficients from Preetham + vec3 mie_beta = turbidity * mie * mie_color.rgb * 0.000434; + + // Optical length. + float zenith = acos(max(0.0, dot(UP, EYEDIR))); + float optical_mass = 1.0 / (cos(zenith) + 0.15 * pow(93.885 - degrees(zenith), -1.253)); + float rayleigh_scatter = rayleigh_zenith_size * optical_mass; + float mie_scatter = mie_zenith_size * optical_mass; + + // Light extinction based on thickness of atmosphere. + vec3 extinction = exp(-(rayleigh_beta * rayleigh_scatter + mie_beta * mie_scatter)); + + // In scattering. + float cos_theta = dot(EYEDIR, normalize(LIGHT0_DIRECTION)); + + float rayleigh_phase = (3.0 / (16.0 * PI)) * (1.0 + pow(cos_theta * 0.5 + 0.5, 2.0)); + vec3 betaRTheta = rayleigh_beta * rayleigh_phase; + + float mie_phase = henyey_greenstein(cos_theta, mie_eccentricity); + vec3 betaMTheta = mie_beta * mie_phase; + + vec3 Lin = pow(sun_energy * ((betaRTheta + betaMTheta) / (rayleigh_beta + mie_beta)) * (1.0 - extinction), vec3(1.5)); + // Hack from https://github.com/mrdoob/three.js/blob/master/examples/jsm/objects/Sky.js + Lin *= mix(vec3(1.0), pow(sun_energy * ((betaRTheta + betaMTheta) / (rayleigh_beta + mie_beta)) * extinction, vec3(0.5)), clamp(pow(1.0 - zenith_angle, 5.0), 0.0, 1.0)); + + // Hack in the ground color. + Lin *= mix(ground_color.rgb, vec3(1.0), smoothstep(-0.1, 0.1, dot(UP, EYEDIR))); + + // Solar disk and out-scattering. + float sunAngularDiameterCos = cos(LIGHT0_SIZE * sun_disk_scale); + float sunAngularDiameterCos2 = cos(LIGHT0_SIZE * sun_disk_scale*0.5); + float sundisk = smoothstep(sunAngularDiameterCos, sunAngularDiameterCos2, cos_theta); + vec3 L0 = (sun_energy * 1900.0 * extinction) * sundisk * LIGHT0_COLOR; + L0 += texture(night_sky, SKY_COORDS).xyz * extinction; + + vec3 color = (Lin + L0) * 0.04; + COLOR = pow(color, vec3(1.0 / (1.2 + (1.2 * sun_fade)))); + COLOR *= exposure; + // Make optional, eliminates banding. + COLOR += (hash(EYEDIR * 1741.9782) * 0.08 - 0.04) * 0.016 * dither_strength; + } else { + // There is no sun, so display night_sky and nothing else. + COLOR = texture(night_sky, SKY_COORDS).xyz * 0.04; + COLOR *= exposure; + } +} +)"); + } + + shader_mutex.unlock(); +} + +PhysicalSkyMaterial::PhysicalSkyMaterial() { set_rayleigh_coefficient(2.0); set_rayleigh_color(Color(0.056, 0.14, 0.3)); set_mie_coefficient(0.005); @@ -596,5 +674,4 @@ PhysicalSkyMaterial::PhysicalSkyMaterial() { } PhysicalSkyMaterial::~PhysicalSkyMaterial() { - RS::get_singleton()->free(shader); } diff --git a/scene/resources/sky_material.h b/scene/resources/sky_material.h index 8fe015519d..63e730617b 100644 --- a/scene/resources/sky_material.h +++ b/scene/resources/sky_material.h @@ -51,7 +51,10 @@ private: float sun_angle_max; float sun_curve; - RID shader; + static Mutex shader_mutex; + static RID shader; + static void _update_shader(); + mutable bool shader_set = false; protected: static void _bind_methods(); @@ -90,6 +93,9 @@ public: virtual Shader::Mode get_shader_mode() const override; virtual RID get_shader_rid() const override; + virtual RID get_rid() const override; + + static void cleanup_shader(); ProceduralSkyMaterial(); ~ProceduralSkyMaterial(); @@ -103,7 +109,11 @@ class PanoramaSkyMaterial : public Material { private: Ref<Texture2D> panorama; - RID shader; + + static Mutex shader_mutex; + static RID shader; + static void _update_shader(); + mutable bool shader_set = false; protected: static void _bind_methods(); @@ -115,6 +125,9 @@ public: virtual Shader::Mode get_shader_mode() const override; virtual RID get_shader_rid() const override; + virtual RID get_rid() const override; + + static void cleanup_shader(); PanoramaSkyMaterial(); ~PanoramaSkyMaterial(); @@ -127,7 +140,8 @@ class PhysicalSkyMaterial : public Material { GDCLASS(PhysicalSkyMaterial, Material); private: - RID shader; + static Mutex shader_mutex; + static RID shader; float rayleigh; Color rayleigh_color; @@ -140,6 +154,8 @@ private: float exposure; float dither_strength; Ref<Texture2D> night_sky; + static void _update_shader(); + mutable bool shader_set = false; protected: static void _bind_methods(); @@ -182,6 +198,9 @@ public: virtual Shader::Mode get_shader_mode() const override; virtual RID get_shader_rid() const override; + static void cleanup_shader(); + virtual RID get_rid() const override; + PhysicalSkyMaterial(); ~PhysicalSkyMaterial(); }; diff --git a/scene/resources/sprite_frames.cpp b/scene/resources/sprite_frames.cpp index df80084c5c..e9adf67559 100644 --- a/scene/resources/sprite_frames.cpp +++ b/scene/resources/sprite_frames.cpp @@ -100,8 +100,8 @@ Vector<String> SpriteFrames::_get_animation_list() const { Vector<String> ret; List<StringName> al; get_animation_list(&al); - for (List<StringName>::Element *E = al.front(); E; E = E->next()) { - ret.push_back(E->get()); + for (const StringName &E : al) { + ret.push_back(E); } return ret; diff --git a/scene/resources/syntax_highlighter.cpp b/scene/resources/syntax_highlighter.cpp index 9dd00849f4..173ce2adce 100644 --- a/scene/resources/syntax_highlighter.cpp +++ b/scene/resources/syntax_highlighter.cpp @@ -405,7 +405,7 @@ void CodeHighlighter::_clear_highlighting_cache() { } void CodeHighlighter::_update_cache() { - font_color = text_edit->get_theme_color("font_color"); + font_color = text_edit->get_theme_color(SNAME("font_color")); } void CodeHighlighter::add_keyword_color(const String &p_keyword, const Color &p_color) { @@ -529,8 +529,8 @@ void CodeHighlighter::set_color_regions(const Dictionary &p_color_regions) { List<Variant> keys; p_color_regions.get_key_list(&keys); - for (List<Variant>::Element *E = keys.front(); E; E = E->next()) { - String key = E->get(); + for (const Variant &E : keys) { + String key = E; String start_key = key.get_slice(" ", 0); String end_key = key.get_slice_count(" ") > 1 ? key.get_slice(" ", 1) : String(); diff --git a/scene/resources/texture.cpp b/scene/resources/texture.cpp index 98997e482a..2ea55843ad 100644 --- a/scene/resources/texture.cpp +++ b/scene/resources/texture.cpp @@ -354,11 +354,11 @@ Ref<Image> StreamTexture2D::load_image_from_file(FileAccess *f, int p_size_limit } Ref<Image> img; - if (data_format == DATA_FORMAT_BASIS_UNIVERSAL) { + if (data_format == DATA_FORMAT_BASIS_UNIVERSAL && Image::basis_universal_unpacker) { img = Image::basis_universal_unpacker(pv); - } else if (data_format == DATA_FORMAT_PNG) { + } else if (data_format == DATA_FORMAT_PNG && Image::png_unpacker) { img = Image::png_unpacker(pv); - } else { + } else if (data_format == DATA_FORMAT_WEBP && Image::webp_unpacker) { img = Image::webp_unpacker(pv); } @@ -1545,19 +1545,19 @@ CurveTexture::~CurveTexture() { ////////////////// -void Curve3Texture::_bind_methods() { - ClassDB::bind_method(D_METHOD("set_width", "width"), &Curve3Texture::set_width); +void CurveXYZTexture::_bind_methods() { + ClassDB::bind_method(D_METHOD("set_width", "width"), &CurveXYZTexture::set_width); - ClassDB::bind_method(D_METHOD("set_curve_x", "curve"), &Curve3Texture::set_curve_x); - ClassDB::bind_method(D_METHOD("get_curve_x"), &Curve3Texture::get_curve_x); + ClassDB::bind_method(D_METHOD("set_curve_x", "curve"), &CurveXYZTexture::set_curve_x); + ClassDB::bind_method(D_METHOD("get_curve_x"), &CurveXYZTexture::get_curve_x); - ClassDB::bind_method(D_METHOD("set_curve_y", "curve"), &Curve3Texture::set_curve_y); - ClassDB::bind_method(D_METHOD("get_curve_y"), &Curve3Texture::get_curve_y); + ClassDB::bind_method(D_METHOD("set_curve_y", "curve"), &CurveXYZTexture::set_curve_y); + ClassDB::bind_method(D_METHOD("get_curve_y"), &CurveXYZTexture::get_curve_y); - ClassDB::bind_method(D_METHOD("set_curve_z", "curve"), &Curve3Texture::set_curve_z); - ClassDB::bind_method(D_METHOD("get_curve_z"), &Curve3Texture::get_curve_z); + ClassDB::bind_method(D_METHOD("set_curve_z", "curve"), &CurveXYZTexture::set_curve_z); + ClassDB::bind_method(D_METHOD("get_curve_z"), &CurveXYZTexture::get_curve_z); - ClassDB::bind_method(D_METHOD("_update"), &Curve3Texture::_update); + ClassDB::bind_method(D_METHOD("_update"), &CurveXYZTexture::_update); ADD_PROPERTY(PropertyInfo(Variant::INT, "width", PROPERTY_HINT_RANGE, "1,4096"), "set_width", "get_width"); ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "curve_x", PROPERTY_HINT_RESOURCE_TYPE, "Curve"), "set_curve_x", "get_curve_x"); @@ -1565,7 +1565,7 @@ void Curve3Texture::_bind_methods() { ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "curve_z", PROPERTY_HINT_RESOURCE_TYPE, "Curve"), "set_curve_z", "get_curve_z"); } -void Curve3Texture::set_width(int p_width) { +void CurveXYZTexture::set_width(int p_width) { ERR_FAIL_COND(p_width < 32 || p_width > 4096); if (_width == p_width) { @@ -1576,11 +1576,11 @@ void Curve3Texture::set_width(int p_width) { _update(); } -int Curve3Texture::get_width() const { +int CurveXYZTexture::get_width() const { return _width; } -void Curve3Texture::ensure_default_setup(float p_min, float p_max) { +void CurveXYZTexture::ensure_default_setup(float p_min, float p_max) { if (_curve_x.is_null()) { Ref<Curve> curve = Ref<Curve>(memnew(Curve)); curve->add_point(Vector2(0, 1)); @@ -1609,46 +1609,46 @@ void Curve3Texture::ensure_default_setup(float p_min, float p_max) { } } -void Curve3Texture::set_curve_x(Ref<Curve> p_curve) { +void CurveXYZTexture::set_curve_x(Ref<Curve> p_curve) { if (_curve_x != p_curve) { if (_curve_x.is_valid()) { - _curve_x->disconnect(CoreStringNames::get_singleton()->changed, callable_mp(this, &Curve3Texture::_update)); + _curve_x->disconnect(CoreStringNames::get_singleton()->changed, callable_mp(this, &CurveXYZTexture::_update)); } _curve_x = p_curve; if (_curve_x.is_valid()) { - _curve_x->connect(CoreStringNames::get_singleton()->changed, callable_mp(this, &Curve3Texture::_update), varray(), CONNECT_REFERENCE_COUNTED); + _curve_x->connect(CoreStringNames::get_singleton()->changed, callable_mp(this, &CurveXYZTexture::_update), varray(), CONNECT_REFERENCE_COUNTED); } _update(); } } -void Curve3Texture::set_curve_y(Ref<Curve> p_curve) { +void CurveXYZTexture::set_curve_y(Ref<Curve> p_curve) { if (_curve_y != p_curve) { if (_curve_y.is_valid()) { - _curve_y->disconnect(CoreStringNames::get_singleton()->changed, callable_mp(this, &Curve3Texture::_update)); + _curve_y->disconnect(CoreStringNames::get_singleton()->changed, callable_mp(this, &CurveXYZTexture::_update)); } _curve_y = p_curve; if (_curve_y.is_valid()) { - _curve_y->connect(CoreStringNames::get_singleton()->changed, callable_mp(this, &Curve3Texture::_update), varray(), CONNECT_REFERENCE_COUNTED); + _curve_y->connect(CoreStringNames::get_singleton()->changed, callable_mp(this, &CurveXYZTexture::_update), varray(), CONNECT_REFERENCE_COUNTED); } _update(); } } -void Curve3Texture::set_curve_z(Ref<Curve> p_curve) { +void CurveXYZTexture::set_curve_z(Ref<Curve> p_curve) { if (_curve_z != p_curve) { if (_curve_z.is_valid()) { - _curve_z->disconnect(CoreStringNames::get_singleton()->changed, callable_mp(this, &Curve3Texture::_update)); + _curve_z->disconnect(CoreStringNames::get_singleton()->changed, callable_mp(this, &CurveXYZTexture::_update)); } _curve_z = p_curve; if (_curve_z.is_valid()) { - _curve_z->connect(CoreStringNames::get_singleton()->changed, callable_mp(this, &Curve3Texture::_update), varray(), CONNECT_REFERENCE_COUNTED); + _curve_z->connect(CoreStringNames::get_singleton()->changed, callable_mp(this, &CurveXYZTexture::_update), varray(), CONNECT_REFERENCE_COUNTED); } _update(); } } -void Curve3Texture::_update() { +void CurveXYZTexture::_update() { Vector<uint8_t> data; data.resize(_width * sizeof(float) * 3); @@ -1714,28 +1714,28 @@ void Curve3Texture::_update() { emit_changed(); } -Ref<Curve> Curve3Texture::get_curve_x() const { +Ref<Curve> CurveXYZTexture::get_curve_x() const { return _curve_x; } -Ref<Curve> Curve3Texture::get_curve_y() const { +Ref<Curve> CurveXYZTexture::get_curve_y() const { return _curve_y; } -Ref<Curve> Curve3Texture::get_curve_z() const { +Ref<Curve> CurveXYZTexture::get_curve_z() const { return _curve_z; } -RID Curve3Texture::get_rid() const { +RID CurveXYZTexture::get_rid() const { if (!_texture.is_valid()) { _texture = RS::get_singleton()->texture_2d_placeholder_create(); } return _texture; } -Curve3Texture::Curve3Texture() {} +CurveXYZTexture::CurveXYZTexture() {} -Curve3Texture::~Curve3Texture() { +CurveXYZTexture::~CurveXYZTexture() { if (_texture.is_valid()) { RS::get_singleton()->free(_texture); } @@ -1790,7 +1790,7 @@ void GradientTexture::_queue_update() { } update_pending = true; - call_deferred("_update"); + call_deferred(SNAME("_update")); } void GradientTexture::_update() { diff --git a/scene/resources/texture.h b/scene/resources/texture.h index 73390039cb..98aa61138d 100644 --- a/scene/resources/texture.h +++ b/scene/resources/texture.h @@ -628,8 +628,8 @@ public: VARIANT_ENUM_CAST(CurveTexture::TextureMode) -class Curve3Texture : public Texture2D { - GDCLASS(Curve3Texture, Texture2D); +class CurveXYZTexture : public Texture2D { + GDCLASS(CurveXYZTexture, Texture2D); RES_BASE_EXTENSION("curvetex") private: @@ -665,8 +665,8 @@ public: virtual int get_height() const override { return 1; } virtual bool has_alpha() const override { return false; } - Curve3Texture(); - ~Curve3Texture(); + CurveXYZTexture(); + ~CurveXYZTexture(); }; class GradientTexture : public Texture2D { diff --git a/scene/resources/theme.cpp b/scene/resources/theme.cpp index 303bbf38f4..e4a731c7f7 100644 --- a/scene/resources/theme.cpp +++ b/scene/resources/theme.cpp @@ -447,8 +447,8 @@ void Theme::_get_property_list(List<PropertyInfo> *p_list) const { // Sort and store properties. list.sort(); - for (List<PropertyInfo>::Element *E = list.front(); E; E = E->next()) { - p_list->push_back(E->get()); + for (const PropertyInfo &E : list) { + p_list->push_back(E); } } @@ -1275,15 +1275,15 @@ void Theme::get_type_variation_list(const StringName &p_base_type, List<StringNa return; } - for (const List<StringName>::Element *E = variation_base_map[p_base_type].front(); E; E = E->next()) { + for (const StringName &E : variation_base_map[p_base_type]) { // Prevent infinite loops if variants were set to be cross-dependent (that's still invalid usage, but handling for stability sake). - if (p_list->find(E->get())) { + if (p_list->find(E)) { continue; } - p_list->push_back(E->get()); + p_list->push_back(E); // Continue looking for sub-variations. - get_type_variation_list(E->get(), p_list); + get_type_variation_list(E, p_list); } } diff --git a/scene/resources/tile_set.cpp b/scene/resources/tile_set.cpp index deee22f05f..737b47ed95 100644 --- a/scene/resources/tile_set.cpp +++ b/scene/resources/tile_set.cpp @@ -41,6 +41,8 @@ /////////////////////////////// TileSet ////////////////////////////////////// +const int TileSet::INVALID_SOURCE = -1; + const char *TileSet::CELL_NEIGHBOR_ENUM_TO_TEXT[] = { "right_side", "right_corner", @@ -127,8 +129,8 @@ void TileSet::_compute_next_source_id() { // Sources management int TileSet::add_source(Ref<TileSetSource> p_tile_set_source, int p_atlas_source_id_override) { - ERR_FAIL_COND_V(!p_tile_set_source.is_valid(), -1); - ERR_FAIL_COND_V_MSG(p_atlas_source_id_override >= 0 && (sources.has(p_atlas_source_id_override)), -1, vformat("Cannot create TileSet atlas source. Another atlas source exists with id %d.", p_atlas_source_id_override)); + ERR_FAIL_COND_V(!p_tile_set_source.is_valid(), TileSet::INVALID_SOURCE); + ERR_FAIL_COND_V_MSG(p_atlas_source_id_override >= 0 && (sources.has(p_atlas_source_id_override)), TileSet::INVALID_SOURCE, vformat("Cannot create TileSet atlas source. Another atlas source exists with id %d.", p_atlas_source_id_override)); int new_source_id = p_atlas_source_id_override >= 0 ? p_atlas_source_id_override : next_source_id; sources[new_source_id] = p_tile_set_source; @@ -191,7 +193,7 @@ int TileSet::get_source_count() const { } int TileSet::get_source_id(int p_index) const { - ERR_FAIL_INDEX_V(p_index, source_ids.size(), -1); + ERR_FAIL_INDEX_V(p_index, source_ids.size(), TileSet::INVALID_SOURCE); return source_ids[p_index]; } @@ -607,6 +609,254 @@ Variant::Type TileSet::get_custom_data_type(int p_layer_id) const { return custom_data_layers[p_layer_id].type; } +void TileSet::set_source_level_tile_proxy(int p_source_from, int p_source_to) { + ERR_FAIL_COND(p_source_from == TileSet::INVALID_SOURCE || p_source_to == TileSet::INVALID_SOURCE); + + source_level_proxies[p_source_from] = p_source_to; + + emit_changed(); +} + +int TileSet::get_source_level_tile_proxy(int p_source_from) { + ERR_FAIL_COND_V(!source_level_proxies.has(p_source_from), TileSet::INVALID_SOURCE); + + return source_level_proxies[p_source_from]; +} + +bool TileSet::has_source_level_tile_proxy(int p_source_from) { + return source_level_proxies.has(p_source_from); +} + +void TileSet::remove_source_level_tile_proxy(int p_source_from) { + ERR_FAIL_COND(!source_level_proxies.has(p_source_from)); + + source_level_proxies.erase(p_source_from); + + emit_changed(); +} + +void TileSet::set_coords_level_tile_proxy(int p_source_from, Vector2i p_coords_from, int p_source_to, Vector2i p_coords_to) { + ERR_FAIL_COND(p_source_from == TileSet::INVALID_SOURCE || p_source_to == TileSet::INVALID_SOURCE); + ERR_FAIL_COND(p_coords_from == TileSetSource::INVALID_ATLAS_COORDS || p_coords_to == TileSetSource::INVALID_ATLAS_COORDS); + + Array from; + from.push_back(p_source_from); + from.push_back(p_coords_from); + + Array to; + to.push_back(p_source_to); + to.push_back(p_coords_to); + + coords_level_proxies[from] = to; + + emit_changed(); +} + +Array TileSet::get_coords_level_tile_proxy(int p_source_from, Vector2i p_coords_from) { + Array from; + from.push_back(p_source_from); + from.push_back(p_coords_from); + + ERR_FAIL_COND_V(!coords_level_proxies.has(from), Array()); + + return coords_level_proxies[from]; +} + +bool TileSet::has_coords_level_tile_proxy(int p_source_from, Vector2i p_coords_from) { + Array from; + from.push_back(p_source_from); + from.push_back(p_coords_from); + + return coords_level_proxies.has(from); +} + +void TileSet::remove_coords_level_tile_proxy(int p_source_from, Vector2i p_coords_from) { + Array from; + from.push_back(p_source_from); + from.push_back(p_coords_from); + + ERR_FAIL_COND(!coords_level_proxies.has(from)); + + coords_level_proxies.erase(from); + + emit_changed(); +} + +void TileSet::set_alternative_level_tile_proxy(int p_source_from, Vector2i p_coords_from, int p_alternative_from, int p_source_to, Vector2i p_coords_to, int p_alternative_to) { + ERR_FAIL_COND(p_source_from == TileSet::INVALID_SOURCE || p_source_to == TileSet::INVALID_SOURCE); + ERR_FAIL_COND(p_coords_from == TileSetSource::INVALID_ATLAS_COORDS || p_coords_to == TileSetSource::INVALID_ATLAS_COORDS); + + Array from; + from.push_back(p_source_from); + from.push_back(p_coords_from); + from.push_back(p_alternative_from); + + Array to; + to.push_back(p_source_to); + to.push_back(p_coords_to); + to.push_back(p_alternative_to); + + alternative_level_proxies[from] = to; + + emit_changed(); +} + +Array TileSet::get_alternative_level_tile_proxy(int p_source_from, Vector2i p_coords_from, int p_alternative_from) { + Array from; + from.push_back(p_source_from); + from.push_back(p_coords_from); + from.push_back(p_alternative_from); + + ERR_FAIL_COND_V(!alternative_level_proxies.has(from), Array()); + + return alternative_level_proxies[from]; +} + +bool TileSet::has_alternative_level_tile_proxy(int p_source_from, Vector2i p_coords_from, int p_alternative_from) { + Array from; + from.push_back(p_source_from); + from.push_back(p_coords_from); + from.push_back(p_alternative_from); + + return alternative_level_proxies.has(from); +} + +void TileSet::remove_alternative_level_tile_proxy(int p_source_from, Vector2i p_coords_from, int p_alternative_from) { + Array from; + from.push_back(p_source_from); + from.push_back(p_coords_from); + from.push_back(p_alternative_from); + + ERR_FAIL_COND(!alternative_level_proxies.has(from)); + + alternative_level_proxies.erase(from); + + emit_changed(); +} + +Array TileSet::get_source_level_tile_proxies() const { + Array output; + for (Map<int, int>::Element *E = source_level_proxies.front(); E; E = E->next()) { + Array proxy; + proxy.push_back(E->key()); + proxy.push_back(E->get()); + output.push_back(proxy); + } + return output; +} + +Array TileSet::get_coords_level_tile_proxies() const { + Array output; + for (Map<Array, Array>::Element *E = coords_level_proxies.front(); E; E = E->next()) { + Array proxy; + proxy.append_array(E->key()); + proxy.append_array(E->get()); + output.push_back(proxy); + } + return output; +} + +Array TileSet::get_alternative_level_tile_proxies() const { + Array output; + for (Map<Array, Array>::Element *E = alternative_level_proxies.front(); E; E = E->next()) { + Array proxy; + proxy.append_array(E->key()); + proxy.append_array(E->get()); + output.push_back(proxy); + } + return output; +} + +Array TileSet::map_tile_proxy(int p_source_from, Vector2i p_coords_from, int p_alternative_from) const { + Array from; + from.push_back(p_source_from); + from.push_back(p_coords_from); + from.push_back(p_alternative_from); + + // Check if the tile is valid, and if so, don't map the tile and return the input. + if (has_source(p_source_from)) { + Ref<TileSetSource> source = get_source(p_source_from); + if (source->has_tile(p_coords_from) && source->has_alternative_tile(p_coords_from, p_alternative_from)) { + return from; + } + } + + // Source, coords and alternative match. + if (alternative_level_proxies.has(from)) { + return alternative_level_proxies[from].duplicate(); + } + + // Source and coords match. + from.pop_back(); + if (coords_level_proxies.has(from)) { + Array output = coords_level_proxies[from].duplicate(); + output.push_back(p_alternative_from); + return output; + } + + // Source matches. + if (source_level_proxies.has(p_source_from)) { + Array output; + output.push_back(source_level_proxies[p_source_from]); + output.push_back(p_coords_from); + output.push_back(p_alternative_from); + return output; + } + + Array output; + output.push_back(p_source_from); + output.push_back(p_coords_from); + output.push_back(p_alternative_from); + return output; +} + +void TileSet::cleanup_invalid_tile_proxies() { + // Source level. + Vector<int> source_to_remove; + for (Map<int, int>::Element *E = source_level_proxies.front(); E; E = E->next()) { + if (has_source(E->key())) { + source_to_remove.append(E->key()); + } + } + for (int i = 0; i < source_to_remove.size(); i++) { + remove_source_level_tile_proxy(source_to_remove[i]); + } + + // Coords level. + Vector<Array> coords_to_remove; + for (Map<Array, Array>::Element *E = coords_level_proxies.front(); E; E = E->next()) { + Array a = E->key(); + if (has_source(a[0]) && get_source(a[0])->has_tile(a[1])) { + coords_to_remove.append(a); + } + } + for (int i = 0; i < coords_to_remove.size(); i++) { + Array a = coords_to_remove[i]; + remove_coords_level_tile_proxy(a[0], a[1]); + } + + // Alternative level. + Vector<Array> alternative_to_remove; + for (Map<Array, Array>::Element *E = alternative_level_proxies.front(); E; E = E->next()) { + Array a = E->key(); + if (has_source(a[0]) && get_source(a[0])->has_tile(a[1]) && get_source(a[0])->has_alternative_tile(a[1], a[2])) { + alternative_to_remove.append(a); + } + } + for (int i = 0; i < alternative_to_remove.size(); i++) { + Array a = alternative_to_remove[i]; + remove_alternative_level_tile_proxy(a[0], a[1], a[2]); + } +} + +void TileSet::clear_tile_proxies() { + source_level_proxies.clear(); + coords_level_proxies.clear(); + alternative_level_proxies.clear(); + + emit_changed(); +} + Vector<Vector2> TileSet::get_tile_shape_polygon() { Vector<Vector2> points; if (tile_shape == TileSet::TILE_SHAPE_SQUARE) { @@ -1539,7 +1789,7 @@ const Vector2i TileSetSource::INVALID_ATLAS_COORDS = Vector2i(-1, -1); const int TileSetSource::INVALID_TILE_ALTERNATIVE = -1; #ifndef DISABLE_DEPRECATED -void TileSet::compatibility_conversion() { +void TileSet::_compatibility_conversion() { for (Map<int, CompatibilityTileData *>::Element *E = compatibility_data.front(); E; E = E->next()) { CompatibilityTileData *ctd = E->value(); @@ -1551,13 +1801,93 @@ void TileSet::compatibility_conversion() { // Handle each tile as a new source. Not optimal but at least it should stay compatible. switch (ctd->tile_mode) { - case 0: // SINGLE_TILE - // TODO - break; - case 1: // AUTO_TILE - // TODO - break; - case 2: // ATLAS_TILE + case COMPATIBILITY_TILE_MODE_SINGLE_TILE: { + atlas_source->set_margins(ctd->region.get_position()); + atlas_source->set_texture_region_size(ctd->region.get_size()); + + Vector2i coords; + for (int flags = 0; flags < 8; flags++) { + bool flip_h = flags & 1; + bool flip_v = flags & 2; + bool transpose = flags & 4; + + int alternative_tile = 0; + if (!atlas_source->has_tile(coords)) { + atlas_source->create_tile(coords); + } else { + alternative_tile = atlas_source->create_alternative_tile(coords); + } + + // Add to the mapping. + Array key_array; + key_array.push_back(flip_h); + key_array.push_back(flip_v); + key_array.push_back(transpose); + + Array value_array; + value_array.push_back(source_id); + value_array.push_back(coords); + value_array.push_back(alternative_tile); + + if (!compatibility_tilemap_mapping.has(E->key())) { + compatibility_tilemap_mapping[E->key()] = Map<Array, Array>(); + } + compatibility_tilemap_mapping[E->key()][key_array] = value_array; + compatibility_tilemap_mapping_tile_modes[E->key()] = COMPATIBILITY_TILE_MODE_SINGLE_TILE; + + TileData *tile_data = Object::cast_to<TileData>(atlas_source->get_tile_data(coords, alternative_tile)); + + tile_data->set_flip_h(flip_h); + tile_data->set_flip_v(flip_v); + tile_data->set_transpose(transpose); + tile_data->tile_set_material(ctd->material); + tile_data->set_modulate(ctd->modulate); + tile_data->set_z_index(ctd->z_index); + + if (ctd->occluder.is_valid()) { + if (get_occlusion_layers_count() < 1) { + set_occlusion_layers_count(1); + } + tile_data->set_occluder(0, ctd->occluder); + } + if (ctd->navigation.is_valid()) { + if (get_navigation_layers_count() < 1) { + set_navigation_layers_count(1); + } + tile_data->set_navigation_polygon(0, ctd->autotile_navpoly_map[coords]); + } + + tile_data->set_z_index(ctd->z_index); + + // Add the shapes. + if (ctd->shapes.size() > 0) { + if (get_physics_layers_count() < 1) { + set_physics_layers_count(1); + } + } + for (int k = 0; k < ctd->shapes.size(); k++) { + CompatibilityShapeData csd = ctd->shapes[k]; + if (csd.autotile_coords == coords) { + Ref<ConvexPolygonShape2D> convex_shape = csd.shape; // Only ConvexPolygonShape2D are supported, which is the default type used by the 3.x editor + if (convex_shape.is_valid()) { + Vector<Vector2> polygon = convex_shape->get_points(); + for (int point_index = 0; point_index < polygon.size(); point_index++) { + polygon.write[point_index] = csd.transform.xform(polygon[point_index]); + } + tile_data->set_collision_polygons_count(0, tile_data->get_collision_polygons_count(0) + 1); + int index = tile_data->get_collision_polygons_count(0) - 1; + tile_data->set_collision_polygon_one_way(0, index, csd.one_way); + tile_data->set_collision_polygon_one_way_margin(0, index, csd.one_way_margin); + tile_data->set_collision_polygon_points(0, index, polygon); + } + } + } + } + } break; + case COMPATIBILITY_TILE_MODE_AUTO_TILE: { + // Not supported. It would need manual conversion. + } break; + case COMPATIBILITY_TILE_MODE_ATLAS_TILE: { atlas_source->set_margins(ctd->region.get_position()); atlas_source->set_separation(Vector2i(ctd->autotile_spacing, ctd->autotile_spacing)); atlas_source->set_texture_region_size(ctd->autotile_tile_size); @@ -1578,6 +1908,25 @@ void TileSet::compatibility_conversion() { } else { alternative_tile = atlas_source->create_alternative_tile(coords); } + + // Add to the mapping. + Array key_array; + key_array.push_back(coords); + key_array.push_back(flip_h); + key_array.push_back(flip_v); + key_array.push_back(transpose); + + Array value_array; + value_array.push_back(source_id); + value_array.push_back(coords); + value_array.push_back(alternative_tile); + + if (!compatibility_tilemap_mapping.has(E->key())) { + compatibility_tilemap_mapping[E->key()] = Map<Array, Array>(); + } + compatibility_tilemap_mapping[E->key()][key_array] = value_array; + compatibility_tilemap_mapping_tile_modes[E->key()] = COMPATIBILITY_TILE_MODE_ATLAS_TILE; + TileData *tile_data = Object::cast_to<TileData>(atlas_source->get_tile_data(coords, alternative_tile)); tile_data->set_flip_h(flip_h); @@ -1641,7 +1990,7 @@ void TileSet::compatibility_conversion() { } } } - break; + } break; } // Offset all shapes @@ -1655,9 +2004,6 @@ void TileSet::compatibility_conversion() { convex->set_points(points); } } - - // Add the mapping to the map - compatibility_source_mapping.insert(E->key(), source_id); } // Reset compatibility data @@ -1666,14 +2012,50 @@ void TileSet::compatibility_conversion() { } compatibility_data = Map<int, CompatibilityTileData *>(); } + +Array TileSet::compatibility_tilemap_map(int p_tile_id, Vector2i p_coords, bool p_flip_h, bool p_flip_v, bool p_transpose) { + Array cannot_convert_array; + cannot_convert_array.push_back(TileSet::INVALID_SOURCE); + cannot_convert_array.push_back(TileSetAtlasSource::INVALID_ATLAS_COORDS); + cannot_convert_array.push_back(TileSetAtlasSource::INVALID_TILE_ALTERNATIVE); + + if (!compatibility_tilemap_mapping.has(p_tile_id)) { + return cannot_convert_array; + } + + int tile_mode = compatibility_tilemap_mapping_tile_modes[p_tile_id]; + switch (tile_mode) { + case COMPATIBILITY_TILE_MODE_SINGLE_TILE: { + Array a; + a.push_back(p_flip_h); + a.push_back(p_flip_v); + a.push_back(p_transpose); + return compatibility_tilemap_mapping[p_tile_id][a]; + } + case COMPATIBILITY_TILE_MODE_AUTO_TILE: + return cannot_convert_array; + break; + case COMPATIBILITY_TILE_MODE_ATLAS_TILE: { + Array a; + a.push_back(p_coords); + a.push_back(p_flip_h); + a.push_back(p_flip_v); + a.push_back(p_transpose); + return compatibility_tilemap_mapping[p_tile_id][a]; + } + default: + return cannot_convert_array; + break; + } +}; + #endif // DISABLE_DEPRECATED bool TileSet::_set(const StringName &p_name, const Variant &p_value) { Vector<String> components = String(p_name).split("/", true, 2); #ifndef DISABLE_DEPRECATED - // TODO: THIS IS HOW WE CHECK IF WE HAVE A DEPRECATED RESOURCE - // This should be moved to a dedicated conversion system + // TODO: This should be moved to a dedicated conversion system (see #50691) if (components.size() >= 1 && components[0].is_valid_int()) { int id = components[0].to_int(); @@ -1809,29 +2191,23 @@ bool TileSet::_set(const StringName &p_name, const Variant &p_value) { /* // IGNORED FOR NOW, they seem duplicated data compared to the shapes array } else if (what == "shape") { - // TODO } else if (what == "shape_offset") { - // TODO } else if (what == "shape_transform") { - // TODO } else if (what == "shape_one_way") { - // TODO } else if (what == "shape_one_way_margin") { - // TODO } // IGNORED FOR NOW, maybe useless ? else if (what == "occluder_offset") { // Not } else if (what == "navigation_offset") { - // TODO } */ } else if (what == "z_index") { ctd->z_index = p_value; - // TODO: remove the conversion from here, it's not where it should be done - compatibility_conversion(); + // TODO: remove the conversion from here, it's not where it should be done (see #50691) + _compatibility_conversion(); } else { return false; } @@ -1966,6 +2342,31 @@ bool TileSet::_set(const StringName &p_name, const Variant &p_value) { add_source(p_value, source_id); } return true; + } else if (components.size() == 2 && components[0] == "tile_proxies") { + ERR_FAIL_COND_V(p_value.get_type() != Variant::ARRAY, false); + Array a = p_value; + ERR_FAIL_COND_V(a.size() % 2 != 0, false); + if (components[1] == "source_level") { + for (int i = 0; i < a.size(); i += 2) { + set_source_level_tile_proxy(a[i], a[i + 1]); + } + return true; + } else if (components[1] == "coords_level") { + for (int i = 0; i < a.size(); i += 2) { + Array key = a[i]; + Array value = a[i + 1]; + set_coords_level_tile_proxy(key[0], key[1], value[0], value[1]); + } + return true; + } else if (components[1] == "alternative_level") { + for (int i = 0; i < a.size(); i += 2) { + Array key = a[i]; + Array value = a[i + 1]; + set_alternative_level_tile_proxy(key[0], key[1], key[2], value[0], value[1], value[2]); + } + return true; + } + return false; } #ifndef DISABLE_DEPRECATED @@ -2065,6 +2466,33 @@ bool TileSet::_get(const StringName &p_name, Variant &r_ret) const { } else { return false; } + } else if (components.size() == 2 && components[0] == "tile_proxies") { + if (components[1] == "source_level") { + Array a; + for (Map<int, int>::Element *E = source_level_proxies.front(); E; E = E->next()) { + a.push_back(E->key()); + a.push_back(E->get()); + } + r_ret = a; + return true; + } else if (components[1] == "coords_level") { + Array a; + for (Map<Array, Array>::Element *E = coords_level_proxies.front(); E; E = E->next()) { + a.push_back(E->key()); + a.push_back(E->get()); + } + r_ret = a; + return true; + } else if (components[1] == "alternative_level") { + Array a; + for (Map<Array, Array>::Element *E = alternative_level_proxies.front(); E; E = E->next()) { + a.push_back(E->key()); + a.push_back(E->get()); + } + r_ret = a; + return true; + } + return false; } return false; @@ -2138,12 +2566,19 @@ void TileSet::_get_property_list(List<PropertyInfo> *p_list) const { for (Map<int, Ref<TileSetSource>>::Element *E_source = sources.front(); E_source; E_source = E_source->next()) { p_list->push_back(PropertyInfo(Variant::INT, vformat("sources/%d", E_source->key()), PROPERTY_HINT_NONE, "", PROPERTY_USAGE_NOEDITOR)); } + + // Tile Proxies. + // Note: proxies need to be set after sources are set. + p_list->push_back(PropertyInfo(Variant::NIL, "Tile Proxies", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_GROUP)); + p_list->push_back(PropertyInfo(Variant::ARRAY, "tile_proxies/source_level", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_NOEDITOR)); + p_list->push_back(PropertyInfo(Variant::ARRAY, "tile_proxies/coords_level", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_NOEDITOR)); + p_list->push_back(PropertyInfo(Variant::ARRAY, "tile_proxies/alternative_level", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_NOEDITOR)); } void TileSet::_bind_methods() { // Sources management. ClassDB::bind_method(D_METHOD("get_next_source_id"), &TileSet::get_next_source_id); - ClassDB::bind_method(D_METHOD("add_source", "atlas_source_id_override"), &TileSet::add_source, DEFVAL(-1)); + ClassDB::bind_method(D_METHOD("add_source", "atlas_source_id_override"), &TileSet::add_source, DEFVAL(TileSet::INVALID_SOURCE)); ClassDB::bind_method(D_METHOD("remove_source", "source_id"), &TileSet::remove_source); ClassDB::bind_method(D_METHOD("set_source_id", "source_id"), &TileSet::set_source_id); ClassDB::bind_method(D_METHOD("get_source_count"), &TileSet::get_source_count); @@ -2212,6 +2647,27 @@ void TileSet::_bind_methods() { ClassDB::bind_method(D_METHOD("set_custom_data_layers_count", "custom_data_layers_count"), &TileSet::set_custom_data_layers_count); ClassDB::bind_method(D_METHOD("get_custom_data_layers_count"), &TileSet::get_custom_data_layers_count); + // Tile proxies + ClassDB::bind_method(D_METHOD("set_source_level_tile_proxy", "source_from", "source_to"), &TileSet::set_source_level_tile_proxy); + ClassDB::bind_method(D_METHOD("get_source_level_tile_proxy", "source_from"), &TileSet::get_source_level_tile_proxy); + ClassDB::bind_method(D_METHOD("has_source_level_tile_proxy", "source_from"), &TileSet::has_source_level_tile_proxy); + ClassDB::bind_method(D_METHOD("remove_source_level_tile_proxy", "source_from"), &TileSet::remove_source_level_tile_proxy); + + ClassDB::bind_method(D_METHOD("set_coords_level_tile_proxy", "p_source_from", "coords_from", "source_to", "coords_to"), &TileSet::set_coords_level_tile_proxy); + ClassDB::bind_method(D_METHOD("get_coords_level_tile_proxy", "source_from", "coords_from"), &TileSet::get_coords_level_tile_proxy); + ClassDB::bind_method(D_METHOD("has_coords_level_tile_proxy", "source_from", "coords_from"), &TileSet::has_coords_level_tile_proxy); + ClassDB::bind_method(D_METHOD("remove_coords_level_tile_proxy", "source_from", "coords_from"), &TileSet::remove_coords_level_tile_proxy); + + ClassDB::bind_method(D_METHOD("set_alternative_level_tile_proxy", "source_from", "coords_from", "alternative_from", "source_to", "coords_to", "alternative_to"), &TileSet::set_alternative_level_tile_proxy); + ClassDB::bind_method(D_METHOD("get_alternative_level_tile_proxy", "source_from", "coords_from", "alternative_from"), &TileSet::get_alternative_level_tile_proxy); + ClassDB::bind_method(D_METHOD("has_alternative_level_tile_proxy", "source_from", "coords_from", "alternative_from"), &TileSet::has_alternative_level_tile_proxy); + ClassDB::bind_method(D_METHOD("remove_alternative_level_tile_proxy", "source_from", "coords_from", "alternative_from"), &TileSet::remove_alternative_level_tile_proxy); + + ClassDB::bind_method(D_METHOD("map_tile_proxy", "source_from", "coords_from", "alternative_from"), &TileSet::map_tile_proxy); + + ClassDB::bind_method(D_METHOD("cleanup_invalid_tile_proxies"), &TileSet::cleanup_invalid_tile_proxies); + ClassDB::bind_method(D_METHOD("clear_tile_proxies"), &TileSet::clear_tile_proxies); + ADD_GROUP("Rendering", ""); ADD_PROPERTY(PropertyInfo(Variant::BOOL, "uv_clipping"), "set_uv_clipping", "is_uv_clipping"); ADD_PROPERTY(PropertyInfo(Variant::BOOL, "y_sorting"), "set_y_sorting", "is_y_sorting"); @@ -2272,7 +2728,7 @@ TileSet::TileSet() { tile_lines_mesh.instantiate(); tile_filled_mesh.instantiate(); - // Instanciate and list all plugins. + // Instantiate and list all plugins. tile_set_plugins_vector.append(memnew(TileSetPluginAtlasRendering)); tile_set_plugins_vector.append(memnew(TileSetPluginAtlasPhysics)); tile_set_plugins_vector.append(memnew(TileSetPluginAtlasNavigation)); @@ -2569,7 +3025,7 @@ void TileSetAtlasSource::create_tile(const Vector2i p_atlas_coords, const Vector } } - emit_signal("changed"); + emit_signal(SNAME("changed")); } void TileSetAtlasSource::remove_tile(Vector2i p_atlas_coords) { @@ -2595,7 +3051,7 @@ void TileSetAtlasSource::remove_tile(Vector2i p_atlas_coords) { tiles_ids.erase(p_atlas_coords); tiles_ids.sort(); - emit_signal("changed"); + emit_signal(SNAME("changed")); } bool TileSetAtlasSource::has_tile(Vector2i p_atlas_coords) const { @@ -2723,7 +3179,7 @@ void TileSetAtlasSource::move_tile_in_atlas(Vector2i p_atlas_coords, Vector2i p_ } } - emit_signal("changed"); + emit_signal(SNAME("changed")); } bool TileSetAtlasSource::has_tiles_outside_texture() { @@ -2755,8 +3211,8 @@ void TileSetAtlasSource::clear_tiles_outside_texture() { } int TileSetAtlasSource::create_alternative_tile(const Vector2i p_atlas_coords, int p_alternative_id_override) { - ERR_FAIL_COND_V_MSG(!tiles.has(p_atlas_coords), -1, vformat("TileSetAtlasSource has no tile at %s.", String(p_atlas_coords))); - ERR_FAIL_COND_V_MSG(p_alternative_id_override >= 0 && tiles[p_atlas_coords].alternatives.has(p_alternative_id_override), -1, vformat("Cannot create alternative tile. Another alternative exists with id %d.", p_alternative_id_override)); + ERR_FAIL_COND_V_MSG(!tiles.has(p_atlas_coords), TileSetSource::INVALID_TILE_ALTERNATIVE, vformat("TileSetAtlasSource has no tile at %s.", String(p_atlas_coords))); + ERR_FAIL_COND_V_MSG(p_alternative_id_override >= 0 && tiles[p_atlas_coords].alternatives.has(p_alternative_id_override), TileSetSource::INVALID_TILE_ALTERNATIVE, vformat("Cannot create alternative tile. Another alternative exists with id %d.", p_alternative_id_override)); int new_alternative_id = p_alternative_id_override >= 0 ? p_alternative_id_override : tiles[p_atlas_coords].next_alternative_id; @@ -2768,7 +3224,7 @@ int TileSetAtlasSource::create_alternative_tile(const Vector2i p_atlas_coords, i tiles[p_atlas_coords].alternatives_ids.sort(); _compute_next_alternative_id(p_atlas_coords); - emit_signal("changed"); + emit_signal(SNAME("changed")); return new_alternative_id; } @@ -2783,7 +3239,7 @@ void TileSetAtlasSource::remove_alternative_tile(const Vector2i p_atlas_coords, tiles[p_atlas_coords].alternatives_ids.erase(p_alternative_tile); tiles[p_atlas_coords].alternatives_ids.sort(); - emit_signal("changed"); + emit_signal(SNAME("changed")); } void TileSetAtlasSource::set_alternative_tile_id(const Vector2i p_atlas_coords, int p_alternative_tile, int p_new_id) { @@ -2800,7 +3256,7 @@ void TileSetAtlasSource::set_alternative_tile_id(const Vector2i p_atlas_coords, tiles[p_atlas_coords].alternatives_ids.erase(p_alternative_tile); tiles[p_atlas_coords].alternatives_ids.sort(); - emit_signal("changed"); + emit_signal(SNAME("changed")); } bool TileSetAtlasSource::has_alternative_tile(const Vector2i p_atlas_coords, int p_alternative_tile) const { @@ -2809,7 +3265,7 @@ bool TileSetAtlasSource::has_alternative_tile(const Vector2i p_atlas_coords, int } int TileSetAtlasSource::get_next_alternative_tile_id(const Vector2i p_atlas_coords) const { - ERR_FAIL_COND_V_MSG(!tiles.has(p_atlas_coords), -1, vformat("The TileSetAtlasSource atlas has no tile at %s.", String(p_atlas_coords))); + ERR_FAIL_COND_V_MSG(!tiles.has(p_atlas_coords), TileSetSource::INVALID_TILE_ALTERNATIVE, vformat("The TileSetAtlasSource atlas has no tile at %s.", String(p_atlas_coords))); return tiles[p_atlas_coords].next_alternative_id; } @@ -2819,8 +3275,8 @@ int TileSetAtlasSource::get_alternative_tiles_count(const Vector2i p_atlas_coord } int TileSetAtlasSource::get_alternative_tile_id(const Vector2i p_atlas_coords, int p_index) const { - ERR_FAIL_COND_V_MSG(!tiles.has(p_atlas_coords), -1, vformat("The TileSetAtlasSource atlas has no tile at %s.", String(p_atlas_coords))); - ERR_FAIL_INDEX_V(p_index, tiles[p_atlas_coords].alternatives_ids.size(), -1); + ERR_FAIL_COND_V_MSG(!tiles.has(p_atlas_coords), TileSetSource::INVALID_TILE_ALTERNATIVE, vformat("The TileSetAtlasSource atlas has no tile at %s.", String(p_atlas_coords))); + ERR_FAIL_INDEX_V(p_index, tiles[p_atlas_coords].alternatives_ids.size(), TileSetSource::INVALID_TILE_ALTERNATIVE); return tiles[p_atlas_coords].alternatives_ids[p_index]; } @@ -2861,7 +3317,7 @@ void TileSetAtlasSource::_bind_methods() { ClassDB::bind_method(D_METHOD("get_tile_at_coords", "atlas_coords"), &TileSetAtlasSource::get_tile_at_coords); // Alternative tiles - ClassDB::bind_method(D_METHOD("create_alternative_tile", "atlas_coords", "alternative_id_override"), &TileSetAtlasSource::create_alternative_tile, DEFVAL(-1)); + ClassDB::bind_method(D_METHOD("create_alternative_tile", "atlas_coords", "alternative_id_override"), &TileSetAtlasSource::create_alternative_tile, DEFVAL(INVALID_TILE_ALTERNATIVE)); ClassDB::bind_method(D_METHOD("remove_alternative_tile", "atlas_coords", "alternative_tile"), &TileSetAtlasSource::remove_alternative_tile); ClassDB::bind_method(D_METHOD("set_alternative_tile_id", "atlas_coords", "alternative_tile", "new_id"), &TileSetAtlasSource::set_alternative_tile_id); ClassDB::bind_method(D_METHOD("has_alternative_tile", "atlas_coords", "alternative_tile"), &TileSetAtlasSource::has_alternative_tile); @@ -2948,7 +3404,7 @@ bool TileSetScenesCollectionSource::has_alternative_tile(const Vector2i p_atlas_ } int TileSetScenesCollectionSource::create_scene_tile(Ref<PackedScene> p_packed_scene, int p_id_override) { - ERR_FAIL_COND_V_MSG(p_id_override >= 0 && scenes.has(p_id_override), -1, vformat("Cannot create scene tile. Another scene tile exists with id %d.", p_id_override)); + ERR_FAIL_COND_V_MSG(p_id_override >= 0 && scenes.has(p_id_override), INVALID_TILE_ALTERNATIVE, vformat("Cannot create scene tile. Another scene tile exists with id %d.", p_id_override)); int new_scene_id = p_id_override >= 0 ? p_id_override : next_scene_id; @@ -2958,7 +3414,7 @@ int TileSetScenesCollectionSource::create_scene_tile(Ref<PackedScene> p_packed_s set_scene_tile_scene(new_scene_id, p_packed_scene); _compute_next_alternative_id(); - emit_signal("changed"); + emit_signal(SNAME("changed")); return new_scene_id; } @@ -2978,7 +3434,7 @@ void TileSetScenesCollectionSource::set_scene_tile_id(int p_id, int p_new_id) { scenes.erase(p_id); scenes_ids.erase(p_id); - emit_signal("changed"); + emit_signal(SNAME("changed")); } void TileSetScenesCollectionSource::set_scene_tile_scene(int p_id, Ref<PackedScene> p_packed_scene) { @@ -2997,7 +3453,7 @@ void TileSetScenesCollectionSource::set_scene_tile_scene(int p_id, Ref<PackedSce } else { scenes[p_id].scene = Ref<PackedScene>(); } - emit_signal("changed"); + emit_signal(SNAME("changed")); } Ref<PackedScene> TileSetScenesCollectionSource::get_scene_tile_scene(int p_id) const { @@ -3010,7 +3466,7 @@ void TileSetScenesCollectionSource::set_scene_tile_display_placeholder(int p_id, scenes[p_id].display_placeholder = p_display_placeholder; - emit_signal("changed"); + emit_signal(SNAME("changed")); } bool TileSetScenesCollectionSource::get_scene_tile_display_placeholder(int p_id) const { @@ -3023,7 +3479,7 @@ void TileSetScenesCollectionSource::remove_scene_tile(int p_id) { scenes.erase(p_id); scenes_ids.erase(p_id); - emit_signal("changed"); + emit_signal(SNAME("changed")); } int TileSetScenesCollectionSource::get_next_scene_tile_id() const { @@ -3096,7 +3552,7 @@ void TileSetScenesCollectionSource::_bind_methods() { ClassDB::bind_method(D_METHOD("get_scene_tiles_count"), &TileSetScenesCollectionSource::get_scene_tiles_count); ClassDB::bind_method(D_METHOD("get_scene_tile_id", "index"), &TileSetScenesCollectionSource::get_scene_tile_id); ClassDB::bind_method(D_METHOD("has_scene_tile_id", "id"), &TileSetScenesCollectionSource::has_scene_tile_id); - ClassDB::bind_method(D_METHOD("create_scene_tile", "packed_scene", "id_override"), &TileSetScenesCollectionSource::create_scene_tile, DEFVAL(-1)); + ClassDB::bind_method(D_METHOD("create_scene_tile", "packed_scene", "id_override"), &TileSetScenesCollectionSource::create_scene_tile, DEFVAL(INVALID_TILE_ALTERNATIVE)); ClassDB::bind_method(D_METHOD("set_scene_tile_id", "id", "new_id"), &TileSetScenesCollectionSource::set_scene_tile_id); ClassDB::bind_method(D_METHOD("set_scene_tile_scene", "id", "packed_scene"), &TileSetScenesCollectionSource::set_scene_tile_scene); ClassDB::bind_method(D_METHOD("get_scene_tile_scene", "id"), &TileSetScenesCollectionSource::get_scene_tile_scene); @@ -3144,7 +3600,7 @@ void TileData::notify_tile_data_properties_should_change() { } notify_property_list_changed(); - emit_signal("changed"); + emit_signal(SNAME("changed")); } void TileData::reset_state() { @@ -3166,7 +3622,7 @@ bool TileData::is_allowing_transform() const { void TileData::set_flip_h(bool p_flip_h) { ERR_FAIL_COND_MSG(!allow_transform && p_flip_h, "Transform is only allowed for alternative tiles (with its alternative_id != 0)"); flip_h = p_flip_h; - emit_signal("changed"); + emit_signal(SNAME("changed")); } bool TileData::get_flip_h() const { return flip_h; @@ -3175,7 +3631,7 @@ bool TileData::get_flip_h() const { void TileData::set_flip_v(bool p_flip_v) { ERR_FAIL_COND_MSG(!allow_transform && p_flip_v, "Transform is only allowed for alternative tiles (with its alternative_id != 0)"); flip_v = p_flip_v; - emit_signal("changed"); + emit_signal(SNAME("changed")); } bool TileData::get_flip_v() const { @@ -3185,7 +3641,7 @@ bool TileData::get_flip_v() const { void TileData::set_transpose(bool p_transpose) { ERR_FAIL_COND_MSG(!allow_transform && p_transpose, "Transform is only allowed for alternative tiles (with its alternative_id != 0)"); transpose = p_transpose; - emit_signal("changed"); + emit_signal(SNAME("changed")); } bool TileData::get_transpose() const { return transpose; @@ -3193,7 +3649,7 @@ bool TileData::get_transpose() const { void TileData::set_texture_offset(Vector2i p_texture_offset) { tex_offset = p_texture_offset; - emit_signal("changed"); + emit_signal(SNAME("changed")); } Vector2i TileData::get_texture_offset() const { @@ -3202,7 +3658,7 @@ Vector2i TileData::get_texture_offset() const { void TileData::tile_set_material(Ref<ShaderMaterial> p_material) { material = p_material; - emit_signal("changed"); + emit_signal(SNAME("changed")); } Ref<ShaderMaterial> TileData::tile_get_material() const { return material; @@ -3210,7 +3666,7 @@ Ref<ShaderMaterial> TileData::tile_get_material() const { void TileData::set_modulate(Color p_modulate) { modulate = p_modulate; - emit_signal("changed"); + emit_signal(SNAME("changed")); } Color TileData::get_modulate() const { return modulate; @@ -3218,7 +3674,7 @@ Color TileData::get_modulate() const { void TileData::set_z_index(int p_z_index) { z_index = p_z_index; - emit_signal("changed"); + emit_signal(SNAME("changed")); } int TileData::get_z_index() const { return z_index; @@ -3226,7 +3682,7 @@ int TileData::get_z_index() const { void TileData::set_y_sort_origin(int p_y_sort_origin) { y_sort_origin = p_y_sort_origin; - emit_signal("changed"); + emit_signal(SNAME("changed")); } int TileData::get_y_sort_origin() const { return y_sort_origin; @@ -3235,7 +3691,7 @@ int TileData::get_y_sort_origin() const { void TileData::set_occluder(int p_layer_id, Ref<OccluderPolygon2D> p_occluder_polygon) { ERR_FAIL_INDEX(p_layer_id, occluders.size()); occluders.write[p_layer_id] = p_occluder_polygon; - emit_signal("changed"); + emit_signal(SNAME("changed")); } Ref<OccluderPolygon2D> TileData::get_occluder(int p_layer_id) const { @@ -3254,20 +3710,20 @@ void TileData::set_collision_polygons_count(int p_layer_id, int p_polygons_count ERR_FAIL_COND(p_polygons_count < 0); physics.write[p_layer_id].polygons.resize(p_polygons_count); notify_property_list_changed(); - emit_signal("changed"); + emit_signal(SNAME("changed")); } void TileData::add_collision_polygon(int p_layer_id) { ERR_FAIL_INDEX(p_layer_id, physics.size()); physics.write[p_layer_id].polygons.push_back(PhysicsLayerTileData::PolygonShapeTileData()); - emit_signal("changed"); + emit_signal(SNAME("changed")); } void TileData::remove_collision_polygon(int p_layer_id, int p_polygon_index) { ERR_FAIL_INDEX(p_layer_id, physics.size()); ERR_FAIL_INDEX(p_polygon_index, physics[p_layer_id].polygons.size()); physics.write[p_layer_id].polygons.remove(p_polygon_index); - emit_signal("changed"); + emit_signal(SNAME("changed")); } void TileData::set_collision_polygon_points(int p_layer_id, int p_polygon_index, Vector<Vector2> p_polygon) { @@ -3291,7 +3747,7 @@ void TileData::set_collision_polygon_points(int p_layer_id, int p_polygon_index, } } physics.write[p_layer_id].polygons.write[p_polygon_index].polygon = p_polygon; - emit_signal("changed"); + emit_signal(SNAME("changed")); } Vector<Vector2> TileData::get_collision_polygon_points(int p_layer_id, int p_polygon_index) const { @@ -3304,7 +3760,7 @@ void TileData::set_collision_polygon_one_way(int p_layer_id, int p_polygon_index ERR_FAIL_INDEX(p_layer_id, physics.size()); ERR_FAIL_INDEX(p_polygon_index, physics[p_layer_id].polygons.size()); physics.write[p_layer_id].polygons.write[p_polygon_index].one_way = p_one_way; - emit_signal("changed"); + emit_signal(SNAME("changed")); } bool TileData::is_collision_polygon_one_way(int p_layer_id, int p_polygon_index) const { @@ -3317,7 +3773,7 @@ void TileData::set_collision_polygon_one_way_margin(int p_layer_id, int p_polygo ERR_FAIL_INDEX(p_layer_id, physics.size()); ERR_FAIL_INDEX(p_polygon_index, physics[p_layer_id].polygons.size()); physics.write[p_layer_id].polygons.write[p_polygon_index].one_way_margin = p_one_way_margin; - emit_signal("changed"); + emit_signal(SNAME("changed")); } float TileData::get_collision_polygon_one_way_margin(int p_layer_id, int p_polygon_index) const { @@ -3353,7 +3809,7 @@ void TileData::set_terrain_set(int p_terrain_set) { } terrain_set = p_terrain_set; notify_property_list_changed(); - emit_signal("changed"); + emit_signal(SNAME("changed")); } int TileData::get_terrain_set() const { @@ -3368,7 +3824,7 @@ void TileData::set_peering_bit_terrain(TileSet::CellNeighbor p_peering_bit, int ERR_FAIL_COND(!is_valid_peering_bit_terrain(p_peering_bit)); } terrain_peering_bits[p_peering_bit] = p_terrain_index; - emit_signal("changed"); + emit_signal(SNAME("changed")); } int TileData::get_peering_bit_terrain(TileSet::CellNeighbor p_peering_bit) const { @@ -3386,7 +3842,7 @@ bool TileData::is_valid_peering_bit_terrain(TileSet::CellNeighbor p_peering_bit) void TileData::set_navigation_polygon(int p_layer_id, Ref<NavigationPolygon> p_navigation_polygon) { ERR_FAIL_INDEX(p_layer_id, navigation.size()); navigation.write[p_layer_id] = p_navigation_polygon; - emit_signal("changed"); + emit_signal(SNAME("changed")); } Ref<NavigationPolygon> TileData::get_navigation_polygon(int p_layer_id) const { @@ -3398,7 +3854,7 @@ Ref<NavigationPolygon> TileData::get_navigation_polygon(int p_layer_id) const { void TileData::set_probability(float p_probability) { ERR_FAIL_COND(p_probability < 0.0); probability = p_probability; - emit_signal("changed"); + emit_signal(SNAME("changed")); } float TileData::get_probability() const { return probability; @@ -3422,7 +3878,7 @@ Variant TileData::get_custom_data(String p_layer_name) const { void TileData::set_custom_data_by_layer_id(int p_layer_id, Variant p_value) { ERR_FAIL_INDEX(p_layer_id, custom_data.size()); custom_data.write[p_layer_id] = p_value; - emit_signal("changed"); + emit_signal(SNAME("changed")); } Variant TileData::get_custom_data_by_layer_id(int p_layer_id) const { @@ -3901,14 +4357,14 @@ void TileSetPluginAtlasRendering::update_dirty_quadrants(TileMap *p_tile_map, Se RenderingServer *rs = RenderingServer::get_singleton(); // Free the canvas items. - for (List<RID>::Element *E = q.canvas_items.front(); E; E = E->next()) { - rs->free(E->get()); + for (const RID &E : q.canvas_items) { + rs->free(E); } q.canvas_items.clear(); // Free the occluders. - for (List<RID>::Element *E = q.occluders.front(); E; E = E->next()) { - rs->free(E->get()); + for (const RID &E : q.occluders) { + rs->free(E); } q.occluders.clear(); @@ -3919,7 +4375,7 @@ void TileSetPluginAtlasRendering::update_dirty_quadrants(TileMap *p_tile_map, Se // Iterate over the cells of the quadrant. for (Map<Vector2i, Vector2i, TileMapQuadrant::CoordsWorldComparator>::Element *E_cell = q.world_to_map.front(); E_cell; E_cell = E_cell->next()) { - TileMapCell c = p_tile_map->get_cell(E_cell->value()); + TileMapCell c = p_tile_map->get_cell(E_cell->value(), true); TileSetSource *source; if (tile_set->has_source(c.source_id)) { @@ -4017,8 +4473,8 @@ void TileSetPluginAtlasRendering::update_dirty_quadrants(TileMap *p_tile_map, Se // Sort the quadrants for (Map<Vector2i, Vector2i, TileMapQuadrant::CoordsWorldComparator>::Element *E = world_to_map.front(); E; E = E->next()) { TileMapQuadrant &q = quadrant_map[E->value()]; - for (List<RID>::Element *F = q.canvas_items.front(); F; F = F->next()) { - RS::get_singleton()->canvas_item_set_draw_index(F->get(), index++); + for (const RID &F : q.canvas_items) { + RS::get_singleton()->canvas_item_set_draw_index(F, index++); } } @@ -4035,14 +4491,14 @@ void TileSetPluginAtlasRendering::create_quadrant(TileMap *p_tile_map, TileMapQu void TileSetPluginAtlasRendering::cleanup_quadrant(TileMap *p_tile_map, TileMapQuadrant *p_quadrant) { // Free the canvas items. - for (List<RID>::Element *E = p_quadrant->canvas_items.front(); E; E = E->next()) { - RenderingServer::get_singleton()->free(E->get()); + for (const RID &E : p_quadrant->canvas_items) { + RenderingServer::get_singleton()->free(E); } p_quadrant->canvas_items.clear(); // Free the occluders. - for (List<RID>::Element *E = p_quadrant->occluders.front(); E; E = E->next()) { - RenderingServer::get_singleton()->free(E->get()); + for (const RID &E : p_quadrant->occluders) { + RenderingServer::get_singleton()->free(E); } p_quadrant->occluders.clear(); } @@ -4059,7 +4515,7 @@ void TileSetPluginAtlasRendering::draw_quadrant_debug(TileMap *p_tile_map, TileM RenderingServer *rs = RenderingServer::get_singleton(); Vector2 quadrant_pos = p_tile_map->map_to_world(p_quadrant->coords * p_tile_map->get_effective_quadrant_size()); for (Set<Vector2i>::Element *E_cell = p_quadrant->cells.front(); E_cell; E_cell = E_cell->next()) { - const TileMapCell &c = p_tile_map->get_cell(E_cell->get()); + const TileMapCell &c = p_tile_map->get_cell(E_cell->get(), true); TileSetSource *source; if (tile_set->has_source(c.source_id)) { @@ -4151,7 +4607,7 @@ void TileSetPluginAtlasPhysics::update_dirty_quadrants(TileMap *p_tile_map, Self } for (Set<Vector2i>::Element *E_cell = q.cells.front(); E_cell; E_cell = E_cell->next()) { - TileMapCell c = p_tile_map->get_cell(E_cell->get()); + TileMapCell c = p_tile_map->get_cell(E_cell->get(), true); TileSetSource *source; if (tile_set->has_source(c.source_id)) { @@ -4276,7 +4732,7 @@ void TileSetPluginAtlasPhysics::draw_quadrant_debug(TileMap *p_tile_map, TileMap Color debug_collision_color = p_tile_map->get_tree()->get_debug_collisions_color(); for (Set<Vector2i>::Element *E_cell = p_quadrant->cells.front(); E_cell; E_cell = E_cell->next()) { - TileMapCell c = p_tile_map->get_cell(E_cell->get()); + TileMapCell c = p_tile_map->get_cell(E_cell->get(), true); Transform2D xform; xform.set_origin(p_tile_map->map_to_world(E_cell->get()) - quadrant_pos); @@ -4370,7 +4826,7 @@ void TileSetPluginAtlasNavigation::update_dirty_quadrants(TileMap *p_tile_map, S // Get the navigation polygons and create regions. for (Set<Vector2i>::Element *E_cell = q.cells.front(); E_cell; E_cell = E_cell->next()) { - TileMapCell c = p_tile_map->get_cell(E_cell->get()); + TileMapCell c = p_tile_map->get_cell(E_cell->get(), true); TileSetSource *source; if (tile_set->has_source(c.source_id)) { @@ -4455,7 +4911,7 @@ void TileSetPluginAtlasNavigation::draw_quadrant_debug(TileMap *p_tile_map, Tile Vector2 quadrant_pos = p_tile_map->map_to_world(p_quadrant->coords * p_tile_map->get_effective_quadrant_size()); for (Set<Vector2i>::Element *E_cell = p_quadrant->cells.front(); E_cell; E_cell = E_cell->next()) { - TileMapCell c = p_tile_map->get_cell(E_cell->get()); + TileMapCell c = p_tile_map->get_cell(E_cell->get(), true); TileSetSource *source; if (tile_set->has_source(c.source_id)) { @@ -4526,7 +4982,7 @@ void TileSetPluginScenesCollections::update_dirty_quadrants(TileMap *p_tile_map, // Recreate the scenes. for (Set<Vector2i>::Element *E_cell = q.cells.front(); E_cell; E_cell = E_cell->next()) { - const TileMapCell &c = p_tile_map->get_cell(E_cell->get()); + const TileMapCell &c = p_tile_map->get_cell(E_cell->get(), true); TileSetSource *source; if (tile_set->has_source(c.source_id)) { @@ -4585,7 +5041,7 @@ void TileSetPluginScenesCollections::draw_quadrant_debug(TileMap *p_tile_map, Ti RenderingServer *rs = RenderingServer::get_singleton(); Vector2 quadrant_pos = p_tile_map->map_to_world(p_quadrant->coords * p_tile_map->get_effective_quadrant_size()); for (Set<Vector2i>::Element *E_cell = p_quadrant->cells.front(); E_cell; E_cell = E_cell->next()) { - const TileMapCell &c = p_tile_map->get_cell(E_cell->get()); + const TileMapCell &c = p_tile_map->get_cell(E_cell->get(), true); TileSetSource *source; if (tile_set->has_source(c.source_id)) { diff --git a/scene/resources/tile_set.h b/scene/resources/tile_set.h index dbf6dbabe6..0a07981171 100644 --- a/scene/resources/tile_set.h +++ b/scene/resources/tile_set.h @@ -79,15 +79,15 @@ private: Vector2 tex_offset; Ref<ShaderMaterial> material; Rect2 region; - int tile_mode; - Color modulate; + int tile_mode = 0; + Color modulate = Color(1, 1, 1); // Atlas or autotiles data - int autotile_bitmask_mode; + int autotile_bitmask_mode = 0; Vector2 autotile_icon_coordinate; Size2i autotile_tile_size = Size2i(16, 16); - int autotile_spacing; + int autotile_spacing = 0; Map<Vector2i, int> autotile_bitmask_flags; Map<Vector2i, Ref<OccluderPolygon2D>> autotile_occluder_map; Map<Vector2i, Ref<NavigationPolygon>> autotile_navpoly_map; @@ -99,23 +99,29 @@ private: Vector2 occluder_offset; Ref<NavigationPolygon> navigation; Vector2 navigation_offset; - int z_index; + int z_index = 0; }; - Map<int, CompatibilityTileData *> compatibility_data = Map<int, CompatibilityTileData *>(); - Map<int, int> compatibility_source_mapping = Map<int, int>(); + enum CompatibilityTileMode { + COMPATIBILITY_TILE_MODE_SINGLE_TILE = 0, + COMPATIBILITY_TILE_MODE_AUTO_TILE, + COMPATIBILITY_TILE_MODE_ATLAS_TILE, + }; -private: - void compatibility_conversion(); + Map<int, CompatibilityTileData *> compatibility_data; + Map<int, int> compatibility_tilemap_mapping_tile_modes; + Map<int, Map<Array, Array>> compatibility_tilemap_mapping; -public: - int compatibility_get_source_for_tile_id(int p_old_source) { - return compatibility_source_mapping[p_old_source]; - }; + void _compatibility_conversion(); +public: + // Format of output array [source_id, atlas_coords, alternative] + Array compatibility_tilemap_map(int p_tile_id, Vector2i p_coords, bool p_flip_h, bool p_flip_v, bool p_transpose); #endif // DISABLE_DEPRECATED public: + static const int INVALID_SOURCE; // -1; + enum CellNeighbor { CELL_NEIGHBOR_RIGHT_SIDE = 0, CELL_NEIGHBOR_RIGHT_CORNER, @@ -165,7 +171,6 @@ public: TILE_OFFSET_AXIS_VERTICAL, }; -public: struct PackedSceneSource { Ref<PackedScene> scene; Vector2 offset; @@ -246,6 +251,11 @@ private: void _compute_next_source_id(); void _source_changed(); + // Tile proxies + Map<int, int> source_level_proxies; + Map<Array, Array> coords_level_proxies; + Map<Array, Array> alternative_level_proxies; + // Helpers Vector<Point2> _get_square_corner_or_side_terrain_bit_polygon(Vector2i p_size, TileSet::CellNeighbor p_bit); Vector<Point2> _get_square_corner_terrain_bit_polygon(Vector2i p_size, TileSet::CellNeighbor p_bit); @@ -341,6 +351,31 @@ public: void set_custom_data_type(int p_layer_id, Variant::Type p_value); Variant::Type get_custom_data_type(int p_layer_id) const; + // Tiles proxies. + void set_source_level_tile_proxy(int p_source_from, int p_source_to); + int get_source_level_tile_proxy(int p_source_from); + bool has_source_level_tile_proxy(int p_source_from); + void remove_source_level_tile_proxy(int p_source_from); + + void set_coords_level_tile_proxy(int p_source_from, Vector2i p_coords_from, int p_source_to, Vector2i p_coords_to); + Array get_coords_level_tile_proxy(int p_source_from, Vector2i p_coords_from); + bool has_coords_level_tile_proxy(int p_source_from, Vector2i p_coords_from); + void remove_coords_level_tile_proxy(int p_source_from, Vector2i p_coords_from); + + void set_alternative_level_tile_proxy(int p_source_from, Vector2i p_coords_from, int p_alternative_from, int p_source_to, Vector2i p_coords_to, int p_alternative_to); + Array get_alternative_level_tile_proxy(int p_source_from, Vector2i p_coords_from, int p_alternative_from); + bool has_alternative_level_tile_proxy(int p_source_from, Vector2i p_coords_from, int p_alternative_from); + void remove_alternative_level_tile_proxy(int p_source_from, Vector2i p_coords_from, int p_alternative_from); + + Array get_source_level_tile_proxies() const; + Array get_coords_level_tile_proxies() const; + Array get_alternative_level_tile_proxies() const; + + Array map_tile_proxy(int p_source_from, Vector2i p_coords_from, int p_alternative_from) const; + + void cleanup_invalid_tile_proxies(); + void clear_tile_proxies(); + // Helpers Vector<Vector2> get_tile_shape_polygon(); void draw_tile_shape(CanvasItem *p_canvas_item, Rect2 p_region, Color p_color, bool p_filled = false, Ref<Texture2D> p_texture = Ref<Texture2D>()); diff --git a/scene/resources/visual_shader.cpp b/scene/resources/visual_shader.cpp index 36a1c206c8..7292728251 100644 --- a/scene/resources/visual_shader.cpp +++ b/scene/resources/visual_shader.cpp @@ -352,14 +352,14 @@ String VisualShaderNodeCustom::generate_code(Shader::Mode p_mode, VisualShader:: for (int i = 0; i < get_output_port_count(); i++) { output_vars.push_back(p_output_vars[i]); } - String code = "\t{\n"; + String code = " {\n"; String _code = (String)get_script_instance()->call("_get_code", input_vars, output_vars, (int)p_mode, (int)p_type); bool nend = _code.ends_with("\n"); - _code = _code.insert(0, "\t\t"); - _code = _code.replace("\n", "\n\t\t"); + _code = _code.insert(0, " "); + _code = _code.replace("\n", "\n "); code += _code; if (!nend) { - code += "\n\t}"; + code += "\n }"; } else { code.remove(code.size() - 1); code += "}"; @@ -628,8 +628,8 @@ bool VisualShader::is_node_connection(Type p_type, int p_from_node, int p_from_p ERR_FAIL_INDEX_V(p_type, TYPE_MAX, false); const Graph *g = &graph[p_type]; - for (const List<Connection>::Element *E = g->connections.front(); E; E = E->next()) { - if (E->get().from_node == p_from_node && E->get().from_port == p_from_port && E->get().to_node == p_to_node && E->get().to_port == p_to_port) { + for (const Connection &E : g->connections) { + if (E.from_node == p_from_node && E.from_port == p_from_port && E.to_node == p_to_node && E.to_port == p_to_port) { return true; } } @@ -642,12 +642,12 @@ bool VisualShader::is_nodes_connected_relatively(const Graph *p_graph, int p_nod const VisualShader::Node &node = p_graph->nodes[p_node]; - for (const List<int>::Element *E = node.prev_connected_nodes.front(); E; E = E->next()) { - if (E->get() == p_target) { + for (const int &E : node.prev_connected_nodes) { + if (E == p_target) { return true; } - result = is_nodes_connected_relatively(p_graph, E->get(), p_target); + result = is_nodes_connected_relatively(p_graph, E, p_target); if (result) { break; } @@ -686,8 +686,8 @@ bool VisualShader::can_connect_nodes(Type p_type, int p_from_node, int p_from_po return false; } - for (const List<Connection>::Element *E = g->connections.front(); E; E = E->next()) { - if (E->get().from_node == p_from_node && E->get().from_port == p_from_port && E->get().to_node == p_to_node && E->get().to_port == p_to_port) { + for (const Connection &E : g->connections) { + if (E.from_node == p_from_node && E.from_port == p_from_port && E.to_node == p_to_node && E.to_port == p_to_port) { return false; } } @@ -739,8 +739,8 @@ Error VisualShader::connect_nodes(Type p_type, int p_from_node, int p_from_port, ERR_FAIL_COND_V_MSG(!is_port_types_compatible(from_port_type, to_port_type), ERR_INVALID_PARAMETER, "Incompatible port types (scalar/vec/bool) with transform."); - for (List<Connection>::Element *E = g->connections.front(); E; E = E->next()) { - if (E->get().from_node == p_from_node && E->get().from_port == p_from_port && E->get().to_node == p_to_node && E->get().to_port == p_to_port) { + for (const Connection &E : g->connections) { + if (E.from_node == p_from_node && E.from_port == p_from_port && E.to_node == p_to_node && E.to_port == p_to_port) { ERR_FAIL_V(ERR_ALREADY_EXISTS); } } @@ -763,7 +763,7 @@ void VisualShader::disconnect_nodes(Type p_type, int p_from_node, int p_from_por ERR_FAIL_INDEX(p_type, TYPE_MAX); Graph *g = &graph[p_type]; - for (List<Connection>::Element *E = g->connections.front(); E; E = E->next()) { + for (const List<Connection>::Element *E = g->connections.front(); E; E = E->next()) { if (E->get().from_node == p_from_node && E->get().from_port == p_from_port && E->get().to_node == p_to_node && E->get().to_port == p_to_port) { g->connections.erase(E); g->nodes[p_to_node].prev_connected_nodes.erase(p_from_node); @@ -780,12 +780,12 @@ Array VisualShader::_get_node_connections(Type p_type) const { const Graph *g = &graph[p_type]; Array ret; - for (const List<Connection>::Element *E = g->connections.front(); E; E = E->next()) { + for (const Connection &E : g->connections) { Dictionary d; - d["from_node"] = E->get().from_node; - d["from_port"] = E->get().from_port; - d["to_node"] = E->get().to_node; - d["to_port"] = E->get().to_port; + d["from_node"] = E.from_node; + d["from_port"] = E.from_port; + d["to_node"] = E.to_node; + d["to_port"] = E.to_port; ret.push_back(d); } @@ -796,8 +796,8 @@ void VisualShader::get_node_connections(Type p_type, List<Connection> *r_connect ERR_FAIL_INDEX(p_type, TYPE_MAX); const Graph *g = &graph[p_type]; - for (const List<Connection>::Element *E = g->connections.front(); E; E = E->next()) { - r_connections->push_back(E->get()); + for (const Connection &E : g->connections) { + r_connections->push_back(E); } } @@ -900,7 +900,7 @@ String VisualShader::generate_preview_shader(Type p_type, int p_node, int p_port String expr = ""; expr += "// " + global_expression->get_caption() + ":" + itos(index++) + "\n"; expr += global_expression->generate_global(get_mode(), Type(i), -1); - expr = expr.replace("\n", "\n\t"); + expr = expr.replace("\n", "\n "); expr += "\n"; global_expressions += expr; } @@ -935,13 +935,13 @@ String VisualShader::generate_preview_shader(Type p_type, int p_node, int p_port ERR_FAIL_COND_V(err != OK, String()); if (node->get_output_port_type(p_port) == VisualShaderNode::PORT_TYPE_SCALAR) { - code += "\tCOLOR.rgb = vec3(n_out" + itos(p_node) + "p" + itos(p_port) + " );\n"; + code += " COLOR.rgb = vec3(n_out" + itos(p_node) + "p" + itos(p_port) + " );\n"; } else if (node->get_output_port_type(p_port) == VisualShaderNode::PORT_TYPE_SCALAR_INT) { - code += "\tCOLOR.rgb = vec3(float(n_out" + itos(p_node) + "p" + itos(p_port) + "));\n"; + code += " COLOR.rgb = vec3(float(n_out" + itos(p_node) + "p" + itos(p_port) + "));\n"; } else if (node->get_output_port_type(p_port) == VisualShaderNode::PORT_TYPE_BOOLEAN) { - code += "\tCOLOR.rgb = vec3(n_out" + itos(p_node) + "p" + itos(p_port) + " ? 1.0 : 0.0);\n"; + code += " COLOR.rgb = vec3(n_out" + itos(p_node) + "p" + itos(p_port) + " ? 1.0 : 0.0);\n"; } else { - code += "\tCOLOR.rgb = n_out" + itos(p_node) + "p" + itos(p_port) + ";\n"; + code += " COLOR.rgb = n_out" + itos(p_node) + "p" + itos(p_port) + ";\n"; } code += "}\n"; @@ -1190,11 +1190,11 @@ bool VisualShader::_get(const StringName &p_name, Variant &r_ret) const { String index = name.get_slicec('/', 2); if (index == "connections") { Vector<int> conns; - for (const List<Connection>::Element *E = graph[type].connections.front(); E; E = E->next()) { - conns.push_back(E->get().from_node); - conns.push_back(E->get().from_port); - conns.push_back(E->get().to_node); - conns.push_back(E->get().to_port); + for (const Connection &E : graph[type].connections) { + conns.push_back(E.from_node); + conns.push_back(E.from_port); + conns.push_back(E.to_node); + conns.push_back(E.to_port); } r_ret = conns; @@ -1302,7 +1302,7 @@ Error VisualShader::_write_node(Type type, StringBuilder &global_code, StringBui if (vsnode->is_disabled()) { code += "// " + vsnode->get_caption() + ":" + itos(node) + "\n"; - code += "\t// Node is disabled and code is not generated.\n"; + code += " // Node is disabled and code is not generated.\n"; return OK; } @@ -1432,19 +1432,19 @@ Error VisualShader::_write_node(Type type, StringBuilder &global_code, StringBui if (defval.get_type() == Variant::FLOAT) { float val = defval; inputs[i] = "n_in" + itos(node) + "p" + itos(i); - node_code += "\tfloat " + inputs[i] + " = " + vformat("%.5f", val) + ";\n"; + node_code += " float " + inputs[i] + " = " + vformat("%.5f", val) + ";\n"; } else if (defval.get_type() == Variant::INT) { int val = defval; inputs[i] = "n_in" + itos(node) + "p" + itos(i); - node_code += "\tint " + inputs[i] + " = " + itos(val) + ";\n"; + node_code += " int " + inputs[i] + " = " + itos(val) + ";\n"; } else if (defval.get_type() == Variant::BOOL) { bool val = defval; inputs[i] = "n_in" + itos(node) + "p" + itos(i); - node_code += "\tbool " + inputs[i] + " = " + (val ? "true" : "false") + ";\n"; + node_code += " bool " + inputs[i] + " = " + (val ? "true" : "false") + ";\n"; } else if (defval.get_type() == Variant::VECTOR3) { Vector3 val = defval; inputs[i] = "n_in" + itos(node) + "p" + itos(i); - node_code += "\tvec3 " + inputs[i] + " = " + vformat("vec3(%.5f, %.5f, %.5f);\n", val.x, val.y, val.z); + node_code += " vec3 " + inputs[i] + " = " + vformat("vec3(%.5f, %.5f, %.5f);\n", val.x, val.y, val.z); } else if (defval.get_type() == Variant::TRANSFORM3D) { Transform3D val = defval; val.basis.transpose(); @@ -1459,7 +1459,7 @@ Error VisualShader::_write_node(Type type, StringBuilder &global_code, StringBui values.push_back(val.origin.y); values.push_back(val.origin.z); bool err = false; - node_code += "\tmat4 " + inputs[i] + " = " + String("mat4(vec4(%.5f, %.5f, %.5f, 0.0), vec4(%.5f, %.5f, %.5f, 0.0), vec4(%.5f, %.5f, %.5f, 0.0), vec4(%.5f, %.5f, %.5f, 1.0));\n").sprintf(values, &err); + node_code += " mat4 " + inputs[i] + " = " + String("mat4(vec4(%.5f, %.5f, %.5f, 0.0), vec4(%.5f, %.5f, %.5f, 0.0), vec4(%.5f, %.5f, %.5f, 0.0), vec4(%.5f, %.5f, %.5f, 1.0));\n").sprintf(values, &err); } else { //will go empty, node is expected to know what it is doing at this point and handle it } @@ -1522,19 +1522,19 @@ Error VisualShader::_write_node(Type type, StringBuilder &global_code, StringBui outputs[i] = "n_out" + itos(node) + "p" + itos(j); switch (vsnode->get_output_port_type(i)) { case VisualShaderNode::PORT_TYPE_SCALAR: - code += "\tfloat " + outputs[i] + ";\n"; + code += " float " + outputs[i] + ";\n"; break; case VisualShaderNode::PORT_TYPE_SCALAR_INT: - code += "\tint " + outputs[i] + ";\n"; + code += " int " + outputs[i] + ";\n"; break; case VisualShaderNode::PORT_TYPE_VECTOR: - code += "\tvec3 " + outputs[i] + ";\n"; + code += " vec3 " + outputs[i] + ";\n"; break; case VisualShaderNode::PORT_TYPE_BOOLEAN: - code += "\tbool " + outputs[i] + ";\n"; + code += " bool " + outputs[i] + ";\n"; break; case VisualShaderNode::PORT_TYPE_TRANSFORM: - code += "\tmat4 " + outputs[i] + ";\n"; + code += " mat4 " + outputs[i] + ";\n"; break; default: { } @@ -1564,7 +1564,7 @@ Error VisualShader::_write_node(Type type, StringBuilder &global_code, StringBui new_line_inserted = true; } String r = "n_out" + itos(node) + "p" + itos(i + 1); - code += "\tfloat " + r + " = n_out" + itos(node) + "p" + itos(i) + ".r;\n"; + code += " float " + r + " = n_out" + itos(node) + "p" + itos(i) + ".r;\n"; outputs[i + 1] = r; } @@ -1574,7 +1574,7 @@ Error VisualShader::_write_node(Type type, StringBuilder &global_code, StringBui new_line_inserted = true; } String g = "n_out" + itos(node) + "p" + itos(i + 2); - code += "\tfloat " + g + " = n_out" + itos(node) + "p" + itos(i) + ".g;\n"; + code += " float " + g + " = n_out" + itos(node) + "p" + itos(i) + ".g;\n"; outputs[i + 2] = g; } @@ -1584,7 +1584,7 @@ Error VisualShader::_write_node(Type type, StringBuilder &global_code, StringBui new_line_inserted = true; } String b = "n_out" + itos(node) + "p" + itos(i + 3); - code += "\tfloat " + b + " = n_out" + itos(node) + "p" + itos(i) + ".b;\n"; + code += " float " + b + " = n_out" + itos(node) + "p" + itos(i) + ".b;\n"; outputs[i + 3] = b; } @@ -1701,7 +1701,7 @@ void VisualShader::_update_shader() const { String expr = ""; expr += "// " + global_expression->get_caption() + ":" + itos(index++) + "\n"; expr += global_expression->generate_global(get_mode(), Type(i), -1); - expr = expr.replace("\n", "\n\t"); + expr = expr.replace("\n", "\n "); expr += "\n"; global_expressions += expr; } @@ -1740,6 +1740,7 @@ void VisualShader::_update_shader() const { } Map<int, String> code_map; + Set<int> empty_funcs; for (int i = 0; i < TYPE_MAX; i++) { if (!has_func_name(RenderingServer::ShaderMode(shader_mode), func_name[i])) { @@ -1752,6 +1753,11 @@ void VisualShader::_update_shader() const { StringBuilder func_code; + bool is_empty_func = false; + if (shader_mode != Shader::MODE_PARTICLES && shader_mode != Shader::MODE_SKY) { + is_empty_func = true; + } + for (const List<Connection>::Element *E = graph[i].connections.front(); E; E = E->next()) { ConnectionKey from_key; from_key.node = E->get().from_node; @@ -1764,7 +1770,17 @@ void VisualShader::_update_shader() const { to_key.port = E->get().to_port; input_connections.insert(to_key, E); + + if (is_empty_func && to_key.node == NODE_ID_OUTPUT) { + is_empty_func = false; + } + } + + if (is_empty_func) { + empty_funcs.insert(i); + continue; } + if (shader_mode != Shader::MODE_PARTICLES) { func_code += "\nvoid " + String(func_name[i]) + "() {\n"; } @@ -1775,8 +1791,8 @@ void VisualShader::_update_shader() const { ERR_FAIL_COND(err != OK); if (emitters.has(i)) { - for (List<int>::Element *E = emitters[i].front(); E; E = E->next()) { - err = _write_node(Type(i), global_code, global_code_per_node, global_code_per_func, func_code, default_tex_params, input_connections, output_connections, E->get(), processed, false, classes); + for (int &E : emitters[i]) { + err = _write_node(Type(i), global_code, global_code_per_node, global_code_per_func, func_code, default_tex_params, input_connections, output_connections, E, processed, false, classes); ERR_FAIL_COND(err != OK); } } @@ -1800,112 +1816,112 @@ void VisualShader::_update_shader() const { code += "void start() {\n"; if (has_start || has_start_custom) { - code += "\tuint __seed = __hash(NUMBER + uint(1) + RANDOM_SEED);\n"; - code += "\tvec3 __diff = TRANSFORM[3].xyz - EMISSION_TRANSFORM[3].xyz;\n"; - code += "\tfloat __radians;\n"; - code += "\tvec3 __vec3_buff1;\n"; - code += "\tvec3 __vec3_buff2;\n"; - code += "\tfloat __scalar_buff1;\n"; - code += "\tfloat __scalar_buff2;\n"; - code += "\tvec3 __ndiff = normalize(__diff);\n\n"; + code += " uint __seed = __hash(NUMBER + uint(1) + RANDOM_SEED);\n"; + code += " vec3 __diff = TRANSFORM[3].xyz - EMISSION_TRANSFORM[3].xyz;\n"; + code += " float __radians;\n"; + code += " vec3 __vec3_buff1;\n"; + code += " vec3 __vec3_buff2;\n"; + code += " float __scalar_buff1;\n"; + code += " float __scalar_buff2;\n"; + code += " vec3 __ndiff = normalize(__diff);\n\n"; } if (has_start) { - code += "\t{\n"; - code += code_map[TYPE_START].replace("\n\t", "\n\t\t"); - code += "\t}\n"; + code += " {\n"; + code += code_map[TYPE_START].replace("\n ", "\n "); + code += " }\n"; if (has_start_custom) { - code += "\t\n"; + code += " \n"; } } if (has_start_custom) { - code += "\t{\n"; - code += code_map[TYPE_START_CUSTOM].replace("\n\t", "\n\t\t"); - code += "\t}\n"; + code += " {\n"; + code += code_map[TYPE_START_CUSTOM].replace("\n ", "\n "); + code += " }\n"; } code += "}\n\n"; code += "void process() {\n"; if (has_process || has_process_custom || has_collide) { - code += "\tuint __seed = __hash(NUMBER + uint(1) + RANDOM_SEED);\n"; - code += "\tvec3 __vec3_buff1;\n"; - code += "\tvec3 __diff = TRANSFORM[3].xyz - EMISSION_TRANSFORM[3].xyz;\n"; - code += "\tvec3 __ndiff = normalize(__diff);\n\n"; + code += " uint __seed = __hash(NUMBER + uint(1) + RANDOM_SEED);\n"; + code += " vec3 __vec3_buff1;\n"; + code += " vec3 __diff = TRANSFORM[3].xyz - EMISSION_TRANSFORM[3].xyz;\n"; + code += " vec3 __ndiff = normalize(__diff);\n\n"; } - code += "\t{\n"; - String tab = "\t"; + code += " {\n"; + String tab = " "; if (has_collide) { - code += "\t\tif (COLLIDED) {\n\n"; - code += code_map[TYPE_COLLIDE].replace("\n\t", "\n\t\t\t"); + code += " if (COLLIDED) {\n\n"; + code += code_map[TYPE_COLLIDE].replace("\n ", "\n "); if (has_process) { - code += "\t\t} else {\n\n"; - tab += "\t"; + code += " } else {\n\n"; + tab += " "; } } if (has_process) { - code += code_map[TYPE_PROCESS].replace("\n\t", "\n\t" + tab); + code += code_map[TYPE_PROCESS].replace("\n ", "\n " + tab); } if (has_collide) { - code += "\t\t}\n"; + code += " }\n"; } - code += "\t}\n"; + code += " }\n"; if (has_process_custom) { - code += "\t{\n\n"; - code += code_map[TYPE_PROCESS_CUSTOM].replace("\n\t", "\n\t\t"); - code += "\t}\n"; + code += " {\n\n"; + code += code_map[TYPE_PROCESS_CUSTOM].replace("\n ", "\n "); + code += " }\n"; } code += "}\n\n"; global_compute_code += "float __rand_from_seed(inout uint seed) {\n"; - global_compute_code += "\tint k;\n"; - global_compute_code += "\tint s = int(seed);\n"; - global_compute_code += "\tif (s == 0)\n"; - global_compute_code += "\ts = 305420679;\n"; - global_compute_code += "\tk = s / 127773;\n"; - global_compute_code += "\ts = 16807 * (s - k * 127773) - 2836 * k;\n"; - global_compute_code += "\tif (s < 0)\n"; - global_compute_code += "\t\ts += 2147483647;\n"; - global_compute_code += "\tseed = uint(s);\n"; - global_compute_code += "\treturn float(seed % uint(65536)) / 65535.0;\n"; + global_compute_code += " int k;\n"; + global_compute_code += " int s = int(seed);\n"; + global_compute_code += " if (s == 0)\n"; + global_compute_code += " s = 305420679;\n"; + global_compute_code += " k = s / 127773;\n"; + global_compute_code += " s = 16807 * (s - k * 127773) - 2836 * k;\n"; + global_compute_code += " if (s < 0)\n"; + global_compute_code += " s += 2147483647;\n"; + global_compute_code += " seed = uint(s);\n"; + global_compute_code += " return float(seed % uint(65536)) / 65535.0;\n"; global_compute_code += "}\n\n"; global_compute_code += "float __rand_from_seed_m1_p1(inout uint seed) {\n"; - global_compute_code += "\treturn __rand_from_seed(seed) * 2.0 - 1.0;\n"; + global_compute_code += " return __rand_from_seed(seed) * 2.0 - 1.0;\n"; global_compute_code += "}\n\n"; global_compute_code += "float __randf_range(inout uint seed, float from, float to) {\n"; - global_compute_code += "\treturn __rand_from_seed(seed) * (to - from) + from;\n"; + global_compute_code += " return __rand_from_seed(seed) * (to - from) + from;\n"; global_compute_code += "}\n\n"; global_compute_code += "vec3 __randv_range(inout uint seed, vec3 from, vec3 to) {\n"; - global_compute_code += "\treturn vec3(__randf_range(seed, from.x, to.x), __randf_range(seed, from.y, to.y), __randf_range(seed, from.z, to.z));\n"; + global_compute_code += " return vec3(__randf_range(seed, from.x, to.x), __randf_range(seed, from.y, to.y), __randf_range(seed, from.z, to.z));\n"; global_compute_code += "}\n\n"; global_compute_code += "uint __hash(uint x) {\n"; - global_compute_code += "\tx = ((x >> uint(16)) ^ x) * uint(73244475);\n"; - global_compute_code += "\tx = ((x >> uint(16)) ^ x) * uint(73244475);\n"; - global_compute_code += "\tx = (x >> uint(16)) ^ x;\n"; - global_compute_code += "\treturn x;\n"; + global_compute_code += " x = ((x >> uint(16)) ^ x) * uint(73244475);\n"; + global_compute_code += " x = ((x >> uint(16)) ^ x) * uint(73244475);\n"; + global_compute_code += " x = (x >> uint(16)) ^ x;\n"; + global_compute_code += " return x;\n"; global_compute_code += "}\n\n"; global_compute_code += "mat3 __build_rotation_mat3(vec3 axis, float angle) {\n"; - global_compute_code += "\taxis = normalize(axis);\n"; - global_compute_code += "\tfloat s = sin(angle);\n"; - global_compute_code += "\tfloat c = cos(angle);\n"; - global_compute_code += "\tfloat oc = 1.0 - c;\n"; - global_compute_code += "\treturn mat3(vec3(oc * axis.x * axis.x + c, oc * axis.x * axis.y - axis.z * s, oc * axis.z * axis.x + axis.y * s), vec3(oc * axis.x * axis.y + axis.z * s, oc * axis.y * axis.y + c, oc * axis.y * axis.z - axis.x * s), vec3(oc * axis.z * axis.x - axis.y * s, oc * axis.y * axis.z + axis.x * s, oc * axis.z * axis.z + c));\n"; + global_compute_code += " axis = normalize(axis);\n"; + global_compute_code += " float s = sin(angle);\n"; + global_compute_code += " float c = cos(angle);\n"; + global_compute_code += " float oc = 1.0 - c;\n"; + global_compute_code += " return mat3(vec3(oc * axis.x * axis.x + c, oc * axis.x * axis.y - axis.z * s, oc * axis.z * axis.x + axis.y * s), vec3(oc * axis.x * axis.y + axis.z * s, oc * axis.y * axis.y + c, oc * axis.y * axis.z - axis.x * s), vec3(oc * axis.z * axis.x - axis.y * s, oc * axis.y * axis.z + axis.x * s, oc * axis.z * axis.z + c));\n"; global_compute_code += "}\n\n"; global_compute_code += "mat4 __build_rotation_mat4(vec3 axis, float angle) {\n"; - global_compute_code += "\taxis = normalize(axis);\n"; - global_compute_code += "\tfloat s = sin(angle);\n"; - global_compute_code += "\tfloat c = cos(angle);\n"; - global_compute_code += "\tfloat oc = 1.0 - c;\n"; - global_compute_code += "\treturn mat4(vec4(oc * axis.x * axis.x + c, oc * axis.x * axis.y - axis.z * s, oc * axis.z * axis.x + axis.y * s, 0), vec4(oc * axis.x * axis.y + axis.z * s, oc * axis.y * axis.y + c, oc * axis.y * axis.z - axis.x * s, 0), vec4(oc * axis.z * axis.x - axis.y * s, oc * axis.y * axis.z + axis.x * s, oc * axis.z * axis.z + c, 0), vec4(0, 0, 0, 1));\n"; + global_compute_code += " axis = normalize(axis);\n"; + global_compute_code += " float s = sin(angle);\n"; + global_compute_code += " float c = cos(angle);\n"; + global_compute_code += " float oc = 1.0 - c;\n"; + global_compute_code += " return mat4(vec4(oc * axis.x * axis.x + c, oc * axis.x * axis.y - axis.z * s, oc * axis.z * axis.x + axis.y * s, 0), vec4(oc * axis.x * axis.y + axis.z * s, oc * axis.y * axis.y + c, oc * axis.y * axis.z - axis.x * s, 0), vec4(oc * axis.z * axis.x - axis.y * s, oc * axis.y * axis.z + axis.x * s, oc * axis.z * axis.z + c, 0), vec4(0, 0, 0, 1));\n"; global_compute_code += "}\n\n"; global_compute_code += "vec3 __get_random_unit_vec3(inout uint seed) {\n"; - global_compute_code += "\treturn normalize(vec3(__rand_from_seed_m1_p1(seed), __rand_from_seed_m1_p1(seed), __rand_from_seed_m1_p1(seed)));\n"; + global_compute_code += " return normalize(vec3(__rand_from_seed_m1_p1(seed), __rand_from_seed_m1_p1(seed), __rand_from_seed_m1_p1(seed)));\n"; global_compute_code += "}\n\n"; } @@ -1920,7 +1936,11 @@ void VisualShader::_update_shader() const { if (!has_func_name(RenderingServer::ShaderMode(shader_mode), func_name[i])) { continue; } - tcode = tcode.insert(insertion_pos[i], global_code_per_func[Type(i)]); + String func_code = global_code_per_func[Type(i)].as_string(); + if (empty_funcs.has(Type(i)) && !func_code.is_empty()) { + func_code = vformat("%s%s%s", String("\nvoid " + String(func_name[i]) + "() {\n"), func_code, "}\n"); + } + tcode = tcode.insert(insertion_pos[i], func_code); } final_code += tcode; @@ -1929,7 +1949,7 @@ void VisualShader::_update_shader() const { const_cast<VisualShader *>(this)->set_default_texture_param(default_tex_params[i].name, default_tex_params[i].param); } if (previous_code != final_code) { - const_cast<VisualShader *>(this)->emit_signal("changed"); + const_cast<VisualShader *>(this)->emit_signal(SNAME("changed")); } previous_code = final_code; } @@ -1940,7 +1960,7 @@ void VisualShader::_queue_update() { } dirty.set(); - call_deferred("_update_shader"); + call_deferred(SNAME("_update_shader")); } void VisualShader::_input_type_changed(Type p_type, int p_id) { @@ -2366,7 +2386,7 @@ String VisualShaderNodeInput::generate_code(Shader::Mode p_mode, VisualShader::T while (preview_ports[idx].mode != Shader::MODE_MAX) { if (preview_ports[idx].mode == shader_mode && preview_ports[idx].shader_type == shader_type && preview_ports[idx].name == input_name) { - code = "\t" + p_output_vars[0] + " = " + preview_ports[idx].string + ";\n"; + code = " " + p_output_vars[0] + " = " + preview_ports[idx].string + ";\n"; break; } idx++; @@ -2375,19 +2395,19 @@ String VisualShaderNodeInput::generate_code(Shader::Mode p_mode, VisualShader::T if (code == String()) { switch (get_output_port_type(0)) { case PORT_TYPE_SCALAR: { - code = "\t" + p_output_vars[0] + " = 0.0;\n"; + code = " " + p_output_vars[0] + " = 0.0;\n"; } break; case PORT_TYPE_SCALAR_INT: { - code = "\t" + p_output_vars[0] + " = 0;\n"; + code = " " + p_output_vars[0] + " = 0;\n"; } break; case PORT_TYPE_VECTOR: { - code = "\t" + p_output_vars[0] + " = vec3(0.0);\n"; + code = " " + p_output_vars[0] + " = vec3(0.0);\n"; } break; case PORT_TYPE_TRANSFORM: { - code = "\t" + p_output_vars[0] + " = mat4(vec4(1.0, 0.0, 0.0, 0.0), vec4(0.0, 1.0, 0.0, 0.0), vec4(0.0, 0.0, 1.0, 0.0), vec4(0.0, 0.0, 0.0, 1.0));\n"; + code = " " + p_output_vars[0] + " = mat4(vec4(1.0, 0.0, 0.0, 0.0), vec4(0.0, 1.0, 0.0, 0.0), vec4(0.0, 0.0, 1.0, 0.0), vec4(0.0, 0.0, 0.0, 1.0));\n"; } break; case PORT_TYPE_BOOLEAN: { - code = "\t" + p_output_vars[0] + " = false;\n"; + code = " " + p_output_vars[0] + " = false;\n"; } break; default: //default (none found) is scalar break; @@ -2403,14 +2423,14 @@ String VisualShaderNodeInput::generate_code(Shader::Mode p_mode, VisualShader::T while (ports[idx].mode != Shader::MODE_MAX) { if (ports[idx].mode == shader_mode && ports[idx].shader_type == shader_type && ports[idx].name == input_name) { - code = "\t" + p_output_vars[0] + " = " + ports[idx].string + ";\n"; + code = " " + p_output_vars[0] + " = " + ports[idx].string + ";\n"; break; } idx++; } if (code == String()) { - code = "\t" + p_output_vars[0] + " = 0.0;\n"; //default (none found) is scalar + code = " " + p_output_vars[0] + " = 0.0;\n"; //default (none found) is scalar } return code; @@ -2422,7 +2442,7 @@ void VisualShaderNodeInput::set_input_name(String p_name) { input_name = p_name; emit_changed(); if (get_input_type_by_name(input_name) != prev_type) { - emit_signal("input_type_changed"); + emit_signal(SNAME("input_type_changed")); } } @@ -2566,8 +2586,8 @@ void VisualShaderNodeUniformRef::clear_uniforms() { } bool VisualShaderNodeUniformRef::has_uniform(const String &p_name) { - for (List<VisualShaderNodeUniformRef::Uniform>::Element *E = uniforms.front(); E; E = E->next()) { - if (E->get().name == p_name) { + for (const VisualShaderNodeUniformRef::Uniform &E : uniforms) { + if (E.name == p_name) { return true; } } @@ -2734,20 +2754,20 @@ String VisualShaderNodeUniformRef::generate_code(Shader::Mode p_mode, VisualShad switch (uniform_type) { case UniformType::UNIFORM_TYPE_FLOAT: if (uniform_name == "[None]") { - return "\t" + p_output_vars[0] + " = 0.0;\n"; + return " " + p_output_vars[0] + " = 0.0;\n"; } - return "\t" + p_output_vars[0] + " = " + get_uniform_name() + ";\n"; + return " " + p_output_vars[0] + " = " + get_uniform_name() + ";\n"; case UniformType::UNIFORM_TYPE_INT: - return "\t" + p_output_vars[0] + " = " + get_uniform_name() + ";\n"; + return " " + p_output_vars[0] + " = " + get_uniform_name() + ";\n"; case UniformType::UNIFORM_TYPE_BOOLEAN: - return "\t" + p_output_vars[0] + " = " + get_uniform_name() + ";\n"; + return " " + p_output_vars[0] + " = " + get_uniform_name() + ";\n"; case UniformType::UNIFORM_TYPE_VECTOR: - return "\t" + p_output_vars[0] + " = " + get_uniform_name() + ";\n"; + return " " + p_output_vars[0] + " = " + get_uniform_name() + ";\n"; case UniformType::UNIFORM_TYPE_TRANSFORM: - return "\t" + p_output_vars[0] + " = " + get_uniform_name() + ";\n"; + return " " + p_output_vars[0] + " = " + get_uniform_name() + ";\n"; case UniformType::UNIFORM_TYPE_COLOR: { - String code = "\t" + p_output_vars[0] + " = " + get_uniform_name() + ".rgb;\n"; - code += "\t" + p_output_vars[1] + " = " + get_uniform_name() + ".a;\n"; + String code = " " + p_output_vars[0] + " = " + get_uniform_name() + ".rgb;\n"; + code += " " + p_output_vars[1] + " = " + get_uniform_name() + ".a;\n"; return code; } break; case UniformType::UNIFORM_TYPE_SAMPLER: @@ -2943,9 +2963,9 @@ String VisualShaderNodeOutput::generate_code(Shader::Mode p_mode, VisualShader:: if (p_input_vars[count] != String()) { String s = ports[idx].string; if (s.find(":") != -1) { - code += "\t" + s.get_slicec(':', 0) + " = " + p_input_vars[count] + "." + s.get_slicec(':', 1) + ";\n"; + code += " " + s.get_slicec(':', 0) + " = " + p_input_vars[count] + "." + s.get_slicec(':', 1) + ";\n"; } else { - code += "\t" + s + " = " + p_input_vars[count] + ";\n"; + code += " " + s + " = " + p_input_vars[count] + ";\n"; } } count++; @@ -2963,7 +2983,7 @@ VisualShaderNodeOutput::VisualShaderNodeOutput() { void VisualShaderNodeUniform::set_uniform_name(const String &p_name) { uniform_name = p_name; - emit_signal("name_changed"); + emit_signal(SNAME("name_changed")); emit_changed(); } @@ -3620,11 +3640,11 @@ String VisualShaderNodeExpression::generate_code(Shader::Mode p_mode, VisualShad String _expression = expression; _expression = _expression.insert(0, "\n"); - _expression = _expression.replace("\n", "\n\t\t"); + _expression = _expression.replace("\n", "\n "); static Vector<String> pre_symbols; if (pre_symbols.is_empty()) { - pre_symbols.push_back("\t"); + pre_symbols.push_back(" "); pre_symbols.push_back(","); pre_symbols.push_back(";"); pre_symbols.push_back("{"); @@ -3644,7 +3664,7 @@ String VisualShaderNodeExpression::generate_code(Shader::Mode p_mode, VisualShad static Vector<String> post_symbols; if (post_symbols.is_empty()) { - post_symbols.push_back("\t"); + post_symbols.push_back(" "); post_symbols.push_back("\n"); post_symbols.push_back(","); post_symbols.push_back(";"); @@ -3703,14 +3723,14 @@ String VisualShaderNodeExpression::generate_code(Shader::Mode p_mode, VisualShad default: continue; } - output_initializer += "\t" + p_output_vars[i] + " = " + tk + ";\n"; + output_initializer += " " + p_output_vars[i] + " = " + tk + ";\n"; } String code; code += output_initializer; - code += "\t{"; + code += " {"; code += _expression; - code += "\n\t}\n"; + code += "\n }\n"; return code; } diff --git a/scene/resources/visual_shader_nodes.cpp b/scene/resources/visual_shader_nodes.cpp index 4e73b8db44..6fd6fd8f3b 100644 --- a/scene/resources/visual_shader_nodes.cpp +++ b/scene/resources/visual_shader_nodes.cpp @@ -66,7 +66,7 @@ String VisualShaderNodeFloatConstant::get_output_port_name(int p_port) const { } String VisualShaderNodeFloatConstant::generate_code(Shader::Mode p_mode, VisualShader::Type p_type, int p_id, const String *p_input_vars, const String *p_output_vars, bool p_for_preview) const { - return "\t" + p_output_vars[0] + " = " + vformat("%.6f", constant) + ";\n"; + return " " + p_output_vars[0] + " = " + vformat("%.6f", constant) + ";\n"; } void VisualShaderNodeFloatConstant::set_constant(float p_value) { @@ -125,7 +125,7 @@ String VisualShaderNodeIntConstant::get_output_port_name(int p_port) const { } String VisualShaderNodeIntConstant::generate_code(Shader::Mode p_mode, VisualShader::Type p_type, int p_id, const String *p_input_vars, const String *p_output_vars, bool p_for_preview) const { - return "\t" + p_output_vars[0] + " = " + itos(constant) + ";\n"; + return " " + p_output_vars[0] + " = " + itos(constant) + ";\n"; } void VisualShaderNodeIntConstant::set_constant(int p_value) { @@ -184,7 +184,7 @@ String VisualShaderNodeBooleanConstant::get_output_port_name(int p_port) const { } String VisualShaderNodeBooleanConstant::generate_code(Shader::Mode p_mode, VisualShader::Type p_type, int p_id, const String *p_input_vars, const String *p_output_vars, bool p_for_preview) const { - return "\t" + p_output_vars[0] + " = " + (constant ? "true" : "false") + ";\n"; + return " " + p_output_vars[0] + " = " + (constant ? "true" : "false") + ";\n"; } void VisualShaderNodeBooleanConstant::set_constant(bool p_value) { @@ -251,8 +251,8 @@ bool VisualShaderNodeColorConstant::is_output_port_expandable(int p_port) const String VisualShaderNodeColorConstant::generate_code(Shader::Mode p_mode, VisualShader::Type p_type, int p_id, const String *p_input_vars, const String *p_output_vars, bool p_for_preview) const { String code; - code += "\t" + p_output_vars[0] + " = " + vformat("vec3(%.6f, %.6f, %.6f)", constant.r, constant.g, constant.b) + ";\n"; - code += "\t" + p_output_vars[1] + " = " + vformat("%.6f", constant.a) + ";\n"; + code += " " + p_output_vars[0] + " = " + vformat("vec3(%.6f, %.6f, %.6f)", constant.r, constant.g, constant.b) + ";\n"; + code += " " + p_output_vars[1] + " = " + vformat("%.6f", constant.a) + ";\n"; return code; } @@ -313,7 +313,7 @@ String VisualShaderNodeVec3Constant::get_output_port_name(int p_port) const { } String VisualShaderNodeVec3Constant::generate_code(Shader::Mode p_mode, VisualShader::Type p_type, int p_id, const String *p_input_vars, const String *p_output_vars, bool p_for_preview) const { - return "\t" + p_output_vars[0] + " = " + vformat("vec3(%.6f, %.6f, %.6f)", constant.x, constant.y, constant.z) + ";\n"; + return " " + p_output_vars[0] + " = " + vformat("vec3(%.6f, %.6f, %.6f)", constant.x, constant.y, constant.z) + ";\n"; } void VisualShaderNodeVec3Constant::set_constant(Vector3 p_value) { @@ -375,7 +375,7 @@ String VisualShaderNodeTransformConstant::generate_code(Shader::Mode p_mode, Vis Transform3D t = constant; t.basis.transpose(); - String code = "\t" + p_output_vars[0] + " = mat4("; + String code = " " + p_output_vars[0] + " = mat4("; code += vformat("vec4(%.6f, %.6f, %.6f, 0.0), ", t.basis[0].x, t.basis[0].y, t.basis[0].z); code += vformat("vec4(%.6f, %.6f, %.6f, 0.0), ", t.basis[1].x, t.basis[1].y, t.basis[1].z); code += vformat("vec4(%.6f, %.6f, %.6f, 0.0), ", t.basis[2].x, t.basis[2].y, t.basis[2].z); @@ -523,20 +523,20 @@ String VisualShaderNodeTexture::generate_code(Shader::Mode p_mode, VisualShader: if (p_input_vars[0] == String()) { // Use UV by default. if (p_input_vars[1] == String()) { - code += "\tvec4 " + id + "_read = texture(" + id + ", " + default_uv + ");\n"; + code += " vec4 " + id + "_read = texture(" + id + ", " + default_uv + ");\n"; } else { - code += "\tvec4 " + id + "_read = textureLod(" + id + ", " + default_uv + ", " + p_input_vars[1] + ");\n"; + code += " vec4 " + id + "_read = textureLod(" + id + ", " + default_uv + ", " + p_input_vars[1] + ");\n"; } } else if (p_input_vars[1] == String()) { //no lod - code += "\tvec4 " + id + "_read = texture(" + id + ", " + p_input_vars[0] + ".xy);\n"; + code += " vec4 " + id + "_read = texture(" + id + ", " + p_input_vars[0] + ".xy);\n"; } else { - code += "\tvec4 " + id + "_read = textureLod(" + id + ", " + p_input_vars[0] + ".xy, " + p_input_vars[1] + ");\n"; + code += " vec4 " + id + "_read = textureLod(" + id + ", " + p_input_vars[0] + ".xy, " + p_input_vars[1] + ");\n"; } - code += "\t" + p_output_vars[0] + " = " + id + "_read.rgb;\n"; - code += "\t" + p_output_vars[1] + " = " + id + "_read.a;\n"; + code += " " + p_output_vars[0] + " = " + id + "_read.rgb;\n"; + code += " " + p_output_vars[1] + " = " + id + "_read.a;\n"; return code; } @@ -544,98 +544,98 @@ String VisualShaderNodeTexture::generate_code(Shader::Mode p_mode, VisualShader: String id = p_input_vars[2]; String code; - code += "\t{\n"; + code += " {\n"; if (id == String()) { - code += "\t\tvec4 " + id + "_tex_read = vec4(0.0);\n"; + code += " vec4 " + id + "_tex_read = vec4(0.0);\n"; } else { if (p_input_vars[0] == String()) { // Use UV by default. if (p_input_vars[1] == String()) { - code += "\t\tvec4 " + id + "_tex_read = texture(" + id + ", " + default_uv + ");\n"; + code += " vec4 " + id + "_tex_read = texture(" + id + ", " + default_uv + ");\n"; } else { - code += "\t\tvec4 " + id + "_tex_read = textureLod(" + id + ", " + default_uv + ", " + p_input_vars[1] + ");\n"; + code += " vec4 " + id + "_tex_read = textureLod(" + id + ", " + default_uv + ", " + p_input_vars[1] + ");\n"; } } else if (p_input_vars[1] == String()) { //no lod - code += "\t\tvec4 " + id + "_tex_read = texture(" + id + ", " + p_input_vars[0] + ".xy);\n"; + code += " vec4 " + id + "_tex_read = texture(" + id + ", " + p_input_vars[0] + ".xy);\n"; } else { - code += "\t\tvec4 " + id + "_tex_read = textureLod(" + id + ", " + p_input_vars[0] + ".xy, " + p_input_vars[1] + ");\n"; + code += " vec4 " + id + "_tex_read = textureLod(" + id + ", " + p_input_vars[0] + ".xy, " + p_input_vars[1] + ");\n"; } - code += "\t\t" + p_output_vars[0] + " = " + id + "_tex_read.rgb;\n"; - code += "\t\t" + p_output_vars[1] + " = " + id + "_tex_read.a;\n"; + code += " " + p_output_vars[0] + " = " + id + "_tex_read.rgb;\n"; + code += " " + p_output_vars[1] + " = " + id + "_tex_read.a;\n"; } - code += "\t}\n"; + code += " }\n"; return code; } if (source == SOURCE_SCREEN && (p_mode == Shader::MODE_SPATIAL || p_mode == Shader::MODE_CANVAS_ITEM) && p_type == VisualShader::TYPE_FRAGMENT) { - String code = "\t{\n"; + String code = " {\n"; if (p_input_vars[0] == String() || p_for_preview) { // Use UV by default. if (p_input_vars[1] == String()) { - code += "\t\tvec4 _tex_read = textureLod(SCREEN_TEXTURE, " + default_uv + ", 0.0 );\n"; + code += " vec4 _tex_read = textureLod(SCREEN_TEXTURE, " + default_uv + ", 0.0 );\n"; } else { - code += "\t\tvec4 _tex_read = textureLod(SCREEN_TEXTURE, " + default_uv + ", " + p_input_vars[1] + ");\n"; + code += " vec4 _tex_read = textureLod(SCREEN_TEXTURE, " + default_uv + ", " + p_input_vars[1] + ");\n"; } } else if (p_input_vars[1] == String()) { //no lod - code += "\t\tvec4 _tex_read = textureLod(SCREEN_TEXTURE, " + p_input_vars[0] + ".xy, 0.0);\n"; + code += " vec4 _tex_read = textureLod(SCREEN_TEXTURE, " + p_input_vars[0] + ".xy, 0.0);\n"; } else { - code += "\t\tvec4 _tex_read = textureLod(SCREEN_TEXTURE, " + p_input_vars[0] + ".xy, " + p_input_vars[1] + ");\n"; + code += " vec4 _tex_read = textureLod(SCREEN_TEXTURE, " + p_input_vars[0] + ".xy, " + p_input_vars[1] + ");\n"; } - code += "\t\t" + p_output_vars[0] + " = _tex_read.rgb;\n"; - code += "\t\t" + p_output_vars[1] + " = _tex_read.a;\n"; - code += "\t}\n"; + code += " " + p_output_vars[0] + " = _tex_read.rgb;\n"; + code += " " + p_output_vars[1] + " = _tex_read.a;\n"; + code += " }\n"; return code; } if (source == SOURCE_2D_TEXTURE && p_mode == Shader::MODE_CANVAS_ITEM && p_type == VisualShader::TYPE_FRAGMENT) { - String code = "\t{\n"; + String code = " {\n"; if (p_input_vars[0] == String()) { // Use UV by default. if (p_input_vars[1] == String()) { - code += "\t\tvec4 _tex_read = texture(TEXTURE, " + default_uv + ");\n"; + code += " vec4 _tex_read = texture(TEXTURE, " + default_uv + ");\n"; } else { - code += "\t\tvec4 _tex_read = textureLod(TEXTURE, " + default_uv + ", " + p_input_vars[1] + ");\n"; + code += " vec4 _tex_read = textureLod(TEXTURE, " + default_uv + ", " + p_input_vars[1] + ");\n"; } } else if (p_input_vars[1] == String()) { //no lod - code += "\t\tvec4 _tex_read = texture(TEXTURE, " + p_input_vars[0] + ".xy);\n"; + code += " vec4 _tex_read = texture(TEXTURE, " + p_input_vars[0] + ".xy);\n"; } else { - code += "\t\tvec4 _tex_read = textureLod(TEXTURE, " + p_input_vars[0] + ".xy, " + p_input_vars[1] + ");\n"; + code += " vec4 _tex_read = textureLod(TEXTURE, " + p_input_vars[0] + ".xy, " + p_input_vars[1] + ");\n"; } - code += "\t\t" + p_output_vars[0] + " = _tex_read.rgb;\n"; - code += "\t\t" + p_output_vars[1] + " = _tex_read.a;\n"; - code += "\t}\n"; + code += " " + p_output_vars[0] + " = _tex_read.rgb;\n"; + code += " " + p_output_vars[1] + " = _tex_read.a;\n"; + code += " }\n"; return code; } if (source == SOURCE_2D_NORMAL && p_mode == Shader::MODE_CANVAS_ITEM && p_type == VisualShader::TYPE_FRAGMENT) { - String code = "\t{\n"; + String code = " {\n"; if (p_input_vars[0] == String()) { // Use UV by default. if (p_input_vars[1] == String()) { - code += "\t\tvec4 _tex_read = texture(NORMAL_TEXTURE, " + default_uv + ");\n"; + code += " vec4 _tex_read = texture(NORMAL_TEXTURE, " + default_uv + ");\n"; } else { - code += "\t\tvec4 _tex_read = textureLod(NORMAL_TEXTURE, " + default_uv + ", " + p_input_vars[1] + ");\n"; + code += " vec4 _tex_read = textureLod(NORMAL_TEXTURE, " + default_uv + ", " + p_input_vars[1] + ");\n"; } } else if (p_input_vars[1] == String()) { //no lod - code += "\t\tvec4 _tex_read = texture(NORMAL_TEXTURE, " + p_input_vars[0] + ".xy);\n"; + code += " vec4 _tex_read = texture(NORMAL_TEXTURE, " + p_input_vars[0] + ".xy);\n"; } else { - code += "\t\tvec4 _tex_read = textureLod(NORMAL_TEXTURE, " + p_input_vars[0] + ".xy, " + p_input_vars[1] + ");\n"; + code += " vec4 _tex_read = textureLod(NORMAL_TEXTURE, " + p_input_vars[0] + ".xy, " + p_input_vars[1] + ");\n"; } - code += "\t\t" + p_output_vars[0] + " = _tex_read.rgb;\n"; - code += "\t\t" + p_output_vars[1] + " = _tex_read.a;\n"; - code += "\t}\n"; + code += " " + p_output_vars[0] + " = _tex_read.rgb;\n"; + code += " " + p_output_vars[1] + " = _tex_read.a;\n"; + code += " }\n"; return code; } @@ -643,44 +643,44 @@ String VisualShaderNodeTexture::generate_code(Shader::Mode p_mode, VisualShader: { if (source == SOURCE_DEPTH) { String code; - code += "\t" + p_output_vars[0] + " = 0.0;\n"; - code += "\t" + p_output_vars[1] + " = 1.0;\n"; + code += " " + p_output_vars[0] + " = 0.0;\n"; + code += " " + p_output_vars[1] + " = 1.0;\n"; return code; } } if (source == SOURCE_DEPTH && p_mode == Shader::MODE_SPATIAL && p_type == VisualShader::TYPE_FRAGMENT) { - String code = "\t{\n"; + String code = " {\n"; if (p_input_vars[0] == String()) { // Use UV by default. if (p_input_vars[1] == String()) { - code += "\t\tfloat _depth = texture(DEPTH_TEXTURE, " + default_uv + ").r;\n"; + code += " float _depth = texture(DEPTH_TEXTURE, " + default_uv + ").r;\n"; } else { - code += "\t\tfloat _depth = textureLod(DEPTH_TEXTURE, " + default_uv + ", " + p_input_vars[1] + ").r;\n"; + code += " float _depth = textureLod(DEPTH_TEXTURE, " + default_uv + ", " + p_input_vars[1] + ").r;\n"; } } else if (p_input_vars[1] == String()) { //no lod - code += "\t\tfloat _depth = texture(DEPTH_TEXTURE, " + p_input_vars[0] + ".xy).r;\n"; + code += " float _depth = texture(DEPTH_TEXTURE, " + p_input_vars[0] + ".xy).r;\n"; } else { - code += "\t\tfloat _depth = textureLod(DEPTH_TEXTURE, " + p_input_vars[0] + ".xy, " + p_input_vars[1] + ").r;\n"; + code += " float _depth = textureLod(DEPTH_TEXTURE, " + p_input_vars[0] + ".xy, " + p_input_vars[1] + ").r;\n"; } - code += "\t\t" + p_output_vars[0] + " = _depth;\n"; - code += "\t\t" + p_output_vars[1] + " = 1.0;\n"; - code += "\t}\n"; + code += " " + p_output_vars[0] + " = _depth;\n"; + code += " " + p_output_vars[1] + " = 1.0;\n"; + code += " }\n"; return code; } else if (source == SOURCE_DEPTH) { String code; - code += "\t" + p_output_vars[0] + " = 0.0;\n"; - code += "\t" + p_output_vars[1] + " = 1.0;\n"; + code += " " + p_output_vars[0] + " = 0.0;\n"; + code += " " + p_output_vars[1] + " = 1.0;\n"; return code; } //none String code; - code += "\t" + p_output_vars[0] + " = vec3(0.0);\n"; - code += "\t" + p_output_vars[1] + " = 1.0;\n"; + code += " " + p_output_vars[0] + " = vec3(0.0);\n"; + code += " " + p_output_vars[1] + " = 1.0;\n"; return code; } @@ -707,7 +707,7 @@ void VisualShaderNodeTexture::set_source(Source p_source) { break; } emit_changed(); - emit_signal("editor_refresh_request"); + emit_signal(SNAME("editor_refresh_request")); } VisualShaderNodeTexture::Source VisualShaderNodeTexture::get_source() const { @@ -856,11 +856,11 @@ String VisualShaderNodeCurveTexture::generate_global(Shader::Mode p_mode, Visual String VisualShaderNodeCurveTexture::generate_code(Shader::Mode p_mode, VisualShader::Type p_type, int p_id, const String *p_input_vars, const String *p_output_vars, bool p_for_preview) const { if (p_input_vars[0] == String()) { - return "\t" + p_output_vars[0] + " = 0.0;\n"; + return " " + p_output_vars[0] + " = 0.0;\n"; } String id = make_unique_id(p_type, p_id, "curve"); String code; - code += "\t" + p_output_vars[0] + " = texture(" + id + ", vec2(" + p_input_vars[0] + ")).r;\n"; + code += " " + p_output_vars[0] + " = texture(" + id + ", vec2(" + p_input_vars[0] + ")).r;\n"; return code; } @@ -889,66 +889,66 @@ VisualShaderNodeCurveTexture::VisualShaderNodeCurveTexture() { allow_v_resize = false; } -////////////// Curve3Texture +////////////// CurveXYZTexture -String VisualShaderNodeCurve3Texture::get_caption() const { - return "Curve3Texture"; +String VisualShaderNodeCurveXYZTexture::get_caption() const { + return "CurveXYZTexture"; } -int VisualShaderNodeCurve3Texture::get_input_port_count() const { +int VisualShaderNodeCurveXYZTexture::get_input_port_count() const { return 1; } -VisualShaderNodeCurve3Texture::PortType VisualShaderNodeCurve3Texture::get_input_port_type(int p_port) const { +VisualShaderNodeCurveXYZTexture::PortType VisualShaderNodeCurveXYZTexture::get_input_port_type(int p_port) const { return PORT_TYPE_SCALAR; } -String VisualShaderNodeCurve3Texture::get_input_port_name(int p_port) const { +String VisualShaderNodeCurveXYZTexture::get_input_port_name(int p_port) const { return String(); } -int VisualShaderNodeCurve3Texture::get_output_port_count() const { +int VisualShaderNodeCurveXYZTexture::get_output_port_count() const { return 1; } -VisualShaderNodeCurve3Texture::PortType VisualShaderNodeCurve3Texture::get_output_port_type(int p_port) const { +VisualShaderNodeCurveXYZTexture::PortType VisualShaderNodeCurveXYZTexture::get_output_port_type(int p_port) const { return PORT_TYPE_VECTOR; } -String VisualShaderNodeCurve3Texture::get_output_port_name(int p_port) const { +String VisualShaderNodeCurveXYZTexture::get_output_port_name(int p_port) const { return String(); } -void VisualShaderNodeCurve3Texture::set_texture(Ref<Curve3Texture> p_texture) { +void VisualShaderNodeCurveXYZTexture::set_texture(Ref<CurveXYZTexture> p_texture) { texture = p_texture; emit_changed(); } -Ref<Curve3Texture> VisualShaderNodeCurve3Texture::get_texture() const { +Ref<CurveXYZTexture> VisualShaderNodeCurveXYZTexture::get_texture() const { return texture; } -Vector<StringName> VisualShaderNodeCurve3Texture::get_editable_properties() const { +Vector<StringName> VisualShaderNodeCurveXYZTexture::get_editable_properties() const { Vector<StringName> props; props.push_back("texture"); return props; } -String VisualShaderNodeCurve3Texture::generate_global(Shader::Mode p_mode, VisualShader::Type p_type, int p_id) const { +String VisualShaderNodeCurveXYZTexture::generate_global(Shader::Mode p_mode, VisualShader::Type p_type, int p_id) const { return "uniform sampler2D " + make_unique_id(p_type, p_id, "curve3d") + ";\n"; } -String VisualShaderNodeCurve3Texture::generate_code(Shader::Mode p_mode, VisualShader::Type p_type, int p_id, const String *p_input_vars, const String *p_output_vars, bool p_for_preview) const { +String VisualShaderNodeCurveXYZTexture::generate_code(Shader::Mode p_mode, VisualShader::Type p_type, int p_id, const String *p_input_vars, const String *p_output_vars, bool p_for_preview) const { if (p_input_vars[0] == String()) { - return "\t" + p_output_vars[0] + " = vec3(0.0);\n"; + return " " + p_output_vars[0] + " = vec3(0.0);\n"; } String id = make_unique_id(p_type, p_id, "curve3d"); String code; - code += "\t" + p_output_vars[0] + " = texture(" + id + ", vec2(" + p_input_vars[0] + ")).rgb;\n"; + code += " " + p_output_vars[0] + " = texture(" + id + ", vec2(" + p_input_vars[0] + ")).rgb;\n"; return code; } -Vector<VisualShader::DefaultTextureParam> VisualShaderNodeCurve3Texture::get_default_texture_parameters(VisualShader::Type p_type, int p_id) const { +Vector<VisualShader::DefaultTextureParam> VisualShaderNodeCurveXYZTexture::get_default_texture_parameters(VisualShader::Type p_type, int p_id) const { VisualShader::DefaultTextureParam dtp; dtp.name = make_unique_id(p_type, p_id, "curve3d"); dtp.param = texture; @@ -957,18 +957,18 @@ Vector<VisualShader::DefaultTextureParam> VisualShaderNodeCurve3Texture::get_def return ret; } -void VisualShaderNodeCurve3Texture::_bind_methods() { - ClassDB::bind_method(D_METHOD("set_texture", "texture"), &VisualShaderNodeCurve3Texture::set_texture); - ClassDB::bind_method(D_METHOD("get_texture"), &VisualShaderNodeCurve3Texture::get_texture); +void VisualShaderNodeCurveXYZTexture::_bind_methods() { + ClassDB::bind_method(D_METHOD("set_texture", "texture"), &VisualShaderNodeCurveXYZTexture::set_texture); + ClassDB::bind_method(D_METHOD("get_texture"), &VisualShaderNodeCurveXYZTexture::get_texture); - ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "texture", PROPERTY_HINT_RESOURCE_TYPE, "Curve3Texture"), "set_texture", "get_texture"); + ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "texture", PROPERTY_HINT_RESOURCE_TYPE, "CurveXYZTexture"), "set_texture", "get_texture"); } -bool VisualShaderNodeCurve3Texture::is_use_prop_slots() const { +bool VisualShaderNodeCurveXYZTexture::is_use_prop_slots() const { return true; } -VisualShaderNodeCurve3Texture::VisualShaderNodeCurve3Texture() { +VisualShaderNodeCurveXYZTexture::VisualShaderNodeCurveXYZTexture() { simple_decl = true; allow_v_resize = false; } @@ -1040,7 +1040,7 @@ String VisualShaderNodeSample3D::generate_code(Shader::Mode p_mode, VisualShader String code; if (source == SOURCE_TEXTURE || source == SOURCE_PORT) { String id; - code += "\t{\n"; + code += " {\n"; if (source == SOURCE_TEXTURE) { id = make_unique_id(p_type, p_id, "tex3d"); } else { @@ -1049,34 +1049,34 @@ String VisualShaderNodeSample3D::generate_code(Shader::Mode p_mode, VisualShader if (id != String()) { if (p_input_vars[0] == String()) { // Use UV by default. if (p_input_vars[1] == String()) { - code += "\t\tvec4 " + id + "_tex_read = texture(" + id + ", " + default_uv + ");\n"; + code += " vec4 " + id + "_tex_read = texture(" + id + ", " + default_uv + ");\n"; } else { - code += "\t\tvec4 " + id + "_tex_read = textureLod(" + id + ", " + default_uv + ", " + p_input_vars[1] + ");\n"; + code += " vec4 " + id + "_tex_read = textureLod(" + id + ", " + default_uv + ", " + p_input_vars[1] + ");\n"; } } else if (p_input_vars[1] == String()) { //no lod - code += "\t\tvec4 " + id + "_tex_read = texture(" + id + ", " + p_input_vars[0] + ");\n"; + code += " vec4 " + id + "_tex_read = texture(" + id + ", " + p_input_vars[0] + ");\n"; } else { - code += "\t\tvec4 " + id + "_tex_read = textureLod(" + id + ", " + p_input_vars[0] + ", " + p_input_vars[1] + ");\n"; + code += " vec4 " + id + "_tex_read = textureLod(" + id + ", " + p_input_vars[0] + ", " + p_input_vars[1] + ");\n"; } } else { - code += "\t\tvec4 " + id + "_tex_read = vec4(0.0);\n"; + code += " vec4 " + id + "_tex_read = vec4(0.0);\n"; } - code += "\t\t" + p_output_vars[0] + " = " + id + "_tex_read.rgb;\n"; - code += "\t\t" + p_output_vars[1] + " = " + id + "_tex_read.a;\n"; - code += "\t}\n"; + code += " " + p_output_vars[0] + " = " + id + "_tex_read.rgb;\n"; + code += " " + p_output_vars[1] + " = " + id + "_tex_read.a;\n"; + code += " }\n"; return code; } - code += "\t" + p_output_vars[0] + " = vec3(0.0);\n"; - code += "\t" + p_output_vars[1] + " = 1.0;\n"; + code += " " + p_output_vars[0] + " = vec3(0.0);\n"; + code += " " + p_output_vars[1] + " = 1.0;\n"; return code; } void VisualShaderNodeSample3D::set_source(Source p_source) { source = p_source; emit_changed(); - emit_signal("editor_refresh_request"); + emit_signal(SNAME("editor_refresh_request")); } VisualShaderNodeSample3D::Source VisualShaderNodeSample3D::get_source() const { @@ -1325,33 +1325,33 @@ String VisualShaderNodeCubemap::generate_code(Shader::Mode p_mode, VisualShader: return String(); } - code += "\t{\n"; + code += " {\n"; if (id == String()) { - code += "\t\tvec4 " + id + "_read = vec4(0.0);\n"; - code += "\t\t" + p_output_vars[0] + " = " + id + "_read.rgb;\n"; - code += "\t\t" + p_output_vars[1] + " = " + id + "_read.a;\n"; - code += "\t}\n"; + code += " vec4 " + id + "_read = vec4(0.0);\n"; + code += " " + p_output_vars[0] + " = " + id + "_read.rgb;\n"; + code += " " + p_output_vars[1] + " = " + id + "_read.a;\n"; + code += " }\n"; return code; } if (p_input_vars[0] == String()) { // Use UV by default. if (p_input_vars[1] == String()) { - code += "\t\tvec4 " + id + "_read = texture(" + id + ", " + default_uv + ");\n"; + code += " vec4 " + id + "_read = texture(" + id + ", " + default_uv + ");\n"; } else { - code += "\t\tvec4 " + id + "_read = textureLod(" + id + ", " + default_uv + ", " + p_input_vars[1] + " );\n"; + code += " vec4 " + id + "_read = textureLod(" + id + ", " + default_uv + ", " + p_input_vars[1] + " );\n"; } } else if (p_input_vars[1] == String()) { //no lod - code += "\t\tvec4 " + id + "_read = texture(" + id + ", " + p_input_vars[0] + ");\n"; + code += " vec4 " + id + "_read = texture(" + id + ", " + p_input_vars[0] + ");\n"; } else { - code += "\t\tvec4 " + id + "_read = textureLod(" + id + ", " + p_input_vars[0] + ", " + p_input_vars[1] + ");\n"; + code += " vec4 " + id + "_read = textureLod(" + id + ", " + p_input_vars[0] + ", " + p_input_vars[1] + ");\n"; } - code += "\t\t" + p_output_vars[0] + " = " + id + "_read.rgb;\n"; - code += "\t\t" + p_output_vars[1] + " = " + id + "_read.a;\n"; - code += "\t}\n"; + code += " " + p_output_vars[0] + " = " + id + "_read.rgb;\n"; + code += " " + p_output_vars[1] + " = " + id + "_read.a;\n"; + code += " }\n"; return code; } @@ -1366,7 +1366,7 @@ String VisualShaderNodeCubemap::get_input_port_default_hint(int p_port) const { void VisualShaderNodeCubemap::set_source(Source p_source) { source = p_source; emit_changed(); - emit_signal("editor_refresh_request"); + emit_signal(SNAME("editor_refresh_request")); } VisualShaderNodeCubemap::Source VisualShaderNodeCubemap::get_source() const { @@ -1465,7 +1465,7 @@ String VisualShaderNodeFloatOp::get_output_port_name(int p_port) const { } String VisualShaderNodeFloatOp::generate_code(Shader::Mode p_mode, VisualShader::Type p_type, int p_id, const String *p_input_vars, const String *p_output_vars, bool p_for_preview) const { - String code = "\t" + p_output_vars[0] + " = "; + String code = " " + p_output_vars[0] + " = "; switch (op) { case OP_ADD: code += p_input_vars[0] + " + " + p_input_vars[1] + ";\n"; @@ -1571,7 +1571,7 @@ String VisualShaderNodeIntOp::get_output_port_name(int p_port) const { } String VisualShaderNodeIntOp::generate_code(Shader::Mode p_mode, VisualShader::Type p_type, int p_id, const String *p_input_vars, const String *p_output_vars, bool p_for_preview) const { - String code = "\t" + p_output_vars[0] + " = "; + String code = " " + p_output_vars[0] + " = "; switch (op) { case OP_ADD: code += p_input_vars[0] + " + " + p_input_vars[1] + ";\n"; @@ -1665,7 +1665,7 @@ String VisualShaderNodeVectorOp::get_output_port_name(int p_port) const { } String VisualShaderNodeVectorOp::generate_code(Shader::Mode p_mode, VisualShader::Type p_type, int p_id, const String *p_input_vars, const String *p_output_vars, bool p_for_preview) const { - String code = "\t" + p_output_vars[0] + " = "; + String code = " " + p_output_vars[0] + " = "; switch (op) { case OP_ADD: code += p_input_vars[0] + " + " + p_input_vars[1] + ";\n"; @@ -1783,64 +1783,64 @@ String VisualShaderNodeColorOp::generate_code(Shader::Mode p_mode, VisualShader: static const char *axisn[3] = { "x", "y", "z" }; switch (op) { case OP_SCREEN: { - code += "\t" + p_output_vars[0] + " = vec3(1.0) - (vec3(1.0) - " + p_input_vars[0] + ") * (vec3(1.0) - " + p_input_vars[1] + ");\n"; + code += " " + p_output_vars[0] + " = vec3(1.0) - (vec3(1.0) - " + p_input_vars[0] + ") * (vec3(1.0) - " + p_input_vars[1] + ");\n"; } break; case OP_DIFFERENCE: { - code += "\t" + p_output_vars[0] + " = abs(" + p_input_vars[0] + " - " + p_input_vars[1] + ");\n"; + code += " " + p_output_vars[0] + " = abs(" + p_input_vars[0] + " - " + p_input_vars[1] + ");\n"; } break; case OP_DARKEN: { - code += "\t" + p_output_vars[0] + " = min(" + p_input_vars[0] + ", " + p_input_vars[1] + ");\n"; + code += " " + p_output_vars[0] + " = min(" + p_input_vars[0] + ", " + p_input_vars[1] + ");\n"; } break; case OP_LIGHTEN: { - code += "\t" + p_output_vars[0] + " = max(" + p_input_vars[0] + ", " + p_input_vars[1] + ");\n"; + code += " " + p_output_vars[0] + " = max(" + p_input_vars[0] + ", " + p_input_vars[1] + ");\n"; } break; case OP_OVERLAY: { for (int i = 0; i < 3; i++) { - code += "\t{\n"; - code += "\t\tfloat base = " + p_input_vars[0] + "." + axisn[i] + ";\n"; - code += "\t\tfloat blend = " + p_input_vars[1] + "." + axisn[i] + ";\n"; - code += "\t\tif (base < 0.5) {\n"; - code += "\t\t\t" + p_output_vars[0] + "." + axisn[i] + " = 2.0 * base * blend;\n"; - code += "\t\t} else {\n"; - code += "\t\t\t" + p_output_vars[0] + "." + axisn[i] + " = 1.0 - 2.0 * (1.0 - blend) * (1.0 - base);\n"; - code += "\t\t}\n"; - code += "\t}\n"; + code += " {\n"; + code += " float base = " + p_input_vars[0] + "." + axisn[i] + ";\n"; + code += " float blend = " + p_input_vars[1] + "." + axisn[i] + ";\n"; + code += " if (base < 0.5) {\n"; + code += " " + p_output_vars[0] + "." + axisn[i] + " = 2.0 * base * blend;\n"; + code += " } else {\n"; + code += " " + p_output_vars[0] + "." + axisn[i] + " = 1.0 - 2.0 * (1.0 - blend) * (1.0 - base);\n"; + code += " }\n"; + code += " }\n"; } } break; case OP_DODGE: { - code += "\t" + p_output_vars[0] + " = (" + p_input_vars[0] + ") / (vec3(1.0) - " + p_input_vars[1] + ");\n"; + code += " " + p_output_vars[0] + " = (" + p_input_vars[0] + ") / (vec3(1.0) - " + p_input_vars[1] + ");\n"; } break; case OP_BURN: { - code += "\t" + p_output_vars[0] + " = vec3(1.0) - (vec3(1.0) - " + p_input_vars[0] + ") / (" + p_input_vars[1] + ");\n"; + code += " " + p_output_vars[0] + " = vec3(1.0) - (vec3(1.0) - " + p_input_vars[0] + ") / (" + p_input_vars[1] + ");\n"; } break; case OP_SOFT_LIGHT: { for (int i = 0; i < 3; i++) { - code += "\t{\n"; - code += "\t\tfloat base = " + p_input_vars[0] + "." + axisn[i] + ";\n"; - code += "\t\tfloat blend = " + p_input_vars[1] + "." + axisn[i] + ";\n"; - code += "\t\tif (base < 0.5) {\n"; - code += "\t\t\t" + p_output_vars[0] + "." + axisn[i] + " = (base * (blend + 0.5));\n"; - code += "\t\t} else {\n"; - code += "\t\t\t" + p_output_vars[0] + "." + axisn[i] + " = (1.0 - (1.0 - base) * (1.0 - (blend - 0.5)));\n"; - code += "\t\t}\n"; - code += "\t}\n"; + code += " {\n"; + code += " float base = " + p_input_vars[0] + "." + axisn[i] + ";\n"; + code += " float blend = " + p_input_vars[1] + "." + axisn[i] + ";\n"; + code += " if (base < 0.5) {\n"; + code += " " + p_output_vars[0] + "." + axisn[i] + " = (base * (blend + 0.5));\n"; + code += " } else {\n"; + code += " " + p_output_vars[0] + "." + axisn[i] + " = (1.0 - (1.0 - base) * (1.0 - (blend - 0.5)));\n"; + code += " }\n"; + code += " }\n"; } } break; case OP_HARD_LIGHT: { for (int i = 0; i < 3; i++) { - code += "\t{\n"; - code += "\t\tfloat base = " + p_input_vars[0] + "." + axisn[i] + ";\n"; - code += "\t\tfloat blend = " + p_input_vars[1] + "." + axisn[i] + ";\n"; - code += "\t\tif (base < 0.5) {\n"; - code += "\t\t\t" + p_output_vars[0] + "." + axisn[i] + " = (base * (2.0 * blend));\n"; - code += "\t\t} else {\n"; - code += "\t\t\t" + p_output_vars[0] + "." + axisn[i] + " = (1.0 - (1.0 - base) * (1.0 - 2.0 * (blend - 0.5)));\n"; - code += "\t\t}\n"; - code += "\t}\n"; + code += " {\n"; + code += " float base = " + p_input_vars[0] + "." + axisn[i] + ";\n"; + code += " float blend = " + p_input_vars[1] + "." + axisn[i] + ";\n"; + code += " if (base < 0.5) {\n"; + code += " " + p_output_vars[0] + "." + axisn[i] + " = (base * (2.0 * blend));\n"; + code += " } else {\n"; + code += " " + p_output_vars[0] + "." + axisn[i] + " = (1.0 - (1.0 - base) * (1.0 - 2.0 * (blend - 0.5)));\n"; + code += " }\n"; + code += " }\n"; } } break; @@ -1947,13 +1947,13 @@ String VisualShaderNodeTransformMult::get_output_port_name(int p_port) const { String VisualShaderNodeTransformMult::generate_code(Shader::Mode p_mode, VisualShader::Type p_type, int p_id, const String *p_input_vars, const String *p_output_vars, bool p_for_preview) const { if (op == OP_AxB) { - return "\t" + p_output_vars[0] + " = " + p_input_vars[0] + " * " + p_input_vars[1] + ";\n"; + return " " + p_output_vars[0] + " = " + p_input_vars[0] + " * " + p_input_vars[1] + ";\n"; } else if (op == OP_BxA) { - return "\t" + p_output_vars[0] + " = " + p_input_vars[1] + " * " + p_input_vars[0] + ";\n"; + return " " + p_output_vars[0] + " = " + p_input_vars[1] + " * " + p_input_vars[0] + ";\n"; } else if (op == OP_AxB_COMP) { - return "\t" + p_output_vars[0] + " = matrixCompMult(" + p_input_vars[0] + ", " + p_input_vars[1] + ");\n"; + return " " + p_output_vars[0] + " = matrixCompMult(" + p_input_vars[0] + ", " + p_input_vars[1] + ");\n"; } else { - return "\t" + p_output_vars[0] + " = matrixCompMult(" + p_input_vars[1] + ", " + p_input_vars[0] + ");\n"; + return " " + p_output_vars[0] + " = matrixCompMult(" + p_input_vars[1] + ", " + p_input_vars[0] + ");\n"; } } @@ -2021,13 +2021,13 @@ String VisualShaderNodeTransformVecMult::get_output_port_name(int p_port) const String VisualShaderNodeTransformVecMult::generate_code(Shader::Mode p_mode, VisualShader::Type p_type, int p_id, const String *p_input_vars, const String *p_output_vars, bool p_for_preview) const { if (op == OP_AxB) { - return "\t" + p_output_vars[0] + " = (" + p_input_vars[0] + " * vec4(" + p_input_vars[1] + ", 1.0)).xyz;\n"; + return " " + p_output_vars[0] + " = (" + p_input_vars[0] + " * vec4(" + p_input_vars[1] + ", 1.0)).xyz;\n"; } else if (op == OP_BxA) { - return "\t" + p_output_vars[0] + " = (vec4(" + p_input_vars[1] + ", 1.0) * " + p_input_vars[0] + ").xyz;\n"; + return " " + p_output_vars[0] + " = (vec4(" + p_input_vars[1] + ", 1.0) * " + p_input_vars[0] + ").xyz;\n"; } else if (op == OP_3x3_AxB) { - return "\t" + p_output_vars[0] + " = (" + p_input_vars[0] + " * vec4(" + p_input_vars[1] + ", 0.0)).xyz;\n"; + return " " + p_output_vars[0] + " = (" + p_input_vars[0] + " * vec4(" + p_input_vars[1] + ", 0.0)).xyz;\n"; } else { - return "\t" + p_output_vars[0] + " = (vec4(" + p_input_vars[1] + ", 0.0) * " + p_input_vars[0] + ").xyz;\n"; + return " " + p_output_vars[0] + " = (vec4(" + p_input_vars[1] + ", 0.0) * " + p_input_vars[0] + ").xyz;\n"; } } @@ -2129,7 +2129,7 @@ String VisualShaderNodeFloatFunc::generate_code(Shader::Mode p_mode, VisualShade "1.0 - $" }; - return "\t" + p_output_vars[0] + " = " + String(scalar_func_id[func]).replace("$", p_input_vars[0]) + ";\n"; + return " " + p_output_vars[0] + " = " + String(scalar_func_id[func]).replace("$", p_input_vars[0]) + ";\n"; } void VisualShaderNodeFloatFunc::set_function(Function p_func) { @@ -2228,7 +2228,7 @@ String VisualShaderNodeIntFunc::generate_code(Shader::Mode p_mode, VisualShader: "sign($)" }; - return "\t" + p_output_vars[0] + " = " + String(int_func_id[func]).replace("$", p_input_vars[0]) + ";\n"; + return " " + p_output_vars[0] + " = " + String(int_func_id[func]).replace("$", p_input_vars[0]) + ";\n"; } void VisualShaderNodeIntFunc::set_function(Function p_func) { @@ -2333,25 +2333,25 @@ String VisualShaderNodeVectorFunc::generate_code(Shader::Mode p_mode, VisualShad String code; if (func == FUNC_RGB2HSV) { - code += "\t{\n"; - code += "\t\tvec3 c = " + p_input_vars[0] + ";\n"; - code += "\t\tvec4 K = vec4(0.0, -1.0 / 3.0, 2.0 / 3.0, -1.0);\n"; - code += "\t\tvec4 p = mix(vec4(c.bg, K.wz), vec4(c.gb, K.xy), step(c.b, c.g));\n"; - code += "\t\tvec4 q = mix(vec4(p.xyw, c.r), vec4(c.r, p.yzx), step(p.x, c.r));\n"; - code += "\t\tfloat d = q.x - min(q.w, q.y);\n"; - code += "\t\tfloat e = 1.0e-10;\n"; - code += "\t\t" + p_output_vars[0] + " = vec3(abs(q.z + (q.w - q.y) / (6.0 * d + e)), d / (q.x + e), q.x);\n"; - code += "\t}\n"; + code += " {\n"; + code += " vec3 c = " + p_input_vars[0] + ";\n"; + code += " vec4 K = vec4(0.0, -1.0 / 3.0, 2.0 / 3.0, -1.0);\n"; + code += " vec4 p = mix(vec4(c.bg, K.wz), vec4(c.gb, K.xy), step(c.b, c.g));\n"; + code += " vec4 q = mix(vec4(p.xyw, c.r), vec4(c.r, p.yzx), step(p.x, c.r));\n"; + code += " float d = q.x - min(q.w, q.y);\n"; + code += " float e = 1.0e-10;\n"; + code += " " + p_output_vars[0] + " = vec3(abs(q.z + (q.w - q.y) / (6.0 * d + e)), d / (q.x + e), q.x);\n"; + code += " }\n"; } else if (func == FUNC_HSV2RGB) { - code += "\t{\n"; - code += "\t\tvec3 c = " + p_input_vars[0] + ";\n"; - code += "\t\tvec4 K = vec4(1.0, 2.0 / 3.0, 1.0 / 3.0, 3.0);\n"; - code += "\t\tvec3 p = abs(fract(c.xxx + K.xyz) * 6.0 - K.www);\n"; - code += "\t\t" + p_output_vars[0] + " = c.z * mix(K.xxx, clamp(p - K.xxx, 0.0, 1.0), c.y);\n"; - code += "\t}\n"; + code += " {\n"; + code += " vec3 c = " + p_input_vars[0] + ";\n"; + code += " vec4 K = vec4(1.0, 2.0 / 3.0, 1.0 / 3.0, 3.0);\n"; + code += " vec3 p = abs(fract(c.xxx + K.xyz) * 6.0 - K.www);\n"; + code += " " + p_output_vars[0] + " = c.z * mix(K.xxx, clamp(p - K.xxx, 0.0, 1.0), c.y);\n"; + code += " }\n"; } else { - code += "\t" + p_output_vars[0] + " = " + String(vec_func_id[func]).replace("$", p_input_vars[0]) + ";\n"; + code += " " + p_output_vars[0] + " = " + String(vec_func_id[func]).replace("$", p_input_vars[0]) + ";\n"; } return code; @@ -2461,22 +2461,22 @@ String VisualShaderNodeColorFunc::generate_code(Shader::Mode p_mode, VisualShade switch (func) { case FUNC_GRAYSCALE: - code += "\t{\n"; - code += "\t\tvec3 c = " + p_input_vars[0] + ";\n"; - code += "\t\tfloat max1 = max(c.r, c.g);\n"; - code += "\t\tfloat max2 = max(max1, c.b);\n"; - code += "\t\tfloat max3 = max(max1, max2);\n"; - code += "\t\t" + p_output_vars[0] + " = vec3(max3, max3, max3);\n"; - code += "\t}\n"; + code += " {\n"; + code += " vec3 c = " + p_input_vars[0] + ";\n"; + code += " float max1 = max(c.r, c.g);\n"; + code += " float max2 = max(max1, c.b);\n"; + code += " float max3 = max(max1, max2);\n"; + code += " " + p_output_vars[0] + " = vec3(max3, max3, max3);\n"; + code += " }\n"; break; case FUNC_SEPIA: - code += "\t{\n"; - code += "\t\tvec3 c = " + p_input_vars[0] + ";\n"; - code += "\t\tfloat r = (c.r * .393) + (c.g *.769) + (c.b * .189);\n"; - code += "\t\tfloat g = (c.r * .349) + (c.g *.686) + (c.b * .168);\n"; - code += "\t\tfloat b = (c.r * .272) + (c.g *.534) + (c.b * .131);\n"; - code += "\t\t" + p_output_vars[0] + " = vec3(r, g, b);\n"; - code += "\t}\n"; + code += " {\n"; + code += " vec3 c = " + p_input_vars[0] + ";\n"; + code += " float r = (c.r * .393) + (c.g *.769) + (c.b * .189);\n"; + code += " float g = (c.r * .349) + (c.g *.686) + (c.b * .168);\n"; + code += " float b = (c.r * .272) + (c.g *.534) + (c.b * .131);\n"; + code += " " + p_output_vars[0] + " = vec3(r, g, b);\n"; + code += " }\n"; break; } @@ -2550,7 +2550,7 @@ String VisualShaderNodeTransformFunc::generate_code(Shader::Mode p_mode, VisualS }; String code; - code += "\t" + p_output_vars[0] + " = " + String(funcs[func]).replace("$", p_input_vars[0]) + ";\n"; + code += " " + p_output_vars[0] + " = " + String(funcs[func]).replace("$", p_input_vars[0]) + ";\n"; return code; } @@ -2668,10 +2668,10 @@ String VisualShaderNodeUVFunc::generate_code(Shader::Mode p_mode, VisualShader:: switch (func) { case FUNC_PANNING: { - code += vformat("\t%s = fma(%s, %s, %s);\n", p_output_vars[0], offset_pivot, scale, uv); + code += vformat(" %s = fma(%s, %s, %s);\n", p_output_vars[0], offset_pivot, scale, uv); } break; case FUNC_SCALING: { - code += vformat("\t%s = fma((%s - %s), %s, %s);\n", p_output_vars[0], uv, offset_pivot, scale, offset_pivot); + code += vformat(" %s = fma((%s - %s), %s, %s);\n", p_output_vars[0], uv, offset_pivot, scale, offset_pivot); } break; case FUNC_MAX: break; @@ -2751,7 +2751,7 @@ String VisualShaderNodeDotProduct::get_output_port_name(int p_port) const { } String VisualShaderNodeDotProduct::generate_code(Shader::Mode p_mode, VisualShader::Type p_type, int p_id, const String *p_input_vars, const String *p_output_vars, bool p_for_preview) const { - return "\t" + p_output_vars[0] + " = dot(" + p_input_vars[0] + ", " + p_input_vars[1] + ");\n"; + return " " + p_output_vars[0] + " = dot(" + p_input_vars[0] + ", " + p_input_vars[1] + ");\n"; } VisualShaderNodeDotProduct::VisualShaderNodeDotProduct() { @@ -2790,7 +2790,7 @@ String VisualShaderNodeVectorLen::get_output_port_name(int p_port) const { } String VisualShaderNodeVectorLen::generate_code(Shader::Mode p_mode, VisualShader::Type p_type, int p_id, const String *p_input_vars, const String *p_output_vars, bool p_for_preview) const { - return "\t" + p_output_vars[0] + " = length(" + p_input_vars[0] + ");\n"; + return " " + p_output_vars[0] + " = length(" + p_input_vars[0] + ");\n"; } VisualShaderNodeVectorLen::VisualShaderNodeVectorLen() { @@ -2828,7 +2828,7 @@ String VisualShaderNodeDeterminant::get_output_port_name(int p_port) const { } String VisualShaderNodeDeterminant::generate_code(Shader::Mode p_mode, VisualShader::Type p_type, int p_id, const String *p_input_vars, const String *p_output_vars, bool p_for_preview) const { - return "\t" + p_output_vars[0] + " = determinant(" + p_input_vars[0] + ");\n"; + return " " + p_output_vars[0] + " = determinant(" + p_input_vars[0] + ");\n"; } VisualShaderNodeDeterminant::VisualShaderNodeDeterminant() { @@ -2873,7 +2873,7 @@ String VisualShaderNodeScalarDerivativeFunc::generate_code(Shader::Mode p_mode, }; String code; - code += "\t" + p_output_vars[0] + " = " + String(funcs[func]).replace("$", p_input_vars[0]) + ";\n"; + code += " " + p_output_vars[0] + " = " + String(funcs[func]).replace("$", p_input_vars[0]) + ";\n"; return code; } @@ -2945,7 +2945,7 @@ String VisualShaderNodeVectorDerivativeFunc::generate_code(Shader::Mode p_mode, }; String code; - code += "\t" + p_output_vars[0] + " = " + String(funcs[func]).replace("$", p_input_vars[0]) + ";\n"; + code += " " + p_output_vars[0] + " = " + String(funcs[func]).replace("$", p_input_vars[0]) + ";\n"; return code; } @@ -3033,7 +3033,7 @@ String VisualShaderNodeClamp::get_output_port_name(int p_port) const { } String VisualShaderNodeClamp::generate_code(Shader::Mode p_mode, VisualShader::Type p_type, int p_id, const String *p_input_vars, const String *p_output_vars, bool p_for_preview) const { - return "\t" + p_output_vars[0] + " = clamp(" + p_input_vars[0] + ", " + p_input_vars[1] + ", " + p_input_vars[2] + ");\n"; + return " " + p_output_vars[0] + " = clamp(" + p_input_vars[0] + ", " + p_input_vars[1] + ", " + p_input_vars[2] + ");\n"; } void VisualShaderNodeClamp::set_op_type(OpType p_op_type) { @@ -3132,7 +3132,7 @@ String VisualShaderNodeFaceForward::get_output_port_name(int p_port) const { } String VisualShaderNodeFaceForward::generate_code(Shader::Mode p_mode, VisualShader::Type p_type, int p_id, const String *p_input_vars, const String *p_output_vars, bool p_for_preview) const { - return "\t" + p_output_vars[0] + " = faceforward(" + p_input_vars[0] + ", " + p_input_vars[1] + ", " + p_input_vars[2] + ");\n"; + return " " + p_output_vars[0] + " = faceforward(" + p_input_vars[0] + ", " + p_input_vars[1] + ", " + p_input_vars[2] + ");\n"; } VisualShaderNodeFaceForward::VisualShaderNodeFaceForward() { @@ -3179,7 +3179,7 @@ String VisualShaderNodeOuterProduct::get_output_port_name(int p_port) const { } String VisualShaderNodeOuterProduct::generate_code(Shader::Mode p_mode, VisualShader::Type p_type, int p_id, const String *p_input_vars, const String *p_output_vars, bool p_for_preview) const { - return "\t" + p_output_vars[0] + " = outerProduct(vec4(" + p_input_vars[0] + ", 0.0), vec4(" + p_input_vars[1] + ", 0.0));\n"; + return " " + p_output_vars[0] + " = outerProduct(vec4(" + p_input_vars[0] + ", 0.0), vec4(" + p_input_vars[1] + ", 0.0));\n"; } VisualShaderNodeOuterProduct::VisualShaderNodeOuterProduct() { @@ -3283,7 +3283,7 @@ VisualShaderNodeStep::OpType VisualShaderNodeStep::get_op_type() const { } String VisualShaderNodeStep::generate_code(Shader::Mode p_mode, VisualShader::Type p_type, int p_id, const String *p_input_vars, const String *p_output_vars, bool p_for_preview) const { - return "\t" + p_output_vars[0] + " = step(" + p_input_vars[0] + ", " + p_input_vars[1] + ");\n"; + return " " + p_output_vars[0] + " = step(" + p_input_vars[0] + ", " + p_input_vars[1] + ");\n"; } Vector<StringName> VisualShaderNodeStep::get_editable_properties() const { @@ -3410,7 +3410,7 @@ VisualShaderNodeSmoothStep::OpType VisualShaderNodeSmoothStep::get_op_type() con } String VisualShaderNodeSmoothStep::generate_code(Shader::Mode p_mode, VisualShader::Type p_type, int p_id, const String *p_input_vars, const String *p_output_vars, bool p_for_preview) const { - return "\t" + p_output_vars[0] + " = smoothstep(" + p_input_vars[0] + ", " + p_input_vars[1] + ", " + p_input_vars[2] + ");\n"; + return " " + p_output_vars[0] + " = smoothstep(" + p_input_vars[0] + ", " + p_input_vars[1] + ", " + p_input_vars[2] + ");\n"; } Vector<StringName> VisualShaderNodeSmoothStep::get_editable_properties() const { @@ -3473,7 +3473,7 @@ String VisualShaderNodeVectorDistance::get_output_port_name(int p_port) const { } String VisualShaderNodeVectorDistance::generate_code(Shader::Mode p_mode, VisualShader::Type p_type, int p_id, const String *p_input_vars, const String *p_output_vars, bool p_for_preview) const { - return "\t" + p_output_vars[0] + " = distance(" + p_input_vars[0] + ", " + p_input_vars[1] + ");\n"; + return " " + p_output_vars[0] + " = distance(" + p_input_vars[0] + ", " + p_input_vars[1] + ");\n"; } VisualShaderNodeVectorDistance::VisualShaderNodeVectorDistance() { @@ -3523,7 +3523,7 @@ String VisualShaderNodeVectorRefract::get_output_port_name(int p_port) const { } String VisualShaderNodeVectorRefract::generate_code(Shader::Mode p_mode, VisualShader::Type p_type, int p_id, const String *p_input_vars, const String *p_output_vars, bool p_for_preview) const { - return "\t" + p_output_vars[0] + " = refract(" + p_input_vars[0] + ", " + p_input_vars[1] + ", " + p_input_vars[2] + ");\n"; + return " " + p_output_vars[0] + " = refract(" + p_input_vars[0] + ", " + p_input_vars[1] + ", " + p_input_vars[2] + ");\n"; } VisualShaderNodeVectorRefract::VisualShaderNodeVectorRefract() { @@ -3626,7 +3626,7 @@ VisualShaderNodeMix::OpType VisualShaderNodeMix::get_op_type() const { } String VisualShaderNodeMix::generate_code(Shader::Mode p_mode, VisualShader::Type p_type, int p_id, const String *p_input_vars, const String *p_output_vars, bool p_for_preview) const { - return "\t" + p_output_vars[0] + " = mix(" + p_input_vars[0] + ", " + p_input_vars[1] + ", " + p_input_vars[2] + ");\n"; + return " " + p_output_vars[0] + " = mix(" + p_input_vars[0] + ", " + p_input_vars[1] + ", " + p_input_vars[2] + ");\n"; } Vector<StringName> VisualShaderNodeMix::get_editable_properties() const { @@ -3690,7 +3690,7 @@ String VisualShaderNodeVectorCompose::get_output_port_name(int p_port) const { } String VisualShaderNodeVectorCompose::generate_code(Shader::Mode p_mode, VisualShader::Type p_type, int p_id, const String *p_input_vars, const String *p_output_vars, bool p_for_preview) const { - return "\t" + p_output_vars[0] + " = vec3(" + p_input_vars[0] + ", " + p_input_vars[1] + ", " + p_input_vars[2] + ");\n"; + return " " + p_output_vars[0] + " = vec3(" + p_input_vars[0] + ", " + p_input_vars[1] + ", " + p_input_vars[2] + ");\n"; } VisualShaderNodeVectorCompose::VisualShaderNodeVectorCompose() { @@ -3738,7 +3738,7 @@ String VisualShaderNodeTransformCompose::get_output_port_name(int p_port) const } String VisualShaderNodeTransformCompose::generate_code(Shader::Mode p_mode, VisualShader::Type p_type, int p_id, const String *p_input_vars, const String *p_output_vars, bool p_for_preview) const { - return "\t" + p_output_vars[0] + " = mat4(vec4(" + p_input_vars[0] + ", 0.0), vec4(" + p_input_vars[1] + ", 0.0), vec4(" + p_input_vars[2] + ", 0.0), vec4(" + p_input_vars[3] + ", 1.0));\n"; + return " " + p_output_vars[0] + " = mat4(vec4(" + p_input_vars[0] + ", 0.0), vec4(" + p_input_vars[1] + ", 0.0), vec4(" + p_input_vars[2] + ", 0.0), vec4(" + p_input_vars[3] + ", 1.0));\n"; } VisualShaderNodeTransformCompose::VisualShaderNodeTransformCompose() { @@ -3785,9 +3785,9 @@ String VisualShaderNodeVectorDecompose::get_output_port_name(int p_port) const { String VisualShaderNodeVectorDecompose::generate_code(Shader::Mode p_mode, VisualShader::Type p_type, int p_id, const String *p_input_vars, const String *p_output_vars, bool p_for_preview) const { String code; - code += "\t" + p_output_vars[0] + " = " + p_input_vars[0] + ".x;\n"; - code += "\t" + p_output_vars[1] + " = " + p_input_vars[0] + ".y;\n"; - code += "\t" + p_output_vars[2] + " = " + p_input_vars[0] + ".z;\n"; + code += " " + p_output_vars[0] + " = " + p_input_vars[0] + ".x;\n"; + code += " " + p_output_vars[1] + " = " + p_input_vars[0] + ".y;\n"; + code += " " + p_output_vars[2] + " = " + p_input_vars[0] + ".z;\n"; return code; } @@ -3835,10 +3835,10 @@ String VisualShaderNodeTransformDecompose::get_output_port_name(int p_port) cons String VisualShaderNodeTransformDecompose::generate_code(Shader::Mode p_mode, VisualShader::Type p_type, int p_id, const String *p_input_vars, const String *p_output_vars, bool p_for_preview) const { String code; - code += "\t" + p_output_vars[0] + " = " + p_input_vars[0] + "[0].xyz;\n"; - code += "\t" + p_output_vars[1] + " = " + p_input_vars[0] + "[1].xyz;\n"; - code += "\t" + p_output_vars[2] + " = " + p_input_vars[0] + "[2].xyz;\n"; - code += "\t" + p_output_vars[3] + " = " + p_input_vars[0] + "[3].xyz;\n"; + code += " " + p_output_vars[0] + " = " + p_input_vars[0] + "[0].xyz;\n"; + code += " " + p_output_vars[1] + " = " + p_input_vars[0] + "[1].xyz;\n"; + code += " " + p_output_vars[2] + " = " + p_input_vars[0] + "[2].xyz;\n"; + code += " " + p_output_vars[3] + " = " + p_input_vars[0] + "[3].xyz;\n"; return code; } @@ -3893,7 +3893,7 @@ String VisualShaderNodeFloatUniform::generate_global(Shader::Mode p_mode, Visual } String VisualShaderNodeFloatUniform::generate_code(Shader::Mode p_mode, VisualShader::Type p_type, int p_id, const String *p_input_vars, const String *p_output_vars, bool p_for_preview) const { - return "\t" + p_output_vars[0] + " = " + get_uniform_name() + ";\n"; + return " " + p_output_vars[0] + " = " + get_uniform_name() + ";\n"; } bool VisualShaderNodeFloatUniform::is_show_prop_names() const { @@ -4064,7 +4064,7 @@ String VisualShaderNodeIntUniform::generate_global(Shader::Mode p_mode, VisualSh } String VisualShaderNodeIntUniform::generate_code(Shader::Mode p_mode, VisualShader::Type p_type, int p_id, const String *p_input_vars, const String *p_output_vars, bool p_for_preview) const { - return "\t" + p_output_vars[0] + " = " + get_uniform_name() + ";\n"; + return " " + p_output_vars[0] + " = " + get_uniform_name() + ";\n"; } bool VisualShaderNodeIntUniform::is_show_prop_names() const { @@ -4250,7 +4250,7 @@ String VisualShaderNodeBooleanUniform::generate_global(Shader::Mode p_mode, Visu } String VisualShaderNodeBooleanUniform::generate_code(Shader::Mode p_mode, VisualShader::Type p_type, int p_id, const String *p_input_vars, const String *p_output_vars, bool p_for_preview) const { - return "\t" + p_output_vars[0] + " = " + get_uniform_name() + ";\n"; + return " " + p_output_vars[0] + " = " + get_uniform_name() + ";\n"; } bool VisualShaderNodeBooleanUniform::is_show_prop_names() const { @@ -4350,8 +4350,8 @@ String VisualShaderNodeColorUniform::generate_global(Shader::Mode p_mode, Visual } String VisualShaderNodeColorUniform::generate_code(Shader::Mode p_mode, VisualShader::Type p_type, int p_id, const String *p_input_vars, const String *p_output_vars, bool p_for_preview) const { - String code = "\t" + p_output_vars[0] + " = " + get_uniform_name() + ".rgb;\n"; - code += "\t" + p_output_vars[1] + " = " + get_uniform_name() + ".a;\n"; + String code = " " + p_output_vars[0] + " = " + get_uniform_name() + ".rgb;\n"; + code += " " + p_output_vars[1] + " = " + get_uniform_name() + ".a;\n"; return code; } @@ -4448,7 +4448,7 @@ String VisualShaderNodeVec3Uniform::generate_global(Shader::Mode p_mode, VisualS } String VisualShaderNodeVec3Uniform::generate_code(Shader::Mode p_mode, VisualShader::Type p_type, int p_id, const String *p_input_vars, const String *p_output_vars, bool p_for_preview) const { - return "\t" + p_output_vars[0] + " = " + get_uniform_name() + ";\n"; + return " " + p_output_vars[0] + " = " + get_uniform_name() + ";\n"; } void VisualShaderNodeVec3Uniform::_bind_methods() { @@ -4552,7 +4552,7 @@ String VisualShaderNodeTransformUniform::generate_global(Shader::Mode p_mode, Vi } String VisualShaderNodeTransformUniform::generate_code(Shader::Mode p_mode, VisualShader::Type p_type, int p_id, const String *p_input_vars, const String *p_output_vars, bool p_for_preview) const { - return "\t" + p_output_vars[0] + " = " + get_uniform_name() + ";\n"; + return " " + p_output_vars[0] + " = " + get_uniform_name() + ";\n"; } void VisualShaderNodeTransformUniform::_bind_methods() { @@ -4684,23 +4684,23 @@ String VisualShaderNodeTextureUniform::generate_code(Shader::Mode p_mode, Visual } String id = get_uniform_name(); - String code = "\t{\n"; + String code = " {\n"; if (p_input_vars[0] == String()) { // Use UV by default. if (p_input_vars[1] == String()) { - code += "\t\tvec4 n_tex_read = texture(" + id + ", " + default_uv + ");\n"; + code += " vec4 n_tex_read = texture(" + id + ", " + default_uv + ");\n"; } else { - code += "\t\tvec4 n_tex_read = textureLod(" + id + ", " + default_uv + ", " + p_input_vars[1] + ");\n"; + code += " vec4 n_tex_read = textureLod(" + id + ", " + default_uv + ", " + p_input_vars[1] + ");\n"; } } else if (p_input_vars[1] == String()) { //no lod - code += "\t\tvec4 n_tex_read = texture(" + id + ", " + p_input_vars[0] + ".xy);\n"; + code += " vec4 n_tex_read = texture(" + id + ", " + p_input_vars[0] + ".xy);\n"; } else { - code += "\t\tvec4 n_tex_read = textureLod(" + id + ", " + p_input_vars[0] + ".xy, " + p_input_vars[1] + ");\n"; + code += " vec4 n_tex_read = textureLod(" + id + ", " + p_input_vars[0] + ".xy, " + p_input_vars[1] + ");\n"; } - code += "\t\t" + p_output_vars[0] + " = n_tex_read.rgb;\n"; - code += "\t\t" + p_output_vars[1] + " = n_tex_read.a;\n"; - code += "\t}\n"; + code += " " + p_output_vars[0] + " = n_tex_read.rgb;\n"; + code += " " + p_output_vars[1] + " = n_tex_read.a;\n"; + code += " }\n"; return code; } @@ -4805,20 +4805,20 @@ String VisualShaderNodeTextureUniformTriplanar::generate_global_per_node(Shader: String code; code += "// TRIPLANAR FUNCTION GLOBAL CODE\n"; - code += "\tvec4 triplanar_texture(sampler2D p_sampler, vec3 p_weights, vec3 p_triplanar_pos) {\n"; - code += "\t\tvec4 samp = vec4(0.0);\n"; - code += "\t\tsamp += texture(p_sampler, p_triplanar_pos.xy) * p_weights.z;\n"; - code += "\t\tsamp += texture(p_sampler, p_triplanar_pos.xz) * p_weights.y;\n"; - code += "\t\tsamp += texture(p_sampler, p_triplanar_pos.zy * vec2(-1.0, 1.0)) * p_weights.x;\n"; - code += "\t\treturn samp;\n"; - code += "\t}\n"; + code += " vec4 triplanar_texture(sampler2D p_sampler, vec3 p_weights, vec3 p_triplanar_pos) {\n"; + code += " vec4 samp = vec4(0.0);\n"; + code += " samp += texture(p_sampler, p_triplanar_pos.xy) * p_weights.z;\n"; + code += " samp += texture(p_sampler, p_triplanar_pos.xz) * p_weights.y;\n"; + code += " samp += texture(p_sampler, p_triplanar_pos.zy * vec2(-1.0, 1.0)) * p_weights.x;\n"; + code += " return samp;\n"; + code += " }\n"; code += "\n"; - code += "\tuniform vec3 triplanar_scale = vec3(1.0, 1.0, 1.0);\n"; - code += "\tuniform vec3 triplanar_offset;\n"; - code += "\tuniform float triplanar_sharpness = 0.5;\n"; + code += " uniform vec3 triplanar_scale = vec3(1.0, 1.0, 1.0);\n"; + code += " uniform vec3 triplanar_offset;\n"; + code += " uniform float triplanar_sharpness = 0.5;\n"; code += "\n"; - code += "\tvarying vec3 triplanar_power_normal;\n"; - code += "\tvarying vec3 triplanar_pos;\n"; + code += " varying vec3 triplanar_power_normal;\n"; + code += " varying vec3 triplanar_pos;\n"; return code; } @@ -4827,11 +4827,11 @@ String VisualShaderNodeTextureUniformTriplanar::generate_global_per_func(Shader: String code; if (p_type == VisualShader::TYPE_VERTEX) { - code += "\t// TRIPLANAR FUNCTION VERTEX CODE\n"; - code += "\t\ttriplanar_power_normal = pow(abs(NORMAL), vec3(triplanar_sharpness));\n"; - code += "\t\ttriplanar_power_normal /= dot(triplanar_power_normal, vec3(1.0));\n"; - code += "\t\ttriplanar_pos = VERTEX * triplanar_scale + triplanar_offset;\n"; - code += "\t\ttriplanar_pos *= vec3(1.0, -1.0, 1.0);\n"; + code += " // TRIPLANAR FUNCTION VERTEX CODE\n"; + code += " triplanar_power_normal = pow(abs(NORMAL), vec3(triplanar_sharpness));\n"; + code += " triplanar_power_normal /= dot(triplanar_power_normal, vec3(1.0));\n"; + code += " triplanar_pos = VERTEX * triplanar_scale + triplanar_offset;\n"; + code += " triplanar_pos *= vec3(1.0, -1.0, 1.0);\n"; } return code; @@ -4839,21 +4839,21 @@ String VisualShaderNodeTextureUniformTriplanar::generate_global_per_func(Shader: String VisualShaderNodeTextureUniformTriplanar::generate_code(Shader::Mode p_mode, VisualShader::Type p_type, int p_id, const String *p_input_vars, const String *p_output_vars, bool p_for_preview) const { String id = get_uniform_name(); - String code = "\t{\n"; + String code = " {\n"; if (p_input_vars[0] == String() && p_input_vars[1] == String()) { - code += "\t\tvec4 n_tex_read = triplanar_texture(" + id + ", triplanar_power_normal, triplanar_pos);\n"; + code += " vec4 n_tex_read = triplanar_texture(" + id + ", triplanar_power_normal, triplanar_pos);\n"; } else if (p_input_vars[0] != String() && p_input_vars[1] == String()) { - code += "\t\tvec4 n_tex_read = triplanar_texture(" + id + ", " + p_input_vars[0] + ", triplanar_pos);\n"; + code += " vec4 n_tex_read = triplanar_texture(" + id + ", " + p_input_vars[0] + ", triplanar_pos);\n"; } else if (p_input_vars[0] == String() && p_input_vars[1] != String()) { - code += "\t\tvec4 n_tex_read = triplanar_texture(" + id + ", triplanar_power_normal, " + p_input_vars[1] + ");\n"; + code += " vec4 n_tex_read = triplanar_texture(" + id + ", triplanar_power_normal, " + p_input_vars[1] + ");\n"; } else { - code += "\t\tvec4 n_tex_read = triplanar_texture(" + id + ", " + p_input_vars[0] + ", " + p_input_vars[1] + ");\n"; + code += " vec4 n_tex_read = triplanar_texture(" + id + ", " + p_input_vars[0] + ", " + p_input_vars[1] + ");\n"; } - code += "\t\t" + p_output_vars[0] + " = n_tex_read.rgb;\n"; - code += "\t\t" + p_output_vars[1] + " = n_tex_read.a;\n"; - code += "\t}\n"; + code += " " + p_output_vars[0] + " = n_tex_read.rgb;\n"; + code += " " + p_output_vars[1] + " = n_tex_read.a;\n"; + code += " }\n"; return code; } @@ -5130,18 +5130,18 @@ String VisualShaderNodeIf::get_output_port_name(int p_port) const { String VisualShaderNodeIf::generate_code(Shader::Mode p_mode, VisualShader::Type p_type, int p_id, const String *p_input_vars, const String *p_output_vars, bool p_for_preview) const { String code; - code += "\tif(abs(" + p_input_vars[0] + " - " + p_input_vars[1] + ") < " + p_input_vars[2] + ")\n"; // abs(a - b) < tolerance eg. a == b - code += "\t{\n"; - code += "\t\t" + p_output_vars[0] + " = " + p_input_vars[3] + ";\n"; - code += "\t}\n"; - code += "\telse if(" + p_input_vars[0] + " < " + p_input_vars[1] + ")\n"; // a < b - code += "\t{\n"; - code += "\t\t" + p_output_vars[0] + " = " + p_input_vars[5] + ";\n"; - code += "\t}\n"; - code += "\telse\n"; // a > b (or a >= b if abs(a - b) < tolerance is false) - code += "\t{\n"; - code += "\t\t" + p_output_vars[0] + " = " + p_input_vars[4] + ";\n"; - code += "\t}\n"; + code += " if(abs(" + p_input_vars[0] + " - " + p_input_vars[1] + ") < " + p_input_vars[2] + ")\n"; // abs(a - b) < tolerance eg. a == b + code += " {\n"; + code += " " + p_output_vars[0] + " = " + p_input_vars[3] + ";\n"; + code += " }\n"; + code += " else if(" + p_input_vars[0] + " < " + p_input_vars[1] + ")\n"; // a < b + code += " {\n"; + code += " " + p_output_vars[0] + " = " + p_input_vars[5] + ";\n"; + code += " }\n"; + code += " else\n"; // a > b (or a >= b if abs(a - b) < tolerance is false) + code += " {\n"; + code += " " + p_output_vars[0] + " = " + p_input_vars[4] + ";\n"; + code += " }\n"; return code; } @@ -5282,14 +5282,14 @@ void VisualShaderNodeSwitch::_bind_methods() { // static String VisualShaderNodeSwitch::generate_code(Shader::Mode p_mode, VisualShader::Type p_type, int p_id, const String *p_input_vars, const String *p_output_vars, bool p_for_preview) const { String code; - code += "\tif(" + p_input_vars[0] + ")\n"; - code += "\t{\n"; - code += "\t\t" + p_output_vars[0] + " = " + p_input_vars[1] + ";\n"; - code += "\t}\n"; - code += "\telse\n"; - code += "\t{\n"; - code += "\t\t" + p_output_vars[0] + " = " + p_input_vars[2] + ";\n"; - code += "\t}\n"; + code += " if(" + p_input_vars[0] + ")\n"; + code += " {\n"; + code += " " + p_output_vars[0] + " = " + p_input_vars[1] + ";\n"; + code += " }\n"; + code += " else\n"; + code += " {\n"; + code += " " + p_output_vars[0] + " = " + p_input_vars[2] + ";\n"; + code += " }\n"; return code; } @@ -5374,12 +5374,12 @@ String VisualShaderNodeFresnel::generate_code(Shader::Mode p_mode, VisualShader: } if (is_input_port_connected(2)) { - return "\t" + p_output_vars[0] + " = " + p_input_vars[2] + " ? (pow(clamp(dot(" + normal + ", " + view + "), 0.0, 1.0), " + p_input_vars[3] + ")) : (pow(1.0 - clamp(dot(" + normal + ", " + view + "), 0.0, 1.0), " + p_input_vars[3] + "));\n"; + return " " + p_output_vars[0] + " = " + p_input_vars[2] + " ? (pow(clamp(dot(" + normal + ", " + view + "), 0.0, 1.0), " + p_input_vars[3] + ")) : (pow(1.0 - clamp(dot(" + normal + ", " + view + "), 0.0, 1.0), " + p_input_vars[3] + "));\n"; } else { if (get_input_port_default_value(2)) { - return "\t" + p_output_vars[0] + " = pow(clamp(dot(" + normal + ", " + view + "), 0.0, 1.0), " + p_input_vars[3] + ");\n"; + return " " + p_output_vars[0] + " = pow(clamp(dot(" + normal + ", " + view + "), 0.0, 1.0), " + p_input_vars[3] + ");\n"; } else { - return "\t" + p_output_vars[0] + " = pow(1.0 - clamp(dot(" + normal + ", " + view + "), 0.0, 1.0), " + p_input_vars[3] + ");\n"; + return " " + p_output_vars[0] + " = pow(1.0 - clamp(dot(" + normal + ", " + view + "), 0.0, 1.0), " + p_input_vars[3] + ");\n"; } } } @@ -5435,7 +5435,7 @@ String VisualShaderNodeIs::generate_code(Shader::Mode p_mode, VisualShader::Type }; String code; - code += "\t" + p_output_vars[0] + " = " + String(funcs[func]).replace("$", p_input_vars[0]) + ";\n"; + code += " " + p_output_vars[0] + " = " + String(funcs[func]).replace("$", p_input_vars[0]) + ";\n"; return code; } @@ -5562,37 +5562,37 @@ String VisualShaderNodeCompare::generate_code(Shader::Mode p_mode, VisualShader: switch (ctype) { case CTYPE_SCALAR: if (func == FUNC_EQUAL) { - code += "\t" + p_output_vars[0] + " = (abs(" + p_input_vars[0] + " - " + p_input_vars[1] + ") < " + p_input_vars[2] + ");"; + code += " " + p_output_vars[0] + " = (abs(" + p_input_vars[0] + " - " + p_input_vars[1] + ") < " + p_input_vars[2] + ");"; } else if (func == FUNC_NOT_EQUAL) { - code += "\t" + p_output_vars[0] + " = !(abs(" + p_input_vars[0] + " - " + p_input_vars[1] + ") < " + p_input_vars[2] + ");"; + code += " " + p_output_vars[0] + " = !(abs(" + p_input_vars[0] + " - " + p_input_vars[1] + ") < " + p_input_vars[2] + ");"; } else { - code += "\t" + p_output_vars[0] + " = " + (p_input_vars[0] + " $ " + p_input_vars[1]).replace("$", ops[func]) + ";\n"; + code += " " + p_output_vars[0] + " = " + (p_input_vars[0] + " $ " + p_input_vars[1]).replace("$", ops[func]) + ";\n"; } break; case CTYPE_SCALAR_INT: - code += "\t" + p_output_vars[0] + " = " + (p_input_vars[0] + " $ " + p_input_vars[1]).replace("$", ops[func]) + ";\n"; + code += " " + p_output_vars[0] + " = " + (p_input_vars[0] + " $ " + p_input_vars[1]).replace("$", ops[func]) + ";\n"; break; case CTYPE_VECTOR: - code += "\t{\n"; - code += "\t\tbvec3 _bv = " + String(funcs[func]).replace("$", p_input_vars[0] + ", " + p_input_vars[1]) + ";\n"; - code += "\t\t" + p_output_vars[0] + " = " + String(conds[condition]).replace("$", "_bv") + ";\n"; - code += "\t}\n"; + code += " {\n"; + code += " bvec3 _bv = " + String(funcs[func]).replace("$", p_input_vars[0] + ", " + p_input_vars[1]) + ";\n"; + code += " " + p_output_vars[0] + " = " + String(conds[condition]).replace("$", "_bv") + ";\n"; + code += " }\n"; break; case CTYPE_BOOLEAN: if (func > FUNC_NOT_EQUAL) { - return "\t" + p_output_vars[0] + " = false;\n"; + return " " + p_output_vars[0] + " = false;\n"; } - code += "\t" + p_output_vars[0] + " = " + (p_input_vars[0] + " $ " + p_input_vars[1]).replace("$", ops[func]) + ";\n"; + code += " " + p_output_vars[0] + " = " + (p_input_vars[0] + " $ " + p_input_vars[1]).replace("$", ops[func]) + ";\n"; break; case CTYPE_TRANSFORM: if (func > FUNC_NOT_EQUAL) { - return "\t" + p_output_vars[0] + " = false;\n"; + return " " + p_output_vars[0] + " = false;\n"; } - code += "\t" + p_output_vars[0] + " = " + (p_input_vars[0] + " $ " + p_input_vars[1]).replace("$", ops[func]) + ";\n"; + code += " " + p_output_vars[0] + " = " + (p_input_vars[0] + " $ " + p_input_vars[1]).replace("$", ops[func]) + ";\n"; break; default: @@ -5748,7 +5748,7 @@ String VisualShaderNodeMultiplyAdd::get_output_port_name(int p_port) const { } String VisualShaderNodeMultiplyAdd::generate_code(Shader::Mode p_mode, VisualShader::Type p_type, int p_id, const String *p_input_vars, const String *p_output_vars, bool p_for_preview) const { - return "\t" + p_output_vars[0] + " = fma(" + p_input_vars[0] + ", " + p_input_vars[1] + ", " + p_input_vars[2] + ");\n"; + return " " + p_output_vars[0] + " = fma(" + p_input_vars[0] + ", " + p_input_vars[1] + ", " + p_input_vars[2] + ");\n"; } void VisualShaderNodeMultiplyAdd::set_op_type(OpType p_op_type) { @@ -5836,34 +5836,34 @@ String VisualShaderNodeBillboard::generate_code(Shader::Mode p_mode, VisualShade switch (billboard_type) { case BILLBOARD_TYPE_ENABLED: - code += "\t{\n"; - code += "\t\tmat4 __mvm = INV_CAMERA_MATRIX * mat4(CAMERA_MATRIX[0], CAMERA_MATRIX[1], CAMERA_MATRIX[2], WORLD_MATRIX[3]);\n"; + code += " {\n"; + code += " mat4 __mvm = INV_CAMERA_MATRIX * mat4(CAMERA_MATRIX[0], CAMERA_MATRIX[1], CAMERA_MATRIX[2], WORLD_MATRIX[3]);\n"; if (keep_scale) { - code += "\t\t__mvm = __mvm * mat4(vec4(length(WORLD_MATRIX[0].xyz), 0.0, 0.0, 0.0), vec4(0.0, length(WORLD_MATRIX[1].xyz), 0.0, 0.0), vec4(0.0, 0.0, length(WORLD_MATRIX[2].xyz), 0.0), vec4(0.0, 0.0, 0.0, 1.0));\n"; + code += " __mvm = __mvm * mat4(vec4(length(WORLD_MATRIX[0].xyz), 0.0, 0.0, 0.0), vec4(0.0, length(WORLD_MATRIX[1].xyz), 0.0, 0.0), vec4(0.0, 0.0, length(WORLD_MATRIX[2].xyz), 0.0), vec4(0.0, 0.0, 0.0, 1.0));\n"; } - code += "\t\t" + p_output_vars[0] + " = __mvm;\n"; - code += "\t}\n"; + code += " " + p_output_vars[0] + " = __mvm;\n"; + code += " }\n"; break; case BILLBOARD_TYPE_FIXED_Y: - code += "\t{\n"; - code += "\t\tmat4 __mvm = INV_CAMERA_MATRIX * mat4(CAMERA_MATRIX[0], WORLD_MATRIX[1], vec4(normalize(cross(CAMERA_MATRIX[0].xyz, WORLD_MATRIX[1].xyz)), 0.0), WORLD_MATRIX[3]);\n"; + code += " {\n"; + code += " mat4 __mvm = INV_CAMERA_MATRIX * mat4(CAMERA_MATRIX[0], WORLD_MATRIX[1], vec4(normalize(cross(CAMERA_MATRIX[0].xyz, WORLD_MATRIX[1].xyz)), 0.0), WORLD_MATRIX[3]);\n"; if (keep_scale) { - code += "\t\t__mvm = __mvm * mat4(vec4(length(WORLD_MATRIX[0].xyz), 0.0, 0.0, 0.0), vec4(0.0, 1.0, 0.0, 0.0), vec4(0.0, 0.0, length(WORLD_MATRIX[2].xyz), 0.0), vec4(0.0, 0.0, 0.0, 1.0));\n"; + code += " __mvm = __mvm * mat4(vec4(length(WORLD_MATRIX[0].xyz), 0.0, 0.0, 0.0), vec4(0.0, 1.0, 0.0, 0.0), vec4(0.0, 0.0, length(WORLD_MATRIX[2].xyz), 0.0), vec4(0.0, 0.0, 0.0, 1.0));\n"; } else { - code += "\t\t__mvm = __mvm * mat4(vec4(1.0, 0.0, 0.0, 0.0), vec4(0.0, 1.0 / length(WORLD_MATRIX[1].xyz), 0.0, 0.0), vec4(0.0, 0.0, 1.0, 0.0), vec4(0.0, 0.0, 0.0, 1.0));\n"; + code += " __mvm = __mvm * mat4(vec4(1.0, 0.0, 0.0, 0.0), vec4(0.0, 1.0 / length(WORLD_MATRIX[1].xyz), 0.0, 0.0), vec4(0.0, 0.0, 1.0, 0.0), vec4(0.0, 0.0, 0.0, 1.0));\n"; } - code += "\t\t" + p_output_vars[0] + " = __mvm;\n"; - code += "\t}\n"; + code += " " + p_output_vars[0] + " = __mvm;\n"; + code += " }\n"; break; case BILLBOARD_TYPE_PARTICLES: - code += "\t{\n"; - code += "\t\tmat4 __wm = mat4(normalize(CAMERA_MATRIX[0]) * length(WORLD_MATRIX[0]), normalize(CAMERA_MATRIX[1]) * length(WORLD_MATRIX[0]), normalize(CAMERA_MATRIX[2]) * length(WORLD_MATRIX[2]), WORLD_MATRIX[3]);\n"; - code += "\t\t__wm = __wm * mat4(vec4(cos(INSTANCE_CUSTOM.x), -sin(INSTANCE_CUSTOM.x), 0.0, 0.0), vec4(sin(INSTANCE_CUSTOM.x), cos(INSTANCE_CUSTOM.x), 0.0, 0.0), vec4(0.0, 0.0, 1.0, 0.0), vec4(0.0, 0.0, 0.0, 1.0));\n"; - code += "\t\t" + p_output_vars[0] + " = INV_CAMERA_MATRIX * __wm;\n"; - code += "\t}\n"; + code += " {\n"; + code += " mat4 __wm = mat4(normalize(CAMERA_MATRIX[0]) * length(WORLD_MATRIX[0]), normalize(CAMERA_MATRIX[1]) * length(WORLD_MATRIX[0]), normalize(CAMERA_MATRIX[2]) * length(WORLD_MATRIX[2]), WORLD_MATRIX[3]);\n"; + code += " __wm = __wm * mat4(vec4(cos(INSTANCE_CUSTOM.x), -sin(INSTANCE_CUSTOM.x), 0.0, 0.0), vec4(sin(INSTANCE_CUSTOM.x), cos(INSTANCE_CUSTOM.x), 0.0, 0.0), vec4(0.0, 0.0, 1.0, 0.0), vec4(0.0, 0.0, 0.0, 1.0));\n"; + code += " " + p_output_vars[0] + " = INV_CAMERA_MATRIX * __wm;\n"; + code += " }\n"; break; default: - code += "\t" + p_output_vars[0] + " = mat4(1.0);\n"; + code += " " + p_output_vars[0] + " = mat4(1.0);\n"; break; } diff --git a/scene/resources/visual_shader_nodes.h b/scene/resources/visual_shader_nodes.h index 3ae79723e9..33a45a4384 100644 --- a/scene/resources/visual_shader_nodes.h +++ b/scene/resources/visual_shader_nodes.h @@ -338,9 +338,9 @@ public: /////////////////////////////////////// -class VisualShaderNodeCurve3Texture : public VisualShaderNodeResizableBase { - GDCLASS(VisualShaderNodeCurve3Texture, VisualShaderNodeResizableBase); - Ref<Curve3Texture> texture; +class VisualShaderNodeCurveXYZTexture : public VisualShaderNodeResizableBase { + GDCLASS(VisualShaderNodeCurveXYZTexture, VisualShaderNodeResizableBase); + Ref<CurveXYZTexture> texture; protected: static void _bind_methods(); @@ -360,13 +360,13 @@ public: virtual String generate_global(Shader::Mode p_mode, VisualShader::Type p_type, int p_id) const override; virtual String generate_code(Shader::Mode p_mode, VisualShader::Type p_type, int p_id, const String *p_input_vars, const String *p_output_vars, bool p_for_preview = false) const override; - void set_texture(Ref<Curve3Texture> p_value); - Ref<Curve3Texture> get_texture() const; + void set_texture(Ref<CurveXYZTexture> p_value); + Ref<CurveXYZTexture> get_texture() const; virtual Vector<StringName> get_editable_properties() const override; virtual bool is_use_prop_slots() const override; - VisualShaderNodeCurve3Texture(); + VisualShaderNodeCurveXYZTexture(); }; /////////////////////////////////////// diff --git a/scene/resources/visual_shader_particle_nodes.cpp b/scene/resources/visual_shader_particle_nodes.cpp index 29d583a82a..2250cf8d95 100644 --- a/scene/resources/visual_shader_particle_nodes.cpp +++ b/scene/resources/visual_shader_particle_nodes.cpp @@ -76,14 +76,14 @@ String VisualShaderNodeParticleSphereEmitter::get_input_port_name(int p_port) co String VisualShaderNodeParticleSphereEmitter::generate_global_per_node(Shader::Mode p_mode, VisualShader::Type p_type, int p_id) const { String code; code += "vec3 __get_random_point_in_sphere(inout uint seed, float radius, float inner_radius) {\n"; - code += "\treturn __get_random_unit_vec3(seed) * __randf_range(seed, inner_radius, radius);\n"; + code += " return __get_random_unit_vec3(seed) * __randf_range(seed, inner_radius, radius);\n"; code += "}\n\n"; return code; } String VisualShaderNodeParticleSphereEmitter::generate_code(Shader::Mode p_mode, VisualShader::Type p_type, int p_id, const String *p_input_vars, const String *p_output_vars, bool p_for_preview) const { String code; - code += "\t" + p_output_vars[0] + " = __get_random_point_in_sphere(__seed, " + (p_input_vars[0].is_empty() ? (String)get_input_port_default_value(0) : p_input_vars[0]) + ", " + (p_input_vars[1].is_empty() ? (String)get_input_port_default_value(1) : p_input_vars[1]) + ");\n"; + code += " " + p_output_vars[0] + " = __get_random_point_in_sphere(__seed, " + (p_input_vars[0].is_empty() ? (String)get_input_port_default_value(0) : p_input_vars[0]) + ", " + (p_input_vars[1].is_empty() ? (String)get_input_port_default_value(1) : p_input_vars[1]) + ");\n"; return code; } @@ -119,15 +119,15 @@ String VisualShaderNodeParticleBoxEmitter::get_input_port_name(int p_port) const String VisualShaderNodeParticleBoxEmitter::generate_global_per_node(Shader::Mode p_mode, VisualShader::Type p_type, int p_id) const { String code; code += "vec3 __get_random_point_in_box(inout uint seed, vec3 extents) {\n"; - code += "\tvec3 half_extents = extents / 2.0;\n"; - code += "\treturn vec3(__randf_range(seed, -half_extents.x, half_extents.x), __randf_range(seed, -half_extents.y, half_extents.y), __randf_range(seed, -half_extents.z, half_extents.z));\n"; + code += " vec3 half_extents = extents / 2.0;\n"; + code += " return vec3(__randf_range(seed, -half_extents.x, half_extents.x), __randf_range(seed, -half_extents.y, half_extents.y), __randf_range(seed, -half_extents.z, half_extents.z));\n"; code += "}\n\n"; return code; } String VisualShaderNodeParticleBoxEmitter::generate_code(Shader::Mode p_mode, VisualShader::Type p_type, int p_id, const String *p_input_vars, const String *p_output_vars, bool p_for_preview) const { String code; - code += "\t" + p_output_vars[0] + " = __get_random_point_in_box(__seed, " + (p_input_vars[0].is_empty() ? (String)get_input_port_default_value(0) : p_input_vars[0]) + ");\n"; + code += " " + p_output_vars[0] + " = __get_random_point_in_box(__seed, " + (p_input_vars[0].is_empty() ? (String)get_input_port_default_value(0) : p_input_vars[0]) + ");\n"; return code; } @@ -163,16 +163,16 @@ String VisualShaderNodeParticleRingEmitter::get_input_port_name(int p_port) cons String VisualShaderNodeParticleRingEmitter::generate_global_per_node(Shader::Mode p_mode, VisualShader::Type p_type, int p_id) const { String code; code += "vec3 __get_random_point_on_ring(inout uint seed, float radius, float inner_radius, float height) {\n"; - code += "\tfloat angle = __rand_from_seed(seed) * PI * 2.0;\n"; - code += "\tvec2 ring = vec2(sin(angle), cos(angle)) * __randf_range(seed, inner_radius, radius);\n"; - code += "\treturn vec3(ring.x, __randf_range(seed, min(0.0, height), max(0.0, height)), ring.y);\n"; + code += " float angle = __rand_from_seed(seed) * PI * 2.0;\n"; + code += " vec2 ring = vec2(sin(angle), cos(angle)) * __randf_range(seed, inner_radius, radius);\n"; + code += " return vec3(ring.x, __randf_range(seed, min(0.0, height), max(0.0, height)), ring.y);\n"; code += "}\n\n"; return code; } String VisualShaderNodeParticleRingEmitter::generate_code(Shader::Mode p_mode, VisualShader::Type p_type, int p_id, const String *p_input_vars, const String *p_output_vars, bool p_for_preview) const { String code; - code = "\t" + p_output_vars[0] + " = __get_random_point_on_ring(__seed, " + (p_input_vars[0].is_empty() ? (String)get_input_port_default_value(0) : p_input_vars[0]) + ", " + (p_input_vars[1].is_empty() ? (String)get_input_port_default_value(1) : p_input_vars[1]) + ", " + (p_input_vars[2].is_empty() ? (String)get_input_port_default_value(2) : p_input_vars[2]) + ");\n"; + code = " " + p_output_vars[0] + " = __get_random_point_on_ring(__seed, " + (p_input_vars[0].is_empty() ? (String)get_input_port_default_value(0) : p_input_vars[0]) + ", " + (p_input_vars[1].is_empty() ? (String)get_input_port_default_value(1) : p_input_vars[1]) + ", " + (p_input_vars[2].is_empty() ? (String)get_input_port_default_value(2) : p_input_vars[2]) + ");\n"; return code; } @@ -242,9 +242,9 @@ String VisualShaderNodeParticleMultiplyByAxisAngle::get_output_port_name(int p_p String VisualShaderNodeParticleMultiplyByAxisAngle::generate_code(Shader::Mode p_mode, VisualShader::Type p_type, int p_id, const String *p_input_vars, const String *p_output_vars, bool p_for_preview) const { String code; if (degrees_mode) { - code += "\t" + p_output_vars[0] + " = __build_rotation_mat3(" + (p_input_vars[1].is_empty() ? ("vec3" + (String)get_input_port_default_value(1)) : p_input_vars[1]) + ", radians(" + (p_input_vars[2].is_empty() ? (String)get_input_port_default_value(2) : p_input_vars[2]) + ")) * " + (p_input_vars[0].is_empty() ? "vec3(0.0)" : p_input_vars[0]) + ";\n"; + code += " " + p_output_vars[0] + " = __build_rotation_mat3(" + (p_input_vars[1].is_empty() ? ("vec3" + (String)get_input_port_default_value(1)) : p_input_vars[1]) + ", radians(" + (p_input_vars[2].is_empty() ? (String)get_input_port_default_value(2) : p_input_vars[2]) + ")) * " + (p_input_vars[0].is_empty() ? "vec3(0.0)" : p_input_vars[0]) + ";\n"; } else { - code += "\t" + p_output_vars[0] + " = __build_rotation_mat3(" + (p_input_vars[1].is_empty() ? ("vec3" + (String)get_input_port_default_value(1)) : p_input_vars[1]) + ", " + (p_input_vars[2].is_empty() ? (String)get_input_port_default_value(2) : p_input_vars[2]) + ") * " + (p_input_vars[0].is_empty() ? "vec3(0.0)" : p_input_vars[0]) + ";\n"; + code += " " + p_output_vars[0] + " = __build_rotation_mat3(" + (p_input_vars[1].is_empty() ? ("vec3" + (String)get_input_port_default_value(1)) : p_input_vars[1]) + ", " + (p_input_vars[2].is_empty() ? (String)get_input_port_default_value(2) : p_input_vars[2]) + ") * " + (p_input_vars[0].is_empty() ? "vec3(0.0)" : p_input_vars[0]) + ";\n"; } return code; } @@ -315,16 +315,16 @@ String VisualShaderNodeParticleConeVelocity::get_output_port_name(int p_port) co String VisualShaderNodeParticleConeVelocity::generate_code(Shader::Mode p_mode, VisualShader::Type p_type, int p_id, const String *p_input_vars, const String *p_output_vars, bool p_for_preview) const { String code; - code += "\t__radians = radians(" + (p_input_vars[1].is_empty() ? (String)get_input_port_default_value(1) : p_input_vars[1]) + ");\n"; - code += "\t__scalar_buff1 = __rand_from_seed_m1_p1(__seed) * __radians;\n"; - code += "\t__scalar_buff2 = __rand_from_seed_m1_p1(__seed) * __radians;\n"; - code += "\t__vec3_buff1 = " + (p_input_vars[0].is_empty() ? "vec3" + (String)get_input_port_default_value(0) : p_input_vars[0]) + ";\n"; - code += "\t__scalar_buff1 += __vec3_buff1.z != 0.0 ? atan(__vec3_buff1.x, __vec3_buff1.z) : sign(__vec3_buff1.x) * (PI / 2.0);\n"; - code += "\t__scalar_buff2 += __vec3_buff1.z != 0.0 ? atan(__vec3_buff1.y, abs(__vec3_buff1.z)) : (__vec3_buff1.x != 0.0 ? atan(__vec3_buff1.y, abs(__vec3_buff1.x)) : sign(__vec3_buff1.y) * (PI / 2.0));\n"; - code += "\t__vec3_buff1 = vec3(sin(__scalar_buff1), 0.0, cos(__scalar_buff1));\n"; - code += "\t__vec3_buff2 = vec3(0.0, sin(__scalar_buff2), cos(__scalar_buff2));\n"; - code += "\t__vec3_buff2.z = __vec3_buff2.z / max(0.0001, sqrt(abs(__vec3_buff2.z)));\n"; - code += "\t" + p_output_vars[0] + " = normalize(vec3(__vec3_buff1.x * __vec3_buff2.z, __vec3_buff2.y, __vec3_buff1.z * __vec3_buff2.z));\n"; + code += " __radians = radians(" + (p_input_vars[1].is_empty() ? (String)get_input_port_default_value(1) : p_input_vars[1]) + ");\n"; + code += " __scalar_buff1 = __rand_from_seed_m1_p1(__seed) * __radians;\n"; + code += " __scalar_buff2 = __rand_from_seed_m1_p1(__seed) * __radians;\n"; + code += " __vec3_buff1 = " + (p_input_vars[0].is_empty() ? "vec3" + (String)get_input_port_default_value(0) : p_input_vars[0]) + ";\n"; + code += " __scalar_buff1 += __vec3_buff1.z != 0.0 ? atan(__vec3_buff1.x, __vec3_buff1.z) : sign(__vec3_buff1.x) * (PI / 2.0);\n"; + code += " __scalar_buff2 += __vec3_buff1.z != 0.0 ? atan(__vec3_buff1.y, abs(__vec3_buff1.z)) : (__vec3_buff1.x != 0.0 ? atan(__vec3_buff1.y, abs(__vec3_buff1.x)) : sign(__vec3_buff1.y) * (PI / 2.0));\n"; + code += " __vec3_buff1 = vec3(sin(__scalar_buff1), 0.0, cos(__scalar_buff1));\n"; + code += " __vec3_buff2 = vec3(0.0, sin(__scalar_buff2), cos(__scalar_buff2));\n"; + code += " __vec3_buff2.z = __vec3_buff2.z / max(0.0001, sqrt(abs(__vec3_buff2.z)));\n"; + code += " " + p_output_vars[0] + " = normalize(vec3(__vec3_buff1.x * __vec3_buff2.z, __vec3_buff2.y, __vec3_buff1.z * __vec3_buff2.z));\n"; return code; } @@ -394,9 +394,9 @@ String VisualShaderNodeParticleRandomness::get_input_port_name(int p_port) const String VisualShaderNodeParticleRandomness::generate_code(Shader::Mode p_mode, VisualShader::Type p_type, int p_id, const String *p_input_vars, const String *p_output_vars, bool p_for_preview) const { String code; if (op_type == OP_TYPE_SCALAR) { - code += vformat("\t%s = __randf_range(__seed, %s, %s);\n", p_output_vars[0], p_input_vars[0].is_empty() ? (String)get_input_port_default_value(0) : p_input_vars[0], p_input_vars[1].is_empty() ? (String)get_input_port_default_value(1) : p_input_vars[1]); + code += vformat(" %s = __randf_range(__seed, %s, %s);\n", p_output_vars[0], p_input_vars[0].is_empty() ? (String)get_input_port_default_value(0) : p_input_vars[0], p_input_vars[1].is_empty() ? (String)get_input_port_default_value(1) : p_input_vars[1]); } else if (op_type == OP_TYPE_VECTOR) { - code += vformat("\t%s = __randv_range(__seed, %s, %s);\n", p_output_vars[0], p_input_vars[0].is_empty() ? (String)get_input_port_default_value(0) : p_input_vars[0], p_input_vars[1].is_empty() ? (String)get_input_port_default_value(1) : p_input_vars[1]); + code += vformat(" %s = __randv_range(__seed, %s, %s);\n", p_output_vars[0], p_input_vars[0].is_empty() ? (String)get_input_port_default_value(0) : p_input_vars[0], p_input_vars[1].is_empty() ? (String)get_input_port_default_value(1) : p_input_vars[1]); } return code; } @@ -491,14 +491,14 @@ String VisualShaderNodeParticleAccelerator::generate_code(Shader::Mode p_mode, V String code; switch (mode) { case MODE_LINEAR: - code += "\t" + p_output_vars[0] + " = length(VELOCITY) > 0.0 ? " + "normalize(VELOCITY) * " + (p_input_vars[0].is_empty() ? "vec3" + (String)get_input_port_default_value(0) : p_input_vars[0]) + " * mix(1.0, __rand_from_seed(__seed), " + (p_input_vars[1].is_empty() ? (String)get_input_port_default_value(1) : p_input_vars[1]) + ") : vec3(0.0);\n"; + code += " " + p_output_vars[0] + " = length(VELOCITY) > 0.0 ? " + "normalize(VELOCITY) * " + (p_input_vars[0].is_empty() ? "vec3" + (String)get_input_port_default_value(0) : p_input_vars[0]) + " * mix(1.0, __rand_from_seed(__seed), " + (p_input_vars[1].is_empty() ? (String)get_input_port_default_value(1) : p_input_vars[1]) + ") : vec3(0.0);\n"; break; case MODE_RADIAL: - code += "\t" + p_output_vars[0] + " = length(__diff) > 0.0 ? __ndiff * " + (p_input_vars[0].is_empty() ? "vec3" + (String)get_input_port_default_value(0) : p_input_vars[0]) + " * mix(1.0, __rand_from_seed(__seed), " + (p_input_vars[1].is_empty() ? (String)get_input_port_default_value(1) : p_input_vars[1]) + ") : vec3(0.0);\n"; + code += " " + p_output_vars[0] + " = length(__diff) > 0.0 ? __ndiff * " + (p_input_vars[0].is_empty() ? "vec3" + (String)get_input_port_default_value(0) : p_input_vars[0]) + " * mix(1.0, __rand_from_seed(__seed), " + (p_input_vars[1].is_empty() ? (String)get_input_port_default_value(1) : p_input_vars[1]) + ") : vec3(0.0);\n"; break; case MODE_TANGENTIAL: - code += "\t__vec3_buff1 = cross(__ndiff, normalize(" + (p_input_vars[2].is_empty() ? "vec3" + (String)get_input_port_default_value(2) : p_input_vars[2]) + "));\n"; - code += "\t" + p_output_vars[0] + " = length(__vec3_buff1) > 0.0 ? normalize(__vec3_buff1) * (" + (p_input_vars[0].is_empty() ? "vec3" + (String)get_input_port_default_value(0) : p_input_vars[0]) + " * mix(1.0, __rand_from_seed(__seed), " + (p_input_vars[1].is_empty() ? (String)get_input_port_default_value(1) : p_input_vars[1]) + ")) : vec3(0.0);\n"; + code += " __vec3_buff1 = cross(__ndiff, normalize(" + (p_input_vars[2].is_empty() ? "vec3" + (String)get_input_port_default_value(2) : p_input_vars[2]) + "));\n"; + code += " " + p_output_vars[0] + " = length(__vec3_buff1) > 0.0 ? normalize(__vec3_buff1) * (" + (p_input_vars[0].is_empty() ? "vec3" + (String)get_input_port_default_value(0) : p_input_vars[0]) + " * mix(1.0, __rand_from_seed(__seed), " + (p_input_vars[1].is_empty() ? (String)get_input_port_default_value(1) : p_input_vars[1]) + ")) : vec3(0.0);\n"; break; case MODE_MAX: break; @@ -693,7 +693,7 @@ bool VisualShaderNodeParticleOutput::is_port_separator(int p_index) const { String VisualShaderNodeParticleOutput::generate_code(Shader::Mode p_mode, VisualShader::Type p_type, int p_id, const String *p_input_vars, const String *p_output_vars, bool p_for_preview) const { String code; - String tab = "\t"; + String tab = " "; if (shader_type == VisualShader::TYPE_START_CUSTOM || shader_type == VisualShader::TYPE_PROCESS_CUSTOM) { if (!p_input_vars[0].is_empty()) { // custom.rgb @@ -718,7 +718,7 @@ String VisualShaderNodeParticleOutput::generate_code(Shader::Mode p_mode, Visual if (!p_input_vars[0].is_empty()) { // active (begin) code += tab + "ACTIVE = " + p_input_vars[0] + ";\n"; code += tab + "if(ACTIVE) {\n"; - tab += "\t"; + tab += " "; } if (!p_input_vars[1].is_empty()) { // velocity code += tab + "VELOCITY = " + p_input_vars[1] + ";\n"; @@ -734,14 +734,14 @@ String VisualShaderNodeParticleOutput::generate_code(Shader::Mode p_mode, Visual if (shader_type == VisualShader::TYPE_START) { code += tab + "if (RESTART_POSITION) {\n"; if (!p_input_vars[4].is_empty()) { - code += tab + "\tTRANSFORM = mat4(vec4(1.0, 0.0, 0.0, 0.0), vec4(0.0, 1.0, 0.0, 0.0), vec4(0.0, 0.0, 1.0, 0.0), vec4(" + p_input_vars[4] + ", 1.0));\n"; + code += tab + " TRANSFORM = mat4(vec4(1.0, 0.0, 0.0, 0.0), vec4(0.0, 1.0, 0.0, 0.0), vec4(0.0, 0.0, 1.0, 0.0), vec4(" + p_input_vars[4] + ", 1.0));\n"; } else { - code += tab + "\tTRANSFORM = mat4(vec4(1.0, 0.0, 0.0, 0.0), vec4(0.0, 1.0, 0.0, 0.0), vec4(0.0, 0.0, 1.0, 0.0), vec4(0.0, 0.0, 0.0, 1.0));\n"; + code += tab + " TRANSFORM = mat4(vec4(1.0, 0.0, 0.0, 0.0), vec4(0.0, 1.0, 0.0, 0.0), vec4(0.0, 0.0, 1.0, 0.0), vec4(0.0, 0.0, 0.0, 1.0));\n"; } - code += tab + "\tif (RESTART_VELOCITY) {\n"; - code += tab + "\t\tVELOCITY = (EMISSION_TRANSFORM * vec4(VELOCITY, 0.0)).xyz;\n"; - code += tab + "\t}\n"; - code += tab + "\tTRANSFORM = EMISSION_TRANSFORM * TRANSFORM;\n"; + code += tab + " if (RESTART_VELOCITY) {\n"; + code += tab + " VELOCITY = (EMISSION_TRANSFORM * vec4(VELOCITY, 0.0)).xyz;\n"; + code += tab + " }\n"; + code += tab + " TRANSFORM = EMISSION_TRANSFORM * TRANSFORM;\n"; code += tab + "}\n"; } else if (shader_type == VisualShader::TYPE_COLLIDE) { // position if (!p_input_vars[4].is_empty()) { @@ -779,7 +779,7 @@ String VisualShaderNodeParticleOutput::generate_code(Shader::Mode p_mode, Visual } } if (!p_input_vars[0].is_empty()) { // active (end) - code += "\t}\n"; + code += " }\n"; } } return code; @@ -926,12 +926,12 @@ String VisualShaderNodeParticleEmit::generate_code(Shader::Mode p_mode, VisualSh if (!is_input_port_connected(0)) { default_condition = true; if (get_input_port_default_value(0)) { - tab = "\t"; + tab = " "; } else { return code; } } else { - tab = "\t\t"; + tab = " "; } String transform; @@ -1008,13 +1008,13 @@ String VisualShaderNodeParticleEmit::generate_code(Shader::Mode p_mode, VisualSh } if (!default_condition) { - code += "\tif (" + p_input_vars[0] + ") {\n"; + code += " if (" + p_input_vars[0] + ") {\n"; } code += tab + "emit_subparticle(" + transform + ", " + velocity + ", vec4(" + color + ", " + alpha + "), vec4(" + custom + ", " + custom_alpha + "), " + flags + ");\n"; if (!default_condition) { - code += "\t}\n"; + code += " }\n"; } return code; diff --git a/scene/resources/visual_shader_sdf_nodes.cpp b/scene/resources/visual_shader_sdf_nodes.cpp index d25e32b070..14c655b129 100644 --- a/scene/resources/visual_shader_sdf_nodes.cpp +++ b/scene/resources/visual_shader_sdf_nodes.cpp @@ -61,7 +61,7 @@ String VisualShaderNodeSDFToScreenUV::get_output_port_name(int p_port) const { } String VisualShaderNodeSDFToScreenUV::generate_code(Shader::Mode p_mode, VisualShader::Type p_type, int p_id, const String *p_input_vars, const String *p_output_vars, bool p_for_preview) const { - return "\t" + p_output_vars[0] + " = vec3(sdf_to_screen_uv(" + (p_input_vars[0] == String() ? "vec2(0.0)" : p_input_vars[0] + ".xy") + "), 0.0f);\n"; + return " " + p_output_vars[0] + " = vec3(sdf_to_screen_uv(" + (p_input_vars[0] == String() ? "vec2(0.0)" : p_input_vars[0] + ".xy") + "), 0.0f);\n"; } VisualShaderNodeSDFToScreenUV::VisualShaderNodeSDFToScreenUV() { @@ -105,7 +105,7 @@ String VisualShaderNodeScreenUVToSDF::get_input_port_default_hint(int p_port) co } String VisualShaderNodeScreenUVToSDF::generate_code(Shader::Mode p_mode, VisualShader::Type p_type, int p_id, const String *p_input_vars, const String *p_output_vars, bool p_for_preview) const { - return "\t" + p_output_vars[0] + " = vec3(screen_uv_to_sdf(" + (p_input_vars[0] == String() ? "SCREEN_UV" : p_input_vars[0] + ".xy") + "), 0.0f);\n"; + return " " + p_output_vars[0] + " = vec3(screen_uv_to_sdf(" + (p_input_vars[0] == String() ? "SCREEN_UV" : p_input_vars[0] + ".xy") + "), 0.0f);\n"; } VisualShaderNodeScreenUVToSDF::VisualShaderNodeScreenUVToSDF() { @@ -142,7 +142,7 @@ String VisualShaderNodeTextureSDF::get_output_port_name(int p_port) const { } String VisualShaderNodeTextureSDF::generate_code(Shader::Mode p_mode, VisualShader::Type p_type, int p_id, const String *p_input_vars, const String *p_output_vars, bool p_for_preview) const { - return "\t" + p_output_vars[0] + " = texture_sdf(" + (p_input_vars[0] == String() ? "vec2(0.0)" : p_input_vars[0] + ".xy") + ");\n"; + return " " + p_output_vars[0] + " = texture_sdf(" + (p_input_vars[0] == String() ? "vec2(0.0)" : p_input_vars[0] + ".xy") + ");\n"; } VisualShaderNodeTextureSDF::VisualShaderNodeTextureSDF() { @@ -179,7 +179,7 @@ String VisualShaderNodeTextureSDFNormal::get_output_port_name(int p_port) const } String VisualShaderNodeTextureSDFNormal::generate_code(Shader::Mode p_mode, VisualShader::Type p_type, int p_id, const String *p_input_vars, const String *p_output_vars, bool p_for_preview) const { - return "\t" + p_output_vars[0] + " = vec3(texture_sdf_normal(" + (p_input_vars[0] == String() ? "vec2(0.0)" : p_input_vars[0] + ".xy") + "), 0.0f);\n"; + return " " + p_output_vars[0] + " = vec3(texture_sdf_normal(" + (p_input_vars[0] == String() ? "vec2(0.0)" : p_input_vars[0] + ".xy") + "), 0.0f);\n"; } VisualShaderNodeTextureSDFNormal::VisualShaderNodeTextureSDFNormal() { @@ -240,40 +240,40 @@ String VisualShaderNodeSDFRaymarch::get_output_port_name(int p_port) const { String VisualShaderNodeSDFRaymarch::generate_code(Shader::Mode p_mode, VisualShader::Type p_type, int p_id, const String *p_input_vars, const String *p_output_vars, bool p_for_preview) const { String code; - code += "\t{\n"; + code += " {\n"; if (p_input_vars[0] == String()) { - code += "\t\tvec2 __from_pos = vec2(0.0f);\n"; + code += " vec2 __from_pos = vec2(0.0f);\n"; } else { - code += "\t\tvec2 __from_pos = " + p_input_vars[0] + ".xy;\n"; + code += " vec2 __from_pos = " + p_input_vars[0] + ".xy;\n"; } if (p_input_vars[1] == String()) { - code += "\t\tvec2 __to_pos = vec2(0.0f);\n"; + code += " vec2 __to_pos = vec2(0.0f);\n"; } else { - code += "\t\tvec2 __to_pos = " + p_input_vars[1] + ".xy;\n"; + code += " vec2 __to_pos = " + p_input_vars[1] + ".xy;\n"; } - code += "\n\t\tvec2 __at = __from_pos;\n"; - code += "\t\tfloat __max_dist = distance(__from_pos, __to_pos);\n"; - code += "\t\tvec2 __dir = normalize(__to_pos - __from_pos);\n\n"; - - code += "\t\tfloat __accum = 0.0f;\n"; - code += "\t\twhile(__accum < __max_dist) {\n"; - code += "\t\t\tfloat __d = texture_sdf(__at);\n"; - code += "\t\t\t__accum += __d;\n"; - code += "\t\t\tif (__d < 0.01f) {\n"; - code += "\t\t\t\tbreak;\n"; - code += "\t\t\t}\n"; - code += "\t\t\t__at += __d * __dir;\n"; - code += "\t\t}\n"; - - code += "\t\tfloat __dist = min(__max_dist, __accum);\n"; - code += "\t\t" + p_output_vars[0] + " = __dist;\n"; - code += "\t\t" + p_output_vars[1] + " = __accum < __max_dist;\n"; - code += "\t\t" + p_output_vars[2] + " = vec3(__from_pos + __dir * __dist, 0.0f);\n"; - - code += "\t}\n"; + code += "\n vec2 __at = __from_pos;\n"; + code += " float __max_dist = distance(__from_pos, __to_pos);\n"; + code += " vec2 __dir = normalize(__to_pos - __from_pos);\n\n"; + + code += " float __accum = 0.0f;\n"; + code += " while(__accum < __max_dist) {\n"; + code += " float __d = texture_sdf(__at);\n"; + code += " __accum += __d;\n"; + code += " if (__d < 0.01f) {\n"; + code += " break;\n"; + code += " }\n"; + code += " __at += __d * __dir;\n"; + code += " }\n"; + + code += " float __dist = min(__max_dist, __accum);\n"; + code += " " + p_output_vars[0] + " = __dist;\n"; + code += " " + p_output_vars[1] + " = __accum < __max_dist;\n"; + code += " " + p_output_vars[2] + " = vec3(__from_pos + __dir * __dist, 0.0f);\n"; + + code += " }\n"; return code; } diff --git a/scene/scene_string_names.cpp b/scene/scene_string_names.cpp index 35f8a506fc..b8173c9623 100644 --- a/scene/scene_string_names.cpp +++ b/scene/scene_string_names.cpp @@ -66,6 +66,8 @@ SceneStringNames::SceneStringNames() { mouse_entered = StaticCString::create("mouse_entered"); mouse_exited = StaticCString::create("mouse_exited"); + mouse_shape_entered = StaticCString::create("mouse_shape_entered"); + mouse_shape_exited = StaticCString::create("mouse_shape_exited"); focus_entered = StaticCString::create("focus_entered"); focus_exited = StaticCString::create("focus_exited"); @@ -134,6 +136,7 @@ SceneStringNames::SceneStringNames() { _spatial_editor_group = StaticCString::create("_spatial_editor_group"); _request_gizmo = StaticCString::create("_request_gizmo"); + _clear_subgizmo_selection = StaticCString::create("_clear_subgizmo_selection"); offset = StaticCString::create("offset"); unit_offset = StaticCString::create("unit_offset"); @@ -169,6 +172,8 @@ SceneStringNames::SceneStringNames() { _mouse_enter = StaticCString::create("_mouse_enter"); _mouse_exit = StaticCString::create("_mouse_exit"); + _mouse_shape_enter = StaticCString::create("_mouse_shape_enter"); + _mouse_shape_exit = StaticCString::create("_mouse_shape_exit"); _pressed = StaticCString::create("_pressed"); _toggled = StaticCString::create("_toggled"); diff --git a/scene/scene_string_names.h b/scene/scene_string_names.h index 01865b0d2f..eddb0c33eb 100644 --- a/scene/scene_string_names.h +++ b/scene/scene_string_names.h @@ -84,6 +84,8 @@ public: StringName mouse_entered; StringName mouse_exited; + StringName mouse_shape_entered; + StringName mouse_shape_exited; StringName focus_entered; StringName focus_exited; @@ -154,6 +156,7 @@ public: StringName _spatial_editor_group; StringName _request_gizmo; + StringName _clear_subgizmo_selection; StringName offset; StringName unit_offset; @@ -181,6 +184,8 @@ public: StringName _mouse_enter; StringName _mouse_exit; + StringName _mouse_shape_enter; + StringName _mouse_shape_exit; StringName frame_changed; StringName texture_changed; diff --git a/servers/audio_server.cpp b/servers/audio_server.cpp index 667087d1ec..076cbb58af 100644 --- a/servers/audio_server.cpp +++ b/servers/audio_server.cpp @@ -561,7 +561,7 @@ void AudioServer::set_bus_count(int p_count) { unlock(); - emit_signal("bus_layout_changed"); + emit_signal(SNAME("bus_layout_changed")); } void AudioServer::remove_bus(int p_index) { @@ -576,7 +576,7 @@ void AudioServer::remove_bus(int p_index) { buses.remove(p_index); unlock(); - emit_signal("bus_layout_changed"); + emit_signal(SNAME("bus_layout_changed")); } void AudioServer::add_bus(int p_at_pos) { @@ -630,7 +630,7 @@ void AudioServer::add_bus(int p_at_pos) { buses.insert(p_at_pos, bus); } - emit_signal("bus_layout_changed"); + emit_signal(SNAME("bus_layout_changed")); } void AudioServer::move_bus(int p_bus, int p_to_pos) { @@ -654,7 +654,7 @@ void AudioServer::move_bus(int p_bus, int p_to_pos) { buses.insert(p_to_pos - 1, bus); } - emit_signal("bus_layout_changed"); + emit_signal(SNAME("bus_layout_changed")); } int AudioServer::get_bus_count() const { @@ -700,7 +700,7 @@ void AudioServer::set_bus_name(int p_bus, const String &p_name) { bus_map[attempt] = buses[p_bus]; unlock(); - emit_signal("bus_layout_changed"); + emit_signal(SNAME("bus_layout_changed")); } String AudioServer::get_bus_name(int p_bus) const { diff --git a/servers/camera_server.cpp b/servers/camera_server.cpp index ee4a2e148b..6f506d0f7a 100644 --- a/servers/camera_server.cpp +++ b/servers/camera_server.cpp @@ -110,7 +110,7 @@ void CameraServer::add_feed(const Ref<CameraFeed> &p_feed) { #endif // let whomever is interested know - emit_signal("camera_feed_added", p_feed->get_id()); + emit_signal(SNAME("camera_feed_added"), p_feed->get_id()); }; void CameraServer::remove_feed(const Ref<CameraFeed> &p_feed) { @@ -127,7 +127,7 @@ void CameraServer::remove_feed(const Ref<CameraFeed> &p_feed) { feeds.remove(i); // let whomever is interested know - emit_signal("camera_feed_removed", feed_id); + emit_signal(SNAME("camera_feed_removed"), feed_id); return; }; }; diff --git a/servers/display_server.cpp b/servers/display_server.cpp index be2a813fd1..3d44484033 100644 --- a/servers/display_server.cpp +++ b/servers/display_server.cpp @@ -346,8 +346,6 @@ void DisplayServer::_bind_methods() { ClassDB::bind_method(D_METHOD("global_menu_remove_item", "menu_root", "idx"), &DisplayServer::global_menu_remove_item); ClassDB::bind_method(D_METHOD("global_menu_clear", "menu_root"), &DisplayServer::global_menu_clear); - ClassDB::bind_method(D_METHOD("alert", "text", "title"), &DisplayServer::alert, DEFVAL("Alert!")); - ClassDB::bind_method(D_METHOD("mouse_set_mode", "mouse_mode"), &DisplayServer::mouse_set_mode); ClassDB::bind_method(D_METHOD("mouse_get_mode"), &DisplayServer::mouse_get_mode); diff --git a/servers/display_server.h b/servers/display_server.h index 8d289b10fd..788206768c 100644 --- a/servers/display_server.h +++ b/servers/display_server.h @@ -143,8 +143,6 @@ public: virtual void global_menu_remove_item(const String &p_menu_root, int p_idx); virtual void global_menu_clear(const String &p_menu_root); - virtual void alert(const String &p_alert, const String &p_title = "ALERT!") = 0; - enum MouseMode { MOUSE_MODE_VISIBLE, MOUSE_MODE_HIDDEN, diff --git a/servers/display_server_headless.h b/servers/display_server_headless.h index 870401b180..d9ee91084f 100644 --- a/servers/display_server_headless.h +++ b/servers/display_server_headless.h @@ -55,8 +55,6 @@ public: bool has_feature(Feature p_feature) const override { return false; } String get_name() const override { return "headless"; } - void alert(const String &p_alert, const String &p_title = "ALERT!") override {} - int get_screen_count() const override { return 0; } Point2i screen_get_position(int p_screen = SCREEN_OF_MAIN_WINDOW) const override { return Point2i(); } Size2i screen_get_size(int p_screen = SCREEN_OF_MAIN_WINDOW) const override { return Size2i(); } diff --git a/servers/navigation_server_2d.cpp b/servers/navigation_server_2d.cpp index ef2635c188..85b12f1585 100644 --- a/servers/navigation_server_2d.cpp +++ b/servers/navigation_server_2d.cpp @@ -158,7 +158,7 @@ static Ref<NavigationMesh> poly_to_mesh(Ref<NavigationPolygon> d) { } void NavigationServer2D::_emit_map_changed(RID p_map) { - emit_signal("map_changed", p_map); + emit_signal(SNAME("map_changed"), p_map); } void NavigationServer2D::_bind_methods() { diff --git a/servers/physics_2d/area_pair_2d_sw.cpp b/servers/physics_2d/area_pair_2d_sw.cpp index 5cc5bae09b..5ca16cb6fc 100644 --- a/servers/physics_2d/area_pair_2d_sw.cpp +++ b/servers/physics_2d/area_pair_2d_sw.cpp @@ -33,7 +33,7 @@ bool AreaPair2DSW::setup(real_t p_step) { bool result = false; - if (area->test_collision_mask(body) && CollisionSolver2DSW::solve(body->get_shape(body_shape), body->get_transform() * body->get_shape_transform(body_shape), Vector2(), area->get_shape(area_shape), area->get_transform() * area->get_shape_transform(area_shape), Vector2(), nullptr, this)) { + if (area->interacts_with(body) && CollisionSolver2DSW::solve(body->get_shape(body_shape), body->get_transform() * body->get_shape_transform(body_shape), Vector2(), area->get_shape(area_shape), area->get_transform() * area->get_shape_transform(area_shape), Vector2(), nullptr, this)) { result = true; } @@ -110,7 +110,7 @@ AreaPair2DSW::~AreaPair2DSW() { bool Area2Pair2DSW::setup(real_t p_step) { bool result = false; - if (area_a->test_collision_mask(area_b) && CollisionSolver2DSW::solve(area_a->get_shape(shape_a), area_a->get_transform() * area_a->get_shape_transform(shape_a), Vector2(), area_b->get_shape(shape_b), area_b->get_transform() * area_b->get_shape_transform(shape_b), Vector2(), nullptr, this)) { + if (area_a->interacts_with(area_b) && CollisionSolver2DSW::solve(area_a->get_shape(shape_a), area_a->get_transform() * area_a->get_shape_transform(shape_a), Vector2(), area_b->get_shape(shape_b), area_b->get_transform() * area_b->get_shape_transform(shape_b), Vector2(), nullptr, this)) { result = true; } diff --git a/servers/physics_2d/body_2d_sw.cpp b/servers/physics_2d/body_2d_sw.cpp index 6f244deb1e..7aa2f9b7de 100644 --- a/servers/physics_2d/body_2d_sw.cpp +++ b/servers/physics_2d/body_2d_sw.cpp @@ -532,13 +532,13 @@ void Body2DSW::integrate_velocities(real_t p_step) { } void Body2DSW::wakeup_neighbours() { - for (List<Pair<Constraint2DSW *, int>>::Element *E = constraint_list.front(); E; E = E->next()) { - const Constraint2DSW *c = E->get().first; + for (const Pair<Constraint2DSW *, int> &E : constraint_list) { + const Constraint2DSW *c = E.first; Body2DSW **n = c->get_body_ptr(); int bc = c->get_body_count(); for (int i = 0; i < bc; i++) { - if (i == E->get().second) { + if (i == E.second) { continue; } Body2DSW *b = n[i]; diff --git a/servers/physics_2d/body_pair_2d_sw.cpp b/servers/physics_2d/body_pair_2d_sw.cpp index e5eb374fa3..91d747b492 100644 --- a/servers/physics_2d/body_pair_2d_sw.cpp +++ b/servers/physics_2d/body_pair_2d_sw.cpp @@ -226,16 +226,16 @@ real_t combine_friction(Body2DSW *A, Body2DSW *B) { } bool BodyPair2DSW::setup(real_t p_step) { - dynamic_A = (A->get_mode() > PhysicsServer2D::BODY_MODE_KINEMATIC); - dynamic_B = (B->get_mode() > PhysicsServer2D::BODY_MODE_KINEMATIC); - - if (!A->test_collision_mask(B) || A->has_exception(B->get_self()) || B->has_exception(A->get_self())) { + if (!A->interacts_with(B) || A->has_exception(B->get_self()) || B->has_exception(A->get_self())) { collided = false; return false; } + collide_A = (A->get_mode() > PhysicsServer2D::BODY_MODE_KINEMATIC) && A->collides_with(B); + collide_B = (B->get_mode() > PhysicsServer2D::BODY_MODE_KINEMATIC) && B->collides_with(A); + report_contacts_only = false; - if (!dynamic_A && !dynamic_B) { + if (!collide_A && !collide_B) { if ((A->get_max_contacts_reported() > 0) || (B->get_max_contacts_reported() > 0)) { report_contacts_only = true; } else { @@ -275,13 +275,13 @@ bool BodyPair2DSW::setup(real_t p_step) { if (!collided) { //test ccd (currently just a raycast) - if (A->get_continuous_collision_detection_mode() == PhysicsServer2D::CCD_MODE_CAST_RAY && dynamic_A) { + if (A->get_continuous_collision_detection_mode() == PhysicsServer2D::CCD_MODE_CAST_RAY && collide_A) { if (_test_ccd(p_step, A, shape_A, xform_A, B, shape_B, xform_B)) { collided = true; } } - if (B->get_continuous_collision_detection_mode() == PhysicsServer2D::CCD_MODE_CAST_RAY && dynamic_B) { + if (B->get_continuous_collision_detection_mode() == PhysicsServer2D::CCD_MODE_CAST_RAY && collide_B) { if (_test_ccd(p_step, B, shape_B, xform_B, A, shape_A, xform_A, true)) { collided = true; } @@ -374,6 +374,12 @@ bool BodyPair2DSW::pre_solve(real_t p_step) { const Transform2D &transform_A = A->get_transform(); const Transform2D &transform_B = B->get_transform(); + real_t inv_inertia_A = collide_A ? A->get_inv_inertia() : 0.0; + real_t inv_inertia_B = collide_B ? B->get_inv_inertia() : 0.0; + + real_t inv_mass_A = collide_A ? A->get_inv_mass() : 0.0; + real_t inv_mass_B = collide_B ? B->get_inv_mass() : 0.0; + for (int i = 0; i < contact_count; i++) { Contact &c = contacts[i]; c.active = false; @@ -384,7 +390,7 @@ bool BodyPair2DSW::pre_solve(real_t p_step) { Vector2 axis = global_A - global_B; real_t depth = axis.dot(c.normal); - if (depth <= 0 || !c.reused) { + if (depth <= 0.0 || !c.reused) { continue; } @@ -416,15 +422,15 @@ bool BodyPair2DSW::pre_solve(real_t p_step) { // Precompute normal mass, tangent mass, and bias. real_t rnA = c.rA.dot(c.normal); real_t rnB = c.rB.dot(c.normal); - real_t kNormal = A->get_inv_mass() + B->get_inv_mass(); - kNormal += A->get_inv_inertia() * (c.rA.dot(c.rA) - rnA * rnA) + B->get_inv_inertia() * (c.rB.dot(c.rB) - rnB * rnB); + real_t kNormal = inv_mass_A + inv_mass_B; + kNormal += inv_inertia_A * (c.rA.dot(c.rA) - rnA * rnA) + inv_inertia_B * (c.rB.dot(c.rB) - rnB * rnB); c.mass_normal = 1.0f / kNormal; Vector2 tangent = c.normal.orthogonal(); real_t rtA = c.rA.dot(tangent); real_t rtB = c.rB.dot(tangent); - real_t kTangent = A->get_inv_mass() + B->get_inv_mass(); - kTangent += A->get_inv_inertia() * (c.rA.dot(c.rA) - rtA * rtA) + B->get_inv_inertia() * (c.rB.dot(c.rB) - rtB * rtB); + real_t kTangent = inv_mass_A + inv_mass_B; + kTangent += inv_inertia_A * (c.rA.dot(c.rA) - rtA * rtA) + inv_inertia_B * (c.rB.dot(c.rB) - rtB * rtB); c.mass_tangent = 1.0f / kTangent; c.bias = -bias * inv_dt * MIN(0.0f, -depth + max_penetration); @@ -436,10 +442,10 @@ bool BodyPair2DSW::pre_solve(real_t p_step) { // Apply normal + friction impulse Vector2 P = c.acc_normal_impulse * c.normal + c.acc_tangent_impulse * tangent; - if (dynamic_A) { + if (collide_A) { A->apply_impulse(-P, c.rA); } - if (dynamic_B) { + if (collide_B) { B->apply_impulse(P, c.rB); } } @@ -493,10 +499,10 @@ void BodyPair2DSW::solve(real_t p_step) { Vector2 jb = c.normal * (c.acc_bias_impulse - jbnOld); - if (dynamic_A) { + if (collide_A) { A->apply_bias_impulse(-jb, c.rA); } - if (dynamic_B) { + if (collide_B) { B->apply_bias_impulse(jb, c.rB); } @@ -513,10 +519,10 @@ void BodyPair2DSW::solve(real_t p_step) { Vector2 j = c.normal * (c.acc_normal_impulse - jnOld) + tangent * (c.acc_tangent_impulse - jtOld); - if (dynamic_A) { + if (collide_A) { A->apply_impulse(-j, c.rA); } - if (dynamic_B) { + if (collide_B) { B->apply_impulse(j, c.rB); } } diff --git a/servers/physics_2d/body_pair_2d_sw.h b/servers/physics_2d/body_pair_2d_sw.h index 4b42b44c92..849a7e2430 100644 --- a/servers/physics_2d/body_pair_2d_sw.h +++ b/servers/physics_2d/body_pair_2d_sw.h @@ -50,8 +50,8 @@ class BodyPair2DSW : public Constraint2DSW { int shape_A = 0; int shape_B = 0; - bool dynamic_A = false; - bool dynamic_B = false; + bool collide_A = false; + bool collide_B = false; Space2DSW *space = nullptr; diff --git a/servers/physics_2d/collision_object_2d_sw.h b/servers/physics_2d/collision_object_2d_sw.h index 67da758d14..55ffa9b1b8 100644 --- a/servers/physics_2d/collision_object_2d_sw.h +++ b/servers/physics_2d/collision_object_2d_sw.h @@ -186,7 +186,11 @@ public: void set_pickable(bool p_pickable) { pickable = p_pickable; } _FORCE_INLINE_ bool is_pickable() const { return pickable; } - _FORCE_INLINE_ bool test_collision_mask(CollisionObject2DSW *p_other) const { + _FORCE_INLINE_ bool collides_with(CollisionObject2DSW *p_other) const { + return p_other->collision_layer & collision_mask; + } + + _FORCE_INLINE_ bool interacts_with(CollisionObject2DSW *p_other) const { return collision_layer & p_other->collision_mask || p_other->collision_layer & collision_mask; } diff --git a/servers/physics_2d/physics_server_2d_sw.cpp b/servers/physics_2d/physics_server_2d_sw.cpp index 155dda4394..467c664302 100644 --- a/servers/physics_2d/physics_server_2d_sw.cpp +++ b/servers/physics_2d/physics_server_2d_sw.cpp @@ -946,7 +946,7 @@ void PhysicsServer2DSW::body_set_pickable(RID p_body, bool p_pickable) { body->set_pickable(p_pickable); } -bool PhysicsServer2DSW::body_test_motion(RID p_body, const Transform2D &p_from, const Vector2 &p_motion, bool p_infinite_inertia, real_t p_margin, MotionResult *r_result, bool p_exclude_raycast_shapes) { +bool PhysicsServer2DSW::body_test_motion(RID p_body, const Transform2D &p_from, const Vector2 &p_motion, bool p_infinite_inertia, real_t p_margin, MotionResult *r_result, bool p_exclude_raycast_shapes, const Set<RID> &p_exclude) { Body2DSW *body = body_owner.getornull(p_body); ERR_FAIL_COND_V(!body, false); ERR_FAIL_COND_V(!body->get_space(), false); @@ -954,7 +954,7 @@ bool PhysicsServer2DSW::body_test_motion(RID p_body, const Transform2D &p_from, _update_shapes(); - return body->get_space()->test_body_motion(body, p_from, p_motion, p_infinite_inertia, p_margin, r_result, p_exclude_raycast_shapes); + return body->get_space()->test_body_motion(body, p_from, p_motion, p_infinite_inertia, p_margin, r_result, p_exclude_raycast_shapes, p_exclude); } int PhysicsServer2DSW::body_test_ray_separation(RID p_body, const Transform2D &p_transform, bool p_infinite_inertia, Vector2 &r_recover_motion, SeparationResult *r_results, int p_result_max, real_t p_margin) { diff --git a/servers/physics_2d/physics_server_2d_sw.h b/servers/physics_2d/physics_server_2d_sw.h index 5002bf5fc8..f40b5a7c42 100644 --- a/servers/physics_2d/physics_server_2d_sw.h +++ b/servers/physics_2d/physics_server_2d_sw.h @@ -247,7 +247,7 @@ public: virtual void body_set_pickable(RID p_body, bool p_pickable) override; - virtual bool body_test_motion(RID p_body, const Transform2D &p_from, const Vector2 &p_motion, bool p_infinite_inertia, real_t p_margin = 0.08, MotionResult *r_result = nullptr, bool p_exclude_raycast_shapes = true) override; + virtual bool body_test_motion(RID p_body, const Transform2D &p_from, const Vector2 &p_motion, bool p_infinite_inertia, real_t p_margin = 0.08, MotionResult *r_result = nullptr, bool p_exclude_raycast_shapes = true, const Set<RID> &p_exclude = Set<RID>()) override; virtual int body_test_ray_separation(RID p_body, const Transform2D &p_transform, bool p_infinite_inertia, Vector2 &r_recover_motion, SeparationResult *r_results, int p_result_max, real_t p_margin = 0.08) override; // this function only works on physics process, errors and returns null otherwise diff --git a/servers/physics_2d/physics_server_2d_wrap_mt.h b/servers/physics_2d/physics_server_2d_wrap_mt.h index a8f7ff3393..fb7235c031 100644 --- a/servers/physics_2d/physics_server_2d_wrap_mt.h +++ b/servers/physics_2d/physics_server_2d_wrap_mt.h @@ -253,9 +253,9 @@ public: FUNC2(body_set_pickable, RID, bool); - bool body_test_motion(RID p_body, const Transform2D &p_from, const Vector2 &p_motion, bool p_infinite_inertia, real_t p_margin = 0.08, MotionResult *r_result = nullptr, bool p_exclude_raycast_shapes = true) override { + bool body_test_motion(RID p_body, const Transform2D &p_from, const Vector2 &p_motion, bool p_infinite_inertia, real_t p_margin = 0.08, MotionResult *r_result = nullptr, bool p_exclude_raycast_shapes = true, const Set<RID> &p_exclude = Set<RID>()) override { ERR_FAIL_COND_V(main_thread != Thread::get_caller_id(), false); - return physics_2d_server->body_test_motion(p_body, p_from, p_motion, p_infinite_inertia, p_margin, r_result, p_exclude_raycast_shapes); + return physics_2d_server->body_test_motion(p_body, p_from, p_motion, p_infinite_inertia, p_margin, r_result, p_exclude_raycast_shapes, p_exclude); } int body_test_ray_separation(RID p_body, const Transform2D &p_transform, bool p_infinite_inertia, Vector2 &r_recover_motion, SeparationResult *r_results, int p_result_max, real_t p_margin = 0.08) override { diff --git a/servers/physics_2d/space_2d_sw.cpp b/servers/physics_2d/space_2d_sw.cpp index 4b123b2d46..590c93a7be 100644 --- a/servers/physics_2d/space_2d_sw.cpp +++ b/servers/physics_2d/space_2d_sw.cpp @@ -283,22 +283,38 @@ bool PhysicsDirectSpaceState2DSW::cast_motion(const RID &p_shape, const Transfor continue; } - //just do kinematic solving - real_t low = 0; - real_t hi = 1; Vector2 mnormal = p_motion.normalized(); + //just do kinematic solving + real_t low = 0.0; + real_t hi = 1.0; + real_t fraction_coeff = 0.5; for (int j = 0; j < 8; j++) { //steps should be customizable.. - - real_t ofs = (low + hi) * 0.5; + real_t fraction = low + (hi - low) * fraction_coeff; Vector2 sep = mnormal; //important optimization for this to work fast enough - bool collided = CollisionSolver2DSW::solve(shape, p_xform, p_motion * ofs, col_obj->get_shape(shape_idx), col_obj_xform, Vector2(), nullptr, nullptr, &sep, p_margin); + bool collided = CollisionSolver2DSW::solve(shape, p_xform, p_motion * fraction, col_obj->get_shape(shape_idx), col_obj_xform, Vector2(), nullptr, nullptr, &sep, p_margin); if (collided) { - hi = ofs; + hi = fraction; + if ((j == 0) || (low > 0.0)) { // Did it not collide before? + // When alternating or first iteration, use dichotomy. + fraction_coeff = 0.5; + } else { + // When colliding again, converge faster towards low fraction + // for more accurate results with long motions that collide near the start. + fraction_coeff = 0.25; + } } else { - low = ofs; + low = fraction; + if ((j == 0) || (hi < 1.0)) { // Did it collide before? + // When alternating or first iteration, use dichotomy. + fraction_coeff = 0.5; + } else { + // When not colliding again, converge faster towards high fraction + // for more accurate results with long motions that collide near the end. + fraction_coeff = 0.75; + } } } @@ -492,7 +508,7 @@ int Space2DSW::_cull_aabb_for_body(Body2DSW *p_body, const Rect2 &p_aabb) { keep = false; } else if (intersection_query_results[i]->get_type() == CollisionObject2DSW::TYPE_AREA) { keep = false; - } else if ((static_cast<Body2DSW *>(intersection_query_results[i])->test_collision_mask(p_body)) == 0) { + } else if (!p_body->collides_with(static_cast<Body2DSW *>(intersection_query_results[i]))) { keep = false; } else if (static_cast<Body2DSW *>(intersection_query_results[i])->has_exception(p_body->get_self()) || p_body->has_exception(intersection_query_results[i]->get_self())) { keep = false; @@ -693,7 +709,7 @@ int Space2DSW::test_body_ray_separation(Body2DSW *p_body, const Transform2D &p_t return rays_found; } -bool Space2DSW::test_body_motion(Body2DSW *p_body, const Transform2D &p_from, const Vector2 &p_motion, bool p_infinite_inertia, real_t p_margin, PhysicsServer2D::MotionResult *r_result, bool p_exclude_raycast_shapes) { +bool Space2DSW::test_body_motion(Body2DSW *p_body, const Transform2D &p_from, const Vector2 &p_motion, bool p_infinite_inertia, real_t p_margin, PhysicsServer2D::MotionResult *r_result, bool p_exclude_raycast_shapes, const Set<RID> &p_exclude) { //give me back regular physics engine logic //this is madness //and most people using this function will think @@ -785,6 +801,9 @@ bool Space2DSW::test_body_motion(Body2DSW *p_body, const Transform2D &p_from, co Transform2D body_shape_xform = body_transform * p_body->get_shape_transform(j); for (int i = 0; i < amount; i++) { const CollisionObject2DSW *col_obj = intersection_query_results[i]; + if (p_exclude.has(col_obj->get_self())) { + continue; + } int shape_idx = intersection_query_subindex_results[i]; if (CollisionObject2DSW::TYPE_BODY == col_obj->get_type()) { @@ -914,6 +933,9 @@ bool Space2DSW::test_body_motion(Body2DSW *p_body, const Transform2D &p_from, co for (int i = 0; i < amount; i++) { const CollisionObject2DSW *col_obj = intersection_query_results[i]; + if (p_exclude.has(col_obj->get_self())) { + continue; + } int col_shape_idx = intersection_query_subindex_results[i]; Shape2DSW *against_shape = col_obj->get_shape(col_shape_idx); @@ -957,20 +979,35 @@ bool Space2DSW::test_body_motion(Body2DSW *p_body, const Transform2D &p_from, co } //just do kinematic solving - real_t low = 0; - real_t hi = 1; - + real_t low = 0.0; + real_t hi = 1.0; + real_t fraction_coeff = 0.5; for (int k = 0; k < 8; k++) { //steps should be customizable.. - - real_t ofs = (low + hi) * 0.5; + real_t fraction = low + (hi - low) * fraction_coeff; Vector2 sep = motion_normal; //important optimization for this to work fast enough - bool collided = CollisionSolver2DSW::solve(body_shape, body_shape_xform, p_motion * ofs, against_shape, col_obj_shape_xform, Vector2(), nullptr, nullptr, &sep, 0); + bool collided = CollisionSolver2DSW::solve(body_shape, body_shape_xform, p_motion * fraction, against_shape, col_obj_shape_xform, Vector2(), nullptr, nullptr, &sep, 0); if (collided) { - hi = ofs; + hi = fraction; + if ((k == 0) || (low > 0.0)) { // Did it not collide before? + // When alternating or first iteration, use dichotomy. + fraction_coeff = 0.5; + } else { + // When colliding again, converge faster towards low fraction + // for more accurate results with long motions that collide near the start. + fraction_coeff = 0.25; + } } else { - low = ofs; + low = fraction; + if ((k == 0) || (hi < 1.0)) { // Did it collide before? + // When alternating or first iteration, use dichotomy. + fraction_coeff = 0.5; + } else { + // When not colliding again, converge faster towards high fraction + // for more accurate results with long motions that collide near the end. + fraction_coeff = 0.75; + } } } @@ -1055,6 +1092,9 @@ bool Space2DSW::test_body_motion(Body2DSW *p_body, const Transform2D &p_from, co for (int i = 0; i < amount; i++) { const CollisionObject2DSW *col_obj = intersection_query_results[i]; + if (p_exclude.has(col_obj->get_self())) { + continue; + } int shape_idx = intersection_query_subindex_results[i]; if (CollisionObject2DSW::TYPE_BODY == col_obj->get_type()) { @@ -1148,7 +1188,7 @@ bool Space2DSW::test_body_motion(Body2DSW *p_body, const Transform2D &p_from, co } void *Space2DSW::_broadphase_pair(CollisionObject2DSW *A, int p_subindex_A, CollisionObject2DSW *B, int p_subindex_B, void *p_self) { - if (!A->test_collision_mask(B)) { + if (!A->interacts_with(B)) { return nullptr; } diff --git a/servers/physics_2d/space_2d_sw.h b/servers/physics_2d/space_2d_sw.h index 4d737d622f..f7224e4661 100644 --- a/servers/physics_2d/space_2d_sw.h +++ b/servers/physics_2d/space_2d_sw.h @@ -183,7 +183,7 @@ public: int get_collision_pairs() const { return collision_pairs; } - bool test_body_motion(Body2DSW *p_body, const Transform2D &p_from, const Vector2 &p_motion, bool p_infinite_inertia, real_t p_margin, PhysicsServer2D::MotionResult *r_result, bool p_exclude_raycast_shapes = true); + bool test_body_motion(Body2DSW *p_body, const Transform2D &p_from, const Vector2 &p_motion, bool p_infinite_inertia, real_t p_margin, PhysicsServer2D::MotionResult *r_result, bool p_exclude_raycast_shapes = true, const Set<RID> &p_exclude = Set<RID>()); int test_body_ray_separation(Body2DSW *p_body, const Transform2D &p_transform, bool p_infinite_inertia, Vector2 &r_recover_motion, PhysicsServer2D::SeparationResult *r_results, int p_result_max, real_t p_margin); void set_debug_contacts(int p_amount) { contact_debug.resize(p_amount); } diff --git a/servers/physics_2d/step_2d_sw.cpp b/servers/physics_2d/step_2d_sw.cpp index b8cb4cddc5..8b30160cc1 100644 --- a/servers/physics_2d/step_2d_sw.cpp +++ b/servers/physics_2d/step_2d_sw.cpp @@ -46,8 +46,8 @@ void Step2DSW::_populate_island(Body2DSW *p_body, LocalVector<Body2DSW *> &p_bod p_body_island.push_back(p_body); } - for (const List<Pair<Constraint2DSW *, int>>::Element *E = p_body->get_constraint_list().front(); E; E = E->next()) { - Constraint2DSW *constraint = (Constraint2DSW *)E->get().first; + for (const Pair<Constraint2DSW *, int> &E : p_body->get_constraint_list()) { + Constraint2DSW *constraint = (Constraint2DSW *)E.first; if (constraint->get_island_step() == _step) { continue; // Already processed. } @@ -56,7 +56,7 @@ void Step2DSW::_populate_island(Body2DSW *p_body, LocalVector<Body2DSW *> &p_bod all_constraints.push_back(constraint); for (int i = 0; i < constraint->get_body_count(); i++) { - if (i == E->get().second) { + if (i == E.second) { continue; } Body2DSW *other_body = constraint->get_body_ptr()[i]; diff --git a/servers/physics_3d/area_pair_3d_sw.cpp b/servers/physics_3d/area_pair_3d_sw.cpp index 9f93a61909..f43c2c965e 100644 --- a/servers/physics_3d/area_pair_3d_sw.cpp +++ b/servers/physics_3d/area_pair_3d_sw.cpp @@ -33,7 +33,7 @@ bool AreaPair3DSW::setup(real_t p_step) { bool result = false; - if (area->test_collision_mask(body) && CollisionSolver3DSW::solve_static(body->get_shape(body_shape), body->get_transform() * body->get_shape_transform(body_shape), area->get_shape(area_shape), area->get_transform() * area->get_shape_transform(area_shape), nullptr, this)) { + if (area->interacts_with(body) && CollisionSolver3DSW::solve_static(body->get_shape(body_shape), body->get_transform() * body->get_shape_transform(body_shape), area->get_shape(area_shape), area->get_transform() * area->get_shape_transform(area_shape), nullptr, this)) { result = true; } @@ -110,7 +110,7 @@ AreaPair3DSW::~AreaPair3DSW() { bool Area2Pair3DSW::setup(real_t p_step) { bool result = false; - if (area_a->test_collision_mask(area_b) && CollisionSolver3DSW::solve_static(area_a->get_shape(shape_a), area_a->get_transform() * area_a->get_shape_transform(shape_a), area_b->get_shape(shape_b), area_b->get_transform() * area_b->get_shape_transform(shape_b), nullptr, this)) { + if (area_a->interacts_with(area_b) && CollisionSolver3DSW::solve_static(area_a->get_shape(shape_a), area_a->get_transform() * area_a->get_shape_transform(shape_a), area_b->get_shape(shape_b), area_b->get_transform() * area_b->get_shape_transform(shape_b), nullptr, this)) { result = true; } diff --git a/servers/physics_3d/body_pair_3d_sw.cpp b/servers/physics_3d/body_pair_3d_sw.cpp index 6fc0fa8690..c27a2ecced 100644 --- a/servers/physics_3d/body_pair_3d_sw.cpp +++ b/servers/physics_3d/body_pair_3d_sw.cpp @@ -212,16 +212,16 @@ real_t combine_friction(Body3DSW *A, Body3DSW *B) { } bool BodyPair3DSW::setup(real_t p_step) { - dynamic_A = (A->get_mode() > PhysicsServer3D::BODY_MODE_KINEMATIC); - dynamic_B = (B->get_mode() > PhysicsServer3D::BODY_MODE_KINEMATIC); - - if (!A->test_collision_mask(B) || A->has_exception(B->get_self()) || B->has_exception(A->get_self())) { + if (!A->interacts_with(B) || A->has_exception(B->get_self()) || B->has_exception(A->get_self())) { collided = false; return false; } + collide_A = (A->get_mode() > PhysicsServer3D::BODY_MODE_KINEMATIC) && A->collides_with(B); + collide_B = (B->get_mode() > PhysicsServer3D::BODY_MODE_KINEMATIC) && B->collides_with(A); + report_contacts_only = false; - if (!dynamic_A && !dynamic_B) { + if (!collide_A && !collide_B) { if ((A->get_max_contacts_reported() > 0) || (B->get_max_contacts_reported() > 0)) { report_contacts_only = true; } else { @@ -250,11 +250,11 @@ bool BodyPair3DSW::setup(real_t p_step) { if (!collided) { //test ccd (currently just a raycast) - if (A->is_continuous_collision_detection_enabled() && dynamic_A && !dynamic_B) { + if (A->is_continuous_collision_detection_enabled() && collide_A) { _test_ccd(p_step, A, shape_A, xform_A, B, shape_B, xform_B); } - if (B->is_continuous_collision_detection_enabled() && dynamic_B && !dynamic_A) { + if (B->is_continuous_collision_detection_enabled() && collide_B) { _test_ccd(p_step, B, shape_B, xform_B, A, shape_A, xform_A); } @@ -293,6 +293,15 @@ bool BodyPair3DSW::pre_solve(real_t p_step) { const Basis &basis_A = A->get_transform().basis; const Basis &basis_B = B->get_transform().basis; + Basis zero_basis; + zero_basis.set_zero(); + + const Basis &inv_inertia_tensor_A = collide_A ? A->get_inv_inertia_tensor() : zero_basis; + const Basis &inv_inertia_tensor_B = collide_B ? B->get_inv_inertia_tensor() : zero_basis; + + real_t inv_mass_A = collide_A ? A->get_inv_mass() : 0.0; + real_t inv_mass_B = collide_B ? B->get_inv_mass() : 0.0; + for (int i = 0; i < contact_count; i++) { Contact &c = contacts[i]; c.active = false; @@ -303,7 +312,7 @@ bool BodyPair3DSW::pre_solve(real_t p_step) { Vector3 axis = global_A - global_B; real_t depth = axis.dot(c.normal); - if (depth <= 0) { + if (depth <= 0.0) { continue; } @@ -339,9 +348,9 @@ bool BodyPair3DSW::pre_solve(real_t p_step) { do_process = true; // Precompute normal mass, tangent mass, and bias. - Vector3 inertia_A = A->get_inv_inertia_tensor().xform(c.rA.cross(c.normal)); - Vector3 inertia_B = B->get_inv_inertia_tensor().xform(c.rB.cross(c.normal)); - real_t kNormal = A->get_inv_mass() + B->get_inv_mass(); + Vector3 inertia_A = inv_inertia_tensor_A.xform(c.rA.cross(c.normal)); + Vector3 inertia_B = inv_inertia_tensor_B.xform(c.rB.cross(c.normal)); + real_t kNormal = inv_mass_A + inv_mass_B; kNormal += c.normal.dot(inertia_A.cross(c.rA)) + c.normal.dot(inertia_B.cross(c.rB)); c.mass_normal = 1.0f / kNormal; @@ -349,10 +358,10 @@ bool BodyPair3DSW::pre_solve(real_t p_step) { c.depth = depth; Vector3 j_vec = c.normal * c.acc_normal_impulse + c.acc_tangent_impulse; - if (dynamic_A) { + if (collide_A) { A->apply_impulse(-j_vec, c.rA + A->get_center_of_mass()); } - if (dynamic_B) { + if (collide_B) { B->apply_impulse(j_vec, c.rB + B->get_center_of_mass()); } c.acc_bias_impulse = 0; @@ -378,6 +387,15 @@ void BodyPair3DSW::solve(real_t p_step) { const real_t max_bias_av = MAX_BIAS_ROTATION / p_step; + Basis zero_basis; + zero_basis.set_zero(); + + const Basis &inv_inertia_tensor_A = collide_A ? A->get_inv_inertia_tensor() : zero_basis; + const Basis &inv_inertia_tensor_B = collide_B ? B->get_inv_inertia_tensor() : zero_basis; + + real_t inv_mass_A = collide_A ? A->get_inv_mass() : 0.0; + real_t inv_mass_B = collide_B ? B->get_inv_mass() : 0.0; + for (int i = 0; i < contact_count; i++) { Contact &c = contacts[i]; if (!c.active) { @@ -401,10 +419,10 @@ void BodyPair3DSW::solve(real_t p_step) { Vector3 jb = c.normal * (c.acc_bias_impulse - jbnOld); - if (dynamic_A) { + if (collide_A) { A->apply_bias_impulse(-jb, c.rA + A->get_center_of_mass(), max_bias_av); } - if (dynamic_B) { + if (collide_B) { B->apply_bias_impulse(jb, c.rB + B->get_center_of_mass(), max_bias_av); } @@ -415,16 +433,16 @@ void BodyPair3DSW::solve(real_t p_step) { vbn = dbv.dot(c.normal); if (Math::abs(-vbn + c.bias) > MIN_VELOCITY) { - real_t jbn_com = (-vbn + c.bias) / (A->get_inv_mass() + B->get_inv_mass()); + real_t jbn_com = (-vbn + c.bias) / (inv_mass_A + inv_mass_B); real_t jbnOld_com = c.acc_bias_impulse_center_of_mass; c.acc_bias_impulse_center_of_mass = MAX(jbnOld_com + jbn_com, 0.0f); Vector3 jb_com = c.normal * (c.acc_bias_impulse_center_of_mass - jbnOld_com); - if (dynamic_A) { + if (collide_A) { A->apply_bias_impulse(-jb_com, A->get_center_of_mass(), 0.0f); } - if (dynamic_B) { + if (collide_B) { B->apply_bias_impulse(jb_com, B->get_center_of_mass(), 0.0f); } } @@ -446,10 +464,10 @@ void BodyPair3DSW::solve(real_t p_step) { Vector3 j = c.normal * (c.acc_normal_impulse - jnOld); - if (dynamic_A) { + if (collide_A) { A->apply_impulse(-j, c.rA + A->get_center_of_mass()); } - if (dynamic_B) { + if (collide_B) { B->apply_impulse(j, c.rB + B->get_center_of_mass()); } @@ -473,11 +491,11 @@ void BodyPair3DSW::solve(real_t p_step) { if (tvl > MIN_VELOCITY) { tv /= tvl; - Vector3 temp1 = A->get_inv_inertia_tensor().xform(c.rA.cross(tv)); - Vector3 temp2 = B->get_inv_inertia_tensor().xform(c.rB.cross(tv)); + Vector3 temp1 = inv_inertia_tensor_A.xform(c.rA.cross(tv)); + Vector3 temp2 = inv_inertia_tensor_B.xform(c.rB.cross(tv)); real_t t = -tvl / - (A->get_inv_mass() + B->get_inv_mass() + tv.dot(temp1.cross(c.rA) + temp2.cross(c.rB))); + (inv_mass_A + inv_mass_B + tv.dot(temp1.cross(c.rA) + temp2.cross(c.rB))); Vector3 jt = t * tv; @@ -493,10 +511,10 @@ void BodyPair3DSW::solve(real_t p_step) { jt = c.acc_tangent_impulse - jtOld; - if (dynamic_A) { + if (collide_A) { A->apply_impulse(-jt, c.rA + A->get_center_of_mass()); } - if (dynamic_B) { + if (collide_B) { B->apply_impulse(jt, c.rB + B->get_center_of_mass()); } @@ -595,13 +613,23 @@ void BodySoftBodyPair3DSW::validate_contacts() { } bool BodySoftBodyPair3DSW::setup(real_t p_step) { - body_dynamic = (body->get_mode() > PhysicsServer3D::BODY_MODE_KINEMATIC); - - if (!body->test_collision_mask(soft_body) || body->has_exception(soft_body->get_self()) || soft_body->has_exception(body->get_self())) { + if (!body->interacts_with(soft_body) || body->has_exception(soft_body->get_self()) || soft_body->has_exception(body->get_self())) { collided = false; return false; } + body_collides = (body->get_mode() > PhysicsServer3D::BODY_MODE_KINEMATIC) && body->collides_with(soft_body); + soft_body_collides = soft_body->collides_with(body); + + if (!body_collides && !soft_body_collides) { + if (body->get_max_contacts_reported() > 0) { + report_contacts_only = true; + } else { + collided = false; + return false; + } + } + const Transform3D &xform_Au = body->get_transform(); Transform3D xform_A = xform_Au * body->get_shape_transform(body_shape); @@ -639,13 +667,20 @@ bool BodySoftBodyPair3DSW::pre_solve(real_t p_step) { const Transform3D &transform_A = body->get_transform(); + Basis zero_basis; + zero_basis.set_zero(); + + const Basis &body_inv_inertia_tensor = body_collides ? body->get_inv_inertia_tensor() : zero_basis; + + real_t body_inv_mass = body_collides ? body->get_inv_mass() : 0.0; + uint32_t contact_count = contacts.size(); for (uint32_t contact_index = 0; contact_index < contact_count; ++contact_index) { Contact &c = contacts[contact_index]; c.active = false; - real_t node_inv_mass = soft_body->get_node_inv_mass(c.index_B); - if (node_inv_mass == 0.0) { + real_t node_inv_mass = soft_body_collides ? soft_body->get_node_inv_mass(c.index_B) : 0.0; + if ((node_inv_mass == 0.0) && (body_inv_mass == 0.0)) { continue; } @@ -654,15 +689,11 @@ bool BodySoftBodyPair3DSW::pre_solve(real_t p_step) { Vector3 axis = global_A - global_B; real_t depth = axis.dot(c.normal); - if (depth <= 0) { + if (depth <= 0.0) { continue; } - c.active = true; - do_process = true; - #ifdef DEBUG_ENABLED - if (space->is_debugging_contacts()) { space->add_debug_contact(global_A); space->add_debug_contact(global_B); @@ -677,13 +708,21 @@ bool BodySoftBodyPair3DSW::pre_solve(real_t p_step) { body->add_contact(global_A, -c.normal, depth, body_shape, global_B, 0, soft_body->get_instance_id(), soft_body->get_self(), crA); } - if (body_dynamic) { + if (report_contacts_only) { + collided = false; + continue; + } + + c.active = true; + do_process = true; + + if (body_collides) { body->set_active(true); } // Precompute normal mass, tangent mass, and bias. - Vector3 inertia_A = body->get_inv_inertia_tensor().xform(c.rA.cross(c.normal)); - real_t kNormal = body->get_inv_mass() + node_inv_mass; + Vector3 inertia_A = body_inv_inertia_tensor.xform(c.rA.cross(c.normal)); + real_t kNormal = body_inv_mass + node_inv_mass; kNormal += c.normal.dot(inertia_A.cross(c.rA)); c.mass_normal = 1.0f / kNormal; @@ -691,10 +730,12 @@ bool BodySoftBodyPair3DSW::pre_solve(real_t p_step) { c.depth = depth; Vector3 j_vec = c.normal * c.acc_normal_impulse + c.acc_tangent_impulse; - if (body_dynamic) { + if (body_collides) { body->apply_impulse(-j_vec, c.rA + body->get_center_of_mass()); } - soft_body->apply_node_impulse(c.index_B, j_vec); + if (soft_body_collides) { + soft_body->apply_node_impulse(c.index_B, j_vec); + } c.acc_bias_impulse = 0; c.acc_bias_impulse_center_of_mass = 0; @@ -719,6 +760,13 @@ void BodySoftBodyPair3DSW::solve(real_t p_step) { const real_t max_bias_av = MAX_BIAS_ROTATION / p_step; + Basis zero_basis; + zero_basis.set_zero(); + + const Basis &body_inv_inertia_tensor = body_collides ? body->get_inv_inertia_tensor() : zero_basis; + + real_t body_inv_mass = body_collides ? body->get_inv_mass() : 0.0; + uint32_t contact_count = contacts.size(); for (uint32_t contact_index = 0; contact_index < contact_count; ++contact_index) { Contact &c = contacts[contact_index]; @@ -728,6 +776,8 @@ void BodySoftBodyPair3DSW::solve(real_t p_step) { c.active = false; + real_t node_inv_mass = soft_body_collides ? soft_body->get_node_inv_mass(c.index_B) : 0.0; + // Bias impulse. Vector3 crbA = body->get_biased_angular_velocity().cross(c.rA); Vector3 dbv = soft_body->get_node_biased_velocity(c.index_B) - body->get_biased_linear_velocity() - crbA; @@ -741,10 +791,12 @@ void BodySoftBodyPair3DSW::solve(real_t p_step) { Vector3 jb = c.normal * (c.acc_bias_impulse - jbnOld); - if (body_dynamic) { + if (body_collides) { body->apply_bias_impulse(-jb, c.rA + body->get_center_of_mass(), max_bias_av); } - soft_body->apply_node_bias_impulse(c.index_B, jb); + if (soft_body_collides) { + soft_body->apply_node_bias_impulse(c.index_B, jb); + } crbA = body->get_biased_angular_velocity().cross(c.rA); dbv = soft_body->get_node_biased_velocity(c.index_B) - body->get_biased_linear_velocity() - crbA; @@ -752,16 +804,18 @@ void BodySoftBodyPair3DSW::solve(real_t p_step) { vbn = dbv.dot(c.normal); if (Math::abs(-vbn + c.bias) > MIN_VELOCITY) { - real_t jbn_com = (-vbn + c.bias) / (body->get_inv_mass() + soft_body->get_node_inv_mass(c.index_B)); + real_t jbn_com = (-vbn + c.bias) / (body_inv_mass + node_inv_mass); real_t jbnOld_com = c.acc_bias_impulse_center_of_mass; c.acc_bias_impulse_center_of_mass = MAX(jbnOld_com + jbn_com, 0.0f); Vector3 jb_com = c.normal * (c.acc_bias_impulse_center_of_mass - jbnOld_com); - if (body_dynamic) { + if (body_collides) { body->apply_bias_impulse(-jb_com, body->get_center_of_mass(), 0.0f); } - soft_body->apply_node_bias_impulse(c.index_B, jb_com); + if (soft_body_collides) { + soft_body->apply_node_bias_impulse(c.index_B, jb_com); + } } c.active = true; @@ -780,10 +834,12 @@ void BodySoftBodyPair3DSW::solve(real_t p_step) { Vector3 j = c.normal * (c.acc_normal_impulse - jnOld); - if (body_dynamic) { + if (body_collides) { body->apply_impulse(-j, c.rA + body->get_center_of_mass()); } - soft_body->apply_node_impulse(c.index_B, j); + if (soft_body_collides) { + soft_body->apply_node_impulse(c.index_B, j); + } c.active = true; } @@ -804,10 +860,10 @@ void BodySoftBodyPair3DSW::solve(real_t p_step) { if (tvl > MIN_VELOCITY) { tv /= tvl; - Vector3 temp1 = body->get_inv_inertia_tensor().xform(c.rA.cross(tv)); + Vector3 temp1 = body_inv_inertia_tensor.xform(c.rA.cross(tv)); real_t t = -tvl / - (body->get_inv_mass() + soft_body->get_node_inv_mass(c.index_B) + tv.dot(temp1.cross(c.rA))); + (body_inv_mass + node_inv_mass + tv.dot(temp1.cross(c.rA))); Vector3 jt = t * tv; @@ -823,10 +879,12 @@ void BodySoftBodyPair3DSW::solve(real_t p_step) { jt = c.acc_tangent_impulse - jtOld; - if (body_dynamic) { + if (body_collides) { body->apply_impulse(-jt, c.rA + body->get_center_of_mass()); } - soft_body->apply_node_impulse(c.index_B, jt); + if (soft_body_collides) { + soft_body->apply_node_impulse(c.index_B, jt); + } c.active = true; } diff --git a/servers/physics_3d/body_pair_3d_sw.h b/servers/physics_3d/body_pair_3d_sw.h index 976982d1f1..19d6a46880 100644 --- a/servers/physics_3d/body_pair_3d_sw.h +++ b/servers/physics_3d/body_pair_3d_sw.h @@ -83,8 +83,8 @@ class BodyPair3DSW : public BodyContact3DSW { int shape_A = 0; int shape_B = 0; - bool dynamic_A = false; - bool dynamic_B = false; + bool collide_A = false; + bool collide_B = false; bool report_contacts_only = false; @@ -115,7 +115,10 @@ class BodySoftBodyPair3DSW : public BodyContact3DSW { int body_shape = 0; - bool body_dynamic = false; + bool body_collides = false; + bool soft_body_collides = false; + + bool report_contacts_only = false; LocalVector<Contact> contacts; diff --git a/servers/physics_3d/collision_object_3d_sw.h b/servers/physics_3d/collision_object_3d_sw.h index b2b2fa0f50..6ffab54645 100644 --- a/servers/physics_3d/collision_object_3d_sw.h +++ b/servers/physics_3d/collision_object_3d_sw.h @@ -166,7 +166,11 @@ public: } _FORCE_INLINE_ uint32_t get_collision_mask() const { return collision_mask; } - _FORCE_INLINE_ bool test_collision_mask(CollisionObject3DSW *p_other) const { + _FORCE_INLINE_ bool collides_with(CollisionObject3DSW *p_other) const { + return p_other->collision_layer & collision_mask; + } + + _FORCE_INLINE_ bool interacts_with(CollisionObject3DSW *p_other) const { return collision_layer & p_other->collision_mask || p_other->collision_layer & collision_mask; } diff --git a/servers/physics_3d/collision_solver_3d_sat.cpp b/servers/physics_3d/collision_solver_3d_sat.cpp index 1cfb9ba3ad..6a7f2b73c5 100644 --- a/servers/physics_3d/collision_solver_3d_sat.cpp +++ b/servers/physics_3d/collision_solver_3d_sat.cpp @@ -629,9 +629,7 @@ public: _FORCE_INLINE_ bool test_axis(const Vector3 &p_axis, bool p_directional = false) { Vector3 axis = p_axis; - if (Math::abs(axis.x) < CMP_EPSILON && - Math::abs(axis.y) < CMP_EPSILON && - Math::abs(axis.z) < CMP_EPSILON) { + if (axis.is_equal_approx(Vector3())) { // strange case, try an upwards separator axis = Vector3(0.0, 1.0, 0.0); } diff --git a/servers/physics_3d/joints/generic_6dof_joint_3d_sw.h b/servers/physics_3d/joints/generic_6dof_joint_3d_sw.h index d46437e782..d0f3dbbd35 100644 --- a/servers/physics_3d/joints/generic_6dof_joint_3d_sw.h +++ b/servers/physics_3d/joints/generic_6dof_joint_3d_sw.h @@ -322,12 +322,12 @@ public: m_angularLimits[2].m_hiLimit = angularUpper.z; } - //! Retrieves the angular limit informacion + //! Retrieves the angular limit information. G6DOFRotationalLimitMotor3DSW *getRotationalLimitMotor(int index) { return &m_angularLimits[index]; } - //! Retrieves the limit informacion + //! Retrieves the limit information. G6DOFTranslationalLimitMotor3DSW *getTranslationalLimitMotor() { return &m_linearLimits; } diff --git a/servers/physics_3d/joints/slider_joint_3d_sw.cpp b/servers/physics_3d/joints/slider_joint_3d_sw.cpp index db9bdb2986..1895fe1e2e 100644 --- a/servers/physics_3d/joints/slider_joint_3d_sw.cpp +++ b/servers/physics_3d/joints/slider_joint_3d_sw.cpp @@ -200,7 +200,7 @@ void SliderJoint3DSW::solve(real_t p_step) { real_t softness = (i) ? m_softnessOrthoLin : (m_solveLinLim ? m_softnessLimLin : m_softnessDirLin); real_t restitution = (i) ? m_restitutionOrthoLin : (m_solveLinLim ? m_restitutionLimLin : m_restitutionDirLin); real_t damping = (i) ? m_dampingOrthoLin : (m_solveLinLim ? m_dampingLimLin : m_dampingDirLin); - // calcutate and apply impulse + // Calculate and apply impulse. real_t normalImpulse = softness * (restitution * depth / p_step - damping * rel_vel) * m_jacLinDiagABInv[i]; Vector3 impulse_vector = normal * normalImpulse; if (dynamic_A) { diff --git a/servers/physics_3d/physics_server_3d_sw.cpp b/servers/physics_3d/physics_server_3d_sw.cpp index f26129a404..c1a9d6259d 100644 --- a/servers/physics_3d/physics_server_3d_sw.cpp +++ b/servers/physics_3d/physics_server_3d_sw.cpp @@ -1584,6 +1584,10 @@ void PhysicsServer3DSW::set_active(bool p_active) { active = p_active; }; +void PhysicsServer3DSW::set_collision_iterations(int p_iterations) { + iterations = p_iterations; +}; + void PhysicsServer3DSW::init() { last_step = 0.001; iterations = 8; // 8? diff --git a/servers/physics_3d/physics_server_3d_sw.h b/servers/physics_3d/physics_server_3d_sw.h index 57b6385758..0ccd15fbb2 100644 --- a/servers/physics_3d/physics_server_3d_sw.h +++ b/servers/physics_3d/physics_server_3d_sw.h @@ -367,6 +367,8 @@ public: virtual void end_sync() override; virtual void finish() override; + virtual void set_collision_iterations(int p_iterations) override; + virtual bool is_flushing_queries() const override { return flushing_queries; } int get_process_info(ProcessInfo p_info) override; diff --git a/servers/physics_3d/physics_server_3d_wrap_mt.h b/servers/physics_3d/physics_server_3d_wrap_mt.h index bda2e30dd1..9beec22bcd 100644 --- a/servers/physics_3d/physics_server_3d_wrap_mt.h +++ b/servers/physics_3d/physics_server_3d_wrap_mt.h @@ -377,6 +377,7 @@ public: FUNC1(free, RID); FUNC1(set_active, bool); + FUNC1(set_collision_iterations, int); virtual void init() override; virtual void step(real_t p_step) override; diff --git a/servers/physics_3d/shape_3d_sw.cpp b/servers/physics_3d/shape_3d_sw.cpp index 2ffab0c923..04a174f9c8 100644 --- a/servers/physics_3d/shape_3d_sw.cpp +++ b/servers/physics_3d/shape_3d_sw.cpp @@ -1783,7 +1783,7 @@ bool HeightMapShape3DSW::intersect_segment(const Vector3 &p_begin, const Vector3 int z = floor(local_begin.z); // Workaround cases where the ray starts at an integer position. - if (Math::abs(cross_x) < CMP_EPSILON) { + if (Math::is_zero_approx(cross_x)) { cross_x += delta_x; // If going backwards, we should ignore the position we would get by the above flooring, // because the ray is not heading in that direction. @@ -1792,7 +1792,7 @@ bool HeightMapShape3DSW::intersect_segment(const Vector3 &p_begin, const Vector3 } } - if (Math::abs(cross_z) < CMP_EPSILON) { + if (Math::is_zero_approx(cross_z)) { cross_z += delta_z; if (z_step == -1) { z -= 1; diff --git a/servers/physics_3d/shape_3d_sw.h b/servers/physics_3d/shape_3d_sw.h index bc8bd3e695..0d1b7cc3d7 100644 --- a/servers/physics_3d/shape_3d_sw.h +++ b/servers/physics_3d/shape_3d_sw.h @@ -128,7 +128,7 @@ class PlaneShape3DSW : public Shape3DSW { public: Plane get_plane() const; - virtual real_t get_area() const { return Math_INF; } + virtual real_t get_area() const { return INFINITY; } virtual PhysicsServer3D::ShapeType get_type() const { return PhysicsServer3D::SHAPE_PLANE; } virtual void project_range(const Vector3 &p_normal, const Transform3D &p_transform, real_t &r_min, real_t &r_max) const; virtual Vector3 get_support(const Vector3 &p_normal) const; diff --git a/servers/physics_3d/soft_body_3d_sw.cpp b/servers/physics_3d/soft_body_3d_sw.cpp index 63a0fe11ba..724125bea8 100644 --- a/servers/physics_3d/soft_body_3d_sw.cpp +++ b/servers/physics_3d/soft_body_3d_sw.cpp @@ -1172,7 +1172,7 @@ struct _SoftBodyIntersectSegmentInfo { Vector3 dir; Vector3 hit_position; uint32_t hit_face_index = -1; - real_t hit_dist_sq = Math_INF; + real_t hit_dist_sq = INFINITY; static bool process_hit(uint32_t p_face_index, void *p_userdata) { _SoftBodyIntersectSegmentInfo &query_info = *(_SoftBodyIntersectSegmentInfo *)(p_userdata); @@ -1203,7 +1203,7 @@ bool SoftBodyShape3DSW::intersect_segment(const Vector3 &p_begin, const Vector3 soft_body->query_ray(p_begin, p_end, _SoftBodyIntersectSegmentInfo::process_hit, &query_info); - if (query_info.hit_dist_sq != Math_INF) { + if (query_info.hit_dist_sq != INFINITY) { r_result = query_info.hit_position; r_normal = soft_body->get_face_normal(query_info.hit_face_index); return true; diff --git a/servers/physics_3d/space_3d_sw.cpp b/servers/physics_3d/space_3d_sw.cpp index eff480396d..1037243d3b 100644 --- a/servers/physics_3d/space_3d_sw.cpp +++ b/servers/physics_3d/space_3d_sw.cpp @@ -255,6 +255,8 @@ bool PhysicsDirectSpaceState3DSW::cast_motion(const RID &p_shape, const Transfor bool best_first = true; + Vector3 motion_normal = p_motion.normalized(); + Vector3 closest_A, closest_B; for (int i = 0; i < amount; i++) { @@ -270,7 +272,7 @@ bool PhysicsDirectSpaceState3DSW::cast_motion(const RID &p_shape, const Transfor int shape_idx = space->intersection_query_subindex_results[i]; Vector3 point_A, point_B; - Vector3 sep_axis = p_motion.normalized(); + Vector3 sep_axis = motion_normal; Transform3D col_obj_xform = col_obj->get_transform() * col_obj->get_shape_transform(shape_idx); //test initial overlap, does it collide if going all the way? @@ -279,35 +281,47 @@ bool PhysicsDirectSpaceState3DSW::cast_motion(const RID &p_shape, const Transfor } //test initial overlap, ignore objects it's inside of. - sep_axis = p_motion.normalized(); + sep_axis = motion_normal; if (!CollisionSolver3DSW::solve_distance(shape, p_xform, col_obj->get_shape(shape_idx), col_obj_xform, point_A, point_B, aabb, &sep_axis)) { continue; } //just do kinematic solving - real_t low = 0; - real_t hi = 1; - Vector3 mnormal = p_motion.normalized(); - + real_t low = 0.0; + real_t hi = 1.0; + real_t fraction_coeff = 0.5; for (int j = 0; j < 8; j++) { //steps should be customizable.. + real_t fraction = low + (hi - low) * fraction_coeff; - real_t ofs = (low + hi) * 0.5; - - Vector3 sep = mnormal; //important optimization for this to work fast enough - - mshape.motion = xform_inv.basis.xform(p_motion * ofs); + mshape.motion = xform_inv.basis.xform(p_motion * fraction); Vector3 lA, lB; - + Vector3 sep = motion_normal; //important optimization for this to work fast enough bool collided = !CollisionSolver3DSW::solve_distance(&mshape, p_xform, col_obj->get_shape(shape_idx), col_obj_xform, lA, lB, aabb, &sep); if (collided) { - hi = ofs; + hi = fraction; + if ((j == 0) || (low > 0.0)) { // Did it not collide before? + // When alternating or first iteration, use dichotomy. + fraction_coeff = 0.5; + } else { + // When colliding again, converge faster towards low fraction + // for more accurate results with long motions that collide near the start. + fraction_coeff = 0.25; + } } else { point_A = lA; point_B = lB; - low = ofs; + low = fraction; + if ((j == 0) || (hi < 1.0)) { // Did it collide before? + // When alternating or first iteration, use dichotomy. + fraction_coeff = 0.5; + } else { + // When not colliding again, converge faster towards high fraction + // for more accurate results with long motions that collide near the end. + fraction_coeff = 0.75; + } } } @@ -535,7 +549,7 @@ int Space3DSW::_cull_aabb_for_body(Body3DSW *p_body, const AABB &p_aabb) { keep = false; } else if (intersection_query_results[i]->get_type() == CollisionObject3DSW::TYPE_SOFT_BODY) { keep = false; - } else if ((static_cast<Body3DSW *>(intersection_query_results[i])->test_collision_mask(p_body)) == 0) { + } else if (!p_body->collides_with(static_cast<Body3DSW *>(intersection_query_results[i]))) { keep = false; } else if (static_cast<Body3DSW *>(intersection_query_results[i])->has_exception(p_body->get_self()) || p_body->has_exception(intersection_query_results[i]->get_self())) { keep = false; @@ -902,27 +916,40 @@ bool Space3DSW::test_body_motion(Body3DSW *p_body, const Transform3D &p_from, co } //just do kinematic solving - real_t low = 0; - real_t hi = 1; - + real_t low = 0.0; + real_t hi = 1.0; + real_t fraction_coeff = 0.5; for (int k = 0; k < 8; k++) { //steps should be customizable.. + real_t fraction = low + (hi - low) * fraction_coeff; - real_t ofs = (low + hi) * 0.5; - - Vector3 sep = motion_normal; //important optimization for this to work fast enough - - mshape.motion = body_shape_xform_inv.basis.xform(p_motion * ofs); + mshape.motion = body_shape_xform_inv.basis.xform(p_motion * fraction); Vector3 lA, lB; - + Vector3 sep = motion_normal; //important optimization for this to work fast enough bool collided = !CollisionSolver3DSW::solve_distance(&mshape, body_shape_xform, col_obj->get_shape(shape_idx), col_obj_xform, lA, lB, motion_aabb, &sep); if (collided) { - hi = ofs; + hi = fraction; + if ((k == 0) || (low > 0.0)) { // Did it not collide before? + // When alternating or first iteration, use dichotomy. + fraction_coeff = 0.5; + } else { + // When colliding again, converge faster towards low fraction + // for more accurate results with long motions that collide near the start. + fraction_coeff = 0.25; + } } else { point_A = lA; point_B = lB; - low = ofs; + low = fraction; + if ((k == 0) || (hi < 1.0)) { // Did it collide before? + // When alternating or first iteration, use dichotomy. + fraction_coeff = 0.5; + } else { + // When not colliding again, converge faster towards high fraction + // for more accurate results with long motions that collide near the end. + fraction_coeff = 0.75; + } } } @@ -1043,7 +1070,7 @@ bool Space3DSW::test_body_motion(Body3DSW *p_body, const Transform3D &p_from, co } void *Space3DSW::_broadphase_pair(CollisionObject3DSW *A, int p_subindex_A, CollisionObject3DSW *B, int p_subindex_B, void *p_self) { - if (!A->test_collision_mask(B)) { + if (!A->interacts_with(B)) { return nullptr; } diff --git a/servers/physics_server_2d.cpp b/servers/physics_server_2d.cpp index ec0ff57a5e..e8272f377e 100644 --- a/servers/physics_server_2d.cpp +++ b/servers/physics_server_2d.cpp @@ -498,12 +498,16 @@ void PhysicsTestMotionResult2D::_bind_methods() { /////////////////////////////////////// -bool PhysicsServer2D::_body_test_motion(RID p_body, const Transform2D &p_from, const Vector2 &p_motion, bool p_infinite_inertia, real_t p_margin, const Ref<PhysicsTestMotionResult2D> &p_result) { +bool PhysicsServer2D::_body_test_motion(RID p_body, const Transform2D &p_from, const Vector2 &p_motion, bool p_infinite_inertia, real_t p_margin, const Ref<PhysicsTestMotionResult2D> &p_result, bool p_exclude_raycast_shapes, const Vector<RID> &p_exclude) { MotionResult *r = nullptr; if (p_result.is_valid()) { r = p_result->get_result_ptr(); } - return body_test_motion(p_body, p_from, p_motion, p_infinite_inertia, p_margin, r); + Set<RID> exclude; + for (int i = 0; i < p_exclude.size(); i++) { + exclude.insert(p_exclude[i]); + } + return body_test_motion(p_body, p_from, p_motion, p_infinite_inertia, p_margin, r, p_exclude_raycast_shapes, exclude); } void PhysicsServer2D::_bind_methods() { @@ -630,7 +634,7 @@ void PhysicsServer2D::_bind_methods() { ClassDB::bind_method(D_METHOD("body_set_force_integration_callback", "body", "callable", "userdata"), &PhysicsServer2D::body_set_force_integration_callback, DEFVAL(Variant())); - ClassDB::bind_method(D_METHOD("body_test_motion", "body", "from", "motion", "infinite_inertia", "margin", "result"), &PhysicsServer2D::_body_test_motion, DEFVAL(0.08), DEFVAL(Variant())); + ClassDB::bind_method(D_METHOD("body_test_motion", "body", "from", "motion", "infinite_inertia", "margin", "result", "exclude_raycast_shapes", "exclude"), &PhysicsServer2D::_body_test_motion, DEFVAL(0.08), DEFVAL(Variant()), DEFVAL(true), DEFVAL(Array())); ClassDB::bind_method(D_METHOD("body_get_direct_state", "body"), &PhysicsServer2D::body_get_direct_state); diff --git a/servers/physics_server_2d.h b/servers/physics_server_2d.h index 6737aacaf0..8542b54838 100644 --- a/servers/physics_server_2d.h +++ b/servers/physics_server_2d.h @@ -208,7 +208,7 @@ class PhysicsServer2D : public Object { static PhysicsServer2D *singleton; - virtual bool _body_test_motion(RID p_body, const Transform2D &p_from, const Vector2 &p_motion, bool p_infinite_inertia, real_t p_margin = 0.08, const Ref<PhysicsTestMotionResult2D> &p_result = Ref<PhysicsTestMotionResult2D>()); + virtual bool _body_test_motion(RID p_body, const Transform2D &p_from, const Vector2 &p_motion, bool p_infinite_inertia, real_t p_margin = 0.08, const Ref<PhysicsTestMotionResult2D> &p_result = Ref<PhysicsTestMotionResult2D>(), bool p_exclude_raycast_shapes = true, const Vector<RID> &p_exclude = Vector<RID>()); protected: static void _bind_methods(); @@ -481,7 +481,7 @@ public: Variant collider_metadata; }; - virtual bool body_test_motion(RID p_body, const Transform2D &p_from, const Vector2 &p_motion, bool p_infinite_inertia, real_t p_margin = 0.08, MotionResult *r_result = nullptr, bool p_exclude_raycast_shapes = true) = 0; + virtual bool body_test_motion(RID p_body, const Transform2D &p_from, const Vector2 &p_motion, bool p_infinite_inertia, real_t p_margin = 0.08, MotionResult *r_result = nullptr, bool p_exclude_raycast_shapes = true, const Set<RID> &p_exclude = Set<RID>()) = 0; struct SeparationResult { real_t collision_depth; @@ -564,7 +564,7 @@ public: virtual bool is_flushing_queries() const = 0; - virtual void set_collision_iterations(int iterations) = 0; + virtual void set_collision_iterations(int p_iterations) = 0; enum ProcessInfo { INFO_ACTIVE_OBJECTS, diff --git a/servers/physics_server_3d.cpp b/servers/physics_server_3d.cpp index 7a0253506c..3ed8841119 100644 --- a/servers/physics_server_3d.cpp +++ b/servers/physics_server_3d.cpp @@ -740,6 +740,8 @@ void PhysicsServer3D::_bind_methods() { ClassDB::bind_method(D_METHOD("set_active", "active"), &PhysicsServer3D::set_active); + ClassDB::bind_method(D_METHOD("set_collision_iterations", "iterations"), &PhysicsServer3D::set_collision_iterations); + ClassDB::bind_method(D_METHOD("get_process_info", "process_info"), &PhysicsServer3D::get_process_info); BIND_ENUM_CONSTANT(SHAPE_PLANE); diff --git a/servers/physics_server_3d.h b/servers/physics_server_3d.h index 78fc026747..17bae9a057 100644 --- a/servers/physics_server_3d.h +++ b/servers/physics_server_3d.h @@ -740,6 +740,8 @@ public: virtual bool is_flushing_queries() const = 0; + virtual void set_collision_iterations(int p_iterations) = 0; + enum ProcessInfo { INFO_ACTIVE_OBJECTS, INFO_COLLISION_PAIRS, diff --git a/servers/register_server_types.cpp b/servers/register_server_types.cpp index 717b4e8d14..857f112102 100644 --- a/servers/register_server_types.cpp +++ b/servers/register_server_types.cpp @@ -205,7 +205,7 @@ void register_server_types() { GDREGISTER_CLASS(RDPipelineColorBlendStateAttachment); GDREGISTER_CLASS(RDPipelineColorBlendState); GDREGISTER_CLASS(RDShaderSource); - GDREGISTER_CLASS(RDShaderBytecode); + GDREGISTER_CLASS(RDShaderSPIRV); GDREGISTER_CLASS(RDShaderFile); GDREGISTER_CLASS(RDPipelineSpecializationConstant); diff --git a/servers/rendering/rasterizer_dummy.h b/servers/rendering/rasterizer_dummy.h index f22ca738ae..b7cf0983af 100644 --- a/servers/rendering/rasterizer_dummy.h +++ b/servers/rendering/rasterizer_dummy.h @@ -61,6 +61,7 @@ public: void geometry_instance_pair_reflection_probe_instances(GeometryInstance *p_geometry_instance, const RID *p_reflection_probe_instances, uint32_t p_reflection_probe_instance_count) override {} void geometry_instance_pair_decal_instances(GeometryInstance *p_geometry_instance, const RID *p_decal_instances, uint32_t p_decal_instance_count) override {} void geometry_instance_pair_voxel_gi_instances(GeometryInstance *p_geometry_instance, const RID *p_voxel_gi_instances, uint32_t p_voxel_gi_instance_count) override {} + void geometry_instance_set_softshadow_projector_pairing(GeometryInstance *p_geometry_instance, bool p_softshadow, bool p_projector) override {} void geometry_instance_free(GeometryInstance *p_geometry_instance) override {} @@ -200,6 +201,9 @@ public: void update() override {} void sdfgi_set_debug_probe_select(const Vector3 &p_position, const Vector3 &p_dir) override {} + virtual void decals_set_filter(RS::DecalFilter p_filter) override {} + virtual void light_projectors_set_filter(RS::LightProjectorFilter p_filter) override {} + RasterizerSceneDummy() {} ~RasterizerSceneDummy() {} }; @@ -413,6 +417,7 @@ public: RS::LightOmniShadowMode light_omni_get_shadow_mode(RID p_light) override { return RS::LIGHT_OMNI_SHADOW_DUAL_PARABOLOID; } bool light_has_shadow(RID p_light) const override { return false; } + bool light_has_projector(RID p_light) const override { return false; } RS::LightType light_get_type(RID p_light) const override { return RS::LIGHT_OMNI; } AABB light_get_aabb(RID p_light) const override { return AABB(); } diff --git a/servers/rendering/renderer_rd/cluster_builder_rd.h b/servers/rendering/renderer_rd/cluster_builder_rd.h index ebb81abdad..c0c03eb26a 100644 --- a/servers/rendering/renderer_rd/cluster_builder_rd.h +++ b/servers/rendering/renderer_rd/cluster_builder_rd.h @@ -235,7 +235,7 @@ public: Transform3D xform = view_xform * p_transform; float radius = xform.basis.get_uniform_scale(); - if (radius > 0.98 || radius < 1.02) { + if (radius < 0.98 || radius > 1.02) { xform.basis.orthonormalize(); } diff --git a/servers/rendering/renderer_rd/effects_rd.cpp b/servers/rendering/renderer_rd/effects_rd.cpp index 5cf8895c8e..699f4a4b90 100644 --- a/servers/rendering/renderer_rd/effects_rd.cpp +++ b/servers/rendering/renderer_rd/effects_rd.cpp @@ -37,6 +37,10 @@ #include "servers/rendering/renderer_rd/renderer_compositor_rd.h" #include "thirdparty/misc/cubemap_coeffs.h" +bool EffectsRD::get_prefer_raster_effects() { + return prefer_raster_effects; +} + static _FORCE_INLINE_ void store_camera(const CameraMatrix &p_mtx, float *p_array) { for (int i = 0; i < 4; i++) { for (int j = 0; j < 4; j++) { @@ -383,6 +387,8 @@ void EffectsRD::set_color(RID p_dest_texture, const Color &p_color, const Rect2i } void EffectsRD::gaussian_blur(RID p_source_rd_texture, RID p_texture, RID p_back_texture, const Rect2i &p_region, bool p_8bit_dst) { + ERR_FAIL_COND_MSG(!prefer_raster_effects, "Can't use the compute version of the gaussian blur with the mobile renderer."); + memset(©.push_constant, 0, sizeof(CopyPushConstant)); uint32_t base_flags = 0; @@ -416,6 +422,8 @@ void EffectsRD::gaussian_blur(RID p_source_rd_texture, RID p_texture, RID p_back } void EffectsRD::gaussian_glow(RID p_source_rd_texture, RID p_back_texture, const Size2i &p_size, float p_strength, bool p_high_quality, bool p_first_pass, float p_luminance_cap, float p_exposure, float p_bloom, float p_hdr_bleed_treshold, float p_hdr_bleed_scale, RID p_auto_exposure, float p_auto_exposure_grey) { + ERR_FAIL_COND_MSG(prefer_raster_effects, "Can't use the compute version of the gaussian glow with the mobile renderer."); + memset(©.push_constant, 0, sizeof(CopyPushConstant)); CopyMode copy_mode = p_first_pass && p_auto_exposure.is_valid() ? COPY_MODE_GAUSSIAN_GLOW_AUTO_EXPOSURE : COPY_MODE_GAUSSIAN_GLOW; @@ -449,6 +457,57 @@ void EffectsRD::gaussian_glow(RID p_source_rd_texture, RID p_back_texture, const RD::get_singleton()->compute_list_end(); } +void EffectsRD::gaussian_glow_raster(RID p_source_rd_texture, RID p_framebuffer_half, RID p_rd_texture_half, RID p_dest_framebuffer, const Vector2 &p_pixel_size, float p_strength, bool p_high_quality, bool p_first_pass, float p_luminance_cap, float p_exposure, float p_bloom, float p_hdr_bleed_treshold, float p_hdr_bleed_scale, RID p_auto_exposure, float p_auto_exposure_grey) { + ERR_FAIL_COND_MSG(!prefer_raster_effects, "Can't use the raster version of the gaussian glow with the clustered renderer."); + + memset(&blur_raster.push_constant, 0, sizeof(BlurRasterPushConstant)); + + BlurRasterMode blur_mode = p_first_pass && p_auto_exposure.is_valid() ? BLUR_MODE_GAUSSIAN_GLOW_AUTO_EXPOSURE : BLUR_MODE_GAUSSIAN_GLOW; + uint32_t base_flags = 0; + + blur_raster.push_constant.pixel_size[0] = p_pixel_size.x; + blur_raster.push_constant.pixel_size[1] = p_pixel_size.y; + + blur_raster.push_constant.glow_strength = p_strength; + blur_raster.push_constant.glow_bloom = p_bloom; + blur_raster.push_constant.glow_hdr_threshold = p_hdr_bleed_treshold; + blur_raster.push_constant.glow_hdr_scale = p_hdr_bleed_scale; + blur_raster.push_constant.glow_exposure = p_exposure; + blur_raster.push_constant.glow_white = 0; //actually unused + blur_raster.push_constant.glow_luminance_cap = p_luminance_cap; + + blur_raster.push_constant.glow_auto_exposure_grey = p_auto_exposure_grey; //unused also + + //HORIZONTAL + RD::DrawListID draw_list = RD::get_singleton()->draw_list_begin(p_framebuffer_half, RD::INITIAL_ACTION_KEEP, RD::FINAL_ACTION_READ, RD::INITIAL_ACTION_KEEP, RD::FINAL_ACTION_DISCARD); + RD::get_singleton()->draw_list_bind_render_pipeline(draw_list, blur_raster.pipelines[blur_mode].get_render_pipeline(RD::INVALID_ID, RD::get_singleton()->framebuffer_get_format(p_framebuffer_half))); + RD::get_singleton()->draw_list_bind_uniform_set(draw_list, _get_uniform_set_from_texture(p_source_rd_texture), 0); + if (p_auto_exposure.is_valid() && p_first_pass) { + RD::get_singleton()->draw_list_bind_uniform_set(draw_list, _get_uniform_set_from_texture(p_auto_exposure), 1); + } + RD::get_singleton()->draw_list_bind_index_array(draw_list, index_array); + + blur_raster.push_constant.flags = base_flags | BLUR_FLAG_HORIZONTAL | (p_first_pass ? BLUR_FLAG_GLOW_FIRST_PASS : 0); + RD::get_singleton()->draw_list_set_push_constant(draw_list, &blur_raster.push_constant, sizeof(BlurRasterPushConstant)); + + RD::get_singleton()->draw_list_draw(draw_list, true); + RD::get_singleton()->draw_list_end(); + + blur_mode = BLUR_MODE_GAUSSIAN_GLOW; + + //VERTICAL + draw_list = RD::get_singleton()->draw_list_begin(p_dest_framebuffer, RD::INITIAL_ACTION_KEEP, RD::FINAL_ACTION_READ, RD::INITIAL_ACTION_KEEP, RD::FINAL_ACTION_DISCARD); + RD::get_singleton()->draw_list_bind_render_pipeline(draw_list, blur_raster.pipelines[blur_mode].get_render_pipeline(RD::INVALID_ID, RD::get_singleton()->framebuffer_get_format(p_dest_framebuffer))); + RD::get_singleton()->draw_list_bind_uniform_set(draw_list, _get_uniform_set_from_texture(p_rd_texture_half), 0); + RD::get_singleton()->draw_list_bind_index_array(draw_list, index_array); + + blur_raster.push_constant.flags = base_flags; + RD::get_singleton()->draw_list_set_push_constant(draw_list, &blur_raster.push_constant, sizeof(BlurRasterPushConstant)); + + RD::get_singleton()->draw_list_draw(draw_list, true); + RD::get_singleton()->draw_list_end(); +} + void EffectsRD::screen_space_reflection(RID p_diffuse, RID p_normal_roughness, RenderingServer::EnvironmentSSRRoughnessQuality p_roughness_quality, RID p_blur_radius, RID p_blur_radius2, RID p_metallic, const Color &p_metallic_mask, RID p_depth, RID p_scale_depth, RID p_scale_normal, RID p_output, RID p_output_blur, const Size2i &p_screen_size, int p_max_steps, float p_fade_in, float p_fade_out, float p_tolerance, const CameraMatrix &p_camera) { RD::ComputeListID compute_list = RD::get_singleton()->compute_list_begin(); @@ -736,6 +795,8 @@ void EffectsRD::tonemapper(RID p_source_color, RID p_dst_framebuffer, const Tone } void EffectsRD::luminance_reduction(RID p_source_texture, const Size2i p_source_size, const Vector<RID> p_reduce, RID p_prev_luminance, float p_min_luminance, float p_max_luminance, float p_adjust, bool p_set) { + ERR_FAIL_COND_MSG(prefer_raster_effects, "Can't use compute version of luminance reduction with the mobile renderer."); + luminance_reduce.push_constant.source_size[0] = p_source_size.x; luminance_reduce.push_constant.source_size[1] = p_source_size.y; luminance_reduce.push_constant.max_luminance = p_max_luminance; @@ -774,7 +835,41 @@ void EffectsRD::luminance_reduction(RID p_source_texture, const Size2i p_source_ RD::get_singleton()->compute_list_end(); } +void EffectsRD::luminance_reduction_raster(RID p_source_texture, const Size2i p_source_size, const Vector<RID> p_reduce, Vector<RID> p_fb, RID p_prev_luminance, float p_min_luminance, float p_max_luminance, float p_adjust, bool p_set) { + ERR_FAIL_COND_MSG(!prefer_raster_effects, "Can't use raster version of luminance reduction with the clustered renderer."); + ERR_FAIL_COND_MSG(p_reduce.size() != p_fb.size(), "Incorrect frame buffer account for luminance reduction."); + + luminance_reduce_raster.push_constant.max_luminance = p_max_luminance; + luminance_reduce_raster.push_constant.min_luminance = p_min_luminance; + luminance_reduce_raster.push_constant.exposure_adjust = p_adjust; + + for (int i = 0; i < p_reduce.size(); i++) { + luminance_reduce_raster.push_constant.source_size[0] = i == 0 ? p_source_size.x : luminance_reduce_raster.push_constant.dest_size[0]; + luminance_reduce_raster.push_constant.source_size[1] = i == 0 ? p_source_size.y : luminance_reduce_raster.push_constant.dest_size[1]; + luminance_reduce_raster.push_constant.dest_size[0] = MAX(luminance_reduce_raster.push_constant.source_size[0] / 8, 1); + luminance_reduce_raster.push_constant.dest_size[1] = MAX(luminance_reduce_raster.push_constant.source_size[1] / 8, 1); + + bool final = !p_set && (luminance_reduce_raster.push_constant.dest_size[0] == 1) && (luminance_reduce_raster.push_constant.dest_size[1] == 1); + LuminanceReduceRasterMode mode = final ? LUMINANCE_REDUCE_FRAGMENT_FINAL : (i == 0 ? LUMINANCE_REDUCE_FRAGMENT_FIRST : LUMINANCE_REDUCE_FRAGMENT); + + RD::DrawListID draw_list = RD::get_singleton()->draw_list_begin(p_fb[i], RD::INITIAL_ACTION_KEEP, RD::FINAL_ACTION_READ, RD::INITIAL_ACTION_KEEP, RD::FINAL_ACTION_DISCARD); + RD::get_singleton()->draw_list_bind_render_pipeline(draw_list, luminance_reduce_raster.pipelines[mode].get_render_pipeline(RD::INVALID_ID, RD::get_singleton()->framebuffer_get_format(p_fb[i]))); + RD::get_singleton()->draw_list_bind_uniform_set(draw_list, _get_uniform_set_from_texture(i == 0 ? p_source_texture : p_reduce[i - 1]), 0); + if (final) { + RD::get_singleton()->draw_list_bind_uniform_set(draw_list, _get_uniform_set_from_texture(p_prev_luminance), 1); + } + RD::get_singleton()->draw_list_bind_index_array(draw_list, index_array); + + RD::get_singleton()->draw_list_set_push_constant(draw_list, &luminance_reduce_raster.push_constant, sizeof(LuminanceReduceRasterPushConstant)); + + RD::get_singleton()->draw_list_draw(draw_list, true); + RD::get_singleton()->draw_list_end(); + } +} + void EffectsRD::bokeh_dof(RID p_base_texture, RID p_depth_texture, const Size2i &p_base_texture_size, RID p_secondary_texture, RID p_halfsize_texture1, RID p_halfsize_texture2, bool p_dof_far, float p_dof_far_begin, float p_dof_far_size, bool p_dof_near, float p_dof_near_begin, float p_dof_near_size, float p_bokeh_size, RenderingServer::DOFBokehShape p_bokeh_shape, RS::DOFBlurQuality p_quality, bool p_use_jitter, float p_cam_znear, float p_cam_zfar, bool p_cam_orthogonal) { + ERR_FAIL_COND_MSG(prefer_raster_effects, "Can't use compute version of BOKEH DOF with the mobile renderer."); + bokeh.push_constant.blur_far_active = p_dof_far; bokeh.push_constant.blur_far_begin = p_dof_far_begin; bokeh.push_constant.blur_far_end = p_dof_far_begin + p_dof_far_size; @@ -924,6 +1019,78 @@ void EffectsRD::bokeh_dof(RID p_base_texture, RID p_depth_texture, const Size2i RD::get_singleton()->compute_list_end(); } +void EffectsRD::blur_dof_raster(RID p_base_texture, RID p_depth_texture, const Size2i &p_base_texture_size, RID p_base_fb, RID p_secondary_texture, RID p_secondary_fb, bool p_dof_far, float p_dof_far_begin, float p_dof_far_size, bool p_dof_near, float p_dof_near_begin, float p_dof_near_size, float p_dof_blur_amount, RS::DOFBlurQuality p_quality, float p_cam_znear, float p_cam_zfar, bool p_cam_orthogonal) { + ERR_FAIL_COND_MSG(!prefer_raster_effects, "Can't use blur DOF with the clustered renderer."); + + memset(&blur_raster.push_constant, 0, sizeof(BlurRasterPushConstant)); + + BlurRasterMode blur_mode; + int qsteps[4] = { 4, 4, 10, 20 }; + uint32_t base_flags = p_cam_orthogonal ? BLUR_FLAG_USE_ORTHOGONAL_PROJECTION : 0; + + Vector2 pixel_size = Vector2(1.0 / p_base_texture_size.width, 1.0 / p_base_texture_size.height); + + blur_raster.push_constant.dof_radius = (p_dof_blur_amount * p_dof_blur_amount) / qsteps[p_quality]; + blur_raster.push_constant.pixel_size[0] = pixel_size.x; + blur_raster.push_constant.pixel_size[1] = pixel_size.y; + blur_raster.push_constant.camera_z_far = p_cam_zfar; + blur_raster.push_constant.camera_z_near = p_cam_znear; + + if (p_dof_far || p_dof_near) { + if (p_quality == RS::DOF_BLUR_QUALITY_HIGH) { + blur_mode = BLUR_MODE_DOF_HIGH; + } else if (p_quality == RS::DOF_BLUR_QUALITY_MEDIUM) { + blur_mode = BLUR_MODE_DOF_MEDIUM; + } else { // for LOW or VERYLOW we use LOW + blur_mode = BLUR_MODE_DOF_LOW; + } + + if (p_dof_far) { + base_flags |= BLUR_FLAG_DOF_FAR; + blur_raster.push_constant.dof_far_begin = p_dof_far_begin; + blur_raster.push_constant.dof_far_end = p_dof_far_begin + p_dof_far_size; + } + + if (p_dof_near) { + base_flags |= BLUR_FLAG_DOF_NEAR; + blur_raster.push_constant.dof_near_begin = p_dof_near_begin; + blur_raster.push_constant.dof_near_end = p_dof_near_begin - p_dof_near_size; + } + + //HORIZONTAL + RD::DrawListID draw_list = RD::get_singleton()->draw_list_begin(p_secondary_fb, RD::INITIAL_ACTION_KEEP, RD::FINAL_ACTION_READ, RD::INITIAL_ACTION_KEEP, RD::FINAL_ACTION_DISCARD); + RD::get_singleton()->draw_list_bind_render_pipeline(draw_list, blur_raster.pipelines[blur_mode].get_render_pipeline(RD::INVALID_ID, RD::get_singleton()->framebuffer_get_format(p_secondary_fb))); + RD::get_singleton()->draw_list_bind_uniform_set(draw_list, _get_uniform_set_from_texture(p_base_texture), 0); + RD::get_singleton()->draw_list_bind_uniform_set(draw_list, _get_uniform_set_from_texture(p_depth_texture), 1); + RD::get_singleton()->draw_list_bind_index_array(draw_list, index_array); + + blur_raster.push_constant.flags = base_flags | BLUR_FLAG_HORIZONTAL; + blur_raster.push_constant.dof_dir[0] = 1.0; + blur_raster.push_constant.dof_dir[1] = 0.0; + + RD::get_singleton()->draw_list_set_push_constant(draw_list, &blur_raster.push_constant, sizeof(BlurRasterPushConstant)); + + RD::get_singleton()->draw_list_draw(draw_list, true); + RD::get_singleton()->draw_list_end(); + + //VERTICAL + draw_list = RD::get_singleton()->draw_list_begin(p_base_fb, RD::INITIAL_ACTION_KEEP, RD::FINAL_ACTION_READ, RD::INITIAL_ACTION_KEEP, RD::FINAL_ACTION_DISCARD); + RD::get_singleton()->draw_list_bind_render_pipeline(draw_list, blur_raster.pipelines[blur_mode].get_render_pipeline(RD::INVALID_ID, RD::get_singleton()->framebuffer_get_format(p_base_fb))); + RD::get_singleton()->draw_list_bind_uniform_set(draw_list, _get_uniform_set_from_texture(p_secondary_texture), 0); + RD::get_singleton()->draw_list_bind_uniform_set(draw_list, _get_uniform_set_from_texture(p_depth_texture), 1); + RD::get_singleton()->draw_list_bind_index_array(draw_list, index_array); + + blur_raster.push_constant.flags = base_flags; + blur_raster.push_constant.dof_dir[0] = 0.0; + blur_raster.push_constant.dof_dir[1] = 1.0; + + RD::get_singleton()->draw_list_set_push_constant(draw_list, &blur_raster.push_constant, sizeof(BlurRasterPushConstant)); + + RD::get_singleton()->draw_list_draw(draw_list, true); + RD::get_singleton()->draw_list_end(); + } +} + void EffectsRD::gather_ssao(RD::ComputeListID p_compute_list, const Vector<RID> p_ao_slices, const SSAOSettings &p_settings, bool p_adaptive_base_pass, RID p_gather_uniform_set, RID p_importance_map_uniform_set) { RD::get_singleton()->compute_list_bind_uniform_set(p_compute_list, p_gather_uniform_set, 0); if ((p_settings.quality == RS::ENV_SSAO_QUALITY_ULTRA) && !p_adaptive_base_pass) { @@ -1188,8 +1355,9 @@ void EffectsRD::generate_ssao(RID p_depth_buffer, RID p_normal_buffer, RID p_dep if (p_settings.quality > RS::ENV_SSAO_QUALITY_VERY_LOW) { if (pass < blur_passes - 2) { blur_pipeline = SSAO_BLUR_PASS_WIDE; + } else { + blur_pipeline = SSAO_BLUR_PASS_SMART; } - blur_pipeline = SSAO_BLUR_PASS_SMART; } for (int i = 0; i < 4; i++) { @@ -1283,7 +1451,9 @@ void EffectsRD::roughness_limit(RID p_source_normal, RID p_roughness, const Size RD::get_singleton()->compute_list_end(); } -void EffectsRD::cubemap_roughness(RID p_source_rd_texture, RID p_dest_framebuffer, uint32_t p_face_id, uint32_t p_sample_count, float p_roughness, float p_size) { +void EffectsRD::cubemap_roughness(RID p_source_rd_texture, RID p_dest_texture, uint32_t p_face_id, uint32_t p_sample_count, float p_roughness, float p_size) { + ERR_FAIL_COND_MSG(prefer_raster_effects, "Can't use compute based cubemap roughness with the mobile renderer."); + memset(&roughness.push_constant, 0, sizeof(CubemapRoughnessPushConstant)); roughness.push_constant.face_id = p_face_id > 9 ? 0 : p_face_id; @@ -1293,10 +1463,10 @@ void EffectsRD::cubemap_roughness(RID p_source_rd_texture, RID p_dest_framebuffe roughness.push_constant.face_size = p_size; RD::ComputeListID compute_list = RD::get_singleton()->compute_list_begin(); - RD::get_singleton()->compute_list_bind_compute_pipeline(compute_list, roughness.pipeline); + RD::get_singleton()->compute_list_bind_compute_pipeline(compute_list, roughness.compute_pipeline); RD::get_singleton()->compute_list_bind_uniform_set(compute_list, _get_compute_uniform_set_from_texture(p_source_rd_texture), 0); - RD::get_singleton()->compute_list_bind_uniform_set(compute_list, _get_uniform_set_from_image(p_dest_framebuffer), 1); + RD::get_singleton()->compute_list_bind_uniform_set(compute_list, _get_uniform_set_from_image(p_dest_texture), 1); RD::get_singleton()->compute_list_set_push_constant(compute_list, &roughness.push_constant, sizeof(CubemapRoughnessPushConstant)); @@ -1308,11 +1478,37 @@ void EffectsRD::cubemap_roughness(RID p_source_rd_texture, RID p_dest_framebuffe RD::get_singleton()->compute_list_end(); } +void EffectsRD::cubemap_roughness_raster(RID p_source_rd_texture, RID p_dest_framebuffer, uint32_t p_face_id, uint32_t p_sample_count, float p_roughness, float p_size) { + ERR_FAIL_COND_MSG(!prefer_raster_effects, "Can't use raster based cubemap roughness with the clustered renderer."); + ERR_FAIL_COND_MSG(p_face_id >= 6, "Raster implementation of cubemap roughness must process one side at a time."); + + memset(&roughness.push_constant, 0, sizeof(CubemapRoughnessPushConstant)); + + roughness.push_constant.face_id = p_face_id; + roughness.push_constant.roughness = p_roughness; + roughness.push_constant.sample_count = p_sample_count; + roughness.push_constant.use_direct_write = p_roughness == 0.0; + roughness.push_constant.face_size = p_size; + + RD::DrawListID draw_list = RD::get_singleton()->draw_list_begin(p_dest_framebuffer, RD::INITIAL_ACTION_KEEP, RD::FINAL_ACTION_READ, RD::INITIAL_ACTION_KEEP, RD::FINAL_ACTION_DISCARD); + RD::get_singleton()->draw_list_bind_render_pipeline(draw_list, roughness.raster_pipeline.get_render_pipeline(RD::INVALID_ID, RD::get_singleton()->framebuffer_get_format(p_dest_framebuffer))); + RD::get_singleton()->draw_list_bind_uniform_set(draw_list, _get_uniform_set_from_texture(p_source_rd_texture), 0); + RD::get_singleton()->draw_list_bind_index_array(draw_list, index_array); + + RD::get_singleton()->draw_list_set_push_constant(draw_list, &roughness.push_constant, sizeof(CubemapRoughnessPushConstant)); + + RD::get_singleton()->draw_list_draw(draw_list, true); + RD::get_singleton()->draw_list_end(); +} + void EffectsRD::cubemap_downsample(RID p_source_cubemap, RID p_dest_cubemap, const Size2i &p_size) { + ERR_FAIL_COND_MSG(prefer_raster_effects, "Can't use compute based cubemap downsample with the mobile renderer."); + cubemap_downsampler.push_constant.face_size = p_size.x; + cubemap_downsampler.push_constant.face_id = 0; // we render all 6 sides to each layer in one call RD::ComputeListID compute_list = RD::get_singleton()->compute_list_begin(); - RD::get_singleton()->compute_list_bind_compute_pipeline(compute_list, cubemap_downsampler.pipeline); + RD::get_singleton()->compute_list_bind_compute_pipeline(compute_list, cubemap_downsampler.compute_pipeline); RD::get_singleton()->compute_list_bind_uniform_set(compute_list, _get_compute_uniform_set_from_texture(p_source_cubemap), 0); RD::get_singleton()->compute_list_bind_uniform_set(compute_list, _get_uniform_set_from_image(p_dest_cubemap), 1); @@ -1326,7 +1522,27 @@ void EffectsRD::cubemap_downsample(RID p_source_cubemap, RID p_dest_cubemap, con RD::get_singleton()->compute_list_end(); } +void EffectsRD::cubemap_downsample_raster(RID p_source_cubemap, RID p_dest_framebuffer, uint32_t p_face_id, const Size2i &p_size) { + ERR_FAIL_COND_MSG(!prefer_raster_effects, "Can't use raster based cubemap downsample with the clustered renderer."); + ERR_FAIL_COND_MSG(p_face_id >= 6, "Raster implementation of cubemap downsample must process one side at a time."); + + cubemap_downsampler.push_constant.face_size = p_size.x; + cubemap_downsampler.push_constant.face_id = p_face_id; + + RD::DrawListID draw_list = RD::get_singleton()->draw_list_begin(p_dest_framebuffer, RD::INITIAL_ACTION_KEEP, RD::FINAL_ACTION_READ, RD::INITIAL_ACTION_KEEP, RD::FINAL_ACTION_DISCARD); + RD::get_singleton()->draw_list_bind_render_pipeline(draw_list, cubemap_downsampler.raster_pipeline.get_render_pipeline(RD::INVALID_ID, RD::get_singleton()->framebuffer_get_format(p_dest_framebuffer))); + RD::get_singleton()->draw_list_bind_uniform_set(draw_list, _get_uniform_set_from_texture(p_source_cubemap), 0); + RD::get_singleton()->draw_list_bind_index_array(draw_list, index_array); + + RD::get_singleton()->draw_list_set_push_constant(draw_list, &cubemap_downsampler.push_constant, sizeof(CubemapDownsamplerPushConstant)); + + RD::get_singleton()->draw_list_draw(draw_list, true); + RD::get_singleton()->draw_list_end(); +} + void EffectsRD::cubemap_filter(RID p_source_cubemap, Vector<RID> p_dest_cubemap, bool p_use_array) { + ERR_FAIL_COND_MSG(prefer_raster_effects, "Can't use compute based cubemap filter with the mobile renderer."); + Vector<RD::Uniform> uniforms; for (int i = 0; i < p_dest_cubemap.size(); i++) { RD::Uniform u; @@ -1338,12 +1554,12 @@ void EffectsRD::cubemap_filter(RID p_source_cubemap, Vector<RID> p_dest_cubemap, if (RD::get_singleton()->uniform_set_is_valid(filter.image_uniform_set)) { RD::get_singleton()->free(filter.image_uniform_set); } - filter.image_uniform_set = RD::get_singleton()->uniform_set_create(uniforms, filter.shader.version_get_shader(filter.shader_version, 0), 2); + filter.image_uniform_set = RD::get_singleton()->uniform_set_create(uniforms, filter.compute_shader.version_get_shader(filter.shader_version, 0), 2); int pipeline = p_use_array ? FILTER_MODE_HIGH_QUALITY_ARRAY : FILTER_MODE_HIGH_QUALITY; pipeline = filter.use_high_quality ? pipeline : pipeline + 1; RD::ComputeListID compute_list = RD::get_singleton()->compute_list_begin(); - RD::get_singleton()->compute_list_bind_compute_pipeline(compute_list, filter.pipelines[pipeline]); + RD::get_singleton()->compute_list_bind_compute_pipeline(compute_list, filter.compute_pipelines[pipeline]); RD::get_singleton()->compute_list_bind_uniform_set(compute_list, _get_compute_uniform_set_from_texture(p_source_cubemap, true), 0); RD::get_singleton()->compute_list_bind_uniform_set(compute_list, filter.uniform_set, 1); RD::get_singleton()->compute_list_bind_uniform_set(compute_list, filter.image_uniform_set, 2); @@ -1355,6 +1571,29 @@ void EffectsRD::cubemap_filter(RID p_source_cubemap, Vector<RID> p_dest_cubemap, RD::get_singleton()->compute_list_end(); } +void EffectsRD::cubemap_filter_raster(RID p_source_cubemap, RID p_dest_framebuffer, uint32_t p_face_id, uint32_t p_mip_level) { + ERR_FAIL_COND_MSG(!prefer_raster_effects, "Can't use raster based cubemap filter with the clustered renderer."); + ERR_FAIL_COND_MSG(p_face_id >= 6, "Raster implementation of cubemap filter must process one side at a time."); + + // TODO implement! + CubemapFilterRasterPushConstant push_constant; + push_constant.mip_level = p_mip_level; + push_constant.face_id = p_face_id; + + CubemapFilterMode mode = filter.use_high_quality ? FILTER_MODE_HIGH_QUALITY : FILTER_MODE_LOW_QUALITY; + + RD::DrawListID draw_list = RD::get_singleton()->draw_list_begin(p_dest_framebuffer, RD::INITIAL_ACTION_KEEP, RD::FINAL_ACTION_READ, RD::INITIAL_ACTION_KEEP, RD::FINAL_ACTION_DISCARD); + RD::get_singleton()->draw_list_bind_render_pipeline(draw_list, filter.raster_pipelines[mode].get_render_pipeline(RD::INVALID_ID, RD::get_singleton()->framebuffer_get_format(p_dest_framebuffer))); + RD::get_singleton()->draw_list_bind_uniform_set(draw_list, _get_uniform_set_from_texture(p_source_cubemap), 0); + RD::get_singleton()->draw_list_bind_uniform_set(draw_list, filter.uniform_set, 1); + RD::get_singleton()->draw_list_bind_index_array(draw_list, index_array); + + RD::get_singleton()->draw_list_set_push_constant(draw_list, &push_constant, sizeof(CubemapFilterRasterPushConstant)); + + RD::get_singleton()->draw_list_draw(draw_list, true); + RD::get_singleton()->draw_list_end(); +} + void EffectsRD::resolve_gi(RID p_source_depth, RID p_source_normal_roughness, RID p_source_voxel_gi, RID p_dest_depth, RID p_dest_normal_roughness, RID p_dest_voxel_gi, Vector2i p_screen_size, int p_samples, uint32_t p_barrier) { ResolvePushConstant push_constant; push_constant.screen_size[0] = p_screen_size.x; @@ -1464,7 +1703,35 @@ void EffectsRD::sort_buffer(RID p_uniform_set, int p_size) { RD::get_singleton()->compute_list_end(); } -EffectsRD::EffectsRD() { +EffectsRD::EffectsRD(bool p_prefer_raster_effects) { + prefer_raster_effects = p_prefer_raster_effects; + + if (prefer_raster_effects) { + // init blur shader (on compute use copy shader) + + Vector<String> blur_modes; + blur_modes.push_back("\n#define MODE_GAUSSIAN_BLUR\n"); // BLUR_MODE_GAUSSIAN_BLUR + blur_modes.push_back("\n#define MODE_GAUSSIAN_GLOW\n"); // BLUR_MODE_GAUSSIAN_GLOW + blur_modes.push_back("\n#define MODE_GAUSSIAN_GLOW\n#define GLOW_USE_AUTO_EXPOSURE\n"); // BLUR_MODE_GAUSSIAN_GLOW_AUTO_EXPOSURE + blur_modes.push_back("\n#define MODE_DOF_BLUR\n#define DOF_QUALITY_LOW\n"); // BLUR_MODE_DOF_LOW + blur_modes.push_back("\n#define MODE_DOF_BLUR\n#define DOF_QUALITY_MEDIUM\n"); // BLUR_MODE_DOF_MEDIUM + blur_modes.push_back("\n#define MODE_DOF_BLUR\n#define DOF_QUALITY_HIGH\n"); // BLUR_MODE_DOF_HIGH + + blur_raster.shader.initialize(blur_modes); + memset(&blur_raster.push_constant, 0, sizeof(BlurRasterPushConstant)); + blur_raster.shader_version = blur_raster.shader.version_create(); + + for (int i = 0; i < BLUR_MODE_MAX; i++) { + blur_raster.pipelines[i].setup(blur_raster.shader.version_get_shader(blur_raster.shader_version, i), RD::RENDER_PRIMITIVE_TRIANGLES, RD::PipelineRasterizationState(), RD::PipelineMultisampleState(), RD::PipelineDepthStencilState(), RD::PipelineColorBlendState::create_disabled(), 0); + } + + } else { + // not used in clustered + for (int i = 0; i < BLUR_MODE_MAX; i++) { + blur_raster.pipelines[i].clear(); + } + } + { // Initialize copy Vector<String> copy_modes; copy_modes.push_back("\n#define MODE_GAUSSIAN_BLUR\n"); @@ -1483,10 +1750,21 @@ EffectsRD::EffectsRD() { copy.shader.initialize(copy_modes); memset(©.push_constant, 0, sizeof(CopyPushConstant)); + + if (prefer_raster_effects) { + // disable shaders we can't use + copy.shader.set_variant_enabled(COPY_MODE_GAUSSIAN_COPY, false); + copy.shader.set_variant_enabled(COPY_MODE_GAUSSIAN_COPY_8BIT, false); + copy.shader.set_variant_enabled(COPY_MODE_GAUSSIAN_GLOW, false); + copy.shader.set_variant_enabled(COPY_MODE_GAUSSIAN_GLOW_AUTO_EXPOSURE, false); + } + copy.shader_version = copy.shader.version_create(); for (int i = 0; i < COPY_MODE_MAX; i++) { - copy.pipelines[i] = RD::get_singleton()->compute_pipeline_create(copy.shader.version_get_shader(copy.shader_version, i)); + if (copy.shader.is_variant_enabled(i)) { + copy.pipelines[i] = RD::get_singleton()->compute_pipeline_create(copy.shader.version_get_shader(copy.shader_version, i)); + } } } { @@ -1510,11 +1788,22 @@ EffectsRD::EffectsRD() { // Initialize roughness Vector<String> cubemap_roughness_modes; cubemap_roughness_modes.push_back(""); - roughness.shader.initialize(cubemap_roughness_modes); - roughness.shader_version = roughness.shader.version_create(); + if (prefer_raster_effects) { + roughness.raster_shader.initialize(cubemap_roughness_modes); + + roughness.shader_version = roughness.raster_shader.version_create(); + + roughness.raster_pipeline.setup(roughness.raster_shader.version_get_shader(roughness.shader_version, 0), RD::RENDER_PRIMITIVE_TRIANGLES, RD::PipelineRasterizationState(), RD::PipelineMultisampleState(), RD::PipelineDepthStencilState(), RD::PipelineColorBlendState::create_disabled(), 0); + + } else { + roughness.compute_shader.initialize(cubemap_roughness_modes); + + roughness.shader_version = roughness.compute_shader.version_create(); - roughness.pipeline = RD::get_singleton()->compute_pipeline_create(roughness.shader.version_get_shader(roughness.shader_version, 0)); + roughness.compute_pipeline = RD::get_singleton()->compute_pipeline_create(roughness.compute_shader.version_get_shader(roughness.shader_version, 0)); + roughness.raster_pipeline.clear(); + } } { @@ -1551,7 +1840,20 @@ EffectsRD::EffectsRD() { } } - { + if (prefer_raster_effects) { + Vector<String> luminance_reduce_modes; + luminance_reduce_modes.push_back("\n#define FIRST_PASS\n"); // LUMINANCE_REDUCE_FRAGMENT_FIRST + luminance_reduce_modes.push_back("\n"); // LUMINANCE_REDUCE_FRAGMENT + luminance_reduce_modes.push_back("\n#define FINAL_PASS\n"); // LUMINANCE_REDUCE_FRAGMENT_FINAL + + luminance_reduce_raster.shader.initialize(luminance_reduce_modes); + memset(&luminance_reduce_raster.push_constant, 0, sizeof(LuminanceReduceRasterPushConstant)); + luminance_reduce_raster.shader_version = luminance_reduce_raster.shader.version_create(); + + for (int i = 0; i < LUMINANCE_REDUCE_FRAGMENT_MAX; i++) { + luminance_reduce_raster.pipelines[i].setup(luminance_reduce_raster.shader.version_get_shader(luminance_reduce_raster.shader_version, i), RD::RENDER_PRIMITIVE_TRIANGLES, RD::PipelineRasterizationState(), RD::PipelineMultisampleState(), RD::PipelineDepthStencilState(), RD::PipelineColorBlendState::create_disabled(), 0); + } + } else { // Initialize luminance_reduce Vector<String> luminance_reduce_modes; luminance_reduce_modes.push_back("\n#define READ_TEXTURE\n"); @@ -1565,6 +1867,10 @@ EffectsRD::EffectsRD() { for (int i = 0; i < LUMINANCE_REDUCE_MAX; i++) { luminance_reduce.pipelines[i] = RD::get_singleton()->compute_pipeline_create(luminance_reduce.shader.version_get_shader(luminance_reduce.shader_version, i)); } + + for (int i = 0; i < LUMINANCE_REDUCE_FRAGMENT_MAX; i++) { + luminance_reduce_raster.pipelines[i].clear(); + } } { @@ -1583,7 +1889,9 @@ EffectsRD::EffectsRD() { cube_to_dp.pipeline.setup(shader, RD::RENDER_PRIMITIVE_TRIANGLES, RD::PipelineRasterizationState(), RD::PipelineMultisampleState(), dss, RD::PipelineColorBlendState(), 0); } - { + if (prefer_raster_effects) { + // not supported + } else { // Initialize bokeh Vector<String> bokeh_modes; bokeh_modes.push_back("\n#define MODE_GEN_BLUR_SIZE\n"); @@ -1761,11 +2069,21 @@ EffectsRD::EffectsRD() { //Initialize cubemap downsampler Vector<String> cubemap_downsampler_modes; cubemap_downsampler_modes.push_back(""); - cubemap_downsampler.shader.initialize(cubemap_downsampler_modes); - cubemap_downsampler.shader_version = cubemap_downsampler.shader.version_create(); + if (prefer_raster_effects) { + cubemap_downsampler.raster_shader.initialize(cubemap_downsampler_modes); + + cubemap_downsampler.shader_version = cubemap_downsampler.raster_shader.version_create(); + + cubemap_downsampler.raster_pipeline.setup(cubemap_downsampler.raster_shader.version_get_shader(cubemap_downsampler.shader_version, 0), RD::RENDER_PRIMITIVE_TRIANGLES, RD::PipelineRasterizationState(), RD::PipelineMultisampleState(), RD::PipelineDepthStencilState(), RD::PipelineColorBlendState::create_disabled(), 0); + } else { + cubemap_downsampler.compute_shader.initialize(cubemap_downsampler_modes); + + cubemap_downsampler.shader_version = cubemap_downsampler.compute_shader.version_create(); - cubemap_downsampler.pipeline = RD::get_singleton()->compute_pipeline_create(cubemap_downsampler.shader.version_get_shader(cubemap_downsampler.shader_version, 0)); + cubemap_downsampler.compute_pipeline = RD::get_singleton()->compute_pipeline_create(cubemap_downsampler.compute_shader.version_get_shader(cubemap_downsampler.shader_version, 0)); + cubemap_downsampler.raster_pipeline.clear(); + } } { @@ -1777,12 +2095,6 @@ EffectsRD::EffectsRD() { cubemap_filter_modes.push_back("\n#define USE_LOW_QUALITY\n"); cubemap_filter_modes.push_back("\n#define USE_HIGH_QUALITY\n#define USE_TEXTURE_ARRAY\n"); cubemap_filter_modes.push_back("\n#define USE_LOW_QUALITY\n#define USE_TEXTURE_ARRAY\n"); - filter.shader.initialize(cubemap_filter_modes); - filter.shader_version = filter.shader.version_create(); - - for (int i = 0; i < FILTER_MODE_MAX; i++) { - filter.pipelines[i] = RD::get_singleton()->compute_pipeline_create(filter.shader.version_get_shader(filter.shader_version, i)); - } if (filter.use_high_quality) { filter.coefficient_buffer = RD::get_singleton()->storage_buffer_create(sizeof(high_quality_coeffs)); @@ -1792,15 +2104,50 @@ EffectsRD::EffectsRD() { RD::get_singleton()->buffer_update(filter.coefficient_buffer, 0, sizeof(low_quality_coeffs), &low_quality_coeffs[0]); } - Vector<RD::Uniform> uniforms; - { - RD::Uniform u; - u.uniform_type = RD::UNIFORM_TYPE_STORAGE_BUFFER; - u.binding = 0; - u.ids.push_back(filter.coefficient_buffer); - uniforms.push_back(u); + if (prefer_raster_effects) { + filter.raster_shader.initialize(cubemap_filter_modes); + filter.shader_version = filter.raster_shader.version_create(); + + // array variants are not supported in raster + filter.raster_shader.set_variant_enabled(FILTER_MODE_HIGH_QUALITY_ARRAY, false); + filter.raster_shader.set_variant_enabled(FILTER_MODE_LOW_QUALITY_ARRAY, false); + + for (int i = 0; i < FILTER_MODE_MAX; i++) { + if (filter.raster_shader.is_variant_enabled(i)) { + filter.raster_pipelines[i].setup(filter.raster_shader.version_get_shader(filter.shader_version, i), RD::RENDER_PRIMITIVE_TRIANGLES, RD::PipelineRasterizationState(), RD::PipelineMultisampleState(), RD::PipelineDepthStencilState(), RD::PipelineColorBlendState::create_disabled(), 0); + } else { + filter.raster_pipelines[i].clear(); + } + } + + Vector<RD::Uniform> uniforms; + { + RD::Uniform u; + u.uniform_type = RD::UNIFORM_TYPE_STORAGE_BUFFER; + u.binding = 0; + u.ids.push_back(filter.coefficient_buffer); + uniforms.push_back(u); + } + filter.uniform_set = RD::get_singleton()->uniform_set_create(uniforms, filter.raster_shader.version_get_shader(filter.shader_version, filter.use_high_quality ? 0 : 1), 1); + } else { + filter.compute_shader.initialize(cubemap_filter_modes); + filter.shader_version = filter.compute_shader.version_create(); + + for (int i = 0; i < FILTER_MODE_MAX; i++) { + filter.compute_pipelines[i] = RD::get_singleton()->compute_pipeline_create(filter.compute_shader.version_get_shader(filter.shader_version, i)); + filter.raster_pipelines[i].clear(); + } + + Vector<RD::Uniform> uniforms; + { + RD::Uniform u; + u.uniform_type = RD::UNIFORM_TYPE_STORAGE_BUFFER; + u.binding = 0; + u.ids.push_back(filter.coefficient_buffer); + uniforms.push_back(u); + } + filter.uniform_set = RD::get_singleton()->uniform_set_create(uniforms, filter.compute_shader.version_get_shader(filter.shader_version, filter.use_high_quality ? 0 : 1), 1); } - filter.uniform_set = RD::get_singleton()->uniform_set_create(uniforms, filter.shader.version_get_shader(filter.shader_version, filter.use_high_quality ? 0 : 1), 1); } { @@ -1974,15 +2321,23 @@ EffectsRD::~EffectsRD() { RD::get_singleton()->free(ssao.gather_constants_buffer); RD::get_singleton()->free(ssao.importance_map_load_counter); - bokeh.shader.version_free(bokeh.shader_version); + if (prefer_raster_effects) { + blur_raster.shader.version_free(blur_raster.shader_version); + luminance_reduce_raster.shader.version_free(luminance_reduce_raster.shader_version); + roughness.raster_shader.version_free(roughness.shader_version); + cubemap_downsampler.raster_shader.version_free(cubemap_downsampler.shader_version); + filter.raster_shader.version_free(filter.shader_version); + } else { + bokeh.shader.version_free(bokeh.shader_version); + luminance_reduce.shader.version_free(luminance_reduce.shader_version); + roughness.compute_shader.version_free(roughness.shader_version); + cubemap_downsampler.compute_shader.version_free(cubemap_downsampler.shader_version); + filter.compute_shader.version_free(filter.shader_version); + } copy.shader.version_free(copy.shader_version); copy_to_fb.shader.version_free(copy_to_fb.shader_version); cube_to_dp.shader.version_free(cube_to_dp.shader_version); - cubemap_downsampler.shader.version_free(cubemap_downsampler.shader_version); - filter.shader.version_free(filter.shader_version); - luminance_reduce.shader.version_free(luminance_reduce.shader_version); resolve.shader.version_free(resolve.shader_version); - roughness.shader.version_free(roughness.shader_version); roughness_limiter.shader.version_free(roughness_limiter.shader_version); sort.shader.version_free(sort.shader_version); specular_merge.shader.version_free(specular_merge.shader_version); diff --git a/servers/rendering/renderer_rd/effects_rd.h b/servers/rendering/renderer_rd/effects_rd.h index 33d32f0c57..eff891571a 100644 --- a/servers/rendering/renderer_rd/effects_rd.h +++ b/servers/rendering/renderer_rd/effects_rd.h @@ -33,14 +33,19 @@ #include "core/math/camera_matrix.h" #include "servers/rendering/renderer_rd/pipeline_cache_rd.h" +#include "servers/rendering/renderer_rd/shaders/blur_raster.glsl.gen.h" #include "servers/rendering/renderer_rd/shaders/bokeh_dof.glsl.gen.h" #include "servers/rendering/renderer_rd/shaders/copy.glsl.gen.h" #include "servers/rendering/renderer_rd/shaders/copy_to_fb.glsl.gen.h" #include "servers/rendering/renderer_rd/shaders/cube_to_dp.glsl.gen.h" #include "servers/rendering/renderer_rd/shaders/cubemap_downsampler.glsl.gen.h" +#include "servers/rendering/renderer_rd/shaders/cubemap_downsampler_raster.glsl.gen.h" #include "servers/rendering/renderer_rd/shaders/cubemap_filter.glsl.gen.h" +#include "servers/rendering/renderer_rd/shaders/cubemap_filter_raster.glsl.gen.h" #include "servers/rendering/renderer_rd/shaders/cubemap_roughness.glsl.gen.h" +#include "servers/rendering/renderer_rd/shaders/cubemap_roughness_raster.glsl.gen.h" #include "servers/rendering/renderer_rd/shaders/luminance_reduce.glsl.gen.h" +#include "servers/rendering/renderer_rd/shaders/luminance_reduce_raster.glsl.gen.h" #include "servers/rendering/renderer_rd/shaders/resolve.glsl.gen.h" #include "servers/rendering/renderer_rd/shaders/roughness_limiter.glsl.gen.h" #include "servers/rendering/renderer_rd/shaders/screen_space_reflection.glsl.gen.h" @@ -60,6 +65,66 @@ #include "servers/rendering_server.h" class EffectsRD { +private: + bool prefer_raster_effects; + + enum BlurRasterMode { + BLUR_MODE_GAUSSIAN_BLUR, + BLUR_MODE_GAUSSIAN_GLOW, + BLUR_MODE_GAUSSIAN_GLOW_AUTO_EXPOSURE, + + BLUR_MODE_DOF_LOW, + BLUR_MODE_DOF_MEDIUM, + BLUR_MODE_DOF_HIGH, + + BLUR_MODE_MAX + }; + + enum { + BLUR_FLAG_HORIZONTAL = (1 << 0), + BLUR_FLAG_USE_ORTHOGONAL_PROJECTION = (1 << 1), + BLUR_FLAG_GLOW_FIRST_PASS = (1 << 2), + BLUR_FLAG_DOF_FAR = (1 << 3), + BLUR_FLAG_DOF_NEAR = (1 << 4), + }; + + struct BlurRasterPushConstant { + float pixel_size[2]; + uint32_t flags; + uint32_t pad; + + //glow + float glow_strength; + float glow_bloom; + float glow_hdr_threshold; + float glow_hdr_scale; + + float glow_exposure; + float glow_white; + float glow_luminance_cap; + float glow_auto_exposure_grey; + + //dof + float dof_far_begin; + float dof_far_end; + float dof_near_begin; + float dof_near_end; + + float dof_radius; + float dof_pad[3]; + + float dof_dir[2]; + float camera_z_far; + float camera_z_near; + }; + + struct BlurRaster { + BlurRasterPushConstant push_constant; + BlurRasterShaderRD shader; + RID shader_version; + PipelineCacheRD pipelines[BLUR_MODE_MAX]; + } blur_raster; + enum CopyMode { COPY_MODE_GAUSSIAN_COPY, COPY_MODE_GAUSSIAN_COPY_8BIT, @@ -161,9 +226,11 @@ class EffectsRD { struct CubemapRoughness { CubemapRoughnessPushConstant push_constant; - CubemapRoughnessShaderRD shader; + CubemapRoughnessShaderRD compute_shader; + CubemapRoughnessRasterShaderRD raster_shader; RID shader_version; - RID pipeline; + RID compute_pipeline; + PipelineCacheRD raster_pipeline; } roughness; enum TonemapMode { @@ -239,6 +306,29 @@ class EffectsRD { RID pipelines[LUMINANCE_REDUCE_MAX]; } luminance_reduce; + enum LuminanceReduceRasterMode { + LUMINANCE_REDUCE_FRAGMENT_FIRST, + LUMINANCE_REDUCE_FRAGMENT, + LUMINANCE_REDUCE_FRAGMENT_FINAL, + LUMINANCE_REDUCE_FRAGMENT_MAX + }; + + struct LuminanceReduceRasterPushConstant { + int32_t source_size[2]; + int32_t dest_size[2]; + float exposure_adjust; + float min_luminance; + float max_luminance; + float pad[1]; + }; + + struct LuminanceReduceFragment { + LuminanceReduceRasterPushConstant push_constant; + LuminanceReduceRasterShaderRD shader; + RID shader_version; + PipelineCacheRD pipelines[LUMINANCE_REDUCE_FRAGMENT_MAX]; + } luminance_reduce_raster; + struct CopyToDPPushConstant { float z_far; float z_near; @@ -426,15 +516,17 @@ class EffectsRD { struct CubemapDownsamplerPushConstant { uint32_t face_size; - float pad[3]; + uint32_t face_id; + float pad[2]; }; struct CubemapDownsampler { CubemapDownsamplerPushConstant push_constant; - CubemapDownsamplerShaderRD shader; + CubemapDownsamplerShaderRD compute_shader; + CubemapDownsamplerRasterShaderRD raster_shader; RID shader_version; - RID pipeline; - + RID compute_pipeline; + PipelineCacheRD raster_pipeline; } cubemap_downsampler; enum CubemapFilterMode { @@ -445,10 +537,19 @@ class EffectsRD { FILTER_MODE_MAX, }; + struct CubemapFilterRasterPushConstant { + uint32_t mip_level; + uint32_t face_id; + float pad[2]; + }; + struct CubemapFilter { - CubemapFilterShaderRD shader; + CubemapFilterShaderRD compute_shader; + CubemapFilterRasterShaderRD raster_shader; RID shader_version; - RID pipelines[FILTER_MODE_MAX]; + RID compute_pipelines[FILTER_MODE_MAX]; + PipelineCacheRD raster_pipelines[FILTER_MODE_MAX]; + RID uniform_set; RID image_uniform_set; RID coefficient_buffer; @@ -657,6 +758,8 @@ class EffectsRD { RID _get_compute_uniform_set_from_image_pair(RID p_texture, RID p_texture2); public: + bool get_prefer_raster_effects(); + void copy_to_fb_rect(RID p_source_rd_texture, RID p_dest_framebuffer, const Rect2i &p_rect, bool p_flip_y = false, bool p_force_luminance = false, bool p_alpha_to_zero = false, bool p_srgb = false, RID p_secondary = RID()); void copy_to_rect(RID p_source_rd_texture, RID p_dest_texture, const Rect2i &p_rect, bool p_flip_y = false, bool p_force_luminance = false, bool p_all_source = false, bool p_8_bit_dst = false, bool p_alpha_to_one = false); void copy_cubemap_to_panorama(RID p_source_cube, RID p_dest_panorama, const Size2i &p_panorama_size, float p_lod, bool p_is_array); @@ -666,12 +769,17 @@ public: void gaussian_blur(RID p_source_rd_texture, RID p_texture, RID p_back_texture, const Rect2i &p_region, bool p_8bit_dst = false); void set_color(RID p_dest_texture, const Color &p_color, const Rect2i &p_region, bool p_8bit_dst = false); void gaussian_glow(RID p_source_rd_texture, RID p_back_texture, const Size2i &p_size, float p_strength = 1.0, bool p_high_quality = false, bool p_first_pass = false, float p_luminance_cap = 16.0, float p_exposure = 1.0, float p_bloom = 0.0, float p_hdr_bleed_treshold = 1.0, float p_hdr_bleed_scale = 1.0, RID p_auto_exposure = RID(), float p_auto_exposure_grey = 1.0); + void gaussian_glow_raster(RID p_source_rd_texture, RID p_framebuffer_half, RID p_rd_texture_half, RID p_dest_framebuffer, const Vector2 &p_pixel_size, float p_strength = 1.0, bool p_high_quality = false, bool p_first_pass = false, float p_luminance_cap = 16.0, float p_exposure = 1.0, float p_bloom = 0.0, float p_hdr_bleed_treshold = 1.0, float p_hdr_bleed_scale = 1.0, RID p_auto_exposure = RID(), float p_auto_exposure_grey = 1.0); - void cubemap_roughness(RID p_source_rd_texture, RID p_dest_framebuffer, uint32_t p_face_id, uint32_t p_sample_count, float p_roughness, float p_size); + void cubemap_roughness(RID p_source_rd_texture, RID p_dest_texture, uint32_t p_face_id, uint32_t p_sample_count, float p_roughness, float p_size); + void cubemap_roughness_raster(RID p_source_rd_texture, RID p_dest_framebuffer, uint32_t p_face_id, uint32_t p_sample_count, float p_roughness, float p_size); void make_mipmap(RID p_source_rd_texture, RID p_dest_texture, const Size2i &p_size); void copy_cubemap_to_dp(RID p_source_rd_texture, RID p_dest_texture, const Rect2 &p_rect, float p_z_near, float p_z_far, bool p_dp_flip); void luminance_reduction(RID p_source_texture, const Size2i p_source_size, const Vector<RID> p_reduce, RID p_prev_luminance, float p_min_luminance, float p_max_luminance, float p_adjust, bool p_set = false); + void luminance_reduction_raster(RID p_source_texture, const Size2i p_source_size, const Vector<RID> p_reduce, Vector<RID> p_fb, RID p_prev_luminance, float p_min_luminance, float p_max_luminance, float p_adjust, bool p_set = false); + void bokeh_dof(RID p_base_texture, RID p_depth_texture, const Size2i &p_base_texture_size, RID p_secondary_texture, RID p_bokeh_texture1, RID p_bokeh_texture2, bool p_dof_far, float p_dof_far_begin, float p_dof_far_size, bool p_dof_near, float p_dof_near_begin, float p_dof_near_size, float p_bokeh_size, RS::DOFBokehShape p_bokeh_shape, RS::DOFBlurQuality p_quality, bool p_use_jitter, float p_cam_znear, float p_cam_zfar, bool p_cam_orthogonal); + void blur_dof_raster(RID p_base_texture, RID p_depth_texture, const Size2i &p_base_texture_size, RID p_base_fb, RID p_secondary_texture, RID p_secondary_fb, bool p_dof_far, float p_dof_far_begin, float p_dof_far_size, bool p_dof_near, float p_dof_near_begin, float p_dof_near_size, float p_dof_blur_amount, RS::DOFBlurQuality p_quality, float p_cam_znear, float p_cam_zfar, bool p_cam_orthogonal); struct TonemapSettings { bool use_glow = false; @@ -740,7 +848,9 @@ public: void roughness_limit(RID p_source_normal, RID p_roughness, const Size2i &p_size, float p_curve); void cubemap_downsample(RID p_source_cubemap, RID p_dest_cubemap, const Size2i &p_size); + void cubemap_downsample_raster(RID p_source_cubemap, RID p_dest_framebuffer, uint32_t p_face_id, const Size2i &p_size); void cubemap_filter(RID p_source_cubemap, Vector<RID> p_dest_cubemap, bool p_use_array); + void cubemap_filter_raster(RID p_source_cubemap, RID p_dest_framebuffer, uint32_t p_face_id, uint32_t p_mip_level); void screen_space_reflection(RID p_diffuse, RID p_normal_roughness, RS::EnvironmentSSRRoughnessQuality p_roughness_quality, RID p_blur_radius, RID p_blur_radius2, RID p_metallic, const Color &p_metallic_mask, RID p_depth, RID p_scale_depth, RID p_scale_normal, RID p_output, RID p_output_blur, const Size2i &p_screen_size, int p_max_steps, float p_fade_in, float p_fade_out, float p_tolerance, const CameraMatrix &p_camera); void merge_specular(RID p_dest_framebuffer, RID p_specular, RID p_base, RID p_reflection); @@ -751,7 +861,7 @@ public: void sort_buffer(RID p_uniform_set, int p_size); - EffectsRD(); + EffectsRD(bool p_prefer_raster_effects); ~EffectsRD(); }; diff --git a/servers/rendering/renderer_rd/forward_clustered/render_forward_clustered.cpp b/servers/rendering/renderer_rd/forward_clustered/render_forward_clustered.cpp index 22bfd03115..ac20515c28 100644 --- a/servers/rendering/renderer_rd/forward_clustered/render_forward_clustered.cpp +++ b/servers/rendering/renderer_rd/forward_clustered/render_forward_clustered.cpp @@ -318,11 +318,11 @@ void RenderForwardClustered::_render_list_template(RenderingDevice::DrawListID p RID prev_pipeline_rd; RID prev_xforms_uniform_set; - bool shadow_pass = (p_params->pass_mode == PASS_MODE_SHADOW) || (p_params->pass_mode == PASS_MODE_SHADOW_DP); + bool shadow_pass = (p_pass_mode == PASS_MODE_SHADOW) || (p_pass_mode == PASS_MODE_SHADOW_DP); SceneState::PushConstant push_constant; - if (p_params->pass_mode == PASS_MODE_DEPTH_MATERIAL) { + if (p_pass_mode == PASS_MODE_DEPTH_MATERIAL) { push_constant.uv_offset = Math::make_half_float(p_params->uv_offset.y) << 16; push_constant.uv_offset |= Math::make_half_float(p_params->uv_offset.x); } else { @@ -339,7 +339,7 @@ void RenderForwardClustered::_render_list_template(RenderingDevice::DrawListID p SceneShaderForwardClustered::ShaderData *shader; void *mesh_surface; - if (shadow_pass || p_params->pass_mode == PASS_MODE_DEPTH) { //regular depth pass can use these too + if (shadow_pass || p_pass_mode == PASS_MODE_DEPTH) { //regular depth pass can use these too material_uniform_set = surf->material_uniform_set_shadow; shader = surf->shader_shadow; mesh_surface = surf->surface_shadow; @@ -369,7 +369,7 @@ void RenderForwardClustered::_render_list_template(RenderingDevice::DrawListID p //find cull variant SceneShaderForwardClustered::ShaderData::CullVariant cull_variant; - if (p_params->pass_mode == PASS_MODE_DEPTH_MATERIAL || p_params->pass_mode == PASS_MODE_SDF || ((p_params->pass_mode == PASS_MODE_SHADOW || p_params->pass_mode == PASS_MODE_SHADOW_DP) && surf->flags & GeometryInstanceSurfaceDataCache::FLAG_USES_DOUBLE_SIDED_SHADOWS)) { + if (p_pass_mode == PASS_MODE_DEPTH_MATERIAL || p_pass_mode == PASS_MODE_SDF || ((p_pass_mode == PASS_MODE_SHADOW || p_pass_mode == PASS_MODE_SHADOW_DP) && surf->flags & GeometryInstanceSurfaceDataCache::FLAG_USES_DOUBLE_SIDED_SHADOWS)) { cull_variant = SceneShaderForwardClustered::ShaderData::CULL_VARIANT_DOUBLE_SIDED; } else { bool mirror = surf->owner->mirror; @@ -384,14 +384,30 @@ void RenderForwardClustered::_render_list_template(RenderingDevice::DrawListID p SceneShaderForwardClustered::ShaderVersion shader_version = SceneShaderForwardClustered::SHADER_VERSION_MAX; // Assigned to silence wrong -Wmaybe-initialized. - switch (p_params->pass_mode) { + uint32_t pipeline_specialization = 0; + + if (p_pass_mode == PASS_MODE_COLOR || p_pass_mode == PASS_MODE_COLOR_TRANSPARENT || p_pass_mode == PASS_MODE_COLOR_SPECULAR) { + if (element_info.uses_softshadow) { + pipeline_specialization |= SceneShaderForwardClustered::SHADER_SPECIALIZATION_SOFT_SHADOWS; + } + if (element_info.uses_projector) { + pipeline_specialization |= SceneShaderForwardClustered::SHADER_SPECIALIZATION_PROJECTOR; + } + + if (p_params->use_directional_soft_shadow) { + pipeline_specialization |= SceneShaderForwardClustered::SHADER_SPECIALIZATION_DIRECTIONAL_SOFT_SHADOWS; + } + } + + switch (p_pass_mode) { case PASS_MODE_COLOR: case PASS_MODE_COLOR_TRANSPARENT: { if (element_info.uses_lightmap) { shader_version = SceneShaderForwardClustered::SHADER_VERSION_LIGHTMAP_COLOR_PASS; - } else if (element_info.uses_forward_gi) { - shader_version = SceneShaderForwardClustered::SHADER_VERSION_COLOR_PASS_WITH_FORWARD_GI; } else { + if (element_info.uses_forward_gi) { + pipeline_specialization |= SceneShaderForwardClustered::SHADER_SPECIALIZATION_FORWARD_GI; + } shader_version = SceneShaderForwardClustered::SHADER_VERSION_COLOR_PASS; } } break; @@ -452,7 +468,7 @@ void RenderForwardClustered::_render_list_template(RenderingDevice::DrawListID p prev_index_array_rd = index_array_rd; } - RID pipeline_rd = pipeline->get_render_pipeline(vertex_format, framebuffer_format, p_params->force_wireframe); + RID pipeline_rd = pipeline->get_render_pipeline(vertex_format, framebuffer_format, p_params->force_wireframe, 0, pipeline_specialization); if (pipeline_rd != prev_pipeline_rd) { // checking with prev shader does not make so much sense, as @@ -573,11 +589,6 @@ void RenderForwardClustered::_setup_environment(const RenderDataRD *p_render_dat RendererStorageRD::store_soft_shadow_kernel(penumbra_shadow_kernel_get(), scene_state.ubo.penumbra_shadow_kernel); RendererStorageRD::store_soft_shadow_kernel(soft_shadow_kernel_get(), scene_state.ubo.soft_shadow_kernel); - scene_state.ubo.directional_penumbra_shadow_samples = directional_penumbra_shadow_samples_get(); - scene_state.ubo.directional_soft_shadow_samples = directional_soft_shadow_samples_get(); - scene_state.ubo.penumbra_shadow_samples = penumbra_shadow_samples_get(); - scene_state.ubo.soft_shadow_samples = soft_shadow_samples_get(); - Size2 screen_pixel_size = Vector2(1.0, 1.0) / Size2(p_screen_size); scene_state.ubo.screen_pixel_size[0] = screen_pixel_size.x; scene_state.ubo.screen_pixel_size[1] = screen_pixel_size.y; @@ -848,7 +859,7 @@ void RenderForwardClustered::_fill_instance_data(RenderListType p_render_list, i bool cant_repeat = instance_data.flags & INSTANCE_DATA_FLAG_MULTIMESH || inst->mesh_instance.is_valid(); - if (prev_surface != nullptr && !cant_repeat && prev_surface->sort.sort_key1 == surface->sort.sort_key1 && prev_surface->sort.sort_key2 == surface->sort.sort_key2) { + if (prev_surface != nullptr && !cant_repeat && prev_surface->sort.sort_key1 == surface->sort.sort_key1 && prev_surface->sort.sort_key2 == surface->sort.sort_key2 && repeats < RenderElementInfo::MAX_REPEATS) { //this element is the same as the previous one, count repeats to draw it using instancing repeats++; } else { @@ -868,6 +879,8 @@ void RenderForwardClustered::_fill_instance_data(RenderListType p_render_list, i element_info.lod_index = surface->sort.lod_index; element_info.uses_forward_gi = surface->sort.uses_forward_gi; element_info.uses_lightmap = surface->sort.uses_lightmap; + element_info.uses_softshadow = surface->sort.uses_softshadow; + element_info.uses_projector = surface->sort.uses_projector; if (cant_repeat) { prev_surface = nullptr; @@ -1375,7 +1388,7 @@ void RenderForwardClustered::_render_scene(RenderDataRD *p_render_data, const Co RID rp_uniform_set = _setup_render_pass_uniform_set(RENDER_LIST_OPAQUE, nullptr, RID()); bool finish_depth = using_ssao || using_sdfgi || using_voxelgi; - RenderListParameters render_list_params(render_list[RENDER_LIST_OPAQUE].elements.ptr(), render_list[RENDER_LIST_OPAQUE].element_info.ptr(), render_list[RENDER_LIST_OPAQUE].elements.size(), reverse_cull, depth_pass_mode, render_buffer == nullptr, rp_uniform_set, get_debug_draw_mode() == RS::VIEWPORT_DEBUG_DRAW_WIREFRAME, Vector2(), p_render_data->lod_camera_plane, p_render_data->lod_distance_multiplier, p_render_data->screen_lod_threshold); + RenderListParameters render_list_params(render_list[RENDER_LIST_OPAQUE].elements.ptr(), render_list[RENDER_LIST_OPAQUE].element_info.ptr(), render_list[RENDER_LIST_OPAQUE].elements.size(), reverse_cull, depth_pass_mode, render_buffer == nullptr, p_render_data->directional_light_soft_shadows, rp_uniform_set, get_debug_draw_mode() == RS::VIEWPORT_DEBUG_DRAW_WIREFRAME, Vector2(), p_render_data->lod_camera_plane, p_render_data->lod_distance_multiplier, p_render_data->screen_lod_threshold); _render_list_with_threads(&render_list_params, depth_framebuffer, needs_pre_resolve ? RD::INITIAL_ACTION_CONTINUE : RD::INITIAL_ACTION_CLEAR, RD::FINAL_ACTION_READ, needs_pre_resolve ? RD::INITIAL_ACTION_CONTINUE : RD::INITIAL_ACTION_CLEAR, finish_depth ? RD::FINAL_ACTION_READ : RD::FINAL_ACTION_CONTINUE, needs_pre_resolve ? Vector<Color>() : depth_pass_clear); RD::get_singleton()->draw_command_end_label(); @@ -1432,7 +1445,7 @@ void RenderForwardClustered::_render_scene(RenderDataRD *p_render_data, const Co } RID framebuffer = using_separate_specular ? opaque_specular_framebuffer : opaque_framebuffer; - RenderListParameters render_list_params(render_list[RENDER_LIST_OPAQUE].elements.ptr(), render_list[RENDER_LIST_OPAQUE].element_info.ptr(), render_list[RENDER_LIST_OPAQUE].elements.size(), reverse_cull, using_separate_specular ? PASS_MODE_COLOR_SPECULAR : PASS_MODE_COLOR, render_buffer == nullptr, rp_uniform_set, get_debug_draw_mode() == RS::VIEWPORT_DEBUG_DRAW_WIREFRAME, Vector2(), p_render_data->lod_camera_plane, p_render_data->lod_distance_multiplier, p_render_data->screen_lod_threshold); + RenderListParameters render_list_params(render_list[RENDER_LIST_OPAQUE].elements.ptr(), render_list[RENDER_LIST_OPAQUE].element_info.ptr(), render_list[RENDER_LIST_OPAQUE].elements.size(), reverse_cull, using_separate_specular ? PASS_MODE_COLOR_SPECULAR : PASS_MODE_COLOR, render_buffer == nullptr, p_render_data->directional_light_soft_shadows, rp_uniform_set, get_debug_draw_mode() == RS::VIEWPORT_DEBUG_DRAW_WIREFRAME, Vector2(), p_render_data->lod_camera_plane, p_render_data->lod_distance_multiplier, p_render_data->screen_lod_threshold); _render_list_with_threads(&render_list_params, framebuffer, keep_color ? RD::INITIAL_ACTION_KEEP : RD::INITIAL_ACTION_CLEAR, will_continue_color ? RD::FINAL_ACTION_CONTINUE : RD::FINAL_ACTION_READ, depth_pre_pass ? (continue_depth ? RD::INITIAL_ACTION_CONTINUE : RD::INITIAL_ACTION_KEEP) : RD::INITIAL_ACTION_CLEAR, will_continue_depth ? RD::FINAL_ACTION_CONTINUE : RD::FINAL_ACTION_READ, c, 1.0, 0); if (will_continue_color && using_separate_specular) { // close the specular framebuffer, as it's no longer used @@ -1529,7 +1542,7 @@ void RenderForwardClustered::_render_scene(RenderDataRD *p_render_data, const Co _setup_environment(p_render_data, p_render_data->reflection_probe.is_valid(), screen_size, !p_render_data->reflection_probe.is_valid(), p_default_bg_color, false); { - RenderListParameters render_list_params(render_list[RENDER_LIST_ALPHA].elements.ptr(), render_list[RENDER_LIST_ALPHA].element_info.ptr(), render_list[RENDER_LIST_ALPHA].elements.size(), false, PASS_MODE_COLOR, render_buffer == nullptr, rp_uniform_set, get_debug_draw_mode() == RS::VIEWPORT_DEBUG_DRAW_WIREFRAME, Vector2(), p_render_data->lod_camera_plane, p_render_data->lod_distance_multiplier, p_render_data->screen_lod_threshold); + RenderListParameters render_list_params(render_list[RENDER_LIST_ALPHA].elements.ptr(), render_list[RENDER_LIST_ALPHA].element_info.ptr(), render_list[RENDER_LIST_ALPHA].elements.size(), false, PASS_MODE_COLOR, render_buffer == nullptr, p_render_data->directional_light_soft_shadows, rp_uniform_set, get_debug_draw_mode() == RS::VIEWPORT_DEBUG_DRAW_WIREFRAME, Vector2(), p_render_data->lod_camera_plane, p_render_data->lod_distance_multiplier, p_render_data->screen_lod_threshold); _render_list_with_threads(&render_list_params, alpha_framebuffer, can_continue_color ? RD::INITIAL_ACTION_CONTINUE : RD::INITIAL_ACTION_KEEP, RD::FINAL_ACTION_READ, can_continue_depth ? RD::INITIAL_ACTION_CONTINUE : RD::INITIAL_ACTION_KEEP, RD::FINAL_ACTION_READ); } @@ -1631,7 +1644,7 @@ void RenderForwardClustered::_render_shadow_end(uint32_t p_barrier) { for (uint32_t i = 0; i < scene_state.shadow_passes.size(); i++) { SceneState::ShadowPass &shadow_pass = scene_state.shadow_passes[i]; - RenderListParameters render_list_parameters(render_list[RENDER_LIST_SECONDARY].elements.ptr() + shadow_pass.element_from, render_list[RENDER_LIST_SECONDARY].element_info.ptr() + shadow_pass.element_from, shadow_pass.element_count, shadow_pass.flip_cull, shadow_pass.pass_mode, true, shadow_pass.rp_uniform_set, false, Vector2(), shadow_pass.camera_plane, shadow_pass.lod_distance_multiplier, shadow_pass.screen_lod_threshold, shadow_pass.element_from, RD::BARRIER_MASK_NO_BARRIER); + RenderListParameters render_list_parameters(render_list[RENDER_LIST_SECONDARY].elements.ptr() + shadow_pass.element_from, render_list[RENDER_LIST_SECONDARY].element_info.ptr() + shadow_pass.element_from, shadow_pass.element_count, shadow_pass.flip_cull, shadow_pass.pass_mode, true, false, shadow_pass.rp_uniform_set, false, Vector2(), shadow_pass.camera_plane, shadow_pass.lod_distance_multiplier, shadow_pass.screen_lod_threshold, shadow_pass.element_from, RD::BARRIER_MASK_NO_BARRIER); _render_list_with_threads(&render_list_parameters, shadow_pass.framebuffer, RD::INITIAL_ACTION_DROP, RD::FINAL_ACTION_DISCARD, shadow_pass.initial_depth_action, shadow_pass.final_depth_action, Vector<Color>(), 1.0, 0, shadow_pass.rect); } @@ -1672,7 +1685,7 @@ void RenderForwardClustered::_render_particle_collider_heightfield(RID p_fb, con { //regular forward for now - RenderListParameters render_list_params(render_list[RENDER_LIST_SECONDARY].elements.ptr(), render_list[RENDER_LIST_SECONDARY].element_info.ptr(), render_list[RENDER_LIST_SECONDARY].elements.size(), false, pass_mode, true, rp_uniform_set); + RenderListParameters render_list_params(render_list[RENDER_LIST_SECONDARY].elements.ptr(), render_list[RENDER_LIST_SECONDARY].element_info.ptr(), render_list[RENDER_LIST_SECONDARY].elements.size(), false, pass_mode, true, false, rp_uniform_set); _render_list_with_threads(&render_list_params, p_fb, RD::INITIAL_ACTION_CLEAR, RD::FINAL_ACTION_READ, RD::INITIAL_ACTION_CLEAR, RD::FINAL_ACTION_READ); } RD::get_singleton()->draw_command_end_label(); @@ -1707,7 +1720,7 @@ void RenderForwardClustered::_render_material(const Transform3D &p_cam_transform RENDER_TIMESTAMP("Render Material"); { - RenderListParameters render_list_params(render_list[RENDER_LIST_SECONDARY].elements.ptr(), render_list[RENDER_LIST_SECONDARY].element_info.ptr(), render_list[RENDER_LIST_SECONDARY].elements.size(), true, pass_mode, true, rp_uniform_set); + RenderListParameters render_list_params(render_list[RENDER_LIST_SECONDARY].elements.ptr(), render_list[RENDER_LIST_SECONDARY].element_info.ptr(), render_list[RENDER_LIST_SECONDARY].elements.size(), true, pass_mode, true, false, rp_uniform_set); //regular forward for now Vector<Color> clear; clear.push_back(Color(0, 0, 0, 0)); @@ -1750,7 +1763,7 @@ void RenderForwardClustered::_render_uv2(const PagedArray<GeometryInstance *> &p RENDER_TIMESTAMP("Render Material"); { - RenderListParameters render_list_params(render_list[RENDER_LIST_SECONDARY].elements.ptr(), render_list[RENDER_LIST_SECONDARY].element_info.ptr(), render_list[RENDER_LIST_SECONDARY].elements.size(), true, pass_mode, true, rp_uniform_set, true); + RenderListParameters render_list_params(render_list[RENDER_LIST_SECONDARY].elements.ptr(), render_list[RENDER_LIST_SECONDARY].element_info.ptr(), render_list[RENDER_LIST_SECONDARY].elements.size(), true, pass_mode, true, false, rp_uniform_set, true); //regular forward for now Vector<Color> clear; clear.push_back(Color(0, 0, 0, 0)); @@ -1868,7 +1881,7 @@ void RenderForwardClustered::_render_sdfgi(RID p_render_buffers, const Vector3i E = sdfgi_framebuffer_size_cache.insert(fb_size, fb); } - RenderListParameters render_list_params(render_list[RENDER_LIST_SECONDARY].elements.ptr(), render_list[RENDER_LIST_SECONDARY].element_info.ptr(), render_list[RENDER_LIST_SECONDARY].elements.size(), true, pass_mode, true, rp_uniform_set, false); + RenderListParameters render_list_params(render_list[RENDER_LIST_SECONDARY].elements.ptr(), render_list[RENDER_LIST_SECONDARY].element_info.ptr(), render_list[RENDER_LIST_SECONDARY].elements.size(), true, pass_mode, true, false, rp_uniform_set, false); _render_list_with_threads(&render_list_params, E->get(), RD::INITIAL_ACTION_DROP, RD::FINAL_ACTION_DISCARD, RD::INITIAL_ACTION_DROP, RD::FINAL_ACTION_DISCARD, Vector<Color>(), 1.0, 0, Rect2(), sbs); } @@ -1924,13 +1937,67 @@ void RenderForwardClustered::_update_render_base_uniform_set() { { RD::Uniform u; u.binding = 3; + u.uniform_type = RD::UNIFORM_TYPE_SAMPLER; + RID sampler; + switch (decals_get_filter()) { + case RS::DECAL_FILTER_NEAREST: { + sampler = storage->sampler_rd_get_default(RS::CANVAS_ITEM_TEXTURE_FILTER_NEAREST, RS::CANVAS_ITEM_TEXTURE_REPEAT_DISABLED); + } break; + case RS::DECAL_FILTER_NEAREST_MIPMAPS: { + sampler = storage->sampler_rd_get_default(RS::CANVAS_ITEM_TEXTURE_FILTER_NEAREST_WITH_MIPMAPS, RS::CANVAS_ITEM_TEXTURE_REPEAT_DISABLED); + } break; + case RS::DECAL_FILTER_LINEAR: { + sampler = storage->sampler_rd_get_default(RS::CANVAS_ITEM_TEXTURE_FILTER_LINEAR, RS::CANVAS_ITEM_TEXTURE_REPEAT_DISABLED); + } break; + case RS::DECAL_FILTER_LINEAR_MIPMAPS: { + sampler = storage->sampler_rd_get_default(RS::CANVAS_ITEM_TEXTURE_FILTER_LINEAR_WITH_MIPMAPS, RS::CANVAS_ITEM_TEXTURE_REPEAT_DISABLED); + } break; + case RS::DECAL_FILTER_LINEAR_MIPMAPS_ANISOTROPIC: { + sampler = storage->sampler_rd_get_default(RS::CANVAS_ITEM_TEXTURE_FILTER_LINEAR_WITH_MIPMAPS_ANISOTROPIC, RS::CANVAS_ITEM_TEXTURE_REPEAT_DISABLED); + } break; + } + + u.ids.push_back(sampler); + uniforms.push_back(u); + } + + { + RD::Uniform u; + u.binding = 4; + u.uniform_type = RD::UNIFORM_TYPE_SAMPLER; + RID sampler; + switch (light_projectors_get_filter()) { + case RS::LIGHT_PROJECTOR_FILTER_NEAREST: { + sampler = storage->sampler_rd_get_default(RS::CANVAS_ITEM_TEXTURE_FILTER_NEAREST, RS::CANVAS_ITEM_TEXTURE_REPEAT_DISABLED); + } break; + case RS::LIGHT_PROJECTOR_FILTER_NEAREST_MIPMAPS: { + sampler = storage->sampler_rd_get_default(RS::CANVAS_ITEM_TEXTURE_FILTER_NEAREST_WITH_MIPMAPS, RS::CANVAS_ITEM_TEXTURE_REPEAT_DISABLED); + } break; + case RS::LIGHT_PROJECTOR_FILTER_LINEAR: { + sampler = storage->sampler_rd_get_default(RS::CANVAS_ITEM_TEXTURE_FILTER_LINEAR, RS::CANVAS_ITEM_TEXTURE_REPEAT_DISABLED); + } break; + case RS::LIGHT_PROJECTOR_FILTER_LINEAR_MIPMAPS: { + sampler = storage->sampler_rd_get_default(RS::CANVAS_ITEM_TEXTURE_FILTER_LINEAR_WITH_MIPMAPS, RS::CANVAS_ITEM_TEXTURE_REPEAT_DISABLED); + } break; + case RS::LIGHT_PROJECTOR_FILTER_LINEAR_MIPMAPS_ANISOTROPIC: { + sampler = storage->sampler_rd_get_default(RS::CANVAS_ITEM_TEXTURE_FILTER_LINEAR_WITH_MIPMAPS_ANISOTROPIC, RS::CANVAS_ITEM_TEXTURE_REPEAT_DISABLED); + } break; + } + + u.ids.push_back(sampler); + uniforms.push_back(u); + } + + { + RD::Uniform u; + u.binding = 5; u.uniform_type = RD::UNIFORM_TYPE_STORAGE_BUFFER; u.ids.push_back(get_omni_light_buffer()); uniforms.push_back(u); } { RD::Uniform u; - u.binding = 4; + u.binding = 6; u.uniform_type = RD::UNIFORM_TYPE_STORAGE_BUFFER; u.ids.push_back(get_spot_light_buffer()); uniforms.push_back(u); @@ -1938,35 +2005,35 @@ void RenderForwardClustered::_update_render_base_uniform_set() { { RD::Uniform u; - u.binding = 5; + u.binding = 7; u.uniform_type = RD::UNIFORM_TYPE_STORAGE_BUFFER; u.ids.push_back(get_reflection_probe_buffer()); uniforms.push_back(u); } { RD::Uniform u; - u.binding = 6; + u.binding = 8; u.uniform_type = RD::UNIFORM_TYPE_UNIFORM_BUFFER; u.ids.push_back(get_directional_light_buffer()); uniforms.push_back(u); } { RD::Uniform u; - u.binding = 7; + u.binding = 9; u.uniform_type = RD::UNIFORM_TYPE_STORAGE_BUFFER; u.ids.push_back(scene_state.lightmap_buffer); uniforms.push_back(u); } { RD::Uniform u; - u.binding = 8; + u.binding = 10; u.uniform_type = RD::UNIFORM_TYPE_STORAGE_BUFFER; u.ids.push_back(scene_state.lightmap_capture_buffer); uniforms.push_back(u); } { RD::Uniform u; - u.binding = 9; + u.binding = 11; u.uniform_type = RD::UNIFORM_TYPE_TEXTURE; RID decal_atlas = storage->decal_atlas_get_texture(); u.ids.push_back(decal_atlas); @@ -1974,7 +2041,7 @@ void RenderForwardClustered::_update_render_base_uniform_set() { } { RD::Uniform u; - u.binding = 10; + u.binding = 12; u.uniform_type = RD::UNIFORM_TYPE_TEXTURE; RID decal_atlas = storage->decal_atlas_get_texture_srgb(); u.ids.push_back(decal_atlas); @@ -1982,7 +2049,7 @@ void RenderForwardClustered::_update_render_base_uniform_set() { } { RD::Uniform u; - u.binding = 11; + u.binding = 13; u.uniform_type = RD::UNIFORM_TYPE_STORAGE_BUFFER; u.ids.push_back(get_decal_buffer()); uniforms.push_back(u); @@ -1991,7 +2058,7 @@ void RenderForwardClustered::_update_render_base_uniform_set() { { RD::Uniform u; u.uniform_type = RD::UNIFORM_TYPE_STORAGE_BUFFER; - u.binding = 12; + u.binding = 14; u.ids.push_back(storage->global_variables_get_storage_buffer()); uniforms.push_back(u); } @@ -1999,7 +2066,7 @@ void RenderForwardClustered::_update_render_base_uniform_set() { { RD::Uniform u; u.uniform_type = RD::UNIFORM_TYPE_UNIFORM_BUFFER; - u.binding = 13; + u.binding = 15; u.ids.push_back(sdfgi_get_ubo()); uniforms.push_back(u); } @@ -2511,12 +2578,14 @@ void RenderForwardClustered::_geometry_instance_add_surface_with_material(Geomet sdcache->sort.sort_key2 = 0; sdcache->sort.surface_index = p_surface; - sdcache->sort.material_id_low = p_material_id & 0x3FFF; - sdcache->sort.material_id_hi = p_material_id >> 14; + sdcache->sort.material_id_low = p_material_id & 0xFFFF; + sdcache->sort.material_id_hi = p_material_id >> 16; sdcache->sort.shader_id = p_shader_id; sdcache->sort.geometry_id = p_mesh.get_local_index(); //only meshes can repeat anyway sdcache->sort.uses_forward_gi = ginstance->can_sdfgi; sdcache->sort.priority = p_material->priority; + sdcache->sort.uses_projector = ginstance->using_projectors; + sdcache->sort.uses_softshadow = ginstance->using_softshadows; } void RenderForwardClustered::_geometry_instance_add_surface(GeometryInstanceForwardClustered *ginstance, uint32_t p_surface, RID p_material, RID p_mesh) { @@ -2911,6 +2980,56 @@ void RenderForwardClustered::geometry_instance_pair_voxel_gi_instances(GeometryI } } +void RenderForwardClustered::geometry_instance_set_softshadow_projector_pairing(GeometryInstance *p_geometry_instance, bool p_softshadow, bool p_projector) { + GeometryInstanceForwardClustered *ginstance = static_cast<GeometryInstanceForwardClustered *>(p_geometry_instance); + ERR_FAIL_COND(!ginstance); + ginstance->using_projectors = p_projector; + ginstance->using_softshadows = p_softshadow; + _geometry_instance_mark_dirty(ginstance); +} + +void RenderForwardClustered::_update_shader_quality_settings() { + Vector<RD::PipelineSpecializationConstant> spec_constants; + + RD::PipelineSpecializationConstant sc; + sc.type = RD::PIPELINE_SPECIALIZATION_CONSTANT_TYPE_INT; + + sc.constant_id = SPEC_CONSTANT_SOFT_SHADOW_SAMPLES; + sc.int_value = soft_shadow_samples_get(); + + spec_constants.push_back(sc); + + sc.constant_id = SPEC_CONSTANT_PENUMBRA_SHADOW_SAMPLES; + sc.int_value = penumbra_shadow_samples_get(); + + spec_constants.push_back(sc); + + sc.constant_id = SPEC_CONSTANT_DIRECTIONAL_SOFT_SHADOW_SAMPLES; + sc.int_value = directional_soft_shadow_samples_get(); + + spec_constants.push_back(sc); + + sc.constant_id = SPEC_CONSTANT_DIRECTIONAL_PENUMBRA_SHADOW_SAMPLES; + sc.int_value = directional_penumbra_shadow_samples_get(); + + spec_constants.push_back(sc); + + sc.type = RD::PIPELINE_SPECIALIZATION_CONSTANT_TYPE_BOOL; + sc.constant_id = SPEC_CONSTANT_DECAL_FILTER; + sc.bool_value = decals_get_filter() == RS::DECAL_FILTER_NEAREST_MIPMAPS || decals_get_filter() == RS::DECAL_FILTER_LINEAR_MIPMAPS || decals_get_filter() == RS::DECAL_FILTER_LINEAR_MIPMAPS_ANISOTROPIC; + + spec_constants.push_back(sc); + + sc.constant_id = SPEC_CONSTANT_PROJECTOR_FILTER; + sc.bool_value = light_projectors_get_filter() == RS::LIGHT_PROJECTOR_FILTER_NEAREST_MIPMAPS || light_projectors_get_filter() == RS::LIGHT_PROJECTOR_FILTER_LINEAR_MIPMAPS || light_projectors_get_filter() == RS::LIGHT_PROJECTOR_FILTER_LINEAR_MIPMAPS_ANISOTROPIC; + + spec_constants.push_back(sc); + + scene_shader.set_default_specialization_constants(spec_constants); + + _base_uniforms_changed(); //also need this +} + RenderForwardClustered::RenderForwardClustered(RendererStorageRD *p_storage) : RendererSceneRenderRD(p_storage) { singleton = this; @@ -2948,6 +3067,8 @@ RenderForwardClustered::RenderForwardClustered(RendererStorageRD *p_storage) : } render_list_thread_threshold = GLOBAL_GET("rendering/limits/forward_renderer/threaded_render_minimum_instances"); + + _update_shader_quality_settings(); } RenderForwardClustered::~RenderForwardClustered() { diff --git a/servers/rendering/renderer_rd/forward_clustered/render_forward_clustered.h b/servers/rendering/renderer_rd/forward_clustered/render_forward_clustered.h index 750c0167e7..6682c5e9b0 100644 --- a/servers/rendering/renderer_rd/forward_clustered/render_forward_clustered.h +++ b/servers/rendering/renderer_rd/forward_clustered/render_forward_clustered.h @@ -51,6 +51,15 @@ class RenderForwardClustered : public RendererSceneRenderRD { }; enum { + SPEC_CONSTANT_SOFT_SHADOW_SAMPLES = 6, + SPEC_CONSTANT_PENUMBRA_SHADOW_SAMPLES = 7, + SPEC_CONSTANT_DIRECTIONAL_SOFT_SHADOW_SAMPLES = 8, + SPEC_CONSTANT_DIRECTIONAL_PENUMBRA_SHADOW_SAMPLES = 9, + SPEC_CONSTANT_DECAL_FILTER = 10, + SPEC_CONSTANT_PROJECTOR_FILTER = 11, + }; + + enum { SDFGI_MAX_CASCADES = 8, MAX_VOXEL_GI_INSTANCESS = 8, MAX_LIGHTMAPS = 8, @@ -156,8 +165,9 @@ class RenderForwardClustered : public RendererSceneRenderRD { RD::FramebufferFormatID framebuffer_format = 0; uint32_t element_offset = 0; uint32_t barrier = RD::BARRIER_MASK_ALL; + bool use_directional_soft_shadow = false; - RenderListParameters(GeometryInstanceSurfaceDataCache **p_elements, RenderElementInfo *p_element_info, int p_element_count, bool p_reverse_cull, PassMode p_pass_mode, bool p_no_gi, RID p_render_pass_uniform_set, bool p_force_wireframe = false, const Vector2 &p_uv_offset = Vector2(), const Plane &p_lod_plane = Plane(), float p_lod_distance_multiplier = 0.0, float p_screen_lod_threshold = 0.0, uint32_t p_element_offset = 0, uint32_t p_barrier = RD::BARRIER_MASK_ALL) { + RenderListParameters(GeometryInstanceSurfaceDataCache **p_elements, RenderElementInfo *p_element_info, int p_element_count, bool p_reverse_cull, PassMode p_pass_mode, bool p_no_gi, bool p_use_directional_soft_shadows, RID p_render_pass_uniform_set, bool p_force_wireframe = false, const Vector2 &p_uv_offset = Vector2(), const Plane &p_lod_plane = Plane(), float p_lod_distance_multiplier = 0.0, float p_screen_lod_threshold = 0.0, uint32_t p_element_offset = 0, uint32_t p_barrier = RD::BARRIER_MASK_ALL) { elements = p_elements; element_info = p_element_info; element_count = p_element_count; @@ -172,6 +182,7 @@ class RenderForwardClustered : public RendererSceneRenderRD { screen_lod_threshold = p_screen_lod_threshold; element_offset = p_element_offset; barrier = p_barrier; + use_directional_soft_shadow = p_use_directional_soft_shadows; } }; @@ -220,11 +231,6 @@ class RenderForwardClustered : public RendererSceneRenderRD { float penumbra_shadow_kernel[128]; float soft_shadow_kernel[128]; - uint32_t directional_penumbra_shadow_samples; - uint32_t directional_soft_shadow_samples; - uint32_t penumbra_shadow_samples; - uint32_t soft_shadow_samples; - float ambient_light_color_energy[4]; float ambient_color_sky_mix; @@ -353,7 +359,10 @@ class RenderForwardClustered : public RendererSceneRenderRD { void _setup_lightmaps(const PagedArray<RID> &p_lightmaps, const Transform3D &p_cam_transform); struct RenderElementInfo { - uint32_t repeat : 22; + enum { MAX_REPEATS = (1 << 20) - 1 }; + uint32_t repeat : 20; + uint32_t uses_projector : 1; + uint32_t uses_softshadow : 1; uint32_t uses_lightmap : 1; uint32_t uses_forward_gi : 1; uint32_t lod_index : 8; @@ -402,12 +411,14 @@ class RenderForwardClustered : public RendererSceneRenderRD { union { struct { uint64_t lod_index : 8; - uint64_t surface_index : 10; + uint64_t surface_index : 8; uint64_t geometry_id : 32; - uint64_t material_id_low : 14; + uint64_t material_id_low : 16; - uint64_t material_id_hi : 18; + uint64_t material_id_hi : 16; uint64_t shader_id : 32; + uint64_t uses_softshadow : 1; + uint64_t uses_projector : 1; uint64_t uses_forward_gi : 1; uint64_t uses_lightmap : 1; uint64_t depth_layer : 4; @@ -455,6 +466,8 @@ class RenderForwardClustered : public RendererSceneRenderRD { uint32_t trail_steps = 1; RID mesh_instance; bool can_sdfgi = false; + bool using_projectors = false; + bool using_softshadows = false; //used during setup uint32_t base_flags = 0; Transform3D transform; @@ -564,6 +577,8 @@ class RenderForwardClustered : public RendererSceneRenderRD { RenderList render_list[RENDER_LIST_MAX]; + virtual void _update_shader_quality_settings() override; + protected: virtual void _render_scene(RenderDataRD *p_render_data, const Color &p_default_bg_color) override; @@ -604,6 +619,8 @@ public: virtual void geometry_instance_pair_decal_instances(GeometryInstance *p_geometry_instance, const RID *p_decal_instances, uint32_t p_decal_instance_count) override; virtual void geometry_instance_pair_voxel_gi_instances(GeometryInstance *p_geometry_instance, const RID *p_voxel_gi_instances, uint32_t p_voxel_gi_instance_count) override; + virtual void geometry_instance_set_softshadow_projector_pairing(GeometryInstance *p_geometry_instance, bool p_softshadow, bool p_projector) override; + virtual bool free(RID p_rid) override; RenderForwardClustered(RendererStorageRD *p_storage); diff --git a/servers/rendering/renderer_rd/forward_clustered/scene_shader_forward_clustered.cpp b/servers/rendering/renderer_rd/forward_clustered/scene_shader_forward_clustered.cpp index d39823a1a3..333e87bdbd 100644 --- a/servers/rendering/renderer_rd/forward_clustered/scene_shader_forward_clustered.cpp +++ b/servers/rendering/renderer_rd/forward_clustered/scene_shader_forward_clustered.cpp @@ -287,7 +287,7 @@ void SceneShaderForwardClustered::ShaderData::set_code(const String &p_code) { multisample_state.enable_alpha_to_one = true; } - if (k == SHADER_VERSION_COLOR_PASS || k == SHADER_VERSION_COLOR_PASS_WITH_FORWARD_GI || k == SHADER_VERSION_LIGHTMAP_COLOR_PASS) { + if (k == SHADER_VERSION_COLOR_PASS || k == SHADER_VERSION_LIGHTMAP_COLOR_PASS) { blend_state = blend_state_blend; if (depth_draw == DEPTH_DRAW_OPAQUE) { depth_stencil.enable_depth_write = false; //alpha does not draw depth @@ -305,7 +305,7 @@ void SceneShaderForwardClustered::ShaderData::set_code(const String &p_code) { continue; // do not use this version (will error if using it is attempted) } } else { - if (k == SHADER_VERSION_COLOR_PASS || k == SHADER_VERSION_COLOR_PASS_WITH_FORWARD_GI || k == SHADER_VERSION_LIGHTMAP_COLOR_PASS) { + if (k == SHADER_VERSION_COLOR_PASS || k == SHADER_VERSION_LIGHTMAP_COLOR_PASS) { blend_state = blend_state_opaque; } else if (k == SHADER_VERSION_DEPTH_PASS || k == SHADER_VERSION_DEPTH_PASS_DP) { //none, leave empty @@ -324,7 +324,7 @@ void SceneShaderForwardClustered::ShaderData::set_code(const String &p_code) { } RID shader_variant = shader_singleton->shader.version_get_shader(version, k); - pipelines[i][j][k].setup(shader_variant, primitive_rd, raster_state, multisample_state, depth_stencil, blend_state, 0); + pipelines[i][j][k].setup(shader_variant, primitive_rd, raster_state, multisample_state, depth_stencil, blend_state, 0, singleton->default_specialization_constants); } } } @@ -408,7 +408,8 @@ RS::ShaderNativeSourceCode SceneShaderForwardClustered::ShaderData::get_native_s return shader_singleton->shader.version_get_native_source_code(version); } -SceneShaderForwardClustered::ShaderData::ShaderData() { +SceneShaderForwardClustered::ShaderData::ShaderData() : + shader_list_element(this) { valid = false; uses_screen_texture = false; } @@ -424,6 +425,7 @@ SceneShaderForwardClustered::ShaderData::~ShaderData() { RendererStorageRD::ShaderData *SceneShaderForwardClustered::_create_shader_func() { ShaderData *shader_data = memnew(ShaderData); + singleton->shader_list.add(&shader_data->shader_list_element); return shader_data; } @@ -483,7 +485,6 @@ void SceneShaderForwardClustered::init(RendererStorageRD *p_storage, const Strin shader_versions.push_back("\n#define MODE_RENDER_DEPTH\n#define MODE_RENDER_MATERIAL\n"); // SHADER_VERSION_DEPTH_PASS_WITH_MATERIAL shader_versions.push_back("\n#define MODE_RENDER_DEPTH\n#define MODE_RENDER_SDF\n"); // SHADER_VERSION_DEPTH_PASS_WITH_SDF shader_versions.push_back(""); // SHADER_VERSION_COLOR_PASS - shader_versions.push_back("\n#define USE_FORWARD_GI\n"); // SHADER_VERSION_COLOR_PASS_WITH_FORWARD_GI shader_versions.push_back("\n#define MODE_MULTIPLE_RENDER_TARGETS\n"); // SHADER_VERSION_COLOR_PASS_WITH_SEPARATE_SPECULAR shader_versions.push_back("\n#define USE_LIGHTMAP\n"); // SHADER_VERSION_LIGHTMAP_COLOR_PASS shader_versions.push_back("\n#define MODE_MULTIPLE_RENDER_TARGETS\n#define USE_LIGHTMAP\n"); // SHADER_VERSION_LIGHTMAP_COLOR_PASS_WITH_SEPARATE_SPECULAR @@ -682,7 +683,19 @@ void SceneShaderForwardClustered::init(RendererStorageRD *p_storage, const Strin //default material and shader default_shader = storage->shader_allocate(); storage->shader_initialize(default_shader); - storage->shader_set_code(default_shader, "shader_type spatial; void vertex() { ROUGHNESS = 0.8; } void fragment() { ALBEDO=vec3(0.6); ROUGHNESS=0.8; METALLIC=0.2; } \n"); + storage->shader_set_code(default_shader, R"( +shader_type spatial; + +void vertex() { + ROUGHNESS = 0.8; +} + +void fragment() { + ALBEDO = vec3(0.6); + ROUGHNESS = 0.8; + METALLIC = 0.2; +} +)"); default_material = storage->material_allocate(); storage->material_initialize(default_material); storage->material_set_shader(default_material, default_shader); @@ -699,7 +712,16 @@ void SceneShaderForwardClustered::init(RendererStorageRD *p_storage, const Strin overdraw_material_shader = storage->shader_allocate(); storage->shader_initialize(overdraw_material_shader); // Use relatively low opacity so that more "layers" of overlapping objects can be distinguished. - storage->shader_set_code(overdraw_material_shader, "shader_type spatial;\nrender_mode blend_add,unshaded;\n void fragment() { ALBEDO=vec3(0.4,0.8,0.8); ALPHA=0.1; }"); + storage->shader_set_code(overdraw_material_shader, R"( +shader_type spatial; + +render_mode blend_add, unshaded; + +void fragment() { + ALBEDO = vec3(0.4, 0.8, 0.8); + ALPHA = 0.1; +} +)"); overdraw_material = storage->material_allocate(); storage->material_initialize(overdraw_material); storage->material_set_shader(overdraw_material, overdraw_material_shader); @@ -729,3 +751,16 @@ void SceneShaderForwardClustered::init(RendererStorageRD *p_storage, const Strin shadow_sampler = RD::get_singleton()->sampler_create(sampler); } } + +void SceneShaderForwardClustered::set_default_specialization_constants(const Vector<RD::PipelineSpecializationConstant> &p_constants) { + default_specialization_constants = p_constants; + for (SelfList<ShaderData> *E = shader_list.first(); E; E = E->next()) { + for (int i = 0; i < ShaderData::CULL_VARIANT_MAX; i++) { + for (int j = 0; j < RS::PRIMITIVE_MAX; j++) { + for (int k = 0; k < SHADER_VERSION_MAX; k++) { + E->self()->pipelines[i][j][k].update_specialization_constants(default_specialization_constants); + } + } + } + } +} diff --git a/servers/rendering/renderer_rd/forward_clustered/scene_shader_forward_clustered.h b/servers/rendering/renderer_rd/forward_clustered/scene_shader_forward_clustered.h index 810b1f3876..8d75f30a20 100644 --- a/servers/rendering/renderer_rd/forward_clustered/scene_shader_forward_clustered.h +++ b/servers/rendering/renderer_rd/forward_clustered/scene_shader_forward_clustered.h @@ -52,7 +52,6 @@ public: SHADER_VERSION_DEPTH_PASS_WITH_MATERIAL, SHADER_VERSION_DEPTH_PASS_WITH_SDF, SHADER_VERSION_COLOR_PASS, - SHADER_VERSION_COLOR_PASS_WITH_FORWARD_GI, SHADER_VERSION_COLOR_PASS_WITH_SEPARATE_SPECULAR, SHADER_VERSION_LIGHTMAP_COLOR_PASS, SHADER_VERSION_LIGHTMAP_COLOR_PASS_WITH_SEPARATE_SPECULAR, @@ -60,6 +59,13 @@ public: SHADER_VERSION_MAX }; + enum ShaderSpecializations { + SHADER_SPECIALIZATION_FORWARD_GI = 1 << 0, + SHADER_SPECIALIZATION_PROJECTOR = 1 << 1, + SHADER_SPECIALIZATION_SOFT_SHADOWS = 1 << 2, + SHADER_SPECIALIZATION_DIRECTIONAL_SOFT_SHADOWS = 1 << 3, + }; + struct ShaderData : public RendererStorageRD::ShaderData { enum BlendMode { //used internally BLEND_MODE_MIX, @@ -154,10 +160,13 @@ public: virtual Variant get_default_parameter(const StringName &p_parameter) const; virtual RS::ShaderNativeSourceCode get_native_source_code() const; + SelfList<ShaderData> shader_list_element; ShaderData(); virtual ~ShaderData(); }; + SelfList<ShaderData>::List shader_list; + RendererStorageRD::ShaderData *_create_shader_func(); static RendererStorageRD::ShaderData *_create_shader_funcs() { return static_cast<SceneShaderForwardClustered *>(singleton)->_create_shader_func(); @@ -203,10 +212,12 @@ public: RID overdraw_material_uniform_set; ShaderData *overdraw_material_shader_ptr = nullptr; + Vector<RD::PipelineSpecializationConstant> default_specialization_constants; SceneShaderForwardClustered(); ~SceneShaderForwardClustered(); void init(RendererStorageRD *p_storage, const String p_defines); + void set_default_specialization_constants(const Vector<RD::PipelineSpecializationConstant> &p_constants); }; } // namespace RendererSceneRenderImplementation 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 7fbd6e23b0..4725599148 100644 --- a/servers/rendering/renderer_rd/forward_mobile/render_forward_mobile.cpp +++ b/servers/rendering/renderer_rd/forward_mobile/render_forward_mobile.cpp @@ -35,6 +35,34 @@ using namespace RendererSceneRenderImplementation; +RenderForwardMobile::ForwardID RenderForwardMobile::_allocate_forward_id(ForwardIDType p_type) { + int32_t index = -1; + for (uint32_t i = 0; i < forward_id_allocators[p_type].allocations.size(); i++) { + if (forward_id_allocators[p_type].allocations[i] == false) { + index = i; + break; + } + } + + if (index == -1) { + index = forward_id_allocators[p_type].allocations.size(); + forward_id_allocators[p_type].allocations.push_back(true); + forward_id_allocators[p_type].map.push_back(0xFF); + } else { + forward_id_allocators[p_type].allocations[index] = true; + } + + return index; +} +void RenderForwardMobile::_free_forward_id(ForwardIDType p_type, ForwardID p_id) { + ERR_FAIL_INDEX(p_id, (ForwardID)forward_id_allocators[p_type].allocations.size()); + forward_id_allocators[p_type].allocations[p_id] = false; +} + +void RenderForwardMobile::_map_forward_id(ForwardIDType p_type, ForwardID p_id, uint32_t p_index) { + forward_id_allocators[p_type].map[p_id] = p_index; +} + /* Render buffer */ void RenderForwardMobile::RenderBufferDataForwardMobile::clear() { @@ -65,7 +93,7 @@ void RenderForwardMobile::RenderBufferDataForwardMobile::configure(RID p_color_b color = p_color_buffer; depth = p_depth_buffer; - // re-introduce setting up msaa? For now we ignore this... + RD::DataFormat color_format = RenderForwardMobile::singleton->_render_buffers_get_color_format(); if (p_msaa == RS::VIEWPORT_MSAA_DISABLED) { Vector<RID> fb; @@ -80,7 +108,7 @@ void RenderForwardMobile::RenderBufferDataForwardMobile::configure(RID p_color_b } else { tf.texture_type = RD::TEXTURE_TYPE_2D; } - tf.format = RD::DATA_FORMAT_R16G16B16A16_SFLOAT; + tf.format = color_format; tf.width = p_width; tf.height = p_height; tf.array_layers = view_count; // create a layer for every view @@ -131,6 +159,17 @@ bool RenderForwardMobile::free(RID p_rid) { /* Render functions */ +RD::DataFormat RenderForwardMobile::_render_buffers_get_color_format() { + // Using 32bit buffers enables AFBC on mobile devices which should have a definite performance improvement (MALI G710 and newer support this on 64bit RTs) + return RD::DATA_FORMAT_A2B10G10R10_UNORM_PACK32; +} + +bool RenderForwardMobile::_render_buffers_can_be_storage() { + // Using 32bit buffers enables AFBC on mobile devices which should have a definite performance improvement (MALI G710 and newer support this on 64bit RTs) + // Doesn't support storage + return false; +} + RID RenderForwardMobile::_setup_render_pass_uniform_set(RenderListType p_render_list, const RenderDataRD *p_render_data, RID p_radiance_texture, bool p_use_directional_shadow_atlas, int p_index) { //there should always be enough uniform buffers for render passes, otherwise bugs ERR_FAIL_INDEX_V(p_index, (int)scene_state.uniform_buffers.size(), RID()); @@ -853,13 +892,67 @@ void RenderForwardMobile::_update_render_base_uniform_set() { { RD::Uniform u; u.binding = 3; + u.uniform_type = RD::UNIFORM_TYPE_SAMPLER; + RID sampler; + switch (decals_get_filter()) { + case RS::DECAL_FILTER_NEAREST: { + sampler = storage->sampler_rd_get_default(RS::CANVAS_ITEM_TEXTURE_FILTER_NEAREST, RS::CANVAS_ITEM_TEXTURE_REPEAT_DISABLED); + } break; + case RS::DECAL_FILTER_NEAREST_MIPMAPS: { + sampler = storage->sampler_rd_get_default(RS::CANVAS_ITEM_TEXTURE_FILTER_NEAREST_WITH_MIPMAPS, RS::CANVAS_ITEM_TEXTURE_REPEAT_DISABLED); + } break; + case RS::DECAL_FILTER_LINEAR: { + sampler = storage->sampler_rd_get_default(RS::CANVAS_ITEM_TEXTURE_FILTER_LINEAR, RS::CANVAS_ITEM_TEXTURE_REPEAT_DISABLED); + } break; + case RS::DECAL_FILTER_LINEAR_MIPMAPS: { + sampler = storage->sampler_rd_get_default(RS::CANVAS_ITEM_TEXTURE_FILTER_LINEAR_WITH_MIPMAPS, RS::CANVAS_ITEM_TEXTURE_REPEAT_DISABLED); + } break; + case RS::DECAL_FILTER_LINEAR_MIPMAPS_ANISOTROPIC: { + sampler = storage->sampler_rd_get_default(RS::CANVAS_ITEM_TEXTURE_FILTER_LINEAR_WITH_MIPMAPS_ANISOTROPIC, RS::CANVAS_ITEM_TEXTURE_REPEAT_DISABLED); + } break; + } + + u.ids.push_back(sampler); + uniforms.push_back(u); + } + + { + RD::Uniform u; + u.binding = 4; + u.uniform_type = RD::UNIFORM_TYPE_SAMPLER; + RID sampler; + switch (light_projectors_get_filter()) { + case RS::LIGHT_PROJECTOR_FILTER_NEAREST: { + sampler = storage->sampler_rd_get_default(RS::CANVAS_ITEM_TEXTURE_FILTER_NEAREST, RS::CANVAS_ITEM_TEXTURE_REPEAT_DISABLED); + } break; + case RS::LIGHT_PROJECTOR_FILTER_NEAREST_MIPMAPS: { + sampler = storage->sampler_rd_get_default(RS::CANVAS_ITEM_TEXTURE_FILTER_NEAREST_WITH_MIPMAPS, RS::CANVAS_ITEM_TEXTURE_REPEAT_DISABLED); + } break; + case RS::LIGHT_PROJECTOR_FILTER_LINEAR: { + sampler = storage->sampler_rd_get_default(RS::CANVAS_ITEM_TEXTURE_FILTER_LINEAR, RS::CANVAS_ITEM_TEXTURE_REPEAT_DISABLED); + } break; + case RS::LIGHT_PROJECTOR_FILTER_LINEAR_MIPMAPS: { + sampler = storage->sampler_rd_get_default(RS::CANVAS_ITEM_TEXTURE_FILTER_LINEAR_WITH_MIPMAPS, RS::CANVAS_ITEM_TEXTURE_REPEAT_DISABLED); + } break; + case RS::LIGHT_PROJECTOR_FILTER_LINEAR_MIPMAPS_ANISOTROPIC: { + sampler = storage->sampler_rd_get_default(RS::CANVAS_ITEM_TEXTURE_FILTER_LINEAR_WITH_MIPMAPS_ANISOTROPIC, RS::CANVAS_ITEM_TEXTURE_REPEAT_DISABLED); + } break; + } + + u.ids.push_back(sampler); + uniforms.push_back(u); + } + + { + RD::Uniform u; + u.binding = 5; u.uniform_type = RD::UNIFORM_TYPE_STORAGE_BUFFER; u.ids.push_back(get_omni_light_buffer()); uniforms.push_back(u); } { RD::Uniform u; - u.binding = 4; + u.binding = 6; u.uniform_type = RD::UNIFORM_TYPE_STORAGE_BUFFER; u.ids.push_back(get_spot_light_buffer()); uniforms.push_back(u); @@ -867,35 +960,35 @@ void RenderForwardMobile::_update_render_base_uniform_set() { { RD::Uniform u; - u.binding = 5; + u.binding = 7; u.uniform_type = RD::UNIFORM_TYPE_STORAGE_BUFFER; u.ids.push_back(get_reflection_probe_buffer()); uniforms.push_back(u); } { RD::Uniform u; - u.binding = 6; + u.binding = 8; u.uniform_type = RD::UNIFORM_TYPE_UNIFORM_BUFFER; u.ids.push_back(get_directional_light_buffer()); uniforms.push_back(u); } { RD::Uniform u; - u.binding = 7; + u.binding = 9; u.uniform_type = RD::UNIFORM_TYPE_STORAGE_BUFFER; u.ids.push_back(scene_state.lightmap_buffer); uniforms.push_back(u); } { RD::Uniform u; - u.binding = 8; + u.binding = 10; u.uniform_type = RD::UNIFORM_TYPE_STORAGE_BUFFER; u.ids.push_back(scene_state.lightmap_capture_buffer); uniforms.push_back(u); } { RD::Uniform u; - u.binding = 9; + u.binding = 11; u.uniform_type = RD::UNIFORM_TYPE_TEXTURE; RID decal_atlas = storage->decal_atlas_get_texture(); u.ids.push_back(decal_atlas); @@ -903,7 +996,7 @@ void RenderForwardMobile::_update_render_base_uniform_set() { } { RD::Uniform u; - u.binding = 10; + u.binding = 12; u.uniform_type = RD::UNIFORM_TYPE_TEXTURE; RID decal_atlas = storage->decal_atlas_get_texture_srgb(); u.ids.push_back(decal_atlas); @@ -911,7 +1004,7 @@ void RenderForwardMobile::_update_render_base_uniform_set() { } { RD::Uniform u; - u.binding = 11; + u.binding = 13; u.uniform_type = RD::UNIFORM_TYPE_STORAGE_BUFFER; u.ids.push_back(get_decal_buffer()); uniforms.push_back(u); @@ -920,7 +1013,7 @@ void RenderForwardMobile::_update_render_base_uniform_set() { { RD::Uniform u; u.uniform_type = RD::UNIFORM_TYPE_STORAGE_BUFFER; - u.binding = 12; + u.binding = 14; u.ids.push_back(storage->global_variables_get_storage_buffer()); uniforms.push_back(u); } @@ -1157,11 +1250,6 @@ void RenderForwardMobile::_setup_environment(const RenderDataRD *p_render_data, RendererStorageRD::store_soft_shadow_kernel(penumbra_shadow_kernel_get(), scene_state.ubo.penumbra_shadow_kernel); RendererStorageRD::store_soft_shadow_kernel(soft_shadow_kernel_get(), scene_state.ubo.soft_shadow_kernel); - scene_state.ubo.directional_penumbra_shadow_samples = directional_penumbra_shadow_samples_get(); - scene_state.ubo.directional_soft_shadow_samples = directional_soft_shadow_samples_get(); - scene_state.ubo.penumbra_shadow_samples = penumbra_shadow_samples_get(); - scene_state.ubo.soft_shadow_samples = soft_shadow_samples_get(); - Size2 screen_pixel_size = Vector2(1.0, 1.0) / Size2(p_screen_size); scene_state.ubo.screen_pixel_size[0] = screen_pixel_size.x; scene_state.ubo.screen_pixel_size[1] = screen_pixel_size.y; @@ -1392,6 +1480,44 @@ void RenderForwardMobile::_render_list_with_threads(RenderListParameters *p_para } } +void RenderForwardMobile::_fill_push_constant_instance_indices(GeometryInstanceForwardMobile::PushConstant *p_push_constant, const GeometryInstanceForwardMobile *p_instance) { + // first zero out our indices + + p_push_constant->omni_lights[0] = 0xFFFF; + p_push_constant->omni_lights[1] = 0xFFFF; + + p_push_constant->spot_lights[0] = 0xFFFF; + p_push_constant->spot_lights[1] = 0xFFFF; + + p_push_constant->decals[0] = 0xFFFF; + p_push_constant->decals[1] = 0xFFFF; + + p_push_constant->reflection_probes[0] = 0xFFFF; + p_push_constant->reflection_probes[1] = 0xFFFF; + + for (uint32_t i = 0; i < MAX_RDL_CULL; i++) { + uint32_t ofs = i < 4 ? 0 : 1; + uint32_t shift = (i & 0x3) << 3; + uint32_t mask = ~(0xFF << shift); + if (i < p_instance->omni_light_count) { + p_push_constant->omni_lights[ofs] &= mask; + p_push_constant->omni_lights[ofs] |= uint32_t(forward_id_allocators[FORWARD_ID_TYPE_OMNI_LIGHT].map[p_instance->omni_lights[i]]) << shift; + } + if (i < p_instance->spot_light_count) { + p_push_constant->spot_lights[ofs] &= mask; + p_push_constant->spot_lights[ofs] |= uint32_t(forward_id_allocators[FORWARD_ID_TYPE_SPOT_LIGHT].map[p_instance->spot_lights[i]]) << shift; + } + if (i < p_instance->decals_count) { + p_push_constant->decals[ofs] &= mask; + p_push_constant->decals[ofs] |= uint32_t(forward_id_allocators[FORWARD_ID_TYPE_DECAL].map[p_instance->decals[i]]) << shift; + } + if (i < p_instance->reflection_probe_count) { + p_push_constant->reflection_probes[ofs] &= mask; + p_push_constant->reflection_probes[ofs] |= uint32_t(forward_id_allocators[FORWARD_ID_TYPE_REFLECTION_PROBE].map[p_instance->reflection_probes[i]]) << shift; + } + } +} + template <RenderForwardMobile::PassMode p_pass_mode> void RenderForwardMobile::_render_list_template(RenderingDevice::DrawListID p_draw_list, RenderingDevice::FramebufferFormatID p_framebuffer_Format, RenderListParameters *p_params, uint32_t p_from_element, uint32_t p_to_element) { RD::DrawListID draw_list = p_draw_list; @@ -1441,8 +1567,6 @@ void RenderForwardMobile::_render_list_template(RenderingDevice::DrawListID p_dr push_constant.lightmap_uv_scale[3] = inst->lightmap_uv_scale.size.y; }; - _fill_instance_indices(inst->omni_lights, inst->omni_light_count, push_constant.omni_lights, inst->spot_lights, inst->spot_light_count, push_constant.spot_lights, inst->reflection_probes, inst->reflection_probe_count, push_constant.reflection_probes, inst->decals, inst->decals_count, push_constant.decals, push_constant.layer_mask); - RID material_uniform_set; SceneShaderForwardMobile::ShaderData *shader; void *mesh_surface; @@ -1453,6 +1577,8 @@ void RenderForwardMobile::_render_list_template(RenderingDevice::DrawListID p_dr mesh_surface = surf->surface_shadow; } else { + _fill_push_constant_instance_indices(&push_constant, inst); + #ifdef DEBUG_ENABLED if (unlikely(get_debug_draw_mode() == RS::VIEWPORT_DEBUG_DRAW_LIGHTING)) { material_uniform_set = scene_shader.default_material_uniform_set; @@ -1761,13 +1887,13 @@ void RenderForwardMobile::geometry_instance_pair_light_instances(GeometryInstanc switch (type) { case RS::LIGHT_OMNI: { if (ginstance->omni_light_count < (uint32_t)MAX_RDL_CULL) { - ginstance->omni_lights[ginstance->omni_light_count] = p_light_instances[i]; + ginstance->omni_lights[ginstance->omni_light_count] = light_instance_get_forward_id(p_light_instances[i]); ginstance->omni_light_count++; } } break; case RS::LIGHT_SPOT: { if (ginstance->spot_light_count < (uint32_t)MAX_RDL_CULL) { - ginstance->spot_lights[ginstance->spot_light_count] = p_light_instances[i]; + ginstance->spot_lights[ginstance->spot_light_count] = light_instance_get_forward_id(p_light_instances[i]); ginstance->spot_light_count++; } } break; @@ -1783,7 +1909,7 @@ void RenderForwardMobile::geometry_instance_pair_reflection_probe_instances(Geom ginstance->reflection_probe_count = p_reflection_probe_instance_count < (uint32_t)MAX_RDL_CULL ? p_reflection_probe_instance_count : (uint32_t)MAX_RDL_CULL; for (uint32_t i = 0; i < ginstance->reflection_probe_count; i++) { - ginstance->reflection_probes[i] = p_reflection_probe_instances[i]; + ginstance->reflection_probes[i] = reflection_probe_instance_get_forward_id(p_reflection_probe_instances[i]); } } @@ -1793,7 +1919,7 @@ void RenderForwardMobile::geometry_instance_pair_decal_instances(GeometryInstanc ginstance->decals_count = p_decal_instance_count < (uint32_t)MAX_RDL_CULL ? p_decal_instance_count : (uint32_t)MAX_RDL_CULL; for (uint32_t i = 0; i < ginstance->decals_count; i++) { - ginstance->decals[i] = p_decal_instances[i]; + ginstance->decals[i] = decal_instance_get_forward_id(p_decal_instances[i]); } } @@ -1801,6 +1927,9 @@ void RenderForwardMobile::geometry_instance_pair_voxel_gi_instances(GeometryInst // We do not have this here! } +void RenderForwardMobile::geometry_instance_set_softshadow_projector_pairing(GeometryInstance *p_geometry_instance, bool p_softshadow, bool p_projector) { +} + void RenderForwardMobile::_geometry_instance_mark_dirty(GeometryInstance *p_geometry_instance) { GeometryInstanceForwardMobile *ginstance = static_cast<GeometryInstanceForwardMobile *>(p_geometry_instance); if (ginstance->dirty_list_element.in_list()) { @@ -2150,10 +2279,54 @@ uint32_t RenderForwardMobile::get_max_elements() const { RenderForwardMobile *RenderForwardMobile::singleton = nullptr; +void RenderForwardMobile::_update_shader_quality_settings() { + Vector<RD::PipelineSpecializationConstant> spec_constants; + + RD::PipelineSpecializationConstant sc; + sc.type = RD::PIPELINE_SPECIALIZATION_CONSTANT_TYPE_INT; + + sc.constant_id = SPEC_CONSTANT_SOFT_SHADOW_SAMPLES; + sc.int_value = soft_shadow_samples_get(); + + spec_constants.push_back(sc); + + sc.constant_id = SPEC_CONSTANT_PENUMBRA_SHADOW_SAMPLES; + sc.int_value = penumbra_shadow_samples_get(); + + spec_constants.push_back(sc); + + sc.constant_id = SPEC_CONSTANT_DIRECTIONAL_SOFT_SHADOW_SAMPLES; + sc.int_value = directional_soft_shadow_samples_get(); + + spec_constants.push_back(sc); + + sc.constant_id = SPEC_CONSTANT_DIRECTIONAL_PENUMBRA_SHADOW_SAMPLES; + sc.int_value = directional_penumbra_shadow_samples_get(); + + spec_constants.push_back(sc); + + sc.type = RD::PIPELINE_SPECIALIZATION_CONSTANT_TYPE_BOOL; + sc.constant_id = SPEC_CONSTANT_DECAL_FILTER; + sc.bool_value = decals_get_filter() == RS::DECAL_FILTER_NEAREST_MIPMAPS || decals_get_filter() == RS::DECAL_FILTER_LINEAR_MIPMAPS || decals_get_filter() == RS::DECAL_FILTER_LINEAR_MIPMAPS_ANISOTROPIC; + + spec_constants.push_back(sc); + + sc.constant_id = SPEC_CONSTANT_PROJECTOR_FILTER; + sc.bool_value = light_projectors_get_filter() == RS::LIGHT_PROJECTOR_FILTER_NEAREST_MIPMAPS || light_projectors_get_filter() == RS::LIGHT_PROJECTOR_FILTER_LINEAR_MIPMAPS || light_projectors_get_filter() == RS::LIGHT_PROJECTOR_FILTER_LINEAR_MIPMAPS_ANISOTROPIC; + + spec_constants.push_back(sc); + + scene_shader.set_default_specialization_constants(spec_constants); + + _base_uniforms_changed(); //also need this +} + RenderForwardMobile::RenderForwardMobile(RendererStorageRD *p_storage) : RendererSceneRenderRD(p_storage) { singleton = this; + sky.set_texture_format(_render_buffers_get_color_format()); + String defines; defines += "\n#define MAX_ROUGHNESS_LOD " + itos(get_roughness_layers() - 1) + ".0\n"; @@ -2185,6 +2358,8 @@ RenderForwardMobile::RenderForwardMobile(RendererStorageRD *p_storage) : // !BAS! maybe we need a mobile version of this setting? render_list_thread_threshold = GLOBAL_GET("rendering/limits/forward_renderer/threaded_render_minimum_instances"); + + _update_shader_quality_settings(); } RenderForwardMobile::~RenderForwardMobile() { diff --git a/servers/rendering/renderer_rd/forward_mobile/render_forward_mobile.h b/servers/rendering/renderer_rd/forward_mobile/render_forward_mobile.h index f40f713c03..973925d562 100644 --- a/servers/rendering/renderer_rd/forward_mobile/render_forward_mobile.h +++ b/servers/rendering/renderer_rd/forward_mobile/render_forward_mobile.h @@ -42,6 +42,18 @@ namespace RendererSceneRenderImplementation { class RenderForwardMobile : public RendererSceneRenderRD { friend SceneShaderForwardMobile; + struct ForwardIDAllocator { + LocalVector<bool> allocations; + LocalVector<uint8_t> map; + }; + + ForwardIDAllocator forward_id_allocators[FORWARD_ID_MAX]; + + virtual ForwardID _allocate_forward_id(ForwardIDType p_type) override; + virtual void _free_forward_id(ForwardIDType p_type, ForwardID p_id) override; + virtual void _map_forward_id(ForwardIDType p_type, ForwardID p_id, uint32_t p_index) override; + virtual bool _uses_forward_ids() const override { return true; } + protected: /* Scene Shader */ @@ -53,6 +65,15 @@ protected: }; enum { + SPEC_CONSTANT_SOFT_SHADOW_SAMPLES = 6, + SPEC_CONSTANT_PENUMBRA_SHADOW_SAMPLES = 7, + SPEC_CONSTANT_DIRECTIONAL_SOFT_SHADOW_SAMPLES = 8, + SPEC_CONSTANT_DIRECTIONAL_PENUMBRA_SHADOW_SAMPLES = 9, + SPEC_CONSTANT_DECAL_FILTER = 10, + SPEC_CONSTANT_PROJECTOR_FILTER = 11, + }; + + enum { MAX_LIGHTMAPS = 8, MAX_RDL_CULL = 8, // maximum number of reflection probes, decals or lights we can cull per geometry instance INSTANCE_DATA_BUFFER_MIN_SIZE = 4096 @@ -151,6 +172,9 @@ protected: } }; + virtual RD::DataFormat _render_buffers_get_color_format() override; + virtual bool _render_buffers_can_be_storage() override; + RID _setup_render_pass_uniform_set(RenderListType p_render_list, const RenderDataRD *p_render_data, RID p_radiance_texture, bool p_use_directional_shadow_atlas = false, int p_index = 0); virtual void _render_scene(RenderDataRD *p_render_data, const Color &p_default_bg_color) override; @@ -213,11 +237,6 @@ protected: float penumbra_shadow_kernel[128]; float soft_shadow_kernel[128]; - uint32_t directional_penumbra_shadow_samples; - uint32_t directional_soft_shadow_samples; - uint32_t penumbra_shadow_samples; - uint32_t soft_shadow_samples; - float ambient_light_color_energy[4]; float ambient_color_sky_mix; @@ -513,14 +532,14 @@ protected: GeometryInstanceLightmapSH *lightmap_sh = nullptr; // culled light info - uint32_t reflection_probe_count; - RID reflection_probes[MAX_RDL_CULL]; - uint32_t omni_light_count; - RID omni_lights[MAX_RDL_CULL]; - uint32_t spot_light_count; - RID spot_lights[MAX_RDL_CULL]; - uint32_t decals_count; - RID decals[MAX_RDL_CULL]; + uint32_t reflection_probe_count = 0; + ForwardID reflection_probes[MAX_RDL_CULL]; + uint32_t omni_light_count = 0; + ForwardID omni_lights[MAX_RDL_CULL]; + uint32_t spot_light_count = 0; + ForwardID spot_lights[MAX_RDL_CULL]; + uint32_t decals_count = 0; + ForwardID decals[MAX_RDL_CULL]; GeometryInstanceSurfaceDataCache *surface_caches = nullptr; @@ -552,6 +571,10 @@ protected: dirty_list_element(this) {} }; + _FORCE_INLINE_ void _fill_push_constant_instance_indices(GeometryInstanceForwardMobile::PushConstant *p_push_constant, const GeometryInstanceForwardMobile *p_instance); + + void _update_shader_quality_settings() override; + public: static void _geometry_instance_dependency_changed(RendererStorage::DependencyChangedNotification p_notification, RendererStorage::DependencyTracker *p_tracker); static void _geometry_instance_dependency_deleted(const RID &p_dependency, RendererStorage::DependencyTracker *p_tracker); @@ -594,6 +617,8 @@ public: virtual void geometry_instance_pair_decal_instances(GeometryInstance *p_geometry_instance, const RID *p_decal_instances, uint32_t p_decal_instance_count) override; virtual void geometry_instance_pair_voxel_gi_instances(GeometryInstance *p_geometry_instance, const RID *p_voxel_gi_instances, uint32_t p_voxel_gi_instance_count) override; + virtual void geometry_instance_set_softshadow_projector_pairing(GeometryInstance *p_geometry_instance, bool p_softshadow, bool p_projector) override; + virtual bool free(RID p_rid) override; virtual bool is_dynamic_gi_supported() const override; diff --git a/servers/rendering/renderer_rd/forward_mobile/scene_shader_forward_mobile.cpp b/servers/rendering/renderer_rd/forward_mobile/scene_shader_forward_mobile.cpp index 7709c8aadc..bcdcb05653 100644 --- a/servers/rendering/renderer_rd/forward_mobile/scene_shader_forward_mobile.cpp +++ b/servers/rendering/renderer_rd/forward_mobile/scene_shader_forward_mobile.cpp @@ -318,7 +318,7 @@ void SceneShaderForwardMobile::ShaderData::set_code(const String &p_code) { } RID shader_variant = shader_singleton->shader.version_get_shader(version, k); - pipelines[i][j][k].setup(shader_variant, primitive_rd, raster_state, multisample_state, depth_stencil, blend_state, 0); + pipelines[i][j][k].setup(shader_variant, primitive_rd, raster_state, multisample_state, depth_stencil, blend_state, 0, singleton->default_specialization_constants); } } } @@ -402,7 +402,8 @@ RS::ShaderNativeSourceCode SceneShaderForwardMobile::ShaderData::get_native_sour return shader_singleton->shader.version_get_native_source_code(version); } -SceneShaderForwardMobile::ShaderData::ShaderData() { +SceneShaderForwardMobile::ShaderData::ShaderData() : + shader_list_element(this) { valid = false; uses_screen_texture = false; } @@ -418,6 +419,7 @@ SceneShaderForwardMobile::ShaderData::~ShaderData() { RendererStorageRD::ShaderData *SceneShaderForwardMobile::_create_shader_func() { ShaderData *shader_data = memnew(ShaderData); + singleton->shader_list.add(&shader_data->shader_list_element); return shader_data; } @@ -671,7 +673,19 @@ void SceneShaderForwardMobile::init(RendererStorageRD *p_storage, const String p //default material and shader default_shader = storage->shader_allocate(); storage->shader_initialize(default_shader); - storage->shader_set_code(default_shader, "shader_type spatial; void vertex() { ROUGHNESS = 0.8; } void fragment() { ALBEDO=vec3(0.6); ROUGHNESS=0.8; METALLIC=0.2; } \n"); + storage->shader_set_code(default_shader, R"( +shader_type spatial; + +void vertex() { + ROUGHNESS = 0.8; +} + +void fragment() { + ALBEDO = vec3(0.6); + ROUGHNESS = 0.8; + METALLIC = 0.2; +} +)"); default_material = storage->material_allocate(); storage->material_initialize(default_material); storage->material_set_shader(default_material, default_shader); @@ -687,7 +701,16 @@ void SceneShaderForwardMobile::init(RendererStorageRD *p_storage, const String p overdraw_material_shader = storage->shader_allocate(); storage->shader_initialize(overdraw_material_shader); // Use relatively low opacity so that more "layers" of overlapping objects can be distinguished. - storage->shader_set_code(overdraw_material_shader, "shader_type spatial;\nrender_mode blend_add,unshaded;\n void fragment() { ALBEDO=vec3(0.4,0.8,0.8); ALPHA=0.1; }"); + storage->shader_set_code(overdraw_material_shader, R"( +shader_type spatial; + +render_mode blend_add, unshaded; + +void fragment() { + ALBEDO = vec3(0.4, 0.8, 0.8); + ALPHA = 0.1; +} +)"); overdraw_material = storage->material_allocate(); storage->material_initialize(overdraw_material); storage->material_set_shader(overdraw_material, overdraw_material_shader); @@ -718,6 +741,19 @@ void SceneShaderForwardMobile::init(RendererStorageRD *p_storage, const String p } } +void SceneShaderForwardMobile::set_default_specialization_constants(const Vector<RD::PipelineSpecializationConstant> &p_constants) { + default_specialization_constants = p_constants; + for (SelfList<ShaderData> *E = shader_list.first(); E; E = E->next()) { + for (int i = 0; i < ShaderData::CULL_VARIANT_MAX; i++) { + for (int j = 0; j < RS::PRIMITIVE_MAX; j++) { + for (int k = 0; k < SHADER_VERSION_MAX; k++) { + E->self()->pipelines[i][j][k].update_specialization_constants(default_specialization_constants); + } + } + } + } +} + SceneShaderForwardMobile::~SceneShaderForwardMobile() { RD::get_singleton()->free(default_vec4_xform_buffer); RD::get_singleton()->free(shadow_sampler); diff --git a/servers/rendering/renderer_rd/forward_mobile/scene_shader_forward_mobile.h b/servers/rendering/renderer_rd/forward_mobile/scene_shader_forward_mobile.h index 5c9e35fd0d..e1c10f0206 100644 --- a/servers/rendering/renderer_rd/forward_mobile/scene_shader_forward_mobile.h +++ b/servers/rendering/renderer_rd/forward_mobile/scene_shader_forward_mobile.h @@ -151,6 +151,8 @@ public: virtual Variant get_default_parameter(const StringName &p_parameter) const; virtual RS::ShaderNativeSourceCode get_native_source_code() const; + SelfList<ShaderData> shader_list_element; + ShaderData(); virtual ~ShaderData(); }; @@ -174,6 +176,8 @@ public: virtual ~MaterialData(); }; + SelfList<ShaderData>::List shader_list; + RendererStorageRD::MaterialData *_create_material_func(ShaderData *p_shader); static RendererStorageRD::MaterialData *_create_material_funcs(RendererStorageRD::ShaderData *p_shader) { return static_cast<SceneShaderForwardMobile *>(singleton)->_create_material_func(static_cast<ShaderData *>(p_shader)); @@ -202,7 +206,10 @@ public: SceneShaderForwardMobile(); ~SceneShaderForwardMobile(); + Vector<RD::PipelineSpecializationConstant> default_specialization_constants; + void init(RendererStorageRD *p_storage, const String p_defines); + void set_default_specialization_constants(const Vector<RD::PipelineSpecializationConstant> &p_constants); }; } // namespace RendererSceneRenderImplementation diff --git a/servers/rendering/renderer_rd/pipeline_cache_rd.cpp b/servers/rendering/renderer_rd/pipeline_cache_rd.cpp index 22888ddbe5..aefe926cb0 100644 --- a/servers/rendering/renderer_rd/pipeline_cache_rd.cpp +++ b/servers/rendering/renderer_rd/pipeline_cache_rd.cpp @@ -31,14 +31,30 @@ #include "pipeline_cache_rd.h" #include "core/os/memory.h" -RID PipelineCacheRD::_generate_version(RD::VertexFormatID p_vertex_format_id, RD::FramebufferFormatID p_framebuffer_format_id, bool p_wireframe, uint32_t p_render_pass) { +RID PipelineCacheRD::_generate_version(RD::VertexFormatID p_vertex_format_id, RD::FramebufferFormatID p_framebuffer_format_id, bool p_wireframe, uint32_t p_render_pass, uint32_t p_bool_specializations) { RD::PipelineMultisampleState multisample_state_version = multisample_state; multisample_state_version.sample_count = RD::get_singleton()->framebuffer_format_get_texture_samples(p_framebuffer_format_id, p_render_pass); RD::PipelineRasterizationState raster_state_version = rasterization_state; raster_state_version.wireframe = p_wireframe; - RID pipeline = RD::get_singleton()->render_pipeline_create(shader, p_framebuffer_format_id, p_vertex_format_id, render_primitive, raster_state_version, multisample_state_version, depth_stencil_state, blend_state, dynamic_state_flags, p_render_pass); + Vector<RD::PipelineSpecializationConstant> specialization_constants = base_specialization_constants; + + uint32_t bool_index = 0; + uint32_t bool_specializations = p_bool_specializations; + while (bool_specializations) { + if (bool_specializations & (1 << bool_index)) { + RD::PipelineSpecializationConstant sc; + sc.bool_value = true; + sc.constant_id = bool_index; + sc.type = RD::PIPELINE_SPECIALIZATION_CONSTANT_TYPE_BOOL; + specialization_constants.push_back(sc); + bool_specializations &= ~(1 << bool_index); + } + bool_index++; + } + + RID pipeline = RD::get_singleton()->render_pipeline_create(shader, p_framebuffer_format_id, p_vertex_format_id, render_primitive, raster_state_version, multisample_state_version, depth_stencil_state, blend_state, dynamic_state_flags, p_render_pass, specialization_constants); ERR_FAIL_COND_V(pipeline.is_null(), RID()); versions = (Version *)memrealloc(versions, sizeof(Version) * (version_count + 1)); versions[version_count].framebuffer_id = p_framebuffer_format_id; @@ -46,11 +62,15 @@ RID PipelineCacheRD::_generate_version(RD::VertexFormatID p_vertex_format_id, RD versions[version_count].wireframe = p_wireframe; versions[version_count].pipeline = pipeline; versions[version_count].render_pass = p_render_pass; + versions[version_count].bool_specializations = p_bool_specializations; version_count++; return pipeline; } void PipelineCacheRD::_clear() { +#ifndef _MSC_VER +#warning Clear should probably recompile all the variants already compiled instead to avoid stalls? needs discussion +#endif if (versions) { for (uint32_t i = 0; i < version_count; i++) { //shader may be gone, so this may not be valid @@ -64,7 +84,7 @@ void PipelineCacheRD::_clear() { } } -void PipelineCacheRD::setup(RID p_shader, RD::RenderPrimitive p_primitive, const RD::PipelineRasterizationState &p_rasterization_state, RD::PipelineMultisampleState p_multisample, const RD::PipelineDepthStencilState &p_depth_stencil_state, const RD::PipelineColorBlendState &p_blend_state, int p_dynamic_state_flags) { +void PipelineCacheRD::setup(RID p_shader, RD::RenderPrimitive p_primitive, const RD::PipelineRasterizationState &p_rasterization_state, RD::PipelineMultisampleState p_multisample, const RD::PipelineDepthStencilState &p_depth_stencil_state, const RD::PipelineColorBlendState &p_blend_state, int p_dynamic_state_flags, const Vector<RD::PipelineSpecializationConstant> &p_base_specialization_constants) { ERR_FAIL_COND(p_shader.is_null()); _clear(); shader = p_shader; @@ -75,6 +95,11 @@ void PipelineCacheRD::setup(RID p_shader, RD::RenderPrimitive p_primitive, const depth_stencil_state = p_depth_stencil_state; blend_state = p_blend_state; dynamic_state_flags = p_dynamic_state_flags; + base_specialization_constants = p_base_specialization_constants; +} +void PipelineCacheRD::update_specialization_constants(const Vector<RD::PipelineSpecializationConstant> &p_base_specialization_constants) { + base_specialization_constants = p_base_specialization_constants; + _clear(); } void PipelineCacheRD::update_shader(RID p_shader) { diff --git a/servers/rendering/renderer_rd/pipeline_cache_rd.h b/servers/rendering/renderer_rd/pipeline_cache_rd.h index 387a8a038f..e52f47fa47 100644 --- a/servers/rendering/renderer_rd/pipeline_cache_rd.h +++ b/servers/rendering/renderer_rd/pipeline_cache_rd.h @@ -46,27 +46,30 @@ class PipelineCacheRD { RD::PipelineDepthStencilState depth_stencil_state; RD::PipelineColorBlendState blend_state; int dynamic_state_flags; + Vector<RD::PipelineSpecializationConstant> base_specialization_constants; struct Version { RD::VertexFormatID vertex_id; RD::FramebufferFormatID framebuffer_id; uint32_t render_pass; bool wireframe; + uint32_t bool_specializations; RID pipeline; }; Version *versions; uint32_t version_count; - RID _generate_version(RD::VertexFormatID p_vertex_format_id, RD::FramebufferFormatID p_framebuffer_format_id, bool p_wireframe, uint32_t p_render_pass); + RID _generate_version(RD::VertexFormatID p_vertex_format_id, RD::FramebufferFormatID p_framebuffer_format_id, bool p_wireframe, uint32_t p_render_pass, uint32_t p_bool_specializations = 0); void _clear(); public: - void setup(RID p_shader, RD::RenderPrimitive p_primitive, const RD::PipelineRasterizationState &p_rasterization_state, RD::PipelineMultisampleState p_multisample, const RD::PipelineDepthStencilState &p_depth_stencil_state, const RD::PipelineColorBlendState &p_blend_state, int p_dynamic_state_flags = 0); + void setup(RID p_shader, RD::RenderPrimitive p_primitive, const RD::PipelineRasterizationState &p_rasterization_state, RD::PipelineMultisampleState p_multisample, const RD::PipelineDepthStencilState &p_depth_stencil_state, const RD::PipelineColorBlendState &p_blend_state, int p_dynamic_state_flags = 0, const Vector<RD::PipelineSpecializationConstant> &p_base_specialization_constants = Vector<RD::PipelineSpecializationConstant>()); + void update_specialization_constants(const Vector<RD::PipelineSpecializationConstant> &p_base_specialization_constants); void update_shader(RID p_shader); - _FORCE_INLINE_ RID get_render_pipeline(RD::VertexFormatID p_vertex_format_id, RD::FramebufferFormatID p_framebuffer_format_id, bool p_wireframe = false, uint32_t p_render_pass = 0) { + _FORCE_INLINE_ RID get_render_pipeline(RD::VertexFormatID p_vertex_format_id, RD::FramebufferFormatID p_framebuffer_format_id, bool p_wireframe = false, uint32_t p_render_pass = 0, uint32_t p_bool_specializations = 0) { #ifdef DEBUG_ENABLED ERR_FAIL_COND_V_MSG(shader.is_null(), RID(), "Attempted to use an unused shader variant (shader is null),"); @@ -75,13 +78,13 @@ public: spin_lock.lock(); RID result; for (uint32_t i = 0; i < version_count; i++) { - if (versions[i].vertex_id == p_vertex_format_id && versions[i].framebuffer_id == p_framebuffer_format_id && versions[i].wireframe == p_wireframe && versions[i].render_pass == p_render_pass) { + if (versions[i].vertex_id == p_vertex_format_id && versions[i].framebuffer_id == p_framebuffer_format_id && versions[i].wireframe == p_wireframe && versions[i].render_pass == p_render_pass && versions[i].bool_specializations == p_bool_specializations) { result = versions[i].pipeline; spin_lock.unlock(); return result; } } - result = _generate_version(p_vertex_format_id, p_framebuffer_format_id, p_wireframe, p_render_pass); + result = _generate_version(p_vertex_format_id, p_framebuffer_format_id, p_wireframe, p_render_pass, p_bool_specializations); spin_lock.unlock(); return result; } diff --git a/servers/rendering/renderer_rd/renderer_canvas_render_rd.cpp b/servers/rendering/renderer_rd/renderer_canvas_render_rd.cpp index 1e3dbe69a3..18c1fe02a0 100644 --- a/servers/rendering/renderer_rd/renderer_canvas_render_rd.cpp +++ b/servers/rendering/renderer_rd/renderer_canvas_render_rd.cpp @@ -620,7 +620,7 @@ void RendererCanvasRenderRD::_render_item(RD::DrawListID p_draw_list, RID p_rend RD::get_singleton()->draw_list_bind_index_array(p_draw_list, shader.quad_index_array); RD::get_singleton()->draw_list_draw(p_draw_list, true); - //restore if overrided + // Restore if overridden. push_constant.color_texture_pixel_size[0] = texpixel_size.x; push_constant.color_texture_pixel_size[1] = texpixel_size.y; @@ -2570,8 +2570,19 @@ RendererCanvasRenderRD::RendererCanvasRenderRD(RendererStorageRD *p_storage) { default_canvas_group_shader = storage->shader_allocate(); storage->shader_initialize(default_canvas_group_shader); - storage->shader_set_code(default_canvas_group_shader, "shader_type canvas_item; \nvoid fragment() {\n\tvec4 c = textureLod(SCREEN_TEXTURE,SCREEN_UV,0.0); if (c.a > 0.0001) c.rgb/=c.a; COLOR *= c; \n}\n"); + storage->shader_set_code(default_canvas_group_shader, R"( +shader_type canvas_item; +void fragment() { + vec4 c = textureLod(SCREEN_TEXTURE, SCREEN_UV, 0.0); + + if (c.a > 0.0001) { + c.rgb /= c.a; + } + + COLOR *= c; +} +)"); default_canvas_group_material = storage->material_allocate(); storage->material_initialize(default_canvas_group_material); diff --git a/servers/rendering/renderer_rd/renderer_compositor_rd.cpp b/servers/rendering/renderer_rd/renderer_compositor_rd.cpp index a8f086b0f9..02d548bf13 100644 --- a/servers/rendering/renderer_rd/renderer_compositor_rd.cpp +++ b/servers/rendering/renderer_rd/renderer_compositor_rd.cpp @@ -173,7 +173,6 @@ void RendererCompositorRD::set_boot_image(const Ref<Image> &p_image, const Color } Size2 window_size = DisplayServer::get_singleton()->window_get_size(); - print_line("window size: " + window_size); Rect2 imgrect(0, 0, p_image->get_width(), p_image->get_height()); Rect2 screenrect; @@ -216,8 +215,6 @@ void RendererCompositorRD::set_boot_image(const Ref<Image> &p_image, const Color blit.push_constant.upscale = 1.0; blit.push_constant.aspect_ratio = 1.0; - print_line("rect: " + screenrect); - RD::get_singleton()->draw_list_set_push_constant(draw_list, &blit.push_constant, sizeof(BlitPushConstant)); RD::get_singleton()->draw_list_draw(draw_list, true); @@ -225,7 +222,7 @@ void RendererCompositorRD::set_boot_image(const Ref<Image> &p_image, const Color RD::get_singleton()->swap_buffers(); - RD::get_singleton()->free(texture); + storage->free(texture); } RendererCompositorRD *RendererCompositorRD::singleton = nullptr; @@ -283,6 +280,9 @@ RendererCompositorRD::RendererCompositorRD() { // default to our high end renderer scene = memnew(RendererSceneRenderImplementation::RenderForwardClustered(storage)); } + + // now we're ready to create our effects, + storage->init_effects(!scene->_render_buffers_can_be_storage()); } RendererCompositorRD::~RendererCompositorRD() { diff --git a/servers/rendering/renderer_rd/renderer_scene_render_rd.cpp b/servers/rendering/renderer_rd/renderer_scene_render_rd.cpp index a70514e9e5..e3516df800 100644 --- a/servers/rendering/renderer_rd/renderer_scene_render_rd.cpp +++ b/servers/rendering/renderer_rd/renderer_scene_render_rd.cpp @@ -567,6 +567,8 @@ int RendererSceneRenderRD::reflection_atlas_get_size(RID p_ref_atlas) const { RID RendererSceneRenderRD::reflection_probe_instance_create(RID p_probe) { ReflectionProbeInstance rpi; rpi.probe = p_probe; + rpi.forward_id = _allocate_forward_id(FORWARD_ID_TYPE_REFLECTION_PROBE); + return reflection_probe_instance_owner.make_rid(rpi); } @@ -627,6 +629,8 @@ bool RendererSceneRenderRD::reflection_probe_instance_begin_render(RID p_instanc ReflectionProbeInstance *rpi = reflection_probe_instance_owner.getornull(p_instance); ERR_FAIL_COND_V(!rpi, false); + RD::get_singleton()->draw_command_begin_label("Reflection probe render"); + if (storage->reflection_probe_get_update_mode(rpi->probe) == RS::REFLECTION_PROBE_UPDATE_ALWAYS && atlas->reflection.is_valid() && atlas->size != 256) { WARN_PRINT("ReflectionProbes set to UPDATE_ALWAYS must have an atlas size of 256. Please update the atlas size in the ProjectSettings."); reflection_atlas_set_size(p_reflection_atlas, 256, atlas->count); @@ -654,12 +658,12 @@ bool RendererSceneRenderRD::reflection_probe_instance_begin_render(RID p_instanc //reflection atlas was unused, create: RD::TextureFormat tf; tf.array_layers = 6 * atlas->count; - tf.format = RD::DATA_FORMAT_R16G16B16A16_SFLOAT; + tf.format = _render_buffers_get_color_format(); tf.texture_type = RD::TEXTURE_TYPE_CUBE_ARRAY; tf.mipmaps = mipmaps; tf.width = atlas->size; tf.height = atlas->size; - tf.usage_bits = RD::TEXTURE_USAGE_COLOR_ATTACHMENT_BIT | RD::TEXTURE_USAGE_SAMPLING_BIT | RD::TEXTURE_USAGE_STORAGE_BIT; + tf.usage_bits = RD::TEXTURE_USAGE_COLOR_ATTACHMENT_BIT | RD::TEXTURE_USAGE_SAMPLING_BIT | (_render_buffers_can_be_storage() ? RD::TEXTURE_USAGE_STORAGE_BIT : 0); atlas->reflection = RD::get_singleton()->texture_create(tf, RD::TextureView()); } @@ -673,7 +677,7 @@ bool RendererSceneRenderRD::reflection_probe_instance_begin_render(RID p_instanc } atlas->reflections.resize(atlas->count); for (int i = 0; i < atlas->count; i++) { - atlas->reflections.write[i].data.update_reflection_data(atlas->size, mipmaps, false, atlas->reflection, i * 6, storage->reflection_probe_get_update_mode(rpi->probe) == RS::REFLECTION_PROBE_UPDATE_ALWAYS, sky.roughness_layers); + atlas->reflections.write[i].data.update_reflection_data(storage, atlas->size, mipmaps, false, atlas->reflection, i * 6, storage->reflection_probe_get_update_mode(rpi->probe) == RS::REFLECTION_PROBE_UPDATE_ALWAYS, sky.roughness_layers, _render_buffers_get_color_format()); for (int j = 0; j < 6; j++) { Vector<RID> fb; fb.push_back(atlas->reflections.write[i].data.layers[0].mipmaps[0].views[j]); @@ -719,6 +723,8 @@ bool RendererSceneRenderRD::reflection_probe_instance_begin_render(RID p_instanc rpi->processing_layer = 1; rpi->processing_side = 0; + RD::get_singleton()->draw_command_end_label(); + return true; } @@ -1233,6 +1239,9 @@ RID RendererSceneRenderRD::light_instance_create(RID p_light) { light_instance->self = li; light_instance->light = p_light; light_instance->light_type = storage->light_get_type(p_light); + if (light_instance->light_type != RS::LIGHT_DIRECTIONAL) { + light_instance->forward_id = _allocate_forward_id(light_instance->light_type == RS::LIGHT_OMNI ? FORWARD_ID_TYPE_OMNI_LIGHT : FORWARD_ID_TYPE_SPOT_LIGHT); + } return li; } @@ -1306,6 +1315,7 @@ RendererSceneRenderRD::ShadowCubemap *RendererSceneRenderRD::_get_shadow_cubemap RID RendererSceneRenderRD::decal_instance_create(RID p_decal) { DecalInstance di; di.decal = p_decal; + di.forward_id = _allocate_forward_id(FORWARD_ID_TYPE_DECAL); return decal_instance_owner.make_rid(di); } @@ -1377,12 +1387,20 @@ void RendererSceneRenderRD::_allocate_blur_textures(RenderBuffers *rb) { uint32_t mipmaps_required = Image::get_image_required_mipmaps(rb->width, rb->height, Image::FORMAT_RGBAH); + // TODO make sure texture_create_shared_from_slice works for multiview + RD::TextureFormat tf; - tf.format = RD::DATA_FORMAT_R16G16B16A16_SFLOAT; + tf.format = _render_buffers_get_color_format(); // RD::DATA_FORMAT_R16G16B16A16_SFLOAT; tf.width = rb->width; tf.height = rb->height; - tf.texture_type = RD::TEXTURE_TYPE_2D; - tf.usage_bits = RD::TEXTURE_USAGE_STORAGE_BIT | RD::TEXTURE_USAGE_SAMPLING_BIT | RD::TEXTURE_USAGE_CAN_COPY_TO_BIT; + tf.texture_type = rb->view_count > 1 ? RD::TEXTURE_TYPE_2D_ARRAY : RD::TEXTURE_TYPE_2D; + tf.array_layers = rb->view_count; + tf.usage_bits = RD::TEXTURE_USAGE_SAMPLING_BIT | RD::TEXTURE_USAGE_CAN_COPY_TO_BIT; + if (_render_buffers_can_be_storage()) { + tf.usage_bits += RD::TEXTURE_USAGE_STORAGE_BIT; + } else { + tf.usage_bits += RD::TEXTURE_USAGE_COLOR_ATTACHMENT_BIT; + } tf.mipmaps = mipmaps_required; rb->blur[0].texture = RD::get_singleton()->texture_create(tf, RD::TextureView()); @@ -1402,11 +1420,40 @@ void RendererSceneRenderRD::_allocate_blur_textures(RenderBuffers *rb) { mm.width = base_width; mm.height = base_height; + if (!_render_buffers_can_be_storage()) { + Vector<RID> fb; + fb.push_back(mm.texture); + + mm.fb = RD::get_singleton()->framebuffer_create(fb); + } + + if (!_render_buffers_can_be_storage()) { + // and half texture, this is an intermediate result so just allocate a texture, is this good enough? + tf.width = MAX(1, base_width >> 1); + tf.height = base_height; + tf.mipmaps = 1; // 1 or 0? + + mm.half_texture = RD::get_singleton()->texture_create(tf, RD::TextureView()); + + Vector<RID> half_fb; + half_fb.push_back(mm.half_texture); + mm.half_fb = RD::get_singleton()->framebuffer_create(half_fb); + } + rb->blur[0].mipmaps.push_back(mm); if (i > 0) { mm.texture = RD::get_singleton()->texture_create_shared_from_slice(RD::TextureView(), rb->blur[1].texture, 0, i - 1); + if (!_render_buffers_can_be_storage()) { + Vector<RID> fb; + fb.push_back(mm.texture); + + mm.fb = RD::get_singleton()->framebuffer_create(fb); + + // We can re-use the half texture here as it is an intermediate result + } + rb->blur[1].mipmaps.push_back(mm); } @@ -1429,26 +1476,48 @@ void RendererSceneRenderRD::_allocate_luminance_textures(RenderBuffers *rb) { tf.format = RD::DATA_FORMAT_R32_SFLOAT; tf.width = w; tf.height = h; - tf.usage_bits = RD::TEXTURE_USAGE_STORAGE_BIT; bool final = w == 1 && h == 1; - if (final) { - tf.usage_bits |= RD::TEXTURE_USAGE_SAMPLING_BIT; + if (_render_buffers_can_be_storage()) { + tf.usage_bits = RD::TEXTURE_USAGE_STORAGE_BIT; + if (final) { + tf.usage_bits |= RD::TEXTURE_USAGE_SAMPLING_BIT; + } + } else { + tf.usage_bits = RD::TEXTURE_USAGE_COLOR_ATTACHMENT_BIT | RD::TEXTURE_USAGE_SAMPLING_BIT; } RID texture = RD::get_singleton()->texture_create(tf, RD::TextureView()); rb->luminance.reduce.push_back(texture); + if (!_render_buffers_can_be_storage()) { + Vector<RID> fb; + fb.push_back(texture); + + rb->luminance.fb.push_back(RD::get_singleton()->framebuffer_create(fb)); + } if (final) { rb->luminance.current = RD::get_singleton()->texture_create(tf, RD::TextureView()); + + if (!_render_buffers_can_be_storage()) { + Vector<RID> fb; + fb.push_back(rb->luminance.current); + + rb->luminance.current_fb = RD::get_singleton()->framebuffer_create(fb); + } break; } } } void RendererSceneRenderRD::_free_render_buffer_data(RenderBuffers *rb) { + if (rb->texture_fb.is_valid()) { + RD::get_singleton()->free(rb->texture_fb); + rb->texture_fb = RID(); + } + if (rb->texture.is_valid()) { RD::get_singleton()->free(rb->texture); rb->texture = RID(); @@ -1460,19 +1529,43 @@ void RendererSceneRenderRD::_free_render_buffer_data(RenderBuffers *rb) { } for (int i = 0; i < 2; i++) { + for (int m = 0; m < rb->blur[i].mipmaps.size(); m++) { + // do we free the texture slice here? or is it enough to free the main texture? + + // do free the mobile extra stuff + if (rb->blur[i].mipmaps[m].fb.is_valid()) { + RD::get_singleton()->free(rb->blur[i].mipmaps[m].fb); + } + if (rb->blur[i].mipmaps[m].half_fb.is_valid()) { + RD::get_singleton()->free(rb->blur[i].mipmaps[m].half_fb); + } + if (rb->blur[i].mipmaps[m].half_texture.is_valid()) { + RD::get_singleton()->free(rb->blur[i].mipmaps[m].half_texture); + } + } + rb->blur[i].mipmaps.clear(); + if (rb->blur[i].texture.is_valid()) { RD::get_singleton()->free(rb->blur[i].texture); rb->blur[i].texture = RID(); - rb->blur[i].mipmaps.clear(); } } + for (int i = 0; i < rb->luminance.fb.size(); i++) { + RD::get_singleton()->free(rb->luminance.fb[i]); + } + rb->luminance.fb.clear(); + for (int i = 0; i < rb->luminance.reduce.size(); i++) { RD::get_singleton()->free(rb->luminance.reduce[i]); } - rb->luminance.reduce.clear(); + if (rb->luminance.current_fb.is_valid()) { + RD::get_singleton()->free(rb->luminance.current_fb); + rb->luminance.current_fb = RID(); + } + if (rb->luminance.current.is_valid()) { RD::get_singleton()->free(rb->luminance.current); rb->luminance.current = RID(); @@ -1744,17 +1837,27 @@ void RendererSceneRenderRD::_render_buffers_post_process_and_tonemap(const Rende CameraEffects *camfx = camera_effects_owner.getornull(p_render_data->camera_effects); bool can_use_effects = rb->width >= 8 && rb->height >= 8; + bool can_use_storage = _render_buffers_can_be_storage(); + + // @TODO IMPLEMENT MULTIVIEW, all effects need to support stereo buffers or effects are only applied to the left eye if (can_use_effects && camfx && (camfx->dof_blur_near_enabled || camfx->dof_blur_far_enabled) && camfx->dof_blur_amount > 0.0) { + RD::get_singleton()->draw_command_begin_label("DOF"); if (rb->blur[0].texture.is_null()) { _allocate_blur_textures(rb); } - float bokeh_size = camfx->dof_blur_amount * 64.0; - storage->get_effects()->bokeh_dof(rb->texture, rb->depth_texture, Size2i(rb->width, rb->height), rb->blur[0].mipmaps[0].texture, rb->blur[1].mipmaps[0].texture, rb->blur[0].mipmaps[1].texture, camfx->dof_blur_far_enabled, camfx->dof_blur_far_distance, camfx->dof_blur_far_transition, camfx->dof_blur_near_enabled, camfx->dof_blur_near_distance, camfx->dof_blur_near_transition, bokeh_size, dof_blur_bokeh_shape, dof_blur_quality, dof_blur_use_jitter, p_render_data->z_near, p_render_data->z_far, p_render_data->cam_ortogonal); + if (can_use_storage) { + float bokeh_size = camfx->dof_blur_amount * 64.0; + storage->get_effects()->bokeh_dof(rb->texture, rb->depth_texture, Size2i(rb->width, rb->height), rb->blur[0].mipmaps[0].texture, rb->blur[1].mipmaps[0].texture, rb->blur[0].mipmaps[1].texture, camfx->dof_blur_far_enabled, camfx->dof_blur_far_distance, camfx->dof_blur_far_transition, camfx->dof_blur_near_enabled, camfx->dof_blur_near_distance, camfx->dof_blur_near_transition, bokeh_size, dof_blur_bokeh_shape, dof_blur_quality, dof_blur_use_jitter, p_render_data->z_near, p_render_data->z_far, p_render_data->cam_ortogonal); + } else { + storage->get_effects()->blur_dof_raster(rb->texture, rb->depth_texture, Size2i(rb->width, rb->height), rb->texture_fb, rb->blur[0].mipmaps[0].texture, rb->blur[0].mipmaps[0].fb, camfx->dof_blur_far_enabled, camfx->dof_blur_far_distance, camfx->dof_blur_far_transition, camfx->dof_blur_near_enabled, camfx->dof_blur_near_distance, camfx->dof_blur_near_transition, camfx->dof_blur_amount, dof_blur_quality, p_render_data->z_near, p_render_data->z_far, p_render_data->cam_ortogonal); + } + RD::get_singleton()->draw_command_end_label(); } if (can_use_effects && env && env->auto_exposure) { + RD::get_singleton()->draw_command_begin_label("Auto exposure"); if (rb->luminance.current.is_null()) { _allocate_luminance_textures(rb); } @@ -1763,16 +1866,26 @@ void RendererSceneRenderRD::_render_buffers_post_process_and_tonemap(const Rende rb->auto_exposure_version = env->auto_exposure_version; double step = env->auto_exp_speed * time_step; - storage->get_effects()->luminance_reduction(rb->texture, Size2i(rb->width, rb->height), rb->luminance.reduce, rb->luminance.current, env->min_luminance, env->max_luminance, step, set_immediate); - + if (can_use_storage) { + storage->get_effects()->luminance_reduction(rb->texture, Size2i(rb->width, rb->height), rb->luminance.reduce, rb->luminance.current, env->min_luminance, env->max_luminance, step, set_immediate); + } else { + storage->get_effects()->luminance_reduction_raster(rb->texture, Size2i(rb->width, rb->height), rb->luminance.reduce, rb->luminance.fb, rb->luminance.current, env->min_luminance, env->max_luminance, step, set_immediate); + } //swap final reduce with prev luminance SWAP(rb->luminance.current, rb->luminance.reduce.write[rb->luminance.reduce.size() - 1]); + if (!can_use_storage) { + SWAP(rb->luminance.current_fb, rb->luminance.fb.write[rb->luminance.fb.size() - 1]); + } + RenderingServerDefault::redraw_request(); //redraw all the time if auto exposure rendering is on + RD::get_singleton()->draw_command_end_label(); } int max_glow_level = -1; if (can_use_effects && env && env->glow_enabled) { + RD::get_singleton()->draw_command_begin_label("Gaussian Glow"); + /* see that blur textures are allocated */ if (rb->blur[1].texture.is_null()) { @@ -1798,14 +1911,26 @@ void RendererSceneRenderRD::_render_buffers_post_process_and_tonemap(const Rende if (env->auto_exposure && rb->luminance.current.is_valid()) { luminance_texture = rb->luminance.current; } - storage->get_effects()->gaussian_glow(rb->texture, rb->blur[1].mipmaps[i].texture, Size2i(vp_w, vp_h), env->glow_strength, glow_high_quality, true, env->glow_hdr_luminance_cap, env->exposure, env->glow_bloom, env->glow_hdr_bleed_threshold, env->glow_hdr_bleed_scale, luminance_texture, env->auto_exp_scale); + if (can_use_storage) { + storage->get_effects()->gaussian_glow(rb->texture, rb->blur[1].mipmaps[i].texture, Size2i(vp_w, vp_h), env->glow_strength, glow_high_quality, true, env->glow_hdr_luminance_cap, env->exposure, env->glow_bloom, env->glow_hdr_bleed_threshold, env->glow_hdr_bleed_scale, luminance_texture, env->auto_exp_scale); + } else { + storage->get_effects()->gaussian_glow_raster(rb->texture, rb->blur[1].mipmaps[i].half_fb, rb->blur[1].mipmaps[i].half_texture, rb->blur[1].mipmaps[i].fb, Size2i(vp_w, vp_h), env->glow_strength, glow_high_quality, true, env->glow_hdr_luminance_cap, env->exposure, env->glow_bloom, env->glow_hdr_bleed_threshold, env->glow_hdr_bleed_scale, luminance_texture, env->auto_exp_scale); + } } else { - storage->get_effects()->gaussian_glow(rb->blur[1].mipmaps[i - 1].texture, rb->blur[1].mipmaps[i].texture, Size2i(vp_w, vp_h), env->glow_strength, glow_high_quality); + if (can_use_storage) { + storage->get_effects()->gaussian_glow(rb->blur[1].mipmaps[i - 1].texture, rb->blur[1].mipmaps[i].texture, Size2i(vp_w, vp_h), env->glow_strength, glow_high_quality); + } else { + storage->get_effects()->gaussian_glow_raster(rb->blur[1].mipmaps[i - 1].texture, rb->blur[1].mipmaps[i].half_fb, rb->blur[1].mipmaps[i].half_texture, rb->blur[1].mipmaps[i].fb, Vector2(1.0 / vp_w, 1.0 / vp_h), env->glow_strength, glow_high_quality); + } } } + + RD::get_singleton()->draw_command_end_label(); } { + RD::get_singleton()->draw_command_begin_label("Tonemap"); + //tonemap EffectsRD::TonemapSettings tonemap; @@ -1864,6 +1989,8 @@ void RendererSceneRenderRD::_render_buffers_post_process_and_tonemap(const Rende tonemap.view_count = p_render_data->view_count; storage->get_effects()->tonemapper(rb->texture, storage->render_target_get_rd_framebuffer(rb->render_target), tonemap); + + RD::get_singleton()->draw_command_end_label(); } storage->render_target_disable_clear_request(rb->render_target); @@ -2118,8 +2245,16 @@ float RendererSceneRenderRD::render_buffers_get_volumetric_fog_detail_spread(RID return rb->volumetric_fog->spread; } +RD::DataFormat RendererSceneRenderRD::_render_buffers_get_color_format() { + return RD::DATA_FORMAT_R16G16B16A16_SFLOAT; +} + +bool RendererSceneRenderRD::_render_buffers_can_be_storage() { + return true; +} + void RendererSceneRenderRD::render_buffers_configure(RID p_render_buffers, RID p_render_target, int p_width, int p_height, RS::ViewportMSAA p_msaa, RenderingServer::ViewportScreenSpaceAA p_screen_space_aa, bool p_use_debanding, uint32_t p_view_count) { - ERR_FAIL_COND_MSG(p_view_count == 0, "Must have atleast 1 view"); + ERR_FAIL_COND_MSG(p_view_count == 0, "Must have at least 1 view"); RenderBuffers *rb = render_buffers_owner.getornull(p_render_buffers); rb->width = p_width; @@ -2144,13 +2279,13 @@ void RendererSceneRenderRD::render_buffers_configure(RID p_render_buffers, RID p if (rb->view_count > 1) { tf.texture_type = RD::TEXTURE_TYPE_2D_ARRAY; } - tf.format = RD::DATA_FORMAT_R16G16B16A16_SFLOAT; + tf.format = _render_buffers_get_color_format(); tf.width = rb->width; tf.height = rb->height; tf.array_layers = rb->view_count; // create a layer for every view - tf.usage_bits = RD::TEXTURE_USAGE_SAMPLING_BIT | RD::TEXTURE_USAGE_STORAGE_BIT; + tf.usage_bits = RD::TEXTURE_USAGE_SAMPLING_BIT | (_render_buffers_can_be_storage() ? RD::TEXTURE_USAGE_STORAGE_BIT : 0); if (rb->msaa != RS::VIEWPORT_MSAA_DISABLED) { - tf.usage_bits |= RD::TEXTURE_USAGE_CAN_COPY_TO_BIT | RD::TEXTURE_USAGE_STORAGE_BIT; + tf.usage_bits |= RD::TEXTURE_USAGE_CAN_COPY_TO_BIT | (_render_buffers_can_be_storage() ? RD::TEXTURE_USAGE_STORAGE_BIT : 0); } else { tf.usage_bits |= RD::TEXTURE_USAGE_COLOR_ATTACHMENT_BIT; } @@ -2183,6 +2318,14 @@ void RendererSceneRenderRD::render_buffers_configure(RID p_render_buffers, RID p rb->depth_texture = RD::get_singleton()->texture_create(tf, RD::TextureView()); } + if (!_render_buffers_can_be_storage()) { + // ONLY USED ON MOBILE RENDERER, ONLY USED FOR POST EFFECTS! + Vector<RID> fb; + fb.push_back(rb->texture); + + rb->texture_fb = RD::get_singleton()->framebuffer_create(fb, RenderingDevice::INVALID_ID, rb->view_count); + } + rb->data->configure(rb->texture, rb->depth_texture, p_width, p_height, p_msaa, p_view_count); if (is_clustered_enabled()) { @@ -2245,6 +2388,8 @@ void RendererSceneRenderRD::shadows_quality_set(RS::ShadowQuality p_quality) { get_vogel_disk(penumbra_shadow_kernel, penumbra_shadow_samples); get_vogel_disk(soft_shadow_kernel, soft_shadow_samples); } + + _update_shader_quality_settings(); } void RendererSceneRenderRD::directional_shadow_quality_set(RS::ShadowQuality p_quality) { @@ -2285,6 +2430,23 @@ void RendererSceneRenderRD::directional_shadow_quality_set(RS::ShadowQuality p_q get_vogel_disk(directional_penumbra_shadow_kernel, directional_penumbra_shadow_samples); get_vogel_disk(directional_soft_shadow_kernel, directional_soft_shadow_samples); } + + _update_shader_quality_settings(); +} + +void RendererSceneRenderRD::decals_set_filter(RenderingServer::DecalFilter p_filter) { + if (decals_filter == p_filter) { + return; + } + decals_filter = p_filter; + _update_shader_quality_settings(); +} +void RendererSceneRenderRD::light_projectors_set_filter(RenderingServer::LightProjectorFilter p_filter) { + if (light_projectors_filter == p_filter) { + return; + } + light_projectors_filter = p_filter; + _update_shader_quality_settings(); } int RendererSceneRenderRD::get_roughness_layers() const { @@ -2324,10 +2486,13 @@ void RendererSceneRenderRD::_setup_reflections(const PagedArray<RID> &p_reflecti sort_array.sort(cluster.reflection_sort, cluster.reflection_count); } + bool using_forward_ids = _uses_forward_ids(); for (uint32_t i = 0; i < cluster.reflection_count; i++) { ReflectionProbeInstance *rpi = cluster.reflection_sort[i].instance; - rpi->render_index = i; + if (using_forward_ids) { + _map_forward_id(FORWARD_ID_TYPE_REFLECTION_PROBE, rpi->forward_id, i); + } RID base_probe = rpi->probe; @@ -2377,7 +2542,7 @@ void RendererSceneRenderRD::_setup_reflections(const PagedArray<RID> &p_reflecti } } -void RendererSceneRenderRD::_setup_lights(const PagedArray<RID> &p_lights, const Transform3D &p_camera_transform, RID p_shadow_atlas, bool p_using_shadows, uint32_t &r_directional_light_count, uint32_t &r_positional_light_count) { +void RendererSceneRenderRD::_setup_lights(const PagedArray<RID> &p_lights, const Transform3D &p_camera_transform, RID p_shadow_atlas, bool p_using_shadows, uint32_t &r_directional_light_count, uint32_t &r_positional_light_count, bool &r_directional_light_soft_shadows) { Transform3D inverse_transform = p_camera_transform.affine_inverse(); r_directional_light_count = 0; @@ -2389,6 +2554,8 @@ void RendererSceneRenderRD::_setup_lights(const PagedArray<RID> &p_lights, const cluster.omni_light_count = 0; cluster.spot_light_count = 0; + r_directional_light_soft_shadows = false; + for (int i = 0; i < (int)p_lights.size(); i++) { LightInstance *li = light_instance_owner.getornull(p_lights[i]); if (!li) { @@ -2427,6 +2594,9 @@ void RendererSceneRenderRD::_setup_lights(const PagedArray<RID> &p_lights, const // technically this will keep expanding until reaching the sun, but all we care // is expand until we reach the radius of the near plane (there can't be more occluders than that) angular_diameter = Math::tan(Math::deg2rad(angular_diameter)); + if (storage->light_has_shadow(base)) { + r_directional_light_soft_shadows = true; + } } else { angular_diameter = 0.0; } @@ -2619,6 +2789,8 @@ void RendererSceneRenderRD::_setup_lights(const PagedArray<RID> &p_lights, const shadow_atlas = shadow_atlas_owner.getornull(p_shadow_atlas); } + bool using_forward_ids = _uses_forward_ids(); + for (uint32_t i = 0; i < (cluster.omni_light_count + cluster.spot_light_count); i++) { uint32_t index = (i < cluster.omni_light_count) ? i : i - (cluster.omni_light_count); Cluster::LightData &light_data = (i < cluster.omni_light_count) ? cluster.omni_lights[index] : cluster.spot_lights[index]; @@ -2626,6 +2798,10 @@ void RendererSceneRenderRD::_setup_lights(const PagedArray<RID> &p_lights, const LightInstance *li = (i < cluster.omni_light_count) ? cluster.omni_light_sort[index].instance : cluster.spot_light_sort[index].instance; RID base = li->light; + if (using_forward_ids) { + _map_forward_id(type == RS::LIGHT_OMNI ? FORWARD_ID_TYPE_OMNI_LIGHT : FORWARD_ID_TYPE_SPOT_LIGHT, li->forward_id, index); + } + Transform3D light_transform = li->transform; float sign = storage->light_is_negative(base) ? -1 : 1; @@ -2758,7 +2934,6 @@ void RendererSceneRenderRD::_setup_lights(const PagedArray<RID> &p_lights, const light_data.shadow_enabled = false; } - li->light_index = index; li->cull_mask = storage->light_get_cull_mask(base); if (current_cluster_builder != nullptr) { @@ -2827,11 +3002,15 @@ void RendererSceneRenderRD::_setup_decals(const PagedArray<RID> &p_decals, const sort_array.sort(cluster.decal_sort, cluster.decal_count); } + bool using_forward_ids = _uses_forward_ids(); for (uint32_t i = 0; i < cluster.decal_count; i++) { DecalInstance *di = cluster.decal_sort[i].instance; RID decal = di->decal; - di->render_index = i; + if (using_forward_ids) { + _map_forward_id(FORWARD_ID_TYPE_DECAL, di->forward_id, i); + } + di->cull_mask = storage->decal_get_cull_mask(decal); Transform3D xform = di->transform; @@ -2948,116 +3127,6 @@ void RendererSceneRenderRD::_setup_decals(const PagedArray<RID> &p_decals, const } } -void RendererSceneRenderRD::_fill_instance_indices(const RID *p_omni_light_instances, uint32_t p_omni_light_instance_count, uint32_t *p_omni_light_indices, const RID *p_spot_light_instances, uint32_t p_spot_light_instance_count, uint32_t *p_spot_light_indices, const RID *p_reflection_probe_instances, uint32_t p_reflection_probe_instance_count, uint32_t *p_reflection_probe_indices, const RID *p_decal_instances, uint32_t p_decal_instance_count, uint32_t *p_decal_instance_indices, uint32_t p_layer_mask, uint32_t p_max_dst_words) { - // first zero out our indices - for (uint32_t i = 0; i < p_max_dst_words; i++) { - p_omni_light_indices[i] = 0; - p_spot_light_indices[i] = 0; - p_reflection_probe_indices[i] = 0; - p_decal_instance_indices[i] = 0; - } - - { - // process omni lights - uint32_t dword = 0; - uint32_t shift = 0; - - for (uint32_t i = 0; i < p_omni_light_instance_count && dword < p_max_dst_words; i++) { - LightInstance *li = light_instance_owner.getornull(p_omni_light_instances[i]); - - if ((li->cull_mask & p_layer_mask) && (li->light_index < 255)) { - p_omni_light_indices[dword] += li->light_index << shift; - if (shift == 24) { - dword++; - shift = 0; - } else { - shift += 8; - } - } - } - - if (dword < 2) { - // put in ending mark - p_omni_light_indices[dword] += 0xFF << shift; - } - } - - { - // process spot lights - uint32_t dword = 0; - uint32_t shift = 0; - - for (uint32_t i = 0; i < p_spot_light_instance_count && dword < p_max_dst_words; i++) { - LightInstance *li = light_instance_owner.getornull(p_spot_light_instances[i]); - - if ((li->cull_mask & p_layer_mask) && (li->light_index < 255)) { - p_spot_light_indices[dword] += li->light_index << shift; - if (shift == 24) { - dword++; - shift = 0; - } else { - shift += 8; - } - } - } - - if (dword < 2) { - // put in ending mark - p_spot_light_indices[dword] += 0xFF << shift; - } - } - - { - // process reflection probes - uint32_t dword = 0; - uint32_t shift = 0; - - for (uint32_t i = 0; i < p_reflection_probe_instance_count && dword < p_max_dst_words; i++) { - ReflectionProbeInstance *rpi = reflection_probe_instance_owner.getornull(p_reflection_probe_instances[i]); - - if ((rpi->cull_mask & p_layer_mask) && (rpi->render_index < 255)) { - p_reflection_probe_indices[dword] += rpi->render_index << shift; - if (shift == 24) { - dword++; - shift = 0; - } else { - shift += 8; - } - } - } - - if (dword < 2) { - // put in ending mark - p_reflection_probe_indices[dword] += 0xFF << shift; - } - } - - { - // process decals - uint32_t dword = 0; - uint32_t shift = 0; - - for (uint32_t i = 0; i < p_decal_instance_count && dword < p_max_dst_words; i++) { - DecalInstance *decal = decal_instance_owner.getornull(p_decal_instances[i]); - - if ((decal->cull_mask & p_layer_mask) && (decal->render_index < 255)) { - p_decal_instance_indices[dword] += decal->render_index << shift; - if (shift == 24) { - dword++; - shift = 0; - } else { - shift += 8; - } - } - } - - if (dword < 2) { - // put in ending mark - p_decal_instance_indices[dword] += 0xFF << shift; - } - } -} - void RendererSceneRenderRD::_volumetric_fog_erase(RenderBuffers *rb) { ERR_FAIL_COND(!rb->volumetric_fog); @@ -3621,7 +3690,7 @@ void RendererSceneRenderRD::_pre_opaque_render(RenderDataRD *p_render_data, bool uint32_t directional_light_count = 0; uint32_t positional_light_count = 0; - _setup_lights(*p_render_data->lights, p_render_data->cam_transform, p_render_data->shadow_atlas, using_shadows, directional_light_count, positional_light_count); + _setup_lights(*p_render_data->lights, p_render_data->cam_transform, p_render_data->shadow_atlas, using_shadows, directional_light_count, positional_light_count, p_render_data->directional_light_soft_shadows); _setup_decals(*p_render_data->decals, p_render_data->cam_transform.affine_inverse()); p_render_data->directional_light_count = directional_light_count; @@ -4033,11 +4102,13 @@ bool RendererSceneRenderRD::free(RID p_rid) { } reflection_atlas_owner.free(p_rid); } else if (reflection_probe_instance_owner.owns(p_rid)) { - //not much to delete, just free it - //ReflectionProbeInstance *rpi = reflection_probe_instance_owner.getornull(p_rid); + ReflectionProbeInstance *rpi = reflection_probe_instance_owner.getornull(p_rid); + _free_forward_id(FORWARD_ID_TYPE_REFLECTION_PROBE, rpi->forward_id); reflection_probe_release_atlas_index(p_rid); reflection_probe_instance_owner.free(p_rid); } else if (decal_instance_owner.owns(p_rid)) { + DecalInstance *di = decal_instance_owner.getornull(p_rid); + _free_forward_id(FORWARD_ID_TYPE_DECAL, di->forward_id); decal_instance_owner.free(p_rid); } else if (lightmap_instance_owner.owns(p_rid)) { lightmap_instance_owner.free(p_rid); @@ -4072,6 +4143,9 @@ bool RendererSceneRenderRD::free(RID p_rid) { shadow_atlas->shadow_owners.erase(p_rid); } + if (light_instance->light_type != RS::LIGHT_DIRECTIONAL) { + _free_forward_id(light_instance->light_type == RS::LIGHT_OMNI ? FORWARD_ID_TYPE_OMNI_LIGHT : FORWARD_ID_TYPE_SPOT_LIGHT, light_instance->forward_id); + } light_instance_owner.free(p_rid); } else if (shadow_atlas_owner.owns(p_rid)) { @@ -4361,6 +4435,9 @@ RendererSceneRenderRD::RendererSceneRenderRD(RendererStorageRD *p_storage) { environment_set_volumetric_fog_volume_size(GLOBAL_GET("rendering/environment/volumetric_fog/volume_size"), GLOBAL_GET("rendering/environment/volumetric_fog/volume_depth")); environment_set_volumetric_fog_filter_active(GLOBAL_GET("rendering/environment/volumetric_fog/use_filter")); + decals_set_filter(RS::DecalFilter(int(GLOBAL_GET("rendering/textures/decals/filter")))); + light_projectors_set_filter(RS::LightProjectorFilter(int(GLOBAL_GET("rendering/textures/light_projectors/filter")))); + cull_argument.set_page_pool(&cull_argument_pool); } diff --git a/servers/rendering/renderer_rd/renderer_scene_render_rd.h b/servers/rendering/renderer_rd/renderer_scene_render_rd.h index be3d3551c7..bb06eb608f 100644 --- a/servers/rendering/renderer_rd/renderer_scene_render_rd.h +++ b/servers/rendering/renderer_rd/renderer_scene_render_rd.h @@ -80,6 +80,7 @@ struct RenderDataRD { uint32_t cluster_max_elements = 0; uint32_t directional_light_count = 0; + bool directional_light_soft_shadows = false; RendererScene::RenderInfo *render_info = nullptr; }; @@ -99,7 +100,7 @@ protected: }; virtual RenderBufferData *_create_render_buffer_data() = 0; - void _setup_lights(const PagedArray<RID> &p_lights, const Transform3D &p_camera_transform, RID p_shadow_atlas, bool p_using_shadows, uint32_t &r_directional_light_count, uint32_t &r_positional_light_count); + void _setup_lights(const PagedArray<RID> &p_lights, const Transform3D &p_camera_transform, RID p_shadow_atlas, bool p_using_shadows, uint32_t &r_directional_light_count, uint32_t &r_positional_light_count, bool &r_directional_light_soft_shadows); void _setup_decals(const PagedArray<RID> &p_decals, const Transform3D &p_camera_inverse_xform); void _setup_reflections(const PagedArray<RID> &p_reflections, const Transform3D &p_camera_inverse_transform, RID p_environment); @@ -147,6 +148,25 @@ protected: } } + //used for mobile renderer mostly + + typedef int32_t ForwardID; + + enum ForwardIDType { + FORWARD_ID_TYPE_OMNI_LIGHT, + FORWARD_ID_TYPE_SPOT_LIGHT, + FORWARD_ID_TYPE_REFLECTION_PROBE, + FORWARD_ID_TYPE_DECAL, + FORWARD_ID_MAX, + }; + + virtual ForwardID _allocate_forward_id(ForwardIDType p_type) { return -1; } + virtual void _free_forward_id(ForwardIDType p_type, ForwardID p_id) {} + virtual void _map_forward_id(ForwardIDType p_type, ForwardID p_id, uint32_t p_index) {} + virtual bool _uses_forward_ids() const { return false; } + + virtual void _update_shader_quality_settings() {} + private: RS::ViewportDebugDraw debug_draw = RS::VIEWPORT_DEBUG_DRAW_DISABLED; static RendererSceneRenderRD *singleton; @@ -188,9 +208,10 @@ private: uint32_t render_step = 0; uint64_t last_pass = 0; - uint32_t render_index = 0; uint32_t cull_mask = 0; + ForwardID forward_id = -1; + Transform3D transform; }; @@ -201,8 +222,8 @@ private: struct DecalInstance { RID decal; Transform3D transform; - uint32_t render_index; uint32_t cull_mask; + ForwardID forward_id = -1; }; mutable RID_Owner<DecalInstance> decal_instance_owner; @@ -286,6 +307,8 @@ private: int directional_soft_shadow_samples = 0; int penumbra_shadow_samples = 0; int soft_shadow_samples = 0; + RS::DecalFilter decals_filter = RS::DECAL_FILTER_LINEAR_MIPMAPS; + RS::LightProjectorFilter light_projectors_filter = RS::LIGHT_PROJECTOR_FILTER_LINEAR_MIPMAPS; /* DIRECTIONAL SHADOW */ @@ -346,7 +369,6 @@ private: uint64_t last_scene_pass = 0; uint64_t last_scene_shadow_pass = 0; uint64_t last_pass = 0; - uint32_t light_index = 0; uint32_t cull_mask = 0; uint32_t light_directional_index = 0; @@ -358,6 +380,8 @@ private: Set<RID> shadow_atlases; //shadow atlases where this light is registered + ForwardID forward_id = -1; + LightInstance() {} }; @@ -426,6 +450,7 @@ private: RID texture; //main texture for rendering to, must be filled after done rendering RID depth_texture; //main depth texture + RID texture_fb; // framebuffer for the main texture, ONLY USED FOR MOBILE RENDERER POST EFFECTS, DO NOT USE FOR RENDERING 3D!!! RendererSceneGIRD::SDFGI *sdfgi = nullptr; VolumetricFog *volumetric_fog = nullptr; @@ -441,6 +466,11 @@ private: RID texture; int width; int height; + + // only used on mobile renderer + RID fb; + RID half_texture; + RID half_fb; }; Vector<Mipmap> mipmaps; @@ -451,6 +481,10 @@ private: struct Luminance { Vector<RID> reduce; RID current; + + // used only on mobile renderer + Vector<RID> fb; + RID current_fb; } luminance; struct SSAO { @@ -1005,14 +1039,9 @@ public: return li->last_pass; } - _FORCE_INLINE_ void light_instance_set_index(RID p_light_instance, uint32_t p_index) { - LightInstance *li = light_instance_owner.getornull(p_light_instance); - li->light_index = p_index; - } - - _FORCE_INLINE_ uint32_t light_instance_get_index(RID p_light_instance) { + _FORCE_INLINE_ ForwardID light_instance_get_forward_id(RID p_light_instance) { LightInstance *li = light_instance_owner.getornull(p_light_instance); - return li->light_index; + return li->forward_id; } _FORCE_INLINE_ RS::LightType light_instance_get_type(RID p_light_instance) { @@ -1049,17 +1078,11 @@ public: return rpi->probe; } - _FORCE_INLINE_ void reflection_probe_instance_set_render_index(RID p_instance, uint32_t p_render_index) { - ReflectionProbeInstance *rpi = reflection_probe_instance_owner.getornull(p_instance); - ERR_FAIL_COND(!rpi); - rpi->render_index = p_render_index; - } - - _FORCE_INLINE_ uint32_t reflection_probe_instance_get_render_index(RID p_instance) { + _FORCE_INLINE_ ForwardID reflection_probe_instance_get_forward_id(RID p_instance) { ReflectionProbeInstance *rpi = reflection_probe_instance_owner.getornull(p_instance); ERR_FAIL_COND_V(!rpi, 0); - return rpi->render_index; + return rpi->forward_id; } _FORCE_INLINE_ void reflection_probe_instance_set_render_pass(RID p_instance, uint32_t p_render_pass) { @@ -1097,6 +1120,11 @@ public: return decal->decal; } + _FORCE_INLINE_ ForwardID decal_instance_get_forward_id(RID p_decal) const { + DecalInstance *decal = decal_instance_owner.getornull(p_decal); + return decal->forward_id; + } + _FORCE_INLINE_ Transform3D decal_instance_get_transform(RID p_decal) const { DecalInstance *decal = decal_instance_owner.getornull(p_decal); return decal->transform; @@ -1117,8 +1145,6 @@ public: return li->transform; } - void _fill_instance_indices(const RID *p_omni_light_instances, uint32_t p_omni_light_instance_count, uint32_t *p_omni_light_indices, const RID *p_spot_light_instances, uint32_t p_spot_light_instance_count, uint32_t *p_spot_light_indices, const RID *p_reflection_probe_instances, uint32_t p_reflection_probe_instance_count, uint32_t *p_reflection_probe_indices, const RID *p_decal_instances, uint32_t p_decal_instance_count, uint32_t *p_decal_instance_indices, uint32_t p_layer_mask, uint32_t p_max_dst_words = 2); - /* gi light probes */ virtual RID voxel_gi_instance_create(RID p_base) override; @@ -1129,6 +1155,8 @@ public: /* render buffers */ + virtual RD::DataFormat _render_buffers_get_color_format(); + virtual bool _render_buffers_can_be_storage(); virtual RID render_buffers_create() override; virtual void render_buffers_configure(RID p_render_buffers, RID p_render_target, int p_width, int p_height, RS::ViewportMSAA p_msaa, RS::ViewportScreenSpaceAA p_screen_space_aa, bool p_use_debanding, uint32_t p_view_count) override; virtual void gi_set_use_half_resolution(bool p_enable) override; @@ -1183,6 +1211,10 @@ public: virtual void shadows_quality_set(RS::ShadowQuality p_quality) override; virtual void directional_shadow_quality_set(RS::ShadowQuality p_quality) override; + + virtual void decals_set_filter(RS::DecalFilter p_filter) override; + virtual void light_projectors_set_filter(RS::LightProjectorFilter p_filter) override; + _FORCE_INLINE_ RS::ShadowQuality shadows_quality_get() const { return shadows_quality; } _FORCE_INLINE_ RS::ShadowQuality directional_shadow_quality_get() const { return directional_shadow_quality; } _FORCE_INLINE_ float shadows_quality_radius_get() const { return shadows_quality_radius; } @@ -1198,6 +1230,9 @@ public: _FORCE_INLINE_ int penumbra_shadow_samples_get() const { return penumbra_shadow_samples; } _FORCE_INLINE_ int soft_shadow_samples_get() const { return soft_shadow_samples; } + _FORCE_INLINE_ RS::LightProjectorFilter light_projectors_get_filter() const { return light_projectors_filter; } + _FORCE_INLINE_ RS::DecalFilter decals_get_filter() const { return decals_filter; } + int get_roughness_layers() const; bool is_using_radiance_cubemap_array() const; diff --git a/servers/rendering/renderer_rd/renderer_scene_sky_rd.cpp b/servers/rendering/renderer_rd/renderer_scene_sky_rd.cpp index e701219617..cadf759ec3 100644 --- a/servers/rendering/renderer_rd/renderer_scene_sky_rd.cpp +++ b/servers/rendering/renderer_rd/renderer_scene_sky_rd.cpp @@ -313,12 +313,16 @@ void RendererSceneSkyRD::ReflectionData::clear_reflection_data() { coefficient_buffer = RID(); } -void RendererSceneSkyRD::ReflectionData::update_reflection_data(int p_size, int p_mipmaps, bool p_use_array, RID p_base_cube, int p_base_layer, bool p_low_quality, int p_roughness_layers) { +void RendererSceneSkyRD::ReflectionData::update_reflection_data(RendererStorageRD *p_storage, int p_size, int p_mipmaps, bool p_use_array, RID p_base_cube, int p_base_layer, bool p_low_quality, int p_roughness_layers, RD::DataFormat p_texture_format) { //recreate radiance and all data int mipmaps = p_mipmaps; uint32_t w = p_size, h = p_size; + EffectsRD *effects = p_storage->get_effects(); + ERR_FAIL_NULL_MSG(effects, "Effects haven't been initialised"); + bool prefer_raster_effects = effects->get_prefer_raster_effects(); + if (p_use_array) { int num_layers = p_low_quality ? 8 : p_roughness_layers; @@ -377,9 +381,9 @@ void RendererSceneSkyRD::ReflectionData::update_reflection_data(int p_size, int } radiance_base_cubemap = RD::get_singleton()->texture_create_shared_from_slice(RD::TextureView(), p_base_cube, p_base_layer, 0, RD::TEXTURE_SLICE_CUBEMAP); - + RD::get_singleton()->set_resource_name(radiance_base_cubemap, "radiance base cubemap"); RD::TextureFormat tf; - tf.format = RD::DATA_FORMAT_R16G16B16A16_SFLOAT; + tf.format = p_texture_format; tf.width = 64; // Always 64x64 tf.height = 64; tf.texture_type = RD::TEXTURE_TYPE_CUBE; @@ -388,6 +392,7 @@ void RendererSceneSkyRD::ReflectionData::update_reflection_data(int p_size, int tf.usage_bits = RD::TEXTURE_USAGE_SAMPLING_BIT | RD::TEXTURE_USAGE_STORAGE_BIT | RD::TEXTURE_USAGE_COLOR_ATTACHMENT_BIT; downsampled_radiance_cubemap = RD::get_singleton()->texture_create(tf, RD::TextureView()); + RD::get_singleton()->set_resource_name(downsampled_radiance_cubemap, "downsampled radiance cubemap"); { uint32_t mmw = 64; uint32_t mmh = 64; @@ -397,6 +402,18 @@ void RendererSceneSkyRD::ReflectionData::update_reflection_data(int p_size, int mm.size.width = mmw; mm.size.height = mmh; mm.view = RD::get_singleton()->texture_create_shared_from_slice(RD::TextureView(), downsampled_radiance_cubemap, 0, j, RD::TEXTURE_SLICE_CUBEMAP); + RD::get_singleton()->set_resource_name(mm.view, "Downsampled Radiance Cubemap Mip " + itos(j) + " "); + if (prefer_raster_effects) { + // we need a framebuffer for each side of our cubemap + + for (int k = 0; k < 6; k++) { + mm.views[k] = RD::get_singleton()->texture_create_shared_from_slice(RD::TextureView(), downsampled_radiance_cubemap, k, j); + RD::get_singleton()->set_resource_name(mm.view, "Downsampled Radiance Cubemap Mip: " + itos(j) + " Face: " + itos(k) + " "); + Vector<RID> fbtex; + fbtex.push_back(mm.views[k]); + mm.framebuffers[k] = RD::get_singleton()->framebuffer_create(fbtex); + } + } mmw = MAX(1, mmw >> 1); mmh = MAX(1, mmh >> 1); @@ -405,50 +422,128 @@ void RendererSceneSkyRD::ReflectionData::update_reflection_data(int p_size, int } void RendererSceneSkyRD::ReflectionData::create_reflection_fast_filter(RendererStorageRD *p_storage, bool p_use_arrays) { - p_storage->get_effects()->cubemap_downsample(radiance_base_cubemap, downsampled_layer.mipmaps[0].view, downsampled_layer.mipmaps[0].size); + EffectsRD *effects = p_storage->get_effects(); + ERR_FAIL_NULL_MSG(effects, "Effects haven't been initialised"); + bool prefer_raster_effects = effects->get_prefer_raster_effects(); + + if (prefer_raster_effects) { + RD::get_singleton()->draw_command_begin_label("Downsample radiance map"); + for (int k = 0; k < 6; k++) { + effects->cubemap_downsample_raster(radiance_base_cubemap, downsampled_layer.mipmaps[0].framebuffers[k], k, downsampled_layer.mipmaps[0].size); + } - for (int i = 1; i < downsampled_layer.mipmaps.size(); i++) { - p_storage->get_effects()->cubemap_downsample(downsampled_layer.mipmaps[i - 1].view, downsampled_layer.mipmaps[i].view, downsampled_layer.mipmaps[i].size); - } + for (int i = 1; i < downsampled_layer.mipmaps.size(); i++) { + for (int k = 0; k < 6; k++) { + effects->cubemap_downsample_raster(downsampled_layer.mipmaps[i - 1].view, downsampled_layer.mipmaps[i].framebuffers[k], k, downsampled_layer.mipmaps[i].size); + } + } + RD::get_singleton()->draw_command_end_label(); // Downsample Radiance - Vector<RID> views; - if (p_use_arrays) { - for (int i = 1; i < layers.size(); i++) { - views.push_back(layers[i].views[0]); + if (p_use_arrays) { + RD::get_singleton()->draw_command_begin_label("filter radiance map into array heads"); + for (int i = 0; i < layers.size(); i++) { + for (int k = 0; k < 6; k++) { + effects->cubemap_filter_raster(downsampled_radiance_cubemap, layers[i].mipmaps[0].framebuffers[k], k, i); + } + } + } else { + RD::get_singleton()->draw_command_begin_label("filter radiance map into mipmaps directly"); + for (int j = 0; j < layers[0].mipmaps.size(); j++) { + for (int k = 0; k < 6; k++) { + effects->cubemap_filter_raster(downsampled_radiance_cubemap, layers[0].mipmaps[j].framebuffers[k], k, j); + } + } } + RD::get_singleton()->draw_command_end_label(); // Filter radiance } else { - for (int i = 1; i < layers[0].views.size(); i++) { - views.push_back(layers[0].views[i]); + effects->cubemap_downsample(radiance_base_cubemap, downsampled_layer.mipmaps[0].view, downsampled_layer.mipmaps[0].size); + + for (int i = 1; i < downsampled_layer.mipmaps.size(); i++) { + effects->cubemap_downsample(downsampled_layer.mipmaps[i - 1].view, downsampled_layer.mipmaps[i].view, downsampled_layer.mipmaps[i].size); } - } - p_storage->get_effects()->cubemap_filter(downsampled_radiance_cubemap, views, p_use_arrays); + Vector<RID> views; + if (p_use_arrays) { + for (int i = 1; i < layers.size(); i++) { + views.push_back(layers[i].views[0]); + } + } else { + for (int i = 1; i < layers[0].views.size(); i++) { + views.push_back(layers[0].views[i]); + } + } + + effects->cubemap_filter(downsampled_radiance_cubemap, views, p_use_arrays); + } } void RendererSceneSkyRD::ReflectionData::create_reflection_importance_sample(RendererStorageRD *p_storage, bool p_use_arrays, int p_cube_side, int p_base_layer, uint32_t p_sky_ggx_samples_quality) { - if (p_use_arrays) { - //render directly to the layers - p_storage->get_effects()->cubemap_roughness(radiance_base_cubemap, layers[p_base_layer].views[0], p_cube_side, p_sky_ggx_samples_quality, float(p_base_layer) / (layers.size() - 1.0), layers[p_base_layer].mipmaps[0].size.x); + EffectsRD *effects = p_storage->get_effects(); + ERR_FAIL_NULL_MSG(effects, "Effects haven't been initialised"); + bool prefer_raster_effects = effects->get_prefer_raster_effects(); + + if (prefer_raster_effects) { + // Need to ask clayjohn but p_cube_side is set to 10, looks like in the compute shader we're doing all 6 sides in one call + // here we need to do them one by one so ignoring p_cube_side + if (p_use_arrays) { + for (int k = 0; k < 6; k++) { + effects->cubemap_roughness_raster( + radiance_base_cubemap, + layers[p_base_layer].mipmaps[0].framebuffers[k], + k, + p_sky_ggx_samples_quality, + float(p_base_layer) / (layers.size() - 1.0), + layers[p_base_layer].mipmaps[0].size.x); + } + } else { + for (int k = 0; k < 6; k++) { + effects->cubemap_roughness_raster( + layers[0].views[p_base_layer - 1], + layers[0].mipmaps[p_base_layer].framebuffers[k], + k, + p_sky_ggx_samples_quality, + float(p_base_layer) / (layers[0].mipmaps.size() - 1.0), + layers[0].mipmaps[p_base_layer].size.x); + } + } } else { - p_storage->get_effects()->cubemap_roughness( - layers[0].views[p_base_layer - 1], - layers[0].views[p_base_layer], - p_cube_side, - p_sky_ggx_samples_quality, - float(p_base_layer) / (layers[0].mipmaps.size() - 1.0), - layers[0].mipmaps[p_base_layer].size.x); + if (p_use_arrays) { + //render directly to the layers + effects->cubemap_roughness(radiance_base_cubemap, layers[p_base_layer].views[0], p_cube_side, p_sky_ggx_samples_quality, float(p_base_layer) / (layers.size() - 1.0), layers[p_base_layer].mipmaps[0].size.x); + } else { + effects->cubemap_roughness( + layers[0].views[p_base_layer - 1], + layers[0].views[p_base_layer], + p_cube_side, + p_sky_ggx_samples_quality, + float(p_base_layer) / (layers[0].mipmaps.size() - 1.0), + layers[0].mipmaps[p_base_layer].size.x); + } } } void RendererSceneSkyRD::ReflectionData::update_reflection_mipmaps(RendererStorageRD *p_storage, int p_start, int p_end) { + EffectsRD *effects = p_storage->get_effects(); + ERR_FAIL_NULL_MSG(effects, "Effects haven't been initialised"); + bool prefer_raster_effects = effects->get_prefer_raster_effects(); + + RD::get_singleton()->draw_command_begin_label("Update Radiance Cubemap Array Mipmaps"); for (int i = p_start; i < p_end; i++) { for (int j = 0; j < layers[i].views.size() - 1; j++) { RID view = layers[i].views[j]; - RID texture = layers[i].views[j + 1]; Size2i size = layers[i].mipmaps[j + 1].size; - p_storage->get_effects()->cubemap_downsample(view, texture, size); + if (prefer_raster_effects) { + for (int k = 0; k < 6; k++) { + RID framebuffer = layers[i].mipmaps[j + 1].framebuffers[k]; + effects->cubemap_downsample_raster(view, framebuffer, k, size); + } + } else { + RID texture = layers[i].views[j + 1]; + effects->cubemap_downsample(view, texture, size); + } } } + RD::get_singleton()->draw_command_end_label(); } //////////////////////////////////////////////////////////////////////////////// @@ -757,7 +852,13 @@ void RendererSceneSkyRD::init(RendererStorageRD *p_storage) { sky_shader.default_shader = storage->shader_allocate(); storage->shader_initialize(sky_shader.default_shader); - storage->shader_set_code(sky_shader.default_shader, "shader_type sky; void sky() { COLOR = vec3(0.0); } \n"); + storage->shader_set_code(sky_shader.default_shader, R"( +shader_type sky; + +void sky() { + COLOR = vec3(0.0); +} +)"); sky_shader.default_material = storage->material_allocate(); storage->material_initialize(sky_shader.default_material); @@ -838,7 +939,15 @@ void RendererSceneSkyRD::init(RendererStorageRD *p_storage) { sky_scene_state.fog_shader = storage->shader_allocate(); storage->shader_initialize(sky_scene_state.fog_shader); - storage->shader_set_code(sky_scene_state.fog_shader, "shader_type sky; uniform vec4 clear_color; void sky() { COLOR = clear_color.rgb; } \n"); + storage->shader_set_code(sky_scene_state.fog_shader, R"( +shader_type sky; + +uniform vec4 clear_color; + +void sky() { + COLOR = clear_color.rgb; +} +)"); sky_scene_state.fog_material = storage->material_allocate(); storage->material_initialize(sky_scene_state.fog_material); @@ -888,6 +997,10 @@ void RendererSceneSkyRD::init(RendererStorageRD *p_storage) { } } +void RendererSceneSkyRD::set_texture_format(RD::DataFormat p_texture_format) { + texture_format = p_texture_format; +} + RendererSceneSkyRD::~RendererSceneSkyRD() { // TODO cleanup anything created in init... @@ -1156,6 +1269,7 @@ void RendererSceneSkyRD::update(RendererSceneEnvironmentRD *p_env, const CameraM cm = correction * cm; if (shader_data->uses_quarter_res) { + RD::get_singleton()->draw_command_begin_label("Render Sky to Quarter Res Cubemap"); PipelineCacheRD *pipeline = &shader_data->pipelines[SKY_VERSION_CUBEMAP_QUARTER_RES]; Vector<Color> clear_colors; @@ -1171,9 +1285,11 @@ void RendererSceneSkyRD::update(RendererSceneEnvironmentRD *p_env, const CameraM _render_sky(cubemap_draw_list, p_time, sky->reflection.layers[0].mipmaps[2].framebuffers[i], pipeline, material->uniform_set, texture_uniform_set, 1, &cm, local_view.basis, multiplier, p_transform.origin); RD::get_singleton()->draw_list_end(); } + RD::get_singleton()->draw_command_end_label(); } if (shader_data->uses_half_res) { + RD::get_singleton()->draw_command_begin_label("Render Sky to Half Res Cubemap"); PipelineCacheRD *pipeline = &shader_data->pipelines[SKY_VERSION_CUBEMAP_HALF_RES]; Vector<Color> clear_colors; @@ -1189,11 +1305,13 @@ void RendererSceneSkyRD::update(RendererSceneEnvironmentRD *p_env, const CameraM _render_sky(cubemap_draw_list, p_time, sky->reflection.layers[0].mipmaps[1].framebuffers[i], pipeline, material->uniform_set, texture_uniform_set, 1, &cm, local_view.basis, multiplier, p_transform.origin); RD::get_singleton()->draw_list_end(); } + RD::get_singleton()->draw_command_end_label(); } RD::DrawListID cubemap_draw_list; PipelineCacheRD *pipeline = &shader_data->pipelines[SKY_VERSION_CUBEMAP]; + RD::get_singleton()->draw_command_begin_label("Render Sky Cubemap"); for (int i = 0; i < 6; i++) { Transform3D local_view; local_view.set_look_at(Vector3(0, 0, 0), view_normals[i], view_up[i]); @@ -1203,6 +1321,7 @@ void RendererSceneSkyRD::update(RendererSceneEnvironmentRD *p_env, const CameraM _render_sky(cubemap_draw_list, p_time, sky->reflection.layers[0].mipmaps[0].framebuffers[i], pipeline, material->uniform_set, texture_uniform_set, 1, &cm, local_view.basis, multiplier, p_transform.origin); RD::get_singleton()->draw_list_end(); } + RD::get_singleton()->draw_command_end_label(); if (sky_mode == RS::SKY_MODE_REALTIME) { sky->reflection.create_reflection_fast_filter(storage, sky_use_cubemap_array); @@ -1379,7 +1498,7 @@ void RendererSceneSkyRD::update_dirty_skys() { //array (higher quality, 6 times more memory) RD::TextureFormat tf; tf.array_layers = layers * 6; - tf.format = RD::DATA_FORMAT_R16G16B16A16_SFLOAT; + tf.format = texture_format; tf.texture_type = RD::TEXTURE_TYPE_CUBE_ARRAY; tf.mipmaps = mipmaps; tf.width = w; @@ -1388,13 +1507,13 @@ void RendererSceneSkyRD::update_dirty_skys() { sky->radiance = RD::get_singleton()->texture_create(tf, RD::TextureView()); - sky->reflection.update_reflection_data(sky->radiance_size, mipmaps, true, sky->radiance, 0, sky->mode == RS::SKY_MODE_REALTIME, roughness_layers); + sky->reflection.update_reflection_data(storage, sky->radiance_size, mipmaps, true, sky->radiance, 0, sky->mode == RS::SKY_MODE_REALTIME, roughness_layers, texture_format); } else { //regular cubemap, lower quality (aliasing, less memory) RD::TextureFormat tf; tf.array_layers = 6; - tf.format = RD::DATA_FORMAT_R16G16B16A16_SFLOAT; + tf.format = texture_format; tf.texture_type = RD::TEXTURE_TYPE_CUBE; tf.mipmaps = MIN(mipmaps, layers); tf.width = w; @@ -1403,7 +1522,7 @@ void RendererSceneSkyRD::update_dirty_skys() { sky->radiance = RD::get_singleton()->texture_create(tf, RD::TextureView()); - sky->reflection.update_reflection_data(sky->radiance_size, MIN(mipmaps, layers), false, sky->radiance, 0, sky->mode == RS::SKY_MODE_REALTIME, roughness_layers); + sky->reflection.update_reflection_data(storage, sky->radiance_size, MIN(mipmaps, layers), false, sky->radiance, 0, sky->mode == RS::SKY_MODE_REALTIME, roughness_layers, texture_format); } texture_set_dirty = true; } @@ -1411,7 +1530,7 @@ void RendererSceneSkyRD::update_dirty_skys() { // Create subpass buffers if they haven't been created already if (sky->half_res_pass.is_null() && !RD::get_singleton()->texture_is_valid(sky->half_res_pass) && sky->screen_size.x >= 4 && sky->screen_size.y >= 4) { RD::TextureFormat tformat; - tformat.format = RD::DATA_FORMAT_R16G16B16A16_SFLOAT; + tformat.format = texture_format; tformat.width = sky->screen_size.x / 2; tformat.height = sky->screen_size.y / 2; tformat.usage_bits = RD::TEXTURE_USAGE_SAMPLING_BIT | RD::TEXTURE_USAGE_COLOR_ATTACHMENT_BIT; @@ -1426,7 +1545,7 @@ void RendererSceneSkyRD::update_dirty_skys() { if (sky->quarter_res_pass.is_null() && !RD::get_singleton()->texture_is_valid(sky->quarter_res_pass) && sky->screen_size.x >= 4 && sky->screen_size.y >= 4) { RD::TextureFormat tformat; - tformat.format = RD::DATA_FORMAT_R16G16B16A16_SFLOAT; + tformat.format = texture_format; tformat.width = sky->screen_size.x / 4; tformat.height = sky->screen_size.y / 4; tformat.usage_bits = RD::TEXTURE_USAGE_SAMPLING_BIT | RD::TEXTURE_USAGE_COLOR_ATTACHMENT_BIT; diff --git a/servers/rendering/renderer_rd/renderer_scene_sky_rd.h b/servers/rendering/renderer_rd/renderer_scene_sky_rd.h index 4f852e55a7..7e0b01d58e 100644 --- a/servers/rendering/renderer_rd/renderer_scene_sky_rd.h +++ b/servers/rendering/renderer_rd/renderer_scene_sky_rd.h @@ -64,6 +64,7 @@ public: private: RendererStorageRD *storage; + RD::DataFormat texture_format = RD::DATA_FORMAT_R16G16B16A16_SFLOAT; RID index_buffer; RID index_array; @@ -190,6 +191,10 @@ public: struct Mipmap { RID view; Size2i size; + + // for mobile only + RID views[6]; + RID framebuffers[6]; }; Vector<Mipmap> mipmaps; }; @@ -204,7 +209,7 @@ public: Vector<Layer> layers; void clear_reflection_data(); - void update_reflection_data(int p_size, int p_mipmaps, bool p_use_array, RID p_base_cube, int p_base_layer, bool p_low_quality, int p_roughness_layers); + void update_reflection_data(RendererStorageRD *p_storage, int p_size, int p_mipmaps, bool p_use_array, RID p_base_cube, int p_base_layer, bool p_low_quality, int p_roughness_layers, RD::DataFormat p_texture_format); void create_reflection_fast_filter(RendererStorageRD *p_storage, bool p_use_arrays); void create_reflection_importance_sample(RendererStorageRD *p_storage, bool p_use_arrays, int p_cube_side, int p_base_layer, uint32_t p_sky_ggx_samples_quality); void update_reflection_mipmaps(RendererStorageRD *p_storage, int p_start, int p_end); @@ -284,6 +289,7 @@ public: RendererSceneSkyRD(); void init(RendererStorageRD *p_storage); + void set_texture_format(RD::DataFormat p_texture_format); ~RendererSceneSkyRD(); void setup(RendererSceneEnvironmentRD *p_env, RID p_render_buffers, const CameraMatrix &p_projection, const Transform3D &p_transform, const Size2i p_screen_size, RendererSceneRenderRD *p_scene_render); diff --git a/servers/rendering/renderer_rd/renderer_storage_rd.cpp b/servers/rendering/renderer_rd/renderer_storage_rd.cpp index 6738f499bd..d5c7db6fd2 100644 --- a/servers/rendering/renderer_rd/renderer_storage_rd.cpp +++ b/servers/rendering/renderer_rd/renderer_storage_rd.cpp @@ -2531,6 +2531,8 @@ void RendererStorageRD::mesh_add_surface(RID p_mesh, const RS::SurfaceData &p_su Mesh *mesh = mesh_owner.getornull(p_mesh); ERR_FAIL_COND(!mesh); + ERR_FAIL_COND(mesh->surface_count == RS::MAX_MESH_SURFACES); + #ifdef DEBUG_ENABLED //do a validation, to catch errors first { @@ -2714,9 +2716,7 @@ void RendererStorageRD::mesh_add_surface(RID p_mesh, const RS::SurfaceData &p_su mesh->surfaces[mesh->surface_count] = s; mesh->surface_count++; - for (List<MeshInstance *>::Element *E = mesh->instances.front(); E; E = E->next()) { - //update instances - MeshInstance *mi = E->get(); + for (MeshInstance *mi : mesh->instances) { _mesh_instance_add_surface(mi, mesh, mesh->surface_count - 1); } @@ -3027,8 +3027,7 @@ void RendererStorageRD::mesh_clear(RID p_mesh) { mesh->surface_count = 0; mesh->material_cache.clear(); //clear instance data - for (List<MeshInstance *>::Element *E = mesh->instances.front(); E; E = E->next()) { - MeshInstance *mi = E->get(); + for (MeshInstance *mi : mesh->instances) { _mesh_instance_clear(mi); } mesh->has_bone_weights = false; @@ -4960,7 +4959,7 @@ void RendererStorageRD::particles_set_view_axis(RID p_particles, const Vector3 & RD::get_singleton()->compute_list_dispatch_threads(compute_list, particles->amount, 1, 1); RD::get_singleton()->compute_list_end(); - effects.sort_buffer(particles->particles_sort_uniform_set, particles->amount); + effects->sort_buffer(particles->particles_sort_uniform_set, particles->amount); } copy_push_constant.total_particles *= copy_push_constant.total_particles; @@ -5886,6 +5885,10 @@ void RendererStorageRD::light_set_param(RID p_light, RS::LightParam p_param, flo ERR_FAIL_COND(!light); ERR_FAIL_INDEX(p_param, RS::LIGHT_PARAM_MAX); + if (light->param[p_param] == p_value) { + return; + } + switch (p_param) { case RS::LIGHT_PARAM_RANGE: case RS::LIGHT_PARAM_SPOT_ANGLE: @@ -5899,6 +5902,12 @@ void RendererStorageRD::light_set_param(RID p_light, RS::LightParam p_param, flo light->version++; light->dependency.changed_notify(DEPENDENCY_CHANGED_LIGHT); } break; + case RS::LIGHT_PARAM_SIZE: { + if ((light->param[p_param] > CMP_EPSILON) != (p_value > CMP_EPSILON)) { + //changing from no size to size and the opposite + light->dependency.changed_notify(DEPENDENCY_CHANGED_LIGHT_SOFT_SHADOW_AND_PROJECTOR); + } + } break; default: { } } @@ -5935,8 +5944,11 @@ void RendererStorageRD::light_set_projector(RID p_light, RID p_texture) { light->projector = p_texture; - if (light->type != RS::LIGHT_DIRECTIONAL && light->projector.is_valid()) { - texture_add_to_decal_atlas(light->projector, light->type == RS::LIGHT_OMNI); + if (light->type != RS::LIGHT_DIRECTIONAL) { + if (light->projector.is_valid()) { + texture_add_to_decal_atlas(light->projector, light->type == RS::LIGHT_OMNI); + } + light->dependency.changed_notify(DEPENDENCY_CHANGED_LIGHT_SOFT_SHADOW_AND_PROJECTOR); } } @@ -7523,7 +7535,7 @@ void RendererStorageRD::render_target_copy_to_back_buffer(RID p_render_target, c //single texture copy for backbuffer //RD::get_singleton()->texture_copy(rt->color, rt->backbuffer_mipmap0, Vector3(region.position.x, region.position.y, 0), Vector3(region.position.x, region.position.y, 0), Vector3(region.size.x, region.size.y, 1), 0, 0, 0, 0, true); - effects.copy_to_rect(rt->color, rt->backbuffer_mipmap0, region, false, false, false, true, true); + effects->copy_to_rect(rt->color, rt->backbuffer_mipmap0, region, false, false, false, true, true); if (!p_gen_mipmaps) { return; @@ -7539,7 +7551,7 @@ void RendererStorageRD::render_target_copy_to_back_buffer(RID p_render_target, c region.size.y = MAX(1, region.size.y >> 1); const RenderTarget::BackbufferMipmap &mm = rt->backbuffer_mipmaps[i]; - effects.gaussian_blur(prev_texture, mm.mipmap, mm.mipmap_copy, region, true); + effects->gaussian_blur(prev_texture, mm.mipmap, mm.mipmap_copy, region, true); prev_texture = mm.mipmap; } } @@ -7562,7 +7574,7 @@ void RendererStorageRD::render_target_clear_back_buffer(RID p_render_target, con } //single texture copy for backbuffer - effects.set_color(rt->backbuffer_mipmap0, p_color, region, true); + effects->set_color(rt->backbuffer_mipmap0, p_color, region, true); } void RendererStorageRD::render_target_gen_back_buffer_mipmaps(RID p_render_target, const Rect2i &p_region) { @@ -7592,7 +7604,7 @@ void RendererStorageRD::render_target_gen_back_buffer_mipmaps(RID p_render_targe region.size.y = MAX(1, region.size.y >> 1); const RenderTarget::BackbufferMipmap &mm = rt->backbuffer_mipmaps[i]; - effects.gaussian_blur(prev_texture, mm.mipmap, mm.mipmap_copy, region, true); + effects->gaussian_blur(prev_texture, mm.mipmap, mm.mipmap_copy, region, true); prev_texture = mm.mipmap; } } @@ -7913,14 +7925,14 @@ void RendererStorageRD::_update_decal_atlas() { while ((K = decal_atlas.textures.next(K))) { DecalAtlas::Texture *t = decal_atlas.textures.getptr(*K); Texture *src_tex = texture_owner.getornull(*K); - effects.copy_to_atlas_fb(src_tex->rd_texture, mm.fb, t->uv_rect, draw_list, false, t->panorama_to_dp_users > 0); + effects->copy_to_atlas_fb(src_tex->rd_texture, mm.fb, t->uv_rect, draw_list, false, t->panorama_to_dp_users > 0); } RD::get_singleton()->draw_list_end(); prev_texture = mm.texture; } else { - effects.copy_to_fb_rect(prev_texture, mm.fb, Rect2i(Point2i(), mm.size)); + effects->copy_to_fb_rect(prev_texture, mm.fb, Rect2i(Point2i(), mm.size)); prev_texture = mm.texture; } } else { @@ -8398,10 +8410,10 @@ void RendererStorageRD::global_variables_load_settings(bool p_load_textures) { List<PropertyInfo> settings; ProjectSettings::get_singleton()->get_property_list(&settings); - for (List<PropertyInfo>::Element *E = settings.front(); E; E = E->next()) { - if (E->get().name.begins_with("shader_globals/")) { - StringName name = E->get().name.get_slice("/", 1); - Dictionary d = ProjectSettings::get_singleton()->get(E->get().name); + for (const PropertyInfo &E : settings) { + if (E.name.begins_with("shader_globals/")) { + StringName name = E.name.get_slice("/", 1); + Dictionary d = ProjectSettings::get_singleton()->get(E.name); ERR_CONTINUE(!d.has("type")); ERR_CONTINUE(!d.has("value")); @@ -8569,8 +8581,8 @@ void RendererStorageRD::_update_global_variables() { if (global_variables.must_update_buffer_materials) { // only happens in the case of a buffer variable added or removed, // so not often. - for (List<RID>::Element *E = global_variables.materials_using_buffer.front(); E; E = E->next()) { - Material *material = material_owner.getornull(E->get()); + for (const RID &E : global_variables.materials_using_buffer) { + Material *material = material_owner.getornull(E); ERR_CONTINUE(!material); //wtf _material_queue_update(material, true, false); @@ -8582,8 +8594,8 @@ void RendererStorageRD::_update_global_variables() { if (global_variables.must_update_texture_materials) { // only happens in the case of a buffer variable added or removed, // so not often. - for (List<RID>::Element *E = global_variables.materials_using_texture.front(); E; E = E->next()) { - Material *material = material_owner.getornull(E->get()); + for (const RID &E : global_variables.materials_using_texture) { + Material *material = material_owner.getornull(E); ERR_CONTINUE(!material); //wtf _material_queue_update(material, false, true); @@ -8792,8 +8804,13 @@ bool RendererStorageRD::free(RID p_rid) { return true; } +void RendererStorageRD::init_effects(bool p_prefer_raster_effects) { + effects = memnew(EffectsRD(p_prefer_raster_effects)); +} + EffectsRD *RendererStorageRD::get_effects() { - return &effects; + ERR_FAIL_NULL_V_MSG(effects, nullptr, "Effects haven't been initialised yet."); + return effects; } void RendererStorageRD::capture_timestamps_begin() { @@ -9373,7 +9390,13 @@ RendererStorageRD::RendererStorageRD() { // default material and shader for particles shader particles_shader.default_shader = shader_allocate(); shader_initialize(particles_shader.default_shader); - shader_set_code(particles_shader.default_shader, "shader_type particles; void process() { COLOR = vec4(1.0); } \n"); + shader_set_code(particles_shader.default_shader, R"( +shader_type particles; + +void process() { + COLOR = vec4(1.0); +} +)"); particles_shader.default_material = material_allocate(); material_initialize(particles_shader.default_material); material_set_shader(particles_shader.default_material, particles_shader.default_shader); @@ -9517,4 +9540,9 @@ RendererStorageRD::~RendererStorageRD() { if (decal_atlas.texture.is_valid()) { RD::get_singleton()->free(decal_atlas.texture); } + + if (effects) { + memdelete(effects); + effects = NULL; + } } diff --git a/servers/rendering/renderer_rd/renderer_storage_rd.h b/servers/rendering/renderer_rd/renderer_storage_rd.h index 1a33569c33..b290c07705 100644 --- a/servers/rendering/renderer_rd/renderer_storage_rd.h +++ b/servers/rendering/renderer_rd/renderer_storage_rd.h @@ -1290,7 +1290,7 @@ private: void _update_global_variables(); /* EFFECTS */ - EffectsRD effects; + EffectsRD *effects = NULL; public: virtual bool can_create_resources_async() const; @@ -1888,6 +1888,13 @@ public: return light->shadow; } + _FORCE_INLINE_ bool light_has_projector(RID p_light) const { + const Light *light = light_owner.getornull(p_light); + ERR_FAIL_COND_V(!light, RS::LIGHT_DIRECTIONAL); + + return texture_owner.owns(light->projector); + } + _FORCE_INLINE_ bool light_is_negative(RID p_light) const { const Light *light = light_owner.getornull(p_light); ERR_FAIL_COND_V(!light, RS::LIGHT_DIRECTIONAL); @@ -2367,6 +2374,7 @@ public: static RendererStorageRD *base_singleton; + void init_effects(bool p_prefer_raster_effects); EffectsRD *get_effects(); RendererStorageRD(); diff --git a/servers/rendering/renderer_rd/shader_compiler_rd.cpp b/servers/rendering/renderer_rd/shader_compiler_rd.cpp index b347197289..9c1068ea2e 100644 --- a/servers/rendering/renderer_rd/shader_compiler_rd.cpp +++ b/servers/rendering/renderer_rd/shader_compiler_rd.cpp @@ -571,7 +571,7 @@ String ShaderCompilerRD::_dump_node_code(const SL::Node *p_node, int p_level, Ge max_texture_uniforms++; } else { if (E->get().scope == SL::ShaderNode::Uniform::SCOPE_INSTANCE) { - continue; //instances are indexed directly, dont need index uniforms + continue; // Instances are indexed directly, don't need index uniforms. } max_uniforms++; @@ -605,7 +605,7 @@ String ShaderCompilerRD::_dump_node_code(const SL::Node *p_node, int p_level, Ge if (uniform.scope == SL::ShaderNode::Uniform::SCOPE_INSTANCE) { //insert, but don't generate any code. p_actions.uniforms->insert(uniform_name, uniform); - continue; //instances are indexed directly, dont need index uniforms + continue; // Instances are indexed directly, don't need index uniforms. } if (SL::is_sampler_type(uniform.type)) { ucode = "layout(set = " + itos(actions.texture_layout_set) + ", binding = " + itos(actions.base_texture_binding_index + uniform.texture_order) + ") uniform "; @@ -760,11 +760,11 @@ String ShaderCompilerRD::_dump_node_code(const SL::Node *p_node, int p_level, Ge if (var_frag_to_light.size() > 0) { String gcode = "\n\nstruct {\n"; - for (List<Pair<StringName, SL::ShaderNode::Varying>>::Element *E = var_frag_to_light.front(); E; E = E->next()) { - gcode += "\t" + _prestr(E->get().second.precision) + _typestr(E->get().second.type) + " " + _mkid(E->get().first); - if (E->get().second.array_size > 0) { + for (const Pair<StringName, SL::ShaderNode::Varying> &E : var_frag_to_light) { + gcode += "\t" + _prestr(E.second.precision) + _typestr(E.second.type) + " " + _mkid(E.first); + if (E.second.array_size > 0) { gcode += "["; - gcode += itos(E->get().second.array_size); + gcode += itos(E.second.array_size); gcode += "]"; } gcode += ";\n"; @@ -1351,7 +1351,13 @@ Error ShaderCompilerRD::compile(RS::ShaderMode p_mode, const String &p_code, Ide if (err != OK) { Vector<String> shader = p_code.split("\n"); for (int i = 0; i < shader.size(); i++) { - print_line(itos(i + 1) + " " + shader[i]); + if (i + 1 == parser.get_error_line()) { + // Mark the error line to be visible without having to look at + // the trace at the end. + print_line(vformat("E%4d-> %s", i + 1, shader[i])); + } else { + print_line(vformat("%5d | %s", i + 1, shader[i])); + } } _err_print_error(nullptr, p_path.utf8().get_data(), parser.get_error_line(), parser.get_error_text().utf8().get_data(), ERR_HANDLER_SHADER); @@ -1388,8 +1394,8 @@ void ShaderCompilerRD::initialize(DefaultIdentifierActions p_actions) { ShaderLanguage::get_builtin_funcs(&func_list); - for (List<String>::Element *E = func_list.front(); E; E = E->next()) { - internal_functions.insert(E->get()); + for (const String &E : func_list) { + internal_functions.insert(E); } texture_functions.insert("texture"); texture_functions.insert("textureProj"); diff --git a/servers/rendering/renderer_rd/shader_rd.cpp b/servers/rendering/renderer_rd/shader_rd.cpp index 27305cc938..5bb12fc168 100644 --- a/servers/rendering/renderer_rd/shader_rd.cpp +++ b/servers/rendering/renderer_rd/shader_rd.cpp @@ -116,8 +116,10 @@ void ShaderRD::setup(const char *p_vertex_code, const char *p_fragment_code, con } StringBuilder tohash; - tohash.append("[VersionKey]"); - tohash.append(RenderingDevice::get_singleton()->shader_get_cache_key()); + tohash.append("[SpirvCacheKey]"); + tohash.append(RenderingDevice::get_singleton()->shader_get_spirv_cache_key()); + tohash.append("[BinaryCacheKey]"); + tohash.append(RenderingDevice::get_singleton()->shader_get_binary_cache_key()); tohash.append("[Vertex]"); tohash.append(p_vertex_code ? p_vertex_code : ""); tohash.append("[Fragment]"); @@ -144,12 +146,14 @@ void ShaderRD::_clear_version(Version *p_version) { //clear versions if they exist if (p_version->variants) { for (int i = 0; i < variant_defines.size(); i++) { - RD::get_singleton()->free(p_version->variants[i]); + if (variants_enabled[i]) { + RD::get_singleton()->free(p_version->variants[i]); + } } memdelete_arr(p_version->variants); - if (p_version->variant_stages) { - memdelete_arr(p_version->variant_stages); + if (p_version->variant_data) { + memdelete_arr(p_version->variant_data); } p_version->variants = nullptr; } @@ -203,7 +207,7 @@ void ShaderRD::_compile_variant(uint32_t p_variant, Version *p_version) { return; //variant is disabled, return } - Vector<RD::ShaderStageData> &stages = p_version->variant_stages[p_variant]; + Vector<RD::ShaderStageSPIRVData> stages; String error; String current_source; @@ -217,8 +221,8 @@ void ShaderRD::_compile_variant(uint32_t p_variant, Version *p_version) { _build_variant_code(builder, p_variant, p_version, stage_templates[STAGE_TYPE_VERTEX]); current_source = builder.as_string(); - RD::ShaderStageData stage; - stage.spir_v = RD::get_singleton()->shader_compile_from_source(RD::SHADER_STAGE_VERTEX, current_source, RD::SHADER_LANGUAGE_GLSL, &error); + RD::ShaderStageSPIRVData stage; + stage.spir_v = RD::get_singleton()->shader_compile_spirv_from_source(RD::SHADER_STAGE_VERTEX, current_source, RD::SHADER_LANGUAGE_GLSL, &error); if (stage.spir_v.size() == 0) { build_ok = false; } else { @@ -235,8 +239,8 @@ void ShaderRD::_compile_variant(uint32_t p_variant, Version *p_version) { _build_variant_code(builder, p_variant, p_version, stage_templates[STAGE_TYPE_FRAGMENT]); current_source = builder.as_string(); - RD::ShaderStageData stage; - stage.spir_v = RD::get_singleton()->shader_compile_from_source(RD::SHADER_STAGE_FRAGMENT, current_source, RD::SHADER_LANGUAGE_GLSL, &error); + RD::ShaderStageSPIRVData stage; + stage.spir_v = RD::get_singleton()->shader_compile_spirv_from_source(RD::SHADER_STAGE_FRAGMENT, current_source, RD::SHADER_LANGUAGE_GLSL, &error); if (stage.spir_v.size() == 0) { build_ok = false; } else { @@ -254,8 +258,8 @@ void ShaderRD::_compile_variant(uint32_t p_variant, Version *p_version) { current_source = builder.as_string(); - RD::ShaderStageData stage; - stage.spir_v = RD::get_singleton()->shader_compile_from_source(RD::SHADER_STAGE_COMPUTE, current_source, RD::SHADER_LANGUAGE_GLSL, &error); + RD::ShaderStageSPIRVData stage; + stage.spir_v = RD::get_singleton()->shader_compile_spirv_from_source(RD::SHADER_STAGE_COMPUTE, current_source, RD::SHADER_LANGUAGE_GLSL, &error); if (stage.spir_v.size() == 0) { build_ok = false; } else { @@ -275,10 +279,15 @@ void ShaderRD::_compile_variant(uint32_t p_variant, Version *p_version) { return; } - RID shader = RD::get_singleton()->shader_create(stages); + Vector<uint8_t> shader_data = RD::get_singleton()->shader_compile_binary_from_spirv(stages); + + ERR_FAIL_COND(shader_data.size() == 0); + + RID shader = RD::get_singleton()->shader_create_from_bytecode(shader_data); { MutexLock lock(variant_set_mutex); p_version->variants[p_variant] = shader; + p_version->variant_data[p_variant] = shader_data; } } @@ -364,14 +373,12 @@ String ShaderRD::_version_get_sha1(Version *p_version) const { } static const char *shader_file_header = "GDSC"; -static const uint32_t cache_file_version = 1; +static const uint32_t cache_file_version = 2; bool ShaderRD::_load_from_cache(Version *p_version) { String sha1 = _version_get_sha1(p_version); String path = shader_cache_dir.plus_file(name).plus_file(base_sha256).plus_file(sha1) + ".cache"; - uint64_t time_from = OS::get_singleton()->get_ticks_usec(); - FileAccessRef f = FileAccess::open(path, FileAccess::READ); if (!f) { return false; @@ -390,76 +397,43 @@ bool ShaderRD::_load_from_cache(Version *p_version) { ERR_FAIL_COND_V(variant_count != (uint32_t)variant_defines.size(), false); //should not happen but check - bool success = true; for (uint32_t i = 0; i < variant_count; i++) { - uint32_t stage_count = f->get_32(); - p_version->variant_stages[i].resize(stage_count); - for (uint32_t j = 0; j < stage_count; j++) { - p_version->variant_stages[i].write[j].shader_stage = RD::ShaderStage(f->get_32()); - - int compression = f->get_32(); - uint32_t length = f->get_32(); - - if (compression == 0) { - Vector<uint8_t> data; - data.resize(length); - - f->get_buffer(data.ptrw(), length); - - p_version->variant_stages[i].write[j].spir_v = data; - } else { - Vector<uint8_t> data; - - if (compression == 2) { - //zstd - int smol_length = f->get_32(); - Vector<uint8_t> zstd_data; - - zstd_data.resize(smol_length); - f->get_buffer(zstd_data.ptrw(), smol_length); - - data.resize(length); - Compression::decompress(data.ptrw(), data.size(), zstd_data.ptr(), zstd_data.size(), Compression::MODE_ZSTD); - - } else { - data.resize(length); - f->get_buffer(data.ptrw(), length); - } - - Vector<uint8_t> spirv; - uint32_t spirv_size = smolv::GetDecodedBufferSize(data.ptr(), data.size()); - spirv.resize(spirv_size); - if (!smolv::Decode(data.ptr(), data.size(), spirv.ptrw(), spirv_size)) { - ERR_PRINT("Malformed smolv input uncompressing shader " + name + ", variant #" + itos(i) + " stage :" + itos(j)); - success = false; - break; - } - p_version->variant_stages[i].write[j].spir_v = spirv; - } + uint32_t variant_size = f->get_32(); + ERR_FAIL_COND_V(variant_size == 0 && variants_enabled[i], false); + if (!variants_enabled[i]) { + continue; } - } + Vector<uint8_t> variant_bytes; + variant_bytes.resize(variant_size); - if (!success) { - for (uint32_t i = 0; i < variant_count; i++) { - p_version->variant_stages[i].resize(0); - } - return false; - } + uint32_t br = f->get_buffer(variant_bytes.ptrw(), variant_size); - float time_ms = double(OS::get_singleton()->get_ticks_usec() - time_from) / 1000.0; + ERR_FAIL_COND_V(br != variant_size, false); - print_verbose("Shader cache load success '" + path + "' " + rtos(time_ms) + "ms."); + p_version->variant_data[i] = variant_bytes; + } for (uint32_t i = 0; i < variant_count; i++) { - RID shader = RD::get_singleton()->shader_create(p_version->variant_stages[i]); + if (!variants_enabled[i]) { + MutexLock lock(variant_set_mutex); + p_version->variants[i] = RID(); + continue; + } + RID shader = RD::get_singleton()->shader_create_from_bytecode(p_version->variant_data[i]); + if (shader.is_null()) { + for (uint32_t j = 0; j < i; j++) { + RD::get_singleton()->free(p_version->variants[i]); + } + ERR_FAIL_COND_V(shader.is_null(), false); + } { MutexLock lock(variant_set_mutex); p_version->variants[i] = shader; } } - memdelete_arr(p_version->variant_stages); //clear stages - p_version->variant_stages = nullptr; + memdelete_arr(p_version->variant_data); //clear stages + p_version->variant_data = nullptr; p_version->valid = true; return true; } @@ -476,49 +450,8 @@ void ShaderRD::_save_to_cache(Version *p_version) { f->store_32(variant_count); //variant count for (uint32_t i = 0; i < variant_count; i++) { - f->store_32(p_version->variant_stages[i].size()); //stage count - for (int j = 0; j < p_version->variant_stages[i].size(); j++) { - f->store_32(p_version->variant_stages[i][j].shader_stage); //stage count - Vector<uint8_t> spirv = p_version->variant_stages[i][j].spir_v; - - bool save_uncompressed = true; - if (shader_cache_save_compressed) { - smolv::ByteArray smolv; - bool strip_debug = !shader_cache_save_debug; - if (!smolv::Encode(spirv.ptr(), spirv.size(), smolv, strip_debug ? smolv::kEncodeFlagStripDebugInfo : 0)) { - ERR_PRINT("Error compressing shader " + name + ", variant #" + itos(i) + " stage :" + itos(i)); - } else { - bool compress_zstd = shader_cache_save_compressed_zstd; - - if (compress_zstd) { - Vector<uint8_t> zstd; - zstd.resize(Compression::get_max_compressed_buffer_size(smolv.size(), Compression::MODE_ZSTD)); - int dst_size = Compression::compress(zstd.ptrw(), &smolv[0], smolv.size(), Compression::MODE_ZSTD); - if (dst_size >= 0 && (uint32_t)dst_size < smolv.size()) { - f->store_32(2); //compressed zstd - f->store_32(smolv.size()); //size of smolv buffer - f->store_32(dst_size); //size of smolv buffer - f->store_buffer(zstd.ptr(), dst_size); //smolv buffer - } else { - compress_zstd = false; - } - } - - if (!compress_zstd) { - f->store_32(1); //compressed - f->store_32(smolv.size()); //size of smolv buffer - f->store_buffer(&smolv[0], smolv.size()); //smolv buffer - } - save_uncompressed = false; - } - } - - if (save_uncompressed) { - f->store_32(0); //uncompressed - f->store_32(spirv.size()); //stage count - f->store_buffer(spirv.ptr(), spirv.size()); //stage count - } - } + f->store_32(p_version->variant_data[i].size()); //stage count + f->store_buffer(p_version->variant_data[i].ptr(), p_version->variant_data[i].size()); } f->close(); @@ -531,8 +464,8 @@ void ShaderRD::_compile_version(Version *p_version) { p_version->dirty = false; p_version->variants = memnew_arr(RID, variant_defines.size()); - typedef Vector<RD::ShaderStageData> ShaderStageArray; - p_version->variant_stages = memnew_arr(ShaderStageArray, variant_defines.size()); + typedef Vector<uint8_t> ShaderStageData; + p_version->variant_data = memnew_arr(ShaderStageData, variant_defines.size()); if (shader_cache_dir_valid) { if (_load_from_cache(p_version)) { @@ -571,19 +504,19 @@ void ShaderRD::_compile_version(Version *p_version) { } } memdelete_arr(p_version->variants); - if (p_version->variant_stages) { - memdelete_arr(p_version->variant_stages); + if (p_version->variant_data) { + memdelete_arr(p_version->variant_data); } p_version->variants = nullptr; - p_version->variant_stages = nullptr; + p_version->variant_data = nullptr; return; } else if (shader_cache_dir_valid) { //save shader cache _save_to_cache(p_version); } - memdelete_arr(p_version->variant_stages); //clear stages - p_version->variant_stages = nullptr; + memdelete_arr(p_version->variant_data); //clear stages + p_version->variant_data = nullptr; p_version->valid = true; } diff --git a/servers/rendering/renderer_rd/shader_rd.h b/servers/rendering/renderer_rd/shader_rd.h index 9a68e02007..529328f0ed 100644 --- a/servers/rendering/renderer_rd/shader_rd.h +++ b/servers/rendering/renderer_rd/shader_rd.h @@ -59,7 +59,7 @@ class ShaderRD { Map<StringName, CharString> code_sections; Vector<CharString> custom_defines; - Vector<RD::ShaderStageData> *variant_stages = nullptr; + Vector<uint8_t> *variant_data = nullptr; RID *variants = nullptr; //same size as version defines bool valid; diff --git a/servers/rendering/renderer_rd/shaders/blur_raster.glsl b/servers/rendering/renderer_rd/shaders/blur_raster.glsl new file mode 100644 index 0000000000..b1d1c2365e --- /dev/null +++ b/servers/rendering/renderer_rd/shaders/blur_raster.glsl @@ -0,0 +1,228 @@ +/* clang-format off */ +#[vertex] + +#version 450 + +#VERSION_DEFINES + +#include "blur_raster_inc.glsl" + +layout(location = 0) out vec2 uv_interp; +/* clang-format on */ + +void main() { + vec2 base_arr[4] = vec2[](vec2(0.0, 0.0), vec2(0.0, 1.0), vec2(1.0, 1.0), vec2(1.0, 0.0)); + uv_interp = base_arr[gl_VertexIndex]; + + gl_Position = vec4(uv_interp * 2.0 - 1.0, 0.0, 1.0); +} + +/* clang-format off */ +#[fragment] + +#version 450 + +#VERSION_DEFINES + +#include "blur_raster_inc.glsl" + +layout(location = 0) in vec2 uv_interp; +/* clang-format on */ + +layout(set = 0, binding = 0) uniform sampler2D source_color; + +#ifdef GLOW_USE_AUTO_EXPOSURE +layout(set = 1, binding = 0) uniform sampler2D source_auto_exposure; +#endif + +layout(location = 0) out vec4 frag_color; + +//DOF +#ifdef MODE_DOF_BLUR + +layout(set = 1, binding = 0) uniform sampler2D dof_source_depth; + +#ifdef DOF_QUALITY_LOW +const int dof_kernel_size = 5; +const int dof_kernel_from = 2; +const float dof_kernel[5] = float[](0.153388, 0.221461, 0.250301, 0.221461, 0.153388); +#endif + +#ifdef DOF_QUALITY_MEDIUM +const int dof_kernel_size = 11; +const int dof_kernel_from = 5; +const float dof_kernel[11] = float[](0.055037, 0.072806, 0.090506, 0.105726, 0.116061, 0.119726, 0.116061, 0.105726, 0.090506, 0.072806, 0.055037); + +#endif + +#ifdef DOF_QUALITY_HIGH +const int dof_kernel_size = 21; +const int dof_kernel_from = 10; +const float dof_kernel[21] = float[](0.028174, 0.032676, 0.037311, 0.041944, 0.046421, 0.050582, 0.054261, 0.057307, 0.059587, 0.060998, 0.061476, 0.060998, 0.059587, 0.057307, 0.054261, 0.050582, 0.046421, 0.041944, 0.037311, 0.032676, 0.028174); +#endif + +#endif + +void main() { +#ifdef MODE_MIPMAP + + vec2 pix_size = blur.pixel_size; + vec4 color = texture(source_color, uv_interp + vec2(-0.5, -0.5) * pix_size); + color += texture(source_color, uv_interp + vec2(0.5, -0.5) * pix_size); + color += texture(source_color, uv_interp + vec2(0.5, 0.5) * pix_size); + color += texture(source_color, uv_interp + vec2(-0.5, 0.5) * pix_size); + frag_color = color / 4.0; + +#endif + +#ifdef MODE_GAUSSIAN_BLUR + + //Simpler blur uses SIGMA2 for the gaussian kernel for a stronger effect + + if (bool(blur.flags & FLAG_HORIZONTAL)) { + vec2 pix_size = blur.pixel_size; + pix_size *= 0.5; //reading from larger buffer, so use more samples + vec4 color = texture(source_color, uv_interp + vec2(0.0, 0.0) * pix_size) * 0.214607; + color += texture(source_color, uv_interp + vec2(1.0, 0.0) * pix_size) * 0.189879; + color += texture(source_color, uv_interp + vec2(2.0, 0.0) * pix_size) * 0.131514; + color += texture(source_color, uv_interp + vec2(3.0, 0.0) * pix_size) * 0.071303; + color += texture(source_color, uv_interp + vec2(-1.0, 0.0) * pix_size) * 0.189879; + color += texture(source_color, uv_interp + vec2(-2.0, 0.0) * pix_size) * 0.131514; + color += texture(source_color, uv_interp + vec2(-3.0, 0.0) * pix_size) * 0.071303; + frag_color = color; + } else { + vec2 pix_size = blur.pixel_size; + vec4 color = texture(source_color, uv_interp + vec2(0.0, 0.0) * pix_size) * 0.38774; + color += texture(source_color, uv_interp + vec2(0.0, 1.0) * pix_size) * 0.24477; + color += texture(source_color, uv_interp + vec2(0.0, 2.0) * pix_size) * 0.06136; + color += texture(source_color, uv_interp + vec2(0.0, -1.0) * pix_size) * 0.24477; + color += texture(source_color, uv_interp + vec2(0.0, -2.0) * pix_size) * 0.06136; + frag_color = color; + } +#endif + +#ifdef MODE_GAUSSIAN_GLOW + + //Glow uses larger sigma 1 for a more rounded blur effect + +#define GLOW_ADD(m_ofs, m_mult) \ + { \ + vec2 ofs = uv_interp + m_ofs * pix_size; \ + vec4 c = texture(source_color, ofs) * m_mult; \ + if (any(lessThan(ofs, vec2(0.0))) || any(greaterThan(ofs, vec2(1.0)))) { \ + c *= 0.0; \ + } \ + color += c; \ + } + + if (bool(blur.flags & FLAG_HORIZONTAL)) { + vec2 pix_size = blur.pixel_size; + pix_size *= 0.5; //reading from larger buffer, so use more samples + vec4 color = texture(source_color, uv_interp + vec2(0.0, 0.0) * pix_size) * 0.174938; + GLOW_ADD(vec2(1.0, 0.0), 0.165569); + GLOW_ADD(vec2(2.0, 0.0), 0.140367); + GLOW_ADD(vec2(3.0, 0.0), 0.106595); + GLOW_ADD(vec2(-1.0, 0.0), 0.165569); + GLOW_ADD(vec2(-2.0, 0.0), 0.140367); + GLOW_ADD(vec2(-3.0, 0.0), 0.106595); + color *= blur.glow_strength; + frag_color = color; + } else { + vec2 pix_size = blur.pixel_size; + vec4 color = texture(source_color, uv_interp + vec2(0.0, 0.0) * pix_size) * 0.288713; + GLOW_ADD(vec2(0.0, 1.0), 0.233062); + GLOW_ADD(vec2(0.0, 2.0), 0.122581); + GLOW_ADD(vec2(0.0, -1.0), 0.233062); + GLOW_ADD(vec2(0.0, -2.0), 0.122581); + color *= blur.glow_strength; + frag_color = color; + } + +#undef GLOW_ADD + + if (bool(blur.flags & FLAG_GLOW_FIRST_PASS)) { +#ifdef GLOW_USE_AUTO_EXPOSURE + + frag_color /= texelFetch(source_auto_exposure, ivec2(0, 0), 0).r / blur.glow_auto_exposure_grey; +#endif + frag_color *= blur.glow_exposure; + + float luminance = max(frag_color.r, max(frag_color.g, frag_color.b)); + float feedback = max(smoothstep(blur.glow_hdr_threshold, blur.glow_hdr_threshold + blur.glow_hdr_scale, luminance), blur.glow_bloom); + + frag_color = min(frag_color * feedback, vec4(blur.glow_luminance_cap)); + } + +#endif + +#ifdef MODE_DOF_BLUR + + vec4 color_accum = vec4(0.0); + + float depth = texture(dof_source_depth, uv_interp, 0.0).r; + depth = depth * 2.0 - 1.0; + + if (bool(blur.flags & FLAG_USE_ORTHOGONAL_PROJECTION)) { + depth = ((depth + (blur.camera_z_far + blur.camera_z_near) / (blur.camera_z_far - blur.camera_z_near)) * (blur.camera_z_far - blur.camera_z_near)) / 2.0; + } else { + depth = 2.0 * blur.camera_z_near * blur.camera_z_far / (blur.camera_z_far + blur.camera_z_near - depth * (blur.camera_z_far - blur.camera_z_near)); + } + + // mix near and far blur amount + float amount = 1.0; + if (bool(blur.flags & FLAG_DOF_FAR)) { + amount *= 1.0 - smoothstep(blur.dof_far_begin, blur.dof_far_end, depth); + } + if (bool(blur.flags & FLAG_DOF_NEAR)) { + amount *= smoothstep(blur.dof_near_end, blur.dof_near_begin, depth); + } + amount = 1.0 - amount; + + if (amount > 0.0) { + float k_accum = 0.0; + + for (int i = 0; i < dof_kernel_size; i++) { + int int_ofs = i - dof_kernel_from; + vec2 tap_uv = uv_interp + blur.dof_dir * float(int_ofs) * amount * blur.dof_radius; + + float tap_k = dof_kernel[i]; + + float tap_depth = texture(dof_source_depth, tap_uv, 0.0).r; + tap_depth = tap_depth * 2.0 - 1.0; + + if (bool(blur.flags & FLAG_USE_ORTHOGONAL_PROJECTION)) { + tap_depth = ((tap_depth + (blur.camera_z_far + blur.camera_z_near) / (blur.camera_z_far - blur.camera_z_near)) * (blur.camera_z_far - blur.camera_z_near)) / 2.0; + } else { + tap_depth = 2.0 * blur.camera_z_near * blur.camera_z_far / (blur.camera_z_far + blur.camera_z_near - tap_depth * (blur.camera_z_far - blur.camera_z_near)); + } + + // mix near and far blur amount + float tap_amount = 1.0; + if (bool(blur.flags & FLAG_DOF_FAR)) { + tap_amount *= mix(1.0 - smoothstep(blur.dof_far_begin, blur.dof_far_end, tap_depth), 0.0, int_ofs == 0); + } + if (bool(blur.flags & FLAG_DOF_NEAR)) { + tap_amount *= mix(smoothstep(blur.dof_near_end, blur.dof_near_begin, tap_depth), 0.0, int_ofs == 0); + } + tap_amount = 1.0 - tap_amount; + + tap_amount *= tap_amount * tap_amount; //prevent undesired glow effect + + vec4 tap_color = texture(source_color, tap_uv, 0.0) * tap_k; + + k_accum += tap_k * tap_amount; + color_accum += tap_color * tap_amount; + } + + if (k_accum > 0.0) { + color_accum /= k_accum; + } + + frag_color = color_accum; ///k_accum; + } else { + // we are in focus, don't waste time + frag_color = texture(source_color, uv_interp, 0.0); + } + +#endif +} diff --git a/servers/rendering/renderer_rd/shaders/blur_raster_inc.glsl b/servers/rendering/renderer_rd/shaders/blur_raster_inc.glsl new file mode 100644 index 0000000000..6ea968e595 --- /dev/null +++ b/servers/rendering/renderer_rd/shaders/blur_raster_inc.glsl @@ -0,0 +1,36 @@ +#define FLAG_HORIZONTAL (1 << 0) +#define FLAG_USE_ORTHOGONAL_PROJECTION (1 << 1) +#define FLAG_GLOW_FIRST_PASS (1 << 2) +#define FLAG_DOF_FAR (1 << 3) +#define FLAG_DOF_NEAR (1 << 4) + +layout(push_constant, binding = 1, std430) uniform Blur { + vec2 pixel_size; + uint flags; + uint pad; + + // Glow. + float glow_strength; + float glow_bloom; + float glow_hdr_threshold; + float glow_hdr_scale; + + float glow_exposure; + float glow_white; + float glow_luminance_cap; + float glow_auto_exposure_grey; + + // DOF. + float dof_far_begin; + float dof_far_end; + float dof_near_begin; + float dof_near_end; + + float dof_radius; + float dof_pad[3]; + + vec2 dof_dir; + float camera_z_far; + float camera_z_near; +} +blur; diff --git a/servers/rendering/renderer_rd/shaders/cubemap_downsampler.glsl b/servers/rendering/renderer_rd/shaders/cubemap_downsampler.glsl index 9fa84657d1..63f0ce690e 100644 --- a/servers/rendering/renderer_rd/shaders/cubemap_downsampler.glsl +++ b/servers/rendering/renderer_rd/shaders/cubemap_downsampler.glsl @@ -32,53 +32,7 @@ layout(set = 0, binding = 0) uniform samplerCube source_cubemap; layout(rgba16f, set = 1, binding = 0) uniform restrict writeonly imageCube dest_cubemap; -layout(push_constant, binding = 1, std430) uniform Params { - uint face_size; -} -params; - -#define M_PI 3.14159265359 - -void get_dir_0(out vec3 dir, in float u, in float v) { - dir[0] = 1.0; - dir[1] = v; - dir[2] = -u; -} - -void get_dir_1(out vec3 dir, in float u, in float v) { - dir[0] = -1.0; - dir[1] = v; - dir[2] = u; -} - -void get_dir_2(out vec3 dir, in float u, in float v) { - dir[0] = u; - dir[1] = 1.0; - dir[2] = -v; -} - -void get_dir_3(out vec3 dir, in float u, in float v) { - dir[0] = u; - dir[1] = -1.0; - dir[2] = v; -} - -void get_dir_4(out vec3 dir, in float u, in float v) { - dir[0] = u; - dir[1] = v; - dir[2] = 1.0; -} - -void get_dir_5(out vec3 dir, in float u, in float v) { - dir[0] = -u; - dir[1] = v; - dir[2] = -1.0; -} - -float calcWeight(float u, float v) { - float val = u * u + v * v + 1.0; - return val * sqrt(val); -} +#include "cubemap_downsampler_inc.glsl" void main() { uvec3 id = gl_GlobalInvocationID; diff --git a/servers/rendering/renderer_rd/shaders/cubemap_downsampler_inc.glsl b/servers/rendering/renderer_rd/shaders/cubemap_downsampler_inc.glsl new file mode 100644 index 0000000000..b329e67293 --- /dev/null +++ b/servers/rendering/renderer_rd/shaders/cubemap_downsampler_inc.glsl @@ -0,0 +1,48 @@ +layout(push_constant, binding = 1, std430) uniform Params { + uint face_size; + uint face_id; // only used in raster shader +} +params; + +#define M_PI 3.14159265359 + +void get_dir_0(out vec3 dir, in float u, in float v) { + dir[0] = 1.0; + dir[1] = v; + dir[2] = -u; +} + +void get_dir_1(out vec3 dir, in float u, in float v) { + dir[0] = -1.0; + dir[1] = v; + dir[2] = u; +} + +void get_dir_2(out vec3 dir, in float u, in float v) { + dir[0] = u; + dir[1] = 1.0; + dir[2] = -v; +} + +void get_dir_3(out vec3 dir, in float u, in float v) { + dir[0] = u; + dir[1] = -1.0; + dir[2] = v; +} + +void get_dir_4(out vec3 dir, in float u, in float v) { + dir[0] = u; + dir[1] = v; + dir[2] = 1.0; +} + +void get_dir_5(out vec3 dir, in float u, in float v) { + dir[0] = -u; + dir[1] = v; + dir[2] = -1.0; +} + +float calcWeight(float u, float v) { + float val = u * u + v * v + 1.0; + return val * sqrt(val); +} diff --git a/servers/rendering/renderer_rd/shaders/cubemap_downsampler_raster.glsl b/servers/rendering/renderer_rd/shaders/cubemap_downsampler_raster.glsl new file mode 100644 index 0000000000..0828ffd921 --- /dev/null +++ b/servers/rendering/renderer_rd/shaders/cubemap_downsampler_raster.glsl @@ -0,0 +1,163 @@ +// Copyright 2016 Activision Publishing, Inc. +// +// 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. + +/* clang-format off */ +#[vertex] + +#version 450 + +#VERSION_DEFINES + +#include "cubemap_downsampler_inc.glsl" + +layout(location = 0) out vec2 uv_interp; +/* clang-format on */ + +void main() { + vec2 base_arr[4] = vec2[](vec2(0.0, 0.0), vec2(0.0, 1.0), vec2(1.0, 1.0), vec2(1.0, 0.0)); + uv_interp = base_arr[gl_VertexIndex] * float(params.face_size); + gl_Position = vec4(base_arr[gl_VertexIndex] * 2.0 - 1.0, 0.0, 1.0); +} + +/* clang-format off */ +#[fragment] + +#version 450 + +#VERSION_DEFINES + +#include "cubemap_downsampler_inc.glsl" + +layout(set = 0, binding = 0) uniform samplerCube source_cubemap; + +layout(location = 0) in vec2 uv_interp; +layout(location = 0) out vec4 frag_color; +/* clang-format on */ + +void main() { + // Converted from compute shader which uses absolute coordinates. + // Could possibly simplify this + float face_size = float(params.face_size); + + if (uv_interp.x < face_size && uv_interp.y < face_size) { + float inv_face_size = 1.0 / face_size; + + float u0 = (uv_interp.x * 2.0 + 1.0 - 0.75) * inv_face_size - 1.0; + float u1 = (uv_interp.x * 2.0 + 1.0 + 0.75) * inv_face_size - 1.0; + + float v0 = (uv_interp.y * 2.0 + 1.0 - 0.75) * -inv_face_size + 1.0; + float v1 = (uv_interp.y * 2.0 + 1.0 + 0.75) * -inv_face_size + 1.0; + + float weights[4]; + weights[0] = calcWeight(u0, v0); + weights[1] = calcWeight(u1, v0); + weights[2] = calcWeight(u0, v1); + weights[3] = calcWeight(u1, v1); + + const float wsum = 0.5 / (weights[0] + weights[1] + weights[2] + weights[3]); + for (int i = 0; i < 4; i++) { + weights[i] = weights[i] * wsum + .125; + } + + vec3 dir; + vec4 color; + switch (params.face_id) { + case 0: + get_dir_0(dir, u0, v0); + color = textureLod(source_cubemap, normalize(dir), 0.0) * weights[0]; + + get_dir_0(dir, u1, v0); + color += textureLod(source_cubemap, normalize(dir), 0.0) * weights[1]; + + get_dir_0(dir, u0, v1); + color += textureLod(source_cubemap, normalize(dir), 0.0) * weights[2]; + + get_dir_0(dir, u1, v1); + color += textureLod(source_cubemap, normalize(dir), 0.0) * weights[3]; + break; + case 1: + get_dir_1(dir, u0, v0); + color = textureLod(source_cubemap, normalize(dir), 0.0) * weights[0]; + + get_dir_1(dir, u1, v0); + color += textureLod(source_cubemap, normalize(dir), 0.0) * weights[1]; + + get_dir_1(dir, u0, v1); + color += textureLod(source_cubemap, normalize(dir), 0.0) * weights[2]; + + get_dir_1(dir, u1, v1); + color += textureLod(source_cubemap, normalize(dir), 0.0) * weights[3]; + break; + case 2: + get_dir_2(dir, u0, v0); + color = textureLod(source_cubemap, normalize(dir), 0.0) * weights[0]; + + get_dir_2(dir, u1, v0); + color += textureLod(source_cubemap, normalize(dir), 0.0) * weights[1]; + + get_dir_2(dir, u0, v1); + color += textureLod(source_cubemap, normalize(dir), 0.0) * weights[2]; + + get_dir_2(dir, u1, v1); + color += textureLod(source_cubemap, normalize(dir), 0.0) * weights[3]; + break; + case 3: + get_dir_3(dir, u0, v0); + color = textureLod(source_cubemap, normalize(dir), 0.0) * weights[0]; + + get_dir_3(dir, u1, v0); + color += textureLod(source_cubemap, normalize(dir), 0.0) * weights[1]; + + get_dir_3(dir, u0, v1); + color += textureLod(source_cubemap, normalize(dir), 0.0) * weights[2]; + + get_dir_3(dir, u1, v1); + color += textureLod(source_cubemap, normalize(dir), 0.0) * weights[3]; + break; + case 4: + get_dir_4(dir, u0, v0); + color = textureLod(source_cubemap, normalize(dir), 0.0) * weights[0]; + + get_dir_4(dir, u1, v0); + color += textureLod(source_cubemap, normalize(dir), 0.0) * weights[1]; + + get_dir_4(dir, u0, v1); + color += textureLod(source_cubemap, normalize(dir), 0.0) * weights[2]; + + get_dir_4(dir, u1, v1); + color += textureLod(source_cubemap, normalize(dir), 0.0) * weights[3]; + break; + default: + get_dir_5(dir, u0, v0); + color = textureLod(source_cubemap, normalize(dir), 0.0) * weights[0]; + + get_dir_5(dir, u1, v0); + color += textureLod(source_cubemap, normalize(dir), 0.0) * weights[1]; + + get_dir_5(dir, u0, v1); + color += textureLod(source_cubemap, normalize(dir), 0.0) * weights[2]; + + get_dir_5(dir, u1, v1); + color += textureLod(source_cubemap, normalize(dir), 0.0) * weights[3]; + break; + } + frag_color = color; + } +} diff --git a/servers/rendering/renderer_rd/shaders/cubemap_filter_raster.glsl b/servers/rendering/renderer_rd/shaders/cubemap_filter_raster.glsl new file mode 100644 index 0000000000..324d306218 --- /dev/null +++ b/servers/rendering/renderer_rd/shaders/cubemap_filter_raster.glsl @@ -0,0 +1,256 @@ +// Copyright 2016 Activision Publishing, Inc. +// +// 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. + +/* clang-format off */ +#[vertex] + +#version 450 + +#VERSION_DEFINES + +layout(push_constant, binding = 1, std430) uniform Params { + int mip_level; + uint face_id; +} +params; + +layout(location = 0) out vec2 uv_interp; +/* clang-format on */ + +void main() { + vec2 base_arr[4] = vec2[](vec2(0.0, 0.0), vec2(0.0, 1.0), vec2(1.0, 1.0), vec2(1.0, 0.0)); + uv_interp = base_arr[gl_VertexIndex]; + gl_Position = vec4(base_arr[gl_VertexIndex] * 2.0 - 1.0, 0.0, 1.0); +} + +/* clang-format off */ +#[fragment] + +#version 450 + +#VERSION_DEFINES + +layout(push_constant, binding = 1, std430) uniform Params { + int mip_level; + uint face_id; +} +params; + +layout(set = 0, binding = 0) uniform samplerCube source_cubemap; + +layout(location = 0) in vec2 uv_interp; +layout(location = 0) out vec4 frag_color; + +/* clang-format on */ + +#ifdef USE_HIGH_QUALITY +#define NUM_TAPS 32 +#else +#define NUM_TAPS 8 +#endif + +#define BASE_RESOLUTION 128 + +#ifdef USE_HIGH_QUALITY +layout(set = 1, binding = 0, std430) buffer restrict readonly Data { + vec4[7][5][3][24] coeffs; +} +data; +#else +layout(set = 1, binding = 0, std430) buffer restrict readonly Data { + vec4[7][5][6] coeffs; +} +data; +#endif + +void get_dir(out vec3 dir, in vec2 uv, in uint face) { + switch (face) { + case 0: + dir = vec3(1.0, uv[1], -uv[0]); + break; + case 1: + dir = vec3(-1.0, uv[1], uv[0]); + break; + case 2: + dir = vec3(uv[0], 1.0, -uv[1]); + break; + case 3: + dir = vec3(uv[0], -1.0, uv[1]); + break; + case 4: + dir = vec3(uv[0], uv[1], 1.0); + break; + default: + dir = vec3(-uv[0], uv[1], -1.0); + break; + } +} + +void main() { + // determine dir / pos for the texel + vec3 dir, adir, frameZ; + { + vec2 uv; + uv.x = uv_interp.x; + uv.y = 1.0 - uv_interp.y; + uv = uv * 2.0 - 1.0; + + get_dir(dir, uv, params.face_id); + frameZ = normalize(dir); + + adir = abs(dir); + } + + // determine which texel this is + // NOTE (macOS/MoltenVK): Do not rename, "level" variable name conflicts with the Metal "level(float lod)" mipmap sampling function name. + int mip_level = 0; + + if (params.mip_level < 0) { + // return as is + frag_color.rgb = textureLod(source_cubemap, frameZ, 0.0).rgb; + frag_color.a = 1.0; + return; + } else if (params.mip_level > 6) { + // maximum level + mip_level = 6; + } else { + mip_level = params.mip_level; + } + + // GGX gather colors + vec4 color = vec4(0.0); + for (int axis = 0; axis < 3; axis++) { + const int otherAxis0 = 1 - (axis & 1) - (axis >> 1); + const int otherAxis1 = 2 - (axis >> 1); + + float frameweight = (max(adir[otherAxis0], adir[otherAxis1]) - .75) / .25; + if (frameweight > 0.0) { + // determine frame + vec3 UpVector; + switch (axis) { + case 0: + UpVector = vec3(1, 0, 0); + break; + case 1: + UpVector = vec3(0, 1, 0); + break; + default: + UpVector = vec3(0, 0, 1); + break; + } + + vec3 frameX = normalize(cross(UpVector, frameZ)); + vec3 frameY = cross(frameZ, frameX); + + // calculate parametrization for polynomial + float Nx = dir[otherAxis0]; + float Ny = dir[otherAxis1]; + float Nz = adir[axis]; + + float NmaxXY = max(abs(Ny), abs(Nx)); + Nx /= NmaxXY; + Ny /= NmaxXY; + + float theta; + if (Ny < Nx) { + if (Ny <= -0.999) + theta = Nx; + else + theta = Ny; + } else { + if (Ny >= 0.999) + theta = -Nx; + else + theta = -Ny; + } + + float phi; + if (Nz <= -0.999) + phi = -NmaxXY; + else if (Nz >= 0.999) + phi = NmaxXY; + else + phi = Nz; + + float theta2 = theta * theta; + float phi2 = phi * phi; + + // sample + for (int iSuperTap = 0; iSuperTap < NUM_TAPS / 4; iSuperTap++) { + const int index = (NUM_TAPS / 4) * axis + iSuperTap; + +#ifdef USE_HIGH_QUALITY + vec4 coeffsDir0[3]; + vec4 coeffsDir1[3]; + vec4 coeffsDir2[3]; + vec4 coeffsLevel[3]; + vec4 coeffsWeight[3]; + + for (int iCoeff = 0; iCoeff < 3; iCoeff++) { + coeffsDir0[iCoeff] = data.coeffs[mip_level][0][iCoeff][index]; + coeffsDir1[iCoeff] = data.coeffs[mip_level][1][iCoeff][index]; + coeffsDir2[iCoeff] = data.coeffs[mip_level][2][iCoeff][index]; + coeffsLevel[iCoeff] = data.coeffs[mip_level][3][iCoeff][index]; + coeffsWeight[iCoeff] = data.coeffs[mip_level][4][iCoeff][index]; + } + + for (int iSubTap = 0; iSubTap < 4; iSubTap++) { + // determine sample attributes (dir, weight, mip_level) + vec3 sample_dir = frameX * (coeffsDir0[0][iSubTap] + coeffsDir0[1][iSubTap] * theta2 + coeffsDir0[2][iSubTap] * phi2) + frameY * (coeffsDir1[0][iSubTap] + coeffsDir1[1][iSubTap] * theta2 + coeffsDir1[2][iSubTap] * phi2) + frameZ * (coeffsDir2[0][iSubTap] + coeffsDir2[1][iSubTap] * theta2 + coeffsDir2[2][iSubTap] * phi2); + + float sample_level = coeffsLevel[0][iSubTap] + coeffsLevel[1][iSubTap] * theta2 + coeffsLevel[2][iSubTap] * phi2; + + float sample_weight = coeffsWeight[0][iSubTap] + coeffsWeight[1][iSubTap] * theta2 + coeffsWeight[2][iSubTap] * phi2; +#else + vec4 coeffsDir0 = data.coeffs[mip_level][0][index]; + vec4 coeffsDir1 = data.coeffs[mip_level][1][index]; + vec4 coeffsDir2 = data.coeffs[mip_level][2][index]; + vec4 coeffsLevel = data.coeffs[mip_level][3][index]; + vec4 coeffsWeight = data.coeffs[mip_level][4][index]; + + for (int iSubTap = 0; iSubTap < 4; iSubTap++) { + // determine sample attributes (dir, weight, mip_level) + vec3 sample_dir = frameX * coeffsDir0[iSubTap] + frameY * coeffsDir1[iSubTap] + frameZ * coeffsDir2[iSubTap]; + + float sample_level = coeffsLevel[iSubTap]; + + float sample_weight = coeffsWeight[iSubTap]; +#endif + + sample_weight *= frameweight; + + // adjust for jacobian + sample_dir /= max(abs(sample_dir[0]), max(abs(sample_dir[1]), abs(sample_dir[2]))); + sample_level += 0.75 * log2(dot(sample_dir, sample_dir)); + // sample cubemap + color.xyz += textureLod(source_cubemap, normalize(sample_dir), sample_level).xyz * sample_weight; + color.w += sample_weight; + } + } + } + } + color /= color.w; + + // write color + color.xyz = max(vec3(0.0), color.xyz); + color.w = 1.0; + + frag_color = color; +} diff --git a/servers/rendering/renderer_rd/shaders/cubemap_roughness.glsl b/servers/rendering/renderer_rd/shaders/cubemap_roughness.glsl index ce7c03c1d4..28f4dc59ec 100644 --- a/servers/rendering/renderer_rd/shaders/cubemap_roughness.glsl +++ b/servers/rendering/renderer_rd/shaders/cubemap_roughness.glsl @@ -12,100 +12,7 @@ layout(set = 0, binding = 0) uniform samplerCube source_cube; layout(rgba16f, set = 1, binding = 0) uniform restrict writeonly imageCube dest_cubemap; -layout(push_constant, binding = 1, std430) uniform Params { - uint face_id; - uint sample_count; - float roughness; - bool use_direct_write; - float face_size; -} -params; - -#define M_PI 3.14159265359 - -vec3 texelCoordToVec(vec2 uv, uint faceID) { - mat3 faceUvVectors[6]; - - // -x - faceUvVectors[1][0] = vec3(0.0, 0.0, 1.0); // u -> +z - faceUvVectors[1][1] = vec3(0.0, -1.0, 0.0); // v -> -y - faceUvVectors[1][2] = vec3(-1.0, 0.0, 0.0); // -x face - - // +x - faceUvVectors[0][0] = vec3(0.0, 0.0, -1.0); // u -> -z - faceUvVectors[0][1] = vec3(0.0, -1.0, 0.0); // v -> -y - faceUvVectors[0][2] = vec3(1.0, 0.0, 0.0); // +x face - - // -y - faceUvVectors[3][0] = vec3(1.0, 0.0, 0.0); // u -> +x - faceUvVectors[3][1] = vec3(0.0, 0.0, -1.0); // v -> -z - faceUvVectors[3][2] = vec3(0.0, -1.0, 0.0); // -y face - - // +y - faceUvVectors[2][0] = vec3(1.0, 0.0, 0.0); // u -> +x - faceUvVectors[2][1] = vec3(0.0, 0.0, 1.0); // v -> +z - faceUvVectors[2][2] = vec3(0.0, 1.0, 0.0); // +y face - - // -z - faceUvVectors[5][0] = vec3(-1.0, 0.0, 0.0); // u -> -x - faceUvVectors[5][1] = vec3(0.0, -1.0, 0.0); // v -> -y - faceUvVectors[5][2] = vec3(0.0, 0.0, -1.0); // -z face - - // +z - faceUvVectors[4][0] = vec3(1.0, 0.0, 0.0); // u -> +x - faceUvVectors[4][1] = vec3(0.0, -1.0, 0.0); // v -> -y - faceUvVectors[4][2] = vec3(0.0, 0.0, 1.0); // +z face - - // out = u * s_faceUv[0] + v * s_faceUv[1] + s_faceUv[2]. - vec3 result = (faceUvVectors[faceID][0] * uv.x) + (faceUvVectors[faceID][1] * uv.y) + faceUvVectors[faceID][2]; - return normalize(result); -} - -vec3 ImportanceSampleGGX(vec2 Xi, float Roughness, vec3 N) { - float a = Roughness * Roughness; // DISNEY'S ROUGHNESS [see Burley'12 siggraph] - - // Compute distribution direction - float Phi = 2.0 * M_PI * Xi.x; - float CosTheta = sqrt((1.0 - Xi.y) / (1.0 + (a * a - 1.0) * Xi.y)); - float SinTheta = sqrt(1.0 - CosTheta * CosTheta); - - // Convert to spherical direction - vec3 H; - H.x = SinTheta * cos(Phi); - H.y = SinTheta * sin(Phi); - H.z = CosTheta; - - vec3 UpVector = abs(N.z) < 0.999 ? vec3(0.0, 0.0, 1.0) : vec3(1.0, 0.0, 0.0); - vec3 TangentX = normalize(cross(UpVector, N)); - vec3 TangentY = cross(N, TangentX); - - // Tangent to world space - return TangentX * H.x + TangentY * H.y + N * H.z; -} - -// http://graphicrants.blogspot.com.au/2013/08/specular-brdf-reference.html -float GGX(float NdotV, float a) { - float k = a / 2.0; - return NdotV / (NdotV * (1.0 - k) + k); -} - -// http://graphicrants.blogspot.com.au/2013/08/specular-brdf-reference.html -float G_Smith(float a, float nDotV, float nDotL) { - return GGX(nDotL, a * a) * GGX(nDotV, a * a); -} - -float radicalInverse_VdC(uint bits) { - bits = (bits << 16u) | (bits >> 16u); - bits = ((bits & 0x55555555u) << 1u) | ((bits & 0xAAAAAAAAu) >> 1u); - bits = ((bits & 0x33333333u) << 2u) | ((bits & 0xCCCCCCCCu) >> 2u); - bits = ((bits & 0x0F0F0F0Fu) << 4u) | ((bits & 0xF0F0F0F0u) >> 4u); - bits = ((bits & 0x00FF00FFu) << 8u) | ((bits & 0xFF00FF00u) >> 8u); - return float(bits) * 2.3283064365386963e-10; // / 0x100000000 -} - -vec2 Hammersley(uint i, uint N) { - return vec2(float(i) / float(N), radicalInverse_VdC(i)); -} +#include "cubemap_roughness_inc.glsl" void main() { uvec3 id = gl_GlobalInvocationID; diff --git a/servers/rendering/renderer_rd/shaders/cubemap_roughness_inc.glsl b/servers/rendering/renderer_rd/shaders/cubemap_roughness_inc.glsl new file mode 100644 index 0000000000..80c0ac4fb4 --- /dev/null +++ b/servers/rendering/renderer_rd/shaders/cubemap_roughness_inc.glsl @@ -0,0 +1,94 @@ +#define M_PI 3.14159265359 + +layout(push_constant, binding = 1, std430) uniform Params { + uint face_id; + uint sample_count; + float roughness; + bool use_direct_write; + float face_size; +} +params; + +vec3 texelCoordToVec(vec2 uv, uint faceID) { + mat3 faceUvVectors[6]; + + // -x + faceUvVectors[1][0] = vec3(0.0, 0.0, 1.0); // u -> +z + faceUvVectors[1][1] = vec3(0.0, -1.0, 0.0); // v -> -y + faceUvVectors[1][2] = vec3(-1.0, 0.0, 0.0); // -x face + + // +x + faceUvVectors[0][0] = vec3(0.0, 0.0, -1.0); // u -> -z + faceUvVectors[0][1] = vec3(0.0, -1.0, 0.0); // v -> -y + faceUvVectors[0][2] = vec3(1.0, 0.0, 0.0); // +x face + + // -y + faceUvVectors[3][0] = vec3(1.0, 0.0, 0.0); // u -> +x + faceUvVectors[3][1] = vec3(0.0, 0.0, -1.0); // v -> -z + faceUvVectors[3][2] = vec3(0.0, -1.0, 0.0); // -y face + + // +y + faceUvVectors[2][0] = vec3(1.0, 0.0, 0.0); // u -> +x + faceUvVectors[2][1] = vec3(0.0, 0.0, 1.0); // v -> +z + faceUvVectors[2][2] = vec3(0.0, 1.0, 0.0); // +y face + + // -z + faceUvVectors[5][0] = vec3(-1.0, 0.0, 0.0); // u -> -x + faceUvVectors[5][1] = vec3(0.0, -1.0, 0.0); // v -> -y + faceUvVectors[5][2] = vec3(0.0, 0.0, -1.0); // -z face + + // +z + faceUvVectors[4][0] = vec3(1.0, 0.0, 0.0); // u -> +x + faceUvVectors[4][1] = vec3(0.0, -1.0, 0.0); // v -> -y + faceUvVectors[4][2] = vec3(0.0, 0.0, 1.0); // +z face + + // out = u * s_faceUv[0] + v * s_faceUv[1] + s_faceUv[2]. + vec3 result = (faceUvVectors[faceID][0] * uv.x) + (faceUvVectors[faceID][1] * uv.y) + faceUvVectors[faceID][2]; + return normalize(result); +} + +vec3 ImportanceSampleGGX(vec2 Xi, float Roughness, vec3 N) { + float a = Roughness * Roughness; // DISNEY'S ROUGHNESS [see Burley'12 siggraph] + + // Compute distribution direction + float Phi = 2.0 * M_PI * Xi.x; + float CosTheta = sqrt((1.0 - Xi.y) / (1.0 + (a * a - 1.0) * Xi.y)); + float SinTheta = sqrt(1.0 - CosTheta * CosTheta); + + // Convert to spherical direction + vec3 H; + H.x = SinTheta * cos(Phi); + H.y = SinTheta * sin(Phi); + H.z = CosTheta; + + vec3 UpVector = abs(N.z) < 0.999 ? vec3(0.0, 0.0, 1.0) : vec3(1.0, 0.0, 0.0); + vec3 TangentX = normalize(cross(UpVector, N)); + vec3 TangentY = cross(N, TangentX); + + // Tangent to world space + return TangentX * H.x + TangentY * H.y + N * H.z; +} + +// http://graphicrants.blogspot.com.au/2013/08/specular-brdf-reference.html +float GGX(float NdotV, float a) { + float k = a / 2.0; + return NdotV / (NdotV * (1.0 - k) + k); +} + +// http://graphicrants.blogspot.com.au/2013/08/specular-brdf-reference.html +float G_Smith(float a, float nDotV, float nDotL) { + return GGX(nDotL, a * a) * GGX(nDotV, a * a); +} + +float radicalInverse_VdC(uint bits) { + bits = (bits << 16u) | (bits >> 16u); + bits = ((bits & 0x55555555u) << 1u) | ((bits & 0xAAAAAAAAu) >> 1u); + bits = ((bits & 0x33333333u) << 2u) | ((bits & 0xCCCCCCCCu) >> 2u); + bits = ((bits & 0x0F0F0F0Fu) << 4u) | ((bits & 0xF0F0F0F0u) >> 4u); + bits = ((bits & 0x00FF00FFu) << 8u) | ((bits & 0xFF00FF00u) >> 8u); + return float(bits) * 2.3283064365386963e-10; // / 0x100000000 +} + +vec2 Hammersley(uint i, uint N) { + return vec2(float(i) / float(N), radicalInverse_VdC(i)); +} diff --git a/servers/rendering/renderer_rd/shaders/cubemap_roughness_raster.glsl b/servers/rendering/renderer_rd/shaders/cubemap_roughness_raster.glsl new file mode 100644 index 0000000000..2570308816 --- /dev/null +++ b/servers/rendering/renderer_rd/shaders/cubemap_roughness_raster.glsl @@ -0,0 +1,63 @@ +/* clang-format off */ +#[vertex] + +#version 450 + +#VERSION_DEFINES + +#include "cubemap_roughness_inc.glsl" + +layout(location = 0) out vec2 uv_interp; +/* clang-format on */ + +void main() { + vec2 base_arr[4] = vec2[](vec2(0.0, 0.0), vec2(0.0, 1.0), vec2(1.0, 1.0), vec2(1.0, 0.0)); + uv_interp = base_arr[gl_VertexIndex]; + gl_Position = vec4(uv_interp * 2.0 - 1.0, 0.0, 1.0); +} + +/* clang-format off */ +#[fragment] + +#version 450 + +#VERSION_DEFINES + +#include "cubemap_roughness_inc.glsl" + +layout(location = 0) in vec2 uv_interp; + +layout(set = 0, binding = 0) uniform samplerCube source_cube; + +layout(location = 0) out vec4 frag_color; +/* clang-format on */ + +void main() { + vec3 N = texelCoordToVec(uv_interp * 2.0 - 1.0, params.face_id); + + //vec4 color = color_interp; + + if (params.use_direct_write) { + frag_color = vec4(texture(source_cube, N).rgb, 1.0); + } else { + vec4 sum = vec4(0.0, 0.0, 0.0, 0.0); + + for (uint sampleNum = 0u; sampleNum < params.sample_count; sampleNum++) { + vec2 xi = Hammersley(sampleNum, params.sample_count); + + vec3 H = ImportanceSampleGGX(xi, params.roughness, N); + vec3 V = N; + vec3 L = (2.0 * dot(V, H) * H - V); + + float ndotl = clamp(dot(N, L), 0.0, 1.0); + + if (ndotl > 0.0) { + sum.rgb += textureLod(source_cube, L, 0.0).rgb * ndotl; + sum.a += ndotl; + } + } + sum /= sum.a; + + frag_color = vec4(sum.rgb, 1.0); + } +} diff --git a/servers/rendering/renderer_rd/shaders/luminance_reduce_raster.glsl b/servers/rendering/renderer_rd/shaders/luminance_reduce_raster.glsl new file mode 100644 index 0000000000..29ebd74a90 --- /dev/null +++ b/servers/rendering/renderer_rd/shaders/luminance_reduce_raster.glsl @@ -0,0 +1,74 @@ +/* clang-format off */ +#[vertex] + +#version 450 + +#VERSION_DEFINES + +#include "luminance_reduce_raster_inc.glsl" + +layout(location = 0) out vec2 uv_interp; +/* clang-format on */ + +void main() { + vec2 base_arr[4] = vec2[](vec2(0.0, 0.0), vec2(0.0, 1.0), vec2(1.0, 1.0), vec2(1.0, 0.0)); + uv_interp = base_arr[gl_VertexIndex]; + + gl_Position = vec4(uv_interp * 2.0 - 1.0, 0.0, 1.0); +} + +/* clang-format off */ +#[fragment] + +#version 450 + +#VERSION_DEFINES + +#include "luminance_reduce_raster_inc.glsl" + +layout(location = 0) in vec2 uv_interp; +/* clang-format on */ + +layout(set = 0, binding = 0) uniform sampler2D source_exposure; + +#ifdef FINAL_PASS +layout(set = 1, binding = 0) uniform sampler2D prev_luminance; +#endif + +layout(location = 0) out highp float luminance; + +void main() { + ivec2 dest_pos = ivec2(uv_interp * settings.dest_size); + ivec2 src_pos = ivec2(uv_interp * settings.source_size); + + ivec2 next_pos = (dest_pos + ivec2(1)) * settings.source_size / settings.dest_size; + next_pos = max(next_pos, src_pos + ivec2(1)); //so it at least reads one pixel + + highp vec3 source_color = vec3(0.0); + for (int i = src_pos.x; i < next_pos.x; i++) { + for (int j = src_pos.y; j < next_pos.y; j++) { + source_color += texelFetch(source_exposure, ivec2(i, j), 0).rgb; + } + } + + source_color /= float((next_pos.x - src_pos.x) * (next_pos.y - src_pos.y)); + +#ifdef FIRST_PASS + luminance = max(source_color.r, max(source_color.g, source_color.b)); + + // This formula should be more "accurate" but gave an overexposed result when testing. + // Leaving it here so we can revisit it if we want. + // luminance = source_color.r * 0.21 + source_color.g * 0.71 + source_color.b * 0.07; +#else + luminance = source_color.r; +#endif + +#ifdef FINAL_PASS + // Obtain our target luminance + luminance = clamp(luminance, settings.min_luminance, settings.max_luminance); + + // Now smooth to our transition + highp float prev_lum = texelFetch(prev_luminance, ivec2(0, 0), 0).r; //1 pixel previous luminance + luminance = prev_lum + (luminance - prev_lum) * clamp(settings.exposure_adjust, 0.0, 1.0); +#endif +} diff --git a/servers/rendering/renderer_rd/shaders/luminance_reduce_raster_inc.glsl b/servers/rendering/renderer_rd/shaders/luminance_reduce_raster_inc.glsl new file mode 100644 index 0000000000..ed389ffe56 --- /dev/null +++ b/servers/rendering/renderer_rd/shaders/luminance_reduce_raster_inc.glsl @@ -0,0 +1,11 @@ + +layout(push_constant, binding = 1, std430) uniform PushConstant { + ivec2 source_size; + ivec2 dest_size; + + float exposure_adjust; + float min_luminance; + float max_luminance; + float pad; +} +settings; diff --git a/servers/rendering/renderer_rd/shaders/particles_copy.glsl b/servers/rendering/renderer_rd/shaders/particles_copy.glsl index 4dceeea995..e88e68b511 100644 --- a/servers/rendering/renderer_rd/shaders/particles_copy.glsl +++ b/servers/rendering/renderer_rd/shaders/particles_copy.glsl @@ -138,7 +138,7 @@ void main() { if (bool(particles.data[particle].flags & PARTICLE_FLAG_ACTIVE) || bool(particles.data[particle].flags & PARTICLE_FLAG_TRAILED)) { txform = particles.data[particle].xform; if (params.trail_size > 1) { - // since the steps dont fit precisely in the history frames, must do a tiny bit of + // Since the steps don't fit precisely in the history frames, must do a tiny bit of // interpolation to get them close to their intended location. uint part_ofs = particle % params.trail_size; float natural_ofs = fract((float(part_ofs) / float(params.trail_size)) * float(params.trail_total)) * params.frame_delta; diff --git a/servers/rendering/renderer_rd/shaders/scene_forward_clustered.glsl b/servers/rendering/renderer_rd/shaders/scene_forward_clustered.glsl index 74d5af5cb6..b3a349c948 100644 --- a/servers/rendering/renderer_rd/shaders/scene_forward_clustered.glsl +++ b/servers/rendering/renderer_rd/shaders/scene_forward_clustered.glsl @@ -356,6 +356,24 @@ void main() { #VERSION_DEFINES +/* Specialization Constants (Toggles) */ + +layout(constant_id = 0) const bool sc_use_forward_gi = false; +layout(constant_id = 1) const bool sc_use_light_projector = false; +layout(constant_id = 2) const bool sc_use_light_soft_shadows = false; +layout(constant_id = 3) const bool sc_use_directional_soft_shadows = false; + +/* Specialization Constants (Values) */ + +layout(constant_id = 6) const uint sc_soft_shadow_samples = 4; +layout(constant_id = 7) const uint sc_penumbra_shadow_samples = 4; + +layout(constant_id = 8) const uint sc_directional_soft_shadow_samples = 4; +layout(constant_id = 9) const uint sc_directional_penumbra_shadow_samples = 4; + +layout(constant_id = 10) const bool sc_decal_use_mipmaps = true; +layout(constant_id = 11) const bool sc_projector_use_mipmaps = true; + #include "scene_forward_clustered_inc.glsl" /* Varyings */ @@ -450,12 +468,8 @@ layout(location = 0) out vec4 frag_color; #include "scene_forward_lights_inc.glsl" -#ifdef USE_FORWARD_GI - #include "scene_forward_gi_inc.glsl" -#endif //USE_FORWARD_GI - #endif //!defined(MODE_RENDER_DEPTH) && !defined(MODE_UNSHADED) #ifndef MODE_RENDER_DEPTH @@ -793,25 +807,35 @@ void main() { continue; //out of decal } - //we need ddx/ddy for mipmaps, so simulate them - vec2 ddx = (decals.data[decal_index].xform * vec4(vertex_ddx, 0.0)).xz; - vec2 ddy = (decals.data[decal_index].xform * vec4(vertex_ddy, 0.0)).xz; - float fade = pow(1.0 - (uv_local.y > 0.0 ? uv_local.y : -uv_local.y), uv_local.y > 0.0 ? decals.data[decal_index].upper_fade : decals.data[decal_index].lower_fade); if (decals.data[decal_index].normal_fade > 0.0) { fade *= smoothstep(decals.data[decal_index].normal_fade, 1.0, dot(normal_interp, decals.data[decal_index].normal) * 0.5 + 0.5); } + //we need ddx/ddy for mipmaps, so simulate them + vec2 ddx = (decals.data[decal_index].xform * vec4(vertex_ddx, 0.0)).xz; + vec2 ddy = (decals.data[decal_index].xform * vec4(vertex_ddy, 0.0)).xz; + if (decals.data[decal_index].albedo_rect != vec4(0.0)) { //has albedo - vec4 decal_albedo = textureGrad(sampler2D(decal_atlas_srgb, material_samplers[SAMPLER_LINEAR_WITH_MIPMAPS_CLAMP]), uv_local.xz * decals.data[decal_index].albedo_rect.zw + decals.data[decal_index].albedo_rect.xy, ddx * decals.data[decal_index].albedo_rect.zw, ddy * decals.data[decal_index].albedo_rect.zw); + vec4 decal_albedo; + if (sc_decal_use_mipmaps) { + decal_albedo = textureGrad(sampler2D(decal_atlas_srgb, decal_sampler), uv_local.xz * decals.data[decal_index].albedo_rect.zw + decals.data[decal_index].albedo_rect.xy, ddx * decals.data[decal_index].albedo_rect.zw, ddy * decals.data[decal_index].albedo_rect.zw); + } else { + decal_albedo = textureLod(sampler2D(decal_atlas_srgb, decal_sampler), uv_local.xz * decals.data[decal_index].albedo_rect.zw + decals.data[decal_index].albedo_rect.xy, 0.0); + } decal_albedo *= decals.data[decal_index].modulate; decal_albedo.a *= fade; albedo = mix(albedo, decal_albedo.rgb, decal_albedo.a * decals.data[decal_index].albedo_mix); if (decals.data[decal_index].normal_rect != vec4(0.0)) { - vec3 decal_normal = textureGrad(sampler2D(decal_atlas, material_samplers[SAMPLER_LINEAR_WITH_MIPMAPS_CLAMP]), uv_local.xz * decals.data[decal_index].normal_rect.zw + decals.data[decal_index].normal_rect.xy, ddx * decals.data[decal_index].normal_rect.zw, ddy * decals.data[decal_index].normal_rect.zw).xyz; + vec3 decal_normal; + if (sc_decal_use_mipmaps) { + decal_normal = textureGrad(sampler2D(decal_atlas, decal_sampler), uv_local.xz * decals.data[decal_index].normal_rect.zw + decals.data[decal_index].normal_rect.xy, ddx * decals.data[decal_index].normal_rect.zw, ddy * decals.data[decal_index].normal_rect.zw).xyz; + } else { + decal_normal = textureLod(sampler2D(decal_atlas, decal_sampler), uv_local.xz * decals.data[decal_index].normal_rect.zw + decals.data[decal_index].normal_rect.xy, 0.0).xyz; + } decal_normal.xy = decal_normal.xy * vec2(2.0, -2.0) - vec2(1.0, -1.0); //users prefer flipped y normal maps in most authoring software decal_normal.z = sqrt(max(0.0, 1.0 - dot(decal_normal.xy, decal_normal.xy))); //convert to view space, use xzy because y is up @@ -821,7 +845,12 @@ void main() { } if (decals.data[decal_index].orm_rect != vec4(0.0)) { - vec3 decal_orm = textureGrad(sampler2D(decal_atlas, material_samplers[SAMPLER_LINEAR_WITH_MIPMAPS_CLAMP]), uv_local.xz * decals.data[decal_index].orm_rect.zw + decals.data[decal_index].orm_rect.xy, ddx * decals.data[decal_index].orm_rect.zw, ddy * decals.data[decal_index].orm_rect.zw).xyz; + vec3 decal_orm; + if (sc_decal_use_mipmaps) { + decal_orm = textureGrad(sampler2D(decal_atlas, decal_sampler), uv_local.xz * decals.data[decal_index].orm_rect.zw + decals.data[decal_index].orm_rect.xy, ddx * decals.data[decal_index].orm_rect.zw, ddy * decals.data[decal_index].orm_rect.zw).xyz; + } else { + decal_orm = textureLod(sampler2D(decal_atlas, decal_sampler), uv_local.xz * decals.data[decal_index].orm_rect.zw + decals.data[decal_index].orm_rect.xy, 0.0).xyz; + } ao = mix(ao, decal_orm.r, decal_albedo.a); roughness = mix(roughness, decal_orm.g, decal_albedo.a); metallic = mix(metallic, decal_orm.b, decal_albedo.a); @@ -830,7 +859,11 @@ void main() { if (decals.data[decal_index].emission_rect != vec4(0.0)) { //emission is additive, so its independent from albedo - emission += textureGrad(sampler2D(decal_atlas_srgb, material_samplers[SAMPLER_LINEAR_WITH_MIPMAPS_CLAMP]), uv_local.xz * decals.data[decal_index].emission_rect.zw + decals.data[decal_index].emission_rect.xy, ddx * decals.data[decal_index].emission_rect.zw, ddy * decals.data[decal_index].emission_rect.zw).xyz * decals.data[decal_index].emission_energy * fade; + if (sc_decal_use_mipmaps) { + emission += textureGrad(sampler2D(decal_atlas_srgb, decal_sampler), uv_local.xz * decals.data[decal_index].emission_rect.zw + decals.data[decal_index].emission_rect.xy, ddx * decals.data[decal_index].emission_rect.zw, ddy * decals.data[decal_index].emission_rect.zw).xyz * decals.data[decal_index].emission_energy * fade; + } else { + emission += textureLod(sampler2D(decal_atlas_srgb, decal_sampler), uv_local.xz * decals.data[decal_index].emission_rect.zw + decals.data[decal_index].emission_rect.xy, 0.0).xyz * decals.data[decal_index].emission_energy * fade; + } } } } @@ -963,9 +996,9 @@ void main() { ambient_light += textureLod(sampler2DArray(lightmap_textures[ofs], material_samplers[SAMPLER_LINEAR_CLAMP]), uvw, 0.0).rgb; } } -#elif defined(USE_FORWARD_GI) +#else - if (bool(instances.data[instance_index].flags & INSTANCE_FLAGS_USE_SDFGI)) { //has lightmap capture + if (sc_use_forward_gi && bool(instances.data[instance_index].flags & INSTANCE_FLAGS_USE_SDFGI)) { //has lightmap capture //make vertex orientation the world one, but still align to camera vec3 cam_pos = mat3(scene_data.camera_matrix) * vertex; @@ -1037,7 +1070,7 @@ void main() { } } - if (bool(instances.data[instance_index].flags & INSTANCE_FLAGS_USE_VOXEL_GI)) { // process voxel_gi_instances + if (sc_use_forward_gi && bool(instances.data[instance_index].flags & INSTANCE_FLAGS_USE_VOXEL_GI)) { // process voxel_gi_instances uint index1 = instances.data[instance_index].gi_offset & 0xFFFF; vec3 ref_vec = normalize(reflect(normalize(vertex), normal)); @@ -1068,9 +1101,8 @@ void main() { specular_light = spec_accum.rgb; ambient_light = amb_accum.rgb; } -#else - if (bool(instances.data[instance_index].flags & INSTANCE_FLAGS_USE_GI_BUFFERS)) { //use GI buffers + if (!sc_use_forward_gi && bool(instances.data[instance_index].flags & INSTANCE_FLAGS_USE_GI_BUFFERS)) { //use GI buffers vec2 coord; @@ -1101,7 +1133,7 @@ void main() { ambient_light = mix(ambient_light, buffer_ambient.rgb, buffer_ambient.a); specular_light = mix(specular_light, buffer_reflection.rgb, buffer_reflection.a); } -#endif +#endif // !USE_LIGHTMAP if (scene_data.ssao_enabled) { float ssao = texture(sampler2D(ao_buffer, material_samplers[SAMPLER_LINEAR_CLAMP]), screen_uv).r; @@ -1182,7 +1214,7 @@ void main() { specular_light *= specular * metallic * albedo * 2.0; #else - // scales the specular reflections, needs to be be computed before lighting happens, + // scales the specular reflections, needs to be computed before lighting happens, // but after environment, GI, and reflection probes are added // Environment brdf approximation (Lazarov 2013) // see https://www.unrealengine.com/en-US/blog/physically-based-shading-on-mobile @@ -1228,14 +1260,13 @@ void main() { float shadow = 1.0; -#ifdef USE_SOFT_SHADOWS //version with soft shadows, more expensive if (directional_lights.data[i].shadow_enabled) { - float depth_z = -vertex.z; + if (sc_use_directional_soft_shadows && directional_lights.data[i].softshadow_angle > 0) { + float depth_z = -vertex.z; - vec4 pssm_coord; - vec3 shadow_color = vec3(0.0); - vec3 light_dir = directional_lights.data[i].direction; + vec3 shadow_color = vec3(0.0); + vec3 light_dir = directional_lights.data[i].direction; #define BIAS_FUNC(m_var, m_idx) \ m_var.xyz += light_dir * directional_lights.data[i].shadow_bias[m_idx]; \ @@ -1243,168 +1274,105 @@ void main() { normal_bias -= light_dir * dot(light_dir, normal_bias); \ m_var.xyz += normal_bias; - if (depth_z < directional_lights.data[i].shadow_split_offsets.x) { - vec4 v = vec4(vertex, 1.0); + uint blend_index = 0; - BIAS_FUNC(v, 0) + if (depth_z < directional_lights.data[i].shadow_split_offsets.x) { + vec4 v = vec4(vertex, 1.0); - pssm_coord = (directional_lights.data[i].shadow_matrix1 * v); - pssm_coord /= pssm_coord.w; + BIAS_FUNC(v, 0) + + vec4 pssm_coord = (directional_lights.data[i].shadow_matrix1 * v); + pssm_coord /= pssm_coord.w; - if (directional_lights.data[i].softshadow_angle > 0) { float range_pos = dot(directional_lights.data[i].direction, v.xyz); float range_begin = directional_lights.data[i].shadow_range_begin.x; float test_radius = (range_pos - range_begin) * directional_lights.data[i].softshadow_angle; vec2 tex_scale = directional_lights.data[i].uv_scale1 * test_radius; shadow = sample_directional_soft_shadow(directional_shadow_atlas, pssm_coord.xyz, tex_scale * directional_lights.data[i].soft_shadow_scale); - } else { - shadow = sample_directional_pcf_shadow(directional_shadow_atlas, scene_data.directional_shadow_pixel_size * directional_lights.data[i].soft_shadow_scale, pssm_coord); + blend_index++; } - shadow_color = directional_lights.data[i].shadow_color1.rgb; - - } else if (depth_z < directional_lights.data[i].shadow_split_offsets.y) { - vec4 v = vec4(vertex, 1.0); + if (blend_index < 2 && depth_z < directional_lights.data[i].shadow_split_offsets.y) { + vec4 v = vec4(vertex, 1.0); - BIAS_FUNC(v, 1) + BIAS_FUNC(v, 1) - pssm_coord = (directional_lights.data[i].shadow_matrix2 * v); - pssm_coord /= pssm_coord.w; + vec4 pssm_coord = (directional_lights.data[i].shadow_matrix2 * v); + pssm_coord /= pssm_coord.w; - if (directional_lights.data[i].softshadow_angle > 0) { float range_pos = dot(directional_lights.data[i].direction, v.xyz); float range_begin = directional_lights.data[i].shadow_range_begin.y; float test_radius = (range_pos - range_begin) * directional_lights.data[i].softshadow_angle; vec2 tex_scale = directional_lights.data[i].uv_scale2 * test_radius; - shadow = sample_directional_soft_shadow(directional_shadow_atlas, pssm_coord.xyz, tex_scale * directional_lights.data[i].soft_shadow_scale); - } else { - shadow = sample_directional_pcf_shadow(directional_shadow_atlas, scene_data.directional_shadow_pixel_size * directional_lights.data[i].soft_shadow_scale, pssm_coord); + float s = sample_directional_soft_shadow(directional_shadow_atlas, pssm_coord.xyz, tex_scale * directional_lights.data[i].soft_shadow_scale); + + if (blend_index == 0) { + shadow = s; + } else { + //blend + float blend = smoothstep(0.0, directional_lights.data[i].shadow_split_offsets.x, depth_z); + shadow = mix(shadow, s, blend); + } + + blend_index++; } - shadow_color = directional_lights.data[i].shadow_color2.rgb; - } else if (depth_z < directional_lights.data[i].shadow_split_offsets.z) { - vec4 v = vec4(vertex, 1.0); + if (blend_index < 2 && depth_z < directional_lights.data[i].shadow_split_offsets.z) { + vec4 v = vec4(vertex, 1.0); - BIAS_FUNC(v, 2) + BIAS_FUNC(v, 2) - pssm_coord = (directional_lights.data[i].shadow_matrix3 * v); - pssm_coord /= pssm_coord.w; + vec4 pssm_coord = (directional_lights.data[i].shadow_matrix3 * v); + pssm_coord /= pssm_coord.w; - if (directional_lights.data[i].softshadow_angle > 0) { float range_pos = dot(directional_lights.data[i].direction, v.xyz); float range_begin = directional_lights.data[i].shadow_range_begin.z; float test_radius = (range_pos - range_begin) * directional_lights.data[i].softshadow_angle; vec2 tex_scale = directional_lights.data[i].uv_scale3 * test_radius; - shadow = sample_directional_soft_shadow(directional_shadow_atlas, pssm_coord.xyz, tex_scale * directional_lights.data[i].soft_shadow_scale); - } else { - shadow = sample_directional_pcf_shadow(directional_shadow_atlas, scene_data.directional_shadow_pixel_size * directional_lights.data[i].soft_shadow_scale, pssm_coord); - } - - shadow_color = directional_lights.data[i].shadow_color3.rgb; + float s = sample_directional_soft_shadow(directional_shadow_atlas, pssm_coord.xyz, tex_scale * directional_lights.data[i].soft_shadow_scale); - } else { - vec4 v = vec4(vertex, 1.0); - - BIAS_FUNC(v, 3) - - pssm_coord = (directional_lights.data[i].shadow_matrix4 * v); - pssm_coord /= pssm_coord.w; + if (blend_index == 0) { + shadow = s; + } else { + //blend + float blend = smoothstep(directional_lights.data[i].shadow_split_offsets.x, directional_lights.data[i].shadow_split_offsets.y, depth_z); + shadow = mix(shadow, s, blend); + } - if (directional_lights.data[i].softshadow_angle > 0) { - float range_pos = dot(directional_lights.data[i].direction, v.xyz); - float range_begin = directional_lights.data[i].shadow_range_begin.w; - float test_radius = (range_pos - range_begin) * directional_lights.data[i].softshadow_angle; - vec2 tex_scale = directional_lights.data[i].uv_scale4 * test_radius; - shadow = sample_directional_soft_shadow(directional_shadow_atlas, pssm_coord.xyz, tex_scale * directional_lights.data[i].soft_shadow_scale); - } else { - shadow = sample_directional_pcf_shadow(directional_shadow_atlas, scene_data.directional_shadow_pixel_size * directional_lights.data[i].soft_shadow_scale, pssm_coord); + blend_index++; } - shadow_color = directional_lights.data[i].shadow_color4.rgb; - } - - if (directional_lights.data[i].blend_splits) { - vec3 shadow_color_blend = vec3(0.0); - float pssm_blend; - float shadow2; - - if (depth_z < directional_lights.data[i].shadow_split_offsets.x) { + if (blend_index < 2) { vec4 v = vec4(vertex, 1.0); - BIAS_FUNC(v, 1) - pssm_coord = (directional_lights.data[i].shadow_matrix2 * v); - pssm_coord /= pssm_coord.w; - if (directional_lights.data[i].softshadow_angle > 0) { - float range_pos = dot(directional_lights.data[i].direction, v.xyz); - float range_begin = directional_lights.data[i].shadow_range_begin.y; - float test_radius = (range_pos - range_begin) * directional_lights.data[i].softshadow_angle; - vec2 tex_scale = directional_lights.data[i].uv_scale2 * test_radius; - shadow2 = sample_directional_soft_shadow(directional_shadow_atlas, pssm_coord.xyz, tex_scale * directional_lights.data[i].soft_shadow_scale); - } else { - shadow2 = sample_directional_pcf_shadow(directional_shadow_atlas, scene_data.directional_shadow_pixel_size * directional_lights.data[i].soft_shadow_scale, pssm_coord); - } + BIAS_FUNC(v, 3) - pssm_blend = smoothstep(0.0, directional_lights.data[i].shadow_split_offsets.x, depth_z); - shadow_color_blend = directional_lights.data[i].shadow_color2.rgb; - } else if (depth_z < directional_lights.data[i].shadow_split_offsets.y) { - vec4 v = vec4(vertex, 1.0); - BIAS_FUNC(v, 2) - pssm_coord = (directional_lights.data[i].shadow_matrix3 * v); + vec4 pssm_coord = (directional_lights.data[i].shadow_matrix4 * v); pssm_coord /= pssm_coord.w; - if (directional_lights.data[i].softshadow_angle > 0) { - float range_pos = dot(directional_lights.data[i].direction, v.xyz); - float range_begin = directional_lights.data[i].shadow_range_begin.z; - float test_radius = (range_pos - range_begin) * directional_lights.data[i].softshadow_angle; - vec2 tex_scale = directional_lights.data[i].uv_scale3 * test_radius; - shadow2 = sample_directional_soft_shadow(directional_shadow_atlas, pssm_coord.xyz, tex_scale * directional_lights.data[i].soft_shadow_scale); - } else { - shadow2 = sample_directional_pcf_shadow(directional_shadow_atlas, scene_data.directional_shadow_pixel_size * directional_lights.data[i].soft_shadow_scale, pssm_coord); - } - - pssm_blend = smoothstep(directional_lights.data[i].shadow_split_offsets.x, directional_lights.data[i].shadow_split_offsets.y, depth_z); + float range_pos = dot(directional_lights.data[i].direction, v.xyz); + float range_begin = directional_lights.data[i].shadow_range_begin.w; + float test_radius = (range_pos - range_begin) * directional_lights.data[i].softshadow_angle; + vec2 tex_scale = directional_lights.data[i].uv_scale4 * test_radius; + float s = sample_directional_soft_shadow(directional_shadow_atlas, pssm_coord.xyz, tex_scale * directional_lights.data[i].soft_shadow_scale); - shadow_color_blend = directional_lights.data[i].shadow_color3.rgb; - } else if (depth_z < directional_lights.data[i].shadow_split_offsets.z) { - vec4 v = vec4(vertex, 1.0); - BIAS_FUNC(v, 3) - pssm_coord = (directional_lights.data[i].shadow_matrix4 * v); - pssm_coord /= pssm_coord.w; - if (directional_lights.data[i].softshadow_angle > 0) { - float range_pos = dot(directional_lights.data[i].direction, v.xyz); - float range_begin = directional_lights.data[i].shadow_range_begin.w; - float test_radius = (range_pos - range_begin) * directional_lights.data[i].softshadow_angle; - vec2 tex_scale = directional_lights.data[i].uv_scale4 * test_radius; - shadow2 = sample_directional_soft_shadow(directional_shadow_atlas, pssm_coord.xyz, tex_scale * directional_lights.data[i].soft_shadow_scale); + if (blend_index == 0) { + shadow = s; } else { - shadow2 = sample_directional_pcf_shadow(directional_shadow_atlas, scene_data.directional_shadow_pixel_size * directional_lights.data[i].soft_shadow_scale, pssm_coord); + //blend + float blend = smoothstep(directional_lights.data[i].shadow_split_offsets.y, directional_lights.data[i].shadow_split_offsets.z, depth_z); + shadow = mix(shadow, s, blend); } - - pssm_blend = smoothstep(directional_lights.data[i].shadow_split_offsets.y, directional_lights.data[i].shadow_split_offsets.z, depth_z); - shadow_color_blend = directional_lights.data[i].shadow_color4.rgb; - } else { - pssm_blend = 0.0; //if no blend, same coord will be used (divide by z will result in same value, and already cached) } - pssm_blend = sqrt(pssm_blend); - - shadow = mix(shadow, shadow2, pssm_blend); - shadow_color = mix(shadow_color, shadow_color_blend, pssm_blend); - } - - shadow = mix(shadow, 1.0, smoothstep(directional_lights.data[i].fade_from, directional_lights.data[i].fade_to, vertex.z)); //done with negative values for performance - #undef BIAS_FUNC - } -#else - // Soft shadow disabled version + } else { //no soft shadows - if (directional_lights.data[i].shadow_enabled) { - float depth_z = -vertex.z; + float depth_z = -vertex.z; - vec4 pssm_coord; - vec3 light_dir = directional_lights.data[i].direction; - vec3 base_normal_bias = normalize(normal_interp) * (1.0 - max(0.0, dot(light_dir, -normalize(normal_interp)))); + vec4 pssm_coord; + vec3 light_dir = directional_lights.data[i].direction; + vec3 base_normal_bias = normalize(normal_interp) * (1.0 - max(0.0, dot(light_dir, -normalize(normal_interp)))); #define BIAS_FUNC(m_var, m_idx) \ m_var.xyz += light_dir * directional_lights.data[i].shadow_bias[m_idx]; \ @@ -1412,70 +1380,70 @@ void main() { normal_bias -= light_dir * dot(light_dir, normal_bias); \ m_var.xyz += normal_bias; - if (depth_z < directional_lights.data[i].shadow_split_offsets.x) { - vec4 v = vec4(vertex, 1.0); - - BIAS_FUNC(v, 0) - - pssm_coord = (directional_lights.data[i].shadow_matrix1 * v); - } else if (depth_z < directional_lights.data[i].shadow_split_offsets.y) { - vec4 v = vec4(vertex, 1.0); - - BIAS_FUNC(v, 1) - - pssm_coord = (directional_lights.data[i].shadow_matrix2 * v); - } else if (depth_z < directional_lights.data[i].shadow_split_offsets.z) { - vec4 v = vec4(vertex, 1.0); - - BIAS_FUNC(v, 2) - - pssm_coord = (directional_lights.data[i].shadow_matrix3 * v); - - } else { - vec4 v = vec4(vertex, 1.0); - - BIAS_FUNC(v, 3) - - pssm_coord = (directional_lights.data[i].shadow_matrix4 * v); - } - - pssm_coord /= pssm_coord.w; - - shadow = sample_directional_pcf_shadow(directional_shadow_atlas, scene_data.directional_shadow_pixel_size * directional_lights.data[i].soft_shadow_scale, pssm_coord); + if (depth_z < directional_lights.data[i].shadow_split_offsets.x) { + vec4 v = vec4(vertex, 1.0); - if (directional_lights.data[i].blend_splits) { - float pssm_blend; + BIAS_FUNC(v, 0) - if (depth_z < directional_lights.data[i].shadow_split_offsets.x) { + pssm_coord = (directional_lights.data[i].shadow_matrix1 * v); + } else if (depth_z < directional_lights.data[i].shadow_split_offsets.y) { vec4 v = vec4(vertex, 1.0); + BIAS_FUNC(v, 1) + pssm_coord = (directional_lights.data[i].shadow_matrix2 * v); - pssm_blend = smoothstep(0.0, directional_lights.data[i].shadow_split_offsets.x, depth_z); - } else if (depth_z < directional_lights.data[i].shadow_split_offsets.y) { + } else if (depth_z < directional_lights.data[i].shadow_split_offsets.z) { vec4 v = vec4(vertex, 1.0); + BIAS_FUNC(v, 2) + pssm_coord = (directional_lights.data[i].shadow_matrix3 * v); - pssm_blend = smoothstep(directional_lights.data[i].shadow_split_offsets.x, directional_lights.data[i].shadow_split_offsets.y, depth_z); - } else if (depth_z < directional_lights.data[i].shadow_split_offsets.z) { + + } else { vec4 v = vec4(vertex, 1.0); + BIAS_FUNC(v, 3) + pssm_coord = (directional_lights.data[i].shadow_matrix4 * v); - pssm_blend = smoothstep(directional_lights.data[i].shadow_split_offsets.y, directional_lights.data[i].shadow_split_offsets.z, depth_z); - } else { - pssm_blend = 0.0; //if no blend, same coord will be used (divide by z will result in same value, and already cached) } pssm_coord /= pssm_coord.w; - float shadow2 = sample_directional_pcf_shadow(directional_shadow_atlas, scene_data.directional_shadow_pixel_size * directional_lights.data[i].soft_shadow_scale, pssm_coord); - shadow = mix(shadow, shadow2, pssm_blend); - } + shadow = sample_directional_pcf_shadow(directional_shadow_atlas, scene_data.directional_shadow_pixel_size * directional_lights.data[i].soft_shadow_scale, pssm_coord); + + if (directional_lights.data[i].blend_splits) { + float pssm_blend; + + if (depth_z < directional_lights.data[i].shadow_split_offsets.x) { + vec4 v = vec4(vertex, 1.0); + BIAS_FUNC(v, 1) + pssm_coord = (directional_lights.data[i].shadow_matrix2 * v); + pssm_blend = smoothstep(0.0, directional_lights.data[i].shadow_split_offsets.x, depth_z); + } else if (depth_z < directional_lights.data[i].shadow_split_offsets.y) { + vec4 v = vec4(vertex, 1.0); + BIAS_FUNC(v, 2) + pssm_coord = (directional_lights.data[i].shadow_matrix3 * v); + pssm_blend = smoothstep(directional_lights.data[i].shadow_split_offsets.x, directional_lights.data[i].shadow_split_offsets.y, depth_z); + } else if (depth_z < directional_lights.data[i].shadow_split_offsets.z) { + vec4 v = vec4(vertex, 1.0); + BIAS_FUNC(v, 3) + pssm_coord = (directional_lights.data[i].shadow_matrix4 * v); + pssm_blend = smoothstep(directional_lights.data[i].shadow_split_offsets.y, directional_lights.data[i].shadow_split_offsets.z, depth_z); + } else { + pssm_blend = 0.0; //if no blend, same coord will be used (divide by z will result in same value, and already cached) + } - shadow = mix(shadow, 1.0, smoothstep(directional_lights.data[i].fade_from, directional_lights.data[i].fade_to, vertex.z)); //done with negative values for performance + pssm_coord /= pssm_coord.w; + + float shadow2 = sample_directional_pcf_shadow(directional_shadow_atlas, scene_data.directional_shadow_pixel_size * directional_lights.data[i].soft_shadow_scale, pssm_coord); + shadow = mix(shadow, shadow2, pssm_blend); + } + + shadow = mix(shadow, 1.0, smoothstep(directional_lights.data[i].fade_from, directional_lights.data[i].fade_to, vertex.z)); //done with negative values for performance #undef BIAS_FUNC - } -#endif + } + } // shadows if (i < 4) { shadow0 |= uint(clamp(shadow * 255.0, 0.0, 255.0)) << (i * 8); @@ -1554,7 +1522,9 @@ void main() { blur_shadow(shadow); - light_compute(normal, directional_lights.data[i].direction, normalize(view), directional_lights.data[i].color * directional_lights.data[i].energy, shadow, f0, orms, 1.0, + float size_A = sc_use_light_soft_shadows ? directional_lights.data[i].size : 0.0; + + light_compute(normal, directional_lights.data[i].direction, normalize(view), size_A, directional_lights.data[i].color * directional_lights.data[i].energy, shadow, f0, orms, 1.0, #ifdef LIGHT_BACKLIGHT_USED backlight, #endif @@ -1573,9 +1543,6 @@ void main() { #ifdef LIGHT_ANISOTROPY_USED binormal, tangent, anisotropy, #endif -#ifdef USE_SOFT_SHADOW - directional_lights.data[i].size, -#endif #ifdef USE_SHADOW_TO_OPACITY alpha, #endif diff --git a/servers/rendering/renderer_rd/shaders/scene_forward_clustered_inc.glsl b/servers/rendering/renderer_rd/shaders/scene_forward_clustered_inc.glsl index 6599a42bab..b53bf6a6d4 100644 --- a/servers/rendering/renderer_rd/shaders/scene_forward_clustered_inc.glsl +++ b/servers/rendering/renderer_rd/shaders/scene_forward_clustered_inc.glsl @@ -52,6 +52,10 @@ layout(set = 0, binding = 1) uniform sampler material_samplers[12]; layout(set = 0, binding = 2) uniform sampler shadow_sampler; +layout(set = 0, binding = 3) uniform sampler decal_sampler; + +layout(set = 0, binding = 4) uniform sampler light_projector_sampler; + #define INSTANCE_FLAGS_NON_UNIFORM_SCALE (1 << 5) #define INSTANCE_FLAGS_USE_GI_BUFFERS (1 << 6) #define INSTANCE_FLAGS_USE_SDFGI (1 << 7) @@ -67,22 +71,22 @@ layout(set = 0, binding = 2) uniform sampler shadow_sampler; //3 bits of stride #define INSTANCE_FLAGS_PARTICLE_TRAIL_MASK 0xFF -layout(set = 0, binding = 3, std430) restrict readonly buffer OmniLights { +layout(set = 0, binding = 5, std430) restrict readonly buffer OmniLights { LightData data[]; } omni_lights; -layout(set = 0, binding = 4, std430) restrict readonly buffer SpotLights { +layout(set = 0, binding = 6, std430) restrict readonly buffer SpotLights { LightData data[]; } spot_lights; -layout(set = 0, binding = 5, std430) restrict readonly buffer ReflectionProbeData { +layout(set = 0, binding = 7, std430) restrict readonly buffer ReflectionProbeData { ReflectionData data[]; } reflections; -layout(set = 0, binding = 6, std140) uniform DirectionalLights { +layout(set = 0, binding = 8, std140) uniform DirectionalLights { DirectionalLightData data[MAX_DIRECTIONAL_LIGHT_DATA_STRUCTS]; } directional_lights; @@ -94,7 +98,7 @@ struct Lightmap { mat3 normal_xform; }; -layout(set = 0, binding = 7, std140) restrict readonly buffer Lightmaps { +layout(set = 0, binding = 9, std140) restrict readonly buffer Lightmaps { Lightmap data[]; } lightmaps; @@ -103,20 +107,20 @@ struct LightmapCapture { vec4 sh[9]; }; -layout(set = 0, binding = 8, std140) restrict readonly buffer LightmapCaptures { +layout(set = 0, binding = 10, std140) restrict readonly buffer LightmapCaptures { LightmapCapture data[]; } lightmap_captures; -layout(set = 0, binding = 9) uniform texture2D decal_atlas; -layout(set = 0, binding = 10) uniform texture2D decal_atlas_srgb; +layout(set = 0, binding = 11) uniform texture2D decal_atlas; +layout(set = 0, binding = 12) uniform texture2D decal_atlas_srgb; -layout(set = 0, binding = 11, std430) restrict readonly buffer Decals { +layout(set = 0, binding = 13, std430) restrict readonly buffer Decals { DecalData data[]; } decals; -layout(set = 0, binding = 12, std430) restrict readonly buffer GlobalVariableData { +layout(set = 0, binding = 14, std430) restrict readonly buffer GlobalVariableData { vec4 data[]; } global_variables; @@ -128,7 +132,7 @@ struct SDFVoxelGICascadeData { float to_cell; // 1/bounds * grid_size }; -layout(set = 0, binding = 13, std140) uniform SDFGI { +layout(set = 0, binding = 15, std140) uniform SDFGI { vec3 grid_size; uint max_cascades; @@ -173,17 +177,12 @@ layout(set = 1, binding = 0, std140) uniform SceneData { uint cluster_type_size; uint max_cluster_element_count_div_32; - //use vec4s because std140 doesnt play nice with vec2s, z and w are wasted + // Use vec4s because std140 doesn't play nice with vec2s, z and w are wasted. vec4 directional_penumbra_shadow_kernel[32]; vec4 directional_soft_shadow_kernel[32]; vec4 penumbra_shadow_kernel[32]; vec4 soft_shadow_kernel[32]; - uint directional_penumbra_shadow_samples; - uint directional_soft_shadow_samples; - uint penumbra_shadow_samples; - uint soft_shadow_samples; - vec4 ambient_light_color_energy; float ambient_color_sky_mix; diff --git a/servers/rendering/renderer_rd/shaders/scene_forward_lights_inc.glsl b/servers/rendering/renderer_rd/shaders/scene_forward_lights_inc.glsl index b6e89acb46..7039ea2942 100644 --- a/servers/rendering/renderer_rd/shaders/scene_forward_lights_inc.glsl +++ b/servers/rendering/renderer_rd/shaders/scene_forward_lights_inc.glsl @@ -73,7 +73,7 @@ vec3 F0(float metallic, float specular, vec3 albedo) { return mix(vec3(dielectric), albedo, vec3(metallic)); } -void light_compute(vec3 N, vec3 L, vec3 V, vec3 light_color, float attenuation, vec3 f0, uint orms, float specular_amount, +void light_compute(vec3 N, vec3 L, vec3 V, float A, vec3 light_color, float attenuation, vec3 f0, uint orms, float specular_amount, #ifdef LIGHT_BACKLIGHT_USED vec3 backlight, #endif @@ -92,9 +92,6 @@ void light_compute(vec3 N, vec3 L, vec3 V, vec3 light_color, float attenuation, #ifdef LIGHT_ANISOTROPY_USED vec3 B, vec3 T, float anisotropy, #endif -#ifdef USE_SOFT_SHADOWS - float A, -#endif #ifdef USE_SHADOW_TO_OPACITY inout float alpha, #endif @@ -111,11 +108,7 @@ void light_compute(vec3 N, vec3 L, vec3 V, vec3 light_color, float attenuation, #else -#ifdef USE_SOFT_SHADOWS float NdotL = min(A + dot(N, L), 1.0); -#else - float NdotL = dot(N, L); -#endif float cNdotL = max(NdotL, 0.0); // clamped NdotL float NdotV = dot(N, V); float cNdotV = max(NdotV, 0.0); @@ -125,19 +118,11 @@ void light_compute(vec3 N, vec3 L, vec3 V, vec3 light_color, float attenuation, #endif #if defined(SPECULAR_BLINN) || defined(SPECULAR_SCHLICK_GGX) || defined(LIGHT_CLEARCOAT_USED) -#ifdef USE_SOFT_SHADOWS float cNdotH = clamp(A + dot(N, H), 0.0, 1.0); -#else - float cNdotH = clamp(dot(N, H), 0.0, 1.0); -#endif #endif #if defined(DIFFUSE_BURLEY) || defined(SPECULAR_SCHLICK_GGX) || defined(LIGHT_CLEARCOAT_USED) -#ifdef USE_SOFT_SHADOWS float cLdotH = clamp(A + dot(L, H), 0.0, 1.0); -#else - float cLdotH = clamp(dot(L, H), 0.0, 1.0); -#endif #endif float metallic = unpackUnorm4x8(orms).z; @@ -232,11 +217,7 @@ void light_compute(vec3 N, vec3 L, vec3 V, vec3 light_color, float attenuation, #elif defined(SPECULAR_PHONG) vec3 R = normalize(-reflect(L, N)); -#ifdef USE_SOFT_SHADOWS float cRdotV = clamp(A + dot(R, V), 0.0, 1.0); -#else - float cRdotV = clamp(dot(R, V), 0.0, 1.0); -#endif float shininess = exp2(15.0 * (1.0 - roughness) + 1.0) * 0.25; float phong = pow(cRdotV, shininess); phong *= (shininess + 8.0) * (1.0 / (8.0 * M_PI)); @@ -320,7 +301,7 @@ float sample_directional_pcf_shadow(texture2D shadow, vec2 shadow_pixel_size, ve float depth = coord.z; //if only one sample is taken, take it from the center - if (scene_data.directional_soft_shadow_samples == 1) { + if (sc_directional_soft_shadow_samples == 1) { return textureProj(sampler2DShadow(shadow, shadow_sampler), vec4(pos, depth, 1.0)); } @@ -334,11 +315,11 @@ float sample_directional_pcf_shadow(texture2D shadow, vec2 shadow_pixel_size, ve float avg = 0.0; - for (uint i = 0; i < scene_data.directional_soft_shadow_samples; i++) { + for (uint i = 0; i < sc_directional_soft_shadow_samples; i++) { avg += textureProj(sampler2DShadow(shadow, shadow_sampler), vec4(pos + shadow_pixel_size * (disk_rotation * scene_data.directional_soft_shadow_kernel[i].xy), depth, 1.0)); } - return avg * (1.0 / float(scene_data.directional_soft_shadow_samples)); + return avg * (1.0 / float(sc_directional_soft_shadow_samples)); } float sample_pcf_shadow(texture2D shadow, vec2 shadow_pixel_size, vec4 coord) { @@ -346,7 +327,7 @@ float sample_pcf_shadow(texture2D shadow, vec2 shadow_pixel_size, vec4 coord) { float depth = coord.z; //if only one sample is taken, take it from the center - if (scene_data.soft_shadow_samples == 1) { + if (sc_soft_shadow_samples == 1) { return textureProj(sampler2DShadow(shadow, shadow_sampler), vec4(pos, depth, 1.0)); } @@ -360,11 +341,11 @@ float sample_pcf_shadow(texture2D shadow, vec2 shadow_pixel_size, vec4 coord) { float avg = 0.0; - for (uint i = 0; i < scene_data.soft_shadow_samples; i++) { + for (uint i = 0; i < sc_soft_shadow_samples; i++) { avg += textureProj(sampler2DShadow(shadow, shadow_sampler), vec4(pos + shadow_pixel_size * (disk_rotation * scene_data.soft_shadow_kernel[i].xy), depth, 1.0)); } - return avg * (1.0 / float(scene_data.soft_shadow_samples)); + return avg * (1.0 / float(sc_soft_shadow_samples)); } float sample_directional_soft_shadow(texture2D shadow, vec3 pssm_coord, vec2 tex_scale) { @@ -380,7 +361,7 @@ float sample_directional_soft_shadow(texture2D shadow, vec3 pssm_coord, vec2 tex disk_rotation = mat2(vec2(cr, -sr), vec2(sr, cr)); } - for (uint i = 0; i < scene_data.directional_penumbra_shadow_samples; i++) { + for (uint i = 0; i < sc_directional_penumbra_shadow_samples; i++) { vec2 suv = pssm_coord.xy + (disk_rotation * scene_data.directional_penumbra_shadow_kernel[i].xy) * tex_scale; float d = textureLod(sampler2D(shadow, material_samplers[SAMPLER_LINEAR_CLAMP]), suv, 0.0).r; if (d < pssm_coord.z) { @@ -396,12 +377,12 @@ float sample_directional_soft_shadow(texture2D shadow, vec3 pssm_coord, vec2 tex tex_scale *= penumbra; float s = 0.0; - for (uint i = 0; i < scene_data.directional_penumbra_shadow_samples; i++) { + for (uint i = 0; i < sc_directional_penumbra_shadow_samples; i++) { vec2 suv = pssm_coord.xy + (disk_rotation * scene_data.directional_penumbra_shadow_kernel[i].xy) * tex_scale; s += textureProj(sampler2DShadow(shadow, shadow_sampler), vec4(suv, pssm_coord.z, 1.0)); } - return s / float(scene_data.directional_penumbra_shadow_samples); + return s / float(sc_directional_penumbra_shadow_samples); } else { //no blockers found, so no shadow @@ -442,8 +423,7 @@ float light_process_omni_shadow(uint idx, vec3 vertex, vec3 normal) { float shadow; -#ifdef USE_SOFT_SHADOWS - if (omni_lights.data[idx].soft_shadow_size > 0.0) { + if (sc_use_light_soft_shadows && omni_lights.data[idx].soft_shadow_size > 0.0) { //soft shadow //find blocker @@ -468,7 +448,7 @@ float light_process_omni_shadow(uint idx, vec3 vertex, vec3 normal) { tangent *= omni_lights.data[idx].soft_shadow_size * omni_lights.data[idx].soft_shadow_scale; bitangent *= omni_lights.data[idx].soft_shadow_size * omni_lights.data[idx].soft_shadow_scale; - for (uint i = 0; i < scene_data.penumbra_shadow_samples; i++) { + for (uint i = 0; i < sc_penumbra_shadow_samples; i++) { vec2 disk = disk_rotation * scene_data.penumbra_shadow_kernel[i].xy; vec3 pos = splane.xyz + tangent * disk.x + bitangent * disk.y; @@ -505,7 +485,7 @@ float light_process_omni_shadow(uint idx, vec3 vertex, vec3 normal) { z_norm -= omni_lights.data[idx].inv_radius * omni_lights.data[idx].shadow_bias; shadow = 0.0; - for (uint i = 0; i < scene_data.penumbra_shadow_samples; i++) { + for (uint i = 0; i < sc_penumbra_shadow_samples; i++) { vec2 disk = disk_rotation * scene_data.penumbra_shadow_kernel[i].xy; vec3 pos = splane.xyz + tangent * disk.x + bitangent * disk.y; @@ -526,14 +506,13 @@ float light_process_omni_shadow(uint idx, vec3 vertex, vec3 normal) { shadow += textureProj(sampler2DShadow(shadow_atlas, shadow_sampler), vec4(pos.xy, z_norm, 1.0)); } - shadow /= float(scene_data.penumbra_shadow_samples); + shadow /= float(sc_penumbra_shadow_samples); } else { //no blockers found, so no shadow shadow = 1.0; } } else { -#endif splane.xyz = normalize(splane.xyz); vec4 clamp_rect = omni_lights.data[idx].atlas_rect; @@ -553,9 +532,7 @@ float light_process_omni_shadow(uint idx, vec3 vertex, vec3 normal) { splane.xy = clamp_rect.xy + splane.xy * clamp_rect.zw; splane.w = 1.0; //needed? i think it should be 1 already shadow = sample_pcf_shadow(shadow_atlas, omni_lights.data[idx].soft_shadow_scale * scene_data.shadow_atlas_pixel_size, splane); -#ifdef USE_SOFT_SHADOWS } -#endif return shadow; } @@ -592,14 +569,12 @@ void light_process_omni(uint idx, vec3 vertex, vec3 eye_vec, vec3 normal, vec3 v float light_attenuation = omni_attenuation; vec3 color = omni_lights.data[idx].color; -#ifdef USE_SOFT_SHADOWS float size_A = 0.0; - if (omni_lights.data[idx].size > 0.0) { + if (sc_use_light_soft_shadows && omni_lights.data[idx].size > 0.0) { float t = omni_lights.data[idx].size / max(0.001, light_length); size_A = max(0.0, 1.0 - 1 / sqrt(1 + t * t)); } -#endif #ifdef LIGHT_TRANSMITTANCE_USED float transmittance_z = transmittance_depth; //no transmittance by default @@ -633,9 +608,7 @@ void light_process_omni(uint idx, vec3 vertex, vec3 eye_vec, vec3 normal, vec3 v } #endif -#if 0 - - if (omni_lights.data[idx].projector_rect != vec4(0.0)) { + if (sc_use_light_projector && omni_lights.data[idx].projector_rect != vec4(0.0)) { vec3 local_v = (omni_lights.data[idx].shadow_matrix * vec4(vertex, 1.0)).xyz; local_v = normalize(local_v); @@ -653,46 +626,50 @@ void light_process_omni(uint idx, vec3 vertex, vec3 eye_vec, vec3 normal, vec3 v local_v.xy = local_v.xy * 0.5 + 0.5; vec2 proj_uv = local_v.xy * atlas_rect.zw; - vec2 proj_uv_ddx; - vec2 proj_uv_ddy; - { - vec3 local_v_ddx = (omni_lights.data[idx].shadow_matrix * vec4(vertex + vertex_ddx, 1.0)).xyz; - local_v_ddx = normalize(local_v_ddx); + if (sc_projector_use_mipmaps) { + vec2 proj_uv_ddx; + vec2 proj_uv_ddy; + { + vec3 local_v_ddx = (omni_lights.data[idx].shadow_matrix * vec4(vertex + vertex_ddx, 1.0)).xyz; + local_v_ddx = normalize(local_v_ddx); - if (local_v_ddx.z >= 0.0) { - local_v_ddx.z += 1.0; - } else { - local_v_ddx.z = 1.0 - local_v_ddx.z; - } + if (local_v_ddx.z >= 0.0) { + local_v_ddx.z += 1.0; + } else { + local_v_ddx.z = 1.0 - local_v_ddx.z; + } - local_v_ddx.xy /= local_v_ddx.z; - local_v_ddx.xy = local_v_ddx.xy * 0.5 + 0.5; + local_v_ddx.xy /= local_v_ddx.z; + local_v_ddx.xy = local_v_ddx.xy * 0.5 + 0.5; - proj_uv_ddx = local_v_ddx.xy * atlas_rect.zw - proj_uv; + proj_uv_ddx = local_v_ddx.xy * atlas_rect.zw - proj_uv; - vec3 local_v_ddy = (omni_lights.data[idx].shadow_matrix * vec4(vertex + vertex_ddy, 1.0)).xyz; - local_v_ddy = normalize(local_v_ddy); + vec3 local_v_ddy = (omni_lights.data[idx].shadow_matrix * vec4(vertex + vertex_ddy, 1.0)).xyz; + local_v_ddy = normalize(local_v_ddy); - if (local_v_ddy.z >= 0.0) { - local_v_ddy.z += 1.0; - } else { - local_v_ddy.z = 1.0 - local_v_ddy.z; - } + if (local_v_ddy.z >= 0.0) { + local_v_ddy.z += 1.0; + } else { + local_v_ddy.z = 1.0 - local_v_ddy.z; + } - local_v_ddy.xy /= local_v_ddy.z; - local_v_ddy.xy = local_v_ddy.xy * 0.5 + 0.5; + local_v_ddy.xy /= local_v_ddy.z; + local_v_ddy.xy = local_v_ddy.xy * 0.5 + 0.5; - proj_uv_ddy = local_v_ddy.xy * atlas_rect.zw - proj_uv; - } + proj_uv_ddy = local_v_ddy.xy * atlas_rect.zw - proj_uv; + } - vec4 proj = textureGrad(sampler2D(decal_atlas_srgb, material_samplers[SAMPLER_LINEAR_WITH_MIPMAPS_CLAMP]), proj_uv + atlas_rect.xy, proj_uv_ddx, proj_uv_ddy); - no_shadow = mix(no_shadow, proj.rgb, proj.a); + vec4 proj = textureGrad(sampler2D(decal_atlas_srgb, light_projector_sampler), proj_uv + atlas_rect.xy, proj_uv_ddx, proj_uv_ddy); + color *= proj.rgb * proj.a; + } else { + vec4 proj = textureLod(sampler2D(decal_atlas_srgb, light_projector_sampler), proj_uv + atlas_rect.xy, 0.0); + color *= proj.rgb * proj.a; + } } -#endif light_attenuation *= shadow; - light_compute(normal, normalize(light_rel_vec), eye_vec, color, light_attenuation, f0, orms, omni_lights.data[idx].specular_amount, + light_compute(normal, normalize(light_rel_vec), eye_vec, size_A, color, light_attenuation, f0, orms, omni_lights.data[idx].specular_amount, #ifdef LIGHT_BACKLIGHT_USED backlight, #endif @@ -711,9 +688,6 @@ void light_process_omni(uint idx, vec3 vertex, vec3 eye_vec, vec3 normal, vec3 v #ifdef LIGHT_ANISOTROPY_USED binormal, tangent, anisotropy, #endif -#ifdef USE_SOFT_SHADOWS - size_A, -#endif #ifdef USE_SHADOW_TO_OPACITY alpha, #endif @@ -747,8 +721,7 @@ float light_process_spot_shadow(uint idx, vec3 vertex, vec3 normal) { vec4 splane = (spot_lights.data[idx].shadow_matrix * v); splane /= splane.w; -#ifdef USE_SOFT_SHADOWS - if (spot_lights.data[idx].soft_shadow_size > 0.0) { + if (sc_use_light_soft_shadows && spot_lights.data[idx].soft_shadow_size > 0.0) { //soft shadow //find blocker @@ -768,11 +741,11 @@ float light_process_spot_shadow(uint idx, vec3 vertex, vec3 normal) { float uv_size = spot_lights.data[idx].soft_shadow_size * z_norm * spot_lights.data[idx].soft_shadow_scale; vec2 clamp_max = spot_lights.data[idx].atlas_rect.xy + spot_lights.data[idx].atlas_rect.zw; - for (uint i = 0; i < scene_data.penumbra_shadow_samples; i++) { + for (uint i = 0; i < sc_penumbra_shadow_samples; i++) { vec2 suv = shadow_uv + (disk_rotation * scene_data.penumbra_shadow_kernel[i].xy) * uv_size; suv = clamp(suv, spot_lights.data[idx].atlas_rect.xy, clamp_max); float d = textureLod(sampler2D(shadow_atlas, material_samplers[SAMPLER_LINEAR_CLAMP]), suv, 0.0).r; - if (d < z_norm) { + if (d < splane.z) { blocker_average += d; blocker_count += 1.0; } @@ -785,13 +758,13 @@ float light_process_spot_shadow(uint idx, vec3 vertex, vec3 normal) { uv_size *= penumbra; shadow = 0.0; - for (uint i = 0; i < scene_data.penumbra_shadow_samples; i++) { + for (uint i = 0; i < sc_penumbra_shadow_samples; i++) { vec2 suv = shadow_uv + (disk_rotation * scene_data.penumbra_shadow_kernel[i].xy) * uv_size; suv = clamp(suv, spot_lights.data[idx].atlas_rect.xy, clamp_max); - shadow += textureProj(sampler2DShadow(shadow_atlas, shadow_sampler), vec4(suv, z_norm, 1.0)); + shadow += textureProj(sampler2DShadow(shadow_atlas, shadow_sampler), vec4(suv, splane.z, 1.0)); } - shadow /= float(scene_data.penumbra_shadow_samples); + shadow /= float(sc_penumbra_shadow_samples); } else { //no blockers found, so no shadow @@ -799,14 +772,11 @@ float light_process_spot_shadow(uint idx, vec3 vertex, vec3 normal) { } } else { -#endif //hard shadow vec4 shadow_uv = vec4(splane.xy * spot_lights.data[idx].atlas_rect.zw + spot_lights.data[idx].atlas_rect.xy, splane.z, 1.0); shadow = sample_pcf_shadow(shadow_atlas, spot_lights.data[idx].soft_shadow_scale * scene_data.shadow_atlas_pixel_size, shadow_uv); -#ifdef USE_SOFT_SHADOWS } -#endif return shadow; } @@ -816,6 +786,18 @@ float light_process_spot_shadow(uint idx, vec3 vertex, vec3 normal) { return 1.0; } +vec2 normal_to_panorama(vec3 n) { + n = normalize(n); + vec2 panorama_coords = vec2(atan(n.x, n.z), acos(-n.y)); + + if (panorama_coords.x < 0.0) { + panorama_coords.x += M_PI * 2.0; + } + + panorama_coords /= vec2(M_PI * 2.0, M_PI); + return panorama_coords; +} + void light_process_spot(uint idx, vec3 vertex, vec3 eye_vec, vec3 normal, vec3 vertex_ddx, vec3 vertex_ddy, vec3 f0, uint orms, float shadow, #ifdef LIGHT_BACKLIGHT_USED vec3 backlight, @@ -850,20 +832,12 @@ void light_process_spot(uint idx, vec3 vertex, vec3 eye_vec, vec3 normal, vec3 v vec3 color = spot_lights.data[idx].color; float specular_amount = spot_lights.data[idx].specular_amount; -#ifdef USE_SOFT_SHADOWS float size_A = 0.0; - if (spot_lights.data[idx].size > 0.0) { + if (sc_use_light_soft_shadows && spot_lights.data[idx].size > 0.0) { float t = spot_lights.data[idx].size / max(0.001, light_length); size_A = max(0.0, 1.0 - 1 / sqrt(1 + t * t)); } -#endif - - /* - if (spot_lights.data[idx].atlas_rect!=vec4(0.0)) { - //use projector texture - } - */ #ifdef LIGHT_TRANSMITTANCE_USED float transmittance_z = transmittance_depth; @@ -886,9 +860,32 @@ void light_process_spot(uint idx, vec3 vertex, vec3 eye_vec, vec3 normal, vec3 v } #endif //LIGHT_TRANSMITTANCE_USED + if (sc_use_light_projector && spot_lights.data[idx].projector_rect != vec4(0.0)) { + vec4 splane = (spot_lights.data[idx].shadow_matrix * vec4(vertex, 1.0)); + splane /= splane.w; + + vec2 proj_uv = normal_to_panorama(splane.xyz) * spot_lights.data[idx].projector_rect.zw; + + if (sc_projector_use_mipmaps) { + //ensure we have proper mipmaps + vec4 splane_ddx = (spot_lights.data[idx].shadow_matrix * vec4(vertex + vertex_ddx, 1.0)); + splane_ddx /= splane_ddx.w; + vec2 proj_uv_ddx = normal_to_panorama(splane_ddx.xyz) * spot_lights.data[idx].projector_rect.zw - proj_uv; + + vec4 splane_ddy = (spot_lights.data[idx].shadow_matrix * vec4(vertex + vertex_ddy, 1.0)); + splane_ddy /= splane_ddy.w; + vec2 proj_uv_ddy = normal_to_panorama(splane_ddy.xyz) * spot_lights.data[idx].projector_rect.zw - proj_uv; + + vec4 proj = textureGrad(sampler2D(decal_atlas_srgb, light_projector_sampler), proj_uv + spot_lights.data[idx].projector_rect.xy, proj_uv_ddx, proj_uv_ddy); + color *= proj.rgb * proj.a; + } else { + vec4 proj = textureLod(sampler2D(decal_atlas_srgb, light_projector_sampler), proj_uv + spot_lights.data[idx].projector_rect.xy, 0.0); + color *= proj.rgb * proj.a; + } + } light_attenuation *= shadow; - light_compute(normal, normalize(light_rel_vec), eye_vec, color, light_attenuation, f0, orms, spot_lights.data[idx].specular_amount, + light_compute(normal, normalize(light_rel_vec), eye_vec, size_A, color, light_attenuation, f0, orms, spot_lights.data[idx].specular_amount, #ifdef LIGHT_BACKLIGHT_USED backlight, #endif @@ -907,9 +904,6 @@ void light_process_spot(uint idx, vec3 vertex, vec3 eye_vec, vec3 normal, vec3 v #ifdef LIGHT_ANISOTROPY_USED binormal, tangent, anisotropy, #endif -#ifdef USE_SOFT_SHADOW - size_A, -#endif #ifdef USE_SHADOW_TO_OPACITY alpha, #endif diff --git a/servers/rendering/renderer_rd/shaders/scene_forward_mobile.glsl b/servers/rendering/renderer_rd/shaders/scene_forward_mobile.glsl index 1bc17e140f..70900a847c 100644 --- a/servers/rendering/renderer_rd/shaders/scene_forward_mobile.glsl +++ b/servers/rendering/renderer_rd/shaders/scene_forward_mobile.glsl @@ -370,6 +370,26 @@ void main() { #VERSION_DEFINES +/* Specialization Constants */ + +/* Specialization Constants (Toggles) */ + +layout(constant_id = 0) const bool sc_use_forward_gi = false; +layout(constant_id = 1) const bool sc_use_light_projector = false; +layout(constant_id = 2) const bool sc_use_light_soft_shadows = false; +layout(constant_id = 3) const bool sc_use_directional_soft_shadows = false; + +/* Specialization Constants (Values) */ + +layout(constant_id = 6) const uint sc_soft_shadow_samples = 4; +layout(constant_id = 7) const uint sc_penumbra_shadow_samples = 4; + +layout(constant_id = 8) const uint sc_directional_soft_shadow_samples = 4; +layout(constant_id = 9) const uint sc_directional_penumbra_shadow_samples = 4; + +layout(constant_id = 10) const bool sc_decal_use_mipmaps = true; +layout(constant_id = 11) const bool sc_projector_use_mipmaps = true; + /* Include our forward mobile UBOs definitions etc. */ #include "scene_forward_mobile_inc.glsl" @@ -961,7 +981,7 @@ void main() { specular_light *= specular * metallic * albedo * 2.0; #else - // scales the specular reflections, needs to be be computed before lighting happens, + // scales the specular reflections, needs to be computed before lighting happens, // but after environment, GI, and reflection probes are added // Environment brdf approximation (Lazarov 2013) // see https://www.unrealengine.com/en-US/blog/physically-based-shading-on-mobile @@ -1284,7 +1304,7 @@ void main() { blur_shadow(shadow); - light_compute(normal, directional_lights.data[i].direction, normalize(view), directional_lights.data[i].color * directional_lights.data[i].energy, shadow, f0, orms, 1.0, + light_compute(normal, directional_lights.data[i].direction, normalize(view), 0.0, directional_lights.data[i].color * directional_lights.data[i].energy, shadow, f0, orms, 1.0, #ifdef LIGHT_BACKLIGHT_USED backlight, #endif diff --git a/servers/rendering/renderer_rd/shaders/scene_forward_mobile_inc.glsl b/servers/rendering/renderer_rd/shaders/scene_forward_mobile_inc.glsl index d4ebcbeec4..d9682d7b23 100644 --- a/servers/rendering/renderer_rd/shaders/scene_forward_mobile_inc.glsl +++ b/servers/rendering/renderer_rd/shaders/scene_forward_mobile_inc.glsl @@ -51,6 +51,9 @@ layout(set = 0, binding = 1) uniform sampler material_samplers[12]; layout(set = 0, binding = 2) uniform sampler shadow_sampler; +layout(set = 0, binding = 3) uniform sampler decal_sampler; +layout(set = 0, binding = 4) uniform sampler light_projector_sampler; + #define INSTANCE_FLAGS_NON_UNIFORM_SCALE (1 << 5) #define INSTANCE_FLAGS_USE_GI_BUFFERS (1 << 6) #define INSTANCE_FLAGS_USE_SDFGI (1 << 7) @@ -66,22 +69,22 @@ layout(set = 0, binding = 2) uniform sampler shadow_sampler; //3 bits of stride #define INSTANCE_FLAGS_PARTICLE_TRAIL_MASK 0xFF -layout(set = 0, binding = 3, std430) restrict readonly buffer OmniLights { +layout(set = 0, binding = 5, std430) restrict readonly buffer OmniLights { LightData data[]; } omni_lights; -layout(set = 0, binding = 4, std430) restrict readonly buffer SpotLights { +layout(set = 0, binding = 6, std430) restrict readonly buffer SpotLights { LightData data[]; } spot_lights; -layout(set = 0, binding = 5, std430) restrict readonly buffer ReflectionProbeData { +layout(set = 0, binding = 7, std430) restrict readonly buffer ReflectionProbeData { ReflectionData data[]; } reflections; -layout(set = 0, binding = 6, std140) uniform DirectionalLights { +layout(set = 0, binding = 8, std140) uniform DirectionalLights { DirectionalLightData data[MAX_DIRECTIONAL_LIGHT_DATA_STRUCTS]; } directional_lights; @@ -93,7 +96,7 @@ struct Lightmap { mat3 normal_xform; }; -layout(set = 0, binding = 7, std140) restrict readonly buffer Lightmaps { +layout(set = 0, binding = 9, std140) restrict readonly buffer Lightmaps { Lightmap data[]; } lightmaps; @@ -102,20 +105,20 @@ struct LightmapCapture { vec4 sh[9]; }; -layout(set = 0, binding = 8, std140) restrict readonly buffer LightmapCaptures { +layout(set = 0, binding = 10, std140) restrict readonly buffer LightmapCaptures { LightmapCapture data[]; } lightmap_captures; -layout(set = 0, binding = 9) uniform texture2D decal_atlas; -layout(set = 0, binding = 10) uniform texture2D decal_atlas_srgb; +layout(set = 0, binding = 11) uniform texture2D decal_atlas; +layout(set = 0, binding = 12) uniform texture2D decal_atlas_srgb; -layout(set = 0, binding = 11, std430) restrict readonly buffer Decals { +layout(set = 0, binding = 13, std430) restrict readonly buffer Decals { DecalData data[]; } decals; -layout(set = 0, binding = 12, std430) restrict readonly buffer GlobalVariableData { +layout(set = 0, binding = 14, std430) restrict readonly buffer GlobalVariableData { vec4 data[]; } global_variables; @@ -135,17 +138,12 @@ layout(set = 1, binding = 0, std140) uniform SceneData { vec2 viewport_size; vec2 screen_pixel_size; - //use vec4s because std140 doesnt play nice with vec2s, z and w are wasted + // Use vec4s because std140 doesn't play nice with vec2s, z and w are wasted. vec4 directional_penumbra_shadow_kernel[32]; vec4 directional_soft_shadow_kernel[32]; vec4 penumbra_shadow_kernel[32]; vec4 soft_shadow_kernel[32]; - uint directional_penumbra_shadow_samples; - uint directional_soft_shadow_samples; - uint penumbra_shadow_samples; - uint soft_shadow_samples; - vec4 ambient_light_color_energy; float ambient_color_sky_mix; diff --git a/servers/rendering/renderer_rd/shaders/sdfgi_direct_light.glsl b/servers/rendering/renderer_rd/shaders/sdfgi_direct_light.glsl index 99db35bb34..d6e5c6a92e 100644 --- a/servers/rendering/renderer_rd/shaders/sdfgi_direct_light.glsl +++ b/servers/rendering/renderer_rd/shaders/sdfgi_direct_light.glsl @@ -20,10 +20,10 @@ layout(set = 0, binding = 3, std430) restrict readonly buffer DispatchData { dispatch_data; struct ProcessVoxel { - uint position; //xyz 7 bit packed, extra 11 bits for neigbours - uint albedo; //rgb bits 0-15 albedo, bits 16-21 are normal bits (set if geometry exists toward that side), extra 11 bits for neibhbours - uint light; //rgbe8985 encoded total saved light, extra 2 bits for neighbours - uint light_aniso; //55555 light anisotropy, extra 2 bits for neighbours + uint position; // xyz 7 bit packed, extra 11 bits for neighbors. + uint albedo; // rgb bits 0-15 albedo, bits 16-21 are normal bits (set if geometry exists toward that side), extra 11 bits for neighbors. + uint light; // rgbe8985 encoded total saved light, extra 2 bits for neighbors. + uint light_aniso; // 55555 light anisotropy, extra 2 bits for neighbors. //total neighbours: 26 }; diff --git a/servers/rendering/renderer_rd/shaders/sdfgi_integrate.glsl b/servers/rendering/renderer_rd/shaders/sdfgi_integrate.glsl index bc376e9522..eedd28959c 100644 --- a/servers/rendering/renderer_rd/shaders/sdfgi_integrate.glsl +++ b/servers/rendering/renderer_rd/shaders/sdfgi_integrate.glsl @@ -266,9 +266,9 @@ void main() { } else if (params.sky_mode == SKY_MODE_SKY) { #ifdef USE_CUBEMAP_ARRAY - light.rgb = textureLod(samplerCubeArray(sky_irradiance, linear_sampler_mipmaps), vec4(ray_dir, 0.0), 2.0).rgb; //use second mipmap because we dont usually throw a lot of rays, so this compensates + light.rgb = textureLod(samplerCubeArray(sky_irradiance, linear_sampler_mipmaps), vec4(ray_dir, 0.0), 2.0).rgb; // Use second mipmap because we don't usually throw a lot of rays, so this compensates. #else - light.rgb = textureLod(samplerCube(sky_irradiance, linear_sampler_mipmaps), ray_dir, 2.0).rgb; //use second mipmap because we dont usually throw a lot of rays, so this compensates + light.rgb = textureLod(samplerCube(sky_irradiance, linear_sampler_mipmaps), ray_dir, 2.0).rgb; // Use second mipmap because we don't usually throw a lot of rays, so this compensates. #endif light.rgb *= params.sky_energy; light.a = 0.0; diff --git a/servers/rendering/renderer_rd/shaders/sdfgi_preprocess.glsl b/servers/rendering/renderer_rd/shaders/sdfgi_preprocess.glsl index aa4ded146f..4d9fa85a74 100644 --- a/servers/rendering/renderer_rd/shaders/sdfgi_preprocess.glsl +++ b/servers/rendering/renderer_rd/shaders/sdfgi_preprocess.glsl @@ -101,7 +101,7 @@ layout(set = 0, binding = 10, std430) restrict buffer DispatchData { dispatch_data; struct ProcessVoxel { - uint position; //xyz 7 bit packed, extra 11 bits for neigbours + uint position; // xyz 7 bit packed, extra 11 bits for neighbors. uint albedo; //rgb bits 0-15 albedo, bits 16-21 are normal bits (set if geometry exists toward that side), extra 11 bits for neibhbours uint light; //rgbe8985 encoded total saved light, extra 2 bits for neighbours uint light_aniso; //55555 light anisotropy, extra 2 bits for neighbours @@ -134,7 +134,7 @@ layout(set = 0, binding = 5, std430) restrict buffer readonly DispatchData { dispatch_data; struct ProcessVoxel { - uint position; //xyz 7 bit packed, extra 11 bits for neigbours + uint position; // xyz 7 bit packed, extra 11 bits for neighbors. uint albedo; //rgb bits 0-15 albedo, bits 16-21 are normal bits (set if geometry exists toward that side), extra 11 bits for neibhbours uint light; //rgbe8985 encoded total saved light, extra 2 bits for neighbours uint light_aniso; //55555 light anisotropy, extra 2 bits for neighbours @@ -183,7 +183,7 @@ void main() { ivec3 write_pos = read_pos + params.scroll; if (any(lessThan(write_pos, ivec3(0))) || any(greaterThanEqual(write_pos, ivec3(params.grid_size)))) { - return; //fits outside the 3D texture, dont do anything + return; // Fits outside the 3D texture, don't do anything. } uint albedo = ((src_process_voxels.data[index].albedo & 0x7FFF) << 1) | 1; //add solid bit diff --git a/servers/rendering/renderer_scene.h b/servers/rendering/renderer_scene.h index 8273e53d46..972637d183 100644 --- a/servers/rendering/renderer_scene.h +++ b/servers/rendering/renderer_scene.h @@ -212,6 +212,9 @@ public: virtual void render_probes() = 0; virtual void update_visibility_notifiers() = 0; + virtual void decals_set_filter(RS::DecalFilter p_filter) = 0; + virtual void light_projectors_set_filter(RS::LightProjectorFilter p_filter) = 0; + virtual bool free(RID p_rid) = 0; RendererScene(); diff --git a/servers/rendering/renderer_scene_cull.cpp b/servers/rendering/renderer_scene_cull.cpp index 271c039aad..83d1b33bf2 100644 --- a/servers/rendering/renderer_scene_cull.cpp +++ b/servers/rendering/renderer_scene_cull.cpp @@ -151,6 +151,22 @@ void RendererSceneCull::_instance_pair(Instance *p_A, Instance *p_B) { idata.flags |= InstanceData::FLAG_GEOM_LIGHTING_DIRTY; } + if (light->uses_projector) { + geom->projector_count++; + if (geom->projector_count == 1) { + InstanceData &idata = A->scenario->instance_data[A->array_index]; + idata.flags |= InstanceData::FLAG_GEOM_PROJECTOR_SOFTSHADOW_DIRTY; + } + } + + if (light->uses_softshadow) { + geom->softshadow_count++; + if (geom->softshadow_count == 1) { + InstanceData &idata = A->scenario->instance_data[A->array_index]; + idata.flags |= InstanceData::FLAG_GEOM_PROJECTOR_SOFTSHADOW_DIRTY; + } + } + } else if (self->geometry_instance_pair_mask & (1 << RS::INSTANCE_REFLECTION_PROBE) && B->base_type == RS::INSTANCE_REFLECTION_PROBE && ((1 << A->base_type) & RS::INSTANCE_GEOMETRY_MASK)) { InstanceReflectionProbeData *reflection_probe = static_cast<InstanceReflectionProbeData *>(B->base_data); InstanceGeometryData *geom = static_cast<InstanceGeometryData *>(A->base_data); @@ -242,6 +258,32 @@ void RendererSceneCull::_instance_unpair(Instance *p_A, Instance *p_B) { idata.flags |= InstanceData::FLAG_GEOM_LIGHTING_DIRTY; } + if (light->uses_projector) { +#ifdef DEBUG_ENABLED + if (geom->projector_count == 0) { + ERR_PRINT("geom->projector_count==0 - BUG!"); + } +#endif + geom->projector_count--; + if (geom->projector_count == 0) { + InstanceData &idata = A->scenario->instance_data[A->array_index]; + idata.flags |= InstanceData::FLAG_GEOM_PROJECTOR_SOFTSHADOW_DIRTY; + } + } + + if (light->uses_softshadow) { +#ifdef DEBUG_ENABLED + if (geom->softshadow_count == 0) { + ERR_PRINT("geom->softshadow_count==0 - BUG!"); + } +#endif + geom->softshadow_count--; + if (geom->softshadow_count == 0) { + InstanceData &idata = A->scenario->instance_data[A->array_index]; + idata.flags |= InstanceData::FLAG_GEOM_PROJECTOR_SOFTSHADOW_DIRTY; + } + } + } else if (self->geometry_instance_pair_mask & (1 << RS::INSTANCE_REFLECTION_PROBE) && B->base_type == RS::INSTANCE_REFLECTION_PROBE && ((1 << A->base_type) & RS::INSTANCE_GEOMETRY_MASK)) { InstanceReflectionProbeData *reflection_probe = static_cast<InstanceReflectionProbeData *>(B->base_data); InstanceGeometryData *geom = static_cast<InstanceGeometryData *>(A->base_data); @@ -1217,7 +1259,7 @@ void RendererSceneCull::_update_instance_visibility_depth(Instance *p_instance) } if (cycle_detected) { - ERR_PRINT("Cycle detected in the visibility dependecies tree."); + ERR_PRINT("Cycle detected in the visibility dependencies tree."); for (Set<Instance *>::Element *E = traversed_nodes.front(); E; E = E->next()) { Instance *instance = E->get(); InstanceGeometryData *geom = static_cast<InstanceGeometryData *>(instance->base_data); @@ -1532,7 +1574,11 @@ void RendererSceneCull::_update_instance(Instance *p_instance) { } } break; case RS::INSTANCE_LIGHT: { - idata.instance_data_rid = static_cast<InstanceLightData *>(p_instance->base_data)->instance.get_id(); + InstanceLightData *light_data = static_cast<InstanceLightData *>(p_instance->base_data); + idata.instance_data_rid = light_data->instance.get_id(); + light_data->uses_projector = RSG::storage->light_has_projector(p_instance->base); + light_data->uses_softshadow = RSG::storage->light_get_param(p_instance->base, RS::LIGHT_PARAM_SIZE) > CMP_EPSILON; + } break; case RS::INSTANCE_REFLECTION_PROBE: { idata.instance_data_rid = static_cast<InstanceReflectionProbeData *>(p_instance->base_data)->instance.get_id(); @@ -2646,6 +2692,13 @@ void RendererSceneCull::_scene_cull(CullData &cull_data, InstanceCullResult &cul idata.flags &= ~uint32_t(InstanceData::FLAG_GEOM_LIGHTING_DIRTY); } + if (idata.flags & InstanceData::FLAG_GEOM_PROJECTOR_SOFTSHADOW_DIRTY) { + InstanceGeometryData *geom = static_cast<InstanceGeometryData *>(idata.instance->base_data); + + scene_render->geometry_instance_set_softshadow_projector_pairing(geom->geometry_instance, geom->softshadow_count > 0, geom->projector_count > 0); + idata.flags &= ~uint32_t(InstanceData::FLAG_GEOM_PROJECTOR_SOFTSHADOW_DIRTY); + } + if (geometry_instance_pair_mask & (1 << RS::INSTANCE_REFLECTION_PROBE) && (idata.flags & InstanceData::FLAG_GEOM_REFLECTION_DIRTY)) { InstanceGeometryData *geom = static_cast<InstanceGeometryData *>(idata.instance->base_data); uint32_t idx = 0; @@ -2823,8 +2876,8 @@ void RendererSceneCull::_render_scene(const RendererSceneRender::CameraData *p_c Vector<Instance *> lights_with_shadow; - for (List<Instance *>::Element *E = scenario->directional_lights.front(); E; E = E->next()) { - if (!E->get()->visible) { + for (Instance *E : scenario->directional_lights) { + if (!E->visible) { continue; } @@ -2832,13 +2885,13 @@ void RendererSceneCull::_render_scene(const RendererSceneRender::CameraData *p_c break; } - InstanceLightData *light = static_cast<InstanceLightData *>(E->get()->base_data); + InstanceLightData *light = static_cast<InstanceLightData *>(E->base_data); //check shadow.. if (light) { - if (p_using_shadows && p_shadow_atlas.is_valid() && RSG::storage->light_has_shadow(E->get()->base) && !(RSG::storage->light_get_type(E->get()->base) == RS::LIGHT_DIRECTIONAL && RSG::storage->light_directional_is_sky_only(E->get()->base))) { - lights_with_shadow.push_back(E->get()); + if (p_using_shadows && p_shadow_atlas.is_valid() && RSG::storage->light_has_shadow(E->base) && !(RSG::storage->light_get_type(E->base) == RS::LIGHT_DIRECTIONAL && RSG::storage->light_directional_is_sky_only(E->base))) { + lights_with_shadow.push_back(E); } //add to list directional_lights.push_back(light->instance); @@ -3338,8 +3391,7 @@ void RendererSceneCull::render_probes() { idx++; } - for (List<Instance *>::Element *E = probe->owner->scenario->directional_lights.front(); E; E = E->next()) { - Instance *instance = E->get(); + for (const Instance *instance : probe->owner->scenario->directional_lights) { InstanceLightData *instance_light = (InstanceLightData *)instance->base_data; if (!instance->visible) { continue; @@ -3412,8 +3464,7 @@ void RendererSceneCull::render_probes() { idx++; } - for (List<Instance *>::Element *E = probe->owner->scenario->directional_lights.front(); E; E = E->next()) { - Instance *instance = E->get(); + for (const Instance *instance : probe->owner->scenario->directional_lights) { InstanceLightData *instance_light = (InstanceLightData *)instance->base_data; if (!instance->visible) { continue; @@ -3520,26 +3571,26 @@ void RendererSceneCull::render_particle_colliders() { void RendererSceneCull::_update_instance_shader_parameters_from_material(Map<StringName, Instance::InstanceShaderParameter> &isparams, const Map<StringName, Instance::InstanceShaderParameter> &existing_isparams, RID p_material) { List<RendererStorage::InstanceShaderParam> plist; RSG::storage->material_get_instance_shader_parameters(p_material, &plist); - for (List<RendererStorage::InstanceShaderParam>::Element *E = plist.front(); E; E = E->next()) { - StringName name = E->get().info.name; + for (const RendererStorage::InstanceShaderParam &E : plist) { + StringName name = E.info.name; if (isparams.has(name)) { - if (isparams[name].info.type != E->get().info.type) { - WARN_PRINT("More than one material in instance export the same instance shader uniform '" + E->get().info.name + "', but they do it with different data types. Only the first one (in order) will display correctly."); + if (isparams[name].info.type != E.info.type) { + WARN_PRINT("More than one material in instance export the same instance shader uniform '" + E.info.name + "', but they do it with different data types. Only the first one (in order) will display correctly."); } - if (isparams[name].index != E->get().index) { - WARN_PRINT("More than one material in instance export the same instance shader uniform '" + E->get().info.name + "', but they do it with different indices. Only the first one (in order) will display correctly."); + if (isparams[name].index != E.index) { + WARN_PRINT("More than one material in instance export the same instance shader uniform '" + E.info.name + "', but they do it with different indices. Only the first one (in order) will display correctly."); } continue; //first one found always has priority } Instance::InstanceShaderParameter isp; - isp.index = E->get().index; - isp.info = E->get().info; - isp.default_value = E->get().default_value; + isp.index = E.index; + isp.info = E.info; + isp.default_value = E.default_value; if (existing_isparams.has(name)) { isp.value = existing_isparams[name].value; } else { - isp.value = E->get().default_value; + isp.value = E.default_value; } isparams[name] = isp; } diff --git a/servers/rendering/renderer_scene_cull.h b/servers/rendering/renderer_scene_cull.h index d586fb531f..96fe6ce25c 100644 --- a/servers/rendering/renderer_scene_cull.h +++ b/servers/rendering/renderer_scene_cull.h @@ -267,6 +267,7 @@ public: FLAG_VISIBILITY_DEPENDENCY_NEEDS_CHECK = (3 << 20), // 2 bits, overlaps with the other vis. dependency flags FLAG_VISIBILITY_DEPENDENCY_HIDDEN_CLOSE_RANGE = (1 << 20), FLAG_VISIBILITY_DEPENDENCY_HIDDEN = (1 << 21), + FLAG_GEOM_PROJECTOR_SOFTSHADOW_DIRTY = (1 << 22), }; uint32_t flags = 0; @@ -489,6 +490,14 @@ public: case RendererStorage::DEPENDENCY_CHANGED_SKELETON_BONES: { //ignored } break; + case RendererStorage::DEPENDENCY_CHANGED_LIGHT_SOFT_SHADOW_AND_PROJECTOR: { + //requires repairing + if (instance->indexer_id.is_valid()) { + singleton->_unpair_instance(instance); + singleton->_instance_queue_update(instance, true, true); + } + + } break; } } @@ -567,6 +576,8 @@ public: Set<Instance *> lights; bool can_cast_shadows; bool material_is_animated; + uint32_t projector_count = 0; + uint32_t softshadow_count = 0; Set<Instance *> decals; Set<Instance *> reflection_probes; @@ -631,6 +642,8 @@ public: List<Instance *>::Element *D; // directional light in scenario bool shadow_dirty; + bool uses_projector = false; + bool uses_softshadow = false; Set<Instance *> geometries; @@ -1130,6 +1143,9 @@ public: PASS1(set_debug_draw_mode, RS::ViewportDebugDraw) + PASS1(decals_set_filter, RS::DecalFilter) + PASS1(light_projectors_set_filter, RS::LightProjectorFilter) + virtual void update(); bool free(RID p_rid); diff --git a/servers/rendering/renderer_scene_render.h b/servers/rendering/renderer_scene_render.h index ff0fea16d0..2000afa0d3 100644 --- a/servers/rendering/renderer_scene_render.h +++ b/servers/rendering/renderer_scene_render.h @@ -69,6 +69,8 @@ public: virtual void geometry_instance_pair_decal_instances(GeometryInstance *p_geometry_instance, const RID *p_decal_instances, uint32_t p_decal_instance_count) = 0; virtual void geometry_instance_pair_voxel_gi_instances(GeometryInstance *p_geometry_instance, const RID *p_voxel_gi_instances, uint32_t p_voxel_gi_instance_count) = 0; + virtual void geometry_instance_set_softshadow_projector_pairing(GeometryInstance *p_geometry_instance, bool p_softshadow, bool p_projector) = 0; + virtual void geometry_instance_free(GeometryInstance *p_geometry_instance) = 0; /* SHADOW ATLAS API */ @@ -260,6 +262,9 @@ public: virtual void sdfgi_set_debug_probe_select(const Vector3 &p_position, const Vector3 &p_dir) = 0; + virtual void decals_set_filter(RS::DecalFilter p_filter) = 0; + virtual void light_projectors_set_filter(RS::LightProjectorFilter p_filter) = 0; + virtual void update() = 0; virtual ~RendererSceneRender() {} }; diff --git a/servers/rendering/renderer_storage.h b/servers/rendering/renderer_storage.h index b2aa0d27d3..b9bc349f79 100644 --- a/servers/rendering/renderer_storage.h +++ b/servers/rendering/renderer_storage.h @@ -48,6 +48,7 @@ public: DEPENDENCY_CHANGED_SKELETON_DATA, DEPENDENCY_CHANGED_SKELETON_BONES, DEPENDENCY_CHANGED_LIGHT, + DEPENDENCY_CHANGED_LIGHT_SOFT_SHADOW_AND_PROJECTOR, DEPENDENCY_CHANGED_REFLECTION_PROBE, }; @@ -337,6 +338,8 @@ public: virtual bool light_has_shadow(RID p_light) const = 0; + virtual bool light_has_projector(RID p_light) const = 0; + virtual RS::LightType light_get_type(RID p_light) const = 0; virtual AABB light_get_aabb(RID p_light) const = 0; virtual float light_get_param(RID p_light, RS::LightParam p_param) = 0; diff --git a/servers/rendering/rendering_device.cpp b/servers/rendering/rendering_device.cpp index 3594939362..b298ad193b 100644 --- a/servers/rendering/rendering_device.cpp +++ b/servers/rendering/rendering_device.cpp @@ -38,23 +38,23 @@ RenderingDevice *RenderingDevice::get_singleton() { return singleton; } -RenderingDevice::ShaderCompileFunction RenderingDevice::compile_function = nullptr; +RenderingDevice::ShaderCompileToSPIRVFunction RenderingDevice::compile_to_spirv_function = nullptr; RenderingDevice::ShaderCacheFunction RenderingDevice::cache_function = nullptr; -RenderingDevice::ShaderGetCacheKeyFunction RenderingDevice::get_cache_key_function = nullptr; +RenderingDevice::ShaderSPIRVGetCacheKeyFunction RenderingDevice::get_spirv_cache_key_function = nullptr; -void RenderingDevice::shader_set_compile_function(ShaderCompileFunction p_function) { - compile_function = p_function; +void RenderingDevice::shader_set_compile_to_spirv_function(ShaderCompileToSPIRVFunction p_function) { + compile_to_spirv_function = p_function; } -void RenderingDevice::shader_set_cache_function(ShaderCacheFunction p_function) { +void RenderingDevice::shader_set_spirv_cache_function(ShaderCacheFunction p_function) { cache_function = p_function; } -void RenderingDevice::shader_set_get_cache_key_function(ShaderGetCacheKeyFunction p_function) { - get_cache_key_function = p_function; +void RenderingDevice::shader_set_get_cache_key_function(ShaderSPIRVGetCacheKeyFunction p_function) { + get_spirv_cache_key_function = p_function; } -Vector<uint8_t> RenderingDevice::shader_compile_from_source(ShaderStage p_stage, const String &p_source_code, ShaderLanguage p_language, String *r_error, bool p_allow_cache) { +Vector<uint8_t> RenderingDevice::shader_compile_spirv_from_source(ShaderStage p_stage, const String &p_source_code, ShaderLanguage p_language, String *r_error, bool p_allow_cache) { if (p_allow_cache && cache_function) { Vector<uint8_t> cache = cache_function(p_stage, p_source_code, p_language); if (cache.size()) { @@ -62,18 +62,24 @@ Vector<uint8_t> RenderingDevice::shader_compile_from_source(ShaderStage p_stage, } } - ERR_FAIL_COND_V(!compile_function, Vector<uint8_t>()); + ERR_FAIL_COND_V(!compile_to_spirv_function, Vector<uint8_t>()); - return compile_function(p_stage, p_source_code, p_language, r_error, &device_capabilities); + return compile_to_spirv_function(p_stage, p_source_code, p_language, r_error, &device_capabilities); } -String RenderingDevice::shader_get_cache_key() const { - if (get_cache_key_function) { - return get_cache_key_function(&device_capabilities); +String RenderingDevice::shader_get_spirv_cache_key() const { + if (get_spirv_cache_key_function) { + return get_spirv_cache_key_function(&device_capabilities); } return String(); } +RID RenderingDevice::shader_create_from_spirv(const Vector<ShaderStageSPIRVData> &p_spirv) { + Vector<uint8_t> bytecode = shader_compile_binary_from_spirv(p_spirv); + ERR_FAIL_COND_V(bytecode.size() == 0, RID()); + return shader_create_from_bytecode(bytecode); +} + RID RenderingDevice::_texture_create(const Ref<RDTextureFormat> &p_format, const Ref<RDTextureView> &p_view, const TypedArray<PackedByteArray> &p_data) { ERR_FAIL_COND_V(p_format.is_null(), RID()); ERR_FAIL_COND_V(p_view.is_null(), RID()); @@ -170,40 +176,59 @@ RID RenderingDevice::_vertex_array_create(uint32_t p_vertex_count, VertexFormatI return vertex_array_create(p_vertex_count, p_vertex_format, buffers); } -Ref<RDShaderBytecode> RenderingDevice::_shader_compile_from_source(const Ref<RDShaderSource> &p_source, bool p_allow_cache) { - ERR_FAIL_COND_V(p_source.is_null(), Ref<RDShaderBytecode>()); +Ref<RDShaderSPIRV> RenderingDevice::_shader_compile_spirv_from_source(const Ref<RDShaderSource> &p_source, bool p_allow_cache) { + ERR_FAIL_COND_V(p_source.is_null(), Ref<RDShaderSPIRV>()); - Ref<RDShaderBytecode> bytecode; + Ref<RDShaderSPIRV> bytecode; bytecode.instantiate(); for (int i = 0; i < RD::SHADER_STAGE_MAX; i++) { String error; ShaderStage stage = ShaderStage(i); - Vector<uint8_t> spirv = shader_compile_from_source(stage, p_source->get_stage_source(stage), p_source->get_language(), &error, p_allow_cache); + Vector<uint8_t> spirv = shader_compile_spirv_from_source(stage, p_source->get_stage_source(stage), p_source->get_language(), &error, p_allow_cache); bytecode->set_stage_bytecode(stage, spirv); bytecode->set_stage_compile_error(stage, error); } return bytecode; } -RID RenderingDevice::shader_create_from_bytecode(const Ref<RDShaderBytecode> &p_bytecode) { - ERR_FAIL_COND_V(p_bytecode.is_null(), RID()); +Vector<uint8_t> RenderingDevice::_shader_compile_binary_from_spirv(const Ref<RDShaderSPIRV> &p_spirv) { + ERR_FAIL_COND_V(p_spirv.is_null(), Vector<uint8_t>()); - Vector<ShaderStageData> stage_data; + Vector<ShaderStageSPIRVData> stage_data; for (int i = 0; i < RD::SHADER_STAGE_MAX; i++) { ShaderStage stage = ShaderStage(i); - ShaderStageData sd; + ShaderStageSPIRVData sd; sd.shader_stage = stage; - String error = p_bytecode->get_stage_compile_error(stage); - ERR_FAIL_COND_V_MSG(error != String(), RID(), "Can't create a shader from an errored bytecode. Check errors in source bytecode."); - sd.spir_v = p_bytecode->get_stage_bytecode(stage); + String error = p_spirv->get_stage_compile_error(stage); + ERR_FAIL_COND_V_MSG(error != String(), Vector<uint8_t>(), "Can't create a shader from an errored bytecode. Check errors in source bytecode."); + sd.spir_v = p_spirv->get_stage_bytecode(stage); if (sd.spir_v.is_empty()) { continue; } stage_data.push_back(sd); } - return shader_create(stage_data); + return shader_compile_binary_from_spirv(stage_data); +} + +RID RenderingDevice::_shader_create_from_spirv(const Ref<RDShaderSPIRV> &p_spirv) { + ERR_FAIL_COND_V(p_spirv.is_null(), RID()); + + Vector<ShaderStageSPIRVData> stage_data; + for (int i = 0; i < RD::SHADER_STAGE_MAX; i++) { + ShaderStage stage = ShaderStage(i); + ShaderStageSPIRVData sd; + sd.shader_stage = stage; + String error = p_spirv->get_stage_compile_error(stage); + ERR_FAIL_COND_V_MSG(error != String(), RID(), "Can't create a shader from an errored bytecode. Check errors in source bytecode."); + sd.spir_v = p_spirv->get_stage_bytecode(stage); + if (sd.spir_v.is_empty()) { + continue; + } + stage_data.push_back(sd); + } + return shader_create_from_spirv(stage_data); } RID RenderingDevice::_uniform_set_create(const Array &p_uniforms, RID p_shader, uint32_t p_shader_set) { @@ -366,8 +391,10 @@ void RenderingDevice::_bind_methods() { ClassDB::bind_method(D_METHOD("index_buffer_create", "size_indices", "format", "data", "use_restart_indices"), &RenderingDevice::index_buffer_create, DEFVAL(Vector<uint8_t>()), DEFVAL(false)); ClassDB::bind_method(D_METHOD("index_array_create", "index_buffer", "index_offset", "index_count"), &RenderingDevice::index_array_create); - ClassDB::bind_method(D_METHOD("shader_compile_from_source", "shader_source", "allow_cache"), &RenderingDevice::_shader_compile_from_source, DEFVAL(true)); - ClassDB::bind_method(D_METHOD("shader_create", "shader_data"), &RenderingDevice::shader_create_from_bytecode); + ClassDB::bind_method(D_METHOD("shader_compile_spirv_from_source", "shader_source", "allow_cache"), &RenderingDevice::_shader_compile_spirv_from_source, DEFVAL(true)); + ClassDB::bind_method(D_METHOD("shader_compile_binary_from_spirv", "spirv_data"), &RenderingDevice::_shader_compile_binary_from_spirv); + ClassDB::bind_method(D_METHOD("shader_create_from_spirv", "spirv_data"), &RenderingDevice::_shader_compile_binary_from_spirv); + ClassDB::bind_method(D_METHOD("shader_create_from_bytecode", "binary_data"), &RenderingDevice::shader_create_from_bytecode); ClassDB::bind_method(D_METHOD("shader_get_vertex_input_attribute_mask", "shader"), &RenderingDevice::shader_get_vertex_input_attribute_mask); ClassDB::bind_method(D_METHOD("uniform_buffer_create", "size_bytes", "data"), &RenderingDevice::uniform_buffer_create, DEFVAL(Vector<uint8_t>())); diff --git a/servers/rendering/rendering_device.h b/servers/rendering/rendering_device.h index 9a154ef7e9..eaf1ace798 100644 --- a/servers/rendering/rendering_device.h +++ b/servers/rendering/rendering_device.h @@ -41,7 +41,7 @@ class RDAttachmentFormat; class RDSamplerState; class RDVertexAttribute; class RDShaderSource; -class RDShaderBytecode; +class RDShaderSPIRV; class RDUniforms; class RDPipelineRasterizationState; class RDPipelineMultisampleState; @@ -105,14 +105,14 @@ public: bool supports_multiview = false; // If true this device supports multiview options }; - typedef String (*ShaderGetCacheKeyFunction)(const Capabilities *p_capabilities); - typedef Vector<uint8_t> (*ShaderCompileFunction)(ShaderStage p_stage, const String &p_source_code, ShaderLanguage p_language, String *r_error, const Capabilities *p_capabilities); + typedef String (*ShaderSPIRVGetCacheKeyFunction)(const Capabilities *p_capabilities); + typedef Vector<uint8_t> (*ShaderCompileToSPIRVFunction)(ShaderStage p_stage, const String &p_source_code, ShaderLanguage p_language, String *r_error, const Capabilities *p_capabilities); typedef Vector<uint8_t> (*ShaderCacheFunction)(ShaderStage p_stage, const String &p_source_code, ShaderLanguage p_language); private: - static ShaderCompileFunction compile_function; + static ShaderCompileToSPIRVFunction compile_to_spirv_function; static ShaderCacheFunction cache_function; - static ShaderGetCacheKeyFunction get_cache_key_function; + static ShaderSPIRVGetCacheKeyFunction get_spirv_cache_key_function; static RenderingDevice *singleton; @@ -651,24 +651,28 @@ public: const Capabilities *get_device_capabilities() const { return &device_capabilities; }; - virtual Vector<uint8_t> shader_compile_from_source(ShaderStage p_stage, const String &p_source_code, ShaderLanguage p_language = SHADER_LANGUAGE_GLSL, String *r_error = nullptr, bool p_allow_cache = true); - virtual String shader_get_cache_key() const; + virtual Vector<uint8_t> shader_compile_spirv_from_source(ShaderStage p_stage, const String &p_source_code, ShaderLanguage p_language = SHADER_LANGUAGE_GLSL, String *r_error = nullptr, bool p_allow_cache = true); + virtual String shader_get_spirv_cache_key() const; - static void shader_set_compile_function(ShaderCompileFunction p_function); - static void shader_set_cache_function(ShaderCacheFunction p_function); - static void shader_set_get_cache_key_function(ShaderGetCacheKeyFunction p_function); + static void shader_set_compile_to_spirv_function(ShaderCompileToSPIRVFunction p_function); + static void shader_set_spirv_cache_function(ShaderCacheFunction p_function); + static void shader_set_get_cache_key_function(ShaderSPIRVGetCacheKeyFunction p_function); - struct ShaderStageData { + struct ShaderStageSPIRVData { ShaderStage shader_stage; Vector<uint8_t> spir_v; - ShaderStageData() { + ShaderStageSPIRVData() { shader_stage = SHADER_STAGE_VERTEX; } }; - RID shader_create_from_bytecode(const Ref<RDShaderBytecode> &p_bytecode); - virtual RID shader_create(const Vector<ShaderStageData> &p_stages) = 0; + virtual String shader_get_binary_cache_key() const = 0; + virtual Vector<uint8_t> shader_compile_binary_from_spirv(const Vector<ShaderStageSPIRVData> &p_spirv) = 0; + + virtual RID shader_create_from_spirv(const Vector<ShaderStageSPIRVData> &p_spirv); + virtual RID shader_create_from_bytecode(const Vector<uint8_t> &p_shader_binary) = 0; + virtual uint32_t shader_get_vertex_input_attribute_mask(RID p_shader) = 0; /******************/ @@ -1194,7 +1198,9 @@ protected: VertexFormatID _vertex_format_create(const TypedArray<RDVertexAttribute> &p_vertex_formats); RID _vertex_array_create(uint32_t p_vertex_count, VertexFormatID p_vertex_format, const TypedArray<RID> &p_src_buffers); - Ref<RDShaderBytecode> _shader_compile_from_source(const Ref<RDShaderSource> &p_source, bool p_allow_cache = true); + Ref<RDShaderSPIRV> _shader_compile_spirv_from_source(const Ref<RDShaderSource> &p_source, bool p_allow_cache = true); + Vector<uint8_t> _shader_compile_binary_from_spirv(const Ref<RDShaderSPIRV> &p_bytecode); + RID _shader_create_from_spirv(const Ref<RDShaderSPIRV> &p_spirv); RID _uniform_set_create(const Array &p_uniforms, RID p_shader, uint32_t p_shader_set); diff --git a/servers/rendering/rendering_device_binds.cpp b/servers/rendering/rendering_device_binds.cpp index 2652edb1bc..fa3f2f3895 100644 --- a/servers/rendering/rendering_device_binds.cpp +++ b/servers/rendering/rendering_device_binds.cpp @@ -172,7 +172,7 @@ Error RDShaderFile::parse_versions_from_text(const String &p_text, const String /* STEP 2, Compile the versions, add to shader file */ for (Map<StringName, String>::Element *E = version_texts.front(); E; E = E->next()) { - Ref<RDShaderBytecode> bytecode; + Ref<RDShaderSPIRV> bytecode; bytecode.instantiate(); for (int i = 0; i < RD::SHADER_STAGE_MAX; i++) { @@ -182,7 +182,7 @@ Error RDShaderFile::parse_versions_from_text(const String &p_text, const String } code = code.replace("VERSION_DEFINES", E->get()); String error; - Vector<uint8_t> spirv = RenderingDevice::get_singleton()->shader_compile_from_source(RD::ShaderStage(i), code, RD::SHADER_LANGUAGE_GLSL, &error, false); + Vector<uint8_t> spirv = RenderingDevice::get_singleton()->shader_compile_spirv_from_source(RD::ShaderStage(i), code, RD::SHADER_LANGUAGE_GLSL, &error, false); bytecode->set_stage_bytecode(RD::ShaderStage(i), spirv); if (error != "") { error += String() + "\n\nStage '" + stage_str[i] + "' source code: \n\n"; diff --git a/servers/rendering/rendering_device_binds.h b/servers/rendering/rendering_device_binds.h index 1af427b356..ccc3e2fb39 100644 --- a/servers/rendering/rendering_device_binds.h +++ b/servers/rendering/rendering_device_binds.h @@ -263,8 +263,8 @@ protected: } }; -class RDShaderBytecode : public Resource { - GDCLASS(RDShaderBytecode, Resource) +class RDShaderSPIRV : public Resource { + GDCLASS(RDShaderSPIRV, Resource) Vector<uint8_t> bytecode[RD::SHADER_STAGE_MAX]; String compile_error[RD::SHADER_STAGE_MAX]; @@ -280,6 +280,19 @@ public: return bytecode[p_stage]; } + Vector<RD::ShaderStageSPIRVData> get_stages() const { + Vector<RD::ShaderStageSPIRVData> stages; + for (int i = 0; i < RD::SHADER_STAGE_MAX; i++) { + if (bytecode[i].size()) { + RD::ShaderStageSPIRVData stage; + stage.shader_stage = RD::ShaderStage(i); + stage.spir_v = bytecode[i]; + stages.push_back(stage); + } + } + return stages; + } + void set_stage_compile_error(RD::ShaderStage p_stage, const String &p_compile_error) { ERR_FAIL_INDEX(p_stage, RD::SHADER_STAGE_MAX); compile_error[p_stage] = p_compile_error; @@ -292,11 +305,11 @@ public: protected: static void _bind_methods() { - ClassDB::bind_method(D_METHOD("set_stage_bytecode", "stage", "bytecode"), &RDShaderBytecode::set_stage_bytecode); - ClassDB::bind_method(D_METHOD("get_stage_bytecode", "stage"), &RDShaderBytecode::get_stage_bytecode); + ClassDB::bind_method(D_METHOD("set_stage_bytecode", "stage", "bytecode"), &RDShaderSPIRV::set_stage_bytecode); + ClassDB::bind_method(D_METHOD("get_stage_bytecode", "stage"), &RDShaderSPIRV::get_stage_bytecode); - ClassDB::bind_method(D_METHOD("set_stage_compile_error", "stage", "compile_error"), &RDShaderBytecode::set_stage_compile_error); - ClassDB::bind_method(D_METHOD("get_stage_compile_error", "stage"), &RDShaderBytecode::get_stage_compile_error); + ClassDB::bind_method(D_METHOD("set_stage_compile_error", "stage", "compile_error"), &RDShaderSPIRV::set_stage_compile_error); + ClassDB::bind_method(D_METHOD("get_stage_compile_error", "stage"), &RDShaderSPIRV::get_stage_compile_error); ADD_GROUP("Bytecode", "bytecode_"); ADD_PROPERTYI(PropertyInfo(Variant::PACKED_BYTE_ARRAY, "bytecode_vertex"), "set_stage_bytecode", "get_stage_bytecode", RD::SHADER_STAGE_VERTEX); @@ -316,24 +329,29 @@ protected: class RDShaderFile : public Resource { GDCLASS(RDShaderFile, Resource) - Map<StringName, Ref<RDShaderBytecode>> versions; + Map<StringName, Ref<RDShaderSPIRV>> versions; String base_error; public: - void set_bytecode(const Ref<RDShaderBytecode> &p_bytecode, const StringName &p_version = StringName()) { + void set_bytecode(const Ref<RDShaderSPIRV> &p_bytecode, const StringName &p_version = StringName()) { ERR_FAIL_COND(p_bytecode.is_null()); versions[p_version] = p_bytecode; emit_changed(); } - Ref<RDShaderBytecode> get_bytecode(const StringName &p_version = StringName()) const { - ERR_FAIL_COND_V(!versions.has(p_version), Ref<RDShaderBytecode>()); + Ref<RDShaderSPIRV> get_spirv(const StringName &p_version = StringName()) const { + ERR_FAIL_COND_V(!versions.has(p_version), Ref<RDShaderSPIRV>()); return versions[p_version]; } + Vector<RD::ShaderStageSPIRVData> get_spirv_stages(const StringName &p_version = StringName()) const { + ERR_FAIL_COND_V(!versions.has(p_version), Vector<RD::ShaderStageSPIRVData>()); + return versions[p_version]->get_stages(); + } + Vector<StringName> get_version_list() const { Vector<StringName> vnames; - for (Map<StringName, Ref<RDShaderBytecode>>::Element *E = versions.front(); E; E = E->next()) { + for (Map<StringName, Ref<RDShaderSPIRV>>::Element *E = versions.front(); E; E = E->next()) { vnames.push_back(E->key()); } vnames.sort_custom<StringName::AlphCompare>(); @@ -353,7 +371,7 @@ public: if (base_error != "") { ERR_PRINT("Error parsing shader '" + p_file + "':\n\n" + base_error); } else { - for (Map<StringName, Ref<RDShaderBytecode>>::Element *E = versions.front(); E; E = E->next()) { + for (Map<StringName, Ref<RDShaderSPIRV>>::Element *E = versions.front(); E; E = E->next()) { for (int i = 0; i < RD::SHADER_STAGE_MAX; i++) { String error = E->get()->get_stage_compile_error(RD::ShaderStage(i)); if (error != String()) { @@ -388,9 +406,9 @@ protected: versions.clear(); List<Variant> keys; p_versions.get_key_list(&keys); - for (List<Variant>::Element *E = keys.front(); E; E = E->next()) { - StringName name = E->get(); - Ref<RDShaderBytecode> bc = p_versions[E->get()]; + for (const Variant &E : keys) { + StringName name = E; + Ref<RDShaderSPIRV> bc = p_versions[E]; ERR_CONTINUE(bc.is_null()); versions[name] = bc; } @@ -400,7 +418,7 @@ protected: static void _bind_methods() { ClassDB::bind_method(D_METHOD("set_bytecode", "bytecode", "version"), &RDShaderFile::set_bytecode, DEFVAL(StringName())); - ClassDB::bind_method(D_METHOD("get_bytecode", "version"), &RDShaderFile::get_bytecode, DEFVAL(StringName())); + ClassDB::bind_method(D_METHOD("get_spirv", "version"), &RDShaderFile::get_spirv, DEFVAL(StringName())); ClassDB::bind_method(D_METHOD("get_version_list"), &RDShaderFile::get_version_list); ClassDB::bind_method(D_METHOD("set_base_error", "error"), &RDShaderFile::set_base_error); @@ -458,7 +476,7 @@ class RDPipelineSpecializationConstant : public RefCounted { friend class RenderingDevice; Variant value = false; - uint32_t constant_id; + uint32_t constant_id = 0; public: void set_value(const Variant &p_value) { diff --git a/servers/rendering/rendering_server_default.cpp b/servers/rendering/rendering_server_default.cpp index e3ebebca86..c79dfb1649 100644 --- a/servers/rendering/rendering_server_default.cpp +++ b/servers/rendering/rendering_server_default.cpp @@ -73,7 +73,7 @@ void RenderingServerDefault::request_frame_drawn_callback(Object *p_where, const void RenderingServerDefault::_draw(bool p_swap_buffers, double frame_step) { //needs to be done before changes is reset to 0, to not force the editor to redraw - RS::get_singleton()->emit_signal("frame_pre_draw"); + RS::get_singleton()->emit_signal(SNAME("frame_pre_draw")); changes = 0; @@ -113,7 +113,7 @@ void RenderingServerDefault::_draw(bool p_swap_buffers, double frame_step) { frame_drawn_callbacks.pop_front(); } - RS::get_singleton()->emit_signal("frame_post_draw"); + RS::get_singleton()->emit_signal(SNAME("frame_post_draw")); if (RSG::storage->get_captured_timestamps_count()) { Vector<FrameProfileArea> new_profile; diff --git a/servers/rendering/rendering_server_default.h b/servers/rendering/rendering_server_default.h index 79665dcdd2..282b0564da 100644 --- a/servers/rendering/rendering_server_default.h +++ b/servers/rendering/rendering_server_default.h @@ -656,6 +656,8 @@ public: FUNC1(shadows_quality_set, ShadowQuality); FUNC1(directional_shadow_quality_set, ShadowQuality); + FUNC1(decals_set_filter, RS::DecalFilter); + FUNC1(light_projectors_set_filter, RS::LightProjectorFilter); /* SCENARIO API */ diff --git a/servers/rendering/shader_language.cpp b/servers/rendering/shader_language.cpp index 9b2ba36358..baa5381554 100644 --- a/servers/rendering/shader_language.cpp +++ b/servers/rendering/shader_language.cpp @@ -912,12 +912,15 @@ void ShaderLanguage::clear() { completion_class = SubClassTag::TAG_GLOBAL; completion_struct = StringName(); + unknown_varying_usages.clear(); + #ifdef DEBUG_ENABLED used_constants.clear(); used_varyings.clear(); used_uniforms.clear(); used_functions.clear(); used_structs.clear(); + used_local_vars.clear(); warnings.clear(); #endif // DEBUG_ENABLED @@ -936,7 +939,7 @@ void ShaderLanguage::clear() { } #ifdef DEBUG_ENABLED -void ShaderLanguage::_parse_used_identifier(const StringName &p_identifier, IdentifierType p_type) { +void ShaderLanguage::_parse_used_identifier(const StringName &p_identifier, IdentifierType p_type, const StringName &p_function) { switch (p_type) { case IdentifierType::IDENTIFIER_CONSTANT: if (HAS_WARNING(ShaderWarning::UNUSED_CONSTANT_FLAG) && used_constants.has(p_identifier)) { @@ -945,7 +948,9 @@ void ShaderLanguage::_parse_used_identifier(const StringName &p_identifier, Iden break; case IdentifierType::IDENTIFIER_VARYING: if (HAS_WARNING(ShaderWarning::UNUSED_VARYING_FLAG) && used_varyings.has(p_identifier)) { - used_varyings[p_identifier].used = true; + if (shader->varyings[p_identifier].stage != ShaderNode::Varying::STAGE_VERTEX && shader->varyings[p_identifier].stage != ShaderNode::Varying::STAGE_FRAGMENT) { + used_varyings[p_identifier].used = true; + } } break; case IdentifierType::IDENTIFIER_UNIFORM: @@ -958,6 +963,11 @@ void ShaderLanguage::_parse_used_identifier(const StringName &p_identifier, Iden used_functions[p_identifier].used = true; } break; + case IdentifierType::IDENTIFIER_LOCAL_VAR: + if (HAS_WARNING(ShaderWarning::UNUSED_LOCAL_VARIABLE_FLAG) && used_local_vars.has(p_function) && used_local_vars[p_function].has(p_identifier)) { + used_local_vars[p_function][p_identifier].used = true; + } + break; default: break; } @@ -2428,6 +2438,10 @@ bool ShaderLanguage::_validate_function_call(BlockNode *p_block, const FunctionI if (shader->uniforms.has(varname)) { fail = true; } else { + if (shader->varyings.has(varname)) { + _set_error(vformat("Varyings cannot be passed for '%s' parameter!", "out")); + return false; + } if (p_function_info.built_ins.has(varname)) { BuiltInInfo info = p_function_info.built_ins[varname]; if (info.constant) { @@ -2806,6 +2820,20 @@ bool ShaderLanguage::is_token_operator(TokenType p_type) { p_type == TK_COLON); } +bool ShaderLanguage::is_token_operator_assign(TokenType p_type) { + return (p_type == TK_OP_ASSIGN || + p_type == TK_OP_ASSIGN_ADD || + p_type == TK_OP_ASSIGN_SUB || + p_type == TK_OP_ASSIGN_MUL || + p_type == TK_OP_ASSIGN_DIV || + p_type == TK_OP_ASSIGN_MOD || + p_type == TK_OP_ASSIGN_SHIFT_LEFT || + p_type == TK_OP_ASSIGN_SHIFT_RIGHT || + p_type == TK_OP_ASSIGN_BIT_AND || + p_type == TK_OP_ASSIGN_BIT_OR || + p_type == TK_OP_ASSIGN_BIT_XOR); +} + bool ShaderLanguage::convert_constant(ConstantNode *p_constant, DataType p_to_type, ConstantNode::Value *p_value) { if (p_constant->datatype == p_to_type) { if (p_value) { @@ -3300,8 +3328,8 @@ bool ShaderLanguage::_is_operator_assign(Operator p_op) const { } bool ShaderLanguage::_validate_varying_assign(ShaderNode::Varying &p_varying, String *r_message) { - if (current_function == String("light")) { - *r_message = RTR("Varying may not be assigned in the 'light' function."); + if (current_function != String("vertex") && current_function != String("fragment")) { + *r_message = vformat(RTR("Varying may not be assigned in the '%s' function."), current_function); return false; } switch (p_varying.stage) { @@ -3312,12 +3340,14 @@ bool ShaderLanguage::_validate_varying_assign(ShaderNode::Varying &p_varying, St p_varying.stage = ShaderNode::Varying::STAGE_FRAGMENT; } break; + case ShaderNode::Varying::STAGE_VERTEX_TO_FRAGMENT_LIGHT: case ShaderNode::Varying::STAGE_VERTEX: if (current_function == varying_function_names.fragment) { *r_message = RTR("Varyings which assigned in 'vertex' function may not be reassigned in 'fragment' or 'light'."); return false; } break; + case ShaderNode::Varying::STAGE_FRAGMENT_TO_LIGHT: case ShaderNode::Varying::STAGE_FRAGMENT: if (current_function == varying_function_names.vertex) { *r_message = RTR("Varyings which assigned in 'fragment' function may not be reassigned in 'vertex' or 'light'."); @@ -3333,13 +3363,14 @@ bool ShaderLanguage::_validate_varying_assign(ShaderNode::Varying &p_varying, St bool ShaderLanguage::_validate_varying_using(ShaderNode::Varying &p_varying, String *r_message) { switch (p_varying.stage) { case ShaderNode::Varying::STAGE_UNKNOWN: - *r_message = RTR("Varying must be assigned before using!"); - return false; + VaryingUsage usage; + usage.var = &p_varying; + usage.line = tk_line; + unknown_varying_usages.push_back(usage); + break; case ShaderNode::Varying::STAGE_VERTEX: - if (current_function == varying_function_names.fragment) { - p_varying.stage = ShaderNode::Varying::STAGE_VERTEX_TO_FRAGMENT; - } else if (current_function == varying_function_names.light) { - p_varying.stage = ShaderNode::Varying::STAGE_VERTEX_TO_LIGHT; + if (current_function == varying_function_names.fragment || current_function == varying_function_names.light) { + p_varying.stage = ShaderNode::Varying::STAGE_VERTEX_TO_FRAGMENT_LIGHT; } break; case ShaderNode::Varying::STAGE_FRAGMENT: @@ -3347,24 +3378,25 @@ bool ShaderLanguage::_validate_varying_using(ShaderNode::Varying &p_varying, Str p_varying.stage = ShaderNode::Varying::STAGE_FRAGMENT_TO_LIGHT; } break; - case ShaderNode::Varying::STAGE_VERTEX_TO_FRAGMENT: - if (current_function == varying_function_names.light) { - *r_message = RTR("Varying must only be used in two different stages, which can be 'vertex' 'fragment' and 'light'"); - return false; - } - break; - case ShaderNode::Varying::STAGE_VERTEX_TO_LIGHT: - if (current_function == varying_function_names.fragment) { - *r_message = RTR("Varying must only be used in two different stages, which can be 'vertex' 'fragment' and 'light'"); - return false; - } - break; default: break; } return true; } +bool ShaderLanguage::_check_varying_usages(int *r_error_line, String *r_error_message) const { + for (const List<ShaderLanguage::VaryingUsage>::Element *E = unknown_varying_usages.front(); E; E = E->next()) { + ShaderNode::Varying::Stage stage = E->get().var->stage; + if (stage != ShaderNode::Varying::STAGE_UNKNOWN && stage != ShaderNode::Varying::STAGE_VERTEX && stage != ShaderNode::Varying::STAGE_VERTEX_TO_FRAGMENT_LIGHT) { + *r_error_line = E->get().line; + *r_error_message = RTR("Fragment-stage varying could not been accessed in custom function!"); + return false; + } + } + + return true; +} + bool ShaderLanguage::_check_node_constness(const Node *p_node) const { switch (p_node->type) { case Node::TYPE_OPERATOR: { @@ -4108,6 +4140,10 @@ ShaderLanguage::Node *ShaderLanguage::_parse_expression(BlockNode *p_block, cons } else if (shader->uniforms.has(varname)) { error = true; } else { + if (shader->varyings.has(varname)) { + _set_error(vformat("Varyings cannot be passed for '%s' parameter!", _get_qualifier_str(call_function->arguments[i].qualifier))); + return nullptr; + } if (p_function_info.built_ins.has(varname)) { BuiltInInfo info = p_function_info.built_ins[varname]; if (info.constant) { @@ -4171,7 +4207,13 @@ ShaderLanguage::Node *ShaderLanguage::_parse_expression(BlockNode *p_block, cons expr = func; #ifdef DEBUG_ENABLED if (check_warnings) { - _parse_used_identifier(name, IdentifierType::IDENTIFIER_FUNCTION); + StringName func_name; + + if (p_block && p_block->parent_function) { + func_name = p_block->parent_function->name; + } + + _parse_used_identifier(name, IdentifierType::IDENTIFIER_FUNCTION, func_name); } #endif // DEBUG_ENABLED } @@ -4212,7 +4254,8 @@ ShaderLanguage::Node *ShaderLanguage::_parse_expression(BlockNode *p_block, cons Token next_token = _get_token(); _set_tkpos(prev_pos); String error; - if (next_token.type == TK_OP_ASSIGN) { + + if (is_token_operator_assign(next_token.type)) { if (!_validate_varying_assign(shader->varyings[identifier], &error)) { _set_error(error); return nullptr; @@ -4319,7 +4362,13 @@ ShaderLanguage::Node *ShaderLanguage::_parse_expression(BlockNode *p_block, cons } #ifdef DEBUG_ENABLED if (check_warnings) { - _parse_used_identifier(identifier, ident_type); + StringName func_name; + + if (p_block && p_block->parent_function) { + func_name = p_block->parent_function->name; + } + + _parse_used_identifier(identifier, ident_type, func_name); } #endif // DEBUG_ENABLED } @@ -4417,12 +4466,12 @@ ShaderLanguage::Node *ShaderLanguage::_parse_expression(BlockNode *p_block, cons String member_name = String(ident.ptr()); if (shader->structs.has(st)) { StructNode *n = shader->structs[st].shader_struct; - for (List<MemberNode *>::Element *E = n->members.front(); E; E = E->next()) { - if (String(E->get()->name) == member_name) { - member_type = E->get()->datatype; - array_size = E->get()->array_size; + for (const MemberNode *E : n->members) { + if (String(E->name) == member_name) { + member_type = E->datatype; + array_size = E->array_size; if (member_type == TYPE_STRUCT) { - member_struct_name = E->get()->struct_name; + member_struct_name = E->struct_name; } ok = true; break; @@ -4747,10 +4796,12 @@ ShaderLanguage::Node *ShaderLanguage::_parse_expression(BlockNode *p_block, cons String member_struct_name; if (expr->get_array_size() > 0) { - uint32_t index_constant = static_cast<ConstantNode *>(index)->values[0].uint; - if (index_constant >= (uint32_t)expr->get_array_size()) { - _set_error(vformat("Index [%s] out of range [%s..%s]", index_constant, 0, expr->get_array_size() - 1)); - return nullptr; + if (index->type == Node::TYPE_CONSTANT) { + uint32_t index_constant = static_cast<ConstantNode *>(index)->values[0].uint; + if (index_constant >= (uint32_t)expr->get_array_size()) { + _set_error(vformat("Index [%s] out of range [%s..%s]", index_constant, 0, expr->get_array_size() - 1)); + return nullptr; + } } member_type = expr->get_datatype(); if (member_type == TYPE_STRUCT) { @@ -5537,6 +5588,20 @@ Error ShaderLanguage::_parse_block(BlockNode *p_block, const FunctionInfo &p_fun } } +#ifdef DEBUG_ENABLED + if (check_warnings && HAS_WARNING(ShaderWarning::UNUSED_LOCAL_VARIABLE_FLAG)) { + if (p_block && p_block->parent_function) { + StringName func_name = p_block->parent_function->name; + + if (!used_local_vars.has(func_name)) { + used_local_vars.insert(func_name, Map<StringName, Usage>()); + } + + used_local_vars[func_name].insert(name, Usage(tk_line)); + } + } +#endif // DEBUG_ENABLED + BlockNode::Variable var; var.type = type; var.precision = precision; @@ -7831,12 +7896,12 @@ Error ShaderLanguage::_parse_shader(const Map<StringName, FunctionInfo> &p_funct tk = _get_token(); } - for (Map<StringName, ShaderNode::Varying>::Element *E = shader->varyings.front(); E; E = E->next()) { - if (E->get().stage == ShaderNode::Varying::STAGE_VERTEX || E->get().stage == ShaderNode::Varying::STAGE_FRAGMENT) { - _set_tkpos(E->get().tkpos); - _set_error(RTR("Varying must only be used in two different stages, which can be 'vertex' 'fragment' and 'light'")); - return ERR_PARSE_ERROR; - } + int error_line; + String error_message; + if (!_check_varying_usages(&error_line, &error_message)) { + _set_tkpos({ 0, error_line }); + _set_error(error_message); + return ERR_PARSE_ERROR; } return OK; @@ -7984,6 +8049,15 @@ String ShaderLanguage::get_shader_type(const String &p_code) { #ifdef DEBUG_ENABLED void ShaderLanguage::_check_warning_accums() { + for (Map<ShaderWarning::Code, Map<StringName, Map<StringName, Usage>> *>::Element *E = warnings_check_map2.front(); E; E = E->next()) { + for (Map<StringName, Map<StringName, Usage>>::Element *T = (*E->get()).front(); T; T = T->next()) { + for (const Map<StringName, Usage>::Element *U = T->get().front(); U; U = U->next()) { + if (!U->get().used) { + _add_warning(E->key(), U->get().decl_line, U->key()); + } + } + } + } for (Map<ShaderWarning::Code, Map<StringName, Usage> *>::Element *E = warnings_check_map.front(); E; E = E->next()) { for (const Map<StringName, Usage>::Element *U = (*E->get()).front(); U; U = U->next()) { if (!U->get().used) { @@ -8456,6 +8530,8 @@ ShaderLanguage::ShaderLanguage() { warnings_check_map.insert(ShaderWarning::UNUSED_STRUCT, &used_structs); warnings_check_map.insert(ShaderWarning::UNUSED_UNIFORM, &used_uniforms); warnings_check_map.insert(ShaderWarning::UNUSED_VARYING, &used_varyings); + + warnings_check_map2.insert(ShaderWarning::UNUSED_LOCAL_VARIABLE, &used_local_vars); #endif // DEBUG_ENABLED } diff --git a/servers/rendering/shader_language.h b/servers/rendering/shader_language.h index 4120e04ee1..c02d6c47ec 100644 --- a/servers/rendering/shader_language.h +++ b/servers/rendering/shader_language.h @@ -646,10 +646,9 @@ public: struct Varying { enum Stage { STAGE_UNKNOWN, - STAGE_VERTEX, // transition stage to STAGE_VERTEX_TO_FRAGMENT or STAGE_VERTEX_TO_LIGHT, emits error if they are not used - STAGE_FRAGMENT, // transition stage to STAGE_FRAGMENT_TO_LIGHT, emits error if it's not used - STAGE_VERTEX_TO_FRAGMENT, - STAGE_VERTEX_TO_LIGHT, + STAGE_VERTEX, // transition stage to STAGE_VERTEX_TO_FRAGMENT_LIGHT, emits warning if it's not used + STAGE_FRAGMENT, // transition stage to STAGE_FRAGMENT_TO_LIGHT, emits warning if it's not used + STAGE_VERTEX_TO_FRAGMENT_LIGHT, STAGE_FRAGMENT_TO_LIGHT, }; @@ -767,6 +766,7 @@ public: static String get_datatype_name(DataType p_type); static bool is_token_nonvoid_datatype(TokenType p_type); static bool is_token_operator(TokenType p_type); + static bool is_token_operator_assign(TokenType p_type); static bool convert_constant(ConstantNode *p_constant, DataType p_to_type, ConstantNode::Value *p_value = nullptr); static DataType get_scalar_type(DataType p_type); @@ -848,6 +848,9 @@ private: Map<StringName, Usage> used_structs; Map<ShaderWarning::Code, Map<StringName, Usage> *> warnings_check_map; + Map<StringName, Map<StringName, Usage>> used_local_vars; + Map<ShaderWarning::Code, Map<StringName, Map<StringName, Usage>> *> warnings_check_map2; + List<ShaderWarning> warnings; bool check_warnings = false; @@ -873,6 +876,14 @@ private: VaryingFunctionNames varying_function_names; + struct VaryingUsage { + ShaderNode::Varying *var; + int line; + }; + List<VaryingUsage> unknown_varying_usages; + + bool _check_varying_usages(int *r_error_line, String *r_error_message) const; + TkPos _get_tkpos() { TkPos tkp; tkp.char_idx = char_idx; @@ -917,7 +928,7 @@ private: bool _find_identifier(const BlockNode *p_block, bool p_allow_reassign, const FunctionInfo &p_function_info, const StringName &p_identifier, DataType *r_data_type = nullptr, IdentifierType *r_type = nullptr, bool *r_is_const = nullptr, int *r_array_size = nullptr, StringName *r_struct_name = nullptr, ConstantNode::Value *r_constant_value = nullptr); #ifdef DEBUG_ENABLED - void _parse_used_identifier(const StringName &p_identifier, IdentifierType p_type); + void _parse_used_identifier(const StringName &p_identifier, IdentifierType p_type, const StringName &p_function); #endif // DEBUG_ENABLED bool _is_operator_assign(Operator p_op) const; bool _validate_assign(Node *p_node, const FunctionInfo &p_function_info, String *r_message = nullptr); diff --git a/servers/rendering/shader_warnings.cpp b/servers/rendering/shader_warnings.cpp index aa11b4e397..0c1d6408c9 100644 --- a/servers/rendering/shader_warnings.cpp +++ b/servers/rendering/shader_warnings.cpp @@ -59,6 +59,8 @@ String ShaderWarning::get_message() const { return vformat("The uniform '%s' is declared but never used.", subject); case UNUSED_VARYING: return vformat("The varying '%s' is declared but never used.", subject); + case UNUSED_LOCAL_VARIABLE: + return vformat("The local variable '%s' is declared but never used.", subject); default: break; } @@ -79,6 +81,7 @@ String ShaderWarning::get_name_from_code(Code p_code) { "UNUSED_STRUCT", "UNUSED_UNIFORM", "UNUSED_VARYING", + "UNUSED_LOCAL_VARIABLE", }; static_assert((sizeof(names) / sizeof(*names)) == WARNING_MAX, "Amount of warning types don't match the amount of warning names."); @@ -106,6 +109,7 @@ static void init_code_to_flags_map() { code_to_flags_map->insert(ShaderWarning::UNUSED_STRUCT, ShaderWarning::UNUSED_STRUCT_FLAG); code_to_flags_map->insert(ShaderWarning::UNUSED_UNIFORM, ShaderWarning::UNUSED_UNIFORM_FLAG); code_to_flags_map->insert(ShaderWarning::UNUSED_VARYING, ShaderWarning::UNUSED_VARYING_FLAG); + code_to_flags_map->insert(ShaderWarning::UNUSED_LOCAL_VARIABLE, ShaderWarning::UNUSED_LOCAL_VARIABLE_FLAG); } ShaderWarning::CodeFlags ShaderWarning::get_flags_from_codemap(const Map<Code, bool> &p_map) { diff --git a/servers/rendering/shader_warnings.h b/servers/rendering/shader_warnings.h index c40aeefa2d..db872d8fb1 100644 --- a/servers/rendering/shader_warnings.h +++ b/servers/rendering/shader_warnings.h @@ -46,6 +46,7 @@ public: UNUSED_STRUCT, UNUSED_UNIFORM, UNUSED_VARYING, + UNUSED_LOCAL_VARIABLE, WARNING_MAX, }; @@ -57,6 +58,7 @@ public: UNUSED_STRUCT_FLAG = 8U, UNUSED_UNIFORM_FLAG = 16U, UNUSED_VARYING_FLAG = 32U, + UNUSED_LOCAL_VARIABLE_FLAG = 64U, }; private: diff --git a/servers/rendering_server.cpp b/servers/rendering_server.cpp index 748b372c62..314b59869d 100644 --- a/servers/rendering_server.cpp +++ b/servers/rendering_server.cpp @@ -53,15 +53,15 @@ Array RenderingServer::_texture_debug_usage_bind() { List<TextureInfo> list; texture_debug_usage(&list); Array arr; - for (const List<TextureInfo>::Element *E = list.front(); E; E = E->next()) { + for (const TextureInfo &E : list) { Dictionary dict; - dict["texture"] = E->get().texture; - dict["width"] = E->get().width; - dict["height"] = E->get().height; - dict["depth"] = E->get().depth; - dict["format"] = E->get().format; - dict["bytes"] = E->get().bytes; - dict["path"] = E->get().path; + dict["texture"] = E.texture; + dict["width"] = E.width; + dict["height"] = E.height; + dict["depth"] = E.depth; + dict["format"] = E.format; + dict["bytes"] = E.bytes; + dict["path"] = E.path; arr.push_back(dict); } return arr; @@ -350,7 +350,7 @@ Error RenderingServer::_surface_set_data(Array p_arrays, uint32_t p_format, uint { for (int i = 0; i < p_vertex_array_len; i++) { - float vector[2] = { src[i].x, src[i].y }; + float vector[2] = { (float)src[i].x, (float)src[i].y }; memcpy(&vw[p_offsets[ai] + i * p_vertex_stride], vector, sizeof(float) * 2); @@ -375,7 +375,7 @@ Error RenderingServer::_surface_set_data(Array p_arrays, uint32_t p_format, uint { for (int i = 0; i < p_vertex_array_len; i++) { - float vector[3] = { src[i].x, src[i].y, src[i].z }; + float vector[3] = { (float)src[i].x, (float)src[i].y, (float)src[i].z }; memcpy(&vw[p_offsets[ai] + i * p_vertex_stride], vector, sizeof(float) * 3); @@ -461,7 +461,7 @@ Error RenderingServer::_surface_set_data(Array p_arrays, uint32_t p_format, uint const Vector2 *src = array.ptr(); for (int i = 0; i < p_vertex_array_len; i++) { - float uv[2] = { src[i].x, src[i].y }; + float uv[2] = { (float)src[i].x, (float)src[i].y }; memcpy(&aw[p_offsets[ai] + i * p_attrib_stride], uv, 2 * 4); } @@ -478,7 +478,7 @@ Error RenderingServer::_surface_set_data(Array p_arrays, uint32_t p_format, uint const Vector2 *src = array.ptr(); for (int i = 0; i < p_vertex_array_len; i++) { - float uv[2] = { src[i].x, src[i].y }; + float uv[2] = { (float)src[i].x, (float)src[i].y }; memcpy(&aw[p_offsets[ai] + i * p_attrib_stride], uv, 2 * 4); } } break; @@ -972,10 +972,10 @@ Error RenderingServer::mesh_create_surface_data_from_arrays(SurfaceData *r_surfa if (index_array_len) { List<Variant> keys; p_lods.get_key_list(&keys); - for (List<Variant>::Element *E = keys.front(); E; E = E->next()) { - float distance = E->get(); + for (const Variant &E : keys) { + float distance = E; ERR_CONTINUE(distance <= 0.0); - Vector<int> indices = p_lods[E->get()]; + Vector<int> indices = p_lods[E]; ERR_CONTINUE(indices.size() == 0); uint32_t index_count = indices.size(); ERR_CONTINUE(index_count >= (uint32_t)index_array_len); //should be smaller.. @@ -1854,6 +1854,14 @@ void RenderingServer::_bind_methods() { ClassDB::bind_method(D_METHOD("light_directional_set_blend_splits", "light", "enable"), &RenderingServer::light_directional_set_blend_splits); ClassDB::bind_method(D_METHOD("light_directional_set_sky_only", "light", "enable"), &RenderingServer::light_directional_set_sky_only); + ClassDB::bind_method(D_METHOD("light_projectors_set_filter", "filter"), &RenderingServer::light_projectors_set_filter); + + BIND_ENUM_CONSTANT(LIGHT_PROJECTOR_FILTER_NEAREST); + BIND_ENUM_CONSTANT(LIGHT_PROJECTOR_FILTER_NEAREST_MIPMAPS); + BIND_ENUM_CONSTANT(LIGHT_PROJECTOR_FILTER_LINEAR); + BIND_ENUM_CONSTANT(LIGHT_PROJECTOR_FILTER_LINEAR_MIPMAPS); + BIND_ENUM_CONSTANT(LIGHT_PROJECTOR_FILTER_LINEAR_MIPMAPS_ANISOTROPIC); + BIND_ENUM_CONSTANT(LIGHT_DIRECTIONAL); BIND_ENUM_CONSTANT(LIGHT_OMNI); BIND_ENUM_CONSTANT(LIGHT_SPOT); @@ -1939,12 +1947,20 @@ void RenderingServer::_bind_methods() { ClassDB::bind_method(D_METHOD("decal_set_fade", "decal", "above", "below"), &RenderingServer::decal_set_fade); ClassDB::bind_method(D_METHOD("decal_set_normal_fade", "decal", "fade"), &RenderingServer::decal_set_normal_fade); + ClassDB::bind_method(D_METHOD("decals_set_filter", "filter"), &RenderingServer::decals_set_filter); + BIND_ENUM_CONSTANT(DECAL_TEXTURE_ALBEDO); BIND_ENUM_CONSTANT(DECAL_TEXTURE_NORMAL); BIND_ENUM_CONSTANT(DECAL_TEXTURE_ORM); BIND_ENUM_CONSTANT(DECAL_TEXTURE_EMISSION); BIND_ENUM_CONSTANT(DECAL_TEXTURE_MAX); + BIND_ENUM_CONSTANT(DECAL_FILTER_NEAREST); + BIND_ENUM_CONSTANT(DECAL_FILTER_NEAREST_MIPMAPS); + BIND_ENUM_CONSTANT(DECAL_FILTER_LINEAR); + BIND_ENUM_CONSTANT(DECAL_FILTER_LINEAR_MIPMAPS); + BIND_ENUM_CONSTANT(DECAL_FILTER_LINEAR_MIPMAPS_ANISOTROPIC); + /* VOXEL GI API */ ClassDB::bind_method(D_METHOD("voxel_gi_create"), &RenderingServer::voxel_gi_create); @@ -2747,12 +2763,12 @@ RenderingServer::RenderingServer() { GLOBAL_DEF("rendering/2d/shadow_atlas/size", 2048); - GLOBAL_DEF_RST("rendering/vulkan/rendering/back_end", 0); - GLOBAL_DEF_RST("rendering/vulkan/rendering/back_end.mobile", 1); + GLOBAL_DEF_RST_BASIC("rendering/vulkan/rendering/back_end", 0); + GLOBAL_DEF_RST_BASIC("rendering/vulkan/rendering/back_end.mobile", 1); ProjectSettings::get_singleton()->set_custom_property_info("rendering/vulkan/rendering/back_end", PropertyInfo(Variant::INT, "rendering/vulkan/rendering/back_end", - PROPERTY_HINT_ENUM, "ForwardClustered,ForwardMobile")); + PROPERTY_HINT_ENUM, "Forward Clustered (Supports Desktop Only),Forward Mobile (Supports Desktop and Mobile)")); GLOBAL_DEF("rendering/shader_compiler/shader_cache/enabled", true); GLOBAL_DEF("rendering/shader_compiler/shader_cache/compress", true); @@ -2814,6 +2830,11 @@ RenderingServer::RenderingServer() { ProjectSettings::get_singleton()->set_custom_property_info("rendering/anti_aliasing/screen_space_roughness_limiter/amount", PropertyInfo(Variant::FLOAT, "rendering/anti_aliasing/screen_space_roughness_limiter/amount", PROPERTY_HINT_RANGE, "0.01,4.0,0.01")); ProjectSettings::get_singleton()->set_custom_property_info("rendering/anti_aliasing/screen_space_roughness_limiter/limit", PropertyInfo(Variant::FLOAT, "rendering/anti_aliasing/screen_space_roughness_limiter/limit", PROPERTY_HINT_RANGE, "0.01,1.0,0.01")); + GLOBAL_DEF("rendering/textures/decals/filter", DECAL_FILTER_LINEAR_MIPMAPS); + ProjectSettings::get_singleton()->set_custom_property_info("rendering/textures/decals/filter", PropertyInfo(Variant::INT, "rendering/textures/decals/filter", PROPERTY_HINT_ENUM, "Nearest (Fast),Nearest+Mipmaps,Linear,Linear+Mipmaps,Linear+Mipmaps Anisotropic (Slow)")); + GLOBAL_DEF("rendering/textures/light_projectors/filter", LIGHT_PROJECTOR_FILTER_LINEAR_MIPMAPS); + ProjectSettings::get_singleton()->set_custom_property_info("rendering/textures/light_projectors/filter", PropertyInfo(Variant::INT, "rendering/textures/light_projectors/filter", PROPERTY_HINT_ENUM, "Nearest (Fast),Nearest+Mipmaps,Linear,Linear+Mipmaps,Linear+Mipmaps Anisotropic (Slow)")); + GLOBAL_DEF_RST("rendering/occlusion_culling/occlusion_rays_per_thread", 512); GLOBAL_DEF_RST("rendering/occlusion_culling/bvh_build_quality", 2); ProjectSettings::get_singleton()->set_custom_property_info("rendering/occlusion_culling/bvh_build_quality", PropertyInfo(Variant::INT, "rendering/occlusion_culling/bvh_build_quality", PROPERTY_HINT_ENUM, "Low,Medium,High")); diff --git a/servers/rendering_server.h b/servers/rendering_server.h index 0d01d4a2bd..28aee1b575 100644 --- a/servers/rendering_server.h +++ b/servers/rendering_server.h @@ -78,7 +78,8 @@ public: CANVAS_ITEM_Z_MAX = 4096, MAX_GLOW_LEVELS = 7, MAX_CURSORS = 8, - MAX_2D_DIRECTIONAL_LIGHTS = 8 + MAX_2D_DIRECTIONAL_LIGHTS = 8, + MAX_MESH_SURFACES = 256 }; /* TEXTURE API */ @@ -482,6 +483,17 @@ public: virtual void shadows_quality_set(ShadowQuality p_quality) = 0; virtual void directional_shadow_quality_set(ShadowQuality p_quality) = 0; + + enum LightProjectorFilter { + LIGHT_PROJECTOR_FILTER_NEAREST, + LIGHT_PROJECTOR_FILTER_NEAREST_MIPMAPS, + LIGHT_PROJECTOR_FILTER_LINEAR, + LIGHT_PROJECTOR_FILTER_LINEAR_MIPMAPS, + LIGHT_PROJECTOR_FILTER_LINEAR_MIPMAPS_ANISOTROPIC, + }; + + virtual void light_projectors_set_filter(LightProjectorFilter p_filter) = 0; + /* PROBE API */ virtual RID reflection_probe_create() = 0; @@ -534,6 +546,16 @@ public: virtual void decal_set_fade(RID p_decal, float p_above, float p_below) = 0; virtual void decal_set_normal_fade(RID p_decal, float p_fade) = 0; + enum DecalFilter { + DECAL_FILTER_NEAREST, + DECAL_FILTER_NEAREST_MIPMAPS, + DECAL_FILTER_LINEAR, + DECAL_FILTER_LINEAR_MIPMAPS, + DECAL_FILTER_LINEAR_MIPMAPS_ANISOTROPIC, + }; + + virtual void decals_set_filter(DecalFilter p_quality) = 0; + /* VOXEL GI API */ virtual RID voxel_gi_create() = 0; @@ -1498,10 +1520,12 @@ VARIANT_ENUM_CAST(RenderingServer::LightParam); VARIANT_ENUM_CAST(RenderingServer::LightBakeMode); VARIANT_ENUM_CAST(RenderingServer::LightOmniShadowMode); VARIANT_ENUM_CAST(RenderingServer::LightDirectionalShadowMode); +VARIANT_ENUM_CAST(RenderingServer::LightProjectorFilter); VARIANT_ENUM_CAST(RenderingServer::ReflectionProbeUpdateMode); VARIANT_ENUM_CAST(RenderingServer::ReflectionProbeAmbientMode); VARIANT_ENUM_CAST(RenderingServer::VoxelGIQuality); VARIANT_ENUM_CAST(RenderingServer::DecalTexture); +VARIANT_ENUM_CAST(RenderingServer::DecalFilter); VARIANT_ENUM_CAST(RenderingServer::ParticlesMode); VARIANT_ENUM_CAST(RenderingServer::ParticlesTransformAlign); VARIANT_ENUM_CAST(RenderingServer::ParticlesDrawOrder); diff --git a/servers/text_server.cpp b/servers/text_server.cpp index 97cfe828f0..1491368109 100644 --- a/servers/text_server.cpp +++ b/servers/text_server.cpp @@ -712,7 +712,7 @@ Vector<Vector2i> TextServer::shaped_text_get_line_breaks(RID p_shaped, float p_w return lines; } -Vector<Vector2i> TextServer::shaped_text_get_word_breaks(RID p_shaped) const { +Vector<Vector2i> TextServer::shaped_text_get_word_breaks(RID p_shaped, int p_grapheme_flags) const { Vector<Vector2i> words; const_cast<TextServer *>(this)->shaped_text_update_justification_ops(p_shaped); @@ -726,7 +726,7 @@ Vector<Vector2i> TextServer::shaped_text_get_word_breaks(RID p_shaped) const { for (int i = 0; i < l_size; i++) { if (l_gl[i].count > 0) { - if (((l_gl[i].flags & GRAPHEME_IS_SPACE) == GRAPHEME_IS_SPACE) || ((l_gl[i].flags & GRAPHEME_IS_PUNCTUATION) == GRAPHEME_IS_PUNCTUATION)) { + if ((l_gl[i].flags & p_grapheme_flags) != 0) { words.push_back(Vector2i(word_start, l_gl[i].start)); word_start = l_gl[i].end; } diff --git a/servers/text_server.h b/servers/text_server.h index 06020d3ffd..4c2ada7fc9 100644 --- a/servers/text_server.h +++ b/servers/text_server.h @@ -87,7 +87,8 @@ public: GRAPHEME_IS_BREAK_SOFT = 1 << 5, // Is line break (optional break, e.g. space). GRAPHEME_IS_TAB = 1 << 6, // Is tab or vertical tab. GRAPHEME_IS_ELONGATION = 1 << 7, // Elongation (e.g. kashida), glyph can be duplicated or truncated to fit line to width. - GRAPHEME_IS_PUNCTUATION = 1 << 8 // Punctuation (can be used as word break, but not line break or justifiction). + GRAPHEME_IS_PUNCTUATION = 1 << 8, // Punctuation, except underscore (can be used as word break, but not line break or justifiction). + GRAPHEME_IS_UNDERSCORE = 1 << 9, // Underscore (can be used as word break). }; enum Hinting { @@ -354,10 +355,9 @@ public: virtual Vector<Vector2i> shaped_text_get_line_breaks_adv(RID p_shaped, const Vector<float> &p_width, int p_start = 0, bool p_once = true, uint8_t /*TextBreakFlag*/ p_break_flags = BREAK_MANDATORY | BREAK_WORD_BOUND) const; virtual Vector<Vector2i> shaped_text_get_line_breaks(RID p_shaped, float p_width, int p_start = 0, uint8_t /*TextBreakFlag*/ p_break_flags = BREAK_MANDATORY | BREAK_WORD_BOUND) const; - virtual Vector<Vector2i> shaped_text_get_word_breaks(RID p_shaped) const; + virtual Vector<Vector2i> shaped_text_get_word_breaks(RID p_shaped, int p_grapheme_flags = GRAPHEME_IS_SPACE | GRAPHEME_IS_PUNCTUATION) const; virtual void shaped_text_overrun_trim_to_width(RID p_shaped, float p_width, uint8_t p_clip_flags) = 0; - virtual Array shaped_text_get_objects(RID p_shaped) const = 0; virtual Rect2 shaped_text_get_object_rect(RID p_shaped, Variant p_key) const = 0; diff --git a/servers/xr/xr_interface.h b/servers/xr/xr_interface.h index 6031bd7003..6b248c9554 100644 --- a/servers/xr/xr_interface.h +++ b/servers/xr/xr_interface.h @@ -41,7 +41,7 @@ struct BlitToScreen; /** @author Bastiaan Olij <mux213@gmail.com> - The XR interface is a template class ontop of which we build interface to different AR, VR and tracking SDKs. + The XR interface is a template class on top of which we build interface to different AR, VR and tracking SDKs. The idea is that we subclass this class, implement the logic, and then instantiate a singleton of each interface when Godot starts. These instances do not initialize themselves but register themselves with the AR/VR server. diff --git a/servers/xr_server.cpp b/servers/xr_server.cpp index b12fff319d..c27656047f 100644 --- a/servers/xr_server.cpp +++ b/servers/xr_server.cpp @@ -164,7 +164,7 @@ void XRServer::add_interface(const Ref<XRInterface> &p_interface) { }; interfaces.push_back(p_interface); - emit_signal("interface_added", p_interface->get_name()); + emit_signal(SNAME("interface_added"), p_interface->get_name()); }; void XRServer::remove_interface(const Ref<XRInterface> &p_interface) { @@ -182,7 +182,7 @@ void XRServer::remove_interface(const Ref<XRInterface> &p_interface) { print_verbose("XR: Removed interface" + p_interface->get_name()); - emit_signal("interface_removed", p_interface->get_name()); + emit_signal(SNAME("interface_removed"), p_interface->get_name()); interfaces.remove(idx); }; @@ -269,7 +269,7 @@ void XRServer::add_tracker(Ref<XRPositionalTracker> p_tracker) { ERR_FAIL_COND(p_tracker.is_null()); trackers.push_back(p_tracker); - emit_signal("tracker_added", p_tracker->get_tracker_name(), p_tracker->get_tracker_type(), p_tracker->get_tracker_id()); + emit_signal(SNAME("tracker_added"), p_tracker->get_tracker_name(), p_tracker->get_tracker_type(), p_tracker->get_tracker_id()); }; void XRServer::remove_tracker(Ref<XRPositionalTracker> p_tracker) { @@ -285,7 +285,7 @@ void XRServer::remove_tracker(Ref<XRPositionalTracker> p_tracker) { ERR_FAIL_COND(idx == -1); - emit_signal("tracker_removed", p_tracker->get_tracker_name(), p_tracker->get_tracker_type(), p_tracker->get_tracker_id()); + emit_signal(SNAME("tracker_removed"), p_tracker->get_tracker_name(), p_tracker->get_tracker_type(), p_tracker->get_tracker_id()); trackers.remove(idx); }; diff --git a/tests/test_class_db.h b/tests/test_class_db.h index 29edf5a4a0..ea680da5d6 100644 --- a/tests/test_class_db.h +++ b/tests/test_class_db.h @@ -108,9 +108,9 @@ struct ExposedClass { List<SignalData> signals_; const PropertyData *find_property_by_name(const StringName &p_name) const { - for (const List<PropertyData>::Element *E = properties.front(); E; E = E->next()) { - if (E->get().name == p_name) { - return &E->get(); + for (const PropertyData &E : properties) { + if (E.name == p_name) { + return &E; } } @@ -118,9 +118,9 @@ struct ExposedClass { } const MethodData *find_method_by_name(const StringName &p_name) const { - for (const List<MethodData>::Element *E = methods.front(); E; E = E->next()) { - if (E->get().name == p_name) { - return &E->get(); + for (const MethodData &E : methods) { + if (E.name == p_name) { + return &E; } } @@ -395,8 +395,8 @@ void validate_method(const Context &p_context, const ExposedClass &p_class, cons } } - for (const List<ArgumentData>::Element *F = p_method.arguments.front(); F; F = F->next()) { - const ArgumentData &arg = F->get(); + for (const ArgumentData &F : p_method.arguments) { + const ArgumentData &arg = F; const ExposedClass *arg_class = p_context.find_exposed_class(arg.type); if (arg_class) { @@ -427,8 +427,8 @@ void validate_method(const Context &p_context, const ExposedClass &p_class, cons } void validate_signal(const Context &p_context, const ExposedClass &p_class, const SignalData &p_signal) { - for (const List<ArgumentData>::Element *F = p_signal.arguments.front(); F; F = F->next()) { - const ArgumentData &arg = F->get(); + for (const ArgumentData &F : p_signal.arguments) { + const ArgumentData &arg = F; const ExposedClass *arg_class = p_context.find_exposed_class(arg.type); if (arg_class) { @@ -469,16 +469,16 @@ void validate_class(const Context &p_context, const ExposedClass &p_exposed_clas TEST_FAIL_COND((is_derived_type && !p_context.exposed_classes.has(p_exposed_class.base)), "Base type '", p_exposed_class.base.operator String(), "' does not exist, for class '", p_exposed_class.name, "'."); - for (const List<PropertyData>::Element *F = p_exposed_class.properties.front(); F; F = F->next()) { - validate_property(p_context, p_exposed_class, F->get()); + for (const PropertyData &F : p_exposed_class.properties) { + validate_property(p_context, p_exposed_class, F); } - for (const List<MethodData>::Element *F = p_exposed_class.methods.front(); F; F = F->next()) { - validate_method(p_context, p_exposed_class, F->get()); + for (const MethodData &F : p_exposed_class.methods) { + validate_method(p_context, p_exposed_class, F); } - for (const List<SignalData>::Element *F = p_exposed_class.signals_.front(); F; F = F->next()) { - validate_signal(p_context, p_exposed_class, F->get()); + for (const SignalData &F : p_exposed_class.signals_) { + validate_signal(p_context, p_exposed_class, F); } } @@ -526,9 +526,7 @@ void add_exposed_classes(Context &r_context) { Map<StringName, StringName> accessor_methods; - for (const List<PropertyInfo>::Element *E = property_list.front(); E; E = E->next()) { - const PropertyInfo &property = E->get(); - + for (const PropertyInfo &property : property_list) { if (property.usage & PROPERTY_USAGE_GROUP || property.usage & PROPERTY_USAGE_SUBGROUP || property.usage & PROPERTY_USAGE_CATEGORY) { continue; } @@ -561,8 +559,8 @@ void add_exposed_classes(Context &r_context) { ClassDB::get_method_list(class_name, &method_list, true); method_list.sort(); - for (List<MethodInfo>::Element *E = method_list.front(); E; E = E->next()) { - const MethodInfo &method_info = E->get(); + for (const MethodInfo &E : method_list) { + const MethodInfo &method_info = E; int argc = method_info.arguments.size(); @@ -667,8 +665,8 @@ void add_exposed_classes(Context &r_context) { // Methods starting with an underscore are ignored unless they're virtual or used as a property setter or getter. if (!method.is_virtual && String(method.name)[0] == '_') { - for (const List<PropertyData>::Element *F = exposed_class.properties.front(); F; F = F->next()) { - const PropertyData &prop = F->get(); + for (const PropertyData &F : exposed_class.properties) { + const PropertyData &prop = F; if (prop.setter == method.name || prop.getter == method.name) { exposed_class.methods.push_back(method); @@ -752,8 +750,8 @@ void add_exposed_classes(Context &r_context) { enum_.name = *k; const List<StringName> &enum_constants = enum_map.get(*k); - for (const List<StringName>::Element *E = enum_constants.front(); E; E = E->next()) { - const StringName &constant_name = E->get(); + for (const StringName &E : enum_constants) { + const StringName &constant_name = E; TEST_FAIL_COND(String(constant_name).find("::") != -1, "Enum constant contains '::', check bindings to remove the scope: '", String(class_name), ".", String(enum_.name), ".", String(constant_name), "'."); @@ -774,12 +772,12 @@ void add_exposed_classes(Context &r_context) { r_context.enum_types.push_back(String(class_name) + "." + String(*k)); } - for (const List<String>::Element *E = constants.front(); E; E = E->next()) { - const String &constant_name = E->get(); + for (const String &E : constants) { + const String &constant_name = E; TEST_FAIL_COND(constant_name.find("::") != -1, "Constant contains '::', check bindings to remove the scope: '", String(class_name), ".", constant_name, "'."); - int *value = class_info->constant_map.getptr(StringName(E->get())); + int *value = class_info->constant_map.getptr(StringName(E)); TEST_FAIL_COND(!value, "Missing constant value: '", String(class_name), ".", String(constant_name), "'."); ConstantData constant; @@ -829,8 +827,8 @@ void add_global_enums(Context &r_context) { } } - for (List<EnumData>::Element *E = r_context.global_enums.front(); E; E = E->next()) { - r_context.enum_types.push_back(E->get().name); + for (const EnumData &E : r_context.global_enums) { + r_context.enum_types.push_back(E.name); } } @@ -840,10 +838,10 @@ void add_global_enums(Context &r_context) { hardcoded_enums.push_back("Vector2i.Axis"); hardcoded_enums.push_back("Vector3.Axis"); hardcoded_enums.push_back("Vector3i.Axis"); - for (List<StringName>::Element *E = hardcoded_enums.front(); E; E = E->next()) { + for (const StringName &E : hardcoded_enums) { // These enums are not generated and must be written manually (e.g.: Vector3.Axis) // Here, we assume core types do not begin with underscore - r_context.enum_types.push_back(E->get()); + r_context.enum_types.push_back(E); } } diff --git a/tests/test_gui.cpp b/tests/test_gui.cpp index b83bd10af4..0ec8aa78c4 100644 --- a/tests/test_gui.cpp +++ b/tests/test_gui.cpp @@ -217,7 +217,7 @@ public: richtext->add_text("faeries.\n"); richtext->pop(); richtext->add_text("In this new episode, we will attempt to "); - richtext->push_font(richtext->get_theme_font("mono_font", "Fonts")); + richtext->push_font(richtext->get_theme_font(SNAME("mono_font"), SNAME("Fonts"))); richtext->push_color(Color(0.7, 0.5, 1.0)); richtext->add_text("deliver something nice"); richtext->pop(); diff --git a/tests/test_math.cpp b/tests/test_math.cpp index 67d9a52539..d0b9fdef4b 100644 --- a/tests/test_math.cpp +++ b/tests/test_math.cpp @@ -549,8 +549,8 @@ MainLoop *test() { List<StringName> tl; ClassDB::get_class_list(&tl); - for (List<StringName>::Element *E = tl.front(); E; E = E->next()) { - Vector<uint8_t> m5b = E->get().operator String().md5_buffer(); + for (const StringName &E : tl) { + Vector<uint8_t> m5b = E.operator String().md5_buffer(); hashes.push_back(hashes.size()); } diff --git a/tests/test_object.h b/tests/test_object.h index 36f9ef2a51..a18adf31b6 100644 --- a/tests/test_object.h +++ b/tests/test_object.h @@ -139,7 +139,7 @@ TEST_CASE("[Object] Metadata") { Color(object.get_meta(meta_path)).is_equal_approx(Color(0, 1, 0)), "The returned object metadata after setting should match the expected value."); - List<String> meta_list; + List<StringName> meta_list; object.get_meta_list(&meta_list); CHECK_MESSAGE( meta_list.size() == 1, @@ -154,7 +154,7 @@ TEST_CASE("[Object] Metadata") { "The returned object metadata after removing should match the expected value."); ERR_PRINT_ON; - List<String> meta_list2; + List<StringName> meta_list2; object.get_meta_list(&meta_list2); CHECK_MESSAGE( meta_list2.size() == 0, diff --git a/tests/test_physics_2d.cpp b/tests/test_physics_2d.cpp index a9e2e92b34..40dc74e89c 100644 --- a/tests/test_physics_2d.cpp +++ b/tests/test_physics_2d.cpp @@ -386,7 +386,7 @@ public: //_add_plane(Vector2(-1,0).normalized(),-600); } - virtual bool process(float p_time) override { + virtual bool process(double p_time) override { return false; } virtual void finalize() override { diff --git a/tests/test_physics_3d.cpp b/tests/test_physics_3d.cpp index 4488e4bf64..ed49b60c71 100644 --- a/tests/test_physics_3d.cpp +++ b/tests/test_physics_3d.cpp @@ -313,7 +313,7 @@ public: test_fall(); quit = false; } - virtual bool physics_process(float p_time) override { + virtual bool physics_process(double p_time) override { if (mover.is_valid()) { static real_t joy_speed = 10; PhysicsServer3D *ps = PhysicsServer3D::get_singleton(); @@ -399,7 +399,7 @@ public: create_static_plane(Plane(Vector3(0, 1, 0), -1)); } - virtual bool process(float p_time) override { + virtual bool process(double p_time) override { return false; } diff --git a/tests/test_render.cpp b/tests/test_render.cpp index fe223ca258..beff86dd83 100644 --- a/tests/test_render.cpp +++ b/tests/test_render.cpp @@ -199,7 +199,7 @@ public: ofs = 0; quit = false; } - virtual bool iteration(float p_time) { + virtual bool iteration(double p_time) { RenderingServer *vs = RenderingServer::get_singleton(); //Transform3D t; //t.rotate(Vector3(0, 1, 0), ofs); @@ -210,12 +210,12 @@ public: //return quit; - for (List<InstanceInfo>::Element *E = instances.front(); E; E = E->next()) { - Transform3D pre(Basis(E->get().rot_axis, ofs), Vector3()); - vs->instance_set_transform(E->get().instance, pre * E->get().base); + for (const InstanceInfo &E : instances) { + Transform3D pre(Basis(E.rot_axis, ofs), Vector3()); + vs->instance_set_transform(E.instance, pre * E.base); /* if( !E->next() ) { - vs->free( E->get().instance ); + vs->free( E.instance ); instances.erase(E ); }*/ } @@ -223,7 +223,7 @@ public: return quit; } - virtual bool idle(float p_time) { + virtual bool idle(double p_time) { return quit; } diff --git a/tests/test_text_server.h b/tests/test_text_server.h index 3d700f8ec4..cac022e33f 100644 --- a/tests/test_text_server.h +++ b/tests/test_text_server.h @@ -55,7 +55,7 @@ TEST_SUITE("[[TextServer]") { for (int i = 0; i < TextServerManager::get_interface_count(); i++) { TextServer *ts = TextServerManager::initialize(i, err); - RID font = ts->create_font_memory(_font_NotoSansUI_Regular, _font_NotoSansUI_Regular_size, "ttf"); + RID font = ts->create_font_memory(_font_NotoSans_Regular, _font_NotoSans_Regular_size, "ttf"); TEST_FAIL_COND(font == RID(), "Loading font failed."); ts->free(font); } @@ -66,7 +66,7 @@ TEST_SUITE("[[TextServer]") { TextServer *ts = TextServerManager::initialize(i, err); Vector<RID> font; - font.push_back(ts->create_font_memory(_font_NotoSansUI_Regular, _font_NotoSansUI_Regular_size, "ttf")); + font.push_back(ts->create_font_memory(_font_NotoSans_Regular, _font_NotoSans_Regular_size, "ttf")); font.push_back(ts->create_font_memory(_font_NotoSansThaiUI_Regular, _font_NotoSansThaiUI_Regular_size, "ttf")); String test = U"คนอ้วน khon uan ראה"; @@ -112,7 +112,7 @@ TEST_SUITE("[[TextServer]") { } Vector<RID> font; - font.push_back(ts->create_font_memory(_font_NotoSansUI_Regular, _font_NotoSansUI_Regular_size, "ttf")); + font.push_back(ts->create_font_memory(_font_NotoSans_Regular, _font_NotoSans_Regular_size, "ttf")); font.push_back(ts->create_font_memory(_font_NotoNaskhArabicUI_Regular, _font_NotoNaskhArabicUI_Regular_size, "ttf")); String test = U"Arabic (اَلْعَرَبِيَّةُ, al-ʿarabiyyah)"; @@ -156,7 +156,7 @@ TEST_SUITE("[[TextServer]") { // 5^ 10^ Vector<RID> font; - font.push_back(ts->create_font_memory(_font_NotoSansUI_Regular, _font_NotoSansUI_Regular_size, "ttf")); + font.push_back(ts->create_font_memory(_font_NotoSans_Regular, _font_NotoSans_Regular_size, "ttf")); font.push_back(ts->create_font_memory(_font_NotoSansThaiUI_Regular, _font_NotoSansThaiUI_Regular_size, "ttf")); RID ctx = ts->create_shaped_text(); @@ -186,7 +186,7 @@ TEST_SUITE("[[TextServer]") { TextServer *ts = TextServerManager::initialize(i, err); Vector<RID> font; - font.push_back(ts->create_font_memory(_font_NotoSansUI_Regular, _font_NotoSansUI_Regular_size, "ttf")); + font.push_back(ts->create_font_memory(_font_NotoSans_Regular, _font_NotoSans_Regular_size, "ttf")); font.push_back(ts->create_font_memory(_font_NotoNaskhArabicUI_Regular, _font_NotoNaskhArabicUI_Regular_size, "ttf")); String test_1 = U"الحمد"; diff --git a/thirdparty/README.md b/thirdparty/README.md index 31e88180d0..3f28838fac 100644 --- a/thirdparty/README.md +++ b/thirdparty/README.md @@ -123,9 +123,9 @@ Files extracted from upstream source: ## fonts -- `NotoSans*.ttf`, `NotoNaskhArabicUI_Regular.ttf`: - * Upstream: https://github.com/googlei18n/noto-fonts - * Version: 1.06 (2017) +- `NotoSans*.ttf`, `NotoNaskhArabicUI_*.ttf`: + * Upstream: https://github.com/googlefonts/noto-fonts + * Version: v2017-10-24-phase3-second-cleanup * License: OFL-1.1 * Comment: Use UI font variant if available, because it has tight vertical metrics and good for UI. @@ -347,21 +347,21 @@ changes are marked with `// -- GODOT --` comments. ## mbedtls - Upstream: https://tls.mbed.org/ -- Version: 2.16.10 (d61fa61bef06b64132e3490543c81b8ee40fbee3, 2021) +- Version: 2.16.11 (aa1d4e097342af799ba80dfb13640efef498227c, 2021) - License: Apache 2.0 File extracted from upstream release tarball: -- All `*.h` from `include/mbedtls/` to `thirdparty/mbedtls/include/mbedtls/` -- All `*.c` from `library/` to `thirdparty/mbedtls/library/` -- LICENSE and apache-2.0.txt files -- Applied the patch in `thirdparty/mbedtls/patches/1453.diff` (PR 1453). - Soon to be merged upstream. Check it out at next update. +- All `*.h` from `include/mbedtls/` to `thirdparty/mbedtls/include/mbedtls/`. +- All `*.c` from `library/` to `thirdparty/mbedtls/library/`. +- `LICENSE` and `apache-2.0.txt` files. +- Applied the patch in `thirdparty/mbedtls/patches/1453.diff` (upstream PR: + https://github.com/ARMmbed/mbedtls/pull/1453). - Applied the patch in `thirdparty/mbedtls/patches/padlock.diff`. This disables VIA padlock support which defines a symbol `unsupported` which clashes with a pre-defined symbol. -- Added 2 files `godot_core_mbedtls_platform.{c,h}` providing configuration - for light bundling with core. +- Added 2 files `godot_core_mbedtls_platform.c` and `godot_core_mbedtls_config.h` + providing configuration for light bundling with core. ## meshoptimizer diff --git a/thirdparty/enet/enet/godot_ext.h b/thirdparty/enet/enet/godot_ext.h index 84a23b1c85..648f3d2f24 100644 --- a/thirdparty/enet/enet/godot_ext.h +++ b/thirdparty/enet/enet/godot_ext.h @@ -11,8 +11,8 @@ */ ENET_API void enet_address_set_ip(ENetAddress * address, const uint8_t * ip, size_t size); -ENET_API void enet_host_dtls_server_setup (ENetHost *, void *, void *); -ENET_API void enet_host_dtls_client_setup (ENetHost *, void *, uint8_t, const char *); +ENET_API int enet_host_dtls_server_setup (ENetHost *, void *, void *); +ENET_API int enet_host_dtls_client_setup (ENetHost *, void *, uint8_t, const char *); ENET_API void enet_host_refuse_new_connections (ENetHost *, int); #endif // __ENET_GODOT_EXT_H__ diff --git a/thirdparty/enet/godot.cpp b/thirdparty/enet/godot.cpp index f6a56f1f5d..d0b381ea51 100644 --- a/thirdparty/enet/godot.cpp +++ b/thirdparty/enet/godot.cpp @@ -52,6 +52,7 @@ public: virtual int set_option(ENetSocketOption p_option, int p_value) = 0; virtual void close() = 0; virtual void set_refuse_new_connections(bool p_enable) {} /* Only used by dtls server */ + virtual bool can_upgrade() { return false; } /* Only true in ENetUDP */ virtual ~ENetGodotSocket() {} }; @@ -79,6 +80,10 @@ public: sock->close(); } + bool can_upgrade() { + return true; + } + Error bind(IPAddress p_ip, uint16_t p_port) { local_address = p_ip; bound = true; @@ -86,7 +91,11 @@ public: } Error get_socket_address(IPAddress *r_ip, uint16_t *r_port) { - return sock->get_socket_address(r_ip, r_port); + Error err = sock->get_socket_address(r_ip, r_port); + if (bound) { + *r_ip = local_address; + } + return err; } Error sendto(const uint8_t *p_buffer, int p_len, int &r_sent, IPAddress p_ip, uint16_t p_port) { @@ -195,7 +204,9 @@ public: Error sendto(const uint8_t *p_buffer, int p_len, int &r_sent, IPAddress p_ip, uint16_t p_port) { if (!connected) { udp->connect_to_host(p_ip, p_port); - dtls->connect_to_peer(udp, verify, for_hostname, cert); + if (dtls->connect_to_peer(udp, verify, for_hostname, cert)) { + return FAILED; + } connected = true; } dtls->poll(); @@ -353,8 +364,8 @@ public: } // Remove disconnected peers from map. - for (List<String>::Element *E = remove.front(); E; E = E->next()) { - peers.erase(E->get()); + for (String &E : remove) { + peers.erase(E); } return err; // OK, ERR_BUSY, or possibly an error. @@ -424,16 +435,24 @@ ENetSocket enet_socket_create(ENetSocketType type) { return socket; } -void enet_host_dtls_server_setup(ENetHost *host, void *p_key, void *p_cert) { - ENetUDP *sock = (ENetUDP *)host->socket; - host->socket = memnew(ENetDTLSServer(sock, Ref<CryptoKey>((CryptoKey *)p_key), Ref<X509Certificate>((X509Certificate *)p_cert))); +int enet_host_dtls_server_setup(ENetHost *host, void *p_key, void *p_cert) { + ENetGodotSocket *sock = (ENetGodotSocket *)host->socket; + if (!sock->can_upgrade()) { + return -1; + } + host->socket = memnew(ENetDTLSServer((ENetUDP *)sock, Ref<CryptoKey>((CryptoKey *)p_key), Ref<X509Certificate>((X509Certificate *)p_cert))); memdelete(sock); + return 0; } -void enet_host_dtls_client_setup(ENetHost *host, void *p_cert, uint8_t p_verify, const char *p_for_hostname) { - ENetUDP *sock = (ENetUDP *)host->socket; - host->socket = memnew(ENetDTLSClient(sock, Ref<X509Certificate>((X509Certificate *)p_cert), p_verify, String(p_for_hostname))); +int enet_host_dtls_client_setup(ENetHost *host, void *p_cert, uint8_t p_verify, const char *p_for_hostname) { + ENetGodotSocket *sock = (ENetGodotSocket *)host->socket; + if (!sock->can_upgrade()) { + return -1; + } + host->socket = memnew(ENetDTLSClient((ENetUDP *)sock, Ref<X509Certificate>((X509Certificate *)p_cert), p_verify, String::utf8(p_for_hostname))); memdelete(sock); + return 0; } void enet_host_refuse_new_connections(ENetHost *host, int p_refuse) { diff --git a/thirdparty/fonts/NotoNaskhArabicUI_Bold.ttf b/thirdparty/fonts/NotoNaskhArabicUI_Bold.ttf Binary files differnew file mode 100644 index 0000000000..5576af7fee --- /dev/null +++ b/thirdparty/fonts/NotoNaskhArabicUI_Bold.ttf diff --git a/thirdparty/fonts/NotoNaskhArabicUI_Regular.ttf b/thirdparty/fonts/NotoNaskhArabicUI_Regular.ttf Binary files differindex 67713c697e..9b7a93d136 100644 --- a/thirdparty/fonts/NotoNaskhArabicUI_Regular.ttf +++ b/thirdparty/fonts/NotoNaskhArabicUI_Regular.ttf diff --git a/thirdparty/fonts/NotoSansBengaliUI_Bold.ttf b/thirdparty/fonts/NotoSansBengaliUI_Bold.ttf Binary files differnew file mode 100644 index 0000000000..dc61efefd5 --- /dev/null +++ b/thirdparty/fonts/NotoSansBengaliUI_Bold.ttf diff --git a/thirdparty/fonts/NotoSansBengali_Regular.ttf b/thirdparty/fonts/NotoSansBengaliUI_Regular.ttf Binary files differindex daeabcf817..d43c292ad6 100644 --- a/thirdparty/fonts/NotoSansBengali_Regular.ttf +++ b/thirdparty/fonts/NotoSansBengaliUI_Regular.ttf diff --git a/thirdparty/fonts/NotoSansDevanagariUI_Bold.ttf b/thirdparty/fonts/NotoSansDevanagariUI_Bold.ttf Binary files differnew file mode 100644 index 0000000000..74791aa469 --- /dev/null +++ b/thirdparty/fonts/NotoSansDevanagariUI_Bold.ttf diff --git a/thirdparty/fonts/NotoSansDevanagariUI_Regular.ttf b/thirdparty/fonts/NotoSansDevanagariUI_Regular.ttf Binary files differindex 1f9fb2e857..e48dced0c9 100644 --- a/thirdparty/fonts/NotoSansDevanagariUI_Regular.ttf +++ b/thirdparty/fonts/NotoSansDevanagariUI_Regular.ttf diff --git a/thirdparty/fonts/NotoSansGeorgian_Bold.ttf b/thirdparty/fonts/NotoSansGeorgian_Bold.ttf Binary files differnew file mode 100644 index 0000000000..5443d04cfa --- /dev/null +++ b/thirdparty/fonts/NotoSansGeorgian_Bold.ttf diff --git a/thirdparty/fonts/NotoSansHebrew_Bold.ttf b/thirdparty/fonts/NotoSansHebrew_Bold.ttf Binary files differnew file mode 100644 index 0000000000..08ef5dc749 --- /dev/null +++ b/thirdparty/fonts/NotoSansHebrew_Bold.ttf diff --git a/thirdparty/fonts/NotoSansHebrew_Regular.ttf b/thirdparty/fonts/NotoSansHebrew_Regular.ttf Binary files differindex 5027f5c228..0a89e9d21f 100644 --- a/thirdparty/fonts/NotoSansHebrew_Regular.ttf +++ b/thirdparty/fonts/NotoSansHebrew_Regular.ttf diff --git a/thirdparty/fonts/NotoSansMalayalamUI_Bold.ttf b/thirdparty/fonts/NotoSansMalayalamUI_Bold.ttf Binary files differnew file mode 100644 index 0000000000..42e5d56f3f --- /dev/null +++ b/thirdparty/fonts/NotoSansMalayalamUI_Bold.ttf diff --git a/thirdparty/fonts/NotoSansOriyaUI_Bold.ttf b/thirdparty/fonts/NotoSansOriyaUI_Bold.ttf Binary files differnew file mode 100644 index 0000000000..36323f79ef --- /dev/null +++ b/thirdparty/fonts/NotoSansOriyaUI_Bold.ttf diff --git a/thirdparty/fonts/NotoSansSinhalaUI_Bold.ttf b/thirdparty/fonts/NotoSansSinhalaUI_Bold.ttf Binary files differnew file mode 100644 index 0000000000..ecfff97e05 --- /dev/null +++ b/thirdparty/fonts/NotoSansSinhalaUI_Bold.ttf diff --git a/thirdparty/fonts/NotoSansTamilUI_Bold.ttf b/thirdparty/fonts/NotoSansTamilUI_Bold.ttf Binary files differnew file mode 100644 index 0000000000..16bcd57081 --- /dev/null +++ b/thirdparty/fonts/NotoSansTamilUI_Bold.ttf diff --git a/thirdparty/fonts/NotoSansTeluguUI_Bold.ttf b/thirdparty/fonts/NotoSansTeluguUI_Bold.ttf Binary files differnew file mode 100644 index 0000000000..16ac368795 --- /dev/null +++ b/thirdparty/fonts/NotoSansTeluguUI_Bold.ttf diff --git a/thirdparty/fonts/NotoSansThaiUI_Bold.ttf b/thirdparty/fonts/NotoSansThaiUI_Bold.ttf Binary files differnew file mode 100644 index 0000000000..5d998f9215 --- /dev/null +++ b/thirdparty/fonts/NotoSansThaiUI_Bold.ttf diff --git a/thirdparty/fonts/NotoSansThaiUI_Regular.ttf b/thirdparty/fonts/NotoSansThaiUI_Regular.ttf Binary files differindex 9c50a1b8f5..8e317961d1 100644 --- a/thirdparty/fonts/NotoSansThaiUI_Regular.ttf +++ b/thirdparty/fonts/NotoSansThaiUI_Regular.ttf diff --git a/thirdparty/fonts/NotoSansUI_Bold.ttf b/thirdparty/fonts/NotoSansUI_Bold.ttf Binary files differdeleted file mode 100644 index 810450aa81..0000000000 --- a/thirdparty/fonts/NotoSansUI_Bold.ttf +++ /dev/null diff --git a/thirdparty/fonts/NotoSansUI_Regular.ttf b/thirdparty/fonts/NotoSansUI_Regular.ttf Binary files differdeleted file mode 100644 index 65b29fcff1..0000000000 --- a/thirdparty/fonts/NotoSansUI_Regular.ttf +++ /dev/null diff --git a/thirdparty/fonts/NotoSans_Bold.ttf b/thirdparty/fonts/NotoSans_Bold.ttf Binary files differnew file mode 100644 index 0000000000..1db7886e94 --- /dev/null +++ b/thirdparty/fonts/NotoSans_Bold.ttf diff --git a/thirdparty/fonts/NotoSans_Regular.ttf b/thirdparty/fonts/NotoSans_Regular.ttf Binary files differnew file mode 100644 index 0000000000..0a01a062f0 --- /dev/null +++ b/thirdparty/fonts/NotoSans_Regular.ttf diff --git a/thirdparty/mbedtls/include/mbedtls/aria.h b/thirdparty/mbedtls/include/mbedtls/aria.h index 13763d4200..20f43f2256 100644 --- a/thirdparty/mbedtls/include/mbedtls/aria.h +++ b/thirdparty/mbedtls/include/mbedtls/aria.h @@ -88,14 +88,14 @@ /* MBEDTLS_ERR_ARIA_HW_ACCEL_FAILED is deprecated and should not be used. */ #define MBEDTLS_ERR_ARIA_HW_ACCEL_FAILED -0x0058 /**< ARIA hardware accelerator failed. */ -#if !defined(MBEDTLS_ARIA_ALT) -// Regular implementation -// - #ifdef __cplusplus extern "C" { #endif +#if !defined(MBEDTLS_ARIA_ALT) +// Regular implementation +// + /** * \brief The ARIA context-type definition. */ diff --git a/thirdparty/mbedtls/include/mbedtls/bn_mul.h b/thirdparty/mbedtls/include/mbedtls/bn_mul.h index 9615090f91..6f1201bf50 100644 --- a/thirdparty/mbedtls/include/mbedtls/bn_mul.h +++ b/thirdparty/mbedtls/include/mbedtls/bn_mul.h @@ -71,6 +71,46 @@ #include "bignum.h" + +/* + * Conversion macros for embedded constants: + * build lists of mbedtls_mpi_uint's from lists of unsigned char's grouped by 8, 4 or 2 + */ +#if defined(MBEDTLS_HAVE_INT32) + +#define MBEDTLS_BYTES_TO_T_UINT_4( a, b, c, d ) \ + ( (mbedtls_mpi_uint) (a) << 0 ) | \ + ( (mbedtls_mpi_uint) (b) << 8 ) | \ + ( (mbedtls_mpi_uint) (c) << 16 ) | \ + ( (mbedtls_mpi_uint) (d) << 24 ) + +#define MBEDTLS_BYTES_TO_T_UINT_2( a, b ) \ + MBEDTLS_BYTES_TO_T_UINT_4( a, b, 0, 0 ) + +#define MBEDTLS_BYTES_TO_T_UINT_8( a, b, c, d, e, f, g, h ) \ + MBEDTLS_BYTES_TO_T_UINT_4( a, b, c, d ), \ + MBEDTLS_BYTES_TO_T_UINT_4( e, f, g, h ) + +#else /* 64-bits */ + +#define MBEDTLS_BYTES_TO_T_UINT_8( a, b, c, d, e, f, g, h ) \ + ( (mbedtls_mpi_uint) (a) << 0 ) | \ + ( (mbedtls_mpi_uint) (b) << 8 ) | \ + ( (mbedtls_mpi_uint) (c) << 16 ) | \ + ( (mbedtls_mpi_uint) (d) << 24 ) | \ + ( (mbedtls_mpi_uint) (e) << 32 ) | \ + ( (mbedtls_mpi_uint) (f) << 40 ) | \ + ( (mbedtls_mpi_uint) (g) << 48 ) | \ + ( (mbedtls_mpi_uint) (h) << 56 ) + +#define MBEDTLS_BYTES_TO_T_UINT_4( a, b, c, d ) \ + MBEDTLS_BYTES_TO_T_UINT_8( a, b, c, d, 0, 0, 0, 0 ) + +#define MBEDTLS_BYTES_TO_T_UINT_2( a, b ) \ + MBEDTLS_BYTES_TO_T_UINT_8( a, b, 0, 0, 0, 0, 0, 0 ) + +#endif /* bits in mbedtls_mpi_uint */ + #if defined(MBEDTLS_HAVE_ASM) #ifndef asm diff --git a/thirdparty/mbedtls/include/mbedtls/config.h b/thirdparty/mbedtls/include/mbedtls/config.h index 610f5d1f50..d53b457630 100644 --- a/thirdparty/mbedtls/include/mbedtls/config.h +++ b/thirdparty/mbedtls/include/mbedtls/config.h @@ -453,7 +453,7 @@ * be overridden, but the wrapper functions mbedtls_aes_decrypt and mbedtls_aes_encrypt * must stay untouched. * - * \note If you use the AES_xxx_ALT macros, then is is recommended to also set + * \note If you use the AES_xxx_ALT macros, then it is recommended to also set * MBEDTLS_AES_ROM_TABLES in order to help the linker garbage-collect the AES * tables. * diff --git a/thirdparty/mbedtls/include/mbedtls/ecp.h b/thirdparty/mbedtls/include/mbedtls/ecp.h index bdc750eb24..e4a1ed81cf 100644 --- a/thirdparty/mbedtls/include/mbedtls/ecp.h +++ b/thirdparty/mbedtls/include/mbedtls/ecp.h @@ -154,6 +154,40 @@ typedef struct mbedtls_ecp_point } mbedtls_ecp_point; +/* Determine the minimum safe value of MBEDTLS_ECP_MAX_BITS. */ +#if !defined(MBEDTLS_ECP_C) +#define MBEDTLS_ECP_MAX_BITS_MIN 0 +/* Note: the curves must be listed in DECREASING size! */ +#elif defined(MBEDTLS_ECP_DP_SECP521R1_ENABLED) +#define MBEDTLS_ECP_MAX_BITS_MIN 521 +#elif defined(MBEDTLS_ECP_DP_BP512R1_ENABLED) +#define MBEDTLS_ECP_MAX_BITS_MIN 512 +#elif defined(MBEDTLS_ECP_DP_CURVE448_ENABLED) +#define MBEDTLS_ECP_MAX_BITS_MIN 448 +#elif defined(MBEDTLS_ECP_DP_BP384R1_ENABLED) +#define MBEDTLS_ECP_MAX_BITS_MIN 384 +#elif defined(MBEDTLS_ECP_DP_SECP384R1_ENABLED) +#define MBEDTLS_ECP_MAX_BITS_MIN 384 +#elif defined(MBEDTLS_ECP_DP_BP256R1_ENABLED) +#define MBEDTLS_ECP_MAX_BITS_MIN 256 +#elif defined(MBEDTLS_ECP_DP_SECP256K1_ENABLED) +#define MBEDTLS_ECP_MAX_BITS_MIN 256 +#elif defined(MBEDTLS_ECP_DP_SECP256R1_ENABLED) +#define MBEDTLS_ECP_MAX_BITS_MIN 256 +#elif defined(MBEDTLS_ECP_DP_CURVE25519_ENABLED) +#define MBEDTLS_ECP_MAX_BITS_MIN 255 +#elif defined(MBEDTLS_ECP_DP_SECP224K1_ENABLED) +#define MBEDTLS_ECP_MAX_BITS_MIN 225 // n is slightly above 2^224 +#elif defined(MBEDTLS_ECP_DP_SECP224R1_ENABLED) +#define MBEDTLS_ECP_MAX_BITS_MIN 224 +#elif defined(MBEDTLS_ECP_DP_SECP192K1_ENABLED) +#define MBEDTLS_ECP_MAX_BITS_MIN 192 +#elif defined(MBEDTLS_ECP_DP_SECP192R1_ENABLED) +#define MBEDTLS_ECP_MAX_BITS_MIN 192 +#else +#error "MBEDTLS_ECP_C enabled, but no curve?" +#endif + #if !defined(MBEDTLS_ECP_ALT) /* * default mbed TLS elliptic curve arithmetic implementation @@ -228,7 +262,13 @@ mbedtls_ecp_group; * \{ */ -#if !defined(MBEDTLS_ECP_MAX_BITS) +#if defined(MBEDTLS_ECP_MAX_BITS) + +#if MBEDTLS_ECP_MAX_BITS < MBEDTLS_ECP_MAX_BITS_MIN +#error "MBEDTLS_ECP_MAX_BITS is smaller than the largest supported curve" +#endif + +#else /** * The maximum size of the groups, that is, of \c N and \c P. */ diff --git a/thirdparty/mbedtls/include/mbedtls/padlock.h b/thirdparty/mbedtls/include/mbedtls/padlock.h index d8246e2cd0..0e4a6bbf69 100644 --- a/thirdparty/mbedtls/include/mbedtls/padlock.h +++ b/thirdparty/mbedtls/include/mbedtls/padlock.h @@ -98,7 +98,7 @@ extern "C" { * * \param feature The feature to detect * - * \return 1 if CPU has support for the feature, 0 otherwise + * \return non-zero if CPU has support for the feature, 0 otherwise */ int mbedtls_padlock_has_support( int feature ); diff --git a/thirdparty/mbedtls/include/mbedtls/ssl.h b/thirdparty/mbedtls/include/mbedtls/ssl.h index fe33ac8d57..0abeb430e4 100644 --- a/thirdparty/mbedtls/include/mbedtls/ssl.h +++ b/thirdparty/mbedtls/include/mbedtls/ssl.h @@ -2237,7 +2237,7 @@ void mbedtls_ssl_conf_dhm_min_bitlen( mbedtls_ssl_config *conf, #if defined(MBEDTLS_ECP_C) /** * \brief Set the allowed curves in order of preference. - * (Default: all defined curves.) + * (Default: all defined curves in order of decreasing size.) * * On server: this only affects selection of the ECDHE curve; * the curves used for ECDH and ECDSA are determined by the @@ -2269,7 +2269,9 @@ void mbedtls_ssl_conf_curves( mbedtls_ssl_config *conf, #if defined(MBEDTLS_KEY_EXCHANGE__WITH_CERT__ENABLED) /** * \brief Set the allowed hashes for signatures during the handshake. - * (Default: all available hashes except MD5.) + * (Default: all SHA-2 hashes, largest first. Also SHA-1 if + * the compile-time option + * `MBEDTLS_TLS_DEFAULT_ALLOW_SHA1_IN_KEY_EXCHANGE` is enabled.) * * \note This only affects which hashes are offered and can be used * for signatures during the handshake. Hashes for message diff --git a/thirdparty/mbedtls/include/mbedtls/ssl_ticket.h b/thirdparty/mbedtls/include/mbedtls/ssl_ticket.h index a10a434138..a83f5e6662 100644 --- a/thirdparty/mbedtls/include/mbedtls/ssl_ticket.h +++ b/thirdparty/mbedtls/include/mbedtls/ssl_ticket.h @@ -124,7 +124,7 @@ void mbedtls_ssl_ticket_init( mbedtls_ssl_ticket_context *ctx ); * Recommended value: 86400 (one day). * * \note It is highly recommended to select a cipher that is at - * least as strong as the the strongest ciphersuite + * least as strong as the strongest ciphersuite * supported. Usually that means a 256-bit key. * * \note The lifetime of the keys is twice the lifetime of tickets. diff --git a/thirdparty/mbedtls/include/mbedtls/version.h b/thirdparty/mbedtls/include/mbedtls/version.h index bd5c730c1d..49cbeb003a 100644 --- a/thirdparty/mbedtls/include/mbedtls/version.h +++ b/thirdparty/mbedtls/include/mbedtls/version.h @@ -65,16 +65,16 @@ */ #define MBEDTLS_VERSION_MAJOR 2 #define MBEDTLS_VERSION_MINOR 16 -#define MBEDTLS_VERSION_PATCH 10 +#define MBEDTLS_VERSION_PATCH 11 /** * The single version number has the following structure: * MMNNPP00 * Major version | Minor version | Patch version */ -#define MBEDTLS_VERSION_NUMBER 0x02100A00 -#define MBEDTLS_VERSION_STRING "2.16.10" -#define MBEDTLS_VERSION_STRING_FULL "mbed TLS 2.16.10" +#define MBEDTLS_VERSION_NUMBER 0x02100B00 +#define MBEDTLS_VERSION_STRING "2.16.11" +#define MBEDTLS_VERSION_STRING_FULL "mbed TLS 2.16.11" #if defined(MBEDTLS_VERSION_C) diff --git a/thirdparty/mbedtls/include/mbedtls/x509_crt.h b/thirdparty/mbedtls/include/mbedtls/x509_crt.h index c38e0c0556..30da1909b7 100644 --- a/thirdparty/mbedtls/include/mbedtls/x509_crt.h +++ b/thirdparty/mbedtls/include/mbedtls/x509_crt.h @@ -229,12 +229,21 @@ typedef void mbedtls_x509_crt_restart_ctx; /** * Default security profile. Should provide a good balance between security * and compatibility with current deployments. + * + * This profile permits: + * - SHA2 hashes. + * - All supported elliptic curves. + * - RSA with 2048 bits and above. + * + * New minor versions of Mbed TLS may extend this profile, for example if + * new curves are added to the library. New minor versions of Mbed TLS will + * not reduce this profile unless serious security concerns require it. */ extern const mbedtls_x509_crt_profile mbedtls_x509_crt_profile_default; /** * Expected next default profile. Recommended for new deployments. - * Currently targets a 128-bit security level, except for RSA-2048. + * Currently targets a 128-bit security level, except for allowing RSA-2048. */ extern const mbedtls_x509_crt_profile mbedtls_x509_crt_profile_next; diff --git a/thirdparty/mbedtls/library/aria.c b/thirdparty/mbedtls/library/aria.c index ef0392f658..50ccb91c70 100644 --- a/thirdparty/mbedtls/library/aria.c +++ b/thirdparty/mbedtls/library/aria.c @@ -952,7 +952,7 @@ static const uint8_t aria_test2_ctr_ct[3][48] = // CTR ciphertext { \ if( verbose ) \ mbedtls_printf( "failed\n" ); \ - return( 1 ); \ + goto exit; \ } else { \ if( verbose ) \ mbedtls_printf( "passed\n" ); \ @@ -966,6 +966,7 @@ int mbedtls_aria_self_test( int verbose ) int i; uint8_t blk[MBEDTLS_ARIA_BLOCKSIZE]; mbedtls_aria_context ctx; + int ret = 1; #if (defined(MBEDTLS_CIPHER_MODE_CFB) || defined(MBEDTLS_CIPHER_MODE_CTR)) size_t j; @@ -977,6 +978,8 @@ int mbedtls_aria_self_test( int verbose ) uint8_t buf[48], iv[MBEDTLS_ARIA_BLOCKSIZE]; #endif + mbedtls_aria_init( &ctx ); + /* * Test set 1 */ @@ -1096,7 +1099,11 @@ int mbedtls_aria_self_test( int verbose ) mbedtls_printf( "\n" ); #endif /* MBEDTLS_CIPHER_MODE_CTR */ - return( 0 ); + ret = 0; + +exit: + mbedtls_aria_free( &ctx ); + return( ret ); } #endif /* MBEDTLS_SELF_TEST */ diff --git a/thirdparty/mbedtls/library/bignum.c b/thirdparty/mbedtls/library/bignum.c index f133f6c13c..540f7523b5 100644 --- a/thirdparty/mbedtls/library/bignum.c +++ b/thirdparty/mbedtls/library/bignum.c @@ -267,6 +267,36 @@ void mbedtls_mpi_swap( mbedtls_mpi *X, mbedtls_mpi *Y ) memcpy( Y, &T, sizeof( mbedtls_mpi ) ); } +/** + * Select between two sign values in constant-time. + * + * This is functionally equivalent to second ? a : b but uses only bit + * operations in order to avoid branches. + * + * \param[in] a The first sign; must be either +1 or -1. + * \param[in] b The second sign; must be either +1 or -1. + * \param[in] second Must be either 1 (return b) or 0 (return a). + * + * \return The selected sign value. + */ +static int mpi_safe_cond_select_sign( int a, int b, unsigned char second ) +{ + /* In order to avoid questions about what we can reasonnably assume about + * the representations of signed integers, move everything to unsigned + * by taking advantage of the fact that a and b are either +1 or -1. */ + unsigned ua = a + 1; + unsigned ub = b + 1; + + /* second was 0 or 1, mask is 0 or 2 as are ua and ub */ + const unsigned mask = second << 1; + + /* select ua or ub */ + unsigned ur = ( ua & ~mask ) | ( ub & mask ); + + /* ur is now 0 or 2, convert back to -1 or +1 */ + return( (int) ur - 1 ); +} + /* * Conditionally assign dest = src, without leaking information * about whether the assignment was made or not. @@ -279,8 +309,23 @@ static void mpi_safe_cond_assign( size_t n, unsigned char assign ) { size_t i; + + /* MSVC has a warning about unary minus on unsigned integer types, + * but this is well-defined and precisely what we want to do here. */ +#if defined(_MSC_VER) +#pragma warning( push ) +#pragma warning( disable : 4146 ) +#endif + + /* all-bits 1 if assign is 1, all-bits 0 if assign is 0 */ + const mbedtls_mpi_uint mask = -assign; + +#if defined(_MSC_VER) +#pragma warning( pop ) +#endif + for( i = 0; i < n; i++ ) - dest[i] = dest[i] * ( 1 - assign ) + src[i] * assign; + dest[i] = ( src[i] & mask ) | ( dest[i] & ~mask ); } /* @@ -292,20 +337,34 @@ int mbedtls_mpi_safe_cond_assign( mbedtls_mpi *X, const mbedtls_mpi *Y, unsigned { int ret = 0; size_t i; + mbedtls_mpi_uint limb_mask; MPI_VALIDATE_RET( X != NULL ); MPI_VALIDATE_RET( Y != NULL ); + /* MSVC has a warning about unary minus on unsigned integer types, + * but this is well-defined and precisely what we want to do here. */ +#if defined(_MSC_VER) +#pragma warning( push ) +#pragma warning( disable : 4146 ) +#endif + /* make sure assign is 0 or 1 in a time-constant manner */ - assign = (assign | (unsigned char)-assign) >> 7; + assign = (assign | (unsigned char)-assign) >> (sizeof( assign ) * 8 - 1); + /* all-bits 1 if assign is 1, all-bits 0 if assign is 0 */ + limb_mask = -assign; + +#if defined(_MSC_VER) +#pragma warning( pop ) +#endif MBEDTLS_MPI_CHK( mbedtls_mpi_grow( X, Y->n ) ); - X->s = X->s * ( 1 - assign ) + Y->s * assign; + X->s = mpi_safe_cond_select_sign( X->s, Y->s, assign ); mpi_safe_cond_assign( Y->n, X->p, Y->p, assign ); for( i = Y->n; i < X->n; i++ ) - X->p[i] *= ( 1 - assign ); + X->p[i] &= ~limb_mask; cleanup: return( ret ); @@ -321,6 +380,7 @@ int mbedtls_mpi_safe_cond_swap( mbedtls_mpi *X, mbedtls_mpi *Y, unsigned char sw { int ret, s; size_t i; + mbedtls_mpi_uint limb_mask; mbedtls_mpi_uint tmp; MPI_VALIDATE_RET( X != NULL ); MPI_VALIDATE_RET( Y != NULL ); @@ -328,22 +388,35 @@ int mbedtls_mpi_safe_cond_swap( mbedtls_mpi *X, mbedtls_mpi *Y, unsigned char sw if( X == Y ) return( 0 ); + /* MSVC has a warning about unary minus on unsigned integer types, + * but this is well-defined and precisely what we want to do here. */ +#if defined(_MSC_VER) +#pragma warning( push ) +#pragma warning( disable : 4146 ) +#endif + /* make sure swap is 0 or 1 in a time-constant manner */ - swap = (swap | (unsigned char)-swap) >> 7; + swap = (swap | (unsigned char)-swap) >> (sizeof( swap ) * 8 - 1); + /* all-bits 1 if swap is 1, all-bits 0 if swap is 0 */ + limb_mask = -swap; + +#if defined(_MSC_VER) +#pragma warning( pop ) +#endif MBEDTLS_MPI_CHK( mbedtls_mpi_grow( X, Y->n ) ); MBEDTLS_MPI_CHK( mbedtls_mpi_grow( Y, X->n ) ); s = X->s; - X->s = X->s * ( 1 - swap ) + Y->s * swap; - Y->s = Y->s * ( 1 - swap ) + s * swap; + X->s = mpi_safe_cond_select_sign( X->s, Y->s, swap ); + Y->s = mpi_safe_cond_select_sign( Y->s, s, swap ); for( i = 0; i < X->n; i++ ) { tmp = X->p[i]; - X->p[i] = X->p[i] * ( 1 - swap ) + Y->p[i] * swap; - Y->p[i] = Y->p[i] * ( 1 - swap ) + tmp * swap; + X->p[i] = ( X->p[i] & ~limb_mask ) | ( Y->p[i] & limb_mask ); + Y->p[i] = ( Y->p[i] & ~limb_mask ) | ( tmp & limb_mask ); } cleanup: @@ -500,6 +573,7 @@ int mbedtls_mpi_read_string( mbedtls_mpi *X, int radix, const char *s ) { int ret; size_t i, j, slen, n; + int sign = 1; mbedtls_mpi_uint d; mbedtls_mpi T; MPI_VALIDATE_RET( X != NULL ); @@ -510,6 +584,12 @@ int mbedtls_mpi_read_string( mbedtls_mpi *X, int radix, const char *s ) mbedtls_mpi_init( &T ); + if( s[0] == '-' ) + { + ++s; + sign = -1; + } + slen = strlen( s ); if( radix == 16 ) @@ -524,12 +604,6 @@ int mbedtls_mpi_read_string( mbedtls_mpi *X, int radix, const char *s ) for( i = slen, j = 0; i > 0; i--, j++ ) { - if( i == 1 && s[i - 1] == '-' ) - { - X->s = -1; - break; - } - MBEDTLS_MPI_CHK( mpi_get_digit( &d, radix, s[i - 1] ) ); X->p[j / ( 2 * ciL )] |= d << ( ( j % ( 2 * ciL ) ) << 2 ); } @@ -540,26 +614,15 @@ int mbedtls_mpi_read_string( mbedtls_mpi *X, int radix, const char *s ) for( i = 0; i < slen; i++ ) { - if( i == 0 && s[i] == '-' ) - { - X->s = -1; - continue; - } - MBEDTLS_MPI_CHK( mpi_get_digit( &d, radix, s[i] ) ); MBEDTLS_MPI_CHK( mbedtls_mpi_mul_int( &T, X, radix ) ); - - if( X->s == 1 ) - { - MBEDTLS_MPI_CHK( mbedtls_mpi_add_int( X, &T, d ) ); - } - else - { - MBEDTLS_MPI_CHK( mbedtls_mpi_sub_int( X, &T, d ) ); - } + MBEDTLS_MPI_CHK( mbedtls_mpi_add_int( X, &T, d ) ); } } + if( sign < 0 && mbedtls_mpi_bitlen( X ) != 0 ) + X->s = -1; + cleanup: mbedtls_mpi_free( &T ); @@ -1570,6 +1633,7 @@ int mbedtls_mpi_mul_mpi( mbedtls_mpi *X, const mbedtls_mpi *A, const mbedtls_mpi int ret; size_t i, j; mbedtls_mpi TA, TB; + int result_is_zero = 0; MPI_VALIDATE_RET( X != NULL ); MPI_VALIDATE_RET( A != NULL ); MPI_VALIDATE_RET( B != NULL ); @@ -1582,10 +1646,14 @@ int mbedtls_mpi_mul_mpi( mbedtls_mpi *X, const mbedtls_mpi *A, const mbedtls_mpi for( i = A->n; i > 0; i-- ) if( A->p[i - 1] != 0 ) break; + if( i == 0 ) + result_is_zero = 1; for( j = B->n; j > 0; j-- ) if( B->p[j - 1] != 0 ) break; + if( j == 0 ) + result_is_zero = 1; MBEDTLS_MPI_CHK( mbedtls_mpi_grow( X, i + j ) ); MBEDTLS_MPI_CHK( mbedtls_mpi_lset( X, 0 ) ); @@ -1593,7 +1661,14 @@ int mbedtls_mpi_mul_mpi( mbedtls_mpi *X, const mbedtls_mpi *A, const mbedtls_mpi for( ; j > 0; j-- ) mpi_mul_hlp( i, A->p, X->p + j - 1, B->p[j - 1] ); - X->s = A->s * B->s; + /* If the result is 0, we don't shortcut the operation, which reduces + * but does not eliminate side channels leaking the zero-ness. We do + * need to take care to set the sign bit properly since the library does + * not fully support an MPI object with a value of 0 and s == -1. */ + if( result_is_zero ) + X->s = 1; + else + X->s = A->s * B->s; cleanup: @@ -2042,6 +2117,72 @@ static void mpi_montred( mbedtls_mpi *A, const mbedtls_mpi *N, } /* + * Constant-flow boolean "equal" comparison: + * return x == y + * + * This function can be used to write constant-time code by replacing branches + * with bit operations - it can be used in conjunction with + * mbedtls_ssl_cf_mask_from_bit(). + * + * This function is implemented without using comparison operators, as those + * might be translated to branches by some compilers on some platforms. + */ +static size_t mbedtls_mpi_cf_bool_eq( size_t x, size_t y ) +{ + /* diff = 0 if x == y, non-zero otherwise */ + const size_t diff = x ^ y; + + /* MSVC has a warning about unary minus on unsigned integer types, + * but this is well-defined and precisely what we want to do here. */ +#if defined(_MSC_VER) +#pragma warning( push ) +#pragma warning( disable : 4146 ) +#endif + + /* diff_msb's most significant bit is equal to x != y */ + const size_t diff_msb = ( diff | (size_t) -diff ); + +#if defined(_MSC_VER) +#pragma warning( pop ) +#endif + + /* diff1 = (x != y) ? 1 : 0 */ + const size_t diff1 = diff_msb >> ( sizeof( diff_msb ) * 8 - 1 ); + + return( 1 ^ diff1 ); +} + +/** + * Select an MPI from a table without leaking the index. + * + * This is functionally equivalent to mbedtls_mpi_copy(R, T[idx]) except it + * reads the entire table in order to avoid leaking the value of idx to an + * attacker able to observe memory access patterns. + * + * \param[out] R Where to write the selected MPI. + * \param[in] T The table to read from. + * \param[in] T_size The number of elements in the table. + * \param[in] idx The index of the element to select; + * this must satisfy 0 <= idx < T_size. + * + * \return \c 0 on success, or a negative error code. + */ +static int mpi_select( mbedtls_mpi *R, const mbedtls_mpi *T, size_t T_size, size_t idx ) +{ + int ret = MBEDTLS_ERR_MPI_BAD_INPUT_DATA; + size_t i; + + for( i = 0; i < T_size; i++ ) + { + MBEDTLS_MPI_CHK( mbedtls_mpi_safe_cond_assign( R, &T[i], + (unsigned char) mbedtls_mpi_cf_bool_eq( i, idx ) ) ); + } + +cleanup: + return( ret ); +} + +/* * Sliding-window exponentiation: X = A^E mod N (HAC 14.85) */ int mbedtls_mpi_exp_mod( mbedtls_mpi *X, const mbedtls_mpi *A, @@ -2053,7 +2194,7 @@ int mbedtls_mpi_exp_mod( mbedtls_mpi *X, const mbedtls_mpi *A, size_t i, j, nblimbs; size_t bufsize, nbits; mbedtls_mpi_uint ei, mm, state; - mbedtls_mpi RR, T, W[ 1 << MBEDTLS_MPI_WINDOW_SIZE ], Apos; + mbedtls_mpi RR, T, W[ 1 << MBEDTLS_MPI_WINDOW_SIZE ], WW, Apos; int neg; MPI_VALIDATE_RET( X != NULL ); @@ -2077,6 +2218,7 @@ int mbedtls_mpi_exp_mod( mbedtls_mpi *X, const mbedtls_mpi *A, mpi_montg_init( &mm, N ); mbedtls_mpi_init( &RR ); mbedtls_mpi_init( &T ); mbedtls_mpi_init( &Apos ); + mbedtls_mpi_init( &WW ); memset( W, 0, sizeof( W ) ); i = mbedtls_mpi_bitlen( E ); @@ -2090,6 +2232,11 @@ int mbedtls_mpi_exp_mod( mbedtls_mpi *X, const mbedtls_mpi *A, #endif j = N->n + 1; + /* All W[i] and X must have at least N->n limbs for the mpi_montmul() + * and mpi_montred() calls later. Here we ensure that W[1] and X are + * large enough, and later we'll grow other W[i] to the same length. + * They must not be shrunk midway through this function! + */ MBEDTLS_MPI_CHK( mbedtls_mpi_grow( X, j ) ); MBEDTLS_MPI_CHK( mbedtls_mpi_grow( &W[1], j ) ); MBEDTLS_MPI_CHK( mbedtls_mpi_grow( &T, j * 2 ) ); @@ -2127,6 +2274,10 @@ int mbedtls_mpi_exp_mod( mbedtls_mpi *X, const mbedtls_mpi *A, MBEDTLS_MPI_CHK( mbedtls_mpi_mod_mpi( &W[1], A, N ) ); else MBEDTLS_MPI_CHK( mbedtls_mpi_copy( &W[1], A ) ); + /* Re-grow W[1] if necessary. This should be only necessary in one corner + * case: when A == 0 represented with A.n == 0, mbedtls_mpi_copy shrinks + * W[1] to 0 limbs. */ + MBEDTLS_MPI_CHK( mbedtls_mpi_grow( &W[1], N->n +1 ) ); mpi_montmul( &W[1], &RR, N, mm, &T ); @@ -2217,7 +2368,8 @@ int mbedtls_mpi_exp_mod( mbedtls_mpi *X, const mbedtls_mpi *A, /* * X = X * W[wbits] R^-1 mod N */ - mpi_montmul( X, &W[wbits], N, mm, &T ); + MBEDTLS_MPI_CHK( mpi_select( &WW, W, (size_t) 1 << wsize, wbits ) ); + mpi_montmul( X, &WW, N, mm, &T ); state--; nbits = 0; @@ -2255,6 +2407,7 @@ cleanup: mbedtls_mpi_free( &W[i] ); mbedtls_mpi_free( &W[1] ); mbedtls_mpi_free( &T ); mbedtls_mpi_free( &Apos ); + mbedtls_mpi_free( &WW ); if( _RR == NULL || _RR->p == NULL ) mbedtls_mpi_free( &RR ); @@ -2283,6 +2436,16 @@ int mbedtls_mpi_gcd( mbedtls_mpi *G, const mbedtls_mpi *A, const mbedtls_mpi *B lz = mbedtls_mpi_lsb( &TA ); lzt = mbedtls_mpi_lsb( &TB ); + /* The loop below gives the correct result when A==0 but not when B==0. + * So have a special case for B==0. Leverage the fact that we just + * calculated the lsb and lsb(B)==0 iff B is odd or 0 to make the test + * slightly more efficient than cmp_int(). */ + if( lzt == 0 && mbedtls_mpi_get_bit( &TB, 0 ) == 0 ) + { + ret = mbedtls_mpi_copy( G, A ); + goto cleanup; + } + if( lzt < lz ) lz = lzt; @@ -2291,11 +2454,52 @@ int mbedtls_mpi_gcd( mbedtls_mpi *G, const mbedtls_mpi *A, const mbedtls_mpi *B TA.s = TB.s = 1; + /* We mostly follow the procedure described in HAC 14.54, but with some + * minor differences: + * - Sequences of multiplications or divisions by 2 are grouped into a + * single shift operation. + * - The procedure in HAC assumes that 0 < TB <= TA. + * - The condition TB <= TA is not actually necessary for correctness. + * TA and TB have symmetric roles except for the loop termination + * condition, and the shifts at the beginning of the loop body + * remove any significance from the ordering of TA vs TB before + * the shifts. + * - If TA = 0, the loop goes through 0 iterations and the result is + * correctly TB. + * - The case TB = 0 was short-circuited above. + * + * For the correctness proof below, decompose the original values of + * A and B as + * A = sa * 2^a * A' with A'=0 or A' odd, and sa = +-1 + * B = sb * 2^b * B' with B'=0 or B' odd, and sb = +-1 + * Then gcd(A, B) = 2^{min(a,b)} * gcd(A',B'), + * and gcd(A',B') is odd or 0. + * + * At the beginning, we have TA = |A|/2^a and TB = |B|/2^b. + * The code maintains the following invariant: + * gcd(A,B) = 2^k * gcd(TA,TB) for some k (I) + */ + + /* Proof that the loop terminates: + * At each iteration, either the right-shift by 1 is made on a nonzero + * value and the nonnegative integer bitlen(TA) + bitlen(TB) decreases + * by at least 1, or the right-shift by 1 is made on zero and then + * TA becomes 0 which ends the loop (TB cannot be 0 if it is right-shifted + * since in that case TB is calculated from TB-TA with the condition TB>TA). + */ while( mbedtls_mpi_cmp_int( &TA, 0 ) != 0 ) { + /* Divisions by 2 preserve the invariant (I). */ MBEDTLS_MPI_CHK( mbedtls_mpi_shift_r( &TA, mbedtls_mpi_lsb( &TA ) ) ); MBEDTLS_MPI_CHK( mbedtls_mpi_shift_r( &TB, mbedtls_mpi_lsb( &TB ) ) ); + /* Set either TA or TB to |TA-TB|/2. Since TA and TB are both odd, + * TA-TB is even so the division by 2 has an integer result. + * Invariant (I) is preserved since any odd divisor of both TA and TB + * also divides |TA-TB|/2, and any odd divisor of both TA and |TA-TB|/2 + * also divides TB, and any odd divisior of both TB and |TA-TB|/2 also + * divides TA. + */ if( mbedtls_mpi_cmp_mpi( &TA, &TB ) >= 0 ) { MBEDTLS_MPI_CHK( mbedtls_mpi_sub_abs( &TA, &TA, &TB ) ); @@ -2306,8 +2510,18 @@ int mbedtls_mpi_gcd( mbedtls_mpi *G, const mbedtls_mpi *A, const mbedtls_mpi *B MBEDTLS_MPI_CHK( mbedtls_mpi_sub_abs( &TB, &TB, &TA ) ); MBEDTLS_MPI_CHK( mbedtls_mpi_shift_r( &TB, 1 ) ); } + /* Note that one of TA or TB is still odd. */ } + /* By invariant (I), gcd(A,B) = 2^k * gcd(TA,TB) for some k. + * At the loop exit, TA = 0, so gcd(TA,TB) = TB. + * - If there was at least one loop iteration, then one of TA or TB is odd, + * and TA = 0, so TB is odd and gcd(TA,TB) = gcd(A',B'). In this case, + * lz = min(a,b) so gcd(A,B) = 2^lz * TB. + * - If there was no loop iteration, then A was 0, and gcd(A,B) = B. + * In this case, lz = 0 and B = TB so gcd(A,B) = B = 2^lz * TB as well. + */ + MBEDTLS_MPI_CHK( mbedtls_mpi_shift_l( &TB, lz ) ); MBEDTLS_MPI_CHK( mbedtls_mpi_copy( G, &TB ) ); diff --git a/thirdparty/mbedtls/library/camellia.c b/thirdparty/mbedtls/library/camellia.c index 40d62121bf..6cf265e578 100644 --- a/thirdparty/mbedtls/library/camellia.c +++ b/thirdparty/mbedtls/library/camellia.c @@ -973,9 +973,11 @@ int mbedtls_camellia_self_test( int verbose ) unsigned char nonce_counter[16]; unsigned char stream_block[16]; #endif + int ret = 1; mbedtls_camellia_context ctx; + mbedtls_camellia_init( &ctx ); memset( key, 0, 32 ); for( j = 0; j < 6; j++ ) { @@ -1005,8 +1007,7 @@ int mbedtls_camellia_self_test( int verbose ) { if( verbose != 0 ) mbedtls_printf( "failed\n" ); - - return( 1 ); + goto exit; } } @@ -1058,8 +1059,7 @@ int mbedtls_camellia_self_test( int verbose ) { if( verbose != 0 ) mbedtls_printf( "failed\n" ); - - return( 1 ); + goto exit; } } @@ -1102,8 +1102,7 @@ int mbedtls_camellia_self_test( int verbose ) { if( verbose != 0 ) mbedtls_printf( "failed\n" ); - - return( 1 ); + goto exit; } } else @@ -1118,8 +1117,7 @@ int mbedtls_camellia_self_test( int verbose ) { if( verbose != 0 ) mbedtls_printf( "failed\n" ); - - return( 1 ); + goto exit; } } @@ -1131,7 +1129,11 @@ int mbedtls_camellia_self_test( int verbose ) mbedtls_printf( "\n" ); #endif /* MBEDTLS_CIPHER_MODE_CTR */ - return( 0 ); + ret = 0; + +exit: + mbedtls_camellia_free( &ctx ); + return( ret ); } #endif /* MBEDTLS_SELF_TEST */ diff --git a/thirdparty/mbedtls/library/debug.c b/thirdparty/mbedtls/library/debug.c index 5f06d0da13..9caa361d44 100644 --- a/thirdparty/mbedtls/library/debug.c +++ b/thirdparty/mbedtls/library/debug.c @@ -261,8 +261,8 @@ void mbedtls_debug_print_mpi( const mbedtls_ssl_context *ssl, int level, const char *text, const mbedtls_mpi *X ) { char str[DEBUG_BUF_SIZE]; - int j, k, zeros = 1; - size_t i, n, idx = 0; + size_t bitlen; + size_t idx = 0; if( NULL == ssl || NULL == ssl->conf || @@ -273,55 +273,43 @@ void mbedtls_debug_print_mpi( const mbedtls_ssl_context *ssl, int level, return; } - for( n = X->n - 1; n > 0; n-- ) - if( X->p[n] != 0 ) - break; - - for( j = ( sizeof(mbedtls_mpi_uint) << 3 ) - 1; j >= 0; j-- ) - if( ( ( X->p[n] >> j ) & 1 ) != 0 ) - break; - - mbedtls_snprintf( str + idx, sizeof( str ) - idx, "value of '%s' (%d bits) is:\n", - text, (int) ( ( n * ( sizeof(mbedtls_mpi_uint) << 3 ) ) + j + 1 ) ); + bitlen = mbedtls_mpi_bitlen( X ); + mbedtls_snprintf( str, sizeof( str ), "value of '%s' (%u bits) is:\n", + text, (unsigned) bitlen ); debug_send_line( ssl, level, file, line, str ); - idx = 0; - for( i = n + 1, j = 0; i > 0; i-- ) + if( bitlen == 0 ) { - if( zeros && X->p[i - 1] == 0 ) - continue; - - for( k = sizeof( mbedtls_mpi_uint ) - 1; k >= 0; k-- ) + str[0] = ' '; str[1] = '0'; str[2] = '0'; + idx = 3; + } + else + { + int n; + for( n = (int) ( ( bitlen - 1 ) / 8 ); n >= 0; n-- ) { - if( zeros && ( ( X->p[i - 1] >> ( k << 3 ) ) & 0xFF ) == 0 ) - continue; - else - zeros = 0; - - if( j % 16 == 0 ) + size_t limb_offset = n / sizeof( mbedtls_mpi_uint ); + size_t offset_in_limb = n % sizeof( mbedtls_mpi_uint ); + unsigned char octet = + ( X->p[limb_offset] >> ( offset_in_limb * 8 ) ) & 0xff; + mbedtls_snprintf( str + idx, sizeof( str ) - idx, " %02x", octet ); + idx += 3; + /* Wrap lines after 16 octets that each take 3 columns */ + if( idx >= 3 * 16 ) { - if( j > 0 ) - { - mbedtls_snprintf( str + idx, sizeof( str ) - idx, "\n" ); - debug_send_line( ssl, level, file, line, str ); - idx = 0; - } + mbedtls_snprintf( str + idx, sizeof( str ) - idx, "\n" ); + debug_send_line( ssl, level, file, line, str ); + idx = 0; } - - idx += mbedtls_snprintf( str + idx, sizeof( str ) - idx, " %02x", (unsigned int) - ( X->p[i - 1] >> ( k << 3 ) ) & 0xFF ); - - j++; } - } - if( zeros == 1 ) - idx += mbedtls_snprintf( str + idx, sizeof( str ) - idx, " 00" ); - - mbedtls_snprintf( str + idx, sizeof( str ) - idx, "\n" ); - debug_send_line( ssl, level, file, line, str ); + if( idx != 0 ) + { + mbedtls_snprintf( str + idx, sizeof( str ) - idx, "\n" ); + debug_send_line( ssl, level, file, line, str ); + } } #endif /* MBEDTLS_BIGNUM_C */ diff --git a/thirdparty/mbedtls/library/dhm.c b/thirdparty/mbedtls/library/dhm.c index d652cf0ac9..535b698ce6 100644 --- a/thirdparty/mbedtls/library/dhm.c +++ b/thirdparty/mbedtls/library/dhm.c @@ -130,22 +130,21 @@ static int dhm_read_bignum( mbedtls_mpi *X, */ static int dhm_check_range( const mbedtls_mpi *param, const mbedtls_mpi *P ) { - mbedtls_mpi L, U; + mbedtls_mpi U; int ret = 0; - mbedtls_mpi_init( &L ); mbedtls_mpi_init( &U ); + mbedtls_mpi_init( &U ); - MBEDTLS_MPI_CHK( mbedtls_mpi_lset( &L, 2 ) ); MBEDTLS_MPI_CHK( mbedtls_mpi_sub_int( &U, P, 2 ) ); - if( mbedtls_mpi_cmp_mpi( param, &L ) < 0 || + if( mbedtls_mpi_cmp_int( param, 2 ) < 0 || mbedtls_mpi_cmp_mpi( param, &U ) > 0 ) { ret = MBEDTLS_ERR_DHM_BAD_INPUT_DATA; } cleanup: - mbedtls_mpi_free( &L ); mbedtls_mpi_free( &U ); + mbedtls_mpi_free( &U ); return( ret ); } @@ -181,38 +180,54 @@ int mbedtls_dhm_read_params( mbedtls_dhm_context *ctx, } /* - * Setup and write the ServerKeyExchange parameters + * Pick a random R in the range [2, M-2] for blinding or key generation. */ -int mbedtls_dhm_make_params( mbedtls_dhm_context *ctx, int x_size, - unsigned char *output, size_t *olen, - int (*f_rng)(void *, unsigned char *, size_t), - void *p_rng ) +static int dhm_random_below( mbedtls_mpi *R, const mbedtls_mpi *M, + int (*f_rng)(void *, unsigned char *, size_t), void *p_rng ) { - int ret, count = 0; - size_t n1, n2, n3; - unsigned char *p; - DHM_VALIDATE_RET( ctx != NULL ); - DHM_VALIDATE_RET( output != NULL ); - DHM_VALIDATE_RET( olen != NULL ); - DHM_VALIDATE_RET( f_rng != NULL ); + int ret, count; + size_t m_size = mbedtls_mpi_size( M ); + size_t m_bitlen = mbedtls_mpi_bitlen( M ); + + count = 0; + do + { + if( count++ > 30 ) + return( MBEDTLS_ERR_MPI_NOT_ACCEPTABLE ); + + MBEDTLS_MPI_CHK( mbedtls_mpi_fill_random( R, m_size, f_rng, p_rng ) ); + MBEDTLS_MPI_CHK( mbedtls_mpi_shift_r( R, ( m_size * 8 ) - m_bitlen ) ); + } + while( dhm_check_range( R, M ) != 0 ); + +cleanup: + return( ret ); +} + +static int dhm_make_common( mbedtls_dhm_context *ctx, int x_size, + int (*f_rng)(void *, unsigned char *, size_t), + void *p_rng ) +{ + int ret = 0; if( mbedtls_mpi_cmp_int( &ctx->P, 0 ) == 0 ) return( MBEDTLS_ERR_DHM_BAD_INPUT_DATA ); + if( x_size < 0 ) + return( MBEDTLS_ERR_DHM_BAD_INPUT_DATA ); - /* - * Generate X as large as possible ( < P ) - */ - do + if( (unsigned) x_size < mbedtls_mpi_size( &ctx->P ) ) { MBEDTLS_MPI_CHK( mbedtls_mpi_fill_random( &ctx->X, x_size, f_rng, p_rng ) ); - - while( mbedtls_mpi_cmp_mpi( &ctx->X, &ctx->P ) >= 0 ) - MBEDTLS_MPI_CHK( mbedtls_mpi_shift_r( &ctx->X, 1 ) ); - - if( count++ > 10 ) + } + else + { + /* Generate X as large as possible ( <= P - 2 ) */ + ret = dhm_random_below( &ctx->X, &ctx->P, f_rng, p_rng ); + if( ret == MBEDTLS_ERR_MPI_NOT_ACCEPTABLE ) return( MBEDTLS_ERR_DHM_MAKE_PARAMS_FAILED ); + if( ret != 0 ) + return( ret ); } - while( dhm_check_range( &ctx->X, &ctx->P ) != 0 ); /* * Calculate GX = G^X mod P @@ -223,8 +238,33 @@ int mbedtls_dhm_make_params( mbedtls_dhm_context *ctx, int x_size, if( ( ret = dhm_check_range( &ctx->GX, &ctx->P ) ) != 0 ) return( ret ); +cleanup: + return( ret ); +} + +/* + * Setup and write the ServerKeyExchange parameters + */ +int mbedtls_dhm_make_params( mbedtls_dhm_context *ctx, int x_size, + unsigned char *output, size_t *olen, + int (*f_rng)(void *, unsigned char *, size_t), + void *p_rng ) +{ + int ret; + size_t n1, n2, n3; + unsigned char *p; + DHM_VALIDATE_RET( ctx != NULL ); + DHM_VALIDATE_RET( output != NULL ); + DHM_VALIDATE_RET( olen != NULL ); + DHM_VALIDATE_RET( f_rng != NULL ); + + ret = dhm_make_common( ctx, x_size, f_rng, p_rng ); + if( ret != 0 ) + goto cleanup; + /* - * export P, G, GX + * Export P, G, GX. RFC 5246 §4.4 states that "leading zero octets are + * not required". We omit leading zeros for compactness. */ #define DHM_MPI_EXPORT( X, n ) \ do { \ @@ -250,11 +290,9 @@ int mbedtls_dhm_make_params( mbedtls_dhm_context *ctx, int x_size, ctx->len = n1; cleanup: - - if( ret != 0 ) + if( ret != 0 && ret > -128 ) return( MBEDTLS_ERR_DHM_MAKE_PARAMS_FAILED + ret ); - - return( 0 ); + return( ret ); } /* @@ -306,7 +344,7 @@ int mbedtls_dhm_make_public( mbedtls_dhm_context *ctx, int x_size, int (*f_rng)(void *, unsigned char *, size_t), void *p_rng ) { - int ret, count = 0; + int ret; DHM_VALIDATE_RET( ctx != NULL ); DHM_VALIDATE_RET( output != NULL ); DHM_VALIDATE_RET( f_rng != NULL ); @@ -314,62 +352,18 @@ int mbedtls_dhm_make_public( mbedtls_dhm_context *ctx, int x_size, if( olen < 1 || olen > ctx->len ) return( MBEDTLS_ERR_DHM_BAD_INPUT_DATA ); - if( mbedtls_mpi_cmp_int( &ctx->P, 0 ) == 0 ) - return( MBEDTLS_ERR_DHM_BAD_INPUT_DATA ); - - /* - * generate X and calculate GX = G^X mod P - */ - do - { - MBEDTLS_MPI_CHK( mbedtls_mpi_fill_random( &ctx->X, x_size, f_rng, p_rng ) ); - - while( mbedtls_mpi_cmp_mpi( &ctx->X, &ctx->P ) >= 0 ) - MBEDTLS_MPI_CHK( mbedtls_mpi_shift_r( &ctx->X, 1 ) ); - - if( count++ > 10 ) - return( MBEDTLS_ERR_DHM_MAKE_PUBLIC_FAILED ); - } - while( dhm_check_range( &ctx->X, &ctx->P ) != 0 ); - - MBEDTLS_MPI_CHK( mbedtls_mpi_exp_mod( &ctx->GX, &ctx->G, &ctx->X, - &ctx->P , &ctx->RP ) ); - - if( ( ret = dhm_check_range( &ctx->GX, &ctx->P ) ) != 0 ) - return( ret ); + ret = dhm_make_common( ctx, x_size, f_rng, p_rng ); + if( ret == MBEDTLS_ERR_DHM_MAKE_PARAMS_FAILED ) + return( MBEDTLS_ERR_DHM_MAKE_PUBLIC_FAILED ); + if( ret != 0 ) + goto cleanup; MBEDTLS_MPI_CHK( mbedtls_mpi_write_binary( &ctx->GX, output, olen ) ); cleanup: - - if( ret != 0 ) + if( ret != 0 && ret > -128 ) return( MBEDTLS_ERR_DHM_MAKE_PUBLIC_FAILED + ret ); - return( 0 ); -} - -/* - * Pick a random R in the range [2, M) for blinding purposes - */ -static int dhm_random_below( mbedtls_mpi *R, const mbedtls_mpi *M, - int (*f_rng)(void *, unsigned char *, size_t), void *p_rng ) -{ - int ret, count; - - count = 0; - do - { - MBEDTLS_MPI_CHK( mbedtls_mpi_fill_random( R, mbedtls_mpi_size( M ), f_rng, p_rng ) ); - - while( mbedtls_mpi_cmp_mpi( R, M ) >= 0 ) - MBEDTLS_MPI_CHK( mbedtls_mpi_shift_r( R, 1 ) ); - - if( count++ > 10 ) - return( MBEDTLS_ERR_MPI_NOT_ACCEPTABLE ); - } - while( mbedtls_mpi_cmp_int( R, 1 ) <= 0 ); - -cleanup: return( ret ); } @@ -420,7 +414,7 @@ static int dhm_update_blinding( mbedtls_dhm_context *ctx, * We need to generate blinding values from scratch */ - /* Vi = random( 2, P-1 ) */ + /* Vi = random( 2, P-2 ) */ MBEDTLS_MPI_CHK( dhm_random_below( &ctx->Vi, &ctx->P, f_rng, p_rng ) ); /* Vf = Vi^-X mod P @@ -484,8 +478,9 @@ int mbedtls_dhm_calc_secret( mbedtls_dhm_context *ctx, MBEDTLS_MPI_CHK( mbedtls_mpi_mod_mpi( &ctx->K, &ctx->K, &ctx->P ) ); } + /* Output the secret without any leading zero byte. This is mandatory + * for TLS per RFC 5246 §8.1.2. */ *olen = mbedtls_mpi_size( &ctx->K ); - MBEDTLS_MPI_CHK( mbedtls_mpi_write_binary( &ctx->K, output, *olen ) ); cleanup: diff --git a/thirdparty/mbedtls/library/ecp.c b/thirdparty/mbedtls/library/ecp.c index fe41b4128a..a7486c198a 100644 --- a/thirdparty/mbedtls/library/ecp.c +++ b/thirdparty/mbedtls/library/ecp.c @@ -106,6 +106,7 @@ #include "mbedtls/ecp.h" #include "mbedtls/threading.h" #include "mbedtls/platform_util.h" +#include "mbedtls/bn_mul.h" #include <string.h> @@ -1738,18 +1739,17 @@ static int ecp_randomize_jac( const mbedtls_ecp_group *grp, mbedtls_ecp_point *p /* Generate l such that 1 < l < p */ do { - MBEDTLS_MPI_CHK( mbedtls_mpi_fill_random( &l, p_size, f_rng, p_rng ) ); - - while( mbedtls_mpi_cmp_mpi( &l, &grp->P ) >= 0 ) - MBEDTLS_MPI_CHK( mbedtls_mpi_shift_r( &l, 1 ) ); - - if( count++ > 10 ) + if( count++ > 30 ) { ret = MBEDTLS_ERR_ECP_RANDOM_FAILED; goto cleanup; } + + MBEDTLS_MPI_CHK( mbedtls_mpi_fill_random( &l, p_size, f_rng, p_rng ) ); + MBEDTLS_MPI_CHK( mbedtls_mpi_shift_r( &l, ( p_size * 8 ) - grp->pbits ) ); } - while( mbedtls_mpi_cmp_int( &l, 1 ) <= 0 ); + while( ( mbedtls_mpi_cmp_int( &l, 1 ) <= 0 ) || + ( mbedtls_mpi_cmp_mpi( &l, &grp->P ) >= 0 ) ); /* Z = l * Z */ MBEDTLS_MPI_CHK( mbedtls_mpi_mul_mpi( &pt->Z, &pt->Z, &l ) ); MOD_MUL( pt->Z ); @@ -2505,7 +2505,7 @@ static int ecp_randomize_mxz( const mbedtls_ecp_group *grp, mbedtls_ecp_point *P #if defined(MBEDTLS_ECP_RANDOMIZE_MXZ_ALT) if( mbedtls_internal_ecp_grp_capable( grp ) ) - return( mbedtls_internal_ecp_randomize_mxz( grp, P, f_rng, p_rng ); + return( mbedtls_internal_ecp_randomize_mxz( grp, P, f_rng, p_rng ) ); #endif /* MBEDTLS_ECP_RANDOMIZE_MXZ_ALT */ p_size = ( grp->pbits + 7 ) / 8; @@ -2514,18 +2514,17 @@ static int ecp_randomize_mxz( const mbedtls_ecp_group *grp, mbedtls_ecp_point *P /* Generate l such that 1 < l < p */ do { - MBEDTLS_MPI_CHK( mbedtls_mpi_fill_random( &l, p_size, f_rng, p_rng ) ); - - while( mbedtls_mpi_cmp_mpi( &l, &grp->P ) >= 0 ) - MBEDTLS_MPI_CHK( mbedtls_mpi_shift_r( &l, 1 ) ); - - if( count++ > 10 ) + if( count++ > 30 ) { ret = MBEDTLS_ERR_ECP_RANDOM_FAILED; goto cleanup; } + + MBEDTLS_MPI_CHK( mbedtls_mpi_fill_random( &l, p_size, f_rng, p_rng ) ); + MBEDTLS_MPI_CHK( mbedtls_mpi_shift_r( &l, ( p_size * 8 ) - grp->pbits ) ); } - while( mbedtls_mpi_cmp_int( &l, 1 ) <= 0 ); + while( ( mbedtls_mpi_cmp_int( &l, 1 ) <= 0 ) || + ( mbedtls_mpi_cmp_mpi( &l, &grp->P ) >= 0 ) ); MBEDTLS_MPI_CHK( mbedtls_mpi_mul_mpi( &P->X, &P->X, &l ) ); MOD_MUL( P->X ); MBEDTLS_MPI_CHK( mbedtls_mpi_mul_mpi( &P->Z, &P->Z, &l ) ); MOD_MUL( P->Z ); @@ -2970,6 +2969,97 @@ int mbedtls_ecp_muladd( mbedtls_ecp_group *grp, mbedtls_ecp_point *R, } #if defined(ECP_MONTGOMERY) +#if defined(MBEDTLS_ECP_DP_CURVE25519_ENABLED) +#define ECP_MPI_INIT(s, n, p) {s, (n), (mbedtls_mpi_uint *)(p)} +#define ECP_MPI_INIT_ARRAY(x) \ + ECP_MPI_INIT(1, sizeof(x) / sizeof(mbedtls_mpi_uint), x) +/* + * Constants for the two points other than 0, 1, -1 (mod p) in + * https://cr.yp.to/ecdh.html#validate + * See ecp_check_pubkey_x25519(). + */ +static const mbedtls_mpi_uint x25519_bad_point_1[] = { + MBEDTLS_BYTES_TO_T_UINT_8( 0xe0, 0xeb, 0x7a, 0x7c, 0x3b, 0x41, 0xb8, 0xae ), + MBEDTLS_BYTES_TO_T_UINT_8( 0x16, 0x56, 0xe3, 0xfa, 0xf1, 0x9f, 0xc4, 0x6a ), + MBEDTLS_BYTES_TO_T_UINT_8( 0xda, 0x09, 0x8d, 0xeb, 0x9c, 0x32, 0xb1, 0xfd ), + MBEDTLS_BYTES_TO_T_UINT_8( 0x86, 0x62, 0x05, 0x16, 0x5f, 0x49, 0xb8, 0x00 ), +}; +static const mbedtls_mpi_uint x25519_bad_point_2[] = { + MBEDTLS_BYTES_TO_T_UINT_8( 0x5f, 0x9c, 0x95, 0xbc, 0xa3, 0x50, 0x8c, 0x24 ), + MBEDTLS_BYTES_TO_T_UINT_8( 0xb1, 0xd0, 0xb1, 0x55, 0x9c, 0x83, 0xef, 0x5b ), + MBEDTLS_BYTES_TO_T_UINT_8( 0x04, 0x44, 0x5c, 0xc4, 0x58, 0x1c, 0x8e, 0x86 ), + MBEDTLS_BYTES_TO_T_UINT_8( 0xd8, 0x22, 0x4e, 0xdd, 0xd0, 0x9f, 0x11, 0x57 ), +}; +static const mbedtls_mpi ecp_x25519_bad_point_1 = ECP_MPI_INIT_ARRAY( + x25519_bad_point_1 ); +static const mbedtls_mpi ecp_x25519_bad_point_2 = ECP_MPI_INIT_ARRAY( + x25519_bad_point_2 ); +#endif /* MBEDTLS_ECP_DP_CURVE25519_ENABLED */ + +/* + * Check that the input point is not one of the low-order points. + * This is recommended by the "May the Fourth" paper: + * https://eprint.iacr.org/2017/806.pdf + * Those points are never sent by an honest peer. + */ +static int ecp_check_bad_points_mx( const mbedtls_mpi *X, const mbedtls_mpi *P, + const mbedtls_ecp_group_id grp_id ) +{ + int ret; + mbedtls_mpi XmP; + + mbedtls_mpi_init( &XmP ); + + /* Reduce X mod P so that we only need to check values less than P. + * We know X < 2^256 so we can proceed by subtraction. */ + MBEDTLS_MPI_CHK( mbedtls_mpi_copy( &XmP, X ) ); + while( mbedtls_mpi_cmp_mpi( &XmP, P ) >= 0 ) + MBEDTLS_MPI_CHK( mbedtls_mpi_sub_mpi( &XmP, &XmP, P ) ); + + /* Check against the known bad values that are less than P. For Curve448 + * these are 0, 1 and -1. For Curve25519 we check the values less than P + * from the following list: https://cr.yp.to/ecdh.html#validate */ + if( mbedtls_mpi_cmp_int( &XmP, 1 ) <= 0 ) /* takes care of 0 and 1 */ + { + ret = MBEDTLS_ERR_ECP_INVALID_KEY; + goto cleanup; + } + +#if defined(MBEDTLS_ECP_DP_CURVE25519_ENABLED) + if( grp_id == MBEDTLS_ECP_DP_CURVE25519 ) + { + if( mbedtls_mpi_cmp_mpi( &XmP, &ecp_x25519_bad_point_1 ) == 0 ) + { + ret = MBEDTLS_ERR_ECP_INVALID_KEY; + goto cleanup; + } + + if( mbedtls_mpi_cmp_mpi( &XmP, &ecp_x25519_bad_point_2 ) == 0 ) + { + ret = MBEDTLS_ERR_ECP_INVALID_KEY; + goto cleanup; + } + } +#else + (void) grp_id; +#endif + + /* Final check: check if XmP + 1 is P (final because it changes XmP!) */ + MBEDTLS_MPI_CHK( mbedtls_mpi_add_int( &XmP, &XmP, 1 ) ); + if( mbedtls_mpi_cmp_mpi( &XmP, P ) == 0 ) + { + ret = MBEDTLS_ERR_ECP_INVALID_KEY; + goto cleanup; + } + + ret = 0; + +cleanup: + mbedtls_mpi_free( &XmP ); + + return( ret ); +} + /* * Check validity of a public key for Montgomery curves with x-only schemes */ @@ -2981,7 +3071,13 @@ static int ecp_check_pubkey_mx( const mbedtls_ecp_group *grp, const mbedtls_ecp_ if( mbedtls_mpi_size( &pt->X ) > ( grp->nbits + 7 ) / 8 ) return( MBEDTLS_ERR_ECP_INVALID_KEY ); - return( 0 ); + /* Implicit in all standards (as they don't consider negative numbers): + * X must be non-negative. This is normally ensured by the way it's + * encoded for transmission, but let's be extra sure. */ + if( mbedtls_mpi_cmp_int( &pt->X, 0 ) < 0 ) + return( MBEDTLS_ERR_ECP_INVALID_KEY ); + + return( ecp_check_bad_points_mx( &pt->X, &grp->P, grp->id ) ); } #endif /* ECP_MONTGOMERY */ @@ -3059,6 +3155,11 @@ int mbedtls_ecp_gen_privkey( const mbedtls_ecp_group *grp, { int ret = MBEDTLS_ERR_ECP_BAD_INPUT_DATA; size_t n_size; +#if defined(ECP_SHORTWEIERSTRASS) + mbedtls_mpi one; + + mbedtls_mpi_init( &one ); +#endif ECP_VALIDATE_RET( grp != NULL ); ECP_VALIDATE_RET( d != NULL ); @@ -3099,7 +3200,10 @@ int mbedtls_ecp_gen_privkey( const mbedtls_ecp_group *grp, { /* SEC1 3.2.1: Generate d such that 1 <= n < N */ int count = 0; - unsigned cmp = 0; + unsigned lt_lower = 1, lt_upper = 0; + + MBEDTLS_MPI_CHK( mbedtls_mpi_grow( &one, grp->N.n ) ); + MBEDTLS_MPI_CHK( mbedtls_mpi_lset( &one, 1 ) ); /* * Match the procedure given in RFC 6979 (deterministic ECDSA): @@ -3123,19 +3227,22 @@ int mbedtls_ecp_gen_privkey( const mbedtls_ecp_group *grp, * such as secp224k1 are actually very close to the worst case. */ if( ++count > 30 ) - return( MBEDTLS_ERR_ECP_RANDOM_FAILED ); - - ret = mbedtls_mpi_lt_mpi_ct( d, &grp->N, &cmp ); - if( ret != 0 ) { + ret = MBEDTLS_ERR_ECP_RANDOM_FAILED; goto cleanup; } + + MBEDTLS_MPI_CHK( mbedtls_mpi_lt_mpi_ct( d, &grp->N, <_upper ) ); + MBEDTLS_MPI_CHK( mbedtls_mpi_lt_mpi_ct( d, &one, <_lower ) ); } - while( mbedtls_mpi_cmp_int( d, 1 ) < 0 || cmp != 1 ); + while( lt_lower != 0 || lt_upper == 0 ); } #endif /* ECP_SHORTWEIERSTRASS */ cleanup: +#if defined(ECP_SHORTWEIERSTRASS) + mbedtls_mpi_free( &one ); +#endif return( ret ); } diff --git a/thirdparty/mbedtls/library/ecp_curves.c b/thirdparty/mbedtls/library/ecp_curves.c index b04596b561..afa3b6324e 100644 --- a/thirdparty/mbedtls/library/ecp_curves.c +++ b/thirdparty/mbedtls/library/ecp_curves.c @@ -54,6 +54,7 @@ #include "mbedtls/ecp.h" #include "mbedtls/platform_util.h" +#include "mbedtls/bn_mul.h" #include <string.h> @@ -70,44 +71,10 @@ #define inline __inline #endif -/* - * Conversion macros for embedded constants: - * build lists of mbedtls_mpi_uint's from lists of unsigned char's grouped by 8, 4 or 2 - */ -#if defined(MBEDTLS_HAVE_INT32) - -#define BYTES_TO_T_UINT_4( a, b, c, d ) \ - ( (mbedtls_mpi_uint) (a) << 0 ) | \ - ( (mbedtls_mpi_uint) (b) << 8 ) | \ - ( (mbedtls_mpi_uint) (c) << 16 ) | \ - ( (mbedtls_mpi_uint) (d) << 24 ) - -#define BYTES_TO_T_UINT_2( a, b ) \ - BYTES_TO_T_UINT_4( a, b, 0, 0 ) - -#define BYTES_TO_T_UINT_8( a, b, c, d, e, f, g, h ) \ - BYTES_TO_T_UINT_4( a, b, c, d ), \ - BYTES_TO_T_UINT_4( e, f, g, h ) - -#else /* 64-bits */ - -#define BYTES_TO_T_UINT_8( a, b, c, d, e, f, g, h ) \ - ( (mbedtls_mpi_uint) (a) << 0 ) | \ - ( (mbedtls_mpi_uint) (b) << 8 ) | \ - ( (mbedtls_mpi_uint) (c) << 16 ) | \ - ( (mbedtls_mpi_uint) (d) << 24 ) | \ - ( (mbedtls_mpi_uint) (e) << 32 ) | \ - ( (mbedtls_mpi_uint) (f) << 40 ) | \ - ( (mbedtls_mpi_uint) (g) << 48 ) | \ - ( (mbedtls_mpi_uint) (h) << 56 ) +#define ECP_MPI_INIT(s, n, p) {s, (n), (mbedtls_mpi_uint *)(p)} -#define BYTES_TO_T_UINT_4( a, b, c, d ) \ - BYTES_TO_T_UINT_8( a, b, c, d, 0, 0, 0, 0 ) - -#define BYTES_TO_T_UINT_2( a, b ) \ - BYTES_TO_T_UINT_8( a, b, 0, 0, 0, 0, 0, 0 ) - -#endif /* bits in mbedtls_mpi_uint */ +#define ECP_MPI_INIT_ARRAY(x) \ + ECP_MPI_INIT(1, sizeof(x) / sizeof(mbedtls_mpi_uint), x) /* * Note: the constants are in little-endian order @@ -119,29 +86,29 @@ */ #if defined(MBEDTLS_ECP_DP_SECP192R1_ENABLED) static const mbedtls_mpi_uint secp192r1_p[] = { - BYTES_TO_T_UINT_8( 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF ), - BYTES_TO_T_UINT_8( 0xFE, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF ), - BYTES_TO_T_UINT_8( 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF ), + MBEDTLS_BYTES_TO_T_UINT_8( 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF ), + MBEDTLS_BYTES_TO_T_UINT_8( 0xFE, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF ), + MBEDTLS_BYTES_TO_T_UINT_8( 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF ), }; static const mbedtls_mpi_uint secp192r1_b[] = { - BYTES_TO_T_UINT_8( 0xB1, 0xB9, 0x46, 0xC1, 0xEC, 0xDE, 0xB8, 0xFE ), - BYTES_TO_T_UINT_8( 0x49, 0x30, 0x24, 0x72, 0xAB, 0xE9, 0xA7, 0x0F ), - BYTES_TO_T_UINT_8( 0xE7, 0x80, 0x9C, 0xE5, 0x19, 0x05, 0x21, 0x64 ), + MBEDTLS_BYTES_TO_T_UINT_8( 0xB1, 0xB9, 0x46, 0xC1, 0xEC, 0xDE, 0xB8, 0xFE ), + MBEDTLS_BYTES_TO_T_UINT_8( 0x49, 0x30, 0x24, 0x72, 0xAB, 0xE9, 0xA7, 0x0F ), + MBEDTLS_BYTES_TO_T_UINT_8( 0xE7, 0x80, 0x9C, 0xE5, 0x19, 0x05, 0x21, 0x64 ), }; static const mbedtls_mpi_uint secp192r1_gx[] = { - BYTES_TO_T_UINT_8( 0x12, 0x10, 0xFF, 0x82, 0xFD, 0x0A, 0xFF, 0xF4 ), - BYTES_TO_T_UINT_8( 0x00, 0x88, 0xA1, 0x43, 0xEB, 0x20, 0xBF, 0x7C ), - BYTES_TO_T_UINT_8( 0xF6, 0x90, 0x30, 0xB0, 0x0E, 0xA8, 0x8D, 0x18 ), + MBEDTLS_BYTES_TO_T_UINT_8( 0x12, 0x10, 0xFF, 0x82, 0xFD, 0x0A, 0xFF, 0xF4 ), + MBEDTLS_BYTES_TO_T_UINT_8( 0x00, 0x88, 0xA1, 0x43, 0xEB, 0x20, 0xBF, 0x7C ), + MBEDTLS_BYTES_TO_T_UINT_8( 0xF6, 0x90, 0x30, 0xB0, 0x0E, 0xA8, 0x8D, 0x18 ), }; static const mbedtls_mpi_uint secp192r1_gy[] = { - BYTES_TO_T_UINT_8( 0x11, 0x48, 0x79, 0x1E, 0xA1, 0x77, 0xF9, 0x73 ), - BYTES_TO_T_UINT_8( 0xD5, 0xCD, 0x24, 0x6B, 0xED, 0x11, 0x10, 0x63 ), - BYTES_TO_T_UINT_8( 0x78, 0xDA, 0xC8, 0xFF, 0x95, 0x2B, 0x19, 0x07 ), + MBEDTLS_BYTES_TO_T_UINT_8( 0x11, 0x48, 0x79, 0x1E, 0xA1, 0x77, 0xF9, 0x73 ), + MBEDTLS_BYTES_TO_T_UINT_8( 0xD5, 0xCD, 0x24, 0x6B, 0xED, 0x11, 0x10, 0x63 ), + MBEDTLS_BYTES_TO_T_UINT_8( 0x78, 0xDA, 0xC8, 0xFF, 0x95, 0x2B, 0x19, 0x07 ), }; static const mbedtls_mpi_uint secp192r1_n[] = { - BYTES_TO_T_UINT_8( 0x31, 0x28, 0xD2, 0xB4, 0xB1, 0xC9, 0x6B, 0x14 ), - BYTES_TO_T_UINT_8( 0x36, 0xF8, 0xDE, 0x99, 0xFF, 0xFF, 0xFF, 0xFF ), - BYTES_TO_T_UINT_8( 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF ), + MBEDTLS_BYTES_TO_T_UINT_8( 0x31, 0x28, 0xD2, 0xB4, 0xB1, 0xC9, 0x6B, 0x14 ), + MBEDTLS_BYTES_TO_T_UINT_8( 0x36, 0xF8, 0xDE, 0x99, 0xFF, 0xFF, 0xFF, 0xFF ), + MBEDTLS_BYTES_TO_T_UINT_8( 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF ), }; #endif /* MBEDTLS_ECP_DP_SECP192R1_ENABLED */ @@ -150,34 +117,34 @@ static const mbedtls_mpi_uint secp192r1_n[] = { */ #if defined(MBEDTLS_ECP_DP_SECP224R1_ENABLED) static const mbedtls_mpi_uint secp224r1_p[] = { - BYTES_TO_T_UINT_8( 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 ), - BYTES_TO_T_UINT_8( 0x00, 0x00, 0x00, 0x00, 0xFF, 0xFF, 0xFF, 0xFF ), - BYTES_TO_T_UINT_8( 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF ), - BYTES_TO_T_UINT_8( 0xFF, 0xFF, 0xFF, 0xFF, 0x00, 0x00, 0x00, 0x00 ), + MBEDTLS_BYTES_TO_T_UINT_8( 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 ), + MBEDTLS_BYTES_TO_T_UINT_8( 0x00, 0x00, 0x00, 0x00, 0xFF, 0xFF, 0xFF, 0xFF ), + MBEDTLS_BYTES_TO_T_UINT_8( 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF ), + MBEDTLS_BYTES_TO_T_UINT_8( 0xFF, 0xFF, 0xFF, 0xFF, 0x00, 0x00, 0x00, 0x00 ), }; static const mbedtls_mpi_uint secp224r1_b[] = { - BYTES_TO_T_UINT_8( 0xB4, 0xFF, 0x55, 0x23, 0x43, 0x39, 0x0B, 0x27 ), - BYTES_TO_T_UINT_8( 0xBA, 0xD8, 0xBF, 0xD7, 0xB7, 0xB0, 0x44, 0x50 ), - BYTES_TO_T_UINT_8( 0x56, 0x32, 0x41, 0xF5, 0xAB, 0xB3, 0x04, 0x0C ), - BYTES_TO_T_UINT_4( 0x85, 0x0A, 0x05, 0xB4 ), + MBEDTLS_BYTES_TO_T_UINT_8( 0xB4, 0xFF, 0x55, 0x23, 0x43, 0x39, 0x0B, 0x27 ), + MBEDTLS_BYTES_TO_T_UINT_8( 0xBA, 0xD8, 0xBF, 0xD7, 0xB7, 0xB0, 0x44, 0x50 ), + MBEDTLS_BYTES_TO_T_UINT_8( 0x56, 0x32, 0x41, 0xF5, 0xAB, 0xB3, 0x04, 0x0C ), + MBEDTLS_BYTES_TO_T_UINT_4( 0x85, 0x0A, 0x05, 0xB4 ), }; static const mbedtls_mpi_uint secp224r1_gx[] = { - BYTES_TO_T_UINT_8( 0x21, 0x1D, 0x5C, 0x11, 0xD6, 0x80, 0x32, 0x34 ), - BYTES_TO_T_UINT_8( 0x22, 0x11, 0xC2, 0x56, 0xD3, 0xC1, 0x03, 0x4A ), - BYTES_TO_T_UINT_8( 0xB9, 0x90, 0x13, 0x32, 0x7F, 0xBF, 0xB4, 0x6B ), - BYTES_TO_T_UINT_4( 0xBD, 0x0C, 0x0E, 0xB7 ), + MBEDTLS_BYTES_TO_T_UINT_8( 0x21, 0x1D, 0x5C, 0x11, 0xD6, 0x80, 0x32, 0x34 ), + MBEDTLS_BYTES_TO_T_UINT_8( 0x22, 0x11, 0xC2, 0x56, 0xD3, 0xC1, 0x03, 0x4A ), + MBEDTLS_BYTES_TO_T_UINT_8( 0xB9, 0x90, 0x13, 0x32, 0x7F, 0xBF, 0xB4, 0x6B ), + MBEDTLS_BYTES_TO_T_UINT_4( 0xBD, 0x0C, 0x0E, 0xB7 ), }; static const mbedtls_mpi_uint secp224r1_gy[] = { - BYTES_TO_T_UINT_8( 0x34, 0x7E, 0x00, 0x85, 0x99, 0x81, 0xD5, 0x44 ), - BYTES_TO_T_UINT_8( 0x64, 0x47, 0x07, 0x5A, 0xA0, 0x75, 0x43, 0xCD ), - BYTES_TO_T_UINT_8( 0xE6, 0xDF, 0x22, 0x4C, 0xFB, 0x23, 0xF7, 0xB5 ), - BYTES_TO_T_UINT_4( 0x88, 0x63, 0x37, 0xBD ), + MBEDTLS_BYTES_TO_T_UINT_8( 0x34, 0x7E, 0x00, 0x85, 0x99, 0x81, 0xD5, 0x44 ), + MBEDTLS_BYTES_TO_T_UINT_8( 0x64, 0x47, 0x07, 0x5A, 0xA0, 0x75, 0x43, 0xCD ), + MBEDTLS_BYTES_TO_T_UINT_8( 0xE6, 0xDF, 0x22, 0x4C, 0xFB, 0x23, 0xF7, 0xB5 ), + MBEDTLS_BYTES_TO_T_UINT_4( 0x88, 0x63, 0x37, 0xBD ), }; static const mbedtls_mpi_uint secp224r1_n[] = { - BYTES_TO_T_UINT_8( 0x3D, 0x2A, 0x5C, 0x5C, 0x45, 0x29, 0xDD, 0x13 ), - BYTES_TO_T_UINT_8( 0x3E, 0xF0, 0xB8, 0xE0, 0xA2, 0x16, 0xFF, 0xFF ), - BYTES_TO_T_UINT_8( 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF ), - BYTES_TO_T_UINT_4( 0xFF, 0xFF, 0xFF, 0xFF ), + MBEDTLS_BYTES_TO_T_UINT_8( 0x3D, 0x2A, 0x5C, 0x5C, 0x45, 0x29, 0xDD, 0x13 ), + MBEDTLS_BYTES_TO_T_UINT_8( 0x3E, 0xF0, 0xB8, 0xE0, 0xA2, 0x16, 0xFF, 0xFF ), + MBEDTLS_BYTES_TO_T_UINT_8( 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF ), + MBEDTLS_BYTES_TO_T_UINT_4( 0xFF, 0xFF, 0xFF, 0xFF ), }; #endif /* MBEDTLS_ECP_DP_SECP224R1_ENABLED */ @@ -186,34 +153,34 @@ static const mbedtls_mpi_uint secp224r1_n[] = { */ #if defined(MBEDTLS_ECP_DP_SECP256R1_ENABLED) static const mbedtls_mpi_uint secp256r1_p[] = { - BYTES_TO_T_UINT_8( 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF ), - BYTES_TO_T_UINT_8( 0xFF, 0xFF, 0xFF, 0xFF, 0x00, 0x00, 0x00, 0x00 ), - BYTES_TO_T_UINT_8( 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 ), - BYTES_TO_T_UINT_8( 0x01, 0x00, 0x00, 0x00, 0xFF, 0xFF, 0xFF, 0xFF ), + MBEDTLS_BYTES_TO_T_UINT_8( 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF ), + MBEDTLS_BYTES_TO_T_UINT_8( 0xFF, 0xFF, 0xFF, 0xFF, 0x00, 0x00, 0x00, 0x00 ), + MBEDTLS_BYTES_TO_T_UINT_8( 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 ), + MBEDTLS_BYTES_TO_T_UINT_8( 0x01, 0x00, 0x00, 0x00, 0xFF, 0xFF, 0xFF, 0xFF ), }; static const mbedtls_mpi_uint secp256r1_b[] = { - BYTES_TO_T_UINT_8( 0x4B, 0x60, 0xD2, 0x27, 0x3E, 0x3C, 0xCE, 0x3B ), - BYTES_TO_T_UINT_8( 0xF6, 0xB0, 0x53, 0xCC, 0xB0, 0x06, 0x1D, 0x65 ), - BYTES_TO_T_UINT_8( 0xBC, 0x86, 0x98, 0x76, 0x55, 0xBD, 0xEB, 0xB3 ), - BYTES_TO_T_UINT_8( 0xE7, 0x93, 0x3A, 0xAA, 0xD8, 0x35, 0xC6, 0x5A ), + MBEDTLS_BYTES_TO_T_UINT_8( 0x4B, 0x60, 0xD2, 0x27, 0x3E, 0x3C, 0xCE, 0x3B ), + MBEDTLS_BYTES_TO_T_UINT_8( 0xF6, 0xB0, 0x53, 0xCC, 0xB0, 0x06, 0x1D, 0x65 ), + MBEDTLS_BYTES_TO_T_UINT_8( 0xBC, 0x86, 0x98, 0x76, 0x55, 0xBD, 0xEB, 0xB3 ), + MBEDTLS_BYTES_TO_T_UINT_8( 0xE7, 0x93, 0x3A, 0xAA, 0xD8, 0x35, 0xC6, 0x5A ), }; static const mbedtls_mpi_uint secp256r1_gx[] = { - BYTES_TO_T_UINT_8( 0x96, 0xC2, 0x98, 0xD8, 0x45, 0x39, 0xA1, 0xF4 ), - BYTES_TO_T_UINT_8( 0xA0, 0x33, 0xEB, 0x2D, 0x81, 0x7D, 0x03, 0x77 ), - BYTES_TO_T_UINT_8( 0xF2, 0x40, 0xA4, 0x63, 0xE5, 0xE6, 0xBC, 0xF8 ), - BYTES_TO_T_UINT_8( 0x47, 0x42, 0x2C, 0xE1, 0xF2, 0xD1, 0x17, 0x6B ), + MBEDTLS_BYTES_TO_T_UINT_8( 0x96, 0xC2, 0x98, 0xD8, 0x45, 0x39, 0xA1, 0xF4 ), + MBEDTLS_BYTES_TO_T_UINT_8( 0xA0, 0x33, 0xEB, 0x2D, 0x81, 0x7D, 0x03, 0x77 ), + MBEDTLS_BYTES_TO_T_UINT_8( 0xF2, 0x40, 0xA4, 0x63, 0xE5, 0xE6, 0xBC, 0xF8 ), + MBEDTLS_BYTES_TO_T_UINT_8( 0x47, 0x42, 0x2C, 0xE1, 0xF2, 0xD1, 0x17, 0x6B ), }; static const mbedtls_mpi_uint secp256r1_gy[] = { - BYTES_TO_T_UINT_8( 0xF5, 0x51, 0xBF, 0x37, 0x68, 0x40, 0xB6, 0xCB ), - BYTES_TO_T_UINT_8( 0xCE, 0x5E, 0x31, 0x6B, 0x57, 0x33, 0xCE, 0x2B ), - BYTES_TO_T_UINT_8( 0x16, 0x9E, 0x0F, 0x7C, 0x4A, 0xEB, 0xE7, 0x8E ), - BYTES_TO_T_UINT_8( 0x9B, 0x7F, 0x1A, 0xFE, 0xE2, 0x42, 0xE3, 0x4F ), + MBEDTLS_BYTES_TO_T_UINT_8( 0xF5, 0x51, 0xBF, 0x37, 0x68, 0x40, 0xB6, 0xCB ), + MBEDTLS_BYTES_TO_T_UINT_8( 0xCE, 0x5E, 0x31, 0x6B, 0x57, 0x33, 0xCE, 0x2B ), + MBEDTLS_BYTES_TO_T_UINT_8( 0x16, 0x9E, 0x0F, 0x7C, 0x4A, 0xEB, 0xE7, 0x8E ), + MBEDTLS_BYTES_TO_T_UINT_8( 0x9B, 0x7F, 0x1A, 0xFE, 0xE2, 0x42, 0xE3, 0x4F ), }; static const mbedtls_mpi_uint secp256r1_n[] = { - BYTES_TO_T_UINT_8( 0x51, 0x25, 0x63, 0xFC, 0xC2, 0xCA, 0xB9, 0xF3 ), - BYTES_TO_T_UINT_8( 0x84, 0x9E, 0x17, 0xA7, 0xAD, 0xFA, 0xE6, 0xBC ), - BYTES_TO_T_UINT_8( 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF ), - BYTES_TO_T_UINT_8( 0x00, 0x00, 0x00, 0x00, 0xFF, 0xFF, 0xFF, 0xFF ), + MBEDTLS_BYTES_TO_T_UINT_8( 0x51, 0x25, 0x63, 0xFC, 0xC2, 0xCA, 0xB9, 0xF3 ), + MBEDTLS_BYTES_TO_T_UINT_8( 0x84, 0x9E, 0x17, 0xA7, 0xAD, 0xFA, 0xE6, 0xBC ), + MBEDTLS_BYTES_TO_T_UINT_8( 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF ), + MBEDTLS_BYTES_TO_T_UINT_8( 0x00, 0x00, 0x00, 0x00, 0xFF, 0xFF, 0xFF, 0xFF ), }; #endif /* MBEDTLS_ECP_DP_SECP256R1_ENABLED */ @@ -222,44 +189,44 @@ static const mbedtls_mpi_uint secp256r1_n[] = { */ #if defined(MBEDTLS_ECP_DP_SECP384R1_ENABLED) static const mbedtls_mpi_uint secp384r1_p[] = { - BYTES_TO_T_UINT_8( 0xFF, 0xFF, 0xFF, 0xFF, 0x00, 0x00, 0x00, 0x00 ), - BYTES_TO_T_UINT_8( 0x00, 0x00, 0x00, 0x00, 0xFF, 0xFF, 0xFF, 0xFF ), - BYTES_TO_T_UINT_8( 0xFE, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF ), - BYTES_TO_T_UINT_8( 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF ), - BYTES_TO_T_UINT_8( 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF ), - BYTES_TO_T_UINT_8( 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF ), + MBEDTLS_BYTES_TO_T_UINT_8( 0xFF, 0xFF, 0xFF, 0xFF, 0x00, 0x00, 0x00, 0x00 ), + MBEDTLS_BYTES_TO_T_UINT_8( 0x00, 0x00, 0x00, 0x00, 0xFF, 0xFF, 0xFF, 0xFF ), + MBEDTLS_BYTES_TO_T_UINT_8( 0xFE, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF ), + MBEDTLS_BYTES_TO_T_UINT_8( 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF ), + MBEDTLS_BYTES_TO_T_UINT_8( 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF ), + MBEDTLS_BYTES_TO_T_UINT_8( 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF ), }; static const mbedtls_mpi_uint secp384r1_b[] = { - BYTES_TO_T_UINT_8( 0xEF, 0x2A, 0xEC, 0xD3, 0xED, 0xC8, 0x85, 0x2A ), - BYTES_TO_T_UINT_8( 0x9D, 0xD1, 0x2E, 0x8A, 0x8D, 0x39, 0x56, 0xC6 ), - BYTES_TO_T_UINT_8( 0x5A, 0x87, 0x13, 0x50, 0x8F, 0x08, 0x14, 0x03 ), - BYTES_TO_T_UINT_8( 0x12, 0x41, 0x81, 0xFE, 0x6E, 0x9C, 0x1D, 0x18 ), - BYTES_TO_T_UINT_8( 0x19, 0x2D, 0xF8, 0xE3, 0x6B, 0x05, 0x8E, 0x98 ), - BYTES_TO_T_UINT_8( 0xE4, 0xE7, 0x3E, 0xE2, 0xA7, 0x2F, 0x31, 0xB3 ), + MBEDTLS_BYTES_TO_T_UINT_8( 0xEF, 0x2A, 0xEC, 0xD3, 0xED, 0xC8, 0x85, 0x2A ), + MBEDTLS_BYTES_TO_T_UINT_8( 0x9D, 0xD1, 0x2E, 0x8A, 0x8D, 0x39, 0x56, 0xC6 ), + MBEDTLS_BYTES_TO_T_UINT_8( 0x5A, 0x87, 0x13, 0x50, 0x8F, 0x08, 0x14, 0x03 ), + MBEDTLS_BYTES_TO_T_UINT_8( 0x12, 0x41, 0x81, 0xFE, 0x6E, 0x9C, 0x1D, 0x18 ), + MBEDTLS_BYTES_TO_T_UINT_8( 0x19, 0x2D, 0xF8, 0xE3, 0x6B, 0x05, 0x8E, 0x98 ), + MBEDTLS_BYTES_TO_T_UINT_8( 0xE4, 0xE7, 0x3E, 0xE2, 0xA7, 0x2F, 0x31, 0xB3 ), }; static const mbedtls_mpi_uint secp384r1_gx[] = { - BYTES_TO_T_UINT_8( 0xB7, 0x0A, 0x76, 0x72, 0x38, 0x5E, 0x54, 0x3A ), - BYTES_TO_T_UINT_8( 0x6C, 0x29, 0x55, 0xBF, 0x5D, 0xF2, 0x02, 0x55 ), - BYTES_TO_T_UINT_8( 0x38, 0x2A, 0x54, 0x82, 0xE0, 0x41, 0xF7, 0x59 ), - BYTES_TO_T_UINT_8( 0x98, 0x9B, 0xA7, 0x8B, 0x62, 0x3B, 0x1D, 0x6E ), - BYTES_TO_T_UINT_8( 0x74, 0xAD, 0x20, 0xF3, 0x1E, 0xC7, 0xB1, 0x8E ), - BYTES_TO_T_UINT_8( 0x37, 0x05, 0x8B, 0xBE, 0x22, 0xCA, 0x87, 0xAA ), + MBEDTLS_BYTES_TO_T_UINT_8( 0xB7, 0x0A, 0x76, 0x72, 0x38, 0x5E, 0x54, 0x3A ), + MBEDTLS_BYTES_TO_T_UINT_8( 0x6C, 0x29, 0x55, 0xBF, 0x5D, 0xF2, 0x02, 0x55 ), + MBEDTLS_BYTES_TO_T_UINT_8( 0x38, 0x2A, 0x54, 0x82, 0xE0, 0x41, 0xF7, 0x59 ), + MBEDTLS_BYTES_TO_T_UINT_8( 0x98, 0x9B, 0xA7, 0x8B, 0x62, 0x3B, 0x1D, 0x6E ), + MBEDTLS_BYTES_TO_T_UINT_8( 0x74, 0xAD, 0x20, 0xF3, 0x1E, 0xC7, 0xB1, 0x8E ), + MBEDTLS_BYTES_TO_T_UINT_8( 0x37, 0x05, 0x8B, 0xBE, 0x22, 0xCA, 0x87, 0xAA ), }; static const mbedtls_mpi_uint secp384r1_gy[] = { - BYTES_TO_T_UINT_8( 0x5F, 0x0E, 0xEA, 0x90, 0x7C, 0x1D, 0x43, 0x7A ), - BYTES_TO_T_UINT_8( 0x9D, 0x81, 0x7E, 0x1D, 0xCE, 0xB1, 0x60, 0x0A ), - BYTES_TO_T_UINT_8( 0xC0, 0xB8, 0xF0, 0xB5, 0x13, 0x31, 0xDA, 0xE9 ), - BYTES_TO_T_UINT_8( 0x7C, 0x14, 0x9A, 0x28, 0xBD, 0x1D, 0xF4, 0xF8 ), - BYTES_TO_T_UINT_8( 0x29, 0xDC, 0x92, 0x92, 0xBF, 0x98, 0x9E, 0x5D ), - BYTES_TO_T_UINT_8( 0x6F, 0x2C, 0x26, 0x96, 0x4A, 0xDE, 0x17, 0x36 ), + MBEDTLS_BYTES_TO_T_UINT_8( 0x5F, 0x0E, 0xEA, 0x90, 0x7C, 0x1D, 0x43, 0x7A ), + MBEDTLS_BYTES_TO_T_UINT_8( 0x9D, 0x81, 0x7E, 0x1D, 0xCE, 0xB1, 0x60, 0x0A ), + MBEDTLS_BYTES_TO_T_UINT_8( 0xC0, 0xB8, 0xF0, 0xB5, 0x13, 0x31, 0xDA, 0xE9 ), + MBEDTLS_BYTES_TO_T_UINT_8( 0x7C, 0x14, 0x9A, 0x28, 0xBD, 0x1D, 0xF4, 0xF8 ), + MBEDTLS_BYTES_TO_T_UINT_8( 0x29, 0xDC, 0x92, 0x92, 0xBF, 0x98, 0x9E, 0x5D ), + MBEDTLS_BYTES_TO_T_UINT_8( 0x6F, 0x2C, 0x26, 0x96, 0x4A, 0xDE, 0x17, 0x36 ), }; static const mbedtls_mpi_uint secp384r1_n[] = { - BYTES_TO_T_UINT_8( 0x73, 0x29, 0xC5, 0xCC, 0x6A, 0x19, 0xEC, 0xEC ), - BYTES_TO_T_UINT_8( 0x7A, 0xA7, 0xB0, 0x48, 0xB2, 0x0D, 0x1A, 0x58 ), - BYTES_TO_T_UINT_8( 0xDF, 0x2D, 0x37, 0xF4, 0x81, 0x4D, 0x63, 0xC7 ), - BYTES_TO_T_UINT_8( 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF ), - BYTES_TO_T_UINT_8( 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF ), - BYTES_TO_T_UINT_8( 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF ), + MBEDTLS_BYTES_TO_T_UINT_8( 0x73, 0x29, 0xC5, 0xCC, 0x6A, 0x19, 0xEC, 0xEC ), + MBEDTLS_BYTES_TO_T_UINT_8( 0x7A, 0xA7, 0xB0, 0x48, 0xB2, 0x0D, 0x1A, 0x58 ), + MBEDTLS_BYTES_TO_T_UINT_8( 0xDF, 0x2D, 0x37, 0xF4, 0x81, 0x4D, 0x63, 0xC7 ), + MBEDTLS_BYTES_TO_T_UINT_8( 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF ), + MBEDTLS_BYTES_TO_T_UINT_8( 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF ), + MBEDTLS_BYTES_TO_T_UINT_8( 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF ), }; #endif /* MBEDTLS_ECP_DP_SECP384R1_ENABLED */ @@ -268,154 +235,154 @@ static const mbedtls_mpi_uint secp384r1_n[] = { */ #if defined(MBEDTLS_ECP_DP_SECP521R1_ENABLED) static const mbedtls_mpi_uint secp521r1_p[] = { - BYTES_TO_T_UINT_8( 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF ), - BYTES_TO_T_UINT_8( 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF ), - BYTES_TO_T_UINT_8( 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF ), - BYTES_TO_T_UINT_8( 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF ), - BYTES_TO_T_UINT_8( 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF ), - BYTES_TO_T_UINT_8( 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF ), - BYTES_TO_T_UINT_8( 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF ), - BYTES_TO_T_UINT_8( 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF ), - BYTES_TO_T_UINT_2( 0xFF, 0x01 ), + MBEDTLS_BYTES_TO_T_UINT_8( 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF ), + MBEDTLS_BYTES_TO_T_UINT_8( 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF ), + MBEDTLS_BYTES_TO_T_UINT_8( 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF ), + MBEDTLS_BYTES_TO_T_UINT_8( 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF ), + MBEDTLS_BYTES_TO_T_UINT_8( 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF ), + MBEDTLS_BYTES_TO_T_UINT_8( 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF ), + MBEDTLS_BYTES_TO_T_UINT_8( 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF ), + MBEDTLS_BYTES_TO_T_UINT_8( 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF ), + MBEDTLS_BYTES_TO_T_UINT_2( 0xFF, 0x01 ), }; static const mbedtls_mpi_uint secp521r1_b[] = { - BYTES_TO_T_UINT_8( 0x00, 0x3F, 0x50, 0x6B, 0xD4, 0x1F, 0x45, 0xEF ), - BYTES_TO_T_UINT_8( 0xF1, 0x34, 0x2C, 0x3D, 0x88, 0xDF, 0x73, 0x35 ), - BYTES_TO_T_UINT_8( 0x07, 0xBF, 0xB1, 0x3B, 0xBD, 0xC0, 0x52, 0x16 ), - BYTES_TO_T_UINT_8( 0x7B, 0x93, 0x7E, 0xEC, 0x51, 0x39, 0x19, 0x56 ), - BYTES_TO_T_UINT_8( 0xE1, 0x09, 0xF1, 0x8E, 0x91, 0x89, 0xB4, 0xB8 ), - BYTES_TO_T_UINT_8( 0xF3, 0x15, 0xB3, 0x99, 0x5B, 0x72, 0xDA, 0xA2 ), - BYTES_TO_T_UINT_8( 0xEE, 0x40, 0x85, 0xB6, 0xA0, 0x21, 0x9A, 0x92 ), - BYTES_TO_T_UINT_8( 0x1F, 0x9A, 0x1C, 0x8E, 0x61, 0xB9, 0x3E, 0x95 ), - BYTES_TO_T_UINT_2( 0x51, 0x00 ), + MBEDTLS_BYTES_TO_T_UINT_8( 0x00, 0x3F, 0x50, 0x6B, 0xD4, 0x1F, 0x45, 0xEF ), + MBEDTLS_BYTES_TO_T_UINT_8( 0xF1, 0x34, 0x2C, 0x3D, 0x88, 0xDF, 0x73, 0x35 ), + MBEDTLS_BYTES_TO_T_UINT_8( 0x07, 0xBF, 0xB1, 0x3B, 0xBD, 0xC0, 0x52, 0x16 ), + MBEDTLS_BYTES_TO_T_UINT_8( 0x7B, 0x93, 0x7E, 0xEC, 0x51, 0x39, 0x19, 0x56 ), + MBEDTLS_BYTES_TO_T_UINT_8( 0xE1, 0x09, 0xF1, 0x8E, 0x91, 0x89, 0xB4, 0xB8 ), + MBEDTLS_BYTES_TO_T_UINT_8( 0xF3, 0x15, 0xB3, 0x99, 0x5B, 0x72, 0xDA, 0xA2 ), + MBEDTLS_BYTES_TO_T_UINT_8( 0xEE, 0x40, 0x85, 0xB6, 0xA0, 0x21, 0x9A, 0x92 ), + MBEDTLS_BYTES_TO_T_UINT_8( 0x1F, 0x9A, 0x1C, 0x8E, 0x61, 0xB9, 0x3E, 0x95 ), + MBEDTLS_BYTES_TO_T_UINT_2( 0x51, 0x00 ), }; static const mbedtls_mpi_uint secp521r1_gx[] = { - BYTES_TO_T_UINT_8( 0x66, 0xBD, 0xE5, 0xC2, 0x31, 0x7E, 0x7E, 0xF9 ), - BYTES_TO_T_UINT_8( 0x9B, 0x42, 0x6A, 0x85, 0xC1, 0xB3, 0x48, 0x33 ), - BYTES_TO_T_UINT_8( 0xDE, 0xA8, 0xFF, 0xA2, 0x27, 0xC1, 0x1D, 0xFE ), - BYTES_TO_T_UINT_8( 0x28, 0x59, 0xE7, 0xEF, 0x77, 0x5E, 0x4B, 0xA1 ), - BYTES_TO_T_UINT_8( 0xBA, 0x3D, 0x4D, 0x6B, 0x60, 0xAF, 0x28, 0xF8 ), - BYTES_TO_T_UINT_8( 0x21, 0xB5, 0x3F, 0x05, 0x39, 0x81, 0x64, 0x9C ), - BYTES_TO_T_UINT_8( 0x42, 0xB4, 0x95, 0x23, 0x66, 0xCB, 0x3E, 0x9E ), - BYTES_TO_T_UINT_8( 0xCD, 0xE9, 0x04, 0x04, 0xB7, 0x06, 0x8E, 0x85 ), - BYTES_TO_T_UINT_2( 0xC6, 0x00 ), + MBEDTLS_BYTES_TO_T_UINT_8( 0x66, 0xBD, 0xE5, 0xC2, 0x31, 0x7E, 0x7E, 0xF9 ), + MBEDTLS_BYTES_TO_T_UINT_8( 0x9B, 0x42, 0x6A, 0x85, 0xC1, 0xB3, 0x48, 0x33 ), + MBEDTLS_BYTES_TO_T_UINT_8( 0xDE, 0xA8, 0xFF, 0xA2, 0x27, 0xC1, 0x1D, 0xFE ), + MBEDTLS_BYTES_TO_T_UINT_8( 0x28, 0x59, 0xE7, 0xEF, 0x77, 0x5E, 0x4B, 0xA1 ), + MBEDTLS_BYTES_TO_T_UINT_8( 0xBA, 0x3D, 0x4D, 0x6B, 0x60, 0xAF, 0x28, 0xF8 ), + MBEDTLS_BYTES_TO_T_UINT_8( 0x21, 0xB5, 0x3F, 0x05, 0x39, 0x81, 0x64, 0x9C ), + MBEDTLS_BYTES_TO_T_UINT_8( 0x42, 0xB4, 0x95, 0x23, 0x66, 0xCB, 0x3E, 0x9E ), + MBEDTLS_BYTES_TO_T_UINT_8( 0xCD, 0xE9, 0x04, 0x04, 0xB7, 0x06, 0x8E, 0x85 ), + MBEDTLS_BYTES_TO_T_UINT_2( 0xC6, 0x00 ), }; static const mbedtls_mpi_uint secp521r1_gy[] = { - BYTES_TO_T_UINT_8( 0x50, 0x66, 0xD1, 0x9F, 0x76, 0x94, 0xBE, 0x88 ), - BYTES_TO_T_UINT_8( 0x40, 0xC2, 0x72, 0xA2, 0x86, 0x70, 0x3C, 0x35 ), - BYTES_TO_T_UINT_8( 0x61, 0x07, 0xAD, 0x3F, 0x01, 0xB9, 0x50, 0xC5 ), - BYTES_TO_T_UINT_8( 0x40, 0x26, 0xF4, 0x5E, 0x99, 0x72, 0xEE, 0x97 ), - BYTES_TO_T_UINT_8( 0x2C, 0x66, 0x3E, 0x27, 0x17, 0xBD, 0xAF, 0x17 ), - BYTES_TO_T_UINT_8( 0x68, 0x44, 0x9B, 0x57, 0x49, 0x44, 0xF5, 0x98 ), - BYTES_TO_T_UINT_8( 0xD9, 0x1B, 0x7D, 0x2C, 0xB4, 0x5F, 0x8A, 0x5C ), - BYTES_TO_T_UINT_8( 0x04, 0xC0, 0x3B, 0x9A, 0x78, 0x6A, 0x29, 0x39 ), - BYTES_TO_T_UINT_2( 0x18, 0x01 ), + MBEDTLS_BYTES_TO_T_UINT_8( 0x50, 0x66, 0xD1, 0x9F, 0x76, 0x94, 0xBE, 0x88 ), + MBEDTLS_BYTES_TO_T_UINT_8( 0x40, 0xC2, 0x72, 0xA2, 0x86, 0x70, 0x3C, 0x35 ), + MBEDTLS_BYTES_TO_T_UINT_8( 0x61, 0x07, 0xAD, 0x3F, 0x01, 0xB9, 0x50, 0xC5 ), + MBEDTLS_BYTES_TO_T_UINT_8( 0x40, 0x26, 0xF4, 0x5E, 0x99, 0x72, 0xEE, 0x97 ), + MBEDTLS_BYTES_TO_T_UINT_8( 0x2C, 0x66, 0x3E, 0x27, 0x17, 0xBD, 0xAF, 0x17 ), + MBEDTLS_BYTES_TO_T_UINT_8( 0x68, 0x44, 0x9B, 0x57, 0x49, 0x44, 0xF5, 0x98 ), + MBEDTLS_BYTES_TO_T_UINT_8( 0xD9, 0x1B, 0x7D, 0x2C, 0xB4, 0x5F, 0x8A, 0x5C ), + MBEDTLS_BYTES_TO_T_UINT_8( 0x04, 0xC0, 0x3B, 0x9A, 0x78, 0x6A, 0x29, 0x39 ), + MBEDTLS_BYTES_TO_T_UINT_2( 0x18, 0x01 ), }; static const mbedtls_mpi_uint secp521r1_n[] = { - BYTES_TO_T_UINT_8( 0x09, 0x64, 0x38, 0x91, 0x1E, 0xB7, 0x6F, 0xBB ), - BYTES_TO_T_UINT_8( 0xAE, 0x47, 0x9C, 0x89, 0xB8, 0xC9, 0xB5, 0x3B ), - BYTES_TO_T_UINT_8( 0xD0, 0xA5, 0x09, 0xF7, 0x48, 0x01, 0xCC, 0x7F ), - BYTES_TO_T_UINT_8( 0x6B, 0x96, 0x2F, 0xBF, 0x83, 0x87, 0x86, 0x51 ), - BYTES_TO_T_UINT_8( 0xFA, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF ), - BYTES_TO_T_UINT_8( 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF ), - BYTES_TO_T_UINT_8( 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF ), - BYTES_TO_T_UINT_8( 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF ), - BYTES_TO_T_UINT_2( 0xFF, 0x01 ), + MBEDTLS_BYTES_TO_T_UINT_8( 0x09, 0x64, 0x38, 0x91, 0x1E, 0xB7, 0x6F, 0xBB ), + MBEDTLS_BYTES_TO_T_UINT_8( 0xAE, 0x47, 0x9C, 0x89, 0xB8, 0xC9, 0xB5, 0x3B ), + MBEDTLS_BYTES_TO_T_UINT_8( 0xD0, 0xA5, 0x09, 0xF7, 0x48, 0x01, 0xCC, 0x7F ), + MBEDTLS_BYTES_TO_T_UINT_8( 0x6B, 0x96, 0x2F, 0xBF, 0x83, 0x87, 0x86, 0x51 ), + MBEDTLS_BYTES_TO_T_UINT_8( 0xFA, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF ), + MBEDTLS_BYTES_TO_T_UINT_8( 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF ), + MBEDTLS_BYTES_TO_T_UINT_8( 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF ), + MBEDTLS_BYTES_TO_T_UINT_8( 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF ), + MBEDTLS_BYTES_TO_T_UINT_2( 0xFF, 0x01 ), }; #endif /* MBEDTLS_ECP_DP_SECP521R1_ENABLED */ #if defined(MBEDTLS_ECP_DP_SECP192K1_ENABLED) static const mbedtls_mpi_uint secp192k1_p[] = { - BYTES_TO_T_UINT_8( 0x37, 0xEE, 0xFF, 0xFF, 0xFE, 0xFF, 0xFF, 0xFF ), - BYTES_TO_T_UINT_8( 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF ), - BYTES_TO_T_UINT_8( 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF ), + MBEDTLS_BYTES_TO_T_UINT_8( 0x37, 0xEE, 0xFF, 0xFF, 0xFE, 0xFF, 0xFF, 0xFF ), + MBEDTLS_BYTES_TO_T_UINT_8( 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF ), + MBEDTLS_BYTES_TO_T_UINT_8( 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF ), }; static const mbedtls_mpi_uint secp192k1_a[] = { - BYTES_TO_T_UINT_2( 0x00, 0x00 ), + MBEDTLS_BYTES_TO_T_UINT_2( 0x00, 0x00 ), }; static const mbedtls_mpi_uint secp192k1_b[] = { - BYTES_TO_T_UINT_2( 0x03, 0x00 ), + MBEDTLS_BYTES_TO_T_UINT_2( 0x03, 0x00 ), }; static const mbedtls_mpi_uint secp192k1_gx[] = { - BYTES_TO_T_UINT_8( 0x7D, 0x6C, 0xE0, 0xEA, 0xB1, 0xD1, 0xA5, 0x1D ), - BYTES_TO_T_UINT_8( 0x34, 0xF4, 0xB7, 0x80, 0x02, 0x7D, 0xB0, 0x26 ), - BYTES_TO_T_UINT_8( 0xAE, 0xE9, 0x57, 0xC0, 0x0E, 0xF1, 0x4F, 0xDB ), + MBEDTLS_BYTES_TO_T_UINT_8( 0x7D, 0x6C, 0xE0, 0xEA, 0xB1, 0xD1, 0xA5, 0x1D ), + MBEDTLS_BYTES_TO_T_UINT_8( 0x34, 0xF4, 0xB7, 0x80, 0x02, 0x7D, 0xB0, 0x26 ), + MBEDTLS_BYTES_TO_T_UINT_8( 0xAE, 0xE9, 0x57, 0xC0, 0x0E, 0xF1, 0x4F, 0xDB ), }; static const mbedtls_mpi_uint secp192k1_gy[] = { - BYTES_TO_T_UINT_8( 0x9D, 0x2F, 0x5E, 0xD9, 0x88, 0xAA, 0x82, 0x40 ), - BYTES_TO_T_UINT_8( 0x34, 0x86, 0xBE, 0x15, 0xD0, 0x63, 0x41, 0x84 ), - BYTES_TO_T_UINT_8( 0xA7, 0x28, 0x56, 0x9C, 0x6D, 0x2F, 0x2F, 0x9B ), + MBEDTLS_BYTES_TO_T_UINT_8( 0x9D, 0x2F, 0x5E, 0xD9, 0x88, 0xAA, 0x82, 0x40 ), + MBEDTLS_BYTES_TO_T_UINT_8( 0x34, 0x86, 0xBE, 0x15, 0xD0, 0x63, 0x41, 0x84 ), + MBEDTLS_BYTES_TO_T_UINT_8( 0xA7, 0x28, 0x56, 0x9C, 0x6D, 0x2F, 0x2F, 0x9B ), }; static const mbedtls_mpi_uint secp192k1_n[] = { - BYTES_TO_T_UINT_8( 0x8D, 0xFD, 0xDE, 0x74, 0x6A, 0x46, 0x69, 0x0F ), - BYTES_TO_T_UINT_8( 0x17, 0xFC, 0xF2, 0x26, 0xFE, 0xFF, 0xFF, 0xFF ), - BYTES_TO_T_UINT_8( 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF ), + MBEDTLS_BYTES_TO_T_UINT_8( 0x8D, 0xFD, 0xDE, 0x74, 0x6A, 0x46, 0x69, 0x0F ), + MBEDTLS_BYTES_TO_T_UINT_8( 0x17, 0xFC, 0xF2, 0x26, 0xFE, 0xFF, 0xFF, 0xFF ), + MBEDTLS_BYTES_TO_T_UINT_8( 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF ), }; #endif /* MBEDTLS_ECP_DP_SECP192K1_ENABLED */ #if defined(MBEDTLS_ECP_DP_SECP224K1_ENABLED) static const mbedtls_mpi_uint secp224k1_p[] = { - BYTES_TO_T_UINT_8( 0x6D, 0xE5, 0xFF, 0xFF, 0xFE, 0xFF, 0xFF, 0xFF ), - BYTES_TO_T_UINT_8( 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF ), - BYTES_TO_T_UINT_8( 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF ), - BYTES_TO_T_UINT_4( 0xFF, 0xFF, 0xFF, 0xFF ), + MBEDTLS_BYTES_TO_T_UINT_8( 0x6D, 0xE5, 0xFF, 0xFF, 0xFE, 0xFF, 0xFF, 0xFF ), + MBEDTLS_BYTES_TO_T_UINT_8( 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF ), + MBEDTLS_BYTES_TO_T_UINT_8( 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF ), + MBEDTLS_BYTES_TO_T_UINT_4( 0xFF, 0xFF, 0xFF, 0xFF ), }; static const mbedtls_mpi_uint secp224k1_a[] = { - BYTES_TO_T_UINT_2( 0x00, 0x00 ), + MBEDTLS_BYTES_TO_T_UINT_2( 0x00, 0x00 ), }; static const mbedtls_mpi_uint secp224k1_b[] = { - BYTES_TO_T_UINT_2( 0x05, 0x00 ), + MBEDTLS_BYTES_TO_T_UINT_2( 0x05, 0x00 ), }; static const mbedtls_mpi_uint secp224k1_gx[] = { - BYTES_TO_T_UINT_8( 0x5C, 0xA4, 0xB7, 0xB6, 0x0E, 0x65, 0x7E, 0x0F ), - BYTES_TO_T_UINT_8( 0xA9, 0x75, 0x70, 0xE4, 0xE9, 0x67, 0xA4, 0x69 ), - BYTES_TO_T_UINT_8( 0xA1, 0x28, 0xFC, 0x30, 0xDF, 0x99, 0xF0, 0x4D ), - BYTES_TO_T_UINT_4( 0x33, 0x5B, 0x45, 0xA1 ), + MBEDTLS_BYTES_TO_T_UINT_8( 0x5C, 0xA4, 0xB7, 0xB6, 0x0E, 0x65, 0x7E, 0x0F ), + MBEDTLS_BYTES_TO_T_UINT_8( 0xA9, 0x75, 0x70, 0xE4, 0xE9, 0x67, 0xA4, 0x69 ), + MBEDTLS_BYTES_TO_T_UINT_8( 0xA1, 0x28, 0xFC, 0x30, 0xDF, 0x99, 0xF0, 0x4D ), + MBEDTLS_BYTES_TO_T_UINT_4( 0x33, 0x5B, 0x45, 0xA1 ), }; static const mbedtls_mpi_uint secp224k1_gy[] = { - BYTES_TO_T_UINT_8( 0xA5, 0x61, 0x6D, 0x55, 0xDB, 0x4B, 0xCA, 0xE2 ), - BYTES_TO_T_UINT_8( 0x59, 0xBD, 0xB0, 0xC0, 0xF7, 0x19, 0xE3, 0xF7 ), - BYTES_TO_T_UINT_8( 0xD6, 0xFB, 0xCA, 0x82, 0x42, 0x34, 0xBA, 0x7F ), - BYTES_TO_T_UINT_4( 0xED, 0x9F, 0x08, 0x7E ), + MBEDTLS_BYTES_TO_T_UINT_8( 0xA5, 0x61, 0x6D, 0x55, 0xDB, 0x4B, 0xCA, 0xE2 ), + MBEDTLS_BYTES_TO_T_UINT_8( 0x59, 0xBD, 0xB0, 0xC0, 0xF7, 0x19, 0xE3, 0xF7 ), + MBEDTLS_BYTES_TO_T_UINT_8( 0xD6, 0xFB, 0xCA, 0x82, 0x42, 0x34, 0xBA, 0x7F ), + MBEDTLS_BYTES_TO_T_UINT_4( 0xED, 0x9F, 0x08, 0x7E ), }; static const mbedtls_mpi_uint secp224k1_n[] = { - BYTES_TO_T_UINT_8( 0xF7, 0xB1, 0x9F, 0x76, 0x71, 0xA9, 0xF0, 0xCA ), - BYTES_TO_T_UINT_8( 0x84, 0x61, 0xEC, 0xD2, 0xE8, 0xDC, 0x01, 0x00 ), - BYTES_TO_T_UINT_8( 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 ), - BYTES_TO_T_UINT_8( 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00 ), + MBEDTLS_BYTES_TO_T_UINT_8( 0xF7, 0xB1, 0x9F, 0x76, 0x71, 0xA9, 0xF0, 0xCA ), + MBEDTLS_BYTES_TO_T_UINT_8( 0x84, 0x61, 0xEC, 0xD2, 0xE8, 0xDC, 0x01, 0x00 ), + MBEDTLS_BYTES_TO_T_UINT_8( 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 ), + MBEDTLS_BYTES_TO_T_UINT_8( 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00 ), }; #endif /* MBEDTLS_ECP_DP_SECP224K1_ENABLED */ #if defined(MBEDTLS_ECP_DP_SECP256K1_ENABLED) static const mbedtls_mpi_uint secp256k1_p[] = { - BYTES_TO_T_UINT_8( 0x2F, 0xFC, 0xFF, 0xFF, 0xFE, 0xFF, 0xFF, 0xFF ), - BYTES_TO_T_UINT_8( 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF ), - BYTES_TO_T_UINT_8( 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF ), - BYTES_TO_T_UINT_8( 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF ), + MBEDTLS_BYTES_TO_T_UINT_8( 0x2F, 0xFC, 0xFF, 0xFF, 0xFE, 0xFF, 0xFF, 0xFF ), + MBEDTLS_BYTES_TO_T_UINT_8( 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF ), + MBEDTLS_BYTES_TO_T_UINT_8( 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF ), + MBEDTLS_BYTES_TO_T_UINT_8( 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF ), }; static const mbedtls_mpi_uint secp256k1_a[] = { - BYTES_TO_T_UINT_2( 0x00, 0x00 ), + MBEDTLS_BYTES_TO_T_UINT_2( 0x00, 0x00 ), }; static const mbedtls_mpi_uint secp256k1_b[] = { - BYTES_TO_T_UINT_2( 0x07, 0x00 ), + MBEDTLS_BYTES_TO_T_UINT_2( 0x07, 0x00 ), }; static const mbedtls_mpi_uint secp256k1_gx[] = { - BYTES_TO_T_UINT_8( 0x98, 0x17, 0xF8, 0x16, 0x5B, 0x81, 0xF2, 0x59 ), - BYTES_TO_T_UINT_8( 0xD9, 0x28, 0xCE, 0x2D, 0xDB, 0xFC, 0x9B, 0x02 ), - BYTES_TO_T_UINT_8( 0x07, 0x0B, 0x87, 0xCE, 0x95, 0x62, 0xA0, 0x55 ), - BYTES_TO_T_UINT_8( 0xAC, 0xBB, 0xDC, 0xF9, 0x7E, 0x66, 0xBE, 0x79 ), + MBEDTLS_BYTES_TO_T_UINT_8( 0x98, 0x17, 0xF8, 0x16, 0x5B, 0x81, 0xF2, 0x59 ), + MBEDTLS_BYTES_TO_T_UINT_8( 0xD9, 0x28, 0xCE, 0x2D, 0xDB, 0xFC, 0x9B, 0x02 ), + MBEDTLS_BYTES_TO_T_UINT_8( 0x07, 0x0B, 0x87, 0xCE, 0x95, 0x62, 0xA0, 0x55 ), + MBEDTLS_BYTES_TO_T_UINT_8( 0xAC, 0xBB, 0xDC, 0xF9, 0x7E, 0x66, 0xBE, 0x79 ), }; static const mbedtls_mpi_uint secp256k1_gy[] = { - BYTES_TO_T_UINT_8( 0xB8, 0xD4, 0x10, 0xFB, 0x8F, 0xD0, 0x47, 0x9C ), - BYTES_TO_T_UINT_8( 0x19, 0x54, 0x85, 0xA6, 0x48, 0xB4, 0x17, 0xFD ), - BYTES_TO_T_UINT_8( 0xA8, 0x08, 0x11, 0x0E, 0xFC, 0xFB, 0xA4, 0x5D ), - BYTES_TO_T_UINT_8( 0x65, 0xC4, 0xA3, 0x26, 0x77, 0xDA, 0x3A, 0x48 ), + MBEDTLS_BYTES_TO_T_UINT_8( 0xB8, 0xD4, 0x10, 0xFB, 0x8F, 0xD0, 0x47, 0x9C ), + MBEDTLS_BYTES_TO_T_UINT_8( 0x19, 0x54, 0x85, 0xA6, 0x48, 0xB4, 0x17, 0xFD ), + MBEDTLS_BYTES_TO_T_UINT_8( 0xA8, 0x08, 0x11, 0x0E, 0xFC, 0xFB, 0xA4, 0x5D ), + MBEDTLS_BYTES_TO_T_UINT_8( 0x65, 0xC4, 0xA3, 0x26, 0x77, 0xDA, 0x3A, 0x48 ), }; static const mbedtls_mpi_uint secp256k1_n[] = { - BYTES_TO_T_UINT_8( 0x41, 0x41, 0x36, 0xD0, 0x8C, 0x5E, 0xD2, 0xBF ), - BYTES_TO_T_UINT_8( 0x3B, 0xA0, 0x48, 0xAF, 0xE6, 0xDC, 0xAE, 0xBA ), - BYTES_TO_T_UINT_8( 0xFE, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF ), - BYTES_TO_T_UINT_8( 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF ), + MBEDTLS_BYTES_TO_T_UINT_8( 0x41, 0x41, 0x36, 0xD0, 0x8C, 0x5E, 0xD2, 0xBF ), + MBEDTLS_BYTES_TO_T_UINT_8( 0x3B, 0xA0, 0x48, 0xAF, 0xE6, 0xDC, 0xAE, 0xBA ), + MBEDTLS_BYTES_TO_T_UINT_8( 0xFE, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF ), + MBEDTLS_BYTES_TO_T_UINT_8( 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF ), }; #endif /* MBEDTLS_ECP_DP_SECP256K1_ENABLED */ @@ -424,40 +391,40 @@ static const mbedtls_mpi_uint secp256k1_n[] = { */ #if defined(MBEDTLS_ECP_DP_BP256R1_ENABLED) static const mbedtls_mpi_uint brainpoolP256r1_p[] = { - BYTES_TO_T_UINT_8( 0x77, 0x53, 0x6E, 0x1F, 0x1D, 0x48, 0x13, 0x20 ), - BYTES_TO_T_UINT_8( 0x28, 0x20, 0x26, 0xD5, 0x23, 0xF6, 0x3B, 0x6E ), - BYTES_TO_T_UINT_8( 0x72, 0x8D, 0x83, 0x9D, 0x90, 0x0A, 0x66, 0x3E ), - BYTES_TO_T_UINT_8( 0xBC, 0xA9, 0xEE, 0xA1, 0xDB, 0x57, 0xFB, 0xA9 ), + MBEDTLS_BYTES_TO_T_UINT_8( 0x77, 0x53, 0x6E, 0x1F, 0x1D, 0x48, 0x13, 0x20 ), + MBEDTLS_BYTES_TO_T_UINT_8( 0x28, 0x20, 0x26, 0xD5, 0x23, 0xF6, 0x3B, 0x6E ), + MBEDTLS_BYTES_TO_T_UINT_8( 0x72, 0x8D, 0x83, 0x9D, 0x90, 0x0A, 0x66, 0x3E ), + MBEDTLS_BYTES_TO_T_UINT_8( 0xBC, 0xA9, 0xEE, 0xA1, 0xDB, 0x57, 0xFB, 0xA9 ), }; static const mbedtls_mpi_uint brainpoolP256r1_a[] = { - BYTES_TO_T_UINT_8( 0xD9, 0xB5, 0x30, 0xF3, 0x44, 0x4B, 0x4A, 0xE9 ), - BYTES_TO_T_UINT_8( 0x6C, 0x5C, 0xDC, 0x26, 0xC1, 0x55, 0x80, 0xFB ), - BYTES_TO_T_UINT_8( 0xE7, 0xFF, 0x7A, 0x41, 0x30, 0x75, 0xF6, 0xEE ), - BYTES_TO_T_UINT_8( 0x57, 0x30, 0x2C, 0xFC, 0x75, 0x09, 0x5A, 0x7D ), + MBEDTLS_BYTES_TO_T_UINT_8( 0xD9, 0xB5, 0x30, 0xF3, 0x44, 0x4B, 0x4A, 0xE9 ), + MBEDTLS_BYTES_TO_T_UINT_8( 0x6C, 0x5C, 0xDC, 0x26, 0xC1, 0x55, 0x80, 0xFB ), + MBEDTLS_BYTES_TO_T_UINT_8( 0xE7, 0xFF, 0x7A, 0x41, 0x30, 0x75, 0xF6, 0xEE ), + MBEDTLS_BYTES_TO_T_UINT_8( 0x57, 0x30, 0x2C, 0xFC, 0x75, 0x09, 0x5A, 0x7D ), }; static const mbedtls_mpi_uint brainpoolP256r1_b[] = { - BYTES_TO_T_UINT_8( 0xB6, 0x07, 0x8C, 0xFF, 0x18, 0xDC, 0xCC, 0x6B ), - BYTES_TO_T_UINT_8( 0xCE, 0xE1, 0xF7, 0x5C, 0x29, 0x16, 0x84, 0x95 ), - BYTES_TO_T_UINT_8( 0xBF, 0x7C, 0xD7, 0xBB, 0xD9, 0xB5, 0x30, 0xF3 ), - BYTES_TO_T_UINT_8( 0x44, 0x4B, 0x4A, 0xE9, 0x6C, 0x5C, 0xDC, 0x26 ), + MBEDTLS_BYTES_TO_T_UINT_8( 0xB6, 0x07, 0x8C, 0xFF, 0x18, 0xDC, 0xCC, 0x6B ), + MBEDTLS_BYTES_TO_T_UINT_8( 0xCE, 0xE1, 0xF7, 0x5C, 0x29, 0x16, 0x84, 0x95 ), + MBEDTLS_BYTES_TO_T_UINT_8( 0xBF, 0x7C, 0xD7, 0xBB, 0xD9, 0xB5, 0x30, 0xF3 ), + MBEDTLS_BYTES_TO_T_UINT_8( 0x44, 0x4B, 0x4A, 0xE9, 0x6C, 0x5C, 0xDC, 0x26 ), }; static const mbedtls_mpi_uint brainpoolP256r1_gx[] = { - BYTES_TO_T_UINT_8( 0x62, 0x32, 0xCE, 0x9A, 0xBD, 0x53, 0x44, 0x3A ), - BYTES_TO_T_UINT_8( 0xC2, 0x23, 0xBD, 0xE3, 0xE1, 0x27, 0xDE, 0xB9 ), - BYTES_TO_T_UINT_8( 0xAF, 0xB7, 0x81, 0xFC, 0x2F, 0x48, 0x4B, 0x2C ), - BYTES_TO_T_UINT_8( 0xCB, 0x57, 0x7E, 0xCB, 0xB9, 0xAE, 0xD2, 0x8B ), + MBEDTLS_BYTES_TO_T_UINT_8( 0x62, 0x32, 0xCE, 0x9A, 0xBD, 0x53, 0x44, 0x3A ), + MBEDTLS_BYTES_TO_T_UINT_8( 0xC2, 0x23, 0xBD, 0xE3, 0xE1, 0x27, 0xDE, 0xB9 ), + MBEDTLS_BYTES_TO_T_UINT_8( 0xAF, 0xB7, 0x81, 0xFC, 0x2F, 0x48, 0x4B, 0x2C ), + MBEDTLS_BYTES_TO_T_UINT_8( 0xCB, 0x57, 0x7E, 0xCB, 0xB9, 0xAE, 0xD2, 0x8B ), }; static const mbedtls_mpi_uint brainpoolP256r1_gy[] = { - BYTES_TO_T_UINT_8( 0x97, 0x69, 0x04, 0x2F, 0xC7, 0x54, 0x1D, 0x5C ), - BYTES_TO_T_UINT_8( 0x54, 0x8E, 0xED, 0x2D, 0x13, 0x45, 0x77, 0xC2 ), - BYTES_TO_T_UINT_8( 0xC9, 0x1D, 0x61, 0x14, 0x1A, 0x46, 0xF8, 0x97 ), - BYTES_TO_T_UINT_8( 0xFD, 0xC4, 0xDA, 0xC3, 0x35, 0xF8, 0x7E, 0x54 ), + MBEDTLS_BYTES_TO_T_UINT_8( 0x97, 0x69, 0x04, 0x2F, 0xC7, 0x54, 0x1D, 0x5C ), + MBEDTLS_BYTES_TO_T_UINT_8( 0x54, 0x8E, 0xED, 0x2D, 0x13, 0x45, 0x77, 0xC2 ), + MBEDTLS_BYTES_TO_T_UINT_8( 0xC9, 0x1D, 0x61, 0x14, 0x1A, 0x46, 0xF8, 0x97 ), + MBEDTLS_BYTES_TO_T_UINT_8( 0xFD, 0xC4, 0xDA, 0xC3, 0x35, 0xF8, 0x7E, 0x54 ), }; static const mbedtls_mpi_uint brainpoolP256r1_n[] = { - BYTES_TO_T_UINT_8( 0xA7, 0x56, 0x48, 0x97, 0x82, 0x0E, 0x1E, 0x90 ), - BYTES_TO_T_UINT_8( 0xF7, 0xA6, 0x61, 0xB5, 0xA3, 0x7A, 0x39, 0x8C ), - BYTES_TO_T_UINT_8( 0x71, 0x8D, 0x83, 0x9D, 0x90, 0x0A, 0x66, 0x3E ), - BYTES_TO_T_UINT_8( 0xBC, 0xA9, 0xEE, 0xA1, 0xDB, 0x57, 0xFB, 0xA9 ), + MBEDTLS_BYTES_TO_T_UINT_8( 0xA7, 0x56, 0x48, 0x97, 0x82, 0x0E, 0x1E, 0x90 ), + MBEDTLS_BYTES_TO_T_UINT_8( 0xF7, 0xA6, 0x61, 0xB5, 0xA3, 0x7A, 0x39, 0x8C ), + MBEDTLS_BYTES_TO_T_UINT_8( 0x71, 0x8D, 0x83, 0x9D, 0x90, 0x0A, 0x66, 0x3E ), + MBEDTLS_BYTES_TO_T_UINT_8( 0xBC, 0xA9, 0xEE, 0xA1, 0xDB, 0x57, 0xFB, 0xA9 ), }; #endif /* MBEDTLS_ECP_DP_BP256R1_ENABLED */ @@ -466,52 +433,52 @@ static const mbedtls_mpi_uint brainpoolP256r1_n[] = { */ #if defined(MBEDTLS_ECP_DP_BP384R1_ENABLED) static const mbedtls_mpi_uint brainpoolP384r1_p[] = { - BYTES_TO_T_UINT_8( 0x53, 0xEC, 0x07, 0x31, 0x13, 0x00, 0x47, 0x87 ), - BYTES_TO_T_UINT_8( 0x71, 0x1A, 0x1D, 0x90, 0x29, 0xA7, 0xD3, 0xAC ), - BYTES_TO_T_UINT_8( 0x23, 0x11, 0xB7, 0x7F, 0x19, 0xDA, 0xB1, 0x12 ), - BYTES_TO_T_UINT_8( 0xB4, 0x56, 0x54, 0xED, 0x09, 0x71, 0x2F, 0x15 ), - BYTES_TO_T_UINT_8( 0xDF, 0x41, 0xE6, 0x50, 0x7E, 0x6F, 0x5D, 0x0F ), - BYTES_TO_T_UINT_8( 0x28, 0x6D, 0x38, 0xA3, 0x82, 0x1E, 0xB9, 0x8C ), + MBEDTLS_BYTES_TO_T_UINT_8( 0x53, 0xEC, 0x07, 0x31, 0x13, 0x00, 0x47, 0x87 ), + MBEDTLS_BYTES_TO_T_UINT_8( 0x71, 0x1A, 0x1D, 0x90, 0x29, 0xA7, 0xD3, 0xAC ), + MBEDTLS_BYTES_TO_T_UINT_8( 0x23, 0x11, 0xB7, 0x7F, 0x19, 0xDA, 0xB1, 0x12 ), + MBEDTLS_BYTES_TO_T_UINT_8( 0xB4, 0x56, 0x54, 0xED, 0x09, 0x71, 0x2F, 0x15 ), + MBEDTLS_BYTES_TO_T_UINT_8( 0xDF, 0x41, 0xE6, 0x50, 0x7E, 0x6F, 0x5D, 0x0F ), + MBEDTLS_BYTES_TO_T_UINT_8( 0x28, 0x6D, 0x38, 0xA3, 0x82, 0x1E, 0xB9, 0x8C ), }; static const mbedtls_mpi_uint brainpoolP384r1_a[] = { - BYTES_TO_T_UINT_8( 0x26, 0x28, 0xCE, 0x22, 0xDD, 0xC7, 0xA8, 0x04 ), - BYTES_TO_T_UINT_8( 0xEB, 0xD4, 0x3A, 0x50, 0x4A, 0x81, 0xA5, 0x8A ), - BYTES_TO_T_UINT_8( 0x0F, 0xF9, 0x91, 0xBA, 0xEF, 0x65, 0x91, 0x13 ), - BYTES_TO_T_UINT_8( 0x87, 0x27, 0xB2, 0x4F, 0x8E, 0xA2, 0xBE, 0xC2 ), - BYTES_TO_T_UINT_8( 0xA0, 0xAF, 0x05, 0xCE, 0x0A, 0x08, 0x72, 0x3C ), - BYTES_TO_T_UINT_8( 0x0C, 0x15, 0x8C, 0x3D, 0xC6, 0x82, 0xC3, 0x7B ), + MBEDTLS_BYTES_TO_T_UINT_8( 0x26, 0x28, 0xCE, 0x22, 0xDD, 0xC7, 0xA8, 0x04 ), + MBEDTLS_BYTES_TO_T_UINT_8( 0xEB, 0xD4, 0x3A, 0x50, 0x4A, 0x81, 0xA5, 0x8A ), + MBEDTLS_BYTES_TO_T_UINT_8( 0x0F, 0xF9, 0x91, 0xBA, 0xEF, 0x65, 0x91, 0x13 ), + MBEDTLS_BYTES_TO_T_UINT_8( 0x87, 0x27, 0xB2, 0x4F, 0x8E, 0xA2, 0xBE, 0xC2 ), + MBEDTLS_BYTES_TO_T_UINT_8( 0xA0, 0xAF, 0x05, 0xCE, 0x0A, 0x08, 0x72, 0x3C ), + MBEDTLS_BYTES_TO_T_UINT_8( 0x0C, 0x15, 0x8C, 0x3D, 0xC6, 0x82, 0xC3, 0x7B ), }; static const mbedtls_mpi_uint brainpoolP384r1_b[] = { - BYTES_TO_T_UINT_8( 0x11, 0x4C, 0x50, 0xFA, 0x96, 0x86, 0xB7, 0x3A ), - BYTES_TO_T_UINT_8( 0x94, 0xC9, 0xDB, 0x95, 0x02, 0x39, 0xB4, 0x7C ), - BYTES_TO_T_UINT_8( 0xD5, 0x62, 0xEB, 0x3E, 0xA5, 0x0E, 0x88, 0x2E ), - BYTES_TO_T_UINT_8( 0xA6, 0xD2, 0xDC, 0x07, 0xE1, 0x7D, 0xB7, 0x2F ), - BYTES_TO_T_UINT_8( 0x7C, 0x44, 0xF0, 0x16, 0x54, 0xB5, 0x39, 0x8B ), - BYTES_TO_T_UINT_8( 0x26, 0x28, 0xCE, 0x22, 0xDD, 0xC7, 0xA8, 0x04 ), + MBEDTLS_BYTES_TO_T_UINT_8( 0x11, 0x4C, 0x50, 0xFA, 0x96, 0x86, 0xB7, 0x3A ), + MBEDTLS_BYTES_TO_T_UINT_8( 0x94, 0xC9, 0xDB, 0x95, 0x02, 0x39, 0xB4, 0x7C ), + MBEDTLS_BYTES_TO_T_UINT_8( 0xD5, 0x62, 0xEB, 0x3E, 0xA5, 0x0E, 0x88, 0x2E ), + MBEDTLS_BYTES_TO_T_UINT_8( 0xA6, 0xD2, 0xDC, 0x07, 0xE1, 0x7D, 0xB7, 0x2F ), + MBEDTLS_BYTES_TO_T_UINT_8( 0x7C, 0x44, 0xF0, 0x16, 0x54, 0xB5, 0x39, 0x8B ), + MBEDTLS_BYTES_TO_T_UINT_8( 0x26, 0x28, 0xCE, 0x22, 0xDD, 0xC7, 0xA8, 0x04 ), }; static const mbedtls_mpi_uint brainpoolP384r1_gx[] = { - BYTES_TO_T_UINT_8( 0x1E, 0xAF, 0xD4, 0x47, 0xE2, 0xB2, 0x87, 0xEF ), - BYTES_TO_T_UINT_8( 0xAA, 0x46, 0xD6, 0x36, 0x34, 0xE0, 0x26, 0xE8 ), - BYTES_TO_T_UINT_8( 0xE8, 0x10, 0xBD, 0x0C, 0xFE, 0xCA, 0x7F, 0xDB ), - BYTES_TO_T_UINT_8( 0xE3, 0x4F, 0xF1, 0x7E, 0xE7, 0xA3, 0x47, 0x88 ), - BYTES_TO_T_UINT_8( 0x6B, 0x3F, 0xC1, 0xB7, 0x81, 0x3A, 0xA6, 0xA2 ), - BYTES_TO_T_UINT_8( 0xFF, 0x45, 0xCF, 0x68, 0xF0, 0x64, 0x1C, 0x1D ), + MBEDTLS_BYTES_TO_T_UINT_8( 0x1E, 0xAF, 0xD4, 0x47, 0xE2, 0xB2, 0x87, 0xEF ), + MBEDTLS_BYTES_TO_T_UINT_8( 0xAA, 0x46, 0xD6, 0x36, 0x34, 0xE0, 0x26, 0xE8 ), + MBEDTLS_BYTES_TO_T_UINT_8( 0xE8, 0x10, 0xBD, 0x0C, 0xFE, 0xCA, 0x7F, 0xDB ), + MBEDTLS_BYTES_TO_T_UINT_8( 0xE3, 0x4F, 0xF1, 0x7E, 0xE7, 0xA3, 0x47, 0x88 ), + MBEDTLS_BYTES_TO_T_UINT_8( 0x6B, 0x3F, 0xC1, 0xB7, 0x81, 0x3A, 0xA6, 0xA2 ), + MBEDTLS_BYTES_TO_T_UINT_8( 0xFF, 0x45, 0xCF, 0x68, 0xF0, 0x64, 0x1C, 0x1D ), }; static const mbedtls_mpi_uint brainpoolP384r1_gy[] = { - BYTES_TO_T_UINT_8( 0x15, 0x53, 0x3C, 0x26, 0x41, 0x03, 0x82, 0x42 ), - BYTES_TO_T_UINT_8( 0x11, 0x81, 0x91, 0x77, 0x21, 0x46, 0x46, 0x0E ), - BYTES_TO_T_UINT_8( 0x28, 0x29, 0x91, 0xF9, 0x4F, 0x05, 0x9C, 0xE1 ), - BYTES_TO_T_UINT_8( 0x64, 0x58, 0xEC, 0xFE, 0x29, 0x0B, 0xB7, 0x62 ), - BYTES_TO_T_UINT_8( 0x52, 0xD5, 0xCF, 0x95, 0x8E, 0xEB, 0xB1, 0x5C ), - BYTES_TO_T_UINT_8( 0xA4, 0xC2, 0xF9, 0x20, 0x75, 0x1D, 0xBE, 0x8A ), + MBEDTLS_BYTES_TO_T_UINT_8( 0x15, 0x53, 0x3C, 0x26, 0x41, 0x03, 0x82, 0x42 ), + MBEDTLS_BYTES_TO_T_UINT_8( 0x11, 0x81, 0x91, 0x77, 0x21, 0x46, 0x46, 0x0E ), + MBEDTLS_BYTES_TO_T_UINT_8( 0x28, 0x29, 0x91, 0xF9, 0x4F, 0x05, 0x9C, 0xE1 ), + MBEDTLS_BYTES_TO_T_UINT_8( 0x64, 0x58, 0xEC, 0xFE, 0x29, 0x0B, 0xB7, 0x62 ), + MBEDTLS_BYTES_TO_T_UINT_8( 0x52, 0xD5, 0xCF, 0x95, 0x8E, 0xEB, 0xB1, 0x5C ), + MBEDTLS_BYTES_TO_T_UINT_8( 0xA4, 0xC2, 0xF9, 0x20, 0x75, 0x1D, 0xBE, 0x8A ), }; static const mbedtls_mpi_uint brainpoolP384r1_n[] = { - BYTES_TO_T_UINT_8( 0x65, 0x65, 0x04, 0xE9, 0x02, 0x32, 0x88, 0x3B ), - BYTES_TO_T_UINT_8( 0x10, 0xC3, 0x7F, 0x6B, 0xAF, 0xB6, 0x3A, 0xCF ), - BYTES_TO_T_UINT_8( 0xA7, 0x25, 0x04, 0xAC, 0x6C, 0x6E, 0x16, 0x1F ), - BYTES_TO_T_UINT_8( 0xB3, 0x56, 0x54, 0xED, 0x09, 0x71, 0x2F, 0x15 ), - BYTES_TO_T_UINT_8( 0xDF, 0x41, 0xE6, 0x50, 0x7E, 0x6F, 0x5D, 0x0F ), - BYTES_TO_T_UINT_8( 0x28, 0x6D, 0x38, 0xA3, 0x82, 0x1E, 0xB9, 0x8C ), + MBEDTLS_BYTES_TO_T_UINT_8( 0x65, 0x65, 0x04, 0xE9, 0x02, 0x32, 0x88, 0x3B ), + MBEDTLS_BYTES_TO_T_UINT_8( 0x10, 0xC3, 0x7F, 0x6B, 0xAF, 0xB6, 0x3A, 0xCF ), + MBEDTLS_BYTES_TO_T_UINT_8( 0xA7, 0x25, 0x04, 0xAC, 0x6C, 0x6E, 0x16, 0x1F ), + MBEDTLS_BYTES_TO_T_UINT_8( 0xB3, 0x56, 0x54, 0xED, 0x09, 0x71, 0x2F, 0x15 ), + MBEDTLS_BYTES_TO_T_UINT_8( 0xDF, 0x41, 0xE6, 0x50, 0x7E, 0x6F, 0x5D, 0x0F ), + MBEDTLS_BYTES_TO_T_UINT_8( 0x28, 0x6D, 0x38, 0xA3, 0x82, 0x1E, 0xB9, 0x8C ), }; #endif /* MBEDTLS_ECP_DP_BP384R1_ENABLED */ @@ -520,64 +487,64 @@ static const mbedtls_mpi_uint brainpoolP384r1_n[] = { */ #if defined(MBEDTLS_ECP_DP_BP512R1_ENABLED) static const mbedtls_mpi_uint brainpoolP512r1_p[] = { - BYTES_TO_T_UINT_8( 0xF3, 0x48, 0x3A, 0x58, 0x56, 0x60, 0xAA, 0x28 ), - BYTES_TO_T_UINT_8( 0x85, 0xC6, 0x82, 0x2D, 0x2F, 0xFF, 0x81, 0x28 ), - BYTES_TO_T_UINT_8( 0xE6, 0x80, 0xA3, 0xE6, 0x2A, 0xA1, 0xCD, 0xAE ), - BYTES_TO_T_UINT_8( 0x42, 0x68, 0xC6, 0x9B, 0x00, 0x9B, 0x4D, 0x7D ), - BYTES_TO_T_UINT_8( 0x71, 0x08, 0x33, 0x70, 0xCA, 0x9C, 0x63, 0xD6 ), - BYTES_TO_T_UINT_8( 0x0E, 0xD2, 0xC9, 0xB3, 0xB3, 0x8D, 0x30, 0xCB ), - BYTES_TO_T_UINT_8( 0x07, 0xFC, 0xC9, 0x33, 0xAE, 0xE6, 0xD4, 0x3F ), - BYTES_TO_T_UINT_8( 0x8B, 0xC4, 0xE9, 0xDB, 0xB8, 0x9D, 0xDD, 0xAA ), + MBEDTLS_BYTES_TO_T_UINT_8( 0xF3, 0x48, 0x3A, 0x58, 0x56, 0x60, 0xAA, 0x28 ), + MBEDTLS_BYTES_TO_T_UINT_8( 0x85, 0xC6, 0x82, 0x2D, 0x2F, 0xFF, 0x81, 0x28 ), + MBEDTLS_BYTES_TO_T_UINT_8( 0xE6, 0x80, 0xA3, 0xE6, 0x2A, 0xA1, 0xCD, 0xAE ), + MBEDTLS_BYTES_TO_T_UINT_8( 0x42, 0x68, 0xC6, 0x9B, 0x00, 0x9B, 0x4D, 0x7D ), + MBEDTLS_BYTES_TO_T_UINT_8( 0x71, 0x08, 0x33, 0x70, 0xCA, 0x9C, 0x63, 0xD6 ), + MBEDTLS_BYTES_TO_T_UINT_8( 0x0E, 0xD2, 0xC9, 0xB3, 0xB3, 0x8D, 0x30, 0xCB ), + MBEDTLS_BYTES_TO_T_UINT_8( 0x07, 0xFC, 0xC9, 0x33, 0xAE, 0xE6, 0xD4, 0x3F ), + MBEDTLS_BYTES_TO_T_UINT_8( 0x8B, 0xC4, 0xE9, 0xDB, 0xB8, 0x9D, 0xDD, 0xAA ), }; static const mbedtls_mpi_uint brainpoolP512r1_a[] = { - BYTES_TO_T_UINT_8( 0xCA, 0x94, 0xFC, 0x77, 0x4D, 0xAC, 0xC1, 0xE7 ), - BYTES_TO_T_UINT_8( 0xB9, 0xC7, 0xF2, 0x2B, 0xA7, 0x17, 0x11, 0x7F ), - BYTES_TO_T_UINT_8( 0xB5, 0xC8, 0x9A, 0x8B, 0xC9, 0xF1, 0x2E, 0x0A ), - BYTES_TO_T_UINT_8( 0xA1, 0x3A, 0x25, 0xA8, 0x5A, 0x5D, 0xED, 0x2D ), - BYTES_TO_T_UINT_8( 0xBC, 0x63, 0x98, 0xEA, 0xCA, 0x41, 0x34, 0xA8 ), - BYTES_TO_T_UINT_8( 0x10, 0x16, 0xF9, 0x3D, 0x8D, 0xDD, 0xCB, 0x94 ), - BYTES_TO_T_UINT_8( 0xC5, 0x4C, 0x23, 0xAC, 0x45, 0x71, 0x32, 0xE2 ), - BYTES_TO_T_UINT_8( 0x89, 0x3B, 0x60, 0x8B, 0x31, 0xA3, 0x30, 0x78 ), + MBEDTLS_BYTES_TO_T_UINT_8( 0xCA, 0x94, 0xFC, 0x77, 0x4D, 0xAC, 0xC1, 0xE7 ), + MBEDTLS_BYTES_TO_T_UINT_8( 0xB9, 0xC7, 0xF2, 0x2B, 0xA7, 0x17, 0x11, 0x7F ), + MBEDTLS_BYTES_TO_T_UINT_8( 0xB5, 0xC8, 0x9A, 0x8B, 0xC9, 0xF1, 0x2E, 0x0A ), + MBEDTLS_BYTES_TO_T_UINT_8( 0xA1, 0x3A, 0x25, 0xA8, 0x5A, 0x5D, 0xED, 0x2D ), + MBEDTLS_BYTES_TO_T_UINT_8( 0xBC, 0x63, 0x98, 0xEA, 0xCA, 0x41, 0x34, 0xA8 ), + MBEDTLS_BYTES_TO_T_UINT_8( 0x10, 0x16, 0xF9, 0x3D, 0x8D, 0xDD, 0xCB, 0x94 ), + MBEDTLS_BYTES_TO_T_UINT_8( 0xC5, 0x4C, 0x23, 0xAC, 0x45, 0x71, 0x32, 0xE2 ), + MBEDTLS_BYTES_TO_T_UINT_8( 0x89, 0x3B, 0x60, 0x8B, 0x31, 0xA3, 0x30, 0x78 ), }; static const mbedtls_mpi_uint brainpoolP512r1_b[] = { - BYTES_TO_T_UINT_8( 0x23, 0xF7, 0x16, 0x80, 0x63, 0xBD, 0x09, 0x28 ), - BYTES_TO_T_UINT_8( 0xDD, 0xE5, 0xBA, 0x5E, 0xB7, 0x50, 0x40, 0x98 ), - BYTES_TO_T_UINT_8( 0x67, 0x3E, 0x08, 0xDC, 0xCA, 0x94, 0xFC, 0x77 ), - BYTES_TO_T_UINT_8( 0x4D, 0xAC, 0xC1, 0xE7, 0xB9, 0xC7, 0xF2, 0x2B ), - BYTES_TO_T_UINT_8( 0xA7, 0x17, 0x11, 0x7F, 0xB5, 0xC8, 0x9A, 0x8B ), - BYTES_TO_T_UINT_8( 0xC9, 0xF1, 0x2E, 0x0A, 0xA1, 0x3A, 0x25, 0xA8 ), - BYTES_TO_T_UINT_8( 0x5A, 0x5D, 0xED, 0x2D, 0xBC, 0x63, 0x98, 0xEA ), - BYTES_TO_T_UINT_8( 0xCA, 0x41, 0x34, 0xA8, 0x10, 0x16, 0xF9, 0x3D ), + MBEDTLS_BYTES_TO_T_UINT_8( 0x23, 0xF7, 0x16, 0x80, 0x63, 0xBD, 0x09, 0x28 ), + MBEDTLS_BYTES_TO_T_UINT_8( 0xDD, 0xE5, 0xBA, 0x5E, 0xB7, 0x50, 0x40, 0x98 ), + MBEDTLS_BYTES_TO_T_UINT_8( 0x67, 0x3E, 0x08, 0xDC, 0xCA, 0x94, 0xFC, 0x77 ), + MBEDTLS_BYTES_TO_T_UINT_8( 0x4D, 0xAC, 0xC1, 0xE7, 0xB9, 0xC7, 0xF2, 0x2B ), + MBEDTLS_BYTES_TO_T_UINT_8( 0xA7, 0x17, 0x11, 0x7F, 0xB5, 0xC8, 0x9A, 0x8B ), + MBEDTLS_BYTES_TO_T_UINT_8( 0xC9, 0xF1, 0x2E, 0x0A, 0xA1, 0x3A, 0x25, 0xA8 ), + MBEDTLS_BYTES_TO_T_UINT_8( 0x5A, 0x5D, 0xED, 0x2D, 0xBC, 0x63, 0x98, 0xEA ), + MBEDTLS_BYTES_TO_T_UINT_8( 0xCA, 0x41, 0x34, 0xA8, 0x10, 0x16, 0xF9, 0x3D ), }; static const mbedtls_mpi_uint brainpoolP512r1_gx[] = { - BYTES_TO_T_UINT_8( 0x22, 0xF8, 0xB9, 0xBC, 0x09, 0x22, 0x35, 0x8B ), - BYTES_TO_T_UINT_8( 0x68, 0x5E, 0x6A, 0x40, 0x47, 0x50, 0x6D, 0x7C ), - BYTES_TO_T_UINT_8( 0x5F, 0x7D, 0xB9, 0x93, 0x7B, 0x68, 0xD1, 0x50 ), - BYTES_TO_T_UINT_8( 0x8D, 0xD4, 0xD0, 0xE2, 0x78, 0x1F, 0x3B, 0xFF ), - BYTES_TO_T_UINT_8( 0x8E, 0x09, 0xD0, 0xF4, 0xEE, 0x62, 0x3B, 0xB4 ), - BYTES_TO_T_UINT_8( 0xC1, 0x16, 0xD9, 0xB5, 0x70, 0x9F, 0xED, 0x85 ), - BYTES_TO_T_UINT_8( 0x93, 0x6A, 0x4C, 0x9C, 0x2E, 0x32, 0x21, 0x5A ), - BYTES_TO_T_UINT_8( 0x64, 0xD9, 0x2E, 0xD8, 0xBD, 0xE4, 0xAE, 0x81 ), + MBEDTLS_BYTES_TO_T_UINT_8( 0x22, 0xF8, 0xB9, 0xBC, 0x09, 0x22, 0x35, 0x8B ), + MBEDTLS_BYTES_TO_T_UINT_8( 0x68, 0x5E, 0x6A, 0x40, 0x47, 0x50, 0x6D, 0x7C ), + MBEDTLS_BYTES_TO_T_UINT_8( 0x5F, 0x7D, 0xB9, 0x93, 0x7B, 0x68, 0xD1, 0x50 ), + MBEDTLS_BYTES_TO_T_UINT_8( 0x8D, 0xD4, 0xD0, 0xE2, 0x78, 0x1F, 0x3B, 0xFF ), + MBEDTLS_BYTES_TO_T_UINT_8( 0x8E, 0x09, 0xD0, 0xF4, 0xEE, 0x62, 0x3B, 0xB4 ), + MBEDTLS_BYTES_TO_T_UINT_8( 0xC1, 0x16, 0xD9, 0xB5, 0x70, 0x9F, 0xED, 0x85 ), + MBEDTLS_BYTES_TO_T_UINT_8( 0x93, 0x6A, 0x4C, 0x9C, 0x2E, 0x32, 0x21, 0x5A ), + MBEDTLS_BYTES_TO_T_UINT_8( 0x64, 0xD9, 0x2E, 0xD8, 0xBD, 0xE4, 0xAE, 0x81 ), }; static const mbedtls_mpi_uint brainpoolP512r1_gy[] = { - BYTES_TO_T_UINT_8( 0x92, 0x08, 0xD8, 0x3A, 0x0F, 0x1E, 0xCD, 0x78 ), - BYTES_TO_T_UINT_8( 0x06, 0x54, 0xF0, 0xA8, 0x2F, 0x2B, 0xCA, 0xD1 ), - BYTES_TO_T_UINT_8( 0xAE, 0x63, 0x27, 0x8A, 0xD8, 0x4B, 0xCA, 0x5B ), - BYTES_TO_T_UINT_8( 0x5E, 0x48, 0x5F, 0x4A, 0x49, 0xDE, 0xDC, 0xB2 ), - BYTES_TO_T_UINT_8( 0x11, 0x81, 0x1F, 0x88, 0x5B, 0xC5, 0x00, 0xA0 ), - BYTES_TO_T_UINT_8( 0x1A, 0x7B, 0xA5, 0x24, 0x00, 0xF7, 0x09, 0xF2 ), - BYTES_TO_T_UINT_8( 0xFD, 0x22, 0x78, 0xCF, 0xA9, 0xBF, 0xEA, 0xC0 ), - BYTES_TO_T_UINT_8( 0xEC, 0x32, 0x63, 0x56, 0x5D, 0x38, 0xDE, 0x7D ), + MBEDTLS_BYTES_TO_T_UINT_8( 0x92, 0x08, 0xD8, 0x3A, 0x0F, 0x1E, 0xCD, 0x78 ), + MBEDTLS_BYTES_TO_T_UINT_8( 0x06, 0x54, 0xF0, 0xA8, 0x2F, 0x2B, 0xCA, 0xD1 ), + MBEDTLS_BYTES_TO_T_UINT_8( 0xAE, 0x63, 0x27, 0x8A, 0xD8, 0x4B, 0xCA, 0x5B ), + MBEDTLS_BYTES_TO_T_UINT_8( 0x5E, 0x48, 0x5F, 0x4A, 0x49, 0xDE, 0xDC, 0xB2 ), + MBEDTLS_BYTES_TO_T_UINT_8( 0x11, 0x81, 0x1F, 0x88, 0x5B, 0xC5, 0x00, 0xA0 ), + MBEDTLS_BYTES_TO_T_UINT_8( 0x1A, 0x7B, 0xA5, 0x24, 0x00, 0xF7, 0x09, 0xF2 ), + MBEDTLS_BYTES_TO_T_UINT_8( 0xFD, 0x22, 0x78, 0xCF, 0xA9, 0xBF, 0xEA, 0xC0 ), + MBEDTLS_BYTES_TO_T_UINT_8( 0xEC, 0x32, 0x63, 0x56, 0x5D, 0x38, 0xDE, 0x7D ), }; static const mbedtls_mpi_uint brainpoolP512r1_n[] = { - BYTES_TO_T_UINT_8( 0x69, 0x00, 0xA9, 0x9C, 0x82, 0x96, 0x87, 0xB5 ), - BYTES_TO_T_UINT_8( 0xDD, 0xDA, 0x5D, 0x08, 0x81, 0xD3, 0xB1, 0x1D ), - BYTES_TO_T_UINT_8( 0x47, 0x10, 0xAC, 0x7F, 0x19, 0x61, 0x86, 0x41 ), - BYTES_TO_T_UINT_8( 0x19, 0x26, 0xA9, 0x4C, 0x41, 0x5C, 0x3E, 0x55 ), - BYTES_TO_T_UINT_8( 0x70, 0x08, 0x33, 0x70, 0xCA, 0x9C, 0x63, 0xD6 ), - BYTES_TO_T_UINT_8( 0x0E, 0xD2, 0xC9, 0xB3, 0xB3, 0x8D, 0x30, 0xCB ), - BYTES_TO_T_UINT_8( 0x07, 0xFC, 0xC9, 0x33, 0xAE, 0xE6, 0xD4, 0x3F ), - BYTES_TO_T_UINT_8( 0x8B, 0xC4, 0xE9, 0xDB, 0xB8, 0x9D, 0xDD, 0xAA ), + MBEDTLS_BYTES_TO_T_UINT_8( 0x69, 0x00, 0xA9, 0x9C, 0x82, 0x96, 0x87, 0xB5 ), + MBEDTLS_BYTES_TO_T_UINT_8( 0xDD, 0xDA, 0x5D, 0x08, 0x81, 0xD3, 0xB1, 0x1D ), + MBEDTLS_BYTES_TO_T_UINT_8( 0x47, 0x10, 0xAC, 0x7F, 0x19, 0x61, 0x86, 0x41 ), + MBEDTLS_BYTES_TO_T_UINT_8( 0x19, 0x26, 0xA9, 0x4C, 0x41, 0x5C, 0x3E, 0x55 ), + MBEDTLS_BYTES_TO_T_UINT_8( 0x70, 0x08, 0x33, 0x70, 0xCA, 0x9C, 0x63, 0xD6 ), + MBEDTLS_BYTES_TO_T_UINT_8( 0x0E, 0xD2, 0xC9, 0xB3, 0xB3, 0x8D, 0x30, 0xCB ), + MBEDTLS_BYTES_TO_T_UINT_8( 0x07, 0xFC, 0xC9, 0x33, 0xAE, 0xE6, 0xD4, 0x3F ), + MBEDTLS_BYTES_TO_T_UINT_8( 0x8B, 0xC4, 0xE9, 0xDB, 0xB8, 0x9D, 0xDD, 0xAA ), }; #endif /* MBEDTLS_ECP_DP_BP512R1_ENABLED */ @@ -689,6 +656,13 @@ static int ecp_mod_p256k1( mbedtls_mpi * ); G ## _n, sizeof( G ## _n ) ) #if defined(MBEDTLS_ECP_DP_CURVE25519_ENABLED) +/* Constants used by ecp_use_curve25519() */ +static const mbedtls_mpi_sint curve25519_a24 = 0x01DB42; +static const unsigned char curve25519_part_of_n[] = { + 0x14, 0xDE, 0xF9, 0xDE, 0xA2, 0xF7, 0x9C, 0xD6, + 0x58, 0x12, 0x63, 0x1A, 0x5C, 0xF5, 0xD3, 0xED, +}; + /* * Specialized function for creating the Curve25519 group */ @@ -697,7 +671,7 @@ static int ecp_use_curve25519( mbedtls_ecp_group *grp ) int ret; /* Actually ( A + 2 ) / 4 */ - MBEDTLS_MPI_CHK( mbedtls_mpi_read_string( &grp->A, 16, "01DB42" ) ); + MBEDTLS_MPI_CHK( mbedtls_mpi_lset( &grp->A, curve25519_a24 ) ); /* P = 2^255 - 19 */ MBEDTLS_MPI_CHK( mbedtls_mpi_lset( &grp->P, 1 ) ); @@ -706,8 +680,8 @@ static int ecp_use_curve25519( mbedtls_ecp_group *grp ) grp->pbits = mbedtls_mpi_bitlen( &grp->P ); /* N = 2^252 + 27742317777372353535851937790883648493 */ - MBEDTLS_MPI_CHK( mbedtls_mpi_read_string( &grp->N, 16, - "14DEF9DEA2F79CD65812631A5CF5D3ED" ) ); + MBEDTLS_MPI_CHK( mbedtls_mpi_read_binary( &grp->N, + curve25519_part_of_n, sizeof( curve25519_part_of_n ) ) ); MBEDTLS_MPI_CHK( mbedtls_mpi_set_bit( &grp->N, 252, 1 ) ); /* Y intentionally not set, since we use x/z coordinates. @@ -728,6 +702,15 @@ cleanup: #endif /* MBEDTLS_ECP_DP_CURVE25519_ENABLED */ #if defined(MBEDTLS_ECP_DP_CURVE448_ENABLED) +/* Constants used by ecp_use_curve448() */ +static const mbedtls_mpi_sint curve448_a24 = 0x98AA; +static const unsigned char curve448_part_of_n[] = { + 0x83, 0x35, 0xDC, 0x16, 0x3B, 0xB1, 0x24, + 0xB6, 0x51, 0x29, 0xC9, 0x6F, 0xDE, 0x93, + 0x3D, 0x8D, 0x72, 0x3A, 0x70, 0xAA, 0xDC, + 0x87, 0x3D, 0x6D, 0x54, 0xA7, 0xBB, 0x0D, +}; + /* * Specialized function for creating the Curve448 group */ @@ -739,7 +722,7 @@ static int ecp_use_curve448( mbedtls_ecp_group *grp ) mbedtls_mpi_init( &Ns ); /* Actually ( A + 2 ) / 4 */ - MBEDTLS_MPI_CHK( mbedtls_mpi_read_string( &grp->A, 16, "98AA" ) ); + MBEDTLS_MPI_CHK( mbedtls_mpi_lset( &grp->A, curve448_a24 ) ); /* P = 2^448 - 2^224 - 1 */ MBEDTLS_MPI_CHK( mbedtls_mpi_lset( &grp->P, 1 ) ); @@ -757,8 +740,8 @@ static int ecp_use_curve448( mbedtls_ecp_group *grp ) /* N = 2^446 - 13818066809895115352007386748515426880336692474882178609894547503885 */ MBEDTLS_MPI_CHK( mbedtls_mpi_set_bit( &grp->N, 446, 1 ) ); - MBEDTLS_MPI_CHK( mbedtls_mpi_read_string( &Ns, 16, - "8335DC163BB124B65129C96FDE933D8D723A70AADC873D6D54A7BB0D" ) ); + MBEDTLS_MPI_CHK( mbedtls_mpi_read_binary( &Ns, + curve448_part_of_n, sizeof( curve448_part_of_n ) ) ); MBEDTLS_MPI_CHK( mbedtls_mpi_sub_mpi( &grp->N, &grp->N, &Ns ) ); /* Actually, the required msb for private keys */ @@ -1048,13 +1031,13 @@ static inline void sub32( uint32_t *dst, uint32_t src, signed char *carry ) /* * If the result is negative, we get it in the form - * c * 2^(bits + 32) + N, with c negative and N positive shorter than 'bits' + * c * 2^bits + N, with c negative and N positive shorter than 'bits' */ static inline int fix_negative( mbedtls_mpi *N, signed char c, mbedtls_mpi *C, size_t bits ) { int ret; - /* C = - c * 2^(bits + 32) */ + /* C = - c * 2^bits */ #if !defined(MBEDTLS_HAVE_INT64) ((void) bits); #else @@ -1452,9 +1435,11 @@ cleanup: static int ecp_mod_p192k1( mbedtls_mpi *N ) { static mbedtls_mpi_uint Rp[] = { - BYTES_TO_T_UINT_8( 0xC9, 0x11, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00 ) }; + MBEDTLS_BYTES_TO_T_UINT_8( 0xC9, 0x11, 0x00, 0x00, 0x01, 0x00, 0x00, + 0x00 ) }; - return( ecp_mod_koblitz( N, Rp, 192 / 8 / sizeof( mbedtls_mpi_uint ), 0, 0, 0 ) ); + return( ecp_mod_koblitz( N, Rp, 192 / 8 / sizeof( mbedtls_mpi_uint ), 0, 0, + 0 ) ); } #endif /* MBEDTLS_ECP_DP_SECP192K1_ENABLED */ @@ -1466,12 +1451,14 @@ static int ecp_mod_p192k1( mbedtls_mpi *N ) static int ecp_mod_p224k1( mbedtls_mpi *N ) { static mbedtls_mpi_uint Rp[] = { - BYTES_TO_T_UINT_8( 0x93, 0x1A, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00 ) }; + MBEDTLS_BYTES_TO_T_UINT_8( 0x93, 0x1A, 0x00, 0x00, 0x01, 0x00, 0x00, + 0x00 ) }; #if defined(MBEDTLS_HAVE_INT64) return( ecp_mod_koblitz( N, Rp, 4, 1, 32, 0xFFFFFFFF ) ); #else - return( ecp_mod_koblitz( N, Rp, 224 / 8 / sizeof( mbedtls_mpi_uint ), 0, 0, 0 ) ); + return( ecp_mod_koblitz( N, Rp, 224 / 8 / sizeof( mbedtls_mpi_uint ), 0, 0, + 0 ) ); #endif } @@ -1485,8 +1472,10 @@ static int ecp_mod_p224k1( mbedtls_mpi *N ) static int ecp_mod_p256k1( mbedtls_mpi *N ) { static mbedtls_mpi_uint Rp[] = { - BYTES_TO_T_UINT_8( 0xD1, 0x03, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00 ) }; - return( ecp_mod_koblitz( N, Rp, 256 / 8 / sizeof( mbedtls_mpi_uint ), 0, 0, 0 ) ); + MBEDTLS_BYTES_TO_T_UINT_8( 0xD1, 0x03, 0x00, 0x00, 0x01, 0x00, 0x00, + 0x00 ) }; + return( ecp_mod_koblitz( N, Rp, 256 / 8 / sizeof( mbedtls_mpi_uint ), 0, 0, + 0 ) ); } #endif /* MBEDTLS_ECP_DP_SECP256K1_ENABLED */ diff --git a/thirdparty/mbedtls/library/entropy.c b/thirdparty/mbedtls/library/entropy.c index c5f414a010..9f1a32bdc1 100644 --- a/thirdparty/mbedtls/library/entropy.c +++ b/thirdparty/mbedtls/library/entropy.c @@ -494,14 +494,20 @@ int mbedtls_entropy_update_nv_seed( mbedtls_entropy_context *ctx ) int mbedtls_entropy_write_seed_file( mbedtls_entropy_context *ctx, const char *path ) { int ret = MBEDTLS_ERR_ENTROPY_FILE_IO_ERROR; - FILE *f; + FILE *f = NULL; unsigned char buf[MBEDTLS_ENTROPY_BLOCK_SIZE]; - if( ( f = fopen( path, "wb" ) ) == NULL ) - return( MBEDTLS_ERR_ENTROPY_FILE_IO_ERROR ); - if( ( ret = mbedtls_entropy_func( ctx, buf, MBEDTLS_ENTROPY_BLOCK_SIZE ) ) != 0 ) + { + ret = MBEDTLS_ERR_ENTROPY_SOURCE_FAILED; + goto exit; + } + + if( ( f = fopen( path, "wb" ) ) == NULL ) + { + ret = MBEDTLS_ERR_ENTROPY_FILE_IO_ERROR; goto exit; + } if( fwrite( buf, 1, MBEDTLS_ENTROPY_BLOCK_SIZE, f ) != MBEDTLS_ENTROPY_BLOCK_SIZE ) { @@ -514,7 +520,9 @@ int mbedtls_entropy_write_seed_file( mbedtls_entropy_context *ctx, const char *p exit: mbedtls_platform_zeroize( buf, sizeof( buf ) ); - fclose( f ); + if( f != NULL ) + fclose( f ); + return( ret ); } diff --git a/thirdparty/mbedtls/library/net_sockets.c b/thirdparty/mbedtls/library/net_sockets.c index 671115f15f..1e701a5000 100644 --- a/thirdparty/mbedtls/library/net_sockets.c +++ b/thirdparty/mbedtls/library/net_sockets.c @@ -47,11 +47,15 @@ /* Enable definition of getaddrinfo() even when compiling with -std=c99. Must * be set before config.h, which pulls in glibc's features.h indirectly. * Harmless on other platforms. */ +#ifndef _POSIX_C_SOURCE #define _POSIX_C_SOURCE 200112L +#endif #if defined(__NetBSD__) +#ifndef _XOPEN_SOURCE #define _XOPEN_SOURCE 600 /* sockaddr_storage */ #endif +#endif #if !defined(MBEDTLS_CONFIG_FILE) #include "mbedtls/config.h" @@ -163,6 +167,31 @@ static int net_prepare( void ) } /* + * Return 0 if the file descriptor is valid, an error otherwise. + * If for_select != 0, check whether the file descriptor is within the range + * allowed for fd_set used for the FD_xxx macros and the select() function. + */ +static int check_fd( int fd, int for_select ) +{ + if( fd < 0 ) + return( MBEDTLS_ERR_NET_INVALID_CONTEXT ); + +#if (defined(_WIN32) || defined(_WIN32_WCE)) && !defined(EFIX64) && \ + !defined(EFI32) + (void) for_select; +#else + /* A limitation of select() is that it only works with file descriptors + * that are strictly less than FD_SETSIZE. This is a limitation of the + * fd_set type. Error out early, because attempting to call FD_SET on a + * large file descriptor is a buffer overflow on typical platforms. */ + if( for_select && fd >= FD_SETSIZE ) + return( MBEDTLS_ERR_NET_POLL_FAILED ); +#endif + + return( 0 ); +} + +/* * Initialize a context */ void mbedtls_net_init( mbedtls_net_context *ctx ) @@ -493,15 +522,9 @@ int mbedtls_net_poll( mbedtls_net_context *ctx, uint32_t rw, uint32_t timeout ) int fd = ctx->fd; - if( fd < 0 ) - return( MBEDTLS_ERR_NET_INVALID_CONTEXT ); - - /* A limitation of select() is that it only works with file descriptors - * that are strictly less than FD_SETSIZE. This is a limitation of the - * fd_set type. Error out early, because attempting to call FD_SET on a - * large file descriptor is a buffer overflow on typical platforms. */ - if( fd >= FD_SETSIZE ) - return( MBEDTLS_ERR_NET_POLL_FAILED ); + ret = check_fd( fd, 1 ); + if( ret != 0 ) + return( ret ); #if defined(__has_feature) #if __has_feature(memory_sanitizer) @@ -580,8 +603,9 @@ int mbedtls_net_recv( void *ctx, unsigned char *buf, size_t len ) int ret; int fd = ((mbedtls_net_context *) ctx)->fd; - if( fd < 0 ) - return( MBEDTLS_ERR_NET_INVALID_CONTEXT ); + ret = check_fd( fd, 0 ); + if( ret != 0 ) + return( ret ); ret = (int) read( fd, buf, len ); @@ -619,15 +643,9 @@ int mbedtls_net_recv_timeout( void *ctx, unsigned char *buf, fd_set read_fds; int fd = ((mbedtls_net_context *) ctx)->fd; - if( fd < 0 ) - return( MBEDTLS_ERR_NET_INVALID_CONTEXT ); - - /* A limitation of select() is that it only works with file descriptors - * that are strictly less than FD_SETSIZE. This is a limitation of the - * fd_set type. Error out early, because attempting to call FD_SET on a - * large file descriptor is a buffer overflow on typical platforms. */ - if( fd >= FD_SETSIZE ) - return( MBEDTLS_ERR_NET_POLL_FAILED ); + ret = check_fd( fd, 1 ); + if( ret != 0 ) + return( ret ); FD_ZERO( &read_fds ); FD_SET( fd, &read_fds ); @@ -667,8 +685,9 @@ int mbedtls_net_send( void *ctx, const unsigned char *buf, size_t len ) int ret; int fd = ((mbedtls_net_context *) ctx)->fd; - if( fd < 0 ) - return( MBEDTLS_ERR_NET_INVALID_CONTEXT ); + ret = check_fd( fd, 0 ); + if( ret != 0 ) + return( ret ); ret = (int) write( fd, buf, len ); diff --git a/thirdparty/mbedtls/library/nist_kw.c b/thirdparty/mbedtls/library/nist_kw.c index 8341ff1303..278b7e91ab 100644 --- a/thirdparty/mbedtls/library/nist_kw.c +++ b/thirdparty/mbedtls/library/nist_kw.c @@ -219,8 +219,6 @@ int mbedtls_nist_kw_wrap( mbedtls_nist_kw_context *ctx, uint64_t t = 0; unsigned char outbuff[KW_SEMIBLOCK_LENGTH * 2]; unsigned char inbuff[KW_SEMIBLOCK_LENGTH * 2]; - unsigned char *R2 = output + KW_SEMIBLOCK_LENGTH; - unsigned char *A = output; *out_len = 0; /* @@ -296,6 +294,9 @@ int mbedtls_nist_kw_wrap( mbedtls_nist_kw_context *ctx, } else { + unsigned char *R2 = output + KW_SEMIBLOCK_LENGTH; + unsigned char *A = output; + /* * Do the wrapping function W, as defined in RFC 3394 section 2.2.1 */ @@ -359,7 +360,7 @@ static int unwrap( mbedtls_nist_kw_context *ctx, uint64_t t = 0; unsigned char outbuff[KW_SEMIBLOCK_LENGTH * 2]; unsigned char inbuff[KW_SEMIBLOCK_LENGTH * 2]; - unsigned char *R = output + ( semiblocks - 2 ) * KW_SEMIBLOCK_LENGTH; + unsigned char *R = NULL; *out_len = 0; if( semiblocks < MIN_SEMIBLOCKS_COUNT ) @@ -369,6 +370,7 @@ static int unwrap( mbedtls_nist_kw_context *ctx, memcpy( A, input, KW_SEMIBLOCK_LENGTH ); memmove( output, input + KW_SEMIBLOCK_LENGTH, ( semiblocks - 1 ) * KW_SEMIBLOCK_LENGTH ); + R = output + ( semiblocks - 2 ) * KW_SEMIBLOCK_LENGTH; /* Calculate intermediate values */ for( t = s; t >= 1; t-- ) diff --git a/thirdparty/mbedtls/library/pk.c b/thirdparty/mbedtls/library/pk.c index 81cfdbfe80..8998271b97 100644 --- a/thirdparty/mbedtls/library/pk.c +++ b/thirdparty/mbedtls/library/pk.c @@ -225,12 +225,15 @@ static inline int pk_hashlen_helper( mbedtls_md_type_t md_alg, size_t *hash_len { const mbedtls_md_info_t *md_info; - if( *hash_len != 0 ) + if( *hash_len != 0 && md_alg == MBEDTLS_MD_NONE ) return( 0 ); if( ( md_info = mbedtls_md_info_from_type( md_alg ) ) == NULL ) return( -1 ); + if ( *hash_len != 0 && *hash_len < mbedtls_md_get_size( md_info ) ) + return ( -1 ); + *hash_len = mbedtls_md_get_size( md_info ); return( 0 ); } diff --git a/thirdparty/mbedtls/library/pkparse.c b/thirdparty/mbedtls/library/pkparse.c index e410f3aae1..2622351a42 100644 --- a/thirdparty/mbedtls/library/pkparse.c +++ b/thirdparty/mbedtls/library/pkparse.c @@ -1070,7 +1070,7 @@ static int pk_parse_key_pkcs8_unencrypted_der( return( MBEDTLS_ERR_PK_KEY_INVALID_VERSION + ret ); if( ( ret = pk_get_pk_alg( &p, end, &pk_alg, ¶ms ) ) != 0 ) - return( MBEDTLS_ERR_PK_KEY_INVALID_FORMAT + ret ); + return( ret ); if( ( ret = mbedtls_asn1_get_tag( &p, end, &len, MBEDTLS_ASN1_OCTET_STRING ) ) != 0 ) return( MBEDTLS_ERR_PK_KEY_INVALID_FORMAT + ret ); diff --git a/thirdparty/mbedtls/library/ssl_ciphersuites.c b/thirdparty/mbedtls/library/ssl_ciphersuites.c index 090040e9ab..01df17a5f3 100644 --- a/thirdparty/mbedtls/library/ssl_ciphersuites.c +++ b/thirdparty/mbedtls/library/ssl_ciphersuites.c @@ -918,13 +918,13 @@ static const mbedtls_ssl_ciphersuite_t ciphersuite_definitions[] = 0 }, #endif /* MBEDTLS_SHA256_C */ -#if defined(MBEDTLS_SHA1_C) +#if defined(MBEDTLS_SHA512_C) { MBEDTLS_TLS_RSA_WITH_CAMELLIA_256_GCM_SHA384, "TLS-RSA-WITH-CAMELLIA-256-GCM-SHA384", MBEDTLS_CIPHER_CAMELLIA_256_GCM, MBEDTLS_MD_SHA384, MBEDTLS_KEY_EXCHANGE_RSA, MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_3, MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_3, 0 }, -#endif /* MBEDTLS_SHA1_C */ +#endif /* MBEDTLS_SHA512_C */ #endif /* MBEDTLS_GCM_C */ #endif /* MBEDTLS_CAMELLIA_C */ diff --git a/thirdparty/mbedtls/library/ssl_cli.c b/thirdparty/mbedtls/library/ssl_cli.c index bd7f28134d..b977e5b7b1 100644 --- a/thirdparty/mbedtls/library/ssl_cli.c +++ b/thirdparty/mbedtls/library/ssl_cli.c @@ -1318,7 +1318,7 @@ static int ssl_parse_max_fragment_length_ext( mbedtls_ssl_context *ssl, mbedtls_ssl_send_alert_message( ssl, MBEDTLS_SSL_ALERT_LEVEL_FATAL, - MBEDTLS_SSL_ALERT_MSG_HANDSHAKE_FAILURE ); + MBEDTLS_SSL_ALERT_MSG_ILLEGAL_PARAMETER ); return( MBEDTLS_ERR_SSL_BAD_HS_SERVER_HELLO ); } @@ -1365,7 +1365,7 @@ static int ssl_parse_encrypt_then_mac_ext( mbedtls_ssl_context *ssl, mbedtls_ssl_send_alert_message( ssl, MBEDTLS_SSL_ALERT_LEVEL_FATAL, - MBEDTLS_SSL_ALERT_MSG_HANDSHAKE_FAILURE ); + MBEDTLS_SSL_ALERT_MSG_UNSUPPORTED_EXT ); return( MBEDTLS_ERR_SSL_BAD_HS_SERVER_HELLO ); } @@ -1391,7 +1391,7 @@ static int ssl_parse_extended_ms_ext( mbedtls_ssl_context *ssl, mbedtls_ssl_send_alert_message( ssl, MBEDTLS_SSL_ALERT_LEVEL_FATAL, - MBEDTLS_SSL_ALERT_MSG_HANDSHAKE_FAILURE ); + MBEDTLS_SSL_ALERT_MSG_UNSUPPORTED_EXT ); return( MBEDTLS_ERR_SSL_BAD_HS_SERVER_HELLO ); } @@ -1416,7 +1416,7 @@ static int ssl_parse_session_ticket_ext( mbedtls_ssl_context *ssl, mbedtls_ssl_send_alert_message( ssl, MBEDTLS_SSL_ALERT_LEVEL_FATAL, - MBEDTLS_SSL_ALERT_MSG_HANDSHAKE_FAILURE ); + MBEDTLS_SSL_ALERT_MSG_UNSUPPORTED_EXT ); return( MBEDTLS_ERR_SSL_BAD_HS_SERVER_HELLO ); } @@ -1522,7 +1522,7 @@ static int ssl_parse_alpn_ext( mbedtls_ssl_context *ssl, mbedtls_ssl_send_alert_message( ssl, MBEDTLS_SSL_ALERT_LEVEL_FATAL, - MBEDTLS_SSL_ALERT_MSG_HANDSHAKE_FAILURE ); + MBEDTLS_SSL_ALERT_MSG_UNSUPPORTED_EXT ); return( MBEDTLS_ERR_SSL_BAD_HS_SERVER_HELLO ); } @@ -2209,6 +2209,7 @@ static int ssl_parse_server_dh_params( mbedtls_ssl_context *ssl, unsigned char *end ) { int ret = MBEDTLS_ERR_SSL_FEATURE_UNAVAILABLE; + size_t dhm_actual_bitlen; /* * Ephemeral DH parameters: @@ -2226,10 +2227,11 @@ static int ssl_parse_server_dh_params( mbedtls_ssl_context *ssl, return( ret ); } - if( ssl->handshake->dhm_ctx.len * 8 < ssl->conf->dhm_min_bitlen ) + dhm_actual_bitlen = mbedtls_mpi_bitlen( &ssl->handshake->dhm_ctx.P ); + if( dhm_actual_bitlen < ssl->conf->dhm_min_bitlen ) { - MBEDTLS_SSL_DEBUG_MSG( 1, ( "DHM prime too short: %d < %d", - ssl->handshake->dhm_ctx.len * 8, + MBEDTLS_SSL_DEBUG_MSG( 1, ( "DHM prime too short: %u < %u", + (unsigned) dhm_actual_bitlen, ssl->conf->dhm_min_bitlen ) ); return( MBEDTLS_ERR_SSL_BAD_HS_SERVER_KEY_EXCHANGE ); } diff --git a/thirdparty/mbedtls/library/ssl_tls.c b/thirdparty/mbedtls/library/ssl_tls.c index c749a8611c..3c1e917598 100644 --- a/thirdparty/mbedtls/library/ssl_tls.c +++ b/thirdparty/mbedtls/library/ssl_tls.c @@ -1895,6 +1895,9 @@ int mbedtls_ssl_cf_hmac( MD_CHK( mbedtls_md_update( ctx, data + offset, 1 ) ); } + /* The context needs to finish() before it starts() again */ + MD_CHK( mbedtls_md_finish( ctx, aux_out ) ); + /* Now compute HASH(okey + inner_hash) */ MD_CHK( mbedtls_md_starts( ctx ) ); MD_CHK( mbedtls_md_update( ctx, okey, block_size ) ); @@ -6364,8 +6367,6 @@ static void ssl_calc_finished_tls_sha256( #if defined(MBEDTLS_SHA512_C) -typedef int (*finish_sha384_t)(mbedtls_sha512_context*, unsigned char*); - static void ssl_calc_finished_tls_sha384( mbedtls_ssl_context *ssl, unsigned char *buf, int from ) { @@ -6373,12 +6374,6 @@ static void ssl_calc_finished_tls_sha384( const char *sender; mbedtls_sha512_context sha512; unsigned char padbuf[48]; - /* - * For SHA-384, we can save 16 bytes by keeping padbuf 48 bytes long. - * However, to avoid stringop-overflow warning in gcc, we have to cast - * mbedtls_sha512_finish_ret(). - */ - finish_sha384_t finish_sha384 = (finish_sha384_t)mbedtls_sha512_finish_ret; mbedtls_ssl_session *session = ssl->session_negotiate; if( !session ) @@ -6404,8 +6399,19 @@ static void ssl_calc_finished_tls_sha384( sender = ( from == MBEDTLS_SSL_IS_CLIENT ) ? "client finished" : "server finished"; - - finish_sha384( &sha512, padbuf ); + /* mbedtls_sha512_finish_ret's output parameter is declared as a + * 64-byte buffer, but sice we're using SHA-384, we know that the + * output fits in 48 bytes. This is correct C, but GCC 11.1 warns + * about it. + */ +#if defined(__GNUC__) && __GNUC__ >= 11 +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wstringop-overflow" +#endif + mbedtls_sha512_finish_ret( &sha512, padbuf ); +#if defined(__GNUC__) && __GNUC__ >= 11 +#pragma GCC diagnostic pop +#endif ssl->handshake->tls_prf( session->master, 48, sender, padbuf, 48, buf, len ); @@ -6678,7 +6684,7 @@ int mbedtls_ssl_parse_finished( mbedtls_ssl_context *ssl ) { MBEDTLS_SSL_DEBUG_MSG( 1, ( "bad finished message" ) ); mbedtls_ssl_send_alert_message( ssl, MBEDTLS_SSL_ALERT_LEVEL_FATAL, - MBEDTLS_SSL_ALERT_MSG_DECODE_ERROR ); + MBEDTLS_SSL_ALERT_MSG_DECRYPT_ERROR ); return( MBEDTLS_ERR_SSL_BAD_HS_FINISHED ); } diff --git a/thirdparty/mbedtls/library/x509_crt.c b/thirdparty/mbedtls/library/x509_crt.c index c458c25ff4..52f6de8fc0 100644 --- a/thirdparty/mbedtls/library/x509_crt.c +++ b/thirdparty/mbedtls/library/x509_crt.c @@ -129,9 +129,8 @@ typedef struct { */ #define X509_MAX_VERIFY_CHAIN_SIZE ( MBEDTLS_X509_MAX_INTERMEDIATE_CA + 2 ) -/* - * Default profile - */ +/* Default profile. Do not remove items unless there are serious security + * concerns. */ const mbedtls_x509_crt_profile mbedtls_x509_crt_profile_default = { #if defined(MBEDTLS_TLS_DEFAULT_ALLOW_SHA1_IN_CERTIFICATES) |