fix hotspot handling when overlay visible
svn-id: r22631
This commit is contained in:
parent
0e6831fa32
commit
14774d1760
3 changed files with 22 additions and 21 deletions
|
@ -1271,8 +1271,8 @@ void OSystem_SDL::setMouseCursor(const byte *buf, uint w, uint h, int hotspot_x,
|
||||||
if (w == 0 || h == 0)
|
if (w == 0 || h == 0)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
_mouseHotspotX = hotspot_x;
|
_mouseCurState.hotX = hotspot_x;
|
||||||
_mouseHotspotY = hotspot_y;
|
_mouseCurState.hotY = hotspot_y;
|
||||||
|
|
||||||
_mouseKeyColor = keycolor;
|
_mouseKeyColor = keycolor;
|
||||||
|
|
||||||
|
@ -1353,18 +1353,26 @@ void OSystem_SDL::blitCursor() {
|
||||||
dstPtr += _mouseOrigSurface->pitch - w * 2;
|
dstPtr += _mouseOrigSurface->pitch - w * 2;
|
||||||
}
|
}
|
||||||
|
|
||||||
int hW, hH, hH1;
|
int hW, hH;
|
||||||
|
|
||||||
if (_cursorTargetScale >= _scaleFactor) {
|
if (_cursorTargetScale >= _scaleFactor) {
|
||||||
hW = w;
|
hW = w;
|
||||||
hH = hH1 = h;
|
hH = h;
|
||||||
|
_mouseCurState.hHotX = _mouseCurState.hotX;
|
||||||
|
_mouseCurState.hHotY = _mouseCurState.hotY;
|
||||||
} else {
|
} else {
|
||||||
hW = w * _scaleFactor / _cursorTargetScale;
|
hW = w * _scaleFactor / _cursorTargetScale;
|
||||||
hH = hH1 = h * _scaleFactor / _cursorTargetScale;
|
hH = h * _scaleFactor / _cursorTargetScale;
|
||||||
|
_mouseCurState.hHotX = _mouseCurState.hotX * _scaleFactor /
|
||||||
|
_cursorTargetScale;
|
||||||
|
_mouseCurState.hHotY = _mouseCurState.hotY * _scaleFactor /
|
||||||
|
_cursorTargetScale;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int hH1 = hH; // store original to pass to aspect-correction function later
|
||||||
if (_adjustAspectRatio && _cursorTargetScale == 1) {
|
if (_adjustAspectRatio && _cursorTargetScale == 1) {
|
||||||
hH = real2Aspect(hH - 1) + 1;
|
hH = real2Aspect(hH - 1) + 1;
|
||||||
|
_mouseCurState.hHotY = real2Aspect(_mouseCurState.hHotY);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (_mouseCurState.hW != hW || _mouseCurState.hH != hH) {
|
if (_mouseCurState.hW != hW || _mouseCurState.hH != hH) {
|
||||||
|
@ -1473,20 +1481,14 @@ void OSystem_SDL::drawMouse() {
|
||||||
scale = _scaleFactor;
|
scale = _scaleFactor;
|
||||||
width = _screenWidth;
|
width = _screenWidth;
|
||||||
height = _screenHeight;
|
height = _screenHeight;
|
||||||
|
dst.x = _mouseCurState.x - _mouseCurState.hotX;
|
||||||
|
dst.y = _mouseCurState.y - _mouseCurState.hotY;
|
||||||
} else {
|
} else {
|
||||||
scale = 1;
|
scale = 1;
|
||||||
width = _overlayWidth;
|
width = _overlayWidth;
|
||||||
height = _overlayHeight;
|
height = _overlayHeight;
|
||||||
}
|
dst.x = _mouseCurState.x - _mouseCurState.hHotX;
|
||||||
|
dst.y = _mouseCurState.y - _mouseCurState.hHotY;
|
||||||
useCursorScaling = (scale >= _cursorTargetScale);
|
|
||||||
|
|
||||||
if (useCursorScaling) {
|
|
||||||
dst.x = _mouseCurState.x - _mouseHotspotX / _cursorTargetScale;
|
|
||||||
dst.y = _mouseCurState.y - _mouseHotspotY / _cursorTargetScale;
|
|
||||||
} else {
|
|
||||||
dst.x = _mouseCurState.x - _mouseHotspotX;
|
|
||||||
dst.y = _mouseCurState.y - _mouseHotspotY;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (_overlayVisible) {
|
if (_overlayVisible) {
|
||||||
|
|
|
@ -293,8 +293,10 @@ protected:
|
||||||
};
|
};
|
||||||
|
|
||||||
struct MousePos {
|
struct MousePos {
|
||||||
int16 x, y, w, h, hW, hH;
|
int16 x, y, w, h, hotX, hotY, hW, hH, hHotX, hHotY;
|
||||||
MousePos() : x(0), y(0), w(0), h(0), hW(0), hH(0) {}
|
MousePos() : x(0), y(0), w(0), h(0), hotX(0), hotY(0),
|
||||||
|
hW(0), hH(0), hHotX(0), hHotY(0)
|
||||||
|
{ }
|
||||||
};
|
};
|
||||||
|
|
||||||
// mouse
|
// mouse
|
||||||
|
@ -304,8 +306,6 @@ protected:
|
||||||
byte *_mouseData;
|
byte *_mouseData;
|
||||||
SDL_Rect _mouseBackup;
|
SDL_Rect _mouseBackup;
|
||||||
MousePos _mouseCurState;
|
MousePos _mouseCurState;
|
||||||
int16 _mouseHotspotX;
|
|
||||||
int16 _mouseHotspotY;
|
|
||||||
byte _mouseKeyColor;
|
byte _mouseKeyColor;
|
||||||
int _cursorTargetScale;
|
int _cursorTargetScale;
|
||||||
bool _cursorPaletteDisabled;
|
bool _cursorPaletteDisabled;
|
||||||
|
|
|
@ -180,8 +180,7 @@ OSystem_SDL::OSystem_SDL()
|
||||||
_samplesPerSec(0),
|
_samplesPerSec(0),
|
||||||
_cdrom(0), _scalerProc(0), _modeChanged(false), _dirtyChecksums(0),
|
_cdrom(0), _scalerProc(0), _modeChanged(false), _dirtyChecksums(0),
|
||||||
_mouseVisible(false), _mouseDrawn(false), _mouseData(0), _mouseSurface(0),
|
_mouseVisible(false), _mouseDrawn(false), _mouseData(0), _mouseSurface(0),
|
||||||
_mouseOrigSurface(0), _mouseHotspotX(0), _mouseHotspotY(0), _cursorTargetScale(1),
|
_mouseOrigSurface(0), _cursorTargetScale(1), _cursorPaletteDisabled(true),
|
||||||
_cursorPaletteDisabled(true),
|
|
||||||
_joystick(0),
|
_joystick(0),
|
||||||
_currentShakePos(0), _newShakePos(0),
|
_currentShakePos(0), _newShakePos(0),
|
||||||
_paletteDirtyStart(0), _paletteDirtyEnd(0),
|
_paletteDirtyStart(0), _paletteDirtyEnd(0),
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue