mirror of
https://github.com/ppy/osu
synced 2025-01-22 05:43:14 +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 NUnit.Framework;
|
||||||
using osu.Framework.Allocation;
|
using osu.Framework.Allocation;
|
||||||
|
using osu.Framework.Bindables;
|
||||||
using osu.Framework.Testing;
|
using osu.Framework.Testing;
|
||||||
using osu.Game.Configuration;
|
using osu.Game.Configuration;
|
||||||
using osu.Game.Rulesets.Scoring;
|
using osu.Game.Rulesets.Scoring;
|
||||||
@ -14,6 +15,8 @@ namespace osu.Game.Tests.Visual.Gameplay
|
|||||||
{
|
{
|
||||||
private FailingLayer layer;
|
private FailingLayer layer;
|
||||||
|
|
||||||
|
private Bindable<bool> enabledHUD = new Bindable<bool>();
|
||||||
|
|
||||||
[Resolved]
|
[Resolved]
|
||||||
private OsuConfigManager config { get; set; }
|
private OsuConfigManager config { get; set; }
|
||||||
|
|
||||||
@ -24,8 +27,10 @@ namespace osu.Game.Tests.Visual.Gameplay
|
|||||||
{
|
{
|
||||||
Child = layer = new FailingLayer();
|
Child = layer = new FailingLayer();
|
||||||
layer.BindHealthProcessor(new DrainingHealthProcessor(1));
|
layer.BindHealthProcessor(new DrainingHealthProcessor(1));
|
||||||
|
layer.HUDEnabled.BindTo(enabledHUD);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
AddStep("enable HUDOverlay", () => enabledHUD.Value = true);
|
||||||
AddStep("enable layer", () => config.Set(OsuSetting.FadePlayfieldWhenHealthLow, true));
|
AddStep("enable layer", () => config.Set(OsuSetting.FadePlayfieldWhenHealthLow, true));
|
||||||
AddUntilStep("layer is visible", () => layer.IsPresent);
|
AddUntilStep("layer is visible", () => layer.IsPresent);
|
||||||
}
|
}
|
||||||
@ -69,5 +74,27 @@ namespace osu.Game.Tests.Visual.Gameplay
|
|||||||
AddWaitStep("wait for potential fade", 10);
|
AddWaitStep("wait for potential fade", 10);
|
||||||
AddAssert("layer is still visible", () => layer.IsPresent);
|
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;
|
boxes.Colour = color.Red;
|
||||||
|
|
||||||
configEnabled = config.GetBindable<bool>(OsuSetting.FadePlayfieldWhenHealthLow);
|
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()
|
protected override void LoadComplete()
|
||||||
|
@ -171,13 +171,11 @@ namespace osu.Game.Screens.Play
|
|||||||
if (healthBar.NewValue)
|
if (healthBar.NewValue)
|
||||||
{
|
{
|
||||||
HealthDisplay.FadeIn(fade_duration, fade_easing);
|
HealthDisplay.FadeIn(fade_duration, fade_easing);
|
||||||
FailingLayer.TryToFade(fade_duration, fade_easing, true);
|
|
||||||
topScoreContainer.MoveToY(30, fade_duration, fade_easing);
|
topScoreContainer.MoveToY(30, fade_duration, fade_easing);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
HealthDisplay.FadeOut(fade_duration, fade_easing);
|
HealthDisplay.FadeOut(fade_duration, fade_easing);
|
||||||
FailingLayer.TryToFade(fade_duration, fade_easing, false);
|
|
||||||
topScoreContainer.MoveToY(0, fade_duration, fade_easing);
|
topScoreContainer.MoveToY(0, fade_duration, fade_easing);
|
||||||
}
|
}
|
||||||
}, true);
|
}, true);
|
||||||
|
Loading…
Reference in New Issue
Block a user