Issue #1018: Don't allow view mode switching while performing an action

actorid
scrawl 11 years ago
parent a3017e16d4
commit d09a86e208

@ -378,10 +378,9 @@ namespace MWInput
MWBase::Environment::get().getWorld()->togglePreviewMode(true);
}
} else {
if (mPreviewPOVDelay > 0.5) {
//disable preview mode
MWBase::Environment::get().getWorld()->togglePreviewMode(false);
} else if (mPreviewPOVDelay > 0.f) {
//disable preview mode
MWBase::Environment::get().getWorld()->togglePreviewMode(false);
if (mPreviewPOVDelay > 0.f && mPreviewPOVDelay <= 0.5) {
MWBase::Environment::get().getWorld()->togglePOV();
}
mPreviewPOVDelay = 0.f;

@ -996,6 +996,16 @@ void Animation::detachObjectFromBone(Ogre::MovableObject *obj)
mSkelBase->detachObjectFromBone(obj);
}
bool Animation::isPlaying(Group group) const
{
for (AnimStateMap::const_iterator stateiter = mStates.begin(); stateiter != mStates.end(); ++stateiter)
{
if(stateiter->second.mGroups == group)
return true;
}
return false;
}
void Animation::addEffect(const std::string &model, int effectId, bool loop, const std::string &bonename, std::string texture)
{
// Early out if we already have this effect

@ -258,6 +258,8 @@ public:
/** Returns true if the named animation group is playing. */
bool isPlaying(const std::string &groupname) const;
bool isPlaying(Group group) const;
/** Gets info about the given animation group.
* \param groupname Animation group to check.
* \param complete Stores completion amount (0 = at start key, 0.5 = half way between start and stop keys), etc.

@ -29,7 +29,9 @@ namespace MWRender
mNearest(30.f),
mFurthest(800.f),
mIsNearest(false),
mIsFurthest(false)
mIsFurthest(false),
mVanityToggleQueued(false),
mViewModeToggleQueued(false)
{
mVanity.enabled = false;
mVanity.allowed = true;
@ -103,6 +105,23 @@ namespace MWRender
void Camera::update(float duration, bool paused)
{
if (!mAnimation->isPlaying(MWRender::Animation::Group_UpperBody))
{
// Now process the view changes we queued earlier
if (mVanityToggleQueued)
{
toggleVanityMode(!mVanity.enabled);
mVanityToggleQueued = false;
}
if (mViewModeToggleQueued)
{
togglePreviewMode(false);
toggleViewMode();
mViewModeToggleQueued = false;
}
}
updateListener();
if (paused)
return;
@ -121,6 +140,14 @@ namespace MWRender
void Camera::toggleViewMode()
{
// Changing the view will stop all playing animations, so if we are playing
// anything important, queue the view change for later
if (mAnimation->isPlaying(MWRender::Animation::Group_UpperBody))
{
mViewModeToggleQueued = true;
return;
}
mFirstPersonView = !mFirstPersonView;
processViewChange();
@ -140,6 +167,14 @@ namespace MWRender
bool Camera::toggleVanityMode(bool enable)
{
// Changing the view will stop all playing animations, so if we are playing
// anything important, queue the view change for later
if (mAnimation->isPlaying(MWRender::Animation::Group_UpperBody))
{
mVanityToggleQueued = true;
return false;
}
if(!mVanity.allowed && enable)
return false;
@ -168,6 +203,9 @@ namespace MWRender
void Camera::togglePreviewMode(bool enable)
{
if (mAnimation->isPlaying(MWRender::Animation::Group_UpperBody))
return;
if(mPreviewMode == enable)
return;
@ -184,7 +222,6 @@ namespace MWRender
}
mCamera->setPosition(0.f, 0.f, offset);
rotateCamera(Ogre::Vector3(getPitch(), 0.f, getYaw()), false);
}
void Camera::setSneakOffset()
@ -319,6 +356,7 @@ namespace MWRender
mAnimation->setViewMode(NpcAnimation::VM_Normal);
mCameraNode->attachObject(mCamera);
}
rotateCamera(Ogre::Vector3(getPitch(), 0.f, getYaw()), false);
}
void Camera::getPosition(Ogre::Vector3 &focal, Ogre::Vector3 &camera)

@ -47,6 +47,9 @@ namespace MWRender
bool mDistanceAdjusted;
bool mVanityToggleQueued;
bool mViewModeToggleQueued;
/// Updates sound manager listener data
void updateListener();
@ -77,6 +80,7 @@ namespace MWRender
bool toggleVanityMode(bool enable);
void allowVanityMode(bool allow);
/// @note this may be ignored if an important animation is currently playing
void togglePreviewMode(bool enable);
/// \brief Lowers the camera for sneak.

Loading…
Cancel
Save