2019-06-04 15:13:16 +08: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.
|
|
|
|
|
|
|
|
|
|
using System;
|
2021-10-18 13:20:38 +08:00
|
|
|
|
using NUnit.Framework;
|
2019-06-04 15:13:16 +08:00
|
|
|
|
using osu.Framework.Graphics.Containers;
|
2021-10-18 13:20:38 +08:00
|
|
|
|
using osu.Game.Configuration;
|
2019-06-04 15:13:16 +08:00
|
|
|
|
using osu.Game.Rulesets;
|
|
|
|
|
using osu.Game.Rulesets.Mods;
|
|
|
|
|
using osu.Game.Screens.Play;
|
|
|
|
|
|
|
|
|
|
namespace osu.Game.Tests.Visual.Gameplay
|
|
|
|
|
{
|
2020-01-31 12:54:26 +08:00
|
|
|
|
public partial class TestSceneFailAnimation : TestSceneAllRulesetPlayers
|
2019-06-04 15:13:16 +08:00
|
|
|
|
{
|
|
|
|
|
protected override Player CreatePlayer(Ruleset ruleset)
|
|
|
|
|
{
|
2019-12-13 20:45:38 +08:00
|
|
|
|
SelectedMods.Value = Array.Empty<Mod>();
|
2019-06-04 15:13:16 +08:00
|
|
|
|
return new FailPlayer();
|
|
|
|
|
}
|
|
|
|
|
|
2021-10-18 13:20:38 +08:00
|
|
|
|
[Test]
|
|
|
|
|
public void TestOsuWithoutRedTint()
|
|
|
|
|
{
|
|
|
|
|
AddStep("Disable red tint", () => Config.SetValue(OsuSetting.FadePlayfieldWhenHealthLow, false));
|
|
|
|
|
TestOsu();
|
|
|
|
|
AddStep("Enable red tint", () => Config.SetValue(OsuSetting.FadePlayfieldWhenHealthLow, true));
|
|
|
|
|
}
|
|
|
|
|
|
2019-06-04 15:13:16 +08:00
|
|
|
|
protected override void AddCheckSteps()
|
|
|
|
|
{
|
2022-01-26 00:45:11 +08:00
|
|
|
|
AddUntilStep("wait for fail", () => Player.GameplayState.HasFailed);
|
2019-06-11 13:28:52 +08:00
|
|
|
|
AddUntilStep("wait for fail overlay", () => ((FailPlayer)Player).FailOverlay.State.Value == Visibility.Visible);
|
2021-11-14 13:26:18 +08:00
|
|
|
|
|
|
|
|
|
// The pause screen and fail animation both ramp frequency.
|
|
|
|
|
// This tests to ensure that it doesn't reset during that handoff.
|
|
|
|
|
AddAssert("frequency only ever decreased", () => !((FailPlayer)Player).FrequencyIncreased);
|
2019-06-04 15:13:16 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private partial class FailPlayer : TestPlayer
|
|
|
|
|
{
|
|
|
|
|
public new FailOverlay FailOverlay => base.FailOverlay;
|
|
|
|
|
|
2021-11-14 13:26:18 +08:00
|
|
|
|
public bool FrequencyIncreased { get; private set; }
|
|
|
|
|
|
2019-06-04 15:13:16 +08:00
|
|
|
|
public FailPlayer()
|
|
|
|
|
: base(false, false)
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
protected override void LoadComplete()
|
|
|
|
|
{
|
|
|
|
|
base.LoadComplete();
|
2022-06-24 20:25:23 +08:00
|
|
|
|
HealthProcessor.FailConditions += (_, _) => true;
|
2019-06-04 15:13:16 +08:00
|
|
|
|
}
|
2021-11-14 13:26:18 +08:00
|
|
|
|
|
|
|
|
|
private double lastFrequency = double.MaxValue;
|
|
|
|
|
|
2022-03-24 13:51:21 +08:00
|
|
|
|
protected override void UpdateAfterChildren()
|
2021-11-14 13:26:18 +08:00
|
|
|
|
{
|
2022-03-24 13:51:21 +08:00
|
|
|
|
base.UpdateAfterChildren();
|
2021-11-14 13:26:18 +08:00
|
|
|
|
|
2022-03-24 13:51:21 +08:00
|
|
|
|
// This must be done in UpdateAfterChildren to allow the gameplay clock to have updated before checking values.
|
2021-11-14 13:26:18 +08:00
|
|
|
|
double freq = Beatmap.Value.Track.AggregateFrequency.Value;
|
|
|
|
|
|
|
|
|
|
FrequencyIncreased |= freq > lastFrequency;
|
|
|
|
|
|
|
|
|
|
lastFrequency = freq;
|
|
|
|
|
}
|
2019-06-04 15:13:16 +08:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|