2010-11-20 10:37:14 +00:00
/* (c) Magnus Auvinen. See licence.txt in the root of the distribution for more information. */
/* If you are missing that file, acquire a complete release at teeworlds.com. */
2022-05-23 18:16:18 +00:00
# include <base/log.h>
# include <engine/favorites.h>
2011-03-23 12:06:35 +00:00
# include <engine/friends.h>
2011-03-18 16:59:48 +00:00
# include <engine/keys.h>
2010-05-29 07:25:38 +00:00
# include <engine/serverbrowser.h>
2020-09-26 19:41:58 +00:00
# include <engine/shared/config.h>
2022-12-09 15:15:19 +00:00
# include <engine/shared/localization.h>
2010-05-29 07:25:38 +00:00
# include <engine/textrender.h>
2023-01-07 08:20:25 +00:00
# include <game/client/animstate.h>
2020-09-26 19:41:58 +00:00
# include <game/client/components/console.h>
# include <game/client/components/countryflags.h>
2023-01-05 11:21:10 +00:00
# include <game/client/gameclient.h>
2011-03-18 16:59:48 +00:00
# include <game/client/render.h>
# include <game/client/ui.h>
2023-01-05 11:21:10 +00:00
# include <game/client/ui_listbox.h>
2020-09-26 19:41:58 +00:00
# include <game/localization.h>
2011-03-18 16:59:48 +00:00
# include "menus.h"
2022-06-30 22:36:32 +00:00
static const int gs_OffsetColFlagLock = 2 ;
static const int gs_OffsetColFav = gs_OffsetColFlagLock + 3 ;
static const int gs_OffsetColOff = gs_OffsetColFav + 3 ;
static const int gs_OffsetColName = gs_OffsetColOff + 3 ;
static const int gs_OffsetColGameType = gs_OffsetColName + 3 ;
static const int gs_OffsetColMap = gs_OffsetColGameType + 3 ;
static const int gs_OffsetColPlayers = gs_OffsetColMap + 3 ;
static const int gs_OffsetColPing = gs_OffsetColPlayers + 3 ;
static const int gs_OffsetColVersion = gs_OffsetColPing + 3 ;
2020-10-12 10:29:47 +00:00
2018-07-11 20:46:04 +00:00
void FormatServerbrowserPing ( char * pBuffer , int BufferLength , const CServerInfo * pInfo )
{
if ( ! pInfo - > m_LatencyIsEstimated )
{
str_format ( pBuffer , BufferLength , " %d " , pInfo - > m_Latency ) ;
return ;
}
static const char * LOCATION_NAMES [ CServerInfo : : NUM_LOCS ] = {
" " , // LOC_UNKNOWN
2022-12-09 15:15:19 +00:00
Localizable ( " AFR " ) , // LOC_AFRICA
Localizable ( " ASI " ) , // LOC_ASIA
Localizable ( " AUS " ) , // LOC_AUSTRALIA
Localizable ( " EUR " ) , // LOC_EUROPE
Localizable ( " NA " ) , // LOC_NORTH_AMERICA
Localizable ( " SA " ) , // LOC_SOUTH_AMERICA
Localizable ( " CHN " ) , // LOC_CHINA
2018-07-11 20:46:04 +00:00
} ;
dbg_assert ( 0 < = pInfo - > m_Location & & pInfo - > m_Location < CServerInfo : : NUM_LOCS , " location out of range " ) ;
2022-10-27 19:28:49 +00:00
str_copy ( pBuffer , Localize ( LOCATION_NAMES [ pInfo - > m_Location ] ) , BufferLength ) ;
2018-07-11 20:46:04 +00:00
}
2010-05-29 07:25:38 +00:00
void CMenus : : RenderServerbrowserServerList ( CUIRect View )
{
CUIRect Headers ;
CUIRect Status ;
2008-08-27 15:48:50 +00:00
2010-05-29 07:25:38 +00:00
View . HSplitTop ( ms_ListheaderHeight , & Headers , & View ) ;
2022-12-18 22:21:35 +00:00
View . HSplitBottom ( 65.0f , & View , & Status ) ;
2008-08-27 15:48:50 +00:00
// split of the scrollbar
2022-08-07 16:12:07 +00:00
Headers . Draw ( ColorRGBA ( 1 , 1 , 1 , 0.25f ) , IGraphics : : CORNER_T , 5.0f ) ;
2010-05-29 07:25:38 +00:00
Headers . VSplitRight ( 20.0f , & Headers , 0 ) ;
struct CColumn
2008-08-27 15:48:50 +00:00
{
2011-02-12 10:40:36 +00:00
int m_ID ;
2010-05-29 07:25:38 +00:00
int m_Sort ;
CLocConstString m_Caption ;
int m_Direction ;
float m_Width ;
CUIRect m_Rect ;
CUIRect m_Spacer ;
2008-08-27 15:48:50 +00:00
} ;
2010-05-29 07:25:38 +00:00
2008-08-27 15:48:50 +00:00
enum
{
2020-09-26 19:41:58 +00:00
COL_FLAG_LOCK = 0 ,
2008-09-03 20:03:01 +00:00
COL_FLAG_FAV ,
2019-03-19 06:46:48 +00:00
COL_FLAG_OFFICIAL ,
2008-08-27 15:48:50 +00:00
COL_NAME ,
COL_GAMETYPE ,
COL_MAP ,
COL_PLAYERS ,
COL_PING ,
COL_VERSION ,
} ;
2010-05-29 07:25:38 +00:00
2016-04-30 15:59:58 +00:00
CColumn s_aCols [ ] = {
2022-10-30 12:05:44 +00:00
{ - 1 , - 1 , " " , - 1 , 2.0f , { 0 } , { 0 } } ,
{ COL_FLAG_LOCK , - 1 , " " , - 1 , 14.0f , { 0 } , { 0 } } ,
{ COL_FLAG_FAV , - 1 , " " , - 1 , 14.0f , { 0 } , { 0 } } ,
{ COL_FLAG_OFFICIAL , - 1 , " " , - 1 , 14.0f , { 0 } , { 0 } } ,
{ COL_NAME , IServerBrowser : : SORT_NAME , " Name " , 0 , 50.0f , { 0 } , { 0 } } , // Localize - these strings are localized within CLocConstString
2022-12-09 15:15:19 +00:00
{ COL_GAMETYPE , IServerBrowser : : SORT_GAMETYPE , Localizable ( " Type " ) , 1 , 50.0f , { 0 } , { 0 } } ,
2022-10-30 12:05:44 +00:00
{ COL_MAP , IServerBrowser : : SORT_MAP , " Map " , 1 , 120.0f + ( Headers . w - 480 ) / 8 , { 0 } , { 0 } } ,
{ COL_PLAYERS , IServerBrowser : : SORT_NUMPLAYERS , " Players " , 1 , 85.0f , { 0 } , { 0 } } ,
{ - 1 , - 1 , " " , 1 , 10.0f , { 0 } , { 0 } } ,
{ COL_PING , IServerBrowser : : SORT_PING , " Ping " , 1 , 40.0f , { 0 } , { 0 } } ,
2008-08-27 15:48:50 +00:00
} ;
2010-05-29 07:25:38 +00:00
2022-03-30 13:16:19 +00:00
int NumCols = std : : size ( s_aCols ) ;
2010-05-29 07:25:38 +00:00
2008-08-27 15:48:50 +00:00
// do layout
2010-05-29 07:25:38 +00:00
for ( int i = 0 ; i < NumCols ; i + + )
2008-08-27 15:48:50 +00:00
{
2010-05-29 07:25:38 +00:00
if ( s_aCols [ i ] . m_Direction = = - 1 )
2008-08-27 15:48:50 +00:00
{
2010-05-29 07:25:38 +00:00
Headers . VSplitLeft ( s_aCols [ i ] . m_Width , & s_aCols [ i ] . m_Rect , & Headers ) ;
2020-09-26 19:41:58 +00:00
if ( i + 1 < NumCols )
2008-08-27 15:48:50 +00:00
{
2010-05-29 07:25:38 +00:00
Headers . VSplitLeft ( 2 , & s_aCols [ i ] . m_Spacer , & Headers ) ;
2008-08-27 15:48:50 +00:00
}
}
}
2010-05-29 07:25:38 +00:00
2020-09-26 19:41:58 +00:00
for ( int i = NumCols - 1 ; i > = 0 ; i - - )
2008-08-27 15:48:50 +00:00
{
2010-05-29 07:25:38 +00:00
if ( s_aCols [ i ] . m_Direction = = 1 )
2008-08-27 15:48:50 +00:00
{
2010-05-29 07:25:38 +00:00
Headers . VSplitRight ( s_aCols [ i ] . m_Width , & Headers , & s_aCols [ i ] . m_Rect ) ;
Headers . VSplitRight ( 2 , & Headers , & s_aCols [ i ] . m_Spacer ) ;
2008-08-27 15:48:50 +00:00
}
}
2010-05-29 07:25:38 +00:00
for ( int i = 0 ; i < NumCols ; i + + )
2008-08-27 15:48:50 +00:00
{
2010-05-29 07:25:38 +00:00
if ( s_aCols [ i ] . m_Direction = = 0 )
s_aCols [ i ] . m_Rect = Headers ;
2008-08-27 15:48:50 +00:00
}
2010-05-29 07:25:38 +00:00
2020-08-24 21:23:37 +00:00
const bool PlayersOrPing = ( g_Config . m_BrSort = = IServerBrowser : : SORT_NUMPLAYERS | | g_Config . m_BrSort = = IServerBrowser : : SORT_PING ) ;
2008-08-27 15:48:50 +00:00
// do headers
2010-05-29 07:25:38 +00:00
for ( int i = 0 ; i < NumCols ; i + + )
2008-08-27 15:48:50 +00:00
{
2020-08-24 21:23:37 +00:00
int Checked = g_Config . m_BrSort = = s_aCols [ i ] . m_Sort ;
if ( PlayersOrPing & & g_Config . m_BrSortOrder = = 2 & & ( s_aCols [ i ] . m_Sort = = IServerBrowser : : SORT_NUMPLAYERS | | s_aCols [ i ] . m_Sort = = IServerBrowser : : SORT_PING ) )
Checked = 2 ;
2020-09-17 19:54:22 +00:00
if ( DoButton_GridHeader ( s_aCols [ i ] . m_Caption , Localize ( s_aCols [ i ] . m_Caption ) , Checked , & s_aCols [ i ] . m_Rect ) )
2008-08-27 15:48:50 +00:00
{
2010-05-29 07:25:38 +00:00
if ( s_aCols [ i ] . m_Sort ! = - 1 )
2008-08-27 15:48:50 +00:00
{
2010-05-29 07:25:38 +00:00
if ( g_Config . m_BrSort = = s_aCols [ i ] . m_Sort )
2020-08-24 21:23:37 +00:00
{
if ( PlayersOrPing )
2020-09-26 19:41:58 +00:00
g_Config . m_BrSortOrder = ( g_Config . m_BrSortOrder + 1 ) % 3 ;
2020-08-24 21:23:37 +00:00
else
2020-09-26 19:41:58 +00:00
g_Config . m_BrSortOrder = ( g_Config . m_BrSortOrder + 1 ) % 2 ;
2020-08-24 21:23:37 +00:00
}
2008-08-27 15:48:50 +00:00
else
2010-05-29 07:25:38 +00:00
g_Config . m_BrSortOrder = 0 ;
g_Config . m_BrSort = s_aCols [ i ] . m_Sort ;
2008-08-27 15:48:50 +00:00
}
}
}
2010-05-29 07:25:38 +00:00
2022-08-07 16:12:07 +00:00
View . Draw ( ColorRGBA ( 0 , 0 , 0 , 0.15f ) , 0 , 0 ) ;
2010-05-29 07:25:38 +00:00
int NumServers = ServerBrowser ( ) - > NumSortedServers ( ) ;
2009-01-21 20:39:48 +00:00
// display important messages in the middle of the screen so no
// users misses it
{
2010-05-29 07:25:38 +00:00
CUIRect MsgBox = View ;
2021-07-08 17:18:01 +00:00
if ( ! ServerBrowser ( ) - > NumServers ( ) & & ServerBrowser ( ) - > IsGettingServerlist ( ) )
2022-06-12 08:34:09 +00:00
UI ( ) - > DoLabel ( & MsgBox , Localize ( " Getting server list from master server " ) , 16.0f , TEXTALIGN_CENTER ) ;
2010-05-29 07:25:38 +00:00
else if ( ! ServerBrowser ( ) - > NumServers ( ) )
2022-06-12 08:34:09 +00:00
UI ( ) - > DoLabel ( & MsgBox , Localize ( " No servers found " ) , 16.0f , TEXTALIGN_CENTER ) ;
2010-05-29 07:25:38 +00:00
else if ( ServerBrowser ( ) - > NumServers ( ) & & ! NumServers )
2022-06-12 08:34:09 +00:00
UI ( ) - > DoLabel ( & MsgBox , Localize ( " No servers match your filter criteria " ) , 16.0f , TEXTALIGN_CENTER ) ;
2009-01-21 20:39:48 +00:00
}
2008-09-07 21:13:24 +00:00
2022-08-21 11:17:09 +00:00
if ( UI ( ) - > ConsumeHotkey ( CUI : : HOTKEY_TAB ) )
2015-06-28 13:43:34 +00:00
{
2022-11-14 21:50:59 +00:00
const int Direction = Input ( ) - > ShiftIsPressed ( ) ? - 1 : 1 ;
2022-08-21 11:17:09 +00:00
g_Config . m_UiToolboxPage = ( g_Config . m_UiToolboxPage + 3 + Direction ) % 3 ;
2015-06-28 13:43:34 +00:00
}
2020-08-16 17:32:46 +00:00
2023-01-05 11:21:10 +00:00
static CListBox s_ListBox ;
s_ListBox . DoStart ( ms_ListheaderHeight , NumServers , 1 , 3 , m_SelectedIndex , & View , false ) ;
2010-05-29 07:25:38 +00:00
int NumPlayers = 0 ;
2023-01-05 11:21:10 +00:00
static int s_PrevSelectedIndex = - 1 ;
if ( s_PrevSelectedIndex ! = m_SelectedIndex )
{
s_ListBox . ScrollToSelected ( ) ;
s_PrevSelectedIndex = m_SelectedIndex ;
}
2010-05-29 07:25:38 +00:00
m_SelectedIndex = - 1 ;
2011-06-26 15:10:13 +00:00
// reset friend counter
2022-06-11 19:38:18 +00:00
for ( auto & Friend : m_vFriends )
2022-05-23 19:15:04 +00:00
Friend . m_NumFound = 0 ;
2010-05-29 07:25:38 +00:00
2022-03-19 17:50:33 +00:00
auto RenderBrowserIcons = [ this ] ( CUIElement : : SUIElementRect & UIRect , CUIRect * pRect , const ColorRGBA & TextColor , const ColorRGBA & TextOutlineColor , const char * pText , ETextAlignment TextAlign , bool SmallFont = false ) {
2022-06-12 08:34:09 +00:00
float FontSize = 14.0f ;
2022-03-19 17:50:33 +00:00
if ( SmallFont )
2022-06-12 08:34:09 +00:00
FontSize = 6.0f ;
2022-03-19 10:25:54 +00:00
TextRender ( ) - > SetCurFont ( TextRender ( ) - > GetFont ( TEXT_FONT_ICON_FONT ) ) ;
TextRender ( ) - > SetRenderFlags ( ETextRenderFlags : : TEXT_RENDER_FLAG_ONLY_ADVANCE_WIDTH | ETextRenderFlags : : TEXT_RENDER_FLAG_NO_X_BEARING | ETextRenderFlags : : TEXT_RENDER_FLAG_NO_Y_BEARING | ETextRenderFlags : : TEXT_RENDER_FLAG_NO_PIXEL_ALIGMENT | ETextRenderFlags : : TEXT_RENDER_FLAG_NO_OVERSIZE ) ;
TextRender ( ) - > TextColor ( TextColor ) ;
TextRender ( ) - > TextOutlineColor ( TextOutlineColor ) ;
UI ( ) - > DoLabelStreamed ( UIRect , pRect , pText , FontSize , TextAlign , - 1 , 0 ) ;
TextRender ( ) - > TextOutlineColor ( TextRender ( ) - > DefaultTextOutlineColor ( ) ) ;
TextRender ( ) - > TextColor ( TextRender ( ) - > DefaultTextColor ( ) ) ;
TextRender ( ) - > SetRenderFlags ( 0 ) ;
TextRender ( ) - > SetCurFont ( nullptr ) ;
} ;
2018-03-13 20:59:07 +00:00
for ( int i = 0 ; i < NumServers ; i + + )
2008-08-27 15:48:50 +00:00
{
2023-01-05 11:21:10 +00:00
const CServerInfo * pItem = ServerBrowser ( ) - > SortedGet ( i ) ;
2018-10-29 21:03:57 +00:00
NumPlayers + = pItem - > m_NumFilteredPlayers ;
2010-05-29 07:25:38 +00:00
2023-01-05 11:21:10 +00:00
if ( pItem - > m_pUIElement = = nullptr )
2020-10-12 10:29:47 +00:00
{
2023-01-05 11:21:10 +00:00
const int UIRectCount = 2 + ( COL_VERSION + 1 ) * 3 ;
2021-09-13 21:48:10 +00:00
pItem - > m_pUIElement = UI ( ) - > GetNewUIElement ( UIRectCount ) ;
2020-10-12 10:29:47 +00:00
}
2023-01-05 11:21:10 +00:00
const CListboxItem ListItem = s_ListBox . DoNextItem ( pItem , str_comp ( pItem - > m_aAddress , g_Config . m_UiServerAddress ) = = 0 ) ;
if ( ListItem . m_Selected )
2010-05-29 07:25:38 +00:00
m_SelectedIndex = i ;
2008-08-27 15:48:50 +00:00
2011-06-26 15:10:13 +00:00
// update friend counter
2022-11-20 07:37:14 +00:00
int FriendsOnServer = 0 ;
2011-06-26 15:10:13 +00:00
if ( pItem - > m_FriendState ! = IFriends : : FRIEND_NO )
{
2017-03-29 10:56:13 +00:00
for ( int j = 0 ; j < pItem - > m_NumReceivedClients ; + + j )
2011-06-26 15:10:13 +00:00
{
if ( pItem - > m_aClients [ j ] . m_FriendState ! = IFriends : : FRIEND_NO )
{
2022-11-20 07:37:14 +00:00
FriendsOnServer + + ;
2011-06-26 15:10:13 +00:00
unsigned NameHash = str_quickhash ( pItem - > m_aClients [ j ] . m_aName ) ;
unsigned ClanHash = str_quickhash ( pItem - > m_aClients [ j ] . m_aClan ) ;
2022-06-11 19:38:18 +00:00
for ( auto & Friend : m_vFriends )
2011-06-26 15:10:13 +00:00
{
2022-05-23 19:15:04 +00:00
if ( ( ( g_Config . m_ClFriendsIgnoreClan & & Friend . m_pFriendInfo - > m_aName [ 0 ] ) | | ( ClanHash = = Friend . m_pFriendInfo - > m_ClanHash & & ! str_comp ( Friend . m_pFriendInfo - > m_aClan , pItem - > m_aClients [ j ] . m_aClan ) ) ) & &
( ! Friend . m_pFriendInfo - > m_aName [ 0 ] | | ( NameHash = = Friend . m_pFriendInfo - > m_NameHash & & ! str_comp ( Friend . m_pFriendInfo - > m_aName , pItem - > m_aClients [ j ] . m_aName ) ) ) )
2011-06-26 15:10:13 +00:00
{
2022-05-23 19:15:04 +00:00
Friend . m_NumFound + + ;
if ( Friend . m_pFriendInfo - > m_aName [ 0 ] )
2011-07-05 21:23:33 +00:00
break ;
2011-06-26 15:10:13 +00:00
}
}
}
}
}
2023-01-05 11:21:10 +00:00
if ( ! ListItem . m_Visible )
2010-05-29 07:25:38 +00:00
{
// reset active item, if not visible
2022-05-27 08:55:32 +00:00
if ( UI ( ) - > CheckActiveItem ( pItem ) )
2022-05-27 09:59:14 +00:00
UI ( ) - > SetActiveItem ( nullptr ) ;
2008-08-27 15:48:50 +00:00
2010-05-29 07:25:38 +00:00
// don't render invisible items
continue ;
}
for ( int c = 0 ; c < NumCols ; c + + )
2008-08-27 15:48:50 +00:00
{
2010-05-29 07:25:38 +00:00
CUIRect Button ;
char aTemp [ 64 ] ;
Button . x = s_aCols [ c ] . m_Rect . x ;
2023-01-05 11:21:10 +00:00
Button . y = ListItem . m_Rect . y ;
Button . h = ListItem . m_Rect . h ;
2010-05-29 07:25:38 +00:00
Button . w = s_aCols [ c ] . m_Rect . w ;
2011-02-12 10:40:36 +00:00
int ID = s_aCols [ c ] . m_ID ;
2010-05-29 07:25:38 +00:00
2011-02-12 10:40:36 +00:00
if ( ID = = COL_FLAG_LOCK )
2008-08-27 15:48:50 +00:00
{
2010-05-29 07:25:38 +00:00
if ( pItem - > m_Flags & SERVER_FLAG_PASSWORD )
2022-03-19 10:25:54 +00:00
{
2022-08-13 09:40:04 +00:00
RenderBrowserIcons ( * pItem - > m_pUIElement - > Rect ( gs_OffsetColFlagLock + 0 ) , & Button , { 0.75f , 0.75f , 0.75f , 1 } , TextRender ( ) - > DefaultTextOutlineColor ( ) , " \xEF \x80 \xA3 " , TEXTALIGN_CENTER ) ;
2022-03-19 10:25:54 +00:00
}
2008-10-05 09:57:46 +00:00
}
2011-02-12 10:40:36 +00:00
else if ( ID = = COL_FLAG_FAV )
2008-09-03 20:03:01 +00:00
{
2022-05-23 18:16:18 +00:00
if ( pItem - > m_Favorite ! = TRISTATE : : NONE )
2022-03-19 10:25:54 +00:00
{
2022-08-13 09:40:04 +00:00
RenderBrowserIcons ( * pItem - > m_pUIElement - > Rect ( gs_OffsetColFav + 0 ) , & Button , { 0.94f , 0.4f , 0.4f , 1 } , TextRender ( ) - > DefaultTextOutlineColor ( ) , " \xEF \x80 \x84 " , TEXTALIGN_CENTER ) ;
2022-03-19 10:25:54 +00:00
}
2008-08-27 15:48:50 +00:00
}
2019-03-19 06:46:48 +00:00
else if ( ID = = COL_FLAG_OFFICIAL )
{
2019-03-29 22:08:11 +00:00
if ( pItem - > m_Official & & g_Config . m_UiPage ! = PAGE_DDNET & & g_Config . m_UiPage ! = PAGE_KOG )
2022-03-19 10:25:54 +00:00
{
2022-08-13 09:40:04 +00:00
RenderBrowserIcons ( * pItem - > m_pUIElement - > Rect ( gs_OffsetColOff + 0 ) , & Button , { 0.4f , 0.7f , 0.94f , 1 } , { 0.0f , 0.0f , 0.0f , 1.0f } , " \xEF \x82 \xA3 " , TEXTALIGN_CENTER ) ;
RenderBrowserIcons ( * pItem - > m_pUIElement - > Rect ( gs_OffsetColOff + 1 ) , & Button , { 0.0f , 0.0f , 0.0f , 1.0f } , { 0.0f , 0.0f , 0.0f , 0.0f } , " \xEF \x80 \x8C " , TEXTALIGN_CENTER , true ) ;
2022-03-19 10:25:54 +00:00
}
2019-03-19 06:46:48 +00:00
}
2011-02-12 10:40:36 +00:00
else if ( ID = = COL_NAME )
2008-08-27 15:48:50 +00:00
{
2022-06-12 08:34:09 +00:00
float FontSize = 12.0f ;
2022-09-25 12:37:24 +00:00
bool Printed = false ;
2010-05-29 07:25:38 +00:00
2020-09-26 19:41:58 +00:00
if ( g_Config . m_BrFilterString [ 0 ] & & ( pItem - > m_QuickSearchHit & IServerBrowser : : QUICK_SERVERNAME ) )
2022-12-23 22:23:44 +00:00
Printed = PrintHighlighted ( pItem - > m_aName , [ this , pItem , FontSize , & Button ] ( const char * pFilteredStr , const int FilterLen ) {
UI ( ) - > DoLabelStreamed ( * pItem - > m_pUIElement - > Rect ( gs_OffsetColName + 0 ) , & Button , pItem - > m_aName , FontSize , TEXTALIGN_LEFT , Button . w , 1 , true , ( int ) ( pFilteredStr - pItem - > m_aName ) ) ;
TextRender ( ) - > TextColor ( 0.4f , 0.4f , 1.0f , 1 ) ;
UI ( ) - > DoLabelStreamed ( * pItem - > m_pUIElement - > Rect ( gs_OffsetColName + 1 ) , & Button , pFilteredStr , FontSize , TEXTALIGN_LEFT , Button . w , 1 , true , FilterLen , & pItem - > m_pUIElement - > Rect ( gs_OffsetColName + 0 ) - > m_Cursor ) ;
TextRender ( ) - > TextColor ( 1 , 1 , 1 , 1 ) ;
UI ( ) - > DoLabelStreamed ( * pItem - > m_pUIElement - > Rect ( gs_OffsetColName + 2 ) , & Button , pFilteredStr + FilterLen , FontSize , TEXTALIGN_LEFT , Button . w , 1 , true , - 1 , & pItem - > m_pUIElement - > Rect ( gs_OffsetColName + 1 ) - > m_Cursor ) ;
} ) ;
2022-09-25 12:37:24 +00:00
if ( ! Printed )
2022-08-13 09:40:04 +00:00
UI ( ) - > DoLabelStreamed ( * pItem - > m_pUIElement - > Rect ( gs_OffsetColName ) , & Button , pItem - > m_aName , FontSize , TEXTALIGN_LEFT , Button . w , 1 , true ) ;
2008-08-27 15:48:50 +00:00
}
2011-02-12 10:40:36 +00:00
else if ( ID = = COL_MAP )
2010-06-09 22:40:22 +00:00
{
2017-08-30 19:34:01 +00:00
if ( g_Config . m_UiPage = = PAGE_DDNET )
{
CUIRect Icon ;
Button . VMargin ( 4.0f , & Button ) ;
Button . VSplitLeft ( Button . h , & Icon , & Button ) ;
Icon . Margin ( 2.0f , & Icon ) ;
2020-08-26 17:23:25 +00:00
2020-09-26 19:41:58 +00:00
if ( g_Config . m_BrIndicateFinished & & pItem - > m_HasRank = = 1 )
2022-03-19 10:25:54 +00:00
{
2022-08-13 09:40:04 +00:00
RenderBrowserIcons ( * pItem - > m_pUIElement - > Rect ( gs_OffsetColFlagLock + 1 ) , & Icon , TextRender ( ) - > DefaultTextColor ( ) , TextRender ( ) - > DefaultTextOutlineColor ( ) , " \xEF \x84 \x9E " , TEXTALIGN_CENTER ) ;
2022-03-19 10:25:54 +00:00
}
2017-08-30 19:34:01 +00:00
}
2022-06-12 08:34:09 +00:00
float FontSize = 12.0f ;
2022-09-25 12:37:24 +00:00
bool Printed = false ;
2020-09-26 19:41:58 +00:00
if ( g_Config . m_BrFilterString [ 0 ] & & ( pItem - > m_QuickSearchHit & IServerBrowser : : QUICK_MAPNAME ) )
2022-12-23 22:23:44 +00:00
Printed = PrintHighlighted ( pItem - > m_aMap , [ this , pItem , FontSize , & Button ] ( const char * pFilteredStr , const int FilterLen ) {
UI ( ) - > DoLabelStreamed ( * pItem - > m_pUIElement - > Rect ( gs_OffsetColMap + 0 ) , & Button , pItem - > m_aMap , FontSize , TEXTALIGN_LEFT , Button . w , 1 , true , ( int ) ( pFilteredStr - pItem - > m_aMap ) ) ;
TextRender ( ) - > TextColor ( 0.4f , 0.4f , 1.0f , 1 ) ;
UI ( ) - > DoLabelStreamed ( * pItem - > m_pUIElement - > Rect ( gs_OffsetColMap + 1 ) , & Button , pFilteredStr , FontSize , TEXTALIGN_LEFT , Button . w , 1 , true , FilterLen , & pItem - > m_pUIElement - > Rect ( gs_OffsetColMap + 0 ) - > m_Cursor ) ;
TextRender ( ) - > TextColor ( 1 , 1 , 1 , 1 ) ;
UI ( ) - > DoLabelStreamed ( * pItem - > m_pUIElement - > Rect ( gs_OffsetColMap + 2 ) , & Button , pFilteredStr + FilterLen , FontSize , TEXTALIGN_LEFT , Button . w , 1 , true , - 1 , & pItem - > m_pUIElement - > Rect ( gs_OffsetColMap + 1 ) - > m_Cursor ) ;
} ) ;
2022-09-25 12:37:24 +00:00
if ( ! Printed )
2022-08-13 09:40:04 +00:00
UI ( ) - > DoLabelStreamed ( * pItem - > m_pUIElement - > Rect ( gs_OffsetColMap ) , & Button , pItem - > m_aMap , FontSize , TEXTALIGN_LEFT , Button . w , 1 , true ) ;
2010-06-09 22:40:22 +00:00
}
2011-02-12 10:40:36 +00:00
else if ( ID = = COL_PLAYERS )
2008-08-27 15:48:50 +00:00
{
2022-11-20 07:37:14 +00:00
CUIRect Icon , IconText ;
Button . VMargin ( 2.0f , & Button ) ;
2011-06-26 15:10:13 +00:00
if ( pItem - > m_FriendState ! = IFriends : : FRIEND_NO )
{
2022-11-20 19:26:53 +00:00
Button . VSplitRight ( 50.0f , & Icon , & Button ) ;
2011-06-26 15:10:13 +00:00
Icon . Margin ( 2.0f , & Icon ) ;
2022-11-20 19:26:53 +00:00
Icon . HSplitBottom ( 6.0f , 0 , & IconText ) ;
RenderBrowserIcons ( * pItem - > m_pUIElement - > Rect ( gs_OffsetColFav + 1 ) , & Icon , { 0.94f , 0.4f , 0.4f , 1 } , TextRender ( ) - > DefaultTextOutlineColor ( ) , " \xEF \x80 \x84 " , TEXTALIGN_CENTER ) ;
2022-11-20 07:37:14 +00:00
if ( FriendsOnServer > 1 )
{
char aBufFriendsOnServer [ 64 ] ;
2022-11-20 19:26:53 +00:00
str_format ( aBufFriendsOnServer , sizeof ( aBufFriendsOnServer ) , " %i " , FriendsOnServer ) ;
TextRender ( ) - > TextColor ( 0.94f , 0.8f , 0.8f , 1 ) ;
UI ( ) - > DoLabel ( & IconText , aBufFriendsOnServer , 10.0f , TEXTALIGN_CENTER ) ;
2022-11-20 07:37:14 +00:00
TextRender ( ) - > TextColor ( 1.0f , 1.0f , 1.0f , 1 ) ;
}
2011-06-26 15:10:13 +00:00
}
2018-10-29 21:03:57 +00:00
str_format ( aTemp , sizeof ( aTemp ) , " %i/%i " , pItem - > m_NumFilteredPlayers , ServerBrowser ( ) - > Max ( * pItem ) ) ;
2020-09-26 19:41:58 +00:00
if ( g_Config . m_BrFilterString [ 0 ] & & ( pItem - > m_QuickSearchHit & IServerBrowser : : QUICK_PLAYER ) )
TextRender ( ) - > TextColor ( 0.4f , 0.4f , 1.0f , 1 ) ;
2022-06-12 08:34:09 +00:00
float FontSize = 12.0f ;
2022-11-20 19:26:53 +00:00
UI ( ) - > DoLabelStreamed ( * pItem - > m_pUIElement - > Rect ( gs_OffsetColPlayers ) , & Button , aTemp , FontSize , TEXTALIGN_RIGHT , - 1 , 1 , false ) ;
2020-09-26 19:41:58 +00:00
TextRender ( ) - > TextColor ( 1 , 1 , 1 , 1 ) ;
2008-08-27 15:48:50 +00:00
}
2011-02-12 10:40:36 +00:00
else if ( ID = = COL_PING )
2008-08-27 15:48:50 +00:00
{
2021-12-28 00:05:50 +00:00
Button . VMargin ( 4.0f , & Button ) ;
2018-07-11 20:46:04 +00:00
FormatServerbrowserPing ( aTemp , sizeof ( aTemp ) , pItem ) ;
2018-03-13 20:59:07 +00:00
if ( g_Config . m_UiColorizePing )
2014-05-03 15:24:34 +00:00
{
2019-04-26 12:06:32 +00:00
ColorRGBA rgb = color_cast < ColorRGBA > ( ColorHSLA ( ( 300.0f - clamp ( pItem - > m_Latency , 0 , 300 ) ) / 1000.0f , 1.0f , 0.5f ) ) ;
2019-04-26 22:34:20 +00:00
TextRender ( ) - > TextColor ( rgb ) ;
2014-05-03 15:24:34 +00:00
}
2022-06-12 08:34:09 +00:00
float FontSize = 12.0f ;
2022-08-13 09:40:04 +00:00
UI ( ) - > DoLabelStreamed ( * pItem - > m_pUIElement - > Rect ( gs_OffsetColPing ) , & Button , aTemp , FontSize , TEXTALIGN_RIGHT , - 1 , 1 , false ) ;
2014-05-03 15:24:34 +00:00
TextRender ( ) - > TextColor ( 1.0f , 1.0f , 1.0f , 1.0f ) ;
2008-08-27 15:48:50 +00:00
}
2011-02-12 10:40:36 +00:00
else if ( ID = = COL_VERSION )
2008-08-27 15:48:50 +00:00
{
2010-05-29 07:25:38 +00:00
const char * pVersion = pItem - > m_aVersion ;
2022-06-12 08:34:09 +00:00
float FontSize = 12.0f ;
2022-08-13 09:40:04 +00:00
UI ( ) - > DoLabelStreamed ( * pItem - > m_pUIElement - > Rect ( gs_OffsetColVersion ) , & Button , pVersion , FontSize , TEXTALIGN_RIGHT , - 1 , 1 , false ) ;
2010-05-29 07:25:38 +00:00
}
2011-02-12 10:40:36 +00:00
else if ( ID = = COL_GAMETYPE )
2008-08-31 21:50:14 +00:00
{
2022-06-12 08:34:09 +00:00
float FontSize = 12.0f ;
2008-10-21 18:50:23 +00:00
2018-03-13 20:59:07 +00:00
if ( g_Config . m_UiColorizeGametype )
2014-05-03 15:24:34 +00:00
{
2019-04-26 12:06:32 +00:00
ColorHSLA hsl = ColorHSLA ( 1.0f , 1.0f , 1.0f ) ;
2014-05-03 15:24:34 +00:00
2022-10-11 12:28:41 +00:00
if ( str_comp ( pItem - > m_aGameType , " DM " ) = = 0 | | str_comp ( pItem - > m_aGameType , " TDM " ) = = 0 | | str_comp ( pItem - > m_aGameType , " CTF " ) = = 0 )
2019-04-26 12:06:32 +00:00
hsl = ColorHSLA ( 0.33f , 1.0f , 0.75f ) ;
2022-10-11 12:28:41 +00:00
else if ( str_find_nocase ( pItem - > m_aGameType , " catch " ) )
2019-04-26 12:06:32 +00:00
hsl = ColorHSLA ( 0.17f , 1.0f , 0.75f ) ;
2022-12-18 08:44:05 +00:00
else if ( str_find_nocase ( pItem - > m_aGameType , " idm " ) | | str_find_nocase ( pItem - > m_aGameType , " itdm " ) | | str_find_nocase ( pItem - > m_aGameType , " ictf " ) | | str_find_nocase ( pItem - > m_aGameType , " f-ddrace " ) )
2019-04-26 12:06:32 +00:00
hsl = ColorHSLA ( 0.00f , 1.0f , 0.75f ) ;
2022-10-11 12:28:41 +00:00
else if ( str_find_nocase ( pItem - > m_aGameType , " fng " ) )
2019-04-26 12:06:32 +00:00
hsl = ColorHSLA ( 0.83f , 1.0f , 0.75f ) ;
2022-12-05 16:03:43 +00:00
else if ( str_find_nocase ( pItem - > m_aGameType , " gores " ) )
hsl = ColorHSLA ( 0.525f , 1.0f , 0.75f ) ;
2022-12-07 18:29:40 +00:00
else if ( str_find_nocase ( pItem - > m_aGameType , " BW " ) )
hsl = ColorHSLA ( 0.050f , 1.0f , 0.75f ) ;
2022-10-11 12:28:41 +00:00
else if ( str_find_nocase ( pItem - > m_aGameType , " ddracenet " ) | | str_find_nocase ( pItem - > m_aGameType , " ddnet " ) )
2019-04-26 12:06:32 +00:00
hsl = ColorHSLA ( 0.58f , 1.0f , 0.75f ) ;
2022-10-11 12:28:41 +00:00
else if ( str_find_nocase ( pItem - > m_aGameType , " ddrace " ) | | str_find_nocase ( pItem - > m_aGameType , " mkrace " ) )
2019-04-26 12:06:32 +00:00
hsl = ColorHSLA ( 0.75f , 1.0f , 0.75f ) ;
2022-10-11 12:28:41 +00:00
else if ( str_find_nocase ( pItem - > m_aGameType , " race " ) | | str_find_nocase ( pItem - > m_aGameType , " fastcap " ) )
2019-04-26 12:06:32 +00:00
hsl = ColorHSLA ( 0.46f , 1.0f , 0.75f ) ;
2014-05-03 15:24:34 +00:00
2019-04-26 12:06:32 +00:00
ColorRGBA rgb = color_cast < ColorRGBA > ( hsl ) ;
2019-04-26 22:34:20 +00:00
TextRender ( ) - > TextColor ( rgb ) ;
2022-08-13 09:40:04 +00:00
UI ( ) - > DoLabelStreamed ( * pItem - > m_pUIElement - > Rect ( gs_OffsetColGameType ) , & Button , pItem - > m_aGameType , FontSize , TEXTALIGN_LEFT , Button . w , 1 , true ) ;
2014-05-03 15:24:34 +00:00
TextRender ( ) - > TextColor ( 1.0f , 1.0f , 1.0f , 1.0f ) ;
}
else
2022-08-13 09:40:04 +00:00
UI ( ) - > DoLabelStreamed ( * pItem - > m_pUIElement - > Rect ( gs_OffsetColGameType ) , & Button , pItem - > m_aGameType , FontSize , TEXTALIGN_LEFT , Button . w , 1 , true ) ;
2014-05-03 15:24:34 +00:00
}
2008-08-27 15:48:50 +00:00
}
}
2023-01-05 11:21:10 +00:00
const int NewSelected = s_ListBox . DoEnd ( ) ;
if ( NewSelected ! = m_SelectedIndex )
2008-08-27 15:48:50 +00:00
{
2023-01-05 11:21:10 +00:00
m_SelectedIndex = NewSelected ;
if ( m_SelectedIndex > = 0 )
{
// select the new server
const CServerInfo * pItem = ServerBrowser ( ) - > SortedGet ( NewSelected ) ;
if ( pItem )
{
str_copy ( g_Config . m_UiServerAddress , pItem - > m_aAddress ) ;
}
}
2008-08-27 15:48:50 +00:00
}
2023-01-05 11:21:10 +00:00
if ( s_ListBox . WasItemActivated ( ) )
Connect ( g_Config . m_UiServerAddress ) ;
2008-08-27 15:48:50 +00:00
2022-12-18 22:21:35 +00:00
// Render bar that shows the loading progression.
// The bar is only shown while loading and fades out when it's done.
CUIRect RefreshBar ;
Status . HSplitTop ( 5.0f , & RefreshBar , & Status ) ;
static float s_LoadingProgressionFadeEnd = 0.0f ;
if ( ServerBrowser ( ) - > IsRefreshing ( ) & & ServerBrowser ( ) - > LoadingProgression ( ) < 100 )
{
s_LoadingProgressionFadeEnd = Client ( ) - > GlobalTime ( ) + 2.0f ;
}
const float LoadingProgressionTimeDiff = s_LoadingProgressionFadeEnd - Client ( ) - > GlobalTime ( ) ;
if ( LoadingProgressionTimeDiff > 0.0f )
{
const float RefreshBarAlpha = minimum ( LoadingProgressionTimeDiff , 0.8f ) ;
RefreshBar . h = 2.0f ;
RefreshBar . w * = ServerBrowser ( ) - > LoadingProgression ( ) / 100.0f ;
RefreshBar . Draw ( ColorRGBA ( 1.0f , 1.0f , 1.0f , RefreshBarAlpha ) , IGraphics : : CORNER_NONE , 0.0f ) ;
}
2010-05-29 07:25:38 +00:00
2020-09-16 01:30:03 +00:00
CUIRect SearchInfoAndAddr , ServersAndConnect , Status3 ;
2020-09-19 20:03:21 +00:00
Status . VSplitRight ( 250.0f , & SearchInfoAndAddr , & ServersAndConnect ) ;
if ( SearchInfoAndAddr . w > 350.0f )
SearchInfoAndAddr . VSplitLeft ( 350.0f , & SearchInfoAndAddr , NULL ) ;
2020-09-16 01:30:03 +00:00
CUIRect SearchAndInfo , ServerAddr , ConnectButtons ;
2020-09-19 20:03:21 +00:00
SearchInfoAndAddr . HSplitTop ( 40.0f , & SearchAndInfo , & ServerAddr ) ;
ServersAndConnect . HSplitTop ( 35.0f , & Status3 , & ConnectButtons ) ;
2020-09-16 01:30:03 +00:00
CUIRect QuickSearch , QuickExclude ;
2020-09-19 20:03:21 +00:00
SearchAndInfo . HSplitTop ( 20.f , & QuickSearch , & QuickExclude ) ;
2020-09-16 01:30:03 +00:00
QuickSearch . Margin ( 2.f , & QuickSearch ) ;
QuickExclude . Margin ( 2.f , & QuickExclude ) ;
2020-10-06 15:55:22 +00:00
float SearchExcludeAddrStrMax = 130.0f ;
2020-09-16 01:30:03 +00:00
float SearchIconWidth = 0 ;
float ExcludeIconWidth = 0 ;
float ExcludeSearchIconMax = 0 ;
2022-03-19 17:50:33 +00:00
const char * pSearchLabel = " \xEF \x80 \x82 " ;
const char * pExcludeLabel = " \xEF \x81 \x9E " ;
2020-09-16 01:30:03 +00:00
2009-01-21 18:09:06 +00:00
// render quick search
2014-12-10 03:49:16 +00:00
{
2018-03-13 20:59:07 +00:00
TextRender ( ) - > SetCurFont ( TextRender ( ) - > GetFont ( TEXT_FONT_ICON_FONT ) ) ;
2020-10-06 10:25:10 +00:00
TextRender ( ) - > SetRenderFlags ( ETextRenderFlags : : TEXT_RENDER_FLAG_ONLY_ADVANCE_WIDTH | ETextRenderFlags : : TEXT_RENDER_FLAG_NO_X_BEARING | ETextRenderFlags : : TEXT_RENDER_FLAG_NO_Y_BEARING | ETextRenderFlags : : TEXT_RENDER_FLAG_NO_PIXEL_ALIGMENT | ETextRenderFlags : : TEXT_RENDER_FLAG_NO_OVERSIZE ) ;
2022-03-11 16:34:48 +00:00
SLabelProperties Props ;
Props . m_AlignVertically = 0 ;
2022-06-12 08:34:09 +00:00
UI ( ) - > DoLabel ( & QuickSearch , pSearchLabel , 16.0f , TEXTALIGN_LEFT , Props ) ;
2020-09-16 01:30:03 +00:00
SearchIconWidth = TextRender ( ) - > TextWidth ( 0 , 16.0f , pSearchLabel , - 1 , - 1.0f ) ;
ExcludeIconWidth = TextRender ( ) - > TextWidth ( 0 , 16.0f , pExcludeLabel , - 1 , - 1.0f ) ;
ExcludeSearchIconMax = maximum ( SearchIconWidth , ExcludeIconWidth ) ;
2018-03-13 20:59:07 +00:00
TextRender ( ) - > SetRenderFlags ( 0 ) ;
TextRender ( ) - > SetCurFont ( NULL ) ;
2020-09-16 01:30:03 +00:00
QuickSearch . VSplitLeft ( ExcludeSearchIconMax , 0 , & QuickSearch ) ;
QuickSearch . VSplitLeft ( 5.0f , 0 , & QuickSearch ) ;
2020-10-06 15:55:22 +00:00
char aBufSearch [ 64 ] ;
str_format ( aBufSearch , sizeof ( aBufSearch ) , " %s: " , Localize ( " Search " ) ) ;
2022-06-12 08:34:09 +00:00
UI ( ) - > DoLabel ( & QuickSearch , aBufSearch , 14.0f , TEXTALIGN_LEFT ) ;
2020-09-16 01:30:03 +00:00
QuickSearch . VSplitLeft ( SearchExcludeAddrStrMax , 0 , & QuickSearch ) ;
2014-12-10 03:49:16 +00:00
QuickSearch . VSplitLeft ( 5.0f , 0 , & QuickSearch ) ;
2020-09-16 01:30:03 +00:00
2022-03-13 18:09:33 +00:00
SUIExEditBoxProperties EditProps ;
2021-12-18 11:23:20 +00:00
if ( Input ( ) - > KeyPress ( KEY_F ) & & Input ( ) - > ModifierIsPressed ( ) )
2022-03-13 18:09:33 +00:00
{
2017-07-24 16:05:19 +00:00
UI ( ) - > SetActiveItem ( & g_Config . m_BrFilterString ) ;
2022-03-13 18:09:33 +00:00
EditProps . m_SelectText = true ;
}
2010-05-29 07:25:38 +00:00
static int s_ClearButton = 0 ;
2021-12-03 19:15:44 +00:00
static float s_Offset = 0.0f ;
2022-08-07 20:03:34 +00:00
if ( UI ( ) - > DoClearableEditBox ( & g_Config . m_BrFilterString , & s_ClearButton , & QuickSearch , g_Config . m_BrFilterString , sizeof ( g_Config . m_BrFilterString ) , 12.0f , & s_Offset , false , IGraphics : : CORNER_ALL , EditProps ) )
2011-03-18 18:03:13 +00:00
Client ( ) - > ServerBrowserUpdate ( ) ;
2010-05-29 07:25:38 +00:00
}
2011-04-13 18:37:12 +00:00
2014-12-10 03:49:16 +00:00
// render quick exclude
2014-01-14 19:58:47 +00:00
{
2018-03-13 20:59:07 +00:00
TextRender ( ) - > SetCurFont ( TextRender ( ) - > GetFont ( TEXT_FONT_ICON_FONT ) ) ;
2020-10-06 10:25:10 +00:00
TextRender ( ) - > SetRenderFlags ( ETextRenderFlags : : TEXT_RENDER_FLAG_ONLY_ADVANCE_WIDTH | ETextRenderFlags : : TEXT_RENDER_FLAG_NO_X_BEARING | ETextRenderFlags : : TEXT_RENDER_FLAG_NO_Y_BEARING | ETextRenderFlags : : TEXT_RENDER_FLAG_NO_PIXEL_ALIGMENT | ETextRenderFlags : : TEXT_RENDER_FLAG_NO_OVERSIZE ) ;
2022-03-11 16:34:48 +00:00
SLabelProperties Props ;
Props . m_AlignVertically = 0 ;
2022-06-12 08:34:09 +00:00
UI ( ) - > DoLabel ( & QuickExclude , pExcludeLabel , 16.0f , TEXTALIGN_LEFT , Props ) ;
2018-03-13 20:59:07 +00:00
TextRender ( ) - > SetRenderFlags ( 0 ) ;
TextRender ( ) - > SetCurFont ( NULL ) ;
2020-09-16 01:30:03 +00:00
QuickExclude . VSplitLeft ( ExcludeSearchIconMax , 0 , & QuickExclude ) ;
2014-12-10 03:49:16 +00:00
QuickExclude . VSplitLeft ( 5.0f , 0 , & QuickExclude ) ;
2020-09-16 01:30:03 +00:00
2020-10-06 15:55:22 +00:00
char aBufExclude [ 64 ] ;
str_format ( aBufExclude , sizeof ( aBufExclude ) , " %s: " , Localize ( " Exclude " ) ) ;
2022-06-12 08:34:09 +00:00
UI ( ) - > DoLabel ( & QuickExclude , aBufExclude , 14.0f , TEXTALIGN_LEFT ) ;
2020-09-16 01:30:03 +00:00
QuickExclude . VSplitLeft ( SearchExcludeAddrStrMax , 0 , & QuickExclude ) ;
QuickExclude . VSplitLeft ( 5.0f , 0 , & QuickExclude ) ;
2018-09-20 05:43:05 +00:00
static int s_ClearButton = 0 ;
2021-12-03 19:15:44 +00:00
static float s_Offset = 0.0f ;
2022-11-14 21:50:59 +00:00
if ( Input ( ) - > KeyPress ( KEY_X ) & & Input ( ) - > ShiftIsPressed ( ) & & Input ( ) - > ModifierIsPressed ( ) )
2017-07-24 16:05:19 +00:00
UI ( ) - > SetActiveItem ( & g_Config . m_BrExcludeString ) ;
2022-08-07 20:03:34 +00:00
if ( UI ( ) - > DoClearableEditBox ( & g_Config . m_BrExcludeString , & s_ClearButton , & QuickExclude , g_Config . m_BrExcludeString , sizeof ( g_Config . m_BrExcludeString ) , 12.0f , & s_Offset , false , IGraphics : : CORNER_ALL ) )
2014-12-10 03:49:16 +00:00
Client ( ) - > ServerBrowserUpdate ( ) ;
2014-01-14 19:58:47 +00:00
}
2014-12-10 03:49:16 +00:00
// render status
2020-09-16 01:30:03 +00:00
char aBufSvr [ 128 ] ;
char aBufPyr [ 128 ] ;
2020-12-28 07:56:55 +00:00
if ( ServerBrowser ( ) - > NumServers ( ) ! = 1 )
2020-09-16 01:30:03 +00:00
str_format ( aBufSvr , sizeof ( aBufSvr ) , Localize ( " %d of %d servers " ) , ServerBrowser ( ) - > NumSortedServers ( ) , ServerBrowser ( ) - > NumServers ( ) ) ;
else
str_format ( aBufSvr , sizeof ( aBufSvr ) , Localize ( " %d of %d server " ) , ServerBrowser ( ) - > NumSortedServers ( ) , ServerBrowser ( ) - > NumServers ( ) ) ;
if ( NumPlayers ! = 1 )
str_format ( aBufPyr , sizeof ( aBufPyr ) , Localize ( " %d players " ) , NumPlayers ) ;
else
str_format ( aBufPyr , sizeof ( aBufPyr ) , Localize ( " %d player " ) , NumPlayers ) ;
CUIRect SvrsOnline , PlysOnline ;
Status3 . HSplitTop ( 20.f , & PlysOnline , & SvrsOnline ) ;
PlysOnline . VSplitRight ( TextRender ( ) - > TextWidth ( 0 , 12.0f , aBufPyr , - 1 , - 1.0f ) , 0 , & PlysOnline ) ;
2022-06-12 08:34:09 +00:00
UI ( ) - > DoLabel ( & PlysOnline , aBufPyr , 12.0f , TEXTALIGN_LEFT ) ;
2020-09-16 01:30:03 +00:00
SvrsOnline . VSplitRight ( TextRender ( ) - > TextWidth ( 0 , 12.0f , aBufSvr , - 1 , - 1.0f ) , 0 , & SvrsOnline ) ;
2022-06-12 08:34:09 +00:00
UI ( ) - > DoLabel ( & SvrsOnline , aBufSvr , 12.0f , TEXTALIGN_LEFT ) ;
2020-09-16 01:30:03 +00:00
// status box
{
CUIRect ButtonRefresh , ButtonConnect , ButtonArea ;
ServerAddr . Margin ( 2.0f , & ServerAddr ) ;
// address info
2022-06-12 08:34:09 +00:00
UI ( ) - > DoLabel ( & ServerAddr , Localize ( " Server address: " ) , 14.0f , TEXTALIGN_LEFT ) ;
2020-09-16 01:30:03 +00:00
ServerAddr . VSplitLeft ( SearchExcludeAddrStrMax + 5.0f + ExcludeSearchIconMax + 5.0f , NULL , & ServerAddr ) ;
2020-09-29 20:41:24 +00:00
static int s_ClearButton = 0 ;
2021-12-03 19:15:44 +00:00
static float s_Offset = 0.0f ;
2022-08-07 20:03:34 +00:00
UI ( ) - > DoClearableEditBox ( & g_Config . m_UiServerAddress , & s_ClearButton , & ServerAddr , g_Config . m_UiServerAddress , sizeof ( g_Config . m_UiServerAddress ) , 12.0f , & s_Offset ) ;
2020-09-16 01:30:03 +00:00
// button area
ButtonArea = ConnectButtons ;
2020-09-19 20:03:21 +00:00
ButtonArea . VSplitMid ( & ButtonRefresh , & ButtonConnect ) ;
2020-09-16 01:30:03 +00:00
ButtonRefresh . HSplitTop ( 5.0f , NULL , & ButtonRefresh ) ;
2020-09-19 20:03:21 +00:00
ButtonConnect . HSplitTop ( 5.0f , NULL , & ButtonConnect ) ;
ButtonConnect . VSplitLeft ( 5.0f , NULL , & ButtonConnect ) ;
2020-09-16 01:30:03 +00:00
static int s_RefreshButton = 0 ;
2020-10-12 10:29:47 +00:00
auto Func = [ this ] ( ) mutable - > const char * {
2022-12-18 22:21:35 +00:00
if ( ServerBrowser ( ) - > IsRefreshing ( ) | | ServerBrowser ( ) - > IsGettingServerlist ( ) )
2022-07-09 16:14:56 +00:00
str_copy ( m_aLocalStringHelper , Localize ( " Refreshing... " ) ) ;
2020-10-12 10:29:47 +00:00
else
2022-07-09 16:14:56 +00:00
str_copy ( m_aLocalStringHelper , Localize ( " Refresh " ) ) ;
2020-09-16 01:30:03 +00:00
2020-10-12 10:29:47 +00:00
return m_aLocalStringHelper ;
} ;
2020-09-16 01:30:03 +00:00
2022-07-26 19:17:29 +00:00
if ( DoButtonMenu ( m_RefreshButton , & s_RefreshButton , Func , 0 , & ButtonRefresh , true , false , IGraphics : : CORNER_ALL ) | | Input ( ) - > KeyPress ( KEY_F5 ) | | ( Input ( ) - > KeyPress ( KEY_R ) & & Input ( ) - > ModifierIsPressed ( ) ) )
2020-09-16 01:30:03 +00:00
{
2022-09-23 17:59:18 +00:00
RefreshBrowserTab ( g_Config . m_UiPage ) ;
2020-09-16 01:30:03 +00:00
}
static int s_JoinButton = 0 ;
2020-10-12 10:29:47 +00:00
if ( DoButtonMenu (
2022-07-26 19:17:29 +00:00
m_ConnectButton , & s_JoinButton , [ ] ( ) - > const char * { return Localize ( " Connect " ) ; } , 0 , & ButtonConnect , false , false , IGraphics : : CORNER_ALL , 5 , 0 , vec4 ( 0.7f , 1 , 0.7f , 0.1f ) , vec4 ( 0.7f , 1 , 0.7f , 0.2f ) ) | |
2022-08-21 11:17:09 +00:00
UI ( ) - > ConsumeHotkey ( CUI : : HOTKEY_ENTER ) )
2020-09-16 01:30:03 +00:00
{
2022-11-30 22:41:32 +00:00
Connect ( g_Config . m_UiServerAddress ) ;
2020-09-16 01:30:03 +00:00
}
}
2008-09-04 18:42:26 +00:00
}
2022-11-30 22:41:32 +00:00
void CMenus : : Connect ( const char * pAddress )
{
if ( Client ( ) - > State ( ) = = IClient : : STATE_ONLINE & & Client ( ) - > GetCurrentRaceTime ( ) / 60 > = g_Config . m_ClConfirmDisconnectTime & & g_Config . m_ClConfirmDisconnectTime > = 0 )
{
str_copy ( m_aNextServer , pAddress ) ;
PopupConfirm ( Localize ( " Disconnect " ) , Localize ( " Are you sure that you want to disconnect and switch to a different server? " ) , Localize ( " Yes " ) , Localize ( " No " ) , & CMenus : : PopupConfirmSwitchServer ) ;
}
else
Client ( ) - > Connect ( pAddress ) ;
}
void CMenus : : PopupConfirmSwitchServer ( )
{
Client ( ) - > Connect ( m_aNextServer ) ;
}
2010-05-29 07:25:38 +00:00
void CMenus : : RenderServerbrowserFilters ( CUIRect View )
2008-09-04 18:42:26 +00:00
{
2011-03-18 16:59:48 +00:00
CUIRect ServerFilter = View , FilterHeader ;
const float FontSize = 12.0f ;
2014-09-20 09:47:51 +00:00
ServerFilter . HSplitBottom ( 0.0f , & ServerFilter , 0 ) ;
2011-03-18 16:59:48 +00:00
// server filter
ServerFilter . HSplitTop ( ms_ListheaderHeight , & FilterHeader , & ServerFilter ) ;
2022-08-07 16:12:07 +00:00
FilterHeader . Draw ( ColorRGBA ( 1 , 1 , 1 , 0.25f ) , IGraphics : : CORNER_T , 4.0f ) ;
2020-09-16 01:30:03 +00:00
2022-08-07 16:12:07 +00:00
ServerFilter . Draw ( ColorRGBA ( 0 , 0 , 0 , 0.15f ) , IGraphics : : CORNER_B , 4.0f ) ;
2022-06-12 08:34:09 +00:00
UI ( ) - > DoLabel ( & FilterHeader , Localize ( " Server filter " ) , FontSize + 2.0f , TEXTALIGN_CENTER ) ;
2014-12-14 15:45:18 +00:00
CUIRect Button , Button2 ;
2008-09-04 18:42:26 +00:00
2011-03-18 16:59:48 +00:00
ServerFilter . VSplitLeft ( 5.0f , 0 , & ServerFilter ) ;
ServerFilter . Margin ( 3.0f , & ServerFilter ) ;
ServerFilter . VMargin ( 5.0f , & ServerFilter ) ;
2008-09-04 18:42:26 +00:00
2011-03-18 16:59:48 +00:00
ServerFilter . HSplitTop ( 20.0f , & Button , & ServerFilter ) ;
2018-03-13 20:59:07 +00:00
if ( DoButton_CheckBox ( & g_Config . m_BrFilterEmpty , Localize ( " Has people playing " ) , g_Config . m_BrFilterEmpty , & Button ) )
2010-05-29 07:25:38 +00:00
g_Config . m_BrFilterEmpty ^ = 1 ;
2008-09-04 18:42:26 +00:00
2011-03-20 14:33:49 +00:00
ServerFilter . HSplitTop ( 20.0f , & Button , & ServerFilter ) ;
if ( DoButton_CheckBox ( & g_Config . m_BrFilterSpectators , Localize ( " Count players only " ) , g_Config . m_BrFilterSpectators , & Button ) )
g_Config . m_BrFilterSpectators ^ = 1 ;
2011-03-18 16:59:48 +00:00
ServerFilter . HSplitTop ( 20.0f , & Button , & ServerFilter ) ;
2018-03-13 20:59:07 +00:00
if ( DoButton_CheckBox ( & g_Config . m_BrFilterFull , Localize ( " Server not full " ) , g_Config . m_BrFilterFull , & Button ) )
2010-05-29 07:25:38 +00:00
g_Config . m_BrFilterFull ^ = 1 ;
2008-09-04 18:42:26 +00:00
2011-03-23 12:06:35 +00:00
ServerFilter . HSplitTop ( 20.0f , & Button , & ServerFilter ) ;
2018-03-13 20:59:07 +00:00
if ( DoButton_CheckBox ( & g_Config . m_BrFilterFriends , Localize ( " Show friends only " ) , g_Config . m_BrFilterFriends , & Button ) )
2011-03-23 12:06:35 +00:00
g_Config . m_BrFilterFriends ^ = 1 ;
2011-03-18 16:59:48 +00:00
ServerFilter . HSplitTop ( 20.0f , & Button , & ServerFilter ) ;
2018-03-13 20:59:07 +00:00
if ( DoButton_CheckBox ( & g_Config . m_BrFilterPw , Localize ( " No password " ) , g_Config . m_BrFilterPw , & Button ) )
2010-05-29 07:25:38 +00:00
g_Config . m_BrFilterPw ^ = 1 ;
2008-09-04 18:42:26 +00:00
2011-04-17 09:57:33 +00:00
ServerFilter . HSplitTop ( 20.0f , & Button , & ServerFilter ) ;
2018-03-13 20:59:07 +00:00
if ( DoButton_CheckBox ( & g_Config . m_BrFilterGametypeStrict , Localize ( " Strict gametype filter " ) , g_Config . m_BrFilterGametypeStrict , & Button ) )
2011-04-17 09:57:33 +00:00
g_Config . m_BrFilterGametypeStrict ^ = 1 ;
2011-04-13 18:37:12 +00:00
2011-03-18 16:59:48 +00:00
ServerFilter . HSplitTop ( 5.0f , 0 , & ServerFilter ) ;
2010-05-29 07:25:38 +00:00
2011-03-18 16:59:48 +00:00
ServerFilter . HSplitTop ( 19.0f , & Button , & ServerFilter ) ;
2022-06-12 08:34:09 +00:00
UI ( ) - > DoLabel ( & Button , Localize ( " Game types: " ) , FontSize , TEXTALIGN_LEFT ) ;
2011-03-18 16:59:48 +00:00
Button . VSplitRight ( 60.0f , 0 , & Button ) ;
ServerFilter . HSplitTop ( 3.0f , 0 , & ServerFilter ) ;
2021-12-03 19:15:44 +00:00
static float s_OffsetGametype = 0.0f ;
2022-08-07 20:03:34 +00:00
if ( UI ( ) - > DoEditBox ( & g_Config . m_BrFilterGametype , & Button , g_Config . m_BrFilterGametype , sizeof ( g_Config . m_BrFilterGametype ) , FontSize , & s_OffsetGametype ) )
2011-03-18 18:03:13 +00:00
Client ( ) - > ServerBrowserUpdate ( ) ;
2008-09-04 18:42:26 +00:00
2011-03-18 18:03:13 +00:00
// server address
ServerFilter . HSplitTop ( 3.0f , 0 , & ServerFilter ) ;
ServerFilter . HSplitTop ( 19.0f , & Button , & ServerFilter ) ;
2022-06-12 08:34:09 +00:00
UI ( ) - > DoLabel ( & Button , Localize ( " Server address: " ) , FontSize , TEXTALIGN_LEFT ) ;
2011-04-13 18:37:12 +00:00
Button . VSplitRight ( 60.0f , 0 , & Button ) ;
2021-12-03 19:15:44 +00:00
static float s_OffsetAddr = 0.0f ;
2022-08-07 20:03:34 +00:00
if ( UI ( ) - > DoEditBox ( & g_Config . m_BrFilterServerAddress , & Button , g_Config . m_BrFilterServerAddress , sizeof ( g_Config . m_BrFilterServerAddress ) , FontSize , & s_OffsetAddr ) )
2011-03-18 18:03:13 +00:00
Client ( ) - > ServerBrowserUpdate ( ) ;
2011-06-29 20:27:32 +00:00
// player country
{
CUIRect Rect ;
ServerFilter . HSplitTop ( 3.0f , 0 , & ServerFilter ) ;
ServerFilter . HSplitTop ( 26.0f , & Button , & ServerFilter ) ;
Button . VSplitRight ( 60.0f , & Button , & Rect ) ;
Button . HMargin ( 3.0f , & Button ) ;
if ( DoButton_CheckBox ( & g_Config . m_BrFilterCountry , Localize ( " Player country: " ) , g_Config . m_BrFilterCountry , & Button ) )
g_Config . m_BrFilterCountry ^ = 1 ;
2011-08-11 08:59:14 +00:00
2011-06-29 20:27:32 +00:00
float OldWidth = Rect . w ;
2020-09-26 19:41:58 +00:00
Rect . w = Rect . h * 2 ;
Rect . x + = ( OldWidth - Rect . w ) / 2.0f ;
ColorRGBA Color ( 1.0f , 1.0f , 1.0f , g_Config . m_BrFilterCountry ? 1.0f : 0.5f ) ;
2021-07-12 09:43:56 +00:00
m_pClient - > m_CountryFlags . Render ( g_Config . m_BrFilterCountryIndex , & Color , Rect . x , Rect . y , Rect . w , Rect . h ) ;
2011-06-29 20:27:32 +00:00
2022-05-13 22:26:15 +00:00
if ( g_Config . m_BrFilterCountry & & UI ( ) - > DoButtonLogic ( & g_Config . m_BrFilterCountryIndex , 0 , & Rect ) )
2011-06-29 20:27:32 +00:00
m_Popup = POPUP_COUNTRY ;
}
2018-08-21 07:03:29 +00:00
ServerFilter . HSplitTop ( 20.0f , & Button , & ServerFilter ) ;
if ( DoButton_CheckBox ( & g_Config . m_BrFilterConnectingPlayers , Localize ( " Filter connecting players " ) , g_Config . m_BrFilterConnectingPlayers , & Button ) )
g_Config . m_BrFilterConnectingPlayers ^ = 1 ;
2020-09-16 01:30:03 +00:00
CUIRect FilterTabs ;
ServerFilter . HSplitBottom ( 23 , & ServerFilter , & FilterTabs ) ;
2014-12-14 15:45:18 +00:00
CUIRect ResetButton ;
//ServerFilter.HSplitBottom(5.0f, &ServerFilter, 0);
2020-09-16 01:30:03 +00:00
ServerFilter . HSplitBottom ( ms_ButtonHeight - 5.0f , & ServerFilter , & ResetButton ) ;
2014-12-14 15:45:18 +00:00
2014-09-19 21:52:09 +00:00
// ddnet country filters
if ( g_Config . m_UiPage = = PAGE_DDNET )
{
2017-08-30 19:34:01 +00:00
ServerFilter . HSplitTop ( 20.0f , & Button , & ServerFilter ) ;
2018-03-13 20:59:07 +00:00
if ( DoButton_CheckBox ( & g_Config . m_BrIndicateFinished , Localize ( " Indicate map finish " ) , g_Config . m_BrIndicateFinished , & Button ) )
2020-08-26 17:23:25 +00:00
{
2017-09-07 18:51:46 +00:00
g_Config . m_BrIndicateFinished ^ = 1 ;
2020-09-26 19:41:58 +00:00
if ( g_Config . m_BrIndicateFinished )
2020-08-26 17:23:25 +00:00
ServerBrowser ( ) - > Refresh ( ServerBrowser ( ) - > GetCurrentType ( ) ) ;
}
2017-09-07 18:51:46 +00:00
if ( g_Config . m_BrIndicateFinished )
{
ServerFilter . HSplitTop ( 20.0f , & Button , & ServerFilter ) ;
2018-03-13 20:59:07 +00:00
if ( DoButton_CheckBox ( & g_Config . m_BrFilterUnfinishedMap , Localize ( " Unfinished map " ) , g_Config . m_BrFilterUnfinishedMap , & Button ) )
2017-09-07 18:51:46 +00:00
g_Config . m_BrFilterUnfinishedMap ^ = 1 ;
}
else
{
g_Config . m_BrFilterUnfinishedMap = 0 ;
}
2019-03-24 22:15:38 +00:00
}
2017-08-30 19:34:01 +00:00
2019-03-24 22:15:38 +00:00
if ( g_Config . m_UiPage = = PAGE_DDNET | | g_Config . m_UiPage = = PAGE_KOG )
{
int Network = g_Config . m_UiPage = = PAGE_DDNET ? IServerBrowser : : NETWORK_DDNET : IServerBrowser : : NETWORK_KOG ;
2014-09-19 21:52:09 +00:00
// add more space
2020-09-10 15:58:27 +00:00
ServerFilter . HSplitTop ( 5.0f , 0 , & ServerFilter ) ;
2014-12-14 15:45:18 +00:00
ServerFilter . HSplitTop ( 20.0f , & Button , & ServerFilter ) ;
2020-10-03 19:02:36 +00:00
ServerFilter . HSplitTop ( 120.0f , & ServerFilter , 0 ) ;
2014-09-19 21:52:09 +00:00
2022-08-07 16:12:07 +00:00
ServerFilter . Draw ( ms_ColorTabbarActive , IGraphics : : CORNER_B , 10.0f ) ;
2014-09-19 21:52:09 +00:00
2014-12-14 15:45:18 +00:00
Button . VSplitMid ( & Button , & Button2 ) ;
2014-09-19 21:52:09 +00:00
2014-12-14 15:45:18 +00:00
static int s_ActivePage = 0 ;
2014-09-19 21:52:09 +00:00
2022-07-16 13:32:06 +00:00
static CButtonContainer s_CountriesButton ;
2022-07-26 19:17:29 +00:00
if ( DoButton_MenuTab ( & s_CountriesButton , Localize ( " Countries " ) , s_ActivePage = = 0 , & Button , IGraphics : : CORNER_TL ) )
2014-12-14 15:45:18 +00:00
{
s_ActivePage = 0 ;
}
2014-09-19 21:52:09 +00:00
2022-07-16 13:32:06 +00:00
static CButtonContainer s_TypesButton ;
2022-07-26 19:17:29 +00:00
if ( DoButton_MenuTab ( & s_TypesButton , Localize ( " Types " ) , s_ActivePage = = 1 , & Button2 , IGraphics : : CORNER_TR ) )
2014-09-19 21:52:09 +00:00
{
2014-12-14 15:45:18 +00:00
s_ActivePage = 1 ;
}
2014-11-21 13:11:04 +00:00
2014-12-14 15:45:18 +00:00
if ( s_ActivePage = = 1 )
{
2019-03-24 22:15:38 +00:00
char * pFilterExcludeTypes = Network = = IServerBrowser : : NETWORK_DDNET ? g_Config . m_BrFilterExcludeTypes : g_Config . m_BrFilterExcludeTypesKoG ;
int MaxTypes = ServerBrowser ( ) - > NumTypes ( Network ) ;
int NumTypes = ServerBrowser ( ) - > NumTypes ( Network ) ;
2014-12-14 15:45:18 +00:00
int PerLine = 3 ;
2014-09-19 21:52:09 +00:00
2016-05-15 08:15:39 +00:00
ServerFilter . HSplitTop ( 4.0f , 0 , & ServerFilter ) ;
ServerFilter . HSplitBottom ( 4.0f , & ServerFilter , 0 ) ;
2014-09-19 21:52:09 +00:00
2014-12-14 15:45:18 +00:00
const float TypesWidth = 40.0f ;
2016-05-15 08:15:39 +00:00
const float TypesHeight = ServerFilter . h / ceil ( MaxTypes / ( float ) PerLine ) ;
2014-09-19 21:52:09 +00:00
2014-12-14 15:45:18 +00:00
CUIRect TypesRect , Left , Right ;
2014-09-19 21:52:09 +00:00
2014-12-14 15:45:18 +00:00
static int s_aTypeButtons [ 64 ] ;
2014-09-19 21:52:09 +00:00
2014-12-14 15:45:18 +00:00
while ( NumTypes > 0 )
{
ServerFilter . HSplitTop ( TypesHeight , & TypesRect , & ServerFilter ) ;
TypesRect . VSplitMid ( & Left , & Right ) ;
for ( int i = 0 ; i < PerLine & & NumTypes > 0 ; i + + , NumTypes - - )
2014-09-19 21:52:09 +00:00
{
2014-12-14 15:45:18 +00:00
int TypeIndex = MaxTypes - NumTypes ;
2019-03-24 22:15:38 +00:00
const char * pName = ServerBrowser ( ) - > GetType ( Network , TypeIndex ) ;
bool Active = ! ServerBrowser ( ) - > DDNetFiltered ( pFilterExcludeTypes , pName ) ;
2014-09-19 21:52:09 +00:00
2020-09-26 19:41:58 +00:00
vec2 Pos = vec2 ( TypesRect . x + TypesRect . w * ( ( i + 0.5f ) / ( float ) PerLine ) , TypesRect . y ) ;
2014-12-14 15:45:18 +00:00
// correct pos
Pos . x - = TypesWidth / 2.0f ;
// create button logic
CUIRect Rect ;
Rect . x = Pos . x ;
Rect . y = Pos . y ;
Rect . w = TypesWidth ;
Rect . h = TypesHeight ;
2022-05-13 22:26:15 +00:00
int Click = UI ( ) - > DoButtonLogic ( & s_aTypeButtons [ TypeIndex ] , 0 , & Rect ) ;
2022-03-20 11:57:50 +00:00
if ( Click = = 1 | | Click = = 2 )
2014-12-14 15:45:18 +00:00
{
2021-08-05 09:28:31 +00:00
// left/right click to toggle filter
if ( pFilterExcludeTypes [ 0 ] = = ' \0 ' )
{
// when all are active, only activate one
for ( int j = 0 ; j < MaxTypes ; + + j )
{
if ( j ! = TypeIndex )
ServerBrowser ( ) - > DDNetFilterAdd ( pFilterExcludeTypes , ServerBrowser ( ) - > GetType ( Network , j ) ) ;
}
}
2014-12-14 15:45:18 +00:00
else
2017-08-30 20:36:39 +00:00
{
2021-08-05 09:28:31 +00:00
bool AllFilteredExceptUs = true ;
for ( int j = 0 ; j < MaxTypes ; + + j )
{
if ( j ! = TypeIndex & & ! ServerBrowser ( ) - > DDNetFiltered ( pFilterExcludeTypes , ServerBrowser ( ) - > GetType ( Network , j ) ) )
{
AllFilteredExceptUs = false ;
break ;
}
}
// when last one is removed, reset (re-enable all)
if ( AllFilteredExceptUs )
{
pFilterExcludeTypes [ 0 ] = ' \0 ' ;
}
else if ( Active )
{
ServerBrowser ( ) - > DDNetFilterAdd ( pFilterExcludeTypes , pName ) ;
}
else
{
ServerBrowser ( ) - > DDNetFilterRem ( pFilterExcludeTypes , pName ) ;
}
2017-08-30 20:36:39 +00:00
}
2021-08-05 09:28:31 +00:00
2019-03-24 22:15:38 +00:00
ServerBrowser ( ) - > Refresh ( ServerBrowser ( ) - > GetCurrentType ( ) ) ;
2017-08-30 20:36:39 +00:00
}
2022-03-20 11:57:50 +00:00
else if ( Click = = 3 )
2017-08-30 20:36:39 +00:00
{
2018-07-10 09:29:02 +00:00
// middle click to reset (re-enable all)
2019-03-24 22:15:38 +00:00
pFilterExcludeTypes [ 0 ] = ' \0 ' ;
ServerBrowser ( ) - > Refresh ( ServerBrowser ( ) - > GetCurrentType ( ) ) ;
2017-08-30 20:36:39 +00:00
}
2014-12-14 15:45:18 +00:00
2019-04-26 22:11:15 +00:00
TextRender ( ) - > TextColor ( 1.0f , 1.0f , 1.0f , Active ? 1.0f : 0.2f ) ;
2022-06-12 08:34:09 +00:00
UI ( ) - > DoLabel ( & Rect , pName , FontSize , TEXTALIGN_CENTER ) ;
2014-12-14 15:45:18 +00:00
TextRender ( ) - > TextColor ( 1.0 , 1.0 , 1.0 , 1.0f ) ;
2014-09-19 21:52:09 +00:00
}
2014-12-14 15:45:18 +00:00
}
}
else
{
2019-03-24 22:15:38 +00:00
char * pFilterExcludeCountries = Network = = IServerBrowser : : NETWORK_DDNET ? g_Config . m_BrFilterExcludeCountries : g_Config . m_BrFilterExcludeCountriesKoG ;
2020-09-16 01:30:03 +00:00
ServerFilter . HSplitTop ( 15.0f , & ServerFilter , & ServerFilter ) ;
2014-12-14 15:45:18 +00:00
const float FlagWidth = 40.0f ;
const float FlagHeight = 20.0f ;
2019-03-24 22:15:38 +00:00
int MaxFlags = ServerBrowser ( ) - > NumCountries ( Network ) ;
int NumFlags = ServerBrowser ( ) - > NumCountries ( Network ) ;
2020-09-16 01:30:03 +00:00
int PerLine = MaxFlags > 8 ? 5 : 4 ;
2014-12-14 15:45:18 +00:00
CUIRect FlagsRect ;
static int s_aFlagButtons [ 64 ] ;
while ( NumFlags > 0 )
{
2020-09-16 01:30:03 +00:00
ServerFilter . HSplitTop ( 23.0f , & FlagsRect , & ServerFilter ) ;
2014-09-19 21:52:09 +00:00
2014-12-14 15:45:18 +00:00
for ( int i = 0 ; i < PerLine & & NumFlags > 0 ; i + + , NumFlags - - )
{
int CountryIndex = MaxFlags - NumFlags ;
2019-03-24 22:15:38 +00:00
const char * pName = ServerBrowser ( ) - > GetCountryName ( Network , CountryIndex ) ;
bool Active = ! ServerBrowser ( ) - > DDNetFiltered ( pFilterExcludeCountries , pName ) ;
int FlagID = ServerBrowser ( ) - > GetCountryFlag ( Network , CountryIndex ) ;
2014-12-14 15:45:18 +00:00
2020-09-26 19:41:58 +00:00
vec2 Pos = vec2 ( FlagsRect . x + FlagsRect . w * ( ( i + 0.5f ) / ( float ) PerLine ) , FlagsRect . y ) ;
2014-12-14 15:45:18 +00:00
// correct pos
Pos . x - = FlagWidth / 2.0f ;
Pos . y - = FlagHeight / 2.0f ;
// create button logic
CUIRect Rect ;
Rect . x = Pos . x ;
Rect . y = Pos . y ;
Rect . w = FlagWidth ;
Rect . h = FlagHeight ;
2014-09-19 21:52:09 +00:00
2022-05-13 22:26:15 +00:00
int Click = UI ( ) - > DoButtonLogic ( & s_aFlagButtons [ CountryIndex ] , 0 , & Rect ) ;
2022-03-20 11:57:50 +00:00
if ( Click = = 1 | | Click = = 2 )
2014-12-14 15:45:18 +00:00
{
2021-08-05 09:28:31 +00:00
// left/right click to toggle filter
if ( pFilterExcludeCountries [ 0 ] = = ' \0 ' )
{
// when all are active, only activate one
for ( int j = 0 ; j < MaxFlags ; + + j )
{
if ( j ! = CountryIndex )
ServerBrowser ( ) - > DDNetFilterAdd ( pFilterExcludeCountries , ServerBrowser ( ) - > GetCountryName ( Network , j ) ) ;
}
}
2014-12-14 15:45:18 +00:00
else
2017-08-30 20:36:39 +00:00
{
2021-08-05 09:28:31 +00:00
bool AllFilteredExceptUs = true ;
for ( int j = 0 ; j < MaxFlags ; + + j )
{
if ( j ! = CountryIndex & & ! ServerBrowser ( ) - > DDNetFiltered ( pFilterExcludeCountries , ServerBrowser ( ) - > GetCountryName ( Network , j ) ) )
{
AllFilteredExceptUs = false ;
break ;
}
}
// when last one is removed, reset (re-enable all)
if ( AllFilteredExceptUs )
{
pFilterExcludeCountries [ 0 ] = ' \0 ' ;
}
else if ( Active )
{
ServerBrowser ( ) - > DDNetFilterAdd ( pFilterExcludeCountries , pName ) ;
}
else
{
ServerBrowser ( ) - > DDNetFilterRem ( pFilterExcludeCountries , pName ) ;
}
2017-08-30 20:36:39 +00:00
}
2021-08-05 09:28:31 +00:00
2019-03-24 22:15:38 +00:00
ServerBrowser ( ) - > Refresh ( ServerBrowser ( ) - > GetCurrentType ( ) ) ;
2017-08-30 20:36:39 +00:00
}
2022-03-20 11:57:50 +00:00
else if ( Click = = 3 )
2017-08-30 20:36:39 +00:00
{
2018-07-10 09:29:02 +00:00
// middle click to reset (re-enable all)
2019-03-24 22:15:38 +00:00
pFilterExcludeCountries [ 0 ] = ' \0 ' ;
ServerBrowser ( ) - > Refresh ( ServerBrowser ( ) - > GetCurrentType ( ) ) ;
2017-08-30 20:36:39 +00:00
}
2014-09-19 21:52:09 +00:00
2019-04-26 22:11:15 +00:00
ColorRGBA Color ( 1.0f , 1.0f , 1.0f , Active ? 1.0f : 0.2f ) ;
2021-07-12 09:43:56 +00:00
m_pClient - > m_CountryFlags . Render ( FlagID , & Color , Pos . x , Pos . y , FlagWidth , FlagHeight ) ;
2014-12-14 15:45:18 +00:00
}
2014-09-19 21:52:09 +00:00
}
}
}
2014-05-03 15:24:34 +00:00
2022-07-16 13:32:06 +00:00
static CButtonContainer s_ClearButton ;
2014-12-14 15:45:18 +00:00
if ( DoButton_Menu ( & s_ClearButton , Localize ( " Reset filter " ) , 0 , & ResetButton ) )
2008-09-04 18:42:26 +00:00
{
2011-07-02 11:10:34 +00:00
g_Config . m_BrFilterString [ 0 ] = 0 ;
2014-12-10 03:49:16 +00:00
g_Config . m_BrExcludeString [ 0 ] = 0 ;
2010-05-29 07:25:38 +00:00
g_Config . m_BrFilterFull = 0 ;
g_Config . m_BrFilterEmpty = 0 ;
2011-07-02 11:10:34 +00:00
g_Config . m_BrFilterSpectators = 0 ;
g_Config . m_BrFilterFriends = 0 ;
g_Config . m_BrFilterCountry = 0 ;
g_Config . m_BrFilterCountryIndex = - 1 ;
2010-05-29 07:25:38 +00:00
g_Config . m_BrFilterPw = 0 ;
g_Config . m_BrFilterGametype [ 0 ] = 0 ;
2011-07-02 11:10:34 +00:00
g_Config . m_BrFilterGametypeStrict = 0 ;
2018-08-21 07:03:29 +00:00
g_Config . m_BrFilterConnectingPlayers = 1 ;
2017-08-30 19:34:01 +00:00
g_Config . m_BrFilterUnfinishedMap = 0 ;
2011-03-18 18:03:13 +00:00
g_Config . m_BrFilterServerAddress [ 0 ] = 0 ;
2014-12-21 17:40:00 +00:00
g_Config . m_BrFilterExcludeCountries [ 0 ] = 0 ;
g_Config . m_BrFilterExcludeTypes [ 0 ] = 0 ;
2021-01-27 18:21:33 +00:00
if ( g_Config . m_UiPage = = PAGE_DDNET | | g_Config . m_UiPage = = PAGE_KOG )
ServerBrowser ( ) - > Refresh ( ServerBrowser ( ) - > GetCurrentType ( ) ) ;
else
Client ( ) - > ServerBrowserUpdate ( ) ;
2008-10-05 09:57:46 +00:00
}
2008-09-04 18:42:26 +00:00
}
2008-08-27 15:48:50 +00:00
2010-05-29 07:25:38 +00:00
void CMenus : : RenderServerbrowserServerDetail ( CUIRect View )
2008-09-04 18:42:26 +00:00
{
2010-05-29 07:25:38 +00:00
CUIRect ServerDetails = View ;
CUIRect ServerScoreBoard , ServerHeader ;
const CServerInfo * pSelectedServer = ServerBrowser ( ) - > SortedGet ( m_SelectedIndex ) ;
2008-09-04 18:42:26 +00:00
// split off a piece to use for scoreboard
2023-01-06 20:14:26 +00:00
ServerDetails . HSplitTop ( 110.0f , & ServerDetails , & ServerScoreBoard ) ;
2008-08-27 15:48:50 +00:00
2008-09-04 18:42:26 +00:00
// server details
2011-01-09 23:18:30 +00:00
CTextCursor Cursor ;
2010-05-29 07:25:38 +00:00
const float FontSize = 12.0f ;
2011-03-18 16:59:48 +00:00
ServerDetails . HSplitTop ( ms_ListheaderHeight , & ServerHeader , & ServerDetails ) ;
2022-08-07 16:12:07 +00:00
ServerHeader . Draw ( ColorRGBA ( 1 , 1 , 1 , 0.25f ) , IGraphics : : CORNER_T , 4.0f ) ;
ServerDetails . Draw ( ColorRGBA ( 0 , 0 , 0 , 0.15f ) , IGraphics : : CORNER_B , 4.0f ) ;
2022-06-12 08:34:09 +00:00
UI ( ) - > DoLabel ( & ServerHeader , Localize ( " Server details " ) , FontSize + 2.0f , TEXTALIGN_CENTER ) ;
2008-08-27 15:48:50 +00:00
2018-03-13 20:59:07 +00:00
if ( pSelectedServer )
2008-09-04 18:42:26 +00:00
{
2023-01-06 20:14:26 +00:00
ServerDetails . Margin ( 5.0f , & ServerDetails ) ;
2011-03-18 16:59:48 +00:00
2010-05-29 07:25:38 +00:00
CUIRect Row ;
static CLocConstString s_aLabels [ ] = {
2020-09-26 19:41:58 +00:00
" Version " , // Localize - these strings are localized within CLocConstString
2010-05-31 11:07:58 +00:00
" Game type " ,
" Ping " } ;
2008-08-27 15:48:50 +00:00
2023-01-06 20:14:26 +00:00
// copy info button
{
CUIRect Button ;
ServerDetails . HSplitBottom ( 15.0f , & ServerDetails , & Button ) ;
static CButtonContainer s_CopyButton ;
if ( DoButton_Menu ( & s_CopyButton , Localize ( " Copy info " ) , 0 , & Button ) )
{
char aInfo [ 256 ] ;
pSelectedServer - > InfoToString ( aInfo , sizeof ( aInfo ) ) ;
Input ( ) - > SetClipboardText ( aInfo ) ;
}
}
ServerDetails . HSplitBottom ( 2.5f , & ServerDetails , nullptr ) ;
2008-08-27 15:48:50 +00:00
2023-01-06 20:14:26 +00:00
// favorite checkbox
2008-09-03 20:03:01 +00:00
{
2010-05-29 07:25:38 +00:00
CUIRect Button ;
ServerDetails . HSplitBottom ( 20.0f , & ServerDetails , & Button ) ;
2021-05-12 19:06:08 +00:00
CUIRect ButtonAddFav ;
CUIRect ButtonLeakIp ;
Button . VSplitMid ( & ButtonAddFav , & ButtonLeakIp ) ;
2010-05-29 07:25:38 +00:00
static int s_AddFavButton = 0 ;
2021-05-12 19:06:08 +00:00
static int s_LeakIpButton = 0 ;
2022-05-23 18:16:18 +00:00
if ( DoButton_CheckBox_Tristate ( & s_AddFavButton , Localize ( " Favorite " ) , pSelectedServer - > m_Favorite , & ButtonAddFav ) )
2008-09-03 20:03:01 +00:00
{
2022-05-23 18:16:18 +00:00
if ( pSelectedServer - > m_Favorite ! = TRISTATE : : NONE )
2021-05-12 19:06:08 +00:00
{
2022-05-23 18:16:18 +00:00
Favorites ( ) - > Remove ( pSelectedServer - > m_aAddresses , pSelectedServer - > m_NumAddresses ) ;
2021-05-12 19:06:08 +00:00
}
2008-09-04 18:42:26 +00:00
else
2021-05-12 19:06:08 +00:00
{
2022-05-23 18:16:18 +00:00
Favorites ( ) - > Add ( pSelectedServer - > m_aAddresses , pSelectedServer - > m_NumAddresses ) ;
2021-05-12 19:06:08 +00:00
if ( g_Config . m_UiPage = = PAGE_LAN )
{
2022-05-23 18:16:18 +00:00
Favorites ( ) - > AllowPing ( pSelectedServer - > m_aAddresses , pSelectedServer - > m_NumAddresses , true ) ;
2021-05-12 19:06:08 +00:00
}
}
2022-05-23 18:16:18 +00:00
Client ( ) - > ServerBrowserUpdate ( ) ;
2021-05-12 19:06:08 +00:00
}
2022-05-23 18:16:18 +00:00
if ( pSelectedServer - > m_Favorite ! = TRISTATE : : NONE )
2021-05-12 19:06:08 +00:00
{
2022-05-23 18:16:18 +00:00
if ( DoButton_CheckBox_Tristate ( & s_LeakIpButton , Localize ( " Leak IP " ) , pSelectedServer - > m_FavoriteAllowPing , & ButtonLeakIp ) )
2021-05-12 19:06:08 +00:00
{
2022-05-23 18:16:18 +00:00
Favorites ( ) - > AllowPing ( pSelectedServer - > m_aAddresses , pSelectedServer - > m_NumAddresses , pSelectedServer - > m_FavoriteAllowPing = = TRISTATE : : NONE ) ;
2021-05-12 19:06:08 +00:00
}
2022-05-23 18:16:18 +00:00
Client ( ) - > ServerBrowserUpdate ( ) ;
2008-09-03 20:03:01 +00:00
}
2008-09-04 18:42:26 +00:00
}
2008-09-03 20:03:01 +00:00
2023-01-06 20:14:26 +00:00
CUIRect LeftColumn , RightColumn ;
2010-05-29 07:25:38 +00:00
ServerDetails . VSplitLeft ( 80.0f , & LeftColumn , & RightColumn ) ;
2008-08-27 15:48:50 +00:00
2020-10-26 14:14:07 +00:00
for ( auto & Label : s_aLabels )
2008-09-04 18:42:26 +00:00
{
2010-05-29 07:25:38 +00:00
LeftColumn . HSplitTop ( 15.0f , & Row , & LeftColumn ) ;
2022-06-12 08:34:09 +00:00
UI ( ) - > DoLabel ( & Row , Localize ( Label ) , FontSize , TEXTALIGN_LEFT ) ;
2008-09-04 18:42:26 +00:00
}
2008-08-27 15:48:50 +00:00
2010-05-29 07:25:38 +00:00
RightColumn . HSplitTop ( 15.0f , & Row , & RightColumn ) ;
2020-09-26 19:41:58 +00:00
TextRender ( ) - > SetCursor ( & Cursor , Row . x , Row . y + ( 15.f - FontSize ) / 2.f , FontSize , TEXTFLAG_RENDER | TEXTFLAG_STOP_AT_END ) ;
2011-01-09 23:18:30 +00:00
Cursor . m_LineWidth = Row . w ;
TextRender ( ) - > TextEx ( & Cursor , pSelectedServer - > m_aVersion , - 1 ) ;
2008-08-27 15:48:50 +00:00
2010-05-29 07:25:38 +00:00
RightColumn . HSplitTop ( 15.0f , & Row , & RightColumn ) ;
2020-09-26 19:41:58 +00:00
TextRender ( ) - > SetCursor ( & Cursor , Row . x , Row . y + ( 15.f - FontSize ) / 2.f , FontSize , TEXTFLAG_RENDER | TEXTFLAG_STOP_AT_END ) ;
2011-01-09 23:18:30 +00:00
Cursor . m_LineWidth = Row . w ;
TextRender ( ) - > TextEx ( & Cursor , pSelectedServer - > m_aGameType , - 1 ) ;
2008-08-27 15:48:50 +00:00
2010-05-29 07:25:38 +00:00
char aTemp [ 16 ] ;
2018-07-11 20:46:04 +00:00
FormatServerbrowserPing ( aTemp , sizeof ( aTemp ) , pSelectedServer ) ;
2010-05-29 07:25:38 +00:00
RightColumn . HSplitTop ( 15.0f , & Row , & RightColumn ) ;
2020-09-26 19:41:58 +00:00
TextRender ( ) - > SetCursor ( & Cursor , Row . x , Row . y + ( 15.f - FontSize ) / 2.f , FontSize , TEXTFLAG_RENDER | TEXTFLAG_STOP_AT_END ) ;
2011-01-30 16:21:41 +00:00
Cursor . m_LineWidth = Row . w ;
TextRender ( ) - > TextEx ( & Cursor , aTemp , - 1 ) ;
2008-09-04 18:42:26 +00:00
}
2010-05-29 07:25:38 +00:00
2008-09-04 18:42:26 +00:00
// server scoreboard
2020-09-16 01:30:03 +00:00
ServerScoreBoard . HSplitBottom ( 23.0f , & ServerScoreBoard , 0x0 ) ;
2010-05-29 07:25:38 +00:00
2011-06-26 15:10:13 +00:00
if ( pSelectedServer )
2008-09-04 18:42:26 +00:00
{
2023-01-05 11:21:10 +00:00
static CListBox s_ListBox ;
s_ListBox . DoAutoSpacing ( 1.0f ) ;
s_ListBox . DoStart ( 25.0f , pSelectedServer - > m_NumReceivedClients , 1 , 3 , - 1 , & ServerScoreBoard ) ;
2014-01-08 05:15:56 +00:00
2018-03-13 20:59:07 +00:00
for ( int i = 0 ; i < pSelectedServer - > m_NumReceivedClients ; i + + )
2008-08-27 15:48:50 +00:00
{
2023-01-05 11:21:10 +00:00
const CServerInfo : : CClient & CurrentClient = pSelectedServer - > m_aClients [ i ] ;
const CListboxItem Item = s_ListBox . DoNextItem ( & CurrentClient ) ;
2014-01-08 05:15:56 +00:00
if ( ! Item . m_Visible )
continue ;
2023-01-07 08:20:25 +00:00
const bool HasTeeToRender = pSelectedServer - > m_aClients [ i ] . m_aSkin [ 0 ] ! = ' \0 ' ;
CUIRect Skin , Name , Clan , Score , Flag ;
2023-01-05 11:21:10 +00:00
Name = Item . m_Rect ;
2011-06-26 15:10:13 +00:00
2023-01-05 11:21:10 +00:00
ColorRGBA Color = CurrentClient . m_FriendState = = IFriends : : FRIEND_NO ?
2020-09-26 19:41:58 +00:00
ColorRGBA ( 1.0f , 1.0f , 1.0f , ( i % 2 + 1 ) * 0.05f ) :
ColorRGBA ( 0.5f , 1.0f , 0.5f , 0.15f + ( i % 2 + 1 ) * 0.05f ) ;
2022-08-07 16:12:07 +00:00
Name . Draw ( Color , IGraphics : : CORNER_ALL , 4.0f ) ;
2023-01-07 08:20:25 +00:00
if ( HasTeeToRender )
{
Name . VSplitLeft ( 1.0f , nullptr , & Name ) ;
}
2014-01-24 21:09:52 +00:00
Name . VSplitLeft ( 34.0f , & Score , & Name ) ;
2023-01-07 08:20:25 +00:00
if ( HasTeeToRender )
{
Name . VSplitLeft ( 18.0f , & Skin , & Name ) ;
}
else
{
Name . VSplitLeft ( 5.0f , 0 , & Name ) ;
}
Name . VSplitRight ( HasTeeToRender ? 20.0 : 34.0f , & Name , & Flag ) ;
2011-04-04 18:37:12 +00:00
Flag . HMargin ( 4.0f , & Flag ) ;
2018-03-13 20:59:07 +00:00
Name . HSplitTop ( 12.0f , & Name , & Clan ) ;
2011-03-18 16:59:48 +00:00
// score
2014-02-19 13:24:26 +00:00
char aTemp [ 16 ] ;
2014-01-24 21:09:52 +00:00
2023-01-05 11:21:10 +00:00
if ( ! CurrentClient . m_Player )
2022-07-09 16:14:56 +00:00
str_copy ( aTemp , " SPEC " ) ;
2022-10-11 12:28:41 +00:00
else if ( ( str_find_nocase ( pSelectedServer - > m_aGameType , " race " ) | | str_find_nocase ( pSelectedServer - > m_aGameType , " fastcap " ) ) & & g_Config . m_ClDDRaceScoreBoard )
2014-02-19 13:24:26 +00:00
{
2023-01-05 11:21:10 +00:00
if ( CurrentClient . m_Score = = - 9999 | | CurrentClient . m_Score = = 0 )
2014-02-19 13:24:26 +00:00
aTemp [ 0 ] = 0 ;
else
2023-01-05 11:21:10 +00:00
str_time ( ( int64_t ) abs ( CurrentClient . m_Score ) * 100 , TIME_HOURS , aTemp , sizeof ( aTemp ) ) ;
2011-03-20 14:33:49 +00:00
}
2014-02-19 13:24:26 +00:00
else
2023-01-05 11:21:10 +00:00
str_format ( aTemp , sizeof ( aTemp ) , " %d " , CurrentClient . m_Score ) ;
2014-02-19 13:24:26 +00:00
2020-10-18 21:33:45 +00:00
float ScoreFontSize = 12.0f ;
while ( ScoreFontSize > = 4.0f & & TextRender ( ) - > TextWidth ( 0 , ScoreFontSize , aTemp , - 1 , - 1.0f ) > Score . w )
ScoreFontSize - - ;
TextRender ( ) - > SetCursor ( & Cursor , Score . x , Score . y + ( Score . h - ScoreFontSize ) / 2.0f , ScoreFontSize , TEXTFLAG_RENDER | TEXTFLAG_STOP_AT_END ) ;
2014-02-19 13:24:26 +00:00
Cursor . m_LineWidth = Score . w ;
TextRender ( ) - > TextEx ( & Cursor , aTemp , - 1 ) ;
2011-04-13 18:37:12 +00:00
2023-01-07 08:20:25 +00:00
// render tee if available
if ( HasTeeToRender )
{
CTeeRenderInfo TeeInfo ;
const CSkin * pSkin = m_pClient - > m_Skins . Find ( CurrentClient . m_aSkin ) ;
TeeInfo . m_OriginalRenderSkin = pSkin - > m_OriginalSkin ;
TeeInfo . m_ColorableRenderSkin = pSkin - > m_ColorableSkin ;
TeeInfo . m_SkinMetrics = pSkin - > m_Metrics ;
TeeInfo . m_CustomColoredSkin = CurrentClient . m_CustomSkinColors ;
if ( CurrentClient . m_CustomSkinColors )
{
TeeInfo . m_ColorBody = color_cast < ColorRGBA > ( ColorHSLA ( CurrentClient . m_CustomSkinColorBody ) . UnclampLighting ( ) ) ;
TeeInfo . m_ColorFeet = color_cast < ColorRGBA > ( ColorHSLA ( CurrentClient . m_CustomSkinColorFeet ) . UnclampLighting ( ) ) ;
}
else
{
TeeInfo . m_ColorBody = ColorRGBA ( 1.0f , 1.0f , 1.0f ) ;
TeeInfo . m_ColorFeet = ColorRGBA ( 1.0f , 1.0f , 1.0f ) ;
}
TeeInfo . m_Size = minimum ( Skin . w , Skin . h ) ;
CAnimState * pIdleState = CAnimState : : GetIdle ( ) ;
vec2 OffsetToMid ;
RenderTools ( ) - > GetRenderTeeOffsetToRenderedTee ( pIdleState , & TeeInfo , OffsetToMid ) ;
vec2 TeeRenderPos ( Skin . x + TeeInfo . m_Size / 2 , Skin . y + Skin . h / 2 + OffsetToMid . y ) ;
RenderTools ( ) - > RenderTee ( pIdleState , & TeeInfo , EMOTE_NORMAL , vec2 ( 1.0f , 0.0f ) , TeeRenderPos ) ;
}
2011-03-18 16:59:48 +00:00
// name
2018-03-13 20:59:07 +00:00
TextRender ( ) - > SetCursor ( & Cursor , Name . x , Name . y + ( Name . h - ( FontSize - 2 ) ) / 2.f , FontSize - 2 , TEXTFLAG_RENDER | TEXTFLAG_STOP_AT_END ) ;
2011-03-18 16:59:48 +00:00
Cursor . m_LineWidth = Name . w ;
2023-01-05 11:21:10 +00:00
const char * pName = CurrentClient . m_aName ;
2022-09-25 12:37:24 +00:00
bool Printed = false ;
2010-05-29 07:25:38 +00:00
if ( g_Config . m_BrFilterString [ 0 ] )
2022-12-23 22:23:44 +00:00
Printed = PrintHighlighted ( pName , [ this , & Cursor , pName ] ( const char * pFilteredStr , const int FilterLen ) {
TextRender ( ) - > TextEx ( & Cursor , pName , ( int ) ( pFilteredStr - pName ) ) ;
TextRender ( ) - > TextColor ( 0.4f , 0.4f , 1.0f , 1.0f ) ;
TextRender ( ) - > TextEx ( & Cursor , pFilteredStr , FilterLen ) ;
TextRender ( ) - > TextColor ( 1.0f , 1.0f , 1.0f , 1.0f ) ;
TextRender ( ) - > TextEx ( & Cursor , pFilteredStr + FilterLen , - 1 ) ;
} ) ;
2022-09-25 12:37:24 +00:00
if ( ! Printed )
2010-05-29 07:25:38 +00:00
TextRender ( ) - > TextEx ( & Cursor , pName , - 1 ) ;
2011-03-18 16:59:48 +00:00
// clan
2018-03-13 20:59:07 +00:00
TextRender ( ) - > SetCursor ( & Cursor , Clan . x , Clan . y + ( Clan . h - ( FontSize - 2 ) ) / 2.f , FontSize - 2 , TEXTFLAG_RENDER | TEXTFLAG_STOP_AT_END ) ;
2011-03-18 16:59:48 +00:00
Cursor . m_LineWidth = Clan . w ;
2023-01-05 11:21:10 +00:00
const char * pClan = CurrentClient . m_aClan ;
2022-09-25 12:37:24 +00:00
Printed = false ;
2011-03-18 16:59:48 +00:00
if ( g_Config . m_BrFilterString [ 0 ] )
2022-12-23 22:23:44 +00:00
Printed = PrintHighlighted ( pClan , [ this , & Cursor , pClan ] ( const char * pFilteredStr , const int FilterLen ) {
TextRender ( ) - > TextEx ( & Cursor , pClan , ( int ) ( pFilteredStr - pClan ) ) ;
TextRender ( ) - > TextColor ( 0.4f , 0.4f , 1.0f , 1.0f ) ;
TextRender ( ) - > TextEx ( & Cursor , pFilteredStr , FilterLen ) ;
TextRender ( ) - > TextColor ( 1.0f , 1.0f , 1.0f , 1.0f ) ;
TextRender ( ) - > TextEx ( & Cursor , pFilteredStr + FilterLen , - 1 ) ;
} ) ;
2022-09-25 12:37:24 +00:00
if ( ! Printed )
2011-03-18 16:59:48 +00:00
TextRender ( ) - > TextEx ( & Cursor , pClan , - 1 ) ;
// flag
2019-04-26 21:47:34 +00:00
ColorRGBA FColor ( 1.0f , 1.0f , 1.0f , 0.5f ) ;
2023-01-07 08:20:25 +00:00
m_pClient - > m_CountryFlags . Render ( CurrentClient . m_Country , & FColor , Flag . x ,
Flag . y + ( ( Flag . h - Flag . w / 2 ) / 2 ) ,
Flag . w , Flag . w / 2 ) ;
2008-08-27 15:48:50 +00:00
}
2014-01-10 11:22:48 +00:00
2023-01-05 11:21:10 +00:00
const int NewSelected = s_ListBox . DoEnd ( ) ;
if ( s_ListBox . WasItemSelected ( ) )
{
const CServerInfo : : CClient & SelectedClient = pSelectedServer - > m_aClients [ NewSelected ] ;
if ( SelectedClient . m_FriendState = = IFriends : : FRIEND_PLAYER )
m_pClient - > Friends ( ) - > RemoveFriend ( SelectedClient . m_aName , SelectedClient . m_aClan ) ;
else
m_pClient - > Friends ( ) - > AddFriend ( SelectedClient . m_aName , SelectedClient . m_aClan ) ;
FriendlistOnUpdate ( ) ;
Client ( ) - > ServerBrowserUpdate ( ) ;
}
2008-08-27 15:48:50 +00:00
}
2008-09-04 18:42:26 +00:00
}
2008-08-27 15:48:50 +00:00
2022-12-23 22:23:44 +00:00
template < typename F >
bool CMenus : : PrintHighlighted ( const char * pName , F & & PrintFn )
{
const char * pStr = g_Config . m_BrFilterString ;
char aFilterStr [ sizeof ( g_Config . m_BrFilterString ) ] ;
while ( ( pStr = str_next_token ( pStr , IServerBrowser : : SEARCH_EXCLUDE_TOKEN , aFilterStr , sizeof ( aFilterStr ) ) ) )
{
// highlight the parts that matches
const char * pFilteredStr ;
int FilterLen = str_length ( aFilterStr ) ;
if ( aFilterStr [ 0 ] = = ' " ' & & aFilterStr [ FilterLen - 1 ] = = ' " ' )
{
aFilterStr [ FilterLen - 1 ] = ' \0 ' ;
pFilteredStr = str_comp ( pName , & aFilterStr [ 1 ] ) = = 0 ? pName : nullptr ;
FilterLen - = 2 ;
}
else
{
pFilteredStr = str_utf8_find_nocase ( pName , aFilterStr ) ;
}
if ( pFilteredStr )
{
PrintFn ( pFilteredStr , FilterLen ) ;
return true ;
}
}
return false ;
}
2011-06-26 15:10:13 +00:00
void CMenus : : FriendlistOnUpdate ( )
{
2022-06-11 19:38:18 +00:00
m_vFriends . clear ( ) ;
2011-06-26 15:10:13 +00:00
for ( int i = 0 ; i < m_pClient - > Friends ( ) - > NumFriends ( ) ; + + i )
2022-06-11 19:38:18 +00:00
m_vFriends . emplace_back ( m_pClient - > Friends ( ) - > GetFriend ( i ) ) ;
std : : sort ( m_vFriends . begin ( ) , m_vFriends . end ( ) ) ;
2011-06-26 15:10:13 +00:00
}
2011-03-23 12:06:35 +00:00
void CMenus : : RenderServerbrowserFriends ( CUIRect View )
2008-09-04 18:42:26 +00:00
{
2011-06-26 15:10:13 +00:00
static int s_Inited = 0 ;
if ( ! s_Inited )
{
FriendlistOnUpdate ( ) ;
s_Inited = 1 ;
}
2011-03-23 12:06:35 +00:00
CUIRect ServerFriends = View , FilterHeader ;
2011-06-26 15:10:13 +00:00
const float FontSize = 10.0f ;
2011-03-23 12:06:35 +00:00
2020-09-16 01:30:03 +00:00
ServerFriends . HSplitBottom ( 18.0f , & ServerFriends , NULL ) ;
2011-03-23 12:06:35 +00:00
// header
ServerFriends . HSplitTop ( ms_ListheaderHeight , & FilterHeader , & ServerFriends ) ;
2022-08-07 16:12:07 +00:00
FilterHeader . Draw ( ColorRGBA ( 1 , 1 , 1 , 0.25f ) , IGraphics : : CORNER_T , 4.0f ) ;
ServerFriends . Draw ( ColorRGBA ( 0 , 0 , 0 , 0.15f ) , 0 , 4.0f ) ;
2022-06-12 08:34:09 +00:00
UI ( ) - > DoLabel ( & FilterHeader , Localize ( " Friends " ) , FontSize + 4.0f , TEXTALIGN_CENTER ) ;
2010-05-29 07:25:38 +00:00
2023-01-05 11:21:10 +00:00
CUIRect List ;
2011-03-23 12:06:35 +00:00
ServerFriends . Margin ( 3.0f , & ServerFriends ) ;
2011-06-26 15:10:13 +00:00
ServerFriends . VMargin ( 3.0f , & ServerFriends ) ;
2011-03-23 12:06:35 +00:00
ServerFriends . HSplitBottom ( 100.0f , & List , & ServerFriends ) ;
2010-05-29 07:25:38 +00:00
2011-03-23 12:06:35 +00:00
// friends list(remove friend)
2023-01-05 11:21:10 +00:00
static CListBox s_ListBox ;
2022-06-11 19:38:18 +00:00
if ( m_FriendlistSelectedIndex > = ( int ) m_vFriends . size ( ) )
m_FriendlistSelectedIndex = m_vFriends . size ( ) - 1 ;
2023-01-05 11:21:10 +00:00
s_ListBox . DoAutoSpacing ( 3.0f ) ;
s_ListBox . DoStart ( 30.0f , m_vFriends . size ( ) , 1 , 3 , m_FriendlistSelectedIndex , & List ) ;
2011-04-13 18:37:12 +00:00
2022-06-11 19:38:18 +00:00
std : : sort ( m_vFriends . begin ( ) , m_vFriends . end ( ) ) ;
2023-01-05 11:21:10 +00:00
for ( size_t i = 0 ; i < m_vFriends . size ( ) ; + + i )
2011-03-23 12:06:35 +00:00
{
2023-01-05 11:21:10 +00:00
const auto & Friend = m_vFriends [ i ] ;
const CListboxItem Item = s_ListBox . DoNextItem ( & Friend , m_FriendlistSelectedIndex > = 0 & & ( size_t ) m_FriendlistSelectedIndex = = i ) ;
if ( ! Item . m_Visible )
continue ;
2011-04-13 18:37:12 +00:00
2023-01-05 11:21:10 +00:00
CUIRect NameClanLabels , NameLabel , ClanLabel , OnState ;
Item . m_Rect . VSplitRight ( 30.0f , & NameClanLabels , & OnState ) ;
NameClanLabels . Draw ( ColorRGBA ( 1.0f , 1.0f , 1.0f , 0.1f ) , IGraphics : : CORNER_L , 4.0f ) ;
NameClanLabels . VMargin ( 2.5f , & NameClanLabels ) ;
NameClanLabels . HSplitTop ( 12.0f , & NameLabel , & ClanLabel ) ;
UI ( ) - > DoLabel ( & NameLabel , Friend . m_pFriendInfo - > m_aName , FontSize , TEXTALIGN_LEFT ) ;
UI ( ) - > DoLabel ( & ClanLabel , Friend . m_pFriendInfo - > m_aClan , FontSize , TEXTALIGN_LEFT ) ;
OnState . Draw ( Friend . m_NumFound ? ColorRGBA ( 0.0f , 1.0f , 0.0f , 0.25f ) : ColorRGBA ( 1.0f , 0.0f , 0.0f , 0.25f ) , IGraphics : : CORNER_R , 4.0f ) ;
OnState . HMargin ( ( OnState . h - FontSize ) / 3 , & OnState ) ;
OnState . VMargin ( 5.0f , & OnState ) ;
char aBuf [ 64 ] ;
str_format ( aBuf , sizeof ( aBuf ) , " %i " , Friend . m_NumFound ) ;
UI ( ) - > DoLabel ( & OnState , aBuf , FontSize + 2 , TEXTALIGN_RIGHT ) ;
2011-03-23 12:06:35 +00:00
}
2011-04-13 18:37:12 +00:00
2023-01-05 11:21:10 +00:00
m_FriendlistSelectedIndex = s_ListBox . DoEnd ( ) ;
2011-06-26 15:10:13 +00:00
// activate found server with friend
2023-01-05 11:21:10 +00:00
if ( s_ListBox . WasItemActivated ( ) & & m_vFriends [ m_FriendlistSelectedIndex ] . m_NumFound )
2011-06-26 15:10:13 +00:00
{
bool Found = false ;
int NumServers = ServerBrowser ( ) - > NumSortedServers ( ) ;
2018-03-13 20:59:07 +00:00
for ( int i = 0 ; i < NumServers & & ! Found ; i + + )
2011-06-26 15:10:13 +00:00
{
2020-09-26 19:41:58 +00:00
int ItemIndex = m_SelectedIndex ! = - 1 ? ( m_SelectedIndex + i + 1 ) % NumServers : i ;
2011-06-26 15:10:13 +00:00
const CServerInfo * pItem = ServerBrowser ( ) - > SortedGet ( ItemIndex ) ;
if ( pItem - > m_FriendState ! = IFriends : : FRIEND_NO )
{
2017-03-29 10:56:13 +00:00
for ( int j = 0 ; j < pItem - > m_NumReceivedClients & & ! Found ; + + j )
2011-06-26 15:10:13 +00:00
{
if ( pItem - > m_aClients [ j ] . m_FriendState ! = IFriends : : FRIEND_NO & &
2022-06-11 19:38:18 +00:00
( ( g_Config . m_ClFriendsIgnoreClan & & m_vFriends [ m_FriendlistSelectedIndex ] . m_pFriendInfo - > m_aName [ 0 ] ) | | str_quickhash ( pItem - > m_aClients [ j ] . m_aClan ) = = m_vFriends [ m_FriendlistSelectedIndex ] . m_pFriendInfo - > m_ClanHash ) & &
( ! m_vFriends [ m_FriendlistSelectedIndex ] . m_pFriendInfo - > m_aName [ 0 ] | |
str_quickhash ( pItem - > m_aClients [ j ] . m_aName ) = = m_vFriends [ m_FriendlistSelectedIndex ] . m_pFriendInfo - > m_NameHash ) )
2011-06-26 15:10:13 +00:00
{
2022-07-09 16:14:56 +00:00
str_copy ( g_Config . m_UiServerAddress , pItem - > m_aAddress ) ;
2011-06-26 15:10:13 +00:00
m_SelectedIndex = ItemIndex ;
Found = true ;
}
}
}
}
}
2011-03-23 12:06:35 +00:00
2023-01-05 11:21:10 +00:00
CUIRect Button ;
2011-03-23 12:06:35 +00:00
ServerFriends . HSplitTop ( 2.5f , 0 , & ServerFriends ) ;
ServerFriends . HSplitTop ( 20.0f , & Button , & ServerFriends ) ;
if ( m_FriendlistSelectedIndex ! = - 1 )
{
2022-07-16 13:32:06 +00:00
static CButtonContainer s_RemoveButton ;
2011-03-23 12:06:35 +00:00
if ( DoButton_Menu ( & s_RemoveButton , Localize ( " Remove " ) , 0 , & Button ) )
2022-11-30 21:50:51 +00:00
{
const CFriendInfo * pRemoveFriend = m_vFriends [ m_FriendlistSelectedIndex ] . m_pFriendInfo ;
const bool IsPlayer = m_pClient - > Friends ( ) - > GetFriendState ( pRemoveFriend - > m_aName , pRemoveFriend - > m_aClan ) = = IFriends : : FRIEND_PLAYER ;
char aBuf [ 256 ] ;
str_format ( aBuf , sizeof ( aBuf ) ,
IsPlayer ? Localize ( " Are you sure that you want to remove the player '%s' from your friends list? " ) : Localize ( " Are you sure that you want to remove the clan '%s' from your friends list? " ) ,
IsPlayer ? pRemoveFriend - > m_aName : pRemoveFriend - > m_aClan ) ;
PopupConfirm ( Localize ( " Remove friend " ) , aBuf , Localize ( " Yes " ) , Localize ( " No " ) , & CMenus : : PopupConfirmRemoveFriend ) ;
}
2011-03-23 12:06:35 +00:00
}
// add friend
if ( m_pClient - > Friends ( ) - > NumFriends ( ) < IFriends : : MAX_FRIENDS )
{
ServerFriends . HSplitTop ( 10.0f , 0 , & ServerFriends ) ;
ServerFriends . HSplitTop ( 19.0f , & Button , & ServerFriends ) ;
char aBuf [ 64 ] ;
str_format ( aBuf , sizeof ( aBuf ) , " %s: " , Localize ( " Name " ) ) ;
2022-06-12 08:34:09 +00:00
UI ( ) - > DoLabel ( & Button , aBuf , FontSize + 2 , TEXTALIGN_LEFT ) ;
2011-03-23 12:06:35 +00:00
Button . VSplitLeft ( 80.0f , 0 , & Button ) ;
static char s_aName [ MAX_NAME_LENGTH ] = { 0 } ;
static float s_OffsetName = 0.0f ;
2022-08-07 20:03:34 +00:00
UI ( ) - > DoEditBox ( & s_aName , & Button , s_aName , sizeof ( s_aName ) , FontSize + 2 , & s_OffsetName ) ;
2011-03-23 12:06:35 +00:00
ServerFriends . HSplitTop ( 3.0f , 0 , & ServerFriends ) ;
ServerFriends . HSplitTop ( 19.0f , & Button , & ServerFriends ) ;
str_format ( aBuf , sizeof ( aBuf ) , " %s: " , Localize ( " Clan " ) ) ;
2022-06-12 08:34:09 +00:00
UI ( ) - > DoLabel ( & Button , aBuf , FontSize + 2 , TEXTALIGN_LEFT ) ;
2011-03-23 12:06:35 +00:00
Button . VSplitLeft ( 80.0f , 0 , & Button ) ;
static char s_aClan [ MAX_CLAN_LENGTH ] = { 0 } ;
static float s_OffsetClan = 0.0f ;
2022-08-07 20:03:34 +00:00
UI ( ) - > DoEditBox ( & s_aClan , & Button , s_aClan , sizeof ( s_aClan ) , FontSize + 2 , & s_OffsetClan ) ;
2011-03-23 12:06:35 +00:00
ServerFriends . HSplitTop ( 3.0f , 0 , & ServerFriends ) ;
ServerFriends . HSplitTop ( 20.0f , & Button , & ServerFriends ) ;
2022-07-16 13:32:06 +00:00
static CButtonContainer s_AddButton ;
2011-06-26 15:10:13 +00:00
if ( DoButton_Menu ( & s_AddButton , Localize ( " Add Friend " ) , 0 , & Button ) )
2011-03-23 12:06:35 +00:00
{
m_pClient - > Friends ( ) - > AddFriend ( s_aName , s_aClan ) ;
2011-06-26 15:10:13 +00:00
FriendlistOnUpdate ( ) ;
2011-03-23 12:06:35 +00:00
Client ( ) - > ServerBrowserUpdate ( ) ;
}
}
}
2022-11-30 21:50:51 +00:00
void CMenus : : PopupConfirmRemoveFriend ( )
{
const CFriendInfo * pRemoveFriend = m_vFriends [ m_FriendlistSelectedIndex ] . m_pFriendInfo ;
m_pClient - > Friends ( ) - > RemoveFriend ( pRemoveFriend - > m_aName , pRemoveFriend - > m_aClan ) ;
FriendlistOnUpdate ( ) ;
Client ( ) - > ServerBrowserUpdate ( ) ;
}
2010-05-29 07:25:38 +00:00
void CMenus : : RenderServerbrowser ( CUIRect MainView )
2008-09-04 18:42:26 +00:00
{
/*
2011-04-13 18:37:12 +00:00
+ - - - - - - - - - - - - - - - - - + + - - - - - - - +
| | | |
| | | tool |
| server list | | box |
| | | |
| | | |
+ - - - - - - - - - - - - - - - - - + | |
status box tab + - - - - - - - +
2008-09-04 18:42:26 +00:00
*/
2010-05-29 07:25:38 +00:00
2020-09-16 01:30:03 +00:00
CUIRect ServerList , ToolBox ;
2010-05-29 07:25:38 +00:00
2011-03-18 16:59:48 +00:00
// background
2022-08-07 16:12:07 +00:00
MainView . Draw ( ms_ColorTabbarActive , IGraphics : : CORNER_B , 10.0f ) ;
2011-03-18 16:59:48 +00:00
MainView . Margin ( 10.0f , & MainView ) ;
2008-08-27 15:48:50 +00:00
2011-03-18 16:59:48 +00:00
// create server list, status box, tab bar and tool box area
MainView . VSplitRight ( 205.0f , & ServerList , & ToolBox ) ;
ServerList . VSplitRight ( 5.0f , & ServerList , 0 ) ;
2008-09-04 18:42:26 +00:00
2011-03-18 16:59:48 +00:00
// server list
{
RenderServerbrowserServerList ( ServerList ) ;
}
2010-05-29 07:25:38 +00:00
int ToolboxPage = g_Config . m_UiToolboxPage ;
2020-09-16 01:30:03 +00:00
// tool box
{
2022-08-07 16:12:07 +00:00
ToolBox . Draw ( ColorRGBA ( 0.0f , 0.0f , 0.0f , 0.15f ) , IGraphics : : CORNER_ALL , 4.0f ) ;
2020-09-16 01:30:03 +00:00
if ( ToolboxPage = = 0 )
RenderServerbrowserFilters ( ToolBox ) ;
else if ( ToolboxPage = = 1 )
RenderServerbrowserServerDetail ( ToolBox ) ;
else if ( ToolboxPage = = 2 )
RenderServerbrowserFriends ( ToolBox ) ;
}
2011-03-18 16:59:48 +00:00
// tab bar
2008-09-04 18:42:26 +00:00
{
2020-09-16 01:30:03 +00:00
CUIRect TabBar ;
ToolBox . HSplitBottom ( 18 , & ToolBox , & TabBar ) ;
2011-03-23 12:06:35 +00:00
CUIRect TabButton0 , TabButton1 , TabButton2 ;
2020-09-16 01:30:03 +00:00
float CurTabBarWidth = ToolBox . w ;
TabBar . VSplitLeft ( 0.333f * CurTabBarWidth , & TabButton0 , & TabBar ) ;
TabBar . VSplitLeft ( 0.333f * CurTabBarWidth , & TabButton1 , & TabBar ) ;
TabBar . VSplitLeft ( 0.333f * CurTabBarWidth , & TabButton2 , & TabBar ) ;
2019-04-26 21:47:34 +00:00
ColorRGBA Active = ms_ColorTabbarActive ;
ColorRGBA InActive = ms_ColorTabbarInactive ;
ms_ColorTabbarActive = ColorRGBA ( 0.0f , 0.0f , 0.0f , 0.3f ) ;
ms_ColorTabbarInactive = ColorRGBA ( 0.0f , 0.0f , 0.0f , 0.15f ) ;
2010-05-29 07:25:38 +00:00
2022-07-16 13:32:06 +00:00
static CButtonContainer s_FiltersTab ;
2022-07-26 19:17:29 +00:00
if ( DoButton_MenuTab ( & s_FiltersTab , Localize ( " Filter " ) , ToolboxPage = = 0 , & TabButton0 , IGraphics : : CORNER_BL , NULL , NULL , NULL , NULL , 4.0f ) )
2010-05-29 07:25:38 +00:00
ToolboxPage = 0 ;
2022-07-16 13:32:06 +00:00
static CButtonContainer s_InfoTab ;
2020-10-26 01:10:55 +00:00
if ( DoButton_MenuTab ( & s_InfoTab , Localize ( " Info " ) , ToolboxPage = = 1 , & TabButton1 , 0 , NULL , NULL , NULL , NULL , 4.0f ) )
2010-05-29 07:25:38 +00:00
ToolboxPage = 1 ;
2008-09-04 18:42:26 +00:00
2022-07-16 13:32:06 +00:00
static CButtonContainer s_FriendsTab ;
2022-07-26 19:17:29 +00:00
if ( DoButton_MenuTab ( & s_FriendsTab , Localize ( " Friends " ) , ToolboxPage = = 2 , & TabButton2 , IGraphics : : CORNER_BR , NULL , NULL , NULL , NULL , 4.0f ) )
2011-03-23 12:06:35 +00:00
ToolboxPage = 2 ;
2010-05-29 07:25:38 +00:00
2011-03-18 16:59:48 +00:00
ms_ColorTabbarActive = Active ;
ms_ColorTabbarInactive = InActive ;
g_Config . m_UiToolboxPage = ToolboxPage ;
}
2008-08-27 15:48:50 +00:00
}
2010-07-04 14:10:00 +00:00
2011-06-26 15:10:13 +00:00
void CMenus : : ConchainFriendlistUpdate ( IConsole : : IResult * pResult , void * pUserData , IConsole : : FCommandCallback pfnCallback , void * pCallbackUserData )
{
pfnCallback ( pResult , pCallbackUserData ) ;
if ( pResult - > NumArguments ( ) = = 2 & & ( ( CMenus * ) pUserData ) - > Client ( ) - > State ( ) = = IClient : : STATE_OFFLINE )
{
( ( CMenus * ) pUserData ) - > FriendlistOnUpdate ( ) ;
( ( CMenus * ) pUserData ) - > Client ( ) - > ServerBrowserUpdate ( ) ;
}
}
2010-07-04 14:10:00 +00:00
void CMenus : : ConchainServerbrowserUpdate ( IConsole : : IResult * pResult , void * pUserData , IConsole : : FCommandCallback pfnCallback , void * pCallbackUserData )
{
2011-08-13 00:11:06 +00:00
pfnCallback ( pResult , pCallbackUserData ) ;
2018-06-17 02:26:23 +00:00
if ( pResult - > NumArguments ( ) & & g_Config . m_UiPage = = PAGE_FAVORITES )
2010-07-04 14:10:00 +00:00
( ( CMenus * ) pUserData ) - > ServerBrowser ( ) - > Refresh ( IServerBrowser : : TYPE_FAVORITES ) ;
}