ZVISION: Passive borders check for tilt and panorama for changelocation

This commit is contained in:
Marisa-Chan 2014-11-12 15:58:35 +06:00
parent 1f0bf5ecf2
commit 418b5f6dd2
3 changed files with 38 additions and 0 deletions

View file

@ -628,6 +628,8 @@ void ScriptManager::do_changeLocation() {
_currentLocation = _nextLocation;
execScope(nodeview);
}
_engine->checkBorders();
}
void ScriptManager::serialize(Common::WriteStream *stream) {

View file

@ -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;

View file

@ -195,6 +195,7 @@ public:
bool ifQuit();
void checkBorders();
void showDebugMsg(const Common::String &msg, int16 delay = 3000);
private: