aboutsummaryrefslogtreecommitdiff
path: root/engines/macventure/macventure.cpp
diff options
context:
space:
mode:
authorBorja Lorente2016-06-08 16:07:53 +0200
committerBorja Lorente2016-08-14 18:11:06 +0200
commitdd072a39de77f410c41604bcbcc1581606422f67 (patch)
tree5b303a401dff807449f704d0443a740faf116c0f /engines/macventure/macventure.cpp
parent2fd43c24d01e7b532deeddeab87d34e5ef0bd039 (diff)
downloadscummvm-rg350-dd072a39de77f410c41604bcbcc1581606422f67.tar.gz
scummvm-rg350-dd072a39de77f410c41604bcbcc1581606422f67.tar.bz2
scummvm-rg350-dd072a39de77f410c41604bcbcc1581606422f67.zip
MACVENTURE: Add basic menu loading
Diffstat (limited to 'engines/macventure/macventure.cpp')
-rw-r--r--engines/macventure/macventure.cpp57
1 files changed, 53 insertions, 4 deletions
diff --git a/engines/macventure/macventure.cpp b/engines/macventure/macventure.cpp
index 3f576373e0..5eefde51f3 100644
--- a/engines/macventure/macventure.cpp
+++ b/engines/macventure/macventure.cpp
@@ -24,13 +24,19 @@
#include "common/debug-channels.h"
#include "common/debug.h"
#include "common/error.h"
-
#include "engines/util.h"
#include "macventure/macventure.h"
+// To move
+#include "common/file.h"
+
namespace MacVenture {
+enum {
+ kMaxMenuTitleLength = 30
+};
+
MacVentureEngine::MacVentureEngine(OSystem *syst, const ADGameDescription *gameDesc) : Engine(syst) {
_gameDescription = gameDesc;
_rnd = new Common::RandomSource("macventure");
@@ -57,9 +63,7 @@ Common::Error MacVentureEngine::run() {
_debugger = new Console(this);
// Additional setup.
- debug("MacVentureEngine::init");
-
- _gui = new Gui();
+ debug("MacVentureEngine::init");
// Your main even loop should be (invoked from) here.
debug("MacVentureEngine::go: Hello, World!");
@@ -68,6 +72,11 @@ Common::Error MacVentureEngine::run() {
if (!_resourceManager->open(getGameFileName()))
error("Could not open %s as a resource fork", getGameFileName());
+ if (!loadMenuData())
+ error("Could not load menu data from %s", getGameFileName());
+
+ _gui = new Gui(this);
+
_shouldQuit = false;
while (!_shouldQuit) {
processEvents();
@@ -95,5 +104,45 @@ void MacVentureEngine::processEvents() {
}
}
+bool MacVentureEngine::loadMenuData() {
+ Common::MacResIDArray resArray;
+ Common::SeekableReadStream *res;
+ Common::MacResIDArray::const_iterator iter;
+
+ if ((resArray = _resourceManager->getResIDArray(MKTAG('M', 'E', 'N', 'U'))).size() == 0)
+ return false;
+
+ _menuData = new Graphics::MenuData[resArray.size()];
+ int i = 0;
+
+ for (iter = resArray.begin(); iter != resArray.end(); ++iter) {
+ res = _resourceManager->getResource(MKTAG('M', 'E', 'N', 'U'), *iter);
+
+ Graphics::MenuData data;
+ int menunum = -1;
+ for (int i = 0; i < 5; i++) {
+ res->readUint16BE();
+ // Skip menuID, width, height, resourceID, placeholder
+ }
+ bool enabled = res->readUint32BE();
+ uint8 titleLength = res->readByte();
+ char* title = new char[titleLength+1];
+ res->read(title, titleLength);
+ title[titleLength] = '\0';
+
+ _menuData[i] = { menunum, title, 0, 0, enabled};
+ i++;
+ }
+
+ // Override last value (end-of-menu) with our end-of-menu
+ _menuData[resArray.size() - 1] = { 0, 0, 0, 0, false };
+
+ return true;
+}
+
+Graphics::MenuData* MacVentureEngine::getMenuData() {
+ return _menuData;
+}
+
} // End of namespace MacVenture