Only allow resting in air when a bed is used

pull/541/head
Capostrophic 6 years ago
parent aacc275e9c
commit 7202f45771

@ -459,8 +459,9 @@ namespace MWBase
{
Rest_Allowed = 0,
Rest_OnlyWaiting = 1,
Rest_PlayerIsUnderwater = 2,
Rest_EnemiesAreNearby = 3
Rest_PlayerIsInAir = 2,
Rest_PlayerIsUnderwater = 3,
Rest_EnemiesAreNearby = 4
};
/// check if the player is allowed to rest

@ -80,10 +80,17 @@ namespace MWGui
mTimeAdvancer.eventInterrupted += MyGUI::newDelegate(this, &WaitDialog::onWaitingInterrupted);
mTimeAdvancer.eventFinished += MyGUI::newDelegate(this, &WaitDialog::onWaitingFinished);
}
void WaitDialog::onReferenceUnavailable ()
{
MWBase::Environment::get().getWindowManager()->removeGuiMode(GM_Rest);
resetReference();
}
void WaitDialog::setPtr(const MWWorld::Ptr &ptr)
{
setCanRest(!ptr.isEmpty() || MWBase::Environment::get().getWorld ()->canRest () == MWBase::World::Rest_Allowed);
mPtr = ptr;
setCanRest(!mPtr.isEmpty() || MWBase::Environment::get().getWorld ()->canRest () == MWBase::World::Rest_Allowed);
if (mUntilHealedButton->getVisible())
MWBase::Environment::get().getWindowManager()->setKeyFocusWidget(mUntilHealedButton);
@ -100,6 +107,7 @@ namespace MWGui
{
mSleeping = false;
mTimeAdvancer.stop();
resetReference();
}
void WaitDialog::onOpen()
@ -129,7 +137,13 @@ namespace MWGui
}
else if (canRest == MWBase::World::Rest_PlayerIsUnderwater)
{
// resting underwater or mid-air not allowed
// resting underwater not allowed
MWBase::Environment::get().getWindowManager()->messageBox ("#{sNotifyMessage1}");
MWBase::Environment::get().getWindowManager()->popGuiMode ();
}
else if (mPtr.isEmpty() && canRest == MWBase::World::Rest_PlayerIsInAir)
{
// Resting in air is not allowed either, unless you're using a bed
MWBase::Environment::get().getWindowManager()->messageBox ("#{sNotifyMessage1}");
MWBase::Environment::get().getWindowManager()->popGuiMode ();
}
@ -289,6 +303,8 @@ namespace MWGui
void WaitDialog::onFrame(float dt)
{
checkReferenceAvailable();
mTimeAdvancer.onFrame(dt);
if (mFadeTimeRemaining <= 0)

@ -4,6 +4,7 @@
#include "timeadvancer.hpp"
#include "windowbase.hpp"
#include "referenceinterface.hpp"
namespace MWGui
{
@ -22,7 +23,7 @@ namespace MWGui
MyGUI::TextBox* mProgressText;
};
class WaitDialog : public WindowBase
class WaitDialog : public WindowBase, public ReferenceInterface
{
public:
WaitDialog();
@ -63,6 +64,8 @@ namespace MWGui
WaitDialogProgressBar mProgressBar;
virtual void onReferenceUnavailable();
void onUntilHealedButtonClicked(MyGUI::Widget* sender);
void onWaitButtonClicked(MyGUI::Widget* sender);
void onCancelButtonClicked(MyGUI::Widget* sender);

@ -2477,9 +2477,12 @@ namespace MWWorld
if(mPlayer->enemiesNearby())
return Rest_EnemiesAreNearby;
if ((actor->getCollisionMode() && !mPhysics->isOnSolidGround(player)) || isUnderwater(currentCell, playerPos) || isWalkingOnWater(player))
if (isUnderwater(currentCell, playerPos) || isWalkingOnWater(player))
return Rest_PlayerIsUnderwater;
if ((actor->getCollisionMode() && !mPhysics->isOnSolidGround(player)) || isFlying(player))
return Rest_PlayerIsInAir;
if((currentCell->getCell()->mData.mFlags&ESM::Cell::NoSleep) || player.getClass().getNpcStats(player).isWerewolf())
return Rest_OnlyWaiting;

Loading…
Cancel
Save