Fix in game menu buttons overlapping on team based gametypes

The ddnet buttons kill and pause do not fit in anymore if there is also
a join red/blue button.

This commit fixes that by hiding the buttons if
there is not enough space anymore.

Related prior work https://github.com/ddnet/ddnet/pull/2720
This commit is contained in:
ChillerDragon 2024-05-11 11:03:17 +08:00
parent 64fec2cd37
commit 9a29c029a5

View file

@ -41,6 +41,7 @@ using namespace std::chrono_literals;
void CMenus::RenderGame(CUIRect MainView)
{
CUIRect Button, ButtonBar, ButtonBar2;
bool ShowDDRaceButtons = MainView.w > 855.0f;
MainView.HSplitTop(45.0f, &ButtonBar, &MainView);
ButtonBar.Draw(ms_ColorTabbarActive, IGraphics::CORNER_B, 10.0f);
@ -180,7 +181,7 @@ void CMenus::RenderGame(CUIRect MainView)
}
}
if(m_pClient->m_Snap.m_pLocalInfo->m_Team != TEAM_SPECTATORS)
if(m_pClient->m_Snap.m_pLocalInfo->m_Team != TEAM_SPECTATORS && ShowDDRaceButtons)
{
ButtonBar.VSplitLeft(5.0f, 0, &ButtonBar);
ButtonBar.VSplitLeft(65.0f, &Button, &ButtonBar);
@ -194,7 +195,7 @@ void CMenus::RenderGame(CUIRect MainView)
}
}
if(m_pClient->m_ReceivedDDNetPlayer && m_pClient->m_Snap.m_pLocalInfo && m_pClient->m_Snap.m_pGameInfoObj)
if(m_pClient->m_ReceivedDDNetPlayer && m_pClient->m_Snap.m_pLocalInfo && m_pClient->m_Snap.m_pGameInfoObj && ShowDDRaceButtons)
{
if(m_pClient->m_Snap.m_pLocalInfo->m_Team != TEAM_SPECTATORS || Paused || Spec)
{