mirror of
https://github.com/libretro/scummvm.git
synced 2024-12-16 06:39:17 +00:00
WAGE: Generate Commands menu
This commit is contained in:
parent
3dc9223399
commit
0c6b063f1e
@ -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);
|
||||
}
|
||||
|
@ -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;
|
||||
|
||||
|
@ -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());
|
||||
|
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user