aboutsummaryrefslogtreecommitdiff
path: root/engines/macventure
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
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')
-rw-r--r--engines/macventure/gui.cpp31
-rw-r--r--engines/macventure/gui.h12
-rw-r--r--engines/macventure/macventure.cpp57
-rw-r--r--engines/macventure/macventure.h9
4 files changed, 98 insertions, 11 deletions
diff --git a/engines/macventure/gui.cpp b/engines/macventure/gui.cpp
index 22e0faa515..38a633673c 100644
--- a/engines/macventure/gui.cpp
+++ b/engines/macventure/gui.cpp
@@ -1,12 +1,23 @@
-
-#include "macventure/macventure.h"
-
#include "common/file.h"
#include "image/bmp.h"
+#include "macventure/macventure.h"
+#include "macventure/gui.h"
+
namespace MacVenture {
-Gui::Gui() {
+/* priority, name, action, shortcut, enabled*/
+#define MV_MENU5(p, n, a, s, e) Graphics::MenuData{p, n, a, s, e}
+#define MV_MENU4(p, n, a, s) Graphics::MenuData{p, n, a, s, false}
+#define MV_MENUtop(n, a, s) Graphics::MenuData{-1, n, a, s, true}
+
+static const Graphics::MenuData menuSubItems[] = {
+ { -1, "Hello World", 0, 0, false },
+ { 0, "How yo duin", 0, 0, false },
+};
+
+Gui::Gui(MacVentureEngine *engine) {
+ _engine = engine;
initGUI();
}
@@ -25,6 +36,12 @@ void Gui::initGUI() {
w->setDimensions(Common::Rect(100, 100));
w->setActive(false);
+ _menu = _wm.addMenu();
+
+ loadMenus();
+
+ _menu->calcDimensions();
+
loadBorder(w, "border_inac.bmp", false);
}
@@ -59,4 +76,10 @@ void Gui::loadBorder(Graphics::MacWindow * target, Common::String filename, bool
}
}
+void Gui::loadMenus() {
+ Graphics::MenuData data;
+ Common::Array<Graphics::MenuData>::const_iterator iter;
+ _menu->addStaticMenus(_engine->getMenuData());
+}
+
} // End of namespace MacVenture
diff --git a/engines/macventure/gui.h b/engines/macventure/gui.h
index 0cfb835d38..c6aae15303 100644
--- a/engines/macventure/gui.h
+++ b/engines/macventure/gui.h
@@ -24,29 +24,35 @@
#define MACVENTURE_GUI_H
#include "graphics/macgui/macwindowmanager.h"
-
-#include "macventure/macventure.h"
+#include "graphics/macgui/macwindow.h"
+#include "graphics/macgui/macmenu.h"
namespace MacVenture {
using namespace Graphics::MacGUIConstants;
+class MacVentureEngine;
class Gui {
public:
- Gui();
+ Gui(MacVentureEngine *engine);
~Gui();
void draw();
private: // Attributes
+ MacVentureEngine *_engine;
+
Graphics::ManagedSurface _screen;
Graphics::MacWindowManager _wm;
+ Graphics::Menu *_menu;
+
private: // Methods
void initGUI();
+ void loadMenus();
void loadBorder(Graphics::MacWindow * target, Common::String filename, bool active);
};
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
diff --git a/engines/macventure/macventure.h b/engines/macventure/macventure.h
index 9be560c46e..254f162d54 100644
--- a/engines/macventure/macventure.h
+++ b/engines/macventure/macventure.h
@@ -58,8 +58,12 @@ public:
virtual Common::Error run();
+ Graphics::MenuData *getMenuData();
+
private:
void processEvents();
+
+ bool loadMenuData();
private: // Attributes
@@ -77,6 +81,11 @@ private: // Attributes
private: // Methods
const char* getGameFileName() const;
+
+private: //To move
+
+ Graphics::MenuData *_menuData;
+
};