Merge pull request #60758 from timothyqiu/asset-lib-error-3.x
This commit is contained in:
commit
f05104f99c
|
@ -891,6 +891,19 @@ void EditorAssetLibrary::_request_image(ObjectID p_for, String p_image_url, Imag
|
|||
}
|
||||
|
||||
void EditorAssetLibrary::_repository_changed(int p_repository_id) {
|
||||
library_error->hide();
|
||||
library_info->set_text(TTR("Loading..."));
|
||||
library_info->show();
|
||||
|
||||
asset_top_page->hide();
|
||||
asset_bottom_page->hide();
|
||||
asset_items->hide();
|
||||
|
||||
filter->set_editable(false);
|
||||
sort->set_disabled(true);
|
||||
categories->set_disabled(true);
|
||||
support->set_disabled(true);
|
||||
|
||||
host = repository->get_item_metadata(p_repository_id);
|
||||
if (templates_only) {
|
||||
_api_request("configure", REQUESTING_CONFIG, "?type=project");
|
||||
|
@ -959,6 +972,10 @@ void EditorAssetLibrary::_filter_debounce_timer_timeout() {
|
|||
_search();
|
||||
}
|
||||
|
||||
void EditorAssetLibrary::_request_current_config() {
|
||||
_repository_changed(repository->get_selected());
|
||||
}
|
||||
|
||||
HBoxContainer *EditorAssetLibrary::_make_pages(int p_page, int p_page_count, int p_page_len, int p_total_items, int p_current_items) {
|
||||
HBoxContainer *hbc = memnew(HBoxContainer);
|
||||
|
||||
|
@ -1100,6 +1117,10 @@ void EditorAssetLibrary::_http_request_completed(int p_status, int p_code, const
|
|||
}
|
||||
|
||||
if (error_abort) {
|
||||
if (requesting == REQUESTING_CONFIG) {
|
||||
library_info->hide();
|
||||
library_error->show();
|
||||
}
|
||||
error_hb->show();
|
||||
return;
|
||||
}
|
||||
|
@ -1136,17 +1157,16 @@ void EditorAssetLibrary::_http_request_completed(int p_status, int p_code, const
|
|||
}
|
||||
}
|
||||
|
||||
filter->set_editable(true);
|
||||
sort->set_disabled(false);
|
||||
categories->set_disabled(false);
|
||||
support->set_disabled(false);
|
||||
|
||||
_search();
|
||||
} break;
|
||||
case REQUESTING_SEARCH: {
|
||||
initial_loading = false;
|
||||
|
||||
// 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);
|
||||
}
|
||||
|
@ -1195,8 +1215,10 @@ void EditorAssetLibrary::_http_request_completed(int p_status, int p_code, const
|
|||
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();
|
||||
library_info->set_text(vformat(TTR("No results for \"%s\"."), filter->get_text()));
|
||||
library_info->show();
|
||||
} else {
|
||||
library_info->hide();
|
||||
}
|
||||
|
||||
for (int i = 0; i < result.size(); i++) {
|
||||
|
@ -1328,6 +1350,7 @@ void EditorAssetLibrary::_bind_methods() {
|
|||
ClassDB::bind_method("_search", &EditorAssetLibrary::_search, DEFVAL(0));
|
||||
ClassDB::bind_method("_search_text_changed", &EditorAssetLibrary::_search_text_changed);
|
||||
ClassDB::bind_method("_filter_debounce_timer_timeout", &EditorAssetLibrary::_filter_debounce_timer_timeout);
|
||||
ClassDB::bind_method("_request_current_config", &EditorAssetLibrary::_request_current_config);
|
||||
ClassDB::bind_method("_install_asset", &EditorAssetLibrary::_install_asset);
|
||||
ClassDB::bind_method("_manage_plugins", &EditorAssetLibrary::_manage_plugins);
|
||||
ClassDB::bind_method("_asset_open", &EditorAssetLibrary::_asset_open);
|
||||
|
@ -1469,15 +1492,23 @@ EditorAssetLibrary::EditorAssetLibrary(bool p_templates_only) {
|
|||
|
||||
library_vb_border->add_child(library_vb);
|
||||
|
||||
library_loading = memnew(Label(TTR("Loading...")));
|
||||
library_loading->set_align(Label::ALIGN_CENTER);
|
||||
library_vb->add_child(library_loading);
|
||||
library_info = memnew(Label);
|
||||
library_info->set_align(Label::ALIGN_CENTER);
|
||||
library_vb->add_child(library_info);
|
||||
|
||||
library_error = memnew(Label);
|
||||
library_error->set_align(Label::ALIGN_CENTER);
|
||||
library_error = memnew(VBoxContainer);
|
||||
library_error->hide();
|
||||
library_vb->add_child(library_error);
|
||||
|
||||
library_error_label = memnew(Label(TTR("Failed to get repository configuration.")));
|
||||
library_error_label->set_align(Label::ALIGN_CENTER);
|
||||
library_error->add_child(library_error_label);
|
||||
|
||||
library_error_retry = memnew(Button(TTR("Retry")));
|
||||
library_error_retry->set_h_size_flags(SIZE_SHRINK_CENTER);
|
||||
library_error_retry->connect("pressed", this, "_request_current_config");
|
||||
library_error->add_child(library_error_retry);
|
||||
|
||||
asset_top_page = memnew(HBoxContainer);
|
||||
library_vb->add_child(asset_top_page);
|
||||
|
||||
|
|
|
@ -181,8 +181,10 @@ class EditorAssetLibrary : public PanelContainer {
|
|||
PanelContainer *library_scroll_bg;
|
||||
ScrollContainer *library_scroll;
|
||||
VBoxContainer *library_vb;
|
||||
Label *library_loading;
|
||||
Label *library_error;
|
||||
Label *library_info;
|
||||
VBoxContainer *library_error;
|
||||
Label *library_error_label;
|
||||
Button *library_error_retry;
|
||||
LineEdit *filter;
|
||||
Timer *filter_debounce_timer;
|
||||
OptionButton *categories;
|
||||
|
@ -285,6 +287,7 @@ class EditorAssetLibrary : public PanelContainer {
|
|||
void _api_request(const String &p_request, RequestType p_request_type, const String &p_arguments = "");
|
||||
void _http_request_completed(int p_status, int p_code, const PoolStringArray &headers, const PoolByteArray &p_data);
|
||||
void _filter_debounce_timer_timeout();
|
||||
void _request_current_config();
|
||||
|
||||
void _repository_changed(int p_repository_id);
|
||||
void _support_toggled(int p_support);
|
||||
|
|
Loading…
Reference in New Issue