From 1f28332b2053f2dbbe138937f9b0e342774a4cc9 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Wed, 28 Jan 2015 20:59:01 -0500 Subject: XEEN: Add saving/restoring of background when opening/closing windows --- engines/xeen/screen.cpp | 18 +++++++++++++++--- engines/xeen/screen.h | 1 + 2 files changed, 16 insertions(+), 3 deletions(-) (limited to 'engines/xeen') diff --git a/engines/xeen/screen.cpp b/engines/xeen/screen.cpp index e979143ed5..9c9783ba4c 100644 --- a/engines/xeen/screen.cpp +++ b/engines/xeen/screen.cpp @@ -60,11 +60,17 @@ void Window::open() { } void Window::open2() { + Screen &screen = *_vm->_screen; + + // Save a copy of the area under the window + _savedArea.create(_bounds.width(), _bounds.height()); + _savedArea.copyRectToSurface(screen, 0, 0, _bounds); + + // Mark the area as dirty and fill it with a default background addDirtyRect(_bounds); frame(); fill(); - Screen &screen = *_vm->_screen; screen._writePos.x = _bounds.right - 8; screen.writeSymbol(19); @@ -130,11 +136,17 @@ void Window::frame() { } void Window::close() { + Screen &screen = *_vm->_screen; + if (_enabled) { - // Update any remaining pending changes to the screen and free - // the window's internal surface storage + // Update the window update(); + // Restore the saved original content + screen.copyRectToSurface(_savedArea, _bounds.left, _bounds.top, + Common::Rect(0, 0, _bounds.width(), _bounds.height())); + addDirtyRect(_bounds); + // Remove the window from the stack and flag it as now disabled for (uint i = 0; i < _vm->_screen->_windowStack.size(); ++i) { if (_vm->_screen->_windowStack[i] == this) diff --git a/engines/xeen/screen.h b/engines/xeen/screen.h index 85affe3aa2..e3ced06236 100644 --- a/engines/xeen/screen.h +++ b/engines/xeen/screen.h @@ -61,6 +61,7 @@ private: XeenEngine *_vm; Common::Rect _bounds; Common::Rect _innerBounds; + XSurface _savedArea; int _a; int _border; int _xLo, _xHi; -- cgit v1.2.3