summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--.github/workflows/ios_builds.yml2
-rw-r--r--SConstruct29
-rw-r--r--core/SCsub1
-rw-r--r--core/config/engine.cpp5
-rw-r--r--core/core_constants.cpp3
-rw-r--r--core/math/vector2.h4
-rw-r--r--core/math/vector2i.h22
-rw-r--r--core/object/callable_method_pointer.h8
-rw-r--r--core/object/class_db.cpp3
-rw-r--r--core/string/string_name.h12
-rw-r--r--core/string/translation.cpp1
-rw-r--r--core/variant/callable.cpp9
-rw-r--r--core/variant/callable.h1
-rw-r--r--core/variant/callable_bind.cpp14
-rw-r--r--core/variant/callable_bind.h2
-rw-r--r--core/variant/variant_call.cpp3
-rw-r--r--core/variant/variant_op.cpp5
-rw-r--r--core/version.h3
-rw-r--r--doc/classes/@GlobalScope.xml6
-rw-r--r--doc/classes/ArrayOccluder3D.xml24
-rw-r--r--doc/classes/AudioStreamRandomPitch.xml19
-rw-r--r--doc/classes/AudioStreamRandomizer.xml90
-rw-r--r--doc/classes/BoxOccluder3D.xml13
-rw-r--r--doc/classes/Button.xml2
-rw-r--r--doc/classes/Mesh.xml2
-rw-r--r--doc/classes/Occluder3D.xml18
-rw-r--r--doc/classes/OccluderInstance3D.xml2
-rw-r--r--doc/classes/PolygonOccluder3D.xml13
-rw-r--r--doc/classes/PopupMenu.xml7
-rw-r--r--doc/classes/QuadOccluder3D.xml13
-rw-r--r--doc/classes/RID.xml6
-rw-r--r--doc/classes/RenderingServer.xml2
-rw-r--r--doc/classes/SphereOccluder3D.xml13
-rw-r--r--doc/classes/String.xml16
-rw-r--r--doc/classes/StringName.xml24
-rw-r--r--doc/classes/TranslationServer.xml7
-rw-r--r--doc/classes/Tree.xml8
-rw-r--r--doc/classes/TreeItem.xml20
-rw-r--r--doc/classes/Window.xml2
-rw-r--r--doc/classes/int.xml7
-rw-r--r--drivers/vulkan/vulkan_context.cpp6
-rw-r--r--editor/animation_track_editor.cpp8
-rw-r--r--editor/code_editor.cpp36
-rw-r--r--editor/connections_dialog.cpp4
-rw-r--r--editor/create_dialog.cpp22
-rw-r--r--editor/create_dialog.h2
-rw-r--r--editor/debugger/editor_debugger_node.cpp24
-rw-r--r--editor/debugger/editor_network_profiler.cpp6
-rw-r--r--editor/debugger/editor_profiler.cpp2
-rw-r--r--editor/debugger/editor_visual_profiler.cpp2
-rw-r--r--editor/debugger/script_editor_debugger.cpp34
-rw-r--r--editor/editor_about.cpp19
-rw-r--r--editor/editor_audio_buses.cpp24
-rw-r--r--editor/editor_autoload_settings.cpp18
-rw-r--r--editor/editor_data.cpp15
-rw-r--r--editor/editor_data.h2
-rw-r--r--editor/editor_feature_profile.cpp2
-rw-r--r--editor/editor_fonts.cpp80
-rw-r--r--editor/editor_help.cpp18
-rw-r--r--editor/editor_help_search.cpp7
-rw-r--r--editor/editor_inspector.cpp38
-rw-r--r--editor/editor_log.cpp8
-rw-r--r--editor/editor_log.h2
-rw-r--r--editor/editor_node.cpp100
-rw-r--r--editor/editor_path.cpp6
-rw-r--r--editor/editor_properties.cpp20
-rw-r--r--editor/editor_properties_array_dict.cpp4
-rw-r--r--editor/editor_resource_picker.cpp18
-rw-r--r--editor/editor_sectioned_inspector.cpp2
-rw-r--r--editor/editor_settings_dialog.cpp4
-rw-r--r--editor/editor_spin_slider.cpp2
-rw-r--r--editor/editor_themes.cpp1046
-rw-r--r--editor/editor_toaster.cpp8
-rw-r--r--editor/editor_zoom_widget.cpp8
-rw-r--r--editor/export_template_manager.cpp10
-rw-r--r--editor/filesystem_dock.cpp89
-rw-r--r--editor/find_in_files.cpp12
-rw-r--r--editor/groups_editor.cpp14
-rw-r--r--editor/import/dynamicfont_import_settings.cpp16
-rw-r--r--editor/import/resource_importer_scene.cpp116
-rw-r--r--editor/import/resource_importer_scene.h10
-rw-r--r--editor/import_dock.cpp10
-rw-r--r--editor/inspector_dock.cpp2
-rw-r--r--editor/plugins/animation_blend_space_1d_editor.cpp6
-rw-r--r--editor/plugins/animation_blend_space_2d_editor.cpp6
-rw-r--r--editor/plugins/animation_blend_tree_editor_plugin.cpp12
-rw-r--r--editor/plugins/animation_player_editor_plugin.cpp8
-rw-r--r--editor/plugins/animation_state_machine_editor.cpp6
-rw-r--r--editor/plugins/asset_library_editor_plugin.cpp44
-rw-r--r--editor/plugins/audio_stream_editor_plugin.cpp10
-rw-r--r--editor/plugins/audio_stream_randomizer_editor_plugin.cpp119
-rw-r--r--editor/plugins/audio_stream_randomizer_editor_plugin.h57
-rw-r--r--editor/plugins/canvas_item_editor_plugin.cpp59
-rw-r--r--editor/plugins/debugger_editor_plugin.cpp2
-rw-r--r--editor/plugins/editor_preview_plugins.cpp6
-rw-r--r--editor/plugins/input_event_editor_plugin.cpp8
-rw-r--r--editor/plugins/node_3d_editor_gizmos.cpp213
-rw-r--r--editor/plugins/node_3d_editor_gizmos.h5
-rw-r--r--editor/plugins/node_3d_editor_plugin.cpp1038
-rw-r--r--editor/plugins/node_3d_editor_plugin.h14
-rw-r--r--editor/plugins/occluder_instance_3d_editor_plugin.cpp8
-rw-r--r--editor/plugins/packed_scene_translation_parser_plugin.cpp9
-rw-r--r--editor/plugins/packed_scene_translation_parser_plugin.h4
-rw-r--r--editor/plugins/polygon_2d_editor_plugin.cpp4
-rw-r--r--editor/plugins/polygon_3d_editor_plugin.cpp (renamed from editor/plugins/collision_polygon_3d_editor_plugin.cpp)114
-rw-r--r--editor/plugins/polygon_3d_editor_plugin.h (renamed from editor/plugins/collision_polygon_3d_editor_plugin.h)29
-rw-r--r--editor/plugins/replication_editor_plugin.cpp6
-rw-r--r--editor/plugins/resource_preloader_editor_plugin.cpp2
-rw-r--r--editor/plugins/script_editor_plugin.cpp14
-rw-r--r--editor/plugins/script_text_editor.cpp17
-rw-r--r--editor/plugins/shader_editor_plugin.cpp10
-rw-r--r--editor/plugins/skeleton_3d_editor_plugin.cpp2
-rw-r--r--editor/plugins/sprite_frames_editor_plugin.cpp8
-rw-r--r--editor/plugins/style_box_editor_plugin.cpp2
-rw-r--r--editor/plugins/text_control_editor_plugin.cpp156
-rw-r--r--editor/plugins/text_editor.cpp2
-rw-r--r--editor/plugins/texture_3d_editor_plugin.cpp10
-rw-r--r--editor/plugins/texture_editor_plugin.cpp14
-rw-r--r--editor/plugins/texture_layered_editor_plugin.cpp10
-rw-r--r--editor/plugins/texture_region_editor_plugin.cpp2
-rw-r--r--editor/plugins/theme_editor_plugin.cpp20
-rw-r--r--editor/plugins/theme_editor_preview.cpp24
-rw-r--r--editor/plugins/tiles/tile_atlas_view.cpp2
-rw-r--r--editor/plugins/tiles/tile_map_editor.cpp2
-rw-r--r--editor/plugins/tiles/tile_set_atlas_source_editor.cpp12
-rw-r--r--editor/plugins/visual_shader_editor_plugin.cpp46
-rw-r--r--editor/project_export.cpp10
-rw-r--r--editor/project_export.h2
-rw-r--r--editor/project_manager.cpp25
-rw-r--r--editor/project_settings_editor.cpp4
-rw-r--r--editor/property_editor.cpp6
-rw-r--r--editor/property_selector.cpp9
-rw-r--r--editor/quick_open.cpp2
-rw-r--r--editor/rename_dialog.cpp6
-rw-r--r--editor/scene_tree_dock.cpp18
-rw-r--r--editor/scene_tree_editor.cpp4
-rw-r--r--editor/script_create_dialog.cpp18
-rw-r--r--editor/shader_create_dialog.cpp10
-rw-r--r--main/main.cpp22
-rw-r--r--methods.py8
-rw-r--r--misc/dist/ios_xcode/godot_ios.xcodeproj/project.pbxproj4
-rw-r--r--modules/SCsub45
-rw-r--r--modules/gdnative/gdnative_library_editor_plugin.cpp1
-rw-r--r--modules/gdnative/nativescript/nativescript.cpp2
-rw-r--r--modules/gdnative/pluginscript/pluginscript_script.cpp2
-rw-r--r--modules/gdscript/gdscript_analyzer.cpp14
-rw-r--r--modules/gdscript/gdscript_editor.cpp16
-rw-r--r--modules/gdscript/gdscript_parser.cpp8
-rw-r--r--modules/gdscript/tests/gdscript_test_runner.cpp18
-rw-r--r--modules/gltf/gltf_document.cpp5
-rw-r--r--modules/gridmap/grid_map_editor_plugin.cpp2
-rw-r--r--modules/meshoptimizer/register_types.cpp6
-rw-r--r--modules/modules_builders.py7
-rw-r--r--modules/mono/editor/GodotTools/GodotTools/Export/AotBuilder.cs1
-rw-r--r--modules/mono/glue/GodotSharp/GodotSharp/Core/StringExtensions.cs47
-rw-r--r--modules/mono/glue/GodotSharp/GodotSharp/Core/Vector2.cs24
-rw-r--r--modules/mono/glue/GodotSharp/GodotSharp/Core/Vector3.cs25
-rw-r--r--modules/raycast/raycast_occlusion_cull.cpp5
-rw-r--r--modules/visual_script/editor/visual_script_editor.cpp21
-rw-r--r--modules/visual_script/editor/visual_script_property_selector.cpp10
-rw-r--r--modules/visual_script/visual_script.cpp3
-rw-r--r--modules/visual_script/visual_script_nodes.cpp10
-rw-r--r--platform/iphone/detect.py1
-rw-r--r--platform/iphone/export/export_plugin.cpp1
-rw-r--r--platform/iphone/godot_view.h5
-rw-r--r--platform/iphone/godot_view.mm8
-rw-r--r--platform/iphone/godot_view_gesture_recognizer.mm31
-rw-r--r--platform/linuxbsd/crash_handler_linuxbsd.cpp7
-rw-r--r--platform/linuxbsd/display_server_x11.cpp2
-rw-r--r--platform/linuxbsd/joypad_linux.cpp5
-rw-r--r--platform/osx/crash_handler_osx.mm7
-rw-r--r--platform/osx/detect.py6
-rw-r--r--platform/osx/display_server_osx.mm1
-rw-r--r--platform/osx/godot_window.mm4
-rw-r--r--platform/windows/crash_handler_windows.cpp7
-rw-r--r--platform/windows/display_server_windows.cpp7
-rw-r--r--scene/2d/navigation_region_2d.cpp8
-rw-r--r--scene/2d/navigation_region_2d.h4
-rw-r--r--scene/2d/ray_cast_2d.cpp7
-rw-r--r--scene/3d/occluder_instance_3d.cpp548
-rw-r--r--scene/3d/occluder_instance_3d.h128
-rw-r--r--scene/3d/ray_cast_3d.cpp7
-rw-r--r--scene/gui/box_container.cpp2
-rw-r--r--scene/gui/button.cpp2
-rw-r--r--scene/gui/color_picker.cpp24
-rw-r--r--scene/gui/dialogs.cpp2
-rw-r--r--scene/gui/file_dialog.cpp48
-rw-r--r--scene/gui/option_button.cpp44
-rw-r--r--scene/gui/popup.cpp4
-rw-r--r--scene/gui/popup_menu.cpp85
-rw-r--r--scene/gui/popup_menu.h3
-rw-r--r--scene/gui/tab_bar.cpp3
-rw-r--r--scene/gui/tree.cpp41
-rw-r--r--scene/gui/tree.h3
-rw-r--r--scene/register_scene_types.cpp7
-rw-r--r--scene/resources/default_theme/default_theme.cpp1180
-rw-r--r--scene/resources/resource_format_text.cpp10
-rw-r--r--scene/resources/surface_tool.cpp79
-rw-r--r--scene/resources/surface_tool.h12
-rw-r--r--scene/resources/tile_set.cpp2
-rw-r--r--servers/audio/audio_stream.cpp370
-rw-r--r--servers/audio/audio_stream.h77
-rw-r--r--servers/register_server_types.cpp2
-rw-r--r--servers/rendering_server.cpp2
-rw-r--r--servers/rendering_server.h2
-rw-r--r--tests/scene/test_gui.cpp2
206 files changed, 4836 insertions, 2843 deletions
diff --git a/.github/workflows/ios_builds.yml b/.github/workflows/ios_builds.yml
index 721d574dbe..cd9c7ec117 100644
--- a/.github/workflows/ios_builds.yml
+++ b/.github/workflows/ios_builds.yml
@@ -25,7 +25,7 @@ jobs:
- name: Setup python and scons
uses: ./.github/actions/godot-deps
- - name: Compilation (armv7)
+ - name: Compilation (arm64v8)
uses: ./.github/actions/godot-build
with:
sconsflags: ${{ env.SCONSFLAGS }}
diff --git a/SConstruct b/SConstruct
index b8063589c6..a27e5490a5 100644
--- a/SConstruct
+++ b/SConstruct
@@ -179,9 +179,11 @@ opts.Add(BoolVariable("use_volk", "Use the volk library to load the Vulkan loade
# Advanced options
opts.Add(BoolVariable("dev", "If yes, alias for verbose=yes warnings=extra werror=yes", False))
-opts.Add(BoolVariable("progress", "Show a progress indicator during compilation", True))
opts.Add(BoolVariable("tests", "Build the unit tests", False))
+opts.Add(BoolVariable("fast_unsafe", "Enable unsafe options for faster rebuilds", False))
+opts.Add(BoolVariable("compiledb", "Generate compilation DB (`compile_commands.json`) for external tools", False))
opts.Add(BoolVariable("verbose", "Enable verbose output for the compilation", False))
+opts.Add(BoolVariable("progress", "Show a progress indicator during compilation", True))
opts.Add(EnumVariable("warnings", "Level of compilation warnings", "all", ("extra", "all", "moderate", "no")))
opts.Add(BoolVariable("werror", "Treat compiler warnings as errors", False))
opts.Add("extra_suffix", "Custom extra suffix added to the base filename of all generated binary files", "")
@@ -360,6 +362,17 @@ if env_base["target"] == "debug":
# working on the engine itself.
env_base.Append(CPPDEFINES=["DEV_ENABLED"])
+# SCons speed optimization controlled by the `fast_unsafe` option, which provide
+# more than 10 s speed up for incremental rebuilds.
+# Unsafe as they reduce the certainty of rebuilding all changed files, so it's
+# enabled by default for `debug` builds, and can be overridden from command line.
+# Ref: https://github.com/SCons/scons/wiki/GoFastButton
+if methods.get_cmdline_bool("fast_unsafe", env_base["target"] == "debug"):
+ # Renamed to `content-timestamp` in SCons >= 4.2, keeping MD5 for compat.
+ env_base.Decider("MD5-timestamp")
+ env_base.SetOption("implicit_cache", 1)
+ env_base.SetOption("max_drift", 60)
+
if env_base["use_precise_math_checks"]:
env_base.Append(CPPDEFINES=["PRECISE_MATH_CHECKS"])
@@ -385,14 +398,15 @@ if selected_platform in platform_list:
else:
env = env_base.Clone()
- # Generating the compilation DB (`compile_commands.json`) requires SCons 4.0.0 or later.
- from SCons import __version__ as scons_raw_version
+ if env["compiledb"]:
+ # Generating the compilation DB (`compile_commands.json`) requires SCons 4.0.0 or later.
+ from SCons import __version__ as scons_raw_version
- scons_ver = env._get_major_minor_revision(scons_raw_version)
+ scons_ver = env._get_major_minor_revision(scons_raw_version)
- if scons_ver >= (4, 0, 0):
- env.Tool("compilation_db")
- env.Alias("compiledb", env.CompilationDatabase())
+ if scons_ver >= (4, 0, 0):
+ env.Tool("compilation_db")
+ env.Alias("compiledb", env.CompilationDatabase())
# 'dev' and 'production' are aliases to set default options if they haven't been set
# manually by the user.
@@ -817,6 +831,7 @@ elif selected_platform != "":
# The following only makes sense when the 'env' is defined, and assumes it is.
if "env" in locals():
+ # FIXME: This method mixes both cosmetic progress stuff and cache handling...
methods.show_progress(env)
# TODO: replace this with `env.Dump(format="json")`
# once we start requiring SCons 4.0 as min version.
diff --git a/core/SCsub b/core/SCsub
index c12dd4e60e..1379e9df9b 100644
--- a/core/SCsub
+++ b/core/SCsub
@@ -147,6 +147,7 @@ env.core_sources += thirdparty_obj
env.add_source_files(env.core_sources, "*.cpp")
env.add_source_files(env.core_sources, "script_encryption_key.gen.cpp")
+env.add_source_files(env.core_sources, "version_hash.gen.cpp")
# Certificates
env.Depends(
diff --git a/core/config/engine.cpp b/core/config/engine.cpp
index d9abf5e5e9..ff8a8d283f 100644
--- a/core/config/engine.cpp
+++ b/core/config/engine.cpp
@@ -35,7 +35,6 @@
#include "core/donors.gen.h"
#include "core/license.gen.h"
#include "core/version.h"
-#include "core/version_hash.gen.h"
void Engine::set_physics_ticks_per_second(int p_ips) {
ERR_FAIL_COND_MSG(p_ips <= 0, "Engine iterations per second must be greater than 0.");
@@ -95,8 +94,8 @@ Dictionary Engine::get_version_info() const {
dict["build"] = VERSION_BUILD;
dict["year"] = VERSION_YEAR;
- String hash = VERSION_HASH;
- dict["hash"] = hash.length() == 0 ? String("unknown") : hash;
+ String hash = String(VERSION_HASH);
+ dict["hash"] = hash.is_empty() ? String("unknown") : hash;
String stringver = String(dict["major"]) + "." + String(dict["minor"]);
if ((int)dict["patch"] != 0) {
diff --git a/core/core_constants.cpp b/core/core_constants.cpp
index 2f5fd05e6a..63e7323f7a 100644
--- a/core/core_constants.cpp
+++ b/core/core_constants.cpp
@@ -165,6 +165,9 @@ void register_global_constants() {
BIND_CORE_ENUM_CONSTANT(INLINE_ALIGNMENT_CENTER);
BIND_CORE_ENUM_CONSTANT(INLINE_ALIGNMENT_BOTTOM);
+ BIND_CORE_ENUM_CONSTANT(INLINE_ALIGNMENT_IMAGE_MASK);
+ BIND_CORE_ENUM_CONSTANT(INLINE_ALIGNMENT_TEXT_MASK);
+
BIND_CORE_ENUM_CLASS_CONSTANT(Key, KEY, SPECIAL);
BIND_CORE_ENUM_CLASS_CONSTANT(Key, KEY, ESCAPE);
BIND_CORE_ENUM_CLASS_CONSTANT(Key, KEY, TAB);
diff --git a/core/math/vector2.h b/core/math/vector2.h
index 123e3dc7b6..92ac5257b0 100644
--- a/core/math/vector2.h
+++ b/core/math/vector2.h
@@ -60,10 +60,10 @@ struct _NO_DISCARD_ Vector2 {
};
_FORCE_INLINE_ real_t &operator[](int p_idx) {
- return p_idx ? y : x;
+ return coord[p_idx];
}
_FORCE_INLINE_ const real_t &operator[](int p_idx) const {
- return p_idx ? y : x;
+ return coord[p_idx];
}
_FORCE_INLINE_ void set_all(const real_t p_value) {
diff --git a/core/math/vector2i.h b/core/math/vector2i.h
index 707c8c9490..3f5f12d4dd 100644
--- a/core/math/vector2i.h
+++ b/core/math/vector2i.h
@@ -43,19 +43,25 @@ struct _NO_DISCARD_ Vector2i {
};
union {
- int32_t x = 0;
- int32_t width;
- };
- union {
- int32_t y = 0;
- int32_t height;
+ struct {
+ union {
+ int32_t x;
+ int32_t width;
+ };
+ union {
+ int32_t y;
+ int32_t height;
+ };
+ };
+
+ int32_t coord[2] = { 0 };
};
_FORCE_INLINE_ int32_t &operator[](int p_idx) {
- return p_idx ? y : x;
+ return coord[p_idx];
}
_FORCE_INLINE_ const int32_t &operator[](int p_idx) const {
- return p_idx ? y : x;
+ return coord[p_idx];
}
_FORCE_INLINE_ Vector2i::Axis min_axis_index() const {
diff --git a/core/object/callable_method_pointer.h b/core/object/callable_method_pointer.h
index 53410a9acf..3cd9ad3819 100644
--- a/core/object/callable_method_pointer.h
+++ b/core/object/callable_method_pointer.h
@@ -51,6 +51,14 @@ protected:
void _setup(uint32_t *p_base_ptr, uint32_t p_ptr_size);
public:
+ virtual StringName get_method() const {
+#ifdef DEBUG_METHODS_ENABLED
+ return StringName(text);
+#else
+ return StringName();
+#endif
+ }
+
#ifdef DEBUG_METHODS_ENABLED
void set_text(const char *p_text) {
text = p_text;
diff --git a/core/object/class_db.cpp b/core/object/class_db.cpp
index 72a98ca20c..3df4db9c5e 100644
--- a/core/object/class_db.cpp
+++ b/core/object/class_db.cpp
@@ -1632,7 +1632,8 @@ Variant ClassDB::class_get_default_property_value(const StringName &p_class, con
// Some properties may have an instantiated Object as default value,
// (like Path2D's `curve` used to have), but that's not a good practice.
// Instead, those properties should use PROPERTY_USAGE_EDITOR_INSTANTIATE_OBJECT
- // to be auto-instantiated when created in the editor.
+ // to be auto-instantiated when created in the editor with the following method:
+ // EditorNode::get_editor_data().instantiate_object_properties(obj);
if (var.get_type() == Variant::OBJECT) {
Object *obj = var.get_validated_object();
if (obj) {
diff --git a/core/string/string_name.h b/core/string/string_name.h
index 9653d2b4cf..f767f3e1ec 100644
--- a/core/string/string_name.h
+++ b/core/string/string_name.h
@@ -181,6 +181,18 @@ bool operator!=(const char *p_name, const StringName &p_string_name);
StringName _scs_create(const char *p_chr, bool p_static = false);
+/*
+ * The SNAME macro is used to speed up StringName creation, as it allows caching it after the first usage in a very efficient way.
+ * It should NOT be used everywhere, but instead in places where high performance is required and the creation of a StringName
+ * can be costly. Places where it should be used are:
+ * - Control::get_theme_*(<name> and Window::get_theme_*(<name> functions.
+ * - emit_signal(<name>,..) function
+ * - call_deferred(<name>,..) function
+ * - Comparisons to a StringName in overriden _set and _get methods.
+ *
+ * Use in places that can be called hundreds of times per frame (or more) is recommended, but this situation is very rare. If in doubt, do not use.
+ */
+
#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 7cc41df9ef..eeac8b0acf 100644
--- a/core/string/translation.cpp
+++ b/core/string/translation.cpp
@@ -925,6 +925,7 @@ bool TranslationServer::is_placeholder(String &p_message, int p_index) const {
void TranslationServer::_bind_methods() {
ClassDB::bind_method(D_METHOD("set_locale", "locale"), &TranslationServer::set_locale);
ClassDB::bind_method(D_METHOD("get_locale"), &TranslationServer::get_locale);
+ ClassDB::bind_method(D_METHOD("get_tool_locale"), &TranslationServer::get_tool_locale);
ClassDB::bind_method(D_METHOD("compare_locales", "locale_a", "locale_b"), &TranslationServer::compare_locales);
ClassDB::bind_method(D_METHOD("standardize_locale", "locale"), &TranslationServer::standardize_locale);
diff --git a/core/variant/callable.cpp b/core/variant/callable.cpp
index c6a67f01d5..27792ce111 100644
--- a/core/variant/callable.cpp
+++ b/core/variant/callable.cpp
@@ -114,8 +114,9 @@ ObjectID Callable::get_object_id() const {
}
StringName Callable::get_method() const {
- ERR_FAIL_COND_V_MSG(is_custom(), StringName(),
- vformat("Can't get method on CallableCustom \"%s\".", operator String()));
+ if (is_custom()) {
+ return get_custom()->get_method();
+ }
return method;
}
@@ -310,6 +311,10 @@ Callable::~Callable() {
}
}
+StringName CallableCustom::get_method() const {
+ ERR_FAIL_V_MSG(StringName(), vformat("Can't get method on CallableCustom \"%s\".", get_as_text()));
+}
+
void CallableCustom::rpc(int p_peer_id, const Variant **p_arguments, int p_argcount, Callable::CallError &r_call_error) const {
r_call_error.error = Callable::CallError::CALL_ERROR_INVALID_METHOD;
r_call_error.argument = 0;
diff --git a/core/variant/callable.h b/core/variant/callable.h
index 855ffa9129..c61870f194 100644
--- a/core/variant/callable.h
+++ b/core/variant/callable.h
@@ -125,6 +125,7 @@ public:
virtual String get_as_text() const = 0;
virtual CompareEqualFunc get_compare_equal_func() const = 0;
virtual CompareLessFunc get_compare_less_func() const = 0;
+ virtual StringName get_method() const;
virtual ObjectID get_object() const = 0; //must always be able to provide an object
virtual void call(const Variant **p_arguments, int p_argcount, Variant &r_return_value, Callable::CallError &r_call_error) const = 0;
virtual void rpc(int p_peer_id, const Variant **p_arguments, int p_argcount, Callable::CallError &r_call_error) const;
diff --git a/core/variant/callable_bind.cpp b/core/variant/callable_bind.cpp
index 4579621760..797e8afede 100644
--- a/core/variant/callable_bind.cpp
+++ b/core/variant/callable_bind.cpp
@@ -70,12 +70,19 @@ bool CallableCustomBind::_less_func(const CallableCustom *p_a, const CallableCus
CallableCustom::CompareEqualFunc CallableCustomBind::get_compare_equal_func() const {
return _equal_func;
}
+
CallableCustom::CompareLessFunc CallableCustomBind::get_compare_less_func() const {
return _less_func;
}
+
+StringName CallableCustomBind::get_method() const {
+ return callable.get_method();
+}
+
ObjectID CallableCustomBind::get_object() const {
return callable.get_object_id();
}
+
const Callable *CallableCustomBind::get_base_comparator() const {
return &callable;
}
@@ -140,12 +147,19 @@ bool CallableCustomUnbind::_less_func(const CallableCustom *p_a, const CallableC
CallableCustom::CompareEqualFunc CallableCustomUnbind::get_compare_equal_func() const {
return _equal_func;
}
+
CallableCustom::CompareLessFunc CallableCustomUnbind::get_compare_less_func() const {
return _less_func;
}
+
+StringName CallableCustomUnbind::get_method() const {
+ return callable.get_method();
+}
+
ObjectID CallableCustomUnbind::get_object() const {
return callable.get_object_id();
}
+
const Callable *CallableCustomUnbind::get_base_comparator() const {
return &callable;
}
diff --git a/core/variant/callable_bind.h b/core/variant/callable_bind.h
index ac5797e05f..4f79a29629 100644
--- a/core/variant/callable_bind.h
+++ b/core/variant/callable_bind.h
@@ -47,6 +47,7 @@ public:
virtual String get_as_text() const;
virtual CompareEqualFunc get_compare_equal_func() const;
virtual CompareLessFunc get_compare_less_func() const;
+ virtual StringName get_method() const;
virtual ObjectID get_object() const; //must always be able to provide an object
virtual void call(const Variant **p_arguments, int p_argcount, Variant &r_return_value, Callable::CallError &r_call_error) const;
virtual const Callable *get_base_comparator() const;
@@ -71,6 +72,7 @@ public:
virtual String get_as_text() const;
virtual CompareEqualFunc get_compare_equal_func() const;
virtual CompareLessFunc get_compare_less_func() const;
+ virtual StringName get_method() const;
virtual ObjectID get_object() const; //must always be able to provide an object
virtual void call(const Variant **p_arguments, int p_argcount, Variant &r_return_value, Callable::CallError &r_call_error) const;
virtual const Callable *get_base_comparator() const;
diff --git a/core/variant/variant_call.cpp b/core/variant/variant_call.cpp
index 750f23902d..a5e89eec80 100644
--- a/core/variant/variant_call.cpp
+++ b/core/variant/variant_call.cpp
@@ -1371,6 +1371,8 @@ static void _register_variant_builtin_methods() {
bind_method(String, length, sarray(), varray());
bind_method(String, substr, sarray("from", "len"), varray(-1));
bind_method(String, get_slice, sarray("delimiter", "slice"), varray());
+ bind_method(String, get_slicec, sarray("delimiter", "slice"), varray());
+ bind_method(String, get_slice_count, sarray("delimiter"), varray());
bind_methodv(String, find, static_cast<int (String::*)(const String &, int) const>(&String::find), sarray("what", "from"), varray(0));
bind_method(String, count, sarray("what", "from", "to"), varray(0, 0));
bind_method(String, countn, sarray("what", "from", "to"), varray(0, 0));
@@ -1667,6 +1669,7 @@ static void _register_variant_builtin_methods() {
/* RID */
+ bind_method(RID, is_valid, sarray(), varray());
bind_method(RID, get_id, sarray(), varray());
/* NodePath */
diff --git a/core/variant/variant_op.cpp b/core/variant/variant_op.cpp
index f35774204b..cd1ae9f41f 100644
--- a/core/variant/variant_op.cpp
+++ b/core/variant/variant_op.cpp
@@ -176,6 +176,7 @@ void Variant::_register_variant_operators() {
register_op<OperatorEvaluatorAdd<double, double, int64_t>>(Variant::OP_ADD, Variant::FLOAT, Variant::INT);
register_op<OperatorEvaluatorAdd<double, double, double>>(Variant::OP_ADD, Variant::FLOAT, Variant::FLOAT);
register_op<OperatorEvaluatorAdd<String, String, String>>(Variant::OP_ADD, Variant::STRING, Variant::STRING);
+ register_op<OperatorEvaluatorAdd<String, char32_t, String>>(Variant::OP_ADD, Variant::INT, Variant::STRING);
register_op<OperatorEvaluatorAdd<Vector2, Vector2, Vector2>>(Variant::OP_ADD, Variant::VECTOR2, Variant::VECTOR2);
register_op<OperatorEvaluatorAdd<Vector2i, Vector2i, Vector2i>>(Variant::OP_ADD, Variant::VECTOR2I, Variant::VECTOR2I);
register_op<OperatorEvaluatorAdd<Vector3, Vector3, Vector3>>(Variant::OP_ADD, Variant::VECTOR3, Variant::VECTOR3);
@@ -622,6 +623,7 @@ void Variant::_register_variant_operators() {
register_op<OperatorEvaluatorLess<double, int64_t>>(Variant::OP_LESS, Variant::FLOAT, Variant::INT);
register_op<OperatorEvaluatorLess<double, double>>(Variant::OP_LESS, Variant::FLOAT, Variant::FLOAT);
register_op<OperatorEvaluatorLess<String, String>>(Variant::OP_LESS, Variant::STRING, Variant::STRING);
+ register_op<OperatorEvaluatorLess<StringName, StringName>>(Variant::OP_LESS, Variant::STRING_NAME, Variant::STRING_NAME);
register_op<OperatorEvaluatorLess<Vector2, Vector2>>(Variant::OP_LESS, Variant::VECTOR2, Variant::VECTOR2);
register_op<OperatorEvaluatorLess<Vector2i, Vector2i>>(Variant::OP_LESS, Variant::VECTOR2I, Variant::VECTOR2I);
register_op<OperatorEvaluatorLess<Vector3, Vector3>>(Variant::OP_LESS, Variant::VECTOR3, Variant::VECTOR3);
@@ -634,6 +636,7 @@ void Variant::_register_variant_operators() {
register_op<OperatorEvaluatorLessEqual<double, int64_t>>(Variant::OP_LESS_EQUAL, Variant::FLOAT, Variant::INT);
register_op<OperatorEvaluatorLessEqual<double, double>>(Variant::OP_LESS_EQUAL, Variant::FLOAT, Variant::FLOAT);
register_op<OperatorEvaluatorLessEqual<String, String>>(Variant::OP_LESS_EQUAL, Variant::STRING, Variant::STRING);
+ register_op<OperatorEvaluatorLessEqual<StringName, StringName>>(Variant::OP_LESS_EQUAL, Variant::STRING_NAME, Variant::STRING_NAME);
register_op<OperatorEvaluatorLessEqual<Vector2, Vector2>>(Variant::OP_LESS_EQUAL, Variant::VECTOR2, Variant::VECTOR2);
register_op<OperatorEvaluatorLessEqual<Vector2i, Vector2i>>(Variant::OP_LESS_EQUAL, Variant::VECTOR2I, Variant::VECTOR2I);
register_op<OperatorEvaluatorLessEqual<Vector3, Vector3>>(Variant::OP_LESS_EQUAL, Variant::VECTOR3, Variant::VECTOR3);
@@ -647,6 +650,7 @@ void Variant::_register_variant_operators() {
register_op<OperatorEvaluatorGreater<double, int64_t>>(Variant::OP_GREATER, Variant::FLOAT, Variant::INT);
register_op<OperatorEvaluatorGreater<double, double>>(Variant::OP_GREATER, Variant::FLOAT, Variant::FLOAT);
register_op<OperatorEvaluatorGreater<String, String>>(Variant::OP_GREATER, Variant::STRING, Variant::STRING);
+ register_op<OperatorEvaluatorGreater<StringName, StringName>>(Variant::OP_GREATER, Variant::STRING_NAME, Variant::STRING_NAME);
register_op<OperatorEvaluatorGreater<Vector2, Vector2>>(Variant::OP_GREATER, Variant::VECTOR2, Variant::VECTOR2);
register_op<OperatorEvaluatorGreater<Vector2i, Vector2i>>(Variant::OP_GREATER, Variant::VECTOR2I, Variant::VECTOR2I);
register_op<OperatorEvaluatorGreater<Vector3, Vector3>>(Variant::OP_GREATER, Variant::VECTOR3, Variant::VECTOR3);
@@ -659,6 +663,7 @@ void Variant::_register_variant_operators() {
register_op<OperatorEvaluatorGreaterEqual<double, int64_t>>(Variant::OP_GREATER_EQUAL, Variant::FLOAT, Variant::INT);
register_op<OperatorEvaluatorGreaterEqual<double, double>>(Variant::OP_GREATER_EQUAL, Variant::FLOAT, Variant::FLOAT);
register_op<OperatorEvaluatorGreaterEqual<String, String>>(Variant::OP_GREATER_EQUAL, Variant::STRING, Variant::STRING);
+ register_op<OperatorEvaluatorGreaterEqual<StringName, StringName>>(Variant::OP_GREATER_EQUAL, Variant::STRING_NAME, Variant::STRING_NAME);
register_op<OperatorEvaluatorGreaterEqual<Vector2, Vector2>>(Variant::OP_GREATER_EQUAL, Variant::VECTOR2, Variant::VECTOR2);
register_op<OperatorEvaluatorGreaterEqual<Vector2i, Vector2i>>(Variant::OP_GREATER_EQUAL, Variant::VECTOR2I, Variant::VECTOR2I);
register_op<OperatorEvaluatorGreaterEqual<Vector3, Vector3>>(Variant::OP_GREATER_EQUAL, Variant::VECTOR3, Variant::VECTOR3);
diff --git a/core/version.h b/core/version.h
index c718d0f4d7..e22922fa66 100644
--- a/core/version.h
+++ b/core/version.h
@@ -68,4 +68,7 @@
// Example: "Godot v3.1.4.stable.official.mono"
#define VERSION_FULL_NAME "" VERSION_NAME " v" VERSION_FULL_BUILD
+// Git commit hash, generated at build time in `core/version_hash.gen.cpp`.
+extern const char *const VERSION_HASH;
+
#endif // VERSION_H
diff --git a/doc/classes/@GlobalScope.xml b/doc/classes/@GlobalScope.xml
index d8c9ca08e8..4c0f89f14d 100644
--- a/doc/classes/@GlobalScope.xml
+++ b/doc/classes/@GlobalScope.xml
@@ -1267,6 +1267,12 @@
<constant name="INLINE_ALIGNMENT_BOTTOM" value="14" enum="InlineAlignment">
Aligns bottom of the inline object (e.g. image, table) to the bottom of the text. Equivalent to [code]INLINE_ALIGNMENT_BOTTOM_TO | INLINE_ALIGNMENT_TO_BOTTOM[/code].
</constant>
+ <constant name="INLINE_ALIGNMENT_IMAGE_MASK" value="3" enum="InlineAlignment">
+ A bit mask for [code]INLINE_ALIGNMENT_*_TO[/code] alignment constants.
+ </constant>
+ <constant name="INLINE_ALIGNMENT_TEXT_MASK" value="12" enum="InlineAlignment">
+ A bit mask for [code]INLINE_ALIGNMENT_TO_*[/code] alignment constants.
+ </constant>
<constant name="KEY_SPECIAL" value="16777216" enum="Key">
Keycodes with this bit applied are non-printable.
</constant>
diff --git a/doc/classes/ArrayOccluder3D.xml b/doc/classes/ArrayOccluder3D.xml
new file mode 100644
index 0000000000..993393cf50
--- /dev/null
+++ b/doc/classes/ArrayOccluder3D.xml
@@ -0,0 +1,24 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+<class name="ArrayOccluder3D" inherits="Occluder3D" version="4.0">
+ <brief_description>
+ </brief_description>
+ <description>
+ </description>
+ <tutorials>
+ </tutorials>
+ <methods>
+ <method name="set_arrays">
+ <return type="void" />
+ <argument index="0" name="vertices" type="PackedVector3Array" />
+ <argument index="1" name="indices" type="PackedInt32Array" />
+ <description>
+ </description>
+ </method>
+ </methods>
+ <members>
+ <member name="indices" type="PackedInt32Array" setter="set_indices" getter="get_indices" default="PackedInt32Array()">
+ </member>
+ <member name="vertices" type="PackedVector3Array" setter="set_vertices" getter="get_vertices" default="PackedVector3Array()">
+ </member>
+ </members>
+</class>
diff --git a/doc/classes/AudioStreamRandomPitch.xml b/doc/classes/AudioStreamRandomPitch.xml
deleted file mode 100644
index 0f580699e9..0000000000
--- a/doc/classes/AudioStreamRandomPitch.xml
+++ /dev/null
@@ -1,19 +0,0 @@
-<?xml version="1.0" encoding="UTF-8" ?>
-<class name="AudioStreamRandomPitch" inherits="AudioStream" version="4.0">
- <brief_description>
- Plays audio with random pitch shifting.
- </brief_description>
- <description>
- Randomly varies pitch on each start.
- </description>
- <tutorials>
- </tutorials>
- <members>
- <member name="audio_stream" type="AudioStream" setter="set_audio_stream" getter="get_audio_stream">
- The current [AudioStream].
- </member>
- <member name="random_pitch" type="float" setter="set_random_pitch" getter="get_random_pitch" default="1.1">
- The intensity of random pitch variation.
- </member>
- </members>
-</class>
diff --git a/doc/classes/AudioStreamRandomizer.xml b/doc/classes/AudioStreamRandomizer.xml
new file mode 100644
index 0000000000..90471a033e
--- /dev/null
+++ b/doc/classes/AudioStreamRandomizer.xml
@@ -0,0 +1,90 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+<class name="AudioStreamRandomizer" inherits="AudioStream" version="4.0">
+ <brief_description>
+ Wraps a pool of audio streams with pitch and volume shifting.
+ </brief_description>
+ <description>
+ Picks a random AudioStream from the pool, depending on the playback mode, and applies random pitch shifting and volume shifting during playback.
+ </description>
+ <tutorials>
+ </tutorials>
+ <methods>
+ <method name="add_stream">
+ <return type="void" />
+ <argument index="0" name="index" type="int" />
+ <description>
+ Insert a stream at the specified index.
+ </description>
+ </method>
+ <method name="get_stream" qualifiers="const">
+ <return type="AudioStream" />
+ <argument index="0" name="index" type="int" />
+ <description>
+ Returns the stream at the specified index.
+ </description>
+ </method>
+ <method name="get_stream_probability_weight" qualifiers="const">
+ <return type="float" />
+ <argument index="0" name="index" type="int" />
+ <description>
+ Returns the probability weight associated with the stream at the given index.
+ </description>
+ </method>
+ <method name="move_stream">
+ <return type="void" />
+ <argument index="0" name="index_from" type="int" />
+ <argument index="1" name="index_to" type="int" />
+ <description>
+ Move a stream from one index to another.
+ </description>
+ </method>
+ <method name="remove_stream">
+ <return type="void" />
+ <argument index="0" name="index" type="int" />
+ <description>
+ Remove the stream at the specified index.
+ </description>
+ </method>
+ <method name="set_stream">
+ <return type="void" />
+ <argument index="0" name="index" type="int" />
+ <argument index="1" name="stream" type="AudioStream" />
+ <description>
+ Set the AudioStream at the specified index.
+ </description>
+ </method>
+ <method name="set_stream_probability_weight">
+ <return type="void" />
+ <argument index="0" name="index" type="int" />
+ <argument index="1" name="weight" type="float" />
+ <description>
+ Set the probability weight of the stream at the specified index. The higher this value, the more likely that the randomizer will choose this stream during random playback modes.
+ </description>
+ </method>
+ </methods>
+ <members>
+ <member name="playback_mode" type="int" setter="set_playback_mode" getter="get_playback_mode" enum="AudioStreamRandomizer.PlaybackMode" default="0">
+ Controls how this AudioStreamRandomizer picks which AudioStream to play next.
+ </member>
+ <member name="random_pitch" type="float" setter="set_random_pitch" getter="get_random_pitch" default="1.1">
+ The intensity of random pitch variation. A value of 1 means no variation.
+ </member>
+ <member name="random_volume_offset_db" type="float" setter="set_random_volume_offset_db" getter="get_random_volume_offset_db" default="5.0">
+ The intensity of random volume variation. A value of 0 means no variation.
+ </member>
+ <member name="streams_count" type="int" setter="set_streams_count" getter="get_streams_count" default="0">
+ The number of streams in the stream pool.
+ </member>
+ </members>
+ <constants>
+ <constant name="PLAYBACK_RANDOM_NO_REPEATS" value="0" enum="PlaybackMode">
+ Pick a stream at random according to the probability weights chosen for each stream, but avoid playing the same stream twice in a row whenever possible.
+ </constant>
+ <constant name="PLAYBACK_RANDOM" value="1" enum="PlaybackMode">
+ Pick a stream at random according to the probability weights chosen for each stream.
+ </constant>
+ <constant name="PLAYBACK_SEQUENTIAL" value="2" enum="PlaybackMode">
+ Play streams in the order they appear in the stream pool.
+ </constant>
+ </constants>
+</class>
diff --git a/doc/classes/BoxOccluder3D.xml b/doc/classes/BoxOccluder3D.xml
new file mode 100644
index 0000000000..8c3b597193
--- /dev/null
+++ b/doc/classes/BoxOccluder3D.xml
@@ -0,0 +1,13 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+<class name="BoxOccluder3D" inherits="Occluder3D" version="4.0">
+ <brief_description>
+ </brief_description>
+ <description>
+ </description>
+ <tutorials>
+ </tutorials>
+ <members>
+ <member name="size" type="Vector3" setter="set_size" getter="get_size" default="Vector3(1, 1, 1)">
+ </member>
+ </members>
+</class>
diff --git a/doc/classes/Button.xml b/doc/classes/Button.xml
index ef4eba62b2..af42f72c66 100644
--- a/doc/classes/Button.xml
+++ b/doc/classes/Button.xml
@@ -115,7 +115,7 @@
<theme_item name="font_pressed_color" data_type="color" type="Color" default="Color(1, 1, 1, 1)">
Text [Color] used when the [Button] is being pressed.
</theme_item>
- <theme_item name="icon_disabled_color" data_type="color" type="Color" default="Color(1, 1, 1, 1)">
+ <theme_item name="icon_disabled_color" data_type="color" type="Color" default="Color(1, 1, 1, 0.4)">
Icon modulate [Color] used when the [Button] is disabled.
</theme_item>
<theme_item name="icon_focus_color" data_type="color" type="Color" default="Color(1, 1, 1, 1)">
diff --git a/doc/classes/Mesh.xml b/doc/classes/Mesh.xml
index c774528a39..8fbafcdb51 100644
--- a/doc/classes/Mesh.xml
+++ b/doc/classes/Mesh.xml
@@ -206,7 +206,7 @@
<constant name="ARRAY_FORMAT_INDEX" value="4096" enum="ArrayFormat">
Mesh array uses indices.
</constant>
- <constant name="ARRAY_FORMAT_BLEND_SHAPE_MASK" value="2147475463" enum="ArrayFormat">
+ <constant name="ARRAY_FORMAT_BLEND_SHAPE_MASK" value="7" enum="ArrayFormat">
</constant>
<constant name="ARRAY_FORMAT_CUSTOM_BASE" value="13" enum="ArrayFormat">
</constant>
diff --git a/doc/classes/Occluder3D.xml b/doc/classes/Occluder3D.xml
index 69fb3002e3..6c6c410bc3 100644
--- a/doc/classes/Occluder3D.xml
+++ b/doc/classes/Occluder3D.xml
@@ -6,10 +6,16 @@
</description>
<tutorials>
</tutorials>
- <members>
- <member name="indices" type="PackedInt32Array" setter="set_indices" getter="get_indices" default="PackedInt32Array()">
- </member>
- <member name="vertices" type="PackedVector3Array" setter="set_vertices" getter="get_vertices" default="PackedVector3Array()">
- </member>
- </members>
+ <methods>
+ <method name="get_indices" qualifiers="const">
+ <return type="PackedInt32Array" />
+ <description>
+ </description>
+ </method>
+ <method name="get_vertices" qualifiers="const">
+ <return type="PackedVector3Array" />
+ <description>
+ </description>
+ </method>
+ </methods>
</class>
diff --git a/doc/classes/OccluderInstance3D.xml b/doc/classes/OccluderInstance3D.xml
index d97aa4312f..32e48f9a70 100644
--- a/doc/classes/OccluderInstance3D.xml
+++ b/doc/classes/OccluderInstance3D.xml
@@ -26,6 +26,8 @@
<members>
<member name="bake_mask" type="int" setter="set_bake_mask" getter="get_bake_mask" default="4294967295">
</member>
+ <member name="bake_simplification_distance" type="float" setter="set_bake_simplification_distance" getter="get_bake_simplification_distance" default="0.1">
+ </member>
<member name="occluder" type="Occluder3D" setter="set_occluder" getter="get_occluder">
</member>
</members>
diff --git a/doc/classes/PolygonOccluder3D.xml b/doc/classes/PolygonOccluder3D.xml
new file mode 100644
index 0000000000..a4d910c983
--- /dev/null
+++ b/doc/classes/PolygonOccluder3D.xml
@@ -0,0 +1,13 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+<class name="PolygonOccluder3D" inherits="Occluder3D" version="4.0">
+ <brief_description>
+ </brief_description>
+ <description>
+ </description>
+ <tutorials>
+ </tutorials>
+ <members>
+ <member name="polygon" type="PackedVector2Array" setter="set_polygon" getter="get_polygon" default="PackedVector2Array()">
+ </member>
+ </members>
+</class>
diff --git a/doc/classes/PopupMenu.xml b/doc/classes/PopupMenu.xml
index eb1b0aada7..b316f822f0 100644
--- a/doc/classes/PopupMenu.xml
+++ b/doc/classes/PopupMenu.xml
@@ -331,6 +331,13 @@
[b]Note:[/b] The indices of items after the removed item will be shifted by one.
</description>
</method>
+ <method name="scroll_to_item">
+ <return type="void" />
+ <argument index="0" name="index" type="int" />
+ <description>
+ Moves the scroll view to make the item at the given [code]index[/code] visible.
+ </description>
+ </method>
<method name="set_current_index">
<return type="void" />
<argument index="0" name="index" type="int" />
diff --git a/doc/classes/QuadOccluder3D.xml b/doc/classes/QuadOccluder3D.xml
new file mode 100644
index 0000000000..c1b89149f5
--- /dev/null
+++ b/doc/classes/QuadOccluder3D.xml
@@ -0,0 +1,13 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+<class name="QuadOccluder3D" inherits="Occluder3D" version="4.0">
+ <brief_description>
+ </brief_description>
+ <description>
+ </description>
+ <tutorials>
+ </tutorials>
+ <members>
+ <member name="size" type="Vector2" setter="set_size" getter="get_size" default="Vector2(1, 1)">
+ </member>
+ </members>
+</class>
diff --git a/doc/classes/RID.xml b/doc/classes/RID.xml
index 695b0933fa..990e82593e 100644
--- a/doc/classes/RID.xml
+++ b/doc/classes/RID.xml
@@ -30,6 +30,12 @@
Returns the ID of the referenced resource.
</description>
</method>
+ <method name="is_valid" qualifiers="const">
+ <return type="bool" />
+ <description>
+ Returns [code]true[/code] if [RID] is valid.
+ </description>
+ </method>
</methods>
<operators>
<operator name="operator !=">
diff --git a/doc/classes/RenderingServer.xml b/doc/classes/RenderingServer.xml
index 446db40dd8..82728c0570 100644
--- a/doc/classes/RenderingServer.xml
+++ b/doc/classes/RenderingServer.xml
@@ -3626,7 +3626,7 @@
<constant name="ARRAY_FORMAT_INDEX" value="4096" enum="ArrayFormat">
Flag used to mark an index array.
</constant>
- <constant name="ARRAY_FORMAT_BLEND_SHAPE_MASK" value="2147475463" enum="ArrayFormat">
+ <constant name="ARRAY_FORMAT_BLEND_SHAPE_MASK" value="7" enum="ArrayFormat">
</constant>
<constant name="ARRAY_FORMAT_CUSTOM_BASE" value="13" enum="ArrayFormat">
</constant>
diff --git a/doc/classes/SphereOccluder3D.xml b/doc/classes/SphereOccluder3D.xml
new file mode 100644
index 0000000000..1ffa51e170
--- /dev/null
+++ b/doc/classes/SphereOccluder3D.xml
@@ -0,0 +1,13 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+<class name="SphereOccluder3D" inherits="Occluder3D" version="4.0">
+ <brief_description>
+ </brief_description>
+ <description>
+ </description>
+ <tutorials>
+ </tutorials>
+ <members>
+ <member name="radius" type="float" setter="set_radius" getter="get_radius" default="1.0">
+ </member>
+ </members>
+</class>
diff --git a/doc/classes/String.xml b/doc/classes/String.xml
index eeb17c24c0..a6182f5dab 100644
--- a/doc/classes/String.xml
+++ b/doc/classes/String.xml
@@ -222,6 +222,22 @@
[/codeblock]
</description>
</method>
+ <method name="get_slice_count" qualifiers="const">
+ <return type="int" />
+ <argument index="0" name="delimiter" type="String" />
+ <description>
+ Splits a string using a [code]delimiter[/code] and returns a number of slices.
+ </description>
+ </method>
+ <method name="get_slicec" qualifiers="const">
+ <return type="String" />
+ <argument index="0" name="delimiter" type="int" />
+ <argument index="1" name="slice" type="int" />
+ <description>
+ Splits a string using a Unicode character with code [code]delimiter[/code] and returns a substring at index [code]slice[/code]. Returns an empty string if the index doesn't exist.
+ This is a more performant alternative to [method split] for cases when you need only one element from the array at a fixed index.
+ </description>
+ </method>
<method name="hash" qualifiers="const">
<return type="int" />
<description>
diff --git a/doc/classes/StringName.xml b/doc/classes/StringName.xml
index b32665a09f..85c4d7593e 100644
--- a/doc/classes/StringName.xml
+++ b/doc/classes/StringName.xml
@@ -48,6 +48,18 @@
<description>
</description>
</operator>
+ <operator name="operator &lt;">
+ <return type="bool" />
+ <argument index="0" name="right" type="StringName" />
+ <description>
+ </description>
+ </operator>
+ <operator name="operator &lt;=">
+ <return type="bool" />
+ <argument index="0" name="right" type="StringName" />
+ <description>
+ </description>
+ </operator>
<operator name="operator ==">
<return type="bool" />
<description>
@@ -65,5 +77,17 @@
<description>
</description>
</operator>
+ <operator name="operator &gt;">
+ <return type="bool" />
+ <argument index="0" name="right" type="StringName" />
+ <description>
+ </description>
+ </operator>
+ <operator name="operator &gt;=">
+ <return type="bool" />
+ <argument index="0" name="right" type="StringName" />
+ <description>
+ </description>
+ </operator>
</operators>
</class>
diff --git a/doc/classes/TranslationServer.xml b/doc/classes/TranslationServer.xml
index c90cb2987c..6ece42da6b 100644
--- a/doc/classes/TranslationServer.xml
+++ b/doc/classes/TranslationServer.xml
@@ -91,6 +91,13 @@
Returns readable script name for the [code]script[/code] code.
</description>
</method>
+ <method name="get_tool_locale">
+ <return type="String" />
+ <description>
+ Returns the current locale of the editor.
+ [b]Note:[/b] When called from an exported project returns the same value as [method get_locale].
+ </description>
+ </method>
<method name="get_translation_object">
<return type="Translation" />
<argument index="0" name="locale" type="String" />
diff --git a/doc/classes/Tree.xml b/doc/classes/Tree.xml
index 766c740a2c..35a70ae53f 100644
--- a/doc/classes/Tree.xml
+++ b/doc/classes/Tree.xml
@@ -72,6 +72,13 @@
[b]Note:[/b] Despite the name of this method, the focus cursor itself is only visible in [constant SELECT_MULTI] mode.
</description>
</method>
+ <method name="get_button_id_at_position" qualifiers="const">
+ <return type="int" />
+ <argument index="0" name="position" type="Vector2" />
+ <description>
+ Returns the button id at [code]position[/code], or -1 if no button is there.
+ </description>
+ </method>
<method name="get_column_at_position" qualifiers="const">
<return type="int" />
<argument index="0" name="position" type="Vector2" />
@@ -240,6 +247,7 @@
<method name="scroll_to_item">
<return type="void" />
<argument index="0" name="item" type="TreeItem" />
+ <argument index="1" name="center_on_item" type="bool" default="false" />
<description>
Causes the [Tree] to jump to the specified [TreeItem].
</description>
diff --git a/doc/classes/TreeItem.xml b/doc/classes/TreeItem.xml
index 12c91cdd10..675c534e7b 100644
--- a/doc/classes/TreeItem.xml
+++ b/doc/classes/TreeItem.xml
@@ -14,11 +14,11 @@
<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="2" name="id" type="int" default="-1" />
<argument index="3" name="disabled" type="bool" default="false" />
<argument index="4" name="tooltip" type="String" default="&quot;&quot;" />
<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].
+ Adds a button with [Texture2D] [code]button[/code] at column [code]column[/code]. The [code]id[/code] is used to identify the button. If not specified, the next available index is used, which may be retrieved by calling [method get_button_count] immediately 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">
@@ -80,6 +80,14 @@
Returns the [Texture2D] of the button at index [code]button_idx[/code] in column [code]column[/code].
</description>
</method>
+ <method name="get_button_by_id" qualifiers="const">
+ <return type="int" />
+ <argument index="0" name="column" type="int" />
+ <argument index="1" name="id" type="int" />
+ <description>
+ Returns the button index if there is a button with id [code]id[/code] in column [code]column[/code], otherwise returns -1.
+ </description>
+ </method>
<method name="get_button_count" qualifiers="const">
<return type="int" />
<argument index="0" name="column" type="int" />
@@ -87,6 +95,14 @@
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_id" qualifiers="const">
+ <return type="int" />
+ <argument index="0" name="column" type="int" />
+ <argument index="1" name="button_idx" type="int" />
+ <description>
+ Returns the id for the button at index [code]button_idx[/code] in column [code]column[/code].
+ </description>
+ </method>
<method name="get_button_tooltip" qualifiers="const">
<return type="String" />
<argument index="0" name="column" type="int" />
diff --git a/doc/classes/Window.xml b/doc/classes/Window.xml
index ab8f51ced5..82bb74683f 100644
--- a/doc/classes/Window.xml
+++ b/doc/classes/Window.xml
@@ -435,7 +435,7 @@
<constant name="CONTENT_SCALE_ASPECT_EXPAND" value="4" enum="ContentScaleAspect">
</constant>
<constant name="LAYOUT_DIRECTION_INHERITED" value="0" enum="LayoutDirection">
- Automatic layout direction, determined from the parent control layout direction.
+ Automatic layout direction, determined from the parent window layout direction.
</constant>
<constant name="LAYOUT_DIRECTION_LOCALE" value="1" enum="LayoutDirection">
Automatic layout direction, determined from the current locale.
diff --git a/doc/classes/int.xml b/doc/classes/int.xml
index d212fe42bf..006dc7eb29 100644
--- a/doc/classes/int.xml
+++ b/doc/classes/int.xml
@@ -177,6 +177,13 @@
</description>
</operator>
<operator name="operator +">
+ <return type="String" />
+ <argument index="0" name="right" type="String" />
+ <description>
+ Adds Unicode character with code [int] to the [String].
+ </description>
+ </operator>
+ <operator name="operator +">
<return type="float" />
<argument index="0" name="right" type="float" />
<description>
diff --git a/drivers/vulkan/vulkan_context.cpp b/drivers/vulkan/vulkan_context.cpp
index 44455b927b..689d76ba26 100644
--- a/drivers/vulkan/vulkan_context.cpp
+++ b/drivers/vulkan/vulkan_context.cpp
@@ -273,9 +273,9 @@ Error VulkanContext::_obtain_vulkan_version() {
uint32_t api_version;
VkResult res = func(&api_version);
if (res == VK_SUCCESS) {
- vulkan_major = VK_VERSION_MAJOR(api_version);
- vulkan_minor = VK_VERSION_MINOR(api_version);
- vulkan_patch = VK_VERSION_PATCH(api_version);
+ vulkan_major = VK_API_VERSION_MAJOR(api_version);
+ vulkan_minor = VK_API_VERSION_MINOR(api_version);
+ vulkan_patch = VK_API_VERSION_PATCH(api_version);
} else {
// according to the documentation this shouldn't fail with anything except a memory allocation error
// in which case we're in deep trouble anyway
diff --git a/editor/animation_track_editor.cpp b/editor/animation_track_editor.cpp
index dab928794f..2f33619a52 100644
--- a/editor/animation_track_editor.cpp
+++ b/editor/animation_track_editor.cpp
@@ -4368,7 +4368,7 @@ void AnimationTrackEditor::_update_tracks() {
g->set_timeline(timeline);
groups.push_back(g);
VBoxContainer *vb = memnew(VBoxContainer);
- vb->add_theme_constant_override(SNAME("separation"), 0);
+ vb->add_theme_constant_override("separation", 0);
vb->add_child(g);
track_vbox->add_child(vb);
group_sort[base_path] = vb;
@@ -4519,7 +4519,7 @@ void AnimationTrackEditor::_notification(int p_what) {
view_group->set_icon(get_theme_icon(view_group->is_pressed() ? SNAME("AnimationTrackList") : SNAME("AnimationTrackGroup"), SNAME("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(SNAME("panel"), get_theme_stylebox(SNAME("bg"), SNAME("Tree")));
+ 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")));
}
@@ -6085,7 +6085,7 @@ AnimationTrackEditor::AnimationTrackEditor() {
timeline_scroll->add_child(timeline_vbox);
timeline_vbox->set_v_size_flags(SIZE_EXPAND_FILL);
timeline_vbox->set_h_size_flags(SIZE_EXPAND_FILL);
- timeline_vbox->add_theme_constant_override(SNAME("separation"), 0);
+ timeline_vbox->add_theme_constant_override("separation", 0);
info_message = memnew(Label);
info_message->set_text(TTR("Select an AnimationPlayer node to create and edit animations."));
@@ -6140,7 +6140,7 @@ AnimationTrackEditor::AnimationTrackEditor() {
scroll->add_child(track_vbox);
track_vbox->set_h_size_flags(SIZE_EXPAND_FILL);
scroll->set_horizontal_scroll_mode(ScrollContainer::SCROLL_MODE_DISABLED);
- track_vbox->add_theme_constant_override(SNAME("separation"), 0);
+ track_vbox->add_theme_constant_override("separation", 0);
HBoxContainer *bottom_hb = memnew(HBoxContainer);
add_child(bottom_hb);
diff --git a/editor/code_editor.cpp b/editor/code_editor.cpp
index daca1e9587..2627baaea8 100644
--- a/editor/code_editor.cpp
+++ b/editor/code_editor.cpp
@@ -105,7 +105,7 @@ void FindReplaceBar::_notification(int p_what) {
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(SNAME("font_color"), results_count > 0 ? get_theme_color(SNAME("font_color"), SNAME("Label")) : get_theme_color(SNAME("error_color"), SNAME("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();
@@ -301,7 +301,7 @@ void FindReplaceBar::_replace_all() {
}
text_editor->set_v_scroll(vsval);
- matches_label->add_theme_color_override(SNAME("font_color"), rc > 0 ? get_theme_color(SNAME("font_color"), SNAME("Label")) : get_theme_color(SNAME("error_color"), SNAME("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(SNAME("connect"), "text_changed", callable_mp(this, &FindReplaceBar::_editor_text_changed));
@@ -365,7 +365,7 @@ void FindReplaceBar::_update_matches_label() {
} else {
matches_label->show();
- matches_label->add_theme_color_override(SNAME("font_color"), results_count > 0 ? get_theme_color(SNAME("font_color"), SNAME("Label")) : get_theme_color(SNAME("error_color"), SNAME("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));
}
}
@@ -818,7 +818,7 @@ void CodeTextEditor::_zoom_changed() {
void CodeTextEditor::_reset_zoom() {
EditorSettings::get_singleton()->set("interface/editor/code_font_size", 14);
- text_editor->add_theme_font_size_override(SNAME("font_size"), 14 * EDSCALE);
+ text_editor->add_theme_font_size_override("font_size", 14 * EDSCALE);
}
void CodeTextEditor::_line_col_changed() {
@@ -936,7 +936,7 @@ bool CodeTextEditor::_add_font_size(int p_delta) {
if (new_size != old_size) {
EditorSettings::get_singleton()->set("interface/editor/code_font_size", new_size / EDSCALE);
- text_editor->add_theme_font_size_override(SNAME("font_size"), new_size);
+ text_editor->add_theme_font_size_override("font_size", new_size);
}
return true;
@@ -1567,14 +1567,14 @@ void CodeTextEditor::_update_text_editor_theme() {
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(SNAME("font"), status_bar_font);
- error->add_theme_font_size_override(SNAME("font_size"), status_bar_font_size);
+ 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();
for (int i = 0; i < count; i++) {
Control *n = Object::cast_to<Control>(status_bar->get_child(i));
if (n) {
- n->add_theme_font_override(SNAME("font"), status_bar_font);
- n->add_theme_font_size_override(SNAME("font_size"), status_bar_font_size);
+ n->add_theme_font_override("font", status_bar_font);
+ n->add_theme_font_size_override("font_size", status_bar_font_size);
}
}
error->end_bulk_theme_override();
@@ -1666,17 +1666,17 @@ void CodeTextEditor::_notification(int p_what) {
case NOTIFICATION_ENTER_TREE:
case NOTIFICATION_THEME_CHANGED: {
error_button->set_icon(get_theme_icon(SNAME("StatusError"), SNAME("EditorIcons")));
- error_button->add_theme_color_override(SNAME("font_color"), get_theme_color(SNAME("error_color"), SNAME("Editor")));
- error_button->add_theme_font_override(SNAME("font"), get_theme_font(SNAME("status_source"), SNAME("EditorFonts")));
- error_button->add_theme_font_size_override(SNAME("font_size"), get_theme_font_size(SNAME("status_source_size"), SNAME("EditorFonts")));
+ error_button->add_theme_color_override("font_color", get_theme_color(SNAME("error_color"), SNAME("Editor")));
+ error_button->add_theme_font_override("font", get_theme_font(SNAME("status_source"), SNAME("EditorFonts")));
+ error_button->add_theme_font_size_override("font_size", get_theme_font_size(SNAME("status_source_size"), SNAME("EditorFonts")));
warning_button->set_icon(get_theme_icon(SNAME("NodeWarning"), SNAME("EditorIcons")));
- warning_button->add_theme_color_override(SNAME("font_color"), get_theme_color(SNAME("warning_color"), SNAME("Editor")));
- warning_button->add_theme_font_override(SNAME("font"), get_theme_font(SNAME("status_source"), SNAME("EditorFonts")));
- warning_button->add_theme_font_size_override(SNAME("font_size"), get_theme_font_size(SNAME("status_source_size"), SNAME("EditorFonts")));
+ warning_button->add_theme_color_override("font_color", get_theme_color(SNAME("warning_color"), SNAME("Editor")));
+ warning_button->add_theme_font_override("font", get_theme_font(SNAME("status_source"), SNAME("EditorFonts")));
+ warning_button->add_theme_font_size_override("font_size", get_theme_font_size(SNAME("status_source_size"), SNAME("EditorFonts")));
- line_and_col_txt->add_theme_font_override(SNAME("font"), get_theme_font(SNAME("status_source"), SNAME("EditorFonts")));
- line_and_col_txt->add_theme_font_size_override(SNAME("font_size"), get_theme_font_size(SNAME("status_source_size"), SNAME("EditorFonts")));
+ line_and_col_txt->add_theme_font_override("font", get_theme_font(SNAME("status_source"), SNAME("EditorFonts")));
+ line_and_col_txt->add_theme_font_size_override("font_size", get_theme_font_size(SNAME("status_source_size"), SNAME("EditorFonts")));
if (p_what == NOTIFICATION_ENTER_TREE) {
break;
@@ -1935,5 +1935,5 @@ CodeTextEditor::CodeTextEditor() {
font_resize_timer->connect("timeout", callable_mp(this, &CodeTextEditor::_font_resize_timeout));
EditorSettings::get_singleton()->connect("settings_changed", callable_mp(this, &CodeTextEditor::_on_settings_change));
- add_theme_constant_override(SNAME("separation"), 4 * EDSCALE);
+ add_theme_constant_override("separation", 4 * EDSCALE);
}
diff --git a/editor/connections_dialog.cpp b/editor/connections_dialog.cpp
index 146eb59623..8efcd60210 100644
--- a/editor/connections_dialog.cpp
+++ b/editor/connections_dialog.cpp
@@ -381,7 +381,7 @@ void ConnectDialog::init(ConnectionData p_cd, bool p_edit) {
void ConnectDialog::popup_dialog(const String &p_for_signal) {
from_signal->set_text(p_for_signal);
- error_label->add_theme_color_override(SNAME("font_color"), error_label->get_theme_color(SNAME("error_color"), SNAME("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()));
}
@@ -1200,7 +1200,7 @@ ConnectionsDock::ConnectionsDock(EditorNode *p_editor) {
tree->connect("item_activated", callable_mp(this, &ConnectionsDock::_tree_item_activated));
tree->connect("item_rmb_selected", callable_mp(this, &ConnectionsDock::_rmb_pressed));
- add_theme_constant_override(SNAME("separation"), 3 * EDSCALE);
+ add_theme_constant_override("separation", 3 * EDSCALE);
EDITOR_DEF("interface/editors/default_signal_callback_name", "_on_{node_name}_{signal_name}");
}
diff --git a/editor/create_dialog.cpp b/editor/create_dialog.cpp
index 119e81c150..61ec8abacf 100644
--- a/editor/create_dialog.cpp
+++ b/editor/create_dialog.cpp
@@ -446,14 +446,14 @@ void CreateDialog::_notification(int p_what) {
}
}
-void CreateDialog::select_type(const String &p_type) {
+void CreateDialog::select_type(const String &p_type, bool p_center_on_item) {
if (!search_options_types.has(p_type)) {
return;
}
TreeItem *to_select = search_options_types[p_type];
to_select->select(0);
- search_options->scroll_to_item(to_select);
+ search_options->scroll_to_item(to_select, p_center_on_item);
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
@@ -503,24 +503,14 @@ Variant CreateDialog::instance_selected() {
} else {
obj = ClassDB::instantiate(selected->get_text(0));
}
-
- // Check if any Object-type property should be instantiated.
- List<PropertyInfo> pinfo;
- ((Object *)obj)->get_property_list(&pinfo);
-
- 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);
- }
- }
+ EditorNode::get_editor_data().instantiate_object_properties(obj);
return obj;
}
void CreateDialog::_item_selected() {
String name = get_selected_type();
- select_type(name);
+ select_type(name, false);
}
void CreateDialog::_hide_requested() {
@@ -743,7 +733,7 @@ CreateDialog::CreateDialog() {
favorites->set_allow_reselect(true);
favorites->connect("cell_selected", callable_mp(this, &CreateDialog::_favorite_selected));
favorites->connect("item_activated", callable_mp(this, &CreateDialog::_favorite_activated));
- favorites->add_theme_constant_override(SNAME("draw_guides"), 1);
+ favorites->add_theme_constant_override("draw_guides", 1);
#ifndef _MSC_VER
#warning cannot forward drag data to a non control, must be fixed
#endif
@@ -760,7 +750,7 @@ CreateDialog::CreateDialog() {
recent->set_allow_reselect(true);
recent->connect("item_selected", callable_mp(this, &CreateDialog::_history_selected));
recent->connect("item_activated", callable_mp(this, &CreateDialog::_history_activated));
- recent->add_theme_constant_override(SNAME("draw_guides"), 1);
+ recent->add_theme_constant_override("draw_guides", 1);
VBoxContainer *vbc = memnew(VBoxContainer);
vbc->set_custom_minimum_size(Size2(300, 0) * EDSCALE);
diff --git a/editor/create_dialog.h b/editor/create_dialog.h
index f905160df3..a82c4db191 100644
--- a/editor/create_dialog.h
+++ b/editor/create_dialog.h
@@ -79,7 +79,7 @@ class CreateDialog : public ConfirmationDialog {
void _sbox_input(const Ref<InputEvent> &p_ie);
void _text_changed(const String &p_newtext);
- void select_type(const String &p_type);
+ void select_type(const String &p_type, bool p_center_on_item = true);
void _item_selected();
void _hide_requested();
diff --git a/editor/debugger/editor_debugger_node.cpp b/editor/debugger/editor_debugger_node.cpp
index 6d9ad9398c..8702e773f8 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(SNAME("margin_left"), -EditorNode::get_singleton()->get_gui_base()->get_theme_stylebox(SNAME("BottomPanelDebuggerOverride"), SNAME("EditorStyles"))->get_margin(SIDE_LEFT));
- add_theme_constant_override(SNAME("margin_right"), -EditorNode::get_singleton()->get_gui_base()->get_theme_stylebox(SNAME("BottomPanelDebuggerOverride"), SNAME("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_alignment(TabContainer::ALIGNMENT_LEFT);
@@ -66,7 +66,7 @@ EditorDebuggerNode::EditorDebuggerNode() {
Ref<StyleBoxEmpty> empty;
empty.instantiate();
- tabs->add_theme_style_override(SNAME("panel"), empty);
+ tabs->add_theme_style_override("panel", empty);
auto_switch_remote_scene_tree = EDITOR_DEF("debugger/auto_switch_to_remote_scene_tree", false);
_add_debugger();
@@ -113,7 +113,7 @@ ScriptEditorDebugger *EditorDebuggerNode::_add_debugger() {
if (tabs->get_tab_count() > 1) {
node->clear_style();
tabs->set_tabs_visible(true);
- tabs->add_theme_style_override(SNAME("panel"), EditorNode::get_singleton()->get_gui_base()->get_theme_stylebox(SNAME("DebuggerPanel"), SNAME("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()) {
@@ -233,10 +233,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(SNAME("margin_left"), -EditorNode::get_singleton()->get_gui_base()->get_theme_stylebox(SNAME("BottomPanelDebuggerOverride"), SNAME("EditorStyles"))->get_margin(SIDE_LEFT));
- add_theme_constant_override(SNAME("margin_right"), -EditorNode::get_singleton()->get_gui_base()->get_theme_stylebox(SNAME("BottomPanelDebuggerOverride"), SNAME("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(SNAME("panel"), EditorNode::get_singleton()->get_gui_base()->get_theme_stylebox(SNAME("DebuggerPanel"), SNAME("EditorStyles")));
+ tabs->add_theme_style_override("panel", EditorNode::get_singleton()->get_gui_base()->get_theme_stylebox(SNAME("DebuggerPanel"), SNAME("EditorStyles")));
}
} break;
case NOTIFICATION_READY: {
@@ -271,20 +271,20 @@ void EditorDebuggerNode::_notification(int p_what) {
if (error_count == 0 && warning_count == 0) {
debugger_button->set_text(TTR("Debugger"));
- debugger_button->remove_theme_color_override(SNAME("font_color"));
+ debugger_button->remove_theme_color_override("font_color");
debugger_button->set_icon(Ref<Texture2D>());
} 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(SNAME("ErrorWarning"), SNAME("EditorIcons")));
// Use error color to represent the highest level of severity reported.
- debugger_button->add_theme_color_override(SNAME("font_color"), get_theme_color(SNAME("error_color"), SNAME("Editor")));
+ debugger_button->add_theme_color_override("font_color", get_theme_color(SNAME("error_color"), SNAME("Editor")));
} else if (error_count >= 1) {
debugger_button->set_icon(get_theme_icon(SNAME("Error"), SNAME("EditorIcons")));
- debugger_button->add_theme_color_override(SNAME("font_color"), get_theme_color(SNAME("error_color"), SNAME("Editor")));
+ debugger_button->add_theme_color_override("font_color", get_theme_color(SNAME("error_color"), SNAME("Editor")));
} else {
debugger_button->set_icon(get_theme_icon(SNAME("Warning"), SNAME("EditorIcons")));
- debugger_button->add_theme_color_override(SNAME("font_color"), get_theme_color(SNAME("warning_color"), SNAME("Editor")));
+ debugger_button->add_theme_color_override("font_color", get_theme_color(SNAME("warning_color"), SNAME("Editor")));
}
}
last_error_count = error_count;
@@ -683,7 +683,7 @@ EditorDebuggerNode::CameraOverride EditorDebuggerNode::get_camera_override() {
void EditorDebuggerNode::add_debugger_plugin(const Ref<Script> &p_script) {
ERR_FAIL_COND_MSG(debugger_plugins.has(p_script), "Debugger plugin already exists.");
ERR_FAIL_COND_MSG(p_script.is_null(), "Debugger plugin script is null");
- ERR_FAIL_COND_MSG(String(p_script->get_instance_base_type()) == "", "Debugger plugin script has error.");
+ ERR_FAIL_COND_MSG(p_script->get_instance_base_type() == StringName(), "Debugger plugin script has error.");
ERR_FAIL_COND_MSG(String(p_script->get_instance_base_type()) != "EditorDebuggerPlugin", "Base type of debugger plugin is not 'EditorDebuggerPlugin'.");
ERR_FAIL_COND_MSG(!p_script->is_tool(), "Debugger plugin script is not in tool mode.");
debugger_plugins.insert(p_script);
diff --git a/editor/debugger/editor_network_profiler.cpp b/editor/debugger/editor_network_profiler.cpp
index c04ec465e5..698e950f57 100644
--- a/editor/debugger/editor_network_profiler.cpp
+++ b/editor/debugger/editor_network_profiler.cpp
@@ -46,8 +46,8 @@ void EditorNetworkProfiler::_notification(int p_what) {
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(SNAME("font_uneditable_color"), get_theme_color(SNAME("font_color"), SNAME("Editor")) * Color(1, 1, 1, 0.5));
- outgoing_bandwidth_text->add_theme_color_override(SNAME("font_uneditable_color"), get_theme_color(SNAME("font_color"), SNAME("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));
}
}
@@ -126,7 +126,7 @@ bool EditorNetworkProfiler::is_profiling() {
EditorNetworkProfiler::EditorNetworkProfiler() {
HBoxContainer *hb = memnew(HBoxContainer);
- hb->add_theme_constant_override(SNAME("separation"), 8 * EDSCALE);
+ hb->add_theme_constant_override("separation", 8 * EDSCALE);
add_child(hb);
activate = memnew(Button);
diff --git a/editor/debugger/editor_profiler.cpp b/editor/debugger/editor_profiler.cpp
index 0a10bc95cc..da1d6a54f2 100644
--- a/editor/debugger/editor_profiler.cpp
+++ b/editor/debugger/editor_profiler.cpp
@@ -618,7 +618,7 @@ EditorProfiler::EditorProfiler() {
hb->add_child(cursor_metric_edit);
cursor_metric_edit->connect("value_changed", callable_mp(this, &EditorProfiler::_cursor_metric_changed));
- hb->add_theme_constant_override(SNAME("separation"), 8 * EDSCALE);
+ hb->add_theme_constant_override("separation", 8 * EDSCALE);
h_split = memnew(HSplitContainer);
add_child(h_split);
diff --git a/editor/debugger/editor_visual_profiler.cpp b/editor/debugger/editor_visual_profiler.cpp
index 5f61edcf8c..3cb5d3513d 100644
--- a/editor/debugger/editor_visual_profiler.cpp
+++ b/editor/debugger/editor_visual_profiler.cpp
@@ -758,7 +758,7 @@ EditorVisualProfiler::EditorVisualProfiler() {
hb->add_child(cursor_metric_edit);
cursor_metric_edit->connect("value_changed", callable_mp(this, &EditorVisualProfiler::_cursor_metric_changed));
- hb->add_theme_constant_override(SNAME("separation"), 8 * EDSCALE);
+ hb->add_theme_constant_override("separation", 8 * EDSCALE);
h_split = memnew(HSplitContainer);
add_child(h_split);
diff --git a/editor/debugger/script_editor_debugger.cpp b/editor/debugger/script_editor_debugger.cpp
index d0be846f76..6a2cb8ee4a 100644
--- a/editor/debugger/script_editor_debugger.cpp
+++ b/editor/debugger/script_editor_debugger.cpp
@@ -36,7 +36,6 @@
#include "core/io/marshalls.h"
#include "core/string/ustring.h"
#include "core/version.h"
-#include "core/version_hash.gen.h"
#include "editor/debugger/debug_adapter/debug_adapter_protocol.h"
#include "editor/debugger/editor_network_profiler.h"
#include "editor/debugger/editor_performance_profiler.h"
@@ -147,7 +146,7 @@ void ScriptEditorDebugger::update_tabs() {
}
void ScriptEditorDebugger::clear_style() {
- tabs->remove_theme_style_override(SNAME("panel"));
+ tabs->remove_theme_style_override("panel");
}
void ScriptEditorDebugger::save_node(ObjectID p_id, const String &p_file) {
@@ -762,13 +761,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(SNAME("font_color"), get_theme_color(SNAME("error_color"), SNAME("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(SNAME("font_color"), get_theme_color(SNAME("warning_color"), SNAME("Editor")));
+ reason->add_theme_color_override("font_color", get_theme_color(SNAME("warning_color"), SNAME("Editor")));
break;
default:
- reason->add_theme_color_override(SNAME("font_color"), get_theme_color(SNAME("success_color"), SNAME("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));
@@ -793,7 +792,7 @@ void ScriptEditorDebugger::_notification(int p_what) {
vmem_export->set_icon(get_theme_icon(SNAME("Save"), SNAME("EditorIcons")));
search->set_right_icon(get_theme_icon(SNAME("Search"), SNAME("EditorIcons")));
- reason->add_theme_color_override(SNAME("font_color"), get_theme_color(SNAME("error_color"), SNAME("Editor")));
+ reason->add_theme_color_override("font_color", get_theme_color(SNAME("error_color"), SNAME("Editor")));
} break;
case NOTIFICATION_PROCESS: {
@@ -855,8 +854,8 @@ void ScriptEditorDebugger::_notification(int p_what) {
};
} break;
case EditorSettings::NOTIFICATION_EDITOR_SETTINGS_CHANGED: {
- if (tabs->has_theme_stylebox_override(SNAME("panel"))) {
- tabs->add_theme_style_override(SNAME("panel"), editor->get_gui_base()->get_theme_stylebox(SNAME("DebuggerPanel"), SNAME("EditorStyles")));
+ if (tabs->has_theme_stylebox_override("panel")) {
+ tabs->add_theme_style_override("panel", editor->get_gui_base()->get_theme_stylebox(SNAME("DebuggerPanel"), SNAME("EditorStyles")));
}
copy->set_icon(get_theme_icon(SNAME("ActionCopy"), SNAME("EditorIcons")));
@@ -1543,19 +1542,10 @@ void ScriptEditorDebugger::_item_menu_id_pressed(int p_option) {
const int line_number = file_line_number[1].to_int();
// Construct a GitHub repository URL and open it in the user's default web browser.
- if (String(VERSION_HASH).length() >= 1) {
- // Git commit hash information available; use it for greater accuracy, including for development versions.
- OS::get_singleton()->shell_open(vformat("https://github.com/godotengine/godot/blob/%s/%s#L%d",
- VERSION_HASH,
- file,
- line_number));
- } else {
- // Git commit hash information unavailable; fall back to tagged releases.
- OS::get_singleton()->shell_open(vformat("https://github.com/godotengine/godot/blob/%s-stable/%s#L%d",
- VERSION_NUMBER,
- file,
- line_number));
- }
+ // If the commit hash is available, use it for greater accuracy. Otherwise fall back to tagged release.
+ String git_ref = String(VERSION_HASH).is_empty() ? String(VERSION_NUMBER) + "-stable" : String(VERSION_HASH);
+ OS::get_singleton()->shell_open(vformat("https://github.com/godotengine/godot/blob/%s/%s#L%d",
+ git_ref, file, line_number));
} break;
case ACTION_DELETE_BREAKPOINT: {
const TreeItem *selected = breakpoints_tree->get_selected();
@@ -1665,7 +1655,7 @@ ScriptEditorDebugger::ScriptEditorDebugger(EditorNode *p_editor) {
tabs = memnew(TabContainer);
tabs->set_tab_alignment(TabContainer::ALIGNMENT_LEFT);
- tabs->add_theme_style_override(SNAME("panel"), editor->get_gui_base()->get_theme_stylebox(SNAME("DebuggerPanel"), SNAME("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/editor_about.cpp b/editor/editor_about.cpp
index 267fe875ca..4309f55a2b 100644
--- a/editor/editor_about.cpp
+++ b/editor/editor_about.cpp
@@ -29,13 +29,12 @@
/*************************************************************************/
#include "editor_about.h"
-#include "editor_node.h"
#include "core/authors.gen.h"
#include "core/donors.gen.h"
#include "core/license.gen.h"
#include "core/version.h"
-#include "core/version_hash.gen.h"
+#include "editor_node.h"
// The metadata key used to store and retrieve the version text to copy to the clipboard.
static const String META_TEXT_TO_COPY = "text_to_copy";
@@ -43,12 +42,12 @@ static const String META_TEXT_TO_COPY = "text_to_copy";
void EditorAbout::_theme_changed() {
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(SNAME("normal_font"), font);
- _tpl_text->add_theme_font_size_override(SNAME("normal_font_size"), font_size);
- _tpl_text->add_theme_constant_override(SNAME("line_separation"), 6 * EDSCALE);
- _license_text->add_theme_font_override(SNAME("normal_font"), font);
- _license_text->add_theme_font_size_override(SNAME("normal_font_size"), font_size);
- _license_text->add_theme_constant_override(SNAME("line_separation"), 6 * EDSCALE);
+ _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(SNAME("Logo"), SNAME("EditorIcons")));
}
@@ -101,7 +100,7 @@ ScrollContainer *EditorAbout::_populate_list(const String &p_name, const List<St
il->set_same_column_width(true);
il->set_auto_height(true);
il->set_mouse_filter(Control::MOUSE_FILTER_IGNORE);
- il->add_theme_constant_override(SNAME("hseparation"), 16 * EDSCALE);
+ il->add_theme_constant_override("hseparation", 16 * EDSCALE);
while (*names_ptr) {
il->add_item(String::utf8(*names_ptr++), nullptr, false);
}
@@ -126,7 +125,7 @@ EditorAbout::EditorAbout() {
HBoxContainer *hbc = memnew(HBoxContainer);
hbc->set_h_size_flags(Control::SIZE_EXPAND_FILL);
hbc->set_alignment(BoxContainer::ALIGNMENT_CENTER);
- hbc->add_theme_constant_override(SNAME("separation"), 30 * EDSCALE);
+ hbc->add_theme_constant_override("separation", 30 * EDSCALE);
add_child(vbc);
vbc->add_child(hbc);
diff --git a/editor/editor_audio_buses.cpp b/editor/editor_audio_buses.cpp
index 9434a4e67b..5e4e375db4 100644
--- a/editor/editor_audio_buses.cpp
+++ b/editor/editor_audio_buses.cpp
@@ -79,17 +79,17 @@ void EditorAudioBus::_notification(int p_what) {
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(SNAME("AudioBusSolo"), SNAME("EditorIcons")));
- solo->add_theme_color_override(SNAME("icon_pressed_color"), solo_color);
+ solo->add_theme_color_override("icon_pressed_color", solo_color);
mute->set_icon(get_theme_icon(SNAME("AudioBusMute"), SNAME("EditorIcons")));
- mute->add_theme_color_override(SNAME("icon_pressed_color"), mute_color);
+ mute->add_theme_color_override("icon_pressed_color", mute_color);
bypass->set_icon(get_theme_icon(SNAME("AudioBusBypass"), SNAME("EditorIcons")));
- bypass->add_theme_color_override(SNAME("icon_pressed_color"), bypass_color);
+ bypass->add_theme_color_override("icon_pressed_color", bypass_color);
bus_options->set_icon(get_theme_icon(SNAME("GuiTabMenuHl"), SNAME("EditorIcons")));
- audio_value_preview_label->add_theme_color_override(SNAME("font_color"), get_theme_color(SNAME("font_color"), SNAME("TooltipLabel")));
- audio_value_preview_label->add_theme_color_override(SNAME("font_shadow_color"), get_theme_color(SNAME("font_shadow_color"), SNAME("TooltipLabel")));
- audio_value_preview_box->add_theme_style_override(SNAME("panel"), get_theme_stylebox(SNAME("panel"), SNAME("TooltipPanel")));
+ 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: {
@@ -574,7 +574,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(SNAME("panel"), get_theme_stylebox(SNAME("focus"), SNAME("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);
@@ -804,10 +804,10 @@ EditorAudioBus::EditorAudioBus(EditorAudioBuses *p_buses, bool p_is_master) {
Ref<StyleBoxEmpty> sbempty = memnew(StyleBoxEmpty);
for (int i = 0; i < hbc->get_child_count(); i++) {
Control *child = Object::cast_to<Control>(hbc->get_child(i));
- child->add_theme_style_override(SNAME("normal"), sbempty);
- child->add_theme_style_override(SNAME("hover"), sbempty);
- child->add_theme_style_override(SNAME("focus"), sbempty);
- child->add_theme_style_override(SNAME("pressed"), sbempty);
+ child->add_theme_style_override("normal", sbempty);
+ child->add_theme_style_override("hover", sbempty);
+ child->add_theme_style_override("focus", sbempty);
+ child->add_theme_style_override("pressed", sbempty);
}
HSeparator *separator = memnew(HSeparator);
@@ -1013,7 +1013,7 @@ void EditorAudioBuses::_notification(int p_what) {
switch (p_what) {
case NOTIFICATION_ENTER_TREE:
case NOTIFICATION_THEME_CHANGED: {
- bus_scroll->add_theme_style_override(SNAME("bg"), get_theme_stylebox(SNAME("bg"), SNAME("Tree")));
+ bus_scroll->add_theme_style_override("bg", get_theme_stylebox(SNAME("bg"), SNAME("Tree")));
} break;
case NOTIFICATION_READY: {
_update_buses();
diff --git a/editor/editor_autoload_settings.cpp b/editor/editor_autoload_settings.cpp
index d27d0c8b53..6d31141be7 100644
--- a/editor/editor_autoload_settings.cpp
+++ b/editor/editor_autoload_settings.cpp
@@ -362,21 +362,21 @@ Node *EditorAutoloadSettings::_create_autoload(const String &p_path) {
RES res = ResourceLoader::load(p_path);
ERR_FAIL_COND_V_MSG(res.is_null(), nullptr, "Can't autoload: " + p_path + ".");
Node *n = nullptr;
- if (res->is_class("PackedScene")) {
- Ref<PackedScene> ps = res;
- n = ps->instantiate();
- } else if (res->is_class("Script")) {
- Ref<Script> s = res;
- StringName ibt = s->get_instance_base_type();
+ Ref<PackedScene> scn = res;
+ Ref<Script> script = res;
+ if (scn.is_valid()) {
+ n = scn->instantiate();
+ } else if (script.is_valid()) {
+ StringName ibt = script->get_instance_base_type();
bool valid_type = ClassDB::is_parent_class(ibt, "Node");
ERR_FAIL_COND_V_MSG(!valid_type, nullptr, "Script does not inherit a Node: " + p_path + ".");
Object *obj = ClassDB::instantiate(ibt);
- ERR_FAIL_COND_V_MSG(obj == nullptr, nullptr, "Cannot instance script for AutoLoad, expected 'Node' inheritance, got: " + String(ibt) + ".");
+ ERR_FAIL_COND_V_MSG(!obj, nullptr, "Cannot instance script for AutoLoad, expected 'Node' inheritance, got: " + String(ibt) + ".");
n = Object::cast_to<Node>(obj);
- n->set_script(s);
+ n->set_script(script);
}
ERR_FAIL_COND_V_MSG(!n, nullptr, "Path in AutoLoad not a node or script: " + p_path + ".");
@@ -839,7 +839,7 @@ EditorAutoloadSettings::EditorAutoloadSettings() {
error_message = memnew(Label);
error_message->hide();
error_message->set_horizontal_alignment(HORIZONTAL_ALIGNMENT_RIGHT);
- error_message->add_theme_color_override(SNAME("font_color"), EditorNode::get_singleton()->get_gui_base()->get_theme_color(SNAME("error_color"), SNAME("Editor")));
+ error_message->add_theme_color_override("font_color", EditorNode::get_singleton()->get_gui_base()->get_theme_color(SNAME("error_color"), SNAME("Editor")));
add_child(error_message);
Label *l = memnew(Label);
diff --git a/editor/editor_data.cpp b/editor/editor_data.cpp
index ee53f4b343..625330ef37 100644
--- a/editor/editor_data.cpp
+++ b/editor/editor_data.cpp
@@ -520,6 +520,21 @@ void EditorData::remove_custom_type(const String &p_type) {
}
}
+void EditorData::instantiate_object_properties(Object *p_object) {
+ ERR_FAIL_NULL(p_object);
+ // Check if any Object-type property should be instantiated.
+ List<PropertyInfo> pinfo;
+ p_object->get_property_list(&pinfo);
+
+ for (List<PropertyInfo>::Element *E = pinfo.front(); E; E = E->next()) {
+ PropertyInfo pi = E->get();
+ if (pi.type == Variant::OBJECT && pi.usage & PROPERTY_USAGE_EDITOR_INSTANTIATE_OBJECT) {
+ Object *prop = ClassDB::instantiate(pi.class_name);
+ p_object->set(pi.name, prop);
+ }
+ }
+}
+
int EditorData::add_edited_scene(int p_at_pos) {
if (p_at_pos < 0) {
p_at_pos = edited_scene.size();
diff --git a/editor/editor_data.h b/editor/editor_data.h
index ccf641ff26..e485d47bf6 100644
--- a/editor/editor_data.h
+++ b/editor/editor_data.h
@@ -182,6 +182,8 @@ public:
void remove_custom_type(const String &p_type);
const Map<String, Vector<CustomType>> &get_custom_types() const { return custom_types; }
+ void instantiate_object_properties(Object *p_object);
+
int add_edited_scene(int p_at_pos);
void move_edited_scene_index(int p_idx, int p_to_idx);
void remove_scene(int p_idx);
diff --git a/editor/editor_feature_profile.cpp b/editor/editor_feature_profile.cpp
index 1ab532eb32..2fc29c46af 100644
--- a/editor/editor_feature_profile.cpp
+++ b/editor/editor_feature_profile.cpp
@@ -955,7 +955,7 @@ EditorFeatureProfileManager::EditorFeatureProfileManager() {
// Add some spacing above the help label.
Ref<StyleBoxEmpty> sb = memnew(StyleBoxEmpty);
sb->set_default_margin(SIDE_TOP, 20 * EDSCALE);
- no_profile_selected_help->add_theme_style_override(SNAME("normal"), sb);
+ no_profile_selected_help->add_theme_style_override("normal", sb);
no_profile_selected_help->set_horizontal_alignment(HORIZONTAL_ALIGNMENT_CENTER);
no_profile_selected_help->set_v_size_flags(Control::SIZE_EXPAND_FILL);
h_split->add_child(no_profile_selected_help);
diff --git a/editor/editor_fonts.cpp b/editor/editor_fonts.cpp
index db87801fbb..0c9a7b2972 100644
--- a/editor/editor_fonts.cpp
+++ b/editor/editor_fonts.cpp
@@ -279,67 +279,67 @@ void editor_register_fonts(Ref<Theme> p_theme) {
p_theme->set_default_font(df); // Default theme font
p_theme->set_default_font_size(default_font_size);
- p_theme->set_font_size(SNAME("main_size"), SNAME("EditorFonts"), default_font_size);
- p_theme->set_font(SNAME("main"), SNAME("EditorFonts"), df);
+ p_theme->set_font_size("main_size", "EditorFonts", default_font_size);
+ p_theme->set_font("main", "EditorFonts", df);
// Bold font
MAKE_BOLD_FONT(df_bold, String());
- p_theme->set_font_size(SNAME("bold_size"), SNAME("EditorFonts"), default_font_size);
- p_theme->set_font(SNAME("bold"), SNAME("EditorFonts"), df_bold);
+ p_theme->set_font_size("bold_size", "EditorFonts", default_font_size);
+ p_theme->set_font("bold", "EditorFonts", df_bold);
// Title font
- p_theme->set_font_size(SNAME("title_size"), SNAME("EditorFonts"), default_font_size + 1 * EDSCALE);
- p_theme->set_font(SNAME("title"), SNAME("EditorFonts"), df_bold);
+ p_theme->set_font_size("title_size", "EditorFonts", default_font_size + 1 * EDSCALE);
+ p_theme->set_font("title", "EditorFonts", df_bold);
- p_theme->set_font_size(SNAME("main_button_font_size"), SNAME("EditorFonts"), default_font_size + 1 * EDSCALE);
- p_theme->set_font(SNAME("main_button_font"), SNAME("EditorFonts"), df_bold);
+ p_theme->set_font_size("main_button_font_size", "EditorFonts", default_font_size + 1 * EDSCALE);
+ p_theme->set_font("main_button_font", "EditorFonts", df_bold);
- p_theme->set_font(SNAME("font"), SNAME("Label"), df);
+ p_theme->set_font("font", "Label", df);
- p_theme->set_type_variation(SNAME("HeaderSmall"), SNAME("Label"));
- p_theme->set_font(SNAME("font"), SNAME("HeaderSmall"), df_bold);
- p_theme->set_font_size(SNAME("font_size"), SNAME("HeaderSmall"), default_font_size);
+ p_theme->set_type_variation("HeaderSmall", "Label");
+ p_theme->set_font("font", "HeaderSmall", df_bold);
+ p_theme->set_font_size("font_size", "HeaderSmall", default_font_size);
- p_theme->set_type_variation(SNAME("HeaderMedium"), SNAME("Label"));
- p_theme->set_font(SNAME("font"), SNAME("HeaderMedium"), df_bold);
- p_theme->set_font_size(SNAME("font_size"), SNAME("HeaderMedium"), default_font_size + 1 * EDSCALE);
+ p_theme->set_type_variation("HeaderMedium", "Label");
+ p_theme->set_font("font", "HeaderMedium", df_bold);
+ p_theme->set_font_size("font_size", "HeaderMedium", default_font_size + 1 * EDSCALE);
- p_theme->set_type_variation(SNAME("HeaderLarge"), SNAME("Label"));
- p_theme->set_font(SNAME("font"), SNAME("HeaderLarge"), df_bold);
- p_theme->set_font_size(SNAME("font_size"), SNAME("HeaderLarge"), default_font_size + 3 * EDSCALE);
+ p_theme->set_type_variation("HeaderLarge", "Label");
+ p_theme->set_font("font", "HeaderLarge", df_bold);
+ p_theme->set_font_size("font_size", "HeaderLarge", default_font_size + 3 * EDSCALE);
// Documentation fonts
String code_font_custom_variations = EditorSettings::get_singleton()->get("interface/editor/code_font_custom_variations");
MAKE_SOURCE_FONT(df_code, code_font_custom_variations);
- p_theme->set_font_size(SNAME("doc_size"), SNAME("EditorFonts"), int(EDITOR_GET("text_editor/help/help_font_size")) * EDSCALE);
- p_theme->set_font(SNAME("doc"), SNAME("EditorFonts"), df);
- p_theme->set_font_size(SNAME("doc_bold_size"), SNAME("EditorFonts"), int(EDITOR_GET("text_editor/help/help_font_size")) * EDSCALE);
- p_theme->set_font(SNAME("doc_bold"), SNAME("EditorFonts"), df_bold);
- p_theme->set_font_size(SNAME("doc_title_size"), SNAME("EditorFonts"), int(EDITOR_GET("text_editor/help/help_title_font_size")) * EDSCALE);
- p_theme->set_font(SNAME("doc_title"), SNAME("EditorFonts"), df_bold);
- p_theme->set_font_size(SNAME("doc_source_size"), SNAME("EditorFonts"), int(EDITOR_GET("text_editor/help/help_source_font_size")) * EDSCALE);
- p_theme->set_font(SNAME("doc_source"), SNAME("EditorFonts"), df_code);
- p_theme->set_font_size(SNAME("doc_keyboard_size"), SNAME("EditorFonts"), (int(EDITOR_GET("text_editor/help/help_source_font_size")) - 1) * EDSCALE);
- p_theme->set_font(SNAME("doc_keyboard"), SNAME("EditorFonts"), df_code);
+ p_theme->set_font_size("doc_size", "EditorFonts", int(EDITOR_GET("text_editor/help/help_font_size")) * EDSCALE);
+ p_theme->set_font("doc", "EditorFonts", df);
+ p_theme->set_font_size("doc_bold_size", "EditorFonts", int(EDITOR_GET("text_editor/help/help_font_size")) * EDSCALE);
+ p_theme->set_font("doc_bold", "EditorFonts", df_bold);
+ p_theme->set_font_size("doc_title_size", "EditorFonts", int(EDITOR_GET("text_editor/help/help_title_font_size")) * EDSCALE);
+ p_theme->set_font("doc_title", "EditorFonts", df_bold);
+ p_theme->set_font_size("doc_source_size", "EditorFonts", int(EDITOR_GET("text_editor/help/help_source_font_size")) * EDSCALE);
+ p_theme->set_font("doc_source", "EditorFonts", df_code);
+ p_theme->set_font_size("doc_keyboard_size", "EditorFonts", (int(EDITOR_GET("text_editor/help/help_source_font_size")) - 1) * EDSCALE);
+ p_theme->set_font("doc_keyboard", "EditorFonts", df_code);
// Ruler font
- p_theme->set_font_size(SNAME("rulers_size"), SNAME("EditorFonts"), 8 * EDSCALE);
- p_theme->set_font(SNAME("rulers"), SNAME("EditorFonts"), df);
+ p_theme->set_font_size("rulers_size", "EditorFonts", 8 * EDSCALE);
+ p_theme->set_font("rulers", "EditorFonts", df);
// Rotation widget font
- p_theme->set_font_size(SNAME("rotation_control_size"), SNAME("EditorFonts"), 14 * EDSCALE);
- p_theme->set_font(SNAME("rotation_control"), SNAME("EditorFonts"), df);
+ p_theme->set_font_size("rotation_control_size", "EditorFonts", 14 * EDSCALE);
+ p_theme->set_font("rotation_control", "EditorFonts", df);
// Code font
- p_theme->set_font_size(SNAME("source_size"), SNAME("EditorFonts"), int(EDITOR_GET("interface/editor/code_font_size")) * EDSCALE);
- p_theme->set_font(SNAME("source"), SNAME("EditorFonts"), df_code);
+ p_theme->set_font_size("source_size", "EditorFonts", int(EDITOR_GET("interface/editor/code_font_size")) * EDSCALE);
+ p_theme->set_font("source", "EditorFonts", df_code);
- p_theme->set_font_size(SNAME("expression_size"), SNAME("EditorFonts"), (int(EDITOR_GET("interface/editor/code_font_size")) - 1) * EDSCALE);
- p_theme->set_font(SNAME("expression"), SNAME("EditorFonts"), df_code);
+ p_theme->set_font_size("expression_size", "EditorFonts", (int(EDITOR_GET("interface/editor/code_font_size")) - 1) * EDSCALE);
+ p_theme->set_font("expression", "EditorFonts", df_code);
- p_theme->set_font_size(SNAME("output_source_size"), SNAME("EditorFonts"), int(EDITOR_GET("run/output/font_size")) * EDSCALE);
- p_theme->set_font(SNAME("output_source"), SNAME("EditorFonts"), df_code);
+ p_theme->set_font_size("output_source_size", "EditorFonts", int(EDITOR_GET("run/output/font_size")) * EDSCALE);
+ p_theme->set_font("output_source", "EditorFonts", df_code);
- p_theme->set_font_size(SNAME("status_source_size"), SNAME("EditorFonts"), default_font_size);
- p_theme->set_font(SNAME("status_source"), SNAME("EditorFonts"), df_code);
+ p_theme->set_font_size("status_source_size", "EditorFonts", default_font_size);
+ p_theme->set_font("status_source", "EditorFonts", df_code);
}
diff --git a/editor/editor_help.cpp b/editor/editor_help.cpp
index dd5eeac4e5..e80e9c43b0 100644
--- a/editor/editor_help.cpp
+++ b/editor/editor_help.cpp
@@ -54,10 +54,10 @@ void EditorHelp::_update_theme() {
qualifier_color = get_theme_color(SNAME("qualifier_color"), SNAME("EditorHelp"));
type_color = get_theme_color(SNAME("type_color"), SNAME("EditorHelp"));
- class_desc->add_theme_color_override(SNAME("selection_color"), get_theme_color(SNAME("selection_color"), SNAME("EditorHelp")));
- class_desc->add_theme_constant_override(SNAME("line_separation"), get_theme_constant(SNAME("line_separation"), SNAME("EditorHelp")));
- class_desc->add_theme_constant_override(SNAME("table_hseparation"), get_theme_constant(SNAME("table_hseparation"), SNAME("EditorHelp")));
- class_desc->add_theme_constant_override(SNAME("table_vseparation"), get_theme_constant(SNAME("table_vseparation"), SNAME("EditorHelp")));
+ class_desc->add_theme_color_override("selection_color", get_theme_color(SNAME("selection_color"), SNAME("EditorHelp")));
+ class_desc->add_theme_constant_override("line_separation", get_theme_constant(SNAME("line_separation"), SNAME("EditorHelp")));
+ class_desc->add_theme_constant_override("table_hseparation", get_theme_constant(SNAME("table_hseparation"), SNAME("EditorHelp")));
+ class_desc->add_theme_constant_override("table_vseparation", get_theme_constant(SNAME("table_vseparation"), SNAME("EditorHelp")));
doc_font = get_theme_font(SNAME("doc"), SNAME("EditorFonts"));
doc_bold_font = get_theme_font(SNAME("doc_bold"), SNAME("EditorFonts"));
@@ -176,7 +176,7 @@ void EditorHelp::_class_desc_resized(bool p_force_update_theme) {
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(SNAME("normal"), class_desc_stylebox);
+ class_desc->add_theme_style_override("normal", class_desc_stylebox);
}
}
@@ -1872,7 +1872,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(SNAME("selection_color"), get_theme_color(SNAME("accent_color"), SNAME("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));
@@ -1951,7 +1951,7 @@ void EditorHelpBit::_notification(int p_what) {
switch (p_what) {
case NOTIFICATION_ENTER_TREE:
case NOTIFICATION_THEME_CHANGED: {
- rich_text->add_theme_color_override(SNAME("selection_color"), get_theme_color(SNAME("selection_color"), SNAME("EditorHelp")));
+ rich_text->add_theme_color_override("selection_color", get_theme_color(SNAME("selection_color"), SNAME("EditorHelp")));
rich_text->clear();
_add_text_to_rt(text, rich_text);
rich_text->reset_size(); // Force recalculating size after parsing bbcode.
@@ -2039,7 +2039,7 @@ void FindBar::_notification(int p_what) {
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(SNAME("font_color"), results_count > 0 ? get_theme_color(SNAME("font_color"), SNAME("Label")) : get_theme_color(SNAME("error_color"), SNAME("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());
@@ -2110,7 +2110,7 @@ void FindBar::_update_matches_label() {
} else {
matches_label->show();
- matches_label->add_theme_color_override(SNAME("font_color"), results_count > 0 ? get_theme_color(SNAME("font_color"), SNAME("Label")) : get_theme_color(SNAME("error_color"), SNAME("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 550e6ee72b..29bf22a478 100644
--- a/editor/editor_help_search.cpp
+++ b/editor/editor_help_search.cpp
@@ -38,7 +38,7 @@
void EditorHelpSearch::_update_icons() {
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(SNAME("right_icon"), results_tree->get_theme_icon(SNAME("Search"), SNAME("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")));
@@ -610,11 +610,6 @@ TreeItem *EditorHelpSearch::Runner::_create_member_item(TreeItem *p_parent, cons
text = p_text;
} else {
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");
-else if (ClassDB::is_parent_class(p_class_name, "Object"))
-icon = ui_service->get_icon("Object", "EditorIcons");*/
text = p_class_name + "." + p_text;
}
diff --git a/editor/editor_inspector.cpp b/editor/editor_inspector.cpp
index d898c84a02..cbfd6ae6de 100644
--- a/editor/editor_inspector.cpp
+++ b/editor/editor_inspector.cpp
@@ -1890,10 +1890,10 @@ void EditorInspectorArray::_setup() {
ae.margin->set_mouse_filter(MOUSE_FILTER_PASS);
if (is_inside_tree()) {
Size2 min_size = get_theme_stylebox(SNAME("Focus"), SNAME("EditorStyles"))->get_minimum_size();
- ae.margin->add_theme_constant_override(SNAME("margin_left"), min_size.x / 2);
- ae.margin->add_theme_constant_override(SNAME("margin_top"), min_size.y / 2);
- ae.margin->add_theme_constant_override(SNAME("margin_right"), min_size.x / 2);
- ae.margin->add_theme_constant_override(SNAME("margin_bottom"), min_size.y / 2);
+ ae.margin->add_theme_constant_override("margin_left", min_size.x / 2);
+ ae.margin->add_theme_constant_override("margin_top", min_size.y / 2);
+ ae.margin->add_theme_constant_override("margin_right", min_size.x / 2);
+ ae.margin->add_theme_constant_override("margin_bottom", min_size.y / 2);
}
ae.panel->add_child(ae.margin);
@@ -1989,10 +1989,10 @@ void EditorInspectorArray::_notification(int p_what) {
ae.move_texture_rect->set_texture(get_theme_icon(SNAME("TripleBar"), SNAME("EditorIcons")));
Size2 min_size = get_theme_stylebox(SNAME("Focus"), SNAME("EditorStyles"))->get_minimum_size();
- ae.margin->add_theme_constant_override(SNAME("margin_left"), min_size.x / 2);
- ae.margin->add_theme_constant_override(SNAME("margin_top"), min_size.y / 2);
- ae.margin->add_theme_constant_override(SNAME("margin_right"), min_size.x / 2);
- ae.margin->add_theme_constant_override(SNAME("margin_bottom"), min_size.y / 2);
+ ae.margin->add_theme_constant_override("margin_left", min_size.x / 2);
+ ae.margin->add_theme_constant_override("margin_top", min_size.y / 2);
+ ae.margin->add_theme_constant_override("margin_right", min_size.x / 2);
+ ae.margin->add_theme_constant_override("margin_bottom", min_size.y / 2);
}
add_button->set_icon(get_theme_icon(SNAME("Add"), SNAME("EditorIcons")));
@@ -2083,7 +2083,7 @@ EditorInspectorArray::EditorInspectorArray() {
add_child(rmb_popup);
elements_vbox = memnew(VBoxContainer);
- elements_vbox->add_theme_constant_override(SNAME("separation"), 0);
+ elements_vbox->add_theme_constant_override("separation", 0);
vbox->add_child(elements_vbox);
add_button = memnew(Button);
@@ -2109,7 +2109,7 @@ EditorInspectorArray::EditorInspectorArray() {
page_line_edit = memnew(LineEdit);
page_line_edit->connect("text_submitted", callable_mp(this, &EditorInspectorArray::_page_line_edit_text_submitted));
- page_line_edit->add_theme_constant_override(SNAME("minimum_character_width"), 2);
+ page_line_edit->add_theme_constant_override("minimum_character_width", 2);
hbox_pagination->add_child(page_line_edit);
page_count_label = memnew(Label);
@@ -2425,7 +2425,7 @@ void EditorInspector::update_tree() {
if (!ClassDB::class_exists(type) && !ScriptServer::is_global_class(type) && p.hint_string.length() && FileAccess::exists(p.hint_string)) {
// If we have a category inside a script, search for the first script with a valid icon.
Ref<Script> script = ResourceLoader::load(p.hint_string, "Script");
- String base_type;
+ StringName base_type;
if (script.is_valid()) {
base_type = script->get_instance_base_type();
}
@@ -3020,9 +3020,9 @@ void EditorInspector::_update_inspector_bg() {
n = n->get_parent();
}
count_subinspectors = MIN(15, count_subinspectors);
- add_theme_style_override(SNAME("bg"), get_theme_stylebox("sub_inspector_bg" + itos(count_subinspectors), SNAME("Editor")));
+ add_theme_style_override("bg", get_theme_stylebox("sub_inspector_bg" + itos(count_subinspectors), SNAME("Editor")));
} else {
- add_theme_style_override(SNAME("bg"), get_theme_stylebox(SNAME("bg"), SNAME("Tree")));
+ add_theme_style_override("bg", get_theme_stylebox(SNAME("bg"), SNAME("Tree")));
}
}
void EditorInspector::set_sub_inspector(bool p_enable) {
@@ -3479,10 +3479,14 @@ void EditorInspector::_update_script_class_properties(const Object &p_object, Li
String path = s->get_path();
String name = EditorNode::get_editor_data().script_class_get_name(path);
if (name.is_empty()) {
- if (!s->is_built_in()) {
- name = path.get_file();
+ if (s->is_built_in()) {
+ if (s->get_name().is_empty()) {
+ name = TTR("Built-in script");
+ } else {
+ name = vformat("%s (%s)", s->get_name(), TTR("Built-in"));
+ }
} else {
- name = TTR("Built-in script");
+ name = path.get_file();
}
}
@@ -3551,7 +3555,7 @@ EditorInspector::EditorInspector() {
undo_redo = nullptr;
main_vbox = memnew(VBoxContainer);
main_vbox->set_h_size_flags(SIZE_EXPAND_FILL);
- main_vbox->add_theme_constant_override(SNAME("separation"), 0);
+ main_vbox->add_theme_constant_override("separation", 0);
add_child(main_vbox);
set_horizontal_scroll_mode(SCROLL_MODE_DISABLED);
diff --git a/editor/editor_log.cpp b/editor/editor_log.cpp
index e6aa38e7c4..db4de3bed0 100644
--- a/editor/editor_log.cpp
+++ b/editor/editor_log.cpp
@@ -64,15 +64,15 @@ 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(SNAME("normal_font"), normal_font);
+ log->add_theme_font_override("normal_font", normal_font);
}
- log->add_theme_font_size_override(SNAME("normal_font_size"), get_theme_font_size(SNAME("output_source_size"), SNAME("EditorFonts")));
- log->add_theme_color_override(SNAME("selection_color"), get_theme_color(SNAME("accent_color"), SNAME("Editor")) * Color(1, 1, 1, 0.4));
+ 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(SNAME("bold_font"), bold_font);
+ 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")));
diff --git a/editor/editor_log.h b/editor/editor_log.h
index abfc78fdcd..69a6a0b449 100644
--- a/editor/editor_log.h
+++ b/editor/editor_log.h
@@ -85,7 +85,7 @@ private:
toggle_button->set_text(itos(message_count));
toggle_button->set_tooltip(TTR(p_tooltip));
// Don't tint the icon even when in "pressed" state.
- toggle_button->add_theme_color_override(SNAME("icon_color_pressed"), Color(1, 1, 1, 1));
+ toggle_button->add_theme_color_override("icon_color_pressed", Color(1, 1, 1, 1));
toggle_button->set_focus_mode(FOCUS_NONE);
// When toggled call the callback and pass the MessageType this button is for.
toggle_button->connect("toggled", p_toggled_callback, varray(type));
diff --git a/editor/editor_node.cpp b/editor/editor_node.cpp
index a4b6790d1c..4b2f1c5104 100644
--- a/editor/editor_node.cpp
+++ b/editor/editor_node.cpp
@@ -47,7 +47,6 @@
#include "core/string/print_string.h"
#include "core/string/translation.h"
#include "core/version.h"
-#include "core/version_hash.gen.h"
#include "main/main.h"
#include "scene/3d/importer_mesh_instance_3d.h"
#include "scene/gui/center_container.h"
@@ -128,10 +127,10 @@
#include "editor/plugins/animation_tree_editor_plugin.h"
#include "editor/plugins/asset_library_editor_plugin.h"
#include "editor/plugins/audio_stream_editor_plugin.h"
+#include "editor/plugins/audio_stream_randomizer_editor_plugin.h"
#include "editor/plugins/camera_3d_editor_plugin.h"
#include "editor/plugins/canvas_item_editor_plugin.h"
#include "editor/plugins/collision_polygon_2d_editor_plugin.h"
-#include "editor/plugins/collision_polygon_3d_editor_plugin.h"
#include "editor/plugins/collision_shape_2d_editor_plugin.h"
#include "editor/plugins/cpu_particles_2d_editor_plugin.h"
#include "editor/plugins/cpu_particles_3d_editor_plugin.h"
@@ -162,6 +161,7 @@
#include "editor/plugins/path_3d_editor_plugin.h"
#include "editor/plugins/physical_bone_3d_editor_plugin.h"
#include "editor/plugins/polygon_2d_editor_plugin.h"
+#include "editor/plugins/polygon_3d_editor_plugin.h"
#include "editor/plugins/replication_editor_plugin.h"
#include "editor/plugins/resource_preloader_editor_plugin.h"
#include "editor/plugins/root_motion_editor_plugin.h"
@@ -692,17 +692,17 @@ void EditorNode::_notification(int p_what) {
theme_base->set_theme(theme);
gui_base->set_theme(theme);
- gui_base->add_theme_style_override(SNAME("panel"), gui_base->get_theme_stylebox(SNAME("Background"), SNAME("EditorStyles")));
- scene_root_parent->add_theme_style_override(SNAME("panel"), gui_base->get_theme_stylebox(SNAME("Content"), SNAME("EditorStyles")));
- bottom_panel->add_theme_style_override(SNAME("panel"), gui_base->get_theme_stylebox(SNAME("panel"), SNAME("TabContainer")));
- scene_tabs->add_theme_style_override(SNAME("tab_selected"), gui_base->get_theme_stylebox(SNAME("SceneTabFG"), SNAME("EditorStyles")));
- scene_tabs->add_theme_style_override(SNAME("tab_unselected"), gui_base->get_theme_stylebox(SNAME("SceneTabBG"), SNAME("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(SNAME("hover"), gui_base->get_theme_stylebox(SNAME("MenuHover"), SNAME("EditorStyles")));
- project_menu->add_theme_style_override(SNAME("hover"), gui_base->get_theme_stylebox(SNAME("MenuHover"), SNAME("EditorStyles")));
- debug_menu->add_theme_style_override(SNAME("hover"), gui_base->get_theme_stylebox(SNAME("MenuHover"), SNAME("EditorStyles")));
- settings_menu->add_theme_style_override(SNAME("hover"), gui_base->get_theme_stylebox(SNAME("MenuHover"), SNAME("EditorStyles")));
- help_menu->add_theme_style_override(SNAME("hover"), gui_base->get_theme_stylebox(SNAME("MenuHover"), SNAME("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);
@@ -715,7 +715,7 @@ void EditorNode::_notification(int p_what) {
// debugger area
if (EditorDebuggerNode::get_singleton()->is_visible()) {
- bottom_panel->add_theme_style_override(SNAME("panel"), gui_base->get_theme_stylebox(SNAME("BottomPanelDebuggerOverride"), SNAME("EditorStyles")));
+ bottom_panel->add_theme_style_override("panel", gui_base->get_theme_stylebox(SNAME("BottomPanelDebuggerOverride"), SNAME("EditorStyles")));
}
// update_icons
@@ -745,7 +745,6 @@ void EditorNode::_notification(int p_what) {
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()) {
dock_tab_move_left->set_icon(theme->get_icon(SNAME("Forward"), SNAME("EditorIcons")));
dock_tab_move_right->set_icon(theme->get_icon(SNAME("Back"), SNAME("EditorIcons")));
@@ -766,8 +765,8 @@ void EditorNode::_notification(int p_what) {
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(SNAME("font"), gui_base->get_theme_font(SNAME("main_button_font"), SNAME("EditorFonts")));
- main_editor_buttons.write[i]->add_theme_font_size_override(SNAME("font_size"), gui_base->get_theme_font_size(SNAME("main_button_font_size"), SNAME("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")));
}
Set<String> updated_textfile_extensions;
@@ -2280,7 +2279,7 @@ void EditorNode::_edit_current(bool p_skip_foreign) {
if (main_plugin) {
// special case if use of external editor is true
Resource *current_res = Object::cast_to<Resource>(current_obj);
- if (main_plugin->get_name() == "Script" && current_obj->get_class_name() != StringName("VisualScript") && current_res && !current_res->is_built_in() && (bool(EditorSettings::get_singleton()->get("text_editor/external/use_external_editor")) || overrides_external_editor(current_obj))) {
+ if (main_plugin->get_name() == "Script" && current_obj->is_class("VisualScript") && current_res && !current_res->is_built_in() && (bool(EditorSettings::get_singleton()->get("text_editor/external/use_external_editor")) || overrides_external_editor(current_obj))) {
if (!changing_scene) {
main_plugin->edit(current_obj);
}
@@ -3184,8 +3183,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(), SNAME("EditorIcons")));
}
- tb->add_theme_font_override(SNAME("font"), singleton->gui_base->get_theme_font(SNAME("main_button_font"), SNAME("EditorFonts")));
- tb->add_theme_font_size_override(SNAME("font_size"), singleton->gui_base->get_theme_font_size(SNAME("main_button_font_size"), SNAME("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")));
singleton->main_editor_buttons.push_back(tb);
singleton->main_editor_button_vb->add_child(tb);
@@ -3293,8 +3292,8 @@ void EditorNode::set_addon_plugin_enabled(const String &p_addon, bool p_enabled,
return;
}
- // Errors in the script cause the base_type to be an empty string.
- if (String(script->get_instance_base_type()) == "") {
+ // Errors in the script cause the base_type to be an empty StringName.
+ if (script->get_instance_base_type() == StringName()) {
show_warning(vformat(TTR("Unable to load addon script from path: '%s'. This might be due to a code error in that script.\nDisabling the addon at '%s' to prevent further errors."), script_path, p_addon));
_remove_plugin_from_enabled(p_addon);
return;
@@ -3937,7 +3936,7 @@ StringName EditorNode::get_object_custom_type_name(const Object *p_object) const
ERR_FAIL_COND_V(!p_object, StringName());
Ref<Script> script = p_object->get_script();
- if (script.is_null() && p_object->is_class("Script")) {
+ if (script.is_null() && Object::cast_to<Script>(p_object)) {
script = p_object;
}
@@ -4148,13 +4147,12 @@ Ref<Texture2D> EditorNode::_file_dialog_get_icon(const String &p_path) {
void EditorNode::_build_icon_type_cache() {
List<StringName> tl;
- StringName ei = "EditorIcons";
- theme_base->get_theme()->get_icon_list(ei, &tl);
+ theme_base->get_theme()->get_icon_list(SNAME("EditorIcons"), &tl);
for (const StringName &E : tl) {
if (!ClassDB::class_exists(E)) {
continue;
}
- icon_type_cache[E] = theme_base->get_theme()->get_icon(E, ei);
+ icon_type_cache[E] = theme_base->get_theme()->get_icon(E, SNAME("EditorIcons"));
}
}
@@ -4252,10 +4250,10 @@ void EditorNode::_dock_make_float() {
window->add_child(p);
MarginContainer *margin = memnew(MarginContainer);
margin->set_anchors_and_offsets_preset(Control::PRESET_WIDE);
- margin->add_theme_constant_override(SNAME("margin_right"), borders.width);
- margin->add_theme_constant_override(SNAME("margin_top"), borders.height);
- margin->add_theme_constant_override(SNAME("margin_left"), borders.width);
- margin->add_theme_constant_override(SNAME("margin_bottom"), borders.height);
+ margin->add_theme_constant_override("margin_right", borders.width);
+ margin->add_theme_constant_override("margin_top", borders.height);
+ margin->add_theme_constant_override("margin_left", borders.width);
+ margin->add_theme_constant_override("margin_bottom", borders.height);
window->add_child(margin);
dock->set_anchors_and_offsets_preset(Control::PRESET_WIDE);
margin->add_child(dock);
@@ -5200,9 +5198,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(SNAME("panel"), gui_base->get_theme_stylebox(SNAME("BottomPanelDebuggerOverride"), SNAME("EditorStyles")));
+ bottom_panel->add_theme_style_override("panel", gui_base->get_theme_stylebox(SNAME("BottomPanelDebuggerOverride"), SNAME("EditorStyles")));
} else {
- bottom_panel->add_theme_style_override(SNAME("panel"), gui_base->get_theme_stylebox(SNAME("panel"), SNAME("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);
@@ -5212,7 +5210,7 @@ void EditorNode::_bottom_panel_switch(bool p_enable, int p_idx) {
bottom_panel_raise->show();
} else {
- bottom_panel->add_theme_style_override(SNAME("panel"), gui_base->get_theme_stylebox(SNAME("panel"), SNAME("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);
@@ -5603,9 +5601,9 @@ void EditorNode::_bottom_panel_raise_toggled(bool p_pressed) {
void EditorNode::_update_rendering_driver_color() {
if (rendering_driver->get_text() == "opengl3") {
- rendering_driver->add_theme_color_override(SNAME("font_color"), Color::hex(0x5586a4ff));
+ rendering_driver->add_theme_color_override("font_color", Color::hex(0x5586a4ff));
} else if (rendering_driver->get_text() == "vulkan") {
- rendering_driver->add_theme_color_override(SNAME("font_color"), theme_base->get_theme_color(SNAME("vulkan_color"), SNAME("Editor")));
+ rendering_driver->add_theme_color_override("font_color", theme_base->get_theme_color(SNAME("vulkan_color"), SNAME("Editor")));
}
}
@@ -5678,6 +5676,7 @@ void EditorNode::_feature_profile_changed() {
void EditorNode::_bind_methods() {
GLOBAL_DEF("editor/scene/scene_naming", SCENE_NAME_CASING_SNAKE_CASE);
ProjectSettings::get_singleton()->set_custom_property_info("editor/scene/scene_naming", PropertyInfo(Variant::INT, "editor/scene/scene_naming", PROPERTY_HINT_ENUM, "Auto,PascalCase,snake_case"));
+ ClassDB::bind_method("edit_current", &EditorNode::edit_current);
ClassDB::bind_method("_editor_select", &EditorNode::_editor_select);
ClassDB::bind_method("_node_renamed", &EditorNode::_node_renamed);
ClassDB::bind_method("edit_node", &EditorNode::edit_node);
@@ -6054,7 +6053,7 @@ EditorNode::EditorNode() {
theme_base->set_theme(theme);
gui_base->set_theme(theme);
- gui_base->add_theme_style_override(SNAME("panel"), gui_base->get_theme_stylebox(SNAME("Background"), SNAME("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);
@@ -6069,7 +6068,7 @@ EditorNode::EditorNode() {
main_vbox = memnew(VBoxContainer);
gui_base->add_child(main_vbox);
main_vbox->set_anchors_and_offsets_preset(Control::PRESET_WIDE, Control::PRESET_MODE_MINSIZE, 8);
- main_vbox->add_theme_constant_override(SNAME("separation"), 8 * EDSCALE);
+ main_vbox->add_theme_constant_override("separation", 8 * EDSCALE);
menu_hb = memnew(HBoxContainer);
main_vbox->add_child(menu_hb);
@@ -6220,7 +6219,7 @@ EditorNode::EditorNode() {
VBoxContainer *srt = memnew(VBoxContainer);
srt->set_v_size_flags(Control::SIZE_EXPAND_FILL);
top_split->add_child(srt);
- srt->add_theme_constant_override(SNAME("separation"), 0);
+ srt->add_theme_constant_override("separation", 0);
tab_preview_panel = memnew(Panel);
tab_preview_panel->set_size(Size2(100, 100) * EDSCALE);
@@ -6238,8 +6237,8 @@ EditorNode::EditorNode() {
srt->add_child(tabbar_container);
scene_tabs = memnew(TabBar);
- scene_tabs->add_theme_style_override(SNAME("tab_selected"), gui_base->get_theme_stylebox(SNAME("SceneTabFG"), SNAME("EditorStyles")));
- scene_tabs->add_theme_style_override(SNAME("tab_unselected"), gui_base->get_theme_stylebox(SNAME("SceneTabBG"), SNAME("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_alignment(TabBar::ALIGNMENT_LEFT);
@@ -6265,7 +6264,7 @@ EditorNode::EditorNode() {
scene_tab_add->set_flat(true);
scene_tab_add->set_tooltip(TTR("Add a new scene."));
scene_tab_add->set_icon(gui_base->get_theme_icon(SNAME("Add"), SNAME("EditorIcons")));
- scene_tab_add->add_theme_color_override(SNAME("icon_normal_color"), Color(0.6f, 0.6f, 0.6f, 0.8f));
+ scene_tab_add->add_theme_color_override("icon_normal_color", Color(0.6f, 0.6f, 0.6f, 0.8f));
scene_tabs->add_child(scene_tab_add);
scene_tab_add->connect("pressed", callable_mp(this, &EditorNode::_menu_option), make_binds(FILE_NEW_SCENE));
@@ -6287,7 +6286,7 @@ EditorNode::EditorNode() {
scene_root_parent = memnew(PanelContainer);
scene_root_parent->set_custom_minimum_size(Size2(0, 80) * EDSCALE);
- scene_root_parent->add_theme_style_override(SNAME("panel"), gui_base->get_theme_stylebox(SNAME("Content"), SNAME("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);
@@ -6301,7 +6300,7 @@ EditorNode::EditorNode() {
main_control = memnew(VBoxContainer);
main_control->set_v_size_flags(Control::SIZE_EXPAND_FILL);
- main_control->add_theme_constant_override(SNAME("separation"), 0);
+ main_control->add_theme_constant_override("separation", 0);
scene_root_parent->add_child(main_control);
HBoxContainer *left_menu_hb = memnew(HBoxContainer);
@@ -6311,7 +6310,7 @@ 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(SNAME("hover"), gui_base->get_theme_stylebox(SNAME("MenuHover"), SNAME("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);
@@ -6427,7 +6426,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(SNAME("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")));
left_menu_hb->add_child(project_menu);
p = project_menu->get_popup();
@@ -6477,7 +6476,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(SNAME("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")));
left_menu_hb->add_child(debug_menu);
menu_hb->add_spacer();
@@ -6486,7 +6485,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(SNAME("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")));
left_menu_hb->add_child(settings_menu);
p = settings_menu->get_popup();
@@ -6534,7 +6533,7 @@ 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(SNAME("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")));
left_menu_hb->add_child(help_menu);
p = help_menu->get_popup();
@@ -6638,8 +6637,8 @@ EditorNode::EditorNode() {
rendering_driver->set_flat(true);
rendering_driver->set_focus_mode(Control::FOCUS_NONE);
rendering_driver->connect("item_selected", callable_mp(this, &EditorNode::_rendering_driver_selected));
- rendering_driver->add_theme_font_override(SNAME("font"), gui_base->get_theme_font(SNAME("bold"), SNAME("EditorFonts")));
- rendering_driver->add_theme_font_size_override(SNAME("font_size"), gui_base->get_theme_font_size(SNAME("bold_size"), SNAME("EditorFonts")));
+ rendering_driver->add_theme_font_override("font", gui_base->get_theme_font(SNAME("bold"), SNAME("EditorFonts")));
+ rendering_driver->add_theme_font_size_override("font_size", gui_base->get_theme_font_size(SNAME("bold_size"), SNAME("EditorFonts")));
right_menu_hb->add_child(rendering_driver);
@@ -6762,7 +6761,7 @@ EditorNode::EditorNode() {
// Bottom panels
bottom_panel = memnew(PanelContainer);
- bottom_panel->add_theme_style_override(SNAME("panel"), gui_base->get_theme_stylebox(SNAME("panel"), SNAME("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);
@@ -7014,6 +7013,7 @@ EditorNode::EditorNode() {
add_editor_plugin(memnew(TextureLayeredEditorPlugin(this)));
add_editor_plugin(memnew(Texture3DEditorPlugin(this)));
add_editor_plugin(memnew(AudioStreamEditorPlugin(this)));
+ add_editor_plugin(memnew(AudioStreamRandomizerEditorPlugin(this)));
add_editor_plugin(memnew(AudioBusesEditorPlugin(audio_bus_editor)));
add_editor_plugin(memnew(Skeleton3DEditorPlugin(this)));
add_editor_plugin(memnew(SkeletonIK3DEditorPlugin(this)));
diff --git a/editor/editor_path.cpp b/editor/editor_path.cpp
index e9ffb08cec..3dee06fb3e 100644
--- a/editor/editor_path.cpp
+++ b/editor/editor_path.cpp
@@ -181,7 +181,7 @@ void EditorPath::_notification(int p_what) {
update_path();
sub_objects_icon->set_texture(get_theme_icon(SNAME("select_arrow"), SNAME("Tree")));
- current_object_label->add_theme_font_override(SNAME("font"), get_theme_font(SNAME("main"), SNAME("EditorFonts")));
+ current_object_label->add_theme_font_override("font", get_theme_font(SNAME("main"), SNAME("EditorFonts")));
} break;
case NOTIFICATION_READY: {
@@ -198,8 +198,8 @@ EditorPath::EditorPath(EditorHistory *p_history) {
MarginContainer *main_mc = memnew(MarginContainer);
main_mc->set_anchors_and_offsets_preset(PRESET_WIDE);
- main_mc->add_theme_constant_override(SNAME("margin_left"), 4 * EDSCALE);
- main_mc->add_theme_constant_override(SNAME("margin_right"), 6 * EDSCALE);
+ main_mc->add_theme_constant_override("margin_left", 4 * EDSCALE);
+ main_mc->add_theme_constant_override("margin_right", 6 * EDSCALE);
add_child(main_mc);
HBoxContainer *main_hb = memnew(HBoxContainer);
diff --git a/editor/editor_properties.cpp b/editor/editor_properties.cpp
index 80da8363ad..ef1ceebabf 100644
--- a/editor/editor_properties.cpp
+++ b/editor/editor_properties.cpp
@@ -3087,18 +3087,18 @@ void EditorPropertyResource::_update_property_bg() {
}
count_subinspectors = MIN(15, count_subinspectors);
- add_theme_color_override(SNAME("property_color"), get_theme_color(SNAME("sub_inspector_property_color"), SNAME("Editor")));
- add_theme_style_override(SNAME("bg_selected"), get_theme_stylebox("sub_inspector_property_bg_selected" + itos(count_subinspectors), SNAME("Editor")));
- add_theme_style_override(SNAME("bg"), get_theme_stylebox("sub_inspector_property_bg" + itos(count_subinspectors), SNAME("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), SNAME("Editor")));
+ add_theme_style_override("bg", get_theme_stylebox("sub_inspector_property_bg" + itos(count_subinspectors), SNAME("Editor")));
- add_theme_constant_override(SNAME("font_offset"), get_theme_constant(SNAME("sub_inspector_font_offset"), SNAME("Editor")));
- add_theme_constant_override(SNAME("vseparation"), 0);
+ 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(SNAME("property_color"), get_theme_color(SNAME("property_color"), SNAME("EditorProperty")));
- add_theme_style_override(SNAME("bg_selected"), get_theme_stylebox(SNAME("bg_selected"), SNAME("EditorProperty")));
- add_theme_style_override(SNAME("bg"), get_theme_stylebox(SNAME("bg"), SNAME("EditorProperty")));
- add_theme_constant_override(SNAME("vseparation"), get_theme_constant(SNAME("vseparation"), SNAME("EditorProperty")));
- add_theme_constant_override(SNAME("font_offset"), get_theme_constant(SNAME("font_offset"), SNAME("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;
diff --git a/editor/editor_properties_array_dict.cpp b/editor/editor_properties_array_dict.cpp
index a96b7d3730..c28c7db2cb 100644
--- a/editor/editor_properties_array_dict.cpp
+++ b/editor/editor_properties_array_dict.cpp
@@ -658,7 +658,7 @@ void EditorPropertyArray::_reorder_button_up() {
Variant array = object->get_array();
Variant value_to_move = array.get(reorder_from_index);
- array.call("remove", reorder_from_index);
+ array.call("remove_at", reorder_from_index);
array.call("insert", reorder_to_index, value_to_move);
emit_changed(get_edited_property(), array, "", false);
@@ -1082,7 +1082,7 @@ void EditorPropertyDictionary::update_property() {
}
flat->set_bg_color(get_theme_color(SNAME("prop_subsection"), SNAME("Editor")));
- pc->add_theme_style_override(SNAME("panel"), flat);
+ pc->add_theme_style_override("panel", flat);
add_vbox = memnew(VBoxContainer);
pc->add_child(add_vbox);
}
diff --git a/editor/editor_resource_picker.cpp b/editor/editor_resource_picker.cpp
index 716643f812..398a096550 100644
--- a/editor/editor_resource_picker.cpp
+++ b/editor/editor_resource_picker.cpp
@@ -77,16 +77,16 @@ void EditorResourcePicker::_update_resource_preview(const String &p_path, const
return;
}
- String type = edited_resource->get_class_name();
- if (ClassDB::is_parent_class(type, "Script")) {
- assign_button->set_text(edited_resource->get_path().get_file());
+ Ref<Script> script = edited_resource;
+ if (script.is_valid()) {
+ assign_button->set_text(script->get_path().get_file());
return;
}
if (p_preview.is_valid()) {
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 == "GradientTexture1D") {
+ if (Ref<GradientTexture1D>(edited_resource).is_valid()) {
preview_rect->set_stretch_mode(TextureRect::STRETCH_SCALE);
assign_button->set_custom_minimum_size(Size2(1, 1));
} else {
@@ -377,6 +377,8 @@ void EditorResourcePicker::_edit_menu_cbk(int p_which) {
Resource *resp = Object::cast_to<Resource>(obj);
ERR_BREAK(!resp);
+ EditorNode::get_editor_data().instantiate_object_properties(obj);
+
edited_resource = RES(resp);
emit_signal(SNAME("resource_changed"), edited_resource);
_update_resource();
@@ -640,7 +642,7 @@ void EditorResourcePicker::drop_data_fw(const Point2 &p_point, const Variant &p_
for (Set<String>::Element *E = allowed_types.front(); E; E = E->next()) {
String at = E->get().strip_edges();
- if (at == "BaseMaterial3D" && ClassDB::is_parent_class(dropped_resource->get_class(), "Texture2D")) {
+ if (at == "BaseMaterial3D" && Ref<Texture2D>(dropped_resource).is_valid()) {
// Use existing resource if possible and only replace its data.
Ref<StandardMaterial3D> mat = edited_resource;
if (!mat.is_valid()) {
@@ -651,7 +653,7 @@ void EditorResourcePicker::drop_data_fw(const Point2 &p_point, const Variant &p_
break;
}
- if (at == "ShaderMaterial" && ClassDB::is_parent_class(dropped_resource->get_class(), "Shader")) {
+ if (at == "ShaderMaterial" && Ref<Shader>(dropped_resource).is_valid()) {
Ref<ShaderMaterial> mat = edited_resource;
if (!mat.is_valid()) {
mat.instantiate();
@@ -661,7 +663,7 @@ void EditorResourcePicker::drop_data_fw(const Point2 &p_point, const Variant &p_
break;
}
- if (at == "Font" && ClassDB::is_parent_class(dropped_resource->get_class(), "FontData")) {
+ if (at == "Font" && Ref<FontData>(dropped_resource).is_valid()) {
Ref<Font> font = edited_resource;
if (!font.is_valid()) {
font.instantiate();
@@ -671,7 +673,7 @@ void EditorResourcePicker::drop_data_fw(const Point2 &p_point, const Variant &p_
break;
}
- if (at == "Texture2D" && ClassDB::is_parent_class(dropped_resource->get_class(), "Image")) {
+ if (at == "Texture2D" && Ref<Image>(dropped_resource).is_valid()) {
Ref<ImageTexture> texture = edited_resource;
if (!texture.is_valid()) {
texture.instantiate();
diff --git a/editor/editor_sectioned_inspector.cpp b/editor/editor_sectioned_inspector.cpp
index 012f10a1bd..1bab56ac4a 100644
--- a/editor/editor_sectioned_inspector.cpp
+++ b/editor/editor_sectioned_inspector.cpp
@@ -302,7 +302,7 @@ SectionedInspector::SectionedInspector() :
sections(memnew(Tree)),
filter(memnew(SectionedInspectorFilter)),
inspector(memnew(EditorInspector)) {
- add_theme_constant_override(SNAME("autohide"), 1); // Fixes the dragger always showing up
+ add_theme_constant_override("autohide", 1); // Fixes the dragger always showing up
VBoxContainer *left_vb = memnew(VBoxContainer);
left_vb->set_custom_minimum_size(Size2(190, 0) * EDSCALE);
diff --git a/editor/editor_settings_dialog.cpp b/editor/editor_settings_dialog.cpp
index 22425ae37d..fc37590337 100644
--- a/editor/editor_settings_dialog.cpp
+++ b/editor/editor_settings_dialog.cpp
@@ -182,9 +182,9 @@ void EditorSettingsDialog::_update_icons() {
shortcut_search_box->set_clear_button_enabled(true);
restart_close_button->set_icon(shortcuts->get_theme_icon(SNAME("Close"), SNAME("EditorIcons")));
- restart_container->add_theme_style_override(SNAME("panel"), shortcuts->get_theme_stylebox(SNAME("bg"), SNAME("Tree")));
+ 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(SNAME("font_color"), shortcuts->get_theme_color(SNAME("warning_color"), SNAME("Editor")));
+ restart_label->add_theme_color_override("font_color", shortcuts->get_theme_color(SNAME("warning_color"), SNAME("Editor")));
}
void EditorSettingsDialog::_event_config_confirmed() {
diff --git a/editor/editor_spin_slider.cpp b/editor/editor_spin_slider.cpp
index 881cd7a8a5..cd28a65c7b 100644
--- a/editor/editor_spin_slider.cpp
+++ b/editor/editor_spin_slider.cpp
@@ -268,7 +268,7 @@ void EditorSpinSlider::_update_value_input_stylebox() {
stylebox->set_default_margin(SIDE_RIGHT, 0);
}
- value_input->add_theme_style_override(SNAME("normal"), stylebox);
+ value_input->add_theme_style_override("normal", stylebox);
}
void EditorSpinSlider::_draw_spin_slider() {
diff --git a/editor/editor_themes.cpp b/editor/editor_themes.cpp
index 7aa5ba7023..1e373239a6 100644
--- a/editor/editor_themes.cpp
+++ b/editor/editor_themes.cpp
@@ -446,28 +446,28 @@ Ref<Theme> create_editor_theme(const Ref<Theme> p_theme) {
float prev_icon_saturation = theme->has_color(SNAME("icon_saturation"), SNAME("Editor")) ? theme->get_color(SNAME("icon_saturation"), SNAME("Editor")).r : 1.0;
- theme->set_color(SNAME("icon_saturation"), SNAME("Editor"), Color(icon_saturation, icon_saturation, icon_saturation)); // can't save single float in theme, so using color
- theme->set_color(SNAME("accent_color"), SNAME("Editor"), accent_color);
- theme->set_color(SNAME("highlight_color"), SNAME("Editor"), highlight_color);
- theme->set_color(SNAME("disabled_highlight_color"), SNAME("Editor"), disabled_highlight_color);
- theme->set_color(SNAME("base_color"), SNAME("Editor"), base_color);
- theme->set_color(SNAME("dark_color_1"), SNAME("Editor"), dark_color_1);
- theme->set_color(SNAME("dark_color_2"), SNAME("Editor"), dark_color_2);
- theme->set_color(SNAME("dark_color_3"), SNAME("Editor"), dark_color_3);
- theme->set_color(SNAME("contrast_color_1"), SNAME("Editor"), contrast_color_1);
- theme->set_color(SNAME("contrast_color_2"), SNAME("Editor"), contrast_color_2);
- theme->set_color(SNAME("box_selection_fill_color"), SNAME("Editor"), accent_color * Color(1, 1, 1, 0.3));
- theme->set_color(SNAME("box_selection_stroke_color"), SNAME("Editor"), accent_color * Color(1, 1, 1, 0.8));
-
- theme->set_color(SNAME("axis_x_color"), SNAME("Editor"), Color(0.96, 0.20, 0.32));
- theme->set_color(SNAME("axis_y_color"), SNAME("Editor"), Color(0.53, 0.84, 0.01));
- theme->set_color(SNAME("axis_z_color"), SNAME("Editor"), Color(0.16, 0.55, 0.96));
-
- theme->set_color(SNAME("font_color"), SNAME("Editor"), font_color);
- theme->set_color(SNAME("highlighted_font_color"), SNAME("Editor"), font_hover_color);
- theme->set_color(SNAME("disabled_font_color"), SNAME("Editor"), font_disabled_color);
-
- theme->set_color(SNAME("mono_color"), SNAME("Editor"), mono_color);
+ theme->set_color("icon_saturation", "Editor", Color(icon_saturation, icon_saturation, icon_saturation)); // can't save single float in theme, so using color
+ theme->set_color("accent_color", "Editor", accent_color);
+ theme->set_color("highlight_color", "Editor", highlight_color);
+ theme->set_color("disabled_highlight_color", "Editor", disabled_highlight_color);
+ theme->set_color("base_color", "Editor", base_color);
+ theme->set_color("dark_color_1", "Editor", dark_color_1);
+ theme->set_color("dark_color_2", "Editor", dark_color_2);
+ theme->set_color("dark_color_3", "Editor", dark_color_3);
+ theme->set_color("contrast_color_1", "Editor", contrast_color_1);
+ theme->set_color("contrast_color_2", "Editor", contrast_color_2);
+ theme->set_color("box_selection_fill_color", "Editor", accent_color * Color(1, 1, 1, 0.3));
+ theme->set_color("box_selection_stroke_color", "Editor", accent_color * Color(1, 1, 1, 0.8));
+
+ theme->set_color("axis_x_color", "Editor", Color(0.96, 0.20, 0.32));
+ theme->set_color("axis_y_color", "Editor", Color(0.53, 0.84, 0.01));
+ theme->set_color("axis_z_color", "Editor", Color(0.16, 0.55, 0.96));
+
+ theme->set_color("font_color", "Editor", font_color);
+ theme->set_color("highlighted_font_color", "Editor", font_hover_color);
+ theme->set_color("disabled_font_color", "Editor", font_disabled_color);
+
+ theme->set_color("mono_color", "Editor", mono_color);
Color success_color = Color(0.45, 0.95, 0.5);
Color warning_color = Color(1, 0.87, 0.4);
@@ -483,21 +483,21 @@ Ref<Theme> create_editor_theme(const Ref<Theme> p_theme) {
error_color = error_color.lerp(mono_color, 0.25);
}
- theme->set_color(SNAME("success_color"), SNAME("Editor"), success_color);
- theme->set_color(SNAME("warning_color"), SNAME("Editor"), warning_color);
- theme->set_color(SNAME("error_color"), SNAME("Editor"), error_color);
- theme->set_color(SNAME("property_color"), SNAME("Editor"), property_color);
- theme->set_color(SNAME("readonly_color"), SNAME("Editor"), readonly_color);
+ theme->set_color("success_color", "Editor", success_color);
+ theme->set_color("warning_color", "Editor", warning_color);
+ theme->set_color("error_color", "Editor", error_color);
+ theme->set_color("property_color", "Editor", property_color);
+ theme->set_color("readonly_color", "Editor", readonly_color);
if (!dark_theme) {
- theme->set_color(SNAME("vulkan_color"), SNAME("Editor"), Color::hex(0xad1128ff));
+ theme->set_color("vulkan_color", "Editor", Color::hex(0xad1128ff));
} else {
- theme->set_color(SNAME("vulkan_color"), SNAME("Editor"), Color(1.0, 0.0, 0.0));
+ theme->set_color("vulkan_color", "Editor", Color(1.0, 0.0, 0.0));
}
const int thumb_size = EDITOR_GET("filesystem/file_dialog/thumbnail_size");
- theme->set_constant(SNAME("scale"), SNAME("Editor"), EDSCALE);
- theme->set_constant(SNAME("thumb_size"), SNAME("Editor"), thumb_size);
- theme->set_constant(SNAME("dark_theme"), SNAME("Editor"), dark_theme);
+ theme->set_constant("scale", "Editor", EDSCALE);
+ theme->set_constant("thumb_size", "Editor", thumb_size);
+ theme->set_constant("dark_theme", "Editor", dark_theme);
// Register icons + font
@@ -632,113 +632,113 @@ Ref<Theme> create_editor_theme(const Ref<Theme> p_theme) {
// Editor background
Color background_color_opaque = background_color;
background_color_opaque.a = 1.0;
- theme->set_stylebox(SNAME("Background"), SNAME("EditorStyles"), make_flat_stylebox(background_color_opaque, default_margin_size, default_margin_size, default_margin_size, default_margin_size));
+ theme->set_stylebox("Background", "EditorStyles", make_flat_stylebox(background_color_opaque, default_margin_size, default_margin_size, default_margin_size, default_margin_size));
// Focus
- theme->set_stylebox(SNAME("Focus"), SNAME("EditorStyles"), style_widget_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(SNAME("FocusViewport"), SNAME("EditorStyles"), style_widget_focus_viewport);
+ theme->set_stylebox("FocusViewport", "EditorStyles", style_widget_focus_viewport);
// Menu
Ref<StyleBoxFlat> style_menu = style_widget->duplicate();
style_menu->set_draw_center(false);
style_menu->set_border_width_all(0);
- theme->set_stylebox(SNAME("panel"), SNAME("PanelContainer"), style_menu);
- theme->set_stylebox(SNAME("MenuPanel"), SNAME("EditorStyles"), style_menu);
+ theme->set_stylebox("panel", "PanelContainer", style_menu);
+ theme->set_stylebox("MenuPanel", "EditorStyles", style_menu);
// CanvasItem Editor
Ref<StyleBoxFlat> style_canvas_editor_info = make_flat_stylebox(Color(0.0, 0.0, 0.0, 0.2));
style_canvas_editor_info->set_expand_margin_size_all(4 * EDSCALE);
- theme->set_stylebox(SNAME("CanvasItemInfoOverlay"), SNAME("EditorStyles"), style_canvas_editor_info);
+ theme->set_stylebox("CanvasItemInfoOverlay", "EditorStyles", style_canvas_editor_info);
// Script Editor
- theme->set_stylebox(SNAME("ScriptEditorPanel"), SNAME("EditorStyles"), make_empty_stylebox(default_margin_size, 0, default_margin_size, default_margin_size));
- theme->set_stylebox(SNAME("ScriptEditor"), SNAME("EditorStyles"), make_empty_stylebox(0, 0, 0, 0));
+ theme->set_stylebox("ScriptEditorPanel", "EditorStyles", make_empty_stylebox(default_margin_size, 0, default_margin_size, default_margin_size));
+ theme->set_stylebox("ScriptEditor", "EditorStyles", make_empty_stylebox(0, 0, 0, 0));
// Play button group
- theme->set_stylebox(SNAME("PlayButtonPanel"), SNAME("EditorStyles"), style_empty);
+ theme->set_stylebox("PlayButtonPanel", "EditorStyles", style_empty);
- theme->set_stylebox(SNAME("normal"), SNAME("MenuButton"), style_menu);
- theme->set_stylebox(SNAME("hover"), SNAME("MenuButton"), style_widget_hover);
- theme->set_stylebox(SNAME("pressed"), SNAME("MenuButton"), style_menu);
- theme->set_stylebox(SNAME("focus"), SNAME("MenuButton"), style_menu);
- theme->set_stylebox(SNAME("disabled"), SNAME("MenuButton"), style_menu);
+ theme->set_stylebox("normal", "MenuButton", style_menu);
+ theme->set_stylebox("hover", "MenuButton", style_widget_hover);
+ theme->set_stylebox("pressed", "MenuButton", style_menu);
+ theme->set_stylebox("focus", "MenuButton", style_menu);
+ theme->set_stylebox("disabled", "MenuButton", style_menu);
- theme->set_color(SNAME("font_color"), SNAME("MenuButton"), font_color);
- theme->set_color(SNAME("font_hover_color"), SNAME("MenuButton"), font_hover_color);
- theme->set_color(SNAME("font_focus_color"), SNAME("MenuButton"), font_focus_color);
+ theme->set_color("font_color", "MenuButton", font_color);
+ theme->set_color("font_hover_color", "MenuButton", font_hover_color);
+ theme->set_color("font_focus_color", "MenuButton", font_focus_color);
- theme->set_stylebox(SNAME("MenuHover"), SNAME("EditorStyles"), style_widget_hover);
+ theme->set_stylebox("MenuHover", "EditorStyles", style_widget_hover);
// Buttons
- theme->set_stylebox(SNAME("normal"), SNAME("Button"), style_widget);
- theme->set_stylebox(SNAME("hover"), SNAME("Button"), style_widget_hover);
- theme->set_stylebox(SNAME("pressed"), SNAME("Button"), style_widget_pressed);
- theme->set_stylebox(SNAME("focus"), SNAME("Button"), style_widget_focus);
- theme->set_stylebox(SNAME("disabled"), SNAME("Button"), style_widget_disabled);
-
- theme->set_color(SNAME("font_color"), SNAME("Button"), font_color);
- theme->set_color(SNAME("font_hover_color"), SNAME("Button"), font_hover_color);
- theme->set_color(SNAME("font_focus_color"), SNAME("Button"), font_focus_color);
- theme->set_color(SNAME("font_pressed_color"), SNAME("Button"), accent_color);
- theme->set_color(SNAME("font_disabled_color"), SNAME("Button"), font_disabled_color);
- theme->set_color(SNAME("icon_hover_color"), SNAME("Button"), icon_hover_color);
- theme->set_color(SNAME("icon_focus_color"), SNAME("Button"), icon_focus_color);
- theme->set_color(SNAME("icon_pressed_color"), SNAME("Button"), icon_pressed_color);
+ theme->set_stylebox("normal", "Button", style_widget);
+ theme->set_stylebox("hover", "Button", style_widget_hover);
+ theme->set_stylebox("pressed", "Button", style_widget_pressed);
+ theme->set_stylebox("focus", "Button", style_widget_focus);
+ theme->set_stylebox("disabled", "Button", style_widget_disabled);
+
+ theme->set_color("font_color", "Button", font_color);
+ theme->set_color("font_hover_color", "Button", font_hover_color);
+ theme->set_color("font_focus_color", "Button", font_focus_color);
+ theme->set_color("font_pressed_color", "Button", accent_color);
+ theme->set_color("font_disabled_color", "Button", font_disabled_color);
+ theme->set_color("icon_hover_color", "Button", icon_hover_color);
+ theme->set_color("icon_focus_color", "Button", icon_focus_color);
+ theme->set_color("icon_pressed_color", "Button", icon_pressed_color);
// OptionButton
- theme->set_stylebox(SNAME("focus"), SNAME("OptionButton"), style_widget_focus);
-
- theme->set_stylebox(SNAME("normal"), SNAME("OptionButton"), style_widget);
- theme->set_stylebox(SNAME("hover"), SNAME("OptionButton"), style_widget_hover);
- theme->set_stylebox(SNAME("pressed"), SNAME("OptionButton"), style_widget_pressed);
- theme->set_stylebox(SNAME("disabled"), SNAME("OptionButton"), style_widget_disabled);
-
- theme->set_stylebox(SNAME("normal_mirrored"), SNAME("OptionButton"), style_widget);
- theme->set_stylebox(SNAME("hover_mirrored"), SNAME("OptionButton"), style_widget_hover);
- theme->set_stylebox(SNAME("pressed_mirrored"), SNAME("OptionButton"), style_widget_pressed);
- theme->set_stylebox(SNAME("disabled_mirrored"), SNAME("OptionButton"), style_widget_disabled);
-
- theme->set_color(SNAME("font_color"), SNAME("OptionButton"), font_color);
- theme->set_color(SNAME("font_hover_color"), SNAME("OptionButton"), font_hover_color);
- theme->set_color(SNAME("font_focus_color"), SNAME("OptionButton"), font_focus_color);
- theme->set_color(SNAME("font_pressed_color"), SNAME("OptionButton"), accent_color);
- theme->set_color(SNAME("font_disabled_color"), SNAME("OptionButton"), font_disabled_color);
- theme->set_color(SNAME("icon_hover_color"), SNAME("OptionButton"), icon_hover_color);
- theme->set_color(SNAME("icon_focus_color"), SNAME("OptionButton"), icon_focus_color);
- theme->set_icon(SNAME("arrow"), SNAME("OptionButton"), theme->get_icon(SNAME("GuiOptionArrow"), SNAME("EditorIcons")));
- theme->set_constant(SNAME("arrow_margin"), SNAME("OptionButton"), widget_default_margin.x - 2 * EDSCALE);
- theme->set_constant(SNAME("modulate_arrow"), SNAME("OptionButton"), true);
- theme->set_constant(SNAME("hseparation"), SNAME("OptionButton"), 4 * EDSCALE);
+ theme->set_stylebox("focus", "OptionButton", style_widget_focus);
+
+ theme->set_stylebox("normal", "OptionButton", style_widget);
+ theme->set_stylebox("hover", "OptionButton", style_widget_hover);
+ theme->set_stylebox("pressed", "OptionButton", style_widget_pressed);
+ theme->set_stylebox("disabled", "OptionButton", style_widget_disabled);
+
+ theme->set_stylebox("normal_mirrored", "OptionButton", style_widget);
+ theme->set_stylebox("hover_mirrored", "OptionButton", style_widget_hover);
+ theme->set_stylebox("pressed_mirrored", "OptionButton", style_widget_pressed);
+ theme->set_stylebox("disabled_mirrored", "OptionButton", style_widget_disabled);
+
+ theme->set_color("font_color", "OptionButton", font_color);
+ theme->set_color("font_hover_color", "OptionButton", font_hover_color);
+ theme->set_color("font_focus_color", "OptionButton", font_focus_color);
+ theme->set_color("font_pressed_color", "OptionButton", accent_color);
+ theme->set_color("font_disabled_color", "OptionButton", font_disabled_color);
+ theme->set_color("icon_hover_color", "OptionButton", icon_hover_color);
+ theme->set_color("icon_focus_color", "OptionButton", icon_focus_color);
+ theme->set_icon("arrow", "OptionButton", theme->get_icon(SNAME("GuiOptionArrow"), SNAME("EditorIcons")));
+ theme->set_constant("arrow_margin", "OptionButton", widget_default_margin.x - 2 * EDSCALE);
+ theme->set_constant("modulate_arrow", "OptionButton", true);
+ theme->set_constant("hseparation", "OptionButton", 4 * EDSCALE);
// CheckButton
- theme->set_stylebox(SNAME("normal"), SNAME("CheckButton"), style_menu);
- theme->set_stylebox(SNAME("pressed"), SNAME("CheckButton"), style_menu);
- theme->set_stylebox(SNAME("disabled"), SNAME("CheckButton"), style_menu);
- theme->set_stylebox(SNAME("hover"), SNAME("CheckButton"), style_menu);
-
- theme->set_icon(SNAME("on"), SNAME("CheckButton"), theme->get_icon(SNAME("GuiToggleOn"), SNAME("EditorIcons")));
- theme->set_icon(SNAME("on_disabled"), SNAME("CheckButton"), theme->get_icon(SNAME("GuiToggleOnDisabled"), SNAME("EditorIcons")));
- theme->set_icon(SNAME("off"), SNAME("CheckButton"), theme->get_icon(SNAME("GuiToggleOff"), SNAME("EditorIcons")));
- theme->set_icon(SNAME("off_disabled"), SNAME("CheckButton"), theme->get_icon(SNAME("GuiToggleOffDisabled"), SNAME("EditorIcons")));
-
- theme->set_icon(SNAME("on_mirrored"), SNAME("CheckButton"), theme->get_icon(SNAME("GuiToggleOnMirrored"), SNAME("EditorIcons")));
- theme->set_icon(SNAME("on_disabled_mirrored"), SNAME("CheckButton"), theme->get_icon(SNAME("GuiToggleOnDisabledMirrored"), SNAME("EditorIcons")));
- theme->set_icon(SNAME("off_mirrored"), SNAME("CheckButton"), theme->get_icon(SNAME("GuiToggleOffMirrored"), SNAME("EditorIcons")));
- theme->set_icon(SNAME("off_disabled_mirrored"), SNAME("CheckButton"), theme->get_icon(SNAME("GuiToggleOffDisabledMirrored"), SNAME("EditorIcons")));
-
- theme->set_color(SNAME("font_color"), SNAME("CheckButton"), font_color);
- theme->set_color(SNAME("font_hover_color"), SNAME("CheckButton"), font_hover_color);
- theme->set_color(SNAME("font_focus_color"), SNAME("CheckButton"), font_focus_color);
- theme->set_color(SNAME("font_pressed_color"), SNAME("CheckButton"), accent_color);
- theme->set_color(SNAME("font_disabled_color"), SNAME("CheckButton"), font_disabled_color);
- theme->set_color(SNAME("icon_hover_color"), SNAME("CheckButton"), icon_hover_color);
- theme->set_color(SNAME("icon_focus_color"), SNAME("CheckButton"), icon_focus_color);
-
- theme->set_constant(SNAME("hseparation"), SNAME("CheckButton"), 8 * EDSCALE);
- theme->set_constant(SNAME("check_vadjust"), SNAME("CheckButton"), 0 * EDSCALE);
+ theme->set_stylebox("normal", "CheckButton", style_menu);
+ theme->set_stylebox("pressed", "CheckButton", style_menu);
+ theme->set_stylebox("disabled", "CheckButton", style_menu);
+ theme->set_stylebox("hover", "CheckButton", style_menu);
+
+ theme->set_icon("on", "CheckButton", theme->get_icon(SNAME("GuiToggleOn"), SNAME("EditorIcons")));
+ theme->set_icon("on_disabled", "CheckButton", theme->get_icon(SNAME("GuiToggleOnDisabled"), SNAME("EditorIcons")));
+ theme->set_icon("off", "CheckButton", theme->get_icon(SNAME("GuiToggleOff"), SNAME("EditorIcons")));
+ theme->set_icon("off_disabled", "CheckButton", theme->get_icon(SNAME("GuiToggleOffDisabled"), SNAME("EditorIcons")));
+
+ theme->set_icon("on_mirrored", "CheckButton", theme->get_icon(SNAME("GuiToggleOnMirrored"), SNAME("EditorIcons")));
+ theme->set_icon("on_disabled_mirrored", "CheckButton", theme->get_icon(SNAME("GuiToggleOnDisabledMirrored"), SNAME("EditorIcons")));
+ theme->set_icon("off_mirrored", "CheckButton", theme->get_icon(SNAME("GuiToggleOffMirrored"), SNAME("EditorIcons")));
+ theme->set_icon("off_disabled_mirrored", "CheckButton", theme->get_icon(SNAME("GuiToggleOffDisabledMirrored"), SNAME("EditorIcons")));
+
+ theme->set_color("font_color", "CheckButton", font_color);
+ theme->set_color("font_hover_color", "CheckButton", font_hover_color);
+ theme->set_color("font_focus_color", "CheckButton", font_focus_color);
+ theme->set_color("font_pressed_color", "CheckButton", accent_color);
+ theme->set_color("font_disabled_color", "CheckButton", font_disabled_color);
+ theme->set_color("icon_hover_color", "CheckButton", icon_hover_color);
+ theme->set_color("icon_focus_color", "CheckButton", icon_focus_color);
+
+ theme->set_constant("hseparation", "CheckButton", 8 * EDSCALE);
+ theme->set_constant("check_vadjust", "CheckButton", 0 * EDSCALE);
// Checkbox
Ref<StyleBoxFlat> sb_checkbox = style_menu->duplicate();
@@ -747,32 +747,32 @@ Ref<Theme> create_editor_theme(const Ref<Theme> p_theme) {
sb_checkbox->set_default_margin(SIDE_TOP, default_margin_size * EDSCALE);
sb_checkbox->set_default_margin(SIDE_BOTTOM, default_margin_size * EDSCALE);
- theme->set_stylebox(SNAME("normal"), SNAME("CheckBox"), sb_checkbox);
- theme->set_stylebox(SNAME("pressed"), SNAME("CheckBox"), sb_checkbox);
- theme->set_stylebox(SNAME("disabled"), SNAME("CheckBox"), sb_checkbox);
- theme->set_stylebox(SNAME("hover"), SNAME("CheckBox"), sb_checkbox);
- theme->set_icon(SNAME("checked"), SNAME("CheckBox"), theme->get_icon(SNAME("GuiChecked"), SNAME("EditorIcons")));
- theme->set_icon(SNAME("unchecked"), SNAME("CheckBox"), theme->get_icon(SNAME("GuiUnchecked"), SNAME("EditorIcons")));
- theme->set_icon(SNAME("radio_checked"), SNAME("CheckBox"), theme->get_icon(SNAME("GuiRadioChecked"), SNAME("EditorIcons")));
- theme->set_icon(SNAME("radio_unchecked"), SNAME("CheckBox"), theme->get_icon(SNAME("GuiRadioUnchecked"), SNAME("EditorIcons")));
- theme->set_icon(SNAME("checked_disabled"), SNAME("CheckBox"), theme->get_icon(SNAME("GuiCheckedDisabled"), SNAME("EditorIcons")));
- theme->set_icon(SNAME("unchecked_disabled"), SNAME("CheckBox"), theme->get_icon(SNAME("GuiUncheckedDisabled"), SNAME("EditorIcons")));
- theme->set_icon(SNAME("radio_checked_disabled"), SNAME("CheckBox"), theme->get_icon(SNAME("GuiRadioCheckedDisabled"), SNAME("EditorIcons")));
- theme->set_icon(SNAME("radio_unchecked_disabled"), SNAME("CheckBox"), theme->get_icon(SNAME("GuiRadioUncheckedDisabled"), SNAME("EditorIcons")));
-
- theme->set_color(SNAME("font_color"), SNAME("CheckBox"), font_color);
- theme->set_color(SNAME("font_hover_color"), SNAME("CheckBox"), font_hover_color);
- theme->set_color(SNAME("font_focus_color"), SNAME("CheckBox"), font_focus_color);
- theme->set_color(SNAME("font_pressed_color"), SNAME("CheckBox"), accent_color);
- theme->set_color(SNAME("font_disabled_color"), SNAME("CheckBox"), font_disabled_color);
- theme->set_color(SNAME("icon_hover_color"), SNAME("CheckBox"), icon_hover_color);
- theme->set_color(SNAME("icon_focus_color"), SNAME("CheckBox"), icon_focus_color);
-
- theme->set_constant(SNAME("hseparation"), SNAME("CheckBox"), 8 * EDSCALE);
- theme->set_constant(SNAME("check_vadjust"), SNAME("CheckBox"), 0 * EDSCALE);
+ theme->set_stylebox("normal", "CheckBox", sb_checkbox);
+ theme->set_stylebox("pressed", "CheckBox", sb_checkbox);
+ theme->set_stylebox("disabled", "CheckBox", sb_checkbox);
+ theme->set_stylebox("hover", "CheckBox", sb_checkbox);
+ theme->set_icon("checked", "CheckBox", theme->get_icon(SNAME("GuiChecked"), SNAME("EditorIcons")));
+ theme->set_icon("unchecked", "CheckBox", theme->get_icon(SNAME("GuiUnchecked"), SNAME("EditorIcons")));
+ theme->set_icon("radio_checked", "CheckBox", theme->get_icon(SNAME("GuiRadioChecked"), SNAME("EditorIcons")));
+ theme->set_icon("radio_unchecked", "CheckBox", theme->get_icon(SNAME("GuiRadioUnchecked"), SNAME("EditorIcons")));
+ theme->set_icon("checked_disabled", "CheckBox", theme->get_icon(SNAME("GuiCheckedDisabled"), SNAME("EditorIcons")));
+ theme->set_icon("unchecked_disabled", "CheckBox", theme->get_icon(SNAME("GuiUncheckedDisabled"), SNAME("EditorIcons")));
+ theme->set_icon("radio_checked_disabled", "CheckBox", theme->get_icon(SNAME("GuiRadioCheckedDisabled"), SNAME("EditorIcons")));
+ theme->set_icon("radio_unchecked_disabled", "CheckBox", theme->get_icon(SNAME("GuiRadioUncheckedDisabled"), SNAME("EditorIcons")));
+
+ theme->set_color("font_color", "CheckBox", font_color);
+ theme->set_color("font_hover_color", "CheckBox", font_hover_color);
+ theme->set_color("font_focus_color", "CheckBox", font_focus_color);
+ theme->set_color("font_pressed_color", "CheckBox", accent_color);
+ theme->set_color("font_disabled_color", "CheckBox", font_disabled_color);
+ theme->set_color("icon_hover_color", "CheckBox", icon_hover_color);
+ theme->set_color("icon_focus_color", "CheckBox", icon_focus_color);
+
+ theme->set_constant("hseparation", "CheckBox", 8 * EDSCALE);
+ theme->set_constant("check_vadjust", "CheckBox", 0 * EDSCALE);
// PopupDialog
- theme->set_stylebox(SNAME("panel"), SNAME("PopupDialog"), style_popup);
+ theme->set_stylebox("panel", "PopupDialog", style_popup);
// PopupMenu
const int popup_menu_margin_size = default_margin_size * 1.5 * EDSCALE;
@@ -787,39 +787,39 @@ Ref<Theme> create_editor_theme(const Ref<Theme> p_theme) {
// Always display a border for PopupMenus so they can be distinguished from their background.
style_popup_menu->set_border_width_all(1 * EDSCALE);
style_popup_menu->set_border_color(dark_color_2);
- theme->set_stylebox(SNAME("panel"), SNAME("PopupMenu"), style_popup_menu);
+ theme->set_stylebox("panel", "PopupMenu", style_popup_menu);
Ref<StyleBoxFlat> style_menu_hover = style_widget_hover->duplicate();
// Don't use rounded corners for hover highlights since the StyleBox touches the PopupMenu's edges.
style_menu_hover->set_corner_radius_all(0);
- theme->set_stylebox(SNAME("hover"), SNAME("PopupMenu"), style_menu_hover);
-
- theme->set_stylebox(SNAME("separator"), SNAME("PopupMenu"), style_popup_separator);
- theme->set_stylebox(SNAME("labeled_separator_left"), SNAME("PopupMenu"), style_popup_labeled_separator_left);
- theme->set_stylebox(SNAME("labeled_separator_right"), SNAME("PopupMenu"), style_popup_labeled_separator_right);
-
- theme->set_color(SNAME("font_color"), SNAME("PopupMenu"), font_color);
- theme->set_color(SNAME("font_hover_color"), SNAME("PopupMenu"), font_hover_color);
- theme->set_color(SNAME("font_accelerator_color"), SNAME("PopupMenu"), font_disabled_color);
- theme->set_color(SNAME("font_disabled_color"), SNAME("PopupMenu"), font_disabled_color);
- theme->set_color(SNAME("font_separator_color"), SNAME("PopupMenu"), font_disabled_color);
- theme->set_icon(SNAME("checked"), SNAME("PopupMenu"), theme->get_icon(SNAME("GuiChecked"), SNAME("EditorIcons")));
- theme->set_icon(SNAME("unchecked"), SNAME("PopupMenu"), theme->get_icon(SNAME("GuiUnchecked"), SNAME("EditorIcons")));
- theme->set_icon(SNAME("radio_checked"), SNAME("PopupMenu"), theme->get_icon(SNAME("GuiRadioChecked"), SNAME("EditorIcons")));
- theme->set_icon(SNAME("radio_unchecked"), SNAME("PopupMenu"), theme->get_icon(SNAME("GuiRadioUnchecked"), SNAME("EditorIcons")));
- theme->set_icon(SNAME("checked_disabled"), SNAME("PopupMenu"), theme->get_icon(SNAME("GuiCheckedDisabled"), SNAME("EditorIcons")));
- theme->set_icon(SNAME("unchecked_disabled"), SNAME("PopupMenu"), theme->get_icon(SNAME("GuiUncheckedDisabled"), SNAME("EditorIcons")));
- theme->set_icon(SNAME("radio_checked_disabled"), SNAME("PopupMenu"), theme->get_icon(SNAME("GuiRadioCheckedDisabled"), SNAME("EditorIcons")));
- theme->set_icon(SNAME("radio_unchecked_disabled"), SNAME("PopupMenu"), theme->get_icon(SNAME("GuiRadioUncheckedDisabled"), SNAME("EditorIcons")));
- theme->set_icon(SNAME("submenu"), SNAME("PopupMenu"), theme->get_icon(SNAME("ArrowRight"), SNAME("EditorIcons")));
- theme->set_icon(SNAME("submenu_mirrored"), SNAME("PopupMenu"), theme->get_icon(SNAME("ArrowLeft"), SNAME("EditorIcons")));
- theme->set_icon(SNAME("visibility_hidden"), SNAME("PopupMenu"), theme->get_icon(SNAME("GuiVisibilityHidden"), SNAME("EditorIcons")));
- theme->set_icon(SNAME("visibility_visible"), SNAME("PopupMenu"), theme->get_icon(SNAME("GuiVisibilityVisible"), SNAME("EditorIcons")));
- theme->set_icon(SNAME("visibility_xray"), SNAME("PopupMenu"), theme->get_icon(SNAME("GuiVisibilityXray"), SNAME("EditorIcons")));
-
- theme->set_constant(SNAME("vseparation"), SNAME("PopupMenu"), (extra_spacing + default_margin_size + 1) * EDSCALE);
- theme->set_constant(SNAME("item_start_padding"), SNAME("PopupMenu"), popup_menu_margin_size * EDSCALE);
- theme->set_constant(SNAME("item_end_padding"), SNAME("PopupMenu"), popup_menu_margin_size * EDSCALE);
+ theme->set_stylebox("hover", "PopupMenu", style_menu_hover);
+
+ theme->set_stylebox("separator", "PopupMenu", style_popup_separator);
+ theme->set_stylebox("labeled_separator_left", "PopupMenu", style_popup_labeled_separator_left);
+ theme->set_stylebox("labeled_separator_right", "PopupMenu", style_popup_labeled_separator_right);
+
+ theme->set_color("font_color", "PopupMenu", font_color);
+ theme->set_color("font_hover_color", "PopupMenu", font_hover_color);
+ theme->set_color("font_accelerator_color", "PopupMenu", font_disabled_color);
+ theme->set_color("font_disabled_color", "PopupMenu", font_disabled_color);
+ theme->set_color("font_separator_color", "PopupMenu", font_disabled_color);
+ theme->set_icon("checked", "PopupMenu", theme->get_icon(SNAME("GuiChecked"), SNAME("EditorIcons")));
+ theme->set_icon("unchecked", "PopupMenu", theme->get_icon(SNAME("GuiUnchecked"), SNAME("EditorIcons")));
+ theme->set_icon("radio_checked", "PopupMenu", theme->get_icon(SNAME("GuiRadioChecked"), SNAME("EditorIcons")));
+ theme->set_icon("radio_unchecked", "PopupMenu", theme->get_icon(SNAME("GuiRadioUnchecked"), SNAME("EditorIcons")));
+ theme->set_icon("checked_disabled", "PopupMenu", theme->get_icon(SNAME("GuiCheckedDisabled"), SNAME("EditorIcons")));
+ theme->set_icon("unchecked_disabled", "PopupMenu", theme->get_icon(SNAME("GuiUncheckedDisabled"), SNAME("EditorIcons")));
+ theme->set_icon("radio_checked_disabled", "PopupMenu", theme->get_icon(SNAME("GuiRadioCheckedDisabled"), SNAME("EditorIcons")));
+ theme->set_icon("radio_unchecked_disabled", "PopupMenu", theme->get_icon(SNAME("GuiRadioUncheckedDisabled"), SNAME("EditorIcons")));
+ theme->set_icon("submenu", "PopupMenu", theme->get_icon(SNAME("ArrowRight"), SNAME("EditorIcons")));
+ theme->set_icon("submenu_mirrored", "PopupMenu", theme->get_icon(SNAME("ArrowLeft"), SNAME("EditorIcons")));
+ theme->set_icon("visibility_hidden", "PopupMenu", theme->get_icon(SNAME("GuiVisibilityHidden"), SNAME("EditorIcons")));
+ theme->set_icon("visibility_visible", "PopupMenu", theme->get_icon(SNAME("GuiVisibilityVisible"), SNAME("EditorIcons")));
+ theme->set_icon("visibility_xray", "PopupMenu", theme->get_icon(SNAME("GuiVisibilityXray"), SNAME("EditorIcons")));
+
+ theme->set_constant("vseparation", "PopupMenu", (extra_spacing + default_margin_size + 1) * EDSCALE);
+ theme->set_constant("item_start_padding", "PopupMenu", popup_menu_margin_size * EDSCALE);
+ theme->set_constant("item_end_padding", "PopupMenu", popup_menu_margin_size * EDSCALE);
for (int i = 0; i < 16; i++) {
Color si_base_color = accent_color;
@@ -843,7 +843,7 @@ Ref<Theme> create_editor_theme(const Ref<Theme> p_theme) {
sub_inspector_bg->set_border_color(si_base_color * Color(0.7, 0.7, 0.7, 0.8));
sub_inspector_bg->set_draw_center(true);
- theme->set_stylebox("sub_inspector_bg" + itos(i), SNAME("Editor"), sub_inspector_bg);
+ theme->set_stylebox("sub_inspector_bg" + itos(i), "Editor", sub_inspector_bg);
Ref<StyleBoxFlat> bg_color;
bg_color.instantiate();
@@ -855,99 +855,99 @@ Ref<Theme> create_editor_theme(const Ref<Theme> p_theme) {
bg_color_selected->set_border_width_all(0);
bg_color_selected->set_bg_color(si_base_color * Color(0.8, 0.8, 0.8, 0.8));
- theme->set_stylebox("sub_inspector_property_bg" + itos(i), SNAME("Editor"), bg_color);
- theme->set_stylebox("sub_inspector_property_bg_selected" + itos(i), SNAME("Editor"), bg_color_selected);
+ theme->set_stylebox("sub_inspector_property_bg" + itos(i), "Editor", bg_color);
+ theme->set_stylebox("sub_inspector_property_bg_selected" + itos(i), "Editor", bg_color_selected);
}
- theme->set_color(SNAME("sub_inspector_property_color"), SNAME("Editor"), dark_theme ? Color(1, 1, 1, 1) : Color(0, 0, 0, 1));
- theme->set_constant(SNAME("sub_inspector_font_offset"), SNAME("Editor"), 4 * EDSCALE);
+ theme->set_color("sub_inspector_property_color", "Editor", dark_theme ? Color(1, 1, 1, 1) : Color(0, 0, 0, 1));
+ theme->set_constant("sub_inspector_font_offset", "Editor", 4 * EDSCALE);
Ref<StyleBoxFlat> style_property_bg = style_default->duplicate();
style_property_bg->set_bg_color(highlight_color);
style_property_bg->set_border_width_all(0);
- theme->set_constant(SNAME("font_offset"), SNAME("EditorProperty"), 8 * EDSCALE);
- theme->set_stylebox(SNAME("bg_selected"), SNAME("EditorProperty"), style_property_bg);
- theme->set_stylebox(SNAME("bg"), SNAME("EditorProperty"), Ref<StyleBoxEmpty>(memnew(StyleBoxEmpty)));
- theme->set_constant(SNAME("vseparation"), SNAME("EditorProperty"), (extra_spacing + default_margin_size) * EDSCALE);
- theme->set_color(SNAME("warning_color"), SNAME("EditorProperty"), warning_color);
- theme->set_color(SNAME("property_color"), SNAME("EditorProperty"), property_color);
- theme->set_color(SNAME("readonly_color"), SNAME("EditorProperty"), readonly_color);
- theme->set_color(SNAME("readonly_warning_color"), SNAME("EditorProperty"), readonly_warning_color);
+ theme->set_constant("font_offset", "EditorProperty", 8 * EDSCALE);
+ theme->set_stylebox("bg_selected", "EditorProperty", style_property_bg);
+ theme->set_stylebox("bg", "EditorProperty", Ref<StyleBoxEmpty>(memnew(StyleBoxEmpty)));
+ theme->set_constant("vseparation", "EditorProperty", (extra_spacing + default_margin_size) * EDSCALE);
+ theme->set_color("warning_color", "EditorProperty", warning_color);
+ theme->set_color("property_color", "EditorProperty", property_color);
+ theme->set_color("readonly_color", "EditorProperty", readonly_color);
+ theme->set_color("readonly_warning_color", "EditorProperty", readonly_warning_color);
Color inspector_section_color = font_color.lerp(Color(0.5, 0.5, 0.5), 0.35);
- theme->set_color(SNAME("font_color"), SNAME("EditorInspectorSection"), inspector_section_color);
+ theme->set_color("font_color", "EditorInspectorSection", inspector_section_color);
- theme->set_constant(SNAME("inspector_margin"), SNAME("Editor"), 12 * EDSCALE);
+ theme->set_constant("inspector_margin", "Editor", 12 * EDSCALE);
// Tree & ItemList background
Ref<StyleBoxFlat> style_tree_bg = style_default->duplicate();
// Make Trees easier to distinguish from other controls by using a darker background color.
style_tree_bg->set_bg_color(dark_color_1.lerp(dark_color_2, 0.5));
style_tree_bg->set_border_color(dark_color_3);
- theme->set_stylebox(SNAME("bg"), SNAME("Tree"), style_tree_bg);
+ theme->set_stylebox("bg", "Tree", style_tree_bg);
// Tree
- theme->set_icon(SNAME("checked"), SNAME("Tree"), theme->get_icon(SNAME("GuiChecked"), SNAME("EditorIcons")));
- theme->set_icon(SNAME("indeterminate"), SNAME("Tree"), theme->get_icon(SNAME("GuiIndeterminate"), SNAME("EditorIcons")));
- theme->set_icon(SNAME("unchecked"), SNAME("Tree"), theme->get_icon(SNAME("GuiUnchecked"), SNAME("EditorIcons")));
- theme->set_icon(SNAME("arrow"), SNAME("Tree"), theme->get_icon(SNAME("GuiTreeArrowDown"), SNAME("EditorIcons")));
- theme->set_icon(SNAME("arrow_collapsed"), SNAME("Tree"), theme->get_icon(SNAME("GuiTreeArrowRight"), SNAME("EditorIcons")));
- theme->set_icon(SNAME("arrow_collapsed_mirrored"), SNAME("Tree"), theme->get_icon(SNAME("GuiTreeArrowLeft"), SNAME("EditorIcons")));
- theme->set_icon(SNAME("updown"), SNAME("Tree"), theme->get_icon(SNAME("GuiTreeUpdown"), SNAME("EditorIcons")));
- theme->set_icon(SNAME("select_arrow"), SNAME("Tree"), theme->get_icon(SNAME("GuiDropdown"), SNAME("EditorIcons")));
- theme->set_stylebox(SNAME("bg_focus"), SNAME("Tree"), style_widget_focus);
- theme->set_stylebox(SNAME("custom_button"), SNAME("Tree"), make_empty_stylebox());
- theme->set_stylebox(SNAME("custom_button_pressed"), SNAME("Tree"), make_empty_stylebox());
- theme->set_stylebox(SNAME("custom_button_hover"), SNAME("Tree"), style_widget);
- theme->set_color(SNAME("custom_button_font_highlight"), SNAME("Tree"), font_hover_color);
- theme->set_color(SNAME("font_color"), SNAME("Tree"), font_color);
- theme->set_color(SNAME("font_selected_color"), SNAME("Tree"), mono_color);
- theme->set_color(SNAME("title_button_color"), SNAME("Tree"), font_color);
- theme->set_color(SNAME("drop_position_color"), SNAME("Tree"), accent_color);
- theme->set_constant(SNAME("vseparation"), SNAME("Tree"), widget_default_margin.y - EDSCALE);
- theme->set_constant(SNAME("hseparation"), SNAME("Tree"), 6 * EDSCALE);
- theme->set_constant(SNAME("guide_width"), SNAME("Tree"), border_width);
- theme->set_constant(SNAME("item_margin"), SNAME("Tree"), 3 * default_margin_size * EDSCALE);
- theme->set_constant(SNAME("button_margin"), SNAME("Tree"), default_margin_size * EDSCALE);
- theme->set_constant(SNAME("scroll_border"), SNAME("Tree"), 40 * EDSCALE);
- theme->set_constant(SNAME("scroll_speed"), SNAME("Tree"), 12);
+ theme->set_icon("checked", "Tree", theme->get_icon(SNAME("GuiChecked"), SNAME("EditorIcons")));
+ theme->set_icon("indeterminate", "Tree", theme->get_icon(SNAME("GuiIndeterminate"), SNAME("EditorIcons")));
+ theme->set_icon("unchecked", "Tree", theme->get_icon(SNAME("GuiUnchecked"), SNAME("EditorIcons")));
+ theme->set_icon("arrow", "Tree", theme->get_icon(SNAME("GuiTreeArrowDown"), SNAME("EditorIcons")));
+ theme->set_icon("arrow_collapsed", "Tree", theme->get_icon(SNAME("GuiTreeArrowRight"), SNAME("EditorIcons")));
+ theme->set_icon("arrow_collapsed_mirrored", "Tree", theme->get_icon(SNAME("GuiTreeArrowLeft"), SNAME("EditorIcons")));
+ theme->set_icon("updown", "Tree", theme->get_icon(SNAME("GuiTreeUpdown"), SNAME("EditorIcons")));
+ theme->set_icon("select_arrow", "Tree", theme->get_icon(SNAME("GuiDropdown"), SNAME("EditorIcons")));
+ theme->set_stylebox("bg_focus", "Tree", style_widget_focus);
+ theme->set_stylebox("custom_button", "Tree", make_empty_stylebox());
+ theme->set_stylebox("custom_button_pressed", "Tree", make_empty_stylebox());
+ theme->set_stylebox("custom_button_hover", "Tree", style_widget);
+ theme->set_color("custom_button_font_highlight", "Tree", font_hover_color);
+ theme->set_color("font_color", "Tree", font_color);
+ theme->set_color("font_selected_color", "Tree", mono_color);
+ theme->set_color("title_button_color", "Tree", font_color);
+ theme->set_color("drop_position_color", "Tree", accent_color);
+ theme->set_constant("vseparation", "Tree", widget_default_margin.y - EDSCALE);
+ theme->set_constant("hseparation", "Tree", 6 * EDSCALE);
+ theme->set_constant("guide_width", "Tree", border_width);
+ theme->set_constant("item_margin", "Tree", 3 * default_margin_size * EDSCALE);
+ theme->set_constant("button_margin", "Tree", default_margin_size * EDSCALE);
+ theme->set_constant("scroll_border", "Tree", 40 * EDSCALE);
+ theme->set_constant("scroll_speed", "Tree", 12);
const Color guide_color = mono_color * Color(1, 1, 1, 0.05);
Color relationship_line_color = mono_color * Color(1, 1, 1, relationship_line_opacity);
- theme->set_constant(SNAME("draw_guides"), SNAME("Tree"), relationship_line_opacity < 0.01);
- theme->set_color(SNAME("guide_color"), SNAME("Tree"), guide_color);
+ theme->set_constant("draw_guides", "Tree", relationship_line_opacity < 0.01);
+ theme->set_color("guide_color", "Tree", guide_color);
int relationship_line_width = 1;
Color parent_line_color = mono_color * Color(1, 1, 1, CLAMP(relationship_line_opacity + 0.45, 0.0, 1.0));
Color children_line_color = mono_color * Color(1, 1, 1, CLAMP(relationship_line_opacity + 0.25, 0.0, 1.0));
- theme->set_constant(SNAME("draw_relationship_lines"), SNAME("Tree"), relationship_line_opacity >= 0.01);
- theme->set_constant(SNAME("relationship_line_width"), SNAME("Tree"), relationship_line_width);
- theme->set_constant(SNAME("parent_hl_line_width"), SNAME("Tree"), relationship_line_width * 2);
- theme->set_constant(SNAME("children_hl_line_width"), SNAME("Tree"), relationship_line_width);
- theme->set_constant(SNAME("parent_hl_line_margin"), SNAME("Tree"), relationship_line_width * 3);
- theme->set_color(SNAME("relationship_line_color"), SNAME("Tree"), relationship_line_color);
- theme->set_color(SNAME("parent_hl_line_color"), SNAME("Tree"), parent_line_color);
- theme->set_color(SNAME("children_hl_line_color"), SNAME("Tree"), children_line_color);
+ theme->set_constant("draw_relationship_lines", "Tree", relationship_line_opacity >= 0.01);
+ theme->set_constant("relationship_line_width", "Tree", relationship_line_width);
+ theme->set_constant("parent_hl_line_width", "Tree", relationship_line_width * 2);
+ theme->set_constant("children_hl_line_width", "Tree", relationship_line_width);
+ theme->set_constant("parent_hl_line_margin", "Tree", relationship_line_width * 3);
+ theme->set_color("relationship_line_color", "Tree", relationship_line_color);
+ theme->set_color("parent_hl_line_color", "Tree", parent_line_color);
+ theme->set_color("children_hl_line_color", "Tree", children_line_color);
Ref<StyleBoxFlat> style_tree_btn = style_default->duplicate();
style_tree_btn->set_bg_color(highlight_color);
style_tree_btn->set_border_width_all(0);
- theme->set_stylebox(SNAME("button_pressed"), SNAME("Tree"), style_tree_btn);
+ theme->set_stylebox("button_pressed", "Tree", style_tree_btn);
Ref<StyleBoxFlat> style_tree_hover = style_default->duplicate();
style_tree_hover->set_bg_color(highlight_color * Color(1, 1, 1, 0.4));
style_tree_hover->set_border_width_all(0);
- theme->set_stylebox(SNAME("hover"), SNAME("Tree"), style_tree_hover);
+ theme->set_stylebox("hover", "Tree", style_tree_hover);
Ref<StyleBoxFlat> style_tree_focus = style_default->duplicate();
style_tree_focus->set_bg_color(highlight_color);
style_tree_focus->set_border_width_all(0);
- theme->set_stylebox(SNAME("selected_focus"), SNAME("Tree"), style_tree_focus);
+ theme->set_stylebox("selected_focus", "Tree", style_tree_focus);
Ref<StyleBoxFlat> style_tree_selected = style_tree_focus->duplicate();
- theme->set_stylebox(SNAME("selected"), SNAME("Tree"), style_tree_selected);
+ theme->set_stylebox("selected", "Tree", style_tree_selected);
Ref<StyleBoxFlat> style_tree_cursor = style_default->duplicate();
style_tree_cursor->set_draw_center(false);
@@ -957,25 +957,25 @@ Ref<Theme> create_editor_theme(const Ref<Theme> p_theme) {
Ref<StyleBoxFlat> style_tree_title = style_default->duplicate();
style_tree_title->set_bg_color(dark_color_3);
style_tree_title->set_border_width_all(0);
- theme->set_stylebox(SNAME("cursor"), SNAME("Tree"), style_tree_cursor);
- theme->set_stylebox(SNAME("cursor_unfocused"), SNAME("Tree"), style_tree_cursor);
- theme->set_stylebox(SNAME("title_button_normal"), SNAME("Tree"), style_tree_title);
- theme->set_stylebox(SNAME("title_button_hover"), SNAME("Tree"), style_tree_title);
- theme->set_stylebox(SNAME("title_button_pressed"), SNAME("Tree"), style_tree_title);
+ theme->set_stylebox("cursor", "Tree", style_tree_cursor);
+ theme->set_stylebox("cursor_unfocused", "Tree", style_tree_cursor);
+ theme->set_stylebox("title_button_normal", "Tree", style_tree_title);
+ theme->set_stylebox("title_button_hover", "Tree", style_tree_title);
+ theme->set_stylebox("title_button_pressed", "Tree", style_tree_title);
Color prop_category_color = dark_color_1.lerp(mono_color, 0.12);
Color prop_section_color = dark_color_1.lerp(mono_color, 0.09);
Color prop_subsection_color = dark_color_1.lerp(mono_color, 0.06);
- theme->set_color(SNAME("prop_category"), SNAME("Editor"), prop_category_color);
- theme->set_color(SNAME("prop_section"), SNAME("Editor"), prop_section_color);
- theme->set_color(SNAME("prop_subsection"), SNAME("Editor"), prop_subsection_color);
- theme->set_color(SNAME("drop_position_color"), SNAME("Tree"), accent_color);
+ theme->set_color("prop_category", "Editor", prop_category_color);
+ theme->set_color("prop_section", "Editor", prop_section_color);
+ theme->set_color("prop_subsection", "Editor", prop_subsection_color);
+ theme->set_color("drop_position_color", "Tree", accent_color);
Ref<StyleBoxFlat> category_bg = style_default->duplicate();
// Make Trees easier to distinguish from other controls by using a darker background color.
category_bg->set_bg_color(prop_category_color);
category_bg->set_border_color(prop_category_color);
- theme->set_stylebox(SNAME("prop_category_style"), SNAME("Editor"), category_bg);
+ theme->set_stylebox("prop_category_style", "Editor", category_bg);
// ItemList
Ref<StyleBoxFlat> style_itemlist_bg = style_default->duplicate();
@@ -987,47 +987,47 @@ Ref<Theme> create_editor_theme(const Ref<Theme> p_theme) {
style_itemlist_cursor->set_draw_center(false);
style_itemlist_cursor->set_border_width_all(border_width);
style_itemlist_cursor->set_border_color(highlight_color);
- theme->set_stylebox(SNAME("cursor"), SNAME("ItemList"), style_itemlist_cursor);
- theme->set_stylebox(SNAME("cursor_unfocused"), SNAME("ItemList"), style_itemlist_cursor);
- theme->set_stylebox(SNAME("selected_focus"), SNAME("ItemList"), style_tree_focus);
- theme->set_stylebox(SNAME("selected"), SNAME("ItemList"), style_tree_selected);
- theme->set_stylebox(SNAME("bg_focus"), SNAME("ItemList"), style_widget_focus);
- theme->set_stylebox(SNAME("bg"), SNAME("ItemList"), style_itemlist_bg);
- theme->set_color(SNAME("font_color"), SNAME("ItemList"), font_color);
- theme->set_color(SNAME("font_selected_color"), SNAME("ItemList"), mono_color);
- theme->set_color(SNAME("guide_color"), SNAME("ItemList"), guide_color);
- theme->set_constant(SNAME("vseparation"), SNAME("ItemList"), widget_default_margin.y - EDSCALE);
- theme->set_constant(SNAME("hseparation"), SNAME("ItemList"), 6 * EDSCALE);
- theme->set_constant(SNAME("icon_margin"), SNAME("ItemList"), 6 * EDSCALE);
- theme->set_constant(SNAME("line_separation"), SNAME("ItemList"), 3 * EDSCALE);
+ theme->set_stylebox("cursor", "ItemList", style_itemlist_cursor);
+ theme->set_stylebox("cursor_unfocused", "ItemList", style_itemlist_cursor);
+ theme->set_stylebox("selected_focus", "ItemList", style_tree_focus);
+ theme->set_stylebox("selected", "ItemList", style_tree_selected);
+ theme->set_stylebox("bg_focus", "ItemList", style_widget_focus);
+ theme->set_stylebox("bg", "ItemList", style_itemlist_bg);
+ theme->set_color("font_color", "ItemList", font_color);
+ theme->set_color("font_selected_color", "ItemList", mono_color);
+ theme->set_color("guide_color", "ItemList", guide_color);
+ theme->set_constant("vseparation", "ItemList", widget_default_margin.y - EDSCALE);
+ theme->set_constant("hseparation", "ItemList", 6 * EDSCALE);
+ theme->set_constant("icon_margin", "ItemList", 6 * EDSCALE);
+ theme->set_constant("line_separation", "ItemList", 3 * EDSCALE);
// TabBar & TabContainer
- theme->set_stylebox(SNAME("tab_selected"), SNAME("TabContainer"), style_tab_selected);
- theme->set_stylebox(SNAME("tab_unselected"), SNAME("TabContainer"), style_tab_unselected);
- theme->set_stylebox(SNAME("tab_disabled"), SNAME("TabContainer"), style_tab_disabled);
- theme->set_stylebox(SNAME("tab_selected"), SNAME("TabBar"), style_tab_selected);
- theme->set_stylebox(SNAME("tab_unselected"), SNAME("TabBar"), style_tab_unselected);
- theme->set_stylebox(SNAME("tab_disabled"), SNAME("TabBar"), style_tab_disabled);
- theme->set_color(SNAME("font_selected_color"), SNAME("TabContainer"), font_color);
- theme->set_color(SNAME("font_unselected_color"), SNAME("TabContainer"), font_disabled_color);
- theme->set_color(SNAME("font_selected_color"), SNAME("TabBar"), font_color);
- theme->set_color(SNAME("font_unselected_color"), SNAME("TabBar"), font_disabled_color);
- theme->set_icon(SNAME("menu"), SNAME("TabContainer"), theme->get_icon(SNAME("GuiTabMenu"), SNAME("EditorIcons")));
- theme->set_icon(SNAME("menu_highlight"), SNAME("TabContainer"), theme->get_icon(SNAME("GuiTabMenuHl"), SNAME("EditorIcons")));
- theme->set_stylebox(SNAME("SceneTabFG"), SNAME("EditorStyles"), style_tab_selected);
- theme->set_stylebox(SNAME("SceneTabBG"), SNAME("EditorStyles"), style_tab_unselected);
- theme->set_icon(SNAME("close"), SNAME("TabBar"), theme->get_icon(SNAME("GuiClose"), SNAME("EditorIcons")));
- theme->set_stylebox(SNAME("button_pressed"), SNAME("TabBar"), style_menu);
- theme->set_stylebox(SNAME("button_highlight"), SNAME("TabBar"), style_menu);
- theme->set_icon(SNAME("increment"), SNAME("TabContainer"), theme->get_icon(SNAME("GuiScrollArrowRight"), SNAME("EditorIcons")));
- theme->set_icon(SNAME("decrement"), SNAME("TabContainer"), theme->get_icon(SNAME("GuiScrollArrowLeft"), SNAME("EditorIcons")));
- theme->set_icon(SNAME("increment"), SNAME("TabBar"), theme->get_icon(SNAME("GuiScrollArrowRight"), SNAME("EditorIcons")));
- theme->set_icon(SNAME("decrement"), SNAME("TabBar"), theme->get_icon(SNAME("GuiScrollArrowLeft"), SNAME("EditorIcons")));
- theme->set_icon(SNAME("increment_highlight"), SNAME("TabBar"), theme->get_icon(SNAME("GuiScrollArrowRightHl"), SNAME("EditorIcons")));
- theme->set_icon(SNAME("decrement_highlight"), SNAME("TabBar"), theme->get_icon(SNAME("GuiScrollArrowLeftHl"), SNAME("EditorIcons")));
- theme->set_icon(SNAME("increment_highlight"), SNAME("TabContainer"), theme->get_icon(SNAME("GuiScrollArrowRightHl"), SNAME("EditorIcons")));
- theme->set_icon(SNAME("decrement_highlight"), SNAME("TabContainer"), theme->get_icon(SNAME("GuiScrollArrowLeftHl"), SNAME("EditorIcons")));
- theme->set_constant(SNAME("hseparation"), SNAME("TabBar"), 4 * EDSCALE);
+ theme->set_stylebox("tab_selected", "TabContainer", style_tab_selected);
+ theme->set_stylebox("tab_unselected", "TabContainer", style_tab_unselected);
+ theme->set_stylebox("tab_disabled", "TabContainer", style_tab_disabled);
+ theme->set_stylebox("tab_selected", "TabBar", style_tab_selected);
+ theme->set_stylebox("tab_unselected", "TabBar", style_tab_unselected);
+ theme->set_stylebox("tab_disabled", "TabBar", style_tab_disabled);
+ theme->set_color("font_selected_color", "TabContainer", font_color);
+ theme->set_color("font_unselected_color", "TabContainer", font_disabled_color);
+ theme->set_color("font_selected_color", "TabBar", font_color);
+ theme->set_color("font_unselected_color", "TabBar", font_disabled_color);
+ theme->set_icon("menu", "TabContainer", theme->get_icon(SNAME("GuiTabMenu"), SNAME("EditorIcons")));
+ theme->set_icon("menu_highlight", "TabContainer", theme->get_icon(SNAME("GuiTabMenuHl"), SNAME("EditorIcons")));
+ theme->set_stylebox("SceneTabFG", "EditorStyles", style_tab_selected);
+ theme->set_stylebox("SceneTabBG", "EditorStyles", style_tab_unselected);
+ theme->set_icon("close", "TabBar", theme->get_icon(SNAME("GuiClose"), SNAME("EditorIcons")));
+ theme->set_stylebox("button_pressed", "TabBar", style_menu);
+ theme->set_stylebox("button_highlight", "TabBar", style_menu);
+ theme->set_icon("increment", "TabContainer", theme->get_icon(SNAME("GuiScrollArrowRight"), SNAME("EditorIcons")));
+ theme->set_icon("decrement", "TabContainer", theme->get_icon(SNAME("GuiScrollArrowLeft"), SNAME("EditorIcons")));
+ theme->set_icon("increment", "TabBar", theme->get_icon(SNAME("GuiScrollArrowRight"), SNAME("EditorIcons")));
+ theme->set_icon("decrement", "TabBar", theme->get_icon(SNAME("GuiScrollArrowLeft"), SNAME("EditorIcons")));
+ theme->set_icon("increment_highlight", "TabBar", theme->get_icon(SNAME("GuiScrollArrowRightHl"), SNAME("EditorIcons")));
+ theme->set_icon("decrement_highlight", "TabBar", theme->get_icon(SNAME("GuiScrollArrowLeftHl"), SNAME("EditorIcons")));
+ theme->set_icon("increment_highlight", "TabContainer", theme->get_icon(SNAME("GuiScrollArrowRightHl"), SNAME("EditorIcons")));
+ theme->set_icon("decrement_highlight", "TabContainer", theme->get_icon(SNAME("GuiScrollArrowLeftHl"), SNAME("EditorIcons")));
+ theme->set_constant("hseparation", "TabBar", 4 * EDSCALE);
// Content of each tab
Ref<StyleBoxFlat> style_content_panel = style_default->duplicate();
@@ -1041,16 +1041,16 @@ Ref<Theme> create_editor_theme(const Ref<Theme> p_theme) {
// Display border to visually split the body of the container from its possible backgrounds.
style_content_panel->set_border_width(Side::SIDE_TOP, Math::round(2 * EDSCALE));
style_content_panel->set_border_color(dark_color_2);
- theme->set_stylebox(SNAME("panel"), SNAME("TabContainer"), style_content_panel);
+ theme->set_stylebox("panel", "TabContainer", style_content_panel);
// These styleboxes can be used on tabs against the base color background (e.g. nested tabs).
Ref<StyleBoxFlat> style_tab_selected_odd = style_tab_selected->duplicate();
style_tab_selected_odd->set_bg_color(disabled_bg_color);
- theme->set_stylebox(SNAME("tab_selected_odd"), SNAME("TabContainer"), style_tab_selected_odd);
+ theme->set_stylebox("tab_selected_odd", "TabContainer", style_tab_selected_odd);
Ref<StyleBoxFlat> style_content_panel_odd = style_content_panel->duplicate();
style_content_panel_odd->set_bg_color(disabled_bg_color);
- theme->set_stylebox(SNAME("panel_odd"), SNAME("TabContainer"), style_content_panel_odd);
+ theme->set_stylebox("panel_odd", "TabContainer", style_content_panel_odd);
// This stylebox is used in 3d and 2d viewports (no borders).
Ref<StyleBoxFlat> style_content_panel_vp = style_content_panel->duplicate();
@@ -1058,31 +1058,31 @@ Ref<Theme> create_editor_theme(const Ref<Theme> p_theme) {
style_content_panel_vp->set_default_margin(SIDE_TOP, default_margin_size * EDSCALE);
style_content_panel_vp->set_default_margin(SIDE_RIGHT, border_width * 2);
style_content_panel_vp->set_default_margin(SIDE_BOTTOM, border_width * 2);
- theme->set_stylebox(SNAME("Content"), SNAME("EditorStyles"), style_content_panel_vp);
+ theme->set_stylebox("Content", "EditorStyles", style_content_panel_vp);
// This stylebox is used by preview tabs in the Theme Editor.
Ref<StyleBoxFlat> style_theme_preview_tab = style_tab_selected_odd->duplicate();
style_theme_preview_tab->set_expand_margin_size(SIDE_BOTTOM, 5 * EDSCALE);
- theme->set_stylebox(SNAME("ThemeEditorPreviewFG"), SNAME("EditorStyles"), style_theme_preview_tab);
+ theme->set_stylebox("ThemeEditorPreviewFG", "EditorStyles", style_theme_preview_tab);
Ref<StyleBoxFlat> style_theme_preview_bg_tab = style_tab_unselected->duplicate();
style_theme_preview_bg_tab->set_expand_margin_size(SIDE_BOTTOM, 2 * EDSCALE);
- theme->set_stylebox(SNAME("ThemeEditorPreviewBG"), SNAME("EditorStyles"), style_theme_preview_bg_tab);
+ theme->set_stylebox("ThemeEditorPreviewBG", "EditorStyles", style_theme_preview_bg_tab);
// Separators
- theme->set_stylebox(SNAME("separator"), SNAME("HSeparator"), make_line_stylebox(separator_color, MAX(Math::round(EDSCALE), border_width)));
- theme->set_stylebox(SNAME("separator"), SNAME("VSeparator"), make_line_stylebox(separator_color, MAX(Math::round(EDSCALE), border_width), 0, 0, true));
+ theme->set_stylebox("separator", "HSeparator", make_line_stylebox(separator_color, MAX(Math::round(EDSCALE), border_width)));
+ theme->set_stylebox("separator", "VSeparator", make_line_stylebox(separator_color, MAX(Math::round(EDSCALE), border_width), 0, 0, true));
// Debugger
Ref<StyleBoxFlat> style_panel_debugger = style_content_panel->duplicate();
style_panel_debugger->set_border_width(SIDE_BOTTOM, 0);
- theme->set_stylebox(SNAME("DebuggerPanel"), SNAME("EditorStyles"), style_panel_debugger);
+ theme->set_stylebox("DebuggerPanel", "EditorStyles", style_panel_debugger);
Ref<StyleBoxFlat> style_panel_invisible_top = style_content_panel->duplicate();
int stylebox_offset = theme->get_font(SNAME("tab_selected"), SNAME("TabContainer"))->get_height(theme->get_font_size(SNAME("tab_selected"), SNAME("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(SNAME("BottomPanelDebuggerOverride"), SNAME("EditorStyles"), style_panel_invisible_top);
+ theme->set_stylebox("BottomPanelDebuggerOverride", "EditorStyles", style_panel_invisible_top);
// LineEdit
@@ -1102,74 +1102,74 @@ Ref<Theme> create_editor_theme(const Ref<Theme> p_theme) {
style_line_edit_disabled->set_border_color(disabled_color);
style_line_edit_disabled->set_bg_color(disabled_bg_color);
- theme->set_stylebox(SNAME("normal"), SNAME("LineEdit"), style_line_edit);
- theme->set_stylebox(SNAME("focus"), SNAME("LineEdit"), style_widget_focus);
- theme->set_stylebox(SNAME("read_only"), SNAME("LineEdit"), style_line_edit_disabled);
- theme->set_icon(SNAME("clear"), SNAME("LineEdit"), theme->get_icon(SNAME("GuiClose"), SNAME("EditorIcons")));
- theme->set_color(SNAME("read_only"), SNAME("LineEdit"), font_disabled_color);
- theme->set_color(SNAME("font_color"), SNAME("LineEdit"), font_color);
- theme->set_color(SNAME("font_selected_color"), SNAME("LineEdit"), mono_color);
- theme->set_color(SNAME("font_uneditable_color"), SNAME("LineEdit"), font_readonly_color);
- theme->set_color(SNAME("font_placeholder_color"), SNAME("LineEdit"), font_placeholder_color);
- theme->set_color(SNAME("caret_color"), SNAME("LineEdit"), font_color);
- theme->set_color(SNAME("selection_color"), SNAME("LineEdit"), selection_color);
- theme->set_color(SNAME("clear_button_color"), SNAME("LineEdit"), font_color);
- theme->set_color(SNAME("clear_button_color_pressed"), SNAME("LineEdit"), accent_color);
+ theme->set_stylebox("normal", "LineEdit", style_line_edit);
+ theme->set_stylebox("focus", "LineEdit", style_widget_focus);
+ theme->set_stylebox("read_only", "LineEdit", style_line_edit_disabled);
+ theme->set_icon("clear", "LineEdit", theme->get_icon(SNAME("GuiClose"), SNAME("EditorIcons")));
+ 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("font_placeholder_color", "LineEdit", font_placeholder_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);
+ theme->set_color("clear_button_color_pressed", "LineEdit", accent_color);
// TextEdit
- theme->set_stylebox(SNAME("normal"), SNAME("TextEdit"), style_line_edit);
- theme->set_stylebox(SNAME("focus"), SNAME("TextEdit"), style_widget_focus);
- theme->set_stylebox(SNAME("read_only"), SNAME("TextEdit"), style_line_edit_disabled);
- theme->set_constant(SNAME("side_margin"), SNAME("TabContainer"), 0);
- theme->set_icon(SNAME("tab"), SNAME("TextEdit"), theme->get_icon(SNAME("GuiTab"), SNAME("EditorIcons")));
- theme->set_icon(SNAME("space"), SNAME("TextEdit"), theme->get_icon(SNAME("GuiSpace"), SNAME("EditorIcons")));
- theme->set_color(SNAME("font_color"), SNAME("TextEdit"), font_color);
- theme->set_color(SNAME("font_readonly_color"), SNAME("TextEdit"), font_readonly_color);
- theme->set_color(SNAME("font_placeholder_color"), SNAME("TextEdit"), font_placeholder_color);
- theme->set_color(SNAME("caret_color"), SNAME("TextEdit"), font_color);
- theme->set_color(SNAME("selection_color"), SNAME("TextEdit"), selection_color);
- theme->set_constant(SNAME("line_spacing"), SNAME("TextEdit"), 4 * EDSCALE);
+ theme->set_stylebox("normal", "TextEdit", style_line_edit);
+ theme->set_stylebox("focus", "TextEdit", style_widget_focus);
+ theme->set_stylebox("read_only", "TextEdit", style_line_edit_disabled);
+ theme->set_constant("side_margin", "TabContainer", 0);
+ theme->set_icon("tab", "TextEdit", theme->get_icon(SNAME("GuiTab"), SNAME("EditorIcons")));
+ theme->set_icon("space", "TextEdit", theme->get_icon(SNAME("GuiSpace"), SNAME("EditorIcons")));
+ theme->set_color("font_color", "TextEdit", font_color);
+ theme->set_color("font_readonly_color", "TextEdit", font_readonly_color);
+ theme->set_color("font_placeholder_color", "TextEdit", font_placeholder_color);
+ theme->set_color("caret_color", "TextEdit", font_color);
+ theme->set_color("selection_color", "TextEdit", selection_color);
+ theme->set_constant("line_spacing", "TextEdit", 4 * EDSCALE);
// CodeEdit
- theme->set_font(SNAME("font"), SNAME("CodeEdit"), theme->get_font(SNAME("source"), SNAME("EditorFonts")));
- theme->set_font_size(SNAME("font_size"), SNAME("CodeEdit"), theme->get_font_size(SNAME("source_size"), SNAME("EditorFonts")));
- theme->set_stylebox(SNAME("normal"), SNAME("CodeEdit"), style_widget);
- theme->set_stylebox(SNAME("focus"), SNAME("CodeEdit"), style_widget_hover);
- theme->set_stylebox(SNAME("read_only"), SNAME("CodeEdit"), style_widget_disabled);
- theme->set_icon(SNAME("tab"), SNAME("CodeEdit"), theme->get_icon(SNAME("GuiTab"), SNAME("EditorIcons")));
- theme->set_icon(SNAME("space"), SNAME("CodeEdit"), theme->get_icon(SNAME("GuiSpace"), SNAME("EditorIcons")));
- theme->set_icon(SNAME("folded"), SNAME("CodeEdit"), theme->get_icon(SNAME("GuiTreeArrowRight"), SNAME("EditorIcons")));
- theme->set_icon(SNAME("can_fold"), SNAME("CodeEdit"), theme->get_icon(SNAME("GuiTreeArrowDown"), SNAME("EditorIcons")));
- theme->set_icon(SNAME("executing_line"), SNAME("CodeEdit"), theme->get_icon(SNAME("MainPlay"), SNAME("EditorIcons")));
- theme->set_icon(SNAME("breakpoint"), SNAME("CodeEdit"), theme->get_icon(SNAME("Breakpoint"), SNAME("EditorIcons")));
- theme->set_constant(SNAME("line_spacing"), SNAME("CodeEdit"), EDITOR_DEF("text_editor/appearance/whitespace/line_spacing", 6));
+ theme->set_font("font", "CodeEdit", theme->get_font(SNAME("source"), SNAME("EditorFonts")));
+ theme->set_font_size("font_size", "CodeEdit", theme->get_font_size(SNAME("source_size"), SNAME("EditorFonts")));
+ theme->set_stylebox("normal", "CodeEdit", style_widget);
+ theme->set_stylebox("focus", "CodeEdit", style_widget_hover);
+ theme->set_stylebox("read_only", "CodeEdit", style_widget_disabled);
+ theme->set_icon("tab", "CodeEdit", theme->get_icon(SNAME("GuiTab"), SNAME("EditorIcons")));
+ theme->set_icon("space", "CodeEdit", theme->get_icon(SNAME("GuiSpace"), SNAME("EditorIcons")));
+ theme->set_icon("folded", "CodeEdit", theme->get_icon(SNAME("GuiTreeArrowRight"), SNAME("EditorIcons")));
+ theme->set_icon("can_fold", "CodeEdit", theme->get_icon(SNAME("GuiTreeArrowDown"), SNAME("EditorIcons")));
+ theme->set_icon("executing_line", "CodeEdit", theme->get_icon(SNAME("MainPlay"), SNAME("EditorIcons")));
+ theme->set_icon("breakpoint", "CodeEdit", theme->get_icon(SNAME("Breakpoint"), SNAME("EditorIcons")));
+ theme->set_constant("line_spacing", "CodeEdit", EDITOR_DEF("text_editor/appearance/whitespace/line_spacing", 6));
// H/VSplitContainer
- theme->set_stylebox(SNAME("bg"), SNAME("VSplitContainer"), make_stylebox(theme->get_icon(SNAME("GuiVsplitBg"), SNAME("EditorIcons")), 1, 1, 1, 1));
- theme->set_stylebox(SNAME("bg"), SNAME("HSplitContainer"), make_stylebox(theme->get_icon(SNAME("GuiHsplitBg"), SNAME("EditorIcons")), 1, 1, 1, 1));
+ theme->set_stylebox("bg", "VSplitContainer", make_stylebox(theme->get_icon(SNAME("GuiVsplitBg"), SNAME("EditorIcons")), 1, 1, 1, 1));
+ theme->set_stylebox("bg", "HSplitContainer", make_stylebox(theme->get_icon(SNAME("GuiHsplitBg"), SNAME("EditorIcons")), 1, 1, 1, 1));
- theme->set_icon(SNAME("grabber"), SNAME("VSplitContainer"), theme->get_icon(SNAME("GuiVsplitter"), SNAME("EditorIcons")));
- theme->set_icon(SNAME("grabber"), SNAME("HSplitContainer"), theme->get_icon(SNAME("GuiHsplitter"), SNAME("EditorIcons")));
+ theme->set_icon("grabber", "VSplitContainer", theme->get_icon(SNAME("GuiVsplitter"), SNAME("EditorIcons")));
+ theme->set_icon("grabber", "HSplitContainer", theme->get_icon(SNAME("GuiHsplitter"), SNAME("EditorIcons")));
- theme->set_constant(SNAME("separation"), SNAME("HSplitContainer"), default_margin_size * 2 * EDSCALE);
- theme->set_constant(SNAME("separation"), SNAME("VSplitContainer"), default_margin_size * 2 * EDSCALE);
+ theme->set_constant("separation", "HSplitContainer", default_margin_size * 2 * EDSCALE);
+ theme->set_constant("separation", "VSplitContainer", default_margin_size * 2 * EDSCALE);
// Containers
- theme->set_constant(SNAME("separation"), SNAME("BoxContainer"), default_margin_size * EDSCALE);
- theme->set_constant(SNAME("separation"), SNAME("HBoxContainer"), default_margin_size * EDSCALE);
- theme->set_constant(SNAME("separation"), SNAME("VBoxContainer"), default_margin_size * EDSCALE);
- theme->set_constant(SNAME("margin_left"), SNAME("MarginContainer"), 0);
- theme->set_constant(SNAME("margin_top"), SNAME("MarginContainer"), 0);
- theme->set_constant(SNAME("margin_right"), SNAME("MarginContainer"), 0);
- theme->set_constant(SNAME("margin_bottom"), SNAME("MarginContainer"), 0);
- theme->set_constant(SNAME("hseparation"), SNAME("GridContainer"), default_margin_size * EDSCALE);
- theme->set_constant(SNAME("vseparation"), SNAME("GridContainer"), default_margin_size * EDSCALE);
- theme->set_constant(SNAME("hseparation"), SNAME("FlowContainer"), default_margin_size * EDSCALE);
- theme->set_constant(SNAME("vseparation"), SNAME("FlowContainer"), default_margin_size * EDSCALE);
- theme->set_constant(SNAME("hseparation"), SNAME("HFlowContainer"), default_margin_size * EDSCALE);
- theme->set_constant(SNAME("vseparation"), SNAME("HFlowContainer"), default_margin_size * EDSCALE);
- theme->set_constant(SNAME("hseparation"), SNAME("VFlowContainer"), default_margin_size * EDSCALE);
- theme->set_constant(SNAME("vseparation"), SNAME("VFlowContainer"), default_margin_size * EDSCALE);
+ theme->set_constant("separation", "BoxContainer", default_margin_size * EDSCALE);
+ theme->set_constant("separation", "HBoxContainer", default_margin_size * EDSCALE);
+ theme->set_constant("separation", "VBoxContainer", default_margin_size * EDSCALE);
+ theme->set_constant("margin_left", "MarginContainer", 0);
+ theme->set_constant("margin_top", "MarginContainer", 0);
+ theme->set_constant("margin_right", "MarginContainer", 0);
+ theme->set_constant("margin_bottom", "MarginContainer", 0);
+ theme->set_constant("hseparation", "GridContainer", default_margin_size * EDSCALE);
+ theme->set_constant("vseparation", "GridContainer", default_margin_size * EDSCALE);
+ theme->set_constant("hseparation", "FlowContainer", default_margin_size * EDSCALE);
+ theme->set_constant("vseparation", "FlowContainer", default_margin_size * EDSCALE);
+ theme->set_constant("hseparation", "HFlowContainer", default_margin_size * EDSCALE);
+ theme->set_constant("vseparation", "HFlowContainer", default_margin_size * EDSCALE);
+ theme->set_constant("hseparation", "VFlowContainer", default_margin_size * EDSCALE);
+ theme->set_constant("vseparation", "VFlowContainer", default_margin_size * EDSCALE);
// Window
@@ -1184,119 +1184,119 @@ Ref<Theme> create_editor_theme(const Ref<Theme> p_theme) {
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(SNAME("embedded_border"), SNAME("Window"), style_window);
-
- theme->set_color(SNAME("title_color"), SNAME("Window"), font_color);
- theme->set_icon(SNAME("close"), SNAME("Window"), theme->get_icon(SNAME("GuiClose"), SNAME("EditorIcons")));
- theme->set_icon(SNAME("close_pressed"), SNAME("Window"), theme->get_icon(SNAME("GuiClose"), SNAME("EditorIcons")));
- theme->set_constant(SNAME("close_h_ofs"), SNAME("Window"), 22 * EDSCALE);
- theme->set_constant(SNAME("close_v_ofs"), SNAME("Window"), 20 * EDSCALE);
- theme->set_constant(SNAME("title_height"), SNAME("Window"), 24 * EDSCALE);
- theme->set_constant(SNAME("resize_margin"), SNAME("Window"), 4 * EDSCALE);
- theme->set_font(SNAME("title_font"), SNAME("Window"), theme->get_font(SNAME("title"), SNAME("EditorFonts")));
- theme->set_font_size(SNAME("title_font_size"), SNAME("Window"), theme->get_font_size(SNAME("title_size"), SNAME("EditorFonts")));
+ theme->set_stylebox("embedded_border", "Window", style_window);
+
+ theme->set_color("title_color", "Window", font_color);
+ theme->set_icon("close", "Window", theme->get_icon(SNAME("GuiClose"), SNAME("EditorIcons")));
+ theme->set_icon("close_pressed", "Window", theme->get_icon(SNAME("GuiClose"), SNAME("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);
+ theme->set_constant("resize_margin", "Window", 4 * EDSCALE);
+ theme->set_font("title_font", "Window", theme->get_font(SNAME("title"), SNAME("EditorFonts")));
+ theme->set_font_size("title_font_size", "Window", theme->get_font_size(SNAME("title_size"), SNAME("EditorFonts")));
// Complex window (currently only Editor Settings and Project Settings)
Ref<StyleBoxFlat> style_complex_window = style_window->duplicate();
style_complex_window->set_bg_color(dark_color_2);
style_complex_window->set_border_color(dark_color_2);
- theme->set_stylebox(SNAME("panel"), SNAME("EditorSettingsDialog"), style_complex_window);
- theme->set_stylebox(SNAME("panel"), SNAME("ProjectSettingsEditor"), style_complex_window);
- theme->set_stylebox(SNAME("panel"), SNAME("EditorAbout"), style_complex_window);
+ theme->set_stylebox("panel", "EditorSettingsDialog", style_complex_window);
+ theme->set_stylebox("panel", "ProjectSettingsEditor", style_complex_window);
+ theme->set_stylebox("panel", "EditorAbout", style_complex_window);
// AcceptDialog
- theme->set_stylebox(SNAME("panel"), SNAME("AcceptDialog"), style_window_title);
+ theme->set_stylebox("panel", "AcceptDialog", style_window_title);
// HScrollBar
Ref<Texture2D> empty_icon = memnew(ImageTexture);
- theme->set_stylebox(SNAME("scroll"), SNAME("HScrollBar"), make_stylebox(theme->get_icon(SNAME("GuiScrollBg"), SNAME("EditorIcons")), 5, 5, 5, 5, 0, 0, 0, 0));
- theme->set_stylebox(SNAME("scroll_focus"), SNAME("HScrollBar"), make_stylebox(theme->get_icon(SNAME("GuiScrollBg"), SNAME("EditorIcons")), 5, 5, 5, 5, 0, 0, 0, 0));
- theme->set_stylebox(SNAME("grabber"), SNAME("HScrollBar"), make_stylebox(theme->get_icon(SNAME("GuiScrollGrabber"), SNAME("EditorIcons")), 6, 6, 6, 6, 2, 2, 2, 2));
- theme->set_stylebox(SNAME("grabber_highlight"), SNAME("HScrollBar"), make_stylebox(theme->get_icon(SNAME("GuiScrollGrabberHl"), SNAME("EditorIcons")), 5, 5, 5, 5, 2, 2, 2, 2));
- theme->set_stylebox(SNAME("grabber_pressed"), SNAME("HScrollBar"), make_stylebox(theme->get_icon(SNAME("GuiScrollGrabberPressed"), SNAME("EditorIcons")), 6, 6, 6, 6, 2, 2, 2, 2));
+ theme->set_stylebox("scroll", "HScrollBar", make_stylebox(theme->get_icon(SNAME("GuiScrollBg"), SNAME("EditorIcons")), 5, 5, 5, 5, 0, 0, 0, 0));
+ theme->set_stylebox("scroll_focus", "HScrollBar", make_stylebox(theme->get_icon(SNAME("GuiScrollBg"), SNAME("EditorIcons")), 5, 5, 5, 5, 0, 0, 0, 0));
+ theme->set_stylebox("grabber", "HScrollBar", make_stylebox(theme->get_icon(SNAME("GuiScrollGrabber"), SNAME("EditorIcons")), 6, 6, 6, 6, 2, 2, 2, 2));
+ theme->set_stylebox("grabber_highlight", "HScrollBar", make_stylebox(theme->get_icon(SNAME("GuiScrollGrabberHl"), SNAME("EditorIcons")), 5, 5, 5, 5, 2, 2, 2, 2));
+ theme->set_stylebox("grabber_pressed", "HScrollBar", make_stylebox(theme->get_icon(SNAME("GuiScrollGrabberPressed"), SNAME("EditorIcons")), 6, 6, 6, 6, 2, 2, 2, 2));
- theme->set_icon(SNAME("increment"), SNAME("HScrollBar"), empty_icon);
- theme->set_icon(SNAME("increment_highlight"), SNAME("HScrollBar"), empty_icon);
- theme->set_icon(SNAME("increment_pressed"), SNAME("HScrollBar"), empty_icon);
- theme->set_icon(SNAME("decrement"), SNAME("HScrollBar"), empty_icon);
- theme->set_icon(SNAME("decrement_highlight"), SNAME("HScrollBar"), empty_icon);
- theme->set_icon(SNAME("decrement_pressed"), SNAME("HScrollBar"), empty_icon);
+ theme->set_icon("increment", "HScrollBar", empty_icon);
+ theme->set_icon("increment_highlight", "HScrollBar", empty_icon);
+ theme->set_icon("increment_pressed", "HScrollBar", empty_icon);
+ theme->set_icon("decrement", "HScrollBar", empty_icon);
+ theme->set_icon("decrement_highlight", "HScrollBar", empty_icon);
+ theme->set_icon("decrement_pressed", "HScrollBar", empty_icon);
// VScrollBar
- theme->set_stylebox(SNAME("scroll"), SNAME("VScrollBar"), make_stylebox(theme->get_icon(SNAME("GuiScrollBg"), SNAME("EditorIcons")), 5, 5, 5, 5, 0, 0, 0, 0));
- theme->set_stylebox(SNAME("scroll_focus"), SNAME("VScrollBar"), make_stylebox(theme->get_icon(SNAME("GuiScrollBg"), SNAME("EditorIcons")), 5, 5, 5, 5, 0, 0, 0, 0));
- theme->set_stylebox(SNAME("grabber"), SNAME("VScrollBar"), make_stylebox(theme->get_icon(SNAME("GuiScrollGrabber"), SNAME("EditorIcons")), 6, 6, 6, 6, 2, 2, 2, 2));
- theme->set_stylebox(SNAME("grabber_highlight"), SNAME("VScrollBar"), make_stylebox(theme->get_icon(SNAME("GuiScrollGrabberHl"), SNAME("EditorIcons")), 5, 5, 5, 5, 2, 2, 2, 2));
- theme->set_stylebox(SNAME("grabber_pressed"), SNAME("VScrollBar"), make_stylebox(theme->get_icon(SNAME("GuiScrollGrabberPressed"), SNAME("EditorIcons")), 6, 6, 6, 6, 2, 2, 2, 2));
-
- theme->set_icon(SNAME("increment"), SNAME("VScrollBar"), empty_icon);
- theme->set_icon(SNAME("increment_highlight"), SNAME("VScrollBar"), empty_icon);
- theme->set_icon(SNAME("increment_pressed"), SNAME("VScrollBar"), empty_icon);
- theme->set_icon(SNAME("decrement"), SNAME("VScrollBar"), empty_icon);
- theme->set_icon(SNAME("decrement_highlight"), SNAME("VScrollBar"), empty_icon);
- theme->set_icon(SNAME("decrement_pressed"), SNAME("VScrollBar"), empty_icon);
+ theme->set_stylebox("scroll", "VScrollBar", make_stylebox(theme->get_icon(SNAME("GuiScrollBg"), SNAME("EditorIcons")), 5, 5, 5, 5, 0, 0, 0, 0));
+ theme->set_stylebox("scroll_focus", "VScrollBar", make_stylebox(theme->get_icon(SNAME("GuiScrollBg"), SNAME("EditorIcons")), 5, 5, 5, 5, 0, 0, 0, 0));
+ theme->set_stylebox("grabber", "VScrollBar", make_stylebox(theme->get_icon(SNAME("GuiScrollGrabber"), SNAME("EditorIcons")), 6, 6, 6, 6, 2, 2, 2, 2));
+ theme->set_stylebox("grabber_highlight", "VScrollBar", make_stylebox(theme->get_icon(SNAME("GuiScrollGrabberHl"), SNAME("EditorIcons")), 5, 5, 5, 5, 2, 2, 2, 2));
+ theme->set_stylebox("grabber_pressed", "VScrollBar", make_stylebox(theme->get_icon(SNAME("GuiScrollGrabberPressed"), SNAME("EditorIcons")), 6, 6, 6, 6, 2, 2, 2, 2));
+
+ theme->set_icon("increment", "VScrollBar", empty_icon);
+ theme->set_icon("increment_highlight", "VScrollBar", empty_icon);
+ theme->set_icon("increment_pressed", "VScrollBar", empty_icon);
+ theme->set_icon("decrement", "VScrollBar", empty_icon);
+ theme->set_icon("decrement_highlight", "VScrollBar", empty_icon);
+ theme->set_icon("decrement_pressed", "VScrollBar", empty_icon);
// HSlider
- theme->set_icon(SNAME("grabber_highlight"), SNAME("HSlider"), theme->get_icon(SNAME("GuiSliderGrabberHl"), SNAME("EditorIcons")));
- theme->set_icon(SNAME("grabber"), SNAME("HSlider"), theme->get_icon(SNAME("GuiSliderGrabber"), SNAME("EditorIcons")));
- theme->set_stylebox(SNAME("slider"), SNAME("HSlider"), make_flat_stylebox(dark_color_3, 0, default_margin_size / 2, 0, default_margin_size / 2, corner_width));
- theme->set_stylebox(SNAME("grabber_area"), SNAME("HSlider"), make_flat_stylebox(contrast_color_1, 0, default_margin_size / 2, 0, default_margin_size / 2, corner_width));
- theme->set_stylebox(SNAME("grabber_area_highlight"), SNAME("HSlider"), make_flat_stylebox(contrast_color_1, 0, default_margin_size / 2, 0, default_margin_size / 2));
+ theme->set_icon("grabber_highlight", "HSlider", theme->get_icon(SNAME("GuiSliderGrabberHl"), SNAME("EditorIcons")));
+ theme->set_icon("grabber", "HSlider", theme->get_icon(SNAME("GuiSliderGrabber"), SNAME("EditorIcons")));
+ theme->set_stylebox("slider", "HSlider", make_flat_stylebox(dark_color_3, 0, default_margin_size / 2, 0, default_margin_size / 2, corner_width));
+ theme->set_stylebox("grabber_area", "HSlider", make_flat_stylebox(contrast_color_1, 0, default_margin_size / 2, 0, default_margin_size / 2, corner_width));
+ theme->set_stylebox("grabber_area_highlight", "HSlider", make_flat_stylebox(contrast_color_1, 0, default_margin_size / 2, 0, default_margin_size / 2));
// VSlider
- theme->set_icon(SNAME("grabber"), SNAME("VSlider"), theme->get_icon(SNAME("GuiSliderGrabber"), SNAME("EditorIcons")));
- theme->set_icon(SNAME("grabber_highlight"), SNAME("VSlider"), theme->get_icon(SNAME("GuiSliderGrabberHl"), SNAME("EditorIcons")));
- theme->set_stylebox(SNAME("slider"), SNAME("VSlider"), make_flat_stylebox(dark_color_3, default_margin_size / 2, 0, default_margin_size / 2, 0, corner_width));
- theme->set_stylebox(SNAME("grabber_area"), SNAME("VSlider"), make_flat_stylebox(contrast_color_1, default_margin_size / 2, 0, default_margin_size / 2, 0, corner_width));
- theme->set_stylebox(SNAME("grabber_area_highlight"), SNAME("VSlider"), make_flat_stylebox(contrast_color_1, default_margin_size / 2, 0, default_margin_size / 2, 0));
+ theme->set_icon("grabber", "VSlider", theme->get_icon(SNAME("GuiSliderGrabber"), SNAME("EditorIcons")));
+ theme->set_icon("grabber_highlight", "VSlider", theme->get_icon(SNAME("GuiSliderGrabberHl"), SNAME("EditorIcons")));
+ theme->set_stylebox("slider", "VSlider", make_flat_stylebox(dark_color_3, default_margin_size / 2, 0, default_margin_size / 2, 0, corner_width));
+ theme->set_stylebox("grabber_area", "VSlider", make_flat_stylebox(contrast_color_1, default_margin_size / 2, 0, default_margin_size / 2, 0, corner_width));
+ theme->set_stylebox("grabber_area_highlight", "VSlider", make_flat_stylebox(contrast_color_1, default_margin_size / 2, 0, default_margin_size / 2, 0));
// RichTextLabel
- theme->set_color(SNAME("default_color"), SNAME("RichTextLabel"), font_color);
- theme->set_color(SNAME("font_shadow_color"), SNAME("RichTextLabel"), Color(0, 0, 0, 0));
- theme->set_constant(SNAME("shadow_offset_x"), SNAME("RichTextLabel"), 1 * EDSCALE);
- theme->set_constant(SNAME("shadow_offset_y"), SNAME("RichTextLabel"), 1 * EDSCALE);
- theme->set_constant(SNAME("shadow_outline_size"), SNAME("RichTextLabel"), 1 * EDSCALE);
- theme->set_stylebox(SNAME("focus"), SNAME("RichTextLabel"), make_empty_stylebox());
- theme->set_stylebox(SNAME("normal"), SNAME("RichTextLabel"), style_tree_bg);
+ theme->set_color("default_color", "RichTextLabel", font_color);
+ theme->set_color("font_shadow_color", "RichTextLabel", Color(0, 0, 0, 0));
+ theme->set_constant("shadow_offset_x", "RichTextLabel", 1 * EDSCALE);
+ theme->set_constant("shadow_offset_y", "RichTextLabel", 1 * EDSCALE);
+ theme->set_constant("shadow_outline_size", "RichTextLabel", 1 * EDSCALE);
+ theme->set_stylebox("focus", "RichTextLabel", make_empty_stylebox());
+ theme->set_stylebox("normal", "RichTextLabel", style_tree_bg);
// Editor help.
- theme->set_color(SNAME("title_color"), SNAME("EditorHelp"), accent_color);
- theme->set_color(SNAME("headline_color"), SNAME("EditorHelp"), mono_color);
- theme->set_color(SNAME("text_color"), SNAME("EditorHelp"), font_color);
- theme->set_color(SNAME("comment_color"), SNAME("EditorHelp"), font_color * Color(1, 1, 1, 0.6));
- theme->set_color(SNAME("symbol_color"), SNAME("EditorHelp"), font_color * Color(1, 1, 1, 0.6));
- theme->set_color(SNAME("value_color"), SNAME("EditorHelp"), font_color * Color(1, 1, 1, 0.6));
- theme->set_color(SNAME("qualifier_color"), SNAME("EditorHelp"), font_color * Color(1, 1, 1, 0.8));
- theme->set_color(SNAME("type_color"), SNAME("EditorHelp"), accent_color.lerp(font_color, 0.5));
- theme->set_color(SNAME("selection_color"), SNAME("EditorHelp"), accent_color * Color(1, 1, 1, 0.4));
- theme->set_color(SNAME("link_color"), SNAME("EditorHelp"), accent_color.lerp(mono_color, 0.8));
- theme->set_color(SNAME("code_color"), SNAME("EditorHelp"), accent_color.lerp(mono_color, 0.6));
- theme->set_color(SNAME("kbd_color"), SNAME("EditorHelp"), accent_color.lerp(property_color, 0.6));
- theme->set_constant(SNAME("line_separation"), SNAME("EditorHelp"), Math::round(6 * EDSCALE));
- theme->set_constant(SNAME("table_hseparation"), SNAME("EditorHelp"), 16 * EDSCALE);
- theme->set_constant(SNAME("table_vseparation"), SNAME("EditorHelp"), 6 * EDSCALE);
+ theme->set_color("title_color", "EditorHelp", accent_color);
+ theme->set_color("headline_color", "EditorHelp", mono_color);
+ theme->set_color("text_color", "EditorHelp", font_color);
+ theme->set_color("comment_color", "EditorHelp", font_color * Color(1, 1, 1, 0.6));
+ theme->set_color("symbol_color", "EditorHelp", font_color * Color(1, 1, 1, 0.6));
+ theme->set_color("value_color", "EditorHelp", font_color * Color(1, 1, 1, 0.6));
+ theme->set_color("qualifier_color", "EditorHelp", font_color * Color(1, 1, 1, 0.8));
+ theme->set_color("type_color", "EditorHelp", accent_color.lerp(font_color, 0.5));
+ theme->set_color("selection_color", "EditorHelp", accent_color * Color(1, 1, 1, 0.4));
+ theme->set_color("link_color", "EditorHelp", accent_color.lerp(mono_color, 0.8));
+ theme->set_color("code_color", "EditorHelp", accent_color.lerp(mono_color, 0.6));
+ theme->set_color("kbd_color", "EditorHelp", accent_color.lerp(property_color, 0.6));
+ theme->set_constant("line_separation", "EditorHelp", Math::round(6 * EDSCALE));
+ theme->set_constant("table_hseparation", "EditorHelp", 16 * EDSCALE);
+ theme->set_constant("table_vseparation", "EditorHelp", 6 * EDSCALE);
// Panel
- theme->set_stylebox(SNAME("panel"), SNAME("Panel"), make_flat_stylebox(dark_color_1, 6, 4, 6, 4, corner_width));
- theme->set_stylebox(SNAME("PanelForeground"), SNAME("EditorStyles"), style_default);
+ theme->set_stylebox("panel", "Panel", make_flat_stylebox(dark_color_1, 6, 4, 6, 4, corner_width));
+ theme->set_stylebox("PanelForeground", "EditorStyles", style_default);
// Label
- theme->set_stylebox(SNAME("normal"), SNAME("Label"), style_empty);
- theme->set_color(SNAME("font_color"), SNAME("Label"), font_color);
- theme->set_color(SNAME("font_shadow_color"), SNAME("Label"), Color(0, 0, 0, 0));
- theme->set_constant(SNAME("shadow_offset_x"), SNAME("Label"), 1 * EDSCALE);
- theme->set_constant(SNAME("shadow_offset_y"), SNAME("Label"), 1 * EDSCALE);
- theme->set_constant(SNAME("shadow_outline_size"), SNAME("Label"), 1 * EDSCALE);
- theme->set_constant(SNAME("line_spacing"), SNAME("Label"), 3 * EDSCALE);
+ theme->set_stylebox("normal", "Label", style_empty);
+ theme->set_color("font_color", "Label", font_color);
+ theme->set_color("font_shadow_color", "Label", Color(0, 0, 0, 0));
+ theme->set_constant("shadow_offset_x", "Label", 1 * EDSCALE);
+ theme->set_constant("shadow_offset_y", "Label", 1 * EDSCALE);
+ theme->set_constant("shadow_outline_size", "Label", 1 * EDSCALE);
+ theme->set_constant("line_spacing", "Label", 3 * EDSCALE);
// LinkButton
- theme->set_stylebox(SNAME("focus"), SNAME("LinkButton"), style_empty);
- theme->set_color(SNAME("font_color"), SNAME("LinkButton"), font_color);
- theme->set_color(SNAME("font_hover_color"), SNAME("LinkButton"), font_hover_color);
- theme->set_color(SNAME("font_focus_color"), SNAME("LinkButton"), font_focus_color);
- theme->set_color(SNAME("font_pressed_color"), SNAME("LinkButton"), accent_color);
- theme->set_color(SNAME("font_disabled_color"), SNAME("LinkButton"), font_disabled_color);
+ theme->set_stylebox("focus", "LinkButton", style_empty);
+ theme->set_color("font_color", "LinkButton", font_color);
+ theme->set_color("font_hover_color", "LinkButton", font_hover_color);
+ theme->set_color("font_focus_color", "LinkButton", font_focus_color);
+ theme->set_color("font_pressed_color", "LinkButton", accent_color);
+ theme->set_color("font_disabled_color", "LinkButton", font_disabled_color);
// TooltipPanel
Ref<StyleBoxFlat> style_tooltip = style_popup->duplicate();
@@ -1307,48 +1307,48 @@ Ref<Theme> create_editor_theme(const Ref<Theme> p_theme) {
style_tooltip->set_default_margin(SIDE_BOTTOM, default_margin_size * EDSCALE * 0.5);
style_tooltip->set_bg_color(dark_color_3 * Color(0.8, 0.8, 0.8, 0.9));
style_tooltip->set_border_width_all(0);
- theme->set_color(SNAME("font_color"), SNAME("TooltipLabel"), font_hover_color);
- theme->set_color(SNAME("font_color_shadow"), SNAME("TooltipLabel"), Color(0, 0, 0, 0));
- theme->set_stylebox(SNAME("panel"), SNAME("TooltipPanel"), style_tooltip);
+ theme->set_color("font_color", "TooltipLabel", font_hover_color);
+ theme->set_color("font_color_shadow", "TooltipLabel", Color(0, 0, 0, 0));
+ theme->set_stylebox("panel", "TooltipPanel", style_tooltip);
// PopupPanel
- theme->set_stylebox(SNAME("panel"), SNAME("PopupPanel"), style_popup);
+ theme->set_stylebox("panel", "PopupPanel", style_popup);
// SpinBox
- theme->set_icon(SNAME("updown"), SNAME("SpinBox"), theme->get_icon(SNAME("GuiSpinboxUpdown"), SNAME("EditorIcons")));
- theme->set_icon(SNAME("updown_disabled"), SNAME("SpinBox"), theme->get_icon(SNAME("GuiSpinboxUpdownDisabled"), SNAME("EditorIcons")));
+ theme->set_icon("updown", "SpinBox", theme->get_icon(SNAME("GuiSpinboxUpdown"), SNAME("EditorIcons")));
+ theme->set_icon("updown_disabled", "SpinBox", theme->get_icon(SNAME("GuiSpinboxUpdownDisabled"), SNAME("EditorIcons")));
// ProgressBar
- theme->set_stylebox(SNAME("bg"), SNAME("ProgressBar"), make_stylebox(theme->get_icon(SNAME("GuiProgressBar"), SNAME("EditorIcons")), 4, 4, 4, 4, 0, 0, 0, 0));
- theme->set_stylebox(SNAME("fg"), SNAME("ProgressBar"), make_stylebox(theme->get_icon(SNAME("GuiProgressFill"), SNAME("EditorIcons")), 6, 6, 6, 6, 2, 1, 2, 1));
- theme->set_color(SNAME("font_color"), SNAME("ProgressBar"), font_color);
+ theme->set_stylebox("bg", "ProgressBar", make_stylebox(theme->get_icon(SNAME("GuiProgressBar"), SNAME("EditorIcons")), 4, 4, 4, 4, 0, 0, 0, 0));
+ theme->set_stylebox("fg", "ProgressBar", make_stylebox(theme->get_icon(SNAME("GuiProgressFill"), SNAME("EditorIcons")), 6, 6, 6, 6, 2, 1, 2, 1));
+ theme->set_color("font_color", "ProgressBar", font_color);
// GraphEdit
- theme->set_stylebox(SNAME("bg"), "GraphEdit", style_tree_bg);
+ theme->set_stylebox("bg", "GraphEdit", style_tree_bg);
if (dark_theme) {
- theme->set_color(SNAME("grid_major"), SNAME("GraphEdit"), Color(1.0, 1.0, 1.0, 0.15));
- theme->set_color(SNAME("grid_minor"), SNAME("GraphEdit"), Color(1.0, 1.0, 1.0, 0.07));
+ theme->set_color("grid_major", "GraphEdit", Color(1.0, 1.0, 1.0, 0.15));
+ theme->set_color("grid_minor", "GraphEdit", Color(1.0, 1.0, 1.0, 0.07));
} else {
- theme->set_color(SNAME("grid_major"), SNAME("GraphEdit"), Color(0.0, 0.0, 0.0, 0.15));
- theme->set_color(SNAME("grid_minor"), SNAME("GraphEdit"), Color(0.0, 0.0, 0.0, 0.07));
+ theme->set_color("grid_major", "GraphEdit", Color(0.0, 0.0, 0.0, 0.15));
+ theme->set_color("grid_minor", "GraphEdit", Color(0.0, 0.0, 0.0, 0.07));
}
- theme->set_color(SNAME("selection_fill"), SNAME("GraphEdit"), theme->get_color(SNAME("box_selection_fill_color"), SNAME("Editor")));
- theme->set_color(SNAME("selection_stroke"), SNAME("GraphEdit"), theme->get_color(SNAME("box_selection_stroke_color"), SNAME("Editor")));
- theme->set_color(SNAME("activity"), SNAME("GraphEdit"), accent_color);
- theme->set_icon(SNAME("minus"), SNAME("GraphEdit"), theme->get_icon(SNAME("ZoomLess"), SNAME("EditorIcons")));
- theme->set_icon(SNAME("more"), SNAME("GraphEdit"), theme->get_icon(SNAME("ZoomMore"), SNAME("EditorIcons")));
- theme->set_icon(SNAME("reset"), SNAME("GraphEdit"), theme->get_icon(SNAME("ZoomReset"), SNAME("EditorIcons")));
- theme->set_icon(SNAME("snap"), SNAME("GraphEdit"), theme->get_icon(SNAME("SnapGrid"), SNAME("EditorIcons")));
- theme->set_icon(SNAME("minimap"), SNAME("GraphEdit"), theme->get_icon(SNAME("GridMinimap"), SNAME("EditorIcons")));
- theme->set_icon(SNAME("layout"), SNAME("GraphEdit"), theme->get_icon(SNAME("GridLayout"), SNAME("EditorIcons")));
- theme->set_constant(SNAME("bezier_len_pos"), SNAME("GraphEdit"), 80 * EDSCALE);
- theme->set_constant(SNAME("bezier_len_neg"), SNAME("GraphEdit"), 160 * EDSCALE);
+ theme->set_color("selection_fill", "GraphEdit", theme->get_color(SNAME("box_selection_fill_color"), SNAME("Editor")));
+ theme->set_color("selection_stroke", "GraphEdit", theme->get_color(SNAME("box_selection_stroke_color"), SNAME("Editor")));
+ theme->set_color("activity", "GraphEdit", accent_color);
+ theme->set_icon("minus", "GraphEdit", theme->get_icon(SNAME("ZoomLess"), SNAME("EditorIcons")));
+ theme->set_icon("more", "GraphEdit", theme->get_icon(SNAME("ZoomMore"), SNAME("EditorIcons")));
+ theme->set_icon("reset", "GraphEdit", theme->get_icon(SNAME("ZoomReset"), SNAME("EditorIcons")));
+ theme->set_icon("snap", "GraphEdit", theme->get_icon(SNAME("SnapGrid"), SNAME("EditorIcons")));
+ theme->set_icon("minimap", "GraphEdit", theme->get_icon(SNAME("GridMinimap"), SNAME("EditorIcons")));
+ theme->set_icon("layout", "GraphEdit", theme->get_icon(SNAME("GridLayout"), SNAME("EditorIcons")));
+ theme->set_constant("bezier_len_pos", "GraphEdit", 80 * EDSCALE);
+ theme->set_constant("bezier_len_neg", "GraphEdit", 160 * EDSCALE);
// GraphEditMinimap
Ref<StyleBoxFlat> style_minimap_bg = make_flat_stylebox(dark_color_1, 0, 0, 0, 0);
style_minimap_bg->set_border_color(dark_color_3);
style_minimap_bg->set_border_width_all(1);
- theme->set_stylebox(SNAME("bg"), SNAME("GraphEditMinimap"), style_minimap_bg);
+ theme->set_stylebox("bg", "GraphEditMinimap", style_minimap_bg);
Ref<StyleBoxFlat> style_minimap_camera;
Ref<StyleBoxFlat> style_minimap_node;
@@ -1363,8 +1363,8 @@ Ref<Theme> create_editor_theme(const Ref<Theme> p_theme) {
}
style_minimap_camera->set_border_width_all(1);
style_minimap_node->set_corner_radius_all(1);
- theme->set_stylebox(SNAME("camera"), SNAME("GraphEditMinimap"), style_minimap_camera);
- theme->set_stylebox(SNAME("node"), SNAME("GraphEditMinimap"), style_minimap_node);
+ theme->set_stylebox("camera", "GraphEditMinimap", style_minimap_camera);
+ theme->set_stylebox("node", "GraphEditMinimap", style_minimap_node);
Ref<Texture2D> minimap_resizer_icon = theme->get_icon(SNAME("GuiResizer"), SNAME("EditorIcons"));
Color minimap_resizer_color;
@@ -1373,8 +1373,8 @@ Ref<Theme> create_editor_theme(const Ref<Theme> p_theme) {
} else {
minimap_resizer_color = Color(0, 0, 0, 0.65);
}
- theme->set_icon(SNAME("resizer"), SNAME("GraphEditMinimap"), flip_icon(minimap_resizer_icon, true, true));
- theme->set_color(SNAME("resizer_color"), SNAME("GraphEditMinimap"), minimap_resizer_color);
+ theme->set_icon("resizer", "GraphEditMinimap", flip_icon(minimap_resizer_icon, true, true));
+ theme->set_color("resizer_color", "GraphEditMinimap", minimap_resizer_color);
// GraphNode
const int gn_margin_side = 28;
@@ -1413,93 +1413,93 @@ Ref<Theme> create_editor_theme(const Ref<Theme> p_theme) {
graphsbcomment->set_border_width(SIDE_TOP, 24 * EDSCALE);
graphsbcommentselected->set_border_width(SIDE_TOP, 24 * EDSCALE);
- theme->set_stylebox(SNAME("frame"), SNAME("GraphNode"), graphsb);
- theme->set_stylebox(SNAME("selectedframe"), SNAME("GraphNode"), graphsbselected);
- theme->set_stylebox(SNAME("comment"), SNAME("GraphNode"), graphsbcomment);
- theme->set_stylebox(SNAME("commentfocus"), SNAME("GraphNode"), graphsbcommentselected);
- theme->set_stylebox(SNAME("breakpoint"), SNAME("GraphNode"), graphsbbreakpoint);
- theme->set_stylebox(SNAME("position"), SNAME("GraphNode"), graphsbposition);
- theme->set_stylebox(SNAME("state_machine_frame"), SNAME("GraphNode"), smgraphsb);
- theme->set_stylebox(SNAME("state_machine_selectedframe"), SNAME("GraphNode"), smgraphsbselected);
+ theme->set_stylebox("frame", "GraphNode", graphsb);
+ theme->set_stylebox("selectedframe", "GraphNode", graphsbselected);
+ theme->set_stylebox("comment", "GraphNode", graphsbcomment);
+ theme->set_stylebox("commentfocus", "GraphNode", graphsbcommentselected);
+ theme->set_stylebox("breakpoint", "GraphNode", graphsbbreakpoint);
+ theme->set_stylebox("position", "GraphNode", graphsbposition);
+ theme->set_stylebox("state_machine_frame", "GraphNode", smgraphsb);
+ theme->set_stylebox("state_machine_selectedframe", "GraphNode", smgraphsbselected);
Color default_node_color = dark_color_1.inverted();
- theme->set_color(SNAME("title_color"), SNAME("GraphNode"), default_node_color);
+ theme->set_color("title_color", "GraphNode", default_node_color);
default_node_color.a = 0.7;
- theme->set_color(SNAME("close_color"), SNAME("GraphNode"), default_node_color);
- theme->set_color(SNAME("resizer_color"), SNAME("GraphNode"), default_node_color);
+ theme->set_color("close_color", "GraphNode", default_node_color);
+ theme->set_color("resizer_color", "GraphNode", default_node_color);
- theme->set_constant(SNAME("port_offset"), SNAME("GraphNode"), 14 * EDSCALE);
- theme->set_constant(SNAME("title_h_offset"), SNAME("GraphNode"), -16 * EDSCALE);
- theme->set_constant(SNAME("title_offset"), SNAME("GraphNode"), 20 * EDSCALE);
- theme->set_constant(SNAME("close_h_offset"), SNAME("GraphNode"), 20 * EDSCALE);
- theme->set_constant(SNAME("close_offset"), SNAME("GraphNode"), 20 * EDSCALE);
- theme->set_constant(SNAME("separation"), SNAME("GraphNode"), 1 * EDSCALE);
+ theme->set_constant("port_offset", "GraphNode", 14 * EDSCALE);
+ theme->set_constant("title_h_offset", "GraphNode", -16 * EDSCALE);
+ theme->set_constant("title_offset", "GraphNode", 20 * EDSCALE);
+ theme->set_constant("close_h_offset", "GraphNode", 20 * EDSCALE);
+ theme->set_constant("close_offset", "GraphNode", 20 * EDSCALE);
+ theme->set_constant("separation", "GraphNode", 1 * EDSCALE);
- theme->set_icon(SNAME("close"), SNAME("GraphNode"), theme->get_icon(SNAME("GuiCloseCustomizable"), SNAME("EditorIcons")));
- theme->set_icon(SNAME("resizer"), SNAME("GraphNode"), theme->get_icon(SNAME("GuiResizer"), SNAME("EditorIcons")));
- theme->set_icon(SNAME("port"), SNAME("GraphNode"), theme->get_icon(SNAME("GuiGraphNodePort"), SNAME("EditorIcons")));
+ theme->set_icon("close", "GraphNode", theme->get_icon(SNAME("GuiCloseCustomizable"), SNAME("EditorIcons")));
+ theme->set_icon("resizer", "GraphNode", theme->get_icon(SNAME("GuiResizer"), SNAME("EditorIcons")));
+ theme->set_icon("port", "GraphNode", theme->get_icon(SNAME("GuiGraphNodePort"), SNAME("EditorIcons")));
// GridContainer
- theme->set_constant(SNAME("vseparation"), SNAME("GridContainer"), Math::round(widget_default_margin.y - 2 * EDSCALE));
+ theme->set_constant("vseparation", "GridContainer", Math::round(widget_default_margin.y - 2 * EDSCALE));
// FileDialog
- theme->set_icon(SNAME("folder"), SNAME("FileDialog"), theme->get_icon(SNAME("Folder"), SNAME("EditorIcons")));
- theme->set_icon(SNAME("parent_folder"), SNAME("FileDialog"), theme->get_icon(SNAME("ArrowUp"), SNAME("EditorIcons")));
- theme->set_icon(SNAME("back_folder"), SNAME("FileDialog"), theme->get_icon(SNAME("Back"), SNAME("EditorIcons")));
- theme->set_icon(SNAME("forward_folder"), SNAME("FileDialog"), theme->get_icon(SNAME("Forward"), SNAME("EditorIcons")));
- theme->set_icon(SNAME("reload"), SNAME("FileDialog"), theme->get_icon(SNAME("Reload"), SNAME("EditorIcons")));
- theme->set_icon(SNAME("toggle_hidden"), SNAME("FileDialog"), theme->get_icon(SNAME("GuiVisibilityVisible"), SNAME("EditorIcons")));
+ theme->set_icon("folder", "FileDialog", theme->get_icon(SNAME("Folder"), SNAME("EditorIcons")));
+ theme->set_icon("parent_folder", "FileDialog", theme->get_icon(SNAME("ArrowUp"), SNAME("EditorIcons")));
+ theme->set_icon("back_folder", "FileDialog", theme->get_icon(SNAME("Back"), SNAME("EditorIcons")));
+ theme->set_icon("forward_folder", "FileDialog", theme->get_icon(SNAME("Forward"), SNAME("EditorIcons")));
+ theme->set_icon("reload", "FileDialog", theme->get_icon(SNAME("Reload"), SNAME("EditorIcons")));
+ theme->set_icon("toggle_hidden", "FileDialog", theme->get_icon(SNAME("GuiVisibilityVisible"), SNAME("EditorIcons")));
// Use a different color for folder icons to make them easier to distinguish from files.
// On a light theme, the icon will be dark, so we need to lighten it before blending it with the accent color.
- theme->set_color(SNAME("folder_icon_modulate"), SNAME("FileDialog"), (dark_theme ? Color(1, 1, 1) : Color(4.25, 4.25, 4.25)).lerp(accent_color, 0.7));
- theme->set_color(SNAME("files_disabled"), SNAME("FileDialog"), font_disabled_color);
+ theme->set_color("folder_icon_modulate", "FileDialog", (dark_theme ? Color(1, 1, 1) : Color(4.25, 4.25, 4.25)).lerp(accent_color, 0.7));
+ theme->set_color("files_disabled", "FileDialog", font_disabled_color);
// ColorPicker
- theme->set_constant(SNAME("margin"), SNAME("ColorPicker"), popup_margin_size);
- theme->set_constant(SNAME("sv_width"), SNAME("ColorPicker"), 256 * EDSCALE);
- theme->set_constant(SNAME("sv_height"), SNAME("ColorPicker"), 256 * EDSCALE);
- theme->set_constant(SNAME("h_width"), SNAME("ColorPicker"), 30 * EDSCALE);
- theme->set_constant(SNAME("label_width"), SNAME("ColorPicker"), 10 * EDSCALE);
- theme->set_icon(SNAME("screen_picker"), SNAME("ColorPicker"), theme->get_icon(SNAME("ColorPick"), SNAME("EditorIcons")));
- theme->set_icon(SNAME("add_preset"), SNAME("ColorPicker"), theme->get_icon(SNAME("Add"), SNAME("EditorIcons")));
- theme->set_icon(SNAME("sample_bg"), SNAME("ColorPicker"), theme->get_icon(SNAME("GuiMiniCheckerboard"), SNAME("EditorIcons")));
- theme->set_icon(SNAME("overbright_indicator"), SNAME("ColorPicker"), theme->get_icon(SNAME("OverbrightIndicator"), SNAME("EditorIcons")));
- theme->set_icon(SNAME("bar_arrow"), SNAME("ColorPicker"), theme->get_icon(SNAME("ColorPickerBarArrow"), SNAME("EditorIcons")));
- theme->set_icon(SNAME("picker_cursor"), SNAME("ColorPicker"), theme->get_icon(SNAME("PickerCursor"), SNAME("EditorIcons")));
+ theme->set_constant("margin", "ColorPicker", popup_margin_size);
+ theme->set_constant("sv_width", "ColorPicker", 256 * EDSCALE);
+ theme->set_constant("sv_height", "ColorPicker", 256 * EDSCALE);
+ theme->set_constant("h_width", "ColorPicker", 30 * EDSCALE);
+ theme->set_constant("label_width", "ColorPicker", 10 * EDSCALE);
+ theme->set_icon("screen_picker", "ColorPicker", theme->get_icon(SNAME("ColorPick"), SNAME("EditorIcons")));
+ theme->set_icon("add_preset", "ColorPicker", theme->get_icon(SNAME("Add"), SNAME("EditorIcons")));
+ theme->set_icon("sample_bg", "ColorPicker", theme->get_icon(SNAME("GuiMiniCheckerboard"), SNAME("EditorIcons")));
+ theme->set_icon("overbright_indicator", "ColorPicker", theme->get_icon(SNAME("OverbrightIndicator"), SNAME("EditorIcons")));
+ theme->set_icon("bar_arrow", "ColorPicker", theme->get_icon(SNAME("ColorPickerBarArrow"), SNAME("EditorIcons")));
+ theme->set_icon("picker_cursor", "ColorPicker", theme->get_icon(SNAME("PickerCursor"), SNAME("EditorIcons")));
// ColorPickerButton
- theme->set_icon(SNAME("bg"), SNAME("ColorPickerButton"), theme->get_icon(SNAME("GuiMiniCheckerboard"), SNAME("EditorIcons")));
+ theme->set_icon("bg", "ColorPickerButton", theme->get_icon(SNAME("GuiMiniCheckerboard"), SNAME("EditorIcons")));
// ColorPresetButton
Ref<StyleBoxFlat> preset_sb = make_flat_stylebox(Color(1, 1, 1), 2, 2, 2, 2, 2);
preset_sb->set_anti_aliased(false);
- theme->set_stylebox(SNAME("preset_fg"), SNAME("ColorPresetButton"), preset_sb);
- theme->set_icon(SNAME("preset_bg"), SNAME("ColorPresetButton"), theme->get_icon(SNAME("GuiMiniCheckerboard"), SNAME("EditorIcons")));
- theme->set_icon(SNAME("overbright_indicator"), SNAME("ColorPresetButton"), theme->get_icon(SNAME("OverbrightIndicator"), SNAME("EditorIcons")));
+ theme->set_stylebox("preset_fg", "ColorPresetButton", preset_sb);
+ theme->set_icon("preset_bg", "ColorPresetButton", theme->get_icon(SNAME("GuiMiniCheckerboard"), SNAME("EditorIcons")));
+ theme->set_icon("overbright_indicator", "ColorPresetButton", theme->get_icon(SNAME("OverbrightIndicator"), SNAME("EditorIcons")));
// Information on 3D viewport
Ref<StyleBoxFlat> style_info_3d_viewport = style_default->duplicate();
style_info_3d_viewport->set_bg_color(style_info_3d_viewport->get_bg_color() * Color(1, 1, 1, 0.5));
style_info_3d_viewport->set_border_width_all(0);
- theme->set_stylebox(SNAME("Information3dViewport"), SNAME("EditorStyles"), style_info_3d_viewport);
+ theme->set_stylebox("Information3dViewport", "EditorStyles", style_info_3d_viewport);
// Asset Library.
- theme->set_stylebox(SNAME("panel"), SNAME("AssetLib"), style_content_panel);
- theme->set_color(SNAME("status_color"), SNAME("AssetLib"), Color(0.5, 0.5, 0.5));
- theme->set_icon(SNAME("dismiss"), SNAME("AssetLib"), theme->get_icon(SNAME("Close"), SNAME("EditorIcons")));
+ theme->set_stylebox("panel", "AssetLib", style_content_panel);
+ theme->set_color("status_color", "AssetLib", Color(0.5, 0.5, 0.5));
+ theme->set_icon("dismiss", "AssetLib", theme->get_icon(SNAME("Close"), SNAME("EditorIcons")));
// Theme editor.
- theme->set_color(SNAME("preview_picker_overlay_color"), SNAME("ThemeEditor"), Color(0.1, 0.1, 0.1, 0.25));
+ theme->set_color("preview_picker_overlay_color", "ThemeEditor", Color(0.1, 0.1, 0.1, 0.25));
Color theme_preview_picker_bg_color = accent_color;
theme_preview_picker_bg_color.a = 0.2;
Ref<StyleBoxFlat> theme_preview_picker_sb = make_flat_stylebox(theme_preview_picker_bg_color, 0, 0, 0, 0);
theme_preview_picker_sb->set_border_color(accent_color);
theme_preview_picker_sb->set_border_width_all(1.0 * EDSCALE);
- theme->set_stylebox(SNAME("preview_picker_overlay"), SNAME("ThemeEditor"), theme_preview_picker_sb);
+ 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(SNAME("preview_picker_label"), SNAME("ThemeEditor"), theme_preview_picker_label_sb);
+ theme->set_stylebox("preview_picker_label", "ThemeEditor", theme_preview_picker_label_sb);
// adaptive script theme constants
// for comments and elements with lower relevance
@@ -1593,27 +1593,27 @@ Ref<Theme> create_editor_theme(const Ref<Theme> p_theme) {
}
// Now theme is loaded, apply it to CodeEdit.
- theme->set_color(SNAME("background_color"), SNAME("CodeEdit"), EDITOR_GET("text_editor/theme/highlighting/background_color"));
- theme->set_color(SNAME("completion_background_color"), SNAME("CodeEdit"), EDITOR_GET("text_editor/theme/highlighting/completion_background_color"));
- theme->set_color(SNAME("completion_selected_color"), SNAME("CodeEdit"), EDITOR_GET("text_editor/theme/highlighting/completion_selected_color"));
- theme->set_color(SNAME("completion_existing_color"), SNAME("CodeEdit"), EDITOR_GET("text_editor/theme/highlighting/completion_existing_color"));
- theme->set_color(SNAME("completion_scroll_color"), SNAME("CodeEdit"), EDITOR_GET("text_editor/theme/highlighting/completion_scroll_color"));
- theme->set_color(SNAME("completion_font_color"), SNAME("CodeEdit"), EDITOR_GET("text_editor/theme/highlighting/completion_font_color"));
- theme->set_color(SNAME("font_color"), SNAME("CodeEdit"), EDITOR_GET("text_editor/theme/highlighting/text_color"));
- theme->set_color(SNAME("line_number_color"), SNAME("CodeEdit"), EDITOR_GET("text_editor/theme/highlighting/line_number_color"));
- theme->set_color(SNAME("caret_color"), SNAME("CodeEdit"), EDITOR_GET("text_editor/theme/highlighting/caret_color"));
- theme->set_color(SNAME("font_selected_color"), SNAME("CodeEdit"), EDITOR_GET("text_editor/theme/highlighting/text_selected_color"));
- theme->set_color(SNAME("selection_color"), SNAME("CodeEdit"), EDITOR_GET("text_editor/theme/highlighting/selection_color"));
- theme->set_color(SNAME("brace_mismatch_color"), SNAME("CodeEdit"), EDITOR_GET("text_editor/theme/highlighting/brace_mismatch_color"));
- theme->set_color(SNAME("current_line_color"), SNAME("CodeEdit"), EDITOR_GET("text_editor/theme/highlighting/current_line_color"));
- theme->set_color(SNAME("line_length_guideline_color"), SNAME("CodeEdit"), EDITOR_GET("text_editor/theme/highlighting/line_length_guideline_color"));
- theme->set_color(SNAME("word_highlighted_color"), SNAME("CodeEdit"), EDITOR_GET("text_editor/theme/highlighting/word_highlighted_color"));
- theme->set_color(SNAME("bookmark_color"), SNAME("CodeEdit"), EDITOR_GET("text_editor/theme/highlighting/bookmark_color"));
- theme->set_color(SNAME("breakpoint_color"), SNAME("CodeEdit"), EDITOR_GET("text_editor/theme/highlighting/breakpoint_color"));
- theme->set_color(SNAME("executing_line_color"), SNAME("CodeEdit"), EDITOR_GET("text_editor/theme/highlighting/executing_line_color"));
- theme->set_color(SNAME("code_folding_color"), SNAME("CodeEdit"), EDITOR_GET("text_editor/theme/highlighting/code_folding_color"));
- theme->set_color(SNAME("search_result_color"), SNAME("CodeEdit"), EDITOR_GET("text_editor/theme/highlighting/search_result_color"));
- theme->set_color(SNAME("search_result_border_color"), SNAME("CodeEdit"), EDITOR_GET("text_editor/theme/highlighting/search_result_border_color"));
+ theme->set_color("background_color", "CodeEdit", EDITOR_GET("text_editor/theme/highlighting/background_color"));
+ theme->set_color("completion_background_color", "CodeEdit", EDITOR_GET("text_editor/theme/highlighting/completion_background_color"));
+ theme->set_color("completion_selected_color", "CodeEdit", EDITOR_GET("text_editor/theme/highlighting/completion_selected_color"));
+ theme->set_color("completion_existing_color", "CodeEdit", EDITOR_GET("text_editor/theme/highlighting/completion_existing_color"));
+ theme->set_color("completion_scroll_color", "CodeEdit", EDITOR_GET("text_editor/theme/highlighting/completion_scroll_color"));
+ theme->set_color("completion_font_color", "CodeEdit", EDITOR_GET("text_editor/theme/highlighting/completion_font_color"));
+ theme->set_color("font_color", "CodeEdit", EDITOR_GET("text_editor/theme/highlighting/text_color"));
+ theme->set_color("line_number_color", "CodeEdit", EDITOR_GET("text_editor/theme/highlighting/line_number_color"));
+ theme->set_color("caret_color", "CodeEdit", EDITOR_GET("text_editor/theme/highlighting/caret_color"));
+ theme->set_color("font_selected_color", "CodeEdit", EDITOR_GET("text_editor/theme/highlighting/text_selected_color"));
+ theme->set_color("selection_color", "CodeEdit", EDITOR_GET("text_editor/theme/highlighting/selection_color"));
+ theme->set_color("brace_mismatch_color", "CodeEdit", EDITOR_GET("text_editor/theme/highlighting/brace_mismatch_color"));
+ theme->set_color("current_line_color", "CodeEdit", EDITOR_GET("text_editor/theme/highlighting/current_line_color"));
+ theme->set_color("line_length_guideline_color", "CodeEdit", EDITOR_GET("text_editor/theme/highlighting/line_length_guideline_color"));
+ theme->set_color("word_highlighted_color", "CodeEdit", EDITOR_GET("text_editor/theme/highlighting/word_highlighted_color"));
+ theme->set_color("bookmark_color", "CodeEdit", EDITOR_GET("text_editor/theme/highlighting/bookmark_color"));
+ theme->set_color("breakpoint_color", "CodeEdit", EDITOR_GET("text_editor/theme/highlighting/breakpoint_color"));
+ theme->set_color("executing_line_color", "CodeEdit", EDITOR_GET("text_editor/theme/highlighting/executing_line_color"));
+ theme->set_color("code_folding_color", "CodeEdit", EDITOR_GET("text_editor/theme/highlighting/code_folding_color"));
+ theme->set_color("search_result_color", "CodeEdit", EDITOR_GET("text_editor/theme/highlighting/search_result_color"));
+ theme->set_color("search_result_border_color", "CodeEdit", EDITOR_GET("text_editor/theme/highlighting/search_result_border_color"));
return theme;
}
diff --git a/editor/editor_toaster.cpp b/editor/editor_toaster.cpp
index f326c9fc37..24227b3a6b 100644
--- a/editor/editor_toaster.cpp
+++ b/editor/editor_toaster.cpp
@@ -333,13 +333,13 @@ Control *EditorToaster::popup(Control *p_control, Severity p_severity, double p_
panel->set_tooltip(p_tooltip);
switch (p_severity) {
case SEVERITY_INFO:
- panel->add_theme_style_override(SNAME("panel"), info_panel_style_background);
+ panel->add_theme_style_override("panel", info_panel_style_background);
break;
case SEVERITY_WARNING:
- panel->add_theme_style_override(SNAME("panel"), warning_panel_style_background);
+ panel->add_theme_style_override("panel", warning_panel_style_background);
break;
case SEVERITY_ERROR:
- panel->add_theme_style_override(SNAME("panel"), error_panel_style_background);
+ panel->add_theme_style_override("panel", error_panel_style_background);
break;
default:
break;
@@ -508,7 +508,7 @@ EditorToaster::EditorToaster() {
// Disable notification button.
disable_notifications_panel = memnew(PanelContainer);
disable_notifications_panel->set_as_top_level(true);
- disable_notifications_panel->add_theme_style_override(SNAME("panel"), info_panel_style_background);
+ disable_notifications_panel->add_theme_style_override("panel", info_panel_style_background);
add_child(disable_notifications_panel);
disable_notifications_button = memnew(Button);
diff --git a/editor/editor_zoom_widget.cpp b/editor/editor_zoom_widget.cpp
index 8d258ba2e1..abfa383297 100644
--- a/editor/editor_zoom_widget.cpp
+++ b/editor/editor_zoom_widget.cpp
@@ -176,9 +176,9 @@ EditorZoomWidget::EditorZoomWidget() {
zoom_reset = memnew(Button);
zoom_reset->set_flat(true);
add_child(zoom_reset);
- zoom_reset->add_theme_constant_override(SNAME("outline_size"), 1);
- zoom_reset->add_theme_color_override(SNAME("font_outline_color"), Color(0, 0, 0));
- zoom_reset->add_theme_color_override(SNAME("font_color"), Color(1, 1, 1));
+ zoom_reset->add_theme_constant_override("outline_size", 1);
+ zoom_reset->add_theme_color_override("font_outline_color", Color(0, 0, 0));
+ zoom_reset->add_theme_color_override("font_color", Color(1, 1, 1));
zoom_reset->connect("pressed", callable_mp(this, &EditorZoomWidget::_button_zoom_reset));
zoom_reset->set_shortcut(ED_SHORTCUT("canvas_item_editor/zoom_reset", TTR("Zoom Reset"), KeyModifierMask::CMD | Key::KEY_0));
zoom_reset->set_shortcut_context(this);
@@ -197,5 +197,5 @@ EditorZoomWidget::EditorZoomWidget() {
_update_zoom_label();
- add_theme_constant_override(SNAME("separation"), Math::round(-8 * EDSCALE));
+ add_theme_constant_override("separation", Math::round(-8 * EDSCALE));
}
diff --git a/editor/export_template_manager.cpp b/editor/export_template_manager.cpp
index 9519224c12..8c34609e9c 100644
--- a/editor/export_template_manager.cpp
+++ b/editor/export_template_manager.cpp
@@ -357,9 +357,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(SNAME("font_color"), get_theme_color(SNAME("error_color"), SNAME("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(SNAME("font_color"), get_theme_color(SNAME("font_color"), SNAME("Label")));
+ download_progress_label->add_theme_color_override("font_color", get_theme_color(SNAME("font_color"), SNAME("Label")));
}
}
@@ -744,9 +744,9 @@ void ExportTemplateManager::_notification(int p_what) {
switch (p_what) {
case NOTIFICATION_ENTER_TREE:
case NOTIFICATION_THEME_CHANGED: {
- current_value->add_theme_font_override(SNAME("font"), get_theme_font(SNAME("main"), SNAME("EditorFonts")));
- current_missing_label->add_theme_color_override(SNAME("font_color"), get_theme_color(SNAME("error_color"), SNAME("Editor")));
- current_installed_label->add_theme_color_override(SNAME("font_color"), get_theme_color(SNAME("disabled_font_color"), SNAME("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(SNAME("GuiTabMenuHl"), SNAME("EditorIcons")));
} break;
diff --git a/editor/filesystem_dock.cpp b/editor/filesystem_dock.cpp
index 324aed5d02..c91351022f 100644
--- a/editor/filesystem_dock.cpp
+++ b/editor/filesystem_dock.cpp
@@ -338,30 +338,28 @@ void FileSystemDock::_notification(int p_what) {
EditorFileSystem::get_singleton()->connect("filesystem_changed", callable_mp(this, &FileSystemDock::_fs_changed));
EditorResourcePreview::get_singleton()->connect("preview_invalidated", callable_mp(this, &FileSystemDock::_preview_invalidated));
- String ei = "EditorIcons";
-
- button_reload->set_icon(get_theme_icon(SNAME("Reload"), ei));
- button_toggle_display_mode->set_icon(get_theme_icon(SNAME("Panels2"), ei));
+ button_reload->set_icon(get_theme_icon(SNAME("Reload"), SNAME("EditorIcons")));
+ button_toggle_display_mode->set_icon(get_theme_icon(SNAME("Panels2"), SNAME("EditorIcons")));
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(SNAME("Search"), ei));
+ tree_search_box->set_right_icon(get_theme_icon(SNAME("Search"), SNAME("EditorIcons")));
tree_search_box->set_clear_button_enabled(true);
- tree_button_sort->set_icon(get_theme_icon(SNAME("Sort"), ei));
+ tree_button_sort->set_icon(get_theme_icon(SNAME("Sort"), SNAME("EditorIcons")));
- file_list_search_box->set_right_icon(get_theme_icon(SNAME("Search"), ei));
+ file_list_search_box->set_right_icon(get_theme_icon(SNAME("Search"), SNAME("EditorIcons")));
file_list_search_box->set_clear_button_enabled(true);
- file_list_button_sort->set_icon(get_theme_icon(SNAME("Sort"), ei));
+ file_list_button_sort->set_icon(get_theme_icon(SNAME("Sort"), SNAME("EditorIcons")));
if (is_layout_rtl()) {
- button_hist_next->set_icon(get_theme_icon(SNAME("Back"), ei));
- button_hist_prev->set_icon(get_theme_icon(SNAME("Forward"), ei));
+ button_hist_next->set_icon(get_theme_icon(SNAME("Back"), SNAME("EditorIcons")));
+ button_hist_prev->set_icon(get_theme_icon(SNAME("Forward"), SNAME("EditorIcons")));
} else {
- button_hist_next->set_icon(get_theme_icon(SNAME("Forward"), ei));
- button_hist_prev->set_icon(get_theme_icon(SNAME("Back"), ei));
+ button_hist_next->set_icon(get_theme_icon(SNAME("Forward"), SNAME("EditorIcons")));
+ button_hist_prev->set_icon(get_theme_icon(SNAME("Back"), SNAME("EditorIcons")));
}
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,15 +410,14 @@ void FileSystemDock::_notification(int p_what) {
case EditorSettings::NOTIFICATION_EDITOR_SETTINGS_CHANGED: {
// Update icons.
- String ei = "EditorIcons";
- button_reload->set_icon(get_theme_icon(SNAME("Reload"), ei));
- button_toggle_display_mode->set_icon(get_theme_icon(SNAME("Panels2"), ei));
+ button_reload->set_icon(get_theme_icon(SNAME("Reload"), SNAME("EditorIcons")));
+ button_toggle_display_mode->set_icon(get_theme_icon(SNAME("Panels2"), SNAME("EditorIcons")));
if (is_layout_rtl()) {
- button_hist_next->set_icon(get_theme_icon(SNAME("Back"), ei));
- button_hist_prev->set_icon(get_theme_icon(SNAME("Forward"), ei));
+ button_hist_next->set_icon(get_theme_icon(SNAME("Back"), SNAME("EditorIcons")));
+ button_hist_prev->set_icon(get_theme_icon(SNAME("Forward"), SNAME("EditorIcons")));
} else {
- button_hist_next->set_icon(get_theme_icon(SNAME("Forward"), ei));
- button_hist_prev->set_icon(get_theme_icon(SNAME("Back"), ei));
+ button_hist_next->set_icon(get_theme_icon(SNAME("Forward"), SNAME("EditorIcons")));
+ button_hist_prev->set_icon(get_theme_icon(SNAME("Back"), SNAME("EditorIcons")));
}
if (file_list_display_mode == FILE_LIST_DISPLAY_LIST) {
button_file_list_display_mode->set_icon(get_theme_icon(SNAME("FileThumbnail"), SNAME("EditorIcons")));
@@ -428,13 +425,13 @@ void FileSystemDock::_notification(int p_what) {
button_file_list_display_mode->set_icon(get_theme_icon(SNAME("FileList"), SNAME("EditorIcons")));
}
- tree_search_box->set_right_icon(get_theme_icon(SNAME("Search"), ei));
+ tree_search_box->set_right_icon(get_theme_icon(SNAME("Search"), SNAME("EditorIcons")));
tree_search_box->set_clear_button_enabled(true);
- tree_button_sort->set_icon(get_theme_icon(SNAME("Sort"), ei));
+ tree_button_sort->set_icon(get_theme_icon(SNAME("Sort"), SNAME("EditorIcons")));
- file_list_search_box->set_right_icon(get_theme_icon(SNAME("Search"), ei));
+ file_list_search_box->set_right_icon(get_theme_icon(SNAME("Search"), SNAME("EditorIcons")));
file_list_search_box->set_clear_button_enabled(true);
- file_list_button_sort->set_icon(get_theme_icon(SNAME("Sort"), ei));
+ file_list_button_sort->set_icon(get_theme_icon(SNAME("Sort"), SNAME("EditorIcons")));
// Update always show folders.
bool new_always_show_folders = bool(EditorSettings::get_singleton()->get("docks/filesystem/always_show_folders"));
@@ -718,7 +715,6 @@ void FileSystemDock::_update_file_list(bool p_keep_selection) {
String directory = path;
String file = "";
- String ei = "EditorIcons";
int thumbnail_size = EditorSettings::get_singleton()->get("docks/filesystem/thumbnail_size");
thumbnail_size *= EDSCALE;
Ref<Texture2D> folder_thumbnail;
@@ -736,13 +732,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(SNAME("FolderMediumThumb"), ei);
- file_thumbnail = get_theme_icon(SNAME("FileMediumThumb"), ei);
- file_thumbnail_broken = get_theme_icon(SNAME("FileDeadMediumThumb"), ei);
+ folder_thumbnail = get_theme_icon(SNAME("FolderMediumThumb"), SNAME("EditorIcons"));
+ file_thumbnail = get_theme_icon(SNAME("FileMediumThumb"), SNAME("EditorIcons"));
+ file_thumbnail_broken = get_theme_icon(SNAME("FileDeadMediumThumb"), SNAME("EditorIcons"));
} else {
- 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);
+ folder_thumbnail = get_theme_icon(SNAME("FolderBigThumb"), SNAME("EditorIcons"));
+ file_thumbnail = get_theme_icon(SNAME("FileBigThumb"), SNAME("EditorIcons"));
+ file_thumbnail_broken = get_theme_icon(SNAME("FileDeadBigThumb"), SNAME("EditorIcons"));
}
} else {
// No thumbnails.
@@ -871,7 +867,6 @@ 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 (FileInfo &E : file_list) {
FileInfo *finfo = &(E);
String fname = finfo->name;
@@ -885,10 +880,10 @@ void FileSystemDock::_update_file_list(bool p_keep_selection) {
// Select the icons.
if (!finfo->import_broken) {
- type_icon = (has_theme_icon(ftype, ei)) ? get_theme_icon(ftype, ei) : get_theme_icon(oi, ei);
+ type_icon = (has_theme_icon(ftype, SNAME("EditorIcons"))) ? get_theme_icon(ftype, SNAME("EditorIcons")) : get_theme_icon(SNAME("Object"), SNAME("EditorIcons"));
big_icon = file_thumbnail;
} else {
- type_icon = get_theme_icon(SNAME("ImportFail"), ei);
+ type_icon = get_theme_icon(SNAME("ImportFail"), SNAME("EditorIcons"));
big_icon = file_thumbnail_broken;
tooltip += "\n" + TTR("Status: Import of file failed. Please fix file and reimport manually.");
}
@@ -1230,6 +1225,30 @@ void FileSystemDock::_try_duplicate_item(const FileOrFolder &p_item, const Strin
if (err != OK) {
EditorNode::get_singleton()->add_io_error(TTR("Error duplicating:") + "\n" + old_path + ".import\n");
}
+
+ // Remove uid from .import file to avoid conflict.
+ Ref<ConfigFile> cfg;
+ cfg.instantiate();
+ cfg->load(new_path + ".import");
+ cfg->erase_section_key("remap", "uid");
+ cfg->save(new_path + ".import");
+ } else if (p_item.is_file && (old_path.get_extension() == "tscn" || old_path.get_extension() == "tres")) {
+ // FIXME: Quick hack to fix text resources. This should be fixed properly.
+ FileAccessRef file = FileAccess::open(old_path, FileAccess::READ, &err);
+ if (err == OK) {
+ PackedStringArray lines = file->get_as_utf8_string().split("\n");
+ String line = lines[0];
+
+ if (line.contains("uid")) {
+ line = line.substr(0, line.find(" uid")) + "]";
+ lines.write[0] = line;
+
+ FileAccessRef file2 = FileAccess::open(new_path, FileAccess::WRITE, &err);
+ if (err == OK) {
+ file2->store_string(String("\n").join(lines));
+ }
+ }
+ }
}
} else {
EditorNode::get_singleton()->add_io_error(TTR("Error duplicating:") + "\n" + old_path + "\n");
@@ -2834,7 +2853,7 @@ FileSystemDock::FileSystemDock(EditorNode *p_editor) {
add_child(top_vbc);
HBoxContainer *toolbar_hbc = memnew(HBoxContainer);
- toolbar_hbc->add_theme_constant_override(SNAME("separation"), 0);
+ toolbar_hbc->add_theme_constant_override("separation", 0);
top_vbc->add_child(toolbar_hbc);
button_hist_prev = memnew(Button);
@@ -2873,7 +2892,7 @@ FileSystemDock::FileSystemDock(EditorNode *p_editor) {
toolbar_hbc->add_child(button_toggle_display_mode);
toolbar2_hbc = memnew(HBoxContainer);
- toolbar2_hbc->add_theme_constant_override(SNAME("separation"), 0);
+ toolbar2_hbc->add_theme_constant_override("separation", 0);
top_vbc->add_child(toolbar2_hbc);
tree_search_box = memnew(LineEdit);
diff --git a/editor/find_in_files.cpp b/editor/find_in_files.cpp
index e2e5f89e23..dd72def6ad 100644
--- a/editor/find_in_files.cpp
+++ b/editor/find_in_files.cpp
@@ -567,8 +567,8 @@ FindInFilesPanel::FindInFilesPanel() {
hbc->add_child(find_label);
_search_text_label = memnew(Label);
- _search_text_label->add_theme_font_override(SNAME("font"), EditorNode::get_singleton()->get_gui_base()->get_theme_font(SNAME("source"), SNAME("EditorFonts")));
- _search_text_label->add_theme_font_size_override(SNAME("font_size"), EditorNode::get_singleton()->get_gui_base()->get_theme_font_size(SNAME("source_size"), SNAME("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);
@@ -596,8 +596,8 @@ FindInFilesPanel::FindInFilesPanel() {
}
_results_display = memnew(Tree);
- _results_display->add_theme_font_override(SNAME("font"), EditorNode::get_singleton()->get_gui_base()->get_theme_font(SNAME("source"), SNAME("EditorFonts")));
- _results_display->add_theme_font_size_override(SNAME("font_size"), EditorNode::get_singleton()->get_gui_base()->get_theme_font_size(SNAME("source_size"), SNAME("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));
@@ -689,8 +689,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(SNAME("font"), get_theme_font(SNAME("source"), SNAME("EditorFonts")));
- _results_display->add_theme_font_override(SNAME("font"), get_theme_font(SNAME("source"), SNAME("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")));
}
}
diff --git a/editor/groups_editor.cpp b/editor/groups_editor.cpp
index 4753035686..1644bb9dbe 100644
--- a/editor/groups_editor.cpp
+++ b/editor/groups_editor.cpp
@@ -448,7 +448,7 @@ GroupDialog::GroupDialog() {
groups->set_allow_reselect(true);
groups->set_allow_rmb_select(true);
groups->set_v_size_flags(Control::SIZE_EXPAND_FILL);
- groups->add_theme_constant_override(SNAME("draw_guides"), 1);
+ groups->add_theme_constant_override("draw_guides", 1);
groups->connect("item_selected", callable_mp(this, &GroupDialog::_group_selected));
groups->connect("button_pressed", callable_mp(this, &GroupDialog::_modify_group_pressed));
groups->connect("item_edited", callable_mp(this, &GroupDialog::_group_renamed));
@@ -484,10 +484,10 @@ GroupDialog::GroupDialog() {
nodes_to_add->set_hide_folding(true);
nodes_to_add->set_select_mode(Tree::SELECT_MULTI);
nodes_to_add->set_v_size_flags(Control::SIZE_EXPAND_FILL);
- nodes_to_add->add_theme_constant_override(SNAME("draw_guides"), 1);
+ nodes_to_add->add_theme_constant_override("draw_guides", 1);
HBoxContainer *add_filter_hbc = memnew(HBoxContainer);
- add_filter_hbc->add_theme_constant_override(SNAME("separate"), 0);
+ add_filter_hbc->add_theme_constant_override("separate", 0);
vbc_add->add_child(add_filter_hbc);
add_filter = memnew(LineEdit);
@@ -534,10 +534,10 @@ GroupDialog::GroupDialog() {
nodes_to_remove->set_hide_root(true);
nodes_to_remove->set_hide_folding(true);
nodes_to_remove->set_select_mode(Tree::SELECT_MULTI);
- nodes_to_remove->add_theme_constant_override(SNAME("draw_guides"), 1);
+ nodes_to_remove->add_theme_constant_override("draw_guides", 1);
HBoxContainer *remove_filter_hbc = memnew(HBoxContainer);
- remove_filter_hbc->add_theme_constant_override(SNAME("separate"), 0);
+ remove_filter_hbc->add_theme_constant_override("separate", 0);
vbc_remove->add_child(remove_filter_hbc);
remove_filter = memnew(LineEdit);
@@ -733,8 +733,8 @@ GroupsEditor::GroupsEditor() {
tree->set_v_size_flags(Control::SIZE_EXPAND_FILL);
vbc->add_child(tree);
tree->connect("button_pressed", callable_mp(this, &GroupsEditor::_modify_group));
- tree->add_theme_constant_override(SNAME("draw_guides"), 1);
- add_theme_constant_override(SNAME("separation"), 3 * EDSCALE);
+ tree->add_theme_constant_override("draw_guides", 1);
+ add_theme_constant_override("separation", 3 * EDSCALE);
_group_name_changed("");
}
diff --git a/editor/import/dynamicfont_import_settings.cpp b/editor/import/dynamicfont_import_settings.cpp
index 6f4966dd33..244352fbb2 100644
--- a/editor/import/dynamicfont_import_settings.cpp
+++ b/editor/import/dynamicfont_import_settings.cpp
@@ -481,7 +481,7 @@ void DynamicFontImportSettings::_main_prop_changed(const String &p_edited_proper
font_preview->get_data(0)->set_oversampling(import_settings_data->get("oversampling"));
}
}
- font_preview_label->add_theme_font_override(SNAME("font"), font_preview);
+ font_preview_label->add_theme_font_override("font", font_preview);
font_preview_label->update();
}
@@ -1036,7 +1036,7 @@ void DynamicFontImportSettings::open_settings(const String &p_path) {
font_main.instantiate();
font_main->add_data(dfont_main);
- text_edit->add_theme_font_override(SNAME("font"), font_main);
+ text_edit->add_theme_font_override("font", font_main);
base_path = p_path;
@@ -1263,7 +1263,7 @@ void DynamicFontImportSettings::open_settings(const String &p_path) {
font_preview->get_data(0)->set_hinting((TextServer::Hinting)import_settings_data->get("hinting").operator int());
font_preview->get_data(0)->set_oversampling(import_settings_data->get("oversampling"));
}
- font_preview_label->add_theme_font_override(SNAME("font"), font_preview);
+ font_preview_label->add_theme_font_override("font", font_preview);
font_preview_label->update();
menu_ot->clear();
@@ -1372,7 +1372,7 @@ DynamicFontImportSettings::DynamicFontImportSettings() {
label_warn->set_horizontal_alignment(HORIZONTAL_ALIGNMENT_CENTER);
label_warn->set_text("");
root_vb->add_child(label_warn);
- label_warn->add_theme_color_override(SNAME("font_color"), warn_color);
+ label_warn->add_theme_color_override("font_color", warn_color);
label_warn->hide();
// Page 1 layout: Rendering Options
@@ -1392,7 +1392,7 @@ DynamicFontImportSettings::DynamicFontImportSettings() {
page1_vb->add_child(page1_hb);
font_preview_label = memnew(Label);
- font_preview_label->add_theme_font_size_override(SNAME("font_size"), 200 * EDSCALE);
+ font_preview_label->add_theme_font_size_override("font_size", 200 * EDSCALE);
font_preview_label->set_horizontal_alignment(HORIZONTAL_ALIGNMENT_CENTER);
font_preview_label->set_vertical_alignment(VERTICAL_ALIGNMENT_CENTER);
font_preview_label->set_autowrap_mode(Label::AUTOWRAP_ARBITRARY);
@@ -1545,9 +1545,9 @@ DynamicFontImportSettings::DynamicFontImportSettings() {
for (int i = 0; i < 16; i++) {
glyph_table->set_column_title(i + 1, String::num_int64(i, 16));
}
- glyph_table->add_theme_style_override(SNAME("selected"), glyph_table->get_theme_stylebox(SNAME("bg")));
- glyph_table->add_theme_style_override(SNAME("selected_focus"), glyph_table->get_theme_stylebox(SNAME("bg")));
- glyph_table->add_theme_constant_override(SNAME("hseparation"), 0);
+ glyph_table->add_theme_style_override("selected", glyph_table->get_theme_stylebox(SNAME("bg")));
+ glyph_table->add_theme_style_override("selected_focus", glyph_table->get_theme_stylebox(SNAME("bg")));
+ glyph_table->add_theme_constant_override("hseparation", 0);
glyph_table->set_h_size_flags(Control::SIZE_EXPAND_FILL);
glyph_table->set_v_size_flags(Control::SIZE_EXPAND_FILL);
diff --git a/editor/import/resource_importer_scene.cpp b/editor/import/resource_importer_scene.cpp
index 22a11e11cb..3eb12353b5 100644
--- a/editor/import/resource_importer_scene.cpp
+++ b/editor/import/resource_importer_scene.cpp
@@ -39,6 +39,7 @@
#include "scene/3d/importer_mesh_instance_3d.h"
#include "scene/3d/mesh_instance_3d.h"
#include "scene/3d/navigation_region_3d.h"
+#include "scene/3d/occluder_instance_3d.h"
#include "scene/3d/physics_body_3d.h"
#include "scene/3d/vehicle_body_3d.h"
#include "scene/animation/animation_player.h"
@@ -371,10 +372,10 @@ static void _pre_gen_shape_list(Ref<ImporterMesh> &mesh, Vector<Ref<Shape3D>> &r
}
}
-Node *ResourceImporterScene::_pre_fix_node(Node *p_node, Node *p_root, Map<Ref<ImporterMesh>, Vector<Ref<Shape3D>>> &collision_map, List<Pair<NodePath, Node *>> &r_node_renames) {
+Node *ResourceImporterScene::_pre_fix_node(Node *p_node, Node *p_root, Map<Ref<ImporterMesh>, Vector<Ref<Shape3D>>> &r_collision_map, Pair<PackedVector3Array, PackedInt32Array> *r_occluder_arrays, List<Pair<NodePath, Node *>> &r_node_renames) {
// Children first.
for (int i = 0; i < p_node->get_child_count(); i++) {
- Node *r = _pre_fix_node(p_node->get_child(i), p_root, collision_map, r_node_renames);
+ Node *r = _pre_fix_node(p_node->get_child(i), p_root, r_collision_map, r_occluder_arrays, r_node_renames);
if (!r) {
i--; // Was erased.
}
@@ -498,14 +499,14 @@ Node *ResourceImporterScene::_pre_fix_node(Node *p_node, Node *p_root, Map<Ref<I
if (mesh.is_valid()) {
Vector<Ref<Shape3D>> shapes;
- if (collision_map.has(mesh)) {
- shapes = collision_map[mesh];
+ if (r_collision_map.has(mesh)) {
+ shapes = r_collision_map[mesh];
} else if (_teststr(name, "colonly")) {
_pre_gen_shape_list(mesh, shapes, false);
- collision_map[mesh] = shapes;
+ r_collision_map[mesh] = shapes;
} else if (_teststr(name, "convcolonly")) {
_pre_gen_shape_list(mesh, shapes, true);
- collision_map[mesh] = shapes;
+ r_collision_map[mesh] = shapes;
}
if (shapes.size()) {
@@ -560,8 +561,8 @@ Node *ResourceImporterScene::_pre_fix_node(Node *p_node, Node *p_root, Map<Ref<I
if (mesh.is_valid()) {
Vector<Ref<Shape3D>> shapes;
- if (collision_map.has(mesh)) {
- shapes = collision_map[mesh];
+ if (r_collision_map.has(mesh)) {
+ shapes = r_collision_map[mesh];
} else {
_pre_gen_shape_list(mesh, shapes, true);
}
@@ -586,14 +587,14 @@ Node *ResourceImporterScene::_pre_fix_node(Node *p_node, Node *p_root, Map<Ref<I
if (mesh.is_valid()) {
Vector<Ref<Shape3D>> shapes;
String fixed_name;
- if (collision_map.has(mesh)) {
- shapes = collision_map[mesh];
+ if (r_collision_map.has(mesh)) {
+ shapes = r_collision_map[mesh];
} else if (_teststr(name, "col")) {
_pre_gen_shape_list(mesh, shapes, false);
- collision_map[mesh] = shapes;
+ r_collision_map[mesh] = shapes;
} else if (_teststr(name, "convcol")) {
_pre_gen_shape_list(mesh, shapes, true);
- collision_map[mesh] = shapes;
+ r_collision_map[mesh] = shapes;
}
if (_teststr(name, "col")) {
@@ -635,7 +636,31 @@ Node *ResourceImporterScene::_pre_fix_node(Node *p_node, Node *p_root, Map<Ref<I
p_node->replace_by(nmi);
memdelete(p_node);
p_node = nmi;
+ } else if (_teststr(name, "occ") || _teststr(name, "occonly")) {
+ if (isroot) {
+ return p_node;
+ }
+ ImporterMeshInstance3D *mi = Object::cast_to<ImporterMeshInstance3D>(p_node);
+ if (mi) {
+ Ref<ImporterMesh> mesh = mi->get_mesh();
+ if (mesh.is_valid()) {
+ if (r_occluder_arrays) {
+ OccluderInstance3D::bake_single_node(mi, 0.0f, r_occluder_arrays->first, r_occluder_arrays->second);
+ }
+ if (_teststr(name, "occ")) {
+ String fixed_name = _fixstr(name, "occ");
+ if (!fixed_name.is_empty()) {
+ if (mi->get_parent() && !mi->get_parent()->has_node(fixed_name)) {
+ mi->set_name(fixed_name);
+ }
+ }
+ } else {
+ memdelete(p_node);
+ p_node = nullptr;
+ }
+ }
+ }
} else if (Object::cast_to<ImporterMeshInstance3D>(p_node)) {
//last attempt, maybe collision inside the mesh data
@@ -644,16 +669,21 @@ Node *ResourceImporterScene::_pre_fix_node(Node *p_node, Node *p_root, Map<Ref<I
Ref<ImporterMesh> mesh = mi->get_mesh();
if (!mesh.is_null()) {
Vector<Ref<Shape3D>> shapes;
- if (collision_map.has(mesh)) {
- shapes = collision_map[mesh];
+ if (r_collision_map.has(mesh)) {
+ shapes = r_collision_map[mesh];
} else if (_teststr(mesh->get_name(), "col")) {
_pre_gen_shape_list(mesh, shapes, false);
- collision_map[mesh] = shapes;
+ r_collision_map[mesh] = shapes;
mesh->set_name(_fixstr(mesh->get_name(), "col"));
} else if (_teststr(mesh->get_name(), "convcol")) {
_pre_gen_shape_list(mesh, shapes, true);
- collision_map[mesh] = shapes;
+ r_collision_map[mesh] = shapes;
mesh->set_name(_fixstr(mesh->get_name(), "convcol"));
+ } else if (_teststr(mesh->get_name(), "occ")) {
+ if (r_occluder_arrays) {
+ OccluderInstance3D::bake_single_node(mi, 0.0f, r_occluder_arrays->first, r_occluder_arrays->second);
+ }
+ mesh->set_name(_fixstr(mesh->get_name(), "occ"));
}
if (shapes.size()) {
@@ -677,10 +707,10 @@ Node *ResourceImporterScene::_pre_fix_node(Node *p_node, Node *p_root, Map<Ref<I
return p_node;
}
-Node *ResourceImporterScene::_post_fix_node(Node *p_node, Node *p_root, Map<Ref<ImporterMesh>, Vector<Ref<Shape3D>>> &collision_map, Set<Ref<ImporterMesh>> &r_scanned_meshes, const Dictionary &p_node_data, const Dictionary &p_material_data, const Dictionary &p_animation_data, float p_animation_fps) {
+Node *ResourceImporterScene::_post_fix_node(Node *p_node, Node *p_root, Map<Ref<ImporterMesh>, Vector<Ref<Shape3D>>> &collision_map, Pair<PackedVector3Array, PackedInt32Array> &r_occluder_arrays, Set<Ref<ImporterMesh>> &r_scanned_meshes, const Dictionary &p_node_data, const Dictionary &p_material_data, const Dictionary &p_animation_data, float p_animation_fps) {
// children first
for (int i = 0; i < p_node->get_child_count(); i++) {
- Node *r = _post_fix_node(p_node->get_child(i), p_root, collision_map, r_scanned_meshes, p_node_data, p_material_data, p_animation_data, p_animation_fps);
+ Node *r = _post_fix_node(p_node->get_child(i), p_root, collision_map, r_occluder_arrays, r_scanned_meshes, p_node_data, p_material_data, p_animation_data, p_animation_fps);
if (!r) {
i--; //was erased
}
@@ -883,6 +913,32 @@ Node *ResourceImporterScene::_post_fix_node(Node *p_node, Node *p_root, Map<Ref<
}
}
+ if (Object::cast_to<ImporterMeshInstance3D>(p_node)) {
+ ImporterMeshInstance3D *mi = Object::cast_to<ImporterMeshInstance3D>(p_node);
+
+ Ref<ImporterMesh> m = mi->get_mesh();
+
+ if (m.is_valid()) {
+ if (node_settings.has("generate/occluder")) {
+ int occluder_mode = node_settings["generate/occluder"];
+
+ if (occluder_mode != OCCLUDER_DISABLED) {
+ float simplification_dist = 0.0f;
+ if (node_settings.has("occluder/simplification_distance")) {
+ simplification_dist = node_settings["occluder/simplification_distance"];
+ }
+
+ OccluderInstance3D::bake_single_node(mi, simplification_dist, r_occluder_arrays.first, r_occluder_arrays.second);
+
+ if (occluder_mode == OCCLUDER_OCCLUDER_ONLY) {
+ memdelete(p_node);
+ p_node = nullptr;
+ }
+ }
+ }
+ }
+ }
+
if (Object::cast_to<AnimationPlayer>(p_node)) {
AnimationPlayer *ap = Object::cast_to<AnimationPlayer>(p_node);
@@ -1255,6 +1311,9 @@ void ResourceImporterScene::get_internal_import_options(InternalImportCategory p
r_options->push_back(ImportOption(PropertyInfo(Variant::FLOAT, "primitive/radius", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_DEFAULT | PROPERTY_USAGE_UPDATE_ALL_IF_MODIFIED), 1.0));
r_options->push_back(ImportOption(PropertyInfo(Variant::VECTOR3, "primitive/position", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_DEFAULT | PROPERTY_USAGE_UPDATE_ALL_IF_MODIFIED), Vector3()));
r_options->push_back(ImportOption(PropertyInfo(Variant::VECTOR3, "primitive/rotation", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_DEFAULT | PROPERTY_USAGE_UPDATE_ALL_IF_MODIFIED), Vector3()));
+
+ r_options->push_back(ImportOption(PropertyInfo(Variant::INT, "generate/occluder", PROPERTY_HINT_ENUM, "Disabled,Mesh + Occluder,Occluder Only", PROPERTY_USAGE_DEFAULT | PROPERTY_USAGE_UPDATE_ALL_IF_MODIFIED), 0));
+ r_options->push_back(ImportOption(PropertyInfo(Variant::FLOAT, "occluder/simplification_distance", PROPERTY_HINT_RANGE, "0.0,2.0,0.01", PROPERTY_USAGE_DEFAULT | PROPERTY_USAGE_UPDATE_ALL_IF_MODIFIED), 0.1f));
} break;
case INTERNAL_IMPORT_CATEGORY_MESH: {
r_options->push_back(ImportOption(PropertyInfo(Variant::BOOL, "save_to_file/enabled", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_DEFAULT | PROPERTY_USAGE_UPDATE_ALL_IF_MODIFIED), false));
@@ -1376,6 +1435,11 @@ bool ResourceImporterScene::get_internal_option_visibility(InternalImportCategor
(physics_shape == SHAPE_TYPE_CYLINDER ||
physics_shape == SHAPE_TYPE_CAPSULE);
}
+
+ if (p_option == "occluder/simplification_distance") {
+ // Show only if occluder generation is enabled
+ return p_options.has("generate/occluder") && p_options["generate/occluder"].operator signed int() != OCCLUDER_DISABLED;
+ }
} break;
case INTERNAL_IMPORT_CATEGORY_MESH: {
if (p_option == "save_to_file/path" || p_option == "save_to_file/make_streamable") {
@@ -1869,7 +1933,7 @@ Node *ResourceImporterScene::pre_import(const String &p_source_file) {
Map<Ref<ImporterMesh>, Vector<Ref<Shape3D>>> collision_map;
List<Pair<NodePath, Node *>> node_renames;
- _pre_fix_node(scene, scene, collision_map, node_renames);
+ _pre_fix_node(scene, scene, collision_map, nullptr, node_renames);
return scene;
}
@@ -1944,15 +2008,16 @@ Error ResourceImporterScene::import(const String &p_source_file, const String &p
Set<Ref<ImporterMesh>> scanned_meshes;
Map<Ref<ImporterMesh>, Vector<Ref<Shape3D>>> collision_map;
+ Pair<PackedVector3Array, PackedInt32Array> occluder_arrays;
List<Pair<NodePath, Node *>> node_renames;
- _pre_fix_node(scene, scene, collision_map, node_renames);
+ _pre_fix_node(scene, scene, collision_map, &occluder_arrays, node_renames);
for (int i = 0; i < post_importer_plugins.size(); i++) {
post_importer_plugins.write[i]->pre_process(scene, p_options);
}
- _post_fix_node(scene, scene, collision_map, scanned_meshes, node_data, material_data, animation_data, fps);
+ _post_fix_node(scene, scene, collision_map, occluder_arrays, scanned_meshes, node_data, material_data, animation_data, fps);
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.
@@ -1989,6 +2054,15 @@ Error ResourceImporterScene::import(const String &p_source_file, const String &p
scene->set_name(p_save_path.get_file().get_basename());
}
+ if (!occluder_arrays.first.is_empty() && !occluder_arrays.second.is_empty()) {
+ Ref<ArrayOccluder3D> occ = memnew(ArrayOccluder3D);
+ occ->set_arrays(occluder_arrays.first, occluder_arrays.second);
+ OccluderInstance3D *occluder_instance = memnew(OccluderInstance3D);
+ occluder_instance->set_occluder(occ);
+ scene->add_child(occluder_instance, true);
+ occluder_instance->set_owner(scene);
+ }
+
bool gen_lods = bool(p_options["meshes/generate_lods"]);
bool create_shadow_meshes = bool(p_options["meshes/create_shadow_meshes"]);
int light_bake_mode = p_options["meshes/light_baking"];
diff --git a/editor/import/resource_importer_scene.h b/editor/import/resource_importer_scene.h
index 04fcc4268b..a819be682d 100644
--- a/editor/import/resource_importer_scene.h
+++ b/editor/import/resource_importer_scene.h
@@ -178,6 +178,12 @@ class ResourceImporterScene : public ResourceImporter {
NAVMESH_NAVMESH_ONLY,
};
+ enum OccluderMode {
+ OCCLUDER_DISABLED,
+ OCCLUDER_MESH_AND_OCCLUDER,
+ OCCLUDER_OCCLUDER_ONLY,
+ };
+
enum MeshOverride {
MESH_OVERRIDE_DEFAULT,
MESH_OVERRIDE_ENABLE,
@@ -261,8 +267,8 @@ public:
// 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<ImporterMesh>, Vector<Ref<Shape3D>>> &collision_map, List<Pair<NodePath, Node *>> &r_node_renames);
- Node *_post_fix_node(Node *p_node, Node *p_root, Map<Ref<ImporterMesh>, Vector<Ref<Shape3D>>> &collision_map, Set<Ref<ImporterMesh>> &r_scanned_meshes, const Dictionary &p_node_data, const Dictionary &p_material_data, const Dictionary &p_animation_data, float p_animation_fps);
+ Node *_pre_fix_node(Node *p_node, Node *p_root, Map<Ref<ImporterMesh>, Vector<Ref<Shape3D>>> &r_collision_map, Pair<PackedVector3Array, PackedInt32Array> *r_occluder_arrays, List<Pair<NodePath, Node *>> &r_node_renames);
+ Node *_post_fix_node(Node *p_node, Node *p_root, Map<Ref<ImporterMesh>, Vector<Ref<Shape3D>>> &collision_map, Pair<PackedVector3Array, PackedInt32Array> &r_occluder_arrays, Set<Ref<ImporterMesh>> &r_scanned_meshes, const Dictionary &p_node_data, const Dictionary &p_material_data, const Dictionary &p_animation_data, float p_animation_fps);
Ref<Animation> _save_animation_to_file(Ref<Animation> anim, bool p_save_to_file, String p_save_to_path, bool p_keep_custom_tracks);
void _create_clips(AnimationPlayer *anim, const Array &p_clips, bool p_bake_all);
diff --git a/editor/import_dock.cpp b/editor/import_dock.cpp
index b76d31ec1f..f809747410 100644
--- a/editor/import_dock.cpp
+++ b/editor/import_dock.cpp
@@ -561,12 +561,12 @@ void ImportDock::_reimport() {
void ImportDock::_notification(int p_what) {
switch (p_what) {
case EditorSettings::NOTIFICATION_EDITOR_SETTINGS_CHANGED: {
- imported->add_theme_style_override(SNAME("normal"), get_theme_stylebox(SNAME("normal"), SNAME("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(SNAME("font_color"), get_theme_color(SNAME("warning_color"), SNAME("Editor")));
+ label_warning->add_theme_color_override("font_color", get_theme_color(SNAME("warning_color"), SNAME("Editor")));
} break;
}
}
@@ -579,12 +579,12 @@ void ImportDock::_set_dirty(bool p_dirty) {
if (p_dirty) {
// Add a dirty marker to notify the user that they should reimport the selected resource to see changes.
import->set_text(TTR("Reimport") + " (*)");
- import->add_theme_color_override(SNAME("font_color"), get_theme_color(SNAME("warning_color"), SNAME("Editor")));
+ import->add_theme_color_override("font_color", get_theme_color(SNAME("warning_color"), SNAME("Editor")));
import->set_tooltip(TTR("You have pending changes that haven't been applied yet. Click Reimport to apply changes made to the import options.\nSelecting another resource in the FileSystem dock without clicking Reimport first will discard changes made in the Import dock."));
} else {
// Remove the dirty marker on the Reimport button.
import->set_text(TTR("Reimport"));
- import->remove_theme_color_override(SNAME("font_color"));
+ import->remove_theme_color_override("font_color");
import->set_tooltip("");
}
}
@@ -617,7 +617,7 @@ ImportDock::ImportDock() {
content->hide();
imported = memnew(Label);
- imported->add_theme_style_override(SNAME("normal"), EditorNode::get_singleton()->get_gui_base()->get_theme_stylebox(SNAME("normal"), SNAME("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);
content->add_child(imported);
HBoxContainer *hb = memnew(HBoxContainer);
diff --git a/editor/inspector_dock.cpp b/editor/inspector_dock.cpp
index 95e50d90b9..e36c86fb10 100644
--- a/editor/inspector_dock.cpp
+++ b/editor/inspector_dock.cpp
@@ -422,7 +422,7 @@ void InspectorDock::_notification(int p_what) {
object_menu->set_icon(get_theme_icon(SNAME("Tools"), SNAME("EditorIcons")));
search->set_right_icon(get_theme_icon(SNAME("Search"), SNAME("EditorIcons")));
warning->set_icon(get_theme_icon(SNAME("NodeWarning"), SNAME("EditorIcons")));
- warning->add_theme_color_override(SNAME("font_color"), get_theme_color(SNAME("warning_color"), SNAME("Editor")));
+ warning->add_theme_color_override("font_color", get_theme_color(SNAME("warning_color"), SNAME("Editor")));
} break;
}
}
diff --git a/editor/plugins/animation_blend_space_1d_editor.cpp b/editor/plugins/animation_blend_space_1d_editor.cpp
index 9a350437a1..3dcb769faf 100644
--- a/editor/plugins/animation_blend_space_1d_editor.cpp
+++ b/editor/plugins/animation_blend_space_1d_editor.cpp
@@ -530,9 +530,9 @@ 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(SNAME("panel"), get_theme_stylebox(SNAME("bg"), SNAME("Tree")));
- error_label->add_theme_color_override(SNAME("font_color"), get_theme_color(SNAME("error_color"), SNAME("Editor")));
- panel->add_theme_style_override(SNAME("panel"), get_theme_stylebox(SNAME("bg"), SNAME("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_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")));
diff --git a/editor/plugins/animation_blend_space_2d_editor.cpp b/editor/plugins/animation_blend_space_2d_editor.cpp
index 15d522d8e7..f9df8db419 100644
--- a/editor/plugins/animation_blend_space_2d_editor.cpp
+++ b/editor/plugins/animation_blend_space_2d_editor.cpp
@@ -730,9 +730,9 @@ 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(SNAME("panel"), get_theme_stylebox(SNAME("bg"), SNAME("Tree")));
- error_label->add_theme_color_override(SNAME("font_color"), get_theme_color(SNAME("error_color"), SNAME("Editor")));
- panel->add_theme_style_override(SNAME("panel"), get_theme_stylebox(SNAME("bg"), SNAME("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_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")));
diff --git a/editor/plugins/animation_blend_tree_editor_plugin.cpp b/editor/plugins/animation_blend_tree_editor_plugin.cpp
index 216405110b..40d6bc48e7 100644
--- a/editor/plugins/animation_blend_tree_editor_plugin.cpp
+++ b/editor/plugins/animation_blend_tree_editor_plugin.cpp
@@ -243,10 +243,10 @@ void AnimationNodeBlendTreeEditor::_update_graph() {
mono_color.a = 0.85;
c = mono_color;
- node->add_theme_color_override(SNAME("title_color"), c);
+ node->add_theme_color_override("title_color", c);
c.a = 0.7;
- node->add_theme_color_override(SNAME("close_color"), c);
- node->add_theme_color_override(SNAME("resizer_color"), c);
+ node->add_theme_color_override("close_color", c);
+ node->add_theme_color_override("resizer_color", c);
}
List<AnimationNodeBlendTree::NodeConnection> connections;
@@ -300,7 +300,7 @@ void AnimationNodeBlendTreeEditor::_add_node(int p_idx) {
base_name = add_options[p_idx].name;
} else {
ERR_FAIL_COND(add_options[p_idx].script.is_null());
- String base_type = add_options[p_idx].script->get_instance_base_type();
+ StringName base_type = add_options[p_idx].script->get_instance_base_type();
AnimationNode *an = Object::cast_to<AnimationNode>(ClassDB::instantiate(base_type));
ERR_FAIL_COND(!an);
anode = Ref<AnimationNode>(an);
@@ -739,8 +739,8 @@ void AnimationNodeBlendTreeEditor::_notification(int p_what) {
}
if (p_what == NOTIFICATION_ENTER_TREE || p_what == NOTIFICATION_THEME_CHANGED) {
- error_panel->add_theme_style_override(SNAME("panel"), get_theme_stylebox(SNAME("bg"), SNAME("Tree")));
- error_label->add_theme_color_override(SNAME("font_color"), get_theme_color(SNAME("error_color"), SNAME("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();
diff --git a/editor/plugins/animation_player_editor_plugin.cpp b/editor/plugins/animation_player_editor_plugin.cpp
index 2a1843fbf2..320c47e820 100644
--- a/editor/plugins/animation_player_editor_plugin.cpp
+++ b/editor/plugins/animation_player_editor_plugin.cpp
@@ -101,10 +101,10 @@ void AnimationPlayerEditor::_notification(int p_what) {
get_tree()->connect("node_removed", callable_mp(this, &AnimationPlayerEditor::_node_removed));
- add_theme_style_override(SNAME("panel"), editor->get_gui_base()->get_theme_stylebox(SNAME("panel"), SNAME("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(SNAME("panel"), editor->get_gui_base()->get_theme_stylebox(SNAME("panel"), SNAME("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:
@@ -137,8 +137,8 @@ void AnimationPlayerEditor::_notification(int p_what) {
pin->set_icon(get_theme_icon(SNAME("Pin"), SNAME("EditorIcons")));
- tool_anim->add_theme_style_override(SNAME("normal"), get_theme_stylebox(SNAME("normal"), SNAME("Button")));
- track_editor->get_edit_menu()->add_theme_style_override(SNAME("normal"), get_theme_stylebox(SNAME("normal"), SNAME("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(SNAME(m_icon), SNAME("EditorIcons")))
diff --git a/editor/plugins/animation_state_machine_editor.cpp b/editor/plugins/animation_state_machine_editor.cpp
index 55cbe640b3..f750c92fb3 100644
--- a/editor/plugins/animation_state_machine_editor.cpp
+++ b/editor/plugins/animation_state_machine_editor.cpp
@@ -883,9 +883,9 @@ 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(SNAME("panel"), get_theme_stylebox(SNAME("bg"), SNAME("Tree")));
- error_label->add_theme_color_override(SNAME("font_color"), get_theme_color(SNAME("error_color"), SNAME("Editor")));
- panel->add_theme_style_override(SNAME("panel"), get_theme_stylebox(SNAME("bg"), SNAME("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(SNAME("ToolSelect"), SNAME("EditorIcons")));
tool_create->set_icon(get_theme_icon(SNAME("ToolAddNode"), SNAME("EditorIcons")));
diff --git a/editor/plugins/asset_library_editor_plugin.cpp b/editor/plugins/asset_library_editor_plugin.cpp
index d11bcb5f1f..7199f69f0b 100644
--- a/editor/plugins/asset_library_editor_plugin.cpp
+++ b/editor/plugins/asset_library_editor_plugin.cpp
@@ -68,9 +68,9 @@ 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(SNAME("ProjectIconLoading"), SNAME("EditorIcons")));
- category->add_theme_color_override(SNAME("font_color"), Color(0.5, 0.5, 0.5));
- author->add_theme_color_override(SNAME("font_color"), Color(0.5, 0.5, 0.5));
- price->add_theme_color_override(SNAME("font_color"), Color(0.5, 0.5, 0.5));
+ 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));
}
}
@@ -100,11 +100,11 @@ EditorAssetLibraryItem::EditorAssetLibraryItem() {
border->set_default_margin(SIDE_RIGHT, 5 * EDSCALE);
border->set_default_margin(SIDE_BOTTOM, 5 * EDSCALE);
border->set_default_margin(SIDE_TOP, 5 * EDSCALE);
- add_theme_style_override(SNAME("panel"), border);
+ add_theme_style_override("panel", border);
HBoxContainer *hb = memnew(HBoxContainer);
// Add some spacing to visually separate the icon from the asset details.
- hb->add_theme_constant_override(SNAME("separation"), 15 * EDSCALE);
+ hb->add_theme_constant_override("separation", 15 * EDSCALE);
add_child(hb);
icon = memnew(TextureButton);
@@ -195,7 +195,7 @@ void EditorAssetLibraryItemDescription::_notification(int p_what) {
switch (p_what) {
case NOTIFICATION_ENTER_TREE:
case NOTIFICATION_THEME_CHANGED: {
- previews_bg->add_theme_style_override(SNAME("panel"), previews->get_theme_stylebox(SNAME("normal"), SNAME("TextEdit")));
+ previews_bg->add_theme_style_override("panel", previews->get_theme_stylebox(SNAME("normal"), SNAME("TextEdit")));
} break;
}
}
@@ -269,7 +269,7 @@ EditorAssetLibraryItemDescription::EditorAssetLibraryItemDescription() {
add_child(hbox);
VBoxContainer *desc_vbox = memnew(VBoxContainer);
hbox->add_child(desc_vbox);
- hbox->add_theme_constant_override(SNAME("separation"), 15 * EDSCALE);
+ hbox->add_theme_constant_override("separation", 15 * EDSCALE);
item = memnew(EditorAssetLibraryItem);
@@ -280,11 +280,11 @@ EditorAssetLibraryItemDescription::EditorAssetLibraryItemDescription() {
desc_vbox->add_child(description);
description->set_v_size_flags(Control::SIZE_EXPAND_FILL);
description->connect("meta_clicked", callable_mp(this, &EditorAssetLibraryItemDescription::_link_click));
- description->add_theme_constant_override(SNAME("line_separation"), Math::round(5 * EDSCALE));
+ description->add_theme_constant_override("line_separation", Math::round(5 * EDSCALE));
VBoxContainer *previews_vbox = memnew(VBoxContainer);
hbox->add_child(previews_vbox);
- previews_vbox->add_theme_constant_override(SNAME("separation"), 15 * EDSCALE);
+ previews_vbox->add_theme_constant_override("separation", 15 * EDSCALE);
previews_vbox->set_v_size_flags(Control::SIZE_EXPAND_FILL);
preview = memnew(TextureRect);
@@ -400,8 +400,8 @@ void EditorAssetLibraryItemDownload::_notification(int p_what) {
switch (p_what) {
case NOTIFICATION_ENTER_TREE:
case NOTIFICATION_THEME_CHANGED: {
- panel->add_theme_style_override(SNAME("panel"), get_theme_stylebox(SNAME("panel"), SNAME("AssetLib")));
- status->add_theme_color_override(SNAME("font_color"), get_theme_color(SNAME("status_color"), SNAME("AssetLib")));
+ panel->add_theme_style_override("panel", get_theme_stylebox(SNAME("panel"), SNAME("AssetLib")));
+ status->add_theme_color_override("font_color", get_theme_color(SNAME("status_color"), SNAME("AssetLib")));
dismiss_button->set_normal_texture(get_theme_icon(SNAME("dismiss"), SNAME("AssetLib")));
} break;
case NOTIFICATION_PROCESS: {
@@ -578,9 +578,9 @@ void EditorAssetLibrary::_notification(int p_what) {
case NOTIFICATION_THEME_CHANGED: {
error_tr->set_texture(get_theme_icon(SNAME("Error"), SNAME("EditorIcons")));
filter->set_right_icon(get_theme_icon(SNAME("Search"), SNAME("EditorIcons")));
- library_scroll_bg->add_theme_style_override(SNAME("panel"), get_theme_stylebox(SNAME("bg"), SNAME("Tree")));
- downloads_scroll->add_theme_style_override(SNAME("bg"), get_theme_stylebox(SNAME("bg"), SNAME("Tree")));
- error_label->add_theme_color_override(SNAME("color"), get_theme_color(SNAME("error_color"), SNAME("Editor")));
+ 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_label->add_theme_color_override("color", get_theme_color(SNAME("error_color"), SNAME("Editor")));
} break;
case NOTIFICATION_VISIBILITY_CHANGED: {
if (is_visible()) {
@@ -984,7 +984,7 @@ HBoxContainer *EditorAssetLibrary::_make_pages(int p_page, int p_page_count, int
}
hbc->add_spacer();
- hbc->add_theme_constant_override(SNAME("separation"), 5 * EDSCALE);
+ hbc->add_theme_constant_override("separation", 5 * EDSCALE);
Button *first = memnew(Button);
first->set_text(TTR("First"));
@@ -1191,8 +1191,8 @@ void EditorAssetLibrary::_http_request_completed(int p_status, int p_code, const
asset_items = memnew(GridContainer);
asset_items->set_columns(2);
- asset_items->add_theme_constant_override(SNAME("hseparation"), 10 * EDSCALE);
- asset_items->add_theme_constant_override(SNAME("vseparation"), 10 * EDSCALE);
+ asset_items->add_theme_constant_override("hseparation", 10 * EDSCALE);
+ asset_items->add_theme_constant_override("vseparation", 10 * EDSCALE);
library_vb->add_child(asset_items);
@@ -1374,7 +1374,7 @@ EditorAssetLibrary::EditorAssetLibrary(bool p_templates_only) {
HBoxContainer *search_hb = memnew(HBoxContainer);
library_main->add_child(search_hb);
- library_main->add_theme_constant_override(SNAME("separation"), 10 * EDSCALE);
+ library_main->add_theme_constant_override("separation", 10 * EDSCALE);
filter = memnew(LineEdit);
if (templates_only) {
@@ -1482,7 +1482,7 @@ EditorAssetLibrary::EditorAssetLibrary(bool p_templates_only) {
PanelContainer *library_vb_border = memnew(PanelContainer);
library_scroll->add_child(library_vb_border);
- library_vb_border->add_theme_style_override(SNAME("panel"), border2);
+ library_vb_border->add_theme_style_override("panel", border2);
library_vb_border->set_h_size_flags(Control::SIZE_EXPAND_FILL);
library_vb = memnew(VBoxContainer);
@@ -1504,8 +1504,8 @@ EditorAssetLibrary::EditorAssetLibrary(bool p_templates_only) {
asset_items = memnew(GridContainer);
asset_items->set_columns(2);
- asset_items->add_theme_constant_override(SNAME("hseparation"), 10 * EDSCALE);
- asset_items->add_theme_constant_override(SNAME("vseparation"), 10 * EDSCALE);
+ asset_items->add_theme_constant_override("hseparation", 10 * EDSCALE);
+ asset_items->add_theme_constant_override("vseparation", 10 * EDSCALE);
library_vb->add_child(asset_items);
@@ -1519,7 +1519,7 @@ EditorAssetLibrary::EditorAssetLibrary(bool p_templates_only) {
last_queue_id = 0;
- library_vb->add_theme_constant_override(SNAME("separation"), 20 * EDSCALE);
+ library_vb->add_theme_constant_override("separation", 20 * EDSCALE);
error_hb = memnew(HBoxContainer);
library_main->add_child(error_hb);
diff --git a/editor/plugins/audio_stream_editor_plugin.cpp b/editor/plugins/audio_stream_editor_plugin.cpp
index e20e6dc9ea..086d5474ba 100644
--- a/editor/plugins/audio_stream_editor_plugin.cpp
+++ b/editor/plugins/audio_stream_editor_plugin.cpp
@@ -224,7 +224,7 @@ AudioStreamEditor::AudioStreamEditor() {
_preview->add_child(_indicator);
HBoxContainer *hbox = memnew(HBoxContainer);
- hbox->add_theme_constant_override(SNAME("separation"), 0);
+ hbox->add_theme_constant_override("separation", 0);
vbox->add_child(hbox);
_play_button = memnew(Button);
@@ -243,14 +243,14 @@ AudioStreamEditor::AudioStreamEditor() {
_current_label = memnew(Label);
_current_label->set_horizontal_alignment(HORIZONTAL_ALIGNMENT_RIGHT);
_current_label->set_h_size_flags(SIZE_EXPAND_FILL);
- _current_label->add_theme_font_override(SNAME("font"), EditorNode::get_singleton()->get_gui_base()->get_theme_font(SNAME("status_source"), SNAME("EditorFonts")));
- _current_label->add_theme_font_size_override(SNAME("font_size"), EditorNode::get_singleton()->get_gui_base()->get_theme_font_size(SNAME("status_source_size"), SNAME("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(SNAME("font"), EditorNode::get_singleton()->get_gui_base()->get_theme_font(SNAME("status_source"), SNAME("EditorFonts")));
- _duration_label->add_theme_font_size_override(SNAME("font_size"), EditorNode::get_singleton()->get_gui_base()->get_theme_font_size(SNAME("status_source_size"), SNAME("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/audio_stream_randomizer_editor_plugin.cpp b/editor/plugins/audio_stream_randomizer_editor_plugin.cpp
new file mode 100644
index 0000000000..fea3c29967
--- /dev/null
+++ b/editor/plugins/audio_stream_randomizer_editor_plugin.cpp
@@ -0,0 +1,119 @@
+/*************************************************************************/
+/* audio_stream_randomizer_editor_plugin.cpp */
+/*************************************************************************/
+/* This file is part of: */
+/* GODOT ENGINE */
+/* https://godotengine.org */
+/*************************************************************************/
+/* Copyright (c) 2007-2022 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2014-2022 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 "audio_stream_randomizer_editor_plugin.h"
+
+void AudioStreamRandomizerEditorPlugin::edit(Object *p_object) {
+}
+
+bool AudioStreamRandomizerEditorPlugin::handles(Object *p_object) const {
+ return false;
+}
+
+void AudioStreamRandomizerEditorPlugin::make_visible(bool p_visible) {
+}
+
+void AudioStreamRandomizerEditorPlugin::_move_stream_array_element(Object *p_undo_redo, Object *p_edited, String p_array_prefix, int p_from_index, int p_to_pos) {
+ UndoRedo *undo_redo = Object::cast_to<UndoRedo>(p_undo_redo);
+ ERR_FAIL_COND(!undo_redo);
+
+ AudioStreamRandomizer *randomizer = Object::cast_to<AudioStreamRandomizer>(p_edited);
+ if (!randomizer) {
+ return;
+ }
+
+ // Compute the array indices to save.
+ int begin = 0;
+ int end;
+ if (p_array_prefix == "stream_") {
+ end = randomizer->get_streams_count();
+ } else {
+ ERR_FAIL_MSG("Invalid array prefix for AudioStreamRandomizer.");
+ }
+ if (p_from_index < 0) {
+ // Adding new.
+ if (p_to_pos >= 0) {
+ begin = p_to_pos;
+ } else {
+ end = 0; // Nothing to save when adding at the end.
+ }
+ } else if (p_to_pos < 0) {
+ // Removing.
+ begin = p_from_index;
+ } else {
+ // Moving.
+ begin = MIN(p_from_index, p_to_pos);
+ end = MIN(MAX(p_from_index, p_to_pos) + 1, end);
+ }
+
+#define ADD_UNDO(obj, property) undo_redo->add_undo_property(obj, property, obj->get(property));
+ // Save layers' properties.
+ if (p_from_index < 0) {
+ undo_redo->add_undo_method(randomizer, "remove_stream", p_to_pos < 0 ? randomizer->get_streams_count() : p_to_pos);
+ } else if (p_to_pos < 0) {
+ undo_redo->add_undo_method(randomizer, "add_stream", p_from_index);
+ }
+
+ List<PropertyInfo> properties;
+ randomizer->get_property_list(&properties);
+ for (PropertyInfo pi : properties) {
+ if (pi.name.begins_with(p_array_prefix)) {
+ String str = pi.name.trim_prefix(p_array_prefix);
+ int to_char_index = 0;
+ while (to_char_index < str.length()) {
+ if (str[to_char_index] < '0' || str[to_char_index] > '9') {
+ break;
+ }
+ to_char_index++;
+ }
+ if (to_char_index > 0) {
+ int array_index = str.left(to_char_index).to_int();
+ if (array_index >= begin && array_index < end) {
+ ADD_UNDO(randomizer, pi.name);
+ }
+ }
+ }
+ }
+#undef ADD_UNDO
+
+ if (p_from_index < 0) {
+ undo_redo->add_do_method(randomizer, "add_stream", p_to_pos);
+ } else if (p_to_pos < 0) {
+ undo_redo->add_do_method(randomizer, "remove_stream", p_from_index);
+ } else {
+ undo_redo->add_do_method(randomizer, "move_stream", p_from_index, p_to_pos);
+ }
+}
+
+AudioStreamRandomizerEditorPlugin::AudioStreamRandomizerEditorPlugin(EditorNode *p_node) {
+ EditorNode::get_singleton()->get_editor_data().add_move_array_element_function(SNAME("AudioStreamRandomizer"), callable_mp(this, &AudioStreamRandomizerEditorPlugin::_move_stream_array_element));
+}
+
+AudioStreamRandomizerEditorPlugin::~AudioStreamRandomizerEditorPlugin() {}
diff --git a/editor/plugins/audio_stream_randomizer_editor_plugin.h b/editor/plugins/audio_stream_randomizer_editor_plugin.h
new file mode 100644
index 0000000000..490af7e2c2
--- /dev/null
+++ b/editor/plugins/audio_stream_randomizer_editor_plugin.h
@@ -0,0 +1,57 @@
+/*************************************************************************/
+/* audio_stream_randomizer_editor_plugin.h */
+/*************************************************************************/
+/* This file is part of: */
+/* GODOT ENGINE */
+/* https://godotengine.org */
+/*************************************************************************/
+/* Copyright (c) 2007-2022 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2014-2022 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 AUDIO_STREAM_RANDOMIZER_EDITOR_PLUGIN_H
+#define AUDIO_STREAM_RANDOMIZER_EDITOR_PLUGIN_H
+
+#include "editor/editor_node.h"
+#include "editor/editor_plugin.h"
+#include "servers/audio/audio_stream.h"
+
+class AudioStreamRandomizerEditorPlugin : public EditorPlugin {
+ GDCLASS(AudioStreamRandomizerEditorPlugin, EditorPlugin);
+
+ EditorNode *editor;
+
+private:
+ void _move_stream_array_element(Object *p_undo_redo, Object *p_edited, String p_array_prefix, int p_from_index, int p_to_pos);
+
+public:
+ virtual String get_name() const override { return "AudioStreamRandomizer"; }
+ bool has_main_screen() const override { return false; }
+ virtual void edit(Object *p_object) override;
+ virtual bool handles(Object *p_object) const override;
+ virtual void make_visible(bool p_visible) override;
+
+ AudioStreamRandomizerEditorPlugin(EditorNode *p_node);
+ ~AudioStreamRandomizerEditorPlugin();
+};
+
+#endif // AUDIO_STREAM_RANDOMIZER_EDITOR_PLUGIN_H
diff --git a/editor/plugins/canvas_item_editor_plugin.cpp b/editor/plugins/canvas_item_editor_plugin.cpp
index 4a7c8d7d01..aa8ad55ff3 100644
--- a/editor/plugins/canvas_item_editor_plugin.cpp
+++ b/editor/plugins/canvas_item_editor_plugin.cpp
@@ -3847,7 +3847,7 @@ void CanvasItemEditor::_notification(int p_what) {
// 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(SNAME("icon_pressed_color"), key_auto_color.lerp(Color(1, 0, 0), 0.55));
+ 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(SNAME("GuiTabMenuHl"), SNAME("EditorIcons")));
_update_context_menu_stylebox();
@@ -3967,7 +3967,7 @@ void CanvasItemEditor::_update_context_menu_stylebox() {
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(SNAME("panel"), context_menu_stylebox);
+ context_menu_container->add_theme_style_override("panel", context_menu_stylebox);
}
void CanvasItemEditor::_update_scrollbars() {
@@ -5804,7 +5804,7 @@ void CanvasItemEditorViewport::_create_nodes(Node *parent, Node *child, String &
}
// make visible for certain node type
- if (ClassDB::is_parent_class(child->get_class(), "Control")) {
+ if (Object::cast_to<Control>(child)) {
Size2 texture_size = texture->get_size();
editor_data->get_undo_redo().add_do_property(child, "rect_size", texture_size);
} else if (Object::cast_to<Polygon2D>(child)) {
@@ -5935,29 +5935,32 @@ bool CanvasItemEditorViewport::can_drop_data(const Point2 &p_point, const Varian
if (String(d["type"]) == "files") {
Vector<String> files = d["files"];
bool can_instantiate = false;
- for (int i = 0; i < files.size(); i++) { // check if dragged files contain resource or scene can be created at least once
- RES res = ResourceLoader::load(files[i]);
- if (res.is_null()) {
- continue;
- }
- String type = res->get_class();
- if (type == "PackedScene") {
- Ref<PackedScene> sdata = Ref<PackedScene>(Object::cast_to<PackedScene>(*res));
- Node *instantiated_scene = sdata->instantiate(PackedScene::GEN_EDIT_STATE_INSTANCE);
- if (!instantiated_scene) {
+
+ List<String> scene_extensions;
+ ResourceLoader::get_recognized_extensions_for_type("PackedScene", &scene_extensions);
+ List<String> texture_extensions;
+ ResourceLoader::get_recognized_extensions_for_type("Texture2D", &texture_extensions);
+
+ for (int i = 0; i < files.size(); i++) {
+ // Check if dragged files with texture or scene extension can be created at least once.
+ if (texture_extensions.find(files[i].get_extension()) || scene_extensions.find(files[i].get_extension())) {
+ RES res = ResourceLoader::load(files[i]);
+ if (res.is_null()) {
continue;
}
- memdelete(instantiated_scene);
- } else if (ClassDB::is_parent_class(type, "Texture2D")) {
- Ref<Texture2D> texture = Ref<Texture2D>(Object::cast_to<Texture2D>(*res));
- if (!texture.is_valid()) {
+ Ref<PackedScene> scn = res;
+ if (scn.is_valid()) {
+ Node *instantiated_scene = scn->instantiate(PackedScene::GEN_EDIT_STATE_INSTANCE);
+ if (!instantiated_scene) {
+ continue;
+ }
+ memdelete(instantiated_scene);
+ } else {
continue;
}
- } else {
- continue;
+ can_instantiate = true;
+ break;
}
- can_instantiate = true;
- break;
}
if (can_instantiate) {
if (!preview_node->get_parent()) { // create preview only once
@@ -6073,7 +6076,7 @@ void CanvasItemEditorViewport::_notification(int p_what) {
check->set_icon(get_theme_icon(check->get_text(), SNAME("EditorIcons")));
}
- label->add_theme_color_override(SNAME("font_color"), get_theme_color(SNAME("warning_color"), SNAME("Editor")));
+ label->add_theme_color_override("font_color", get_theme_color(SNAME("warning_color"), SNAME("Editor")));
}
switch (p_what) {
@@ -6141,16 +6144,16 @@ CanvasItemEditorViewport::CanvasItemEditorViewport(EditorNode *p_node, CanvasIte
}
label = memnew(Label);
- label->add_theme_color_override(SNAME("font_shadow_color"), Color(0, 0, 0, 1));
- label->add_theme_constant_override(SNAME("shadow_outline_size"), 1 * EDSCALE);
+ label->add_theme_color_override("font_shadow_color", Color(0, 0, 0, 1));
+ label->add_theme_constant_override("shadow_outline_size", 1 * EDSCALE);
label->hide();
canvas_item_editor->get_controls_container()->add_child(label);
label_desc = memnew(Label);
- label_desc->add_theme_color_override(SNAME("font_color"), Color(0.6f, 0.6f, 0.6f, 1));
- label_desc->add_theme_color_override(SNAME("font_shadow_color"), Color(0.2f, 0.2f, 0.2f, 1));
- label_desc->add_theme_constant_override(SNAME("shadow_outline_size"), 1 * EDSCALE);
- label_desc->add_theme_constant_override(SNAME("line_spacing"), 0);
+ 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_outline_size", 1 * EDSCALE);
+ label_desc->add_theme_constant_override("line_spacing", 0);
label_desc->hide();
canvas_item_editor->get_controls_container()->add_child(label_desc);
diff --git a/editor/plugins/debugger_editor_plugin.cpp b/editor/plugins/debugger_editor_plugin.cpp
index 3042132a4d..6e43130a92 100644
--- a/editor/plugins/debugger_editor_plugin.cpp
+++ b/editor/plugins/debugger_editor_plugin.cpp
@@ -54,7 +54,7 @@ DebuggerEditorPlugin::DebuggerEditorPlugin(EditorNode *p_editor, MenuButton *p_d
EditorDebuggerNode *debugger = memnew(EditorDebuggerNode);
Button *db = EditorNode::get_singleton()->add_bottom_panel_item(TTR("Debugger"), debugger);
// Add separation for the warning/error icon that is displayed later.
- db->add_theme_constant_override(SNAME("hseparation"), 6 * EDSCALE);
+ db->add_theme_constant_override("hseparation", 6 * EDSCALE);
debugger->set_tool_button(db);
// Main editor debug menu.
diff --git a/editor/plugins/editor_preview_plugins.cpp b/editor/plugins/editor_preview_plugins.cpp
index 7e0019faac..d23b52014e 100644
--- a/editor/plugins/editor_preview_plugins.cpp
+++ b/editor/plugins/editor_preview_plugins.cpp
@@ -188,7 +188,7 @@ bool EditorImagePreviewPlugin::generate_small_preview_automatically() const {
}
////////////////////////////////////////////////////////////////////////////
-/////////////////////////////////////////////////
+
bool EditorBitmapPreviewPlugin::handles(const String &p_type) const {
return ClassDB::is_parent_class(p_type, "BitMap");
}
@@ -308,7 +308,7 @@ void EditorMaterialPreviewPlugin::_preview_done() {
}
bool EditorMaterialPreviewPlugin::handles(const String &p_type) const {
- return ClassDB::is_parent_class(p_type, "Material"); //any material
+ return ClassDB::is_parent_class(p_type, "Material"); // Any material.
}
bool EditorMaterialPreviewPlugin::generate_small_preview_automatically() const {
@@ -699,7 +699,7 @@ void EditorMeshPreviewPlugin::_preview_done() {
}
bool EditorMeshPreviewPlugin::handles(const String &p_type) const {
- return ClassDB::is_parent_class(p_type, "Mesh"); //any Mesh
+ return ClassDB::is_parent_class(p_type, "Mesh"); // Any mesh.
}
Ref<Texture2D> EditorMeshPreviewPlugin::generate(const RES &p_from, const Size2 &p_size) const {
diff --git a/editor/plugins/input_event_editor_plugin.cpp b/editor/plugins/input_event_editor_plugin.cpp
index e8497c620e..b0ee88479a 100644
--- a/editor/plugins/input_event_editor_plugin.cpp
+++ b/editor/plugins/input_event_editor_plugin.cpp
@@ -76,10 +76,10 @@ void InputEventConfigContainer::set_event(const Ref<InputEvent> &p_event) {
InputEventConfigContainer::InputEventConfigContainer() {
MarginContainer *mc = memnew(MarginContainer);
- mc->add_theme_constant_override(SNAME("margin_left"), 10);
- mc->add_theme_constant_override(SNAME("margin_right"), 10);
- mc->add_theme_constant_override(SNAME("margin_top"), 10);
- mc->add_theme_constant_override(SNAME("margin_bottom"), 10);
+ mc->add_theme_constant_override("margin_left", 10);
+ mc->add_theme_constant_override("margin_right", 10);
+ mc->add_theme_constant_override("margin_top", 10);
+ mc->add_theme_constant_override("margin_bottom", 10);
add_child(mc);
HBoxContainer *hb = memnew(HBoxContainer);
diff --git a/editor/plugins/node_3d_editor_gizmos.cpp b/editor/plugins/node_3d_editor_gizmos.cpp
index 88d2aee667..b4b1cf05ac 100644
--- a/editor/plugins/node_3d_editor_gizmos.cpp
+++ b/editor/plugins/node_3d_editor_gizmos.cpp
@@ -1889,6 +1889,7 @@ void MeshInstance3DGizmoPlugin::redraw(EditorNode3DGizmo *p_gizmo) {
OccluderInstance3DGizmoPlugin::OccluderInstance3DGizmoPlugin() {
create_material("line_material", EDITOR_DEF("editors/3d_gizmos/gizmo_colors/occluder", Color(0.8, 0.5, 1)));
+ create_handle_material("handles");
}
bool OccluderInstance3DGizmoPlugin::has_gizmo(Node3D *p_spatial) {
@@ -1903,6 +1904,189 @@ int OccluderInstance3DGizmoPlugin::get_priority() const {
return -1;
}
+String OccluderInstance3DGizmoPlugin::get_handle_name(const EditorNode3DGizmo *p_gizmo, int p_id, bool p_secondary) const {
+ const OccluderInstance3D *cs = Object::cast_to<OccluderInstance3D>(p_gizmo->get_spatial_node());
+
+ Ref<Occluder3D> o = cs->get_occluder();
+ if (o.is_null()) {
+ return "";
+ }
+
+ if (Object::cast_to<SphereOccluder3D>(*o)) {
+ return "Radius";
+ }
+
+ if (Object::cast_to<BoxOccluder3D>(*o) || Object::cast_to<QuadOccluder3D>(*o)) {
+ return "Size";
+ }
+
+ return "";
+}
+
+Variant OccluderInstance3DGizmoPlugin::get_handle_value(const EditorNode3DGizmo *p_gizmo, int p_id, bool p_secondary) const {
+ OccluderInstance3D *oi = Object::cast_to<OccluderInstance3D>(p_gizmo->get_spatial_node());
+
+ Ref<Occluder3D> o = oi->get_occluder();
+ if (o.is_null()) {
+ return Variant();
+ }
+
+ if (Object::cast_to<SphereOccluder3D>(*o)) {
+ Ref<SphereOccluder3D> so = o;
+ return so->get_radius();
+ }
+
+ if (Object::cast_to<BoxOccluder3D>(*o)) {
+ Ref<BoxOccluder3D> bo = o;
+ return bo->get_size();
+ }
+
+ if (Object::cast_to<QuadOccluder3D>(*o)) {
+ Ref<QuadOccluder3D> qo = o;
+ return qo->get_size();
+ }
+
+ return Variant();
+}
+
+void OccluderInstance3DGizmoPlugin::set_handle(const EditorNode3DGizmo *p_gizmo, int p_id, bool p_secondary, Camera3D *p_camera, const Point2 &p_point) {
+ OccluderInstance3D *oi = Object::cast_to<OccluderInstance3D>(p_gizmo->get_spatial_node());
+
+ Ref<Occluder3D> o = oi->get_occluder();
+ if (o.is_null()) {
+ return;
+ }
+
+ Transform3D gt = oi->get_global_transform();
+ Transform3D gi = gt.affine_inverse();
+
+ Vector3 ray_from = p_camera->project_ray_origin(p_point);
+ Vector3 ray_dir = p_camera->project_ray_normal(p_point);
+
+ Vector3 sg[2] = { gi.xform(ray_from), gi.xform(ray_from + ray_dir * 4096) };
+
+ bool snap_enabled = Node3DEditor::get_singleton()->is_snap_enabled();
+ float snap = Node3DEditor::get_singleton()->get_translate_snap();
+
+ if (Object::cast_to<SphereOccluder3D>(*o)) {
+ Ref<SphereOccluder3D> so = o;
+ Vector3 ra, rb;
+ Geometry3D::get_closest_points_between_segments(Vector3(), Vector3(4096, 0, 0), sg[0], sg[1], ra, rb);
+ float d = ra.x;
+ if (snap_enabled) {
+ d = Math::snapped(d, snap);
+ }
+
+ if (d < 0.001) {
+ d = 0.001;
+ }
+
+ so->set_radius(d);
+ }
+
+ if (Object::cast_to<BoxOccluder3D>(*o)) {
+ Vector3 axis;
+ axis[p_id] = 1.0;
+ Ref<BoxOccluder3D> bo = o;
+ Vector3 ra, rb;
+ Geometry3D::get_closest_points_between_segments(Vector3(), axis * 4096, sg[0], sg[1], ra, rb);
+ float d = ra[p_id];
+ if (snap_enabled) {
+ d = Math::snapped(d, snap);
+ }
+
+ if (d < 0.001) {
+ d = 0.001;
+ }
+
+ Vector3 he = bo->get_size();
+ he[p_id] = d * 2;
+ bo->set_size(he);
+ }
+
+ if (Object::cast_to<QuadOccluder3D>(*o)) {
+ Ref<QuadOccluder3D> qo = o;
+ Plane p = Plane(Vector3(0.0f, 0.0f, 1.0f), 0.0f);
+ Vector3 intersection;
+ if (!p.intersects_segment(sg[0], sg[1], &intersection)) {
+ return;
+ }
+
+ if (p_id == 2) {
+ Vector2 s = Vector2(intersection.x, intersection.y) * 2.0f;
+ if (snap_enabled) {
+ s = s.snapped(Vector2(snap, snap));
+ }
+ s = s.max(Vector2(0.001, 0.001));
+ qo->set_size(s);
+ } else {
+ float d = intersection[p_id];
+ if (snap_enabled) {
+ d = Math::snapped(d, snap);
+ }
+
+ if (d < 0.001) {
+ d = 0.001;
+ }
+
+ Vector2 he = qo->get_size();
+ he[p_id] = d * 2.0f;
+ qo->set_size(he);
+ }
+ }
+}
+
+void OccluderInstance3DGizmoPlugin::commit_handle(const EditorNode3DGizmo *p_gizmo, int p_id, bool p_secondary, const Variant &p_restore, bool p_cancel) {
+ OccluderInstance3D *oi = Object::cast_to<OccluderInstance3D>(p_gizmo->get_spatial_node());
+
+ Ref<Occluder3D> o = oi->get_occluder();
+ if (o.is_null()) {
+ return;
+ }
+
+ if (Object::cast_to<SphereOccluder3D>(*o)) {
+ Ref<SphereOccluder3D> so = o;
+ if (p_cancel) {
+ so->set_radius(p_restore);
+ return;
+ }
+
+ UndoRedo *ur = Node3DEditor::get_singleton()->get_undo_redo();
+ ur->create_action(TTR("Change Sphere Shape Radius"));
+ ur->add_do_method(so.ptr(), "set_radius", so->get_radius());
+ ur->add_undo_method(so.ptr(), "set_radius", p_restore);
+ ur->commit_action();
+ }
+
+ if (Object::cast_to<BoxOccluder3D>(*o)) {
+ Ref<BoxOccluder3D> bo = o;
+ if (p_cancel) {
+ bo->set_size(p_restore);
+ return;
+ }
+
+ UndoRedo *ur = Node3DEditor::get_singleton()->get_undo_redo();
+ ur->create_action(TTR("Change Box Shape Size"));
+ ur->add_do_method(bo.ptr(), "set_size", bo->get_size());
+ ur->add_undo_method(bo.ptr(), "set_size", p_restore);
+ ur->commit_action();
+ }
+
+ if (Object::cast_to<QuadOccluder3D>(*o)) {
+ Ref<QuadOccluder3D> qo = o;
+ if (p_cancel) {
+ qo->set_size(p_restore);
+ return;
+ }
+
+ UndoRedo *ur = Node3DEditor::get_singleton()->get_undo_redo();
+ ur->create_action(TTR("Change Box Shape Size"));
+ ur->add_do_method(qo.ptr(), "set_size", qo->get_size());
+ ur->add_undo_method(qo.ptr(), "set_size", p_restore);
+ ur->commit_action();
+ }
+}
+
void OccluderInstance3DGizmoPlugin::redraw(EditorNode3DGizmo *p_gizmo) {
OccluderInstance3D *occluder_instance = Object::cast_to<OccluderInstance3D>(p_gizmo->get_spatial_node());
@@ -1920,6 +2104,35 @@ void OccluderInstance3DGizmoPlugin::redraw(EditorNode3DGizmo *p_gizmo) {
p_gizmo->add_lines(lines, material);
p_gizmo->add_collision_segments(lines);
}
+
+ Ref<Material> handles_material = get_material("handles");
+ if (Object::cast_to<SphereOccluder3D>(*o)) {
+ Ref<SphereOccluder3D> so = o;
+ float r = so->get_radius();
+ Vector<Vector3> handles = { Vector3(r, 0, 0) };
+ p_gizmo->add_handles(handles, handles_material);
+ }
+
+ if (Object::cast_to<BoxOccluder3D>(*o)) {
+ Ref<BoxOccluder3D> bo = o;
+
+ Vector<Vector3> handles;
+ for (int i = 0; i < 3; i++) {
+ Vector3 ax;
+ ax[i] = bo->get_size()[i] / 2;
+ handles.push_back(ax);
+ }
+
+ p_gizmo->add_handles(handles, handles_material);
+ }
+
+ if (Object::cast_to<QuadOccluder3D>(*o)) {
+ Ref<QuadOccluder3D> qo = o;
+ Vector2 size = qo->get_size();
+ Vector3 s = Vector3(size.x, size.y, 0.0f) / 2.0f;
+ Vector<Vector3> handles = { Vector3(s.x, 0.0f, 0.0f), Vector3(0.0f, s.y, 0.0f), Vector3(s.x, s.y, 0.0f) };
+ p_gizmo->add_handles(handles, handles_material);
+ }
}
/////
diff --git a/editor/plugins/node_3d_editor_gizmos.h b/editor/plugins/node_3d_editor_gizmos.h
index 66b3f02fcf..fa55651d26 100644
--- a/editor/plugins/node_3d_editor_gizmos.h
+++ b/editor/plugins/node_3d_editor_gizmos.h
@@ -300,6 +300,11 @@ public:
int get_priority() const override;
void redraw(EditorNode3DGizmo *p_gizmo) override;
+ String get_handle_name(const EditorNode3DGizmo *p_gizmo, int p_id, bool p_secondary) const override;
+ Variant get_handle_value(const EditorNode3DGizmo *p_gizmo, int p_id, bool p_secondary) const override;
+ void set_handle(const EditorNode3DGizmo *p_gizmo, int p_id, bool p_secondary, Camera3D *p_camera, const Point2 &p_point) override;
+ void commit_handle(const EditorNode3DGizmo *p_gizmo, int p_id, bool p_secondary, const Variant &p_restore, bool p_cancel = false) override;
+
OccluderInstance3DGizmoPlugin();
};
diff --git a/editor/plugins/node_3d_editor_plugin.cpp b/editor/plugins/node_3d_editor_plugin.cpp
index b069cbc0bf..2e8ae1a286 100644
--- a/editor/plugins/node_3d_editor_plugin.cpp
+++ b/editor/plugins/node_3d_editor_plugin.cpp
@@ -384,6 +384,28 @@ int Node3DEditorViewport::get_selected_count() const {
return count;
}
+void Node3DEditorViewport::cancel_transform() {
+ _edit.mode = TRANSFORM_NONE;
+
+ 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 *se = editor_selection->get_node_editor_data<Node3DEditorSelectedItem>(sp);
+ if (!se) {
+ continue;
+ }
+
+ sp->set_global_transform(se->original);
+ }
+ surface->update();
+ set_message(TTR("Transform Aborted."), 3);
+}
+
float Node3DEditorViewport::get_znear() const {
return CLAMP(spatial_editor->get_znear(), MIN_Z, MAX_Z);
}
@@ -865,6 +887,7 @@ void Node3DEditorViewport::_update_name() {
}
void Node3DEditorViewport::_compute_edit(const Point2 &p_point) {
+ _edit.original_local = spatial_editor->are_local_coords_enabled();
_edit.click_ray = _get_ray(p_point);
_edit.click_ray_pos = _get_ray_pos(p_point);
_edit.plane = TRANSFORM_VIEW;
@@ -1018,24 +1041,40 @@ bool Node3DEditorViewport::_transform_gizmo_select(const Vector2 &p_screenpos, b
if (spatial_editor->get_tool_mode() == Node3DEditor::TOOL_MODE_SELECT || spatial_editor->get_tool_mode() == Node3DEditor::TOOL_MODE_ROTATE) {
int col_axis = -1;
- float col_d = 1e20;
- for (int i = 0; i < 3; i++) {
- Plane plane(gt.basis.get_axis(i).normalized(), gt.origin);
- Vector3 r;
- if (!plane.intersects_ray(ray_pos, ray, &r)) {
- continue;
+ Vector3 hit_position;
+ Vector3 hit_normal;
+ real_t ray_length = gt.origin.distance_to(ray_pos) + (GIZMO_CIRCLE_SIZE * gizmo_scale) * 4.0f;
+ if (Geometry3D::segment_intersects_sphere(ray_pos, ray_pos + ray * ray_length, gt.origin, gizmo_scale * (GIZMO_CIRCLE_SIZE), &hit_position, &hit_normal)) {
+ if (hit_normal.dot(_get_camera_normal()) < 0.05) {
+ hit_position = gt.xform_inv(hit_position).abs();
+ int min_axis = hit_position.min_axis_index();
+ if (hit_position[min_axis] < gizmo_scale * GIZMO_RING_HALF_WIDTH) {
+ col_axis = min_axis;
+ }
}
+ }
+
+ if (col_axis == -1) {
+ float col_d = 1e20;
- const real_t dist = r.distance_to(gt.origin);
- const Vector3 r_dir = (r - gt.origin).normalized();
+ for (int i = 0; i < 3; i++) {
+ Plane plane(gt.basis.get_axis(i).normalized(), gt.origin);
+ Vector3 r;
+ if (!plane.intersects_ray(ray_pos, ray, &r)) {
+ continue;
+ }
+
+ const real_t dist = r.distance_to(gt.origin);
+ const Vector3 r_dir = (r - gt.origin).normalized();
- if (_get_camera_normal().dot(r_dir) <= 0.005) {
- if (dist > gizmo_scale * (GIZMO_CIRCLE_SIZE - GIZMO_RING_HALF_WIDTH) && dist < gizmo_scale * (GIZMO_CIRCLE_SIZE + GIZMO_RING_HALF_WIDTH)) {
- const real_t d = ray_pos.distance_to(r);
- if (d < col_d) {
- col_d = d;
- col_axis = i;
+ if (_get_camera_normal().dot(r_dir) <= 0.005) {
+ if (dist > gizmo_scale * (GIZMO_CIRCLE_SIZE - GIZMO_RING_HALF_WIDTH) && dist < gizmo_scale * (GIZMO_CIRCLE_SIZE + GIZMO_RING_HALF_WIDTH)) {
+ const real_t d = ray_pos.distance_to(r);
+ if (d < col_d) {
+ col_d = d;
+ col_axis = i;
+ }
}
}
}
@@ -1375,39 +1414,7 @@ void Node3DEditorViewport::_sinput(const Ref<InputEvent> &p_event) {
}
if (_edit.mode != TRANSFORM_NONE && b->is_pressed()) {
- //cancel motion
- _edit.mode = TRANSFORM_NONE;
-
- List<Node *> &selection = editor_selection->get_selected_node_list();
-
- for (Node *E : selection) {
- Node3D *sp = Object::cast_to<Node3D>(E);
- if (!sp) {
- continue;
- }
-
- Node3DEditorSelectedItem *se = editor_selection->get_node_editor_data<Node3DEditorSelectedItem>(sp);
- if (!se) {
- continue;
- }
-
- if (se->gizmo.is_valid()) {
- Vector<int> ids;
- Vector<Transform3D> restore;
-
- for (const KeyValue<int, Transform3D> &GE : se->subgizmos) {
- 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);
+ cancel_transform();
}
if (b->is_pressed()) {
@@ -1461,6 +1468,10 @@ void Node3DEditorViewport::_sinput(const Ref<InputEvent> &p_event) {
} break;
case MouseButton::LEFT: {
if (b->is_pressed()) {
+ if (_edit.mode != TRANSFORM_NONE && _edit.instant) {
+ commit_transform();
+ break; // just commit the edit, stop processing the event so we don't deselect the object
+ }
NavigationScheme nav_scheme = (NavigationScheme)EditorSettings::get_singleton()->get("editors/3d/navigation/navigation_scheme").operator int();
if ((nav_scheme == NAVIGATION_MAYA || nav_scheme == NAVIGATION_MODO) && b->is_alt_pressed()) {
break;
@@ -1567,33 +1578,17 @@ void Node3DEditorViewport::_sinput(const Ref<InputEvent> &p_event) {
clicked = ObjectID();
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 */
- if (get_selected_count() == 0) {
- break; //bye
- }
- //handle rotate
- _edit.mode = TRANSFORM_ROTATE;
- _compute_edit(b->get_position());
+ begin_transform(TRANSFORM_ROTATE, false);
break;
}
if (spatial_editor->get_tool_mode() == Node3DEditor::TOOL_MODE_MOVE) {
- if (get_selected_count() == 0) {
- break; //bye
- }
- //handle translate
- _edit.mode = TRANSFORM_TRANSLATE;
- _compute_edit(b->get_position());
+ begin_transform(TRANSFORM_TRANSLATE, false);
break;
}
if (spatial_editor->get_tool_mode() == Node3DEditor::TOOL_MODE_SCALE) {
- if (get_selected_count() == 0) {
- break; //bye
- }
- //handle scale
- _edit.mode = TRANSFORM_SCALE;
- _compute_edit(b->get_position());
+ begin_transform(TRANSFORM_SCALE, false);
break;
}
@@ -1648,32 +1643,7 @@ void Node3DEditorViewport::_sinput(const Ref<InputEvent> &p_event) {
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", sel_item->original);
- }
- undo_redo->commit_action();
+ commit_transform();
}
_edit.mode = TRANSFORM_NONE;
set_message("");
@@ -1739,7 +1709,7 @@ void Node3DEditorViewport::_sinput(const Ref<InputEvent> &p_event) {
String n = _edit.gizmo->get_handle_name(_edit.gizmo_handle, _edit.gizmo_handle_secondary);
set_message(n + ": " + String(v));
- } else if ((m->get_button_mask() & MouseButton::MASK_LEFT) != MouseButton::NONE) {
+ } else if ((m->get_button_mask() & MouseButton::MASK_LEFT) != MouseButton::NONE || _edit.instant) {
if (nav_scheme == NAVIGATION_MAYA && m->is_alt_pressed()) {
nav_mode = NAVIGATION_ORBIT;
} else if (nav_scheme == NAVIGATION_MODO && m->is_alt_pressed() && m->is_shift_pressed()) {
@@ -1767,324 +1737,7 @@ void Node3DEditorViewport::_sinput(const Ref<InputEvent> &p_event) {
return;
}
- Vector3 ray_pos = _get_ray_pos(m->get_position());
- Vector3 ray = _get_ray(m->get_position());
- double snap = EDITOR_GET("interface/inspector/default_float_step");
- int snap_step_decimals = Math::range_step_decimals(snap);
-
- switch (_edit.mode) {
- case TRANSFORM_SCALE: {
- Vector3 motion_mask;
- Plane plane;
- bool plane_mv = false;
-
- switch (_edit.plane) {
- case TRANSFORM_VIEW:
- motion_mask = Vector3(0, 0, 0);
- plane = Plane(_get_camera_normal(), _edit.center);
- break;
- case TRANSFORM_X_AXIS:
- motion_mask = spatial_editor->get_gizmo_transform().basis.get_axis(0).normalized();
- plane = Plane(motion_mask.cross(motion_mask.cross(_get_camera_normal())).normalized(), _edit.center);
- break;
- case TRANSFORM_Y_AXIS:
- motion_mask = spatial_editor->get_gizmo_transform().basis.get_axis(1).normalized();
- plane = Plane(motion_mask.cross(motion_mask.cross(_get_camera_normal())).normalized(), _edit.center);
- break;
- case TRANSFORM_Z_AXIS:
- motion_mask = spatial_editor->get_gizmo_transform().basis.get_axis(2).normalized();
- plane = Plane(motion_mask.cross(motion_mask.cross(_get_camera_normal())).normalized(), _edit.center);
- break;
- case TRANSFORM_YZ:
- motion_mask = spatial_editor->get_gizmo_transform().basis.get_axis(2).normalized() + spatial_editor->get_gizmo_transform().basis.get_axis(1).normalized();
- plane = Plane(spatial_editor->get_gizmo_transform().basis.get_axis(0).normalized(), _edit.center);
- plane_mv = true;
- break;
- case TRANSFORM_XZ:
- motion_mask = spatial_editor->get_gizmo_transform().basis.get_axis(2).normalized() + spatial_editor->get_gizmo_transform().basis.get_axis(0).normalized();
- plane = Plane(spatial_editor->get_gizmo_transform().basis.get_axis(1).normalized(), _edit.center);
- plane_mv = true;
- break;
- case TRANSFORM_XY:
- motion_mask = spatial_editor->get_gizmo_transform().basis.get_axis(0).normalized() + spatial_editor->get_gizmo_transform().basis.get_axis(1).normalized();
- plane = Plane(spatial_editor->get_gizmo_transform().basis.get_axis(2).normalized(), _edit.center);
- plane_mv = true;
- break;
- }
-
- Vector3 intersection;
- if (!plane.intersects_ray(ray_pos, ray, &intersection)) {
- break;
- }
-
- Vector3 click;
- if (!plane.intersects_ray(_edit.click_ray_pos, _edit.click_ray, &click)) {
- break;
- }
-
- Vector3 motion = intersection - click;
- if (_edit.plane != TRANSFORM_VIEW) {
- if (!plane_mv) {
- motion = motion_mask.dot(motion) * motion_mask;
-
- } else {
- // Alternative planar scaling mode
- if (_get_key_modifier(m) != Key::SHIFT) {
- motion = motion_mask.dot(motion) * motion_mask;
- }
- }
-
- } else {
- const real_t center_click_dist = click.distance_to(_edit.center);
- const real_t center_inters_dist = intersection.distance_to(_edit.center);
- if (center_click_dist == 0) {
- break;
- }
-
- const real_t scale = center_inters_dist - center_click_dist;
- motion = Vector3(scale, scale, scale);
- }
-
- motion /= click.distance_to(_edit.center);
-
- // Disable local transformation for TRANSFORM_VIEW
- bool local_coords = (spatial_editor->are_local_coords_enabled() && _edit.plane != TRANSFORM_VIEW);
-
- if (_edit.snap || spatial_editor->is_snap_enabled()) {
- snap = spatial_editor->get_scale_snap() / 100;
- }
- Vector3 motion_snapped = motion;
- motion_snapped.snap(Vector3(snap, snap, snap));
- // This might not be necessary anymore after issue #288 is solved (in 4.0?).
- 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) + ")");
- motion = _edit.original.basis.inverse().xform(motion);
-
- List<Node *> &selection = editor_selection->get_selected_node_list();
- for (Node *E : selection) {
- Node3D *sp = Object::cast_to<Node3D>(E);
- if (!sp) {
- continue;
- }
-
- Node3DEditorSelectedItem *se = editor_selection->get_node_editor_data<Node3DEditorSelectedItem>(sp);
- if (!se) {
- continue;
- }
-
- if (sp->has_meta("_edit_lock_")) {
- continue;
- }
-
- if (se->gizmo.is_valid()) {
- for (KeyValue<int, Transform3D> &GE : se->subgizmos) {
- Transform3D xform = GE.value;
- Transform3D new_xform = _compute_transform(TRANSFORM_SCALE, se->original * xform, xform, motion, snap, local_coords, true); // Force orthogonal with subgizmo.
- if (!local_coords) {
- new_xform = se->original.affine_inverse() * new_xform;
- }
- se->gizmo->set_subgizmo_transform(GE.key, new_xform);
- }
- } else {
- Transform3D new_xform = _compute_transform(TRANSFORM_SCALE, se->original, se->original_local, motion, snap, local_coords, sp->get_rotation_edit_mode() != Node3D::ROTATION_EDIT_MODE_BASIS);
- _transform_gizmo_apply(se->sp, new_xform, local_coords);
- }
- }
-
- spatial_editor->update_transform_gizmo();
- surface->update();
-
- } break;
-
- case TRANSFORM_TRANSLATE: {
- Vector3 motion_mask;
- Plane plane;
- bool plane_mv = false;
-
- switch (_edit.plane) {
- case TRANSFORM_VIEW:
- plane = Plane(_get_camera_normal(), _edit.center);
- break;
- case TRANSFORM_X_AXIS:
- motion_mask = spatial_editor->get_gizmo_transform().basis.get_axis(0).normalized();
- plane = Plane(motion_mask.cross(motion_mask.cross(_get_camera_normal())).normalized(), _edit.center);
- break;
- case TRANSFORM_Y_AXIS:
- motion_mask = spatial_editor->get_gizmo_transform().basis.get_axis(1).normalized();
- plane = Plane(motion_mask.cross(motion_mask.cross(_get_camera_normal())).normalized(), _edit.center);
- break;
- case TRANSFORM_Z_AXIS:
- motion_mask = spatial_editor->get_gizmo_transform().basis.get_axis(2).normalized();
- plane = Plane(motion_mask.cross(motion_mask.cross(_get_camera_normal())).normalized(), _edit.center);
- break;
- case TRANSFORM_YZ:
- plane = Plane(spatial_editor->get_gizmo_transform().basis.get_axis(0).normalized(), _edit.center);
- plane_mv = true;
- break;
- case TRANSFORM_XZ:
- plane = Plane(spatial_editor->get_gizmo_transform().basis.get_axis(1).normalized(), _edit.center);
- plane_mv = true;
- break;
- case TRANSFORM_XY:
- plane = Plane(spatial_editor->get_gizmo_transform().basis.get_axis(2).normalized(), _edit.center);
- plane_mv = true;
- break;
- }
-
- Vector3 intersection;
- if (!plane.intersects_ray(ray_pos, ray, &intersection)) {
- break;
- }
-
- Vector3 click;
- if (!plane.intersects_ray(_edit.click_ray_pos, _edit.click_ray, &click)) {
- break;
- }
-
- Vector3 motion = intersection - click;
- if (_edit.plane != TRANSFORM_VIEW) {
- if (!plane_mv) {
- motion = motion_mask.dot(motion) * motion_mask;
- }
- }
-
- // Disable local transformation for TRANSFORM_VIEW
- bool local_coords = (spatial_editor->are_local_coords_enabled() && _edit.plane != TRANSFORM_VIEW);
-
- if (_edit.snap || spatial_editor->is_snap_enabled()) {
- snap = spatial_editor->get_translate_snap();
- }
- Vector3 motion_snapped = motion;
- motion_snapped.snap(Vector3(snap, snap, snap));
- 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) + ")");
- motion = spatial_editor->get_gizmo_transform().basis.inverse().xform(motion);
-
- List<Node *> &selection = editor_selection->get_selected_node_list();
- for (Node *E : selection) {
- Node3D *sp = Object::cast_to<Node3D>(E);
- if (!sp) {
- continue;
- }
-
- Node3DEditorSelectedItem *se = editor_selection->get_node_editor_data<Node3DEditorSelectedItem>(sp);
- if (!se) {
- continue;
- }
-
- if (sp->has_meta("_edit_lock_")) {
- continue;
- }
-
- if (se->gizmo.is_valid()) {
- for (KeyValue<int, Transform3D> &GE : se->subgizmos) {
- Transform3D xform = GE.value;
- Transform3D new_xform = _compute_transform(TRANSFORM_TRANSLATE, se->original * xform, xform, motion, snap, local_coords, true); // Force orthogonal with subgizmo.
- new_xform = se->original.affine_inverse() * new_xform;
- se->gizmo->set_subgizmo_transform(GE.key, new_xform);
- }
- } else {
- Transform3D new_xform = _compute_transform(TRANSFORM_TRANSLATE, se->original, se->original_local, motion, snap, local_coords, sp->get_rotation_edit_mode() != Node3D::ROTATION_EDIT_MODE_BASIS);
- _transform_gizmo_apply(se->sp, new_xform, false);
- }
- }
-
- spatial_editor->update_transform_gizmo();
- surface->update();
-
- } break;
-
- case TRANSFORM_ROTATE: {
- Plane plane;
- Vector3 axis;
-
- switch (_edit.plane) {
- case TRANSFORM_VIEW:
- plane = Plane(_get_camera_normal(), _edit.center);
- break;
- case TRANSFORM_X_AXIS:
- plane = Plane(spatial_editor->get_gizmo_transform().basis.get_axis(0).normalized(), _edit.center);
- axis = Vector3(1, 0, 0);
- break;
- case TRANSFORM_Y_AXIS:
- plane = Plane(spatial_editor->get_gizmo_transform().basis.get_axis(1).normalized(), _edit.center);
- axis = Vector3(0, 1, 0);
- break;
- case TRANSFORM_Z_AXIS:
- plane = Plane(spatial_editor->get_gizmo_transform().basis.get_axis(2).normalized(), _edit.center);
- axis = Vector3(0, 0, 1);
- break;
- case TRANSFORM_YZ:
- case TRANSFORM_XZ:
- case TRANSFORM_XY:
- break;
- }
-
- Vector3 intersection;
- if (!plane.intersects_ray(ray_pos, ray, &intersection)) {
- break;
- }
-
- Vector3 click;
- if (!plane.intersects_ray(_edit.click_ray_pos, _edit.click_ray, &click)) {
- break;
- }
-
- Vector3 y_axis = (click - _edit.center).normalized();
- Vector3 x_axis = plane.normal.cross(y_axis).normalized();
-
- double angle = Math::atan2(x_axis.dot(intersection - _edit.center), y_axis.dot(intersection - _edit.center));
-
- if (_edit.snap || spatial_editor->is_snap_enabled()) {
- snap = spatial_editor->get_rotate_snap();
- }
- angle = Math::rad2deg(angle) + snap * 0.5; //else it won't reach +180
- angle -= Math::fmod(angle, snap);
- set_message(vformat(TTR("Rotating %s degrees."), String::num(angle, snap_step_decimals)));
- angle = Math::deg2rad(angle);
-
- bool local_coords = (spatial_editor->are_local_coords_enabled() && _edit.plane != TRANSFORM_VIEW); // Disable local transformation for TRANSFORM_VIEW
-
- List<Node *> &selection = editor_selection->get_selected_node_list();
- for (Node *E : selection) {
- Node3D *sp = Object::cast_to<Node3D>(E);
- if (!sp) {
- continue;
- }
-
- Node3DEditorSelectedItem *se = editor_selection->get_node_editor_data<Node3DEditorSelectedItem>(sp);
- if (!se) {
- continue;
- }
-
- if (sp->has_meta("_edit_lock_")) {
- continue;
- }
-
- Vector3 compute_axis = local_coords ? axis : plane.normal;
- if (se->gizmo.is_valid()) {
- for (KeyValue<int, Transform3D> &GE : se->subgizmos) {
- Transform3D xform = GE.value;
-
- Transform3D new_xform = _compute_transform(TRANSFORM_ROTATE, se->original * xform, xform, compute_axis, angle, local_coords, true); // Force orthogonal with subgizmo.
- if (!local_coords) {
- new_xform = se->original.affine_inverse() * new_xform;
- }
- se->gizmo->set_subgizmo_transform(GE.key, new_xform);
- }
- } else {
- Transform3D new_xform = _compute_transform(TRANSFORM_ROTATE, se->original, se->original_local, compute_axis, angle, local_coords, sp->get_rotation_edit_mode() != Node3D::ROTATION_EDIT_MODE_BASIS);
- _transform_gizmo_apply(se->sp, new_xform, local_coords);
- }
- }
-
- spatial_editor->update_transform_gizmo();
- surface->update();
-
- } break;
- default: {
- }
- }
+ update_transform(m->get_position(), _get_key_modifier(m) == Key::SHIFT);
}
} else if ((m->get_button_mask() & MouseButton::MASK_RIGHT) != MouseButton::NONE || freelook_active) {
if (nav_scheme == NAVIGATION_MAYA && m->is_alt_pressed()) {
@@ -2225,6 +1878,51 @@ void Node3DEditorViewport::_sinput(const Ref<InputEvent> &p_event) {
}
}
+ if (_edit.mode != TRANSFORM_NONE) {
+ // We're actively transforming, handle keys specially
+ TransformPlane new_plane = TRANSFORM_VIEW;
+ String new_message;
+ if (ED_IS_SHORTCUT("spatial_editor/lock_transform_x", p_event)) {
+ new_plane = TRANSFORM_X_AXIS;
+ new_message = TTR("X-Axis Transform.");
+ } else if (ED_IS_SHORTCUT("spatial_editor/lock_transform_y", p_event)) {
+ new_plane = TRANSFORM_Y_AXIS;
+ new_message = TTR("Y-Axis Transform.");
+ } else if (ED_IS_SHORTCUT("spatial_editor/lock_transform_z", p_event)) {
+ new_plane = TRANSFORM_Z_AXIS;
+ new_message = TTR("Z-Axis Transform.");
+ } else if (_edit.mode != TRANSFORM_ROTATE) { // rotating on a plane doesn't make sense
+ if (ED_IS_SHORTCUT("spatial_editor/lock_transform_yz", p_event)) {
+ new_plane = TRANSFORM_YZ;
+ new_message = TTR("YZ-Plane Transform.");
+ } else if (ED_IS_SHORTCUT("spatial_editor/lock_transform_xz", p_event)) {
+ new_plane = TRANSFORM_XZ;
+ new_message = TTR("XZ-Plane Transform.");
+ } else if (ED_IS_SHORTCUT("spatial_editor/lock_transform_xy", p_event)) {
+ new_plane = TRANSFORM_XY;
+ new_message = TTR("XY-Plane Transform.");
+ }
+ }
+
+ if (new_plane != TRANSFORM_VIEW) {
+ if (new_plane != _edit.plane) {
+ // lock me once and get a global constraint
+ _edit.plane = new_plane;
+ spatial_editor->set_local_coords_enabled(false);
+ } else if (!spatial_editor->are_local_coords_enabled()) {
+ // lock me twice and get a local constraint
+ spatial_editor->set_local_coords_enabled(true);
+ } else {
+ // lock me thrice and we're back where we started
+ _edit.plane = TRANSFORM_VIEW;
+ spatial_editor->set_local_coords_enabled(false);
+ }
+ update_transform(_edit.mouse_pos, Input::get_singleton()->is_key_pressed(Key::SHIFT));
+ set_message(new_message, 2);
+ accept_event();
+ return;
+ }
+ }
if (ED_IS_SHORTCUT("spatial_editor/snap", p_event)) {
if (_edit.mode != TRANSFORM_NONE) {
_edit.snap = !_edit.snap;
@@ -2315,6 +2013,18 @@ void Node3DEditorViewport::_sinput(const Ref<InputEvent> &p_event) {
set_message(TTR("Animation Key Inserted."));
}
+ if (ED_IS_SHORTCUT("spatial_editor/cancel_transform", p_event) && _edit.mode != TRANSFORM_NONE) {
+ cancel_transform();
+ }
+ if (ED_IS_SHORTCUT("spatial_editor/instant_translate", p_event)) {
+ begin_transform(TRANSFORM_TRANSLATE, true);
+ }
+ if (ED_IS_SHORTCUT("spatial_editor/instant_rotate", p_event)) {
+ begin_transform(TRANSFORM_ROTATE, true);
+ }
+ if (ED_IS_SHORTCUT("spatial_editor/instant_scale", p_event)) {
+ begin_transform(TRANSFORM_SCALE, true);
+ }
// Freelook doesn't work in orthogonal mode.
if (!orthogonal && ED_IS_SHORTCUT("spatial_editor/freelook_toggle", p_event)) {
@@ -2946,28 +2656,28 @@ void Node3DEditorViewport::_notification(int p_what) {
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(SNAME("normal"), editor->get_gui_base()->get_theme_stylebox(SNAME("Information3dViewport"), SNAME("EditorStyles")));
- view_menu->add_theme_style_override(SNAME("hover"), editor->get_gui_base()->get_theme_stylebox(SNAME("Information3dViewport"), SNAME("EditorStyles")));
- view_menu->add_theme_style_override(SNAME("pressed"), editor->get_gui_base()->get_theme_stylebox(SNAME("Information3dViewport"), SNAME("EditorStyles")));
- view_menu->add_theme_style_override(SNAME("focus"), editor->get_gui_base()->get_theme_stylebox(SNAME("Information3dViewport"), SNAME("EditorStyles")));
- view_menu->add_theme_style_override(SNAME("disabled"), editor->get_gui_base()->get_theme_stylebox(SNAME("Information3dViewport"), SNAME("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(SNAME("normal"), editor->get_gui_base()->get_theme_stylebox(SNAME("Information3dViewport"), SNAME("EditorStyles")));
- preview_camera->add_theme_style_override(SNAME("hover"), editor->get_gui_base()->get_theme_stylebox(SNAME("Information3dViewport"), SNAME("EditorStyles")));
- preview_camera->add_theme_style_override(SNAME("pressed"), editor->get_gui_base()->get_theme_stylebox(SNAME("Information3dViewport"), SNAME("EditorStyles")));
- preview_camera->add_theme_style_override(SNAME("focus"), editor->get_gui_base()->get_theme_stylebox(SNAME("Information3dViewport"), SNAME("EditorStyles")));
- preview_camera->add_theme_style_override(SNAME("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(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(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(SNAME("normal"), editor->get_gui_base()->get_theme_stylebox(SNAME("Information3dViewport"), SNAME("EditorStyles")));
- cpu_time_label->add_theme_style_override(SNAME("normal"), editor->get_gui_base()->get_theme_stylebox(SNAME("Information3dViewport"), SNAME("EditorStyles")));
- gpu_time_label->add_theme_style_override(SNAME("normal"), editor->get_gui_base()->get_theme_stylebox(SNAME("Information3dViewport"), SNAME("EditorStyles")));
- fps_label->add_theme_style_override(SNAME("normal"), editor->get_gui_base()->get_theme_stylebox(SNAME("Information3dViewport"), SNAME("EditorStyles")));
- cinema_label->add_theme_style_override(SNAME("normal"), editor->get_gui_base()->get_theme_stylebox(SNAME("Information3dViewport"), SNAME("EditorStyles")));
- locked_label->add_theme_style_override(SNAME("normal"), editor->get_gui_base()->get_theme_stylebox(SNAME("Information3dViewport"), SNAME("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")));
}
}
@@ -3036,7 +2746,7 @@ void Node3DEditorViewport::_draw() {
font->draw_string(ci, msgpos, message, HORIZONTAL_ALIGNMENT_LEFT, -1, font_size, Color(1, 1, 1, 1));
}
- if (_edit.mode == TRANSFORM_ROTATE) {
+ if (_edit.mode == TRANSFORM_ROTATE && _edit.show_rotation_line) {
Point2 center = _point_to_screen(_edit.center);
Color handle_color;
@@ -3544,6 +3254,13 @@ void Node3DEditorViewport::_init_gizmo_instance(int p_idx) {
RS::get_singleton()->instance_geometry_set_cast_shadows_setting(scale_plane_gizmo_instance[i], RS::SHADOW_CASTING_SETTING_OFF);
RS::get_singleton()->instance_set_layer_mask(scale_plane_gizmo_instance[i], layer);
RS::get_singleton()->instance_geometry_set_flag(scale_plane_gizmo_instance[i], RS::INSTANCE_FLAG_IGNORE_OCCLUSION_CULLING, true);
+
+ axis_gizmo_instance[i] = RS::get_singleton()->instance_create();
+ RS::get_singleton()->instance_set_base(axis_gizmo_instance[i], spatial_editor->get_axis_gizmo(i)->get_rid());
+ RS::get_singleton()->instance_set_scenario(axis_gizmo_instance[i], get_tree()->get_root()->get_world_3d()->get_scenario());
+ RS::get_singleton()->instance_set_visible(axis_gizmo_instance[i], true);
+ RS::get_singleton()->instance_geometry_set_cast_shadows_setting(axis_gizmo_instance[i], RS::SHADOW_CASTING_SETTING_OFF);
+ RS::get_singleton()->instance_set_layer_mask(axis_gizmo_instance[i], layer);
}
// Rotation white outline
@@ -3563,6 +3280,7 @@ void Node3DEditorViewport::_finish_gizmo_instances() {
RS::get_singleton()->free(rotate_gizmo_instance[i]);
RS::get_singleton()->free(scale_gizmo_instance[i]);
RS::get_singleton()->free(scale_plane_gizmo_instance[i]);
+ RS::get_singleton()->free(axis_gizmo_instance[i]);
}
// Rotation white outline
RS::get_singleton()->free(rotate_gizmo_instance[3]);
@@ -3655,6 +3373,7 @@ void Node3DEditorViewport::update_transform_gizmo_view() {
RenderingServer::get_singleton()->instance_set_visible(rotate_gizmo_instance[i], false);
RenderingServer::get_singleton()->instance_set_visible(scale_gizmo_instance[i], false);
RenderingServer::get_singleton()->instance_set_visible(scale_plane_gizmo_instance[i], false);
+ RenderingServer::get_singleton()->instance_set_visible(axis_gizmo_instance[i], false);
}
// Rotation white outline
RenderingServer::get_singleton()->instance_set_visible(rotate_gizmo_instance[3], false);
@@ -3711,7 +3430,15 @@ void Node3DEditorViewport::update_transform_gizmo_view() {
RenderingServer::get_singleton()->instance_set_visible(scale_gizmo_instance[i], spatial_editor->is_gizmo_visible() && (spatial_editor->get_tool_mode() == Node3DEditor::TOOL_MODE_SCALE));
RenderingServer::get_singleton()->instance_set_transform(scale_plane_gizmo_instance[i], axis_angle);
RenderingServer::get_singleton()->instance_set_visible(scale_plane_gizmo_instance[i], spatial_editor->is_gizmo_visible() && (spatial_editor->get_tool_mode() == Node3DEditor::TOOL_MODE_SCALE));
+ RenderingServer::get_singleton()->instance_set_transform(axis_gizmo_instance[i], xform);
}
+
+ bool show_axes = spatial_editor->is_gizmo_visible() && _edit.mode != TRANSFORM_NONE;
+ RenderingServer *rs = RenderingServer::get_singleton();
+ rs->instance_set_visible(axis_gizmo_instance[0], show_axes && (_edit.plane == TRANSFORM_X_AXIS || _edit.plane == TRANSFORM_XY || _edit.plane == TRANSFORM_XZ));
+ rs->instance_set_visible(axis_gizmo_instance[1], show_axes && (_edit.plane == TRANSFORM_Y_AXIS || _edit.plane == TRANSFORM_XY || _edit.plane == TRANSFORM_YZ));
+ rs->instance_set_visible(axis_gizmo_instance[2], show_axes && (_edit.plane == TRANSFORM_Z_AXIS || _edit.plane == TRANSFORM_XZ || _edit.plane == TRANSFORM_YZ));
+
// Rotation white outline
xform.orthonormalize();
xform.basis.scale(scale);
@@ -3978,7 +3705,7 @@ AABB Node3DEditorViewport::_calculate_spatial_bounds(const Node3D *p_parent, boo
if (child) {
AABB child_bounds = _calculate_spatial_bounds(child, false);
- if (bounds.size == Vector3() && p_parent->get_class_name() == StringName("Node3D")) {
+ if (bounds.size == Vector3() && Object::cast_to<Node3D>(p_parent)) {
bounds = child_bounds;
} else {
bounds.merge_with(child_bounds);
@@ -3986,7 +3713,7 @@ AABB Node3DEditorViewport::_calculate_spatial_bounds(const Node3D *p_parent, boo
}
}
- if (bounds.size == Vector3() && p_parent->get_class_name() != StringName("Node3D")) {
+ if (bounds.size == Vector3() && !Object::cast_to<Node3D>(p_parent)) {
bounds = AABB(Vector3(-0.2, -0.2, -0.2), Vector3(0.4, 0.4, 0.4));
}
@@ -4213,25 +3940,19 @@ bool Node3DEditorViewport::can_drop_data_fw(const Point2 &p_point, const Variant
ResourceLoader::get_recognized_extensions_for_type("Mesh", &mesh_extensions);
for (int i = 0; i < files.size(); i++) {
+ // Check if dragged files with mesh or scene extension can be created at least once.
if (mesh_extensions.find(files[i].get_extension()) || scene_extensions.find(files[i].get_extension())) {
RES res = ResourceLoader::load(files[i]);
if (res.is_null()) {
continue;
}
-
- String type = res->get_class();
- if (type == "PackedScene") {
- Ref<PackedScene> sdata = ResourceLoader::load(files[i]);
- Node *instantiated_scene = sdata->instantiate(PackedScene::GEN_EDIT_STATE_INSTANCE);
+ Ref<PackedScene> scn = res;
+ if (scn.is_valid()) {
+ Node *instantiated_scene = scn->instantiate(PackedScene::GEN_EDIT_STATE_INSTANCE);
if (!instantiated_scene) {
continue;
}
memdelete(instantiated_scene);
- } else if (ClassDB::is_parent_class(type, "Mesh")) {
- Ref<Mesh> mesh = ResourceLoader::load(files[i]);
- if (!mesh.is_valid()) {
- continue;
- }
} else {
continue;
}
@@ -4299,6 +4020,387 @@ void Node3DEditorViewport::drop_data_fw(const Point2 &p_point, const Variant &p_
_perform_drop_data();
}
+void Node3DEditorViewport::begin_transform(TransformMode p_mode, bool instant) {
+ if (get_selected_count() > 0) {
+ _edit.mode = p_mode;
+ _compute_edit(_edit.mouse_pos);
+ _edit.instant = instant;
+ _edit.snap = spatial_editor->is_snap_enabled();
+ }
+}
+
+void Node3DEditorViewport::commit_transform() {
+ ERR_FAIL_COND(_edit.mode == TRANSFORM_NONE);
+ 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(_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 *se = editor_selection->get_node_editor_data<Node3DEditorSelectedItem>(sp);
+ if (!se) {
+ 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->commit_action();
+ _edit.mode = TRANSFORM_NONE;
+ _edit.instant = false;
+ spatial_editor->set_local_coords_enabled(_edit.original_local);
+ set_message("");
+ spatial_editor->update_transform_gizmo();
+ surface->update();
+}
+
+void Node3DEditorViewport::update_transform(Point2 p_mousepos, bool p_shift) {
+ Vector3 ray_pos = _get_ray_pos(p_mousepos);
+ Vector3 ray = _get_ray(p_mousepos);
+ double snap = EDITOR_GET("interface/inspector/default_float_step");
+ int snap_step_decimals = Math::range_step_decimals(snap);
+
+ switch (_edit.mode) {
+ case TRANSFORM_SCALE: {
+ Vector3 motion_mask;
+ Plane plane;
+ bool plane_mv = false;
+
+ switch (_edit.plane) {
+ case TRANSFORM_VIEW:
+ motion_mask = Vector3(0, 0, 0);
+ plane = Plane(_get_camera_normal(), _edit.center);
+ break;
+ case TRANSFORM_X_AXIS:
+ motion_mask = spatial_editor->get_gizmo_transform().basis.get_axis(0).normalized();
+ plane = Plane(motion_mask.cross(motion_mask.cross(_get_camera_normal())).normalized(), _edit.center);
+ break;
+ case TRANSFORM_Y_AXIS:
+ motion_mask = spatial_editor->get_gizmo_transform().basis.get_axis(1).normalized();
+ plane = Plane(motion_mask.cross(motion_mask.cross(_get_camera_normal())).normalized(), _edit.center);
+ break;
+ case TRANSFORM_Z_AXIS:
+ motion_mask = spatial_editor->get_gizmo_transform().basis.get_axis(2).normalized();
+ plane = Plane(motion_mask.cross(motion_mask.cross(_get_camera_normal())).normalized(), _edit.center);
+ break;
+ case TRANSFORM_YZ:
+ motion_mask = spatial_editor->get_gizmo_transform().basis.get_axis(2).normalized() + spatial_editor->get_gizmo_transform().basis.get_axis(1).normalized();
+ plane = Plane(spatial_editor->get_gizmo_transform().basis.get_axis(0).normalized(), _edit.center);
+ plane_mv = true;
+ break;
+ case TRANSFORM_XZ:
+ motion_mask = spatial_editor->get_gizmo_transform().basis.get_axis(2).normalized() + spatial_editor->get_gizmo_transform().basis.get_axis(0).normalized();
+ plane = Plane(spatial_editor->get_gizmo_transform().basis.get_axis(1).normalized(), _edit.center);
+ plane_mv = true;
+ break;
+ case TRANSFORM_XY:
+ motion_mask = spatial_editor->get_gizmo_transform().basis.get_axis(0).normalized() + spatial_editor->get_gizmo_transform().basis.get_axis(1).normalized();
+ plane = Plane(spatial_editor->get_gizmo_transform().basis.get_axis(2).normalized(), _edit.center);
+ plane_mv = true;
+ break;
+ }
+
+ Vector3 intersection;
+ if (!plane.intersects_ray(ray_pos, ray, &intersection)) {
+ break;
+ }
+
+ Vector3 click;
+ if (!plane.intersects_ray(_edit.click_ray_pos, _edit.click_ray, &click)) {
+ break;
+ }
+
+ Vector3 motion = intersection - click;
+ if (_edit.plane != TRANSFORM_VIEW) {
+ if (!plane_mv) {
+ motion = motion_mask.dot(motion) * motion_mask;
+
+ } else {
+ // Alternative planar scaling mode
+ if (p_shift) {
+ motion = motion_mask.dot(motion) * motion_mask;
+ }
+ }
+
+ } else {
+ const real_t center_click_dist = click.distance_to(_edit.center);
+ const real_t center_inters_dist = intersection.distance_to(_edit.center);
+ if (center_click_dist == 0) {
+ break;
+ }
+
+ const real_t scale = center_inters_dist - center_click_dist;
+ motion = Vector3(scale, scale, scale);
+ }
+
+ motion /= click.distance_to(_edit.center);
+
+ // Disable local transformation for TRANSFORM_VIEW
+ bool local_coords = (spatial_editor->are_local_coords_enabled() && _edit.plane != TRANSFORM_VIEW);
+
+ if (_edit.snap || spatial_editor->is_snap_enabled()) {
+ snap = spatial_editor->get_scale_snap() / 100;
+ }
+ Vector3 motion_snapped = motion;
+ motion_snapped.snap(Vector3(snap, snap, snap));
+ // This might not be necessary anymore after issue #288 is solved (in 4.0?).
+ 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) + ")");
+ motion = _edit.original.basis.inverse().xform(motion);
+
+ List<Node *> &selection = editor_selection->get_selected_node_list();
+ for (Node *E : selection) {
+ Node3D *sp = Object::cast_to<Node3D>(E);
+ if (!sp) {
+ continue;
+ }
+
+ Node3DEditorSelectedItem *se = editor_selection->get_node_editor_data<Node3DEditorSelectedItem>(sp);
+ if (!se) {
+ continue;
+ }
+
+ if (sp->has_meta("_edit_lock_")) {
+ continue;
+ }
+
+ if (se->gizmo.is_valid()) {
+ for (KeyValue<int, Transform3D> &GE : se->subgizmos) {
+ Transform3D xform = GE.value;
+ Transform3D new_xform = _compute_transform(TRANSFORM_SCALE, se->original * xform, xform, motion, snap, local_coords, true); // Force orthogonal with subgizmo.
+ if (!local_coords) {
+ new_xform = se->original.affine_inverse() * new_xform;
+ }
+ se->gizmo->set_subgizmo_transform(GE.key, new_xform);
+ }
+ } else {
+ Transform3D new_xform = _compute_transform(TRANSFORM_SCALE, se->original, se->original_local, motion, snap, local_coords, sp->get_rotation_edit_mode() != Node3D::ROTATION_EDIT_MODE_BASIS);
+ _transform_gizmo_apply(se->sp, new_xform, local_coords);
+ }
+ }
+
+ spatial_editor->update_transform_gizmo();
+ surface->update();
+
+ } break;
+
+ case TRANSFORM_TRANSLATE: {
+ Vector3 motion_mask;
+ Plane plane;
+ bool plane_mv = false;
+
+ switch (_edit.plane) {
+ case TRANSFORM_VIEW:
+ plane = Plane(_get_camera_normal(), _edit.center);
+ break;
+ case TRANSFORM_X_AXIS:
+ motion_mask = spatial_editor->get_gizmo_transform().basis.get_axis(0).normalized();
+ plane = Plane(motion_mask.cross(motion_mask.cross(_get_camera_normal())).normalized(), _edit.center);
+ break;
+ case TRANSFORM_Y_AXIS:
+ motion_mask = spatial_editor->get_gizmo_transform().basis.get_axis(1).normalized();
+ plane = Plane(motion_mask.cross(motion_mask.cross(_get_camera_normal())).normalized(), _edit.center);
+ break;
+ case TRANSFORM_Z_AXIS:
+ motion_mask = spatial_editor->get_gizmo_transform().basis.get_axis(2).normalized();
+ plane = Plane(motion_mask.cross(motion_mask.cross(_get_camera_normal())).normalized(), _edit.center);
+ break;
+ case TRANSFORM_YZ:
+ plane = Plane(spatial_editor->get_gizmo_transform().basis.get_axis(0).normalized(), _edit.center);
+ plane_mv = true;
+ break;
+ case TRANSFORM_XZ:
+ plane = Plane(spatial_editor->get_gizmo_transform().basis.get_axis(1).normalized(), _edit.center);
+ plane_mv = true;
+ break;
+ case TRANSFORM_XY:
+ plane = Plane(spatial_editor->get_gizmo_transform().basis.get_axis(2).normalized(), _edit.center);
+ plane_mv = true;
+ break;
+ }
+
+ Vector3 intersection;
+ if (!plane.intersects_ray(ray_pos, ray, &intersection)) {
+ break;
+ }
+
+ Vector3 click;
+ if (!plane.intersects_ray(_edit.click_ray_pos, _edit.click_ray, &click)) {
+ break;
+ }
+
+ Vector3 motion = intersection - click;
+ if (_edit.plane != TRANSFORM_VIEW) {
+ if (!plane_mv) {
+ motion = motion_mask.dot(motion) * motion_mask;
+ }
+ }
+
+ // Disable local transformation for TRANSFORM_VIEW
+ bool local_coords = (spatial_editor->are_local_coords_enabled() && _edit.plane != TRANSFORM_VIEW);
+
+ if (_edit.snap || spatial_editor->is_snap_enabled()) {
+ snap = spatial_editor->get_translate_snap();
+ }
+ Vector3 motion_snapped = motion;
+ motion_snapped.snap(Vector3(snap, snap, snap));
+ 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) + ")");
+ motion = spatial_editor->get_gizmo_transform().basis.inverse().xform(motion);
+
+ List<Node *> &selection = editor_selection->get_selected_node_list();
+ for (Node *E : selection) {
+ Node3D *sp = Object::cast_to<Node3D>(E);
+ if (!sp) {
+ continue;
+ }
+
+ Node3DEditorSelectedItem *se = editor_selection->get_node_editor_data<Node3DEditorSelectedItem>(sp);
+ if (!se) {
+ continue;
+ }
+
+ if (sp->has_meta("_edit_lock_")) {
+ continue;
+ }
+
+ if (se->gizmo.is_valid()) {
+ for (KeyValue<int, Transform3D> &GE : se->subgizmos) {
+ Transform3D xform = GE.value;
+ Transform3D new_xform = _compute_transform(TRANSFORM_TRANSLATE, se->original * xform, xform, motion, snap, local_coords, true); // Force orthogonal with subgizmo.
+ new_xform = se->original.affine_inverse() * new_xform;
+ se->gizmo->set_subgizmo_transform(GE.key, new_xform);
+ }
+ } else {
+ Transform3D new_xform = _compute_transform(TRANSFORM_TRANSLATE, se->original, se->original_local, motion, snap, local_coords, sp->get_rotation_edit_mode() != Node3D::ROTATION_EDIT_MODE_BASIS);
+ _transform_gizmo_apply(se->sp, new_xform, false);
+ }
+ }
+
+ spatial_editor->update_transform_gizmo();
+ surface->update();
+
+ } break;
+
+ case TRANSFORM_ROTATE: {
+ Plane plane = Plane(_get_camera_normal(), _edit.center);
+
+ Vector3 local_axis;
+ Vector3 global_axis;
+ switch (_edit.plane) {
+ case TRANSFORM_VIEW:
+ // local_axis unused
+ global_axis = _get_camera_normal();
+ break;
+ case TRANSFORM_X_AXIS:
+ local_axis = Vector3(1, 0, 0);
+ break;
+ case TRANSFORM_Y_AXIS:
+ local_axis = Vector3(0, 1, 0);
+ break;
+ case TRANSFORM_Z_AXIS:
+ local_axis = Vector3(0, 0, 1);
+ break;
+ case TRANSFORM_YZ:
+ case TRANSFORM_XZ:
+ case TRANSFORM_XY:
+ break;
+ }
+
+ if (_edit.plane != TRANSFORM_VIEW) {
+ global_axis = spatial_editor->get_gizmo_transform().basis.xform(local_axis).normalized();
+ }
+
+ Vector3 intersection;
+ if (!plane.intersects_ray(ray_pos, ray, &intersection)) {
+ break;
+ }
+
+ Vector3 click;
+ if (!plane.intersects_ray(_edit.click_ray_pos, _edit.click_ray, &click)) {
+ break;
+ }
+
+ static const float orthogonal_threshold = Math::cos(Math::deg2rad(87.0f));
+ bool axis_is_orthogonal = ABS(plane.normal.dot(global_axis)) < orthogonal_threshold;
+
+ double angle = 0.0f;
+ if (axis_is_orthogonal) {
+ _edit.show_rotation_line = false;
+ Vector3 projection_axis = plane.normal.cross(global_axis);
+ Vector3 delta = intersection - click;
+ float projection = delta.dot(projection_axis);
+ angle = (projection * (Math_PI / 2.0f)) / (gizmo_scale * GIZMO_CIRCLE_SIZE);
+ } else {
+ _edit.show_rotation_line = true;
+ Vector3 click_axis = (click - _edit.center).normalized();
+ Vector3 current_axis = (intersection - _edit.center).normalized();
+ angle = click_axis.signed_angle_to(current_axis, global_axis);
+ }
+
+ if (_edit.snap || spatial_editor->is_snap_enabled()) {
+ snap = spatial_editor->get_rotate_snap();
+ }
+ angle = Math::rad2deg(angle) + snap * 0.5; //else it won't reach +180
+ angle -= Math::fmod(angle, snap);
+ set_message(vformat(TTR("Rotating %s degrees."), String::num(angle, snap_step_decimals)));
+ angle = Math::deg2rad(angle);
+
+ bool local_coords = (spatial_editor->are_local_coords_enabled() && _edit.plane != TRANSFORM_VIEW); // Disable local transformation for TRANSFORM_VIEW
+
+ List<Node *> &selection = editor_selection->get_selected_node_list();
+ for (Node *E : selection) {
+ Node3D *sp = Object::cast_to<Node3D>(E);
+ if (!sp) {
+ continue;
+ }
+
+ Node3DEditorSelectedItem *se = editor_selection->get_node_editor_data<Node3DEditorSelectedItem>(sp);
+ if (!se) {
+ continue;
+ }
+
+ if (sp->has_meta("_edit_lock_")) {
+ continue;
+ }
+
+ Vector3 compute_axis = local_coords ? local_axis : global_axis;
+ if (se->gizmo.is_valid()) {
+ for (KeyValue<int, Transform3D> &GE : se->subgizmos) {
+ Transform3D xform = GE.value;
+
+ Transform3D new_xform = _compute_transform(TRANSFORM_ROTATE, se->original * xform, xform, compute_axis, angle, local_coords, true); // Force orthogonal with subgizmo.
+ if (!local_coords) {
+ new_xform = se->original.affine_inverse() * new_xform;
+ }
+ se->gizmo->set_subgizmo_transform(GE.key, new_xform);
+ }
+ } else {
+ Transform3D new_xform = _compute_transform(TRANSFORM_ROTATE, se->original, se->original_local, compute_axis, angle, local_coords, sp->get_rotation_edit_mode() != Node3D::ROTATION_EDIT_MODE_BASIS);
+ _transform_gizmo_apply(se->sp, new_xform, local_coords);
+ }
+ }
+
+ spatial_editor->update_transform_gizmo();
+ surface->update();
+
+ } break;
+ default: {
+ }
+ }
+}
+
Node3DEditorViewport::Node3DEditorViewport(Node3DEditor *p_spatial_editor, EditorNode *p_editor, int p_index) {
cpu_time_history_index = 0;
gpu_time_history_index = 0;
@@ -4306,6 +4408,8 @@ Node3DEditorViewport::Node3DEditorViewport(Node3DEditor *p_spatial_editor, Edito
_edit.mode = TRANSFORM_NONE;
_edit.plane = TRANSFORM_VIEW;
_edit.snap = true;
+ _edit.show_rotation_line = true;
+ _edit.instant = false;
_edit.gizmo_handle = -1;
_edit.gizmo_handle_secondary = false;
@@ -4383,7 +4487,7 @@ Node3DEditorViewport::Node3DEditorViewport(Node3DEditor *p_spatial_editor, Edito
display_submenu->add_radio_check_item(TTR("Normal Buffer"), VIEW_DISPLAY_NORMAL_BUFFER);
display_submenu->add_separator();
display_submenu->add_radio_check_item(TTR("Shadow Atlas"), VIEW_DISPLAY_DEBUG_SHADOW_ATLAS);
- display_submenu->add_radio_check_item(TTR("Directional Shadow"), VIEW_DISPLAY_DEBUG_DIRECTIONAL_SHADOW_ATLAS);
+ display_submenu->add_radio_check_item(TTR("Directional Shadow Map"), VIEW_DISPLAY_DEBUG_DIRECTIONAL_SHADOW_ATLAS);
display_submenu->add_separator();
display_submenu->add_radio_check_item(TTR("Decal Atlas"), VIEW_DISPLAY_DEBUG_DECAL_ATLAS);
display_submenu->add_separator();
@@ -4399,14 +4503,14 @@ Node3DEditorViewport::Node3DEditorViewport(Node3DEditor *p_spatial_editor, Edito
display_submenu->add_radio_check_item(TTR("SSAO"), VIEW_DISPLAY_DEBUG_SSAO);
display_submenu->add_radio_check_item(TTR("SSIL"), VIEW_DISPLAY_DEBUG_SSIL);
display_submenu->add_separator();
- display_submenu->add_radio_check_item(TTR("GI Buffer"), VIEW_DISPLAY_DEBUG_GI_BUFFER);
+ display_submenu->add_radio_check_item(TTR("VoxelGI/SDFGI Buffer"), VIEW_DISPLAY_DEBUG_GI_BUFFER);
display_submenu->add_separator();
- display_submenu->add_radio_check_item(TTR("Disable LOD"), VIEW_DISPLAY_DEBUG_DISABLE_LOD);
+ display_submenu->add_radio_check_item(TTR("Disable Mesh LOD"), VIEW_DISPLAY_DEBUG_DISABLE_LOD);
display_submenu->add_separator();
- display_submenu->add_radio_check_item(TTR("Omni Light Cluster"), VIEW_DISPLAY_DEBUG_CLUSTER_OMNI_LIGHTS);
- display_submenu->add_radio_check_item(TTR("Spot Light Cluster"), VIEW_DISPLAY_DEBUG_CLUSTER_SPOT_LIGHTS);
+ display_submenu->add_radio_check_item(TTR("OmniLight3D Cluster"), VIEW_DISPLAY_DEBUG_CLUSTER_OMNI_LIGHTS);
+ display_submenu->add_radio_check_item(TTR("SpotLight3D Cluster"), VIEW_DISPLAY_DEBUG_CLUSTER_SPOT_LIGHTS);
display_submenu->add_radio_check_item(TTR("Decal Cluster"), VIEW_DISPLAY_DEBUG_CLUSTER_DECALS);
- display_submenu->add_radio_check_item(TTR("Reflection Probe Cluster"), VIEW_DISPLAY_DEBUG_CLUSTER_REFLECTION_PROBES);
+ display_submenu->add_radio_check_item(TTR("ReflectionProbe Cluster"), VIEW_DISPLAY_DEBUG_CLUSTER_REFLECTION_PROBES);
display_submenu->add_radio_check_item(TTR("Occlusion Culling Buffer"), VIEW_DISPLAY_DEBUG_OCCLUDERS);
display_submenu->set_name("display_advanced");
@@ -4465,6 +4569,16 @@ Node3DEditorViewport::Node3DEditorViewport(Node3DEditor *p_spatial_editor, Edito
ED_SHORTCUT("spatial_editor/freelook_down", TTR("Freelook Down"), Key::Q);
ED_SHORTCUT("spatial_editor/freelook_speed_modifier", TTR("Freelook Speed Modifier"), Key::SHIFT);
ED_SHORTCUT("spatial_editor/freelook_slow_modifier", TTR("Freelook Slow Modifier"), Key::ALT);
+ ED_SHORTCUT("spatial_editor/lock_transform_x", TTR("Lock Transformation to X axis"), Key::X);
+ ED_SHORTCUT("spatial_editor/lock_transform_y", TTR("Lock Transformation to Y axis"), Key::Y);
+ ED_SHORTCUT("spatial_editor/lock_transform_z", TTR("Lock Transformation to Z axis"), Key::Z);
+ ED_SHORTCUT("spatial_editor/lock_transform_yz", TTR("Lock Transformation to YZ plane"), KeyModifierMask::SHIFT | Key::X);
+ ED_SHORTCUT("spatial_editor/lock_transform_xz", TTR("Lock Transformation to XZ plane"), KeyModifierMask::SHIFT | Key::Y);
+ ED_SHORTCUT("spatial_editor/lock_transform_xy", TTR("Lock Transformation to XY plane"), KeyModifierMask::SHIFT | Key::Z);
+ ED_SHORTCUT("spatial_editor/cancel_transform", TTR("Cancel Transformation"), Key::ESCAPE);
+ ED_SHORTCUT("spatial_editor/instant_translate", TTR("Begin Translate Transformation"));
+ ED_SHORTCUT("spatial_editor/instant_rotate", TTR("Begin Rotate Transformation"));
+ ED_SHORTCUT("spatial_editor/instant_scale", TTR("Begin Scale Transformation"));
preview_camera = memnew(CheckBox);
preview_camera->set_text(TTR("Preview"));
@@ -4512,7 +4626,7 @@ Node3DEditorViewport::Node3DEditorViewport(Node3DEditor *p_spatial_editor, Edito
zoom_limit_label->set_offset(Side::SIDE_TOP, -28 * EDSCALE);
zoom_limit_label->set_text(TTR("To zoom further, change the camera's clipping planes (View -> Settings...)"));
zoom_limit_label->set_name("ZoomLimitMessageLabel");
- zoom_limit_label->add_theme_color_override(SNAME("font_color"), Color(1, 1, 1, 1));
+ zoom_limit_label->add_theme_color_override("font_color", Color(1, 1, 1, 1));
zoom_limit_label->hide();
surface->add_child(zoom_limit_label);
@@ -4526,7 +4640,7 @@ Node3DEditorViewport::Node3DEditorViewport(Node3DEditor *p_spatial_editor, Edito
// Make sure frame time labels don't touch the viewport's edge.
top_right_vbox->set_custom_minimum_size(Size2(100, 0) * EDSCALE);
// Prevent visible spacing between frame time labels.
- top_right_vbox->add_theme_constant_override(SNAME("separation"), 0);
+ top_right_vbox->add_theme_constant_override("separation", 0);
rotation_control = memnew(ViewportRotationControl);
rotation_control->set_custom_minimum_size(Size2(80, 80) * EDSCALE);
@@ -5854,6 +5968,7 @@ void fragment() {
rotate_gizmo[i] = Ref<ArrayMesh>(memnew(ArrayMesh));
scale_gizmo[i] = Ref<ArrayMesh>(memnew(ArrayMesh));
scale_plane_gizmo[i] = Ref<ArrayMesh>(memnew(ArrayMesh));
+ axis_gizmo[i] = Ref<ArrayMesh>(memnew(ArrayMesh));
Ref<StandardMaterial3D> mat = memnew(StandardMaterial3D);
mat->set_shading_mode(StandardMaterial3D::SHADING_MODE_UNSHADED);
@@ -6175,6 +6290,21 @@ void fragment() {
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
}
+
+ // Lines to visualize transforms locked to an axis/plane
+ {
+ Ref<SurfaceTool> surftool = memnew(SurfaceTool);
+ surftool->begin(Mesh::PRIMITIVE_LINES);
+
+ Vector3 vec;
+ vec[i] = 1;
+
+ // line extending through infinity(ish)
+ surftool->add_vertex(vec * -99999);
+ surftool->add_vertex(vec * 99999);
+ surftool->set_material(mat_hl);
+ surftool->commit(axis_gizmo[i]);
+ }
}
}
@@ -6190,7 +6320,7 @@ void Node3DEditor::_update_context_menu_stylebox() {
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(SNAME("panel"), context_menu_stylebox);
+ context_menu_container->add_theme_style_override("panel", context_menu_stylebox);
}
void Node3DEditor::_update_gizmos_menu() {
@@ -6777,8 +6907,8 @@ void Node3DEditor::_update_theme() {
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(SNAME("font"), get_theme_font(SNAME("title_font"), SNAME("Window")));
- environ_title->add_theme_font_override(SNAME("font"), get_theme_font(SNAME("title_font"), SNAME("Window")));
+ 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) {
@@ -6815,8 +6945,8 @@ void Node3DEditor::_notification(int p_what) {
_update_theme();
_update_gizmos_menu_theme();
_update_context_menu_stylebox();
- sun_title->add_theme_font_override(SNAME("font"), get_theme_font(SNAME("title_font"), SNAME("Window")));
- environ_title->add_theme_font_override(SNAME("font"), get_theme_font(SNAME("title_font"), SNAME("Window")));
+ 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.
@@ -7806,7 +7936,7 @@ void fragment() {
sun_angle_azimuth->connect("value_changed", callable_mp(this, &Node3DEditor::_sun_direction_angle_set).unbind(1));
sun_angle_azimuth_vbox->add_child(sun_angle_azimuth);
sun_angle_hbox->add_child(sun_angle_azimuth_vbox);
- sun_angle_hbox->add_theme_constant_override(SNAME("separation"), 10);
+ sun_angle_hbox->add_theme_constant_override("separation", 10);
sun_vb->add_child(sun_angle_hbox);
sun_color = memnew(ColorPickerButton);
diff --git a/editor/plugins/node_3d_editor_plugin.h b/editor/plugins/node_3d_editor_plugin.h
index 20a782c8a8..bbe5615570 100644
--- a/editor/plugins/node_3d_editor_plugin.h
+++ b/editor/plugins/node_3d_editor_plugin.h
@@ -247,6 +247,7 @@ private:
Point2 _point_to_screen(const Vector3 &p_point);
Transform3D _get_camera_transform() const;
int get_selected_count() const;
+ void cancel_transform();
Vector3 _get_camera_position() const;
Vector3 _get_camera_normal() const;
@@ -310,10 +311,13 @@ private:
Point2 mouse_pos;
Point2 original_mouse_pos;
bool snap = false;
+ bool show_rotation_line = false;
Ref<EditorNode3DGizmo> gizmo;
int gizmo_handle = 0;
bool gizmo_handle_secondary = false;
Variant gizmo_initial_value;
+ bool original_local;
+ bool instant;
} _edit;
struct Cursor {
@@ -347,7 +351,7 @@ private:
real_t zoom_indicator_delay;
int zoom_failed_attempts_count = 0;
- RID move_gizmo_instance[3], move_plane_gizmo_instance[3], rotate_gizmo_instance[4], scale_gizmo_instance[3], scale_plane_gizmo_instance[3];
+ RID move_gizmo_instance[3], move_plane_gizmo_instance[3], rotate_gizmo_instance[4], scale_gizmo_instance[3], scale_plane_gizmo_instance[3], axis_gizmo_instance[3];
String last_message;
String message;
@@ -402,6 +406,10 @@ private:
Transform3D _compute_transform(TransformMode p_mode, const Transform3D &p_original, const Transform3D &p_original_local, Vector3 p_motion, double p_extra, bool p_local, bool p_orthogonal);
+ void begin_transform(TransformMode p_mode, bool instant);
+ void commit_transform();
+ void update_transform(Point2 p_mousepos, bool p_shift);
+
protected:
void _notification(int p_what);
static void _bind_methods();
@@ -546,7 +554,7 @@ private:
Camera3D::Projection grid_camera_last_update_perspective = Camera3D::PROJECTION_PERSPECTIVE;
Vector3 grid_camera_last_update_position = Vector3();
- Ref<ArrayMesh> move_gizmo[3], move_plane_gizmo[3], rotate_gizmo[4], scale_gizmo[3], scale_plane_gizmo[3];
+ Ref<ArrayMesh> move_gizmo[3], move_plane_gizmo[3], rotate_gizmo[4], scale_gizmo[3], scale_plane_gizmo[3], axis_gizmo[3];
Ref<StandardMaterial3D> gizmo_color[3];
Ref<StandardMaterial3D> plane_gizmo_color[3];
Ref<ShaderMaterial> rotate_gizmo_color[3];
@@ -773,12 +781,14 @@ public:
ToolMode get_tool_mode() const { return tool_mode; }
bool are_local_coords_enabled() const { return tool_option_button[Node3DEditor::TOOL_OPT_LOCAL_COORDS]->is_pressed(); }
+ void set_local_coords_enabled(bool on) const { tool_option_button[Node3DEditor::TOOL_OPT_LOCAL_COORDS]->set_pressed(on); }
bool is_snap_enabled() const { return snap_enabled ^ snap_key_enabled; }
double get_translate_snap() const;
double get_rotate_snap() const;
double get_scale_snap() const;
Ref<ArrayMesh> get_move_gizmo(int idx) const { return move_gizmo[idx]; }
+ Ref<ArrayMesh> get_axis_gizmo(int idx) const { return axis_gizmo[idx]; }
Ref<ArrayMesh> get_move_plane_gizmo(int idx) const { return move_plane_gizmo[idx]; }
Ref<ArrayMesh> get_rotate_gizmo(int idx) const { return rotate_gizmo[idx]; }
Ref<ArrayMesh> get_scale_gizmo(int idx) const { return scale_gizmo[idx]; }
diff --git a/editor/plugins/occluder_instance_3d_editor_plugin.cpp b/editor/plugins/occluder_instance_3d_editor_plugin.cpp
index 2dd760275e..e7fe8da716 100644
--- a/editor/plugins/occluder_instance_3d_editor_plugin.cpp
+++ b/editor/plugins/occluder_instance_3d_editor_plugin.cpp
@@ -34,9 +34,9 @@ void OccluderInstance3DEditorPlugin::_bake_select_file(const String &p_file) {
if (occluder_instance) {
OccluderInstance3D::BakeError err;
if (get_tree()->get_edited_scene_root() && get_tree()->get_edited_scene_root() == occluder_instance) {
- err = occluder_instance->bake(occluder_instance, p_file);
+ err = occluder_instance->bake_scene(occluder_instance, p_file);
} else {
- err = occluder_instance->bake(occluder_instance->get_parent(), p_file);
+ err = occluder_instance->bake_scene(occluder_instance->get_parent(), p_file);
}
switch (err) {
@@ -59,6 +59,10 @@ void OccluderInstance3DEditorPlugin::_bake_select_file(const String &p_file) {
EditorNode::get_singleton()->show_warning(TTR("No meshes to bake.\nMake sure there is at least one MeshInstance3D node in the scene whose visual layers are part of the OccluderInstance3D's Bake Mask property."));
break;
}
+ case OccluderInstance3D::BAKE_ERROR_CANT_SAVE: {
+ EditorNode::get_singleton()->show_warning(TTR("Could not save the new occluder at the specified path: ") + p_file);
+ break;
+ }
default: {
}
}
diff --git a/editor/plugins/packed_scene_translation_parser_plugin.cpp b/editor/plugins/packed_scene_translation_parser_plugin.cpp
index b492c27f41..9a8584f4a2 100644
--- a/editor/plugins/packed_scene_translation_parser_plugin.cpp
+++ b/editor/plugins/packed_scene_translation_parser_plugin.cpp
@@ -132,10 +132,7 @@ PackedSceneEditorTranslationParserPlugin::PackedSceneEditorTranslationParserPlug
lookup_properties.insert("script");
// Exception list (to prevent false positives).
- exception_list.insert("LineEdit", Vector<StringName>());
- exception_list["LineEdit"].append("text");
- exception_list.insert("TextEdit", Vector<StringName>());
- exception_list["TextEdit"].append("text");
- exception_list.insert("CodeEdit", Vector<StringName>());
- exception_list["CodeEdit"].append("text");
+ exception_list.insert("LineEdit", { "text" });
+ exception_list.insert("TextEdit", { "text" });
+ exception_list.insert("CodeEdit", { "text" });
}
diff --git a/editor/plugins/packed_scene_translation_parser_plugin.h b/editor/plugins/packed_scene_translation_parser_plugin.h
index fc19496eb6..ecd090b31b 100644
--- a/editor/plugins/packed_scene_translation_parser_plugin.h
+++ b/editor/plugins/packed_scene_translation_parser_plugin.h
@@ -37,9 +37,9 @@ class PackedSceneEditorTranslationParserPlugin : public EditorTranslationParserP
GDCLASS(PackedSceneEditorTranslationParserPlugin, EditorTranslationParserPlugin);
// Scene Node's properties that contain translation strings.
- Set<StringName> lookup_properties;
+ Set<String> lookup_properties;
// Properties from specific Nodes that should be ignored.
- Map<StringName, Vector<StringName>> exception_list;
+ Map<String, Vector<String>> exception_list;
public:
virtual Error parse_file(const String &p_path, Vector<String> *r_ids, Vector<Vector<String>> *r_ids_ctx_plural) override;
diff --git a/editor/plugins/polygon_2d_editor_plugin.cpp b/editor/plugins/polygon_2d_editor_plugin.cpp
index 6a7a98ff89..b116f8ff6d 100644
--- a/editor/plugins/polygon_2d_editor_plugin.cpp
+++ b/editor/plugins/polygon_2d_editor_plugin.cpp
@@ -92,8 +92,8 @@ void Polygon2DEditor::_notification(int p_what) {
[[fallthrough]];
}
case NOTIFICATION_THEME_CHANGED: {
- uv_edit_draw->add_theme_style_override(SNAME("panel"), get_theme_stylebox(SNAME("bg"), SNAME("Tree")));
- bone_scroll->add_theme_style_override(SNAME("bg"), get_theme_stylebox(SNAME("bg"), SNAME("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_VISIBILITY_CHANGED: {
if (!is_visible()) {
diff --git a/editor/plugins/collision_polygon_3d_editor_plugin.cpp b/editor/plugins/polygon_3d_editor_plugin.cpp
index 52651ae380..4014da2441 100644
--- a/editor/plugins/collision_polygon_3d_editor_plugin.cpp
+++ b/editor/plugins/polygon_3d_editor_plugin.cpp
@@ -1,5 +1,5 @@
/*************************************************************************/
-/* collision_polygon_3d_editor_plugin.cpp */
+/* polygon_3d_editor_plugin.cpp */
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
@@ -28,9 +28,10 @@
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
-#include "collision_polygon_3d_editor_plugin.h"
+#include "polygon_3d_editor_plugin.h"
#include "canvas_item_editor_plugin.h"
+#include "core/core_string_names.h"
#include "core/input/input.h"
#include "core/io/file_access.h"
#include "core/math/geometry_2d.h"
@@ -39,13 +40,13 @@
#include "node_3d_editor_plugin.h"
#include "scene/3d/camera_3d.h"
-void CollisionPolygon3DEditor::_notification(int p_what) {
+void Polygon3DEditor::_notification(int p_what) {
switch (p_what) {
case NOTIFICATION_READY: {
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));
+ get_tree()->connect("node_removed", callable_mp(this, &Polygon3DEditor::_node_removed));
} break;
case NOTIFICATION_PROCESS: {
@@ -62,7 +63,7 @@ void CollisionPolygon3DEditor::_notification(int p_what) {
}
}
-void CollisionPolygon3DEditor::_node_removed(Node *p_node) {
+void Polygon3DEditor::_node_removed(Node *p_node) {
if (p_node == node) {
node = nullptr;
if (imgeom->get_parent() == p_node) {
@@ -73,7 +74,7 @@ void CollisionPolygon3DEditor::_node_removed(Node *p_node) {
}
}
-void CollisionPolygon3DEditor::_menu_option(int p_option) {
+void Polygon3DEditor::_menu_option(int p_option) {
switch (p_option) {
case MODE_CREATE: {
mode = MODE_CREATE;
@@ -88,10 +89,12 @@ void CollisionPolygon3DEditor::_menu_option(int p_option) {
}
}
-void CollisionPolygon3DEditor::_wip_close() {
+void Polygon3DEditor::_wip_close() {
+ Object *obj = node_resource.is_valid() ? (Object *)node_resource.ptr() : node;
+ ERR_FAIL_COND_MSG(!obj, "Edited object is not valid.");
undo_redo->create_action(TTR("Create Polygon3D"));
- undo_redo->add_undo_method(node, "set_polygon", node->call("get_polygon"));
- undo_redo->add_do_method(node, "set_polygon", wip);
+ undo_redo->add_undo_method(obj, "set_polygon", obj->call("get_polygon"));
+ undo_redo->add_do_method(obj, "set_polygon", wip);
undo_redo->add_do_method(this, "_polygon_draw");
undo_redo->add_undo_method(this, "_polygon_draw");
wip.clear();
@@ -103,11 +106,12 @@ void CollisionPolygon3DEditor::_wip_close() {
undo_redo->commit_action();
}
-EditorPlugin::AfterGUIInput CollisionPolygon3DEditor::forward_spatial_gui_input(Camera3D *p_camera, const Ref<InputEvent> &p_event) {
+EditorPlugin::AfterGUIInput Polygon3DEditor::forward_spatial_gui_input(Camera3D *p_camera, const Ref<InputEvent> &p_event) {
if (!node) {
return EditorPlugin::AFTER_GUI_INPUT_PASS;
}
+ Object *obj = node_resource.is_valid() ? (Object *)node_resource.ptr() : node;
Transform3D gt = node->get_global_transform();
Transform3D gi = gt.affine_inverse();
float depth = _get_depth() * 0.5;
@@ -135,7 +139,7 @@ EditorPlugin::AfterGUIInput CollisionPolygon3DEditor::forward_spatial_gui_input(
//Let the snap happen when the point is being moved, instead.
//cpoint = CanvasItemEditor::get_singleton()->snap_point(cpoint);
- Vector<Vector2> poly = node->call("get_polygon");
+ PackedVector2Array poly = _get_polygon();
//first check if a point is to be added (segment split)
real_t grab_threshold = EDITOR_GET("editors/polygon_editor/point_grab_radius");
@@ -178,9 +182,9 @@ EditorPlugin::AfterGUIInput CollisionPolygon3DEditor::forward_spatial_gui_input(
if (mb->is_ctrl_pressed()) {
if (poly.size() < 3) {
undo_redo->create_action(TTR("Edit Poly"));
- undo_redo->add_undo_method(node, "set_polygon", poly);
+ undo_redo->add_undo_method(obj, "set_polygon", poly);
poly.push_back(cpoint);
- undo_redo->add_do_method(node, "set_polygon", poly);
+ undo_redo->add_do_method(obj, "set_polygon", poly);
undo_redo->add_do_method(this, "_polygon_draw");
undo_redo->add_undo_method(this, "_polygon_draw");
undo_redo->commit_action();
@@ -215,7 +219,7 @@ EditorPlugin::AfterGUIInput CollisionPolygon3DEditor::forward_spatial_gui_input(
poly.insert(closest_idx + 1, cpoint);
edited_point = closest_idx + 1;
edited_point_pos = cpoint;
- node->call("set_polygon", poly);
+ _set_polygon(poly);
_polygon_draw();
snap_ignore = true;
@@ -256,8 +260,8 @@ EditorPlugin::AfterGUIInput CollisionPolygon3DEditor::forward_spatial_gui_input(
ERR_FAIL_INDEX_V(edited_point, poly.size(), EditorPlugin::AFTER_GUI_INPUT_PASS);
poly.write[edited_point] = edited_point_pos;
undo_redo->create_action(TTR("Edit Poly"));
- undo_redo->add_do_method(node, "set_polygon", poly);
- undo_redo->add_undo_method(node, "set_polygon", pre_move_edit);
+ undo_redo->add_do_method(obj, "set_polygon", poly);
+ undo_redo->add_undo_method(obj, "set_polygon", pre_move_edit);
undo_redo->add_do_method(this, "_polygon_draw");
undo_redo->add_undo_method(this, "_polygon_draw");
undo_redo->commit_action();
@@ -284,9 +288,9 @@ EditorPlugin::AfterGUIInput CollisionPolygon3DEditor::forward_spatial_gui_input(
if (closest_idx >= 0) {
undo_redo->create_action(TTR("Edit Poly (Remove Point)"));
- undo_redo->add_undo_method(node, "set_polygon", poly);
+ undo_redo->add_undo_method(obj, "set_polygon", poly);
poly.remove_at(closest_idx);
- undo_redo->add_do_method(node, "set_polygon", poly);
+ undo_redo->add_do_method(obj, "set_polygon", poly);
undo_redo->add_do_method(this, "_polygon_draw");
undo_redo->add_undo_method(this, "_polygon_draw");
undo_redo->commit_action();
@@ -335,25 +339,40 @@ EditorPlugin::AfterGUIInput CollisionPolygon3DEditor::forward_spatial_gui_input(
return EditorPlugin::AFTER_GUI_INPUT_PASS;
}
-float CollisionPolygon3DEditor::_get_depth() {
- if (bool(node->call("_has_editable_3d_polygon_no_depth"))) {
- return 0;
+float Polygon3DEditor::_get_depth() {
+ Object *obj = node_resource.is_valid() ? (Object *)node_resource.ptr() : node;
+ ERR_FAIL_COND_V_MSG(!obj, 0.0f, "Edited object is not valid.");
+
+ if (bool(obj->call("_has_editable_3d_polygon_no_depth"))) {
+ return 0.0f;
}
- return float(node->call("get_depth"));
+ return float(obj->call("get_depth"));
+}
+
+PackedVector2Array Polygon3DEditor::_get_polygon() {
+ Object *obj = node_resource.is_valid() ? (Object *)node_resource.ptr() : node;
+ ERR_FAIL_COND_V_MSG(!obj, PackedVector2Array(), "Edited object is not valid.");
+ return PackedVector2Array(obj->call("get_polygon"));
+}
+
+void Polygon3DEditor::_set_polygon(PackedVector2Array p_poly) {
+ Object *obj = node_resource.is_valid() ? (Object *)node_resource.ptr() : node;
+ ERR_FAIL_COND_MSG(!obj, "Edited object is not valid.");
+ obj->call("set_polygon", p_poly);
}
-void CollisionPolygon3DEditor::_polygon_draw() {
+void Polygon3DEditor::_polygon_draw() {
if (!node) {
return;
}
- Vector<Vector2> poly;
+ PackedVector2Array poly;
if (wip_active) {
poly = wip;
} else {
- poly = node->call("get_polygon");
+ poly = _get_polygon();
}
float depth = _get_depth() * 0.5;
@@ -464,23 +483,32 @@ void CollisionPolygon3DEditor::_polygon_draw() {
m->surface_set_material(0, handle_material);
}
-void CollisionPolygon3DEditor::edit(Node *p_collision_polygon) {
- if (p_collision_polygon) {
- node = Object::cast_to<Node3D>(p_collision_polygon);
+void Polygon3DEditor::edit(Node *p_node) {
+ if (p_node) {
+ node = Object::cast_to<Node3D>(p_node);
+ node_resource = node->call("_get_editable_3d_polygon_resource");
+
+ if (node_resource.is_valid()) {
+ node_resource->connect(CoreStringNames::get_singleton()->changed, callable_mp(this, &Polygon3DEditor::_polygon_draw));
+ }
//Enable the pencil tool if the polygon is empty
- if (Vector<Vector2>(node->call("get_polygon")).size() == 0) {
+ if (_get_polygon().is_empty()) {
_menu_option(MODE_CREATE);
}
wip.clear();
wip_active = false;
edited_point = -1;
- p_collision_polygon->add_child(imgeom);
+ p_node->add_child(imgeom);
_polygon_draw();
set_process(true);
prev_depth = -1;
} else {
node = nullptr;
+ if (node_resource.is_valid()) {
+ node_resource->disconnect(CoreStringNames::get_singleton()->changed, callable_mp(this, &Polygon3DEditor::_polygon_draw));
+ }
+ node_resource.unref();
if (imgeom->get_parent()) {
imgeom->get_parent()->remove_child(imgeom);
@@ -490,11 +518,11 @@ void CollisionPolygon3DEditor::edit(Node *p_collision_polygon) {
}
}
-void CollisionPolygon3DEditor::_bind_methods() {
- ClassDB::bind_method(D_METHOD("_polygon_draw"), &CollisionPolygon3DEditor::_polygon_draw);
+void Polygon3DEditor::_bind_methods() {
+ ClassDB::bind_method(D_METHOD("_polygon_draw"), &Polygon3DEditor::_polygon_draw);
}
-CollisionPolygon3DEditor::CollisionPolygon3DEditor(EditorNode *p_editor) {
+Polygon3DEditor::Polygon3DEditor(EditorNode *p_editor) {
node = nullptr;
editor = p_editor;
undo_redo = EditorNode::get_undo_redo();
@@ -503,13 +531,13 @@ CollisionPolygon3DEditor::CollisionPolygon3DEditor(EditorNode *p_editor) {
button_create = memnew(Button);
button_create->set_flat(true);
add_child(button_create);
- button_create->connect("pressed", callable_mp(this, &CollisionPolygon3DEditor::_menu_option), varray(MODE_CREATE));
+ button_create->connect("pressed", callable_mp(this, &Polygon3DEditor::_menu_option), varray(MODE_CREATE));
button_create->set_toggle_mode(true);
button_edit = memnew(Button);
button_edit->set_flat(true);
add_child(button_edit);
- button_edit->connect("pressed", callable_mp(this, &CollisionPolygon3DEditor::_menu_option), varray(MODE_EDIT));
+ button_edit->connect("pressed", callable_mp(this, &Polygon3DEditor::_menu_option), varray(MODE_EDIT));
button_edit->set_toggle_mode(true);
mode = MODE_EDIT;
@@ -545,12 +573,12 @@ CollisionPolygon3DEditor::CollisionPolygon3DEditor(EditorNode *p_editor) {
snap_ignore = false;
}
-CollisionPolygon3DEditor::~CollisionPolygon3DEditor() {
+Polygon3DEditor::~Polygon3DEditor() {
memdelete(imgeom);
}
void Polygon3DEditorPlugin::edit(Object *p_object) {
- collision_polygon_editor->edit(Object::cast_to<Node>(p_object));
+ polygon_editor->edit(Object::cast_to<Node>(p_object));
}
bool Polygon3DEditorPlugin::handles(Object *p_object) const {
@@ -559,19 +587,19 @@ bool Polygon3DEditorPlugin::handles(Object *p_object) const {
void Polygon3DEditorPlugin::make_visible(bool p_visible) {
if (p_visible) {
- collision_polygon_editor->show();
+ polygon_editor->show();
} else {
- collision_polygon_editor->hide();
- collision_polygon_editor->edit(nullptr);
+ polygon_editor->hide();
+ polygon_editor->edit(nullptr);
}
}
Polygon3DEditorPlugin::Polygon3DEditorPlugin(EditorNode *p_node) {
editor = p_node;
- collision_polygon_editor = memnew(CollisionPolygon3DEditor(p_node));
- Node3DEditor::get_singleton()->add_control_to_menu_panel(collision_polygon_editor);
+ polygon_editor = memnew(Polygon3DEditor(p_node));
+ Node3DEditor::get_singleton()->add_control_to_menu_panel(polygon_editor);
- collision_polygon_editor->hide();
+ polygon_editor->hide();
}
Polygon3DEditorPlugin::~Polygon3DEditorPlugin() {
diff --git a/editor/plugins/collision_polygon_3d_editor_plugin.h b/editor/plugins/polygon_3d_editor_plugin.h
index cd8c857398..6b0370541e 100644
--- a/editor/plugins/collision_polygon_3d_editor_plugin.h
+++ b/editor/plugins/polygon_3d_editor_plugin.h
@@ -1,5 +1,5 @@
/*************************************************************************/
-/* collision_polygon_3d_editor_plugin.h */
+/* polygon_3d_editor_plugin.h */
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
@@ -28,8 +28,8 @@
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
-#ifndef COLLISION_POLYGON_EDITOR_PLUGIN_H
-#define COLLISION_POLYGON_EDITOR_PLUGIN_H
+#ifndef POLYGON_3D_EDITOR_PLUGIN_H
+#define POLYGON_3D_EDITOR_PLUGIN_H
#include "editor/editor_node.h"
#include "editor/editor_plugin.h"
@@ -39,8 +39,8 @@
class CanvasItemEditor;
-class CollisionPolygon3DEditor : public HBoxContainer {
- GDCLASS(CollisionPolygon3DEditor, HBoxContainer);
+class Polygon3DEditor : public HBoxContainer {
+ GDCLASS(Polygon3DEditor, HBoxContainer);
UndoRedo *undo_redo;
enum Mode {
@@ -60,6 +60,7 @@ class CollisionPolygon3DEditor : public HBoxContainer {
EditorNode *editor;
Panel *panel;
Node3D *node;
+ Ref<Resource> node_resource;
Ref<ImmediateMesh> imesh;
MeshInstance3D *imgeom;
MeshInstance3D *pointsm;
@@ -69,8 +70,8 @@ class CollisionPolygon3DEditor : public HBoxContainer {
int edited_point;
Vector2 edited_point_pos;
- Vector<Vector2> pre_move_edit;
- Vector<Vector2> wip;
+ PackedVector2Array pre_move_edit;
+ PackedVector2Array wip;
bool wip_active;
bool snap_ignore;
@@ -81,6 +82,8 @@ class CollisionPolygon3DEditor : public HBoxContainer {
void _menu_option(int p_option);
float _get_depth();
+ PackedVector2Array _get_polygon();
+ void _set_polygon(PackedVector2Array p_poly);
protected:
void _notification(int p_what);
@@ -89,19 +92,19 @@ protected:
public:
virtual EditorPlugin::AfterGUIInput forward_spatial_gui_input(Camera3D *p_camera, const Ref<InputEvent> &p_event);
- void edit(Node *p_collision_polygon);
- CollisionPolygon3DEditor(EditorNode *p_editor);
- ~CollisionPolygon3DEditor();
+ void edit(Node *p_node);
+ Polygon3DEditor(EditorNode *p_editor);
+ ~Polygon3DEditor();
};
class Polygon3DEditorPlugin : public EditorPlugin {
GDCLASS(Polygon3DEditorPlugin, EditorPlugin);
- CollisionPolygon3DEditor *collision_polygon_editor;
+ Polygon3DEditor *polygon_editor;
EditorNode *editor;
public:
- virtual EditorPlugin::AfterGUIInput forward_spatial_gui_input(Camera3D *p_camera, const Ref<InputEvent> &p_event) override { return collision_polygon_editor->forward_spatial_gui_input(p_camera, p_event); }
+ virtual EditorPlugin::AfterGUIInput forward_spatial_gui_input(Camera3D *p_camera, const Ref<InputEvent> &p_event) override { return polygon_editor->forward_spatial_gui_input(p_camera, p_event); }
virtual String get_name() const override { return "Polygon3DEditor"; }
bool has_main_screen() const override { return false; }
@@ -113,4 +116,4 @@ public:
~Polygon3DEditorPlugin();
};
-#endif // COLLISION_POLYGON_EDITOR_PLUGIN_H
+#endif // POLYGON_3D_EDITOR_PLUGIN_H
diff --git a/editor/plugins/replication_editor_plugin.cpp b/editor/plugins/replication_editor_plugin.cpp
index 467db13246..fd4fc8f59c 100644
--- a/editor/plugins/replication_editor_plugin.cpp
+++ b/editor/plugins/replication_editor_plugin.cpp
@@ -95,7 +95,7 @@ void ReplicationEditor::_bind_methods() {
void ReplicationEditor::_notification(int p_what) {
if (p_what == NOTIFICATION_ENTER_TREE || p_what == EditorSettings::NOTIFICATION_EDITOR_SETTINGS_CHANGED) {
- add_theme_style_override(SNAME("panel"), editor->get_gui_base()->get_theme_stylebox(SNAME("panel"), SNAME("Panel")));
+ add_theme_style_override("panel", editor->get_gui_base()->get_theme_stylebox(SNAME("panel"), SNAME("Panel")));
} else if (p_what == NOTIFICATION_VISIBILITY_CHANGED) {
update_keying();
}
@@ -257,10 +257,10 @@ void ReplicationEditor::edit(MultiplayerSynchronizer *p_sync) {
}
Ref<Texture2D> ReplicationEditor::_get_class_icon(const Node *p_node) {
- if (!p_node || !has_theme_icon(p_node->get_class(), SNAME("EditorIcons"))) {
+ if (!p_node || !has_theme_icon(p_node->get_class(), "EditorIcons")) {
return get_theme_icon(SNAME("ImportFail"), SNAME("EditorIcons"));
}
- return get_theme_icon(p_node->get_class(), SNAME("EditorIcons"));
+ return get_theme_icon(p_node->get_class(), "EditorIcons");
}
void ReplicationEditor::_add_property(const NodePath &p_property, bool p_spawn, bool p_sync) {
diff --git a/editor/plugins/resource_preloader_editor_plugin.cpp b/editor/plugins/resource_preloader_editor_plugin.cpp
index 271d035986..786217a5c2 100644
--- a/editor/plugins/resource_preloader_editor_plugin.cpp
+++ b/editor/plugins/resource_preloader_editor_plugin.cpp
@@ -341,7 +341,7 @@ void ResourcePreloaderEditor::_bind_methods() {
}
ResourcePreloaderEditor::ResourcePreloaderEditor() {
- //add_style_override(SNAME("panel"), EditorNode::get_singleton()->get_gui_base()->get_stylebox("panel","Panel"));
+ //add_style_override("panel", EditorNode::get_singleton()->get_gui_base()->get_stylebox("panel","Panel"));
VBoxContainer *vbc = memnew(VBoxContainer);
add_child(vbc);
diff --git a/editor/plugins/script_editor_plugin.cpp b/editor/plugins/script_editor_plugin.cpp
index b20f9650ac..17de3ba026 100644
--- a/editor/plugins/script_editor_plugin.cpp
+++ b/editor/plugins/script_editor_plugin.cpp
@@ -381,7 +381,7 @@ ScriptEditorQuickOpen::ScriptEditorQuickOpen() {
search_options->connect("item_activated", callable_mp(this, &ScriptEditorQuickOpen::_confirmed));
search_options->set_hide_root(true);
search_options->set_hide_folding(true);
- search_options->add_theme_constant_override(SNAME("draw_guides"), 1);
+ search_options->add_theme_constant_override("draw_guides", 1);
}
/////////////////////////////////
@@ -1630,7 +1630,7 @@ void ScriptEditor::_notification(int p_what) {
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(SNAME("normal"), editor->get_gui_base()->get_theme_stylebox(SNAME("normal"), SNAME("LineEdit")));
+ filename->add_theme_style_override("normal", editor->get_gui_base()->get_theme_stylebox(SNAME("normal"), SNAME("LineEdit")));
recent_scripts->set_as_minsize();
@@ -2265,7 +2265,7 @@ bool ScriptEditor::edit(const RES &p_resource, int p_line, int p_col, bool p_gra
if (use_external_editor &&
(EditorDebuggerNode::get_singleton()->get_dump_stack_script() != p_resource || EditorDebuggerNode::get_singleton()->get_debug_with_external_editor()) &&
p_resource->get_path().is_resource_file() &&
- p_resource->get_class_name() != StringName("VisualScript")) {
+ !Ref<VisualScript>(p_resource).is_valid()) {
String path = EditorSettings::get_singleton()->get("text_editor/external/exec_path");
String flags = EditorSettings::get_singleton()->get("text_editor/external/exec_flags");
@@ -2364,7 +2364,7 @@ bool ScriptEditor::edit(const RES &p_resource, int p_line, int p_col, bool p_gra
se->set_edited_resource(p_resource);
- if (p_resource->get_class_name() != StringName("VisualScript")) {
+ if (!Ref<VisualScript>(p_resource).is_valid()) {
bool highlighter_set = false;
for (int i = 0; i < syntax_highlighters.size(); i++) {
Ref<EditorSyntaxHighlighter> highlighter = syntax_highlighters[i]->_create();
@@ -3693,7 +3693,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(SNAME("normal"), EditorNode::get_singleton()->get_gui_base()->get_theme_stylebox(SNAME("normal"), SNAME("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);
@@ -3948,8 +3948,8 @@ ScriptEditor::ScriptEditor(EditorNode *p_editor) {
ScriptServer::edit_request_func = _open_script_request;
- add_theme_style_override(SNAME("panel"), editor->get_gui_base()->get_theme_stylebox(SNAME("ScriptEditorPanel"), SNAME("EditorStyles")));
- tab_container->add_theme_style_override(SNAME("panel"), editor->get_gui_base()->get_theme_stylebox(SNAME("ScriptEditor"), SNAME("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 a818caabbe..c3d61dfd58 100644
--- a/editor/plugins/script_text_editor.cpp
+++ b/editor/plugins/script_text_editor.cpp
@@ -930,21 +930,22 @@ void ScriptTextEditor::_update_connected_methods() {
continue;
}
- if (methods_found.has(connection.callable.get_method())) {
+ const StringName method = connection.callable.get_method();
+ if (methods_found.has(method)) {
continue;
}
- if (!ClassDB::has_method(script->get_instance_base_type(), connection.callable.get_method())) {
+ if (!ClassDB::has_method(script->get_instance_base_type(), method)) {
int line = -1;
for (int j = 0; j < functions.size(); j++) {
String name = functions[j].get_slice(":", 0);
- if (name == connection.callable.get_method()) {
+ if (name == 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_metadata(line, connection_gutter, method);
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());
+ methods_found.insert(method);
break;
}
}
@@ -957,7 +958,7 @@ void ScriptTextEditor::_update_connected_methods() {
bool found_inherited_function = false;
Ref<Script> inherited_script = script->get_base_script();
while (!inherited_script.is_null()) {
- if (inherited_script->has_method(connection.callable.get_method())) {
+ if (inherited_script->has_method(method)) {
found_inherited_function = true;
break;
}
@@ -1373,7 +1374,7 @@ void ScriptTextEditor::reload(bool p_soft) {
return;
}
scr->set_source_code(te->get_text());
- bool soft = p_soft || scr->get_instance_base_type() == "EditorPlugin"; //always soft-reload editor plugins
+ bool soft = p_soft || scr->get_instance_base_type() == "EditorPlugin"; // Always soft-reload editor plugins.
scr->get_language()->reload_tool_script(scr, soft);
}
@@ -1848,7 +1849,7 @@ void ScriptTextEditor::_enable_code_editor() {
ScriptTextEditor::ScriptTextEditor() {
code_editor = memnew(CodeTextEditor);
- code_editor->add_theme_constant_override(SNAME("separation"), 2);
+ code_editor->add_theme_constant_override("separation", 2);
code_editor->set_anchors_and_offsets_preset(Control::PRESET_WIDE);
code_editor->set_code_complete_func(_code_complete_scripts, this);
code_editor->set_v_size_flags(SIZE_EXPAND_FILL);
diff --git a/editor/plugins/shader_editor_plugin.cpp b/editor/plugins/shader_editor_plugin.cpp
index 9aff507bdd..4bbeb33406 100644
--- a/editor/plugins/shader_editor_plugin.cpp
+++ b/editor/plugins/shader_editor_plugin.cpp
@@ -189,8 +189,8 @@ void ShaderTextEditor::_load_theme_settings() {
if (warnings_panel) {
// Warnings panel
- warnings_panel->add_theme_font_override(SNAME("normal_font"), EditorNode::get_singleton()->get_gui_base()->get_theme_font(SNAME("main"), SNAME("EditorFonts")));
- warnings_panel->add_theme_font_size_override(SNAME("normal_font_size"), EditorNode::get_singleton()->get_gui_base()->get_theme_font_size(SNAME("main_size"), SNAME("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")));
}
}
@@ -443,7 +443,7 @@ void ShaderEditor::_notification(int p_what) {
void ShaderEditor::_editor_settings_changed() {
shader_editor->update_editor_settings();
- shader_editor->get_text_editor()->add_theme_constant_override(SNAME("line_spacing"), EditorSettings::get_singleton()->get("text_editor/appearance/whitespace/line_spacing"));
+ shader_editor->get_text_editor()->add_theme_constant_override("line_spacing", EditorSettings::get_singleton()->get("text_editor/appearance/whitespace/line_spacing"));
shader_editor->get_text_editor()->set_draw_breakpoints_gutter(false);
shader_editor->get_text_editor()->set_draw_executing_lines_gutter(false);
}
@@ -701,7 +701,7 @@ ShaderEditor::ShaderEditor(EditorNode *p_node) {
shader_editor = memnew(ShaderTextEditor);
shader_editor->set_v_size_flags(SIZE_EXPAND_FILL);
- shader_editor->add_theme_constant_override(SNAME("separation"), 0);
+ shader_editor->add_theme_constant_override("separation", 0);
shader_editor->set_anchors_and_offsets_preset(Control::PRESET_WIDE);
shader_editor->connect("show_warnings_panel", callable_mp(this, &ShaderEditor::_show_warnings_panel));
@@ -789,7 +789,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(SNAME("panel"), p_node->get_gui_base()->get_theme_stylebox(SNAME("ScriptEditorPanel"), SNAME("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);
diff --git a/editor/plugins/skeleton_3d_editor_plugin.cpp b/editor/plugins/skeleton_3d_editor_plugin.cpp
index 9e2ded3ec9..ac77f51812 100644
--- a/editor/plugins/skeleton_3d_editor_plugin.cpp
+++ b/editor/plugins/skeleton_3d_editor_plugin.cpp
@@ -602,7 +602,7 @@ void Skeleton3DEditor::update_editors() {
void Skeleton3DEditor::create_editors() {
set_h_size_flags(SIZE_EXPAND_FILL);
- add_theme_constant_override(SNAME("separation"), 0);
+ add_theme_constant_override("separation", 0);
set_focus_mode(FOCUS_ALL);
diff --git a/editor/plugins/sprite_frames_editor_plugin.cpp b/editor/plugins/sprite_frames_editor_plugin.cpp
index e504756440..419076a3f6 100644
--- a/editor/plugins/sprite_frames_editor_plugin.cpp
+++ b/editor/plugins/sprite_frames_editor_plugin.cpp
@@ -328,10 +328,10 @@ void SpriteFramesEditor::_notification(int p_what) {
[[fallthrough]];
}
case NOTIFICATION_THEME_CHANGED: {
- split_sheet_scroll->add_theme_style_override(SNAME("bg"), get_theme_stylebox(SNAME("bg"), SNAME("Tree")));
+ split_sheet_scroll->add_theme_style_override("bg", get_theme_stylebox(SNAME("bg"), SNAME("Tree")));
} break;
case NOTIFICATION_READY: {
- add_theme_constant_override(SNAME("autohide"), 1); // Fixes the dragger always showing up.
+ add_theme_constant_override("autohide", 1); // Fixes the dragger always showing up.
} break;
}
}
@@ -1247,8 +1247,8 @@ SpriteFramesEditor::SpriteFramesEditor() {
split_sheet_panel->add_child(split_sheet_zoom_margin);
split_sheet_zoom_margin->set_h_size_flags(0);
split_sheet_zoom_margin->set_v_size_flags(0);
- split_sheet_zoom_margin->add_theme_constant_override(SNAME("margin_top"), 5);
- split_sheet_zoom_margin->add_theme_constant_override(SNAME("margin_left"), 5);
+ split_sheet_zoom_margin->add_theme_constant_override("margin_top", 5);
+ split_sheet_zoom_margin->add_theme_constant_override("margin_left", 5);
HBoxContainer *split_sheet_zoom_hb = memnew(HBoxContainer);
split_sheet_zoom_margin->add_child(split_sheet_zoom_hb);
diff --git a/editor/plugins/style_box_editor_plugin.cpp b/editor/plugins/style_box_editor_plugin.cpp
index 8ec5ffc0a3..5d38352b22 100644
--- a/editor/plugins/style_box_editor_plugin.cpp
+++ b/editor/plugins/style_box_editor_plugin.cpp
@@ -50,7 +50,7 @@ void StyleBoxPreview::edit(const Ref<StyleBox> &p_stylebox) {
}
stylebox = p_stylebox;
if (p_stylebox.is_valid()) {
- preview->add_theme_style_override(SNAME("panel"), stylebox);
+ preview->add_theme_style_override("panel", stylebox);
stylebox->connect("changed", callable_mp(this, &StyleBoxPreview::_sb_changed));
}
_sb_changed();
diff --git a/editor/plugins/text_control_editor_plugin.cpp b/editor/plugins/text_control_editor_plugin.cpp
index 59796179a6..4ce94176e5 100644
--- a/editor/plugins/text_control_editor_plugin.cpp
+++ b/editor/plugins/text_control_editor_plugin.cpp
@@ -110,7 +110,7 @@ void TextControlEditor::_update_styles_menu() {
for (Map<String, String>::Element *E = fonts[name].front(); E; E = E->next()) {
font_style_list->add_item(E->key());
}
- } else {
+ } else if (font_list->get_selected() >= 0) {
font_style_list->add_item("Default");
}
@@ -123,9 +123,9 @@ void TextControlEditor::_update_styles_menu() {
void TextControlEditor::_update_control() {
if (!edited_controls.is_empty()) {
- int font_selected = 0;
+ String font_selected;
bool same_font = true;
- int style_selected = 0;
+ String style_selected;
bool same_style = true;
int font_size = 0;
bool same_font_size = true;
@@ -136,26 +136,23 @@ void TextControlEditor::_update_control() {
Color outline_color = Color{ 1.0f, 1.0f, 1.0f };
bool same_outline_color = true;
- _update_fonts_menu();
- _update_styles_menu();
-
int count = edited_controls.size();
for (int i = 0; i < count; ++i) {
Control *edited_control = edited_controls[i];
- String edited_color;
- String edited_font;
- String edited_font_size;
+ StringName edited_color;
+ StringName edited_font;
+ StringName edited_font_size;
// Get override names.
- if (edited_control->is_class("RichTextLabel")) {
- edited_color = "default_color";
- edited_font = "normal_font";
- edited_font_size = "normal_font_size";
+ if (Object::cast_to<RichTextLabel>(edited_control)) {
+ edited_color = SNAME("default_color");
+ edited_font = SNAME("normal_font");
+ edited_font_size = SNAME("normal_font_size");
} else {
- edited_color = "font_color";
- edited_font = "font";
- edited_font_size = "font_size";
+ edited_color = SNAME("font_color");
+ edited_font = SNAME("font");
+ edited_font_size = SNAME("font_size");
}
// Get font override.
@@ -166,57 +163,40 @@ void TextControlEditor::_update_control() {
if (font.is_valid()) {
if (font->get_data_count() != 1) {
- custom_font = font;
if (i > 0) {
- same_font = same_font && (font_selected == FONT_INFO_USER_CUSTOM);
- same_style = same_style && (style_selected == 0);
+ same_font = same_font && (custom_font == font);
}
+ custom_font = font;
- font_selected = FONT_INFO_USER_CUSTOM;
- style_selected = 0;
+ font_selected = TTR("[Custom Font]");
+ same_style = false;
} else {
String name = font->get_data(0)->get_font_name();
String style = font->get_data(0)->get_font_style_name();
if (fonts.has(name) && fonts[name].has(style)) {
- for (int j = 0; j < font_list->get_item_count(); j++) {
- if (font_list->get_item_text(j) == name) {
- if (i > 0) {
- same_font = same_font && (j == font_selected);
- }
-
- font_selected = j;
- break;
- }
- }
- for (int j = 0; j < font_style_list->get_item_count(); j++) {
- if (font_style_list->get_item_text(j) == style) {
- if (i > 0) {
- same_style = same_style && (j == style_selected);
- }
-
- style_selected = j;
- break;
- }
+ if (i > 0) {
+ same_font = same_font && (name == font_selected);
+ same_style = same_style && (style == style_selected);
}
+ font_selected = name;
+ style_selected = style;
} else {
- custom_font = font;
if (i > 0) {
- same_font = same_font && (font_selected == FONT_INFO_USER_CUSTOM);
- same_style = same_style && (style_selected == 0);
+ same_font = same_font && (custom_font == font);
}
+ custom_font = font;
- font_selected = FONT_INFO_USER_CUSTOM;
- style_selected = 0;
+ font_selected = TTR("[Custom Font]");
+ same_style = false;
}
}
} else {
if (i > 0) {
- same_font = same_font && (font_selected == FONT_INFO_THEME_DEFAULT);
- same_style = same_style && (style_selected == 0);
+ same_font = same_font && (font_selected == TTR("[Theme Default]"));
}
- font_selected = FONT_INFO_THEME_DEFAULT;
- style_selected = 0;
+ font_selected = TTR("[Theme Default]");
+ same_style = false;
}
int current_font_size = edited_control->get_theme_font_size(edited_font_size);
@@ -235,19 +215,29 @@ void TextControlEditor::_update_control() {
font_color = current_font_color;
outline_color = current_outline_color;
}
-
_update_fonts_menu();
if (same_font) {
- font_list->select(font_selected);
+ for (int j = 0; j < font_list->get_item_count(); j++) {
+ if (font_list->get_item_text(j) == font_selected) {
+ font_list->select(j);
+ break;
+ }
+ }
} else {
+ custom_font = Ref<Font>();
font_list->select(-1);
}
_update_styles_menu();
if (same_style) {
- font_style_list->select(style_selected);
+ for (int j = 0; j < font_style_list->get_item_count(); j++) {
+ if (font_style_list->get_item_text(j) == style_selected) {
+ font_style_list->select(j);
+ break;
+ }
+ }
} else {
- font_list->select(-1);
+ font_style_list->select(-1);
}
// Get other theme overrides.
@@ -282,6 +272,7 @@ void TextControlEditor::_update_control() {
}
void TextControlEditor::_font_selected(int p_id) {
+ _update_styles_menu();
_set_font();
}
@@ -301,11 +292,11 @@ void TextControlEditor::_set_font() {
for (int i = 0; i < count; ++i) {
Control *edited_control = edited_controls[i];
- String edited_font;
- if (edited_control->is_class("RichTextLabel")) {
- edited_font = "normal_font";
+ StringName edited_font;
+ if (Object::cast_to<RichTextLabel>(edited_control)) {
+ edited_font = SNAME("normal_font");
} else {
- edited_font = "font";
+ edited_font = SNAME("font");
}
if (font_list->get_selected_id() == FONT_INFO_THEME_DEFAULT) {
@@ -314,14 +305,13 @@ void TextControlEditor::_set_font() {
} else if (font_list->get_selected_id() == FONT_INFO_USER_CUSTOM) {
// Restore "custom_font".
ur->add_do_method(edited_control, "add_theme_font_override", edited_font, custom_font);
- } else {
+ } else if (font_list->get_selected() >= 0) {
// Load new font resource using selected name and style.
String name = font_list->get_item_text(font_list->get_selected());
String style = font_style_list->get_item_text(font_style_list->get_selected());
if (style.is_empty()) {
style = "Default";
}
-
if (fonts.has(name)) {
Ref<FontData> fd = ResourceLoader::load(fonts[name][style]);
if (fd.is_valid()) {
@@ -358,11 +348,11 @@ void TextControlEditor::_font_size_selected(double p_size) {
for (int i = 0; i < count; ++i) {
Control *edited_control = edited_controls[i];
- String edited_font_size;
- if (edited_control->is_class("RichTextLabel")) {
- edited_font_size = "normal_font_size";
+ StringName edited_font_size;
+ if (Object::cast_to<RichTextLabel>(edited_control)) {
+ edited_font_size = SNAME("normal_font_size");
} else {
- edited_font_size = "font_size";
+ edited_font_size = SNAME("font_size");
}
ur->add_do_method(edited_control, "add_theme_font_size_override", edited_font_size, p_size);
@@ -392,7 +382,7 @@ void TextControlEditor::_outline_size_selected(double p_size) {
Control *edited_control = edited_controls[i];
ur->add_do_method(edited_control, "add_theme_constant_override", "outline_size", p_size);
- if (edited_control->has_theme_constant_override(SNAME("outline_size"))) {
+ if (edited_control->has_theme_constant_override("outline_size")) {
ur->add_undo_method(edited_control, "add_theme_constant_override", "outline_size", edited_control->get_theme_constant(SNAME("outline_size")));
} else {
ur->add_undo_method(edited_control, "remove_theme_constant_override", "outline_size");
@@ -417,11 +407,11 @@ void TextControlEditor::_font_color_changed(const Color &p_color) {
for (int i = 0; i < count; ++i) {
Control *edited_control = edited_controls[i];
- String edited_color;
- if (edited_control->is_class("RichTextLabel")) {
- edited_color = "default_color";
+ StringName edited_color;
+ if (Object::cast_to<RichTextLabel>(edited_control)) {
+ edited_color = SNAME("default_color");
} else {
- edited_color = "font_color";
+ edited_color = SNAME("font_color");
}
ur->add_do_method(edited_control, "add_theme_color_override", edited_color, p_color);
@@ -451,7 +441,7 @@ void TextControlEditor::_outline_color_changed(const Color &p_color) {
Control *edited_control = edited_controls[i];
ur->add_do_method(edited_control, "add_theme_color_override", "font_outline_color", p_color);
- if (edited_control->has_theme_color_override(SNAME("font_outline_color"))) {
+ if (edited_control->has_theme_color_override("font_outline_color")) {
ur->add_undo_method(edited_control, "add_theme_color_override", "font_outline_color", edited_control->get_theme_color(SNAME("font_outline_color")));
} else {
ur->add_undo_method(edited_control, "remove_theme_color_override", "font_outline_color");
@@ -476,19 +466,19 @@ void TextControlEditor::_clear_formatting() {
for (int i = 0; i < count; ++i) {
Control *edited_control = edited_controls[i];
- String edited_color;
- String edited_font;
- String edited_font_size;
+ StringName edited_color;
+ StringName edited_font;
+ StringName edited_font_size;
// Get override names.
- if (edited_control->is_class("RichTextLabel")) {
- edited_color = "default_color";
- edited_font = "normal_font";
- edited_font_size = "normal_font_size";
+ if (Object::cast_to<RichTextLabel>(edited_control)) {
+ edited_color = SNAME("default_color");
+ edited_font = SNAME("normal_font");
+ edited_font_size = SNAME("normal_font_size");
} else {
- edited_color = "font_color";
- edited_font = "font";
- edited_font_size = "font_size";
+ edited_color = SNAME("font_color");
+ edited_font = SNAME("font");
+ edited_font_size = SNAME("font_size");
}
ur->add_do_method(edited_control, "begin_bulk_theme_override");
@@ -510,12 +500,12 @@ void TextControlEditor::_clear_formatting() {
}
ur->add_do_method(edited_control, "remove_theme_color_override", "font_outline_color");
- if (edited_control->has_theme_color_override(SNAME("font_outline_color"))) {
+ if (edited_control->has_theme_color_override("font_outline_color")) {
ur->add_undo_method(edited_control, "add_theme_color_override", "font_outline_color", edited_control->get_theme_color(SNAME("font_outline_color")));
}
ur->add_do_method(edited_control, "remove_theme_constant_override", "outline_size");
- if (edited_control->has_theme_constant_override(SNAME("outline_size"))) {
+ if (edited_control->has_theme_constant_override("outline_size")) {
ur->add_undo_method(edited_control, "add_theme_constant_override", "outline_size", edited_control->get_theme_constant(SNAME("outline_size")));
}
@@ -600,7 +590,7 @@ TextControlEditor::TextControlEditor() {
font_size_list = memnew(SpinBox);
font_size_list->set_tooltip(TTR("Font Size"));
- font_size_list->get_line_edit()->add_theme_constant_override(SNAME("minimum_character_width"), 2);
+ font_size_list->get_line_edit()->add_theme_constant_override("minimum_character_width", 2);
font_size_list->set_min(6);
font_size_list->set_step(1);
font_size_list->set_max(96);
@@ -619,7 +609,7 @@ TextControlEditor::TextControlEditor() {
outline_size_list = memnew(SpinBox);
outline_size_list->set_tooltip(TTR("Outline Size"));
- outline_size_list->get_line_edit()->add_theme_constant_override(SNAME("minimum_character_width"), 2);
+ outline_size_list->get_line_edit()->add_theme_constant_override("minimum_character_width", 2);
outline_size_list->set_min(0);
outline_size_list->set_step(1);
outline_size_list->set_max(96);
diff --git a/editor/plugins/text_editor.cpp b/editor/plugins/text_editor.cpp
index 54cfff66c5..940f269803 100644
--- a/editor/plugins/text_editor.cpp
+++ b/editor/plugins/text_editor.cpp
@@ -521,7 +521,7 @@ void TextEditor::update_toggle_scripts_button() {
TextEditor::TextEditor() {
code_editor = memnew(CodeTextEditor);
add_child(code_editor);
- code_editor->add_theme_constant_override(SNAME("separation"), 0);
+ code_editor->add_theme_constant_override("separation", 0);
code_editor->connect("load_theme_settings", callable_mp(this, &TextEditor::_load_theme_settings));
code_editor->connect("validate_script", callable_mp(this, &TextEditor::_validate_script));
code_editor->set_anchors_and_offsets_preset(Control::PRESET_WIDE);
diff --git a/editor/plugins/texture_3d_editor_plugin.cpp b/editor/plugins/texture_3d_editor_plugin.cpp
index 6792d8b329..6080f9df87 100644
--- a/editor/plugins/texture_3d_editor_plugin.cpp
+++ b/editor/plugins/texture_3d_editor_plugin.cpp
@@ -171,11 +171,11 @@ Texture3DEditor::Texture3DEditor() {
info->set_anchor(SIDE_TOP, 1);
info->set_h_grow_direction(GROW_DIRECTION_BEGIN);
info->set_v_grow_direction(GROW_DIRECTION_BEGIN);
- info->add_theme_color_override(SNAME("font_color"), Color(1, 1, 1, 1));
- info->add_theme_color_override(SNAME("font_shadow_color"), Color(0, 0, 0, 0.5));
- info->add_theme_constant_override(SNAME("shadow_outline_size"), 1);
- info->add_theme_constant_override(SNAME("shadow_offset_x"), 2);
- info->add_theme_constant_override(SNAME("shadow_offset_y"), 2);
+ info->add_theme_color_override("font_color", Color(1, 1, 1, 1));
+ info->add_theme_color_override("font_shadow_color", Color(0, 0, 0, 0.5));
+ info->add_theme_constant_override("shadow_outline_size", 1);
+ info->add_theme_constant_override("shadow_offset_x", 2);
+ info->add_theme_constant_override("shadow_offset_y", 2);
setting = false;
layer->connect("value_changed", Callable(this, "_layer_changed"));
diff --git a/editor/plugins/texture_editor_plugin.cpp b/editor/plugins/texture_editor_plugin.cpp
index 85b5cde066..84b33f0986 100644
--- a/editor/plugins/texture_editor_plugin.cpp
+++ b/editor/plugins/texture_editor_plugin.cpp
@@ -50,7 +50,7 @@ void TexturePreview::_notification(int p_what) {
if (metadata_label) {
Ref<Font> metadata_label_font = get_theme_font(SNAME("expression"), SNAME("EditorFonts"));
- metadata_label->add_theme_font_override(SNAME("font"), metadata_label_font);
+ metadata_label->add_theme_font_override("font", metadata_label_font);
}
checkerboard->set_texture(get_theme_icon(SNAME("Checkerboard"), SNAME("EditorIcons")));
@@ -94,14 +94,14 @@ TexturePreview::TexturePreview(Ref<Texture2D> p_texture, bool p_show_metadata) {
p_texture->connect("changed", callable_mp(this, &TexturePreview::_update_metadata_label_text));
// It's okay that these colors are static since the grid color is static too.
- metadata_label->add_theme_color_override(SNAME("font_color"), Color::named("white"));
- metadata_label->add_theme_color_override(SNAME("font_color_shadow"), Color::named("black"));
+ metadata_label->add_theme_color_override("font_color", Color::named("white"));
+ metadata_label->add_theme_color_override("font_color_shadow", Color::named("black"));
- metadata_label->add_theme_font_size_override(SNAME("font_size"), 16 * EDSCALE);
- metadata_label->add_theme_color_override(SNAME("font_outline_color"), Color::named("black"));
- metadata_label->add_theme_constant_override(SNAME("outline_size"), 2 * EDSCALE);
+ 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);
- metadata_label->add_theme_constant_override(SNAME("shadow_outline_size"), 1);
+ metadata_label->add_theme_constant_override("shadow_outline_size", 1);
metadata_label->set_h_size_flags(Control::SIZE_SHRINK_END);
metadata_label->set_v_size_flags(Control::SIZE_SHRINK_END);
diff --git a/editor/plugins/texture_layered_editor_plugin.cpp b/editor/plugins/texture_layered_editor_plugin.cpp
index 83bc51b8d1..a8c37d37fe 100644
--- a/editor/plugins/texture_layered_editor_plugin.cpp
+++ b/editor/plugins/texture_layered_editor_plugin.cpp
@@ -247,11 +247,11 @@ TextureLayeredEditor::TextureLayeredEditor() {
info->set_anchor(SIDE_TOP, 1);
info->set_h_grow_direction(GROW_DIRECTION_BEGIN);
info->set_v_grow_direction(GROW_DIRECTION_BEGIN);
- info->add_theme_color_override(SNAME("font_color"), Color(1, 1, 1, 1));
- info->add_theme_color_override(SNAME("font_shadow_color"), Color(0, 0, 0, 0.5));
- info->add_theme_constant_override(SNAME("shadow_outline_size"), 1);
- info->add_theme_constant_override(SNAME("shadow_offset_x"), 2);
- info->add_theme_constant_override(SNAME("shadow_offset_y"), 2);
+ info->add_theme_color_override("font_color", Color(1, 1, 1, 1));
+ info->add_theme_color_override("font_shadow_color", Color(0, 0, 0, 0.5));
+ info->add_theme_constant_override("shadow_outline_size", 1);
+ info->add_theme_constant_override("shadow_offset_x", 2);
+ info->add_theme_constant_override("shadow_offset_y", 2);
setting = false;
layer->connect("value_changed", Callable(this, "_layer_changed"));
diff --git a/editor/plugins/texture_region_editor_plugin.cpp b/editor/plugins/texture_region_editor_plugin.cpp
index dc567586d6..662c0126ec 100644
--- a/editor/plugins/texture_region_editor_plugin.cpp
+++ b/editor/plugins/texture_region_editor_plugin.cpp
@@ -808,7 +808,7 @@ void TextureRegionEditor::_notification(int p_what) {
switch (p_what) {
case NOTIFICATION_ENTER_TREE:
case NOTIFICATION_THEME_CHANGED: {
- edit_draw->add_theme_style_override(SNAME("panel"), get_theme_stylebox(SNAME("bg"), SNAME("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(SNAME("ZoomLess"), SNAME("EditorIcons")));
diff --git a/editor/plugins/theme_editor_plugin.cpp b/editor/plugins/theme_editor_plugin.cpp
index bfe605ea2d..aaa09237cf 100644
--- a/editor/plugins/theme_editor_plugin.cpp
+++ b/editor/plugins/theme_editor_plugin.cpp
@@ -830,7 +830,7 @@ void ThemeItemImportTree::_notification(int p_what) {
case NOTIFICATION_ENTER_TREE:
case NOTIFICATION_THEME_CHANGED: {
select_icons_warning_icon->set_texture(get_theme_icon(SNAME("StatusWarning"), SNAME("EditorIcons")));
- select_icons_warning->add_theme_color_override(SNAME("font_color"), get_theme_color(SNAME("disabled_font_color"), SNAME("Editor")));
+ 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(SNAME("CollapseTree"), SNAME("EditorIcons")));
@@ -1824,8 +1824,8 @@ void ThemeItemEditorDialog::_notification(int p_what) {
import_another_theme_button->set_icon(get_theme_icon(SNAME("Folder"), SNAME("EditorIcons")));
- tc->add_theme_style_override(SNAME("tab_selected"), get_theme_stylebox(SNAME("tab_selected_odd"), SNAME("TabContainer")));
- tc->add_theme_style_override(SNAME("panel"), get_theme_stylebox(SNAME("panel_odd"), SNAME("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;
}
}
@@ -2389,7 +2389,7 @@ HBoxContainer *ThemeTypeEditor::_create_property_control(Theme::DataType p_data_
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(SNAME("font_color"), get_theme_color(SNAME("disabled_font_color"), SNAME("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(SNAME("Add"), SNAME("EditorIcons")));
@@ -3251,8 +3251,8 @@ void ThemeTypeEditor::_notification(int p_what) {
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(SNAME("tab_selected"), get_theme_stylebox(SNAME("tab_selected_odd"), SNAME("TabContainer")));
- data_type_tabs->add_theme_style_override(SNAME("panel"), get_theme_stylebox(SNAME("panel_odd"), SNAME("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(SNAME("Add"), SNAME("EditorIcons")));
} break;
@@ -3532,9 +3532,9 @@ void ThemeEditor::_notification(int p_what) {
switch (p_what) {
case NOTIFICATION_ENTER_TREE:
case NOTIFICATION_THEME_CHANGED: {
- preview_tabs->add_theme_style_override(SNAME("tab_selected"), get_theme_stylebox(SNAME("ThemeEditorPreviewFG"), SNAME("EditorStyles")));
- preview_tabs->add_theme_style_override(SNAME("tab_unselected"), get_theme_stylebox(SNAME("ThemeEditorPreviewBG"), SNAME("EditorStyles")));
- preview_tabs_content->add_theme_style_override(SNAME("panel"), get_theme_stylebox(SNAME("panel_odd"), SNAME("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(SNAME("Add"), SNAME("EditorIcons")));
} break;
@@ -3586,7 +3586,7 @@ ThemeEditor::ThemeEditor() {
VBoxContainer *preview_tabs_vb = memnew(VBoxContainer);
preview_tabs_vb->set_h_size_flags(SIZE_EXPAND_FILL);
preview_tabs_vb->set_custom_minimum_size(Size2(520, 0) * EDSCALE);
- preview_tabs_vb->add_theme_constant_override(SNAME("separation"), 2 * EDSCALE);
+ preview_tabs_vb->add_theme_constant_override("separation", 2 * EDSCALE);
main_hs->add_child(preview_tabs_vb);
HBoxContainer *preview_tabbar_hb = memnew(HBoxContainer);
preview_tabs_vb->add_child(preview_tabbar_hb);
diff --git a/editor/plugins/theme_editor_preview.cpp b/editor/plugins/theme_editor_preview.cpp
index a1f98df2aa..c4ef6e086d 100644
--- a/editor/plugins/theme_editor_preview.cpp
+++ b/editor/plugins/theme_editor_preview.cpp
@@ -247,10 +247,10 @@ ThemeEditorPreview::ThemeEditorPreview() {
preview_content = memnew(MarginContainer);
preview_root->add_child(preview_content);
- preview_content->add_theme_constant_override(SNAME("margin_right"), 4 * EDSCALE);
- preview_content->add_theme_constant_override(SNAME("margin_top"), 4 * EDSCALE);
- preview_content->add_theme_constant_override(SNAME("margin_left"), 4 * EDSCALE);
- preview_content->add_theme_constant_override(SNAME("margin_bottom"), 4 * EDSCALE);
+ preview_content->add_theme_constant_override("margin_right", 4 * EDSCALE);
+ preview_content->add_theme_constant_override("margin_top", 4 * EDSCALE);
+ preview_content->add_theme_constant_override("margin_left", 4 * EDSCALE);
+ preview_content->add_theme_constant_override("margin_bottom", 4 * EDSCALE);
preview_overlay = memnew(MarginContainer);
preview_overlay->set_mouse_filter(MOUSE_FILTER_IGNORE);
@@ -269,20 +269,20 @@ DefaultThemeEditorPreview::DefaultThemeEditorPreview() {
preview_content->add_child(main_panel);
MarginContainer *main_mc = memnew(MarginContainer);
- main_mc->add_theme_constant_override(SNAME("margin_right"), 4 * EDSCALE);
- main_mc->add_theme_constant_override(SNAME("margin_top"), 4 * EDSCALE);
- main_mc->add_theme_constant_override(SNAME("margin_left"), 4 * EDSCALE);
- main_mc->add_theme_constant_override(SNAME("margin_bottom"), 4 * EDSCALE);
+ main_mc->add_theme_constant_override("margin_right", 4 * EDSCALE);
+ main_mc->add_theme_constant_override("margin_top", 4 * EDSCALE);
+ main_mc->add_theme_constant_override("margin_left", 4 * EDSCALE);
+ main_mc->add_theme_constant_override("margin_bottom", 4 * EDSCALE);
preview_content->add_child(main_mc);
HBoxContainer *main_hb = memnew(HBoxContainer);
main_mc->add_child(main_hb);
- main_hb->add_theme_constant_override(SNAME("separation"), 20 * EDSCALE);
+ main_hb->add_theme_constant_override("separation", 20 * EDSCALE);
VBoxContainer *first_vb = memnew(VBoxContainer);
main_hb->add_child(first_vb);
first_vb->set_h_size_flags(SIZE_EXPAND_FILL);
- first_vb->add_theme_constant_override(SNAME("separation"), 10 * EDSCALE);
+ first_vb->add_theme_constant_override("separation", 10 * EDSCALE);
first_vb->add_child(memnew(Label("Label")));
@@ -343,7 +343,7 @@ DefaultThemeEditorPreview::DefaultThemeEditorPreview() {
VBoxContainer *second_vb = memnew(VBoxContainer);
second_vb->set_h_size_flags(SIZE_EXPAND_FILL);
main_hb->add_child(second_vb);
- second_vb->add_theme_constant_override(SNAME("separation"), 10 * EDSCALE);
+ second_vb->add_theme_constant_override("separation", 10 * EDSCALE);
LineEdit *le = memnew(LineEdit);
le->set_text("LineEdit");
second_vb->add_child(le);
@@ -383,7 +383,7 @@ DefaultThemeEditorPreview::DefaultThemeEditorPreview() {
VBoxContainer *third_vb = memnew(VBoxContainer);
third_vb->set_h_size_flags(SIZE_EXPAND_FILL);
- third_vb->add_theme_constant_override(SNAME("separation"), 10 * EDSCALE);
+ third_vb->add_theme_constant_override("separation", 10 * EDSCALE);
main_hb->add_child(third_vb);
TabContainer *tc = memnew(TabContainer);
diff --git a/editor/plugins/tiles/tile_atlas_view.cpp b/editor/plugins/tiles/tile_atlas_view.cpp
index ebece8ef40..35496795e0 100644
--- a/editor/plugins/tiles/tile_atlas_view.cpp
+++ b/editor/plugins/tiles/tile_atlas_view.cpp
@@ -585,7 +585,7 @@ TileAtlasView::TileAtlasView() {
hbox = memnew(HBoxContainer);
hbox->set_mouse_filter(Control::MOUSE_FILTER_IGNORE);
- hbox->add_theme_constant_override(SNAME("separation"), 10);
+ hbox->add_theme_constant_override("separation", 10);
hbox->hide();
margin_container->add_child(hbox);
diff --git a/editor/plugins/tiles/tile_map_editor.cpp b/editor/plugins/tiles/tile_map_editor.cpp
index 621cdae927..6e3724ead9 100644
--- a/editor/plugins/tiles/tile_map_editor.cpp
+++ b/editor/plugins/tiles/tile_map_editor.cpp
@@ -2095,7 +2095,7 @@ TileMapEditorTilesPlugin::TileMapEditorTilesPlugin() {
scatter_spinbox->set_max(1000);
scatter_spinbox->set_step(0.001);
scatter_spinbox->set_tooltip(TTR("Defines the probability of painting nothing instead of a randomly selected tile."));
- scatter_spinbox->get_line_edit()->add_theme_constant_override(SNAME("minimum_character_width"), 4);
+ scatter_spinbox->get_line_edit()->add_theme_constant_override("minimum_character_width", 4);
scatter_spinbox->connect("value_changed", callable_mp(this, &TileMapEditorTilesPlugin::_on_scattering_spinbox_changed));
tools_settings->add_child(scatter_spinbox);
diff --git a/editor/plugins/tiles/tile_set_atlas_source_editor.cpp b/editor/plugins/tiles/tile_set_atlas_source_editor.cpp
index 7e05001b57..1bd1cd0219 100644
--- a/editor/plugins/tiles/tile_set_atlas_source_editor.cpp
+++ b/editor/plugins/tiles/tile_set_atlas_source_editor.cpp
@@ -609,8 +609,8 @@ void TileSetAtlasSourceEditor::_update_tile_data_editors() {
}
// Theming.
- tile_data_editors_tree->add_theme_constant_override(SNAME("vseparation"), 1);
- tile_data_editors_tree->add_theme_constant_override(SNAME("hseparation"), 3);
+ 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(SNAME("prop_category"), SNAME("Editor"));
@@ -908,10 +908,10 @@ void TileSetAtlasSourceEditor::_update_atlas_view() {
alternative_tiles_control->add_child(button);
button->set_flat(true);
button->set_icon(get_theme_icon(SNAME("Add"), SNAME("EditorIcons")));
- button->add_theme_style_override(SNAME("normal"), memnew(StyleBoxEmpty));
- button->add_theme_style_override(SNAME("hover"), memnew(StyleBoxEmpty));
- button->add_theme_style_override(SNAME("focus"), memnew(StyleBoxEmpty));
- button->add_theme_style_override(SNAME("pressed"), memnew(StyleBoxEmpty));
+ 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, 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);
diff --git a/editor/plugins/visual_shader_editor_plugin.cpp b/editor/plugins/visual_shader_editor_plugin.cpp
index ac316427da..dd19f3d781 100644
--- a/editor/plugins/visual_shader_editor_plugin.cpp
+++ b/editor/plugins/visual_shader_editor_plugin.cpp
@@ -679,7 +679,7 @@ void VisualShaderGraphPlugin::add_node(VisualShader::Type p_type, int p_id) {
} else {
hb = memnew(HBoxContainer);
}
- hb->add_theme_constant_override(SNAME("separation"), 7 * EDSCALE);
+ hb->add_theme_constant_override("separation", 7 * EDSCALE);
Variant default_value;
@@ -732,14 +732,14 @@ void VisualShaderGraphPlugin::add_node(VisualShader::Type p_type, int p_id) {
} else {
Label *label = memnew(Label);
label->set_text(name_left);
- label->add_theme_style_override(SNAME("normal"), label_style); //more compact
+ label->add_theme_style_override("normal", label_style); //more compact
hb->add_child(label);
if (vsnode->is_input_port_default(i, mode) && !port_left_used) {
Label *hint_label = memnew(Label);
hint_label->set_text(TTR("[default]"));
- hint_label->add_theme_color_override(SNAME("font_color"), editor->get_theme_color(SNAME("font_readonly_color"), SNAME("TextEdit")));
- hint_label->add_theme_style_override(SNAME("normal"), label_style);
+ hint_label->add_theme_color_override("font_color", editor->get_theme_color(SNAME("font_readonly_color"), SNAME("TextEdit")));
+ hint_label->add_theme_style_override("normal", label_style);
hb->add_child(hint_label);
}
}
@@ -779,7 +779,7 @@ void VisualShaderGraphPlugin::add_node(VisualShader::Type p_type, int p_id) {
} else {
Label *label = memnew(Label);
label->set_text(name_right);
- label->add_theme_style_override(SNAME("normal"), label_style); //more compact
+ label->add_theme_style_override("normal", label_style); //more compact
hb->add_child(label);
}
}
@@ -896,7 +896,7 @@ void VisualShaderGraphPlugin::add_node(VisualShader::Type p_type, int p_id) {
String error = vsnode->get_warning(mode, p_type);
if (!error.is_empty()) {
Label *error_label = memnew(Label);
- error_label->add_theme_color_override(SNAME("font_color"), editor->get_theme_color(SNAME("error_color"), SNAME("Editor")));
+ error_label->add_theme_color_override("font_color", editor->get_theme_color(SNAME("error_color"), SNAME("Editor")));
error_label->set_text(error);
node->add_child(error_label);
}
@@ -920,7 +920,7 @@ void VisualShaderGraphPlugin::add_node(VisualShader::Type p_type, int p_id) {
Color members_color = EDITOR_GET("text_editor/theme/highlighting/member_variable_color");
expression_box->set_syntax_highlighter(expression_syntax_highlighter);
- expression_box->add_theme_color_override(SNAME("background_color"), background_color);
+ expression_box->add_theme_color_override("background_color", background_color);
for (const String &E : editor->keyword_list) {
if (ShaderLanguage::is_control_flow_keyword(E)) {
@@ -930,9 +930,9 @@ void VisualShaderGraphPlugin::add_node(VisualShader::Type p_type, int p_id) {
}
}
- expression_box->add_theme_font_override(SNAME("font"), editor->get_theme_font(SNAME("expression"), SNAME("EditorFonts")));
- expression_box->add_theme_font_size_override(SNAME("font_size"), editor->get_theme_font_size(SNAME("expression_size"), SNAME("EditorFonts")));
- expression_box->add_theme_color_override(SNAME("font_color"), text_color);
+ expression_box->add_theme_font_override("font", editor->get_theme_font(SNAME("expression"), SNAME("EditorFonts")));
+ expression_box->add_theme_font_size_override("font_size", editor->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);
expression_syntax_highlighter->set_function_color(function_color);
@@ -1512,10 +1512,10 @@ void VisualShaderEditor::_update_created_node(GraphNode *node) {
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;
- node->add_theme_color_override(SNAME("title_color"), c);
+ node->add_theme_color_override("title_color", c);
c.a = 0.7;
- node->add_theme_color_override(SNAME("close_color"), c);
- node->add_theme_color_override(SNAME("resizer_color"), c);
+ node->add_theme_color_override("close_color", c);
+ node->add_theme_color_override("resizer_color", c);
}
void VisualShaderEditor::_update_uniforms(bool p_update_refs) {
@@ -2584,7 +2584,7 @@ void VisualShaderEditor::_add_node(int p_idx, const Vector<Variant> &p_ops, Stri
vsnode = Ref<VisualShaderNode>(vsn);
} else {
ERR_FAIL_COND(add_options[p_idx].script.is_null());
- String base_type = add_options[p_idx].script->get_instance_base_type();
+ StringName base_type = add_options[p_idx].script->get_instance_base_type();
VisualShaderNode *vsn = Object::cast_to<VisualShaderNode>(ClassDB::instantiate(base_type));
ERR_FAIL_COND(!vsn);
vsnode = Ref<VisualShaderNode>(vsn);
@@ -3421,7 +3421,7 @@ void VisualShaderEditor::_notification(int p_what) {
Color number_color = EDITOR_GET("text_editor/theme/highlighting/number_color");
Color members_color = EDITOR_GET("text_editor/theme/highlighting/member_variable_color");
- preview_text->add_theme_color_override(SNAME("background_color"), background_color);
+ preview_text->add_theme_color_override("background_color", background_color);
for (const String &E : keyword_list) {
if (ShaderLanguage::is_control_flow_keyword(E)) {
@@ -3431,9 +3431,9 @@ void VisualShaderEditor::_notification(int p_what) {
}
}
- preview_text->add_theme_font_override(SNAME("font"), get_theme_font(SNAME("expression"), SNAME("EditorFonts")));
- preview_text->add_theme_font_size_override(SNAME("font_size"), get_theme_font_size(SNAME("expression_size"), SNAME("EditorFonts")));
- preview_text->add_theme_color_override(SNAME("font_color"), text_color);
+ 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);
syntax_highlighter->set_function_color(function_color);
@@ -3446,10 +3446,10 @@ void VisualShaderEditor::_notification(int p_what) {
preview_text->add_comment_delimiter("/*", "*/", false);
preview_text->add_comment_delimiter("//", "", true);
- error_panel->add_theme_style_override(SNAME("panel"), get_theme_stylebox(SNAME("panel"), SNAME("Panel")));
- error_label->add_theme_font_override(SNAME("font"), get_theme_font(SNAME("status_source"), SNAME("EditorFonts")));
- error_label->add_theme_font_size_override(SNAME("font_size"), get_theme_font_size(SNAME("status_source_size"), SNAME("EditorFonts")));
- error_label->add_theme_color_override(SNAME("font_color"), get_theme_color(SNAME("error_color"), SNAME("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(SNAME("Tools"), SNAME("EditorIcons")));
@@ -4301,7 +4301,7 @@ VisualShaderEditor::VisualShaderEditor() {
preview_vbox = memnew(VBoxContainer);
preview_window->add_child(preview_vbox);
- preview_vbox->add_theme_constant_override(SNAME("separation"), 0);
+ preview_vbox->add_theme_constant_override("separation", 0);
preview_text = memnew(CodeEdit);
syntax_highlighter.instantiate();
diff --git a/editor/project_export.cpp b/editor/project_export.cpp
index 5e2334f5e3..b8775cd3ed 100644
--- a/editor/project_export.cpp
+++ b/editor/project_export.cpp
@@ -1158,7 +1158,7 @@ ProjectExportDialog::ProjectExportDialog() {
script_key->connect("text_changed", callable_mp(this, &ProjectExportDialog::_script_encryption_key_changed));
script_key_error = memnew(Label);
script_key_error->set_text(String::utf8("• ") + TTR("Invalid Encryption Key (must be 64 hexadecimal characters long)"));
- script_key_error->add_theme_color_override(SNAME("font_color"), EditorNode::get_singleton()->get_gui_base()->get_theme_color(SNAME("error_color"), SNAME("Editor")));
+ 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);
@@ -1227,12 +1227,12 @@ ProjectExportDialog::ProjectExportDialog() {
export_error = memnew(Label);
main_vb->add_child(export_error);
export_error->hide();
- export_error->add_theme_color_override(SNAME("font_color"), EditorNode::get_singleton()->get_gui_base()->get_theme_color(SNAME("error_color"), SNAME("Editor")));
+ export_error->add_theme_color_override("font_color", EditorNode::get_singleton()->get_gui_base()->get_theme_color(SNAME("error_color"), SNAME("Editor")));
export_warning = memnew(Label);
main_vb->add_child(export_warning);
export_warning->hide();
- export_warning->add_theme_color_override(SNAME("font_color"), EditorNode::get_singleton()->get_gui_base()->get_theme_color(SNAME("warning_color"), SNAME("Editor")));
+ export_warning->add_theme_color_override("font_color", EditorNode::get_singleton()->get_gui_base()->get_theme_color(SNAME("warning_color"), SNAME("Editor")));
export_templates_error = memnew(HBoxContainer);
main_vb->add_child(export_templates_error);
@@ -1240,7 +1240,7 @@ ProjectExportDialog::ProjectExportDialog() {
Label *export_error2 = memnew(Label);
export_templates_error->add_child(export_error2);
- export_error2->add_theme_color_override(SNAME("font_color"), EditorNode::get_singleton()->get_gui_base()->get_theme_color(SNAME("error_color"), SNAME("Editor")));
+ 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);
@@ -1275,8 +1275,6 @@ ProjectExportDialog::ProjectExportDialog() {
set_hide_on_ok(false);
- editor_icons = "EditorIcons";
-
default_filename = EditorSettings::get_singleton()->get_project_metadata("export_options", "default_filename", "");
// If no default set, use project name
if (default_filename.is_empty()) {
diff --git a/editor/project_export.h b/editor/project_export.h
index 3d90a0d3ff..09e402c67f 100644
--- a/editor/project_export.h
+++ b/editor/project_export.h
@@ -85,8 +85,6 @@ private:
Label *include_label;
MarginContainer *include_margin;
- StringName editor_icons;
-
Button *export_button;
Button *export_all_button;
AcceptDialog *export_all_dialog;
diff --git a/editor/project_manager.cpp b/editor/project_manager.cpp
index 528347b779..57e47a15fd 100644
--- a/editor/project_manager.cpp
+++ b/editor/project_manager.cpp
@@ -40,7 +40,6 @@
#include "core/os/os.h"
#include "core/string/translation.h"
#include "core/version.h"
-#include "core/version_hash.gen.h"
#include "editor/editor_vcs_interface.h"
#include "editor_scale.h"
#include "editor_settings.h"
@@ -117,13 +116,13 @@ private:
switch (p_type) {
case MESSAGE_ERROR: {
- msg->add_theme_color_override(SNAME("font_color"), msg->get_theme_color(SNAME("error_color"), SNAME("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(SNAME("StatusError"), SNAME("EditorIcons"));
} break;
case MESSAGE_WARNING: {
- msg->add_theme_color_override(SNAME("font_color"), msg->get_theme_color(SNAME("warning_color"), SNAME("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(SNAME("StatusWarning"), SNAME("EditorIcons"));
@@ -1349,7 +1348,7 @@ void ProjectList::create_project_item_control(int p_index) {
ProjectListItemControl *hb = memnew(ProjectListItemControl);
hb->connect("draw", callable_mp(this, &ProjectList::_panel_draw), varray(hb));
hb->connect("gui_input", callable_mp(this, &ProjectList::_panel_input), varray(hb));
- hb->add_theme_constant_override(SNAME("separation"), 10 * EDSCALE);
+ hb->add_theme_constant_override("separation", 10 * EDSCALE);
hb->set_tooltip(item.description);
VBoxContainer *favorite_box = memnew(VBoxContainer);
@@ -1394,9 +1393,9 @@ void ProjectList::create_project_item_control(int p_index) {
Label *title = memnew(Label(!item.missing ? item.project_name : TTR("Missing Project")));
title->set_h_size_flags(Control::SIZE_EXPAND_FILL);
- title->add_theme_font_override(SNAME("font"), get_theme_font(SNAME("title"), SNAME("EditorFonts")));
- title->add_theme_font_size_override(SNAME("font_size"), get_theme_font_size(SNAME("title_size"), SNAME("EditorFonts")));
- title->add_theme_color_override(SNAME("font_color"), font_color);
+ 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);
title_hb->add_child(title);
@@ -1405,8 +1404,8 @@ void ProjectList::create_project_item_control(int p_index) {
if (length > 0) {
Label *unsupported_label = memnew(Label(unsupported_features_str));
unsupported_label->set_custom_minimum_size(Size2(length * 15, 10) * EDSCALE);
- unsupported_label->add_theme_font_override(SNAME("font"), get_theme_font(SNAME("title"), SNAME("EditorFonts")));
- unsupported_label->add_theme_color_override(SNAME("font_color"), get_theme_color(SNAME("warning_color"), SNAME("Editor")));
+ unsupported_label->add_theme_font_override("font", get_theme_font(SNAME("title"), SNAME("EditorFonts")));
+ unsupported_label->add_theme_color_override("font_color", get_theme_color(SNAME("warning_color"), SNAME("Editor")));
unsupported_label->set_clip_text(true);
unsupported_label->set_horizontal_alignment(HORIZONTAL_ALIGNMENT_RIGHT);
title_hb->add_child(unsupported_label);
@@ -1443,7 +1442,7 @@ void ProjectList::create_project_item_control(int p_index) {
path_hb->add_child(fpath);
fpath->set_h_size_flags(Control::SIZE_EXPAND_FILL);
fpath->set_modulate(Color(1, 1, 1, 0.5));
- fpath->add_theme_color_override(SNAME("font_color"), font_color);
+ fpath->add_theme_color_override("font_color", font_color);
fpath->set_clip_text(true);
}
@@ -2524,7 +2523,7 @@ ProjectManager::ProjectManager() {
Panel *panel = memnew(Panel);
add_child(panel);
panel->set_anchors_and_offsets_preset(Control::PRESET_WIDE);
- panel->add_theme_style_override(SNAME("panel"), get_theme_stylebox(SNAME("Background"), SNAME("EditorStyles")));
+ panel->add_theme_style_override("panel", get_theme_stylebox(SNAME("Background"), SNAME("EditorStyles")));
VBoxContainer *vb = memnew(VBoxContainer);
panel->add_child(vb);
@@ -2562,7 +2561,7 @@ ProjectManager::ProjectManager() {
hb->add_child(search_box);
loading_label = memnew(Label(TTR("Loading, please wait...")));
- loading_label->add_theme_font_override(SNAME("font"), get_theme_font(SNAME("bold"), SNAME("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.
@@ -2588,7 +2587,7 @@ ProjectManager::ProjectManager() {
}
PanelContainer *pc = memnew(PanelContainer);
- pc->add_theme_style_override(SNAME("panel"), get_theme_stylebox(SNAME("bg"), SNAME("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);
diff --git a/editor/project_settings_editor.cpp b/editor/project_settings_editor.cpp
index 2a72764469..c0ff1d72ee 100644
--- a/editor/project_settings_editor.cpp
+++ b/editor/project_settings_editor.cpp
@@ -509,9 +509,9 @@ void ProjectSettingsEditor::_update_action_map_editor() {
void ProjectSettingsEditor::_update_theme() {
search_box->set_right_icon(get_theme_icon(SNAME("Search"), SNAME("EditorIcons")));
restart_close_button->set_icon(get_theme_icon(SNAME("Close"), SNAME("EditorIcons")));
- restart_container->add_theme_style_override(SNAME("panel"), get_theme_stylebox(SNAME("bg"), SNAME("Tree")));
+ 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(SNAME("font_color"), get_theme_color(SNAME("warning_color"), SNAME("Editor")));
+ restart_label->add_theme_color_override("font_color", get_theme_color(SNAME("warning_color"), SNAME("Editor")));
type_box->clear();
for (int i = 0; i < Variant::VARIANT_MAX; i++) {
diff --git a/editor/property_editor.cpp b/editor/property_editor.cpp
index 27fe696cc3..405e263a62 100644
--- a/editor/property_editor.cpp
+++ b/editor/property_editor.cpp
@@ -269,7 +269,9 @@ void CustomPropertyEditor::_menu_option(int p_which) {
res->call("set_instance_base_type", owner->get_class());
}
+ EditorNode::get_editor_data().instantiate_object_properties(obj);
v = obj;
+
emit_signal(SNAME("variant_changed"));
} break;
@@ -1092,7 +1094,9 @@ void CustomPropertyEditor::_type_create_selected(int p_idx) {
ERR_FAIL_COND(!obj);
ERR_FAIL_COND(!Object::cast_to<Resource>(obj));
+ EditorNode::get_editor_data().instantiate_object_properties(obj);
v = obj;
+
emit_signal(SNAME("variant_changed"));
hide();
}
@@ -1283,7 +1287,9 @@ void CustomPropertyEditor::_action_pressed(int p_which) {
ERR_BREAK(!obj);
ERR_BREAK(!Object::cast_to<Resource>(obj));
+ EditorNode::get_editor_data().instantiate_object_properties(obj);
v = obj;
+
emit_signal(SNAME("variant_changed"));
hide();
}
diff --git a/editor/property_selector.cpp b/editor/property_selector.cpp
index 406bcbe342..0862efb4ee 100644
--- a/editor/property_selector.cpp
+++ b/editor/property_selector.cpp
@@ -214,10 +214,13 @@ void PropertySelector::_update_search() {
Variant::construct(type, v, nullptr, 0, ce);
v.get_method_list(&methods);
} else {
- Object *obj = ObjectDB::get_instance(script);
- if (Object::cast_to<Script>(obj)) {
+ Ref<Script> script_ref = Object::cast_to<Script>(ObjectDB::get_instance(script));
+ if (script_ref.is_valid()) {
methods.push_back(MethodInfo("*Script Methods"));
- Object::cast_to<Script>(obj)->get_script_method_list(&methods);
+ if (script_ref->is_built_in()) {
+ script_ref->reload(true);
+ }
+ script_ref->get_script_method_list(&methods);
}
StringName base = base_type;
diff --git a/editor/quick_open.cpp b/editor/quick_open.cpp
index c3fb61da86..2a8ca67fe6 100644
--- a/editor/quick_open.cpp
+++ b/editor/quick_open.cpp
@@ -261,7 +261,7 @@ EditorQuickOpen::EditorQuickOpen() {
search_options->create_item();
search_options->set_hide_root(true);
search_options->set_hide_folding(true);
- search_options->add_theme_constant_override(SNAME("draw_guides"), 1);
+ search_options->add_theme_constant_override("draw_guides", 1);
vbc->add_margin_child(TTR("Matches:"), search_options, true);
get_ok_button()->set_text(TTR("Open"));
diff --git a/editor/rename_dialog.cpp b/editor/rename_dialog.cpp
index 835551c4af..c6a4c0d86a 100644
--- a/editor/rename_dialog.cpp
+++ b/editor/rename_dialog.cpp
@@ -391,9 +391,9 @@ void RenameDialog::_update_preview(String new_text) {
// 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(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(SNAME("font_color"), accent_color.lerp(text_color, 0.5));
+ lbl_preview->add_theme_color_override("font_color", accent_color.lerp(text_color, 0.5));
} else {
- lbl_preview->add_theme_color_override(SNAME("font_color"), EditorNode::get_singleton()->get_gui_base()->get_theme_color(SNAME("success_color"), SNAME("Editor")));
+ lbl_preview->add_theme_color_override("font_color", EditorNode::get_singleton()->get_gui_base()->get_theme_color(SNAME("success_color"), SNAME("Editor")));
}
}
@@ -479,7 +479,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(SNAME("font_color"), EditorNode::get_singleton()->get_gui_base()->get_theme_color(SNAME("error_color"), SNAME("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));
}
diff --git a/editor/scene_tree_dock.cpp b/editor/scene_tree_dock.cpp
index 3c2194ccb3..0e362b13c6 100644
--- a/editor/scene_tree_dock.cpp
+++ b/editor/scene_tree_dock.cpp
@@ -1206,8 +1206,16 @@ void SceneTreeDock::_notification(int p_what) {
create_root_dialog->add_child(top_row);
+ ScrollContainer *scroll_container = memnew(ScrollContainer);
+ scroll_container->set_name("NodeShortcutsScrollContainer");
+ create_root_dialog->add_child(scroll_container);
+ scroll_container->set_v_size_flags(SIZE_EXPAND_FILL);
+ scroll_container->set_horizontal_scroll_mode(ScrollContainer::SCROLL_MODE_DISABLED);
+
VBoxContainer *node_shortcuts = memnew(VBoxContainer);
node_shortcuts->set_name("NodeShortcuts");
+ scroll_container->add_child(node_shortcuts);
+ node_shortcuts->set_h_size_flags(SIZE_EXPAND_FILL);
VBoxContainer *beginner_node_shortcuts = memnew(VBoxContainer);
beginner_node_shortcuts->set_name("BeginnerNodeShortcuts");
@@ -1247,8 +1255,6 @@ void SceneTreeDock::_notification(int p_what) {
button_clipboard->set_icon(get_theme_icon(SNAME("ActionPaste"), SNAME("EditorIcons")));
button_clipboard->connect("pressed", callable_bind(callable_mp(this, &SceneTreeDock::_tool_selected), TOOL_PASTE, false));
- node_shortcuts->add_spacer();
- create_root_dialog->add_child(node_shortcuts);
_update_create_root_dialog();
} break;
@@ -3112,7 +3118,7 @@ void SceneTreeDock::_local_tree_selected() {
void SceneTreeDock::_update_create_root_dialog() {
BaseButton *toggle = Object::cast_to<BaseButton>(create_root_dialog->get_node(String("NodeShortcutsTopRow/NodeShortcutsToggle")));
- Node *node_shortcuts = create_root_dialog->get_node(String("NodeShortcuts"));
+ Node *node_shortcuts = create_root_dialog->get_node(String("NodeShortcutsScrollContainer/NodeShortcuts"));
if (!toggle || !node_shortcuts) {
return;
@@ -3142,6 +3148,7 @@ void SceneTreeDock::_update_create_root_dialog() {
Button *button = memnew(Button);
favorite_nodes->add_child(button);
button->set_text(l);
+ button->set_clip_text(true);
String name = l.get_slicec(' ', 0);
if (ScriptServer::is_global_class(name)) {
name = ScriptServer::get_global_class_native_base(name);
@@ -3301,7 +3308,7 @@ SceneTreeDock::SceneTreeDock(EditorNode *p_editor, Node *p_scene_root, EditorSel
VBoxContainer *vbc = this;
HBoxContainer *filter_hbc = memnew(HBoxContainer);
- filter_hbc->add_theme_constant_override(SNAME("separate"), 0);
+ filter_hbc->add_theme_constant_override("separate", 0);
ED_SHORTCUT("scene_tree/rename", TTR("Rename"), Key::F2);
ED_SHORTCUT_OVERRIDE("scene_tree/rename", "macos", Key::ENTER);
@@ -3349,7 +3356,7 @@ SceneTreeDock::SceneTreeDock(EditorNode *p_editor, Node *p_scene_root, EditorSel
filter->set_h_size_flags(SIZE_EXPAND_FILL);
filter->set_placeholder(TTR("Filter nodes"));
filter_hbc->add_child(filter);
- filter->add_theme_constant_override(SNAME("minimum_character_width"), 0);
+ filter->add_theme_constant_override("minimum_character_width", 0);
filter->connect("text_changed", callable_mp(this, &SceneTreeDock::_filter_changed));
button_create_script = memnew(Button);
@@ -3403,6 +3410,7 @@ SceneTreeDock::SceneTreeDock(EditorNode *p_editor, Node *p_scene_root, EditorSel
create_root_dialog = memnew(VBoxContainer);
vbc->add_child(create_root_dialog);
+ create_root_dialog->set_v_size_flags(SIZE_EXPAND_FILL);
create_root_dialog->hide();
scene_tree = memnew(SceneTreeEditor(false, true, true));
diff --git a/editor/scene_tree_editor.cpp b/editor/scene_tree_editor.cpp
index ddf7d8c465..e9aed53b4e 100644
--- a/editor/scene_tree_editor.cpp
+++ b/editor/scene_tree_editor.cpp
@@ -1219,7 +1219,7 @@ SceneTreeEditor::SceneTreeEditor(bool p_label, bool p_can_rename, bool p_can_ope
tree->set_begin(Point2(0, p_label ? 18 : 0));
tree->set_end(Point2(0, 0));
tree->set_allow_reselect(true);
- tree->add_theme_constant_override(SNAME("button_margin"), 0);
+ tree->add_theme_constant_override("button_margin", 0);
add_child(tree);
@@ -1324,7 +1324,7 @@ SceneTreeDialog::SceneTreeDialog() {
filter->set_h_size_flags(Control::SIZE_EXPAND_FILL);
filter->set_placeholder(TTR("Filter nodes"));
filter->set_clear_button_enabled(true);
- filter->add_theme_constant_override(SNAME("minimum_character_width"), 0);
+ filter->add_theme_constant_override("minimum_character_width", 0);
filter->connect("text_changed", callable_mp(this, &SceneTreeDialog::_filter_changed));
vbc->add_child(filter);
diff --git a/editor/script_create_dialog.cpp b/editor/script_create_dialog.cpp
index 1fa85f8df6..b42d4a1d6d 100644
--- a/editor/script_create_dialog.cpp
+++ b/editor/script_create_dialog.cpp
@@ -70,7 +70,7 @@ void ScriptCreateDialog::_notification(int p_what) {
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(SNAME("panel"), get_theme_stylebox(SNAME("bg"), SNAME("Tree")));
+ status_panel->add_theme_style_override("panel", get_theme_stylebox(SNAME("bg"), SNAME("Tree")));
} break;
}
}
@@ -291,7 +291,7 @@ void ScriptCreateDialog::_template_changed(int p_template) {
template_info += " - " + sinfo.description;
}
template_info_label->set_text(template_info);
- template_info_label->add_theme_color_override(SNAME("font_color"), get_theme_color(SNAME("success_color"), SNAME("Editor")));
+ template_info_label->add_theme_color_override("font_color", get_theme_color(SNAME("success_color"), SNAME("Editor")));
}
void ScriptCreateDialog::ok_pressed() {
@@ -522,18 +522,18 @@ void ScriptCreateDialog::_path_submitted(const String &p_path) {
void ScriptCreateDialog::_msg_script_valid(bool valid, const String &p_msg) {
error_label->set_text(String::utf8("• ") + p_msg);
if (valid) {
- error_label->add_theme_color_override(SNAME("font_color"), get_theme_color(SNAME("success_color"), SNAME("Editor")));
+ error_label->add_theme_color_override("font_color", get_theme_color(SNAME("success_color"), SNAME("Editor")));
} else {
- error_label->add_theme_color_override(SNAME("font_color"), get_theme_color(SNAME("error_color"), SNAME("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(String::utf8("• ") + p_msg);
if (valid) {
- path_error_label->add_theme_color_override(SNAME("font_color"), get_theme_color(SNAME("success_color"), SNAME("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(SNAME("font_color"), get_theme_color(SNAME("error_color"), SNAME("Editor")));
+ path_error_label->add_theme_color_override("font_color", get_theme_color(SNAME("error_color"), SNAME("Editor")));
}
}
@@ -658,7 +658,7 @@ void ScriptCreateDialog::_update_dialog() {
class_name->set_placeholder(TTR("Allowed: a-z, A-Z, 0-9, _ and ."));
Color placeholder_color = class_name->get_theme_color(SNAME("font_placeholder_color"));
placeholder_color.a = 0.3;
- class_name->add_theme_color_override(SNAME("font_placeholder_color"), placeholder_color);
+ class_name->add_theme_color_override("font_placeholder_color", placeholder_color);
} else {
class_name->set_editable(false);
}
@@ -667,7 +667,7 @@ void ScriptCreateDialog::_update_dialog() {
class_name->set_placeholder(TTR("N/A"));
Color placeholder_color = class_name->get_theme_color(SNAME("font_placeholder_color"));
placeholder_color.a = 1;
- class_name->add_theme_color_override(SNAME("font_placeholder_color"), placeholder_color);
+ class_name->add_theme_color_override("font_placeholder_color", placeholder_color);
class_name->set_text("");
}
@@ -911,7 +911,7 @@ ScriptCreateDialog::ScriptCreateDialog() {
script_name_warning_label->set_text(
TTR("Warning: Having the script name be the same as a built-in type is usually not desired."));
vb->add_child(script_name_warning_label);
- script_name_warning_label->add_theme_color_override(SNAME("font_color"), Color(1, 0.85, 0.4));
+ script_name_warning_label->add_theme_color_override("font_color", Color(1, 0.85, 0.4));
script_name_warning_label->set_autowrap_mode(Label::AUTOWRAP_WORD_SMART);
script_name_warning_label->hide();
diff --git a/editor/shader_create_dialog.cpp b/editor/shader_create_dialog.cpp
index a34cbed2dc..95c4c5ff0d 100644
--- a/editor/shader_create_dialog.cpp
+++ b/editor/shader_create_dialog.cpp
@@ -72,7 +72,7 @@ void ShaderCreateDialog::_update_theme() {
}
path_button->set_icon(get_theme_icon(SNAME("Folder"), SNAME("EditorIcons")));
- status_panel->add_theme_style_override(SNAME("panel"), get_theme_stylebox(SNAME("bg"), SNAME("Tree")));
+ status_panel->add_theme_style_override("panel", get_theme_stylebox(SNAME("bg"), SNAME("Tree")));
}
void ShaderCreateDialog::_update_language_info() {
@@ -419,18 +419,18 @@ String ShaderCreateDialog::_validate_path(const String &p_path) {
void ShaderCreateDialog::_msg_script_valid(bool valid, const String &p_msg) {
error_label->set_text("- " + p_msg);
if (valid) {
- error_label->add_theme_color_override(SNAME("font_color"), gc->get_theme_color(SNAME("success_color"), SNAME("Editor")));
+ error_label->add_theme_color_override("font_color", gc->get_theme_color(SNAME("success_color"), SNAME("Editor")));
} else {
- error_label->add_theme_color_override(SNAME("font_color"), gc->get_theme_color(SNAME("error_color"), SNAME("Editor")));
+ error_label->add_theme_color_override("font_color", gc->get_theme_color(SNAME("error_color"), SNAME("Editor")));
}
}
void ShaderCreateDialog::_msg_path_valid(bool valid, const String &p_msg) {
path_error_label->set_text("- " + p_msg);
if (valid) {
- path_error_label->add_theme_color_override(SNAME("font_color"), gc->get_theme_color(SNAME("success_color"), SNAME("Editor")));
+ path_error_label->add_theme_color_override("font_color", gc->get_theme_color(SNAME("success_color"), SNAME("Editor")));
} else {
- path_error_label->add_theme_color_override(SNAME("font_color"), gc->get_theme_color(SNAME("error_color"), SNAME("Editor")));
+ path_error_label->add_theme_color_override("font_color", gc->get_theme_color(SNAME("error_color"), SNAME("Editor")));
}
}
diff --git a/main/main.cpp b/main/main.cpp
index f8088cba1c..0bca5bef0c 100644
--- a/main/main.cpp
+++ b/main/main.cpp
@@ -50,7 +50,6 @@
#include "core/register_core_types.h"
#include "core/string/translation.h"
#include "core/version.h"
-#include "core/version_hash.gen.h"
#include "drivers/register_driver_types.h"
#include "main/app_icon.gen.h"
#include "main/main_timer_sync.h"
@@ -200,7 +199,7 @@ static String unescape_cmdline(const String &p_str) {
static String get_full_version_string() {
String hash = String(VERSION_HASH);
- if (hash.length() != 0) {
+ if (!hash.is_empty()) {
hash = "." + hash.left(9);
}
return String(VERSION_FULL_BUILD) + hash;
@@ -2250,9 +2249,8 @@ bool Main::start() {
}
}
- if (main_loop->is_class("SceneTree")) {
- SceneTree *sml = Object::cast_to<SceneTree>(main_loop);
-
+ SceneTree *sml = Object::cast_to<SceneTree>(main_loop);
+ if (sml) {
#ifdef DEBUG_ENABLED
if (debug_collisions) {
sml->set_debug_collisions_hint(true);
@@ -2294,20 +2292,18 @@ bool Main::start() {
RES res = ResourceLoader::load(info.path);
ERR_CONTINUE_MSG(res.is_null(), "Can't autoload: " + info.path);
Node *n = nullptr;
- if (res->is_class("PackedScene")) {
- Ref<PackedScene> ps = res;
- n = ps->instantiate();
- } else if (res->is_class("Script")) {
- Ref<Script> script_res = res;
+ Ref<PackedScene> scn = res;
+ Ref<Script> script_res = res;
+ if (scn.is_valid()) {
+ n = scn->instantiate();
+ } else if (script_res.is_valid()) {
StringName ibt = script_res->get_instance_base_type();
bool valid_type = ClassDB::is_parent_class(ibt, "Node");
ERR_CONTINUE_MSG(!valid_type, "Script does not inherit a Node: " + info.path);
Object *obj = ClassDB::instantiate(ibt);
- ERR_CONTINUE_MSG(obj == nullptr,
- "Cannot instance script for autoload, expected 'Node' inheritance, got: " +
- String(ibt));
+ ERR_CONTINUE_MSG(!obj, "Cannot instance script for autoload, expected 'Node' inheritance, got: " + String(ibt) + ".");
n = Object::cast_to<Node>(obj);
n->set_script(script_res);
diff --git a/methods.py b/methods.py
index fbd304ddde..fe84641e9d 100644
--- a/methods.py
+++ b/methods.py
@@ -111,10 +111,9 @@ def update_version(module_version_string=""):
f.close()
# NOTE: It is safe to generate this file here, since this is still executed serially
- fhash = open("core/version_hash.gen.h", "w")
+ fhash = open("core/version_hash.gen.cpp", "w")
fhash.write("/* THIS FILE IS GENERATED DO NOT EDIT */\n")
- fhash.write("#ifndef VERSION_HASH_GEN_H\n")
- fhash.write("#define VERSION_HASH_GEN_H\n")
+ fhash.write('#include "core/version.h"\n')
githash = ""
gitfolder = ".git"
@@ -132,8 +131,7 @@ def update_version(module_version_string=""):
else:
githash = head
- fhash.write('#define VERSION_HASH "' + githash + '"\n')
- fhash.write("#endif // VERSION_HASH_GEN_H\n")
+ fhash.write('const char *const VERSION_HASH = "' + githash + '";\n')
fhash.close()
diff --git a/misc/dist/ios_xcode/godot_ios.xcodeproj/project.pbxproj b/misc/dist/ios_xcode/godot_ios.xcodeproj/project.pbxproj
index 5ba45c0c13..e2505de3bf 100644
--- a/misc/dist/ios_xcode/godot_ios.xcodeproj/project.pbxproj
+++ b/misc/dist/ios_xcode/godot_ios.xcodeproj/project.pbxproj
@@ -325,7 +325,7 @@
PRODUCT_NAME = "$(TARGET_NAME)";
PROVISIONING_PROFILE = "$provisioning_profile_uuid_debug";
TARGETED_DEVICE_FAMILY = "$targeted_device_family";
- VALID_ARCHS = "armv7 armv7s arm64 i386 x86_64";
+ VALID_ARCHS = "arm64 x86_64";
WRAPPER_EXTENSION = app;
};
name = Debug;
@@ -356,7 +356,7 @@
PRODUCT_NAME = "$(TARGET_NAME)";
PROVISIONING_PROFILE = "$provisioning_profile_uuid_release";
TARGETED_DEVICE_FAMILY = "$targeted_device_family";
- VALID_ARCHS = "armv7 armv7s arm64 i386 x86_64";
+ VALID_ARCHS = "arm64 x86_64";
WRAPPER_EXTENSION = app;
};
name = Release;
diff --git a/modules/SCsub b/modules/SCsub
index 5ff4623743..fcc01e2c1b 100644
--- a/modules/SCsub
+++ b/modules/SCsub
@@ -22,36 +22,45 @@ env.CommandNoCache(
),
)
-# Header to be included in `tests/test_main.cpp` to run module-specific tests.
-if env["tests"]:
- env.Depends("modules_tests.gen.h", Value(env.module_list))
- env.CommandNoCache(
- "modules_tests.gen.h",
- Value(env.module_list),
- env.Run(
- modules_builders.generate_modules_tests,
- "Generating modules tests header.",
- # NOTE: No need to run in subprocess since this is still executed serially.
- subprocess=False,
- ),
- )
- env.AlwaysBuild("modules_tests.gen.h")
vs_sources = []
+test_headers = []
# libmodule_<name>.a for each active module.
for name, path in env.module_list.items():
env.modules_sources = []
- if not os.path.isabs(path):
- SConscript(name + "/SCsub") # Built-in.
- else:
- SConscript(path + "/SCsub") # Custom.
+ # Name for built-in modules, (absolute) path for custom ones.
+ base_path = path if os.path.isabs(path) else name
+ SConscript(base_path + "/SCsub")
lib = env_modules.add_library("module_%s" % name, env.modules_sources)
env.Prepend(LIBS=[lib])
if env["vsproj"]:
vs_sources += env.modules_sources
+ if env["tests"]:
+ # Lookup potential headers in `tests` subfolder.
+ import glob
+
+ module_tests = sorted(glob.glob(os.path.join(base_path, "tests", "*.h")))
+ if module_tests != []:
+ test_headers += module_tests
+
+
+# Generate header to be included in `tests/test_main.cpp` to run module-specific tests.
+if env["tests"]:
+ env.Depends("modules_tests.gen.h", test_headers)
+ env.CommandNoCache(
+ "modules_tests.gen.h",
+ test_headers,
+ env.Run(
+ modules_builders.generate_modules_tests,
+ "Generating modules tests header.",
+ # NOTE: No need to run in subprocess since this is still executed serially.
+ subprocess=False,
+ ),
+ )
+
# libmodules.a with only register_module_types.
# Must be last so that all libmodule_<name>.a libraries are on the right side
# in the linker command.
diff --git a/modules/gdnative/gdnative_library_editor_plugin.cpp b/modules/gdnative/gdnative_library_editor_plugin.cpp
index f94464826e..33ea078696 100644
--- a/modules/gdnative/gdnative_library_editor_plugin.cpp
+++ b/modules/gdnative/gdnative_library_editor_plugin.cpp
@@ -315,7 +315,6 @@ GDNativeLibraryEditor::GDNativeLibraryEditor() {
NativePlatformConfig platform_ios;
platform_ios.name = "iOS";
- platform_ios.entries.push_back("armv7");
platform_ios.entries.push_back("arm64");
platform_ios.entries.push_back("x86_64");
// iOS can use both Static and Dynamic libraries.
diff --git a/modules/gdnative/nativescript/nativescript.cpp b/modules/gdnative/nativescript/nativescript.cpp
index be304a43f0..5d5414c694 100644
--- a/modules/gdnative/nativescript/nativescript.cpp
+++ b/modules/gdnative/nativescript/nativescript.cpp
@@ -766,7 +766,7 @@ Variant NativeScriptInstance::call(const StringName &p_method, const Variant **p
void NativeScriptInstance::notification(int p_notification) {
#ifdef DEBUG_ENABLED
if (p_notification == MainLoop::NOTIFICATION_CRASH) {
- if (current_method_call != StringName("")) {
+ if (current_method_call != StringName()) {
ERR_PRINT("NativeScriptInstance detected crash on method: " + current_method_call);
current_method_call = "";
}
diff --git a/modules/gdnative/pluginscript/pluginscript_script.cpp b/modules/gdnative/pluginscript/pluginscript_script.cpp
index 71ab8ef0a2..ec3c9eb4ff 100644
--- a/modules/gdnative/pluginscript/pluginscript_script.cpp
+++ b/modules/gdnative/pluginscript/pluginscript_script.cpp
@@ -93,7 +93,7 @@ Variant PluginScript::_new(const Variant **p_args, int p_argcount, Callable::Cal
REF ref;
Object *owner = nullptr;
- if (get_instance_base_type() == "") {
+ if (get_instance_base_type() == StringName()) {
owner = memnew(RefCounted);
} else {
owner = ClassDB::instantiate(get_instance_base_type());
diff --git a/modules/gdscript/gdscript_analyzer.cpp b/modules/gdscript/gdscript_analyzer.cpp
index 9ff52347e9..94daba4bf6 100644
--- a/modules/gdscript/gdscript_analyzer.cpp
+++ b/modules/gdscript/gdscript_analyzer.cpp
@@ -196,7 +196,7 @@ Error GDScriptAnalyzer::check_class_member_name_conflict(const GDScriptParser::C
}
if (current_data_type && current_data_type->kind == GDScriptParser::DataType::Kind::NATIVE) {
- if (current_data_type->native_type != StringName("")) {
+ if (current_data_type->native_type != StringName()) {
return check_native_member_name_conflict(
p_member_name,
p_member_node,
@@ -250,7 +250,7 @@ Error GDScriptAnalyzer::resolve_inheritance(GDScriptParser::ClassNode *p_class,
if (!p_class->extends_used) {
result.type_source = GDScriptParser::DataType::ANNOTATED_INFERRED;
result.kind = GDScriptParser::DataType::NATIVE;
- result.native_type = "RefCounted";
+ result.native_type = SNAME("RefCounted");
} else {
result.type_source = GDScriptParser::DataType::ANNOTATED_EXPLICIT;
@@ -438,7 +438,7 @@ GDScriptParser::DataType GDScriptAnalyzer::resolve_datatype(GDScriptParser::Type
StringName first = p_type->type_chain[0]->name;
- if (first == "Variant") {
+ if (first == SNAME("Variant")) {
result.kind = GDScriptParser::DataType::VARIANT;
if (p_type->type_chain.size() > 1) {
push_error(R"("Variant" type don't contain nested types.)", p_type->type_chain[1]);
@@ -447,9 +447,9 @@ GDScriptParser::DataType GDScriptAnalyzer::resolve_datatype(GDScriptParser::Type
return result;
}
- if (first == "Object") {
+ if (first == SNAME("Object")) {
result.kind = GDScriptParser::DataType::NATIVE;
- result.native_type = "Object";
+ result.native_type = SNAME("Object");
if (p_type->type_chain.size() > 1) {
push_error(R"("Object" type don't contain nested types.)", p_type->type_chain[1]);
return GDScriptParser::DataType();
@@ -2552,7 +2552,7 @@ void GDScriptAnalyzer::reduce_get_node(GDScriptParser::GetNodeNode *p_get_node)
GDScriptParser::DataType result;
result.type_source = GDScriptParser::DataType::ANNOTATED_EXPLICIT;
result.kind = GDScriptParser::DataType::NATIVE;
- result.native_type = "Node";
+ result.native_type = SNAME("Node");
result.builtin_type = Variant::OBJECT;
if (!ClassDB::is_parent_class(parser->current_class->base_type.native_type, result.native_type)) {
@@ -3524,7 +3524,7 @@ GDScriptParser::DataType GDScriptAnalyzer::type_from_property(const PropertyInfo
result.builtin_type = p_property.type;
if (p_property.type == Variant::OBJECT) {
result.kind = GDScriptParser::DataType::NATIVE;
- result.native_type = p_property.class_name == StringName() ? "Object" : p_property.class_name;
+ result.native_type = p_property.class_name == StringName() ? SNAME("Object") : p_property.class_name;
} else {
result.kind = GDScriptParser::DataType::BUILTIN;
result.builtin_type = p_property.type;
diff --git a/modules/gdscript/gdscript_editor.cpp b/modules/gdscript/gdscript_editor.cpp
index 33a88dd2dd..f0dc830ed8 100644
--- a/modules/gdscript/gdscript_editor.cpp
+++ b/modules/gdscript/gdscript_editor.cpp
@@ -652,7 +652,7 @@ static void _get_directory_contents(EditorFileSystemDirectory *p_dir, Map<String
}
static void _find_annotation_arguments(const GDScriptParser::AnnotationNode *p_annotation, int p_argument, const String p_quote_style, Map<String, ScriptCodeCompletionOption> &r_result) {
- if (p_annotation->name == "@export_range") {
+ if (p_annotation->name == SNAME("@export_range")) {
if (p_argument == 3 || p_argument == 4) {
// Slider hint.
ScriptCodeCompletionOption slider1("or_greater", ScriptCodeCompletionOption::KIND_PLAIN_TEXT);
@@ -662,7 +662,7 @@ static void _find_annotation_arguments(const GDScriptParser::AnnotationNode *p_a
slider2.insert_text = slider2.display.quote(p_quote_style);
r_result.insert(slider2.display, slider2);
}
- } else if (p_annotation->name == "@export_exp_easing") {
+ } else if (p_annotation->name == SNAME("@export_exp_easing")) {
if (p_argument == 0 || p_argument == 1) {
// Easing hint.
ScriptCodeCompletionOption hint1("attenuation", ScriptCodeCompletionOption::KIND_PLAIN_TEXT);
@@ -672,7 +672,7 @@ static void _find_annotation_arguments(const GDScriptParser::AnnotationNode *p_a
hint2.insert_text = hint2.display.quote(p_quote_style);
r_result.insert(hint2.display, hint2);
}
- } else if (p_annotation->name == "@export_node_path") {
+ } else if (p_annotation->name == SNAME("@export_node_path")) {
ScriptCodeCompletionOption node("Node", ScriptCodeCompletionOption::KIND_CLASS);
r_result.insert(node.display, node);
List<StringName> node_types;
@@ -684,7 +684,7 @@ static void _find_annotation_arguments(const GDScriptParser::AnnotationNode *p_a
ScriptCodeCompletionOption option(E, ScriptCodeCompletionOption::KIND_CLASS);
r_result.insert(option.display, option);
}
- } else if (p_annotation->name == "@warning_ignore") {
+ } else if (p_annotation->name == SNAME("@warning_ignore")) {
for (int warning_code = 0; warning_code < GDScriptWarning::WARNING_MAX; warning_code++) {
ScriptCodeCompletionOption warning(GDScriptWarning::get_name_from_code((GDScriptWarning::Code)warning_code).to_lower(), ScriptCodeCompletionOption::KIND_PLAIN_TEXT);
r_result.insert(warning.display, warning);
@@ -1384,7 +1384,7 @@ static bool _guess_expression_type(GDScriptParser::CompletionContext &p_context,
Object *baseptr = base.value;
- if (all_is_const && String(call->function_name) == "get_node" && ClassDB::is_parent_class(native_type.native_type, "Node") && args.size()) {
+ if (all_is_const && call->function_name == SNAME("get_node") && ClassDB::is_parent_class(native_type.native_type, SNAME("Node")) && args.size()) {
String arg1 = args[0];
if (arg1.begins_with("/root/")) {
String which = arg1.get_slice("/", 2);
@@ -2085,7 +2085,7 @@ static bool _guess_method_return_type_from_base(GDScriptParser::CompletionContex
GDScriptParser::DataType base_type = p_base.type;
bool is_static = base_type.is_meta_type;
- if (is_static && p_method == "new") {
+ if (is_static && p_method == SNAME("new")) {
r_type.type = base_type;
r_type.type.is_meta_type = false;
r_type.type.is_constant = false;
@@ -2274,7 +2274,7 @@ static void _find_call_arguments(GDScriptParser::CompletionContext &p_context, c
r_arghint = _make_arguments_hint(info, p_argidx);
}
- if (p_argidx == 0 && ClassDB::is_parent_class(class_name, "Node") && (p_method == "get_node" || p_method == "has_node")) {
+ if (p_argidx == 0 && ClassDB::is_parent_class(class_name, SNAME("Node")) && (p_method == SNAME("get_node") || p_method == SNAME("has_node"))) {
// Get autoloads
List<PropertyInfo> props;
ProjectSettings::get_singleton()->get_property_list(&props);
@@ -2291,7 +2291,7 @@ static void _find_call_arguments(GDScriptParser::CompletionContext &p_context, c
}
}
- if (p_argidx == 0 && method_args > 0 && ClassDB::is_parent_class(class_name, "InputEvent") && p_method.operator String().contains("action")) {
+ if (p_argidx == 0 && method_args > 0 && ClassDB::is_parent_class(class_name, SNAME("InputEvent")) && p_method.operator String().contains("action")) {
// Get input actions
List<PropertyInfo> props;
ProjectSettings::get_singleton()->get_property_list(&props);
diff --git a/modules/gdscript/gdscript_parser.cpp b/modules/gdscript/gdscript_parser.cpp
index cfad832a6c..8e4e457ec1 100644
--- a/modules/gdscript/gdscript_parser.cpp
+++ b/modules/gdscript/gdscript_parser.cpp
@@ -519,7 +519,7 @@ void GDScriptParser::parse_program() {
// Check for @tool annotation.
AnnotationNode *annotation = parse_annotation(AnnotationInfo::SCRIPT | AnnotationInfo::CLASS_LEVEL);
if (annotation != nullptr) {
- if (annotation->name == "@tool") {
+ if (annotation->name == SNAME("@tool")) {
// TODO: don't allow @tool anywhere else. (Should all script annotations be the first thing?).
_is_tool = true;
if (previous.type != GDScriptTokenizer::Token::NEWLINE) {
@@ -573,7 +573,7 @@ void GDScriptParser::parse_program() {
// Check for @icon annotation.
AnnotationNode *annotation = parse_annotation(AnnotationInfo::SCRIPT | AnnotationInfo::CLASS_LEVEL);
if (annotation != nullptr) {
- if (annotation->name == "@icon") {
+ if (annotation->name == SNAME("@icon")) {
if (previous.type != GDScriptTokenizer::Token::NEWLINE) {
push_error(R"(Expected newline after "@icon" annotation.)");
}
@@ -3503,7 +3503,7 @@ bool GDScriptParser::export_annotations(const AnnotationNode *p_annotation, Node
// This is called after the analyzer is done finding the type, so this should be set here.
DataType export_type = variable->get_datatype();
- if (p_annotation->name == "@export") {
+ if (p_annotation->name == SNAME("@export")) {
if (variable->datatype_specifier == nullptr && variable->initializer == nullptr) {
push_error(R"(Cannot use simple "@export" annotation with variable without type or initializer, since type can't be inferred.)", p_annotation);
return false;
@@ -3528,7 +3528,7 @@ bool GDScriptParser::export_annotations(const AnnotationNode *p_annotation, Node
variable->export_info.hint_string = Variant::get_type_name(export_type.builtin_type);
break;
case GDScriptParser::DataType::NATIVE:
- if (ClassDB::is_parent_class(export_type.native_type, "Resource")) {
+ if (ClassDB::is_parent_class(export_type.native_type, SNAME("Resource"))) {
variable->export_info.type = Variant::OBJECT;
variable->export_info.hint = PROPERTY_HINT_RESOURCE_TYPE;
variable->export_info.hint_string = export_type.native_type;
diff --git a/modules/gdscript/tests/gdscript_test_runner.cpp b/modules/gdscript/tests/gdscript_test_runner.cpp
index 73a424dae4..c2bb2caa29 100644
--- a/modules/gdscript/tests/gdscript_test_runner.cpp
+++ b/modules/gdscript/tests/gdscript_test_runner.cpp
@@ -73,23 +73,21 @@ void init_autoloads() {
RES res = ResourceLoader::load(info.path);
ERR_CONTINUE_MSG(res.is_null(), "Can't autoload: " + info.path);
Node *n = nullptr;
- if (res->is_class("PackedScene")) {
- Ref<PackedScene> ps = res;
- n = ps->instantiate();
- } else if (res->is_class("Script")) {
- Ref<Script> script_res = res;
- StringName ibt = script_res->get_instance_base_type();
+ Ref<PackedScene> scn = res;
+ Ref<Script> script = res;
+ if (scn.is_valid()) {
+ n = scn->instantiate();
+ } else if (script.is_valid()) {
+ StringName ibt = script->get_instance_base_type();
bool valid_type = ClassDB::is_parent_class(ibt, "Node");
ERR_CONTINUE_MSG(!valid_type, "Script does not inherit a Node: " + info.path);
Object *obj = ClassDB::instantiate(ibt);
- ERR_CONTINUE_MSG(obj == nullptr,
- "Cannot instance script for autoload, expected 'Node' inheritance, got: " +
- String(ibt));
+ ERR_CONTINUE_MSG(!obj, "Cannot instance script for autoload, expected 'Node' inheritance, got: " + String(ibt) + ".");
n = Object::cast_to<Node>(obj);
- n->set_script(script_res);
+ n->set_script(script);
}
ERR_CONTINUE_MSG(!n, "Path in autoload not a node or script: " + info.path);
diff --git a/modules/gltf/gltf_document.cpp b/modules/gltf/gltf_document.cpp
index baa39a3b80..0056fee7a4 100644
--- a/modules/gltf/gltf_document.cpp
+++ b/modules/gltf/gltf_document.cpp
@@ -57,7 +57,6 @@
#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"
@@ -6655,8 +6654,8 @@ Error GLTFDocument::_serialize_version(Ref<GLTFState> state) {
Dictionary asset;
asset["version"] = version;
- String hash = VERSION_HASH;
- asset["generator"] = String(VERSION_FULL_NAME) + String("@") + (hash.length() == 0 ? String("unknown") : hash);
+ String hash = String(VERSION_HASH);
+ asset["generator"] = String(VERSION_FULL_NAME) + String("@") + (hash.is_empty() ? String("unknown") : hash);
state->json["asset"] = asset;
ERR_FAIL_COND_V(!asset.has("version"), Error::FAILED);
ERR_FAIL_COND_V(!state->json.has("asset"), Error::FAILED);
diff --git a/modules/gridmap/grid_map_editor_plugin.cpp b/modules/gridmap/grid_map_editor_plugin.cpp
index 3275851b20..84510fc71e 100644
--- a/modules/gridmap/grid_map_editor_plugin.cpp
+++ b/modules/gridmap/grid_map_editor_plugin.cpp
@@ -1181,7 +1181,7 @@ GridMapEditor::GridMapEditor(EditorNode *p_editor) {
floor->set_min(-32767);
floor->set_max(32767);
floor->set_step(1);
- floor->get_line_edit()->add_theme_constant_override(SNAME("minimum_character_width"), 16);
+ floor->get_line_edit()->add_theme_constant_override("minimum_character_width", 16);
spatial_editor_hb->add_child(floor);
floor->connect("value_changed", callable_mp(this, &GridMapEditor::_floor_changed));
diff --git a/modules/meshoptimizer/register_types.cpp b/modules/meshoptimizer/register_types.cpp
index 57a1b697be..597c12ed23 100644
--- a/modules/meshoptimizer/register_types.cpp
+++ b/modules/meshoptimizer/register_types.cpp
@@ -38,6 +38,9 @@ void register_meshoptimizer_types() {
SurfaceTool::simplify_with_attrib_func = meshopt_simplifyWithAttributes;
SurfaceTool::simplify_scale_func = meshopt_simplifyScale;
SurfaceTool::simplify_sloppy_func = meshopt_simplifySloppy;
+ SurfaceTool::generate_remap_func = meshopt_generateVertexRemap;
+ SurfaceTool::remap_vertex_func = meshopt_remapVertexBuffer;
+ SurfaceTool::remap_index_func = meshopt_remapIndexBuffer;
}
void unregister_meshoptimizer_types() {
@@ -45,4 +48,7 @@ void unregister_meshoptimizer_types() {
SurfaceTool::simplify_func = nullptr;
SurfaceTool::simplify_scale_func = nullptr;
SurfaceTool::simplify_sloppy_func = nullptr;
+ SurfaceTool::generate_remap_func = nullptr;
+ SurfaceTool::remap_vertex_func = nullptr;
+ SurfaceTool::remap_index_func = nullptr;
}
diff --git a/modules/modules_builders.py b/modules/modules_builders.py
index 2243162555..13d5a2075a 100644
--- a/modules/modules_builders.py
+++ b/modules/modules_builders.py
@@ -14,13 +14,10 @@ def generate_modules_enabled(target, source, env):
def generate_modules_tests(target, source, env):
import os
- import glob
with open(target[0].path, "w") as f:
- for name, path in env.module_list.items():
- headers = glob.glob(os.path.join(path, "tests", "*.h"))
- for h in headers:
- f.write('#include "%s"\n' % (os.path.normpath(h)))
+ for header in source:
+ f.write('#include "%s"\n' % (os.path.normpath(header.path)))
if __name__ == "__main__":
diff --git a/modules/mono/editor/GodotTools/GodotTools/Export/AotBuilder.cs b/modules/mono/editor/GodotTools/GodotTools/Export/AotBuilder.cs
index 37e6a34977..ed758cc137 100644
--- a/modules/mono/editor/GodotTools/GodotTools/Export/AotBuilder.cs
+++ b/modules/mono/editor/GodotTools/GodotTools/Export/AotBuilder.cs
@@ -537,7 +537,6 @@ MONO_AOT_MODE_LAST = 1000,
{
var iosArchs = new[]
{
- "armv7",
"arm64"
};
diff --git a/modules/mono/glue/GodotSharp/GodotSharp/Core/StringExtensions.cs b/modules/mono/glue/GodotSharp/GodotSharp/Core/StringExtensions.cs
index eba0ea9a79..a1f058ffe5 100644
--- a/modules/mono/glue/GodotSharp/GodotSharp/Core/StringExtensions.cs
+++ b/modules/mono/glue/GodotSharp/GodotSharp/Core/StringExtensions.cs
@@ -266,7 +266,7 @@ namespace Godot
/// <returns>The capitalized string.</returns>
public static string Capitalize(this string instance)
{
- string aux = instance.Replace("_", " ").ToLower();
+ string aux = instance.CamelcaseToUnderscore(true).Replace("_", " ").Trim();
string cap = string.Empty;
for (int i = 0; i < aux.GetSliceCount(" "); i++)
@@ -284,6 +284,51 @@ namespace Godot
return cap;
}
+ private static string CamelcaseToUnderscore(this string instance, bool lowerCase)
+ {
+ string newString = string.Empty;
+ int startIndex = 0;
+
+ for (int i = 1; i < instance.Length; i++)
+ {
+ bool isUpper = char.IsUpper(instance[i]);
+ bool isNumber = char.IsDigit(instance[i]);
+
+ bool areNext2Lower = false;
+ bool isNextLower = false;
+ bool isNextNumber = false;
+ bool wasPrecedentUpper = char.IsUpper(instance[i - 1]);
+ bool wasPrecedentNumber = char.IsDigit(instance[i - 1]);
+
+ if (i + 2 < instance.Length)
+ {
+ areNext2Lower = char.IsLower(instance[i + 1]) && char.IsLower(instance[i + 2]);
+ }
+
+ if (i + 1 < instance.Length)
+ {
+ isNextLower = char.IsLower(instance[i + 1]);
+ isNextNumber = char.IsDigit(instance[i + 1]);
+ }
+
+ bool condA = isUpper && !wasPrecedentUpper && !wasPrecedentNumber;
+ bool condB = wasPrecedentUpper && isUpper && areNext2Lower;
+ bool condC = isNumber && !wasPrecedentNumber;
+ bool canBreakNumberLetter = isNumber && !wasPrecedentNumber && isNextLower;
+ bool canBreakLetterNumber = !isNumber && wasPrecedentNumber && (isNextLower || isNextNumber);
+
+ bool shouldSplit = condA || condB || condC || canBreakNumberLetter || canBreakLetterNumber;
+ if (shouldSplit)
+ {
+ newString += instance.Substring(startIndex, i - startIndex) + "_";
+ startIndex = i;
+ }
+ }
+
+ newString += instance.Substring(startIndex, instance.Length - startIndex);
+ return lowerCase ? newString.ToLower() : newString;
+ }
+
/// <summary>
/// Performs a case-sensitive comparison to another string, return -1 if less, 0 if equal and +1 if greater.
/// </summary>
diff --git a/modules/mono/glue/GodotSharp/GodotSharp/Core/Vector2.cs b/modules/mono/glue/GodotSharp/GodotSharp/Core/Vector2.cs
index 1f5282e88f..fa7838633c 100644
--- a/modules/mono/glue/GodotSharp/GodotSharp/Core/Vector2.cs
+++ b/modules/mono/glue/GodotSharp/GodotSharp/Core/Vector2.cs
@@ -512,24 +512,24 @@ namespace Godot
/// Returns the result of the spherical linear interpolation between
/// this vector and <paramref name="to"/> by amount <paramref name="weight"/>.
///
- /// Note: Both vectors must be normalized.
+ /// This method also handles interpolating the lengths if the input vectors have different lengths.
+ /// For the special case of one or both input vectors having zero length, this method behaves like [method lerp].
/// </summary>
- /// <param name="to">The destination vector for interpolation. Must be normalized.</param>
+ /// <param name="to">The destination vector for interpolation.</param>
/// <param name="weight">A value on the range of 0.0 to 1.0, representing the amount of interpolation.</param>
/// <returns>The resulting vector of the interpolation.</returns>
public Vector2 Slerp(Vector2 to, real_t weight)
{
-#if DEBUG
- if (!IsNormalized())
- {
- throw new InvalidOperationException("Vector2.Slerp: From vector is not normalized.");
+ real_t startLengthSquared = LengthSquared();
+ real_t endLengthSquared = to.LengthSquared();
+ if (startLengthSquared == 0.0 || endLengthSquared == 0.0) {
+ // Zero length vectors have no angle, so the best we can do is either lerp or throw an error.
+ return Lerp(to, weight);
}
- if (!to.IsNormalized())
- {
- throw new InvalidOperationException($"Vector2.Slerp: `{nameof(to)}` is not normalized.");
- }
-#endif
- return Rotated(AngleTo(to) * weight);
+ real_t startLength = Mathf.Sqrt(startLengthSquared);
+ real_t resultLength = Mathf.Lerp(startLength, Mathf.Sqrt(endLengthSquared), weight);
+ real_t angle = AngleTo(to);
+ return Rotated(angle * weight) * (resultLength / startLength);
}
/// <summary>
diff --git a/modules/mono/glue/GodotSharp/GodotSharp/Core/Vector3.cs b/modules/mono/glue/GodotSharp/GodotSharp/Core/Vector3.cs
index 433a5d9dc9..0faf13f8b7 100644
--- a/modules/mono/glue/GodotSharp/GodotSharp/Core/Vector3.cs
+++ b/modules/mono/glue/GodotSharp/GodotSharp/Core/Vector3.cs
@@ -549,25 +549,24 @@ namespace Godot
/// Returns the result of the spherical linear interpolation between
/// this vector and <paramref name="to"/> by amount <paramref name="weight"/>.
///
- /// Note: Both vectors must be normalized.
+ /// This method also handles interpolating the lengths if the input vectors have different lengths.
+ /// For the special case of one or both input vectors having zero length, this method behaves like [method lerp].
/// </summary>
- /// <param name="to">The destination vector for interpolation. Must be normalized.</param>
+ /// <param name="to">The destination vector for interpolation.</param>
/// <param name="weight">A value on the range of 0.0 to 1.0, representing the amount of interpolation.</param>
/// <returns>The resulting vector of the interpolation.</returns>
public Vector3 Slerp(Vector3 to, real_t weight)
{
-#if DEBUG
- if (!IsNormalized())
- {
- throw new InvalidOperationException("Vector3.Slerp: From vector is not normalized.");
+ real_t startLengthSquared = LengthSquared();
+ real_t endLengthSquared = to.LengthSquared();
+ if (startLengthSquared == 0.0 || endLengthSquared == 0.0) {
+ // Zero length vectors have no angle, so the best we can do is either lerp or throw an error.
+ return Lerp(to, weight);
}
- if (!to.IsNormalized())
- {
- throw new InvalidOperationException($"Vector3.Slerp: `{nameof(to)}` is not normalized.");
- }
-#endif
- real_t theta = AngleTo(to);
- return Rotated(Cross(to), theta * weight);
+ real_t startLength = Mathf.Sqrt(startLengthSquared);
+ real_t resultLength = Mathf.Lerp(startLength, Mathf.Sqrt(endLengthSquared), weight);
+ real_t angle = AngleTo(to);
+ return Rotated(Cross(to).Normalized(), angle * weight) * (resultLength / startLength);
}
/// <summary>
diff --git a/modules/raycast/raycast_occlusion_cull.cpp b/modules/raycast/raycast_occlusion_cull.cpp
index dd5eef8b2b..2e0d17fb28 100644
--- a/modules/raycast/raycast_occlusion_cull.cpp
+++ b/modules/raycast/raycast_occlusion_cull.cpp
@@ -270,13 +270,14 @@ void RaycastOcclusionCull::scenario_set_instance(RID p_scenario, RID p_instance,
OccluderInstance &instance = scenario.instances[p_instance];
+ bool changed = false;
+
if (instance.removed) {
instance.removed = false;
scenario.removed_instances.erase(p_instance);
+ changed = true; // It was removed and re-added, we might have missed some changes
}
- bool changed = false;
-
if (instance.occluder != p_occluder) {
Occluder *old_occluder = occluder_owner.get_or_null(instance.occluder);
if (old_occluder) {
diff --git a/modules/visual_script/editor/visual_script_editor.cpp b/modules/visual_script/editor/visual_script_editor.cpp
index 6e3b173fce..5ea8eaff00 100644
--- a/modules/visual_script/editor/visual_script_editor.cpp
+++ b/modules/visual_script/editor/visual_script_editor.cpp
@@ -653,7 +653,6 @@ void VisualScriptEditor::_update_graph(int p_only_id) {
List<int> ids;
script->get_node_list(&ids);
- StringName editor_icons = "EditorIcons";
for (int &E : ids) {
if (p_only_id >= 0 && p_only_id != E) {
@@ -713,7 +712,7 @@ 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(SNAME("font"), get_theme_font(SNAME("source"), SNAME("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));
} else {
@@ -743,11 +742,11 @@ void VisualScriptEditor::_update_graph(int p_only_id) {
Color c = sbf->get_border_color();
c = ((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);
Color ic = c;
- gnode->add_theme_color_override(SNAME("title_color"), c);
+ gnode->add_theme_color_override("title_color", c);
c.a = 1;
- gnode->add_theme_color_override(SNAME("close_color"), c);
- gnode->add_theme_color_override(SNAME("resizer_color"), ic);
- gnode->add_theme_style_override(SNAME("frame"), sbf);
+ gnode->add_theme_color_override("close_color", c);
+ gnode->add_theme_color_override("resizer_color", ic);
+ gnode->add_theme_style_override("frame", sbf);
}
const Color mono_color = get_theme_color(SNAME("mono_color"), SNAME("Editor"));
@@ -2661,7 +2660,7 @@ Ref<Texture2D> VisualScriptEditor::get_theme_icon() {
icon_name += "Internal";
}
- if (Control::has_theme_icon(icon_name, SNAME("EditorIcons"))) {
+ if (Control::has_theme_icon(icon_name, "EditorIcons")) {
return Control::get_theme_icon(icon_name, SNAME("EditorIcons"));
}
@@ -3931,13 +3930,13 @@ void VisualScriptEditor::_notification(int p_what) {
update_toggle_scripts_button();
- edit_variable_edit->add_theme_style_override(SNAME("bg"), get_theme_stylebox(SNAME("bg"), SNAME("Tree")));
- edit_signal_edit->add_theme_style_override(SNAME("bg"), get_theme_stylebox(SNAME("bg"), SNAME("Tree")));
- func_input_scroll->add_theme_style_override(SNAME("bg"), get_theme_stylebox(SNAME("bg"), SNAME("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();
- bool dark_theme = tm->get_constant(SNAME("dark_theme"), SNAME("Editor"));
+ bool dark_theme = tm->get_constant("dark_theme", "Editor");
if (dark_theme) {
node_colors["flow_control"] = Color(0.96, 0.96, 0.96);
diff --git a/modules/visual_script/editor/visual_script_property_selector.cpp b/modules/visual_script/editor/visual_script_property_selector.cpp
index 8913b88d1a..bba5410629 100644
--- a/modules/visual_script/editor/visual_script_property_selector.cpp
+++ b/modules/visual_script/editor/visual_script_property_selector.cpp
@@ -46,7 +46,7 @@
void VisualScriptPropertySelector::_update_icons() {
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(SNAME("right_icon"), results_tree->get_theme_icon(SNAME("Search"), SNAME("EditorIcons")));
+ search_box->add_theme_icon_override("right_icon", results_tree->get_theme_icon(SNAME("Search"), SNAME("EditorIcons")));
search_visual_script_nodes->set_icon(results_tree->get_theme_icon(SNAME("VisualScript"), SNAME("EditorIcons")));
search_classes->set_icon(results_tree->get_theme_icon(SNAME("Object"), SNAME("EditorIcons")));
@@ -1142,11 +1142,11 @@ TreeItem *VisualScriptPropertySelector::SearchRunner::_create_class_item(TreeIte
} else {
if (p_doc->name.is_quoted()) {
text_0 = p_doc->name.unquote().get_file();
- if (ui_service->has_theme_icon(p_doc->inherits, SNAME("EditorIcons"))) {
- icon = ui_service->get_theme_icon(p_doc->inherits, SNAME("EditorIcons"));
+ if (ui_service->has_theme_icon(p_doc->inherits, "EditorIcons")) {
+ icon = ui_service->get_theme_icon(p_doc->inherits, "EditorIcons");
}
- } else if (ui_service->has_theme_icon(p_doc->name, SNAME("EditorIcons"))) {
- icon = ui_service->get_theme_icon(p_doc->name, SNAME("EditorIcons"));
+ } else 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(SNAME("Object"), SNAME("EditorIcons"));
}
diff --git a/modules/visual_script/visual_script.cpp b/modules/visual_script/visual_script.cpp
index fbdf3a654b..88445f2f98 100644
--- a/modules/visual_script/visual_script.cpp
+++ b/modules/visual_script/visual_script.cpp
@@ -1164,9 +1164,6 @@ void VisualScript::_bind_methods() {
ClassDB::bind_method(D_METHOD("remove_custom_signal", "name"), &VisualScript::remove_custom_signal);
ClassDB::bind_method(D_METHOD("rename_custom_signal", "name", "new_name"), &VisualScript::rename_custom_signal);
- //ClassDB::bind_method(D_METHOD("set_variable_info","name","info"),&VScript::set_variable_info);
- //ClassDB::bind_method(D_METHOD("get_variable_info","name"),&VScript::set_variable_info);
-
ClassDB::bind_method(D_METHOD("set_instance_base_type", "type"), &VisualScript::set_instance_base_type);
ClassDB::bind_method(D_METHOD("_set_data", "data"), &VisualScript::_set_data);
diff --git a/modules/visual_script/visual_script_nodes.cpp b/modules/visual_script/visual_script_nodes.cpp
index f3594e5164..e7f4e542c1 100644
--- a/modules/visual_script/visual_script_nodes.cpp
+++ b/modules/visual_script/visual_script_nodes.cpp
@@ -2495,7 +2495,7 @@ static Node *_find_script_node(Node *p_edited_scene, Node *p_current_node, const
VisualScriptSceneNode::TypeGuess VisualScriptSceneNode::guess_output_type(TypeGuess *p_inputs, int p_output) const {
VisualScriptSceneNode::TypeGuess tg;
tg.type = Variant::OBJECT;
- tg.gdclass = "Node";
+ tg.gdclass = SNAME("Node");
#ifdef TOOLS_ENABLED
Ref<Script> script = get_visual_script();
@@ -2649,7 +2649,7 @@ VisualScriptNodeInstance *VisualScriptSceneTree::instantiate(VisualScriptInstanc
VisualScriptSceneTree::TypeGuess VisualScriptSceneTree::guess_output_type(TypeGuess *p_inputs, int p_output) const {
TypeGuess tg;
tg.type = Variant::OBJECT;
- tg.gdclass = "SceneTree";
+ tg.gdclass = SNAME("SceneTree");
return tg;
}
@@ -2766,11 +2766,11 @@ PropertyInfo VisualScriptSelf::get_input_value_port_info(int p_idx) const {
}
PropertyInfo VisualScriptSelf::get_output_value_port_info(int p_idx) const {
- String type_name;
+ StringName type_name;
if (get_visual_script().is_valid()) {
type_name = get_visual_script()->get_instance_base_type();
} else {
- type_name = "instance";
+ type_name = SNAME("instance");
}
return PropertyInfo(Variant::OBJECT, type_name);
@@ -2801,7 +2801,7 @@ VisualScriptNodeInstance *VisualScriptSelf::instantiate(VisualScriptInstance *p_
VisualScriptSelf::TypeGuess VisualScriptSelf::guess_output_type(TypeGuess *p_inputs, int p_output) const {
VisualScriptSceneNode::TypeGuess tg;
tg.type = Variant::OBJECT;
- tg.gdclass = "Object";
+ tg.gdclass = SNAME("Object");
Ref<Script> script = get_visual_script();
if (!script.is_valid()) {
diff --git a/platform/iphone/detect.py b/platform/iphone/detect.py
index 4e4b0d81c3..f442235e7c 100644
--- a/platform/iphone/detect.py
+++ b/platform/iphone/detect.py
@@ -120,7 +120,6 @@ def configure(env):
)
)
env.Append(CPPDEFINES=["NEED_LONG_INT"])
- env.Append(CPPDEFINES=["LIBYUV_DISABLE_NEON"])
# Disable exceptions on non-tools (template) builds
if not env["tools"]:
diff --git a/platform/iphone/export/export_plugin.cpp b/platform/iphone/export/export_plugin.cpp
index fe00b1a3cd..122e64d6a1 100644
--- a/platform/iphone/export/export_plugin.cpp
+++ b/platform/iphone/export/export_plugin.cpp
@@ -43,7 +43,6 @@ void EditorExportPlatformIOS::get_preset_features(const Ref<EditorExportPreset>
Vector<EditorExportPlatformIOS::ExportArchitecture> EditorExportPlatformIOS::_get_supported_architectures() {
Vector<ExportArchitecture> archs;
- archs.push_back(ExportArchitecture("armv7", false)); // Disabled by default, not included in official templates.
archs.push_back(ExportArchitecture("arm64", true));
return archs;
}
diff --git a/platform/iphone/godot_view.h b/platform/iphone/godot_view.h
index 1c72a26b4a..fcb97fa63a 100644
--- a/platform/iphone/godot_view.h
+++ b/platform/iphone/godot_view.h
@@ -59,4 +59,9 @@ class String;
- (void)stopRendering;
- (void)startRendering;
+- (void)godotTouchesBegan:(NSSet *)touches withEvent:(UIEvent *)event;
+- (void)godotTouchesMoved:(NSSet *)touches withEvent:(UIEvent *)event;
+- (void)godotTouchesEnded:(NSSet *)touches withEvent:(UIEvent *)event;
+- (void)godotTouchesCancelled:(NSSet *)touches withEvent:(UIEvent *)event;
+
@end
diff --git a/platform/iphone/godot_view.mm b/platform/iphone/godot_view.mm
index b90c10fa84..ae92f32851 100644
--- a/platform/iphone/godot_view.mm
+++ b/platform/iphone/godot_view.mm
@@ -336,7 +336,7 @@ static const float earth_gravity = 9.80665;
}
}
-- (void)touchesBegan:(NSSet *)touchesSet withEvent:(UIEvent *)event {
+- (void)godotTouchesBegan:(NSSet *)touchesSet withEvent:(UIEvent *)event {
NSArray *tlist = [event.allTouches allObjects];
for (unsigned int i = 0; i < [tlist count]; i++) {
if ([touchesSet containsObject:[tlist objectAtIndex:i]]) {
@@ -349,7 +349,7 @@ static const float earth_gravity = 9.80665;
}
}
-- (void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event {
+- (void)godotTouchesMoved:(NSSet *)touches withEvent:(UIEvent *)event {
NSArray *tlist = [event.allTouches allObjects];
for (unsigned int i = 0; i < [tlist count]; i++) {
if ([touches containsObject:[tlist objectAtIndex:i]]) {
@@ -363,7 +363,7 @@ static const float earth_gravity = 9.80665;
}
}
-- (void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event {
+- (void)godotTouchesEnded:(NSSet *)touches withEvent:(UIEvent *)event {
NSArray *tlist = [event.allTouches allObjects];
for (unsigned int i = 0; i < [tlist count]; i++) {
if ([touches containsObject:[tlist objectAtIndex:i]]) {
@@ -377,7 +377,7 @@ static const float earth_gravity = 9.80665;
}
}
-- (void)touchesCancelled:(NSSet *)touches withEvent:(UIEvent *)event {
+- (void)godotTouchesCancelled:(NSSet *)touches withEvent:(UIEvent *)event {
NSArray *tlist = [event.allTouches allObjects];
for (unsigned int i = 0; i < [tlist count]; i++) {
if ([touches containsObject:[tlist objectAtIndex:i]]) {
diff --git a/platform/iphone/godot_view_gesture_recognizer.mm b/platform/iphone/godot_view_gesture_recognizer.mm
index b50ba5f942..a46c42765a 100644
--- a/platform/iphone/godot_view_gesture_recognizer.mm
+++ b/platform/iphone/godot_view_gesture_recognizer.mm
@@ -29,6 +29,7 @@
/*************************************************************************/
#import "godot_view_gesture_recognizer.h"
+#import "godot_view.h"
#include "core/config/project_settings.h"
@@ -58,6 +59,10 @@ const CGFloat kGLGestureMovementDistance = 0.5;
@implementation GodotViewGestureRecognizer
+- (GodotView *)godotView {
+ return (GodotView *)self.view;
+}
+
- (instancetype)init {
self = [super init];
@@ -104,7 +109,7 @@ const CGFloat kGLGestureMovementDistance = 0.5;
self.delayTimer = nil;
if (self.delayedTouches) {
- [self.view touchesBegan:self.delayedTouches withEvent:self.delayedEvent];
+ [self.godotView godotTouchesBegan:self.delayedTouches withEvent:self.delayedEvent];
}
self.delayedTouches = nil;
@@ -114,6 +119,8 @@ const CGFloat kGLGestureMovementDistance = 0.5;
- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event {
NSSet *cleared = [self copyClearedTouches:touches phase:UITouchPhaseBegan];
[self delayTouches:cleared andEvent:event];
+
+ [super touchesBegan:touches withEvent:event];
}
- (void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event {
@@ -123,8 +130,8 @@ const CGFloat kGLGestureMovementDistance = 0.5;
// We should check if movement was significant enough to fire an event
// for dragging to work correctly.
for (UITouch *touch in cleared) {
- CGPoint from = [touch locationInView:self.view];
- CGPoint to = [touch previousLocationInView:self.view];
+ CGPoint from = [touch locationInView:self.godotView];
+ CGPoint to = [touch previousLocationInView:self.godotView];
CGFloat xDistance = from.x - to.x;
CGFloat yDistance = from.y - to.y;
@@ -133,7 +140,7 @@ const CGFloat kGLGestureMovementDistance = 0.5;
// Early exit, since one of touches has moved enough to fire a drag event.
if (distance > kGLGestureMovementDistance) {
[self.delayTimer fire];
- [self.view touchesMoved:cleared withEvent:event];
+ [self.godotView godotTouchesMoved:cleared withEvent:event];
return;
}
}
@@ -141,26 +148,32 @@ const CGFloat kGLGestureMovementDistance = 0.5;
return;
}
- [self.view touchesMoved:cleared withEvent:event];
+ [self.godotView touchesMoved:cleared withEvent:event];
+
+ [super touchesMoved:touches withEvent:event];
}
- (void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event {
[self.delayTimer fire];
NSSet *cleared = [self copyClearedTouches:touches phase:UITouchPhaseEnded];
- [self.view touchesEnded:cleared withEvent:event];
+ [self.godotView godotTouchesEnded:cleared withEvent:event];
+
+ [super touchesEnded:touches withEvent:event];
}
- (void)touchesCancelled:(NSSet *)touches withEvent:(UIEvent *)event {
[self.delayTimer fire];
- [self.view touchesCancelled:touches withEvent:event];
-};
+ [self.godotView godotTouchesCancelled:touches withEvent:event];
+
+ [super touchesCancelled:touches withEvent:event];
+}
- (NSSet *)copyClearedTouches:(NSSet *)touches phase:(UITouchPhase)phaseToSave {
NSMutableSet *cleared = [touches mutableCopy];
for (UITouch *touch in touches) {
- if (touch.phase != phaseToSave) {
+ if (touch.view != self.view || touch.phase != phaseToSave) {
[cleared removeObject:touch];
}
}
diff --git a/platform/linuxbsd/crash_handler_linuxbsd.cpp b/platform/linuxbsd/crash_handler_linuxbsd.cpp
index e9369fefdd..b4ec7924f6 100644
--- a/platform/linuxbsd/crash_handler_linuxbsd.cpp
+++ b/platform/linuxbsd/crash_handler_linuxbsd.cpp
@@ -33,7 +33,6 @@
#include "core/config/project_settings.h"
#include "core/os/os.h"
#include "core/version.h"
-#include "core/version_hash.gen.h"
#include "main/main.h"
#ifdef DEBUG_ENABLED
@@ -71,10 +70,10 @@ static void handle_crash(int sig) {
}
// Print the engine version just before, so that people are reminded to include the version in backtrace reports.
- if (String(VERSION_HASH).length() != 0) {
- fprintf(stderr, "Engine version: " VERSION_FULL_NAME " (" VERSION_HASH ")\n");
+ if (String(VERSION_HASH).is_empty()) {
+ fprintf(stderr, "Engine version: %s\n", VERSION_FULL_NAME);
} else {
- fprintf(stderr, "Engine version: " VERSION_FULL_NAME "\n");
+ fprintf(stderr, "Engine version: %s (%s)\n", VERSION_FULL_NAME, VERSION_HASH);
}
fprintf(stderr, "Dumping the backtrace. %s\n", msg.utf8().get_data());
char **strings = backtrace_symbols(bt_buffer, size);
diff --git a/platform/linuxbsd/display_server_x11.cpp b/platform/linuxbsd/display_server_x11.cpp
index c3b44f348c..bf9c9b1766 100644
--- a/platform/linuxbsd/display_server_x11.cpp
+++ b/platform/linuxbsd/display_server_x11.cpp
@@ -1835,7 +1835,7 @@ void DisplayServerX11::_set_wm_fullscreen(WindowID p_window, bool p_enabled) {
Hints hints;
Atom property;
hints.flags = 2;
- hints.decorations = window_get_flag(WINDOW_FLAG_BORDERLESS, p_window) ? 0 : 1;
+ hints.decorations = wd.borderless ? 0 : 1;
property = XInternAtom(x11_display, "_MOTIF_WM_HINTS", True);
if (property != None) {
XChangeProperty(x11_display, wd.x11_window, property, property, 32, PropModeReplace, (unsigned char *)&hints, 5);
diff --git a/platform/linuxbsd/joypad_linux.cpp b/platform/linuxbsd/joypad_linux.cpp
index 5eda42fea6..8e963238e3 100644
--- a/platform/linuxbsd/joypad_linux.cpp
+++ b/platform/linuxbsd/joypad_linux.cpp
@@ -333,8 +333,9 @@ void JoypadLinux::open_joypad(const char *p_path) {
}
// Check if the device supports basic gamepad events
- if (!(test_bit(EV_KEY, evbit) && test_bit(EV_ABS, evbit) &&
- test_bit(ABS_X, absbit) && test_bit(ABS_Y, absbit))) {
+ bool has_abs_left = (test_bit(ABS_X, absbit) && test_bit(ABS_Y, absbit));
+ bool has_abs_right = (test_bit(ABS_RX, absbit) && test_bit(ABS_RY, absbit));
+ if (!(test_bit(EV_KEY, evbit) && test_bit(EV_ABS, evbit) && (has_abs_left || has_abs_right))) {
close(fd);
return;
}
diff --git a/platform/osx/crash_handler_osx.mm b/platform/osx/crash_handler_osx.mm
index 16be941308..3e640b3bf3 100644
--- a/platform/osx/crash_handler_osx.mm
+++ b/platform/osx/crash_handler_osx.mm
@@ -33,7 +33,6 @@
#include "core/config/project_settings.h"
#include "core/os/os.h"
#include "core/version.h"
-#include "core/version_hash.gen.h"
#include "main/main.h"
#include <string.h>
@@ -94,10 +93,10 @@ static void handle_crash(int sig) {
OS::get_singleton()->get_main_loop()->notification(MainLoop::NOTIFICATION_CRASH);
// Print the engine version just before, so that people are reminded to include the version in backtrace reports.
- if (String(VERSION_HASH).length() != 0) {
- fprintf(stderr, "Engine version: " VERSION_FULL_NAME " (" VERSION_HASH ")\n");
+ if (String(VERSION_HASH).is_empty()) {
+ fprintf(stderr, "Engine version: %s\n", VERSION_FULL_NAME);
} else {
- fprintf(stderr, "Engine version: " VERSION_FULL_NAME "\n");
+ fprintf(stderr, "Engine version: %s (%s)\n", VERSION_FULL_NAME, VERSION_HASH);
}
fprintf(stderr, "Dumping the backtrace. %s\n", msg.utf8().get_data());
char **strings = backtrace_symbols(bt_buffer, size);
diff --git a/platform/osx/detect.py b/platform/osx/detect.py
index e7fe37d4b5..0ff93bedb4 100644
--- a/platform/osx/detect.py
+++ b/platform/osx/detect.py
@@ -78,9 +78,9 @@ def configure(env):
env["osxcross"] = True
if env["arch"] == "arm64":
- print("Building for macOS 11.00+, platform arm64.")
- env.Append(CCFLAGS=["-arch", "arm64", "-mmacosx-version-min=11.00"])
- env.Append(LINKFLAGS=["-arch", "arm64", "-mmacosx-version-min=11.00"])
+ print("Building for macOS 11.0+, platform arm64.")
+ env.Append(CCFLAGS=["-arch", "arm64", "-mmacosx-version-min=11.0"])
+ env.Append(LINKFLAGS=["-arch", "arm64", "-mmacosx-version-min=11.0"])
else:
print("Building for macOS 10.12+, platform x86_64.")
env.Append(CCFLAGS=["-arch", "x86_64", "-mmacosx-version-min=10.12"])
diff --git a/platform/osx/display_server_osx.mm b/platform/osx/display_server_osx.mm
index ba10d7593f..2691664b96 100644
--- a/platform/osx/display_server_osx.mm
+++ b/platform/osx/display_server_osx.mm
@@ -125,6 +125,7 @@ DisplayServerOSX::WindowID DisplayServerOSX::_create_window(WindowMode p_mode, V
backing:NSBackingStoreBuffered
defer:NO];
ERR_FAIL_COND_V_MSG(wd.window_object == nil, INVALID_WINDOW_ID, "Can't create a window");
+ [wd.window_object setWindowID:window_id_counter];
wd.window_view = [[GodotContentView alloc] init];
ERR_FAIL_COND_V_MSG(wd.window_view == nil, INVALID_WINDOW_ID, "Can't create a window view");
diff --git a/platform/osx/godot_window.mm b/platform/osx/godot_window.mm
index e392cfb384..772a2ddb9f 100644
--- a/platform/osx/godot_window.mm
+++ b/platform/osx/godot_window.mm
@@ -45,7 +45,7 @@
}
- (BOOL)canBecomeKeyWindow {
- // Required for NSBorderlessWindowMask windows.
+ // Required for NSWindowStyleMaskBorderless windows.
DisplayServerOSX *ds = (DisplayServerOSX *)DisplayServer::get_singleton();
if (!ds || !ds->has_window(window_id)) {
return YES;
@@ -56,7 +56,7 @@
}
- (BOOL)canBecomeMainWindow {
- // Required for NSBorderlessWindowMask windows.
+ // Required for NSWindowStyleMaskBorderless windows.
DisplayServerOSX *ds = (DisplayServerOSX *)DisplayServer::get_singleton();
if (!ds || !ds->has_window(window_id)) {
return YES;
diff --git a/platform/windows/crash_handler_windows.cpp b/platform/windows/crash_handler_windows.cpp
index 71e9d9acbd..5064f6b97f 100644
--- a/platform/windows/crash_handler_windows.cpp
+++ b/platform/windows/crash_handler_windows.cpp
@@ -33,7 +33,6 @@
#include "core/config/project_settings.h"
#include "core/os/os.h"
#include "core/version.h"
-#include "core/version_hash.gen.h"
#include "main/main.h"
#ifdef CRASH_HANDLER_EXCEPTION
@@ -179,10 +178,10 @@ DWORD CrashHandlerException(EXCEPTION_POINTERS *ep) {
}
// Print the engine version just before, so that people are reminded to include the version in backtrace reports.
- if (String(VERSION_HASH).length() != 0) {
- fprintf(stderr, "Engine version: " VERSION_FULL_NAME " (" VERSION_HASH ")\n");
+ if (String(VERSION_HASH).is_empty()) {
+ fprintf(stderr, "Engine version: %s\n", VERSION_FULL_NAME);
} else {
- fprintf(stderr, "Engine version: " VERSION_FULL_NAME "\n");
+ fprintf(stderr, "Engine version: %s (%s)\n", VERSION_FULL_NAME, VERSION_HASH);
}
fprintf(stderr, "Dumping the backtrace. %s\n", msg.utf8().get_data());
diff --git a/platform/windows/display_server_windows.cpp b/platform/windows/display_server_windows.cpp
index 21ab9923a2..20268b3f6a 100644
--- a/platform/windows/display_server_windows.cpp
+++ b/platform/windows/display_server_windows.cpp
@@ -2710,12 +2710,17 @@ LRESULT DisplayServerWindows::WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARA
case WM_WINDOWPOSCHANGED: {
Rect2i window_client_rect;
+ Rect2i window_rect;
{
RECT rect;
GetClientRect(hWnd, &rect);
ClientToScreen(hWnd, (POINT *)&rect.left);
ClientToScreen(hWnd, (POINT *)&rect.right);
window_client_rect = Rect2i(rect.left, rect.top, rect.right - rect.left, rect.bottom - rect.top);
+
+ RECT wrect;
+ GetWindowRect(hWnd, &wrect);
+ window_rect = Rect2i(wrect.left, wrect.top, wrect.right - wrect.left, wrect.bottom - wrect.top);
}
WINDOWPOS *window_pos_params = (WINDOWPOS *)lParam;
@@ -2735,7 +2740,7 @@ LRESULT DisplayServerWindows::WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARA
window.minimized = true;
} else if (IsZoomed(hWnd)) {
window.maximized = true;
- } else if (window_client_rect.position == screen_position && window_client_rect.size == screen_size) {
+ } else if (window_rect.position == screen_position && window_rect.size == screen_size) {
window.fullscreen = true;
}
diff --git a/scene/2d/navigation_region_2d.cpp b/scene/2d/navigation_region_2d.cpp
index 4bead978f1..e685ad8f67 100644
--- a/scene/2d/navigation_region_2d.cpp
+++ b/scene/2d/navigation_region_2d.cpp
@@ -104,8 +104,8 @@ void NavigationPolygon::_set_polygons(const TypedArray<Vector<int32_t>> &p_array
}
}
-Array NavigationPolygon::_get_polygons() const {
- Array ret;
+TypedArray<Vector<int32_t>> NavigationPolygon::_get_polygons() const {
+ TypedArray<Vector<int32_t>> ret;
ret.resize(polygons.size());
for (int i = 0; i < ret.size(); i++) {
ret[i] = polygons[i].indices;
@@ -122,8 +122,8 @@ void NavigationPolygon::_set_outlines(const TypedArray<Vector<Vector2>> &p_array
rect_cache_dirty = true;
}
-Array NavigationPolygon::_get_outlines() const {
- Array ret;
+TypedArray<Vector<Vector2>> NavigationPolygon::_get_outlines() const {
+ TypedArray<Vector<Vector2>> ret;
ret.resize(outlines.size());
for (int i = 0; i < ret.size(); i++) {
ret[i] = outlines[i];
diff --git a/scene/2d/navigation_region_2d.h b/scene/2d/navigation_region_2d.h
index 012debb584..487a578401 100644
--- a/scene/2d/navigation_region_2d.h
+++ b/scene/2d/navigation_region_2d.h
@@ -55,10 +55,10 @@ protected:
static void _bind_methods();
void _set_polygons(const TypedArray<Vector<int32_t>> &p_array);
- Array _get_polygons() const;
+ TypedArray<Vector<int32_t>> _get_polygons() const;
void _set_outlines(const TypedArray<Vector<Vector2>> &p_array);
- Array _get_outlines() const;
+ TypedArray<Vector<Vector2>> _get_outlines() const;
public:
#ifdef TOOLS_ENABLED
diff --git a/scene/2d/ray_cast_2d.cpp b/scene/2d/ray_cast_2d.cpp
index 9521667854..51b3e676f9 100644
--- a/scene/2d/ray_cast_2d.cpp
+++ b/scene/2d/ray_cast_2d.cpp
@@ -279,6 +279,13 @@ void RayCast2D::remove_exception(const CollisionObject2D *p_node) {
void RayCast2D::clear_exceptions() {
exclude.clear();
+
+ if (exclude_parent_body && is_inside_tree()) {
+ CollisionObject2D *parent = Object::cast_to<CollisionObject2D>(get_parent());
+ if (parent) {
+ exclude.insert(parent->get_rid());
+ }
+ }
}
void RayCast2D::set_collide_with_areas(bool p_enabled) {
diff --git a/scene/3d/occluder_instance_3d.cpp b/scene/3d/occluder_instance_3d.cpp
index e0e2eae4a5..0277171922 100644
--- a/scene/3d/occluder_instance_3d.cpp
+++ b/scene/3d/occluder_instance_3d.cpp
@@ -30,41 +30,24 @@
#include "occluder_instance_3d.h"
#include "core/core_string_names.h"
+#include "core/math/geometry_2d.h"
+#include "core/math/triangulate.h"
+#include "scene/3d/importer_mesh_instance_3d.h"
#include "scene/3d/mesh_instance_3d.h"
+#include "scene/resources/importer_mesh.h"
+#include "scene/resources/surface_tool.h"
+
+#ifdef TOOLS_ENABLED
+#include "editor/editor_node.h"
+#endif
RID Occluder3D::get_rid() const {
- if (!occluder.is_valid()) {
- occluder = RS::get_singleton()->occluder_create();
- RS::get_singleton()->occluder_set_mesh(occluder, vertices, indices);
- }
return occluder;
}
-void Occluder3D::set_vertices(PackedVector3Array p_vertices) {
- vertices = p_vertices;
- if (occluder.is_valid()) {
- RS::get_singleton()->occluder_set_mesh(occluder, vertices, indices);
- }
- _update_changes();
-}
-
-PackedVector3Array Occluder3D::get_vertices() const {
- return vertices;
-}
-
-void Occluder3D::set_indices(PackedInt32Array p_indices) {
- indices = p_indices;
- if (occluder.is_valid()) {
- RS::get_singleton()->occluder_set_mesh(occluder, vertices, indices);
- }
- _update_changes();
-}
+void Occluder3D::_update() {
+ _update_arrays(vertices, indices);
-PackedInt32Array Occluder3D::get_indices() const {
- return indices;
-}
-
-void Occluder3D::_update_changes() {
aabb = AABB();
const Vector3 *ptr = vertices.ptr();
@@ -75,9 +58,18 @@ void Occluder3D::_update_changes() {
debug_lines.clear();
debug_mesh.unref();
+ RS::get_singleton()->occluder_set_mesh(occluder, vertices, indices);
emit_changed();
}
+PackedVector3Array Occluder3D::get_vertices() const {
+ return vertices;
+}
+
+PackedInt32Array Occluder3D::get_indices() const {
+ return indices;
+}
+
Vector<Vector3> Occluder3D::get_debug_lines() const {
if (!debug_lines.is_empty()) {
return debug_lines;
@@ -87,14 +79,18 @@ Vector<Vector3> Occluder3D::get_debug_lines() const {
return Vector<Vector3>();
}
+ const Vector3 *vertices_ptr = vertices.ptr();
+ debug_lines.resize(indices.size() / 3 * 6);
+ Vector3 *line_ptr = debug_lines.ptrw();
+ int line_i = 0;
for (int i = 0; i < indices.size() / 3; i++) {
for (int j = 0; j < 3; j++) {
int a = indices[i * 3 + j];
int b = indices[i * 3 + (j + 1) % 3];
ERR_FAIL_INDEX_V_MSG(a, vertices.size(), Vector<Vector3>(), "Occluder indices are out of range.");
ERR_FAIL_INDEX_V_MSG(b, vertices.size(), Vector<Vector3>(), "Occluder indices are out of range.");
- debug_lines.push_back(vertices[a]);
- debug_lines.push_back(vertices[b]);
+ line_ptr[line_i++] = vertices_ptr[a];
+ line_ptr[line_i++] = vertices_ptr[b];
}
}
return debug_lines;
@@ -105,7 +101,7 @@ Ref<ArrayMesh> Occluder3D::get_debug_mesh() const {
return debug_mesh;
}
- if (indices.size() % 3 != 0) {
+ if (vertices.is_empty() || indices.is_empty() || indices.size() % 3 != 0) {
return debug_mesh;
}
@@ -123,18 +119,17 @@ AABB Occluder3D::get_aabb() const {
return aabb;
}
-void Occluder3D::_bind_methods() {
- ClassDB::bind_method(D_METHOD("set_vertices", "vertices"), &Occluder3D::set_vertices);
- ClassDB::bind_method(D_METHOD("get_vertices"), &Occluder3D::get_vertices);
-
- ClassDB::bind_method(D_METHOD("set_indices", "indices"), &Occluder3D::set_indices);
- ClassDB::bind_method(D_METHOD("get_indices"), &Occluder3D::get_indices);
+void Occluder3D::_notification(int p_what) {
+ if (p_what == NOTIFICATION_POSTINITIALIZE) {
+ _update();
+ }
+}
- ADD_PROPERTY(PropertyInfo(Variant::PACKED_VECTOR3_ARRAY, "vertices", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_NO_EDITOR), "set_vertices", "get_vertices");
- ADD_PROPERTY(PropertyInfo(Variant::PACKED_INT32_ARRAY, "indices", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_NO_EDITOR), "set_indices", "get_indices");
+void Occluder3D::_bind_methods() {
}
Occluder3D::Occluder3D() {
+ occluder = RS::get_singleton()->occluder_create();
}
Occluder3D::~Occluder3D() {
@@ -142,6 +137,291 @@ Occluder3D::~Occluder3D() {
RS::get_singleton()->free(occluder);
}
}
+
+/////////////////////////////////////////////////
+
+void ArrayOccluder3D::set_arrays(PackedVector3Array p_vertices, PackedInt32Array p_indices) {
+ vertices = p_vertices;
+ indices = p_indices;
+ _update();
+}
+
+void ArrayOccluder3D::set_vertices(PackedVector3Array p_vertices) {
+ vertices = p_vertices;
+ _update();
+}
+
+void ArrayOccluder3D::set_indices(PackedInt32Array p_indices) {
+ indices = p_indices;
+ _update();
+}
+
+void ArrayOccluder3D::_update_arrays(PackedVector3Array &r_vertices, PackedInt32Array &r_indices) {
+ r_vertices = vertices;
+ r_indices = indices;
+}
+
+void ArrayOccluder3D::_bind_methods() {
+ ClassDB::bind_method(D_METHOD("set_arrays", "vertices", "indices"), &ArrayOccluder3D::set_arrays);
+
+ ClassDB::bind_method(D_METHOD("set_vertices", "vertices"), &ArrayOccluder3D::set_vertices);
+ ClassDB::bind_method(D_METHOD("get_vertices"), &ArrayOccluder3D::get_vertices);
+
+ ClassDB::bind_method(D_METHOD("set_indices", "indices"), &ArrayOccluder3D::set_indices);
+ ClassDB::bind_method(D_METHOD("get_indices"), &ArrayOccluder3D::get_indices);
+
+ ADD_PROPERTY(PropertyInfo(Variant::PACKED_VECTOR3_ARRAY, "vertices", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_NO_EDITOR), "set_vertices", "get_vertices");
+ ADD_PROPERTY(PropertyInfo(Variant::PACKED_INT32_ARRAY, "indices", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_NO_EDITOR), "set_indices", "get_indices");
+}
+
+ArrayOccluder3D::ArrayOccluder3D() {
+}
+
+ArrayOccluder3D::~ArrayOccluder3D() {
+}
+
+/////////////////////////////////////////////////
+
+void QuadOccluder3D::set_size(const Vector2 &p_size) {
+ if (size == p_size) {
+ return;
+ }
+
+ size = p_size.max(Vector2());
+ ;
+ _update();
+}
+
+Vector2 QuadOccluder3D::get_size() const {
+ return size;
+}
+
+void QuadOccluder3D::_update_arrays(PackedVector3Array &r_vertices, PackedInt32Array &r_indices) {
+ Vector2 _size = Vector2(size.x / 2.0f, size.y / 2.0f);
+
+ r_vertices = {
+ Vector3(-_size.x, -_size.y, 0),
+ Vector3(-_size.x, _size.y, 0),
+ Vector3(_size.x, _size.y, 0),
+ Vector3(_size.x, -_size.y, 0),
+ };
+
+ r_indices = {
+ 0, 1, 2,
+ 0, 2, 3
+ };
+}
+
+void QuadOccluder3D::_bind_methods() {
+ ClassDB::bind_method(D_METHOD("set_size", "size"), &QuadOccluder3D::set_size);
+ ClassDB::bind_method(D_METHOD("get_size"), &QuadOccluder3D::get_size);
+
+ ADD_PROPERTY(PropertyInfo(Variant::VECTOR2, "size"), "set_size", "get_size");
+}
+
+QuadOccluder3D::QuadOccluder3D() {
+}
+
+QuadOccluder3D::~QuadOccluder3D() {
+}
+
+/////////////////////////////////////////////////
+
+void BoxOccluder3D::set_size(const Vector3 &p_size) {
+ if (size == p_size) {
+ return;
+ }
+
+ size = Vector3(MAX(p_size.x, 0.0f), MAX(p_size.y, 0.0f), MAX(p_size.z, 0.0f));
+ ;
+ _update();
+}
+
+Vector3 BoxOccluder3D::get_size() const {
+ return size;
+}
+
+void BoxOccluder3D::_update_arrays(PackedVector3Array &r_vertices, PackedInt32Array &r_indices) {
+ Vector3 _size = Vector3(size.x / 2.0f, size.y / 2.0f, size.z / 2.0f);
+
+ r_vertices = {
+ // front
+ Vector3(-_size.x, -_size.y, _size.z),
+ Vector3(_size.x, -_size.y, _size.z),
+ Vector3(_size.x, _size.y, _size.z),
+ Vector3(-_size.x, _size.y, _size.z),
+ // back
+ Vector3(-_size.x, -_size.y, -_size.z),
+ Vector3(_size.x, -_size.y, -_size.z),
+ Vector3(_size.x, _size.y, -_size.z),
+ Vector3(-_size.x, _size.y, -_size.z),
+ };
+
+ r_indices = {
+ // front
+ 0, 1, 2,
+ 2, 3, 0,
+ // right
+ 1, 5, 6,
+ 6, 2, 1,
+ // back
+ 7, 6, 5,
+ 5, 4, 7,
+ // left
+ 4, 0, 3,
+ 3, 7, 4,
+ // bottom
+ 4, 5, 1,
+ 1, 0, 4,
+ // top
+ 3, 2, 6,
+ 6, 7, 3
+ };
+}
+
+void BoxOccluder3D::_bind_methods() {
+ ClassDB::bind_method(D_METHOD("set_size", "size"), &BoxOccluder3D::set_size);
+ ClassDB::bind_method(D_METHOD("get_size"), &BoxOccluder3D::get_size);
+
+ ADD_PROPERTY(PropertyInfo(Variant::VECTOR3, "size"), "set_size", "get_size");
+}
+
+BoxOccluder3D::BoxOccluder3D() {
+}
+
+BoxOccluder3D::~BoxOccluder3D() {
+}
+
+/////////////////////////////////////////////////
+
+void SphereOccluder3D::set_radius(float p_radius) {
+ if (radius == p_radius) {
+ return;
+ }
+
+ radius = MAX(p_radius, 0.0f);
+ _update();
+}
+
+float SphereOccluder3D::get_radius() const {
+ return radius;
+}
+
+void SphereOccluder3D::_update_arrays(PackedVector3Array &r_vertices, PackedInt32Array &r_indices) {
+ r_vertices.resize((RINGS + 2) * (RADIAL_SEGMENTS + 1));
+ int vertex_i = 0;
+ Vector3 *vertex_ptr = r_vertices.ptrw();
+
+ r_indices.resize((RINGS + 1) * RADIAL_SEGMENTS * 6);
+ int idx_i = 0;
+ int *idx_ptr = r_indices.ptrw();
+
+ int current_row = 0;
+ int previous_row = 0;
+ int point = 0;
+ for (int j = 0; j <= (RINGS + 1); j++) {
+ float v = j / float(RINGS + 1);
+ float w = Math::sin(Math_PI * v);
+ float y = Math::cos(Math_PI * v);
+ for (int i = 0; i <= RADIAL_SEGMENTS; i++) {
+ float u = i / float(RADIAL_SEGMENTS);
+
+ float x = Math::cos(u * Math_TAU);
+ float z = Math::sin(u * Math_TAU);
+ vertex_ptr[vertex_i++] = Vector3(x * w, y, z * w) * radius;
+
+ if (i > 0 && j > 0) {
+ idx_ptr[idx_i++] = previous_row + i - 1;
+ idx_ptr[idx_i++] = previous_row + i;
+ idx_ptr[idx_i++] = current_row + i - 1;
+
+ idx_ptr[idx_i++] = previous_row + i;
+ idx_ptr[idx_i++] = current_row + i;
+ idx_ptr[idx_i++] = current_row + i - 1;
+ }
+
+ point++;
+ }
+
+ previous_row = current_row;
+ current_row = point;
+ }
+}
+
+void SphereOccluder3D::_bind_methods() {
+ ClassDB::bind_method(D_METHOD("set_radius", "radius"), &SphereOccluder3D::set_radius);
+ ClassDB::bind_method(D_METHOD("get_radius"), &SphereOccluder3D::get_radius);
+
+ ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "radius"), "set_radius", "get_radius");
+}
+
+SphereOccluder3D::SphereOccluder3D() {
+}
+
+SphereOccluder3D::~SphereOccluder3D() {
+}
+
+/////////////////////////////////////////////////
+
+void PolygonOccluder3D::set_polygon(const Vector<Vector2> &p_polygon) {
+ polygon = p_polygon;
+ _update();
+}
+
+Vector<Vector2> PolygonOccluder3D::get_polygon() const {
+ return polygon;
+}
+
+void PolygonOccluder3D::_update_arrays(PackedVector3Array &r_vertices, PackedInt32Array &r_indices) {
+ if (polygon.size() < 3) {
+ r_vertices.clear();
+ r_indices.clear();
+ return;
+ }
+
+ Vector<Point2> occluder_polygon = polygon;
+ if (Triangulate::get_area(occluder_polygon) > 0) {
+ occluder_polygon.reverse();
+ }
+
+ Vector<int> occluder_indices = Geometry2D::triangulate_polygon(occluder_polygon);
+
+ if (occluder_indices.size() < 3) {
+ r_vertices.clear();
+ r_indices.clear();
+ ERR_FAIL_MSG("Failed to triangulate PolygonOccluder3D. Make sure the polygon doesn't have any intersecting edges.");
+ }
+
+ r_vertices.resize(occluder_polygon.size());
+ Vector3 *vertex_ptr = r_vertices.ptrw();
+ const Vector2 *polygon_ptr = occluder_polygon.ptr();
+ for (int i = 0; i < occluder_polygon.size(); i++) {
+ vertex_ptr[i] = Vector3(polygon_ptr[i].x, polygon_ptr[i].y, 0.0);
+ }
+
+ r_indices.resize(occluder_indices.size());
+ memcpy(r_indices.ptrw(), occluder_indices.ptr(), occluder_indices.size() * sizeof(int));
+}
+
+bool PolygonOccluder3D::_has_editable_3d_polygon_no_depth() const {
+ return false;
+}
+
+void PolygonOccluder3D::_bind_methods() {
+ ClassDB::bind_method(D_METHOD("set_polygon", "polygon"), &PolygonOccluder3D::set_polygon);
+ ClassDB::bind_method(D_METHOD("get_polygon"), &PolygonOccluder3D::get_polygon);
+
+ ClassDB::bind_method(D_METHOD("_has_editable_3d_polygon_no_depth"), &PolygonOccluder3D::_has_editable_3d_polygon_no_depth);
+
+ ADD_PROPERTY(PropertyInfo(Variant::PACKED_VECTOR2_ARRAY, "polygon"), "set_polygon", "get_polygon");
+}
+
+PolygonOccluder3D::PolygonOccluder3D() {
+}
+
+PolygonOccluder3D::~PolygonOccluder3D() {
+}
+
/////////////////////////////////////////////////
AABB OccluderInstance3D::get_aabb() const {
@@ -175,6 +455,13 @@ void OccluderInstance3D::set_occluder(const Ref<Occluder3D> &p_occluder) {
update_gizmos();
update_configuration_warnings();
+
+#ifdef TOOLS_ENABLED
+ // PolygonOccluder3D is edited via an editor plugin, this ensures the plugin is shown/hidden when necessary
+ if (Engine::get_singleton()->is_editor_hint()) {
+ EditorNode::get_singleton()->call_deferred(SNAME("edit_current"));
+ }
+#endif
}
void OccluderInstance3D::_occluder_changed() {
@@ -195,6 +482,14 @@ uint32_t OccluderInstance3D::get_bake_mask() const {
return bake_mask;
}
+void OccluderInstance3D::set_bake_simplification_distance(float p_dist) {
+ bake_simplification_dist = MAX(p_dist, 0.0f);
+}
+
+float OccluderInstance3D::get_bake_simplification_distance() const {
+ return bake_simplification_dist;
+}
+
void OccluderInstance3D::set_bake_mask_value(int p_layer_number, bool p_value) {
ERR_FAIL_COND_MSG(p_layer_number < 1, "Render layer number must be between 1 and 20 inclusive.");
ERR_FAIL_COND_MSG(p_layer_number > 20, "Render layer number must be between 1 and 20 inclusive.");
@@ -221,6 +516,47 @@ bool OccluderInstance3D::_bake_material_check(Ref<Material> p_material) {
return true;
}
+void OccluderInstance3D::_bake_surface(const Transform3D &p_transform, Array p_surface_arrays, Ref<Material> p_material, float p_simplification_dist, PackedVector3Array &r_vertices, PackedInt32Array &r_indices) {
+ if (!_bake_material_check(p_material)) {
+ return;
+ }
+ ERR_FAIL_COND_MSG(p_surface_arrays.size() != Mesh::ARRAY_MAX, "Invalid surface array.");
+
+ PackedVector3Array vertices = p_surface_arrays[Mesh::ARRAY_VERTEX];
+ PackedInt32Array indices = p_surface_arrays[Mesh::ARRAY_INDEX];
+
+ if (vertices.size() == 0 || indices.size() == 0) {
+ return;
+ }
+
+ Vector3 *vertices_ptr = vertices.ptrw();
+ for (int j = 0; j < vertices.size(); j++) {
+ vertices_ptr[j] = p_transform.xform(vertices_ptr[j]);
+ }
+
+ if (!Math::is_zero_approx(p_simplification_dist) && SurfaceTool::simplify_func) {
+ float error_scale = SurfaceTool::simplify_scale_func((float *)vertices.ptr(), vertices.size(), sizeof(Vector3));
+ float target_error = p_simplification_dist / error_scale;
+ float error = -1.0f;
+ int target_index_count = MIN(indices.size(), 36);
+ uint32_t index_count = SurfaceTool::simplify_func((unsigned int *)indices.ptrw(), (unsigned int *)indices.ptr(), indices.size(), (float *)vertices.ptr(), vertices.size(), sizeof(Vector3), target_index_count, target_error, &error);
+ indices.resize(index_count);
+ }
+
+ SurfaceTool::strip_mesh_arrays(vertices, indices);
+
+ int vertex_offset = r_vertices.size();
+ r_vertices.resize(vertex_offset + vertices.size());
+ memcpy(r_vertices.ptrw() + vertex_offset, vertices.ptr(), vertices.size() * sizeof(Vector3));
+
+ int index_offset = r_indices.size();
+ r_indices.resize(index_offset + indices.size());
+ int *idx_ptr = r_indices.ptrw();
+ for (int j = 0; j < indices.size(); j++) {
+ idx_ptr[index_offset + j] = vertex_offset + indices[j];
+ }
+}
+
void OccluderInstance3D::_bake_node(Node *p_node, PackedVector3Array &r_vertices, PackedInt32Array &r_indices) {
MeshInstance3D *mi = Object::cast_to<MeshInstance3D>(p_node);
if (mi && mi->is_visible_in_tree()) {
@@ -243,58 +579,76 @@ void OccluderInstance3D::_bake_node(Node *p_node, PackedVector3Array &r_vertices
Transform3D global_to_local = get_global_transform().affine_inverse() * mi->get_global_transform();
for (int i = 0; i < mesh->get_surface_count(); i++) {
- if (mesh->surface_get_primitive_type(i) != Mesh::PRIMITIVE_TRIANGLES) {
- continue;
- }
+ _bake_surface(global_to_local, mesh->surface_get_arrays(i), mi->get_active_material(i), bake_simplification_dist, r_vertices, r_indices);
+ }
+ }
+ }
- if (mi->get_surface_override_material(i).is_valid()) {
- if (!_bake_material_check(mi->get_surface_override_material(i))) {
- continue;
- }
- } else {
- if (!_bake_material_check(mesh->surface_get_material(i))) {
- continue;
- }
- }
+ for (int i = 0; i < p_node->get_child_count(); i++) {
+ Node *child = p_node->get_child(i);
+ if (!child->get_owner()) {
+ continue; // may be a helper
+ }
- Array arrays = mesh->surface_get_arrays(i);
+ _bake_node(child, r_vertices, r_indices);
+ }
+}
- int vertex_offset = r_vertices.size();
- PackedVector3Array vertices = arrays[Mesh::ARRAY_VERTEX];
- r_vertices.resize(r_vertices.size() + vertices.size());
+void OccluderInstance3D::bake_single_node(const Node3D *p_node, float p_simplification_distance, PackedVector3Array &r_vertices, PackedInt32Array &r_indices) {
+ ERR_FAIL_COND(!p_node);
- Vector3 *vtx_ptr = r_vertices.ptrw();
- for (int j = 0; j < vertices.size(); j++) {
- vtx_ptr[vertex_offset + j] = global_to_local.xform(vertices[j]);
- }
+ Transform3D xform = p_node->is_inside_tree() ? p_node->get_global_transform() : p_node->get_transform();
- int index_offset = r_indices.size();
- PackedInt32Array indices = arrays[Mesh::ARRAY_INDEX];
- r_indices.resize(r_indices.size() + indices.size());
+ const MeshInstance3D *mi = Object::cast_to<MeshInstance3D>(p_node);
+ if (mi) {
+ Ref<Mesh> mesh = mi->get_mesh();
+ bool valid = true;
- int *idx_ptr = r_indices.ptrw();
- for (int j = 0; j < indices.size(); j++) {
- idx_ptr[index_offset + j] = vertex_offset + indices[j];
- }
+ if (mesh.is_null()) {
+ valid = false;
+ }
+
+ if (valid && !_bake_material_check(mi->get_material_override())) {
+ valid = false;
+ }
+
+ if (valid) {
+ for (int i = 0; i < mesh->get_surface_count(); i++) {
+ _bake_surface(xform, mesh->surface_get_arrays(i), mi->get_active_material(i), p_simplification_distance, r_vertices, r_indices);
}
}
}
- for (int i = 0; i < p_node->get_child_count(); i++) {
- Node *child = p_node->get_child(i);
- if (!child->get_owner()) {
- continue; //maybe a helper
+ const ImporterMeshInstance3D *imi = Object::cast_to<ImporterMeshInstance3D>(p_node);
+ if (imi) {
+ Ref<ImporterMesh> mesh = imi->get_mesh();
+ bool valid = true;
+
+ if (mesh.is_null()) {
+ valid = false;
}
- _bake_node(child, r_vertices, r_indices);
+ if (valid) {
+ for (int i = 0; i < mesh->get_surface_count(); i++) {
+ Ref<Material> material = imi->get_surface_material(i);
+ if (material.is_null()) {
+ material = mesh->get_surface_material(i);
+ }
+ _bake_surface(xform, mesh->get_surface_arrays(i), material, p_simplification_distance, r_vertices, r_indices);
+ }
+ }
}
}
-OccluderInstance3D::BakeError OccluderInstance3D::bake(Node *p_from_node, String p_occluder_path) {
+OccluderInstance3D::BakeError OccluderInstance3D::bake_scene(Node *p_from_node, String p_occluder_path) {
if (p_occluder_path.is_empty()) {
if (get_occluder().is_null()) {
return BAKE_ERROR_NO_SAVE_PATH;
}
+ p_occluder_path = get_occluder()->get_path();
+ if (!p_occluder_path.is_resource_file()) {
+ return BAKE_ERROR_NO_SAVE_PATH;
+ }
}
PackedVector3Array vertices;
@@ -306,16 +660,25 @@ OccluderInstance3D::BakeError OccluderInstance3D::bake(Node *p_from_node, String
return BAKE_ERROR_NO_MESHES;
}
- Ref<Occluder3D> occ;
+ Ref<ArrayOccluder3D> occ;
if (get_occluder().is_valid()) {
occ = get_occluder();
- } else {
+ set_occluder(Ref<Occluder3D>()); // clear
+ }
+
+ if (occ.is_null()) {
occ.instantiate();
- occ->set_path(p_occluder_path);
}
- occ->set_vertices(vertices);
- occ->set_indices(indices);
+ occ->set_arrays(vertices, indices);
+
+ Error err = ResourceSaver::save(p_occluder_path, occ);
+
+ if (err != OK) {
+ return BAKE_ERROR_CANT_SAVE;
+ }
+
+ occ->set_path(p_occluder_path);
set_occluder(occ);
return BAKE_ERROR_OK;
@@ -333,28 +696,49 @@ TypedArray<String> OccluderInstance3D::get_configuration_warnings() const {
}
if (occluder.is_null()) {
- warnings.push_back(TTR("No occluder mesh is defined in the Occluder property, so no occlusion culling will be performed using this OccluderInstance3D.\nTo resolve this, select the OccluderInstance3D then use the Bake Occluders button at the top of the 3D editor viewport."));
- } else if (occluder->get_vertices().size() < 3) {
- // Using the "New Occluder" dropdown button won't result in a correct occluder,
- // so warn the user about this.
- warnings.push_back(TTR("The occluder mesh has less than 3 vertices, so no occlusion culling will be performed using this OccluderInstance3D.\nTo generate a proper occluder mesh, select the OccluderInstance3D then use the Bake Occluders button at the top of the 3D editor viewport."));
+ warnings.push_back(TTR("No occluder mesh is defined in the Occluder property, so no occlusion culling will be performed using this OccluderInstance3D.\nTo resolve this, set the Occluder property to one of the primitive occluder types or bake the scene meshes by selecting the OccluderInstance3D and pressing the Bake Occluders button at the top of the 3D editor viewport."));
+ } else {
+ Ref<ArrayOccluder3D> arr_occluder = occluder;
+ if (arr_occluder.is_valid() && arr_occluder->get_indices().size() < 3) {
+ // Setting a new ArrayOccluder3D from the inspector will create an empty occluder,
+ // so warn the user about this.
+ warnings.push_back(TTR("The occluder mesh has less than 3 vertices, so no occlusion culling will be performed using this OccluderInstance3D.\nTo generate a proper occluder mesh, select the OccluderInstance3D then use the Bake Occluders button at the top of the 3D editor viewport."));
+ }
+ Ref<PolygonOccluder3D> poly_occluder = occluder;
+ if (poly_occluder.is_valid() && poly_occluder->get_polygon().size() < 3) {
+ warnings.push_back(TTR("The polygon occluder has less than 3 vertices, so no occlusion culling will be performed using this OccluderInstance3D.\nVertices can be added in the inspector or using the polygon editing tools at the top of the 3D editor viewport."));
+ }
}
return warnings;
}
+bool OccluderInstance3D::_is_editable_3d_polygon() const {
+ return Ref<PolygonOccluder3D>(occluder).is_valid();
+}
+
+Ref<Resource> OccluderInstance3D::_get_editable_3d_polygon_resource() const {
+ return occluder;
+}
+
void OccluderInstance3D::_bind_methods() {
ClassDB::bind_method(D_METHOD("set_bake_mask", "mask"), &OccluderInstance3D::set_bake_mask);
ClassDB::bind_method(D_METHOD("get_bake_mask"), &OccluderInstance3D::get_bake_mask);
ClassDB::bind_method(D_METHOD("set_bake_mask_value", "layer_number", "value"), &OccluderInstance3D::set_bake_mask_value);
ClassDB::bind_method(D_METHOD("get_bake_mask_value", "layer_number"), &OccluderInstance3D::get_bake_mask_value);
+ ClassDB::bind_method(D_METHOD("set_bake_simplification_distance", "simplification_distance"), &OccluderInstance3D::set_bake_simplification_distance);
+ ClassDB::bind_method(D_METHOD("get_bake_simplification_distance"), &OccluderInstance3D::get_bake_simplification_distance);
ClassDB::bind_method(D_METHOD("set_occluder", "occluder"), &OccluderInstance3D::set_occluder);
ClassDB::bind_method(D_METHOD("get_occluder"), &OccluderInstance3D::get_occluder);
+ ClassDB::bind_method(D_METHOD("_is_editable_3d_polygon"), &OccluderInstance3D::_is_editable_3d_polygon);
+ ClassDB::bind_method(D_METHOD("_get_editable_3d_polygon_resource"), &OccluderInstance3D::_get_editable_3d_polygon_resource);
+
ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "occluder", PROPERTY_HINT_RESOURCE_TYPE, "Occluder3D"), "set_occluder", "get_occluder");
ADD_GROUP("Bake", "bake_");
ADD_PROPERTY(PropertyInfo(Variant::INT, "bake_mask", PROPERTY_HINT_LAYERS_3D_RENDER), "set_bake_mask", "get_bake_mask");
+ ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "bake_simplification_distance", PROPERTY_HINT_RANGE, "0.0,2.0,0.01"), "set_bake_simplification_distance", "get_bake_simplification_distance");
}
OccluderInstance3D::OccluderInstance3D() {
diff --git a/scene/3d/occluder_instance_3d.h b/scene/3d/occluder_instance_3d.h
index 8a8d4c9af4..669ddba775 100644
--- a/scene/3d/occluder_instance_3d.h
+++ b/scene/3d/occluder_instance_3d.h
@@ -37,24 +37,23 @@ class Occluder3D : public Resource {
GDCLASS(Occluder3D, Resource);
RES_BASE_EXTENSION("occ");
- mutable RID occluder;
- mutable Ref<ArrayMesh> debug_mesh;
- mutable Vector<Vector3> debug_lines;
- AABB aabb;
-
+ RID occluder;
PackedVector3Array vertices;
PackedInt32Array indices;
+ AABB aabb;
- void _update_changes();
+ mutable Ref<ArrayMesh> debug_mesh;
+ mutable Vector<Vector3> debug_lines;
protected:
+ void _update();
+ virtual void _update_arrays(PackedVector3Array &r_vertices, PackedInt32Array &r_indices) = 0;
+
static void _bind_methods();
+ void _notification(int p_what);
public:
- void set_vertices(PackedVector3Array p_vertices);
PackedVector3Array get_vertices() const;
-
- void set_indices(PackedInt32Array p_indices);
PackedInt32Array get_indices() const;
Vector<Vector3> get_debug_lines() const;
@@ -63,7 +62,102 @@ public:
virtual RID get_rid() const override;
Occluder3D();
- ~Occluder3D();
+ virtual ~Occluder3D();
+};
+
+class ArrayOccluder3D : public Occluder3D {
+ GDCLASS(ArrayOccluder3D, Occluder3D);
+
+ PackedVector3Array vertices;
+ PackedInt32Array indices;
+
+protected:
+ virtual void _update_arrays(PackedVector3Array &r_vertices, PackedInt32Array &r_indices) override;
+ static void _bind_methods();
+
+public:
+ void set_arrays(PackedVector3Array p_vertices, PackedInt32Array p_indices);
+ void set_vertices(PackedVector3Array p_vertices);
+ void set_indices(PackedInt32Array p_indices);
+
+ ArrayOccluder3D();
+ ~ArrayOccluder3D();
+};
+
+class QuadOccluder3D : public Occluder3D {
+ GDCLASS(QuadOccluder3D, Occluder3D);
+
+private:
+ Vector2 size = Vector2(1.0f, 1.0f);
+
+protected:
+ virtual void _update_arrays(PackedVector3Array &r_vertices, PackedInt32Array &r_indices) override;
+ static void _bind_methods();
+
+public:
+ Vector2 get_size() const;
+ void set_size(const Vector2 &p_size);
+
+ QuadOccluder3D();
+ ~QuadOccluder3D();
+};
+
+class BoxOccluder3D : public Occluder3D {
+ GDCLASS(BoxOccluder3D, Occluder3D);
+
+private:
+ Vector3 size = Vector3(1.0f, 1.0f, 1.0f);
+
+protected:
+ virtual void _update_arrays(PackedVector3Array &r_vertices, PackedInt32Array &r_indices) override;
+ static void _bind_methods();
+
+public:
+ Vector3 get_size() const;
+ void set_size(const Vector3 &p_size);
+
+ BoxOccluder3D();
+ ~BoxOccluder3D();
+};
+
+class SphereOccluder3D : public Occluder3D {
+ GDCLASS(SphereOccluder3D, Occluder3D);
+
+private:
+ static constexpr int RINGS = 7;
+ static constexpr int RADIAL_SEGMENTS = 7;
+ float radius = 1.0f;
+
+protected:
+ virtual void _update_arrays(PackedVector3Array &r_vertices, PackedInt32Array &r_indices) override;
+ static void _bind_methods();
+
+public:
+ float get_radius() const;
+ void set_radius(float p_radius);
+
+ SphereOccluder3D();
+ ~SphereOccluder3D();
+};
+
+class PolygonOccluder3D : public Occluder3D {
+ GDCLASS(PolygonOccluder3D, Occluder3D);
+
+private:
+ Vector<Vector2> polygon;
+
+ bool _has_editable_3d_polygon_no_depth() const;
+
+protected:
+ virtual void _update_arrays(PackedVector3Array &r_vertices, PackedInt32Array &r_indices) override;
+ static void _bind_methods();
+
+public:
+ void set_polygon(const Vector<Vector2> &p_polygon);
+ Vector<Vector2> get_polygon() const;
+
+ PolygonOccluder3D();
+ ~PolygonOccluder3D();
};
class OccluderInstance3D : public VisualInstance3D {
@@ -72,12 +166,17 @@ class OccluderInstance3D : public VisualInstance3D {
private:
Ref<Occluder3D> occluder;
uint32_t bake_mask = 0xFFFFFFFF;
+ float bake_simplification_dist = 0.1f;
void _occluder_changed();
- bool _bake_material_check(Ref<Material> p_material);
+ static bool _bake_material_check(Ref<Material> p_material);
+ static void _bake_surface(const Transform3D &p_transform, Array p_surface_arrays, Ref<Material> p_material, float p_simplification_dist, PackedVector3Array &r_vertices, PackedInt32Array &r_indices);
void _bake_node(Node *p_node, PackedVector3Array &r_vertices, PackedInt32Array &r_indices);
+ bool _is_editable_3d_polygon() const;
+ Ref<Resource> _get_editable_3d_polygon_resource() const;
+
protected:
static void _bind_methods();
@@ -88,6 +187,7 @@ public:
BAKE_ERROR_OK,
BAKE_ERROR_NO_SAVE_PATH,
BAKE_ERROR_NO_MESHES,
+ BAKE_ERROR_CANT_SAVE,
};
void set_occluder(const Ref<Occluder3D> &p_occluder);
@@ -99,10 +199,14 @@ public:
void set_bake_mask(uint32_t p_mask);
uint32_t get_bake_mask() const;
+ void set_bake_simplification_distance(float p_dist);
+ float get_bake_simplification_distance() const;
+
void set_bake_mask_value(int p_layer_number, bool p_enable);
bool get_bake_mask_value(int p_layer_number) const;
- BakeError bake(Node *p_from_node, String p_occluder_path = "");
+ BakeError bake_scene(Node *p_from_node, String p_occluder_path = "");
+ static void bake_single_node(const Node3D *p_node, float p_simplification_distance, PackedVector3Array &r_vertices, PackedInt32Array &r_indices);
OccluderInstance3D();
~OccluderInstance3D();
diff --git a/scene/3d/ray_cast_3d.cpp b/scene/3d/ray_cast_3d.cpp
index b71c54dcf9..b251aa38ba 100644
--- a/scene/3d/ray_cast_3d.cpp
+++ b/scene/3d/ray_cast_3d.cpp
@@ -259,6 +259,13 @@ void RayCast3D::remove_exception(const CollisionObject3D *p_node) {
void RayCast3D::clear_exceptions() {
exclude.clear();
+
+ if (exclude_parent_body && is_inside_tree()) {
+ CollisionObject3D *parent = Object::cast_to<CollisionObject3D>(get_parent());
+ if (parent) {
+ exclude.insert(parent->get_rid());
+ }
+ }
}
void RayCast3D::set_collide_with_areas(bool p_enabled) {
diff --git a/scene/gui/box_container.cpp b/scene/gui/box_container.cpp
index 3261fc9d7b..9827bd0cef 100644
--- a/scene/gui/box_container.cpp
+++ b/scene/gui/box_container.cpp
@@ -353,7 +353,7 @@ MarginContainer *VBoxContainer::add_margin_child(const String &p_label, Control
l->set_text(p_label);
add_child(l);
MarginContainer *mc = memnew(MarginContainer);
- mc->add_theme_constant_override(SNAME("margin_left"), 0);
+ mc->add_theme_constant_override("margin_left", 0);
mc->add_child(p_control, true);
add_child(mc);
if (p_expand) {
diff --git a/scene/gui/button.cpp b/scene/gui/button.cpp
index 65bfb463f0..3ed1b873af 100644
--- a/scene/gui/button.cpp
+++ b/scene/gui/button.cpp
@@ -127,7 +127,7 @@ void Button::_notification(int p_what) {
} break;
case DRAW_HOVER_PRESSED: {
// Edge case for CheckButton and CheckBox.
- if (has_theme_stylebox(SNAME("hover_pressed"))) {
+ if (has_theme_stylebox("hover_pressed")) {
if (rtl && has_theme_stylebox(SNAME("hover_pressed_mirrored"))) {
style = get_theme_stylebox(SNAME("hover_pressed_mirrored"));
} else {
diff --git a/scene/gui/color_picker.cpp b/scene/gui/color_picker.cpp
index 4cc8f53837..36ea843d1e 100644
--- a/scene/gui/color_picker.cpp
+++ b/scene/gui/color_picker.cpp
@@ -70,7 +70,7 @@ void ColorPicker::_notification(int p_what) {
w_edit->set_custom_minimum_size(Size2(get_theme_constant(SNAME("h_width")), 0));
wheel_edit->set_custom_minimum_size(Size2(get_theme_constant(SNAME("sv_width")), get_theme_constant(SNAME("sv_height"))));
- wheel_margin->add_theme_constant_override(SNAME("margin_bottom"), 8 * get_theme_default_base_scale());
+ wheel_margin->add_theme_constant_override("margin_bottom", 8 * get_theme_default_base_scale());
for (int i = 0; i < 4; i++) {
labels[i]->set_custom_minimum_size(Size2(get_theme_constant(SNAME("label_width")), 0));
@@ -191,22 +191,22 @@ void ColorPicker::_update_controls() {
if (raw_mode_enabled) {
for (int i = 0; i < 3; i++) {
- scroll[i]->remove_theme_icon_override(SNAME("grabber"));
- scroll[i]->remove_theme_icon_override(SNAME("grabber_highlight"));
- scroll[i]->remove_theme_style_override(SNAME("slider"));
- scroll[i]->remove_theme_style_override(SNAME("grabber_area"));
- scroll[i]->remove_theme_style_override(SNAME("grabber_area_highlight"));
+ scroll[i]->remove_theme_icon_override("grabber");
+ scroll[i]->remove_theme_icon_override("grabber_highlight");
+ scroll[i]->remove_theme_style_override("slider");
+ scroll[i]->remove_theme_style_override("grabber_area");
+ scroll[i]->remove_theme_style_override("grabber_area_highlight");
}
} else {
Ref<StyleBoxEmpty> style_box_empty(memnew(StyleBoxEmpty));
Ref<Texture2D> bar_arrow = get_theme_icon(SNAME("bar_arrow"));
for (int i = 0; i < 4; i++) {
- scroll[i]->add_theme_icon_override(SNAME("grabber"), bar_arrow);
- scroll[i]->add_theme_icon_override(SNAME("grabber_highlight"), bar_arrow);
- scroll[i]->add_theme_style_override(SNAME("slider"), style_box_empty);
- scroll[i]->add_theme_style_override(SNAME("grabber_area"), style_box_empty);
- scroll[i]->add_theme_style_override(SNAME("grabber_area_highlight"), style_box_empty);
+ scroll[i]->add_theme_icon_override("grabber", bar_arrow);
+ scroll[i]->add_theme_icon_override("grabber_highlight", bar_arrow);
+ scroll[i]->add_theme_style_override("slider", style_box_empty);
+ scroll[i]->add_theme_style_override("grabber_area", style_box_empty);
+ scroll[i]->add_theme_style_override("grabber_area_highlight", style_box_empty);
}
}
@@ -1245,7 +1245,7 @@ ColorPicker::ColorPicker() :
circle_mat.instantiate();
circle_mat->set_shader(circle_shader);
- wheel_margin->add_theme_constant_override(SNAME("margin_bottom"), 8);
+ wheel_margin->add_theme_constant_override("margin_bottom", 8);
wheel_edit->add_child(wheel_margin);
wheel_margin->add_child(wheel);
diff --git a/scene/gui/dialogs.cpp b/scene/gui/dialogs.cpp
index 8a89c983c5..1cbe3adb3c 100644
--- a/scene/gui/dialogs.cpp
+++ b/scene/gui/dialogs.cpp
@@ -73,7 +73,7 @@ void AcceptDialog::_notification(int p_what) {
}
} break;
case NOTIFICATION_THEME_CHANGED: {
- bg->add_theme_style_override(SNAME("panel"), bg->get_theme_stylebox(SNAME("panel"), SNAME("AcceptDialog")));
+ bg->add_theme_style_override("panel", bg->get_theme_stylebox(SNAME("panel"), SNAME("AcceptDialog")));
} break;
case NOTIFICATION_EXIT_TREE: {
if (parent_visible) {
diff --git a/scene/gui/file_dialog.cpp b/scene/gui/file_dialog.cpp
index 83dc676c55..dad84461f4 100644
--- a/scene/gui/file_dialog.cpp
+++ b/scene/gui/file_dialog.cpp
@@ -65,30 +65,30 @@ void FileDialog::_theme_changed() {
Color font_focus_color = vbox->get_theme_color(SNAME("font_focus_color"), SNAME("Button"));
Color font_pressed_color = vbox->get_theme_color(SNAME("font_pressed_color"), SNAME("Button"));
- dir_up->add_theme_color_override(SNAME("icon_normal_color"), font_color);
- dir_up->add_theme_color_override(SNAME("icon_hover_color"), font_hover_color);
- dir_up->add_theme_color_override(SNAME("icon_focus_color"), font_focus_color);
- dir_up->add_theme_color_override(SNAME("icon_pressed_color"), font_pressed_color);
-
- dir_prev->add_theme_color_override(SNAME("icon_color_normal"), font_color);
- dir_prev->add_theme_color_override(SNAME("icon_color_hover"), font_hover_color);
- dir_prev->add_theme_color_override(SNAME("icon_focus_color"), font_focus_color);
- dir_prev->add_theme_color_override(SNAME("icon_color_pressed"), font_pressed_color);
-
- dir_next->add_theme_color_override(SNAME("icon_color_normal"), font_color);
- dir_next->add_theme_color_override(SNAME("icon_color_hover"), font_hover_color);
- dir_next->add_theme_color_override(SNAME("icon_focus_color"), font_focus_color);
- dir_next->add_theme_color_override(SNAME("icon_color_pressed"), font_pressed_color);
-
- refresh->add_theme_color_override(SNAME("icon_normal_color"), font_color);
- refresh->add_theme_color_override(SNAME("icon_hover_color"), font_hover_color);
- refresh->add_theme_color_override(SNAME("icon_focus_color"), font_focus_color);
- refresh->add_theme_color_override(SNAME("icon_pressed_color"), font_pressed_color);
-
- show_hidden->add_theme_color_override(SNAME("icon_normal_color"), font_color);
- show_hidden->add_theme_color_override(SNAME("icon_hover_color"), font_hover_color);
- show_hidden->add_theme_color_override(SNAME("icon_focus_color"), font_focus_color);
- show_hidden->add_theme_color_override(SNAME("icon_pressed_color"), font_pressed_color);
+ dir_up->add_theme_color_override("icon_normal_color", font_color);
+ dir_up->add_theme_color_override("icon_hover_color", font_hover_color);
+ dir_up->add_theme_color_override("icon_focus_color", font_focus_color);
+ dir_up->add_theme_color_override("icon_pressed_color", font_pressed_color);
+
+ dir_prev->add_theme_color_override("icon_color_normal", font_color);
+ dir_prev->add_theme_color_override("icon_color_hover", font_hover_color);
+ dir_prev->add_theme_color_override("icon_focus_color", font_focus_color);
+ dir_prev->add_theme_color_override("icon_color_pressed", font_pressed_color);
+
+ dir_next->add_theme_color_override("icon_color_normal", font_color);
+ dir_next->add_theme_color_override("icon_color_hover", font_hover_color);
+ dir_next->add_theme_color_override("icon_focus_color", font_focus_color);
+ dir_next->add_theme_color_override("icon_color_pressed", font_pressed_color);
+
+ refresh->add_theme_color_override("icon_normal_color", font_color);
+ refresh->add_theme_color_override("icon_hover_color", font_hover_color);
+ refresh->add_theme_color_override("icon_focus_color", font_focus_color);
+ refresh->add_theme_color_override("icon_pressed_color", font_pressed_color);
+
+ show_hidden->add_theme_color_override("icon_normal_color", font_color);
+ show_hidden->add_theme_color_override("icon_hover_color", font_hover_color);
+ show_hidden->add_theme_color_override("icon_focus_color", font_focus_color);
+ show_hidden->add_theme_color_override("icon_pressed_color", font_pressed_color);
}
void FileDialog::_notification(int p_what) {
diff --git a/scene/gui/option_button.cpp b/scene/gui/option_button.cpp
index 31f3b306b7..ad2434cd8b 100644
--- a/scene/gui/option_button.cpp
+++ b/scene/gui/option_button.cpp
@@ -118,6 +118,11 @@ void OptionButton::_notification(int p_what) {
bool OptionButton::_set(const StringName &p_name, const Variant &p_value) {
Vector<String> components = String(p_name).split("/", true, 2);
if (components.size() >= 2 && components[0] == "popup") {
+ String property = components[2];
+ if (property != "text" && property != "icon" && property != "id" && property != "disabled" && property != "separator") {
+ return false;
+ }
+
bool valid;
popup->set(String(p_name).trim_prefix("popup/"), p_value, &valid);
@@ -136,6 +141,11 @@ bool OptionButton::_set(const StringName &p_name, const Variant &p_value) {
bool OptionButton::_get(const StringName &p_name, Variant &r_ret) const {
Vector<String> components = String(p_name).split("/", true, 2);
if (components.size() >= 2 && components[0] == "popup") {
+ String property = components[2];
+ if (property != "text" && property != "icon" && property != "id" && property != "disabled" && property != "separator") {
+ return false;
+ }
+
bool valid;
r_ret = popup->get(String(p_name).trim_prefix("popup/"), &valid);
return valid;
@@ -151,14 +161,6 @@ void OptionButton::_get_property_list(List<PropertyInfo> *p_list) const {
pi.usage &= ~(popup->get_item_icon(i).is_null() ? PROPERTY_USAGE_STORAGE : 0);
p_list->push_back(pi);
- pi = PropertyInfo(Variant::INT, vformat("popup/item_%d/checkable", i), PROPERTY_HINT_ENUM, "No,As checkbox,As radio button");
- pi.usage &= ~(!popup->is_item_checkable(i) ? PROPERTY_USAGE_STORAGE : 0);
- p_list->push_back(pi);
-
- pi = PropertyInfo(Variant::BOOL, vformat("popup/item_%d/checked", i));
- pi.usage &= ~(!popup->is_item_checked(i) ? PROPERTY_USAGE_STORAGE : 0);
- p_list->push_back(pi);
-
pi = PropertyInfo(Variant::INT, vformat("popup/item_%d/id", i), PROPERTY_HINT_RANGE, "0,10,1,or_greater");
p_list->push_back(pi);
@@ -186,10 +188,13 @@ void OptionButton::pressed() {
popup->set_size(Size2(size.width, 0));
// If not triggered by the mouse, start the popup with the checked item selected.
- if (popup->get_item_count() > 0 &&
- ((get_action_mode() == ActionMode::ACTION_MODE_BUTTON_PRESS && Input::get_singleton()->is_action_just_pressed("ui_accept")) ||
- (get_action_mode() == ActionMode::ACTION_MODE_BUTTON_RELEASE && Input::get_singleton()->is_action_just_released("ui_accept")))) {
- popup->set_current_index(current > -1 ? current : 0);
+ if (popup->get_item_count() > 0) {
+ if ((get_action_mode() == ActionMode::ACTION_MODE_BUTTON_PRESS && Input::get_singleton()->is_action_just_pressed("ui_accept")) ||
+ (get_action_mode() == ActionMode::ACTION_MODE_BUTTON_RELEASE && Input::get_singleton()->is_action_just_released("ui_accept"))) {
+ popup->set_current_index(current > -1 ? current : 0);
+ } else {
+ popup->scroll_to_item(current > -1 ? current : 0);
+ }
}
popup->popup();
@@ -267,7 +272,20 @@ bool OptionButton::is_item_disabled(int p_idx) const {
void OptionButton::set_item_count(int p_count) {
ERR_FAIL_COND(p_count < 0);
+
+ int count_old = get_item_count();
+ if (p_count == count_old) {
+ return;
+ }
+
popup->set_item_count(p_count);
+
+ if (p_count > count_old) {
+ for (int i = count_old; i < p_count; i++) {
+ popup->set_item_as_radio_checkable(i, true);
+ }
+ }
+
notify_property_list_changed();
}
@@ -297,7 +315,7 @@ void OptionButton::_select(int p_which, bool p_emit) {
current = NONE_SELECTED;
set_text("");
- set_icon(NULL);
+ set_icon(nullptr);
} else {
ERR_FAIL_INDEX(p_which, popup->get_item_count());
diff --git a/scene/gui/popup.cpp b/scene/gui/popup.cpp
index 416d847218..7c03fcbb37 100644
--- a/scene/gui/popup.cpp
+++ b/scene/gui/popup.cpp
@@ -242,9 +242,9 @@ void PopupPanel::_update_child_rects() {
void PopupPanel::_notification(int p_what) {
if (p_what == NOTIFICATION_THEME_CHANGED) {
- panel->add_theme_style_override(SNAME("panel"), get_theme_stylebox(SNAME("panel"), get_class_name()));
+ panel->add_theme_style_override("panel", get_theme_stylebox(SNAME("panel"), get_class_name()));
} else if (p_what == NOTIFICATION_READY || p_what == NOTIFICATION_ENTER_TREE) {
- panel->add_theme_style_override(SNAME("panel"), get_theme_stylebox(SNAME("panel"), get_class_name()));
+ panel->add_theme_style_override("panel", get_theme_stylebox(SNAME("panel"), get_class_name()));
_update_child_rects();
} else if (p_what == NOTIFICATION_WM_SIZE_CHANGED) {
_update_child_rects();
diff --git a/scene/gui/popup_menu.cpp b/scene/gui/popup_menu.cpp
index ca1c8505fe..61a5fb999c 100644
--- a/scene/gui/popup_menu.cpp
+++ b/scene/gui/popup_menu.cpp
@@ -108,7 +108,6 @@ Size2 PopupMenu::_get_contents_minimum_size() const {
int PopupMenu::_get_item_height(int p_item) const {
ERR_FAIL_INDEX_V(p_item, items.size(), 0);
- ERR_FAIL_COND_V(p_item < 0, 0);
int icon_height = items[p_item].get_icon_size().height;
if (items[p_item].checkable_type && !items[p_item].separator) {
@@ -141,23 +140,6 @@ int PopupMenu::_get_items_total_height() const {
return items_total_height - vsep;
}
-void PopupMenu::_scroll_to_item(int p_item) {
- ERR_FAIL_INDEX(p_item, items.size());
- ERR_FAIL_COND(p_item < 0);
-
- // Scroll item into view (upwards)
- if (items[p_item]._ofs_cache < -control->get_position().y) {
- int amnt_over = items[p_item]._ofs_cache + control->get_position().y;
- scroll_container->set_v_scroll(scroll_container->get_v_scroll() + amnt_over);
- }
-
- // Scroll item into view (downwards)
- if (items[p_item]._ofs_cache + items[p_item]._height_cache > -control->get_position().y + scroll_container->get_size().height) {
- int amnt_over = items[p_item]._ofs_cache + items[p_item]._height_cache + control->get_position().y - scroll_container->get_size().height;
- scroll_container->set_v_scroll(scroll_container->get_v_scroll() + amnt_over);
- }
-}
-
int PopupMenu::_get_mouse_over(const Point2 &p_over) const {
if (p_over.x < 0 || p_over.x >= get_size().width) {
return -1;
@@ -276,7 +258,7 @@ void PopupMenu::gui_input(const Ref<InputEvent> &p_event) {
if (!items[i].separator && !items[i].disabled) {
mouse_over = i;
emit_signal(SNAME("id_focused"), i);
- _scroll_to_item(i);
+ scroll_to_item(i);
control->update();
set_input_as_handled();
match_found = true;
@@ -290,7 +272,7 @@ void PopupMenu::gui_input(const Ref<InputEvent> &p_event) {
if (!items[i].separator && !items[i].disabled) {
mouse_over = i;
emit_signal(SNAME("id_focused"), i);
- _scroll_to_item(i);
+ scroll_to_item(i);
control->update();
set_input_as_handled();
break;
@@ -308,7 +290,7 @@ void PopupMenu::gui_input(const Ref<InputEvent> &p_event) {
if (!items[i].separator && !items[i].disabled) {
mouse_over = i;
emit_signal(SNAME("id_focused"), i);
- _scroll_to_item(i);
+ scroll_to_item(i);
control->update();
set_input_as_handled();
match_found = true;
@@ -322,7 +304,7 @@ void PopupMenu::gui_input(const Ref<InputEvent> &p_event) {
if (!items[i].separator && !items[i].disabled) {
mouse_over = i;
emit_signal(SNAME("id_focused"), i);
- _scroll_to_item(i);
+ scroll_to_item(i);
control->update();
set_input_as_handled();
break;
@@ -472,7 +454,7 @@ void PopupMenu::gui_input(const Ref<InputEvent> &p_event) {
if (items[i].text.findn(search_string) == 0) {
mouse_over = i;
emit_signal(SNAME("id_focused"), i);
- _scroll_to_item(i);
+ scroll_to_item(i);
control->update();
set_input_as_handled();
break;
@@ -754,26 +736,7 @@ void PopupMenu::_notification(int p_what) {
}
} break;
case NOTIFICATION_THEME_CHANGED:
- case Control::NOTIFICATION_LAYOUT_DIRECTION_CHANGED: {
- // Pass the layout direction to all submenus.
- for (int i = 0; i < items.size(); i++) {
- if (items[i].submenu.is_empty()) {
- continue;
- }
-
- Node *n = get_node(items[i].submenu);
- if (!n) {
- continue;
- }
-
- PopupMenu *pm = Object::cast_to<PopupMenu>(n);
- if (pm) {
- pm->set_layout_direction(get_layout_direction());
- }
- }
-
- [[fallthrough]];
- }
+ case Control::NOTIFICATION_LAYOUT_DIRECTION_CHANGED:
case NOTIFICATION_TRANSLATION_CHANGED: {
for (int i = 0; i < items.size(); i++) {
items.write[i].xl_text = atr(items[i].text);
@@ -846,10 +809,10 @@ void PopupMenu::_notification(int p_what) {
// Set margin on the margin container
Ref<StyleBox> panel_style = get_theme_stylebox(SNAME("panel"));
- margin_container->add_theme_constant_override(SNAME("margin_top"), panel_style->get_margin(Side::SIDE_TOP));
- margin_container->add_theme_constant_override(SNAME("margin_bottom"), panel_style->get_margin(Side::SIDE_BOTTOM));
- margin_container->add_theme_constant_override(SNAME("margin_left"), panel_style->get_margin(Side::SIDE_LEFT));
- margin_container->add_theme_constant_override(SNAME("margin_right"), panel_style->get_margin(Side::SIDE_RIGHT));
+ 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));
+ margin_container->add_theme_constant_override("margin_right", panel_style->get_margin(Side::SIDE_RIGHT));
}
} break;
}
@@ -862,7 +825,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 = atr(p_label); \
- item.id = p_id == -1 ? items.size() - 1 : p_id; \
+ item.id = p_id == -1 ? items.size() : p_id; \
item.accel = p_accel;
void PopupMenu::add_item(const String &p_label, int p_id, Key p_accel) {
@@ -944,7 +907,7 @@ void PopupMenu::add_multistate_item(const String &p_label, int p_max_states, int
_ref_shortcut(p_shortcut); \
item.text = p_shortcut->get_name(); \
item.xl_text = atr(item.text); \
- item.id = p_id == -1 ? items.size() - 1 : p_id; \
+ item.id = p_id == -1 ? items.size() : p_id; \
item.shortcut = p_shortcut; \
item.shortcut_is_global = p_global;
@@ -1013,7 +976,7 @@ void PopupMenu::add_submenu_item(const String &p_label, const String &p_submenu,
Item item;
item.text = p_label;
item.xl_text = atr(p_label);
- item.id = p_id == -1 ? items.size() - 1 : p_id;
+ item.id = p_id == -1 ? items.size() : p_id;
item.submenu = p_submenu;
items.push_back(item);
_shape_item(items.size() - 1);
@@ -1324,7 +1287,7 @@ bool PopupMenu::is_item_shortcut_disabled(int p_idx) const {
void PopupMenu::set_current_index(int p_idx) {
ERR_FAIL_INDEX(p_idx, items.size());
mouse_over = p_idx;
- _scroll_to_item(mouse_over);
+ scroll_to_item(mouse_over);
control->update();
}
@@ -1352,6 +1315,20 @@ int PopupMenu::get_item_count() const {
return items.size();
}
+void PopupMenu::scroll_to_item(int p_item) {
+ ERR_FAIL_INDEX(p_item, items.size());
+
+ // Scroll item into view (upwards).
+ if (items[p_item]._ofs_cache - scroll_container->get_v_scroll() < -control->get_position().y) {
+ scroll_container->set_v_scroll(items[p_item]._ofs_cache + control->get_position().y);
+ }
+
+ // Scroll item into view (downwards).
+ if (items[p_item]._ofs_cache + items[p_item]._height_cache - scroll_container->get_v_scroll() > -control->get_position().y + scroll_container->get_size().height) {
+ scroll_container->set_v_scroll(items[p_item]._ofs_cache + items[p_item]._height_cache + control->get_position().y);
+ }
+}
+
bool PopupMenu::activate_item_by_event(const Ref<InputEvent> &p_event, bool p_for_global_only) {
Key code = Key::NONE;
Ref<InputEventKey> k = p_event;
@@ -1625,7 +1602,7 @@ bool PopupMenu::_set(const StringName &p_name, const Variant &p_value) {
} else if (property == "id") {
set_item_id(item_index, p_value);
return true;
- } else if (components[1] == "disabled") {
+ } else if (property == "disabled") {
set_item_disabled(item_index, p_value);
return true;
} else if (property == "separator") {
@@ -1698,7 +1675,7 @@ bool PopupMenu::_get(const StringName &p_name, Variant &r_ret) const {
} else if (property == "id") {
r_ret = get_item_id(item_index);
return true;
- } else if (components[1] == "disabled") {
+ } else if (property == "disabled") {
r_ret = is_item_disabled(item_index);
return true;
} else if (property == "separator") {
@@ -1804,6 +1781,8 @@ void PopupMenu::_bind_methods() {
ClassDB::bind_method(D_METHOD("set_item_count", "count"), &PopupMenu::set_item_count);
ClassDB::bind_method(D_METHOD("get_item_count"), &PopupMenu::get_item_count);
+ ClassDB::bind_method(D_METHOD("scroll_to_item", "index"), &PopupMenu::scroll_to_item);
+
ClassDB::bind_method(D_METHOD("remove_item", "index"), &PopupMenu::remove_item);
ClassDB::bind_method(D_METHOD("add_separator", "label", "id"), &PopupMenu::add_separator, DEFVAL(String()), DEFVAL(-1));
diff --git a/scene/gui/popup_menu.h b/scene/gui/popup_menu.h
index 7c2212d82d..5ce55209d4 100644
--- a/scene/gui/popup_menu.h
+++ b/scene/gui/popup_menu.h
@@ -103,7 +103,6 @@ class PopupMenu : public Popup {
int _get_item_height(int p_item) const;
int _get_items_total_height() const;
- void _scroll_to_item(int p_item);
void _shape_item(int p_item);
@@ -218,6 +217,8 @@ public:
void set_item_count(int p_count);
int get_item_count() const;
+ void scroll_to_item(int p_item);
+
bool activate_item_by_event(const Ref<InputEvent> &p_event, bool p_for_global_only = false);
void activate_item(int p_item);
diff --git a/scene/gui/tab_bar.cpp b/scene/gui/tab_bar.cpp
index 5a551ec5a5..b1baacd887 100644
--- a/scene/gui/tab_bar.cpp
+++ b/scene/gui/tab_bar.cpp
@@ -761,6 +761,8 @@ void TabBar::_update_hover() {
return;
}
+ ERR_FAIL_COND(tabs.is_empty());
+
const Point2 &pos = get_local_mouse_position();
// Test hovering to display right or close button.
int hover_now = -1;
@@ -1436,7 +1438,6 @@ void TabBar::_get_property_list(List<PropertyInfo> *p_list) const {
}
void TabBar::_bind_methods() {
- ClassDB::bind_method(D_METHOD("_update_hover"), &TabBar::_update_hover);
ClassDB::bind_method(D_METHOD("set_tab_count", "count"), &TabBar::set_tab_count);
ClassDB::bind_method(D_METHOD("get_tab_count"), &TabBar::get_tab_count);
ClassDB::bind_method(D_METHOD("set_current_tab", "tab_idx"), &TabBar::set_current_tab);
diff --git a/scene/gui/tree.cpp b/scene/gui/tree.cpp
index e2c7597f7e..a36eaaa0ee 100644
--- a/scene/gui/tree.cpp
+++ b/scene/gui/tree.cpp
@@ -905,6 +905,12 @@ String TreeItem::get_button_tooltip(int p_column, int p_idx) const {
return cells[p_column].buttons[p_idx].tooltip;
}
+int TreeItem::get_button_id(int p_column, int p_idx) const {
+ ERR_FAIL_INDEX_V(p_column, cells.size(), -1);
+ ERR_FAIL_INDEX_V(p_idx, cells[p_column].buttons.size(), -1);
+ return cells[p_column].buttons[p_idx].id;
+}
+
void TreeItem::erase_button(int p_column, int p_idx) {
ERR_FAIL_INDEX(p_column, cells.size());
ERR_FAIL_INDEX(p_idx, cells[p_column].buttons.size());
@@ -1283,9 +1289,11 @@ void TreeItem::_bind_methods() {
ClassDB::bind_method(D_METHOD("set_custom_as_button", "column", "enable"), &TreeItem::set_custom_as_button);
ClassDB::bind_method(D_METHOD("is_custom_set_as_button", "column"), &TreeItem::is_custom_set_as_button);
- ClassDB::bind_method(D_METHOD("add_button", "column", "button", "button_idx", "disabled", "tooltip"), &TreeItem::add_button, DEFVAL(-1), DEFVAL(false), DEFVAL(""));
+ ClassDB::bind_method(D_METHOD("add_button", "column", "button", "id", "disabled", "tooltip"), &TreeItem::add_button, DEFVAL(-1), DEFVAL(false), DEFVAL(""));
ClassDB::bind_method(D_METHOD("get_button_count", "column"), &TreeItem::get_button_count);
ClassDB::bind_method(D_METHOD("get_button_tooltip", "column", "button_idx"), &TreeItem::get_button_tooltip);
+ ClassDB::bind_method(D_METHOD("get_button_id", "column", "button_idx"), &TreeItem::get_button_id);
+ ClassDB::bind_method(D_METHOD("get_button_by_id", "column", "id"), &TreeItem::get_button_by_id);
ClassDB::bind_method(D_METHOD("get_button", "column", "button_idx"), &TreeItem::get_button);
ClassDB::bind_method(D_METHOD("set_button", "column", "button_idx", "button"), &TreeItem::set_button);
ClassDB::bind_method(D_METHOD("erase_button", "column", "button_idx"), &TreeItem::erase_button);
@@ -4409,21 +4417,29 @@ Point2 Tree::get_scroll() const {
return ofs;
}
-void Tree::scroll_to_item(TreeItem *p_item) {
+void Tree::scroll_to_item(TreeItem *p_item, bool p_center_on_item) {
if (!is_visible_in_tree()) {
- // hack to work around crash in get_item_rect() if Tree is not in tree.
- return;
+ return; // Hack to work around crash in get_item_rect() if Tree is not in tree.
}
- // make sure the scrollbar min and max are up to date with latest changes.
update_scrollbars();
- const Rect2 r = get_item_rect(p_item);
+ const real_t tree_height = get_size().y;
+ const Rect2 item_rect = get_item_rect(p_item);
+ const real_t item_y = item_rect.position.y;
+ const real_t item_height = item_rect.size.y + cache.vseparation;
- if (r.position.y <= v_scroll->get_value()) {
- v_scroll->set_value(r.position.y);
- } else if (r.position.y + r.size.y + 2 * cache.vseparation > v_scroll->get_value() + get_size().y) {
- v_scroll->set_value(r.position.y + r.size.y + 2 * cache.vseparation - get_size().y);
+ if (p_center_on_item) {
+ v_scroll->set_value(item_y - (tree_height - item_height) / 2.0f);
+ } else {
+ if (item_y < v_scroll->get_value()) {
+ v_scroll->set_value(item_y);
+ } else {
+ const real_t new_position = item_y + item_height - tree_height;
+ if (new_position > v_scroll->get_value()) {
+ v_scroll->set_value(new_position);
+ }
+ }
}
}
@@ -4848,6 +4864,7 @@ void Tree::_bind_methods() {
ClassDB::bind_method(D_METHOD("get_item_at_position", "position"), &Tree::get_item_at_position);
ClassDB::bind_method(D_METHOD("get_column_at_position", "position"), &Tree::get_column_at_position);
ClassDB::bind_method(D_METHOD("get_drop_section_at_position", "position"), &Tree::get_drop_section_at_position);
+ ClassDB::bind_method(D_METHOD("get_button_id_at_position", "position"), &Tree::get_button_id_at_position);
ClassDB::bind_method(D_METHOD("ensure_cursor_is_visible"), &Tree::ensure_cursor_is_visible);
@@ -4868,7 +4885,7 @@ void Tree::_bind_methods() {
ClassDB::bind_method(D_METHOD("get_column_title_language", "column"), &Tree::get_column_title_language);
ClassDB::bind_method(D_METHOD("get_scroll"), &Tree::get_scroll);
- ClassDB::bind_method(D_METHOD("scroll_to_item", "item"), &Tree::scroll_to_item);
+ ClassDB::bind_method(D_METHOD("scroll_to_item", "item", "center_on_item"), &Tree::scroll_to_item, DEFVAL(false));
ClassDB::bind_method(D_METHOD("set_h_scroll_enabled", "h_scroll"), &Tree::set_h_scroll_enabled);
ClassDB::bind_method(D_METHOD("is_h_scroll_enabled"), &Tree::is_h_scroll_enabled);
@@ -4941,7 +4958,7 @@ Tree::Tree() {
add_child(popup_editor, false, INTERNAL_MODE_FRONT);
popup_editor_vb = memnew(VBoxContainer);
popup_editor->add_child(popup_editor_vb);
- popup_editor_vb->add_theme_constant_override(SNAME("separation"), 0);
+ popup_editor_vb->add_theme_constant_override("separation", 0);
popup_editor_vb->set_anchors_and_offsets_preset(PRESET_WIDE);
text_editor = memnew(LineEdit);
popup_editor_vb->add_child(text_editor);
diff --git a/scene/gui/tree.h b/scene/gui/tree.h
index c24763a0e4..dc786de6dc 100644
--- a/scene/gui/tree.h
+++ b/scene/gui/tree.h
@@ -248,6 +248,7 @@ public:
int get_button_count(int p_column) const;
String get_button_tooltip(int p_column, int p_idx) const;
Ref<Texture2D> get_button(int p_column, int p_idx) const;
+ int get_button_id(int p_column, int p_idx) const;
void erase_button(int p_column, int p_idx);
int get_button_by_id(int p_column, int p_id) const;
void set_button(int p_column, int p_idx, const Ref<Texture2D> &p_button);
@@ -682,7 +683,7 @@ public:
TreeItem *get_item_with_text(const String &p_find) const;
Point2 get_scroll() const;
- void scroll_to_item(TreeItem *p_item);
+ void scroll_to_item(TreeItem *p_item, bool p_center_on_item = false);
void set_h_scroll_enabled(bool p_enable);
bool is_h_scroll_enabled() const;
void set_v_scroll_enabled(bool p_enable);
diff --git a/scene/register_scene_types.cpp b/scene/register_scene_types.cpp
index 9ed83eb8c3..87e9bd023b 100644
--- a/scene/register_scene_types.cpp
+++ b/scene/register_scene_types.cpp
@@ -470,7 +470,12 @@ void register_scene_types() {
GDREGISTER_CLASS(XROrigin3D);
GDREGISTER_CLASS(MeshInstance3D);
GDREGISTER_CLASS(OccluderInstance3D);
- GDREGISTER_CLASS(Occluder3D);
+ GDREGISTER_VIRTUAL_CLASS(Occluder3D);
+ GDREGISTER_CLASS(ArrayOccluder3D);
+ GDREGISTER_CLASS(QuadOccluder3D);
+ GDREGISTER_CLASS(BoxOccluder3D);
+ GDREGISTER_CLASS(SphereOccluder3D);
+ GDREGISTER_CLASS(PolygonOccluder3D);
GDREGISTER_VIRTUAL_CLASS(SpriteBase3D);
GDREGISTER_CLASS(Sprite3D);
GDREGISTER_CLASS(AnimatedSprite3D);
diff --git a/scene/resources/default_theme/default_theme.cpp b/scene/resources/default_theme/default_theme.cpp
index c77efcc6db..c92a46a98c 100644
--- a/scene/resources/default_theme/default_theme.cpp
+++ b/scene/resources/default_theme/default_theme.cpp
@@ -139,8 +139,8 @@ void fill_default_theme(Ref<Theme> &theme, const Ref<Font> &default_font, Ref<Te
}
// Panel
- theme->set_stylebox(SNAME("panel"), SNAME("Panel"), make_flat_stylebox(style_normal_color, 0, 0, 0, 0));
- theme->set_stylebox(SNAME("panel_fg"), SNAME("Panel"), make_flat_stylebox(style_normal_color, 0, 0, 0, 0));
+ theme->set_stylebox("panel", "Panel", make_flat_stylebox(style_normal_color, 0, 0, 0, 0));
+ theme->set_stylebox("panel_fg", "Panel", make_flat_stylebox(style_normal_color, 0, 0, 0, 0));
// Button
@@ -152,108 +152,108 @@ void fill_default_theme(Ref<Theme> &theme, const Ref<Font> &default_font, Ref<Te
// Make the focus outline appear to be flush with the buttons it's focusing.
focus->set_expand_margin_size_all(2 * scale);
- theme->set_stylebox(SNAME("normal"), SNAME("Button"), button_normal);
- theme->set_stylebox(SNAME("hover"), SNAME("Button"), button_hover);
- theme->set_stylebox(SNAME("pressed"), SNAME("Button"), button_pressed);
- theme->set_stylebox(SNAME("disabled"), SNAME("Button"), button_disabled);
- theme->set_stylebox(SNAME("focus"), SNAME("Button"), focus);
-
- theme->set_font(SNAME("font"), SNAME("Button"), Ref<Font>());
- theme->set_font_size(SNAME("font_size"), SNAME("Button"), -1);
- theme->set_constant(SNAME("outline_size"), SNAME("Button"), 0 * scale);
-
- theme->set_color(SNAME("font_color"), SNAME("Button"), control_font_color);
- theme->set_color(SNAME("font_pressed_color"), SNAME("Button"), control_font_pressed_color);
- theme->set_color(SNAME("font_hover_color"), SNAME("Button"), control_font_hover_color);
- theme->set_color(SNAME("font_focus_color"), SNAME("Button"), control_font_focus_color);
- theme->set_color(SNAME("font_hover_pressed_color"), SNAME("Button"), control_font_pressed_color);
- theme->set_color(SNAME("font_disabled_color"), SNAME("Button"), control_font_disabled_color);
- theme->set_color(SNAME("font_outline_color"), SNAME("Button"), Color(1, 1, 1));
-
- theme->set_color(SNAME("icon_normal_color"), SNAME("Button"), Color(1, 1, 1, 1));
- theme->set_color(SNAME("icon_pressed_color"), SNAME("Button"), Color(1, 1, 1, 1));
- theme->set_color(SNAME("icon_hover_color"), SNAME("Button"), Color(1, 1, 1, 1));
- theme->set_color(SNAME("icon_hover_pressed_color"), SNAME("Button"), Color(1, 1, 1, 1));
- theme->set_color(SNAME("icon_focus_color"), SNAME("Button"), Color(1, 1, 1, 1));
- theme->set_color(SNAME("icon_disabled_color"), SNAME("Button"), Color(1, 1, 1, 1));
-
- theme->set_constant(SNAME("hseparation"), SNAME("Button"), 2 * scale);
+ theme->set_stylebox("normal", "Button", button_normal);
+ theme->set_stylebox("hover", "Button", button_hover);
+ theme->set_stylebox("pressed", "Button", button_pressed);
+ theme->set_stylebox("disabled", "Button", button_disabled);
+ theme->set_stylebox("focus", "Button", focus);
+
+ theme->set_font("font", "Button", Ref<Font>());
+ theme->set_font_size("font_size", "Button", -1);
+ theme->set_constant("outline_size", "Button", 0 * scale);
+
+ theme->set_color("font_color", "Button", control_font_color);
+ theme->set_color("font_pressed_color", "Button", control_font_pressed_color);
+ theme->set_color("font_hover_color", "Button", control_font_hover_color);
+ theme->set_color("font_focus_color", "Button", control_font_focus_color);
+ theme->set_color("font_hover_pressed_color", "Button", control_font_pressed_color);
+ theme->set_color("font_disabled_color", "Button", control_font_disabled_color);
+ theme->set_color("font_outline_color", "Button", Color(1, 1, 1));
+
+ theme->set_color("icon_normal_color", "Button", Color(1, 1, 1, 1));
+ theme->set_color("icon_pressed_color", "Button", Color(1, 1, 1, 1));
+ theme->set_color("icon_hover_color", "Button", Color(1, 1, 1, 1));
+ theme->set_color("icon_hover_pressed_color", "Button", Color(1, 1, 1, 1));
+ theme->set_color("icon_focus_color", "Button", Color(1, 1, 1, 1));
+ theme->set_color("icon_disabled_color", "Button", Color(1, 1, 1, 0.4));
+
+ theme->set_constant("hseparation", "Button", 2 * scale);
// LinkButton
- theme->set_stylebox(SNAME("focus"), SNAME("LinkButton"), focus);
+ theme->set_stylebox("focus", "LinkButton", focus);
- theme->set_font(SNAME("font"), SNAME("LinkButton"), Ref<Font>());
- theme->set_font_size(SNAME("font_size"), SNAME("LinkButton"), -1);
+ theme->set_font("font", "LinkButton", Ref<Font>());
+ theme->set_font_size("font_size", "LinkButton", -1);
- theme->set_color(SNAME("font_color"), SNAME("LinkButton"), control_font_color);
- theme->set_color(SNAME("font_pressed_color"), SNAME("LinkButton"), control_font_pressed_color);
- theme->set_color(SNAME("font_hover_color"), SNAME("LinkButton"), control_font_hover_color);
- theme->set_color(SNAME("font_focus_color"), SNAME("LinkButton"), control_font_focus_color);
- theme->set_color(SNAME("font_outline_color"), SNAME("LinkButton"), Color(1, 1, 1));
+ theme->set_color("font_color", "LinkButton", control_font_color);
+ theme->set_color("font_pressed_color", "LinkButton", control_font_pressed_color);
+ theme->set_color("font_hover_color", "LinkButton", control_font_hover_color);
+ theme->set_color("font_focus_color", "LinkButton", control_font_focus_color);
+ theme->set_color("font_outline_color", "LinkButton", Color(1, 1, 1));
- theme->set_constant(SNAME("outline_size"), SNAME("LinkButton"), 0);
- theme->set_constant(SNAME("underline_spacing"), SNAME("LinkButton"), 2 * scale);
+ theme->set_constant("outline_size", "LinkButton", 0);
+ theme->set_constant("underline_spacing", "LinkButton", 2 * scale);
// OptionButton
- theme->set_stylebox(SNAME("focus"), SNAME("OptionButton"), focus);
+ theme->set_stylebox("focus", "OptionButton", focus);
Ref<StyleBox> sb_optbutton_normal = make_flat_stylebox(style_normal_color, 2 * default_margin, default_margin, 21, default_margin);
Ref<StyleBox> sb_optbutton_hover = make_flat_stylebox(style_hover_color, 2 * default_margin, default_margin, 21, default_margin);
Ref<StyleBox> sb_optbutton_pressed = make_flat_stylebox(style_pressed_color, 2 * default_margin, default_margin, 21, default_margin);
Ref<StyleBox> sb_optbutton_disabled = make_flat_stylebox(style_disabled_color, 2 * default_margin, default_margin, 21, default_margin);
- theme->set_stylebox(SNAME("normal"), SNAME("OptionButton"), sb_optbutton_normal);
- theme->set_stylebox(SNAME("hover"), SNAME("OptionButton"), sb_optbutton_hover);
- theme->set_stylebox(SNAME("pressed"), SNAME("OptionButton"), sb_optbutton_pressed);
- theme->set_stylebox(SNAME("disabled"), SNAME("OptionButton"), sb_optbutton_disabled);
+ theme->set_stylebox("normal", "OptionButton", sb_optbutton_normal);
+ theme->set_stylebox("hover", "OptionButton", sb_optbutton_hover);
+ theme->set_stylebox("pressed", "OptionButton", sb_optbutton_pressed);
+ theme->set_stylebox("disabled", "OptionButton", sb_optbutton_disabled);
Ref<StyleBox> sb_optbutton_normal_mirrored = make_flat_stylebox(style_normal_color, 21, default_margin, 2 * default_margin, default_margin);
Ref<StyleBox> sb_optbutton_hover_mirrored = make_flat_stylebox(style_hover_color, 21, default_margin, 2 * default_margin, default_margin);
Ref<StyleBox> sb_optbutton_pressed_mirrored = make_flat_stylebox(style_pressed_color, 21, default_margin, 2 * default_margin, default_margin);
Ref<StyleBox> sb_optbutton_disabled_mirrored = make_flat_stylebox(style_disabled_color, 21, default_margin, 2 * default_margin, default_margin);
- theme->set_stylebox(SNAME("normal_mirrored"), SNAME("OptionButton"), sb_optbutton_normal_mirrored);
- theme->set_stylebox(SNAME("hover_mirrored"), SNAME("OptionButton"), sb_optbutton_hover_mirrored);
- theme->set_stylebox(SNAME("pressed_mirrored"), SNAME("OptionButton"), sb_optbutton_pressed_mirrored);
- theme->set_stylebox(SNAME("disabled_mirrored"), SNAME("OptionButton"), sb_optbutton_disabled_mirrored);
+ theme->set_stylebox("normal_mirrored", "OptionButton", sb_optbutton_normal_mirrored);
+ theme->set_stylebox("hover_mirrored", "OptionButton", sb_optbutton_hover_mirrored);
+ theme->set_stylebox("pressed_mirrored", "OptionButton", sb_optbutton_pressed_mirrored);
+ theme->set_stylebox("disabled_mirrored", "OptionButton", sb_optbutton_disabled_mirrored);
- theme->set_icon(SNAME("arrow"), SNAME("OptionButton"), icons["option_button_arrow"]);
+ theme->set_icon("arrow", "OptionButton", icons["option_button_arrow"]);
- theme->set_font(SNAME("font"), SNAME("OptionButton"), Ref<Font>());
- theme->set_font_size(SNAME("font_size"), SNAME("OptionButton"), -1);
+ theme->set_font("font", "OptionButton", Ref<Font>());
+ theme->set_font_size("font_size", "OptionButton", -1);
- theme->set_color(SNAME("font_color"), SNAME("OptionButton"), control_font_color);
- theme->set_color(SNAME("font_pressed_color"), SNAME("OptionButton"), control_font_pressed_color);
- theme->set_color(SNAME("font_hover_color"), SNAME("OptionButton"), control_font_hover_color);
- theme->set_color(SNAME("font_focus_color"), SNAME("OptionButton"), control_font_focus_color);
- theme->set_color(SNAME("font_disabled_color"), SNAME("OptionButton"), control_font_disabled_color);
- theme->set_color(SNAME("font_outline_color"), SNAME("OptionButton"), Color(1, 1, 1));
+ theme->set_color("font_color", "OptionButton", control_font_color);
+ theme->set_color("font_pressed_color", "OptionButton", control_font_pressed_color);
+ theme->set_color("font_hover_color", "OptionButton", control_font_hover_color);
+ theme->set_color("font_focus_color", "OptionButton", control_font_focus_color);
+ theme->set_color("font_disabled_color", "OptionButton", control_font_disabled_color);
+ theme->set_color("font_outline_color", "OptionButton", Color(1, 1, 1));
- theme->set_constant(SNAME("hseparation"), SNAME("OptionButton"), 2 * scale);
- theme->set_constant(SNAME("arrow_margin"), SNAME("OptionButton"), 4 * scale);
- theme->set_constant(SNAME("outline_size"), SNAME("OptionButton"), 0);
+ theme->set_constant("hseparation", "OptionButton", 2 * scale);
+ theme->set_constant("arrow_margin", "OptionButton", 4 * scale);
+ theme->set_constant("outline_size", "OptionButton", 0);
// MenuButton
- theme->set_stylebox(SNAME("normal"), SNAME("MenuButton"), button_normal);
- theme->set_stylebox(SNAME("pressed"), SNAME("MenuButton"), button_pressed);
- theme->set_stylebox(SNAME("hover"), SNAME("MenuButton"), button_hover);
- theme->set_stylebox(SNAME("disabled"), SNAME("MenuButton"), button_disabled);
- theme->set_stylebox(SNAME("focus"), SNAME("MenuButton"), focus);
+ theme->set_stylebox("normal", "MenuButton", button_normal);
+ theme->set_stylebox("pressed", "MenuButton", button_pressed);
+ theme->set_stylebox("hover", "MenuButton", button_hover);
+ theme->set_stylebox("disabled", "MenuButton", button_disabled);
+ theme->set_stylebox("focus", "MenuButton", focus);
- theme->set_font(SNAME("font"), SNAME("MenuButton"), Ref<Font>());
- theme->set_font_size(SNAME("font_size"), SNAME("MenuButton"), -1);
+ theme->set_font("font", "MenuButton", Ref<Font>());
+ theme->set_font_size("font_size", "MenuButton", -1);
- theme->set_color(SNAME("font_color"), SNAME("MenuButton"), control_font_color);
- theme->set_color(SNAME("font_pressed_color"), SNAME("MenuButton"), control_font_pressed_color);
- theme->set_color(SNAME("font_hover_color"), SNAME("MenuButton"), control_font_hover_color);
- theme->set_color(SNAME("font_focus_color"), SNAME("MenuButton"), control_font_focus_color);
- theme->set_color(SNAME("font_disabled_color"), SNAME("MenuButton"), Color(1, 1, 1, 0.3));
- theme->set_color(SNAME("font_outline_color"), SNAME("MenuButton"), Color(1, 1, 1));
+ theme->set_color("font_color", "MenuButton", control_font_color);
+ theme->set_color("font_pressed_color", "MenuButton", control_font_pressed_color);
+ theme->set_color("font_hover_color", "MenuButton", control_font_hover_color);
+ theme->set_color("font_focus_color", "MenuButton", control_font_focus_color);
+ theme->set_color("font_disabled_color", "MenuButton", Color(1, 1, 1, 0.3));
+ theme->set_color("font_outline_color", "MenuButton", Color(1, 1, 1));
- theme->set_constant(SNAME("hseparation"), SNAME("MenuButton"), 3 * scale);
- theme->set_constant(SNAME("outline_size"), SNAME("MenuButton"), 0);
+ theme->set_constant("hseparation", "MenuButton", 3 * scale);
+ theme->set_constant("outline_size", "MenuButton", 0);
// CheckBox
@@ -268,36 +268,36 @@ void fill_default_theme(Ref<Theme> &theme, const Ref<Font> &default_font, Ref<Te
cbx_focus->set_default_margin(SIDE_TOP, 4 * scale);
cbx_focus->set_default_margin(SIDE_BOTTOM, 4 * scale);
- theme->set_stylebox(SNAME("normal"), SNAME("CheckBox"), cbx_empty);
- theme->set_stylebox(SNAME("pressed"), SNAME("CheckBox"), cbx_empty);
- theme->set_stylebox(SNAME("disabled"), SNAME("CheckBox"), cbx_empty);
- theme->set_stylebox(SNAME("hover"), SNAME("CheckBox"), cbx_empty);
- theme->set_stylebox(SNAME("hover_pressed"), SNAME("CheckBox"), cbx_empty);
- theme->set_stylebox(SNAME("focus"), SNAME("CheckBox"), cbx_focus);
-
- theme->set_icon(SNAME("checked"), SNAME("CheckBox"), icons["checked"]);
- theme->set_icon(SNAME("checked_disabled"), SNAME("CheckBox"), icons["checked"]);
- theme->set_icon(SNAME("unchecked"), SNAME("CheckBox"), icons["unchecked"]);
- theme->set_icon(SNAME("unchecked_disabled"), SNAME("CheckBox"), icons["unchecked"]);
- theme->set_icon(SNAME("radio_checked"), SNAME("CheckBox"), icons["radio_checked"]);
- theme->set_icon(SNAME("radio_checked_disabled"), SNAME("CheckBox"), icons["radio_checked"]);
- theme->set_icon(SNAME("radio_unchecked"), SNAME("CheckBox"), icons["radio_unchecked"]);
- theme->set_icon(SNAME("radio_unchecked_disabled"), SNAME("CheckBox"), icons["radio_unchecked"]);
-
- theme->set_font(SNAME("font"), SNAME("CheckBox"), Ref<Font>());
- theme->set_font_size(SNAME("font_size"), SNAME("CheckBox"), -1);
-
- theme->set_color(SNAME("font_color"), SNAME("CheckBox"), control_font_color);
- theme->set_color(SNAME("font_pressed_color"), SNAME("CheckBox"), control_font_pressed_color);
- theme->set_color(SNAME("font_hover_color"), SNAME("CheckBox"), control_font_hover_color);
- theme->set_color(SNAME("font_hover_pressed_color"), SNAME("CheckBox"), control_font_pressed_color);
- theme->set_color(SNAME("font_focus_color"), SNAME("CheckBox"), control_font_focus_color);
- theme->set_color(SNAME("font_disabled_color"), SNAME("CheckBox"), control_font_disabled_color);
- theme->set_color(SNAME("font_outline_color"), SNAME("CheckBox"), Color(1, 1, 1));
-
- theme->set_constant(SNAME("hseparation"), SNAME("CheckBox"), 4 * scale);
- theme->set_constant(SNAME("check_vadjust"), SNAME("CheckBox"), 0 * scale);
- theme->set_constant(SNAME("outline_size"), SNAME("CheckBox"), 0);
+ theme->set_stylebox("normal", "CheckBox", cbx_empty);
+ theme->set_stylebox("pressed", "CheckBox", cbx_empty);
+ theme->set_stylebox("disabled", "CheckBox", cbx_empty);
+ theme->set_stylebox("hover", "CheckBox", cbx_empty);
+ theme->set_stylebox("hover_pressed", "CheckBox", cbx_empty);
+ theme->set_stylebox("focus", "CheckBox", cbx_focus);
+
+ theme->set_icon("checked", "CheckBox", icons["checked"]);
+ theme->set_icon("checked_disabled", "CheckBox", icons["checked"]);
+ theme->set_icon("unchecked", "CheckBox", icons["unchecked"]);
+ theme->set_icon("unchecked_disabled", "CheckBox", icons["unchecked"]);
+ theme->set_icon("radio_checked", "CheckBox", icons["radio_checked"]);
+ theme->set_icon("radio_checked_disabled", "CheckBox", icons["radio_checked"]);
+ theme->set_icon("radio_unchecked", "CheckBox", icons["radio_unchecked"]);
+ theme->set_icon("radio_unchecked_disabled", "CheckBox", icons["radio_unchecked"]);
+
+ theme->set_font("font", "CheckBox", Ref<Font>());
+ theme->set_font_size("font_size", "CheckBox", -1);
+
+ theme->set_color("font_color", "CheckBox", control_font_color);
+ theme->set_color("font_pressed_color", "CheckBox", control_font_pressed_color);
+ theme->set_color("font_hover_color", "CheckBox", control_font_hover_color);
+ theme->set_color("font_hover_pressed_color", "CheckBox", control_font_pressed_color);
+ theme->set_color("font_focus_color", "CheckBox", control_font_focus_color);
+ theme->set_color("font_disabled_color", "CheckBox", control_font_disabled_color);
+ theme->set_color("font_outline_color", "CheckBox", Color(1, 1, 1));
+
+ theme->set_constant("hseparation", "CheckBox", 4 * scale);
+ theme->set_constant("check_vadjust", "CheckBox", 0 * scale);
+ theme->set_constant("outline_size", "CheckBox", 0);
// CheckButton
@@ -307,62 +307,62 @@ void fill_default_theme(Ref<Theme> &theme, const Ref<Font> &default_font, Ref<Te
cb_empty->set_default_margin(SIDE_TOP, 4 * scale);
cb_empty->set_default_margin(SIDE_BOTTOM, 4 * scale);
- theme->set_stylebox(SNAME("normal"), SNAME("CheckButton"), cb_empty);
- theme->set_stylebox(SNAME("pressed"), SNAME("CheckButton"), cb_empty);
- theme->set_stylebox(SNAME("disabled"), SNAME("CheckButton"), cb_empty);
- theme->set_stylebox(SNAME("hover"), SNAME("CheckButton"), cb_empty);
- theme->set_stylebox(SNAME("hover_pressed"), SNAME("CheckButton"), cb_empty);
- theme->set_stylebox(SNAME("focus"), SNAME("CheckButton"), focus);
-
- theme->set_icon(SNAME("on"), SNAME("CheckButton"), icons["toggle_on"]);
- theme->set_icon(SNAME("on_disabled"), SNAME("CheckButton"), icons["toggle_on_disabled"]);
- theme->set_icon(SNAME("off"), SNAME("CheckButton"), icons["toggle_off"]);
- theme->set_icon(SNAME("off_disabled"), SNAME("CheckButton"), icons["toggle_off_disabled"]);
-
- theme->set_icon(SNAME("on_mirrored"), SNAME("CheckButton"), icons["toggle_on_mirrored"]);
- theme->set_icon(SNAME("on_disabled_mirrored"), SNAME("CheckButton"), icons["toggle_on_disabled_mirrored"]);
- theme->set_icon(SNAME("off_mirrored"), SNAME("CheckButton"), icons["toggle_off_mirrored"]);
- theme->set_icon(SNAME("off_disabled_mirrored"), SNAME("CheckButton"), icons["toggle_off_disabled_mirrored"]);
-
- theme->set_font(SNAME("font"), SNAME("CheckButton"), Ref<Font>());
- theme->set_font_size(SNAME("font_size"), SNAME("CheckButton"), -1);
-
- theme->set_color(SNAME("font_color"), SNAME("CheckButton"), control_font_color);
- theme->set_color(SNAME("font_pressed_color"), SNAME("CheckButton"), control_font_pressed_color);
- theme->set_color(SNAME("font_hover_color"), SNAME("CheckButton"), control_font_hover_color);
- theme->set_color(SNAME("font_hover_pressed_color"), SNAME("CheckButton"), control_font_pressed_color);
- theme->set_color(SNAME("font_focus_color"), SNAME("CheckButton"), control_font_focus_color);
- theme->set_color(SNAME("font_disabled_color"), SNAME("CheckButton"), control_font_disabled_color);
- theme->set_color(SNAME("font_outline_color"), SNAME("CheckButton"), Color(1, 1, 1));
-
- theme->set_constant(SNAME("hseparation"), SNAME("CheckButton"), 4 * scale);
- theme->set_constant(SNAME("check_vadjust"), SNAME("CheckButton"), 0 * scale);
- theme->set_constant(SNAME("outline_size"), SNAME("CheckButton"), 0);
+ theme->set_stylebox("normal", "CheckButton", cb_empty);
+ theme->set_stylebox("pressed", "CheckButton", cb_empty);
+ theme->set_stylebox("disabled", "CheckButton", cb_empty);
+ theme->set_stylebox("hover", "CheckButton", cb_empty);
+ theme->set_stylebox("hover_pressed", "CheckButton", cb_empty);
+ theme->set_stylebox("focus", "CheckButton", focus);
+
+ theme->set_icon("on", "CheckButton", icons["toggle_on"]);
+ theme->set_icon("on_disabled", "CheckButton", icons["toggle_on_disabled"]);
+ theme->set_icon("off", "CheckButton", icons["toggle_off"]);
+ theme->set_icon("off_disabled", "CheckButton", icons["toggle_off_disabled"]);
+
+ theme->set_icon("on_mirrored", "CheckButton", icons["toggle_on_mirrored"]);
+ theme->set_icon("on_disabled_mirrored", "CheckButton", icons["toggle_on_disabled_mirrored"]);
+ theme->set_icon("off_mirrored", "CheckButton", icons["toggle_off_mirrored"]);
+ theme->set_icon("off_disabled_mirrored", "CheckButton", icons["toggle_off_disabled_mirrored"]);
+
+ theme->set_font("font", "CheckButton", Ref<Font>());
+ theme->set_font_size("font_size", "CheckButton", -1);
+
+ theme->set_color("font_color", "CheckButton", control_font_color);
+ theme->set_color("font_pressed_color", "CheckButton", control_font_pressed_color);
+ theme->set_color("font_hover_color", "CheckButton", control_font_hover_color);
+ theme->set_color("font_hover_pressed_color", "CheckButton", control_font_pressed_color);
+ theme->set_color("font_focus_color", "CheckButton", control_font_focus_color);
+ theme->set_color("font_disabled_color", "CheckButton", control_font_disabled_color);
+ theme->set_color("font_outline_color", "CheckButton", Color(1, 1, 1));
+
+ theme->set_constant("hseparation", "CheckButton", 4 * scale);
+ theme->set_constant("check_vadjust", "CheckButton", 0 * scale);
+ theme->set_constant("outline_size", "CheckButton", 0);
// Label
- theme->set_stylebox(SNAME("normal"), SNAME("Label"), memnew(StyleBoxEmpty));
- theme->set_font(SNAME("font"), SNAME("Label"), Ref<Font>());
- theme->set_font_size(SNAME("font_size"), SNAME("Label"), -1);
+ theme->set_stylebox("normal", "Label", memnew(StyleBoxEmpty));
+ theme->set_font("font", "Label", Ref<Font>());
+ theme->set_font_size("font_size", "Label", -1);
- theme->set_color(SNAME("font_color"), SNAME("Label"), Color(1, 1, 1));
- theme->set_color(SNAME("font_shadow_color"), SNAME("Label"), Color(0, 0, 0, 0));
- theme->set_color(SNAME("font_outline_color"), SNAME("Label"), Color(1, 1, 1));
+ theme->set_color("font_color", "Label", Color(1, 1, 1));
+ theme->set_color("font_shadow_color", "Label", Color(0, 0, 0, 0));
+ theme->set_color("font_outline_color", "Label", Color(1, 1, 1));
- theme->set_constant(SNAME("shadow_offset_x"), SNAME("Label"), 1 * scale);
- theme->set_constant(SNAME("shadow_offset_y"), SNAME("Label"), 1 * scale);
- theme->set_constant(SNAME("outline_size"), SNAME("Label"), 0);
- theme->set_constant(SNAME("shadow_outline_size"), SNAME("Label"), 1 * scale);
- theme->set_constant(SNAME("line_spacing"), SNAME("Label"), 3 * scale);
+ theme->set_constant("shadow_offset_x", "Label", 1 * scale);
+ theme->set_constant("shadow_offset_y", "Label", 1 * scale);
+ theme->set_constant("outline_size", "Label", 0);
+ theme->set_constant("shadow_outline_size", "Label", 1 * scale);
+ theme->set_constant("line_spacing", "Label", 3 * scale);
- theme->set_type_variation(SNAME("HeaderSmall"), SNAME("Label"));
- theme->set_font_size(SNAME("font_size"), SNAME("HeaderSmall"), default_font_size + 4);
+ theme->set_type_variation("HeaderSmall", "Label");
+ theme->set_font_size("font_size", "HeaderSmall", default_font_size + 4);
- theme->set_type_variation(SNAME("HeaderMedium"), SNAME("Label"));
- theme->set_font_size(SNAME("font_size"), SNAME("HeaderMedium"), default_font_size + 8);
+ theme->set_type_variation("HeaderMedium", "Label");
+ theme->set_font_size("font_size", "HeaderMedium", default_font_size + 8);
- theme->set_type_variation(SNAME("HeaderLarge"), SNAME("Label"));
- theme->set_font_size(SNAME("font_size"), SNAME("HeaderLarge"), default_font_size + 12);
+ theme->set_type_variation("HeaderLarge", "Label");
+ theme->set_font_size("font_size", "HeaderLarge", default_font_size + 12);
// LineEdit
@@ -370,129 +370,129 @@ void fill_default_theme(Ref<Theme> &theme, const Ref<Font> &default_font, Ref<Te
// Add a line at the bottom to make LineEdits distinguishable from Buttons.
style_line_edit->set_border_width(SIDE_BOTTOM, 2);
style_line_edit->set_border_color(style_pressed_color);
- theme->set_stylebox(SNAME("normal"), SNAME("LineEdit"), style_line_edit);
+ theme->set_stylebox("normal", "LineEdit", style_line_edit);
- theme->set_stylebox(SNAME("focus"), SNAME("LineEdit"), focus);
+ theme->set_stylebox("focus", "LineEdit", focus);
Ref<StyleBoxFlat> style_line_edit_read_only = make_flat_stylebox(style_disabled_color);
// Add a line at the bottom to make LineEdits distinguishable from Buttons.
style_line_edit_read_only->set_border_width(SIDE_BOTTOM, 2);
style_line_edit_read_only->set_border_color(style_pressed_color * Color(1, 1, 1, 0.5));
- theme->set_stylebox(SNAME("read_only"), SNAME("LineEdit"), style_line_edit_read_only);
+ theme->set_stylebox("read_only", "LineEdit", style_line_edit_read_only);
- theme->set_font(SNAME("font"), SNAME("LineEdit"), Ref<Font>());
- theme->set_font_size(SNAME("font_size"), SNAME("LineEdit"), -1);
+ theme->set_font("font", "LineEdit", Ref<Font>());
+ theme->set_font_size("font_size", "LineEdit", -1);
- theme->set_color(SNAME("font_color"), SNAME("LineEdit"), control_font_color);
- theme->set_color(SNAME("font_selected_color"), SNAME("LineEdit"), control_font_pressed_color);
- theme->set_color(SNAME("font_uneditable_color"), SNAME("LineEdit"), control_font_disabled_color);
- theme->set_color(SNAME("font_placeholder_color"), SNAME("LineEdit"), control_font_placeholder_color);
- theme->set_color(SNAME("font_outline_color"), SNAME("LineEdit"), Color(1, 1, 1));
- theme->set_color(SNAME("caret_color"), SNAME("LineEdit"), control_font_hover_color);
- theme->set_color(SNAME("selection_color"), SNAME("LineEdit"), control_selection_color);
- theme->set_color(SNAME("clear_button_color"), SNAME("LineEdit"), control_font_color);
- theme->set_color(SNAME("clear_button_color_pressed"), SNAME("LineEdit"), control_font_pressed_color);
+ theme->set_color("font_color", "LineEdit", control_font_color);
+ theme->set_color("font_selected_color", "LineEdit", control_font_pressed_color);
+ theme->set_color("font_uneditable_color", "LineEdit", control_font_disabled_color);
+ theme->set_color("font_placeholder_color", "LineEdit", control_font_placeholder_color);
+ theme->set_color("font_outline_color", "LineEdit", Color(1, 1, 1));
+ theme->set_color("caret_color", "LineEdit", control_font_hover_color);
+ theme->set_color("selection_color", "LineEdit", control_selection_color);
+ theme->set_color("clear_button_color", "LineEdit", control_font_color);
+ theme->set_color("clear_button_color_pressed", "LineEdit", control_font_pressed_color);
- theme->set_constant(SNAME("minimum_character_width"), SNAME("LineEdit"), 4);
- theme->set_constant(SNAME("outline_size"), SNAME("LineEdit"), 0);
- theme->set_constant(SNAME("caret_width"), SNAME("LineEdit"), 1);
+ theme->set_constant("minimum_character_width", "LineEdit", 4);
+ theme->set_constant("outline_size", "LineEdit", 0);
+ theme->set_constant("caret_width", "LineEdit", 1);
- theme->set_icon(SNAME("clear"), SNAME("LineEdit"), icons["line_edit_clear"]);
+ theme->set_icon("clear", "LineEdit", icons["line_edit_clear"]);
// ProgressBar
- theme->set_stylebox(SNAME("bg"), SNAME("ProgressBar"), make_flat_stylebox(style_disabled_color, 2, 2, 2, 2, 6));
- theme->set_stylebox(SNAME("fg"), SNAME("ProgressBar"), make_flat_stylebox(style_progress_color, 2, 2, 2, 2, 6));
+ theme->set_stylebox("bg", "ProgressBar", make_flat_stylebox(style_disabled_color, 2, 2, 2, 2, 6));
+ theme->set_stylebox("fg", "ProgressBar", make_flat_stylebox(style_progress_color, 2, 2, 2, 2, 6));
- theme->set_font(SNAME("font"), SNAME("ProgressBar"), Ref<Font>());
- theme->set_font_size(SNAME("font_size"), SNAME("ProgressBar"), -1);
+ theme->set_font("font", "ProgressBar", Ref<Font>());
+ theme->set_font_size("font_size", "ProgressBar", -1);
- theme->set_color(SNAME("font_color"), SNAME("ProgressBar"), control_font_hover_color);
- theme->set_color(SNAME("font_shadow_color"), SNAME("ProgressBar"), Color(0, 0, 0));
- theme->set_color(SNAME("font_outline_color"), SNAME("ProgressBar"), Color(1, 1, 1));
+ theme->set_color("font_color", "ProgressBar", control_font_hover_color);
+ theme->set_color("font_shadow_color", "ProgressBar", Color(0, 0, 0));
+ theme->set_color("font_outline_color", "ProgressBar", Color(1, 1, 1));
- theme->set_constant(SNAME("outline_size"), SNAME("ProgressBar"), 0);
+ theme->set_constant("outline_size", "ProgressBar", 0);
// TextEdit
- theme->set_stylebox(SNAME("normal"), SNAME("TextEdit"), style_line_edit);
- theme->set_stylebox(SNAME("focus"), SNAME("TextEdit"), focus);
- theme->set_stylebox(SNAME("read_only"), SNAME("TextEdit"), style_line_edit_read_only);
-
- theme->set_icon(SNAME("tab"), SNAME("TextEdit"), icons["text_edit_tab"]);
- theme->set_icon(SNAME("space"), SNAME("TextEdit"), icons["text_edit_space"]);
-
- theme->set_font(SNAME("font"), SNAME("TextEdit"), Ref<Font>());
- theme->set_font_size(SNAME("font_size"), SNAME("TextEdit"), -1);
-
- theme->set_color(SNAME("background_color"), SNAME("TextEdit"), Color(0, 0, 0, 0));
- theme->set_color(SNAME("font_color"), SNAME("TextEdit"), control_font_color);
- theme->set_color(SNAME("font_selected_color"), SNAME("TextEdit"), control_font_pressed_color);
- theme->set_color(SNAME("font_readonly_color"), SNAME("TextEdit"), control_font_disabled_color);
- theme->set_color(SNAME("font_placeholder_color"), SNAME("TextEdit"), control_font_placeholder_color);
- theme->set_color(SNAME("font_outline_color"), SNAME("TextEdit"), Color(1, 1, 1));
- theme->set_color(SNAME("selection_color"), SNAME("TextEdit"), control_selection_color);
- theme->set_color(SNAME("current_line_color"), SNAME("TextEdit"), Color(0.25, 0.25, 0.26, 0.8));
- theme->set_color(SNAME("caret_color"), SNAME("TextEdit"), control_font_color);
- theme->set_color(SNAME("caret_background_color"), SNAME("TextEdit"), Color(0, 0, 0));
- theme->set_color(SNAME("word_highlighted_color"), SNAME("TextEdit"), Color(0.5, 0.5, 0.5, 0.25));
- theme->set_color(SNAME("search_result_color"), SNAME("TextEdit"), Color(0.3, 0.3, 0.3));
- theme->set_color(SNAME("search_result_border_color"), SNAME("TextEdit"), Color(0.3, 0.3, 0.3, 0.4));
-
- theme->set_constant(SNAME("line_spacing"), SNAME("TextEdit"), 4 * scale);
- theme->set_constant(SNAME("outline_size"), SNAME("TextEdit"), 0);
- theme->set_constant(SNAME("caret_width"), SNAME("TextEdit"), 1);
+ theme->set_stylebox("normal", "TextEdit", style_line_edit);
+ theme->set_stylebox("focus", "TextEdit", focus);
+ theme->set_stylebox("read_only", "TextEdit", style_line_edit_read_only);
+
+ theme->set_icon("tab", "TextEdit", icons["text_edit_tab"]);
+ theme->set_icon("space", "TextEdit", icons["text_edit_space"]);
+
+ theme->set_font("font", "TextEdit", Ref<Font>());
+ theme->set_font_size("font_size", "TextEdit", -1);
+
+ theme->set_color("background_color", "TextEdit", Color(0, 0, 0, 0));
+ theme->set_color("font_color", "TextEdit", control_font_color);
+ theme->set_color("font_selected_color", "TextEdit", control_font_pressed_color);
+ theme->set_color("font_readonly_color", "TextEdit", control_font_disabled_color);
+ theme->set_color("font_placeholder_color", "TextEdit", control_font_placeholder_color);
+ theme->set_color("font_outline_color", "TextEdit", Color(1, 1, 1));
+ theme->set_color("selection_color", "TextEdit", control_selection_color);
+ theme->set_color("current_line_color", "TextEdit", Color(0.25, 0.25, 0.26, 0.8));
+ theme->set_color("caret_color", "TextEdit", control_font_color);
+ theme->set_color("caret_background_color", "TextEdit", Color(0, 0, 0));
+ theme->set_color("word_highlighted_color", "TextEdit", Color(0.5, 0.5, 0.5, 0.25));
+ theme->set_color("search_result_color", "TextEdit", Color(0.3, 0.3, 0.3));
+ theme->set_color("search_result_border_color", "TextEdit", Color(0.3, 0.3, 0.3, 0.4));
+
+ theme->set_constant("line_spacing", "TextEdit", 4 * scale);
+ theme->set_constant("outline_size", "TextEdit", 0);
+ theme->set_constant("caret_width", "TextEdit", 1);
// CodeEdit
- theme->set_stylebox(SNAME("normal"), SNAME("CodeEdit"), style_line_edit);
- theme->set_stylebox(SNAME("focus"), SNAME("CodeEdit"), focus);
- theme->set_stylebox(SNAME("read_only"), SNAME("CodeEdit"), style_line_edit_read_only);
- theme->set_stylebox(SNAME("completion"), SNAME("CodeEdit"), make_flat_stylebox(style_normal_color, 0, 0, 0, 0));
-
- theme->set_icon(SNAME("tab"), SNAME("CodeEdit"), icons["text_edit_tab"]);
- theme->set_icon(SNAME("space"), SNAME("CodeEdit"), icons["text_edit_space"]);
- theme->set_icon(SNAME("breakpoint"), SNAME("CodeEdit"), icons["breakpoint"]);
- theme->set_icon(SNAME("bookmark"), SNAME("CodeEdit"), icons["bookmark"]);
- theme->set_icon(SNAME("executing_line"), SNAME("CodeEdit"), icons["arrow_right"]);
- theme->set_icon(SNAME("can_fold"), SNAME("CodeEdit"), icons["arrow_down"]);
- theme->set_icon(SNAME("folded"), SNAME("CodeEdit"), icons["arrow_right"]);
- theme->set_icon(SNAME("folded_eol_icon"), SNAME("CodeEdit"), icons["text_edit_ellipsis"]);
-
- theme->set_font(SNAME("font"), SNAME("CodeEdit"), Ref<Font>());
- theme->set_font_size(SNAME("font_size"), SNAME("CodeEdit"), -1);
-
- theme->set_color(SNAME("background_color"), SNAME("CodeEdit"), Color(0, 0, 0, 0));
- theme->set_color(SNAME("completion_background_color"), SNAME("CodeEdit"), Color(0.17, 0.16, 0.2));
- theme->set_color(SNAME("completion_selected_color"), SNAME("CodeEdit"), Color(0.26, 0.26, 0.27));
- theme->set_color(SNAME("completion_existing_color"), SNAME("CodeEdit"), Color(0.87, 0.87, 0.87, 0.13));
- theme->set_color(SNAME("completion_scroll_color"), SNAME("CodeEdit"), control_font_pressed_color);
- theme->set_color(SNAME("completion_font_color"), SNAME("CodeEdit"), Color(0.67, 0.67, 0.67));
- theme->set_color(SNAME("font_color"), SNAME("CodeEdit"), control_font_color);
- theme->set_color(SNAME("font_selected_color"), SNAME("CodeEdit"), Color(0, 0, 0));
- theme->set_color(SNAME("font_readonly_color"), SNAME("CodeEdit"), Color(control_font_color.r, control_font_color.g, control_font_color.b, 0.5f));
- theme->set_color(SNAME("font_placeholder_color"), SNAME("CodeEdit"), control_font_placeholder_color);
- theme->set_color(SNAME("font_outline_color"), SNAME("CodeEdit"), Color(1, 1, 1));
- theme->set_color(SNAME("selection_color"), SNAME("CodeEdit"), control_selection_color);
- theme->set_color(SNAME("bookmark_color"), SNAME("CodeEdit"), Color(0.5, 0.64, 1, 0.8));
- theme->set_color(SNAME("breakpoint_color"), SNAME("CodeEdit"), Color(0.9, 0.29, 0.3));
- theme->set_color(SNAME("executing_line_color"), SNAME("CodeEdit"), Color(0.98, 0.89, 0.27));
- theme->set_color(SNAME("current_line_color"), SNAME("CodeEdit"), Color(0.25, 0.25, 0.26, 0.8));
- theme->set_color(SNAME("code_folding_color"), SNAME("CodeEdit"), Color(0.8, 0.8, 0.8, 0.8));
- theme->set_color(SNAME("caret_color"), SNAME("CodeEdit"), control_font_color);
- theme->set_color(SNAME("caret_background_color"), SNAME("CodeEdit"), Color(0, 0, 0));
- theme->set_color(SNAME("brace_mismatch_color"), SNAME("CodeEdit"), Color(1, 0.2, 0.2));
- theme->set_color(SNAME("line_number_color"), SNAME("CodeEdit"), Color(0.67, 0.67, 0.67, 0.4));
- theme->set_color(SNAME("word_highlighted_color"), SNAME("CodeEdit"), Color(0.8, 0.9, 0.9, 0.15));
- theme->set_color(SNAME("line_length_guideline_color"), SNAME("CodeEdit"), Color(0.3, 0.5, 0.8, 0.1));
- theme->set_color(SNAME("search_result_color"), SNAME("CodeEdit"), Color(0.3, 0.3, 0.3));
- theme->set_color(SNAME("search_result_border_color"), SNAME("CodeEdit"), Color(0.3, 0.3, 0.3, 0.4));
-
- theme->set_constant(SNAME("completion_lines"), SNAME("CodeEdit"), 7);
- theme->set_constant(SNAME("completion_max_width"), SNAME("CodeEdit"), 50);
- theme->set_constant(SNAME("completion_scroll_width"), SNAME("CodeEdit"), 3);
- theme->set_constant(SNAME("line_spacing"), SNAME("CodeEdit"), 4 * scale);
- theme->set_constant(SNAME("outline_size"), SNAME("CodeEdit"), 0);
+ theme->set_stylebox("normal", "CodeEdit", style_line_edit);
+ theme->set_stylebox("focus", "CodeEdit", focus);
+ theme->set_stylebox("read_only", "CodeEdit", style_line_edit_read_only);
+ theme->set_stylebox("completion", "CodeEdit", make_flat_stylebox(style_normal_color, 0, 0, 0, 0));
+
+ theme->set_icon("tab", "CodeEdit", icons["text_edit_tab"]);
+ theme->set_icon("space", "CodeEdit", icons["text_edit_space"]);
+ theme->set_icon("breakpoint", "CodeEdit", icons["breakpoint"]);
+ theme->set_icon("bookmark", "CodeEdit", icons["bookmark"]);
+ theme->set_icon("executing_line", "CodeEdit", icons["arrow_right"]);
+ theme->set_icon("can_fold", "CodeEdit", icons["arrow_down"]);
+ theme->set_icon("folded", "CodeEdit", icons["arrow_right"]);
+ theme->set_icon("folded_eol_icon", "CodeEdit", icons["text_edit_ellipsis"]);
+
+ theme->set_font("font", "CodeEdit", Ref<Font>());
+ theme->set_font_size("font_size", "CodeEdit", -1);
+
+ theme->set_color("background_color", "CodeEdit", Color(0, 0, 0, 0));
+ theme->set_color("completion_background_color", "CodeEdit", Color(0.17, 0.16, 0.2));
+ theme->set_color("completion_selected_color", "CodeEdit", Color(0.26, 0.26, 0.27));
+ theme->set_color("completion_existing_color", "CodeEdit", Color(0.87, 0.87, 0.87, 0.13));
+ theme->set_color("completion_scroll_color", "CodeEdit", control_font_pressed_color);
+ theme->set_color("completion_font_color", "CodeEdit", Color(0.67, 0.67, 0.67));
+ theme->set_color("font_color", "CodeEdit", control_font_color);
+ theme->set_color("font_selected_color", "CodeEdit", Color(0, 0, 0));
+ theme->set_color("font_readonly_color", "CodeEdit", Color(control_font_color.r, control_font_color.g, control_font_color.b, 0.5f));
+ theme->set_color("font_placeholder_color", "CodeEdit", control_font_placeholder_color);
+ theme->set_color("font_outline_color", "CodeEdit", Color(1, 1, 1));
+ theme->set_color("selection_color", "CodeEdit", control_selection_color);
+ theme->set_color("bookmark_color", "CodeEdit", Color(0.5, 0.64, 1, 0.8));
+ theme->set_color("breakpoint_color", "CodeEdit", Color(0.9, 0.29, 0.3));
+ theme->set_color("executing_line_color", "CodeEdit", Color(0.98, 0.89, 0.27));
+ theme->set_color("current_line_color", "CodeEdit", Color(0.25, 0.25, 0.26, 0.8));
+ theme->set_color("code_folding_color", "CodeEdit", Color(0.8, 0.8, 0.8, 0.8));
+ theme->set_color("caret_color", "CodeEdit", control_font_color);
+ theme->set_color("caret_background_color", "CodeEdit", Color(0, 0, 0));
+ theme->set_color("brace_mismatch_color", "CodeEdit", Color(1, 0.2, 0.2));
+ theme->set_color("line_number_color", "CodeEdit", Color(0.67, 0.67, 0.67, 0.4));
+ theme->set_color("word_highlighted_color", "CodeEdit", Color(0.8, 0.9, 0.9, 0.15));
+ theme->set_color("line_length_guideline_color", "CodeEdit", Color(0.3, 0.5, 0.8, 0.1));
+ theme->set_color("search_result_color", "CodeEdit", Color(0.3, 0.3, 0.3));
+ theme->set_color("search_result_border_color", "CodeEdit", Color(0.3, 0.3, 0.3, 0.4));
+
+ theme->set_constant("completion_lines", "CodeEdit", 7);
+ theme->set_constant("completion_max_width", "CodeEdit", 50);
+ theme->set_constant("completion_scroll_width", "CodeEdit", 3);
+ theme->set_constant("line_spacing", "CodeEdit", 4 * scale);
+ theme->set_constant("outline_size", "CodeEdit", 0);
Ref<Texture2D> empty_icon = memnew(ImageTexture);
@@ -503,33 +503,33 @@ void fill_default_theme(Ref<Theme> &theme, const Ref<Font> &default_font, Ref<Te
// HScrollBar
- theme->set_stylebox(SNAME("scroll"), SNAME("HScrollBar"), style_scrollbar);
- theme->set_stylebox(SNAME("scroll_focus"), SNAME("HScrollBar"), focus);
- theme->set_stylebox(SNAME("grabber"), SNAME("HScrollBar"), style_scrollbar_grabber);
- theme->set_stylebox(SNAME("grabber_highlight"), SNAME("HScrollBar"), style_scrollbar_grabber_highlight);
- theme->set_stylebox(SNAME("grabber_pressed"), SNAME("HScrollBar"), style_scrollbar_grabber_pressed);
+ theme->set_stylebox("scroll", "HScrollBar", style_scrollbar);
+ theme->set_stylebox("scroll_focus", "HScrollBar", focus);
+ theme->set_stylebox("grabber", "HScrollBar", style_scrollbar_grabber);
+ theme->set_stylebox("grabber_highlight", "HScrollBar", style_scrollbar_grabber_highlight);
+ theme->set_stylebox("grabber_pressed", "HScrollBar", style_scrollbar_grabber_pressed);
- theme->set_icon(SNAME("increment"), SNAME("HScrollBar"), empty_icon);
- theme->set_icon(SNAME("increment_highlight"), SNAME("HScrollBar"), empty_icon);
- theme->set_icon(SNAME("increment_pressed"), SNAME("HScrollBar"), empty_icon);
- theme->set_icon(SNAME("decrement"), SNAME("HScrollBar"), empty_icon);
- theme->set_icon(SNAME("decrement_highlight"), SNAME("HScrollBar"), empty_icon);
- theme->set_icon(SNAME("decrement_pressed"), SNAME("HScrollBar"), empty_icon);
+ theme->set_icon("increment", "HScrollBar", empty_icon);
+ theme->set_icon("increment_highlight", "HScrollBar", empty_icon);
+ theme->set_icon("increment_pressed", "HScrollBar", empty_icon);
+ theme->set_icon("decrement", "HScrollBar", empty_icon);
+ theme->set_icon("decrement_highlight", "HScrollBar", empty_icon);
+ theme->set_icon("decrement_pressed", "HScrollBar", empty_icon);
// VScrollBar
- theme->set_stylebox(SNAME("scroll"), SNAME("VScrollBar"), style_scrollbar);
- theme->set_stylebox(SNAME("scroll_focus"), SNAME("VScrollBar"), focus);
- theme->set_stylebox(SNAME("grabber"), SNAME("VScrollBar"), style_scrollbar_grabber);
- theme->set_stylebox(SNAME("grabber_highlight"), SNAME("VScrollBar"), style_scrollbar_grabber_highlight);
- theme->set_stylebox(SNAME("grabber_pressed"), SNAME("VScrollBar"), style_scrollbar_grabber_pressed);
+ theme->set_stylebox("scroll", "VScrollBar", style_scrollbar);
+ theme->set_stylebox("scroll_focus", "VScrollBar", focus);
+ theme->set_stylebox("grabber", "VScrollBar", style_scrollbar_grabber);
+ theme->set_stylebox("grabber_highlight", "VScrollBar", style_scrollbar_grabber_highlight);
+ theme->set_stylebox("grabber_pressed", "VScrollBar", style_scrollbar_grabber_pressed);
- theme->set_icon(SNAME("increment"), SNAME("VScrollBar"), empty_icon);
- theme->set_icon(SNAME("increment_highlight"), SNAME("VScrollBar"), empty_icon);
- theme->set_icon(SNAME("increment_pressed"), SNAME("VScrollBar"), empty_icon);
- theme->set_icon(SNAME("decrement"), SNAME("VScrollBar"), empty_icon);
- theme->set_icon(SNAME("decrement_highlight"), SNAME("VScrollBar"), empty_icon);
- theme->set_icon(SNAME("decrement_pressed"), SNAME("VScrollBar"), empty_icon);
+ theme->set_icon("increment", "VScrollBar", empty_icon);
+ theme->set_icon("increment_highlight", "VScrollBar", empty_icon);
+ theme->set_icon("increment_pressed", "VScrollBar", empty_icon);
+ theme->set_icon("decrement", "VScrollBar", empty_icon);
+ theme->set_icon("decrement_highlight", "VScrollBar", empty_icon);
+ theme->set_icon("decrement_pressed", "VScrollBar", empty_icon);
const Ref<StyleBoxFlat> style_slider = make_flat_stylebox(style_normal_color, 4, 4, 4, 4, 4);
const Ref<StyleBoxFlat> style_slider_grabber = make_flat_stylebox(style_progress_color, 4, 4, 4, 4, 4);
@@ -537,83 +537,83 @@ void fill_default_theme(Ref<Theme> &theme, const Ref<Font> &default_font, Ref<Te
// HSlider
- theme->set_stylebox(SNAME("slider"), SNAME("HSlider"), style_slider);
- theme->set_stylebox(SNAME("grabber_area"), SNAME("HSlider"), style_slider_grabber);
- theme->set_stylebox(SNAME("grabber_area_highlight"), SNAME("HSlider"), style_slider_grabber_highlight);
+ theme->set_stylebox("slider", "HSlider", style_slider);
+ theme->set_stylebox("grabber_area", "HSlider", style_slider_grabber);
+ theme->set_stylebox("grabber_area_highlight", "HSlider", style_slider_grabber_highlight);
- theme->set_icon(SNAME("grabber"), SNAME("HSlider"), icons["slider_grabber"]);
- theme->set_icon(SNAME("grabber_highlight"), SNAME("HSlider"), icons["slider_grabber_hl"]);
- theme->set_icon(SNAME("grabber_disabled"), SNAME("HSlider"), icons["slider_grabber_disabled"]);
- theme->set_icon(SNAME("tick"), SNAME("HSlider"), icons["hslider_tick"]);
+ theme->set_icon("grabber", "HSlider", icons["slider_grabber"]);
+ theme->set_icon("grabber_highlight", "HSlider", icons["slider_grabber_hl"]);
+ theme->set_icon("grabber_disabled", "HSlider", icons["slider_grabber_disabled"]);
+ theme->set_icon("tick", "HSlider", icons["hslider_tick"]);
// VSlider
- theme->set_stylebox(SNAME("slider"), SNAME("VSlider"), style_slider);
- theme->set_stylebox(SNAME("grabber_area"), SNAME("VSlider"), style_slider_grabber);
- theme->set_stylebox(SNAME("grabber_area_highlight"), SNAME("VSlider"), style_slider_grabber_highlight);
+ theme->set_stylebox("slider", "VSlider", style_slider);
+ theme->set_stylebox("grabber_area", "VSlider", style_slider_grabber);
+ theme->set_stylebox("grabber_area_highlight", "VSlider", style_slider_grabber_highlight);
- theme->set_icon(SNAME("grabber"), SNAME("VSlider"), icons["slider_grabber"]);
- theme->set_icon(SNAME("grabber_highlight"), SNAME("VSlider"), icons["slider_grabber_hl"]);
- theme->set_icon(SNAME("grabber_disabled"), SNAME("VSlider"), icons["slider_grabber_disabled"]);
- theme->set_icon(SNAME("tick"), SNAME("VSlider"), icons["vslider_tick"]);
+ theme->set_icon("grabber", "VSlider", icons["slider_grabber"]);
+ theme->set_icon("grabber_highlight", "VSlider", icons["slider_grabber_hl"]);
+ theme->set_icon("grabber_disabled", "VSlider", icons["slider_grabber_disabled"]);
+ theme->set_icon("tick", "VSlider", icons["vslider_tick"]);
// SpinBox
- theme->set_icon(SNAME("updown"), SNAME("SpinBox"), icons["updown"]);
+ theme->set_icon("updown", "SpinBox", icons["updown"]);
// ScrollContainer
Ref<StyleBoxEmpty> empty;
empty.instantiate();
- theme->set_stylebox(SNAME("bg"), SNAME("ScrollContainer"), empty);
+ theme->set_stylebox("bg", "ScrollContainer", empty);
// Window
- theme->set_stylebox(SNAME("embedded_border"), SNAME("Window"), sb_expand(make_flat_stylebox(style_popup_color, 10, 28, 10, 8), 8, 32, 8, 6));
- theme->set_constant(SNAME("scaleborder_size"), SNAME("Window"), 4 * scale);
+ theme->set_stylebox("embedded_border", "Window", sb_expand(make_flat_stylebox(style_popup_color, 10, 28, 10, 8), 8, 32, 8, 6));
+ theme->set_constant("scaleborder_size", "Window", 4 * scale);
- theme->set_font(SNAME("title_font"), SNAME("Window"), Ref<Font>());
- theme->set_font_size(SNAME("title_font_size"), SNAME("Window"), -1);
- theme->set_color(SNAME("title_color"), SNAME("Window"), control_font_color);
- theme->set_color(SNAME("title_outline_modulate"), SNAME("Window"), Color(1, 1, 1));
- theme->set_constant(SNAME("title_outline_size"), SNAME("Window"), 0);
- theme->set_constant(SNAME("title_height"), SNAME("Window"), 36 * scale);
- theme->set_constant(SNAME("resize_margin"), SNAME("Window"), 4 * scale);
+ theme->set_font("title_font", "Window", Ref<Font>());
+ theme->set_font_size("title_font_size", "Window", -1);
+ theme->set_color("title_color", "Window", control_font_color);
+ theme->set_color("title_outline_modulate", "Window", Color(1, 1, 1));
+ theme->set_constant("title_outline_size", "Window", 0);
+ theme->set_constant("title_height", "Window", 36 * scale);
+ theme->set_constant("resize_margin", "Window", 4 * scale);
- theme->set_icon(SNAME("close"), SNAME("Window"), icons["close"]);
- theme->set_icon(SNAME("close_pressed"), SNAME("Window"), icons["close_hl"]);
- theme->set_constant(SNAME("close_h_ofs"), SNAME("Window"), 18 * scale);
- theme->set_constant(SNAME("close_v_ofs"), SNAME("Window"), 24 * scale);
+ theme->set_icon("close", "Window", icons["close"]);
+ theme->set_icon("close_pressed", "Window", icons["close_hl"]);
+ theme->set_constant("close_h_ofs", "Window", 18 * scale);
+ theme->set_constant("close_v_ofs", "Window", 24 * scale);
// Dialogs
- theme->set_constant(SNAME("margin"), SNAME("Dialogs"), 8 * scale);
- theme->set_constant(SNAME("button_margin"), SNAME("Dialogs"), 32 * scale);
+ theme->set_constant("margin", "Dialogs", 8 * scale);
+ theme->set_constant("button_margin", "Dialogs", 32 * scale);
// AcceptDialog
- theme->set_stylebox(SNAME("panel"), SNAME("AcceptDialog"), make_flat_stylebox(style_popup_color, 0, 0, 0, 0));
+ theme->set_stylebox("panel", "AcceptDialog", make_flat_stylebox(style_popup_color, 0, 0, 0, 0));
// File Dialog
- theme->set_icon(SNAME("parent_folder"), SNAME("FileDialog"), icons["folder_up"]);
- theme->set_icon(SNAME("back_folder"), SNAME("FileDialog"), icons["arrow_left"]);
- theme->set_icon(SNAME("forward_folder"), SNAME("FileDialog"), icons["arrow_right"]);
- theme->set_icon(SNAME("reload"), SNAME("FileDialog"), icons["reload"]);
- theme->set_icon(SNAME("toggle_hidden"), SNAME("FileDialog"), icons["visibility_visible"]);
- theme->set_icon(SNAME("folder"), SNAME("FileDialog"), icons["folder"]);
- theme->set_icon(SNAME("file"), SNAME("FileDialog"), icons["file"]);
- theme->set_color(SNAME("folder_icon_modulate"), SNAME("FileDialog"), Color(1, 1, 1));
- theme->set_color(SNAME("file_icon_modulate"), SNAME("FileDialog"), Color(1, 1, 1));
- theme->set_color(SNAME("files_disabled"), SNAME("FileDialog"), Color(0, 0, 0, 0.7));
+ theme->set_icon("parent_folder", "FileDialog", icons["folder_up"]);
+ theme->set_icon("back_folder", "FileDialog", icons["arrow_left"]);
+ theme->set_icon("forward_folder", "FileDialog", icons["arrow_right"]);
+ theme->set_icon("reload", "FileDialog", icons["reload"]);
+ theme->set_icon("toggle_hidden", "FileDialog", icons["visibility_visible"]);
+ theme->set_icon("folder", "FileDialog", icons["folder"]);
+ theme->set_icon("file", "FileDialog", icons["file"]);
+ theme->set_color("folder_icon_modulate", "FileDialog", Color(1, 1, 1));
+ theme->set_color("file_icon_modulate", "FileDialog", Color(1, 1, 1));
+ theme->set_color("files_disabled", "FileDialog", Color(0, 0, 0, 0.7));
// Popup
- theme->set_stylebox(SNAME("panel"), SNAME("PopupPanel"), make_flat_stylebox(style_normal_color));
+ theme->set_stylebox("panel", "PopupPanel", make_flat_stylebox(style_normal_color));
// PopupDialog
- theme->set_stylebox(SNAME("panel"), SNAME("PopupDialog"), make_flat_stylebox(style_normal_color));
+ theme->set_stylebox("panel", "PopupDialog", make_flat_stylebox(style_normal_color));
// PopupMenu
@@ -638,35 +638,35 @@ void fill_default_theme(Ref<Theme> &theme, const Ref<Font> &default_font, Ref<Te
Ref<StyleBoxFlat> style_popup_panel_disabled = style_popup_panel->duplicate();
style_popup_panel_disabled->set_bg_color(style_disabled_color);
- theme->set_stylebox(SNAME("panel"), SNAME("PopupMenu"), style_popup_panel);
- theme->set_stylebox(SNAME("panel_disabled"), SNAME("PopupMenu"), style_popup_panel_disabled);
- theme->set_stylebox(SNAME("hover"), SNAME("PopupMenu"), make_flat_stylebox(style_popup_hover_color));
- theme->set_stylebox(SNAME("separator"), SNAME("PopupMenu"), separator_horizontal);
- theme->set_stylebox(SNAME("labeled_separator_left"), SNAME("PopupMenu"), separator_horizontal);
- theme->set_stylebox(SNAME("labeled_separator_right"), SNAME("PopupMenu"), separator_horizontal);
-
- theme->set_icon(SNAME("checked"), SNAME("PopupMenu"), icons["checked"]);
- theme->set_icon(SNAME("unchecked"), SNAME("PopupMenu"), icons["unchecked"]);
- theme->set_icon(SNAME("radio_checked"), SNAME("PopupMenu"), icons["radio_checked"]);
- theme->set_icon(SNAME("radio_unchecked"), SNAME("PopupMenu"), icons["radio_unchecked"]);
- theme->set_icon(SNAME("submenu"), SNAME("PopupMenu"), icons["arrow_right"]);
- theme->set_icon(SNAME("submenu_mirrored"), SNAME("PopupMenu"), icons["arrow_left"]);
-
- theme->set_font(SNAME("font"), SNAME("PopupMenu"), Ref<Font>());
- theme->set_font_size(SNAME("font_size"), SNAME("PopupMenu"), -1);
-
- theme->set_color(SNAME("font_color"), SNAME("PopupMenu"), control_font_color);
- theme->set_color(SNAME("font_accelerator_color"), SNAME("PopupMenu"), Color(0.7, 0.7, 0.7, 0.8));
- theme->set_color(SNAME("font_disabled_color"), SNAME("PopupMenu"), Color(0.4, 0.4, 0.4, 0.8));
- theme->set_color(SNAME("font_hover_color"), SNAME("PopupMenu"), control_font_color);
- theme->set_color(SNAME("font_separator_color"), SNAME("PopupMenu"), control_font_color);
- theme->set_color(SNAME("font_outline_color"), SNAME("PopupMenu"), Color(1, 1, 1));
-
- theme->set_constant(SNAME("hseparation"), SNAME("PopupMenu"), 4 * scale);
- theme->set_constant(SNAME("vseparation"), SNAME("PopupMenu"), 4 * scale);
- theme->set_constant(SNAME("outline_size"), SNAME("PopupMenu"), 0);
- theme->set_constant(SNAME("item_start_padding"), SNAME("PopupMenu"), 2 * scale);
- theme->set_constant(SNAME("item_end_padding"), SNAME("PopupMenu"), 2 * scale);
+ theme->set_stylebox("panel", "PopupMenu", style_popup_panel);
+ theme->set_stylebox("panel_disabled", "PopupMenu", style_popup_panel_disabled);
+ theme->set_stylebox("hover", "PopupMenu", make_flat_stylebox(style_popup_hover_color));
+ theme->set_stylebox("separator", "PopupMenu", separator_horizontal);
+ theme->set_stylebox("labeled_separator_left", "PopupMenu", separator_horizontal);
+ theme->set_stylebox("labeled_separator_right", "PopupMenu", separator_horizontal);
+
+ theme->set_icon("checked", "PopupMenu", icons["checked"]);
+ theme->set_icon("unchecked", "PopupMenu", icons["unchecked"]);
+ theme->set_icon("radio_checked", "PopupMenu", icons["radio_checked"]);
+ theme->set_icon("radio_unchecked", "PopupMenu", icons["radio_unchecked"]);
+ theme->set_icon("submenu", "PopupMenu", icons["arrow_right"]);
+ theme->set_icon("submenu_mirrored", "PopupMenu", icons["arrow_left"]);
+
+ theme->set_font("font", "PopupMenu", Ref<Font>());
+ theme->set_font_size("font_size", "PopupMenu", -1);
+
+ theme->set_color("font_color", "PopupMenu", control_font_color);
+ theme->set_color("font_accelerator_color", "PopupMenu", Color(0.7, 0.7, 0.7, 0.8));
+ theme->set_color("font_disabled_color", "PopupMenu", Color(0.4, 0.4, 0.4, 0.8));
+ theme->set_color("font_hover_color", "PopupMenu", control_font_color);
+ theme->set_color("font_separator_color", "PopupMenu", control_font_color);
+ theme->set_color("font_outline_color", "PopupMenu", Color(1, 1, 1));
+
+ theme->set_constant("hseparation", "PopupMenu", 4 * scale);
+ theme->set_constant("vseparation", "PopupMenu", 4 * scale);
+ theme->set_constant("outline_size", "PopupMenu", 0);
+ theme->set_constant("item_start_padding", "PopupMenu", 2 * scale);
+ theme->set_constant("item_end_padding", "PopupMenu", 2 * scale);
// GraphNode
Ref<StyleBoxFlat> graphnode_normal = make_flat_stylebox(style_normal_color, 18, 42, 18, 12);
@@ -683,101 +683,101 @@ void fill_default_theme(Ref<Theme> &theme, const Ref<Font> &default_font, Ref<Te
Ref<StyleBoxFlat> graphnode_position = make_flat_stylebox(style_pressed_color, 18, 42, 18, 12, 6, true, 4);
graphnode_position->set_border_color(Color(0.98, 0.89, 0.27));
- theme->set_stylebox(SNAME("frame"), SNAME("GraphNode"), graphnode_normal);
- theme->set_stylebox(SNAME("selectedframe"), SNAME("GraphNode"), graphnode_selected);
- theme->set_stylebox(SNAME("comment"), SNAME("GraphNode"), graphnode_comment_normal);
- theme->set_stylebox(SNAME("commentfocus"), SNAME("GraphNode"), graphnode_comment_selected);
- theme->set_stylebox(SNAME("breakpoint"), SNAME("GraphNode"), graphnode_breakpoint);
- theme->set_stylebox(SNAME("position"), SNAME("GraphNode"), graphnode_position);
-
- theme->set_icon(SNAME("port"), SNAME("GraphNode"), icons["graph_port"]);
- theme->set_icon(SNAME("close"), SNAME("GraphNode"), icons["close"]);
- theme->set_icon(SNAME("resizer"), SNAME("GraphNode"), icons["resizer_se"]);
- theme->set_font(SNAME("title_font"), SNAME("GraphNode"), Ref<Font>());
- theme->set_color(SNAME("title_color"), SNAME("GraphNode"), control_font_color);
- theme->set_color(SNAME("close_color"), SNAME("GraphNode"), control_font_color);
- theme->set_color(SNAME("resizer_color"), SNAME("GraphNode"), control_font_color);
- theme->set_constant(SNAME("separation"), SNAME("GraphNode"), 2 * scale);
- theme->set_constant(SNAME("title_offset"), SNAME("GraphNode"), 26 * scale);
- theme->set_constant(SNAME("close_offset"), SNAME("GraphNode"), 22 * scale);
- theme->set_constant(SNAME("port_offset"), SNAME("GraphNode"), 0);
+ theme->set_stylebox("frame", "GraphNode", graphnode_normal);
+ theme->set_stylebox("selectedframe", "GraphNode", graphnode_selected);
+ theme->set_stylebox("comment", "GraphNode", graphnode_comment_normal);
+ theme->set_stylebox("commentfocus", "GraphNode", graphnode_comment_selected);
+ theme->set_stylebox("breakpoint", "GraphNode", graphnode_breakpoint);
+ theme->set_stylebox("position", "GraphNode", graphnode_position);
+
+ theme->set_icon("port", "GraphNode", icons["graph_port"]);
+ theme->set_icon("close", "GraphNode", icons["close"]);
+ theme->set_icon("resizer", "GraphNode", icons["resizer_se"]);
+ theme->set_font("title_font", "GraphNode", Ref<Font>());
+ theme->set_color("title_color", "GraphNode", control_font_color);
+ theme->set_color("close_color", "GraphNode", control_font_color);
+ theme->set_color("resizer_color", "GraphNode", control_font_color);
+ theme->set_constant("separation", "GraphNode", 2 * scale);
+ theme->set_constant("title_offset", "GraphNode", 26 * scale);
+ theme->set_constant("close_offset", "GraphNode", 22 * scale);
+ theme->set_constant("port_offset", "GraphNode", 0);
// Tree
- theme->set_stylebox(SNAME("bg"), SNAME("Tree"), make_flat_stylebox(style_normal_color, 4, 4, 4, 5));
- theme->set_stylebox(SNAME("bg_focus"), SNAME("Tree"), focus);
- theme->set_stylebox(SNAME("selected"), SNAME("Tree"), make_flat_stylebox(style_selected_color));
- theme->set_stylebox(SNAME("selected_focus"), SNAME("Tree"), make_flat_stylebox(style_selected_color));
- theme->set_stylebox(SNAME("cursor"), SNAME("Tree"), focus);
- theme->set_stylebox(SNAME("cursor_unfocused"), SNAME("Tree"), focus);
- theme->set_stylebox(SNAME("button_pressed"), SNAME("Tree"), button_pressed);
- theme->set_stylebox(SNAME("title_button_normal"), SNAME("Tree"), make_flat_stylebox(style_pressed_color, 4, 4, 4, 4));
- theme->set_stylebox(SNAME("title_button_pressed"), SNAME("Tree"), make_flat_stylebox(style_hover_color, 4, 4, 4, 4));
- theme->set_stylebox(SNAME("title_button_hover"), SNAME("Tree"), make_flat_stylebox(style_normal_color, 4, 4, 4, 4));
- theme->set_stylebox(SNAME("custom_button"), SNAME("Tree"), button_normal);
- theme->set_stylebox(SNAME("custom_button_pressed"), SNAME("Tree"), button_pressed);
- theme->set_stylebox(SNAME("custom_button_hover"), SNAME("Tree"), button_hover);
-
- theme->set_icon(SNAME("checked"), SNAME("Tree"), icons["checked"]);
- theme->set_icon(SNAME("unchecked"), SNAME("Tree"), icons["unchecked"]);
- theme->set_icon(SNAME("indeterminate"), SNAME("Tree"), icons["indeterminate"]);
- theme->set_icon(SNAME("updown"), SNAME("Tree"), icons["updown"]);
- theme->set_icon(SNAME("select_arrow"), SNAME("Tree"), icons["option_button_arrow"]);
- theme->set_icon(SNAME("arrow"), SNAME("Tree"), icons["arrow_down"]);
- theme->set_icon(SNAME("arrow_collapsed"), SNAME("Tree"), icons["arrow_right"]);
- theme->set_icon(SNAME("arrow_collapsed_mirrored"), SNAME("Tree"), icons["arrow_left"]);
-
- theme->set_font(SNAME("title_button_font"), SNAME("Tree"), Ref<Font>());
- theme->set_font(SNAME("font"), SNAME("Tree"), Ref<Font>());
- theme->set_font_size(SNAME("font_size"), SNAME("Tree"), -1);
-
- theme->set_color(SNAME("title_button_color"), SNAME("Tree"), control_font_color);
- theme->set_color(SNAME("font_color"), SNAME("Tree"), control_font_low_color);
- theme->set_color(SNAME("font_selected_color"), SNAME("Tree"), control_font_pressed_color);
- theme->set_color(SNAME("font_outline_color"), SNAME("Tree"), Color(1, 1, 1));
- theme->set_color(SNAME("guide_color"), SNAME("Tree"), Color(0.7, 0.7, 0.7, 0.25));
- theme->set_color(SNAME("drop_position_color"), SNAME("Tree"), Color(1, 0.3, 0.2));
- theme->set_color(SNAME("relationship_line_color"), SNAME("Tree"), Color(0.27, 0.27, 0.27));
- theme->set_color(SNAME("parent_hl_line_color"), SNAME("Tree"), Color(0.27, 0.27, 0.27));
- theme->set_color(SNAME("children_hl_line_color"), SNAME("Tree"), Color(0.27, 0.27, 0.27));
- theme->set_color(SNAME("custom_button_font_highlight"), SNAME("Tree"), control_font_hover_color);
-
- theme->set_constant(SNAME("hseparation"), SNAME("Tree"), 4 * scale);
- theme->set_constant(SNAME("vseparation"), SNAME("Tree"), 4 * scale);
- theme->set_constant(SNAME("item_margin"), SNAME("Tree"), 16 * scale);
- theme->set_constant(SNAME("button_margin"), SNAME("Tree"), 4 * scale);
- theme->set_constant(SNAME("draw_relationship_lines"), SNAME("Tree"), 0);
- theme->set_constant(SNAME("relationship_line_width"), SNAME("Tree"), 1);
- theme->set_constant(SNAME("parent_hl_line_width"), SNAME("Tree"), 1);
- theme->set_constant(SNAME("children_hl_line_width"), SNAME("Tree"), 1);
- theme->set_constant(SNAME("parent_hl_line_margin"), SNAME("Tree"), 0);
- theme->set_constant(SNAME("draw_guides"), SNAME("Tree"), 1);
- theme->set_constant(SNAME("scroll_border"), SNAME("Tree"), 4);
- theme->set_constant(SNAME("scroll_speed"), SNAME("Tree"), 12);
- theme->set_constant(SNAME("outline_size"), SNAME("Tree"), 0);
+ theme->set_stylebox("bg", "Tree", make_flat_stylebox(style_normal_color, 4, 4, 4, 5));
+ theme->set_stylebox("bg_focus", "Tree", focus);
+ theme->set_stylebox("selected", "Tree", make_flat_stylebox(style_selected_color));
+ theme->set_stylebox("selected_focus", "Tree", make_flat_stylebox(style_selected_color));
+ theme->set_stylebox("cursor", "Tree", focus);
+ theme->set_stylebox("cursor_unfocused", "Tree", focus);
+ theme->set_stylebox("button_pressed", "Tree", button_pressed);
+ theme->set_stylebox("title_button_normal", "Tree", make_flat_stylebox(style_pressed_color, 4, 4, 4, 4));
+ theme->set_stylebox("title_button_pressed", "Tree", make_flat_stylebox(style_hover_color, 4, 4, 4, 4));
+ theme->set_stylebox("title_button_hover", "Tree", make_flat_stylebox(style_normal_color, 4, 4, 4, 4));
+ theme->set_stylebox("custom_button", "Tree", button_normal);
+ theme->set_stylebox("custom_button_pressed", "Tree", button_pressed);
+ theme->set_stylebox("custom_button_hover", "Tree", button_hover);
+
+ theme->set_icon("checked", "Tree", icons["checked"]);
+ theme->set_icon("unchecked", "Tree", icons["unchecked"]);
+ theme->set_icon("indeterminate", "Tree", icons["indeterminate"]);
+ theme->set_icon("updown", "Tree", icons["updown"]);
+ theme->set_icon("select_arrow", "Tree", icons["option_button_arrow"]);
+ theme->set_icon("arrow", "Tree", icons["arrow_down"]);
+ theme->set_icon("arrow_collapsed", "Tree", icons["arrow_right"]);
+ theme->set_icon("arrow_collapsed_mirrored", "Tree", icons["arrow_left"]);
+
+ theme->set_font("title_button_font", "Tree", Ref<Font>());
+ theme->set_font("font", "Tree", Ref<Font>());
+ theme->set_font_size("font_size", "Tree", -1);
+
+ theme->set_color("title_button_color", "Tree", control_font_color);
+ theme->set_color("font_color", "Tree", control_font_low_color);
+ theme->set_color("font_selected_color", "Tree", control_font_pressed_color);
+ theme->set_color("font_outline_color", "Tree", Color(1, 1, 1));
+ theme->set_color("guide_color", "Tree", Color(0.7, 0.7, 0.7, 0.25));
+ theme->set_color("drop_position_color", "Tree", Color(1, 0.3, 0.2));
+ theme->set_color("relationship_line_color", "Tree", Color(0.27, 0.27, 0.27));
+ theme->set_color("parent_hl_line_color", "Tree", Color(0.27, 0.27, 0.27));
+ theme->set_color("children_hl_line_color", "Tree", Color(0.27, 0.27, 0.27));
+ theme->set_color("custom_button_font_highlight", "Tree", control_font_hover_color);
+
+ theme->set_constant("hseparation", "Tree", 4 * scale);
+ theme->set_constant("vseparation", "Tree", 4 * scale);
+ theme->set_constant("item_margin", "Tree", 16 * scale);
+ theme->set_constant("button_margin", "Tree", 4 * scale);
+ theme->set_constant("draw_relationship_lines", "Tree", 0);
+ theme->set_constant("relationship_line_width", "Tree", 1);
+ theme->set_constant("parent_hl_line_width", "Tree", 1);
+ theme->set_constant("children_hl_line_width", "Tree", 1);
+ theme->set_constant("parent_hl_line_margin", "Tree", 0);
+ theme->set_constant("draw_guides", "Tree", 1);
+ theme->set_constant("scroll_border", "Tree", 4);
+ theme->set_constant("scroll_speed", "Tree", 12);
+ theme->set_constant("outline_size", "Tree", 0);
// ItemList
- theme->set_stylebox(SNAME("bg"), SNAME("ItemList"), make_flat_stylebox(style_normal_color));
- theme->set_stylebox(SNAME("bg_focus"), SNAME("ItemList"), focus);
- theme->set_constant(SNAME("hseparation"), SNAME("ItemList"), 4);
- theme->set_constant(SNAME("vseparation"), SNAME("ItemList"), 2);
- theme->set_constant(SNAME("icon_margin"), SNAME("ItemList"), 4);
- theme->set_constant(SNAME("line_separation"), SNAME("ItemList"), 2 * scale);
+ theme->set_stylebox("bg", "ItemList", make_flat_stylebox(style_normal_color));
+ theme->set_stylebox("bg_focus", "ItemList", focus);
+ theme->set_constant("hseparation", "ItemList", 4);
+ theme->set_constant("vseparation", "ItemList", 2);
+ theme->set_constant("icon_margin", "ItemList", 4);
+ theme->set_constant("line_separation", "ItemList", 2 * scale);
- theme->set_font(SNAME("font"), SNAME("ItemList"), Ref<Font>());
- theme->set_font_size(SNAME("font_size"), SNAME("ItemList"), -1);
+ theme->set_font("font", "ItemList", Ref<Font>());
+ theme->set_font_size("font_size", "ItemList", -1);
- theme->set_color(SNAME("font_color"), SNAME("ItemList"), control_font_lower_color);
- theme->set_color(SNAME("font_selected_color"), SNAME("ItemList"), control_font_pressed_color);
- theme->set_color(SNAME("font_outline_color"), SNAME("ItemList"), Color(1, 1, 1));
- theme->set_color(SNAME("guide_color"), SNAME("ItemList"), Color(0, 0, 0, 0.1));
- theme->set_stylebox(SNAME("selected"), SNAME("ItemList"), make_flat_stylebox(style_selected_color));
- theme->set_stylebox(SNAME("selected_focus"), SNAME("ItemList"), make_flat_stylebox(style_selected_color));
- theme->set_stylebox(SNAME("cursor"), SNAME("ItemList"), focus);
- theme->set_stylebox(SNAME("cursor_unfocused"), SNAME("ItemList"), focus);
+ theme->set_color("font_color", "ItemList", control_font_lower_color);
+ theme->set_color("font_selected_color", "ItemList", control_font_pressed_color);
+ theme->set_color("font_outline_color", "ItemList", Color(1, 1, 1));
+ theme->set_color("guide_color", "ItemList", Color(0, 0, 0, 0.1));
+ theme->set_stylebox("selected", "ItemList", make_flat_stylebox(style_selected_color));
+ theme->set_stylebox("selected_focus", "ItemList", make_flat_stylebox(style_selected_color));
+ theme->set_stylebox("cursor", "ItemList", focus);
+ theme->set_stylebox("cursor_unfocused", "ItemList", focus);
- theme->set_constant(SNAME("outline_size"), SNAME("ItemList"), 0);
+ theme->set_constant("outline_size", "ItemList", 0);
// TabContainer
@@ -792,105 +792,105 @@ void fill_default_theme(Ref<Theme> &theme, const Ref<Font> &default_font, Ref<Te
Ref<StyleBoxFlat> style_tab_disabled = style_tab_unselected->duplicate();
style_tab_disabled->set_bg_color(style_disabled_color);
- theme->set_stylebox(SNAME("tab_selected"), SNAME("TabContainer"), style_tab_selected);
- theme->set_stylebox(SNAME("tab_unselected"), SNAME("TabContainer"), style_tab_unselected);
- theme->set_stylebox(SNAME("tab_disabled"), SNAME("TabContainer"), style_tab_disabled);
- theme->set_stylebox(SNAME("panel"), SNAME("TabContainer"), make_flat_stylebox(style_normal_color, 0, 0, 0, 0));
+ theme->set_stylebox("tab_selected", "TabContainer", style_tab_selected);
+ theme->set_stylebox("tab_unselected", "TabContainer", style_tab_unselected);
+ theme->set_stylebox("tab_disabled", "TabContainer", style_tab_disabled);
+ theme->set_stylebox("panel", "TabContainer", make_flat_stylebox(style_normal_color, 0, 0, 0, 0));
- theme->set_icon(SNAME("increment"), SNAME("TabContainer"), icons["scroll_button_right"]);
- theme->set_icon(SNAME("increment_highlight"), SNAME("TabContainer"), icons["scroll_button_right_hl"]);
- theme->set_icon(SNAME("decrement"), SNAME("TabContainer"), icons["scroll_button_left"]);
- theme->set_icon(SNAME("decrement_highlight"), SNAME("TabContainer"), icons["scroll_button_left_hl"]);
- theme->set_icon(SNAME("menu"), SNAME("TabContainer"), icons["tabs_menu"]);
- theme->set_icon(SNAME("menu_highlight"), SNAME("TabContainer"), icons["tabs_menu_hl"]);
+ theme->set_icon("increment", "TabContainer", icons["scroll_button_right"]);
+ theme->set_icon("increment_highlight", "TabContainer", icons["scroll_button_right_hl"]);
+ theme->set_icon("decrement", "TabContainer", icons["scroll_button_left"]);
+ theme->set_icon("decrement_highlight", "TabContainer", icons["scroll_button_left_hl"]);
+ theme->set_icon("menu", "TabContainer", icons["tabs_menu"]);
+ theme->set_icon("menu_highlight", "TabContainer", icons["tabs_menu_hl"]);
- theme->set_font(SNAME("font"), SNAME("TabContainer"), Ref<Font>());
- theme->set_font_size(SNAME("font_size"), SNAME("TabContainer"), -1);
+ theme->set_font("font", "TabContainer", Ref<Font>());
+ theme->set_font_size("font_size", "TabContainer", -1);
- theme->set_color(SNAME("font_selected_color"), SNAME("TabContainer"), control_font_hover_color);
- theme->set_color(SNAME("font_unselected_color"), SNAME("TabContainer"), control_font_low_color);
- theme->set_color(SNAME("font_disabled_color"), SNAME("TabContainer"), control_font_disabled_color);
- theme->set_color(SNAME("font_outline_color"), SNAME("TabContainer"), Color(1, 1, 1));
+ theme->set_color("font_selected_color", "TabContainer", control_font_hover_color);
+ theme->set_color("font_unselected_color", "TabContainer", control_font_low_color);
+ theme->set_color("font_disabled_color", "TabContainer", control_font_disabled_color);
+ theme->set_color("font_outline_color", "TabContainer", Color(1, 1, 1));
- theme->set_constant(SNAME("side_margin"), SNAME("TabContainer"), 8 * scale);
- theme->set_constant(SNAME("icon_separation"), SNAME("TabContainer"), 4 * scale);
- theme->set_constant(SNAME("outline_size"), SNAME("TabContainer"), 0);
+ theme->set_constant("side_margin", "TabContainer", 8 * scale);
+ theme->set_constant("icon_separation", "TabContainer", 4 * scale);
+ theme->set_constant("outline_size", "TabContainer", 0);
// TabBar
- theme->set_stylebox(SNAME("tab_selected"), SNAME("TabBar"), style_tab_selected);
- theme->set_stylebox(SNAME("tab_unselected"), SNAME("TabBar"), style_tab_unselected);
- theme->set_stylebox(SNAME("tab_disabled"), SNAME("TabBar"), style_tab_disabled);
- theme->set_stylebox(SNAME("button_pressed"), SNAME("TabBar"), button_pressed);
- theme->set_stylebox(SNAME("button_highlight"), SNAME("TabBar"), button_normal);
+ theme->set_stylebox("tab_selected", "TabBar", style_tab_selected);
+ theme->set_stylebox("tab_unselected", "TabBar", style_tab_unselected);
+ theme->set_stylebox("tab_disabled", "TabBar", style_tab_disabled);
+ theme->set_stylebox("button_pressed", "TabBar", button_pressed);
+ theme->set_stylebox("button_highlight", "TabBar", button_normal);
- theme->set_icon(SNAME("increment"), SNAME("TabBar"), icons["scroll_button_right"]);
- theme->set_icon(SNAME("increment_highlight"), SNAME("TabBar"), icons["scroll_button_right_hl"]);
- theme->set_icon(SNAME("decrement"), SNAME("TabBar"), icons["scroll_button_left"]);
- theme->set_icon(SNAME("decrement_highlight"), SNAME("TabBar"), icons["scroll_button_left_hl"]);
- theme->set_icon(SNAME("close"), SNAME("TabBar"), icons["close"]);
+ theme->set_icon("increment", "TabBar", icons["scroll_button_right"]);
+ theme->set_icon("increment_highlight", "TabBar", icons["scroll_button_right_hl"]);
+ theme->set_icon("decrement", "TabBar", icons["scroll_button_left"]);
+ theme->set_icon("decrement_highlight", "TabBar", icons["scroll_button_left_hl"]);
+ theme->set_icon("close", "TabBar", icons["close"]);
- theme->set_font(SNAME("font"), SNAME("TabBar"), Ref<Font>());
- theme->set_font_size(SNAME("font_size"), SNAME("TabBar"), -1);
+ theme->set_font("font", "TabBar", Ref<Font>());
+ theme->set_font_size("font_size", "TabBar", -1);
- theme->set_color(SNAME("font_selected_color"), SNAME("TabBar"), control_font_hover_color);
- theme->set_color(SNAME("font_unselected_color"), SNAME("TabBar"), control_font_low_color);
- theme->set_color(SNAME("font_disabled_color"), SNAME("TabBar"), control_font_disabled_color);
- theme->set_color(SNAME("font_outline_color"), SNAME("TabBar"), Color(1, 1, 1));
+ theme->set_color("font_selected_color", "TabBar", control_font_hover_color);
+ theme->set_color("font_unselected_color", "TabBar", control_font_low_color);
+ theme->set_color("font_disabled_color", "TabBar", control_font_disabled_color);
+ theme->set_color("font_outline_color", "TabBar", Color(1, 1, 1));
- theme->set_constant(SNAME("hseparation"), SNAME("TabBar"), 4 * scale);
- theme->set_constant(SNAME("outline_size"), SNAME("TabBar"), 0);
+ theme->set_constant("hseparation", "TabBar", 4 * scale);
+ theme->set_constant("outline_size", "TabBar", 0);
// Separators
- theme->set_stylebox(SNAME("separator"), SNAME("HSeparator"), separator_horizontal);
- theme->set_stylebox(SNAME("separator"), SNAME("VSeparator"), separator_vertical);
+ theme->set_stylebox("separator", "HSeparator", separator_horizontal);
+ theme->set_stylebox("separator", "VSeparator", separator_vertical);
- theme->set_icon(SNAME("close"), SNAME("Icons"), icons["close"]);
- theme->set_font(SNAME("normal"), SNAME("Fonts"), Ref<Font>());
- theme->set_font(SNAME("large"), SNAME("Fonts"), Ref<Font>());
+ theme->set_icon("close", "Icons", icons["close"]);
+ theme->set_font("normal", "Fonts", Ref<Font>());
+ theme->set_font("large", "Fonts", Ref<Font>());
- theme->set_constant(SNAME("separation"), SNAME("HSeparator"), 4 * scale);
- theme->set_constant(SNAME("separation"), SNAME("VSeparator"), 4 * scale);
+ theme->set_constant("separation", "HSeparator", 4 * scale);
+ theme->set_constant("separation", "VSeparator", 4 * scale);
// ColorPicker
- theme->set_constant(SNAME("margin"), SNAME("ColorPicker"), 4 * scale);
- theme->set_constant(SNAME("sv_width"), SNAME("ColorPicker"), 256 * scale);
- theme->set_constant(SNAME("sv_height"), SNAME("ColorPicker"), 256 * scale);
- theme->set_constant(SNAME("h_width"), SNAME("ColorPicker"), 30 * scale);
- theme->set_constant(SNAME("label_width"), SNAME("ColorPicker"), 10 * scale);
-
- theme->set_icon(SNAME("screen_picker"), SNAME("ColorPicker"), icons["color_picker_pipette"]);
- theme->set_icon(SNAME("add_preset"), SNAME("ColorPicker"), icons["add"]);
- theme->set_icon(SNAME("color_hue"), SNAME("ColorPicker"), icons["color_picker_hue"]);
- theme->set_icon(SNAME("color_sample"), SNAME("ColorPicker"), icons["color_picker_sample"]);
- theme->set_icon(SNAME("sample_bg"), SNAME("ColorPicker"), icons["mini_checkerboard"]);
- theme->set_icon(SNAME("overbright_indicator"), SNAME("ColorPicker"), icons["color_picker_overbright"]);
- theme->set_icon(SNAME("bar_arrow"), SNAME("ColorPicker"), icons["color_picker_bar_arrow"]);
- theme->set_icon(SNAME("picker_cursor"), SNAME("ColorPicker"), icons["color_picker_cursor"]);
+ theme->set_constant("margin", "ColorPicker", 4 * scale);
+ theme->set_constant("sv_width", "ColorPicker", 256 * scale);
+ theme->set_constant("sv_height", "ColorPicker", 256 * scale);
+ theme->set_constant("h_width", "ColorPicker", 30 * scale);
+ theme->set_constant("label_width", "ColorPicker", 10 * scale);
+
+ theme->set_icon("screen_picker", "ColorPicker", icons["color_picker_pipette"]);
+ theme->set_icon("add_preset", "ColorPicker", icons["add"]);
+ theme->set_icon("color_hue", "ColorPicker", icons["color_picker_hue"]);
+ theme->set_icon("color_sample", "ColorPicker", icons["color_picker_sample"]);
+ theme->set_icon("sample_bg", "ColorPicker", icons["mini_checkerboard"]);
+ theme->set_icon("overbright_indicator", "ColorPicker", icons["color_picker_overbright"]);
+ theme->set_icon("bar_arrow", "ColorPicker", icons["color_picker_bar_arrow"]);
+ theme->set_icon("picker_cursor", "ColorPicker", icons["color_picker_cursor"]);
// ColorPickerButton
- theme->set_icon(SNAME("bg"), SNAME("ColorPickerButton"), icons["mini_checkerboard"]);
- theme->set_stylebox(SNAME("normal"), SNAME("ColorPickerButton"), button_normal);
- theme->set_stylebox(SNAME("pressed"), SNAME("ColorPickerButton"), button_pressed);
- theme->set_stylebox(SNAME("hover"), SNAME("ColorPickerButton"), button_hover);
- theme->set_stylebox(SNAME("disabled"), SNAME("ColorPickerButton"), button_disabled);
- theme->set_stylebox(SNAME("focus"), SNAME("ColorPickerButton"), focus);
+ theme->set_icon("bg", "ColorPickerButton", icons["mini_checkerboard"]);
+ theme->set_stylebox("normal", "ColorPickerButton", button_normal);
+ theme->set_stylebox("pressed", "ColorPickerButton", button_pressed);
+ theme->set_stylebox("hover", "ColorPickerButton", button_hover);
+ theme->set_stylebox("disabled", "ColorPickerButton", button_disabled);
+ theme->set_stylebox("focus", "ColorPickerButton", focus);
- theme->set_font(SNAME("font"), SNAME("ColorPickerButton"), Ref<Font>());
- theme->set_font_size(SNAME("font_size"), SNAME("ColorPickerButton"), -1);
+ theme->set_font("font", "ColorPickerButton", Ref<Font>());
+ theme->set_font_size("font_size", "ColorPickerButton", -1);
- theme->set_color(SNAME("font_color"), SNAME("ColorPickerButton"), Color(1, 1, 1, 1));
- theme->set_color(SNAME("font_pressed_color"), SNAME("ColorPickerButton"), Color(0.8, 0.8, 0.8, 1));
- theme->set_color(SNAME("font_hover_color"), SNAME("ColorPickerButton"), Color(1, 1, 1, 1));
- theme->set_color(SNAME("font_focus_color"), SNAME("ColorPickerButton"), Color(1, 1, 1, 1));
- theme->set_color(SNAME("font_disabled_color"), SNAME("ColorPickerButton"), Color(0.9, 0.9, 0.9, 0.3));
- theme->set_color(SNAME("font_outline_color"), SNAME("ColorPickerButton"), Color(1, 1, 1));
+ theme->set_color("font_color", "ColorPickerButton", Color(1, 1, 1, 1));
+ theme->set_color("font_pressed_color", "ColorPickerButton", Color(0.8, 0.8, 0.8, 1));
+ theme->set_color("font_hover_color", "ColorPickerButton", Color(1, 1, 1, 1));
+ theme->set_color("font_focus_color", "ColorPickerButton", Color(1, 1, 1, 1));
+ theme->set_color("font_disabled_color", "ColorPickerButton", Color(0.9, 0.9, 0.9, 0.3));
+ theme->set_color("font_outline_color", "ColorPickerButton", Color(1, 1, 1));
- theme->set_constant(SNAME("hseparation"), SNAME("ColorPickerButton"), 2 * scale);
- theme->set_constant(SNAME("outline_size"), SNAME("ColorPickerButton"), 0);
+ theme->set_constant("hseparation", "ColorPickerButton", 2 * scale);
+ theme->set_constant("outline_size", "ColorPickerButton", 0);
// ColorPresetButton
@@ -899,118 +899,118 @@ void fill_default_theme(Ref<Theme> &theme, const Ref<Font> &default_font, Ref<Te
preset_sb->set_corner_detail(2);
preset_sb->set_anti_aliased(false);
- theme->set_stylebox(SNAME("preset_fg"), SNAME("ColorPresetButton"), preset_sb);
- theme->set_icon(SNAME("preset_bg"), SNAME("ColorPresetButton"), icons["mini_checkerboard"]);
- theme->set_icon(SNAME("overbright_indicator"), SNAME("ColorPresetButton"), icons["color_picker_overbright"]);
+ theme->set_stylebox("preset_fg", "ColorPresetButton", preset_sb);
+ theme->set_icon("preset_bg", "ColorPresetButton", icons["mini_checkerboard"]);
+ theme->set_icon("overbright_indicator", "ColorPresetButton", icons["color_picker_overbright"]);
// TooltipPanel + TooltipLabel
- theme->set_stylebox(SNAME("panel"), SNAME("TooltipPanel"),
+ theme->set_stylebox("panel", "TooltipPanel",
make_flat_stylebox(Color(0, 0, 0, 0.5), 2 * default_margin, 0.5 * default_margin, 2 * default_margin, 0.5 * default_margin));
- theme->set_font(SNAME("font"), SNAME("TooltipLabel"), Ref<Font>());
- theme->set_font_size(SNAME("font_size"), SNAME("TooltipLabel"), -1);
+ theme->set_font("font", "TooltipLabel", Ref<Font>());
+ theme->set_font_size("font_size", "TooltipLabel", -1);
- theme->set_color(SNAME("font_color"), SNAME("TooltipLabel"), control_font_color);
- theme->set_color(SNAME("font_shadow_color"), SNAME("TooltipLabel"), Color(0, 0, 0, 0));
- theme->set_color(SNAME("font_outline_color"), SNAME("TooltipLabel"), Color(0, 0, 0, 0));
+ theme->set_color("font_color", "TooltipLabel", control_font_color);
+ theme->set_color("font_shadow_color", "TooltipLabel", Color(0, 0, 0, 0));
+ theme->set_color("font_outline_color", "TooltipLabel", Color(0, 0, 0, 0));
- theme->set_constant(SNAME("shadow_offset_x"), SNAME("TooltipLabel"), 1);
- theme->set_constant(SNAME("shadow_offset_y"), SNAME("TooltipLabel"), 1);
- theme->set_constant(SNAME("outline_size"), SNAME("TooltipLabel"), 0);
+ theme->set_constant("shadow_offset_x", "TooltipLabel", 1);
+ theme->set_constant("shadow_offset_y", "TooltipLabel", 1);
+ theme->set_constant("outline_size", "TooltipLabel", 0);
// RichTextLabel
- theme->set_stylebox(SNAME("focus"), SNAME("RichTextLabel"), focus);
- theme->set_stylebox(SNAME("normal"), SNAME("RichTextLabel"), make_empty_stylebox(0, 0, 0, 0));
+ theme->set_stylebox("focus", "RichTextLabel", focus);
+ theme->set_stylebox("normal", "RichTextLabel", make_empty_stylebox(0, 0, 0, 0));
- theme->set_font(SNAME("normal_font"), SNAME("RichTextLabel"), Ref<Font>());
- theme->set_font(SNAME("bold_font"), SNAME("RichTextLabel"), Ref<Font>());
- theme->set_font(SNAME("italics_font"), SNAME("RichTextLabel"), Ref<Font>());
- theme->set_font(SNAME("bold_italics_font"), SNAME("RichTextLabel"), Ref<Font>());
- theme->set_font(SNAME("mono_font"), SNAME("RichTextLabel"), Ref<Font>());
+ theme->set_font("normal_font", "RichTextLabel", Ref<Font>());
+ theme->set_font("bold_font", "RichTextLabel", Ref<Font>());
+ theme->set_font("italics_font", "RichTextLabel", Ref<Font>());
+ theme->set_font("bold_italics_font", "RichTextLabel", Ref<Font>());
+ theme->set_font("mono_font", "RichTextLabel", Ref<Font>());
- theme->set_font_size(SNAME("normal_font_size"), SNAME("RichTextLabel"), -1);
- theme->set_font_size(SNAME("bold_font_size"), SNAME("RichTextLabel"), -1);
- theme->set_font_size(SNAME("italics_font_size"), SNAME("RichTextLabel"), -1);
- theme->set_font_size(SNAME("bold_italics_font_size"), SNAME("RichTextLabel"), -1);
- theme->set_font_size(SNAME("mono_font_size"), SNAME("RichTextLabel"), -1);
+ theme->set_font_size("normal_font_size", "RichTextLabel", -1);
+ theme->set_font_size("bold_font_size", "RichTextLabel", -1);
+ theme->set_font_size("italics_font_size", "RichTextLabel", -1);
+ theme->set_font_size("bold_italics_font_size", "RichTextLabel", -1);
+ theme->set_font_size("mono_font_size", "RichTextLabel", -1);
- theme->set_color(SNAME("default_color"), SNAME("RichTextLabel"), Color(1, 1, 1));
- theme->set_color(SNAME("font_selected_color"), SNAME("RichTextLabel"), Color(0, 0, 0));
- theme->set_color(SNAME("selection_color"), SNAME("RichTextLabel"), Color(0.1, 0.1, 1, 0.8));
+ theme->set_color("default_color", "RichTextLabel", Color(1, 1, 1));
+ theme->set_color("font_selected_color", "RichTextLabel", Color(0, 0, 0));
+ theme->set_color("selection_color", "RichTextLabel", Color(0.1, 0.1, 1, 0.8));
- theme->set_color(SNAME("font_shadow_color"), SNAME("RichTextLabel"), Color(0, 0, 0, 0));
+ theme->set_color("font_shadow_color", "RichTextLabel", Color(0, 0, 0, 0));
- theme->set_color(SNAME("font_outline_color"), SNAME("RichTextLabel"), Color(1, 1, 1));
+ theme->set_color("font_outline_color", "RichTextLabel", Color(1, 1, 1));
- theme->set_constant(SNAME("shadow_offset_x"), SNAME("RichTextLabel"), 1 * scale);
- theme->set_constant(SNAME("shadow_offset_y"), SNAME("RichTextLabel"), 1 * scale);
- theme->set_constant(SNAME("shadow_outline_size"), SNAME("RichTextLabel"), 1 * scale);
+ theme->set_constant("shadow_offset_x", "RichTextLabel", 1 * scale);
+ theme->set_constant("shadow_offset_y", "RichTextLabel", 1 * scale);
+ theme->set_constant("shadow_outline_size", "RichTextLabel", 1 * scale);
- theme->set_constant(SNAME("line_separation"), SNAME("RichTextLabel"), 0 * scale);
- theme->set_constant(SNAME("table_hseparation"), SNAME("RichTextLabel"), 3 * scale);
- theme->set_constant(SNAME("table_vseparation"), SNAME("RichTextLabel"), 3 * scale);
+ theme->set_constant("line_separation", "RichTextLabel", 0 * scale);
+ theme->set_constant("table_hseparation", "RichTextLabel", 3 * scale);
+ theme->set_constant("table_vseparation", "RichTextLabel", 3 * scale);
- theme->set_constant(SNAME("outline_size"), SNAME("RichTextLabel"), 0);
+ theme->set_constant("outline_size", "RichTextLabel", 0);
- theme->set_color(SNAME("table_odd_row_bg"), SNAME("RichTextLabel"), Color(0, 0, 0, 0));
- theme->set_color(SNAME("table_even_row_bg"), SNAME("RichTextLabel"), Color(0, 0, 0, 0));
- theme->set_color(SNAME("table_border"), SNAME("RichTextLabel"), Color(0, 0, 0, 0));
+ theme->set_color("table_odd_row_bg", "RichTextLabel", Color(0, 0, 0, 0));
+ theme->set_color("table_even_row_bg", "RichTextLabel", Color(0, 0, 0, 0));
+ theme->set_color("table_border", "RichTextLabel", Color(0, 0, 0, 0));
// Containers
- theme->set_icon(SNAME("grabber"), SNAME("VSplitContainer"), icons["vsplitter"]);
- theme->set_icon(SNAME("grabber"), SNAME("HSplitContainer"), icons["hsplitter"]);
-
- theme->set_constant(SNAME("separation"), SNAME("HBoxContainer"), 4 * scale);
- theme->set_constant(SNAME("separation"), SNAME("VBoxContainer"), 4 * scale);
- theme->set_constant(SNAME("margin_left"), SNAME("MarginContainer"), 0 * scale);
- theme->set_constant(SNAME("margin_top"), SNAME("MarginContainer"), 0 * scale);
- theme->set_constant(SNAME("margin_right"), SNAME("MarginContainer"), 0 * scale);
- theme->set_constant(SNAME("margin_bottom"), SNAME("MarginContainer"), 0 * scale);
- theme->set_constant(SNAME("hseparation"), SNAME("GridContainer"), 4 * scale);
- theme->set_constant(SNAME("vseparation"), SNAME("GridContainer"), 4 * scale);
- theme->set_constant(SNAME("separation"), SNAME("HSplitContainer"), 12 * scale);
- theme->set_constant(SNAME("separation"), SNAME("VSplitContainer"), 12 * scale);
- theme->set_constant(SNAME("autohide"), SNAME("HSplitContainer"), 1 * scale);
- theme->set_constant(SNAME("autohide"), SNAME("VSplitContainer"), 1 * scale);
- theme->set_constant(SNAME("hseparation"), SNAME("HFlowContainer"), 4 * scale);
- theme->set_constant(SNAME("vseparation"), SNAME("HFlowContainer"), 4 * scale);
- theme->set_constant(SNAME("hseparation"), SNAME("VFlowContainer"), 4 * scale);
- theme->set_constant(SNAME("vseparation"), SNAME("VFlowContainer"), 4 * scale);
-
- theme->set_stylebox(SNAME("panel"), SNAME("PanelContainer"), make_flat_stylebox(style_normal_color, 0, 0, 0, 0));
-
- theme->set_icon(SNAME("minus"), SNAME("GraphEdit"), icons["zoom_less"]);
- theme->set_icon(SNAME("reset"), SNAME("GraphEdit"), icons["zoom_reset"]);
- theme->set_icon(SNAME("more"), SNAME("GraphEdit"), icons["zoom_more"]);
- theme->set_icon(SNAME("snap"), SNAME("GraphEdit"), icons["grid_snap"]);
- theme->set_icon(SNAME("minimap"), SNAME("GraphEdit"), icons["grid_minimap"]);
- theme->set_icon(SNAME("layout"), SNAME("GraphEdit"), icons["grid_layout"]);
- theme->set_stylebox(SNAME("bg"), SNAME("GraphEdit"), make_flat_stylebox(style_normal_color, 4, 4, 4, 5));
- theme->set_color(SNAME("grid_minor"), SNAME("GraphEdit"), Color(1, 1, 1, 0.05));
- theme->set_color(SNAME("grid_major"), SNAME("GraphEdit"), Color(1, 1, 1, 0.2));
- theme->set_color(SNAME("selection_fill"), SNAME("GraphEdit"), Color(1, 1, 1, 0.3));
- theme->set_color(SNAME("selection_stroke"), SNAME("GraphEdit"), Color(1, 1, 1, 0.8));
- theme->set_color(SNAME("activity"), SNAME("GraphEdit"), Color(1, 1, 1));
- theme->set_constant(SNAME("bezier_len_pos"), SNAME("GraphEdit"), 80 * scale);
- theme->set_constant(SNAME("bezier_len_neg"), SNAME("GraphEdit"), 160 * scale);
+ theme->set_icon("grabber", "VSplitContainer", icons["vsplitter"]);
+ theme->set_icon("grabber", "HSplitContainer", icons["hsplitter"]);
+
+ theme->set_constant("separation", "HBoxContainer", 4 * scale);
+ theme->set_constant("separation", "VBoxContainer", 4 * scale);
+ theme->set_constant("margin_left", "MarginContainer", 0 * scale);
+ theme->set_constant("margin_top", "MarginContainer", 0 * scale);
+ theme->set_constant("margin_right", "MarginContainer", 0 * scale);
+ theme->set_constant("margin_bottom", "MarginContainer", 0 * scale);
+ theme->set_constant("hseparation", "GridContainer", 4 * scale);
+ theme->set_constant("vseparation", "GridContainer", 4 * scale);
+ theme->set_constant("separation", "HSplitContainer", 12 * scale);
+ theme->set_constant("separation", "VSplitContainer", 12 * scale);
+ theme->set_constant("autohide", "HSplitContainer", 1 * scale);
+ theme->set_constant("autohide", "VSplitContainer", 1 * scale);
+ theme->set_constant("hseparation", "HFlowContainer", 4 * scale);
+ theme->set_constant("vseparation", "HFlowContainer", 4 * scale);
+ theme->set_constant("hseparation", "VFlowContainer", 4 * scale);
+ theme->set_constant("vseparation", "VFlowContainer", 4 * scale);
+
+ theme->set_stylebox("panel", "PanelContainer", make_flat_stylebox(style_normal_color, 0, 0, 0, 0));
+
+ theme->set_icon("minus", "GraphEdit", icons["zoom_less"]);
+ theme->set_icon("reset", "GraphEdit", icons["zoom_reset"]);
+ theme->set_icon("more", "GraphEdit", icons["zoom_more"]);
+ theme->set_icon("snap", "GraphEdit", icons["grid_snap"]);
+ theme->set_icon("minimap", "GraphEdit", icons["grid_minimap"]);
+ theme->set_icon("layout", "GraphEdit", icons["grid_layout"]);
+ theme->set_stylebox("bg", "GraphEdit", make_flat_stylebox(style_normal_color, 4, 4, 4, 5));
+ theme->set_color("grid_minor", "GraphEdit", Color(1, 1, 1, 0.05));
+ theme->set_color("grid_major", "GraphEdit", Color(1, 1, 1, 0.2));
+ theme->set_color("selection_fill", "GraphEdit", Color(1, 1, 1, 0.3));
+ theme->set_color("selection_stroke", "GraphEdit", Color(1, 1, 1, 0.8));
+ theme->set_color("activity", "GraphEdit", Color(1, 1, 1));
+ theme->set_constant("bezier_len_pos", "GraphEdit", 80 * scale);
+ theme->set_constant("bezier_len_neg", "GraphEdit", 160 * scale);
// Visual Node Ports
- theme->set_constant(SNAME("port_grab_distance_horizontal"), SNAME("GraphEdit"), 24 * scale);
- theme->set_constant(SNAME("port_grab_distance_vertical"), SNAME("GraphEdit"), 26 * scale);
+ theme->set_constant("port_grab_distance_horizontal", "GraphEdit", 24 * scale);
+ theme->set_constant("port_grab_distance_vertical", "GraphEdit", 26 * scale);
- theme->set_stylebox(SNAME("bg"), SNAME("GraphEditMinimap"), make_flat_stylebox(Color(0.24, 0.24, 0.24), 0, 0, 0, 0));
+ theme->set_stylebox("bg", "GraphEditMinimap", make_flat_stylebox(Color(0.24, 0.24, 0.24), 0, 0, 0, 0));
Ref<StyleBoxFlat> style_minimap_camera = make_flat_stylebox(Color(0.65, 0.65, 0.65, 0.2), 0, 0, 0, 0, 0);
style_minimap_camera->set_border_color(Color(0.65, 0.65, 0.65, 0.45));
style_minimap_camera->set_border_width_all(1);
- theme->set_stylebox(SNAME("camera"), SNAME("GraphEditMinimap"), style_minimap_camera);
- theme->set_stylebox(SNAME("node"), SNAME("GraphEditMinimap"), make_flat_stylebox(Color(1, 1, 1), 0, 0, 0, 0, 2));
+ theme->set_stylebox("camera", "GraphEditMinimap", style_minimap_camera);
+ theme->set_stylebox("node", "GraphEditMinimap", make_flat_stylebox(Color(1, 1, 1), 0, 0, 0, 0, 2));
- theme->set_icon(SNAME("resizer"), SNAME("GraphEditMinimap"), icons["resizer_nw"]);
- theme->set_color(SNAME("resizer_color"), SNAME("GraphEditMinimap"), Color(1, 1, 1, 0.85));
+ theme->set_icon("resizer", "GraphEditMinimap", icons["resizer_nw"]);
+ theme->set_color("resizer_color", "GraphEditMinimap", Color(1, 1, 1, 0.85));
// Theme
diff --git a/scene/resources/resource_format_text.cpp b/scene/resources/resource_format_text.cpp
index 6bb710b1d9..c03faa2c2d 100644
--- a/scene/resources/resource_format_text.cpp
+++ b/scene/resources/resource_format_text.cpp
@@ -1951,7 +1951,7 @@ Error ResourceFormatSaverTextInstance::save(const String &p_path, const RES &p_r
}
Error ResourceFormatSaverText::save(const String &p_path, const RES &p_resource, uint32_t p_flags) {
- if (p_path.ends_with(".sct") && p_resource->get_class() != "PackedScene") {
+ if (p_path.ends_with(".tscn") && !Ref<PackedScene>(p_resource).is_valid()) {
return ERR_FILE_UNRECOGNIZED;
}
@@ -1960,14 +1960,14 @@ Error ResourceFormatSaverText::save(const String &p_path, const RES &p_resource,
}
bool ResourceFormatSaverText::recognize(const RES &p_resource) const {
- return true; // all recognized!
+ return true; // All resources recognized!
}
void ResourceFormatSaverText::get_recognized_extensions(const RES &p_resource, List<String> *p_extensions) const {
- if (p_resource->get_class() == "PackedScene") {
- p_extensions->push_back("tscn"); //text scene
+ if (Ref<PackedScene>(p_resource).is_valid()) {
+ p_extensions->push_back("tscn"); // Text scene.
} else {
- p_extensions->push_back("tres"); //text resource
+ p_extensions->push_back("tres"); // Text resource.
}
}
diff --git a/scene/resources/surface_tool.cpp b/scene/resources/surface_tool.cpp
index 0677d9c1a8..52151ae846 100644
--- a/scene/resources/surface_tool.cpp
+++ b/scene/resources/surface_tool.cpp
@@ -37,6 +37,44 @@ SurfaceTool::SimplifyFunc SurfaceTool::simplify_func = nullptr;
SurfaceTool::SimplifyWithAttribFunc SurfaceTool::simplify_with_attrib_func = nullptr;
SurfaceTool::SimplifyScaleFunc SurfaceTool::simplify_scale_func = nullptr;
SurfaceTool::SimplifySloppyFunc SurfaceTool::simplify_sloppy_func = nullptr;
+SurfaceTool::GenerateRemapFunc SurfaceTool::generate_remap_func = nullptr;
+SurfaceTool::RemapVertexFunc SurfaceTool::remap_vertex_func = nullptr;
+SurfaceTool::RemapIndexFunc SurfaceTool::remap_index_func = nullptr;
+
+void SurfaceTool::strip_mesh_arrays(PackedVector3Array &r_vertices, PackedInt32Array &r_indices) {
+ ERR_FAIL_COND_MSG(!generate_remap_func || !remap_vertex_func || !remap_index_func, "Meshoptimizer library is not initialized.");
+
+ Vector<uint32_t> remap;
+ remap.resize(r_vertices.size());
+ uint32_t new_vertex_count = generate_remap_func(remap.ptrw(), (unsigned int *)r_indices.ptr(), r_indices.size(), (float *)r_vertices.ptr(), r_vertices.size(), sizeof(Vector3));
+ remap_vertex_func(r_vertices.ptrw(), r_vertices.ptr(), r_vertices.size(), sizeof(Vector3), remap.ptr());
+ r_vertices.resize(new_vertex_count);
+ remap_index_func((unsigned int *)r_indices.ptrw(), (unsigned int *)r_indices.ptr(), r_indices.size(), remap.ptr());
+
+ HashMap<const int *, bool, TriangleHasher, TriangleHasher> found_triangles;
+ int *idx_ptr = r_indices.ptrw();
+
+ int filtered_indices_count = 0;
+ for (int i = 0; i < r_indices.size() / 3; i++) {
+ const int *tri = idx_ptr + (i * 3);
+
+ if (tri[0] == tri[1] || tri[1] == tri[2] || tri[2] == tri[0]) {
+ continue;
+ }
+
+ if (found_triangles.has(tri)) {
+ continue;
+ }
+
+ if (i != filtered_indices_count) {
+ memcpy(idx_ptr + (filtered_indices_count * 3), tri, sizeof(int) * 3);
+ }
+
+ found_triangles[tri] = true;
+ filtered_indices_count++;
+ }
+ r_indices.resize(filtered_indices_count * 3);
+}
bool SurfaceTool::Vertex::operator==(const Vertex &p_vertex) const {
if (vertex != p_vertex.vertex) {
@@ -107,6 +145,47 @@ uint32_t SurfaceTool::VertexHasher::hash(const Vertex &p_vtx) {
return h;
}
+uint32_t SurfaceTool::TriangleHasher::hash(const int *p_triangle) {
+ int t0 = p_triangle[0];
+ int t1 = p_triangle[1];
+ int t2 = p_triangle[2];
+
+ if (t0 > t1)
+ SWAP(t0, t1);
+ if (t1 > t2)
+ SWAP(t1, t2);
+ if (t0 > t1)
+ SWAP(t0, t1);
+
+ return (t0 * 73856093) ^ (t1 * 19349663) ^ (t2 * 83492791);
+}
+
+bool SurfaceTool::TriangleHasher::compare(const int *p_lhs, const int *p_rhs) {
+ int r0 = p_rhs[0];
+ int r1 = p_rhs[1];
+ int r2 = p_rhs[2];
+
+ if (r0 > r1)
+ SWAP(r0, r1);
+ if (r1 > r2)
+ SWAP(r1, r2);
+ if (r0 > r1)
+ SWAP(r0, r1);
+
+ int l0 = p_lhs[0];
+ int l1 = p_lhs[1];
+ int l2 = p_lhs[2];
+
+ if (l0 > l1)
+ SWAP(l0, l1);
+ if (l1 > l2)
+ SWAP(l1, l2);
+ if (l0 > l1)
+ SWAP(l0, l1);
+
+ return l0 == r0 && l1 == r1 && l2 == r2;
+}
+
void SurfaceTool::begin(Mesh::PrimitiveType p_primitive) {
clear();
diff --git a/scene/resources/surface_tool.h b/scene/resources/surface_tool.h
index 9cb83e0e68..bf4332ad2a 100644
--- a/scene/resources/surface_tool.h
+++ b/scene/resources/surface_tool.h
@@ -84,12 +84,24 @@ public:
static SimplifyScaleFunc simplify_scale_func;
typedef size_t (*SimplifySloppyFunc)(unsigned int *destination, const unsigned int *indices, size_t index_count, const float *vertex_positions_data, size_t vertex_count, size_t vertex_positions_stride, size_t target_index_count, float target_error, float *out_result_error);
static SimplifySloppyFunc simplify_sloppy_func;
+ typedef size_t (*GenerateRemapFunc)(unsigned int *destination, const unsigned int *indices, size_t index_count, const void *vertices, size_t vertex_count, size_t vertex_size);
+ static GenerateRemapFunc generate_remap_func;
+ typedef void (*RemapVertexFunc)(void *destination, const void *vertices, size_t vertex_count, size_t vertex_size, const unsigned int *remap);
+ static RemapVertexFunc remap_vertex_func;
+ typedef void (*RemapIndexFunc)(unsigned int *destination, const unsigned int *indices, size_t index_count, const unsigned int *remap);
+ static RemapIndexFunc remap_index_func;
+ static void strip_mesh_arrays(PackedVector3Array &r_vertices, PackedInt32Array &r_indices);
private:
struct VertexHasher {
static _FORCE_INLINE_ uint32_t hash(const Vertex &p_vtx);
};
+ struct TriangleHasher {
+ static _FORCE_INLINE_ uint32_t hash(const int *p_triangle);
+ static _FORCE_INLINE_ bool compare(const int *p_lhs, const int *p_rhs);
+ };
+
struct WeightSort {
int index = 0;
float weight = 0.0;
diff --git a/scene/resources/tile_set.cpp b/scene/resources/tile_set.cpp
index 1f77cc0570..1e84947b87 100644
--- a/scene/resources/tile_set.cpp
+++ b/scene/resources/tile_set.cpp
@@ -4434,7 +4434,7 @@ void TileSetAtlasSource::_update_padded_texture() {
Ref<Image> image;
image.instantiate();
- image->create(size.x, size.y, false, Image::FORMAT_RGBA8);
+ image->create(size.x, size.y, false, src->get_format());
for (KeyValue<Vector2i, TileAlternativesData> kv : tiles) {
for (int frame = 0; frame < (int)kv.value.animation_frames_durations.size(); frame++) {
diff --git a/servers/audio/audio_stream.cpp b/servers/audio/audio_stream.cpp
index 170a7ef967..39060286a4 100644
--- a/servers/audio/audio_stream.cpp
+++ b/servers/audio/audio_stream.cpp
@@ -351,100 +351,372 @@ AudioStreamPlaybackMicrophone::AudioStreamPlaybackMicrophone() {
////////////////////////////////
-void AudioStreamRandomPitch::set_audio_stream(const Ref<AudioStream> &p_audio_stream) {
- audio_stream = p_audio_stream;
- if (audio_stream.is_valid()) {
- for (Set<AudioStreamPlaybackRandomPitch *>::Element *E = playbacks.front(); E; E = E->next()) {
- E->get()->playback = audio_stream->instance_playback();
- }
+void AudioStreamRandomizer::add_stream(int p_index) {
+ if (p_index < 0) {
+ p_index = audio_stream_pool.size();
+ }
+ ERR_FAIL_COND(p_index > audio_stream_pool.size());
+ PoolEntry entry{ nullptr, 1.0f };
+ audio_stream_pool.insert(p_index, entry);
+ emit_signal(SNAME("changed"));
+ notify_property_list_changed();
+}
+
+void AudioStreamRandomizer::move_stream(int p_index_from, int p_index_to) {
+ ERR_FAIL_COND(p_index_from < 0);
+ ERR_FAIL_COND(p_index_from >= audio_stream_pool.size());
+ ERR_FAIL_COND(p_index_to < 0);
+ ERR_FAIL_COND(p_index_to > audio_stream_pool.size());
+ audio_stream_pool.insert(p_index_to, audio_stream_pool[p_index_from]);
+ // If 'from' is strictly after 'to' we need to increment the index by one because of the insertion.
+ if (p_index_from > p_index_to) {
+ p_index_from++;
}
+ audio_stream_pool.remove_at(p_index_from);
+ emit_signal(SNAME("changed"));
+ notify_property_list_changed();
+}
+
+void AudioStreamRandomizer::remove_stream(int p_index) {
+ ERR_FAIL_COND(p_index < 0);
+ ERR_FAIL_COND(p_index >= audio_stream_pool.size());
+ audio_stream_pool.remove_at(p_index);
+ emit_signal(SNAME("changed"));
+ notify_property_list_changed();
+}
+
+void AudioStreamRandomizer::set_stream(int p_index, Ref<AudioStream> p_stream) {
+ ERR_FAIL_COND(p_index < 0);
+ ERR_FAIL_COND(p_index >= audio_stream_pool.size());
+ audio_stream_pool.write[p_index].stream = p_stream;
+ emit_signal(SNAME("changed"));
}
-Ref<AudioStream> AudioStreamRandomPitch::get_audio_stream() const {
- return audio_stream;
+Ref<AudioStream> AudioStreamRandomizer::get_stream(int p_index) const {
+ ERR_FAIL_COND_V(p_index < 0, nullptr);
+ ERR_FAIL_COND_V(p_index >= audio_stream_pool.size(), nullptr);
+ return audio_stream_pool[p_index].stream;
}
-void AudioStreamRandomPitch::set_random_pitch(float p_pitch) {
+void AudioStreamRandomizer::set_stream_probability_weight(int p_index, float p_weight) {
+ ERR_FAIL_COND(p_index < 0);
+ ERR_FAIL_COND(p_index >= audio_stream_pool.size());
+ audio_stream_pool.write[p_index].weight = p_weight;
+ emit_signal(SNAME("changed"));
+}
+
+float AudioStreamRandomizer::get_stream_probability_weight(int p_index) const {
+ ERR_FAIL_COND_V(p_index < 0, 0);
+ ERR_FAIL_COND_V(p_index >= audio_stream_pool.size(), 0);
+ return audio_stream_pool[p_index].weight;
+}
+
+void AudioStreamRandomizer::set_streams_count(int p_count) {
+ audio_stream_pool.resize(p_count);
+}
+
+int AudioStreamRandomizer::get_streams_count() const {
+ return audio_stream_pool.size();
+}
+
+void AudioStreamRandomizer::set_random_pitch(float p_pitch) {
if (p_pitch < 1) {
p_pitch = 1;
}
- random_pitch = p_pitch;
+ random_pitch_scale = p_pitch;
+}
+
+float AudioStreamRandomizer::get_random_pitch() const {
+ return random_pitch_scale;
+}
+
+void AudioStreamRandomizer::set_random_volume_offset_db(float p_volume_offset_db) {
+ if (p_volume_offset_db < 0) {
+ p_volume_offset_db = 0;
+ }
+ random_volume_offset_db = p_volume_offset_db;
+}
+
+float AudioStreamRandomizer::get_random_volume_offset_db() const {
+ return random_volume_offset_db;
}
-float AudioStreamRandomPitch::get_random_pitch() const {
- return random_pitch;
+void AudioStreamRandomizer::set_playback_mode(PlaybackMode p_playback_mode) {
+ playback_mode = p_playback_mode;
}
-Ref<AudioStreamPlayback> AudioStreamRandomPitch::instance_playback() {
- Ref<AudioStreamPlaybackRandomPitch> playback;
+AudioStreamRandomizer::PlaybackMode AudioStreamRandomizer::get_playback_mode() const {
+ return playback_mode;
+}
+
+Ref<AudioStreamPlayback> AudioStreamRandomizer::instance_playback_random() {
+ Ref<AudioStreamPlaybackRandomizer> playback;
playback.instantiate();
- if (audio_stream.is_valid()) {
- playback->playback = audio_stream->instance_playback();
+ playbacks.insert(playback.ptr());
+ playback->randomizer = Ref<AudioStreamRandomizer>((AudioStreamRandomizer *)this);
+
+ double total_weight = 0;
+ Vector<PoolEntry> local_pool;
+ for (const PoolEntry &entry : audio_stream_pool) {
+ if (entry.stream.is_valid() && entry.weight > 0) {
+ local_pool.push_back(entry);
+ total_weight += entry.weight;
+ }
+ }
+ if (local_pool.is_empty()) {
+ return playback;
}
+ double chosen_cumulative_weight = Math::random(0.0, total_weight);
+ double cumulative_weight = 0;
+ for (PoolEntry &entry : local_pool) {
+ cumulative_weight += entry.weight;
+ if (cumulative_weight > chosen_cumulative_weight) {
+ playback->playback = entry.stream->instance_playback();
+ last_playback = entry.stream;
+ break;
+ }
+ }
+ if (playback->playback.is_null()) {
+ // This indicates a floating point error. Take the last element.
+ last_playback = local_pool[local_pool.size() - 1].stream;
+ playback->playback = local_pool.write[local_pool.size() - 1].stream->instance_playback();
+ }
+ return playback;
+}
+
+Ref<AudioStreamPlayback> AudioStreamRandomizer::instance_playback_no_repeats() {
+ Ref<AudioStreamPlaybackRandomizer> playback;
+ double total_weight = 0;
+ Vector<PoolEntry> local_pool;
+ for (const PoolEntry &entry : audio_stream_pool) {
+ if (entry.stream == last_playback) {
+ continue;
+ }
+ if (entry.stream.is_valid() && entry.weight > 0) {
+ local_pool.push_back(entry);
+ total_weight += entry.weight;
+ }
+ }
+ if (local_pool.is_empty()) {
+ playback = instance_playback_random();
+ WARN_PRINT("Playback stream pool is too small to prevent repeats.");
+ return playback;
+ }
+
+ playback.instantiate();
playbacks.insert(playback.ptr());
- playback->random_pitch = Ref<AudioStreamRandomPitch>((AudioStreamRandomPitch *)this);
+ playback->randomizer = Ref<AudioStreamRandomizer>((AudioStreamRandomizer *)this);
+ double chosen_cumulative_weight = Math::random(0.0, total_weight);
+ double cumulative_weight = 0;
+ for (PoolEntry &entry : local_pool) {
+ cumulative_weight += entry.weight;
+ if (cumulative_weight > chosen_cumulative_weight) {
+ last_playback = entry.stream;
+ playback->playback = entry.stream->instance_playback();
+ break;
+ }
+ }
+ if (playback->playback.is_null()) {
+ // This indicates a floating point error. Take the last element.
+ last_playback = local_pool[local_pool.size() - 1].stream;
+ playback->playback = local_pool.write[local_pool.size() - 1].stream->instance_playback();
+ }
return playback;
}
-String AudioStreamRandomPitch::get_stream_name() const {
- if (audio_stream.is_valid()) {
- return "Random: " + audio_stream->get_name();
+Ref<AudioStreamPlayback> AudioStreamRandomizer::instance_playback_sequential() {
+ Ref<AudioStreamPlaybackRandomizer> playback;
+ playback.instantiate();
+ playbacks.insert(playback.ptr());
+ playback->randomizer = Ref<AudioStreamRandomizer>((AudioStreamRandomizer *)this);
+
+ Vector<Ref<AudioStream>> local_pool;
+ for (const PoolEntry &entry : audio_stream_pool) {
+ if (entry.stream.is_null()) {
+ continue;
+ }
+ if (local_pool.find(entry.stream) != -1) {
+ WARN_PRINT("Duplicate stream in sequential playback pool");
+ continue;
+ }
+ local_pool.push_back(entry.stream);
+ }
+ if (local_pool.is_empty()) {
+ return playback;
}
- return "RandomPitch";
+ bool found_last_stream = false;
+ for (Ref<AudioStream> &entry : local_pool) {
+ if (found_last_stream) {
+ last_playback = entry;
+ playback->playback = entry->instance_playback();
+ break;
+ }
+ if (entry == last_playback) {
+ found_last_stream = true;
+ }
+ }
+ if (playback->playback.is_null()) {
+ // Wrap around
+ last_playback = local_pool[0];
+ playback->playback = local_pool.write[0]->instance_playback();
+ }
+ return playback;
}
-float AudioStreamRandomPitch::get_length() const {
- if (audio_stream.is_valid()) {
- return audio_stream->get_length();
+Ref<AudioStreamPlayback> AudioStreamRandomizer::instance_playback() {
+ switch (playback_mode) {
+ case PLAYBACK_RANDOM:
+ return instance_playback_random();
+ case PLAYBACK_RANDOM_NO_REPEATS:
+ return instance_playback_no_repeats();
+ case PLAYBACK_SEQUENTIAL:
+ return instance_playback_sequential();
+ default:
+ ERR_FAIL_V_MSG(nullptr, "Unhandled playback mode.");
}
+}
+String AudioStreamRandomizer::get_stream_name() const {
+ return "Randomizer";
+}
+
+float AudioStreamRandomizer::get_length() const {
return 0;
}
-bool AudioStreamRandomPitch::is_monophonic() const {
- if (audio_stream.is_valid()) {
- return audio_stream->is_monophonic();
+bool AudioStreamRandomizer::is_monophonic() const {
+ for (const PoolEntry &entry : audio_stream_pool) {
+ if (entry.stream.is_valid() && entry.stream->is_monophonic()) {
+ return true;
+ }
+ }
+ return false;
+}
+
+bool AudioStreamRandomizer::_get(const StringName &p_name, Variant &r_ret) const {
+ if (AudioStream::_get(p_name, r_ret)) {
+ return true;
}
+ Vector<String> components = String(p_name).split("/", true, 2);
+ if (components.size() == 2 && components[0].begins_with("stream_") && components[0].trim_prefix("stream_").is_valid_int()) {
+ int index = components[0].trim_prefix("stream_").to_int();
+ if (index < 0 || index >= (int)audio_stream_pool.size()) {
+ return false;
+ }
- return true; // It doesn't really matter what we return here, but no sense instancing a many playbacks of a null stream.
+ if (components[1] == "stream") {
+ r_ret = get_stream(index);
+ return true;
+ } else if (components[1] == "weight") {
+ r_ret = get_stream_probability_weight(index);
+ return true;
+ } else {
+ return false;
+ }
+ }
+ return false;
+}
+
+bool AudioStreamRandomizer::_set(const StringName &p_name, const Variant &p_value) {
+ if (AudioStream::_set(p_name, p_value)) {
+ return true;
+ }
+ Vector<String> components = String(p_name).split("/", true, 2);
+ if (components.size() == 2 && components[0].begins_with("stream_") && components[0].trim_prefix("stream_").is_valid_int()) {
+ int index = components[0].trim_prefix("stream_").to_int();
+ if (index < 0 || index >= (int)audio_stream_pool.size()) {
+ return false;
+ }
+
+ if (components[1] == "stream") {
+ set_stream(index, p_value);
+ return true;
+ } else if (components[1] == "weight") {
+ set_stream_probability_weight(index, p_value);
+ return true;
+ } else {
+ return false;
+ }
+ }
+ return false;
+}
+
+void AudioStreamRandomizer::_get_property_list(List<PropertyInfo> *p_list) const {
+ AudioStream::_get_property_list(p_list); // Define the trivial scalar properties.
+ p_list->push_back(PropertyInfo(Variant::NIL, "Streams", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_GROUP));
+ for (int i = 0; i < audio_stream_pool.size(); i++) {
+ p_list->push_back(PropertyInfo(Variant::OBJECT, vformat("stream_%d/stream", i), PROPERTY_HINT_RESOURCE_TYPE, "AudioStream"));
+ p_list->push_back(PropertyInfo(Variant::FLOAT, vformat("stream_%d/weight", i), PROPERTY_HINT_RANGE, "0,100,0.001,or_greater"));
+ }
}
-void AudioStreamRandomPitch::_bind_methods() {
- ClassDB::bind_method(D_METHOD("set_audio_stream", "stream"), &AudioStreamRandomPitch::set_audio_stream);
- ClassDB::bind_method(D_METHOD("get_audio_stream"), &AudioStreamRandomPitch::get_audio_stream);
+void AudioStreamRandomizer::_bind_methods() {
+ ClassDB::bind_method(D_METHOD("add_stream", "index"), &AudioStreamRandomizer::add_stream);
+ ClassDB::bind_method(D_METHOD("move_stream", "index_from", "index_to"), &AudioStreamRandomizer::move_stream);
+ ClassDB::bind_method(D_METHOD("remove_stream", "index"), &AudioStreamRandomizer::remove_stream);
+
+ ClassDB::bind_method(D_METHOD("set_stream", "index", "stream"), &AudioStreamRandomizer::set_stream);
+ ClassDB::bind_method(D_METHOD("get_stream", "index"), &AudioStreamRandomizer::get_stream);
+ ClassDB::bind_method(D_METHOD("set_stream_probability_weight", "index", "weight"), &AudioStreamRandomizer::set_stream_probability_weight);
+ ClassDB::bind_method(D_METHOD("get_stream_probability_weight", "index"), &AudioStreamRandomizer::get_stream_probability_weight);
+
+ ClassDB::bind_method(D_METHOD("set_streams_count", "count"), &AudioStreamRandomizer::set_streams_count);
+ ClassDB::bind_method(D_METHOD("get_streams_count"), &AudioStreamRandomizer::get_streams_count);
+
+ ClassDB::bind_method(D_METHOD("set_random_pitch", "scale"), &AudioStreamRandomizer::set_random_pitch);
+ ClassDB::bind_method(D_METHOD("get_random_pitch"), &AudioStreamRandomizer::get_random_pitch);
- ClassDB::bind_method(D_METHOD("set_random_pitch", "scale"), &AudioStreamRandomPitch::set_random_pitch);
- ClassDB::bind_method(D_METHOD("get_random_pitch"), &AudioStreamRandomPitch::get_random_pitch);
+ ClassDB::bind_method(D_METHOD("set_random_volume_offset_db", "db_offset"), &AudioStreamRandomizer::set_random_volume_offset_db);
+ ClassDB::bind_method(D_METHOD("get_random_volume_offset_db"), &AudioStreamRandomizer::get_random_volume_offset_db);
- ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "audio_stream", PROPERTY_HINT_RESOURCE_TYPE, "AudioStream"), "set_audio_stream", "get_audio_stream");
+ ClassDB::bind_method(D_METHOD("set_playback_mode", "mode"), &AudioStreamRandomizer::set_playback_mode);
+ ClassDB::bind_method(D_METHOD("get_playback_mode"), &AudioStreamRandomizer::get_playback_mode);
+
+ ADD_ARRAY("streams", "stream_");
+ ADD_PROPERTY(PropertyInfo(Variant::INT, "streams_count", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_NO_EDITOR), "set_streams_count", "get_streams_count");
+ ADD_PROPERTY(PropertyInfo(Variant::INT, "playback_mode", PROPERTY_HINT_ENUM, "Random (Avoid Repeats),Random,Sequential"), "set_playback_mode", "get_playback_mode");
ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "random_pitch", PROPERTY_HINT_RANGE, "1,16,0.01"), "set_random_pitch", "get_random_pitch");
+ ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "random_volume_offset_db", PROPERTY_HINT_RANGE, "0,40,0"), "set_random_volume_offset_db", "get_random_volume_offset_db");
+
+ BIND_ENUM_CONSTANT(PLAYBACK_RANDOM_NO_REPEATS);
+ BIND_ENUM_CONSTANT(PLAYBACK_RANDOM);
+ BIND_ENUM_CONSTANT(PLAYBACK_SEQUENTIAL);
}
-AudioStreamRandomPitch::AudioStreamRandomPitch() {
- random_pitch = 1.1;
+AudioStreamRandomizer::AudioStreamRandomizer() {
+ random_pitch_scale = 1.1;
+ random_volume_offset_db = 5;
}
-void AudioStreamPlaybackRandomPitch::start(float p_from_pos) {
+void AudioStreamPlaybackRandomizer::start(float p_from_pos) {
playing = playback;
- float range_from = 1.0 / random_pitch->random_pitch;
- float range_to = random_pitch->random_pitch;
+ {
+ float range_from = 1.0 / randomizer->random_pitch_scale;
+ float range_to = randomizer->random_pitch_scale;
- pitch_scale = range_from + Math::randf() * (range_to - range_from);
+ pitch_scale = range_from + Math::randf() * (range_to - range_from);
+ }
+ {
+ float range_from = -randomizer->random_volume_offset_db;
+ float range_to = randomizer->random_volume_offset_db;
+
+ float volume_offset_db = range_from + Math::randf() * (range_to - range_from);
+ volume_scale = Math::db2linear(volume_offset_db);
+ }
if (playing.is_valid()) {
playing->start(p_from_pos);
}
}
-void AudioStreamPlaybackRandomPitch::stop() {
+void AudioStreamPlaybackRandomizer::stop() {
if (playing.is_valid()) {
playing->stop();
- ;
}
}
-bool AudioStreamPlaybackRandomPitch::is_playing() const {
+bool AudioStreamPlaybackRandomizer::is_playing() const {
if (playing.is_valid()) {
return playing->is_playing();
}
@@ -452,7 +724,7 @@ bool AudioStreamPlaybackRandomPitch::is_playing() const {
return false;
}
-int AudioStreamPlaybackRandomPitch::get_loop_count() const {
+int AudioStreamPlaybackRandomizer::get_loop_count() const {
if (playing.is_valid()) {
return playing->get_loop_count();
}
@@ -460,7 +732,7 @@ int AudioStreamPlaybackRandomPitch::get_loop_count() const {
return 0;
}
-float AudioStreamPlaybackRandomPitch::get_playback_position() const {
+float AudioStreamPlaybackRandomizer::get_playback_position() const {
if (playing.is_valid()) {
return playing->get_playback_position();
}
@@ -468,13 +740,13 @@ float AudioStreamPlaybackRandomPitch::get_playback_position() const {
return 0;
}
-void AudioStreamPlaybackRandomPitch::seek(float p_time) {
+void AudioStreamPlaybackRandomizer::seek(float p_time) {
if (playing.is_valid()) {
playing->seek(p_time);
}
}
-int AudioStreamPlaybackRandomPitch::mix(AudioFrame *p_buffer, float p_rate_scale, int p_frames) {
+int AudioStreamPlaybackRandomizer::mix(AudioFrame *p_buffer, float p_rate_scale, int p_frames) {
if (playing.is_valid()) {
return playing->mix(p_buffer, p_rate_scale * pitch_scale, p_frames);
} else {
@@ -485,7 +757,7 @@ int AudioStreamPlaybackRandomPitch::mix(AudioFrame *p_buffer, float p_rate_scale
}
}
-AudioStreamPlaybackRandomPitch::~AudioStreamPlaybackRandomPitch() {
- random_pitch->playbacks.erase(this);
+AudioStreamPlaybackRandomizer::~AudioStreamPlaybackRandomizer() {
+ randomizer->playbacks.erase(this);
}
/////////////////////////////////////////////
diff --git a/servers/audio/audio_stream.h b/servers/audio/audio_stream.h
index 32159e96ef..ce9bcabb9c 100644
--- a/servers/audio/audio_stream.h
+++ b/servers/audio/audio_stream.h
@@ -167,43 +167,86 @@ public:
//
-class AudioStreamPlaybackRandomPitch;
+class AudioStreamPlaybackRandomizer;
-class AudioStreamRandomPitch : public AudioStream {
- GDCLASS(AudioStreamRandomPitch, AudioStream);
- friend class AudioStreamPlaybackRandomPitch;
+class AudioStreamRandomizer : public AudioStream {
+ GDCLASS(AudioStreamRandomizer, AudioStream);
- Set<AudioStreamPlaybackRandomPitch *> playbacks;
- Ref<AudioStream> audio_stream;
- float random_pitch;
+public:
+ enum PlaybackMode {
+ PLAYBACK_RANDOM_NO_REPEATS,
+ PLAYBACK_RANDOM,
+ PLAYBACK_SEQUENTIAL,
+ };
+
+private:
+ friend class AudioStreamPlaybackRandomizer;
+
+ struct PoolEntry {
+ Ref<AudioStream> stream;
+ float weight;
+ };
+
+ Set<AudioStreamPlaybackRandomizer *> playbacks;
+ Vector<PoolEntry> audio_stream_pool;
+ float random_pitch_scale;
+ float random_volume_offset_db;
+
+ Ref<AudioStreamPlayback> instance_playback_random();
+ Ref<AudioStreamPlayback> instance_playback_no_repeats();
+ Ref<AudioStreamPlayback> instance_playback_sequential();
+
+ Ref<AudioStream> last_playback = nullptr;
+ PlaybackMode playback_mode = PLAYBACK_RANDOM_NO_REPEATS;
protected:
static void _bind_methods();
+ bool _set(const StringName &p_name, const Variant &p_value);
+ bool _get(const StringName &p_name, Variant &r_ret) const;
+ void _get_property_list(List<PropertyInfo> *p_list) const;
+
public:
- void set_audio_stream(const Ref<AudioStream> &p_audio_stream);
- Ref<AudioStream> get_audio_stream() const;
+ void add_stream(int p_index);
+ void move_stream(int p_index_from, int p_index_to);
+ void remove_stream(int p_index);
+
+ void set_stream(int p_index, Ref<AudioStream> p_stream);
+ Ref<AudioStream> get_stream(int p_index) const;
+ void set_stream_probability_weight(int p_index, float p_weight);
+ float get_stream_probability_weight(int p_index) const;
- void set_random_pitch(float p_pitch);
+ void set_streams_count(int p_count);
+ int get_streams_count() const;
+
+ void set_random_pitch(float p_pitch_scale);
float get_random_pitch() const;
+ void set_random_volume_offset_db(float p_volume_offset_db);
+ float get_random_volume_offset_db() const;
+
+ void set_playback_mode(PlaybackMode p_playback_mode);
+ PlaybackMode get_playback_mode() const;
+
virtual Ref<AudioStreamPlayback> instance_playback() override;
virtual String get_stream_name() const override;
virtual float get_length() const override; //if supported, otherwise return 0
virtual bool is_monophonic() const override;
- AudioStreamRandomPitch();
+ AudioStreamRandomizer();
};
-class AudioStreamPlaybackRandomPitch : public AudioStreamPlayback {
- GDCLASS(AudioStreamPlaybackRandomPitch, AudioStreamPlayback);
- friend class AudioStreamRandomPitch;
+class AudioStreamPlaybackRandomizer : public AudioStreamPlayback {
+ GDCLASS(AudioStreamPlaybackRandomizer, AudioStreamPlayback);
+ friend class AudioStreamRandomizer;
- Ref<AudioStreamRandomPitch> random_pitch;
+ Ref<AudioStreamRandomizer> randomizer;
Ref<AudioStreamPlayback> playback;
Ref<AudioStreamPlayback> playing;
+
float pitch_scale;
+ float volume_scale;
public:
virtual void start(float p_from_pos = 0.0) override;
@@ -217,7 +260,9 @@ public:
virtual int mix(AudioFrame *p_buffer, float p_rate_scale, int p_frames) override;
- ~AudioStreamPlaybackRandomPitch();
+ ~AudioStreamPlaybackRandomizer();
};
+VARIANT_ENUM_CAST(AudioStreamRandomizer::PlaybackMode);
+
#endif // AUDIO_STREAM_H
diff --git a/servers/register_server_types.cpp b/servers/register_server_types.cpp
index bf8b6379d2..3726bcde35 100644
--- a/servers/register_server_types.cpp
+++ b/servers/register_server_types.cpp
@@ -140,7 +140,7 @@ void register_server_types() {
GDREGISTER_CLASS(AudioStreamPlayback);
GDREGISTER_VIRTUAL_CLASS(AudioStreamPlaybackResampled);
GDREGISTER_CLASS(AudioStreamMicrophone);
- GDREGISTER_CLASS(AudioStreamRandomPitch);
+ GDREGISTER_CLASS(AudioStreamRandomizer);
GDREGISTER_VIRTUAL_CLASS(AudioEffect);
GDREGISTER_VIRTUAL_CLASS(AudioEffectInstance);
GDREGISTER_CLASS(AudioEffectEQ);
diff --git a/servers/rendering_server.cpp b/servers/rendering_server.cpp
index 584abbc351..ac181cb5eb 100644
--- a/servers/rendering_server.cpp
+++ b/servers/rendering_server.cpp
@@ -933,7 +933,7 @@ Error RenderingServer::mesh_create_surface_data_from_arrays(SurfaceData *r_surfa
}
}
- ERR_FAIL_COND_V_MSG((bsformat & RS::ARRAY_FORMAT_BLEND_SHAPE_MASK) != (format & RS::ARRAY_FORMAT_BLEND_SHAPE_MASK), ERR_INVALID_PARAMETER, "Blend shape format must match the main array format for Vertex, Normal and Tangent arrays.");
+ ERR_FAIL_COND_V_MSG(bsformat != (format & RS::ARRAY_FORMAT_BLEND_SHAPE_MASK), ERR_INVALID_PARAMETER, "Blend shape format must match the main array format for Vertex, Normal and Tangent arrays.");
}
}
diff --git a/servers/rendering_server.h b/servers/rendering_server.h
index 472fff1bf1..d21f3a3299 100644
--- a/servers/rendering_server.h
+++ b/servers/rendering_server.h
@@ -259,7 +259,7 @@ public:
ARRAY_FORMAT_WEIGHTS = 1 << ARRAY_WEIGHTS,
ARRAY_FORMAT_INDEX = 1 << ARRAY_INDEX,
- ARRAY_FORMAT_BLEND_SHAPE_MASK = (~(ARRAY_FORMAT_COLOR | ARRAY_FORMAT_TEX_UV | ARRAY_FORMAT_TEX_UV2 | ARRAY_FORMAT_BONES | ARRAY_FORMAT_WEIGHTS | ARRAY_FORMAT_CUSTOM0 | ARRAY_FORMAT_CUSTOM1 | ARRAY_FORMAT_CUSTOM2 | ARRAY_FORMAT_CUSTOM3 | ARRAY_FORMAT_INDEX)) & 0x7FFFFFFF,
+ ARRAY_FORMAT_BLEND_SHAPE_MASK = ARRAY_FORMAT_VERTEX | ARRAY_FORMAT_NORMAL | ARRAY_FORMAT_TANGENT,
ARRAY_FORMAT_CUSTOM_BASE = (ARRAY_INDEX + 1),
ARRAY_FORMAT_CUSTOM_BITS = 3,
diff --git a/tests/scene/test_gui.cpp b/tests/scene/test_gui.cpp
index 9da6063c7b..cd5624b70c 100644
--- a/tests/scene/test_gui.cpp
+++ b/tests/scene/test_gui.cpp
@@ -103,7 +103,7 @@ public:
item->set_editable(0, true);
item->set_range_config(0, 0, 20, 0.1);
item->set_range(0, 2);
- item->add_button(0, Theme::get_default()->get_icon(SNAME("folder"), SNAME("FileDialog")));
+ item->add_button(0, Theme::get_default()->get_icon("folder", "FileDialog"));
item->set_cell_mode(1, TreeItem::CELL_MODE_RANGE);
item->set_editable(1, true);
item->set_range_config(1, 0, 20, 0.1);