aboutsummaryrefslogtreecommitdiff
path: root/engines/supernova/state.cpp
diff options
context:
space:
mode:
authorJoseph-Eugene Winzer2018-03-11 22:07:13 +0100
committerJoseph-Eugene Winzer2018-04-14 11:45:52 +0200
commitff5426c609a4affc0cd96cff38211f949c614989 (patch)
tree15fb6b5ce74926c5127b26ce083e56f8afaf08d4 /engines/supernova/state.cpp
parentbb46e53667c017442bd456b3da384bbf82ca1347 (diff)
downloadscummvm-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/supernova/state.cpp')
-rw-r--r--engines/supernova/state.cpp86
1 files changed, 78 insertions, 8 deletions
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());