Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 24 additions & 3 deletions src/game/client/tf/vgui/mute_player_dialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,20 @@ CMutePlayerDialog::~CMutePlayerDialog()
{
}

//-----------------------------------------------------------------------------
// Purpose: Sort function for the player time column.
//-----------------------------------------------------------------------------
static int __cdecl SortPlayersByPlayTime( vgui::ListPanel *pPanel, const ListPanelItem &item1, const ListPanelItem &item2 )
{
int time1 = item1.kv->GetInt( "time_int", 0 );
int time2 = item2.kv->GetInt( "time_int", 0 );
if ( time1 < time2 )
return -1;
if ( time1 > time2 )
return 1;
return 0;
}

//-----------------------------------------------------------------------------
// Purpose:
//-----------------------------------------------------------------------------
Expand Down Expand Up @@ -72,6 +86,7 @@ void CMutePlayerDialog::ApplySchemeSettings( vgui::IScheme *pScheme )
m_pPlayerList->AddColumnHeader( 2, "name", "#TF_Scoreboard_Name", m_iNameWidth + m_nExtraSpace );
m_pPlayerList->AddColumnHeader( 3, "score", "#TF_Scoreboard_Score", m_iScoreWidth );
m_pPlayerList->AddColumnHeader( 4, "time", "#TF_Connected", m_iTimeWidth );
m_pPlayerList->SetSortFunc( 4, SortPlayersByPlayTime );
m_pPlayerList->AddColumnHeader( 5, "status", "", m_iStatusWidth );

// doesn't make sense to sort with the images
Expand Down Expand Up @@ -155,7 +170,10 @@ void CMutePlayerDialog::Activate()

// The medal column is just a place holder for the images that are displayed later
pKeyValues->SetInt( "medal", 0 );
pKeyValues->SetString( "time", FormatSeconds( gpGlobals->curtime - g_TF_PR->GetConnectTime( playerIndex ) ) );

int nTime = gpGlobals->curtime - g_TF_PR->GetConnectTime( playerIndex );
pKeyValues->SetInt( "time_int", nTime );
pKeyValues->SetString( "time", FormatSeconds( nTime ) );

Color clr = g_PR->GetTeamColor( nTeam );
pKeyValues->SetColor( "cellcolor", clr );
Expand Down Expand Up @@ -185,7 +203,8 @@ void CMutePlayerDialog::RefreshPlayerStatus()
{
for ( int i = 0; i <= m_pPlayerList->GetItemCount(); i++ )
{
KeyValues *data = m_pPlayerList->GetItem( i );
int itemID = m_pPlayerList->GetItemIDFromRow( i );
KeyValues *data = m_pPlayerList->GetItem( itemID );
if ( !data )
continue;

Expand All @@ -197,6 +216,7 @@ void CMutePlayerDialog::RefreshPlayerStatus()
{
// disconnected
data->SetString( "status", "#TF_Disconnected" );
m_pPlayerList->ApplyItemChanges( itemID );
continue;
}

Expand All @@ -210,8 +230,9 @@ void CMutePlayerDialog::RefreshPlayerStatus()
{
data->SetString( "status", "" );
}

m_pPlayerList->ApplyItemChanges( itemID );
}
m_pPlayerList->RereadAllItems();
}

//-----------------------------------------------------------------------------
Expand Down