Skip to content

Commit

Permalink
add friends in lobby to lobby list
Browse files Browse the repository at this point in the history
  • Loading branch information
BenLubar committed Oct 30, 2023
1 parent f364d76 commit f33eebc
Show file tree
Hide file tree
Showing 2 changed files with 75 additions and 3 deletions.
77 changes: 74 additions & 3 deletions src/game/client/swarm/gameui/swarm/vfoundgames.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -656,6 +656,7 @@ FoundGameListItem::FoundGameListItem( vgui::Panel *parent, const char *panelName

SetPaintBackgroundEnabled( true );

m_iBaseTall = 10;
m_sweep = 0;
m_bSelected = false;
m_bHasMouseover = false;
Expand Down Expand Up @@ -856,8 +857,7 @@ void FoundGameListItem::SetGamePlayerCount( int current, int max )
//=============================================================================
void FoundGameListItem::DrawListItemLabel( vgui::Label* label, bool bSmallFont, bool bEastAligned /* = false */ )
{
int panelWide, panelTall;
GetSize( panelWide, panelTall );
int panelTall = m_iBaseTall;

if ( label )
{
Expand Down Expand Up @@ -990,6 +990,49 @@ void FoundGameListItem::PaintBackground()
{
DrawListItemLabel( m_pLblNotJoinable, true );
}

if ( m_FullInfo.m_Friends.Count() )
{
int wide = GetWide();
int iFriendLabelX = wide;
int iFriendLabelY = m_iBaseTall - YRES( 12 );
int iFriendLabelXOffset, discard;
m_pLblPlayerGamerTag->GetPos( iFriendLabelXOffset, discard );
Color FriendColor = HasFocus() || HasMouseover() || IsSelected() ? Color( 255, 255, 255, 255 ) : Color( 100, 100, 100, 255 );
if ( ISteamFriends *pSteamFriends = SteamFriends() )
{
vgui::surface()->DrawSetTextFont( m_hTextFont );
vgui::surface()->DrawSetTextColor( FriendColor );

FOR_EACH_VEC( m_FullInfo.m_Friends, i )
{
wchar_t wszFriendName[k_cwchPersonaNameMax];
V_UTF8ToUnicode( pSteamFriends->GetFriendPersonaName( m_FullInfo.m_Friends[i] ), wszFriendName, sizeof( wszFriendName ) );

int w, t;
vgui::surface()->GetTextSize( m_hTextFont, wszFriendName, w, t );
int iFriendLabelWide = YRES( 16 ) + w;
if ( iFriendLabelX + iFriendLabelWide > wide )
{
iFriendLabelY += YRES( 10 );
iFriendLabelX = iFriendLabelXOffset;
}

vgui::IImage *pAvatarImage = CUIGameData::Get()->GetAvatarImage( m_FullInfo.m_Friends[i].ConvertToUint64() );
if ( pAvatarImage )
{
pAvatarImage->SetPos( iFriendLabelX + YRES( 2 ), iFriendLabelY );
pAvatarImage->SetSize( YRES( 10 ), YRES( 10 ) );
pAvatarImage->SetColor( FriendColor );
pAvatarImage->Paint();
}

vgui::surface()->DrawSetTextPos( iFriendLabelX + YRES( 14 ), iFriendLabelY );
vgui::surface()->DrawUnicodeString( wszFriendName );
iFriendLabelX += iFriendLabelWide;
}
}
}
}

//=============================================================================
Expand Down Expand Up @@ -1097,7 +1140,9 @@ void FoundGameListItem::ApplySchemeSettings( IScheme *pScheme )
BaseClass::ApplySchemeSettings( pScheme );

LoadControlSettings( CFmtStr( "Resource/UI/BaseModUI/%s.res", GetName() ) );


m_iBaseTall = GetTall();

//////////////////////////////////////////////////////
// !!!!! THE ENABLED STATES CONTROL VISIBILITY !!!! //
//////////////////////////////////////////////////////
Expand Down Expand Up @@ -1177,6 +1222,32 @@ void FoundGameListItem::PerformLayout()
Assert( panel );
panel->SetMouseInputEnabled( false );
}

int wide = GetWide();
int iFriendLabelX = wide;
int iFriendLabelTall = m_FullInfo.m_Friends.Count() ? YRES( 2 ) : 0;
int iFriendLabelXOffset, discard;
m_pLblPlayerGamerTag->GetPos( iFriendLabelXOffset, discard );
if ( ISteamFriends *pSteamFriends = SteamFriends() )
{
FOR_EACH_VEC( m_FullInfo.m_Friends, i )
{
wchar_t wszFriendName[k_cwchPersonaNameMax];
V_UTF8ToUnicode( pSteamFriends->GetFriendPersonaName( m_FullInfo.m_Friends[i] ), wszFriendName, sizeof( wszFriendName ) );

int w, t;
vgui::surface()->GetTextSize( m_hTextFont, wszFriendName, w, t );
int iFriendLabelWide = YRES( 16 ) + w;
if ( iFriendLabelX + iFriendLabelWide > wide )
{
iFriendLabelTall += YRES( 10 );
iFriendLabelX = iFriendLabelXOffset;
}
iFriendLabelX += iFriendLabelWide;
}
}

SetTall( m_iBaseTall + iFriendLabelTall );
}

//=============================================================================
Expand Down
1 change: 1 addition & 0 deletions src/game/client/swarm/gameui/swarm/vfoundgames.h
Original file line number Diff line number Diff line change
Expand Up @@ -181,6 +181,7 @@ class FoundGameListItem : public vgui::EditablePanel, public IBaseModFrameListen
vgui::HFont m_hSmallTextBlurFont;

CPanelAnimationVar( Color, m_SelectedColor, "selected_color", "255 0 0 128" );
int m_iBaseTall;
bool m_sweep : 1;
bool m_bSelected : 1;
bool m_bHasMouseover : 1;
Expand Down

0 comments on commit f33eebc

Please sign in to comment.