Change alignment and size of the browser columns

This commit is contained in:
Jordy Ruiz 2018-12-17 13:22:11 +01:00
parent 60f13f4555
commit e0cd64b595

View file

@ -25,10 +25,10 @@
CMenus::CColumn CMenus::ms_aBrowserCols[] = {
{COL_BROWSER_FLAG, -1, " ", -1, 87.0f, 0, {0}, {0}}, // Localize - these strings are localized within CLocConstString
{COL_BROWSER_NAME, IServerBrowser::SORT_NAME, "Server", 0, 300.0f, 0, {0}, {0}},
{COL_BROWSER_NAME, IServerBrowser::SORT_NAME, "Server", 0, 320.0f, 0, {0}, {0}},
{COL_BROWSER_GAMETYPE, IServerBrowser::SORT_GAMETYPE, "Type", 1, 70.0f, 0, {0}, {0}},
{COL_BROWSER_MAP, IServerBrowser::SORT_MAP, "Map", 1, 100.0f, 0, {0}, {0}},
{COL_BROWSER_PLAYERS, IServerBrowser::SORT_NUMPLAYERS, "Players", 1, 60.0f, 0, {0}, {0}},
{COL_BROWSER_PLAYERS, IServerBrowser::SORT_NUMPLAYERS, "Players", 1, 40.0f, 0, {0}, {0}},
{COL_BROWSER_PING, IServerBrowser::SORT_PING, "Ping", 1, 40.0f, 0, {0}, {0}},
};
@ -443,7 +443,7 @@ int CMenus::DoBrowserEntry(const void *pID, CUIRect View, const CServerInfo *pEn
CTextCursor Cursor;
float tw = TextRender()->TextWidth(0, 12.0f, pEntry->m_aName, -1);
if(tw < Button.w)
TextRender()->SetCursor(&Cursor, Button.x+Button.w/2.0f-tw/2.0f, Button.y, 12.0f, TEXTFLAG_RENDER);
TextRender()->SetCursor(&Cursor, Button.x, Button.y, 12.0f, TEXTFLAG_RENDER);
else
{
TextRender()->SetCursor(&Cursor, Button.x, Button.y, 12.0f, TEXTFLAG_RENDER|TEXTFLAG_STOP_AT_END);
@ -475,7 +475,7 @@ int CMenus::DoBrowserEntry(const void *pID, CUIRect View, const CServerInfo *pEn
CTextCursor Cursor;
float tw = TextRender()->TextWidth(0, 12.0f, pEntry->m_aMap, -1);
if(tw < Button.w)
TextRender()->SetCursor(&Cursor, Button.x+Button.w/2.0f-tw/2.0f, Button.y, 12.0f, TEXTFLAG_RENDER);
TextRender()->SetCursor(&Cursor, Button.x, Button.y, 12.0f, TEXTFLAG_RENDER);
else
{
TextRender()->SetCursor(&Cursor, Button.x, Button.y, 12.0f, TEXTFLAG_RENDER|TEXTFLAG_STOP_AT_END);
@ -531,7 +531,7 @@ int CMenus::DoBrowserEntry(const void *pID, CUIRect View, const CServerInfo *pEn
if(g_Config.m_BrFilterString[0] && (pEntry->m_QuickSearchHit&IServerBrowser::QUICK_PLAYER))
TextRender()->TextColor(0.4f, 0.4f, 1.0f, TextAlpha);
Button.y += 2.0f;
UI()->DoLabel(&Button, aTemp, 12.0f, CUI::ALIGN_CENTER);
UI()->DoLabel(&Button, aTemp, 12.0f, CUI::ALIGN_LEFT);
}
else if(ID == COL_BROWSER_PING)
{
@ -567,7 +567,7 @@ int CMenus::DoBrowserEntry(const void *pID, CUIRect View, const CServerInfo *pEn
str_format(aTemp, sizeof(aTemp), "%d", pEntry->m_Latency);
TextRender()->TextColor(Color.r, Color.g, Color.b, Color.a);
Button.y += 2.0f;
UI()->DoLabel(&Button, aTemp, 12.0f, CUI::ALIGN_CENTER);
UI()->DoLabel(&Button, aTemp, 12.0f, CUI::ALIGN_RIGHT);
}
else if(ID == COL_BROWSER_GAMETYPE)
{
@ -916,11 +916,16 @@ void CMenus::RenderServerbrowserServerList(CUIRect View)
// background
RenderTools()->DrawUIRect(&View, vec4(0.0f, 0.0f, 0.0f, 0.25f), CUI::CORNER_ALL, 5.0f);
// split scrollbar from view
CUIRect Scroll;
View.VSplitRight(20.0f, &View, &Scroll);
View.HSplitTop(ms_ListheaderHeight, &Headers, &View);
View.HSplitBottom(ButtonHeight*3.0f+SpacingH*2.0f, &View, &Status);
Headers.VSplitRight(ms_ListheaderHeight, &Headers, &InfoButton); // split for info button
// do layout
for(int i = 0; i < NUM_BROWSER_COLS; i++)
{
@ -970,9 +975,6 @@ void CMenus::RenderServerbrowserServerList(CUIRect View)
}
}
// split scrollbar from view
CUIRect Scroll;
View.VSplitRight(20.0f, &View, &Scroll);
// scrollbar background
RenderTools()->DrawUIRect(&Scroll, vec4(0.0f, 0.0f, 0.0f, 0.25f), CUI::CORNER_ALL, 5.0f);