aboutsummaryrefslogtreecommitdiff
path: root/graphics
diff options
context:
space:
mode:
authorEugene Sandulenko2019-12-11 12:00:16 +0100
committerEugene Sandulenko2019-12-11 12:00:16 +0100
commit98b14a36ad225e3604b483a3d1c3c384f6a83be5 (patch)
treef9ae15a04ba9134158d8f2e2049c9985eac026f1 /graphics
parent57b9a08a207362e8f8bca3a741d4d2aee3b1066d (diff)
downloadscummvm-rg350-98b14a36ad225e3604b483a3d1c3c384f6a83be5.tar.gz
scummvm-rg350-98b14a36ad225e3604b483a3d1c3c384f6a83be5.tar.bz2
scummvm-rg350-98b14a36ad225e3604b483a3d1c3c384f6a83be5.zip
GRAPHICS: MACGUI: Added setup sanity checks to MacMenu
Diffstat (limited to 'graphics')
-rw-r--r--graphics/macgui/macmenu.cpp32
-rw-r--r--graphics/macgui/macmenu.h1
2 files changed, 27 insertions, 6 deletions
diff --git a/graphics/macgui/macmenu.cpp b/graphics/macgui/macmenu.cpp
index 42f1d32f58..a6788007ed 100644
--- a/graphics/macgui/macmenu.cpp
+++ b/graphics/macgui/macmenu.cpp
@@ -1042,6 +1042,22 @@ bool MacMenu::mouseMove(int x, int y) {
return false;
}
+bool MacMenu::checkCallback(bool unicode) {
+ if (unicode) {
+ if (_unicodeccallback == nullptr) {
+ warning("MacMenu: no Unicode callback set");
+ return false;
+ }
+ } else {
+ if (_ccallback == nullptr) {
+ warning("MacMenu: no callback set");
+ return false;
+ }
+ }
+
+ return true;
+}
+
bool MacMenu::mouseRelease(int x, int y) {
if (_menuActivated) {
_menuActivated = false;
@@ -1056,11 +1072,13 @@ bool MacMenu::mouseRelease(int x, int y) {
if (_activeItem != -1 && _activeSubItem != -1 && _menustack.back()->items[_activeSubItem]->enabled) {
if (_menustack.back()->items[_activeSubItem]->unicode) {
- (*_unicodeccallback)(_menustack.back()->items[_activeSubItem]->action,
- _menustack.back()->items[_activeSubItem]->unicodeText, _cdata);
+ if (checkCallback(true))
+ (*_unicodeccallback)(_menustack.back()->items[_activeSubItem]->action,
+ _menustack.back()->items[_activeSubItem]->unicodeText, _cdata);
} else {
- (*_ccallback)(_menustack.back()->items[_activeSubItem]->action,
- _menustack.back()->items[_activeSubItem]->text, _cdata);
+ if (checkCallback())
+ (*_ccallback)(_menustack.back()->items[_activeSubItem]->action,
+ _menustack.back()->items[_activeSubItem]->text, _cdata);
}
}
@@ -1085,9 +1103,11 @@ bool MacMenu::processMenuShortCut(byte flags, uint16 ascii) {
for (uint j = 0; j < _items[i]->submenu->items.size(); j++)
if (_items[i]->submenu->items[j]->enabled && tolower(_items[i]->submenu->items[j]->shortcut) == ascii) {
if (_items[i]->submenu->items[j]->unicode) {
- (*_unicodeccallback)(_items[i]->submenu->items[j]->action, _items[i]->submenu->items[j]->unicodeText, _cdata);
+ if (checkCallback(true))
+ (*_unicodeccallback)(_items[i]->submenu->items[j]->action, _items[i]->submenu->items[j]->unicodeText, _cdata);
} else {
- (*_ccallback)(_items[i]->submenu->items[j]->action, _items[i]->submenu->items[j]->text, _cdata);
+ if (checkCallback())
+ (*_ccallback)(_items[i]->submenu->items[j]->action, _items[i]->submenu->items[j]->text, _cdata);
}
return true;
}
diff --git a/graphics/macgui/macmenu.h b/graphics/macgui/macmenu.h
index e7c172c3fb..88f6e9bb74 100644
--- a/graphics/macgui/macmenu.h
+++ b/graphics/macgui/macmenu.h
@@ -92,6 +92,7 @@ private:
ManagedSurface _tempSurface;
private:
+ bool checkCallback(bool unicode = false);
const Font *getMenuFont();
const Common::String getAcceleratorString(MacMenuItem *item, const char *prefix);
void processTabs();