animation_library_editor.h 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134
  1. /**************************************************************************/
  2. /* animation_library_editor.h */
  3. /**************************************************************************/
  4. /* This file is part of: */
  5. /* GODOT ENGINE */
  6. /* https://godotengine.org */
  7. /**************************************************************************/
  8. /* Copyright (c) 2014-present Godot Engine contributors (see AUTHORS.md). */
  9. /* Copyright (c) 2007-2014 Juan Linietsky, Ariel Manzur. */
  10. /* */
  11. /* Permission is hereby granted, free of charge, to any person obtaining */
  12. /* a copy of this software and associated documentation files (the */
  13. /* "Software"), to deal in the Software without restriction, including */
  14. /* without limitation the rights to use, copy, modify, merge, publish, */
  15. /* distribute, sublicense, and/or sell copies of the Software, and to */
  16. /* permit persons to whom the Software is furnished to do so, subject to */
  17. /* the following conditions: */
  18. /* */
  19. /* The above copyright notice and this permission notice shall be */
  20. /* included in all copies or substantial portions of the Software. */
  21. /* */
  22. /* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
  23. /* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
  24. /* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. */
  25. /* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
  26. /* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
  27. /* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
  28. /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
  29. /**************************************************************************/
  30. #ifndef ANIMATION_LIBRARY_EDITOR_H
  31. #define ANIMATION_LIBRARY_EDITOR_H
  32. #include "core/io/config_file.h"
  33. #include "core/templates/vector.h"
  34. #include "editor/animation_track_editor.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. class AnimationMixer;
  40. class EditorFileDialog;
  41. class AnimationLibraryEditor : public AcceptDialog {
  42. GDCLASS(AnimationLibraryEditor, AcceptDialog)
  43. enum {
  44. LIB_BUTTON_ADD,
  45. LIB_BUTTON_LOAD,
  46. LIB_BUTTON_PASTE,
  47. LIB_BUTTON_FILE,
  48. LIB_BUTTON_DELETE,
  49. };
  50. enum {
  51. ANIM_BUTTON_COPY,
  52. ANIM_BUTTON_FILE,
  53. ANIM_BUTTON_DELETE,
  54. };
  55. enum FileMenuAction {
  56. FILE_MENU_SAVE_LIBRARY,
  57. FILE_MENU_SAVE_AS_LIBRARY,
  58. FILE_MENU_MAKE_LIBRARY_UNIQUE,
  59. FILE_MENU_EDIT_LIBRARY,
  60. FILE_MENU_SAVE_ANIMATION,
  61. FILE_MENU_SAVE_AS_ANIMATION,
  62. FILE_MENU_MAKE_ANIMATION_UNIQUE,
  63. FILE_MENU_EDIT_ANIMATION,
  64. };
  65. enum FileDialogAction {
  66. FILE_DIALOG_ACTION_OPEN_LIBRARY,
  67. FILE_DIALOG_ACTION_SAVE_LIBRARY,
  68. FILE_DIALOG_ACTION_OPEN_ANIMATION,
  69. FILE_DIALOG_ACTION_SAVE_ANIMATION,
  70. };
  71. FileDialogAction file_dialog_action = FILE_DIALOG_ACTION_OPEN_ANIMATION;
  72. StringName file_dialog_animation;
  73. StringName file_dialog_library;
  74. Button *new_library_button = nullptr;
  75. Button *load_library_button = nullptr;
  76. AcceptDialog *error_dialog = nullptr;
  77. bool adding_animation = false;
  78. StringName adding_animation_to_library;
  79. EditorFileDialog *file_dialog = nullptr;
  80. ConfirmationDialog *add_library_dialog = nullptr;
  81. LineEdit *add_library_name = nullptr;
  82. Label *add_library_validate = nullptr;
  83. PopupMenu *file_popup = nullptr;
  84. Tree *tree = nullptr;
  85. AnimationMixer *mixer = nullptr;
  86. void _add_library();
  87. void _add_library_validate(const String &p_name);
  88. void _add_library_confirm();
  89. void _load_library();
  90. void _load_file(const String &p_path);
  91. void _load_files(const PackedStringArray &p_paths);
  92. void _save_mixer_lib_folding(TreeItem *p_item);
  93. Vector<uint64_t> _load_mixer_libs_folding();
  94. void _load_config_libs_folding(Vector<uint64_t> &p_lib_ids, ConfigFile *p_config, String p_section);
  95. String _get_mixer_signature() const;
  96. void _item_renamed();
  97. void _button_pressed(TreeItem *p_item, int p_column, int p_id, MouseButton p_button);
  98. void _file_popup_selected(int p_id);
  99. bool updating = false;
  100. protected:
  101. void _notification(int p_what);
  102. void _update_editor(Object *p_mixer);
  103. virtual void shortcut_input(const Ref<InputEvent> &p_event) override;
  104. static void _bind_methods();
  105. public:
  106. void set_animation_mixer(Object *p_mixer);
  107. void show_dialog();
  108. void update_tree();
  109. AnimationLibraryEditor();
  110. };
  111. #endif // ANIMATION_LIBRARY_EDITOR_H