| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
|
| 16 |
|
| 17 |
|
| 18 |
|
| 19 |
|
| 20 |
|
| 21 |
|
| 22 |
|
| 23 |
|
| 24 |
|
| 25 |
|
| 26 |
|
| 27 |
|
| 28 |
|
| 29 |
|
| 30 |
|
| 31 |
#pragma once |
| 32 |
|
| 33 |
#include "core/io/config_file.h" |
| 34 |
#include "core/templates/vector.h" |
| 35 |
#include "editor/plugins/editor_plugin.h" |
| 36 |
#include "scene/animation/animation_mixer.h" |
| 37 |
#include "scene/gui/dialogs.h" |
| 38 |
#include "scene/gui/tree.h" |
| 39 |
|
| 40 |
class AnimationMixer; |
| 41 |
class EditorFileDialog; |
| 42 |
|
| 43 |
class AnimationLibraryEditor : public AcceptDialog { |
| 44 |
GDCLASS(AnimationLibraryEditor, AcceptDialog) |
| 45 |
|
| 46 |
enum { |
| 47 |
LIB_BUTTON_ADD, |
| 48 |
LIB_BUTTON_LOAD, |
| 49 |
LIB_BUTTON_PASTE, |
| 50 |
LIB_BUTTON_FILE, |
| 51 |
LIB_BUTTON_DELETE, |
| 52 |
}; |
| 53 |
enum { |
| 54 |
ANIM_BUTTON_COPY, |
| 55 |
ANIM_BUTTON_FILE, |
| 56 |
ANIM_BUTTON_DELETE, |
| 57 |
}; |
| 58 |
|
| 59 |
enum FileMenuAction { |
| 60 |
FILE_MENU_SAVE_LIBRARY, |
| 61 |
FILE_MENU_SAVE_AS_LIBRARY, |
| 62 |
FILE_MENU_MAKE_LIBRARY_UNIQUE, |
| 63 |
FILE_MENU_EDIT_LIBRARY, |
| 64 |
|
| 65 |
FILE_MENU_SAVE_ANIMATION, |
| 66 |
FILE_MENU_SAVE_AS_ANIMATION, |
| 67 |
FILE_MENU_MAKE_ANIMATION_UNIQUE, |
| 68 |
FILE_MENU_EDIT_ANIMATION, |
| 69 |
}; |
| 70 |
|
| 71 |
enum FileDialogAction { |
| 72 |
FILE_DIALOG_ACTION_OPEN_LIBRARY, |
| 73 |
FILE_DIALOG_ACTION_SAVE_LIBRARY, |
| 74 |
FILE_DIALOG_ACTION_OPEN_ANIMATION, |
| 75 |
FILE_DIALOG_ACTION_SAVE_ANIMATION, |
| 76 |
}; |
| 77 |
|
| 78 |
FileDialogAction file_dialog_action = FILE_DIALOG_ACTION_OPEN_ANIMATION; |
| 79 |
|
| 80 |
StringName file_dialog_animation; |
| 81 |
StringName file_dialog_library; |
| 82 |
|
| 83 |
Button *new_library_button = nullptr; |
| 84 |
Button *load_library_button = nullptr; |
| 85 |
|
| 86 |
AcceptDialog *error_dialog = nullptr; |
| 87 |
bool adding_animation = false; |
| 88 |
StringName adding_animation_to_library; |
| 89 |
EditorFileDialog *file_dialog = nullptr; |
| 90 |
ConfirmationDialog *add_library_dialog = nullptr; |
| 91 |
LineEdit *add_library_name = nullptr; |
| 92 |
Label *add_library_validate = nullptr; |
| 93 |
PopupMenu *file_popup = nullptr; |
| 94 |
|
| 95 |
Tree *tree = nullptr; |
| 96 |
|
| 97 |
AnimationMixer *mixer = nullptr; |
| 98 |
|
| 99 |
void _add_library(); |
| 100 |
void _add_library_validate(const String &p_name); |
| 101 |
void _add_library_confirm(); |
| 102 |
void _load_library(); |
| 103 |
void _load_file(const String &p_path); |
| 104 |
void _load_files(const PackedStringArray &p_paths); |
| 105 |
|
| 106 |
void _save_mixer_lib_folding(TreeItem *p_item); |
| 107 |
Vector<uint64_t> _load_mixer_libs_folding(); |
| 108 |
void _load_config_libs_folding(Vector<uint64_t> &p_lib_ids, ConfigFile *p_config, String p_section); |
| 109 |
String _get_mixer_signature() const; |
| 110 |
|
| 111 |
void _item_renamed(); |
| 112 |
void _button_pressed(TreeItem *p_item, int p_column, int p_id, MouseButton p_button); |
| 113 |
|
| 114 |
void _file_popup_selected(int p_id); |
| 115 |
|
| 116 |
bool updating = false; |
| 117 |
|
| 118 |
protected: |
| 119 |
void _notification(int p_what); |
| 120 |
void _update_editor(Object *p_mixer); |
| 121 |
virtual void shortcut_input(const Ref<InputEvent> &p_event) override; |
| 122 |
static void _bind_methods(); |
| 123 |
|
| 124 |
public: |
| 125 |
void set_animation_mixer(Object *p_mixer); |
| 126 |
void show_dialog(); |
| 127 |
void update_tree(); |
| 128 |
AnimationLibraryEditor(); |
| 129 |
}; |