diff options
author | Peter Kohaut | 2019-09-04 16:00:35 +0200 |
---|---|---|
committer | Peter Kohaut | 2019-09-04 21:26:37 +0200 |
commit | 89384b9124dfc385626f9b3aebb7ef4ad19a38b1 (patch) | |
tree | 5464f0959116e1c3c8203e8babca8789e7f319aa /engines/bladerunner/ui | |
parent | cb88db65cdff4302dd5952a0ed2a048ba5ef489a (diff) | |
download | scummvm-rg350-89384b9124dfc385626f9b3aebb7ef4ad19a38b1.tar.gz scummvm-rg350-89384b9124dfc385626f9b3aebb7ef4ad19a38b1.tar.bz2 scummvm-rg350-89384b9124dfc385626f9b3aebb7ef4ad19a38b1.zip |
BLADERUNNER: Framelimiter simplification
Diffstat (limited to 'engines/bladerunner/ui')
-rw-r--r-- | engines/bladerunner/ui/elevator.cpp | 45 | ||||
-rw-r--r-- | engines/bladerunner/ui/elevator.h | 2 | ||||
-rw-r--r-- | engines/bladerunner/ui/end_credits.cpp | 19 | ||||
-rw-r--r-- | engines/bladerunner/ui/end_credits.h | 2 | ||||
-rw-r--r-- | engines/bladerunner/ui/esper.cpp | 46 | ||||
-rw-r--r-- | engines/bladerunner/ui/esper.h | 2 | ||||
-rw-r--r-- | engines/bladerunner/ui/kia.cpp | 23 | ||||
-rw-r--r-- | engines/bladerunner/ui/kia.h | 4 | ||||
-rw-r--r-- | engines/bladerunner/ui/spinner.cpp | 47 | ||||
-rw-r--r-- | engines/bladerunner/ui/spinner.h | 2 | ||||
-rw-r--r-- | engines/bladerunner/ui/vk.cpp | 46 | ||||
-rw-r--r-- | engines/bladerunner/ui/vk.h | 2 |
12 files changed, 78 insertions, 162 deletions
diff --git a/engines/bladerunner/ui/elevator.cpp b/engines/bladerunner/ui/elevator.cpp index d01acc21ed..cff2a16ab7 100644 --- a/engines/bladerunner/ui/elevator.cpp +++ b/engines/bladerunner/ui/elevator.cpp @@ -25,7 +25,6 @@ #include "bladerunner/actor.h" #include "bladerunner/bladerunner.h" #include "bladerunner/audio_player.h" -#include "bladerunner/framelimiter.h" #include "bladerunner/game_info.h" #include "bladerunner/mouse.h" #include "bladerunner/shape.h" @@ -45,17 +44,11 @@ Elevator::Elevator(BladeRunnerEngine *vm) { _vm = vm; reset(); _imagePicker = new UIImagePicker(vm, 8); - _framelimiter = new Framelimiter(_vm, Framelimiter::kDefaultFpsRate, Framelimiter::kDefaultUseDelayMillis); } Elevator::~Elevator() { delete _imagePicker; _imagePicker = nullptr; - - if (_framelimiter) { - delete _framelimiter; - _framelimiter = nullptr; - } } int Elevator::activate(int elevatorId) { @@ -194,7 +187,6 @@ int Elevator::activate(int elevatorId) { void Elevator::open() { resetDescription(); _isOpen = true; - _framelimiter->init(); } bool Elevator::isOpen() const { @@ -213,35 +205,32 @@ int Elevator::handleMouseDown(int x, int y) { void Elevator::tick() { if (!_vm->_windowIsActive) { - _framelimiter->init(); return; } - if (_framelimiter->shouldExecuteScreenUpdate()) { - int frame = _vqaPlayer->update(); - assert(frame >= -1); + int frame = _vqaPlayer->update(); + assert(frame >= -1); + + // vqaPlayer renders to _surfaceBack + blit(_vm->_surfaceBack, _vm->_surfaceFront); - // vqaPlayer renders to _surfaceBack - blit(_vm->_surfaceBack, _vm->_surfaceFront); + Common::Point p = _vm->getMousePos(); - Common::Point p = _vm->getMousePos(); + // TODO(madmoose): BLADE.EXE has hasHoveredImage before handleMouseAction? + _imagePicker->handleMouseAction(p.x, p.y, false, false, false); + if (_imagePicker->hasHoveredImage()) { + _vm->_mouse->setCursor(1); + } else { + _vm->_mouse->setCursor(0); + } - // TODO(madmoose): BLADE.EXE has hasHoveredImage before handleMouseAction? - _imagePicker->handleMouseAction(p.x, p.y, false, false, false); - if (_imagePicker->hasHoveredImage()) { - _vm->_mouse->setCursor(1); - } else { - _vm->_mouse->setCursor(0); - } + _imagePicker->draw(_vm->_surfaceFront); + _vm->_mouse->draw(_vm->_surfaceFront, p.x, p.y); - _imagePicker->draw(_vm->_surfaceFront); - _vm->_mouse->draw(_vm->_surfaceFront, p.x, p.y); + _vm->_subtitles->tick(_vm->_surfaceFront); - _vm->_subtitles->tick(_vm->_surfaceFront); + _vm->blitToScreen(_vm->_surfaceFront); - _vm->blitToScreen(_vm->_surfaceFront); - _framelimiter->postScreenUpdate(); - } tickDescription(); } diff --git a/engines/bladerunner/ui/elevator.h b/engines/bladerunner/ui/elevator.h index c64152c3fc..6ed91ce799 100644 --- a/engines/bladerunner/ui/elevator.h +++ b/engines/bladerunner/ui/elevator.h @@ -28,14 +28,12 @@ namespace BladeRunner { class BladeRunnerEngine; -class Framelimiter; class Shape; class VQAPlayer; class UIImagePicker; class Elevator { BladeRunnerEngine *_vm; - Framelimiter *_framelimiter; bool _isOpen; VQAPlayer *_vqaPlayer; int _buttonClicked; diff --git a/engines/bladerunner/ui/end_credits.cpp b/engines/bladerunner/ui/end_credits.cpp index 291014c5a3..b609e2ea0d 100644 --- a/engines/bladerunner/ui/end_credits.cpp +++ b/engines/bladerunner/ui/end_credits.cpp @@ -29,7 +29,6 @@ #include "bladerunner/game_constants.h" #include "bladerunner/ambient_sounds.h" #include "bladerunner/audio_speech.h" -#include "bladerunner/framelimiter.h" #include "bladerunner/font.h" #include "bladerunner/game_info.h" #include "bladerunner/mouse.h" @@ -42,14 +41,9 @@ namespace BladeRunner { EndCredits::EndCredits(BladeRunnerEngine *vm) { _vm = vm; - _framelimiter = new Framelimiter(_vm, Framelimiter::kDefaultFpsRate, Framelimiter::kDefaultUseDelayMillis); } EndCredits::~EndCredits() { - if (_framelimiter) { - delete _framelimiter; - _framelimiter = nullptr; - } } void EndCredits::show() { @@ -98,7 +92,7 @@ void EndCredits::show() { _vm->_vqaStopIsRequested = false; double position = 0.0; - _framelimiter->init(); + uint32 timeLast = _vm->_time->currentSystem(); while (!_vm->_vqaStopIsRequested && !_vm->shouldQuit()) { if (position >= textPositions[textCount - 1]) { @@ -109,15 +103,13 @@ void EndCredits::show() { _vm->handleEvents(); if (!_vm->_windowIsActive) { - _framelimiter->init(); - continue; - } - - if (!_framelimiter->shouldExecuteScreenUpdate()) { + timeLast = _vm->_time->currentSystem(); continue; } - position += (double)(_framelimiter->getTimeOfCurrentPass() - _framelimiter->getTimeOfLastPass()) * 0.05f; // unsigned difference is intentional + uint32 timeNow = _vm->_time->currentSystem(); + position += (double)(timeNow - timeLast) * 0.05f; // unsigned difference is intentional + timeLast = timeNow; _vm->_surfaceFront.fillRect(Common::Rect(640, 480), 0); @@ -154,7 +146,6 @@ void EndCredits::show() { _vm->_surfaceFront.fillRect(Common::Rect(0, 452, 640, 480), 0); _vm->blitToScreen(_vm->_surfaceFront); - _framelimiter->postScreenUpdate(); } _vm->_vqaIsPlaying = false; diff --git a/engines/bladerunner/ui/end_credits.h b/engines/bladerunner/ui/end_credits.h index 6c45adfd60..39086cd796 100644 --- a/engines/bladerunner/ui/end_credits.h +++ b/engines/bladerunner/ui/end_credits.h @@ -26,11 +26,9 @@ namespace BladeRunner { class BladeRunnerEngine; -class Framelimiter; class EndCredits { BladeRunnerEngine *_vm; - Framelimiter *_framelimiter; public: EndCredits(BladeRunnerEngine *vm); diff --git a/engines/bladerunner/ui/esper.cpp b/engines/bladerunner/ui/esper.cpp index f5257bf694..fe59805153 100644 --- a/engines/bladerunner/ui/esper.cpp +++ b/engines/bladerunner/ui/esper.cpp @@ -28,7 +28,6 @@ #include "bladerunner/bladerunner.h" #include "bladerunner/debugger.h" #include "bladerunner/decompress_lcw.h" -#include "bladerunner/framelimiter.h" #include "bladerunner/font.h" #include "bladerunner/game_info.h" #include "bladerunner/mouse.h" @@ -67,17 +66,11 @@ ESPER::ESPER(BladeRunnerEngine *vm) { reset(); _buttons = new UIImagePicker(vm, kPhotoCount + 4); - _framelimiter = new Framelimiter(_vm, Framelimiter::kDefaultFpsRate, Framelimiter::kDefaultUseDelayMillis); } ESPER::~ESPER() { delete _buttons; reset(); - - if (_framelimiter) { - delete _framelimiter; - _framelimiter = nullptr; - } } void ESPER::open(Graphics::Surface *surface) { @@ -122,8 +115,6 @@ void ESPER::open(Graphics::Surface *surface) { _vqaPlayerMain->setLoop(2, -1, kLoopSetModeJustStart, nullptr, nullptr); _isOpen = true; - _framelimiter->init(); - _flash = false; _script = new ESPERScript(_vm); @@ -216,35 +207,30 @@ void ESPER::handleMouseDown(int x, int y, bool mainButton) { void ESPER::tick() { if (!_vm->_windowIsActive) { - _framelimiter->init(); return; } - if (_framelimiter->shouldExecuteScreenUpdate()) { - tickSound(); + tickSound(); - blit(_vm->_surfaceBack, _vm->_surfaceFront); + blit(_vm->_surfaceBack, _vm->_surfaceFront); - int mouseX, mouseY; - _vm->_mouse->getXY(&mouseX, &mouseY); - if (!_vm->_mouse->isDisabled()) { - _buttons->handleMouseAction(mouseX, mouseY, false, false, false); - } - - if (!_isOpen) { - return; - } + int mouseX, mouseY; + _vm->_mouse->getXY(&mouseX, &mouseY); + if (!_vm->_mouse->isDisabled()) { + _buttons->handleMouseAction(mouseX, mouseY, false, false, false); + } - draw(_vm->_surfaceFront); - _buttons->draw(_vm->_surfaceFront); - drawMouse(_vm->_surfaceFront); + if (!_isOpen) { + return; + } - tickSound(); - _vm->_subtitles->tick(_vm->_surfaceFront); - _vm->blitToScreen(_vm->_surfaceFront); + draw(_vm->_surfaceFront); + _buttons->draw(_vm->_surfaceFront); + drawMouse(_vm->_surfaceFront); - _framelimiter->postScreenUpdate(); - } + tickSound(); + _vm->_subtitles->tick(_vm->_surfaceFront); + _vm->blitToScreen(_vm->_surfaceFront); if (_statePhoto == kEsperPhotoStateVideoShow) { if (_regionSelectedAck) { diff --git a/engines/bladerunner/ui/esper.h b/engines/bladerunner/ui/esper.h index 818d51ca44..0c1c6a86e8 100644 --- a/engines/bladerunner/ui/esper.h +++ b/engines/bladerunner/ui/esper.h @@ -31,7 +31,6 @@ namespace BladeRunner { class BladeRunnerEngine; -class Framelimiter; class Font; class Shape; class VQAPlayer; @@ -88,7 +87,6 @@ class ESPER { }; BladeRunnerEngine *_vm; - Framelimiter *_framelimiter; ESPERScript *_script; bool _isWaiting; diff --git a/engines/bladerunner/ui/kia.cpp b/engines/bladerunner/ui/kia.cpp index 501a1e7cf2..3e9011e0c0 100644 --- a/engines/bladerunner/ui/kia.cpp +++ b/engines/bladerunner/ui/kia.cpp @@ -26,7 +26,6 @@ #include "bladerunner/audio_player.h" #include "bladerunner/bladerunner.h" #include "bladerunner/combat.h" -#include "bladerunner/framelimiter.h" #include "bladerunner/font.h" #include "bladerunner/game_constants.h" #include "bladerunner/game_flags.h" @@ -81,6 +80,7 @@ KIA::KIA(BladeRunnerEngine *vm) { _playerPhotograph = nullptr; _playerSliceModelId = -1; _playerSliceModelAngle = 0.0f; + _timeLast = _vm->_time->currentSystem(); _playerActorDialogueQueuePosition = 0; _playerActorDialogueQueueSize = 0; _playerActorDialogueState = 0; @@ -110,9 +110,6 @@ KIA::KIA(BladeRunnerEngine *vm) { _playerActorDialogueQueue[i].actorId = -1; _playerActorDialogueQueue[i].sentenceId = -1; } - - _framelimiter = new Framelimiter(_vm, Framelimiter::kDefaultFpsRate, Framelimiter::kDefaultUseDelayMillis); - _framelimiter->init(); } KIA::~KIA() { @@ -136,11 +133,6 @@ KIA::~KIA() { delete _shapes; delete _log; delete _script; - - if (_framelimiter) { - delete _framelimiter; - _framelimiter = nullptr; - } } void KIA::reset() { @@ -238,13 +230,9 @@ void KIA::tick() { return; } - if (!_framelimiter->shouldExecuteScreenUpdate()) { - return; - } - - uint32 timeNow = _framelimiter->getTimeOfCurrentPass(); + uint32 timeNow = _vm->_time->currentSystem(); // unsigned difference is intentional - uint32 timeDiff = timeNow - _framelimiter->getTimeOfLastPass(); + uint32 timeDiff = timeNow - _timeLast; if (_playerActorDialogueQueueSize == _playerActorDialogueQueuePosition) { _playerActorDialogueState = 0; @@ -396,7 +384,7 @@ void KIA::tick() { _vm->blitToScreen(_vm->_surfaceFront); - _framelimiter->postScreenUpdate(); + _timeLast = timeNow; } void KIA::resume() { @@ -691,8 +679,7 @@ void KIA::init() { playerReset(); _playerVqaFrame = 0; _playerVqaTimeLast = _vm->_time->currentSystem(); - - _framelimiter->init(); + _timeLast = _vm->_time->currentSystem(); if (_vm->_gameFlags->query(kFlagKIAPrivacyAddon) && !_vm->_gameFlags->query(kFlagKIAPrivacyAddonIntro)) { _vm->_gameFlags->set(kFlagKIAPrivacyAddonIntro); diff --git a/engines/bladerunner/ui/kia.h b/engines/bladerunner/ui/kia.h index fdc4d8ef15..2a87f5df6a 100644 --- a/engines/bladerunner/ui/kia.h +++ b/engines/bladerunner/ui/kia.h @@ -34,7 +34,6 @@ struct KeyState; namespace BladeRunner { class BladeRunnerEngine; -class Framelimiter; class KIALog; class KIAScript; class KIASectionBase; @@ -76,7 +75,6 @@ class KIA { }; BladeRunnerEngine *_vm; - Framelimiter *_framelimiter; int _transitionId; @@ -89,7 +87,7 @@ class KIA { int _playerSliceModelId; float _playerSliceModelAngle; Graphics::Surface _playerImage; -// uint32 _timeLast; + uint32 _timeLast; ActorDialogueQueueEntry _playerActorDialogueQueue[kPlayerActorDialogueQueueCapacity]; int _playerActorDialogueQueuePosition; diff --git a/engines/bladerunner/ui/spinner.cpp b/engines/bladerunner/ui/spinner.cpp index 85d2c373bb..27116a8f20 100644 --- a/engines/bladerunner/ui/spinner.cpp +++ b/engines/bladerunner/ui/spinner.cpp @@ -28,7 +28,6 @@ #include "bladerunner/ambient_sounds.h" #include "bladerunner/game_info.h" #include "bladerunner/subtitles.h" -#include "bladerunner/framelimiter.h" #include "bladerunner/game_constants.h" #include "bladerunner/mouse.h" #include "bladerunner/savefile.h" @@ -49,7 +48,6 @@ Spinner::Spinner(BladeRunnerEngine *vm) { reset(); _imagePicker = new UIImagePicker(vm, kSpinnerDestinations); _vqaPlayer = nullptr; - _framelimiter = new Framelimiter(_vm, Framelimiter::kDefaultFpsRate, Framelimiter::kDefaultUseDelayMillis); } Spinner::~Spinner() { @@ -61,11 +59,6 @@ Spinner::~Spinner() { _vqaPlayer->close(); delete _vqaPlayer; } - - if (_framelimiter) { - delete _framelimiter; - _framelimiter = nullptr; - } } void Spinner::setSelectableDestinationFlag(int destination, bool selectable) { @@ -237,7 +230,6 @@ void Spinner::mouseUpCallback(int destinationImage, void *self) { void Spinner::open() { _isOpen = true; - _framelimiter->init(); } bool Spinner::isOpen() const { @@ -256,35 +248,30 @@ int Spinner::handleMouseDown(int x, int y) { void Spinner::tick() { if (!_vm->_windowIsActive) { - _framelimiter->init(); return; } - if (_framelimiter->shouldExecuteScreenUpdate()) { - int frame = _vqaPlayer->update(); - assert(frame >= -1); + int frame = _vqaPlayer->update(); + assert(frame >= -1); - // vqaPlayer renders to _surfaceBack - blit(_vm->_surfaceBack, _vm->_surfaceFront); - - Common::Point p = _vm->getMousePos(); - _imagePicker->handleMouseAction(p.x, p.y, false, false, false); - if (_imagePicker->hasHoveredImage()) { - _vm->_mouse->setCursor(1); - } else { - _vm->_mouse->setCursor(0); - } - _imagePicker->draw(_vm->_surfaceFront); - _vm->_mouse->draw(_vm->_surfaceFront, p.x, p.y); - _imagePicker->drawTooltip(_vm->_surfaceFront, p.x, p.y); + // vqaPlayer renders to _surfaceBack + blit(_vm->_surfaceBack, _vm->_surfaceFront); - if (_vm->_cutContent) { - _vm->_subtitles->tick(_vm->_surfaceFront); - } - _vm->blitToScreen(_vm->_surfaceFront); - _framelimiter->postScreenUpdate(); + Common::Point p = _vm->getMousePos(); + _imagePicker->handleMouseAction(p.x, p.y, false, false, false); + if (_imagePicker->hasHoveredImage()) { + _vm->_mouse->setCursor(1); + } else { + _vm->_mouse->setCursor(0); + } + _imagePicker->draw(_vm->_surfaceFront); + _vm->_mouse->draw(_vm->_surfaceFront, p.x, p.y); + _imagePicker->drawTooltip(_vm->_surfaceFront, p.x, p.y); + if (_vm->_cutContent) { + _vm->_subtitles->tick(_vm->_surfaceFront); } + _vm->blitToScreen(_vm->_surfaceFront); if (_vm->_cutContent) { tickDescription(); diff --git a/engines/bladerunner/ui/spinner.h b/engines/bladerunner/ui/spinner.h index 78c2943eb2..2fa0dc659c 100644 --- a/engines/bladerunner/ui/spinner.h +++ b/engines/bladerunner/ui/spinner.h @@ -29,7 +29,6 @@ namespace BladeRunner { class BladeRunnerEngine; -class Framelimiter; class SaveFileReadStream; class SaveFileWriteStream; class Shape; @@ -45,7 +44,6 @@ class Spinner { }; BladeRunnerEngine *_vm; - Framelimiter *_framelimiter; bool _isDestinationSelectable[kSpinnerDestinations]; bool _isOpen; VQAPlayer *_vqaPlayer; diff --git a/engines/bladerunner/ui/vk.cpp b/engines/bladerunner/ui/vk.cpp index 7e24b798b6..245bae9512 100644 --- a/engines/bladerunner/ui/vk.cpp +++ b/engines/bladerunner/ui/vk.cpp @@ -27,7 +27,6 @@ #include "bladerunner/audio_player.h" #include "bladerunner/bladerunner.h" #include "bladerunner/combat.h" -#include "bladerunner/framelimiter.h" #include "bladerunner/font.h" #include "bladerunner/game_constants.h" #include "bladerunner/game_flags.h" @@ -54,16 +53,10 @@ VK::VK(BladeRunnerEngine *vm) { _vm = vm; reset(); - _framelimiter = new Framelimiter(_vm, Framelimiter::kDefaultFpsRate, Framelimiter::kDefaultUseDelayMillis); } VK::~VK() { reset(); - - if (_framelimiter) { - delete _framelimiter; - _framelimiter = nullptr; - } } void VK::open(int actorId, int calibrationRatio) { @@ -133,7 +126,6 @@ void VK::open(int actorId, int calibrationRatio) { } _isOpen = true; - _framelimiter->init(); _script = new VKScript(_vm); @@ -198,31 +190,27 @@ void VK::close() { } void VK::tick() { + int mouseX, mouseY; + _vm->_mouse->getXY(&mouseX, &mouseY); + if (!_vm->_mouse->isDisabled()) { + _buttons->handleMouseAction(mouseX, mouseY, false, false, false); + } - if (_framelimiter->shouldExecuteScreenUpdate()) { - int mouseX, mouseY; - _vm->_mouse->getXY(&mouseX, &mouseY); - if (!_vm->_mouse->isDisabled()) { - _buttons->handleMouseAction(mouseX, mouseY, false, false, false); - } - - draw(); + draw(); - if ( _vm->_debugger->_showStatsVk - && !_vm->_actors[_actorId]->isSpeeching() - && !_vm->_actors[kActorMcCoy]->isSpeeching() - && !_vm->_actors[kActorAnsweringMachine]->isSpeeching() - && !_isClosing - ) { - _vm->_subtitles->setGameSubsText(Common::String::format("Calibration: %02d Ratio: %02d Anxiety: %02d%%\nReplicant: %02d%% Human: %02d%%", _calibration, _calibrationRatio, _anxiety, _replicantProbability, _humanProbability), true); - _vm->_subtitles->show(); - } + if ( _vm->_debugger->_showStatsVk + && !_vm->_actors[_actorId]->isSpeeching() + && !_vm->_actors[kActorMcCoy]->isSpeeching() + && !_vm->_actors[kActorAnsweringMachine]->isSpeeching() + && !_isClosing + ) { + _vm->_subtitles->setGameSubsText(Common::String::format("Calibration: %02d Ratio: %02d Anxiety: %02d%%\nReplicant: %02d%% Human: %02d%%", _calibration, _calibrationRatio, _anxiety, _replicantProbability, _humanProbability), true); + _vm->_subtitles->show(); + } - _vm->_subtitles->tick(_vm->_surfaceFront); + _vm->_subtitles->tick(_vm->_surfaceFront); - _vm->blitToScreen(_vm->_surfaceFront); - _framelimiter->postScreenUpdate(); - } + _vm->blitToScreen(_vm->_surfaceFront); // unsigned difference is intentional if (_isClosing && (_vm->_time->current() - _timeCloseStart >= 3000u) && !_script->isInsideScript()) { diff --git a/engines/bladerunner/ui/vk.h b/engines/bladerunner/ui/vk.h index a8802046e3..eeaee1b54d 100644 --- a/engines/bladerunner/ui/vk.h +++ b/engines/bladerunner/ui/vk.h @@ -31,7 +31,6 @@ namespace BladeRunner { class BladeRunnerEngine; -class Framelimiter; class VKScript; class Shape; class UIImagePicker; @@ -48,7 +47,6 @@ class VK { }; BladeRunnerEngine *_vm; - Framelimiter *_framelimiter; VKScript *_script; |