summaryrefslogtreecommitdiff
path: root/scene/animation
diff options
context:
space:
mode:
authorBojidar Marinov <bojidar.marinov.bg@gmail.com>2018-01-14 12:28:57 +0200
committerBojidar Marinov <bojidar.marinov.bg@gmail.com>2018-01-14 12:28:57 +0200
commitf2355949c458bcc0eaf967f57d782520a168f563 (patch)
tree221dacd8362c487f248be8718aed992851fd81d7 /scene/animation
parent859ac6233d79a8e699de7f8cd2d16238d8887dfe (diff)
Fix an issue with the animation editor not seeking to the target time properly.
Fixes #15646.
Diffstat (limited to 'scene/animation')
-rw-r--r--scene/animation/animation_player.cpp28
-rw-r--r--scene/animation/animation_player.h2
2 files changed, 23 insertions, 7 deletions
diff --git a/scene/animation/animation_player.cpp b/scene/animation/animation_player.cpp
index d1829ce4d4..b20bc64d41 100644
--- a/scene/animation/animation_player.cpp
+++ b/scene/animation/animation_player.cpp
@@ -977,6 +977,7 @@ bool AnimationPlayer::is_playing() const {
return true;
*/
}
+
void AnimationPlayer::set_current_animation(const String &p_anim) {
if (p_anim == "[stop]" || p_anim == "") {
@@ -986,13 +987,6 @@ void AnimationPlayer::set_current_animation(const String &p_anim) {
} else {
// Same animation, do not replay from start
}
-
- /*
- ERR_FAIL_COND(!animation_set.has(p_anim));
- playback.current.pos = 0;
- playback.current.from = &animation_set[p_anim];
- playback.assigned = p_anim;
- */
}
String AnimationPlayer::get_current_animation() const {
@@ -1000,6 +994,23 @@ String AnimationPlayer::get_current_animation() const {
return (is_playing() ? playback.assigned : "");
}
+void AnimationPlayer::set_assigned_animation(const String &p_anim) {
+
+ if (is_playing()) {
+ play(p_anim);
+ } else {
+ ERR_FAIL_COND(!animation_set.has(p_anim));
+ playback.current.pos = 0;
+ playback.current.from = &animation_set[p_anim];
+ playback.assigned = p_anim;
+ }
+}
+
+String AnimationPlayer::get_assigned_animation() const {
+
+ return playback.assigned;
+}
+
void AnimationPlayer::stop(bool p_reset) {
Playback &c = playback;
@@ -1301,6 +1312,8 @@ void AnimationPlayer::_bind_methods() {
ClassDB::bind_method(D_METHOD("set_current_animation", "anim"), &AnimationPlayer::set_current_animation);
ClassDB::bind_method(D_METHOD("get_current_animation"), &AnimationPlayer::get_current_animation);
+ ClassDB::bind_method(D_METHOD("set_assigned_animation", "anim"), &AnimationPlayer::set_assigned_animation);
+ ClassDB::bind_method(D_METHOD("get_assigned_animation"), &AnimationPlayer::get_assigned_animation);
ClassDB::bind_method(D_METHOD("queue", "name"), &AnimationPlayer::queue);
ClassDB::bind_method(D_METHOD("clear_queue"), &AnimationPlayer::clear_queue);
@@ -1331,6 +1344,7 @@ void AnimationPlayer::_bind_methods() {
ADD_PROPERTY(PropertyInfo(Variant::NODE_PATH, "root_node"), "set_root", "get_root");
ADD_PROPERTY(PropertyInfo(Variant::STRING, "current_animation", PROPERTY_HINT_ENUM, "", PROPERTY_USAGE_EDITOR | PROPERTY_USAGE_ANIMATE_AS_TRIGGER), "set_current_animation", "get_current_animation");
+ ADD_PROPERTY(PropertyInfo(Variant::STRING, "assigned_animation", PROPERTY_HINT_NONE, "", 0), "set_assigned_animation", "get_assigned_animation");
ADD_PROPERTY(PropertyInfo(Variant::STRING, "autoplay", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_NOEDITOR), "set_autoplay", "get_autoplay");
ADD_PROPERTY(PropertyInfo(Variant::REAL, "current_animation_length", PROPERTY_HINT_NONE, "", 0), "", "get_current_animation_length");
ADD_PROPERTY(PropertyInfo(Variant::REAL, "current_animation_position", PROPERTY_HINT_NONE, "", 0), "", "get_current_animation_position");
diff --git a/scene/animation/animation_player.h b/scene/animation/animation_player.h
index ef1720443f..ef758bac44 100644
--- a/scene/animation/animation_player.h
+++ b/scene/animation/animation_player.h
@@ -284,6 +284,8 @@ public:
bool is_playing() const;
String get_current_animation() const;
void set_current_animation(const String &p_anim);
+ String get_assigned_animation() const;
+ void set_assigned_animation(const String &p_anim);
void stop_all();
void set_active(bool p_active);
bool is_active() const;