From c6f2db393e8d939dc0378826513ca09943660f31 Mon Sep 17 00:00:00 2001 From: Juan Linietsky Date: Sun, 26 Nov 2017 15:31:08 -0300 Subject: [PATCH] Ask users to explore official projects when none is loaded. --- .../plugins/asset_library_editor_plugin.cpp | 4 ++++ editor/plugins/asset_library_editor_plugin.h | 2 ++ editor/project_manager.cpp | 19 +++++++++++++++++++ editor/project_manager.h | 3 +++ 4 files changed, 28 insertions(+) diff --git a/editor/plugins/asset_library_editor_plugin.cpp b/editor/plugins/asset_library_editor_plugin.cpp index b63352389e2..eee54f3cd25 100644 --- a/editor/plugins/asset_library_editor_plugin.cpp +++ b/editor/plugins/asset_library_editor_plugin.cpp @@ -1268,6 +1268,10 @@ void EditorAssetLibrary::_install_external_asset(String p_zip_path, String p_tit emit_signal("install_asset", p_zip_path, p_title); } +void EditorAssetLibrary::disable_community_support() { + support->get_popup()->set_item_checked(SUPPORT_COMMUNITY, false); +} + void EditorAssetLibrary::_bind_methods() { ClassDB::bind_method("_http_request_completed", &EditorAssetLibrary::_http_request_completed); diff --git a/editor/plugins/asset_library_editor_plugin.h b/editor/plugins/asset_library_editor_plugin.h index 35977f39498..90d597e70af 100644 --- a/editor/plugins/asset_library_editor_plugin.h +++ b/editor/plugins/asset_library_editor_plugin.h @@ -301,6 +301,8 @@ protected: void _notification(int p_what); public: + void disable_community_support(); + EditorAssetLibrary(bool p_templates_only = false); }; diff --git a/editor/project_manager.cpp b/editor/project_manager.cpp index 46c47d86564..43c7f33cbe2 100644 --- a/editor/project_manager.cpp +++ b/editor/project_manager.cpp @@ -655,6 +655,12 @@ void ProjectManager::_notification(int p_what) { Engine::get_singleton()->set_editor_hint(false); + } else if (p_what == NOTIFICATION_READY) { + + if (scroll_childs->get_child_count() == 0) { + open_templates->popup_centered_minsize(); + } + } else if (p_what == NOTIFICATION_VISIBILITY_CHANGED) { set_process_unhandled_input(is_visible_in_tree()); @@ -1432,9 +1438,15 @@ void ProjectManager::_bind_methods() { ClassDB::bind_method("_favorite_pressed", &ProjectManager::_favorite_pressed); ClassDB::bind_method("_install_project", &ProjectManager::_install_project); ClassDB::bind_method("_files_dropped", &ProjectManager::_files_dropped); + ClassDB::bind_method("_open_asset_library", &ProjectManager::_open_asset_library); ClassDB::bind_method(D_METHOD("_scan_multiple_folders", "files"), &ProjectManager::_scan_multiple_folders); } +void ProjectManager::_open_asset_library() { + asset_library->disable_community_support(); + tabs->set_current_tab(1); +} + ProjectManager::ProjectManager() { // load settings @@ -1705,6 +1717,12 @@ ProjectManager::ProjectManager() { dialog_error = memnew(AcceptDialog); gui_base->add_child(dialog_error); + + open_templates = memnew(ConfirmationDialog); + open_templates->set_text(TTR("You don't currently have any projects.\nWould you like to explore the official example projects in the Asset Library?")); + open_templates->get_ok()->set_text(TTR("Open Asset Library")); + open_templates->connect("confirmed", this, "_open_asset_library"); + add_child(open_templates); } ProjectManager::~ProjectManager() { @@ -1756,6 +1774,7 @@ void ProjectListFilter::_notification(int p_what) { switch (p_what) { case NOTIFICATION_ENTER_TREE: { clear_search_button->set_icon(get_icon("Close", "EditorIcons")); + } break; } } diff --git a/editor/project_manager.h b/editor/project_manager.h index 656bd2d19c1..4080f1df225 100644 --- a/editor/project_manager.h +++ b/editor/project_manager.h @@ -76,6 +76,9 @@ class ProjectManager : public Control { Control *gui_base; + ConfirmationDialog *open_templates; + + void _open_asset_library(); void _scan_projects(); void _run_project(); void _run_project_confirm();