expand scoreboard panel and hitpanel so cursor can hit anywhere on screen

This commit is contained in:
pierow 2023-09-10 16:34:52 -04:00
parent b44a8b7f63
commit 1c8668638d
2 changed files with 20 additions and 7 deletions

View file

@ -191,7 +191,7 @@ vgui::Color BuildColor( int R, int G, int B, float gamma )
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
// Purpose: Create the ScoreBoard panel // 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(); CSchemeManager *pSchemes = gViewPort->GetSchemeManager();
SchemeHandle_t hTitleScheme = pSchemes->getSchemeHandle("Scoreboard Title Text"); 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 *smallfont = pSchemes->getFont(hSmallScheme);
Font *tinyfont = pSchemes->getFont(hTinyScheme); 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_pCurrentHighlightLabel = NULL;
m_iHighlightRow = -1; m_iHighlightRow = -1;
// : 0001073 // : 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.setBounds(xpos, 4, wide, SBOARD_TITLE_SIZE_Y);
m_TitleLabel.setContentFitted(false); m_TitleLabel.setContentFitted(false);
m_TitleLabel.setParent(this); m_TitleLabel.setParent(m_BGPanel);
// Setup the header (labels like "name", "class", etc..). // Setup the header (labels like "name", "class", etc..).
m_HeaderGrid.SetDimensions(NUM_COLUMNS, 1); 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.AutoSetRowHeights();
m_HeaderGrid.setBounds(X_BORDER, SBOARD_TITLE_SIZE_Y, wide - X_BORDER*2, m_HeaderGrid.GetRowHeight(0)); 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); 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_HeaderGrid.getBounds(headerX, headerY, headerWidth, headerHeight);
m_PlayerList.setBounds(headerX, headerY+headerHeight, headerWidth, tall - headerY - headerHeight - 6); m_PlayerList.setBounds(headerX, headerY+headerHeight, headerWidth, tall - headerY - headerHeight - 6);
m_PlayerList.setBgColor(0,0,0,255); m_PlayerList.setBgColor(0,0,0,255);
m_PlayerList.setParent(this); m_PlayerList.setParent(m_BGPanel);
for(int row=0; row < NUM_ROWS; row++) 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. // 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.setBgColor(0,0,0,255);
m_HitTestPanel.setParent(this); m_HitTestPanel.setParent(this);
m_HitTestPanel.setBounds(0, 0, wide, tall); m_HitTestPanel.setBounds(0, 0, ScreenWidth(), ScreenWidth());
m_HitTestPanel.addInputSignal(this); m_HitTestPanel.addInputSignal(this);
m_pCloseButton = new CommandButton( "x", wide-XRES(12 + 4), YRES(2), XRES( 12 ) , YRES( 12 ) ); 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->addActionSignal( new CMenuHandler_StringCommandWatch( "-showscores", true ) );
m_pCloseButton->setBgColor(0,0,0,255); m_pCloseButton->setBgColor(0,0,0,255);
m_pCloseButton->setFgColor( 255, 255, 255, 0 ); m_pCloseButton->setFgColor( 255, 255, 255, 0 );

View file

@ -76,6 +76,7 @@ private:
CGrid m_PlayerGrids[NUM_ROWS]; // The grid with player and team info. CGrid m_PlayerGrids[NUM_ROWS]; // The grid with player and team info.
CLabelHeader m_PlayerEntries[NUM_COLUMNS][NUM_ROWS]; // Labels for the grid entries. CLabelHeader m_PlayerEntries[NUM_COLUMNS][NUM_ROWS]; // Labels for the grid entries.
Panel* m_BGPanel;
ScorePanel::HitTestPanel m_HitTestPanel; ScorePanel::HitTestPanel m_HitTestPanel;
CommandButton *m_pCloseButton; CommandButton *m_pCloseButton;
CLabelHeader* GetPlayerEntry(int x, int y) {return &m_PlayerEntries[x][y];} CLabelHeader* GetPlayerEntry(int x, int y) {return &m_PlayerEntries[x][y];}