[Scummvm-git-logs] scummvm master -> e8fb9920a9cf4ccb44620d992a093205ffd98c15

dreammaster dreammaster at scummvm.org
Mon Dec 4 02:08:26 CET 2017


This automated email contains information about 1 new commit which have been
pushed to the 'scummvm' repo located at https://github.com/scummvm/scummvm .

Summary:
e8fb9920a9 XEEN: Cleanup of window opening & closing


Commit: e8fb9920a9cf4ccb44620d992a093205ffd98c15
    https://github.com/scummvm/scummvm/commit/e8fb9920a9cf4ccb44620d992a093205ffd98c15
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2017-12-03T20:08:11-05:00

Commit Message:
XEEN: Cleanup of window opening & closing

Changed paths:
    engines/xeen/interface.cpp
    engines/xeen/party.cpp
    engines/xeen/scripts.cpp
    engines/xeen/window.cpp
    engines/xeen/window.h
    engines/xeen/xeen.h


diff --git a/engines/xeen/interface.cpp b/engines/xeen/interface.cpp
index 7db7e85..43e8592 100644
--- a/engines/xeen/interface.cpp
+++ b/engines/xeen/interface.cpp
@@ -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?
 	}
 
diff --git a/engines/xeen/party.cpp b/engines/xeen/party.cpp
index 732e9fa..ce30859 100644
--- a/engines/xeen/party.cpp
+++ b/engines/xeen/party.cpp
@@ -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);
diff --git a/engines/xeen/scripts.cpp b/engines/xeen/scripts.cpp
index 5c09f9f..37ddd1e 100644
--- a/engines/xeen/scripts.cpp
+++ b/engines/xeen/scripts.cpp
@@ -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;
diff --git a/engines/xeen/window.cpp b/engines/xeen/window.cpp
index d4a798b..ef3fede 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
diff --git a/engines/xeen/window.h b/engines/xeen/window.h
index cd9a1dd..0594a99 100644
--- a/engines/xeen/window.h
+++ b/engines/xeen/window.h
@@ -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:
diff --git a/engines/xeen/xeen.h b/engines/xeen/xeen.h
index 51845d7..cc187c9 100644
--- a/engines/xeen/xeen.h
+++ b/engines/xeen/xeen.h
@@ -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,





More information about the Scummvm-git-logs mailing list