1
0
mirror of https://github.com/ppy/osu.git synced 2025-03-06 03:03:05 +08:00

Merge remote-tracking branch 'refs/remotes/ppy/master' into comments-vote-pill

This commit is contained in:
Andrei Zavatski 2019-10-23 13:27:45 +03:00
commit a6d5a2024a
10 changed files with 105 additions and 34 deletions

View File

@ -2,6 +2,7 @@
// 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 System; using System;
using System.Collections.Generic;
using NUnit.Framework; using NUnit.Framework;
using osu.Framework.Allocation; using osu.Framework.Allocation;
using osu.Framework.Graphics; using osu.Framework.Graphics;
@ -14,6 +15,7 @@ using osu.Game.Rulesets.Osu.Beatmaps;
using osu.Game.Rulesets.Osu.Edit; using osu.Game.Rulesets.Osu.Edit;
using osu.Game.Rulesets.Osu.Objects; using osu.Game.Rulesets.Osu.Objects;
using osu.Game.Screens.Edit; using osu.Game.Screens.Edit;
using osu.Game.Screens.Edit.Compose.Components;
using osu.Game.Tests.Visual; using osu.Game.Tests.Visual;
using osuTK; using osuTK;
using osuTK.Graphics; using osuTK.Graphics;
@ -25,6 +27,11 @@ namespace osu.Game.Rulesets.Osu.Tests
private const double beat_length = 100; private const double beat_length = 100;
private static readonly Vector2 grid_position = new Vector2(512, 384); private static readonly Vector2 grid_position = new Vector2(512, 384);
public override IReadOnlyList<Type> RequiredTypes => new[]
{
typeof(CircularDistanceSnapGrid)
};
[Cached(typeof(IEditorBeatmap))] [Cached(typeof(IEditorBeatmap))]
private readonly EditorBeatmap<OsuHitObject> editorBeatmap; private readonly EditorBeatmap<OsuHitObject> editorBeatmap;

View File

@ -111,6 +111,21 @@ namespace osu.Game.Rulesets.Osu.Tests
AddStep("Distance Overflow 1 Repeat", () => SetContents(() => testDistanceOverflow(1))); AddStep("Distance Overflow 1 Repeat", () => SetContents(() => testDistanceOverflow(1)));
} }
[Test]
public void TestChangeStackHeight()
{
DrawableSlider slider = null;
AddStep("create slider", () =>
{
slider = (DrawableSlider)createSlider(repeats: 1);
Add(slider);
});
AddStep("change stack height", () => slider.HitObject.StackHeight = 10);
AddAssert("body positioned correctly", () => slider.Position == slider.HitObject.StackedPosition);
}
private Drawable testSimpleBig(int repeats = 0) => createSlider(2, repeats: repeats); private Drawable testSimpleBig(int repeats = 0) => createSlider(2, repeats: repeats);
private Drawable testSimpleBigLargeStackOffset(int repeats = 0) => createSlider(2, repeats: repeats, stackHeight: 10); private Drawable testSimpleBigLargeStackOffset(int repeats = 0) => createSlider(2, repeats: repeats, stackHeight: 10);

View File

