Merge remote-tracking branch 'upstream/master' into hide-seekbar-with-no-song

This commit is contained in:
Dean Herbert 2018-11-14 11:53:43 +09:00
commit 161d476091
122 changed files with 987 additions and 963 deletions

14
.github/ISSUE_TEMPLATE/bug-issues.md vendored Normal file
View File

@ -0,0 +1,14 @@
---
name: Bug Report
about: For issues regarding encountered game bugs
---
<!-- After you fill in all information, delete all comments in the issue -->
**Describe your problem:** <!-- Provide any information you believe could be useful -->
**Screenshots or videos showing encountered issue:**
**osu!lazer version:** <!-- Provide the version of your osu!lazer, you can find it at the bottom of the screen -->
**Logs:** <!-- Attach your osu!lazer logs, you can find them under %appdata%\osu\logs in Windows, or under ~/.local/share/osu/ in Linux and macOS -->

16
.github/ISSUE_TEMPLATE/crash-issues.md vendored Normal file
View File

@ -0,0 +1,16 @@
---
name: Crash Report
about: For issues regarding game crashes or permanent freezes
---
<!-- After you fill in all information, delete all comments in the issue -->
**Describe your problem:** <!-- Provide any information you believe could be useful -->
**Screenshots or videos showing encountered issue:**
**osu!lazer version:** <!-- Provide the version of your osu!lazer, you can find it at the bottom of the screen -->
**Logs:** <!-- Attach your osu!lazer logs, you can find them under %appdata%\osu\logs in Windows, or under ~/.local/share/osu/ in Linux and macOS -->
**Computer Specifications:** <!-- Attach your computer specifications, you can find them by using System Information in Windows, System Monitor in Linux, or About This Mac in macOS -->

View File

@ -0,0 +1,10 @@
---
name: Feature Request
about: Let us know what you would like to see in the game!
---
<!-- After you fill in all information, delete all comments in the issue -->
**Describe the feature:** <!-- Describe the feature you would like to see in the game -->
**Proposal designs of the feature:** <!-- Attach screenshots of how the feature should look like according to you -->

View File

@ -0,0 +1,10 @@
---
name: Missing for Live
about: Let us know the features you need which are available in osu-stable but not lazer
---
<!-- After you fill in all information, delete all comments in the issue -->
**Describe the feature:** <!-- Describe the missing game feature -->
**Designs:** <!-- Attach screenshots of how the feature is supposed to look like. For illustrative purpose only; final designs are usually re-imagined from scratch. -->

6
.gitignore vendored
View File

