mirror of
https://github.com/ppy/osu.git
synced 2025-01-14 19:22:56 +08:00
Merge branch 'master' of https://github.com/ppy/osu into trail-density
This commit is contained in:
commit
676f58c3bf
@ -164,7 +164,7 @@ namespace osu.Game.Rulesets.Osu.Tests
|
|||||||
{
|
{
|
||||||
var slider = new Slider
|
var slider = new Slider
|
||||||
{
|
{
|
||||||
StartTime = Time.Current + 1000,
|
StartTime = Time.Current + time_offset,
|
||||||
Position = new Vector2(239, 176),
|
Position = new Vector2(239, 176),
|
||||||
Path = new SliderPath(PathType.PerfectCurve, new[]
|
Path = new SliderPath(PathType.PerfectCurve, new[]
|
||||||
{
|
{
|
||||||
@ -185,22 +185,26 @@ namespace osu.Game.Rulesets.Osu.Tests
|
|||||||
|
|
||||||
private Drawable testSlowSpeed() => createSlider(speedMultiplier: 0.5);
|
private Drawable testSlowSpeed() => createSlider(speedMultiplier: 0.5);
|
||||||
|
|
||||||
private Drawable testShortSlowSpeed(int repeats = 0) => createSlider(distance: 100, repeats: repeats, speedMultiplier: 0.5);
|
private Drawable testShortSlowSpeed(int repeats = 0) => createSlider(distance: max_length / 4, repeats: repeats, speedMultiplier: 0.5);
|
||||||
|
|
||||||
private Drawable testHighSpeed(int repeats = 0) => createSlider(repeats: repeats, speedMultiplier: 15);
|
private Drawable testHighSpeed(int repeats = 0) => createSlider(repeats: repeats, speedMultiplier: 15);
|
||||||
|
|
||||||
private Drawable testShortHighSpeed(int repeats = 0) => createSlider(distance: 100, repeats: repeats, speedMultiplier: 15);
|
private Drawable testShortHighSpeed(int repeats = 0) => createSlider(distance: max_length / 4, repeats: repeats, speedMultiplier: 15);
|
||||||
|
|
||||||
private Drawable createSlider(float circleSize = 2, float distance = 400, int repeats = 0, double speedMultiplier = 2, int stackHeight = 0)
|
private const double time_offset = 1500;
|
||||||
|
|
||||||
|
private const float max_length = 200;
|
||||||
|
|
||||||
|
private Drawable createSlider(float circleSize = 2, float distance = max_length, int repeats = 0, double speedMultiplier = 2, int stackHeight = 0)
|
||||||
{
|
{
|
||||||
var slider = new Slider
|
var slider = new Slider
|
||||||
{
|
{
|
||||||
StartTime = Time.Current + 1000,
|
StartTime = Time.Current + time_offset,
|
||||||
Position = new Vector2(-(distance / 2), 0),
|
Position = new Vector2(0, -(distance / 2)),
|
||||||
Path = new SliderPath(PathType.PerfectCurve, new[]
|
Path = new SliderPath(PathType.PerfectCurve, new[]
|
||||||
{
|
{
|
||||||
Vector2.Zero,
|
Vector2.Zero,
|
||||||
new Vector2(distance, 0),
|
new Vector2(0, distance),
|
||||||
}, distance),
|
}, distance),
|
||||||
RepeatCount = repeats,
|
RepeatCount = repeats,
|
||||||
StackHeight = stackHeight
|
StackHeight = stackHeight
|
||||||
@ -213,14 +217,14 @@ namespace osu.Game.Rulesets.Osu.Tests
|
|||||||
{
|
{
|
||||||
var slider = new Slider
|
var slider = new Slider
|
||||||
{
|
{
|
||||||
StartTime = Time.Current + 1000,
|
StartTime = Time.Current + time_offset,
|
||||||
Position = new Vector2(-200, 0),
|
Position = new Vector2(-max_length / 2, 0),
|
||||||
Path = new SliderPath(PathType.PerfectCurve, new[]
|
Path = new SliderPath(PathType.PerfectCurve, new[]
|
||||||
{
|
{
|
||||||
Vector2.Zero,
|
Vector2.Zero,
|
||||||
new Vector2(200, 200),
|
new Vector2(max_length / 2, max_length / 2),
|
||||||
new Vector2(400, 0)
|
new Vector2(max_length, 0)
|
||||||
}, 600),
|
}, max_length * 1.5f),
|
||||||
RepeatCount = repeats,
|
RepeatCount = repeats,
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -233,16 +237,16 @@ namespace osu.Game.Rulesets.Osu.Tests
|
|||||||
{
|
{
|
||||||
var slider = new Slider
|
var slider = new Slider
|
||||||
{
|
{
|
||||||
StartTime = Time.Current + 1000,
|
StartTime = Time.Current + time_offset,
|
||||||
Position = new Vector2(-200, 0),
|
Position = new Vector2(-max_length / 2, 0),
|
||||||
Path = new SliderPath(PathType.Linear, new[]
|
Path = new SliderPath(PathType.Linear, new[]
|
||||||
{
|
{
|
||||||
Vector2.Zero,
|
Vector2.Zero,
|
||||||
new Vector2(150, 75),
|
new Vector2(max_length * 0.375f, max_length * 0.18f),
|
||||||
new Vector2(200, 0),
|
new Vector2(max_length / 2, 0),
|
||||||
new Vector2(300, -200),
|
new Vector2(max_length * 0.75f, -max_length / 2),
|
||||||
new Vector2(400, 0),
|
new Vector2(max_length * 0.95f, 0),
|
||||||
new Vector2(430, 0)
|
new Vector2(max_length, 0)
|
||||||
}),
|
}),
|
||||||
RepeatCount = repeats,
|
RepeatCount = repeats,
|
||||||
};
|
};
|
||||||
@ -256,15 +260,15 @@ namespace osu.Game.Rulesets.Osu.Tests
|
|||||||
{
|
{
|
||||||
var slider = new Slider
|
var slider = new Slider
|
||||||
{
|
{
|
||||||
StartTime = Time.Current + 1000,
|
StartTime = Time.Current + time_offset,
|
||||||
Position = new Vector2(-200, 0),
|
Position = new Vector2(-max_length / 2, 0),
|
||||||
Path = new SliderPath(PathType.Bezier, new[]
|
Path = new SliderPath(PathType.Bezier, new[]
|
||||||
{
|
{
|
||||||
Vector2.Zero,
|
Vector2.Zero,
|
||||||
new Vector2(150, 75),
|
new Vector2(max_length * 0.375f, max_length * 0.18f),
|
||||||
new Vector2(200, 100),
|
new Vector2(max_length / 2, max_length / 4),
|
||||||
new Vector2(300, -200),
|
new Vector2(max_length * 0.75f, -max_length / 2),
|
||||||
new Vector2(430, 0)
|
new Vector2(max_length, 0)
|
||||||
}),
|
}),
|
||||||
RepeatCount = repeats,
|
RepeatCount = repeats,
|
||||||
};
|
};
|
||||||
@ -278,16 +282,16 @@ namespace osu.Game.Rulesets.Osu.Tests
|
|||||||
{
|
{
|
||||||
var slider = new Slider
|
var slider = new Slider
|
||||||
{
|
{
|
||||||
StartTime = Time.Current + 1000,
|
StartTime = Time.Current + time_offset,
|
||||||
Position = new Vector2(0, 0),
|
Position = new Vector2(0, 0),
|
||||||
Path = new SliderPath(PathType.Linear, new[]
|
Path = new SliderPath(PathType.Linear, new[]
|
||||||
{
|
{
|
||||||
Vector2.Zero,
|
Vector2.Zero,
|
||||||
new Vector2(-200, 0),
|
new Vector2(-max_length / 2, 0),
|
||||||
new Vector2(0, 0),
|
new Vector2(0, 0),
|
||||||
new Vector2(0, -200),
|
new Vector2(0, -max_length / 2),
|
||||||
new Vector2(-200, -200),
|
new Vector2(-max_length / 2, -max_length / 2),
|
||||||
new Vector2(0, -200)
|
new Vector2(0, -max_length / 2)
|
||||||
}),
|
}),
|
||||||
RepeatCount = repeats,
|
RepeatCount = repeats,
|
||||||
};
|
};
|
||||||
@ -305,14 +309,14 @@ namespace osu.Game.Rulesets.Osu.Tests
|
|||||||
|
|
||||||
var slider = new Slider
|
var slider = new Slider
|
||||||
{
|
{
|
||||||
StartTime = Time.Current + 1000,
|
StartTime = Time.Current + time_offset,
|
||||||
Position = new Vector2(-100, 0),
|
Position = new Vector2(-max_length / 4, 0),
|
||||||
Path = new SliderPath(PathType.Catmull, new[]
|
Path = new SliderPath(PathType.Catmull, new[]
|
||||||
{
|
{
|
||||||
Vector2.Zero,
|
Vector2.Zero,
|
||||||
new Vector2(50, -50),
|
new Vector2(max_length * 0.125f, max_length * 0.125f),
|
||||||
new Vector2(150, 50),
|
new Vector2(max_length * 0.375f, max_length * 0.125f),
|
||||||
new Vector2(200, 0)
|
new Vector2(max_length / 2, 0)
|
||||||
}),
|
}),
|
||||||
RepeatCount = repeats,
|
RepeatCount = repeats,
|
||||||
NodeSamples = repeatSamples
|
NodeSamples = repeatSamples
|
||||||
|
@ -6,6 +6,7 @@ using osu.Framework.Graphics;
|
|||||||
using osu.Framework.Graphics.Containers;
|
using osu.Framework.Graphics.Containers;
|
||||||
using osu.Framework.Graphics.Sprites;
|
using osu.Framework.Graphics.Sprites;
|
||||||
using osu.Framework.Graphics.Textures;
|
using osu.Framework.Graphics.Textures;
|
||||||
|
using osu.Game.Rulesets.Objects.Drawables;
|
||||||
using osuTK;
|
using osuTK;
|
||||||
|
|
||||||
namespace osu.Game.Rulesets.Osu.Objects.Drawables.Pieces
|
namespace osu.Game.Rulesets.Osu.Objects.Drawables.Pieces
|
||||||
@ -25,7 +26,7 @@ namespace osu.Game.Rulesets.Osu.Objects.Drawables.Pieces
|
|||||||
}
|
}
|
||||||
|
|
||||||
[BackgroundDependencyLoader]
|
[BackgroundDependencyLoader]
|
||||||
private void load(TextureStore textures)
|
private void load(TextureStore textures, DrawableHitObject drawableHitObject)
|
||||||
{
|
{
|
||||||
InternalChildren = new Drawable[]
|
InternalChildren = new Drawable[]
|
||||||
{
|
{
|
||||||
@ -35,7 +36,7 @@ namespace osu.Game.Rulesets.Osu.Objects.Drawables.Pieces
|
|||||||
Origin = Anchor.Centre,
|
Origin = Anchor.Centre,
|
||||||
Texture = textures.Get(@"Gameplay/osu/disc"),
|
Texture = textures.Get(@"Gameplay/osu/disc"),
|
||||||
},
|
},
|
||||||
new TrianglesPiece
|
new TrianglesPiece((int)drawableHitObject.HitObject.StartTime)
|
||||||
{
|
{
|
||||||
RelativeSizeAxes = Axes.Both,
|
RelativeSizeAxes = Axes.Both,
|
||||||
Blending = BlendingParameters.Additive,
|
Blending = BlendingParameters.Additive,
|
||||||
|
@ -20,6 +20,7 @@ namespace osu.Game.Rulesets.Osu.Objects.Drawables.Pieces
|
|||||||
|
|
||||||
private Spinner spinner;
|
private Spinner spinner;
|
||||||
|
|
||||||
|
private const float initial_scale = 1.3f;
|
||||||
private const float idle_alpha = 0.2f;
|
private const float idle_alpha = 0.2f;
|
||||||
private const float tracking_alpha = 0.4f;
|
private const float tracking_alpha = 0.4f;
|
||||||
|
|
||||||
@ -41,7 +42,7 @@ namespace osu.Game.Rulesets.Osu.Objects.Drawables.Pieces
|
|||||||
|
|
||||||
// we are slightly bigger than our parent, to clip the top and bottom of the circle
|
// we are slightly bigger than our parent, to clip the top and bottom of the circle
|
||||||
// this should probably be revisited when scaled spinners are a thing.
|
// this should probably be revisited when scaled spinners are a thing.
|
||||||
Scale = new Vector2(1.3f);
|
Scale = new Vector2(initial_scale);
|
||||||
|
|
||||||
Anchor = Anchor.Centre;
|
Anchor = Anchor.Centre;
|
||||||
Origin = Anchor.Centre;
|
Origin = Anchor.Centre;
|
||||||
@ -117,8 +118,8 @@ namespace osu.Game.Rulesets.Osu.Objects.Drawables.Pieces
|
|||||||
fill.Alpha = (float)Interpolation.Damp(fill.Alpha, drawableSpinner.RotationTracker.Tracking ? tracking_alpha : idle_alpha, 0.98f, (float)Math.Abs(Clock.ElapsedFrameTime));
|
fill.Alpha = (float)Interpolation.Damp(fill.Alpha, drawableSpinner.RotationTracker.Tracking ? tracking_alpha : idle_alpha, 0.98f, (float)Math.Abs(Clock.ElapsedFrameTime));
|
||||||
}
|
}
|
||||||
|
|
||||||
const float initial_scale = 0.2f;
|
const float initial_fill_scale = 0.2f;
|
||||||
float targetScale = initial_scale + (1 - initial_scale) * drawableSpinner.Progress;
|
float targetScale = initial_fill_scale + (1 - initial_fill_scale) * drawableSpinner.Progress;
|
||||||
|
|
||||||
fill.Scale = new Vector2((float)Interpolation.Lerp(fill.Scale.X, targetScale, Math.Clamp(Math.Abs(Time.Elapsed) / 100, 0, 1)));
|
fill.Scale = new Vector2((float)Interpolation.Lerp(fill.Scale.X, targetScale, Math.Clamp(Math.Abs(Time.Elapsed) / 100, 0, 1)));
|
||||||
mainContainer.Rotation = drawableSpinner.RotationTracker.Rotation;
|
mainContainer.Rotation = drawableSpinner.RotationTracker.Rotation;
|
||||||
@ -129,41 +130,54 @@ namespace osu.Game.Rulesets.Osu.Objects.Drawables.Pieces
|
|||||||
if (!(drawableHitObject is DrawableSpinner))
|
if (!(drawableHitObject is DrawableSpinner))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
centre.ScaleTo(0);
|
using (BeginAbsoluteSequence(spinner.StartTime - spinner.TimePreempt, true))
|
||||||
mainContainer.ScaleTo(0);
|
|
||||||
|
|
||||||
using (BeginAbsoluteSequence(spinner.StartTime - spinner.TimePreempt / 2, true))
|
|
||||||
{
|
{
|
||||||
// constant ambient rotation to give the spinner "spinning" character.
|
this.ScaleTo(initial_scale);
|
||||||
this.RotateTo((float)(25 * spinner.Duration / 2000), spinner.TimePreempt + spinner.Duration);
|
this.RotateTo(0);
|
||||||
|
|
||||||
centre.ScaleTo(0.3f, spinner.TimePreempt / 4, Easing.OutQuint);
|
|
||||||
mainContainer.ScaleTo(0.2f, spinner.TimePreempt / 4, Easing.OutQuint);
|
|
||||||
|
|
||||||
using (BeginDelayedSequence(spinner.TimePreempt / 2, true))
|
using (BeginDelayedSequence(spinner.TimePreempt / 2, true))
|
||||||
{
|
{
|
||||||
centre.ScaleTo(0.5f, spinner.TimePreempt / 2, Easing.OutQuint);
|
// constant ambient rotation to give the spinner "spinning" character.
|
||||||
mainContainer.ScaleTo(1, spinner.TimePreempt / 2, Easing.OutQuint);
|
this.RotateTo((float)(25 * spinner.Duration / 2000), spinner.TimePreempt + spinner.Duration);
|
||||||
|
}
|
||||||
|
|
||||||
|
using (BeginDelayedSequence(spinner.TimePreempt + spinner.Duration + drawableHitObject.Result.TimeOffset, true))
|
||||||
|
{
|
||||||
|
switch (state)
|
||||||
|
{
|
||||||
|
case ArmedState.Hit:
|
||||||
|
this.ScaleTo(initial_scale * 1.2f, 320, Easing.Out);
|
||||||
|
this.RotateTo(mainContainer.Rotation + 180, 320);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case ArmedState.Miss:
|
||||||
|
this.ScaleTo(initial_scale * 0.8f, 320, Easing.In);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
using (BeginAbsoluteSequence(spinner.StartTime - spinner.TimePreempt, true))
|
||||||
|
{
|
||||||
|
centre.ScaleTo(0);
|
||||||
|
mainContainer.ScaleTo(0);
|
||||||
|
|
||||||
|
using (BeginDelayedSequence(spinner.TimePreempt / 2, true))
|
||||||
|
{
|
||||||
|
centre.ScaleTo(0.3f, spinner.TimePreempt / 4, Easing.OutQuint);
|
||||||
|
mainContainer.ScaleTo(0.2f, spinner.TimePreempt / 4, Easing.OutQuint);
|
||||||
|
|
||||||
|
using (BeginDelayedSequence(spinner.TimePreempt / 2, true))
|
||||||
|
{
|
||||||
|
centre.ScaleTo(0.5f, spinner.TimePreempt / 2, Easing.OutQuint);
|
||||||
|
mainContainer.ScaleTo(1, spinner.TimePreempt / 2, Easing.OutQuint);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// transforms we have from completing the spinner will be rolled back, so reapply immediately.
|
// transforms we have from completing the spinner will be rolled back, so reapply immediately.
|
||||||
updateComplete(state == ArmedState.Hit, 0);
|
using (BeginAbsoluteSequence(spinner.StartTime - spinner.TimePreempt, true))
|
||||||
|
updateComplete(state == ArmedState.Hit, 0);
|
||||||
using (BeginDelayedSequence(spinner.Duration, true))
|
|
||||||
{
|
|
||||||
switch (state)
|
|
||||||
{
|
|
||||||
case ArmedState.Hit:
|
|
||||||
this.ScaleTo(Scale * 1.2f, 320, Easing.Out);
|
|
||||||
this.RotateTo(mainContainer.Rotation + 180, 320);
|
|
||||||
break;
|
|
||||||
|
|
||||||
case ArmedState.Miss:
|
|
||||||
this.ScaleTo(Scale * 0.8f, 320, Easing.In);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void updateComplete(bool complete, double duration)
|
private void updateComplete(bool complete, double duration)
|
||||||
|
@ -11,7 +11,8 @@ namespace osu.Game.Rulesets.Osu.Objects.Drawables.Pieces
|
|||||||
protected override bool CreateNewTriangles => false;
|
protected override bool CreateNewTriangles => false;
|
||||||
protected override float SpawnRatio => 0.5f;
|
protected override float SpawnRatio => 0.5f;
|
||||||
|
|
||||||
public TrianglesPiece()
|
public TrianglesPiece(int? seed = null)
|
||||||
|
: base(seed)
|
||||||
{
|
{
|
||||||
TriangleScale = 1.2f;
|
TriangleScale = 1.2f;
|
||||||
HideAlphaDiscrepancies = false;
|
HideAlphaDiscrepancies = false;
|
||||||
|
@ -70,9 +70,7 @@ namespace osu.Game.Rulesets.Osu.Skinning
|
|||||||
{
|
{
|
||||||
base.LoadComplete();
|
base.LoadComplete();
|
||||||
|
|
||||||
this.FadeOut();
|
|
||||||
drawableSpinner.ApplyCustomUpdateState += updateStateTransforms;
|
drawableSpinner.ApplyCustomUpdateState += updateStateTransforms;
|
||||||
|
|
||||||
updateStateTransforms(drawableSpinner, drawableSpinner.State.Value);
|
updateStateTransforms(drawableSpinner, drawableSpinner.State.Value);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -83,12 +81,19 @@ namespace osu.Game.Rulesets.Osu.Skinning
|
|||||||
|
|
||||||
var spinner = (Spinner)drawableSpinner.HitObject;
|
var spinner = (Spinner)drawableSpinner.HitObject;
|
||||||
|
|
||||||
|
using (BeginAbsoluteSequence(spinner.StartTime - spinner.TimePreempt, true))
|
||||||
|
this.FadeOut();
|
||||||
|
|
||||||
using (BeginAbsoluteSequence(spinner.StartTime - spinner.TimeFadeIn / 2, true))
|
using (BeginAbsoluteSequence(spinner.StartTime - spinner.TimeFadeIn / 2, true))
|
||||||
this.FadeInFromZero(spinner.TimeFadeIn / 2);
|
this.FadeInFromZero(spinner.TimeFadeIn / 2);
|
||||||
|
|
||||||
fixedMiddle.FadeColour(Color4.White);
|
using (BeginAbsoluteSequence(spinner.StartTime - spinner.TimePreempt, true))
|
||||||
using (BeginAbsoluteSequence(spinner.StartTime, true))
|
{
|
||||||
fixedMiddle.FadeColour(Color4.Red, spinner.Duration);
|
fixedMiddle.FadeColour(Color4.White);
|
||||||
|
|
||||||
|
using (BeginDelayedSequence(spinner.TimePreempt, true))
|
||||||
|
fixedMiddle.FadeColour(Color4.Red, spinner.Duration);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override void Update()
|
protected override void Update()
|
||||||
|
@ -88,9 +88,7 @@ namespace osu.Game.Rulesets.Osu.Skinning
|
|||||||
{
|
{
|
||||||
base.LoadComplete();
|
base.LoadComplete();
|
||||||
|
|
||||||
this.FadeOut();
|
|
||||||
drawableSpinner.ApplyCustomUpdateState += updateStateTransforms;
|
drawableSpinner.ApplyCustomUpdateState += updateStateTransforms;
|
||||||
|
|
||||||
updateStateTransforms(drawableSpinner, drawableSpinner.State.Value);
|
updateStateTransforms(drawableSpinner, drawableSpinner.State.Value);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -101,6 +99,9 @@ namespace osu.Game.Rulesets.Osu.Skinning
|
|||||||
|
|
||||||
var spinner = drawableSpinner.HitObject;
|
var spinner = drawableSpinner.HitObject;
|
||||||
|
|
||||||
|
using (BeginAbsoluteSequence(spinner.StartTime - spinner.TimePreempt, true))
|
||||||
|
this.FadeOut();
|
||||||
|
|
||||||
using (BeginAbsoluteSequence(spinner.StartTime - spinner.TimeFadeIn / 2, true))
|
using (BeginAbsoluteSequence(spinner.StartTime - spinner.TimeFadeIn / 2, true))
|
||||||
this.FadeInFromZero(spinner.TimeFadeIn / 2);
|
this.FadeInFromZero(spinner.TimeFadeIn / 2);
|
||||||
}
|
}
|
||||||
|
@ -139,6 +139,22 @@ namespace osu.Game.Tests.NonVisual
|
|||||||
Assert.That(cpi.Groups.Count, Is.EqualTo(0));
|
Assert.That(cpi.Groups.Count, Is.EqualTo(0));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void TestRemoveGroupAlsoRemovedControlPoints()
|
||||||
|
{
|
||||||
|
var cpi = new ControlPointInfo();
|
||||||
|
|
||||||
|
var group = cpi.GroupAt(1000, true);
|
||||||
|
|
||||||
|
group.Add(new SampleControlPoint());
|
||||||
|
|
||||||
|
Assert.That(cpi.SamplePoints.Count, Is.EqualTo(1));
|
||||||
|
|
||||||
|
cpi.RemoveGroup(group);
|
||||||
|
|
||||||
|
Assert.That(cpi.SamplePoints.Count, Is.EqualTo(0));
|
||||||
|
}
|
||||||
|
|
||||||
[Test]
|
[Test]
|
||||||
public void TestAddControlPointToGroup()
|
public void TestAddControlPointToGroup()
|
||||||
{
|
{
|
||||||
|
@ -158,6 +158,9 @@ namespace osu.Game.Beatmaps.ControlPoints
|
|||||||
|
|
||||||
public void RemoveGroup(ControlPointGroup group)
|
public void RemoveGroup(ControlPointGroup group)
|
||||||
{
|
{
|
||||||
|
foreach (var item in group.ControlPoints.ToArray())
|
||||||
|
group.Remove(item);
|
||||||
|
|
||||||
group.ItemAdded -= groupItemAdded;
|
group.ItemAdded -= groupItemAdded;
|
||||||
group.ItemRemoved -= groupItemRemoved;
|
group.ItemRemoved -= groupItemRemoved;
|
||||||
|
|
||||||
|
@ -86,13 +86,24 @@ namespace osu.Game.Graphics.Backgrounds
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public float Velocity = 1;
|
public float Velocity = 1;
|
||||||
|
|
||||||
|
private readonly Random stableRandom;
|
||||||
|
|
||||||
|
private float nextRandom() => (float)(stableRandom?.NextDouble() ?? RNG.NextSingle());
|
||||||
|
|
||||||
private readonly SortedList<TriangleParticle> parts = new SortedList<TriangleParticle>(Comparer<TriangleParticle>.Default);
|
private readonly SortedList<TriangleParticle> parts = new SortedList<TriangleParticle>(Comparer<TriangleParticle>.Default);
|
||||||
|
|
||||||
private IShader shader;
|
private IShader shader;
|
||||||
private readonly Texture texture;
|
private readonly Texture texture;
|
||||||
|
|
||||||
public Triangles()
|
/// <summary>
|
||||||
|
/// Construct a new triangle visualisation.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="seed">An optional seed to stabilise random positions / attributes. Note that this does not guarantee stable playback when seeking in time.</param>
|
||||||
|
public Triangles(int? seed = null)
|
||||||
{
|
{
|
||||||
|
if (seed != null)
|
||||||
|
stableRandom = new Random(seed.Value);
|
||||||
|
|
||||||
texture = Texture.WhitePixel;
|
texture = Texture.WhitePixel;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -175,8 +186,8 @@ namespace osu.Game.Graphics.Backgrounds
|
|||||||
{
|
{
|
||||||
TriangleParticle particle = CreateTriangle();
|
TriangleParticle particle = CreateTriangle();
|
||||||
|
|
||||||
particle.Position = new Vector2(RNG.NextSingle(), randomY ? RNG.NextSingle() : 1);
|
particle.Position = new Vector2(nextRandom(), randomY ? nextRandom() : 1);
|
||||||
particle.ColourShade = RNG.NextSingle();
|
particle.ColourShade = nextRandom();
|
||||||
particle.Colour = CreateTriangleShade(particle.ColourShade);
|
particle.Colour = CreateTriangleShade(particle.ColourShade);
|
||||||
|
|
||||||
return particle;
|
return particle;
|
||||||
@ -191,8 +202,8 @@ namespace osu.Game.Graphics.Backgrounds
|
|||||||
const float std_dev = 0.16f;
|
const float std_dev = 0.16f;
|
||||||
const float mean = 0.5f;
|
const float mean = 0.5f;
|
||||||
|
|
||||||
float u1 = 1 - RNG.NextSingle(); //uniform(0,1] random floats
|
float u1 = 1 - nextRandom(); //uniform(0,1] random floats
|
||||||
float u2 = 1 - RNG.NextSingle();
|
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)
|
||||||
var scale = Math.Max(triangleScale * (mean + std_dev * randStdNormal), 0.1f); // random normal(mean,stdDev^2)
|
var scale = Math.Max(triangleScale * (mean + std_dev * randStdNormal), 0.1f); // random normal(mean,stdDev^2)
|
||||||
|
|
||||||
|
@ -41,6 +41,7 @@ namespace osu.Game.Screens.Edit.Timing
|
|||||||
|
|
||||||
private IReadOnlyList<Drawable> createSections() => new Drawable[]
|
private IReadOnlyList<Drawable> createSections() => new Drawable[]
|
||||||
{
|
{
|
||||||
|
new GroupSection(),
|
||||||
new TimingSection(),
|
new TimingSection(),
|
||||||
new DifficultySection(),
|
new DifficultySection(),
|
||||||
new SampleSection(),
|
new SampleSection(),
|
||||||
|
113
osu.Game/Screens/Edit/Timing/GroupSection.cs
Normal file
113
osu.Game/Screens/Edit/Timing/GroupSection.cs
Normal file
@ -0,0 +1,113 @@
|
|||||||
|
// 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.
|
||||||
|
|
||||||
|
using System.Linq;
|
||||||
|
using osu.Framework.Allocation;
|
||||||
|
using osu.Framework.Bindables;
|
||||||
|
using osu.Framework.Graphics;
|
||||||
|
using osu.Framework.Graphics.Containers;
|
||||||
|
using osu.Game.Beatmaps;
|
||||||
|
using osu.Game.Beatmaps.ControlPoints;
|
||||||
|
using osu.Game.Graphics.UserInterface;
|
||||||
|
using osu.Game.Graphics.UserInterfaceV2;
|
||||||
|
using osuTK;
|
||||||
|
|
||||||
|
namespace osu.Game.Screens.Edit.Timing
|
||||||
|
{
|
||||||
|
internal class GroupSection : CompositeDrawable
|
||||||
|
{
|
||||||
|
private LabelledTextBox textBox;
|
||||||
|
|
||||||
|
[Resolved]
|
||||||
|
protected Bindable<ControlPointGroup> SelectedGroup { get; private set; }
|
||||||
|
|
||||||
|
[Resolved]
|
||||||
|
protected IBindable<WorkingBeatmap> Beatmap { get; private set; }
|
||||||
|
|
||||||
|
[Resolved]
|
||||||
|
private EditorClock clock { get; set; }
|
||||||
|
|
||||||
|
[Resolved(canBeNull: true)]
|
||||||
|
private IEditorChangeHandler changeHandler { get; set; }
|
||||||
|
|
||||||
|
[BackgroundDependencyLoader]
|
||||||
|
private void load()
|
||||||
|
{
|
||||||
|
RelativeSizeAxes = Axes.X;
|
||||||
|
AutoSizeAxes = Axes.Y;
|
||||||
|
|
||||||
|
Padding = new MarginPadding(10);
|
||||||
|
|
||||||
|
InternalChildren = new Drawable[]
|
||||||
|
{
|
||||||
|
new FillFlowContainer
|
||||||
|
{
|
||||||
|
RelativeSizeAxes = Axes.X,
|
||||||
|
AutoSizeAxes = Axes.Y,
|
||||||
|
Spacing = new Vector2(10),
|
||||||
|
Direction = FillDirection.Vertical,
|
||||||
|
Children = new Drawable[]
|
||||||
|
{
|
||||||
|
textBox = new LabelledTextBox
|
||||||
|
{
|
||||||
|
Label = "Time"
|
||||||
|
},
|
||||||
|
new TriangleButton
|
||||||
|
{
|
||||||
|
Text = "Use current time",
|
||||||
|
RelativeSizeAxes = Axes.X,
|
||||||
|
Action = () => changeSelectedGroupTime(clock.CurrentTime)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
};
|
||||||
|
|
||||||
|
textBox.OnCommit += (sender, isNew) =>
|
||||||
|
{
|
||||||
|
if (!isNew)
|
||||||
|
return;
|
||||||
|
|
||||||
|
if (double.TryParse(sender.Text, out var newTime))
|
||||||
|
{
|
||||||
|
changeSelectedGroupTime(newTime);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
SelectedGroup.TriggerChange();
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
SelectedGroup.BindValueChanged(group =>
|
||||||
|
{
|
||||||
|
if (group.NewValue == null)
|
||||||
|
{
|
||||||
|
textBox.Text = string.Empty;
|
||||||
|
textBox.Current.Disabled = true;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
textBox.Current.Disabled = false;
|
||||||
|
textBox.Text = $"{group.NewValue.Time:n0}";
|
||||||
|
}, true);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void changeSelectedGroupTime(in double time)
|
||||||
|
{
|
||||||
|
if (time == SelectedGroup.Value.Time)
|
||||||
|
return;
|
||||||
|
|
||||||
|
changeHandler?.BeginChange();
|
||||||
|
|
||||||
|
var currentGroupItems = SelectedGroup.Value.ControlPoints.ToArray();
|
||||||
|
|
||||||
|
Beatmap.Value.Beatmap.ControlPointInfo.RemoveGroup(SelectedGroup.Value);
|
||||||
|
|
||||||
|
foreach (var cp in currentGroupItems)
|
||||||
|
Beatmap.Value.Beatmap.ControlPointInfo.Add(time, cp);
|
||||||
|
|
||||||
|
SelectedGroup.Value = Beatmap.Value.Beatmap.ControlPointInfo.GroupAt(time);
|
||||||
|
|
||||||
|
changeHandler?.EndChange();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user