CFirstMenu :: CFirstMenu(int iTrans, int iRemoveMe, int x, int y, int wide, int tall) : CMenuPanel(iTrans, iRemoveMe, x,y,wide,tall) { CSchemeManager *pSchemes = gViewPort->GetSchemeManager(); SchemeHandle_t hTitleScheme = pSchemes->getSchemeHandle( "Title Font" ); int r, g, b, a; m_pPanel = new CTransparentPanel( 200, XRES(80), YRES(80), XRES(BASE_WIDTH), YRES(BASE_HEIGHT)); m_pPanel->setParent( this ); m_pPanel->setBorder( new LineBorder( Color(255 * 0.7,170 * 0.7,0,0) ) ); m_pCancelButton = new CommandButton( gHUD.m_TextMessage.BufferedLocaliseTextString( "Cancel" ), XRES(50), YRES(279), XRES(378), YRES(42)); m_pCancelButton->setContentAlignment(vgui::Label::a_center); m_pCancelButton->setParent( m_pPanel ); m_pCancelButton->addActionSignal( new CMenuHandler_TextWindow(HIDE_TEXTWINDOW) ); m_pTitle = new Label( "", XRES(1), YRES(1), XRES(478), YRES(58) ); m_pTitle->setParent( m_pPanel ); m_pTitle->setFont( pSchemes->getFont(hTitleScheme) ); pSchemes->getFgColor( hTitleScheme, r, g, b, a ); m_pTitle->setFgColor( r, g, b, a ); pSchemes->getBgColor( hTitleScheme, r, g, b, a ); m_pTitle->setBgColor( r, g, b, a ); m_pTitle->setContentAlignment( vgui::Label::a_center ); m_pTitle->setText( "Your First Menu" ); // Start - VGUI Tutorial 2 m_pSpeak = new CommandButton( "Say something", XRES(1), YRES(61), XRES(478), YRES(58)); m_pSpeak->setContentAlignment( vgui::Label::a_center ); m_pSpeak->setParent( m_pPanel ); m_pSpeak->addActionSignal( new CMenuHandler_StringCommand( "test_say" ) ); // End - VGUI Tutorial 2 // Start - VGUI Tutorial 3 /* m_pEditbox = new TextEntry( "Testing!", XRES(200), YRES(230), XRES(230), 17); m_pEditbox->setVisible( true ); m_pEditbox->setParent( m_pPanel ); */ m_pMyPicture = new CImageLabel( "cross", XRES(BASE_WIDTH/2), YRES(BASE_HEIGHT/2) ); m_pMyPicture->setParent( m_pPanel ); m_pMyPicture->setVisible( true ); // End - VGUI Tutorial 3 }
// Creation CClassMenuPanel::CClassMenuPanel(int iTrans, int iRemoveMe, int x,int y,int wide,int tall) : CMenuPanel(iTrans, iRemoveMe, x,y,wide,tall) { // don't show class graphics at below 640x480 resolution bool bShowClassGraphic = true; if ( ScreenWidth < 640 ) { bShowClassGraphic = false; } memset( m_pClassImages, 0, sizeof(m_pClassImages) ); // Get the scheme used for the Titles CSchemeManager *pSchemes = gViewPort->GetSchemeManager(); // schemes SchemeHandle_t hTitleScheme = pSchemes->getSchemeHandle( "Title Font" ); SchemeHandle_t hClassWindowText = pSchemes->getSchemeHandle( "Briefing Text" ); // color schemes int r, g, b, a; // Create the title Label *pLabel = new Label( "", CLASSMENU_TITLE_X, CLASSMENU_TITLE_Y ); pLabel->setParent( this ); pLabel->setFont( pSchemes->getFont(hTitleScheme) ); pSchemes->getFgColor( hTitleScheme, r, g, b, a ); pLabel->setFgColor( r, g, b, a ); pSchemes->getBgColor( hTitleScheme, r, g, b, a ); pLabel->setBgColor( r, g, b, a ); pLabel->setContentAlignment( vgui::Label::a_west ); pLabel->setText(gHUD.m_TextMessage.BufferedLocaliseTextString("#Title_SelectYourClass")); // Create the Scroll panel m_pScrollPanel = new CTFScrollPanel( CLASSMENU_WINDOW_X, CLASSMENU_WINDOW_Y, CLASSMENU_WINDOW_SIZE_X, CLASSMENU_WINDOW_SIZE_Y ); m_pScrollPanel->setParent(this); //force the scrollbars on, so after the validate clientClip will be smaller m_pScrollPanel->setScrollBarAutoVisible(false, false); m_pScrollPanel->setScrollBarVisible(true, true); m_pScrollPanel->setBorder( new LineBorder( Color(255 * 0.7,170 * 0.7,0,0) ) ); m_pScrollPanel->validate(); int clientWide=m_pScrollPanel->getClient()->getWide(); //turn scrollpanel back into auto show scrollbar mode and validate m_pScrollPanel->setScrollBarAutoVisible(false,true); m_pScrollPanel->setScrollBarVisible(false,false); m_pScrollPanel->validate(); // Create the Class buttons for (int i = 0; i <= PC_RANDOM; i++) { char sz[256]; int iYPos = CLASSMENU_TOPLEFT_BUTTON_Y + ( (CLASSMENU_BUTTON_SIZE_Y + CLASSMENU_BUTTON_SPACER_Y) * i ); ActionSignal *pASignal = new CMenuHandler_StringCommandClassSelect( sTFClassSelection[i], true ); // Class button sprintf(sz, "%s", CHudTextMessage::BufferedLocaliseTextString( sLocalisedClasses[i] ) ); m_pButtons[i] = new ClassButton( i, sz, CLASSMENU_TOPLEFT_BUTTON_X, iYPos, CLASSMENU_BUTTON_SIZE_X, CLASSMENU_BUTTON_SIZE_Y, true); // RandomPC uses '0' if ( i >= 1 && i <= 9 ) { sprintf(sz,"%d",i); } else { sprintf(sz,"0"); } m_pButtons[i]->setBoundKey( sz[0] ); m_pButtons[i]->setContentAlignment( vgui::Label::a_west ); m_pButtons[i]->addActionSignal( pASignal ); m_pButtons[i]->addInputSignal( new CHandler_MenuButtonOver(this, i) ); m_pButtons[i]->setParent( this ); // Create the Class Info Window //m_pClassInfoPanel[i] = new CTransparentPanel( 255, CLASSMENU_WINDOW_X, CLASSMENU_WINDOW_Y, CLASSMENU_WINDOW_SIZE_X, CLASSMENU_WINDOW_SIZE_Y ); m_pClassInfoPanel[i] = new CTransparentPanel( 255, 0, 0, clientWide, CLASSMENU_WINDOW_SIZE_Y ); m_pClassInfoPanel[i]->setParent( m_pScrollPanel->getClient() ); //m_pClassInfoPanel[i]->setVisible( false ); // don't show class pic in lower resolutions int textOffs = XRES(8); if ( bShowClassGraphic ) { textOffs = CLASSMENU_WINDOW_NAME_X; } // Create the Class Name Label sprintf(sz, "#Title_%s", sTFClassSelection[i]); char* localName=CHudTextMessage::BufferedLocaliseTextString( sz ); Label *pNameLabel = new Label( "", textOffs, CLASSMENU_WINDOW_NAME_Y ); pNameLabel->setFont( pSchemes->getFont(hTitleScheme) ); pNameLabel->setParent( m_pClassInfoPanel[i] ); pSchemes->getFgColor( hTitleScheme, r, g, b, a ); pNameLabel->setFgColor( r, g, b, a ); pSchemes->getBgColor( hTitleScheme, r, g, b, a ); pNameLabel->setBgColor( r, g, b, a ); pNameLabel->setContentAlignment( vgui::Label::a_west ); //pNameLabel->setBorder(new LineBorder()); pNameLabel->setText(localName); // Create the Class Image if ( bShowClassGraphic ) { for ( int team = 0; team < 2; team++ ) { if ( team == 1 ) { sprintf( sz, "%sred", sTFClassSelection[i] ); } else { sprintf( sz, "%sblue", sTFClassSelection[i] ); } m_pClassImages[team][i] = new CImageLabel( sz, 0, 0, CLASSMENU_WINDOW_TEXT_X, CLASSMENU_WINDOW_TEXT_Y ); CImageLabel *pLabel = m_pClassImages[team][i]; pLabel->setParent( m_pClassInfoPanel[i] ); //pLabel->setBorder(new LineBorder()); if ( team != 1 ) { pLabel->setVisible( false ); } // Reposition it based upon it's size int xOut, yOut; pNameLabel->getTextSize( xOut, yOut ); pLabel->setPos( (CLASSMENU_WINDOW_TEXT_X - pLabel->getWide()) / 2, yOut /2 ); } } // Create the Player count string gHUD.m_TextMessage.LocaliseTextString( "#Title_CurrentlyOnYourTeam", m_sPlayersOnTeamString, STRLENMAX_PLAYERSONTEAM ); m_pPlayers[i] = new Label( "", textOffs, CLASSMENU_WINDOW_PLAYERS_Y ); m_pPlayers[i]->setParent( m_pClassInfoPanel[i] ); m_pPlayers[i]->setBgColor( 0, 0, 0, 255 ); m_pPlayers[i]->setContentAlignment( vgui::Label::a_west ); m_pPlayers[i]->setFont( pSchemes->getFont(hClassWindowText) ); // Open up the Class Briefing File sprintf(sz, "classes/short_%s.txt", sTFClassSelection[i]); char *cText = "Class Description not available."; char *pfile = (char *)gEngfuncs.COM_LoadFile( sz, 5, NULL ); if (pfile) { cText = pfile; } // Create the Text info window TextPanel *pTextWindow = new TextPanel(cText, textOffs, CLASSMENU_WINDOW_TEXT_Y, (CLASSMENU_WINDOW_SIZE_X - textOffs)-5, CLASSMENU_WINDOW_SIZE_Y - CLASSMENU_WINDOW_TEXT_Y); pTextWindow->setParent( m_pClassInfoPanel[i] ); pTextWindow->setFont( pSchemes->getFont(hClassWindowText) ); pSchemes->getFgColor( hClassWindowText, r, g, b, a ); pTextWindow->setFgColor( r, g, b, a ); pSchemes->getBgColor( hClassWindowText, r, g, b, a ); pTextWindow->setBgColor( r, g, b, a ); // Resize the Info panel to fit it all int wide,tall; pTextWindow->getTextImage()->getTextSizeWrapped( wide,tall); pTextWindow->setSize(wide,tall); int xx,yy; pTextWindow->getPos(xx,yy); int maxX=xx+wide; int maxY=yy+tall; //check to see if the image goes lower than the text //just use the red teams [0] images if(m_pClassImages[0][i]!=null) { m_pClassImages[0][i]->getPos(xx,yy); if((yy+m_pClassImages[0][i]->getTall())>maxY) { maxY=yy+m_pClassImages[0][i]->getTall(); } } m_pClassInfoPanel[i]->setSize( maxX , maxY ); if (pfile) gEngfuncs.COM_FreeFile( pfile ); //m_pClassInfoPanel[i]->setBorder(new LineBorder()); } // Create the Cancel button m_pCancelButton = new CommandButton( gHUD.m_TextMessage.BufferedLocaliseTextString( "#Menu_Cancel" ), CLASSMENU_TOPLEFT_BUTTON_X, 0, CLASSMENU_BUTTON_SIZE_X, CLASSMENU_BUTTON_SIZE_Y); m_pCancelButton->setParent( this ); m_pCancelButton->addActionSignal( new CMenuHandler_TextWindow(HIDE_TEXTWINDOW) ); m_iCurrentInfo = 0; }
// Creation CTeamMenuPanel::CTeamMenuPanel(int iTrans, int iRemoveMe, int x,int y,int wide,int tall) : CMenuPanel(iTrans, iRemoveMe, x,y,wide,tall) { // Get the scheme used for the Titles CSchemeManager *pSchemes = gViewPort->GetSchemeManager(); // schemes SchemeHandle_t hTitleScheme = pSchemes->getSchemeHandle( "Title Font" ); SchemeHandle_t hTeamWindowText = pSchemes->getSchemeHandle( "Briefing Text" ); SchemeHandle_t hTeamInfoText = pSchemes->getSchemeHandle( "Team Info Text" ); // get the Font used for the Titles Font *pTitleFont = pSchemes->getFont( hTitleScheme ); int r, g, b, a; // Create the title Label *pLabel = new Label( "", TEAMMENU_TITLE_X, TEAMMENU_TITLE_Y ); pLabel->setParent( this ); pLabel->setFont( pTitleFont ); pSchemes->getFgColor( hTitleScheme, r, g, b, a ); pLabel->setFgColor( r, g, b, a ); pSchemes->getBgColor( hTitleScheme, r, g, b, a ); pLabel->setBgColor( r, g, b, a ); pLabel->setContentAlignment( vgui::Label::a_west ); pLabel->setText( "%s", gHUD.m_TextMessage.BufferedLocaliseTextString("#Title_SelectYourTeam")); // Create the Info Window m_pTeamWindow = new CTransparentPanel( 255, TEAMMENU_WINDOW_X, TEAMMENU_WINDOW_Y, TEAMMENU_WINDOW_SIZE_X, TEAMMENU_WINDOW_SIZE_Y ); m_pTeamWindow->setParent( this ); m_pTeamWindow->setBorder( new LineBorder( Color(255*0.7,170*0.7,0,0 )) ); // Create the Map Name Label m_pMapTitle = new Label( "", TEAMMENU_WINDOW_TITLE_X, TEAMMENU_WINDOW_TITLE_Y ); m_pMapTitle->setFont( pTitleFont ); m_pMapTitle->setParent( m_pTeamWindow ); pSchemes->getFgColor( hTitleScheme, r, g, b, a ); m_pMapTitle->setFgColor( r, g, b, a ); pSchemes->getBgColor( hTitleScheme, r, g, b, a ); m_pMapTitle->setBgColor( r, g, b, a ); m_pMapTitle->setContentAlignment( vgui::Label::a_west ); // Create the Scroll panel m_pScrollPanel = new CTFScrollPanel( TEAMMENU_WINDOW_TEXT_X, TEAMMENU_WINDOW_TEXT_Y, TEAMMENU_WINDOW_SIZE_X - (TEAMMENU_WINDOW_TEXT_X * 2), TEAMMENU_WINDOW_TEXT_SIZE_Y ); m_pScrollPanel->setParent(m_pTeamWindow); m_pScrollPanel->setScrollBarVisible(false, false); // Create the Map Briefing panel m_pBriefing = new TextPanel("", 0,0, TEAMMENU_WINDOW_SIZE_X - TEAMMENU_WINDOW_TEXT_X, TEAMMENU_WINDOW_TEXT_SIZE_Y ); m_pBriefing->setParent( m_pScrollPanel->getClient() ); m_pBriefing->setFont( pSchemes->getFont(hTeamWindowText) ); pSchemes->getFgColor( hTeamWindowText, r, g, b, a ); m_pBriefing->setFgColor( r, g, b, a ); pSchemes->getBgColor( hTeamWindowText, r, g, b, a ); m_pBriefing->setBgColor( r, g, b, a ); m_pBriefing->setText( gHUD.m_TextMessage.BufferedLocaliseTextString("#Map_Description_not_available") ); // Team Menu buttons for (int i = 1; i <= 5; i++) { char sz[256]; int iYPos = TEAMMENU_TOPLEFT_BUTTON_Y + ( (TEAMMENU_BUTTON_SIZE_Y + TEAMMENU_BUTTON_SPACER_Y) * i ); // Team button m_pButtons[i] = new CommandButton( "", TEAMMENU_TOPLEFT_BUTTON_X, iYPos, TEAMMENU_BUTTON_SIZE_X, TEAMMENU_BUTTON_SIZE_Y, true); m_pButtons[i]->setParent( this ); m_pButtons[i]->setContentAlignment( vgui::Label::a_west ); m_pButtons[i]->setVisible( false ); // AutoAssign button uses special case if (i == 5) { m_pButtons[5]->setBoundKey( '5' ); m_pButtons[5]->setText( gHUD.m_TextMessage.BufferedLocaliseTextString("#Team_AutoAssign") ); m_pButtons[5]->setVisible( true ); } // Create the Signals sprintf(sz, "jointeam %d", i); m_pButtons[i]->addActionSignal( new CMenuHandler_StringCommandWatch( sz, true ) ); m_pButtons[i]->addInputSignal( new CHandler_MenuButtonOver(this, i) ); // Create the Team Info panel m_pTeamInfoPanel[i] = new TextPanel("", TEAMMENU_WINDOW_INFO_X, TEAMMENU_WINDOW_INFO_Y, TEAMMENU_WINDOW_SIZE_X - TEAMMENU_WINDOW_INFO_X, TEAMMENU_WINDOW_SIZE_X - TEAMMENU_WINDOW_INFO_Y ); m_pTeamInfoPanel[i]->setParent( m_pTeamWindow ); m_pTeamInfoPanel[i]->setFont( pSchemes->getFont(hTeamInfoText) ); m_pTeamInfoPanel[i]->setFgColor( iTeamColors[i % iNumberOfTeamColors][0], iTeamColors[i % iNumberOfTeamColors][1], iTeamColors[i % iNumberOfTeamColors][2], 0 ); m_pTeamInfoPanel[i]->setBgColor( 0,0,0, 255 ); } // Create the Cancel button m_pCancelButton = new CommandButton( CHudTextMessage::BufferedLocaliseTextString( "#Menu_Cancel" ), TEAMMENU_TOPLEFT_BUTTON_X, 0, TEAMMENU_BUTTON_SIZE_X, TEAMMENU_BUTTON_SIZE_Y); m_pCancelButton->setParent( this ); m_pCancelButton->addActionSignal( new CMenuHandler_TextWindow(HIDE_TEXTWINDOW) ); // Create the Spectate button m_pSpectateButton = new SpectateButton( CHudTextMessage::BufferedLocaliseTextString( "#Menu_Spectate" ), TEAMMENU_TOPLEFT_BUTTON_X, 0, TEAMMENU_BUTTON_SIZE_X, TEAMMENU_BUTTON_SIZE_Y, true); m_pSpectateButton->setParent( this ); m_pSpectateButton->addActionSignal( new CMenuHandler_StringCommand( "spectate", true ) ); m_pSpectateButton->setBoundKey( '6' ); m_pSpectateButton->addInputSignal( new CHandler_MenuButtonOver(this, 6) ); Initialize(); }
void ScorePanel::FillGrid() { CSchemeManager *pSchemes = gViewPort->GetSchemeManager(); SchemeHandle_t hScheme = pSchemes->getSchemeHandle("Scoreboard Text"); SchemeHandle_t hTitleScheme = pSchemes->getSchemeHandle("Scoreboard Title Text"); SchemeHandle_t hSmallScheme = pSchemes->getSchemeHandle("Scoreboard Small Text"); SchemeHandle_t hTinyScheme = pSchemes->getSchemeHandle("Scoreboard Tiny Text"); Font *sfont = pSchemes->getFont(hScheme); Font *tfont = pSchemes->getFont(hTitleScheme); Font *smallfont = pSchemes->getFont(hSmallScheme); Font *tinyfont = pSchemes->getFont(hTinyScheme); // update highlight position int x, y; getApp()->getCursorPos(x, y); cursorMoved(x, y, this); // remove highlight row if we're not in squelch mode if (!GetClientVoiceMgr()->IsInSquelchMode()) { m_iHighlightRow = -1; } bool bNextRowIsGap = false; for(int row=0; row < NUM_ROWS; row++) { CGrid *pGridRow = &m_PlayerGrids[row]; pGridRow->SetRowUnderline(0, false, 0, 0, 0, 0, 0); if(row >= m_iRows) { for(int col=0; col < NUM_COLUMNS; col++) m_PlayerEntries[col][row].setVisible(false); continue; } bool bRowIsGap = false; if (bNextRowIsGap) { bNextRowIsGap = false; bRowIsGap = true; } // Get the player's data int theSortedRow = m_iSortedRows[row]; hud_player_info_t* pl_info = &g_PlayerInfoList[theSortedRow]; extra_player_info_t* theExtraPlayerInfo = &g_PlayerExtraInfo[theSortedRow]; int thePlayerClass = theExtraPlayerInfo->playerclass; short theTeamNumber = theExtraPlayerInfo->teamnumber; string theCustomIcon = (string)theExtraPlayerInfo->customicon; // puzl: 0001073 short thePlayerAuthentication = theExtraPlayerInfo->auth; bool thePlayerIsDead = false; switch( thePlayerClass ) { case PLAYERCLASS_DEAD_MARINE: case PLAYERCLASS_DEAD_ALIEN: case PLAYERCLASS_REINFORCING: thePlayerIsDead = true; break; } // Code to test DEBUG #if 0 #ifdef DEBUG extern int gGlobalDebugAuth; thePlayerAuthentication = 1; thePlayerAuthentication <<= gGlobalDebugAuth; #endif #endif team_info_t* team_info = &g_TeamInfo[m_iSortedRows[row]]; int theColorIndex = theTeamNumber % iNumberOfTeamColors; int theLocalPlayerTeam = 0; if(gEngfuncs.GetLocalPlayer()) { theLocalPlayerTeam = gEngfuncs.GetLocalPlayer()->curstate.team; } for(int col=0; col < NUM_COLUMNS; col++) { CLabelHeader *pLabel = &m_PlayerEntries[col][row]; pLabel->setVisible(true); pLabel->setText2(""); pLabel->setImage(NULL); pLabel->setFont(sfont); pLabel->setTextOffset(0, 0); int rowheight = 13; if (ScreenHeight() > 480) { rowheight = YRES(rowheight); } else { // more tweaking, make sure icons fit at low res rowheight = 15; } pLabel->setSize(pLabel->getWide(), rowheight); pLabel->setBgColor(0, 0, 0, 255); char sz[128]; Color gammaAdjustedTeamColor = BuildColor(kTeamColors[theColorIndex][0], kTeamColors[theColorIndex][1], kTeamColors[theColorIndex][2], gHUD.GetGammaSlope()); pLabel->setFgColor(gammaAdjustedTeamColor[0], gammaAdjustedTeamColor[1], gammaAdjustedTeamColor[2], 0); if (m_iIsATeam[row] == TEAM_BLANK) { pLabel->setText(" "); continue; } else if ( m_iIsATeam[row] == TEAM_YES ) { theColorIndex = team_info->teamnumber % iNumberOfTeamColors; // team color text for team names // different height for team header rows rowheight = 20; if (ScreenHeight() >= 480) { rowheight = YRES(rowheight); } pLabel->setSize(pLabel->getWide(), rowheight); pLabel->setFont(tfont); pGridRow->SetRowUnderline( 0, true, YRES(3), gammaAdjustedTeamColor[0], gammaAdjustedTeamColor[1], gammaAdjustedTeamColor[2], 0 ); } else if ( m_iIsATeam[row] == TEAM_SPECTATORS ) { // grey text for spectators pLabel->setFgColor(100, 100, 100, 0); // different height for team header rows rowheight = 20; if (ScreenHeight() >= 480) { rowheight = YRES(rowheight); } pLabel->setSize(pLabel->getWide(), rowheight); pLabel->setFont(tfont); pGridRow->SetRowUnderline(0, true, YRES(3), 100, 100, 100, 0); } else { if(thePlayerIsDead) { pLabel->setFgColor(255, 0, 0, 0); } else { // team color text for player names pLabel->setFgColor(gammaAdjustedTeamColor[0], gammaAdjustedTeamColor[1], gammaAdjustedTeamColor[2], 0); } // Set background color if ( pl_info && pl_info->thisplayer ) // if it is their name, draw it a different color { // Highlight this player pLabel->setFgColor(Scheme::sc_white); pLabel->setBgColor(gammaAdjustedTeamColor[0], gammaAdjustedTeamColor[1], gammaAdjustedTeamColor[2], 196 ); } else if ( theSortedRow == m_iLastKilledBy && m_fLastKillTime && m_fLastKillTime > gHUD.m_flTime ) { // Killer's name pLabel->setBgColor( 255,0,0, 255 - ((float)15 * (float)(m_fLastKillTime - gHUD.m_flTime)) ); } } // Align switch(col) { case COLUMN_NAME: case COLUMN_CLASS: pLabel->setContentAlignment( vgui::Label::a_west ); break; case COLUMN_TRACKER: case COLUMN_RANK_ICON: case COLUMN_VOICE: pLabel->setContentAlignment( vgui::Label::a_center ); break; case COLUMN_SCORE: case COLUMN_KILLS: case COLUMN_DEATHS: case COLUMN_LATENCY: default: pLabel->setContentAlignment( vgui::Label::a_east ); break; } // Fill out with the correct data strcpy(sz, ""); if ( m_iIsATeam[row] ) { char sz2[128]; switch (col) { case COLUMN_NAME: if ( m_iIsATeam[row] == TEAM_SPECTATORS ) { sprintf( sz2, CHudTextMessage::BufferedLocaliseTextString( "#Spectators" ) ); } else { if(team_info) { sprintf( sz2, gViewPort->GetTeamName(team_info->teamnumber) ); } } strcpy(sz, sz2); // Append the number of players if ( m_iIsATeam[row] == TEAM_YES && team_info) { if (team_info->players == 1) { sprintf(sz2, "(%d %s)", team_info->players, CHudTextMessage::BufferedLocaliseTextString( "#Player" ) ); } else { sprintf(sz2, "(%d %s)", team_info->players, CHudTextMessage::BufferedLocaliseTextString( "#Player_plural" ) ); } pLabel->setText2(sz2); pLabel->setFont2(smallfont); } break; case COLUMN_VOICE: break; case COLUMN_CLASS: break; case COLUMN_SCORE: // Don't show score for enemies unless spectating or in RR if ((m_iIsATeam[row] == TEAM_YES) && team_info && ((theLocalPlayerTeam == 0) || (theLocalPlayerTeam == team_info->teamnumber))) sprintf(sz, "%d", team_info->score); break; case COLUMN_KILLS: if ((m_iIsATeam[row] == TEAM_YES) && team_info) sprintf(sz, "%d", team_info->frags ); break; case COLUMN_DEATHS: if ((m_iIsATeam[row] == TEAM_YES) && team_info) sprintf(sz, "%d", team_info->deaths ); break; case COLUMN_LATENCY: if ((m_iIsATeam[row] == TEAM_YES) && team_info) sprintf(sz, "%d", team_info->ping ); break; default: break; } } else { // Are these stats for an enemy? Score and other stats shouldn't be drawn for enemies. bool theIsForEnemy = false; int theLocalPlayerTeam = 0; if(gEngfuncs.GetLocalPlayer()) { theLocalPlayerTeam = gEngfuncs.GetLocalPlayer()->curstate.team; } if((theLocalPlayerTeam != 0) && (theExtraPlayerInfo->teamnumber != theLocalPlayerTeam)) { theIsForEnemy = true; } switch (col) { case COLUMN_NAME: if (g_pTrackerUser) { int playerSlot = m_iSortedRows[row]; int trackerID = gEngfuncs.GetTrackerIDForPlayer(playerSlot); const char *trackerName = g_pTrackerUser->GetUserName(trackerID); if (trackerName && *trackerName) { sprintf(sz, " (%s)", trackerName); pLabel->setText2(sz); } } if(pl_info) { sprintf(sz, "%s ", pl_info->name); } break; case COLUMN_VOICE: sz[0] = 0; // in HLTV mode allow spectator to turn on/off commentator voice if (pl_info && (!pl_info->thisplayer || gEngfuncs.IsSpectateOnly())) { GetClientVoiceMgr()->UpdateSpeakerImage(pLabel, theSortedRow); } break; case COLUMN_CLASS: // No class for other team's members (unless allied or spectator, and make sure player is on our team) strcpy(sz, ""); if(team_info && ((theLocalPlayerTeam == theTeamNumber) || (gHUD.GetPlayMode() == PLAYMODE_OBSERVER))) { switch(thePlayerClass) { case (int)(PLAYERCLASS_DEAD_MARINE): case (int)(PLAYERCLASS_DEAD_ALIEN): sprintf(sz, "%s", CHudTextMessage::BufferedLocaliseTextString(kClassDead)); break; case (int)(PLAYERCLASS_REINFORCING): sprintf(sz, "%s", CHudTextMessage::BufferedLocaliseTextString(kClassReinforcing)); break; case (int)(PLAYERCLASS_REINFORCINGCOMPLETE): sprintf(sz, "%s", CHudTextMessage::BufferedLocaliseTextString(kClassReinforcingComplete)); break; case (int)(PLAYERCLASS_ALIVE_JETPACK_MARINE): sprintf(sz, "%s", CHudTextMessage::BufferedLocaliseTextString(kClassJetpackMarine)); break; case (int)(PLAYERCLASS_ALIVE_HEAVY_MARINE): sprintf(sz, "%s", CHudTextMessage::BufferedLocaliseTextString(kClassHeavyMarine)); break; case (int)(PLAYERCLASS_COMMANDER): sprintf(sz, "%s", CHudTextMessage::BufferedLocaliseTextString(kClassCommander)); break; case (int)(PLAYERCLASS_ALIVE_LEVEL1): sprintf(sz, "%s", CHudTextMessage::BufferedLocaliseTextString(kClassLevel1)); break; case (int)(PLAYERCLASS_ALIVE_LEVEL2): sprintf(sz, "%s", CHudTextMessage::BufferedLocaliseTextString(kClassLevel2)); break; case (int)(PLAYERCLASS_ALIVE_LEVEL3): sprintf(sz, "%s", CHudTextMessage::BufferedLocaliseTextString(kClassLevel3)); break; case (int)(PLAYERCLASS_ALIVE_LEVEL4): sprintf(sz, "%s", CHudTextMessage::BufferedLocaliseTextString(kClassLevel4)); break; case (int)(PLAYERCLASS_ALIVE_LEVEL5): sprintf(sz, "%s", CHudTextMessage::BufferedLocaliseTextString(kClassLevel5)); break; case (int)(PLAYERCLASS_ALIVE_DIGESTING): sprintf(sz, "%s", CHudTextMessage::BufferedLocaliseTextString(kClassDigesting)); break; case (int)(PLAYERCLASS_ALIVE_GESTATING): sprintf(sz, "%s", CHudTextMessage::BufferedLocaliseTextString(kClassGestating)); break; default: break; } } break; case COLUMN_RANK_ICON: // puzl: 0001073 #ifdef USE_OLDAUTH // Check if we have authority. Right now these override the tracker icons. Listed in increasing order of "importance". if(thePlayerAuthentication & PLAYERAUTH_CHEATINGDEATH) { // Red pLabel->setImage(m_pCheatingDeathIcon); pLabel->setFgColorAsImageColor(false); m_pCheatingDeathIcon->setColor(BuildColor(255, 69, 9, gHUD.GetGammaSlope())); } if(thePlayerAuthentication & PLAYERAUTH_VETERAN) { // Yellow pLabel->setImage(m_pVeteranIcon); pLabel->setFgColorAsImageColor(false); m_pVeteranIcon->setColor(BuildColor(248, 252, 0, gHUD.GetGammaSlope())); } if(thePlayerAuthentication & PLAYERAUTH_BETASERVEROP) { // Whitish pLabel->setImage(m_pServerOpIcon); pLabel->setFgColorAsImageColor(false); m_pServerOpIcon->setColor(BuildColor(220, 220, 220, gHUD.GetGammaSlope())); } if(thePlayerAuthentication & PLAYERAUTH_CONTRIBUTOR) { // Light blue pLabel->setImage(m_pContribIcon); pLabel->setFgColorAsImageColor(false); m_pContribIcon->setColor(BuildColor(117, 214, 241, gHUD.GetGammaSlope())); } if(thePlayerAuthentication & PLAYERAUTH_GUIDE) { // Magenta pLabel->setImage(m_pGuideIcon); pLabel->setFgColorAsImageColor(false); m_pGuideIcon->setColor(BuildColor(208, 16, 190, gHUD.GetGammaSlope())); } if(thePlayerAuthentication & PLAYERAUTH_PLAYTESTER) { // Orange pLabel->setImage(m_pPTIcon); pLabel->setFgColorAsImageColor(false); m_pPTIcon->setColor(BuildColor(255, 167, 54, gHUD.GetGammaSlope())); } if(thePlayerAuthentication & PLAYERAUTH_DEVELOPER) { // TSA blue pLabel->setImage(m_pDevIcon); pLabel->setFgColorAsImageColor(false); m_pDevIcon->setColor(BuildColor(100, 215, 255, gHUD.GetGammaSlope())); } if(thePlayerAuthentication & PLAYERAUTH_SERVEROP) { // Bright green pLabel->setImage(m_pServerOpIcon); pLabel->setFgColorAsImageColor(false); m_pServerOpIcon->setColor(BuildColor(0, 255, 0, gHUD.GetGammaSlope())); } // Allow custom icons to override other general icons if(thePlayerAuthentication & PLAYERAUTH_CUSTOM) { if(theCustomIcon != "") { string theIconName = theCustomIcon.substr(0, strlen(theCustomIcon.c_str()) - 3); string theFullCustomIconString = string("gfx/vgui/640_") + theIconName + string(".tga"); vgui::BitmapTGA *pIcon = GetIconPointer(theCustomIcon); //Icon hasnt been loaded, load it now and add it to list of icons. if(pIcon == NULL) { pIcon = vgui_LoadTGANoInvertAlpha(theFullCustomIconString.c_str()); if(pIcon) m_CustomIconList.push_back( make_pair(pIcon, theCustomIcon) ); } if(pIcon) { pLabel->setImage(pIcon); pLabel->setFgColorAsImageColor(false); // Parse color (last 3 bytes are the RGB values 1-9) string theColor = theCustomIcon.substr( strlen(theCustomIcon.c_str())-3, 3); int theRed = (MakeIntFromString(theColor.substr(0, 1))/9.0f)*255; int theGreen = (MakeIntFromString(theColor.substr(1, 1))/9.0f)*255; int theBlue = (MakeIntFromString(theColor.substr(2, 1))/9.0f)*255; pIcon->setColor(BuildColor(theRed, theGreen, theBlue, gHUD.GetGammaSlope())); } } } if(g_pTrackerUser) { int playerSlot = theSortedRow; int trackerID = gEngfuncs.GetTrackerIDForPlayer(playerSlot); if (g_pTrackerUser->IsFriend(trackerID) && trackerID != g_pTrackerUser->GetTrackerID()) { pLabel->setImage(m_pTrackerIcon); pLabel->setFgColorAsImageColor(false); m_pTrackerIcon->setColor(Color(255, 255, 255, 0)); } } #else if( theExtraPlayerInfo->icon ) { vgui::Bitmap* image = theExtraPlayerInfo->icon->getImage( this->GetIconFrame() ); if( image ) { pLabel->setImage( image ); } } #endif break; case COLUMN_SCORE: if(!theIsForEnemy) { const float kDeltaDisplayTime = 3.0f; float theTimeSinceChange = gHUD.GetTimeOfLastUpdate() - theExtraPlayerInfo->timeOfLastScoreChange; if((theExtraPlayerInfo->score > theExtraPlayerInfo->lastScore) && (theTimeSinceChange > 0) && (theTimeSinceChange < kDeltaDisplayTime) && (theExtraPlayerInfo->teamnumber != 0)) { // draw score with change int theDelta = (theExtraPlayerInfo->score - theExtraPlayerInfo->lastScore); sprintf(sz, "(+%d) %d", theDelta, theExtraPlayerInfo->score); } else { sprintf(sz, "%d", theExtraPlayerInfo->score); } } break; case COLUMN_KILLS: sprintf(sz, "%d", theExtraPlayerInfo->frags); break; case COLUMN_DEATHS: sprintf(sz, "%d", theExtraPlayerInfo->deaths); break; case COLUMN_LATENCY: if(pl_info) { sprintf(sz, "%d", pl_info->ping ); } break; default: break; } } pLabel->setText(sz); } } for(row=0; row < NUM_ROWS; row++) { CGrid *pGridRow = &m_PlayerGrids[row]; pGridRow->AutoSetRowHeights(); pGridRow->setSize(PanelWidth(pGridRow), pGridRow->CalcDrawHeight()); pGridRow->RepositionContents(); } // hack, for the thing to resize m_PlayerList.getSize(x, y); m_PlayerList.setSize(x, y); }
//----------------------------------------------------------------------------- // Purpose: Create the ScoreBoard panel //----------------------------------------------------------------------------- ScorePanel::ScorePanel(int x,int y,int wide,int tall) : Panel(x,y,wide,tall) { CSchemeManager *pSchemes = gViewPort->GetSchemeManager(); SchemeHandle_t hTitleScheme = pSchemes->getSchemeHandle("Scoreboard Title Text"); SchemeHandle_t hSmallScheme = pSchemes->getSchemeHandle("Scoreboard Small Text"); SchemeHandle_t hTinyScheme = pSchemes->getSchemeHandle("Scoreboard Tiny Text"); Font *tfont = pSchemes->getFont(hTitleScheme); Font *smallfont = pSchemes->getFont(hSmallScheme); Font *tinyfont = pSchemes->getFont(hTinyScheme); setBgColor(0, 0, 0, 96); m_pCurrentHighlightLabel = NULL; m_iHighlightRow = -1; // puzl: 0001073 m_pTrackerIcon = NULL; m_pDevIcon = NULL; m_pPTIcon = NULL; m_pGuideIcon = NULL; m_pServerOpIcon = NULL; m_pContribIcon = NULL; m_pCheatingDeathIcon = NULL; m_pVeteranIcon = NULL; m_pTrackerIcon = vgui_LoadTGANoInvertAlpha("gfx/vgui/640_scoreboardtracker.tga"); m_pDevIcon = vgui_LoadTGANoInvertAlpha("gfx/vgui/640_scoreboarddev.tga"); m_pPTIcon = vgui_LoadTGANoInvertAlpha("gfx/vgui/640_scoreboardpt.tga"); m_pGuideIcon = vgui_LoadTGANoInvertAlpha("gfx/vgui/640_scoreboardguide.tga"); m_pServerOpIcon = vgui_LoadTGANoInvertAlpha("gfx/vgui/640_scoreboardserverop.tga"); m_pContribIcon = vgui_LoadTGANoInvertAlpha("gfx/vgui/640_scoreboardcontrib.tga"); m_pCheatingDeathIcon = vgui_LoadTGANoInvertAlpha("gfx/vgui/640_scoreboardcd.tga"); m_pVeteranIcon = vgui_LoadTGANoInvertAlpha("gfx/vgui/640_scoreboardveteran.tga"); m_iIconFrame = 0; m_iLastFrameIncrementTime = gHUD.GetTimeOfLastUpdate(); // Initialize the top title. m_TitleLabel.setFont(tfont); m_TitleLabel.setText(""); m_TitleLabel.setBgColor( 0, 0, 0, 255 ); m_TitleLabel.setFgColor( Scheme::sc_primary1 ); m_TitleLabel.setContentAlignment( vgui::Label::a_west ); LineBorder *border = new LineBorder(Color(60, 60, 60, 128)); setBorder(border); setPaintBorderEnabled(true); int xpos = g_ColumnInfo[0].m_Width + 3; if (ScreenWidth() >= 640) { // only expand column size for res greater than 640 xpos = XRES(xpos); } m_TitleLabel.setBounds(xpos, 4, wide, SBOARD_TITLE_SIZE_Y); m_TitleLabel.setContentFitted(false); m_TitleLabel.setParent(this); // Setup the header (labels like "name", "class", etc..). m_HeaderGrid.SetDimensions(NUM_COLUMNS, 1); m_HeaderGrid.SetSpacing(0, 0); for(int i=0; i < NUM_COLUMNS; i++) { if (g_ColumnInfo[i].m_pTitle && g_ColumnInfo[i].m_pTitle[0] == '#') m_HeaderLabels[i].setText(CHudTextMessage::BufferedLocaliseTextString(g_ColumnInfo[i].m_pTitle)); else if(g_ColumnInfo[i].m_pTitle) m_HeaderLabels[i].setText(g_ColumnInfo[i].m_pTitle); int xwide = g_ColumnInfo[i].m_Width; if (ScreenWidth() >= 640) { xwide = XRES(xwide); } else if (ScreenWidth() == 400) { // hack to make 400x300 resolution scoreboard fit if (i == 1) { // reduces size of player name cell xwide -= 28; } else if (i == 0) { // tracker icon cell xwide -= 8; } } m_HeaderGrid.SetColumnWidth(i, xwide); m_HeaderGrid.SetEntry(i, 0, &m_HeaderLabels[i]); m_HeaderLabels[i].setBgColor(0,0,0,255); m_HeaderLabels[i].setBgColor(0,0,0,255); int theColorIndex = 0; Color gammaAdjustedTeamColor = BuildColor(kTeamColors[theColorIndex][0], kTeamColors[theColorIndex][1], kTeamColors[theColorIndex][2], gHUD.GetGammaSlope()); int theR, theG, theB, theA; gammaAdjustedTeamColor.getColor(theR, theG, theB, theA); m_HeaderLabels[i].setFgColor(theR, theG, theB, theA); m_HeaderLabels[i].setFont(smallfont); m_HeaderLabels[i].setContentAlignment(g_ColumnInfo[i].m_Alignment); int yres = 12; if (ScreenHeight() >= 480) { yres = YRES(yres); } m_HeaderLabels[i].setSize(50, yres); } // Set the width of the last column to be the remaining space. int ex, ey, ew, eh; m_HeaderGrid.GetEntryBox(NUM_COLUMNS - 2, 0, ex, ey, ew, eh); m_HeaderGrid.SetColumnWidth(NUM_COLUMNS - 1, (wide - X_BORDER) - (ex + ew)); 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.setBgColor(0,0,0,255); // Now setup the listbox with the actual player data in it. int headerX, headerY, headerWidth, headerHeight; 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); for(int row=0; row < NUM_ROWS; row++) { CGrid *pGridRow = &m_PlayerGrids[row]; pGridRow->SetDimensions(NUM_COLUMNS, 1); for(int col=0; col < NUM_COLUMNS; col++) { m_PlayerEntries[col][row].setContentFitted(false); m_PlayerEntries[col][row].setRow(row); m_PlayerEntries[col][row].addInputSignal(this); pGridRow->SetEntry(col, 0, &m_PlayerEntries[col][row]); } pGridRow->setBgColor(0,0,0,255); // pGridRow->SetSpacing(2, 0);f pGridRow->SetSpacing(0, 0); pGridRow->CopyColumnWidths(&m_HeaderGrid); pGridRow->AutoSetRowHeights(); pGridRow->setSize(PanelWidth(pGridRow), pGridRow->CalcDrawHeight()); pGridRow->RepositionContents(); m_PlayerList.AddItem(pGridRow); } // 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.addInputSignal(this); m_pCloseButton = new CommandButton( "x", wide-XRES(12 + 4), YRES(2), XRES( 12 ) , YRES( 12 ) ); m_pCloseButton->setParent( this ); m_pCloseButton->addActionSignal( new CMenuHandler_StringCommandWatch( "-showscores", true ) ); m_pCloseButton->setBgColor(0,0,0,255); m_pCloseButton->setFgColor( 255, 255, 255, 0 ); m_pCloseButton->setFont(tfont); m_pCloseButton->setBoundKey( (char)255 ); m_pCloseButton->setContentAlignment(Label::a_center); Initialize(); }
void SpectatorPanel::Initialize() { int x, y, wide, tall; getBounds(x, y, wide, tall); CSchemeManager *pSchemes = gViewPort->GetSchemeManager(); SchemeHandle_t hSmallScheme = pSchemes->getSchemeHandle("Team Info Text"); m_TopBorder = new CTransparentPanel(64, 0, 0, ScreenWidth, PANEL_HEIGHT); m_TopBorder->setParent(this); m_BottomBorder = new CTransparentPanel(64, 0, ScreenHeight - PANEL_HEIGHT, ScreenWidth, PANEL_HEIGHT); m_BottomBorder->setParent(this); setPaintBackgroundEnabled(false); m_ExtraInfo = new Label("Extra Info", 0, 0, wide, PANEL_HEIGHT); m_ExtraInfo->setParent(m_TopBorder); m_ExtraInfo->setFont(pSchemes->getFont(hSmallScheme)); m_ExtraInfo->setPaintBackgroundEnabled(false); m_ExtraInfo->setFgColor(143, 143, 54, 0); m_ExtraInfo->setContentAlignment(vgui::Label::a_west); m_TimerImage = new CImageLabel("timer", 0, 0, 14, 14); m_TimerImage->setParent(m_TopBorder); m_TopBanner = new CImageLabel("banner", 0, 0, XRES(BANNER_WIDTH), YRES(BANNER_HEIGHT)); m_TopBanner->setParent(this); m_CurrentTime = new Label("00:00", 0, 0, wide, PANEL_HEIGHT); m_CurrentTime->setParent(m_TopBorder); m_CurrentTime->setFont(pSchemes->getFont(hSmallScheme)); m_CurrentTime->setPaintBackgroundEnabled(false); m_CurrentTime->setFgColor(143, 143, 54, 0); m_CurrentTime->setContentAlignment(vgui::Label::a_west); m_Separator = new Panel(0, 0, XRES(64), YRES(96)); m_Separator->setParent(m_TopBorder); m_Separator->setFgColor(59, 58, 34, 48); m_Separator->setBgColor(59, 58, 34, 48); for(int j = 0; j < TEAM_NUMBER; j++) { m_TeamScores[j] = new Label(" ", 0, 0, wide, PANEL_HEIGHT); m_TeamScores[j]->setParent(m_TopBorder); m_TeamScores[j]->setFont(pSchemes->getFont(hSmallScheme)); m_TeamScores[j]->setPaintBackgroundEnabled(false); m_TeamScores[j]->setFgColor(143, 143, 54, 0); m_TeamScores[j]->setContentAlignment(vgui::Label::a_west); m_TeamScores[j]->setVisible(false); } // Initialize command buttons. // m_OptionButton = new ColorButton( CHudTextMessage::BufferedLocaliseTextString( "#SPECT_OPTIONS" ), XRES(15), YRES(6), XRES(OPTIONS_BUTTON_X), YRES(20), false, false ); m_OptionButton = new DropDownButton(CHudTextMessage::BufferedLocaliseTextString("#SPECT_OPTIONS"), XRES(15), YRES(6), XRES(OPTIONS_BUTTON_X), YRES(20), false, false); m_OptionButton->setParent(m_BottomBorder); m_OptionButton->setContentAlignment(vgui::Label::a_center); m_OptionButton->setBoundKey((char)255); // special no bound to avoid leading spaces in name m_OptionButton->addActionSignal(new CSpectatorHandler_Command(this, SPECTATOR_PANEL_CMD_OPTIONS)); m_OptionButton->setUnArmedBorderColor(59, 58, 34, 48); m_OptionButton->setArmedBorderColor(194, 202, 54, 0); m_OptionButton->setUnArmedColor(143, 143, 54, 0); m_OptionButton->setArmedColor(194, 202, 54, 0); m_CamButton = new DropDownButton(CHudTextMessage::BufferedLocaliseTextString("#CAM_OPTIONS"), ScreenWidth - (XRES(CAMOPTIONS_BUTTON_X) + 15), YRES(6), XRES(CAMOPTIONS_BUTTON_X), YRES(20), false, false); m_CamButton->setParent(m_BottomBorder); m_CamButton->setContentAlignment(vgui::Label::a_center); m_CamButton->setBoundKey((char)255); // special no bound to avoid leading spaces in name m_CamButton->addActionSignal(new CSpectatorHandler_Command(this, SPECTATOR_PANEL_CMD_CAMERA)); m_CamButton->setUnArmedBorderColor(59, 58, 34, 48); m_CamButton->setArmedBorderColor(194, 202, 54, 0); m_CamButton->setUnArmedColor(143, 143, 54, 0); m_CamButton->setArmedColor(194, 202, 54, 0); // m_PrevPlayerButton= new ColorButton("<", XRES( 15 + OPTIONS_BUTTON_X + 15 ), YRES(6), XRES(24), YRES(20), false, false ); m_PrevPlayerButton = new CImageButton("arrowleft", XRES(15 + OPTIONS_BUTTON_X + 15), YRES(6), XRES(24), YRES(20), false, false); m_PrevPlayerButton->setParent(m_BottomBorder); m_PrevPlayerButton->setContentAlignment(vgui::Label::a_center); m_PrevPlayerButton->setBoundKey((char)255); // special no bound to avoid leading spaces in name m_PrevPlayerButton->addActionSignal(new CSpectatorHandler_Command(this, SPECTATOR_PANEL_CMD_PREVPLAYER)); m_PrevPlayerButton->setUnArmedBorderColor(59, 58, 34, 48); m_PrevPlayerButton->setArmedBorderColor(194, 202, 54, 0); m_PrevPlayerButton->setUnArmedColor(143, 143, 54, 0); m_PrevPlayerButton->setArmedColor(194, 202, 54, 0); // m_NextPlayerButton= new ColorButton(">", (ScreenWidth - (XRES ( CAMOPTIONS_BUTTON_X ) + 15)) - XRES ( 24 + 15 ), YRES(6), XRES(24), YRES(20),false, false ); m_NextPlayerButton = new CImageButton("arrowright", (ScreenWidth - (XRES(CAMOPTIONS_BUTTON_X) + 15)) - XRES(24 + 15), YRES(6), XRES(24), YRES(20), false, false); m_NextPlayerButton->setParent(m_BottomBorder); m_NextPlayerButton->setContentAlignment(vgui::Label::a_center); m_NextPlayerButton->setBoundKey((char)255); // special no bound to avoid leading spaces in name m_NextPlayerButton->addActionSignal(new CSpectatorHandler_Command(this, SPECTATOR_PANEL_CMD_NEXTPLAYER)); m_NextPlayerButton->setUnArmedBorderColor(59, 58, 34, 48); m_NextPlayerButton->setArmedBorderColor(194, 202, 54, 0); m_NextPlayerButton->setUnArmedColor(143, 143, 54, 0); m_NextPlayerButton->setArmedColor(194, 202, 54, 0); // Initialize the bottom title. float flLabelSize = ((ScreenWidth - (XRES(CAMOPTIONS_BUTTON_X) + 15)) - XRES(24 + 15)) - XRES((15 + OPTIONS_BUTTON_X + 15) + 38); m_BottomMainButton = new DropDownButton("Spectator Bottom", XRES((15 + OPTIONS_BUTTON_X + 15) + 31), YRES(6), flLabelSize, YRES(20), false, false); m_BottomMainButton->setParent(m_BottomBorder); m_BottomMainButton->setPaintBackgroundEnabled(false); m_BottomMainButton->setFgColor(Scheme::sc_primary1); m_BottomMainButton->setContentAlignment(vgui::Label::a_center); m_BottomMainButton->setBorder(new LineBorder(Color(59, 58, 34, 48))); m_BottomMainButton->setBoundKey((char)255); // special no bound to avoid leading spaces in name m_BottomMainButton->addActionSignal(new CSpectatorHandler_Command(this, SPECTATOR_PANEL_CMD_PLAYERS)); m_BottomMainButton->setUnArmedBorderColor(59, 58, 34, 48); m_BottomMainButton->setArmedBorderColor(194, 202, 54, 0); m_BottomMainButton->setUnArmedColor(143, 143, 54, 0); m_BottomMainButton->setArmedColor(194, 202, 54, 0); m_BottomMainLabel = new Label("Spectator Bottom", XRES((15 + OPTIONS_BUTTON_X + 15) + 31), YRES(6), flLabelSize, YRES(20)); m_BottomMainLabel->setParent(m_BottomBorder); m_BottomMainLabel->setPaintBackgroundEnabled(false); m_BottomMainLabel->setFgColor(Scheme::sc_primary1); m_BottomMainLabel->setContentAlignment(vgui::Label::a_center); m_BottomMainLabel->setBorder(NULL); m_BottomMainLabel->setVisible(false); m_InsetViewButton = new ColorButton("", XRES(2), YRES(2), XRES(240), YRES(180), false, false); m_InsetViewButton->setParent(this); m_InsetViewButton->setBoundKey((char)255); m_InsetViewButton->addActionSignal(new CSpectatorHandler_Command(this, SPECTATOR_PANEL_CMD_TOGGLE_INSET)); m_InsetViewButton->setUnArmedBorderColor(59, 58, 34, 48); m_InsetViewButton->setArmedBorderColor(194, 202, 54, 0); m_InsetViewButton->setUnArmedColor(143, 143, 54, 0); m_InsetViewButton->setArmedColor(194, 202, 54, 0); m_menuVisible = false; m_insetVisible = false; // m_HideButton->setVisible(false); m_CamButton->setVisible(false); m_OptionButton->setVisible(false); m_NextPlayerButton->setVisible(false); m_PrevPlayerButton->setVisible(false); m_TopBanner->setVisible(false); m_ExtraInfo->setVisible(false); m_Separator->setVisible(false); m_TimerImage->setVisible(false); }
void ScorePanel::FillGrid() { CSchemeManager *pSchemes = gViewPort->GetSchemeManager(); SchemeHandle_t hScheme = pSchemes->getSchemeHandle("Scoreboard Text"); SchemeHandle_t hTitleScheme = pSchemes->getSchemeHandle("Scoreboard Title Text"); SchemeHandle_t hSmallScheme = pSchemes->getSchemeHandle("Scoreboard Small Text"); Font *sfont = pSchemes->getFont(hScheme); Font *tfont = pSchemes->getFont(hTitleScheme); /* Font *smallfont = */ pSchemes->getFont(hSmallScheme); int i = 0; // update highlight position int x, y; getApp()->getCursorPos(x, y); cursorMoved(x, y, this); // remove highlight row if we're not in squelch mode if (!GetClientVoiceMgr()->IsInSquelchMode()) { m_iHighlightRow = -1; } for(int row=0; row < NUM_ROWS; row++) { CGrid *pGridRow = &m_PlayerGrids[row]; pGridRow->SetRowUnderline(0, false, 0, 0, 0, 0, 0); if(row >= m_iRows) { for(int col=0; col < NUM_COLUMNS; col++) m_PlayerEntries[col][row].setVisible(false); continue; } for(int col=0; col < NUM_COLUMNS; col++) { CLabelHeader *pLabel = &m_PlayerEntries[col][row]; pLabel->setVisible(true); pLabel->setText2(""); pLabel->setImage(NULL); pLabel->setFont(sfont); pLabel->setTextOffset(0, 0); int rowheight = 13; if (ScreenHeight > 480) { rowheight = YRES(rowheight); } else { // more tweaking, make sure icons fit at low res rowheight = 15; } pLabel->setSize(pLabel->getWide(), rowheight); pLabel->setBgColor(0, 0, 0, 255); char sz[128]; hud_player_info_t *pl_info = NULL; team_info_t *team_info = NULL; if (m_iIsATeam[row] == TEAM_SPECTATORS) { pLabel->setText(" "); continue; } else if ( m_iIsATeam[row] == TEAM_YES ) { // Get the team's data team_info = &g_TeamInfo[ m_iSortedRows[row] ]; // team color text for team names pLabel->setFgColor( iTeamColors[team_info->teamnumber % 5][0], iTeamColors[team_info->teamnumber % 5][1], iTeamColors[team_info->teamnumber % 5][2], 0 ); // different height for team header rows rowheight = 20; if (ScreenHeight >= 480) { rowheight = YRES(rowheight); } pLabel->setSize(pLabel->getWide(), rowheight); pLabel->setFont(tfont); pGridRow->SetRowUnderline( 0, true, YRES(3), iTeamColors[team_info->teamnumber % 5][0], iTeamColors[team_info->teamnumber % 5][1], iTeamColors[team_info->teamnumber % 5][2], 0 ); } else if ( m_iIsATeam[row] == TEAM_SPECTATORS ) { // grey text for spectators pLabel->setFgColor(100, 100, 100, 0); // different height for team header rows rowheight = 20; if (ScreenHeight >= 480) { rowheight = YRES(rowheight); } pLabel->setSize(pLabel->getWide(), rowheight); pLabel->setFont(tfont); pGridRow->SetRowUnderline(0, true, YRES(3), 100, 100, 100, 0); } else { // team color text for player names pLabel->setFgColor( g_iaDiscColors[ g_PlayerExtraInfo[ m_iSortedRows[row] ].teamnumber % iNumberOfTeamColors ][0], g_iaDiscColors[ g_PlayerExtraInfo[ m_iSortedRows[row] ].teamnumber % iNumberOfTeamColors ][1], g_iaDiscColors[ g_PlayerExtraInfo[ m_iSortedRows[row] ].teamnumber % iNumberOfTeamColors ][2], 0 ); // Get the player's data pl_info = &g_PlayerInfoList[ m_iSortedRows[row] ]; // Set background color if ( pl_info->thisplayer ) // if it is their name, draw it a different color { // Highlight this player pLabel->setFgColor(Scheme::sc_white); pLabel->setBgColor( g_iaDiscColors[ g_PlayerExtraInfo[ m_iSortedRows[row] ].teamnumber % iNumberOfTeamColors ][0], g_iaDiscColors[ g_PlayerExtraInfo[ m_iSortedRows[row] ].teamnumber % iNumberOfTeamColors ][1], g_iaDiscColors[ g_PlayerExtraInfo[ m_iSortedRows[row] ].teamnumber % iNumberOfTeamColors ][2], 196 ); } else if ( m_iSortedRows[row] == m_iLastKilledBy && m_fLastKillTime && m_fLastKillTime > gHUD.m_flTime ) { // Killer's name pLabel->setBgColor( 255,0,0, 255 - ((float)15 * (float)(m_fLastKillTime - gHUD.m_flTime)) ); } } // Align if (col == COLUMN_NAME ) { pLabel->setContentAlignment( vgui::Label::a_west ); } else if (col == COLUMN_TRACKER) { pLabel->setContentAlignment( vgui::Label::a_center ); } else { pLabel->setContentAlignment( vgui::Label::a_east ); } // Fill out with the correct data strcpy(sz, ""); if ( m_iIsATeam[row] ) { char sz2[128]; switch (col) { case COLUMN_NAME: if ( m_iIsATeam[row] == TEAM_UNASSIGNED ) { sprintf( sz2, "%s", CHudTextMessage::BufferedLocaliseTextString( "#Queue" ) ); } else if ( m_iIsATeam[row] == TEAM_SPECTATORS ) { sprintf( sz2, "%s", CHudTextMessage::BufferedLocaliseTextString( "#Spectators" ) ); } else { sprintf( sz2, "%s", CHudTextMessage::BufferedLocaliseTextString( team_info->name ) ); } // Uppercase it for ( i = 0; i < (int)strlen(sz2); i++) { if ( *(sz2 + i) ) sz[i] = toupper( *(sz2 + i) ); } sz[i] = '\0'; // Append the number of players if ( m_iIsATeam[row] == TEAM_YES ) { const char *pszTemp = NULL; if ( team_info->players == 1 ) { pszTemp = "#Player"; } else { pszTemp = "#Player_plural"; } sprintf(sz, "%s (%d %s)", sz, team_info->players, CHudTextMessage::BufferedLocaliseTextString( pszTemp ) ); } break; case COLUMN_VOICE: break; case COLUMN_CLASS: break; case COLUMN_KILLS: //Wins if ( g_iArenaMode == FALSE ) strcpy ( sz, " " ); else { if ( m_iIsATeam[row] == TEAM_YES ) sprintf(sz, "%d", team_info->deaths ); } break; case COLUMN_DEATHS: //Points if ( m_iIsATeam[row] == TEAM_YES ) sprintf(sz, "%d", team_info->frags ); break; case COLUMN_LATENCY: if ( m_iIsATeam[row] == TEAM_YES ) sprintf(sz, "%d", team_info->ping ); break; default: break; } } else { switch (col) { case COLUMN_NAME: /* if (g_pTrackerUser) { int playerSlot = m_iSortedRows[row]; int trackerID = gEngfuncs.GetTrackerIDForPlayer(playerSlot); const char *trackerName = g_pTrackerUser->GetUserName(trackerID); if (trackerName && *trackerName) { sprintf(sz, " (%s)", trackerName); pLabel->setText2(sz); } } */ sprintf(sz, "%s ", pl_info->name); break; case COLUMN_VOICE: sz[0] = 0; GetClientVoiceMgr()->UpdateSpeakerImage(pLabel, m_iSortedRows[row]); break; case COLUMN_CLASS: if ( g_PlayerExtraInfo[ m_iSortedRows[row] ].teamnumber == 0 && g_iArenaMode == TRUE ) { sprintf(sz, "%d", g_PlayerExtraInfo[ m_iSortedRows[row] ].playerclass ); } else { strcpy(sz, ""); } break; case COLUMN_TRACKER: /* if (g_pTrackerUser) { int playerSlot = m_iSortedRows[row]; int trackerID = gEngfuncs.GetTrackerIDForPlayer(playerSlot); if (g_pTrackerUser->IsFriend(trackerID) && trackerID != g_pTrackerUser->GetTrackerID()) { pLabel->setImage(m_pTrackerIcon); pLabel->setFgColorAsImageColor(false); m_pTrackerIcon->setColor(Color(255, 255, 255, 0)); } }*/ break; case COLUMN_KILLS: //Wins if ( g_iArenaMode == TRUE ) sprintf(sz, "%d", g_PlayerExtraInfo[ m_iSortedRows[row] ].deaths ); break; case COLUMN_DEATHS: //Points sprintf(sz, "%d", g_PlayerExtraInfo[ m_iSortedRows[row] ].frags ); break; case COLUMN_LATENCY: sprintf(sz, "%d", g_PlayerInfoList[ m_iSortedRows[row] ].ping ); break; default: break; } } pLabel->setText(sz); } } for(int row = 0; row < NUM_ROWS; row++) { CGrid *pGridRow = &m_PlayerGrids[row]; pGridRow->AutoSetRowHeights(); pGridRow->setSize(PanelWidth(pGridRow), pGridRow->CalcDrawHeight()); pGridRow->RepositionContents(); } // hack, for the thing to resize m_PlayerList.getSize(x, y); m_PlayerList.setSize(x, y); }
void CScoreBoard::paintTeamplay() { CSchemeManager *pSchemes = gViewPort->GetSchemeManager(); SchemeHandle_t hTitleScheme = pSchemes->getSchemeHandle( "Basic_Text" ); Font *pTitleFont = pSchemes->getFont( hTitleScheme ); drawSetColor(255, 255, 0, 200); drawFilledRect(0, 0, getWide(), pTitleFont->getTall() + YRES(4)); drawSetTextFont(pTitleFont); drawSetTextColor(250, 250, 250, 40); drawSetTextPos(XRES(10), YRES(2)); drawPrintText("SCORES:", strlen( "SCORES:" ) ); drawSetTextFont(pTitleFont); drawSetTextColor(250, 250, 250, 40); drawSetTextPos(XRES(10), YRES(20)); drawPrintText("Teams", strlen( "Teams" ) ); drawSetTextFont(pTitleFont); drawSetTextColor(250, 250, 250, 40); drawSetTextPos(XRES(280), YRES(20)); drawPrintText("Frags", strlen( "Frags" ) ); drawSetTextFont(pTitleFont); drawSetTextColor(250, 250, 250, 40); drawSetTextPos(XRES(330), YRES(20)); drawPrintText("Deaths", strlen( "Deaths" ) ); drawSetTextFont(pTitleFont); drawSetTextColor(250, 250, 250, 40); drawSetTextPos(XRES(380), YRES(20)); drawPrintText("Ping", strlen( "Ping" ) ); drawSetColor(0, 0, 0, 70); drawOutlinedRect(0, 0, getWide(), getTall()); drawSetColor(255, 0, 0, 200); drawFilledRect( XRES( 10 ), YRES( 40 ), XRES( 430 ), pTitleFont->getTall() + YRES(44) ); drawSetTextFont(pTitleFont); drawSetTextColor(250, 250, 250, 40); drawSetTextPos(XRES(12), YRES(42)); drawPrintText("Terrorists", strlen( "Terrorists" ) ); drawSetColor(0, 0, 255, 200); drawFilledRect( XRES( 10 ), YRES( 200 ), XRES( 430 ), pTitleFont->getTall() + YRES(204) ); drawSetTextFont(pTitleFont); drawSetTextColor(250, 250, 250, 40); drawSetTextPos(XRES(12), YRES(202)); drawPrintText("Counter-Terrorists", strlen( "Counter-Terrorists" ) ); int TY = YRES(46) + pTitleFont->getTall(); int CTY = YRES(206) + pTitleFont->getTall(); for( int i = 0; i < CountPlayers; i++ ) { if( ScrBrdPlayerInfo[i].spectator ) continue; char Name[32]; char Frags[32]; char Deaths[32]; char Ping[32]; int Team; strcpy( Name, ScrBrdPlayerInfo[i].Name ); sprintf( Frags, "%d", ScrBrdPlayerInfo[i].Frags ); sprintf( Deaths, "%d", ScrBrdPlayerInfo[i].Deaths ); sprintf( Ping, "%d", ScrBrdPlayerInfo[i].Ping ); Team = ScrBrdPlayerInfo[i].Team; int X = XRES(12); int Y; if( Team == 1 ) Y = TY; else Y = CTY; drawSetTextFont(pTitleFont); drawSetTextColor(250, 250, 250, 40); drawSetTextPos(X, Y); drawPrintText(Name, strlen( Name ) ); drawSetTextFont(pTitleFont); drawSetTextColor(250, 250, 250, 40); drawSetTextPos(XRES(290), Y); drawPrintText(Frags, strlen( Frags ) ); drawSetTextFont(pTitleFont); drawSetTextColor(250, 250, 250, 40); drawSetTextPos(XRES(340), Y); drawPrintText(Deaths, strlen( Deaths ) ); drawSetTextFont(pTitleFont); drawSetTextColor(250, 250, 250, 40); drawSetTextPos(XRES(390), Y); drawPrintText(Ping, strlen( Ping ) ); if( Team == 1 ) TY += YRES(2) + pTitleFont->getTall(); else CTY += YRES(2) + pTitleFont->getTall(); } }
void CScoreBoard::paint() { gViewPort->GetAllPlayersInfo(); CountPlayers = 0; for ( int i = 1; i < MAX_PLAYERS; i++ ) { if( !g_PlayerInfoList[i].name ) continue; if( !strlen( g_PlayerInfoList[i].name ) ) continue; strcpy( ScrBrdPlayerInfo[i - 1].Name, g_PlayerInfoList[i].name ); ScrBrdPlayerInfo[i - 1].Frags = g_PlayerExtraInfo[i].frags; ScrBrdPlayerInfo[i - 1].Deaths = g_PlayerExtraInfo[i].deaths; ScrBrdPlayerInfo[i - 1].Ping = g_PlayerInfoList[i].ping; ScrBrdPlayerInfo[i - 1].Team = g_PlayerExtraInfo[i].teamnumber; ScrBrdPlayerInfo[i - 1].spectator = g_IsSpectator[i]; CountPlayers++; } sort( ScrBrdPlayerInfo, ScrBrdPlayerInfo + CountPlayers, cmp ); if( gHUD.m_GameMode != 1 ) { paintTeamplay(); return; } CSchemeManager *pSchemes = gViewPort->GetSchemeManager(); SchemeHandle_t hTitleScheme = pSchemes->getSchemeHandle( "Basic_Text" ); Font *pTitleFont = pSchemes->getFont( hTitleScheme ); drawSetColor(255, 255, 0, 200); drawFilledRect(0, 0, getWide(), pTitleFont->getTall() + YRES(4)); drawSetTextFont(pTitleFont); drawSetTextColor(250, 250, 250, 40); drawSetTextPos(XRES(10), YRES(2)); drawPrintText("SCORES:", strlen( "SCORES:" ) ); drawSetTextFont(pTitleFont); drawSetTextColor(250, 250, 250, 40); drawSetTextPos(XRES(10), YRES(20)); drawPrintText("Teams", strlen( "Teams" ) ); drawSetTextFont(pTitleFont); drawSetTextColor(250, 250, 250, 40); drawSetTextPos(XRES(280), YRES(20)); drawPrintText("Frags", strlen( "Frags" ) ); drawSetTextFont(pTitleFont); drawSetTextColor(250, 250, 250, 40); drawSetTextPos(XRES(330), YRES(20)); drawPrintText("Deaths", strlen( "Deaths" ) ); drawSetTextFont(pTitleFont); drawSetTextColor(250, 250, 250, 40); drawSetTextPos(XRES(380), YRES(20)); drawPrintText("Ping", strlen( "Ping" ) ); drawSetColor(0, 0, 0, 70); drawOutlinedRect(0, 0, getWide(), getTall()); int Y = YRES(36) + pTitleFont->getTall(); for( int i = 0; i < CountPlayers; i++ ) { if( ScrBrdPlayerInfo[i].spectator ) continue; char Name[32]; char Frags[32]; char Deaths[32]; char Ping[32]; int Team; strcpy( Name, ScrBrdPlayerInfo[i].Name ); sprintf( Frags, "%d", ScrBrdPlayerInfo[i].Frags ); sprintf( Deaths, "%d", ScrBrdPlayerInfo[i].Deaths ); sprintf( Ping, "%d", ScrBrdPlayerInfo[i].Ping ); Team = ScrBrdPlayerInfo[i].Team; int X = XRES(12); drawSetTextFont(pTitleFont); drawSetTextColor(250, 250, 250, 40); drawSetTextPos(X, Y); drawPrintText(Name, strlen( Name ) ); drawSetTextFont(pTitleFont); drawSetTextColor(250, 250, 250, 40); drawSetTextPos(XRES(290), Y); drawPrintText(Frags, strlen( Frags ) ); drawSetTextFont(pTitleFont); drawSetTextColor(250, 250, 250, 40); drawSetTextPos(XRES(340), Y); drawPrintText(Deaths, strlen( Deaths ) ); drawSetTextFont(pTitleFont); drawSetTextColor(250, 250, 250, 40); drawSetTextPos(XRES(390), Y); drawPrintText(Ping, strlen( Ping ) ); Y += YRES(2) + pTitleFont->getTall(); } }
//----------------------------------------------------------------------------- // Purpose: Constructs a message panel //----------------------------------------------------------------------------- CMessageWindowPanel::CMessageWindowPanel( const char *szMOTD, const char *szTitle, int iShadeFullscreen, int iRemoveMe, int x, int y, int wide, int tall ) : CMenuPanel( iShadeFullscreen ? 100 : 255, iRemoveMe, x, y, wide, tall ) { // Get the scheme used for the Titles CSchemeManager *pSchemes = gViewPort->GetSchemeManager(); // schemes SchemeHandle_t hTitleScheme = pSchemes->getSchemeHandle( "Title Font" ); SchemeHandle_t hMOTDText = pSchemes->getSchemeHandle( "Briefing Text" ); // color schemes int r, g, b, a; // Create the window m_pBackgroundPanel = new CTransparentPanel( iShadeFullscreen ? 255 : 100, MOTD_WINDOW_X, MOTD_WINDOW_Y, MOTD_WINDOW_SIZE_X, MOTD_WINDOW_SIZE_Y ); m_pBackgroundPanel->setParent( this ); m_pBackgroundPanel->setBorder( new LineBorder( Color(255 * 0.7,170 * 0.7,0,0)) ); m_pBackgroundPanel->setVisible( true ); int iXSize,iYSize,iXPos,iYPos; m_pBackgroundPanel->getPos( iXPos,iYPos ); m_pBackgroundPanel->getSize( iXSize,iYSize ); // Create the title Label *pLabel = new Label( "", iXPos + MOTD_TITLE_X, iYPos + MOTD_TITLE_Y ); pLabel->setParent( this ); pLabel->setFont( pSchemes->getFont(hTitleScheme) ); pLabel->setFont( Scheme::sf_primary1 ); pSchemes->getFgColor( hTitleScheme, r, g, b, a ); pLabel->setFgColor( r, g, b, a ); pLabel->setFgColor( Scheme::sc_primary1 ); pSchemes->getBgColor( hTitleScheme, r, g, b, a ); pLabel->setBgColor( r, g, b, a ); pLabel->setContentAlignment( vgui::Label::a_west ); pLabel->setText( "%s", szTitle); // Create the Scroll panel ScrollPanel *pScrollPanel = new CTFScrollPanel( iXPos + XRES(16), iYPos + MOTD_TITLE_Y*2 + YRES(16), iXSize - XRES(32), iYSize - (YRES(48) + BUTTON_SIZE_Y*2) ); pScrollPanel->setParent(this); //force the scrollbars on so clientClip will take them in account after the validate pScrollPanel->setScrollBarAutoVisible(false, false); pScrollPanel->setScrollBarVisible(true, true); pScrollPanel->validate(); // Create the text panel TextPanel *pText = new TextPanel( "", 0,0, 64,64); pText->setParent( pScrollPanel->getClient() ); // get the font and colors from the scheme pText->setFont( pSchemes->getFont(hMOTDText) ); pSchemes->getFgColor( hMOTDText, r, g, b, a ); pText->setFgColor( r, g, b, a ); pSchemes->getBgColor( hMOTDText, r, g, b, a ); pText->setBgColor( r, g, b, a ); pText->setText( szMOTD); // Get the total size of the MOTD text and resize the text panel int iScrollSizeX, iScrollSizeY; // First, set the size so that the client's wdith is correct at least because the // width is critical for getting the "wrapped" size right. // You'll see a horizontal scroll bar if there is a single word that won't wrap in the // specified width. pText->getTextImage()->setSize(pScrollPanel->getClientClip()->getWide(), pScrollPanel->getClientClip()->getTall()); pText->getTextImage()->getTextSizeWrapped( iScrollSizeX, iScrollSizeY ); // Now resize the textpanel to fit the scrolled size pText->setSize( iScrollSizeX , iScrollSizeY ); //turn the scrollbars back into automode pScrollPanel->setScrollBarAutoVisible(true, true); pScrollPanel->setScrollBarVisible(false, false); pScrollPanel->validate(); CommandButton *pButton = new CommandButton( CHudTextMessage::BufferedLocaliseTextString( "#Menu_OK" ), iXPos + XRES(16), iYPos + iYSize - YRES(16) - BUTTON_SIZE_Y, CMENU_SIZE_X, BUTTON_SIZE_Y); pButton->addActionSignal(new CMenuHandler_TextWindow(HIDE_TEXTWINDOW)); pButton->setParent(this); }
void ScorePanel::FillGrid() { CSchemeManager *pSchemes = gViewPort->GetSchemeManager(); SchemeHandle_t hScheme = pSchemes->getSchemeHandle("Scoreboard Text"); SchemeHandle_t hTitleScheme = pSchemes->getSchemeHandle("Scoreboard Title Text"); SchemeHandle_t hSmallScheme = pSchemes->getSchemeHandle("Scoreboard Small Text"); Font *sfont = pSchemes->getFont(hScheme); Font *tfont = pSchemes->getFont(hTitleScheme); Font *smallfont = pSchemes->getFont(hSmallScheme); // update highlight position int x, y; getApp()->getCursorPos(x, y); cursorMoved(x, y, this); // remove highlight row if we're not in squelch mode if (!GetClientVoiceMgr()->IsInSquelchMode()) { m_iHighlightRow = -1; } bool bNextRowIsGap = false; for(int row=0; row < NUM_ROWS; row++) { CGrid *pGridRow = &m_PlayerGrids[row]; pGridRow->SetRowUnderline(0, false, 0, 0, 0, 0, 0); if(row >= m_iRows) { for(int col=0; col < NUM_COLUMNS; col++) m_PlayerEntries[col][row].setVisible(false); continue; } bool bRowIsGap = false; if (bNextRowIsGap) { bNextRowIsGap = false; bRowIsGap = true; } for(int col=0; col < NUM_COLUMNS; col++) { CLabelHeader *pLabel = &m_PlayerEntries[col][row]; pLabel->setVisible(true); pLabel->setText2(""); pLabel->setImage(NULL); pLabel->setFont(sfont); pLabel->setTextOffset(0, 0); int rowheight = 13; if (ScreenHeight > 480) { rowheight = YRES(rowheight); } else { // more tweaking, make sure icons fit at low res rowheight = 15; } pLabel->setSize(pLabel->getWide(), rowheight); pLabel->setBgColor(0, 0, 0, 255); char sz[128]; hud_player_info_t *pl_info = NULL; team_info_t *team_info = NULL; if (m_iIsATeam[row] == TEAM_BLANK) { pLabel->setText(" "); continue; } else if ( m_iIsATeam[row] == TEAM_YES ) { // Get the team's data team_info = &g_TeamInfo[ m_iSortedRows[row] ]; // team color text for team names pLabel->setFgColor( iTeamColors[team_info->teamnumber % iNumberOfTeamColors][0], iTeamColors[team_info->teamnumber % iNumberOfTeamColors][1], iTeamColors[team_info->teamnumber % iNumberOfTeamColors][2], 0 ); // different height for team header rows rowheight = 20; if (ScreenHeight >= 480) { rowheight = YRES(rowheight); } pLabel->setSize(pLabel->getWide(), rowheight); pLabel->setFont(tfont); pGridRow->SetRowUnderline( 0, true, YRES(3), iTeamColors[team_info->teamnumber % iNumberOfTeamColors][0], iTeamColors[team_info->teamnumber % iNumberOfTeamColors][1], iTeamColors[team_info->teamnumber % iNumberOfTeamColors][2], 0 ); } else if ( m_iIsATeam[row] == TEAM_SPECTATORS ) { // grey text for spectators pLabel->setFgColor(100, 100, 100, 0); // different height for team header rows rowheight = 20; if (ScreenHeight >= 480) { rowheight = YRES(rowheight); } pLabel->setSize(pLabel->getWide(), rowheight); pLabel->setFont(tfont); pGridRow->SetRowUnderline(0, true, YRES(3), 100, 100, 100, 0); } else { // team color text for player names pLabel->setFgColor( iTeamColors[ g_PlayerExtraInfo[ m_iSortedRows[row] ].teamnumber % iNumberOfTeamColors ][0], iTeamColors[ g_PlayerExtraInfo[ m_iSortedRows[row] ].teamnumber % iNumberOfTeamColors ][1], iTeamColors[ g_PlayerExtraInfo[ m_iSortedRows[row] ].teamnumber % iNumberOfTeamColors ][2], 0 ); // Get the player's data pl_info = &g_PlayerInfoList[ m_iSortedRows[row] ]; // Set background color if ( pl_info->thisplayer ) // if it is their name, draw it a different color { // Highlight this player pLabel->setFgColor(Scheme::sc_white); pLabel->setBgColor( iTeamColors[ g_PlayerExtraInfo[ m_iSortedRows[row] ].teamnumber % iNumberOfTeamColors ][0], iTeamColors[ g_PlayerExtraInfo[ m_iSortedRows[row] ].teamnumber % iNumberOfTeamColors ][1], iTeamColors[ g_PlayerExtraInfo[ m_iSortedRows[row] ].teamnumber % iNumberOfTeamColors ][2], 196 ); } else if ( m_iSortedRows[row] == m_iLastKilledBy && m_fLastKillTime && m_fLastKillTime > gHUD.m_flTime ) { // Killer's name pLabel->setBgColor( 255,0,0, 255 - ((float)15 * (float)(m_fLastKillTime - gHUD.m_flTime)) ); } } // Align if (col == COLUMN_NAME || col == COLUMN_CLASS) { pLabel->setContentAlignment( vgui::Label::a_west ); } else if (col == COLUMN_TRACKER) { pLabel->setContentAlignment( vgui::Label::a_center ); } else { pLabel->setContentAlignment( vgui::Label::a_east ); } // Fill out with the correct data strcpy(sz, ""); if ( m_iIsATeam[row] ) { char sz2[128]; switch (col) { case COLUMN_NAME: if ( m_iIsATeam[row] == TEAM_SPECTATORS ) { sprintf( sz2, CHudTextMessage::BufferedLocaliseTextString( "#Spectators" ) ); } else { sprintf( sz2, gViewPort->GetTeamName(team_info->teamnumber) ); } strcpy(sz, sz2); // Append the number of players if ( m_iIsATeam[row] == TEAM_YES ) { if (team_info->players == 1) { sprintf(sz2, "(%d %s)", team_info->players, CHudTextMessage::BufferedLocaliseTextString( "#Player" ) ); } else { sprintf(sz2, "(%d %s)", team_info->players, CHudTextMessage::BufferedLocaliseTextString( "#Player_plural" ) ); } pLabel->setText2(sz2); pLabel->setFont2(smallfont); } break; case COLUMN_VOICE: break; case COLUMN_CLASS: break; case COLUMN_KILLS: if ( m_iIsATeam[row] == TEAM_YES ) sprintf(sz, "%d", team_info->frags ); break; case COLUMN_DEATHS: if ( m_iIsATeam[row] == TEAM_YES ) sprintf(sz, "%d", team_info->deaths ); break; case COLUMN_LATENCY: if ( m_iIsATeam[row] == TEAM_YES ) sprintf(sz, "%d", team_info->ping ); break; default: break; } } else { bool bShowClass = false; switch (col) { case COLUMN_NAME: sprintf(sz, "%s ", pl_info->name); break; case COLUMN_VOICE: sz[0] = 0; // in HLTV mode allow spectator to turn on/off commentator voice if (!pl_info->thisplayer || gEngfuncs.IsSpectateOnly() ) { GetClientVoiceMgr()->UpdateSpeakerImage(pLabel, m_iSortedRows[row]); } break; case COLUMN_CLASS: // No class for other team's members (unless allied or spectator) if ( gViewPort && EV_TFC_IsAllyTeam( g_iTeamNumber, g_PlayerExtraInfo[ m_iSortedRows[row] ].teamnumber ) ) bShowClass = true; // Don't show classes if this client hasnt picked a team yet if ( g_iTeamNumber == 0 ) bShowClass = false; if (bShowClass) { // Only print Civilian if this team are all civilians bool bNoClass = false; if ( g_PlayerExtraInfo[ m_iSortedRows[row] ].playerclass == 0 ) { if ( gViewPort->GetValidClasses( g_PlayerExtraInfo[ m_iSortedRows[row] ].teamnumber ) != -1 ) bNoClass = true; } if (bNoClass) sprintf(sz, ""); else sprintf( sz, "%s", CHudTextMessage::BufferedLocaliseTextString( sLocalisedClasses[ g_PlayerExtraInfo[ m_iSortedRows[row] ].playerclass ] ) ); } else { strcpy(sz, ""); } break; case COLUMN_TRACKER: break; case COLUMN_KILLS: sprintf(sz, "%d", g_PlayerExtraInfo[ m_iSortedRows[row] ].frags ); break; case COLUMN_DEATHS: sprintf(sz, "%d", g_PlayerExtraInfo[ m_iSortedRows[row] ].deaths ); break; case COLUMN_LATENCY: sprintf(sz, "%d", g_PlayerInfoList[ m_iSortedRows[row] ].ping ); break; default: break; } } pLabel->setText(sz); } } for(row=0; row < NUM_ROWS; row++) { CGrid *pGridRow = &m_PlayerGrids[row]; pGridRow->AutoSetRowHeights(); pGridRow->setSize(PanelWidth(pGridRow), pGridRow->CalcDrawHeight()); pGridRow->RepositionContents(); } // hack, for the thing to resize m_PlayerList.getSize(x, y); m_PlayerList.setSize(x, y); }