diff options
author | Eugene Sandulenko | 2019-10-02 12:40:57 +0200 |
---|---|---|
committer | Eugene Sandulenko | 2019-10-02 12:40:57 +0200 |
commit | a49fd0dd5e2c578399858e1687f45dff056dc964 (patch) | |
tree | 89507a3e984a84a375cddcb075ba6d74f19489c8 /graphics/macgui | |
parent | 78ef4b9499200d9c55e5ed537f7f037538583367 (diff) | |
download | scummvm-rg350-a49fd0dd5e2c578399858e1687f45dff056dc964.tar.gz scummvm-rg350-a49fd0dd5e2c578399858e1687f45dff056dc964.tar.bz2 scummvm-rg350-a49fd0dd5e2c578399858e1687f45dff056dc964.zip |
GRAPHICS: MACGUI: Read nested submenus from PE exes
Diffstat (limited to 'graphics/macgui')
-rw-r--r-- | graphics/macgui/macmenu.cpp | 47 | ||||
-rw-r--r-- | graphics/macgui/macmenu.h | 3 |
2 files changed, 45 insertions, 5 deletions
diff --git a/graphics/macgui/macmenu.cpp b/graphics/macgui/macmenu.cpp index 522144fe3e..c22e3a0860 100644 --- a/graphics/macgui/macmenu.cpp +++ b/graphics/macgui/macmenu.cpp @@ -21,6 +21,7 @@ */ #include "common/system.h" +#include "common/stack.h" #include "common/keyboard.h" #include "common/macresman.h" @@ -218,6 +219,8 @@ MacMenu *MacMenu::createMenuFromPEexe(Common::PEResources &exe, MacWindowManager MacMenu *menu = wm->addMenu(); + Common::Stack<MacMenuSubMenu *> menus; + int depth = 0; int curMenuItemId = 0; int action = 0; @@ -228,11 +231,19 @@ MacMenu *MacMenu::createMenuFromPEexe(Common::PEResources &exe, MacWindowManager if (flags & kPopUp) { if (depth == 0) { menu->addMenuItem(readUnicodeString(menuData)); + + MacMenuSubMenu *submenu = menu->addSubMenu(nullptr); + menus.push(submenu); } else { - // TODO - // for now skip - readUnicodeString(menuData); + MacMenuSubMenu *submenu = menu->addSubMenu(menus.size() ? menus.top() : nullptr); + + menus.push(submenu); + + Common::U32String name = readUnicodeString(menuData); + menu->addSubMenuItem(submenu, name, action); + action++; } + if (lastPopUp) { lastPopUpCopy = lastPopUp; } @@ -242,13 +253,15 @@ MacMenu *MacMenu::createMenuFromPEexe(Common::PEResources &exe, MacWindowManager } else { menuData->readUint16LE(); // menu id Common::U32String name = readUnicodeString(menuData); - if (depth == 1) { - menu->addMenuSubItem(curMenuItemId, name, action); + if (depth > 0) { + menu->addSubMenuItem(menus.top(), name, action); } if (!name.empty()) { action++; } if (flags & kEndMenu) { + menus.pop(); + if (lastPopUp) depth -= 2; else @@ -303,6 +316,14 @@ int MacMenu::addMenuItem(const Common::U32String &name) { return _items.size() - 1; } +MacMenuSubMenu *MacMenu::addSubMenu(MacMenuSubMenu *submenu) { + if (submenu == nullptr) { + return (_items.back()->submenu = new MacMenuSubMenu()); + } else { + return (submenu->subitems.back()->submenu = new MacMenuSubMenu()); + } +} + void MacMenu::addMenuSubItem(int id, const Common::String &text, int action, int style, char shortcut, bool enabled) { if (_items[id]->submenu == nullptr) _items[id]->submenu = new MacMenuSubMenu(); @@ -321,6 +342,22 @@ void MacMenu::addMenuSubItem(int id, const Common::U32String &text, int action, calcSubMenuBounds(_items[id]->submenu, _items[id]->bbox.left - 1, _items[id]->bbox.bottom + 1); } +void MacMenu::addSubMenuItem(MacMenuSubMenu *submenu, const Common::String &text, int action, int style, char shortcut, bool enabled) { + assert(submenu != nullptr); + + submenu->subitems.push_back(new MacMenuSubItem(text, action, style, shortcut, enabled)); + + calcSubMenuBounds(submenu, 0, 0); // FIXME +} + +void MacMenu::addSubMenuItem(MacMenuSubMenu *submenu, const Common::U32String &text, int action, int style, char shortcut, bool enabled) { + assert(submenu != nullptr); + + submenu->subitems.push_back(new MacMenuSubItem(text, action, style, shortcut, enabled)); + + calcSubMenuBounds(submenu, 0, 0); // FIXME +} + void MacMenu::calcDimensions() { // Calculate menu dimensions int y = 1; diff --git a/graphics/macgui/macmenu.h b/graphics/macgui/macmenu.h index 2ff2bf0ba8..012ea5f609 100644 --- a/graphics/macgui/macmenu.h +++ b/graphics/macgui/macmenu.h @@ -59,10 +59,13 @@ public: void addStaticMenus(const MacMenuData *data); void calcDimensions(); + MacMenuSubMenu *addSubMenu(MacMenuSubMenu *submenu); int addMenuItem(const Common::String &name); int addMenuItem(const Common::U32String &name); void addMenuSubItem(int id, const Common::String &text, int action, int style = 0, char shortcut = 0, bool enabled = true); void addMenuSubItem(int id, const Common::U32String &text, int action, int style = 0, char shortcut = 0, bool enabled = true); + void addSubMenuItem(MacMenuSubMenu *submenu, const Common::String &text, int action, int style = 0, char shortcut = 0, bool enabled = true); + void addSubMenuItem(MacMenuSubMenu *submenu, const Common::U32String &text, int action, int style = 0, char shortcut = 0, bool enabled = true); void loadMenuResource(Common::MacResManager *resFork, uint16 id); void loadMenuBarResource(Common::MacResManager *resFork, uint16 id); void createSubMenuFromString(int id, const char *string, int commandId); |