Don't require modal windows to be removed in the same order they were added

pull/303/head
scrawl 7 years ago
parent b5c9977a7b
commit 7c68ed04b2

@ -865,7 +865,7 @@ namespace MWGui
window->onFrame(frameDuration); window->onFrame(frameDuration);
} }
if (!mCurrentModals.empty()) if (!mCurrentModals.empty())
mCurrentModals.top()->onFrame(frameDuration); mCurrentModals.back()->onFrame(frameDuration);
mKeyboardNavigation->onFrame(); mKeyboardNavigation->onFrame();
@ -1727,9 +1727,9 @@ namespace MWGui
{ {
if (!mCurrentModals.empty()) if (!mCurrentModals.empty())
{ {
if (!mCurrentModals.top()->exit()) if (!mCurrentModals.back()->exit())
return; return;
mCurrentModals.top()->setVisible(false); mCurrentModals.back()->setVisible(false);
} }
} }
@ -1738,7 +1738,7 @@ namespace MWGui
if (mCurrentModals.empty()) if (mCurrentModals.empty())
mKeyboardNavigation->saveFocus(getMode()); mKeyboardNavigation->saveFocus(getMode());
mCurrentModals.push(input); mCurrentModals.push_back(input);
mKeyboardNavigation->restoreFocus(-1); mKeyboardNavigation->restoreFocus(-1);
mKeyboardNavigation->setModalWindow(input->mMainWidget); mKeyboardNavigation->setModalWindow(input->mMainWidget);
@ -1747,17 +1747,21 @@ namespace MWGui
void WindowManager::removeCurrentModal(WindowModal* input) 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.empty()) if(!mCurrentModals.empty())
{ {
if(input == mCurrentModals.top()) if(input == mCurrentModals.back())
{ {
mCurrentModals.pop(); mCurrentModals.pop_back();
mKeyboardNavigation->saveFocus(-1); mKeyboardNavigation->saveFocus(-1);
} }
else else
std::cout << " warning: modal widget " << input << " " << typeid(input).name() << " not found " << std::endl; {
auto found = std::find(mCurrentModals.begin(), mCurrentModals.end(), input);
if (found != mCurrentModals.end())
mCurrentModals.erase(found);
else
std::cerr << " warning: can't find modal window " << input << std::endl;
}
} }
if (mCurrentModals.empty()) if (mCurrentModals.empty())
{ {
@ -1765,7 +1769,7 @@ namespace MWGui
mKeyboardNavigation->restoreFocus(getMode()); mKeyboardNavigation->restoreFocus(getMode());
} }
else else
mKeyboardNavigation->setModalWindow(mCurrentModals.top()->mMainWidget); mKeyboardNavigation->setModalWindow(mCurrentModals.back()->mMainWidget);
} }
void WindowManager::onVideoKeyPressed(MyGUI::Widget *_sender, MyGUI::KeyCode _key, MyGUI::Char _char) void WindowManager::onVideoKeyPressed(MyGUI::Widget *_sender, MyGUI::KeyCode _key, MyGUI::Char _char)

@ -401,7 +401,7 @@ namespace MWGui
MWWorld::Ptr mSelectedEnchantItem; MWWorld::Ptr mSelectedEnchantItem;
MWWorld::Ptr mSelectedWeapon; MWWorld::Ptr mSelectedWeapon;
std::stack<WindowModal*> mCurrentModals; std::vector<WindowModal*> mCurrentModals;
// Markers placed manually by the player. Must be shared between both map views (the HUD map and the map window). // Markers placed manually by the player. Must be shared between both map views (the HUD map and the map window).
CustomMarkerCollection mCustomMarkers; CustomMarkerCollection mCustomMarkers;

Loading…
Cancel
Save