From 1c8668638d0bb914314f701f68e2420a93c34455 Mon Sep 17 00:00:00 2001 From: pierow Date: Sun, 10 Sep 2023 16:34:52 -0400 Subject: [PATCH] expand scoreboard panel and hitpanel so cursor can hit anywhere on screen --- main/source/cl_dll/vgui_ScorePanel.cpp | 26 +++++++++++++++++++------- main/source/cl_dll/vgui_ScorePanel.h | 1 + 2 files changed, 20 insertions(+), 7 deletions(-) diff --git a/main/source/cl_dll/vgui_ScorePanel.cpp b/main/source/cl_dll/vgui_ScorePanel.cpp index bc98a206..efe84070 100644 --- a/main/source/cl_dll/vgui_ScorePanel.cpp +++ b/main/source/cl_dll/vgui_ScorePanel.cpp @@ -191,7 +191,7 @@ vgui::Color BuildColor( int R, int G, int B, float gamma ) //----------------------------------------------------------------------------- // Purpose: Create the ScoreBoard panel //----------------------------------------------------------------------------- -ScorePanel::ScorePanel(int x,int y,int wide,int tall) : Panel(x,y,wide,tall) +ScorePanel::ScorePanel(int x,int y,int wide,int tall) : Panel(0,0, ScreenWidth(), ScreenHeight()) { CSchemeManager *pSchemes = gViewPort->GetSchemeManager(); SchemeHandle_t hTitleScheme = pSchemes->getSchemeHandle("Scoreboard Title Text"); @@ -201,7 +201,19 @@ ScorePanel::ScorePanel(int x,int y,int wide,int tall) : Panel(x,y,wide,tall) Font *smallfont = pSchemes->getFont(hSmallScheme); Font *tinyfont = pSchemes->getFont(hTinyScheme); - setBgColor(0, 0, 0, 96); + m_BGPanel = new Panel(0, 0, 0, 96); + + 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 @@ -260,7 +272,7 @@ ScorePanel::ScorePanel(int x,int y,int wide,int tall) : Panel(x,y,wide,tall) } m_TitleLabel.setBounds(xpos, 4, wide, SBOARD_TITLE_SIZE_Y); m_TitleLabel.setContentFitted(false); - m_TitleLabel.setParent(this); + m_TitleLabel.setParent(m_BGPanel); // Setup the header (labels like "name", "class", etc..). m_HeaderGrid.SetDimensions(NUM_COLUMNS, 1); @@ -323,7 +335,7 @@ ScorePanel::ScorePanel(int x,int y,int wide,int tall) : Panel(x,y,wide,tall) m_HeaderGrid.AutoSetRowHeights(); m_HeaderGrid.setBounds(X_BORDER, SBOARD_TITLE_SIZE_Y, wide - X_BORDER*2, m_HeaderGrid.GetRowHeight(0)); - m_HeaderGrid.setParent(this); + m_HeaderGrid.setParent(m_BGPanel); m_HeaderGrid.setBgColor(0,0,0,255); @@ -332,7 +344,7 @@ ScorePanel::ScorePanel(int x,int y,int wide,int tall) : Panel(x,y,wide,tall) m_HeaderGrid.getBounds(headerX, headerY, headerWidth, headerHeight); m_PlayerList.setBounds(headerX, headerY+headerHeight, headerWidth, tall - headerY - headerHeight - 6); m_PlayerList.setBgColor(0,0,0,255); - m_PlayerList.setParent(this); + m_PlayerList.setParent(m_BGPanel); for(int row=0; row < NUM_ROWS; row++) { @@ -363,11 +375,11 @@ ScorePanel::ScorePanel(int x,int y,int wide,int tall) : Panel(x,y,wide,tall) // Add the hit test panel. It is invisible and traps mouse clicks so we can go into squelch mode. m_HitTestPanel.setBgColor(0,0,0,255); m_HitTestPanel.setParent(this); - m_HitTestPanel.setBounds(0, 0, wide, tall); + m_HitTestPanel.setBounds(0, 0, ScreenWidth(), ScreenWidth()); m_HitTestPanel.addInputSignal(this); m_pCloseButton = new CommandButton( "x", wide-XRES(12 + 4), YRES(2), XRES( 12 ) , YRES( 12 ) ); - m_pCloseButton->setParent( this ); + m_pCloseButton->setParent(m_BGPanel); m_pCloseButton->addActionSignal( new CMenuHandler_StringCommandWatch( "-showscores", true ) ); m_pCloseButton->setBgColor(0,0,0,255); m_pCloseButton->setFgColor( 255, 255, 255, 0 ); diff --git a/main/source/cl_dll/vgui_ScorePanel.h b/main/source/cl_dll/vgui_ScorePanel.h index adcf1be9..847f14a3 100644 --- a/main/source/cl_dll/vgui_ScorePanel.h +++ b/main/source/cl_dll/vgui_ScorePanel.h @@ -76,6 +76,7 @@ private: CGrid m_PlayerGrids[NUM_ROWS]; // The grid with player and team info. CLabelHeader m_PlayerEntries[NUM_COLUMNS][NUM_ROWS]; // Labels for the grid entries. + Panel* m_BGPanel; ScorePanel::HitTestPanel m_HitTestPanel; CommandButton *m_pCloseButton; CLabelHeader* GetPlayerEntry(int x, int y) {return &m_PlayerEntries[x][y];}