[Scummvm-cvs-logs] scummvm master -> d31e602add7e5466754d4b651ce7f947f6effdda

dreammaster dreammaster at scummvm.org
Sat Feb 14 22:58:37 CET 2015


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:
d31e602add MADS: Allow Escape key to close game options dialog


Commit: d31e602add7e5466754d4b651ce7f947f6effdda
    https://github.com/scummvm/scummvm/commit/d31e602add7e5466754d4b651ce7f947f6effdda
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2015-02-14T16:54:47-05:00

Commit Message:
MADS: Allow Escape key to close game options dialog

Changed paths:
    engines/mads/events.cpp
    engines/mads/events.h
    engines/mads/game.cpp
    engines/mads/game.h
    engines/mads/nebular/dialogs_nebular.cpp
    engines/mads/scene.cpp



diff --git a/engines/mads/events.cpp b/engines/mads/events.cpp
index e7ec8b0..586ef7c 100644
--- a/engines/mads/events.cpp
+++ b/engines/mads/events.cpp
@@ -157,7 +157,7 @@ void EventsManager::pollEvents() {
 				_vm->_debugger->attach();
 				_vm->_debugger->onFrame();
 			} else {
-				_pendingKeys.push(event);
+				_pendingKeys.push(event.kbd);
 			}
 			return;
 		case Common::EVENT_KEYUP:
diff --git a/engines/mads/events.h b/engines/mads/events.h
index 870d6e0..21ef374 100644
--- a/engines/mads/events.h
+++ b/engines/mads/events.h
@@ -70,7 +70,7 @@ public:
 	int _vD2;
 	int _mouseStatusCopy;
 	bool _mouseMoved;
-	Common::Stack<Common::Event> _pendingKeys;
+	Common::Stack<Common::KeyState> _pendingKeys;
 public:
 	/**
 	 * Constructor
@@ -168,6 +168,8 @@ public:
 	 * Returns true if there's any pending keys to be processed
 	 */
 	bool isKeyPressed() const { return !_pendingKeys.empty(); }
+
+	Common::KeyState getKey() { return _pendingKeys.pop(); }
 };
 
 } // End of namespace MADS
diff --git a/engines/mads/game.cpp b/engines/mads/game.cpp
index 0ce24da..27691d3 100644
--- a/engines/mads/game.cpp
+++ b/engines/mads/game.cpp
@@ -403,12 +403,12 @@ Common::StringArray Game::getMessage(uint32 id) {
 
 static const char *const DEBUG_STRING = "WIDEPIPE";
 
-void Game::handleKeypress(const Common::Event &event) {
-	if (event.kbd.flags & Common::KBD_CTRL) {
+void Game::handleKeypress(const Common::KeyState &kbd) {
+	if (kbd.flags & Common::KBD_CTRL) {
 		if (_widepipeCtr == 8) {
 			// Implement original game cheating keys here someday
 		} else {
-			if (event.kbd.keycode == (Common::KEYCODE_a +
+			if (kbd.keycode == (Common::KEYCODE_a +
 					(DEBUG_STRING[_widepipeCtr] - 'a'))) {
 				if (++_widepipeCtr == 8) {
 					MessageDialog *dlg = new MessageDialog(_vm, 2,
@@ -420,7 +420,7 @@ void Game::handleKeypress(const Common::Event &event) {
 		}
 	}
 
-	switch (event.kbd.keycode) {
+	switch (kbd.keycode) {
 	case Common::KEYCODE_F1:
 		_vm->_dialogs->_pendingDialog = DIALOG_GAME_MENU;
 		break;
diff --git a/engines/mads/game.h b/engines/mads/game.h
index 1a61fc8..66f2580 100644
--- a/engines/mads/game.h
+++ b/engines/mads/game.h
@@ -204,7 +204,7 @@ public:
 	/**
 	* Handle a keyboard event
 	*/
-	void handleKeypress(const Common::Event &event);
+	void handleKeypress(const Common::KeyState &kbd);
 
 	/**
 	 * Starts a savegame loading.
diff --git a/engines/mads/nebular/dialogs_nebular.cpp b/engines/mads/nebular/dialogs_nebular.cpp
index 05c2e4b..be683d0 100644
--- a/engines/mads/nebular/dialogs_nebular.cpp
+++ b/engines/mads/nebular/dialogs_nebular.cpp
@@ -804,7 +804,7 @@ void GameDialog::show() {
 
 	Scene &scene = _vm->_game->_scene;
 
-	while (_selectedLine < 1 && !_vm->shouldQuit()) {
+	while (_selectedLine == -1 && !_vm->shouldQuit()) {
 		handleEvents();
 		if (_redrawFlag) {
 			if (!_tempLine)
@@ -831,7 +831,17 @@ void GameDialog::handleEvents() {
 		_lines[i]._state = DLGSTATE_UNSELECTED;
 
 	// Process pending events
-	_vm->_events->pollEvents();
+	events.pollEvents();
+
+	if (events.isKeyPressed()) {
+		switch (events.getKey().keycode) {
+		case Common::KEYCODE_ESCAPE:
+			_selectedLine = 0;
+			break;
+		default:
+			break;
+		}
+	}
 
 	// Scan for objects in the dialog
 	Common::Point mousePos = events.currentPos() - Common::Point(0, DIALOG_TOP);
@@ -1010,12 +1020,13 @@ void GameMenuDialog::show() {
 		_vm->_dialogs->_pendingDialog = DIALOG_OPTIONS;
 		_vm->_dialogs->showDialog();
 		break;
+	case 5:
+		_vm->quitGame();
+		break;
 	case 4:
+	default:
 		// Resume game
 		break;
-	case 5:
-	default:
-		_vm->quitGame();
 	}
 }
 
diff --git a/engines/mads/scene.cpp b/engines/mads/scene.cpp
index ea3fe2c..61db1a6 100644
--- a/engines/mads/scene.cpp
+++ b/engines/mads/scene.cpp
@@ -592,12 +592,14 @@ void Scene::doSceneStep() {
 }
 
 void Scene::checkKeyboard() {
-	if (_vm->_events->isKeyPressed()) {
-		Common::Event evt = _vm->_events->_pendingKeys.pop();
+	EventsManager &events = *_vm->_events;
+
+	if (events.isKeyPressed()) {
+		Common::KeyState evt = events.getKey();
 		_vm->_game->handleKeypress(evt);
 	}
 
-	if ((_vm->_events->_mouseStatus & 3) == 3 && _vm->_game->_player._stepEnabled) {
+	if ((events._mouseStatus & 3) == 3 && _vm->_game->_player._stepEnabled) {
 		_reloadSceneFlag = true;
 		_vm->_dialogs->_pendingDialog = DIALOG_GAME_MENU;
 		_action.clear();






More information about the Scummvm-git-logs mailing list