diff options
Diffstat (limited to 'editor/project_manager.cpp')
-rw-r--r-- | editor/project_manager.cpp | 60 |
1 files changed, 44 insertions, 16 deletions
diff --git a/editor/project_manager.cpp b/editor/project_manager.cpp index 57e47a15fd..1cd13e10c8 100644 --- a/editor/project_manager.cpp +++ b/editor/project_manager.cpp @@ -30,6 +30,7 @@ #include "project_manager.h" +#include "core/config/project_settings.h" #include "core/io/config_file.h" #include "core/io/dir_access.h" #include "core/io/file_access.h" @@ -40,10 +41,11 @@ #include "core/os/os.h" #include "core/string/translation.h" #include "core/version.h" +#include "editor/editor_file_dialog.h" +#include "editor/editor_scale.h" +#include "editor/editor_settings.h" +#include "editor/editor_themes.h" #include "editor/editor_vcs_interface.h" -#include "editor_scale.h" -#include "editor_settings.h" -#include "editor_themes.h" #include "scene/gui/center_container.h" #include "scene/gui/line_edit.h" #include "scene/gui/margin_container.h" @@ -53,6 +55,7 @@ #include "scene/main/window.h" #include "servers/display_server.h" #include "servers/navigation_server_3d.h" +#include "servers/physics_server_2d.h" static inline String get_project_key_from_path(const String &dir) { return dir.replace("/", "::"); @@ -98,8 +101,8 @@ private: LineEdit *install_path; TextureRect *status_rect; TextureRect *install_status_rect; - FileDialog *fdialog; - FileDialog *fdialog_install; + EditorFileDialog *fdialog; + EditorFileDialog *fdialog_install; OptionButton *vcs_metadata_selection; String zip_path; String zip_title; @@ -363,19 +366,19 @@ private: fdialog->set_current_dir(project_path->get_text()); if (mode == MODE_IMPORT) { - fdialog->set_file_mode(FileDialog::FILE_MODE_OPEN_FILE); + fdialog->set_file_mode(EditorFileDialog::FILE_MODE_OPEN_FILE); fdialog->clear_filters(); fdialog->add_filter(vformat("project.godot ; %s %s", VERSION_NAME, TTR("Project"))); fdialog->add_filter("*.zip ; " + TTR("ZIP File")); } else { - fdialog->set_file_mode(FileDialog::FILE_MODE_OPEN_DIR); + fdialog->set_file_mode(EditorFileDialog::FILE_MODE_OPEN_DIR); } fdialog->popup_file_dialog(); } void _browse_install_path() { fdialog_install->set_current_dir(install_path->get_text()); - fdialog_install->set_file_mode(FileDialog::FILE_MODE_OPEN_DIR); + fdialog_install->set_file_mode(EditorFileDialog::FILE_MODE_OPEN_DIR); fdialog_install->popup_file_dialog(); } @@ -923,12 +926,15 @@ public: spacer->set_h_size_flags(Control::SIZE_EXPAND_FILL); default_files_container->add_child(spacer); - fdialog = memnew(FileDialog); - fdialog->set_access(FileDialog::ACCESS_FILESYSTEM); - fdialog_install = memnew(FileDialog); - fdialog_install->set_access(FileDialog::ACCESS_FILESYSTEM); + fdialog = memnew(EditorFileDialog); + fdialog->set_previews_enabled(false); //Crucial, otherwise the engine crashes. + fdialog->set_access(EditorFileDialog::ACCESS_FILESYSTEM); + fdialog_install = memnew(EditorFileDialog); + fdialog_install->set_previews_enabled(false); //Crucial, otherwise the engine crashes. + fdialog_install->set_access(EditorFileDialog::ACCESS_FILESYSTEM); add_child(fdialog); add_child(fdialog_install); + project_name->connect("text_changed", callable_mp(this, &ProjectDialog::_text_changed)); project_path->connect("text_changed", callable_mp(this, &ProjectDialog::_path_text_changed)); install_path->connect("text_changed", callable_mp(this, &ProjectDialog::_path_text_changed)); @@ -1902,6 +1908,23 @@ void ProjectManager::_notification(int p_what) { } } +Map<String, Ref<Texture2D>> ProjectManager::icon_type_cache; + +Ref<Texture2D> ProjectManager::_file_dialog_get_icon(const String &p_path) { + return icon_type_cache["ObjectHR"]; +} + +void ProjectManager::_build_icon_type_cache(Ref<Theme> p_theme) { + List<StringName> tl; + p_theme->get_icon_list(SNAME("EditorIcons"), &tl); + for (List<StringName>::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")); + } +} + void ProjectManager::_dim_window() { // This method must be called before calling `get_tree()->quit()`. // Otherwise, its effect won't be visible @@ -2508,12 +2531,14 @@ ProjectManager::ProjectManager() { float scale_factor = MAX(1, EDSCALE); Vector2i window_size = DisplayServer::get_singleton()->window_get_size(); DisplayServer::get_singleton()->window_set_size(Vector2i(window_size.x * scale_factor, window_size.y * scale_factor)); + + EditorFileDialog::get_icon_func = &ProjectManager::_file_dialog_get_icon; } // TRANSLATORS: This refers to the application where users manage their Godot projects. DisplayServer::get_singleton()->window_set_title(VERSION_NAME + String(" - ") + TTR("Project Manager")); - FileDialog::set_default_show_hidden_files(EditorSettings::get_singleton()->get("filesystem/file_dialog/show_hidden_files")); + EditorFileDialog::set_default_show_hidden_files(EditorSettings::get_singleton()->get("filesystem/file_dialog/show_hidden_files")); set_anchors_and_offsets_preset(Control::PRESET_WIDE); set_theme(create_custom_theme()); @@ -2744,9 +2769,10 @@ ProjectManager::ProjectManager() { language_restart_ask->get_cancel_button()->set_text(TTR("Continue")); add_child(language_restart_ask); - scan_dir = memnew(FileDialog); - scan_dir->set_access(FileDialog::ACCESS_FILESYSTEM); - scan_dir->set_file_mode(FileDialog::FILE_MODE_OPEN_DIR); + scan_dir = memnew(EditorFileDialog); + scan_dir->set_previews_enabled(false); + scan_dir->set_access(EditorFileDialog::ACCESS_FILESYSTEM); + scan_dir->set_file_mode(EditorFileDialog::FILE_MODE_OPEN_DIR); scan_dir->set_title(TTR("Select a Folder to Scan")); // must be after mode or it's overridden scan_dir->set_current_dir(EditorSettings::get_singleton()->get("filesystem/directories/default_project_path")); add_child(scan_dir); @@ -2810,6 +2836,8 @@ ProjectManager::ProjectManager() { about = memnew(EditorAbout); add_child(about); + + _build_icon_type_cache(get_theme()); } _load_recent_projects(); |