[Scummvm-git-logs] scummvm master -> 4149e3da21e6ea44d38662087f9550b547641ee5
eriktorbjorn
noreply at scummvm.org
Fri Jan 10 21:18:53 UTC 2025
This automated email contains information about 1 new commit which have been
pushed to the 'scummvm' repo located at https://github.com/scummvm/scummvm .
Summary:
4149e3da21 SCUMM: MACGUI: Eliminate some code duplication
Commit: 4149e3da21e6ea44d38662087f9550b547641ee5
https://github.com/scummvm/scummvm/commit/4149e3da21e6ea44d38662087f9550b547641ee5
Author: Torbjörn Andersson (eriktorbjorn at users.sourceforge.net)
Date: 2025-01-10T22:18:39+01:00
Commit Message:
SCUMM: MACGUI: Eliminate some code duplication
Changed paths:
engines/scumm/macgui/macgui_impl.cpp
engines/scumm/macgui/macgui_impl.h
engines/scumm/macgui/macgui_v6.cpp
diff --git a/engines/scumm/macgui/macgui_impl.cpp b/engines/scumm/macgui/macgui_impl.cpp
index e53ed05296b..e70ba1f8780 100644
--- a/engines/scumm/macgui/macgui_impl.cpp
+++ b/engines/scumm/macgui/macgui_impl.cpp
@@ -172,12 +172,35 @@ MacGuiImpl::DelayStatus MacGuiImpl::delay(uint32 ms) {
void MacGuiImpl::menuCallback(int id, Common::String &name, void *data) {
MacGuiImpl *gui = (MacGuiImpl *)data;
- gui->handleMenu(id, name);
+ // This menu item (e.g. a menu separator) has no action, so it can be
+ // immediately ignored.
+ if (id == 0)
+ return;
+
+ Graphics::MacMenu *menu = gui->_windowManager->getMenu();
+ bool forceMenuClosed = false;
+
+ // If the menu is opened through a shortcut key, force it to activate
+ // to avoid screen corruption. In that case, we also force the menu to
+ // close afterwards, or the game will stay paused. Which is
+ // particularly bad during a restart.
- if (gui->_forceMenuClosed) {
- gui->_windowManager->getMenu()->closeMenu();
- gui->_forceMenuClosed = false;
+ if (!menu->_active) {
+ gui->_windowManager->activateMenu();
+ forceMenuClosed = true;
}
+
+ // This is how we keep the menu bar visible.
+
+ menu->closeMenu();
+ menu->setActive(true);
+ menu->setVisible(true);
+ gui->updateWindowManager();
+
+ gui->handleMenu(id, name);
+
+ if (forceMenuClosed)
+ menu->closeMenu();
}
bool MacGuiImpl::initialize() {
@@ -365,29 +388,6 @@ void MacGuiImpl::updateMenus() {
}
bool MacGuiImpl::handleMenu(int id, Common::String &name) {
- // This menu item (e.g. a menu separator) has no action, so it's
- // handled trivially.
- if (id == 0)
- return true;
-
- // This is how we keep the menu bar visible.
- Graphics::MacMenu *menu = _windowManager->getMenu();
-
- // If the menu is opened through a shortcut key, force it to activate
- // to avoid screen corruption. In that case, we also force the menu to
- // close afterwards, or the game will stay paused. Which is
- // particularly bad during a restart.
-
- if (!menu->_active) {
- _windowManager->activateMenu();
- _forceMenuClosed = true;
- }
-
- menu->closeMenu();
- menu->setActive(true);
- menu->setVisible(true);
- updateWindowManager();
-
int saveSlotToHandle = -1;
Common::String savegameName;
@@ -424,7 +424,7 @@ bool MacGuiImpl::handleMenu(int id, Common::String &name) {
case 203: // Pause
if (!_vm->_messageBannerActive) {
- menu->closeMenu();
+ _windowManager->getMenu()->closeMenu();
if (_vm->_game.version == 3)
_vm->mac_showOldStyleBannerAndPause(_vm->getGUIString(gsPause), -1);
diff --git a/engines/scumm/macgui/macgui_impl.h b/engines/scumm/macgui/macgui_impl.h
index 504f3daeadd..cc94f21c76d 100644
--- a/engines/scumm/macgui/macgui_impl.h
+++ b/engines/scumm/macgui/macgui_impl.h
@@ -781,7 +781,6 @@ public:
virtual ~MacGuiImpl();
Graphics::MacWindowManager *_windowManager = nullptr;
- bool _forceMenuClosed = false;
virtual int getNumColors() const = 0;
diff --git a/engines/scumm/macgui/macgui_v6.cpp b/engines/scumm/macgui/macgui_v6.cpp
index 785eba96f3b..6b95b8737f4 100644
--- a/engines/scumm/macgui/macgui_v6.cpp
+++ b/engines/scumm/macgui/macgui_v6.cpp
@@ -190,30 +190,6 @@ void MacV6Gui::updateMenus() {
bool MacV6Gui::handleMenu(int id, Common::String &name) {
// Don't call the original method. The menus are too different.
- // TODO: Separate the common code into its own method?
-
- // This menu item (e.g. a menu separator) has no action, so it's
- // handled trivially.
- if (id == 0)
- return true;
-
- // This is how we keep the menu bar visible.
- Graphics::MacMenu *menu = _windowManager->getMenu();
-
- // If the menu is opened through a shortcut key, force it to activate
- // to avoid screen corruption. In that case, we also force the menu to
- // close afterwards, or the game will stay paused. Which is
- // particularly bad during a restart.
-
- if (!menu->_active) {
- _windowManager->activateMenu();
- _forceMenuClosed = true;
- }
-
- menu->closeMenu();
- menu->setActive(true);
- menu->setVisible(true);
- updateWindowManager();
int saveSlotToHandle = -1;
bool syncSoundSettings = false;
More information about the Scummvm-git-logs
mailing list