2020-10-30 05:23:24 +00: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.
|
|
|
|
|
2022-06-17 07:37:17 +00:00
|
|
|
#nullable disable
|
|
|
|
|
2020-10-30 05:23:24 +00:00
|
|
|
using System;
|
|
|
|
using System.Collections.Generic;
|
|
|
|
using System.Linq;
|
|
|
|
using NUnit.Framework;
|
|
|
|
using osu.Framework.Allocation;
|
|
|
|
using osu.Framework.Extensions.IEnumerableExtensions;
|
|
|
|
using osu.Framework.Graphics;
|
2023-04-03 06:37:10 +00:00
|
|
|
using osu.Framework.Graphics.Containers;
|
|
|
|
using osu.Framework.Testing;
|
2022-03-17 20:22:07 +00:00
|
|
|
using osu.Framework.Timing;
|
2020-10-30 05:23:24 +00:00
|
|
|
using osu.Game.Rulesets;
|
|
|
|
using osu.Game.Rulesets.Mods;
|
|
|
|
using osu.Game.Rulesets.Osu;
|
2021-05-03 07:47:47 +00:00
|
|
|
using osu.Game.Rulesets.Scoring;
|
2020-10-30 05:23:24 +00:00
|
|
|
using osu.Game.Screens.Play;
|
2023-03-07 07:28:54 +00:00
|
|
|
using osu.Game.Screens.Play.HUD;
|
2022-05-28 12:55:57 +00:00
|
|
|
using osu.Game.Tests.Gameplay;
|
2020-10-30 05:23:24 +00:00
|
|
|
using osuTK.Input;
|
|
|
|
|
|
|
|
namespace osu.Game.Tests.Visual.Gameplay
|
|
|
|
{
|
|
|
|
public partial class TestSceneSkinnableHUDOverlay : SkinnableTestScene
|
|
|
|
{
|
|
|
|
private HUDOverlay hudOverlay;
|
|
|
|
|
2023-05-25 07:38:22 +00:00
|
|
|
[Cached(typeof(ScoreProcessor))]
|
|
|
|
private ScoreProcessor scoreProcessor => gameplayState.ScoreProcessor;
|
2021-05-03 07:47:47 +00:00
|
|
|
|
2021-05-07 08:47:38 +00:00
|
|
|
[Cached(typeof(HealthProcessor))]
|
|
|
|
private HealthProcessor healthProcessor = new DrainingHealthProcessor(0);
|
|
|
|
|
2022-03-15 13:55:47 +00:00
|
|
|
[Cached]
|
2022-05-28 12:55:57 +00:00
|
|
|
private GameplayState gameplayState = TestGameplayState.Create(new OsuRuleset());
|
2022-03-15 13:55:47 +00:00
|
|
|
|
2022-08-15 08:36:18 +00:00
|
|
|
[Cached(typeof(IGameplayClock))]
|
2022-08-15 10:46:29 +00:00
|
|
|
private readonly IGameplayClock gameplayClock = new GameplayClockContainer(new FramedClock());
|
2022-03-17 20:22:07 +00:00
|
|
|
|
2020-10-30 05:23:24 +00:00
|
|
|
private IEnumerable<HUDOverlay> hudOverlays => CreatedDrawables.OfType<HUDOverlay>();
|
|
|
|
|
|
|
|
// best way to check without exposing.
|
2023-06-14 11:25:24 +00:00
|
|
|
private Drawable hideTarget => hudOverlay.ChildrenOfType<KeyCounterDisplay>().First();
|
|
|
|
private Drawable keyCounterFlow => hudOverlay.ChildrenOfType<KeyCounterDisplay>().First().ChildrenOfType<FillFlowContainer<KeyCounter>>().Single();
|
2020-10-30 05:23:24 +00:00
|
|
|
|
|
|
|
[Test]
|
|
|
|
public void TestComboCounterIncrementing()
|
|
|
|
{
|
|
|
|
createNew();
|
|
|
|
|
2021-05-03 07:47:47 +00:00
|
|
|
AddRepeatStep("increase combo", () => scoreProcessor.Combo.Value++, 10);
|
2020-10-30 05:23:24 +00:00
|
|
|
|
2021-05-03 07:47:47 +00:00
|
|
|
AddStep("reset combo", () => scoreProcessor.Combo.Value = 0);
|
2020-10-30 05:23:24 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
[Test]
|
|
|
|
public void TestFadesInOnLoadComplete()
|
|
|
|
{
|
|
|
|
float? initialAlpha = null;
|
|
|
|
|
|
|
|
createNew(h => h.OnLoadComplete += _ => initialAlpha = hideTarget.Alpha);
|
|
|
|
AddUntilStep("wait for load", () => hudOverlay.IsAlive);
|
|
|
|
AddAssert("initial alpha was less than 1", () => initialAlpha < 1);
|
|
|
|
}
|
|
|
|
|
|
|
|
[Test]
|
|
|
|
public void TestHideExternally()
|
|
|
|
{
|
|
|
|
createNew();
|
|
|
|
|
|
|
|
AddStep("set showhud false", () => hudOverlays.ForEach(h => h.ShowHud.Value = false));
|
|
|
|
|
|
|
|
AddUntilStep("hidetarget is hidden", () => !hideTarget.IsPresent);
|
|
|
|
AddAssert("pause button is still visible", () => hudOverlay.HoldToQuit.IsPresent);
|
|
|
|
|
|
|
|
// Key counter flow container should not be affected by this, only the key counter display will be hidden as checked above.
|
|
|
|
AddAssert("key counter flow not affected", () => keyCounterFlow.IsPresent);
|
|
|
|
}
|
|
|
|
|
|
|
|
private void createNew(Action<HUDOverlay> action = null)
|
|
|
|
{
|
|
|
|
AddStep("create overlay", () =>
|
|
|
|
{
|
2021-06-02 07:04:53 +00:00
|
|
|
SetContents(_ =>
|
2020-10-30 05:23:24 +00:00
|
|
|
{
|
2021-05-07 08:27:34 +00:00
|
|
|
hudOverlay = new HUDOverlay(null, Array.Empty<Mod>());
|
2020-10-30 05:23:24 +00:00
|
|
|
|
|
|
|
// Add any key just to display the key counter visually.
|
2023-06-14 11:25:24 +00:00
|
|
|
hudOverlay.ChildrenOfType<KeyCounterDisplay>().ForEach(k => k.Add(new KeyCounterKeyboardTrigger(Key.Space)));
|
2020-10-30 05:23:24 +00:00
|
|
|
|
|
|
|
action?.Invoke(hudOverlay);
|
|
|
|
|
|
|
|
return hudOverlay;
|
|
|
|
});
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
protected override Ruleset CreateRulesetForSkinProvider() => new OsuRuleset();
|
|
|
|
}
|
|
|
|
}
|