diff --git a/Aquaria/AnimationEditor.cpp b/Aquaria/AnimationEditor.cpp index cd25eb4..a72eaab 100644 --- a/Aquaria/AnimationEditor.cpp +++ b/Aquaria/AnimationEditor.cpp @@ -277,6 +277,7 @@ void AnimationEditor::applyState() addAction(MakeFunctionEvent(AnimationEditor, prevAnim), KEY_PGUP, 0); addAction(MakeFunctionEvent(AnimationEditor, nextAnim), KEY_PGDN, 0); + addAction(MakeFunctionEvent(AnimationEditor, selectAnim), KEY_F9, 0); addAction(MakeFunctionEvent(AnimationEditor, animateOrStop), KEY_RETURN, 0); addAction(MakeFunctionEvent(AnimationEditor, toggleRenderBorders), KEY_B, 0); @@ -1394,6 +1395,23 @@ void AnimationEditor::prevAnim() } } +void AnimationEditor::selectAnim() +{ + if (dsq->isNested()) return; + + std::string name = dsq->getUserInputString("Select anim name:"); + if (name.empty()) + return; + + if(editSprite->selectAnimation(name.c_str())) + { + currentKey = 0; + rebuildKeyframeWidgets(); + } + else + dsq->screenMessage("No such anim name"); +} + void AnimationEditor::reverseAnim() { if (dsq->isNested()) return; diff --git a/Aquaria/AnimationEditor.h b/Aquaria/AnimationEditor.h index 28c958a..c18ad74 100644 --- a/Aquaria/AnimationEditor.h +++ b/Aquaria/AnimationEditor.h @@ -60,6 +60,7 @@ public: void nextAnim(); void prevAnim(); + void selectAnim(); void quit(); diff --git a/BBGE/SkeletalSprite.cpp b/BBGE/SkeletalSprite.cpp index 8d43fbe..0a85f53 100644 --- a/BBGE/SkeletalSprite.cpp +++ b/BBGE/SkeletalSprite.cpp @@ -1243,6 +1243,20 @@ void SkeletalSprite::firstAnimation() animLayers[0].currentAnimation = 0; } +bool SkeletalSprite::selectAnimation(const char* name) +{ + for(size_t i = 0; i < animations.size(); ++i) + { + if(animations[i].name == name) + { + stopAnimation(); + animLayers[0].currentAnimation = i; + return true; + } + } + return false; +} + void SkeletalSprite::lastAnimation() { stopAnimation(); diff --git a/BBGE/SkeletalSprite.h b/BBGE/SkeletalSprite.h index 41acaae..a1d04ee 100644 --- a/BBGE/SkeletalSprite.h +++ b/BBGE/SkeletalSprite.h @@ -277,6 +277,7 @@ public: void prevAnimation(); void lastAnimation(); void firstAnimation(); + bool selectAnimation(const char *name); void updateSelectedBoneColor();