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. */
|
2011-03-23 12:06:35 +00:00
|
|
|
#include <engine/config.h>
|
|
|
|
#include <engine/friends.h>
|
2011-03-18 16:59:48 +00:00
|
|
|
#include <engine/graphics.h>
|
|
|
|
#include <engine/keys.h>
|
2010-05-29 07:25:38 +00:00
|
|
|
#include <engine/serverbrowser.h>
|
|
|
|
#include <engine/textrender.h>
|
|
|
|
#include <engine/shared/config.h>
|
2011-03-18 16:59:48 +00:00
|
|
|
|
2010-05-29 07:25:38 +00:00
|
|
|
#include <game/generated/client_data.h>
|
2011-03-18 16:59:48 +00:00
|
|
|
#include <game/generated/protocol.h>
|
2010-05-29 07:25:38 +00:00
|
|
|
|
|
|
|
#include <game/localization.h>
|
|
|
|
#include <game/version.h>
|
2011-03-18 16:59:48 +00:00
|
|
|
#include <game/client/render.h>
|
|
|
|
#include <game/client/ui.h>
|
|
|
|
#include <game/client/components/countryflags.h>
|
|
|
|
|
|
|
|
#include "menus.h"
|
|
|
|
|
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);
|
|
|
|
View.HSplitBottom(28.0f, &View, &Status);
|
2008-08-27 15:48:50 +00:00
|
|
|
|
|
|
|
// split of the scrollbar
|
2010-05-29 07:25:38 +00:00
|
|
|
RenderTools()->DrawUIRect(&Headers, vec4(1,1,1,0.25f), CUI::CORNER_T, 5.0f);
|
|
|
|
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;
|
|
|
|
int m_Flags;
|
|
|
|
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
|
|
|
|
{
|
|
|
|
FIXED=1,
|
|
|
|
SPACER=2,
|
2010-05-29 07:25:38 +00:00
|
|
|
|
2008-09-03 20:03:01 +00:00
|
|
|
COL_FLAG_LOCK=0,
|
2009-01-11 10:40:14 +00:00
|
|
|
COL_FLAG_PURE,
|
2008-09-03 20:03:01 +00:00
|
|
|
COL_FLAG_FAV,
|
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
|
|
|
|
|
|
|
static CColumn s_aCols[] = {
|
2008-09-03 20:03:01 +00:00
|
|
|
{-1, -1, " ", -1, 2.0f, 0, {0}, {0}},
|
|
|
|
{COL_FLAG_LOCK, -1, " ", -1, 14.0f, 0, {0}, {0}},
|
2009-01-11 10:40:14 +00:00
|
|
|
{COL_FLAG_PURE, -1, " ", -1, 14.0f, 0, {0}, {0}},
|
2008-09-03 20:03:01 +00:00
|
|
|
{COL_FLAG_FAV, -1, " ", -1, 14.0f, 0, {0}, {0}},
|
2011-04-13 18:37:12 +00:00
|
|
|
{COL_NAME, IServerBrowser::SORT_NAME, "Name", 0, 300.0f, 0, {0}, {0}}, // Localize - these strings are localized within CLocConstString
|
2010-05-31 11:07:58 +00:00
|
|
|
{COL_GAMETYPE, IServerBrowser::SORT_GAMETYPE, "Type", 1, 50.0f, 0, {0}, {0}},
|
|
|
|
{COL_MAP, IServerBrowser::SORT_MAP, "Map", 1, 100.0f, 0, {0}, {0}},
|
|
|
|
{COL_PLAYERS, IServerBrowser::SORT_NUMPLAYERS, "Players", 1, 60.0f, 0, {0}, {0}},
|
2008-08-27 15:48:50 +00:00
|
|
|
{-1, -1, " ", 1, 10.0f, 0, {0}, {0}},
|
2010-05-31 11:07:58 +00:00
|
|
|
{COL_PING, IServerBrowser::SORT_PING, "Ping", 1, 40.0f, FIXED, {0}, {0}},
|
2014-06-16 11:29:18 +00:00
|
|
|
#if defined(__ANDROID__)
|
|
|
|
{-1, -1, " ", 1, 50.0f, 0, {0}, {0}}, // Scrollbar
|
|
|
|
#endif
|
2008-08-27 15:48:50 +00:00
|
|
|
};
|
2010-08-08 22:35:37 +00:00
|
|
|
// This is just for scripts/update_localization.py to work correctly (all other strings are already Localize()'d somewhere else). Don't remove!
|
|
|
|
// Localize("Type");
|
2010-05-29 07:25:38 +00:00
|
|
|
|
|
|
|
int NumCols = sizeof(s_aCols)/sizeof(CColumn);
|
|
|
|
|
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);
|
|
|
|
|
|
|
|
if(i+1 < NumCols)
|
2008-08-27 15:48:50 +00:00
|
|
|
{
|
2010-05-29 07:25:38 +00:00
|
|
|
//Cols[i].flags |= SPACER;
|
|
|
|
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
|
|
|
|
|
|
|
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
|
|
|
|
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
|
|
|
{
|
2010-05-29 07:25:38 +00:00
|
|
|
if(DoButton_GridHeader(s_aCols[i].m_Caption, s_aCols[i].m_Caption, g_Config.m_BrSort == s_aCols[i].m_Sort, &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)
|
|
|
|
g_Config.m_BrSortOrder ^= 1;
|
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
|
|
|
|
|
|
|
RenderTools()->DrawUIRect(&View, vec4(0,0,0,0.15f), 0, 0);
|
|
|
|
|
|
|
|
CUIRect Scroll;
|
2014-06-16 11:29:18 +00:00
|
|
|
#if defined(__ANDROID__)
|
|
|
|
View.VSplitRight(50, &View, &Scroll);
|
|
|
|
#else
|
2010-05-29 07:25:38 +00:00
|
|
|
View.VSplitRight(15, &View, &Scroll);
|
2014-06-16 11:29:18 +00:00
|
|
|
#endif
|
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;
|
|
|
|
MsgBox.y += View.h/3;
|
|
|
|
|
|
|
|
if(m_ActivePage == PAGE_INTERNET && ServerBrowser()->IsRefreshingMasters())
|
2010-12-14 00:20:47 +00:00
|
|
|
UI()->DoLabelScaled(&MsgBox, Localize("Refreshing master servers"), 16.0f, 0);
|
2010-05-29 07:25:38 +00:00
|
|
|
else if(!ServerBrowser()->NumServers())
|
2010-12-14 00:20:47 +00:00
|
|
|
UI()->DoLabelScaled(&MsgBox, Localize("No servers found"), 16.0f, 0);
|
2010-05-29 07:25:38 +00:00
|
|
|
else if(ServerBrowser()->NumServers() && !NumServers)
|
2010-12-14 00:20:47 +00:00
|
|
|
UI()->DoLabelScaled(&MsgBox, Localize("No servers match your filter criteria"), 16.0f, 0);
|
2009-01-21 20:39:48 +00:00
|
|
|
}
|
2008-09-07 21:13:24 +00:00
|
|
|
|
2010-09-29 22:32:45 +00:00
|
|
|
int Num = (int)(View.h/s_aCols[0].m_Rect.h) + 1;
|
2010-05-29 07:25:38 +00:00
|
|
|
static int s_ScrollBar = 0;
|
|
|
|
static float s_ScrollValue = 0;
|
|
|
|
|
|
|
|
Scroll.HMargin(5.0f, &Scroll);
|
|
|
|
s_ScrollValue = DoScrollbarV(&s_ScrollBar, &Scroll, s_ScrollValue);
|
|
|
|
|
2010-09-29 22:32:45 +00:00
|
|
|
int ScrollNum = NumServers-Num+1;
|
2010-05-29 07:25:38 +00:00
|
|
|
if(ScrollNum > 0)
|
2008-08-27 15:48:50 +00:00
|
|
|
{
|
2011-06-26 15:10:13 +00:00
|
|
|
if(m_ScrollOffset)
|
|
|
|
{
|
|
|
|
s_ScrollValue = (float)(m_ScrollOffset)/ScrollNum;
|
|
|
|
m_ScrollOffset = 0;
|
|
|
|
}
|
2011-05-10 17:16:22 +00:00
|
|
|
if(Input()->KeyPresses(KEY_MOUSE_WHEEL_UP) && UI()->MouseInside(&View))
|
2011-01-22 12:57:26 +00:00
|
|
|
s_ScrollValue -= 3.0f/ScrollNum;
|
2011-05-10 17:16:22 +00:00
|
|
|
if(Input()->KeyPresses(KEY_MOUSE_WHEEL_DOWN) && UI()->MouseInside(&View))
|
2011-01-22 12:57:26 +00:00
|
|
|
s_ScrollValue += 3.0f/ScrollNum;
|
2008-08-27 15:48:50 +00:00
|
|
|
}
|
|
|
|
else
|
2010-05-29 07:25:38 +00:00
|
|
|
ScrollNum = 0;
|
2011-04-13 18:37:12 +00:00
|
|
|
|
|
|
|
if(m_SelectedIndex > -1)
|
2010-05-29 07:25:38 +00:00
|
|
|
{
|
|
|
|
for(int i = 0; i < m_NumInputEvents; i++)
|
|
|
|
{
|
|
|
|
int NewIndex = -1;
|
|
|
|
if(m_aInputEvents[i].m_Flags&IInput::FLAG_PRESS)
|
|
|
|
{
|
|
|
|
if(m_aInputEvents[i].m_Key == KEY_DOWN) NewIndex = m_SelectedIndex + 1;
|
|
|
|
if(m_aInputEvents[i].m_Key == KEY_UP) NewIndex = m_SelectedIndex - 1;
|
|
|
|
}
|
|
|
|
if(NewIndex > -1 && NewIndex < NumServers)
|
|
|
|
{
|
2011-04-13 18:37:12 +00:00
|
|
|
//scroll
|
|
|
|
float IndexY = View.y - s_ScrollValue*ScrollNum*s_aCols[0].m_Rect.h + NewIndex*s_aCols[0].m_Rect.h;
|
2010-09-29 23:13:12 +00:00
|
|
|
int Scroll = View.y > IndexY ? -1 : View.y+View.h < IndexY+s_aCols[0].m_Rect.h ? 1 : 0;
|
2011-04-13 18:37:12 +00:00
|
|
|
if(Scroll)
|
2010-09-29 23:13:12 +00:00
|
|
|
{
|
|
|
|
if(Scroll < 0)
|
|
|
|
{
|
|
|
|
int NumScrolls = (View.y-IndexY+s_aCols[0].m_Rect.h-1.0f)/s_aCols[0].m_Rect.h;
|
|
|
|
s_ScrollValue -= (1.0f/ScrollNum)*NumScrolls;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
int NumScrolls = (IndexY+s_aCols[0].m_Rect.h-(View.y+View.h)+s_aCols[0].m_Rect.h-1.0f)/s_aCols[0].m_Rect.h;
|
|
|
|
s_ScrollValue += (1.0f/ScrollNum)*NumScrolls;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2010-05-29 07:25:38 +00:00
|
|
|
m_SelectedIndex = NewIndex;
|
2011-04-13 18:37:12 +00:00
|
|
|
|
2010-05-29 07:25:38 +00:00
|
|
|
const CServerInfo *pItem = ServerBrowser()->SortedGet(m_SelectedIndex);
|
|
|
|
str_copy(g_Config.m_UiServerAddress, pItem->m_aAddress, sizeof(g_Config.m_UiServerAddress));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2011-04-13 18:37:12 +00:00
|
|
|
|
|
|
|
if(s_ScrollValue < 0) s_ScrollValue = 0;
|
|
|
|
if(s_ScrollValue > 1) s_ScrollValue = 1;
|
2008-08-27 15:48:50 +00:00
|
|
|
|
|
|
|
// set clipping
|
2010-05-29 07:25:38 +00:00
|
|
|
UI()->ClipEnable(&View);
|
|
|
|
|
|
|
|
CUIRect OriginalView = View;
|
|
|
|
View.y -= s_ScrollValue*ScrollNum*s_aCols[0].m_Rect.h;
|
2008-08-27 15:48:50 +00:00
|
|
|
|
2010-05-29 07:25:38 +00:00
|
|
|
int NewSelected = -1;
|
2014-06-27 08:13:57 +00:00
|
|
|
#if defined(__ANDROID__)
|
2014-06-16 11:29:18 +00:00
|
|
|
int DoubleClicked = 0;
|
2014-06-27 08:13:57 +00:00
|
|
|
#endif
|
2010-05-29 07:25:38 +00:00
|
|
|
int NumPlayers = 0;
|
2008-09-04 18:42:26 +00:00
|
|
|
|
2010-05-29 07:25:38 +00:00
|
|
|
m_SelectedIndex = -1;
|
|
|
|
|
2011-06-26 15:10:13 +00:00
|
|
|
// reset friend counter
|
|
|
|
for(int i = 0; i < m_lFriends.size(); m_lFriends[i++].m_NumFound = 0);
|
2010-05-29 07:25:38 +00:00
|
|
|
|
|
|
|
for (int i = 0; i < NumServers; i++)
|
2008-08-27 15:48:50 +00:00
|
|
|
{
|
2010-05-29 07:25:38 +00:00
|
|
|
int ItemIndex = i;
|
|
|
|
const CServerInfo *pItem = ServerBrowser()->SortedGet(ItemIndex);
|
2012-04-20 19:50:25 +00:00
|
|
|
NumPlayers += g_Config.m_BrFilterSpectators ? pItem->m_NumPlayers : pItem->m_NumClients;
|
2010-05-29 07:25:38 +00:00
|
|
|
CUIRect Row;
|
2011-04-13 18:37:12 +00:00
|
|
|
CUIRect SelectHitBox;
|
2010-05-29 07:25:38 +00:00
|
|
|
|
|
|
|
int Selected = str_comp(pItem->m_aAddress, g_Config.m_UiServerAddress) == 0; //selected_index==ItemIndex;
|
2008-08-27 15:48:50 +00:00
|
|
|
|
2014-06-16 11:29:18 +00:00
|
|
|
View.HSplitTop(ms_ListheaderHeight, &Row, &View);
|
2010-05-29 07:25:38 +00:00
|
|
|
SelectHitBox = Row;
|
|
|
|
|
|
|
|
if(Selected)
|
|
|
|
m_SelectedIndex = i;
|
2008-08-27 15:48:50 +00:00
|
|
|
|
2011-06-26 15:10:13 +00:00
|
|
|
// update friend counter
|
|
|
|
if(pItem->m_FriendState != IFriends::FRIEND_NO)
|
|
|
|
{
|
|
|
|
for(int j = 0; j < pItem->m_NumClients; ++j)
|
|
|
|
{
|
|
|
|
if(pItem->m_aClients[j].m_FriendState != IFriends::FRIEND_NO)
|
|
|
|
{
|
|
|
|
unsigned NameHash = str_quickhash(pItem->m_aClients[j].m_aName);
|
|
|
|
unsigned ClanHash = str_quickhash(pItem->m_aClients[j].m_aClan);
|
|
|
|
for(int f = 0; f < m_lFriends.size(); ++f)
|
|
|
|
{
|
|
|
|
if(ClanHash == m_lFriends[f].m_pFriendInfo->m_ClanHash &&
|
|
|
|
(!m_lFriends[f].m_pFriendInfo->m_aName[0] || NameHash == m_lFriends[f].m_pFriendInfo->m_NameHash))
|
|
|
|
{
|
|
|
|
m_lFriends[f].m_NumFound++;
|
2011-07-05 21:23:33 +00:00
|
|
|
if(m_lFriends[f].m_pFriendInfo->m_aName[0])
|
|
|
|
break;
|
2011-06-26 15:10:13 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2008-08-27 15:48:50 +00:00
|
|
|
// make sure that only those in view can be selected
|
2010-05-29 07:25:38 +00:00
|
|
|
if(Row.y+Row.h > OriginalView.y && Row.y < OriginalView.y+OriginalView.h)
|
2008-08-27 15:48:50 +00:00
|
|
|
{
|
2010-05-29 07:25:38 +00:00
|
|
|
if(Selected)
|
|
|
|
{
|
|
|
|
CUIRect r = Row;
|
|
|
|
r.Margin(1.5f, &r);
|
|
|
|
RenderTools()->DrawUIRect(&r, vec4(1,1,1,0.5f), CUI::CORNER_ALL, 4.0f);
|
|
|
|
}
|
|
|
|
|
|
|
|
// clip the selection
|
|
|
|
if(SelectHitBox.y < OriginalView.y) // top
|
2008-08-27 15:48:50 +00:00
|
|
|
{
|
2010-05-29 07:25:38 +00:00
|
|
|
SelectHitBox.h -= OriginalView.y-SelectHitBox.y;
|
|
|
|
SelectHitBox.y = OriginalView.y;
|
2008-08-27 15:48:50 +00:00
|
|
|
}
|
2010-05-29 07:25:38 +00:00
|
|
|
else if(SelectHitBox.y+SelectHitBox.h > OriginalView.y+OriginalView.h) // bottom
|
|
|
|
SelectHitBox.h = OriginalView.y+OriginalView.h-SelectHitBox.y;
|
|
|
|
|
|
|
|
if(UI()->DoButtonLogic(pItem, "", Selected, &SelectHitBox))
|
2008-08-27 15:48:50 +00:00
|
|
|
{
|
2010-05-29 07:25:38 +00:00
|
|
|
NewSelected = ItemIndex;
|
2014-06-27 08:13:57 +00:00
|
|
|
#if defined(__ANDROID__)
|
2014-06-16 11:29:18 +00:00
|
|
|
if(NewSelected == m_DoubleClickIndex)
|
|
|
|
DoubleClicked = 1;
|
2014-06-27 08:13:57 +00:00
|
|
|
#endif
|
2014-06-16 11:29:18 +00:00
|
|
|
m_DoubleClickIndex = NewSelected;
|
2008-08-27 15:48:50 +00:00
|
|
|
}
|
|
|
|
}
|
2010-05-29 07:25:38 +00:00
|
|
|
else
|
|
|
|
{
|
|
|
|
// reset active item, if not visible
|
|
|
|
if(UI()->ActiveItem() == pItem)
|
|
|
|
UI()->SetActiveItem(0);
|
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;
|
|
|
|
Button.y = Row.y;
|
|
|
|
Button.h = Row.h;
|
|
|
|
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
|
|
|
{
|
2014-06-16 11:29:18 +00:00
|
|
|
#if defined(__ANDROID__)
|
|
|
|
Button.h = Button.w;
|
|
|
|
Button.y += ms_ListitemAdditionalHeight / 2;
|
|
|
|
#endif
|
2010-05-29 07:25:38 +00:00
|
|
|
if(pItem->m_Flags & SERVER_FLAG_PASSWORD)
|
2010-11-17 18:46:50 +00:00
|
|
|
DoButton_Icon(IMAGE_BROWSEICONS, SPRITE_BROWSE_LOCK, &Button);
|
2008-10-05 09:57:46 +00:00
|
|
|
}
|
2011-02-12 10:40:36 +00:00
|
|
|
else if(ID == COL_FLAG_PURE)
|
2008-10-05 09:57:46 +00:00
|
|
|
{
|
2014-06-16 11:29:18 +00:00
|
|
|
#if defined(__ANDROID__)
|
|
|
|
Button.h = Button.w;
|
|
|
|
Button.y += ms_ListitemAdditionalHeight / 2;
|
|
|
|
#endif
|
2010-05-29 07:25:38 +00:00
|
|
|
if( str_comp(pItem->m_aGameType, "DM") == 0 ||
|
|
|
|
str_comp(pItem->m_aGameType, "TDM") == 0 ||
|
|
|
|
str_comp(pItem->m_aGameType, "CTF") == 0)
|
2009-01-11 13:31:36 +00:00
|
|
|
{
|
|
|
|
// pure server
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
// unpure
|
2010-11-17 18:46:50 +00:00
|
|
|
DoButton_Icon(IMAGE_BROWSEICONS, SPRITE_BROWSE_UNPURE, &Button);
|
2009-01-11 13:31:36 +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
|
|
|
{
|
2014-06-16 11:29:18 +00:00
|
|
|
#if defined(__ANDROID__)
|
|
|
|
Button.h = Button.w;
|
|
|
|
Button.y += ms_ListitemAdditionalHeight / 2;
|
|
|
|
#endif
|
2010-05-29 07:25:38 +00:00
|
|
|
if(pItem->m_Favorite)
|
2010-11-17 18:46:50 +00:00
|
|
|
DoButton_Icon(IMAGE_BROWSEICONS, SPRITE_BROWSE_HEART, &Button);
|
2008-08-27 15:48:50 +00:00
|
|
|
}
|
2011-02-12 10:40:36 +00:00
|
|
|
else if(ID == COL_NAME)
|
2008-08-27 15:48:50 +00:00
|
|
|
{
|
2010-05-29 07:25:38 +00:00
|
|
|
CTextCursor Cursor;
|
2014-06-16 11:29:18 +00:00
|
|
|
#if defined(__ANDROID__)
|
|
|
|
TextRender()->SetCursor(&Cursor, Button.x, Button.y + ms_ListitemAdditionalHeight / 2, 12.0f * UI()->Scale(), TEXTFLAG_RENDER|TEXTFLAG_STOP_AT_END);
|
|
|
|
#else
|
2010-11-20 13:57:38 +00:00
|
|
|
TextRender()->SetCursor(&Cursor, Button.x, Button.y, 12.0f * UI()->Scale(), TEXTFLAG_RENDER|TEXTFLAG_STOP_AT_END);
|
2014-06-16 11:29:18 +00:00
|
|
|
#endif
|
2010-05-29 07:25:38 +00:00
|
|
|
Cursor.m_LineWidth = Button.w;
|
|
|
|
|
|
|
|
if(g_Config.m_BrFilterString[0] && (pItem->m_QuickSearchHit&IServerBrowser::QUICK_SERVERNAME))
|
2008-08-27 15:48:50 +00:00
|
|
|
{
|
|
|
|
// highlight the parts that matches
|
2011-02-12 10:40:36 +00:00
|
|
|
const char *pStr = str_find_nocase(pItem->m_aName, g_Config.m_BrFilterString);
|
|
|
|
if(pStr)
|
2008-08-27 15:48:50 +00:00
|
|
|
{
|
2011-02-12 10:40:36 +00:00
|
|
|
TextRender()->TextEx(&Cursor, pItem->m_aName, (int)(pStr-pItem->m_aName));
|
2010-05-29 07:25:38 +00:00
|
|
|
TextRender()->TextColor(0.4f,0.4f,1.0f,1);
|
2011-02-12 10:40:36 +00:00
|
|
|
TextRender()->TextEx(&Cursor, pStr, str_length(g_Config.m_BrFilterString));
|
2010-05-29 07:25:38 +00:00
|
|
|
TextRender()->TextColor(1,1,1,1);
|
2011-02-12 10:40:36 +00:00
|
|
|
TextRender()->TextEx(&Cursor, pStr+str_length(g_Config.m_BrFilterString), -1);
|
2008-08-27 15:48:50 +00:00
|
|
|
}
|
|
|
|
else
|
2010-05-29 07:25:38 +00:00
|
|
|
TextRender()->TextEx(&Cursor, pItem->m_aName, -1);
|
2008-08-27 15:48:50 +00:00
|
|
|
}
|
|
|
|
else
|
2010-05-29 07:25:38 +00:00
|
|
|
TextRender()->TextEx(&Cursor, pItem->m_aName, -1);
|
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
|
|
|
{
|
|
|
|
CTextCursor Cursor;
|
2014-06-16 11:29:18 +00:00
|
|
|
#if defined(__ANDROID__)
|
|
|
|
TextRender()->SetCursor(&Cursor, Button.x, Button.y + ms_ListitemAdditionalHeight / 2, 12.0f * UI()->Scale(), TEXTFLAG_RENDER|TEXTFLAG_STOP_AT_END);
|
|
|
|
#else
|
2010-12-14 00:20:47 +00:00
|
|
|
TextRender()->SetCursor(&Cursor, Button.x, Button.y, 12.0f * UI()->Scale(), TEXTFLAG_RENDER|TEXTFLAG_STOP_AT_END);
|
2014-06-16 11:29:18 +00:00
|
|
|
#endif
|
2010-06-09 22:40:22 +00:00
|
|
|
Cursor.m_LineWidth = Button.w;
|
2011-03-18 18:14:35 +00:00
|
|
|
|
|
|
|
if(g_Config.m_BrFilterString[0] && (pItem->m_QuickSearchHit&IServerBrowser::QUICK_MAPNAME))
|
|
|
|
{
|
|
|
|
// highlight the parts that matches
|
|
|
|
const char *pStr = str_find_nocase(pItem->m_aMap, g_Config.m_BrFilterString);
|
|
|
|
if(pStr)
|
|
|
|
{
|
|
|
|
TextRender()->TextEx(&Cursor, pItem->m_aMap, (int)(pStr-pItem->m_aMap));
|
|
|
|
TextRender()->TextColor(0.4f,0.4f,1.0f,1);
|
|
|
|
TextRender()->TextEx(&Cursor, pStr, str_length(g_Config.m_BrFilterString));
|
|
|
|
TextRender()->TextColor(1,1,1,1);
|
|
|
|
TextRender()->TextEx(&Cursor, pStr+str_length(g_Config.m_BrFilterString), -1);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
TextRender()->TextEx(&Cursor, pItem->m_aMap, -1);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
TextRender()->TextEx(&Cursor, pItem->m_aMap, -1);
|
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
|
|
|
{
|
2014-06-16 11:29:18 +00:00
|
|
|
#if defined(__ANDROID__)
|
|
|
|
Button.h -= ms_ListitemAdditionalHeight;
|
|
|
|
Button.y += ms_ListitemAdditionalHeight / 2;
|
|
|
|
#endif
|
2011-06-26 15:10:13 +00:00
|
|
|
CUIRect Icon;
|
|
|
|
Button.VMargin(4.0f, &Button);
|
|
|
|
if(pItem->m_FriendState != IFriends::FRIEND_NO)
|
|
|
|
{
|
|
|
|
Button.VSplitLeft(Button.h, &Icon, &Button);
|
|
|
|
Icon.Margin(2.0f, &Icon);
|
|
|
|
DoButton_Icon(IMAGE_BROWSEICONS, SPRITE_BROWSE_HEART, &Icon);
|
|
|
|
}
|
|
|
|
|
2011-03-20 14:33:49 +00:00
|
|
|
if(g_Config.m_BrFilterSpectators)
|
|
|
|
str_format(aTemp, sizeof(aTemp), "%i/%i", pItem->m_NumPlayers, pItem->m_MaxPlayers);
|
|
|
|
else
|
|
|
|
str_format(aTemp, sizeof(aTemp), "%i/%i", pItem->m_NumClients, pItem->m_MaxClients);
|
2011-03-18 16:59:48 +00:00
|
|
|
if(g_Config.m_BrFilterString[0] && (pItem->m_QuickSearchHit&IServerBrowser::QUICK_PLAYER))
|
2010-05-29 07:25:38 +00:00
|
|
|
TextRender()->TextColor(0.4f,0.4f,1.0f,1);
|
2010-12-14 00:20:47 +00:00
|
|
|
UI()->DoLabelScaled(&Button, aTemp, 12.0f, 1);
|
2010-05-29 07:25:38 +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
|
|
|
{
|
2014-06-16 11:29:18 +00:00
|
|
|
#if defined(__ANDROID__)
|
|
|
|
Button.h -= ms_ListitemAdditionalHeight;
|
|
|
|
Button.y += ms_ListitemAdditionalHeight / 2;
|
|
|
|
#endif
|
2010-05-29 07:25:38 +00:00
|
|
|
str_format(aTemp, sizeof(aTemp), "%i", pItem->m_Latency);
|
2014-05-03 15:24:34 +00:00
|
|
|
if (g_Config.m_UiColorizePing)
|
|
|
|
{
|
|
|
|
vec3 rgb = HslToRgb(vec3((300.0f - clamp(pItem->m_Latency, 0, 300)) / 1000.0f, 1.0f, 0.5f));
|
|
|
|
TextRender()->TextColor(rgb.r, rgb.g, rgb.b, 1.0f);
|
|
|
|
}
|
|
|
|
|
2010-12-14 00:20:47 +00:00
|
|
|
UI()->DoLabelScaled(&Button, aTemp, 12.0f, 1);
|
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
|
|
|
{
|
2014-06-16 11:29:18 +00:00
|
|
|
#if defined(__ANDROID__)
|
|
|
|
Button.h -= ms_ListitemAdditionalHeight;
|
|
|
|
Button.y += ms_ListitemAdditionalHeight / 2;
|
|
|
|
#endif
|
2010-05-29 07:25:38 +00:00
|
|
|
const char *pVersion = pItem->m_aVersion;
|
2010-12-14 00:20:47 +00:00
|
|
|
UI()->DoLabelScaled(&Button, pVersion, 12.0f, 1);
|
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
|
|
|
{
|
2010-06-09 22:40:22 +00:00
|
|
|
CTextCursor Cursor;
|
2014-06-16 11:29:18 +00:00
|
|
|
#if defined(__ANDROID__)
|
|
|
|
TextRender()->SetCursor(&Cursor, Button.x, Button.y + ms_ListitemAdditionalHeight / 2, 12.0f*UI()->Scale(), TEXTFLAG_RENDER|TEXTFLAG_STOP_AT_END);
|
|
|
|
#else
|
2010-12-14 00:20:47 +00:00
|
|
|
TextRender()->SetCursor(&Cursor, Button.x, Button.y, 12.0f*UI()->Scale(), TEXTFLAG_RENDER|TEXTFLAG_STOP_AT_END);
|
2014-06-16 11:29:18 +00:00
|
|
|
#endif
|
2010-06-09 22:40:22 +00:00
|
|
|
Cursor.m_LineWidth = Button.w;
|
2008-10-21 18:50:23 +00:00
|
|
|
|
2014-05-03 15:24:34 +00:00
|
|
|
if (g_Config.m_UiColorizeGametype)
|
|
|
|
{
|
|
|
|
vec3 hsl = vec3(1.0f, 1.0f, 1.0f);
|
|
|
|
|
|
|
|
if (!str_comp(pItem->m_aGameType, "DM")
|
|
|
|
|| !str_comp(pItem->m_aGameType, "TDM")
|
|
|
|
|| !str_comp(pItem->m_aGameType, "CTF"))
|
|
|
|
hsl = vec3(0.33f, 1.0f, 0.75f); // Vanilla
|
|
|
|
else if (str_find_nocase(pItem->m_aGameType, "catch"))
|
|
|
|
hsl = vec3(0.17f, 1.0f, 0.75f); // Catch
|
|
|
|
else if (str_find_nocase(pItem->m_aGameType, "idm")
|
|
|
|
|| str_find_nocase(pItem->m_aGameType, "itdm")
|
|
|
|
|| str_find_nocase(pItem->m_aGameType, "ictf"))
|
|
|
|
hsl = vec3(0.00f, 1.0f, 0.75f); // Instagib
|
|
|
|
else if (str_find_nocase(pItem->m_aGameType, "fng"))
|
|
|
|
hsl = vec3(0.83f, 1.0f, 0.75f); // FNG
|
|
|
|
else if (str_find_nocase(pItem->m_aGameType, "ddracenetwo"))
|
|
|
|
hsl = vec3(0.58f, 1.0f, 0.75f); // DDNet
|
|
|
|
else if (str_find_nocase(pItem->m_aGameType, "ddrace")
|
|
|
|
|| str_find_nocase(pItem->m_aGameType, "mkrace"))
|
|
|
|
hsl = vec3(0.75f, 1.0f, 0.75f); // DDRace
|
|
|
|
else if (str_find_nocase(pItem->m_aGameType, "race")
|
|
|
|
|| !str_comp(pItem->m_aGameType, "FastCap"))
|
|
|
|
hsl = vec3(0.46f, 1.0f, 0.75f); // Races
|
|
|
|
|
|
|
|
vec3 rgb = HslToRgb(hsl);
|
|
|
|
TextRender()->TextColor(rgb.r, rgb.g, rgb.b, 1.0f);
|
|
|
|
TextRender()->TextEx(&Cursor, pItem->m_aGameType, -1);
|
|
|
|
TextRender()->TextColor(1.0f, 1.0f, 1.0f, 1.0f);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
TextRender()->TextEx(&Cursor, pItem->m_aGameType, -1);
|
|
|
|
}
|
2008-08-27 15:48:50 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2009-10-27 14:38:53 +00:00
|
|
|
UI()->ClipDisable();
|
2010-05-29 07:25:38 +00:00
|
|
|
|
|
|
|
if(NewSelected != -1)
|
2008-08-27 15:48:50 +00:00
|
|
|
{
|
|
|
|
// select the new server
|
2010-05-29 07:25:38 +00:00
|
|
|
const CServerInfo *pItem = ServerBrowser()->SortedGet(NewSelected);
|
|
|
|
str_copy(g_Config.m_UiServerAddress, pItem->m_aAddress, sizeof(g_Config.m_UiServerAddress));
|
2014-06-16 11:29:18 +00:00
|
|
|
#if defined(__ANDROID__)
|
|
|
|
if(DoubleClicked)
|
|
|
|
#else
|
2010-05-29 07:25:38 +00:00
|
|
|
if(Input()->MouseDoubleClick())
|
2014-06-16 11:29:18 +00:00
|
|
|
#endif
|
2010-05-29 07:25:38 +00:00
|
|
|
Client()->Connect(g_Config.m_UiServerAddress);
|
2008-08-27 15:48:50 +00:00
|
|
|
}
|
|
|
|
|
2010-05-29 07:25:38 +00:00
|
|
|
RenderTools()->DrawUIRect(&Status, vec4(1,1,1,0.25f), CUI::CORNER_B, 5.0f);
|
|
|
|
Status.Margin(5.0f, &Status);
|
|
|
|
|
2009-01-21 18:09:06 +00:00
|
|
|
// render quick search
|
2010-05-29 07:25:38 +00:00
|
|
|
CUIRect QuickSearch, Button;
|
2011-03-18 16:59:48 +00:00
|
|
|
Status.VSplitLeft(240.0f, &QuickSearch, &Status);
|
2014-07-09 19:59:03 +00:00
|
|
|
const char *pLabel = Localize("Search:");
|
2010-12-14 00:20:47 +00:00
|
|
|
UI()->DoLabelScaled(&QuickSearch, pLabel, 12.0f, -1);
|
2010-06-03 21:32:32 +00:00
|
|
|
float w = TextRender()->TextWidth(0, 12.0f, pLabel, -1);
|
|
|
|
QuickSearch.VSplitLeft(w, 0, &QuickSearch);
|
2010-05-29 07:25:38 +00:00
|
|
|
QuickSearch.VSplitLeft(5.0f, 0, &QuickSearch);
|
2011-03-18 16:59:48 +00:00
|
|
|
QuickSearch.VSplitLeft(240.0f-w-22.0f, &QuickSearch, &Button);
|
2010-05-29 15:53:57 +00:00
|
|
|
static float Offset = 0.0f;
|
2011-03-18 18:03:13 +00:00
|
|
|
if(DoEditBox(&g_Config.m_BrFilterString, &QuickSearch, g_Config.m_BrFilterString, sizeof(g_Config.m_BrFilterString), 12.0f, &Offset, false, CUI::CORNER_L))
|
|
|
|
Client()->ServerBrowserUpdate();
|
|
|
|
|
2010-05-29 07:25:38 +00:00
|
|
|
// clear button
|
|
|
|
{
|
|
|
|
static int s_ClearButton = 0;
|
|
|
|
RenderTools()->DrawUIRect(&Button, vec4(1,1,1,0.33f)*ButtonColorMul(&s_ClearButton), CUI::CORNER_R, 3.0f);
|
|
|
|
UI()->DoLabel(&Button, "x", Button.h*ms_FontmodHeight, 0);
|
|
|
|
if(UI()->DoButtonLogic(&s_ClearButton, "x", 0, &Button))
|
|
|
|
{
|
|
|
|
g_Config.m_BrFilterString[0] = 0;
|
|
|
|
UI()->SetActiveItem(&g_Config.m_BrFilterString);
|
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
|
|
|
|
2009-01-21 18:09:06 +00:00
|
|
|
// render status
|
2010-05-29 07:25:38 +00:00
|
|
|
char aBuf[128];
|
2010-11-17 11:43:24 +00:00
|
|
|
if(ServerBrowser()->IsRefreshing())
|
2014-01-14 19:58:47 +00:00
|
|
|
{
|
|
|
|
char aBuf2[64];
|
|
|
|
char aBuf3[64];
|
|
|
|
str_format(aBuf3, sizeof(aBuf3), Localize("%d%% loaded"), ServerBrowser()->LoadingProgression());
|
|
|
|
str_format(aBuf2, sizeof(aBuf2), Localize("%d of %d servers, %d players"), ServerBrowser()->NumSortedServers(), ServerBrowser()->NumServers(), NumPlayers);
|
|
|
|
str_format(aBuf, sizeof(aBuf), "%s, %s", aBuf3, aBuf2);
|
|
|
|
}
|
2010-11-17 11:43:24 +00:00
|
|
|
else
|
|
|
|
str_format(aBuf, sizeof(aBuf), Localize("%d of %d servers, %d players"), ServerBrowser()->NumSortedServers(), ServerBrowser()->NumServers(), NumPlayers);
|
2010-05-29 07:25:38 +00:00
|
|
|
Status.VSplitRight(TextRender()->TextWidth(0, 14.0f, aBuf, -1), 0, &Status);
|
2010-12-14 00:20:47 +00:00
|
|
|
UI()->DoLabelScaled(&Status, aBuf, 14.0f, -1);
|
2008-09-04 18:42:26 +00:00
|
|
|
}
|
|
|
|
|
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);
|
|
|
|
RenderTools()->DrawUIRect(&FilterHeader, vec4(1,1,1,0.25f), CUI::CORNER_T, 4.0f);
|
|
|
|
RenderTools()->DrawUIRect(&ServerFilter, vec4(0,0,0,0.15f), CUI::CORNER_B, 4.0f);
|
|
|
|
UI()->DoLabelScaled(&FilterHeader, Localize("Server filter"), FontSize+2.0f, 0);
|
2010-05-29 07:25:38 +00:00
|
|
|
CUIRect Button;
|
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);
|
2010-05-29 07:25:38 +00:00
|
|
|
if (DoButton_CheckBox(&g_Config.m_BrFilterEmpty, Localize("Has people playing"), g_Config.m_BrFilterEmpty, &Button))
|
|
|
|
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);
|
2010-05-29 07:25:38 +00:00
|
|
|
if (DoButton_CheckBox(&g_Config.m_BrFilterFull, Localize("Server not full"), g_Config.m_BrFilterFull, &Button))
|
|
|
|
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);
|
2011-06-26 15:10:13 +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);
|
2010-05-29 07:25:38 +00:00
|
|
|
if (DoButton_CheckBox(&g_Config.m_BrFilterPw, Localize("No password"), g_Config.m_BrFilterPw, &Button))
|
|
|
|
g_Config.m_BrFilterPw ^= 1;
|
2008-09-04 18:42:26 +00:00
|
|
|
|
2011-03-18 16:59:48 +00:00
|
|
|
ServerFilter.HSplitTop(20.0f, &Button, &ServerFilter);
|
2010-05-29 07:25:38 +00:00
|
|
|
if (DoButton_CheckBox((char *)&g_Config.m_BrFilterCompatversion, Localize("Compatible version"), g_Config.m_BrFilterCompatversion, &Button))
|
|
|
|
g_Config.m_BrFilterCompatversion ^= 1;
|
|
|
|
|
2011-03-18 16:59:48 +00:00
|
|
|
ServerFilter.HSplitTop(20.0f, &Button, &ServerFilter);
|
2010-05-29 07:25:38 +00:00
|
|
|
if (DoButton_CheckBox((char *)&g_Config.m_BrFilterPure, Localize("Standard gametype"), g_Config.m_BrFilterPure, &Button))
|
|
|
|
g_Config.m_BrFilterPure ^= 1;
|
|
|
|
|
2011-03-18 16:59:48 +00:00
|
|
|
ServerFilter.HSplitTop(20.0f, &Button, &ServerFilter);
|
2010-05-29 07:25:38 +00:00
|
|
|
if (DoButton_CheckBox((char *)&g_Config.m_BrFilterPureMap, Localize("Standard map"), g_Config.m_BrFilterPureMap, &Button))
|
|
|
|
g_Config.m_BrFilterPureMap ^= 1;
|
2011-08-11 08:59:14 +00:00
|
|
|
|
2011-04-17 09:57:33 +00:00
|
|
|
ServerFilter.HSplitTop(20.0f, &Button, &ServerFilter);
|
|
|
|
if (DoButton_CheckBox((char *)&g_Config.m_BrFilterGametypeStrict, Localize("Strict gametype filter"), g_Config.m_BrFilterGametypeStrict, &Button))
|
|
|
|
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);
|
|
|
|
UI()->DoLabelScaled(&Button, Localize("Game types:"), FontSize, -1);
|
|
|
|
Button.VSplitRight(60.0f, 0, &Button);
|
|
|
|
ServerFilter.HSplitTop(3.0f, 0, &ServerFilter);
|
2010-05-29 15:53:57 +00:00
|
|
|
static float Offset = 0.0f;
|
2011-03-18 18:03:13 +00:00
|
|
|
if(DoEditBox(&g_Config.m_BrFilterGametype, &Button, g_Config.m_BrFilterGametype, sizeof(g_Config.m_BrFilterGametype), FontSize, &Offset))
|
|
|
|
Client()->ServerBrowserUpdate();
|
2008-09-04 18:42:26 +00:00
|
|
|
|
2008-09-04 18:25:12 +00:00
|
|
|
{
|
2011-03-18 16:59:48 +00:00
|
|
|
ServerFilter.HSplitTop(19.0f, &Button, &ServerFilter);
|
2010-05-29 07:25:38 +00:00
|
|
|
CUIRect EditBox;
|
2011-03-18 16:59:48 +00:00
|
|
|
Button.VSplitRight(60.0f, &Button, &EditBox);
|
2011-04-13 18:37:12 +00:00
|
|
|
|
2011-03-18 16:59:48 +00:00
|
|
|
UI()->DoLabelScaled(&Button, Localize("Maximum ping:"), FontSize, -1);
|
2011-04-13 18:37:12 +00:00
|
|
|
|
2010-05-29 07:25:38 +00:00
|
|
|
char aBuf[5];
|
|
|
|
str_format(aBuf, sizeof(aBuf), "%d", g_Config.m_BrFilterPing);
|
2010-05-29 15:53:57 +00:00
|
|
|
static float Offset = 0.0f;
|
2011-03-18 16:59:48 +00:00
|
|
|
DoEditBox(&g_Config.m_BrFilterPing, &EditBox, aBuf, sizeof(aBuf), FontSize, &Offset);
|
2011-01-23 17:04:31 +00:00
|
|
|
g_Config.m_BrFilterPing = clamp(str_toint(aBuf), 0, 999);
|
2008-09-04 18:25:12 +00:00
|
|
|
}
|
2010-05-29 07:25:38 +00:00
|
|
|
|
2011-03-18 18:03:13 +00:00
|
|
|
// server address
|
|
|
|
ServerFilter.HSplitTop(3.0f, 0, &ServerFilter);
|
|
|
|
ServerFilter.HSplitTop(19.0f, &Button, &ServerFilter);
|
|
|
|
UI()->DoLabelScaled(&Button, Localize("Server address:"), FontSize, -1);
|
2011-04-13 18:37:12 +00:00
|
|
|
Button.VSplitRight(60.0f, 0, &Button);
|
2011-03-18 18:03:13 +00:00
|
|
|
static float OffsetAddr = 0.0f;
|
|
|
|
if(DoEditBox(&g_Config.m_BrFilterServerAddress, &Button, g_Config.m_BrFilterServerAddress, sizeof(g_Config.m_BrFilterServerAddress), FontSize, &OffsetAddr))
|
|
|
|
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;
|
|
|
|
Rect.w = Rect.h*2;
|
|
|
|
Rect.x += (OldWidth-Rect.w)/2.0f;
|
2012-01-08 17:16:38 +00:00
|
|
|
vec4 Color(1.0f, 1.0f, 1.0f, g_Config.m_BrFilterCountry?1.0f: 0.5f);
|
|
|
|
m_pClient->m_pCountryFlags->Render(g_Config.m_BrFilterCountryIndex, &Color, Rect.x, Rect.y, Rect.w, Rect.h);
|
2011-06-29 20:27:32 +00:00
|
|
|
|
|
|
|
if(g_Config.m_BrFilterCountry && UI()->DoButtonLogic(&g_Config.m_BrFilterCountryIndex, "", 0, &Rect))
|
|
|
|
m_Popup = POPUP_COUNTRY;
|
|
|
|
}
|
|
|
|
|
2014-05-03 15:24:34 +00:00
|
|
|
ServerFilter.HSplitTop(20.0f, &Button, &ServerFilter);
|
|
|
|
if (DoButton_CheckBox((char *)&g_Config.m_UiColorizeGametype, Localize("Colorize gametype"), g_Config.m_UiColorizeGametype, &Button))
|
|
|
|
g_Config.m_UiColorizeGametype ^= 1;
|
|
|
|
|
|
|
|
ServerFilter.HSplitTop(20.0f, &Button, &ServerFilter);
|
|
|
|
if (DoButton_CheckBox((char *)&g_Config.m_UiColorizePing, Localize("Colorize ping"), g_Config.m_UiColorizePing, &Button))
|
|
|
|
g_Config.m_UiColorizePing ^= 1;
|
2014-09-19 21:52:09 +00:00
|
|
|
|
|
|
|
// ddnet country filters
|
|
|
|
if(g_Config.m_UiPage == PAGE_DDNET)
|
|
|
|
{
|
|
|
|
// add more space
|
|
|
|
ServerFilter.HSplitTop(10.0f, &Button, &ServerFilter);
|
|
|
|
|
|
|
|
ServerFilter.HSplitTop(40.0f, &Button, &ServerFilter);
|
|
|
|
UI()->DoLabelScaled(&Button, Localize("DDNet Countries:"), FontSize, -1);
|
|
|
|
|
|
|
|
vec4 Color(1.0f, 1.0f, 1.0f, 1.0f);
|
|
|
|
|
|
|
|
const float FlagWidth = 40.0f;
|
|
|
|
const float FlagHeight = 20.0f;
|
|
|
|
|
|
|
|
int MaxFlags = ServerBrowser()->NumDDNetCountries();
|
|
|
|
int NumFlags = ServerBrowser()->NumDDNetCountries();
|
|
|
|
|
|
|
|
CUIRect FlagsRect;
|
|
|
|
|
|
|
|
static int s_aFlagButtons[64];
|
|
|
|
|
|
|
|
while(NumFlags > 0)
|
|
|
|
{
|
|
|
|
ServerFilter.HSplitTop(30.0f, &FlagsRect, &ServerFilter);
|
|
|
|
|
|
|
|
for(int i = 0; i < 3 && NumFlags > 0; i++)
|
|
|
|
{
|
|
|
|
int CountryIndex = MaxFlags - NumFlags;
|
|
|
|
const char *pName = ServerBrowser()->GetDDNetCountryName(CountryIndex);
|
|
|
|
bool Active = !ServerBrowser()->DDNetCountryFiltered(pName);
|
|
|
|
int FlagID = ServerBrowser()->GetDDNetCountryFlag(CountryIndex);
|
|
|
|
|
|
|
|
vec2 Pos = vec2(FlagsRect.x+FlagsRect.w*((i+0.5f)/3.0f), FlagsRect.y);
|
|
|
|
|
|
|
|
// 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;
|
|
|
|
|
|
|
|
if (UI()->DoButtonLogic(&s_aFlagButtons[CountryIndex], "", 0, &Rect))
|
|
|
|
{
|
|
|
|
// toggle flag filter
|
|
|
|
if (Active)
|
|
|
|
ServerBrowser()->DDNetCountryFilterAdd(pName);
|
|
|
|
else
|
|
|
|
ServerBrowser()->DDNetCountryFilterRem(pName);
|
|
|
|
|
|
|
|
ServerBrowser()->Refresh(IServerBrowser::TYPE_DDNET);
|
|
|
|
}
|
|
|
|
|
|
|
|
vec4 Color(1.0f, 1.0f, 1.0f, 1.0f);
|
|
|
|
|
|
|
|
if (!Active)
|
|
|
|
Color.a = 0.2f;
|
|
|
|
|
|
|
|
m_pClient->m_pCountryFlags->Render(FlagID, &Color, Pos.x, Pos.y, FlagWidth, FlagHeight);
|
|
|
|
|
|
|
|
NumFlags--;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2014-05-03 15:24:34 +00:00
|
|
|
|
2011-03-18 16:59:48 +00:00
|
|
|
ServerFilter.HSplitBottom(5.0f, &ServerFilter, 0);
|
2011-04-09 16:08:11 +00:00
|
|
|
ServerFilter.HSplitBottom(ms_ButtonHeight-2.0f, &ServerFilter, &Button);
|
2010-05-29 07:25:38 +00:00
|
|
|
static int s_ClearButton = 0;
|
|
|
|
if(DoButton_Menu(&s_ClearButton, Localize("Reset filter"), 0, &Button))
|
2008-09-04 18:42:26 +00:00
|
|
|
{
|
2011-07-02 11:10:34 +00:00
|
|
|
g_Config.m_BrFilterString[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_BrFilterPing = 999;
|
|
|
|
g_Config.m_BrFilterGametype[0] = 0;
|
2011-07-02 11:10:34 +00:00
|
|
|
g_Config.m_BrFilterGametypeStrict = 0;
|
2011-03-18 18:03:13 +00:00
|
|
|
g_Config.m_BrFilterServerAddress[0] = 0;
|
2011-04-15 04:40:42 +00:00
|
|
|
g_Config.m_BrFilterPure = 0;
|
|
|
|
g_Config.m_BrFilterPureMap = 0;
|
2011-08-13 00:11:06 +00:00
|
|
|
g_Config.m_BrFilterCompatversion = 0;
|
2011-03-18 18:03:13 +00:00
|
|
|
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
|
2011-03-23 12:06:35 +00:00
|
|
|
ServerDetails.HSplitTop(90.0f, &ServerDetails, &ServerScoreBoard);
|
|
|
|
ServerDetails.HSplitBottom(2.5f, &ServerDetails, 0x0);
|
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);
|
2010-05-29 07:25:38 +00:00
|
|
|
RenderTools()->DrawUIRect(&ServerHeader, vec4(1,1,1,0.25f), CUI::CORNER_T, 4.0f);
|
|
|
|
RenderTools()->DrawUIRect(&ServerDetails, vec4(0,0,0,0.15f), CUI::CORNER_B, 4.0f);
|
2011-03-18 16:59:48 +00:00
|
|
|
UI()->DoLabelScaled(&ServerHeader, Localize("Server details"), FontSize+2.0f, 0);
|
2008-08-27 15:48:50 +00:00
|
|
|
|
2010-05-29 07:25:38 +00:00
|
|
|
if (pSelectedServer)
|
2008-09-04 18:42:26 +00:00
|
|
|
{
|
2011-03-18 16:59:48 +00:00
|
|
|
ServerDetails.VSplitLeft(5.0f, 0, &ServerDetails);
|
|
|
|
ServerDetails.Margin(3.0f, &ServerDetails);
|
|
|
|
|
2010-05-29 07:25:38 +00:00
|
|
|
CUIRect Row;
|
|
|
|
static CLocConstString s_aLabels[] = {
|
2010-05-31 11:07:58 +00:00
|
|
|
"Version", // Localize - these strings are localized within CLocConstString
|
|
|
|
"Game type",
|
|
|
|
"Ping"};
|
2008-08-27 15:48:50 +00:00
|
|
|
|
2010-05-29 07:25:38 +00:00
|
|
|
CUIRect LeftColumn;
|
|
|
|
CUIRect RightColumn;
|
2008-08-27 15:48:50 +00:00
|
|
|
|
2010-05-29 07:25:38 +00:00
|
|
|
//
|
2008-09-03 20:03:01 +00:00
|
|
|
{
|
2010-05-29 07:25:38 +00:00
|
|
|
CUIRect Button;
|
|
|
|
ServerDetails.HSplitBottom(20.0f, &ServerDetails, &Button);
|
2011-03-18 16:59:48 +00:00
|
|
|
Button.VSplitLeft(5.0f, 0, &Button);
|
2010-05-29 07:25:38 +00:00
|
|
|
static int s_AddFavButton = 0;
|
|
|
|
if(DoButton_CheckBox(&s_AddFavButton, Localize("Favorite"), pSelectedServer->m_Favorite, &Button))
|
2008-09-03 20:03:01 +00:00
|
|
|
{
|
2010-05-29 07:25:38 +00:00
|
|
|
if(pSelectedServer->m_Favorite)
|
|
|
|
ServerBrowser()->RemoveFavorite(pSelectedServer->m_NetAddr);
|
2008-09-04 18:42:26 +00:00
|
|
|
else
|
2010-05-29 07:25:38 +00:00
|
|
|
ServerBrowser()->AddFavorite(pSelectedServer->m_NetAddr);
|
2008-09-03 20:03:01 +00:00
|
|
|
}
|
2008-09-04 18:42:26 +00:00
|
|
|
}
|
2008-09-03 20:03:01 +00:00
|
|
|
|
2010-05-29 07:25:38 +00:00
|
|
|
ServerDetails.VSplitLeft(5.0f, 0x0, &ServerDetails);
|
|
|
|
ServerDetails.VSplitLeft(80.0f, &LeftColumn, &RightColumn);
|
2008-08-27 15:48:50 +00:00
|
|
|
|
2010-05-29 07:25:38 +00:00
|
|
|
for (unsigned int i = 0; i < sizeof(s_aLabels) / sizeof(s_aLabels[0]); i++)
|
2008-09-04 18:42:26 +00:00
|
|
|
{
|
2010-05-29 07:25:38 +00:00
|
|
|
LeftColumn.HSplitTop(15.0f, &Row, &LeftColumn);
|
2010-12-14 00:20:47 +00:00
|
|
|
UI()->DoLabelScaled(&Row, s_aLabels[i], FontSize, -1);
|
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);
|
2011-01-09 23:18:30 +00:00
|
|
|
TextRender()->SetCursor(&Cursor, Row.x, Row.y, FontSize, TEXTFLAG_RENDER|TEXTFLAG_STOP_AT_END);
|
|
|
|
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);
|
2011-01-09 23:18:30 +00:00
|
|
|
TextRender()->SetCursor(&Cursor, Row.x, Row.y, FontSize, TEXTFLAG_RENDER|TEXTFLAG_STOP_AT_END);
|
|
|
|
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];
|
|
|
|
str_format(aTemp, sizeof(aTemp), "%d", pSelectedServer->m_Latency);
|
|
|
|
RightColumn.HSplitTop(15.0f, &Row, &RightColumn);
|
2011-01-30 16:21:41 +00:00
|
|
|
TextRender()->SetCursor(&Cursor, Row.x, Row.y, FontSize, TEXTFLAG_RENDER|TEXTFLAG_STOP_AT_END);
|
|
|
|
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
|
2014-01-10 11:22:48 +00:00
|
|
|
//ServerScoreBoard.HSplitBottom(20.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
|
|
|
{
|
2014-01-08 05:15:56 +00:00
|
|
|
static int s_VoteList = 0;
|
|
|
|
static float s_ScrollValue = 0;
|
|
|
|
UiDoListboxStart(&s_VoteList, &ServerScoreBoard, 26.0f, Localize("Scoreboard"), "", pSelectedServer->m_NumClients, 1, -1, s_ScrollValue);
|
|
|
|
|
2011-03-20 14:33:49 +00:00
|
|
|
for (int i = 0; i < pSelectedServer->m_NumClients; i++)
|
2008-08-27 15:48:50 +00:00
|
|
|
{
|
2014-01-15 23:46:13 +00:00
|
|
|
CListboxItem Item = UiDoListboxNextItem(&i);
|
2014-01-08 05:15:56 +00:00
|
|
|
|
|
|
|
if(!Item.m_Visible)
|
|
|
|
continue;
|
|
|
|
|
2011-03-18 16:59:48 +00:00
|
|
|
CUIRect Name, Clan, Score, Flag;
|
2014-01-08 05:15:56 +00:00
|
|
|
Item.m_Rect.HSplitTop(25.0f, &Name, &Item.m_Rect);
|
2011-06-26 15:10:13 +00:00
|
|
|
if(UI()->DoButtonLogic(&pSelectedServer->m_aClients[i], "", 0, &Name))
|
|
|
|
{
|
|
|
|
if(pSelectedServer->m_aClients[i].m_FriendState == IFriends::FRIEND_PLAYER)
|
|
|
|
m_pClient->Friends()->RemoveFriend(pSelectedServer->m_aClients[i].m_aName, pSelectedServer->m_aClients[i].m_aClan);
|
|
|
|
else
|
|
|
|
m_pClient->Friends()->AddFriend(pSelectedServer->m_aClients[i].m_aName, pSelectedServer->m_aClients[i].m_aClan);
|
|
|
|
FriendlistOnUpdate();
|
|
|
|
Client()->ServerBrowserUpdate();
|
|
|
|
}
|
|
|
|
|
|
|
|
vec4 Colour = pSelectedServer->m_aClients[i].m_FriendState == IFriends::FRIEND_NO ? vec4(1.0f, 1.0f, 1.0f, (i%2+1)*0.05f) :
|
|
|
|
vec4(0.5f, 1.0f, 0.5f, 0.15f+(i%2+1)*0.05f);
|
|
|
|
RenderTools()->DrawUIRect(&Name, Colour, CUI::CORNER_ALL, 4.0f);
|
2011-04-16 16:55:36 +00:00
|
|
|
Name.VSplitLeft(5.0f, 0, &Name);
|
2014-01-24 21:09:52 +00:00
|
|
|
Name.VSplitLeft(34.0f, &Score, &Name);
|
2011-04-04 18:37:12 +00:00
|
|
|
Name.VSplitRight(34.0f, &Name, &Flag);
|
|
|
|
Flag.HMargin(4.0f, &Flag);
|
2011-04-16 16:55:36 +00:00
|
|
|
Name.HSplitTop(11.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
|
|
|
|
2014-02-19 13:24:26 +00:00
|
|
|
if(!pSelectedServer->m_aClients[i].m_Player)
|
|
|
|
str_copy(aTemp, "SPEC", sizeof(aTemp));
|
|
|
|
else if(str_find_nocase(pSelectedServer->m_aGameType, "race") || str_find_nocase(pSelectedServer->m_aGameType, "fastcap"))
|
|
|
|
{
|
|
|
|
if(pSelectedServer->m_aClients[i].m_Score == -9999 || pSelectedServer->m_aClients[i].m_Score == 0)
|
|
|
|
aTemp[0] = 0;
|
|
|
|
else
|
2014-01-24 21:09:52 +00:00
|
|
|
{
|
2014-02-19 13:24:26 +00:00
|
|
|
int Time = abs(pSelectedServer->m_aClients[i].m_Score);
|
|
|
|
str_format(aTemp, sizeof(aTemp), "%02d:%02d", Time/60, Time%60);
|
2014-01-24 21:09:52 +00:00
|
|
|
}
|
2011-03-20 14:33:49 +00:00
|
|
|
}
|
2014-02-19 13:24:26 +00:00
|
|
|
else
|
|
|
|
str_format(aTemp, sizeof(aTemp), "%d", pSelectedServer->m_aClients[i].m_Score);
|
|
|
|
|
|
|
|
TextRender()->SetCursor(&Cursor, Score.x, Score.y+(Score.h-FontSize)/4.0f, FontSize, TEXTFLAG_RENDER|TEXTFLAG_STOP_AT_END);
|
|
|
|
Cursor.m_LineWidth = Score.w;
|
|
|
|
TextRender()->TextEx(&Cursor, aTemp, -1);
|
2011-04-13 18:37:12 +00:00
|
|
|
|
2011-03-18 16:59:48 +00:00
|
|
|
// name
|
|
|
|
TextRender()->SetCursor(&Cursor, Name.x, Name.y, FontSize-2, TEXTFLAG_RENDER|TEXTFLAG_STOP_AT_END);
|
|
|
|
Cursor.m_LineWidth = Name.w;
|
2011-03-20 14:33:49 +00:00
|
|
|
const char *pName = pSelectedServer->m_aClients[i].m_aName;
|
2010-05-29 07:25:38 +00:00
|
|
|
if(g_Config.m_BrFilterString[0])
|
2008-09-04 18:42:26 +00:00
|
|
|
{
|
|
|
|
// highlight the parts that matches
|
2010-05-29 07:25:38 +00:00
|
|
|
const char *s = str_find_nocase(pName, g_Config.m_BrFilterString);
|
2008-09-04 18:42:26 +00:00
|
|
|
if(s)
|
2008-08-27 15:48:50 +00:00
|
|
|
{
|
2010-05-29 07:25:38 +00:00
|
|
|
TextRender()->TextEx(&Cursor, pName, (int)(s-pName));
|
2011-03-18 16:59:48 +00:00
|
|
|
TextRender()->TextColor(0.4f, 0.4f, 1.0f, 1.0f);
|
2010-05-29 07:25:38 +00:00
|
|
|
TextRender()->TextEx(&Cursor, s, str_length(g_Config.m_BrFilterString));
|
2011-03-18 16:59:48 +00:00
|
|
|
TextRender()->TextColor(1.0f, 1.0f, 1.0f, 1.0f);
|
2010-05-29 07:25:38 +00:00
|
|
|
TextRender()->TextEx(&Cursor, s+str_length(g_Config.m_BrFilterString), -1);
|
2008-08-27 15:48:50 +00:00
|
|
|
}
|
|
|
|
else
|
2010-05-29 07:25:38 +00:00
|
|
|
TextRender()->TextEx(&Cursor, pName, -1);
|
2008-08-27 15:48:50 +00:00
|
|
|
}
|
2008-09-04 18:42:26 +00:00
|
|
|
else
|
2010-05-29 07:25:38 +00:00
|
|
|
TextRender()->TextEx(&Cursor, pName, -1);
|
|
|
|
|
2011-03-18 16:59:48 +00:00
|
|
|
// clan
|
|
|
|
TextRender()->SetCursor(&Cursor, Clan.x, Clan.y, FontSize-2, TEXTFLAG_RENDER|TEXTFLAG_STOP_AT_END);
|
|
|
|
Cursor.m_LineWidth = Clan.w;
|
2011-03-20 14:33:49 +00:00
|
|
|
const char *pClan = pSelectedServer->m_aClients[i].m_aClan;
|
2011-03-18 16:59:48 +00:00
|
|
|
if(g_Config.m_BrFilterString[0])
|
|
|
|
{
|
|
|
|
// highlight the parts that matches
|
|
|
|
const char *s = str_find_nocase(pClan, g_Config.m_BrFilterString);
|
|
|
|
if(s)
|
|
|
|
{
|
|
|
|
TextRender()->TextEx(&Cursor, pClan, (int)(s-pClan));
|
|
|
|
TextRender()->TextColor(0.4f, 0.4f, 1.0f, 1.0f);
|
|
|
|
TextRender()->TextEx(&Cursor, s, str_length(g_Config.m_BrFilterString));
|
|
|
|
TextRender()->TextColor(1.0f, 1.0f, 1.0f, 1.0f);
|
|
|
|
TextRender()->TextEx(&Cursor, s+str_length(g_Config.m_BrFilterString), -1);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
TextRender()->TextEx(&Cursor, pClan, -1);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
TextRender()->TextEx(&Cursor, pClan, -1);
|
|
|
|
|
|
|
|
// flag
|
2012-01-08 17:16:38 +00:00
|
|
|
vec4 Color(1.0f, 1.0f, 1.0f, 0.5f);
|
|
|
|
m_pClient->m_pCountryFlags->Render(pSelectedServer->m_aClients[i].m_Country, &Color, Flag.x, Flag.y, Flag.w, Flag.h);
|
2008-08-27 15:48:50 +00:00
|
|
|
}
|
2014-01-10 11:22:48 +00:00
|
|
|
|
|
|
|
UiDoListboxEnd(&s_ScrollValue, 0);
|
2008-08-27 15:48:50 +00:00
|
|
|
}
|
2008-09-04 18:42:26 +00:00
|
|
|
}
|
2008-08-27 15:48:50 +00:00
|
|
|
|
2011-06-26 15:10:13 +00:00
|
|
|
void CMenus::FriendlistOnUpdate()
|
|
|
|
{
|
|
|
|
m_lFriends.clear();
|
|
|
|
for(int i = 0; i < m_pClient->Friends()->NumFriends(); ++i)
|
|
|
|
{
|
|
|
|
CFriendItem Item;
|
|
|
|
Item.m_pFriendInfo = m_pClient->Friends()->GetFriend(i);
|
|
|
|
Item.m_NumFound = 0;
|
|
|
|
m_lFriends.add_unsorted(Item);
|
|
|
|
}
|
|
|
|
m_lFriends.sort_range();
|
|
|
|
}
|
|
|
|
|
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
|
|
|
|
|
|
|
// header
|
|
|
|
ServerFriends.HSplitTop(ms_ListheaderHeight, &FilterHeader, &ServerFriends);
|
|
|
|
RenderTools()->DrawUIRect(&FilterHeader, vec4(1,1,1,0.25f), CUI::CORNER_T, 4.0f);
|
|
|
|
RenderTools()->DrawUIRect(&ServerFriends, vec4(0,0,0,0.15f), 0, 4.0f);
|
2011-06-26 15:10:13 +00:00
|
|
|
UI()->DoLabelScaled(&FilterHeader, Localize("Friends"), FontSize+4.0f, 0);
|
2011-03-23 12:06:35 +00:00
|
|
|
CUIRect Button, List;
|
2010-05-29 07:25:38 +00:00
|
|
|
|
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)
|
|
|
|
static float s_ScrollValue = 0;
|
2013-03-16 15:03:38 +00:00
|
|
|
if(m_FriendlistSelectedIndex >= m_lFriends.size())
|
|
|
|
m_FriendlistSelectedIndex = m_lFriends.size()-1;
|
2014-06-16 11:29:18 +00:00
|
|
|
#if defined(__ANDROID__)
|
|
|
|
UiDoListboxStart(&m_lFriends, &List, 50.0f, "", "", m_lFriends.size(), 1, m_FriendlistSelectedIndex, s_ScrollValue);
|
|
|
|
#else
|
2011-06-26 15:10:13 +00:00
|
|
|
UiDoListboxStart(&m_lFriends, &List, 30.0f, "", "", m_lFriends.size(), 1, m_FriendlistSelectedIndex, s_ScrollValue);
|
2014-06-16 11:29:18 +00:00
|
|
|
#endif
|
2011-04-13 18:37:12 +00:00
|
|
|
|
2011-06-26 15:10:13 +00:00
|
|
|
m_lFriends.sort_range();
|
|
|
|
for(int i = 0; i < m_lFriends.size(); ++i)
|
2011-03-23 12:06:35 +00:00
|
|
|
{
|
2011-06-26 15:10:13 +00:00
|
|
|
CListboxItem Item = UiDoListboxNextItem(&m_lFriends[i]);
|
2011-04-13 18:37:12 +00:00
|
|
|
|
2011-03-23 12:06:35 +00:00
|
|
|
if(Item.m_Visible)
|
|
|
|
{
|
2011-06-26 15:10:13 +00:00
|
|
|
Item.m_Rect.Margin(1.5f, &Item.m_Rect);
|
|
|
|
CUIRect OnState;
|
|
|
|
Item.m_Rect.VSplitRight(30.0f, &Item.m_Rect, &OnState);
|
|
|
|
RenderTools()->DrawUIRect(&Item.m_Rect, vec4(1.0f, 1.0f, 1.0f, 0.1f), CUI::CORNER_L, 4.0f);
|
|
|
|
|
|
|
|
Item.m_Rect.VMargin(2.5f, &Item.m_Rect);
|
|
|
|
Item.m_Rect.HSplitTop(12.0f, &Item.m_Rect, &Button);
|
|
|
|
UI()->DoLabelScaled(&Item.m_Rect, m_lFriends[i].m_pFriendInfo->m_aName, FontSize, -1);
|
|
|
|
UI()->DoLabelScaled(&Button, m_lFriends[i].m_pFriendInfo->m_aClan, FontSize, -1);
|
|
|
|
|
|
|
|
RenderTools()->DrawUIRect(&OnState, m_lFriends[i].m_NumFound ? vec4(0.0f, 1.0f, 0.0f, 0.25f) : vec4(1.0f, 0.0f, 0.0f, 0.25f), CUI::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", m_lFriends[i].m_NumFound);
|
|
|
|
UI()->DoLabelScaled(&OnState, aBuf, FontSize+2, 1);
|
2011-03-23 12:06:35 +00:00
|
|
|
}
|
|
|
|
}
|
2011-04-13 18:37:12 +00:00
|
|
|
|
2011-06-26 15:10:13 +00:00
|
|
|
bool Activated = false;
|
|
|
|
m_FriendlistSelectedIndex = UiDoListboxEnd(&s_ScrollValue, &Activated);
|
|
|
|
|
|
|
|
// activate found server with friend
|
|
|
|
if(Activated && !m_EnterPressed && m_lFriends[m_FriendlistSelectedIndex].m_NumFound)
|
|
|
|
{
|
|
|
|
bool Found = false;
|
|
|
|
int NumServers = ServerBrowser()->NumSortedServers();
|
|
|
|
for (int i = 0; i < NumServers && !Found; i++)
|
|
|
|
{
|
|
|
|
int ItemIndex = m_SelectedIndex != -1 ? (m_SelectedIndex+i+1)%NumServers : i;
|
|
|
|
const CServerInfo *pItem = ServerBrowser()->SortedGet(ItemIndex);
|
|
|
|
if(pItem->m_FriendState != IFriends::FRIEND_NO)
|
|
|
|
{
|
|
|
|
for(int j = 0; j < pItem->m_NumClients && !Found; ++j)
|
|
|
|
{
|
|
|
|
if(pItem->m_aClients[j].m_FriendState != IFriends::FRIEND_NO &&
|
|
|
|
str_quickhash(pItem->m_aClients[j].m_aClan) == m_lFriends[m_FriendlistSelectedIndex].m_pFriendInfo->m_ClanHash &&
|
|
|
|
(!m_lFriends[m_FriendlistSelectedIndex].m_pFriendInfo->m_aName[0] ||
|
|
|
|
str_quickhash(pItem->m_aClients[j].m_aName) == m_lFriends[m_FriendlistSelectedIndex].m_pFriendInfo->m_NameHash))
|
|
|
|
{
|
|
|
|
str_copy(g_Config.m_UiServerAddress, pItem->m_aAddress, sizeof(g_Config.m_UiServerAddress));
|
|
|
|
m_ScrollOffset = ItemIndex;
|
|
|
|
m_SelectedIndex = ItemIndex;
|
|
|
|
Found = true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2011-03-23 12:06:35 +00:00
|
|
|
|
|
|
|
ServerFriends.HSplitTop(2.5f, 0, &ServerFriends);
|
|
|
|
ServerFriends.HSplitTop(20.0f, &Button, &ServerFriends);
|
|
|
|
if(m_FriendlistSelectedIndex != -1)
|
|
|
|
{
|
|
|
|
static int s_RemoveButton = 0;
|
|
|
|
if(DoButton_Menu(&s_RemoveButton, Localize("Remove"), 0, &Button))
|
|
|
|
m_Popup = POPUP_REMOVE_FRIEND;
|
|
|
|
}
|
|
|
|
|
|
|
|
// 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"));
|
|
|
|
UI()->DoLabelScaled(&Button, aBuf, FontSize, -1);
|
|
|
|
Button.VSplitLeft(80.0f, 0, &Button);
|
|
|
|
static char s_aName[MAX_NAME_LENGTH] = {0};
|
|
|
|
static float s_OffsetName = 0.0f;
|
|
|
|
DoEditBox(&s_aName, &Button, s_aName, sizeof(s_aName), FontSize, &s_OffsetName);
|
|
|
|
|
|
|
|
ServerFriends.HSplitTop(3.0f, 0, &ServerFriends);
|
|
|
|
ServerFriends.HSplitTop(19.0f, &Button, &ServerFriends);
|
|
|
|
str_format(aBuf, sizeof(aBuf), "%s:", Localize("Clan"));
|
|
|
|
UI()->DoLabelScaled(&Button, aBuf, FontSize, -1);
|
|
|
|
Button.VSplitLeft(80.0f, 0, &Button);
|
|
|
|
static char s_aClan[MAX_CLAN_LENGTH] = {0};
|
|
|
|
static float s_OffsetClan = 0.0f;
|
|
|
|
DoEditBox(&s_aClan, &Button, s_aClan, sizeof(s_aClan), FontSize, &s_OffsetClan);
|
|
|
|
|
|
|
|
ServerFriends.HSplitTop(3.0f, 0, &ServerFriends);
|
|
|
|
ServerFriends.HSplitTop(20.0f, &Button, &ServerFriends);
|
2011-06-26 15:10:13 +00:00
|
|
|
static int s_AddButton = 0;
|
|
|
|
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();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
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
|
|
|
|
2011-03-18 16:59:48 +00:00
|
|
|
CUIRect ServerList, ToolBox, StatusBox, TabBar;
|
2010-05-29 07:25:38 +00:00
|
|
|
|
2011-03-18 16:59:48 +00:00
|
|
|
// background
|
|
|
|
RenderTools()->DrawUIRect(&MainView, ms_ColorTabbarActive, CUI::CORNER_ALL, 10.0f);
|
|
|
|
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.HSplitBottom(70.0f, &ServerList, &StatusBox);
|
|
|
|
StatusBox.VSplitRight(100.0f, &StatusBox, &TabBar);
|
|
|
|
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;
|
|
|
|
|
2011-03-18 16:59:48 +00:00
|
|
|
// tab bar
|
2008-09-04 18:42:26 +00:00
|
|
|
{
|
2011-03-23 12:06:35 +00:00
|
|
|
CUIRect TabButton0, TabButton1, TabButton2;
|
2011-03-18 16:59:48 +00:00
|
|
|
TabBar.HSplitTop(5.0f, 0, &TabBar);
|
|
|
|
TabBar.HSplitTop(20.0f, &TabButton0, &TabBar);
|
2011-03-23 12:06:35 +00:00
|
|
|
TabBar.HSplitTop(2.5f, 0, &TabBar);
|
|
|
|
TabBar.HSplitTop(20.0f, &TabButton1, &TabBar);
|
|
|
|
TabBar.HSplitTop(2.5f, 0, &TabBar);
|
|
|
|
TabBar.HSplitTop(20.0f, &TabButton2, 0);
|
2011-03-18 16:59:48 +00:00
|
|
|
vec4 Active = ms_ColorTabbarActive;
|
|
|
|
vec4 InActive = ms_ColorTabbarInactive;
|
|
|
|
ms_ColorTabbarActive = vec4(0.0f, 0.0f, 0.0f, 0.3f);
|
|
|
|
ms_ColorTabbarInactive = vec4(0.0f, 0.0f, 0.0f, 0.15f);
|
2010-05-29 07:25:38 +00:00
|
|
|
|
|
|
|
static int s_FiltersTab = 0;
|
2011-03-18 16:59:48 +00:00
|
|
|
if (DoButton_MenuTab(&s_FiltersTab, Localize("Filter"), ToolboxPage==0, &TabButton0, CUI::CORNER_L))
|
2010-05-29 07:25:38 +00:00
|
|
|
ToolboxPage = 0;
|
|
|
|
|
|
|
|
static int s_InfoTab = 0;
|
2011-03-18 16:59:48 +00:00
|
|
|
if (DoButton_MenuTab(&s_InfoTab, Localize("Info"), ToolboxPage==1, &TabButton1, CUI::CORNER_L))
|
2010-05-29 07:25:38 +00:00
|
|
|
ToolboxPage = 1;
|
2008-09-04 18:42:26 +00:00
|
|
|
|
2011-03-23 12:06:35 +00:00
|
|
|
static int s_FriendsTab = 0;
|
|
|
|
if (DoButton_MenuTab(&s_FriendsTab, Localize("Friends"), ToolboxPage==2, &TabButton2, CUI::CORNER_L))
|
|
|
|
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;
|
|
|
|
}
|
2010-05-29 07:25:38 +00:00
|
|
|
|
2011-03-18 16:59:48 +00:00
|
|
|
// tool box
|
|
|
|
{
|
|
|
|
RenderTools()->DrawUIRect(&ToolBox, vec4(0.0f, 0.0f, 0.0f, 0.15f), CUI::CORNER_T, 4.0f);
|
2011-04-13 18:37:12 +00:00
|
|
|
|
2010-05-29 07:25:38 +00:00
|
|
|
|
2011-03-18 16:59:48 +00:00
|
|
|
if(ToolboxPage == 0)
|
2014-09-18 14:13:06 +00:00
|
|
|
RenderServerbrowserFilters(ToolBox);
|
2011-03-18 16:59:48 +00:00
|
|
|
else if(ToolboxPage == 1)
|
|
|
|
RenderServerbrowserServerDetail(ToolBox);
|
2011-03-23 12:06:35 +00:00
|
|
|
else if(ToolboxPage == 2)
|
|
|
|
RenderServerbrowserFriends(ToolBox);
|
2011-03-18 16:59:48 +00:00
|
|
|
}
|
2008-08-27 15:48:50 +00:00
|
|
|
|
2011-03-18 16:59:48 +00:00
|
|
|
// status box
|
2008-09-04 18:25:12 +00:00
|
|
|
{
|
2011-03-18 16:59:48 +00:00
|
|
|
CUIRect Button, ButtonArea;
|
|
|
|
StatusBox.HSplitTop(5.0f, 0, &StatusBox);
|
2010-05-29 07:25:38 +00:00
|
|
|
|
2011-03-18 16:59:48 +00:00
|
|
|
// version note
|
|
|
|
StatusBox.HSplitBottom(15.0f, &StatusBox, &Button);
|
|
|
|
char aBuf[64];
|
|
|
|
if(str_comp(Client()->LatestVersion(), "0") != 0)
|
2011-04-01 16:06:59 +00:00
|
|
|
{
|
2014-01-14 22:13:17 +00:00
|
|
|
str_format(aBuf, sizeof(aBuf), Localize("DDNet %s is out! Download it at ddnet.tw!"), Client()->LatestVersion());
|
2011-04-01 16:06:59 +00:00
|
|
|
TextRender()->TextColor(1.0f, 0.4f, 0.4f, 1.0f);
|
|
|
|
}
|
2011-03-18 16:59:48 +00:00
|
|
|
else
|
|
|
|
str_format(aBuf, sizeof(aBuf), Localize("Current version: %s"), GAME_VERSION);
|
|
|
|
UI()->DoLabelScaled(&Button, aBuf, 14.0f, -1);
|
2011-04-01 16:06:59 +00:00
|
|
|
TextRender()->TextColor(1.0f, 1.0f, 1.0f, 1.0f);
|
2010-05-29 07:25:38 +00:00
|
|
|
|
2011-03-18 16:59:48 +00:00
|
|
|
// button area
|
|
|
|
StatusBox.VSplitRight(80.0f, &StatusBox, 0);
|
|
|
|
StatusBox.VSplitRight(170.0f, &StatusBox, &ButtonArea);
|
|
|
|
ButtonArea.VSplitRight(150.0f, 0, &ButtonArea);
|
|
|
|
ButtonArea.HSplitTop(20.0f, &Button, &ButtonArea);
|
2010-05-29 07:25:38 +00:00
|
|
|
Button.VMargin(2.0f, &Button);
|
2011-04-13 18:37:12 +00:00
|
|
|
|
2010-05-29 07:25:38 +00:00
|
|
|
static int s_RefreshButton = 0;
|
|
|
|
if(DoButton_Menu(&s_RefreshButton, Localize("Refresh"), 0, &Button))
|
2008-09-04 18:25:12 +00:00
|
|
|
{
|
2010-05-29 07:25:38 +00:00
|
|
|
if(g_Config.m_UiPage == PAGE_INTERNET)
|
|
|
|
ServerBrowser()->Refresh(IServerBrowser::TYPE_INTERNET);
|
|
|
|
else if(g_Config.m_UiPage == PAGE_LAN)
|
|
|
|
ServerBrowser()->Refresh(IServerBrowser::TYPE_LAN);
|
|
|
|
else if(g_Config.m_UiPage == PAGE_FAVORITES)
|
|
|
|
ServerBrowser()->Refresh(IServerBrowser::TYPE_FAVORITES);
|
2014-09-13 14:36:25 +00:00
|
|
|
else if(g_Config.m_UiPage == PAGE_DDNET)
|
2014-09-19 22:36:22 +00:00
|
|
|
{
|
|
|
|
// start a new serverlist request
|
|
|
|
Client()->RequestDDNetSrvList();
|
2014-09-13 14:36:25 +00:00
|
|
|
ServerBrowser()->Refresh(IServerBrowser::TYPE_DDNET);
|
2014-09-19 22:36:22 +00:00
|
|
|
}
|
2014-06-16 11:29:18 +00:00
|
|
|
m_DoubleClickIndex = -1;
|
2008-09-04 18:25:12 +00:00
|
|
|
}
|
2010-05-29 07:25:38 +00:00
|
|
|
|
2011-03-18 16:59:48 +00:00
|
|
|
ButtonArea.HSplitTop(5.0f, 0, &ButtonArea);
|
|
|
|
ButtonArea.HSplitTop(20.0f, &Button, &ButtonArea);
|
2010-05-29 07:25:38 +00:00
|
|
|
Button.VMargin(2.0f, &Button);
|
2011-04-13 18:37:12 +00:00
|
|
|
|
2010-05-29 07:25:38 +00:00
|
|
|
static int s_JoinButton = 0;
|
|
|
|
if(DoButton_Menu(&s_JoinButton, Localize("Connect"), 0, &Button) || m_EnterPressed)
|
2009-01-21 21:19:10 +00:00
|
|
|
{
|
2010-05-29 07:25:38 +00:00
|
|
|
Client()->Connect(g_Config.m_UiServerAddress);
|
|
|
|
m_EnterPressed = false;
|
2009-01-21 21:19:10 +00:00
|
|
|
}
|
2010-05-29 07:25:38 +00:00
|
|
|
|
2011-03-18 16:59:48 +00:00
|
|
|
// address info
|
|
|
|
StatusBox.VSplitLeft(20.0f, 0, &StatusBox);
|
|
|
|
StatusBox.HSplitTop(20.0f, &Button, &StatusBox);
|
|
|
|
UI()->DoLabelScaled(&Button, Localize("Host address"), 14.0f, -1);
|
|
|
|
StatusBox.HSplitTop(20.0f, &Button, 0);
|
2010-05-29 15:53:57 +00:00
|
|
|
static float Offset = 0.0f;
|
|
|
|
DoEditBox(&g_Config.m_UiServerAddress, &Button, g_Config.m_UiServerAddress, sizeof(g_Config.m_UiServerAddress), 14.0f, &Offset);
|
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);
|
2014-09-13 14:36:25 +00:00
|
|
|
if(pResult->NumArguments() && (g_Config.m_UiPage == PAGE_FAVORITES || g_Config.m_UiPage == PAGE_DDNET) && ((CMenus *)pUserData)->Client()->State() == IClient::STATE_OFFLINE)
|
2010-07-04 14:10:00 +00:00
|
|
|
((CMenus *)pUserData)->ServerBrowser()->Refresh(IServerBrowser::TYPE_FAVORITES);
|
|
|
|
}
|