animation_blend_space_1d_editor.h 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136
  1. /**************************************************************************/
  2. /* animation_blend_space_1d_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_BLEND_SPACE_1D_EDITOR_H
  31. #define ANIMATION_BLEND_SPACE_1D_EDITOR_H
  32. #include "editor/editor_node.h"
  33. #include "editor/editor_plugin.h"
  34. #include "editor/plugins/animation_tree_editor_plugin.h"
  35. #include "editor/property_editor.h"
  36. #include "scene/animation/animation_blend_space_1d.h"
  37. #include "scene/gui/button.h"
  38. #include "scene/gui/graph_edit.h"
  39. #include "scene/gui/popup.h"
  40. #include "scene/gui/tree.h"
  41. class AnimationNodeBlendSpace1DEditor : public AnimationTreeNodeEditorPlugin {
  42. GDCLASS(AnimationNodeBlendSpace1DEditor, AnimationTreeNodeEditorPlugin);
  43. Ref<AnimationNodeBlendSpace1D> blend_space;
  44. HBoxContainer *goto_parent_hb;
  45. ToolButton *goto_parent;
  46. PanelContainer *panel;
  47. ToolButton *tool_blend;
  48. ToolButton *tool_select;
  49. ToolButton *tool_create;
  50. VSeparator *tool_erase_sep;
  51. ToolButton *tool_erase;
  52. ToolButton *snap;
  53. SpinBox *snap_value;
  54. LineEdit *label_value;
  55. SpinBox *max_value;
  56. SpinBox *min_value;
  57. HBoxContainer *edit_hb;
  58. SpinBox *edit_value;
  59. Button *open_editor;
  60. int selected_point;
  61. Control *blend_space_draw;
  62. PanelContainer *error_panel;
  63. Label *error_label;
  64. bool updating;
  65. UndoRedo *undo_redo;
  66. static AnimationNodeBlendSpace1DEditor *singleton;
  67. void _blend_space_gui_input(const Ref<InputEvent> &p_event);
  68. void _blend_space_draw();
  69. void _update_space();
  70. void _config_changed(double);
  71. void _labels_changed(String);
  72. void _snap_toggled();
  73. PopupMenu *menu;
  74. PopupMenu *animations_menu;
  75. Vector<String> animations_to_add;
  76. float add_point_pos;
  77. Vector<float> points;
  78. bool dragging_selected_attempt;
  79. bool dragging_selected;
  80. Vector2 drag_from;
  81. Vector2 drag_ofs;
  82. void _add_menu_type(int p_index);
  83. void _add_animation_type(int p_index);
  84. void _tool_switch(int p_tool);
  85. void _update_edited_point_pos();
  86. void _update_tool_erase();
  87. void _erase_selected();
  88. void _edit_point_pos(double);
  89. void _open_editor();
  90. EditorFileDialog *open_file;
  91. Ref<AnimationNode> file_loaded;
  92. void _file_opened(const String &p_file);
  93. enum {
  94. MENU_LOAD_FILE = 1000,
  95. MENU_PASTE = 1001,
  96. MENU_LOAD_FILE_CONFIRM = 1002
  97. };
  98. StringName get_blend_position_path() const;
  99. protected:
  100. void _notification(int p_what);
  101. static void _bind_methods();
  102. public:
  103. static AnimationNodeBlendSpace1DEditor *get_singleton() { return singleton; }
  104. virtual bool can_edit(const Ref<AnimationNode> &p_node);
  105. virtual void edit(const Ref<AnimationNode> &p_node);
  106. AnimationNodeBlendSpace1DEditor();
  107. };
  108. #endif // ANIMATION_BLEND_SPACE_1D_EDITOR_H