Add symbol for official servers in server browser (fixes #1501)

- Also fix favorites checkbox when removing favorite
- Might need a nicer looking symbol
This commit is contained in:
def 2019-03-19 07:46:48 +01:00
parent 1fec65572b
commit 4f515bf67e
5 changed files with 34 additions and 6 deletions

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.3 KiB

After

Width:  |  Height:  |  Size: 8.4 KiB

View file

@ -263,7 +263,7 @@ container.pickups.Add(Pickup("ninja", 90, 90))
set_particles = SpriteSet("particles", image_particles, 8, 8)
set_game = SpriteSet("game", image_game, 32, 16)
set_tee = SpriteSet("tee", image_null, 8, 4)
set_browseicons = SpriteSet("browseicons", image_browseicons, 6, 1)
set_browseicons = SpriteSet("browseicons", image_browseicons, 7, 1)
set_emoticons = SpriteSet("emoticons", image_emoticons, 4, 4)
set_speedup_arrow = SpriteSet("speedup_arrow", image_speedup_arrow, 1, 1)
set_demobuttons = SpriteSet("demobuttons", image_demobuttons, 5, 1)
@ -397,6 +397,7 @@ container.sprites.Add(Sprite("browse_heart", set_browseicons, 1,0,1,1))
container.sprites.Add(Sprite("browse_unpure", set_browseicons, 3,0,1,1))
container.sprites.Add(Sprite("browse_norank", set_browseicons, 4,0,1,1))
container.sprites.Add(Sprite("browse_rank", set_browseicons, 5,0,1,1))
container.sprites.Add(Sprite("browse_ddnet", set_browseicons, 6,0,1,1))
container.sprites.Add(Sprite("speedup_arrow", set_speedup_arrow, 0,0,1,1))

View file

@ -436,9 +436,11 @@ void CServerBrowser::QueueRequest(CServerEntry *pEntry)
void CServerBrowser::SetInfo(CServerEntry *pEntry, const CServerInfo &Info)
{
int Fav = pEntry->m_Info.m_Favorite;
bool Fav = pEntry->m_Info.m_Favorite;
bool Off = pEntry->m_Info.m_Official;
pEntry->m_Info = Info;
pEntry->m_Info.m_Favorite = Fav;
pEntry->m_Info.m_Official = Off;
pEntry->m_Info.m_NetAddr = pEntry->m_Addr;
// all these are just for nice compatibility
@ -481,7 +483,24 @@ CServerBrowser::CServerEntry *CServerBrowser::Add(const NETADDR &Addr)
for(i = 0; i < m_NumFavoriteServers; i++)
{
if(net_addr_comp(&Addr, &m_aFavoriteServers[i]) == 0)
pEntry->m_Info.m_Favorite = 1;
{
pEntry->m_Info.m_Favorite = true;
break;
}
}
// check if it's an official server
for(int i = 0; i < m_NumDDNetCountries; i++)
{
CDDNetCountry *pCntr = &m_aDDNetCountries[i];
for(int j = 0; j < pCntr->m_NumServers; j++)
{
if(net_addr_comp(&Addr, &pCntr->m_aServers[j]) == 0)
{
pEntry->m_Info.m_Official = true;
break;
}
}
}
// add to the hash list
@ -952,7 +971,7 @@ void CServerBrowser::AddFavorite(const NETADDR &Addr)
m_aFavoriteServers[m_NumFavoriteServers++] = Addr;
pEntry = Find(Addr);
if(pEntry)
pEntry->m_Info.m_Favorite = 1;
pEntry->m_Info.m_Favorite = true;
if(g_Config.m_Debug)
{
@ -978,7 +997,7 @@ void CServerBrowser::RemoveFavorite(const NETADDR &Addr)
pEntry = Find(Addr);
if(pEntry)
pEntry->m_Info.m_Favorite = 0;
pEntry->m_Info.m_Favorite = false;
return;
}

View file

@ -48,7 +48,8 @@ public:
int m_MaxPlayers;
int m_NumPlayers;
int m_Flags;
int m_Favorite;
bool m_Favorite;
bool m_Official;
int m_Latency; // in ms
int m_HasRank;
char m_aGameType[16];

View file

@ -53,6 +53,7 @@ void CMenus::RenderServerbrowserServerList(CUIRect View)
COL_FLAG_LOCK=0,
COL_FLAG_FAV,
COL_FLAG_OFFICIAL,
COL_NAME,
COL_GAMETYPE,
COL_MAP,
@ -65,6 +66,7 @@ void CMenus::RenderServerbrowserServerList(CUIRect View)
{-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}},
@ -336,6 +338,11 @@ void CMenus::RenderServerbrowserServerList(CUIRect View)
if(pItem->m_Favorite)
DoButton_Icon(IMAGE_BROWSEICONS, SPRITE_BROWSE_HEART, &Button);
}
else if(ID == COL_FLAG_OFFICIAL)
{
if(pItem->m_Official)
DoButton_Icon(IMAGE_BROWSEICONS, SPRITE_BROWSE_DDNET, &Button);
}
else if(ID == COL_NAME)
{
CTextCursor Cursor;