mirror of
https://github.com/Relintai/procedural_animations.git
synced 2024-11-13 08:27:19 +01:00
Started work on an editor plugin.
This commit is contained in:
parent
9b20b6f7d9
commit
adf50b93a2
1
SCsub
1
SCsub
@ -13,6 +13,7 @@ sources = [
|
||||
|
||||
"procedural_animation.cpp",
|
||||
"procedural_animation_player.cpp",
|
||||
"procedural_animation_editor_plugin.cpp",
|
||||
]
|
||||
|
||||
if ARGUMENTS.get('custom_modules_shared', 'no') == 'yes':
|
||||
|
139
procedural_animation_editor_plugin.cpp
Normal file
139
procedural_animation_editor_plugin.cpp
Normal file
@ -0,0 +1,139 @@
|
||||
#include "procedural_animation_editor_plugin.h"
|
||||
|
||||
#include "editor/editor_scale.h"
|
||||
|
||||
void ProceduralAnimationEditor::edit(const Ref<ProceduralAnimation> &animation) {
|
||||
_animation = animation;
|
||||
}
|
||||
|
||||
void ProceduralAnimationEditor::add_frame_button_pressed() {
|
||||
GraphNode *gn = memnew(GraphNode);
|
||||
gn->set_title("Animation Frame");
|
||||
gn->set_show_close_button(true);
|
||||
|
||||
Label *l1 = memnew(Label);
|
||||
l1->set_text("Name");
|
||||
gn->add_child(l1);
|
||||
|
||||
LineEdit *le = memnew(LineEdit);
|
||||
gn->add_child(le);
|
||||
|
||||
Label *l2 = memnew(Label);
|
||||
l2->set_text("Keyframe");
|
||||
gn->add_child(l2);
|
||||
|
||||
HBoxContainer *kfc = memnew(HBoxContainer);
|
||||
gn->add_child(kfc);
|
||||
|
||||
OptionButton *kob = memnew(OptionButton);
|
||||
kfc->add_child(kob);
|
||||
|
||||
Button *kb = memnew(Button);
|
||||
kb->set_text("Edit name");
|
||||
kfc->add_child(kb);
|
||||
|
||||
Label *l3 = memnew(Label);
|
||||
l3->set_text("In Curve");
|
||||
gn->add_child(l3);
|
||||
|
||||
//placeholder
|
||||
Button *pb = memnew(Button);
|
||||
pb->set_text("Edit / Show");
|
||||
pb->set_custom_minimum_size(Size2(0, 69) * EDSCALE);
|
||||
gn->add_child(pb);
|
||||
|
||||
gn->set_slot(0, true, 0, Color(0, 1, 0), true, 0, Color(0, 1, 0));
|
||||
|
||||
_graph_edit->add_child(gn);
|
||||
}
|
||||
|
||||
void ProceduralAnimationEditor::_bind_methods() {
|
||||
ClassDB::bind_method(D_METHOD("add_frame_button_pressed"), &ProceduralAnimationEditor::add_frame_button_pressed);
|
||||
}
|
||||
|
||||
ProceduralAnimationEditor::ProceduralAnimationEditor(EditorNode *p_editor) {
|
||||
set_h_size_flags(SIZE_EXPAND_FILL);
|
||||
|
||||
//top bar
|
||||
HBoxContainer *hbc = memnew(HBoxContainer);
|
||||
add_child(hbc);
|
||||
|
||||
MenuButton *categtnb = memnew(MenuButton);
|
||||
categtnb->set_text("Category");
|
||||
|
||||
PopupMenu *cpm = categtnb->get_popup();
|
||||
cpm->add_item("Add");
|
||||
cpm->add_item("Delete");
|
||||
cpm->add_item("Rename");
|
||||
|
||||
hbc->add_child(categtnb);
|
||||
|
||||
OptionButton *cob = memnew(OptionButton);
|
||||
cob->set_h_size_flags(SIZE_EXPAND_FILL);
|
||||
hbc->add_child(cob);
|
||||
|
||||
MenuButton *animtn = memnew(MenuButton);
|
||||
animtn->set_text("Animation");
|
||||
|
||||
PopupMenu *apm = animtn->get_popup();
|
||||
apm->add_item("Add");
|
||||
apm->add_item("Delete");
|
||||
apm->add_item("Rename");
|
||||
|
||||
hbc->add_child(animtn);
|
||||
|
||||
OptionButton *cab = memnew(OptionButton);
|
||||
cab->set_h_size_flags(SIZE_EXPAND_FILL);
|
||||
hbc->add_child(cab);
|
||||
|
||||
Button *aafb = memnew(Button);
|
||||
aafb->set_text("add frame");
|
||||
aafb->connect("pressed", this, "add_frame_button_pressed");
|
||||
hbc->add_child(aafb);
|
||||
|
||||
Button *pinb = memnew(Button);
|
||||
pinb->set_text("Pin");
|
||||
hbc->add_child(pinb);
|
||||
|
||||
//bottom
|
||||
_graph_edit = memnew(GraphEdit);
|
||||
_graph_edit->set_h_size_flags(SIZE_EXPAND_FILL);
|
||||
_graph_edit->set_v_size_flags(SIZE_EXPAND_FILL);
|
||||
_graph_edit->set_custom_minimum_size(Size2(0, 200) * EDSCALE);
|
||||
add_child(_graph_edit);
|
||||
}
|
||||
ProceduralAnimationEditor::~ProceduralAnimationEditor() {
|
||||
}
|
||||
|
||||
void ProceduralAnimationEditorPlugin::edit(Object *p_object) {
|
||||
}
|
||||
|
||||
bool ProceduralAnimationEditorPlugin::handles(Object *p_object) const {
|
||||
|
||||
bool handles = p_object->is_class("ProceduralAnimation");
|
||||
|
||||
if (handles) {
|
||||
animation_editor_button->show();
|
||||
} else {
|
||||
animation_editor_button->hide();
|
||||
}
|
||||
|
||||
return handles;
|
||||
}
|
||||
|
||||
void ProceduralAnimationEditorPlugin::make_visible(bool p_visible) {
|
||||
}
|
||||
|
||||
ProceduralAnimationEditorPlugin::ProceduralAnimationEditorPlugin(EditorNode *p_node) {
|
||||
|
||||
editor = p_node;
|
||||
|
||||
animation_editor = memnew(ProceduralAnimationEditor(editor));
|
||||
|
||||
animation_editor_button = add_control_to_bottom_panel(animation_editor, "Procedural Animations");
|
||||
|
||||
animation_editor->hide();
|
||||
}
|
||||
|
||||
ProceduralAnimationEditorPlugin::~ProceduralAnimationEditorPlugin() {
|
||||
}
|
52
procedural_animation_editor_plugin.h
Normal file
52
procedural_animation_editor_plugin.h
Normal file
@ -0,0 +1,52 @@
|
||||
#ifndef PROCEDURAL_ANIMATION_EDITOR_PLUGIN_H
|
||||
#define PROCEDURAL_ANIMATION_EDITOR_PLUGIN_H
|
||||
|
||||
#include "editor/editor_plugin.h"
|
||||
#include "editor/pane_drag.h"
|
||||
|
||||
#include "scene/gui/graph_edit.h"
|
||||
#include "scene/gui/menu_button.h"
|
||||
|
||||
#include "procedural_animation.h"
|
||||
|
||||
class ProceduralAnimationEditor : public VBoxContainer {
|
||||
GDCLASS(ProceduralAnimationEditor, VBoxContainer);
|
||||
|
||||
public:
|
||||
void edit(const Ref<ProceduralAnimation> &animation);
|
||||
void add_frame_button_pressed();
|
||||
|
||||
ProceduralAnimationEditor() {}
|
||||
ProceduralAnimationEditor(EditorNode *p_editor);
|
||||
~ProceduralAnimationEditor();
|
||||
|
||||
protected:
|
||||
static void _bind_methods();
|
||||
|
||||
private:
|
||||
Ref<ProceduralAnimation> _animation;
|
||||
GraphEdit *_graph_edit;
|
||||
};
|
||||
|
||||
class ProceduralAnimationEditorPlugin : public EditorPlugin {
|
||||
|
||||
GDCLASS(ProceduralAnimationEditorPlugin, EditorPlugin);
|
||||
|
||||
public:
|
||||
virtual String get_name() const { return "ProceduralAnimation"; }
|
||||
bool has_main_screen() const { return false; }
|
||||
virtual void edit(Object *p_object);
|
||||
virtual bool handles(Object *p_object) const;
|
||||
virtual void make_visible(bool p_visible);
|
||||
|
||||
ProceduralAnimationEditorPlugin(EditorNode *p_node);
|
||||
~ProceduralAnimationEditorPlugin();
|
||||
|
||||
protected:
|
||||
private:
|
||||
ProceduralAnimationEditor *animation_editor;
|
||||
ToolButton *animation_editor_button;
|
||||
EditorNode *editor;
|
||||
};
|
||||
|
||||
#endif
|
@ -3,9 +3,15 @@
|
||||
#include "procedural_animation.h"
|
||||
#include "procedural_animation_player.h"
|
||||
|
||||
#include "procedural_animation_editor_plugin.h"
|
||||
|
||||
void register_procedural_animations_types() {
|
||||
ClassDB::register_class<ProceduralAnimation>();
|
||||
ClassDB::register_class<ProceduralAnimationPlayer>();
|
||||
|
||||
#ifdef TOOLS_ENABLED
|
||||
EditorPlugins::add_by_type<ProceduralAnimationEditorPlugin>();
|
||||
#endif
|
||||
}
|
||||
|
||||
void unregister_procedural_animations_types() {
|
||||
|
Loading…
Reference in New Issue
Block a user