From f4eda441862f8aacf75417f577907343278708e4 Mon Sep 17 00:00:00 2001 From: Andrei Prykhodko Date: Sun, 22 Jul 2018 21:19:02 +0300 Subject: GRAPHICS: MACGUI: fixes for menu parser from win exe --- graphics/macgui/macmenu.cpp | 29 +++++++++++++++++++++++++---- 1 file changed, 25 insertions(+), 4 deletions(-) (limited to 'graphics/macgui') diff --git a/graphics/macgui/macmenu.cpp b/graphics/macgui/macmenu.cpp index 427f605614..d48a7f47f9 100644 --- a/graphics/macgui/macmenu.cpp +++ b/graphics/macgui/macmenu.cpp @@ -194,6 +194,9 @@ MacMenu *MacMenu::createMenuFromPEexe(Common::PEResources &exe, MacWindowManager int depth = 0; int curMenuItemId = 0; + int action = 0; + bool lastPopUp = false; + bool lastPopUpCopy = false; // no more than 2 level menu for now while (depth >= 0) { uint16 flags = menuData->readUint16LE(); if (flags & kPopUp) { @@ -204,14 +207,32 @@ MacMenu *MacMenu::createMenuFromPEexe(Common::PEResources &exe, MacWindowManager // for now skip readUnicodeString(menuData); } - if (!(flags & kEndMenu)) { - depth++; + if (lastPopUp) { + lastPopUpCopy = lastPopUp; } + + lastPopUp = (flags & kEndMenu) != 0; + depth++; } else { menuData->readUint16LE(); // menu id - menu->addMenuSubItem(curMenuItemId, readUnicodeString(menuData), 0); + Common::U32String name = readUnicodeString(menuData); + if (depth == 1) { + menu->addMenuSubItem(curMenuItemId, name, action); + } + if (!name.empty()) { + action++; + } if (flags & kEndMenu) { - depth--; + if (lastPopUp) + depth -= 2; + else + depth--; + + if (depth == 0) + curMenuItemId++; + + lastPopUp = lastPopUpCopy; + lastPopUpCopy = false; } } } -- cgit v1.2.3