mirror of
https://github.com/ppy/osu.git
synced 2025-01-14 02:03:22 +08:00
Add judgementTally to HUD overlay
This commit is contained in:
parent
54c0b2c20c
commit
ffbe68bd26
56
osu.Game/Screens/Play/HUD/JudgementCounter/JudgementTally.cs
Normal file
56
osu.Game/Screens/Play/HUD/JudgementCounter/JudgementTally.cs
Normal file
@ -0,0 +1,56 @@
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
// 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;
|
||||||
|
using osu.Game.Rulesets.Scoring;
|
||||||
|
using osu.Game.Rulesets.UI;
|
||||||
|
|
||||||
|
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]
|
||||||
|
private void load(DrawableRuleset ruleset)
|
||||||
|
{
|
||||||
|
foreach (var result in ruleset.Ruleset.GetHitResults())
|
||||||
|
{
|
||||||
|
Results.Add(new JudgementCounterInfo
|
||||||
|
{
|
||||||
|
ResultInfo = (result.result, result.displayName),
|
||||||
|
ResultCount = new BindableInt(),
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
protected override void LoadComplete()
|
||||||
|
{
|
||||||
|
base.LoadComplete();
|
||||||
|
scoreProcessor.NewJudgement += judgement =>
|
||||||
|
{
|
||||||
|
foreach (JudgementCounterInfo result in Results.Where(result => result.ResultInfo.Type == judgement.Type))
|
||||||
|
{
|
||||||
|
result.ResultCount.Value++;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
scoreProcessor.JudgementReverted += judgement =>
|
||||||
|
{
|
||||||
|
foreach (JudgementCounterInfo result in Results.Where(result => result.ResultInfo.Type == judgement.Type))
|
||||||
|
{
|
||||||
|
result.ResultCount.Value--;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -24,6 +24,7 @@ using osu.Game.Screens.Play.HUD;
|
|||||||
using osu.Game.Screens.Play.HUD.ClicksPerSecond;
|
using osu.Game.Screens.Play.HUD.ClicksPerSecond;
|
||||||
using osu.Game.Skinning;
|
using osu.Game.Skinning;
|
||||||
using osuTK;
|
using osuTK;
|
||||||
|
using JudgementTally = osu.Game.Screens.Play.HUD.JudgementCounter.JudgementTally;
|
||||||
|
|
||||||
namespace osu.Game.Screens.Play
|
namespace osu.Game.Screens.Play
|
||||||
{
|
{
|
||||||
@ -58,6 +59,9 @@ namespace osu.Game.Screens.Play
|
|||||||
[Cached]
|
[Cached]
|
||||||
private readonly ClicksPerSecondCalculator clicksPerSecondCalculator;
|
private readonly ClicksPerSecondCalculator clicksPerSecondCalculator;
|
||||||
|
|
||||||
|
[Cached]
|
||||||
|
private readonly JudgementTally tally;
|
||||||
|
|
||||||
public Bindable<bool> ShowHealthBar = new Bindable<bool>(true);
|
public Bindable<bool> ShowHealthBar = new Bindable<bool>(true);
|
||||||
|
|
||||||
private readonly DrawableRuleset drawableRuleset;
|
private readonly DrawableRuleset drawableRuleset;
|
||||||
@ -146,6 +150,7 @@ namespace osu.Game.Screens.Play
|
|||||||
Spacing = new Vector2(5)
|
Spacing = new Vector2(5)
|
||||||
},
|
},
|
||||||
clicksPerSecondCalculator = new ClicksPerSecondCalculator(),
|
clicksPerSecondCalculator = new ClicksPerSecondCalculator(),
|
||||||
|
tally = new JudgementTally()
|
||||||
};
|
};
|
||||||
|
|
||||||
hideTargets = new List<Drawable> { mainComponents, KeyCounter, topRightElements };
|
hideTargets = new List<Drawable> { mainComponents, KeyCounter, topRightElements };
|
||||||
|
Loading…
Reference in New Issue
Block a user