| 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/docks/editor_dock.h" |
| 34 |
#include "editor/plugins/editor_plugin.h" |
| 35 |
#include "scene/animation/animation_tree.h" |
| 36 |
#include "scene/gui/graph_edit.h" |
| 37 |
|
| 38 |
class Button; |
| 39 |
class EditorFileDialog; |
| 40 |
class ScrollContainer; |
| 41 |
|
| 42 |
class AnimationTreeNodeEditorPlugin : public VBoxContainer { |
| 43 |
GDCLASS(AnimationTreeNodeEditorPlugin, VBoxContainer); |
| 44 |
|
| 45 |
public: |
| 46 |
virtual bool can_edit(const Ref<AnimationNode> &p_node) = 0; |
| 47 |
virtual void edit(const Ref<AnimationNode> &p_node) = 0; |
| 48 |
}; |
| 49 |
|
| 50 |
class AnimationTreeEditor : public EditorDock { |
| 51 |
GDCLASS(AnimationTreeEditor, EditorDock); |
| 52 |
|
| 53 |
ScrollContainer *path_edit = nullptr; |
| 54 |
HBoxContainer *path_hb = nullptr; |
| 55 |
|
| 56 |
AnimationTree *tree = nullptr; |
| 57 |
MarginContainer *editor_base = nullptr; |
| 58 |
|
| 59 |
Vector<String> button_path; |
| 60 |
Vector<String> edited_path; |
| 61 |
Vector<AnimationTreeNodeEditorPlugin *> editors; |
| 62 |
|
| 63 |
void _update_path(); |
| 64 |
void _clear_editors(); |
| 65 |
ObjectID current_root; |
| 66 |
|
| 67 |
void _path_button_pressed(int p_path); |
| 68 |
void _animation_list_changed(); |
| 69 |
|
| 70 |
static Vector<String> get_animation_list(); |
| 71 |
|
| 72 |
protected: |
| 73 |
void _notification(int p_what); |
| 74 |
void _node_removed(Node *p_node); |
| 75 |
|
| 76 |
static AnimationTreeEditor *singleton; |
| 77 |
|
| 78 |
public: |
| 79 |
AnimationTree *get_animation_tree() { return tree; } |
| 80 |
void add_plugin(AnimationTreeNodeEditorPlugin *p_editor); |
| 81 |
void remove_plugin(AnimationTreeNodeEditorPlugin *p_editor); |
| 82 |
|
| 83 |
String get_base_path(); |
| 84 |
|
| 85 |
bool can_edit(const Ref<AnimationNode> &p_node) const; |
| 86 |
|
| 87 |
void edit_path(const Vector<String> &p_path); |
| 88 |
Vector<String> get_edited_path() const; |
| 89 |
|
| 90 |
void enter_editor(const String &p_path = ""); |
| 91 |
static AnimationTreeEditor *get_singleton() { return singleton; } |
| 92 |
void edit(AnimationTree *p_tree); |
| 93 |
AnimationTreeEditor(); |
| 94 |
}; |
| 95 |
|
| 96 |
class AnimationTreeEditorPlugin : public EditorPlugin { |
| 97 |
GDCLASS(AnimationTreeEditorPlugin, EditorPlugin); |
| 98 |
|
| 99 |
AnimationTreeEditor *anim_tree_editor = nullptr; |
| 100 |
|
| 101 |
public: |
| 102 |
virtual String get_plugin_name() const override { return "AnimationTree"; } |
| 103 |
bool has_main_screen() const override { return false; } |
| 104 |
virtual void edit(Object *p_object) override; |
| 105 |
virtual bool handles(Object *p_object) const override; |
| 106 |
virtual void make_visible(bool p_visible) override; |
| 107 |
|
| 108 |
AnimationTreeEditorPlugin(); |
| 109 |
}; |