mirror of
https://github.com/libretro/scummvm.git
synced 2025-01-31 16:03:24 +00:00
Moved mask creation/handling to Gfx.
svn-id: r35447
This commit is contained in:
parent
a6e4bd793f
commit
025b2a93e9
@ -32,7 +32,10 @@
|
||||
|
||||
namespace Parallaction {
|
||||
|
||||
GfxObj::GfxObj(uint objType, Frames *frames, const char* name) : _frames(frames), _keep(true), x(0), y(0), z(0), _flags(kGfxObjNormal), type(objType), frame(0), layer(3), scale(100) {
|
||||
GfxObj::GfxObj(uint objType, Frames *frames, const char* name) :
|
||||
_frames(frames), _keep(true), x(0), y(0), z(0), _flags(kGfxObjNormal),
|
||||
type(objType), frame(0), layer(3), scale(100), _hasMask(false) {
|
||||
|
||||
if (name) {
|
||||
_name = strdup(name);
|
||||
} else {
|
||||
@ -43,6 +46,7 @@ GfxObj::GfxObj(uint objType, Frames *frames, const char* name) : _frames(frames)
|
||||
GfxObj::~GfxObj() {
|
||||
delete _frames;
|
||||
free(_name);
|
||||
_mask.free();
|
||||
}
|
||||
|
||||
void GfxObj::release() {
|
||||
@ -136,6 +140,14 @@ void Gfx::clearGfxObjects(uint filter) {
|
||||
|
||||
}
|
||||
|
||||
void Gfx::loadGfxObjMask(const char *name, GfxObj *obj) {
|
||||
Common::Rect rect;
|
||||
obj->getRect(0, rect);
|
||||
obj->_mask.create(rect.width(), rect.height());
|
||||
_vm->_disk->loadMask(_tokens[1], obj->_mask);
|
||||
obj->_hasMask = true;
|
||||
}
|
||||
|
||||
void Gfx::showGfxObj(GfxObj* obj, bool visible) {
|
||||
if (!obj) {
|
||||
return;
|
||||
@ -146,6 +158,14 @@ void Gfx::showGfxObj(GfxObj* obj, bool visible) {
|
||||
} else {
|
||||
obj->clearFlags(kGfxObjVisible);
|
||||
}
|
||||
|
||||
if (obj->_hasMask && _backgroundInfo->hasMask) {
|
||||
if (visible) {
|
||||
_backgroundInfo->mask.bltOr(obj->x, obj->y, obj->_mask, 0, 0, obj->_mask.w, obj->_mask.h);
|
||||
} else {
|
||||
_backgroundInfo->mask.bltCopy(obj->x, obj->y, _backgroundInfo->maskBackup, obj->x, obj->y, obj->_mask.w, obj->_mask.h);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
@ -803,6 +803,10 @@ void Gfx::setBackground(uint type, BackgroundInfo *info) {
|
||||
setPalette(_backgroundInfo->palette);
|
||||
}
|
||||
|
||||
if (_backgroundInfo->hasMask) {
|
||||
_backgroundInfo->maskBackup.clone(_backgroundInfo->mask);
|
||||
}
|
||||
|
||||
if (_gameType == GType_BRA) {
|
||||
int width = CLIP(info->width, (int)_vm->_screenWidth, info->width);
|
||||
int height = CLIP(info->height, (int)_vm->_screenHeight, info->height);
|
||||
|
@ -140,6 +140,15 @@ public:
|
||||
MaskBuffer() : w(0), internalWidth(0), h(0), size(0), data(0), bigEndian(true) {
|
||||
}
|
||||
|
||||
void clone(const MaskBuffer &buf) {
|
||||
if (!buf.data)
|
||||
return;
|
||||
|
||||
create(buf.w, buf.h);
|
||||
bigEndian = buf.bigEndian;
|
||||
memcpy(data, buf.data, size);
|
||||
}
|
||||
|
||||
void create(uint16 width, uint16 height) {
|
||||
free();
|
||||
|
||||
@ -378,6 +387,10 @@ public:
|
||||
uint transparentKey;
|
||||
uint scale;
|
||||
|
||||
MaskBuffer _mask;
|
||||
bool _hasMask;
|
||||
|
||||
|
||||
GfxObj(uint type, Frames *frames, const char *name = NULL);
|
||||
virtual ~GfxObj();
|
||||
|
||||
@ -413,6 +426,7 @@ struct BackgroundInfo {
|
||||
|
||||
Graphics::Surface bg;
|
||||
MaskBuffer mask;
|
||||
MaskBuffer maskBackup;
|
||||
PathBuffer path;
|
||||
|
||||
Palette palette;
|
||||
@ -442,6 +456,7 @@ struct BackgroundInfo {
|
||||
~BackgroundInfo() {
|
||||
bg.free();
|
||||
mask.free();
|
||||
maskBackup.free();
|
||||
path.free();
|
||||
x = 0;
|
||||
y = 0;
|
||||
@ -607,6 +622,8 @@ public:
|
||||
void bltMaskScale(const Common::Rect& r, byte *data, Graphics::Surface *surf, uint16 z, uint scale, byte transparentColor);
|
||||
void bltMaskNoScale(const Common::Rect& r, byte *data, Graphics::Surface *surf, uint16 z, byte transparentColor);
|
||||
void bltNoMaskNoScale(const Common::Rect& r, byte *data, Graphics::Surface *surf, byte transparentColor);
|
||||
|
||||
void loadGfxObjMask(const char *name, GfxObj *obj);
|
||||
};
|
||||
|
||||
|
||||
|
@ -193,13 +193,10 @@ struct Dialogue {
|
||||
struct GetData {
|
||||
uint32 _icon;
|
||||
GfxObj *gfxobj;
|
||||
MaskBuffer _mask[2];
|
||||
bool hasMask;
|
||||
|
||||
GetData() {
|
||||
_icon = 0;
|
||||
gfxobj = NULL;
|
||||
hasMask = false;
|
||||
}
|
||||
};
|
||||
struct SpeakData {
|
||||
|
@ -521,15 +521,6 @@ void Parallaction::showZone(ZonePtr z, bool visible) {
|
||||
|
||||
if ((z->_type & 0xFFFF) == kZoneGet) {
|
||||
_gfx->showGfxObj(z->u.get->gfxobj, visible);
|
||||
|
||||
GetData *data = z->u.get;
|
||||
if (data->hasMask && _gfx->_backgroundInfo->hasMask) {
|
||||
if (visible) {
|
||||
_gfx->_backgroundInfo->mask.bltOr(data->gfxobj->x, data->gfxobj->y, data->_mask[0], 0, 0, data->_mask->w, data->_mask->h);
|
||||
} else {
|
||||
_gfx->_backgroundInfo->mask.bltCopy(data->gfxobj->x, data->gfxobj->y, data->_mask[1], 0, 0, data->_mask->w, data->_mask->h);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -788,13 +788,7 @@ void LocationParser_br::parseGetData(ZonePtr z) {
|
||||
|
||||
if (!scumm_stricmp(_tokens[0], "mask")) {
|
||||
if (ctxt.info->hasMask) {
|
||||
Common::Rect rect;
|
||||
data->gfxobj->getRect(0, rect);
|
||||
data->_mask[0].create(rect.width(), rect.height());
|
||||
_vm->_disk->loadMask(_tokens[1], data->_mask[0]);
|
||||
data->_mask[1].create(rect.width(), rect.height());
|
||||
data->_mask[1].bltCopy(0, 0, ctxt.info->mask, data->gfxobj->x, data->gfxobj->y, data->_mask->w, data->_mask->h);
|
||||
data->hasMask = true;
|
||||
_vm->_gfx->loadGfxObjMask(_tokens[1], data->gfxobj);
|
||||
} else {
|
||||
warning("Mask for zone '%s' ignored, since background doesn't have one", z->_name);
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user