1
0
mirror of https://gitlab.com/OpenMW/openmw.git synced 2025-02-20 15:40:32 +00:00

Handle the wait progress bar as part of the GUI mode

This commit is contained in:
scrawl 2017-09-24 12:58:14 +02:00
parent 9ed1b16553
commit 843106fc61
5 changed files with 33 additions and 17 deletions

View File

@ -51,12 +51,18 @@ namespace MWGui
mTimeAdvancer.eventProgressChanged += MyGUI::newDelegate(this, &TrainingWindow::onTrainingProgressChanged);
mTimeAdvancer.eventFinished += MyGUI::newDelegate(this, &TrainingWindow::onTrainingFinished);
mProgressBar.setVisible(false);
}
void TrainingWindow::onOpen()
{
if (mTimeAdvancer.isRunning())
{
mProgressBar.setVisible(true);
setVisible(false);
}
else
mProgressBar.setVisible(false);
center();
}
@ -166,15 +172,12 @@ namespace MWGui
// add gold to NPC trading gold pool
npcStats.setGoldPool(npcStats.getGoldPool() + price);
// go back to game mode
MWBase::Environment::get().getWindowManager()->removeGuiMode (GM_Training);
MWBase::Environment::get().getDialogueManager()->goodbyeSelected();
// advance time
MWBase::Environment::get().getMechanicsManager()->rest(false);
MWBase::Environment::get().getMechanicsManager()->rest(false);
MWBase::Environment::get().getWorld ()->advanceTime (2);
setVisible(false);
mProgressBar.setVisible(true);
mProgressBar.setProgress(0, 2);
mTimeAdvancer.run(2);
@ -191,6 +194,10 @@ namespace MWGui
void TrainingWindow::onTrainingFinished()
{
mProgressBar.setVisible(false);
// go back to game mode
MWBase::Environment::get().getWindowManager()->removeGuiMode (GM_Training);
MWBase::Environment::get().getDialogueManager()->goodbyeSelected();
}
void TrainingWindow::onFrame(float dt)

View File

@ -16,10 +16,14 @@ namespace MWGui
virtual void onOpen();
bool exit() { return false; }
void setPtr(const MWWorld::Ptr& actor);
void onFrame(float dt);
WindowBase* getProgressBar() { return &mProgressBar; }
void clear() { resetReference(); }
protected:

View File

@ -75,8 +75,6 @@ namespace MWGui
mTimeAdvancer.eventProgressChanged += MyGUI::newDelegate(this, &WaitDialog::onWaitingProgressChanged);
mTimeAdvancer.eventInterrupted += MyGUI::newDelegate(this, &WaitDialog::onWaitingInterrupted);
mTimeAdvancer.eventFinished += MyGUI::newDelegate(this, &WaitDialog::onWaitingFinished);
mProgressBar.setVisible (false);
}
void WaitDialog::setPtr(const MWWorld::Ptr &ptr)
@ -86,11 +84,22 @@ namespace MWGui
bool WaitDialog::exit()
{
return (!mProgressBar.isVisible()); //Only exit if not currently waiting
return (!mTimeAdvancer.isRunning()); //Only exit if not currently waiting
}
void WaitDialog::onOpen()
{
if (mTimeAdvancer.isRunning())
{
mProgressBar.setVisible(true);
setVisible(false);
return;
}
else
{
mProgressBar.setVisible(false);
}
if (!MWBase::Environment::get().getWindowManager ()->getRestEnabled ())
{
MWBase::Environment::get().getWindowManager()->popGuiMode ();
@ -262,11 +271,6 @@ namespace MWGui
}
}
void WaitDialog::clear()
{
mProgressBar.setVisible(false);
}
void WaitDialog::stopWaiting ()
{
MWBase::Environment::get().getWindowManager()->fadeScreenIn(0.2f);

View File

@ -34,12 +34,13 @@ namespace MWGui
virtual bool exit();
void onFrame(float dt);
void clear();
bool getSleeping() { return mTimeAdvancer.isRunning() && mSleeping; }
void wakeUp();
void autosave();
WindowBase* getProgressBar() { return &mProgressBar; }
protected:
MyGUI::TextBox* mDateTimeText;
MyGUI::TextBox* mRestText;

View File

@ -414,7 +414,7 @@ namespace MWGui
mWaitDialog = new WaitDialog();
mWindows.push_back(mWaitDialog);
mGuiModeStates[GM_Rest] = GuiModeState(mWaitDialog);
mGuiModeStates[GM_Rest] = GuiModeState({mWaitDialog->getProgressBar(), mWaitDialog});
SpellCreationDialog* spellCreationDialog = new SpellCreationDialog();
mWindows.push_back(spellCreationDialog);
@ -426,7 +426,7 @@ namespace MWGui
TrainingWindow* trainingWindow = new TrainingWindow();
mWindows.push_back(trainingWindow);
mGuiModeStates[GM_Training] = GuiModeState(trainingWindow);
mGuiModeStates[GM_Training] = GuiModeState({trainingWindow->getProgressBar(), trainingWindow});
MerchantRepair* merchantRepair = new MerchantRepair();
mWindows.push_back(merchantRepair);