mirror of
https://github.com/ppy/osu.git
synced 2025-02-01 00:39:11 +08:00
Merge branch 'master' into triangles-v2
This commit is contained in:
commit
d94c624ee4
@ -56,6 +56,8 @@ namespace osu.Game.Rulesets.Osu.Mods
|
|||||||
{
|
{
|
||||||
switch (nested)
|
switch (nested)
|
||||||
{
|
{
|
||||||
|
//Freezing the SliderTicks doesnt play well with snaking sliders
|
||||||
|
case SliderTick:
|
||||||
//SliderRepeat wont layer correctly if preempt is changed.
|
//SliderRepeat wont layer correctly if preempt is changed.
|
||||||
case SliderRepeat:
|
case SliderRepeat:
|
||||||
break;
|
break;
|
||||||
|
@ -9,6 +9,7 @@ using osu.Framework.Graphics.Shapes;
|
|||||||
using osu.Game.Beatmaps.ControlPoints;
|
using osu.Game.Beatmaps.ControlPoints;
|
||||||
using osu.Game.Graphics.Containers;
|
using osu.Game.Graphics.Containers;
|
||||||
using osu.Game.Rulesets.Objects.Drawables;
|
using osu.Game.Rulesets.Objects.Drawables;
|
||||||
|
using osu.Game.Rulesets.Taiko.Objects;
|
||||||
using osuTK.Graphics;
|
using osuTK.Graphics;
|
||||||
|
|
||||||
namespace osu.Game.Rulesets.Taiko.Skinning.Argon
|
namespace osu.Game.Rulesets.Taiko.Skinning.Argon
|
||||||
@ -81,12 +82,15 @@ namespace osu.Game.Rulesets.Taiko.Skinning.Argon
|
|||||||
updateStateTransforms(drawableHitObject, drawableHitObject.State.Value);
|
updateStateTransforms(drawableHitObject, drawableHitObject.State.Value);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void updateStateTransforms(DrawableHitObject drawableHitObject, ArmedState state)
|
private void updateStateTransforms(DrawableHitObject h, ArmedState state)
|
||||||
{
|
{
|
||||||
|
if (h.HitObject is not Hit)
|
||||||
|
return;
|
||||||
|
|
||||||
switch (state)
|
switch (state)
|
||||||
{
|
{
|
||||||
case ArmedState.Hit:
|
case ArmedState.Hit:
|
||||||
using (BeginAbsoluteSequence(drawableHitObject.HitStateUpdateTime))
|
using (BeginAbsoluteSequence(h.HitStateUpdateTime))
|
||||||
{
|
{
|
||||||
flash.FadeTo(0.9f).FadeOut(500, Easing.OutQuint);
|
flash.FadeTo(0.9f).FadeOut(500, Easing.OutQuint);
|
||||||
}
|
}
|
||||||
|
@ -153,12 +153,15 @@ namespace osu.Game.Rulesets.Taiko.Skinning.Default
|
|||||||
updateStateTransforms(drawableHitObject, drawableHitObject.State.Value);
|
updateStateTransforms(drawableHitObject, drawableHitObject.State.Value);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void updateStateTransforms(DrawableHitObject drawableHitObject, ArmedState state)
|
private void updateStateTransforms(DrawableHitObject h, ArmedState state)
|
||||||
{
|
{
|
||||||
|
if (h.HitObject is not Hit)
|
||||||
|
return;
|
||||||
|
|
||||||
switch (state)
|
switch (state)
|
||||||
{
|
{
|
||||||
case ArmedState.Hit:
|
case ArmedState.Hit:
|
||||||
using (BeginAbsoluteSequence(drawableHitObject.HitStateUpdateTime))
|
using (BeginAbsoluteSequence(h.HitStateUpdateTime))
|
||||||
flashBox.FadeTo(0.9f).FadeOut(300);
|
flashBox.FadeTo(0.9f).FadeOut(300);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -1,43 +1,40 @@
|
|||||||
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
|
// 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.
|
// See the LICENCE file in the repository root for full licence text.
|
||||||
|
|
||||||
using osu.Framework.Graphics;
|
|
||||||
using osu.Framework.Graphics.Containers;
|
|
||||||
using osu.Framework.Graphics.Shapes;
|
|
||||||
using osuTK;
|
|
||||||
using osuTK.Graphics;
|
|
||||||
using osu.Game.Graphics.Backgrounds;
|
using osu.Game.Graphics.Backgrounds;
|
||||||
|
using osu.Framework.Graphics;
|
||||||
|
using osuTK.Graphics;
|
||||||
|
using osu.Framework.Graphics.Shapes;
|
||||||
|
|
||||||
namespace osu.Game.Tests.Visual.Background
|
namespace osu.Game.Tests.Visual.Background
|
||||||
{
|
{
|
||||||
public class TestSceneTrianglesBackground : OsuTestScene
|
public class TestSceneTrianglesBackground : OsuTestScene
|
||||||
{
|
{
|
||||||
|
private readonly Triangles triangles;
|
||||||
|
|
||||||
public TestSceneTrianglesBackground()
|
public TestSceneTrianglesBackground()
|
||||||
{
|
{
|
||||||
AddRange(new Drawable[]
|
Children = new Drawable[]
|
||||||
{
|
{
|
||||||
new Box
|
new Box
|
||||||
{
|
{
|
||||||
RelativeSizeAxes = Axes.Both,
|
RelativeSizeAxes = Axes.Both,
|
||||||
Colour = Color4.Gray
|
Colour = Color4.Black
|
||||||
},
|
},
|
||||||
new Container
|
triangles = new Triangles
|
||||||
{
|
{
|
||||||
Anchor = Anchor.Centre,
|
|
||||||
Origin = Anchor.Centre,
|
|
||||||
Size = new Vector2(200),
|
|
||||||
Masking = true,
|
|
||||||
CornerRadius = 40,
|
|
||||||
Child = new TrianglesV2
|
|
||||||
{
|
|
||||||
Anchor = Anchor.Centre,
|
|
||||||
Origin = Anchor.Centre,
|
|
||||||
RelativeSizeAxes = Axes.Both,
|
RelativeSizeAxes = Axes.Both,
|
||||||
ColourTop = Color4.Red,
|
ColourLight = Color4.White,
|
||||||
ColourBottom = Color4.Orange
|
ColourDark = Color4.Gray
|
||||||
}
|
}
|
||||||
|
};
|
||||||
}
|
}
|
||||||
});
|
|
||||||
|
protected override void LoadComplete()
|
||||||
|
{
|
||||||
|
base.LoadComplete();
|
||||||
|
|
||||||
|
AddSliderStep("Triangle scale", 0f, 10f, 1f, s => triangles.TriangleScale = s);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -163,10 +163,7 @@ namespace osu.Game.Tests.Visual.Gameplay
|
|||||||
|
|
||||||
AddUntilStep("wait for bars to disappear", () => !this.ChildrenOfType<BarHitErrorMeter.JudgementLine>().Any());
|
AddUntilStep("wait for bars to disappear", () => !this.ChildrenOfType<BarHitErrorMeter.JudgementLine>().Any());
|
||||||
AddUntilStep("ensure max circles not exceeded", () =>
|
AddUntilStep("ensure max circles not exceeded", () =>
|
||||||
{
|
this.ChildrenOfType<ColourHitErrorMeter>().First().ChildrenOfType<ColourHitErrorMeter.HitErrorShape>().Count(), () => Is.LessThanOrEqualTo(max_displayed_judgements));
|
||||||
return this.ChildrenOfType<ColourHitErrorMeter>()
|
|
||||||
.All(m => m.ChildrenOfType<ColourHitErrorMeter.HitErrorShape>().Count() <= max_displayed_judgements);
|
|
||||||
});
|
|
||||||
|
|
||||||
AddStep("show displays", () =>
|
AddStep("show displays", () =>
|
||||||
{
|
{
|
||||||
|
@ -59,6 +59,8 @@ namespace osu.Game.Beatmaps.Drawables.Cards
|
|||||||
return base.OnScroll(e);
|
return base.OnScroll(e);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected override bool OnClick(ClickEvent e) => true;
|
||||||
|
|
||||||
private class ExpandedContentScrollbar : OsuScrollbar
|
private class ExpandedContentScrollbar : OsuScrollbar
|
||||||
{
|
{
|
||||||
public ExpandedContentScrollbar(Direction scrollDir)
|
public ExpandedContentScrollbar(Direction scrollDir)
|
||||||
|
@ -17,6 +17,7 @@ using System.Collections.Generic;
|
|||||||
using osu.Framework.Graphics.Rendering;
|
using osu.Framework.Graphics.Rendering;
|
||||||
using osu.Framework.Graphics.Rendering.Vertices;
|
using osu.Framework.Graphics.Rendering.Vertices;
|
||||||
using osu.Framework.Lists;
|
using osu.Framework.Lists;
|
||||||
|
using osu.Framework.Bindables;
|
||||||
|
|
||||||
namespace osu.Game.Graphics.Backgrounds
|
namespace osu.Game.Graphics.Backgrounds
|
||||||
{
|
{
|
||||||
@ -25,6 +26,11 @@ namespace osu.Game.Graphics.Backgrounds
|
|||||||
private const float triangle_size = 100;
|
private const float triangle_size = 100;
|
||||||
private const float base_velocity = 50;
|
private const float base_velocity = 50;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// sqrt(3) / 2
|
||||||
|
/// </summary>
|
||||||
|
private const float equilateral_triangle_ratio = 0.866f;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// How many screen-space pixels are smoothed over.
|
/// How many screen-space pixels are smoothed over.
|
||||||
/// Same behavior as Sprite's EdgeSmoothness.
|
/// Same behavior as Sprite's EdgeSmoothness.
|
||||||
@ -69,7 +75,13 @@ namespace osu.Game.Graphics.Backgrounds
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
protected virtual float SpawnRatio => 1;
|
protected virtual float SpawnRatio => 1;
|
||||||
|
|
||||||
private float triangleScale = 1;
|
private readonly BindableFloat triangleScale = new BindableFloat(1f);
|
||||||
|
|
||||||
|
public float TriangleScale
|
||||||
|
{
|
||||||
|
get => triangleScale.Value;
|
||||||
|
set => triangleScale.Value = value;
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Whether we should drop-off alpha values of triangles more quickly to improve
|
/// Whether we should drop-off alpha values of triangles more quickly to improve
|
||||||
@ -109,24 +121,7 @@ namespace osu.Game.Graphics.Backgrounds
|
|||||||
protected override void LoadComplete()
|
protected override void LoadComplete()
|
||||||
{
|
{
|
||||||
base.LoadComplete();
|
base.LoadComplete();
|
||||||
addTriangles(true);
|
triangleScale.BindValueChanged(_ => Reset(), true);
|
||||||
}
|
|
||||||
|
|
||||||
public float TriangleScale
|
|
||||||
{
|
|
||||||
get => triangleScale;
|
|
||||||
set
|
|
||||||
{
|
|
||||||
float change = value / triangleScale;
|
|
||||||
triangleScale = value;
|
|
||||||
|
|
||||||
for (int i = 0; i < parts.Count; i++)
|
|
||||||
{
|
|
||||||
TriangleParticle newParticle = parts[i];
|
|
||||||
newParticle.Scale *= change;
|
|
||||||
parts[i] = newParticle;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override void Update()
|
protected override void Update()
|
||||||
@ -147,7 +142,7 @@ namespace osu.Game.Graphics.Backgrounds
|
|||||||
// Since position is relative, the velocity needs to scale inversely with DrawHeight.
|
// Since position is relative, the velocity needs to scale inversely with DrawHeight.
|
||||||
// Since we will later multiply by the scale of individual triangles we normalize by
|
// Since we will later multiply by the scale of individual triangles we normalize by
|
||||||
// dividing by triangleScale.
|
// dividing by triangleScale.
|
||||||
float movedDistance = -elapsedSeconds * Velocity * base_velocity / (DrawHeight * triangleScale);
|
float movedDistance = -elapsedSeconds * Velocity * base_velocity / (DrawHeight * TriangleScale);
|
||||||
|
|
||||||
for (int i = 0; i < parts.Count; i++)
|
for (int i = 0; i < parts.Count; i++)
|
||||||
{
|
{
|
||||||
@ -159,7 +154,7 @@ namespace osu.Game.Graphics.Backgrounds
|
|||||||
|
|
||||||
parts[i] = newParticle;
|
parts[i] = newParticle;
|
||||||
|
|
||||||
float bottomPos = parts[i].Position.Y + triangle_size * parts[i].Scale * 0.866f / DrawHeight;
|
float bottomPos = parts[i].Position.Y + triangle_size * parts[i].Scale * equilateral_triangle_ratio / DrawHeight;
|
||||||
if (bottomPos < 0)
|
if (bottomPos < 0)
|
||||||
parts.RemoveAt(i);
|
parts.RemoveAt(i);
|
||||||
}
|
}
|
||||||
@ -185,9 +180,11 @@ namespace osu.Game.Graphics.Backgrounds
|
|||||||
// Limited by the maximum size of QuadVertexBuffer for safety.
|
// Limited by the maximum size of QuadVertexBuffer for safety.
|
||||||
const int max_triangles = ushort.MaxValue / (IRenderer.VERTICES_PER_QUAD + 2);
|
const int max_triangles = ushort.MaxValue / (IRenderer.VERTICES_PER_QUAD + 2);
|
||||||
|
|
||||||
AimCount = (int)Math.Min(max_triangles, (DrawWidth * DrawHeight * 0.002f / (triangleScale * triangleScale) * SpawnRatio));
|
AimCount = (int)Math.Min(max_triangles, DrawWidth * DrawHeight * 0.002f / (TriangleScale * TriangleScale) * SpawnRatio);
|
||||||
|
|
||||||
for (int i = 0; i < AimCount - parts.Count; i++)
|
int currentCount = parts.Count;
|
||||||
|
|
||||||
|
for (int i = 0; i < AimCount - currentCount; i++)
|
||||||
parts.Add(createTriangle(randomY));
|
parts.Add(createTriangle(randomY));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -195,13 +192,27 @@ namespace osu.Game.Graphics.Backgrounds
|
|||||||
{
|
{
|
||||||
TriangleParticle particle = CreateTriangle();
|
TriangleParticle particle = CreateTriangle();
|
||||||
|
|
||||||
particle.Position = new Vector2(nextRandom(), randomY ? nextRandom() : 1);
|
particle.Position = getRandomPosition(randomY, particle.Scale);
|
||||||
particle.ColourShade = nextRandom();
|
particle.ColourShade = nextRandom();
|
||||||
particle.Colour = CreateTriangleShade(particle.ColourShade);
|
particle.Colour = CreateTriangleShade(particle.ColourShade);
|
||||||
|
|
||||||
return particle;
|
return particle;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private Vector2 getRandomPosition(bool randomY, float scale)
|
||||||
|
{
|
||||||
|
float y = 1;
|
||||||
|
|
||||||
|
if (randomY)
|
||||||
|
{
|
||||||
|
// since triangles are drawn from the top - allow them to be positioned a bit above the screen
|
||||||
|
float maxOffset = triangle_size * scale * equilateral_triangle_ratio / DrawHeight;
|
||||||
|
y = Interpolation.ValueAt(nextRandom(), -maxOffset, 1f, 0f, 1f);
|
||||||
|
}
|
||||||
|
|
||||||
|
return new Vector2(nextRandom(), y);
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Creates a triangle particle with a random scale.
|
/// Creates a triangle particle with a random scale.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@ -214,7 +225,7 @@ namespace osu.Game.Graphics.Backgrounds
|
|||||||
float u1 = 1 - nextRandom(); //uniform(0,1] random floats
|
float u1 = 1 - nextRandom(); //uniform(0,1] random floats
|
||||||
float u2 = 1 - nextRandom();
|
float u2 = 1 - nextRandom();
|
||||||
float randStdNormal = (float)(Math.Sqrt(-2.0 * Math.Log(u1)) * Math.Sin(2.0 * Math.PI * u2)); // random normal(0,1)
|
float randStdNormal = (float)(Math.Sqrt(-2.0 * Math.Log(u1)) * Math.Sin(2.0 * Math.PI * u2)); // random normal(0,1)
|
||||||
float scale = Math.Max(triangleScale * (mean + std_dev * randStdNormal), 0.1f); // random normal(mean,stdDev^2)
|
float scale = Math.Max(TriangleScale * (mean + std_dev * randStdNormal), 0.1f); // random normal(mean,stdDev^2)
|
||||||
|
|
||||||
return new TriangleParticle { Scale = scale };
|
return new TriangleParticle { Scale = scale };
|
||||||
}
|
}
|
||||||
@ -284,7 +295,7 @@ namespace osu.Game.Graphics.Backgrounds
|
|||||||
|
|
||||||
foreach (TriangleParticle particle in parts)
|
foreach (TriangleParticle particle in parts)
|
||||||
{
|
{
|
||||||
var offset = triangle_size * new Vector2(particle.Scale * 0.5f, particle.Scale * 0.866f);
|
var offset = triangle_size * new Vector2(particle.Scale * 0.5f, particle.Scale * equilateral_triangle_ratio);
|
||||||
|
|
||||||
var triangle = new Triangle(
|
var triangle = new Triangle(
|
||||||
Vector2Extensions.Transform(particle.Position * size, DrawInfo.Matrix),
|
Vector2Extensions.Transform(particle.Position * size, DrawInfo.Matrix),
|
||||||
|
@ -115,7 +115,11 @@ namespace osu.Game.Rulesets.UI
|
|||||||
|
|
||||||
public Sample Get(string name) => primary.Get(name) ?? fallback.Get(name);
|
public Sample Get(string name) => primary.Get(name) ?? fallback.Get(name);
|
||||||
|
|
||||||
public Task<Sample> GetAsync(string name, CancellationToken cancellationToken = default) => primary.GetAsync(name, cancellationToken) ?? fallback.GetAsync(name, cancellationToken);
|
public async Task<Sample> GetAsync(string name, CancellationToken cancellationToken = default)
|
||||||
|
{
|
||||||
|
return await primary.GetAsync(name, cancellationToken).ConfigureAwait(false)
|
||||||
|
?? await fallback.GetAsync(name, cancellationToken).ConfigureAwait(false);
|
||||||
|
}
|
||||||
|
|
||||||
public Stream GetStream(string name) => primary.GetStream(name) ?? fallback.GetStream(name);
|
public Stream GetStream(string name) => primary.GetStream(name) ?? fallback.GetStream(name);
|
||||||
|
|
||||||
|
@ -1,8 +1,6 @@
|
|||||||
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
|
// 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.
|
// See the LICENCE file in the repository root for full licence text.
|
||||||
|
|
||||||
#nullable disable
|
|
||||||
|
|
||||||
using System;
|
using System;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using osu.Framework.Allocation;
|
using osu.Framework.Allocation;
|
||||||
@ -11,6 +9,7 @@ using osu.Framework.Extensions.Color4Extensions;
|
|||||||
using osu.Framework.Graphics;
|
using osu.Framework.Graphics;
|
||||||
using osu.Framework.Graphics.Colour;
|
using osu.Framework.Graphics.Colour;
|
||||||
using osu.Framework.Graphics.Containers;
|
using osu.Framework.Graphics.Containers;
|
||||||
|
using osu.Framework.Graphics.Pooling;
|
||||||
using osu.Framework.Graphics.Shapes;
|
using osu.Framework.Graphics.Shapes;
|
||||||
using osu.Framework.Graphics.Sprites;
|
using osu.Framework.Graphics.Sprites;
|
||||||
using osu.Game.Configuration;
|
using osu.Game.Configuration;
|
||||||
@ -23,10 +22,9 @@ using osuTK;
|
|||||||
|
|
||||||
namespace osu.Game.Screens.Play.HUD.HitErrorMeters
|
namespace osu.Game.Screens.Play.HUD.HitErrorMeters
|
||||||
{
|
{
|
||||||
|
[Cached]
|
||||||
public class BarHitErrorMeter : HitErrorMeter
|
public class BarHitErrorMeter : HitErrorMeter
|
||||||
{
|
{
|
||||||
private const int judgement_line_width = 14;
|
|
||||||
|
|
||||||
[SettingSource("Judgement line thickness", "How thick the individual lines should be.")]
|
[SettingSource("Judgement line thickness", "How thick the individual lines should be.")]
|
||||||
public BindableNumber<float> JudgementLineThickness { get; } = new BindableNumber<float>(4)
|
public BindableNumber<float> JudgementLineThickness { get; } = new BindableNumber<float>(4)
|
||||||
{
|
{
|
||||||
@ -44,28 +42,33 @@ namespace osu.Game.Screens.Play.HUD.HitErrorMeters
|
|||||||
[SettingSource("Label style", "How to show early/late extremities")]
|
[SettingSource("Label style", "How to show early/late extremities")]
|
||||||
public Bindable<LabelStyles> LabelStyle { get; } = new Bindable<LabelStyles>(LabelStyles.Icons);
|
public Bindable<LabelStyles> LabelStyle { get; } = new Bindable<LabelStyles>(LabelStyles.Icons);
|
||||||
|
|
||||||
private SpriteIcon arrow;
|
private const int judgement_line_width = 14;
|
||||||
private UprightAspectMaintainingContainer labelEarly;
|
|
||||||
private UprightAspectMaintainingContainer labelLate;
|
|
||||||
|
|
||||||
private Container colourBarsEarly;
|
private const int max_concurrent_judgements = 50;
|
||||||
private Container colourBarsLate;
|
|
||||||
|
|
||||||
private Container judgementsContainer;
|
private const int centre_marker_size = 8;
|
||||||
|
|
||||||
private double maxHitWindow;
|
private double maxHitWindow;
|
||||||
|
|
||||||
private double floatingAverage;
|
private double floatingAverage;
|
||||||
private Container colourBars;
|
|
||||||
private Container arrowContainer;
|
|
||||||
|
|
||||||
private (HitResult result, double length)[] hitWindows;
|
private readonly DrawablePool<JudgementLine> judgementLinePool = new DrawablePool<JudgementLine>(50);
|
||||||
|
|
||||||
private const int max_concurrent_judgements = 50;
|
private SpriteIcon arrow = null!;
|
||||||
|
private UprightAspectMaintainingContainer labelEarly = null!;
|
||||||
|
private UprightAspectMaintainingContainer labelLate = null!;
|
||||||
|
|
||||||
private Drawable[] centreMarkerDrawables;
|
private Container colourBarsEarly = null!;
|
||||||
|
private Container colourBarsLate = null!;
|
||||||
|
|
||||||
private const int centre_marker_size = 8;
|
private Container judgementsContainer = null!;
|
||||||
|
|
||||||
|
private Container colourBars = null!;
|
||||||
|
private Container arrowContainer = null!;
|
||||||
|
|
||||||
|
private (HitResult result, double length)[] hitWindows = null!;
|
||||||
|
|
||||||
|
private Drawable[]? centreMarkerDrawables;
|
||||||
|
|
||||||
public BarHitErrorMeter()
|
public BarHitErrorMeter()
|
||||||
{
|
{
|
||||||
@ -88,6 +91,7 @@ namespace osu.Game.Screens.Play.HUD.HitErrorMeters
|
|||||||
Margin = new MarginPadding(2),
|
Margin = new MarginPadding(2),
|
||||||
Children = new Drawable[]
|
Children = new Drawable[]
|
||||||
{
|
{
|
||||||
|
judgementLinePool,
|
||||||
colourBars = new Container
|
colourBars = new Container
|
||||||
{
|
{
|
||||||
Name = "colour axis",
|
Name = "colour axis",
|
||||||
@ -403,11 +407,12 @@ namespace osu.Game.Screens.Play.HUD.HitErrorMeters
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
judgementsContainer.Add(new JudgementLine
|
judgementLinePool.Get(drawableJudgement =>
|
||||||
{
|
{
|
||||||
JudgementLineThickness = { BindTarget = JudgementLineThickness },
|
drawableJudgement.Y = getRelativeJudgementPosition(judgement.TimeOffset);
|
||||||
Y = getRelativeJudgementPosition(judgement.TimeOffset),
|
drawableJudgement.Colour = GetColourForHitResult(judgement.Type);
|
||||||
Colour = GetColourForHitResult(judgement.Type),
|
|
||||||
|
judgementsContainer.Add(drawableJudgement);
|
||||||
});
|
});
|
||||||
|
|
||||||
arrow.MoveToY(
|
arrow.MoveToY(
|
||||||
@ -417,10 +422,13 @@ namespace osu.Game.Screens.Play.HUD.HitErrorMeters
|
|||||||
|
|
||||||
private float getRelativeJudgementPosition(double value) => Math.Clamp((float)((value / maxHitWindow) + 1) / 2, 0, 1);
|
private float getRelativeJudgementPosition(double value) => Math.Clamp((float)((value / maxHitWindow) + 1) / 2, 0, 1);
|
||||||
|
|
||||||
internal class JudgementLine : CompositeDrawable
|
internal class JudgementLine : PoolableDrawable
|
||||||
{
|
{
|
||||||
public readonly BindableNumber<float> JudgementLineThickness = new BindableFloat();
|
public readonly BindableNumber<float> JudgementLineThickness = new BindableFloat();
|
||||||
|
|
||||||
|
[Resolved]
|
||||||
|
private BarHitErrorMeter barHitErrorMeter { get; set; } = null!;
|
||||||
|
|
||||||
public JudgementLine()
|
public JudgementLine()
|
||||||
{
|
{
|
||||||
RelativeSizeAxes = Axes.X;
|
RelativeSizeAxes = Axes.X;
|
||||||
@ -439,16 +447,22 @@ namespace osu.Game.Screens.Play.HUD.HitErrorMeters
|
|||||||
|
|
||||||
protected override void LoadComplete()
|
protected override void LoadComplete()
|
||||||
{
|
{
|
||||||
|
base.LoadComplete();
|
||||||
|
|
||||||
|
JudgementLineThickness.BindTo(barHitErrorMeter.JudgementLineThickness);
|
||||||
|
JudgementLineThickness.BindValueChanged(thickness => Height = thickness.NewValue, true);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected override void PrepareForUse()
|
||||||
|
{
|
||||||
|
base.PrepareForUse();
|
||||||
|
|
||||||
const int judgement_fade_in_duration = 100;
|
const int judgement_fade_in_duration = 100;
|
||||||
const int judgement_fade_out_duration = 5000;
|
const int judgement_fade_out_duration = 5000;
|
||||||
|
|
||||||
base.LoadComplete();
|
|
||||||
|
|
||||||
Alpha = 0;
|
Alpha = 0;
|
||||||
Width = 0;
|
Width = 0;
|
||||||
|
|
||||||
JudgementLineThickness.BindValueChanged(thickness => Height = thickness.NewValue, true);
|
|
||||||
|
|
||||||
this
|
this
|
||||||
.FadeTo(0.6f, judgement_fade_in_duration, Easing.OutQuint)
|
.FadeTo(0.6f, judgement_fade_in_duration, Easing.OutQuint)
|
||||||
.ResizeWidthTo(1, judgement_fade_in_duration, Easing.OutQuint)
|
.ResizeWidthTo(1, judgement_fade_in_duration, Easing.OutQuint)
|
||||||
|
@ -3,9 +3,11 @@
|
|||||||
|
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
|
using osu.Framework.Allocation;
|
||||||
using osu.Framework.Bindables;
|
using osu.Framework.Bindables;
|
||||||
using osu.Framework.Graphics;
|
using osu.Framework.Graphics;
|
||||||
using osu.Framework.Graphics.Containers;
|
using osu.Framework.Graphics.Containers;
|
||||||
|
using osu.Framework.Graphics.Pooling;
|
||||||
using osu.Framework.Graphics.Shapes;
|
using osu.Framework.Graphics.Shapes;
|
||||||
using osu.Game.Configuration;
|
using osu.Game.Configuration;
|
||||||
using osu.Game.Rulesets.Judgements;
|
using osu.Game.Rulesets.Judgements;
|
||||||
@ -15,6 +17,7 @@ using osuTK.Graphics;
|
|||||||
|
|
||||||
namespace osu.Game.Screens.Play.HUD.HitErrorMeters
|
namespace osu.Game.Screens.Play.HUD.HitErrorMeters
|
||||||
{
|
{
|
||||||
|
[Cached]
|
||||||
public class ColourHitErrorMeter : HitErrorMeter
|
public class ColourHitErrorMeter : HitErrorMeter
|
||||||
{
|
{
|
||||||
private const int animation_duration = 200;
|
private const int animation_duration = 200;
|
||||||
@ -82,7 +85,7 @@ namespace osu.Game.Screens.Play.HUD.HitErrorMeters
|
|||||||
{
|
{
|
||||||
base.LoadComplete();
|
base.LoadComplete();
|
||||||
|
|
||||||
JudgementCount.BindValueChanged(count =>
|
JudgementCount.BindValueChanged(_ =>
|
||||||
{
|
{
|
||||||
removeExtraJudgements();
|
removeExtraJudgements();
|
||||||
updateMetrics();
|
updateMetrics();
|
||||||
@ -91,14 +94,17 @@ namespace osu.Game.Screens.Play.HUD.HitErrorMeters
|
|||||||
JudgementSpacing.BindValueChanged(_ => updateMetrics(), true);
|
JudgementSpacing.BindValueChanged(_ => updateMetrics(), true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private readonly DrawablePool<HitErrorShape> judgementLinePool = new DrawablePool<HitErrorShape>(50);
|
||||||
|
|
||||||
public void Push(Color4 colour)
|
public void Push(Color4 colour)
|
||||||
{
|
{
|
||||||
Add(new HitErrorShape(colour, drawable_judgement_size)
|
judgementLinePool.Get(shape =>
|
||||||
{
|
{
|
||||||
Shape = { BindTarget = JudgementShape },
|
shape.Colour = colour;
|
||||||
});
|
Add(shape);
|
||||||
|
|
||||||
removeExtraJudgements();
|
removeExtraJudgements();
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
private void removeExtraJudgements()
|
private void removeExtraJudgements()
|
||||||
@ -116,32 +122,32 @@ namespace osu.Game.Screens.Play.HUD.HitErrorMeters
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public class HitErrorShape : Container
|
public class HitErrorShape : PoolableDrawable
|
||||||
{
|
{
|
||||||
public bool IsRemoved { get; private set; }
|
public bool IsRemoved { get; private set; }
|
||||||
|
|
||||||
public readonly Bindable<ShapeStyle> Shape = new Bindable<ShapeStyle>();
|
public readonly Bindable<ShapeStyle> Shape = new Bindable<ShapeStyle>();
|
||||||
|
|
||||||
private readonly Color4 colour;
|
[Resolved]
|
||||||
|
private ColourHitErrorMeter hitErrorMeter { get; set; } = null!;
|
||||||
|
|
||||||
private Container content = null!;
|
private Container content = null!;
|
||||||
|
|
||||||
public HitErrorShape(Color4 colour, int size)
|
public HitErrorShape()
|
||||||
{
|
{
|
||||||
this.colour = colour;
|
Size = new Vector2(drawable_judgement_size);
|
||||||
Size = new Vector2(size);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override void LoadComplete()
|
protected override void LoadComplete()
|
||||||
{
|
{
|
||||||
base.LoadComplete();
|
base.LoadComplete();
|
||||||
|
|
||||||
Child = content = new Container
|
InternalChild = content = new Container
|
||||||
{
|
{
|
||||||
RelativeSizeAxes = Axes.Both,
|
RelativeSizeAxes = Axes.Both,
|
||||||
Colour = colour
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Shape.BindTo(hitErrorMeter.JudgementShape);
|
||||||
Shape.BindValueChanged(shape =>
|
Shape.BindValueChanged(shape =>
|
||||||
{
|
{
|
||||||
switch (shape.NewValue)
|
switch (shape.NewValue)
|
||||||
@ -155,17 +161,32 @@ namespace osu.Game.Screens.Play.HUD.HitErrorMeters
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}, true);
|
}, true);
|
||||||
|
}
|
||||||
|
|
||||||
content.FadeInFromZero(animation_duration, Easing.OutQuint);
|
protected override void PrepareForUse()
|
||||||
content.MoveToY(-DrawSize.Y);
|
{
|
||||||
content.MoveToY(0, animation_duration, Easing.OutQuint);
|
base.PrepareForUse();
|
||||||
|
|
||||||
|
this.FadeInFromZero(animation_duration, Easing.OutQuint)
|
||||||
|
// On pool re-use, start flow animation from (0,0).
|
||||||
|
.MoveTo(Vector2.Zero);
|
||||||
|
|
||||||
|
content.MoveToY(-DrawSize.Y)
|
||||||
|
.MoveToY(0, animation_duration, Easing.OutQuint);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected override void FreeAfterUse()
|
||||||
|
{
|
||||||
|
base.FreeAfterUse();
|
||||||
|
IsRemoved = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Remove()
|
public void Remove()
|
||||||
{
|
{
|
||||||
IsRemoved = true;
|
IsRemoved = true;
|
||||||
|
|
||||||
this.FadeOut(animation_duration, Easing.OutQuint).Expire();
|
this.FadeOut(animation_duration, Easing.OutQuint)
|
||||||
|
.Expire();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user