diff options
| -rw-r--r-- | engines/gob/demos/demoplayer.cpp | 105 | ||||
| -rw-r--r-- | engines/gob/demos/demoplayer.h | 4 | ||||
| -rw-r--r-- | engines/gob/videoplayer.cpp | 25 | ||||
| -rw-r--r-- | engines/gob/videoplayer.h | 7 | 
4 files changed, 88 insertions, 53 deletions
diff --git a/engines/gob/demos/demoplayer.cpp b/engines/gob/demos/demoplayer.cpp index cd3e97d7f0..25cd470f04 100644 --- a/engines/gob/demos/demoplayer.cpp +++ b/engines/gob/demos/demoplayer.cpp @@ -152,12 +152,13 @@ void DemoPlayer::playVideo(const char *fileName) {  	debugC(1, kDebugDemo, "Playing video \"%s\"", file); -	int16 x = _rebase0 ? 0 : -1; -	int16 y = _rebase0 ? 0 : -1; -	if (_vm->_vidPlayer->primaryOpen(file, x, y)) { -		bool videoSupportsDouble = false; -			//((_vm->_vidPlayer->getFeatures() & Graphics::CoktelDecoder::kFeaturesSupportsDouble) != 0); +	VideoPlayer::Properties props; +	props.x = _rebase0 ? 0 : -1; +	props.y = _rebase0 ? 0 : -1; + +	int slot; +	if ((slot = _vm->_vidPlayer->openVideo(true, file, props)) >= 0) {  		if (_autoDouble) {  			int16 defX = _rebase0 ? 0 : _vm->_vidPlayer->getDefaultX();  			int16 defY = _rebase0 ? 0 : _vm->_vidPlayer->getDefaultY(); @@ -167,16 +168,12 @@ void DemoPlayer::playVideo(const char *fileName) {  			_doubleMode = ((right < 320) && (bottom < 200));  		} -		if (_doubleMode) { -			if (videoSupportsDouble) { -				_vm->_vidPlayer->slotSetDoubleMode(-1, true); -				playVideoNormal(); -			} else -				playVideoDoubled(); -		} else -			playVideoNormal(); +		if (_doubleMode) +			playVideoDoubled(slot); +		else +			playVideoNormal(slot); -		_vm->_vidPlayer->primaryClose(); +		_vm->_vidPlayer->closeVideo(slot);  		if (waitTime > 0)  			_vm->_util->longDelay(waitTime); @@ -210,53 +207,67 @@ void DemoPlayer::playADL(const char *params) {  	playADL(fileName, waitEsc, repeat);  } -void DemoPlayer::playVideoNormal() { -	_vm->_vidPlayer->primaryPlay(); +void DemoPlayer::playVideoNormal(int slot) { +	VideoPlayer::Properties props; + +	_vm->_vidPlayer->play(slot, props);  } -void DemoPlayer::playVideoDoubled() { -	Common::String fileNameOpened = _vm->_vidPlayer->getFileName(); -	_vm->_vidPlayer->primaryClose(); +void DemoPlayer::playVideoDoubled(int slot) { +	Common::String fileNameOpened = _vm->_vidPlayer->getFileName(slot); +	_vm->_vidPlayer->closeVideo(slot); -	int16 x = _rebase0 ? 0 : -1; -	int16 y = _rebase0 ? 0 : -1; -	if (_vm->_vidPlayer->primaryOpen(fileNameOpened.c_str(), x, y, -				VideoPlayer::kFlagScreenSurface)) { +	VideoPlayer::Properties props; -		for (uint i = 0; i < _vm->_vidPlayer->getFrameCount(); i++) { -			// _vm->_vidPlayer->playFrame(i); +	props.x            = _rebase0 ? 0 : -1; +	props.y            = _rebase0 ? 0 : -1; +	props.flags        = VideoPlayer::kFlagScreenSurface; +	props.waitEndFrame = false; -			/* -			Graphics::CoktelDecoder::State state;// = _vm->_vidPlayer->getState(); +	_vm->_vidPlayer->evaluateFlags(props); + +	slot = _vm->_vidPlayer->openVideo(true, fileNameOpened, props); +	if (slot < 0) +		return; -			int16 w = state.right - state.left + 1; -			int16 h = state.bottom - state.top + 1; -			int16 wD = (state.left * 2) + (w * 2); -			int16 hD = (state.top * 2) + (h * 2); +	for (uint i = 0; i < _vm->_vidPlayer->getFrameCount(slot); i++) { +		props.startFrame = _vm->_vidPlayer->getCurrentFrame(slot) + 1; +		props.lastFrame  = _vm->_vidPlayer->getCurrentFrame(slot) + 1; + +		_vm->_vidPlayer->play(slot, props); + +		const Common::List<Common::Rect> *rects = _vm->_vidPlayer->getDirtyRects(slot); +		if (rects) { +			for (Common::List<Common::Rect>::const_iterator rect = rects->begin(); rect != rects->end(); ++rect) { +				int16 w  = rect->right  - rect->left; +				int16 h  = rect->bottom - rect->top; +				int16 wD = (rect->left * 2) + (w * 2); +				int16 hD = (rect->top  * 2) + (h * 2);  			_vm->_video->drawSpriteDouble(*_vm->_draw->_spritesArray[0], *_vm->_draw->_frontSurface, -					state.left, state.top, state.right, state.bottom, state.left, state.top, 0); +					rect->left, rect->top, rect->right - 1, rect->bottom - 1, rect->left, rect->top, 0);  			_vm->_draw->dirtiedRect(_vm->_draw->_frontSurface, -					state.left * 2, state.top * 2, wD, hD); -			*/ -			_vm->_video->retrace(); +					rect->left * 2, rect->top * 2, wD, hD); +			} +		} -			_vm->_util->processInput(); -			if (_vm->shouldQuit()) -				break; +		_vm->_video->retrace(); -			int16 key; -			bool end = false; -			while (_vm->_util->checkKey(key)) -				if (key == kKeyEscape) -					end = true; -			if (end) -				break; +		_vm->_util->processInput(); +		if (_vm->shouldQuit()) +			break; -			_vm->_vidPlayer->slotWaitEndFrame(); +		int16 key; +		bool end = false; +		while (_vm->_util->checkKey(key)) +			if (key == kKeyEscape) +				end = true; +		if (end) +			break; -		} +		_vm->_vidPlayer->waitEndFrame(slot);  	} +  }  void DemoPlayer::playADL(const Common::String &fileName, bool waitEsc, int32 repeat) { diff --git a/engines/gob/demos/demoplayer.h b/engines/gob/demos/demoplayer.h index f0672b9645..207b050363 100644 --- a/engines/gob/demos/demoplayer.h +++ b/engines/gob/demos/demoplayer.h @@ -59,8 +59,8 @@ protected:  	void playVideo(const char *fileName);  	void playADL(const char *params); -	void playVideoNormal(); -	void playVideoDoubled(); +	void playVideoNormal(int slot); +	void playVideoDoubled(int slot);  	void playADL(const Common::String &fileName, bool waitEsc = true, int32 repeat = -1);  private: diff --git a/engines/gob/videoplayer.cpp b/engines/gob/videoplayer.cpp index d0e61c84e3..35f423d2f4 100644 --- a/engines/gob/videoplayer.cpp +++ b/engines/gob/videoplayer.cpp @@ -40,7 +40,8 @@ namespace Gob {  VideoPlayer::Properties::Properties() : type(kVideoTypeTry), sprite(Draw::kFrontSurface),  	x(-1), y(-1), width(-1), height(-1), flags(kFlagFrontSurface),  	startFrame(-1), lastFrame(-1), endFrame(-1), breakKey(kShortKeyEscape), -	palCmd(8), palStart(0), palEnd(255), palFrame(-1), fade(false), canceled(false) { +	palCmd(8), palStart(0), palEnd(255), palFrame(-1), +	fade(false), waitEndFrame(true), canceled(false) {  } @@ -241,8 +242,8 @@ bool VideoPlayer::play(int slot, Properties &properties) {  			properties.fade = false;  		} -		if (!_noCursorSwitch) -			_vm->_util->delay(video->decoder->getTimeToNextFrame()); +		if (!_noCursorSwitch && properties.waitEndFrame) +			waitEndFrame(slot);  	}  	evalBgShading(*video); @@ -250,6 +251,14 @@ bool VideoPlayer::play(int slot, Properties &properties) {  	return true;  } +void VideoPlayer::waitEndFrame(int slot) { +	Video *video = getVideoBySlot(slot); +	if (!video) +		return; + +	_vm->_util->delay(video->decoder->getTimeToNextFrame()); +} +  bool VideoPlayer::playFrame(int slot, Properties &properties) {  	Video *video = getVideoBySlot(slot);  	if (!video) @@ -353,7 +362,7 @@ bool VideoPlayer::playFrame(int slot, Properties &properties) {  			_vm->_palAnim->fade(_vm->_global->_pPaletteDesc, -2, 0);  	} -	if (primary) +	if (primary && properties.waitEndFrame)  		checkAbort(*video, properties);  	return true; @@ -445,6 +454,14 @@ uint16 VideoPlayer::getDefaultY(int slot) const {  	return video->decoder->getDefaultY();  } +const Common::List<Common::Rect> *VideoPlayer::getDirtyRects(int slot) const { +	const Video *video = getVideoBySlot(slot); +	if (!video) +		return 0; + +	return &video->decoder->getDirtyRects(); +} +  bool VideoPlayer::hasEmbeddedFile(const Common::String &fileName, int slot) const {  	const Video *video = getVideoBySlot(slot);  	if (!video) diff --git a/engines/gob/videoplayer.h b/engines/gob/videoplayer.h index b932807d65..6f9d927739 100644 --- a/engines/gob/videoplayer.h +++ b/engines/gob/videoplayer.h @@ -27,6 +27,8 @@  #define GOB_VIDEOPLAYER_H  #include "common/array.h" +#include "common/list.h" +#include "common/rect.h"  #include "common/str.h"  #include "graphics/surface.h" @@ -85,6 +87,8 @@ public:  		bool fade; ///< Fade in? +		bool waitEndFrame; ///< Wait for the frame's time to run out? +  		bool canceled; ///< Was the video canceled?  		Properties(); @@ -99,6 +103,7 @@ public:  	bool closeVideo(int slot = 0);  	bool play(int slot, Properties &properties); +	void waitEndFrame(int slot);  	bool slotIsOpen(int slot = 0) const; @@ -111,6 +116,8 @@ public:  	uint16 getDefaultX    (int slot = 0) const;  	uint16 getDefaultY    (int slot = 0) const; +	const Common::List<Common::Rect> *getDirtyRects(int slot = 0) const; +  	bool                      hasEmbeddedFile(const Common::String &fileName, int slot = 0) const;  	Common::MemoryReadStream *getEmbeddedFile(const Common::String &fileName, int slot = 0);  | 
