forked from teamnwah/openmw-tes3coop
Handle the wait progress bar as part of the GUI mode
This commit is contained in:
parent
9ed1b16553
commit
843106fc61
5 changed files with 33 additions and 17 deletions
|
@ -51,12 +51,18 @@ namespace MWGui
|
||||||
|
|
||||||
mTimeAdvancer.eventProgressChanged += MyGUI::newDelegate(this, &TrainingWindow::onTrainingProgressChanged);
|
mTimeAdvancer.eventProgressChanged += MyGUI::newDelegate(this, &TrainingWindow::onTrainingProgressChanged);
|
||||||
mTimeAdvancer.eventFinished += MyGUI::newDelegate(this, &TrainingWindow::onTrainingFinished);
|
mTimeAdvancer.eventFinished += MyGUI::newDelegate(this, &TrainingWindow::onTrainingFinished);
|
||||||
|
|
||||||
mProgressBar.setVisible(false);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void TrainingWindow::onOpen()
|
void TrainingWindow::onOpen()
|
||||||
{
|
{
|
||||||
|
if (mTimeAdvancer.isRunning())
|
||||||
|
{
|
||||||
|
mProgressBar.setVisible(true);
|
||||||
|
setVisible(false);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
mProgressBar.setVisible(false);
|
||||||
|
|
||||||
center();
|
center();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -166,15 +172,12 @@ namespace MWGui
|
||||||
// add gold to NPC trading gold pool
|
// add gold to NPC trading gold pool
|
||||||
npcStats.setGoldPool(npcStats.getGoldPool() + price);
|
npcStats.setGoldPool(npcStats.getGoldPool() + price);
|
||||||
|
|
||||||
// go back to game mode
|
|
||||||
MWBase::Environment::get().getWindowManager()->removeGuiMode (GM_Training);
|
|
||||||
MWBase::Environment::get().getDialogueManager()->goodbyeSelected();
|
|
||||||
|
|
||||||
// advance time
|
// advance time
|
||||||
MWBase::Environment::get().getMechanicsManager()->rest(false);
|
MWBase::Environment::get().getMechanicsManager()->rest(false);
|
||||||
MWBase::Environment::get().getMechanicsManager()->rest(false);
|
MWBase::Environment::get().getMechanicsManager()->rest(false);
|
||||||
MWBase::Environment::get().getWorld ()->advanceTime (2);
|
MWBase::Environment::get().getWorld ()->advanceTime (2);
|
||||||
|
|
||||||
|
setVisible(false);
|
||||||
mProgressBar.setVisible(true);
|
mProgressBar.setVisible(true);
|
||||||
mProgressBar.setProgress(0, 2);
|
mProgressBar.setProgress(0, 2);
|
||||||
mTimeAdvancer.run(2);
|
mTimeAdvancer.run(2);
|
||||||
|
@ -191,6 +194,10 @@ namespace MWGui
|
||||||
void TrainingWindow::onTrainingFinished()
|
void TrainingWindow::onTrainingFinished()
|
||||||
{
|
{
|
||||||
mProgressBar.setVisible(false);
|
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)
|
void TrainingWindow::onFrame(float dt)
|
||||||
|
|
|
@ -16,10 +16,14 @@ namespace MWGui
|
||||||
|
|
||||||
virtual void onOpen();
|
virtual void onOpen();
|
||||||
|
|
||||||
|
bool exit() { return false; }
|
||||||
|
|
||||||
void setPtr(const MWWorld::Ptr& actor);
|
void setPtr(const MWWorld::Ptr& actor);
|
||||||
|
|
||||||
void onFrame(float dt);
|
void onFrame(float dt);
|
||||||
|
|
||||||
|
WindowBase* getProgressBar() { return &mProgressBar; }
|
||||||
|
|
||||||
void clear() { resetReference(); }
|
void clear() { resetReference(); }
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
|
|
@ -75,8 +75,6 @@ namespace MWGui
|
||||||
mTimeAdvancer.eventProgressChanged += MyGUI::newDelegate(this, &WaitDialog::onWaitingProgressChanged);
|
mTimeAdvancer.eventProgressChanged += MyGUI::newDelegate(this, &WaitDialog::onWaitingProgressChanged);
|
||||||
mTimeAdvancer.eventInterrupted += MyGUI::newDelegate(this, &WaitDialog::onWaitingInterrupted);
|
mTimeAdvancer.eventInterrupted += MyGUI::newDelegate(this, &WaitDialog::onWaitingInterrupted);
|
||||||
mTimeAdvancer.eventFinished += MyGUI::newDelegate(this, &WaitDialog::onWaitingFinished);
|
mTimeAdvancer.eventFinished += MyGUI::newDelegate(this, &WaitDialog::onWaitingFinished);
|
||||||
|
|
||||||
mProgressBar.setVisible (false);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void WaitDialog::setPtr(const MWWorld::Ptr &ptr)
|
void WaitDialog::setPtr(const MWWorld::Ptr &ptr)
|
||||||
|
@ -86,11 +84,22 @@ namespace MWGui
|
||||||
|
|
||||||
bool WaitDialog::exit()
|
bool WaitDialog::exit()
|
||||||
{
|
{
|
||||||
return (!mProgressBar.isVisible()); //Only exit if not currently waiting
|
return (!mTimeAdvancer.isRunning()); //Only exit if not currently waiting
|
||||||
}
|
}
|
||||||
|
|
||||||
void WaitDialog::onOpen()
|
void WaitDialog::onOpen()
|
||||||
{
|
{
|
||||||
|
if (mTimeAdvancer.isRunning())
|
||||||
|
{
|
||||||
|
mProgressBar.setVisible(true);
|
||||||
|
setVisible(false);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
mProgressBar.setVisible(false);
|
||||||
|
}
|
||||||
|
|
||||||
if (!MWBase::Environment::get().getWindowManager ()->getRestEnabled ())
|
if (!MWBase::Environment::get().getWindowManager ()->getRestEnabled ())
|
||||||
{
|
{
|
||||||
MWBase::Environment::get().getWindowManager()->popGuiMode ();
|
MWBase::Environment::get().getWindowManager()->popGuiMode ();
|
||||||
|
@ -262,11 +271,6 @@ namespace MWGui
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void WaitDialog::clear()
|
|
||||||
{
|
|
||||||
mProgressBar.setVisible(false);
|
|
||||||
}
|
|
||||||
|
|
||||||
void WaitDialog::stopWaiting ()
|
void WaitDialog::stopWaiting ()
|
||||||
{
|
{
|
||||||
MWBase::Environment::get().getWindowManager()->fadeScreenIn(0.2f);
|
MWBase::Environment::get().getWindowManager()->fadeScreenIn(0.2f);
|
||||||
|
|
|
@ -34,12 +34,13 @@ namespace MWGui
|
||||||
virtual bool exit();
|
virtual bool exit();
|
||||||
|
|
||||||
void onFrame(float dt);
|
void onFrame(float dt);
|
||||||
void clear();
|
|
||||||
|
|
||||||
bool getSleeping() { return mTimeAdvancer.isRunning() && mSleeping; }
|
bool getSleeping() { return mTimeAdvancer.isRunning() && mSleeping; }
|
||||||
void wakeUp();
|
void wakeUp();
|
||||||
void autosave();
|
void autosave();
|
||||||
|
|
||||||
|
WindowBase* getProgressBar() { return &mProgressBar; }
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
MyGUI::TextBox* mDateTimeText;
|
MyGUI::TextBox* mDateTimeText;
|
||||||
MyGUI::TextBox* mRestText;
|
MyGUI::TextBox* mRestText;
|
||||||
|
|
|
@ -414,7 +414,7 @@ namespace MWGui
|
||||||
|
|
||||||
mWaitDialog = new WaitDialog();
|
mWaitDialog = new WaitDialog();
|
||||||
mWindows.push_back(mWaitDialog);
|
mWindows.push_back(mWaitDialog);
|
||||||
mGuiModeStates[GM_Rest] = GuiModeState(mWaitDialog);
|
mGuiModeStates[GM_Rest] = GuiModeState({mWaitDialog->getProgressBar(), mWaitDialog});
|
||||||
|
|
||||||
SpellCreationDialog* spellCreationDialog = new SpellCreationDialog();
|
SpellCreationDialog* spellCreationDialog = new SpellCreationDialog();
|
||||||
mWindows.push_back(spellCreationDialog);
|
mWindows.push_back(spellCreationDialog);
|
||||||
|
@ -426,7 +426,7 @@ namespace MWGui
|
||||||
|
|
||||||
TrainingWindow* trainingWindow = new TrainingWindow();
|
TrainingWindow* trainingWindow = new TrainingWindow();
|
||||||
mWindows.push_back(trainingWindow);
|
mWindows.push_back(trainingWindow);
|
||||||
mGuiModeStates[GM_Training] = GuiModeState(trainingWindow);
|
mGuiModeStates[GM_Training] = GuiModeState({trainingWindow->getProgressBar(), trainingWindow});
|
||||||
|
|
||||||
MerchantRepair* merchantRepair = new MerchantRepair();
|
MerchantRepair* merchantRepair = new MerchantRepair();
|
||||||
mWindows.push_back(merchantRepair);
|
mWindows.push_back(merchantRepair);
|
||||||
|
|
Loading…
Reference in a new issue