diff --git a/.idea/.idea.osu.Desktop/.idea/modules.xml b/.idea/.idea.osu.Desktop/.idea/modules.xml
index 366f172c30..fe63f5faf3 100644
--- a/.idea/.idea.osu.Desktop/.idea/modules.xml
+++ b/.idea/.idea.osu.Desktop/.idea/modules.xml
@@ -2,7 +2,6 @@
-
diff --git a/osu.Android.props b/osu.Android.props
index 493b1f5529..ff86ac6574 100644
--- a/osu.Android.props
+++ b/osu.Android.props
@@ -52,6 +52,6 @@
-
+
diff --git a/osu.Android/OsuGameActivity.cs b/osu.Android/OsuGameActivity.cs
index 2e5fa59d20..9839d16030 100644
--- a/osu.Android/OsuGameActivity.cs
+++ b/osu.Android/OsuGameActivity.cs
@@ -9,7 +9,7 @@ using osu.Framework.Android;
namespace osu.Android
{
- [Activity(Theme = "@android:style/Theme.NoTitleBar", MainLauncher = true, ScreenOrientation = ScreenOrientation.FullSensor, SupportsPictureInPicture = false, ConfigurationChanges = ConfigChanges.Orientation | ConfigChanges.ScreenSize, HardwareAccelerated = true)]
+ [Activity(Theme = "@android:style/Theme.NoTitleBar", MainLauncher = true, ScreenOrientation = ScreenOrientation.FullSensor, SupportsPictureInPicture = false, ConfigurationChanges = ConfigChanges.Orientation | ConfigChanges.ScreenSize, HardwareAccelerated = false)]
public class OsuGameActivity : AndroidGameActivity
{
protected override Framework.Game CreateGame() => new OsuGameAndroid();
diff --git a/osu.Game.Rulesets.Catch.Tests/CatchBeatmapConversionTest.cs b/osu.Game.Rulesets.Catch.Tests/CatchBeatmapConversionTest.cs
index f4749be370..df54df7b01 100644
--- a/osu.Game.Rulesets.Catch.Tests/CatchBeatmapConversionTest.cs
+++ b/osu.Game.Rulesets.Catch.Tests/CatchBeatmapConversionTest.cs
@@ -8,7 +8,6 @@ using NUnit.Framework;
using osu.Framework.Utils;
using osu.Game.Rulesets.Catch.Mods;
using osu.Game.Rulesets.Catch.Objects;
-using osu.Game.Rulesets.Catch.UI;
using osu.Game.Rulesets.Objects;
using osu.Game.Tests.Beatmaps;
@@ -83,7 +82,7 @@ namespace osu.Game.Rulesets.Catch.Tests
public float Position
{
- get => HitObject?.X * CatchPlayfield.BASE_WIDTH ?? position;
+ get => HitObject?.X ?? position;
set => position = value;
}
diff --git a/osu.Game.Rulesets.Catch.Tests/TestSceneAutoJuiceStream.cs b/osu.Game.Rulesets.Catch.Tests/TestSceneAutoJuiceStream.cs
index 7c2304694f..d6bba3d55e 100644
--- a/osu.Game.Rulesets.Catch.Tests/TestSceneAutoJuiceStream.cs
+++ b/osu.Game.Rulesets.Catch.Tests/TestSceneAutoJuiceStream.cs
@@ -27,15 +27,15 @@ namespace osu.Game.Rulesets.Catch.Tests
for (int i = 0; i < 100; i++)
{
- float width = (i % 10 + 1) / 20f;
+ float width = (i % 10 + 1) / 20f * CatchPlayfield.WIDTH;
beatmap.HitObjects.Add(new JuiceStream
{
- X = 0.5f - width / 2,
+ X = CatchPlayfield.CENTER_X - width / 2,
Path = new SliderPath(PathType.Linear, new[]
{
Vector2.Zero,
- new Vector2(width * CatchPlayfield.BASE_WIDTH, 0)
+ new Vector2(width, 0)
}),
StartTime = i * 2000,
NewCombo = i % 8 == 0
diff --git a/osu.Game.Rulesets.Catch.Tests/TestSceneCatchStacker.cs b/osu.Game.Rulesets.Catch.Tests/TestSceneCatchStacker.cs
index 44672b6526..1ff31697b8 100644
--- a/osu.Game.Rulesets.Catch.Tests/TestSceneCatchStacker.cs
+++ b/osu.Game.Rulesets.Catch.Tests/TestSceneCatchStacker.cs
@@ -4,6 +4,7 @@
using NUnit.Framework;
using osu.Game.Beatmaps;
using osu.Game.Rulesets.Catch.Objects;
+using osu.Game.Rulesets.Catch.UI;
namespace osu.Game.Rulesets.Catch.Tests
{
@@ -22,7 +23,14 @@ namespace osu.Game.Rulesets.Catch.Tests
};
for (int i = 0; i < 512; i++)
- beatmap.HitObjects.Add(new Fruit { X = 0.5f + i / 2048f * (i % 10 - 5), StartTime = i * 100, NewCombo = i % 8 == 0 });
+ {
+ beatmap.HitObjects.Add(new Fruit
+ {
+ X = (0.5f + i / 2048f * (i % 10 - 5)) * CatchPlayfield.WIDTH,
+ StartTime = i * 100,
+ NewCombo = i % 8 == 0
+ });
+ }
return beatmap;
}
diff --git a/osu.Game.Rulesets.Catch.Tests/TestSceneCatcherArea.cs b/osu.Game.Rulesets.Catch.Tests/TestSceneCatcherArea.cs
index 2b30edb70b..fbb22a8498 100644
--- a/osu.Game.Rulesets.Catch.Tests/TestSceneCatcherArea.cs
+++ b/osu.Game.Rulesets.Catch.Tests/TestSceneCatcherArea.cs
@@ -76,8 +76,8 @@ namespace osu.Game.Rulesets.Catch.Tests
RelativeSizeAxes = Axes.Both,
Child = new TestCatcherArea(new BeatmapDifficulty { CircleSize = size })
{
- Anchor = Anchor.CentreLeft,
- Origin = Anchor.TopLeft,
+ Anchor = Anchor.Centre,
+ Origin = Anchor.TopCentre,
CreateDrawableRepresentation = ((DrawableRuleset)catchRuleset.CreateInstance().CreateDrawableRulesetWith(new CatchBeatmap())).CreateDrawableRepresentation
},
});
diff --git a/osu.Game.Rulesets.Catch.Tests/TestSceneDrawableHitObjects.cs b/osu.Game.Rulesets.Catch.Tests/TestSceneDrawableHitObjects.cs
index a7094c00be..d35f828e28 100644
--- a/osu.Game.Rulesets.Catch.Tests/TestSceneDrawableHitObjects.cs
+++ b/osu.Game.Rulesets.Catch.Tests/TestSceneDrawableHitObjects.cs
@@ -158,8 +158,8 @@ namespace osu.Game.Rulesets.Catch.Tests
private float getXCoords(bool hit)
{
- const float x_offset = 0.2f;
- float xCoords = drawableRuleset.Playfield.Width / 2;
+ const float x_offset = 0.2f * CatchPlayfield.WIDTH;
+ float xCoords = CatchPlayfield.CENTER_X;
if (drawableRuleset.Playfield is CatchPlayfield catchPlayfield)
catchPlayfield.CatcherArea.MovableCatcher.X = xCoords - x_offset;
diff --git a/osu.Game.Rulesets.Catch.Tests/TestSceneHyperDash.cs b/osu.Game.Rulesets.Catch.Tests/TestSceneHyperDash.cs
index a0dcb86d57..ad24adf352 100644
--- a/osu.Game.Rulesets.Catch.Tests/TestSceneHyperDash.cs
+++ b/osu.Game.Rulesets.Catch.Tests/TestSceneHyperDash.cs
@@ -47,13 +47,13 @@ namespace osu.Game.Rulesets.Catch.Tests
};
// Should produce a hyper-dash (edge case test)
- beatmap.HitObjects.Add(new Fruit { StartTime = 1816, X = 56 / 512f, NewCombo = true });
- beatmap.HitObjects.Add(new Fruit { StartTime = 2008, X = 308 / 512f, NewCombo = true });
+ beatmap.HitObjects.Add(new Fruit { StartTime = 1816, X = 56, NewCombo = true });
+ beatmap.HitObjects.Add(new Fruit { StartTime = 2008, X = 308, NewCombo = true });
double startTime = 3000;
- const float left_x = 0.02f;
- const float right_x = 0.98f;
+ const float left_x = 0.02f * CatchPlayfield.WIDTH;
+ const float right_x = 0.98f * CatchPlayfield.WIDTH;
createObjects(() => new Fruit { X = left_x });
createObjects(() => new TestJuiceStream(right_x), 1);
diff --git a/osu.Game.Rulesets.Catch.Tests/TestSceneJuiceStream.cs b/osu.Game.Rulesets.Catch.Tests/TestSceneJuiceStream.cs
index ffcf61a4bf..269e783899 100644
--- a/osu.Game.Rulesets.Catch.Tests/TestSceneJuiceStream.cs
+++ b/osu.Game.Rulesets.Catch.Tests/TestSceneJuiceStream.cs
@@ -5,6 +5,7 @@ using System.Collections.Generic;
using NUnit.Framework;
using osu.Game.Beatmaps;
using osu.Game.Rulesets.Catch.Objects;
+using osu.Game.Rulesets.Catch.UI;
using osu.Game.Rulesets.Objects;
using osu.Game.Rulesets.Objects.Types;
using osuTK;
@@ -30,7 +31,7 @@ namespace osu.Game.Rulesets.Catch.Tests
{
new JuiceStream
{
- X = 0.5f,
+ X = CatchPlayfield.CENTER_X,
Path = new SliderPath(PathType.Linear, new[]
{
Vector2.Zero,
@@ -40,7 +41,7 @@ namespace osu.Game.Rulesets.Catch.Tests
},
new Banana
{
- X = 0.5f,
+ X = CatchPlayfield.CENTER_X,
StartTime = 1000,
NewCombo = true
}
diff --git a/osu.Game.Rulesets.Catch/Beatmaps/CatchBeatmapConverter.cs b/osu.Game.Rulesets.Catch/Beatmaps/CatchBeatmapConverter.cs
index 0de2060e2d..145a40f5f5 100644
--- a/osu.Game.Rulesets.Catch/Beatmaps/CatchBeatmapConverter.cs
+++ b/osu.Game.Rulesets.Catch/Beatmaps/CatchBeatmapConverter.cs
@@ -5,7 +5,6 @@ using osu.Game.Beatmaps;
using osu.Game.Rulesets.Catch.Objects;
using System.Collections.Generic;
using System.Linq;
-using osu.Game.Rulesets.Catch.UI;
using osu.Game.Rulesets.Objects.Types;
using osu.Game.Rulesets.Objects;
using osu.Framework.Extensions.IEnumerableExtensions;
@@ -36,7 +35,7 @@ namespace osu.Game.Rulesets.Catch.Beatmaps
Path = curveData.Path,
NodeSamples = curveData.NodeSamples,
RepeatCount = curveData.RepeatCount,
- X = (positionData?.X ?? 0) / CatchPlayfield.BASE_WIDTH,
+ X = positionData?.X ?? 0,
NewCombo = comboData?.NewCombo ?? false,
ComboOffset = comboData?.ComboOffset ?? 0,
LegacyLastTickOffset = (obj as IHasLegacyLastTickOffset)?.LegacyLastTickOffset ?? 0
@@ -59,7 +58,7 @@ namespace osu.Game.Rulesets.Catch.Beatmaps
Samples = obj.Samples,
NewCombo = comboData?.NewCombo ?? false,
ComboOffset = comboData?.ComboOffset ?? 0,
- X = (positionData?.X ?? 0) / CatchPlayfield.BASE_WIDTH
+ X = positionData?.X ?? 0
}.Yield();
}
}
diff --git a/osu.Game.Rulesets.Catch/Beatmaps/CatchBeatmapProcessor.cs b/osu.Game.Rulesets.Catch/Beatmaps/CatchBeatmapProcessor.cs
index 7c81bcdf0c..bb14988414 100644
--- a/osu.Game.Rulesets.Catch/Beatmaps/CatchBeatmapProcessor.cs
+++ b/osu.Game.Rulesets.Catch/Beatmaps/CatchBeatmapProcessor.cs
@@ -65,7 +65,7 @@ namespace osu.Game.Rulesets.Catch.Beatmaps
case BananaShower bananaShower:
foreach (var banana in bananaShower.NestedHitObjects.OfType())
{
- banana.XOffset = (float)rng.NextDouble();
+ banana.XOffset = (float)(rng.NextDouble() * CatchPlayfield.WIDTH);
rng.Next(); // osu!stable retrieved a random banana type
rng.Next(); // osu!stable retrieved a random banana rotation
rng.Next(); // osu!stable retrieved a random banana colour
@@ -75,7 +75,7 @@ namespace osu.Game.Rulesets.Catch.Beatmaps
case JuiceStream juiceStream:
// Todo: BUG!! Stable used the last control point as the final position of the path, but it should use the computed path instead.
- lastPosition = juiceStream.X + juiceStream.Path.ControlPoints[^1].Position.Value.X / CatchPlayfield.BASE_WIDTH;
+ lastPosition = juiceStream.X + juiceStream.Path.ControlPoints[^1].Position.Value.X;
// Todo: BUG!! Stable attempted to use the end time of the stream, but referenced it too early in execution and used the start time instead.
lastStartTime = juiceStream.StartTime;
@@ -86,7 +86,7 @@ namespace osu.Game.Rulesets.Catch.Beatmaps
catchObject.XOffset = 0;
if (catchObject is TinyDroplet)
- catchObject.XOffset = Math.Clamp(rng.Next(-20, 20) / CatchPlayfield.BASE_WIDTH, -catchObject.X, 1 - catchObject.X);
+ catchObject.XOffset = Math.Clamp(rng.Next(-20, 20), -catchObject.X, CatchPlayfield.WIDTH - catchObject.X);
else if (catchObject is Droplet)
rng.Next(); // osu!stable retrieved a random droplet rotation
}
@@ -131,7 +131,7 @@ namespace osu.Game.Rulesets.Catch.Beatmaps
}
// ReSharper disable once PossibleLossOfFraction
- if (Math.Abs(positionDiff * CatchPlayfield.BASE_WIDTH) < timeDiff / 3)
+ if (Math.Abs(positionDiff) < timeDiff / 3)
applyOffset(ref offsetPosition, positionDiff);
hitObject.XOffset = offsetPosition - hitObject.X;
@@ -149,12 +149,12 @@ namespace osu.Game.Rulesets.Catch.Beatmaps
private static void applyRandomOffset(ref float position, double maxOffset, FastRandom rng)
{
bool right = rng.NextBool();
- float rand = Math.Min(20, (float)rng.Next(0, Math.Max(0, maxOffset))) / CatchPlayfield.BASE_WIDTH;
+ float rand = Math.Min(20, (float)rng.Next(0, Math.Max(0, maxOffset)));
if (right)
{
// Clamp to the right bound
- if (position + rand <= 1)
+ if (position + rand <= CatchPlayfield.WIDTH)
position += rand;
else
position -= rand;
@@ -211,7 +211,7 @@ namespace osu.Game.Rulesets.Catch.Beatmaps
objectWithDroplets.Sort((h1, h2) => h1.StartTime.CompareTo(h2.StartTime));
- double halfCatcherWidth = CatcherArea.GetCatcherSize(beatmap.BeatmapInfo.BaseDifficulty) / 2;
+ double halfCatcherWidth = Catcher.CalculateCatchWidth(beatmap.BeatmapInfo.BaseDifficulty) / 2;
int lastDirection = 0;
double lastExcess = halfCatcherWidth;
diff --git a/osu.Game.Rulesets.Catch/Difficulty/Preprocessing/CatchDifficultyHitObject.cs b/osu.Game.Rulesets.Catch/Difficulty/Preprocessing/CatchDifficultyHitObject.cs
index 360af1a8c9..3e21b8fbaf 100644
--- a/osu.Game.Rulesets.Catch/Difficulty/Preprocessing/CatchDifficultyHitObject.cs
+++ b/osu.Game.Rulesets.Catch/Difficulty/Preprocessing/CatchDifficultyHitObject.cs
@@ -3,7 +3,6 @@
using System;
using osu.Game.Rulesets.Catch.Objects;
-using osu.Game.Rulesets.Catch.UI;
using osu.Game.Rulesets.Difficulty.Preprocessing;
using osu.Game.Rulesets.Objects;
@@ -33,8 +32,8 @@ namespace osu.Game.Rulesets.Catch.Difficulty.Preprocessing
// We will scale everything by this factor, so we can assume a uniform CircleSize among beatmaps.
var scalingFactor = normalized_hitobject_radius / halfCatcherWidth;
- NormalizedPosition = BaseObject.X * CatchPlayfield.BASE_WIDTH * scalingFactor;
- LastNormalizedPosition = LastObject.X * CatchPlayfield.BASE_WIDTH * scalingFactor;
+ NormalizedPosition = BaseObject.X * scalingFactor;
+ LastNormalizedPosition = LastObject.X * scalingFactor;
// Every strain interval is hard capped at the equivalent of 375 BPM streaming speed as a safety measure
StrainTime = Math.Max(40, DeltaTime);
diff --git a/osu.Game.Rulesets.Catch/Difficulty/Skills/Movement.cs b/osu.Game.Rulesets.Catch/Difficulty/Skills/Movement.cs
index 918ed77683..e679231638 100644
--- a/osu.Game.Rulesets.Catch/Difficulty/Skills/Movement.cs
+++ b/osu.Game.Rulesets.Catch/Difficulty/Skills/Movement.cs
@@ -3,7 +3,6 @@
using System;
using osu.Game.Rulesets.Catch.Difficulty.Preprocessing;
-using osu.Game.Rulesets.Catch.UI;
using osu.Game.Rulesets.Difficulty.Preprocessing;
using osu.Game.Rulesets.Difficulty.Skills;
@@ -68,7 +67,7 @@ namespace osu.Game.Rulesets.Catch.Difficulty.Skills
}
// Bonus for edge dashes.
- if (catchCurrent.LastObject.DistanceToHyperDash <= 20.0f / CatchPlayfield.BASE_WIDTH)
+ if (catchCurrent.LastObject.DistanceToHyperDash <= 20.0f)
{
if (!catchCurrent.LastObject.HyperDash)
edgeDashBonus += 5.7;
@@ -78,7 +77,7 @@ namespace osu.Game.Rulesets.Catch.Difficulty.Skills
playerPosition = catchCurrent.NormalizedPosition;
}
- distanceAddition *= 1.0 + edgeDashBonus * ((20 - catchCurrent.LastObject.DistanceToHyperDash * CatchPlayfield.BASE_WIDTH) / 20) * Math.Pow((Math.Min(catchCurrent.StrainTime * catchCurrent.ClockRate, 265) / 265), 1.5); // Edge Dashes are easier at lower ms values
+ distanceAddition *= 1.0 + edgeDashBonus * ((20 - catchCurrent.LastObject.DistanceToHyperDash) / 20) * Math.Pow((Math.Min(catchCurrent.StrainTime * catchCurrent.ClockRate, 265) / 265), 1.5); // Edge Dashes are easier at lower ms values
}
lastPlayerPosition = playerPosition;
diff --git a/osu.Game.Rulesets.Catch/Objects/CatchHitObject.cs b/osu.Game.Rulesets.Catch/Objects/CatchHitObject.cs
index f3b566f340..04932ecdbb 100644
--- a/osu.Game.Rulesets.Catch/Objects/CatchHitObject.cs
+++ b/osu.Game.Rulesets.Catch/Objects/CatchHitObject.cs
@@ -5,6 +5,7 @@ using osu.Framework.Bindables;
using osu.Game.Beatmaps;
using osu.Game.Beatmaps.ControlPoints;
using osu.Game.Rulesets.Catch.Beatmaps;
+using osu.Game.Rulesets.Catch.UI;
using osu.Game.Rulesets.Objects;
using osu.Game.Rulesets.Objects.Types;
using osu.Game.Rulesets.Scoring;
@@ -17,6 +18,9 @@ namespace osu.Game.Rulesets.Catch.Objects
private float x;
+ ///
+ /// The horizontal position of the fruit between 0 and .
+ ///
public float X
{
get => x + XOffset;
diff --git a/osu.Game.Rulesets.Catch/Objects/Drawables/DrawableCatchHitObject.cs b/osu.Game.Rulesets.Catch/Objects/Drawables/DrawableCatchHitObject.cs
index b12cdd4ccb..c6345a9df7 100644
--- a/osu.Game.Rulesets.Catch/Objects/Drawables/DrawableCatchHitObject.cs
+++ b/osu.Game.Rulesets.Catch/Objects/Drawables/DrawableCatchHitObject.cs
@@ -9,6 +9,7 @@ using osu.Framework.Graphics.Containers;
using osu.Game.Rulesets.Objects;
using osu.Game.Rulesets.Objects.Drawables;
using osu.Game.Rulesets.Scoring;
+using osu.Game.Rulesets.Catch.UI;
using osuTK;
using osuTK.Graphics;
@@ -70,12 +71,11 @@ namespace osu.Game.Rulesets.Catch.Objects.Drawables
public float DisplayRadius => DrawSize.X / 2 * Scale.X * HitObject.Scale;
- protected override float SamplePlaybackPosition => HitObject.X;
+ protected override float SamplePlaybackPosition => HitObject.X / CatchPlayfield.WIDTH;
protected DrawableCatchHitObject(CatchHitObject hitObject)
: base(hitObject)
{
- RelativePositionAxes = Axes.X;
X = hitObject.X;
}
diff --git a/osu.Game.Rulesets.Catch/Objects/JuiceStream.cs b/osu.Game.Rulesets.Catch/Objects/JuiceStream.cs
index 2c96ee2b19..6b8b70ed54 100644
--- a/osu.Game.Rulesets.Catch/Objects/JuiceStream.cs
+++ b/osu.Game.Rulesets.Catch/Objects/JuiceStream.cs
@@ -7,7 +7,6 @@ using System.Threading;
using osu.Game.Audio;
using osu.Game.Beatmaps;
using osu.Game.Beatmaps.ControlPoints;
-using osu.Game.Rulesets.Catch.UI;
using osu.Game.Rulesets.Judgements;
using osu.Game.Rulesets.Objects;
using osu.Game.Rulesets.Objects.Types;
@@ -80,7 +79,7 @@ namespace osu.Game.Rulesets.Catch.Objects
{
StartTime = t + lastEvent.Value.Time,
X = X + Path.PositionAt(
- lastEvent.Value.PathProgress + (t / sinceLastTick) * (e.PathProgress - lastEvent.Value.PathProgress)).X / CatchPlayfield.BASE_WIDTH,
+ lastEvent.Value.PathProgress + (t / sinceLastTick) * (e.PathProgress - lastEvent.Value.PathProgress)).X,
});
}
}
@@ -97,7 +96,7 @@ namespace osu.Game.Rulesets.Catch.Objects
{
Samples = dropletSamples,
StartTime = e.Time,
- X = X + Path.PositionAt(e.PathProgress).X / CatchPlayfield.BASE_WIDTH,
+ X = X + Path.PositionAt(e.PathProgress).X,
});
break;
@@ -108,14 +107,14 @@ namespace osu.Game.Rulesets.Catch.Objects
{
Samples = Samples,
StartTime = e.Time,
- X = X + Path.PositionAt(e.PathProgress).X / CatchPlayfield.BASE_WIDTH,
+ X = X + Path.PositionAt(e.PathProgress).X,
});
break;
}
}
}
- public float EndX => X + this.CurvePositionAt(1).X / CatchPlayfield.BASE_WIDTH;
+ public float EndX => X + this.CurvePositionAt(1).X;
public double Duration
{
diff --git a/osu.Game.Rulesets.Catch/Replays/CatchAutoGenerator.cs b/osu.Game.Rulesets.Catch/Replays/CatchAutoGenerator.cs
index 7a33cb0577..5d11c574b1 100644
--- a/osu.Game.Rulesets.Catch/Replays/CatchAutoGenerator.cs
+++ b/osu.Game.Rulesets.Catch/Replays/CatchAutoGenerator.cs
@@ -34,7 +34,7 @@ namespace osu.Game.Rulesets.Catch.Replays
// todo: add support for HT DT
const double dash_speed = Catcher.BASE_SPEED;
const double movement_speed = dash_speed / 2;
- float lastPosition = 0.5f;
+ float lastPosition = CatchPlayfield.CENTER_X;
double lastTime = 0;
void moveToNext(CatchHitObject h)
@@ -51,7 +51,7 @@ namespace osu.Game.Rulesets.Catch.Replays
bool impossibleJump = speedRequired > movement_speed * 2;
// todo: get correct catcher size, based on difficulty CS.
- const float catcher_width_half = CatcherArea.CATCHER_SIZE / CatchPlayfield.BASE_WIDTH * 0.3f * 0.5f;
+ const float catcher_width_half = CatcherArea.CATCHER_SIZE * 0.3f * 0.5f;
if (lastPosition - catcher_width_half < h.X && lastPosition + catcher_width_half > h.X)
{
diff --git a/osu.Game.Rulesets.Catch/Replays/CatchReplayFrame.cs b/osu.Game.Rulesets.Catch/Replays/CatchReplayFrame.cs
index 9dab3ed630..7efd832f62 100644
--- a/osu.Game.Rulesets.Catch/Replays/CatchReplayFrame.cs
+++ b/osu.Game.Rulesets.Catch/Replays/CatchReplayFrame.cs
@@ -4,7 +4,6 @@
using System.Collections.Generic;
using osu.Game.Beatmaps;
using osu.Game.Replays.Legacy;
-using osu.Game.Rulesets.Catch.UI;
using osu.Game.Rulesets.Replays;
using osu.Game.Rulesets.Replays.Types;
@@ -41,7 +40,7 @@ namespace osu.Game.Rulesets.Catch.Replays
public void FromLegacy(LegacyReplayFrame currentFrame, IBeatmap beatmap, ReplayFrame lastFrame = null)
{
- Position = currentFrame.Position.X / CatchPlayfield.BASE_WIDTH;
+ Position = currentFrame.Position.X;
Dashing = currentFrame.ButtonState == ReplayButtonState.Left1;
if (Dashing)
@@ -63,7 +62,7 @@ namespace osu.Game.Rulesets.Catch.Replays
if (Actions.Contains(CatchAction.Dash)) state |= ReplayButtonState.Left1;
- return new LegacyReplayFrame(Time, Position * CatchPlayfield.BASE_WIDTH, null, state);
+ return new LegacyReplayFrame(Time, Position, null, state);
}
}
}
diff --git a/osu.Game.Rulesets.Catch/UI/CatchPlayfield.cs b/osu.Game.Rulesets.Catch/UI/CatchPlayfield.cs
index 2319c5ac1f..d034f3c7d4 100644
--- a/osu.Game.Rulesets.Catch/UI/CatchPlayfield.cs
+++ b/osu.Game.Rulesets.Catch/UI/CatchPlayfield.cs
@@ -16,7 +16,16 @@ namespace osu.Game.Rulesets.Catch.UI
{
public class CatchPlayfield : ScrollingPlayfield
{
- public const float BASE_WIDTH = 512;
+ ///
+ /// The width of the playfield.
+ /// The horizontal movement of the catcher is confined in the area of this width.
+ ///
+ public const float WIDTH = 512;
+
+ ///
+ /// The center position of the playfield.
+ ///
+ public const float CENTER_X = WIDTH / 2;
internal readonly CatcherArea CatcherArea;
diff --git a/osu.Game.Rulesets.Catch/UI/CatchPlayfieldAdjustmentContainer.cs b/osu.Game.Rulesets.Catch/UI/CatchPlayfieldAdjustmentContainer.cs
index b8d3dc9017..8ee23461ba 100644
--- a/osu.Game.Rulesets.Catch/UI/CatchPlayfieldAdjustmentContainer.cs
+++ b/osu.Game.Rulesets.Catch/UI/CatchPlayfieldAdjustmentContainer.cs
@@ -40,7 +40,7 @@ namespace osu.Game.Rulesets.Catch.UI
{
base.Update();
- Scale = new Vector2(Parent.ChildSize.X / CatchPlayfield.BASE_WIDTH);
+ Scale = new Vector2(Parent.ChildSize.X / CatchPlayfield.WIDTH);
Size = Vector2.Divide(Vector2.One, Scale);
}
}
diff --git a/osu.Game.Rulesets.Catch/UI/Catcher.cs b/osu.Game.Rulesets.Catch/UI/Catcher.cs
index 9cce46d730..82cbbefcca 100644
--- a/osu.Game.Rulesets.Catch/UI/Catcher.cs
+++ b/osu.Game.Rulesets.Catch/UI/Catcher.cs
@@ -42,7 +42,7 @@ namespace osu.Game.Rulesets.Catch.UI
///
/// The relative space to cover in 1 millisecond. based on 1 game pixel per millisecond as in osu-stable.
///
- public const double BASE_SPEED = 1.0 / 512;
+ public const double BASE_SPEED = 1.0;
public Container ExplodingFruitTarget;
@@ -104,9 +104,6 @@ namespace osu.Game.Rulesets.Catch.UI
{
this.trailsTarget = trailsTarget;
- RelativePositionAxes = Axes.X;
- X = 0.5f;
-
Origin = Anchor.TopCentre;
Size = new Vector2(CatcherArea.CATCHER_SIZE);
@@ -209,8 +206,8 @@ namespace osu.Game.Rulesets.Catch.UI
var halfCatchWidth = catchWidth * 0.5f;
// this stuff wil disappear once we move fruit to non-relative coordinate space in the future.
- var catchObjectPosition = fruit.X * CatchPlayfield.BASE_WIDTH;
- var catcherPosition = Position.X * CatchPlayfield.BASE_WIDTH;
+ var catchObjectPosition = fruit.X;
+ var catcherPosition = Position.X;
var validCatch =
catchObjectPosition >= catcherPosition - halfCatchWidth &&
@@ -224,7 +221,7 @@ namespace osu.Game.Rulesets.Catch.UI
{
var target = fruit.HyperDashTarget;
var timeDifference = target.StartTime - fruit.StartTime;
- double positionDifference = target.X * CatchPlayfield.BASE_WIDTH - catcherPosition;
+ double positionDifference = target.X - catcherPosition;
var velocity = positionDifference / Math.Max(1.0, timeDifference - 1000.0 / 60.0);
SetHyperDashState(Math.Abs(velocity), target.X);
@@ -331,7 +328,7 @@ namespace osu.Game.Rulesets.Catch.UI
public void UpdatePosition(float position)
{
- position = Math.Clamp(position, 0, 1);
+ position = Math.Clamp(position, 0, CatchPlayfield.WIDTH);
if (position == X)
return;
diff --git a/osu.Game.Rulesets.Catch/UI/CatcherArea.cs b/osu.Game.Rulesets.Catch/UI/CatcherArea.cs
index 37d177b936..bf1ac5bc0e 100644
--- a/osu.Game.Rulesets.Catch/UI/CatcherArea.cs
+++ b/osu.Game.Rulesets.Catch/UI/CatcherArea.cs
@@ -31,14 +31,8 @@ namespace osu.Game.Rulesets.Catch.UI
public CatcherArea(BeatmapDifficulty difficulty = null)
{
- RelativeSizeAxes = Axes.X;
- Height = CATCHER_SIZE;
- Child = MovableCatcher = new Catcher(this, difficulty);
- }
-
- public static float GetCatcherSize(BeatmapDifficulty difficulty)
- {
- return CATCHER_SIZE / CatchPlayfield.BASE_WIDTH * (1.0f - 0.7f * (difficulty.CircleSize - 5) / 5);
+ Size = new Vector2(CatchPlayfield.WIDTH, CATCHER_SIZE);
+ Child = MovableCatcher = new Catcher(this, difficulty) { X = CatchPlayfield.CENTER_X };
}
public void OnResult(DrawableCatchHitObject fruit, JudgementResult result)
diff --git a/osu.Game.Rulesets.Mania.Tests/ManiaBeatmapSampleConversionTest.cs b/osu.Game.Rulesets.Mania.Tests/ManiaBeatmapSampleConversionTest.cs
index d8f87195d1..c8feb4ae24 100644
--- a/osu.Game.Rulesets.Mania.Tests/ManiaBeatmapSampleConversionTest.cs
+++ b/osu.Game.Rulesets.Mania.Tests/ManiaBeatmapSampleConversionTest.cs
@@ -20,6 +20,7 @@ namespace osu.Game.Rulesets.Mania.Tests
[TestCase("convert-samples")]
[TestCase("mania-samples")]
+ [TestCase("slider-convert-samples")]
public void Test(string name) => base.Test(name);
protected override IEnumerable CreateConvertValue(HitObject hitObject)
@@ -29,13 +30,16 @@ namespace osu.Game.Rulesets.Mania.Tests
StartTime = hitObject.StartTime,
EndTime = hitObject.GetEndTime(),
Column = ((ManiaHitObject)hitObject).Column,
- NodeSamples = getSampleNames((hitObject as HoldNote)?.NodeSamples)
+ Samples = getSampleNames(hitObject.Samples),
+ NodeSamples = getNodeSampleNames((hitObject as HoldNote)?.NodeSamples)
};
}
- private IList> getSampleNames(List> hitSampleInfo)
- => hitSampleInfo?.Select(samples =>
- (IList)samples.Select(sample => sample.LookupNames.First()).ToList())
+ private IList getSampleNames(IList hitSampleInfo)
+ => hitSampleInfo.Select(sample => sample.LookupNames.First()).ToList();
+
+ private IList> getNodeSampleNames(List> hitSampleInfo)
+ => hitSampleInfo?.Select(getSampleNames)
.ToList();
protected override Ruleset CreateRuleset() => new ManiaRuleset();
@@ -51,14 +55,19 @@ namespace osu.Game.Rulesets.Mania.Tests
public double StartTime;
public double EndTime;
public int Column;
+ public IList Samples;
public IList> NodeSamples;
public bool Equals(SampleConvertValue other)
=> Precision.AlmostEquals(StartTime, other.StartTime, conversion_lenience)
&& Precision.AlmostEquals(EndTime, other.EndTime, conversion_lenience)
- && samplesEqual(NodeSamples, other.NodeSamples);
+ && samplesEqual(Samples, other.Samples)
+ && nodeSamplesEqual(NodeSamples, other.NodeSamples);
- private static bool samplesEqual(ICollection> firstSampleList, ICollection> secondSampleList)
+ private static bool samplesEqual(ICollection firstSampleList, ICollection secondSampleList)
+ => firstSampleList.SequenceEqual(secondSampleList);
+
+ private static bool nodeSamplesEqual(ICollection> firstSampleList, ICollection> secondSampleList)
{
if (firstSampleList == null && secondSampleList == null)
return true;
diff --git a/osu.Game.Rulesets.Mania.Tests/Resources/SampleLookups/mania-hitobject-beatmap-custom-sample-bank.osu b/osu.Game.Rulesets.Mania.Tests/Resources/SampleLookups/mania-hitobject-beatmap-custom-sample-bank.osu
new file mode 100644
index 0000000000..4f8e1b68dd
--- /dev/null
+++ b/osu.Game.Rulesets.Mania.Tests/Resources/SampleLookups/mania-hitobject-beatmap-custom-sample-bank.osu
@@ -0,0 +1,10 @@
+osu file format v14
+
+[General]
+Mode: 3
+
+[TimingPoints]
+0,300,4,0,2,100,1,0
+
+[HitObjects]
+444,320,1000,5,2,0:0:0:0:
diff --git a/osu.Game.Rulesets.Mania.Tests/Resources/SampleLookups/mania-hitobject-beatmap-normal-sample-bank.osu b/osu.Game.Rulesets.Mania.Tests/Resources/SampleLookups/mania-hitobject-beatmap-normal-sample-bank.osu
new file mode 100644
index 0000000000..f22901e304
--- /dev/null
+++ b/osu.Game.Rulesets.Mania.Tests/Resources/SampleLookups/mania-hitobject-beatmap-normal-sample-bank.osu
@@ -0,0 +1,10 @@
+osu file format v14
+
+[General]
+Mode: 3
+
+[TimingPoints]
+0,300,4,0,2,100,1,0
+
+[HitObjects]
+444,320,1000,5,1,0:0:0:0:
diff --git a/osu.Game.Rulesets.Mania.Tests/Resources/special-skin/mania-stage-left.png b/osu.Game.Rulesets.Mania.Tests/Resources/special-skin/mania/stage-left.png
similarity index 100%
rename from osu.Game.Rulesets.Mania.Tests/Resources/special-skin/mania-stage-left.png
rename to osu.Game.Rulesets.Mania.Tests/Resources/special-skin/mania/stage-left.png
diff --git a/osu.Game.Rulesets.Mania.Tests/Resources/special-skin/mania-stage-right.png b/osu.Game.Rulesets.Mania.Tests/Resources/special-skin/mania/stage-right.png
similarity index 100%
rename from osu.Game.Rulesets.Mania.Tests/Resources/special-skin/mania-stage-right.png
rename to osu.Game.Rulesets.Mania.Tests/Resources/special-skin/mania/stage-right.png
diff --git a/osu.Game.Rulesets.Mania.Tests/Resources/special-skin/skin.ini b/osu.Game.Rulesets.Mania.Tests/Resources/special-skin/skin.ini
index 941abac1da..36765d61bf 100644
--- a/osu.Game.Rulesets.Mania.Tests/Resources/special-skin/skin.ini
+++ b/osu.Game.Rulesets.Mania.Tests/Resources/special-skin/skin.ini
@@ -9,4 +9,6 @@ Hit50: mania/hit50
Hit100: mania/hit100
Hit200: mania/hit200
Hit300: mania/hit300
-Hit300g: mania/hit300g
\ No newline at end of file
+Hit300g: mania/hit300g
+StageLeft: mania/stage-left
+StageRight: mania/stage-right
\ No newline at end of file
diff --git a/osu.Game.Rulesets.Mania.Tests/TestSceneManiaHitObjectSamples.cs b/osu.Game.Rulesets.Mania.Tests/TestSceneManiaHitObjectSamples.cs
new file mode 100644
index 0000000000..0d726e1a50
--- /dev/null
+++ b/osu.Game.Rulesets.Mania.Tests/TestSceneManiaHitObjectSamples.cs
@@ -0,0 +1,49 @@
+// Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence.
+// See the LICENCE file in the repository root for full licence text.
+
+using System.Reflection;
+using NUnit.Framework;
+using osu.Framework.IO.Stores;
+using osu.Game.Tests.Beatmaps;
+
+namespace osu.Game.Rulesets.Mania.Tests
+{
+ public class TestSceneManiaHitObjectSamples : HitObjectSampleTest
+ {
+ protected override Ruleset CreatePlayerRuleset() => new ManiaRuleset();
+ protected override IResourceStore Resources => new DllResourceStore(Assembly.GetAssembly(typeof(TestSceneManiaHitObjectSamples)));
+
+ ///
+ /// Tests that when a normal sample bank is used, the normal hitsound will be looked up.
+ ///
+ [Test]
+ public void TestManiaHitObjectNormalSampleBank()
+ {
+ const string expected_sample = "normal-hitnormal2";
+
+ SetupSkins(expected_sample, expected_sample);
+
+ CreateTestWithBeatmap("mania-hitobject-beatmap-normal-sample-bank.osu");
+
+ AssertBeatmapLookup(expected_sample);
+ }
+
+ ///
+ /// Tests that when a custom sample bank is used, layered hitsounds are not played
+ /// (only the sample from the custom bank is looked up).
+ ///
+ [Test]
+ public void TestManiaHitObjectCustomSampleBank()
+ {
+ const string expected_sample = "normal-hitwhistle2";
+ const string unwanted_sample = "normal-hitnormal2";
+
+ SetupSkins(expected_sample, unwanted_sample);
+
+ CreateTestWithBeatmap("mania-hitobject-beatmap-custom-sample-bank.osu");
+
+ AssertBeatmapLookup(expected_sample);
+ AssertNoLookup(unwanted_sample);
+ }
+ }
+}
diff --git a/osu.Game.Rulesets.Mania/Beatmaps/Patterns/Legacy/DistanceObjectPatternGenerator.cs b/osu.Game.Rulesets.Mania/Beatmaps/Patterns/Legacy/DistanceObjectPatternGenerator.cs
index 9fbdf58e21..d03eb0b3c9 100644
--- a/osu.Game.Rulesets.Mania/Beatmaps/Patterns/Legacy/DistanceObjectPatternGenerator.cs
+++ b/osu.Game.Rulesets.Mania/Beatmaps/Patterns/Legacy/DistanceObjectPatternGenerator.cs
@@ -483,9 +483,8 @@ namespace osu.Game.Rulesets.Mania.Beatmaps.Patterns.Legacy
if (!(HitObject is IHasPathWithRepeats curveData))
return null;
- double segmentTime = (EndTime - HitObject.StartTime) / spanCount;
-
- int index = (int)(segmentTime == 0 ? 0 : (time - HitObject.StartTime) / segmentTime);
+ // mathematically speaking this should be a whole number always, but floating-point arithmetic is not so kind
+ var index = (int)Math.Round(SegmentDuration == 0 ? 0 : (time - HitObject.StartTime) / SegmentDuration, MidpointRounding.AwayFromZero);
// avoid slicing the list & creating copies, if at all possible.
return index == 0 ? curveData.NodeSamples : curveData.NodeSamples.Skip(index).ToList();
diff --git a/osu.Game.Rulesets.Mania/ManiaRuleset.cs b/osu.Game.Rulesets.Mania/ManiaRuleset.cs
index 6ddb052585..a27485dd06 100644
--- a/osu.Game.Rulesets.Mania/ManiaRuleset.cs
+++ b/osu.Game.Rulesets.Mania/ManiaRuleset.cs
@@ -30,6 +30,7 @@ using osu.Game.Rulesets.Mania.Skinning;
using osu.Game.Rulesets.Scoring;
using osu.Game.Skinning;
using osu.Game.Scoring;
+using osu.Game.Screens.Ranking.Statistics;
namespace osu.Game.Rulesets.Mania
{
@@ -309,6 +310,21 @@ namespace osu.Game.Rulesets.Mania
{
return (PlayfieldType)Enum.GetValues(typeof(PlayfieldType)).Cast().OrderByDescending(i => i).First(v => variant >= v);
}
+
+ public override StatisticRow[] CreateStatisticsForScore(ScoreInfo score, IBeatmap playableBeatmap) => new[]
+ {
+ new StatisticRow
+ {
+ Columns = new[]
+ {
+ new StatisticItem("Timing Distribution", new HitEventTimingDistributionGraph(score.HitEvents)
+ {
+ RelativeSizeAxes = Axes.X,
+ Height = 250
+ }),
+ }
+ }
+ };
}
public enum PlayfieldType
diff --git a/osu.Game.Rulesets.Mania/Resources/Testing/Beatmaps/convert-samples-expected-conversion.json b/osu.Game.Rulesets.Mania/Resources/Testing/Beatmaps/convert-samples-expected-conversion.json
index b8ce85eef5..fec1360b26 100644
--- a/osu.Game.Rulesets.Mania/Resources/Testing/Beatmaps/convert-samples-expected-conversion.json
+++ b/osu.Game.Rulesets.Mania/Resources/Testing/Beatmaps/convert-samples-expected-conversion.json
@@ -9,7 +9,8 @@
["normal-hitnormal"],
["soft-hitnormal"],
["drum-hitnormal"]
- ]
+ ],
+ "Samples": ["drum-hitnormal"]
}, {
"StartTime": 1875.0,
"EndTime": 2750.0,
@@ -17,14 +18,16 @@
"NodeSamples": [
["soft-hitnormal"],
["drum-hitnormal"]
- ]
+ ],
+ "Samples": ["drum-hitnormal"]
}]
}, {
"StartTime": 3750.0,
"Objects": [{
"StartTime": 3750.0,
"EndTime": 3750.0,
- "Column": 3
+ "Column": 3,
+ "Samples": ["normal-hitnormal"]
}]
}]
}
\ No newline at end of file
diff --git a/osu.Game.Rulesets.Mania/Resources/Testing/Beatmaps/convert-samples.osu b/osu.Game.Rulesets.Mania/Resources/Testing/Beatmaps/convert-samples.osu
index 16b73992d2..fea1de6614 100644
--- a/osu.Game.Rulesets.Mania/Resources/Testing/Beatmaps/convert-samples.osu
+++ b/osu.Game.Rulesets.Mania/Resources/Testing/Beatmaps/convert-samples.osu
@@ -13,4 +13,4 @@ SliderTickRate:1
[HitObjects]
88,99,1000,6,0,L|306:259,2,245,0|0|0,1:0|2:0|3:0,0:0:0:0:
-259,118,3750,1,0,0:0:0:0:
+259,118,3750,1,0,1:0:0:0:
diff --git a/osu.Game.Rulesets.Mania/Resources/Testing/Beatmaps/mania-samples-expected-conversion.json b/osu.Game.Rulesets.Mania/Resources/Testing/Beatmaps/mania-samples-expected-conversion.json
index e22540614d..1aca75a796 100644
--- a/osu.Game.Rulesets.Mania/Resources/Testing/Beatmaps/mania-samples-expected-conversion.json
+++ b/osu.Game.Rulesets.Mania/Resources/Testing/Beatmaps/mania-samples-expected-conversion.json
@@ -8,7 +8,8 @@
"NodeSamples": [
["normal-hitnormal"],
[]
- ]
+ ],
+ "Samples": ["normal-hitnormal"]
}]
}, {
"StartTime": 2000.0,
@@ -19,7 +20,8 @@
"NodeSamples": [
["drum-hitnormal"],
[]
- ]
+ ],
+ "Samples": ["drum-hitnormal"]
}]
}]
}
\ No newline at end of file
diff --git a/osu.Game.Rulesets.Mania/Resources/Testing/Beatmaps/slider-convert-samples-expected-conversion.json b/osu.Game.Rulesets.Mania/Resources/Testing/Beatmaps/slider-convert-samples-expected-conversion.json
new file mode 100644
index 0000000000..e3768a90d7
--- /dev/null
+++ b/osu.Game.Rulesets.Mania/Resources/Testing/Beatmaps/slider-convert-samples-expected-conversion.json
@@ -0,0 +1,21 @@
+{
+ "Mappings": [{
+ "StartTime": 8470.0,
+ "Objects": [{
+ "StartTime": 8470.0,
+ "EndTime": 8470.0,
+ "Column": 0,
+ "Samples": ["normal-hitnormal", "normal-hitclap"]
+ }, {
+ "StartTime": 8626.470587768974,
+ "EndTime": 8626.470587768974,
+ "Column": 1,
+ "Samples": ["normal-hitnormal"]
+ }, {
+ "StartTime": 8782.941175537948,
+ "EndTime": 8782.941175537948,
+ "Column": 2,
+ "Samples": ["normal-hitnormal", "normal-hitclap"]
+ }]
+ }]
+}
diff --git a/osu.Game.Rulesets.Mania/Resources/Testing/Beatmaps/slider-convert-samples.osu b/osu.Game.Rulesets.Mania/Resources/Testing/Beatmaps/slider-convert-samples.osu
new file mode 100644
index 0000000000..08e90ce807
--- /dev/null
+++ b/osu.Game.Rulesets.Mania/Resources/Testing/Beatmaps/slider-convert-samples.osu
@@ -0,0 +1,15 @@
+osu file format v14
+
+[Difficulty]
+HPDrainRate:6
+CircleSize:4
+OverallDifficulty:8
+ApproachRate:9.5
+SliderMultiplier:2.00000000596047
+SliderTickRate:1
+
+[TimingPoints]
+0,312.941176470588,4,1,0,100,1,0
+
+[HitObjects]
+82,216,8470,6,0,P|52:161|99:113,2,100,8|0|8,1:0|1:0|1:0,0:0:0:0:
diff --git a/osu.Game.Rulesets.Mania/Skinning/ManiaLegacySkinTransformer.cs b/osu.Game.Rulesets.Mania/Skinning/ManiaLegacySkinTransformer.cs
index 84e88a10be..e167135556 100644
--- a/osu.Game.Rulesets.Mania/Skinning/ManiaLegacySkinTransformer.cs
+++ b/osu.Game.Rulesets.Mania/Skinning/ManiaLegacySkinTransformer.cs
@@ -9,6 +9,9 @@ using osu.Game.Beatmaps;
using osu.Game.Rulesets.Mania.Beatmaps;
using osu.Game.Skinning;
using System.Collections.Generic;
+using osu.Framework.Audio.Sample;
+using osu.Game.Audio;
+using osu.Game.Rulesets.Objects.Legacy;
namespace osu.Game.Rulesets.Mania.Skinning
{
@@ -129,6 +132,15 @@ namespace osu.Game.Rulesets.Mania.Skinning
return this.GetAnimation(filename, true, true);
}
+ public override SampleChannel GetSample(ISampleInfo sampleInfo)
+ {
+ // layered hit sounds never play in mania
+ if (sampleInfo is ConvertHitObjectParser.LegacyHitSampleInfo legacySample && legacySample.IsLayered)
+ return new SampleChannelVirtual();
+
+ return Source.GetSample(sampleInfo);
+ }
+
public override IBindable GetConfig(TLookup lookup)
{
if (lookup is ManiaSkinConfigurationLookup maniaLookup)
diff --git a/osu.Game.Rulesets.Osu.Tests/TestSceneAccuracyHeatmap.cs b/osu.Game.Rulesets.Osu.Tests/TestSceneAccuracyHeatmap.cs
new file mode 100644
index 0000000000..10d9d7ffde
--- /dev/null
+++ b/osu.Game.Rulesets.Osu.Tests/TestSceneAccuracyHeatmap.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 NUnit.Framework;
+using osu.Framework.Extensions.Color4Extensions;
+using osu.Framework.Graphics;
+using osu.Framework.Graphics.Containers;
+using osu.Framework.Graphics.Shapes;
+using osu.Framework.Input.Events;
+using osu.Framework.Threading;
+using osu.Framework.Utils;
+using osu.Game.Rulesets.Osu.Statistics;
+using osu.Game.Scoring;
+using osu.Game.Tests.Beatmaps;
+using osu.Game.Tests.Visual;
+using osuTK;
+using osuTK.Graphics;
+
+namespace osu.Game.Rulesets.Osu.Tests
+{
+ public class TestSceneAccuracyHeatmap : OsuManualInputManagerTestScene
+ {
+ private Box background;
+ private Drawable object1;
+ private Drawable object2;
+ private TestAccuracyHeatmap accuracyHeatmap;
+ private ScheduledDelegate automaticAdditionDelegate;
+
+ [SetUp]
+ public void Setup() => Schedule(() =>
+ {
+ automaticAdditionDelegate?.Cancel();
+ automaticAdditionDelegate = null;
+
+ Children = new[]
+ {
+ background = new Box
+ {
+ RelativeSizeAxes = Axes.Both,
+ Colour = Color4Extensions.FromHex("#333"),
+ },
+ object1 = new BorderCircle
+ {
+ Position = new Vector2(256, 192),
+ Colour = Color4.Yellow,
+ },
+ object2 = new BorderCircle
+ {
+ Position = new Vector2(100, 300),
+ },
+ accuracyHeatmap = new TestAccuracyHeatmap(new ScoreInfo { Beatmap = new TestBeatmap(new OsuRuleset().RulesetInfo).BeatmapInfo })
+ {
+ Anchor = Anchor.Centre,
+ Origin = Anchor.Centre,
+ Size = new Vector2(130)
+ }
+ };
+ });
+
+ [Test]
+ public void TestManyHitPointsAutomatic()
+ {
+ AddStep("add scheduled delegate", () =>
+ {
+ automaticAdditionDelegate = Scheduler.AddDelayed(() =>
+ {
+ var randomPos = new Vector2(
+ RNG.NextSingle(object1.DrawPosition.X - object1.DrawSize.X / 2, object1.DrawPosition.X + object1.DrawSize.X / 2),
+ RNG.NextSingle(object1.DrawPosition.Y - object1.DrawSize.Y / 2, object1.DrawPosition.Y + object1.DrawSize.Y / 2));
+
+ // The background is used for ToLocalSpace() since we need to go _inside_ the DrawSizePreservingContainer (Content of TestScene).
+ accuracyHeatmap.AddPoint(object2.Position, object1.Position, randomPos, RNG.NextSingle(10, 500));
+ InputManager.MoveMouseTo(background.ToScreenSpace(randomPos));
+ }, 1, true);
+ });
+
+ AddWaitStep("wait for some hit points", 10);
+ }
+
+ [Test]
+ public void TestManualPlacement()
+ {
+ AddStep("return user input", () => InputManager.UseParentInput = true);
+ }
+
+ protected override bool OnMouseDown(MouseDownEvent e)
+ {
+ accuracyHeatmap.AddPoint(object2.Position, object1.Position, background.ToLocalSpace(e.ScreenSpaceMouseDownPosition), 50);
+ return true;
+ }
+
+ private class TestAccuracyHeatmap : AccuracyHeatmap
+ {
+ public TestAccuracyHeatmap(ScoreInfo score)
+ : base(score, new TestBeatmap(new OsuRuleset().RulesetInfo))
+ {
+ }
+
+ public new void AddPoint(Vector2 start, Vector2 end, Vector2 hitPoint, float radius)
+ => base.AddPoint(start, end, hitPoint, radius);
+ }
+
+ private class BorderCircle : CircularContainer
+ {
+ public BorderCircle()
+ {
+ Origin = Anchor.Centre;
+ Size = new Vector2(100);
+
+ Masking = true;
+ BorderThickness = 2;
+ BorderColour = Color4.White;
+
+ InternalChildren = new Drawable[]
+ {
+ new Box
+ {
+ RelativeSizeAxes = Axes.Both,
+ Alpha = 0,
+ AlwaysPresent = true
+ },
+ new Circle
+ {
+ Anchor = Anchor.Centre,
+ Origin = Anchor.Centre,
+ Size = new Vector2(4),
+ }
+ };
+ }
+ }
+ }
+}
diff --git a/osu.Game.Rulesets.Osu/Judgements/OsuHitCircleJudgementResult.cs b/osu.Game.Rulesets.Osu/Judgements/OsuHitCircleJudgementResult.cs
new file mode 100644
index 0000000000..9b33e746b3
--- /dev/null
+++ b/osu.Game.Rulesets.Osu/Judgements/OsuHitCircleJudgementResult.cs
@@ -0,0 +1,28 @@
+// 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.Judgements;
+using osu.Game.Rulesets.Objects;
+using osu.Game.Rulesets.Osu.Objects;
+using osuTK;
+
+namespace osu.Game.Rulesets.Osu.Judgements
+{
+ public class OsuHitCircleJudgementResult : OsuJudgementResult
+ {
+ ///
+ /// The .
+ ///
+ public HitCircle HitCircle => (HitCircle)HitObject;
+
+ ///
+ /// The position of the player's cursor when was hit.
+ ///
+ public Vector2? CursorPositionAtHit;
+
+ public OsuHitCircleJudgementResult(HitObject hitObject, Judgement judgement)
+ : base(hitObject, judgement)
+ {
+ }
+ }
+}
diff --git a/osu.Game.Rulesets.Osu/Objects/Drawables/DrawableHitCircle.cs b/osu.Game.Rulesets.Osu/Objects/Drawables/DrawableHitCircle.cs
index d73ad888f4..854fc4c91c 100644
--- a/osu.Game.Rulesets.Osu/Objects/Drawables/DrawableHitCircle.cs
+++ b/osu.Game.Rulesets.Osu/Objects/Drawables/DrawableHitCircle.cs
@@ -7,8 +7,11 @@ using osu.Framework.Allocation;
using osu.Framework.Bindables;
using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers;
+using osu.Framework.Input;
using osu.Framework.Input.Bindings;
+using osu.Game.Rulesets.Judgements;
using osu.Game.Rulesets.Objects.Drawables;
+using osu.Game.Rulesets.Osu.Judgements;
using osu.Game.Rulesets.Osu.Objects.Drawables.Pieces;
using osu.Game.Rulesets.Scoring;
using osuTK;
@@ -32,6 +35,8 @@ namespace osu.Game.Rulesets.Osu.Objects.Drawables
protected virtual OsuSkinComponents CirclePieceComponent => OsuSkinComponents.HitCircle;
+ private InputManager inputManager;
+
public DrawableHitCircle(HitCircle h)
: base(h)
{
@@ -86,6 +91,13 @@ namespace osu.Game.Rulesets.Osu.Objects.Drawables
AccentColour.BindValueChanged(accent => ApproachCircle.Colour = accent.NewValue, true);
}
+ protected override void LoadComplete()
+ {
+ base.LoadComplete();
+
+ inputManager = GetContainingInputManager();
+ }
+
public override double LifetimeStart
{
get => base.LifetimeStart;
@@ -126,7 +138,19 @@ namespace osu.Game.Rulesets.Osu.Objects.Drawables
return;
}
- ApplyResult(r => r.Type = result);
+ ApplyResult(r =>
+ {
+ var circleResult = (OsuHitCircleJudgementResult)r;
+
+ // Todo: This should also consider misses, but they're a little more interesting to handle, since we don't necessarily know the position at the time of a miss.
+ if (result != HitResult.Miss)
+ {
+ var localMousePosition = ToLocalSpace(inputManager.CurrentState.Mouse.Position);
+ circleResult.CursorPositionAtHit = HitObject.StackedPosition + (localMousePosition - DrawSize / 2);
+ }
+
+ circleResult.Type = result;
+ });
}
protected override void UpdateInitialTransforms()
@@ -172,6 +196,8 @@ namespace osu.Game.Rulesets.Osu.Objects.Drawables
public Drawable ProxiedLayer => ApproachCircle;
+ protected override JudgementResult CreateResult(Judgement judgement) => new OsuHitCircleJudgementResult(HitObject, judgement);
+
public class HitReceptor : CompositeDrawable, IKeyBindingHandler
{
// IsHovered is used
diff --git a/osu.Game.Rulesets.Osu/Objects/Drawables/DrawableSpinner.cs b/osu.Game.Rulesets.Osu/Objects/Drawables/DrawableSpinner.cs
index 3c8ab0f5ab..4d37622be5 100644
--- a/osu.Game.Rulesets.Osu/Objects/Drawables/DrawableSpinner.cs
+++ b/osu.Game.Rulesets.Osu/Objects/Drawables/DrawableSpinner.cs
@@ -14,6 +14,7 @@ using osu.Framework.Extensions.Color4Extensions;
using osu.Framework.Allocation;
using osu.Framework.Bindables;
using osu.Framework.Graphics.Sprites;
+using osu.Framework.Utils;
using osu.Game.Rulesets.Scoring;
using osu.Game.Screens.Ranking;
@@ -193,9 +194,10 @@ namespace osu.Game.Rulesets.Osu.Objects.Drawables
SpmCounter.SetRotation(Disc.RotationAbsolute);
float relativeCircleScale = Spinner.Scale * circle.DrawHeight / mainContainer.DrawHeight;
- Disc.ScaleTo(relativeCircleScale + (1 - relativeCircleScale) * Progress, 200, Easing.OutQuint);
+ float targetScale = relativeCircleScale + (1 - relativeCircleScale) * Progress;
+ Disc.Scale = new Vector2((float)Interpolation.Lerp(Disc.Scale.X, targetScale, Math.Clamp(Math.Abs(Time.Elapsed) / 100, 0, 1)));
- symbol.RotateTo(Disc.Rotation / 2, 500, Easing.OutQuint);
+ symbol.Rotation = (float)Interpolation.Lerp(symbol.Rotation, Disc.RotationAbsolute / 2, Math.Clamp(Math.Abs(Time.Elapsed) / 40, 0, 1));
}
protected override void UpdateInitialTransforms()
diff --git a/osu.Game.Rulesets.Osu/OsuRuleset.cs b/osu.Game.Rulesets.Osu/OsuRuleset.cs
index 689a7b35ea..e488ba65c8 100644
--- a/osu.Game.Rulesets.Osu/OsuRuleset.cs
+++ b/osu.Game.Rulesets.Osu/OsuRuleset.cs
@@ -29,6 +29,10 @@ using osu.Game.Rulesets.Scoring;
using osu.Game.Scoring;
using osu.Game.Skinning;
using System;
+using System.Linq;
+using osu.Game.Rulesets.Osu.Objects;
+using osu.Game.Rulesets.Osu.Statistics;
+using osu.Game.Screens.Ranking.Statistics;
namespace osu.Game.Rulesets.Osu
{
@@ -186,5 +190,31 @@ namespace osu.Game.Rulesets.Osu
public override IConvertibleReplayFrame CreateConvertibleReplayFrame() => new OsuReplayFrame();
public override IRulesetConfigManager CreateConfig(SettingsStore settings) => new OsuRulesetConfigManager(settings, RulesetInfo);
+
+ public override StatisticRow[] CreateStatisticsForScore(ScoreInfo score, IBeatmap playableBeatmap) => new[]
+ {
+ new StatisticRow
+ {
+ Columns = new[]
+ {
+ new StatisticItem("Timing Distribution", new HitEventTimingDistributionGraph(score.HitEvents.Where(e => e.HitObject is HitCircle && !(e.HitObject is SliderTailCircle)).ToList())
+ {
+ RelativeSizeAxes = Axes.X,
+ Height = 250
+ }),
+ }
+ },
+ new StatisticRow
+ {
+ Columns = new[]
+ {
+ new StatisticItem("Accuracy Heatmap", new AccuracyHeatmap(score, playableBeatmap)
+ {
+ RelativeSizeAxes = Axes.X,
+ Height = 250
+ }),
+ }
+ }
+ };
}
}
diff --git a/osu.Game.Rulesets.Osu/Scoring/OsuScoreProcessor.cs b/osu.Game.Rulesets.Osu/Scoring/OsuScoreProcessor.cs
index 79a6ea7e92..86ec76e373 100644
--- a/osu.Game.Rulesets.Osu/Scoring/OsuScoreProcessor.cs
+++ b/osu.Game.Rulesets.Osu/Scoring/OsuScoreProcessor.cs
@@ -4,13 +4,27 @@
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;
namespace osu.Game.Rulesets.Osu.Scoring
{
public class OsuScoreProcessor : ScoreProcessor
{
- protected override JudgementResult CreateResult(HitObject hitObject, Judgement judgement) => new OsuJudgementResult(hitObject, judgement);
+ protected override HitEvent CreateHitEvent(JudgementResult result)
+ => base.CreateHitEvent(result).With((result as OsuHitCircleJudgementResult)?.CursorPositionAtHit);
+
+ protected override JudgementResult CreateResult(HitObject hitObject, Judgement judgement)
+ {
+ switch (hitObject)
+ {
+ case HitCircle _:
+ return new OsuHitCircleJudgementResult(hitObject, judgement);
+
+ default:
+ return new OsuJudgementResult(hitObject, judgement);
+ }
+ }
public override HitWindows CreateHitWindows() => new OsuHitWindows();
}
diff --git a/osu.Game.Rulesets.Osu/Statistics/AccuracyHeatmap.cs b/osu.Game.Rulesets.Osu/Statistics/AccuracyHeatmap.cs
new file mode 100644
index 0000000000..20adbc1c02
--- /dev/null
+++ b/osu.Game.Rulesets.Osu/Statistics/AccuracyHeatmap.cs
@@ -0,0 +1,297 @@
+// 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.Diagnostics;
+using System.Linq;
+using osu.Framework.Allocation;
+using osu.Framework.Extensions.Color4Extensions;
+using osu.Framework.Graphics;
+using osu.Framework.Graphics.Containers;
+using osu.Framework.Graphics.Shapes;
+using osu.Framework.Utils;
+using osu.Game.Beatmaps;
+using osu.Game.Rulesets.Osu.Objects;
+using osu.Game.Scoring;
+using osuTK;
+using osuTK.Graphics;
+
+namespace osu.Game.Rulesets.Osu.Statistics
+{
+ public class AccuracyHeatmap : CompositeDrawable
+ {
+ ///
+ /// Size of the inner circle containing the "hit" points, relative to the size of this .
+ /// All other points outside of the inner circle are "miss" points.
+ ///
+ private const float inner_portion = 0.8f;
+
+ ///
+ /// Number of rows/columns of points.
+ /// ~4px per point @ 128x128 size (the contents of the are always square). 1089 total points.
+ ///
+ private const int points_per_dimension = 33;
+
+ private const float rotation = 45;
+
+ private BufferedContainer bufferedGrid;
+ private GridContainer pointGrid;
+
+ private readonly ScoreInfo score;
+ private readonly IBeatmap playableBeatmap;
+
+ private const float line_thickness = 2;
+
+ ///
+ /// The highest count of any point currently being displayed.
+ ///
+ protected float PeakValue { get; private set; }
+
+ public AccuracyHeatmap(ScoreInfo score, IBeatmap playableBeatmap)
+ {
+ this.score = score;
+ this.playableBeatmap = playableBeatmap;
+ }
+
+ [BackgroundDependencyLoader]
+ private void load()
+ {
+ InternalChild = new Container
+ {
+ Anchor = Anchor.Centre,
+ Origin = Anchor.Centre,
+ RelativeSizeAxes = Axes.Both,
+ FillMode = FillMode.Fit,
+ Children = new Drawable[]
+ {
+ new CircularContainer
+ {
+ Anchor = Anchor.Centre,
+ Origin = Anchor.Centre,
+ RelativeSizeAxes = Axes.Both,
+ Size = new Vector2(inner_portion),
+ Masking = true,
+ BorderThickness = line_thickness,
+ BorderColour = Color4.White,
+ Child = new Box
+ {
+ RelativeSizeAxes = Axes.Both,
+ Colour = Color4Extensions.FromHex("#202624")
+ }
+ },
+ new Container
+ {
+ RelativeSizeAxes = Axes.Both,
+ Children = new Drawable[]
+ {
+ new Container
+ {
+ RelativeSizeAxes = Axes.Both,
+ Padding = new MarginPadding(1),
+ Child = new Container
+ {
+ RelativeSizeAxes = Axes.Both,
+ Masking = true,
+ Children = new Drawable[]
+ {
+ new Box
+ {
+ Anchor = Anchor.Centre,
+ Origin = Anchor.Centre,
+ EdgeSmoothness = new Vector2(1),
+ RelativeSizeAxes = Axes.Y,
+ Height = 2, // We're rotating along a diagonal - we don't really care how big this is.
+ Width = line_thickness / 2,
+ Rotation = -rotation,
+ Alpha = 0.3f,
+ },
+ new Box
+ {
+ Anchor = Anchor.Centre,
+ Origin = Anchor.Centre,
+ EdgeSmoothness = new Vector2(1),
+ RelativeSizeAxes = Axes.Y,
+ Height = 2, // We're rotating along a diagonal - we don't really care how big this is.
+ Width = line_thickness / 2, // adjust for edgesmoothness
+ Rotation = rotation
+ },
+ }
+ },
+ },
+ new Box
+ {
+ Anchor = Anchor.TopRight,
+ Origin = Anchor.TopRight,
+ Width = 10,
+ EdgeSmoothness = new Vector2(1),
+ Height = line_thickness / 2, // adjust for edgesmoothness
+ },
+ new Box
+ {
+ Anchor = Anchor.TopRight,
+ Origin = Anchor.TopRight,
+ EdgeSmoothness = new Vector2(1),
+ Width = line_thickness / 2, // adjust for edgesmoothness
+ Height = 10,
+ }
+ }
+ },
+ bufferedGrid = new BufferedContainer
+ {
+ RelativeSizeAxes = Axes.Both,
+ CacheDrawnFrameBuffer = true,
+ BackgroundColour = Color4Extensions.FromHex("#202624").Opacity(0),
+ Child = pointGrid = new GridContainer
+ {
+ RelativeSizeAxes = Axes.Both
+ }
+ },
+ }
+ };
+
+ Vector2 centre = new Vector2(points_per_dimension) / 2;
+ float innerRadius = centre.X * inner_portion;
+
+ Drawable[][] points = new Drawable[points_per_dimension][];
+
+ for (int r = 0; r < points_per_dimension; r++)
+ {
+ points[r] = new Drawable[points_per_dimension];
+
+ for (int c = 0; c < points_per_dimension; c++)
+ {
+ HitPointType pointType = Vector2.Distance(new Vector2(c, r), centre) <= innerRadius
+ ? HitPointType.Hit
+ : HitPointType.Miss;
+
+ var point = new HitPoint(pointType, this)
+ {
+ Colour = pointType == HitPointType.Hit ? new Color4(102, 255, 204, 255) : new Color4(255, 102, 102, 255)
+ };
+
+ points[r][c] = point;
+ }
+ }
+
+ pointGrid.Content = points;
+
+ if (score.HitEvents == null || score.HitEvents.Count == 0)
+ return;
+
+ // Todo: This should probably not be done like this.
+ float radius = OsuHitObject.OBJECT_RADIUS * (1.0f - 0.7f * (playableBeatmap.BeatmapInfo.BaseDifficulty.CircleSize - 5) / 5) / 2;
+
+ foreach (var e in score.HitEvents.Where(e => e.HitObject is HitCircle && !(e.HitObject is SliderTailCircle)))
+ {
+ if (e.LastHitObject == null || e.Position == null)
+ continue;
+
+ AddPoint(((OsuHitObject)e.LastHitObject).StackedEndPosition, ((OsuHitObject)e.HitObject).StackedEndPosition, e.Position.Value, radius);
+ }
+ }
+
+ protected void AddPoint(Vector2 start, Vector2 end, Vector2 hitPoint, float radius)
+ {
+ if (pointGrid.Content.Length == 0)
+ return;
+
+ double angle1 = Math.Atan2(end.Y - hitPoint.Y, hitPoint.X - end.X); // Angle between the end point and the hit point.
+ double angle2 = Math.Atan2(end.Y - start.Y, start.X - end.X); // Angle between the end point and the start point.
+ double finalAngle = angle2 - angle1; // Angle between start, end, and hit points.
+ float normalisedDistance = Vector2.Distance(hitPoint, end) / radius;
+
+ // Consider two objects placed horizontally, with the start on the left and the end on the right.
+ // The above calculated the angle between {end, start}, and the angle between {end, hitPoint}, in the form:
+ // +pi | 0
+ // O --------- O -----> Note: Math.Atan2 has a range (-pi <= theta <= +pi)
+ // -pi | 0
+ // E.g. If the hit point was directly above end, it would have an angle pi/2.
+ //
+ // It also calculated the angle separating hitPoint from the line joining {start, end}, that is anti-clockwise in the form:
+ // 0 | pi
+ // O --------- O ----->
+ // 2pi | pi
+ //
+ // However keep in mind that cos(0)=1 and cos(2pi)=1, whereas we actually want these values to appear on the left, so the x-coordinate needs to be inverted.
+ // Likewise sin(pi/2)=1 and sin(3pi/2)=-1, whereas we actually want these values to appear on the bottom/top respectively, so the y-coordinate also needs to be inverted.
+ //
+ // We also need to apply the anti-clockwise rotation.
+ var rotatedAngle = finalAngle - MathUtils.DegreesToRadians(rotation);
+ var rotatedCoordinate = -1 * new Vector2((float)Math.Cos(rotatedAngle), (float)Math.Sin(rotatedAngle));
+
+ Vector2 localCentre = new Vector2(points_per_dimension - 1) / 2;
+ float localRadius = localCentre.X * inner_portion * normalisedDistance; // The radius inside the inner portion which of the heatmap which the closest point lies.
+ Vector2 localPoint = localCentre + localRadius * rotatedCoordinate;
+
+ // Find the most relevant hit point.
+ int r = Math.Clamp((int)Math.Round(localPoint.Y), 0, points_per_dimension - 1);
+ int c = Math.Clamp((int)Math.Round(localPoint.X), 0, points_per_dimension - 1);
+
+ PeakValue = Math.Max(PeakValue, ((HitPoint)pointGrid.Content[r][c]).Increment());
+
+ bufferedGrid.ForceRedraw();
+ }
+
+ private class HitPoint : Circle
+ {
+ private readonly HitPointType pointType;
+ private readonly AccuracyHeatmap heatmap;
+
+ public override bool IsPresent => count > 0;
+
+ public HitPoint(HitPointType pointType, AccuracyHeatmap heatmap)
+ {
+ this.pointType = pointType;
+ this.heatmap = heatmap;
+
+ RelativeSizeAxes = Axes.Both;
+ Alpha = 1;
+ }
+
+ private int count;
+
+ ///
+ /// Increment the value of this point by one.
+ ///
+ /// The value after incrementing.
+ public int Increment()
+ {
+ return ++count;
+ }
+
+ protected override void Update()
+ {
+ base.Update();
+
+ // the point at which alpha is saturated and we begin to adjust colour lightness.
+ const float lighten_cutoff = 0.95f;
+
+ // the amount of lightness to attribute regardless of relative value to peak point.
+ const float non_relative_portion = 0.2f;
+
+ float amount = 0;
+
+ // give some amount of alpha regardless of relative count
+ amount += non_relative_portion * Math.Min(1, count / 10f);
+
+ // add relative portion
+ amount += (1 - non_relative_portion) * (count / heatmap.PeakValue);
+
+ // apply easing
+ amount = (float)Interpolation.ApplyEasing(Easing.OutQuint, Math.Min(1, amount));
+
+ Debug.Assert(amount <= 1);
+
+ Alpha = Math.Min(amount / lighten_cutoff, 1);
+ if (pointType == HitPointType.Hit)
+ Colour = ((Color4)Colour).Lighten(Math.Max(0, amount - lighten_cutoff));
+ }
+ }
+
+ private enum HitPointType
+ {
+ Hit,
+ Miss
+ }
+ }
+}
diff --git a/osu.Game.Rulesets.Taiko/TaikoRuleset.cs b/osu.Game.Rulesets.Taiko/TaikoRuleset.cs
index 4cdd1fbc24..156905fa9c 100644
--- a/osu.Game.Rulesets.Taiko/TaikoRuleset.cs
+++ b/osu.Game.Rulesets.Taiko/TaikoRuleset.cs
@@ -21,9 +21,12 @@ using osu.Game.Rulesets.Taiko.Difficulty;
using osu.Game.Rulesets.Taiko.Scoring;
using osu.Game.Scoring;
using System;
+using System.Linq;
using osu.Game.Rulesets.Edit;
using osu.Game.Rulesets.Taiko.Edit;
+using osu.Game.Rulesets.Taiko.Objects;
using osu.Game.Rulesets.Taiko.Skinning;
+using osu.Game.Screens.Ranking.Statistics;
using osu.Game.Skinning;
namespace osu.Game.Rulesets.Taiko
@@ -155,5 +158,20 @@ namespace osu.Game.Rulesets.Taiko
public int LegacyID => 1;
public override IConvertibleReplayFrame CreateConvertibleReplayFrame() => new TaikoReplayFrame();
+
+ public override StatisticRow[] CreateStatisticsForScore(ScoreInfo score, IBeatmap playableBeatmap) => new[]
+ {
+ new StatisticRow
+ {
+ Columns = new[]
+ {
+ new StatisticItem("Timing Distribution", new HitEventTimingDistributionGraph(score.HitEvents.Where(e => e.HitObject is Hit).ToList())
+ {
+ RelativeSizeAxes = Axes.X,
+ Height = 250
+ }),
+ }
+ }
+ };
}
}
diff --git a/osu.Game.Rulesets.Taiko/UI/TaikoHitTarget.cs b/osu.Game.Rulesets.Taiko/UI/TaikoHitTarget.cs
index 7de1593ab6..caddc8b122 100644
--- a/osu.Game.Rulesets.Taiko/UI/TaikoHitTarget.cs
+++ b/osu.Game.Rulesets.Taiko/UI/TaikoHitTarget.cs
@@ -41,7 +41,7 @@ namespace osu.Game.Rulesets.Taiko.UI
Anchor = Anchor.Centre,
Origin = Anchor.Centre,
RelativeSizeAxes = Axes.Both,
- Scale = new Vector2(TaikoHitObject.DEFAULT_STRONG_SIZE),
+ Size = new Vector2(TaikoHitObject.DEFAULT_STRONG_SIZE),
Masking = true,
BorderColour = Color4.White,
BorderThickness = border_thickness,
@@ -62,7 +62,7 @@ namespace osu.Game.Rulesets.Taiko.UI
Anchor = Anchor.Centre,
Origin = Anchor.Centre,
RelativeSizeAxes = Axes.Both,
- Scale = new Vector2(TaikoHitObject.DEFAULT_SIZE),
+ Size = new Vector2(TaikoHitObject.DEFAULT_SIZE),
Masking = true,
BorderColour = Color4.White,
BorderThickness = border_thickness,
diff --git a/osu.Game.Tests/Gameplay/TestSceneHitObjectSamples.cs b/osu.Game.Tests/Gameplay/TestSceneHitObjectSamples.cs
index ef6efb7fec..737946e1e0 100644
--- a/osu.Game.Tests/Gameplay/TestSceneHitObjectSamples.cs
+++ b/osu.Game.Tests/Gameplay/TestSceneHitObjectSamples.cs
@@ -6,6 +6,7 @@ using osu.Framework.IO.Stores;
using osu.Framework.Testing;
using osu.Game.Rulesets;
using osu.Game.Rulesets.Osu;
+using osu.Game.Skinning;
using osu.Game.Tests.Beatmaps;
using osu.Game.Tests.Resources;
@@ -167,5 +168,64 @@ namespace osu.Game.Tests.Gameplay
AssertBeatmapLookup(expected_sample);
}
+
+ ///
+ /// Tests that when a custom sample bank is used, both the normal and additional sounds will be looked up.
+ ///
+ [Test]
+ public void TestHitObjectCustomSampleBank()
+ {
+ string[] expectedSamples =
+ {
+ "normal-hitnormal2",
+ "normal-hitwhistle2"
+ };
+
+ SetupSkins(expectedSamples[0], expectedSamples[1]);
+
+ CreateTestWithBeatmap("hitobject-beatmap-custom-sample-bank.osu");
+
+ AssertBeatmapLookup(expectedSamples[0]);
+ AssertUserLookup(expectedSamples[1]);
+ }
+
+ ///
+ /// Tests that when a custom sample bank is used, but is disabled,
+ /// only the additional sound will be looked up.
+ ///
+ [Test]
+ public void TestHitObjectCustomSampleBankWithoutLayered()
+ {
+ const string expected_sample = "normal-hitwhistle2";
+ const string unwanted_sample = "normal-hitnormal2";
+
+ SetupSkins(expected_sample, unwanted_sample);
+ disableLayeredHitSounds();
+
+ CreateTestWithBeatmap("hitobject-beatmap-custom-sample-bank.osu");
+
+ AssertBeatmapLookup(expected_sample);
+ AssertNoLookup(unwanted_sample);
+ }
+
+ ///
+ /// Tests that when a normal sample bank is used and is disabled,
+ /// the normal sound will be looked up anyway.
+ ///
+ [Test]
+ public void TestHitObjectNormalSampleBankWithoutLayered()
+ {
+ const string expected_sample = "normal-hitnormal";
+
+ SetupSkins(expected_sample, expected_sample);
+ disableLayeredHitSounds();
+
+ CreateTestWithBeatmap("hitobject-beatmap-sample.osu");
+
+ AssertBeatmapLookup(expected_sample);
+ }
+
+ private void disableLayeredHitSounds()
+ => AddStep("set LayeredHitSounds to false", () => Skin.Configuration.ConfigDictionary[GlobalSkinConfiguration.LayeredHitSounds.ToString()] = "0");
}
}
diff --git a/osu.Game.Tests/Gameplay/TestSceneStoryboardSamples.cs b/osu.Game.Tests/Gameplay/TestSceneStoryboardSamples.cs
index 552d163b2f..b30870d057 100644
--- a/osu.Game.Tests/Gameplay/TestSceneStoryboardSamples.cs
+++ b/osu.Game.Tests/Gameplay/TestSceneStoryboardSamples.cs
@@ -11,8 +11,10 @@ using osu.Framework.Audio.Sample;
using osu.Framework.IO.Stores;
using osu.Framework.Testing;
using osu.Game.Audio;
+using osu.Game.Rulesets;
using osu.Game.Rulesets.Mods;
using osu.Game.Rulesets.Osu;
+using osu.Game.Rulesets.Osu.Mods;
using osu.Game.Screens.Play;
using osu.Game.Skinning;
using osu.Game.Storyboards;
@@ -70,6 +72,50 @@ namespace osu.Game.Tests.Gameplay
AddUntilStep("sample playback succeeded", () => sample.LifetimeEnd < double.MaxValue);
}
+ [TestCase(typeof(OsuModDoubleTime), 1.5)]
+ [TestCase(typeof(OsuModHalfTime), 0.75)]
+ [TestCase(typeof(ModWindUp), 1.5)]
+ [TestCase(typeof(ModWindDown), 0.75)]
+ [TestCase(typeof(OsuModDoubleTime), 2)]
+ [TestCase(typeof(OsuModHalfTime), 0.5)]
+ [TestCase(typeof(ModWindUp), 2)]
+ [TestCase(typeof(ModWindDown), 0.5)]
+ public void TestSamplePlaybackWithRateMods(Type expectedMod, double expectedRate)
+ {
+ GameplayClockContainer gameplayContainer = null;
+ TestDrawableStoryboardSample sample = null;
+
+ Mod testedMod = Activator.CreateInstance(expectedMod) as Mod;
+
+ switch (testedMod)
+ {
+ case ModRateAdjust m:
+ m.SpeedChange.Value = expectedRate;
+ break;
+
+ case ModTimeRamp m:
+ m.InitialRate.Value = m.FinalRate.Value = expectedRate;
+ break;
+ }
+
+ AddStep("setup storyboard sample", () =>
+ {
+ Beatmap.Value = new TestCustomSkinWorkingBeatmap(new OsuRuleset().RulesetInfo, Audio);
+ SelectedMods.Value = new[] { testedMod };
+
+ Add(gameplayContainer = new GameplayClockContainer(Beatmap.Value, SelectedMods.Value, 0));
+
+ gameplayContainer.Add(sample = new TestDrawableStoryboardSample(new StoryboardSampleInfo("test-sample", 1, 1))
+ {
+ Clock = gameplayContainer.GameplayClock
+ });
+ });
+
+ AddStep("start", () => gameplayContainer.Start());
+
+ AddAssert("sample playback rate matches mod rates", () => sample.Channel.AggregateFrequency.Value == expectedRate);
+ }
+
private class TestSkin : LegacySkin
{
public TestSkin(string resourceName, AudioManager audioManager)
@@ -99,5 +145,28 @@ namespace osu.Game.Tests.Gameplay
{
}
}
+
+ private class TestCustomSkinWorkingBeatmap : ClockBackedTestWorkingBeatmap
+ {
+ private readonly AudioManager audio;
+
+ public TestCustomSkinWorkingBeatmap(RulesetInfo ruleset, AudioManager audio)
+ : base(ruleset, null, audio)
+ {
+ this.audio = audio;
+ }
+
+ protected override ISkin GetSkin() => new TestSkin("test-sample", audio);
+ }
+
+ private class TestDrawableStoryboardSample : DrawableStoryboardSample
+ {
+ public TestDrawableStoryboardSample(StoryboardSampleInfo sampleInfo)
+ : base(sampleInfo)
+ {
+ }
+
+ public new SampleChannel Channel => base.Channel;
+ }
}
}
diff --git a/osu.Game.Tests/NonVisual/CustomDataDirectoryTest.cs b/osu.Game.Tests/NonVisual/CustomDataDirectoryTest.cs
index f3d54d876a..8ea0e34214 100644
--- a/osu.Game.Tests/NonVisual/CustomDataDirectoryTest.cs
+++ b/osu.Game.Tests/NonVisual/CustomDataDirectoryTest.cs
@@ -127,6 +127,9 @@ namespace osu.Game.Tests.NonVisual
var osu = loadOsu(host);
var storage = osu.Dependencies.Get();
+ // Store the current storage's path. We'll need to refer to this for assertions in the original directory after the migration completes.
+ string originalDirectory = storage.GetFullPath(".");
+
// ensure we perform a save
host.Dependencies.Get().Save();
@@ -145,25 +148,25 @@ namespace osu.Game.Tests.NonVisual
Assert.That(storage.GetFullPath("."), Is.EqualTo(customPath));
// ensure cache was not moved
- Assert.That(host.Storage.ExistsDirectory("cache"));
+ Assert.That(Directory.Exists(Path.Combine(originalDirectory, "cache")));
// ensure nested cache was moved
- Assert.That(!host.Storage.ExistsDirectory(Path.Combine("test-nested", "cache")));
+ Assert.That(!Directory.Exists(Path.Combine(originalDirectory, "test-nested", "cache")));
Assert.That(storage.ExistsDirectory(Path.Combine("test-nested", "cache")));
foreach (var file in OsuStorage.IGNORE_FILES)
{
- Assert.That(host.Storage.Exists(file), Is.True);
+ Assert.That(File.Exists(Path.Combine(originalDirectory, file)));
Assert.That(storage.Exists(file), Is.False);
}
foreach (var dir in OsuStorage.IGNORE_DIRECTORIES)
{
- Assert.That(host.Storage.ExistsDirectory(dir), Is.True);
+ Assert.That(Directory.Exists(Path.Combine(originalDirectory, dir)));
Assert.That(storage.ExistsDirectory(dir), Is.False);
}
- Assert.That(new StreamReader(host.Storage.GetStream("storage.ini")).ReadToEnd().Contains($"FullPath = {customPath}"));
+ Assert.That(new StreamReader(Path.Combine(originalDirectory, "storage.ini")).ReadToEnd().Contains($"FullPath = {customPath}"));
}
finally
{
diff --git a/osu.Game.Tests/Online/TestAPIModSerialization.cs b/osu.Game.Tests/Online/TestAPIModSerialization.cs
index d9318aa822..5948582d77 100644
--- a/osu.Game.Tests/Online/TestAPIModSerialization.cs
+++ b/osu.Game.Tests/Online/TestAPIModSerialization.cs
@@ -49,9 +49,32 @@ namespace osu.Game.Tests.Online
Assert.That(converted.TestSetting.Value, Is.EqualTo(2));
}
+ [Test]
+ public void TestDeserialiseTimeRampMod()
+ {
+ // Create the mod with values different from default.
+ var apiMod = new APIMod(new TestModTimeRamp
+ {
+ AdjustPitch = { Value = false },
+ InitialRate = { Value = 1.25 },
+ FinalRate = { Value = 0.25 }
+ });
+
+ var deserialised = JsonConvert.DeserializeObject(JsonConvert.SerializeObject(apiMod));
+ var converted = (TestModTimeRamp)deserialised.ToMod(new TestRuleset());
+
+ Assert.That(converted.AdjustPitch.Value, Is.EqualTo(false));
+ Assert.That(converted.InitialRate.Value, Is.EqualTo(1.25));
+ Assert.That(converted.FinalRate.Value, Is.EqualTo(0.25));
+ }
+
private class TestRuleset : Ruleset
{
- public override IEnumerable GetModsFor(ModType type) => new[] { new TestMod() };
+ public override IEnumerable GetModsFor(ModType type) => new Mod[]
+ {
+ new TestMod(),
+ new TestModTimeRamp(),
+ };
public override DrawableRuleset CreateDrawableRulesetWith(IBeatmap beatmap, IReadOnlyList mods = null) => throw new System.NotImplementedException();
@@ -78,5 +101,39 @@ namespace osu.Game.Tests.Online
Precision = 0.01,
};
}
+
+ private class TestModTimeRamp : ModTimeRamp
+ {
+ public override string Name => "Test Mod";
+ public override string Acronym => "TMTR";
+ public override double ScoreMultiplier => 1;
+
+ [SettingSource("Initial rate", "The starting speed of the track")]
+ public override BindableNumber InitialRate { get; } = new BindableDouble
+ {
+ MinValue = 1,
+ MaxValue = 2,
+ Default = 1.5,
+ Value = 1.5,
+ Precision = 0.01,
+ };
+
+ [SettingSource("Final rate", "The speed increase to ramp towards")]
+ public override BindableNumber FinalRate { get; } = new BindableDouble
+ {
+ MinValue = 0,
+ MaxValue = 1,
+ Default = 0.5,
+ Value = 0.5,
+ Precision = 0.01,
+ };
+
+ [SettingSource("Adjust pitch", "Should pitch be adjusted with speed")]
+ public override BindableBool AdjustPitch { get; } = new BindableBool
+ {
+ Default = true,
+ Value = true
+ };
+ }
}
}
diff --git a/osu.Game.Tests/Resources/SampleLookups/hitobject-beatmap-custom-sample-bank.osu b/osu.Game.Tests/Resources/SampleLookups/hitobject-beatmap-custom-sample-bank.osu
new file mode 100644
index 0000000000..c50c921839
--- /dev/null
+++ b/osu.Game.Tests/Resources/SampleLookups/hitobject-beatmap-custom-sample-bank.osu
@@ -0,0 +1,7 @@
+osu file format v14
+
+[TimingPoints]
+0,300,4,0,2,100,1,0
+
+[HitObjects]
+444,320,1000,5,2,0:0:0:0:
diff --git a/osu.Game.Tests/Resources/skin-zero-alpha-colour.ini b/osu.Game.Tests/Resources/skin-zero-alpha-colour.ini
new file mode 100644
index 0000000000..3c0dae6b13
--- /dev/null
+++ b/osu.Game.Tests/Resources/skin-zero-alpha-colour.ini
@@ -0,0 +1,5 @@
+[General]
+Version: latest
+
+[Colours]
+Combo1: 255,255,255,0
\ No newline at end of file
diff --git a/osu.Game.Tests/Skins/LegacySkinDecoderTest.cs b/osu.Game.Tests/Skins/LegacySkinDecoderTest.cs
index aedf26ee75..c408d2f182 100644
--- a/osu.Game.Tests/Skins/LegacySkinDecoderTest.cs
+++ b/osu.Game.Tests/Skins/LegacySkinDecoderTest.cs
@@ -108,5 +108,15 @@ namespace osu.Game.Tests.Skins
using (var stream = new LineBufferedReader(resStream))
Assert.That(decoder.Decode(stream).LegacyVersion, Is.EqualTo(1.0m));
}
+
+ [Test]
+ public void TestDecodeColourWithZeroAlpha()
+ {
+ var decoder = new LegacySkinDecoder();
+
+ using (var resStream = TestResources.OpenResource("skin-zero-alpha-colour.ini"))
+ using (var stream = new LineBufferedReader(resStream))
+ Assert.That(decoder.Decode(stream).ComboColours[0].A, Is.EqualTo(1.0f));
+ }
}
}
diff --git a/osu.Game.Tests/Visual/Gameplay/TestSceneFailingLayer.cs b/osu.Game.Tests/Visual/Gameplay/TestSceneFailingLayer.cs
index a95e806862..1c55595c97 100644
--- a/osu.Game.Tests/Visual/Gameplay/TestSceneFailingLayer.cs
+++ b/osu.Game.Tests/Visual/Gameplay/TestSceneFailingLayer.cs
@@ -3,6 +3,7 @@
using NUnit.Framework;
using osu.Framework.Allocation;
+using osu.Framework.Bindables;
using osu.Framework.Testing;
using osu.Game.Configuration;
using osu.Game.Rulesets.Scoring;
@@ -14,6 +15,8 @@ namespace osu.Game.Tests.Visual.Gameplay
{
private FailingLayer layer;
+ private readonly Bindable showHealth = new Bindable();
+
[Resolved]
private OsuConfigManager config { get; set; }
@@ -24,8 +27,10 @@ namespace osu.Game.Tests.Visual.Gameplay
{
Child = layer = new FailingLayer();
layer.BindHealthProcessor(new DrainingHealthProcessor(1));
+ layer.ShowHealth.BindTo(showHealth);
});
+ AddStep("show health", () => showHealth.Value = true);
AddStep("enable layer", () => config.Set(OsuSetting.FadePlayfieldWhenHealthLow, true));
AddUntilStep("layer is visible", () => layer.IsPresent);
}
@@ -69,5 +74,27 @@ namespace osu.Game.Tests.Visual.Gameplay
AddWaitStep("wait for potential fade", 10);
AddAssert("layer is still visible", () => layer.IsPresent);
}
+
+ [Test]
+ public void TestLayerVisibilityWithDifferentOptions()
+ {
+ AddStep("set health to 0.10", () => layer.Current.Value = 0.1);
+
+ AddStep("don't show health", () => showHealth.Value = false);
+ AddStep("disable FadePlayfieldWhenHealthLow", () => config.Set(OsuSetting.FadePlayfieldWhenHealthLow, false));
+ AddUntilStep("layer fade is invisible", () => !layer.IsPresent);
+
+ AddStep("don't show health", () => showHealth.Value = false);
+ AddStep("enable FadePlayfieldWhenHealthLow", () => config.Set(OsuSetting.FadePlayfieldWhenHealthLow, true));
+ AddUntilStep("layer fade is invisible", () => !layer.IsPresent);
+
+ AddStep("show health", () => showHealth.Value = true);
+ AddStep("disable FadePlayfieldWhenHealthLow", () => config.Set(OsuSetting.FadePlayfieldWhenHealthLow, false));
+ AddUntilStep("layer fade is invisible", () => !layer.IsPresent);
+
+ AddStep("show health", () => showHealth.Value = true);
+ AddStep("enable FadePlayfieldWhenHealthLow", () => config.Set(OsuSetting.FadePlayfieldWhenHealthLow, true));
+ AddUntilStep("layer fade is visible", () => layer.IsPresent);
+ }
}
}
diff --git a/osu.Game.Tests/Visual/Menus/IntroTestScene.cs b/osu.Game.Tests/Visual/Menus/IntroTestScene.cs
index 2d2f1a1618..f71d13ed35 100644
--- a/osu.Game.Tests/Visual/Menus/IntroTestScene.cs
+++ b/osu.Game.Tests/Visual/Menus/IntroTestScene.cs
@@ -19,10 +19,10 @@ namespace osu.Game.Tests.Visual.Menus
[Cached]
private OsuLogo logo;
+ protected OsuScreenStack IntroStack;
+
protected IntroTestScene()
{
- OsuScreenStack introStack = null;
-
Children = new Drawable[]
{
new Box
@@ -45,17 +45,17 @@ namespace osu.Game.Tests.Visual.Menus
logo.FinishTransforms();
logo.IsTracking = false;
- introStack?.Expire();
+ IntroStack?.Expire();
- Add(introStack = new OsuScreenStack
+ Add(IntroStack = new OsuScreenStack
{
RelativeSizeAxes = Axes.Both,
});
- introStack.Push(CreateScreen());
+ IntroStack.Push(CreateScreen());
});
- AddUntilStep("wait for menu", () => introStack.CurrentScreen is MainMenu);
+ AddUntilStep("wait for menu", () => IntroStack.CurrentScreen is MainMenu);
}
protected abstract IScreen CreateScreen();
diff --git a/osu.Game.Tests/Visual/Menus/TestSceneIntroWelcome.cs b/osu.Game.Tests/Visual/Menus/TestSceneIntroWelcome.cs
index 905f17ef0b..8f20e38494 100644
--- a/osu.Game.Tests/Visual/Menus/TestSceneIntroWelcome.cs
+++ b/osu.Game.Tests/Visual/Menus/TestSceneIntroWelcome.cs
@@ -2,6 +2,7 @@
// See the LICENCE file in the repository root for full licence text.
using NUnit.Framework;
+using osu.Framework.Audio.Track;
using osu.Framework.Screens;
using osu.Game.Screens.Menu;
@@ -11,5 +12,14 @@ namespace osu.Game.Tests.Visual.Menus
public class TestSceneIntroWelcome : IntroTestScene
{
protected override IScreen CreateScreen() => new IntroWelcome();
+
+ public TestSceneIntroWelcome()
+ {
+ AddUntilStep("wait for load", () => getTrack() != null);
+
+ AddAssert("check if menu music loops", () => getTrack().Looping);
+ }
+
+ private Track getTrack() => (IntroStack?.CurrentScreen as MainMenu)?.Track;
}
}
diff --git a/osu.Game.Tests/Visual/Ranking/TestSceneHitEventTimingDistributionGraph.cs b/osu.Game.Tests/Visual/Ranking/TestSceneHitEventTimingDistributionGraph.cs
new file mode 100644
index 0000000000..7ca1fc842f
--- /dev/null
+++ b/osu.Game.Tests/Visual/Ranking/TestSceneHitEventTimingDistributionGraph.cs
@@ -0,0 +1,71 @@
+// 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.Extensions.Color4Extensions;
+using osu.Framework.Graphics;
+using osu.Framework.Graphics.Shapes;
+using osu.Game.Rulesets.Osu.Objects;
+using osu.Game.Rulesets.Scoring;
+using osu.Game.Screens.Ranking.Statistics;
+using osuTK;
+
+namespace osu.Game.Tests.Visual.Ranking
+{
+ public class TestSceneHitEventTimingDistributionGraph : OsuTestScene
+ {
+ [Test]
+ public void TestManyDistributedEvents()
+ {
+ createTest(CreateDistributedHitEvents());
+ }
+
+ [Test]
+ public void TestZeroTimeOffset()
+ {
+ createTest(Enumerable.Range(0, 100).Select(_ => new HitEvent(0, HitResult.Perfect, new HitCircle(), new HitCircle(), null)).ToList());
+ }
+
+ [Test]
+ public void TestNoEvents()
+ {
+ createTest(new List());
+ }
+
+ private void createTest(List events) => AddStep("create test", () =>
+ {
+ Children = new Drawable[]
+ {
+ new Box
+ {
+ RelativeSizeAxes = Axes.Both,
+ Colour = Color4Extensions.FromHex("#333")
+ },
+ new HitEventTimingDistributionGraph(events)
+ {
+ Anchor = Anchor.Centre,
+ Origin = Anchor.Centre,
+ Size = new Vector2(600, 130)
+ }
+ };
+ });
+
+ public static List CreateDistributedHitEvents()
+ {
+ var hitEvents = new List();
+
+ for (int i = 0; i < 50; i++)
+ {
+ int count = (int)(Math.Pow(25 - Math.Abs(i - 25), 2));
+
+ for (int j = 0; j < count; j++)
+ hitEvents.Add(new HitEvent(i - 25, HitResult.Perfect, new HitCircle(), new HitCircle(), null));
+ }
+
+ return hitEvents;
+ }
+ }
+}
diff --git a/osu.Game.Tests/Visual/Ranking/TestSceneResultsScreen.cs b/osu.Game.Tests/Visual/Ranking/TestSceneResultsScreen.cs
index 125aa0a1e7..74808bc2f5 100644
--- a/osu.Game.Tests/Visual/Ranking/TestSceneResultsScreen.cs
+++ b/osu.Game.Tests/Visual/Ranking/TestSceneResultsScreen.cs
@@ -1,23 +1,32 @@
// 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 System.Threading.Tasks;
using NUnit.Framework;
using osu.Framework.Allocation;
using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers;
using osu.Framework.Screens;
+using osu.Framework.Testing;
+using osu.Framework.Utils;
using osu.Game.Beatmaps;
+using osu.Game.Online.API;
using osu.Game.Rulesets.Osu;
using osu.Game.Scoring;
using osu.Game.Screens;
using osu.Game.Screens.Play;
using osu.Game.Screens.Ranking;
+using osu.Game.Screens.Ranking.Statistics;
+using osuTK;
+using osuTK.Input;
namespace osu.Game.Tests.Visual.Ranking
{
[TestFixture]
- public class TestSceneResultsScreen : ScreenTestScene
+ public class TestSceneResultsScreen : OsuManualInputManagerTestScene
{
private BeatmapManager beatmaps;
@@ -41,7 +50,7 @@ namespace osu.Game.Tests.Visual.Ranking
private UnrankedSoloResultsScreen createUnrankedSoloResultsScreen() => new UnrankedSoloResultsScreen(new TestScoreInfo(new OsuRuleset().RulesetInfo));
[Test]
- public void ResultsWithoutPlayer()
+ public void TestResultsWithoutPlayer()
{
TestResultsScreen screen = null;
OsuScreenStack stack;
@@ -60,7 +69,7 @@ namespace osu.Game.Tests.Visual.Ranking
}
[Test]
- public void ResultsWithPlayer()
+ public void TestResultsWithPlayer()
{
TestResultsScreen screen = null;
@@ -70,7 +79,7 @@ namespace osu.Game.Tests.Visual.Ranking
}
[Test]
- public void ResultsForUnranked()
+ public void TestResultsForUnranked()
{
UnrankedSoloResultsScreen screen = null;
@@ -79,6 +88,130 @@ namespace osu.Game.Tests.Visual.Ranking
AddAssert("retry overlay present", () => screen.RetryOverlay != null);
}
+ [Test]
+ public void TestShowHideStatisticsViaOutsideClick()
+ {
+ TestResultsScreen screen = null;
+
+ AddStep("load results", () => Child = new TestResultsContainer(screen = createResultsScreen()));
+ AddUntilStep("wait for loaded", () => screen.IsLoaded);
+
+ AddStep("click expanded panel", () =>
+ {
+ var expandedPanel = this.ChildrenOfType().Single(p => p.State == PanelState.Expanded);
+ InputManager.MoveMouseTo(expandedPanel);
+ InputManager.Click(MouseButton.Left);
+ });
+
+ AddAssert("statistics shown", () => this.ChildrenOfType().Single().State.Value == Visibility.Visible);
+
+ AddUntilStep("expanded panel at the left of the screen", () =>
+ {
+ var expandedPanel = this.ChildrenOfType().Single(p => p.State == PanelState.Expanded);
+ return expandedPanel.ScreenSpaceDrawQuad.TopLeft.X - screen.ScreenSpaceDrawQuad.TopLeft.X < 150;
+ });
+
+ AddStep("click to right of panel", () =>
+ {
+ var expandedPanel = this.ChildrenOfType().Single(p => p.State == PanelState.Expanded);
+ InputManager.MoveMouseTo(expandedPanel.ScreenSpaceDrawQuad.TopRight + new Vector2(100, 0));
+ InputManager.Click(MouseButton.Left);
+ });
+
+ AddAssert("statistics hidden", () => this.ChildrenOfType().Single().State.Value == Visibility.Hidden);
+
+ AddUntilStep("expanded panel in centre of screen", () =>
+ {
+ var expandedPanel = this.ChildrenOfType().Single(p => p.State == PanelState.Expanded);
+ return Precision.AlmostEquals(expandedPanel.ScreenSpaceDrawQuad.Centre.X, screen.ScreenSpaceDrawQuad.Centre.X, 1);
+ });
+ }
+
+ [Test]
+ public void TestShowHideStatistics()
+ {
+ TestResultsScreen screen = null;
+
+ AddStep("load results", () => Child = new TestResultsContainer(screen = createResultsScreen()));
+ AddUntilStep("wait for loaded", () => screen.IsLoaded);
+
+ AddStep("click expanded panel", () =>
+ {
+ var expandedPanel = this.ChildrenOfType().Single(p => p.State == PanelState.Expanded);
+ InputManager.MoveMouseTo(expandedPanel);
+ InputManager.Click(MouseButton.Left);
+ });
+
+ AddAssert("statistics shown", () => this.ChildrenOfType().Single().State.Value == Visibility.Visible);
+
+ AddUntilStep("expanded panel at the left of the screen", () =>
+ {
+ var expandedPanel = this.ChildrenOfType().Single(p => p.State == PanelState.Expanded);
+ return expandedPanel.ScreenSpaceDrawQuad.TopLeft.X - screen.ScreenSpaceDrawQuad.TopLeft.X < 150;
+ });
+
+ AddStep("click expanded panel", () =>
+ {
+ var expandedPanel = this.ChildrenOfType().Single(p => p.State == PanelState.Expanded);
+ InputManager.MoveMouseTo(expandedPanel);
+ InputManager.Click(MouseButton.Left);
+ });
+
+ AddAssert("statistics hidden", () => this.ChildrenOfType().Single().State.Value == Visibility.Hidden);
+
+ AddUntilStep("expanded panel in centre of screen", () =>
+ {
+ var expandedPanel = this.ChildrenOfType().Single(p => p.State == PanelState.Expanded);
+ return Precision.AlmostEquals(expandedPanel.ScreenSpaceDrawQuad.Centre.X, screen.ScreenSpaceDrawQuad.Centre.X, 1);
+ });
+ }
+
+ [Test]
+ public void TestShowStatisticsAndClickOtherPanel()
+ {
+ TestResultsScreen screen = null;
+
+ AddStep("load results", () => Child = new TestResultsContainer(screen = createResultsScreen()));
+ AddUntilStep("wait for loaded", () => screen.IsLoaded);
+
+ ScorePanel expandedPanel = null;
+ ScorePanel contractedPanel = null;
+
+ AddStep("click expanded panel then contracted panel", () =>
+ {
+ expandedPanel = this.ChildrenOfType().Single(p => p.State == PanelState.Expanded);
+ InputManager.MoveMouseTo(expandedPanel);
+ InputManager.Click(MouseButton.Left);
+
+ contractedPanel = this.ChildrenOfType().First(p => p.State == PanelState.Contracted && p.ScreenSpaceDrawQuad.TopLeft.X > screen.ScreenSpaceDrawQuad.TopLeft.X);
+ InputManager.MoveMouseTo(contractedPanel);
+ InputManager.Click(MouseButton.Left);
+ });
+
+ AddAssert("statistics shown", () => this.ChildrenOfType().Single().State.Value == Visibility.Visible);
+
+ AddAssert("contracted panel still contracted", () => contractedPanel.State == PanelState.Contracted);
+ AddAssert("expanded panel still expanded", () => expandedPanel.State == PanelState.Expanded);
+ }
+
+ [Test]
+ public void TestFetchScoresAfterShowingStatistics()
+ {
+ DelayedFetchResultsScreen screen = null;
+
+ AddStep("load results", () => Child = new TestResultsContainer(screen = new DelayedFetchResultsScreen(new TestScoreInfo(new OsuRuleset().RulesetInfo), 3000)));
+ AddUntilStep("wait for loaded", () => screen.IsLoaded);
+ AddStep("click expanded panel", () =>
+ {
+ var expandedPanel = this.ChildrenOfType().Single(p => p.State == PanelState.Expanded);
+ InputManager.MoveMouseTo(expandedPanel);
+ InputManager.Click(MouseButton.Left);
+ });
+
+ AddUntilStep("wait for fetch", () => screen.FetchCompleted);
+ AddAssert("expanded panel still on screen", () => this.ChildrenOfType().Single(p => p.State == PanelState.Expanded).ScreenSpaceDrawQuad.TopLeft.X > 0);
+ }
+
private class TestResultsContainer : Container
{
[Cached(typeof(Player))]
@@ -113,6 +246,58 @@ namespace osu.Game.Tests.Visual.Ranking
RetryOverlay = InternalChildren.OfType().SingleOrDefault();
}
+
+ protected override APIRequest FetchScores(Action> scoresCallback)
+ {
+ var scores = new List();
+
+ for (int i = 0; i < 20; i++)
+ {
+ var score = new TestScoreInfo(new OsuRuleset().RulesetInfo);
+ score.TotalScore += 10 - i;
+ scores.Add(score);
+ }
+
+ scoresCallback?.Invoke(scores);
+
+ return null;
+ }
+ }
+
+ private class DelayedFetchResultsScreen : TestResultsScreen
+ {
+ public bool FetchCompleted { get; private set; }
+
+ private readonly double delay;
+
+ public DelayedFetchResultsScreen(ScoreInfo score, double delay)
+ : base(score)
+ {
+ this.delay = delay;
+ }
+
+ protected override APIRequest FetchScores(Action> scoresCallback)
+ {
+ Task.Run(async () =>
+ {
+ await Task.Delay(TimeSpan.FromMilliseconds(delay));
+
+ var scores = new List();
+
+ for (int i = 0; i < 20; i++)
+ {
+ var score = new TestScoreInfo(new OsuRuleset().RulesetInfo);
+ score.TotalScore += 10 - i;
+ scores.Add(score);
+ }
+
+ scoresCallback?.Invoke(scores);
+
+ Schedule(() => FetchCompleted = true);
+ });
+
+ return null;
+ }
}
private class UnrankedSoloResultsScreen : SoloResultsScreen
diff --git a/osu.Game.Tests/Visual/Ranking/TestSceneStatisticsPanel.cs b/osu.Game.Tests/Visual/Ranking/TestSceneStatisticsPanel.cs
new file mode 100644
index 0000000000..8700fbeb42
--- /dev/null
+++ b/osu.Game.Tests/Visual/Ranking/TestSceneStatisticsPanel.cs
@@ -0,0 +1,48 @@
+// 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.Graphics;
+using osu.Framework.Graphics.Containers;
+using osu.Game.Rulesets.Osu;
+using osu.Game.Scoring;
+using osu.Game.Screens.Ranking.Statistics;
+
+namespace osu.Game.Tests.Visual.Ranking
+{
+ public class TestSceneStatisticsPanel : OsuTestScene
+ {
+ [Test]
+ public void TestScoreWithStatistics()
+ {
+ var score = new TestScoreInfo(new OsuRuleset().RulesetInfo)
+ {
+ HitEvents = TestSceneHitEventTimingDistributionGraph.CreateDistributedHitEvents()
+ };
+
+ loadPanel(score);
+ }
+
+ [Test]
+ public void TestScoreWithoutStatistics()
+ {
+ loadPanel(new TestScoreInfo(new OsuRuleset().RulesetInfo));
+ }
+
+ [Test]
+ public void TestNullScore()
+ {
+ loadPanel(null);
+ }
+
+ private void loadPanel(ScoreInfo score) => AddStep("load panel", () =>
+ {
+ Child = new StatisticsPanel
+ {
+ RelativeSizeAxes = Axes.Both,
+ State = { Value = Visibility.Visible },
+ Score = { Value = score }
+ };
+ });
+ }
+}
diff --git a/osu.Game.Tests/Visual/SongSelect/TestSceneBeatmapCarousel.cs b/osu.Game.Tests/Visual/SongSelect/TestSceneBeatmapCarousel.cs
index 2f12194ede..073d75692e 100644
--- a/osu.Game.Tests/Visual/SongSelect/TestSceneBeatmapCarousel.cs
+++ b/osu.Game.Tests/Visual/SongSelect/TestSceneBeatmapCarousel.cs
@@ -17,11 +17,12 @@ using osu.Game.Rulesets;
using osu.Game.Screens.Select;
using osu.Game.Screens.Select.Carousel;
using osu.Game.Screens.Select.Filter;
+using osuTK.Input;
namespace osu.Game.Tests.Visual.SongSelect
{
[TestFixture]
- public class TestSceneBeatmapCarousel : OsuTestScene
+ public class TestSceneBeatmapCarousel : OsuManualInputManagerTestScene
{
private TestBeatmapCarousel carousel;
private RulesetStore rulesets;
@@ -39,6 +40,43 @@ namespace osu.Game.Tests.Visual.SongSelect
this.rulesets = rulesets;
}
+ [Test]
+ public void TestKeyRepeat()
+ {
+ loadBeatmaps();
+ advanceSelection(false);
+
+ AddStep("press down arrow", () => InputManager.PressKey(Key.Down));
+
+ BeatmapInfo selection = null;
+
+ checkSelectionIterating(true);
+
+ AddStep("press up arrow", () => InputManager.PressKey(Key.Up));
+
+ checkSelectionIterating(true);
+
+ AddStep("release down arrow", () => InputManager.ReleaseKey(Key.Down));
+
+ checkSelectionIterating(true);
+
+ AddStep("release up arrow", () => InputManager.ReleaseKey(Key.Up));
+
+ checkSelectionIterating(false);
+
+ void checkSelectionIterating(bool isIterating)
+ {
+ for (int i = 0; i < 3; i++)
+ {
+ AddStep("store selection", () => selection = carousel.SelectedBeatmap);
+ if (isIterating)
+ AddUntilStep("selection changed", () => carousel.SelectedBeatmap != selection);
+ else
+ AddUntilStep("selection not changed", () => carousel.SelectedBeatmap == selection);
+ }
+ }
+ }
+
[Test]
public void TestRecommendedSelection()
{
diff --git a/osu.Game.Tournament.Tests/Components/TestSceneMatchScoreDisplay.cs b/osu.Game.Tournament.Tests/Components/TestSceneMatchScoreDisplay.cs
index 77119f7a60..acd5d53310 100644
--- a/osu.Game.Tournament.Tests/Components/TestSceneMatchScoreDisplay.cs
+++ b/osu.Game.Tournament.Tests/Components/TestSceneMatchScoreDisplay.cs
@@ -9,7 +9,7 @@ using osu.Game.Tournament.Screens.Gameplay.Components;
namespace osu.Game.Tournament.Tests.Components
{
- public class TestSceneMatchScoreDisplay : LadderTestScene
+ public class TestSceneMatchScoreDisplay : TournamentTestScene
{
[Cached(Type = typeof(MatchIPCInfo))]
private MatchIPCInfo matchInfo = new MatchIPCInfo();
diff --git a/osu.Game.Tournament.Tests/Components/TestSceneTournamentBeatmapPanel.cs b/osu.Game.Tournament.Tests/Components/TestSceneTournamentBeatmapPanel.cs
index 77fa411058..bc32a12ab7 100644
--- a/osu.Game.Tournament.Tests/Components/TestSceneTournamentBeatmapPanel.cs
+++ b/osu.Game.Tournament.Tests/Components/TestSceneTournamentBeatmapPanel.cs
@@ -8,12 +8,11 @@ using osu.Game.Online.API;
using osu.Game.Online.API.Requests;
using osu.Game.Online.API.Requests.Responses;
using osu.Game.Rulesets;
-using osu.Game.Tests.Visual;
using osu.Game.Tournament.Components;
namespace osu.Game.Tournament.Tests.Components
{
- public class TestSceneTournamentBeatmapPanel : OsuTestScene
+ public class TestSceneTournamentBeatmapPanel : TournamentTestScene
{
[Resolved]
private IAPIProvider api { get; set; }
diff --git a/osu.Game.Tournament.Tests/LadderTestScene.cs b/osu.Game.Tournament.Tests/LadderTestScene.cs
deleted file mode 100644
index 2f4373679c..0000000000
--- a/osu.Game.Tournament.Tests/LadderTestScene.cs
+++ /dev/null
@@ -1,146 +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 System.Linq;
-using NUnit.Framework;
-using osu.Framework.Allocation;
-using osu.Framework.Utils;
-using osu.Game.Beatmaps;
-using osu.Game.Rulesets;
-using osu.Game.Tournament.Models;
-using osu.Game.Users;
-
-namespace osu.Game.Tournament.Tests
-{
- [TestFixture]
- public abstract class LadderTestScene : TournamentTestScene
- {
- [Cached]
- protected LadderInfo Ladder { get; private set; } = new LadderInfo();
-
- [Resolved]
- private RulesetStore rulesetStore { get; set; }
-
- [BackgroundDependencyLoader]
- private void load()
- {
- Ladder.Ruleset.Value ??= rulesetStore.AvailableRulesets.First();
-
- Ruleset.BindTo(Ladder.Ruleset);
- }
-
- protected override void LoadComplete()
- {
- base.LoadComplete();
-
- TournamentMatch match = CreateSampleMatch();
-
- Ladder.Rounds.Add(match.Round.Value);
- Ladder.Matches.Add(match);
- Ladder.Teams.Add(match.Team1.Value);
- Ladder.Teams.Add(match.Team2.Value);
-
- Ladder.CurrentMatch.Value = match;
- }
-
- public static TournamentMatch CreateSampleMatch() => new TournamentMatch
- {
- Team1 =
- {
- Value = new TournamentTeam
- {
- FlagName = { Value = "JP" },
- FullName = { Value = "Japan" },
- LastYearPlacing = { Value = 10 },
- Seed = { Value = "Low" },
- SeedingResults =
- {
- new SeedingResult
- {
- Mod = { Value = "NM" },
- Seed = { Value = 10 },
- Beatmaps =
- {
- new SeedingBeatmap
- {
- BeatmapInfo = CreateSampleBeatmapInfo(),
- Score = 12345672,
- Seed = { Value = 24 },
- },
- new SeedingBeatmap
- {
- BeatmapInfo = CreateSampleBeatmapInfo(),
- Score = 1234567,
- Seed = { Value = 12 },
- },
- new SeedingBeatmap
- {
- BeatmapInfo = CreateSampleBeatmapInfo(),
- Score = 1234567,
- Seed = { Value = 16 },
- }
- }
- },
- new SeedingResult
- {
- Mod = { Value = "DT" },
- Seed = { Value = 5 },
- Beatmaps =
- {
- new SeedingBeatmap
- {
- BeatmapInfo = CreateSampleBeatmapInfo(),
- Score = 234567,
- Seed = { Value = 3 },
- },
- new SeedingBeatmap
- {
- BeatmapInfo = CreateSampleBeatmapInfo(),
- Score = 234567,
- Seed = { Value = 6 },
- },
- new SeedingBeatmap
- {
- BeatmapInfo = CreateSampleBeatmapInfo(),
- Score = 234567,
- Seed = { Value = 12 },
- }
- }
- }
- },
- Players =
- {
- new User { Username = "Hello", Statistics = new UserStatistics { Ranks = new UserStatistics.UserRanks { Global = 12 } } },
- new User { Username = "Hello", Statistics = new UserStatistics { Ranks = new UserStatistics.UserRanks { Global = 16 } } },
- new User { Username = "Hello", Statistics = new UserStatistics { Ranks = new UserStatistics.UserRanks { Global = 20 } } },
- new User { Username = "Hello", Statistics = new UserStatistics { Ranks = new UserStatistics.UserRanks { Global = 24 } } },
- new User { Username = "Hello", Statistics = new UserStatistics { Ranks = new UserStatistics.UserRanks { Global = 30 } } },
- }
- }
- },
- Team2 =
- {
- Value = new TournamentTeam
- {
- FlagName = { Value = "US" },
- FullName = { Value = "United States" },
- Players =
- {
- new User { Username = "Hello" },
- new User { Username = "Hello" },
- new User { Username = "Hello" },
- new User { Username = "Hello" },
- new User { Username = "Hello" },
- }
- }
- },
- Round =
- {
- Value = new TournamentRound { Name = { Value = "Quarterfinals" } }
- }
- };
-
- public static BeatmapInfo CreateSampleBeatmapInfo() =>
- new BeatmapInfo { Metadata = new BeatmapMetadata { Title = "Test Title", Artist = "Test Artist", ID = RNG.Next(0, 1000000) } };
- }
-}
diff --git a/osu.Game.Tournament.Tests/Screens/TestSceneLadderEditorScreen.cs b/osu.Game.Tournament.Tests/Screens/TestSceneLadderEditorScreen.cs
index a45c5de2bd..bceb3e6b74 100644
--- a/osu.Game.Tournament.Tests/Screens/TestSceneLadderEditorScreen.cs
+++ b/osu.Game.Tournament.Tests/Screens/TestSceneLadderEditorScreen.cs
@@ -8,7 +8,7 @@ using osu.Game.Tournament.Screens.Editors;
namespace osu.Game.Tournament.Tests.Screens
{
- public class TestSceneLadderEditorScreen : LadderTestScene
+ public class TestSceneLadderEditorScreen : TournamentTestScene
{
[BackgroundDependencyLoader]
private void load()
diff --git a/osu.Game.Tournament.Tests/Screens/TestSceneLadderScreen.cs b/osu.Game.Tournament.Tests/Screens/TestSceneLadderScreen.cs
index 2be0564c82..c4c100d506 100644
--- a/osu.Game.Tournament.Tests/Screens/TestSceneLadderScreen.cs
+++ b/osu.Game.Tournament.Tests/Screens/TestSceneLadderScreen.cs
@@ -8,7 +8,7 @@ using osu.Game.Tournament.Screens.Ladder;
namespace osu.Game.Tournament.Tests.Screens
{
- public class TestSceneLadderScreen : LadderTestScene
+ public class TestSceneLadderScreen : TournamentTestScene
{
[BackgroundDependencyLoader]
private void load()
diff --git a/osu.Game.Tournament.Tests/Screens/TestSceneMapPoolScreen.cs b/osu.Game.Tournament.Tests/Screens/TestSceneMapPoolScreen.cs
index a4538be384..f4032fdd54 100644
--- a/osu.Game.Tournament.Tests/Screens/TestSceneMapPoolScreen.cs
+++ b/osu.Game.Tournament.Tests/Screens/TestSceneMapPoolScreen.cs
@@ -12,7 +12,7 @@ using osu.Game.Tournament.Screens.MapPool;
namespace osu.Game.Tournament.Tests.Screens
{
- public class TestSceneMapPoolScreen : LadderTestScene
+ public class TestSceneMapPoolScreen : TournamentTestScene
{
private MapPoolScreen screen;
diff --git a/osu.Game.Tournament.Tests/Screens/TestSceneRoundEditorScreen.cs b/osu.Game.Tournament.Tests/Screens/TestSceneRoundEditorScreen.cs
index e15ac416b0..5c2b59df3a 100644
--- a/osu.Game.Tournament.Tests/Screens/TestSceneRoundEditorScreen.cs
+++ b/osu.Game.Tournament.Tests/Screens/TestSceneRoundEditorScreen.cs
@@ -5,7 +5,7 @@ using osu.Game.Tournament.Screens.Editors;
namespace osu.Game.Tournament.Tests.Screens
{
- public class TestSceneRoundEditorScreen : LadderTestScene
+ public class TestSceneRoundEditorScreen : TournamentTestScene
{
public TestSceneRoundEditorScreen()
{
diff --git a/osu.Game.Tournament.Tests/Screens/TestSceneSeedingEditorScreen.cs b/osu.Game.Tournament.Tests/Screens/TestSceneSeedingEditorScreen.cs
index 8d12d5393d..2722021216 100644
--- a/osu.Game.Tournament.Tests/Screens/TestSceneSeedingEditorScreen.cs
+++ b/osu.Game.Tournament.Tests/Screens/TestSceneSeedingEditorScreen.cs
@@ -7,7 +7,7 @@ using osu.Game.Tournament.Screens.Editors;
namespace osu.Game.Tournament.Tests.Screens
{
- public class TestSceneSeedingEditorScreen : LadderTestScene
+ public class TestSceneSeedingEditorScreen : TournamentTestScene
{
[Cached]
private readonly LadderInfo ladder = new LadderInfo();
diff --git a/osu.Game.Tournament.Tests/Screens/TestSceneSeedingScreen.cs b/osu.Game.Tournament.Tests/Screens/TestSceneSeedingScreen.cs
index 4269f8f56a..d414d8e36e 100644
--- a/osu.Game.Tournament.Tests/Screens/TestSceneSeedingScreen.cs
+++ b/osu.Game.Tournament.Tests/Screens/TestSceneSeedingScreen.cs
@@ -8,7 +8,7 @@ using osu.Game.Tournament.Screens.TeamIntro;
namespace osu.Game.Tournament.Tests.Screens
{
- public class TestSceneSeedingScreen : LadderTestScene
+ public class TestSceneSeedingScreen : TournamentTestScene
{
[Cached]
private readonly LadderInfo ladder = new LadderInfo();
diff --git a/osu.Game.Tournament.Tests/Screens/TestSceneTeamEditorScreen.cs b/osu.Game.Tournament.Tests/Screens/TestSceneTeamEditorScreen.cs
index 097bad4a02..fc6574ec8a 100644
--- a/osu.Game.Tournament.Tests/Screens/TestSceneTeamEditorScreen.cs
+++ b/osu.Game.Tournament.Tests/Screens/TestSceneTeamEditorScreen.cs
@@ -5,7 +5,7 @@ using osu.Game.Tournament.Screens.Editors;
namespace osu.Game.Tournament.Tests.Screens
{
- public class TestSceneTeamEditorScreen : LadderTestScene
+ public class TestSceneTeamEditorScreen : TournamentTestScene
{
public TestSceneTeamEditorScreen()
{
diff --git a/osu.Game.Tournament.Tests/Screens/TestSceneTeamIntroScreen.cs b/osu.Game.Tournament.Tests/Screens/TestSceneTeamIntroScreen.cs
index e36b594ff2..b3f78c92d9 100644
--- a/osu.Game.Tournament.Tests/Screens/TestSceneTeamIntroScreen.cs
+++ b/osu.Game.Tournament.Tests/Screens/TestSceneTeamIntroScreen.cs
@@ -9,7 +9,7 @@ using osu.Game.Tournament.Screens.TeamIntro;
namespace osu.Game.Tournament.Tests.Screens
{
- public class TestSceneTeamIntroScreen : LadderTestScene
+ public class TestSceneTeamIntroScreen : TournamentTestScene
{
[Cached]
private readonly LadderInfo ladder = new LadderInfo();
diff --git a/osu.Game.Tournament.Tests/Screens/TestSceneTeamWinScreen.cs b/osu.Game.Tournament.Tests/Screens/TestSceneTeamWinScreen.cs
index 1a2faa76c1..3ca58dcaf4 100644
--- a/osu.Game.Tournament.Tests/Screens/TestSceneTeamWinScreen.cs
+++ b/osu.Game.Tournament.Tests/Screens/TestSceneTeamWinScreen.cs
@@ -4,25 +4,19 @@
using System.Linq;
using osu.Framework.Allocation;
using osu.Framework.Graphics;
-using osu.Game.Tournament.Models;
using osu.Game.Tournament.Screens.TeamWin;
namespace osu.Game.Tournament.Tests.Screens
{
- public class TestSceneTeamWinScreen : LadderTestScene
+ public class TestSceneTeamWinScreen : TournamentTestScene
{
- [Cached]
- private readonly LadderInfo ladder = new LadderInfo();
-
[BackgroundDependencyLoader]
private void load()
{
- var match = new TournamentMatch();
- match.Team1.Value = Ladder.Teams.FirstOrDefault(t => t.Acronym.Value == "USA");
- match.Team2.Value = Ladder.Teams.FirstOrDefault(t => t.Acronym.Value == "JPN");
+ var match = Ladder.CurrentMatch.Value;
+
match.Round.Value = Ladder.Rounds.FirstOrDefault(g => g.Name.Value == "Finals");
match.Completed.Value = true;
- ladder.CurrentMatch.Value = match;
Add(new TeamWinScreen
{
diff --git a/osu.Game.Tournament.Tests/TournamentTestScene.cs b/osu.Game.Tournament.Tests/TournamentTestScene.cs
index 18ac3230da..d22da25f9d 100644
--- a/osu.Game.Tournament.Tests/TournamentTestScene.cs
+++ b/osu.Game.Tournament.Tests/TournamentTestScene.cs
@@ -1,13 +1,151 @@
// 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 osu.Framework.Allocation;
+using osu.Framework.Platform;
using osu.Framework.Testing;
+using osu.Framework.Utils;
+using osu.Game.Beatmaps;
+using osu.Game.Rulesets;
using osu.Game.Tests.Visual;
+using osu.Game.Tournament.IPC;
+using osu.Game.Tournament.Models;
+using osu.Game.Users;
namespace osu.Game.Tournament.Tests
{
public abstract class TournamentTestScene : OsuTestScene
{
+ [Cached]
+ protected LadderInfo Ladder { get; private set; } = new LadderInfo();
+
+ [Resolved]
+ private RulesetStore rulesetStore { get; set; }
+
+ [Cached]
+ protected MatchIPCInfo IPCInfo { get; private set; } = new MatchIPCInfo();
+
+ [BackgroundDependencyLoader]
+ private void load(Storage storage)
+ {
+ Ladder.Ruleset.Value ??= rulesetStore.AvailableRulesets.First();
+
+ TournamentMatch match = CreateSampleMatch();
+
+ Ladder.Rounds.Add(match.Round.Value);
+ Ladder.Matches.Add(match);
+ Ladder.Teams.Add(match.Team1.Value);
+ Ladder.Teams.Add(match.Team2.Value);
+
+ Ladder.CurrentMatch.Value = match;
+
+ Ruleset.BindTo(Ladder.Ruleset);
+ Dependencies.CacheAs(new StableInfo(storage));
+ }
+
+ public static TournamentMatch CreateSampleMatch() => new TournamentMatch
+ {
+ Team1 =
+ {
+ Value = new TournamentTeam
+ {
+ Acronym = { Value = "JPN" },
+ FlagName = { Value = "JP" },
+ FullName = { Value = "Japan" },
+ LastYearPlacing = { Value = 10 },
+ Seed = { Value = "Low" },
+ SeedingResults =
+ {
+ new SeedingResult
+ {
+ Mod = { Value = "NM" },
+ Seed = { Value = 10 },
+ Beatmaps =
+ {
+ new SeedingBeatmap
+ {
+ BeatmapInfo = CreateSampleBeatmapInfo(),
+ Score = 12345672,
+ Seed = { Value = 24 },
+ },
+ new SeedingBeatmap
+ {
+ BeatmapInfo = CreateSampleBeatmapInfo(),
+ Score = 1234567,
+ Seed = { Value = 12 },
+ },
+ new SeedingBeatmap
+ {
+ BeatmapInfo = CreateSampleBeatmapInfo(),
+ Score = 1234567,
+ Seed = { Value = 16 },
+ }
+ }
+ },
+ new SeedingResult
+ {
+ Mod = { Value = "DT" },
+ Seed = { Value = 5 },
+ Beatmaps =
+ {
+ new SeedingBeatmap
+ {
+ BeatmapInfo = CreateSampleBeatmapInfo(),
+ Score = 234567,
+ Seed = { Value = 3 },
+ },
+ new SeedingBeatmap
+ {
+ BeatmapInfo = CreateSampleBeatmapInfo(),
+ Score = 234567,
+ Seed = { Value = 6 },
+ },
+ new SeedingBeatmap
+ {
+ BeatmapInfo = CreateSampleBeatmapInfo(),
+ Score = 234567,
+ Seed = { Value = 12 },
+ }
+ }
+ }
+ },
+ Players =
+ {
+ new User { Username = "Hello", Statistics = new UserStatistics { Ranks = new UserStatistics.UserRanks { Global = 12 } } },
+ new User { Username = "Hello", Statistics = new UserStatistics { Ranks = new UserStatistics.UserRanks { Global = 16 } } },
+ new User { Username = "Hello", Statistics = new UserStatistics { Ranks = new UserStatistics.UserRanks { Global = 20 } } },
+ new User { Username = "Hello", Statistics = new UserStatistics { Ranks = new UserStatistics.UserRanks { Global = 24 } } },
+ new User { Username = "Hello", Statistics = new UserStatistics { Ranks = new UserStatistics.UserRanks { Global = 30 } } },
+ }
+ }
+ },
+ Team2 =
+ {
+ Value = new TournamentTeam
+ {
+ Acronym = { Value = "USA" },
+ FlagName = { Value = "US" },
+ FullName = { Value = "United States" },
+ Players =
+ {
+ new User { Username = "Hello" },
+ new User { Username = "Hello" },
+ new User { Username = "Hello" },
+ new User { Username = "Hello" },
+ new User { Username = "Hello" },
+ }
+ }
+ },
+ Round =
+ {
+ Value = new TournamentRound { Name = { Value = "Quarterfinals" } }
+ }
+ };
+
+ public static BeatmapInfo CreateSampleBeatmapInfo() =>
+ new BeatmapInfo { Metadata = new BeatmapMetadata { Title = "Test Title", Artist = "Test Artist", ID = RNG.Next(0, 1000000) } };
+
protected override ITestSceneTestRunner CreateRunner() => new TournamentTestSceneTestRunner();
public class TournamentTestSceneTestRunner : TournamentGameBase, ITestSceneTestRunner
diff --git a/osu.Game.Tournament/Components/SongBar.cs b/osu.Game.Tournament/Components/SongBar.cs
index fc7fcef892..cafec0a88b 100644
--- a/osu.Game.Tournament/Components/SongBar.cs
+++ b/osu.Game.Tournament/Components/SongBar.cs
@@ -6,6 +6,7 @@ using osu.Framework.Allocation;
using osu.Framework.Bindables;
using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers;
+using osu.Framework.Graphics.Primitives;
using osu.Framework.Graphics.Shapes;
using osu.Framework.Graphics.Sprites;
using osu.Game.Beatmaps;
@@ -66,6 +67,9 @@ namespace osu.Game.Tournament.Components
}
}
+ // Todo: This is a hack for https://github.com/ppy/osu-framework/issues/3617 since this container is at the very edge of the screen and potentially initially masked away.
+ protected override bool ComputeIsMaskedAway(RectangleF maskingBounds) => false;
+
[BackgroundDependencyLoader]
private void load()
{
@@ -77,8 +81,6 @@ namespace osu.Game.Tournament.Components
flow = new FillFlowContainer
{
RelativeSizeAxes = Axes.X,
- // Todo: This is a hack for https://github.com/ppy/osu-framework/issues/3617 since this container is at the very edge of the screen and potentially initially masked away.
- Height = 1,
AutoSizeAxes = Axes.Y,
LayoutDuration = 500,
LayoutEasing = Easing.OutQuint,
diff --git a/osu.Game.Tournament/TournamentSceneManager.cs b/osu.Game.Tournament/TournamentSceneManager.cs
index 23fcb01db7..2c539cdd43 100644
--- a/osu.Game.Tournament/TournamentSceneManager.cs
+++ b/osu.Game.Tournament/TournamentSceneManager.cs
@@ -37,7 +37,7 @@ namespace osu.Game.Tournament
public const float STREAM_AREA_WIDTH = 1366;
- public const double REQUIRED_WIDTH = TournamentSceneManager.CONTROL_AREA_WIDTH * 2 + TournamentSceneManager.STREAM_AREA_WIDTH;
+ public const double REQUIRED_WIDTH = CONTROL_AREA_WIDTH * 2 + STREAM_AREA_WIDTH;
[Cached]
private TournamentMatchChatDisplay chat = new TournamentMatchChatDisplay();
diff --git a/osu.Game/Beatmaps/BeatmapManager.cs b/osu.Game/Beatmaps/BeatmapManager.cs
index 2cf3a21975..637833fb5d 100644
--- a/osu.Game/Beatmaps/BeatmapManager.cs
+++ b/osu.Game/Beatmaps/BeatmapManager.cs
@@ -240,6 +240,9 @@ namespace osu.Game.Beatmaps
beatmapInfo = QueryBeatmap(b => b.ID == info.ID);
}
+ if (beatmapInfo == null)
+ return DefaultBeatmap;
+
lock (workingCache)
{
var working = workingCache.FirstOrDefault(w => w.BeatmapInfo?.ID == beatmapInfo.ID);
diff --git a/osu.Game/Beatmaps/Formats/LegacyBeatmapEncoder.cs b/osu.Game/Beatmaps/Formats/LegacyBeatmapEncoder.cs
index cefb47893c..57555cce90 100644
--- a/osu.Game/Beatmaps/Formats/LegacyBeatmapEncoder.cs
+++ b/osu.Game/Beatmaps/Formats/LegacyBeatmapEncoder.cs
@@ -218,7 +218,7 @@ namespace osu.Game.Beatmaps.Formats
break;
case 2:
- position.X = ((IHasXPosition)hitObject).X * 512;
+ position.X = ((IHasXPosition)hitObject).X;
break;
case 3:
diff --git a/osu.Game/Beatmaps/Formats/LegacyDecoder.cs b/osu.Game/Beatmaps/Formats/LegacyDecoder.cs
index 6406bd88a5..a0e83554a3 100644
--- a/osu.Game/Beatmaps/Formats/LegacyDecoder.cs
+++ b/osu.Game/Beatmaps/Formats/LegacyDecoder.cs
@@ -103,7 +103,12 @@ namespace osu.Game.Beatmaps.Formats
try
{
- colour = new Color4(byte.Parse(split[0]), byte.Parse(split[1]), byte.Parse(split[2]), split.Length == 4 ? byte.Parse(split[3]) : (byte)255);
+ byte alpha = split.Length == 4 ? byte.Parse(split[3]) : (byte)255;
+
+ if (alpha == 0)
+ alpha = 255;
+
+ colour = new Color4(byte.Parse(split[0]), byte.Parse(split[1]), byte.Parse(split[2]), alpha);
}
catch
{
diff --git a/osu.Game/Beatmaps/Formats/Parsing.cs b/osu.Game/Beatmaps/Formats/Parsing.cs
index c3efb8c760..c4795a6931 100644
--- a/osu.Game/Beatmaps/Formats/Parsing.cs
+++ b/osu.Game/Beatmaps/Formats/Parsing.cs
@@ -11,7 +11,7 @@ namespace osu.Game.Beatmaps.Formats
///
public static class Parsing
{
- public const int MAX_COORDINATE_VALUE = 65536;
+ public const int MAX_COORDINATE_VALUE = 131072;
public const double MAX_PARSE_VALUE = int.MaxValue;
diff --git a/osu.Game/IO/OsuStorage.cs b/osu.Game/IO/OsuStorage.cs
index 499bcb4063..1d15294666 100644
--- a/osu.Game/IO/OsuStorage.cs
+++ b/osu.Game/IO/OsuStorage.cs
@@ -2,9 +2,11 @@
// See the LICENCE file in the repository root for full licence text.
using System;
+using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Threading;
+using JetBrains.Annotations;
using osu.Framework.Logging;
using osu.Framework.Platform;
using osu.Game.Configuration;
@@ -13,28 +15,86 @@ namespace osu.Game.IO
{
public class OsuStorage : WrappedStorage
{
+ ///
+ /// Indicates the error (if any) that occurred when initialising the custom storage during initial startup.
+ ///
+ public readonly OsuStorageError Error;
+
+ ///
+ /// The custom storage path as selected by the user.
+ ///
+ [CanBeNull]
+ public string CustomStoragePath => storageConfig.Get(StorageConfig.FullPath);
+
+ ///
+ /// The default storage path to be used if a custom storage path hasn't been selected or is not accessible.
+ ///
+ [NotNull]
+ public string DefaultStoragePath => defaultStorage.GetFullPath(".");
+
private readonly GameHost host;
private readonly StorageConfigManager storageConfig;
+ private readonly Storage defaultStorage;
- internal static readonly string[] IGNORE_DIRECTORIES = { "cache" };
+ public static readonly string[] IGNORE_DIRECTORIES = { "cache" };
- internal static readonly string[] IGNORE_FILES =
+ public static readonly string[] IGNORE_FILES =
{
"framework.ini",
"storage.ini"
};
- public OsuStorage(GameHost host)
- : base(host.Storage, string.Empty)
+ public OsuStorage(GameHost host, Storage defaultStorage)
+ : base(defaultStorage, string.Empty)
{
this.host = host;
+ this.defaultStorage = defaultStorage;
- storageConfig = new StorageConfigManager(host.Storage);
+ storageConfig = new StorageConfigManager(defaultStorage);
- var customStoragePath = storageConfig.Get(StorageConfig.FullPath);
+ if (!string.IsNullOrEmpty(CustomStoragePath))
+ TryChangeToCustomStorage(out Error);
+ }
- if (!string.IsNullOrEmpty(customStoragePath))
- ChangeTargetStorage(host.GetStorage(customStoragePath));
+ ///
+ /// Resets the custom storage path, changing the target storage to the default location.
+ ///
+ public void ResetCustomStoragePath()
+ {
+ storageConfig.Set(StorageConfig.FullPath, string.Empty);
+ storageConfig.Save();
+
+ ChangeTargetStorage(defaultStorage);
+ }
+
+ ///
+ /// Attempts to change to the user's custom storage path.
+ ///
+ /// The error that occurred.
+ /// Whether the custom storage path was used successfully. If not, will be populated with the reason.
+ public bool TryChangeToCustomStorage(out OsuStorageError error)
+ {
+ Debug.Assert(!string.IsNullOrEmpty(CustomStoragePath));
+
+ error = OsuStorageError.None;
+ Storage lastStorage = UnderlyingStorage;
+
+ try
+ {
+ Storage userStorage = host.GetStorage(CustomStoragePath);
+
+ if (!userStorage.ExistsDirectory(".") || !userStorage.GetFiles(".").Any())
+ error = OsuStorageError.AccessibleButEmpty;
+
+ ChangeTargetStorage(userStorage);
+ }
+ catch
+ {
+ error = OsuStorageError.NotAccessible;
+ ChangeTargetStorage(lastStorage);
+ }
+
+ return error == OsuStorageError.None;
}
protected override void ChangeTargetStorage(Storage newStorage)
@@ -145,4 +205,23 @@ namespace osu.Game.IO
}
}
}
+
+ public enum OsuStorageError
+ {
+ ///
+ /// No error.
+ ///
+ None,
+
+ ///
+ /// Occurs when the target storage directory is accessible but does not already contain game files.
+ /// Only happens when the user changes the storage directory and then moves the files manually or mounts a different device to the same path.
+ ///
+ AccessibleButEmpty,
+
+ ///
+ /// Occurs when the target storage directory cannot be accessed at all.
+ ///
+ NotAccessible,
+ }
}
diff --git a/osu.Game/OsuGame.cs b/osu.Game/OsuGame.cs
index b0d7b14d34..92233f143d 100644
--- a/osu.Game/OsuGame.cs
+++ b/osu.Game/OsuGame.cs
@@ -767,7 +767,7 @@ namespace osu.Game
Text = "Subsequent messages have been logged. Click to view log files.",
Activated = () =>
{
- Host.Storage.GetStorageForDirectory("logs").OpenInNativeExplorer();
+ Storage.GetStorageForDirectory("logs").OpenInNativeExplorer();
return true;
}
}));
diff --git a/osu.Game/OsuGameBase.cs b/osu.Game/OsuGameBase.cs
index 3e7311092e..c79f710151 100644
--- a/osu.Game/OsuGameBase.cs
+++ b/osu.Game/OsuGameBase.cs
@@ -312,11 +312,13 @@ namespace osu.Game
base.SetHost(host);
// may be non-null for certain tests
- Storage ??= new OsuStorage(host);
+ Storage ??= host.Storage;
LocalConfig ??= new OsuConfigManager(Storage);
}
+ protected override Storage CreateStorage(GameHost host, Storage defaultStorage) => new OsuStorage(host, defaultStorage);
+
private readonly List fileImporters = new List();
public async Task Import(params string[] paths)
diff --git a/osu.Game/Overlays/Dialog/PopupDialog.cs b/osu.Game/Overlays/Dialog/PopupDialog.cs
index 02ef900dc5..1bcbe4dd2f 100644
--- a/osu.Game/Overlays/Dialog/PopupDialog.cs
+++ b/osu.Game/Overlays/Dialog/PopupDialog.cs
@@ -42,25 +42,34 @@ namespace osu.Game.Overlays.Dialog
set => icon.Icon = value;
}
- private string text;
+ private string headerText;
public string HeaderText
{
- get => text;
+ get => headerText;
set
{
- if (text == value)
+ if (headerText == value)
return;
- text = value;
-
+ headerText = value;
header.Text = value;
}
}
+ private string bodyText;
+
public string BodyText
{
- set => body.Text = value;
+ get => bodyText;
+ set
+ {
+ if (bodyText == value)
+ return;
+
+ bodyText = value;
+ body.Text = value;
+ }
}
public IEnumerable Buttons
diff --git a/osu.Game/Rulesets/Mods/IApplicableToAudio.cs b/osu.Game/Rulesets/Mods/IApplicableToAudio.cs
new file mode 100644
index 0000000000..901da7af55
--- /dev/null
+++ b/osu.Game/Rulesets/Mods/IApplicableToAudio.cs
@@ -0,0 +1,9 @@
+// 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.Mods
+{
+ public interface IApplicableToAudio : IApplicableToTrack, IApplicableToSample
+ {
+ }
+}
diff --git a/osu.Game/Rulesets/Mods/IApplicableToSample.cs b/osu.Game/Rulesets/Mods/IApplicableToSample.cs
new file mode 100644
index 0000000000..559d127cfc
--- /dev/null
+++ b/osu.Game/Rulesets/Mods/IApplicableToSample.cs
@@ -0,0 +1,15 @@
+// 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.Sample;
+
+namespace osu.Game.Rulesets.Mods
+{
+ ///
+ /// An interface for mods that make adjustments to a sample.
+ ///
+ public interface IApplicableToSample : IApplicableMod
+ {
+ void ApplyToSample(SampleChannel sample);
+ }
+}
diff --git a/osu.Game/Rulesets/Mods/ModFlashlight.cs b/osu.Game/Rulesets/Mods/ModFlashlight.cs
index 35a8334237..6e94a84e7d 100644
--- a/osu.Game/Rulesets/Mods/ModFlashlight.cs
+++ b/osu.Game/Rulesets/Mods/ModFlashlight.cs
@@ -47,9 +47,25 @@ namespace osu.Game.Rulesets.Mods
public void ApplyToScoreProcessor(ScoreProcessor scoreProcessor)
{
Combo.BindTo(scoreProcessor.Combo);
+
+ // Default value of ScoreProcessor's Rank in Flashlight Mod should be SS+
+ scoreProcessor.Rank.Value = ScoreRank.XH;
}
- public ScoreRank AdjustRank(ScoreRank rank, double accuracy) => rank;
+ public ScoreRank AdjustRank(ScoreRank rank, double accuracy)
+ {
+ switch (rank)
+ {
+ case ScoreRank.X:
+ return ScoreRank.XH;
+
+ case ScoreRank.S:
+ return ScoreRank.SH;
+
+ default:
+ return rank;
+ }
+ }
public virtual void ApplyToDrawableRuleset(DrawableRuleset drawableRuleset)
{
diff --git a/osu.Game/Rulesets/Mods/ModRateAdjust.cs b/osu.Game/Rulesets/Mods/ModRateAdjust.cs
index cb2ff149f1..874384686f 100644
--- a/osu.Game/Rulesets/Mods/ModRateAdjust.cs
+++ b/osu.Game/Rulesets/Mods/ModRateAdjust.cs
@@ -2,12 +2,13 @@
// See the LICENCE file in the repository root for full licence text.
using osu.Framework.Audio;
+using osu.Framework.Audio.Sample;
using osu.Framework.Audio.Track;
using osu.Framework.Bindables;
namespace osu.Game.Rulesets.Mods
{
- public abstract class ModRateAdjust : Mod, IApplicableToTrack
+ public abstract class ModRateAdjust : Mod, IApplicableToAudio
{
public abstract BindableNumber SpeedChange { get; }
@@ -16,6 +17,11 @@ namespace osu.Game.Rulesets.Mods
track.AddAdjustment(AdjustableProperty.Tempo, SpeedChange);
}
+ public virtual void ApplyToSample(SampleChannel sample)
+ {
+ sample.AddAdjustment(AdjustableProperty.Frequency, SpeedChange);
+ }
+
public override string SettingDescription => SpeedChange.IsDefault ? string.Empty : $"{SpeedChange.Value:N2}x";
}
}
diff --git a/osu.Game/Rulesets/Mods/ModTimeRamp.cs b/osu.Game/Rulesets/Mods/ModTimeRamp.cs
index df059eef7d..839d97f04e 100644
--- a/osu.Game/Rulesets/Mods/ModTimeRamp.cs
+++ b/osu.Game/Rulesets/Mods/ModTimeRamp.cs
@@ -10,10 +10,11 @@ using osu.Game.Beatmaps;
using osu.Game.Configuration;
using osu.Game.Rulesets.UI;
using osu.Game.Rulesets.Objects;
+using osu.Framework.Audio.Sample;
namespace osu.Game.Rulesets.Mods
{
- public abstract class ModTimeRamp : Mod, IUpdatableByPlayfield, IApplicableToBeatmap, IApplicableToTrack
+ public abstract class ModTimeRamp : Mod, IUpdatableByPlayfield, IApplicableToBeatmap, IApplicableToAudio
{
///
/// The point in the beatmap at which the final ramping rate should be reached.
@@ -58,6 +59,11 @@ namespace osu.Game.Rulesets.Mods
AdjustPitch.TriggerChange();
}
+ public void ApplyToSample(SampleChannel sample)
+ {
+ sample.AddAdjustment(AdjustableProperty.Frequency, SpeedChange);
+ }
+
public virtual void ApplyToBeatmap(IBeatmap beatmap)
{
HitObject lastObject = beatmap.HitObjects.LastOrDefault();
@@ -83,9 +89,9 @@ namespace osu.Game.Rulesets.Mods
private void applyPitchAdjustment(ValueChangedEvent adjustPitchSetting)
{
// remove existing old adjustment
- track.RemoveAdjustment(adjustmentForPitchSetting(adjustPitchSetting.OldValue), SpeedChange);
+ track?.RemoveAdjustment(adjustmentForPitchSetting(adjustPitchSetting.OldValue), SpeedChange);
- track.AddAdjustment(adjustmentForPitchSetting(adjustPitchSetting.NewValue), SpeedChange);
+ track?.AddAdjustment(adjustmentForPitchSetting(adjustPitchSetting.NewValue), SpeedChange);
}
private AdjustableProperty adjustmentForPitchSetting(bool adjustPitchSettingValue)
diff --git a/osu.Game/Rulesets/Objects/Legacy/ConvertHitObjectParser.cs b/osu.Game/Rulesets/Objects/Legacy/ConvertHitObjectParser.cs
index 9e936c7717..77075b2abe 100644
--- a/osu.Game/Rulesets/Objects/Legacy/ConvertHitObjectParser.cs
+++ b/osu.Game/Rulesets/Objects/Legacy/ConvertHitObjectParser.cs
@@ -12,6 +12,7 @@ using System.Linq;
using JetBrains.Annotations;
using osu.Framework.Utils;
using osu.Game.Beatmaps.Legacy;
+using osu.Game.Skinning;
namespace osu.Game.Rulesets.Objects.Legacy
{
@@ -356,7 +357,10 @@ namespace osu.Game.Rulesets.Objects.Legacy
Bank = bankInfo.Normal,
Name = HitSampleInfo.HIT_NORMAL,
Volume = bankInfo.Volume,
- CustomSampleBank = bankInfo.CustomSampleBank
+ CustomSampleBank = bankInfo.CustomSampleBank,
+ // if the sound type doesn't have the Normal flag set, attach it anyway as a layered sample.
+ // None also counts as a normal non-layered sample: https://osu.ppy.sh/help/wiki/osu!_File_Formats/Osu_(file_format)#hitsounds
+ IsLayered = type != LegacyHitSoundType.None && !type.HasFlag(LegacyHitSoundType.Normal)
}
};
@@ -409,7 +413,7 @@ namespace osu.Game.Rulesets.Objects.Legacy
public SampleBankInfo Clone() => (SampleBankInfo)MemberwiseClone();
}
- internal class LegacyHitSampleInfo : HitSampleInfo
+ public class LegacyHitSampleInfo : HitSampleInfo
{
private int customSampleBank;
@@ -424,6 +428,15 @@ namespace osu.Game.Rulesets.Objects.Legacy
Suffix = value.ToString();
}
}
+
+ ///
+ /// Whether this hit sample is layered.
+ ///
+ ///
+ /// Layered hit samples are automatically added in all modes (except osu!mania), but can be disabled
+ /// using the skin config option.
+ ///
+ public bool IsLayered { get; set; }
}
private class FileHitSampleInfo : LegacyHitSampleInfo
diff --git a/osu.Game/Rulesets/Ruleset.cs b/osu.Game/Rulesets/Ruleset.cs
index 4f28607733..3a7f433a37 100644
--- a/osu.Game/Rulesets/Ruleset.cs
+++ b/osu.Game/Rulesets/Ruleset.cs
@@ -23,6 +23,7 @@ using osu.Game.Scoring;
using osu.Game.Skinning;
using osu.Game.Users;
using JetBrains.Annotations;
+using osu.Game.Screens.Ranking.Statistics;
namespace osu.Game.Rulesets
{
@@ -208,5 +209,14 @@ namespace osu.Game.Rulesets
///
/// An empty frame for the current ruleset, or null if unsupported.
public virtual IConvertibleReplayFrame CreateConvertibleReplayFrame() => null;
+
+ ///
+ /// Creates the statistics for a to be displayed in the results screen.
+ ///
+ /// The to create the statistics for. The score is guaranteed to have populated.
+ /// The , converted for this with all relevant s applied.
+ /// The s to display. Each may contain 0 or more .
+ [NotNull]
+ public virtual StatisticRow[] CreateStatisticsForScore(ScoreInfo score, IBeatmap playableBeatmap) => Array.Empty();
}
}
diff --git a/osu.Game/Rulesets/Scoring/HitEvent.cs b/osu.Game/Rulesets/Scoring/HitEvent.cs
new file mode 100644
index 0000000000..0ebbec62ba
--- /dev/null
+++ b/osu.Game/Rulesets/Scoring/HitEvent.cs
@@ -0,0 +1,66 @@
+// Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence.
+// See the LICENCE file in the repository root for full licence text.
+
+using JetBrains.Annotations;
+using osu.Game.Rulesets.Objects;
+using osuTK;
+
+namespace osu.Game.Rulesets.Scoring
+{
+ ///
+ /// A generated by the containing extra statistics around a .
+ ///
+ public readonly struct HitEvent
+ {
+ ///
+ /// The time offset from the end of at which the event occurred.
+ ///
+ public readonly double TimeOffset;
+
+ ///
+ /// The hit result.
+ ///
+ public readonly HitResult Result;
+
+ ///
+ /// The on which the result occurred.
+ ///
+ public readonly HitObject HitObject;
+
+ ///
+ /// The occurring prior to .
+ ///
+ [CanBeNull]
+ public readonly HitObject LastHitObject;
+
+ ///
+ /// A position, if available, at the time of the event.
+ ///
+ [CanBeNull]
+ public readonly Vector2? Position;
+
+ ///
+ /// Creates a new .
+ ///
+ /// The time offset from the end of at which the event occurs.
+ /// The .
+ /// The that triggered the event.
+ /// The previous .
+ /// A position corresponding to the event.
+ public HitEvent(double timeOffset, HitResult result, HitObject hitObject, [CanBeNull] HitObject lastHitObject, [CanBeNull] Vector2? position)
+ {
+ TimeOffset = timeOffset;
+ Result = result;
+ HitObject = hitObject;
+ LastHitObject = lastHitObject;
+ Position = position;
+ }
+
+ ///
+ /// Creates a new with an optional positional offset.
+ ///
+ /// The positional offset.
+ /// The new .
+ public HitEvent With(Vector2? positionOffset) => new HitEvent(TimeOffset, Result, HitObject, LastHitObject, positionOffset);
+ }
+}
diff --git a/osu.Game/Rulesets/Scoring/ScoreProcessor.cs b/osu.Game/Rulesets/Scoring/ScoreProcessor.cs
index 1f40f44dce..9c1bc35169 100644
--- a/osu.Game/Rulesets/Scoring/ScoreProcessor.cs
+++ b/osu.Game/Rulesets/Scoring/ScoreProcessor.cs
@@ -9,6 +9,7 @@ using osu.Framework.Bindables;
using osu.Framework.Extensions;
using osu.Game.Rulesets.Judgements;
using osu.Game.Rulesets.Mods;
+using osu.Game.Rulesets.Objects;
using osu.Game.Scoring;
namespace osu.Game.Rulesets.Scoring
@@ -61,6 +62,9 @@ namespace osu.Game.Rulesets.Scoring
private double baseScore;
private double bonusScore;
+ private readonly List hitEvents = new List();
+ private HitObject lastHitObject;
+
private double scoreMultiplier = 1;
public ScoreProcessor()
@@ -128,9 +132,20 @@ namespace osu.Game.Rulesets.Scoring
rollingMaxBaseScore += result.Judgement.MaxNumericResult;
}
+ hitEvents.Add(CreateHitEvent(result));
+ lastHitObject = result.HitObject;
+
updateScore();
}
+ ///
+ /// Creates the that describes a .
+ ///
+ /// The to describe.
+ /// The .
+ protected virtual HitEvent CreateHitEvent(JudgementResult result)
+ => new HitEvent(result.TimeOffset, result.Type, result.HitObject, lastHitObject, null);
+
protected sealed override void RevertResultInternal(JudgementResult result)
{
Combo.Value = result.ComboAtJudgement;
@@ -153,6 +168,10 @@ namespace osu.Game.Rulesets.Scoring
rollingMaxBaseScore -= result.Judgement.MaxNumericResult;
}
+ Debug.Assert(hitEvents.Count > 0);
+ lastHitObject = hitEvents[^1].LastHitObject;
+ hitEvents.RemoveAt(hitEvents.Count - 1);
+
updateScore();
}
@@ -207,6 +226,8 @@ namespace osu.Game.Rulesets.Scoring
base.Reset(storeResults);
scoreResultCounts.Clear();
+ hitEvents.Clear();
+ lastHitObject = null;
if (storeResults)
{
@@ -247,6 +268,8 @@ namespace osu.Game.Rulesets.Scoring
foreach (var result in Enum.GetValues(typeof(HitResult)).OfType().Where(r => r > HitResult.None && hitWindows.IsHitResultAllowed(r)))
score.Statistics[result] = GetStatistic(result);
+
+ score.HitEvents = new List(hitEvents);
}
///
diff --git a/osu.Game/Rulesets/UI/RulesetInputManager.cs b/osu.Game/Rulesets/UI/RulesetInputManager.cs
index ba30fe28d5..f2ac61eaf4 100644
--- a/osu.Game/Rulesets/UI/RulesetInputManager.cs
+++ b/osu.Game/Rulesets/UI/RulesetInputManager.cs
@@ -18,9 +18,6 @@ using osu.Game.Input.Handlers;
using osu.Game.Screens.Play;
using osuTK.Input;
using static osu.Game.Input.Handlers.ReplayInputHandler;
-using JoystickState = osu.Framework.Input.States.JoystickState;
-using KeyboardState = osu.Framework.Input.States.KeyboardState;
-using MouseState = osu.Framework.Input.States.MouseState;
namespace osu.Game.Rulesets.UI
{
@@ -42,11 +39,7 @@ namespace osu.Game.Rulesets.UI
}
}
- protected override InputState CreateInitialState()
- {
- var state = base.CreateInitialState();
- return new RulesetInputManagerInputState(state.Mouse, state.Keyboard, state.Joystick);
- }
+ protected override InputState CreateInitialState() => new RulesetInputManagerInputState(base.CreateInitialState());
protected readonly KeyBindingContainer KeyBindingContainer;
@@ -203,8 +196,8 @@ namespace osu.Game.Rulesets.UI
{
public ReplayState LastReplayState;
- public RulesetInputManagerInputState(MouseState mouse = null, KeyboardState keyboard = null, JoystickState joystick = null)
- : base(mouse, keyboard, joystick)
+ public RulesetInputManagerInputState(InputState state = null)
+ : base(state)
{
}
}
diff --git a/osu.Game/Rulesets/UI/Scrolling/Algorithms/SequentialScrollAlgorithm.cs b/osu.Game/Rulesets/UI/Scrolling/Algorithms/SequentialScrollAlgorithm.cs
index 0052c877f6..a1f68d7201 100644
--- a/osu.Game/Rulesets/UI/Scrolling/Algorithms/SequentialScrollAlgorithm.cs
+++ b/osu.Game/Rulesets/UI/Scrolling/Algorithms/SequentialScrollAlgorithm.cs
@@ -3,21 +3,26 @@
using System;
using System.Collections.Generic;
+using System.Diagnostics;
+using JetBrains.Annotations;
using osu.Game.Rulesets.Timing;
namespace osu.Game.Rulesets.UI.Scrolling.Algorithms
{
public class SequentialScrollAlgorithm : IScrollAlgorithm
{
- private readonly Dictionary positionCache;
+ private static readonly IComparer by_position_comparer = Comparer.Create((c1, c2) => c1.Position.CompareTo(c2.Position));
private readonly IReadOnlyList controlPoints;
+ ///
+ /// Stores a mapping of time -> position for each control point.
+ ///
+ private readonly List positionMappings = new List();
+
public SequentialScrollAlgorithm(IReadOnlyList controlPoints)
{
this.controlPoints = controlPoints;
-
- positionCache = new Dictionary();
}
public double GetDisplayStartTime(double originTime, float offset, double timeRange, float scrollLength)
@@ -27,55 +32,31 @@ namespace osu.Game.Rulesets.UI.Scrolling.Algorithms
public float GetLength(double startTime, double endTime, double timeRange, float scrollLength)
{
- var objectLength = relativePositionAtCached(endTime, timeRange) - relativePositionAtCached(startTime, timeRange);
+ var objectLength = relativePositionAt(endTime, timeRange) - relativePositionAt(startTime, timeRange);
return (float)(objectLength * scrollLength);
}
public float PositionAt(double time, double currentTime, double timeRange, float scrollLength)
{
- // Caching is not used here as currentTime is unlikely to have been previously cached
- double timelinePosition = relativePositionAt(currentTime, timeRange);
- return (float)((relativePositionAtCached(time, timeRange) - timelinePosition) * scrollLength);
+ double timelineLength = relativePositionAt(time, timeRange) - relativePositionAt(currentTime, timeRange);
+ return (float)(timelineLength * scrollLength);
}
public double TimeAt(float position, double currentTime, double timeRange, float scrollLength)
{
- // Convert the position to a length relative to time = 0
- double length = position / scrollLength + relativePositionAt(currentTime, timeRange);
+ if (controlPoints.Count == 0)
+ return position * timeRange;
- // We need to consider all timing points until the specified time and not just the currently-active one,
- // since each timing point individually affects the positions of _all_ hitobjects after its start time
- for (int i = 0; i < controlPoints.Count; i++)
- {
- var current = controlPoints[i];
- var next = i < controlPoints.Count - 1 ? controlPoints[i + 1] : null;
+ // Find the position at the current time, and the given length.
+ double relativePosition = relativePositionAt(currentTime, timeRange) + position / scrollLength;
- // Duration of the current control point
- var currentDuration = (next?.StartTime ?? double.PositiveInfinity) - current.StartTime;
+ var positionMapping = findControlPointMapping(timeRange, new PositionMapping(0, null, relativePosition), by_position_comparer);
- // Figure out the length of control point
- var currentLength = currentDuration / timeRange * current.Multiplier;
-
- if (currentLength > length)
- {
- // The point is within this control point
- return current.StartTime + length * timeRange / current.Multiplier;
- }
-
- length -= currentLength;
- }
-
- return 0; // Should never occur
+ // Begin at the control point's time and add the remaining time to reach the given position.
+ return positionMapping.Time + (relativePosition - positionMapping.Position) * timeRange / positionMapping.ControlPoint.Multiplier;
}
- private double relativePositionAtCached(double time, double timeRange)
- {
- if (!positionCache.TryGetValue(time, out double existing))
- positionCache[time] = existing = relativePositionAt(time, timeRange);
- return existing;
- }
-
- public void Reset() => positionCache.Clear();
+ public void Reset() => positionMappings.Clear();
///
/// Finds the position which corresponds to a point in time.
@@ -84,37 +65,100 @@ namespace osu.Game.Rulesets.UI.Scrolling.Algorithms
/// The time to find the position at.
/// The amount of time visualised by the scrolling area.
/// A positive value indicating the position at .
- private double relativePositionAt(double time, double timeRange)
+ private double relativePositionAt(in double time, in double timeRange)
{
if (controlPoints.Count == 0)
return time / timeRange;
- double length = 0;
+ var mapping = findControlPointMapping(timeRange, new PositionMapping(time));
- // We need to consider all timing points until the specified time and not just the currently-active one,
- // since each timing point individually affects the positions of _all_ hitobjects after its start time
- for (int i = 0; i < controlPoints.Count; i++)
+ // Begin at the control point's position and add the remaining distance to reach the given time.
+ return mapping.Position + (time - mapping.Time) / timeRange * mapping.ControlPoint.Multiplier;
+ }
+
+ ///
+ /// Finds a 's that is relevant to a given .
+ ///
+ ///
+ /// This is used to find the last occuring prior to a time value, or prior to a position value (if is used).
+ ///
+ /// The time range.
+ /// The to find the closest to.
+ /// The comparison. If null, the default comparer is used (by time).
+ /// The 's that is relevant for .
+ private PositionMapping findControlPointMapping(in double timeRange, in PositionMapping search, IComparer comparer = null)
+ {
+ generatePositionMappings(timeRange);
+
+ var mappingIndex = positionMappings.BinarySearch(search, comparer ?? Comparer.Default);
+
+ if (mappingIndex < 0)
{
- var current = controlPoints[i];
- var next = i < controlPoints.Count - 1 ? controlPoints[i + 1] : null;
+ // If the search value isn't found, the _next_ control point is returned, but we actually want the _previous_ control point.
+ // In doing so, we must make sure to not underflow the position mapping list (i.e. always use the 0th control point for time < first_control_point_time).
+ mappingIndex = Math.Max(0, ~mappingIndex - 1);
- // We don't need to consider any control points beyond the current time, since it will not yet
- // affect any hitobjects
- if (i > 0 && current.StartTime > time)
- continue;
-
- // Duration of the current control point
- var currentDuration = (next?.StartTime ?? double.PositiveInfinity) - current.StartTime;
-
- // We want to consider the minimal amount of time that this control point has affected,
- // which may be either its duration, or the amount of time that has passed within it
- var durationInCurrent = Math.Min(currentDuration, time - current.StartTime);
-
- // Figure out how much of the time range the duration represents, and adjust it by the speed multiplier
- length += durationInCurrent / timeRange * current.Multiplier;
+ Debug.Assert(mappingIndex < positionMappings.Count);
}
- return length;
+ var mapping = positionMappings[mappingIndex];
+ Debug.Assert(mapping.ControlPoint != null);
+
+ return mapping;
+ }
+
+ ///
+ /// Generates the mapping of (and their respective start times) to their relative position from 0.
+ ///
+ /// The time range.
+ private void generatePositionMappings(in double timeRange)
+ {
+ if (positionMappings.Count > 0)
+ return;
+
+ if (controlPoints.Count == 0)
+ return;
+
+ positionMappings.Add(new PositionMapping(controlPoints[0].StartTime, controlPoints[0]));
+
+ for (int i = 0; i < controlPoints.Count - 1; i++)
+ {
+ var current = controlPoints[i];
+ var next = controlPoints[i + 1];
+
+ // Figure out how much of the time range the duration represents, and adjust it by the speed multiplier
+ float length = (float)((next.StartTime - current.StartTime) / timeRange * current.Multiplier);
+
+ positionMappings.Add(new PositionMapping(next.StartTime, next, positionMappings[^1].Position + length));
+ }
+ }
+
+ private readonly struct PositionMapping : IComparable
+ {
+ ///
+ /// The time corresponding to this position.
+ ///
+ public readonly double Time;
+
+ ///
+ /// The at .
+ ///
+ [CanBeNull]
+ public readonly MultiplierControlPoint ControlPoint;
+
+ ///
+ /// The relative position from 0 of .
+ ///
+ public readonly double Position;
+
+ public PositionMapping(double time, MultiplierControlPoint controlPoint = null, double position = default)
+ {
+ Time = time;
+ ControlPoint = controlPoint;
+ Position = position;
+ }
+
+ public int CompareTo(PositionMapping other) => Time.CompareTo(other.Time);
}
}
}
diff --git a/osu.Game/Scoring/ScoreInfo.cs b/osu.Game/Scoring/ScoreInfo.cs
index 7b37c267bc..84c0d5b54e 100644
--- a/osu.Game/Scoring/ScoreInfo.cs
+++ b/osu.Game/Scoring/ScoreInfo.cs
@@ -166,6 +166,10 @@ namespace osu.Game.Scoring
}
}
+ [NotMapped]
+ [JsonIgnore]
+ public List HitEvents { get; set; }
+
[JsonIgnore]
public List Files { get; set; }
diff --git a/osu.Game/Screens/Menu/ConfirmExitDialog.cs b/osu.Game/Screens/Menu/ConfirmExitDialog.cs
new file mode 100644
index 0000000000..d120eb21a8
--- /dev/null
+++ b/osu.Game/Screens/Menu/ConfirmExitDialog.cs
@@ -0,0 +1,34 @@
+// 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.Graphics.Sprites;
+using osu.Game.Overlays.Dialog;
+
+namespace osu.Game.Screens.Menu
+{
+ public class ConfirmExitDialog : PopupDialog
+ {
+ public ConfirmExitDialog(Action confirm, Action cancel)
+ {
+ HeaderText = "Are you sure you want to exit?";
+ BodyText = "Last chance to back out.";
+
+ Icon = FontAwesome.Solid.ExclamationTriangle;
+
+ Buttons = new PopupDialogButton[]
+ {
+ new PopupDialogOkButton
+ {
+ Text = @"Goodbye",
+ Action = confirm
+ },
+ new PopupDialogCancelButton
+ {
+ Text = @"Just a little more",
+ Action = cancel
+ },
+ };
+ }
+ }
+}
diff --git a/osu.Game/Screens/Menu/IntroScreen.cs b/osu.Game/Screens/Menu/IntroScreen.cs
index 88d18d0073..5f91aaad15 100644
--- a/osu.Game/Screens/Menu/IntroScreen.cs
+++ b/osu.Game/Screens/Menu/IntroScreen.cs
@@ -73,7 +73,6 @@ namespace osu.Game.Screens.Menu
MenuVoice = config.GetBindable(OsuSetting.MenuVoice);
MenuMusic = config.GetBindable(OsuSetting.MenuMusic);
-
seeya = audio.Samples.Get(SeeyaSampleName);
BeatmapSetInfo setInfo = null;
diff --git a/osu.Game/Screens/Menu/IntroWelcome.cs b/osu.Game/Screens/Menu/IntroWelcome.cs
index abd4a68d4f..bf42e36e8c 100644
--- a/osu.Game/Screens/Menu/IntroWelcome.cs
+++ b/osu.Game/Screens/Menu/IntroWelcome.cs
@@ -39,6 +39,8 @@ namespace osu.Game.Screens.Menu
welcome = audio.Samples.Get(@"Intro/Welcome/welcome");
pianoReverb = audio.Samples.Get(@"Intro/Welcome/welcome_piano");
+
+ Track.Looping = true;
}
protected override void LogoArriving(OsuLogo logo, bool resuming)
diff --git a/osu.Game/Screens/Menu/MainMenu.cs b/osu.Game/Screens/Menu/MainMenu.cs
index f0da2482d6..76950982e6 100644
--- a/osu.Game/Screens/Menu/MainMenu.cs
+++ b/osu.Game/Screens/Menu/MainMenu.cs
@@ -1,22 +1,21 @@
// 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.Linq;
using osuTK;
using osuTK.Graphics;
using osu.Framework.Allocation;
+using osu.Framework.Audio.Track;
using osu.Framework.Bindables;
using osu.Framework.Graphics;
-using osu.Framework.Graphics.Sprites;
using osu.Framework.Platform;
using osu.Framework.Screens;
using osu.Game.Configuration;
using osu.Game.Graphics;
using osu.Game.Graphics.Containers;
+using osu.Game.IO;
using osu.Game.Online.API;
using osu.Game.Overlays;
-using osu.Game.Overlays.Dialog;
using osu.Game.Screens.Backgrounds;
using osu.Game.Screens.Edit;
using osu.Game.Screens.Multi;
@@ -63,6 +62,8 @@ namespace osu.Game.Screens.Menu
protected override BackgroundScreen CreateBackground() => background;
+ internal Track Track { get; private set; }
+
private Bindable holdDelay;
private Bindable loginDisplayed;
@@ -168,22 +169,28 @@ namespace osu.Game.Screens.Menu
return s;
}
+ [Resolved]
+ private Storage storage { get; set; }
+
public override void OnEntering(IScreen last)
{
base.OnEntering(last);
buttons.FadeInFromZero(500);
- var track = Beatmap.Value.Track;
+ Track = Beatmap.Value.Track;
var metadata = Beatmap.Value.Metadata;
- if (last is IntroScreen && track != null)
+ if (last is IntroScreen && Track != null)
{
- if (!track.IsRunning)
+ if (!Track.IsRunning)
{
- track.Seek(metadata.PreviewTime != -1 ? metadata.PreviewTime : 0.4f * track.Length);
- track.Start();
+ Track.Seek(metadata.PreviewTime != -1 ? metadata.PreviewTime : 0.4f * Track.Length);
+ Track.Start();
}
}
+
+ if (storage is OsuStorage osuStorage && osuStorage.Error != OsuStorageError.None)
+ dialogOverlay?.Push(new StorageErrorDialog(osuStorage, osuStorage.Error));
}
private bool exitConfirmed;
@@ -280,30 +287,5 @@ namespace osu.Game.Screens.Menu
this.FadeOut(3000);
return base.OnExiting(next);
}
-
- private class ConfirmExitDialog : PopupDialog
- {
- public ConfirmExitDialog(Action confirm, Action cancel)
- {
- HeaderText = "Are you sure you want to exit?";
- BodyText = "Last chance to back out.";
-
- Icon = FontAwesome.Solid.ExclamationTriangle;
-
- Buttons = new PopupDialogButton[]
- {
- new PopupDialogOkButton
- {
- Text = @"Goodbye",
- Action = confirm
- },
- new PopupDialogCancelButton
- {
- Text = @"Just a little more",
- Action = cancel
- },
- };
- }
- }
}
}
diff --git a/osu.Game/Screens/Menu/StorageErrorDialog.cs b/osu.Game/Screens/Menu/StorageErrorDialog.cs
new file mode 100644
index 0000000000..dcaad4013a
--- /dev/null
+++ b/osu.Game/Screens/Menu/StorageErrorDialog.cs
@@ -0,0 +1,79 @@
+// 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.Graphics.Sprites;
+using osu.Game.IO;
+using osu.Game.Overlays;
+using osu.Game.Overlays.Dialog;
+
+namespace osu.Game.Screens.Menu
+{
+ public class StorageErrorDialog : PopupDialog
+ {
+ [Resolved]
+ private DialogOverlay dialogOverlay { get; set; }
+
+ [Resolved]
+ private OsuGameBase osuGame { get; set; }
+
+ public StorageErrorDialog(OsuStorage storage, OsuStorageError error)
+ {
+ HeaderText = "osu! storage error";
+ Icon = FontAwesome.Solid.ExclamationTriangle;
+
+ var buttons = new List();
+
+ switch (error)
+ {
+ case OsuStorageError.NotAccessible:
+ BodyText = $"The specified osu! data location (\"{storage.CustomStoragePath}\") is not accessible. If it is on external storage, please reconnect the device and try again.";
+
+ buttons.AddRange(new PopupDialogButton[]
+ {
+ new PopupDialogCancelButton
+ {
+ Text = "Try again",
+ Action = () =>
+ {
+ if (!storage.TryChangeToCustomStorage(out var nextError))
+ dialogOverlay.Push(new StorageErrorDialog(storage, nextError));
+ }
+ },
+ new PopupDialogCancelButton
+ {
+ Text = "Use default location until restart",
+ },
+ new PopupDialogOkButton
+ {
+ Text = "Reset to default location",
+ Action = storage.ResetCustomStoragePath
+ },
+ });
+ break;
+
+ case OsuStorageError.AccessibleButEmpty:
+ BodyText = $"The specified osu! data location (\"{storage.CustomStoragePath}\") is empty. If you have moved the files, please close osu! and move them back.";
+
+ // Todo: Provide the option to search for the files similar to migration.
+ buttons.AddRange(new PopupDialogButton[]
+ {
+ new PopupDialogCancelButton
+ {
+ Text = "Start fresh at specified location"
+ },
+ new PopupDialogOkButton
+ {
+ Text = "Reset to default location",
+ Action = storage.ResetCustomStoragePath
+ },
+ });
+
+ break;
+ }
+
+ Buttons = buttons;
+ }
+ }
+}
diff --git a/osu.Game/Screens/Multi/RoomManager.cs b/osu.Game/Screens/Multi/RoomManager.cs
index 4d6ac46c84..642378d8d5 100644
--- a/osu.Game/Screens/Multi/RoomManager.cs
+++ b/osu.Game/Screens/Multi/RoomManager.cs
@@ -3,6 +3,7 @@
using System;
using System.Collections.Generic;
+using System.Diagnostics;
using System.Linq;
using System.Threading.Tasks;
using osu.Framework.Allocation;
@@ -142,6 +143,8 @@ namespace osu.Game.Screens.Multi
joinedRoom = null;
}
+ private readonly HashSet ignoredRooms = new HashSet();
+
///
/// Invoked when the listing of all s is received from the server.
///
@@ -163,11 +166,27 @@ namespace osu.Game.Screens.Multi
continue;
}
- var r = listing[i];
- r.Position.Value = i;
+ var room = listing[i];
- update(r, r);
- addRoom(r);
+ Debug.Assert(room.RoomID.Value != null);
+
+ if (ignoredRooms.Contains(room.RoomID.Value.Value))
+ continue;
+
+ room.Position.Value = i;
+
+ try
+ {
+ update(room, room);
+ addRoom(room);
+ }
+ catch (Exception ex)
+ {
+ Logger.Error(ex, $"Failed to update room: {room.Name.Value}.");
+
+ ignoredRooms.Add(room.RoomID.Value.Value);
+ rooms.Remove(room);
+ }
}
RoomsUpdated?.Invoke();
diff --git a/osu.Game/Screens/Play/HUD/FailingLayer.cs b/osu.Game/Screens/Play/HUD/FailingLayer.cs
index a49aa89a7c..84dbb35f68 100644
--- a/osu.Game/Screens/Play/HUD/FailingLayer.cs
+++ b/osu.Game/Screens/Play/HUD/FailingLayer.cs
@@ -18,10 +18,15 @@ 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 .
+ /// 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
{
+ ///
+ /// Whether the current player health should be shown on screen.
+ ///
+ public readonly Bindable ShowHealth = new Bindable();
+
private const float max_alpha = 0.4f;
private const int fade_time = 400;
private const float gradient_size = 0.3f;
@@ -29,12 +34,11 @@ namespace osu.Game.Screens.Play.HUD
///
/// 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 const double low_health_threshold = 0.20f;
- private readonly Bindable enabled = new Bindable();
private readonly Container boxes;
- private Bindable configEnabled;
+ private Bindable fadePlayfieldWhenHealthLow;
private HealthProcessor healthProcessor;
public FailingLayer()
@@ -73,14 +77,15 @@ namespace osu.Game.Screens.Play.HUD
{
boxes.Colour = color.Red;
- configEnabled = config.GetBindable(OsuSetting.FadePlayfieldWhenHealthLow);
- enabled.BindValueChanged(e => this.FadeTo(e.NewValue ? 1 : 0, fade_time, Easing.OutQuint), true);
+ fadePlayfieldWhenHealthLow = config.GetBindable(OsuSetting.FadePlayfieldWhenHealthLow);
+ fadePlayfieldWhenHealthLow.BindValueChanged(_ => updateState());
+ ShowHealth.BindValueChanged(_ => updateState());
}
protected override void LoadComplete()
{
base.LoadComplete();
- updateBindings();
+ updateState();
}
public override void BindHealthProcessor(HealthProcessor processor)
@@ -88,26 +93,19 @@ namespace osu.Game.Screens.Play.HUD
base.BindHealthProcessor(processor);
healthProcessor = processor;
- updateBindings();
+ updateState();
}
- private void updateBindings()
+ private void updateState()
{
- 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;
+ var showLayer = healthProcessor is DrainingHealthProcessor && fadePlayfieldWhenHealthLow.Value && ShowHealth.Value;
+ this.FadeTo(showLayer ? 1 : 0, fade_time, Easing.OutQuint);
}
protected override void Update()
{
- double target = Math.Clamp(max_alpha * (1 - Current.Value / LowHealthThreshold), 0, max_alpha);
+ double target = Math.Clamp(max_alpha * (1 - Current.Value / low_health_threshold), 0, max_alpha);
boxes.Alpha = (float)Interpolation.Lerp(boxes.Alpha, target, Clock.ElapsedFrameTime * 0.01f);
diff --git a/osu.Game/Screens/Play/HUDOverlay.cs b/osu.Game/Screens/Play/HUDOverlay.cs
index 5114efd9a9..f09745cf71 100644
--- a/osu.Game/Screens/Play/HUDOverlay.cs
+++ b/osu.Game/Screens/Play/HUDOverlay.cs
@@ -262,7 +262,10 @@ namespace osu.Game.Screens.Play
Margin = new MarginPadding { Top = 20 }
};
- protected virtual FailingLayer CreateFailingLayer() => new FailingLayer();
+ protected virtual FailingLayer CreateFailingLayer() => new FailingLayer
+ {
+ ShowHealth = { BindTarget = ShowHealthbar }
+ };
protected virtual KeyCounterDisplay CreateKeyCounter() => new KeyCounterDisplay
{
diff --git a/osu.Game/Screens/Play/ReplayPlayer.cs b/osu.Game/Screens/Play/ReplayPlayer.cs
index b443603128..7f5c17a265 100644
--- a/osu.Game/Screens/Play/ReplayPlayer.cs
+++ b/osu.Game/Screens/Play/ReplayPlayer.cs
@@ -1,7 +1,6 @@
// 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.Screens;
using osu.Game.Scoring;
using osu.Game.Screens.Ranking;
@@ -25,13 +24,16 @@ namespace osu.Game.Screens.Play
DrawableRuleset?.SetReplayScore(score);
}
- protected override void GotoRanking()
- {
- this.Push(CreateResults(DrawableRuleset.ReplayScore.ScoreInfo));
- }
-
protected override ResultsScreen CreateResults(ScoreInfo score) => new SoloResultsScreen(score, false);
- protected override ScoreInfo CreateScore() => score.ScoreInfo;
+ protected override ScoreInfo CreateScore()
+ {
+ var baseScore = base.CreateScore();
+
+ // Since the replay score doesn't contain statistics, we'll pass them through here.
+ score.ScoreInfo.HitEvents = baseScore.HitEvents;
+
+ return score.ScoreInfo;
+ }
}
}
diff --git a/osu.Game/Screens/Ranking/Expanded/Accuracy/AccuracyCircle.cs b/osu.Game/Screens/Ranking/Expanded/Accuracy/AccuracyCircle.cs
index ee53ee9879..45da23f1f9 100644
--- a/osu.Game/Screens/Ranking/Expanded/Accuracy/AccuracyCircle.cs
+++ b/osu.Game/Screens/Ranking/Expanded/Accuracy/AccuracyCircle.cs
@@ -2,6 +2,7 @@
// See the LICENCE file in the repository root for full licence text.
using System;
+using System.Linq;
using osu.Framework.Allocation;
using osu.Framework.Extensions.Color4Extensions;
using osu.Framework.Graphics;
@@ -9,6 +10,7 @@ using osu.Framework.Graphics.Colour;
using osu.Framework.Graphics.Containers;
using osu.Framework.Utils;
using osu.Game.Graphics;
+using osu.Game.Rulesets.Mods;
using osu.Game.Scoring;
using osuTK;
@@ -191,18 +193,26 @@ namespace osu.Game.Screens.Ranking.Expanded.Accuracy
Padding = new MarginPadding { Vertical = -15, Horizontal = -20 },
Children = new[]
{
- new RankBadge(1f, ScoreRank.X),
- new RankBadge(0.95f, ScoreRank.S),
- new RankBadge(0.9f, ScoreRank.A),
- new RankBadge(0.8f, ScoreRank.B),
- new RankBadge(0.7f, ScoreRank.C),
- new RankBadge(0.35f, ScoreRank.D),
+ new RankBadge(1f, getRank(ScoreRank.X)),
+ new RankBadge(0.95f, getRank(ScoreRank.S)),
+ new RankBadge(0.9f, getRank(ScoreRank.A)),
+ new RankBadge(0.8f, getRank(ScoreRank.B)),
+ new RankBadge(0.7f, getRank(ScoreRank.C)),
+ new RankBadge(0.35f, getRank(ScoreRank.D)),
}
},
rankText = new RankText(score.Rank)
};
}
+ private ScoreRank getRank(ScoreRank rank)
+ {
+ foreach (var mod in score.Mods.OfType())
+ rank = mod.AdjustRank(rank, score.Accuracy);
+
+ return rank;
+ }
+
protected override void LoadComplete()
{
base.LoadComplete();
diff --git a/osu.Game/Screens/Ranking/ResultsScreen.cs b/osu.Game/Screens/Ranking/ResultsScreen.cs
index fbb9b95478..49ce07b708 100644
--- a/osu.Game/Screens/Ranking/ResultsScreen.cs
+++ b/osu.Game/Screens/Ranking/ResultsScreen.cs
@@ -3,6 +3,7 @@
using System;
using System.Collections.Generic;
+using System.Linq;
using osu.Framework.Allocation;
using osu.Framework.Bindables;
using osu.Framework.Extensions.Color4Extensions;
@@ -16,6 +17,7 @@ using osu.Game.Online.API;
using osu.Game.Scoring;
using osu.Game.Screens.Backgrounds;
using osu.Game.Screens.Play;
+using osu.Game.Screens.Ranking.Statistics;
using osuTK;
namespace osu.Game.Screens.Ranking
@@ -23,6 +25,7 @@ namespace osu.Game.Screens.Ranking
public abstract class ResultsScreen : OsuScreen
{
protected const float BACKGROUND_BLUR = 20;
+ private static readonly float screen_height = 768 - TwoLayerButton.SIZE_EXTENDED.Y;
public override bool DisallowExternalBeatmapRulesetChanges => true;
@@ -42,8 +45,10 @@ namespace osu.Game.Screens.Ranking
[Resolved]
private IAPIProvider api { get; set; }
+ private StatisticsPanel statisticsPanel;
private Drawable bottomPanel;
- private ScorePanelList panels;
+ private ScorePanelList scorePanelList;
+ private Container detachedPanelContainer;
protected ResultsScreen(ScoreInfo score, bool allowRetry = true)
{
@@ -65,14 +70,33 @@ namespace osu.Game.Screens.Ranking
{
new Drawable[]
{
- new ResultsScrollContainer
+ new VerticalScrollContainer
{
- Child = panels = new ScorePanelList
+ RelativeSizeAxes = Axes.Both,
+ ScrollbarVisible = false,
+ Child = new Container
{
RelativeSizeAxes = Axes.Both,
- SelectedScore = { BindTarget = SelectedScore }
+ Children = new Drawable[]
+ {
+ statisticsPanel = new StatisticsPanel
+ {
+ RelativeSizeAxes = Axes.Both,
+ Score = { BindTarget = SelectedScore }
+ },
+ scorePanelList = new ScorePanelList
+ {
+ RelativeSizeAxes = Axes.Both,
+ SelectedScore = { BindTarget = SelectedScore },
+ PostExpandAction = () => statisticsPanel.ToggleVisibility()
+ },
+ detachedPanelContainer = new Container
+ {
+ RelativeSizeAxes = Axes.Both
+ },
+ }
}
- }
+ },
},
new[]
{
@@ -118,7 +142,7 @@ namespace osu.Game.Screens.Ranking
};
if (Score != null)
- panels.AddScore(Score);
+ scorePanelList.AddScore(Score);
if (player != null && allowRetry)
{
@@ -143,11 +167,13 @@ namespace osu.Game.Screens.Ranking
var req = FetchScores(scores => Schedule(() =>
{
foreach (var s in scores)
- panels.AddScore(s);
+ addScore(s);
}));
if (req != null)
api.Queue(req);
+
+ statisticsPanel.State.BindValueChanged(onStatisticsStateChanged, true);
}
///
@@ -169,32 +195,96 @@ namespace osu.Game.Screens.Ranking
public override bool OnExiting(IScreen next)
{
+ if (statisticsPanel.State.Value == Visibility.Visible)
+ {
+ statisticsPanel.Hide();
+ return true;
+ }
+
Background.FadeTo(1, 250);
return base.OnExiting(next);
}
- private class ResultsScrollContainer : OsuScrollContainer
+ private void addScore(ScoreInfo score)
{
- private readonly Container content;
+ var panel = scorePanelList.AddScore(score);
+ if (detachedPanel != null)
+ panel.Alpha = 0;
+ }
+
+ private ScorePanel detachedPanel;
+
+ private void onStatisticsStateChanged(ValueChangedEvent state)
+ {
+ if (state.NewValue == Visibility.Visible)
+ {
+ // Detach the panel in its original location, and move into the desired location in the local container.
+ var expandedPanel = scorePanelList.GetPanelForScore(SelectedScore.Value);
+ var screenSpacePos = expandedPanel.ScreenSpaceDrawQuad.TopLeft;
+
+ // Detach and move into the local container.
+ scorePanelList.Detach(expandedPanel);
+ detachedPanelContainer.Add(expandedPanel);
+
+ // Move into its original location in the local container first, then to the final location.
+ var origLocation = detachedPanelContainer.ToLocalSpace(screenSpacePos);
+ expandedPanel.MoveTo(origLocation)
+ .Then()
+ .MoveTo(new Vector2(StatisticsPanel.SIDE_PADDING, origLocation.Y), 150, Easing.OutQuint);
+
+ // Hide contracted panels.
+ foreach (var contracted in scorePanelList.GetScorePanels().Where(p => p.State == PanelState.Contracted))
+ contracted.FadeOut(150, Easing.OutQuint);
+ scorePanelList.HandleInput = false;
+
+ // Dim background.
+ Background.FadeTo(0.1f, 150);
+
+ detachedPanel = expandedPanel;
+ }
+ else if (detachedPanel != null)
+ {
+ var screenSpacePos = detachedPanel.ScreenSpaceDrawQuad.TopLeft;
+
+ // Remove from the local container and re-attach.
+ detachedPanelContainer.Remove(detachedPanel);
+ scorePanelList.Attach(detachedPanel);
+
+ // Move into its original location in the attached container first, then to the final location.
+ var origLocation = detachedPanel.Parent.ToLocalSpace(screenSpacePos);
+ detachedPanel.MoveTo(origLocation)
+ .Then()
+ .MoveTo(new Vector2(0, origLocation.Y), 150, Easing.OutQuint);
+
+ // Show contracted panels.
+ foreach (var contracted in scorePanelList.GetScorePanels().Where(p => p.State == PanelState.Contracted))
+ contracted.FadeIn(150, Easing.OutQuint);
+ scorePanelList.HandleInput = true;
+
+ // Un-dim background.
+ Background.FadeTo(0.5f, 150);
+
+ detachedPanel = null;
+ }
+ }
+
+ private class VerticalScrollContainer : OsuScrollContainer
+ {
protected override Container Content => content;
- public ResultsScrollContainer()
- {
- base.Content.Add(content = new Container
- {
- RelativeSizeAxes = Axes.X
- });
+ private readonly Container content;
- RelativeSizeAxes = Axes.Both;
- ScrollbarVisible = false;
+ public VerticalScrollContainer()
+ {
+ base.Content.Add(content = new Container { RelativeSizeAxes = Axes.X });
}
protected override void Update()
{
base.Update();
- content.Height = Math.Max(768 - TwoLayerButton.SIZE_EXTENDED.Y, DrawHeight);
+ content.Height = Math.Max(screen_height, DrawHeight);
}
}
}
diff --git a/osu.Game/Screens/Ranking/ScorePanel.cs b/osu.Game/Screens/Ranking/ScorePanel.cs
index 65fb901c89..9633f5c533 100644
--- a/osu.Game/Screens/Ranking/ScorePanel.cs
+++ b/osu.Game/Screens/Ranking/ScorePanel.cs
@@ -76,6 +76,12 @@ namespace osu.Game.Screens.Ranking
private static readonly Color4 contracted_middle_layer_colour = Color4Extensions.FromHex("#353535");
public event Action StateChanged;
+
+ ///
+ /// An action to be invoked if this is clicked while in an expanded state.
+ ///
+ public Action PostExpandAction;
+
public readonly ScoreInfo Score;
private Container content;
@@ -236,10 +242,28 @@ namespace osu.Game.Screens.Ranking
}
}
+ public override Vector2 Size
+ {
+ get => base.Size;
+ set
+ {
+ base.Size = value;
+
+ // Auto-size isn't used to avoid 1-frame issues and because the score panel is removed/re-added to the container.
+ if (trackingContainer != null)
+ trackingContainer.Size = value;
+ }
+ }
+
protected override bool OnClick(ClickEvent e)
{
if (State == PanelState.Contracted)
+ {
State = PanelState.Expanded;
+ return true;
+ }
+
+ PostExpandAction?.Invoke();
return true;
}
@@ -248,5 +272,24 @@ namespace osu.Game.Screens.Ranking
=> base.ReceivePositionalInputAt(screenSpacePos)
|| topLayerContainer.ReceivePositionalInputAt(screenSpacePos)
|| middleLayerContainer.ReceivePositionalInputAt(screenSpacePos);
+
+ private ScorePanelTrackingContainer trackingContainer;
+
+ ///
+ /// Creates a which this can reside inside.
+ /// The will track the size of this .
+ ///
+ ///
+ /// This is immediately added as a child of the .
+ ///
+ /// The .
+ /// If a already exists.
+ public ScorePanelTrackingContainer CreateTrackingContainer()
+ {
+ if (trackingContainer != null)
+ throw new InvalidOperationException("A score panel container has already been created.");
+
+ return trackingContainer = new ScorePanelTrackingContainer(this);
+ }
}
}
diff --git a/osu.Game/Screens/Ranking/ScorePanelList.cs b/osu.Game/Screens/Ranking/ScorePanelList.cs
index 1142297274..0f8bc82ac0 100644
--- a/osu.Game/Screens/Ranking/ScorePanelList.cs
+++ b/osu.Game/Screens/Ranking/ScorePanelList.cs
@@ -3,6 +3,7 @@
using System;
using System.Collections.Generic;
+using System.Diagnostics;
using System.Linq;
using osu.Framework.Bindables;
using osu.Framework.Graphics;
@@ -25,12 +26,20 @@ namespace osu.Game.Screens.Ranking
///
private const float expanded_panel_spacing = 15;
+ ///
+ /// An action to be invoked if a is clicked while in an expanded state.
+ ///
+ public Action PostExpandAction;
+
public readonly Bindable SelectedScore = new Bindable();
private readonly Flow flow;
private readonly Scroll scroll;
private ScorePanel expandedPanel;
+ ///
+ /// Creates a new .
+ ///
public ScorePanelList()
{
RelativeSizeAxes = Axes.Both;
@@ -38,6 +47,7 @@ namespace osu.Game.Screens.Ranking
InternalChild = scroll = new Scroll
{
RelativeSizeAxes = Axes.Both,
+ HandleScroll = () => expandedPanel?.IsHovered != true, // handle horizontal scroll only when not hovering the expanded panel.
Child = flow = new Flow
{
Anchor = Anchor.Centre,
@@ -60,12 +70,11 @@ namespace osu.Game.Screens.Ranking
/// Adds a to this list.
///
/// The to add.
- public void AddScore(ScoreInfo score)
+ public ScorePanel AddScore(ScoreInfo score)
{
- flow.Add(new ScorePanel(score)
+ var panel = new ScorePanel(score)
{
- Anchor = Anchor.Centre,
- Origin = Anchor.Centre,
+ PostExpandAction = () => PostExpandAction?.Invoke()
}.With(p =>
{
p.StateChanged += s =>
@@ -73,6 +82,12 @@ namespace osu.Game.Screens.Ranking
if (s == PanelState.Expanded)
SelectedScore.Value = p.Score;
};
+ });
+
+ flow.Add(panel.CreateTrackingContainer().With(d =>
+ {
+ d.Anchor = Anchor.Centre;
+ d.Origin = Anchor.Centre;
}));
if (SelectedScore.Value == score)
@@ -90,6 +105,8 @@ namespace osu.Game.Screens.Ranking
scroll.InstantScrollTarget = (scroll.InstantScrollTarget ?? scroll.Target) + ScorePanel.CONTRACTED_WIDTH + panel_spacing;
}
}
+
+ return panel;
}
///
@@ -99,24 +116,24 @@ namespace osu.Game.Screens.Ranking
private void selectedScoreChanged(ValueChangedEvent score)
{
// Contract the old panel.
- foreach (var p in flow.Where(p => p.Score == score.OldValue))
+ foreach (var t in flow.Where(t => t.Panel.Score == score.OldValue))
{
- p.State = PanelState.Contracted;
- p.Margin = new MarginPadding();
+ t.Panel.State = PanelState.Contracted;
+ t.Margin = new MarginPadding();
}
// Find the panel corresponding to the new score.
- expandedPanel = flow.SingleOrDefault(p => p.Score == score.NewValue);
-
- // handle horizontal scroll only when not hovering the expanded panel.
- scroll.HandleScroll = () => expandedPanel?.IsHovered != true;
+ var expandedTrackingComponent = flow.SingleOrDefault(t => t.Panel.Score == score.NewValue);
+ expandedPanel = expandedTrackingComponent?.Panel;
if (expandedPanel == null)
return;
+ Debug.Assert(expandedTrackingComponent != null);
+
// Expand the new panel.
+ expandedTrackingComponent.Margin = new MarginPadding { Horizontal = expanded_panel_spacing };
expandedPanel.State = PanelState.Expanded;
- expandedPanel.Margin = new MarginPadding { Horizontal = expanded_panel_spacing };
// Scroll to the new panel. This is done manually since we need:
// 1) To scroll after the scroll container's visible range is updated.
@@ -145,15 +162,92 @@ namespace osu.Game.Screens.Ranking
flow.Padding = new MarginPadding { Horizontal = offset };
}
- private class Flow : FillFlowContainer
+ private bool handleInput = true;
+
+ ///
+ /// Whether this or any of the s contained should handle scroll or click input.
+ /// Setting to false will also hide the scrollbar.
+ ///
+ public bool HandleInput
+ {
+ get => handleInput;
+ set
+ {
+ handleInput = value;
+ scroll.ScrollbarVisible = value;
+ }
+ }
+
+ public override bool PropagatePositionalInputSubTree => HandleInput && base.PropagatePositionalInputSubTree;
+
+ public override bool PropagateNonPositionalInputSubTree => HandleInput && base.PropagateNonPositionalInputSubTree;
+
+ ///
+ /// Enumerates all s contained in this .
+ ///
+ ///
+ public IEnumerable GetScorePanels() => flow.Select(t => t.Panel);
+
+ ///
+ /// Finds the corresponding to a .
+ ///
+ /// The to find the corresponding for.
+ /// The .
+ public ScorePanel GetPanelForScore(ScoreInfo score) => flow.Single(t => t.Panel.Score == score).Panel;
+
+ ///
+ /// Detaches a from its , allowing the panel to be moved elsewhere in the hierarchy.
+ ///
+ /// The to detach.
+ /// If is not a part of this .
+ public void Detach(ScorePanel panel)
+ {
+ var container = flow.SingleOrDefault(t => t.Panel == panel);
+ if (container == null)
+ throw new InvalidOperationException("Panel is not contained by the score panel list.");
+
+ container.Detach();
+ }
+
+ ///
+ /// Attaches a to its in this .
+ ///
+ /// The to attach.
+ /// If is not a part of this .
+ public void Attach(ScorePanel panel)
+ {
+ var container = flow.SingleOrDefault(t => t.Panel == panel);
+ if (container == null)
+ throw new InvalidOperationException("Panel is not contained by the score panel list.");
+
+ container.Attach();
+ }
+
+ private class Flow : FillFlowContainer
{
public override IEnumerable FlowingChildren => applySorting(AliveInternalChildren);
- public int GetPanelIndex(ScoreInfo score) => applySorting(Children).TakeWhile(s => s.Score != score).Count();
+ public int GetPanelIndex(ScoreInfo score) => applySorting(Children).TakeWhile(s => s.Panel.Score != score).Count();
- private IEnumerable applySorting(IEnumerable drawables) => drawables.OfType()
- .OrderByDescending(s => s.Score.TotalScore)
- .ThenBy(s => s.Score.OnlineScoreID);
+ private IEnumerable applySorting(IEnumerable drawables) => drawables.OfType()
+ .OrderByDescending(s => s.Panel.Score.TotalScore)
+ .ThenBy(s => s.Panel.Score.OnlineScoreID);
+
+ protected override int Compare(Drawable x, Drawable y)
+ {
+ var tX = (ScorePanelTrackingContainer)x;
+ var tY = (ScorePanelTrackingContainer)y;
+
+ int result = tY.Panel.Score.TotalScore.CompareTo(tX.Panel.Score.TotalScore);
+
+ if (result != 0)
+ return result;
+
+ if (tX.Panel.Score.OnlineScoreID == null || tY.Panel.Score.OnlineScoreID == null)
+ return base.Compare(x, y);
+
+ return tX.Panel.Score.OnlineScoreID.Value.CompareTo(tY.Panel.Score.OnlineScoreID.Value);
+ }
}
private class Scroll : OsuScrollContainer
diff --git a/osu.Game/Screens/Ranking/ScorePanelTrackingContainer.cs b/osu.Game/Screens/Ranking/ScorePanelTrackingContainer.cs
new file mode 100644
index 0000000000..c8010d1c32
--- /dev/null
+++ b/osu.Game/Screens/Ranking/ScorePanelTrackingContainer.cs
@@ -0,0 +1,50 @@
+// 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.Graphics.Containers;
+
+namespace osu.Game.Screens.Ranking
+{
+ ///
+ /// A which tracks the size of a , to which the can be added or removed.
+ ///
+ public class ScorePanelTrackingContainer : CompositeDrawable
+ {
+ ///
+ /// The that created this .
+ ///
+ public readonly ScorePanel Panel;
+
+ internal ScorePanelTrackingContainer(ScorePanel panel)
+ {
+ Panel = panel;
+ Attach();
+ }
+
+ ///
+ /// Detaches the from this , removing it as a child.
+ /// This will continue tracking any size changes.
+ ///
+ /// If the is already detached.
+ public void Detach()
+ {
+ if (InternalChildren.Count == 0)
+ throw new InvalidOperationException("Score panel container is not attached.");
+
+ RemoveInternal(Panel);
+ }
+
+ ///
+ /// Attaches the to this , adding it as a child.
+ ///
+ /// If the is already attached.
+ public void Attach()
+ {
+ if (InternalChildren.Count > 0)
+ throw new InvalidOperationException("Score panel container is already attached.");
+
+ AddInternal(Panel);
+ }
+ }
+}
diff --git a/osu.Game/Screens/Ranking/Statistics/HitEventTimingDistributionGraph.cs b/osu.Game/Screens/Ranking/Statistics/HitEventTimingDistributionGraph.cs
new file mode 100644
index 0000000000..527da429ed
--- /dev/null
+++ b/osu.Game/Screens/Ranking/Statistics/HitEventTimingDistributionGraph.cs
@@ -0,0 +1,173 @@
+// 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.Framework.Allocation;
+using osu.Framework.Extensions.Color4Extensions;
+using osu.Framework.Graphics;
+using osu.Framework.Graphics.Containers;
+using osu.Framework.Graphics.Shapes;
+using osu.Game.Graphics;
+using osu.Game.Graphics.Sprites;
+using osu.Game.Rulesets.Scoring;
+
+namespace osu.Game.Screens.Ranking.Statistics
+{
+ ///
+ /// A graph which displays the distribution of hit timing in a series of s.
+ ///
+ public class HitEventTimingDistributionGraph : CompositeDrawable
+ {
+ ///
+ /// The number of bins on each side of the timing distribution.
+ ///
+ private const int timing_distribution_bins = 50;
+
+ ///
+ /// The total number of bins in the timing distribution, including bins on both sides and the centre bin at 0.
+ ///
+ private const int total_timing_distribution_bins = timing_distribution_bins * 2 + 1;
+
+ ///
+ /// The centre bin, with a timing distribution very close to/at 0.
+ ///
+ private const int timing_distribution_centre_bin_index = timing_distribution_bins;
+
+ ///
+ /// The number of data points shown on each side of the axis below the graph.
+ ///
+ private const float axis_points = 5;
+
+ private readonly IReadOnlyList hitEvents;
+
+ ///
+ /// Creates a new .
+ ///
+ /// The s to display the timing distribution of.
+ public HitEventTimingDistributionGraph(IReadOnlyList hitEvents)
+ {
+ this.hitEvents = hitEvents.Where(e => !(e.HitObject.HitWindows is HitWindows.EmptyHitWindows)).ToList();
+ }
+
+ [BackgroundDependencyLoader]
+ private void load()
+ {
+ if (hitEvents == null || hitEvents.Count == 0)
+ return;
+
+ int[] bins = new int[total_timing_distribution_bins];
+
+ double binSize = Math.Ceiling(hitEvents.Max(e => Math.Abs(e.TimeOffset)) / timing_distribution_bins);
+
+ // Prevent div-by-0 by enforcing a minimum bin size
+ binSize = Math.Max(1, binSize);
+
+ foreach (var e in hitEvents)
+ {
+ int binOffset = (int)(e.TimeOffset / binSize);
+ bins[timing_distribution_centre_bin_index + binOffset]++;
+ }
+
+ int maxCount = bins.Max();
+ var bars = new Drawable[total_timing_distribution_bins];
+ for (int i = 0; i < bars.Length; i++)
+ bars[i] = new Bar { Height = Math.Max(0.05f, (float)bins[i] / maxCount) };
+
+ Container axisFlow;
+
+ InternalChild = new GridContainer
+ {
+ Anchor = Anchor.Centre,
+ Origin = Anchor.Centre,
+ RelativeSizeAxes = Axes.Both,
+ Width = 0.8f,
+ Content = new[]
+ {
+ new Drawable[]
+ {
+ new GridContainer
+ {
+ RelativeSizeAxes = Axes.Both,
+ Content = new[] { bars }
+ }
+ },
+ new Drawable[]
+ {
+ axisFlow = new Container
+ {
+ RelativeSizeAxes = Axes.X,
+ AutoSizeAxes = Axes.Y
+ }
+ },
+ },
+ RowDimensions = new[]
+ {
+ new Dimension(),
+ new Dimension(GridSizeMode.AutoSize),
+ }
+ };
+
+ // Our axis will contain one centre element + 5 points on each side, each with a value depending on the number of bins * bin size.
+ double maxValue = timing_distribution_bins * binSize;
+ double axisValueStep = maxValue / axis_points;
+
+ axisFlow.Add(new OsuSpriteText
+ {
+ Anchor = Anchor.Centre,
+ Origin = Anchor.Centre,
+ Text = "0",
+ Font = OsuFont.GetFont(size: 12, weight: FontWeight.SemiBold)
+ });
+
+ for (int i = 1; i <= axis_points; i++)
+ {
+ double axisValue = i * axisValueStep;
+ float position = (float)(axisValue / maxValue);
+ float alpha = 1f - position * 0.8f;
+
+ axisFlow.Add(new OsuSpriteText
+ {
+ Anchor = Anchor.Centre,
+ Origin = Anchor.Centre,
+ RelativePositionAxes = Axes.X,
+ X = -position / 2,
+ Alpha = alpha,
+ Text = axisValue.ToString("-0"),
+ Font = OsuFont.GetFont(size: 12, weight: FontWeight.SemiBold)
+ });
+
+ axisFlow.Add(new OsuSpriteText
+ {
+ Anchor = Anchor.Centre,
+ Origin = Anchor.Centre,
+ RelativePositionAxes = Axes.X,
+ X = position / 2,
+ Alpha = alpha,
+ Text = axisValue.ToString("+0"),
+ Font = OsuFont.GetFont(size: 12, weight: FontWeight.SemiBold)
+ });
+ }
+ }
+
+ private class Bar : CompositeDrawable
+ {
+ public Bar()
+ {
+ Anchor = Anchor.BottomCentre;
+ Origin = Anchor.BottomCentre;
+
+ RelativeSizeAxes = Axes.Both;
+
+ Padding = new MarginPadding { Horizontal = 1 };
+
+ InternalChild = new Circle
+ {
+ RelativeSizeAxes = Axes.Both,
+ Colour = Color4Extensions.FromHex("#66FFCC")
+ };
+ }
+ }
+ }
+}
diff --git a/osu.Game/Screens/Ranking/Statistics/StatisticContainer.cs b/osu.Game/Screens/Ranking/Statistics/StatisticContainer.cs
new file mode 100644
index 0000000000..ed98698411
--- /dev/null
+++ b/osu.Game/Screens/Ranking/Statistics/StatisticContainer.cs
@@ -0,0 +1,82 @@
+// 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.CodeAnalysis;
+using osu.Framework.Extensions.Color4Extensions;
+using osu.Framework.Graphics;
+using osu.Framework.Graphics.Containers;
+using osu.Framework.Graphics.Shapes;
+using osu.Game.Graphics;
+using osu.Game.Graphics.Sprites;
+using osuTK;
+
+namespace osu.Game.Screens.Ranking.Statistics
+{
+ ///
+ /// Wraps a to add a header and suitable layout for use in .
+ ///
+ internal class StatisticContainer : CompositeDrawable
+ {
+ ///
+ /// Creates a new .
+ ///
+ /// The to display.
+ public StatisticContainer([NotNull] StatisticItem item)
+ {
+ RelativeSizeAxes = Axes.X;
+ AutoSizeAxes = Axes.Y;
+
+ InternalChild = new GridContainer
+ {
+ RelativeSizeAxes = Axes.X,
+ AutoSizeAxes = Axes.Y,
+ Content = new[]
+ {
+ new Drawable[]
+ {
+ new FillFlowContainer
+ {
+ RelativeSizeAxes = Axes.X,
+ AutoSizeAxes = Axes.Y,
+ Direction = FillDirection.Horizontal,
+ Spacing = new Vector2(5, 0),
+ Children = new Drawable[]
+ {
+ new Circle
+ {
+ Anchor = Anchor.CentreLeft,
+ Origin = Anchor.CentreLeft,
+ Height = 9,
+ Width = 4,
+ Colour = Color4Extensions.FromHex("#00FFAA")
+ },
+ new OsuSpriteText
+ {
+ Anchor = Anchor.CentreLeft,
+ Origin = Anchor.CentreLeft,
+ Text = item.Name,
+ Font = OsuFont.GetFont(size: 14, weight: FontWeight.SemiBold),
+ }
+ }
+ }
+ },
+ new Drawable[]
+ {
+ new Container
+ {
+ RelativeSizeAxes = Axes.X,
+ AutoSizeAxes = Axes.Y,
+ Margin = new MarginPadding { Top = 15 },
+ Child = item.Content
+ }
+ },
+ },
+ RowDimensions = new[]
+ {
+ new Dimension(GridSizeMode.AutoSize),
+ new Dimension(GridSizeMode.AutoSize),
+ }
+ };
+ }
+ }
+}
diff --git a/osu.Game/Screens/Ranking/Statistics/StatisticItem.cs b/osu.Game/Screens/Ranking/Statistics/StatisticItem.cs
new file mode 100644
index 0000000000..e959ed24fc
--- /dev/null
+++ b/osu.Game/Screens/Ranking/Statistics/StatisticItem.cs
@@ -0,0 +1,43 @@
+// Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence.
+// See the LICENCE file in the repository root for full licence text.
+
+using JetBrains.Annotations;
+using osu.Framework.Graphics;
+using osu.Framework.Graphics.Containers;
+
+namespace osu.Game.Screens.Ranking.Statistics
+{
+ ///
+ /// An item to be displayed in a row of statistics inside the results screen.
+ ///
+ public class StatisticItem
+ {
+ ///
+ /// The name of this item.
+ ///
+ public readonly string Name;
+
+ ///
+ /// The content to be displayed.
+ ///
+ public readonly Drawable Content;
+
+ ///
+ /// The of this row. This can be thought of as the column dimension of an encompassing .
+ ///
+ public readonly Dimension Dimension;
+
+ ///
+ /// Creates a new , to be displayed inside a in the results screen.
+ ///
+ /// The name of the item.
+ /// The content to be displayed.
+ /// The of this item. This can be thought of as the column dimension of an encompassing .
+ public StatisticItem([NotNull] string name, [NotNull] Drawable content, [CanBeNull] Dimension dimension = null)
+ {
+ Name = name;
+ Content = content;
+ Dimension = dimension;
+ }
+ }
+}
diff --git a/osu.Game/Screens/Ranking/Statistics/StatisticRow.cs b/osu.Game/Screens/Ranking/Statistics/StatisticRow.cs
new file mode 100644
index 0000000000..e1ca9799a3
--- /dev/null
+++ b/osu.Game/Screens/Ranking/Statistics/StatisticRow.cs
@@ -0,0 +1,19 @@
+// Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence.
+// See the LICENCE file in the repository root for full licence text.
+
+using JetBrains.Annotations;
+
+namespace osu.Game.Screens.Ranking.Statistics
+{
+ ///
+ /// A row of statistics to be displayed in the results screen.
+ ///
+ public class StatisticRow
+ {
+ ///
+ /// The columns of this .
+ ///
+ [ItemNotNull]
+ public StatisticItem[] Columns;
+ }
+}
diff --git a/osu.Game/Screens/Ranking/Statistics/StatisticsPanel.cs b/osu.Game/Screens/Ranking/Statistics/StatisticsPanel.cs
new file mode 100644
index 0000000000..7f406331cd
--- /dev/null
+++ b/osu.Game/Screens/Ranking/Statistics/StatisticsPanel.cs
@@ -0,0 +1,150 @@
+// 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.Linq;
+using System.Threading;
+using System.Threading.Tasks;
+using osu.Framework.Allocation;
+using osu.Framework.Bindables;
+using osu.Framework.Graphics;
+using osu.Framework.Graphics.Containers;
+using osu.Framework.Input.Events;
+using osu.Game.Beatmaps;
+using osu.Game.Graphics.UserInterface;
+using osu.Game.Online.Placeholders;
+using osu.Game.Rulesets.Mods;
+using osu.Game.Scoring;
+using osuTK;
+
+namespace osu.Game.Screens.Ranking.Statistics
+{
+ public class StatisticsPanel : VisibilityContainer
+ {
+ public const float SIDE_PADDING = 30;
+
+ public readonly Bindable Score = new Bindable();
+
+ protected override bool StartHidden => true;
+
+ [Resolved]
+ private BeatmapManager beatmapManager { get; set; }
+
+ private readonly Container content;
+ private readonly LoadingSpinner spinner;
+
+ public StatisticsPanel()
+ {
+ InternalChild = new Container
+ {
+ RelativeSizeAxes = Axes.Both,
+ Padding = new MarginPadding
+ {
+ Left = ScorePanel.EXPANDED_WIDTH + SIDE_PADDING * 3,
+ Right = SIDE_PADDING,
+ Top = SIDE_PADDING,
+ Bottom = 50 // Approximate padding to the bottom of the score panel.
+ },
+ Children = new Drawable[]
+ {
+ content = new Container { RelativeSizeAxes = Axes.Both },
+ spinner = new LoadingSpinner()
+ }
+ };
+ }
+
+ [BackgroundDependencyLoader]
+ private void load()
+ {
+ Score.BindValueChanged(populateStatistics, true);
+ }
+
+ private CancellationTokenSource loadCancellation;
+
+ private void populateStatistics(ValueChangedEvent score)
+ {
+ loadCancellation?.Cancel();
+ loadCancellation = null;
+
+ foreach (var child in content)
+ child.FadeOut(150).Expire();
+
+ var newScore = score.NewValue;
+
+ if (newScore == null)
+ return;
+
+ if (newScore.HitEvents == null || newScore.HitEvents.Count == 0)
+ content.Add(new MessagePlaceholder("Score has no statistics :("));
+ else
+ {
+ spinner.Show();
+
+ var localCancellationSource = loadCancellation = new CancellationTokenSource();
+ IBeatmap playableBeatmap = null;
+
+ // Todo: The placement of this is temporary. Eventually we'll both generate the playable beatmap _and_ run through it in a background task to generate the hit events.
+ Task.Run(() =>
+ {
+ playableBeatmap = beatmapManager.GetWorkingBeatmap(newScore.Beatmap).GetPlayableBeatmap(newScore.Ruleset, newScore.Mods ?? Array.Empty());
+ }, loadCancellation.Token).ContinueWith(t => Schedule(() =>
+ {
+ var rows = new FillFlowContainer
+ {
+ RelativeSizeAxes = Axes.Both,
+ Direction = FillDirection.Vertical,
+ Spacing = new Vector2(30, 15),
+ };
+
+ foreach (var row in newScore.Ruleset.CreateInstance().CreateStatisticsForScore(newScore, playableBeatmap))
+ {
+ rows.Add(new GridContainer
+ {
+ Anchor = Anchor.Centre,
+ Origin = Anchor.Centre,
+ RelativeSizeAxes = Axes.X,
+ AutoSizeAxes = Axes.Y,
+ Content = new[]
+ {
+ row.Columns?.Select(c => new StatisticContainer(c)
+ {
+ Anchor = Anchor.Centre,
+ Origin = Anchor.Centre,
+ }).Cast().ToArray()
+ },
+ ColumnDimensions = Enumerable.Range(0, row.Columns?.Length ?? 0)
+ .Select(i => row.Columns[i].Dimension ?? new Dimension()).ToArray(),
+ RowDimensions = new[] { new Dimension(GridSizeMode.AutoSize) }
+ });
+ }
+
+ LoadComponentAsync(rows, d =>
+ {
+ if (Score.Value != newScore)
+ return;
+
+ spinner.Hide();
+ content.Add(d);
+ }, localCancellationSource.Token);
+ }), localCancellationSource.Token);
+ }
+ }
+
+ protected override bool OnClick(ClickEvent e)
+ {
+ ToggleVisibility();
+ return true;
+ }
+
+ protected override void PopIn() => this.FadeIn(150, Easing.OutQuint);
+
+ protected override void PopOut() => this.FadeOut(150, Easing.OutQuint);
+
+ protected override void Dispose(bool isDisposing)
+ {
+ loadCancellation?.Cancel();
+
+ base.Dispose(isDisposing);
+ }
+ }
+}
diff --git a/osu.Game/Screens/Select/BeatmapCarousel.cs b/osu.Game/Screens/Select/BeatmapCarousel.cs
index e174c46610..6f913a3177 100644
--- a/osu.Game/Screens/Select/BeatmapCarousel.cs
+++ b/osu.Game/Screens/Select/BeatmapCarousel.cs
@@ -19,6 +19,7 @@ using osu.Framework.Extensions.IEnumerableExtensions;
using osu.Framework.Input.Bindings;
using osu.Framework.Input.Events;
using osu.Game.Beatmaps;
+using osu.Game.Extensions;
using osu.Game.Graphics.Containers;
using osu.Game.Graphics.Cursor;
using osu.Game.Input.Bindings;
@@ -301,6 +302,9 @@ namespace osu.Game.Screens.Select
private void selectNextDifficulty(int direction)
{
+ if (selectedBeatmap == null)
+ return;
+
var unfilteredDifficulties = selectedBeatmapSet.Children.Where(s => !s.Filtered.Value).ToList();
int index = unfilteredDifficulties.IndexOf(selectedBeatmap);
@@ -452,32 +456,49 @@ namespace osu.Game.Screens.Select
///
public void ScrollToSelected() => scrollPositionCache.Invalidate();
+ #region Key / button selection logic
+
protected override bool OnKeyDown(KeyDownEvent e)
{
switch (e.Key)
{
case Key.Left:
- SelectNext(-1, true);
+ if (!e.Repeat)
+ beginRepeatSelection(() => SelectNext(-1, true), e.Key);
return true;
case Key.Right:
- SelectNext(1, true);
+ if (!e.Repeat)
+ beginRepeatSelection(() => SelectNext(1, true), e.Key);
return true;
}
return false;
}
+ protected override void OnKeyUp(KeyUpEvent e)
+ {
+ switch (e.Key)
+ {
+ case Key.Left:
+ case Key.Right:
+ endRepeatSelection(e.Key);
+ break;
+ }
+
+ base.OnKeyUp(e);
+ }
+
public bool OnPressed(GlobalAction action)
{
switch (action)
{
case GlobalAction.SelectNext:
- SelectNext(1, false);
+ beginRepeatSelection(() => SelectNext(1, false), action);
return true;
case GlobalAction.SelectPrevious:
- SelectNext(-1, false);
+ beginRepeatSelection(() => SelectNext(-1, false), action);
return true;
}
@@ -486,8 +507,44 @@ namespace osu.Game.Screens.Select
public void OnReleased(GlobalAction action)
{
+ switch (action)
+ {
+ case GlobalAction.SelectNext:
+ case GlobalAction.SelectPrevious:
+ endRepeatSelection(action);
+ break;
+ }
}
+ private ScheduledDelegate repeatDelegate;
+ private object lastRepeatSource;
+
+ ///
+ /// Begin repeating the specified selection action.
+ ///
+ /// The action to perform.
+ /// The source of the action. Used in conjunction with to only cancel the correct action (most recently pressed key).
+ private void beginRepeatSelection(Action action, object source)
+ {
+ endRepeatSelection();
+
+ lastRepeatSource = source;
+ repeatDelegate = this.BeginKeyRepeat(Scheduler, action);
+ }
+
+ private void endRepeatSelection(object source = null)
+ {
+ // only the most recent source should be able to cancel the current action.
+ if (source != null && !EqualityComparer