From d4d05b21c561d9d8f1bb8b4b9bff66a734ab6e55 Mon Sep 17 00:00:00 2001 From: pierow Date: Wed, 3 Feb 2021 23:15:38 -0500 Subject: [PATCH] Revert setmousevisibility showcursor change. Old piemenu showcursor code fixed. --- main/source/mod/AvHPieMenuHandler.cpp | 21 ++++++++++++++++----- main/source/ui/UIManager.cpp | 25 +++++++++++++++---------- 2 files changed, 31 insertions(+), 15 deletions(-) diff --git a/main/source/mod/AvHPieMenuHandler.cpp b/main/source/mod/AvHPieMenuHandler.cpp index 8bdf7cca..74f61374 100644 --- a/main/source/mod/AvHPieMenuHandler.cpp +++ b/main/source/mod/AvHPieMenuHandler.cpp @@ -123,7 +123,8 @@ void AvHPieMenuHandler::ClosePieMenu(void) IN_ResetMouse(); gHUD.ShowCrosshair(); - sPieMenuOpen = false; + // 2021 - moved to InternalClosePieMenu for ShowCursor fix. + //sPieMenuOpen = false; } @@ -137,6 +138,12 @@ void AvHPieMenuHandler::InternalClosePieMenu(void) if(!gHUD.GetInTopDownMode()) { gHUD.GetManager().SetMouseVisibility(false); + + // OS cursor displaying over in game cursor fix. Remove if showcursor code in SetMouseVisibility is made bug free. + #ifdef WIN32 + if(sPieMenuOpen) + ShowCursor(TRUE); + #endif } theMarineMenu->SetFadeState(false); @@ -146,6 +153,7 @@ void AvHPieMenuHandler::InternalClosePieMenu(void) } sLastNodeHighlighted = NULL; + // Return to raw input after menu closes if (CVAR_GET_FLOAT("m_rawinput") != 0) { SDL_SetRelativeMouseMode(SDL_TRUE); @@ -160,7 +168,7 @@ void AvHPieMenuHandler::InternalClosePieMenu(void) // } // } } - + sPieMenuOpen = false; } void AvHPieMenuHandler::OpenPieMenu(void) @@ -181,18 +189,21 @@ void AvHPieMenuHandler::OpenPieMenu(void) if(!gHUD.GetInTopDownMode()) { gHUD.GetManager().SetMouseVisibility(true); + + // OS cursor displaying over in game cursor fix. Remove if showcursor code in SetMouseVisibility is made bug free. + #ifdef WIN32 + ShowCursor(FALSE); + #endif } gHUD.HideCrosshair(); + // Workaround for not being able to center mouse with raw input enabled. if (CVAR_GET_FLOAT("m_rawinput") != 0) { SDL_SetRelativeMouseMode(SDL_FALSE); gEngfuncs.pfnSetMousePos(gEngfuncs.GetWindowCenterX(), gEngfuncs.GetWindowCenterY()); } - //App::getInstance()->setCursorOveride(App::getInstance()->getScheme()->getCursor(Scheme::scu_none)); - //App::getInstance()->setCursorOveride(gHUD.GetManager().mBlankCursor); - // Only do this when in full screen //App::getInstance()->setCursorPos(ScreenWidth/2, ScreenHeight/2); diff --git a/main/source/ui/UIManager.cpp b/main/source/ui/UIManager.cpp index 3cb57ee2..84c06a5b 100644 --- a/main/source/ui/UIManager.cpp +++ b/main/source/ui/UIManager.cpp @@ -307,13 +307,16 @@ void UIManager::SetMouseVisibility(bool inState) //App::getInstance()->setCursorOveride(App::getInstance()->getScheme()->getCursor(Scheme::SchemeCursor::scu_arrow)); // Remove above line and put this line back in for sprite cursors App::getInstance()->setCursorOveride(this->mBlankCursor); -#ifdef WIN32 - // 2021 - Prevent windows OS cursor from appearing over sprite cursor. - // Uncomment below to track windows showcursor value because you can only increment or decrement by 1 with no min or max on the value so it can get stuck in a high or low range. - // If the cursor breaks, create a for loop to increment or decrement the value as necessary to fix it. https://devblogs.microsoft.com/oldnewthing/20091217-00/?p=15643 - /*int sc = */ShowCursor(FALSE); - //gEngfuncs.Con_Printf("showcursor:%d\n", sc); -#endif + + // OS cursor show/hide fix for m_rawinput 0. Disabled until we can find a way to check if options menu is open. Otherwise cursor is hidden in options menu when commanding or spectating. + // If uncommenting this, remove Showcursor code in PieMenuHandler. +//#ifdef WIN32 +// // 2021 - Prevent windows OS cursor from appearing over sprite cursor. +// // Uncomment below to track windows showcursor value because you can only increment or decrement by 1 with no min or max on the value so it can get stuck in a high or low range. +// // If the cursor breaks, create a for loop to increment or decrement the value as necessary to fix it. https://devblogs.microsoft.com/oldnewthing/20091217-00/?p=15643 +// /*int sc = */ShowCursor(FALSE); +// //gEngfuncs.Con_Printf("showcursor:%d\n", sc); +//#endif } else { @@ -325,9 +328,11 @@ void UIManager::SetMouseVisibility(bool inState) // Hide cursor again App::getInstance()->setCursorOveride( App::getInstance()->getScheme()->getCursor(Scheme::scu_none) ); -#ifdef WIN32 - ShowCursor(TRUE); -#endif + + // OS cursor show/hide fix for m_rawinput 0. +//#ifdef WIN32 +// ShowCursor(TRUE); +//#endif } //App::getInstance()->setCursorOveride( App::getInstance()->getScheme()->getCursor(Scheme::SchemeCursor::scu_none) );