animation_library_editor.h 4.2 KB

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