From 193f417144177566532bb119ddfd513826e5fc1b Mon Sep 17 00:00:00 2001 From: pierow Date: Mon, 11 Sep 2023 17:48:01 -0400 Subject: [PATCH] Scoreboard squelch raw input update. -Also made showcursor code for comm fall within raw input check. --- main/source/cl_dll/vgui_ScorePanel.cpp | 32 +++++++++++++++------- main/source/cl_dll/vgui_ScorePanel.h | 8 ++++-- main/source/mod/AvHHud.cpp | 37 +++++++++++++++++++++----- 3 files changed, 60 insertions(+), 17 deletions(-) diff --git a/main/source/cl_dll/vgui_ScorePanel.cpp b/main/source/cl_dll/vgui_ScorePanel.cpp index 389d9ce4..3ae7ee4f 100644 --- a/main/source/cl_dll/vgui_ScorePanel.cpp +++ b/main/source/cl_dll/vgui_ScorePanel.cpp @@ -81,6 +81,7 @@ #include "mod/AvHServerVariables.h" #include "util/STLUtil.h" #include "ui/ScoreboardIcon.h" +#include /* @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); } diff --git a/main/source/cl_dll/vgui_ScorePanel.h b/main/source/cl_dll/vgui_ScorePanel.h index 847f14a3..91e36cb3 100644 --- a/main/source/cl_dll/vgui_ScorePanel.h +++ b/main/source/cl_dll/vgui_ScorePanel.h @@ -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); diff --git a/main/source/mod/AvHHud.cpp b/main/source/mod/AvHHud.cpp index 0c3cf20e..0da1d456 100644 --- a/main/source/mod/AvHHud.cpp +++ b/main/source/mod/AvHHud.cpp @@ -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 {