aboutsummaryrefslogtreecommitdiff
path: root/engines/macventure
diff options
context:
space:
mode:
authorBorja Lorente2016-08-02 18:45:23 +0200
committerBorja Lorente2016-08-14 19:00:59 +0200
commit5c43e3049936c28b57147c2062e1f7724a9165ce (patch)
tree8fbcf5be61fdcdb2492c64ca46779a4f27ddf764 /engines/macventure
parentd1a31ff5dbb3fb9cd7a3cda2945ee7f9183a6497 (diff)
downloadscummvm-rg350-5c43e3049936c28b57147c2062e1f7724a9165ce.tar.gz
scummvm-rg350-5c43e3049936c28b57147c2062e1f7724a9165ce.tar.bz2
scummvm-rg350-5c43e3049936c28b57147c2062e1f7724a9165ce.zip
MACVENTURE: Implement loading borders from zip
Diffstat (limited to 'engines/macventure')
-rw-r--r--engines/macventure/datafiles.cpp83
-rw-r--r--engines/macventure/gui.cpp36
-rw-r--r--engines/macventure/gui.h4
-rw-r--r--engines/macventure/macventure.cpp5
-rw-r--r--engines/macventure/macventure.h6
-rw-r--r--engines/macventure/module.mk3
6 files changed, 110 insertions, 27 deletions
diff --git a/engines/macventure/datafiles.cpp b/engines/macventure/datafiles.cpp
new file mode 100644
index 0000000000..71407a7557
--- /dev/null
+++ b/engines/macventure/datafiles.cpp
@@ -0,0 +1,83 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ */
+
+#ifndef MACVENTURE_DATAFILES_H
+#define MACVENTURE_DATAFILES_H
+
+#include "macventure/macventure.h"
+#include "macventure/windows.h"
+
+#include "common/unzip.h"
+
+namespace MacVenture {
+
+#define MACVENTURE_DATA_BUNDLE Common::String("macventure.zip")
+
+Common::String windowTypeName(MVWindowType windowType) {
+ switch (windowType) {
+ case kDocument:
+ return "Document";
+ case kDBox:
+ return "DBox";
+ case kPlainDBox:
+ return "PlainDBox";
+ case kAltBox:
+ return "AltBox";
+ case kNoGrowDoc:
+ return "NoGrowDoc";
+ case kMovableDBox:
+ return "MovableDBox";
+ case kZoomDoc:
+ return "ZoomDoc";
+ case kZoomNoGrow:
+ return "ZoomNoGrow";
+ case kRDoc16:
+ return "RDoc16";
+ case kRDoc4:
+ return "RDoc4";
+ case kRDoc6:
+ return "RDoc6";
+ case kRDoc10:
+ return "RDoc10";
+ }
+}
+
+void MacVentureEngine::loadDataBundle() {
+ _dataBundle = Common::makeZipArchive(MACVENTURE_DATA_BUNDLE);
+ if (!_dataBundle)
+ error("Couldn't load data bundle '%s'.", MACVENTURE_DATA_BUNDLE.c_str());
+}
+
+Common::SeekableReadStream *MacVentureEngine::getBorderFile(MVWindowType windowType, bool isActive) {
+ Common::String filename = windowTypeName(windowType);
+ filename += (isActive ? "_act.bmp" : "_inac.bmp");
+ if (!_dataBundle->hasFile(filename)) {
+ warning("Missing border file '%s' in data bundle", filename.c_str());
+ return nullptr;
+ }
+
+ return _dataBundle->createReadStreamForMember(filename);
+}
+
+} // End of namespace MacVenture
+
+#endif
diff --git a/engines/macventure/gui.cpp b/engines/macventure/gui.cpp
index b3f282f4c9..4f11478c21 100644
--- a/engines/macventure/gui.cpp
+++ b/engines/macventure/gui.cpp
@@ -215,40 +215,35 @@ void Gui::initWindows() {
_controlsWindow->setDimensions(getWindowData(kCommandsWindow).bounds);
_controlsWindow->setActive(false);
_controlsWindow->setCallback(commandsWindowCallback, this);
- loadBorder(_controlsWindow, "border_command.bmp", false, findWindowData(kCommandsWindow).type);
- loadBorder(_controlsWindow, "border_command.bmp", true, findWindowData(kCommandsWindow).type);
+ loadBorders(_controlsWindow, findWindowData(kCommandsWindow).type);
// Main Game Window
_mainGameWindow = _wm.addWindow(true, true, true);
_mainGameWindow->setDimensions(getWindowData(kMainGameWindow).bounds);
_mainGameWindow->setActive(false);
_mainGameWindow->setCallback(mainGameWindowCallback, this);
- loadBorder(_mainGameWindow, "border_no_scroll_inac.bmp", false, findWindowData(kMainGameWindow).type);
- loadBorder(_mainGameWindow, "border_no_scroll_act.bmp", true, findWindowData(kMainGameWindow).type);
+ loadBorders(_mainGameWindow, findWindowData(kMainGameWindow).type);
// In-game Output Console
_outConsoleWindow = _wm.addWindow(true, true, false);
_outConsoleWindow->setDimensions(getWindowData(kOutConsoleWindow).bounds);
_outConsoleWindow->setActive(false);
_outConsoleWindow->setCallback(outConsoleWindowCallback, this);
- loadBorder(_outConsoleWindow, "border_left_scroll_inac.bmp", false, findWindowData(kOutConsoleWindow).type);
- loadBorder(_outConsoleWindow, "border_left_scroll_act.bmp", true, findWindowData(kOutConsoleWindow).type);
+ loadBorders(_outConsoleWindow, findWindowData(kOutConsoleWindow).type);
// Self Window
_selfWindow = _wm.addWindow(false, true, false);
_selfWindow->setDimensions(getWindowData(kSelfWindow).bounds);
_selfWindow->setActive(false);
_selfWindow->setCallback(selfWindowCallback, this);
- loadBorder(_selfWindow, "border_none.bmp", false, findWindowData(kSelfWindow).type);
- loadBorder(_selfWindow, "border_none.bmp", true, findWindowData(kSelfWindow).type);
+ loadBorders(_selfWindow, findWindowData(kSelfWindow).type);
// Exits Window
_exitsWindow = _wm.addWindow(false, false, false);
_exitsWindow->setDimensions(getWindowData(kExitsWindow).bounds);
_exitsWindow->setActive(false);
_exitsWindow->setCallback(exitsWindowCallback, this);
- loadBorder(_exitsWindow, "border_no_scroll_inac.bmp", false, findWindowData(kExitsWindow).type);
- loadBorder(_exitsWindow, "border_no_scroll_act.bmp", true, findWindowData(kExitsWindow).type);
+ loadBorders(_exitsWindow, findWindowData(kExitsWindow).type);
}
const WindowData& Gui::getWindowData(WindowReference reference) {
@@ -336,35 +331,28 @@ WindowReference Gui::createInventoryWindow(ObjID objRef) {
newWindow->setDimensions(newData.bounds);
newWindow->setCallback(inventoryWindowCallback, this);
newWindow->setCloseable(true);
- loadBorder(newWindow, "border_both_scroll_inac.bmp", false, newData.type);
- loadBorder(newWindow, "border_both_scroll_act.bmp", true, newData.type);
+ loadBorders(newWindow, newData.type);
_inventoryWindows.push_back(newWindow);
debug("Create new inventory window. Reference: %d", newData.refcon);
return newData.refcon;
}
-void Gui::loadBorder(Graphics::MacWindow *target, Common::String filename, bool active, MVWindowType type) {
- Common::File borderfile;
+void Gui::loadBorders(Graphics::MacWindow * target, MVWindowType type) {
+ loadBorder(target, type, false);
+ loadBorder(target, type, true);
+}
- if (!borderfile.open(filename)) {
- debug(1, "Cannot open border file");
- return;
- }
+void Gui::loadBorder(Graphics::MacWindow * target, MVWindowType type, bool active) {
- Image::BitmapDecoder bmpDecoder;
- Common::SeekableReadStream *stream = borderfile.readStream(borderfile.size());
- Graphics::Surface source;
- Graphics::TransparentSurface *surface = new Graphics::TransparentSurface();
+ Common::SeekableReadStream *stream = _engine->getBorderFile(type, active);
if (stream) {
BorderBounds bbs = borderBounds(type);
- debug(4, "Loading %s border from %s", (active ? "active" : "inactive"), filename.c_str());
target->loadBorder(*stream, active, bbs.leftOffset, bbs.rightOffset, bbs.topOffset, bbs.bottomOffset);
delete stream;
}
- borderfile.close();
}
void Gui::loadGraphics() {
diff --git a/engines/macventure/gui.h b/engines/macventure/gui.h
index 18be9b93e2..fb9bccf8a5 100644
--- a/engines/macventure/gui.h
+++ b/engines/macventure/gui.h
@@ -156,7 +156,6 @@ public:
void setTextInput(Common::String str);
void closeDialog();
-
// TODO: Currently unused, we are using ScummVM dialogs instead.
void loadGame(int slot);
void saveInto(int slot);
@@ -205,7 +204,8 @@ private: // Methods
bool loadMenus();
bool loadWindows();
bool loadControls();
- void loadBorder(Graphics::MacWindow * target, Common::String filename, bool active, MVWindowType type);
+ void loadBorders(Graphics::MacWindow *target, MVWindowType type);
+ void loadBorder(Graphics::MacWindow *target, MVWindowType type, bool active);
void loadGraphics();
// Drawers
diff --git a/engines/macventure/macventure.cpp b/engines/macventure/macventure.cpp
index b52379d6ed..ac9ae8e3f7 100644
--- a/engines/macventure/macventure.cpp
+++ b/engines/macventure/macventure.cpp
@@ -86,6 +86,9 @@ MacVentureEngine::~MacVentureEngine() {
if (_soundManager)
delete _soundManager;
+
+ if (_dataBundle)
+ delete _dataBundle;
}
Common::Error MacVentureEngine::run() {
@@ -113,6 +116,8 @@ Common::Error MacVentureEngine::run() {
_decodingNamingArticles = new StringTable(this, _resourceManager, kNamingArticlesStringTableID);
_decodingIndirectArticles = new StringTable(this, _resourceManager, kIndirectArticlesStringTableID);
+ loadDataBundle();
+
// Big class instantiation
_gui = new Gui(this, _resourceManager);
_world = new World(this, _resourceManager);
diff --git a/engines/macventure/macventure.h b/engines/macventure/macventure.h
index b4f8192ed7..6953b61904 100644
--- a/engines/macventure/macventure.h
+++ b/engines/macventure/macventure.h
@@ -191,6 +191,10 @@ public:
virtual Common::Error loadGameState(int slot);
virtual Common::Error saveGameState(int slot, const Common::String &desc);
+ // datafiles.cpp
+ void loadDataBundle();
+ Common::SeekableReadStream *getBorderFile(MVWindowType windowType, bool isActive);
+
void reset();
void resetInternals();
void resetGui();
@@ -319,6 +323,8 @@ private: // Attributes
SoundManager *_soundManager;
+ Common::Archive *_dataBundle;
+
// Engine state
GameState _gameState;
GlobalSettings _globalSettings;
diff --git a/engines/macventure/module.mk b/engines/macventure/module.mk
index 244401b4a6..7b81018394 100644
--- a/engines/macventure/module.mk
+++ b/engines/macventure/module.mk
@@ -14,7 +14,8 @@ MODULE_OBJS := \
prebuilt_dialogs.o \
windows.o \
sound.o \
- saveload.o
+ saveload.o \
+ datafiles.o
MODULE_DIRS += \