mirror of
https://github.com/libretro/scummvm.git
synced 2024-12-13 21:31:53 +00:00
Allow pausing during cutscene movies. (This will need an update to the mixer's
getSoundElapsedTime() function to work better.) svn-id: r34954
This commit is contained in:
parent
85c1d35ae3
commit
db3438f2c9
@ -75,6 +75,7 @@ MoviePlayer::MoviePlayer(Sword2Engine *vm, const char *name) {
|
||||
_name = strdup(name);
|
||||
_mixer = _vm->_mixer;
|
||||
_system = _vm->_system;
|
||||
_pauseTicks = 0;
|
||||
_textSurface = NULL;
|
||||
_bgSoundStream = NULL;
|
||||
_ticks = 0;
|
||||
@ -98,6 +99,10 @@ MoviePlayer::~MoviePlayer() {
|
||||
free(_name);
|
||||
}
|
||||
|
||||
uint32 MoviePlayer::getTick() {
|
||||
return _system->getMillis() - _pauseTicks;
|
||||
}
|
||||
|
||||
void MoviePlayer::updatePalette(byte *pal, bool packed) {
|
||||
byte palette[4 * 256];
|
||||
byte *p = palette;
|
||||
@ -167,7 +172,7 @@ bool MoviePlayer::checkSkipFrame() {
|
||||
if ((_mixer->getSoundElapsedTime(_bgSoundHandle) * 12) / 1000 < _currentFrame + 1)
|
||||
return false;
|
||||
} else {
|
||||
if (_system->getMillis() <= _ticks)
|
||||
if (getTick() <= _ticks)
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -192,9 +197,9 @@ bool MoviePlayer::syncFrame() {
|
||||
// so that we can still fall back on the no-sound sync case for
|
||||
// the subsequent frames.
|
||||
|
||||
_ticks = _system->getMillis();
|
||||
_ticks = getTick();
|
||||
} else {
|
||||
while (_system->getMillis() < _ticks) {
|
||||
while (getTick() < _ticks) {
|
||||
_system->delayMillis(10);
|
||||
}
|
||||
}
|
||||
@ -392,7 +397,7 @@ void MoviePlayer::play(SequenceTextInfo *textList, uint32 numLines, int32 leadIn
|
||||
savePalette();
|
||||
|
||||
_framesSkipped = 0;
|
||||
_ticks = _system->getMillis();
|
||||
_ticks = getTick();
|
||||
_bgSoundStream = Audio::AudioStream::openStreamFile(_name);
|
||||
|
||||
if (_bgSoundStream) {
|
||||
@ -497,6 +502,16 @@ void MoviePlayer::play(SequenceTextInfo *textList, uint32 numLines, int32 leadIn
|
||||
restorePalette();
|
||||
}
|
||||
|
||||
void MoviePlayer::pauseMovie(bool pause) {
|
||||
_mixer->pauseHandle(_bgSoundHandle, pause);
|
||||
|
||||
if (pause) {
|
||||
_pauseStartTick = _system->getMillis();
|
||||
} else {
|
||||
_pauseTicks += (_system->getMillis() - _pauseStartTick);
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef USE_ZLIB
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
@ -840,7 +855,7 @@ bool MoviePlayerDummy::decodeFrame() {
|
||||
|
||||
bool MoviePlayerDummy::syncFrame() {
|
||||
if ((_numSpeechLines == 0 || _currentFrame < _firstSpeechFrame) && !_mixer->isSoundHandleActive(_bgSoundHandle)) {
|
||||
_ticks = _system->getMillis();
|
||||
_ticks = getTick();
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -82,6 +82,9 @@ protected:
|
||||
|
||||
uint32 _ticks;
|
||||
|
||||
uint32 _pauseStartTick;
|
||||
uint32 _pauseTicks;
|
||||
|
||||
uint _currentFrame;
|
||||
byte *_frameBuffer;
|
||||
int _frameWidth, _frameHeight;
|
||||
@ -100,6 +103,8 @@ protected:
|
||||
|
||||
uint32 _currentText;
|
||||
|
||||
uint32 getTick();
|
||||
|
||||
void savePalette();
|
||||
void restorePalette();
|
||||
|
||||
@ -125,6 +130,7 @@ public:
|
||||
virtual bool load();
|
||||
bool userInterrupt();
|
||||
void play(SequenceTextInfo *textList, uint32 numLines, int32 leadIn, int32 leadOut);
|
||||
void pauseMovie(bool pause);
|
||||
};
|
||||
|
||||
class MoviePlayerDummy : public MoviePlayer {
|
||||
|
@ -2139,15 +2139,16 @@ int32 Logic::fnPlaySequence(int32 *params) {
|
||||
// pause sfx during sequence
|
||||
_vm->_sound->pauseFx();
|
||||
|
||||
MoviePlayer *player = makeMoviePlayer(_vm, filename);
|
||||
_moviePlayer = makeMoviePlayer(_vm, filename);
|
||||
|
||||
if (player->load()) {
|
||||
player->play(_sequenceTextList, _sequenceTextLines, _smackerLeadIn, _smackerLeadOut);
|
||||
if (_moviePlayer->load()) {
|
||||
_moviePlayer->play(_sequenceTextList, _sequenceTextLines, _smackerLeadIn, _smackerLeadOut);
|
||||
}
|
||||
|
||||
_sequenceTextLines = 0;
|
||||
|
||||
delete player;
|
||||
delete _moviePlayer;
|
||||
_moviePlayer = NULL;
|
||||
|
||||
// unpause sound fx again, in case we're staying in same location
|
||||
_vm->_sound->unpauseFx();
|
||||
|
@ -38,10 +38,10 @@
|
||||
namespace Sword2 {
|
||||
|
||||
Logic::Logic(Sword2Engine *vm) :
|
||||
_vm(vm), _kills(0), _currentRunList(0), _smackerLeadIn(0),
|
||||
_smackerLeadOut(0), _sequenceTextLines(0), _speechTime(0), _animId(0),
|
||||
_speechAnimType(0), _leftClickDelay(0), _rightClickDelay(0),
|
||||
_officialTextNumber(0), _speechTextBlocNo(0) {
|
||||
_vm(vm), _kills(0), _currentRunList(0), _moviePlayer(0),
|
||||
_smackerLeadIn(0), _smackerLeadOut(0), _sequenceTextLines(0),
|
||||
_speechTime(0), _animId(0), _speechAnimType(0), _leftClickDelay(0),
|
||||
_rightClickDelay(0), _officialTextNumber(0), _speechTextBlocNo(0) {
|
||||
|
||||
_scriptVars = NULL;
|
||||
memset(_eventList, 0, sizeof(_eventList));
|
||||
@ -274,4 +274,14 @@ void Logic::resetKillList() {
|
||||
_kills = 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Pause or unpause the currently playing cutscene movie, if any.
|
||||
* @param pause true if pausing, false if unpausing
|
||||
*/
|
||||
|
||||
void Logic::pauseMovie(bool pause) {
|
||||
if (_moviePlayer)
|
||||
_moviePlayer->pauseMovie(pause);
|
||||
}
|
||||
|
||||
} // End of namespace Sword2
|
||||
|
@ -77,6 +77,8 @@ private:
|
||||
|
||||
EventUnit _eventList[MAX_events];
|
||||
|
||||
MoviePlayer *_moviePlayer;
|
||||
|
||||
// Resource id of the wav to use as lead-in/lead-out from smacker
|
||||
uint32 _smackerLeadIn;
|
||||
uint32 _smackerLeadOut;
|
||||
@ -310,6 +312,8 @@ public:
|
||||
void logicReplace(uint32 new_script);
|
||||
void logicOne(uint32 new_script);
|
||||
void resetKillList();
|
||||
|
||||
void pauseMovie(bool pause);
|
||||
};
|
||||
|
||||
} // End of namespace Sword2
|
||||
|
@ -744,7 +744,7 @@ void Sword2Engine::sleepUntil(uint32 time) {
|
||||
void Sword2Engine::pauseEngineIntern(bool pause) {
|
||||
if (pause) {
|
||||
// FIXME: We should never disallow pausing, and we need to do
|
||||
// something about pausing during cutscene moves, credits, etc.
|
||||
// something about pausing during credits, etc.
|
||||
|
||||
// Don't allow Pause while screen fading or while black
|
||||
if (_screen->getFadeStatus() != RDFADE_NONE)
|
||||
@ -752,6 +752,7 @@ void Sword2Engine::pauseEngineIntern(bool pause) {
|
||||
|
||||
_sound->pauseAllSound();
|
||||
_mouse->pauseEngine(true);
|
||||
_logic->pauseMovie(true);
|
||||
|
||||
#ifdef SWORD2_DEBUG
|
||||
// Don't dim it if we're single-stepping through frames
|
||||
@ -766,6 +767,7 @@ void Sword2Engine::pauseEngineIntern(bool pause) {
|
||||
_gamePaused = true;
|
||||
} else {
|
||||
_mouse->pauseEngine(false);
|
||||
_logic->pauseMovie(false);
|
||||
_sound->unpauseAllSound();
|
||||
|
||||
_screen->dimPalette(false);
|
||||
|
Loading…
Reference in New Issue
Block a user