Show/hide play related buttons, and work on the player's api.

This commit is contained in:
Relintai 2020-03-14 17:01:48 +01:00
parent 83d1574a04
commit ec07898853
3 changed files with 52 additions and 3 deletions

View File

@ -30,6 +30,12 @@ void ProceduralAnimationEditor::edit(const Ref<ProceduralAnimation> &animation)
_selected_category = -1;
_selected_animation = -1;
_stop->hide();
_play->hide();
_play_from->hide();
_play_bw->hide();
_play_bw_from->hide();
clear_keyframe_nodes();
refresh_option_buttons();
}
@ -39,6 +45,17 @@ void ProceduralAnimationEditor::edit(ProceduralAnimationPlayer *player) {
_selected_category = -1;
_selected_animation = -1;
_stop->show();
_play->show();
_play_from->show();
_play_bw->show();
_play_bw_from->show();
_animation = player->get_animation();
clear_keyframe_nodes();
refresh_option_buttons();
}
void ProceduralAnimationEditor::load_selected_animation() {
@ -684,6 +701,7 @@ void ProceduralAnimationEditorPlugin::edit(Object *p_object) {
animation_editor->edit(Object::cast_to<ProceduralAnimationPlayer>(p_object));
animation_editor_button->show();
} else {
animation_editor_button->set_pressed(false);
animation_editor_button->hide();
}
}
@ -698,8 +716,7 @@ bool ProceduralAnimationEditorPlugin::handles(Object *p_object) const {
if (player)
animation_editor_button->set_pressed(true);
} else {
if (player)
animation_editor_button->set_pressed(false);
animation_editor_button->set_pressed(false);
animation_editor_button->hide();
}

View File

@ -22,6 +22,24 @@ SOFTWARE.
#include "procedural_animation_player.h"
Ref<ProceduralAnimation> ProceduralAnimationPlayer::get_animation() {
return _animation;
}
void ProceduralAnimationPlayer::set_animation(const Ref<ProceduralAnimation> &animation) {
_animation = animation;
}
void ProceduralAnimationPlayer::play(const StringName &p_name, float p_custom_blend, float p_custom_scale, bool p_from_end) {
print_error("adada");
}
ProceduralAnimationPlayer::ProceduralAnimationPlayer() {
}
ProceduralAnimationPlayer::~ProceduralAnimationPlayer() {
_animation.unref();
}
void ProceduralAnimationPlayer::_bind_methods() {
ClassDB::bind_method(D_METHOD("get_animation"), &ProceduralAnimationPlayer::get_animation);
ClassDB::bind_method(D_METHOD("set_animation", "value"), &ProceduralAnimationPlayer::set_animation);
ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "animation", PROPERTY_HINT_RESOURCE_TYPE, "ProceduralAnimation"), "set_animation", "get_animation");
}

View File

@ -25,11 +25,25 @@ SOFTWARE.
#include "scene/main/node.h"
#include "procedural_animation.h"
class ProceduralAnimationPlayer : public Node {
GDCLASS(ProceduralAnimationPlayer, Node);
public:
Ref<ProceduralAnimation> get_animation();
void set_animation(const Ref<ProceduralAnimation> &animation);
void play(const StringName &p_name = StringName(), float p_custom_blend = -1, float p_custom_scale = 1.0, bool p_from_end = false);
ProceduralAnimationPlayer();
~ProceduralAnimationPlayer();
protected:
static void _bind_methods();
private:
Ref<ProceduralAnimation> _animation;
};
#endif