diff options
Diffstat (limited to 'editor')
-rw-r--r-- | editor/editor_node.cpp | 46 | ||||
-rw-r--r-- | editor/editor_node.h | 9 | ||||
-rw-r--r-- | editor/editor_settings.cpp | 5 |
3 files changed, 60 insertions, 0 deletions
diff --git a/editor/editor_node.cpp b/editor/editor_node.cpp index 00df0f337d..b74438f695 100644 --- a/editor/editor_node.cpp +++ b/editor/editor_node.cpp @@ -4716,6 +4716,44 @@ 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/dim_editor_on_dialog_popup"); + if (p_dimming) { + if (dim_ui && dim_count == 0) + _start_dimming(true); + dim_count++; + } else { + dim_count--; + if (dim_count < 1) + _start_dimming(false); + } +} + +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 = EditorSettings::get_singleton()->get("interface/dim_transition_time"); + + float c = 1.0f - (float)EditorSettings::get_singleton()->get("interface/dim_amount"); + + 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(); + } else { + gui_base->set_modulate(base.linear_interpolate(final, _dim_time / wait_time)); + } +} + void EditorNode::_bind_methods() { ClassDB::bind_method("_menu_option", &EditorNode::_menu_option); @@ -4792,6 +4830,7 @@ 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); ADD_SIGNAL(MethodInfo("play_pressed")); ADD_SIGNAL(MethodInfo("pause_pressed")); @@ -6102,6 +6141,13 @@ EditorNode::EditorNode() { FileAccess::set_file_close_fail_notify_callback(_file_access_close_error_notify); 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); } EditorNode::~EditorNode() { diff --git a/editor/editor_node.h b/editor/editor_node.h index cb165bdf21..ef8ae34475 100644 --- a/editor/editor_node.h +++ b/editor/editor_node.h @@ -598,6 +598,13 @@ private: void _tool_menu_insert_item(const ToolMenuItem &p_item); void _rebuild_tool_menu() const; + bool _dimming; + float _dim_time; + Timer *_dim_timer; + + void _start_dimming(bool p_dimming); + void _dim_timeout(); + protected: void _notification(int p_what); static void _bind_methods(); @@ -753,6 +760,8 @@ public: void add_tool_submenu_item(const String &p_name, PopupMenu *p_submenu); void remove_tool_menu_item(const String &p_name); + void dim_editor(bool p_dimming); + EditorNode(); ~EditorNode(); void get_singleton(const char *arg1, bool arg2); diff --git a/editor/editor_settings.cpp b/editor/editor_settings.cpp index 8794a34f62..9e5021af6e 100644 --- a/editor/editor_settings.cpp +++ b/editor/editor_settings.cpp @@ -502,6 +502,11 @@ void EditorSettings::_load_defaults(Ref<ConfigFile> p_extra_config) { hints["interface/custom_font"] = PropertyInfo(Variant::STRING, "interface/custom_font", PROPERTY_HINT_GLOBAL_FILE, "*.fnt", PROPERTY_USAGE_DEFAULT | PROPERTY_USAGE_RESTART_IF_CHANGED); set("interface/custom_theme", ""); hints["interface/custom_theme"] = PropertyInfo(Variant::STRING, "interface/custom_theme", PROPERTY_HINT_GLOBAL_FILE, "*.res,*.tres,*.theme", PROPERTY_USAGE_DEFAULT | PROPERTY_USAGE_RESTART_IF_CHANGED); + set("interface/dim_editor_on_dialog_popup", true); + set("interface/dim_amount", 0.6f); + hints["interface/dim_amount"] = PropertyInfo(Variant::REAL, "interface/dim_amount", PROPERTY_HINT_RANGE, "0,1,0.01", PROPERTY_USAGE_DEFAULT); + set("interface/dim_transition_time", 0.11f); + hints["interface/dim_transition_time"] = PropertyInfo(Variant::REAL, "interface/dim_transition_time", PROPERTY_HINT_RANGE, "0,1,0.001", PROPERTY_USAGE_DEFAULT); set("filesystem/directories/autoscan_project_path", ""); hints["filesystem/directories/autoscan_project_path"] = PropertyInfo(Variant::STRING, "filesystem/directories/autoscan_project_path", PROPERTY_HINT_GLOBAL_DIR); |