move config

This commit is contained in:
nanashi-1 2022-09-26 21:11:38 +08:00
parent 4295d9c169
commit 5d18001d75
1 changed files with 16 additions and 0 deletions

View File

@ -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);
}
}