aboutsummaryrefslogtreecommitdiff
path: root/engines/wage
diff options
context:
space:
mode:
authorEugene Sandulenko2016-01-14 13:43:42 +0100
committerEugene Sandulenko2016-01-14 13:43:42 +0100
commit0c6b063f1ef472a11ddc3714f720ffc4be697739 (patch)
treea7e1971127913eaf5734f6672d322fd167c78d58 /engines/wage
parent3dc92233997b86990665fee972487faf5de99bde (diff)
downloadscummvm-rg350-0c6b063f1ef472a11ddc3714f720ffc4be697739.tar.gz
scummvm-rg350-0c6b063f1ef472a11ddc3714f720ffc4be697739.tar.bz2
scummvm-rg350-0c6b063f1ef472a11ddc3714f720ffc4be697739.zip
WAGE: Generate Commands menu
Diffstat (limited to 'engines/wage')
-rw-r--r--engines/wage/menu.cpp83
-rw-r--r--engines/wage/menu.h11
-rw-r--r--engines/wage/world.cpp22
-rw-r--r--engines/wage/world.h6
4 files changed, 104 insertions, 18 deletions
diff --git a/engines/wage/menu.cpp b/engines/wage/menu.cpp
index 713f3bcc0d..a8fa2b27da 100644
--- a/engines/wage/menu.cpp
+++ b/engines/wage/menu.cpp
@@ -92,7 +92,9 @@ enum {
kMenuActionCut,
kMenuActionCopy,
kMenuActionPaste,
- kMenuActionClear
+ kMenuActionClear,
+
+ kMenuActionCommand
};
struct MenuData {
@@ -121,6 +123,9 @@ struct MenuData {
};
Menu::Menu(Gui *gui) : _gui(gui) {
+ assert(_gui->_engine);
+ assert(_gui->_engine->_world);
+
MenuItem *about = new MenuItem(_gui->_builtInFonts ? "\xa9" : "\xf0"); // (c) Symbol as the most resembling apple
_items.push_back(about);
_items[0]->subitems.push_back(new MenuSubItem(_gui->_engine->_world->getAboutMenuItemName(), kMenuActionAbout));
@@ -137,14 +142,11 @@ Menu::Menu(Gui *gui) : _gui(gui) {
_items[m->menunum]->subitems.push_back(new MenuSubItem(m->title, m->action, 0, m->shortcut, m->enabled));
}
- MenuItem *commands = new MenuItem("Commands");
+ MenuItem *commands = createCommandsMenu();
_items.push_back(commands);
- assert(_gui->_engine);
- assert(_gui->_engine->_world);
-
if (!_gui->_engine->_world->_weaponMenuDisabled) {
- MenuItem *weapons = new MenuItem("Weapons");
+ MenuItem *weapons = new MenuItem(_gui->_engine->_world->_weaponsMenuName.c_str());
_items.push_back(weapons);
}
@@ -189,6 +191,75 @@ Menu::~Menu() {
}
}
+MenuItem *Menu::createCommandsMenu() {
+ MenuItem *menu = new MenuItem(_gui->_engine->_world->_commandsMenuName.c_str());
+ Common::String string(_gui->_engine->_world->_commandsMenu);
+
+ Common::String item;
+
+ for (int i = 0; i < string.size(); i++) {
+ while(i < string.size() && string[i] != ';') // Read token
+ item += string[i++];
+
+ if (item == "(-") {
+ menu->subitems.push_back(new MenuSubItem(NULL, 0));
+ } else {
+ bool enabled = true;
+ int style = 0;
+ char shortcut = 0;
+ char *shortptr = strrchr(item.c_str(), '/');
+ if (shortptr != NULL) {
+ if (strlen(shortptr) == 2) {
+ shortcut = shortptr[1];
+ item.deleteLastChar();
+ item.deleteLastChar();
+ } else {
+ error("Unexpected shortcut: '%s', item '%s' in menu '%s'", shortptr, item.c_str(), string.c_str());
+ }
+ }
+
+ while (item.size() >= 2 && item[item.size() - 2] == '<') {
+ char c = item.lastChar();
+ if (c == 'B') {
+ style |= kFontStyleBold;
+ } else if (c == 'I') {
+ style |= kFontStyleItalic;
+ } else if (c == 'U') {
+ style |= kFontStyleUnderline;
+ } else if (c == 'O') {
+ style |= kFontStyleOutline;
+ } else if (c == 'S') {
+ style |= kFontStyleShadow;
+ } else if (c == 'C') {
+ style |= kFontStyleCondensed;
+ } else if (c == 'E') {
+ style |= kFontStyleExtended;
+ }
+ item.deleteLastChar();
+ item.deleteLastChar();
+ }
+
+ Common::String tmpitem(item);
+ tmpitem.trim();
+ if (tmpitem[0] == '(') {
+ enabled = false;
+
+ for (int j = 0; j < item.size(); j++)
+ if (item[j] == '(') {
+ item.deleteChar(j);
+ break;
+ }
+ }
+
+ menu->subitems.push_back(new MenuSubItem(item.c_str(), kMenuActionCommand, style, shortcut, enabled));
+ }
+
+ item = "";
+ }
+
+ return menu;
+}
+
const Graphics::Font *Menu::getMenuFont() {
return _gui->getFont("Chicago-12", Graphics::FontManager::kBigGUIFont);
}
diff --git a/engines/wage/menu.h b/engines/wage/menu.h
index 00b7a3f906..67d061d212 100644
--- a/engines/wage/menu.h
+++ b/engines/wage/menu.h
@@ -53,6 +53,16 @@ namespace Wage {
struct MenuItem;
struct MenuSubItem;
+enum {
+ kFontStyleBold = 1,
+ kFontStyleItalic = 2,
+ kFontStyleUnderline = 4,
+ kFontStyleOutline = 8,
+ kFontStyleShadow = 16,
+ kFontStyleCondensed = 32,
+ kFontStyleExtended = 64
+};
+
class Menu {
public:
Menu(Gui *gui);
@@ -77,6 +87,7 @@ private:
int calculateMenuWidth(MenuItem *menu);
void calcMenuBounds(MenuItem *menu);
void renderSubmenu(MenuItem *menu);
+ MenuItem *createCommandsMenu();
Common::Array<MenuItem *> _items;
diff --git a/engines/wage/world.cpp b/engines/wage/world.cpp
index deac19bdf4..ca1e585440 100644
--- a/engines/wage/world.cpp
+++ b/engines/wage/world.cpp
@@ -273,17 +273,17 @@ 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]);
+ Common::StringArray *menu = readMenu(res);
+ _commandsMenuName = menu->operator[](0);
+ _commandsMenu = menu->operator[](1);
+ delete menu;
delete res;
}
res = resMan->getResource(MKTAG('M','E','N','U'), 2005);
if (res != NULL) {
- readMenu(res);
- warning("STUB: weaponsMenu");
- //world.setWeaponsMenuName(weaponsMenu[0]);
+ Common::StringArray *menu = readMenu(res);
+ _weaponsMenuName = menu->operator[](0);
+ delete menu;
delete res;
}
// TODO: Read Apple menu and get the name of that menu item..
@@ -294,7 +294,7 @@ bool World::loadWorld(Common::MacResManager *resMan) {
return true;
}
-Common::StringArray World::readMenu(Common::SeekableReadStream *res) {
+Common::StringArray *World::readMenu(Common::SeekableReadStream *res) {
res->skip(10);
int enableFlags = res->readUint32BE();
String menuName = readPascalString(res);
@@ -327,9 +327,9 @@ Common::StringArray World::readMenu(Common::SeekableReadStream *res) {
menuItemNumber++;
}
- Common::StringArray result;
- result.push_back(menuName);
- result.push_back(sb);
+ Common::StringArray *result = new Common::StringArray;
+ result->push_back(menuName);
+ result->push_back(sb);
warning("menuName: %s", menuName.c_str());
warning("sb: %s", sb.c_str());
diff --git a/engines/wage/world.h b/engines/wage/world.h
index a79d30cff9..2d2a16de41 100644
--- a/engines/wage/world.h
+++ b/engines/wage/world.h
@@ -95,6 +95,10 @@ public:
Common::String *_saveBeforeCloseMessage;
Common::String *_revertMessage;
+ Common::String _commandsMenuName;
+ Common::String _commandsMenu;
+ Common::String _weaponsMenuName;
+
void addScene(Scene *room) {
if (room->_name.size() != 0) {
String s = room->_name;
@@ -128,7 +132,7 @@ public:
}
private:
- Common::StringArray readMenu(Common::SeekableReadStream *res);
+ Common::StringArray *readMenu(Common::SeekableReadStream *res);
};
} // End of namespace Wage