animation_blend_space_1d_editor.h 4.9 KB

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