mirror of
https://github.com/libretro/scummvm.git
synced 2025-02-02 17:03:13 +00:00
GRAPHICS: MACGUI: Added method for reading menu from resource
This commit is contained in:
parent
95d0477674
commit
a0907d2679
@ -112,6 +112,49 @@ Menu::~Menu() {
|
||||
}
|
||||
}
|
||||
|
||||
Common::StringArray *Menu::readMenuFromResource(Common::SeekableReadStream *res) {
|
||||
res->skip(10);
|
||||
int enableFlags = res->readUint32BE();
|
||||
Common::String menuName = res->readPascalString();
|
||||
Common::String menuItem = res->readPascalString();
|
||||
int menuItemNumber = 1;
|
||||
Common::String menu;
|
||||
byte itemData[4];
|
||||
|
||||
while (!menuItem.empty()) {
|
||||
if (!menu.empty()) {
|
||||
menu += ';';
|
||||
}
|
||||
if ((enableFlags & (1 << menuItemNumber)) == 0) {
|
||||
menu += '(';
|
||||
}
|
||||
menu += 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) {
|
||||
menu += '<';
|
||||
menu += styles[i];
|
||||
}
|
||||
}
|
||||
if (itemData[1] != 0) {
|
||||
menu += '/';
|
||||
menu += (char)itemData[1];
|
||||
}
|
||||
menuItem = res->readPascalString();
|
||||
menuItemNumber++;
|
||||
}
|
||||
|
||||
Common::StringArray *result = new Common::StringArray;
|
||||
result->push_back(menuName);
|
||||
result->push_back(menu);
|
||||
|
||||
debug(4, "menuName: %s", menuName.c_str());
|
||||
debug(4, "menu: %s", menu.c_str());
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
void Menu::addStaticMenus(const MenuData *data) {
|
||||
MenuItem *about = new MenuItem(_wm->_fontMan->hasBuiltInFonts() ? "\xa9" : "\xf0"); // (c) Symbol as the most resembling apple
|
||||
_items.push_back(about);
|
||||
|
@ -23,6 +23,8 @@
|
||||
#ifndef GRAPHICS_MACGUI_MACMENU_H
|
||||
#define GRAPHICS_MACGUI_MACMENU_H
|
||||
|
||||
#include "common/str-array.h"
|
||||
|
||||
namespace Graphics {
|
||||
|
||||
struct MenuItem;
|
||||
@ -41,6 +43,8 @@ public:
|
||||
Menu(int id, const Common::Rect &bounds, MacWindowManager *wm);
|
||||
~Menu();
|
||||
|
||||
static Common::StringArray *readMenuFromResource(Common::SeekableReadStream *res);
|
||||
|
||||
void setCommandsCallback(void (*callback)(int, Common::String &, void *), void *data) { _ccallback = callback; _cdata = data; }
|
||||
|
||||
void addStaticMenus(const MenuData *data);
|
||||
|
Loading…
x
Reference in New Issue
Block a user