From 2f242a10daee5d95510c43f686f83e3bfb9e3f50 Mon Sep 17 00:00:00 2001 From: Peter Kohaut Date: Sat, 15 Dec 2018 22:40:07 +0100 Subject: BLADERUNNER: Added time control and game pausing --- engines/bladerunner/actor.cpp | 11 ++++++----- engines/bladerunner/actor_dialogue_queue.cpp | 5 +++-- engines/bladerunner/ambient_sounds.cpp | 7 ++++--- engines/bladerunner/bladerunner.cpp | 10 +++++----- engines/bladerunner/bladerunner.h | 2 +- engines/bladerunner/item_pickup.cpp | 4 ++-- engines/bladerunner/mouse.cpp | 3 ++- engines/bladerunner/script/police_maze.cpp | 5 +++-- engines/bladerunner/script/script.cpp | 5 +++-- engines/bladerunner/time.cpp | 2 +- engines/bladerunner/time.h | 2 +- engines/bladerunner/ui/elevator.cpp | 9 +++++---- engines/bladerunner/ui/end_credits.cpp | 6 +++--- engines/bladerunner/ui/esper.cpp | 29 +++++++++++++++------------- engines/bladerunner/ui/kia.cpp | 5 +++-- engines/bladerunner/ui/kia_section_load.cpp | 4 ++-- engines/bladerunner/ui/kia_section_save.cpp | 4 ++-- engines/bladerunner/ui/scores.cpp | 3 ++- engines/bladerunner/ui/ui_check_box.cpp | 4 ++-- engines/bladerunner/ui/ui_image_picker.cpp | 10 ++++++++-- engines/bladerunner/ui/ui_image_picker.h | 2 +- engines/bladerunner/ui/ui_input_box.cpp | 4 ++-- engines/bladerunner/ui/ui_scroll_box.cpp | 12 ++++++------ engines/bladerunner/ui/vk.cpp | 17 ++++++++-------- 24 files changed, 92 insertions(+), 73 deletions(-) diff --git a/engines/bladerunner/actor.cpp b/engines/bladerunner/actor.cpp index 26a7a80d6e..45d6d08277 100644 --- a/engines/bladerunner/actor.cpp +++ b/engines/bladerunner/actor.cpp @@ -40,6 +40,7 @@ #include "bladerunner/set.h" #include "bladerunner/slice_animations.h" #include "bladerunner/slice_renderer.h" +#include "bladerunner/time.h" #include "bladerunner/waypoints.h" #include "bladerunner/zbuffer.h" @@ -104,7 +105,7 @@ void Actor::setup(int actorId) { for (int i = 0; i != 7; ++i) { _timersLeft[i] = 0; - _timersLast[i] = _vm->getTotalPlayTime(); + _timersLast[i] = _vm->_time->current(); } _honesty = 50; @@ -174,7 +175,7 @@ void Actor::increaseFPS() { void Actor::timerStart(int timerId, int interval) { assert(timerId >= 0 && timerId < 7); _timersLeft[timerId] = interval; - _timersLast[timerId] = _vm->getTotalPlayTime(); + _timersLast[timerId] = _vm->_time->current(); } void Actor::timerReset(int timerId) { @@ -198,7 +199,7 @@ void Actor::timerUpdate(int timerId) { return; } - uint32 timeNow = _vm->getTotalPlayTime(); + uint32 timeNow = _vm->_time->current(); int timeDiff = timeNow - _timersLast[timerId]; _timersLast[timerId] = timeNow; _timersLeft[timerId] -= timeDiff; @@ -1307,7 +1308,7 @@ void Actor::save(SaveFileWriteStream &f) { f.writeInt(_timersLeft[i]); } - uint32 now = _vm->getTotalPlayTime(); // TODO: should be last lock time + uint32 now = _vm->_time->getPauseStart(); for (int i = 0; i < 7; ++i) { f.writeInt(now - _timersLast[i]); } @@ -1386,7 +1387,7 @@ void Actor::load(SaveFileReadStream &f) { _timersLeft[i] = f.readInt(); } - uint32 now = _vm->getTotalPlayTime(); // TODO: should be last lock time + uint32 now = _vm->_time->getPauseStart(); for (int i = 0; i < 7; ++i) { _timersLast[i] = now - f.readInt(); } diff --git a/engines/bladerunner/actor_dialogue_queue.cpp b/engines/bladerunner/actor_dialogue_queue.cpp index 320dd53478..479e399d9c 100644 --- a/engines/bladerunner/actor_dialogue_queue.cpp +++ b/engines/bladerunner/actor_dialogue_queue.cpp @@ -28,6 +28,7 @@ #include "bladerunner/audio_speech.h" #include "bladerunner/savefile.h" #include "bladerunner/scene.h" +#include "bladerunner/time.h" #include "bladerunner/script/scene_script.h" @@ -107,7 +108,7 @@ void ActorDialogueQueue::flush(int a1, bool callScript) { void ActorDialogueQueue::tick() { if (!_vm->_audioSpeech->isPlaying()) { if (_isPause) { - int time = _vm->getTotalPlayTime(); + int time = _vm->_time->current(); int timeDiff = time - _timeLast; _timeLast = time; _delay -= timeDiff; @@ -154,7 +155,7 @@ void ActorDialogueQueue::tick() { } else if (firstEntry.isPause) { _isPause = true; _delay = firstEntry.delay; - _timeLast = _vm->getTotalPlayTime(); + _timeLast = _vm->_time->current(); } } } diff --git a/engines/bladerunner/ambient_sounds.cpp b/engines/bladerunner/ambient_sounds.cpp index a9cd82fe2e..c21f8d8b84 100644 --- a/engines/bladerunner/ambient_sounds.cpp +++ b/engines/bladerunner/ambient_sounds.cpp @@ -26,6 +26,7 @@ #include "bladerunner/bladerunner.h" #include "bladerunner/game_info.h" #include "bladerunner/savefile.h" +#include "bladerunner/time.h" #include "common/debug.h" #include "common/system.h" @@ -185,7 +186,7 @@ void AmbientSounds::removeAllLoopingSounds(int delay) { } void AmbientSounds::tick() { - uint32 now = g_system->getMillis(); + uint32 now = _vm->_time->current(); for (int i = 0; i != kNonLoopingSounds; ++i) { NonLoopingSound &track = _nonLoopingSounds[i]; @@ -303,7 +304,7 @@ void AmbientSounds::addSoundByName( NonLoopingSound &track = _nonLoopingSounds[i]; - uint32 now = _vm->getTotalPlayTime(); + uint32 now = _vm->_time->current(); track.isActive = true; track.name = name; @@ -392,7 +393,7 @@ void AmbientSounds::load(SaveFileReadStream &f) { f.skip(4); // TODO: _isDisabled - uint32 now = g_system->getMillis(); + uint32 now = _vm->_time->getPauseStart(); for (int i = 0; i != kNonLoopingSounds; ++i) { NonLoopingSound &track = _nonLoopingSounds[i]; diff --git a/engines/bladerunner/bladerunner.cpp b/engines/bladerunner/bladerunner.cpp index 61b45e9ada..5a00863ceb 100644 --- a/engines/bladerunner/bladerunner.cpp +++ b/engines/bladerunner/bladerunner.cpp @@ -149,7 +149,7 @@ BladeRunnerEngine::BladeRunnerEngine(OSystem *syst, const ADGameDescription *des _lights = nullptr; _obstacles = nullptr; _sceneScript = nullptr; - _gameTime = nullptr; + _time = nullptr; _gameInfo = nullptr; _waypoints = nullptr; _gameVars = nullptr; @@ -352,7 +352,7 @@ bool BladeRunnerEngine::startup(bool hasSavegames) { _surfaceBack.create(640, 480, createRGB555()); _surface4.create(640, 480, createRGB555()); - _gameTime = new Time(this); + _time = new Time(this); r = openArchive("STARTUP.MIX"); if (!r) @@ -740,8 +740,8 @@ void BladeRunnerEngine::shutdown() { // TODO: Delete MIXArchives here - delete _gameTime; - _gameTime = nullptr; + delete _time; + _time = nullptr; // These are static objects in original game @@ -1148,7 +1148,7 @@ void BladeRunnerEngine::handleMouseAction(int x, int y, bool mainButton, bool bu x = CLIP(x, 0, 639); y = CLIP(y, 0, 479); - int timeNow = getTotalPlayTime(); + int timeNow = _time->current(); if (buttonDown) { _mouseClickTimeDiff = timeNow - _mouseClickTimeLast; diff --git a/engines/bladerunner/bladerunner.h b/engines/bladerunner/bladerunner.h index a377b89aa9..f056a669d9 100644 --- a/engines/bladerunner/bladerunner.h +++ b/engines/bladerunner/bladerunner.h @@ -148,7 +148,7 @@ public: SliceRenderer *_sliceRenderer; Spinner *_spinner; SuspectsDatabase *_suspectsDatabase; - Time *_gameTime; + Time *_time; View *_view; VK *_vk; Waypoints *_waypoints; diff --git a/engines/bladerunner/item_pickup.cpp b/engines/bladerunner/item_pickup.cpp index ffaeb79f33..1bed3bb640 100644 --- a/engines/bladerunner/item_pickup.cpp +++ b/engines/bladerunner/item_pickup.cpp @@ -56,7 +56,7 @@ void ItemPickup::setup(int animationId, int screenX, int screenY) { int pan = (150 * _screenX - 48000) / 640; _vm->_audioPlayer->playAud(_vm->_gameInfo->getSfxTrack(335), 80, pan, pan, 50, 0); - _timeLast = _vm->getTotalPlayTime(); + _timeLast = _vm->getTotalPlayTime(); // Original game is using system timer } void ItemPickup::reset() { @@ -75,7 +75,7 @@ void ItemPickup::tick() { return; } - int timeNow = _vm->getTotalPlayTime(); + int timeNow = _vm->getTotalPlayTime(); // Original game is using system timer int timeDiff = timeNow - _timeLast; _timeLast = timeNow; timeDiff = MIN(MIN(timeDiff, 67), _timeLeft); diff --git a/engines/bladerunner/mouse.cpp b/engines/bladerunner/mouse.cpp index 093c73fcff..59dcb41ac8 100644 --- a/engines/bladerunner/mouse.cpp +++ b/engines/bladerunner/mouse.cpp @@ -33,6 +33,7 @@ #include "bladerunner/scene_objects.h" #include "bladerunner/settings.h" #include "bladerunner/shape.h" +#include "bladerunner/time.h" #include "bladerunner/view.h" #include "bladerunner/zbuffer.h" @@ -262,7 +263,7 @@ void Mouse::draw(Graphics::Surface &surface, int x, int y) { } void Mouse::updateCursorFrame() { - uint32 now = _vm->getTotalPlayTime(); + uint32 now = _vm->_time->current(); const int offset[4] = { 0, 6, 12, 6 }; if (now - _lastFrameTime < 66) { diff --git a/engines/bladerunner/script/police_maze.cpp b/engines/bladerunner/script/police_maze.cpp index 284b55dcb0..f201b566c5 100644 --- a/engines/bladerunner/script/police_maze.cpp +++ b/engines/bladerunner/script/police_maze.cpp @@ -29,6 +29,7 @@ #include "bladerunner/scene_objects.h" #include "bladerunner/script/police_maze.h" #include "bladerunner/script/scene_script.h" +#include "bladerunner/time.h" namespace BladeRunner { @@ -78,7 +79,7 @@ void PoliceMaze::setPauseState(bool state) { warning("PAUSE: %d", state); _isPaused = state; - uint32 t = _vm->getTotalPlayTime(); + uint32 t = _vm->_time->current(); for (int i = 0; i < kNumMazeTracks; i++) { _tracks[i]->setTime(t); @@ -207,7 +208,7 @@ bool PoliceMazeTargetTrack::tick() { } uint32 oldTime = _time; - _time = _vm->getTotalPlayTime(); + _time = _vm->_time->current(); int32 timeDiff = _time - oldTime; _timeLeftUpdate -= timeDiff; diff --git a/engines/bladerunner/script/script.cpp b/engines/bladerunner/script/script.cpp index 9d9243afa5..28475d69f5 100644 --- a/engines/bladerunner/script/script.cpp +++ b/engines/bladerunner/script/script.cpp @@ -50,6 +50,7 @@ #include "bladerunner/slice_renderer.h" #include "bladerunner/suspects_database.h" #include "bladerunner/text_resource.h" +#include "bladerunner/time.h" #include "bladerunner/ui/elevator.h" #include "bladerunner/ui/esper.h" #include "bladerunner/ui/kia.h" @@ -729,8 +730,8 @@ int ScriptBase::Animation_Skip_To_Frame() { void ScriptBase::Delay(int miliseconds) { Player_Loses_Control(); - int endTime = _vm->getTotalPlayTime() + miliseconds; - while (_vm->_gameIsRunning && (int)_vm->getTotalPlayTime() < endTime) { + int endTime = _vm->_time->current() + miliseconds; + while (_vm->_gameIsRunning && (_vm->_time->current() < endTime)) { _vm->gameTick(); } Player_Gains_Control(); diff --git a/engines/bladerunner/time.cpp b/engines/bladerunner/time.cpp index a395a811d1..2e412824f8 100644 --- a/engines/bladerunner/time.cpp +++ b/engines/bladerunner/time.cpp @@ -53,7 +53,7 @@ int Time::getPauseStart() { return _pauseStart; } -int Time::unpause() { +int Time::resume() { assert(_pauseCount > 0); if (--_pauseCount == 0) { _offset += current() - _pauseStart; diff --git a/engines/bladerunner/time.h b/engines/bladerunner/time.h index bda8c84d14..11f96ed29f 100644 --- a/engines/bladerunner/time.h +++ b/engines/bladerunner/time.h @@ -41,7 +41,7 @@ public: int current(); int pause(); int getPauseStart(); - int unpause(); + int resume(); bool isLocked(); }; diff --git a/engines/bladerunner/ui/elevator.cpp b/engines/bladerunner/ui/elevator.cpp index c7432368f2..64164f442d 100644 --- a/engines/bladerunner/ui/elevator.cpp +++ b/engines/bladerunner/ui/elevator.cpp @@ -29,6 +29,7 @@ #include "bladerunner/mouse.h" #include "bladerunner/shape.h" #include "bladerunner/script/script.h" +#include "bladerunner/time.h" #include "bladerunner/ui/ui_image_picker.h" #include "bladerunner/vqa_player.h" @@ -156,7 +157,7 @@ int Elevator::activate(int elevatorId) { open(); - // TODO: time->lock(); + _vm->_time->pause(); _buttonClicked = -1; do { @@ -177,7 +178,7 @@ int Elevator::activate(int elevatorId) { _isOpen = false; - // TODO: time->unlock(); + _vm->_time->resume(); return _buttonClicked; } @@ -281,7 +282,7 @@ void Elevator::setupDescription(int actorId, int sentenceId) { _sentenceId = sentenceId; // TODO: Use proper timer - _timeSpeakDescription = _vm->getTotalPlayTime() + 600; + _timeSpeakDescription = _vm->_time->current() + 600; } void Elevator::resetDescription() { @@ -291,7 +292,7 @@ void Elevator::resetDescription() { } void Elevator::tickDescription() { - int now = _vm->getTotalPlayTime(); + int now = _vm->_time->current(); if (_actorId <= 0 || now < _timeSpeakDescription) { return; } diff --git a/engines/bladerunner/ui/end_credits.cpp b/engines/bladerunner/ui/end_credits.cpp index 6d964d0290..096f8988bb 100644 --- a/engines/bladerunner/ui/end_credits.cpp +++ b/engines/bladerunner/ui/end_credits.cpp @@ -95,7 +95,7 @@ void EndCredits::show() { _vm->_vqaStopIsRequested = false; double position = 0.0; - uint32 timeLast = _vm->getTotalPlayTime(); + uint32 timeLast = _vm->getTotalPlayTime(); // Original game is using system timer while (!_vm->_vqaStopIsRequested && !_vm->shouldQuit()) { if (position >= textPositions[textCount - 1]) { @@ -106,12 +106,12 @@ void EndCredits::show() { _vm->handleEvents(); if (!_vm->_gameIsRunning) { - timeLast = _vm->getTotalPlayTime(); + timeLast = _vm->getTotalPlayTime(); // Original game is using system timer continue; } - uint32 timeNow = _vm->getTotalPlayTime(); + uint32 timeNow = _vm->getTotalPlayTime(); // Original game is using system timer position += (double)(timeNow - timeLast) * 0.05f; timeLast = timeNow; diff --git a/engines/bladerunner/ui/esper.cpp b/engines/bladerunner/ui/esper.cpp index 6803ce5c5c..51c64f6bc9 100644 --- a/engines/bladerunner/ui/esper.cpp +++ b/engines/bladerunner/ui/esper.cpp @@ -35,6 +35,7 @@ #include "bladerunner/shape.h" #include "bladerunner/script/esper_script.h" #include "bladerunner/text_resource.h" +#include "bladerunner/time.h" #include "bladerunner/ui/ui_image_picker.h" #include "bladerunner/vqa_player.h" @@ -82,7 +83,8 @@ void ESPER::open(Graphics::Surface *surface) { _vm->_mouse->enable(); } - //TODO: time->lock() + _vm->_time->pause(); + _ambientVolume = _vm->_ambientSounds->getVolume(); _vm->_ambientSounds->setVolume(_ambientVolume / 2); @@ -151,7 +153,8 @@ void ESPER::close() { _vm->closeArchive("MODE.MIX"); - //TODO: time->unlock() + _vm->_time->resume(); + _vm->_ambientSounds->setVolume(_ambientVolume); _vm->_scene->resume(); reset(); @@ -533,8 +536,8 @@ void ESPER::setStatePhoto(EsperPhotoStates state) { void ESPER::wait(int timeout) { if (!_isWaiting) { _isWaiting = true; - uint timeEnd = timeout + _vm->getTotalPlayTime(); - while (_vm->_gameIsRunning && _vm->getTotalPlayTime() < timeEnd) { + int timeEnd = timeout + _vm->_time->current(); + while (_vm->_gameIsRunning && (_vm->_time->current() < timeEnd)) { _vm->gameTick(); } _isWaiting = false; @@ -652,7 +655,7 @@ void ESPER::draw(Graphics::Surface &surface) { void ESPER::drawPhotoOpening(Graphics::Surface &surface) { bool needMoreZooming = true; - int timeNow = _vm->getTotalPlayTime(); + int timeNow = _vm->_time->current(); if (timeNow >= _timePhotoOpeningNext) { _photoOpeningWidth = MIN(_photoOpeningWidth + 8, _screen.right - 1); _photoOpeningHeight = MIN(_photoOpeningHeight + 7, _screen.bottom - 1); @@ -682,7 +685,7 @@ void ESPER::drawPhotoOpening(Graphics::Surface &surface) { bool ESPER::drawSelectionZooming(Graphics::Surface &surface) { bool zooming = false; bool needMoreZooming = true; - int timeNow = _vm->getTotalPlayTime(); + int timeNow = _vm->_time->current(); if (timeNow > _timeSelectionZoomNext) { zooming = true; _selection.left += _selectionDelta.left; @@ -713,7 +716,7 @@ bool ESPER::drawSelectionZooming(Graphics::Surface &surface) { bool ESPER::drawSelectionBlinking(Graphics::Surface &surface) { bool needMoreBlinking = true; - int timeNow = _vm->getTotalPlayTime(); + int timeNow = _vm->_time->current(); if (timeNow > _timeSelectionBlinkingNext) { _timeSelectionBlinkingNext = timeNow + 100; _selectionBlinkingStyle ^= 1; @@ -731,7 +734,7 @@ bool ESPER::drawSelectionBlinking(Graphics::Surface &surface) { } void ESPER::drawPhotoZooming(Graphics::Surface &surface) { - int timeNow = _vm->getTotalPlayTime(); + int timeNow = _vm->_time->current(); if ((timeNow > _timeZoomNext) && (_zoomStep < _zoomSteps)) { _flash = true; @@ -799,7 +802,7 @@ void ESPER::drawPhotoZooming(Graphics::Surface &surface) { } void ESPER::drawPhotoSharpening(Graphics::Surface &surface) { - int timeNow = _vm->getTotalPlayTime(); + int timeNow = _vm->_time->current(); bool needMoreSharpening = true; if (timeNow >= _timePhotoOpeningNext) { _photoOpeningWidth = MIN(_photoOpeningWidth + 8, _screen.right - 1); @@ -840,7 +843,7 @@ void ESPER::drawPhotoSharpening(Graphics::Surface &surface) { } void ESPER::drawPhotoZoomOut(Graphics::Surface &surface) { - int timeNow = _vm->getTotalPlayTime(); + int timeNow = _vm->_time->current(); if (timeNow >= _timeZoomOutNext) { _timeZoomOutNext = timeNow + 300; @@ -882,7 +885,7 @@ void ESPER::drawVideoZooming(Graphics::Surface &surface) { bool flash = false; bool advanceFrame = false; - int timeNow = _vm->getTotalPlayTime(); + int timeNow = _vm->_time->current(); if (timeNow > _timeZoomNext) { _timeZoomNext = timeNow + 300; playSound(419, 25); @@ -907,7 +910,7 @@ void ESPER::drawVideoZooming(Graphics::Surface &surface) { void ESPER::drawVideoZoomOut(Graphics::Surface &surface) { bool flash = false; bool advanceFrame = false; - int timeNow = _vm->getTotalPlayTime(); + int timeNow = _vm->_time->current(); if (timeNow > _timeZoomNext && _vqaLastFrame > 0) { _timeZoomNext = timeNow + 300; playSound(419, 25); @@ -1379,7 +1382,7 @@ void ESPER::tickSound() { } void ESPER::tickScroll() { - int timeNow = _vm->getTotalPlayTime(); + int timeNow = _vm->_time->current(); if (timeNow <= _timeScrollNext) { return; } diff --git a/engines/bladerunner/ui/kia.cpp b/engines/bladerunner/ui/kia.cpp index 6bea198b7c..bd0402847b 100644 --- a/engines/bladerunner/ui/kia.cpp +++ b/engines/bladerunner/ui/kia.cpp @@ -38,6 +38,7 @@ #include "bladerunner/settings.h" #include "bladerunner/slice_renderer.h" #include "bladerunner/text_resource.h" +#include "bladerunner/time.h" #include "bladerunner/ui/kia_log.h" #include "bladerunner/ui/kia_section_base.h" #include "bladerunner/ui/kia_section_clues.h" @@ -665,7 +666,7 @@ void KIA::init() { } _vm->_audioPlayer->playAud(_vm->_gameInfo->getSfxTrack(501), 70, 0, 0, 50, 0); - // TODO: time->lock(); + _vm->_time->pause(); } void KIA::unload() { @@ -703,7 +704,7 @@ void KIA::unload() { _currentSectionId = kKIASectionNone; - // TODO: Unfreeze game time + _vm->_time->resume(); if (!_vm->_settings->isLoadingGame() && _vm->_gameIsRunning) { _vm->_scene->resume(); diff --git a/engines/bladerunner/ui/kia_section_load.cpp b/engines/bladerunner/ui/kia_section_load.cpp index bbc3c74c68..bada5a1415 100644 --- a/engines/bladerunner/ui/kia_section_load.cpp +++ b/engines/bladerunner/ui/kia_section_load.cpp @@ -74,7 +74,7 @@ void KIASectionLoad::open() { _scrollBox->addLine(_vm->_textOptions->getText(29), _newGameHardLineId, 0); // Hard _hoveredLineId = -1; - _timeLast = _vm->getTotalPlayTime(); + _timeLast = _vm->getTotalPlayTime(); // Original game is using system timer _timeLeft = 800; } @@ -108,7 +108,7 @@ void KIASectionLoad::draw(Graphics::Surface &surface){ _hoveredLineId = selectedLineId; } - uint32 now = _vm->getTotalPlayTime(); + uint32 now = _vm->getTotalPlayTime(); // Original game is using system timer if (selectedLineId >= 0 && selectedLineId < (int)_saveList.size()) { if (_timeLeft) { uint32 timeDiff = now - _timeLast; diff --git a/engines/bladerunner/ui/kia_section_save.cpp b/engines/bladerunner/ui/kia_section_save.cpp index 997cb75778..b042dc8097 100644 --- a/engines/bladerunner/ui/kia_section_save.cpp +++ b/engines/bladerunner/ui/kia_section_save.cpp @@ -121,7 +121,7 @@ void KIASectionSave::open() { } _hoveredLineId = -1; - _timeLast = _vm->getTotalPlayTime(); + _timeLast = _vm->getTotalPlayTime(); // Original game is using system timer _timeLeft = 800; } @@ -191,7 +191,7 @@ void KIASectionSave::draw(Graphics::Surface &surface){ _hoveredLineId = selectedLineId; } - uint32 now = _vm->getTotalPlayTime(); + uint32 now = _vm->getTotalPlayTime(); // Original game is using system timer if (selectedLineId >= 0 && selectedLineId < (int)_saveList.size()) { if (_timeLeft) { uint32 timeDiff = now - _timeLast; diff --git a/engines/bladerunner/ui/scores.cpp b/engines/bladerunner/ui/scores.cpp index 8fc3378207..3879d81c4e 100644 --- a/engines/bladerunner/ui/scores.cpp +++ b/engines/bladerunner/ui/scores.cpp @@ -27,6 +27,7 @@ #include "bladerunner/savefile.h" #include "bladerunner/scene.h" #include "bladerunner/text_resource.h" +#include "bladerunner/time.h" #include "bladerunner/vqa_player.h" #include "common/keyboard.h" @@ -58,7 +59,7 @@ void Scores::open() { _vqaPlayer->setLoop(1, -1, 0, nullptr, nullptr); - // TODO: Freeze game time + _vm->_time->pause(); _txtScorers = new TextResource(_vm); _txtScorers->open("SCORERS"); diff --git a/engines/bladerunner/ui/ui_check_box.cpp b/engines/bladerunner/ui/ui_check_box.cpp index 39e120e883..631b9ba942 100644 --- a/engines/bladerunner/ui/ui_check_box.cpp +++ b/engines/bladerunner/ui/ui_check_box.cpp @@ -47,7 +47,7 @@ UICheckBox::UICheckBox(BladeRunnerEngine *vm, UIComponentCallback *valueChangedC _frame = 0; } - _timeLast = _vm->getTotalPlayTime(); + _timeLast = _vm->getTotalPlayTime(); // Original game is using system timer _rect = rect; _isChecked = isChecked; } @@ -56,7 +56,7 @@ UICheckBox::UICheckBox(BladeRunnerEngine *vm, UIComponentCallback *valueChangedC void UICheckBox::draw(Graphics::Surface &surface) { int shapeId; if (_rect.right > _rect.left && _rect.bottom > _rect.top) { - uint timeNow = _vm->getTotalPlayTime(); + uint timeNow = _vm->getTotalPlayTime(); // Original game is using system timer if (timeNow - _timeLast > 67) { int frameDelta = (timeNow - _timeLast) / 67u; _timeLast = timeNow; diff --git a/engines/bladerunner/ui/ui_image_picker.cpp b/engines/bladerunner/ui/ui_image_picker.cpp index 0e00bf0484..7055fe31d6 100644 --- a/engines/bladerunner/ui/ui_image_picker.cpp +++ b/engines/bladerunner/ui/ui_image_picker.cpp @@ -27,6 +27,7 @@ #include "bladerunner/font.h" #include "bladerunner/mouse.h" #include "bladerunner/shape.h" +#include "bladerunner/time.h" #include "common/rect.h" #include "common/str.h" @@ -226,7 +227,12 @@ void UIImagePicker::drawTooltip(Graphics::Surface &surface, int x, int y) { return; } - if (_hoveredImageIndex == -1 || _vm->_mouse->isDisabled() || !_images[_hoveredImageIndex].active || _vm->getTotalPlayTime() < _hoverStartTimestamp + 1000) { + if ( + (_hoveredImageIndex == -1) || + (_vm->_mouse->isDisabled()) || + (!_images[_hoveredImageIndex].active) || + (_vm->_time->current() < _hoverStartTimestamp + 1000) + ) { return; } @@ -293,7 +299,7 @@ bool UIImagePicker::handleMouseAction(int x, int y, bool down, bool up, bool ign } } } - _hoverStartTimestamp = _vm->getTotalPlayTime(); + _hoverStartTimestamp = _vm->_time->current(); _hoveredImageIndex = hoveredImageIndex; } diff --git a/engines/bladerunner/ui/ui_image_picker.h b/engines/bladerunner/ui/ui_image_picker.h index d5b18b2f0a..3d62192454 100644 --- a/engines/bladerunner/ui/ui_image_picker.h +++ b/engines/bladerunner/ui/ui_image_picker.h @@ -54,7 +54,7 @@ class UIImagePicker { int _imageCount; int _hoveredImageIndex; int _pressedImageIndex; - uint32 _hoverStartTimestamp; + int _hoverStartTimestamp; int _isButtonDown; Common::Array _images; diff --git a/engines/bladerunner/ui/ui_input_box.cpp b/engines/bladerunner/ui/ui_input_box.cpp index 466238f8d3..6b9388c767 100644 --- a/engines/bladerunner/ui/ui_input_box.cpp +++ b/engines/bladerunner/ui/ui_input_box.cpp @@ -43,7 +43,7 @@ UIInputBox::UIInputBox(BladeRunnerEngine *vm, UIComponentCallback *valueChangedC setText(text); _cursorIsVisible = false; - _timeLast = _vm->getTotalPlayTime(); + _timeLast = _vm->getTotalPlayTime(); // Original game is using system timer } void UIInputBox::draw(Graphics::Surface &surface) { @@ -60,7 +60,7 @@ void UIInputBox::draw(Graphics::Surface &surface) { surface.vLine(textHalfWidth + rectHalfWidth + 2, _rect.top, _rect.bottom - 1, 0x7FDD); // 11111 11110 11101 } - if (_vm->getTotalPlayTime() - _timeLast > 500) { + if (_vm->getTotalPlayTime() - _timeLast > 500) { // Original game is using system timer _timeLast = _vm->getTotalPlayTime(); _cursorIsVisible = !_cursorIsVisible; } diff --git a/engines/bladerunner/ui/ui_scroll_box.cpp b/engines/bladerunner/ui/ui_scroll_box.cpp index a030e534c5..d39e580cd3 100644 --- a/engines/bladerunner/ui/ui_scroll_box.cpp +++ b/engines/bladerunner/ui/ui_scroll_box.cpp @@ -62,7 +62,7 @@ UIScrollBox::UIScrollBox(BladeRunnerEngine *vm, UIScrollBoxCallback *lineSelecte _isVisible = false; _style = style; _center = center; - _timeLastScroll = _vm->getTotalPlayTime(); + _timeLastScroll = _vm->getTotalPlayTime(); // Original game is using system timer _timeLastCheckbox = _vm->getTotalPlayTime(); _timeLastHighlight = _vm->getTotalPlayTime(); @@ -113,7 +113,7 @@ void UIScrollBox::show() { _scrollAreaDownHover = false; _scrollBarHover = false; - _timeLastScroll = _vm->getTotalPlayTime(); + _timeLastScroll = _vm->getTotalPlayTime(); // Original game is using system timer _timeLastCheckbox = _vm->getTotalPlayTime(); _timeLastHighlight = _vm->getTotalPlayTime(); @@ -267,7 +267,7 @@ void UIScrollBox::handleMouseDown(bool alternateButton) { if (!alternateButton) { if (_scrollUpButtonHover) { _scrollUpButtonState = 2; - _timeLastScroll = _vm->getTotalPlayTime() - 160; + _timeLastScroll = _vm->getTotalPlayTime() - 160; // Original game is using system timer } else { _scrollUpButtonState = 1; } @@ -283,13 +283,13 @@ void UIScrollBox::handleMouseDown(bool alternateButton) { } if (_scrollAreaUpHover) { _scrollAreaUpState = 2; - _timeLastScroll = _vm->getTotalPlayTime() - 160; + _timeLastScroll = _vm->getTotalPlayTime() - 160; // Original game is using system timer } else { _scrollAreaUpState = 1; } if (_scrollAreaDownHover) { _scrollAreaDownState = 2; - _timeLastScroll = _vm->getTotalPlayTime() - 160; + _timeLastScroll = _vm->getTotalPlayTime() - 160; // Original game is using system timer } else { _scrollAreaDownState = 1; } @@ -321,7 +321,7 @@ int UIScrollBox::getSelectedLineData() { } void UIScrollBox::draw(Graphics::Surface &surface) { - int timeNow = _vm->getTotalPlayTime(); + int timeNow = _vm->getTotalPlayTime(); // Original game is using system timer // update scrolling if (_scrollUpButtonState == 2 && _scrollUpButtonHover) { diff --git a/engines/bladerunner/ui/vk.cpp b/engines/bladerunner/ui/vk.cpp index ae776b7e55..aa95b6bf9c 100644 --- a/engines/bladerunner/ui/vk.cpp +++ b/engines/bladerunner/ui/vk.cpp @@ -38,6 +38,7 @@ #include "bladerunner/script/vk_script.h" #include "bladerunner/slice_renderer.h" #include "bladerunner/text_resource.h" +#include "bladerunner/time.h" #include "bladerunner/ui/ui_image_picker.h" #include "bladerunner/vqa_player.h" @@ -198,7 +199,7 @@ void VK::tick() { _vm->blitToScreen(_vm->_surfaceFront); _vm->_system->delayMillis(10); - if (_isClosing && (int)_vm->getTotalPlayTime() >= _timeClose && !_script->isInsideScript()) { + if (_isClosing && _vm->_time->current() >= _timeClose && !_script->isInsideScript()) { close(); _vm->_mouse->enable(); reset(); @@ -250,8 +251,8 @@ void VK::playSpeechLine(int actorId, int sentenceId, float duration) { } if (duration > 0.0f && !_vm->_speechSkipped) { - int timeEnd = duration * 1000.0f + _vm->getTotalPlayTime(); - while (timeEnd > (int)_vm->getTotalPlayTime() && _vm->_gameIsRunning) { + int timeEnd = duration * 1000.0f + _vm->_time->current(); + while ((timeEnd > _vm->_time->current()) && _vm->_gameIsRunning) { _vm->gameTick(); } } @@ -265,7 +266,7 @@ void VK::subjectReacts(int intensity, int humanResponse, int replicantResponse, humanResponse = CLIP(humanResponse, -20, 20); replicantResponse = CLIP(replicantResponse, -20, 20); - int timeNow = _vm->getTotalPlayTime(); + int timeNow = _vm->_time->current(); if (intensity > 0) { _needleValueTarget = 78 * intensity / 100; @@ -509,7 +510,7 @@ void VK::draw() { Graphics::Surface &surface = _vm->_surfaceFront; - int timeNow = _vm->getTotalPlayTime(); + int timeNow = _vm->_time->current(); if (_isAdjusting && !_testStarted && !_vm->isMouseButtonDown()) { _isAdjusting = false; @@ -670,7 +671,7 @@ void VK::draw() { void VK::drawNeedle(Graphics::Surface &surface) { int x = _needleValue + 165; - if ((int)_vm->getTotalPlayTime() >= _timeNextNeedleOscillate && x > 165) { + if ((_vm->_time->current() >= _timeNextNeedleOscillate) && (x > 165)) { x = CLIP(x + (int)_vm->_rnd.getRandomNumberRng(0, 4) - 2, 165, 245); } @@ -851,7 +852,7 @@ void VK::stopAdjustement() { void VK::animateAdjustment(int target) { _adjustmentTarget = MAX(target - 4, 154); _adjustmentDelta = (_adjustmentTarget - _adjustment) / 5; - _timeNextAdjustementStep = _vm->getTotalPlayTime() + 50; + _timeNextAdjustementStep = _vm->_time->current() + 50; } void VK::setAdjustment(int x) { @@ -920,7 +921,7 @@ void VK::askQuestion(int intensity) { } else if (!_isClosing && !_script->isInsideScript()) { _isClosing = true; _vm->_mouse->disable(); - _timeClose = _vm->getTotalPlayTime() + 3000; + _timeClose = _vm->_time->current() + 3000; } } -- cgit v1.2.3