diff options
author | Alyssa Milburn | 2011-07-07 16:21:09 +0200 |
---|---|---|
committer | Alyssa Milburn | 2011-07-07 16:23:10 +0200 |
commit | f0bef196b19802b2ad544775ee80acfafb057bbf (patch) | |
tree | 0fc7d89e0c7de1f9b3b1e974a7949456b4a06b47 /engines/mohawk/livingbooks.cpp | |
parent | e3558e56d7b94fce8a561eb52c4c02c73ab74091 (diff) | |
download | scummvm-rg350-f0bef196b19802b2ad544775ee80acfafb057bbf.tar.gz scummvm-rg350-f0bef196b19802b2ad544775ee80acfafb057bbf.tar.bz2 scummvm-rg350-f0bef196b19802b2ad544775ee80acfafb057bbf.zip |
MOHAWK: Maintain ordered list of LB items.
Diffstat (limited to 'engines/mohawk/livingbooks.cpp')
-rw-r--r-- | engines/mohawk/livingbooks.cpp | 14 |
1 files changed, 11 insertions, 3 deletions
diff --git a/engines/mohawk/livingbooks.cpp b/engines/mohawk/livingbooks.cpp index f9d18ff7ff..dd7bc9a839 100644 --- a/engines/mohawk/livingbooks.cpp +++ b/engines/mohawk/livingbooks.cpp @@ -204,9 +204,12 @@ Common::Error MohawkEngine_LivingBooks::run() { break; case Common::EVENT_LBUTTONDOWN: - for (uint16 i = 0; i < _items.size(); i++) - if (_items[i]->contains(event.mouse)) - found = _items[i]; + for (Common::List<LBItem *>::const_iterator i = _orderedItems.begin(); i != _orderedItems.end(); ++i) { + if ((*i)->contains(event.mouse)) { + found = *i; + break; + } + } if (found) found->handleMouseDown(event.mouse); @@ -341,6 +344,7 @@ void MohawkEngine_LivingBooks::destroyPage() { delete _page; assert(_items.empty()); + assert(_orderedItems.empty()); _page = NULL; _notifyEvents.clear(); @@ -567,6 +571,7 @@ void MohawkEngine_LivingBooks::updatePage() { case kLBDelayedEventDestroy: _items.remove_at(i); i--; + _orderedItems.remove(delayedEvent.item); delete delayedEvent.item; _page->itemDestroyed(delayedEvent.item); if (_focus == delayedEvent.item) @@ -613,6 +618,8 @@ void MohawkEngine_LivingBooks::removeArchive(Archive *archive) { void MohawkEngine_LivingBooks::addItem(LBItem *item) { _items.push_back(item); + _orderedItems.push_front(item); + item->_iterator = _orderedItems.begin(); } void MohawkEngine_LivingBooks::removeItems(const Common::Array<LBItem *> &items) { @@ -626,6 +633,7 @@ void MohawkEngine_LivingBooks::removeItems(const Common::Array<LBItem *> &items) break; } assert(found); + _orderedItems.erase(items[i]->_iterator); } } |