mirror of
https://github.com/ppy/osu.git
synced 2024-11-11 14:17:26 +08:00
Tidy up load process
This commit is contained in:
parent
d60478851f
commit
713f69ea55
@ -22,6 +22,8 @@ namespace osu.Game.Overlays
|
||||
private readonly Container sidebarContainer;
|
||||
private readonly NewsSidebar sidebar;
|
||||
|
||||
private CancellationTokenSource cancellationToken;
|
||||
|
||||
public NewsOverlay()
|
||||
: base(OverlayColourScheme.Purple, false)
|
||||
{
|
||||
@ -97,7 +99,7 @@ namespace osu.Game.Overlays
|
||||
|
||||
public void ShowYear(int year)
|
||||
{
|
||||
showYear(year);
|
||||
loadFrontPage(year);
|
||||
Show();
|
||||
}
|
||||
|
||||
@ -107,32 +109,18 @@ namespace osu.Game.Overlays
|
||||
Show();
|
||||
}
|
||||
|
||||
private CancellationTokenSource cancellationToken;
|
||||
|
||||
private void showYear(int year)
|
||||
{
|
||||
cancellationToken?.Cancel();
|
||||
Loading.Show();
|
||||
|
||||
loadFrontPage(year);
|
||||
}
|
||||
|
||||
private void onArticleChanged(ValueChangedEvent<string> e)
|
||||
{
|
||||
cancellationToken?.Cancel();
|
||||
Loading.Show();
|
||||
|
||||
if (e.NewValue == null)
|
||||
{
|
||||
loadFrontPage();
|
||||
return;
|
||||
}
|
||||
|
||||
loadArticle(e.NewValue);
|
||||
else
|
||||
loadArticle(e.NewValue);
|
||||
}
|
||||
|
||||
private void loadFrontPage(int year = 0)
|
||||
{
|
||||
beginLoading();
|
||||
|
||||
Header.SetFrontPage();
|
||||
|
||||
var page = new FrontPageDisplay(year);
|
||||
@ -146,6 +134,8 @@ namespace osu.Game.Overlays
|
||||
|
||||
private void loadArticle(string article)
|
||||
{
|
||||
beginLoading();
|
||||
|
||||
Header.SetArticle(article);
|
||||
|
||||
// Temporary, should be handled by ArticleDisplay later
|
||||
@ -153,6 +143,12 @@ namespace osu.Game.Overlays
|
||||
Loading.Hide();
|
||||
}
|
||||
|
||||
private void beginLoading()
|
||||
{
|
||||
cancellationToken?.Cancel();
|
||||
Loading.Show();
|
||||
}
|
||||
|
||||
protected void LoadDisplay(Drawable display)
|
||||
{
|
||||
ScrollFlow.ScrollToStart();
|
||||
|
Loading…
Reference in New Issue
Block a user