diff options
author | Willem Jan Palenstijn | 2015-07-22 22:37:40 +0200 |
---|---|---|
committer | Willem Jan Palenstijn | 2015-07-22 22:43:42 +0200 |
commit | 6ec9c81b575f13b2c4b30aeac592ebf2557b5890 (patch) | |
tree | 503d50902bad2d800165593039d08d5ccf0c98ab /engines/mohawk/livingbooks_code.cpp | |
parent | 5ec05f6b647c5ea41418be7ed19ad381f97cabd8 (diff) | |
parent | 4e5c8d35f7e133e2e72a846fdbd54900c91eeb73 (diff) | |
download | scummvm-rg350-6ec9c81b575f13b2c4b30aeac592ebf2557b5890.tar.gz scummvm-rg350-6ec9c81b575f13b2c4b30aeac592ebf2557b5890.tar.bz2 scummvm-rg350-6ec9c81b575f13b2c4b30aeac592ebf2557b5890.zip |
Merge branch 'master' into mm
Conflicts:
engines/access/access.cpp
engines/access/asurface.h
engines/access/bubble_box.cpp
engines/access/bubble_box.h
engines/access/martian/martian_game.cpp
engines/access/player.cpp
engines/access/player.h
engines/access/resources.cpp
engines/access/screen.cpp
engines/access/screen.h
engines/access/sound.cpp
engines/access/sound.h
Diffstat (limited to 'engines/mohawk/livingbooks_code.cpp')
-rw-r--r-- | engines/mohawk/livingbooks_code.cpp | 55 |
1 files changed, 50 insertions, 5 deletions
diff --git a/engines/mohawk/livingbooks_code.cpp b/engines/mohawk/livingbooks_code.cpp index 6dcd8c3ce7..b5ea547414 100644 --- a/engines/mohawk/livingbooks_code.cpp +++ b/engines/mohawk/livingbooks_code.cpp @@ -842,8 +842,8 @@ CodeCommandInfo generalCommandInfo[NUM_GENERAL_COMMANDS] = { { "bottom", &LBCode::cmdBottom }, // 0x10 { "right", &LBCode::cmdRight }, - { "xpos", 0 }, - { "ypos", 0 }, + { "xpos", &LBCode::cmdXPos }, + { "ypos", &LBCode::cmdYPos }, { "playFrom", 0 }, { "move", &LBCode::cmdMove }, { 0, 0 }, @@ -852,13 +852,13 @@ CodeCommandInfo generalCommandInfo[NUM_GENERAL_COMMANDS] = { { "resetDragParams", 0 }, { "enableRollover", &LBCode::cmdUnimplemented /* FIXME */ }, { "setCursor", 0 }, - { "width", 0 }, - { "height", 0 }, + { "width", &LBCode::cmdWidth }, + { "height", &LBCode::cmdHeight }, { "getFrameBounds", 0 }, // also "getFrameRect" { "traceRect", 0 }, { "sqrt", 0 }, // 0x20 - { "deleteVar", 0 }, + { "deleteVar", &LBCode::cmdDeleteVar }, { "saveVars", 0 }, { "scriptLink", 0 }, { "setViewOrigin", &LBCode::cmdUnimplemented }, @@ -1131,6 +1131,38 @@ void LBCode::cmdRight(const Common::Array<LBValue> ¶ms) { _stack.push(rect.right); } +void LBCode::cmdXPos(const Common::Array<LBValue> ¶ms) { + if (params.size() != 1) + error("too many parameters (%d) to xpos", params.size()); + + Common::Point point = params[0].toPoint(); + _stack.push(point.x); +} + +void LBCode::cmdYPos(const Common::Array<LBValue> ¶ms) { + if (params.size() != 1) + error("too many parameters (%d) to ypos", params.size()); + + Common::Point point = params[0].toPoint(); + _stack.push(point.y); +} + +void LBCode::cmdWidth(const Common::Array<LBValue> ¶ms) { + if (params.size() > 1) + error("too many parameters (%d) to width", params.size()); + + Common::Rect rect = getRectFromParams(params); + _stack.push(rect.width()); +} + +void LBCode::cmdHeight(const Common::Array<LBValue> ¶ms) { + if (params.size() > 1) + error("too many parameters (%d) to height", params.size()); + + Common::Rect rect = getRectFromParams(params); + _stack.push(rect.height()); +} + 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()); @@ -1263,6 +1295,14 @@ void LBCode::cmdGetProperty(const Common::Array<LBValue> ¶ms) { _stack.push(target->_variables[name]); } +void LBCode::cmdDeleteVar(const Common::Array<LBValue> ¶ms) { + if (params.size() != 1) + error("incorrect number of parameters (%d) to deleteVar", params.size()); + + const Common::String &string = params[0].toString(); + _vm->_variables.erase(string); +} + void LBCode::cmdExec(const Common::Array<LBValue> ¶ms) { if (params.size() != 1) error("incorrect number of parameters (%d) to exec", params.size()); @@ -1706,6 +1746,10 @@ uint LBCode::parseCode(const Common::String &source) { if (token != ' ' && token != '(' && wasFunction) error("while parsing script '%s', encountered incomplete function call", source.c_str()); + // Skip C++-style comments + if (token == '/' && lookahead == '/') + break; + // First, we check for simple operators. for (uint i = 0; i < NUM_LB_OPERATORS; i++) { if (token != operators[i].token) @@ -1736,6 +1780,7 @@ uint LBCode::parseCode(const Common::String &source) { switch (token) { // whitespace case ' ': + case '\t': // ignore break; // literal string |