animation_tree_player_editor_plugin.h 5.9 KB

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