@ -252,7 +252,11 @@ paket-files/
.fake/ .fake/
# JetBrains Rider # JetBrains Rider
.idea/ .idea/.idea.osu/.idea/*.xml
.idea/.idea.osu/.idea/codeStyles/*.xml
.idea/.idea.osu/.idea/dataSources/*.xml
.idea/.idea.osu/.idea/dictionaries/*.xml
.idea/.idea.osu/*.iml
*.sln.iml *.sln.iml
# CodeRush # CodeRush

0
build.sh Normal file → Executable file
View File

@ -1 +1 @@
Subproject commit c3848d8b1c84966abe851d915bcca878415614b4 Subproject commit 651e598b016b43e31ab1c1b29d5b30c92361b8d9

View File

@ -5,6 +5,7 @@ using System.Linq;
using osu.Game.Beatmaps; using osu.Game.Beatmaps;
using osu.Game.Rulesets.Catch.Objects; using osu.Game.Rulesets.Catch.Objects;
using osu.Game.Rulesets.Catch.UI; using osu.Game.Rulesets.Catch.UI;
using osu.Game.Rulesets.Objects;
using osu.Game.Rulesets.Objects.Types; using osu.Game.Rulesets.Objects.Types;
using osu.Game.Screens.Play; using osu.Game.Screens.Play;
using osu.Game.Tests.Visual; using osu.Game.Tests.Visual;
@ -37,13 +38,11 @@ namespace osu.Game.Rulesets.Catch.Tests
beatmap.HitObjects.Add(new JuiceStream beatmap.HitObjects.Add(new JuiceStream
{ {
X = 0.5f - width / 2, X = 0.5f - width / 2,
ControlPoints = new[] Path = new SliderPath(PathType.Linear, new[]
{ {
Vector2.Zero, Vector2.Zero,
new Vector2(width * CatchPlayfield.BASE_WIDTH, 0) new Vector2(width * CatchPlayfield.BASE_WIDTH, 0)
}, }),
PathType = PathType.Linear,
Distance = width * CatchPlayfield.BASE_WIDTH,
StartTime = i * 2000, StartTime = i * 2000,
NewCombo = i % 8 == 0 NewCombo = i % 8 == 0
}); });

View File

@ -4,7 +4,7 @@
<PackageReference Include="Appveyor.TestLogger" Version="2.0.0" /> <PackageReference Include="Appveyor.TestLogger" Version="2.0.0" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="15.9.0" /> <PackageReference Include="Microsoft.NET.Test.Sdk" Version="15.9.0" />
<PackageReference Include="NUnit" Version="3.11.0" /> <PackageReference Include="NUnit" Version="3.11.0" />
<PackageReference Include="NUnit3TestAdapter" Version="3.10.0" /> <PackageReference Include="NUnit3TestAdapter" Version="3.11.0" />
<PackageReference Update="Microsoft.EntityFrameworkCore.Sqlite" Version="2.1.4" /> <PackageReference Update="Microsoft.EntityFrameworkCore.Sqlite" Version="2.1.4" />
</ItemGroup> </ItemGroup>
<PropertyGroup Label="Project"> <PropertyGroup Label="Project">

View File

@ -34,10 +34,8 @@ namespace osu.Game.Rulesets.Catch.Beatmaps
{ {
StartTime = obj.StartTime, StartTime = obj.StartTime,
Samples = obj.Samples, Samples = obj.Samples,
ControlPoints = curveData.ControlPoints, Path = curveData.Path,
PathType = curveData.PathType, NodeSamples = curveData.NodeSamples,
Distance = curveData.Distance,
RepeatSamples = curveData.RepeatSamples,
RepeatCount = curveData.RepeatCount, RepeatCount = curveData.RepeatCount,
X = (positionData?.X ?? 0) / CatchPlayfield.BASE_WIDTH, X = (positionData?.X ?? 0) / CatchPlayfield.BASE_WIDTH,
NewCombo = comboData?.NewCombo ?? false, NewCombo = comboData?.NewCombo ?? false,

View File

@ -10,7 +10,6 @@ using osu.Game.Beatmaps.ControlPoints;
using osu.Game.Rulesets.Catch.UI; using osu.Game.Rulesets.Catch.UI;
using osu.Game.Rulesets.Objects; using osu.Game.Rulesets.Objects;
using osu.Game.Rulesets.Objects.Types; using osu.Game.Rulesets.Objects.Types;
using OpenTK;
namespace osu.Game.Rulesets.Catch.Objects namespace osu.Game.Rulesets.Catch.Objects
{ {
@ -138,27 +137,17 @@ namespace osu.Game.Rulesets.Catch.Objects
public double Duration => EndTime - StartTime; public double Duration => EndTime - StartTime;
public double Distance private SliderPath path;
public SliderPath Path
{ {
get { return Path.Distance; } get => path;
set { Path.Distance = value; } set => path = value;
} }
public SliderPath Path { get; } = new SliderPath(); public double Distance => Path.Distance;
public Vector2[] ControlPoints public List<List<SampleInfo>> NodeSamples { get; set; } = new List<List<SampleInfo>>();
{
get { return Path.ControlPoints; }
set { Path.ControlPoints = value; }
}
public List<List<SampleInfo>> RepeatSamples { get; set; } = new List<List<SampleInfo>>();
public PathType PathType
{
get { return Path.PathType; }
set { Path.PathType = value; }
}
public double? LegacyLastTickOffset { get; set; } public double? LegacyLastTickOffset { get; set; }
} }

View File

@ -4,7 +4,7 @@
<PackageReference Include="Appveyor.TestLogger" Version="2.0.0" /> <PackageReference Include="Appveyor.TestLogger" Version="2.0.0" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="15.9.0" /> <PackageReference Include="Microsoft.NET.Test.Sdk" Version="15.9.0" />
<PackageReference Include="NUnit" Version="3.11.0" /> <PackageReference Include="NUnit" Version="3.11.0" />
<PackageReference Include="NUnit3TestAdapter" Version="3.10.0" /> <PackageReference Include="NUnit3TestAdapter" Version="3.11.0" />
<PackageReference Update="Microsoft.EntityFrameworkCore.Sqlite" Version="2.1.4" /> <PackageReference Update="Microsoft.EntityFrameworkCore.Sqlite" Version="2.1.4" />
</ItemGroup> </ItemGroup>
<PropertyGroup Label="Project"> <PropertyGroup Label="Project">

View File

@ -247,7 +247,7 @@ namespace osu.Game.Rulesets.Mania.Beatmaps
double segmentTime = (curveData.EndTime - HitObject.StartTime) / curveData.SpanCount(); double segmentTime = (curveData.EndTime - HitObject.StartTime) / curveData.SpanCount();
int index = (int)(segmentTime == 0 ? 0 : (time - HitObject.StartTime) / segmentTime); int index = (int)(segmentTime == 0 ? 0 : (time - HitObject.StartTime) / segmentTime);
return curveData.RepeatSamples[index]; return curveData.NodeSamples[index];
} }
} }
} }

View File

@ -470,7 +470,7 @@ namespace osu.Game.Rulesets.Mania.Beatmaps.Patterns.Legacy
double segmentTime = (EndTime - HitObject.StartTime) / spanCount; double segmentTime = (EndTime - HitObject.StartTime) / spanCount;
int index = (int)(segmentTime == 0 ? 0 : (time - HitObject.StartTime) / segmentTime); int index = (int)(segmentTime == 0 ? 0 : (time - HitObject.StartTime) / segmentTime);
return curveData.RepeatSamples[index]; return curveData.NodeSamples[index];
} }
/// <summary> /// <summary>

View File

@ -5,7 +5,6 @@ using osu.Framework.Allocation;
using osu.Framework.Configuration; using osu.Framework.Configuration;
using osu.Framework.Graphics; using osu.Framework.Graphics;
using osu.Game.Graphics; using osu.Game.Graphics;
using osu.Game.Rulesets.Edit;
using osu.Game.Rulesets.Mania.Objects.Drawables; using osu.Game.Rulesets.Mania.Objects.Drawables;
using osu.Game.Rulesets.Mania.Objects.Drawables.Pieces; using osu.Game.Rulesets.Mania.Objects.Drawables.Pieces;
using osu.Game.Rulesets.Mania.UI; using osu.Game.Rulesets.Mania.UI;
@ -13,9 +12,9 @@ using osu.Game.Rulesets.UI.Scrolling;
using OpenTK; using OpenTK;
using OpenTK.Graphics; using OpenTK.Graphics;
namespace osu.Game.Rulesets.Mania.Edit.Masks namespace osu.Game.Rulesets.Mania.Edit.Blueprints
{ {
public class HoldNoteSelectionMask : SelectionMask public class HoldNoteSelectionBlueprint : ManiaSelectionBlueprint
{ {
public new DrawableHoldNote HitObject => (DrawableHoldNote)base.HitObject; public new DrawableHoldNote HitObject => (DrawableHoldNote)base.HitObject;
@ -23,13 +22,13 @@ namespace osu.Game.Rulesets.Mania.Edit.Masks
private readonly BodyPiece body; private readonly BodyPiece body;
public HoldNoteSelectionMask(DrawableHoldNote hold) public HoldNoteSelectionBlueprint(DrawableHoldNote hold)
: base(hold) : base(hold)
{ {
InternalChildren = new Drawable[] InternalChildren = new Drawable[]
{ {
new HoldNoteNoteSelectionMask(hold.Head), new HoldNoteNoteSelectionBlueprint(hold.Head),
new HoldNoteNoteSelectionMask(hold.Tail), new HoldNoteNoteSelectionBlueprint(hold.Tail),
body = new BodyPiece body = new BodyPiece
{ {
AccentColour = Color4.Transparent AccentColour = Color4.Transparent
@ -59,9 +58,9 @@ namespace osu.Game.Rulesets.Mania.Edit.Masks
Y -= HitObject.Tail.DrawHeight; Y -= HitObject.Tail.DrawHeight;
} }
private class HoldNoteNoteSelectionMask : NoteSelectionMask private class HoldNoteNoteSelectionBlueprint : NoteSelectionBlueprint
{ {
public HoldNoteNoteSelectionMask(DrawableNote note) public HoldNoteNoteSelectionBlueprint(DrawableNote note)
: base(note) : base(note)
{ {
Select(); Select();

View File

@ -0,0 +1,21 @@
// Copyright (c) 2007-2018 ppy Pty Ltd <contact@ppy.sh>.
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
using osu.Framework.Input.Events;
using osu.Game.Rulesets.Edit;
using osu.Game.Rulesets.Objects.Drawables;
namespace osu.Game.Rulesets.Mania.Edit.Blueprints
{
public class ManiaSelectionBlueprint : SelectionBlueprint
{
public ManiaSelectionBlueprint(DrawableHitObject hitObject)
: base(hitObject)
{
}
public override void AdjustPosition(DragEvent dragEvent)
{
}
}
}

View File

@ -3,15 +3,14 @@
using osu.Framework.Allocation; using osu.Framework.Allocation;
using osu.Game.Graphics; using osu.Game.Graphics;
using osu.Game.Rulesets.Edit;
using osu.Game.Rulesets.Mania.Objects.Drawables; using osu.Game.Rulesets.Mania.Objects.Drawables;
using osu.Game.Rulesets.Mania.Objects.Drawables.Pieces; using osu.Game.Rulesets.Mania.Objects.Drawables.Pieces;
namespace osu.Game.Rulesets.Mania.Edit.Masks namespace osu.Game.Rulesets.Mania.Edit.Blueprints
{ {
public class NoteSelectionMask : SelectionMask public class NoteSelectionBlueprint : ManiaSelectionBlueprint
{ {
public NoteSelectionMask(DrawableNote note) public NoteSelectionBlueprint(DrawableNote note)
: base(note) : base(note)
{ {
Scale = note.Scale; Scale = note.Scale;

View File

@ -11,7 +11,7 @@ using osu.Game.Rulesets.Objects.Drawables;
using System.Collections.Generic; using System.Collections.Generic;
using osu.Framework.Allocation; using osu.Framework.Allocation;
using osu.Game.Rulesets.Mania.Configuration; using osu.Game.Rulesets.Mania.Configuration;
using osu.Game.Rulesets.Mania.Edit.Masks; using osu.Game.Rulesets.Mania.Edit.Blueprints;
using osu.Game.Rulesets.Mania.UI; using osu.Game.Rulesets.Mania.UI;
using osu.Game.Rulesets.UI; using osu.Game.Rulesets.UI;
@ -38,17 +38,17 @@ namespace osu.Game.Rulesets.Mania.Edit
protected override IReadOnlyList<HitObjectCompositionTool> CompositionTools => Array.Empty<HitObjectCompositionTool>(); protected override IReadOnlyList<HitObjectCompositionTool> CompositionTools => Array.Empty<HitObjectCompositionTool>();
public override SelectionMask CreateMaskFor(DrawableHitObject hitObject) public override SelectionBlueprint CreateBlueprintFor(DrawableHitObject hitObject)
{ {
switch (hitObject) switch (hitObject)
{ {
case DrawableNote note: case DrawableNote note:
return new NoteSelectionMask(note); return new NoteSelectionBlueprint(note);
case DrawableHoldNote holdNote: case DrawableHoldNote holdNote:
return new HoldNoteSelectionMask(holdNote); return new HoldNoteSelectionBlueprint(holdNote);
} }
return base.CreateMaskFor(hitObject); return base.CreateBlueprintFor(hitObject);
} }
} }
} }

View File

@ -4,16 +4,16 @@
using osu.Game.Rulesets.Edit; using osu.Game.Rulesets.Edit;
using osu.Game.Rulesets.Objects; using osu.Game.Rulesets.Objects;
using osu.Game.Rulesets.Objects.Drawables; using osu.Game.Rulesets.Objects.Drawables;
using osu.Game.Rulesets.Osu.Edit.Masks.HitCircleMasks; using osu.Game.Rulesets.Osu.Edit.Blueprints.HitCircles;
using osu.Game.Rulesets.Osu.Objects; using osu.Game.Rulesets.Osu.Objects;
using osu.Game.Rulesets.Osu.Objects.Drawables; using osu.Game.Rulesets.Osu.Objects.Drawables;
using osu.Game.Tests.Visual; using osu.Game.Tests.Visual;
namespace osu.Game.Rulesets.Osu.Tests namespace osu.Game.Rulesets.Osu.Tests
{ {
public class TestCaseHitCirclePlacementMask : HitObjectPlacementMaskTestCase public class TestCaseHitCirclePlacementBlueprint : PlacementBlueprintTestCase
{ {
protected override DrawableHitObject CreateHitObject(HitObject hitObject) => new DrawableHitCircle((HitCircle)hitObject); protected override DrawableHitObject CreateHitObject(HitObject hitObject) => new DrawableHitCircle((HitCircle)hitObject);
protected override PlacementMask CreateMask() => new HitCirclePlacementMask(); protected override PlacementBlueprint CreateBlueprint() => new HitCirclePlacementBlueprint();
} }
} }

View File

@ -4,7 +4,7 @@
using osu.Game.Beatmaps; using osu.Game.Beatmaps;
using osu.Game.Beatmaps.ControlPoints; using osu.Game.Beatmaps.ControlPoints;
using osu.Game.Rulesets.Edit; using osu.Game.Rulesets.Edit;
using osu.Game.Rulesets.Osu.Edit.Masks.HitCircleMasks; using osu.Game.Rulesets.Osu.Edit.Blueprints.HitCircles;
using osu.Game.Rulesets.Osu.Objects; using osu.Game.Rulesets.Osu.Objects;
using osu.Game.Rulesets.Osu.Objects.Drawables; using osu.Game.Rulesets.Osu.Objects.Drawables;
using osu.Game.Tests.Visual; using osu.Game.Tests.Visual;
@ -12,11 +12,11 @@ using OpenTK;
namespace osu.Game.Rulesets.Osu.Tests namespace osu.Game.Rulesets.Osu.Tests
{ {
public class TestCaseHitCircleSelectionMask : HitObjectSelectionMaskTestCase public class TestCaseHitCircleSelectionBlueprint : SelectionBlueprintTestCase
{ {
private readonly DrawableHitCircle drawableObject; private readonly DrawableHitCircle drawableObject;
public TestCaseHitCircleSelectionMask() public TestCaseHitCircleSelectionBlueprint()
{ {
var hitCircle = new HitCircle { Position = new Vector2(256, 192) }; var hitCircle = new HitCircle { Position = new Vector2(256, 192) };
hitCircle.ApplyDefaults(new ControlPointInfo(), new BeatmapDifficulty { CircleSize = 2 }); hitCircle.ApplyDefaults(new ControlPointInfo(), new BeatmapDifficulty { CircleSize = 2 });
@ -24,6 +24,6 @@ namespace osu.Game.Rulesets.Osu.Tests
Add(drawableObject = new DrawableHitCircle(hitCircle)); Add(drawableObject = new DrawableHitCircle(hitCircle));
} }
protected override SelectionMask CreateMask() => new HitCircleSelectionMask(drawableObject); protected override SelectionBlueprint CreateBlueprint() => new HitCircleSelectionBlueprint(drawableObject);
} }
} }

View File

@ -18,6 +18,7 @@ using System.Linq;
using NUnit.Framework; using NUnit.Framework;
using osu.Game.Graphics.Sprites; using osu.Game.Graphics.Sprites;
using osu.Game.Rulesets.Judgements; using osu.Game.Rulesets.Judgements;
using osu.Game.Rulesets.Objects;
using osu.Game.Rulesets.Objects.Drawables; using osu.Game.Rulesets.Objects.Drawables;
using osu.Game.Rulesets.Objects.Types; using osu.Game.Rulesets.Objects.Types;
using osu.Game.Rulesets.Osu.Objects.Drawables.Pieces; using osu.Game.Rulesets.Osu.Objects.Drawables.Pieces;
@ -108,15 +109,14 @@ namespace osu.Game.Rulesets.Osu.Tests
{ {
StartTime = Time.Current + 1000, StartTime = Time.Current + 1000,
Position = new Vector2(239, 176), Position = new Vector2(239, 176),
ControlPoints = new[] Path = new SliderPath(PathType.PerfectCurve, new[]
{ {
Vector2.Zero, Vector2.Zero,
new Vector2(154, 28), new Vector2(154, 28),
new Vector2(52, -34) new Vector2(52, -34)
}, }, 700),
Distance = 700,
RepeatCount = repeats, RepeatCount = repeats,
RepeatSamples = createEmptySamples(repeats), NodeSamples = createEmptySamples(repeats),
StackHeight = 10 StackHeight = 10
}; };
@ -141,14 +141,13 @@ namespace osu.Game.Rulesets.Osu.Tests
{ {
StartTime = Time.Current + 1000, StartTime = Time.Current + 1000,
Position = new Vector2(-(distance / 2), 0), Position = new Vector2(-(distance / 2), 0),
ControlPoints = new[] Path = new SliderPath(PathType.PerfectCurve, new[]
{ {
Vector2.Zero, Vector2.Zero,
new Vector2(distance, 0), new Vector2(distance, 0),
}, }, distance),
Distance = distance,
RepeatCount = repeats, RepeatCount = repeats,
RepeatSamples = createEmptySamples(repeats), NodeSamples = createEmptySamples(repeats),
StackHeight = stackHeight StackHeight = stackHeight
}; };
@ -161,15 +160,14 @@ namespace osu.Game.Rulesets.Osu.Tests
{ {
StartTime = Time.Current + 1000, StartTime = Time.Current + 1000,
Position = new Vector2(-200, 0), Position = new Vector2(-200, 0),
ControlPoints = new[] Path = new SliderPath(PathType.PerfectCurve, new[]
{ {
Vector2.Zero, Vector2.Zero,
new Vector2(200, 200), new Vector2(200, 200),
new Vector2(400, 0) new Vector2(400, 0)
}, }, 600),
Distance = 600,
RepeatCount = repeats, RepeatCount = repeats,
RepeatSamples = createEmptySamples(repeats) NodeSamples = createEmptySamples(repeats)
}; };
addSlider(slider, 2, 3); addSlider(slider, 2, 3);
@ -181,10 +179,9 @@ namespace osu.Game.Rulesets.Osu.Tests
{ {
var slider = new Slider var slider = new Slider
{ {
PathType = PathType.Linear,
StartTime = Time.Current + 1000, StartTime = Time.Current + 1000,
Position = new Vector2(-200, 0), Position = new Vector2(-200, 0),
ControlPoints = new[] Path = new SliderPath(PathType.Linear, new[]
{ {
Vector2.Zero, Vector2.Zero,
new Vector2(150, 75), new Vector2(150, 75),
@ -192,10 +189,9 @@ namespace osu.Game.Rulesets.Osu.Tests
new Vector2(300, -200), new Vector2(300, -200),
new Vector2(400, 0), new Vector2(400, 0),
new Vector2(430, 0) new Vector2(430, 0)
}, }),
Distance = 793.4417,
RepeatCount = repeats, RepeatCount = repeats,
RepeatSamples = createEmptySamples(repeats) NodeSamples = createEmptySamples(repeats)
}; };
addSlider(slider, 2, 3); addSlider(slider, 2, 3);
@ -207,20 +203,18 @@ namespace osu.Game.Rulesets.Osu.Tests
{ {
var slider = new Slider var slider = new Slider
{ {
PathType = PathType.Bezier,
StartTime = Time.Current + 1000, StartTime = Time.Current + 1000,
Position = new Vector2(-200, 0), Position = new Vector2(-200, 0),
ControlPoints = new[] Path = new SliderPath(PathType.Bezier, new[]
{ {
Vector2.Zero, Vector2.Zero,
new Vector2(150, 75), new Vector2(150, 75),
new Vector2(200, 100), new Vector2(200, 100),
new Vector2(300, -200), new Vector2(300, -200),
new Vector2(430, 0) new Vector2(430, 0)
}, }),
Distance = 480,
RepeatCount = repeats, RepeatCount = repeats,
RepeatSamples = createEmptySamples(repeats) NodeSamples = createEmptySamples(repeats)
}; };
addSlider(slider, 2, 3); addSlider(slider, 2, 3);
@ -232,10 +226,9 @@ namespace osu.Game.Rulesets.Osu.Tests
{ {
var slider = new Slider var slider = new Slider
{ {
PathType = PathType.Linear,
StartTime = Time.Current + 1000, StartTime = Time.Current + 1000,
Position = new Vector2(0, 0), Position = new Vector2(0, 0),
ControlPoints = new[] Path = new SliderPath(PathType.Linear, new[]
{ {
Vector2.Zero, Vector2.Zero,
new Vector2(-200, 0), new Vector2(-200, 0),
@ -243,10 +236,9 @@ namespace osu.Game.Rulesets.Osu.Tests
new Vector2(0, -200), new Vector2(0, -200),
new Vector2(-200, -200), new Vector2(-200, -200),
new Vector2(0, -200) new Vector2(0, -200)
}, }),
Distance = 1000,
RepeatCount = repeats, RepeatCount = repeats,
RepeatSamples = createEmptySamples(repeats) NodeSamples = createEmptySamples(repeats)
}; };
addSlider(slider, 2, 3); addSlider(slider, 2, 3);
@ -264,17 +256,15 @@ namespace osu.Game.Rulesets.Osu.Tests
{ {
StartTime = Time.Current + 1000, StartTime = Time.Current + 1000,
Position = new Vector2(-100, 0), Position = new Vector2(-100, 0),
PathType = PathType.Catmull, Path = new SliderPath(PathType.Catmull, new[]
ControlPoints = new[]
{ {
Vector2.Zero, Vector2.Zero,
new Vector2(50, -50), new Vector2(50, -50),
new Vector2(150, 50), new Vector2(150, 50),
new Vector2(200, 0) new Vector2(200, 0)
}, }),
Distance = 300,
RepeatCount = repeats, RepeatCount = repeats,
RepeatSamples = repeatSamples NodeSamples = repeatSamples
}; };
addSlider(slider, 3, 1); addSlider(slider, 3, 1);

View File

@ -4,16 +4,16 @@
using osu.Game.Rulesets.Edit; using osu.Game.Rulesets.Edit;
using osu.Game.Rulesets.Objects; using osu.Game.Rulesets.Objects;
using osu.Game.Rulesets.Objects.Drawables; using osu.Game.Rulesets.Objects.Drawables;
using osu.Game.Rulesets.Osu.Edit.Masks.SliderMasks; using osu.Game.Rulesets.Osu.Edit.Blueprints.Sliders;
using osu.Game.Rulesets.Osu.Objects; using osu.Game.Rulesets.Osu.Objects;
using osu.Game.Rulesets.Osu.Objects.Drawables; using osu.Game.Rulesets.Osu.Objects.Drawables;
using osu.Game.Tests.Visual; using osu.Game.Tests.Visual;
namespace osu.Game.Rulesets.Osu.Tests namespace osu.Game.Rulesets.Osu.Tests
{ {
public class TestCaseSliderPlacementMask : HitObjectPlacementMaskTestCase public class TestCaseSliderPlacementBlueprint : PlacementBlueprintTestCase
{ {
protected override DrawableHitObject CreateHitObject(HitObject hitObject) => new DrawableSlider((Slider)hitObject); protected override DrawableHitObject CreateHitObject(HitObject hitObject) => new DrawableSlider((Slider)hitObject);
protected override PlacementMask CreateMask() => new SliderPlacementMask(); protected override PlacementBlueprint CreateBlueprint() => new SliderPlacementBlueprint();
} }
} }

View File

@ -6,9 +6,10 @@ using System.Collections.Generic;
using osu.Game.Beatmaps; using osu.Game.Beatmaps;
using osu.Game.Beatmaps.ControlPoints; using osu.Game.Beatmaps.ControlPoints;
using osu.Game.Rulesets.Edit; using osu.Game.Rulesets.Edit;
using osu.Game.Rulesets.Objects;
using osu.Game.Rulesets.Objects.Types; using osu.Game.Rulesets.Objects.Types;
using osu.Game.Rulesets.Osu.Edit.Masks.SliderMasks; using osu.Game.Rulesets.Osu.Edit.Blueprints.Sliders;
using osu.Game.Rulesets.Osu.Edit.Masks.SliderMasks.Components; using osu.Game.Rulesets.Osu.Edit.Blueprints.Sliders.Components;
using osu.Game.Rulesets.Osu.Objects; using osu.Game.Rulesets.Osu.Objects;
using osu.Game.Rulesets.Osu.Objects.Drawables; using osu.Game.Rulesets.Osu.Objects.Drawables;
using osu.Game.Tests.Visual; using osu.Game.Tests.Visual;
@ -16,12 +17,12 @@ using OpenTK;
namespace osu.Game.Rulesets.Osu.Tests namespace osu.Game.Rulesets.Osu.Tests
{ {
public class TestCaseSliderSelectionMask : HitObjectSelectionMaskTestCase public class TestCaseSliderSelectionBlueprint : SelectionBlueprintTestCase
{ {
public override IReadOnlyList<Type> RequiredTypes => new[] public override IReadOnlyList<Type> RequiredTypes => new[]
{ {
typeof(SliderSelectionMask), typeof(SliderSelectionBlueprint),
typeof(SliderCircleSelectionMask), typeof(SliderCircleSelectionBlueprint),
typeof(SliderBodyPiece), typeof(SliderBodyPiece),
typeof(SliderCircle), typeof(SliderCircle),
typeof(PathControlPointVisualiser), typeof(PathControlPointVisualiser),
@ -30,19 +31,17 @@ namespace osu.Game.Rulesets.Osu.Tests
private readonly DrawableSlider drawableObject; private readonly DrawableSlider drawableObject;
public TestCaseSliderSelectionMask() public TestCaseSliderSelectionBlueprint()
{ {
var slider = new Slider var slider = new Slider
{ {
Position = new Vector2(256, 192), Position = new Vector2(256, 192),
ControlPoints = new[] Path = new SliderPath(PathType.Bezier, new[]
{ {
Vector2.Zero, Vector2.Zero,
new Vector2(150, 150), new Vector2(150, 150),
new Vector2(300, 0) new Vector2(300, 0)
}, })
PathType = PathType.Bezier,
Distance = 350
}; };
slider.ApplyDefaults(new ControlPointInfo(), new BeatmapDifficulty { CircleSize = 2 }); slider.ApplyDefaults(new ControlPointInfo(), new BeatmapDifficulty { CircleSize = 2 });
@ -50,6 +49,6 @@ namespace osu.Game.Rulesets.Osu.Tests
Add(drawableObject = new DrawableSlider(slider)); Add(drawableObject = new DrawableSlider(slider));
} }
protected override SelectionMask CreateMask() => new SliderSelectionMask(drawableObject); protected override SelectionBlueprint CreateBlueprint() => new SliderSelectionBlueprint(drawableObject);
} }
} }

View File

@ -4,17 +4,17 @@
using osu.Game.Rulesets.Edit; using osu.Game.Rulesets.Edit;
using osu.Game.Rulesets.Objects; using osu.Game.Rulesets.Objects;
using osu.Game.Rulesets.Objects.Drawables; using osu.Game.Rulesets.Objects.Drawables;
using osu.Game.Rulesets.Osu.Edit.Masks.SpinnerMasks; using osu.Game.Rulesets.Osu.Edit.Blueprints.Spinners;
using osu.Game.Rulesets.Osu.Objects; using osu.Game.Rulesets.Osu.Objects;
using osu.Game.Rulesets.Osu.Objects.Drawables; using osu.Game.Rulesets.Osu.Objects.Drawables;
using osu.Game.Tests.Visual; using osu.Game.Tests.Visual;
namespace osu.Game.Rulesets.Osu.Tests namespace osu.Game.Rulesets.Osu.Tests
{ {
public class TestCaseSpinnerPlacementMask : HitObjectPlacementMaskTestCase public class TestCaseSpinnerPlacementBlueprint : PlacementBlueprintTestCase
{ {
protected override DrawableHitObject CreateHitObject(HitObject hitObject) => new DrawableSpinner((Spinner)hitObject); protected override DrawableHitObject CreateHitObject(HitObject hitObject) => new DrawableSpinner((Spinner)hitObject);
protected override PlacementMask CreateMask() => new SpinnerPlacementMask(); protected override PlacementBlueprint CreateBlueprint() => new SpinnerPlacementBlueprint();
} }
} }

View File

@ -8,8 +8,8 @@ using osu.Framework.Graphics.Containers;
using osu.Game.Beatmaps; using osu.Game.Beatmaps;
using osu.Game.Beatmaps.ControlPoints; using osu.Game.Beatmaps.ControlPoints;
using osu.Game.Rulesets.Edit; using osu.Game.Rulesets.Edit;
using osu.Game.Rulesets.Osu.Edit.Masks.SpinnerMasks; using osu.Game.Rulesets.Osu.Edit.Blueprints.Spinners;
using osu.Game.Rulesets.Osu.Edit.Masks.SpinnerMasks.Components; using osu.Game.Rulesets.Osu.Edit.Blueprints.Spinners.Components;
using osu.Game.Rulesets.Osu.Objects; using osu.Game.Rulesets.Osu.Objects;
using osu.Game.Rulesets.Osu.Objects.Drawables; using osu.Game.Rulesets.Osu.Objects.Drawables;
using osu.Game.Tests.Visual; using osu.Game.Tests.Visual;
@ -17,17 +17,17 @@ using OpenTK;
namespace osu.Game.Rulesets.Osu.Tests namespace osu.Game.Rulesets.Osu.Tests
{ {
public class TestCaseSpinnerSelectionMask : HitObjectSelectionMaskTestCase public class TestCaseSpinnerSelectionBlueprint : SelectionBlueprintTestCase
{ {
public override IReadOnlyList<Type> RequiredTypes => new[] public override IReadOnlyList<Type> RequiredTypes => new[]
{ {
typeof(SpinnerSelectionMask), typeof(SpinnerSelectionBlueprint),
typeof(SpinnerPiece) typeof(SpinnerPiece)
}; };
private readonly DrawableSpinner drawableSpinner; private readonly DrawableSpinner drawableSpinner;
public TestCaseSpinnerSelectionMask() public TestCaseSpinnerSelectionBlueprint()
{ {
var spinner = new Spinner var spinner = new Spinner
{ {
@ -45,6 +45,6 @@ namespace osu.Game.Rulesets.Osu.Tests
}); });
} }
protected override SelectionMask CreateMask() => new SpinnerSelectionMask(drawableSpinner) { Size = new Vector2(0.5f) }; protected override SelectionBlueprint CreateBlueprint() => new SpinnerSelectionBlueprint(drawableSpinner) { Size = new Vector2(0.5f) };
} }
} }

View File

@ -4,7 +4,7 @@
<PackageReference Include="Appveyor.TestLogger" Version="2.0.0" /> <PackageReference Include="Appveyor.TestLogger" Version="2.0.0" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="15.9.0" /> <PackageReference Include="Microsoft.NET.Test.Sdk" Version="15.9.0" />
<PackageReference Include="NUnit" Version="3.11.0" /> <PackageReference Include="NUnit" Version="3.11.0" />
<PackageReference Include="NUnit3TestAdapter" Version="3.10.0" /> <PackageReference Include="NUnit3TestAdapter" Version="3.11.0" />
<PackageReference Update="Microsoft.EntityFrameworkCore.Sqlite" Version="2.1.4" /> <PackageReference Update="Microsoft.EntityFrameworkCore.Sqlite" Version="2.1.4" />
</ItemGroup> </ItemGroup>
<PropertyGroup Label="Project"> <PropertyGroup Label="Project">

View File

@ -35,10 +35,8 @@ namespace osu.Game.Rulesets.Osu.Beatmaps
{ {
StartTime = original.StartTime, StartTime = original.StartTime,
Samples = original.Samples, Samples = original.Samples,
ControlPoints = curveData.ControlPoints, Path = curveData.Path,
PathType = curveData.PathType, NodeSamples = curveData.NodeSamples,
Distance = curveData.Distance,
RepeatSamples = curveData.RepeatSamples,
RepeatCount = curveData.RepeatCount, RepeatCount = curveData.RepeatCount,
Position = positionData?.Position ?? Vector2.Zero, Position = positionData?.Position ?? Vector2.Zero,
NewCombo = comboData?.NewCombo ?? false, NewCombo = comboData?.NewCombo ?? false,

View File

@ -9,7 +9,7 @@ using osu.Game.Rulesets.Osu.Objects;
using osu.Game.Rulesets.Osu.Objects.Drawables.Pieces; using osu.Game.Rulesets.Osu.Objects.Drawables.Pieces;
using OpenTK; using OpenTK;
namespace osu.Game.Rulesets.Osu.Edit.Masks.HitCircleMasks.Components namespace osu.Game.Rulesets.Osu.Edit.Blueprints.HitCircles.Components
{ {
public class HitCirclePiece : CompositeDrawable public class HitCirclePiece : CompositeDrawable
{ {

View File

@ -3,16 +3,16 @@
using osu.Framework.Input.Events; using osu.Framework.Input.Events;
using osu.Game.Rulesets.Edit; using osu.Game.Rulesets.Edit;
using osu.Game.Rulesets.Osu.Edit.Masks.HitCircleMasks.Components; using osu.Game.Rulesets.Osu.Edit.Blueprints.HitCircles.Components;
using osu.Game.Rulesets.Osu.Objects; using osu.Game.Rulesets.Osu.Objects;
namespace osu.Game.Rulesets.Osu.Edit.Masks.HitCircleMasks namespace osu.Game.Rulesets.Osu.Edit.Blueprints.HitCircles
{ {
public class HitCirclePlacementMask : PlacementMask public class HitCirclePlacementBlueprint : PlacementBlueprint
{ {
public new HitCircle HitObject => (HitCircle)base.HitObject; public new HitCircle HitObject => (HitCircle)base.HitObject;
public HitCirclePlacementMask() public HitCirclePlacementBlueprint()
: base(new HitCircle()) : base(new HitCircle())
{ {
InternalChild = new HitCirclePiece(HitObject); InternalChild = new HitCirclePiece(HitObject);

View File

@ -1,16 +1,15 @@
// Copyright (c) 2007-2018 ppy Pty Ltd <contact@ppy.sh>. // Copyright (c) 2007-2018 ppy Pty Ltd <contact@ppy.sh>.
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE // Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
using osu.Game.Rulesets.Edit; using osu.Game.Rulesets.Osu.Edit.Blueprints.HitCircles.Components;
using osu.Game.Rulesets.Osu.Edit.Masks.HitCircleMasks.Components;
using osu.Game.Rulesets.Osu.Objects; using osu.Game.Rulesets.Osu.Objects;
using osu.Game.Rulesets.Osu.Objects.Drawables; using osu.Game.Rulesets.Osu.Objects.Drawables;
namespace osu.Game.Rulesets.Osu.Edit.Masks.HitCircleMasks namespace osu.Game.Rulesets.Osu.Edit.Blueprints.HitCircles
{ {
public class HitCircleSelectionMask : SelectionMask public class HitCircleSelectionBlueprint : OsuSelectionBlueprint
{ {
public HitCircleSelectionMask(DrawableHitCircle hitCircle) public HitCircleSelectionBlueprint(DrawableHitCircle hitCircle)
: base(hitCircle) : base(hitCircle)
{ {
InternalChild = new HitCirclePiece((HitCircle)hitCircle.HitObject); InternalChild = new HitCirclePiece((HitCircle)hitCircle.HitObject);

View File

@ -0,0 +1,22 @@
// Copyright (c) 2007-2018 ppy Pty Ltd <contact@ppy.sh>.
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
using osu.Framework.Input.Events;
using osu.Game.Rulesets.Edit;
using osu.Game.Rulesets.Objects.Drawables;
using osu.Game.Rulesets.Osu.Objects;
namespace osu.Game.Rulesets.Osu.Edit.Blueprints
{
public class OsuSelectionBlueprint : SelectionBlueprint
{
protected OsuHitObject OsuObject => (OsuHitObject)HitObject.HitObject;
public OsuSelectionBlueprint(DrawableHitObject hitObject)
: base(hitObject)
{
}
public override void AdjustPosition(DragEvent dragEvent) => OsuObject.Position += dragEvent.Delta;
}
}

View File

@ -1,7 +1,6 @@
// Copyright (c) 2007-2018 ppy Pty Ltd <contact@ppy.sh>. // Copyright (c) 2007-2018 ppy Pty Ltd <contact@ppy.sh>.
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE // Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
using System.Linq;
using osu.Framework.Allocation; using osu.Framework.Allocation;
using osu.Framework.Graphics; using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers; using osu.Framework.Graphics.Containers;
@ -9,10 +8,11 @@ using osu.Framework.Graphics.Lines;
using osu.Framework.Graphics.Shapes; using osu.Framework.Graphics.Shapes;
using osu.Framework.Input.Events; using osu.Framework.Input.Events;
using osu.Game.Graphics; using osu.Game.Graphics;
using osu.Game.Rulesets.Objects;
using osu.Game.Rulesets.Osu.Objects; using osu.Game.Rulesets.Osu.Objects;
using OpenTK; using OpenTK;
namespace osu.Game.Rulesets.Osu.Edit.Masks.SliderMasks.Components namespace osu.Game.Rulesets.Osu.Edit.Blueprints.Sliders.Components
{ {
public class PathControlPointPiece : CompositeDrawable public class PathControlPointPiece : CompositeDrawable
{ {
@ -55,16 +55,16 @@ namespace osu.Game.Rulesets.Osu.Edit.Masks.SliderMasks.Components
{ {
base.Update(); base.Update();
Position = slider.StackedPosition + slider.ControlPoints[index]; Position = slider.StackedPosition + slider.Path.ControlPoints[index];
marker.Colour = isSegmentSeparator ? colours.Red : colours.Yellow; marker.Colour = isSegmentSeparator ? colours.Red : colours.Yellow;
path.ClearVertices(); path.ClearVertices();
if (index != slider.ControlPoints.Length - 1) if (index != slider.Path.ControlPoints.Length - 1)
{ {
path.AddVertex(Vector2.Zero); path.AddVertex(Vector2.Zero);
path.AddVertex(slider.ControlPoints[index + 1] - slider.ControlPoints[index]); path.AddVertex(slider.Path.ControlPoints[index + 1] - slider.Path.ControlPoints[index]);
} }
path.OriginPosition = path.PositionInBoundingBox(Vector2.Zero); path.OriginPosition = path.PositionInBoundingBox(Vector2.Zero);
@ -76,7 +76,7 @@ namespace osu.Game.Rulesets.Osu.Edit.Masks.SliderMasks.Components
protected override bool OnDrag(DragEvent e) protected override bool OnDrag(DragEvent e)
{ {
var newControlPoints = slider.ControlPoints.ToArray(); var newControlPoints = slider.Path.ControlPoints.ToArray();
if (index == 0) if (index == 0)
{ {
@ -96,8 +96,7 @@ namespace osu.Game.Rulesets.Osu.Edit.Masks.SliderMasks.Components
if (isSegmentSeparatorWithPrevious) if (isSegmentSeparatorWithPrevious)
newControlPoints[index - 1] = newControlPoints[index]; newControlPoints[index - 1] = newControlPoints[index];
slider.ControlPoints = newControlPoints; slider.Path = new SliderPath(slider.Path.Type, newControlPoints);
slider.Path.Calculate(true);
return true; return true;
} }
@ -106,8 +105,8 @@ namespace osu.Game.Rulesets.Osu.Edit.Masks.SliderMasks.Components
private bool isSegmentSeparator => isSegmentSeparatorWithNext || isSegmentSeparatorWithPrevious; private bool isSegmentSeparator => isSegmentSeparatorWithNext || isSegmentSeparatorWithPrevious;
private bool isSegmentSeparatorWithNext => index < slider.ControlPoints.Length - 1 && slider.ControlPoints[index + 1] == slider.ControlPoints[index]; private bool isSegmentSeparatorWithNext => index < slider.Path.ControlPoints.Length - 1 && slider.Path.ControlPoints[index + 1] == slider.Path.ControlPoints[index];
private bool isSegmentSeparatorWithPrevious => index > 0 && slider.ControlPoints[index - 1] == slider.ControlPoints[index]; private bool isSegmentSeparatorWithPrevious => index > 0 && slider.Path.ControlPoints[index - 1] == slider.Path.ControlPoints[index];
} }
} }

View File

@ -5,7 +5,7 @@ using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers; using osu.Framework.Graphics.Containers;
using osu.Game.Rulesets.Osu.Objects; using osu.Game.Rulesets.Osu.Objects;
namespace osu.Game.Rulesets.Osu.Edit.Masks.SliderMasks.Components namespace osu.Game.Rulesets.Osu.Edit.Blueprints.Sliders.Components
{ {
public class PathControlPointVisualiser : CompositeDrawable public class PathControlPointVisualiser : CompositeDrawable
{ {
@ -19,15 +19,15 @@ namespace osu.Game.Rulesets.Osu.Edit.Masks.SliderMasks.Components
InternalChild = pieces = new Container<PathControlPointPiece> { RelativeSizeAxes = Axes.Both }; InternalChild = pieces = new Container<PathControlPointPiece> { RelativeSizeAxes = Axes.Both };
slider.ControlPointsChanged += _ => updatePathControlPoints(); slider.PathChanged += _ => updatePathControlPoints();
updatePathControlPoints(); updatePathControlPoints();
} }
private void updatePathControlPoints() private void updatePathControlPoints()
{ {
while (slider.ControlPoints.Length > pieces.Count) while (slider.Path.ControlPoints.Length > pieces.Count)
pieces.Add(new PathControlPointPiece(slider, pieces.Count)); pieces.Add(new PathControlPointPiece(slider, pieces.Count));
while (slider.ControlPoints.Length < pieces.Count) while (slider.Path.ControlPoints.Length < pieces.Count)
pieces.Remove(pieces[pieces.Count - 1]); pieces.Remove(pieces[pieces.Count - 1]);
} }
} }

View File

@ -10,7 +10,7 @@ using osu.Game.Rulesets.Osu.Objects.Drawables.Pieces;
using OpenTK; using OpenTK;
using OpenTK.Graphics; using OpenTK.Graphics;
namespace osu.Game.Rulesets.Osu.Edit.Masks.SliderMasks.Components namespace osu.Game.Rulesets.Osu.Edit.Blueprints.Sliders.Components
{ {
public class SliderBodyPiece : CompositeDrawable public class SliderBodyPiece : CompositeDrawable
{ {
@ -45,8 +45,6 @@ namespace osu.Game.Rulesets.Osu.Edit.Masks.SliderMasks.Components
{ {
base.Update(); base.Update();
slider.Path.Calculate();
var vertices = new List<Vector2>(); var vertices = new List<Vector2>();
slider.Path.GetPathToProgress(vertices, 0, 1); slider.Path.GetPathToProgress(vertices, 0, 1);

View File

@ -1,10 +1,10 @@
// Copyright (c) 2007-2018 ppy Pty Ltd <contact@ppy.sh>. // Copyright (c) 2007-2018 ppy Pty Ltd <contact@ppy.sh>.
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE // Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
using osu.Game.Rulesets.Osu.Edit.Masks.HitCircleMasks.Components; using osu.Game.Rulesets.Osu.Edit.Blueprints.HitCircles.Components;
using osu.Game.Rulesets.Osu.Objects; using osu.Game.Rulesets.Osu.Objects;
namespace osu.Game.Rulesets.Osu.Edit.Masks.SliderMasks.Components namespace osu.Game.Rulesets.Osu.Edit.Blueprints.Sliders.Components
{ {
public class SliderCirclePiece : HitCirclePiece public class SliderCirclePiece : HitCirclePiece
{ {
@ -17,7 +17,7 @@ namespace osu.Game.Rulesets.Osu.Edit.Masks.SliderMasks.Components
this.slider = slider; this.slider = slider;
this.position = position; this.position = position;
slider.ControlPointsChanged += _ => UpdatePosition(); slider.PathChanged += _ => UpdatePosition();
} }
protected override void UpdatePosition() protected override void UpdatePosition()

View File

@ -1,18 +1,22 @@
// Copyright (c) 2007-2018 ppy Pty Ltd <contact@ppy.sh>. // Copyright (c) 2007-2018 ppy Pty Ltd <contact@ppy.sh>.
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE // Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
using osu.Game.Rulesets.Edit; using osu.Framework.Input.Events;
using osu.Game.Rulesets.Osu.Edit.Masks.SliderMasks.Components; using osu.Game.Rulesets.Osu.Edit.Blueprints.Sliders.Components;
using osu.Game.Rulesets.Osu.Objects; using osu.Game.Rulesets.Osu.Objects;
using osu.Game.Rulesets.Osu.Objects.Drawables; using osu.Game.Rulesets.Osu.Objects.Drawables;
namespace osu.Game.Rulesets.Osu.Edit.Masks.SliderMasks namespace osu.Game.Rulesets.Osu.Edit.Blueprints.Sliders
{ {
public class SliderCircleSelectionMask : SelectionMask public class SliderCircleSelectionBlueprint : OsuSelectionBlueprint
{ {
public SliderCircleSelectionMask(DrawableOsuHitObject hitObject, Slider slider, SliderPosition position) private readonly Slider slider;
public SliderCircleSelectionBlueprint(DrawableOsuHitObject hitObject, Slider slider, SliderPosition position)
: base(hitObject) : base(hitObject)
{ {
this.slider = slider;
InternalChild = new SliderCirclePiece(slider, position); InternalChild = new SliderCirclePiece(slider, position);
Select(); Select();
@ -20,5 +24,7 @@ namespace osu.Game.Rulesets.Osu.Edit.Masks.SliderMasks
// Todo: This is temporary, since the slider circle masks don't do anything special yet. In the future they will handle input. // Todo: This is temporary, since the slider circle masks don't do anything special yet. In the future they will handle input.
public override bool HandlePositionalInput => false; public override bool HandlePositionalInput => false;
public override void AdjustPosition(DragEvent dragEvent) => slider.Position += dragEvent.Delta;
} }
} }

View File

@ -1,24 +1,23 @@
// Copyright (c) 2007-2018 ppy Pty Ltd <contact@ppy.sh>. // Copyright (c) 2007-2018 ppy Pty Ltd <contact@ppy.sh>.
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE // Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
using osu.Framework.Allocation; using osu.Framework.Allocation;
using osu.Framework.Extensions.IEnumerableExtensions; using osu.Framework.Extensions.IEnumerableExtensions;
using osu.Framework.Graphics; using osu.Framework.Graphics;
using osu.Framework.Input.Events; using osu.Framework.Input.Events;
using osu.Framework.MathUtils;
using osu.Game.Graphics; using osu.Game.Graphics;
using osu.Game.Rulesets.Edit; using osu.Game.Rulesets.Edit;
using osu.Game.Rulesets.Objects;
using osu.Game.Rulesets.Objects.Types; using osu.Game.Rulesets.Objects.Types;
using osu.Game.Rulesets.Osu.Edit.Masks.SliderMasks.Components; using osu.Game.Rulesets.Osu.Edit.Blueprints.Sliders.Components;
using OpenTK; using OpenTK;
using OpenTK.Input; using OpenTK.Input;
namespace osu.Game.Rulesets.Osu.Edit.Masks.SliderMasks namespace osu.Game.Rulesets.Osu.Edit.Blueprints.Sliders
{ {
public class SliderPlacementMask : PlacementMask public class SliderPlacementBlueprint : PlacementBlueprint
{ {
public new Objects.Slider HitObject => (Objects.Slider)base.HitObject; public new Objects.Slider HitObject => (Objects.Slider)base.HitObject;
@ -27,7 +26,7 @@ namespace osu.Game.Rulesets.Osu.Edit.Masks.SliderMasks
private PlacementState state; private PlacementState state;
public SliderPlacementMask() public SliderPlacementBlueprint()
: base(new Objects.Slider()) : base(new Objects.Slider())
{ {
RelativeSizeAxes = Axes.Both; RelativeSizeAxes = Axes.Both;
@ -119,12 +118,8 @@ namespace osu.Game.Rulesets.Osu.Edit.Masks.SliderMasks
private void updateSlider() private void updateSlider()
{ {
for (int i = 0; i < segments.Count; i++) var newControlPoints = segments.SelectMany(s => s.ControlPoints).Concat(cursor.Yield()).ToArray();
segments[i].Calculate(i == segments.Count - 1 ? (Vector2?)cursor : null); HitObject.Path = new SliderPath(newControlPoints.Length > 2 ? PathType.Bezier : PathType.Linear, newControlPoints);
HitObject.ControlPoints = segments.SelectMany(s => s.ControlPoints).Concat(cursor.Yield()).ToArray();
HitObject.PathType = HitObject.ControlPoints.Length > 2 ? PathType.Bezier : PathType.Linear;
HitObject.Distance = segments.Sum(s => s.Distance);
} }
private void setState(PlacementState newState) private void setState(PlacementState newState)
@ -140,41 +135,12 @@ namespace osu.Game.Rulesets.Osu.Edit.Masks.SliderMasks
private class Segment private class Segment
{ {
public float Distance { get; private set; }
public readonly List<Vector2> ControlPoints = new List<Vector2>(); public readonly List<Vector2> ControlPoints = new List<Vector2>();
public Segment(Vector2 offset) public Segment(Vector2 offset)
{ {
ControlPoints.Add(offset); ControlPoints.Add(offset);
} }
public void Calculate(Vector2? cursor = null)
{
Span<Vector2> allControlPoints = stackalloc Vector2[ControlPoints.Count + (cursor.HasValue ? 1 : 0)];
for (int i = 0; i < ControlPoints.Count; i++)
allControlPoints[i] = ControlPoints[i];
if (cursor.HasValue)
allControlPoints[allControlPoints.Length - 1] = cursor.Value;
List<Vector2> result;
switch (allControlPoints.Length)
{
case 1:
case 2:
result = PathApproximator.ApproximateLinear(allControlPoints);
break;
default:
result = PathApproximator.ApproximateBezier(allControlPoints);
break;
}
Distance = 0;
for (int i = 0; i < result.Count - 1; i++)
Distance += Vector2.Distance(result[i], result[i + 1]);
}
} }
} }
} }

View File

@ -1,7 +1,7 @@
// Copyright (c) 2007-2018 ppy Pty Ltd <contact@ppy.sh>. // Copyright (c) 2007-2018 ppy Pty Ltd <contact@ppy.sh>.
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE // Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
namespace osu.Game.Rulesets.Osu.Edit.Masks.SliderMasks namespace osu.Game.Rulesets.Osu.Edit.Blueprints.Sliders
{ {
public enum SliderPosition public enum SliderPosition
{ {

View File

@ -0,0 +1,32 @@
// Copyright (c) 2007-2018 ppy Pty Ltd <contact@ppy.sh>.
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
using osu.Framework.Graphics;
using osu.Game.Rulesets.Osu.Edit.Blueprints.Sliders.Components;
using osu.Game.Rulesets.Osu.Objects;
using osu.Game.Rulesets.Osu.Objects.Drawables;
using OpenTK;
namespace osu.Game.Rulesets.Osu.Edit.Blueprints.Sliders
{
public class SliderSelectionBlueprint : OsuSelectionBlueprint
{
private readonly SliderCircleSelectionBlueprint headBlueprint;
public SliderSelectionBlueprint(DrawableSlider slider)
: base(slider)
{
var sliderObject = (Slider)slider.HitObject;
InternalChildren = new Drawable[]
{
new SliderBodyPiece(sliderObject),
headBlueprint = new SliderCircleSelectionBlueprint(slider.HeadCircle, sliderObject, SliderPosition.Start),
new SliderCircleSelectionBlueprint(slider.TailCircle, sliderObject, SliderPosition.End),
new PathControlPointVisualiser(sliderObject),
};
}
public override Vector2 SelectionPoint => headBlueprint.SelectionPoint;
}
}

View File

@ -10,7 +10,7 @@ using osu.Game.Rulesets.Osu.Objects;
using osu.Game.Rulesets.Osu.Objects.Drawables.Pieces; using osu.Game.Rulesets.Osu.Objects.Drawables.Pieces;
using OpenTK; using OpenTK;
namespace osu.Game.Rulesets.Osu.Edit.Masks.SpinnerMasks.Components namespace osu.Game.Rulesets.Osu.Edit.Blueprints.Spinners.Components
{ {
public class SpinnerPiece : CompositeDrawable public class SpinnerPiece : CompositeDrawable
{ {

View File

@ -4,13 +4,13 @@
using osu.Framework.Graphics; using osu.Framework.Graphics;
using osu.Framework.Input.Events; using osu.Framework.Input.Events;
using osu.Game.Rulesets.Edit; using osu.Game.Rulesets.Edit;
using osu.Game.Rulesets.Osu.Edit.Masks.SpinnerMasks.Components; using osu.Game.Rulesets.Osu.Edit.Blueprints.Spinners.Components;
using osu.Game.Rulesets.Osu.Objects; using osu.Game.Rulesets.Osu.Objects;
using osu.Game.Rulesets.Osu.UI; using osu.Game.Rulesets.Osu.UI;
namespace osu.Game.Rulesets.Osu.Edit.Masks.SpinnerMasks namespace osu.Game.Rulesets.Osu.Edit.Blueprints.Spinners
{ {
public class SpinnerPlacementMask : PlacementMask public class SpinnerPlacementBlueprint : PlacementBlueprint
{ {
public new Spinner HitObject => (Spinner)base.HitObject; public new Spinner HitObject => (Spinner)base.HitObject;
@ -18,7 +18,7 @@ namespace osu.Game.Rulesets.Osu.Edit.Masks.SpinnerMasks
private bool isPlacingEnd; private bool isPlacingEnd;
public SpinnerPlacementMask() public SpinnerPlacementBlueprint()
: base(new Spinner { Position = OsuPlayfield.BASE_SIZE / 2 }) : base(new Spinner { Position = OsuPlayfield.BASE_SIZE / 2 })
{ {
InternalChild = piece = new SpinnerPiece(HitObject) { Alpha = 0.5f }; InternalChild = piece = new SpinnerPiece(HitObject) { Alpha = 0.5f };

View File

@ -1,24 +1,29 @@
// Copyright (c) 2007-2018 ppy Pty Ltd <contact@ppy.sh>. // Copyright (c) 2007-2018 ppy Pty Ltd <contact@ppy.sh>.
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE // Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
using osu.Game.Rulesets.Edit; using osu.Framework.Input.Events;
using osu.Game.Rulesets.Osu.Edit.Masks.SpinnerMasks.Components; using osu.Game.Rulesets.Osu.Edit.Blueprints.Spinners.Components;
using osu.Game.Rulesets.Osu.Objects; using osu.Game.Rulesets.Osu.Objects;
using osu.Game.Rulesets.Osu.Objects.Drawables; using osu.Game.Rulesets.Osu.Objects.Drawables;
using OpenTK; using OpenTK;
namespace osu.Game.Rulesets.Osu.Edit.Masks.SpinnerMasks namespace osu.Game.Rulesets.Osu.Edit.Blueprints.Spinners
{ {
public class SpinnerSelectionMask : SelectionMask public class SpinnerSelectionBlueprint : OsuSelectionBlueprint
{ {
private readonly SpinnerPiece piece; private readonly SpinnerPiece piece;
public SpinnerSelectionMask(DrawableSpinner spinner) public SpinnerSelectionBlueprint(DrawableSpinner spinner)
: base(spinner) : base(spinner)
{ {
InternalChild = piece = new SpinnerPiece((Spinner)spinner.HitObject); InternalChild = piece = new SpinnerPiece((Spinner)spinner.HitObject);
} }
public override bool ReceivePositionalInputAt(Vector2 screenSpacePos) => piece.ReceivePositionalInputAt(screenSpacePos); public override bool ReceivePositionalInputAt(Vector2 screenSpacePos) => piece.ReceivePositionalInputAt(screenSpacePos);
public override void AdjustPosition(DragEvent dragEvent)
{
// Spinners don't support position adjustments
}
} }
} }

View File

@ -3,7 +3,7 @@
using osu.Game.Rulesets.Edit; using osu.Game.Rulesets.Edit;
using osu.Game.Rulesets.Edit.Tools; using osu.Game.Rulesets.Edit.Tools;
using osu.Game.Rulesets.Osu.Edit.Masks.HitCircleMasks; using osu.Game.Rulesets.Osu.Edit.Blueprints.HitCircles;
using osu.Game.Rulesets.Osu.Objects; using osu.Game.Rulesets.Osu.Objects;
namespace osu.Game.Rulesets.Osu.Edit namespace osu.Game.Rulesets.Osu.Edit
@ -15,6 +15,6 @@ namespace osu.Game.Rulesets.Osu.Edit
{ {
} }
public override PlacementMask CreatePlacementMask() => new HitCirclePlacementMask(); public override PlacementBlueprint CreatePlacementBlueprint() => new HitCirclePlacementBlueprint();
} }
} }

View File

@ -1,33 +0,0 @@
// Copyright (c) 2007-2018 ppy Pty Ltd <contact@ppy.sh>.
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
using osu.Framework.Graphics;
using osu.Game.Rulesets.Edit;
using osu.Game.Rulesets.Osu.Edit.Masks.SliderMasks.Components;
using osu.Game.Rulesets.Osu.Objects;
using osu.Game.Rulesets.Osu.Objects.Drawables;
using OpenTK;
namespace osu.Game.Rulesets.Osu.Edit.Masks.SliderMasks
{
public class SliderSelectionMask : SelectionMask
{
private readonly SliderCircleSelectionMask headMask;
public SliderSelectionMask(DrawableSlider slider)
: base(slider)
{
var sliderObject = (Slider)slider.HitObject;
InternalChildren = new Drawable[]
{
new SliderBodyPiece(sliderObject),
headMask = new SliderCircleSelectionMask(slider.HeadCircle, sliderObject, SliderPosition.Start),
new SliderCircleSelectionMask(slider.TailCircle, sliderObject, SliderPosition.End),
new PathControlPointVisualiser(sliderObject),
};
}
public override Vector2 SelectionPoint => headMask.SelectionPoint;
}
}

View File

@ -8,9 +8,9 @@ using osu.Game.Beatmaps;
using osu.Game.Rulesets.Edit; using osu.Game.Rulesets.Edit;
using osu.Game.Rulesets.Edit.Tools; using osu.Game.Rulesets.Edit.Tools;
using osu.Game.Rulesets.Objects.Drawables; using osu.Game.Rulesets.Objects.Drawables;
using osu.Game.Rulesets.Osu.Edit.Masks.HitCircleMasks; using osu.Game.Rulesets.Osu.Edit.Blueprints.HitCircles;
using osu.Game.Rulesets.Osu.Edit.Masks.SliderMasks; using osu.Game.Rulesets.Osu.Edit.Blueprints.Sliders;
using osu.Game.Rulesets.Osu.Edit.Masks.SpinnerMasks; using osu.Game.Rulesets.Osu.Edit.Blueprints.Spinners;
using osu.Game.Rulesets.Osu.Objects; using osu.Game.Rulesets.Osu.Objects;
using osu.Game.Rulesets.Osu.Objects.Drawables; using osu.Game.Rulesets.Osu.Objects.Drawables;
using osu.Game.Rulesets.Osu.UI; using osu.Game.Rulesets.Osu.UI;
@ -37,19 +37,19 @@ namespace osu.Game.Rulesets.Osu.Edit
protected override Container CreateLayerContainer() => new PlayfieldAdjustmentContainer { RelativeSizeAxes = Axes.Both }; protected override Container CreateLayerContainer() => new PlayfieldAdjustmentContainer { RelativeSizeAxes = Axes.Both };
public override SelectionMask CreateMaskFor(DrawableHitObject hitObject) public override SelectionBlueprint CreateBlueprintFor(DrawableHitObject hitObject)
{ {
switch (hitObject) switch (hitObject)
{ {
case DrawableHitCircle circle: case DrawableHitCircle circle:
return new HitCircleSelectionMask(circle); return new HitCircleSelectionBlueprint(circle);
case DrawableSlider slider: case DrawableSlider slider:
return new SliderSelectionMask(slider); return new SliderSelectionBlueprint(slider);
case DrawableSpinner spinner: case DrawableSpinner spinner:
return new SpinnerSelectionMask(spinner); return new SpinnerSelectionBlueprint(spinner);
} }
return base.CreateMaskFor(hitObject); return base.CreateBlueprintFor(hitObject);
} }
} }
} }

View File

@ -3,7 +3,7 @@
using osu.Game.Rulesets.Edit; using osu.Game.Rulesets.Edit;
using osu.Game.Rulesets.Edit.Tools; using osu.Game.Rulesets.Edit.Tools;
using osu.Game.Rulesets.Osu.Edit.Masks.SliderMasks; using osu.Game.Rulesets.Osu.Edit.Blueprints.Sliders;
using osu.Game.Rulesets.Osu.Objects; using osu.Game.Rulesets.Osu.Objects;
namespace osu.Game.Rulesets.Osu.Edit namespace osu.Game.Rulesets.Osu.Edit
@ -15,6 +15,6 @@ namespace osu.Game.Rulesets.Osu.Edit
{ {
} }
public override PlacementMask CreatePlacementMask() => new SliderPlacementMask(); public override PlacementBlueprint CreatePlacementBlueprint() => new SliderPlacementBlueprint();
} }
} }

View File

@ -3,7 +3,7 @@
using osu.Game.Rulesets.Edit; using osu.Game.Rulesets.Edit;
using osu.Game.Rulesets.Edit.Tools; using osu.Game.Rulesets.Edit.Tools;
using osu.Game.Rulesets.Osu.Edit.Masks.SpinnerMasks; using osu.Game.Rulesets.Osu.Edit.Blueprints.Spinners;
using osu.Game.Rulesets.Osu.Objects; using osu.Game.Rulesets.Osu.Objects;
namespace osu.Game.Rulesets.Osu.Edit namespace osu.Game.Rulesets.Osu.Edit
@ -15,6 +15,6 @@ namespace osu.Game.Rulesets.Osu.Edit
{ {
} }
public override PlacementMask CreatePlacementMask() => new SpinnerPlacementMask(); public override PlacementBlueprint CreatePlacementBlueprint() => new SpinnerPlacementBlueprint();
} }
} }

View File

@ -32,12 +32,11 @@ namespace osu.Game.Rulesets.Osu.Mods
slider.NestedHitObjects.OfType<SliderTick>().ForEach(h => h.Position = new Vector2(h.Position.X, OsuPlayfield.BASE_SIZE.Y - h.Position.Y)); slider.NestedHitObjects.OfType<SliderTick>().ForEach(h => h.Position = new Vector2(h.Position.X, OsuPlayfield.BASE_SIZE.Y - h.Position.Y));
slider.NestedHitObjects.OfType<RepeatPoint>().ForEach(h => h.Position = new Vector2(h.Position.X, OsuPlayfield.BASE_SIZE.Y - h.Position.Y)); slider.NestedHitObjects.OfType<RepeatPoint>().ForEach(h => h.Position = new Vector2(h.Position.X, OsuPlayfield.BASE_SIZE.Y - h.Position.Y));
var newControlPoints = new Vector2[slider.ControlPoints.Length]; var newControlPoints = new Vector2[slider.Path.ControlPoints.Length];
for (int i = 0; i < slider.ControlPoints.Length; i++) for (int i = 0; i < slider.Path.ControlPoints.Length; i++)
newControlPoints[i] = new Vector2(slider.ControlPoints[i].X, -slider.ControlPoints[i].Y); newControlPoints[i] = new Vector2(slider.Path.ControlPoints[i].X, -slider.Path.ControlPoints[i].Y);
slider.ControlPoints = newControlPoints; slider.Path = new SliderPath(slider.Path.Type, newControlPoints, slider.Path.ExpectedDistance);
slider.Path?.Calculate(); // Recalculate the slider curve
} }
} }
} }

View File

@ -91,7 +91,7 @@ namespace osu.Game.Rulesets.Osu.Objects.Drawables
Ball.Scale = new Vector2(HitObject.Scale); Ball.Scale = new Vector2(HitObject.Scale);
}; };
slider.ControlPointsChanged += _ => Body.Refresh(); slider.PathChanged += _ => Body.Refresh();
} }
public override Color4 AccentColour public override Color4 AccentColour

View File

@ -17,7 +17,7 @@ namespace osu.Game.Rulesets.Osu.Objects.Drawables
this.slider = slider; this.slider = slider;
h.PositionChanged += _ => updatePosition(); h.PositionChanged += _ => updatePosition();
slider.ControlPointsChanged += _ => updatePosition(); slider.PathChanged += _ => updatePosition();
updatePosition(); updatePosition();
} }

View File

@ -30,7 +30,7 @@ namespace osu.Game.Rulesets.Osu.Objects.Drawables
AlwaysPresent = true; AlwaysPresent = true;
hitCircle.PositionChanged += _ => updatePosition(); hitCircle.PositionChanged += _ => updatePosition();
slider.ControlPointsChanged += _ => updatePosition(); slider.PathChanged += _ => updatePosition();
updatePosition(); updatePosition();
} }

View File

@ -7,11 +7,10 @@ using osu.Game.Rulesets.Objects;
using OpenTK; using OpenTK;
using osu.Game.Rulesets.Objects.Types; using osu.Game.Rulesets.Objects.Types;
using osu.Game.Beatmaps.ControlPoints; using osu.Game.Beatmaps.ControlPoints;
using osu.Game.Rulesets.Edit.Types;
namespace osu.Game.Rulesets.Osu.Objects namespace osu.Game.Rulesets.Osu.Objects
{ {
public abstract class OsuHitObject : HitObject, IHasComboInformation, IHasEditablePosition public abstract class OsuHitObject : HitObject, IHasComboInformation, IHasPosition
{ {
public const double OBJECT_RADIUS = 64; public const double OBJECT_RADIUS = 64;
@ -100,8 +99,6 @@ namespace osu.Game.Rulesets.Osu.Objects
Scale = (1.0f - 0.7f * (difficulty.CircleSize - 5) / 5) / 2; Scale = (1.0f - 0.7f * (difficulty.CircleSize - 5) / 5) / 2;
} }
public virtual void OffsetPosition(Vector2 offset) => Position += offset;
protected override HitWindows CreateHitWindows() => new OsuHitWindows(); protected override HitWindows CreateHitWindows() => new OsuHitWindows();
} }
} }

View File

@ -22,7 +22,7 @@ namespace osu.Game.Rulesets.Osu.Objects
/// </summary> /// </summary>
private const float base_scoring_distance = 100; private const float base_scoring_distance = 100;
public event Action<Vector2[]> ControlPointsChanged; public event Action<SliderPath> PathChanged;
public double EndTime => StartTime + this.SpanCount() * Path.Distance / Velocity; public double EndTime => StartTime + this.SpanCount() * Path.Distance / Velocity;
public double Duration => EndTime - StartTime; public double Duration => EndTime - StartTime;
@ -52,35 +52,23 @@ namespace osu.Game.Rulesets.Osu.Objects
} }
} }
public SliderPath Path { get; } = new SliderPath(); private SliderPath path;
public Vector2[] ControlPoints public SliderPath Path
{ {
get => Path.ControlPoints; get => path;
set set
{ {
if (Path.ControlPoints == value) path = value;
return;
Path.ControlPoints = value;
ControlPointsChanged?.Invoke(value); PathChanged?.Invoke(value);
if (TailCircle != null) if (TailCircle != null)
TailCircle.Position = EndPosition; TailCircle.Position = EndPosition;
} }
} }
public PathType PathType public double Distance => Path.Distance;
{
get { return Path.PathType; }
set { Path.PathType = value; }
}
public double Distance
{
get { return Path.Distance; }
set { Path.Distance = value; }
}
public override Vector2 Position public override Vector2 Position
{ {
@ -111,7 +99,8 @@ namespace osu.Game.Rulesets.Osu.Objects
/// </summary> /// </summary>
internal float LazyTravelDistance; internal float LazyTravelDistance;
public List<List<SampleInfo>> RepeatSamples { get; set; } = new List<List<SampleInfo>>(); public List<List<SampleInfo>> NodeSamples { get; set; } = new List<List<SampleInfo>>();
public int RepeatCount { get; set; } public int RepeatCount { get; set; }
/// <summary> /// <summary>
@ -165,17 +154,17 @@ namespace osu.Game.Rulesets.Osu.Objects
private void createSliderEnds() private void createSliderEnds()
{ {
HeadCircle = new SliderCircle(this) HeadCircle = new SliderCircle
{ {
StartTime = StartTime, StartTime = StartTime,
Position = Position, Position = Position,
Samples = Samples, Samples = getNodeSamples(0),
SampleControlPoint = SampleControlPoint, SampleControlPoint = SampleControlPoint,
IndexInCurrentCombo = IndexInCurrentCombo, IndexInCurrentCombo = IndexInCurrentCombo,
ComboIndex = ComboIndex, ComboIndex = ComboIndex,
}; };
TailCircle = new SliderTailCircle(this) TailCircle = new SliderTailCircle
{ {
StartTime = EndTime, StartTime = EndTime,
Position = EndPosition, Position = EndPosition,
@ -249,11 +238,18 @@ namespace osu.Game.Rulesets.Osu.Objects
Position = Position + Path.PositionAt(repeat % 2), Position = Position + Path.PositionAt(repeat % 2),
StackHeight = StackHeight, StackHeight = StackHeight,
Scale = Scale, Scale = Scale,
Samples = new List<SampleInfo>(RepeatSamples[repeatIndex]) Samples = getNodeSamples(1 + repeatIndex)
}); });
} }
} }
private List<SampleInfo> getNodeSamples(int nodeIndex)
{
if (nodeIndex < NodeSamples.Count)
return NodeSamples[nodeIndex];
return Samples;
}
public override Judgement CreateJudgement() => new OsuJudgement(); public override Judgement CreateJudgement() => new OsuJudgement();
} }
} }

View File

@ -1,19 +1,9 @@
// Copyright (c) 2007-2018 ppy Pty Ltd <contact@ppy.sh>. // Copyright (c) 2007-2018 ppy Pty Ltd <contact@ppy.sh>.
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE // Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
using OpenTK;
namespace osu.Game.Rulesets.Osu.Objects namespace osu.Game.Rulesets.Osu.Objects
{ {
public class SliderCircle : HitCircle public class SliderCircle : HitCircle
{ {
private readonly Slider slider;
public SliderCircle(Slider slider)
{
this.slider = slider;
}
public override void OffsetPosition(Vector2 offset) => slider.OffsetPosition(offset);
} }
} }

View File

@ -8,11 +8,6 @@ namespace osu.Game.Rulesets.Osu.Objects
{ {
public class SliderTailCircle : SliderCircle public class SliderTailCircle : SliderCircle
{ {
public SliderTailCircle(Slider slider)
: base(slider)
{
}
public override Judgement CreateJudgement() => new OsuSliderTailJudgement(); public override Judgement CreateJudgement() => new OsuSliderTailJudgement();
} }
} }

View File

@ -7,7 +7,6 @@ using osu.Game.Rulesets.Objects.Types;
using osu.Game.Beatmaps.ControlPoints; using osu.Game.Beatmaps.ControlPoints;
using osu.Game.Rulesets.Judgements; using osu.Game.Rulesets.Judgements;
using osu.Game.Rulesets.Osu.Judgements; using osu.Game.Rulesets.Osu.Judgements;
using OpenTK;
namespace osu.Game.Rulesets.Osu.Objects namespace osu.Game.Rulesets.Osu.Objects
{ {
@ -32,10 +31,5 @@ namespace osu.Game.Rulesets.Osu.Objects
} }
public override Judgement CreateJudgement() => new OsuJudgement(); public override Judgement CreateJudgement() => new OsuJudgement();
public override void OffsetPosition(Vector2 offset)
{
// for now we don't want to allow spinners to be moved around.
}
} }
} }

View File

@ -4,7 +4,7 @@
<PackageReference Include="Appveyor.TestLogger" Version="2.0.0" /> <PackageReference Include="Appveyor.TestLogger" Version="2.0.0" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="15.9.0" /> <PackageReference Include="Microsoft.NET.Test.Sdk" Version="15.9.0" />
<PackageReference Include="NUnit" Version="3.11.0" /> <PackageReference Include="NUnit" Version="3.11.0" />
<PackageReference Include="NUnit3TestAdapter" Version="3.10.0" /> <PackageReference Include="NUnit3TestAdapter" Version="3.11.0" />
<PackageReference Update="Microsoft.EntityFrameworkCore.Sqlite" Version="2.1.4" /> <PackageReference Update="Microsoft.EntityFrameworkCore.Sqlite" Version="2.1.4" />
</ItemGroup> </ItemGroup>
<PropertyGroup Label="Project"> <PropertyGroup Label="Project">

View File

@ -117,7 +117,7 @@ namespace osu.Game.Rulesets.Taiko.Beatmaps
if (!isForCurrentRuleset && tickSpacing > 0 && osuDuration < 2 * speedAdjustedBeatLength) if (!isForCurrentRuleset && tickSpacing > 0 && osuDuration < 2 * speedAdjustedBeatLength)
{ {
List<List<SampleInfo>> allSamples = curveData != null ? curveData.RepeatSamples : new List<List<SampleInfo>>(new[] { samples }); List<List<SampleInfo>> allSamples = curveData != null ? curveData.NodeSamples : new List<List<SampleInfo>>(new[] { samples });
int i = 0; int i = 0;
for (double j = obj.StartTime; j <= obj.StartTime + taikoDuration + tickSpacing / 8; j += tickSpacing) for (double j = obj.StartTime; j <= obj.StartTime + taikoDuration + tickSpacing / 8; j += tickSpacing)

View File

@ -14,6 +14,7 @@ using osu.Game.Beatmaps.Formats;
using osu.Game.Beatmaps.Timing; using osu.Game.Beatmaps.Timing;
using osu.Game.Rulesets.Catch.Beatmaps; using osu.Game.Rulesets.Catch.Beatmaps;
using osu.Game.Rulesets.Objects; using osu.Game.Rulesets.Objects;
using osu.Game.Rulesets.Objects.Legacy;
using osu.Game.Rulesets.Osu; using osu.Game.Rulesets.Osu;
using osu.Game.Rulesets.Osu.Beatmaps; using osu.Game.Rulesets.Osu.Beatmaps;
using osu.Game.Skinning; using osu.Game.Skinning;
@ -333,5 +334,61 @@ namespace osu.Game.Tests.Beatmaps.Formats
SampleInfo getTestableSampleInfo(HitObject hitObject) => hitObject.SampleControlPoint.ApplyTo(hitObject.Samples[0]); SampleInfo getTestableSampleInfo(HitObject hitObject) => hitObject.SampleControlPoint.ApplyTo(hitObject.Samples[0]);
} }
[Test]
public void TestDecodeSliderSamples()
{
var decoder = new LegacyBeatmapDecoder { ApplyOffsets = false };
using (var resStream = Resource.OpenResource("slider-samples.osu"))
using (var stream = new StreamReader(resStream))
{
var hitObjects = decoder.Decode(stream).HitObjects;
var slider1 = (ConvertSlider)hitObjects[0];
Assert.AreEqual(1, slider1.NodeSamples[0].Count);
Assert.AreEqual(SampleInfo.HIT_NORMAL, slider1.NodeSamples[0][0].Name);
Assert.AreEqual(1, slider1.NodeSamples[1].Count);
Assert.AreEqual(SampleInfo.HIT_NORMAL, slider1.NodeSamples[1][0].Name);
Assert.AreEqual(1, slider1.NodeSamples[2].Count);
Assert.AreEqual(SampleInfo.HIT_NORMAL, slider1.NodeSamples[2][0].Name);
var slider2 = (ConvertSlider)hitObjects[1];
Assert.AreEqual(2, slider2.NodeSamples[0].Count);
Assert.AreEqual(SampleInfo.HIT_NORMAL, slider2.NodeSamples[0][0].Name);
Assert.AreEqual(SampleInfo.HIT_CLAP, slider2.NodeSamples[0][1].Name);
Assert.AreEqual(2, slider2.NodeSamples[1].Count);
Assert.AreEqual(SampleInfo.HIT_NORMAL, slider2.NodeSamples[1][0].Name);
Assert.AreEqual(SampleInfo.HIT_CLAP, slider2.NodeSamples[1][1].Name);
Assert.AreEqual(2, slider2.NodeSamples[2].Count);
Assert.AreEqual(SampleInfo.HIT_NORMAL, slider2.NodeSamples[2][0].Name);
Assert.AreEqual(SampleInfo.HIT_CLAP, slider2.NodeSamples[2][1].Name);
var slider3 = (ConvertSlider)hitObjects[2];
Assert.AreEqual(2, slider3.NodeSamples[0].Count);
Assert.AreEqual(SampleInfo.HIT_NORMAL, slider3.NodeSamples[0][0].Name);
Assert.AreEqual(SampleInfo.HIT_WHISTLE, slider3.NodeSamples[0][1].Name);
Assert.AreEqual(1, slider3.NodeSamples[1].Count);
Assert.AreEqual(SampleInfo.HIT_NORMAL, slider3.NodeSamples[1][0].Name);
Assert.AreEqual(2, slider3.NodeSamples[2].Count);
Assert.AreEqual(SampleInfo.HIT_NORMAL, slider3.NodeSamples[2][0].Name);
Assert.AreEqual(SampleInfo.HIT_CLAP, slider3.NodeSamples[2][1].Name);
}
}
[Test]
public void TestDecodeHitObjectNullAdditionBank()
{
var decoder = new LegacyBeatmapDecoder { ApplyOffsets = false };
using (var resStream = Resource.OpenResource("hitobject-no-addition-bank.osu"))
using (var stream = new StreamReader(resStream))
{
var hitObjects = decoder.Decode(stream).HitObjects;
Assert.AreEqual(hitObjects[0].Samples[0].Bank, hitObjects[0].Samples[1].Bank);
}
}
} }
} }

View File

@ -0,0 +1,4 @@
osu file format v14
[HitObjects]
444,320,1000,5,2,3:0:1:0:

View File

@ -0,0 +1,23 @@
osu file format v14
[General]
SampleSet: Normal
[Difficulty]
SliderMultiplier:1.6
SliderTickRate:2
[TimingPoints]
24735,389.61038961039,4,1,1,25,1,0
[HitObjects]
// Unified: Normal, Normal, Normal
168,256,30579,6,0,B|248:320|320:248,2,160
// Unified: Normal+Clap, Normal+Clap, Normal+Clap
168,256,32137,6,8,B|248:320|320:248,2,160
// Nodal: Normal+Whistle, Normal, Normal+Clap
// Nodal sounds should override the unified clap sound
168,256,33696,6,8,B|248:320|320:248,2,160,2|0|8

View File

@ -5,7 +5,8 @@ using System;
using System.Collections.Generic; using System.Collections.Generic;
using osu.Framework.Allocation; using osu.Framework.Allocation;
using osu.Framework.Graphics; using osu.Framework.Graphics;
using osu.Game.Screens.Edit.Screens.Compose; using osu.Game.Screens.Edit;
using osu.Game.Screens.Edit.Compose.Components;
using OpenTK; using OpenTK;
namespace osu.Game.Tests.Visual namespace osu.Game.Tests.Visual

View File

@ -6,7 +6,7 @@ using System.Collections.Generic;
using NUnit.Framework; using NUnit.Framework;
using osu.Framework.Allocation; using osu.Framework.Allocation;
using osu.Game.Rulesets.Osu; using osu.Game.Rulesets.Osu;
using osu.Game.Screens.Edit.Screens.Compose; using osu.Game.Screens.Edit.Compose;
using osu.Game.Tests.Beatmaps; using osu.Game.Tests.Beatmaps;
namespace osu.Game.Tests.Visual namespace osu.Game.Tests.Visual
@ -14,13 +14,13 @@ namespace osu.Game.Tests.Visual
[TestFixture] [TestFixture]
public class TestCaseEditorCompose : EditorClockTestCase public class TestCaseEditorCompose : EditorClockTestCase
{ {
public override IReadOnlyList<Type> RequiredTypes => new[] { typeof(Compose) }; public override IReadOnlyList<Type> RequiredTypes => new[] { typeof(ComposeScreen) };
[BackgroundDependencyLoader] [BackgroundDependencyLoader]
private void load() private void load()
{ {
Beatmap.Value = new TestWorkingBeatmap(new OsuRuleset().RulesetInfo); Beatmap.Value = new TestWorkingBeatmap(new OsuRuleset().RulesetInfo);
Child = new Compose(); Child = new ComposeScreen();
} }
} }
} }

View File

@ -5,7 +5,7 @@ using System;
using System.Collections.Generic; using System.Collections.Generic;
using NUnit.Framework; using NUnit.Framework;
using osu.Framework.Graphics; using osu.Framework.Graphics;
using osu.Game.Screens.Edit.Screens.Compose.RadioButtons; using osu.Game.Screens.Edit.Components.RadioButtons;
namespace osu.Game.Tests.Visual namespace osu.Game.Tests.Visual
{ {

View File

@ -13,7 +13,7 @@ using osu.Framework.Graphics.Shapes;
using osu.Framework.Graphics.UserInterface; using osu.Framework.Graphics.UserInterface;
using osu.Framework.Timing; using osu.Framework.Timing;
using osu.Game.Beatmaps; using osu.Game.Beatmaps;
using osu.Game.Screens.Edit.Screens.Compose.Timeline; using osu.Game.Screens.Edit.Compose.Components.Timeline;
using OpenTK.Graphics; using OpenTK.Graphics;
namespace osu.Game.Tests.Visual namespace osu.Game.Tests.Visual

View File

@ -8,7 +8,7 @@ using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers; using osu.Framework.Graphics.Containers;
using osu.Framework.Graphics.UserInterface; using osu.Framework.Graphics.UserInterface;
using osu.Game.Graphics.UserInterface; using osu.Game.Graphics.UserInterface;
using osu.Game.Screens.Edit.Menus; using osu.Game.Screens.Edit.Components.Menus;
namespace osu.Game.Tests.Visual namespace osu.Game.Tests.Visual
{ {

View File

@ -11,13 +11,14 @@ using OpenTK;
using osu.Game.Beatmaps; using osu.Game.Beatmaps;
using osu.Game.Rulesets.Edit; using osu.Game.Rulesets.Edit;
using osu.Game.Rulesets.Objects; using osu.Game.Rulesets.Objects;
using osu.Game.Rulesets.Objects.Types;
using osu.Game.Rulesets.Osu; using osu.Game.Rulesets.Osu;
using osu.Game.Rulesets.Osu.Edit; using osu.Game.Rulesets.Osu.Edit;
using osu.Game.Rulesets.Osu.Edit.Masks.HitCircleMasks; using osu.Game.Rulesets.Osu.Edit.Blueprints.HitCircles;
using osu.Game.Rulesets.Osu.Edit.Masks.HitCircleMasks.Components; using osu.Game.Rulesets.Osu.Edit.Blueprints.HitCircles.Components;
using osu.Game.Rulesets.Osu.Objects; using osu.Game.Rulesets.Osu.Objects;
using osu.Game.Screens.Edit.Screens.Compose; using osu.Game.Screens.Edit.Compose;
using osu.Game.Screens.Edit.Screens.Compose.Layers; using osu.Game.Screens.Edit.Compose.Components;
using osu.Game.Tests.Beatmaps; using osu.Game.Tests.Beatmaps;
namespace osu.Game.Tests.Visual namespace osu.Game.Tests.Visual
@ -28,15 +29,15 @@ namespace osu.Game.Tests.Visual
{ {
public override IReadOnlyList<Type> RequiredTypes => new[] public override IReadOnlyList<Type> RequiredTypes => new[]
{ {
typeof(MaskSelection), typeof(SelectionBox),
typeof(DragLayer), typeof(DragBox),
typeof(HitObjectComposer), typeof(HitObjectComposer),
typeof(OsuHitObjectComposer), typeof(OsuHitObjectComposer),
typeof(HitObjectMaskLayer), typeof(BlueprintContainer),
typeof(NotNullAttribute), typeof(NotNullAttribute),
typeof(HitCirclePiece), typeof(HitCirclePiece),
typeof(HitCircleSelectionMask), typeof(HitCircleSelectionBlueprint),
typeof(HitCirclePlacementMask), typeof(HitCirclePlacementBlueprint),
}; };
private HitObjectComposer composer; private HitObjectComposer composer;
@ -53,12 +54,11 @@ namespace osu.Game.Tests.Visual
new Slider new Slider
{ {
Position = new Vector2(128, 256), Position = new Vector2(128, 256),
ControlPoints = new[] Path = new SliderPath(PathType.Linear, new[]
{ {
Vector2.Zero, Vector2.Zero,
new Vector2(216, 0), new Vector2(216, 0),
}, }),
Distance = 216,
Scale = 0.5f, Scale = 0.5f,
} }
}, },

View File

@ -5,9 +5,9 @@ using NUnit.Framework;
using osu.Framework.Allocation; using osu.Framework.Allocation;
using osu.Framework.Graphics; using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers; using osu.Framework.Graphics.Containers;
using osu.Game.Screens.Edit.Screens.Setup.Components.LabelledComponents;
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using osu.Game.Screens.Edit.Setup.Components.LabelledComponents;
namespace osu.Game.Tests.Visual namespace osu.Game.Tests.Visual
{ {

View File

@ -10,7 +10,7 @@ using osu.Framework.Graphics.Shapes;
using osu.Framework.MathUtils; using osu.Framework.MathUtils;
using osu.Game.Graphics; using osu.Game.Graphics;
using osu.Game.Graphics.Cursor; using osu.Game.Graphics.Cursor;
using osu.Game.Screens.Edit.Screens.Compose.Timeline; using osu.Game.Screens.Edit.Compose.Components.Timeline;
using OpenTK; using OpenTK;
using OpenTK.Graphics; using OpenTK.Graphics;

View File

@ -5,7 +5,7 @@
<PackageReference Include="DeepEqual" Version="1.6.0" /> <PackageReference Include="DeepEqual" Version="1.6.0" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="15.9.0" /> <PackageReference Include="Microsoft.NET.Test.Sdk" Version="15.9.0" />
<PackageReference Include="NUnit" Version="3.11.0" /> <PackageReference Include="NUnit" Version="3.11.0" />
<PackageReference Include="NUnit3TestAdapter" Version="3.10.0" /> <PackageReference Include="NUnit3TestAdapter" Version="3.11.0" />
<PackageReference Update="Microsoft.EntityFrameworkCore.Sqlite" Version="2.1.4" /> <PackageReference Update="Microsoft.EntityFrameworkCore.Sqlite" Version="2.1.4" />
</ItemGroup> </ItemGroup>
<PropertyGroup Label="Project"> <PropertyGroup Label="Project">

View File

@ -16,8 +16,8 @@ using osu.Game.Rulesets.Edit.Tools;
using osu.Game.Rulesets.Objects; using osu.Game.Rulesets.Objects;
using osu.Game.Rulesets.Objects.Drawables; using osu.Game.Rulesets.Objects.Drawables;
using osu.Game.Rulesets.UI; using osu.Game.Rulesets.UI;
using osu.Game.Screens.Edit.Screens.Compose.Layers; using osu.Game.Screens.Edit.Components.RadioButtons;
using osu.Game.Screens.Edit.Screens.Compose.RadioButtons; using osu.Game.Screens.Edit.Compose.Components;
namespace osu.Game.Rulesets.Edit namespace osu.Game.Rulesets.Edit
{ {
@ -35,8 +35,7 @@ namespace osu.Game.Rulesets.Edit
private EditRulesetContainer rulesetContainer; private EditRulesetContainer rulesetContainer;
private HitObjectMaskLayer maskLayer; private BlueprintContainer blueprintContainer;
private PlacementContainer placementContainer;
internal HitObjectComposer(Ruleset ruleset) internal HitObjectComposer(Ruleset ruleset)
{ {
@ -62,14 +61,10 @@ namespace osu.Game.Rulesets.Edit
} }
var layerBelowRuleset = CreateLayerContainer(); var layerBelowRuleset = CreateLayerContainer();
layerBelowRuleset.Child = new BorderLayer { RelativeSizeAxes = Axes.Both }; layerBelowRuleset.Child = new EditorPlayfieldBorder { RelativeSizeAxes = Axes.Both };
var layerAboveRuleset = CreateLayerContainer(); var layerAboveRuleset = CreateLayerContainer();
layerAboveRuleset.Children = new Drawable[] layerAboveRuleset.Child = blueprintContainer = new BlueprintContainer();
{
maskLayer = new HitObjectMaskLayer(),
placementContainer = new PlacementContainer(),
};
layerContainers.Add(layerBelowRuleset); layerContainers.Add(layerBelowRuleset);
layerContainers.Add(layerAboveRuleset); layerContainers.Add(layerAboveRuleset);
@ -112,8 +107,8 @@ namespace osu.Game.Rulesets.Edit
}; };
toolboxCollection.Items = toolboxCollection.Items =
CompositionTools.Select(t => new RadioButton(t.Name, () => placementContainer.CurrentTool = t)) CompositionTools.Select(t => new RadioButton(t.Name, () => blueprintContainer.CurrentTool = t))
.Prepend(new RadioButton("Select", () => placementContainer.CurrentTool = null)) .Prepend(new RadioButton("Select", () => blueprintContainer.CurrentTool = null))
.ToList(); .ToList();
toolboxCollection.Items[0].Select(); toolboxCollection.Items[0].Select();
@ -146,29 +141,25 @@ namespace osu.Game.Rulesets.Edit
/// Adds a <see cref="HitObject"/> to the <see cref="Beatmaps.Beatmap"/> and visualises it. /// Adds a <see cref="HitObject"/> to the <see cref="Beatmaps.Beatmap"/> and visualises it.
/// </summary> /// </summary>
/// <param name="hitObject">The <see cref="HitObject"/> to add.</param> /// <param name="hitObject">The <see cref="HitObject"/> to add.</param>
public void Add(HitObject hitObject) public void Add(HitObject hitObject) => blueprintContainer.AddBlueprintFor(rulesetContainer.Add(hitObject));
{
maskLayer.AddMaskFor(rulesetContainer.Add(hitObject));
placementContainer.Refresh();
}
public void Remove(HitObject hitObject) => maskLayer.RemoveMaskFor(rulesetContainer.Remove(hitObject)); public void Remove(HitObject hitObject) => blueprintContainer.RemoveBlueprintFor(rulesetContainer.Remove(hitObject));
internal abstract EditRulesetContainer CreateRulesetContainer(); internal abstract EditRulesetContainer CreateRulesetContainer();
protected abstract IReadOnlyList<HitObjectCompositionTool> CompositionTools { get; } protected abstract IReadOnlyList<HitObjectCompositionTool> CompositionTools { get; }
/// <summary> /// <summary>
/// Creates a <see cref="SelectionMask"/> for a specific <see cref="DrawableHitObject"/>. /// Creates a <see cref="SelectionBlueprint"/> for a specific <see cref="DrawableHitObject"/>.
/// </summary> /// </summary>
/// <param name="hitObject">The <see cref="DrawableHitObject"/> to create the overlay for.</param> /// <param name="hitObject">The <see cref="DrawableHitObject"/> to create the overlay for.</param>
public virtual SelectionMask CreateMaskFor(DrawableHitObject hitObject) => null; public virtual SelectionBlueprint CreateBlueprintFor(DrawableHitObject hitObject) => null;
/// <summary> /// <summary>
/// Creates a <see cref="MaskSelection"/> which outlines <see cref="DrawableHitObject"/>s /// Creates a <see cref="SelectionBox"/> which outlines <see cref="DrawableHitObject"/>s
/// and handles hitobject pattern adjustments. /// and handles hitobject pattern adjustments.
/// </summary> /// </summary>
public virtual MaskSelection CreateMaskSelection() => new MaskSelection(); public virtual SelectionBox CreateSelectionBox() => new SelectionBox();
/// <summary> /// <summary>
/// Creates a <see cref="ScalableContainer"/> which provides a layer above or below the <see cref="Playfield"/>. /// Creates a <see cref="ScalableContainer"/> which provides a layer above or below the <see cref="Playfield"/>.

View File

@ -10,15 +10,15 @@ using osu.Framework.Input.Events;
using osu.Framework.Timing; using osu.Framework.Timing;
using osu.Game.Beatmaps; using osu.Game.Beatmaps;
using osu.Game.Rulesets.Objects; using osu.Game.Rulesets.Objects;
using osu.Game.Screens.Edit.Screens.Compose; using osu.Game.Screens.Edit.Compose;
using OpenTK; using OpenTK;
namespace osu.Game.Rulesets.Edit namespace osu.Game.Rulesets.Edit
{ {
/// <summary> /// <summary>
/// A mask which governs the creation of a new <see cref="HitObject"/> to actualisation. /// A blueprint which governs the creation of a new <see cref="HitObject"/> to actualisation.
/// </summary> /// </summary>
public abstract class PlacementMask : CompositeDrawable, IRequireHighFrequencyMousePosition public abstract class PlacementBlueprint : CompositeDrawable, IRequireHighFrequencyMousePosition
{ {
/// <summary> /// <summary>
/// The <see cref="HitObject"/> that is being placed. /// The <see cref="HitObject"/> that is being placed.
@ -32,7 +32,7 @@ namespace osu.Game.Rulesets.Edit
[Resolved] [Resolved]
private IPlacementHandler placementHandler { get; set; } private IPlacementHandler placementHandler { get; set; }
protected PlacementMask(HitObject hitObject) protected PlacementBlueprint(HitObject hitObject)
{ {
HitObject = hitObject; HitObject = hitObject;
@ -62,7 +62,7 @@ namespace osu.Game.Rulesets.Edit
/// <summary> /// <summary>
/// Signals that the placement of <see cref="HitObject"/> has finished. /// Signals that the placement of <see cref="HitObject"/> has finished.
/// This will destroy this <see cref="PlacementMask"/>, and add the <see cref="HitObject"/> to the <see cref="Beatmap"/>. /// This will destroy this <see cref="PlacementBlueprint"/>, and add the <see cref="HitObject"/> to the <see cref="Beatmap"/>.
/// </summary> /// </summary>
protected void EndPlacement() protected void EndPlacement()
{ {

View File

@ -15,33 +15,33 @@ using OpenTK;
namespace osu.Game.Rulesets.Edit namespace osu.Game.Rulesets.Edit
{ {
/// <summary> /// <summary>
/// A mask placed above a <see cref="DrawableHitObject"/> adding editing functionality. /// A blueprint placed above a <see cref="DrawableHitObject"/> adding editing functionality.
/// </summary> /// </summary>
public class SelectionMask : CompositeDrawable, IStateful<SelectionState> public abstract class SelectionBlueprint : CompositeDrawable, IStateful<SelectionState>
{ {
/// <summary> /// <summary>
/// Invoked when this <see cref="SelectionMask"/> has been selected. /// Invoked when this <see cref="SelectionBlueprint"/> has been selected.
/// </summary> /// </summary>
public event Action<SelectionMask> Selected; public event Action<SelectionBlueprint> Selected;
/// <summary> /// <summary>
/// Invoked when this <see cref="SelectionMask"/> has been deselected. /// Invoked when this <see cref="SelectionBlueprint"/> has been deselected.
/// </summary> /// </summary>
public event Action<SelectionMask> Deselected; public event Action<SelectionBlueprint> Deselected;
/// <summary> /// <summary>
/// Invoked when this <see cref="SelectionMask"/> has requested selection. /// Invoked when this <see cref="SelectionBlueprint"/> has requested selection.
/// Will fire even if already selected. Does not actually perform selection. /// Will fire even if already selected. Does not actually perform selection.
/// </summary> /// </summary>
public event Action<SelectionMask, InputState> SelectionRequested; public event Action<SelectionBlueprint, InputState> SelectionRequested;
/// <summary> /// <summary>
/// Invoked when this <see cref="SelectionMask"/> has requested drag. /// Invoked when this <see cref="SelectionBlueprint"/> has requested drag.
/// </summary> /// </summary>
public event Action<SelectionMask, Vector2, InputState> DragRequested; public event Action<DragEvent> DragRequested;
/// <summary> /// <summary>
/// The <see cref="DrawableHitObject"/> which this <see cref="SelectionMask"/> applies to. /// The <see cref="DrawableHitObject"/> which this <see cref="SelectionBlueprint"/> applies to.
/// </summary> /// </summary>
public readonly DrawableHitObject HitObject; public readonly DrawableHitObject HitObject;
@ -49,7 +49,7 @@ namespace osu.Game.Rulesets.Edit
public override bool HandlePositionalInput => ShouldBeAlive; public override bool HandlePositionalInput => ShouldBeAlive;
public override bool RemoveWhenNotAlive => false; public override bool RemoveWhenNotAlive => false;
public SelectionMask(DrawableHitObject hitObject) protected SelectionBlueprint(DrawableHitObject hitObject)
{ {
HitObject = hitObject; HitObject = hitObject;
@ -86,12 +86,12 @@ namespace osu.Game.Rulesets.Edit
} }
/// <summary> /// <summary>
/// Selects this <see cref="SelectionMask"/>, causing it to become visible. /// Selects this <see cref="SelectionBlueprint"/>, causing it to become visible.
/// </summary> /// </summary>
public void Select() => State = SelectionState.Selected; public void Select() => State = SelectionState.Selected;
/// <summary> /// <summary>
/// Deselects this <see cref="SelectionMask"/>, causing it to become invisible. /// Deselects this <see cref="SelectionBlueprint"/>, causing it to become invisible.
/// </summary> /// </summary>
public void Deselect() => State = SelectionState.NotSelected; public void Deselect() => State = SelectionState.NotSelected;
@ -130,17 +130,19 @@ namespace osu.Game.Rulesets.Edit
protected override bool OnDrag(DragEvent e) protected override bool OnDrag(DragEvent e)
{ {
DragRequested?.Invoke(this, e.Delta, e.CurrentState); DragRequested?.Invoke(e);
return true; return true;
} }
public abstract void AdjustPosition(DragEvent dragEvent);
/// <summary> /// <summary>
/// The screen-space point that causes this <see cref="SelectionMask"/> to be selected. /// The screen-space point that causes this <see cref="SelectionBlueprint"/> to be selected.
/// </summary> /// </summary>
public virtual Vector2 SelectionPoint => HitObject.ScreenSpaceDrawQuad.Centre; public virtual Vector2 SelectionPoint => HitObject.ScreenSpaceDrawQuad.Centre;
/// <summary> /// <summary>
/// The screen-space quad that outlines this <see cref="SelectionMask"/> for selections. /// The screen-space quad that outlines this <see cref="SelectionBlueprint"/> for selections.
/// </summary> /// </summary>
public virtual Quad SelectionQuad => HitObject.ScreenSpaceDrawQuad; public virtual Quad SelectionQuad => HitObject.ScreenSpaceDrawQuad;
} }

View File

@ -12,6 +12,6 @@ namespace osu.Game.Rulesets.Edit.Tools
Name = name; Name = name;
} }
public abstract PlacementMask CreatePlacementMask(); public abstract PlacementBlueprint CreatePlacementBlueprint();
} }
} }

View File

@ -1,13 +0,0 @@
// Copyright (c) 2007-2018 ppy Pty Ltd <contact@ppy.sh>.
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
using osu.Game.Rulesets.Objects.Types;
using OpenTK;
namespace osu.Game.Rulesets.Edit.Types
{
public interface IHasEditablePosition : IHasPosition
{
void OffsetPosition(Vector2 offset);
}
}

View File

@ -7,7 +7,6 @@ using System.Linq;
using osu.Framework.Allocation; using osu.Framework.Allocation;
using osu.Framework.Configuration; using osu.Framework.Configuration;
using osu.Framework.Extensions.TypeExtensions; using osu.Framework.Extensions.TypeExtensions;
using osu.Framework.Graphics;
using osu.Framework.Graphics.Primitives; using osu.Framework.Graphics.Primitives;
using osu.Game.Audio; using osu.Game.Audio;
using osu.Game.Graphics; using osu.Game.Graphics;
@ -167,13 +166,7 @@ namespace osu.Game.Rulesets.Objects.Drawables
} }
} }
public override bool UpdateSubTreeMasking(Drawable source, RectangleF maskingBounds) protected override bool ComputeIsMaskedAway(RectangleF maskingBounds) => AllJudged && base.ComputeIsMaskedAway(maskingBounds);
{
if (!AllJudged)
return false;
return base.UpdateSubTreeMasking(source, maskingBounds);
}
protected override void UpdateAfterChildren() protected override void UpdateAfterChildren()
{ {

View File

@ -3,7 +3,6 @@
using System.Collections.Generic; using System.Collections.Generic;
using Newtonsoft.Json; using Newtonsoft.Json;
using osu.Framework.Lists;
using osu.Game.Audio; using osu.Game.Audio;
using osu.Game.Beatmaps; using osu.Game.Beatmaps;
using osu.Game.Beatmaps.ControlPoints; using osu.Game.Beatmaps.ControlPoints;
@ -56,7 +55,7 @@ namespace osu.Game.Rulesets.Objects
/// </summary> /// </summary>
public HitWindows HitWindows { get; set; } public HitWindows HitWindows { get; set; }
private readonly SortedList<HitObject> nestedHitObjects = new SortedList<HitObject>(compareObjects); private readonly List<HitObject> nestedHitObjects = new List<HitObject>();
[JsonIgnore] [JsonIgnore]
public IReadOnlyList<HitObject> NestedHitObjects => nestedHitObjects; public IReadOnlyList<HitObject> NestedHitObjects => nestedHitObjects;
@ -74,6 +73,8 @@ namespace osu.Game.Rulesets.Objects
CreateNestedHitObjects(); CreateNestedHitObjects();
nestedHitObjects.Sort((h1, h2) => h1.StartTime.CompareTo(h2.StartTime));
foreach (var h in nestedHitObjects) foreach (var h in nestedHitObjects)
{ {
h.HitWindows = HitWindows; h.HitWindows = HitWindows;
@ -114,7 +115,5 @@ namespace osu.Game.Rulesets.Objects
/// </para> /// </para>
/// </summary> /// </summary>
protected virtual HitWindows CreateHitWindows() => new HitWindows(); protected virtual HitWindows CreateHitWindows() => new HitWindows();
private static int compareObjects(HitObject first, HitObject second) => first.StartTime.CompareTo(second.StartTime);
} }
} }

View File

@ -37,7 +37,7 @@ namespace osu.Game.Rulesets.Objects.Legacy.Catch
}; };
} }
protected override HitObject CreateSlider(Vector2 position, bool newCombo, int comboOffset, Vector2[] controlPoints, double length, PathType pathType, int repeatCount, List<List<SampleInfo>> repeatSamples) protected override HitObject CreateSlider(Vector2 position, bool newCombo, int comboOffset, Vector2[] controlPoints, double length, PathType pathType, int repeatCount, List<List<SampleInfo>> nodeSamples)
{ {
newCombo |= forceNewCombo; newCombo |= forceNewCombo;
comboOffset += extraComboOffset; comboOffset += extraComboOffset;
@ -50,10 +50,8 @@ namespace osu.Game.Rulesets.Objects.Legacy.Catch
X = position.X, X = position.X,
NewCombo = FirstObject || newCombo, NewCombo = FirstObject || newCombo,
ComboOffset = comboOffset, ComboOffset = comboOffset,
ControlPoints = controlPoints, Path = new SliderPath(pathType, controlPoints, length),
Distance = length, NodeSamples = nodeSamples,
PathType = pathType,
RepeatSamples = repeatSamples,
RepeatCount = repeatCount RepeatCount = repeatCount
}; };
} }

View File

@ -179,6 +179,9 @@ namespace osu.Game.Rulesets.Objects.Legacy
nodeSamples.Add(convertSoundType(nodeSoundTypes[i], nodeBankInfos[i])); nodeSamples.Add(convertSoundType(nodeSoundTypes[i], nodeBankInfos[i]));
result = CreateSlider(pos, combo, comboOffset, points, length, pathType, repeatCount, nodeSamples); result = CreateSlider(pos, combo, comboOffset, points, length, pathType, repeatCount, nodeSamples);
// The samples are played when the slider ends, which is the last node
result.Samples = nodeSamples[nodeSamples.Count - 1];
} }
else if (type.HasFlag(ConvertHitObjectType.Spinner)) else if (type.HasFlag(ConvertHitObjectType.Spinner))
{ {
@ -210,6 +213,8 @@ namespace osu.Game.Rulesets.Objects.Legacy
} }
result.StartTime = Convert.ToDouble(split[2], CultureInfo.InvariantCulture) + Offset; result.StartTime = Convert.ToDouble(split[2], CultureInfo.InvariantCulture) + Offset;
if (result.Samples.Count == 0)
result.Samples = convertSoundType(soundType, bankInfo); result.Samples = convertSoundType(soundType, bankInfo);
FirstObject = false; FirstObject = false;
@ -240,7 +245,7 @@ namespace osu.Game.Rulesets.Objects.Legacy
stringAddBank = null; stringAddBank = null;
bankInfo.Normal = stringBank; bankInfo.Normal = stringBank;
bankInfo.Add = stringAddBank; bankInfo.Add = string.IsNullOrEmpty(stringAddBank) ? stringBank : stringAddBank;
if (split.Length > 2) if (split.Length > 2)
bankInfo.CustomSampleBank = int.Parse(split[2]); bankInfo.CustomSampleBank = int.Parse(split[2]);
@ -270,9 +275,9 @@ namespace osu.Game.Rulesets.Objects.Legacy
/// <param name="length">The slider length.</param> /// <param name="length">The slider length.</param>
/// <param name="pathType">The slider curve type.</param> /// <param name="pathType">The slider curve type.</param>
/// <param name="repeatCount">The slider repeat count.</param> /// <param name="repeatCount">The slider repeat count.</param>
/// <param name="repeatSamples">The samples to be played when the repeat nodes are hit. This includes the head and tail of the slider.</param> /// <param name="nodeSamples">The samples to be played when the slider nodes are hit. This includes the head and tail of the slider.</param>
/// <returns>The hit object.</returns> /// <returns>The hit object.</returns>
protected abstract HitObject CreateSlider(Vector2 position, bool newCombo, int comboOffset, Vector2[] controlPoints, double length, PathType pathType, int repeatCount, List<List<SampleInfo>> repeatSamples); protected abstract HitObject CreateSlider(Vector2 position, bool newCombo, int comboOffset, Vector2[] controlPoints, double length, PathType pathType, int repeatCount, List<List<SampleInfo>> nodeSamples);
/// <summary> /// <summary>
/// Creates a legacy Spinner-type hit object. /// Creates a legacy Spinner-type hit object.

View File

@ -3,7 +3,6 @@
using osu.Game.Rulesets.Objects.Types; using osu.Game.Rulesets.Objects.Types;
using System.Collections.Generic; using System.Collections.Generic;
using OpenTK;
using osu.Game.Audio; using osu.Game.Audio;
using osu.Game.Beatmaps; using osu.Game.Beatmaps;
using osu.Game.Beatmaps.ControlPoints; using osu.Game.Beatmaps.ControlPoints;
@ -20,13 +19,11 @@ namespace osu.Game.Rulesets.Objects.Legacy
/// <summary> /// <summary>
/// <see cref="ConvertSlider"/>s don't need a curve since they're converted to ruleset-specific hitobjects. /// <see cref="ConvertSlider"/>s don't need a curve since they're converted to ruleset-specific hitobjects.
/// </summary> /// </summary>
public SliderPath Path { get; } = null; public SliderPath Path { get; set; }
public Vector2[] ControlPoints { get; set; }
public PathType PathType { get; set; }
public double Distance { get; set; } public double Distance => Path.Distance;
public List<List<SampleInfo>> RepeatSamples { get; set; } public List<List<SampleInfo>> NodeSamples { get; set; }
public int RepeatCount { get; set; } public int RepeatCount { get; set; }
public double EndTime => StartTime + this.SpanCount() * Distance / Velocity; public double EndTime => StartTime + this.SpanCount() * Distance / Velocity;

View File

@ -26,15 +26,13 @@ namespace osu.Game.Rulesets.Objects.Legacy.Mania
}; };
} }
protected override HitObject CreateSlider(Vector2 position, bool newCombo, int comboOffset, Vector2[] controlPoints, double length, PathType pathType, int repeatCount, List<List<SampleInfo>> repeatSamples) protected override HitObject CreateSlider(Vector2 position, bool newCombo, int comboOffset, Vector2[] controlPoints, double length, PathType pathType, int repeatCount, List<List<SampleInfo>> nodeSamples)
{ {
return new ConvertSlider return new ConvertSlider
{ {
X = position.X, X = position.X,
ControlPoints = controlPoints, Path = new SliderPath(pathType, controlPoints, length),
Distance = length, NodeSamples = nodeSamples,
PathType = pathType,
RepeatSamples = repeatSamples,
RepeatCount = repeatCount RepeatCount = repeatCount
}; };
} }

View File

@ -38,7 +38,7 @@ namespace osu.Game.Rulesets.Objects.Legacy.Osu
}; };
} }
protected override HitObject CreateSlider(Vector2 position, bool newCombo, int comboOffset, Vector2[] controlPoints, double length, PathType pathType, int repeatCount, List<List<SampleInfo>> repeatSamples) protected override HitObject CreateSlider(Vector2 position, bool newCombo, int comboOffset, Vector2[] controlPoints, double length, PathType pathType, int repeatCount, List<List<SampleInfo>> nodeSamples)
{ {
newCombo |= forceNewCombo; newCombo |= forceNewCombo;
comboOffset += extraComboOffset; comboOffset += extraComboOffset;
@ -51,10 +51,8 @@ namespace osu.Game.Rulesets.Objects.Legacy.Osu
Position = position, Position = position,
NewCombo = FirstObject || newCombo, NewCombo = FirstObject || newCombo,
ComboOffset = comboOffset, ComboOffset = comboOffset,
ControlPoints = controlPoints, Path = new SliderPath(pathType, controlPoints, Math.Max(0, length)),
Distance = Math.Max(0, length), NodeSamples = nodeSamples,
PathType = pathType,
RepeatSamples = repeatSamples,
RepeatCount = repeatCount RepeatCount = repeatCount
}; };
} }

View File

@ -23,14 +23,12 @@ namespace osu.Game.Rulesets.Objects.Legacy.Taiko
return new ConvertHit(); return new ConvertHit();
} }
protected override HitObject CreateSlider(Vector2 position, bool newCombo, int comboOffset, Vector2[] controlPoints, double length, PathType pathType, int repeatCount, List<List<SampleInfo>> repeatSamples) protected override HitObject CreateSlider(Vector2 position, bool newCombo, int comboOffset, Vector2[] controlPoints, double length, PathType pathType, int repeatCount, List<List<SampleInfo>> nodeSamples)
{ {
return new ConvertSlider return new ConvertSlider
{ {
ControlPoints = controlPoints, Path = new SliderPath(pathType, controlPoints, length),
Distance = length, NodeSamples = nodeSamples,
PathType = pathType,
RepeatSamples = repeatSamples,
RepeatCount = repeatCount RepeatCount = repeatCount
}; };
} }

View File

@ -4,28 +4,140 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
using Newtonsoft.Json;
using osu.Framework.MathUtils; using osu.Framework.MathUtils;
using osu.Game.Rulesets.Objects.Types; using osu.Game.Rulesets.Objects.Types;
using OpenTK; using OpenTK;
namespace osu.Game.Rulesets.Objects namespace osu.Game.Rulesets.Objects
{ {
public class SliderPath public struct SliderPath : IEquatable<SliderPath>
{ {
public double Distance; /// <summary>
/// The user-set distance of the path. If non-null, <see cref="Distance"/> will match this value,
/// and the path will be shortened/lengthened to match this length.
/// </summary>
public readonly double? ExpectedDistance;
public Vector2[] ControlPoints = Array.Empty<Vector2>(); /// <summary>
/// The type of path.
/// </summary>
public readonly PathType Type;
public PathType PathType = PathType.PerfectCurve; [JsonProperty]
private Vector2[] controlPoints;
public Vector2 Offset; private List<Vector2> calculatedPath;
private List<double> cumulativeLength;
private readonly List<Vector2> calculatedPath = new List<Vector2>(); private bool isInitialised;
private readonly List<double> cumulativeLength = new List<double>();
/// <summary>
/// Creates a new <see cref="SliderPath"/>.
/// </summary>
/// <param name="type">The type of path.</param>
/// <param name="controlPoints">The control points of the path.</param>
/// <param name="expectedDistance">A user-set distance of the path that may be shorter or longer than the true distance between all
/// <paramref name="controlPoints"/>. The path will be shortened/lengthened to match this length.
/// If null, the path will use the true distance between all <paramref name="controlPoints"/>.</param>
[JsonConstructor]
public SliderPath(PathType type, Vector2[] controlPoints, double? expectedDistance = null)
{
this = default;
this.controlPoints = controlPoints;
Type = type;
ExpectedDistance = expectedDistance;
ensureInitialised();
}
/// <summary>
/// The control points of the path.
/// </summary>
[JsonIgnore]
public ReadOnlySpan<Vector2> ControlPoints
{
get
{
ensureInitialised();
return controlPoints.AsSpan();
}
}
/// <summary>
/// The distance of the path after lengthening/shortening to account for <see cref="ExpectedDistance"/>.
/// </summary>
[JsonIgnore]
public double Distance
{
get
{
ensureInitialised();
return cumulativeLength.Count == 0 ? 0 : cumulativeLength[cumulativeLength.Count - 1];
}
}
/// <summary>
/// Computes the slider path until a given progress that ranges from 0 (beginning of the slider)
/// to 1 (end of the slider) and stores the generated path in the given list.
/// </summary>
/// <param name="path">The list to be filled with the computed path.</param>
/// <param name="p0">Start progress. Ranges from 0 (beginning of the slider) to 1 (end of the slider).</param>
/// <param name="p1">End progress. Ranges from 0 (beginning of the slider) to 1 (end of the slider).</param>
public void GetPathToProgress(List<Vector2> path, double p0, double p1)
{
ensureInitialised();
double d0 = progressToDistance(p0);
double d1 = progressToDistance(p1);
path.Clear();
int i = 0;
for (; i < calculatedPath.Count && cumulativeLength[i] < d0; ++i)
{
}
path.Add(interpolateVertices(i, d0));
for (; i < calculatedPath.Count && cumulativeLength[i] <= d1; ++i)
path.Add(calculatedPath[i]);
path.Add(interpolateVertices(i, d1));
}
/// <summary>
/// Computes the position on the slider at a given progress that ranges from 0 (beginning of the path)
/// to 1 (end of the path).
/// </summary>
/// <param name="progress">Ranges from 0 (beginning of the path) to 1 (end of the path).</param>
/// <returns></returns>
public Vector2 PositionAt(double progress)
{
ensureInitialised();
double d = progressToDistance(progress);
return interpolateVertices(indexOfDistance(d), d);
}
private void ensureInitialised()
{
if (isInitialised)
return;
isInitialised = true;
controlPoints = controlPoints ?? Array.Empty<Vector2>();
calculatedPath = new List<Vector2>();
cumulativeLength = new List<double>();
calculatePath();
calculateCumulativeLength();
}
private List<Vector2> calculateSubpath(ReadOnlySpan<Vector2> subControlPoints) private List<Vector2> calculateSubpath(ReadOnlySpan<Vector2> subControlPoints)
{ {
switch (PathType) switch (Type)
{ {
case PathType.Linear: case PathType.Linear:
return PathApproximator.ApproximateLinear(subControlPoints); return PathApproximator.ApproximateLinear(subControlPoints);
@ -66,7 +178,7 @@ namespace osu.Game.Rulesets.Objects
if (i == ControlPoints.Length - 1 || ControlPoints[i] == ControlPoints[i + 1]) if (i == ControlPoints.Length - 1 || ControlPoints[i] == ControlPoints[i + 1])
{ {
ReadOnlySpan<Vector2> cpSpan = ControlPoints.AsSpan().Slice(start, end - start); ReadOnlySpan<Vector2> cpSpan = ControlPoints.Slice(start, end - start);
foreach (Vector2 t in calculateSubpath(cpSpan)) foreach (Vector2 t in calculateSubpath(cpSpan))
if (calculatedPath.Count == 0 || calculatedPath.Last() != t) if (calculatedPath.Count == 0 || calculatedPath.Last() != t)
@ -77,49 +189,6 @@ namespace osu.Game.Rulesets.Objects
} }
} }
private void calculateCumulativeLengthAndTrimPath()
{
double l = 0;
cumulativeLength.Clear();
cumulativeLength.Add(l);
for (int i = 0; i < calculatedPath.Count - 1; ++i)
{
Vector2 diff = calculatedPath[i + 1] - calculatedPath[i];
double d = diff.Length;
// Shorten slider paths that are too long compared to what's
// in the .osu file.
if (Distance - l < d)
{
calculatedPath[i + 1] = calculatedPath[i] + diff * (float)((Distance - l) / d);
calculatedPath.RemoveRange(i + 2, calculatedPath.Count - 2 - i);
l = Distance;
cumulativeLength.Add(l);
break;
}
l += d;
cumulativeLength.Add(l);
}
// Lengthen slider paths that are too short compared to what's
// in the .osu file.
if (l < Distance && calculatedPath.Count > 1)
{
Vector2 diff = calculatedPath[calculatedPath.Count - 1] - calculatedPath[calculatedPath.Count - 2];
double d = diff.Length;
if (d <= 0)
return;
calculatedPath[calculatedPath.Count - 1] += diff * (float)((Distance - l) / d);
cumulativeLength[calculatedPath.Count - 1] = Distance;
}
}
private void calculateCumulativeLength() private void calculateCumulativeLength()
{ {
double l = 0; double l = 0;
@ -132,21 +201,33 @@ namespace osu.Game.Rulesets.Objects
Vector2 diff = calculatedPath[i + 1] - calculatedPath[i]; Vector2 diff = calculatedPath[i + 1] - calculatedPath[i];
double d = diff.Length; double d = diff.Length;
// Shorted slider paths that are too long compared to the expected distance
if (ExpectedDistance.HasValue && ExpectedDistance - l < d)
{
calculatedPath[i + 1] = calculatedPath[i] + diff * (float)((ExpectedDistance - l) / d);
calculatedPath.RemoveRange(i + 2, calculatedPath.Count - 2 - i);
l = ExpectedDistance.Value;
cumulativeLength.Add(l);
break;
}
l += d; l += d;
cumulativeLength.Add(l); cumulativeLength.Add(l);
} }
Distance = l; // Lengthen slider paths that are too short compared to the expected distance
} if (ExpectedDistance.HasValue && l < ExpectedDistance && calculatedPath.Count > 1)
public void Calculate(bool updateDistance = false)
{ {
calculatePath(); Vector2 diff = calculatedPath[calculatedPath.Count - 1] - calculatedPath[calculatedPath.Count - 2];
double d = diff.Length;
if (!updateDistance) if (d <= 0)
calculateCumulativeLengthAndTrimPath(); return;
else
calculateCumulativeLength(); calculatedPath[calculatedPath.Count - 1] += diff * (float)((ExpectedDistance - l) / d);
cumulativeLength[calculatedPath.Count - 1] = ExpectedDistance.Value;
}
} }
private int indexOfDistance(double d) private int indexOfDistance(double d)
@ -169,7 +250,7 @@ namespace osu.Game.Rulesets.Objects
if (i <= 0) if (i <= 0)
return calculatedPath.First(); return calculatedPath.First();
else if (i >= calculatedPath.Count) if (i >= calculatedPath.Count)
return calculatedPath.Last(); return calculatedPath.Last();
Vector2 p0 = calculatedPath[i - 1]; Vector2 p0 = calculatedPath[i - 1];
@ -186,47 +267,20 @@ namespace osu.Game.Rulesets.Objects
return p0 + (p1 - p0) * (float)w; return p0 + (p1 - p0) * (float)w;
} }
/// <summary> public bool Equals(SliderPath other)
/// Computes the slider path until a given progress that ranges from 0 (beginning of the slider)
/// to 1 (end of the slider) and stores the generated path in the given list.
/// </summary>
/// <param name="path">The list to be filled with the computed path.</param>
/// <param name="p0">Start progress. Ranges from 0 (beginning of the slider) to 1 (end of the slider).</param>
/// <param name="p1">End progress. Ranges from 0 (beginning of the slider) to 1 (end of the slider).</param>
public void GetPathToProgress(List<Vector2> path, double p0, double p1)
{ {
if (calculatedPath.Count == 0 && ControlPoints.Length > 0) if (ControlPoints == null && other.ControlPoints != null)
Calculate(); return false;
if (other.ControlPoints == null && ControlPoints != null)
return false;
double d0 = progressToDistance(p0); return ControlPoints.SequenceEqual(other.ControlPoints) && ExpectedDistance.Equals(other.ExpectedDistance) && Type == other.Type;
double d1 = progressToDistance(p1);
path.Clear();
int i = 0;
for (; i < calculatedPath.Count && cumulativeLength[i] < d0; ++i) { }
path.Add(interpolateVertices(i, d0) + Offset);
for (; i < calculatedPath.Count && cumulativeLength[i] <= d1; ++i)
path.Add(calculatedPath[i] + Offset);
path.Add(interpolateVertices(i, d1) + Offset);
} }
/// <summary> public override bool Equals(object obj)
/// Computes the position on the slider at a given progress that ranges from 0 (beginning of the path)
/// to 1 (end of the path).
/// </summary>
/// <param name="progress">Ranges from 0 (beginning of the path) to 1 (end of the path).</param>
/// <returns></returns>
public Vector2 PositionAt(double progress)
{ {
if (calculatedPath.Count == 0 && ControlPoints.Length > 0) if (ReferenceEquals(null, obj)) return false;
Calculate(); return obj is SliderPath other && Equals(other);
double d = progressToDistance(progress);
return interpolateVertices(indexOfDistance(d), d) + Offset;
} }
} }
} }

View File

@ -14,16 +14,6 @@ namespace osu.Game.Rulesets.Objects.Types
/// The curve. /// The curve.
/// </summary> /// </summary>
SliderPath Path { get; } SliderPath Path { get; }
/// <summary>
/// The control points that shape the curve.
/// </summary>
Vector2[] ControlPoints { get; }
/// <summary>
/// The type of curve.
/// </summary>
PathType PathType { get; }
} }
public static class HasCurveExtensions public static class HasCurveExtensions

View File

@ -17,9 +17,15 @@ namespace osu.Game.Rulesets.Objects.Types
int RepeatCount { get; } int RepeatCount { get; }
/// <summary> /// <summary>
/// The samples to be played when each repeat node is hit (0 -> first repeat node, 1 -> second repeat node, etc). /// The samples to be played when each node of the <see cref="IHasRepeats"/> is hit.<br />
/// 0: The first node.<br />
/// 1: The first repeat.<br />
/// 2: The second repeat.<br />
/// ...<br />
/// n-1: The last repeat.<br />
/// n: The last node.
/// </summary> /// </summary>
List<List<SampleInfo>> RepeatSamples { get; } List<List<SampleInfo>> NodeSamples { get; }
} }
public static class HasRepeatsExtensions public static class HasRepeatsExtensions

View File

@ -5,7 +5,7 @@ using System;
using System.Linq; using System.Linq;
using osu.Framework.Configuration; using osu.Framework.Configuration;
namespace osu.Game.Screens.Edit.Screens.Compose namespace osu.Game.Screens.Edit
{ {
public class BindableBeatDivisor : BindableNumber<int> public class BindableBeatDivisor : BindableNumber<int>
{ {

View File

@ -2,19 +2,18 @@
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE // Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
using osu.Framework.Allocation; using osu.Framework.Allocation;
using osu.Framework.Configuration;
using osu.Framework.Graphics; using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers; using osu.Framework.Graphics.Containers;
using osu.Framework.Graphics.Shapes; using osu.Framework.Graphics.Shapes;
using osu.Framework.Graphics.UserInterface; using osu.Framework.Graphics.UserInterface;
using osu.Framework.Input.Events;
using osu.Game.Graphics; using osu.Game.Graphics;
using osu.Game.Graphics.UserInterface; using osu.Game.Graphics.UserInterface;
using OpenTK; using OpenTK;
using OpenTK.Graphics; using OpenTK.Graphics;
using osu.Framework.Configuration;
using osu.Framework.Input.Events;
using osu.Game.Screens.Edit.Screens;
namespace osu.Game.Screens.Edit.Menus namespace osu.Game.Screens.Edit.Components.Menus
{ {
public class EditorMenuBar : OsuMenu public class EditorMenuBar : OsuMenu
{ {

View File

@ -4,7 +4,7 @@
using System; using System;
using osu.Game.Graphics.UserInterface; using osu.Game.Graphics.UserInterface;
namespace osu.Game.Screens.Edit.Menus namespace osu.Game.Screens.Edit.Components.Menus
{ {
public class EditorMenuItem : OsuMenuItem public class EditorMenuItem : OsuMenuItem
{ {

View File

@ -1,7 +1,7 @@
// Copyright (c) 2007-2018 ppy Pty Ltd <contact@ppy.sh>. // Copyright (c) 2007-2018 ppy Pty Ltd <contact@ppy.sh>.
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE // Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
namespace osu.Game.Screens.Edit.Menus namespace osu.Game.Screens.Edit.Components.Menus
{ {
public class EditorMenuItemSpacer : EditorMenuItem public class EditorMenuItemSpacer : EditorMenuItem
{ {

View File

@ -1,7 +1,6 @@
// Copyright (c) 2007-2018 ppy Pty Ltd <contact@ppy.sh>. // Copyright (c) 2007-2018 ppy Pty Ltd <contact@ppy.sh>.
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE // Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
using OpenTK.Graphics;
using osu.Framework.Allocation; using osu.Framework.Allocation;
using osu.Framework.Extensions.Color4Extensions; using osu.Framework.Extensions.Color4Extensions;
using osu.Framework.Graphics; using osu.Framework.Graphics;
@ -9,10 +8,10 @@ using osu.Framework.Graphics.Shapes;
using osu.Framework.Graphics.UserInterface; using osu.Framework.Graphics.UserInterface;
using osu.Game.Graphics; using osu.Game.Graphics;
using osu.Game.Graphics.UserInterface; using osu.Game.Graphics.UserInterface;
using osu.Game.Screens.Edit.Screens;
using OpenTK; using OpenTK;
using OpenTK.Graphics;
namespace osu.Game.Screens.Edit.Menus namespace osu.Game.Screens.Edit.Components.Menus
{ {
public class ScreenSelectionTabControl : OsuTabControl<EditorScreenMode> public class ScreenSelectionTabControl : OsuTabControl<EditorScreenMode>
{ {

View File

@ -2,8 +2,6 @@
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE // Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
using System; using System;
using OpenTK;
using OpenTK.Graphics;
using osu.Framework.Allocation; using osu.Framework.Allocation;
using osu.Framework.Extensions.Color4Extensions; using osu.Framework.Extensions.Color4Extensions;
using osu.Framework.Graphics; using osu.Framework.Graphics;
@ -14,8 +12,10 @@ using osu.Framework.Input.Events;
using osu.Game.Graphics; using osu.Game.Graphics;
using osu.Game.Graphics.Sprites; using osu.Game.Graphics.Sprites;
using osu.Game.Graphics.UserInterface; using osu.Game.Graphics.UserInterface;
using OpenTK;
using OpenTK.Graphics;
namespace osu.Game.Screens.Edit.Screens.Compose.RadioButtons namespace osu.Game.Screens.Edit.Components.RadioButtons
{ {
public class DrawableRadioButton : TriangleButton public class DrawableRadioButton : TriangleButton
{ {

View File

@ -4,7 +4,7 @@
using System; using System;
using osu.Framework.Configuration; using osu.Framework.Configuration;
namespace osu.Game.Screens.Edit.Screens.Compose.RadioButtons namespace osu.Game.Screens.Edit.Components.RadioButtons
{ {
public class RadioButton public class RadioButton
{ {

View File

@ -2,12 +2,12 @@
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE // Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
using System.Collections.Generic; using System.Collections.Generic;
using OpenTK;
using osu.Framework.Extensions.IEnumerableExtensions; using osu.Framework.Extensions.IEnumerableExtensions;
using osu.Framework.Graphics; using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers; using osu.Framework.Graphics.Containers;
using OpenTK;
namespace osu.Game.Screens.Edit.Screens.Compose.RadioButtons namespace osu.Game.Screens.Edit.Components.RadioButtons
{ {
public class RadioButtonCollection : CompositeDrawable public class RadioButtonCollection : CompositeDrawable
{ {

View File

@ -7,6 +7,7 @@ using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers; using osu.Framework.Graphics.Containers;
using osu.Framework.Graphics.Shapes; using osu.Framework.Graphics.Shapes;
using osu.Framework.Input.Events; using osu.Framework.Input.Events;
using osu.Framework.Threading;
using osu.Framework.Timing; using osu.Framework.Timing;
using osu.Game.Beatmaps; using osu.Game.Beatmaps;
using osu.Game.Graphics; using osu.Game.Graphics;
@ -43,17 +44,23 @@ namespace osu.Game.Screens.Edit.Components.Timelines.Summary.Parts
return true; return true;
} }
private ScheduledDelegate scheduledSeek;
/// <summary> /// <summary>
/// Seeks the <see cref="SummaryTimeline"/> to the time closest to a position on the screen relative to the <see cref="SummaryTimeline"/>. /// Seeks the <see cref="SummaryTimeline"/> to the time closest to a position on the screen relative to the <see cref="SummaryTimeline"/>.
/// </summary> /// </summary>
/// <param name="screenPosition">The position in screen coordinates.</param> /// <param name="screenPosition">The position in screen coordinates.</param>
private void seekToPosition(Vector2 screenPosition) private void seekToPosition(Vector2 screenPosition)
{
scheduledSeek?.Cancel();
scheduledSeek = Schedule(() =>
{ {
if (Beatmap.Value == null) if (Beatmap.Value == null)
return; return;
float markerPos = MathHelper.Clamp(ToLocalSpace(screenPosition).X, 0, DrawWidth); float markerPos = MathHelper.Clamp(ToLocalSpace(screenPosition).X, 0, DrawWidth);
adjustableClock.Seek(markerPos / DrawWidth * Beatmap.Value.Track.Length); adjustableClock.Seek(markerPos / DrawWidth * Beatmap.Value.Track.Length);
});
} }
protected override void Update() protected override void Update()

View File

@ -19,7 +19,7 @@ using OpenTK;
using OpenTK.Graphics; using OpenTK.Graphics;
using OpenTK.Input; using OpenTK.Input;
namespace osu.Game.Screens.Edit.Screens.Compose namespace osu.Game.Screens.Edit.Compose.Components
{ {
public class BeatDivisorControl : CompositeDrawable public class BeatDivisorControl : CompositeDrawable
{ {

View File

@ -0,0 +1,191 @@
// Copyright (c) 2007-2018 ppy Pty Ltd <contact@ppy.sh>.
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
using System.Collections.Generic;
using System.Linq;
using osu.Framework.Allocation;
using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers;
using osu.Framework.Graphics.Primitives;
using osu.Framework.Input.Events;
using osu.Framework.Input.States;
using osu.Game.Rulesets.Edit;
using osu.Game.Rulesets.Edit.Tools;
using osu.Game.Rulesets.Objects.Drawables;
namespace osu.Game.Screens.Edit.Compose.Components
{
public class BlueprintContainer : CompositeDrawable
{
private SelectionBlueprintContainer selectionBlueprints;
private Container<PlacementBlueprint> placementBlueprintContainer;
private SelectionBox selectionBox;
private IEnumerable<SelectionBlueprint> selections => selectionBlueprints.Children.Where(c => c.IsAlive);
[Resolved]
private HitObjectComposer composer { get; set; }
public BlueprintContainer()
{
RelativeSizeAxes = Axes.Both;
}
[BackgroundDependencyLoader]
private void load()
{
selectionBox = composer.CreateSelectionBox();
selectionBox.DeselectAll = deselectAll;
var dragBox = new DragBox(select);
dragBox.DragEnd += () => selectionBox.UpdateVisibility();
InternalChildren = new[]
{
dragBox,
selectionBox,
selectionBlueprints = new SelectionBlueprintContainer { RelativeSizeAxes = Axes.Both },
placementBlueprintContainer = new Container<PlacementBlueprint> { RelativeSizeAxes = Axes.Both },
dragBox.CreateProxy()
};
foreach (var obj in composer.HitObjects)
AddBlueprintFor(obj);
}
private HitObjectCompositionTool currentTool;
/// <summary>
/// The current placement tool.
/// </summary>
public HitObjectCompositionTool CurrentTool
{
get => currentTool;
set
{
if (currentTool == value)
return;
currentTool = value;
refreshTool();
}
}
/// <summary>
/// Adds a blueprint for a <see cref="DrawableHitObject"/> which adds movement support.
/// </summary>
/// <param name="hitObject">The <see cref="DrawableHitObject"/> to create a blueprint for.</param>
public void AddBlueprintFor(DrawableHitObject hitObject)
{
refreshTool();
var blueprint = composer.CreateBlueprintFor(hitObject);
if (blueprint == null)
return;
blueprint.Selected += onBlueprintSelected;
blueprint.Deselected += onBlueprintDeselected;
blueprint.SelectionRequested += onSelectionRequested;
blueprint.DragRequested += onDragRequested;
selectionBlueprints.Add(blueprint);
}
/// <summary>
/// Removes a blueprint for a <see cref="DrawableHitObject"/>.
/// </summary>
/// <param name="hitObject">The <see cref="DrawableHitObject"/> for which to remove the blueprint.</param>
public void RemoveBlueprintFor(DrawableHitObject hitObject)
{
var blueprint = selectionBlueprints.Single(m => m.HitObject == hitObject);
if (blueprint == null)
return;
blueprint.Deselect();
blueprint.Selected -= onBlueprintSelected;
blueprint.Deselected -= onBlueprintDeselected;
blueprint.SelectionRequested -= onSelectionRequested;
blueprint.DragRequested -= onDragRequested;
selectionBlueprints.Remove(blueprint);
}
protected override bool OnClick(ClickEvent e)
{
deselectAll();
return true;
}
/// <summary>
/// Refreshes the current placement tool.
/// </summary>
private void refreshTool()
{
placementBlueprintContainer.Clear();
var blueprint = CurrentTool?.CreatePlacementBlueprint();
if (blueprint != null)
placementBlueprintContainer.Child = blueprint;
}
/// <summary>
/// Select all masks in a given rectangle selection area.
/// </summary>
/// <param name="rect">The rectangle to perform a selection on in screen-space coordinates.</param>
private void select(RectangleF rect)
{
foreach (var blueprint in selections.ToList())
{
if (blueprint.IsPresent && rect.Contains(blueprint.SelectionPoint))
blueprint.Select();
else
blueprint.Deselect();
}
}
/// <summary>
/// Deselects all selected <see cref="SelectionBlueprint"/>s.
/// </summary>
private void deselectAll() => selections.ToList().ForEach(m => m.Deselect());
private void onBlueprintSelected(SelectionBlueprint blueprint)
{
selectionBox.HandleSelected(blueprint);
selectionBlueprints.ChangeChildDepth(blueprint, 1);
}
private void onBlueprintDeselected(SelectionBlueprint blueprint)
{
selectionBox.HandleDeselected(blueprint);
selectionBlueprints.ChangeChildDepth(blueprint, 0);
}
private void onSelectionRequested(SelectionBlueprint blueprint, InputState state) => selectionBox.HandleSelectionRequested(blueprint, state);
private void onDragRequested(DragEvent dragEvent) => selectionBox.HandleDrag(dragEvent);
private class SelectionBlueprintContainer : Container<SelectionBlueprint>
{
protected override int Compare(Drawable x, Drawable y)
{
if (!(x is SelectionBlueprint xBlueprint) || !(y is SelectionBlueprint yBlueprint))
return base.Compare(x, y);
return Compare(xBlueprint, yBlueprint);
}
public int Compare(SelectionBlueprint x, SelectionBlueprint y)
{
// dpeth is used to denote selected status (we always want selected blueprints to handle input first).
int d = x.Depth.CompareTo(y.Depth);
if (d != 0)
return d;
// Put earlier hitobjects towards the end of the list, so they handle input first
int i = y.HitObject.HitObject.StartTime.CompareTo(x.HitObject.HitObject.StartTime);
return i == 0 ? CompareReverseChildID(x, y) : i;
}
}
}
}

View File

@ -8,15 +8,14 @@ using osu.Framework.Graphics.Containers;
using osu.Framework.Graphics.Primitives; using osu.Framework.Graphics.Primitives;
using osu.Framework.Graphics.Shapes; using osu.Framework.Graphics.Shapes;
using osu.Framework.Input.Events; using osu.Framework.Input.Events;
using osu.Game.Rulesets.Edit;
using OpenTK.Graphics; using OpenTK.Graphics;
namespace osu.Game.Screens.Edit.Screens.Compose.Layers namespace osu.Game.Screens.Edit.Compose.Components
{ {
/// <summary> /// <summary>
/// A layer that handles and displays drag selection for a collection of <see cref="SelectionMask"/>s. /// A box that displays the drag selection and provides selection events for users to handle.
/// </summary> /// </summary>
public class DragLayer : CompositeDrawable public class DragBox : CompositeDrawable
{ {
private readonly Action<RectangleF> performSelection; private readonly Action<RectangleF> performSelection;
@ -28,10 +27,10 @@ namespace osu.Game.Screens.Edit.Screens.Compose.Layers
private Drawable box; private Drawable box;
/// <summary> /// <summary>
/// Creates a new <see cref="DragLayer"/>. /// Creates a new <see cref="DragBox"/>.
/// </summary> /// </summary>
/// <param name="maskContainer">The selectable <see cref="SelectionMask"/>s.</param> /// <param name="performSelection">A delegate that performs drag selection.</param>
public DragLayer(Action<RectangleF> performSelection) public DragBox(Action<RectangleF> performSelection)
{ {
this.performSelection = performSelection; this.performSelection = performSelection;
@ -47,7 +46,7 @@ namespace osu.Game.Screens.Edit.Screens.Compose.Layers
{ {
Masking = true, Masking = true,
BorderColour = Color4.White, BorderColour = Color4.White,
BorderThickness = MaskSelection.BORDER_RADIUS, BorderThickness = SelectionBox.BORDER_RADIUS,
Child = new Box Child = new Box
{ {
RelativeSizeAxes = Axes.Both, RelativeSizeAxes = Axes.Both,

View File

@ -0,0 +1,32 @@
// Copyright (c) 2007-2018 ppy Pty Ltd <contact@ppy.sh>.
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers;
using osu.Framework.Graphics.Shapes;
using OpenTK.Graphics;
namespace osu.Game.Screens.Edit.Compose.Components
{
/// <summary>
/// Provides a border around the playfield.
/// </summary>
public class EditorPlayfieldBorder : CompositeDrawable
{
public EditorPlayfieldBorder()
{
RelativeSizeAxes = Axes.Both;
Masking = true;
BorderColour = Color4.White;
BorderThickness = 2;
InternalChild = new Box
{
RelativeSizeAxes = Axes.Both,
Alpha = 0,
AlwaysPresent = true
};
}
}
}

View File

@ -12,29 +12,28 @@ using osu.Framework.Input.Events;
using osu.Framework.Input.States; using osu.Framework.Input.States;
using osu.Game.Graphics; using osu.Game.Graphics;
using osu.Game.Rulesets.Edit; using osu.Game.Rulesets.Edit;
using osu.Game.Rulesets.Edit.Types;
using OpenTK; using OpenTK;
using OpenTK.Input; using OpenTK.Input;
namespace osu.Game.Screens.Edit.Screens.Compose.Layers namespace osu.Game.Screens.Edit.Compose.Components
{ {
/// <summary> /// <summary>
/// A box which surrounds <see cref="SelectionMask"/>s and provides interactive handles, context menus etc. /// A box which surrounds <see cref="SelectionBlueprint"/>s and provides interactive handles, context menus etc.
/// </summary> /// </summary>
public class MaskSelection : CompositeDrawable public class SelectionBox : CompositeDrawable
{ {
public const float BORDER_RADIUS = 2; public const float BORDER_RADIUS = 2;
private readonly List<SelectionMask> selectedMasks; private readonly List<SelectionBlueprint> selectedBlueprints;
private Drawable outline; private Drawable outline;
[Resolved] [Resolved]
private IPlacementHandler placementHandler { get; set; } private IPlacementHandler placementHandler { get; set; }
public MaskSelection() public SelectionBox()
{ {
selectedMasks = new List<SelectionMask>(); selectedBlueprints = new List<SelectionBlueprint>();
RelativeSizeAxes = Axes.Both; RelativeSizeAxes = Axes.Both;
AlwaysPresent = true; AlwaysPresent = true;
@ -60,19 +59,12 @@ namespace osu.Game.Screens.Edit.Screens.Compose.Layers
#region User Input Handling #region User Input Handling
public void HandleDrag(SelectionMask m, Vector2 delta, InputState state) public void HandleDrag(DragEvent dragEvent)
{ {
// Todo: Various forms of snapping // Todo: Various forms of snapping
foreach (var mask in selectedMasks) foreach (var blueprint in selectedBlueprints)
{ blueprint.AdjustPosition(dragEvent);
switch (mask.HitObject.HitObject)
{
case IHasEditablePosition editablePosition:
editablePosition.OffsetPosition(delta);
break;
}
}
} }
protected override bool OnKeyDown(KeyDownEvent e) protected override bool OnKeyDown(KeyDownEvent e)
@ -83,7 +75,7 @@ namespace osu.Game.Screens.Edit.Screens.Compose.Layers
switch (e.Key) switch (e.Key)
{ {
case Key.Delete: case Key.Delete:
foreach (var h in selectedMasks.ToList()) foreach (var h in selectedBlueprints.ToList())
placementHandler.Delete(h.HitObject.HitObject); placementHandler.Delete(h.HitObject.HitObject);
return true; return true;
} }
@ -96,49 +88,49 @@ namespace osu.Game.Screens.Edit.Screens.Compose.Layers
#region Selection Handling #region Selection Handling
/// <summary> /// <summary>
/// Bind an action to deselect all selected masks. /// Bind an action to deselect all selected blueprints.
/// </summary> /// </summary>
public Action DeselectAll { private get; set; } public Action DeselectAll { private get; set; }
/// <summary> /// <summary>
/// Handle a mask becoming selected. /// Handle a blueprint becoming selected.
/// </summary> /// </summary>
/// <param name="mask">The mask.</param> /// <param name="blueprint">The blueprint.</param>
public void HandleSelected(SelectionMask mask) => selectedMasks.Add(mask); public void HandleSelected(SelectionBlueprint blueprint) => selectedBlueprints.Add(blueprint);
/// <summary> /// <summary>
/// Handle a mask becoming deselected. /// Handle a blueprint becoming deselected.
/// </summary> /// </summary>
/// <param name="mask">The mask.</param> /// <param name="blueprint">The blueprint.</param>
public void HandleDeselected(SelectionMask mask) public void HandleDeselected(SelectionBlueprint blueprint)
{ {
selectedMasks.Remove(mask); selectedBlueprints.Remove(blueprint);
// We don't want to update visibility if > 0, since we may be deselecting masks during drag-selection // We don't want to update visibility if > 0, since we may be deselecting blueprints during drag-selection
if (selectedMasks.Count == 0) if (selectedBlueprints.Count == 0)
UpdateVisibility(); UpdateVisibility();
} }
/// <summary> /// <summary>
/// Handle a mask requesting selection. /// Handle a blueprint requesting selection.
/// </summary> /// </summary>
/// <param name="mask">The mask.</param> /// <param name="blueprint">The blueprint.</param>
public void HandleSelectionRequested(SelectionMask mask, InputState state) public void HandleSelectionRequested(SelectionBlueprint blueprint, InputState state)
{ {
if (state.Keyboard.ControlPressed) if (state.Keyboard.ControlPressed)
{ {
if (mask.IsSelected) if (blueprint.IsSelected)
mask.Deselect(); blueprint.Deselect();
else else
mask.Select(); blueprint.Select();
} }
else else
{ {
if (mask.IsSelected) if (blueprint.IsSelected)
return; return;
DeselectAll?.Invoke(); DeselectAll?.Invoke();
mask.Select(); blueprint.Select();
} }
UpdateVisibility(); UpdateVisibility();
@ -147,11 +139,11 @@ namespace osu.Game.Screens.Edit.Screens.Compose.Layers
#endregion #endregion
/// <summary> /// <summary>
/// Updates whether this <see cref="MaskSelection"/> is visible. /// Updates whether this <see cref="SelectionBox"/> is visible.
/// </summary> /// </summary>
internal void UpdateVisibility() internal void UpdateVisibility()
{ {
if (selectedMasks.Count > 0) if (selectedBlueprints.Count > 0)
Show(); Show();
else else
Hide(); Hide();
@ -161,7 +153,7 @@ namespace osu.Game.Screens.Edit.Screens.Compose.Layers
{ {
base.Update(); base.Update();
if (selectedMasks.Count == 0) if (selectedBlueprints.Count == 0)
return; return;
// Move the rectangle to cover the hitobjects // Move the rectangle to cover the hitobjects
@ -170,10 +162,10 @@ namespace osu.Game.Screens.Edit.Screens.Compose.Layers
bool hasSelection = false; bool hasSelection = false;
foreach (var mask in selectedMasks) foreach (var blueprint in selectedBlueprints)
{ {
topLeft = Vector2.ComponentMin(topLeft, ToLocalSpace(mask.SelectionQuad.TopLeft)); topLeft = Vector2.ComponentMin(topLeft, ToLocalSpace(blueprint.SelectionQuad.TopLeft));
bottomRight = Vector2.ComponentMax(bottomRight, ToLocalSpace(mask.SelectionQuad.BottomRight)); bottomRight = Vector2.ComponentMax(bottomRight, ToLocalSpace(blueprint.SelectionQuad.BottomRight));
} }
topLeft -= new Vector2(5); topLeft -= new Vector2(5);

Some files were not shown because too many files have changed in this diff Show More