mirror of
https://github.com/ENSL/NS.git
synced 2024-11-10 07:11:38 +00:00
fix mouse centering not working correctly with non-native fullscreen resolutions
This commit is contained in:
parent
dfd82fcec5
commit
61f3c7be61
7 changed files with 59 additions and 10 deletions
|
@ -34,6 +34,7 @@ public:
|
|||
int m_iRes;
|
||||
cvar_t *m_pCvarStealMouse;
|
||||
cvar_t *m_pCvarDraw;
|
||||
bool m_bWindowed;
|
||||
|
||||
int m_iFontHeight;
|
||||
int DrawHudNumber(int x, int y, int iFlags, int iNumber, int r, int g, int b );
|
||||
|
|
|
@ -326,6 +326,21 @@ void CHud :: VidInit( void )
|
|||
|
||||
gHUD.SetViewport(theViewPort);
|
||||
|
||||
//Determine if we're playing in windowed mode so we can do mouse centering correctly later.
|
||||
for (Uint32 id = 0; id < UINT32_MAX; ++id)
|
||||
{
|
||||
SDL_Window* theWindow = SDL_GetWindowFromID(id);
|
||||
if (theWindow)
|
||||
{
|
||||
if (!(SDL_GetWindowFlags(theWindow) & SDL_WINDOW_FULLSCREEN))
|
||||
{
|
||||
m_bWindowed = true;
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (CVAR_GET_FLOAT("hud_style") == 2.0f)
|
||||
{
|
||||
mFont.Load("sprites/nl/font_arial");
|
||||
|
|
|
@ -185,9 +185,16 @@ void ScorePanel::HitTestPanel::internalMousePressed(MouseCode code)
|
|||
if (SDL_GetRelativeMouseMode() == SDL_TRUE)
|
||||
{
|
||||
SDL_SetRelativeMouseMode(SDL_FALSE);
|
||||
//gEngfuncs.pfnSetMousePos(gEngfuncs.GetWindowCenterX(), gEngfuncs.GetWindowCenterY());
|
||||
|
||||
//Fix for windowed mode centering being incorrect.
|
||||
gEngfuncs.pfnSetMousePos(ScreenWidth() / 2, ScreenHeight() / 2);
|
||||
if (gHUD.m_bWindowed)
|
||||
{
|
||||
gEngfuncs.pfnSetMousePos(ScreenWidth() / 2, ScreenHeight() / 2);
|
||||
}
|
||||
else
|
||||
{
|
||||
gEngfuncs.pfnSetMousePos(gEngfuncs.GetWindowCenterX(), gEngfuncs.GetWindowCenterY());
|
||||
}
|
||||
|
||||
//#ifdef WIN32
|
||||
//ShowCursor(FALSE);
|
||||
|
|
|
@ -1524,8 +1524,14 @@ void TeamFortressViewport::HideOptionsMenu()
|
|||
|
||||
gHUD.GetManager().SetMouseVisibility(false);
|
||||
|
||||
//gEngfuncs.pfnSetMousePos(gEngfuncs.GetWindowCenterX(), gEngfuncs.GetWindowCenterY());
|
||||
gEngfuncs.pfnSetMousePos(ScreenWidth() / 2, ScreenHeight() / 2);
|
||||
if (gHUD.m_bWindowed)
|
||||
{
|
||||
gEngfuncs.pfnSetMousePos(ScreenWidth() / 2, ScreenHeight() / 2);
|
||||
}
|
||||
else
|
||||
{
|
||||
gEngfuncs.pfnSetMousePos(gEngfuncs.GetWindowCenterX(), gEngfuncs.GetWindowCenterY());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -2892,8 +2892,15 @@ int AvHHud::MsgFunc_SetTopDown(const char* pszName, int iSize, void* pbuf)
|
|||
if (CVAR_GET_FLOAT("m_rawinput") != 0)
|
||||
{
|
||||
SDL_SetRelativeMouseMode(SDL_FALSE);
|
||||
//gEngfuncs.pfnSetMousePos(gEngfuncs.GetWindowCenterX(), gEngfuncs.GetWindowCenterY());
|
||||
gEngfuncs.pfnSetMousePos(ScreenWidth() / 2, ScreenHeight() / 2);
|
||||
|
||||
if (gHUD.m_bWindowed)
|
||||
{
|
||||
gEngfuncs.pfnSetMousePos(ScreenWidth() / 2, ScreenHeight() / 2);
|
||||
}
|
||||
else
|
||||
{
|
||||
gEngfuncs.pfnSetMousePos(gEngfuncs.GetWindowCenterX(), gEngfuncs.GetWindowCenterY());
|
||||
}
|
||||
|
||||
#ifdef WIN32
|
||||
//Hide windows OS cursor while raw input is momentarily off.
|
||||
|
|
|
@ -90,8 +90,14 @@ void AvHParticleEditorHandler::ToggleEdit()
|
|||
gHUD.ToggleMouse();
|
||||
|
||||
// Set mouse position to center so it doesn't jar our view
|
||||
//gEngfuncs.pfnSetMousePos(gEngfuncs.GetWindowCenterX(), gEngfuncs.GetWindowCenterY());
|
||||
gEngfuncs.pfnSetMousePos(ScreenWidth() / 2, ScreenHeight() / 2);
|
||||
if (gHUD.m_bWindowed)
|
||||
{
|
||||
gEngfuncs.pfnSetMousePos(ScreenWidth() / 2, ScreenHeight() / 2);
|
||||
}
|
||||
else
|
||||
{
|
||||
gEngfuncs.pfnSetMousePos(gEngfuncs.GetWindowCenterX(), gEngfuncs.GetWindowCenterY());
|
||||
}
|
||||
|
||||
sInEditMode = false;
|
||||
}
|
||||
|
|
|
@ -203,8 +203,15 @@ void AvHPieMenuHandler::OpenPieMenu(void)
|
|||
if (CVAR_GET_FLOAT("m_rawinput") != 0 && !sPieMenuOpen)
|
||||
{
|
||||
SDL_SetRelativeMouseMode(SDL_FALSE);
|
||||
//gEngfuncs.pfnSetMousePos(gEngfuncs.GetWindowCenterX(), gEngfuncs.GetWindowCenterY());
|
||||
gEngfuncs.pfnSetMousePos(ScreenWidth() / 2, ScreenHeight() / 2);
|
||||
|
||||
if (gHUD.m_bWindowed)
|
||||
{
|
||||
gEngfuncs.pfnSetMousePos(ScreenWidth() / 2, ScreenHeight() / 2);
|
||||
}
|
||||
else
|
||||
{
|
||||
gEngfuncs.pfnSetMousePos(gEngfuncs.GetWindowCenterX(), gEngfuncs.GetWindowCenterY());
|
||||
}
|
||||
}
|
||||
|
||||
// Only do this when in full screen
|
||||
|
|
Loading…
Reference in a new issue