1
0
mirror of https://gitlab.com/OpenMW/openmw.git synced 2025-01-25 06:35:30 +00:00

Add a method to tell the character controller of new text keys

This commit is contained in:
Chris Robinson 2013-01-16 13:09:21 -08:00
parent 0a2f92f679
commit d2fc3c7b33
3 changed files with 37 additions and 0 deletions

View File

@ -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: \""<<evt<<"\"" <<std::endl;
return;
}
}
void CharacterController::setState(CharacterState state)
{

View File

@ -23,8 +23,15 @@ class CharacterController
CharacterState mState;
protected:
/* Called by the animation whenever a new text key is reached. */
void markerEvent(const std::string &evt);
friend class MWRender::Animation;
public:
CharacterController(const MWWorld::Ptr &ptr, MWRender::Animation *anim, CharacterState state);
CharacterController(const CharacterController &rhs);
void setState(CharacterState state);
CharacterState getState() const

View File

@ -10,11 +10,14 @@
#include "../mwbase/environment.hpp"
#include "../mwbase/world.hpp"
#include "../mwmechanics/character.hpp"
namespace MWRender
{
Animation::Animation(const MWWorld::Ptr &ptr)
: mPtr(ptr)
, mController(NULL)
, mInsert(NULL)
, mAccumRoot(NULL)
, mNonAccumRoot(NULL)
@ -240,6 +243,8 @@ void Animation::runAnimation(float timepassed)
while(mCurGroup.mNext != mCurGroup.mTextKeys->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++;
}