Allow to draw cursor outside visible area to avoid weird jumping around edges when pointing outside

This commit is contained in:
Petr Bartos 2022-03-23 18:02:23 +01:00
parent 0e99425a79
commit 36222228bb
2 changed files with 16 additions and 25 deletions

View file

@ -915,27 +915,23 @@ UI_MouseEvent
void UI_MouseEvent( int dx, int dy )
{
int i;
int bias;
menucommon_s* m;
if (!uis.activemenu)
return;
// convert X bias to 640 coords
bias = uis.bias / UI_GetXScale();
// update mouse screen position
uis.cursorx += dx;
if (uis.cursorx < -bias)
uis.cursorx = -bias;
else if (uis.cursorx > SCREEN_WIDTH+bias)
uis.cursorx = SCREEN_WIDTH+bias;
if (uis.cursorx < -16)
uis.cursorx = -16;
else if (uis.cursorx > SCREEN_WIDTH+16)
uis.cursorx = SCREEN_WIDTH+16;
uis.cursory += dy;
if (uis.cursory < 0)
uis.cursory = 0;
else if (uis.cursory > SCREEN_HEIGHT)
uis.cursory = SCREEN_HEIGHT;
if (uis.cursory < -16)
uis.cursory = -16;
else if (uis.cursory > SCREEN_HEIGHT+16)
uis.cursory = SCREEN_HEIGHT+16;
vr->menuCursorX = &uis.cursorx;
vr->menuCursorY = &uis.cursory;

View file

@ -5259,23 +5259,18 @@ UI_MouseEvent
*/
void _UI_MouseEvent( int dx, int dy )
{
int bias;
// convert X bias to 640 coords
bias = uiInfo.uiDC.bias / uiInfo.uiDC.xscale;
// update mouse screen position
uiInfo.uiDC.cursorx += dx;
if (uiInfo.uiDC.cursorx < -bias)
uiInfo.uiDC.cursorx = -bias;
else if (uiInfo.uiDC.cursorx > SCREEN_WIDTH+bias)
uiInfo.uiDC.cursorx = SCREEN_WIDTH+bias;
if (uiInfo.uiDC.cursorx < -16)
uiInfo.uiDC.cursorx = -16;
else if (uiInfo.uiDC.cursorx > SCREEN_WIDTH+16)
uiInfo.uiDC.cursorx = SCREEN_WIDTH+16;
uiInfo.uiDC.cursory += dy;
if (uiInfo.uiDC.cursory < 0)
uiInfo.uiDC.cursory = 0;
else if (uiInfo.uiDC.cursory > SCREEN_HEIGHT)
uiInfo.uiDC.cursory = SCREEN_HEIGHT;
if (uiInfo.uiDC.cursory < -16)
uiInfo.uiDC.cursory = -16;
else if (uiInfo.uiDC.cursory > SCREEN_HEIGHT+16)
uiInfo.uiDC.cursory = SCREEN_HEIGHT+16;
vr->menuCursorX = &uiInfo.uiDC.cursorx;
vr->menuCursorY = &uiInfo.uiDC.cursory;