mirror of
https://github.com/ppy/osu.git
synced 2025-01-12 20:22:55 +08:00
Add loading spinner while tournament bracket is loading / retrieving data
This commit is contained in:
parent
267869bd0b
commit
725db56837
@ -13,6 +13,8 @@ namespace osu.Game.Tournament.Tests
|
||||
{
|
||||
base.LoadComplete();
|
||||
|
||||
BracketLoadTask.Wait();
|
||||
|
||||
LoadComponentAsync(new Background("Menu/menu-background-0")
|
||||
{
|
||||
Colour = OsuColour.Gray(0.5f),
|
||||
|
@ -154,6 +154,8 @@ namespace osu.Game.Tournament.Tests
|
||||
|
||||
protected override void LoadAsyncComplete()
|
||||
{
|
||||
BracketLoadTask.Wait();
|
||||
|
||||
// this has to be run here rather than LoadComplete because
|
||||
// TestScene.cs is checking the IsLoaded state (on another thread) and expects
|
||||
// the runner to be loaded at that point.
|
||||
|
@ -13,6 +13,7 @@ using osu.Framework.Graphics.Colour;
|
||||
using osu.Game.Graphics.Cursor;
|
||||
using osu.Game.Tournament.Models;
|
||||
using osu.Game.Graphics;
|
||||
using osu.Game.Graphics.UserInterface;
|
||||
using osuTK;
|
||||
using osuTK.Graphics;
|
||||
|
||||
@ -32,25 +33,24 @@ namespace osu.Game.Tournament
|
||||
private Drawable heightWarning;
|
||||
private Bindable<Size> windowSize;
|
||||
private Bindable<WindowMode> windowMode;
|
||||
private LoadingSpinner loadingSpinner;
|
||||
|
||||
[BackgroundDependencyLoader]
|
||||
private void load(FrameworkConfigManager frameworkConfig)
|
||||
{
|
||||
windowSize = frameworkConfig.GetBindable<Size>(FrameworkSetting.WindowedSize);
|
||||
windowSize.BindValueChanged(size => ScheduleAfterChildren(() =>
|
||||
{
|
||||
var minWidth = (int)(size.NewValue.Height / 768f * TournamentSceneManager.REQUIRED_WIDTH) - 1;
|
||||
|
||||
heightWarning.Alpha = size.NewValue.Width < minWidth ? 1 : 0;
|
||||
}), true);
|
||||
|
||||
windowMode = frameworkConfig.GetBindable<WindowMode>(FrameworkSetting.WindowMode);
|
||||
windowMode.BindValueChanged(mode => ScheduleAfterChildren(() =>
|
||||
{
|
||||
windowMode.Value = WindowMode.Windowed;
|
||||
}), true);
|
||||
|
||||
AddRange(new[]
|
||||
Add(loadingSpinner = new LoadingSpinner(true, true)
|
||||
{
|
||||
Anchor = Anchor.BottomRight,
|
||||
Origin = Anchor.BottomRight,
|
||||
Margin = new MarginPadding(40),
|
||||
});
|
||||
|
||||
loadingSpinner.Show();
|
||||
|
||||
BracketLoadTask.ContinueWith(_ => LoadComponentsAsync(new[]
|
||||
{
|
||||
new Container
|
||||
{
|
||||
@ -93,7 +93,24 @@ namespace osu.Game.Tournament
|
||||
RelativeSizeAxes = Axes.Both,
|
||||
Child = new TournamentSceneManager()
|
||||
}
|
||||
});
|
||||
}, drawables =>
|
||||
{
|
||||
loadingSpinner.Hide();
|
||||
loadingSpinner.Expire();
|
||||
|
||||
AddRange(drawables);
|
||||
|
||||
windowSize.BindValueChanged(size => ScheduleAfterChildren(() =>
|
||||
{
|
||||
var minWidth = (int)(size.NewValue.Height / 768f * TournamentSceneManager.REQUIRED_WIDTH) - 1;
|
||||
heightWarning.Alpha = size.NewValue.Width < minWidth ? 1 : 0;
|
||||
}), true);
|
||||
|
||||
windowMode.BindValueChanged(mode => ScheduleAfterChildren(() =>
|
||||
{
|
||||
windowMode.Value = WindowMode.Windowed;
|
||||
}), true);
|
||||
}));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -4,6 +4,8 @@
|
||||
using System;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using Newtonsoft.Json;
|
||||
using osu.Framework.Allocation;
|
||||
using osu.Framework.Graphics.Textures;
|
||||
@ -29,6 +31,8 @@ namespace osu.Game.Tournament
|
||||
private DependencyContainer dependencies;
|
||||
private FileBasedIPC ipc;
|
||||
|
||||
protected Task BracketLoadTask { get; private set; }
|
||||
|
||||
protected override IReadOnlyDependencyContainer CreateChildDependencies(IReadOnlyDependencyContainer parent)
|
||||
{
|
||||
return dependencies = new DependencyContainer(base.CreateChildDependencies(parent));
|
||||
@ -46,14 +50,9 @@ namespace osu.Game.Tournament
|
||||
|
||||
Textures.AddStore(new TextureLoaderStore(new StorageBackedResourceStore(storage)));
|
||||
|
||||
readBracket();
|
||||
|
||||
ladder.CurrentMatch.Value = ladder.Matches.FirstOrDefault(p => p.Current.Value);
|
||||
BracketLoadTask = Task.Run(readBracket);
|
||||
|
||||
dependencies.CacheAs(new StableInfo(storage));
|
||||
|
||||
dependencies.CacheAs<MatchIPCInfo>(ipc = new FileBasedIPC());
|
||||
Add(ipc);
|
||||
}
|
||||
|
||||
private void readBracket()
|
||||
@ -70,8 +69,6 @@ namespace osu.Game.Tournament
|
||||
|
||||
Ruleset.BindTo(ladder.Ruleset);
|
||||
|
||||
dependencies.Cache(ladder);
|
||||
|
||||
bool addedInfo = false;
|
||||
|
||||
// assign teams
|
||||
@ -127,6 +124,15 @@ namespace osu.Game.Tournament
|
||||
|
||||
if (addedInfo)
|
||||
SaveChanges();
|
||||
|
||||
ladder.CurrentMatch.Value = ladder.Matches.FirstOrDefault(p => p.Current.Value);
|
||||
|
||||
Schedule(() =>
|
||||
{
|
||||
dependencies.Cache(ladder);
|
||||
dependencies.CacheAs<MatchIPCInfo>(ipc = new FileBasedIPC());
|
||||
Add(ipc);
|
||||
});
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
Loading…
Reference in New Issue
Block a user