forked from mirror/openmw-tes3mp
Don't use the character controller to handle text keys
The Animation class has the Ptr and can call to whatever subsystem is needed.
This commit is contained in:
parent
e8cabc9434
commit
b80891099e
3 changed files with 16 additions and 44 deletions
|
@ -148,27 +148,6 @@ void CharacterController::updatePtr(const MWWorld::Ptr &ptr)
|
|||
}
|
||||
|
||||
|
||||
void CharacterController::markerEvent(float time, const std::string &evt)
|
||||
{
|
||||
if(evt == "stop")
|
||||
{
|
||||
if(mAnimQueue.size() > 0)
|
||||
{
|
||||
mAnimQueue.pop_front();
|
||||
if(mAnimQueue.size() > 0)
|
||||
{
|
||||
mCurrentGroup = mAnimQueue.front().first;
|
||||
size_t count = mAnimQueue.front().second;
|
||||
mAnimation->play(mCurrentGroup, "start", "stop", count);
|
||||
}
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
std::cerr<< "Unhandled animation event: "<<evt <<std::endl;
|
||||
}
|
||||
|
||||
|
||||
void CharacterController::update(float duration, Movement &movement)
|
||||
{
|
||||
float speed = 0.0f;
|
||||
|
@ -237,7 +216,17 @@ void CharacterController::update(float duration, Movement &movement)
|
|||
setState(CharState_TurnLeft, true);
|
||||
}
|
||||
else if(getState() != CharState_SpecialIdle || !mAnimation->isPlaying(0))
|
||||
setState((inwater ? CharState_IdleSwim : (sneak ? CharState_IdleSneak : CharState_Idle)), true);
|
||||
{
|
||||
if(mAnimQueue.size() > 0)
|
||||
{
|
||||
mCurrentGroup = mAnimQueue.front().first;
|
||||
size_t count = mAnimQueue.front().second;
|
||||
mAnimQueue.pop_front();
|
||||
mAnimation->play(mCurrentGroup, "start", "stop", count);
|
||||
}
|
||||
else
|
||||
setState((inwater ? CharState_IdleSwim : (sneak ? CharState_IdleSneak : CharState_Idle)), true);
|
||||
}
|
||||
|
||||
movement.mRotation[0] += rot.x * duration;
|
||||
movement.mRotation[1] += rot.y * duration;
|
||||
|
@ -263,17 +252,16 @@ void CharacterController::playGroup(const std::string &groupname, int mode, int
|
|||
else
|
||||
{
|
||||
count = std::max(count, 1);
|
||||
if(mode != 0 || mAnimQueue.size() == 0)
|
||||
if(mode != 0 || getState() != CharState_SpecialIdle)
|
||||
{
|
||||
mAnimQueue.clear();
|
||||
mAnimQueue.push_back(std::make_pair(groupname, count-1));
|
||||
mCurrentGroup = groupname;
|
||||
mState = CharState_SpecialIdle;
|
||||
mAnimation->play(mCurrentGroup, ((mode==2) ? "loop start" : "start"), "stop", count-1);
|
||||
}
|
||||
else if(mode == 0)
|
||||
{
|
||||
mAnimQueue.resize(1);
|
||||
mAnimQueue.clear();
|
||||
mAnimQueue.push_back(std::make_pair(groupname, count-1));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -79,12 +79,6 @@ class CharacterController
|
|||
CharacterState mState;
|
||||
bool mSkipAnim;
|
||||
|
||||
protected:
|
||||
/* Called by the animation whenever a new text key is reached. */
|
||||
void markerEvent(float time, const std::string &evt);
|
||||
|
||||
friend class MWRender::Animation;
|
||||
|
||||
public:
|
||||
CharacterController(const MWWorld::Ptr &ptr, MWRender::Animation *anim, CharacterState state, bool loop);
|
||||
CharacterController(const CharacterController &rhs);
|
||||
|
|
|
@ -499,7 +499,7 @@ bool Animation::handleTextKey(size_t layeridx, const NifOgre::TextKeyMap::const_
|
|||
return true;
|
||||
}
|
||||
|
||||
if(evt.compare(off, len, "loop stop") == 0)
|
||||
if(evt.compare(off, len, "loop stop") == 0 || evt.compare(off, len, "stop") == 0)
|
||||
{
|
||||
if(doLoop(layeridx))
|
||||
{
|
||||
|
@ -508,18 +508,8 @@ bool Animation::handleTextKey(size_t layeridx, const NifOgre::TextKeyMap::const_
|
|||
}
|
||||
return true;
|
||||
}
|
||||
if(evt.compare(off, len, "stop") == 0)
|
||||
{
|
||||
if(doLoop(layeridx))
|
||||
{
|
||||
if(mLayer[layeridx].mTime >= time)
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
// fall-through
|
||||
}
|
||||
if(mController)
|
||||
mController->markerEvent(time, evt.substr(off));
|
||||
|
||||
std::cerr<< "Unhandled animation textkey: "<<evt <<std::endl;
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue