mirror of
https://github.com/libretro/scummvm.git
synced 2025-02-22 12:12:16 +00:00
XEEN: Cleanup of window opening & closing
This commit is contained in:
parent
20fb25d58a
commit
e8fb9920a9
@ -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?
|
||||
}
|
||||
|
||||
|
@ -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);
|
||||
|
@ -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;
|
||||
|
@ -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() {
|
||||
if (!_enabled) {
|
||||
_enabled = true;
|
||||
g_vm->_windows->addToStack(this);
|
||||
open2();
|
||||
}
|
||||
Screen &screen = *g_vm->_screen;
|
||||
|
||||
if (g_vm->_mode == MODE_9) {
|
||||
warning("TODO: copyFileToMemory");
|
||||
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;
|
||||
|
||||
// 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);
|
||||
if (_enabled) {
|
||||
// Update the window
|
||||
update();
|
||||
|
||||
// Mark the area as dirty and fill it with a default background
|
||||
addDirtyRect(_bounds);
|
||||
frame();
|
||||
fill();
|
||||
// Restore the saved original content
|
||||
screen.copyRectToSurface(_savedArea, _bounds.left, _bounds.top,
|
||||
Common::Rect(0, 0, _bounds.width(), _bounds.height()));
|
||||
addDirtyRect(_bounds);
|
||||
|
||||
_writePos.x = _bounds.right - 8;
|
||||
writeSymbol(19);
|
||||
|
||||
_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
|
||||
|
@ -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 @@ public:
|
||||
* 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 @@ private:
|
||||
int _border;
|
||||
int _xLo, _xHi;
|
||||
int _ycL, _ycH;
|
||||
|
||||
void open2();
|
||||
public:
|
||||
bool _enabled;
|
||||
public:
|
||||
|
@ -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,
|
||||
|
Loading…
x
Reference in New Issue
Block a user