mirror of
https://github.com/OpenMW/openmw.git
synced 2025-02-01 14:15:36 +00:00
Fixed crash when Esc-ing out of Save "are you sure" dialog.
This commit is contained in:
parent
e0356cf89d
commit
ee7b5fa5c2
4 changed files with 34 additions and 7 deletions
|
@ -322,7 +322,12 @@ namespace MWBase
|
|||
|
||||
/// Sets the current Modal
|
||||
/** Used to send exit command to active Modal when Esc is pressed **/
|
||||
virtual void setCurrentModal(MWGui::WindowModal* input) = 0;
|
||||
virtual void addCurrentModal(MWGui::WindowModal* input) = 0;
|
||||
|
||||
/// Removes the top Modal
|
||||
/** Used when one Modal adds another Modal
|
||||
\param input Pointer to the current modal, to ensure proper modal is removed **/
|
||||
virtual void removeCurrentModal(MWGui::WindowModal* input) = 0;
|
||||
};
|
||||
}
|
||||
|
||||
|
|
|
@ -47,13 +47,13 @@ WindowModal::WindowModal(const std::string& parLayout)
|
|||
void WindowModal::open()
|
||||
{
|
||||
MyGUI::InputManager::getInstance ().addWidgetModal (mMainWidget);
|
||||
MWBase::Environment::get().getWindowManager()->setCurrentModal(this); //Set so we can escape it if needed
|
||||
MWBase::Environment::get().getWindowManager()->addCurrentModal(this); //Set so we can escape it if needed
|
||||
}
|
||||
|
||||
void WindowModal::close()
|
||||
{
|
||||
MyGUI::InputManager::getInstance ().removeWidgetModal (mMainWidget);
|
||||
MWBase::Environment::get().getWindowManager()->setCurrentModal(NULL);
|
||||
MWBase::Environment::get().getWindowManager()->removeCurrentModal(this);
|
||||
}
|
||||
|
||||
void WindowModal::exit()
|
||||
|
|
|
@ -136,7 +136,7 @@ namespace MWGui
|
|||
, mFPS(0.0f)
|
||||
, mTriangleCount(0)
|
||||
, mBatchCount(0)
|
||||
, currentModal(NULL)
|
||||
, mCurrentModals()
|
||||
{
|
||||
// Set up the GUI system
|
||||
mGuiManager = new OEngine::GUI::MyGUIManager(mRendering->getWindow(), mRendering->getScene(), false, logpath);
|
||||
|
@ -1606,4 +1606,21 @@ namespace MWGui
|
|||
mVideoWidget->setCoord(leftPadding, topPadding,
|
||||
screenWidth - leftPadding*2, screenHeight - topPadding*2);
|
||||
}
|
||||
|
||||
WindowModal* WindowManager::getCurrentModal() const
|
||||
{
|
||||
if(mCurrentModals.size() > 0)
|
||||
return mCurrentModals.top();
|
||||
else
|
||||
return NULL;
|
||||
}
|
||||
|
||||
void WindowManager::removeCurrentModal(WindowModal* input)
|
||||
{
|
||||
// Only remove the top if it matches the current pointer. A lot of things hide their visibility before showing it,
|
||||
//so just popping the top would cause massive issues.
|
||||
if(mCurrentModals.size() > 0)
|
||||
if(input == mCurrentModals.top())
|
||||
mCurrentModals.pop();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -305,11 +305,16 @@ namespace MWGui
|
|||
|
||||
/// Returns the current Modal
|
||||
/** Used to send exit command to active Modal when Esc is pressed **/
|
||||
virtual WindowModal* getCurrentModal() const {return currentModal;}
|
||||
virtual WindowModal* getCurrentModal() const;
|
||||
|
||||
/// Sets the current Modal
|
||||
/** Used to send exit command to active Modal when Esc is pressed **/
|
||||
virtual void setCurrentModal(WindowModal* input) {currentModal = input;}
|
||||
virtual void addCurrentModal(WindowModal* input) {mCurrentModals.push(input);}
|
||||
|
||||
/// Removes the top Modal
|
||||
/** Used when one Modal adds another Modal
|
||||
\param input Pointer to the current modal, to ensure proper modal is removed **/
|
||||
virtual void removeCurrentModal(WindowModal* input);
|
||||
|
||||
private:
|
||||
bool mConsoleOnlyScripts;
|
||||
|
@ -320,7 +325,7 @@ namespace MWGui
|
|||
|
||||
std::string mSelectedSpell;
|
||||
|
||||
WindowModal* currentModal;
|
||||
std::stack<WindowModal*> mCurrentModals;
|
||||
|
||||
OEngine::GUI::MyGUIManager *mGuiManager;
|
||||
OEngine::Render::OgreRenderer *mRendering;
|
||||
|
|
Loading…
Reference in a new issue