aboutsummaryrefslogtreecommitdiff
path: root/engines
diff options
context:
space:
mode:
Diffstat (limited to 'engines')
-rw-r--r--engines/mohawk/livingbooks.h3
-rw-r--r--engines/mohawk/livingbooks_code.cpp43
-rw-r--r--engines/mohawk/livingbooks_code.h2
3 files changed, 46 insertions, 2 deletions
diff --git a/engines/mohawk/livingbooks.h b/engines/mohawk/livingbooks.h
index 1ab6e4d89c..cde6357788 100644
--- a/engines/mohawk/livingbooks.h
+++ b/engines/mohawk/livingbooks.h
@@ -424,6 +424,9 @@ public:
Common::List<LBItem *>::iterator _iterator;
+ // TODO: make private
+ Common::HashMap<Common::String, LBValue, Common::IgnoreCase_Hash, Common::IgnoreCase_EqualTo> _variables;
+
protected:
MohawkEngine_LivingBooks *_vm;
LBPage *_page;
diff --git a/engines/mohawk/livingbooks_code.cpp b/engines/mohawk/livingbooks_code.cpp
index 8e7c69b070..e821e7e54d 100644
--- a/engines/mohawk/livingbooks_code.cpp
+++ b/engines/mohawk/livingbooks_code.cpp
@@ -847,8 +847,8 @@ CodeCommandInfo generalCommandInfo[NUM_GENERAL_COMMANDS] = {
{ "deleteAt", &LBCode::cmdDeleteAt },
{ "clearList", &LBCode::cmdUnimplemented },
{ "setWorld", 0 },
- { "setProperty", 0 },
- { "getProperty", 0 },
+ { "setProperty", &LBCode::cmdSetProperty },
+ { "getProperty", &LBCode::cmdGetProperty },
{ "copyList", 0 },
{ "invoke", 0 },
{ "exec", &LBCode::cmdExec },
@@ -1189,6 +1189,45 @@ void LBCode::cmdDeleteAt(const Common::Array<LBValue> &params) {
params[0].list->array.remove_at(params[1].integer - 1);
}
+void LBCode::cmdSetProperty(const Common::Array<LBValue> &params) {
+ if (params.size() < 2 || params.size() > 3)
+ error("incorrect number of parameters (%d) to setProperty", params.size());
+
+ Common::String name;
+ LBValue val;
+ LBItem *target = _currSource;
+ if (params.size() == 3) {
+ target = resolveItem(params[0]);
+ if (!target)
+ error("attempted setProperty on invalid item (%s)", params[0].toString().c_str());
+ name = params[1].toString();
+ val = params[2];
+ } else {
+ name = params[0].toString();
+ val = params[1];
+ }
+
+ target->_variables[name] = val;
+}
+
+void LBCode::cmdGetProperty(const Common::Array<LBValue> &params) {
+ if (params.size() < 1 || params.size() > 2)
+ error("incorrect number of parameters (%d) to getProperty", params.size());
+
+ Common::String name;
+ LBItem *target = _currSource;
+ if (params.size() == 2) {
+ target = resolveItem(params[0]);
+ if (!target)
+ error("attempted getProperty on invalid item (%s)", params[0].toString().c_str());
+ name = params[1].toString();
+ } else {
+ name = params[0].toString();
+ }
+
+ _stack.push(target->_variables[name]);
+}
+
void LBCode::cmdExec(const Common::Array<LBValue> &params) {
if (params.size() != 1)
error("incorrect number of parameters (%d) to exec", params.size());
diff --git a/engines/mohawk/livingbooks_code.h b/engines/mohawk/livingbooks_code.h
index 2cb1994492..a8d5e2d2dc 100644
--- a/engines/mohawk/livingbooks_code.h
+++ b/engines/mohawk/livingbooks_code.h
@@ -270,6 +270,8 @@ public:
void cmdSetAt(const Common::Array<LBValue> &params);
void cmdListLen(const Common::Array<LBValue> &params);
void cmdDeleteAt(const Common::Array<LBValue> &params);
+ void cmdSetProperty(const Common::Array<LBValue> &params);
+ void cmdGetProperty(const Common::Array<LBValue> &params);
void cmdExec(const Common::Array<LBValue> &params);
void cmdReturn(const Common::Array<LBValue> &params);
void cmdSetPlayParams(const Common::Array<LBValue> &params);