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

Display a message if no results are found in the asset library
This commit is contained in:
Rémi Verschelde 2019-10-26 09:12:29 +02:00 committed by GitHub
commit a8e007f055
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 15 additions and 1 deletions

View file

@ -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);

View file

@ -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;