XEEN: Restrict drawing in windows to drawing within their bounds

This commit is contained in:
Paul Gilbert 2015-01-24 15:14:57 -05:00
parent 177f47a535
commit 339dfcb2cc
3 changed files with 8 additions and 12 deletions

View File

@ -38,7 +38,7 @@ Window::Window(XeenEngine *vm, const Common::Rect &bounds, int a, int border,
_vm(vm), _enabled(false), _a(a), _border(border),
_xLo(xLo), _ycL(ycL), _xHi(xHi), _ycH(ycH) {
setBounds(bounds);
create(_vm->_screen, Common::Rect(0, 0, SCREEN_WIDTH, SCREEN_HEIGHT));
create(_vm->_screen, bounds);
}
void Window::setBounds(const Common::Rect &r) {
@ -167,17 +167,12 @@ void Window::writeString(const Common::String &s) {
}
void Window::drawList(DrawStruct *items, int count) {
Screen &screen = *_vm->_screen;
for (int i = 0; i < count; ++i, ++items) {
if (items->_frame == -1 || items->_scale == -1 || items->_sprites == nullptr)
continue;
Common::Rect bounds = _innerBounds;
bounds.translate(items->_x, items->_y);
// TODO: There are two sprite calls in this method. Figure out why
items->_sprites->draw(screen, items->_frame,
items->_sprites->draw(*this, items->_frame,
Common::Point(items->_x, items->_y), items->_flags, items->_scale);
}
}

View File

@ -104,9 +104,10 @@ void SpriteResource::drawOffset(XSurface &dest, uint16 offset, const Common::Poi
bool flipped = (flags & SPRFLAG_HORIZ_FLIPPED) != 0;
int xInc = flipped ? -1 : 1;
if (dest.w < (xOffset + width) || dest.h < (yOffset + height))
dest.create(xOffset + width, yOffset + height);
if (flags & SPRFLAG_RESIZE) {
if (dest.w < (xOffset + width) || dest.h < (yOffset + height))
dest.create(xOffset + width, yOffset + height);
}
// The pattern steps used in the pattern command
const int patternSteps[] = { 0, 1, 1, 1, 2, 2, 3, 3, 0, -1, -1, -1, -2, -2, -3, -3 };

View File

@ -34,7 +34,7 @@ namespace Xeen {
class XeenEngine;
enum SpriteFlags { SPRFLAG_2000 = 0x2000, SPRFLAG_4000 = 0x4000,
SPRFLAG_HORIZ_FLIPPED = 0x8000 };
SPRFLAG_HORIZ_FLIPPED = 0x8000, SPRFLAG_RESIZE = 0x10000 };
class SpriteResource {
private: