Skip to content

Commit

Permalink
ZVISION: Passive borders check for tilt and panorama for changelocation
Browse files Browse the repository at this point in the history
  • Loading branch information
Marisa-Chan committed Nov 12, 2014
1 parent 1f0bf5e commit 418b5f6
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 0 deletions.
2 changes: 2 additions & 0 deletions engines/zvision/scripting/script_manager.cpp
Expand Up @@ -628,6 +628,8 @@ void ScriptManager::do_changeLocation() {
_currentLocation = _nextLocation;
execScope(nodeview);
}

_engine->checkBorders();
}

void ScriptManager::serialize(Common::WriteStream *stream) {
Expand Down
35 changes: 35 additions & 0 deletions engines/zvision/zvision.cpp
Expand Up @@ -410,6 +410,41 @@ void ZVision::updateRotation() {
}
}

void ZVision::checkBorders() {
RenderTable::RenderState renderState = _renderManager->getRenderTable()->getRenderState();
if (renderState == RenderTable::PANORAMA) {
int16 st_pos = _scriptManager->getStateValue(StateKey_ViewPos);

int16 new_pos = st_pos;

int16 scr_width = _renderManager->getBkgSize().x;

if (scr_width)
new_pos %= scr_width;

if (new_pos < 0)
new_pos += scr_width;

if (st_pos != new_pos)
_renderManager->setBackgroundPosition(new_pos);
} else if (renderState == RenderTable::TILT) {
int16 st_pos = _scriptManager->getStateValue(StateKey_ViewPos);

int16 new_pos = st_pos;

int16 scr_height = _renderManager->getBkgSize().y;
int16 tilt_gap = _renderManager->getRenderTable()->getTiltGap();

if (new_pos >= (scr_height - tilt_gap))
new_pos = scr_height - tilt_gap;
if (new_pos <= tilt_gap)
new_pos = tilt_gap;

if (st_pos != new_pos)
_renderManager->setBackgroundPosition(new_pos);
}
}

void ZVision::rotateTo(int16 _toPos, int16 _time) {
if (_renderManager->getRenderTable()->getRenderState() != RenderTable::PANORAMA)
return;
Expand Down
1 change: 1 addition & 0 deletions engines/zvision/zvision.h
Expand Up @@ -195,6 +195,7 @@ class ZVision : public Engine {

bool ifQuit();

void checkBorders();
void showDebugMsg(const Common::String &msg, int16 delay = 3000);

private:
Expand Down

0 comments on commit 418b5f6

Please sign in to comment.