FF Diff Viewer

Comparing 2006 Base SDK to Fortress Forever 2.46

cl_dll/game_controls/SpectatorGUI.cpp

343536373839
#include #include #include // memdbgon must be the last include file in a .cpp file!!! #include "tier0/memdbgon.h"
343536373839404142
#include #include #include #include "c_ff_team.h" #include "ff_gamerules.h" #include "ff_utils.h" // memdbgon must be the last include file in a .cpp file!!! #include "tier0/memdbgon.h"
444546474849
// void DuckMessage(const char *str); // from vgui_teamfortressviewport.cpp ConVar spec_scoreboard( "spec_scoreboard", "0", FCVAR_CLIENTDLL | FCVAR_ARCHIVE ); CSpectatorGUI *g_pSpectatorGUI = NULL;
47484950515253
// void DuckMessage(const char *str); // from vgui_teamfortressviewport.cpp extern ConVar cl_drawhud; ConVar spec_scoreboard( "spec_scoreboard", "0", FCVAR_CLIENTDLL | FCVAR_ARCHIVE ); CSpectatorGUI *g_pSpectatorGUI = NULL;
215216217218219220221222223224
void CSpectatorMenu::ShowPanel(bool bShow) { if ( BaseClass::IsVisible() == bShow ) return; if ( bShow ) { Activate(); SetMouseInputEnabled( true );
219220221222223224225226227228
void CSpectatorMenu::ShowPanel(bool bShow) { //if ( IsVisible() == bShow ) // return; if ( bShow && cl_drawhud.GetBool() ) { Activate(); SetMouseInputEnabled( true );
231232233234235236237238239240241242243244245246247248
SetKeyBoardInputEnabled( false ); } bool bIsEnabled = true; if ( engine->IsHLTV() && HLTVCamera()->IsPVSLocked() ) { // when wattching HLTV with a locked PVS, some elements are disabled bIsEnabled = false; } m_pLeftButton->SetVisible( bIsEnabled ); m_pRightButton->SetVisible( bIsEnabled ); m_pPlayerList->SetVisible( bIsEnabled ); m_pViewOptions->SetVisible( bIsEnabled ); }
235236237238239240241242243244245246247248249250251252253
SetKeyBoardInputEnabled( false ); } //bool bIsEnabled = true; if ( engine->IsHLTV() && HLTVCamera()->IsPVSLocked() || !cl_drawhud.GetBool() ) { // when wattching HLTV with a locked PVS, some elements are disabled //bIsEnabled = false; bShow = false; } m_pLeftButton->SetVisible( bShow ); // bIsEnabled ); m_pRightButton->SetVisible( bShow ); // bIsEnabled ); m_pPlayerList->SetVisible( bShow ); // bIsEnabled ); m_pViewOptions->SetVisible( bShow ); // bIsEnabled ); }
361362363364365366367368369370371
m_pBottomBarBlank->SetSize( w, h - y ); } //----------------------------------------------------------------------------- // Purpose: checks spec_scoreboard cvar to see if the scoreboard should be displayed //----------------------------------------------------------------------------- void CSpectatorGUI::OnThink() { BaseClass::OnThink(); if ( IsVisible() )
366367368369370371372373374375376377378379380381382383384385386387
m_pBottomBarBlank->SetSize( w, h - y ); } bool CSpectatorGUI::IsVisible() { if ( !cl_drawhud.GetBool() ) return false; return BaseClass::IsVisible(); } //----------------------------------------------------------------------------- // Purpose: checks spec_scoreboard cvar to see if the scoreboard should be displayed //----------------------------------------------------------------------------- void CSpectatorGUI::OnThink() { if ( !cl_drawhud.GetBool() ) return; BaseClass::OnThink(); if ( IsVisible() )
454455456457458459460461462463
void CSpectatorGUI::Update() { int wide, tall; int bx, by, bwide, btall; GetHudSize(wide, tall); m_pTopBar->GetBounds( bx, by, bwide, btall ); IGameResources *gr = GameResources(); int specmode = GetSpectatorMode();
470471472473474475476477
void CSpectatorGUI::Update() { int wide, tall; GetHudSize(wide, tall); IGameResources *gr = GameResources(); int specmode = GetSpectatorMode();
467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496
if ( overview && overview->IsVisible() ) { int mx, my, mwide, mtall; VPANEL p = overview->GetVPanel(); vgui::ipanel()->GetPos( p, mx, my ); vgui::ipanel()->GetSize( p, mwide, mtall ); if ( my < btall ) { // reduce to bar m_pTopBar->SetSize( wide - (mx + mwide), btall ); m_pTopBar->SetPos( (mx + mwide), 0 ); } else { // full top bar m_pTopBar->SetSize( wide , btall ); m_pTopBar->SetPos( 0, 0 ); } } else { // full top bar m_pTopBar->SetSize( wide , btall ); // change width, keep height m_pTopBar->SetPos( 0, 0 ); } m_pPlayerLabel->SetVisible( ShouldShowPlayerLabel(specmode) );
481482483484485486487488489
if ( overview && overview->IsVisible() ) { } else { } m_pPlayerLabel->SetVisible( ShouldShowPlayerLabel(specmode) );
503504505506507508509510511512513514515516517518
m_pPlayerLabel->SetFgColor( c ); wchar_t playerText[ 80 ], playerName[ 64 ], health[ 10 ]; wcscpy( playerText, L"Unable to find #Spec_PlayerItem*" ); memset( playerName, 0x0, sizeof( playerName ) * sizeof( wchar_t ) ); localize()->ConvertANSIToUnicode( UTIL_SafeName(gr->GetPlayerName( playernum )), playerName, sizeof( playerName ) ); int iHealth = gr->GetHealth( playernum ); if ( iHealth > 0 && gr->IsAlive(playernum) ) { _snwprintf( health, sizeof( health ), L"%i", iHealth ); localize()->ConstructString( playerText, sizeof( playerText ), localize()->Find( "#Spec_PlayerItem_Team" ), 2, playerName, health ); } else {
496497498499500501502503504505506507508509510511512513514
m_pPlayerLabel->SetFgColor( c ); wchar_t playerText[ 80 ], playerName[ 64 ], health[ 10 ], armor[ 10 ]; wcscpy( playerText, L"Unable to find #Spec_PlayerItem*" ); memset( playerName, 0x0, sizeof( playerName ) ); localize()->ConvertANSIToUnicode( UTIL_SafeName(gr->GetPlayerName( playernum )), playerName, sizeof( playerName ) ); int iHealth = gr->GetHealth( playernum ); int iArmor = gr->GetArmor( playernum ); if ( iHealth > 0 && gr->IsAlive(playernum) ) { _snwprintf( health, sizeof( health ), L"%i", iHealth ); _snwprintf( armor, sizeof( armor ), L"%i", iArmor ); // TODO: Modify #Spec_PlayerItem_team to include a %s for armor localize()->ConstructString( playerText, sizeof( playerText ), localize()->Find( "#Spec_PlayerItem_Team" ), 3, playerName, health, armor ); } else {
531532533534535536537538
wchar_t szTitleLabel[1024]; char tempstr[128]; if ( engine->IsHLTV() ) { // set spectator number and HLTV title Q_snprintf(tempstr,sizeof(tempstr),"Spectators : %d", HLTVCamera()->GetNumSpectators() ); localize()->ConvertANSIToUnicode(tempstr,szEtxraInfo,sizeof(szEtxraInfo));
527528529530531532533534535536537
wchar_t szTitleLabel[1024]; char tempstr[128]; if ( engine->IsHLTV() && !engine->IsPlayingDemo() ) { // show top bar m_pTopBar->SetVisible(true); // set spectator number and HLTV title Q_snprintf(tempstr,sizeof(tempstr),"Spectators : %d", HLTVCamera()->GetNumSpectators() ); localize()->ConvertANSIToUnicode(tempstr,szEtxraInfo,sizeof(szEtxraInfo));
542543544545546547548549550551552553554
} else { // otherwise show map name Q_FileBase( engine->GetLevelName(), tempstr, sizeof(tempstr) ); wchar_t wMapName[64]; localize()->ConvertANSIToUnicode(tempstr,wMapName,sizeof(wMapName)); localize()->ConstructString( szEtxraInfo,sizeof( szEtxraInfo ), localize()->Find("#Spec_Map" ),1, wMapName ); localize()->ConvertANSIToUnicode( "" ,szTitleLabel,sizeof(szTitleLabel)); }
541542543544545546547548549550551552553554555556557558
} else { // hide top bar m_pTopBar->SetVisible(false); /*// otherwise show map name Q_FileBase( engine->GetLevelName(), tempstr, sizeof(tempstr) ); wchar_t wMapName[64]; localize()->ConvertANSIToUnicode(tempstr,wMapName,sizeof(wMapName)); localize()->ConstructString( szEtxraInfo,sizeof( szEtxraInfo ), localize()->Find("#Spec_Map" ),1, wMapName ); */ localize()->ConvertANSIToUnicode( "" ,szEtxraInfo,sizeof(szEtxraInfo)); localize()->ConvertANSIToUnicode( "" ,szTitleLabel,sizeof(szTitleLabel)); }
556557558559560561562
SetLabelText("titlelabel", szTitleLabel ); } //----------------------------------------------------------------------------- // Purpose: Resets the list of players //-----------------------------------------------------------------------------
560561562563564565
SetLabelText("titlelabel", szTitleLabel ); } //----------------------------------------------------------------------------- // Purpose: Resets the list of players //-----------------------------------------------------------------------------
596597598599600601602
const char * teamname = gr->GetTeamName( gr->GetTeam(iPlayerIndex) ); if ( teamname ) { Q_snprintf( localizeTeamName, sizeof( localizeTeamName ), "#%s", teamname ); team=localize()->Find( localizeTeamName ); if ( !team )
599600601602603604605
const char * teamname = gr->GetTeamName( gr->GetTeam(iPlayerIndex) ); if ( teamname ) { Q_snprintf( localizeTeamName, sizeof( localizeTeamName ), "%s", teamname ); team=localize()->Find( localizeTeamName ); if ( !team )
605606607608609610611
team = teamText; } localize()->ConstructString( playerText, sizeof( playerText ), localize()->Find( "#Spec_PlayerItem_Team" ), 2, playerName, team ); } else {
608609610611612613614615616617618619620621622623624625626627628
team = teamText; } wchar_t classText[ 64 ], *pwszClass; char localizeClassName[64]; const char *classname = Class_IntToResourceString( gr->GetClass( iPlayerIndex ) ); Q_snprintf( localizeClassName, sizeof( localizeClassName ), "%s", classname ); pwszClass=localize()->Find( localizeClassName ); if ( !pwszClass ) { localize()->ConvertANSIToUnicode( classname , classText, sizeof( classText ) ); pwszClass = classText; } localize()->ConstructString( playerText, sizeof( playerText ), localize()->Find( "#Spec_PlayerItem_Team" ), 3, playerName, team, pwszClass ); } else {
632633634635636637638639
} } void CSpectatorMenu::OnThink() { BaseClass::OnThink(); IGameResources *gr = GameResources();
649650651652653654655656657658659660661662663664665666667
} } bool CSpectatorMenu::IsVisible() { if ( !cl_drawhud.GetBool() ) return false; return BaseClass::IsVisible(); } void CSpectatorMenu::OnThink() { if ( !cl_drawhud.GetBool() ) return; BaseClass::OnThink(); IGameResources *gr = GameResources();
664665666667668669670671672673674675676677678679680681682683684685686
} } //----------------------------------------------------------------------------- // Purpose: Updates the timer label if one exists //----------------------------------------------------------------------------- void CSpectatorGUI::UpdateTimer() { wchar_t szText[ 63 ]; int timer = 0; _snwprintf ( szText, sizeof( szText ), L"%d:%02d\n", (timer / 60), (timer % 60) ); szText[63] = 0; SetLabelText("timerlabel", szText ); } static void ForwardSpecCmdToServer() { if ( engine->IsPlayingDemo() )
692693694695696697
} } static void ForwardSpecCmdToServer() { if ( engine->IsPlayingDemo() )
813814815816817
} }
824825826827828829830831832833834835836837838839840841842843844845846847848849850851
} } CON_COMMAND( spec_item, "Spectate item by name" ) { C_BasePlayer *pPlayer = C_BasePlayer::GetLocalPlayer(); if ( !pPlayer || !pPlayer->IsObserver() ) return; if ( engine->Cmd_Argc() != 2 ) return; if ( engine->IsHLTV() ) { // we can only switch primary spectator targets is PVS isnt locked by auto-director if ( !HLTVCamera()->IsPVSLocked() ) { //HLTVCamera()->SpecNamedPlayer( engine->Cmd_Argv(1) ); } } else { ForwardSpecCmdToServer(); } }