@ -78,6 +78,13 @@ namespace osu.Game.Rulesets.Osu.Tests
checkPositions(); checkPositions();
} }
[Test]
public void TestStackedHitObject()
{
AddStep("set stacking", () => slider.StackHeight = 5);
checkPositions();
}
private void moveHitObject() private void moveHitObject()
{ {
AddStep("move hitobject", () => AddStep("move hitobject", () =>
@ -88,7 +95,7 @@ namespace osu.Game.Rulesets.Osu.Tests
private void checkPositions() private void checkPositions()
{ {
AddAssert("body positioned correctly", () => blueprint.BodyPiece.Position == slider.Position); AddAssert("body positioned correctly", () => blueprint.BodyPiece.Position == slider.StackedPosition);
AddAssert("head positioned correctly", AddAssert("head positioned correctly",
() => Precision.AlmostEquals(blueprint.HeadBlueprint.CirclePiece.ScreenSpaceDrawQuad.Centre, drawableObject.HeadCircle.ScreenSpaceDrawQuad.Centre)); () => Precision.AlmostEquals(blueprint.HeadBlueprint.CirclePiece.ScreenSpaceDrawQuad.Centre, drawableObject.HeadCircle.ScreenSpaceDrawQuad.Centre));

View File

@ -34,6 +34,7 @@ namespace osu.Game.Rulesets.Osu.Objects.Drawables
private readonly Slider slider; private readonly Slider slider;
private readonly IBindable<Vector2> positionBindable = new Bindable<Vector2>(); private readonly IBindable<Vector2> positionBindable = new Bindable<Vector2>();
private readonly IBindable<int> stackHeightBindable = new Bindable<int>();
private readonly IBindable<float> scaleBindable = new Bindable<float>(); private readonly IBindable<float> scaleBindable = new Bindable<float>();
private readonly IBindable<SliderPath> pathBindable = new Bindable<SliderPath>(); private readonly IBindable<SliderPath> pathBindable = new Bindable<SliderPath>();
@ -72,6 +73,7 @@ namespace osu.Game.Rulesets.Osu.Objects.Drawables
config?.BindWith(OsuRulesetSetting.SnakingOutSliders, Body.SnakingOut); config?.BindWith(OsuRulesetSetting.SnakingOutSliders, Body.SnakingOut);
positionBindable.BindValueChanged(_ => Position = HitObject.StackedPosition); positionBindable.BindValueChanged(_ => Position = HitObject.StackedPosition);
stackHeightBindable.BindValueChanged(_ => Position = HitObject.StackedPosition);
scaleBindable.BindValueChanged(scale => scaleBindable.BindValueChanged(scale =>
{ {
updatePathRadius(); updatePathRadius();
@ -79,6 +81,7 @@ namespace osu.Game.Rulesets.Osu.Objects.Drawables
}); });
positionBindable.BindTo(HitObject.PositionBindable); positionBindable.BindTo(HitObject.PositionBindable);
stackHeightBindable.BindTo(HitObject.StackHeightBindable);
scaleBindable.BindTo(HitObject.ScaleBindable); scaleBindable.BindTo(HitObject.ScaleBindable);
pathBindable.BindTo(slider.PathBindable); pathBindable.BindTo(slider.PathBindable);

View File

@ -1,6 +1,7 @@
// 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 System.Linq;
using osu.Framework.Bindables; using osu.Framework.Bindables;
using osu.Game.Beatmaps; using osu.Game.Beatmaps;
using osu.Game.Rulesets.Objects; using osu.Game.Rulesets.Objects;
@ -98,6 +99,15 @@ namespace osu.Game.Rulesets.Osu.Objects
set => LastInComboBindable.Value = value; set => LastInComboBindable.Value = value;
} }
protected OsuHitObject()
{
StackHeightBindable.BindValueChanged(height =>
{
foreach (var nested in NestedHitObjects.OfType<OsuHitObject>())
nested.StackHeight = height.NewValue;
});
}
protected override void ApplyDefaultsToSelf(ControlPointInfo controlPointInfo, BeatmapDifficulty difficulty) protected override void ApplyDefaultsToSelf(ControlPointInfo controlPointInfo, BeatmapDifficulty difficulty)
{ {
base.ApplyDefaultsToSelf(controlPointInfo, difficulty); base.ApplyDefaultsToSelf(controlPointInfo, difficulty);

View File

@ -163,6 +163,7 @@ namespace osu.Game.Rulesets.Osu.Objects
{ {
StartTime = e.Time, StartTime = e.Time,
Position = Position, Position = Position,
StackHeight = StackHeight,
Samples = getNodeSamples(0), Samples = getNodeSamples(0),
SampleControlPoint = SampleControlPoint, SampleControlPoint = SampleControlPoint,
}); });
@ -176,6 +177,7 @@ namespace osu.Game.Rulesets.Osu.Objects
{ {
StartTime = e.Time, StartTime = e.Time,
Position = EndPosition, Position = EndPosition,
StackHeight = StackHeight
}); });
break; break;

View File

@ -143,14 +143,14 @@
"Objects": [{ "Objects": [{
"StartTime": 34989, "StartTime": 34989,
"EndTime": 34989, "EndTime": 34989,
"X": 163, "X": 156.597382,
"Y": 138 "Y": 131.597382
}, },
{ {
"StartTime": 35018, "StartTime": 35018,
"EndTime": 35018, "EndTime": 35018,
"X": 188, "X": 181.597382,
"Y": 138 "Y": 131.597382
} }
] ]
}, },
@ -159,14 +159,14 @@
"Objects": [{ "Objects": [{
"StartTime": 35106, "StartTime": 35106,
"EndTime": 35106, "EndTime": 35106,
"X": 163, "X": 159.798691,
"Y": 138 "Y": 134.798691
}, },
{ {
"StartTime": 35135, "StartTime": 35135,
"EndTime": 35135, "EndTime": 35135,
"X": 188, "X": 184.798691,
"Y": 138 "Y": 134.798691
} }
] ]
}, },
@ -191,20 +191,20 @@
"Objects": [{ "Objects": [{
"StartTime": 35695, "StartTime": 35695,
"EndTime": 35695, "EndTime": 35695,
"X": 166, "X": 162.798691,
"Y": 76 "Y": 72.79869
}, },
{ {
"StartTime": 35871, "StartTime": 35871,
"EndTime": 35871, "EndTime": 35871,
"X": 240.99855, "X": 237.797241,
"Y": 75.53417 "Y": 72.33286
}, },
{ {
"StartTime": 36011, "StartTime": 36011,
"EndTime": 36011, "EndTime": 36011,
"X": 315.9971, "X": 312.795776,
"Y": 75.0683441 "Y": 71.8670349
} }
] ]
}, },
@ -235,20 +235,20 @@
"Objects": [{ "Objects": [{
"StartTime": 36518, "StartTime": 36518,
"EndTime": 36518, "EndTime": 36518,
"X": 166, "X": 169.201309,
"Y": 76 "Y": 79.20131
}, },
{ {
"StartTime": 36694, "StartTime": 36694,
"EndTime": 36694, "EndTime": 36694,
"X": 240.99855, "X": 244.19986,
"Y": 75.53417 "Y": 78.73548
}, },
{ {
"StartTime": 36834, "StartTime": 36834,
"EndTime": 36834, "EndTime": 36834,
"X": 315.9971, "X": 319.198425,
"Y": 75.0683441 "Y": 78.26965
} }
] ]
}, },
@ -257,20 +257,20 @@
"Objects": [{ "Objects": [{
"StartTime": 36929, "StartTime": 36929,
"EndTime": 36929, "EndTime": 36929,
"X": 315, "X": 324.603943,
"Y": 75 "Y": 84.6039352
}, },
{ {
"StartTime": 37105, "StartTime": 37105,
"EndTime": 37105, "EndTime": 37105,
"X": 240.001526, "X": 249.605469,
"Y": 75.47769 "Y": 85.08163
}, },
{ {
"StartTime": 37245, "StartTime": 37245,
"EndTime": 37245, "EndTime": 37245,
"X": 165.003052, "X": 174.607,
"Y": 75.95539 "Y": 85.5593262
} }
] ]
} }

