From 9368323cdf182121577511b129f8d981c364a34b Mon Sep 17 00:00:00 2001 From: Eugene Sandulenko Date: Fri, 4 Oct 2019 00:35:21 +0200 Subject: GRAPHICS: MACGUI: Process Windows menu shortcuts --- graphics/macgui/macmenu.cpp | 37 ++++++++++++++++++++++++++++++++++--- 1 file changed, 34 insertions(+), 3 deletions(-) (limited to 'graphics/macgui') diff --git a/graphics/macgui/macmenu.cpp b/graphics/macgui/macmenu.cpp index 873b2b92f0..d8b5a433f5 100644 --- a/graphics/macgui/macmenu.cpp +++ b/graphics/macgui/macmenu.cpp @@ -337,7 +337,18 @@ int MacMenu::addMenuItem(const Common::String &name) { } int MacMenu::addMenuItem(const Common::U32String &name) { - MacMenuItem *i = new MacMenuItem(name); + Common::U32String amp("&"); + Common::U32String res; + + for (uint i = 0; i < name.size(); i++) + if (name[i] == amp[0]) { + //shortcut = amp[0] & 0xff; + } else { + res += name[i]; + } + + + MacMenuItem *i = new MacMenuItem(res); _items.push_back(i); _dimensionsDirty = true; @@ -370,7 +381,17 @@ void MacMenu::addMenuSubItem(int id, const Common::U32String &text, int action, if (_items[id]->submenu == nullptr) _items[id]->submenu = new MacMenuSubMenu(); - _items[id]->submenu->subitems.push_back(new MacMenuSubItem(text, action, style, shortcut, enabled)); + Common::U32String amp("&"); + Common::U32String res; + + for (uint i = 0; i < text.size(); i++) + if (text[i] == amp[0]) { + shortcut = amp[0] & 0xff; + } else { + res += text[i]; + } + + _items[id]->submenu->subitems.push_back(new MacMenuSubItem(res, action, style, shortcut, enabled)); } void MacMenu::addSubMenuItem(MacMenuSubMenu *submenu, const Common::String &text, int action, int style, char shortcut, bool enabled) { @@ -386,7 +407,17 @@ void MacMenu::addSubMenuItem(MacMenuSubMenu *submenu, const Common::U32String &t _dimensionsDirty = true; - submenu->subitems.push_back(new MacMenuSubItem(text, action, style, shortcut, enabled)); + Common::U32String amp("&"); + Common::U32String res; + + for (uint i = 0; i < text.size(); i++) + if (text[i] == amp[0]) { + shortcut = amp[0] & 0xff; + } else { + res += text[i]; + } + + submenu->subitems.push_back(new MacMenuSubItem(res, action, style, shortcut, enabled)); } void MacMenu::calcDimensions() { -- cgit v1.2.3