Scoreboard squelch raw input update.

-Also made showcursor code for comm fall within raw input check.
This commit is contained in:
pierow 2023-09-11 17:48:01 -04:00
parent c95aa67ca9
commit 193f417144
3 changed files with 60 additions and 17 deletions

View file

@ -81,6 +81,7 @@
#include "mod/AvHServerVariables.h"
#include "util/STLUtil.h"
#include "ui/ScoreboardIcon.h"
#include <SDL2/SDL_mouse.h>
/* @2014
#include "common/itrackeruser.h"
extern ITrackerUser *g_pTrackerUser;
@ -177,6 +178,24 @@ void ScorePanel::HitTestPanel::internalMousePressed(MouseCode code)
{
_inputSignalDar[i]->mousePressed(code,this);
}
// Workaround for not being able to center mouse with raw input enabled.
if (CVAR_GET_FLOAT("m_rawinput") != 0)
{
if (SDL_GetRelativeMouseMode() == SDL_TRUE)
{
SDL_SetRelativeMouseMode(SDL_FALSE);
gEngfuncs.pfnSetMousePos(gEngfuncs.GetWindowCenterX(), gEngfuncs.GetWindowCenterY());
//#ifdef WIN32
//ShowCursor(FALSE);
//#endif
}
}
this->frameSinceEnteredSquelchMode = false;
}
}
@ -205,15 +224,10 @@ ScorePanel::ScorePanel(int x,int y,int wide,int tall) : Panel(0,0, ScreenWidth()
m_BGPanel->setBgColor(0, 0, 0, 96);
m_BGPanel->setParent(this);
m_BGPanel->setPos(x, y);
m_BGPanel->setSize(wide, tall);
//m_BGPanel->setBounds(x, y, wide, tall);
//m_BGPanel->addInputSignal(this);
//setBgColor(0, 0, 0, 96);
setBgColor(0, 0, 0, 255);
m_pCurrentHighlightLabel = NULL;
m_iHighlightRow = -1;
// : 0001073
@ -261,8 +275,8 @@ ScorePanel::ScorePanel(int x,int y,int wide,int tall) : Panel(0,0, ScreenWidth()
m_TitleLabel.setContentAlignment( vgui::Label::a_center );
LineBorder *border = new LineBorder(Color(60, 60, 60, 128));
setBorder(border);
setPaintBorderEnabled(true);
m_BGPanel->setBorder(border);
m_BGPanel->setPaintBorderEnabled(true);
int xpos = g_ColumnInfo[0].m_Width + 3;
if (ScreenWidth() >= 640)
@ -1574,7 +1588,7 @@ void CLabelHeader::paintBackground()
}
Panel::paintBackground();
setBgColor(oldBg);
}

View file

@ -52,6 +52,7 @@ private:
{
public:
virtual void internalMousePressed(MouseCode code);
bool frameSinceEnteredSquelchMode;
};
@ -77,8 +78,8 @@ private:
CLabelHeader m_PlayerEntries[NUM_COLUMNS][NUM_ROWS]; // Labels for the grid entries.
Panel* m_BGPanel;
ScorePanel::HitTestPanel m_HitTestPanel;
CommandButton *m_pCloseButton;
//ScorePanel::HitTestPanel m_HitTestPanel;
CommandButton *m_pCloseButton;
CLabelHeader* GetPlayerEntry(int x, int y) {return &m_PlayerEntries[x][y];}
vgui::BitmapTGA *m_pTrackerIcon;
@ -115,6 +116,9 @@ public:
bool m_bHasBeenSorted[MAX_PLAYERS];
int m_iLastKilledBy;
int m_fLastKillTime;
ScorePanel::HitTestPanel m_HitTestPanel;
public:
ScorePanel(int x,int y,int wide,int tall);

View file

@ -2246,11 +2246,13 @@ void AvHHud::ResetComponentsForUser3()
if (SDL_GetRelativeMouseMode() != SDL_TRUE)
{
SDL_SetRelativeMouseMode(SDL_TRUE);
#ifdef WIN32
//Reincrement windows cursor now that raw input is reenabled.
ShowCursor(TRUE);
#endif
}
}
#ifdef WIN32
ShowCursor(TRUE);
#endif
}
else
{
@ -2880,12 +2882,14 @@ int AvHHud::MsgFunc_SetTopDown(const char* pszName, int iSize, void* pbuf)
{
SDL_SetRelativeMouseMode(SDL_FALSE);
gEngfuncs.pfnSetMousePos(gEngfuncs.GetWindowCenterX(), gEngfuncs.GetWindowCenterY());
#ifdef WIN32
//Hide windows OS cursor while raw input is momentarily off.
ShowCursor(FALSE);
#endif
}
this->mFramesSinceEnteredTopdownMode = 0;
#ifdef WIN32
ShowCursor(FALSE);
#endif
}
@ -5397,6 +5401,27 @@ void AvHHud::UpdatePieMenuControl()
if(theScoreBoardIsOpen)
{
AvHPieMenuHandler::SetPieMenuControl("");
//Scoreboard squelch mode mouse centering code. This isn't a great place to put this, but it's here because piemenu uses similar scoreboard logic and raw input centering, so we need to differentiate to prevent bugs.
if (theScoreBoard->m_HitTestPanel.frameSinceEnteredSquelchMode == true)
{
// Workaround for not being able to center mouse with raw input enabled.
if (CVAR_GET_FLOAT("m_rawinput") != 0)
{
if (SDL_GetRelativeMouseMode() != SDL_TRUE)
{
SDL_SetRelativeMouseMode(SDL_TRUE);
//#ifdef WIN32
// ShowCursor(TRUE);
//#endif
}
}
}
else
{
theScoreBoard->m_HitTestPanel.frameSinceEnteredSquelchMode = true;
//theScoreBoard->m_frameSinceEnteredSquelchMode = true;
}
}
else
{