From b80129dd446cbfd98a1cb14a1bac4ea4a97fffd7 Mon Sep 17 00:00:00 2001 From: Alyssa Milburn Date: Mon, 18 Jul 2011 21:58:59 +0200 Subject: COMPOSER: Move Button code around. --- engines/composer/composer.cpp | 170 +++++++++++++++++++++--------------------- 1 file changed, 85 insertions(+), 85 deletions(-) (limited to 'engines/composer') diff --git a/engines/composer/composer.cpp b/engines/composer/composer.cpp index 485932eaa4..c63e07d9ee 100644 --- a/engines/composer/composer.cpp +++ b/engines/composer/composer.cpp @@ -47,91 +47,6 @@ namespace Composer { -Button::Button(Common::SeekableReadStream *stream, uint16 id) { - _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(); - - switch (_type) { - case kButtonRect: - case kButtonEllipse: - if (size != 4) - error("button %d of type %d had %d points, not 4", id, _type, size); - _rect.left = stream->readSint16LE(); - _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: - for (uint i = 0; i < size; i++) { - _spriteIds.push_back(stream->readSint16LE()); - } - break; - default: - error("unknown button type %d", _type); - } - - delete stream; -} - -bool Button::contains(const Common::Point &pos) const { - switch (_type) { - case kButtonRect: - return _rect.contains(pos); - case kButtonEllipse: - if (!_rect.contains(pos)) - return false; - { - int16 a = _rect.width() / 2; - int16 b = _rect.height() / 2; - if (!a || !b) - return false; - Common::Point adjustedPos = pos - Common::Point(_rect.left + a, _rect.top + b); - return ((adjustedPos.x*adjustedPos.x)/(a*a) + (adjustedPos.y*adjustedPos.y)/(b*b) < 1); - } - case kButtonSprites: - return false; - default: - error("internal error (button type %d)", _type); - } -} - -const Button *ComposerEngine::getButtonFor(const Sprite *sprite, const Common::Point &pos) { - for (Common::List