mirror of
https://github.com/ppy/osu
synced 2025-01-18 20:10:49 +00:00
Merge branch 'master' into revert-10003-beatmapskin-interface
This commit is contained in:
commit
436242cf60
117
osu.Game.Rulesets.Mania.Tests/TestSceneOutOfOrderHits.cs
Normal file
117
osu.Game.Rulesets.Mania.Tests/TestSceneOutOfOrderHits.cs
Normal file
@ -0,0 +1,117 @@
|
||||
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
|
||||
// See the LICENCE file in the repository root for full licence text.
|
||||
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using NUnit.Framework;
|
||||
using osu.Framework.Extensions.TypeExtensions;
|
||||
using osu.Framework.Screens;
|
||||
using osu.Framework.Utils;
|
||||
using osu.Game.Beatmaps.ControlPoints;
|
||||
using osu.Game.Replays;
|
||||
using osu.Game.Rulesets.Judgements;
|
||||
using osu.Game.Rulesets.Mania.Beatmaps;
|
||||
using osu.Game.Rulesets.Mania.Objects;
|
||||
using osu.Game.Rulesets.Mania.Replays;
|
||||
using osu.Game.Rulesets.Replays;
|
||||
using osu.Game.Rulesets.Scoring;
|
||||
using osu.Game.Scoring;
|
||||
using osu.Game.Screens.Play;
|
||||
using osu.Game.Tests.Visual;
|
||||
|
||||
namespace osu.Game.Rulesets.Mania.Tests
|
||||
{
|
||||
public class TestSceneOutOfOrderHits : RateAdjustedBeatmapTestScene
|
||||
{
|
||||
[Test]
|
||||
public void TestPreviousHitWindowDoesNotExtendPastNextObject()
|
||||
{
|
||||
var objects = new List<ManiaHitObject>();
|
||||
var frames = new List<ReplayFrame>();
|
||||
|
||||
for (int i = 0; i < 7; i++)
|
||||
{
|
||||
double time = 1000 + i * 100;
|
||||
|
||||
objects.Add(new Note { StartTime = time });
|
||||
|
||||
if (i > 0)
|
||||
{
|
||||
frames.Add(new ManiaReplayFrame(time + 10, ManiaAction.Key1));
|
||||
frames.Add(new ManiaReplayFrame(time + 11));
|
||||
}
|
||||
}
|
||||
|
||||
performTest(objects, frames);
|
||||
|
||||
addJudgementAssert(objects[0], HitResult.Miss);
|
||||
|
||||
for (int i = 1; i < 7; i++)
|
||||
{
|
||||
addJudgementAssert(objects[i], HitResult.Perfect);
|
||||
addJudgementOffsetAssert(objects[i], 10);
|
||||
}
|
||||
}
|
||||
|
||||
private void addJudgementAssert(ManiaHitObject hitObject, HitResult result)
|
||||
{
|
||||
AddAssert($"({hitObject.GetType().ReadableName()} @ {hitObject.StartTime}) judgement is {result}",
|
||||
() => judgementResults.Single(r => r.HitObject == hitObject).Type == result);
|
||||
}
|
||||
|
||||
private void addJudgementOffsetAssert(ManiaHitObject hitObject, double offset)
|
||||
{
|
||||
AddAssert($"({hitObject.GetType().ReadableName()} @ {hitObject.StartTime}) judged at {offset}",
|
||||
() => Precision.AlmostEquals(judgementResults.Single(r => r.HitObject == hitObject).TimeOffset, offset, 100));
|
||||
}
|
||||
|
||||
private ScoreAccessibleReplayPlayer currentPlayer;
|
||||
private List<JudgementResult> judgementResults;
|
||||
|
||||
private void performTest(List<ManiaHitObject> hitObjects, List<ReplayFrame> frames)
|
||||
{
|
||||
AddStep("load player", () =>
|
||||
{
|
||||
Beatmap.Value = CreateWorkingBeatmap(new ManiaBeatmap(new StageDefinition { Columns = 4 })
|
||||
{
|
||||
HitObjects = hitObjects,
|
||||
BeatmapInfo =
|
||||
{
|
||||
Ruleset = new ManiaRuleset().RulesetInfo
|
||||
},
|
||||
});
|
||||
|
||||
Beatmap.Value.Beatmap.ControlPointInfo.Add(0, new DifficultyControlPoint { SpeedMultiplier = 0.1f });
|
||||
|
||||
var p = new ScoreAccessibleReplayPlayer(new Score { Replay = new Replay { Frames = frames } });
|
||||
|
||||
p.OnLoadComplete += _ =>
|
||||
{
|
||||
p.ScoreProcessor.NewJudgement += result =>
|
||||
{
|
||||
if (currentPlayer == p) judgementResults.Add(result);
|
||||
};
|
||||
};
|
||||
|
||||
LoadScreen(currentPlayer = p);
|
||||
judgementResults = new List<JudgementResult>();
|
||||
});
|
||||
|
||||
AddUntilStep("Beatmap at 0", () => Beatmap.Value.Track.CurrentTime == 0);
|
||||
AddUntilStep("Wait until player is loaded", () => currentPlayer.IsCurrentScreen());
|
||||
AddUntilStep("Wait for completion", () => currentPlayer.ScoreProcessor.HasCompleted.Value);
|
||||
}
|
||||
|
||||
private class ScoreAccessibleReplayPlayer : ReplayPlayer
|
||||
{
|
||||
public new ScoreProcessor ScoreProcessor => base.ScoreProcessor;
|
||||
|
||||
protected override bool PauseOnFocusLost => false;
|
||||
|
||||
public ScoreAccessibleReplayPlayer(Score score)
|
||||
: base(score, false, false)
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -255,6 +255,9 @@ namespace osu.Game.Rulesets.Mania.Objects.Drawables
|
||||
if (action != Action.Value)
|
||||
return false;
|
||||
|
||||
if (CheckHittable?.Invoke(this, Time.Current) == false)
|
||||
return false;
|
||||
|
||||
// The tail has a lenience applied to it which is factored into the miss window (i.e. the miss judgement will be delayed).
|
||||
// But the hold cannot ever be started within the late-lenience window, so we should skip trying to begin the hold during that time.
|
||||
// Note: Unlike below, we use the tail's start time to determine the time offset.
|
||||
|
@ -1,6 +1,7 @@
|
||||
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
|
||||
// See the LICENCE file in the repository root for full licence text.
|
||||
|
||||
using System;
|
||||
using JetBrains.Annotations;
|
||||
using osu.Framework.Allocation;
|
||||
using osu.Framework.Bindables;
|
||||
@ -8,6 +9,7 @@ using osu.Framework.Graphics;
|
||||
using osu.Game.Rulesets.Objects.Drawables;
|
||||
using osu.Game.Rulesets.UI.Scrolling;
|
||||
using osu.Game.Rulesets.Mania.UI;
|
||||
using osu.Game.Rulesets.Scoring;
|
||||
|
||||
namespace osu.Game.Rulesets.Mania.Objects.Drawables
|
||||
{
|
||||
@ -34,6 +36,12 @@ namespace osu.Game.Rulesets.Mania.Objects.Drawables
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Whether this <see cref="DrawableManiaHitObject"/> can be hit, given a time value.
|
||||
/// If non-null, judgements will be ignored whilst the function returns false.
|
||||
/// </summary>
|
||||
public Func<DrawableHitObject, double, bool> CheckHittable;
|
||||
|
||||
protected DrawableManiaHitObject(ManiaHitObject hitObject)
|
||||
: base(hitObject)
|
||||
{
|
||||
@ -124,6 +132,11 @@ namespace osu.Game.Rulesets.Mania.Objects.Drawables
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Causes this <see cref="DrawableManiaHitObject"/> to get missed, disregarding all conditions in implementations of <see cref="DrawableHitObject.CheckForResult"/>.
|
||||
/// </summary>
|
||||
public void MissForcefully() => ApplyResult(r => r.Type = HitResult.Miss);
|
||||
}
|
||||
|
||||
public abstract class DrawableManiaHitObject<TObject> : DrawableManiaHitObject
|
||||
|
@ -64,6 +64,9 @@ namespace osu.Game.Rulesets.Mania.Objects.Drawables
|
||||
if (action != Action.Value)
|
||||
return false;
|
||||
|
||||
if (CheckHittable?.Invoke(this, Time.Current) == false)
|
||||
return false;
|
||||
|
||||
return UpdateResult(true);
|
||||
}
|
||||
|
||||
|
@ -17,6 +17,7 @@ using osu.Game.Rulesets.UI.Scrolling;
|
||||
using osu.Game.Skinning;
|
||||
using osuTK;
|
||||
using osu.Game.Rulesets.Mania.Beatmaps;
|
||||
using osu.Game.Rulesets.Mania.Objects.Drawables;
|
||||
|
||||
namespace osu.Game.Rulesets.Mania.UI
|
||||
{
|
||||
@ -36,6 +37,7 @@ namespace osu.Game.Rulesets.Mania.UI
|
||||
public readonly ColumnHitObjectArea HitObjectArea;
|
||||
internal readonly Container TopLevelContainer;
|
||||
private readonly DrawablePool<PoolableHitExplosion> hitExplosionPool;
|
||||
private readonly OrderedHitPolicy hitPolicy;
|
||||
|
||||
public Container UnderlayElements => HitObjectArea.UnderlayElements;
|
||||
|
||||
@ -65,6 +67,8 @@ namespace osu.Game.Rulesets.Mania.UI
|
||||
TopLevelContainer = new Container { RelativeSizeAxes = Axes.Both }
|
||||
};
|
||||
|
||||
hitPolicy = new OrderedHitPolicy(HitObjectContainer);
|
||||
|
||||
TopLevelContainer.Add(HitObjectArea.Explosions.CreateProxy());
|
||||
}
|
||||
|
||||
@ -90,6 +94,9 @@ namespace osu.Game.Rulesets.Mania.UI
|
||||
hitObject.AccentColour.Value = AccentColour;
|
||||
hitObject.OnNewResult += OnNewResult;
|
||||
|
||||
DrawableManiaHitObject maniaObject = (DrawableManiaHitObject)hitObject;
|
||||
maniaObject.CheckHittable = hitPolicy.IsHittable;
|
||||
|
||||
HitObjectContainer.Add(hitObject);
|
||||
}
|
||||
|
||||
@ -104,6 +111,9 @@ namespace osu.Game.Rulesets.Mania.UI
|
||||
|
||||
internal void OnNewResult(DrawableHitObject judgedObject, JudgementResult result)
|
||||
{
|
||||
if (result.IsHit)
|
||||
hitPolicy.HandleHit(judgedObject);
|
||||
|
||||
if (!result.IsHit || !judgedObject.DisplayResult || !DisplayJudgements.Value)
|
||||
return;
|
||||
|
||||
|
78
osu.Game.Rulesets.Mania/UI/OrderedHitPolicy.cs
Normal file
78
osu.Game.Rulesets.Mania/UI/OrderedHitPolicy.cs
Normal file
@ -0,0 +1,78 @@
|
||||
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
|
||||
// See the LICENCE file in the repository root for full licence text.
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using osu.Framework.Extensions.IEnumerableExtensions;
|
||||
using osu.Game.Rulesets.Mania.Objects.Drawables;
|
||||
using osu.Game.Rulesets.Objects;
|
||||
using osu.Game.Rulesets.Objects.Drawables;
|
||||
using osu.Game.Rulesets.UI;
|
||||
|
||||
namespace osu.Game.Rulesets.Mania.UI
|
||||
{
|
||||
/// <summary>
|
||||
/// Ensures that only the most recent <see cref="HitObject"/> is hittable, affectionately known as "note lock".
|
||||
/// </summary>
|
||||
public class OrderedHitPolicy
|
||||
{
|
||||
private readonly HitObjectContainer hitObjectContainer;
|
||||
|
||||
public OrderedHitPolicy(HitObjectContainer hitObjectContainer)
|
||||
{
|
||||
this.hitObjectContainer = hitObjectContainer;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Determines whether a <see cref="DrawableHitObject"/> can be hit at a point in time.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// Only the most recent <see cref="DrawableHitObject"/> can be hit, a previous hitobject's window cannot extend past the next one.
|
||||
/// </remarks>
|
||||
/// <param name="hitObject">The <see cref="DrawableHitObject"/> to check.</param>
|
||||
/// <param name="time">The time to check.</param>
|
||||
/// <returns>Whether <paramref name="hitObject"/> can be hit at the given <paramref name="time"/>.</returns>
|
||||
public bool IsHittable(DrawableHitObject hitObject, double time)
|
||||
{
|
||||
var nextObject = hitObjectContainer.AliveObjects.GetNext(hitObject);
|
||||
return nextObject == null || time < nextObject.HitObject.StartTime;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Handles a <see cref="HitObject"/> being hit to potentially miss all earlier <see cref="HitObject"/>s.
|
||||
/// </summary>
|
||||
/// <param name="hitObject">The <see cref="HitObject"/> that was hit.</param>
|
||||
public void HandleHit(DrawableHitObject hitObject)
|
||||
{
|
||||
if (!IsHittable(hitObject, hitObject.HitObject.StartTime + hitObject.Result.TimeOffset))
|
||||
throw new InvalidOperationException($"A {hitObject} was hit before it became hittable!");
|
||||
|
||||
foreach (var obj in enumerateHitObjectsUpTo(hitObject.HitObject.StartTime))
|
||||
{
|
||||
if (obj.Judged)
|
||||
continue;
|
||||
|
||||
((DrawableManiaHitObject)obj).MissForcefully();
|
||||
}
|
||||
}
|
||||
|
||||
private IEnumerable<DrawableHitObject> enumerateHitObjectsUpTo(double targetTime)
|
||||
{
|
||||
foreach (var obj in hitObjectContainer.AliveObjects)
|
||||
{
|
||||
if (obj.HitObject.GetEndTime() >= targetTime)
|
||||
yield break;
|
||||
|
||||
yield return obj;
|
||||
|
||||
foreach (var nestedObj in obj.NestedHitObjects)
|
||||
{
|
||||
if (nestedObj.HitObject.GetEndTime() >= targetTime)
|
||||
break;
|
||||
|
||||
yield return nestedObj;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -22,7 +22,7 @@ namespace osu.Game.Rulesets.Osu.Objects.Drawables
|
||||
protected override float SamplePlaybackPosition => HitObject.X / OsuPlayfield.BASE_SIZE.X;
|
||||
|
||||
/// <summary>
|
||||
/// Whether this <see cref="DrawableOsuHitObject"/> can be hit.
|
||||
/// Whether this <see cref="DrawableOsuHitObject"/> can be hit, given a time value.
|
||||
/// If non-null, judgements will be ignored (resulting in a shake) whilst the function returns false.
|
||||
/// </summary>
|
||||
public Func<DrawableHitObject, double, bool> CheckHittable;
|
||||
|
@ -154,8 +154,12 @@ namespace osu.Game.Rulesets.Osu.Replays
|
||||
// The startPosition for the slider should not be its .Position, but the point on the circle whose tangent crosses the current cursor position
|
||||
// We also modify spinnerDirection so it spins in the direction it enters the spin circle, to make a smooth transition.
|
||||
// TODO: Shouldn't the spinner always spin in the same direction?
|
||||
if (h is Spinner)
|
||||
if (h is Spinner spinner)
|
||||
{
|
||||
// spinners with 0 spins required will auto-complete - don't bother
|
||||
if (spinner.SpinsRequired == 0)
|
||||
return;
|
||||
|
||||
calcSpinnerStartPosAndDirection(((OsuReplayFrame)Frames[^1]).Position, out startPosition, out spinnerDirection);
|
||||
|
||||
Vector2 spinCentreOffset = SPINNER_CENTRE - ((OsuReplayFrame)Frames[^1]).Position;
|
||||
|
@ -27,6 +27,7 @@ using osu.Framework.Logging;
|
||||
using osu.Game.Rulesets;
|
||||
using osu.Game.Rulesets.Mods;
|
||||
using osu.Game.Rulesets.UI;
|
||||
using osu.Game.Screens.Ranking.Expanded;
|
||||
|
||||
namespace osu.Game.Screens.Select
|
||||
{
|
||||
@ -222,10 +223,20 @@ namespace osu.Game.Screens.Select
|
||||
Direction = FillDirection.Vertical,
|
||||
Padding = new MarginPadding { Top = 14, Right = shear_width / 2 },
|
||||
AutoSizeAxes = Axes.Both,
|
||||
Children = new Drawable[]
|
||||
Shear = wedged_container_shear,
|
||||
Children = new[]
|
||||
{
|
||||
createStarRatingDisplay(beatmapInfo).With(display =>
|
||||
{
|
||||
display.Anchor = Anchor.TopRight;
|
||||
display.Origin = Anchor.TopRight;
|
||||
display.Shear = -wedged_container_shear;
|
||||
}),
|
||||
StatusPill = new BeatmapSetOnlineStatusPill
|
||||
{
|
||||
Anchor = Anchor.TopRight,
|
||||
Origin = Anchor.TopRight,
|
||||
Shear = -wedged_container_shear,
|
||||
TextSize = 11,
|
||||
TextPadding = new MarginPadding { Horizontal = 8, Vertical = 2 },
|
||||
Status = beatmapInfo.Status,
|
||||
@ -282,6 +293,13 @@ namespace osu.Game.Screens.Select
|
||||
StatusPill.Hide();
|
||||
}
|
||||
|
||||
private static Drawable createStarRatingDisplay(BeatmapInfo beatmapInfo) => beatmapInfo.StarDifficulty > 0
|
||||
? new StarRatingDisplay(beatmapInfo)
|
||||
{
|
||||
Margin = new MarginPadding { Bottom = 5 }
|
||||
}
|
||||
: Empty();
|
||||
|
||||
private void setMetadata(string source)
|
||||
{
|
||||
ArtistLabel.Text = artistBinding.Value;
|
||||
|
Loading…
Reference in New Issue
Block a user