diff --git a/fluXis.Game/Screens/Gameplay/HUD/Components/JudgementCounter.cs b/fluXis.Game/Screens/Gameplay/HUD/Components/JudgementCounter.cs index 07e0fd01..47b13b54 100644 --- a/fluXis.Game/Screens/Gameplay/HUD/Components/JudgementCounter.cs +++ b/fluXis.Game/Screens/Gameplay/HUD/Components/JudgementCounter.cs @@ -1,3 +1,4 @@ +using System.Collections.Generic; using System.Linq; using fluXis.Game.Graphics; using fluXis.Game.Graphics.Sprites; @@ -5,6 +6,7 @@ using fluXis.Game.Scoring; using fluXis.Game.Scoring.Enums; using fluXis.Game.Scoring.Processing; +using fluXis.Game.Scoring.Structs; using fluXis.Game.Skinning; using osu.Framework.Allocation; using osu.Framework.Graphics; @@ -24,6 +26,16 @@ private void load() Masking = true; EdgeEffect = FluXisStyles.ShadowSmall; + var dict = new Dictionary + { + { Judgement.Flawless, "FL" }, + { Judgement.Perfect, "PF" }, + { Judgement.Great, "GR" }, + { Judgement.Alright, "AL" }, + { Judgement.Okay, "OK" }, + { Judgement.Miss, "MS" }, + }; + Children = new Drawable[] { new Box @@ -36,25 +48,27 @@ private void load() Direction = FillDirection.Vertical, RelativeSizeAxes = Axes.X, AutoSizeAxes = Axes.Y, - Children = Screen.HitWindows.GetTimings().Select(t => new CounterItem(ScoreProcessor, t)).ToArray() + Children = Screen.HitWindows.GetTimings().Select(t => new CounterItem(JudgementProcessor, t, dict[t.Judgement])).ToArray() } }; } private partial class CounterItem : Container { - private readonly ScoreProcessor scoreProcessor; - private readonly Timing timing; + private JudgementProcessor processor { get; } + private Timing timing { get; } + private string defaultText { get; } private int count; private Box background; private FluXisSpriteText text; - public CounterItem(ScoreProcessor scoreProcessor, Timing timing) + public CounterItem(JudgementProcessor processor, Timing timing, string defaultText) { - this.scoreProcessor = scoreProcessor; + this.processor = processor; this.timing = timing; + this.defaultText = defaultText; } [BackgroundDependencyLoader] @@ -73,6 +87,7 @@ private void load(SkinManager skinManager) }, text = new FluXisSpriteText { + Text = defaultText, Font = FluXisFont.YoureGone, FontSize = 24, Anchor = Anchor.Centre, @@ -82,69 +97,56 @@ private void load(SkinManager skinManager) }; } - private int getCount() + protected override void LoadComplete() { - switch (timing.Judgement) - { - case Judgement.Miss: - return scoreProcessor.Miss; - - case Judgement.Okay: - return scoreProcessor.Okay; + base.LoadComplete(); - case Judgement.Alright: - return scoreProcessor.Alright; + processor.ResultAdded += addResult; + processor.ResultReverted += revertResult; + } - case Judgement.Great: - return scoreProcessor.Great; + protected override void Dispose(bool isDisposing) + { + processor.ResultAdded -= addResult; + processor.ResultReverted -= revertResult; - case Judgement.Perfect: - return scoreProcessor.Perfect; + base.Dispose(isDisposing); + } - case Judgement.Flawless: - return scoreProcessor.Flawless; + private void addResult(HitResult result) + { + if (result.Judgement != timing.Judgement) + return; - default: - return 0; - } + count++; + updateText(); + lightUp(); } - protected override void Update() + private void revertResult(HitResult result) { - var actualCount = getCount(); + if (result.Judgement != timing.Judgement) + return; - if (actualCount != 0) - { - if (actualCount != count) - { - count = actualCount; - lightUp(); - text.FontSize = count switch - { - > 0 and < 100 => 24, - < 1000 => 20, - < 10000 => 16, - _ => 12 // > 9999 - }; - } + count--; + updateText(); + } - text.Text = count.ToString(); - } - else + private void updateText() + { + if (count > 0) { - text.Text = timing.Judgement switch + text.FontSize = count switch { - Judgement.Flawless => "FL", - Judgement.Perfect => "PF", - Judgement.Great => "GR", - Judgement.Alright => "AL", - Judgement.Okay => "OK", - Judgement.Miss => "MS", - _ => "??" + > 0 and < 100 => 24, + < 1000 => 20, + < 10000 => 16, + _ => 12 // > 9999 }; + text.Text = count.ToString(); } - - base.Update(); + else + text.Text = defaultText; } private void lightUp()