diff options
author | Marisa-Chan | 2014-11-12 15:55:10 +0600 |
---|---|---|
committer | Marisa-Chan | 2014-11-12 15:55:10 +0600 |
commit | 1f0bf5ecf2f3eb1c65019d196f7327a0874f93bb (patch) | |
tree | 12a7b4d0d2d94331a7097829a13add7a593bbbde /engines/zvision | |
parent | e57c358cead20cbf75332a15c4961ff6c15abf6a (diff) | |
download | scummvm-rg350-1f0bf5ecf2f3eb1c65019d196f7327a0874f93bb.tar.gz scummvm-rg350-1f0bf5ecf2f3eb1c65019d196f7327a0874f93bb.tar.bz2 scummvm-rg350-1f0bf5ecf2f3eb1c65019d196f7327a0874f93bb.zip |
ZVISION: Implement code for pan from keyboard and mouse
Diffstat (limited to 'engines/zvision')
-rw-r--r-- | engines/zvision/core/events.cpp | 46 | ||||
-rw-r--r-- | engines/zvision/zvision.cpp | 12 | ||||
-rw-r--r-- | engines/zvision/zvision.h | 3 |
3 files changed, 49 insertions, 12 deletions
diff --git a/engines/zvision/core/events.cpp b/engines/zvision/core/events.cpp index 72e3fa6d34..38ceb5ceb4 100644 --- a/engines/zvision/core/events.cpp +++ b/engines/zvision/core/events.cpp @@ -189,10 +189,26 @@ void ZVision::processEvents() { _console->onFrame(); } break; + + case Common::KEYCODE_LEFT: + case Common::KEYCODE_RIGHT: + if (_renderManager->getRenderTable()->getRenderState() == RenderTable::PANORAMA) + _kbdVelocity = (_event.kbd.keycode == Common::KEYCODE_LEFT ? + -_scriptManager->getStateValue(StateKey_KbdRotateSpeed) : + _scriptManager->getStateValue(StateKey_KbdRotateSpeed)) * 2; case Common::KEYCODE_q: if (_event.kbd.hasFlags(Common::KBD_CTRL)) quitGame(); break; + + case Common::KEYCODE_UP: + case Common::KEYCODE_DOWN: + if (_renderManager->getRenderTable()->getRenderState() == RenderTable::TILT) + _kbdVelocity = (_event.kbd.keycode == Common::KEYCODE_UP ? + -_scriptManager->getStateValue(StateKey_KbdRotateSpeed) : + _scriptManager->getStateValue(StateKey_KbdRotateSpeed)) * 2; + break; + default: break; } @@ -208,6 +224,20 @@ void ZVision::processEvents() { break; case Common::EVENT_KEYUP: _scriptManager->addEvent(_event); + switch (_event.kbd.keycode) { + case Common::KEYCODE_LEFT: + case Common::KEYCODE_RIGHT: + if (_renderManager->getRenderTable()->getRenderState() == RenderTable::PANORAMA) + _kbdVelocity = 0; + break; + case Common::KEYCODE_UP: + case Common::KEYCODE_DOWN: + if (_renderManager->getRenderTable()->getRenderState() == RenderTable::TILT) + _kbdVelocity = 0; + break; + default: + break; + } break; default: break; @@ -261,7 +291,7 @@ void ZVision::onMouseMove(const Common::Point &pos) { int16 mspeed = _scriptManager->getStateValue(StateKey_RotateSpeed) >> 4; if (mspeed <= 0) mspeed = 400 >> 4; - _velocity = (((pos.x - (ROTATION_SCREEN_EDGE_OFFSET + _workingWindow.left)) << 7) / ROTATION_SCREEN_EDGE_OFFSET * mspeed) >> 7; + _mouseVelocity = (((pos.x - (ROTATION_SCREEN_EDGE_OFFSET + _workingWindow.left)) << 7) / ROTATION_SCREEN_EDGE_OFFSET * mspeed) >> 7; _cursorManager->changeCursor(CursorIndex_Left); cursorWasChanged = true; @@ -270,12 +300,12 @@ void ZVision::onMouseMove(const Common::Point &pos) { int16 mspeed = _scriptManager->getStateValue(StateKey_RotateSpeed) >> 4; if (mspeed <= 0) mspeed = 400 >> 4; - _velocity = (((pos.x - (_workingWindow.right - ROTATION_SCREEN_EDGE_OFFSET)) << 7) / ROTATION_SCREEN_EDGE_OFFSET * mspeed) >> 7; + _mouseVelocity = (((pos.x - (_workingWindow.right - ROTATION_SCREEN_EDGE_OFFSET)) << 7) / ROTATION_SCREEN_EDGE_OFFSET * mspeed) >> 7; _cursorManager->changeCursor(CursorIndex_Right); cursorWasChanged = true; } else { - _velocity = 0; + _mouseVelocity = 0; } } else if (renderState == RenderTable::TILT) { if (pos.y >= _workingWindow.top && pos.y < _workingWindow.top + ROTATION_SCREEN_EDGE_OFFSET) { @@ -283,7 +313,7 @@ void ZVision::onMouseMove(const Common::Point &pos) { int16 mspeed = _scriptManager->getStateValue(StateKey_RotateSpeed) >> 4; if (mspeed <= 0) mspeed = 400 >> 4; - _velocity = (((pos.y - (_workingWindow.top + ROTATION_SCREEN_EDGE_OFFSET)) << 7) / ROTATION_SCREEN_EDGE_OFFSET * mspeed) >> 7; + _mouseVelocity = (((pos.y - (_workingWindow.top + ROTATION_SCREEN_EDGE_OFFSET)) << 7) / ROTATION_SCREEN_EDGE_OFFSET * mspeed) >> 7; _cursorManager->changeCursor(CursorIndex_UpArr); cursorWasChanged = true; @@ -292,18 +322,18 @@ void ZVision::onMouseMove(const Common::Point &pos) { int16 mspeed = _scriptManager->getStateValue(StateKey_RotateSpeed) >> 4; if (mspeed <= 0) mspeed = 400 >> 4; - _velocity = (((pos.y - (_workingWindow.bottom - ROTATION_SCREEN_EDGE_OFFSET)) << 7) / ROTATION_SCREEN_EDGE_OFFSET * mspeed) >> 7; + _mouseVelocity = (((pos.y - (_workingWindow.bottom - ROTATION_SCREEN_EDGE_OFFSET)) << 7) / ROTATION_SCREEN_EDGE_OFFSET * mspeed) >> 7; _cursorManager->changeCursor(CursorIndex_DownArr); cursorWasChanged = true; } else { - _velocity = 0; + _mouseVelocity = 0; } } else { - _velocity = 0; + _mouseVelocity = 0; } } else { - _velocity = 0; + _mouseVelocity = 0; } if (!cursorWasChanged) { diff --git a/engines/zvision/zvision.cpp b/engines/zvision/zvision.cpp index 3518e01d68..f2f713dac0 100644 --- a/engines/zvision/zvision.cpp +++ b/engines/zvision/zvision.cpp @@ -97,7 +97,8 @@ ZVision::ZVision(OSystem *syst, const ZVisionGameDescription *gameDesc) _midiManager(nullptr), _aud_id(0), _rendDelay(2), - _velocity(0) { + _kbdVelocity(0), + _mouseVelocity(0) { debug(1, "ZVision::ZVision"); @@ -365,12 +366,17 @@ bool ZVision::canRender() { } void ZVision::updateRotation() { + int16 _velocity = _mouseVelocity + _kbdVelocity; + + if (_halveDelay) + _velocity /= 2; + if (_velocity) { RenderTable::RenderState renderState = _renderManager->getRenderTable()->getRenderState(); if (renderState == RenderTable::PANORAMA) { int16 st_pos = _scriptManager->getStateValue(StateKey_ViewPos); - int16 new_pos = st_pos + _velocity * (1 - 2 * 0); + int16 new_pos = st_pos + (_renderManager->getRenderTable()->getPanoramaReverse() ? -_velocity : _velocity); int16 zero_point = _renderManager->getRenderTable()->getPanoramaZeroPoint(); if (st_pos >= zero_point && new_pos < zero_point) @@ -389,7 +395,7 @@ void ZVision::updateRotation() { } else if (renderState == RenderTable::TILT) { int16 st_pos = _scriptManager->getStateValue(StateKey_ViewPos); - int16 new_pos = st_pos + _velocity * (1 - 2 * 0); + int16 new_pos = st_pos + _velocity; int16 scr_height = _renderManager->getBkgSize().y; int16 tilt_gap = _renderManager->getRenderTable()->getTiltGap(); diff --git a/engines/zvision/zvision.h b/engines/zvision/zvision.h index 8564e4e26b..549ea9bcdf 100644 --- a/engines/zvision/zvision.h +++ b/engines/zvision/zvision.h @@ -122,7 +122,8 @@ private: const Common::Rect _workingWindow_ZNM; int _rendDelay; - int16 _velocity; + int16 _mouseVelocity; + int16 _kbdVelocity; bool _halveDelay; uint8 _cheatBuff[KEYBUF_SIZE]; |