Added a skeleton editor plugin for the ProceduralAnimationPlayer.

This commit is contained in:
Relintai 2020-03-06 09:06:24 +01:00
parent ba464ef045
commit 9b1868668d
5 changed files with 168 additions and 3 deletions

1
SCsub
View File

@ -14,6 +14,7 @@ sources = [
"procedural_animation.cpp",
"procedural_animation_player.cpp",
"procedural_animation_editor_plugin.cpp",
"procedural_animation_player_editor_plugin.cpp",
]
if ARGUMENTS.get('custom_modules_shared', 'no') == 'yes':

View File

@ -124,7 +124,7 @@ public:
void on_animation_keyframe_spinbox_value_changed(const String &value);
void changed();
ProceduralAnimationEditorGraphNode();
~ProceduralAnimationEditorGraphNode();
@ -147,9 +147,9 @@ class ProceduralAnimationEditorPlugin : public EditorPlugin {
GDCLASS(ProceduralAnimationEditorPlugin, EditorPlugin);
public:
virtual String get_name() const { return "ProceduralAnimation"; }
virtual String get_name() const { return "ProceduralAnimationEditor"; }
bool has_main_screen() const { return false; }
virtual void edit(Object *p_object);
virtual void edit(Object *p_object);
virtual bool handles(Object *p_object) const;
virtual void make_visible(bool p_visible);

View File

@ -0,0 +1,90 @@
/*
Copyright (c) 2020 Péter Magyar
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
*/
#include "procedural_animation_player_editor_plugin.h"
#include "editor/editor_scale.h"
void ProceduralAnimationPlayerEditor::edit(ProceduralAnimationPlayer *player) {
_animation_player = player;
_selected_category = -1;
_selected_animation = -1;
}
void ProceduralAnimationPlayerEditor::_bind_methods() {
}
ProceduralAnimationPlayerEditor::ProceduralAnimationPlayerEditor() {
_animation_player = NULL;
_selected_category = -1;
_selected_animation = -1;
}
ProceduralAnimationPlayerEditor::ProceduralAnimationPlayerEditor(EditorNode *p_editor) {
set_h_size_flags(SIZE_EXPAND_FILL);
_animation_player = NULL;
_selected_category = -1;
_selected_animation = -1;
}
ProceduralAnimationPlayerEditor::~ProceduralAnimationPlayerEditor() {
}
void ProceduralAnimationPlayerEditorPlugin::edit(Object *p_object) {
if (Object::cast_to<ProceduralAnimationPlayer>(p_object)) {
animation_editor->edit(Object::cast_to<ProceduralAnimationPlayer>(p_object));
animation_editor_button->show();
} else
animation_editor_button->hide();
}
bool ProceduralAnimationPlayerEditorPlugin::handles(Object *p_object) const {
bool handles = p_object->is_class("ProceduralAnimationPlayer");
if (handles) {
animation_editor_button->show();
} else {
animation_editor_button->hide();
}
return handles;
}
void ProceduralAnimationPlayerEditorPlugin::make_visible(bool p_visible) {
}
ProceduralAnimationPlayerEditorPlugin::ProceduralAnimationPlayerEditorPlugin(EditorNode *p_node) {
editor = p_node;
animation_editor = memnew(ProceduralAnimationPlayerEditor(editor));
animation_editor_button = add_control_to_bottom_panel(animation_editor, "Procedural Animations");
animation_editor->hide();
}
ProceduralAnimationPlayerEditorPlugin::~ProceduralAnimationPlayerEditorPlugin() {
}

View File

@ -0,0 +1,72 @@
/*
Copyright (c) 2020 Péter Magyar
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
*/
#ifndef PROCEDURAL_ANIMATION_PLAYER_EDITOR_PLUGIN_H
#define PROCEDURAL_ANIMATION_PLAYER_EDITOR_PLUGIN_H
#include "scene/gui/box_container.h"
#include "editor/editor_plugin.h"
#include "procedural_animation_player.h"
#include "core/core_string_names.h"
class ProceduralAnimationPlayerEditor : public VBoxContainer {
GDCLASS(ProceduralAnimationPlayerEditor, VBoxContainer);
public:
void edit(ProceduralAnimationPlayer *player);
ProceduralAnimationPlayerEditor();
ProceduralAnimationPlayerEditor(EditorNode *p_editor);
~ProceduralAnimationPlayerEditor();
protected:
static void _bind_methods();
private:
int _selected_category;
int _selected_animation;
ProceduralAnimationPlayer *_animation_player;
};
class ProceduralAnimationPlayerEditorPlugin : public EditorPlugin {
GDCLASS(ProceduralAnimationPlayerEditorPlugin, EditorPlugin);
public:
virtual String get_name() const { return "ProceduralAnimationPlayerEditor"; }
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);
ProceduralAnimationPlayerEditorPlugin(EditorNode *p_node);
~ProceduralAnimationPlayerEditorPlugin();
protected:
private:
ProceduralAnimationPlayerEditor *animation_editor;
ToolButton *animation_editor_button;
EditorNode *editor;
};
#endif

View File

@ -26,6 +26,7 @@ SOFTWARE.
#include "procedural_animation_player.h"
#include "procedural_animation_editor_plugin.h"
#include "procedural_animation_player_editor_plugin.h"
void register_procedural_animations_types() {
ClassDB::register_class<ProceduralAnimation>();
@ -33,6 +34,7 @@ void register_procedural_animations_types() {
#ifdef TOOLS_ENABLED
EditorPlugins::add_by_type<ProceduralAnimationEditorPlugin>();
EditorPlugins::add_by_type<ProceduralAnimationPlayerEditorPlugin>();
#endif
}