1
0
mirror of https://github.com/godotengine/godot.git synced 2025-11-06 12:20:30 +00:00

Handle AssetLib repository config error

This commit is contained in:
Haoyu Qiu
2022-05-04 17:49:11 +08:00
parent a9ebf121f8
commit c0516c2312
2 changed files with 49 additions and 16 deletions

View File

@@ -897,6 +897,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");
@@ -965,6 +978,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);
@@ -1106,6 +1123,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;
}
@@ -1140,17 +1161,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);
}
@@ -1200,16 +1220,18 @@ void EditorAssetLibrary::_http_request_completed(int p_status, int p_code, const
if (result.is_empty()) {
if (!filter->get_text().is_empty()) {
library_error->set_text(
library_info->set_text(
vformat(TTR("No results for \"%s\"."), filter->get_text()));
} else {
// No results, even though the user didn't search for anything specific.
// This is typically because the version number changed recently
// and no assets compatible with the new version have been published yet.
library_error->set_text(
library_info->set_text(
vformat(TTR("No results compatible with %s %s."), String(VERSION_SHORT_NAME).capitalize(), String(VERSION_BRANCH)));
}
library_error->show();
library_info->show();
} else {
library_info->hide();
}
for (int i = 0; i < result.size(); i++) {
@@ -1488,15 +1510,23 @@ EditorAssetLibrary::EditorAssetLibrary(bool p_templates_only) {
library_vb_border->add_child(library_vb);
library_loading = memnew(Label(TTR("Loading...")));
library_loading->set_horizontal_alignment(HORIZONTAL_ALIGNMENT_CENTER);
library_vb->add_child(library_loading);
library_info = memnew(Label);
library_info->set_horizontal_alignment(HORIZONTAL_ALIGNMENT_CENTER);
library_vb->add_child(library_info);
library_error = memnew(Label);
library_error->set_horizontal_alignment(HORIZONTAL_ALIGNMENT_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_horizontal_alignment(HORIZONTAL_ALIGNMENT_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", callable_mp(this, &EditorAssetLibrary::_request_current_config));
library_error->add_child(library_error_retry);
asset_top_page = memnew(HBoxContainer);
library_vb->add_child(asset_top_page);