diff options
Diffstat (limited to 'engines/composer/composer.cpp')
-rw-r--r-- | engines/composer/composer.cpp | 66 |
1 files changed, 43 insertions, 23 deletions
diff --git a/engines/composer/composer.cpp b/engines/composer/composer.cpp index cf773dc2dc..d9bb0cdc54 100644 --- a/engines/composer/composer.cpp +++ b/engines/composer/composer.cpp @@ -125,9 +125,9 @@ Common::Error ComposerEngine::run() { } if (lastDrawTime + frameTime <= thisTime) { - // catch up if we're more than 5 frames behind - if (lastDrawTime + (frameTime * 5) <= thisTime) - lastDrawTime = thisTime - (frameTime * 5); + // catch up if we're more than 2 frames behind + if (lastDrawTime + (frameTime * 2) <= thisTime) + lastDrawTime = thisTime; else lastDrawTime += frameTime; @@ -253,16 +253,15 @@ void ComposerEngine::setCursor(uint16 id, const Common::Point &offset) { } void ComposerEngine::setCursorVisible(bool visible) { - if (!_mouseSpriteId) - return; - if (visible && !_mouseVisible) { _mouseVisible = true; - addSprite(_mouseSpriteId, 0, 0, _lastMousePos - _mouseOffset); + if (_mouseSpriteId) + addSprite(_mouseSpriteId, 0, 0, _lastMousePos - _mouseOffset); onMouseMove(_lastMousePos); } else if (!visible && _mouseVisible) { _mouseVisible = false; - removeSprite(_mouseSpriteId, 0); + if (_mouseSpriteId) + removeSprite(_mouseSpriteId, 0); } } @@ -276,6 +275,11 @@ Common::String ComposerEngine::getStringFromConfig(const Common::String §ion Common::String ComposerEngine::getFilename(const Common::String §ion, uint id) { Common::String key = Common::String::format("%d", id); Common::String filename = getStringFromConfig(section, key); + + return mangleFilename(filename); +} + +Common::String ComposerEngine::mangleFilename(Common::String filename) { while (filename.size() && (filename[0] == '~' || filename[0] == ':' || filename[0] == '\\')) filename = filename.c_str() + 1; @@ -318,11 +322,11 @@ void ComposerEngine::loadLibrary(uint id) { for (uint i = 0; i < buttonResources.size(); i++) { uint16 buttonId = buttonResources[i]; Common::SeekableReadStream *stream = library._archive->getResource(ID_BUTN, buttonId); - Button button(stream, buttonId); + Button button(stream, buttonId, getGameType()); bool inserted = false; for (Common::List<Button>::iterator b = newLib._buttons.begin(); b != newLib._buttons.end(); b++) { - if (button._zorder <= b->_zorder) + if (button._zorder < b->_zorder) continue; newLib._buttons.insert(b, button); inserted = true; @@ -405,22 +409,32 @@ Common::SeekableReadStream *ComposerEngine::getResource(uint32 tag, uint16 id) { error("No loaded library contains '%s' %04x", tag2str(tag), id); } -Button::Button(Common::SeekableReadStream *stream, uint16 id) { +Button::Button(Common::SeekableReadStream *stream, uint16 id, uint gameType) { _id = id; _type = stream->readUint16LE(); _active = (_type & 0x8000) ? true : false; _type &= 0xfff; - debug(9, "button: type %d, active %d", _type, _active); - - _zorder = stream->readUint16LE(); - _scriptId = stream->readUint16LE(); - _scriptIdRollOn = stream->readUint16LE(); - _scriptIdRollOff = stream->readUint16LE(); - - stream->skip(4); - - uint16 size = stream->readUint16LE(); + debug(9, "button %d: type %d, active %d", id, _type, _active); + + uint16 flags = 0; + uint16 size = 4; + if (gameType == GType_ComposerV1) { + flags = stream->readUint16LE(); + _zorder = 0; + _scriptId = stream->readUint16LE(); + _scriptIdRollOn = 0; + _scriptIdRollOff = 0; + } else { + _zorder = stream->readUint16LE(); + _scriptId = stream->readUint16LE(); + _scriptIdRollOn = stream->readUint16LE(); + _scriptIdRollOff = stream->readUint16LE(); + + stream->skip(4); + + size = stream->readUint16LE(); + } switch (_type) { case kButtonRect: @@ -431,17 +445,23 @@ Button::Button(Common::SeekableReadStream *stream, uint16 id) { _rect.top = stream->readSint16LE(); _rect.right = stream->readSint16LE(); _rect.bottom = stream->readSint16LE(); - debug(9, "button: (%d, %d, %d, %d)", _rect.left, _rect.top, _rect.right, _rect.bottom); break; case kButtonSprites: + if (gameType == GType_ComposerV1) + error("encountered kButtonSprites in V1 data"); for (uint i = 0; i < size; i++) { - _spriteIds.push_back(stream->readSint16LE()); + _spriteIds.push_back(stream->readUint16LE()); } break; default: error("unknown button type %d", _type); } + if (flags & 0x40) { + _scriptIdRollOn = stream->readUint16LE(); + _scriptIdRollOff = stream->readUint16LE(); + } + delete stream; } |