mirror of
https://github.com/ddnet/ddnet.git
synced 2024-11-19 14:38:18 +00:00
Render bar below server browser to show loading progression
Render a slim bar below the server browser listbox to show the loading progression, instead of showing a percentage on the Refresh button, as suggested in https://github.com/ddnet/ddnet/pull/5878#issuecomment-1257227947. The margin around the bottom status elements is removed to make more space and improve the alignment of the elements with the rest of the server browser.
This commit is contained in:
parent
5831e761b8
commit
1eb600f7e0
|
@ -57,7 +57,7 @@ void CMenus::RenderServerbrowserServerList(CUIRect View)
|
||||||
CUIRect Status;
|
CUIRect Status;
|
||||||
|
|
||||||
View.HSplitTop(ms_ListheaderHeight, &Headers, &View);
|
View.HSplitTop(ms_ListheaderHeight, &Headers, &View);
|
||||||
View.HSplitBottom(70.0f, &View, &Status);
|
View.HSplitBottom(65.0f, &View, &Status);
|
||||||
|
|
||||||
// split of the scrollbar
|
// split of the scrollbar
|
||||||
Headers.Draw(ColorRGBA(1, 1, 1, 0.25f), IGraphics::CORNER_T, 5.0f);
|
Headers.Draw(ColorRGBA(1, 1, 1, 0.25f), IGraphics::CORNER_T, 5.0f);
|
||||||
|
@ -510,8 +510,23 @@ void CMenus::RenderServerbrowserServerList(CUIRect View)
|
||||||
Connect(g_Config.m_UiServerAddress);
|
Connect(g_Config.m_UiServerAddress);
|
||||||
}
|
}
|
||||||
|
|
||||||
//Status.Draw(ms_ColorTabbarActive, IGraphics::CORNER_B, 5.0f);
|
// Render bar that shows the loading progression.
|
||||||
Status.Margin(5.0f, &Status);
|
// The bar is only shown while loading and fades out when it's done.
|
||||||
|
CUIRect RefreshBar;
|
||||||
|
Status.HSplitTop(5.0f, &RefreshBar, &Status);
|
||||||
|
static float s_LoadingProgressionFadeEnd = 0.0f;
|
||||||
|
if(ServerBrowser()->IsRefreshing() && ServerBrowser()->LoadingProgression() < 100)
|
||||||
|
{
|
||||||
|
s_LoadingProgressionFadeEnd = Client()->GlobalTime() + 2.0f;
|
||||||
|
}
|
||||||
|
const float LoadingProgressionTimeDiff = s_LoadingProgressionFadeEnd - Client()->GlobalTime();
|
||||||
|
if(LoadingProgressionTimeDiff > 0.0f)
|
||||||
|
{
|
||||||
|
const float RefreshBarAlpha = minimum(LoadingProgressionTimeDiff, 0.8f);
|
||||||
|
RefreshBar.h = 2.0f;
|
||||||
|
RefreshBar.w *= ServerBrowser()->LoadingProgression() / 100.0f;
|
||||||
|
RefreshBar.Draw(ColorRGBA(1.0f, 1.0f, 1.0f, RefreshBarAlpha), IGraphics::CORNER_NONE, 0.0f);
|
||||||
|
}
|
||||||
|
|
||||||
CUIRect SearchInfoAndAddr, ServersAndConnect, Status3;
|
CUIRect SearchInfoAndAddr, ServersAndConnect, Status3;
|
||||||
Status.VSplitRight(250.0f, &SearchInfoAndAddr, &ServersAndConnect);
|
Status.VSplitRight(250.0f, &SearchInfoAndAddr, &ServersAndConnect);
|
||||||
|
@ -637,9 +652,7 @@ void CMenus::RenderServerbrowserServerList(CUIRect View)
|
||||||
|
|
||||||
static int s_RefreshButton = 0;
|
static int s_RefreshButton = 0;
|
||||||
auto Func = [this]() mutable -> const char * {
|
auto Func = [this]() mutable -> const char * {
|
||||||
if(ServerBrowser()->IsRefreshing())
|
if(ServerBrowser()->IsRefreshing() || ServerBrowser()->IsGettingServerlist())
|
||||||
str_format(m_aLocalStringHelper, sizeof(m_aLocalStringHelper), "%s (%d%%)", Localize("Refresh"), ServerBrowser()->LoadingProgression());
|
|
||||||
else if(ServerBrowser()->IsGettingServerlist())
|
|
||||||
str_copy(m_aLocalStringHelper, Localize("Refreshing..."));
|
str_copy(m_aLocalStringHelper, Localize("Refreshing..."));
|
||||||
else
|
else
|
||||||
str_copy(m_aLocalStringHelper, Localize("Refresh"));
|
str_copy(m_aLocalStringHelper, Localize("Refresh"));
|
||||||
|
|
Loading…
Reference in a new issue