aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEugene Sandulenko2017-01-14 12:54:10 +0100
committerEugene Sandulenko2017-01-14 13:04:21 +0100
commita0907d26792dcd8301d24c821e3375c41c41b04a (patch)
treea5d4f363c747a232180fcb9a01da263ce5564e0b
parent95d047767417504dac9ff6cbe9d86b63baea3ce8 (diff)
downloadscummvm-rg350-a0907d26792dcd8301d24c821e3375c41c41b04a.tar.gz
scummvm-rg350-a0907d26792dcd8301d24c821e3375c41c41b04a.tar.bz2
scummvm-rg350-a0907d26792dcd8301d24c821e3375c41c41b04a.zip
GRAPHICS: MACGUI: Added method for reading menu from resource
-rw-r--r--graphics/macgui/macmenu.cpp43
-rw-r--r--graphics/macgui/macmenu.h4
2 files changed, 47 insertions, 0 deletions
diff --git a/graphics/macgui/macmenu.cpp b/graphics/macgui/macmenu.cpp
index 449cf58335..4017ddeeeb 100644
--- a/graphics/macgui/macmenu.cpp
+++ b/graphics/macgui/macmenu.cpp
@@ -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);
diff --git a/graphics/macgui/macmenu.h b/graphics/macgui/macmenu.h
index 8e02ee1403..39fc57509f 100644
--- a/graphics/macgui/macmenu.h
+++ b/graphics/macgui/macmenu.h
@@ -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);