aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarisa-Chan2014-11-07 10:25:11 +0600
committerMarisa-Chan2014-11-07 10:25:11 +0600
commit0efa1bc5606c9fd984df077d55cf93a7903f5f67 (patch)
tree44c3f32e5e229088f0b615c703a5aabb182e6cd4
parent7151240345cc723c0084a4ea5dda9aaaa4dff690 (diff)
downloadscummvm-rg350-0efa1bc5606c9fd984df077d55cf93a7903f5f67.tar.gz
scummvm-rg350-0efa1bc5606c9fd984df077d55cf93a7903f5f67.tar.bz2
scummvm-rg350-0efa1bc5606c9fd984df077d55cf93a7903f5f67.zip
ZVISION: Implement action:rotate_to
-rw-r--r--engines/zvision/scripting/actions.cpp15
-rw-r--r--engines/zvision/scripting/actions.h10
-rw-r--r--engines/zvision/scripting/scr_file_handling.cpp2
-rw-r--r--engines/zvision/zvision.cpp52
-rw-r--r--engines/zvision/zvision.h2
5 files changed, 80 insertions, 1 deletions
diff --git a/engines/zvision/scripting/actions.cpp b/engines/zvision/scripting/actions.cpp
index 9733c5cae8..2754a39676 100644
--- a/engines/zvision/scripting/actions.cpp
+++ b/engines/zvision/scripting/actions.cpp
@@ -612,6 +612,21 @@ bool ActionRandom::execute() {
return true;
}
+//////////////////////////////////////////////////////////////////////////////
+// ActionRotateTo
+//////////////////////////////////////////////////////////////////////////////
+
+ActionRotateTo::ActionRotateTo(ZVision *engine, int32 slotkey, const Common::String &line) :
+ ResultAction(engine, slotkey) {
+ sscanf(line.c_str(), "%d, %d", &_toPos, &_time);
+}
+
+bool ActionRotateTo::execute() {
+ _engine->rotateTo(_toPos, _time);
+
+ return true;
+}
+
//////////////////////////////////////////////////////////////////////////////
// ActionSetPartialScreen
diff --git a/engines/zvision/scripting/actions.h b/engines/zvision/scripting/actions.h
index f51847ed05..6a200198b7 100644
--- a/engines/zvision/scripting/actions.h
+++ b/engines/zvision/scripting/actions.h
@@ -360,6 +360,16 @@ private:
ValueSlot *_max;
};
+class ActionRotateTo : public ResultAction {
+public:
+ ActionRotateTo(ZVision *engine, int32 slotkey, const Common::String &line);
+ bool execute();
+
+private:
+ int32 _toPos;
+ int32 _time;
+};
+
class ActionSetPartialScreen : public ResultAction {
public:
ActionSetPartialScreen(ZVision *engine, int32 slotkey, const Common::String &line);
diff --git a/engines/zvision/scripting/scr_file_handling.cpp b/engines/zvision/scripting/scr_file_handling.cpp
index df60b0b8d4..b16a2d9474 100644
--- a/engines/zvision/scripting/scr_file_handling.cpp
+++ b/engines/zvision/scripting/scr_file_handling.cpp
@@ -270,7 +270,7 @@ void ScriptManager::parseResults(Common::SeekableReadStream &stream, Common::Lis
} else if (act.matchString("restore_game", true)) {
// TODO: Implement ActionRestoreGame
} else if (act.matchString("rotate_to", true)) {
- // TODO: Implement ActionRotateTo
+ actionList.push_back(new ActionRotateTo(_engine, slot, args));
} else if (act.matchString("save_game", true)) {
// TODO: Implement ActionSaveGame
} else if (act.matchString("set_partial_screen", true)) {
diff --git a/engines/zvision/zvision.cpp b/engines/zvision/zvision.cpp
index 41d3eea6aa..79f7d74a8d 100644
--- a/engines/zvision/zvision.cpp
+++ b/engines/zvision/zvision.cpp
@@ -402,4 +402,56 @@ void ZVision::updateRotation() {
}
}
+void ZVision::rotateTo(int16 _toPos, int16 _time) {
+ if (_renderManager->getRenderTable()->getRenderState() != RenderTable::PANORAMA)
+ return;
+
+ if (_time == 0)
+ _time = 1;
+
+ int32 maxX = _renderManager->getBkgSize().x;
+ int32 curX = _renderManager->getCurrentBackgroundOffset();
+ int32 dx = 0;
+
+ if (curX == _toPos)
+ return;
+
+ if (curX > _toPos) {
+ if (curX - _toPos > maxX / 2)
+ dx = (_toPos + (maxX - curX)) / _time;
+ else
+ dx = -(curX - _toPos) / _time;
+ } else {
+ if (_toPos - curX > maxX / 2)
+ dx = -((maxX - _toPos) + curX) / _time;
+ else
+ dx = (_toPos - curX) / _time;
+ }
+
+ _clock.stop();
+
+ for (int16 i = 0; i <= _time; i++) {
+ if (i == _time)
+ curX = _toPos;
+ else
+ curX += dx;
+
+ if (curX < 0)
+ curX = maxX - curX;
+ else if (curX >= maxX)
+ curX %= maxX;
+
+ _renderManager->setBackgroundPosition(curX);
+
+ _renderManager->prepareBkg();
+ _renderManager->renderBackbufferToScreen();
+
+ _system->updateScreen();
+
+ _system->delayMillis(500 / _time);
+ }
+
+ _clock.start();
+}
+
} // End of namespace ZVision
diff --git a/engines/zvision/zvision.h b/engines/zvision/zvision.h
index 0bee639458..e2bde7bd9e 100644
--- a/engines/zvision/zvision.h
+++ b/engines/zvision/zvision.h
@@ -170,6 +170,8 @@ public:
*/
void playVideo(Video::VideoDecoder &videoDecoder, const Common::Rect &destRect = Common::Rect(0, 0, 0, 0), bool skippable = true, Subtitle *sub = NULL);
+ void rotateTo(int16 to, int16 time);
+
Common::String generateSaveFileName(uint slot);
Common::String generateAutoSaveFileName();