BACKENDS: (OPENGL/SURFACESDL) - include mouse pointer in screen shakes

This is the original behaviour of DOS games (where the screen shakes are done by writing certain offsets into the crt cotnrol register of the vga adapter).

Usually it doesn't matter much, since the shake is an effect that passes quickly. But the difference can be noticed in cases like DOTT when switching on the stereo in green tentacle's room. The shaking will continue until the stereo is turned off again. In that case it is really more appealing if the mouse cursor "sticks" to the background.
This commit is contained in:
athrxx 2021-11-16 19:19:02 +01:00
parent d78295a8ca
commit 3b061ae0e8
3 changed files with 16 additions and 3 deletions

View file

@ -67,7 +67,7 @@ OpenGLGraphicsManager::OpenGLGraphicsManager()
_cursor(nullptr),
_cursorHotspotX(0), _cursorHotspotY(0),
_cursorHotspotXScaled(0), _cursorHotspotYScaled(0), _cursorWidthScaled(0), _cursorHeightScaled(0),
_cursorKeyColor(0), _cursorDontScale(false), _cursorPaletteEnabled(false)
_cursorKeyColor(0), _cursorDontScale(false), _cursorPaletteEnabled(false), _shakeOffsetScaled()
#ifdef USE_OSD
, _osdMessageChangeRequest(false), _osdMessageAlpha(0), _osdMessageFadeStartTime(0), _osdMessageSurface(nullptr),
_osdIconSurface(nullptr)
@ -537,8 +537,8 @@ void OpenGLGraphicsManager::updateScreen() {
_backBuffer.enableBlend(Framebuffer::kBlendModePremultipliedTransparency);
g_context.getActivePipeline()->drawTexture(_cursor->getGLTexture(),
_cursorX - _cursorHotspotXScaled,
_cursorY - _cursorHotspotYScaled,
_cursorX - _cursorHotspotXScaled + _shakeOffsetScaled.x,
_cursorY - _cursorHotspotYScaled + _shakeOffsetScaled.y,
_cursorWidthScaled, _cursorHeightScaled);
}
@ -1257,6 +1257,9 @@ void OpenGLGraphicsManager::recalculateDisplayAreas() {
_gameDrawRect.width(),
_gameDrawRect.height());
_shakeOffsetScaled = Common::Point(_gameScreenShakeXOffset * _activeArea.drawRect.width() / _activeArea.width,
_gameScreenShakeYOffset * _activeArea.drawRect.height() / _activeArea.height);
// Update the cursor position to adjust for new display area.
setMousePosition(_cursorX, _cursorY);