mirror of https://github.com/ppy/osu
move config
This commit is contained in:
parent
4295d9c169
commit
5d18001d75
|
@ -5,6 +5,8 @@
|
|||
using System.Linq;
|
||||
using osu.Framework.Allocation;
|
||||
using osu.Framework.Bindables;
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Game.Configuration;
|
||||
using osu.Game.Rulesets.Scoring;
|
||||
using osu.Game.Scoring;
|
||||
using osu.Game.Users;
|
||||
|
@ -13,6 +15,9 @@ namespace osu.Game.Screens.Play.HUD
|
|||
{
|
||||
public class SoloGameplayLeaderboard : GameplayLeaderboard
|
||||
{
|
||||
private const int duration = 100;
|
||||
|
||||
private readonly Bindable<bool> configVisibility = new Bindable<bool>();
|
||||
private readonly IUser trackingUser;
|
||||
|
||||
public readonly IBindableList<ScoreInfo> Scores = new BindableList<ScoreInfo>();
|
||||
|
@ -31,10 +36,18 @@ public SoloGameplayLeaderboard(IUser trackingUser)
|
|||
this.trackingUser = trackingUser;
|
||||
}
|
||||
|
||||
[BackgroundDependencyLoader]
|
||||
private void load(OsuConfigManager config)
|
||||
{
|
||||
config.BindWith(OsuSetting.GameplayLeaderboard, configVisibility);
|
||||
}
|
||||
|
||||
protected override void LoadComplete()
|
||||
{
|
||||
base.LoadComplete();
|
||||
Scores.BindCollectionChanged((_, _) => Scheduler.AddOnce(showScores), true);
|
||||
|
||||
configVisibility.BindValueChanged(_ => updateVisibility(), true);
|
||||
}
|
||||
|
||||
private void showScores()
|
||||
|
@ -69,5 +82,8 @@ private void showScores()
|
|||
// Local score should always show lower than any existing scores in cases of ties.
|
||||
local.DisplayOrder.Value = long.MaxValue;
|
||||
}
|
||||
|
||||
private void updateVisibility() =>
|
||||
Flow.FadeTo(configVisibility.Value ? 1 : 0, duration);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue