diff options
-rw-r--r-- | engines/mohawk/livingbooks.cpp | 40 | ||||
-rw-r--r-- | engines/mohawk/livingbooks.h | 6 | ||||
-rw-r--r-- | engines/mohawk/livingbooks_code.cpp | 36 | ||||
-rw-r--r-- | engines/mohawk/livingbooks_code.h | 1 |
4 files changed, 81 insertions, 2 deletions
diff --git a/engines/mohawk/livingbooks.cpp b/engines/mohawk/livingbooks.cpp index f2d66ccf03..f0d918129e 100644 --- a/engines/mohawk/livingbooks.cpp +++ b/engines/mohawk/livingbooks.cpp @@ -2659,6 +2659,14 @@ void LBItem::unload() { // FIXME: stuff } +void LBItem::moveBy(const Common::Point &pos) { + _rect.translate(pos.x, pos.y); +} + +void LBItem::moveTo(const Common::Point &pos) { + _rect.moveTo(pos); +} + void LBItem::runScript(uint event, uint16 data, uint16 from) { for (uint i = 0; i < _scriptEntries.size(); i++) { LBScriptEntry *entry = _scriptEntries[i]; @@ -3179,6 +3187,38 @@ void LBGroupItem::stop() { } } +void LBGroupItem::load() { + for (uint i = 0; i < _groupEntries.size(); i++) { + LBItem *item = _vm->getItemById(_groupEntries[i].entryId); + if (item) + item->load(); + } +} + +void LBGroupItem::unload() { + for (uint i = 0; i < _groupEntries.size(); i++) { + LBItem *item = _vm->getItemById(_groupEntries[i].entryId); + if (item) + item->unload(); + } +} + +void LBGroupItem::moveBy(const Common::Point &pos) { + for (uint i = 0; i < _groupEntries.size(); i++) { + LBItem *item = _vm->getItemById(_groupEntries[i].entryId); + if (item) + item->moveBy(pos); + } +} + +void LBGroupItem::moveTo(const Common::Point &pos) { + for (uint i = 0; i < _groupEntries.size(); i++) { + LBItem *item = _vm->getItemById(_groupEntries[i].entryId); + if (item) + item->moveTo(pos); + } +} + LBPaletteItem::LBPaletteItem(MohawkEngine_LivingBooks *vm, LBPage *page, Common::Rect rect) : LBItem(vm, page, rect) { debug(3, "new LBPaletteItem"); diff --git a/engines/mohawk/livingbooks.h b/engines/mohawk/livingbooks.h index 39bd9cab30..e79d134017 100644 --- a/engines/mohawk/livingbooks.h +++ b/engines/mohawk/livingbooks.h @@ -403,6 +403,8 @@ public: virtual void notify(uint16 data, uint16 from); // 0x1A virtual void load(); virtual void unload(); + virtual void moveBy(const Common::Point &pos); + virtual void moveTo(const Common::Point &pos); uint16 getId() { return _itemId; } const Common::String &getName() { return _desc; } @@ -482,6 +484,10 @@ public: void setGlobalVisible(bool visible); void startPhase(uint phase); void stop(); + void load(); + void unload(); + void moveBy(const Common::Point &pos); + void moveTo(const Common::Point &pos); protected: bool _starting; diff --git a/engines/mohawk/livingbooks_code.cpp b/engines/mohawk/livingbooks_code.cpp index d0feffde35..60ace17205 100644 --- a/engines/mohawk/livingbooks_code.cpp +++ b/engines/mohawk/livingbooks_code.cpp @@ -767,7 +767,7 @@ CodeCommandInfo generalCommandInfo[NUM_GENERAL_COMMANDS] = { { "xpos", 0 }, { "ypos", 0 }, { "playFrom", 0 }, - { "move", 0 }, + { "move", &LBCode::cmdMove }, { 0, 0 }, { 0, 0 }, { "setDragParams", &LBCode::cmdSetDragParams }, @@ -1053,6 +1053,24 @@ void LBCode::cmdRight(const Common::Array<LBValue> ¶ms) { _stack.push(rect.right); } +void LBCode::cmdMove(const Common::Array<LBValue> ¶ms) { + if (params.size() != 1 && params.size() != 2) + error("incorrect number of parameters (%d) to move", params.size()); + + LBItem *target = _currSource; + Common::Point pt; + if (params.size() == 1) { + pt = params[0].toPoint(); + } else { + target = resolveItem(params[0]); + if (!target) + error("attempted move on invalid item (%s)", params[0].toString().c_str()); + pt = params[1].toPoint(); + } + + target->moveBy(pt); +} + void LBCode::cmdSetDragParams(const Common::Array<LBValue> ¶ms) { warning("ignoring setDragParams"); } @@ -1224,7 +1242,21 @@ void LBCode::itemIsPlaying(const Common::Array<LBValue> ¶ms) { } void LBCode::itemMoveTo(const Common::Array<LBValue> ¶ms) { - warning("ignoring moveTo"); + if (params.size() != 1 && params.size() != 2) + error("incorrect number of parameters (%d) to moveTo", params.size()); + + LBItem *target = _currSource; + Common::Point pt; + if (params.size() == 1) { + pt = params[0].toPoint(); + } else { + target = resolveItem(params[0]); + if (!target) + error("attempted moveTo on invalid item (%s)", params[0].toString().c_str()); + pt = params[1].toPoint(); + } + + target->moveTo(pt); } void LBCode::itemSeek(const Common::Array<LBValue> ¶ms) { diff --git a/engines/mohawk/livingbooks_code.h b/engines/mohawk/livingbooks_code.h index 973a674fdd..bfe047bf23 100644 --- a/engines/mohawk/livingbooks_code.h +++ b/engines/mohawk/livingbooks_code.h @@ -262,6 +262,7 @@ public: void cmdLeft(const Common::Array<LBValue> ¶ms); void cmdBottom(const Common::Array<LBValue> ¶ms); void cmdRight(const Common::Array<LBValue> ¶ms); + void cmdMove(const Common::Array<LBValue> ¶ms); void cmdSetDragParams(const Common::Array<LBValue> ¶ms); void cmdNewList(const Common::Array<LBValue> ¶ms); void cmdListLen(const Common::Array<LBValue> ¶ms); |