2
0

animation_library_editor.h 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132
  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/plugins/editor_plugin.h"
  35. #include "scene/animation/animation_mixer.h"
  36. #include "scene/gui/dialogs.h"
  37. #include "scene/gui/tree.h"
  38. class AnimationMixer;
  39. class EditorFileDialog;
  40. class AnimationLibraryEditor : public AcceptDialog {
  41. GDCLASS(AnimationLibraryEditor, AcceptDialog)
  42. enum {
  43. LIB_BUTTON_ADD,
  44. LIB_BUTTON_LOAD,
  45. LIB_BUTTON_PASTE,
  46. LIB_BUTTON_FILE,
  47. LIB_BUTTON_DELETE,
  48. };
  49. enum {
  50. ANIM_BUTTON_COPY,
  51. ANIM_BUTTON_FILE,
  52. ANIM_BUTTON_DELETE,
  53. };
  54. enum FileMenuAction {
  55. FILE_MENU_SAVE_LIBRARY,
  56. FILE_MENU_SAVE_AS_LIBRARY,
  57. FILE_MENU_MAKE_LIBRARY_UNIQUE,
  58. FILE_MENU_EDIT_LIBRARY,
  59. FILE_MENU_SAVE_ANIMATION,
  60. FILE_MENU_SAVE_AS_ANIMATION,
  61. FILE_MENU_MAKE_ANIMATION_UNIQUE,
  62. FILE_MENU_EDIT_ANIMATION,
  63. };
  64. enum FileDialogAction {
  65. FILE_DIALOG_ACTION_OPEN_LIBRARY,
  66. FILE_DIALOG_ACTION_SAVE_LIBRARY,
  67. FILE_DIALOG_ACTION_OPEN_ANIMATION,
  68. FILE_DIALOG_ACTION_SAVE_ANIMATION,
  69. };
  70. FileDialogAction file_dialog_action = FILE_DIALOG_ACTION_OPEN_ANIMATION;
  71. StringName file_dialog_animation;
  72. StringName file_dialog_library;
  73. Button *new_library_button = nullptr;
  74. Button *load_library_button = nullptr;
  75. AcceptDialog *error_dialog = nullptr;
  76. bool adding_animation = false;
  77. StringName adding_animation_to_library;
  78. EditorFileDialog *file_dialog = nullptr;
  79. ConfirmationDialog *add_library_dialog = nullptr;
  80. LineEdit *add_library_name = nullptr;
  81. Label *add_library_validate = nullptr;
  82. PopupMenu *file_popup = nullptr;
  83. Tree *tree = nullptr;
  84. AnimationMixer *mixer = nullptr;
  85. void _add_library();
  86. void _add_library_validate(const String &p_name);
  87. void _add_library_confirm();
  88. void _load_library();
  89. void _load_file(const String &p_path);
  90. void _load_files(const PackedStringArray &p_paths);
  91. void _save_mixer_lib_folding(TreeItem *p_item);
  92. Vector<uint64_t> _load_mixer_libs_folding();
  93. void _load_config_libs_folding(Vector<uint64_t> &p_lib_ids, ConfigFile *p_config, String p_section);
  94. String _get_mixer_signature() const;
  95. void _item_renamed();
  96. void _button_pressed(TreeItem *p_item, int p_column, int p_id, MouseButton p_button);
  97. void _file_popup_selected(int p_id);
  98. bool updating = false;
  99. protected:
  100. void _notification(int p_what);
  101. void _update_editor(Object *p_mixer);
  102. virtual void shortcut_input(const Ref<InputEvent> &p_event) override;
  103. static void _bind_methods();
  104. public:
  105. void set_animation_mixer(Object *p_mixer);
  106. void show_dialog();
  107. void update_tree();
  108. AnimationLibraryEditor();
  109. };
  110. #endif // ANIMATION_LIBRARY_EDITOR_H