diff options
author | Eugene Sandulenko | 2019-12-16 16:40:51 +0100 |
---|---|---|
committer | Eugene Sandulenko | 2019-12-16 16:40:51 +0100 |
commit | 64b148afbaca3a7bfbf6df1e3715503f0e35c28a (patch) | |
tree | c666d4a3c5e49668d7f22f1eec3fb37cd05112ef /graphics | |
parent | 2582036ea6588a117a08523368dfb91dea4fccc3 (diff) | |
download | scummvm-rg350-64b148afbaca3a7bfbf6df1e3715503f0e35c28a.tar.gz scummvm-rg350-64b148afbaca3a7bfbf6df1e3715503f0e35c28a.tar.bz2 scummvm-rg350-64b148afbaca3a7bfbf6df1e3715503f0e35c28a.zip |
GRAPHICS: MACGUI: Added possibility to provide action ids in menus in strings
Diffstat (limited to 'graphics')
-rw-r--r-- | graphics/macgui/macmenu.cpp | 20 |
1 files changed, 18 insertions, 2 deletions
diff --git a/graphics/macgui/macmenu.cpp b/graphics/macgui/macmenu.cpp index 76c73341bd..8b738c78bd 100644 --- a/graphics/macgui/macmenu.cpp +++ b/graphics/macgui/macmenu.cpp @@ -488,9 +488,25 @@ void MacMenu::createSubMenuFromString(int id, const char *str, int commandId) { submenu = addSubMenu(nullptr, id); for (uint i = 0; i < string.size(); i++) { - while(i < string.size() && string[i] != ';') // Read token + while (i < string.size() && string[i] != ';') // Read token item += string[i++]; + if (item.lastChar() == ']') { // we have command id + item.deleteLastChar(); + + const char *p = strrchr(item.c_str(), '['); + + p++; + + if (p == NULL) { + error("MacMenu::createSubMenuFromString(): Malformed menu item: '%s', bad format for actionId", item.c_str()); + } + + commandId = atoi(p); + + item = Common::String(item.c_str(), p - 1); + } + if (item == "(-") { addMenuItem(submenu, NULL, 0); } else { @@ -504,7 +520,7 @@ void MacMenu::createSubMenuFromString(int id, const char *str, int commandId) { item.deleteChar(shortPtr - item.c_str()); item.deleteChar(shortPtr - item.c_str()); } else { - error("Unexpected shortcut: '%s', item '%s' in menu '%s'", shortPtr, item.c_str(), string.c_str()); + error("MacMenu::createSubMenuFromString(): Unexpected shortcut: '%s', item '%s' in menu '%s'", shortPtr, item.c_str(), string.c_str()); } } |