From 236cec06330f321e92867b30abbd168d7ea0b3aa Mon Sep 17 00:00:00 2001 From: Yuri Sizov Date: Fri, 17 Feb 2023 22:37:38 +0100 Subject: Add a custom icon for the `project.godot` file in the EditorFileDialog --- editor/project_manager.cpp | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) (limited to 'editor/project_manager.cpp') diff --git a/editor/project_manager.cpp b/editor/project_manager.cpp index dc019d8e7c..1d510703b0 100644 --- a/editor/project_manager.cpp +++ b/editor/project_manager.cpp @@ -2013,16 +2013,25 @@ void ProjectManager::_notification(int p_what) { } Ref ProjectManager::_file_dialog_get_icon(const String &p_path) { - return singleton->icon_type_cache["ObjectHR"]; + if (p_path.get_extension().to_lower() == "godot") { + return singleton->icon_type_cache["GodotMonochrome"]; + } + + return singleton->icon_type_cache["Object"]; +} + +Ref ProjectManager::_file_dialog_get_thumbnail(const String &p_path) { + if (p_path.get_extension().to_lower() == "godot") { + return singleton->icon_type_cache["GodotFile"]; + } + + return Ref(); } void ProjectManager::_build_icon_type_cache(Ref p_theme) { List tl; p_theme->get_icon_list(SNAME("EditorIcons"), &tl); for (List::Element *E = tl.front(); E; E = E->next()) { - if (!ClassDB::class_exists(E->get())) { - continue; - } icon_type_cache[E->get()] = p_theme->get_icon(E->get(), SNAME("EditorIcons")); } } @@ -2651,6 +2660,7 @@ ProjectManager::ProjectManager() { break; } EditorFileDialog::get_icon_func = &ProjectManager::_file_dialog_get_icon; + EditorFileDialog::get_thumbnail_func = &ProjectManager::_file_dialog_get_thumbnail; } // TRANSLATORS: This refers to the application where users manage their Godot projects. -- cgit v1.2.3