mirror of
https://github.com/OpenMW/openmw.git
synced 2025-02-22 10:09:41 +00:00
Issue #1018: Don't allow view mode switching while performing an action
This commit is contained in:
parent
a3017e16d4
commit
d09a86e208
5 changed files with 59 additions and 6 deletions
|
@ -378,10 +378,9 @@ namespace MWInput
|
||||||
MWBase::Environment::get().getWorld()->togglePreviewMode(true);
|
MWBase::Environment::get().getWorld()->togglePreviewMode(true);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (mPreviewPOVDelay > 0.5) {
|
//disable preview mode
|
||||||
//disable preview mode
|
MWBase::Environment::get().getWorld()->togglePreviewMode(false);
|
||||||
MWBase::Environment::get().getWorld()->togglePreviewMode(false);
|
if (mPreviewPOVDelay > 0.f && mPreviewPOVDelay <= 0.5) {
|
||||||
} else if (mPreviewPOVDelay > 0.f) {
|
|
||||||
MWBase::Environment::get().getWorld()->togglePOV();
|
MWBase::Environment::get().getWorld()->togglePOV();
|
||||||
}
|
}
|
||||||
mPreviewPOVDelay = 0.f;
|
mPreviewPOVDelay = 0.f;
|
||||||
|
|
|
@ -996,6 +996,16 @@ void Animation::detachObjectFromBone(Ogre::MovableObject *obj)
|
||||||
mSkelBase->detachObjectFromBone(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)
|
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
|
// Early out if we already have this effect
|
||||||
|
|
|
@ -258,6 +258,8 @@ public:
|
||||||
/** Returns true if the named animation group is playing. */
|
/** Returns true if the named animation group is playing. */
|
||||||
bool isPlaying(const std::string &groupname) const;
|
bool isPlaying(const std::string &groupname) const;
|
||||||
|
|
||||||
|
bool isPlaying(Group group) const;
|
||||||
|
|
||||||
/** Gets info about the given animation group.
|
/** Gets info about the given animation group.
|
||||||
* \param groupname Animation group to check.
|
* \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.
|
* \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),
|
mNearest(30.f),
|
||||||
mFurthest(800.f),
|
mFurthest(800.f),
|
||||||
mIsNearest(false),
|
mIsNearest(false),
|
||||||
mIsFurthest(false)
|
mIsFurthest(false),
|
||||||
|
mVanityToggleQueued(false),
|
||||||
|
mViewModeToggleQueued(false)
|
||||||
{
|
{
|
||||||
mVanity.enabled = false;
|
mVanity.enabled = false;
|
||||||
mVanity.allowed = true;
|
mVanity.allowed = true;
|
||||||
|
@ -103,6 +105,23 @@ namespace MWRender
|
||||||
|
|
||||||
void Camera::update(float duration, bool paused)
|
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();
|
updateListener();
|
||||||
if (paused)
|
if (paused)
|
||||||
return;
|
return;
|
||||||
|
@ -121,6 +140,14 @@ namespace MWRender
|
||||||
|
|
||||||
void Camera::toggleViewMode()
|
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;
|
mFirstPersonView = !mFirstPersonView;
|
||||||
processViewChange();
|
processViewChange();
|
||||||
|
|
||||||
|
@ -140,6 +167,14 @@ namespace MWRender
|
||||||
|
|
||||||
bool Camera::toggleVanityMode(bool enable)
|
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)
|
if(!mVanity.allowed && enable)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
|
@ -168,6 +203,9 @@ namespace MWRender
|
||||||
|
|
||||||
void Camera::togglePreviewMode(bool enable)
|
void Camera::togglePreviewMode(bool enable)
|
||||||
{
|
{
|
||||||
|
if (mAnimation->isPlaying(MWRender::Animation::Group_UpperBody))
|
||||||
|
return;
|
||||||
|
|
||||||
if(mPreviewMode == enable)
|
if(mPreviewMode == enable)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
@ -184,7 +222,6 @@ namespace MWRender
|
||||||
}
|
}
|
||||||
|
|
||||||
mCamera->setPosition(0.f, 0.f, offset);
|
mCamera->setPosition(0.f, 0.f, offset);
|
||||||
rotateCamera(Ogre::Vector3(getPitch(), 0.f, getYaw()), false);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void Camera::setSneakOffset()
|
void Camera::setSneakOffset()
|
||||||
|
@ -319,6 +356,7 @@ namespace MWRender
|
||||||
mAnimation->setViewMode(NpcAnimation::VM_Normal);
|
mAnimation->setViewMode(NpcAnimation::VM_Normal);
|
||||||
mCameraNode->attachObject(mCamera);
|
mCameraNode->attachObject(mCamera);
|
||||||
}
|
}
|
||||||
|
rotateCamera(Ogre::Vector3(getPitch(), 0.f, getYaw()), false);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Camera::getPosition(Ogre::Vector3 &focal, Ogre::Vector3 &camera)
|
void Camera::getPosition(Ogre::Vector3 &focal, Ogre::Vector3 &camera)
|
||||||
|
|
|
@ -47,6 +47,9 @@ namespace MWRender
|
||||||
|
|
||||||
bool mDistanceAdjusted;
|
bool mDistanceAdjusted;
|
||||||
|
|
||||||
|
bool mVanityToggleQueued;
|
||||||
|
bool mViewModeToggleQueued;
|
||||||
|
|
||||||
/// Updates sound manager listener data
|
/// Updates sound manager listener data
|
||||||
void updateListener();
|
void updateListener();
|
||||||
|
|
||||||
|
@ -77,6 +80,7 @@ namespace MWRender
|
||||||
bool toggleVanityMode(bool enable);
|
bool toggleVanityMode(bool enable);
|
||||||
void allowVanityMode(bool allow);
|
void allowVanityMode(bool allow);
|
||||||
|
|
||||||
|
/// @note this may be ignored if an important animation is currently playing
|
||||||
void togglePreviewMode(bool enable);
|
void togglePreviewMode(bool enable);
|
||||||
|
|
||||||
/// \brief Lowers the camera for sneak.
|
/// \brief Lowers the camera for sneak.
|
||||||
|
|
Loading…
Reference in a new issue