From 7e252922058ecfc46a134383e9f6cebc60532b05 Mon Sep 17 00:00:00 2001 From: Hugo Locurcio Date: Thu, 8 Feb 2024 15:13:15 +0100 Subject: [PATCH] Show update spinner by default in `dev_build=yes` editor builds This ensures contributors can see when something forces the editor to redraw constantly. The existing boolean `true` value will be casted to `1` in the setting, so it'll switch to Enabled automatically if the setting was previously enabled. --- doc/classes/EditorSettings.xml | 7 ++++++- editor/editor_node.cpp | 17 +++++++++++++---- editor/editor_node.h | 2 ++ editor/editor_settings.cpp | 2 ++ 4 files changed, 23 insertions(+), 5 deletions(-) diff --git a/doc/classes/EditorSettings.xml b/doc/classes/EditorSettings.xml index 1cc249ec4876..b0949ec377b9 100644 --- a/doc/classes/EditorSettings.xml +++ b/doc/classes/EditorSettings.xml @@ -613,7 +613,12 @@ If enabled, displays internal engine errors in toast notifications (toggleable by clicking the "bell" icon at the bottom of the editor). No matter the value of this setting, non-internal engine errors will always be visible in toast notifications. - The default [b]Auto[/b] value will only enable this if the editor was compiled with the [code]dev=yes[/code] option (the default is [code]dev=no[/code]). + The default [b]Auto[/b] value will only enable this if the editor was compiled with the [code]dev_build=yes[/code] SCons option (the default is [code]dev_build=no[/code]). + + + If enabled, displays an icon in the top-right corner of the editor that spins when the editor redraws a frame. This can be used to diagnose situations where the engine is constantly redrawing, which should be avoided as this increases CPU and GPU utilization for no good reason. To further troubleshoot these situations, start the editor with the [code]--debug-canvas-item-redraw[/code] [url=$DOCS_URL/tutorials/editor/command_line_tutorial.html]command line argument[/url]. + Consider enabling this if you are developing editor plugins to ensure they only make the editor redraw when required. + The default [b]Auto[/b] value will only enable this if the editor was compiled with the [code]dev_build=yes[/code] SCons option (the default is [code]dev_build=no[/code]). If [code]true[/code], embed modal windows such as docks inside the main editor window. When single-window mode is enabled, tooltips will also be embedded inside the main editor window, which means they can't be displayed outside of the editor window. diff --git a/editor/editor_node.cpp b/editor/editor_node.cpp index 07a048c60723..6ec656d588d7 100644 --- a/editor/editor_node.cpp +++ b/editor/editor_node.cpp @@ -610,7 +610,7 @@ void EditorNode::_notification(int p_what) { update_spinner_step_frame = frame + 1; // Update the icon itself only when the spinner is visible. - if (EDITOR_GET("interface/editor/show_update_spinner")) { + if (_should_display_update_spinner()) { update_spinner->set_icon(theme->get_icon("Progress" + itos(update_spinner_step + 1), EditorStringName(EditorIcons))); } } @@ -798,7 +798,7 @@ void EditorNode::_notification(int p_what) { } void EditorNode::_update_update_spinner() { - update_spinner->set_visible(!RenderingServer::get_singleton()->canvas_item_get_debug_redraw() && EDITOR_GET("interface/editor/show_update_spinner")); + update_spinner->set_visible(!RenderingServer::get_singleton()->canvas_item_get_debug_redraw() && _should_display_update_spinner()); const bool update_continuously = EDITOR_GET("interface/editor/update_continuously"); PopupMenu *update_popup = update_spinner->get_popup(); @@ -2913,7 +2913,7 @@ void EditorNode::_menu_option_confirm(int p_option, bool p_confirmed) { _update_update_spinner(); } break; case SETTINGS_UPDATE_SPINNER_HIDE: { - EditorSettings::get_singleton()->set("interface/editor/show_update_spinner", false); + EditorSettings::get_singleton()->set("interface/editor/show_update_spinner", 2); // Disabled _update_update_spinner(); } break; case SETTINGS_PREFERENCES: { @@ -4632,6 +4632,16 @@ String EditorNode::_get_system_info() const { return String(" - ").join(info); } +bool EditorNode::_should_display_update_spinner() const { +#ifdef DEV_ENABLED + const bool in_dev = true; +#else + const bool in_dev = false; +#endif + const int show_update_spinner_setting = EDITOR_GET("interface/editor/show_update_spinner"); + return (show_update_spinner_setting == 0 && in_dev) || show_update_spinner_setting == 1; +} + Ref EditorNode::_file_dialog_get_icon(const String &p_path) { EditorFileSystemDirectory *efsd = EditorFileSystem::get_singleton()->get_filesystem_path(p_path.get_base_dir()); if (efsd) { @@ -6476,7 +6486,6 @@ EditorNode::EditorNode() { register_exporters(); EDITOR_DEF("interface/editor/save_on_focus_loss", false); - EDITOR_DEF("interface/editor/show_update_spinner", false); EDITOR_DEF("interface/editor/update_continuously", false); EDITOR_DEF("interface/editor/localize_settings", true); EDITOR_DEF_RST("interface/scene_tabs/restore_scenes_on_load", true); diff --git a/editor/editor_node.h b/editor/editor_node.h index 04d7b921c590..f1f75ddd8411 100644 --- a/editor/editor_node.h +++ b/editor/editor_node.h @@ -488,6 +488,8 @@ class EditorNode : public Node { String _get_system_info() const; + bool _should_display_update_spinner() const; + static void _dependency_error_report(const String &p_path, const String &p_dep, const String &p_type) { DEV_ASSERT(Thread::get_caller_id() == Thread::get_main_id()); if (!singleton->dependency_errors.has(p_path)) { diff --git a/editor/editor_settings.cpp b/editor/editor_settings.cpp index 9d43fc4d223a..67006196eea9 100644 --- a/editor/editor_settings.cpp +++ b/editor/editor_settings.cpp @@ -452,8 +452,10 @@ void EditorSettings::_load_defaults(Ref p_extra_config) { PROPERTY_USAGE_DEFAULT | PROPERTY_USAGE_RESTART_IF_CHANGED); #ifdef DEV_ENABLED EDITOR_SETTING(Variant::INT, PROPERTY_HINT_ENUM, "interface/editor/show_internal_errors_in_toast_notifications", 0, "Auto (Enabled),Enabled,Disabled") + EDITOR_SETTING(Variant::INT, PROPERTY_HINT_ENUM, "interface/editor/show_update_spinner", 0, "Auto (Enabled),Enabled,Disabled") #else EDITOR_SETTING(Variant::INT, PROPERTY_HINT_ENUM, "interface/editor/show_internal_errors_in_toast_notifications", 0, "Auto (Disabled),Enabled,Disabled") + EDITOR_SETTING(Variant::INT, PROPERTY_HINT_ENUM, "interface/editor/show_update_spinner", 0, "Auto (Disabled),Enabled,Disabled") #endif // Inspector