Remove IOnlineComponent and change existing components to use bindable flow

This commit is contained in:
Dean Herbert
2020-10-22 14:19:12 +09:00
parent e664d04be2
commit 9753dab93b
17 changed files with 140 additions and 219 deletions

View File

@ -6,6 +6,7 @@ using System.Collections.Generic;
using System.Linq;
using System.Threading;
using osu.Framework.Allocation;
using osu.Framework.Bindables;
using osu.Framework.Extensions.Color4Extensions;
using osu.Framework.Graphics;
using osu.Framework.Graphics.Colour;
@ -22,7 +23,7 @@ using osuTK.Graphics;
namespace osu.Game.Online.Leaderboards
{
public abstract class Leaderboard<TScope, TScoreInfo> : Container, IOnlineComponent
public abstract class Leaderboard<TScope, TScoreInfo> : Container
{
private const double fade_duration = 300;
@ -242,16 +243,13 @@ namespace osu.Game.Online.Leaderboards
private ScheduledDelegate pendingUpdateScores;
private readonly IBindable<APIState> apiState = new Bindable<APIState>();
[BackgroundDependencyLoader]
private void load()
{
api?.Register(this);
}
protected override void Dispose(bool isDisposing)
{
base.Dispose(isDisposing);
api?.Unregister(this);
apiState.BindTo(api.State);
apiState.BindValueChanged(onlineStateChanged, true);
}
public void RefreshScores() => UpdateScores();
@ -260,9 +258,9 @@ namespace osu.Game.Online.Leaderboards
protected abstract bool IsOnlineScope { get; }
public void APIStateChanged(IAPIProvider api, APIState state)
private void onlineStateChanged(ValueChangedEvent<APIState> state) => Schedule(() =>
{
switch (state)
switch (state.NewValue)
{
case APIState.Online:
case APIState.Offline:
@ -271,7 +269,7 @@ namespace osu.Game.Online.Leaderboards
break;
}
}
});
protected void UpdateScores()
{