View File

@ -162,11 +162,13 @@ namespace osu.Game.Rulesets.Edit
inputManager = GetContainingInputManager(); inputManager = GetContainingInputManager();
} }
private double lastGridUpdateTime;
protected override void Update() protected override void Update()
{ {
base.Update(); base.Update();
if (EditorClock.ElapsedFrameTime != 0 && blueprintContainer.CurrentTool != null) if (EditorClock.CurrentTime != lastGridUpdateTime && blueprintContainer.CurrentTool != null)
showGridFor(Enumerable.Empty<HitObject>()); showGridFor(Enumerable.Empty<HitObject>());
} }
@ -213,6 +215,8 @@ namespace osu.Game.Rulesets.Edit
distanceSnapGridContainer.Child = distanceSnapGrid; distanceSnapGridContainer.Child = distanceSnapGrid;
distanceSnapGridContainer.Show(); distanceSnapGridContainer.Show();
} }
lastGridUpdateTime = EditorClock.CurrentTime;
} }
private ScheduledDelegate scheduledUpdate; private ScheduledDelegate scheduledUpdate;

View File

@ -3,6 +3,7 @@
using System; using System;
using osu.Framework.Graphics; using osu.Framework.Graphics;
using osu.Framework.Graphics.Shapes;
using osu.Framework.Graphics.UserInterface; using osu.Framework.Graphics.UserInterface;
using osu.Game.Rulesets.Objects; using osu.Game.Rulesets.Objects;
using osuTK; using osuTK;
@ -18,10 +19,32 @@ namespace osu.Game.Screens.Edit.Compose.Components
protected override void CreateContent(Vector2 centrePosition) protected override void CreateContent(Vector2 centrePosition)
{ {
const float crosshair_thickness = 1;
const float crosshair_max_size = 10;
AddRangeInternal(new[]
{
new Box
{
Origin = Anchor.Centre,
Position = centrePosition,
Width = crosshair_thickness,
EdgeSmoothness = new Vector2(1),
Height = Math.Min(crosshair_max_size, DistanceSpacing * 2),
},
new Box
{
Origin = Anchor.Centre,
Position = centrePosition,
EdgeSmoothness = new Vector2(1),
Width = Math.Min(crosshair_max_size, DistanceSpacing * 2),
Height = crosshair_thickness,
}
});
float dx = Math.Max(centrePosition.X, DrawWidth - centrePosition.X); float dx = Math.Max(centrePosition.X, DrawWidth - centrePosition.X);
float dy = Math.Max(centrePosition.Y, DrawHeight - centrePosition.Y); float dy = Math.Max(centrePosition.Y, DrawHeight - centrePosition.Y);
float maxDistance = new Vector2(dx, dy).Length; float maxDistance = new Vector2(dx, dy).Length;
int requiredCircles = (int)(maxDistance / DistanceSpacing); int requiredCircles = (int)(maxDistance / DistanceSpacing);
for (int i = 0; i < requiredCircles; i++) for (int i = 0; i < requiredCircles; i++)

View File

@ -36,15 +36,15 @@ namespace osu.Game.Screens.Edit.Compose.Components
/// </summary> /// </summary>
protected readonly Vector2 CentrePosition; protected readonly Vector2 CentrePosition;
[Resolved]
protected OsuColour Colours { get; private set; }
[Resolved] [Resolved]
private IEditorBeatmap beatmap { get; set; } private IEditorBeatmap beatmap { get; set; }
[Resolved] [Resolved]
private BindableBeatDivisor beatDivisor { get; set; } private BindableBeatDivisor beatDivisor { get; set; }
[Resolved]
private OsuColour colours { get; set; }
private readonly Cached gridCache = new Cached(); private readonly Cached gridCache = new Cached();
private readonly HitObject hitObject; private readonly HitObject hitObject;
@ -136,7 +136,7 @@ namespace osu.Game.Screens.Edit.Compose.Components
protected ColourInfo GetColourForBeatIndex(int index) protected ColourInfo GetColourForBeatIndex(int index)
{ {
int beat = (index + 1) % beatDivisor.Value; int beat = (index + 1) % beatDivisor.Value;
ColourInfo colour = colours.Gray5; ColourInfo colour = Colours.Gray5;
for (int i = 0; i < BindableBeatDivisor.VALID_DIVISORS.Length; i++) for (int i = 0; i < BindableBeatDivisor.VALID_DIVISORS.Length; i++)
{ {
@ -144,7 +144,7 @@ namespace osu.Game.Screens.Edit.Compose.Components
if ((beat * divisor) % beatDivisor.Value == 0) if ((beat * divisor) % beatDivisor.Value == 0)
{ {
colour = BindableBeatDivisor.GetColourFor(divisor, colours); colour = BindableBeatDivisor.GetColourFor(divisor, Colours);
break; break;
} }
} }