diff options
Diffstat (limited to 'engines/xeen/window.cpp')
-rw-r--r-- | engines/xeen/window.cpp | 78 |
1 files changed, 34 insertions, 44 deletions
diff --git a/engines/xeen/window.cpp b/engines/xeen/window.cpp index d4a798bc4b..ef3fedeec2 100644 --- a/engines/xeen/window.cpp +++ b/engines/xeen/window.cpp @@ -92,11 +92,11 @@ void Windows::closeAll() { assert(_windowStack.size() == 0); } -void Windows::addToStack(Window *win) { +void Windows::windowOpened(Window *win) { _windowStack.push_back(win); } -void Windows::removeFromStack(Window *win) { +void Windows::windowClosed(Window *win) { for (uint i = 0; i < _windowStack.size(); ++i) { if (_windowStack[i] == win) { _windowStack.remove_at(i); @@ -134,36 +134,48 @@ void Window::setBounds(const Common::Rect &r) { } void Window::open() { + Screen &screen = *g_vm->_screen; + if (!_enabled) { + // 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(); + + _writePos.x = _bounds.right - 8; + writeSymbol(19); + + _writePos.x = _innerBounds.left; + _writePos.y = _innerBounds.top; + _fontJustify = JUSTIFY_NONE; + _fontReduced = false; _enabled = true; - g_vm->_windows->addToStack(this); - open2(); - } - if (g_vm->_mode == MODE_9) { - warning("TODO: copyFileToMemory"); + // Signal that the window has opened + g_vm->_windows->windowOpened(this); } } -void Window::open2() { +void Window::close() { Screen &screen = *g_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(); + if (_enabled) { + // Update the window + update(); - _writePos.x = _bounds.right - 8; - writeSymbol(19); + // Restore the saved original content + screen.copyRectToSurface(_savedArea, _bounds.left, _bounds.top, + Common::Rect(0, 0, _bounds.width(), _bounds.height())); + addDirtyRect(_bounds); - _writePos.x = _innerBounds.left; - _writePos.y = _innerBounds.top; - _fontJustify = JUSTIFY_NONE; - _fontReduced = false; + // Signal that the window has closed + g_vm->_windows->windowClosed(this); + _enabled = false; + } } void Window::frame() { @@ -220,28 +232,6 @@ void Window::frame() { writeSymbol(19); } -void Window::close() { - Screen &screen = *g_vm->_screen; - - if (_enabled) { - // 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 - g_vm->_windows->removeFromStack(this); - _enabled = false; - } - - if (g_vm->_mode == MODE_9) { - warning("TODO: copyFileToMemory"); - } -} - void Window::update() { // Since all window drawing is done on the screen surface anyway, // there's nothing that needs to be updated here |