diff options
author | Le Philousophe | 2019-05-20 20:56:35 +0200 |
---|---|---|
committer | Eugene Sandulenko | 2019-06-01 22:43:48 +0200 |
commit | 01f6e2db12aa980aa316b80bc0e4b29e58cf2b5e (patch) | |
tree | df1db24186d6e4027c01cc4f3c954ac139155f66 /engines/cryomni3d/versailles/logic.cpp | |
parent | edf2fdb12880b2b96beb3a753da4c1ad44b0bbf4 (diff) | |
download | scummvm-rg350-01f6e2db12aa980aa316b80bc0e4b29e58cf2b5e.tar.gz scummvm-rg350-01f6e2db12aa980aa316b80bc0e4b29e58cf2b5e.tar.bz2 scummvm-rg350-01f6e2db12aa980aa316b80bc0e4b29e58cf2b5e.zip |
CRYOMNI3D: Implement countdown
Diffstat (limited to 'engines/cryomni3d/versailles/logic.cpp')
-rw-r--r-- | engines/cryomni3d/versailles/logic.cpp | 80 |
1 files changed, 80 insertions, 0 deletions
diff --git a/engines/cryomni3d/versailles/logic.cpp b/engines/cryomni3d/versailles/logic.cpp index e65d5a62dc..af20e9c3af 100644 --- a/engines/cryomni3d/versailles/logic.cpp +++ b/engines/cryomni3d/versailles/logic.cpp @@ -4085,5 +4085,85 @@ FILTER_EVENT(6, 19) { #undef FILTER_EVENT #undef INIT_PLACE +// Countdown + +void CryOmni3DEngine_Versailles::initCountdown() { + strcpy(_countdownValue, "05:00"); + if (_gameVariables[GameVariables::kSavedCountdown]) { + unsigned int counter = _gameVariables[GameVariables::kSavedCountdown]; + _countdownValue[4] = counter; + counter >>= 8; + _countdownValue[3] = counter; + counter >>= 8; + _countdownValue[1] = counter; + counter >>= 8; + _countdownValue[0] = counter; + } +} + +void CryOmni3DEngine_Versailles::syncCountdown() { + unsigned int counter = 0; + counter |= _countdownValue[0]; + counter <<= 8; + counter |= _countdownValue[1]; + counter <<= 8; + counter |= _countdownValue[3]; + counter <<= 8; + counter |= _countdownValue[4]; + _gameVariables[GameVariables::kSavedCountdown] = counter; +} + +bool CryOmni3DEngine_Versailles::doCountDown() { + if (g_system->getMillis() > _countdownNextEvent) { + _countdownNextEvent = g_system->getMillis() + 1000; + // Decrement countdown + _countdownValue[4]--; + if (_countdownValue[4] < '0') { + _countdownValue[4] = '9'; + _countdownValue[3]--; + if (_countdownValue[3] < '0') { + _countdownValue[3] = '5'; + _countdownValue[1]--; + if (_countdownValue[1] < '0') { + _countdownValue[1] = '9'; + _countdownValue[0]--; + if (_countdownValue[0] < '0') { + // Finished! + _countingDown = false; + playTransitionEndLevel(8); + _abortCommand = AbortGameOver; + } + } + } + } + + // Redraw surface + _countdownSurface.clear(0); + _fontManager.setCurrentFont(3); + _fontManager.setTransparentBackground(true); + _fontManager.setForeColor(241); + _fontManager.setLineHeight(14); + _fontManager.setSpaceWidth(0); + _fontManager.setCharSpacing(1); + _fontManager.setSurface(&_countdownSurface); + + _fontManager.displayStr(0, 2, _countdownValue); + + // Surface changed: need redraw + return true; + } else { + return false; + } +} + +void CryOmni3DEngine_Versailles::doDrawCountdown(Graphics::ManagedSurface *surface) { + if (surface) { + surface->blitFrom(_countdownSurface, Common::Point(600, 0)); + } else { + g_system->copyRectToScreen(_countdownSurface.getPixels(), _countdownSurface.pitch, 600, 0, + _countdownSurface.w, _countdownSurface.h); + } +} + } // End of namespace Versailles } // End of namespace CryOmni3D |