From 5d2a73fe01c71e59caabacdd12f59e1f9de49713 Mon Sep 17 00:00:00 2001 From: ysj1173886760 <1173886760@qq.com> Date: Sat, 17 Apr 2021 15:19:02 +0800 Subject: [PATCH] GRAPHICS: MACGUI: add win95 mode for menu behaviour, currently in win95 mode, it will exit the menu only when you click something useful(trigger some event) --- graphics/macgui/macmenu.cpp | 73 +++++++++++++++++++++++++------------ graphics/macgui/macmenu.h | 2 + 2 files changed, 51 insertions(+), 24 deletions(-) diff --git a/graphics/macgui/macmenu.cpp b/graphics/macgui/macmenu.cpp index fbadb296f0c..5df342336b1 100644 --- a/graphics/macgui/macmenu.cpp +++ b/graphics/macgui/macmenu.cpp @@ -1169,35 +1169,60 @@ bool MacMenu::checkCallback(bool unicode) { return true; } +void MacMenu::closeMenu() { + setActive(false); + if (_wm->_mode & kWMModeAutohideMenu) + _isVisible = false; + + if (_wm->_mode & kWMModalMenuMode) { + _wm->disableScreenCopy(); + } + _activeItem = -1; + _activeSubItem = -1; + _menustack.clear(); + + _wm->setFullRefresh(true); +} + bool MacMenu::mouseRelease(int x, int y) { - if (_active) { - setActive(false); - if (_wm->_mode & kWMModeAutohideMenu) - _isVisible = false; - - if (_wm->_mode & kWMModalMenuMode) { - _wm->disableScreenCopy(); - } - - if (_activeItem != -1 && _activeSubItem != -1 && _menustack.back()->items[_activeSubItem]->enabled) { - if (_menustack.back()->items[_activeSubItem]->unicode) { - if (checkCallback(true)) - (*_unicodeccallback)(_menustack.back()->items[_activeSubItem]->action, - _menustack.back()->items[_activeSubItem]->unicodeText, _cdata); - } else { - if (checkCallback()) - (*_ccallback)(_menustack.back()->items[_activeSubItem]->action, - _menustack.back()->items[_activeSubItem]->text, _cdata); + if (!(_wm->_mode & kWMModeWin95)) { + if (_active) { + if (_activeItem != -1 && _activeSubItem != -1 && _menustack.back()->items[_activeSubItem]->enabled) { + if (_menustack.back()->items[_activeSubItem]->unicode) { + if (checkCallback(true)) + (*_unicodeccallback)(_menustack.back()->items[_activeSubItem]->action, + _menustack.back()->items[_activeSubItem]->unicodeText, _cdata); + } else { + if (checkCallback()) + (*_ccallback)(_menustack.back()->items[_activeSubItem]->action, + _menustack.back()->items[_activeSubItem]->text, _cdata); + } } + + closeMenu(); + return true; } + } else { + if (_active) { - _activeItem = -1; - _activeSubItem = -1; - _menustack.clear(); + if (_activeItem != -1 && _activeSubItem != -1 && _menustack.back()->items[_activeSubItem]->enabled) { + if (_menustack.back()->items[_activeSubItem]->unicode) { + if (checkCallback(true)) { + (*_unicodeccallback)(_menustack.back()->items[_activeSubItem]->action, + _menustack.back()->items[_activeSubItem]->unicodeText, _cdata); + closeMenu(); + } + } else { + if (checkCallback()) { + (*_ccallback)(_menustack.back()->items[_activeSubItem]->action, + _menustack.back()->items[_activeSubItem]->text, _cdata); + closeMenu(); + } + } + } - _wm->setFullRefresh(true); - - return true; + return true; + } } return false; diff --git a/graphics/macgui/macmenu.h b/graphics/macgui/macmenu.h index b87bd5525df..f611930ae2a 100644 --- a/graphics/macgui/macmenu.h +++ b/graphics/macgui/macmenu.h @@ -93,6 +93,8 @@ public: void printMenu(int level = 0, MacMenuSubMenu *submenu = nullptr); + void closeMenu(); + Common::Rect _bbox; private: