2022-12-12 05:08:48 +08:00
|
|
|
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
|
|
|
|
// See the LICENCE file in the repository root for full licence text.
|
|
|
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
using System.Linq;
|
|
|
|
using osu.Framework.Allocation;
|
|
|
|
using osu.Framework.Bindables;
|
|
|
|
using osu.Framework.Graphics.Containers;
|
2022-12-12 18:53:07 +08:00
|
|
|
using osu.Game.Rulesets;
|
2022-12-12 05:08:48 +08:00
|
|
|
using osu.Game.Rulesets.Scoring;
|
|
|
|
|
|
|
|
namespace osu.Game.Screens.Play.HUD.JudgementCounter
|
|
|
|
{
|
|
|
|
public partial class JudgementTally : CompositeDrawable
|
|
|
|
{
|
|
|
|
[Resolved]
|
|
|
|
private ScoreProcessor scoreProcessor { get; set; } = null!;
|
|
|
|
|
|
|
|
public List<JudgementCounterInfo> Results = new List<JudgementCounterInfo>();
|
|
|
|
|
|
|
|
[BackgroundDependencyLoader]
|
2022-12-12 22:10:10 +08:00
|
|
|
private void load(IBindable<RulesetInfo> ruleset)
|
2022-12-12 05:08:48 +08:00
|
|
|
{
|
2022-12-12 22:10:10 +08:00
|
|
|
foreach (var result in ruleset.Value.CreateInstance().GetHitResults())
|
2022-12-12 05:08:48 +08:00
|
|
|
{
|
|
|
|
Results.Add(new JudgementCounterInfo
|
|
|
|
{
|
2022-12-12 22:10:10 +08:00
|
|
|
Type = result.result,
|
2022-12-12 06:47:17 +08:00
|
|
|
ResultCount = new BindableInt()
|
2022-12-12 05:08:48 +08:00
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
protected override void LoadComplete()
|
|
|
|
{
|
|
|
|
base.LoadComplete();
|
2022-12-15 06:00:34 +08:00
|
|
|
|
2022-12-12 05:08:48 +08:00
|
|
|
scoreProcessor.NewJudgement += judgement =>
|
|
|
|
{
|
2022-12-12 22:10:10 +08:00
|
|
|
foreach (JudgementCounterInfo result in Results.Where(result => result.Type == judgement.Type))
|
2022-12-12 05:08:48 +08:00
|
|
|
result.ResultCount.Value++;
|
|
|
|
};
|
2022-12-15 06:00:34 +08:00
|
|
|
|
2022-12-12 05:08:48 +08:00
|
|
|
scoreProcessor.JudgementReverted += judgement =>
|
|
|
|
{
|
2022-12-12 22:10:10 +08:00
|
|
|
foreach (JudgementCounterInfo result in Results.Where(result => result.Type == judgement.Type))
|
2022-12-12 05:08:48 +08:00
|
|
|
result.ResultCount.Value--;
|
|
|
|
};
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|