From c1d051da65e9790330f712c9e3962e31af965851 Mon Sep 17 00:00:00 2001 From: Eugene Sandulenko Date: Mon, 21 Dec 2015 15:47:10 +0100 Subject: WAGE: More work on menu reading --- engines/wage/world.cpp | 54 ++++++++++++++++++++++++++++++++++++++++++++++---- 1 file changed, 50 insertions(+), 4 deletions(-) (limited to 'engines/wage/world.cpp') diff --git a/engines/wage/world.cpp b/engines/wage/world.cpp index 0fd31c6232..96f3faf618 100644 --- a/engines/wage/world.cpp +++ b/engines/wage/world.cpp @@ -45,15 +45,16 @@ * */ +#include "common/file.h" +#include "common/macresman.h" +#include "common/memstream.h" +#include "common/str-array.h" + #include "wage/wage.h" #include "wage/entities.h" #include "wage/script.h" #include "wage/world.h" -#include "common/file.h" -#include "common/macresman.h" -#include "common/memstream.h" - namespace Wage { World::World() { @@ -235,6 +236,7 @@ bool World::loadWorld(Common::MacResManager *resMan) { res = resMan->getResource(MKTAG('M','E','N','U'), 2001); if (res != NULL) { + readMenu(res); warning("STUB: aboutMenu"); //String aboutMenuItemName = appleMenu[1].split(";")[0]; //world.setAboutMenuItemName(aboutMenuItemName); @@ -242,6 +244,7 @@ bool World::loadWorld(Common::MacResManager *resMan) { } res = resMan->getResource(MKTAG('M','E','N','U'), 2004); if (res != NULL) { + readMenu(res); warning("STUB: commandsMenu"); //world.setCommandsMenuName(commandsMenu[0]); //world.setDefaultCommandsMenu(commandsMenu[1]); @@ -249,6 +252,7 @@ bool World::loadWorld(Common::MacResManager *resMan) { } res = resMan->getResource(MKTAG('M','E','N','U'), 2005); if (res != NULL) { + readMenu(res); warning("STUB: weaponsMenu"); //world.setWeaponsMenuName(weaponsMenu[0]); delete res; @@ -261,6 +265,48 @@ bool World::loadWorld(Common::MacResManager *resMan) { return true; } +Common::StringArray World::readMenu(Common::SeekableReadStream *res) { + res->skip(10); + int enableFlags = res->readUint32BE(); + String menuName = readPascalString(res); + String menuItem = readPascalString(res); + int menuItemNumber = 1; + Common::String sb; + byte itemData[4]; + + while (menuItem.size() > 0) { + if (sb.size() > 0) { + sb += ';'; + } + if ((enableFlags & (1 << menuItemNumber)) == 0) { + sb += '('; + } + sb += menuItem; + res->read(itemData, 4); + static const char styles[] = {'B', 'I', 'U', 'O', 'S', 'C', 'E', 0}; + for (int i = 0; styles[i] != 0; i++) { + if ((itemData[3] & (1 << i)) != 0) { + sb += '<'; + sb += styles[i]; + } + } + if (itemData[1] != 0) { + sb += '/'; + sb += (char)itemData[1]; + } + menuItem = readPascalString(res); + menuItemNumber++; + } + + Common::StringArray result; + result.push_back(menuName); + result.push_back(sb); + + warning("menuName: %s", menuName.c_str()); + warning("sb: %s", sb.c_str()); + return result; +} + void World::loadExternalSounds(String fname) { Common::File in; -- cgit v1.2.3