aboutsummaryrefslogtreecommitdiff
path: root/engines
diff options
context:
space:
mode:
authorBorja Lorente2016-06-22 21:48:14 +0200
committerBorja Lorente2016-08-14 18:33:25 +0200
commit1540674f7720f520bdb585999e24ceb653c9bda3 (patch)
treecffa9a277fce2df8178a87101a39e1427adb0622 /engines
parent0743e9531b5ef871e17cd7ca88966ea2c07b7147 (diff)
downloadscummvm-rg350-1540674f7720f520bdb585999e24ceb653c9bda3.tar.gz
scummvm-rg350-1540674f7720f520bdb585999e24ceb653c9bda3.tar.bz2
scummvm-rg350-1540674f7720f520bdb585999e24ceb653c9bda3.zip
MACVENTURE: Fix dymanic object drawing
Diffstat (limited to 'engines')
-rw-r--r--engines/macventure/gui.cpp49
-rw-r--r--engines/macventure/image.cpp58
2 files changed, 81 insertions, 26 deletions
diff --git a/engines/macventure/gui.cpp b/engines/macventure/gui.cpp
index e202b82d3e..5c1747cb18 100644
--- a/engines/macventure/gui.cpp
+++ b/engines/macventure/gui.cpp
@@ -26,6 +26,9 @@
#include "macventure/macventure.h"
#include "macventure/gui.h"
+//Test
+#include "common/system.h"
+
namespace MacVenture {
enum MenuAction;
@@ -99,11 +102,12 @@ Gui::~Gui() {
}
void Gui::draw() {
- drawWindows();
- _wm.draw();
+ drawWindows();
drawTitle();
+
+ _wm.draw();
}
void Gui::drawMenu() {
@@ -178,7 +182,7 @@ void Gui::updateWindowInfo(WindowReference ref, ObjID objID, const Common::Array
originx = originx > childPos.x ? childPos.x : originx;
originy = originy > childPos.y ? childPos.y : originy;
}
- data.children.push_back(DrawableObject(child, kBlitDirect));
+ data.children.push_back(DrawableObject(child, kBlitBIC));
}
}
if (originx != 0x7fff) data.bounds.left = originx;
@@ -187,7 +191,7 @@ void Gui::updateWindowInfo(WindowReference ref, ObjID objID, const Common::Array
}
void Gui::addChild(WindowReference target, ObjID child) {
- findWindowData(target).children.push_back(DrawableObject(child, kBlitDirect));
+ findWindowData(target).children.push_back(DrawableObject(child, kBlitBIC));
}
void Gui::removeChild(WindowReference target, ObjID child) {
@@ -502,8 +506,11 @@ void Gui::drawMainGameWindow() {
Graphics::ManagedSurface *srf = _mainGameWindow->getSurface();
BorderBounds border = borderBounds(getWindowData(kMainGameWindow).type);
- ImageAsset bg(3, _graphics);
- bg.blitInto(
+ if (!_assets.contains(3)) {
+ _assets[3] = new ImageAsset(3, _graphics);
+ }
+
+ _assets[3]->blitInto(
_mainGameWindow->getSurface(),
border.leftOffset * 2,
border.topOffset * 2,
@@ -511,18 +518,16 @@ void Gui::drawMainGameWindow() {
drawObjectsInWindow(kMainGameWindow, _mainGameWindow->getSurface());
+ // To be deleted
+ _wm.draw();
+
+ g_system->updateScreen();
+
}
void Gui::drawSelfWindow() {
Graphics::ManagedSurface *srf = _selfWindow->getSurface();
BorderBounds border = borderBounds(getWindowData(kSelfWindow).type);
- srf->fillRect(
- Common::Rect(
- border.leftOffset * 2,
- border.topOffset * 2,
- srf->w - (border.rightOffset * 3),
- srf->h - (border.bottomOffset * 3)),
- kColorWhite);
}
void Gui::drawObjectsInWindow(WindowReference target, Graphics::ManagedSurface * surface) {
@@ -543,6 +548,12 @@ void Gui::drawObjectsInWindow(WindowReference target, Graphics::ManagedSurface *
border.leftOffset * 2 + pos.x,
border.topOffset * 2 + pos.y,
mode);
+
+ // To be deleted
+ _wm.draw();
+
+ g_system->updateScreen();
+
}
}
@@ -674,14 +685,14 @@ void Gui::updateWindow(WindowReference winID, bool containerOpen) {
for (uint i = 0; i < children.size(); i++) {
uint flag = 0;
ObjID child = children[i].obj;
- BlitMode mode;
- bool off = _engine->isObjVisible(child);
- if (!off || _engine->isObjClickable(child)) {
+ BlitMode mode = kBlitDirect;
+ bool off = !_engine->isObjVisible(child);
+ if (flag || !off || !_engine->isObjClickable(child)) {
mode = kBlitBIC;
- if (_engine->isObjSelected(child)) {
- mode = kBlitOR;
- } else if (off || flag) {
+ if (off || flag) {
mode = kBlitXOR;
+ } else if (_engine->isObjSelected(child)) {
+ mode = kBlitOR;
}
children[i] = DrawableObject(child, mode);
}
diff --git a/engines/macventure/image.cpp b/engines/macventure/image.cpp
index 47b755a829..60f491cf55 100644
--- a/engines/macventure/image.cpp
+++ b/engines/macventure/image.cpp
@@ -332,8 +332,7 @@ void ImageAsset::blitInto(Graphics::ManagedSurface *target, uint32 x, uint32 y,
blitOR(target, x, y, _maskData);
break;
}
- }
- else if (_container->getItemByteSize(_id)) {
+ } else if (_container->getItemByteSize(_id)) {
switch (mode) {
case MacVenture::kBlitBIC:
target->fillRect(Common::Rect(x, y, x + _bitWidth, y + _bitHeight * 2), kColorWhite);
@@ -343,12 +342,24 @@ void ImageAsset::blitInto(Graphics::ManagedSurface *target, uint32 x, uint32 y,
break;
}
}
+
if (_container->getItemByteSize(_id) && mode > 0) {
blitXOR(target, x, y, _imgData);
}
}
void ImageAsset::blitDirect(Graphics::ManagedSurface * target, uint32 ox, uint32 oy, const Common::Array<byte>& data) {
+ if (_bitWidth == 0 || _bitHeight == 0) return;
+ uint w = _bitWidth;
+ uint h = _bitHeight;
+ uint sx = 0;
+ uint sy = 0;
+ if (ox<0) { sx = -ox; ox = 0; }
+ if (oy<0) { sy = -oy; oy = 0; }
+ if (w + ox >= target->w) w = target->w - ox;
+ if (h + oy >= target->h) h = target->h - oy;
+ if (w == 0 || h == 0) return;
+
for (uint y = 0;y < _bitHeight; y++) {
uint bmpofs = y * _rowBytes;
byte pix = 0;
@@ -361,10 +372,21 @@ void ImageAsset::blitDirect(Graphics::ManagedSurface * target, uint32 ox, uint32
}
void ImageAsset::blitBIC(Graphics::ManagedSurface * target, uint32 ox, uint32 oy, const Common::Array<byte> &data) {
- for (uint y = 0;y < _bitHeight; y++) {
+ if (_bitWidth == 0 || _bitHeight == 0) return;
+ uint w = _bitWidth;
+ uint h = _bitHeight;
+ uint sx = 0;
+ uint sy = 0;
+ if (ox<0) { sx = -ox; ox = 0; }
+ if (oy<0) { sy = -oy; oy = 0; }
+ if (w + ox >= target->w) w = target->w - ox;
+ if (h + oy >= target->h) h = target->h - oy;
+ if (w == 0 || h == 0) return;
+
+ for (uint y = 0;y < h; y++) {
uint bmpofs = y * _rowBytes;
byte pix = 0;
- for (uint x = 0; x < _bitWidth; x++) {
+ for (uint x = 0; x < w; x++) {
pix = data[bmpofs + (x >> 3)] & (1 << (7 - (x & 7)));
if (pix) *((byte *)target->getBasePtr(ox + x, oy + y)) = kColorWhite;
@@ -373,6 +395,17 @@ void ImageAsset::blitBIC(Graphics::ManagedSurface * target, uint32 ox, uint32 oy
}
void ImageAsset::blitOR(Graphics::ManagedSurface * target, uint32 ox, uint32 oy, const Common::Array<byte> &data) {
+ if (_bitWidth == 0 || _bitHeight == 0) return;
+ uint w = _bitWidth;
+ uint h = _bitHeight;
+ uint sx = 0;
+ uint sy = 0;
+ if (ox<0) { sx = -ox; ox = 0; }
+ if (oy<0) { sy = -oy; oy = 0; }
+ if (w + ox >= target->w) w = target->w - ox;
+ if (h + oy >= target->h) h = target->h - oy;
+ if (w == 0 || h == 0) return;
+
for (uint y = 0;y < _bitHeight; y++) {
uint bmpofs = y * _rowBytes;
byte pix = 0;
@@ -385,6 +418,17 @@ void ImageAsset::blitOR(Graphics::ManagedSurface * target, uint32 ox, uint32 oy,
}
void ImageAsset::blitXOR(Graphics::ManagedSurface * target, uint32 ox, uint32 oy, const Common::Array<byte> &data) {
+ if (_bitWidth == 0 || _bitHeight == 0) return;
+ uint w = _bitWidth;
+ uint h = _bitHeight;
+ uint sx = 0;
+ uint sy = 0;
+ if (ox<0) { sx = -ox; ox = 0; }
+ if (oy<0) { sy = -oy; oy = 0; }
+ if (w + ox >= target->w) w = target->w - ox;
+ if (h + oy >= target->h) h = target->h - oy;
+ if (w == 0 || h == 0) return;
+
for (uint y = 0;y < _bitHeight; y++) {
uint bmpofs = y * _rowBytes;
byte pix = 0;
@@ -393,9 +437,9 @@ void ImageAsset::blitXOR(Graphics::ManagedSurface * target, uint32 ox, uint32 oy
if (pix) { // We need to xor
byte p = *((byte *)target->getBasePtr(ox + x, oy + y));
- if (p == kColorWhite) p = kColorBlack;
- else p = kColorWhite;
- *((byte *)target->getBasePtr(ox + x, oy + y)) = p;
+
+ *((byte *)target->getBasePtr(ox + x, oy + y)) =
+ (p == kColorWhite) ? kColorBlack : kColorWhite;
}
}
}