[Scummvm-git-logs] scummvm master -> 7b9afc37ce87f05d72f42980fe8eff1ad57478dd

stevenhoefel stevenhoefel at hotmail.com
Mon Apr 3 03:33:14 CEST 2017


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:
7b9afc37ce DIRECTOR: Pre-load Button child text members.


Commit: 7b9afc37ce87f05d72f42980fe8eff1ad57478dd
    https://github.com/scummvm/scummvm/commit/7b9afc37ce87f05d72f42980fe8eff1ad57478dd
Author: stevenhoefel (stevenhoefel at hotmail.com)
Date: 2017-04-03T11:33:02+10:00

Commit Message:
DIRECTOR: Pre-load Button child text members.

Changed paths:
    engines/director/archive.cpp
    engines/director/archive.h
    engines/director/frame.cpp
    engines/director/score.cpp


diff --git a/engines/director/archive.cpp b/engines/director/archive.cpp
index bcd064b..ea25dc7 100644
--- a/engines/director/archive.cpp
+++ b/engines/director/archive.cpp
@@ -298,6 +298,7 @@ bool RIFFArchive::openStream(Common::SeekableReadStream *stream, uint32 startOff
 		res.offset = offset;
 		res.size = size;
 		res.name = name;
+		res.tag = tag;
 	}
 
 	_stream = stream;
@@ -402,6 +403,7 @@ bool RIFXArchive::openStream(Common::SeekableReadStream *stream, uint32 startOff
 		Resource res;
 		res.offset = offset;
 		res.size = size;
+		res.tag = tag;
 		resources.push_back(res);
 
 		// APPL is a special case; it has an embedded "normal" archive
diff --git a/engines/director/archive.h b/engines/director/archive.h
index 28be6cf..4549e1e 100644
--- a/engines/director/archive.h
+++ b/engines/director/archive.h
@@ -39,6 +39,7 @@ struct Resource {
 	uint32 offset;
 	uint32 size;
 	uint32 castId;
+	uint32 tag;
 	Common::String name;
 	Common::Array<Resource> children;
 };
diff --git a/engines/director/frame.cpp b/engines/director/frame.cpp
index 92aa851..e2f3b4c 100644
--- a/engines/director/frame.cpp
+++ b/engines/director/frame.cpp
@@ -559,7 +559,6 @@ void Frame::renderSprites(Graphics::ManagedSurface &surface, bool renderTrail) {
 				continue;
 
 			CastType castType = kCastTypeNull;
-			Cast *cast = nullptr;
 			if (_vm->getVersion() < 4) {
 				debugC(1, kDebugImages, "Channel: %d type: %d", i, _sprites[i]->_spriteType);
 				switch (_sprites[i]->_spriteType) {
@@ -594,9 +593,9 @@ void Frame::renderSprites(Graphics::ManagedSurface &surface, bool renderTrail) {
 			if (castType == kCastShape) {
 				renderShape(surface, i);
 			} else if (castType == kCastText) {
-				renderText(surface, i, _vm->getVersion() < 4 ? _sprites[i]->_castId + 1024 : cast->children[0].index);
+				renderText(surface, i, _vm->getVersion() < 4 ? _sprites[i]->_castId + 1024 : _sprites[i]->_textCast->children[0].index);
 			} else if (castType == kCastButton) {
-				renderButton(surface, i, _vm->getVersion() < 4 ? _sprites[i]->_castId + 1024 : cast->children[0].index);
+				renderButton(surface, i, _vm->getVersion() < 4 ? _sprites[i]->_castId + 1024 : _sprites[i]->_buttonCast->children[0].index);
 			} else {
 				if (!_sprites[i]->_bitmapCast) {
 					warning("No cast ID for sprite %d", i);
@@ -742,8 +741,7 @@ void Frame::renderText(Graphics::ManagedSurface &surface, uint16 spriteId, Commo
 	if (textStream == NULL)
 		return;
 
-	uint16 castId = _sprites[spriteId]->_castId;
-	TextCast *textCast = _vm->getCurrentScore()->_loadedText->getVal(castId);
+	TextCast *textCast = _sprites[spriteId]->_textCast;
 
 	uint32 unk1 = textStream->readUint32();
 	uint32 strLen = textStream->readUint32();
diff --git a/engines/director/score.cpp b/engines/director/score.cpp
index 3ab17fc..e8210b5 100644
--- a/engines/director/score.cpp
+++ b/engines/director/score.cpp
@@ -430,8 +430,21 @@ void Score::setSpriteCasts() {
 
 			if (_vm->getSharedScore()->_loadedButtons->contains(castId)) {
 				_frames[i]->_sprites[j]->_buttonCast = _vm->getSharedScore()->_loadedButtons->getVal(castId);
+				if (_frames[i]->_sprites[j]->_buttonCast->children.size() == 1) {
+					_frames[i]->_sprites[j]->_textCast = 
+						_vm->getSharedScore()->_loadedText->getVal(_frames[i]->_sprites[j]->_buttonCast->children[0].index);
+				} else if (_frames[i]->_sprites[j]->_buttonCast->children.size() > 0) {
+					warning("Cast %d has too many children!", j);
+				}
 			} else if (_loadedButtons->contains(castId)) {
 				_frames[i]->_sprites[j]->_buttonCast = _loadedButtons->getVal(castId);
+				if (_frames[i]->_sprites[j]->_buttonCast->children.size() == 1) {
+					Resource child = _frames[i]->_sprites[j]->_buttonCast->children[0];
+					_loadedText->setVal(child.index, new TextCast(*_movieArchive->getResource(child.tag, child.index), _vm->getVersion()));
+					_frames[i]->_sprites[j]->_textCast = _loadedText->getVal(child.index);
+				} else if (_frames[i]->_sprites[j]->_buttonCast->children.size() > 0) {
+					warning("Cast %d has too many children!", j);
+				}
 			}
 
 			//if (_loadedScripts->contains(castId))
@@ -521,6 +534,8 @@ void Score::loadCastData(Common::SeekableSubReadStreamEndian &stream, uint16 id,
 		break;
 	case kCastButton:
 		_loadedButtons->setVal(id, new ButtonCast(castStream, _vm->getVersion()));
+		for (uint child = 0; child < res->children.size(); child++)
+			_loadedButtons->getVal(id)->children.push_back(res->children[child]);
 		_castTypes[id] = kCastButton;
 		break;
 	case kCastLingoScript:





More information about the Scummvm-git-logs mailing list