OS cursor over sprite cursor fix

This commit is contained in:
pierow 2021-01-31 18:59:14 -05:00
parent 9842b437a0
commit ce5f18f1dc
2 changed files with 46 additions and 33 deletions

View file

@ -123,6 +123,13 @@ void AvHPieMenuHandler::ClosePieMenu(void)
IN_ResetMouse();
gHUD.ShowCrosshair();
// Reset showcursor value after forcing it to hide
// Check if piemenu is open or else windows will keep decrementing the showcursor value every time -popupmenu is called from closing the console
if (sPieMenuOpen)
{
gHUD.GetManager().SetMouseVisibility(false);
}
sPieMenuOpen = false;
}
@ -133,15 +140,11 @@ void AvHPieMenuHandler::InternalClosePieMenu(void)
if(gHUD.GetManager().GetVGUIComponentNamed(sPieMenuName, theMarineMenu))
{
// TODO: Select option on menu before closing it!
if(!gHUD.GetInTopDownMode())
{
gHUD.GetManager().SetMouseVisibility(false);
//attempt at fixing OS cursor appearing over game's cursor
#ifdef WIN32
ShowCursor(TRUE);
#endif
}
//// TODO: Select option on menu before closing it!
//if(!gHUD.GetInTopDownMode())
//{
// gHUD.GetManager().SetMouseVisibility(false);
//}
theMarineMenu->SetFadeState(false);
if(sLastNodeHighlighted)
@ -185,10 +188,6 @@ void AvHPieMenuHandler::OpenPieMenu(void)
if(!gHUD.GetInTopDownMode())
{
gHUD.GetManager().SetMouseVisibility(true);
//attempt at fixing OS cursor appearing over game's cursor
#ifdef WIN32
ShowCursor(FALSE);
#endif
}
gHUD.HideCrosshair();

View file

@ -293,6 +293,9 @@ bool UIManager::SetLMBActionRelative(const TRTag& inTag)
}
void UIManager::SetMouseVisibility(bool inState)
{
// 2021 - Check if we need to run code. Prevents showcursor from incrementing or decrementing outside of useful range.
if (g_iVisibleMouse != inState)
{
// To change whether the mouse is visible, just change this variable
g_iVisibleMouse = inState;
@ -304,6 +307,13 @@ 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
}
else
{
@ -315,9 +325,13 @@ void UIManager::SetMouseVisibility(bool inState)
// Hide cursor again
App::getInstance()->setCursorOveride( App::getInstance()->getScheme()->getCursor(Scheme::scu_none) );
#ifdef WIN32
ShowCursor(TRUE);
#endif
}
//App::getInstance()->setCursorOveride( App::getInstance()->getScheme()->getCursor(Scheme::SchemeCursor::scu_none) );
}
}