diff options
Diffstat (limited to 'editor/editor_node.cpp')
-rw-r--r-- | editor/editor_node.cpp | 59 |
1 files changed, 7 insertions, 52 deletions
diff --git a/editor/editor_node.cpp b/editor/editor_node.cpp index 635f6d4fc7..7574951e2c 100644 --- a/editor/editor_node.cpp +++ b/editor/editor_node.cpp @@ -2632,11 +2632,8 @@ void EditorNode::_exit_editor() { resource_preview->stop(); //stop early to avoid crashes _save_docks(); - // Dim the editor window while it's quitting to make it clearer that it's busy. - // No transition is applied, as the effect needs to be visible immediately - float c = 0.4f; - Color dim_color = Color(c, c, c); - gui_base->set_modulate(dim_color); + // Dim the editor window while it's quitting to make it clearer that it's busy + dim_editor(true, true); get_tree()->quit(); } @@ -5133,46 +5130,12 @@ void EditorNode::_open_imported() { load_scene(open_import_request, true, false, true, true); } -void EditorNode::dim_editor(bool p_dimming) { - static int dim_count = 0; - bool dim_ui = EditorSettings::get_singleton()->get("interface/editor/dim_editor_on_dialog_popup"); - if (p_dimming) { - if (dim_ui && dim_count == 0) { - _start_dimming(true); - } - dim_count++; - } else { - if (dim_count == 1) { - _start_dimming(false); - } - if (dim_count > 0) { - dim_count--; - } else { - ERR_PRINT("Undimmed before dimming!"); - } - } -} - -void EditorNode::_start_dimming(bool p_dimming) { - _dimming = p_dimming; - _dim_time = 0.0f; - _dim_timer->start(); -} - -void EditorNode::_dim_timeout() { - - _dim_time += _dim_timer->get_wait_time(); - float wait_time = 0.08f; - float c = 0.4f; - - Color base = _dimming ? Color(1, 1, 1) : Color(c, c, c); - Color final = _dimming ? Color(c, c, c) : Color(1, 1, 1); - - if (_dim_time + _dim_timer->get_wait_time() >= wait_time) { - gui_base->set_modulate(final); - _dim_timer->stop(); +void EditorNode::dim_editor(bool p_dimming, bool p_force_dim) { + // Dimming can be forced regardless of the editor setting, which is useful when quitting the editor + if ((p_force_dim || EditorSettings::get_singleton()->get("interface/editor/dim_editor_on_dialog_popup")) && p_dimming) { + gui_base->set_modulate(Color(0.5, 0.5, 0.5)); } else { - gui_base->set_modulate(base.linear_interpolate(final, _dim_time / wait_time)); + gui_base->set_modulate(Color(1, 1, 1)); } } @@ -5356,7 +5319,6 @@ void EditorNode::_bind_methods() { ClassDB::bind_method(D_METHOD("_open_imported"), &EditorNode::_open_imported); ClassDB::bind_method(D_METHOD("_inherit_imported"), &EditorNode::_inherit_imported); - ClassDB::bind_method(D_METHOD("_dim_timeout"), &EditorNode::_dim_timeout); ClassDB::bind_method("_copy_warning", &EditorNode::_copy_warning); @@ -6687,13 +6649,6 @@ EditorNode::EditorNode() { waiting_for_first_scan = true; - _dimming = false; - _dim_time = 0.0f; - _dim_timer = memnew(Timer); - _dim_timer->set_wait_time(0.01666f); - _dim_timer->connect("timeout", this, "_dim_timeout"); - add_child(_dim_timer); - print_handler.printfunc = _print_handler; print_handler.userdata = this; add_print_handler(&print_handler); |