From 894e302d9a2f951105a2c8b69f004ea63eb3bf89 Mon Sep 17 00:00:00 2001 From: Jordan Schidlowsky Date: Thu, 13 Oct 2022 11:15:45 -0600 Subject: [PATCH 01/16] expose additional global enums in 3.x which are available in master (cherry picked from commit dc5226ecfd63703cfda529065aafd4627b316be1) --- core/global_constants.cpp | 16 +++++++++++++++ doc/classes/@GlobalScope.xml | 38 ++++++++++++++++++++++++++++++++++++ 2 files changed, 54 insertions(+) diff --git a/core/global_constants.cpp b/core/global_constants.cpp index ab073013129..c70667485ab 100644 --- a/core/global_constants.cpp +++ b/core/global_constants.cpp @@ -607,6 +607,22 @@ void register_global_constants() { BIND_GLOBAL_ENUM_CONSTANT(PROPERTY_HINT_COLOR_NO_ALPHA); BIND_GLOBAL_ENUM_CONSTANT(PROPERTY_HINT_IMAGE_COMPRESS_LOSSY); BIND_GLOBAL_ENUM_CONSTANT(PROPERTY_HINT_IMAGE_COMPRESS_LOSSLESS); + BIND_GLOBAL_ENUM_CONSTANT(PROPERTY_HINT_OBJECT_ID); + BIND_GLOBAL_ENUM_CONSTANT(PROPERTY_HINT_TYPE_STRING); + + BIND_GLOBAL_ENUM_CONSTANT(PROPERTY_HINT_NODE_PATH_TO_EDITED_NODE); + BIND_GLOBAL_ENUM_CONSTANT(PROPERTY_HINT_METHOD_OF_VARIANT_TYPE); + BIND_GLOBAL_ENUM_CONSTANT(PROPERTY_HINT_METHOD_OF_BASE_TYPE); + BIND_GLOBAL_ENUM_CONSTANT(PROPERTY_HINT_METHOD_OF_INSTANCE); + BIND_GLOBAL_ENUM_CONSTANT(PROPERTY_HINT_METHOD_OF_SCRIPT); + BIND_GLOBAL_ENUM_CONSTANT(PROPERTY_HINT_PROPERTY_OF_VARIANT_TYPE); + BIND_GLOBAL_ENUM_CONSTANT(PROPERTY_HINT_PROPERTY_OF_BASE_TYPE); + BIND_GLOBAL_ENUM_CONSTANT(PROPERTY_HINT_PROPERTY_OF_INSTANCE); + BIND_GLOBAL_ENUM_CONSTANT(PROPERTY_HINT_PROPERTY_OF_SCRIPT); + BIND_GLOBAL_ENUM_CONSTANT(PROPERTY_HINT_OBJECT_TOO_BIG); + BIND_GLOBAL_ENUM_CONSTANT(PROPERTY_HINT_NODE_PATH_VALID_TYPES); + BIND_GLOBAL_ENUM_CONSTANT(PROPERTY_HINT_SAVE_FILE); + BIND_GLOBAL_ENUM_CONSTANT(PROPERTY_HINT_MAX); BIND_GLOBAL_ENUM_CONSTANT(PROPERTY_USAGE_STORAGE); BIND_GLOBAL_ENUM_CONSTANT(PROPERTY_USAGE_EDITOR); diff --git a/doc/classes/@GlobalScope.xml b/doc/classes/@GlobalScope.xml index bc664f13113..1d51658a026 100644 --- a/doc/classes/@GlobalScope.xml +++ b/doc/classes/@GlobalScope.xml @@ -1485,6 +1485,44 @@ Hints that an image is compressed using lossless compression. + + + + Hint that a property represents a particular type. If a property is [constant TYPE_STRING], allows to set a type from the create dialog. If you need to create an [Array] to contain elements of a specific type, the [code]hint_string[/code] must encode nested types using [code]":"[/code] and [code]"/"[/code] for specifying [Resource] types. For instance: + [codeblock] + hint_string = "%s:" % [TYPE_INT] # Array of inteters. + hint_string = "%s:%s:" % [TYPE_ARRAY, TYPE_REAL] # Two-dimensional array of floats. + hint_string = "%s/%s:Resource" % [TYPE_OBJECT, TYPE_OBJECT] # Array of resources. + hint_string = "%s:%s/%s:Resource" % [TYPE_ARRAY, TYPE_OBJECT, TYPE_OBJECT] # Two-dimensional array of resources. + [/codeblock] + [b]Note:[/b] The final colon is required to specify for properly detecting built-in types. + + + + + + + + + + + + + + + + + + + + + + + + + + + The property is serialized and saved in the scene file (default). From 3b833bfaf19619390941873830dc1f71ad5fa301 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A9mi=20Verschelde?= Date: Mon, 12 Dec 2022 09:10:37 +0100 Subject: [PATCH 02/16] Revert "RID: Change comparison operators to use RID_Data id instead of address" (cherry picked from commit c404cc0e5819914af34b37bd964260c66e5b4cab) --- core/rid.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/core/rid.h b/core/rid.h index 1d9eb1dbf94..747c623ffbb 100644 --- a/core/rid.h +++ b/core/rid.h @@ -68,13 +68,13 @@ public: return _data == p_rid._data; } _FORCE_INLINE_ bool operator<(const RID &p_rid) const { - return get_id() < p_rid.get_id(); + return _data < p_rid._data; } _FORCE_INLINE_ bool operator<=(const RID &p_rid) const { - return get_id() <= p_rid.get_id(); + return _data <= p_rid._data; } _FORCE_INLINE_ bool operator>(const RID &p_rid) const { - return get_id() > p_rid.get_id(); + return _data > p_rid._data; } _FORCE_INLINE_ bool operator!=(const RID &p_rid) const { return _data != p_rid._data; From 5dc2a60c64bd028cf2ccbefbb1460215f99da853 Mon Sep 17 00:00:00 2001 From: Hugo Locurcio Date: Sun, 23 Oct 2022 00:03:00 +0200 Subject: [PATCH 03/16] Document debanding only affecting 3D rendering by default (cherry picked from commit 4475a93736ff05c27a21f29a01e59e1dd9c4483c) --- doc/classes/ProjectSettings.xml | 4 +++- doc/classes/Viewport.xml | 7 ++++--- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/doc/classes/ProjectSettings.xml b/doc/classes/ProjectSettings.xml index 0da34af29c4..328446cf3f3 100644 --- a/doc/classes/ProjectSettings.xml +++ b/doc/classes/ProjectSettings.xml @@ -1673,9 +1673,11 @@ If set to a value greater than [code]0.0[/code], contrast-adaptive sharpening will be applied to the 3D viewport. This has a low performance cost and can be used to recover some of the sharpness lost from using FXAA. Values around [code]0.5[/code] generally give the best results. See also [member rendering/quality/filters/use_fxaa]. - If [code]true[/code], uses a fast post-processing filter to make banding significantly less visible. In some cases, debanding may introduce a slightly noticeable dithering pattern. It's recommended to enable debanding only when actually needed since the dithering pattern will make lossless-compressed screenshots larger. + If [code]true[/code], uses a fast post-processing filter to make banding significantly less visible in 3D. 2D rendering is [i]not[/i] affected by debanding unless the [member Environment.background_mode] is [constant Environment.BG_CANVAS]. In this case, [member rendering/quality/intended_usage/framebuffer_allocation] must also be set to [b]3D[/b]. + In some cases, debanding may introduce a slightly noticeable dithering pattern. It's recommended to enable debanding only when actually needed since the dithering pattern will make lossless-compressed screenshots larger. [b]Note:[/b] Only available on the GLES3 backend. [member rendering/quality/depth/hdr] must also be [code]true[/code] for debanding to be effective. [b]Note:[/b] There are known issues with debanding breaking rendering on mobile platforms. Due to this, it is recommended to leave this option disabled when targeting mobile platforms. + [b]Note:[/b] This property is only read when the project starts. To set debanding at run-time, set [member Viewport.debanding] on the root [Viewport] instead. Enables FXAA in the root Viewport. FXAA is a popular screen-space antialiasing method, which is fast but will make the image look blurry, especially at lower resolutions. It can still work relatively well at large resolutions such as 1440p and 4K. Some of the lost sharpness can be recovered by enabling contrast-adaptive sharpening (see [member rendering/quality/filters/sharpen_intensity]). diff --git a/doc/classes/Viewport.xml b/doc/classes/Viewport.xml index 43ef70309f7..d76373be1cd 100644 --- a/doc/classes/Viewport.xml +++ b/doc/classes/Viewport.xml @@ -208,14 +208,15 @@ The canvas transform of the viewport, useful for changing the on-screen positions of all child [CanvasItem]s. This is relative to the global canvas transform of the viewport. - If [code]true[/code], uses a fast post-processing filter to make banding significantly less visible. In some cases, debanding may introduce a slightly noticeable dithering pattern. It's recommended to enable debanding only when actually needed since the dithering pattern will make lossless-compressed screenshots larger. + If [code]true[/code], uses a fast post-processing filter to make banding significantly less visible in 3D. 2D rendering is [i]not[/i] affected by debanding unless the [member Environment.background_mode] is [constant Environment.BG_CANVAS]. In this case, [member usage] must also be set to [constant USAGE_3D]. See also [member ProjectSettings.rendering/quality/filters/use_debanding]. + In some cases, debanding may introduce a slightly noticeable dithering pattern. It's recommended to enable debanding only when actually needed since the dithering pattern will make lossless-compressed screenshots larger. [b]Note:[/b] Only available on the GLES3 backend. [member hdr] must also be [code]true[/code] for debanding to be effective. The overlay mode for test rendered geometry in debug purposes. - If [code]true[/code], the viewport will disable 3D rendering. For actual disabling use [code]usage[/code]. + If [code]true[/code], the viewport will disable 3D rendering. To actually disable allocation of 3D buffers, set [member usage] instead. Enables fast approximate antialiasing. FXAA is a popular screen-space antialiasing method, which is fast but will make the image look blurry, especially at lower resolutions. It can still work relatively well at large resolutions such as 1440p and 4K. Some of the lost sharpness can be recovered by enabling contrast-adaptive sharpening (see [member sharpen_intensity]). @@ -290,7 +291,7 @@ If [code]true[/code], the viewport should render its background as transparent. - The rendering mode of viewport. + The viewport's rendering mode. This controls which buffers are allocated for the viewport (2D only, or 2D + 3D). 2D-only options can reduce memory usage and improve performance slightly, especially on low-end devices. [b]Note:[/b] If set to [constant USAGE_2D] or [constant USAGE_2D_NO_SAMPLING], [member hdr] will have no effect when enabled since HDR is not supported for 2D. From eb100cbddb19c1c8095c2872c4784f579bd9d27e Mon Sep 17 00:00:00 2001 From: Hugo Locurcio Date: Fri, 7 Oct 2022 19:03:24 +0200 Subject: [PATCH 04/16] Only support XDG directory path configuration on Linux MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This also harmonizes the server code to be consistent with Linux desktop (with warnings printed for relative XDG paths). Co-authored-by: RĂ©mi Verschelde (cherry picked from commit 06c266f231992dc4feda76e4e2e2d678019f1429) --- doc/classes/OS.xml | 6 ++-- platform/osx/os_osx.mm | 24 ---------------- platform/server/os_server.cpp | 51 +++++++++++++++++++++++---------- platform/windows/os_windows.cpp | 26 +---------------- 4 files changed, 40 insertions(+), 67 deletions(-) diff --git a/doc/classes/OS.xml b/doc/classes/OS.xml index dcb2ce9c6a8..b26aa447084 100644 --- a/doc/classes/OS.xml +++ b/doc/classes/OS.xml @@ -143,7 +143,7 @@ - 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=$DOCS_URL/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]. + Returns the [i]global[/i] cache data directory according to the operating system's standards. On Linux, this path can be overridden by setting the [code]XDG_CACHE_HOME[/code] environment variable before starting the project. See [url=$DOCS_URL/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. @@ -171,7 +171,7 @@ - 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=$DOCS_URL/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]. + Returns the [i]global[/i] user configuration directory according to the operating system's standards. On Linux, this path can be overridden by setting the [code]XDG_CONFIG_HOME[/code] environment variable before starting the project. See [url=$DOCS_URL/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. @@ -192,7 +192,7 @@ - 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=$DOCS_URL/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]. + Returns the [i]global[/i] user data directory according to the operating system's standards. On Linux, this path can be overridden by setting the [code]XDG_DATA_HOME[/code] environment variable before starting the project. See [url=$DOCS_URL/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. diff --git a/platform/osx/os_osx.mm b/platform/osx/os_osx.mm index e501dfcb5a5..02b9587a765 100644 --- a/platform/osx/os_osx.mm +++ b/platform/osx/os_osx.mm @@ -2285,14 +2285,6 @@ MainLoop *OS_OSX::get_main_loop() const { } String OS_OSX::get_config_path() const { - // The XDG Base Directory specification technically only applies on Linux/*BSD, but it doesn't hurt to support it on macOS as well. - if (has_environment("XDG_CONFIG_HOME")) { - if (get_environment("XDG_CONFIG_HOME").is_abs_path()) { - return get_environment("XDG_CONFIG_HOME"); - } else { - WARN_PRINT_ONCE("`XDG_CONFIG_HOME` is a relative path. Ignoring its value and falling back to `$HOME/Library/Application Support` or `.` per the XDG Base Directory specification."); - } - } if (has_environment("HOME")) { return get_environment("HOME").plus_file("Library/Application Support"); } @@ -2300,26 +2292,10 @@ String OS_OSX::get_config_path() const { } String OS_OSX::get_data_path() const { - // The XDG Base Directory specification technically only applies on Linux/*BSD, but it doesn't hurt to support it on macOS as well. - if (has_environment("XDG_DATA_HOME")) { - if (get_environment("XDG_DATA_HOME").is_abs_path()) { - return get_environment("XDG_DATA_HOME"); - } else { - WARN_PRINT_ONCE("`XDG_DATA_HOME` is a relative path. Ignoring its value and falling back to `get_config_path()` per the XDG Base Directory specification."); - } - } return get_config_path(); } String OS_OSX::get_cache_path() const { - // The XDG Base Directory specification technically only applies on Linux/*BSD, but it doesn't hurt to support it on macOS as well. - if (has_environment("XDG_CACHE_HOME")) { - if (get_environment("XDG_CACHE_HOME").is_abs_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/Library/Caches` or `get_config_path()` per the XDG Base Directory specification."); - } - } if (has_environment("HOME")) { return get_environment("HOME").plus_file("Library/Caches"); } diff --git a/platform/server/os_server.cpp b/platform/server/os_server.cpp index 0317a1668e5..943d298052b 100644 --- a/platform/server/os_server.cpp +++ b/platform/server/os_server.cpp @@ -207,33 +207,54 @@ void OS_Server::run() { } String OS_Server::get_config_path() const { +#ifndef __APPLE__ if (has_environment("XDG_CONFIG_HOME")) { - return get_environment("XDG_CONFIG_HOME"); - } else if (has_environment("HOME")) { - return get_environment("HOME").plus_file(".config"); - } else { - return "."; + if (get_environment("XDG_CONFIG_HOME").is_abs_path()) { + return get_environment("XDG_CONFIG_HOME"); + } else { + WARN_PRINT_ONCE("`XDG_CONFIG_HOME` is a relative path. Ignoring its value and falling back to `$HOME/.config` or `.` per the XDG Base Directory specification."); + } } +#endif + + if (has_environment("HOME")) { + return get_environment("HOME").plus_file(".config"); + } + return "."; } String OS_Server::get_data_path() const { +#ifndef __APPLE__ if (has_environment("XDG_DATA_HOME")) { - return get_environment("XDG_DATA_HOME"); - } else if (has_environment("HOME")) { - return get_environment("HOME").plus_file(".local/share"); - } else { - return get_config_path(); + if (get_environment("XDG_DATA_HOME").is_abs_path()) { + return get_environment("XDG_DATA_HOME"); + } else { + WARN_PRINT_ONCE("`XDG_DATA_HOME` is a relative path. Ignoring its value and falling back to `$HOME/.local/share` or `get_config_path()` per the XDG Base Directory specification."); + } } +#endif + + if (has_environment("HOME")) { + return get_environment("HOME").plus_file(".local/share"); + } + return get_config_path(); } String OS_Server::get_cache_path() const { +#ifndef __APPLE__ if (has_environment("XDG_CACHE_HOME")) { - return get_environment("XDG_CACHE_HOME"); - } else if (has_environment("HOME")) { - return get_environment("HOME").plus_file(".cache"); - } else { - return get_config_path(); + if (get_environment("XDG_CACHE_HOME").is_abs_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/.cache` or `get_config_path()` per the XDG Base Directory specification."); + } } +#endif + + if (has_environment("HOME")) { + return get_environment("HOME").plus_file(".cache"); + } + return get_config_path(); } String OS_Server::get_system_dir(SystemDir p_dir, bool p_shared_storage) const { diff --git a/platform/windows/os_windows.cpp b/platform/windows/os_windows.cpp index 791082ab7be..a54d90baf58 100644 --- a/platform/windows/os_windows.cpp +++ b/platform/windows/os_windows.cpp @@ -3604,14 +3604,6 @@ uint64_t OS_Windows::get_embedded_pck_offset() const { } String OS_Windows::get_config_path() const { - // The XDG Base Directory specification technically only applies on Linux/*BSD, but it doesn't hurt to support it on Windows as well. - if (has_environment("XDG_CONFIG_HOME")) { - if (get_environment("XDG_CONFIG_HOME").is_abs_path()) { - return get_environment("XDG_CONFIG_HOME").replace("\\", "/"); - } else { - WARN_PRINT_ONCE("`XDG_CONFIG_HOME` is a relative path. Ignoring its value and falling back to `%APPDATA%` or `.` per the XDG Base Directory specification."); - } - } if (has_environment("APPDATA")) { return get_environment("APPDATA").replace("\\", "/"); } @@ -3619,29 +3611,13 @@ String OS_Windows::get_config_path() const { } String OS_Windows::get_data_path() const { - // The XDG Base Directory specification technically only applies on Linux/*BSD, but it doesn't hurt to support it on Windows as well. - if (has_environment("XDG_DATA_HOME")) { - if (get_environment("XDG_DATA_HOME").is_abs_path()) { - return get_environment("XDG_DATA_HOME").replace("\\", "/"); - } else { - WARN_PRINT_ONCE("`XDG_DATA_HOME` is a relative path. Ignoring its value and falling back to `get_config_path()` per the XDG Base Directory specification."); - } - } return get_config_path(); } String OS_Windows::get_cache_path() const { static String cache_path_cache; if (cache_path_cache == String()) { - // The XDG Base Directory specification technically only applies on Linux/*BSD, but it doesn't hurt to support it on Windows as well. - if (has_environment("XDG_CACHE_HOME")) { - if (get_environment("XDG_CACHE_HOME").is_abs_path()) { - cache_path_cache = get_environment("XDG_CACHE_HOME").replace("\\", "/"); - } else { - WARN_PRINT_ONCE("`XDG_CACHE_HOME` is a relative path. Ignoring its value and falling back to `%LOCALAPPDATA%\\cache`, `%TEMP%` or `get_config_path()` per the XDG Base Directory specification."); - } - } - if (cache_path_cache == String() && has_environment("LOCALAPPDATA")) { + if (has_environment("LOCALAPPDATA")) { cache_path_cache = get_environment("LOCALAPPDATA").replace("\\", "/"); } if (cache_path_cache == String() && has_environment("TEMP")) { From f1231a7c7e7f11e014378a8bdea3042fb255d067 Mon Sep 17 00:00:00 2001 From: ray90514 Date: Fri, 9 Apr 2021 23:02:39 +0800 Subject: [PATCH 05/16] Fix Script editor completion doesn't suggest members of a script for type hints (cherry picked from commit 7afbd5904e8cfccd8e87ddfca9f05359ca2df113) --- modules/gdscript/gdscript_editor.cpp | 11 ++++++++++- modules/gdscript/gdscript_parser.cpp | 1 + 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/modules/gdscript/gdscript_editor.cpp b/modules/gdscript/gdscript_editor.cpp index d1b49076abd..89eadd9ca6f 100644 --- a/modules/gdscript/gdscript_editor.cpp +++ b/modules/gdscript/gdscript_editor.cpp @@ -2983,8 +2983,17 @@ Error GDScriptLanguage::complete_code(const String &p_code, const String &p_path base_type.has_type = false; } } break; - case GDScriptParser::DataType::SCRIPT: case GDScriptParser::DataType::GDSCRIPT: { + Ref scr = base_type.script_type; + if (scr.is_valid()) { + for (const Map>::Element *E = scr->get_subclasses().front(); E; E = E->next()) { + ScriptCodeCompletionOption option(E->key().operator String(), ScriptCodeCompletionOption::KIND_CLASS); + options.insert(option.display, option); + } + } + FALLTHROUGH; + } + case GDScriptParser::DataType::SCRIPT: { Ref