From 3a41e5f36422c3a3540ce5dadf7b95cd0fe40564 Mon Sep 17 00:00:00 2001 From: Eugene Sandulenko Date: Tue, 27 Mar 2018 23:43:38 +0200 Subject: BLADERUNNER: Implemented EndCredits --- engines/bladerunner/ui/end_credits.cpp | 130 +++++++++++++++++++++++++++++++++ 1 file changed, 130 insertions(+) (limited to 'engines/bladerunner/ui') diff --git a/engines/bladerunner/ui/end_credits.cpp b/engines/bladerunner/ui/end_credits.cpp index 0051fad534..692e8fbbf9 100644 --- a/engines/bladerunner/ui/end_credits.cpp +++ b/engines/bladerunner/ui/end_credits.cpp @@ -20,6 +20,19 @@ * */ +#include "common/system.h" +#include "common/rect.h" + +#include "audio/mixer.h" + +#include "bladerunner/bladerunner.h" +#include "bladerunner/ambient_sounds.h" +#include "bladerunner/audio_speech.h" +#include "bladerunner/font.h" +#include "bladerunner/game_info.h" +#include "bladerunner/mouse.h" +#include "bladerunner/music.h" +#include "bladerunner/text_resource.h" #include "bladerunner/ui/end_credits.h" namespace BladeRunner { @@ -32,6 +45,123 @@ EndCredits::~EndCredits() { } void EndCredits::show() { + _vm->_mouse->disable(); + _vm->_mixer->stopAll(); + _vm->_ambientSounds->removeAllNonLoopingSounds(true); + _vm->_ambientSounds->removeAllLoopingSounds(4); + _vm->_audioSpeech->stopSpeech(); + + _vm->_music->play(_vm->_gameInfo->getMusicTrack(17), 100, 0, 2, -1, 0, 3); + + Font *fontBig = new Font(_vm); + fontBig->open("TAHOMA24.FON", 640, 480, -1, 0, 0); + fontBig->setSpacing(1, 0); + + Font *fontSmall = new Font(_vm); + fontSmall->open("TAHOMA18.FON", 640, 480, -1, 0, 0); + fontSmall->setSpacing(1, 0); + + TextResource *textResource = new TextResource(_vm); + textResource->open("ENDCRED"); + + int textCount = textResource->getCount(); + int *textPositions = (int *)malloc(textCount * sizeof(int)); + int y = 452; + bool small = false; + + for (int i = 0; i < textCount; i++) { + Common::String s = textResource->getText(i); + if (s.hasPrefix("^")) { + if (!small) { + y += 28; + } + small = false; + } else { + if (small) { + y += 24; + } else { + y += 28; + } + small = true; + } + if (s.hasPrefix("^")) { + textPositions[i] = y; + } else { + textPositions[i] = y + 2; + } + } + + _vm->_vqaIsPlaying = true; + _vm->_vqaStopIsRequested = false; + + double position = 0.0; + uint32 timeLast = _vm->getTotalPlayTime(); + + while (!_vm->_vqaStopIsRequested) { + if (position >= textPositions[textCount - 1]) { + break; + } + + //soundSystem::tick(SoundSystem); + _vm->handleEvents(); + + if (!_vm->_gameIsRunning) { + timeLast = _vm->getTotalPlayTime(); + + continue; + } + + uint32 timeNow = _vm->getTotalPlayTime(); + position += (double)(timeNow - timeLast) * 0.05f; + timeLast = timeNow; + + _vm->_surfaceFront.fillRect(Common::Rect(640, 480), 0); + + for (int i = 0; i < textCount; i++) { + Common::String s = textResource->getText(i); + Font *font; + int height; + + if (s.hasPrefix("^")) { + font = fontBig; + height = 28; + s.deleteChar(0); + } else { + font = fontSmall; + height = 24; + } + + y = textPositions[i] - (int)position; + + if (y < 452 && y + height > 28) { + int x; + + if (font == fontBig) { + x = 280; + } else { + x = 270 - font->getTextWidth(s); + } + + font->draw(s, _vm->_surfaceFront, x, y); + } + } + + _vm->_surfaceFront.fillRect(Common::Rect(0, 0, 640, 28), 0); + _vm->_surfaceFront.fillRect(Common::Rect(0, 452, 640, 480), 0); + + _vm->blitToScreen(_vm->_surfaceFront); + + _vm->_system->delayMillis(10); + } + + _vm->_vqaIsPlaying = false; + _vm->_vqaStopIsRequested = false; + + free(textPositions); + delete textResource; + + _vm->_music->stop(0); + _vm->_mouse->enable(); } } // End of namespace BladeRunner -- cgit v1.2.3