From 272df29a129f779ca9ee7d4c912b66595d3c8a79 Mon Sep 17 00:00:00 2001 From: Capostrophic Date: Tue, 14 May 2019 20:38:41 +0300 Subject: [PATCH] Exit waiting at the correct time when the player is in air --- apps/openmw/mwgui/waitdialog.cpp | 25 ++++++++----------------- apps/openmw/mwgui/waitdialog.hpp | 5 +---- 2 files changed, 9 insertions(+), 21 deletions(-) diff --git a/apps/openmw/mwgui/waitdialog.cpp b/apps/openmw/mwgui/waitdialog.cpp index eda4242fd..d18eaebdd 100644 --- a/apps/openmw/mwgui/waitdialog.cpp +++ b/apps/openmw/mwgui/waitdialog.cpp @@ -80,18 +80,18 @@ 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) { - mPtr = ptr; - setCanRest(!mPtr.isEmpty() || MWBase::Environment::get().getWorld ()->canRest () == MWBase::World::Rest_Allowed); + setCanRest(!ptr.isEmpty() || MWBase::Environment::get().getWorld ()->canRest () == MWBase::World::Rest_Allowed); + if (ptr.isEmpty() && MWBase::Environment::get().getWorld ()->canRest() == MWBase::World::Rest_PlayerIsInAir) + { + // Resting in air is not allowed unless you're using a bed + MWBase::Environment::get().getWindowManager()->messageBox ("#{sNotifyMessage1}"); + MWBase::Environment::get().getWindowManager()->removeGuiMode(GM_Rest); + } + if (mUntilHealedButton->getVisible()) MWBase::Environment::get().getWindowManager()->setKeyFocusWidget(mUntilHealedButton); else @@ -107,7 +107,6 @@ namespace MWGui { mSleeping = false; mTimeAdvancer.stop(); - resetReference(); } void WaitDialog::onOpen() @@ -141,12 +140,6 @@ namespace MWGui 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 (); - } onHourSliderChangedPosition(mHourSlider, 0); mHourSlider->setScrollPosition (0); @@ -303,8 +296,6 @@ namespace MWGui void WaitDialog::onFrame(float dt) { - checkReferenceAvailable(); - mTimeAdvancer.onFrame(dt); if (mFadeTimeRemaining <= 0) diff --git a/apps/openmw/mwgui/waitdialog.hpp b/apps/openmw/mwgui/waitdialog.hpp index b54a9e254..2aecb002f 100644 --- a/apps/openmw/mwgui/waitdialog.hpp +++ b/apps/openmw/mwgui/waitdialog.hpp @@ -4,7 +4,6 @@ #include "timeadvancer.hpp" #include "windowbase.hpp" -#include "referenceinterface.hpp" namespace MWGui { @@ -23,7 +22,7 @@ namespace MWGui MyGUI::TextBox* mProgressText; }; - class WaitDialog : public WindowBase, public ReferenceInterface + class WaitDialog : public WindowBase { public: WaitDialog(); @@ -64,8 +63,6 @@ namespace MWGui WaitDialogProgressBar mProgressBar; - virtual void onReferenceUnavailable(); - void onUntilHealedButtonClicked(MyGUI::Widget* sender); void onWaitButtonClicked(MyGUI::Widget* sender); void onCancelButtonClicked(MyGUI::Widget* sender);