mirror of
https://github.com/ppy/osu
synced 2025-01-05 21:59:46 +00:00
Make some changes, fix and add tests
This commit is contained in:
parent
97a212a7f6
commit
efeaa1cc10
@ -3,6 +3,7 @@
|
||||
|
||||
using NUnit.Framework;
|
||||
using osu.Framework.Allocation;
|
||||
using osu.Framework.Bindables;
|
||||
using osu.Framework.Testing;
|
||||
using osu.Game.Configuration;
|
||||
using osu.Game.Rulesets.Scoring;
|
||||
@ -14,6 +15,8 @@ namespace osu.Game.Tests.Visual.Gameplay
|
||||
{
|
||||
private FailingLayer layer;
|
||||
|
||||
private Bindable<bool> enabledHUD = new Bindable<bool>();
|
||||
|
||||
[Resolved]
|
||||
private OsuConfigManager config { get; set; }
|
||||
|
||||
@ -24,8 +27,10 @@ namespace osu.Game.Tests.Visual.Gameplay
|
||||
{
|
||||
Child = layer = new FailingLayer();
|
||||
layer.BindHealthProcessor(new DrainingHealthProcessor(1));
|
||||
layer.HUDEnabled.BindTo(enabledHUD);
|
||||
});
|
||||
|
||||
AddStep("enable HUDOverlay", () => enabledHUD.Value = true);
|
||||
AddStep("enable layer", () => config.Set(OsuSetting.FadePlayfieldWhenHealthLow, true));
|
||||
AddUntilStep("layer is visible", () => layer.IsPresent);
|
||||
}
|
||||
@ -69,5 +74,27 @@ namespace osu.Game.Tests.Visual.Gameplay
|
||||
AddWaitStep("wait for potential fade", 10);
|
||||
AddAssert("layer is still visible", () => layer.IsPresent);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestLayerVisibilityWithDifferentOptions()
|
||||
{
|
||||
AddStep("set health to 0.10", () => layer.Current.Value = 0.1);
|
||||
|
||||
AddStep("disable HUDOverlay", () => enabledHUD.Value = false);
|
||||
AddStep("disable FadePlayfieldWhenHealthLow", () => config.Set(OsuSetting.FadePlayfieldWhenHealthLow, false));
|
||||
AddUntilStep("layer fade is invisible", () => !layer.IsPresent);
|
||||
|
||||
AddStep("disable HUDOverlay", () => enabledHUD.Value = false);
|
||||
AddStep("enable FadePlayfieldWhenHealthLow", () => config.Set(OsuSetting.FadePlayfieldWhenHealthLow, true));
|
||||
AddUntilStep("layer fade is invisible", () => !layer.IsPresent);
|
||||
|
||||
AddStep("enable HUDOverlay", () => enabledHUD.Value = true);
|
||||
AddStep("disable FadePlayfieldWhenHealthLow", () => config.Set(OsuSetting.FadePlayfieldWhenHealthLow, false));
|
||||
AddUntilStep("layer fade is invisible", () => !layer.IsPresent);
|
||||
|
||||
AddStep("enable HUDOverlay", () => enabledHUD.Value = true);
|
||||
AddStep("enable FadePlayfieldWhenHealthLow", () => config.Set(OsuSetting.FadePlayfieldWhenHealthLow, true));
|
||||
AddUntilStep("layer fade is visible", () => layer.IsPresent);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -75,7 +75,8 @@ namespace osu.Game.Screens.Play.HUD
|
||||
boxes.Colour = color.Red;
|
||||
|
||||
configEnabled = config.GetBindable<bool>(OsuSetting.FadePlayfieldWhenHealthLow);
|
||||
enabled.BindValueChanged(e => TryToFade(fade_time, Easing.OutQuint, e.NewValue ? true : false), true);
|
||||
enabled.BindValueChanged(e => TryToFade(fade_time, Easing.OutQuint, e.NewValue), true);
|
||||
HUDEnabled.BindValueChanged(e => TryToFade(fade_time, Easing.OutQuint, e.NewValue), true);
|
||||
}
|
||||
|
||||
protected override void LoadComplete()
|
||||
|
@ -171,13 +171,11 @@ namespace osu.Game.Screens.Play
|
||||
if (healthBar.NewValue)
|
||||
{
|
||||
HealthDisplay.FadeIn(fade_duration, fade_easing);
|
||||
FailingLayer.TryToFade(fade_duration, fade_easing, true);
|
||||
topScoreContainer.MoveToY(30, fade_duration, fade_easing);
|
||||
}
|
||||
else
|
||||
{
|
||||
HealthDisplay.FadeOut(fade_duration, fade_easing);
|
||||
FailingLayer.TryToFade(fade_duration, fade_easing, false);
|
||||
topScoreContainer.MoveToY(0, fade_duration, fade_easing);
|
||||
}
|
||||
}, true);
|
||||
|
Loading…
Reference in New Issue
Block a user