diff options
author | Jaromir Wysoglad | 2019-07-15 09:20:47 +0200 |
---|---|---|
committer | Thierry Crozat | 2019-07-28 15:09:14 +0100 |
commit | c2177f84539472defe31c6fba80ad4a6f3357266 (patch) | |
tree | 8b586c50ec2c69119d68b58ee4e36adbcb261ec3 /engines/supernova/game-manager.cpp | |
parent | 448db9f4321f5854385e1726284d2ba35c76866f (diff) | |
download | scummvm-rg350-c2177f84539472defe31c6fba80ad4a6f3357266.tar.gz scummvm-rg350-c2177f84539472defe31c6fba80ad4a6f3357266.tar.bz2 scummvm-rg350-c2177f84539472defe31c6fba80ad4a6f3357266.zip |
SUPERNOVA: Merge getInput and waitOnInput methods.
Diffstat (limited to 'engines/supernova/game-manager.cpp')
-rw-r--r-- | engines/supernova/game-manager.cpp | 51 |
1 files changed, 11 insertions, 40 deletions
diff --git a/engines/supernova/game-manager.cpp b/engines/supernova/game-manager.cpp index cb4d81be65..bf4cbc69c8 100644 --- a/engines/supernova/game-manager.cpp +++ b/engines/supernova/game-manager.cpp @@ -591,7 +591,7 @@ void GameManager::say(const char *text) { _vm->renderBox(0, 141, 320, numRows * 10 - 1, kColorWhite25); for (uint r = 0; r < numRows; ++r) _vm->renderText(row[r], 1, 142 + r * 10, kColorDarkGreen); - waitOnInput((t.size() + 20) * _vm->_textSpeed / 10); + wait((t.size() + 20) * _vm->_textSpeed / 10, true); _vm->renderBox(0, 138, 320, 62, kColorBlack); } @@ -608,12 +608,12 @@ void GameManager::reply(const char *text, int aus1, int aus2) { for (int z = (strlen(text) + 20) * _vm->_textSpeed / 40; z > 0; --z) { if (aus1) _vm->renderImage(aus1); - waitOnInput(2); + wait(2, true); if (_keyPressed || _mouseClicked) z = 1; if (aus2) _vm->renderImage(aus2); - waitOnInput(2); + wait(2, true); if (_keyPressed || _mouseClicked) z = 1; } @@ -718,33 +718,10 @@ void GameManager::drawInventory() { } } -int GameManager::getKeyInput() { +void GameManager::getInput(bool onlyKeys) { while (!_vm->shouldQuit()) { updateEvents(); - if (_keyPressed) { - return _key.ascii; - } - g_system->updateScreen(); - g_system->delayMillis(_vm->_delay); - } - return 0; -} - -Common::EventType GameManager::getMouseInput() { - while (!_vm->shouldQuit()) { - updateEvents(); - if (_mouseClicked) - return _mouseClickType; - g_system->updateScreen(); - g_system->delayMillis(_vm->_delay); - } - return Common::EVENT_INVALID; -} - -void GameManager::getInput() { - while (!_vm->shouldQuit()) { - updateEvents(); - if (_mouseClicked || _keyPressed) + if ((_mouseClicked && !onlyKeys) || _keyPressed) break; g_system->updateScreen(); g_system->delayMillis(_vm->_delay); @@ -768,22 +745,16 @@ void GameManager::changeRoom(RoomId id) { } } -void GameManager::wait(int ticks) { - int32 end = _time + ticksToMsec(ticks); - do { - g_system->delayMillis(_vm->_delay); - updateEvents(); - g_system->updateScreen(); - } while (_time < end && !_vm->shouldQuit()); -} - -void GameManager::waitOnInput(int ticks) { +void GameManager::wait(int ticks, bool checkInput) { int32 end = _time + ticksToMsec(ticks); + bool inputEvent = false; do { g_system->delayMillis(_vm->_delay); updateEvents(); g_system->updateScreen(); - } while (_time < end && !_vm->shouldQuit() && !_keyPressed && !_mouseClicked); + if (checkInput) + inputEvent = _keyPressed || _mouseClicked; + } while (_time < end && !_vm->shouldQuit() && !inputEvent); } bool GameManager::waitOnInput(int ticks, Common::KeyCode &keycode) { @@ -897,7 +868,7 @@ void GameManager::edit(Common::String &input, int x, int y, uint length) { _vm->renderBox(_vm->_screen->getTextCursorPos().x, y - 1, 1, 9, kColorWhite99); } - getKeyInput(); + getInput(true); if (_vm->shouldQuit()) break; switch (_key.keycode) { |