From d2fc3c7b333f7dedd605b073dcd5a22eb853e3b4 Mon Sep 17 00:00:00 2001 From: Chris Robinson Date: Wed, 16 Jan 2013 13:09:21 -0800 Subject: [PATCH] Add a method to tell the character controller of new text keys --- apps/openmw/mwmechanics/character.cpp | 21 +++++++++++++++++++++ apps/openmw/mwmechanics/character.hpp | 7 +++++++ apps/openmw/mwrender/animation.cpp | 9 +++++++++ 3 files changed, 37 insertions(+) diff --git a/apps/openmw/mwmechanics/character.cpp b/apps/openmw/mwmechanics/character.cpp index 21ebd255a..6496ba9f2 100644 --- a/apps/openmw/mwmechanics/character.cpp +++ b/apps/openmw/mwmechanics/character.cpp @@ -21,6 +21,7 @@ #include "../mwrender/animation.hpp" + namespace MWMechanics { @@ -42,6 +43,26 @@ CharacterController::CharacterController(const MWWorld::Ptr &ptr, MWRender::Anim } } +CharacterController::CharacterController(const CharacterController &rhs) + : mPtr(rhs.mPtr), mAnimation(rhs.mAnimation), mState(rhs.mState) +{ + if(!mAnimation) + return; + /* We've been copied. Update the animation with the new controller. */ + mAnimation->setController(this); +} + + +void CharacterController::markerEvent(const std::string &evt) +{ + std::string::size_type gp = evt.find(':'); + if(gp >= evt.length()-2) + { + std::cerr<< "Unexpected animation marker: \""<end() && mCurGroup.mNext->first <= mCurGroup.mLoopStop->first) { + if(mController) + mController->markerEvent(mCurGroup.mNext->second); mCurGroup.mNext++; } @@ -256,6 +261,8 @@ void Animation::runAnimation(float timepassed) while(mCurGroup.mNext != mCurGroup.mTextKeys->end() && mCurGroup.mNext->first <= mCurGroup.mStop->first) { + if(mController) + mController->markerEvent(mCurGroup.mNext->second); mCurGroup.mNext++; } if(mNextGroup.mLoops > 0) @@ -275,6 +282,8 @@ void Animation::runAnimation(float timepassed) while(mCurGroup.mNext != mCurGroup.mTextKeys->end() && mCurGroup.mNext->first <= mTime) { + if(mController) + mController->markerEvent(mCurGroup.mNext->second); mCurGroup.mNext++; }