[Scummvm-cvs-logs] scummvm master -> 1e9ea0849516c545ce9f6f943f154c31597be8ef

fuzzie fuzzie at fuzzie.org
Sun Nov 27 21:04:59 CET 2011


This automated email contains information about 1 new commit which have been
pushed to the 'scummvm' repo located at https://github.com/scummvm/scummvm .

Summary:
1e9ea08495 MOHAWK: Fix LBCode seek/seekToFrame.


Commit: 1e9ea0849516c545ce9f6f943f154c31597be8ef
    https://github.com/scummvm/scummvm/commit/1e9ea0849516c545ce9f6f943f154c31597be8ef
Author: Alyssa Milburn (fuzzie at fuzzie.org)
Date: 2011-11-27T12:02:13-08:00

Commit Message:
MOHAWK: Fix LBCode seek/seekToFrame.

Changed paths:
    engines/mohawk/livingbooks.cpp
    engines/mohawk/livingbooks.h
    engines/mohawk/livingbooks_code.cpp
    engines/mohawk/livingbooks_code.h



diff --git a/engines/mohawk/livingbooks.cpp b/engines/mohawk/livingbooks.cpp
index d0c8bf3..486ecb5 100644
--- a/engines/mohawk/livingbooks.cpp
+++ b/engines/mohawk/livingbooks.cpp
@@ -1859,6 +1859,35 @@ void LBAnimation::seek(uint16 pos) {
 	}
 }
 
+void LBAnimation::seekToTime(uint32 time) {
+	_lastTime = 0;
+	_currentFrame = 0;
+
+	if (_currentSound != 0xffff) {
+		_vm->_sound->stopSound(_currentSound);
+		_currentSound = 0xffff;
+	}
+
+	for (uint32 i = 0; i < _nodes.size(); i++)
+		_nodes[i]->reset();
+
+	uint32 elapsed = 0;
+	while (elapsed <= time) {
+		bool ranSomething = false;
+		// nodes don't wait while seeking
+		for (uint32 i = 0; i < _nodes.size(); i++)
+			ranSomething |= (_nodes[i]->update(true) != kLBNodeDone);
+
+		elapsed += _tempo;
+		_currentFrame++;
+
+		if (!ranSomething) {
+			_running = false;
+			break;
+		}
+	}
+}
+
 void LBAnimation::stop() {
 	_running = false;
 	if (_currentSound != 0xffff) {
@@ -3612,6 +3641,10 @@ void LBAnimationItem::seek(uint16 pos) {
 	_anim->seek(pos);
 }
 
+void LBAnimationItem::seekToTime(uint32 time) {
+	_anim->seekToTime(time);
+}
+
 void LBAnimationItem::startPhase(uint phase) {
 	if (phase == _phase)
 		seek(1);
diff --git a/engines/mohawk/livingbooks.h b/engines/mohawk/livingbooks.h
index 975a5f9..39bd9ca 100644
--- a/engines/mohawk/livingbooks.h
+++ b/engines/mohawk/livingbooks.h
@@ -331,6 +331,7 @@ public:
 
 	void start();
 	void seek(uint16 pos);
+	void seekToTime(uint32 time);
 	void stop();
 
 	void playSound(uint16 resourceId);
@@ -393,6 +394,7 @@ public:
 	virtual void done(bool onlyNotify); // 0x10
 	virtual void init(); // 0x11
 	virtual void seek(uint16 pos) { } // 0x13
+	virtual void seekToTime(uint32 time) { }
 	virtual void setFocused(bool focused) { } // 0x14
 	virtual void setVisible(bool visible); // 0x17
 	virtual void setGlobalVisible(bool enabled);
@@ -567,6 +569,7 @@ public:
 	void done(bool onlyNotify);
 	void init();
 	void seek(uint16 pos);
+	void seekToTime(uint32 time);
 	void startPhase(uint phase);
 	void stop();
 
diff --git a/engines/mohawk/livingbooks_code.cpp b/engines/mohawk/livingbooks_code.cpp
index f16fd40..836ad8c 100644
--- a/engines/mohawk/livingbooks_code.cpp
+++ b/engines/mohawk/livingbooks_code.cpp
@@ -1177,7 +1177,7 @@ CodeCommandInfo itemCommandInfo[NUM_ITEM_COMMANDS] = {
 	{ "mute", 0 },
 	{ "play", 0 },
 	{ "seek", &LBCode::itemSeek },
-	{ "seekToFrame", 0 },
+	{ "seekToFrame", &LBCode::itemSeekToFrame },
 	{ "setParent", &LBCode::itemSetParent },
 	{ "setZOrder", 0 },
 	{ "setText", 0 },
@@ -1220,6 +1220,17 @@ void LBCode::itemSeek(const Common::Array<LBValue> &params) {
 	if (!item)
 		error("attempted seek on invalid item (%s)", params[0].toString().c_str());
 	uint seekTo = params[1].toInt();
+	item->seekToTime(seekTo);
+}
+
+void LBCode::itemSeekToFrame(const Common::Array<LBValue> &params) {
+	if (params.size() != 2)
+		error("incorrect number of parameters (%d) to seekToFrame", params.size());
+
+	LBItem *item = resolveItem(params[0]);
+	if (!item)
+		error("attempted seekToFrame on invalid item (%s)", params[0].toString().c_str());
+	uint seekTo = params[1].toInt();
 	item->seek(seekTo);
 }
 
diff --git a/engines/mohawk/livingbooks_code.h b/engines/mohawk/livingbooks_code.h
index 6d3812a..e866fca 100644
--- a/engines/mohawk/livingbooks_code.h
+++ b/engines/mohawk/livingbooks_code.h
@@ -275,6 +275,7 @@ public:
 	void itemIsPlaying(const Common::Array<LBValue> &params);
 	void itemMoveTo(const Common::Array<LBValue> &params);
 	void itemSeek(const Common::Array<LBValue> &params);
+	void itemSeekToFrame(const Common::Array<LBValue> &params);
 	void itemSetParent(const Common::Array<LBValue> &params);
 };
 






More information about the Scummvm-git-logs mailing list