aboutsummaryrefslogtreecommitdiff
path: root/engines
diff options
context:
space:
mode:
authorAlyssa Milburn2011-12-08 23:23:35 +0100
committerAlyssa Milburn2011-12-08 23:23:35 +0100
commit99d3b7b5c3042dcd0857aa733e2d43ed17864c0f (patch)
treeb964bc7acac20dd8c325a45ca862bba7f4ea212d /engines
parent64c5a12d604f09a1c0322b698f35136d46b4d621 (diff)
downloadscummvm-rg350-99d3b7b5c3042dcd0857aa733e2d43ed17864c0f.tar.gz
scummvm-rg350-99d3b7b5c3042dcd0857aa733e2d43ed17864c0f.tar.bz2
scummvm-rg350-99d3b7b5c3042dcd0857aa733e2d43ed17864c0f.zip
MOHAWK: Stub LB clone command.
Diffstat (limited to 'engines')
-rw-r--r--engines/mohawk/livingbooks.cpp63
-rw-r--r--engines/mohawk/livingbooks.h26
-rw-r--r--engines/mohawk/livingbooks_code.cpp13
-rw-r--r--engines/mohawk/livingbooks_code.h1
4 files changed, 102 insertions, 1 deletions
diff --git a/engines/mohawk/livingbooks.cpp b/engines/mohawk/livingbooks.cpp
index bcc13e2707..08f3b86c7c 100644
--- a/engines/mohawk/livingbooks.cpp
+++ b/engines/mohawk/livingbooks.cpp
@@ -107,6 +107,11 @@ void LBPage::open(Archive *mhk, uint16 baseId) {
_items[i]->startPhase(kLBPhaseLoad);
}
+void LBPage::addClonedItem(LBItem *item) {
+ _vm->addItem(item);
+ _items.push_back(item);
+}
+
void LBPage::itemDestroyed(LBItem *item) {
for (uint i = 0; i < _items.size(); i++)
if (item == _items[i]) {
@@ -2670,6 +2675,24 @@ void LBItem::moveTo(const Common::Point &pos) {
_rect.moveTo(pos);
}
+LBItem *LBItem::clone(uint16 newId, const Common::String &newName) {
+ LBItem *item = createClone();
+
+ item->_itemId = newId;
+ item->_desc = newName;
+
+ item->_resourceId = _resourceId;
+ // FIXME: the rest
+
+ _page->addClonedItem(item);
+ // FIXME: zorder?
+ return item;
+}
+
+LBItem *LBItem::createClone() {
+ return new LBItem(_vm, _page, _rect);
+}
+
void LBItem::runScript(uint event, uint16 data, uint16 from) {
for (uint i = 0; i < _scriptEntries.size(); i++) {
LBScriptEntry *entry = _scriptEntries[i];
@@ -3075,6 +3098,10 @@ void LBSoundItem::stop() {
LBItem::stop();
}
+LBItem *LBSoundItem::createClone() {
+ return new LBSoundItem(_vm, _page, _rect);
+}
+
LBGroupItem::LBGroupItem(MohawkEngine_LivingBooks *vm, LBPage *page, Common::Rect rect) : LBItem(vm, page, rect) {
debug(3, "new LBGroupItem");
_starting = false;
@@ -3222,6 +3249,12 @@ void LBGroupItem::moveTo(const Common::Point &pos) {
}
}
+LBItem *LBGroupItem::createClone() {
+ // TODO: needed?
+ error("LBGroupItem::createClone unimplemented");
+ return new LBGroupItem(_vm, _page, _rect);
+}
+
LBPaletteItem::LBPaletteItem(MohawkEngine_LivingBooks *vm, LBPage *page, Common::Rect rect) : LBItem(vm, page, rect) {
debug(3, "new LBPaletteItem");
@@ -3307,6 +3340,10 @@ void LBPaletteItem::update() {
LBItem::update();
}
+LBItem *LBPaletteItem::createClone() {
+ error("can't clone LBPaletteItem");
+}
+
LBLiveTextItem::LBLiveTextItem(MohawkEngine_LivingBooks *vm, LBPage *page, Common::Rect rect) : LBItem(vm, page, rect) {
_currentPhrase = 0xFFFF;
_currentWord = 0xFFFF;
@@ -3554,6 +3591,10 @@ void LBLiveTextItem::notify(uint16 data, uint16 from) {
LBItem::notify(data, from);
}
+LBItem *LBLiveTextItem::createClone() {
+ error("can't clone LBLiveTextItem");
+}
+
LBPictureItem::LBPictureItem(MohawkEngine_LivingBooks *vm, LBPage *page, Common::Rect rect) : LBItem(vm, page, rect) {
debug(3, "new LBPictureItem");
}
@@ -3599,6 +3640,10 @@ void LBPictureItem::draw() {
_vm->_gfx->copyAnimImageToScreen(_resourceId, _rect.left, _rect.top);
}
+LBItem *LBPictureItem::createClone() {
+ return new LBPictureItem(_vm, _page, _rect);
+}
+
LBAnimationItem::LBAnimationItem(MohawkEngine_LivingBooks *vm, LBPage *page, Common::Rect rect) : LBItem(vm, page, rect) {
_anim = NULL;
_running = false;
@@ -3704,6 +3749,12 @@ void LBAnimationItem::draw() {
_anim->draw();
}
+LBItem *LBAnimationItem::createClone() {
+ LBAnimationItem *item = new LBAnimationItem(_vm, _page, _rect);
+ item->_anim = new LBAnimation(_vm, item, _resourceId);
+ return item;
+}
+
LBMovieItem::LBMovieItem(MohawkEngine_LivingBooks *vm, LBPage *page, Common::Rect rect) : LBItem(vm, page, rect) {
debug(3, "new LBMovieItem");
}
@@ -3733,6 +3784,10 @@ bool LBMovieItem::togglePlaying(bool playing, bool restart) {
return LBItem::togglePlaying(playing, restart);
}
+LBItem *LBMovieItem::createClone() {
+ return new LBMovieItem(_vm, _page, _rect);
+}
+
LBMiniGameItem::LBMiniGameItem(MohawkEngine_LivingBooks *vm, LBPage *page, Common::Rect rect) : LBItem(vm, page, rect) {
debug(3, "new LBMiniGameItem");
}
@@ -3768,6 +3823,10 @@ bool LBMiniGameItem::togglePlaying(bool playing, bool restart) {
return false;
}
+LBItem *LBMiniGameItem::createClone() {
+ error("can't clone LBMiniGameItem");
+}
+
LBProxyItem::LBProxyItem(MohawkEngine_LivingBooks *vm, LBPage *page, Common::Rect rect) : LBItem(vm, page, rect) {
debug(3, "new LBProxyItem");
@@ -3811,4 +3870,8 @@ void LBProxyItem::unload() {
LBItem::unload();
}
+LBItem *LBProxyItem::createClone() {
+ return new LBProxyItem(_vm, _page, _rect);
+}
+
} // End of namespace Mohawk
diff --git a/engines/mohawk/livingbooks.h b/engines/mohawk/livingbooks.h
index cde6357788..23ab0acfb1 100644
--- a/engines/mohawk/livingbooks.h
+++ b/engines/mohawk/livingbooks.h
@@ -415,6 +415,8 @@ public:
virtual void moveBy(const Common::Point &pos);
virtual void moveTo(const Common::Point &pos);
+ LBItem *clone(uint16 newId, const Common::String &newName);
+
uint16 getId() { return _itemId; }
const Common::String &getName() { return _desc; }
const Common::Rect &getRect() { return _rect; }
@@ -452,6 +454,8 @@ protected:
bool _isAmbient;
bool _doHitTest;
+ virtual LBItem *createClone();
+
Common::Array<LBScriptEntry *> _scriptEntries;
void runScript(uint event, uint16 data = 0, uint16 from = 0);
int runScriptEntry(LBScriptEntry *entry);
@@ -472,6 +476,8 @@ public:
void stop();
protected:
+ LBItem *createClone();
+
bool _running;
};
@@ -503,6 +509,8 @@ public:
void moveTo(const Common::Point &pos);
protected:
+ LBItem *createClone();
+
bool _starting;
Common::Array<GroupEntry> _groupEntries;
@@ -519,6 +527,8 @@ public:
void update();
protected:
+ LBItem *createClone();
+
uint16 _fadeInPeriod, _fadeInStep, _drawStart, _drawCount;
uint32 _fadeInStart, _fadeInCurrent;
byte *_palette;
@@ -550,6 +560,8 @@ public:
void notify(uint16 data, uint16 from);
protected:
+ LBItem *createClone();
+
void paletteUpdate(uint16 word, bool on);
void drawWord(uint word, uint yPos);
@@ -573,6 +585,9 @@ public:
bool contains(Common::Point point);
void draw();
void init();
+
+protected:
+ LBItem *createClone();
};
class LBAnimationItem : public LBItem {
@@ -593,6 +608,8 @@ public:
void stop();
protected:
+ LBItem *createClone();
+
LBAnimation *_anim;
bool _running;
};
@@ -604,6 +621,9 @@ public:
void update();
bool togglePlaying(bool playing, bool restart);
+
+protected:
+ LBItem *createClone();
};
class LBMiniGameItem : public LBItem {
@@ -612,6 +632,9 @@ public:
~LBMiniGameItem();
bool togglePlaying(bool playing, bool restart);
+
+protected:
+ LBItem *createClone();
};
class LBProxyItem : public LBItem {
@@ -623,6 +646,8 @@ public:
void unload();
protected:
+ LBItem *createClone();
+
class LBPage *_page;
};
@@ -659,6 +684,7 @@ public:
void open(Archive *mhk, uint16 baseId);
uint16 getResourceVersion();
+ void addClonedItem(LBItem *item);
void itemDestroyed(LBItem *item);
LBCode *_code;
diff --git a/engines/mohawk/livingbooks_code.cpp b/engines/mohawk/livingbooks_code.cpp
index 0cb99f709e..41acea19c4 100644
--- a/engines/mohawk/livingbooks_code.cpp
+++ b/engines/mohawk/livingbooks_code.cpp
@@ -1336,7 +1336,7 @@ void LBCode::cmdKey(const Common::Array<LBValue> &params) {
#define NUM_ITEM_COMMANDS 34
CodeCommandInfo itemCommandInfo[NUM_ITEM_COMMANDS] = {
- { "clone", 0 },
+ { "clone", &LBCode::itemClone },
{ "destroy", 0 },
{ "dragBeginFrom", 0 },
{ "dragEnd", 0 },
@@ -1389,6 +1389,17 @@ void LBCode::runItemCommand() {
(this->*(info.func))(params);
}
+void LBCode::itemClone(const Common::Array<LBValue> &params) {
+ // TODO: first param can be target?
+ if (params.size() != 2)
+ error("incorrect number of parameters (%d) to setParent", params.size());
+
+ uint id = params[0].toInt();
+ const Common::String &name = params[1].toString();
+
+ _currSource->clone(id, name);
+}
+
void LBCode::itemIsPlaying(const Common::Array<LBValue> &params) {
// TODO
warning("ignoring isPlaying");
diff --git a/engines/mohawk/livingbooks_code.h b/engines/mohawk/livingbooks_code.h
index a8d5e2d2dc..47dd90f814 100644
--- a/engines/mohawk/livingbooks_code.h
+++ b/engines/mohawk/livingbooks_code.h
@@ -281,6 +281,7 @@ public:
void cmdLBXFunc(const Common::Array<LBValue> &params);
void cmdKey(const Common::Array<LBValue> &params);
+ void itemClone(const Common::Array<LBValue> &params);
void itemIsPlaying(const Common::Array<LBValue> &params);
void itemIsLoaded(const Common::Array<LBValue> &params);
void itemMoveTo(const Common::Array<LBValue> &params);