aboutsummaryrefslogtreecommitdiff
path: root/engines
diff options
context:
space:
mode:
authorPaul Gilbert2015-02-14 16:54:47 -0500
committerPaul Gilbert2015-02-14 16:54:47 -0500
commitd31e602add7e5466754d4b651ce7f947f6effdda (patch)
tree4499c99675bdcf4a99411adf0731c9075ccc0704 /engines
parent1aa9181466d1916824abb7301ea3e67781d08183 (diff)
downloadscummvm-rg350-d31e602add7e5466754d4b651ce7f947f6effdda.tar.gz
scummvm-rg350-d31e602add7e5466754d4b651ce7f947f6effdda.tar.bz2
scummvm-rg350-d31e602add7e5466754d4b651ce7f947f6effdda.zip
MADS: Allow Escape key to close game options dialog
Diffstat (limited to 'engines')
-rw-r--r--engines/mads/events.cpp2
-rw-r--r--engines/mads/events.h4
-rw-r--r--engines/mads/game.cpp8
-rw-r--r--engines/mads/game.h2
-rw-r--r--engines/mads/nebular/dialogs_nebular.cpp21
-rw-r--r--engines/mads/scene.cpp8
6 files changed, 30 insertions, 15 deletions
diff --git a/engines/mads/events.cpp b/engines/mads/events.cpp
index e7ec8b0821..586ef7cbf3 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 870d6e03b8..21ef37407b 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 0ce24daf7a..27691d3380 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 1a61fc8ac8..66f2580249 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 05c2e4ba96..be683d0b51 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 ea3fe2c148..61db1a6a32 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();