summaryrefslogtreecommitdiff
path: root/editor/plugins
diff options
context:
space:
mode:
Diffstat (limited to 'editor/plugins')
-rw-r--r--editor/plugins/animation_blend_tree_editor_plugin.cpp2
-rw-r--r--editor/plugins/animation_player_editor_plugin.cpp81
-rw-r--r--editor/plugins/animation_player_editor_plugin.h3
-rw-r--r--editor/plugins/asset_library_editor_plugin.cpp40
-rw-r--r--editor/plugins/asset_library_editor_plugin.h5
5 files changed, 78 insertions, 53 deletions
diff --git a/editor/plugins/animation_blend_tree_editor_plugin.cpp b/editor/plugins/animation_blend_tree_editor_plugin.cpp
index 10e2f5f1d0..71db40a829 100644
--- a/editor/plugins/animation_blend_tree_editor_plugin.cpp
+++ b/editor/plugins/animation_blend_tree_editor_plugin.cpp
@@ -103,7 +103,7 @@ void AnimationNodeBlendTreeEditor::_property_changed(const StringName &p_propert
}
void AnimationNodeBlendTreeEditor::_update_graph() {
- if (updating) {
+ if (updating || blend_tree.is_null()) {
return;
}
diff --git a/editor/plugins/animation_player_editor_plugin.cpp b/editor/plugins/animation_player_editor_plugin.cpp
index 4ce9f40a5e..d7c0ba7540 100644
--- a/editor/plugins/animation_player_editor_plugin.cpp
+++ b/editor/plugins/animation_player_editor_plugin.cpp
@@ -967,16 +967,7 @@ void AnimationPlayerEditor::_animation_duplicate() {
return;
}
- Ref<Animation> new_anim = memnew(Animation);
- List<PropertyInfo> plist;
- anim->get_property_list(&plist);
- for (const PropertyInfo &E : plist) {
- if (E.usage & PROPERTY_USAGE_STORAGE) {
- new_anim->set(E.name, anim->get(E.name));
- }
- }
- new_anim->set_path("");
-
+ Ref<Animation> new_anim = _animation_clone(anim);
String new_name = current;
while (player->has_animation(new_name)) {
new_name = new_name + " (copy)";
@@ -1000,6 +991,44 @@ void AnimationPlayerEditor::_animation_duplicate() {
}
}
+Ref<Animation> AnimationPlayerEditor::_animation_clone(Ref<Animation> p_anim) {
+ Ref<Animation> new_anim = memnew(Animation);
+ List<PropertyInfo> plist;
+ p_anim->get_property_list(&plist);
+
+ for (const PropertyInfo &E : plist) {
+ if (E.usage & PROPERTY_USAGE_STORAGE) {
+ new_anim->set(E.name, p_anim->get(E.name));
+ }
+ }
+ new_anim->set_path("");
+
+ return new_anim;
+}
+
+void AnimationPlayerEditor::_animation_paste(Ref<Animation> p_anim) {
+ String name = p_anim->get_name();
+ if (name.is_empty()) {
+ name = TTR("Pasted Animation");
+ }
+
+ int idx = 1;
+ String base = name;
+ while (player->has_animation(name)) {
+ idx++;
+ name = base + " " + itos(idx);
+ }
+
+ undo_redo->create_action(TTR("Paste Animation"));
+ undo_redo->add_do_method(player, "add_animation", name, p_anim);
+ undo_redo->add_undo_method(player, "remove_animation", name);
+ undo_redo->add_do_method(this, "_animation_player_changed", player);
+ undo_redo->add_undo_method(this, "_animation_player_changed", player);
+ undo_redo->commit_action();
+
+ _select_anim_by_name(name);
+}
+
void AnimationPlayerEditor::_seek_value_changed(float p_value, bool p_set, bool p_timeline_only) {
if (updating || !player || player->is_playing()) {
return;
@@ -1135,31 +1164,22 @@ void AnimationPlayerEditor::_animation_tool_menu(int p_option) {
case TOOL_PASTE_ANIM: {
Ref<Animation> anim2 = EditorSettings::get_singleton()->get_resource_clipboard();
if (!anim2.is_valid()) {
- error_dialog->set_text(TTR("No animation resource on clipboard!"));
+ error_dialog->set_text(TTR("No animation resource in clipboard!"));
error_dialog->popup_centered();
return;
}
-
- String name = anim2->get_name();
- if (name.is_empty()) {
- name = TTR("Pasted Animation");
- }
-
- int idx = 1;
- String base = name;
- while (player->has_animation(name)) {
- idx++;
- name = base + " " + itos(idx);
+ Ref<Animation> new_anim = _animation_clone(anim2);
+ _animation_paste(new_anim);
+ } break;
+ case TOOL_PASTE_ANIM_REF: {
+ Ref<Animation> anim2 = EditorSettings::get_singleton()->get_resource_clipboard();
+ if (!anim2.is_valid()) {
+ error_dialog->set_text(TTR("No animation resource in clipboard!"));
+ error_dialog->popup_centered();
+ return;
}
- undo_redo->create_action(TTR("Paste Animation"));
- undo_redo->add_do_method(player, "add_animation", name, anim2);
- undo_redo->add_undo_method(player, "remove_animation", name);
- undo_redo->add_do_method(this, "_animation_player_changed", player);
- undo_redo->add_undo_method(this, "_animation_player_changed", player);
- undo_redo->commit_action();
-
- _select_anim_by_name(name);
+ _animation_paste(anim2);
} break;
case TOOL_EDIT_RESOURCE: {
if (!animation->get_item_count()) {
@@ -1587,6 +1607,7 @@ AnimationPlayerEditor::AnimationPlayerEditor(EditorNode *p_editor, AnimationPlay
tool_anim->get_popup()->add_separator();
tool_anim->get_popup()->add_shortcut(ED_SHORTCUT("animation_player_editor/copy_animation", TTR("Copy")), TOOL_COPY_ANIM);
tool_anim->get_popup()->add_shortcut(ED_SHORTCUT("animation_player_editor/paste_animation", TTR("Paste")), TOOL_PASTE_ANIM);
+ tool_anim->get_popup()->add_shortcut(ED_SHORTCUT("animation_player_editor/paste_animation_as_reference", TTR("Paste As Reference")), TOOL_PASTE_ANIM_REF);
tool_anim->get_popup()->add_separator();
tool_anim->get_popup()->add_shortcut(ED_SHORTCUT("animation_player_editor/duplicate_animation", TTR("Duplicate")), TOOL_DUPLICATE_ANIM);
tool_anim->get_popup()->add_separator();
diff --git a/editor/plugins/animation_player_editor_plugin.h b/editor/plugins/animation_player_editor_plugin.h
index 4e7ea46c1d..626d31f439 100644
--- a/editor/plugins/animation_player_editor_plugin.h
+++ b/editor/plugins/animation_player_editor_plugin.h
@@ -60,6 +60,7 @@ class AnimationPlayerEditor : public VBoxContainer {
TOOL_REMOVE_ANIM,
TOOL_COPY_ANIM,
TOOL_PASTE_ANIM,
+ TOOL_PASTE_ANIM_REF,
TOOL_EDIT_RESOURCE
};
@@ -183,6 +184,8 @@ class AnimationPlayerEditor : public VBoxContainer {
void _animation_blend();
void _animation_edit();
void _animation_duplicate();
+ Ref<Animation> _animation_clone(const Ref<Animation> p_anim);
+ void _animation_paste(const Ref<Animation> p_anim);
void _animation_resource_edit();
void _scale_changed(const String &p_scale);
void _save_animation(String p_file);
diff --git a/editor/plugins/asset_library_editor_plugin.cpp b/editor/plugins/asset_library_editor_plugin.cpp
index 49bef4acd5..31ef13a2eb 100644
--- a/editor/plugins/asset_library_editor_plugin.cpp
+++ b/editor/plugins/asset_library_editor_plugin.cpp
@@ -193,7 +193,8 @@ void EditorAssetLibraryItemDescription::set_image(int p_type, int p_index, const
void EditorAssetLibraryItemDescription::_notification(int p_what) {
switch (p_what) {
- case NOTIFICATION_ENTER_TREE: {
+ case NOTIFICATION_ENTER_TREE:
+ case NOTIFICATION_THEME_CHANGED: {
previews_bg->add_theme_style_override("panel", previews->get_theme_stylebox(SNAME("normal"), SNAME("TextEdit")));
} break;
}
@@ -397,9 +398,9 @@ void EditorAssetLibraryItemDownload::configure(const String &p_title, int p_asse
void EditorAssetLibraryItemDownload::_notification(int p_what) {
switch (p_what) {
- // FIXME: The editor crashes if 'NOTICATION_THEME_CHANGED' is used.
- case NOTIFICATION_ENTER_TREE: {
- add_theme_style_override("panel", get_theme_stylebox(SNAME("panel"), SNAME("TabContainer")));
+ case NOTIFICATION_ENTER_TREE:
+ case NOTIFICATION_THEME_CHANGED: {
+ panel->add_theme_style_override("panel", get_theme_stylebox(SNAME("panel"), SNAME("TabContainer")));
dismiss->set_normal_texture(get_theme_icon(SNAME("Close"), SNAME("EditorIcons")));
} break;
case NOTIFICATION_PROCESS: {
@@ -492,8 +493,11 @@ void EditorAssetLibraryItemDownload::_bind_methods() {
}
EditorAssetLibraryItemDownload::EditorAssetLibraryItemDownload() {
+ panel = memnew(PanelContainer);
+ add_child(panel);
+
HBoxContainer *hb = memnew(HBoxContainer);
- add_child(hb);
+ panel->add_child(hb);
icon = memnew(TextureRect);
hb->add_child(icon);
@@ -541,16 +545,16 @@ EditorAssetLibraryItemDownload::EditorAssetLibraryItemDownload() {
set_custom_minimum_size(Size2(310, 0) * EDSCALE);
download = memnew(HTTPRequest);
- add_child(download);
+ panel->add_child(download);
download->connect("request_completed", callable_mp(this, &EditorAssetLibraryItemDownload::_http_download_completed));
setup_http_request(download);
download_error = memnew(AcceptDialog);
- add_child(download_error);
+ panel->add_child(download_error);
download_error->set_title(TTR("Download Error"));
asset_installer = memnew(EditorAssetInstaller);
- add_child(asset_installer);
+ panel->add_child(asset_installer);
asset_installer->connect("confirmed", callable_mp(this, &EditorAssetLibraryItemDownload::_close));
prev_status = -1;
@@ -562,11 +566,15 @@ EditorAssetLibraryItemDownload::EditorAssetLibraryItemDownload() {
void EditorAssetLibrary::_notification(int p_what) {
switch (p_what) {
case NOTIFICATION_READY: {
+ error_label->raise();
+ } break;
+ case NOTIFICATION_ENTER_TREE:
+ case NOTIFICATION_THEME_CHANGED: {
error_tr->set_texture(get_theme_icon(SNAME("Error"), SNAME("EditorIcons")));
filter->set_right_icon(get_theme_icon(SNAME("Search"), SNAME("EditorIcons")));
- filter->set_clear_button_enabled(true);
-
- error_label->raise();
+ library_scroll_bg->add_theme_style_override("panel", get_theme_stylebox(SNAME("bg"), SNAME("Tree")));
+ downloads_scroll->add_theme_style_override("bg", get_theme_stylebox(SNAME("bg"), SNAME("Tree")));
+ error_label->add_theme_color_override("color", get_theme_color(SNAME("error_color"), SNAME("Editor")));
} break;
case NOTIFICATION_VISIBILITY_CHANGED: {
if (is_visible()) {
@@ -596,14 +604,6 @@ void EditorAssetLibrary::_notification(int p_what) {
}
} break;
- case NOTIFICATION_THEME_CHANGED: {
- library_scroll_bg->add_theme_style_override("panel", get_theme_stylebox(SNAME("bg"), SNAME("Tree")));
- downloads_scroll->add_theme_style_override("bg", get_theme_stylebox(SNAME("bg"), SNAME("Tree")));
- error_tr->set_texture(get_theme_icon(SNAME("Error"), SNAME("EditorIcons")));
- filter->set_right_icon(get_theme_icon(SNAME("Search"), SNAME("EditorIcons")));
- filter->set_clear_button_enabled(true);
- } break;
-
case EditorSettings::NOTIFICATION_EDITOR_SETTINGS_CHANGED: {
_update_repository_options();
} break;
@@ -1354,6 +1354,7 @@ EditorAssetLibrary::EditorAssetLibrary(bool p_templates_only) {
} else {
filter->set_placeholder(TTR("Search assets (excluding templates, projects, and demos)"));
}
+ filter->set_clear_button_enabled(true);
search_hb->add_child(filter);
filter->set_h_size_flags(Control::SIZE_EXPAND_FILL);
filter->connect("text_changed", callable_mp(this, &EditorAssetLibrary::_search_text_changed));
@@ -1495,7 +1496,6 @@ EditorAssetLibrary::EditorAssetLibrary(bool p_templates_only) {
error_hb = memnew(HBoxContainer);
library_main->add_child(error_hb);
error_label = memnew(Label);
- error_label->add_theme_color_override("color", get_theme_color(SNAME("error_color"), SNAME("Editor")));
error_hb->add_child(error_label);
error_tr = memnew(TextureRect);
error_tr->set_v_size_flags(Control::SIZE_SHRINK_CENTER);
diff --git a/editor/plugins/asset_library_editor_plugin.h b/editor/plugins/asset_library_editor_plugin.h
index d797608c24..8d6c0eb76e 100644
--- a/editor/plugins/asset_library_editor_plugin.h
+++ b/editor/plugins/asset_library_editor_plugin.h
@@ -126,9 +126,10 @@ public:
EditorAssetLibraryItemDescription();
};
-class EditorAssetLibraryItemDownload : public PanelContainer {
- GDCLASS(EditorAssetLibraryItemDownload, PanelContainer);
+class EditorAssetLibraryItemDownload : public Control {
+ GDCLASS(EditorAssetLibraryItemDownload, Control);
+ PanelContainer *panel;
TextureRect *icon;
Label *title;
ProgressBar *progress;