animation_tree_player_editor_plugin.h 5.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181
  1. /**************************************************************************/
  2. /* animation_tree_player_editor_plugin.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_TREE_PLAYER_EDITOR_PLUGIN_H
  31. #define ANIMATION_TREE_PLAYER_EDITOR_PLUGIN_H
  32. #include "editor/editor_node.h"
  33. #include "editor/editor_plugin.h"
  34. #include "editor/property_editor.h"
  35. #include "scene/animation/animation_tree_player.h"
  36. #include "scene/gui/button.h"
  37. #include "scene/gui/popup.h"
  38. #include "scene/gui/tree.h"
  39. class AnimationTreePlayerEditor : public Control {
  40. GDCLASS(AnimationTreePlayerEditor, Control);
  41. static const char *_node_type_names[];
  42. enum ClickType {
  43. CLICK_NONE,
  44. CLICK_NAME,
  45. CLICK_NODE,
  46. CLICK_INPUT_SLOT,
  47. CLICK_OUTPUT_SLOT,
  48. CLICK_PARAMETER
  49. };
  50. enum {
  51. MENU_GRAPH_CLEAR = 100,
  52. MENU_IMPORT_ANIMATIONS = 101,
  53. NODE_DISCONNECT,
  54. NODE_RENAME,
  55. NODE_ERASE,
  56. NODE_ADD_INPUT,
  57. NODE_DELETE_INPUT,
  58. NODE_SET_AUTOADVANCE,
  59. NODE_CLEAR_AUTOADVANCE
  60. };
  61. bool renaming_edit;
  62. StringName edited_node;
  63. bool updating_edit;
  64. Popup *edit_dialog;
  65. HSlider *edit_scroll[2];
  66. LineEdit *edit_line[4];
  67. OptionButton *edit_option;
  68. Label *edit_label[4];
  69. Button *edit_button;
  70. Button *filter_button;
  71. CheckButton *edit_check;
  72. EditorFileDialog *file_dialog;
  73. int file_op;
  74. void _popup_edit_dialog();
  75. PopupMenu *master_anim_popup;
  76. PopupMenu *node_popup;
  77. PopupMenu *add_popup;
  78. HScrollBar *h_scroll;
  79. VScrollBar *v_scroll;
  80. MenuButton *add_menu;
  81. CustomPropertyEditor *property_editor;
  82. AnimationTreePlayer *anim_tree;
  83. List<StringName> order;
  84. Set<StringName> active_nodes;
  85. int last_x, last_y;
  86. Point2 offset;
  87. ClickType click_type;
  88. Point2 click_pos;
  89. StringName click_node;
  90. int click_slot;
  91. Point2 click_motion;
  92. ClickType rclick_type;
  93. StringName rclick_node;
  94. int rclick_slot;
  95. Button *play_button;
  96. Size2 _get_maximum_size();
  97. Size2 get_node_size(const StringName &p_node) const;
  98. void _draw_node(const StringName &p_node);
  99. AcceptDialog *filter_dialog;
  100. Tree *filter;
  101. void _draw_cos_line(const Vector2 &p_from, const Vector2 &p_to, const Color &p_color);
  102. void _update_scrollbars();
  103. void _scroll_moved(float);
  104. void _play_toggled();
  105. /*
  106. void _node_param_changed();
  107. void _node_add_callback();
  108. void _node_add(VisualServer::AnimationTreeNodeType p_type);
  109. void _node_edit_property(const StringName& p_node);
  110. */
  111. void _master_anim_menu_item(int p_item);
  112. void _node_menu_item(int p_item);
  113. void _add_menu_item(int p_item);
  114. void _filter_edited();
  115. void _find_paths_for_filter(const StringName &p_node, Set<String> &paths);
  116. void _edit_filters();
  117. void _edit_oneshot_start();
  118. void _edit_dialog_animation_changed();
  119. void _edit_dialog_edit_animation();
  120. void _edit_dialog_changeds(String);
  121. void _edit_dialog_changede(String);
  122. void _edit_dialog_changedf(float);
  123. void _edit_dialog_changed();
  124. ClickType _locate_click(const Point2 &p_click, StringName *p_node_id, int *p_slot_index) const;
  125. Point2 _get_slot_pos(const StringName &p_node_id, bool p_input, int p_slot);
  126. StringName _add_node(int p_item);
  127. void _file_dialog_selected(String p_path);
  128. protected:
  129. void _notification(int p_what);
  130. void _gui_input(Ref<InputEvent> p_event);
  131. static void _bind_methods();
  132. public:
  133. virtual Size2 get_minimum_size() const;
  134. void edit(AnimationTreePlayer *p_anim_tree);
  135. AnimationTreePlayerEditor();
  136. };
  137. class AnimationTreePlayerEditorPlugin : public EditorPlugin {
  138. GDCLASS(AnimationTreePlayerEditorPlugin, EditorPlugin);
  139. AnimationTreePlayerEditor *anim_tree_editor;
  140. EditorNode *editor;
  141. Button *button;
  142. public:
  143. virtual String get_name() const { return "AnimTree"; }
  144. bool has_main_screen() const { return false; }
  145. virtual void edit(Object *p_object);
  146. virtual bool handles(Object *p_object) const;
  147. virtual void make_visible(bool p_visible);
  148. AnimationTreePlayerEditorPlugin(EditorNode *p_node);
  149. ~AnimationTreePlayerEditorPlugin();
  150. };
  151. #endif // ANIMATION_TREE_PLAYER_EDITOR_PLUGIN_H