From bba637e5336f1bc0377dc82a5a4d7236c3143a25 Mon Sep 17 00:00:00 2001 From: kobewi Date: Thu, 5 Sep 2024 19:05:18 +0200 Subject: [PATCH 1/6] Don't use EditorSettings metadata (cherry picked from commit c8a076693013cd78ba01242aa3e72fdf72686103) --- editor/export/export_template_manager.cpp | 4 +-- editor/script_create_dialog.cpp | 39 ++++++++++------------- 2 files changed, 19 insertions(+), 24 deletions(-) diff --git a/editor/export/export_template_manager.cpp b/editor/export/export_template_manager.cpp index abaf3cd8335..6b04d3fbd8e 100644 --- a/editor/export/export_template_manager.cpp +++ b/editor/export/export_template_manager.cpp @@ -545,7 +545,7 @@ bool ExportTemplateManager::_install_file_selected(const String &p_file, bool p_ unzClose(pkg); _update_template_status(); - EditorSettings::get_singleton()->set_meta("export_template_download_directory", p_file.get_base_dir()); + EditorSettings::get_singleton()->set("_export_template_download_directory", p_file.get_base_dir()); return true; } @@ -1059,7 +1059,7 @@ ExportTemplateManager::ExportTemplateManager() { install_file_dialog->set_title(TTR("Select Template File")); install_file_dialog->set_access(FileDialog::ACCESS_FILESYSTEM); install_file_dialog->set_file_mode(FileDialog::FILE_MODE_OPEN_FILE); - install_file_dialog->set_current_dir(EditorSettings::get_singleton()->get_meta("export_template_download_directory", "")); + install_file_dialog->set_current_dir(EDITOR_DEF("_export_template_download_directory", "")); install_file_dialog->add_filter("*.tpz", TTR("Redot Export Templates")); install_file_dialog->connect("file_selected", callable_mp(this, &ExportTemplateManager::_install_file_selected).bind(false)); add_child(install_file_dialog); diff --git a/editor/script_create_dialog.cpp b/editor/script_create_dialog.cpp index 0588bc4ac19..e734a4209d1 100644 --- a/editor/script_create_dialog.cpp +++ b/editor/script_create_dialog.cpp @@ -113,15 +113,7 @@ static Vector _get_hierarchy(const String &p_class_name) { void ScriptCreateDialog::_notification(int p_what) { switch (p_what) { - case NOTIFICATION_ENTER_TREE: - case NOTIFICATION_THEME_CHANGED: { - for (int i = 0; i < ScriptServer::get_language_count(); i++) { - Ref language_icon = get_editor_theme_icon(ScriptServer::get_language(i)->get_type()); - if (language_icon.is_valid()) { - language_menu->set_item_icon(i, language_icon); - } - } - + case NOTIFICATION_ENTER_TREE: { String last_language = EditorSettings::get_singleton()->get_project_metadata("script_setup", "last_selected_language", ""); if (!last_language.is_empty()) { for (int i = 0; i < language_menu->get_item_count(); i++) { @@ -133,9 +125,16 @@ void ScriptCreateDialog::_notification(int p_what) { } else { language_menu->select(default_language); } - if (EditorSettings::get_singleton()->has_meta("script_setup_use_script_templates")) { - is_using_templates = bool(EditorSettings::get_singleton()->get_meta("script_setup_use_script_templates")); - use_templates->set_pressed(is_using_templates); + is_using_templates = EDITOR_DEF("_script_setup_use_script_templates", false); + use_templates->set_pressed(is_using_templates); + } break; + + case NOTIFICATION_THEME_CHANGED: { + for (int i = 0; i < ScriptServer::get_language_count(); i++) { + Ref language_icon = get_editor_theme_icon(ScriptServer::get_language(i)->get_type()); + if (language_icon.is_valid()) { + language_menu->set_item_icon(i, language_icon); + } } path_button->set_icon(get_editor_theme_icon(SNAME("Folder"))); @@ -299,12 +298,9 @@ void ScriptCreateDialog::_template_changed(int p_template) { EditorSettings::get_singleton()->set_project_metadata("script_setup", "templates_dictionary", dic_templates_project); } else { // Save template info to editor dictionary (not a project template). - Dictionary dic_templates; - if (EditorSettings::get_singleton()->has_meta("script_setup_templates_dictionary")) { - dic_templates = (Dictionary)EditorSettings::get_singleton()->get_meta("script_setup_templates_dictionary"); - } + Dictionary dic_templates = EDITOR_GET("_script_setup_templates_dictionary"); dic_templates[parent_name->get_text()] = sinfo.get_hash(); - EditorSettings::get_singleton()->set_meta("script_setup_templates_dictionary", dic_templates); + EditorSettings::get_singleton()->set("_script_setup_templates_dictionary", dic_templates); // Remove template from project dictionary as we last used an editor level template. Dictionary dic_templates_project = EditorSettings::get_singleton()->get_project_metadata("script_setup", "templates_dictionary", Dictionary()); if (dic_templates_project.has(parent_name->get_text())) { @@ -417,7 +413,7 @@ void ScriptCreateDialog::_built_in_pressed() { void ScriptCreateDialog::_use_template_pressed() { is_using_templates = use_templates->is_pressed(); - EditorSettings::get_singleton()->set_meta("script_setup_use_script_templates", is_using_templates); + EditorSettings::get_singleton()->set("_script_setup_use_script_templates", is_using_templates); validation_panel->update(); } @@ -511,10 +507,7 @@ void ScriptCreateDialog::_update_template_menu() { if (is_language_using_templates) { // Get the latest templates used for each type of node from project settings then global settings. Dictionary last_local_templates = EditorSettings::get_singleton()->get_project_metadata("script_setup", "templates_dictionary", Dictionary()); - Dictionary last_global_templates; - if (EditorSettings::get_singleton()->has_meta("script_setup_templates_dictionary")) { - last_global_templates = (Dictionary)EditorSettings::get_singleton()->get_meta("script_setup_templates_dictionary"); - } + Dictionary last_global_templates = EDITOR_GET("_script_setup_templates_dictionary"); String inherits_base_type = parent_name->get_text(); // If it inherits from a script, get its parent class first. @@ -827,6 +820,8 @@ void ScriptCreateDialog::_bind_methods() { } ScriptCreateDialog::ScriptCreateDialog() { + EDITOR_DEF("_script_setup_templates_dictionary", Dictionary()); + /* Main Controls */ GridContainer *gc = memnew(GridContainer); From b192feba21e4e75fcbd4f9ff7f2abbc290bd0099 Mon Sep 17 00:00:00 2001 From: Jeff Ward Date: Wed, 6 Nov 2024 20:21:51 -0500 Subject: [PATCH 2/6] Support extension icons in ScriptCreateDialog Attempt to grab the icon for a script type from the theme first, then ask the extension for the icon. (cherry picked from commit 5da3e816404708b22b4a66796c7371d2d6b5853f) --- editor/script_create_dialog.cpp | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/editor/script_create_dialog.cpp b/editor/script_create_dialog.cpp index e734a4209d1..8a6d8116743 100644 --- a/editor/script_create_dialog.cpp +++ b/editor/script_create_dialog.cpp @@ -47,6 +47,7 @@ #include "editor/themes/editor_scale.h" #include "scene/gui/grid_container.h" #include "scene/gui/line_edit.h" +#include "scene/theme/theme_db.h" static String _get_parent_class_of_script(const String &p_path) { if (!ResourceLoader::exists(p_path, "Script")) { @@ -130,8 +131,23 @@ void ScriptCreateDialog::_notification(int p_what) { } break; case NOTIFICATION_THEME_CHANGED: { + const int icon_size = get_theme_constant(SNAME("class_icon_size"), EditorStringName(Editor)); + + EditorData &ed = EditorNode::get_editor_data(); + for (int i = 0; i < ScriptServer::get_language_count(); i++) { - Ref language_icon = get_editor_theme_icon(ScriptServer::get_language(i)->get_type()); + // Check if the extension has an icon first. + String script_type = ScriptServer::get_language(i)->get_type(); + Ref language_icon = get_editor_theme_icon(script_type); + if (language_icon.is_null() || language_icon == ThemeDB::get_singleton()->get_fallback_icon()) { + // The theme doesn't have an icon for this language, ask the extensions. + Ref extension_language_icon = ed.extension_class_get_icon(script_type); + if (extension_language_icon.is_valid()) { + language_menu->get_popup()->set_item_icon_max_width(i, icon_size); + language_icon = extension_language_icon; + } + } + if (language_icon.is_valid()) { language_menu->set_item_icon(i, language_icon); } @@ -852,6 +868,7 @@ ScriptCreateDialog::ScriptCreateDialog() { language_menu = memnew(OptionButton); language_menu->set_custom_minimum_size(Size2(350, 0) * EDSCALE); + language_menu->set_expand_icon(true); language_menu->set_h_size_flags(Control::SIZE_EXPAND_FILL); gc->add_child(memnew(Label(TTR("Language:")))); gc->add_child(language_menu); From 52080b79fa94114bb6eb48165c6b4f01aecf2ba1 Mon Sep 17 00:00:00 2001 From: David Snopek Date: Mon, 18 Nov 2024 13:19:22 -0600 Subject: [PATCH 3/6] GDExtension: Fix method binds not saying if they are varargs (cherry picked from commit 2599df3b8ae5aa6b718feadefb39cab037927f3e) --- core/extension/gdextension.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core/extension/gdextension.cpp b/core/extension/gdextension.cpp index c12f0e33618..bf66ad41021 100644 --- a/core/extension/gdextension.cpp +++ b/core/extension/gdextension.cpp @@ -298,7 +298,7 @@ class GDExtensionMethodBind : public MethodBind { } virtual bool is_vararg() const override { - return false; + return vararg; } #ifdef TOOLS_ENABLED From 3cc0ea8665c1f10fb711408e2ba1e94c9529df34 Mon Sep 17 00:00:00 2001 From: David Snopek Date: Tue, 3 Dec 2024 12:57:56 -0600 Subject: [PATCH 4/6] `CompositorEffect` should use `GDVIRTUAL_CALL()` so it works with GDExtension (cherry picked from commit ca12f350dbb718312ef6875a5d20bca38c07a24d) --- scene/resources/compositor.cpp | 6 +++++- scene/resources/compositor.h | 2 ++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/scene/resources/compositor.cpp b/scene/resources/compositor.cpp index cfe18746921..e8f31656e64 100644 --- a/scene/resources/compositor.cpp +++ b/scene/resources/compositor.cpp @@ -87,6 +87,10 @@ void CompositorEffect::_validate_property(PropertyInfo &p_property) const { } } +void CompositorEffect::_call_render_callback(int p_effect_callback_type, const RenderData *p_render_data) { + GDVIRTUAL_CALL(_render_callback, p_effect_callback_type, p_render_data); +} + void CompositorEffect::set_enabled(bool p_enabled) { enabled = p_enabled; if (rid.is_valid()) { @@ -107,7 +111,7 @@ void CompositorEffect::set_effect_callback_type(EffectCallbackType p_callback_ty if (rid.is_valid()) { RenderingServer *rs = RenderingServer::get_singleton(); ERR_FAIL_NULL(rs); - rs->compositor_effect_set_callback(rid, RenderingServer::CompositorEffectCallbackType(effect_callback_type), Callable(this, "_render_callback")); + rs->compositor_effect_set_callback(rid, RenderingServer::CompositorEffectCallbackType(effect_callback_type), callable_mp(this, &CompositorEffect::_call_render_callback)); } } diff --git a/scene/resources/compositor.h b/scene/resources/compositor.h index 3c7315aec0d..da4270014c1 100644 --- a/scene/resources/compositor.h +++ b/scene/resources/compositor.h @@ -67,6 +67,8 @@ class CompositorEffect : public Resource { static void _bind_methods(); void _validate_property(PropertyInfo &p_property) const; + void _call_render_callback(int p_effect_callback_type, const RenderData *p_render_data); + GDVIRTUAL2(_render_callback, int, const RenderData *) public: From 7f9675c81589f4d2fe98fe8fb5ee6d57f648e0b2 Mon Sep 17 00:00:00 2001 From: David Snopek Date: Fri, 6 Dec 2024 16:58:50 -0600 Subject: [PATCH 5/6] Add missing `GDVIRTUAL_BIND()` for `AudioStream::_has_loop()` and `::_get_bar_beats()` (cherry picked from commit 3866a7f818d3975d6051a59f116e4f196b261005) --- doc/classes/AudioStream.xml | 12 ++++++++++++ servers/audio/audio_stream.cpp | 2 ++ 2 files changed, 14 insertions(+) diff --git a/doc/classes/AudioStream.xml b/doc/classes/AudioStream.xml index 44edff122e7..7e8c61f4d4f 100644 --- a/doc/classes/AudioStream.xml +++ b/doc/classes/AudioStream.xml @@ -13,6 +13,12 @@ https://godotengine.org/asset-library/asset/2762 + + + + Override this method to return the bar beats of this stream. + + @@ -45,6 +51,12 @@ Override this method to customize the name assigned to this audio stream. Unused by the engine. + + + + Override this method to return [code]true[/code] if this stream has a loop. + + diff --git a/servers/audio/audio_stream.cpp b/servers/audio/audio_stream.cpp index 3dfff6c8bc1..40b2fa8ed78 100644 --- a/servers/audio/audio_stream.cpp +++ b/servers/audio/audio_stream.cpp @@ -311,6 +311,8 @@ void AudioStream::_bind_methods() { GDVIRTUAL_BIND(_get_bpm) GDVIRTUAL_BIND(_get_beat_count) GDVIRTUAL_BIND(_get_parameter_list) + GDVIRTUAL_BIND(_has_loop); + GDVIRTUAL_BIND(_get_bar_beats); ADD_SIGNAL(MethodInfo("parameter_list_changed")); } From e58becb08a5cb2a7faf12b37277548c728da4090 Mon Sep 17 00:00:00 2001 From: David Snopek Date: Thu, 12 Dec 2024 08:31:12 -0600 Subject: [PATCH 6/6] Fix `StreamPeerExtension::put_partial_data()` to call `_put_partial_data()` (cherry picked from commit 8c01fc22744e56c666af0d70afc20a09910d6f80) --- core/io/stream_peer.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core/io/stream_peer.cpp b/core/io/stream_peer.cpp index 2b5a44a27c7..545870df799 100644 --- a/core/io/stream_peer.cpp +++ b/core/io/stream_peer.cpp @@ -443,7 +443,7 @@ Error StreamPeerExtension::put_data(const uint8_t *p_data, int p_bytes) { Error StreamPeerExtension::put_partial_data(const uint8_t *p_data, int p_bytes, int &r_sent) { Error err; - if (GDVIRTUAL_CALL(_put_data, p_data, p_bytes, &r_sent, err)) { + if (GDVIRTUAL_CALL(_put_partial_data, p_data, p_bytes, &r_sent, err)) { return err; } WARN_PRINT_ONCE("StreamPeerExtension::_put_partial_data is unimplemented!");