aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlyssa Milburn2011-11-04 12:25:37 +0100
committerAlyssa Milburn2011-11-04 12:25:37 +0100
commitbee2e69e117af5205e96083cb7b0b128dd891e0c (patch)
tree64425b4044b69487cb879953355a001cc33ecf47
parentdbba1e08fedf9a345b6e6765c0dcd18e3b49307b (diff)
downloadscummvm-rg350-bee2e69e117af5205e96083cb7b0b128dd891e0c.tar.gz
scummvm-rg350-bee2e69e117af5205e96083cb7b0b128dd891e0c.tar.bz2
scummvm-rg350-bee2e69e117af5205e96083cb7b0b128dd891e0c.zip
COMPOSER: Factor out button activation code.
-rw-r--r--engines/composer/composer.cpp12
-rw-r--r--engines/composer/composer.h1
-rw-r--r--engines/composer/scripting.cpp18
3 files changed, 15 insertions, 16 deletions
diff --git a/engines/composer/composer.cpp b/engines/composer/composer.cpp
index 595c2eca46..c2ebed32b6 100644
--- a/engines/composer/composer.cpp
+++ b/engines/composer/composer.cpp
@@ -571,4 +571,16 @@ const Button *ComposerEngine::getButtonFor(const Sprite *sprite, const Common::P
return NULL;
}
+void ComposerEngine::setButtonActive(uint16 id, bool active) {
+ 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 != id)
+ continue;
+ i->_active = active;
+ }
+ }
+
+ onMouseMove(_lastMousePos);
+}
+
} // End of namespace Composer
diff --git a/engines/composer/composer.h b/engines/composer/composer.h
index 1816d89d60..da146227e9 100644
--- a/engines/composer/composer.h
+++ b/engines/composer/composer.h
@@ -216,6 +216,7 @@ private:
void removeSprite(uint16 id, uint16 animId);
const Sprite *getSpriteAtPos(const Common::Point &pos);
const Button *getButtonFor(const Sprite *sprite, const Common::Point &pos);
+ void setButtonActive(uint16 id, bool active);
void dirtySprite(const Sprite &sprite);
void redraw();
diff --git a/engines/composer/scripting.cpp b/engines/composer/scripting.cpp
index 41e9151279..3f692c5d4e 100644
--- a/engines/composer/scripting.cpp
+++ b/engines/composer/scripting.cpp
@@ -570,25 +570,11 @@ int16 ComposerEngine::scriptFuncCall(uint16 id, int16 param1, int16 param2, int1
return 0;
case kFuncActivateButton:
debug(3, "kFuncActivateButton(%d)", param1);
- 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);
+ setButtonActive(param1, true);
return 1;
case kFuncDeactivateButton:
debug(3, "kFuncDeactivateButton(%d)", param1);
- 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);
+ setButtonActive(param1, false);
return 1;
case kFuncNewPage:
debug(3, "kFuncNewPage(%d, %d)", param1, param2);