1
0
mirror of https://github.com/ppy/osu.git synced 2025-02-13 19:12:54 +08:00

Nest model class

This commit is contained in:
Dean Herbert 2023-01-17 18:16:46 +09:00
parent a55ce9b586
commit 0a7d6948ca
4 changed files with 17 additions and 21 deletions

View File

@ -18,9 +18,9 @@ namespace osu.Game.Screens.Play.HUD.JudgementCounter
public BindableBool ShowName = new BindableBool();
public Bindable<FillDirection> Direction = new Bindable<FillDirection>();
public readonly JudgementCounterInfo Result;
public readonly JudgementTally.JudgementCount Result;
public JudgementCounter(JudgementCounterInfo result) => Result = result;
public JudgementCounter(JudgementTally.JudgementCount result) => Result = result;
public OsuSpriteText ResultName = null!;
private FillFlowContainer flowContainer = null!;

View File

@ -124,7 +124,7 @@ namespace osu.Game.Screens.Play.HUD.JudgementCounter
All
}
private JudgementCounter createCounter(JudgementCounterInfo info)
private JudgementCounter createCounter(JudgementTally.JudgementCount info)
{
JudgementCounter counter = new JudgementCounter(info)
{

View File

@ -1,15 +0,0 @@
// 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 osu.Framework.Bindables;
using osu.Game.Rulesets.Scoring;
namespace osu.Game.Screens.Play.HUD.JudgementCounter
{
public struct JudgementCounterInfo
{
public HitResult Type { get; set; }
public BindableInt ResultCount { get; set; }
}
}

View File

@ -12,19 +12,23 @@ using osu.Game.Rulesets.Scoring;
namespace osu.Game.Screens.Play.HUD.JudgementCounter
{
/// <summary>
/// Keeps track of judgements for a current play session, exposing bindable counts which can
/// be used for display purposes.
/// </summary>
public partial class JudgementTally : CompositeDrawable
{
[Resolved]
private ScoreProcessor scoreProcessor { get; set; } = null!;
public List<JudgementCounterInfo> Results = new List<JudgementCounterInfo>();
public List<JudgementCount> Results = new List<JudgementCount>();
[BackgroundDependencyLoader]
private void load(IBindable<RulesetInfo> ruleset)
{
foreach (var result in ruleset.Value.CreateInstance().GetHitResults())
{
Results.Add(new JudgementCounterInfo
Results.Add(new JudgementCount
{
Type = result.result,
ResultCount = new BindableInt()
@ -42,8 +46,15 @@ namespace osu.Game.Screens.Play.HUD.JudgementCounter
private void updateCount(JudgementResult judgement, bool revert)
{
foreach (JudgementCounterInfo result in Results.Where(result => result.Type == judgement.Type))
foreach (JudgementCount result in Results.Where(result => result.Type == judgement.Type))
result.ResultCount.Value = revert ? result.ResultCount.Value - 1 : result.ResultCount.Value + 1;
}
public struct JudgementCount
{
public HitResult Type { get; set; }
public BindableInt ResultCount { get; set; }
}
}
}