forked from mirror/openmw-tes3mp
Add a method to tell the character controller of new text keys
This commit is contained in:
parent
0a2f92f679
commit
d2fc3c7b33
3 changed files with 37 additions and 0 deletions
|
@ -21,6 +21,7 @@
|
||||||
|
|
||||||
#include "../mwrender/animation.hpp"
|
#include "../mwrender/animation.hpp"
|
||||||
|
|
||||||
|
|
||||||
namespace MWMechanics
|
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)
|
void CharacterController::setState(CharacterState state)
|
||||||
{
|
{
|
||||||
|
|
|
@ -23,8 +23,15 @@ class CharacterController
|
||||||
|
|
||||||
CharacterState mState;
|
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:
|
public:
|
||||||
CharacterController(const MWWorld::Ptr &ptr, MWRender::Animation *anim, CharacterState state);
|
CharacterController(const MWWorld::Ptr &ptr, MWRender::Animation *anim, CharacterState state);
|
||||||
|
CharacterController(const CharacterController &rhs);
|
||||||
|
|
||||||
void setState(CharacterState state);
|
void setState(CharacterState state);
|
||||||
CharacterState getState() const
|
CharacterState getState() const
|
||||||
|
|
|
@ -10,11 +10,14 @@
|
||||||
#include "../mwbase/environment.hpp"
|
#include "../mwbase/environment.hpp"
|
||||||
#include "../mwbase/world.hpp"
|
#include "../mwbase/world.hpp"
|
||||||
|
|
||||||
|
#include "../mwmechanics/character.hpp"
|
||||||
|
|
||||||
namespace MWRender
|
namespace MWRender
|
||||||
{
|
{
|
||||||
|
|
||||||
Animation::Animation(const MWWorld::Ptr &ptr)
|
Animation::Animation(const MWWorld::Ptr &ptr)
|
||||||
: mPtr(ptr)
|
: mPtr(ptr)
|
||||||
|
, mController(NULL)
|
||||||
, mInsert(NULL)
|
, mInsert(NULL)
|
||||||
, mAccumRoot(NULL)
|
, mAccumRoot(NULL)
|
||||||
, mNonAccumRoot(NULL)
|
, mNonAccumRoot(NULL)
|
||||||
|
@ -240,6 +243,8 @@ void Animation::runAnimation(float timepassed)
|
||||||
while(mCurGroup.mNext != mCurGroup.mTextKeys->end() &&
|
while(mCurGroup.mNext != mCurGroup.mTextKeys->end() &&
|
||||||
mCurGroup.mNext->first <= mCurGroup.mLoopStop->first)
|
mCurGroup.mNext->first <= mCurGroup.mLoopStop->first)
|
||||||
{
|
{
|
||||||
|
if(mController)
|
||||||
|
mController->markerEvent(mCurGroup.mNext->second);
|
||||||
mCurGroup.mNext++;
|
mCurGroup.mNext++;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -256,6 +261,8 @@ void Animation::runAnimation(float timepassed)
|
||||||
while(mCurGroup.mNext != mCurGroup.mTextKeys->end() &&
|
while(mCurGroup.mNext != mCurGroup.mTextKeys->end() &&
|
||||||
mCurGroup.mNext->first <= mCurGroup.mStop->first)
|
mCurGroup.mNext->first <= mCurGroup.mStop->first)
|
||||||
{
|
{
|
||||||
|
if(mController)
|
||||||
|
mController->markerEvent(mCurGroup.mNext->second);
|
||||||
mCurGroup.mNext++;
|
mCurGroup.mNext++;
|
||||||
}
|
}
|
||||||
if(mNextGroup.mLoops > 0)
|
if(mNextGroup.mLoops > 0)
|
||||||
|
@ -275,6 +282,8 @@ void Animation::runAnimation(float timepassed)
|
||||||
while(mCurGroup.mNext != mCurGroup.mTextKeys->end() &&
|
while(mCurGroup.mNext != mCurGroup.mTextKeys->end() &&
|
||||||
mCurGroup.mNext->first <= mTime)
|
mCurGroup.mNext->first <= mTime)
|
||||||
{
|
{
|
||||||
|
if(mController)
|
||||||
|
mController->markerEvent(mCurGroup.mNext->second);
|
||||||
mCurGroup.mNext++;
|
mCurGroup.mNext++;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue