| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
|
| 16 |
|
| 17 |
|
| 18 |
|
| 19 |
|
| 20 |
|
| 21 |
|
| 22 |
|
| 23 |
|
| 24 |
|
| 25 |
|
| 26 |
|
| 27 |
|
| 28 |
|
| 29 |
|
| 30 |
|
| 31 |
#pragma once |
| 32 |
|
| 33 |
#include "editor/animation/animation_tree_editor_plugin.h" |
| 34 |
#include "editor/plugins/editor_plugin.h" |
| 35 |
#include "scene/animation/animation_blend_space_1d.h" |
| 36 |
#include "scene/gui/graph_edit.h" |
| 37 |
|
| 38 |
class Button; |
| 39 |
class CheckBox; |
| 40 |
class LineEdit; |
| 41 |
class OptionButton; |
| 42 |
class PanelContainer; |
| 43 |
class SpinBox; |
| 44 |
class VSeparator; |
| 45 |
|
| 46 |
class AnimationNodeBlendSpace1DEditor : public AnimationTreeNodeEditorPlugin { |
| 47 |
GDCLASS(AnimationNodeBlendSpace1DEditor, AnimationTreeNodeEditorPlugin); |
| 48 |
|
| 49 |
Ref<AnimationNodeBlendSpace1D> blend_space; |
| 50 |
bool read_only = false; |
| 51 |
|
| 52 |
PanelContainer *panel = nullptr; |
| 53 |
Button *tool_blend = nullptr; |
| 54 |
Button *tool_select = nullptr; |
| 55 |
Button *tool_create = nullptr; |
| 56 |
VSeparator *tool_erase_sep = nullptr; |
| 57 |
Button *tool_erase = nullptr; |
| 58 |
Button *snap = nullptr; |
| 59 |
SpinBox *snap_value = nullptr; |
| 60 |
|
| 61 |
LineEdit *label_value = nullptr; |
| 62 |
SpinBox *max_value = nullptr; |
| 63 |
SpinBox *min_value = nullptr; |
| 64 |
|
| 65 |
CheckBox *sync = nullptr; |
| 66 |
OptionButton *interpolation = nullptr; |
| 67 |
|
| 68 |
HBoxContainer *edit_hb = nullptr; |
| 69 |
SpinBox *edit_value = nullptr; |
| 70 |
Button *open_editor = nullptr; |
| 71 |
|
| 72 |
int selected_point = -1; |
| 73 |
|
| 74 |
Control *blend_space_draw = nullptr; |
| 75 |
|
| 76 |
PanelContainer *error_panel = nullptr; |
| 77 |
Label *error_label = nullptr; |
| 78 |
|
| 79 |
bool updating = false; |
| 80 |
|
| 81 |
static AnimationNodeBlendSpace1DEditor *singleton; |
| 82 |
|
| 83 |
void _blend_space_gui_input(const Ref<InputEvent> &p_event); |
| 84 |
void _blend_space_draw(); |
| 85 |
|
| 86 |
void _update_space(); |
| 87 |
|
| 88 |
void _config_changed(double); |
| 89 |
void _labels_changed(String); |
| 90 |
void _snap_toggled(); |
| 91 |
|
| 92 |
PopupMenu *menu = nullptr; |
| 93 |
PopupMenu *animations_menu = nullptr; |
| 94 |
Vector<String> animations_to_add; |
| 95 |
float add_point_pos = 0.0f; |
| 96 |
Vector<real_t> points; |
| 97 |
|
| 98 |
bool dragging_blend_position = false; |
| 99 |
bool dragging_selected_attempt = false; |
| 100 |
bool dragging_selected = false; |
| 101 |
Vector2 drag_from; |
| 102 |
Vector2 drag_ofs; |
| 103 |
|
| 104 |
void _add_menu_type(int p_index); |
| 105 |
void _add_animation_type(int p_index); |
| 106 |
|
| 107 |
void _tool_switch(int p_tool); |
| 108 |
void _update_edited_point_pos(); |
| 109 |
void _update_tool_erase(); |
| 110 |
void _erase_selected(); |
| 111 |
void _edit_point_pos(double); |
| 112 |
void _open_editor(); |
| 113 |
|
| 114 |
EditorFileDialog *open_file = nullptr; |
| 115 |
Ref<AnimationNode> file_loaded; |
| 116 |
void _file_opened(const String &p_file); |
| 117 |
|
| 118 |
enum { |
| 119 |
MENU_LOAD_FILE = 1000, |
| 120 |
MENU_PASTE = 1001, |
| 121 |
MENU_LOAD_FILE_CONFIRM = 1002 |
| 122 |
}; |
| 123 |
|
| 124 |
StringName get_blend_position_path() const; |
| 125 |
|
| 126 |
protected: |
| 127 |
void _notification(int p_what); |
| 128 |
static void _bind_methods(); |
| 129 |
|
| 130 |
public: |
| 131 |
static AnimationNodeBlendSpace1DEditor *get_singleton() { return singleton; } |
| 132 |
virtual bool can_edit(const Ref<AnimationNode> &p_node) override; |
| 133 |
virtual void edit(const Ref<AnimationNode> &p_node) override; |
| 134 |
AnimationNodeBlendSpace1DEditor(); |
| 135 |
}; |