diff options
Diffstat (limited to 'editor/plugins/animation_library_editor.cpp')
-rw-r--r-- | editor/plugins/animation_library_editor.cpp | 124 |
1 files changed, 62 insertions, 62 deletions
diff --git a/editor/plugins/animation_library_editor.cpp b/editor/plugins/animation_library_editor.cpp index 6a54bc654f..c4c0799daa 100644 --- a/editor/plugins/animation_library_editor.cpp +++ b/editor/plugins/animation_library_editor.cpp @@ -36,8 +36,8 @@ #include "editor/editor_undo_redo_manager.h" #include "editor/gui/editor_file_dialog.h" -void AnimationLibraryEditor::set_animation_player(Object *p_player) { - player = p_player; +void AnimationLibraryEditor::set_animation_mixer(Object *p_mixer) { + mixer = p_mixer; } void AnimationLibraryEditor::_add_library() { @@ -54,7 +54,7 @@ void AnimationLibraryEditor::_add_library_validate(const String &p_name) { String error; if (adding_animation) { - Ref<AnimationLibrary> al = player->call("get_animation_library", adding_animation_to_library); + Ref<AnimationLibrary> al = mixer->call("get_animation_library", adding_animation_to_library); ERR_FAIL_COND(al.is_null()); if (p_name == "") { error = TTR("Animation name can't be empty."); @@ -64,11 +64,11 @@ void AnimationLibraryEditor::_add_library_validate(const String &p_name) { error = TTR("Animation with the same name already exists."); } } else { - if (p_name == "" && bool(player->call("has_animation_library", ""))) { + if (p_name == "" && bool(mixer->call("has_animation_library", ""))) { error = TTR("Enter a library name."); } else if (!AnimationLibrary::is_valid_library_name(p_name)) { error = TTR("Library name contains invalid characters: '/', ':', ',' or '['."); - } else if (bool(player->call("has_animation_library", p_name))) { + } else if (bool(mixer->call("has_animation_library", p_name))) { error = TTR("Library with the same name already exists."); } } @@ -97,7 +97,7 @@ void AnimationLibraryEditor::_add_library_confirm() { String anim_name = add_library_name->get_text(); EditorUndoRedoManager *undo_redo = EditorUndoRedoManager::get_singleton(); - Ref<AnimationLibrary> al = player->call("get_animation_library", adding_animation_to_library); + Ref<AnimationLibrary> al = mixer->call("get_animation_library", adding_animation_to_library); ERR_FAIL_COND(!al.is_valid()); Ref<Animation> anim; @@ -106,8 +106,8 @@ void AnimationLibraryEditor::_add_library_confirm() { undo_redo->create_action(vformat(TTR("Add Animation to Library: %s"), anim_name)); undo_redo->add_do_method(al.ptr(), "add_animation", anim_name, anim); undo_redo->add_undo_method(al.ptr(), "remove_animation", anim_name); - undo_redo->add_do_method(this, "_update_editor", player); - undo_redo->add_undo_method(this, "_update_editor", player); + undo_redo->add_do_method(this, "_update_editor", mixer); + undo_redo->add_undo_method(this, "_update_editor", mixer); undo_redo->commit_action(); } else { @@ -118,10 +118,10 @@ void AnimationLibraryEditor::_add_library_confirm() { al.instantiate(); undo_redo->create_action(vformat(TTR("Add Animation Library: %s"), lib_name)); - undo_redo->add_do_method(player, "add_animation_library", lib_name, al); - undo_redo->add_undo_method(player, "remove_animation_library", lib_name); - undo_redo->add_do_method(this, "_update_editor", player); - undo_redo->add_undo_method(this, "_update_editor", player); + undo_redo->add_do_method(mixer, "add_animation_library", lib_name, al); + undo_redo->add_undo_method(mixer, "remove_animation_library", lib_name); + undo_redo->add_do_method(this, "_update_editor", mixer); + undo_redo->add_undo_method(this, "_update_editor", mixer); undo_redo->commit_action(); } } @@ -144,7 +144,7 @@ void AnimationLibraryEditor::_load_library() { } void AnimationLibraryEditor::_file_popup_selected(int p_id) { - Ref<AnimationLibrary> al = player->call("get_animation_library", file_dialog_library); + Ref<AnimationLibrary> al = mixer->call("get_animation_library", file_dialog_library); Ref<Animation> anim; if (file_dialog_animation != StringName()) { anim = al->get_animation(file_dialog_animation); @@ -214,12 +214,12 @@ void AnimationLibraryEditor::_file_popup_selected(int p_id) { EditorUndoRedoManager *undo_redo = EditorUndoRedoManager::get_singleton(); undo_redo->create_action(vformat(TTR("Make Animation Library Unique: %s"), lib_name)); - undo_redo->add_do_method(player, "remove_animation_library", lib_name); - undo_redo->add_do_method(player, "add_animation_library", lib_name, ald); - undo_redo->add_undo_method(player, "remove_animation_library", lib_name); - undo_redo->add_undo_method(player, "add_animation_library", lib_name, al); - undo_redo->add_do_method(this, "_update_editor", player); - undo_redo->add_undo_method(this, "_update_editor", player); + undo_redo->add_do_method(mixer, "remove_animation_library", lib_name); + undo_redo->add_do_method(mixer, "add_animation_library", lib_name, ald); + undo_redo->add_undo_method(mixer, "remove_animation_library", lib_name); + undo_redo->add_undo_method(mixer, "add_animation_library", lib_name, al); + undo_redo->add_do_method(this, "_update_editor", mixer); + undo_redo->add_undo_method(this, "_update_editor", mixer); undo_redo->commit_action(); update_tree(); @@ -287,8 +287,8 @@ void AnimationLibraryEditor::_file_popup_selected(int p_id) { undo_redo->add_do_method(al.ptr(), "add_animation", anim_name, animd); undo_redo->add_undo_method(al.ptr(), "remove_animation", anim_name); undo_redo->add_undo_method(al.ptr(), "add_animation", anim_name, anim); - undo_redo->add_do_method(this, "_update_editor", player); - undo_redo->add_undo_method(this, "_update_editor", player); + undo_redo->add_do_method(this, "_update_editor", mixer); + undo_redo->add_undo_method(this, "_update_editor", mixer); undo_redo->commit_action(); update_tree(); @@ -308,12 +308,12 @@ void AnimationLibraryEditor::_load_file(String p_path) { return; } - TypedArray<StringName> libs = player->call("get_animation_library_list"); + TypedArray<StringName> libs = mixer->call("get_animation_library_list"); for (int i = 0; i < libs.size(); i++) { const StringName K = libs[i]; - Ref<AnimationLibrary> al2 = player->call("get_animation_library", K); + Ref<AnimationLibrary> al2 = mixer->call("get_animation_library", K); if (al2 == al) { - error_dialog->set_text(TTR("This library is already added to the player.")); + error_dialog->set_text(TTR("This library is already added to the mixer.")); error_dialog->popup_centered(); return; @@ -324,7 +324,7 @@ void AnimationLibraryEditor::_load_file(String p_path) { int attempt = 1; - while (bool(player->call("has_animation_library", name))) { + while (bool(mixer->call("has_animation_library", name))) { attempt++; name = p_path.get_file().get_basename() + " " + itos(attempt); } @@ -332,10 +332,10 @@ void AnimationLibraryEditor::_load_file(String p_path) { EditorUndoRedoManager *undo_redo = EditorUndoRedoManager::get_singleton(); undo_redo->create_action(vformat(TTR("Add Animation Library: %s"), name)); - undo_redo->add_do_method(player, "add_animation_library", name, al); - undo_redo->add_undo_method(player, "remove_animation_library", name); - undo_redo->add_do_method(this, "_update_editor", player); - undo_redo->add_undo_method(this, "_update_editor", player); + undo_redo->add_do_method(mixer, "add_animation_library", name, al); + undo_redo->add_undo_method(mixer, "remove_animation_library", name); + undo_redo->add_do_method(this, "_update_editor", mixer); + undo_redo->add_undo_method(this, "_update_editor", mixer); undo_redo->commit_action(); } break; case FILE_DIALOG_ACTION_OPEN_ANIMATION: { @@ -346,7 +346,7 @@ void AnimationLibraryEditor::_load_file(String p_path) { return; } - Ref<AnimationLibrary> al = player->call("get_animation_library", adding_animation_to_library); + Ref<AnimationLibrary> al = mixer->call("get_animation_library", adding_animation_to_library); List<StringName> anims; al->get_animation_list(&anims); for (const StringName &K : anims) { @@ -372,13 +372,13 @@ void AnimationLibraryEditor::_load_file(String p_path) { undo_redo->create_action(vformat(TTR("Load Animation into Library: %s"), name)); undo_redo->add_do_method(al.ptr(), "add_animation", name, anim); undo_redo->add_undo_method(al.ptr(), "remove_animation", name); - undo_redo->add_do_method(this, "_update_editor", player); - undo_redo->add_undo_method(this, "_update_editor", player); + undo_redo->add_do_method(this, "_update_editor", mixer); + undo_redo->add_undo_method(this, "_update_editor", mixer); undo_redo->commit_action(); } break; case FILE_DIALOG_ACTION_SAVE_LIBRARY: { - Ref<AnimationLibrary> al = player->call("get_animation_library", file_dialog_library); + Ref<AnimationLibrary> al = mixer->call("get_animation_library", file_dialog_library); String prev_path = al->get_path(); EditorNode::get_singleton()->save_resource_in_path(al, p_path); @@ -388,14 +388,14 @@ void AnimationLibraryEditor::_load_file(String p_path) { undo_redo->create_action(vformat(TTR("Save Animation library to File: %s"), file_dialog_library)); undo_redo->add_do_method(al.ptr(), "set_path", al->get_path()); undo_redo->add_undo_method(al.ptr(), "set_path", prev_path); - undo_redo->add_do_method(this, "_update_editor", player); - undo_redo->add_undo_method(this, "_update_editor", player); + undo_redo->add_do_method(this, "_update_editor", mixer); + undo_redo->add_undo_method(this, "_update_editor", mixer); undo_redo->commit_action(); } } break; case FILE_DIALOG_ACTION_SAVE_ANIMATION: { - Ref<AnimationLibrary> al = player->call("get_animation_library", file_dialog_library); + Ref<AnimationLibrary> al = mixer->call("get_animation_library", file_dialog_library); Ref<Animation> anim; if (file_dialog_animation != StringName()) { anim = al->get_animation(file_dialog_animation); @@ -409,8 +409,8 @@ void AnimationLibraryEditor::_load_file(String p_path) { undo_redo->create_action(vformat(TTR("Save Animation to File: %s"), file_dialog_animation)); undo_redo->add_do_method(anim.ptr(), "set_path", anim->get_path()); undo_redo->add_undo_method(anim.ptr(), "set_path", prev_path); - undo_redo->add_do_method(this, "_update_editor", player); - undo_redo->add_undo_method(this, "_update_editor", player); + undo_redo->add_do_method(this, "_update_editor", mixer); + undo_redo->add_undo_method(this, "_update_editor", mixer); undo_redo->commit_action(); } } break; @@ -430,14 +430,14 @@ void AnimationLibraryEditor::_item_renamed() { if (ti->get_parent() == tree->get_root()) { // Renamed library - if (player->call("has_animation_library", text)) { + if (mixer->call("has_animation_library", text)) { restore_text = true; } else { undo_redo->create_action(vformat(TTR("Rename Animation Library: %s"), text)); - undo_redo->add_do_method(player, "rename_animation_library", old_text, text); - undo_redo->add_undo_method(player, "rename_animation_library", text, old_text); - undo_redo->add_do_method(this, "_update_editor", player); - undo_redo->add_undo_method(this, "_update_editor", player); + undo_redo->add_do_method(mixer, "rename_animation_library", old_text, text); + undo_redo->add_undo_method(mixer, "rename_animation_library", text, old_text); + undo_redo->add_do_method(this, "_update_editor", mixer); + undo_redo->add_undo_method(this, "_update_editor", mixer); updating = true; undo_redo->commit_action(); updating = false; @@ -451,7 +451,7 @@ void AnimationLibraryEditor::_item_renamed() { } else { // Renamed anim StringName library = ti->get_parent()->get_metadata(0); - Ref<AnimationLibrary> al = player->call("get_animation_library", library); + Ref<AnimationLibrary> al = mixer->call("get_animation_library", library); if (al.is_valid()) { if (al->has_animation(text)) { @@ -460,8 +460,8 @@ void AnimationLibraryEditor::_item_renamed() { undo_redo->create_action(vformat(TTR("Rename Animation: %s"), text)); undo_redo->add_do_method(al.ptr(), "rename_animation", old_text, text); undo_redo->add_undo_method(al.ptr(), "rename_animation", text, old_text); - undo_redo->add_do_method(this, "_update_editor", player); - undo_redo->add_undo_method(this, "_update_editor", player); + undo_redo->add_do_method(this, "_update_editor", mixer); + undo_redo->add_undo_method(this, "_update_editor", mixer); updating = true; undo_redo->commit_action(); updating = false; @@ -483,7 +483,7 @@ void AnimationLibraryEditor::_button_pressed(TreeItem *p_item, int p_column, int if (p_item->get_parent() == tree->get_root()) { // Library StringName lib_name = p_item->get_metadata(0); - Ref<AnimationLibrary> al = player->call("get_animation_library", lib_name); + Ref<AnimationLibrary> al = mixer->call("get_animation_library", lib_name); switch (p_id) { case LIB_BUTTON_ADD: { add_library_dialog->set_title(TTR("Animation Name:")); @@ -541,8 +541,8 @@ void AnimationLibraryEditor::_button_pressed(TreeItem *p_item, int p_column, int undo_redo->create_action(vformat(TTR("Add Animation to Library: %s"), name)); undo_redo->add_do_method(al.ptr(), "add_animation", name, anim); undo_redo->add_undo_method(al.ptr(), "remove_animation", name); - undo_redo->add_do_method(this, "_update_editor", player); - undo_redo->add_undo_method(this, "_update_editor", player); + undo_redo->add_do_method(this, "_update_editor", mixer); + undo_redo->add_undo_method(this, "_update_editor", mixer); undo_redo->commit_action(); } break; @@ -564,10 +564,10 @@ void AnimationLibraryEditor::_button_pressed(TreeItem *p_item, int p_column, int case LIB_BUTTON_DELETE: { EditorUndoRedoManager *undo_redo = EditorUndoRedoManager::get_singleton(); undo_redo->create_action(vformat(TTR("Remove Animation Library: %s"), lib_name)); - undo_redo->add_do_method(player, "remove_animation_library", lib_name); - undo_redo->add_undo_method(player, "add_animation_library", lib_name, al); - undo_redo->add_do_method(this, "_update_editor", player); - undo_redo->add_undo_method(this, "_update_editor", player); + undo_redo->add_do_method(mixer, "remove_animation_library", lib_name); + undo_redo->add_undo_method(mixer, "add_animation_library", lib_name, al); + undo_redo->add_do_method(this, "_update_editor", mixer); + undo_redo->add_undo_method(this, "_update_editor", mixer); undo_redo->commit_action(); } break; } @@ -576,7 +576,7 @@ void AnimationLibraryEditor::_button_pressed(TreeItem *p_item, int p_column, int // Animation StringName lib_name = p_item->get_parent()->get_metadata(0); StringName anim_name = p_item->get_metadata(0); - Ref<AnimationLibrary> al = player->call("get_animation_library", lib_name); + Ref<AnimationLibrary> al = mixer->call("get_animation_library", lib_name); Ref<Animation> anim = al->get_animation(anim_name); ERR_FAIL_COND(!anim.is_valid()); switch (p_id) { @@ -607,8 +607,8 @@ void AnimationLibraryEditor::_button_pressed(TreeItem *p_item, int p_column, int undo_redo->create_action(vformat(TTR("Remove Animation from Library: %s"), anim_name)); undo_redo->add_do_method(al.ptr(), "remove_animation", anim_name); undo_redo->add_undo_method(al.ptr(), "add_animation", anim_name, anim); - undo_redo->add_do_method(this, "_update_editor", player); - undo_redo->add_undo_method(this, "_update_editor", player); + undo_redo->add_do_method(this, "_update_editor", mixer); + undo_redo->add_undo_method(this, "_update_editor", mixer); undo_redo->commit_action(); } break; } @@ -621,12 +621,12 @@ void AnimationLibraryEditor::update_tree() { } tree->clear(); - ERR_FAIL_NULL(player); + ERR_FAIL_NULL(mixer); Color ss_color = get_theme_color(SNAME("prop_subsection"), EditorStringName(Editor)); TreeItem *root = tree->create_item(); - TypedArray<StringName> libs = player->call("get_animation_library_list"); + TypedArray<StringName> libs = mixer->call("get_animation_library_list"); for (int i = 0; i < libs.size(); i++) { const StringName K = libs[i]; @@ -638,7 +638,7 @@ void AnimationLibraryEditor::update_tree() { libitem->set_suffix(0, ""); } - Ref<AnimationLibrary> al = player->call("get_animation_library", K); + Ref<AnimationLibrary> al = mixer->call("get_animation_library", K); bool animation_library_is_foreign = false; String al_path = al->get_path(); if (!al_path.is_resource_file()) { @@ -727,12 +727,12 @@ void AnimationLibraryEditor::show_dialog() { popup_centered_ratio(0.5); } -void AnimationLibraryEditor::_update_editor(Object *p_player) { - emit_signal("update_editor", p_player); +void AnimationLibraryEditor::_update_editor(Object *p_mixer) { + emit_signal("update_editor", p_mixer); } void AnimationLibraryEditor::_bind_methods() { - ClassDB::bind_method(D_METHOD("_update_editor", "player"), &AnimationLibraryEditor::_update_editor); + ClassDB::bind_method(D_METHOD("_update_editor", "mixer"), &AnimationLibraryEditor::_update_editor); ADD_SIGNAL(MethodInfo("update_editor")); } |