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