aboutsummaryrefslogtreecommitdiff
path: root/engines
diff options
context:
space:
mode:
authorBorja Lorente2016-06-05 21:34:23 +0200
committerBorja Lorente2016-08-14 18:07:22 +0200
commit322836699a87fb7ce334d1d99ed5df00e5ebac8b (patch)
tree187a3beb17dd322a6ada31bf12c993ed3f3c7332 /engines
parent6f5997fec6a7fcf1f3a9875218f82a7fda73ac31 (diff)
downloadscummvm-rg350-322836699a87fb7ce334d1d99ed5df00e5ebac8b.tar.gz
scummvm-rg350-322836699a87fb7ce334d1d99ed5df00e5ebac8b.tar.bz2
scummvm-rg350-322836699a87fb7ce334d1d99ed5df00e5ebac8b.zip
MACVENTURE: Border Loading code
Diffstat (limited to 'engines')
-rw-r--r--engines/macventure/macventure.cpp56
-rw-r--r--engines/macventure/macventure.h3
2 files changed, 51 insertions, 8 deletions
diff --git a/engines/macventure/macventure.cpp b/engines/macventure/macventure.cpp
index 67efbc8e31..be949ec00a 100644
--- a/engines/macventure/macventure.cpp
+++ b/engines/macventure/macventure.cpp
@@ -25,6 +25,10 @@
#include "common/debug.h"
#include "common/error.h"
+// For border loading, should be gone later
+#include "common/file.h"
+#include "image/bmp.h"
+
#include "engines/util.h"
#include "macventure/macventure.h"
@@ -60,14 +64,8 @@ Common::Error MacVentureEngine::run() {
_screen.create(kScreenWidth, kScreenHeight, Graphics::PixelFormat::createFormatCLUT8());
- _wm = new Graphics::MacWindowManager();
- _wm->setScreen(&_screen);
-
- _screen.fillRect(Common::Rect(0, 0, _screen.w, _screen.h), Graphics::kColorWhite);
-
- Graphics::MacWindow *w = _wm->addWindow(false, true, true);
- w->setDimensions(Common::Rect(100, 100));
-
+ initGUI();
+
// Your main even loop should be (invoked from) here.
debug("MacVentureEngine::go: Hello, World!");
@@ -98,4 +96,46 @@ void MacVentureEngine::processEvents() {
}
}
+void MacVentureEngine::initGUI() {
+ _wm = new Graphics::MacWindowManager();
+ _wm->setScreen(&_screen);
+ Graphics::MacWindow *w = _wm->addWindow(false, true, true);
+ w->setDimensions(Common::Rect(100, 100));
+ w->setActive(false);
+
+ loadBorder(w, "border_inac.bmp", false);
+
+}
+
+void MacVentureEngine::loadBorder(Graphics::MacWindow *target, Common::String filename, bool active) {
+ Common::File borderfile;
+
+ if (!borderfile.open(filename)) {
+ debug(1, "Cannot open border file");
+ return;
+ }
+
+ Image::BitmapDecoder bmpDecoder;
+ Common::SeekableReadStream *stream = borderfile.readStream(borderfile.size());
+ Graphics::Surface source;
+ Graphics::TransparentSurface *surface = new Graphics::TransparentSurface();
+
+ if (stream) {
+ debug(4, "Loading %s border from %s", (active ? "active" : "inactive"), filename);
+ bmpDecoder.loadStream(*stream);
+ source = *(bmpDecoder.getSurface());
+
+ source.convertToInPlace(surface->getSupportedPixelFormat(), bmpDecoder.getPalette());
+ surface->create(source.w, source.h, source.format);
+ surface->copyFrom(source);
+ surface->applyColorKey(255, 0, 255, false);
+
+ target->setBorder(*surface, active);
+
+ borderfile.close();
+
+ delete stream;
+ }
+}
+
} // End of namespace MacVenture
diff --git a/engines/macventure/macventure.h b/engines/macventure/macventure.h
index ab29eedea7..cdf50b7e91 100644
--- a/engines/macventure/macventure.h
+++ b/engines/macventure/macventure.h
@@ -62,6 +62,9 @@ public:
private:
void processEvents();
+ void initGUI();
+ void loadBorder(Graphics::MacWindow * target, Common::String filename, bool active);
+
private:
const ADGameDescription *_gameDescription;
Common::RandomSource *_rnd;