Permalink
Browse files

XEEN: Cleanup of window opening & closing

  • Loading branch information...
dreammaster committed Dec 4, 2017
1 parent 20fb25d commit e8fb9920a9cf4ccb44620d992a093205ffd98c15
Showing with 49 additions and 62 deletions.
  1. +1 −1 engines/xeen/interface.cpp
  2. +2 −2 engines/xeen/party.cpp
  3. +1 −1 engines/xeen/scripts.cpp
  4. +34 −44 engines/xeen/window.cpp
  5. +10 −13 engines/xeen/window.h
  6. +1 −1 engines/xeen/xeen.h
@@ -1298,7 +1298,7 @@ void Interface::draw3d(bool updateFlag, bool skipDelay) {
}
party._stepped = false;
if (_vm->_mode == MODE_9) {
if (_vm->_mode == MODE_RECORD_EVENTS) {
// TODO: Save current scripts data?
}
View
@@ -405,7 +405,7 @@ void Party::addTime(int numMinutes) {
_newDay = true;
if (_newDay && _minutes >= 300) {
if (_vm->_mode != MODE_9 && _vm->_mode != MODE_17) {
if (_vm->_mode != MODE_RECORD_EVENTS && _vm->_mode != MODE_17) {
resetTemps();
if (_rested || _vm->_mode == MODE_SLEEPING) {
_rested = false;
@@ -579,7 +579,7 @@ void Party::giveTreasure() {
for (int idx = 0; idx < 26 && !monstersPresent; ++idx)
monstersPresent = combat._attackMonsters[idx] != -1;
if (_vm->_mode != MODE_9 && monstersPresent)
if (_vm->_mode != MODE_RECORD_EVENTS && monstersPresent)
return;
Common::fill(&combat._shooting[0], &combat._shooting[MAX_PARTY_COUNT], 0);
View
@@ -188,7 +188,7 @@ int Scripts::checkEvents() {
if (event._position == _currentPos && party._mazeDirection !=
(_currentPos.x | _currentPos.y) && event._line == _lineNum) {
if (event._direction == party._mazeDirection || event._direction == DIR_ALL) {
_vm->_mode = MODE_9;
_vm->_mode = MODE_RECORD_EVENTS;
_scriptExecuted = true;
doOpcode(event);
break;
View
@@ -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
View
@@ -49,20 +49,9 @@ struct DrawStruct {
};
class Windows : public FontData {
friend class Window;
private:
Common::Array<Window> _windows;
Common::Array<Window *> _windowStack;
private:
/**
* Adds a window to the stack of currently open ones
*/
void addToStack(Window *win);
/**
* Removes a window from the currently active stack
*/
void removeFromStack(Window *win);
public:
Windows();
~Windows();
@@ -76,6 +65,16 @@ class Windows : public FontData {
* Close all currently open windows
*/
void closeAll();
/**
* Called when a window has been opened
*/
void windowOpened(Window *win);
/**
* Called when a window has been closed
*/
void windowClosed(Window *win);
};
class Window: public FontSurface {
@@ -87,8 +86,6 @@ class Window: public FontSurface {
int _border;
int _xLo, _xHi;
int _ycL, _ycH;
void open2();
public:
bool _enabled;
public:
View
@@ -86,7 +86,7 @@ enum Mode {
MODE_6 = 6,
MODE_7 = 7,
MODE_8 = 8,
MODE_9 = 9,
MODE_RECORD_EVENTS = 9,
MODE_CHARACTER_INFO = 10,
MODE_12 = 12,
MODE_DIALOG_123 = 13,

0 comments on commit e8fb992

Please sign in to comment.