diff --git a/osu.Android.props b/osu.Android.props
index 5b200ee104..d2bdbc8b61 100644
--- a/osu.Android.props
+++ b/osu.Android.props
@@ -51,7 +51,7 @@
-
-
+
+
diff --git a/osu.Game.Benchmarks/osu.Game.Benchmarks.csproj b/osu.Game.Benchmarks/osu.Game.Benchmarks.csproj
index f2e1c0ec3b..88fe8f1150 100644
--- a/osu.Game.Benchmarks/osu.Game.Benchmarks.csproj
+++ b/osu.Game.Benchmarks/osu.Game.Benchmarks.csproj
@@ -7,7 +7,7 @@
-
+
diff --git a/osu.Game.Rulesets.Catch.Tests/TestSceneHyperDashColouring.cs b/osu.Game.Rulesets.Catch.Tests/TestSceneHyperDashColouring.cs
new file mode 100644
index 0000000000..a48ecb9b79
--- /dev/null
+++ b/osu.Game.Rulesets.Catch.Tests/TestSceneHyperDashColouring.cs
@@ -0,0 +1,132 @@
+// Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence.
+// See the LICENCE file in the repository root for full licence text.
+
+using System.Linq;
+using NUnit.Framework;
+using osu.Framework.Allocation;
+using osu.Framework.Graphics;
+using osu.Framework.Graphics.Containers;
+using osu.Framework.Graphics.Sprites;
+using osu.Framework.Testing;
+using osu.Game.Beatmaps;
+using osu.Game.Beatmaps.ControlPoints;
+using osu.Game.Rulesets.Catch.Objects;
+using osu.Game.Rulesets.Catch.Objects.Drawables;
+using osu.Game.Rulesets.Catch.Skinning;
+using osu.Game.Rulesets.Catch.UI;
+using osu.Game.Skinning;
+using osu.Game.Tests.Visual;
+using osuTK;
+using osuTK.Graphics;
+
+namespace osu.Game.Rulesets.Catch.Tests
+{
+ public class TestSceneHyperDashColouring : OsuTestScene
+ {
+ [Resolved]
+ private SkinManager skins { get; set; }
+
+ [Test]
+ public void TestDefaultFruitColour()
+ {
+ var skin = new TestSkin();
+
+ checkHyperDashFruitColour(skin, Catcher.DEFAULT_HYPER_DASH_COLOUR);
+ }
+
+ [Test]
+ public void TestCustomFruitColour()
+ {
+ var skin = new TestSkin
+ {
+ HyperDashFruitColour = Color4.Cyan
+ };
+
+ checkHyperDashFruitColour(skin, skin.HyperDashFruitColour);
+ }
+
+ [Test]
+ public void TestCustomFruitColourPriority()
+ {
+ var skin = new TestSkin
+ {
+ HyperDashColour = Color4.Goldenrod,
+ HyperDashFruitColour = Color4.Cyan
+ };
+
+ checkHyperDashFruitColour(skin, skin.HyperDashFruitColour);
+ }
+
+ [Test]
+ public void TestFruitColourFallback()
+ {
+ var skin = new TestSkin
+ {
+ HyperDashColour = Color4.Goldenrod
+ };
+
+ checkHyperDashFruitColour(skin, skin.HyperDashColour);
+ }
+
+ private void checkHyperDashFruitColour(ISkin skin, Color4 expectedColour)
+ {
+ DrawableFruit drawableFruit = null;
+
+ AddStep("create hyper-dash fruit", () =>
+ {
+ var fruit = new Fruit { HyperDashTarget = new Banana() };
+ fruit.ApplyDefaults(new ControlPointInfo(), new BeatmapDifficulty());
+
+ Child = setupSkinHierarchy(drawableFruit = new DrawableFruit(fruit)
+ {
+ Anchor = Anchor.Centre,
+ Origin = Anchor.Centre,
+ Scale = new Vector2(4f),
+ }, skin);
+ });
+
+ AddAssert("hyper-dash colour is correct", () => checkLegacyFruitHyperDashColour(drawableFruit, expectedColour));
+ }
+
+ private Drawable setupSkinHierarchy(Drawable child, ISkin skin)
+ {
+ var legacySkinProvider = new SkinProvidingContainer(skins.GetSkin(DefaultLegacySkin.Info));
+ var testSkinProvider = new SkinProvidingContainer(skin);
+ var legacySkinTransformer = new SkinProvidingContainer(new CatchLegacySkinTransformer(testSkinProvider));
+
+ return legacySkinProvider
+ .WithChild(testSkinProvider
+ .WithChild(legacySkinTransformer
+ .WithChild(child)));
+ }
+
+ private bool checkLegacyFruitHyperDashColour(DrawableFruit fruit, Color4 expectedColour) =>
+ fruit.ChildrenOfType().First().Drawable.ChildrenOfType().Any(c => c.Colour == expectedColour);
+
+ private class TestSkin : LegacySkin
+ {
+ public Color4 HyperDashColour
+ {
+ get => Configuration.CustomColours[CatchSkinColour.HyperDash.ToString()];
+ set => Configuration.CustomColours[CatchSkinColour.HyperDash.ToString()] = value;
+ }
+
+ public Color4 HyperDashAfterImageColour
+ {
+ get => Configuration.CustomColours[CatchSkinColour.HyperDashAfterImage.ToString()];
+ set => Configuration.CustomColours[CatchSkinColour.HyperDashAfterImage.ToString()] = value;
+ }
+
+ public Color4 HyperDashFruitColour
+ {
+ get => Configuration.CustomColours[CatchSkinColour.HyperDashFruit.ToString()];
+ set => Configuration.CustomColours[CatchSkinColour.HyperDashFruit.ToString()] = value;
+ }
+
+ public TestSkin()
+ : base(new SkinInfo(), null, null, string.Empty)
+ {
+ }
+ }
+ }
+}
diff --git a/osu.Game.Rulesets.Catch/Objects/Drawables/DrawableCatchHitObject.cs b/osu.Game.Rulesets.Catch/Objects/Drawables/DrawableCatchHitObject.cs
index 6844be5941..b12cdd4ccb 100644
--- a/osu.Game.Rulesets.Catch/Objects/Drawables/DrawableCatchHitObject.cs
+++ b/osu.Game.Rulesets.Catch/Objects/Drawables/DrawableCatchHitObject.cs
@@ -70,6 +70,8 @@ namespace osu.Game.Rulesets.Catch.Objects.Drawables
public float DisplayRadius => DrawSize.X / 2 * Scale.X * HitObject.Scale;
+ protected override float SamplePlaybackPosition => HitObject.X;
+
protected DrawableCatchHitObject(CatchHitObject hitObject)
: base(hitObject)
{
diff --git a/osu.Game.Rulesets.Catch/Objects/Drawables/FruitPiece.cs b/osu.Game.Rulesets.Catch/Objects/Drawables/FruitPiece.cs
index 5797588ded..7ac9f11ad6 100644
--- a/osu.Game.Rulesets.Catch/Objects/Drawables/FruitPiece.cs
+++ b/osu.Game.Rulesets.Catch/Objects/Drawables/FruitPiece.cs
@@ -7,6 +7,7 @@ using osu.Framework.Bindables;
using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers;
using osu.Framework.Graphics.Shapes;
+using osu.Game.Rulesets.Catch.UI;
using osu.Game.Rulesets.Objects.Drawables;
using osuTK.Graphics;
@@ -67,7 +68,7 @@ namespace osu.Game.Rulesets.Catch.Objects.Drawables
RelativeSizeAxes = Axes.Both,
Anchor = Anchor.Centre,
Origin = Anchor.Centre,
- BorderColour = Color4.Red,
+ BorderColour = Catcher.DEFAULT_HYPER_DASH_COLOUR,
BorderThickness = 12f * RADIUS_ADJUST,
Children = new Drawable[]
{
@@ -77,7 +78,7 @@ namespace osu.Game.Rulesets.Catch.Objects.Drawables
Alpha = 0.3f,
Blending = BlendingParameters.Additive,
RelativeSizeAxes = Axes.Both,
- Colour = Color4.Red,
+ Colour = Catcher.DEFAULT_HYPER_DASH_COLOUR,
}
}
});
diff --git a/osu.Game.Rulesets.Catch/Skinning/CatchLegacySkinTransformer.cs b/osu.Game.Rulesets.Catch/Skinning/CatchLegacySkinTransformer.cs
index 65e6e6f209..4a87eb95e7 100644
--- a/osu.Game.Rulesets.Catch/Skinning/CatchLegacySkinTransformer.cs
+++ b/osu.Game.Rulesets.Catch/Skinning/CatchLegacySkinTransformer.cs
@@ -65,6 +65,15 @@ namespace osu.Game.Rulesets.Catch.Skinning
public SampleChannel GetSample(ISampleInfo sample) => source.GetSample(sample);
- public IBindable GetConfig(TLookup lookup) => source.GetConfig(lookup);
+ public IBindable GetConfig(TLookup lookup)
+ {
+ switch (lookup)
+ {
+ case CatchSkinColour colour:
+ return source.GetConfig(new SkinCustomColourLookup(colour));
+ }
+
+ return source.GetConfig(lookup);
+ }
}
}
diff --git a/osu.Game.Rulesets.Catch/Skinning/CatchSkinColour.cs b/osu.Game.Rulesets.Catch/Skinning/CatchSkinColour.cs
new file mode 100644
index 0000000000..4506111498
--- /dev/null
+++ b/osu.Game.Rulesets.Catch/Skinning/CatchSkinColour.cs
@@ -0,0 +1,23 @@
+// Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence.
+// See the LICENCE file in the repository root for full licence text.
+
+namespace osu.Game.Rulesets.Catch.Skinning
+{
+ public enum CatchSkinColour
+ {
+ ///
+ /// The colour to be used for the catcher while in hyper-dashing state.
+ ///
+ HyperDash,
+
+ ///
+ /// The colour to be used for fruits that grant the catcher the ability to hyper-dash.
+ ///
+ HyperDashFruit,
+
+ ///
+ /// The colour to be used for the "exploding" catcher sprite on beginning of hyper-dashing.
+ ///
+ HyperDashAfterImage,
+ }
+}
diff --git a/osu.Game.Rulesets.Catch/Skinning/LegacyFruitPiece.cs b/osu.Game.Rulesets.Catch/Skinning/LegacyFruitPiece.cs
index 25ee0811d0..5be54d3882 100644
--- a/osu.Game.Rulesets.Catch/Skinning/LegacyFruitPiece.cs
+++ b/osu.Game.Rulesets.Catch/Skinning/LegacyFruitPiece.cs
@@ -7,6 +7,7 @@ using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers;
using osu.Framework.Graphics.Sprites;
using osu.Game.Rulesets.Catch.Objects.Drawables;
+using osu.Game.Rulesets.Catch.UI;
using osu.Game.Rulesets.Objects.Drawables;
using osu.Game.Skinning;
using osuTK;
@@ -55,14 +56,16 @@ namespace osu.Game.Rulesets.Catch.Skinning
{
var hyperDash = new Sprite
{
- Texture = skin.GetTexture(lookupName),
- Colour = Color4.Red,
Anchor = Anchor.Centre,
Origin = Anchor.Centre,
Blending = BlendingParameters.Additive,
Depth = 1,
Alpha = 0.7f,
- Scale = new Vector2(1.2f)
+ Scale = new Vector2(1.2f),
+ Texture = skin.GetTexture(lookupName),
+ Colour = skin.GetConfig(CatchSkinColour.HyperDashFruit)?.Value ??
+ skin.GetConfig(CatchSkinColour.HyperDash)?.Value ??
+ Catcher.DEFAULT_HYPER_DASH_COLOUR,
};
AddInternal(hyperDash);
diff --git a/osu.Game.Rulesets.Catch/UI/Catcher.cs b/osu.Game.Rulesets.Catch/UI/Catcher.cs
index 7c815370c8..920d804e72 100644
--- a/osu.Game.Rulesets.Catch/UI/Catcher.cs
+++ b/osu.Game.Rulesets.Catch/UI/Catcher.cs
@@ -21,6 +21,8 @@ namespace osu.Game.Rulesets.Catch.UI
{
public class Catcher : Container, IKeyBindingHandler
{
+ public static readonly Color4 DEFAULT_HYPER_DASH_COLOUR = Color4.Red;
+
///
/// Whether we are hyper-dashing or not.
///
diff --git a/osu.Game.Rulesets.Mania.Tests/ManiaLegacyReplayTest.cs b/osu.Game.Rulesets.Mania.Tests/ManiaLegacyReplayTest.cs
new file mode 100644
index 0000000000..40bb83aece
--- /dev/null
+++ b/osu.Game.Rulesets.Mania.Tests/ManiaLegacyReplayTest.cs
@@ -0,0 +1,51 @@
+// Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence.
+// See the LICENCE file in the repository root for full licence text.
+
+using NUnit.Framework;
+using osu.Game.Rulesets.Mania.Beatmaps;
+using osu.Game.Rulesets.Mania.Replays;
+
+namespace osu.Game.Rulesets.Mania.Tests
+{
+ [TestFixture]
+ public class ManiaLegacyReplayTest
+ {
+ [TestCase(ManiaAction.Key1)]
+ [TestCase(ManiaAction.Key1, ManiaAction.Key2)]
+ [TestCase(ManiaAction.Special1)]
+ [TestCase(ManiaAction.Key8)]
+ public void TestEncodeDecodeSingleStage(params ManiaAction[] actions)
+ {
+ var beatmap = new ManiaBeatmap(new StageDefinition { Columns = 9 });
+
+ var frame = new ManiaReplayFrame(0, actions);
+ var legacyFrame = frame.ToLegacy(beatmap);
+
+ var decodedFrame = new ManiaReplayFrame();
+ decodedFrame.FromLegacy(legacyFrame, beatmap);
+
+ Assert.That(decodedFrame.Actions, Is.EquivalentTo(frame.Actions));
+ }
+
+ [TestCase(ManiaAction.Key1)]
+ [TestCase(ManiaAction.Key1, ManiaAction.Key2)]
+ [TestCase(ManiaAction.Special1)]
+ [TestCase(ManiaAction.Special2)]
+ [TestCase(ManiaAction.Special1, ManiaAction.Special2)]
+ [TestCase(ManiaAction.Special1, ManiaAction.Key5)]
+ [TestCase(ManiaAction.Key8)]
+ public void TestEncodeDecodeDualStage(params ManiaAction[] actions)
+ {
+ var beatmap = new ManiaBeatmap(new StageDefinition { Columns = 5 });
+ beatmap.Stages.Add(new StageDefinition { Columns = 5 });
+
+ var frame = new ManiaReplayFrame(0, actions);
+ var legacyFrame = frame.ToLegacy(beatmap);
+
+ var decodedFrame = new ManiaReplayFrame();
+ decodedFrame.FromLegacy(legacyFrame, beatmap);
+
+ Assert.That(decodedFrame.Actions, Is.EquivalentTo(frame.Actions));
+ }
+ }
+}
diff --git a/osu.Game.Rulesets.Mania/Objects/Drawables/DrawableManiaHitObject.cs b/osu.Game.Rulesets.Mania/Objects/Drawables/DrawableManiaHitObject.cs
index 5bfa07bd14..88888001b4 100644
--- a/osu.Game.Rulesets.Mania/Objects/Drawables/DrawableManiaHitObject.cs
+++ b/osu.Game.Rulesets.Mania/Objects/Drawables/DrawableManiaHitObject.cs
@@ -7,6 +7,7 @@ using osu.Framework.Bindables;
using osu.Framework.Graphics;
using osu.Game.Rulesets.Objects.Drawables;
using osu.Game.Rulesets.UI.Scrolling;
+using osu.Game.Rulesets.Mania.UI;
namespace osu.Game.Rulesets.Mania.Objects.Drawables
{
@@ -24,6 +25,20 @@ namespace osu.Game.Rulesets.Mania.Objects.Drawables
protected readonly IBindable Direction = new Bindable();
+ [Resolved(canBeNull: true)]
+ private ManiaPlayfield playfield { get; set; }
+
+ protected override float SamplePlaybackPosition
+ {
+ get
+ {
+ if (playfield == null)
+ return base.SamplePlaybackPosition;
+
+ return (float)HitObject.Column / playfield.TotalColumns;
+ }
+ }
+
protected DrawableManiaHitObject(ManiaHitObject hitObject)
: base(hitObject)
{
diff --git a/osu.Game.Rulesets.Mania/Replays/ManiaReplayFrame.cs b/osu.Game.Rulesets.Mania/Replays/ManiaReplayFrame.cs
index 8c73c36e99..dbab54d1d0 100644
--- a/osu.Game.Rulesets.Mania/Replays/ManiaReplayFrame.cs
+++ b/osu.Game.Rulesets.Mania/Replays/ManiaReplayFrame.cs
@@ -1,8 +1,8 @@
// Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence.
// See the LICENCE file in the repository root for full licence text.
+using System;
using System.Collections.Generic;
-using System.Linq;
using osu.Game.Beatmaps;
using osu.Game.Replays.Legacy;
using osu.Game.Rulesets.Mania.Beatmaps;
@@ -37,7 +37,7 @@ namespace osu.Game.Rulesets.Mania.Replays
while (activeColumns > 0)
{
- var isSpecial = maniaBeatmap.Stages.First().IsSpecialColumn(counter);
+ bool isSpecial = isColumnAtIndexSpecial(maniaBeatmap, counter);
if ((activeColumns & 1) > 0)
Actions.Add(isSpecial ? specialAction : normalAction);
@@ -58,33 +58,87 @@ namespace osu.Game.Rulesets.Mania.Replays
int keys = 0;
- var specialColumns = new List();
-
- for (int i = 0; i < maniaBeatmap.TotalColumns; i++)
- {
- if (maniaBeatmap.Stages.First().IsSpecialColumn(i))
- specialColumns.Add(i);
- }
-
foreach (var action in Actions)
{
switch (action)
{
case ManiaAction.Special1:
- keys |= 1 << specialColumns[0];
+ keys |= 1 << getSpecialColumnIndex(maniaBeatmap, 0);
break;
case ManiaAction.Special2:
- keys |= 1 << specialColumns[1];
+ keys |= 1 << getSpecialColumnIndex(maniaBeatmap, 1);
break;
default:
- keys |= 1 << (action - ManiaAction.Key1);
+ // the index in lazer, which doesn't include special keys.
+ int nonSpecialKeyIndex = action - ManiaAction.Key1;
+
+ // the index inclusive of special keys.
+ int overallIndex = 0;
+
+ // iterate to find the index including special keys.
+ for (; overallIndex < maniaBeatmap.TotalColumns; overallIndex++)
+ {
+ // skip over special columns.
+ if (isColumnAtIndexSpecial(maniaBeatmap, overallIndex))
+ continue;
+ // found a non-special column to use.
+ if (nonSpecialKeyIndex == 0)
+ break;
+ // found a non-special column but not ours.
+ nonSpecialKeyIndex--;
+ }
+
+ keys |= 1 << overallIndex;
break;
}
}
return new LegacyReplayFrame(Time, keys, null, ReplayButtonState.None);
}
+
+ ///
+ /// Find the overall index (across all stages) for a specified special key.
+ ///
+ /// The beatmap.
+ /// The special key offset (0 is S1).
+ /// The overall index for the special column.
+ private int getSpecialColumnIndex(ManiaBeatmap maniaBeatmap, int specialOffset)
+ {
+ for (int i = 0; i < maniaBeatmap.TotalColumns; i++)
+ {
+ if (isColumnAtIndexSpecial(maniaBeatmap, i))
+ {
+ if (specialOffset == 0)
+ return i;
+
+ specialOffset--;
+ }
+ }
+
+ throw new ArgumentException("Special key index is too high.", nameof(specialOffset));
+ }
+
+ ///
+ /// Check whether the column at an overall index (across all stages) is a special column.
+ ///
+ /// The beatmap.
+ /// The overall index to check.
+ private bool isColumnAtIndexSpecial(ManiaBeatmap beatmap, int index)
+ {
+ foreach (var stage in beatmap.Stages)
+ {
+ if (index >= stage.Columns)
+ {
+ index -= stage.Columns;
+ continue;
+ }
+
+ return stage.IsSpecialColumn(index);
+ }
+
+ throw new ArgumentException("Column index is too high.", nameof(index));
+ }
}
}
diff --git a/osu.Game.Rulesets.Mania/UI/ManiaPlayfield.cs b/osu.Game.Rulesets.Mania/UI/ManiaPlayfield.cs
index c2eb48b774..2dec468654 100644
--- a/osu.Game.Rulesets.Mania/UI/ManiaPlayfield.cs
+++ b/osu.Game.Rulesets.Mania/UI/ManiaPlayfield.cs
@@ -6,6 +6,7 @@ using osu.Framework.Graphics.Containers;
using System;
using System.Collections.Generic;
using System.Linq;
+using osu.Framework.Allocation;
using osu.Game.Rulesets.Mania.Beatmaps;
using osu.Game.Rulesets.Mania.Objects;
using osu.Game.Rulesets.Objects.Drawables;
@@ -14,6 +15,7 @@ using osuTK;
namespace osu.Game.Rulesets.Mania.UI
{
+ [Cached]
public class ManiaPlayfield : ScrollingPlayfield
{
private readonly List stages = new List();
diff --git a/osu.Game.Rulesets.Osu.Tests/TestScenePathControlPointVisualiser.cs b/osu.Game.Rulesets.Osu.Tests/TestScenePathControlPointVisualiser.cs
new file mode 100644
index 0000000000..cbe14ff4d2
--- /dev/null
+++ b/osu.Game.Rulesets.Osu.Tests/TestScenePathControlPointVisualiser.cs
@@ -0,0 +1,64 @@
+// Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence.
+// See the LICENCE file in the repository root for full licence text.
+
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using Humanizer;
+using NUnit.Framework;
+using osu.Framework.Graphics;
+using osu.Game.Beatmaps;
+using osu.Game.Beatmaps.ControlPoints;
+using osu.Game.Rulesets.Objects;
+using osu.Game.Rulesets.Osu.Edit.Blueprints.Sliders.Components;
+using osu.Game.Rulesets.Osu.Objects;
+using osu.Game.Tests.Visual;
+using osuTK;
+
+namespace osu.Game.Rulesets.Osu.Tests
+{
+ public class TestScenePathControlPointVisualiser : OsuTestScene
+ {
+ public override IReadOnlyList RequiredTypes => new[]
+ {
+ typeof(StringHumanizeExtensions),
+ typeof(PathControlPointPiece),
+ typeof(PathControlPointConnectionPiece)
+ };
+
+ private Slider slider;
+ private PathControlPointVisualiser visualiser;
+
+ [SetUp]
+ public void Setup() => Schedule(() =>
+ {
+ slider = new Slider();
+ slider.ApplyDefaults(new ControlPointInfo(), new BeatmapDifficulty());
+ });
+
+ [Test]
+ public void TestAddOverlappingControlPoints()
+ {
+ createVisualiser(true);
+
+ addControlPointStep(new Vector2(200));
+ addControlPointStep(new Vector2(300));
+ addControlPointStep(new Vector2(300));
+ addControlPointStep(new Vector2(500, 300));
+
+ AddAssert("last connection displayed", () =>
+ {
+ var lastConnection = visualiser.Connections.Last(c => c.ControlPoint.Position.Value == new Vector2(300));
+ return lastConnection.DrawWidth > 50;
+ });
+ }
+
+ private void createVisualiser(bool allowSelection) => AddStep("create visualiser", () => Child = visualiser = new PathControlPointVisualiser(slider, allowSelection)
+ {
+ Anchor = Anchor.Centre,
+ Origin = Anchor.Centre
+ });
+
+ private void addControlPointStep(Vector2 position) => AddStep($"add control point {position}", () => slider.Path.ControlPoints.Add(new PathControlPoint(position)));
+ }
+}
diff --git a/osu.Game.Rulesets.Osu.Tests/TestSceneSliderPlacementBlueprint.cs b/osu.Game.Rulesets.Osu.Tests/TestSceneSliderPlacementBlueprint.cs
index 0522260150..9fc479953e 100644
--- a/osu.Game.Rulesets.Osu.Tests/TestSceneSliderPlacementBlueprint.cs
+++ b/osu.Game.Rulesets.Osu.Tests/TestSceneSliderPlacementBlueprint.cs
@@ -1,18 +1,285 @@
// Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence.
// See the LICENCE file in the repository root for full licence text.
+using NUnit.Framework;
+using osu.Framework.Utils;
using osu.Game.Rulesets.Edit;
using osu.Game.Rulesets.Objects;
using osu.Game.Rulesets.Objects.Drawables;
+using osu.Game.Rulesets.Objects.Types;
using osu.Game.Rulesets.Osu.Edit.Blueprints.Sliders;
using osu.Game.Rulesets.Osu.Objects;
using osu.Game.Rulesets.Osu.Objects.Drawables;
using osu.Game.Tests.Visual;
+using osuTK;
+using osuTK.Input;
namespace osu.Game.Rulesets.Osu.Tests
{
public class TestSceneSliderPlacementBlueprint : PlacementBlueprintTestScene
{
+ [SetUp]
+ public void Setup() => Schedule(() =>
+ {
+ HitObjectContainer.Clear();
+ ResetPlacement();
+ });
+
+ [Test]
+ public void TestBeginPlacementWithoutFinishing()
+ {
+ addMovementStep(new Vector2(200));
+ addClickStep(MouseButton.Left);
+
+ assertPlaced(false);
+ }
+
+ [Test]
+ public void TestPlaceWithoutMovingMouse()
+ {
+ addMovementStep(new Vector2(200));
+ addClickStep(MouseButton.Left);
+ addClickStep(MouseButton.Right);
+
+ assertPlaced(true);
+ assertLength(0);
+ assertControlPointType(0, PathType.Linear);
+ }
+
+ [Test]
+ public void TestPlaceWithMouseMovement()
+ {
+ addMovementStep(new Vector2(200));
+ addClickStep(MouseButton.Left);
+
+ addMovementStep(new Vector2(400, 200));
+ addClickStep(MouseButton.Right);
+
+ assertPlaced(true);
+ assertLength(200);
+ assertControlPointCount(2);
+ assertControlPointType(0, PathType.Linear);
+ }
+
+ [Test]
+ public void TestPlaceNormalControlPoint()
+ {
+ addMovementStep(new Vector2(200));
+ addClickStep(MouseButton.Left);
+
+ addMovementStep(new Vector2(300, 200));
+ addClickStep(MouseButton.Left);
+
+ addMovementStep(new Vector2(300));
+ addClickStep(MouseButton.Right);
+
+ assertPlaced(true);
+ assertControlPointCount(3);
+ assertControlPointPosition(1, new Vector2(100, 0));
+ assertControlPointType(0, PathType.PerfectCurve);
+ }
+
+ [Test]
+ public void TestPlaceTwoNormalControlPoints()
+ {
+ addMovementStep(new Vector2(200));
+ addClickStep(MouseButton.Left);
+
+ addMovementStep(new Vector2(300, 200));
+ addClickStep(MouseButton.Left);
+
+ addMovementStep(new Vector2(300));
+ addClickStep(MouseButton.Left);
+
+ addMovementStep(new Vector2(400, 300));
+ addClickStep(MouseButton.Right);
+
+ assertPlaced(true);
+ assertControlPointCount(4);
+ assertControlPointPosition(1, new Vector2(100, 0));
+ assertControlPointPosition(2, new Vector2(100, 100));
+ assertControlPointType(0, PathType.Bezier);
+ }
+
+ [Test]
+ public void TestPlaceSegmentControlPoint()
+ {
+ addMovementStep(new Vector2(200));
+ addClickStep(MouseButton.Left);
+
+ addMovementStep(new Vector2(300, 200));
+ addClickStep(MouseButton.Left);
+ addClickStep(MouseButton.Left);
+
+ addMovementStep(new Vector2(300));
+ addClickStep(MouseButton.Right);
+
+ assertPlaced(true);
+ assertControlPointCount(3);
+ assertControlPointPosition(1, new Vector2(100, 0));
+ assertControlPointType(0, PathType.Linear);
+ assertControlPointType(1, PathType.Linear);
+ }
+
+ [Test]
+ public void TestMoveToPerfectCurveThenPlaceLinear()
+ {
+ addMovementStep(new Vector2(200));
+ addClickStep(MouseButton.Left);
+
+ addMovementStep(new Vector2(300, 200));
+ addClickStep(MouseButton.Left);
+
+ addMovementStep(new Vector2(300));
+ addMovementStep(new Vector2(300, 200));
+ addClickStep(MouseButton.Right);
+
+ assertPlaced(true);
+ assertControlPointCount(2);
+ assertControlPointType(0, PathType.Linear);
+ assertLength(100);
+ }
+
+ [Test]
+ public void TestMoveToBezierThenPlacePerfectCurve()
+ {
+ addMovementStep(new Vector2(200));
+ addClickStep(MouseButton.Left);
+
+ addMovementStep(new Vector2(300, 200));
+ addClickStep(MouseButton.Left);
+
+ addMovementStep(new Vector2(300));
+ addClickStep(MouseButton.Left);
+
+ addMovementStep(new Vector2(400, 300));
+ addMovementStep(new Vector2(300));
+ addClickStep(MouseButton.Right);
+
+ assertPlaced(true);
+ assertControlPointCount(3);
+ assertControlPointType(0, PathType.PerfectCurve);
+ }
+
+ [Test]
+ public void TestMoveToFourthOrderBezierThenPlaceThirdOrderBezier()
+ {
+ addMovementStep(new Vector2(200));
+ addClickStep(MouseButton.Left);
+
+ addMovementStep(new Vector2(300, 200));
+ addClickStep(MouseButton.Left);
+
+ addMovementStep(new Vector2(300));
+ addClickStep(MouseButton.Left);
+
+ addMovementStep(new Vector2(400, 300));
+ addClickStep(MouseButton.Left);
+
+ addMovementStep(new Vector2(400));
+ addMovementStep(new Vector2(400, 300));
+ addClickStep(MouseButton.Right);
+
+ assertPlaced(true);
+ assertControlPointCount(4);
+ assertControlPointType(0, PathType.Bezier);
+ }
+
+ [Test]
+ public void TestPlaceLinearSegmentThenPlaceLinearSegment()
+ {
+ addMovementStep(new Vector2(200));
+ addClickStep(MouseButton.Left);
+
+ addMovementStep(new Vector2(300, 200));
+ addClickStep(MouseButton.Left);
+ addClickStep(MouseButton.Left);
+
+ addMovementStep(new Vector2(300, 300));
+ addClickStep(MouseButton.Right);
+
+ assertPlaced(true);
+ assertControlPointCount(3);
+ assertControlPointPosition(1, new Vector2(100, 0));
+ assertControlPointPosition(2, new Vector2(100));
+ assertControlPointType(0, PathType.Linear);
+ assertControlPointType(1, PathType.Linear);
+ }
+
+ [Test]
+ public void TestPlaceLinearSegmentThenPlacePerfectCurveSegment()
+ {
+ addMovementStep(new Vector2(200));
+ addClickStep(MouseButton.Left);
+
+ addMovementStep(new Vector2(300, 200));
+ addClickStep(MouseButton.Left);
+ addClickStep(MouseButton.Left);
+
+ addMovementStep(new Vector2(300, 300));
+ addClickStep(MouseButton.Left);
+
+ addMovementStep(new Vector2(400, 300));
+ addClickStep(MouseButton.Right);
+
+ assertPlaced(true);
+ assertControlPointCount(4);
+ assertControlPointPosition(1, new Vector2(100, 0));
+ assertControlPointPosition(2, new Vector2(100));
+ assertControlPointType(0, PathType.Linear);
+ assertControlPointType(1, PathType.PerfectCurve);
+ }
+
+ [Test]
+ public void TestPlacePerfectCurveSegmentThenPlacePerfectCurveSegment()
+ {
+ addMovementStep(new Vector2(200));
+ addClickStep(MouseButton.Left);
+
+ addMovementStep(new Vector2(300, 200));
+ addClickStep(MouseButton.Left);
+
+ addMovementStep(new Vector2(300, 300));
+ addClickStep(MouseButton.Left);
+ addClickStep(MouseButton.Left);
+
+ addMovementStep(new Vector2(400, 300));
+ addClickStep(MouseButton.Left);
+
+ addMovementStep(new Vector2(400));
+ addClickStep(MouseButton.Right);
+
+ assertPlaced(true);
+ assertControlPointCount(5);
+ assertControlPointPosition(1, new Vector2(100, 0));
+ assertControlPointPosition(2, new Vector2(100));
+ assertControlPointPosition(3, new Vector2(200, 100));
+ assertControlPointPosition(4, new Vector2(200));
+ assertControlPointType(0, PathType.PerfectCurve);
+ assertControlPointType(2, PathType.PerfectCurve);
+ }
+
+ private void addMovementStep(Vector2 position) => AddStep($"move mouse to {position}", () => InputManager.MoveMouseTo(InputManager.ToScreenSpace(position)));
+
+ private void addClickStep(MouseButton button)
+ {
+ AddStep($"press {button}", () => InputManager.PressButton(button));
+ AddStep($"release {button}", () => InputManager.ReleaseButton(button));
+ }
+
+ private void assertPlaced(bool expected) => AddAssert($"slider {(expected ? "placed" : "not placed")}", () => (getSlider() != null) == expected);
+
+ private void assertLength(double expected) => AddAssert($"slider length is {expected}", () => Precision.AlmostEquals(expected, getSlider().Distance, 1));
+
+ private void assertControlPointCount(int expected) => AddAssert($"has {expected} control points", () => getSlider().Path.ControlPoints.Count == expected);
+
+ private void assertControlPointType(int index, PathType type) => AddAssert($"control point {index} is {type}", () => getSlider().Path.ControlPoints[index].Type.Value == type);
+
+ private void assertControlPointPosition(int index, Vector2 position) =>
+ AddAssert($"control point {index} at {position}", () => Precision.AlmostEquals(position, getSlider().Path.ControlPoints[index].Position.Value, 1));
+
+ private Slider getSlider() => HitObjectContainer.Count > 0 ? (Slider)((DrawableSlider)HitObjectContainer[0]).HitObject : null;
+
protected override DrawableHitObject CreateHitObject(HitObject hitObject) => new DrawableSlider((Slider)hitObject);
protected override PlacementBlueprint CreateBlueprint() => new SliderPlacementBlueprint();
}
diff --git a/osu.Game.Rulesets.Osu/Edit/Blueprints/Sliders/Components/PathControlPointConnectionPiece.cs b/osu.Game.Rulesets.Osu/Edit/Blueprints/Sliders/Components/PathControlPointConnectionPiece.cs
index 0fc441fec6..ba1d35c35c 100644
--- a/osu.Game.Rulesets.Osu/Edit/Blueprints/Sliders/Components/PathControlPointConnectionPiece.cs
+++ b/osu.Game.Rulesets.Osu/Edit/Blueprints/Sliders/Components/PathControlPointConnectionPiece.cs
@@ -16,22 +16,25 @@ namespace osu.Game.Rulesets.Osu.Edit.Blueprints.Sliders.Components
///
public class PathControlPointConnectionPiece : CompositeDrawable
{
- public PathControlPoint ControlPoint;
+ public readonly PathControlPoint ControlPoint;
private readonly Path path;
private readonly Slider slider;
+ private readonly int controlPointIndex;
private IBindable sliderPosition;
private IBindable pathVersion;
- public PathControlPointConnectionPiece(Slider slider, PathControlPoint controlPoint)
+ public PathControlPointConnectionPiece(Slider slider, int controlPointIndex)
{
this.slider = slider;
- ControlPoint = controlPoint;
+ this.controlPointIndex = controlPointIndex;
Origin = Anchor.Centre;
AutoSizeAxes = Axes.Both;
+ ControlPoint = slider.Path.ControlPoints[controlPointIndex];
+
InternalChild = path = new SmoothPath
{
Anchor = Anchor.Centre,
@@ -61,13 +64,12 @@ namespace osu.Game.Rulesets.Osu.Edit.Blueprints.Sliders.Components
path.ClearVertices();
- int index = slider.Path.ControlPoints.IndexOf(ControlPoint) + 1;
-
- if (index == 0 || index == slider.Path.ControlPoints.Count)
+ int nextIndex = controlPointIndex + 1;
+ if (nextIndex == 0 || nextIndex >= slider.Path.ControlPoints.Count)
return;
path.AddVertex(Vector2.Zero);
- path.AddVertex(slider.Path.ControlPoints[index].Position.Value - ControlPoint.Position.Value);
+ path.AddVertex(slider.Path.ControlPoints[nextIndex].Position.Value - ControlPoint.Position.Value);
path.OriginPosition = path.PositionInBoundingBox(Vector2.Zero);
}
diff --git a/osu.Game.Rulesets.Osu/Edit/Blueprints/Sliders/Components/PathControlPointPiece.cs b/osu.Game.Rulesets.Osu/Edit/Blueprints/Sliders/Components/PathControlPointPiece.cs
index af4da5e853..fed149b5c5 100644
--- a/osu.Game.Rulesets.Osu/Edit/Blueprints/Sliders/Components/PathControlPointPiece.cs
+++ b/osu.Game.Rulesets.Osu/Edit/Blueprints/Sliders/Components/PathControlPointPiece.cs
@@ -4,6 +4,7 @@
using System;
using osu.Framework.Allocation;
using osu.Framework.Bindables;
+using osu.Framework.Extensions.Color4Extensions;
using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers;
using osu.Framework.Graphics.Shapes;
@@ -12,6 +13,7 @@ using osu.Game.Graphics;
using osu.Game.Rulesets.Edit;
using osu.Game.Rulesets.Objects;
using osu.Game.Rulesets.Osu.Objects;
+using osu.Game.Screens.Edit;
using osuTK;
using osuTK.Graphics;
using osuTK.Input;
@@ -33,6 +35,9 @@ namespace osu.Game.Rulesets.Osu.Edit.Blueprints.Sliders.Components
private readonly Container marker;
private readonly Drawable markerRing;
+ [Resolved(CanBeNull = true)]
+ private IEditorChangeHandler changeHandler { get; set; }
+
[Resolved(CanBeNull = true)]
private IDistanceSnapProvider snapProvider { get; set; }
@@ -47,6 +52,8 @@ namespace osu.Game.Rulesets.Osu.Edit.Blueprints.Sliders.Components
this.slider = slider;
ControlPoint = controlPoint;
+ controlPoint.Type.BindValueChanged(_ => updateMarkerDisplay());
+
Origin = Anchor.Centre;
AutoSizeAxes = Axes.Both;
@@ -137,7 +144,16 @@ namespace osu.Game.Rulesets.Osu.Edit.Blueprints.Sliders.Components
protected override bool OnClick(ClickEvent e) => RequestSelection != null;
- protected override bool OnDragStart(DragStartEvent e) => e.Button == MouseButton.Left;
+ protected override bool OnDragStart(DragStartEvent e)
+ {
+ if (e.Button == MouseButton.Left)
+ {
+ changeHandler?.BeginChange();
+ return true;
+ }
+
+ return false;
+ }
protected override void OnDrag(DragEvent e)
{
@@ -158,6 +174,8 @@ namespace osu.Game.Rulesets.Osu.Edit.Blueprints.Sliders.Components
ControlPoint.Position.Value += e.Delta;
}
+ protected override void OnDragEnd(DragEndEvent e) => changeHandler?.EndChange();
+
///
/// Updates the state of the circular control point marker.
///
@@ -168,8 +186,10 @@ namespace osu.Game.Rulesets.Osu.Edit.Blueprints.Sliders.Components
markerRing.Alpha = IsSelected.Value ? 1 : 0;
Color4 colour = ControlPoint.Type.Value != null ? colours.Red : colours.Yellow;
+
if (IsHovered || IsSelected.Value)
- colour = Color4.White;
+ colour = colour.Lighten(1);
+
marker.Colour = colour;
}
}
diff --git a/osu.Game.Rulesets.Osu/Edit/Blueprints/Sliders/Components/PathControlPointVisualiser.cs b/osu.Game.Rulesets.Osu/Edit/Blueprints/Sliders/Components/PathControlPointVisualiser.cs
index e293eba9d7..f6354bc612 100644
--- a/osu.Game.Rulesets.Osu/Edit/Blueprints/Sliders/Components/PathControlPointVisualiser.cs
+++ b/osu.Game.Rulesets.Osu/Edit/Blueprints/Sliders/Components/PathControlPointVisualiser.cs
@@ -3,6 +3,7 @@
using System;
using System.Collections.Generic;
+using System.Collections.Specialized;
using System.Linq;
using Humanizer;
using osu.Framework.Bindables;
@@ -24,17 +25,14 @@ namespace osu.Game.Rulesets.Osu.Edit.Blueprints.Sliders.Components
public class PathControlPointVisualiser : CompositeDrawable, IKeyBindingHandler, IHasContextMenu
{
internal readonly Container Pieces;
+ internal readonly Container Connections;
- private readonly Container connections;
-
+ private readonly IBindableList controlPoints = new BindableList();
private readonly Slider slider;
-
private readonly bool allowSelection;
private InputManager inputManager;
- private IBindableList controlPoints;
-
public Action> RemoveControlPointsRequested;
public PathControlPointVisualiser(Slider slider, bool allowSelection)
@@ -46,7 +44,7 @@ namespace osu.Game.Rulesets.Osu.Edit.Blueprints.Sliders.Components
InternalChildren = new Drawable[]
{
- connections = new Container { RelativeSizeAxes = Axes.Both },
+ Connections = new Container { RelativeSizeAxes = Axes.Both },
Pieces = new Container { RelativeSizeAxes = Axes.Both }
};
}
@@ -57,33 +55,38 @@ namespace osu.Game.Rulesets.Osu.Edit.Blueprints.Sliders.Components
inputManager = GetContainingInputManager();
- controlPoints = slider.Path.ControlPoints.GetBoundCopy();
- controlPoints.ItemsAdded += addControlPoints;
- controlPoints.ItemsRemoved += removeControlPoints;
-
- addControlPoints(controlPoints);
+ controlPoints.CollectionChanged += onControlPointsChanged;
+ controlPoints.BindTo(slider.Path.ControlPoints);
}
- private void addControlPoints(IEnumerable controlPoints)
+ private void onControlPointsChanged(object sender, NotifyCollectionChangedEventArgs e)
{
- foreach (var point in controlPoints)
+ switch (e.Action)
{
- Pieces.Add(new PathControlPointPiece(slider, point).With(d =>
- {
- if (allowSelection)
- d.RequestSelection = selectPiece;
- }));
+ case NotifyCollectionChangedAction.Add:
+ for (int i = 0; i < e.NewItems.Count; i++)
+ {
+ var point = (PathControlPoint)e.NewItems[i];
- connections.Add(new PathControlPointConnectionPiece(slider, point));
- }
- }
+ Pieces.Add(new PathControlPointPiece(slider, point).With(d =>
+ {
+ if (allowSelection)
+ d.RequestSelection = selectPiece;
+ }));
- private void removeControlPoints(IEnumerable controlPoints)
- {
- foreach (var point in controlPoints)
- {
- Pieces.RemoveAll(p => p.ControlPoint == point);
- connections.RemoveAll(c => c.ControlPoint == point);
+ Connections.Add(new PathControlPointConnectionPiece(slider, e.NewStartingIndex + i));
+ }
+
+ break;
+
+ case NotifyCollectionChangedAction.Remove:
+ foreach (var point in e.OldItems.Cast())
+ {
+ Pieces.RemoveAll(p => p.ControlPoint == point);
+ Connections.RemoveAll(c => c.ControlPoint == point);
+ }
+
+ break;
}
}
diff --git a/osu.Game.Rulesets.Osu/Edit/Blueprints/Sliders/SliderPlacementBlueprint.cs b/osu.Game.Rulesets.Osu/Edit/Blueprints/Sliders/SliderPlacementBlueprint.cs
index a780653796..9af972dbce 100644
--- a/osu.Game.Rulesets.Osu/Edit/Blueprints/Sliders/SliderPlacementBlueprint.cs
+++ b/osu.Game.Rulesets.Osu/Edit/Blueprints/Sliders/SliderPlacementBlueprint.cs
@@ -1,6 +1,9 @@
// Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence.
// See the LICENCE file in the repository root for full licence text.
+using System.Diagnostics;
+using System.Linq;
+using JetBrains.Annotations;
using osu.Framework.Allocation;
using osu.Framework.Graphics;
using osu.Framework.Input;
@@ -23,6 +26,7 @@ namespace osu.Game.Rulesets.Osu.Edit.Blueprints.Sliders
private SliderBodyPiece bodyPiece;
private HitCirclePiece headCirclePiece;
private HitCirclePiece tailCirclePiece;
+ private PathControlPointVisualiser controlPointVisualiser;
private InputManager inputManager;
@@ -51,7 +55,7 @@ namespace osu.Game.Rulesets.Osu.Edit.Blueprints.Sliders
bodyPiece = new SliderBodyPiece(),
headCirclePiece = new HitCirclePiece(),
tailCirclePiece = new HitCirclePiece(),
- new PathControlPointVisualiser(HitObject, false)
+ controlPointVisualiser = new PathControlPointVisualiser(HitObject, false)
};
setState(PlacementState.Initial);
@@ -73,11 +77,7 @@ namespace osu.Game.Rulesets.Osu.Edit.Blueprints.Sliders
break;
case PlacementState.Body:
- ensureCursor();
-
- // The given screen-space position may have been externally snapped, but the unsnapped position from the input manager
- // is used instead since snapping control points doesn't make much sense
- cursor.Position.Value = ToLocalSpace(inputManager.CurrentState.Mouse.Position) - HitObject.Position;
+ updateCursor();
break;
}
}
@@ -91,17 +91,27 @@ namespace osu.Game.Rulesets.Osu.Edit.Blueprints.Sliders
break;
case PlacementState.Body:
- switch (e.Button)
- {
- case MouseButton.Left:
- ensureCursor();
+ if (e.Button != MouseButton.Left)
+ break;
- // Detatch the cursor
- cursor = null;
- break;
+ if (canPlaceNewControlPoint(out var lastPoint))
+ {
+ // Place a new point by detatching the current cursor.
+ updateCursor();
+ cursor = null;
+ }
+ else
+ {
+ // Transform the last point into a new segment.
+ Debug.Assert(lastPoint != null);
+
+ segmentStart = lastPoint;
+ segmentStart.Type.Value = PathType.Linear;
+
+ currentSegmentLength = 1;
}
- break;
+ return true;
}
return true;
@@ -114,16 +124,6 @@ namespace osu.Game.Rulesets.Osu.Edit.Blueprints.Sliders
base.OnMouseUp(e);
}
- protected override bool OnDoubleClick(DoubleClickEvent e)
- {
- // Todo: This should all not occur on double click, but rather if the previous control point is hovered.
- segmentStart = HitObject.Path.ControlPoints[^1];
- segmentStart.Type.Value = PathType.Linear;
-
- currentSegmentLength = 1;
- return true;
- }
-
private void beginCurve()
{
BeginPlacement(commitStart: true);
@@ -161,17 +161,50 @@ namespace osu.Game.Rulesets.Osu.Edit.Blueprints.Sliders
}
}
- private void ensureCursor()
+ private void updateCursor()
{
- if (cursor == null)
+ if (canPlaceNewControlPoint(out _))
{
- HitObject.Path.ControlPoints.Add(cursor = new PathControlPoint { Position = { Value = Vector2.Zero } });
- currentSegmentLength++;
+ // The cursor does not overlap a previous control point, so it can be added if not already existing.
+ if (cursor == null)
+ {
+ HitObject.Path.ControlPoints.Add(cursor = new PathControlPoint { Position = { Value = Vector2.Zero } });
+ // The path type should be adjusted in the progression of updatePathType() (Linear -> PC -> Bezier).
+ currentSegmentLength++;
+ updatePathType();
+ }
+
+ // Update the cursor position.
+ cursor.Position.Value = ToLocalSpace(inputManager.CurrentState.Mouse.Position) - HitObject.Position;
+ }
+ else if (cursor != null)
+ {
+ // The cursor overlaps a previous control point, so it's removed.
+ HitObject.Path.ControlPoints.Remove(cursor);
+ cursor = null;
+
+ // The path type should be adjusted in the reverse progression of updatePathType() (Bezier -> PC -> Linear).
+ currentSegmentLength--;
updatePathType();
}
}
+ ///
+ /// Whether a new control point can be placed at the current mouse position.
+ ///
+ /// The last-placed control point. May be null, but is not null if false is returned.
+ /// Whether a new control point can be placed at the current position.
+ private bool canPlaceNewControlPoint([CanBeNull] out PathControlPoint lastPoint)
+ {
+ // We cannot rely on the ordering of drawable pieces, so find the respective drawable piece by searching for the last non-cursor control point.
+ var last = HitObject.Path.ControlPoints.LastOrDefault(p => p != cursor);
+ var lastPiece = controlPointVisualiser.Pieces.Single(p => p.ControlPoint == last);
+
+ lastPoint = last;
+ return lastPiece?.IsHovered != true;
+ }
+
private void updateSlider()
{
HitObject.Path.ExpectedDistance.Value = composer?.GetSnappedDistanceFromDistance(HitObject.StartTime, (float)HitObject.Path.CalculatedDistance) ?? (float)HitObject.Path.CalculatedDistance;
diff --git a/osu.Game.Rulesets.Osu/Edit/Blueprints/Sliders/SliderSelectionBlueprint.cs b/osu.Game.Rulesets.Osu/Edit/Blueprints/Sliders/SliderSelectionBlueprint.cs
index 001100d3ce..b7074b7ee5 100644
--- a/osu.Game.Rulesets.Osu/Edit/Blueprints/Sliders/SliderSelectionBlueprint.cs
+++ b/osu.Game.Rulesets.Osu/Edit/Blueprints/Sliders/SliderSelectionBlueprint.cs
@@ -38,6 +38,9 @@ namespace osu.Game.Rulesets.Osu.Edit.Blueprints.Sliders
[Resolved(CanBeNull = true)]
private EditorBeatmap editorBeatmap { get; set; }
+ [Resolved(CanBeNull = true)]
+ private IEditorChangeHandler changeHandler { get; set; }
+
public SliderSelectionBlueprint(DrawableSlider slider)
: base(slider)
{
@@ -92,7 +95,16 @@ namespace osu.Game.Rulesets.Osu.Edit.Blueprints.Sliders
private int? placementControlPointIndex;
- protected override bool OnDragStart(DragStartEvent e) => placementControlPointIndex != null;
+ protected override bool OnDragStart(DragStartEvent e)
+ {
+ if (placementControlPointIndex != null)
+ {
+ changeHandler?.BeginChange();
+ return true;
+ }
+
+ return false;
+ }
protected override void OnDrag(DragEvent e)
{
@@ -103,7 +115,11 @@ namespace osu.Game.Rulesets.Osu.Edit.Blueprints.Sliders
protected override void OnDragEnd(DragEndEvent e)
{
- placementControlPointIndex = null;
+ if (placementControlPointIndex != null)
+ {
+ placementControlPointIndex = null;
+ changeHandler?.EndChange();
+ }
}
private BindableList controlPoints => HitObject.Path.ControlPoints;
diff --git a/osu.Game.Rulesets.Osu/Objects/Drawables/DrawableOsuHitObject.cs b/osu.Game.Rulesets.Osu/Objects/Drawables/DrawableOsuHitObject.cs
index fe23e3729d..8308c0c576 100644
--- a/osu.Game.Rulesets.Osu/Objects/Drawables/DrawableOsuHitObject.cs
+++ b/osu.Game.Rulesets.Osu/Objects/Drawables/DrawableOsuHitObject.cs
@@ -7,6 +7,7 @@ using osu.Framework.Graphics;
using osu.Game.Rulesets.Judgements;
using osu.Game.Rulesets.Osu.Judgements;
using osu.Game.Graphics.Containers;
+using osu.Game.Rulesets.Osu.UI;
using osu.Game.Rulesets.Scoring;
namespace osu.Game.Rulesets.Osu.Objects.Drawables
@@ -18,6 +19,8 @@ namespace osu.Game.Rulesets.Osu.Objects.Drawables
// Must be set to update IsHovered as it's used in relax mdo to detect osu hit objects.
public override bool HandlePositionalInput => true;
+ protected override float SamplePlaybackPosition => HitObject.X / OsuPlayfield.BASE_SIZE.X;
+
///
/// Whether this can be hit.
/// If non-null, judgements will be ignored (resulting in a shake) whilst the function returns false.
diff --git a/osu.Game.Rulesets.Taiko.Tests/Resources/metrics-skin/taikohitcircle@2x.png b/osu.Game.Rulesets.Taiko.Tests/Resources/metrics-skin/taikohitcircle@2x.png
new file mode 100644
index 0000000000..043bfbfae1
Binary files /dev/null and b/osu.Game.Rulesets.Taiko.Tests/Resources/metrics-skin/taikohitcircle@2x.png differ
diff --git a/osu.Game.Rulesets.Taiko.Tests/Resources/metrics-skin/taikohitcircleoverlay@2x.png b/osu.Game.Rulesets.Taiko.Tests/Resources/metrics-skin/taikohitcircleoverlay@2x.png
new file mode 100644
index 0000000000..4233d9bb6e
Binary files /dev/null and b/osu.Game.Rulesets.Taiko.Tests/Resources/metrics-skin/taikohitcircleoverlay@2x.png differ
diff --git a/osu.Game.Rulesets.Taiko.Tests/Resources/old-skin/taikobigcircle.png b/osu.Game.Rulesets.Taiko.Tests/Resources/old-skin/taikobigcircle.png
new file mode 100644
index 0000000000..63504dd52d
Binary files /dev/null and b/osu.Game.Rulesets.Taiko.Tests/Resources/old-skin/taikobigcircle.png differ
diff --git a/osu.Game.Rulesets.Taiko.Tests/Resources/old-skin/taikobigcircleoverlay-0.png b/osu.Game.Rulesets.Taiko.Tests/Resources/old-skin/taikobigcircleoverlay-0.png
new file mode 100644
index 0000000000..490c196fba
Binary files /dev/null and b/osu.Game.Rulesets.Taiko.Tests/Resources/old-skin/taikobigcircleoverlay-0.png differ
diff --git a/osu.Game.Rulesets.Taiko.Tests/Resources/old-skin/taikobigcircleoverlay-1.png b/osu.Game.Rulesets.Taiko.Tests/Resources/old-skin/taikobigcircleoverlay-1.png
new file mode 100644
index 0000000000..99cd589a10
Binary files /dev/null and b/osu.Game.Rulesets.Taiko.Tests/Resources/old-skin/taikobigcircleoverlay-1.png differ
diff --git a/osu.Game.Rulesets.Taiko.Tests/Resources/old-skin/taikohitcircle.png b/osu.Game.Rulesets.Taiko.Tests/Resources/old-skin/taikohitcircle.png
new file mode 100644
index 0000000000..26eec54d07
Binary files /dev/null and b/osu.Game.Rulesets.Taiko.Tests/Resources/old-skin/taikohitcircle.png differ
diff --git a/osu.Game.Rulesets.Taiko.Tests/Resources/old-skin/taikohitcircleoverlay-0.png b/osu.Game.Rulesets.Taiko.Tests/Resources/old-skin/taikohitcircleoverlay-0.png
new file mode 100644
index 0000000000..272c6bcaf7
Binary files /dev/null and b/osu.Game.Rulesets.Taiko.Tests/Resources/old-skin/taikohitcircleoverlay-0.png differ
diff --git a/osu.Game.Rulesets.Taiko.Tests/Resources/old-skin/taikohitcircleoverlay-1.png b/osu.Game.Rulesets.Taiko.Tests/Resources/old-skin/taikohitcircleoverlay-1.png
new file mode 100644
index 0000000000..e49e82a71f
Binary files /dev/null and b/osu.Game.Rulesets.Taiko.Tests/Resources/old-skin/taikohitcircleoverlay-1.png differ
diff --git a/osu.Game.Rulesets.Taiko.Tests/TestSceneDrawableHit.cs b/osu.Game.Rulesets.Taiko.Tests/TestSceneDrawableHit.cs
new file mode 100644
index 0000000000..301295253d
--- /dev/null
+++ b/osu.Game.Rulesets.Taiko.Tests/TestSceneDrawableHit.cs
@@ -0,0 +1,70 @@
+// Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence.
+// See the LICENCE file in the repository root for full licence text.
+
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using NUnit.Framework;
+using osu.Framework.Allocation;
+using osu.Framework.Graphics;
+using osu.Game.Beatmaps;
+using osu.Game.Beatmaps.ControlPoints;
+using osu.Game.Rulesets.Taiko.Objects;
+using osu.Game.Rulesets.Taiko.Objects.Drawables;
+using osu.Game.Rulesets.Taiko.Skinning;
+
+namespace osu.Game.Rulesets.Taiko.Tests
+{
+ [TestFixture]
+ public class TestSceneDrawableHit : TaikoSkinnableTestScene
+ {
+ public override IReadOnlyList RequiredTypes => base.RequiredTypes.Concat(new[]
+ {
+ typeof(DrawableHit),
+ typeof(DrawableCentreHit),
+ typeof(DrawableRimHit),
+ typeof(LegacyHit),
+ }).ToList();
+
+ [BackgroundDependencyLoader]
+ private void load()
+ {
+ AddStep("Centre hit", () => SetContents(() => new DrawableCentreHit(createHitAtCurrentTime())
+ {
+ Anchor = Anchor.Centre,
+ Origin = Anchor.Centre,
+ }));
+
+ AddStep("Centre hit (strong)", () => SetContents(() => new DrawableCentreHit(createHitAtCurrentTime(true))
+ {
+ Anchor = Anchor.Centre,
+ Origin = Anchor.Centre,
+ }));
+
+ AddStep("Rim hit", () => SetContents(() => new DrawableRimHit(createHitAtCurrentTime())
+ {
+ Anchor = Anchor.Centre,
+ Origin = Anchor.Centre,
+ }));
+
+ AddStep("Rim hit (strong)", () => SetContents(() => new DrawableRimHit(createHitAtCurrentTime(true))
+ {
+ Anchor = Anchor.Centre,
+ Origin = Anchor.Centre,
+ }));
+ }
+
+ private Hit createHitAtCurrentTime(bool strong = false)
+ {
+ var hit = new Hit
+ {
+ IsStrong = strong,
+ StartTime = Time.Current + 3000,
+ };
+
+ hit.ApplyDefaults(new ControlPointInfo(), new BeatmapDifficulty());
+
+ return hit;
+ }
+ }
+}
diff --git a/osu.Game.Rulesets.Taiko/Objects/Drawables/DrawableCentreHit.cs b/osu.Game.Rulesets.Taiko/Objects/Drawables/DrawableCentreHit.cs
index 4979135f50..f3f4c59a62 100644
--- a/osu.Game.Rulesets.Taiko/Objects/Drawables/DrawableCentreHit.cs
+++ b/osu.Game.Rulesets.Taiko/Objects/Drawables/DrawableCentreHit.cs
@@ -1,9 +1,9 @@
// Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence.
// See the LICENCE file in the repository root for full licence text.
-using osu.Framework.Allocation;
-using osu.Game.Graphics;
+using osu.Framework.Graphics.Containers;
using osu.Game.Rulesets.Taiko.Objects.Drawables.Pieces;
+using osu.Game.Skinning;
namespace osu.Game.Rulesets.Taiko.Objects.Drawables
{
@@ -14,13 +14,9 @@ namespace osu.Game.Rulesets.Taiko.Objects.Drawables
public DrawableCentreHit(Hit hit)
: base(hit)
{
- MainPiece.Add(new CentreHitSymbolPiece());
}
- [BackgroundDependencyLoader]
- private void load(OsuColour colours)
- {
- MainPiece.AccentColour = colours.PinkDarker;
- }
+ protected override CompositeDrawable CreateMainPiece() => new SkinnableDrawable(new TaikoSkinComponent(TaikoSkinComponents.CentreHit),
+ _ => new CentreHitCirclePiece(), confineMode: ConfineMode.ScaleToFit);
}
}
diff --git a/osu.Game.Rulesets.Taiko/Objects/Drawables/DrawableDrumRoll.cs b/osu.Game.Rulesets.Taiko/Objects/Drawables/DrawableDrumRoll.cs
index 5806c90115..0627eb95fd 100644
--- a/osu.Game.Rulesets.Taiko/Objects/Drawables/DrawableDrumRoll.cs
+++ b/osu.Game.Rulesets.Taiko/Objects/Drawables/DrawableDrumRoll.cs
@@ -34,17 +34,19 @@ namespace osu.Game.Rulesets.Taiko.Objects.Drawables
private Color4 colourIdle;
private Color4 colourEngaged;
+ private ElongatedCirclePiece elongatedPiece;
+
public DrawableDrumRoll(DrumRoll drumRoll)
: base(drumRoll)
{
RelativeSizeAxes = Axes.Y;
- MainPiece.Add(tickContainer = new Container { RelativeSizeAxes = Axes.Both });
+ elongatedPiece.Add(tickContainer = new Container { RelativeSizeAxes = Axes.Both });
}
[BackgroundDependencyLoader]
private void load(OsuColour colours)
{
- MainPiece.AccentColour = colourIdle = colours.YellowDark;
+ elongatedPiece.AccentColour = colourIdle = colours.YellowDark;
colourEngaged = colours.YellowDarker;
}
@@ -84,7 +86,7 @@ namespace osu.Game.Rulesets.Taiko.Objects.Drawables
return base.CreateNestedHitObject(hitObject);
}
- protected override TaikoPiece CreateMainPiece() => new ElongatedCirclePiece();
+ protected override CompositeDrawable CreateMainPiece() => elongatedPiece = new ElongatedCirclePiece();
public override bool OnPressed(TaikoAction action) => false;
@@ -101,7 +103,7 @@ namespace osu.Game.Rulesets.Taiko.Objects.Drawables
rollingHits = Math.Clamp(rollingHits, 0, rolling_hits_for_engaged_colour);
Color4 newColour = Interpolation.ValueAt((float)rollingHits / rolling_hits_for_engaged_colour, colourIdle, colourEngaged, 0, 1);
- MainPiece.FadeAccent(newColour, 100);
+ (MainPiece as IHasAccentColour)?.FadeAccent(newColour, 100);
}
protected override void CheckForResult(bool userTriggered, double timeOffset)
diff --git a/osu.Game.Rulesets.Taiko/Objects/Drawables/DrawableDrumRollTick.cs b/osu.Game.Rulesets.Taiko/Objects/Drawables/DrawableDrumRollTick.cs
index 25b6141a0e..fea3eea6a9 100644
--- a/osu.Game.Rulesets.Taiko/Objects/Drawables/DrawableDrumRollTick.cs
+++ b/osu.Game.Rulesets.Taiko/Objects/Drawables/DrawableDrumRollTick.cs
@@ -3,6 +3,7 @@
using System;
using osu.Framework.Graphics;
+using osu.Framework.Graphics.Containers;
using osu.Game.Rulesets.Objects.Drawables;
using osu.Game.Rulesets.Scoring;
using osu.Game.Rulesets.Taiko.Objects.Drawables.Pieces;
@@ -19,7 +20,7 @@ namespace osu.Game.Rulesets.Taiko.Objects.Drawables
public override bool DisplayResult => false;
- protected override TaikoPiece CreateMainPiece() => new TickPiece
+ protected override CompositeDrawable CreateMainPiece() => new TickPiece
{
Filled = HitObject.FirstTick
};
diff --git a/osu.Game.Rulesets.Taiko/Objects/Drawables/DrawableRimHit.cs b/osu.Game.Rulesets.Taiko/Objects/Drawables/DrawableRimHit.cs
index 5a12d71cea..463a8b746c 100644
--- a/osu.Game.Rulesets.Taiko/Objects/Drawables/DrawableRimHit.cs
+++ b/osu.Game.Rulesets.Taiko/Objects/Drawables/DrawableRimHit.cs
@@ -1,9 +1,9 @@
// Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence.
// See the LICENCE file in the repository root for full licence text.
-using osu.Framework.Allocation;
-using osu.Game.Graphics;
+using osu.Framework.Graphics.Containers;
using osu.Game.Rulesets.Taiko.Objects.Drawables.Pieces;
+using osu.Game.Skinning;
namespace osu.Game.Rulesets.Taiko.Objects.Drawables
{
@@ -14,13 +14,9 @@ namespace osu.Game.Rulesets.Taiko.Objects.Drawables
public DrawableRimHit(Hit hit)
: base(hit)
{
- MainPiece.Add(new RimHitSymbolPiece());
}
- [BackgroundDependencyLoader]
- private void load(OsuColour colours)
- {
- MainPiece.AccentColour = colours.BlueDarker;
- }
+ protected override CompositeDrawable CreateMainPiece() => new SkinnableDrawable(new TaikoSkinComponent(TaikoSkinComponents.RimHit),
+ _ => new RimHitCirclePiece(), confineMode: ConfineMode.ScaleToFit);
}
}
diff --git a/osu.Game.Rulesets.Taiko/Objects/Drawables/DrawableSwell.cs b/osu.Game.Rulesets.Taiko/Objects/Drawables/DrawableSwell.cs
index fa39819199..3a2e44038f 100644
--- a/osu.Game.Rulesets.Taiko/Objects/Drawables/DrawableSwell.cs
+++ b/osu.Game.Rulesets.Taiko/Objects/Drawables/DrawableSwell.cs
@@ -9,11 +9,11 @@ using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers;
using osu.Game.Graphics;
using osu.Game.Rulesets.Objects.Drawables;
-using osu.Game.Rulesets.Taiko.Objects.Drawables.Pieces;
using osuTK.Graphics;
using osu.Framework.Graphics.Shapes;
using osu.Game.Rulesets.Objects;
using osu.Game.Rulesets.Scoring;
+using osu.Game.Rulesets.Taiko.Objects.Drawables.Pieces;
namespace osu.Game.Rulesets.Taiko.Objects.Drawables
{
@@ -34,8 +34,6 @@ namespace osu.Game.Rulesets.Taiko.Objects.Drawables
private readonly CircularContainer targetRing;
private readonly CircularContainer expandingRing;
- private readonly SwellSymbolPiece symbol;
-
public DrawableSwell(Swell swell)
: base(swell)
{
@@ -107,18 +105,22 @@ namespace osu.Game.Rulesets.Taiko.Objects.Drawables
});
AddInternal(ticks = new Container { RelativeSizeAxes = Axes.Both });
-
- MainPiece.Add(symbol = new SwellSymbolPiece());
}
[BackgroundDependencyLoader]
private void load(OsuColour colours)
{
- MainPiece.AccentColour = colours.YellowDark;
expandingRing.Colour = colours.YellowLight;
targetRing.BorderColour = colours.YellowDark.Opacity(0.25f);
}
+ protected override CompositeDrawable CreateMainPiece() => new SwellCirclePiece
+ {
+ // to allow for rotation transform
+ Anchor = Anchor.Centre,
+ Origin = Anchor.Centre,
+ };
+
protected override void LoadComplete()
{
base.LoadComplete();
@@ -182,7 +184,7 @@ namespace osu.Game.Rulesets.Taiko.Objects.Drawables
.Then()
.FadeTo(completion / 8, 2000, Easing.OutQuint);
- symbol.RotateTo((float)(completion * HitObject.Duration / 8), 4000, Easing.OutQuint);
+ MainPiece.RotateTo((float)(completion * HitObject.Duration / 8), 4000, Easing.OutQuint);
expandingRing.ScaleTo(1f + Math.Min(target_ring_scale - 1f, (target_ring_scale - 1f) * completion * 1.3f), 260, Easing.OutQuint);
diff --git a/osu.Game.Rulesets.Taiko/Objects/Drawables/DrawableSwellTick.cs b/osu.Game.Rulesets.Taiko/Objects/Drawables/DrawableSwellTick.cs
index ce875ebba8..5a954addfb 100644
--- a/osu.Game.Rulesets.Taiko/Objects/Drawables/DrawableSwellTick.cs
+++ b/osu.Game.Rulesets.Taiko/Objects/Drawables/DrawableSwellTick.cs
@@ -2,7 +2,9 @@
// See the LICENCE file in the repository root for full licence text.
using osu.Framework.Graphics;
+using osu.Framework.Graphics.Containers;
using osu.Game.Rulesets.Scoring;
+using osu.Game.Rulesets.Taiko.Objects.Drawables.Pieces;
namespace osu.Game.Rulesets.Taiko.Objects.Drawables
{
@@ -28,5 +30,7 @@ namespace osu.Game.Rulesets.Taiko.Objects.Drawables
}
public override bool OnPressed(TaikoAction action) => false;
+
+ protected override CompositeDrawable CreateMainPiece() => new TickPiece();
}
}
diff --git a/osu.Game.Rulesets.Taiko/Objects/Drawables/DrawableTaikoHitObject.cs b/osu.Game.Rulesets.Taiko/Objects/Drawables/DrawableTaikoHitObject.cs
index 5f892dd2fa..2f90f3b96c 100644
--- a/osu.Game.Rulesets.Taiko/Objects/Drawables/DrawableTaikoHitObject.cs
+++ b/osu.Game.Rulesets.Taiko/Objects/Drawables/DrawableTaikoHitObject.cs
@@ -4,7 +4,6 @@
using osu.Framework.Graphics;
using osu.Framework.Input.Bindings;
using osu.Game.Rulesets.Objects.Drawables;
-using osu.Game.Rulesets.Taiko.Objects.Drawables.Pieces;
using osuTK;
using System.Linq;
using osu.Game.Audio;
@@ -45,7 +44,7 @@ namespace osu.Game.Rulesets.Taiko.Objects.Drawables
///
/// Moves to a layer proxied above the playfield.
- /// Does nothing is content is already proxied.
+ /// Does nothing if content is already proxied.
///
protected void ProxyContent()
{
@@ -108,19 +107,19 @@ namespace osu.Game.Rulesets.Taiko.Objects.Drawables
}
}
- public abstract class DrawableTaikoHitObject : DrawableTaikoHitObject
- where TTaikoHit : TaikoHitObject
+ public abstract class DrawableTaikoHitObject : DrawableTaikoHitObject
+ where TObject : TaikoHitObject
{
public override Vector2 OriginPosition => new Vector2(DrawHeight / 2);
- public new TTaikoHit HitObject;
+ public new TObject HitObject;
protected readonly Vector2 BaseSize;
- protected readonly TaikoPiece MainPiece;
+ protected readonly CompositeDrawable MainPiece;
private readonly Container strongHitContainer;
- protected DrawableTaikoHitObject(TTaikoHit hitObject)
+ protected DrawableTaikoHitObject(TObject hitObject)
: base(hitObject)
{
HitObject = hitObject;
@@ -132,7 +131,6 @@ namespace osu.Game.Rulesets.Taiko.Objects.Drawables
Size = BaseSize = new Vector2(HitObject.IsStrong ? TaikoHitObject.DEFAULT_STRONG_SIZE : TaikoHitObject.DEFAULT_SIZE);
Content.Add(MainPiece = CreateMainPiece());
- MainPiece.KiaiMode = HitObject.Kiai;
AddInternal(strongHitContainer = new Container());
}
@@ -169,7 +167,7 @@ namespace osu.Game.Rulesets.Taiko.Objects.Drawables
// Normal and clap samples are handled by the drum
protected override IEnumerable GetSamples() => HitObject.Samples.Where(s => s.Name != HitSampleInfo.HIT_NORMAL && s.Name != HitSampleInfo.HIT_CLAP);
- protected virtual TaikoPiece CreateMainPiece() => new CirclePiece();
+ protected abstract CompositeDrawable CreateMainPiece();
///
/// Creates the handler for this 's .
diff --git a/osu.Game.Rulesets.Taiko/Objects/Drawables/Pieces/CentreHitCirclePiece.cs b/osu.Game.Rulesets.Taiko/Objects/Drawables/Pieces/CentreHitCirclePiece.cs
new file mode 100644
index 0000000000..0509841ba8
--- /dev/null
+++ b/osu.Game.Rulesets.Taiko/Objects/Drawables/Pieces/CentreHitCirclePiece.cs
@@ -0,0 +1,52 @@
+// Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence.
+// See the LICENCE file in the repository root for full licence text.
+
+using osu.Framework.Allocation;
+using osu.Framework.Graphics;
+using osu.Framework.Graphics.Containers;
+using osuTK;
+using osu.Framework.Graphics.Shapes;
+using osu.Game.Graphics;
+
+namespace osu.Game.Rulesets.Taiko.Objects.Drawables.Pieces
+{
+ public class CentreHitCirclePiece : CirclePiece
+ {
+ public CentreHitCirclePiece()
+ {
+ Add(new CentreHitSymbolPiece());
+ }
+
+ [BackgroundDependencyLoader]
+ private void load(OsuColour colours)
+ {
+ AccentColour = colours.PinkDarker;
+ }
+
+ ///
+ /// The symbol used for centre hit pieces.
+ ///
+ public class CentreHitSymbolPiece : Container
+ {
+ public CentreHitSymbolPiece()
+ {
+ Anchor = Anchor.Centre;
+ Origin = Anchor.Centre;
+
+ RelativeSizeAxes = Axes.Both;
+ Size = new Vector2(SYMBOL_SIZE);
+ Padding = new MarginPadding(SYMBOL_BORDER);
+
+ Children = new[]
+ {
+ new CircularContainer
+ {
+ RelativeSizeAxes = Axes.Both,
+ Masking = true,
+ Children = new[] { new Box { RelativeSizeAxes = Axes.Both } }
+ }
+ };
+ }
+ }
+ }
+}
diff --git a/osu.Game.Rulesets.Taiko/Objects/Drawables/Pieces/CentreHitSymbolPiece.cs b/osu.Game.Rulesets.Taiko/Objects/Drawables/Pieces/CentreHitSymbolPiece.cs
deleted file mode 100644
index 7ed61ede96..0000000000
--- a/osu.Game.Rulesets.Taiko/Objects/Drawables/Pieces/CentreHitSymbolPiece.cs
+++ /dev/null
@@ -1,36 +0,0 @@
-// Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence.
-// See the LICENCE file in the repository root for full licence text.
-
-using osu.Framework.Graphics;
-using osu.Framework.Graphics.Containers;
-using osuTK;
-using osu.Framework.Graphics.Shapes;
-
-namespace osu.Game.Rulesets.Taiko.Objects.Drawables.Pieces
-{
- ///
- /// The symbol used for centre hit pieces.
- ///
- public class CentreHitSymbolPiece : Container
- {
- public CentreHitSymbolPiece()
- {
- Anchor = Anchor.Centre;
- Origin = Anchor.Centre;
-
- RelativeSizeAxes = Axes.Both;
- Size = new Vector2(CirclePiece.SYMBOL_SIZE);
- Padding = new MarginPadding(CirclePiece.SYMBOL_BORDER);
-
- Children = new[]
- {
- new CircularContainer
- {
- RelativeSizeAxes = Axes.Both,
- Masking = true,
- Children = new[] { new Box { RelativeSizeAxes = Axes.Both } }
- }
- };
- }
- }
-}
diff --git a/osu.Game.Rulesets.Taiko/Objects/Drawables/Pieces/CirclePiece.cs b/osu.Game.Rulesets.Taiko/Objects/Drawables/Pieces/CirclePiece.cs
index d9c0664ecd..6ca77e666d 100644
--- a/osu.Game.Rulesets.Taiko/Objects/Drawables/Pieces/CirclePiece.cs
+++ b/osu.Game.Rulesets.Taiko/Objects/Drawables/Pieces/CirclePiece.cs
@@ -10,6 +10,7 @@ using osuTK.Graphics;
using osu.Game.Beatmaps.ControlPoints;
using osu.Framework.Audio.Track;
using osu.Framework.Graphics.Effects;
+using osu.Game.Graphics.Containers;
namespace osu.Game.Rulesets.Taiko.Objects.Drawables.Pieces
{
@@ -20,21 +21,23 @@ namespace osu.Game.Rulesets.Taiko.Objects.Drawables.Pieces
/// for a usage example.
///
///
- public class CirclePiece : TaikoPiece
+ public abstract class CirclePiece : BeatSyncedContainer
{
public const float SYMBOL_SIZE = 0.45f;
public const float SYMBOL_BORDER = 8;
private const double pre_beat_transition_time = 80;
+ private Color4 accentColour;
+
///
/// The colour of the inner circle and outer glows.
///
- public override Color4 AccentColour
+ public Color4 AccentColour
{
- get => base.AccentColour;
+ get => accentColour;
set
{
- base.AccentColour = value;
+ accentColour = value;
background.Colour = AccentColour;
@@ -42,15 +45,17 @@ namespace osu.Game.Rulesets.Taiko.Objects.Drawables.Pieces
}
}
+ private bool kiaiMode;
+
///
/// Whether Kiai mode effects are enabled for this circle piece.
///
- public override bool KiaiMode
+ public bool KiaiMode
{
- get => base.KiaiMode;
+ get => kiaiMode;
set
{
- base.KiaiMode = value;
+ kiaiMode = value;
resetEdgeEffects();
}
@@ -64,8 +69,10 @@ namespace osu.Game.Rulesets.Taiko.Objects.Drawables.Pieces
public Box FlashBox;
- public CirclePiece()
+ protected CirclePiece()
{
+ RelativeSizeAxes = Axes.Both;
+
EarlyActivationMilliseconds = pre_beat_transition_time;
AddRangeInternal(new Drawable[]
diff --git a/osu.Game.Rulesets.Taiko/Objects/Drawables/Pieces/RimHitCirclePiece.cs b/osu.Game.Rulesets.Taiko/Objects/Drawables/Pieces/RimHitCirclePiece.cs
new file mode 100644
index 0000000000..3273ab7fa7
--- /dev/null
+++ b/osu.Game.Rulesets.Taiko/Objects/Drawables/Pieces/RimHitCirclePiece.cs
@@ -0,0 +1,55 @@
+// Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence.
+// See the LICENCE file in the repository root for full licence text.
+
+using osu.Framework.Allocation;
+using osu.Framework.Graphics;
+using osu.Framework.Graphics.Containers;
+using osu.Framework.Graphics.Shapes;
+using osu.Game.Graphics;
+using osuTK;
+using osuTK.Graphics;
+
+namespace osu.Game.Rulesets.Taiko.Objects.Drawables.Pieces
+{
+ public class RimHitCirclePiece : CirclePiece
+ {
+ public RimHitCirclePiece()
+ {
+ Add(new RimHitSymbolPiece());
+ }
+
+ [BackgroundDependencyLoader]
+ private void load(OsuColour colours)
+ {
+ AccentColour = colours.BlueDarker;
+ }
+
+ ///
+ /// The symbol used for rim hit pieces.
+ ///
+ public class RimHitSymbolPiece : CircularContainer
+ {
+ public RimHitSymbolPiece()
+ {
+ Anchor = Anchor.Centre;
+ Origin = Anchor.Centre;
+
+ RelativeSizeAxes = Axes.Both;
+ Size = new Vector2(SYMBOL_SIZE);
+
+ BorderThickness = SYMBOL_BORDER;
+ BorderColour = Color4.White;
+ Masking = true;
+ Children = new[]
+ {
+ new Box
+ {
+ RelativeSizeAxes = Axes.Both,
+ Alpha = 0,
+ AlwaysPresent = true
+ }
+ };
+ }
+ }
+ }
+}
diff --git a/osu.Game.Rulesets.Taiko/Objects/Drawables/Pieces/RimHitSymbolPiece.cs b/osu.Game.Rulesets.Taiko/Objects/Drawables/Pieces/RimHitSymbolPiece.cs
deleted file mode 100644
index e4c964a884..0000000000
--- a/osu.Game.Rulesets.Taiko/Objects/Drawables/Pieces/RimHitSymbolPiece.cs
+++ /dev/null
@@ -1,39 +0,0 @@
-// Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence.
-// See the LICENCE file in the repository root for full licence text.
-
-using osu.Framework.Graphics;
-using osu.Framework.Graphics.Containers;
-using osuTK;
-using osuTK.Graphics;
-using osu.Framework.Graphics.Shapes;
-
-namespace osu.Game.Rulesets.Taiko.Objects.Drawables.Pieces
-{
- ///
- /// The symbol used for rim hit pieces.
- ///
- public class RimHitSymbolPiece : CircularContainer
- {
- public RimHitSymbolPiece()
- {
- Anchor = Anchor.Centre;
- Origin = Anchor.Centre;
-
- RelativeSizeAxes = Axes.Both;
- Size = new Vector2(CirclePiece.SYMBOL_SIZE);
-
- BorderThickness = CirclePiece.SYMBOL_BORDER;
- BorderColour = Color4.White;
- Masking = true;
- Children = new[]
- {
- new Box
- {
- RelativeSizeAxes = Axes.Both,
- Alpha = 0,
- AlwaysPresent = true
- }
- };
- }
- }
-}
diff --git a/osu.Game.Rulesets.Taiko/Objects/Drawables/Pieces/SwellSymbolPiece.cs b/osu.Game.Rulesets.Taiko/Objects/Drawables/Pieces/SwellSymbolPiece.cs
index 0ed9923924..a8f9f0b94d 100644
--- a/osu.Game.Rulesets.Taiko/Objects/Drawables/Pieces/SwellSymbolPiece.cs
+++ b/osu.Game.Rulesets.Taiko/Objects/Drawables/Pieces/SwellSymbolPiece.cs
@@ -1,36 +1,52 @@
// Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence.
// See the LICENCE file in the repository root for full licence text.
+using osu.Framework.Allocation;
using osuTK;
using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers;
using osu.Framework.Graphics.Sprites;
+using osu.Game.Graphics;
namespace osu.Game.Rulesets.Taiko.Objects.Drawables.Pieces
{
- ///
- /// The symbol used for swell pieces.
- ///
- public class SwellSymbolPiece : Container
+ public class SwellCirclePiece : CirclePiece
{
- public SwellSymbolPiece()
+ public SwellCirclePiece()
{
- Anchor = Anchor.Centre;
- Origin = Anchor.Centre;
+ Add(new SwellSymbolPiece());
+ }
- RelativeSizeAxes = Axes.Both;
- Size = new Vector2(CirclePiece.SYMBOL_SIZE);
- Padding = new MarginPadding(CirclePiece.SYMBOL_BORDER);
+ [BackgroundDependencyLoader]
+ private void load(OsuColour colours)
+ {
+ AccentColour = colours.YellowDark;
+ }
- Children = new[]
+ ///
+ /// The symbol used for swell pieces.
+ ///
+ public class SwellSymbolPiece : Container
+ {
+ public SwellSymbolPiece()
{
- new SpriteIcon
+ Anchor = Anchor.Centre;
+ Origin = Anchor.Centre;
+
+ RelativeSizeAxes = Axes.Both;
+ Size = new Vector2(SYMBOL_SIZE);
+ Padding = new MarginPadding(SYMBOL_BORDER);
+
+ Children = new[]
{
- RelativeSizeAxes = Axes.Both,
- Icon = FontAwesome.Solid.Asterisk,
- Shadow = false
- }
- };
+ new SpriteIcon
+ {
+ RelativeSizeAxes = Axes.Both,
+ Icon = FontAwesome.Solid.Asterisk,
+ Shadow = false
+ }
+ };
+ }
}
}
}
diff --git a/osu.Game.Rulesets.Taiko/Objects/Drawables/Pieces/TaikoPiece.cs b/osu.Game.Rulesets.Taiko/Objects/Drawables/Pieces/TaikoPiece.cs
deleted file mode 100644
index 8067054f8f..0000000000
--- a/osu.Game.Rulesets.Taiko/Objects/Drawables/Pieces/TaikoPiece.cs
+++ /dev/null
@@ -1,28 +0,0 @@
-// Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence.
-// See the LICENCE file in the repository root for full licence text.
-
-using osu.Game.Graphics;
-using osuTK.Graphics;
-using osu.Game.Graphics.Containers;
-using osu.Framework.Graphics;
-
-namespace osu.Game.Rulesets.Taiko.Objects.Drawables.Pieces
-{
- public class TaikoPiece : BeatSyncedContainer, IHasAccentColour
- {
- ///
- /// The colour of the inner circle and outer glows.
- ///
- public virtual Color4 AccentColour { get; set; }
-
- ///
- /// Whether Kiai mode effects are enabled for this circle piece.
- ///
- public virtual bool KiaiMode { get; set; }
-
- public TaikoPiece()
- {
- RelativeSizeAxes = Axes.Both;
- }
- }
-}
diff --git a/osu.Game.Rulesets.Taiko/Objects/Drawables/Pieces/TickPiece.cs b/osu.Game.Rulesets.Taiko/Objects/Drawables/Pieces/TickPiece.cs
index 83cf7a64ec..0648bcebcd 100644
--- a/osu.Game.Rulesets.Taiko/Objects/Drawables/Pieces/TickPiece.cs
+++ b/osu.Game.Rulesets.Taiko/Objects/Drawables/Pieces/TickPiece.cs
@@ -9,7 +9,7 @@ using osu.Framework.Graphics.Shapes;
namespace osu.Game.Rulesets.Taiko.Objects.Drawables.Pieces
{
- public class TickPiece : TaikoPiece
+ public class TickPiece : CompositeDrawable
{
///
/// Any tick that is not the first for a drumroll is not filled, but is instead displayed
@@ -45,7 +45,7 @@ namespace osu.Game.Rulesets.Taiko.Objects.Drawables.Pieces
FillMode = FillMode.Fit;
Size = new Vector2(tick_size);
- Add(new CircularContainer
+ InternalChild = new CircularContainer
{
RelativeSizeAxes = Axes.Both,
Masking = true,
@@ -60,7 +60,7 @@ namespace osu.Game.Rulesets.Taiko.Objects.Drawables.Pieces
AlwaysPresent = true
}
}
- });
+ };
}
}
}
diff --git a/osu.Game.Rulesets.Taiko/Skinning/LegacyHit.cs b/osu.Game.Rulesets.Taiko/Skinning/LegacyHit.cs
new file mode 100644
index 0000000000..80bf97936d
--- /dev/null
+++ b/osu.Game.Rulesets.Taiko/Skinning/LegacyHit.cs
@@ -0,0 +1,91 @@
+// Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence.
+// See the LICENCE file in the repository root for full licence text.
+
+using osu.Framework.Allocation;
+using osu.Framework.Graphics;
+using osu.Framework.Graphics.Animations;
+using osu.Framework.Graphics.Containers;
+using osu.Game.Graphics;
+using osu.Game.Rulesets.Objects.Drawables;
+using osu.Game.Rulesets.Taiko.Objects.Drawables;
+using osu.Game.Skinning;
+using osuTK;
+using osuTK.Graphics;
+
+namespace osu.Game.Rulesets.Taiko.Skinning
+{
+ public class LegacyHit : CompositeDrawable, IHasAccentColour
+ {
+ private readonly TaikoSkinComponents component;
+
+ private Drawable backgroundLayer;
+
+ public LegacyHit(TaikoSkinComponents component)
+ {
+ this.component = component;
+
+ RelativeSizeAxes = Axes.Both;
+ }
+
+ [BackgroundDependencyLoader]
+ private void load(ISkinSource skin, DrawableHitObject drawableHitObject)
+ {
+ Drawable getDrawableFor(string lookup)
+ {
+ const string normal_hit = "taikohit";
+ const string big_hit = "taikobig";
+
+ string prefix = ((drawableHitObject as DrawableTaikoHitObject)?.HitObject.IsStrong ?? false) ? big_hit : normal_hit;
+
+ return skin.GetAnimation($"{prefix}{lookup}", true, false) ??
+ // fallback to regular size if "big" version doesn't exist.
+ skin.GetAnimation($"{normal_hit}{lookup}", true, false);
+ }
+
+ // backgroundLayer is guaranteed to exist due to the pre-check in TaikoLegacySkinTransformer.
+ AddInternal(backgroundLayer = getDrawableFor("circle"));
+
+ var foregroundLayer = getDrawableFor("circleoverlay");
+ if (foregroundLayer != null)
+ AddInternal(foregroundLayer);
+
+ // Animations in taiko skins are used in a custom way (>150 combo and animating in time with beat).
+ // For now just stop at first frame for sanity.
+ foreach (var c in InternalChildren)
+ {
+ (c as IFramedAnimation)?.Stop();
+
+ c.Anchor = Anchor.Centre;
+ c.Origin = Anchor.Centre;
+ }
+
+ AccentColour = component == TaikoSkinComponents.CentreHit
+ ? new Color4(235, 69, 44, 255)
+ : new Color4(67, 142, 172, 255);
+ }
+
+ protected override void Update()
+ {
+ base.Update();
+
+ // Not all skins (including the default osu-stable) have similar sizes for "hitcircle" and "hitcircleoverlay".
+ // This ensures they are scaled relative to each other but also match the expected DrawableHit size.
+ foreach (var c in InternalChildren)
+ c.Scale = new Vector2(DrawWidth / 128);
+ }
+
+ private Color4 accentColour;
+
+ public Color4 AccentColour
+ {
+ get => accentColour;
+ set
+ {
+ if (value == accentColour)
+ return;
+
+ backgroundLayer.Colour = accentColour = value;
+ }
+ }
+ }
+}
diff --git a/osu.Game.Rulesets.Taiko/Skinning/TaikoLegacySkinTransformer.cs b/osu.Game.Rulesets.Taiko/Skinning/TaikoLegacySkinTransformer.cs
index 78eec94590..9cd625c35f 100644
--- a/osu.Game.Rulesets.Taiko/Skinning/TaikoLegacySkinTransformer.cs
+++ b/osu.Game.Rulesets.Taiko/Skinning/TaikoLegacySkinTransformer.cs
@@ -32,6 +32,14 @@ namespace osu.Game.Rulesets.Taiko.Skinning
return new LegacyInputDrum();
return null;
+
+ case TaikoSkinComponents.CentreHit:
+ case TaikoSkinComponents.RimHit:
+
+ if (GetTexture("taikohitcircle") != null)
+ return new LegacyHit(taikoComponent.Component);
+
+ return null;
}
return source.GetDrawableComponent(component);
diff --git a/osu.Game.Rulesets.Taiko/TaikoSkinComponents.cs b/osu.Game.Rulesets.Taiko/TaikoSkinComponents.cs
index 6d4581db80..babf21b6a9 100644
--- a/osu.Game.Rulesets.Taiko/TaikoSkinComponents.cs
+++ b/osu.Game.Rulesets.Taiko/TaikoSkinComponents.cs
@@ -6,5 +6,7 @@ namespace osu.Game.Rulesets.Taiko
public enum TaikoSkinComponents
{
InputDrum,
+ CentreHit,
+ RimHit
}
}
diff --git a/osu.Game.Tests/Editor/EditorChangeHandlerTest.cs b/osu.Game.Tests/Editor/EditorChangeHandlerTest.cs
new file mode 100644
index 0000000000..9613f250c4
--- /dev/null
+++ b/osu.Game.Tests/Editor/EditorChangeHandlerTest.cs
@@ -0,0 +1,74 @@
+// Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence.
+// See the LICENCE file in the repository root for full licence text.
+
+using NUnit.Framework;
+using osu.Game.Beatmaps;
+using osu.Game.Screens.Edit;
+
+namespace osu.Game.Tests.Editor
+{
+ [TestFixture]
+ public class EditorChangeHandlerTest
+ {
+ [Test]
+ public void TestSaveRestoreState()
+ {
+ var handler = new EditorChangeHandler(new EditorBeatmap(new Beatmap()));
+
+ Assert.That(handler.CanUndo.Value, Is.False);
+ Assert.That(handler.CanRedo.Value, Is.False);
+
+ handler.SaveState();
+
+ Assert.That(handler.CanUndo.Value, Is.True);
+ Assert.That(handler.CanRedo.Value, Is.False);
+
+ handler.RestoreState(-1);
+
+ Assert.That(handler.CanUndo.Value, Is.False);
+ Assert.That(handler.CanRedo.Value, Is.True);
+ }
+
+ [Test]
+ public void TestMaxStatesSaved()
+ {
+ var handler = new EditorChangeHandler(new EditorBeatmap(new Beatmap()));
+
+ Assert.That(handler.CanUndo.Value, Is.False);
+
+ for (int i = 0; i < EditorChangeHandler.MAX_SAVED_STATES; i++)
+ handler.SaveState();
+
+ Assert.That(handler.CanUndo.Value, Is.True);
+
+ for (int i = 0; i < EditorChangeHandler.MAX_SAVED_STATES; i++)
+ {
+ Assert.That(handler.CanUndo.Value, Is.True);
+ handler.RestoreState(-1);
+ }
+
+ Assert.That(handler.CanUndo.Value, Is.False);
+ }
+
+ [Test]
+ public void TestMaxStatesExceeded()
+ {
+ var handler = new EditorChangeHandler(new EditorBeatmap(new Beatmap()));
+
+ Assert.That(handler.CanUndo.Value, Is.False);
+
+ for (int i = 0; i < EditorChangeHandler.MAX_SAVED_STATES * 2; i++)
+ handler.SaveState();
+
+ Assert.That(handler.CanUndo.Value, Is.True);
+
+ for (int i = 0; i < EditorChangeHandler.MAX_SAVED_STATES; i++)
+ {
+ Assert.That(handler.CanUndo.Value, Is.True);
+ handler.RestoreState(-1);
+ }
+
+ Assert.That(handler.CanUndo.Value, Is.False);
+ }
+ }
+}
diff --git a/osu.Game.Tests/Editor/LegacyEditorBeatmapPatcherTest.cs b/osu.Game.Tests/Editor/LegacyEditorBeatmapPatcherTest.cs
new file mode 100644
index 0000000000..c24418d688
--- /dev/null
+++ b/osu.Game.Tests/Editor/LegacyEditorBeatmapPatcherTest.cs
@@ -0,0 +1,342 @@
+// Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence.
+// See the LICENCE file in the repository root for full licence text.
+
+using System.IO;
+using System.Text;
+using NUnit.Framework;
+using osu.Game.Audio;
+using osu.Game.Beatmaps;
+using osu.Game.Beatmaps.Formats;
+using osu.Game.IO;
+using osu.Game.Rulesets.Objects;
+using osu.Game.Rulesets.Objects.Types;
+using osu.Game.Rulesets.Osu;
+using osu.Game.Rulesets.Osu.Beatmaps;
+using osu.Game.Rulesets.Osu.Objects;
+using osu.Game.Screens.Edit;
+using osuTK;
+using Decoder = osu.Game.Beatmaps.Formats.Decoder;
+
+namespace osu.Game.Tests.Editor
+{
+ [TestFixture]
+ public class LegacyEditorBeatmapPatcherTest
+ {
+ private LegacyEditorBeatmapPatcher patcher;
+ private EditorBeatmap current;
+
+ [SetUp]
+ public void Setup()
+ {
+ patcher = new LegacyEditorBeatmapPatcher(current = new EditorBeatmap(new OsuBeatmap
+ {
+ BeatmapInfo =
+ {
+ Ruleset = new OsuRuleset().RulesetInfo
+ }
+ }));
+ }
+
+ [Test]
+ public void TestAddHitObject()
+ {
+ var patch = new OsuBeatmap
+ {
+ HitObjects =
+ {
+ new HitCircle { StartTime = 1000 }
+ }
+ };
+
+ runTest(patch);
+ }
+
+ [Test]
+ public void TestInsertHitObject()
+ {
+ current.AddRange(new[]
+ {
+ new HitCircle { StartTime = 1000 },
+ new HitCircle { StartTime = 3000 },
+ });
+
+ var patch = new OsuBeatmap
+ {
+ HitObjects =
+ {
+ (OsuHitObject)current.HitObjects[0],
+ new HitCircle { StartTime = 2000 },
+ (OsuHitObject)current.HitObjects[1],
+ }
+ };
+
+ runTest(patch);
+ }
+
+ [Test]
+ public void TestDeleteHitObject()
+ {
+ current.AddRange(new[]
+ {
+ new HitCircle { StartTime = 1000 },
+ new HitCircle { StartTime = 2000 },
+ new HitCircle { StartTime = 3000 },
+ });
+
+ var patch = new OsuBeatmap
+ {
+ HitObjects =
+ {
+ (OsuHitObject)current.HitObjects[0],
+ (OsuHitObject)current.HitObjects[2],
+ }
+ };
+
+ runTest(patch);
+ }
+
+ [Test]
+ public void TestChangeStartTime()
+ {
+ current.AddRange(new[]
+ {
+ new HitCircle { StartTime = 1000 },
+ new HitCircle { StartTime = 2000 },
+ new HitCircle { StartTime = 3000 },
+ });
+
+ var patch = new OsuBeatmap
+ {
+ HitObjects =
+ {
+ new HitCircle { StartTime = 500 },
+ (OsuHitObject)current.HitObjects[1],
+ (OsuHitObject)current.HitObjects[2],
+ }
+ };
+
+ runTest(patch);
+ }
+
+ [Test]
+ public void TestChangeSample()
+ {
+ current.AddRange(new[]
+ {
+ new HitCircle { StartTime = 1000 },
+ new HitCircle { StartTime = 2000 },
+ new HitCircle { StartTime = 3000 },
+ });
+
+ var patch = new OsuBeatmap
+ {
+ HitObjects =
+ {
+ (OsuHitObject)current.HitObjects[0],
+ new HitCircle { StartTime = 2000, Samples = { new HitSampleInfo { Name = HitSampleInfo.HIT_FINISH } } },
+ (OsuHitObject)current.HitObjects[2],
+ }
+ };
+
+ runTest(patch);
+ }
+
+ [Test]
+ public void TestChangeSliderPath()
+ {
+ current.AddRange(new OsuHitObject[]
+ {
+ new HitCircle { StartTime = 1000 },
+ new Slider
+ {
+ StartTime = 2000,
+ Path = new SliderPath(new[]
+ {
+ new PathControlPoint(Vector2.Zero),
+ new PathControlPoint(Vector2.One),
+ new PathControlPoint(new Vector2(2), PathType.Bezier),
+ new PathControlPoint(new Vector2(3)),
+ }, 50)
+ },
+ new HitCircle { StartTime = 3000 },
+ });
+
+ var patch = new OsuBeatmap
+ {
+ HitObjects =
+ {
+ (OsuHitObject)current.HitObjects[0],
+ new Slider
+ {
+ StartTime = 2000,
+ Path = new SliderPath(new[]
+ {
+ new PathControlPoint(Vector2.Zero, PathType.Bezier),
+ new PathControlPoint(new Vector2(4)),
+ new PathControlPoint(new Vector2(5)),
+ }, 100)
+ },
+ (OsuHitObject)current.HitObjects[2],
+ }
+ };
+
+ runTest(patch);
+ }
+
+ [Test]
+ public void TestAddMultipleHitObjects()
+ {
+ current.AddRange(new[]
+ {
+ new HitCircle { StartTime = 1000 },
+ new HitCircle { StartTime = 2000 },
+ new HitCircle { StartTime = 3000 },
+ });
+
+ var patch = new OsuBeatmap
+ {
+ HitObjects =
+ {
+ new HitCircle { StartTime = 500 },
+ (OsuHitObject)current.HitObjects[0],
+ new HitCircle { StartTime = 1500 },
+ (OsuHitObject)current.HitObjects[1],
+ new HitCircle { StartTime = 2250 },
+ new HitCircle { StartTime = 2500 },
+ (OsuHitObject)current.HitObjects[2],
+ new HitCircle { StartTime = 3500 },
+ }
+ };
+
+ runTest(patch);
+ }
+
+ [Test]
+ public void TestDeleteMultipleHitObjects()
+ {
+ current.AddRange(new[]
+ {
+ new HitCircle { StartTime = 500 },
+ new HitCircle { StartTime = 1000 },
+ new HitCircle { StartTime = 1500 },
+ new HitCircle { StartTime = 2000 },
+ new HitCircle { StartTime = 2250 },
+ new HitCircle { StartTime = 2500 },
+ new HitCircle { StartTime = 3000 },
+ new HitCircle { StartTime = 3500 },
+ });
+
+ var patch = new OsuBeatmap
+ {
+ HitObjects =
+ {
+ (OsuHitObject)current.HitObjects[1],
+ (OsuHitObject)current.HitObjects[3],
+ (OsuHitObject)current.HitObjects[6],
+ }
+ };
+
+ runTest(patch);
+ }
+
+ [Test]
+ public void TestChangeSamplesOfMultipleHitObjects()
+ {
+ current.AddRange(new[]
+ {
+ new HitCircle { StartTime = 500 },
+ new HitCircle { StartTime = 1000 },
+ new HitCircle { StartTime = 1500 },
+ new HitCircle { StartTime = 2000 },
+ new HitCircle { StartTime = 2250 },
+ new HitCircle { StartTime = 2500 },
+ new HitCircle { StartTime = 3000 },
+ new HitCircle { StartTime = 3500 },
+ });
+
+ var patch = new OsuBeatmap
+ {
+ HitObjects =
+ {
+ (OsuHitObject)current.HitObjects[0],
+ new HitCircle { StartTime = 1000, Samples = { new HitSampleInfo { Name = HitSampleInfo.HIT_FINISH } } },
+ (OsuHitObject)current.HitObjects[2],
+ (OsuHitObject)current.HitObjects[3],
+ new HitCircle { StartTime = 2250, Samples = { new HitSampleInfo { Name = HitSampleInfo.HIT_WHISTLE } } },
+ (OsuHitObject)current.HitObjects[5],
+ new HitCircle { StartTime = 3000, Samples = { new HitSampleInfo { Name = HitSampleInfo.HIT_CLAP } } },
+ (OsuHitObject)current.HitObjects[7],
+ }
+ };
+
+ runTest(patch);
+ }
+
+ [Test]
+ public void TestAddAndDeleteHitObjects()
+ {
+ current.AddRange(new[]
+ {
+ new HitCircle { StartTime = 500 },
+ new HitCircle { StartTime = 1000 },
+ new HitCircle { StartTime = 1500 },
+ new HitCircle { StartTime = 2000 },
+ new HitCircle { StartTime = 2250 },
+ new HitCircle { StartTime = 2500 },
+ new HitCircle { StartTime = 3000 },
+ new HitCircle { StartTime = 3500 },
+ });
+
+ var patch = new OsuBeatmap
+ {
+ HitObjects =
+ {
+ new HitCircle { StartTime = 750 },
+ (OsuHitObject)current.HitObjects[1],
+ (OsuHitObject)current.HitObjects[4],
+ (OsuHitObject)current.HitObjects[5],
+ new HitCircle { StartTime = 2650 },
+ new HitCircle { StartTime = 2750 },
+ new HitCircle { StartTime = 4000 },
+ }
+ };
+
+ runTest(patch);
+ }
+
+ private void runTest(IBeatmap patch)
+ {
+ // Due to the method of testing, "patch" comes in without having been decoded via a beatmap decoder.
+ // This causes issues because the decoder adds various default properties (e.g. new combo on first object, default samples).
+ // To resolve "patch" into a sane state it is encoded and then re-decoded.
+ patch = decode(encode(patch));
+
+ // Apply the patch.
+ patcher.Patch(encode(current), encode(patch));
+
+ // Convert beatmaps to strings for assertion purposes.
+ string currentStr = Encoding.ASCII.GetString(encode(current));
+ string patchStr = Encoding.ASCII.GetString(encode(patch));
+
+ Assert.That(currentStr, Is.EqualTo(patchStr));
+ }
+
+ private byte[] encode(IBeatmap beatmap)
+ {
+ using (var encoded = new MemoryStream())
+ {
+ using (var sw = new StreamWriter(encoded))
+ new LegacyBeatmapEncoder(beatmap).Encode(sw);
+
+ return encoded.ToArray();
+ }
+ }
+
+ private IBeatmap decode(byte[] state)
+ {
+ using (var stream = new MemoryStream(state))
+ using (var reader = new LineBufferedReader(stream))
+ return Decoder.GetDecoder(reader).Decode(reader);
+ }
+ }
+}
diff --git a/osu.Game.Tests/Gameplay/TestSceneHitObjectSamples.cs b/osu.Game.Tests/Gameplay/TestSceneHitObjectSamples.cs
new file mode 100644
index 0000000000..f611f2717e
--- /dev/null
+++ b/osu.Game.Tests/Gameplay/TestSceneHitObjectSamples.cs
@@ -0,0 +1,346 @@
+// Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence.
+// See the LICENCE file in the repository root for full licence text.
+
+using System;
+using System.Collections.Generic;
+using System.IO;
+using System.Linq;
+using System.Threading.Tasks;
+using NUnit.Framework;
+using osu.Framework.Allocation;
+using osu.Framework.Audio;
+using osu.Framework.IO.Stores;
+using osu.Framework.Testing;
+using osu.Framework.Timing;
+using osu.Game.Beatmaps;
+using osu.Game.Beatmaps.Formats;
+using osu.Game.IO;
+using osu.Game.Rulesets;
+using osu.Game.Rulesets.Osu;
+using osu.Game.Skinning;
+using osu.Game.Storyboards;
+using osu.Game.Tests.Resources;
+using osu.Game.Tests.Visual;
+using osu.Game.Users;
+
+namespace osu.Game.Tests.Gameplay
+{
+ [HeadlessTest]
+ public class TestSceneHitObjectSamples : PlayerTestScene
+ {
+ private readonly SkinInfo userSkinInfo = new SkinInfo();
+
+ private readonly BeatmapInfo beatmapInfo = new BeatmapInfo
+ {
+ BeatmapSet = new BeatmapSetInfo(),
+ Metadata = new BeatmapMetadata
+ {
+ Author = User.SYSTEM_USER
+ }
+ };
+
+ private readonly TestResourceStore userSkinResourceStore = new TestResourceStore();
+ private readonly TestResourceStore beatmapSkinResourceStore = new TestResourceStore();
+
+ protected override bool HasCustomSteps => true;
+
+ public TestSceneHitObjectSamples()
+ : base(new OsuRuleset())
+ {
+ }
+
+ private SkinSourceDependencyContainer dependencies;
+
+ protected override IReadOnlyDependencyContainer CreateChildDependencies(IReadOnlyDependencyContainer parent)
+ => new DependencyContainer(dependencies = new SkinSourceDependencyContainer(base.CreateChildDependencies(parent)));
+
+ ///
+ /// Tests that a hitobject which provides no custom sample set retrieves samples from the user skin.
+ ///
+ [Test]
+ public void TestDefaultSampleFromUserSkin()
+ {
+ const string expected_sample = "normal-hitnormal";
+
+ setupSkins(expected_sample, expected_sample);
+
+ createTestWithBeatmap("hitobject-skin-sample.osu");
+
+ assertUserLookup(expected_sample);
+ }
+
+ ///
+ /// Tests that a hitobject which provides a sample set of 1 retrieves samples from the beatmap skin.
+ ///
+ [Test]
+ public void TestDefaultSampleFromBeatmap()
+ {
+ const string expected_sample = "normal-hitnormal";
+
+ setupSkins(expected_sample, expected_sample);
+
+ createTestWithBeatmap("hitobject-beatmap-sample.osu");
+
+ assertBeatmapLookup(expected_sample);
+ }
+
+ ///
+ /// Tests that a hitobject which provides a sample set of 1 retrieves samples from the user skin when the beatmap does not contain the sample.
+ ///
+ [Test]
+ public void TestDefaultSampleFromUserSkinFallback()
+ {
+ const string expected_sample = "normal-hitnormal";
+
+ setupSkins(null, expected_sample);
+
+ createTestWithBeatmap("hitobject-beatmap-sample.osu");
+
+ assertUserLookup(expected_sample);
+ }
+
+ ///
+ /// Tests that a hitobject which provides a custom sample set of 2 retrieves the following samples from the beatmap skin:
+ /// normal-hitnormal2
+ /// normal-hitnormal
+ ///
+ [TestCase("normal-hitnormal2")]
+ [TestCase("normal-hitnormal")]
+ public void TestDefaultCustomSampleFromBeatmap(string expectedSample)
+ {
+ setupSkins(expectedSample, expectedSample);
+
+ createTestWithBeatmap("hitobject-beatmap-custom-sample.osu");
+
+ assertBeatmapLookup(expectedSample);
+ }
+
+ ///
+ /// Tests that a hitobject which provides a custom sample set of 2 retrieves the following samples from the user skin when the beatmap does not contain the sample:
+ /// normal-hitnormal2
+ /// normal-hitnormal
+ ///
+ [TestCase("normal-hitnormal2")]
+ [TestCase("normal-hitnormal")]
+ public void TestDefaultCustomSampleFromUserSkinFallback(string expectedSample)
+ {
+ setupSkins(string.Empty, expectedSample);
+
+ createTestWithBeatmap("hitobject-beatmap-custom-sample.osu");
+
+ assertUserLookup(expectedSample);
+ }
+
+ ///
+ /// Tests that a hitobject which provides a sample file retrieves the sample file from the beatmap skin.
+ ///
+ [Test]
+ public void TestFileSampleFromBeatmap()
+ {
+ const string expected_sample = "hit_1.wav";
+
+ setupSkins(expected_sample, expected_sample);
+
+ createTestWithBeatmap("file-beatmap-sample.osu");
+
+ assertBeatmapLookup(expected_sample);
+ }
+
+ ///
+ /// Tests that a default hitobject and control point causes .
+ ///
+ [Test]
+ public void TestControlPointSampleFromSkin()
+ {
+ const string expected_sample = "normal-hitnormal";
+
+ setupSkins(expected_sample, expected_sample);
+
+ createTestWithBeatmap("controlpoint-skin-sample.osu");
+
+ assertUserLookup(expected_sample);
+ }
+
+ ///
+ /// Tests that a control point that provides a custom sample set of 1 causes .
+ ///
+ [Test]
+ public void TestControlPointSampleFromBeatmap()
+ {
+ const string expected_sample = "normal-hitnormal";
+
+ setupSkins(expected_sample, expected_sample);
+
+ createTestWithBeatmap("controlpoint-beatmap-sample.osu");
+
+ assertBeatmapLookup(expected_sample);
+ }
+
+ ///
+ /// Tests that a control point that provides a custom sample of 2 causes .
+ ///
+ [TestCase("normal-hitnormal2")]
+ [TestCase("normal-hitnormal")]
+ public void TestControlPointCustomSampleFromBeatmap(string sampleName)
+ {
+ setupSkins(sampleName, sampleName);
+
+ createTestWithBeatmap("controlpoint-beatmap-custom-sample.osu");
+
+ assertBeatmapLookup(sampleName);
+ }
+
+ ///
+ /// Tests that a hitobject's custom sample overrides the control point's.
+ ///
+ [Test]
+ public void TestHitObjectCustomSampleOverride()
+ {
+ const string expected_sample = "normal-hitnormal3";
+
+ setupSkins(expected_sample, expected_sample);
+
+ createTestWithBeatmap("hitobject-beatmap-custom-sample-override.osu");
+
+ assertBeatmapLookup(expected_sample);
+ }
+
+ protected override IBeatmap CreateBeatmap(RulesetInfo ruleset) => currentTestBeatmap;
+
+ protected override WorkingBeatmap CreateWorkingBeatmap(IBeatmap beatmap, Storyboard storyboard = null)
+ => new TestWorkingBeatmap(beatmapInfo, beatmapSkinResourceStore, beatmap, storyboard, Clock, Audio);
+
+ private IBeatmap currentTestBeatmap;
+
+ private void createTestWithBeatmap(string filename)
+ {
+ CreateTest(() =>
+ {
+ AddStep("clear performed lookups", () =>
+ {
+ userSkinResourceStore.PerformedLookups.Clear();
+ beatmapSkinResourceStore.PerformedLookups.Clear();
+ });
+
+ AddStep($"load {filename}", () =>
+ {
+ using (var reader = new LineBufferedReader(TestResources.OpenResource($"SampleLookups/{filename}")))
+ currentTestBeatmap = Decoder.GetDecoder(reader).Decode(reader);
+ });
+ });
+ }
+
+ private void setupSkins(string beatmapFile, string userFile)
+ {
+ AddStep("setup skins", () =>
+ {
+ userSkinInfo.Files = new List
+ {
+ new SkinFileInfo
+ {
+ Filename = userFile,
+ FileInfo = new IO.FileInfo { Hash = userFile }
+ }
+ };
+
+ beatmapInfo.BeatmapSet.Files = new List
+ {
+ new BeatmapSetFileInfo
+ {
+ Filename = beatmapFile,
+ FileInfo = new IO.FileInfo { Hash = beatmapFile }
+ }
+ };
+
+ // Need to refresh the cached skin source to refresh the skin resource store.
+ dependencies.SkinSource = new SkinProvidingContainer(new LegacySkin(userSkinInfo, userSkinResourceStore, Audio));
+ });
+ }
+
+ private void assertBeatmapLookup(string name) => AddAssert($"\"{name}\" looked up from beatmap skin",
+ () => !userSkinResourceStore.PerformedLookups.Contains(name) && beatmapSkinResourceStore.PerformedLookups.Contains(name));
+
+ private void assertUserLookup(string name) => AddAssert($"\"{name}\" looked up from user skin",
+ () => !beatmapSkinResourceStore.PerformedLookups.Contains(name) && userSkinResourceStore.PerformedLookups.Contains(name));
+
+ private class SkinSourceDependencyContainer : IReadOnlyDependencyContainer
+ {
+ public ISkinSource SkinSource;
+
+ private readonly IReadOnlyDependencyContainer fallback;
+
+ public SkinSourceDependencyContainer(IReadOnlyDependencyContainer fallback)
+ {
+ this.fallback = fallback;
+ }
+
+ public object Get(Type type)
+ {
+ if (type == typeof(ISkinSource))
+ return SkinSource;
+
+ return fallback.Get(type);
+ }
+
+ public object Get(Type type, CacheInfo info)
+ {
+ if (type == typeof(ISkinSource))
+ return SkinSource;
+
+ return fallback.Get(type, info);
+ }
+
+ public void Inject(T instance) where T : class
+ {
+ // Never used directly
+ }
+ }
+
+ private class TestResourceStore : IResourceStore
+ {
+ public readonly List PerformedLookups = new List();
+
+ public byte[] Get(string name)
+ {
+ markLookup(name);
+ return Array.Empty();
+ }
+
+ public Task GetAsync(string name)
+ {
+ markLookup(name);
+ return Task.FromResult(Array.Empty());
+ }
+
+ public Stream GetStream(string name)
+ {
+ markLookup(name);
+ return new MemoryStream();
+ }
+
+ private void markLookup(string name) => PerformedLookups.Add(name.Substring(name.LastIndexOf(Path.DirectorySeparatorChar) + 1));
+
+ public IEnumerable GetAvailableResources() => Enumerable.Empty();
+
+ public void Dispose()
+ {
+ }
+ }
+
+ private class TestWorkingBeatmap : ClockBackedTestWorkingBeatmap
+ {
+ private readonly BeatmapInfo skinBeatmapInfo;
+ private readonly IResourceStore resourceStore;
+
+ public TestWorkingBeatmap(BeatmapInfo skinBeatmapInfo, IResourceStore resourceStore, IBeatmap beatmap, Storyboard storyboard, IFrameBasedClock referenceClock, AudioManager audio,
+ double length = 60000)
+ : base(beatmap, storyboard, referenceClock, audio, length)
+ {
+ this.skinBeatmapInfo = skinBeatmapInfo;
+ this.resourceStore = resourceStore;
+ }
+
+ protected override ISkin GetSkin() => new LegacyBeatmapSkin(skinBeatmapInfo, resourceStore, AudioManager);
+ }
+ }
+}
diff --git a/osu.Game.Tests/NonVisual/ControlPointInfoTest.cs b/osu.Game.Tests/NonVisual/ControlPointInfoTest.cs
index 2782e902fe..158954106d 100644
--- a/osu.Game.Tests/NonVisual/ControlPointInfoTest.cs
+++ b/osu.Game.Tests/NonVisual/ControlPointInfoTest.cs
@@ -29,11 +29,17 @@ namespace osu.Game.Tests.NonVisual
var cpi = new ControlPointInfo();
cpi.Add(0, new TimingControlPoint()); // is *not* redundant, special exception for first timing point.
- cpi.Add(1000, new TimingControlPoint()); // is redundant
+ cpi.Add(1000, new TimingControlPoint()); // is also not redundant, due to change of offset
- Assert.That(cpi.Groups.Count, Is.EqualTo(1));
- Assert.That(cpi.TimingPoints.Count, Is.EqualTo(1));
- Assert.That(cpi.AllControlPoints.Count(), Is.EqualTo(1));
+ Assert.That(cpi.Groups.Count, Is.EqualTo(2));
+ Assert.That(cpi.TimingPoints.Count, Is.EqualTo(2));
+ Assert.That(cpi.AllControlPoints.Count(), Is.EqualTo(2));
+
+ cpi.Add(1000, new TimingControlPoint()); //is redundant
+
+ Assert.That(cpi.Groups.Count, Is.EqualTo(2));
+ Assert.That(cpi.TimingPoints.Count, Is.EqualTo(2));
+ Assert.That(cpi.AllControlPoints.Count(), Is.EqualTo(2));
}
[Test]
@@ -86,11 +92,12 @@ namespace osu.Game.Tests.NonVisual
Assert.That(cpi.EffectPoints.Count, Is.EqualTo(0));
Assert.That(cpi.AllControlPoints.Count(), Is.EqualTo(0));
- cpi.Add(1000, new EffectControlPoint { KiaiMode = true }); // is not redundant
+ cpi.Add(1000, new EffectControlPoint { KiaiMode = true, OmitFirstBarLine = true }); // is not redundant
+ cpi.Add(1400, new EffectControlPoint { KiaiMode = true, OmitFirstBarLine = true }); // same settings, but is not redundant
- Assert.That(cpi.Groups.Count, Is.EqualTo(1));
- Assert.That(cpi.EffectPoints.Count, Is.EqualTo(1));
- Assert.That(cpi.AllControlPoints.Count(), Is.EqualTo(1));
+ Assert.That(cpi.Groups.Count, Is.EqualTo(2));
+ Assert.That(cpi.EffectPoints.Count, Is.EqualTo(2));
+ Assert.That(cpi.AllControlPoints.Count(), Is.EqualTo(2));
}
[Test]
diff --git a/osu.Game.Tests/Online/TestDummyAPIRequestHandling.cs b/osu.Game.Tests/Online/TestDummyAPIRequestHandling.cs
new file mode 100644
index 0000000000..1e77d50115
--- /dev/null
+++ b/osu.Game.Tests/Online/TestDummyAPIRequestHandling.cs
@@ -0,0 +1,117 @@
+// Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence.
+// See the LICENCE file in the repository root for full licence text.
+
+using NUnit.Framework;
+using osu.Framework.Testing;
+using osu.Game.Online.API;
+using osu.Game.Online.API.Requests;
+using osu.Game.Online.API.Requests.Responses;
+using osu.Game.Online.Chat;
+using osu.Game.Tests.Visual;
+using osu.Game.Users;
+
+namespace osu.Game.Tests.Online
+{
+ [HeadlessTest]
+ public class TestDummyAPIRequestHandling : OsuTestScene
+ {
+ [Test]
+ public void TestGenericRequestHandling()
+ {
+ AddStep("register request handling", () => ((DummyAPIAccess)API).HandleRequest = req =>
+ {
+ switch (req)
+ {
+ case CommentVoteRequest cRequest:
+ cRequest.TriggerSuccess(new CommentBundle());
+ break;
+ }
+ });
+
+ CommentVoteRequest request = null;
+ CommentBundle response = null;
+
+ AddStep("fire request", () =>
+ {
+ response = null;
+ request = new CommentVoteRequest(1, CommentVoteAction.Vote);
+ request.Success += res => response = res;
+ API.Queue(request);
+ });
+
+ AddAssert("response event fired", () => response != null);
+
+ AddAssert("request has response", () => request.Result == response);
+ }
+
+ [Test]
+ public void TestQueueRequestHandling()
+ {
+ registerHandler();
+
+ LeaveChannelRequest request;
+ bool gotResponse = false;
+
+ AddStep("fire request", () =>
+ {
+ gotResponse = false;
+ request = new LeaveChannelRequest(new Channel(), new User());
+ request.Success += () => gotResponse = true;
+ API.Queue(request);
+ });
+
+ AddAssert("response event fired", () => gotResponse);
+ }
+
+ [Test]
+ public void TestPerformRequestHandling()
+ {
+ registerHandler();
+
+ LeaveChannelRequest request;
+ bool gotResponse = false;
+
+ AddStep("fire request", () =>
+ {
+ gotResponse = false;
+ request = new LeaveChannelRequest(new Channel(), new User());
+ request.Success += () => gotResponse = true;
+ API.Perform(request);
+ });
+
+ AddAssert("response event fired", () => gotResponse);
+ }
+
+ [Test]
+ public void TestPerformAsyncRequestHandling()
+ {
+ registerHandler();
+
+ LeaveChannelRequest request;
+ bool gotResponse = false;
+
+ AddStep("fire request", () =>
+ {
+ gotResponse = false;
+ request = new LeaveChannelRequest(new Channel(), new User());
+ request.Success += () => gotResponse = true;
+ API.PerformAsync(request);
+ });
+
+ AddAssert("response event fired", () => gotResponse);
+ }
+
+ private void registerHandler()
+ {
+ AddStep("register request handling", () => ((DummyAPIAccess)API).HandleRequest = req =>
+ {
+ switch (req)
+ {
+ case LeaveChannelRequest cRequest:
+ cRequest.TriggerSuccess();
+ break;
+ }
+ });
+ }
+ }
+}
diff --git a/osu.Game.Tests/Resources/SampleLookups/controlpoint-beatmap-custom-sample.osu b/osu.Game.Tests/Resources/SampleLookups/controlpoint-beatmap-custom-sample.osu
new file mode 100644
index 0000000000..91dbc6a60e
--- /dev/null
+++ b/osu.Game.Tests/Resources/SampleLookups/controlpoint-beatmap-custom-sample.osu
@@ -0,0 +1,7 @@
+osu file format v14
+
+[TimingPoints]
+0,300,4,0,2,100,1,0
+
+[HitObjects]
+444,320,1000,5,0,0:0:0:0:
\ No newline at end of file
diff --git a/osu.Game.Tests/Resources/SampleLookups/controlpoint-beatmap-sample.osu b/osu.Game.Tests/Resources/SampleLookups/controlpoint-beatmap-sample.osu
new file mode 100644
index 0000000000..3274820100
--- /dev/null
+++ b/osu.Game.Tests/Resources/SampleLookups/controlpoint-beatmap-sample.osu
@@ -0,0 +1,7 @@
+osu file format v14
+
+[TimingPoints]
+0,300,4,0,1,100,1,0
+
+[HitObjects]
+444,320,1000,5,0,0:0:0:0:
\ No newline at end of file
diff --git a/osu.Game.Tests/Resources/SampleLookups/controlpoint-skin-sample.osu b/osu.Game.Tests/Resources/SampleLookups/controlpoint-skin-sample.osu
new file mode 100644
index 0000000000..c53ec465fb
--- /dev/null
+++ b/osu.Game.Tests/Resources/SampleLookups/controlpoint-skin-sample.osu
@@ -0,0 +1,7 @@
+osu file format v14
+
+[TimingPoints]
+0,300,4,0,0,100,1,0
+
+[HitObjects]
+444,320,1000,5,0,0:0:0:0:
\ No newline at end of file
diff --git a/osu.Game.Tests/Resources/SampleLookups/file-beatmap-sample.osu b/osu.Game.Tests/Resources/SampleLookups/file-beatmap-sample.osu
new file mode 100644
index 0000000000..65b5ea8707
--- /dev/null
+++ b/osu.Game.Tests/Resources/SampleLookups/file-beatmap-sample.osu
@@ -0,0 +1,4 @@
+osu file format v14
+
+[HitObjects]
+255,193,2170,1,0,0:0:0:0:hit_1.wav
diff --git a/osu.Game.Tests/Resources/SampleLookups/hitobject-beatmap-custom-sample-override.osu b/osu.Game.Tests/Resources/SampleLookups/hitobject-beatmap-custom-sample-override.osu
new file mode 100644
index 0000000000..13dc2faab1
--- /dev/null
+++ b/osu.Game.Tests/Resources/SampleLookups/hitobject-beatmap-custom-sample-override.osu
@@ -0,0 +1,7 @@
+osu file format v14
+
+[TimingPoints]
+0,300,4,0,2,100,1,0
+
+[HitObjects]
+444,320,1000,5,0,0:0:3:0:
\ No newline at end of file
diff --git a/osu.Game.Tests/Resources/SampleLookups/hitobject-beatmap-custom-sample.osu b/osu.Game.Tests/Resources/SampleLookups/hitobject-beatmap-custom-sample.osu
new file mode 100644
index 0000000000..4ab672dbb0
--- /dev/null
+++ b/osu.Game.Tests/Resources/SampleLookups/hitobject-beatmap-custom-sample.osu
@@ -0,0 +1,4 @@
+osu file format v14
+
+[HitObjects]
+444,320,1000,5,0,0:0:2:0:
\ No newline at end of file
diff --git a/osu.Game.Tests/Resources/SampleLookups/hitobject-beatmap-sample.osu b/osu.Game.Tests/Resources/SampleLookups/hitobject-beatmap-sample.osu
new file mode 100644
index 0000000000..33bc34949a
--- /dev/null
+++ b/osu.Game.Tests/Resources/SampleLookups/hitobject-beatmap-sample.osu
@@ -0,0 +1,4 @@
+osu file format v14
+
+[HitObjects]
+444,320,1000,5,0,0:0:1:0:
\ No newline at end of file
diff --git a/osu.Game.Tests/Resources/SampleLookups/hitobject-skin-sample.osu b/osu.Game.Tests/Resources/SampleLookups/hitobject-skin-sample.osu
new file mode 100644
index 0000000000..47f5b44c90
--- /dev/null
+++ b/osu.Game.Tests/Resources/SampleLookups/hitobject-skin-sample.osu
@@ -0,0 +1,4 @@
+osu file format v14
+
+[HitObjects]
+444,320,1000,5,0,0:0:0:0:
\ No newline at end of file
diff --git a/osu.Game.Tests/Rulesets/Scoring/ScoreProcessorTest.cs b/osu.Game.Tests/Rulesets/Scoring/ScoreProcessorTest.cs
new file mode 100644
index 0000000000..64d1024efb
--- /dev/null
+++ b/osu.Game.Tests/Rulesets/Scoring/ScoreProcessorTest.cs
@@ -0,0 +1,57 @@
+// Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence.
+// See the LICENCE file in the repository root for full licence text.
+
+using System.Collections.Generic;
+using System.Linq;
+using NUnit.Framework;
+using osu.Framework.Utils;
+using osu.Game.Beatmaps;
+using osu.Game.Rulesets;
+using osu.Game.Rulesets.Judgements;
+using osu.Game.Rulesets.Objects;
+using osu.Game.Rulesets.Osu.Judgements;
+using osu.Game.Rulesets.Osu.Objects;
+using osu.Game.Rulesets.Scoring;
+using osu.Game.Tests.Beatmaps;
+
+namespace osu.Game.Tests.Rulesets.Scoring
+{
+ public class ScoreProcessorTest
+ {
+ private ScoreProcessor scoreProcessor;
+ private IBeatmap beatmap;
+
+ [SetUp]
+ public void SetUp()
+ {
+ scoreProcessor = new ScoreProcessor();
+ beatmap = new TestBeatmap(new RulesetInfo())
+ {
+ HitObjects = new List
+ {
+ new HitCircle()
+ }
+ };
+ }
+
+ [TestCase(ScoringMode.Standardised, HitResult.Meh, 750_000)]
+ [TestCase(ScoringMode.Standardised, HitResult.Good, 800_000)]
+ [TestCase(ScoringMode.Standardised, HitResult.Great, 1_000_000)]
+ [TestCase(ScoringMode.Classic, HitResult.Meh, 50)]
+ [TestCase(ScoringMode.Classic, HitResult.Good, 100)]
+ [TestCase(ScoringMode.Classic, HitResult.Great, 300)]
+ public void TestSingleOsuHit(ScoringMode scoringMode, HitResult hitResult, int expectedScore)
+ {
+ scoreProcessor.Mode.Value = scoringMode;
+ scoreProcessor.ApplyBeatmap(beatmap);
+
+ var judgementResult = new JudgementResult(beatmap.HitObjects.Single(), new OsuJudgement())
+ {
+ Type = hitResult
+ };
+ scoreProcessor.ApplyResult(judgementResult);
+
+ Assert.IsTrue(Precision.AlmostEquals(expectedScore, scoreProcessor.TotalScore.Value));
+ }
+ }
+}
diff --git a/osu.Game.Tests/Visual/Editor/TestSceneEditorChangeStates.cs b/osu.Game.Tests/Visual/Editor/TestSceneEditorChangeStates.cs
new file mode 100644
index 0000000000..dd1b6cf6aa
--- /dev/null
+++ b/osu.Game.Tests/Visual/Editor/TestSceneEditorChangeStates.cs
@@ -0,0 +1,195 @@
+// Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence.
+// See the LICENCE file in the repository root for full licence text.
+
+using System.Linq;
+using NUnit.Framework;
+using osu.Framework.Testing;
+using osu.Game.Rulesets.Edit;
+using osu.Game.Rulesets.Objects;
+using osu.Game.Rulesets.Osu;
+using osu.Game.Rulesets.Osu.Objects;
+using osu.Game.Screens.Edit;
+using osu.Game.Screens.Edit.Compose.Components.Timeline;
+using osuTK.Input;
+
+namespace osu.Game.Tests.Visual.Editor
+{
+ public class TestSceneEditorChangeStates : ScreenTestScene
+ {
+ private EditorBeatmap editorBeatmap;
+
+ public override void SetUpSteps()
+ {
+ base.SetUpSteps();
+
+ Screens.Edit.Editor editor = null;
+
+ AddStep("load editor", () =>
+ {
+ Beatmap.Value = CreateWorkingBeatmap(new OsuRuleset().RulesetInfo);
+ LoadScreen(editor = new Screens.Edit.Editor());
+ });
+
+ AddUntilStep("wait for editor to load", () => editor.ChildrenOfType().FirstOrDefault()?.IsLoaded == true
+ && editor.ChildrenOfType().FirstOrDefault()?.IsLoaded == true);
+ AddStep("get beatmap", () => editorBeatmap = editor.ChildrenOfType().Single());
+ }
+
+ [Test]
+ public void TestUndoFromInitialState()
+ {
+ int hitObjectCount = 0;
+
+ AddStep("get initial state", () => hitObjectCount = editorBeatmap.HitObjects.Count);
+
+ addUndoSteps();
+
+ AddAssert("no change occurred", () => hitObjectCount == editorBeatmap.HitObjects.Count);
+ }
+
+ [Test]
+ public void TestRedoFromInitialState()
+ {
+ int hitObjectCount = 0;
+
+ AddStep("get initial state", () => hitObjectCount = editorBeatmap.HitObjects.Count);
+
+ addRedoSteps();
+
+ AddAssert("no change occurred", () => hitObjectCount == editorBeatmap.HitObjects.Count);
+ }
+
+ [Test]
+ public void TestAddObjectAndUndo()
+ {
+ HitObject addedObject = null;
+ HitObject removedObject = null;
+ HitObject expectedObject = null;
+
+ AddStep("bind removal", () =>
+ {
+ editorBeatmap.HitObjectAdded += h => addedObject = h;
+ editorBeatmap.HitObjectRemoved += h => removedObject = h;
+ });
+
+ AddStep("add hitobject", () => editorBeatmap.Add(expectedObject = new HitCircle { StartTime = 1000 }));
+ AddAssert("hitobject added", () => addedObject == expectedObject);
+
+ addUndoSteps();
+ AddAssert("hitobject removed", () => removedObject == expectedObject);
+ }
+
+ [Test]
+ public void TestAddObjectThenUndoThenRedo()
+ {
+ HitObject addedObject = null;
+ HitObject removedObject = null;
+ HitObject expectedObject = null;
+
+ AddStep("bind removal", () =>
+ {
+ editorBeatmap.HitObjectAdded += h => addedObject = h;
+ editorBeatmap.HitObjectRemoved += h => removedObject = h;
+ });
+
+ AddStep("add hitobject", () => editorBeatmap.Add(expectedObject = new HitCircle { StartTime = 1000 }));
+ addUndoSteps();
+
+ AddStep("reset variables", () =>
+ {
+ addedObject = null;
+ removedObject = null;
+ });
+
+ addRedoSteps();
+ AddAssert("hitobject added", () => addedObject.StartTime == expectedObject.StartTime); // Can't compare via equality (new hitobject instance)
+ AddAssert("no hitobject removed", () => removedObject == null);
+ }
+
+ [Test]
+ public void TestRemoveObjectThenUndo()
+ {
+ HitObject addedObject = null;
+ HitObject removedObject = null;
+ HitObject expectedObject = null;
+
+ AddStep("bind removal", () =>
+ {
+ editorBeatmap.HitObjectAdded += h => addedObject = h;
+ editorBeatmap.HitObjectRemoved += h => removedObject = h;
+ });
+
+ AddStep("add hitobject", () => editorBeatmap.Add(expectedObject = new HitCircle { StartTime = 1000 }));
+ AddStep("remove object", () => editorBeatmap.Remove(expectedObject));
+ AddStep("reset variables", () =>
+ {
+ addedObject = null;
+ removedObject = null;
+ });
+
+ addUndoSteps();
+ AddAssert("hitobject added", () => addedObject.StartTime == expectedObject.StartTime); // Can't compare via equality (new hitobject instance)
+ AddAssert("no hitobject removed", () => removedObject == null);
+ }
+
+ [Test]
+ public void TestRemoveObjectThenUndoThenRedo()
+ {
+ HitObject addedObject = null;
+ HitObject removedObject = null;
+ HitObject expectedObject = null;
+
+ AddStep("bind removal", () =>
+ {
+ editorBeatmap.HitObjectAdded += h => addedObject = h;
+ editorBeatmap.HitObjectRemoved += h => removedObject = h;
+ });
+
+ AddStep("add hitobject", () => editorBeatmap.Add(expectedObject = new HitCircle { StartTime = 1000 }));
+ AddStep("remove object", () => editorBeatmap.Remove(expectedObject));
+ addUndoSteps();
+
+ AddStep("reset variables", () =>
+ {
+ addedObject = null;
+ removedObject = null;
+ });
+
+ addRedoSteps();
+ AddAssert("hitobject removed", () => removedObject.StartTime == expectedObject.StartTime); // Can't compare via equality (new hitobject instance after undo)
+ AddAssert("no hitobject added", () => addedObject == null);
+ }
+
+ private void addUndoSteps()
+ {
+ AddStep("press undo", () =>
+ {
+ InputManager.PressKey(Key.LControl);
+ InputManager.PressKey(Key.Z);
+ });
+
+ AddStep("release keys", () =>
+ {
+ InputManager.ReleaseKey(Key.LControl);
+ InputManager.ReleaseKey(Key.Z);
+ });
+ }
+
+ private void addRedoSteps()
+ {
+ AddStep("press redo", () =>
+ {
+ InputManager.PressKey(Key.LControl);
+ InputManager.PressKey(Key.LShift);
+ InputManager.PressKey(Key.Z);
+ });
+
+ AddStep("release keys", () =>
+ {
+ InputManager.ReleaseKey(Key.LControl);
+ InputManager.ReleaseKey(Key.LShift);
+ InputManager.ReleaseKey(Key.Z);
+ });
+ }
+ }
+}
diff --git a/osu.Game.Tests/Visual/Gameplay/TestSceneFailingLayer.cs b/osu.Game.Tests/Visual/Gameplay/TestSceneFailingLayer.cs
new file mode 100644
index 0000000000..a95e806862
--- /dev/null
+++ b/osu.Game.Tests/Visual/Gameplay/TestSceneFailingLayer.cs
@@ -0,0 +1,73 @@
+// Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence.
+// See the LICENCE file in the repository root for full licence text.
+
+using NUnit.Framework;
+using osu.Framework.Allocation;
+using osu.Framework.Testing;
+using osu.Game.Configuration;
+using osu.Game.Rulesets.Scoring;
+using osu.Game.Screens.Play.HUD;
+
+namespace osu.Game.Tests.Visual.Gameplay
+{
+ public class TestSceneFailingLayer : OsuTestScene
+ {
+ private FailingLayer layer;
+
+ [Resolved]
+ private OsuConfigManager config { get; set; }
+
+ [SetUpSteps]
+ public void SetUpSteps()
+ {
+ AddStep("create layer", () =>
+ {
+ Child = layer = new FailingLayer();
+ layer.BindHealthProcessor(new DrainingHealthProcessor(1));
+ });
+
+ AddStep("enable layer", () => config.Set(OsuSetting.FadePlayfieldWhenHealthLow, true));
+ AddUntilStep("layer is visible", () => layer.IsPresent);
+ }
+
+ [Test]
+ public void TestLayerFading()
+ {
+ AddSliderStep("current health", 0.0, 1.0, 1.0, val =>
+ {
+ if (layer != null)
+ layer.Current.Value = val;
+ });
+
+ AddStep("set health to 0.10", () => layer.Current.Value = 0.1);
+ AddUntilStep("layer fade is visible", () => layer.Child.Alpha > 0.1f);
+ AddStep("set health to 1", () => layer.Current.Value = 1f);
+ AddUntilStep("layer fade is invisible", () => !layer.Child.IsPresent);
+ }
+
+ [Test]
+ public void TestLayerDisabledViaConfig()
+ {
+ AddStep("disable layer", () => config.Set(OsuSetting.FadePlayfieldWhenHealthLow, false));
+ AddStep("set health to 0.10", () => layer.Current.Value = 0.1);
+ AddUntilStep("layer is not visible", () => !layer.IsPresent);
+ }
+
+ [Test]
+ public void TestLayerVisibilityWithAccumulatingProcessor()
+ {
+ AddStep("bind accumulating processor", () => layer.BindHealthProcessor(new AccumulatingHealthProcessor(1)));
+ AddStep("set health to 0.10", () => layer.Current.Value = 0.1);
+ AddUntilStep("layer is not visible", () => !layer.IsPresent);
+ }
+
+ [Test]
+ public void TestLayerVisibilityWithDrainingProcessor()
+ {
+ AddStep("bind accumulating processor", () => layer.BindHealthProcessor(new DrainingHealthProcessor(1)));
+ AddStep("set health to 0.10", () => layer.Current.Value = 0.1);
+ AddWaitStep("wait for potential fade", 10);
+ AddAssert("layer is still visible", () => layer.IsPresent);
+ }
+ }
+}
diff --git a/osu.Game.Tests/Visual/Navigation/TestScenePresentBeatmap.cs b/osu.Game.Tests/Visual/Navigation/TestScenePresentBeatmap.cs
index 909409835c..27f5b29738 100644
--- a/osu.Game.Tests/Visual/Navigation/TestScenePresentBeatmap.cs
+++ b/osu.Game.Tests/Visual/Navigation/TestScenePresentBeatmap.cs
@@ -20,26 +20,30 @@ namespace osu.Game.Tests.Visual.Navigation
public void TestFromMainMenu()
{
var firstImport = importBeatmap(1);
+ var secondimport = importBeatmap(3);
+
presentAndConfirm(firstImport);
-
- AddStep("return to menu", () => Game.ScreenStack.CurrentScreen.Exit());
- AddUntilStep("wait for menu", () => Game.ScreenStack.CurrentScreen is MainMenu);
-
- var secondimport = importBeatmap(2);
+ returnToMenu();
presentAndConfirm(secondimport);
+ returnToMenu();
+ presentSecondDifficultyAndConfirm(firstImport, 1);
+ returnToMenu();
+ presentSecondDifficultyAndConfirm(secondimport, 3);
}
[Test]
public void TestFromMainMenuDifferentRuleset()
{
var firstImport = importBeatmap(1);
+ var secondimport = importBeatmap(3, new ManiaRuleset().RulesetInfo);
+
presentAndConfirm(firstImport);
-
- AddStep("return to menu", () => Game.ScreenStack.CurrentScreen.Exit());
- AddUntilStep("wait for menu", () => Game.ScreenStack.CurrentScreen is MainMenu);
-
- var secondimport = importBeatmap(2, new ManiaRuleset().RulesetInfo);
+ returnToMenu();
presentAndConfirm(secondimport);
+ returnToMenu();
+ presentSecondDifficultyAndConfirm(firstImport, 1);
+ returnToMenu();
+ presentSecondDifficultyAndConfirm(secondimport, 3);
}
[Test]
@@ -48,8 +52,11 @@ namespace osu.Game.Tests.Visual.Navigation
var firstImport = importBeatmap(1);
presentAndConfirm(firstImport);
- var secondimport = importBeatmap(2);
+ var secondimport = importBeatmap(3);
presentAndConfirm(secondimport);
+
+ presentSecondDifficultyAndConfirm(firstImport, 1);
+ presentSecondDifficultyAndConfirm(secondimport, 3);
}
[Test]
@@ -58,8 +65,17 @@ namespace osu.Game.Tests.Visual.Navigation
var firstImport = importBeatmap(1);
presentAndConfirm(firstImport);
- var secondimport = importBeatmap(2, new ManiaRuleset().RulesetInfo);
+ var secondimport = importBeatmap(3, new ManiaRuleset().RulesetInfo);
presentAndConfirm(secondimport);
+
+ presentSecondDifficultyAndConfirm(firstImport, 1);
+ presentSecondDifficultyAndConfirm(secondimport, 3);
+ }
+
+ private void returnToMenu()
+ {
+ AddStep("return to menu", () => Game.ScreenStack.CurrentScreen.Exit());
+ AddUntilStep("wait for menu", () => Game.ScreenStack.CurrentScreen is MainMenu);
}
private Func importBeatmap(int i, RulesetInfo ruleset = null)
@@ -89,6 +105,13 @@ namespace osu.Game.Tests.Visual.Navigation
BaseDifficulty = difficulty,
Ruleset = ruleset ?? new OsuRuleset().RulesetInfo
},
+ new BeatmapInfo
+ {
+ OnlineBeatmapID = i * 2048,
+ Metadata = metadata,
+ BaseDifficulty = difficulty,
+ Ruleset = ruleset ?? new OsuRuleset().RulesetInfo
+ },
}
}).Result;
});
@@ -106,5 +129,15 @@ namespace osu.Game.Tests.Visual.Navigation
AddUntilStep("correct beatmap displayed", () => Game.Beatmap.Value.BeatmapSetInfo.ID == getImport().ID);
AddAssert("correct ruleset selected", () => Game.Ruleset.Value.ID == getImport().Beatmaps.First().Ruleset.ID);
}
+
+ private void presentSecondDifficultyAndConfirm(Func getImport, int importedID)
+ {
+ Predicate pred = b => b.OnlineBeatmapID == importedID * 2048;
+ AddStep("present difficulty", () => Game.PresentBeatmap(getImport(), pred));
+
+ AddUntilStep("wait for song select", () => Game.ScreenStack.CurrentScreen is Screens.Select.SongSelect);
+ AddUntilStep("correct beatmap displayed", () => Game.Beatmap.Value.BeatmapInfo.OnlineBeatmapID == importedID * 2048);
+ AddAssert("correct ruleset selected", () => Game.Ruleset.Value.ID == getImport().Beatmaps.First().Ruleset.ID);
+ }
}
}
diff --git a/osu.Game.Tests/Visual/Online/TestSceneChangelogOverlay.cs b/osu.Game.Tests/Visual/Online/TestSceneChangelogOverlay.cs
index 864fd31a0f..22d20f7098 100644
--- a/osu.Game.Tests/Visual/Online/TestSceneChangelogOverlay.cs
+++ b/osu.Game.Tests/Visual/Online/TestSceneChangelogOverlay.cs
@@ -24,7 +24,6 @@ namespace osu.Game.Tests.Visual.Online
typeof(ChangelogListing),
typeof(ChangelogSingleBuild),
typeof(ChangelogBuild),
- typeof(Comments),
};
protected override bool UseOnlineAPI => true;
diff --git a/osu.Game.Tests/Visual/Online/TestSceneDirectDownloadButton.cs b/osu.Game.Tests/Visual/Online/TestSceneDirectDownloadButton.cs
index 5b0c2d3c67..f612992bf6 100644
--- a/osu.Game.Tests/Visual/Online/TestSceneDirectDownloadButton.cs
+++ b/osu.Game.Tests/Visual/Online/TestSceneDirectDownloadButton.cs
@@ -149,8 +149,8 @@ namespace osu.Game.Tests.Visual.Online
public DownloadState DownloadState => State.Value;
- public TestDownloadButton(BeatmapSetInfo beatmapSet, bool noVideo = false)
- : base(beatmapSet, noVideo)
+ public TestDownloadButton(BeatmapSetInfo beatmapSet)
+ : base(beatmapSet)
{
}
}
diff --git a/osu.Game.Tests/Visual/SongSelect/TestSceneBeatmapCarousel.cs b/osu.Game.Tests/Visual/SongSelect/TestSceneBeatmapCarousel.cs
index 76a8ee9914..f68ed4154b 100644
--- a/osu.Game.Tests/Visual/SongSelect/TestSceneBeatmapCarousel.cs
+++ b/osu.Game.Tests/Visual/SongSelect/TestSceneBeatmapCarousel.cs
@@ -54,6 +54,35 @@ namespace osu.Game.Tests.Visual.SongSelect
this.rulesets = rulesets;
}
+ [Test]
+ public void TestRecommendedSelection()
+ {
+ loadBeatmaps();
+
+ AddStep("set recommendation function", () => carousel.GetRecommendedBeatmap = beatmaps => beatmaps.LastOrDefault());
+
+ // check recommended was selected
+ advanceSelection(direction: 1, diff: false);
+ waitForSelection(1, 3);
+
+ // change away from recommended
+ advanceSelection(direction: -1, diff: true);
+ waitForSelection(1, 2);
+
+ // next set, check recommended
+ advanceSelection(direction: 1, diff: false);
+ waitForSelection(2, 3);
+
+ // next set, check recommended
+ advanceSelection(direction: 1, diff: false);
+ waitForSelection(3, 3);
+
+ // go back to first set and ensure user selection was retained
+ advanceSelection(direction: -1, diff: false);
+ advanceSelection(direction: -1, diff: false);
+ waitForSelection(1, 2);
+ }
+
///
/// Test keyboard traversal
///
diff --git a/osu.Game.Tests/Visual/UserInterface/TestSceneOsuMenu.cs b/osu.Game.Tests/Visual/UserInterface/TestSceneOsuMenu.cs
new file mode 100644
index 0000000000..9ea76c2c7b
--- /dev/null
+++ b/osu.Game.Tests/Visual/UserInterface/TestSceneOsuMenu.cs
@@ -0,0 +1,91 @@
+// Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence.
+// See the LICENCE file in the repository root for full licence text.
+
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using NUnit.Framework;
+using osu.Framework.Graphics;
+using osu.Framework.Testing;
+using osu.Game.Graphics.UserInterface;
+using osuTK.Input;
+
+namespace osu.Game.Tests.Visual.UserInterface
+{
+ public class TestSceneOsuMenu : OsuManualInputManagerTestScene
+ {
+ public override IReadOnlyList RequiredTypes => new[]
+ {
+ typeof(OsuMenu),
+ typeof(DrawableOsuMenuItem)
+ };
+
+ private OsuMenu menu;
+ private bool actionPerformed;
+
+ [SetUp]
+ public void Setup() => Schedule(() =>
+ {
+ actionPerformed = false;
+
+ Child = menu = new OsuMenu(Direction.Vertical, true)
+ {
+ Anchor = Anchor.Centre,
+ Origin = Anchor.Centre,
+ Items = new[]
+ {
+ new OsuMenuItem("standard", MenuItemType.Standard, performAction),
+ new OsuMenuItem("highlighted", MenuItemType.Highlighted, performAction),
+ new OsuMenuItem("destructive", MenuItemType.Destructive, performAction),
+ }
+ };
+ });
+
+ [Test]
+ public void TestClickEnabledMenuItem()
+ {
+ AddStep("move to first menu item", () => InputManager.MoveMouseTo(menu.ChildrenOfType().First()));
+ AddStep("click", () => InputManager.Click(MouseButton.Left));
+
+ AddAssert("action performed", () => actionPerformed);
+ }
+
+ [Test]
+ public void TestDisableMenuItemsAndClick()
+ {
+ AddStep("disable menu items", () =>
+ {
+ foreach (var item in menu.Items)
+ ((OsuMenuItem)item).Action.Disabled = true;
+ });
+
+ AddStep("move to first menu item", () => InputManager.MoveMouseTo(menu.ChildrenOfType().First()));
+ AddStep("click", () => InputManager.Click(MouseButton.Left));
+
+ AddAssert("action not performed", () => !actionPerformed);
+ }
+
+ [Test]
+ public void TestEnableMenuItemsAndClick()
+ {
+ AddStep("disable menu items", () =>
+ {
+ foreach (var item in menu.Items)
+ ((OsuMenuItem)item).Action.Disabled = true;
+ });
+
+ AddStep("enable menu items", () =>
+ {
+ foreach (var item in menu.Items)
+ ((OsuMenuItem)item).Action.Disabled = false;
+ });
+
+ AddStep("move to first menu item", () => InputManager.MoveMouseTo(menu.ChildrenOfType().First()));
+ AddStep("click", () => InputManager.Click(MouseButton.Left));
+
+ AddAssert("action performed", () => actionPerformed);
+ }
+
+ private void performAction() => actionPerformed = true;
+ }
+}
diff --git a/osu.Game.Tests/Visual/UserInterface/TestSceneOverlayScrollContainer.cs b/osu.Game.Tests/Visual/UserInterface/TestSceneOverlayScrollContainer.cs
new file mode 100644
index 0000000000..e9e63613c0
--- /dev/null
+++ b/osu.Game.Tests/Visual/UserInterface/TestSceneOverlayScrollContainer.cs
@@ -0,0 +1,113 @@
+// Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence.
+// See the LICENCE file in the repository root for full licence text.
+
+using osu.Framework.Graphics.Containers;
+using osu.Game.Overlays;
+using System;
+using System.Collections.Generic;
+using osu.Framework.Graphics;
+using osu.Framework.Allocation;
+using osu.Framework.Graphics.Shapes;
+using osuTK.Graphics;
+using NUnit.Framework;
+using osu.Framework.Utils;
+using osuTK.Input;
+
+namespace osu.Game.Tests.Visual.UserInterface
+{
+ public class TestSceneOverlayScrollContainer : OsuManualInputManagerTestScene
+ {
+ public override IReadOnlyList RequiredTypes => new[]
+ {
+ typeof(OverlayScrollContainer)
+ };
+
+ [Cached]
+ private readonly OverlayColourProvider colourProvider = new OverlayColourProvider(OverlayColourScheme.Blue);
+
+ private TestScrollContainer scroll;
+
+ private int invocationCount;
+
+ [SetUp]
+ public void SetUp() => Schedule(() =>
+ {
+ Child = scroll = new TestScrollContainer
+ {
+ RelativeSizeAxes = Axes.Both,
+ Child = new Container
+ {
+ Height = 3000,
+ RelativeSizeAxes = Axes.X,
+ Child = new Box
+ {
+ RelativeSizeAxes = Axes.Both,
+ Colour = Color4.Gray
+ }
+ }
+ };
+
+ invocationCount = 0;
+
+ scroll.Button.Action += () => invocationCount++;
+ });
+
+ [Test]
+ public void TestButtonVisibility()
+ {
+ AddAssert("button is hidden", () => scroll.Button.State == Visibility.Hidden);
+
+ AddStep("scroll to end", () => scroll.ScrollToEnd(false));
+ AddAssert("button is visible", () => scroll.Button.State == Visibility.Visible);
+
+ AddStep("scroll to start", () => scroll.ScrollToStart(false));
+ AddAssert("button is hidden", () => scroll.Button.State == Visibility.Hidden);
+
+ AddStep("scroll to 500", () => scroll.ScrollTo(500));
+ AddUntilStep("scrolled to 500", () => Precision.AlmostEquals(scroll.Current, 500, 0.1f));
+ AddAssert("button is visible", () => scroll.Button.State == Visibility.Visible);
+ }
+
+ [Test]
+ public void TestButtonAction()
+ {
+ AddStep("scroll to end", () => scroll.ScrollToEnd(false));
+
+ AddStep("invoke action", () => scroll.Button.Action.Invoke());
+
+ AddUntilStep("scrolled back to start", () => Precision.AlmostEquals(scroll.Current, 0, 0.1f));
+ }
+
+ [Test]
+ public void TestClick()
+ {
+ AddStep("scroll to end", () => scroll.ScrollToEnd(false));
+
+ AddStep("click button", () =>
+ {
+ InputManager.MoveMouseTo(scroll.Button);
+ InputManager.Click(MouseButton.Left);
+ });
+
+ AddUntilStep("scrolled back to start", () => Precision.AlmostEquals(scroll.Current, 0, 0.1f));
+ }
+
+ [Test]
+ public void TestMultipleClicks()
+ {
+ AddStep("scroll to end", () => scroll.ScrollToEnd(false));
+
+ AddAssert("invocation count is 0", () => invocationCount == 0);
+
+ AddStep("hover button", () => InputManager.MoveMouseTo(scroll.Button));
+ AddRepeatStep("click button", () => InputManager.Click(MouseButton.Left), 3);
+
+ AddAssert("invocation count is 1", () => invocationCount == 1);
+ }
+
+ private class TestScrollContainer : OverlayScrollContainer
+ {
+ public new ScrollToTopButton Button => base.Button;
+ }
+ }
+}
diff --git a/osu.Game/Beatmaps/ControlPoints/ControlPoint.cs b/osu.Game/Beatmaps/ControlPoints/ControlPoint.cs
index 39a0e6f6d4..a1822a1163 100644
--- a/osu.Game/Beatmaps/ControlPoints/ControlPoint.cs
+++ b/osu.Game/Beatmaps/ControlPoints/ControlPoint.cs
@@ -5,7 +5,7 @@ using System;
namespace osu.Game.Beatmaps.ControlPoints
{
- public abstract class ControlPoint : IComparable, IEquatable
+ public abstract class ControlPoint : IComparable
{
///
/// The time at which the control point takes effect.
@@ -19,12 +19,10 @@ namespace osu.Game.Beatmaps.ControlPoints
public int CompareTo(ControlPoint other) => Time.CompareTo(other.Time);
///
- /// Whether this control point is equivalent to another, ignoring time.
+ /// Determines whether this results in a meaningful change when placed alongside another.
///
- /// Another control point to compare with.
- /// Whether equivalent.
- public abstract bool EquivalentTo(ControlPoint other);
-
- public bool Equals(ControlPoint other) => Time == other?.Time && EquivalentTo(other);
+ /// An existing control point to compare with.
+ /// Whether this is redundant when placed alongside .
+ public abstract bool IsRedundant(ControlPoint existing);
}
}
diff --git a/osu.Game/Beatmaps/ControlPoints/ControlPointInfo.cs b/osu.Game/Beatmaps/ControlPoints/ControlPointInfo.cs
index df68d8acd2..d33a922a32 100644
--- a/osu.Game/Beatmaps/ControlPoints/ControlPointInfo.cs
+++ b/osu.Game/Beatmaps/ControlPoints/ControlPointInfo.cs
@@ -247,7 +247,7 @@ namespace osu.Game.Beatmaps.ControlPoints
break;
}
- return existing?.EquivalentTo(newPoint) == true;
+ return newPoint?.IsRedundant(existing) == true;
}
private void groupItemAdded(ControlPoint controlPoint)
diff --git a/osu.Game/Beatmaps/ControlPoints/DifficultyControlPoint.cs b/osu.Game/Beatmaps/ControlPoints/DifficultyControlPoint.cs
index 8b21098a51..2448b2b25c 100644
--- a/osu.Game/Beatmaps/ControlPoints/DifficultyControlPoint.cs
+++ b/osu.Game/Beatmaps/ControlPoints/DifficultyControlPoint.cs
@@ -27,7 +27,8 @@ namespace osu.Game.Beatmaps.ControlPoints
set => SpeedMultiplierBindable.Value = value;
}
- public override bool EquivalentTo(ControlPoint other) =>
- other is DifficultyControlPoint otherTyped && otherTyped.SpeedMultiplier.Equals(SpeedMultiplier);
+ public override bool IsRedundant(ControlPoint existing)
+ => existing is DifficultyControlPoint existingDifficulty
+ && SpeedMultiplier == existingDifficulty.SpeedMultiplier;
}
}
diff --git a/osu.Game/Beatmaps/ControlPoints/EffectControlPoint.cs b/osu.Game/Beatmaps/ControlPoints/EffectControlPoint.cs
index 369b93ff3d..9b69147468 100644
--- a/osu.Game/Beatmaps/ControlPoints/EffectControlPoint.cs
+++ b/osu.Game/Beatmaps/ControlPoints/EffectControlPoint.cs
@@ -35,8 +35,10 @@ namespace osu.Game.Beatmaps.ControlPoints
set => KiaiModeBindable.Value = value;
}
- public override bool EquivalentTo(ControlPoint other) =>
- other is EffectControlPoint otherTyped &&
- KiaiMode == otherTyped.KiaiMode && OmitFirstBarLine == otherTyped.OmitFirstBarLine;
+ public override bool IsRedundant(ControlPoint existing)
+ => !OmitFirstBarLine
+ && existing is EffectControlPoint existingEffect
+ && KiaiMode == existingEffect.KiaiMode
+ && OmitFirstBarLine == existingEffect.OmitFirstBarLine;
}
}
diff --git a/osu.Game/Beatmaps/ControlPoints/SampleControlPoint.cs b/osu.Game/Beatmaps/ControlPoints/SampleControlPoint.cs
index 393bcfdb3c..61851a00d7 100644
--- a/osu.Game/Beatmaps/ControlPoints/SampleControlPoint.cs
+++ b/osu.Game/Beatmaps/ControlPoints/SampleControlPoint.cs
@@ -68,8 +68,9 @@ namespace osu.Game.Beatmaps.ControlPoints
return newSampleInfo;
}
- public override bool EquivalentTo(ControlPoint other) =>
- other is SampleControlPoint otherTyped &&
- SampleBank == otherTyped.SampleBank && SampleVolume == otherTyped.SampleVolume;
+ public override bool IsRedundant(ControlPoint existing)
+ => existing is SampleControlPoint existingSample
+ && SampleBank == existingSample.SampleBank
+ && SampleVolume == existingSample.SampleVolume;
}
}
diff --git a/osu.Game/Beatmaps/ControlPoints/TimingControlPoint.cs b/osu.Game/Beatmaps/ControlPoints/TimingControlPoint.cs
index 51b3377394..1927dd6575 100644
--- a/osu.Game/Beatmaps/ControlPoints/TimingControlPoint.cs
+++ b/osu.Game/Beatmaps/ControlPoints/TimingControlPoint.cs
@@ -48,8 +48,7 @@ namespace osu.Game.Beatmaps.ControlPoints
///
public double BPM => 60000 / BeatLength;
- public override bool EquivalentTo(ControlPoint other) =>
- other is TimingControlPoint otherTyped
- && TimeSignature == otherTyped.TimeSignature && BeatLength.Equals(otherTyped.BeatLength);
+ // Timing points are never redundant as they can change the time signature.
+ public override bool IsRedundant(ControlPoint existing) => false;
}
}
diff --git a/osu.Game/Beatmaps/Formats/LegacyDecoder.cs b/osu.Game/Beatmaps/Formats/LegacyDecoder.cs
index 561707f9ef..6406bd88a5 100644
--- a/osu.Game/Beatmaps/Formats/LegacyDecoder.cs
+++ b/osu.Game/Beatmaps/Formats/LegacyDecoder.cs
@@ -8,6 +8,7 @@ using osu.Framework.Logging;
using osu.Game.Audio;
using osu.Game.Beatmaps.ControlPoints;
using osu.Game.IO;
+using osu.Game.Rulesets.Objects.Legacy;
using osuTK.Graphics;
namespace osu.Game.Beatmaps.Formats
@@ -149,7 +150,8 @@ namespace osu.Game.Beatmaps.Formats
HitObjects,
Variables,
Fonts,
- Mania
+ CatchTheBeat,
+ Mania,
}
internal class LegacyDifficultyControlPoint : DifficultyControlPoint
@@ -168,15 +170,19 @@ namespace osu.Game.Beatmaps.Formats
{
var baseInfo = base.ApplyTo(hitSampleInfo);
- if (string.IsNullOrEmpty(baseInfo.Suffix) && CustomSampleBank > 1)
- baseInfo.Suffix = CustomSampleBank.ToString();
+ if (baseInfo is ConvertHitObjectParser.LegacyHitSampleInfo legacy
+ && legacy.CustomSampleBank == 0)
+ {
+ legacy.CustomSampleBank = CustomSampleBank;
+ }
return baseInfo;
}
- public override bool EquivalentTo(ControlPoint other) =>
- base.EquivalentTo(other) && other is LegacySampleControlPoint otherTyped &&
- CustomSampleBank == otherTyped.CustomSampleBank;
+ public override bool IsRedundant(ControlPoint existing)
+ => base.IsRedundant(existing)
+ && existing is LegacySampleControlPoint existingSample
+ && CustomSampleBank == existingSample.CustomSampleBank;
}
}
}
diff --git a/osu.Game/Configuration/OsuConfigManager.cs b/osu.Game/Configuration/OsuConfigManager.cs
index 41f6747b74..9d31bc9bba 100644
--- a/osu.Game/Configuration/OsuConfigManager.cs
+++ b/osu.Game/Configuration/OsuConfigManager.cs
@@ -49,6 +49,7 @@ namespace osu.Game.Configuration
};
Set(OsuSetting.ExternalLinkWarning, true);
+ Set(OsuSetting.PreferNoVideo, false);
// Audio
Set(OsuSetting.VolumeInactive, 0.25, 0, 1, 0.01);
@@ -87,7 +88,9 @@ namespace osu.Game.Configuration
Set(OsuSetting.ShowInterface, true);
Set(OsuSetting.ShowProgressGraph, true);
Set(OsuSetting.ShowHealthDisplayWhenCantFail, true);
+ Set(OsuSetting.FadePlayfieldWhenHealthLow, true);
Set(OsuSetting.KeyOverlay, false);
+ Set(OsuSetting.PositionalHitSounds, true);
Set(OsuSetting.ScoreMeter, ScoreMeterType.HitErrorBoth);
Set(OsuSetting.FloatingComments, false);
@@ -176,11 +179,13 @@ namespace osu.Game.Configuration
LightenDuringBreaks,
ShowStoryboard,
KeyOverlay,
+ PositionalHitSounds,
ScoreMeter,
FloatingComments,
ShowInterface,
ShowProgressGraph,
ShowHealthDisplayWhenCantFail,
+ FadePlayfieldWhenHealthLow,
MouseDisableButtons,
MouseDisableWheel,
AudioOffset,
@@ -212,6 +217,7 @@ namespace osu.Game.Configuration
IncreaseFirstObjectVisibility,
ScoreDisplayMode,
ExternalLinkWarning,
+ PreferNoVideo,
Scaling,
ScalingPositionX,
ScalingPositionY,
diff --git a/osu.Game/Graphics/Containers/BeatSyncedContainer.cs b/osu.Game/Graphics/Containers/BeatSyncedContainer.cs
index f36079682e..5a613d1a54 100644
--- a/osu.Game/Graphics/Containers/BeatSyncedContainer.cs
+++ b/osu.Game/Graphics/Containers/BeatSyncedContainer.cs
@@ -103,7 +103,7 @@ namespace osu.Game.Graphics.Containers
TimeSinceLastBeat = beatLength - TimeUntilNextBeat;
- if (timingPoint.Equals(lastTimingPoint) && beatIndex == lastBeat)
+ if (timingPoint == lastTimingPoint && beatIndex == lastBeat)
return;
using (BeginDelayedSequence(-TimeSinceLastBeat, true))
diff --git a/osu.Game/Graphics/Containers/SectionsContainer.cs b/osu.Game/Graphics/Containers/SectionsContainer.cs
index 07a50c39e1..a3125614aa 100644
--- a/osu.Game/Graphics/Containers/SectionsContainer.cs
+++ b/osu.Game/Graphics/Containers/SectionsContainer.cs
@@ -3,6 +3,7 @@
using System;
using System.Linq;
+using JetBrains.Annotations;
using osu.Framework.Bindables;
using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers;
@@ -16,12 +17,7 @@ namespace osu.Game.Graphics.Containers
public class SectionsContainer : Container
where T : Drawable
{
- private Drawable expandableHeader, fixedHeader, footer, headerBackground;
- private readonly OsuScrollContainer scrollContainer;
- private readonly Container headerBackgroundContainer;
- private readonly FlowContainer scrollContentContainer;
-
- protected override Container Content => scrollContentContainer;
+ public Bindable SelectedSection { get; } = new Bindable();
public Drawable ExpandableHeader
{
@@ -83,6 +79,7 @@ namespace osu.Game.Graphics.Containers
headerBackgroundContainer.Clear();
headerBackground = value;
+
if (value == null) return;
headerBackgroundContainer.Add(headerBackground);
@@ -91,15 +88,37 @@ namespace osu.Game.Graphics.Containers
}
}
- public Bindable SelectedSection { get; } = new Bindable();
+ protected override Container Content => scrollContentContainer;
- protected virtual FlowContainer CreateScrollContentContainer()
- => new FillFlowContainer
+ private readonly OsuScrollContainer scrollContainer;
+ private readonly Container headerBackgroundContainer;
+ private readonly MarginPadding originalSectionsMargin;
+ private Drawable expandableHeader, fixedHeader, footer, headerBackground;
+ private FlowContainer scrollContentContainer;
+
+ private float headerHeight, footerHeight;
+
+ private float lastKnownScroll;
+
+ public SectionsContainer()
+ {
+ AddRangeInternal(new Drawable[]
{
- Direction = FillDirection.Vertical,
- AutoSizeAxes = Axes.Y,
- RelativeSizeAxes = Axes.X,
- };
+ scrollContainer = CreateScrollContainer().With(s =>
+ {
+ s.RelativeSizeAxes = Axes.Both;
+ s.Masking = true;
+ s.ScrollbarVisible = false;
+ s.Child = scrollContentContainer = CreateScrollContentContainer();
+ }),
+ headerBackgroundContainer = new Container
+ {
+ RelativeSizeAxes = Axes.X
+ }
+ });
+
+ originalSectionsMargin = scrollContentContainer.Margin;
+ }
public override void Add(T drawable)
{
@@ -109,40 +128,23 @@ namespace osu.Game.Graphics.Containers
footerHeight = float.NaN;
}
- private float headerHeight, footerHeight;
- private readonly MarginPadding originalSectionsMargin;
-
- private void updateSectionsMargin()
- {
- if (!Children.Any()) return;
-
- var newMargin = originalSectionsMargin;
- newMargin.Top += headerHeight;
- newMargin.Bottom += footerHeight;
-
- scrollContentContainer.Margin = newMargin;
- }
-
- public SectionsContainer()
- {
- AddInternal(scrollContainer = new OsuScrollContainer
- {
- RelativeSizeAxes = Axes.Both,
- Masking = true,
- ScrollbarVisible = false,
- Children = new Drawable[] { scrollContentContainer = CreateScrollContentContainer() }
- });
- AddInternal(headerBackgroundContainer = new Container
- {
- RelativeSizeAxes = Axes.X
- });
- originalSectionsMargin = scrollContentContainer.Margin;
- }
-
- public void ScrollTo(Drawable section) => scrollContainer.ScrollTo(scrollContainer.GetChildPosInContent(section) - (FixedHeader?.BoundingBox.Height ?? 0));
+ public void ScrollTo(Drawable section) =>
+ scrollContainer.ScrollTo(scrollContainer.GetChildPosInContent(section) - (FixedHeader?.BoundingBox.Height ?? 0));
public void ScrollToTop() => scrollContainer.ScrollTo(0);
+ [NotNull]
+ protected virtual OsuScrollContainer CreateScrollContainer() => new OsuScrollContainer();
+
+ [NotNull]
+ protected virtual FlowContainer CreateScrollContentContainer() =>
+ new FillFlowContainer
+ {
+ Direction = FillDirection.Vertical,
+ AutoSizeAxes = Axes.Y,
+ RelativeSizeAxes = Axes.X,
+ };
+
protected override bool OnInvalidate(Invalidation invalidation, InvalidationSource source)
{
var result = base.OnInvalidate(invalidation, source);
@@ -156,8 +158,6 @@ namespace osu.Game.Graphics.Containers
return result;
}
- private float lastKnownScroll;
-
protected override void UpdateAfterChildren()
{
base.UpdateAfterChildren();
@@ -208,5 +208,16 @@ namespace osu.Game.Graphics.Containers
SelectedSection.Value = bestMatch;
}
}
+
+ private void updateSectionsMargin()
+ {
+ if (!Children.Any()) return;
+
+ var newMargin = originalSectionsMargin;
+ newMargin.Top += headerHeight;
+ newMargin.Bottom += footerHeight;
+
+ scrollContentContainer.Margin = newMargin;
+ }
}
}
diff --git a/osu.Game/Graphics/UserInterface/DrawableOsuMenuItem.cs b/osu.Game/Graphics/UserInterface/DrawableOsuMenuItem.cs
index a3ca851341..abaae7b43c 100644
--- a/osu.Game/Graphics/UserInterface/DrawableOsuMenuItem.cs
+++ b/osu.Game/Graphics/UserInterface/DrawableOsuMenuItem.cs
@@ -42,6 +42,8 @@ namespace osu.Game.Graphics.UserInterface
BackgroundColourHover = Color4Extensions.FromHex(@"172023");
updateTextColour();
+
+ Item.Action.BindDisabledChanged(_ => updateState(), true);
}
private void updateTextColour()
@@ -65,19 +67,33 @@ namespace osu.Game.Graphics.UserInterface
protected override bool OnHover(HoverEvent e)
{
- sampleHover.Play();
- text.BoldText.FadeIn(transition_length, Easing.OutQuint);
- text.NormalText.FadeOut(transition_length, Easing.OutQuint);
+ updateState();
return base.OnHover(e);
}
protected override void OnHoverLost(HoverLostEvent e)
{
- text.BoldText.FadeOut(transition_length, Easing.OutQuint);
- text.NormalText.FadeIn(transition_length, Easing.OutQuint);
+ updateState();
base.OnHoverLost(e);
}
+ private void updateState()
+ {
+ Alpha = Item.Action.Disabled ? 0.2f : 1;
+
+ if (IsHovered && !Item.Action.Disabled)
+ {
+ sampleHover.Play();
+ text.BoldText.FadeIn(transition_length, Easing.OutQuint);
+ text.NormalText.FadeOut(transition_length, Easing.OutQuint);
+ }
+ else
+ {
+ text.BoldText.FadeOut(transition_length, Easing.OutQuint);
+ text.NormalText.FadeIn(transition_length, Easing.OutQuint);
+ }
+ }
+
protected override bool OnClick(ClickEvent e)
{
sampleClick.Play();
diff --git a/osu.Game/Online/API/APIRequest.cs b/osu.Game/Online/API/APIRequest.cs
index 6a6c7b72a8..47600e4f68 100644
--- a/osu.Game/Online/API/APIRequest.cs
+++ b/osu.Game/Online/API/APIRequest.cs
@@ -16,20 +16,27 @@ namespace osu.Game.Online.API
{
protected override WebRequest CreateWebRequest() => new OsuJsonWebRequest(Uri);
- public T Result => ((OsuJsonWebRequest)WebRequest)?.ResponseObject;
+ public T Result { get; private set; }
protected APIRequest()
{
- base.Success += onSuccess;
+ base.Success += () => TriggerSuccess(((OsuJsonWebRequest)WebRequest)?.ResponseObject);
}
- private void onSuccess() => Success?.Invoke(Result);
-
///
/// Invoked on successful completion of an API request.
/// This will be scheduled to the API's internal scheduler (run on update thread automatically).
///
public new event APISuccessHandler Success;
+
+ internal void TriggerSuccess(T result)
+ {
+ if (Result != null)
+ throw new InvalidOperationException("Attempted to trigger success more than once");
+
+ Result = result;
+ Success?.Invoke(result);
+ }
}
///
@@ -96,10 +103,15 @@ namespace osu.Game.Online.API
{
if (cancelled) return;
- Success?.Invoke();
+ TriggerSuccess();
});
}
+ internal void TriggerSuccess()
+ {
+ Success?.Invoke();
+ }
+
public void Cancel() => Fail(new OperationCanceledException(@"Request cancelled"));
public void Fail(Exception e)
diff --git a/osu.Game/Online/API/DummyAPIAccess.cs b/osu.Game/Online/API/DummyAPIAccess.cs
index a1c3475fd9..7800241904 100644
--- a/osu.Game/Online/API/DummyAPIAccess.cs
+++ b/osu.Game/Online/API/DummyAPIAccess.cs
@@ -1,6 +1,7 @@
// Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence.
// See the LICENCE file in the repository root for full licence text.
+using System;
using System.Collections.Generic;
using System.Threading;
using System.Threading.Tasks;
@@ -30,6 +31,11 @@ namespace osu.Game.Online.API
private readonly List components = new List();
+ ///
+ /// Provide handling logic for an arbitrary API request.
+ ///
+ public Action HandleRequest;
+
public APIState State
{
get => state;
@@ -55,11 +61,16 @@ namespace osu.Game.Online.API
public virtual void Queue(APIRequest request)
{
+ HandleRequest?.Invoke(request);
}
- public void Perform(APIRequest request) { }
+ public void Perform(APIRequest request) => HandleRequest?.Invoke(request);
- public Task PerformAsync(APIRequest request) => Task.CompletedTask;
+ public Task PerformAsync(APIRequest request)
+ {
+ HandleRequest?.Invoke(request);
+ return Task.CompletedTask;
+ }
public void Register(IOnlineComponent component)
{
diff --git a/osu.Game/OsuGame.cs b/osu.Game/OsuGame.cs
index 1b2fd658f4..5e93d760e3 100644
--- a/osu.Game/OsuGame.cs
+++ b/osu.Game/OsuGame.cs
@@ -315,8 +315,15 @@ namespace osu.Game
/// The user should have already requested this interactively.
///
/// The beatmap to select.
- public void PresentBeatmap(BeatmapSetInfo beatmap)
+ ///
+ /// Optional predicate used to try and find a difficulty to select.
+ /// If omitted, this will try to present the first beatmap from the current ruleset.
+ /// In case of failure the first difficulty of the set will be presented, ignoring the predicate.
+ ///
+ public void PresentBeatmap(BeatmapSetInfo beatmap, Predicate difficultyCriteria = null)
{
+ difficultyCriteria ??= b => b.Ruleset.Equals(Ruleset.Value);
+
var databasedSet = beatmap.OnlineBeatmapSetID != null
? BeatmapManager.QueryBeatmapSet(s => s.OnlineBeatmapSetID == beatmap.OnlineBeatmapSetID)
: BeatmapManager.QueryBeatmapSet(s => s.Hash == beatmap.Hash);
@@ -334,13 +341,13 @@ namespace osu.Game
menuScreen.LoadToSolo();
// we might even already be at the song
- if (Beatmap.Value.BeatmapSetInfo.Hash == databasedSet.Hash)
+ if (Beatmap.Value.BeatmapSetInfo.Hash == databasedSet.Hash && difficultyCriteria(Beatmap.Value.BeatmapInfo))
{
return;
}
- // Use first beatmap available for current ruleset, else switch ruleset.
- var first = databasedSet.Beatmaps.Find(b => b.Ruleset.Equals(Ruleset.Value)) ?? databasedSet.Beatmaps.First();
+ // Find first beatmap that matches our predicate.
+ var first = databasedSet.Beatmaps.Find(difficultyCriteria) ?? databasedSet.Beatmaps.First();
Ruleset.Value = first.Ruleset;
Beatmap.Value = BeatmapManager.GetWorkingBeatmap(first);
diff --git a/osu.Game/Overlays/BeatmapListingOverlay.cs b/osu.Game/Overlays/BeatmapListingOverlay.cs
index 5bac5a5402..b450f33ee1 100644
--- a/osu.Game/Overlays/BeatmapListingOverlay.cs
+++ b/osu.Game/Overlays/BeatmapListingOverlay.cs
@@ -54,7 +54,7 @@ namespace osu.Game.Overlays
RelativeSizeAxes = Axes.Both,
Colour = ColourProvider.Background6
},
- new BasicScrollContainer
+ new OverlayScrollContainer
{
RelativeSizeAxes = Axes.Both,
ScrollbarVisible = false,
diff --git a/osu.Game/Overlays/BeatmapSet/Header.cs b/osu.Game/Overlays/BeatmapSet/Header.cs
index 29c259b7f8..11dc424183 100644
--- a/osu.Game/Overlays/BeatmapSet/Header.cs
+++ b/osu.Game/Overlays/BeatmapSet/Header.cs
@@ -277,7 +277,8 @@ namespace osu.Game.Overlays.BeatmapSet
downloadButtonsContainer.Child = new PanelDownloadButton(BeatmapSet.Value)
{
Width = 50,
- RelativeSizeAxes = Axes.Y
+ RelativeSizeAxes = Axes.Y,
+ SelectedBeatmap = { BindTarget = Picker.Beatmap }
};
break;
diff --git a/osu.Game/Overlays/BeatmapSetOverlay.cs b/osu.Game/Overlays/BeatmapSetOverlay.cs
index 0d16c4842d..3e23442023 100644
--- a/osu.Game/Overlays/BeatmapSetOverlay.cs
+++ b/osu.Game/Overlays/BeatmapSetOverlay.cs
@@ -39,7 +39,7 @@ namespace osu.Game.Overlays
public BeatmapSetOverlay()
: base(OverlayColourScheme.Blue)
{
- OsuScrollContainer scroll;
+ OverlayScrollContainer scroll;
Info info;
CommentsSection comments;
@@ -49,7 +49,7 @@ namespace osu.Game.Overlays
{
RelativeSizeAxes = Axes.Both
},
- scroll = new OsuScrollContainer
+ scroll = new OverlayScrollContainer
{
RelativeSizeAxes = Axes.Both,
ScrollbarVisible = false,
diff --git a/osu.Game/Overlays/Changelog/Comments.cs b/osu.Game/Overlays/Changelog/Comments.cs
deleted file mode 100644
index 4cf39e7b44..0000000000
--- a/osu.Game/Overlays/Changelog/Comments.cs
+++ /dev/null
@@ -1,79 +0,0 @@
-// Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence.
-// See the LICENCE file in the repository root for full licence text.
-
-using osu.Framework.Allocation;
-using osu.Framework.Graphics;
-using osu.Framework.Graphics.Containers;
-using osu.Framework.Graphics.Shapes;
-using osu.Framework.Graphics.Sprites;
-using osu.Game.Graphics;
-using osu.Game.Graphics.Containers;
-using osu.Game.Online.API.Requests.Responses;
-using osuTK.Graphics;
-
-namespace osu.Game.Overlays.Changelog
-{
- public class Comments : CompositeDrawable
- {
- private readonly APIChangelogBuild build;
-
- public Comments(APIChangelogBuild build)
- {
- this.build = build;
-
- RelativeSizeAxes = Axes.X;
- AutoSizeAxes = Axes.Y;
-
- Padding = new MarginPadding
- {
- Horizontal = 50,
- Vertical = 20,
- };
- }
-
- [BackgroundDependencyLoader]
- private void load(OsuColour colours)
- {
- LinkFlowContainer text;
-
- InternalChildren = new Drawable[]
- {
- new Container
- {
- RelativeSizeAxes = Axes.Both,
- Masking = true,
- CornerRadius = 10,
- Child = new Box
- {
- RelativeSizeAxes = Axes.Both,
- Colour = colours.GreyVioletDarker
- },
- },
- text = new LinkFlowContainer(t =>
- {
- t.Colour = colours.PinkLighter;
- t.Font = OsuFont.Default.With(size: 14);
- })
- {
- Padding = new MarginPadding(20),
- RelativeSizeAxes = Axes.X,
- AutoSizeAxes = Axes.Y,
- }
- };
-
- text.AddParagraph("Got feedback?", t =>
- {
- t.Colour = Color4.White;
- t.Font = OsuFont.Default.With(italics: true, size: 20);
- t.Padding = new MarginPadding { Bottom = 20 };
- });
-
- text.AddParagraph("We would love to hear what you think of this update! ");
- text.AddIcon(FontAwesome.Regular.GrinHearts);
-
- text.AddParagraph("Please visit the ");
- text.AddLink("web version", $"{build.Url}#comments");
- text.AddText(" of this changelog to leave any comments.");
- }
- }
-}
diff --git a/osu.Game/Overlays/ChangelogOverlay.cs b/osu.Game/Overlays/ChangelogOverlay.cs
index d13ac5c2de..726be9e194 100644
--- a/osu.Game/Overlays/ChangelogOverlay.cs
+++ b/osu.Game/Overlays/ChangelogOverlay.cs
@@ -50,7 +50,7 @@ namespace osu.Game.Overlays
RelativeSizeAxes = Axes.Both,
Colour = ColourProvider.Background4,
},
- new OsuScrollContainer
+ new OverlayScrollContainer
{
RelativeSizeAxes = Axes.Both,
ScrollbarVisible = false,
diff --git a/osu.Game/Overlays/Direct/PanelDownloadButton.cs b/osu.Game/Overlays/Direct/PanelDownloadButton.cs
index 1b3657f010..387ced6acb 100644
--- a/osu.Game/Overlays/Direct/PanelDownloadButton.cs
+++ b/osu.Game/Overlays/Direct/PanelDownloadButton.cs
@@ -1,9 +1,12 @@
// Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence.
// See the LICENCE file in the repository root for full licence text.
+using System;
using osu.Framework.Allocation;
+using osu.Framework.Bindables;
using osu.Framework.Graphics;
using osu.Game.Beatmaps;
+using osu.Game.Configuration;
using osu.Game.Graphics.Containers;
using osu.Game.Graphics.UserInterface;
using osu.Game.Online;
@@ -14,16 +17,18 @@ namespace osu.Game.Overlays.Direct
{
protected bool DownloadEnabled => button.Enabled.Value;
- private readonly bool noVideo;
+ ///
+ /// Currently selected beatmap. Used to present the correct difficulty after completing a download.
+ ///
+ public readonly IBindable SelectedBeatmap = new Bindable();
private readonly ShakeContainer shakeContainer;
private readonly DownloadButton button;
+ private Bindable noVideoSetting;
- public PanelDownloadButton(BeatmapSetInfo beatmapSet, bool noVideo = false)
+ public PanelDownloadButton(BeatmapSetInfo beatmapSet)
: base(beatmapSet)
{
- this.noVideo = noVideo;
-
InternalChild = shakeContainer = new ShakeContainer
{
RelativeSizeAxes = Axes.Both,
@@ -43,7 +48,7 @@ namespace osu.Game.Overlays.Direct
}
[BackgroundDependencyLoader(true)]
- private void load(OsuGame game, BeatmapManager beatmaps)
+ private void load(OsuGame game, BeatmapManager beatmaps, OsuConfigManager osuConfig)
{
if (BeatmapSet.Value?.OnlineInfo?.Availability?.DownloadDisabled ?? false)
{
@@ -52,6 +57,8 @@ namespace osu.Game.Overlays.Direct
return;
}
+ noVideoSetting = osuConfig.GetBindable(OsuSetting.PreferNoVideo);
+
button.Action = () =>
{
switch (State.Value)
@@ -62,11 +69,15 @@ namespace osu.Game.Overlays.Direct
break;
case DownloadState.LocallyAvailable:
- game?.PresentBeatmap(BeatmapSet.Value);
+ Predicate findPredicate = null;
+ if (SelectedBeatmap.Value != null)
+ findPredicate = b => b.OnlineBeatmapID == SelectedBeatmap.Value.OnlineBeatmapID;
+
+ game?.PresentBeatmap(BeatmapSet.Value, findPredicate);
break;
default:
- beatmaps.Download(BeatmapSet.Value, noVideo);
+ beatmaps.Download(BeatmapSet.Value, noVideoSetting.Value);
break;
}
};
diff --git a/osu.Game/Overlays/NewsOverlay.cs b/osu.Game/Overlays/NewsOverlay.cs
index 71c205ff63..46d692d44d 100644
--- a/osu.Game/Overlays/NewsOverlay.cs
+++ b/osu.Game/Overlays/NewsOverlay.cs
@@ -8,7 +8,6 @@ using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers;
using osu.Framework.Graphics.Shapes;
using osu.Game.Graphics;
-using osu.Game.Graphics.Containers;
using osu.Game.Overlays.News;
namespace osu.Game.Overlays
@@ -36,7 +35,7 @@ namespace osu.Game.Overlays
RelativeSizeAxes = Axes.Both,
Colour = colours.PurpleDarkAlternative
},
- new OsuScrollContainer
+ new OverlayScrollContainer
{
RelativeSizeAxes = Axes.Both,
Child = new FillFlowContainer
diff --git a/osu.Game/Overlays/OverlayScrollContainer.cs b/osu.Game/Overlays/OverlayScrollContainer.cs
new file mode 100644
index 0000000000..e7415e6f74
--- /dev/null
+++ b/osu.Game/Overlays/OverlayScrollContainer.cs
@@ -0,0 +1,149 @@
+// Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence.
+// See the LICENCE file in the repository root for full licence text.
+
+using System.Collections.Generic;
+using osu.Framework.Allocation;
+using osu.Framework.Extensions.Color4Extensions;
+using osu.Framework.Graphics;
+using osu.Framework.Graphics.Containers;
+using osu.Framework.Graphics.Effects;
+using osu.Framework.Graphics.Shapes;
+using osu.Framework.Graphics.Sprites;
+using osu.Framework.Input.Events;
+using osu.Game.Graphics.Containers;
+using osuTK;
+using osuTK.Graphics;
+
+namespace osu.Game.Overlays
+{
+ ///
+ /// which provides . Mostly used in .
+ ///
+ public class OverlayScrollContainer : OsuScrollContainer
+ {
+ ///
+ /// Scroll position at which the will be shown.
+ ///
+ private const int button_scroll_position = 200;
+
+ protected readonly ScrollToTopButton Button;
+
+ public OverlayScrollContainer()
+ {
+ AddInternal(Button = new ScrollToTopButton
+ {
+ Anchor = Anchor.BottomRight,
+ Origin = Anchor.BottomRight,
+ Margin = new MarginPadding(20),
+ Action = () =>
+ {
+ ScrollToStart();
+ Button.State = Visibility.Hidden;
+ }
+ });
+ }
+
+ protected override void UpdateAfterChildren()
+ {
+ base.UpdateAfterChildren();
+
+ if (ScrollContent.DrawHeight + button_scroll_position < DrawHeight)
+ {
+ Button.State = Visibility.Hidden;
+ return;
+ }
+
+ Button.State = Target > button_scroll_position ? Visibility.Visible : Visibility.Hidden;
+ }
+
+ public class ScrollToTopButton : OsuHoverContainer
+ {
+ private const int fade_duration = 500;
+
+ private Visibility state;
+
+ public Visibility State
+ {
+ get => state;
+ set
+ {
+ if (value == state)
+ return;
+
+ state = value;
+ Enabled.Value = state == Visibility.Visible;
+ this.FadeTo(state == Visibility.Visible ? 1 : 0, fade_duration, Easing.OutQuint);
+ }
+ }
+
+ protected override IEnumerable EffectTargets => new[] { background };
+
+ private Color4 flashColour;
+
+ private readonly Container content;
+ private readonly Box background;
+
+ public ScrollToTopButton()
+ {
+ Size = new Vector2(50);
+ Alpha = 0;
+ Add(content = new CircularContainer
+ {
+ RelativeSizeAxes = Axes.Both,
+ Anchor = Anchor.Centre,
+ Origin = Anchor.Centre,
+ Masking = true,
+ EdgeEffect = new EdgeEffectParameters
+ {
+ Type = EdgeEffectType.Shadow,
+ Offset = new Vector2(0f, 1f),
+ Radius = 3f,
+ Colour = Color4.Black.Opacity(0.25f),
+ },
+ Children = new Drawable[]
+ {
+ background = new Box
+ {
+ RelativeSizeAxes = Axes.Both
+ },
+ new SpriteIcon
+ {
+ Anchor = Anchor.Centre,
+ Origin = Anchor.Centre,
+ Size = new Vector2(15),
+ Icon = FontAwesome.Solid.ChevronUp
+ }
+ }
+ });
+
+ TooltipText = "Scroll to top";
+ }
+
+ [BackgroundDependencyLoader]
+ private void load(OverlayColourProvider colourProvider)
+ {
+ IdleColour = colourProvider.Background6;
+ HoverColour = colourProvider.Background5;
+ flashColour = colourProvider.Light1;
+ }
+
+ protected override bool OnClick(ClickEvent e)
+ {
+ background.FlashColour(flashColour, 800, Easing.OutQuint);
+ return base.OnClick(e);
+ }
+
+ protected override bool OnMouseDown(MouseDownEvent e)
+ {
+ content.ScaleTo(0.75f, 2000, Easing.OutQuint);
+ return true;
+ }
+
+ protected override void OnMouseUp(MouseUpEvent e)
+ {
+ content.ScaleTo(1, 1000, Easing.OutElastic);
+ base.OnMouseUp(e);
+ }
+ }
+ }
+}
diff --git a/osu.Game/Overlays/RankingsOverlay.cs b/osu.Game/Overlays/RankingsOverlay.cs
index afb23883ac..7b200d4226 100644
--- a/osu.Game/Overlays/RankingsOverlay.cs
+++ b/osu.Game/Overlays/RankingsOverlay.cs
@@ -23,7 +23,7 @@ namespace osu.Game.Overlays
protected Bindable Scope => header.Current;
- private readonly BasicScrollContainer scrollFlow;
+ private readonly OverlayScrollContainer scrollFlow;
private readonly Container contentContainer;
private readonly LoadingLayer loading;
private readonly Box background;
@@ -44,7 +44,7 @@ namespace osu.Game.Overlays
{
RelativeSizeAxes = Axes.Both
},
- scrollFlow = new BasicScrollContainer
+ scrollFlow = new OverlayScrollContainer
{
RelativeSizeAxes = Axes.Both,
ScrollbarVisible = false,
diff --git a/osu.Game/Overlays/SearchableList/SearchableListOverlay.cs b/osu.Game/Overlays/SearchableList/SearchableListOverlay.cs
index d6174e0733..4ab2de06b6 100644
--- a/osu.Game/Overlays/SearchableList/SearchableListOverlay.cs
+++ b/osu.Game/Overlays/SearchableList/SearchableListOverlay.cs
@@ -8,7 +8,6 @@ using osu.Framework.Graphics.Containers;
using osu.Framework.Graphics.Shapes;
using osu.Framework.Input.Events;
using osu.Game.Graphics.Backgrounds;
-using osu.Game.Graphics.Containers;
using osu.Game.Graphics.Cursor;
namespace osu.Game.Overlays.SearchableList
@@ -72,7 +71,7 @@ namespace osu.Game.Overlays.SearchableList
{
RelativeSizeAxes = Axes.Both,
Masking = true,
- Child = new OsuScrollContainer
+ Child = new OverlayScrollContainer
{
RelativeSizeAxes = Axes.Both,
ScrollbarVisible = false,
diff --git a/osu.Game/Overlays/Settings/Sections/Gameplay/GeneralSettings.cs b/osu.Game/Overlays/Settings/Sections/Gameplay/GeneralSettings.cs
index 2d2cd42213..93a02ea0e4 100644
--- a/osu.Game/Overlays/Settings/Sections/Gameplay/GeneralSettings.cs
+++ b/osu.Game/Overlays/Settings/Sections/Gameplay/GeneralSettings.cs
@@ -53,10 +53,20 @@ namespace osu.Game.Overlays.Settings.Sections.Gameplay
Keywords = new[] { "hp", "bar" }
},
new SettingsCheckbox
+ {
+ LabelText = "Fade playfield to red when health is low",
+ Bindable = config.GetBindable(OsuSetting.FadePlayfieldWhenHealthLow),
+ },
+ new SettingsCheckbox
{
LabelText = "Always show key overlay",
Bindable = config.GetBindable(OsuSetting.KeyOverlay)
},
+ new SettingsCheckbox
+ {
+ LabelText = "Positional hitsounds",
+ Bindable = config.GetBindable(OsuSetting.PositionalHitSounds)
+ },
new SettingsEnumDropdown
{
LabelText = "Score meter type",
diff --git a/osu.Game/Overlays/Settings/Sections/Online/WebSettings.cs b/osu.Game/Overlays/Settings/Sections/Online/WebSettings.cs
index a8b3e45a83..23513eade8 100644
--- a/osu.Game/Overlays/Settings/Sections/Online/WebSettings.cs
+++ b/osu.Game/Overlays/Settings/Sections/Online/WebSettings.cs
@@ -21,6 +21,12 @@ namespace osu.Game.Overlays.Settings.Sections.Online
LabelText = "Warn about opening external links",
Bindable = config.GetBindable(OsuSetting.ExternalLinkWarning)
},
+ new SettingsCheckbox
+ {
+ LabelText = "Prefer downloads without video",
+ Keywords = new[] { "no-video" },
+ Bindable = config.GetBindable(OsuSetting.PreferNoVideo)
+ },
};
}
}
diff --git a/osu.Game/Overlays/UserProfileOverlay.cs b/osu.Game/Overlays/UserProfileOverlay.cs
index 6ec30f7707..b4c8a2d3ca 100644
--- a/osu.Game/Overlays/UserProfileOverlay.cs
+++ b/osu.Game/Overlays/UserProfileOverlay.cs
@@ -195,6 +195,8 @@ namespace osu.Game.Overlays
RelativeSizeAxes = Axes.Both;
}
+ protected override OsuScrollContainer CreateScrollContainer() => new OverlayScrollContainer();
+
protected override FlowContainer CreateScrollContentContainer() => new FillFlowContainer
{
Direction = FillDirection.Vertical,
diff --git a/osu.Game/Rulesets/Edit/PlacementBlueprint.cs b/osu.Game/Rulesets/Edit/PlacementBlueprint.cs
index ea77a6091a..fb1eb7adbf 100644
--- a/osu.Game/Rulesets/Edit/PlacementBlueprint.cs
+++ b/osu.Game/Rulesets/Edit/PlacementBlueprint.cs
@@ -106,6 +106,9 @@ namespace osu.Game.Rulesets.Edit
case ScrollEvent _:
return false;
+ case DoubleClickEvent _:
+ return false;
+
case MouseButtonEvent _:
return true;
diff --git a/osu.Game/Rulesets/Objects/Drawables/DrawableHitObject.cs b/osu.Game/Rulesets/Objects/Drawables/DrawableHitObject.cs
index 8fa0c041d4..b14927bcd5 100644
--- a/osu.Game/Rulesets/Objects/Drawables/DrawableHitObject.cs
+++ b/osu.Game/Rulesets/Objects/Drawables/DrawableHitObject.cs
@@ -12,11 +12,13 @@ using osu.Framework.Extensions.TypeExtensions;
using osu.Framework.Graphics;
using osu.Framework.Graphics.Primitives;
using osu.Framework.Threading;
+using osu.Framework.Audio;
using osu.Game.Audio;
using osu.Game.Rulesets.Judgements;
using osu.Game.Rulesets.Objects.Types;
using osu.Game.Rulesets.Scoring;
using osu.Game.Skinning;
+using osu.Game.Configuration;
using osuTK.Graphics;
namespace osu.Game.Rulesets.Objects.Drawables
@@ -84,8 +86,20 @@ namespace osu.Game.Rulesets.Objects.Drawables
///
public JudgementResult Result { get; private set; }
+ ///
+ /// The relative X position of this hit object for sample playback balance adjustment.
+ ///
+ ///
+ /// This is a range of 0..1 (0 for far-left, 0.5 for centre, 1 for far-right).
+ /// Dampening is post-applied to ensure the effect is not too intense.
+ ///
+ protected virtual float SamplePlaybackPosition => 0.5f;
+
+ private readonly BindableDouble balanceAdjust = new BindableDouble();
+
private BindableList samplesBindable;
private Bindable startTimeBindable;
+ private Bindable userPositionalHitSounds;
private Bindable comboIndexBindable;
public override bool RemoveWhenNotAlive => false;
@@ -104,8 +118,9 @@ namespace osu.Game.Rulesets.Objects.Drawables
}
[BackgroundDependencyLoader]
- private void load()
+ private void load(OsuConfigManager config)
{
+ userPositionalHitSounds = config.GetBindable(OsuSetting.PositionalHitSounds);
var judgement = HitObject.CreateJudgement();
Result = CreateResult(judgement);
@@ -156,7 +171,9 @@ namespace osu.Game.Rulesets.Objects.Drawables
+ $" This is an indication that {nameof(HitObject.ApplyDefaults)} has not been invoked on {this}.");
}
- AddInternal(Samples = new SkinnableSound(samples.Select(s => HitObject.SampleControlPoint.ApplyTo(s))));
+ Samples = new SkinnableSound(samples.Select(s => HitObject.SampleControlPoint.ApplyTo(s)));
+ Samples.AddAdjustment(AdjustableProperty.Balance, balanceAdjust);
+ AddInternal(Samples);
}
private void onDefaultsApplied() => apply(HitObject);
@@ -353,7 +370,13 @@ namespace osu.Game.Rulesets.Objects.Drawables
/// Plays all the hit sounds for this .
/// This is invoked automatically when this is hit.
///
- public virtual void PlaySamples() => Samples?.Play();
+ public virtual void PlaySamples()
+ {
+ const float balance_adjust_amount = 0.4f;
+
+ balanceAdjust.Value = balance_adjust_amount * (userPositionalHitSounds.Value ? SamplePlaybackPosition - 0.5f : 0);
+ Samples?.Play();
+ }
protected override void Update()
{
diff --git a/osu.Game/Rulesets/Objects/Legacy/ConvertHitObjectParser.cs b/osu.Game/Rulesets/Objects/Legacy/ConvertHitObjectParser.cs
index 8d3ad5984f..9a60a0a75c 100644
--- a/osu.Game/Rulesets/Objects/Legacy/ConvertHitObjectParser.cs
+++ b/osu.Game/Rulesets/Objects/Legacy/ConvertHitObjectParser.cs
@@ -409,22 +409,34 @@ namespace osu.Game.Rulesets.Objects.Legacy
public SampleBankInfo Clone() => (SampleBankInfo)MemberwiseClone();
}
- private class LegacyHitSampleInfo : HitSampleInfo
+ internal class LegacyHitSampleInfo : HitSampleInfo
{
+ private int customSampleBank;
+
public int CustomSampleBank
{
+ get => customSampleBank;
set
{
- if (value > 1)
+ customSampleBank = value;
+
+ if (value >= 2)
Suffix = value.ToString();
}
}
}
- private class FileHitSampleInfo : HitSampleInfo
+ private class FileHitSampleInfo : LegacyHitSampleInfo
{
public string Filename;
+ public FileHitSampleInfo()
+ {
+ // Make sure that the LegacyBeatmapSkin does not fall back to the user skin.
+ // Note that this does not change the lookup names, as they are overridden locally.
+ CustomSampleBank = 1;
+ }
+
public override IEnumerable LookupNames => new[]
{
Filename,
diff --git a/osu.Game/Rulesets/Scoring/ScoreProcessor.cs b/osu.Game/Rulesets/Scoring/ScoreProcessor.cs
index 8eafaa88ec..1f40f44dce 100644
--- a/osu.Game/Rulesets/Scoring/ScoreProcessor.cs
+++ b/osu.Game/Rulesets/Scoring/ScoreProcessor.cs
@@ -174,7 +174,7 @@ namespace osu.Game.Rulesets.Scoring
case ScoringMode.Classic:
// should emulate osu-stable's scoring as closely as we can (https://osu.ppy.sh/help/wiki/Score/ScoreV1)
- return bonusScore + baseScore * ((1 + Math.Max(0, HighestCombo.Value - 1) * scoreMultiplier) / 25);
+ return bonusScore + baseScore * (1 + Math.Max(0, HighestCombo.Value - 1) * scoreMultiplier / 25);
}
}
diff --git a/osu.Game/Screens/Edit/Compose/Components/BlueprintContainer.cs b/osu.Game/Screens/Edit/Compose/Components/BlueprintContainer.cs
index c81c6059cc..ad16e22e5e 100644
--- a/osu.Game/Screens/Edit/Compose/Components/BlueprintContainer.cs
+++ b/osu.Game/Screens/Edit/Compose/Components/BlueprintContainer.cs
@@ -37,6 +37,9 @@ namespace osu.Game.Screens.Edit.Compose.Components
private SelectionHandler selectionHandler;
+ [Resolved(CanBeNull = true)]
+ private IEditorChangeHandler changeHandler { get; set; }
+
[Resolved]
private IAdjustableClock adjustableClock { get; set; }
@@ -164,7 +167,11 @@ namespace osu.Game.Screens.Edit.Compose.Components
return false;
if (movementBlueprint != null)
+ {
+ isDraggingBlueprint = true;
+ changeHandler?.BeginChange();
return true;
+ }
if (DragBox.HandleDrag(e))
{
@@ -191,6 +198,12 @@ namespace osu.Game.Screens.Edit.Compose.Components
if (e.Button == MouseButton.Right)
return;
+ if (isDraggingBlueprint)
+ {
+ changeHandler?.EndChange();
+ isDraggingBlueprint = false;
+ }
+
if (DragBox.State == Visibility.Visible)
{
DragBox.Hide();
@@ -354,6 +367,7 @@ namespace osu.Game.Screens.Edit.Compose.Components
private Vector2? movementBlueprintOriginalPosition;
private SelectionBlueprint movementBlueprint;
+ private bool isDraggingBlueprint;
///
/// Attempts to begin the movement of any selected blueprints.
diff --git a/osu.Game/Screens/Edit/Compose/Components/SelectionHandler.cs b/osu.Game/Screens/Edit/Compose/Components/SelectionHandler.cs
index fc46bf3fed..764eae1056 100644
--- a/osu.Game/Screens/Edit/Compose/Components/SelectionHandler.cs
+++ b/osu.Game/Screens/Edit/Compose/Components/SelectionHandler.cs
@@ -40,6 +40,9 @@ namespace osu.Game.Screens.Edit.Compose.Components
[Resolved(CanBeNull = true)]
private EditorBeatmap editorBeatmap { get; set; }
+ [Resolved(CanBeNull = true)]
+ private IEditorChangeHandler changeHandler { get; set; }
+
public SelectionHandler()
{
selectedBlueprints = new List();
@@ -152,8 +155,12 @@ namespace osu.Game.Screens.Edit.Compose.Components
private void deleteSelected()
{
+ changeHandler?.BeginChange();
+
foreach (var h in selectedBlueprints.ToList())
- editorBeatmap.Remove(h.HitObject);
+ editorBeatmap?.Remove(h.HitObject);
+
+ changeHandler?.EndChange();
}
#endregion
@@ -205,6 +212,8 @@ namespace osu.Game.Screens.Edit.Compose.Components
/// The name of the hit sample.
public void AddHitSample(string sampleName)
{
+ changeHandler?.BeginChange();
+
foreach (var h in SelectedHitObjects)
{
// Make sure there isn't already an existing sample
@@ -213,6 +222,8 @@ namespace osu.Game.Screens.Edit.Compose.Components
h.Samples.Add(new HitSampleInfo { Name = sampleName });
}
+
+ changeHandler?.EndChange();
}
///
@@ -221,8 +232,12 @@ namespace osu.Game.Screens.Edit.Compose.Components
/// The name of the hit sample.
public void RemoveHitSample(string sampleName)
{
+ changeHandler?.BeginChange();
+
foreach (var h in SelectedHitObjects)
h.SamplesBindable.RemoveAll(s => s.Name == sampleName);
+
+ changeHandler?.EndChange();
}
#endregion
diff --git a/osu.Game/Screens/Edit/Compose/Components/Timeline/TimelineHitObjectBlueprint.cs b/osu.Game/Screens/Edit/Compose/Components/Timeline/TimelineHitObjectBlueprint.cs
index 8f12c2f0ed..16ba3ba89a 100644
--- a/osu.Game/Screens/Edit/Compose/Components/Timeline/TimelineHitObjectBlueprint.cs
+++ b/osu.Game/Screens/Edit/Compose/Components/Timeline/TimelineHitObjectBlueprint.cs
@@ -254,14 +254,21 @@ namespace osu.Game.Screens.Edit.Compose.Components.Timeline
Colour = IsHovered || hasMouseDown ? Color4.OrangeRed : Color4.White;
}
- protected override bool OnDragStart(DragStartEvent e) => true;
-
[Resolved]
private EditorBeatmap beatmap { get; set; }
[Resolved]
private IBeatSnapProvider beatSnapProvider { get; set; }
+ [Resolved(CanBeNull = true)]
+ private IEditorChangeHandler changeHandler { get; set; }
+
+ protected override bool OnDragStart(DragStartEvent e)
+ {
+ changeHandler?.BeginChange();
+ return true;
+ }
+
protected override void OnDrag(DragEvent e)
{
base.OnDrag(e);
@@ -301,6 +308,7 @@ namespace osu.Game.Screens.Edit.Compose.Components.Timeline
base.OnDragEnd(e);
OnDragHandled?.Invoke(null);
+ changeHandler?.EndChange();
}
}
}
diff --git a/osu.Game/Screens/Edit/Editor.cs b/osu.Game/Screens/Edit/Editor.cs
index f1cbed57f1..9a1f450dc6 100644
--- a/osu.Game/Screens/Edit/Editor.cs
+++ b/osu.Game/Screens/Edit/Editor.cs
@@ -62,6 +62,7 @@ namespace osu.Game.Screens.Edit
private IBeatmap playableBeatmap;
private EditorBeatmap editorBeatmap;
+ private EditorChangeHandler changeHandler;
private DependencyContainer dependencies;
@@ -100,10 +101,14 @@ namespace osu.Game.Screens.Edit
}
AddInternal(editorBeatmap = new EditorBeatmap(playableBeatmap));
-
dependencies.CacheAs(editorBeatmap);
+ changeHandler = new EditorChangeHandler(editorBeatmap);
+ dependencies.CacheAs(changeHandler);
+
EditorMenuBar menuBar;
+ OsuMenuItem undoMenuItem;
+ OsuMenuItem redoMenuItem;
var fileMenuItems = new List
/// The to add.
- public void Remove(HitObject hitObject)
+ /// True if the has been removed, false otherwise.
+ public bool Remove(HitObject hitObject)
{
- if (!mutableHitObjects.Contains(hitObject))
- return;
+ int index = FindIndex(hitObject);
- mutableHitObjects.Remove(hitObject);
+ if (index == -1)
+ return false;
+
+ RemoveAt(index);
+ return true;
+ }
+
+ ///
+ /// Finds the index of a in this .
+ ///
+ /// The to search for.
+ /// The index of .
+ public int FindIndex(HitObject hitObject) => mutableHitObjects.IndexOf(hitObject);
+
+ ///
+ /// Removes a at an index in this .
+ ///
+ /// The index of the to remove.
+ public void RemoveAt(int index)
+ {
+ var hitObject = (HitObject)mutableHitObjects[index];
+
+ mutableHitObjects.RemoveAt(index);
var bindable = startTimeBindables[hitObject];
bindable.UnbindAll();
diff --git a/osu.Game/Screens/Edit/EditorChangeHandler.cs b/osu.Game/Screens/Edit/EditorChangeHandler.cs
new file mode 100644
index 0000000000..1553c2d2ef
--- /dev/null
+++ b/osu.Game/Screens/Edit/EditorChangeHandler.cs
@@ -0,0 +1,130 @@
+// Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence.
+// See the LICENCE file in the repository root for full licence text.
+
+using System;
+using System.Collections.Generic;
+using System.IO;
+using System.Text;
+using osu.Framework.Bindables;
+using osu.Game.Beatmaps.Formats;
+using osu.Game.Rulesets.Objects;
+
+namespace osu.Game.Screens.Edit
+{
+ ///
+ /// Tracks changes to the .
+ ///
+ public class EditorChangeHandler : IEditorChangeHandler
+ {
+ public readonly Bindable CanUndo = new Bindable();
+ public readonly Bindable CanRedo = new Bindable();
+
+ private readonly LegacyEditorBeatmapPatcher patcher;
+ private readonly List savedStates = new List();
+
+ private int currentState = -1;
+
+ private readonly EditorBeatmap editorBeatmap;
+ private int bulkChangesStarted;
+ private bool isRestoring;
+
+ public const int MAX_SAVED_STATES = 50;
+
+ ///
+ /// Creates a new .
+ ///
+ /// The to track the s of.
+ public EditorChangeHandler(EditorBeatmap editorBeatmap)
+ {
+ this.editorBeatmap = editorBeatmap;
+
+ editorBeatmap.HitObjectAdded += hitObjectAdded;
+ editorBeatmap.HitObjectRemoved += hitObjectRemoved;
+ editorBeatmap.HitObjectUpdated += hitObjectUpdated;
+
+ patcher = new LegacyEditorBeatmapPatcher(editorBeatmap);
+
+ // Initial state.
+ SaveState();
+ }
+
+ private void hitObjectAdded(HitObject obj) => SaveState();
+
+ private void hitObjectRemoved(HitObject obj) => SaveState();
+
+ private void hitObjectUpdated(HitObject obj) => SaveState();
+
+ public void BeginChange() => bulkChangesStarted++;
+
+ public void EndChange()
+ {
+ if (bulkChangesStarted == 0)
+ throw new InvalidOperationException($"Cannot call {nameof(EndChange)} without a previous call to {nameof(BeginChange)}.");
+
+ if (--bulkChangesStarted == 0)
+ SaveState();
+ }
+
+ ///
+ /// Saves the current state.
+ ///
+ public void SaveState()
+ {
+ if (bulkChangesStarted > 0)
+ return;
+
+ if (isRestoring)
+ return;
+
+ if (currentState < savedStates.Count - 1)
+ savedStates.RemoveRange(currentState + 1, savedStates.Count - currentState - 1);
+
+ if (savedStates.Count > MAX_SAVED_STATES)
+ savedStates.RemoveAt(0);
+
+ using (var stream = new MemoryStream())
+ {
+ using (var sw = new StreamWriter(stream, Encoding.UTF8, 1024, true))
+ new LegacyBeatmapEncoder(editorBeatmap).Encode(sw);
+
+ savedStates.Add(stream.ToArray());
+ }
+
+ currentState = savedStates.Count - 1;
+
+ updateBindables();
+ }
+
+ ///
+ /// Restores an older or newer state.
+ ///
+ /// The direction to restore in. If less than 0, an older state will be used. If greater than 0, a newer state will be used.
+ public void RestoreState(int direction)
+ {
+ if (bulkChangesStarted > 0)
+ return;
+
+ if (savedStates.Count == 0)
+ return;
+
+ int newState = Math.Clamp(currentState + direction, 0, savedStates.Count - 1);
+ if (currentState == newState)
+ return;
+
+ isRestoring = true;
+
+ patcher.Patch(savedStates[currentState], savedStates[newState]);
+ currentState = newState;
+
+ isRestoring = false;
+
+ updateBindables();
+ }
+
+ private void updateBindables()
+ {
+ CanUndo.Value = savedStates.Count > 0 && currentState > 0;
+ CanRedo.Value = currentState < savedStates.Count - 1;
+ }
+ }
+}
diff --git a/osu.Game/Screens/Edit/IEditorChangeHandler.cs b/osu.Game/Screens/Edit/IEditorChangeHandler.cs
new file mode 100644
index 0000000000..c1328252d4
--- /dev/null
+++ b/osu.Game/Screens/Edit/IEditorChangeHandler.cs
@@ -0,0 +1,33 @@
+// Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence.
+// See the LICENCE file in the repository root for full licence text.
+
+using osu.Game.Rulesets.Objects;
+
+namespace osu.Game.Screens.Edit
+{
+ ///
+ /// Interface for a component that manages changes in the .
+ ///
+ public interface IEditorChangeHandler
+ {
+ ///
+ /// Begins a bulk state change event. should be invoked soon after.
+ ///
+ ///
+ /// This should be invoked when multiple changes to the should be bundled together into one state change event.
+ /// When nested invocations are involved, a state change will not occur until an equal number of invocations of are received.
+ ///
+ ///
+ /// When a group of s are deleted, a single undo and redo state change should update the state of all .
+ ///
+ void BeginChange();
+
+ ///
+ /// Ends a bulk state change event.
+ ///
+ ///
+ /// This should be invoked as soon as possible after to cause a state change.
+ ///
+ void EndChange();
+ }
+}
diff --git a/osu.Game/Screens/Edit/LegacyEditorBeatmapPatcher.cs b/osu.Game/Screens/Edit/LegacyEditorBeatmapPatcher.cs
new file mode 100644
index 0000000000..17eba87076
--- /dev/null
+++ b/osu.Game/Screens/Edit/LegacyEditorBeatmapPatcher.cs
@@ -0,0 +1,107 @@
+// Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence.
+// See the LICENCE file in the repository root for full licence text.
+
+using System;
+using System.Collections.Generic;
+using System.IO;
+using System.Text;
+using DiffPlex;
+using osu.Framework.Audio.Track;
+using osu.Framework.Graphics.Textures;
+using osu.Game.Beatmaps;
+using osu.Game.IO;
+using Decoder = osu.Game.Beatmaps.Formats.Decoder;
+
+namespace osu.Game.Screens.Edit
+{
+ ///
+ /// Patches an based on the difference between two legacy (.osu) states.
+ ///
+ public class LegacyEditorBeatmapPatcher
+ {
+ private readonly EditorBeatmap editorBeatmap;
+
+ public LegacyEditorBeatmapPatcher(EditorBeatmap editorBeatmap)
+ {
+ this.editorBeatmap = editorBeatmap;
+ }
+
+ public void Patch(byte[] currentState, byte[] newState)
+ {
+ // Diff the beatmaps
+ var result = new Differ().CreateLineDiffs(readString(currentState), readString(newState), true, false);
+
+ // Find the index of [HitObject] sections. Lines changed prior to this index are ignored.
+ int oldHitObjectsIndex = Array.IndexOf(result.PiecesOld, "[HitObjects]");
+ int newHitObjectsIndex = Array.IndexOf(result.PiecesNew, "[HitObjects]");
+
+ var toRemove = new List();
+ var toAdd = new List();
+
+ foreach (var block in result.DiffBlocks)
+ {
+ // Removed hitobjects
+ for (int i = 0; i < block.DeleteCountA; i++)
+ {
+ int hoIndex = block.DeleteStartA + i - oldHitObjectsIndex - 1;
+
+ if (hoIndex < 0)
+ continue;
+
+ toRemove.Add(hoIndex);
+ }
+
+ // Added hitobjects
+ for (int i = 0; i < block.InsertCountB; i++)
+ {
+ int hoIndex = block.InsertStartB + i - newHitObjectsIndex - 1;
+
+ if (hoIndex < 0)
+ continue;
+
+ toAdd.Add(hoIndex);
+ }
+ }
+
+ // Make the removal indices are sorted so that iteration order doesn't get messed up post-removal.
+ toRemove.Sort();
+
+ // Apply the changes.
+ for (int i = toRemove.Count - 1; i >= 0; i--)
+ editorBeatmap.RemoveAt(toRemove[i]);
+
+ if (toAdd.Count > 0)
+ {
+ IBeatmap newBeatmap = readBeatmap(newState);
+ foreach (var i in toAdd)
+ editorBeatmap.Add(newBeatmap.HitObjects[i]);
+ }
+ }
+
+ private string readString(byte[] state) => Encoding.UTF8.GetString(state);
+
+ private IBeatmap readBeatmap(byte[] state)
+ {
+ using (var stream = new MemoryStream(state))
+ using (var reader = new LineBufferedReader(stream, true))
+ return new PassThroughWorkingBeatmap(Decoder.GetDecoder(reader).Decode(reader)).GetPlayableBeatmap(editorBeatmap.BeatmapInfo.Ruleset);
+ }
+
+ private class PassThroughWorkingBeatmap : WorkingBeatmap
+ {
+ private readonly IBeatmap beatmap;
+
+ public PassThroughWorkingBeatmap(IBeatmap beatmap)
+ : base(beatmap.BeatmapInfo, null)
+ {
+ this.beatmap = beatmap;
+ }
+
+ protected override IBeatmap GetBeatmap() => beatmap;
+
+ protected override Texture GetBackground() => throw new NotImplementedException();
+
+ protected override Track GetTrack() => throw new NotImplementedException();
+ }
+ }
+}
diff --git a/osu.Game/Screens/Multi/DrawableRoomPlaylistItem.cs b/osu.Game/Screens/Multi/DrawableRoomPlaylistItem.cs
index ed3f9af8e2..d7dcca9809 100644
--- a/osu.Game/Screens/Multi/DrawableRoomPlaylistItem.cs
+++ b/osu.Game/Screens/Multi/DrawableRoomPlaylistItem.cs
@@ -212,8 +212,8 @@ namespace osu.Game.Screens.Multi
private class PlaylistDownloadButton : PanelDownloadButton
{
- public PlaylistDownloadButton(BeatmapSetInfo beatmapSet, bool noVideo = false)
- : base(beatmapSet, noVideo)
+ public PlaylistDownloadButton(BeatmapSetInfo beatmapSet)
+ : base(beatmapSet)
{
Alpha = 0;
}
diff --git a/osu.Game/Screens/Play/HUD/FailingLayer.cs b/osu.Game/Screens/Play/HUD/FailingLayer.cs
new file mode 100644
index 0000000000..a49aa89a7c
--- /dev/null
+++ b/osu.Game/Screens/Play/HUD/FailingLayer.cs
@@ -0,0 +1,117 @@
+// Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence.
+// See the LICENCE file in the repository root for full licence text.
+
+using System;
+using osu.Framework.Allocation;
+using osu.Framework.Bindables;
+using osu.Framework.Extensions.Color4Extensions;
+using osu.Framework.Graphics;
+using osu.Framework.Graphics.Colour;
+using osu.Framework.Graphics.Containers;
+using osu.Framework.Graphics.Shapes;
+using osu.Framework.Utils;
+using osu.Game.Configuration;
+using osu.Game.Graphics;
+using osu.Game.Rulesets.Scoring;
+using osuTK.Graphics;
+
+namespace osu.Game.Screens.Play.HUD
+{
+ ///
+ /// An overlay layer on top of the playfield which fades to red when the current player health falls below a certain threshold defined by .
+ ///
+ public class FailingLayer : HealthDisplay
+ {
+ private const float max_alpha = 0.4f;
+ private const int fade_time = 400;
+ private const float gradient_size = 0.3f;
+
+ ///
+ /// The threshold under which the current player life should be considered low and the layer should start fading in.
+ ///
+ public double LowHealthThreshold = 0.20f;
+
+ private readonly Bindable enabled = new Bindable();
+ private readonly Container boxes;
+
+ private Bindable configEnabled;
+ private HealthProcessor healthProcessor;
+
+ public FailingLayer()
+ {
+ RelativeSizeAxes = Axes.Both;
+ Children = new Drawable[]
+ {
+ boxes = new Container
+ {
+ Alpha = 0,
+ Blending = BlendingParameters.Additive,
+ RelativeSizeAxes = Axes.Both,
+ Children = new Drawable[]
+ {
+ new Box
+ {
+ RelativeSizeAxes = Axes.Both,
+ Colour = ColourInfo.GradientVertical(Color4.White, Color4.White.Opacity(0)),
+ Height = gradient_size,
+ },
+ new Box
+ {
+ RelativeSizeAxes = Axes.Both,
+ Height = gradient_size,
+ Colour = ColourInfo.GradientVertical(Color4.White.Opacity(0), Color4.White),
+ Anchor = Anchor.BottomLeft,
+ Origin = Anchor.BottomLeft,
+ },
+ }
+ },
+ };
+ }
+
+ [BackgroundDependencyLoader]
+ private void load(OsuColour color, OsuConfigManager config)
+ {
+ boxes.Colour = color.Red;
+
+ configEnabled = config.GetBindable(OsuSetting.FadePlayfieldWhenHealthLow);
+ enabled.BindValueChanged(e => this.FadeTo(e.NewValue ? 1 : 0, fade_time, Easing.OutQuint), true);
+ }
+
+ protected override void LoadComplete()
+ {
+ base.LoadComplete();
+ updateBindings();
+ }
+
+ public override void BindHealthProcessor(HealthProcessor processor)
+ {
+ base.BindHealthProcessor(processor);
+
+ healthProcessor = processor;
+ updateBindings();
+ }
+
+ private void updateBindings()
+ {
+ if (LoadState < LoadState.Ready)
+ return;
+
+ enabled.UnbindBindings();
+
+ // Don't display ever if the ruleset is not using a draining health display.
+ if (healthProcessor is DrainingHealthProcessor)
+ enabled.BindTo(configEnabled);
+ else
+ enabled.Value = false;
+ }
+
+ protected override void Update()
+ {
+ double target = Math.Clamp(max_alpha * (1 - Current.Value / LowHealthThreshold), 0, max_alpha);
+
+ boxes.Alpha = (float)Interpolation.Lerp(boxes.Alpha, target, Clock.ElapsedFrameTime * 0.01f);
+
+ base.Update();
+ }
+ }
+}
diff --git a/osu.Game/Screens/Play/HUD/HealthDisplay.cs b/osu.Game/Screens/Play/HUD/HealthDisplay.cs
index 37038ad58c..edc9dedf24 100644
--- a/osu.Game/Screens/Play/HUD/HealthDisplay.cs
+++ b/osu.Game/Screens/Play/HUD/HealthDisplay.cs
@@ -3,15 +3,29 @@
using osu.Framework.Bindables;
using osu.Framework.Graphics.Containers;
+using osu.Game.Rulesets.Scoring;
+using osu.Game.Rulesets.UI;
namespace osu.Game.Screens.Play.HUD
{
+ ///
+ /// A container for components displaying the current player health.
+ /// Gets bound automatically to the when inserted to hierarchy.
+ ///
public abstract class HealthDisplay : Container
{
- public readonly BindableDouble Current = new BindableDouble
+ public readonly BindableDouble Current = new BindableDouble(1)
{
MinValue = 0,
MaxValue = 1
};
+
+ ///
+ /// Bind the tracked fields of to this health display.
+ ///
+ public virtual void BindHealthProcessor(HealthProcessor processor)
+ {
+ Current.BindTo(processor.Health);
+ }
}
}
diff --git a/osu.Game/Screens/Play/HUDOverlay.cs b/osu.Game/Screens/Play/HUDOverlay.cs
index e06f6d19c2..5114efd9a9 100644
--- a/osu.Game/Screens/Play/HUDOverlay.cs
+++ b/osu.Game/Screens/Play/HUDOverlay.cs
@@ -37,6 +37,7 @@ namespace osu.Game.Screens.Play
public readonly HitErrorDisplay HitErrorDisplay;
public readonly HoldForMenuButton HoldToQuit;
public readonly PlayerSettingsOverlay PlayerSettingsOverlay;
+ public readonly FailingLayer FailingLayer;
public Bindable ShowHealthbar = new Bindable(true);
@@ -75,6 +76,7 @@ namespace osu.Game.Screens.Play
Children = new Drawable[]
{
+ FailingLayer = CreateFailingLayer(),
visibilityContainer = new Container
{
RelativeSizeAxes = Axes.Both,
@@ -260,6 +262,8 @@ namespace osu.Game.Screens.Play
Margin = new MarginPadding { Top = 20 }
};
+ protected virtual FailingLayer CreateFailingLayer() => new FailingLayer();
+
protected virtual KeyCounterDisplay CreateKeyCounter() => new KeyCounterDisplay
{
Anchor = Anchor.BottomRight,
@@ -304,7 +308,8 @@ namespace osu.Game.Screens.Play
protected virtual void BindHealthProcessor(HealthProcessor processor)
{
- HealthDisplay?.Current.BindTo(processor.Health);
+ HealthDisplay?.BindHealthProcessor(processor);
+ FailingLayer?.BindHealthProcessor(processor);
}
}
}
diff --git a/osu.Game/Screens/Select/BeatmapCarousel.cs b/osu.Game/Screens/Select/BeatmapCarousel.cs
index e13511a02c..b5dfcadeaa 100644
--- a/osu.Game/Screens/Select/BeatmapCarousel.cs
+++ b/osu.Game/Screens/Select/BeatmapCarousel.cs
@@ -48,6 +48,11 @@ namespace osu.Game.Screens.Select
///
public BeatmapSetInfo SelectedBeatmapSet => selectedBeatmapSet?.BeatmapSet;
+ ///
+ /// A function to optionally decide on a recommended difficulty from a beatmap set.
+ ///
+ public Func, BeatmapInfo> GetRecommendedBeatmap;
+
private CarouselBeatmapSet selectedBeatmapSet;
///
@@ -116,6 +121,7 @@ namespace osu.Game.Screens.Select
private readonly Stack randomSelectedBeatmaps = new Stack();
protected List Items = new List();
+
private CarouselRoot root;
public BeatmapCarousel()
@@ -579,7 +585,10 @@ namespace osu.Game.Screens.Select
b.Metadata = beatmapSet.Metadata;
}
- var set = new CarouselBeatmapSet(beatmapSet);
+ var set = new CarouselBeatmapSet(beatmapSet)
+ {
+ GetRecommendedBeatmap = beatmaps => GetRecommendedBeatmap?.Invoke(beatmaps)
+ };
foreach (var c in set.Beatmaps)
{
diff --git a/osu.Game/Screens/Select/Carousel/CarouselBeatmapSet.cs b/osu.Game/Screens/Select/Carousel/CarouselBeatmapSet.cs
index 8e323c66e2..92ccfde14b 100644
--- a/osu.Game/Screens/Select/Carousel/CarouselBeatmapSet.cs
+++ b/osu.Game/Screens/Select/Carousel/CarouselBeatmapSet.cs
@@ -16,6 +16,8 @@ namespace osu.Game.Screens.Select.Carousel
public BeatmapSetInfo BeatmapSet;
+ public Func, BeatmapInfo> GetRecommendedBeatmap;
+
public CarouselBeatmapSet(BeatmapSetInfo beatmapSet)
{
BeatmapSet = beatmapSet ?? throw new ArgumentNullException(nameof(beatmapSet));
@@ -28,6 +30,17 @@ namespace osu.Game.Screens.Select.Carousel
protected override DrawableCarouselItem CreateDrawableRepresentation() => new DrawableCarouselBeatmapSet(this);
+ protected override CarouselItem GetNextToSelect()
+ {
+ if (LastSelected == null)
+ {
+ if (GetRecommendedBeatmap?.Invoke(Children.OfType().Where(b => !b.Filtered.Value).Select(b => b.Beatmap)) is BeatmapInfo recommended)
+ return Children.OfType().First(b => b.Beatmap == recommended);
+ }
+
+ return base.GetNextToSelect();
+ }
+
public override int CompareTo(FilterCriteria criteria, CarouselItem other)
{
if (!(other is CarouselBeatmapSet otherSet))
diff --git a/osu.Game/Screens/Select/Carousel/CarouselGroupEagerSelect.cs b/osu.Game/Screens/Select/Carousel/CarouselGroupEagerSelect.cs
index 6ce12f7b89..262bea9c71 100644
--- a/osu.Game/Screens/Select/Carousel/CarouselGroupEagerSelect.cs
+++ b/osu.Game/Screens/Select/Carousel/CarouselGroupEagerSelect.cs
@@ -90,11 +90,15 @@ namespace osu.Game.Screens.Select.Carousel
PerformSelection();
}
+ protected virtual CarouselItem GetNextToSelect()
+ {
+ return Children.Skip(lastSelectedIndex).FirstOrDefault(i => !i.Filtered.Value) ??
+ Children.Reverse().Skip(InternalChildren.Count - lastSelectedIndex).FirstOrDefault(i => !i.Filtered.Value);
+ }
+
protected virtual void PerformSelection()
{
- CarouselItem nextToSelect =
- Children.Skip(lastSelectedIndex).FirstOrDefault(i => !i.Filtered.Value) ??
- Children.Reverse().Skip(InternalChildren.Count - lastSelectedIndex).FirstOrDefault(i => !i.Filtered.Value);
+ CarouselItem nextToSelect = GetNextToSelect();
if (nextToSelect != null)
nextToSelect.State.Value = CarouselItemState.Selected;
diff --git a/osu.Game/Screens/Select/Carousel/DrawableCarouselBeatmap.cs b/osu.Game/Screens/Select/Carousel/DrawableCarouselBeatmap.cs
index 2520c70989..3e4798a812 100644
--- a/osu.Game/Screens/Select/Carousel/DrawableCarouselBeatmap.cs
+++ b/osu.Game/Screens/Select/Carousel/DrawableCarouselBeatmap.cs
@@ -49,12 +49,13 @@ namespace osu.Game.Screens.Select.Carousel
}
[BackgroundDependencyLoader(true)]
- private void load(SongSelect songSelect, BeatmapManager manager)
+ private void load(BeatmapManager manager, SongSelect songSelect)
{
if (songSelect != null)
{
startRequested = b => songSelect.FinaliseSelection(b);
- editRequested = songSelect.Edit;
+ if (songSelect.AllowEditing)
+ editRequested = songSelect.Edit;
}
if (manager != null)
@@ -187,15 +188,19 @@ namespace osu.Game.Screens.Select.Carousel
{
get
{
- List
public virtual bool AllowEditing => true;
- [Resolved(canBeNull: true)]
- private NotificationOverlay notificationOverlay { get; set; }
-
[Resolved]
private Bindable> selectedMods { get; set; }
@@ -81,6 +77,8 @@ namespace osu.Game.Screens.Select
protected BeatmapCarousel Carousel { get; private set; }
+ private DifficultyRecommender recommender;
+
private BeatmapInfoWedge beatmapInfoWedge;
private DialogOverlay dialogOverlay;
@@ -109,6 +107,7 @@ namespace osu.Game.Screens.Select
AddRangeInternal(new Drawable[]
{
+ recommender = new DifficultyRecommender(),
new ResetScrollContainer(() => Carousel.ScrollToSelected())
{
RelativeSizeAxes = Axes.Y,
@@ -156,6 +155,7 @@ namespace osu.Game.Screens.Select
RelativeSizeAxes = Axes.Both,
SelectionChanged = updateSelectedBeatmap,
BeatmapSetsChanged = carouselBeatmapsLoaded,
+ GetRecommendedBeatmap = recommender.GetRecommendedBeatmap,
},
}
},
@@ -325,10 +325,7 @@ namespace osu.Game.Screens.Select
public void Edit(BeatmapInfo beatmap = null)
{
if (!AllowEditing)
- {
- notificationOverlay?.Post(new SimpleNotification { Text = "Editing is not available from the current mode." });
- return;
- }
+ throw new InvalidOperationException($"Attempted to edit when {nameof(AllowEditing)} is disabled");
Beatmap.Value = beatmaps.GetWorkingBeatmap(beatmap ?? beatmapNoDebounce);
this.Push(new Editor());
diff --git a/osu.Game/Skinning/LegacyBeatmapSkin.cs b/osu.Game/Skinning/LegacyBeatmapSkin.cs
index 1190a330fe..21533e58cd 100644
--- a/osu.Game/Skinning/LegacyBeatmapSkin.cs
+++ b/osu.Game/Skinning/LegacyBeatmapSkin.cs
@@ -2,9 +2,12 @@
// See the LICENCE file in the repository root for full licence text.
using osu.Framework.Audio;
+using osu.Framework.Audio.Sample;
using osu.Framework.Bindables;
using osu.Framework.IO.Stores;
+using osu.Game.Audio;
using osu.Game.Beatmaps;
+using osu.Game.Rulesets.Objects.Legacy;
namespace osu.Game.Skinning
{
@@ -33,6 +36,17 @@ namespace osu.Game.Skinning
return base.GetConfig(lookup);
}
+ public override SampleChannel GetSample(ISampleInfo sampleInfo)
+ {
+ if (sampleInfo is ConvertHitObjectParser.LegacyHitSampleInfo legacy && legacy.CustomSampleBank == 0)
+ {
+ // When no custom sample bank is provided, always fall-back to the default samples.
+ return null;
+ }
+
+ return base.GetSample(sampleInfo);
+ }
+
private static SkinInfo createSkinInfo(BeatmapInfo beatmap) =>
new SkinInfo { Name = beatmap.ToString(), Creator = beatmap.Metadata.Author.ToString() };
}
diff --git a/osu.Game/Skinning/LegacySkinDecoder.cs b/osu.Game/Skinning/LegacySkinDecoder.cs
index 5d4b8de7ac..75b7ba28b9 100644
--- a/osu.Game/Skinning/LegacySkinDecoder.cs
+++ b/osu.Game/Skinning/LegacySkinDecoder.cs
@@ -44,6 +44,12 @@ namespace osu.Game.Skinning
}
break;
+
+ // osu!catch section only has colour settings
+ // so no harm in handling the entire section
+ case Section.CatchTheBeat:
+ HandleColours(skin, line);
+ return;
}
if (!string.IsNullOrEmpty(pair.Key))
diff --git a/osu.Game/Storyboards/Storyboard.cs b/osu.Game/Storyboards/Storyboard.cs
index a1ddafbacf..d13c874ee2 100644
--- a/osu.Game/Storyboards/Storyboard.cs
+++ b/osu.Game/Storyboards/Storyboard.cs
@@ -47,9 +47,6 @@ namespace osu.Game.Storyboards
if (backgroundPath == null)
return false;
- if (GetLayer("Video").Elements.Any())
- return true;
-
return GetLayer("Background").Elements.Any(e => e.Path.ToLowerInvariant() == backgroundPath);
}
}
diff --git a/osu.Game/Tests/Beatmaps/TestWorkingBeatmap.cs b/osu.Game/Tests/Beatmaps/TestWorkingBeatmap.cs
index 6db34af20c..8f8afb87d4 100644
--- a/osu.Game/Tests/Beatmaps/TestWorkingBeatmap.cs
+++ b/osu.Game/Tests/Beatmaps/TestWorkingBeatmap.cs
@@ -1,6 +1,7 @@
// Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence.
// See the LICENCE file in the repository root for full licence text.
+using osu.Framework.Audio;
using osu.Framework.Audio.Track;
using osu.Framework.Graphics.Textures;
using osu.Game.Beatmaps;
@@ -18,8 +19,9 @@ namespace osu.Game.Tests.Beatmaps
///
/// The beatmap.
/// An optional storyboard.
- public TestWorkingBeatmap(IBeatmap beatmap, Storyboard storyboard = null)
- : base(beatmap.BeatmapInfo, null)
+ /// The .
+ public TestWorkingBeatmap(IBeatmap beatmap, Storyboard storyboard = null, AudioManager audioManager = null)
+ : base(beatmap.BeatmapInfo, audioManager)
{
this.beatmap = beatmap;
this.storyboard = storyboard;
diff --git a/osu.Game/Tests/Visual/OsuTestScene.cs b/osu.Game/Tests/Visual/OsuTestScene.cs
index d1d8059cb1..5dc8714c07 100644
--- a/osu.Game/Tests/Visual/OsuTestScene.cs
+++ b/osu.Game/Tests/Visual/OsuTestScene.cs
@@ -179,7 +179,7 @@ namespace osu.Game.Tests.Visual
/// Audio manager. Required if a reference clock isn't provided.
/// The length of the returned virtual track.
public ClockBackedTestWorkingBeatmap(IBeatmap beatmap, Storyboard storyboard, IFrameBasedClock referenceClock, AudioManager audio, double length = 60000)
- : base(beatmap, storyboard)
+ : base(beatmap, storyboard, audio)
{
if (referenceClock != null)
{
diff --git a/osu.Game/Tests/Visual/PlacementBlueprintTestScene.cs b/osu.Game/Tests/Visual/PlacementBlueprintTestScene.cs
index ce95dfa62f..dc67d28f63 100644
--- a/osu.Game/Tests/Visual/PlacementBlueprintTestScene.cs
+++ b/osu.Game/Tests/Visual/PlacementBlueprintTestScene.cs
@@ -4,8 +4,6 @@
using osu.Framework.Allocation;
using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers;
-using osu.Framework.Input;
-using osu.Framework.Input.Events;
using osu.Framework.Timing;
using osu.Game.Rulesets.Edit;
using osu.Game.Rulesets.Objects;
@@ -15,13 +13,11 @@ using osu.Game.Screens.Edit.Compose;
namespace osu.Game.Tests.Visual
{
[Cached(Type = typeof(IPlacementHandler))]
- public abstract class PlacementBlueprintTestScene : OsuTestScene, IPlacementHandler
+ public abstract class PlacementBlueprintTestScene : OsuManualInputManagerTestScene, IPlacementHandler
{
- protected Container HitObjectContainer;
+ protected readonly Container HitObjectContainer;
private PlacementBlueprint currentBlueprint;
- private InputManager inputManager;
-
protected PlacementBlueprintTestScene()
{
Add(HitObjectContainer = CreateHitObjectContainer().With(c => c.Clock = new FramedClock(new StopwatchClock())));
@@ -45,8 +41,7 @@ namespace osu.Game.Tests.Visual
{
base.LoadComplete();
- inputManager = GetContainingInputManager();
- Add(currentBlueprint = CreateBlueprint());
+ ResetPlacement();
}
public void BeginPlacement(HitObject hitObject)
@@ -58,7 +53,13 @@ namespace osu.Game.Tests.Visual
if (commit)
AddHitObject(CreateHitObject(hitObject));
- Remove(currentBlueprint);
+ ResetPlacement();
+ }
+
+ protected void ResetPlacement()
+ {
+ if (currentBlueprint != null)
+ Remove(currentBlueprint);
Add(currentBlueprint = CreateBlueprint());
}
@@ -66,10 +67,11 @@ namespace osu.Game.Tests.Visual
{
}
- protected override bool OnMouseMove(MouseMoveEvent e)
+ protected override void Update()
{
- currentBlueprint.UpdatePosition(e.ScreenSpaceMousePosition);
- return true;
+ base.Update();
+
+ currentBlueprint.UpdatePosition(InputManager.CurrentState.Mouse.Position);
}
public override void Add(Drawable drawable)
@@ -79,7 +81,7 @@ namespace osu.Game.Tests.Visual
if (drawable is PlacementBlueprint blueprint)
{
blueprint.Show();
- blueprint.UpdatePosition(inputManager.CurrentState.Mouse.Position);
+ blueprint.UpdatePosition(InputManager.CurrentState.Mouse.Position);
}
}
diff --git a/osu.Game/osu.Game.csproj b/osu.Game/osu.Game.csproj
index 7cf1272611..5facb04117 100644
--- a/osu.Game/osu.Game.csproj
+++ b/osu.Game/osu.Game.csproj
@@ -18,12 +18,13 @@
+
-
-
+
+
diff --git a/osu.iOS.props b/osu.iOS.props
index c58a431e80..dda1ee5c42 100644
--- a/osu.iOS.props
+++ b/osu.iOS.props
@@ -70,16 +70,17 @@
-
-
+
+
+
-
+