mirror of
https://github.com/ppy/osu.git
synced 2024-12-14 14:25:05 +08:00
fixed shape bindable not working, test creation, removal of Clear(), adjusted settings names
This commit is contained in:
parent
05797cb9e5
commit
f6aef73f9e
119
osu.Game.Tests/Visual/Gameplay/TestSceneColourHitErrorMeter.cs
Normal file
119
osu.Game.Tests/Visual/Gameplay/TestSceneColourHitErrorMeter.cs
Normal file
@ -0,0 +1,119 @@
|
||||
// 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.
|
||||
|
||||
#nullable disable
|
||||
using System;
|
||||
using System.Diagnostics;
|
||||
using NUnit.Framework;
|
||||
using osu.Framework.Bindables;
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Framework.Testing;
|
||||
using osu.Game.Rulesets;
|
||||
using osu.Game.Rulesets.Judgements;
|
||||
using osu.Game.Rulesets.Objects;
|
||||
using osu.Game.Rulesets.Osu;
|
||||
using osu.Game.Rulesets.Osu.Judgements;
|
||||
using osu.Game.Rulesets.Scoring;
|
||||
using osu.Game.Screens.Play.HUD.HitErrorMeters;
|
||||
using osuTK;
|
||||
|
||||
namespace osu.Game.Tests.Visual.Gameplay
|
||||
{
|
||||
public class TestSceneColourHitErrorMeter : OsuTestScene
|
||||
{
|
||||
private DependencyProvidingContainer dependencyContainer;
|
||||
|
||||
private readonly Bindable<JudgementResult> lastJudgementResult = new Bindable<JudgementResult>();
|
||||
private ScoreProcessor scoreProcessor;
|
||||
private int iteration;
|
||||
private ColourHitErrorMeter colourHitErrorMeter;
|
||||
|
||||
public TestSceneColourHitErrorMeter()
|
||||
{
|
||||
AddSliderStep("Manual Opacity test", 0.01f, 1, 1, alpha =>
|
||||
{
|
||||
if (colourHitErrorMeter != null) colourHitErrorMeter.HitShapeOpacity.Value = alpha;
|
||||
});
|
||||
AddSliderStep("Manual spacing test", 0, 10, 2, spacing =>
|
||||
{
|
||||
if (colourHitErrorMeter != null) colourHitErrorMeter.HitShapeSpacing.Value = spacing;
|
||||
});
|
||||
}
|
||||
|
||||
[SetUpSteps]
|
||||
public void SetupSteps() => AddStep("Create components", () =>
|
||||
{
|
||||
var ruleset = CreateRuleset();
|
||||
|
||||
Debug.Assert(ruleset != null);
|
||||
|
||||
scoreProcessor = new ScoreProcessor(ruleset);
|
||||
Child = dependencyContainer = new DependencyProvidingContainer
|
||||
{
|
||||
RelativeSizeAxes = Axes.Both,
|
||||
CachedDependencies = new (Type, object)[]
|
||||
{
|
||||
(typeof(ScoreProcessor), scoreProcessor)
|
||||
}
|
||||
};
|
||||
dependencyContainer.Child = colourHitErrorMeter = new ColourHitErrorMeter
|
||||
{
|
||||
Margin = new MarginPadding
|
||||
{
|
||||
Top = 100
|
||||
},
|
||||
Anchor = Anchor.TopCentre,
|
||||
Origin = Anchor.TopCentre,
|
||||
Scale = new Vector2(2),
|
||||
};
|
||||
});
|
||||
|
||||
protected override Ruleset CreateRuleset() => new OsuRuleset();
|
||||
|
||||
[Test]
|
||||
public void TestOpacityChange()
|
||||
{
|
||||
AddRepeatStep("Add judgement", applyOneJudgement, 5);
|
||||
AddStep("Change opacity to 30%", () => colourHitErrorMeter.HitShapeOpacity.Value = 0.3f);
|
||||
AddRepeatStep("Add judgement", applyOneJudgement, 5);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestSpacingChange()
|
||||
{
|
||||
AddRepeatStep("Add judgement", applyOneJudgement, 5);
|
||||
AddStep("Change spacing", () => colourHitErrorMeter.HitShapeSpacing.Value = 10);
|
||||
AddRepeatStep("Add judgement", applyOneJudgement, 5);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestShapeChange()
|
||||
{
|
||||
AddRepeatStep("Add judgement", applyOneJudgement, 10);
|
||||
AddStep("Judgement count change to 4", () => colourHitErrorMeter.HitShapeCount.Value = 4);
|
||||
AddRepeatStep("Add judgement", applyOneJudgement, 8);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestHitErrorShapeChange()
|
||||
{
|
||||
AddRepeatStep("Add judgement", applyOneJudgement, 8);
|
||||
AddStep("Change shape square", () => colourHitErrorMeter.HitShape.Value = ColourHitErrorMeter.ShapeStyle.Square);
|
||||
AddRepeatStep("Add judgement", applyOneJudgement, 10);
|
||||
}
|
||||
|
||||
private void applyOneJudgement()
|
||||
{
|
||||
lastJudgementResult.Value = new OsuJudgementResult(new HitObject
|
||||
{
|
||||
StartTime = iteration * 10000,
|
||||
}, new OsuJudgement())
|
||||
{
|
||||
Type = HitResult.Great,
|
||||
};
|
||||
scoreProcessor.ApplyResult(lastJudgementResult.Value);
|
||||
|
||||
iteration++;
|
||||
}
|
||||
}
|
||||
}
|
@ -20,7 +20,7 @@ namespace osu.Game.Screens.Play.HUD.HitErrorMeters
|
||||
private const int animation_duration = 200;
|
||||
private const int drawable_judgement_size = 8;
|
||||
|
||||
[SettingSource("Hit error amount", "Number of hit error shapes")]
|
||||
[SettingSource("Judgement count", "Number of displayed judgements")]
|
||||
public BindableNumber<int> HitShapeCount { get; } = new BindableNumber<int>(20)
|
||||
{
|
||||
MinValue = 1,
|
||||
@ -28,7 +28,7 @@ namespace osu.Game.Screens.Play.HUD.HitErrorMeters
|
||||
Precision = 1
|
||||
};
|
||||
|
||||
[SettingSource("Opacity", "Visibility of object")]
|
||||
[SettingSource("Opacity", "Visibility of the displayed judgements")]
|
||||
public BindableNumber<float> HitShapeOpacity { get; } = new BindableNumber<float>(1)
|
||||
{
|
||||
MinValue = 0.01f,
|
||||
@ -36,7 +36,7 @@ namespace osu.Game.Screens.Play.HUD.HitErrorMeters
|
||||
Precision = 0.01f,
|
||||
};
|
||||
|
||||
[SettingSource("Spacing", "Space between hit error shapes")]
|
||||
[SettingSource("Spacing", "Space between each displayed judgement")]
|
||||
public BindableNumber<float> HitShapeSpacing { get; } = new BindableNumber<float>(2)
|
||||
{
|
||||
MinValue = 0,
|
||||
@ -44,7 +44,7 @@ namespace osu.Game.Screens.Play.HUD.HitErrorMeters
|
||||
Precision = 0.1f
|
||||
};
|
||||
|
||||
[SettingSource("Shape", "The shape of each displayed error")]
|
||||
[SettingSource("Shape", "The shape of each displayed judgement")]
|
||||
public Bindable<ShapeStyle> HitShape { get; } = new Bindable<ShapeStyle>();
|
||||
|
||||
private readonly JudgementFlow judgementsFlow;
|
||||
@ -74,9 +74,11 @@ namespace osu.Game.Screens.Play.HUD.HitErrorMeters
|
||||
}, true);
|
||||
HitShapeCount.BindValueChanged(_ =>
|
||||
{
|
||||
judgementsFlow.Clear();
|
||||
//Used to clear out the overflowing judgement children when the value is lowered
|
||||
judgementsFlow.RemoveAll(_ => true);
|
||||
judgementsFlow.Height = HitShapeCount.Value * (drawable_judgement_size + HitShapeSpacing.Value) - HitShapeSpacing.Value;
|
||||
}, true);
|
||||
HitShape.BindValueChanged(_ => judgementsFlow.Shape.Value = HitShape.Value, true);
|
||||
}
|
||||
|
||||
public override void Clear() => judgementsFlow.Clear();
|
||||
|
Loading…
Reference in New Issue
Block a user