mirror of
https://github.com/ppy/osu.git
synced 2024-11-14 15:57:24 +08:00
Fix failing test by setting health on source of truth
This commit is contained in:
parent
f912a1ba31
commit
49d13cda6b
@ -22,6 +22,8 @@ namespace osu.Game.Tests.Visual.Gameplay
|
|||||||
|
|
||||||
private readonly Bindable<bool> showHealth = new Bindable<bool>();
|
private readonly Bindable<bool> showHealth = new Bindable<bool>();
|
||||||
|
|
||||||
|
private HealthProcessor healthProcessor;
|
||||||
|
|
||||||
[Resolved]
|
[Resolved]
|
||||||
private OsuConfigManager config { get; set; }
|
private OsuConfigManager config { get; set; }
|
||||||
|
|
||||||
@ -29,7 +31,7 @@ namespace osu.Game.Tests.Visual.Gameplay
|
|||||||
{
|
{
|
||||||
AddStep("create layer", () =>
|
AddStep("create layer", () =>
|
||||||
{
|
{
|
||||||
Child = new HealthProcessorContainer(healthProcessor)
|
Child = new HealthProcessorContainer(this.healthProcessor = healthProcessor)
|
||||||
{
|
{
|
||||||
RelativeSizeAxes = Axes.Both,
|
RelativeSizeAxes = Axes.Both,
|
||||||
Child = layer = new FailingLayer()
|
Child = layer = new FailingLayer()
|
||||||
@ -50,12 +52,12 @@ namespace osu.Game.Tests.Visual.Gameplay
|
|||||||
AddSliderStep("current health", 0.0, 1.0, 1.0, val =>
|
AddSliderStep("current health", 0.0, 1.0, 1.0, val =>
|
||||||
{
|
{
|
||||||
if (layer != null)
|
if (layer != null)
|
||||||
layer.Current.Value = val;
|
healthProcessor.Health.Value = val;
|
||||||
});
|
});
|
||||||
|
|
||||||
AddStep("set health to 0.10", () => layer.Current.Value = 0.1);
|
AddStep("set health to 0.10", () => healthProcessor.Health.Value = 0.1);
|
||||||
AddUntilStep("layer fade is visible", () => layer.ChildrenOfType<Container>().First().Alpha > 0.1f);
|
AddUntilStep("layer fade is visible", () => layer.ChildrenOfType<Container>().First().Alpha > 0.1f);
|
||||||
AddStep("set health to 1", () => layer.Current.Value = 1f);
|
AddStep("set health to 1", () => healthProcessor.Health.Value = 1f);
|
||||||
AddUntilStep("layer fade is invisible", () => !layer.ChildrenOfType<Container>().First().IsPresent);
|
AddUntilStep("layer fade is invisible", () => !layer.ChildrenOfType<Container>().First().IsPresent);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -65,7 +67,7 @@ namespace osu.Game.Tests.Visual.Gameplay
|
|||||||
create(new DrainingHealthProcessor(0));
|
create(new DrainingHealthProcessor(0));
|
||||||
AddUntilStep("layer is visible", () => layer.IsPresent);
|
AddUntilStep("layer is visible", () => layer.IsPresent);
|
||||||
AddStep("disable layer", () => config.SetValue(OsuSetting.FadePlayfieldWhenHealthLow, false));
|
AddStep("disable layer", () => config.SetValue(OsuSetting.FadePlayfieldWhenHealthLow, false));
|
||||||
AddStep("set health to 0.10", () => layer.Current.Value = 0.1);
|
AddStep("set health to 0.10", () => healthProcessor.Health.Value = 0.1);
|
||||||
AddUntilStep("layer is not visible", () => !layer.IsPresent);
|
AddUntilStep("layer is not visible", () => !layer.IsPresent);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -74,7 +76,7 @@ namespace osu.Game.Tests.Visual.Gameplay
|
|||||||
{
|
{
|
||||||
create(new AccumulatingHealthProcessor(1));
|
create(new AccumulatingHealthProcessor(1));
|
||||||
AddUntilStep("layer is not visible", () => !layer.IsPresent);
|
AddUntilStep("layer is not visible", () => !layer.IsPresent);
|
||||||
AddStep("set health to 0.10", () => layer.Current.Value = 0.1);
|
AddStep("set health to 0.10", () => healthProcessor.Health.Value = 0.1);
|
||||||
AddUntilStep("layer is not visible", () => !layer.IsPresent);
|
AddUntilStep("layer is not visible", () => !layer.IsPresent);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -82,7 +84,7 @@ namespace osu.Game.Tests.Visual.Gameplay
|
|||||||
public void TestLayerVisibilityWithDrainingProcessor()
|
public void TestLayerVisibilityWithDrainingProcessor()
|
||||||
{
|
{
|
||||||
create(new DrainingHealthProcessor(0));
|
create(new DrainingHealthProcessor(0));
|
||||||
AddStep("set health to 0.10", () => layer.Current.Value = 0.1);
|
AddStep("set health to 0.10", () => healthProcessor.Health.Value = 0.1);
|
||||||
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);
|
||||||
}
|
}
|
||||||
@ -92,7 +94,7 @@ namespace osu.Game.Tests.Visual.Gameplay
|
|||||||
{
|
{
|
||||||
create(new DrainingHealthProcessor(0));
|
create(new DrainingHealthProcessor(0));
|
||||||
|
|
||||||
AddStep("set health to 0.10", () => layer.Current.Value = 0.1);
|
AddStep("set health to 0.10", () => healthProcessor.Health.Value = 0.1);
|
||||||
|
|
||||||
AddStep("don't show health", () => showHealth.Value = false);
|
AddStep("don't show health", () => showHealth.Value = false);
|
||||||
AddStep("disable FadePlayfieldWhenHealthLow", () => config.SetValue(OsuSetting.FadePlayfieldWhenHealthLow, false));
|
AddStep("disable FadePlayfieldWhenHealthLow", () => config.SetValue(OsuSetting.FadePlayfieldWhenHealthLow, false));
|
||||||
|
@ -100,11 +100,11 @@ namespace osu.Game.Screens.Play.HUD
|
|||||||
|
|
||||||
protected override void Update()
|
protected override void Update()
|
||||||
{
|
{
|
||||||
|
base.Update();
|
||||||
|
|
||||||
double target = Math.Clamp(max_alpha * (1 - Current.Value / low_health_threshold), 0, max_alpha);
|
double target = Math.Clamp(max_alpha * (1 - Current.Value / low_health_threshold), 0, max_alpha);
|
||||||
|
|
||||||
boxes.Alpha = (float)Interpolation.Lerp(boxes.Alpha, target, Clock.ElapsedFrameTime * 0.01f);
|
boxes.Alpha = (float)Interpolation.Lerp(boxes.Alpha, target, Clock.ElapsedFrameTime * 0.01f);
|
||||||
|
|
||||||
base.Update();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user