Merge pull request #1687 from Dune-jr/feature-refoldonclick

Hide server details when the server is clicked on again
This commit is contained in:
oy 2018-11-19 15:25:31 +01:00 committed by GitHub
commit b9ea02d13f
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 18 additions and 5 deletions

View file

@ -45,6 +45,7 @@ CMenus::CMenus()
m_GamePage = PAGE_GAME;
m_SidebarTab = 0;
m_SidebarActive = true;
m_ShowServerDetails = true;
m_NeedRestartGraphics = false;
m_NeedRestartSound = false;

View file

@ -182,6 +182,7 @@ private:
bool m_MenuActive;
int m_SidebarTab;
bool m_SidebarActive;
bool m_ShowServerDetails;
bool m_UseMouseButtons;
vec2 m_MousePos;
vec2 m_PrevMousePos;

View file

@ -356,6 +356,7 @@ void CMenus::SetOverlay(int Type, float x, float y, const void *pData)
}
}
// 1 = browser entry click, 2 = server info click
int CMenus::DoBrowserEntry(const void *pID, CUIRect View, const CServerInfo *pEntry, const CBrowserFilter *pFilter, bool Selected)
{
// logic
@ -579,7 +580,7 @@ int CMenus::DoBrowserEntry(const void *pID, CUIRect View, const CServerInfo *pEn
}
// show server info
if(!m_SidebarActive && Selected)
if(!m_SidebarActive && m_ShowServerDetails && Selected)
{
CUIRect Info;
View.HSplitTop(ms_aBrowserCols[0].m_Rect.h, 0, &View);
@ -587,6 +588,9 @@ int CMenus::DoBrowserEntry(const void *pID, CUIRect View, const CServerInfo *pEn
RenderDetailInfo(Info, pEntry);
RenderDetailScoreboard(View, pEntry, 4);
if(ReturnValue && UI()->MouseInside(&View))
ReturnValue++;
}
TextRender()->TextOutlineColor(0.0f, 0.0f, 0.0f, 0.3f);
@ -1033,7 +1037,7 @@ void CMenus::RenderServerbrowserServerList(CUIRect View)
float ListHeight = NumServers * ms_ListheaderHeight; // add server list height
ListHeight += NumFilters * SpacingH; // add filters
ListHeight += (NumFilters) * ButtonHeight;// add filters spacing
if(!m_SidebarActive && m_SelectedServer.m_Index != -1 && SelectedFilter != -1)
if(!m_SidebarActive && m_SelectedServer.m_Index != -1 && SelectedFilter != -1 && m_ShowServerDetails)
ListHeight += ms_ListheaderHeight*5;
// float LineH = ms_aBrowserCols[0].m_Rect.h;
@ -1117,7 +1121,11 @@ void CMenus::RenderServerbrowserServerList(CUIRect View)
}
m_SelectedServer.m_Filter = NewFilter;
m_SelectedServer.m_Index = NewIndex;
if(m_SelectedServer.m_Index != NewIndex)
{
m_SelectedServer.m_Index = NewIndex;
m_ShowServerDetails = true;
}
const CServerInfo *pItem = ServerBrowser()->SortedGet(NewFilter, NewIndex);
str_copy(g_Config.m_UiServerAddress, pItem->m_aAddress, sizeof(g_Config.m_UiServerAddress));
@ -1157,11 +1165,13 @@ void CMenus::RenderServerbrowserServerList(CUIRect View)
// select server
if(!str_comp(pItem->m_aAddress, g_Config.m_UiServerAddress))
{
if(m_SelectedServer.m_Index != i) // new server selected
m_ShowServerDetails = true;
m_SelectedServer.m_Filter = s;
m_SelectedServer.m_Index = i;
}
if(!m_SidebarActive && m_SelectedServer.m_Filter == s && m_SelectedServer.m_Index == i)
if(!m_SidebarActive && m_SelectedServer.m_Filter == s && m_SelectedServer.m_Index == i && m_ShowServerDetails)
View.HSplitTop(ms_ListheaderHeight*6, &Row, &View);
else
View.HSplitTop(ms_ListheaderHeight, &Row, &View);
@ -1185,8 +1195,9 @@ void CMenus::RenderServerbrowserServerList(CUIRect View)
continue;
}
if(DoBrowserEntry(pFilter->ID(i), Row, pItem, pFilter, m_SelectedServer.m_Filter == s && m_SelectedServer.m_Index == i))
if(int ReturnValue = DoBrowserEntry(pFilter->ID(i), Row, pItem, pFilter, m_SelectedServer.m_Filter == s && m_SelectedServer.m_Index == i))
{
m_ShowServerDetails = !m_ShowServerDetails || ReturnValue == 2 || m_SelectedServer.m_Index != i; // click twice on line => fold server details
m_SelectedServer.m_Filter = s;
m_SelectedServer.m_Index = i;
if(g_Config.m_UiAutoswitchInfotab)