void CHUDScores::UpdateLayout() { char *pTag = "Scores"; m_BasePos = g_pLayoutMgr->GetPoint(pTag,"BasePos"); uint8 nFont = (uint8)g_pLayoutMgr->GetInt(pTag,"Font"); m_nBaseFontSize = (uint8)g_pLayoutMgr->GetInt(pTag,"FontSize"); LTVector vCol = g_pLayoutMgr->GetVector(pTag,"TextColor"); uint8 nR = (uint8)vCol.x; uint8 nG = (uint8)vCol.y; uint8 nB = (uint8)vCol.z; m_nTextColor = SET_ARGB(0xFF,nR,nG,nB); vCol = g_pLayoutMgr->GetVector(pTag,"PlayerTextColor"); nR = (uint8)vCol.x; nG = (uint8)vCol.y; nB = (uint8)vCol.z; m_nPlayerTextColor = SET_ARGB(0xFF,nR,nG,nB); vCol = g_pLayoutMgr->GetVector(pTag,"ScreenPlayerTextColor"); nR = (uint8)vCol.x; nG = (uint8)vCol.y; nB = (uint8)vCol.z; m_nScreenPlayerTextColor = SET_ARGB(0xFF,nR,nG,nB); vCol = g_pLayoutMgr->GetVector(pTag,"ScreenTextColor"); nR = (uint8)vCol.x; nG = (uint8)vCol.y; nB = (uint8)vCol.z; m_nScreenTextColor = SET_ARGB(0xFF,nR,nG,nB); vCol = g_pLayoutMgr->GetVector(pTag,"FrameColor"); nR = (uint8)vCol.x; nG = (uint8)vCol.y; nB = (uint8)vCol.z; float fAlpha = g_pLayoutMgr->GetFloat(pTag,"FrameAlpha"); uint8 nA = (uint8)(255.0f * fAlpha); uint32 nFrameColor = SET_ARGB(nA,nR,nG,nB); uint32 nTeamColors[kNumTeams] = {argbBlack,argbBlack}; vCol = g_pLayoutMgr->GetVector(pTag,"Team1Color"); nR = (uint8)vCol.x; nG = (uint8)vCol.y; nB = (uint8)vCol.z; nTeamColors[0]= SET_ARGB(nA,nR,nG,nB); vCol = g_pLayoutMgr->GetVector(pTag,"Team2Color"); nR = (uint8)vCol.x; nG = (uint8)vCol.y; nB = (uint8)vCol.z; nTeamColors[1]= SET_ARGB(nA,nR,nG,nB); CUIFont* pFont = g_pInterfaceResMgr->GetFont(nFont); uint16 nCol1 = g_pLayoutMgr->GetInt(pTag,"NameColumn"); uint16 nCol2 = g_pLayoutMgr->GetInt(pTag,"ScoreColumn"); uint16 nCol3 = g_pLayoutMgr->GetInt(pTag,"KillColumn"); uint16 nCol4 = g_pLayoutMgr->GetInt(pTag,"TagColumn"); uint16 nCol5 = g_pLayoutMgr->GetInt(pTag,"PingColumn"); m_nFrameWidth = (nCol1+nCol2+nCol3+nCol4+nCol5) + 16; if (!m_bControlsInited) { m_SingleFrame.Create(nFrameColor,m_nFrameWidth,32); for (int team = 0; team < kNumTeams; team++) { m_Frame[team].Create(nTeamColors[team],m_nFrameWidth,32); m_Team[team].Create("",0,0,pFont,(m_nBaseFontSize+4),NULL); m_Team[team].SetColors(m_nTextColor,m_nTextColor,m_nTextColor); m_Rounds[team].Create("",0,0,pFont,(m_nBaseFontSize+4),NULL); m_Rounds[team].SetColors(m_nTextColor,m_nTextColor,m_nTextColor); m_Rounds[team].GetString()->SetAlignmentH(CUI_HALIGN_RIGHT); m_Header[team].Create ( 0,0, pFont, (m_nBaseFontSize+4), NULL); m_Header[team].SetColors(m_nTextColor,m_nTextColor,m_nTextColor); m_Header[team].AddColumn(LoadTempString(IDS_SCORE_PLAYERS), (nCol1-8), LTFALSE); m_Header[team].AddColumn(LoadTempString(IDS_SCORE_SCORE), nCol2, LTFALSE); m_Header[team].AddColumn(LoadTempString(IDS_SCORE_KILLS), nCol3, LTFALSE); m_Header[team].AddColumn(LoadTempString(IDS_SCORE_TAGS), nCol4, LTFALSE); m_Header[team].AddColumn(LoadTempString(IDS_SCORE_PING), nCol5, LTFALSE); for (int i = 0; i < kMaxPlayers; i++) { m_Columns[team][i].Create ( 0,0, pFont, m_nBaseFontSize, NULL); m_Columns[team][i].SetColors(m_nTextColor,m_nTextColor,m_nTextColor); m_Columns[team][i].AddColumn("<player name>", nCol1, LTTRUE); m_Columns[team][i].AddColumn("<Score>", nCol2, LTTRUE); m_Columns[team][i].AddColumn("<Frags>", nCol3, LTTRUE); m_Columns[team][i].AddColumn("<Tags>", nCol4, LTTRUE); m_Columns[team][i].AddColumn("<Ping>", nCol5, LTTRUE); m_Columns[team][i].Show(LTFALSE); } } m_Server.Create("",0,0,pFont,(m_nBaseFontSize+4),NULL); m_Server.SetColors(m_nTextColor,m_nTextColor,m_nTextColor); LTIntPt framePos = m_BasePos; framePos.x -= 8; framePos.y -= 4; m_SingleFrame.SetBasePos(framePos); UpdateTeamPos(0,m_BasePos); m_bControlsInited = true; } }
void CHUDScores::UpdateLayout( ) { if( !m_bInitialized ) return; //if we haven't initialized our layout info if (!m_hLayout) { m_hLayout = g_pLayoutDB->GetHUDRecord("HUDScores"); } CHUDItem::UpdateLayout(); CFontInfo headerFont = m_sTextFont; headerFont.m_nHeight = g_pLayoutDB->GetInt32(m_hLayout,LDB_HUDAddInt,kNumColumns); headerFont.m_nStyle = CFontInfo::kStyle_Bold; m_cPlayerTextColor = g_pLayoutDB->GetColor(m_hLayout,LDB_HUDAddColor,0); m_cDeadColor = g_pLayoutDB->GetColor(m_hLayout,LDB_HUDAddColor,1); m_cPlayerDeadColor = g_pLayoutDB->GetColor(m_hLayout,LDB_HUDAddColor,2); for (uint8 nTeam = 0; nTeam < kNumTeams; nTeam++) { m_hFrameTexture[nTeam].Load( g_pLayoutDB->GetString(m_hLayout,LDB_HUDAddTex,nTeam)); } uint32 nCol[kNumColumns]; m_nFrameWidth = 16; for (uint8 n = 0; n < kNumColumns; ++n) { nCol[n] = g_pLayoutDB->GetInt32(m_hLayout,LDB_HUDAddInt,n); m_nFrameWidth += nCol[n]; } if( !m_bControlsInited ) { CLTGUICtrl_create cs; cs.rnBaseRect.Right() = m_nFrameWidth; cs.rnBaseRect.Bottom() = 32; m_SingleFrame.Create(m_hIconTexture,cs); for (int team = 0; team < kNumTeams; team++) { m_Frame[team].Create(m_hFrameTexture[team],cs); CLTGUICtrl_create tcs; tcs.rnBaseRect.Right() = nCol[0]; tcs.rnBaseRect.Bottom() = headerFont.m_nHeight; m_Team[team].Create(L"",headerFont,tcs); m_Team[team].SetColor(m_cTextColor); m_Rounds[team].Create(L"",headerFont, tcs); m_Rounds[team].SetColor(m_cTextColor); m_Rounds[team].SetAlignment(kRight); m_Header[team].Create(headerFont, tcs); m_Header[team].SetColor(m_cTextColor); m_Header[team].AddColumn(LoadString("IDS_SCORE_PLAYERS"), (nCol[eColumnName]-8), false); m_Header[team].AddColumn(LoadString("IDS_SCORE_SCORE"), nCol[eColumnScore], false); m_Header[team].AddColumn(LoadString("IDS_SCORE_KILLS"), nCol[eColumnKill], false); m_Header[team].AddColumn(LoadString("IDS_SCORE_DEATHS"), nCol[eColumnDeath], false); m_Header[team].AddColumn(LoadString("IDS_SCORE_OBJECTIVE"), nCol[eColumnObjective], false); m_Header[team].AddColumn(LoadString("IDS_SCORE_TK"), nCol[eColumnTK], false); m_Header[team].AddColumn(LoadString("IDS_SCORE_SUICIDE"), nCol[eColumnSuicide], false); m_Header[team].AddColumn(LoadString("IDS_SCORE_PING"), nCol[eColumnPing], false); for (int i = 0; i < kMaxPlayers; i++) { tcs.rnBaseRect.Bottom() = m_sTextFont.m_nHeight; m_Columns[team][i].Create ( m_sTextFont,tcs); m_Columns[team][i].SetColor(m_cTextColor); m_Columns[team][i].AddColumn(L"<player name>", nCol[eColumnName], true); m_Columns[team][i].AddColumn(L"<Score>", nCol[eColumnScore], true); m_Columns[team][i].AddColumn(L"<Frags>", nCol[eColumnKill], true); m_Columns[team][i].AddColumn(L"<Deaths>", nCol[eColumnDeath], true); m_Columns[team][i].AddColumn(L"<Objective>", nCol[eColumnObjective], true); m_Columns[team][i].AddColumn(L"<Team Kills>", nCol[eColumnTK], true); m_Columns[team][i].AddColumn(L"<Suicides>", nCol[eColumnSuicide], true); m_Columns[team][i].AddColumn(L"<Ping>", nCol[eColumnPing], true); m_Columns[team][i].Show(false); } } cs.rnBaseRect.Right() = nCol[0]; cs.rnBaseRect.Bottom() = headerFont.m_nHeight; m_Server.Create(L"",headerFont,cs); m_Server.SetColor(m_cTextColor); cs.rnBaseRect.Right() = m_nFrameWidth - 16; cs.rnBaseRect.Bottom() = headerFont.m_nHeight; m_RoundInfo.Create(L"",headerFont,cs); m_RoundInfo.SetColor(m_cTextColor); m_RoundInfo.SetAlignment( kRight ); LTVector2n framePos = m_vBasePos; g_pInterfaceResMgr->ScaleScreenPos(framePos); framePos.x -= 8; framePos.y -= 4; m_SingleFrame.SetBasePos(framePos); LTVector2n pos = m_vBasePos; g_pInterfaceResMgr->ScaleScreenPos(pos); UpdateTeamPos(0,pos); m_bControlsInited = true; } }
void CHUDScores::Update() { if (m_nDraw <= 0) return; uint32 textCol = (m_bScreen ? m_nScreenTextColor : m_nTextColor); uint32 playerTextCol = (m_bScreen ? m_nScreenPlayerTextColor : m_nPlayerTextColor); float fScale = g_pInterfaceResMgr->GetXRatio(); if (fScale != m_fScale) { m_fScale = fScale; m_Server.SetScale(fScale); m_SingleFrame.SetScale(fScale); for (int team = 0; team < kNumTeams; team++) { m_Team[team].SetScale(fScale); m_Rounds[team].SetScale(fScale); m_Header[team].SetScale(fScale); m_Frame[team].SetScale(fScale); for (int i = 0; i < kMaxPlayers; i++) { m_Columns[team][i].SetScale(fScale); } } } if (IsTeamGameType()) { CUserProfile *pProfile = g_pProfileMgr->GetCurrentProfile(); for( uint8 team = 0; team < kNumTeams; ++team ) { CTeam* pTeam = CTeamMgr::Instance().GetTeam(team); if (!pTeam) continue; char szTmp[128]; sprintf(szTmp,"%s : %d",pTeam->GetName(),pTeam->GetScore()); m_Team[team].SetString(szTmp); sprintf(szTmp,"%s : %d", LoadTempString(IDS_ROUNDS), pTeam->GetRoundScore( )); m_Rounds[team].SetString(szTmp); m_Header[team].Show(LTTRUE); } } else { m_Team[0].SetString(""); m_Rounds[0].SetString(""); m_Header[1].Show(LTFALSE); } m_Server.SetColors(textCol,textCol,textCol); CClientInfoMgr *pCIMgr = g_pGameClientShell->GetInterfaceMgr( )->GetClientInfoMgr(); if (!pCIMgr) return; CLIENT_INFO* pCI = pCIMgr->GetFirstClient(); int nTotal = 0; int count[kNumTeams] = {0,0}; char szTmp[64] = ""; uint16 nHeight[kNumTeams]; nHeight[0] = m_Server.GetBaseHeight() + m_Header[0].GetBaseHeight() + m_Team[0].GetBaseHeight() + 24; nHeight[1] = m_Team[1].GetBaseHeight() + m_Header[1].GetBaseHeight() + 16; uint32 nLocalID = 0; g_pLTClient->GetLocalClientID (&nLocalID); while (pCI && (nTotal < kMaxPlayers)) { uint8 nTeam = 0; if (IsTeamGameType()) { nTeam = pCI->nTeamID; } int ndx = count[nTeam]; if (nTeam < kNumTeams) { sprintf( szTmp, "%s%s",pCI->sName.c_str( ), pCI->bIsAdmin ? "[*]" : "" ); m_Columns[nTeam][ndx].GetPolyString(0)->SetText( szTmp ); sprintf(szTmp,"%d",pCI->sScore.GetScore()); m_Columns[nTeam][ndx].GetPolyString(1)->SetText(szTmp); sprintf(szTmp,"%d",pCI->sScore.GetFrags()); m_Columns[nTeam][ndx].GetPolyString(2)->SetText(szTmp); sprintf(szTmp,"%d",pCI->sScore.GetTags()); m_Columns[nTeam][ndx].GetPolyString(3)->SetText(szTmp); sprintf(szTmp,"%d",pCI->nPing); m_Columns[nTeam][ndx].GetPolyString(4)->SetText(szTmp); if (nLocalID == pCI->nID) { m_Columns[nTeam][ndx].SetColors(playerTextCol,playerTextCol,playerTextCol); } else { m_Columns[nTeam][ndx].SetColors(textCol,textCol,textCol); } m_Columns[nTeam][ndx].Show(LTTRUE); nHeight[nTeam] += m_Columns[nTeam][ndx].GetBaseHeight(); } pCI = pCI->pNext; ++count[nTeam]; } for (int team = 0; team < kNumTeams; team++) { m_Team[team].SetColors(textCol,textCol,textCol); m_Rounds[team].SetColors(textCol,textCol,textCol); m_Header[team].SetColors(textCol,textCol,textCol); nHeight[team] += 16; m_Frame[team].SetSize(m_nFrameWidth,nHeight[team]); while (count[team] < kMaxPlayers) { m_Columns[team][count[team]].Show(LTFALSE); ++count[team]; } LTIntPt pos = m_BasePos; if (IsTeamGameType() && team > 0) { pos.y += nHeight[team-1] + 8; UpdateTeamPos(team,pos); } } m_SingleFrame.SetSize(m_nFrameWidth,nHeight[0]+8); }
void CHUDScores::Update() { if( !m_bInitialized ) return; if( !m_bDraw ) return; // uint32 textCol = (m_bScreen ? m_cScreenTextColor : m_cTextColor); // uint32 playerTextCol = (m_bScreen ? m_cScreenPlayerTextColor : m_cPlayerTextColor); //for the screen mode scoreboard, don't update the text once we've drawn it if (m_bScreen && !m_bFirstScreenUpdate) return; m_bFirstScreenUpdate = false; if (GameModeMgr::Instance( ).m_grbUseTeams) { for( uint8 nTeamNum = 0; nTeamNum < kNumTeams; ++nTeamNum ) { uint8 team; if (g_pInterfaceMgr->GetClientInfoMgr()->IsLocalTeam(nTeamNum)) team = 0; else team = 1; CTeam* pTeam = CTeamMgr::Instance().GetTeam(nTeamNum); if (!pTeam) continue; wchar_t wszTmp[128]; LTSNPrintF(wszTmp,LTARRAYSIZE(wszTmp),L"%s : %d",pTeam->GetName(),pTeam->GetScore()); m_Team[team].SetString(wszTmp); LTSNPrintF(wszTmp,LTARRAYSIZE(wszTmp),L"%s : %d", LoadString("IDS_ROUNDS"), pTeam->GetRoundScore( )); m_Rounds[team].SetString(wszTmp); m_Header[team].Show(true); } } else { m_Team[0].SetString(L""); m_Rounds[0].SetString(L""); m_Header[1].Show(false); } m_Server.SetColor(m_cTextColor); if ( !GameModeMgr::Instance( ).m_grwsSessionName.GetValue().empty()) { std::wstring wstr = GameModeMgr::Instance( ).m_grwsSessionName; if ( g_pClientConnectionMgr->IsConnectedToRemoteServer( )) { wstr += L" : "; wstr += MPA2W(g_pClientConnectionMgr->GetStartGameRequest( ).m_TCPAddress).c_str(); } m_Server.SetString(wstr.c_str()); } else { m_Server.SetString(L""); } // Update the round counter. m_RoundInfo.SetColor(m_cTextColor); wchar_t wszRound[32]; uint8 nCurrentRound = g_pClientConnectionMgr ? g_pClientConnectionMgr->GetCurrentRound() : 0; uint8 nNumRounds = GameModeMgr::Instance( ).m_grnNumRounds; FormatString( "HUD_SCORES_ROUNDINFO", wszRound, LTARRAYSIZE( wszRound ), nCurrentRound + 1, nNumRounds ); m_RoundInfo.SetString( wszRound ); CClientInfoMgr *pCIMgr = g_pGameClientShell->GetInterfaceMgr( )->GetClientInfoMgr(); if (!pCIMgr) return; CLIENT_INFO* pCI = pCIMgr->GetFirstClient(); int nTotal = 0; int count[kNumTeams] = {0,0}; wchar_t wszTmp[64] = L""; uint32 nHeight[kNumTeams]; nHeight[0] = m_Server.GetBaseHeight() + m_Header[0].GetBaseHeight() + m_Team[0].GetBaseHeight() + 24; nHeight[1] = m_Team[1].GetBaseHeight() + m_Header[1].GetBaseHeight() + 16; uint32 nLocalID = 0; g_pLTClient->GetLocalClientID (&nLocalID); while (pCI && (nTotal < kMaxPlayers)) { uint8 nTeam = 0; CCharacterFX* pCharacter = g_pGameClientShell->GetSFXMgr()->GetCharacterFromClientID(pCI->nID); if (GameModeMgr::Instance( ).m_grbUseTeams) { if (g_pInterfaceMgr->GetClientInfoMgr()->IsLocalTeam(pCI->nTeamID)) nTeam = 0; else nTeam = 1; } int ndx = count[nTeam]; if (nTeam < kNumTeams) { LTSNPrintF(wszTmp,LTARRAYSIZE(wszTmp),L"%s%s",pCI->sName.c_str( ), pCI->bIsAdmin ? L"[*]" : L"" ); m_Columns[nTeam][ndx].SetString( eColumnName, wszTmp ); LTSNPrintF(wszTmp,LTARRAYSIZE(wszTmp),L"%d",pCI->sScore.GetScore()); m_Columns[nTeam][ndx].SetString( eColumnScore, wszTmp ); LTSNPrintF(wszTmp,LTARRAYSIZE(wszTmp),L"%d",pCI->sScore.GetEventCount(CPlayerScore::eKill)); m_Columns[nTeam][ndx].SetString( eColumnKill, wszTmp ); LTSNPrintF(wszTmp,LTARRAYSIZE(wszTmp),L"%d",pCI->sScore.GetEventCount(CPlayerScore::eDeath)); m_Columns[nTeam][ndx].SetString( eColumnDeath, wszTmp ); LTSNPrintF(wszTmp,LTARRAYSIZE(wszTmp),L"%d",pCI->sScore.GetEventCount(CPlayerScore::eObjective)); m_Columns[nTeam][ndx].SetString( eColumnObjective, wszTmp ); if (GameModeMgr::Instance( ).m_grbUseTeams) { LTSNPrintF(wszTmp,LTARRAYSIZE(wszTmp),L"%d",pCI->sScore.GetEventCount(CPlayerScore::eTeamKill)); m_Columns[nTeam][ndx].SetString( eColumnTK, wszTmp ); m_Columns[nTeam][ndx].ShowColumn(eColumnTK, true); } else { m_Columns[nTeam][ndx].ShowColumn(eColumnTK, false); } LTSNPrintF(wszTmp,LTARRAYSIZE(wszTmp),L"%d",pCI->sScore.GetEventCount(CPlayerScore::eSuicide)); m_Columns[nTeam][ndx].SetString( eColumnSuicide, wszTmp ); LTSNPrintF(wszTmp,LTARRAYSIZE(wszTmp),L"%d",pCI->nPing); m_Columns[nTeam][ndx].SetString( eColumnPing, wszTmp ); if (nLocalID == pCI->nID) { if (!pCharacter || pCharacter->IsPlayerDead() || pCharacter->m_cs.bIsSpectating ) m_Columns[nTeam][ndx].SetColor(m_cPlayerDeadColor); else m_Columns[nTeam][ndx].SetColor(m_cPlayerTextColor); } else { if (!pCharacter || pCharacter->IsPlayerDead() || pCharacter->m_cs.bIsSpectating ) m_Columns[nTeam][ndx].SetColor(m_cDeadColor); else m_Columns[nTeam][ndx].SetColor(m_cTextColor); } m_Columns[nTeam][ndx].Show(true); nHeight[nTeam] += m_Columns[nTeam][ndx].GetBaseHeight(); } pCI = pCI->pNext; ++count[nTeam]; } for (uint8 team = 0; team < kNumTeams; team++) { m_Team[team].SetColor(m_cTextColor); m_Rounds[team].SetColor(m_cTextColor); m_Header[team].SetColor(m_cTextColor); nHeight[team] += 16; m_Frame[team].SetSize(LTVector2n(m_nFrameWidth,nHeight[team])); while (count[team] < kMaxPlayers) { m_Columns[team][count[team]].Show(false); ++count[team]; } LTVector2n pos = m_vBasePos; g_pInterfaceResMgr->ScaleScreenPos(pos); if (GameModeMgr::Instance( ).m_grbUseTeams && team > 0) { pos.y += nHeight[team-1] + 8; } UpdateTeamPos(team,pos); } m_SingleFrame.SetSize(LTVector2n(m_nFrameWidth,nHeight[0]+8)); }