mirror of
https://github.com/ddnet/ddnet.git
synced 2024-11-10 10:08:18 +00:00
Merge #6175
6175: Render bar below server browser to show loading progression r=def- a=Robyt3 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. https://user-images.githubusercontent.com/23437060/209000517-76fea4a1-e2d2-41de-b5af-1d907589e30e.mp4 (I used `br_max_requests 1` for this video and used a bind to activate `leak_ip_address_to_all_servers`) Screenshot comparison for margins: - Before: ![screenshot_2022-12-21_21-53-04](https://user-images.githubusercontent.com/23437060/209000858-8f2aa45c-40d5-443c-bba4-c4881bf926d6.png) - After: ![screenshot_2022-12-21_21-49-06](https://user-images.githubusercontent.com/23437060/209000348-f6c30036-4acc-4777-aa72-2f896f4df9f6.png) ## Checklist - [X] Tested the change ingame - [X] Provided screenshots if it is a visual change - [ ] Tested in combination with possibly related configuration options - [ ] Written a unit test (especially base/) or added coverage to integration test - [ ] Considered possible null pointers and out of bounds array indexing - [ ] Changed no physics that affect existing maps - [ ] Tested the change with [ASan+UBSan or valgrind's memcheck](https://github.com/ddnet/ddnet/#using-addresssanitizer--undefinedbehavioursanitizer-or-valgrinds-memcheck) (optional) Co-authored-by: Robert Müller <robytemueller@gmail.com>
This commit is contained in:
commit
db08cc01cd
|
@ -57,7 +57,7 @@ void CMenus::RenderServerbrowserServerList(CUIRect View)
|
|||
CUIRect Status;
|
||||
|
||||
View.HSplitTop(ms_ListheaderHeight, &Headers, &View);
|
||||
View.HSplitBottom(70.0f, &View, &Status);
|
||||
View.HSplitBottom(65.0f, &View, &Status);
|
||||
|
||||
// split of the scrollbar
|
||||
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);
|
||||
}
|
||||
|
||||
//Status.Draw(ms_ColorTabbarActive, IGraphics::CORNER_B, 5.0f);
|
||||
Status.Margin(5.0f, &Status);
|
||||
// Render bar that shows the loading progression.
|
||||
// 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;
|
||||
Status.VSplitRight(250.0f, &SearchInfoAndAddr, &ServersAndConnect);
|
||||
|
@ -637,9 +652,7 @@ void CMenus::RenderServerbrowserServerList(CUIRect View)
|
|||
|
||||
static int s_RefreshButton = 0;
|
||||
auto Func = [this]() mutable -> const char * {
|
||||
if(ServerBrowser()->IsRefreshing())
|
||||
str_format(m_aLocalStringHelper, sizeof(m_aLocalStringHelper), "%s (%d%%)", Localize("Refresh"), ServerBrowser()->LoadingProgression());
|
||||
else if(ServerBrowser()->IsGettingServerlist())
|
||||
if(ServerBrowser()->IsRefreshing() || ServerBrowser()->IsGettingServerlist())
|
||||
str_copy(m_aLocalStringHelper, Localize("Refreshing..."));
|
||||
else
|
||||
str_copy(m_aLocalStringHelper, Localize("Refresh"));
|
||||
|
|
Loading…
Reference in a new issue