[Scummvm-cvs-logs] scummvm master -> e4fc8e85ed30217ee537c178e01d5a980ba0f14a
fuzzie
fuzzie at fuzzie.org
Thu Jul 7 16:27:03 CEST 2011
This automated email contains information about 3 new commits which have been
pushed to the 'scummvm' repo located at https://github.com/scummvm/scummvm .
Summary:
f0bef196b1 MOHAWK: Maintain ordered list of LB items.
33a85af915 MOHAWK: Handle cursor changes in kLBNotifyChangeMode.
e4fc8e85ed MOHAWK: Implement stringLen and substring LBCode functions.
Commit: f0bef196b19802b2ad544775ee80acfafb057bbf
https://github.com/scummvm/scummvm/commit/f0bef196b19802b2ad544775ee80acfafb057bbf
Author: Alyssa Milburn (fuzzie at fuzzie.org)
Date: 2011-07-07T07:23:10-07:00
Commit Message:
MOHAWK: Maintain ordered list of LB items.
Changed paths:
engines/mohawk/livingbooks.cpp
engines/mohawk/livingbooks.h
diff --git a/engines/mohawk/livingbooks.cpp b/engines/mohawk/livingbooks.cpp
index f9d18ff..dd7bc9a 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);
}
}
diff --git a/engines/mohawk/livingbooks.h b/engines/mohawk/livingbooks.h
index ad2fe56..c86a3cc 100644
--- a/engines/mohawk/livingbooks.h
+++ b/engines/mohawk/livingbooks.h
@@ -405,6 +405,8 @@ public:
uint16 getSoundPriority() { return _soundMode; }
bool isAmbient() { return _isAmbient; }
+ Common::List<LBItem *>::iterator _iterator;
+
protected:
MohawkEngine_LivingBooks *_vm;
LBPage *_page;
@@ -714,6 +716,7 @@ private:
uint16 _phase;
LBPage *_page;
Common::Array<LBItem *> _items;
+ Common::List<LBItem *> _orderedItems;
Common::Queue<DelayedEvent> _eventQueue;
LBItem *_focus;
void destroyPage();
Commit: 33a85af915bed7db63561f54ee5848aa7792fcbc
https://github.com/scummvm/scummvm/commit/33a85af915bed7db63561f54ee5848aa7792fcbc
Author: Alyssa Milburn (fuzzie at fuzzie.org)
Date: 2011-07-07T07:23:11-07:00
Commit Message:
MOHAWK: Handle cursor changes in kLBNotifyChangeMode.
Changed paths:
engines/mohawk/livingbooks.cpp
engines/mohawk/livingbooks.h
diff --git a/engines/mohawk/livingbooks.cpp b/engines/mohawk/livingbooks.cpp
index dd7bc9a..65073bd 100644
--- a/engines/mohawk/livingbooks.cpp
+++ b/engines/mohawk/livingbooks.cpp
@@ -1327,8 +1327,13 @@ void MohawkEngine_LivingBooks::handleNotify(NotifyEvent &event) {
if (getGameType() == GType_LIVINGBOOKSV1) {
debug(2, "kLBNotifyChangeMode: %d", event.param);
quitGame();
- } else {
- debug(2, "kLBNotifyChangeMode: mode %d, page %d.%d",
+ break;
+ }
+
+ debug(2, "kLBNotifyChangeMode: v2 type %d", event.param);
+ switch (event.param) {
+ case 1:
+ debug(2, "kLBNotifyChangeMode:, mode %d, page %d.%d",
event.newMode, event.newPage, event.newSubpage);
// TODO: what is entry.newUnknown?
if (!event.newMode)
@@ -1339,6 +1344,13 @@ void MohawkEngine_LivingBooks::handleNotify(NotifyEvent &event) {
error("kLBNotifyChangeMode failed to move to mode %d, page %d.%d",
event.newMode, event.newPage, event.newSubpage);
}
+ break;
+ case 3:
+ debug(2, "kLBNotifyChangeMode: new cursor '%s'", event.newCursor.c_str());
+ _cursor->setCursor(event.newCursor);
+ break;
+ default:
+ error("unknown v2 kLBNotifyChangeMode type %d", event.param);
}
break;
@@ -2092,16 +2104,32 @@ LBScriptEntry *LBItem::parseScriptEntry(uint16 type, uint16 &size, Common::Memor
}
if (type == kLBNotifyScript && entry->opcode == kLBNotifyChangeMode && _vm->getGameType() != GType_LIVINGBOOKSV1) {
- if (size < 8) {
- error("%d unknown bytes in notify entry kLBNotifyChangeMode", size);
+ switch (entry->param) {
+ case 1:
+ if (size < 8)
+ error("%d unknown bytes in notify entry kLBNotifyChangeMode", size);
+ entry->newUnknown = stream->readUint16();
+ entry->newMode = stream->readUint16();
+ entry->newPage = stream->readUint16();
+ entry->newSubpage = stream->readUint16();
+ debug(4, "kLBNotifyChangeMode: unknown %04x, mode %d, page %d.%d",
+ entry->newUnknown, entry->newMode, entry->newPage, entry->newSubpage);
+ size -= 8;
+ break;
+ case 3:
+ {
+ Common::String newCursor = _vm->readString(stream);
+ entry->newCursor = newCursor;
+ if (size < newCursor.size() + 1)
+ error("failed to read newCursor in notify entry");
+ size -= newCursor.size() + 1;
+ debug(4, "kLBNotifyChangeMode: new cursor '%s'", newCursor.c_str());
+ }
+ break;
+ default:
+ // the original engine also does something when param==2 (but not a notify)
+ error("unknown v2 kLBNotifyChangeMode type %d", entry->param);
}
- entry->newUnknown = stream->readUint16();
- entry->newMode = stream->readUint16();
- entry->newPage = stream->readUint16();
- entry->newSubpage = stream->readUint16();
- debug(4, "kLBNotifyChangeMode: unknown %04x, mode %d, page %d.%d",
- entry->newUnknown, entry->newMode, entry->newPage, entry->newSubpage);
- size -= 8;
}
if (entry->opcode == kLBOpSendExpression) {
if (size < 4)
@@ -2585,6 +2613,7 @@ void LBItem::runScript(uint event, uint16 data, uint16 from) {
notifyEvent.newMode = entry->newMode;
notifyEvent.newPage = entry->newPage;
notifyEvent.newSubpage = entry->newSubpage;
+ notifyEvent.newCursor = entry->newCursor;
_vm->addNotifyEvent(notifyEvent);
} else
_vm->addNotifyEvent(NotifyEvent(entry->opcode, entry->param));
diff --git a/engines/mohawk/livingbooks.h b/engines/mohawk/livingbooks.h
index c86a3cc..8426945 100644
--- a/engines/mohawk/livingbooks.h
+++ b/engines/mohawk/livingbooks.h
@@ -133,7 +133,9 @@ enum {
kLBEventMouseUp = 5,
kLBEventPhaseMain = 6,
kLBEventNotified = 7,
+ kLBEventDragStart = 8,
kLBEventDragMove = 9,
+ kLBEventDragEnd = 0xa,
kLBEventRolloverBegin = 0xb,
kLBEventRolloverMove = 0xc,
kLBEventRolloverEnd = 0xd,
@@ -271,6 +273,7 @@ struct LBScriptEntry {
uint16 newMode;
uint16 newPage;
uint16 newSubpage;
+ Common::String newCursor;
// kLBEventNotified
uint16 matchFrom;
@@ -610,6 +613,7 @@ struct NotifyEvent {
uint16 newMode;
uint16 newPage;
uint16 newSubpage;
+ Common::String newCursor;
};
enum DelayedEventType {
Commit: e4fc8e85ed30217ee537c178e01d5a980ba0f14a
https://github.com/scummvm/scummvm/commit/e4fc8e85ed30217ee537c178e01d5a980ba0f14a
Author: Alyssa Milburn (fuzzie at fuzzie.org)
Date: 2011-07-07T07:23:34-07:00
Commit Message:
MOHAWK: Implement stringLen and substring LBCode functions.
Changed paths:
engines/mohawk/livingbooks_code.cpp
engines/mohawk/livingbooks_code.h
diff --git a/engines/mohawk/livingbooks_code.cpp b/engines/mohawk/livingbooks_code.cpp
index e9ef251..6531f65 100644
--- a/engines/mohawk/livingbooks_code.cpp
+++ b/engines/mohawk/livingbooks_code.cpp
@@ -686,8 +686,8 @@ struct CodeCommandInfo {
CodeCommandInfo generalCommandInfo[NUM_GENERAL_COMMANDS] = {
{ "eval", &LBCode::cmdEval },
{ "random", &LBCode::cmdRandom },
- { "stringLen", 0 },
- { "substring", 0 },
+ { "stringLen", &LBCode::cmdStringLen },
+ { "substring", &LBCode::cmdSubstring },
{ "max", 0 },
{ "min", 0 },
{ "abs", 0 },
@@ -861,6 +861,31 @@ void LBCode::cmdRandom(const Common::Array<LBValue> ¶ms) {
_stack.push(_vm->_rnd->getRandomNumberRng(min, max));
}
+void LBCode::cmdStringLen(const Common::Array<LBValue> ¶ms) {
+ if (params.size() != 1)
+ error("incorrect number of parameters (%d) to stringLen", params.size());
+
+ const Common::String &string = params[0].toString();
+ _stack.push(string.size());
+}
+
+void LBCode::cmdSubstring(const Common::Array<LBValue> ¶ms) {
+ if (params.size() != 3)
+ error("incorrect number of parameters (%d) to substring", params.size());
+
+ const Common::String &string = params[0].toString();
+ uint begin = params[1].toInt();
+ uint end = params[2].toInt();
+ if (begin == 0)
+ error("invalid substring call (%d to %d)", begin, end);
+ if (begin > end || end > string.size()) {
+ _stack.push(Common::String());
+ return;
+ }
+ Common::String substring(string.c_str() + (begin - 1), end - begin + 1);
+ _stack.push(substring);
+}
+
void LBCode::cmdGetRect(const Common::Array<LBValue> ¶ms) {
if (params.size() < 2) {
_stack.push(getRectFromParams(params));
diff --git a/engines/mohawk/livingbooks_code.h b/engines/mohawk/livingbooks_code.h
index 9c58ed7..79c9af9 100644
--- a/engines/mohawk/livingbooks_code.h
+++ b/engines/mohawk/livingbooks_code.h
@@ -222,6 +222,8 @@ public:
void cmdUnimplemented(const Common::Array<LBValue> ¶ms);
void cmdEval(const Common::Array<LBValue> ¶ms);
void cmdRandom(const Common::Array<LBValue> ¶ms);
+ void cmdStringLen(const Common::Array<LBValue> ¶ms);
+ void cmdSubstring(const Common::Array<LBValue> ¶ms);
void cmdGetRect(const Common::Array<LBValue> ¶ms);
void cmdTopLeft(const Common::Array<LBValue> ¶ms);
void cmdBottomRight(const Common::Array<LBValue> ¶ms);
More information about the Scummvm-git-logs
mailing list