Răsfoiți Sursa

Merge pull request #33078 from Calinou/assetlib-no-results-message

Display a message if no results are found in the asset library
Rémi Verschelde 5 ani în urmă
părinte
comite
a8e007f055

+ 14 - 1
editor/plugins/asset_library_editor_plugin.cpp

@@ -1137,9 +1137,12 @@ void EditorAssetLibrary::_http_request_completed(int p_status, int p_code, const
 
 			initial_loading = false;
 
-			// The loading text only needs to be displayed before the first page is loaded
+			// The loading text only needs to be displayed before the first page is loaded.
+			// Therefore, we don't need to show it again.
 			library_loading->hide();
 
+			library_error->hide();
+
 			if (asset_items) {
 				memdelete(asset_items);
 			}
@@ -1187,6 +1190,11 @@ void EditorAssetLibrary::_http_request_completed(int p_status, int p_code, const
 			asset_bottom_page = _make_pages(page, pages, page_len, total_items, result.size());
 			library_vb->add_child(asset_bottom_page);
 
+			if (result.empty()) {
+				library_error->set_text(vformat(TTR("No results for \"%s\"."), filter->get_text()));
+				library_error->show();
+			}
+
 			for (int i = 0; i < result.size(); i++) {
 
 				Dictionary r = result[i];
@@ -1453,6 +1461,11 @@ EditorAssetLibrary::EditorAssetLibrary(bool p_templates_only) {
 	library_loading->set_align(Label::ALIGN_CENTER);
 	library_vb->add_child(library_loading);
 
+	library_error = memnew(Label);
+	library_error->set_align(Label::ALIGN_CENTER);
+	library_error->hide();
+	library_vb->add_child(library_error);
+
 	asset_top_page = memnew(HBoxContainer);
 	library_vb->add_child(asset_top_page);
 

+ 1 - 0
editor/plugins/asset_library_editor_plugin.h

@@ -184,6 +184,7 @@ class EditorAssetLibrary : public PanelContainer {
 	ScrollContainer *library_scroll;
 	VBoxContainer *library_vb;
 	Label *library_loading;
+	Label *library_error;
 	LineEdit *filter;
 	OptionButton *categories;
 	OptionButton *repository;