mirror of
https://github.com/godotengine/godot.git
synced 2024-11-24 21:22:48 +00:00
Asset Library author link, description popup size and UX details
This commit is contained in:
parent
4e990cd7e5
commit
38ac946af7
@ -93,6 +93,12 @@ void EditorAssetLibraryItem::_notification(int p_what) {
|
||||
category->add_theme_color_override("font_color", Color(0.5, 0.5, 0.5));
|
||||
author->add_theme_color_override("font_color", Color(0.5, 0.5, 0.5));
|
||||
price->add_theme_color_override("font_color", Color(0.5, 0.5, 0.5));
|
||||
|
||||
if (author->get_default_cursor_shape() == CURSOR_ARROW) {
|
||||
// Disable visible feedback if author link isn't clickable.
|
||||
author->add_theme_color_override("font_pressed_color", Color(0.5, 0.5, 0.5));
|
||||
author->add_theme_color_override("font_hover_color", Color(0.5, 0.5, 0.5));
|
||||
}
|
||||
} break;
|
||||
}
|
||||
}
|
||||
@ -106,7 +112,7 @@ void EditorAssetLibraryItem::_category_clicked() {
|
||||
}
|
||||
|
||||
void EditorAssetLibraryItem::_author_clicked() {
|
||||
emit_signal(SNAME("author_selected"), author_id);
|
||||
emit_signal(SNAME("author_selected"), author->get_text());
|
||||
}
|
||||
|
||||
void EditorAssetLibraryItem::_bind_methods() {
|
||||
@ -116,7 +122,7 @@ void EditorAssetLibraryItem::_bind_methods() {
|
||||
ADD_SIGNAL(MethodInfo("author_selected"));
|
||||
}
|
||||
|
||||
EditorAssetLibraryItem::EditorAssetLibraryItem() {
|
||||
EditorAssetLibraryItem::EditorAssetLibraryItem(bool p_clickable) {
|
||||
Ref<StyleBoxEmpty> border;
|
||||
border.instantiate();
|
||||
border->set_content_margin_all(5 * EDSCALE);
|
||||
@ -129,9 +135,6 @@ EditorAssetLibraryItem::EditorAssetLibraryItem() {
|
||||
|
||||
icon = memnew(TextureButton);
|
||||
icon->set_custom_minimum_size(Size2(64, 64) * EDSCALE);
|
||||
icon->set_default_cursor_shape(CURSOR_POINTING_HAND);
|
||||
icon->connect("pressed", callable_mp(this, &EditorAssetLibraryItem::_asset_clicked));
|
||||
|
||||
hb->add_child(icon);
|
||||
|
||||
VBoxContainer *vb = memnew(VBoxContainer);
|
||||
@ -141,23 +144,48 @@ EditorAssetLibraryItem::EditorAssetLibraryItem() {
|
||||
|
||||
title = memnew(LinkButton);
|
||||
title->set_underline_mode(LinkButton::UNDERLINE_MODE_ON_HOVER);
|
||||
title->connect("pressed", callable_mp(this, &EditorAssetLibraryItem::_asset_clicked));
|
||||
vb->add_child(title);
|
||||
|
||||
category = memnew(LinkButton);
|
||||
category->set_underline_mode(LinkButton::UNDERLINE_MODE_ON_HOVER);
|
||||
category->connect("pressed", callable_mp(this, &EditorAssetLibraryItem::_category_clicked));
|
||||
vb->add_child(category);
|
||||
|
||||
HBoxContainer *author_price_hbox = memnew(HBoxContainer);
|
||||
author_price_hbox->add_theme_constant_override("separation", 5 * EDSCALE);
|
||||
vb->add_child(author_price_hbox);
|
||||
|
||||
author = memnew(LinkButton);
|
||||
author->set_underline_mode(LinkButton::UNDERLINE_MODE_ON_HOVER);
|
||||
author->connect("pressed", callable_mp(this, &EditorAssetLibraryItem::_author_clicked));
|
||||
vb->add_child(author);
|
||||
author->set_tooltip_text(TTR("Author"));
|
||||
author_price_hbox->add_child(author);
|
||||
|
||||
author_price_hbox->add_child(memnew(HSeparator));
|
||||
|
||||
if (p_clickable) {
|
||||
author->set_underline_mode(LinkButton::UNDERLINE_MODE_ON_HOVER);
|
||||
icon->set_default_cursor_shape(CURSOR_POINTING_HAND);
|
||||
icon->connect("pressed", callable_mp(this, &EditorAssetLibraryItem::_asset_clicked));
|
||||
title->connect("pressed", callable_mp(this, &EditorAssetLibraryItem::_asset_clicked));
|
||||
category->connect("pressed", callable_mp(this, &EditorAssetLibraryItem::_category_clicked));
|
||||
author->connect("pressed", callable_mp(this, &EditorAssetLibraryItem::_author_clicked));
|
||||
} else {
|
||||
title->set_mouse_filter(MOUSE_FILTER_IGNORE);
|
||||
category->set_mouse_filter(MOUSE_FILTER_IGNORE);
|
||||
author->set_underline_mode(LinkButton::UNDERLINE_MODE_NEVER);
|
||||
author->set_default_cursor_shape(CURSOR_ARROW);
|
||||
}
|
||||
|
||||
Ref<StyleBoxEmpty> label_margin;
|
||||
label_margin.instantiate();
|
||||
label_margin->set_content_margin_all(0);
|
||||
|
||||
price = memnew(Label);
|
||||
vb->add_child(price);
|
||||
price->add_theme_style_override("normal", label_margin);
|
||||
price->set_tooltip_text(TTR("License"));
|
||||
price->set_mouse_filter(MOUSE_FILTER_PASS);
|
||||
|
||||
set_custom_minimum_size(Size2(250, 100) * EDSCALE);
|
||||
author_price_hbox->add_child(price);
|
||||
|
||||
set_custom_minimum_size(Size2(250, 80) * EDSCALE);
|
||||
set_h_size_flags(Control::SIZE_EXPAND_FILL);
|
||||
}
|
||||
|
||||
@ -262,6 +290,10 @@ void EditorAssetLibraryItemDescription::configure(const String &p_title, int p_a
|
||||
}
|
||||
|
||||
void EditorAssetLibraryItemDescription::add_preview(int p_id, bool p_video, const String &p_url) {
|
||||
if (preview_images.is_empty()) {
|
||||
previews_vbox->show();
|
||||
}
|
||||
|
||||
Preview new_preview;
|
||||
new_preview.id = p_id;
|
||||
new_preview.video_link = p_url;
|
||||
@ -290,7 +322,7 @@ EditorAssetLibraryItemDescription::EditorAssetLibraryItemDescription() {
|
||||
item = memnew(EditorAssetLibraryItem);
|
||||
|
||||
desc_vbox->add_child(item);
|
||||
desc_vbox->set_custom_minimum_size(Size2(440 * EDSCALE, 0));
|
||||
desc_vbox->set_custom_minimum_size(Size2(440 * EDSCALE, 440 * EDSCALE));
|
||||
|
||||
description = memnew(RichTextLabel);
|
||||
desc_vbox->add_child(description);
|
||||
@ -298,7 +330,9 @@ EditorAssetLibraryItemDescription::EditorAssetLibraryItemDescription() {
|
||||
description->connect("meta_clicked", callable_mp(this, &EditorAssetLibraryItemDescription::_link_click));
|
||||
description->add_theme_constant_override("line_separation", Math::round(5 * EDSCALE));
|
||||
|
||||
VBoxContainer *previews_vbox = memnew(VBoxContainer);
|
||||
previews_vbox = memnew(VBoxContainer);
|
||||
previews_vbox->hide(); // Will be shown if we add any previews later.
|
||||
|
||||
hbox->add_child(previews_vbox);
|
||||
previews_vbox->add_theme_constant_override("separation", 15 * EDSCALE);
|
||||
previews_vbox->set_v_size_flags(Control::SIZE_EXPAND_FILL);
|
||||
@ -736,8 +770,12 @@ const char *EditorAssetLibrary::support_text[SUPPORT_MAX] = {
|
||||
TTRC("Testing"),
|
||||
};
|
||||
|
||||
void EditorAssetLibrary::_select_author(int p_id) {
|
||||
// Open author window.
|
||||
void EditorAssetLibrary::_select_author(const String &p_author) {
|
||||
if (!host.contains("godotengine.org")) {
|
||||
// Don't open the link for alternative repositories.
|
||||
return;
|
||||
}
|
||||
OS::get_singleton()->shell_open("https://godotengine.org/asset-library/asset?user=" + p_author.uri_encode());
|
||||
}
|
||||
|
||||
void EditorAssetLibrary::_select_category(int p_id) {
|
||||
@ -1342,7 +1380,7 @@ void EditorAssetLibrary::_http_request_completed(int p_status, int p_code, const
|
||||
ERR_FAIL_COND(!category_map.has(r["category_id"]));
|
||||
ERR_CONTINUE(!r.has("cost"));
|
||||
|
||||
EditorAssetLibraryItem *item = memnew(EditorAssetLibraryItem);
|
||||
EditorAssetLibraryItem *item = memnew(EditorAssetLibraryItem(true));
|
||||
asset_items->add_child(item);
|
||||
item->configure(r["title"], r["asset_id"], category_map[r["category_id"]], r["category_id"], r["author"], r["author_id"], r["cost"]);
|
||||
item->clamp_width(asset_items_column_width);
|
||||
@ -1382,7 +1420,6 @@ void EditorAssetLibrary::_http_request_completed(int p_status, int p_code, const
|
||||
|
||||
description = memnew(EditorAssetLibraryItemDescription);
|
||||
add_child(description);
|
||||
description->popup_centered();
|
||||
description->connect("confirmed", callable_mp(this, &EditorAssetLibrary::_install_asset));
|
||||
|
||||
description->configure(r["title"], r["asset_id"], category_map[r["category_id"]], r["category_id"], r["author"], r["author_id"], r["cost"], r["version"], r["version_string"], r["description"], r["download_url"], r["browse_url"], r["download_hash"]);
|
||||
@ -1431,6 +1468,8 @@ void EditorAssetLibrary::_http_request_completed(int p_status, int p_code, const
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
description->popup_centered();
|
||||
} break;
|
||||
default:
|
||||
break;
|
||||
|
@ -60,7 +60,6 @@ class EditorAssetLibraryItem : public PanelContainer {
|
||||
LinkButton *title = nullptr;
|
||||
LinkButton *category = nullptr;
|
||||
LinkButton *author = nullptr;
|
||||
TextureRect *stars[5];
|
||||
Label *price = nullptr;
|
||||
|
||||
int asset_id = 0;
|
||||
@ -82,7 +81,7 @@ public:
|
||||
|
||||
void clamp_width(int p_max_width);
|
||||
|
||||
EditorAssetLibraryItem();
|
||||
EditorAssetLibraryItem(bool p_clickable = false);
|
||||
};
|
||||
|
||||
class EditorAssetLibraryItemDescription : public ConfirmationDialog {
|
||||
@ -90,6 +89,7 @@ class EditorAssetLibraryItemDescription : public ConfirmationDialog {
|
||||
|
||||
EditorAssetLibraryItem *item = nullptr;
|
||||
RichTextLabel *description = nullptr;
|
||||
VBoxContainer *previews_vbox = nullptr;
|
||||
ScrollContainer *previews = nullptr;
|
||||
HBoxContainer *preview_hb = nullptr;
|
||||
PanelContainer *previews_bg = nullptr;
|
||||
@ -294,7 +294,7 @@ class EditorAssetLibrary : public PanelContainer {
|
||||
|
||||
void _install_asset();
|
||||
|
||||
void _select_author(int p_id);
|
||||
void _select_author(const String &p_author);
|
||||
void _select_category(int p_id);
|
||||
void _select_asset(int p_id);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user