Fix mouse centering in menu

This commit is contained in:
nukeykt 2019-09-14 23:33:22 +09:00 committed by Christoph Oelckers
parent 3fbb171990
commit 90b005a44a
3 changed files with 7 additions and 9 deletions

View file

@ -62,7 +62,6 @@ void CMenuTextMgr::GetFontInfo(int nFont, const char *pString, int *pXSize, int
bool CGameMenuMgr::m_bInitialized = false;
bool CGameMenuMgr::m_bActive = false;
bool CGameMenuMgr::m_bFirstPush = true;
CGameMenuMgr::CGameMenuMgr()
{
@ -103,14 +102,11 @@ bool CGameMenuMgr::Push(CGameMenu *pMenu, int nItem)
{
if (nMenuPointer == 0)
{
mouseReadAbs(&m_prevmousepos, &g_mouseAbs);
m_mouselastactivity = -M_MOUSETIMEOUT;
m_mousewake_watchpoint = 0;
mouseLockToWindow(0);
if (m_bFirstPush)
m_bFirstPush = false;
else
mouseMoveToCenter();
mouseMoveToCenter();
mouseReadAbs(&m_prevmousepos, &g_mouseAbs);
}
dassert(pMenu != NULL);
if (nMenuPointer == 8)
@ -190,7 +186,7 @@ void CGameMenuMgr::Draw(void)
}
// Display the mouse cursor, except on touch devices.
if (MOUSEACTIVECONDITION && !m_bFirstPush)
if (MOUSEACTIVECONDITION)
{
vec2_t cursorpos = { m_mousepos.x + (7 << 16), m_mousepos.y + (6 << 16) };

View file

@ -462,7 +462,6 @@ class CGameMenuMgr
public:
static bool m_bInitialized;
static bool m_bActive;
static bool m_bFirstPush;
CGameMenu *pTempMenu;
CGameMenu *pActiveMenu;
CGameMenu *pMenuStack[8];

View file

@ -1109,7 +1109,10 @@ void mouseLockToWindow(char a)
void mouseMoveToCenter(void)
{
if (sdl_window)
SDL_WarpMouseInWindow(sdl_window, xdim / 2, ydim / 2);
{
g_mouseAbs = { xdim >> 1, ydim >> 1 };
SDL_WarpMouseInWindow(sdl_window, g_mouseAbs.x, g_mouseAbs.y);
}
}
//