Handle AssetLib repository config error
This commit is contained in:
parent
a9ebf121f8
commit
c0516c2312
@ -897,6 +897,19 @@ void EditorAssetLibrary::_request_image(ObjectID p_for, String p_image_url, Imag
|
|||||||
}
|
}
|
||||||
|
|
||||||
void EditorAssetLibrary::_repository_changed(int p_repository_id) {
|
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);
|
host = repository->get_item_metadata(p_repository_id);
|
||||||
if (templates_only) {
|
if (templates_only) {
|
||||||
_api_request("configure", REQUESTING_CONFIG, "?type=project");
|
_api_request("configure", REQUESTING_CONFIG, "?type=project");
|
||||||
@ -965,6 +978,10 @@ void EditorAssetLibrary::_filter_debounce_timer_timeout() {
|
|||||||
_search();
|
_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 *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);
|
HBoxContainer *hbc = memnew(HBoxContainer);
|
||||||
|
|
||||||
@ -1106,6 +1123,10 @@ void EditorAssetLibrary::_http_request_completed(int p_status, int p_code, const
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (error_abort) {
|
if (error_abort) {
|
||||||
|
if (requesting == REQUESTING_CONFIG) {
|
||||||
|
library_info->hide();
|
||||||
|
library_error->show();
|
||||||
|
}
|
||||||
error_hb->show();
|
error_hb->show();
|
||||||
return;
|
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();
|
_search();
|
||||||
} break;
|
} break;
|
||||||
case REQUESTING_SEARCH: {
|
case REQUESTING_SEARCH: {
|
||||||
initial_loading = false;
|
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) {
|
if (asset_items) {
|
||||||
memdelete(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 (result.is_empty()) {
|
||||||
if (!filter->get_text().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()));
|
vformat(TTR("No results for \"%s\"."), filter->get_text()));
|
||||||
} else {
|
} else {
|
||||||
// No results, even though the user didn't search for anything specific.
|
// No results, even though the user didn't search for anything specific.
|
||||||
// This is typically because the version number changed recently
|
// This is typically because the version number changed recently
|
||||||
// and no assets compatible with the new version have been published yet.
|
// 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)));
|
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++) {
|
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_vb_border->add_child(library_vb);
|
||||||
|
|
||||||
library_loading = memnew(Label(TTR("Loading...")));
|
library_info = memnew(Label);
|
||||||
library_loading->set_horizontal_alignment(HORIZONTAL_ALIGNMENT_CENTER);
|
library_info->set_horizontal_alignment(HORIZONTAL_ALIGNMENT_CENTER);
|
||||||
library_vb->add_child(library_loading);
|
library_vb->add_child(library_info);
|
||||||
|
|
||||||
library_error = memnew(Label);
|
library_error = memnew(VBoxContainer);
|
||||||
library_error->set_horizontal_alignment(HORIZONTAL_ALIGNMENT_CENTER);
|
|
||||||
library_error->hide();
|
library_error->hide();
|
||||||
library_vb->add_child(library_error);
|
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);
|
asset_top_page = memnew(HBoxContainer);
|
||||||
library_vb->add_child(asset_top_page);
|
library_vb->add_child(asset_top_page);
|
||||||
|
|
||||||
|
@ -186,8 +186,10 @@ class EditorAssetLibrary : public PanelContainer {
|
|||||||
PanelContainer *library_scroll_bg = nullptr;
|
PanelContainer *library_scroll_bg = nullptr;
|
||||||
ScrollContainer *library_scroll = nullptr;
|
ScrollContainer *library_scroll = nullptr;
|
||||||
VBoxContainer *library_vb = nullptr;
|
VBoxContainer *library_vb = nullptr;
|
||||||
Label *library_loading = nullptr;
|
Label *library_info = nullptr;
|
||||||
Label *library_error = nullptr;
|
VBoxContainer *library_error = nullptr;
|
||||||
|
Label *library_error_label = nullptr;
|
||||||
|
Button *library_error_retry = nullptr;
|
||||||
LineEdit *filter = nullptr;
|
LineEdit *filter = nullptr;
|
||||||
Timer *filter_debounce_timer = nullptr;
|
Timer *filter_debounce_timer = nullptr;
|
||||||
OptionButton *categories = nullptr;
|
OptionButton *categories = nullptr;
|
||||||
@ -291,6 +293,7 @@ class EditorAssetLibrary : public PanelContainer {
|
|||||||
void _api_request(const String &p_request, RequestType p_request_type, const String &p_arguments = "");
|
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 PackedStringArray &headers, const PackedByteArray &p_data);
|
void _http_request_completed(int p_status, int p_code, const PackedStringArray &headers, const PackedByteArray &p_data);
|
||||||
void _filter_debounce_timer_timeout();
|
void _filter_debounce_timer_timeout();
|
||||||
|
void _request_current_config();
|
||||||
EditorAssetLibraryItemDownload *_get_asset_in_progress(int p_asset_id) const;
|
EditorAssetLibraryItemDownload *_get_asset_in_progress(int p_asset_id) const;
|
||||||
|
|
||||||
void _repository_changed(int p_repository_id);
|
void _repository_changed(int p_repository_id);
|
||||||
|
Loading…
Reference in New Issue
Block a user