From 638e8e99c885722b0ab2d7ee62a7f840ddea1c1a Mon Sep 17 00:00:00 2001 From: Borja Lorente Date: Fri, 3 Jun 2016 20:50:40 +0200 Subject: WAGE: Change GUI Scene to load BMP borders --- engines/wage/gui.cpp | 46 ++++++++++++++++++---------------------------- engines/wage/gui.h | 4 ++-- 2 files changed, 20 insertions(+), 30 deletions(-) (limited to 'engines/wage') diff --git a/engines/wage/gui.cpp b/engines/wage/gui.cpp index 35a8f28e5f..0f4733364a 100644 --- a/engines/wage/gui.cpp +++ b/engines/wage/gui.cpp @@ -170,8 +170,7 @@ Gui::Gui(WageEngine *engine) { _consoleWindow->setCallback(consoleWindowCallback, this); loadBorders(); - _sceneWindow->setBorder(_activeBorder, true); - _sceneWindow->setBorder(_inactiveBorder, false); + } Gui::~Gui() { @@ -367,9 +366,15 @@ void Gui::executeMenuCommand(int action, Common::String &text) { } } -void Gui::loadBorders() { +void Gui::loadBorders() { + loadBorder(_sceneWindow, "border_inac.bmp", false); + loadBorder(_sceneWindow, "border_act.bmp", true); +} + +void Gui::loadBorder(Graphics::MacWindow *target, Common::String filename, bool active) { Common::File borderfile; - if (!borderfile.open("border_act.bmp")) { + + if (!borderfile.open(filename)) { debug(1, "Cannot open border file"); return; } @@ -377,36 +382,21 @@ void Gui::loadBorders() { Image::BitmapDecoder bmpDecoder; Common::SeekableReadStream *stream = borderfile.readStream(borderfile.size()); Graphics::Surface source; + Graphics::TransparentSurface *surface = new Graphics::TransparentSurface(); if (stream) { - bmpDecoder.loadStream(*stream); + debug(4, "Loading %s border from %s", (active ? "active" : "inactive"), filename); + bmpDecoder.loadStream(*stream); source = *(bmpDecoder.getSurface()); - _activeBorder = new Graphics::TransparentSurface(); - source.convertToInPlace(_activeBorder->getSupportedPixelFormat(), bmpDecoder.getPalette()); - _activeBorder->create(source.w, source.h, source.format); - _activeBorder->copyFrom(source); - _activeBorder->applyColorKey(255, 0, 255, false); - - delete stream; - } - - if (!borderfile.open("border_inac.bmp")) { - debug(1, "Cannot open border file"); - return; - } - - stream = borderfile.readStream(borderfile.size()); + source.convertToInPlace(surface->getSupportedPixelFormat(), bmpDecoder.getPalette()); + surface->create(source.w, source.h, source.format); + surface->copyFrom(source); + surface->applyColorKey(255, 0, 255, false); - if (stream) { - bmpDecoder.loadStream(*stream); - source = *(bmpDecoder.getSurface()); + target->setBorder(*surface, active); - _inactiveBorder = new Graphics::TransparentSurface(); - source.convertToInPlace(_inactiveBorder->getSupportedPixelFormat(), bmpDecoder.getPalette()); - _inactiveBorder->create(source.w, source.h, source.format); - _inactiveBorder->copyFrom(source); - _inactiveBorder->applyColorKey(255, 0, 255, false); + borderfile.close(); delete stream; } diff --git a/engines/wage/gui.h b/engines/wage/gui.h index a6a25266b1..898c7c3162 100644 --- a/engines/wage/gui.h +++ b/engines/wage/gui.h @@ -54,6 +54,7 @@ #include "graphics/macgui/macwindowmanager.h" #include "graphics/macgui/macwindow.h" #include "graphics/macgui/macmenu.h" +#include "graphics/macgui/macwindowborder.h" #include "common/events.h" #include "common/rect.h" @@ -156,6 +157,7 @@ private: void updateTextSelection(int x, int y); void loadBorders(); + void loadBorder(Graphics::MacWindow *target, Common::String filename, bool active); public: Graphics::ManagedSurface _screen; @@ -175,8 +177,6 @@ public: Graphics::MacWindow *_consoleWindow; private: - Graphics::TransparentSurface *_activeBorder; - Graphics::TransparentSurface *_inactiveBorder; Graphics::ManagedSurface _console; Graphics::Menu *_menu; -- cgit v1.2.3