Update ComboCounter components to use DI to attach data source

This commit is contained in:
Dean Herbert
2021-05-03 16:47:47 +09:00
parent d8d2c731ee
commit 625890381f
8 changed files with 41 additions and 57 deletions

View File

@ -10,6 +10,7 @@ using osu.Framework.Graphics.Containers;
using osu.Framework.Testing;
using osu.Game.Configuration;
using osu.Game.Rulesets.Mods;
using osu.Game.Rulesets.Scoring;
using osu.Game.Screens.Play;
using osuTK.Input;
@ -19,6 +20,9 @@ namespace osu.Game.Tests.Visual.Gameplay
{
private HUDOverlay hudOverlay;
[Cached]
private ScoreProcessor scoreProcessor = new ScoreProcessor();
// best way to check without exposing.
private Drawable hideTarget => hudOverlay.KeyCounter;
private FillFlowContainer<KeyCounter> keyCounterFlow => hudOverlay.KeyCounter.ChildrenOfType<FillFlowContainer<KeyCounter>>().First();
@ -31,9 +35,9 @@ namespace osu.Game.Tests.Visual.Gameplay
{
createNew();
AddRepeatStep("increase combo", () => { hudOverlay.ComboCounter.Current.Value++; }, 10);
AddRepeatStep("increase combo", () => { scoreProcessor.Combo.Value++; }, 10);
AddStep("reset combo", () => { hudOverlay.ComboCounter.Current.Value = 0; });
AddStep("reset combo", () => { scoreProcessor.Combo.Value = 0; });
}
[Test]
@ -139,12 +143,12 @@ namespace osu.Game.Tests.Visual.Gameplay
{
AddStep("create overlay", () =>
{
hudOverlay = new HUDOverlay(null, null, null, Array.Empty<Mod>());
hudOverlay = new HUDOverlay(scoreProcessor, null, null, Array.Empty<Mod>());
// Add any key just to display the key counter visually.
hudOverlay.KeyCounter.Add(new KeyCounterKeyboard(Key.Space));
hudOverlay.ComboCounter.Current.Value = 1;
scoreProcessor.Combo.Value = 1;
action?.Invoke(hudOverlay);