aboutsummaryrefslogtreecommitdiff
path: root/graphics
diff options
context:
space:
mode:
authorCameron Cawley2019-08-10 18:37:58 +0100
committerFilippos Karapetis2019-08-11 22:27:11 +0300
commit92a3a3a8a551f32abc9654d3731ae3d297280878 (patch)
treeb666ed2f57aa17ada6764a114e83601648af86ba /graphics
parentaca627bec7b407790d78a64df984344ff454c15b (diff)
downloadscummvm-rg350-92a3a3a8a551f32abc9654d3731ae3d297280878.tar.gz
scummvm-rg350-92a3a3a8a551f32abc9654d3731ae3d297280878.tar.bz2
scummvm-rg350-92a3a3a8a551f32abc9654d3731ae3d297280878.zip
GRAPHICS: MACGUI: Allow loading menus from resource forks
Diffstat (limited to 'graphics')
-rw-r--r--graphics/macgui/macmenu.cpp47
-rw-r--r--graphics/macgui/macmenu.h3
2 files changed, 50 insertions, 0 deletions
diff --git a/graphics/macgui/macmenu.cpp b/graphics/macgui/macmenu.cpp
index a966f98616..af906aa33a 100644
--- a/graphics/macgui/macmenu.cpp
+++ b/graphics/macgui/macmenu.cpp
@@ -22,6 +22,7 @@
#include "common/system.h"
#include "common/keyboard.h"
+#include "common/macresman.h"
#include "graphics/primitives.h"
#include "graphics/font.h"
@@ -307,6 +308,52 @@ void MacMenu::calcDimensions() {
}
}
+void MacMenu::loadMenuResource(Common::MacResManager *resFork, uint16 id) {
+ Common::SeekableReadStream *res = resFork->getResource(MKTAG('M', 'E', 'N', 'U'), id);
+ assert(res);
+
+ uint16 menuID = res->readUint16BE();
+ /* uint16 width = */ res->readUint16BE();
+ /* uint16 height = */ res->readUint16BE();
+ /* uint16 resourceID = */ res->readUint16BE();
+ /* uint16 placeholder = */ res->readUint16BE();
+ uint32 initialState = res->readUint32BE();
+ Common::String menuTitle = res->readPascalString();
+
+ if (!menuTitle.empty()) {
+ int menu = addMenuItem(menuTitle);
+ initialState >>= 1;
+
+ // Read submenu items
+ int action = menuID << 16;
+ while (true) {
+ Common::String subMenuTitle = res->readPascalString();
+ if (subMenuTitle.empty())
+ break;
+
+ /* uint8 icon = */ res->readByte();
+ uint8 key = res->readByte();
+ /* uint8 mark = */ res->readByte();
+ uint8 style = res->readByte();
+
+ addMenuSubItem(menu, subMenuTitle, action++, style, key, initialState & 1);
+ initialState >>= 1;
+ }
+ }
+
+ delete res;
+}
+
+void MacMenu::loadMenuBarResource(Common::MacResManager *resFork, uint16 id) {
+ Common::SeekableReadStream *res = resFork->getResource(MKTAG('M', 'B', 'A', 'R'), id);
+ assert(res);
+
+ uint16 count = res->readUint16BE();
+ for (int i = 0; i < count; i++) {
+ loadMenuResource(resFork, res->readUint16BE());
+ }
+}
+
void MacMenu::clearSubMenu(int id) {
MacMenuItem *menu = _items[id];
diff --git a/graphics/macgui/macmenu.h b/graphics/macgui/macmenu.h
index 388e662938..e531be6ead 100644
--- a/graphics/macgui/macmenu.h
+++ b/graphics/macgui/macmenu.h
@@ -28,6 +28,7 @@
namespace Common {
class U32String;
+class MacResManager;
}
namespace Graphics {
@@ -61,6 +62,8 @@ public:
int addMenuItem(const Common::U32String &name);
void addMenuSubItem(int id, const Common::String &text, int action, int style = 0, char shortcut = 0, bool enabled = true);
void addMenuSubItem(int id, const Common::U32String &text, int action, int style = 0, char shortcut = 0, bool enabled = true);
+ void loadMenuResource(Common::MacResManager *resFork, uint16 id);
+ void loadMenuBarResource(Common::MacResManager *resFork, uint16 id);
void createSubMenuFromString(int id, const char *string, int commandId);
void clearSubMenu(int id);