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>
|
2020-09-26 19:41:58 +00:00
|
|
|
#include <engine/shared/config.h>
|
2010-05-29 07:25:38 +00:00
|
|
|
#include <engine/textrender.h>
|
2015-04-18 19:17:27 +00:00
|
|
|
#include <engine/updater.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
|
|
|
|
2020-09-26 19:41:58 +00:00
|
|
|
#include <game/client/components/console.h>
|
|
|
|
#include <game/client/components/countryflags.h>
|
2011-03-18 16:59:48 +00:00
|
|
|
#include <game/client/render.h>
|
|
|
|
#include <game/client/ui.h>
|
2020-09-26 19:41:58 +00:00
|
|
|
#include <game/localization.h>
|
|
|
|
#include <game/version.h>
|
2011-03-18 16:59:48 +00:00
|
|
|
|
|
|
|
#include "menus.h"
|
|
|
|
|
2020-10-12 10:29:47 +00:00
|
|
|
static const int g_OffsetColFlagLock = 2;
|
|
|
|
static const int g_OffsetColFav = g_OffsetColFlagLock + 3;
|
|
|
|
static const int g_OffsetColOff = g_OffsetColFav + 3;
|
|
|
|
static const int g_OffsetColName = g_OffsetColOff + 3;
|
|
|
|
static const int g_OffsetColGameType = g_OffsetColName + 3;
|
|
|
|
static const int g_OffsetColMap = g_OffsetColGameType + 3;
|
|
|
|
static const int g_OffsetColPlayers = g_OffsetColMap + 3;
|
|
|
|
static const int g_OffsetColPing = g_OffsetColPlayers + 3;
|
|
|
|
static const int g_OffsetColVersion = g_OffsetColPing + 3;
|
|
|
|
|
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
|
|
|
|
"AFR", // LOC_AFRICA // Localize("AFR")
|
|
|
|
"ASI", // LOC_ASIA // Localize("ASI")
|
|
|
|
"AUS", // LOC_AUSTRALIA // Localize("AUS")
|
|
|
|
"EUR", // LOC_EUROPE // Localize("EUR")
|
|
|
|
"NA", // LOC_NORTH_AMERICA // Localize("NA")
|
|
|
|
"SA", // LOC_SOUTH_AMERICA // Localize("SA")
|
2021-04-24 13:48:27 +00:00
|
|
|
"CHN", // LOC_CHINA // Localize("CHN")
|
2018-07-11 20:46:04 +00:00
|
|
|
};
|
|
|
|
dbg_assert(0 <= pInfo->m_Location && pInfo->m_Location < CServerInfo::NUM_LOCS, "location out of range");
|
|
|
|
str_format(pBuffer, BufferLength, "%s", Localize(LOCATION_NAMES[pInfo->m_Location]));
|
|
|
|
}
|
|
|
|
|
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);
|
2020-09-19 20:03:21 +00:00
|
|
|
View.HSplitBottom(70.0f, &View, &Status);
|
2008-08-27 15:48:50 +00:00
|
|
|
|
|
|
|
// split of the scrollbar
|
2020-09-26 19:41:58 +00:00
|
|
|
RenderTools()->DrawUIRect(&Headers, ColorRGBA(1, 1, 1, 0.25f), CUI::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;
|
|
|
|
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
|
|
|
|
{
|
2020-09-26 19:41:58 +00:00
|
|
|
FIXED = 1,
|
|
|
|
SPACER = 2,
|
2010-05-29 07:25:38 +00:00
|
|
|
|
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[] = {
|
2020-09-26 19:41:58 +00:00
|
|
|
{-1, -1, " ", -1, 2.0f, 0, {0}, {0}},
|
|
|
|
{COL_FLAG_LOCK, -1, " ", -1, 14.0f, 0, {0}, {0}},
|
|
|
|
{COL_FLAG_FAV, -1, " ", -1, 14.0f, 0, {0}, {0}},
|
|
|
|
{COL_FLAG_OFFICIAL, -1, " ", -1, 14.0f, 0, {0}, {0}},
|
|
|
|
{COL_NAME, IServerBrowser::SORT_NAME, "Name", 0, 50.0f, 0, {0}, {0}}, // Localize - these strings are localized within CLocConstString
|
|
|
|
{COL_GAMETYPE, IServerBrowser::SORT_GAMETYPE, "Type", 1, 50.0f, 0, {0}, {0}},
|
|
|
|
{COL_MAP, IServerBrowser::SORT_MAP, "Map", 1, 120.0f + (Headers.w - 480) / 8, 0, {0}, {0}},
|
|
|
|
{COL_PLAYERS, IServerBrowser::SORT_NUMPLAYERS, "Players", 1, 60.0f, 0, {0}, {0}},
|
|
|
|
{-1, -1, " ", 1, 10.0f, 0, {0}, {0}},
|
|
|
|
{COL_PING, IServerBrowser::SORT_PING, "Ping", 1, 40.0f, FIXED, {0}, {0}},
|
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
|
|
|
|
2020-09-26 19:41:58 +00:00
|
|
|
int NumCols = sizeof(s_aCols) / sizeof(CColumn);
|
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
|
|
|
//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
|
|
|
|
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
|
|
|
|
2020-09-26 19:41:58 +00:00
|
|
|
RenderTools()->DrawUIRect(&View, ColorRGBA(0, 0, 0, 0.15f), 0, 0);
|
2010-05-29 07:25:38 +00:00
|
|
|
|
|
|
|
CUIRect Scroll;
|
2020-12-14 05:50:20 +00:00
|
|
|
View.VSplitRight(10, &View, &Scroll);
|
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;
|
|
|
|
|
2018-07-11 20:46:04 +00:00
|
|
|
if(ServerBrowser()->IsGettingServerlist())
|
2021-05-27 07:02:35 +00:00
|
|
|
UI()->DoLabelScaled(&MsgBox, Localize("Getting server list from master server"), 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-05-29 07:25:38 +00:00
|
|
|
static int s_ScrollBar = 0;
|
|
|
|
static float s_ScrollValue = 0;
|
|
|
|
|
|
|
|
s_ScrollValue = DoScrollbarV(&s_ScrollBar, &Scroll, s_ScrollValue);
|
|
|
|
|
2016-04-30 18:11:26 +00:00
|
|
|
if(Input()->KeyPress(KEY_TAB) && m_pClient->m_pGameConsole->IsClosed())
|
2015-06-28 13:43:34 +00:00
|
|
|
{
|
2016-04-30 18:11:26 +00:00
|
|
|
if(Input()->KeyIsPressed(KEY_LSHIFT) || Input()->KeyIsPressed(KEY_RSHIFT))
|
2015-06-28 13:43:34 +00:00
|
|
|
g_Config.m_UiToolboxPage = (g_Config.m_UiToolboxPage + 3 - 1) % 3;
|
|
|
|
else
|
|
|
|
g_Config.m_UiToolboxPage = (g_Config.m_UiToolboxPage + 3 + 1) % 3;
|
|
|
|
}
|
2020-08-16 17:32:46 +00:00
|
|
|
|
2020-11-12 13:20:38 +00:00
|
|
|
if(HandleListInputs(View, s_ScrollValue, 3.0f, &m_ScrollOffset, s_aCols[0].m_Rect.h, m_SelectedIndex, NumServers))
|
2010-05-29 07:25:38 +00:00
|
|
|
{
|
2020-11-12 13:20:38 +00:00
|
|
|
const CServerInfo *pItem = ServerBrowser()->SortedGet(m_SelectedIndex);
|
|
|
|
str_copy(g_Config.m_UiServerAddress, pItem->m_aAddress, sizeof(g_Config.m_UiServerAddress));
|
2015-08-27 14:42:21 +00:00
|
|
|
}
|
2011-04-13 18:37:12 +00:00
|
|
|
|
2008-08-27 15:48:50 +00:00
|
|
|
// set clipping
|
2010-05-29 07:25:38 +00:00
|
|
|
UI()->ClipEnable(&View);
|
|
|
|
|
|
|
|
CUIRect OriginalView = View;
|
2020-11-12 13:20:38 +00:00
|
|
|
int Num = (int)(View.h / s_aCols[0].m_Rect.h) + 1;
|
2020-11-21 17:30:24 +00:00
|
|
|
int ScrollNum = maximum(NumServers - Num + 1, 0);
|
2020-09-26 19:41:58 +00:00
|
|
|
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-16 11:29:18 +00:00
|
|
|
int DoubleClicked = 0;
|
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
|
2020-09-26 19:41:58 +00:00
|
|
|
for(int i = 0; i < m_lFriends.size(); m_lFriends[i++].m_NumFound = 0)
|
|
|
|
;
|
2010-05-29 07:25:38 +00:00
|
|
|
|
2018-03-13 20:59:07 +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);
|
2018-10-29 21:03:57 +00:00
|
|
|
NumPlayers += pItem->m_NumFilteredPlayers;
|
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
|
|
|
|
2020-10-12 10:29:47 +00:00
|
|
|
//initialize
|
|
|
|
if(pItem->m_pUIElement == NULL)
|
|
|
|
{
|
|
|
|
pItem->m_pUIElement = UI()->GetNewUIElement();
|
|
|
|
}
|
|
|
|
|
|
|
|
const int UIRectCount = 2 + (COL_VERSION + 1) * 3;
|
|
|
|
|
|
|
|
if(pItem->m_pUIElement->Size() != UIRectCount)
|
|
|
|
{
|
|
|
|
UI()->ResetUIElement(*pItem->m_pUIElement);
|
|
|
|
|
|
|
|
for(int UIElIndex = 0; UIElIndex < UIRectCount; ++UIElIndex)
|
|
|
|
{
|
|
|
|
CUIElement::SUIElementRect AddRect;
|
|
|
|
pItem->m_pUIElement->Add(AddRect);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
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)
|
|
|
|
{
|
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)
|
|
|
|
{
|
|
|
|
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)
|
|
|
|
{
|
2017-04-12 09:13:54 +00:00
|
|
|
if(((g_Config.m_ClFriendsIgnoreClan && m_lFriends[f].m_pFriendInfo->m_aName[0]) || (ClanHash == m_lFriends[f].m_pFriendInfo->m_ClanHash && !str_comp(m_lFriends[f].m_pFriendInfo->m_aClan, pItem->m_aClients[j].m_aClan))) &&
|
|
|
|
(!m_lFriends[f].m_pFriendInfo->m_aName[0] || (NameHash == m_lFriends[f].m_pFriendInfo->m_NameHash && !str_comp(m_lFriends[f].m_pFriendInfo->m_aName, pItem->m_aClients[j].m_aName))))
|
2011-06-26 15:10:13 +00:00
|
|
|
{
|
|
|
|
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
|
2020-09-26 19:41:58 +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;
|
2018-03-13 20:59:07 +00:00
|
|
|
r.Margin(0.5f, &r);
|
2020-10-12 10:29:47 +00:00
|
|
|
RenderTools()->DrawUIElRect(*pItem->m_pUIElement->Get(0), &r, ColorRGBA(1, 1, 1, 0.5f), CUI::CORNER_ALL, 4.0f);
|
2010-05-29 07:25:38 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// clip the selection
|
|
|
|
if(SelectHitBox.y < OriginalView.y) // top
|
2008-08-27 15:48:50 +00:00
|
|
|
{
|
2020-09-26 19:41:58 +00:00
|
|
|
SelectHitBox.h -= OriginalView.y - SelectHitBox.y;
|
2010-05-29 07:25:38 +00:00
|
|
|
SelectHitBox.y = OriginalView.y;
|
2008-08-27 15:48:50 +00:00
|
|
|
}
|
2020-09-16 01:30:03 +00:00
|
|
|
else if(SelectHitBox.y + SelectHitBox.h > OriginalView.y + OriginalView.h) // bottom
|
|
|
|
SelectHitBox.h = OriginalView.y + OriginalView.h - SelectHitBox.y;
|
|
|
|
|
|
|
|
if(!Selected && UI()->MouseInside(&SelectHitBox))
|
|
|
|
{
|
|
|
|
CUIRect r = Row;
|
|
|
|
r.Margin(0.5f, &r);
|
2020-10-12 10:29:47 +00:00
|
|
|
RenderTools()->DrawUIElRect(*pItem->m_pUIElement->Get(1), &r, ColorRGBA(1, 1, 1, 0.25f), CUI::CORNER_ALL, 4.0f);
|
2020-09-16 01:30:03 +00:00
|
|
|
}
|
2010-05-29 07:25:38 +00:00
|
|
|
|
|
|
|
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-16 11:29:18 +00:00
|
|
|
if(NewSelected == m_DoubleClickIndex)
|
|
|
|
DoubleClicked = 1;
|
|
|
|
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
|
|
|
{
|
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_FAV)
|
2008-09-03 20:03:01 +00:00
|
|
|
{
|
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
|
|
|
}
|
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)
|
2019-03-19 06:46:48 +00:00
|
|
|
DoButton_Icon(IMAGE_BROWSEICONS, SPRITE_BROWSE_DDNET, &Button);
|
|
|
|
}
|
2011-02-12 10:40:36 +00:00
|
|
|
else if(ID == COL_NAME)
|
2008-08-27 15:48:50 +00:00
|
|
|
{
|
2018-03-13 20:59:07 +00:00
|
|
|
float FontSize = 12.0f * UI()->Scale();
|
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))
|
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
|
|
|
{
|
2020-10-12 10:29:47 +00:00
|
|
|
UI()->DoLabelStreamed(*pItem->m_pUIElement->Get(g_OffsetColName + 0), &Button, pItem->m_aName, FontSize, -1, Button.w, 1, true, (int)(pStr - pItem->m_aName));
|
2020-09-26 19:41:58 +00:00
|
|
|
TextRender()->TextColor(0.4f, 0.4f, 1.0f, 1);
|
2020-10-12 10:29:47 +00:00
|
|
|
UI()->DoLabelStreamed(*pItem->m_pUIElement->Get(g_OffsetColName + 1), &Button, pStr, FontSize, -1, Button.w, 1, true, (int)str_length(g_Config.m_BrFilterString), &pItem->m_pUIElement->Get(g_OffsetColName + 0)->m_Cursor);
|
2020-09-26 19:41:58 +00:00
|
|
|
TextRender()->TextColor(1, 1, 1, 1);
|
2020-10-12 10:29:47 +00:00
|
|
|
UI()->DoLabelStreamed(*pItem->m_pUIElement->Get(g_OffsetColName + 2), &Button, pStr + str_length(g_Config.m_BrFilterString), FontSize, -1, Button.w, 1, true, -1, &pItem->m_pUIElement->Get(g_OffsetColName + 1)->m_Cursor);
|
2008-08-27 15:48:50 +00:00
|
|
|
}
|
|
|
|
else
|
2020-10-12 10:29:47 +00:00
|
|
|
UI()->DoLabelStreamed(*pItem->m_pUIElement->Get(g_OffsetColName), &Button, pItem->m_aName, FontSize, -1, Button.w, 1, true);
|
2008-08-27 15:48:50 +00:00
|
|
|
}
|
|
|
|
else
|
2020-10-12 10:29:47 +00:00
|
|
|
UI()->DoLabelStreamed(*pItem->m_pUIElement->Get(g_OffsetColName), &Button, pItem->m_aName, FontSize, -1, 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)
|
|
|
|
DoButton_Icon(IMAGE_BROWSEICONS, SPRITE_BROWSE_RANK, &Icon);
|
2017-08-30 19:34:01 +00:00
|
|
|
}
|
|
|
|
|
2018-03-13 20:59:07 +00:00
|
|
|
float FontSize = 12.0f * UI()->Scale();
|
2011-03-18 18:14:35 +00:00
|
|
|
|
2020-09-26 19:41:58 +00:00
|
|
|
if(g_Config.m_BrFilterString[0] && (pItem->m_QuickSearchHit & IServerBrowser::QUICK_MAPNAME))
|
2011-03-18 18:14:35 +00:00
|
|
|
{
|
|
|
|
// highlight the parts that matches
|
|
|
|
const char *pStr = str_find_nocase(pItem->m_aMap, g_Config.m_BrFilterString);
|
|
|
|
if(pStr)
|
|
|
|
{
|
2020-10-12 10:29:47 +00:00
|
|
|
UI()->DoLabelStreamed(*pItem->m_pUIElement->Get(g_OffsetColMap + 0), &Button, pItem->m_aMap, FontSize, -1, Button.w, 1, true, (int)(pStr - pItem->m_aMap));
|
2020-09-26 19:41:58 +00:00
|
|
|
TextRender()->TextColor(0.4f, 0.4f, 1.0f, 1);
|
2020-10-12 10:29:47 +00:00
|
|
|
UI()->DoLabelStreamed(*pItem->m_pUIElement->Get(g_OffsetColMap + 1), &Button, pStr, FontSize, -1, Button.w, 1, true, (int)str_length(g_Config.m_BrFilterString), &pItem->m_pUIElement->Get(g_OffsetColMap + 0)->m_Cursor);
|
2020-09-26 19:41:58 +00:00
|
|
|
TextRender()->TextColor(1, 1, 1, 1);
|
2020-10-12 10:29:47 +00:00
|
|
|
UI()->DoLabelStreamed(*pItem->m_pUIElement->Get(g_OffsetColMap + 2), &Button, pStr + str_length(g_Config.m_BrFilterString), FontSize, -1, Button.w, 1, true, -1, &pItem->m_pUIElement->Get(g_OffsetColMap + 1)->m_Cursor);
|
2011-03-18 18:14:35 +00:00
|
|
|
}
|
|
|
|
else
|
2020-10-12 10:29:47 +00:00
|
|
|
UI()->DoLabelStreamed(*pItem->m_pUIElement->Get(g_OffsetColMap), &Button, pItem->m_aMap, FontSize, -1, Button.w, 1, true);
|
2011-03-18 18:14:35 +00:00
|
|
|
}
|
|
|
|
else
|
2020-10-12 10:29:47 +00:00
|
|
|
UI()->DoLabelStreamed(*pItem->m_pUIElement->Get(g_OffsetColMap), &Button, pItem->m_aMap, FontSize, -1, 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
|
|
|
{
|
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);
|
|
|
|
}
|
|
|
|
|
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);
|
2020-10-12 10:29:47 +00:00
|
|
|
float FontSize = 12.0f * UI()->Scale();
|
2020-11-09 20:24:06 +00:00
|
|
|
UI()->DoLabelStreamed(*pItem->m_pUIElement->Get(g_OffsetColPlayers), &Button, aTemp, FontSize, 1, -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
|
|
|
{
|
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
|
|
|
}
|
|
|
|
|
2020-10-12 10:29:47 +00:00
|
|
|
float FontSize = 12.0f * UI()->Scale();
|
2020-11-09 20:24:06 +00:00
|
|
|
UI()->DoLabelStreamed(*pItem->m_pUIElement->Get(g_OffsetColPing), &Button, aTemp, FontSize, 1, -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;
|
2020-10-12 10:29:47 +00:00
|
|
|
float FontSize = 12.0f * UI()->Scale();
|
2020-11-09 20:24:06 +00:00
|
|
|
UI()->DoLabelStreamed(*pItem->m_pUIElement->Get(g_OffsetColVersion), &Button, pVersion, FontSize, 1, -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
|
|
|
{
|
2018-03-13 20:59:07 +00:00
|
|
|
float FontSize = 12.0f * UI()->Scale();
|
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
|
|
|
|
2018-03-13 20:59:07 +00:00
|
|
|
if(IsVanilla(pItem))
|
2019-04-26 12:06:32 +00:00
|
|
|
hsl = ColorHSLA(0.33f, 1.0f, 0.75f);
|
2018-03-13 20:59:07 +00:00
|
|
|
else if(IsCatch(pItem))
|
2019-04-26 12:06:32 +00:00
|
|
|
hsl = ColorHSLA(0.17f, 1.0f, 0.75f);
|
2018-03-13 20:59:07 +00:00
|
|
|
else if(IsInsta(pItem))
|
2019-04-26 12:06:32 +00:00
|
|
|
hsl = ColorHSLA(0.00f, 1.0f, 0.75f);
|
2018-03-13 20:59:07 +00:00
|
|
|
else if(IsFNG(pItem))
|
2019-04-26 12:06:32 +00:00
|
|
|
hsl = ColorHSLA(0.83f, 1.0f, 0.75f);
|
2018-03-13 20:59:07 +00:00
|
|
|
else if(IsDDNet(pItem))
|
2019-04-26 12:06:32 +00:00
|
|
|
hsl = ColorHSLA(0.58f, 1.0f, 0.75f);
|
2018-03-13 20:59:07 +00:00
|
|
|
else if(IsDDRace(pItem))
|
2019-04-26 12:06:32 +00:00
|
|
|
hsl = ColorHSLA(0.75f, 1.0f, 0.75f);
|
2018-03-13 20:59:07 +00:00
|
|
|
else if(IsRace(pItem))
|
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);
|
2020-10-12 10:29:47 +00:00
|
|
|
UI()->DoLabelStreamed(*pItem->m_pUIElement->Get(g_OffsetColGameType), &Button, pItem->m_aGameType, FontSize, -1, Button.w, 1, true);
|
2014-05-03 15:24:34 +00:00
|
|
|
TextRender()->TextColor(1.0f, 1.0f, 1.0f, 1.0f);
|
|
|
|
}
|
|
|
|
else
|
2020-10-12 10:29:47 +00:00
|
|
|
UI()->DoLabelStreamed(*pItem->m_pUIElement->Get(g_OffsetColGameType), &Button, pItem->m_aGameType, FontSize, -1, Button.w, 1, true);
|
2014-05-03 15:24:34 +00:00
|
|
|
}
|
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));
|
2017-03-22 15:55:26 +00:00
|
|
|
if(Input()->MouseDoubleClick() && DoubleClicked)
|
2020-11-05 19:19:29 +00:00
|
|
|
{
|
2020-11-07 10:00:30 +00:00
|
|
|
if(Client()->State() == IClient::STATE_ONLINE && Client()->GetCurrentRaceTime() / 60 >= g_Config.m_ClConfirmDisconnectTime && g_Config.m_ClConfirmDisconnectTime >= 0)
|
2021-06-26 11:39:14 +00:00
|
|
|
{
|
|
|
|
m_Popup = POPUP_SWITCH_SERVER;
|
|
|
|
str_copy(m_aNextServer, g_Config.m_UiServerAddress, sizeof(m_aNextServer));
|
|
|
|
}
|
2020-11-05 19:19:29 +00:00
|
|
|
else
|
|
|
|
Client()->Connect(g_Config.m_UiServerAddress);
|
|
|
|
}
|
2008-08-27 15:48:50 +00:00
|
|
|
}
|
|
|
|
|
2020-09-19 20:03:21 +00:00
|
|
|
//RenderTools()->DrawUIRect(&Status, ms_ColorTabbarActive, CUI::CORNER_B, 5.0f);
|
2010-05-29 07:25:38 +00:00
|
|
|
Status.Margin(5.0f, &Status);
|
|
|
|
|
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;
|
|
|
|
const char *pSearchLabel = "\xEE\xA2\xB6"; // U+0e8b6
|
|
|
|
const char *pExcludeLabel = "\xEE\x85\x8B"; // U+0e14b
|
|
|
|
|
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);
|
|
|
|
UI()->DoLabelScaled(&QuickSearch, pSearchLabel, 16.0f, -1, -1, 0);
|
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"));
|
2020-09-19 20:03:21 +00:00
|
|
|
UI()->DoLabelScaled(&QuickSearch, aBufSearch, 14.0f, -1);
|
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
|
|
|
|
2014-12-10 03:49:16 +00:00
|
|
|
static float Offset = 0.0f;
|
2017-07-24 16:05:19 +00:00
|
|
|
if(Input()->KeyPress(KEY_F) && (Input()->KeyIsPressed(KEY_LCTRL) || Input()->KeyIsPressed(KEY_RCTRL)))
|
|
|
|
UI()->SetActiveItem(&g_Config.m_BrFilterString);
|
2010-05-29 07:25:38 +00:00
|
|
|
static int s_ClearButton = 0;
|
2020-09-19 20:03:21 +00:00
|
|
|
if(DoClearableEditBox(&g_Config.m_BrFilterString, &s_ClearButton, &QuickSearch, g_Config.m_BrFilterString, sizeof(g_Config.m_BrFilterString), 12.0f, &Offset, false, CUI::CORNER_ALL))
|
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);
|
|
|
|
UI()->DoLabelScaled(&QuickExclude, pExcludeLabel, 16.0f, -1, -1, 0);
|
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"));
|
2020-09-19 20:03:21 +00:00
|
|
|
UI()->DoLabelScaled(&QuickExclude, aBufExclude, 14.0f, -1);
|
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;
|
2014-12-10 03:49:16 +00:00
|
|
|
static float Offset = 0.0f;
|
2017-07-24 16:05:19 +00:00
|
|
|
if(Input()->KeyPress(KEY_X) && (Input()->KeyIsPressed(KEY_LCTRL) || Input()->KeyIsPressed(KEY_RCTRL)))
|
|
|
|
UI()->SetActiveItem(&g_Config.m_BrExcludeString);
|
2020-09-19 20:03:21 +00:00
|
|
|
if(DoClearableEditBox(&g_Config.m_BrExcludeString, &s_ClearButton, &QuickExclude, g_Config.m_BrExcludeString, sizeof(g_Config.m_BrExcludeString), 12.0f, &Offset, false, CUI::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);
|
|
|
|
UI()->DoLabelScaled(&PlysOnline, aBufPyr, 12.0f, -1);
|
|
|
|
SvrsOnline.VSplitRight(TextRender()->TextWidth(0, 12.0f, aBufSvr, -1, -1.0f), 0, &SvrsOnline);
|
|
|
|
UI()->DoLabelScaled(&SvrsOnline, aBufSvr, 12.0f, -1);
|
|
|
|
|
|
|
|
// status box
|
|
|
|
{
|
|
|
|
CUIRect ButtonRefresh, ButtonConnect, ButtonArea;
|
|
|
|
|
|
|
|
ServerAddr.Margin(2.0f, &ServerAddr);
|
|
|
|
|
|
|
|
// address info
|
|
|
|
UI()->DoLabelScaled(&ServerAddr, Localize("Server address:"), 14.0f, -1);
|
|
|
|
ServerAddr.VSplitLeft(SearchExcludeAddrStrMax + 5.0f + ExcludeSearchIconMax + 5.0f, NULL, &ServerAddr);
|
2020-09-29 20:41:24 +00:00
|
|
|
static int s_ClearButton = 0;
|
2020-09-16 01:30:03 +00:00
|
|
|
static float Offset = 0.0f;
|
2020-09-29 20:41:24 +00:00
|
|
|
DoClearableEditBox(&g_Config.m_UiServerAddress, &s_ClearButton, &ServerAddr, g_Config.m_UiServerAddress, sizeof(g_Config.m_UiServerAddress), 12.0f, &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 * {
|
|
|
|
if(ServerBrowser()->IsRefreshing())
|
|
|
|
str_format(m_aLocalStringHelper, sizeof(m_aLocalStringHelper), "%s (%d%%)", Localize("Refresh"), ServerBrowser()->LoadingProgression());
|
|
|
|
else
|
|
|
|
str_copy(m_aLocalStringHelper, Localize("Refresh"), sizeof(m_aLocalStringHelper));
|
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
|
|
|
|
2020-10-12 10:29:47 +00:00
|
|
|
if(DoButtonMenu(m_RefreshButton, &s_RefreshButton, Func, 0, &ButtonRefresh, true, false, CUI::CORNER_ALL) || Input()->KeyPress(KEY_F5) || (Input()->KeyPress(KEY_R) && (Input()->KeyIsPressed(KEY_LCTRL) || Input()->KeyIsPressed(KEY_RCTRL))))
|
2020-09-16 01:30:03 +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);
|
|
|
|
else if(g_Config.m_UiPage == PAGE_DDNET)
|
|
|
|
{
|
2021-05-27 07:02:35 +00:00
|
|
|
// start a new server list request
|
2020-09-16 01:30:03 +00:00
|
|
|
Client()->RequestDDNetInfo();
|
|
|
|
ServerBrowser()->Refresh(IServerBrowser::TYPE_DDNET);
|
|
|
|
}
|
|
|
|
else if(g_Config.m_UiPage == PAGE_KOG)
|
|
|
|
{
|
2021-05-27 07:02:35 +00:00
|
|
|
// start a new server list request
|
2020-09-16 01:30:03 +00:00
|
|
|
Client()->RequestDDNetInfo();
|
|
|
|
ServerBrowser()->Refresh(IServerBrowser::TYPE_KOG);
|
|
|
|
}
|
|
|
|
m_DoubleClickIndex = -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int s_JoinButton = 0;
|
2020-10-12 10:29:47 +00:00
|
|
|
|
|
|
|
if(DoButtonMenu(
|
|
|
|
m_ConnectButton, &s_JoinButton, []() -> const char * { return Localize("Connect"); }, 0, &ButtonConnect, false, false, CUI::CORNER_ALL, 5, 0, vec4(0.7f, 1, 0.7f, 0.1f), vec4(0.7f, 1, 0.7f, 0.2f)) ||
|
|
|
|
m_EnterPressed)
|
2020-09-16 01:30:03 +00:00
|
|
|
{
|
2020-11-07 10:00:30 +00:00
|
|
|
if(Client()->State() == IClient::STATE_ONLINE && Client()->GetCurrentRaceTime() / 60 >= g_Config.m_ClConfirmDisconnectTime && g_Config.m_ClConfirmDisconnectTime >= 0)
|
2021-06-26 11:39:14 +00:00
|
|
|
{
|
|
|
|
m_Popup = POPUP_SWITCH_SERVER;
|
|
|
|
str_copy(m_aNextServer, g_Config.m_UiServerAddress, sizeof(m_aNextServer));
|
|
|
|
}
|
2020-11-05 19:19:29 +00:00
|
|
|
else
|
|
|
|
Client()->Connect(g_Config.m_UiServerAddress);
|
2020-09-16 01:30:03 +00:00
|
|
|
m_EnterPressed = false;
|
|
|
|
}
|
|
|
|
}
|
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);
|
2020-09-16 01:30:03 +00:00
|
|
|
RenderTools()->DrawUIRect(&FilterHeader, ColorRGBA(1, 1, 1, 0.25f), CUI::CORNER_T, 4.0f);
|
|
|
|
|
|
|
|
RenderTools()->DrawUIRect(&ServerFilter, ColorRGBA(0, 0, 0, 0.15f), CUI::CORNER_B, 4.0f);
|
|
|
|
UI()->DoLabelScaled(&FilterHeader, Localize("Server filter"), FontSize + 2.0f, 0);
|
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-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_BrFilterCompatversion, Localize("Compatible version"), g_Config.m_BrFilterCompatversion, &Button))
|
2010-05-29 07:25:38 +00:00
|
|
|
g_Config.m_BrFilterCompatversion ^= 1;
|
|
|
|
|
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);
|
|
|
|
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
|
|
|
|
2020-09-02 16:26:26 +00:00
|
|
|
char aBuf[5] = "";
|
2020-09-02 21:08:33 +00:00
|
|
|
if(g_Config.m_BrFilterPing != 0)
|
2020-09-02 16:26:26 +00:00
|
|
|
str_format(aBuf, sizeof(aBuf), "%d", g_Config.m_BrFilterPing);
|
2010-05-29 15:53:57 +00:00
|
|
|
static float Offset = 0.0f;
|
2020-09-26 19:41:58 +00:00
|
|
|
if(DoEditBox(&g_Config.m_BrFilterPing, &EditBox, aBuf, sizeof(aBuf), FontSize, &Offset))
|
2020-09-03 01:08:34 +00:00
|
|
|
{
|
|
|
|
g_Config.m_BrFilterPing = clamp(str_toint(aBuf), 0, 999);
|
|
|
|
Client()->ServerBrowserUpdate();
|
|
|
|
}
|
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;
|
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);
|
2012-01-08 17:16:38 +00:00
|
|
|
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;
|
|
|
|
}
|
|
|
|
|
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
|
|
|
|
2014-12-14 15:45:18 +00:00
|
|
|
RenderTools()->DrawUIRect(&ServerFilter, ms_ColorTabbarActive, CUI::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
|
|
|
|
2014-12-14 15:45:18 +00:00
|
|
|
static int s_CountriesButton = 0;
|
|
|
|
if(DoButton_MenuTab(&s_CountriesButton, Localize("Countries"), s_ActivePage == 0, &Button, CUI::CORNER_TL))
|
|
|
|
{
|
|
|
|
s_ActivePage = 0;
|
|
|
|
}
|
2014-09-19 21:52:09 +00:00
|
|
|
|
2014-12-14 15:45:18 +00:00
|
|
|
static int s_TypesButton = 0;
|
|
|
|
if(DoButton_MenuTab(&s_TypesButton, Localize("Types"), s_ActivePage == 1, &Button2, CUI::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;
|
|
|
|
|
2017-08-30 20:36:39 +00:00
|
|
|
int Button = UI()->DoButtonLogic(&s_aTypeButtons[TypeIndex], "", 0, &Rect);
|
|
|
|
if(Button == 1)
|
2014-12-14 15:45:18 +00:00
|
|
|
{
|
2017-08-30 20:36:39 +00:00
|
|
|
// left click to toggle flag filter
|
|
|
|
if(Active)
|
2019-03-24 22:15:38 +00:00
|
|
|
ServerBrowser()->DDNetFilterAdd(pFilterExcludeTypes, pName);
|
2014-12-14 15:45:18 +00:00
|
|
|
else
|
2019-03-24 22:15:38 +00:00
|
|
|
ServerBrowser()->DDNetFilterRem(pFilterExcludeTypes, pName);
|
2014-12-14 15:45:18 +00:00
|
|
|
|
2019-03-24 22:15:38 +00:00
|
|
|
ServerBrowser()->Refresh(ServerBrowser()->GetCurrentType());
|
2014-12-14 15:45:18 +00:00
|
|
|
}
|
2017-08-30 20:36:39 +00:00
|
|
|
else if(Button == 2)
|
|
|
|
{
|
|
|
|
// right click to exclusively activate one
|
2019-03-24 22:15:38 +00:00
|
|
|
pFilterExcludeTypes[0] = '\0';
|
2018-03-13 20:59:07 +00:00
|
|
|
for(int j = 0; j < MaxTypes; ++j)
|
2017-08-30 20:36:39 +00:00
|
|
|
{
|
|
|
|
if(j != TypeIndex)
|
2019-03-24 22:15:38 +00:00
|
|
|
ServerBrowser()->DDNetFilterAdd(pFilterExcludeTypes, ServerBrowser()->GetType(Network, j));
|
2017-08-30 20:36:39 +00:00
|
|
|
}
|
2019-03-24 22:15:38 +00:00
|
|
|
ServerBrowser()->Refresh(ServerBrowser()->GetCurrentType());
|
2017-08-30 20:36:39 +00:00
|
|
|
}
|
|
|
|
else if(Button == 3)
|
|
|
|
{
|
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);
|
2014-12-14 15:45:18 +00:00
|
|
|
UI()->DoLabelScaled(&Rect, pName, FontSize, 0);
|
|
|
|
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
|
|
|
|
2017-08-30 20:36:39 +00:00
|
|
|
int Button = UI()->DoButtonLogic(&s_aFlagButtons[CountryIndex], "", 0, &Rect);
|
|
|
|
if(Button == 1)
|
2014-12-14 15:45:18 +00:00
|
|
|
{
|
2017-08-30 20:36:39 +00:00
|
|
|
// left click to toggle flag filter
|
|
|
|
if(Active)
|
2019-03-24 22:15:38 +00:00
|
|
|
ServerBrowser()->DDNetFilterAdd(pFilterExcludeCountries, pName);
|
2014-12-14 15:45:18 +00:00
|
|
|
else
|
2019-03-24 22:15:38 +00:00
|
|
|
ServerBrowser()->DDNetFilterRem(pFilterExcludeCountries, pName);
|
2014-12-14 15:45:18 +00:00
|
|
|
|
2019-03-24 22:15:38 +00:00
|
|
|
ServerBrowser()->Refresh(ServerBrowser()->GetCurrentType());
|
2014-12-14 15:45:18 +00:00
|
|
|
}
|
2017-08-30 20:36:39 +00:00
|
|
|
else if(Button == 2)
|
|
|
|
{
|
|
|
|
// right click to exclusively activate one
|
2019-03-24 22:15:38 +00:00
|
|
|
pFilterExcludeCountries[0] = '\0';
|
2018-03-13 20:59:07 +00:00
|
|
|
for(int j = 0; j < MaxFlags; ++j)
|
2017-08-30 20:36:39 +00:00
|
|
|
{
|
|
|
|
if(j != CountryIndex)
|
2019-03-24 22:15:38 +00:00
|
|
|
ServerBrowser()->DDNetFilterAdd(pFilterExcludeCountries, ServerBrowser()->GetCountryName(Network, j));
|
2017-08-30 20:36:39 +00:00
|
|
|
}
|
2019-03-24 22:15:38 +00:00
|
|
|
ServerBrowser()->Refresh(ServerBrowser()->GetCurrentType());
|
2017-08-30 20:36:39 +00:00
|
|
|
}
|
|
|
|
else if(Button == 3)
|
|
|
|
{
|
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);
|
2014-12-14 15:45:18 +00:00
|
|
|
m_pClient->m_pCountryFlags->Render(FlagID, &Color, Pos.x, Pos.y, FlagWidth, FlagHeight);
|
|
|
|
}
|
2014-09-19 21:52:09 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2014-05-03 15:24:34 +00:00
|
|
|
|
2010-05-29 07:25:38 +00:00
|
|
|
static int s_ClearButton = 0;
|
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_BrFilterPing = 999;
|
|
|
|
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;
|
2011-08-13 00:11:06 +00:00
|
|
|
g_Config.m_BrFilterCompatversion = 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
|
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);
|
2020-09-26 19:41:58 +00:00
|
|
|
RenderTools()->DrawUIRect(&ServerHeader, ColorRGBA(1, 1, 1, 0.25f), CUI::CORNER_T, 4.0f);
|
|
|
|
RenderTools()->DrawUIRect(&ServerDetails, ColorRGBA(0, 0, 0, 0.15f), CUI::CORNER_B, 4.0f);
|
|
|
|
UI()->DoLabelScaled(&ServerHeader, Localize("Server details"), FontSize + 2.0f, 0);
|
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
|
|
|
{
|
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[] = {
|
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
|
|
|
|
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);
|
2021-05-12 19:06:08 +00:00
|
|
|
CUIRect ButtonAddFav;
|
|
|
|
CUIRect ButtonLeakIp;
|
|
|
|
Button.VSplitMid(&ButtonAddFav, &ButtonLeakIp);
|
|
|
|
ButtonAddFav.VSplitLeft(5.0f, 0, &ButtonAddFav);
|
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;
|
|
|
|
if(DoButton_CheckBox(&s_AddFavButton, Localize("Favorite"), pSelectedServer->m_Favorite, &ButtonAddFav))
|
2008-09-03 20:03:01 +00:00
|
|
|
{
|
2010-05-29 07:25:38 +00:00
|
|
|
if(pSelectedServer->m_Favorite)
|
2021-05-12 19:06:08 +00:00
|
|
|
{
|
2010-05-29 07:25:38 +00:00
|
|
|
ServerBrowser()->RemoveFavorite(pSelectedServer->m_NetAddr);
|
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
|
|
|
{
|
2010-05-29 07:25:38 +00:00
|
|
|
ServerBrowser()->AddFavorite(pSelectedServer->m_NetAddr);
|
2021-05-12 19:06:08 +00:00
|
|
|
if(g_Config.m_UiPage == PAGE_LAN)
|
|
|
|
{
|
|
|
|
ServerBrowser()->FavoriteAllowPing(pSelectedServer->m_NetAddr, true);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if(pSelectedServer->m_Favorite)
|
|
|
|
{
|
|
|
|
bool IpLeak = ServerBrowser()->IsFavoritePingAllowed(pSelectedServer->m_NetAddr);
|
|
|
|
if(DoButton_CheckBox(&s_LeakIpButton, Localize("Leak IP"), IpLeak, &ButtonLeakIp))
|
|
|
|
{
|
|
|
|
ServerBrowser()->FavoriteAllowPing(pSelectedServer->m_NetAddr, !IpLeak);
|
|
|
|
}
|
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
|
|
|
|
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);
|
2020-12-21 11:17:07 +00:00
|
|
|
UI()->DoLabelScaled(&Row, Localize(Label), 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);
|
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
|
|
|
{
|
2014-01-08 05:15:56 +00:00
|
|
|
static int s_VoteList = 0;
|
|
|
|
static float s_ScrollValue = 0;
|
2017-03-29 10:56:13 +00:00
|
|
|
UiDoListboxStart(&s_VoteList, &ServerScoreBoard, 26.0f, Localize("Scoreboard"), "", pSelectedServer->m_NumReceivedClients, 1, -1, s_ScrollValue);
|
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
|
|
|
{
|
2021-04-01 14:48:38 +00:00
|
|
|
CListboxItem Item = UiDoListboxNextItem(&pSelectedServer->m_aClients[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);
|
2021-04-01 14:48:38 +00:00
|
|
|
if(UiLogicGetCurrentClickedItem() == i)
|
2011-06-26 15:10:13 +00:00
|
|
|
{
|
|
|
|
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();
|
|
|
|
}
|
|
|
|
|
2019-04-26 21:47:34 +00:00
|
|
|
ColorRGBA Color = pSelectedServer->m_aClients[i].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);
|
2019-04-26 21:47:34 +00:00
|
|
|
RenderTools()->DrawUIRect(&Name, Color, 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);
|
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
|
|
|
|
2014-02-19 13:24:26 +00:00
|
|
|
if(!pSelectedServer->m_aClients[i].m_Player)
|
|
|
|
str_copy(aTemp, "SPEC", sizeof(aTemp));
|
2019-03-18 12:13:37 +00:00
|
|
|
else if(IsRace(pSelectedServer) && g_Config.m_ClDDRaceScoreBoard)
|
2014-02-19 13:24:26 +00:00
|
|
|
{
|
|
|
|
if(pSelectedServer->m_aClients[i].m_Score == -9999 || pSelectedServer->m_aClients[i].m_Score == 0)
|
|
|
|
aTemp[0] = 0;
|
|
|
|
else
|
2020-10-18 21:33:45 +00:00
|
|
|
str_time((int64)abs(pSelectedServer->m_aClients[i].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
|
|
|
|
str_format(aTemp, sizeof(aTemp), "%d", pSelectedServer->m_aClients[i].m_Score);
|
|
|
|
|
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
|
|
|
|
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;
|
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
|
|
|
{
|
2020-09-26 19:41:58 +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);
|
2020-09-26 19:41:58 +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
|
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;
|
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)
|
|
|
|
{
|
2020-09-26 19:41:58 +00:00
|
|
|
TextRender()->TextEx(&Cursor, pClan, (int)(s - pClan));
|
2011-03-18 16:59:48 +00:00
|
|
|
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);
|
2020-09-26 19:41:58 +00:00
|
|
|
TextRender()->TextEx(&Cursor, s + str_length(g_Config.m_BrFilterString), -1);
|
2011-03-18 16:59:48 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
TextRender()->TextEx(&Cursor, pClan, -1);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
TextRender()->TextEx(&Cursor, pClan, -1);
|
|
|
|
|
|
|
|
// flag
|
2019-04-26 21:47:34 +00:00
|
|
|
ColorRGBA FColor(1.0f, 1.0f, 1.0f, 0.5f);
|
|
|
|
m_pClient->m_pCountryFlags->Render(pSelectedServer->m_aClients[i].m_Country, &FColor, 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
|
|
|
|
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);
|
2020-09-26 19:41:58 +00:00
|
|
|
RenderTools()->DrawUIRect(&FilterHeader, ColorRGBA(1, 1, 1, 0.25f), CUI::CORNER_T, 4.0f);
|
|
|
|
RenderTools()->DrawUIRect(&ServerFriends, ColorRGBA(0, 0, 0, 0.15f), 0, 4.0f);
|
|
|
|
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())
|
2020-09-26 19:41:58 +00:00
|
|
|
m_FriendlistSelectedIndex = m_lFriends.size() - 1;
|
2011-06-26 15:10:13 +00:00
|
|
|
UiDoListboxStart(&m_lFriends, &List, 30.0f, "", "", m_lFriends.size(), 1, m_FriendlistSelectedIndex, s_ScrollValue);
|
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
|
|
|
{
|
2016-04-27 18:26:33 +00:00
|
|
|
CListboxItem Item = UiDoListboxNextItem(&m_lFriends[i], false, false);
|
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);
|
2019-04-26 21:47:34 +00:00
|
|
|
RenderTools()->DrawUIRect(&Item.m_Rect, ColorRGBA(1.0f, 1.0f, 1.0f, 0.1f), CUI::CORNER_L, 4.0f);
|
2011-06-26 15:10:13 +00:00
|
|
|
|
|
|
|
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);
|
|
|
|
|
2019-04-26 21:47:34 +00:00
|
|
|
RenderTools()->DrawUIRect(&OnState, m_lFriends[i].m_NumFound ? ColorRGBA(0.0f, 1.0f, 0.0f, 0.25f) : ColorRGBA(1.0f, 0.0f, 0.0f, 0.25f), CUI::CORNER_R, 4.0f);
|
2020-09-26 19:41:58 +00:00
|
|
|
OnState.HMargin((OnState.h - FontSize) / 3, &OnState);
|
2011-06-26 15:10:13 +00:00
|
|
|
OnState.VMargin(5.0f, &OnState);
|
|
|
|
char aBuf[64];
|
|
|
|
str_format(aBuf, sizeof(aBuf), "%i", m_lFriends[i].m_NumFound);
|
2020-09-26 19:41:58 +00:00
|
|
|
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();
|
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 &&
|
2014-12-24 23:38:05 +00:00
|
|
|
((g_Config.m_ClFriendsIgnoreClan && m_lFriends[m_FriendlistSelectedIndex].m_pFriendInfo->m_aName[0]) || str_quickhash(pItem->m_aClients[j].m_aClan) == m_lFriends[m_FriendlistSelectedIndex].m_pFriendInfo->m_ClanHash) &&
|
2011-06-26 15:10:13 +00:00
|
|
|
(!m_lFriends[m_FriendlistSelectedIndex].m_pFriendInfo->m_aName[0] ||
|
2020-09-26 19:41:58 +00:00
|
|
|
str_quickhash(pItem->m_aClients[j].m_aName) == m_lFriends[m_FriendlistSelectedIndex].m_pFriendInfo->m_NameHash))
|
2011-06-26 15:10:13 +00:00
|
|
|
{
|
|
|
|
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"));
|
2020-09-19 20:03:21 +00:00
|
|
|
UI()->DoLabelScaled(&Button, aBuf, FontSize + 2, -1);
|
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;
|
2020-09-19 20:03:21 +00:00
|
|
|
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"));
|
2020-09-19 20:03:21 +00:00
|
|
|
UI()->DoLabelScaled(&Button, aBuf, FontSize + 2, -1);
|
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;
|
2020-09-19 20:03:21 +00:00
|
|
|
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);
|
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
|
|
|
|
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
|
2019-03-24 22:15:38 +00:00
|
|
|
RenderTools()->DrawUIRect(&MainView, ms_ColorTabbarActive, CUI::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
|
|
|
|
{
|
|
|
|
RenderTools()->DrawUIRect(&ToolBox, ColorRGBA(0.0f, 0.0f, 0.0f, 0.15f), CUI::CORNER_ALL, 4.0f);
|
|
|
|
|
|
|
|
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
|
|
|
|
|
|
|
static int s_FiltersTab = 0;
|
2020-10-26 01:10:55 +00:00
|
|
|
if(DoButton_MenuTab(&s_FiltersTab, Localize("Filter"), ToolboxPage == 0, &TabButton0, CUI::CORNER_BL, NULL, NULL, NULL, NULL, 4.0f))
|
2010-05-29 07:25:38 +00:00
|
|
|
ToolboxPage = 0;
|
|
|
|
|
|
|
|
static int s_InfoTab = 0;
|
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
|
|
|
|
2011-03-23 12:06:35 +00:00
|
|
|
static int s_FriendsTab = 0;
|
2020-10-26 01:10:55 +00:00
|
|
|
if(DoButton_MenuTab(&s_FriendsTab, Localize("Friends"), ToolboxPage == 2, &TabButton2, CUI::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);
|
|
|
|
}
|