Skip to content

Commit

Permalink
Show update spinner by default in dev_build=yes editor builds
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
Calinou committed Feb 9, 2024
1 parent 4e990cd commit 7e25292
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 5 deletions.
7 changes: 6 additions & 1 deletion doc/classes/EditorSettings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -613,7 +613,12 @@
</member>
<member name="interface/editor/show_internal_errors_in_toast_notifications" type="int" setter="" getter="">
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]).
</member>
<member name="interface/editor/show_update_spinner" type="int" setter="" getter="">
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]).
</member>
<member name="interface/editor/single_window_mode" type="bool" setter="" getter="">
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.
Expand Down
17 changes: 13 additions & 4 deletions editor/editor_node.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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)));
}
}
Expand Down Expand Up @@ -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();
Expand Down Expand Up @@ -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: {
Expand Down Expand Up @@ -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<Texture2D> EditorNode::_file_dialog_get_icon(const String &p_path) {
EditorFileSystemDirectory *efsd = EditorFileSystem::get_singleton()->get_filesystem_path(p_path.get_base_dir());
if (efsd) {
Expand Down Expand Up @@ -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);
Expand Down
2 changes: 2 additions & 0 deletions editor/editor_node.h
Original file line number Diff line number Diff line change
Expand Up @@ -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)) {
Expand Down
2 changes: 2 additions & 0 deletions editor/editor_settings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -452,8 +452,10 @@ void EditorSettings::_load_defaults(Ref<ConfigFile> 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
Expand Down

0 comments on commit 7e25292

Please sign in to comment.