Fix #162: Center ingame mouse cursor after login

--HG--
branch : sdl2
hg/feature/sdl2
kaetemi 11 years ago
parent a307c383f9
commit 733455b5fb

@ -59,6 +59,8 @@ namespace NLGUI
/// get buttons state
NLMISC::TMouseButton getButtonState() const { return _Buttons; }
static const sint32 InvalidCoord = 0x80000000;
protected:
// (x,y) is from the TopLeft corner of the window
sint32 _PointerX; // Current pointer position (raw, before snapping)

@ -25,7 +25,7 @@ namespace NLGUI
CViewBase( param ),
_Buttons( NLMISC::noButton )
{
_PointerX = _PointerY = _PointerOldX = _PointerOldY = _PointerDownX = _PointerDownY = 0;
_PointerX = _PointerY = _PointerOldX = _PointerOldY = _PointerDownX = _PointerDownY = InvalidCoord;
_PointerDown = false;
_PointerVisible = true;
}

@ -169,8 +169,6 @@ bool IsMouseFreeLook()
return MouseFreeLook;
}
bool MouseCursorNoZero = true;
// *********************************************************************************
// Use this method to toggle the mouse (freelook -> cursor)
void SetMouseCursor (bool updatePos)
@ -194,7 +192,7 @@ void SetMouseCursor (bool updatePos)
{
sint32 ix, iy;
cursor->getPointerPos (ix, iy);
if (!MouseCursorNoZero || (ix != 0 || iy != 0))
if (ix != CViewPointer::InvalidCoord && iy != CViewPointer::InvalidCoord)
{
x = (float)ix / (float)width;
y = (float)iy / (float)height;

Loading…
Cancel
Save