Display a message if no results are found in the asset library

This closes https://github.com/godotengine/godot-proposals/issues/184.
This commit is contained in:
Hugo Locurcio 2019-10-26 01:07:02 +02:00
parent 5cdecb8227
commit 41c89880f8
No known key found for this signature in database
GPG Key ID: 39E8F8BE30B0A49C
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;