diff options
author | Alyssa Milburn | 2011-07-19 21:53:16 +0200 |
---|---|---|
committer | Alyssa Milburn | 2011-07-19 21:53:16 +0200 |
commit | 78cb4919c659c0cc9004a0a5247141b3de649220 (patch) | |
tree | 69562abf271b3421675c91bb5e47af461c0e277b /engines/composer | |
parent | 0706588388be81aa96073777585bc3e79095c97b (diff) | |
download | scummvm-rg350-78cb4919c659c0cc9004a0a5247141b3de649220.tar.gz scummvm-rg350-78cb4919c659c0cc9004a0a5247141b3de649220.tar.bz2 scummvm-rg350-78cb4919c659c0cc9004a0a5247141b3de649220.zip |
COMPOSER: Buttons belong to libraries.
Diffstat (limited to 'engines/composer')
-rw-r--r-- | engines/composer/composer.cpp | 38 | ||||
-rw-r--r-- | engines/composer/composer.h | 3 | ||||
-rw-r--r-- | engines/composer/scripting.cpp | 20 |
3 files changed, 35 insertions, 26 deletions
diff --git a/engines/composer/composer.cpp b/engines/composer/composer.cpp index 17e47257c2..70a54846ba 100644 --- a/engines/composer/composer.cpp +++ b/engines/composer/composer.cpp @@ -315,6 +315,8 @@ void ComposerEngine::loadLibrary(uint id) { error("failed to open '%s'", filename.c_str()); _libraries.push_front(library); + Library &newLib = _libraries.front(); + Common::Array<uint16> buttonResources = library._archive->getResourceIDList(ID_BUTN); for (uint i = 0; i < buttonResources.size(); i++) { uint16 buttonId = buttonResources[i]; @@ -322,15 +324,15 @@ void ComposerEngine::loadLibrary(uint id) { Button button(stream, buttonId); bool inserted = false; - for (Common::List<Button>::iterator b = _buttons.begin(); b != _buttons.end(); b++) { + for (Common::List<Button>::iterator b = newLib._buttons.begin(); b != newLib._buttons.end(); b++) { if (button._zorder <= b->_zorder) continue; - _buttons.insert(b, button); + newLib._buttons.insert(b, button); inserted = true; break; } if (!inserted) - _buttons.push_back(button); + newLib._buttons.push_back(button); } // add background sprite, if it exists @@ -367,7 +369,7 @@ void ComposerEngine::unloadLibrary(uint id) { j->_surface.free(); } _sprites.clear(); - _buttons.clear(); + i->_buttons.clear(); _lastButton = NULL; @@ -469,22 +471,24 @@ bool Button::contains(const Common::Point &pos) const { } const Button *ComposerEngine::getButtonFor(const Sprite *sprite, const Common::Point &pos) { - for (Common::List<Button>::iterator i = _buttons.reverse_begin(); i != _buttons.end(); --i) { - if (!i->_active) - continue; + for (Common::List<Library>::iterator l = _libraries.begin(); l != _libraries.end(); l++) { + for (Common::List<Button>::iterator i = l->_buttons.reverse_begin(); i != l->_buttons.end(); --i) { + if (!i->_active) + continue; - if (i->_spriteIds.empty()) { - if (i->contains(pos)) - return &(*i); - continue; - } + if (i->_spriteIds.empty()) { + if (i->contains(pos)) + return &(*i); + continue; + } - if (!sprite) - continue; + if (!sprite) + continue; - for (uint j = 0; j < i->_spriteIds.size(); j++) { - if (i->_spriteIds[j] == sprite->_id) - return &(*i); + for (uint j = 0; j < i->_spriteIds.size(); j++) { + if (i->_spriteIds[j] == sprite->_id) + return &(*i); + } } } diff --git a/engines/composer/composer.h b/engines/composer/composer.h index c1cf8326cb..ab70c864bc 100644 --- a/engines/composer/composer.h +++ b/engines/composer/composer.h @@ -100,6 +100,8 @@ enum { struct Library { uint _id; Archive *_archive; + + Common::List<Button> _buttons; }; struct QueuedScript { @@ -143,7 +145,6 @@ private: bool _needsUpdate; Graphics::Surface _surface; - Common::List<Button> _buttons; Common::List<Sprite> _sprites; uint _directoriesToStrip; diff --git a/engines/composer/scripting.cpp b/engines/composer/scripting.cpp index 3c951f9d8f..497d40b5d8 100644 --- a/engines/composer/scripting.cpp +++ b/engines/composer/scripting.cpp @@ -564,19 +564,23 @@ int16 ComposerEngine::scriptFuncCall(uint16 id, int16 param1, int16 param2, int1 return 0; case kFuncActivateButton: debug(3, "kFuncActivateButton(%d)", param1); - for (Common::List<Button>::iterator i = _buttons.begin(); i != _buttons.end(); i++) { - if (i->_id != param1) - continue; - i->_active = true; + for (Common::List<Library>::iterator l = _libraries.begin(); l != _libraries.end(); l++) { + for (Common::List<Button>::iterator i = l->_buttons.begin(); i != l->_buttons.end(); i++) { + if (i->_id != param1) + continue; + i->_active = true; + } } onMouseMove(_lastMousePos); return 1; case kFuncDeactivateButton: debug(3, "kFuncDeactivateButton(%d)", param1); - for (Common::List<Button>::iterator i = _buttons.begin(); i != _buttons.end(); i++) { - if (i->_id != param1) - continue; - i->_active = false; + for (Common::List<Library>::iterator l = _libraries.begin(); l != _libraries.end(); l++) { + for (Common::List<Button>::iterator i = l->_buttons.begin(); i != l->_buttons.end(); i++) { + if (i->_id != param1) + continue; + i->_active = false; + } } onMouseMove(_lastMousePos); return 1; |