diff options
author | Joseph-Eugene Winzer | 2018-03-11 22:07:13 +0100 |
---|---|---|
committer | Joseph-Eugene Winzer | 2018-04-14 11:45:52 +0200 |
commit | ff5426c609a4affc0cd96cff38211f949c614989 (patch) | |
tree | 15fb6b5ce74926c5127b26ce083e56f8afaf08d4 /engines | |
parent | bb46e53667c017442bd456b3da384bbf82ca1347 (diff) | |
download | scummvm-rg350-ff5426c609a4affc0cd96cff38211f949c614989.tar.gz scummvm-rg350-ff5426c609a4affc0cd96cff38211f949c614989.tar.bz2 scummvm-rg350-ff5426c609a4affc0cd96cff38211f949c614989.zip |
SUPERNOVA: Moves updateEvents() to GameManager
updatEvents() depends on an initalized GameManager instance and mostly
manipulates its state. So it seemed fitting to move it over.
Diffstat (limited to 'engines')
-rw-r--r-- | engines/supernova/rooms.cpp | 4 | ||||
-rw-r--r-- | engines/supernova/state.cpp | 86 | ||||
-rw-r--r-- | engines/supernova/state.h | 1 | ||||
-rw-r--r-- | engines/supernova/supernova.cpp | 71 | ||||
-rw-r--r-- | engines/supernova/supernova.h | 1 |
5 files changed, 82 insertions, 81 deletions
diff --git a/engines/supernova/rooms.cpp b/engines/supernova/rooms.cpp index e6847d2a02..1899fcfd36 100644 --- a/engines/supernova/rooms.cpp +++ b/engines/supernova/rooms.cpp @@ -272,7 +272,7 @@ void Intro::titleScreen() { Marquee marquee(_vm, Marquee::kMarqueeIntro, _introText.c_str()); while (!_vm->shouldQuit()) { - _vm->updateEvents(); + _gm->updateEvents(); marquee.renderCharacter(); if (_gm->_mouseClicked || _gm->_keyPressed) break; @@ -3298,7 +3298,7 @@ void Outro::onEntrance() { _vm->playSoundMod(kMusicOutro); Marquee marquee(_vm, Marquee::kMarqueeOutro, _outroText.c_str()); while (!_vm->shouldQuit()) { - _vm->updateEvents(); + _gm->updateEvents(); marquee.renderCharacter(); if (_gm->_mouseClicked || _gm->_keyPressed) break; diff --git a/engines/supernova/state.cpp b/engines/supernova/state.cpp index e88b4596a8..23cb277240 100644 --- a/engines/supernova/state.cpp +++ b/engines/supernova/state.cpp @@ -503,6 +503,76 @@ void GameManager::initGui() { _guiInventoryArrow[1].setTextPosition(273, 186); } +void GameManager::updateEvents() { + handleTime(); + if (_animationEnabled && !_vm->_messageDisplayed && _animationTimer == 0) + _currentRoom->animation(); + + if (_state._eventCallback != kNoFn && _state._time >= _state._eventTime) { + _vm->_allowLoadGame = false; + _vm->_allowSaveGame = false; + _state._eventTime = kMaxTimerValue; + EventFunction fn = _state._eventCallback; + _state._eventCallback = kNoFn; + switch (fn) { + case kNoFn: + break; + case kSupernovaFn: + supernovaEvent(); + break; + case kGuardReturnedFn: + guardReturnedEvent(); + break; + case kGuardWalkFn: + guardWalkEvent(); + break; + case kTaxiFn: + taxiEvent(); + break; + case kSearchStartFn: + searchStartEvent(); + break; + } + _vm->_allowLoadGame = true; + _vm->_allowSaveGame = true; + return; + } + + if (_state._alarmOn && _state._timeAlarm <= _state._time) { + _state._alarmOn = false; + alarm(); + return; + } + + _mouseClicked = false; + _keyPressed = false; + Common::Event event; + while (g_system->getEventManager()->pollEvent(event)) { + switch (event.type) { + case Common::EVENT_KEYDOWN: + _keyPressed = true; + processInput(event.kbd); + break; + case Common::EVENT_LBUTTONUP: + // fallthrough + case Common::EVENT_RBUTTONUP: + if (_currentRoom->getId() != INTRO && + _vm->_mixer->isSoundHandleActive(_vm->_soundHandle)) + return; + _mouseClicked = true; + // fallthrough + case Common::EVENT_MOUSEMOVE: + _mouseClickType = event.type; + _mouseX = event.mouse.x; + _mouseY = event.mouse.y; + if (_guiEnabled) + processInput(); + break; + default: + break; + } + } +} void GameManager::processInput(Common::KeyState &state) { _key = state; @@ -1412,7 +1482,7 @@ int GameManager::dialog(int num, byte rowLength[6], StringID text[6], int number _currentSentence = -1; do { do { - _vm->updateEvents(); + updateEvents(); mousePosDialog(_mouseX, _mouseY); g_system->updateScreen(); g_system->delayMillis(_vm->_delay); @@ -1500,7 +1570,7 @@ void GameManager::drawInventory() { uint16 GameManager::getKeyInput(bool blockForPrintChar) { while (!_vm->shouldQuit()) { - _vm->updateEvents(); + updateEvents(); if (_keyPressed) { if (blockForPrintChar) { if (Common::isPrint(_key.keycode) || @@ -1530,7 +1600,7 @@ uint16 GameManager::getKeyInput(bool blockForPrintChar) { Common::EventType GameManager::getMouseInput() { while (!_vm->shouldQuit()) { - _vm->updateEvents(); + updateEvents(); if (_mouseClicked) return _mouseClickType; g_system->updateScreen(); @@ -1541,7 +1611,7 @@ Common::EventType GameManager::getMouseInput() { void GameManager::getInput() { while (!_vm->shouldQuit()) { - _vm->updateEvents(); + updateEvents(); if (_mouseClicked || _keyPressed) break; g_system->updateScreen(); @@ -1573,7 +1643,7 @@ void GameManager::wait(int ticks) { int32 end = _state._time + ticksToMsec(ticks); do { g_system->delayMillis(_vm->_delay); - _vm->updateEvents(); + updateEvents(); g_system->updateScreen(); } while (_state._time < end && !_vm->shouldQuit()); } @@ -1582,7 +1652,7 @@ void GameManager::waitOnInput(int ticks) { int32 end = _state._time + ticksToMsec(ticks); do { g_system->delayMillis(_vm->_delay); - _vm->updateEvents(); + updateEvents(); g_system->updateScreen(); } while (_state._time < end && !_vm->shouldQuit() && !_keyPressed && !_mouseClicked); } @@ -1592,7 +1662,7 @@ bool GameManager::waitOnInput(int ticks, Common::KeyCode &keycode) { int32 end = _state._time + ticksToMsec(ticks); do { g_system->delayMillis(_vm->_delay); - _vm->updateEvents(); + updateEvents(); g_system->updateScreen(); if (_keyPressed) { keycode = _key.keycode; @@ -2342,7 +2412,7 @@ void GameManager::alarmSound() { _vm->playSound(kAudioAlarm); while (_vm->_mixer->isSoundHandleActive(_vm->_soundHandle)) { g_system->delayMillis(_vm->_delay); - _vm->updateEvents(); + updateEvents(); g_system->updateScreen(); } } while (_state._time < end && !_vm->shouldQuit()); diff --git a/engines/supernova/state.h b/engines/supernova/state.h index f617bc0355..774bcc67e9 100644 --- a/engines/supernova/state.h +++ b/engines/supernova/state.h @@ -124,6 +124,7 @@ public: GameManager(SupernovaEngine *vm); ~GameManager(); + void updateEvents(); void processInput(Common::KeyState &state); void processInput(); void executeRoom(); diff --git a/engines/supernova/supernova.cpp b/engines/supernova/supernova.cpp index c9f6abab7a..c3e4223947 100644 --- a/engines/supernova/supernova.cpp +++ b/engines/supernova/supernova.cpp @@ -165,7 +165,7 @@ Common::Error SupernovaEngine::run() { while (!shouldQuit()) { uint32 start = _system->getMillis(); - updateEvents(); + _gm->updateEvents(); _gm->executeRoom(); _console->onFrame(); _system->updateScreen(); @@ -179,75 +179,6 @@ Common::Error SupernovaEngine::run() { return Common::kNoError; } -void SupernovaEngine::updateEvents() { - _gm->handleTime(); - if (_gm->_animationEnabled && !_messageDisplayed && _gm->_animationTimer == 0) - _gm->_currentRoom->animation(); - - if (_gm->_state._eventCallback != kNoFn && _gm->_state._time >= _gm->_state._eventTime) { - _allowLoadGame = false; - _allowSaveGame = false; - _gm->_state._eventTime = kMaxTimerValue; - EventFunction fn = _gm->_state._eventCallback; - _gm->_state._eventCallback = kNoFn; - switch (fn) { - case kNoFn: - break; - case kSupernovaFn: - _gm->supernovaEvent(); - break; - case kGuardReturnedFn: - _gm->guardReturnedEvent(); - break; - case kGuardWalkFn: - _gm->guardWalkEvent(); - break; - case kTaxiFn: - _gm->taxiEvent(); - break; - case kSearchStartFn: - _gm->searchStartEvent(); - break; - } - _allowLoadGame = true; - _allowSaveGame = true; - return; - } - - if (_gm->_state._alarmOn && _gm->_state._timeAlarm <= _gm->_state._time) { - _gm->_state._alarmOn = false; - _gm->alarm(); - return; - } - - _gm->_mouseClicked = false; - _gm->_keyPressed = false; - Common::Event event; - while (g_system->getEventManager()->pollEvent(event)) { - switch (event.type) { - case Common::EVENT_KEYDOWN: - _gm->_keyPressed = true; - _gm->processInput(event.kbd); - break; - case Common::EVENT_LBUTTONUP: - // fallthrough - case Common::EVENT_RBUTTONUP: - if (_gm->_currentRoom->getId() != INTRO && _mixer->isSoundHandleActive(_soundHandle)) - return; - _gm->_mouseClicked = true; - // fallthrough - case Common::EVENT_MOUSEMOVE: - _gm->_mouseClickType = event.type; - _gm->_mouseX = event.mouse.x; - _gm->_mouseY = event.mouse.y; - if (_gm->_guiEnabled) - _gm->processInput(); - break; - default: - break; - } - } -} bool SupernovaEngine::hasFeature(EngineFeature f) const { switch (f) { diff --git a/engines/supernova/supernova.h b/engines/supernova/supernova.h index e01fb778a5..2a71a111ae 100644 --- a/engines/supernova/supernova.h +++ b/engines/supernova/supernova.h @@ -133,7 +133,6 @@ public: void paletteFadeIn(); void paletteFadeOut(); void paletteBrightness(); - void updateEvents(); void playSound(AudioIndex sample); void playSoundMod(int filenumber); void stopSound(); |