mirror of
https://github.com/ppy/osu.git
synced 2025-01-12 23:12:56 +08:00
Merge branch 'master' into legacy-scores-classic-mod
This commit is contained in:
commit
d4d78f7434
@ -52,6 +52,6 @@
|
|||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<PackageReference Include="ppy.osu.Game.Resources" Version="2021.412.0" />
|
<PackageReference Include="ppy.osu.Game.Resources" Version="2021.412.0" />
|
||||||
<PackageReference Include="ppy.osu.Framework.Android" Version="2021.419.0" />
|
<PackageReference Include="ppy.osu.Framework.Android" Version="2021.422.0" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
</Project>
|
</Project>
|
||||||
|
@ -10,6 +10,7 @@ using osu.Game.Rulesets.Catch.UI;
|
|||||||
using osu.Framework.Graphics;
|
using osu.Framework.Graphics;
|
||||||
using osu.Framework.Graphics.Containers;
|
using osu.Framework.Graphics.Containers;
|
||||||
using osu.Framework.Testing;
|
using osu.Framework.Testing;
|
||||||
|
using osu.Framework.Utils;
|
||||||
using osu.Game.Beatmaps;
|
using osu.Game.Beatmaps;
|
||||||
using osu.Game.Beatmaps.ControlPoints;
|
using osu.Game.Beatmaps.ControlPoints;
|
||||||
using osu.Game.Configuration;
|
using osu.Game.Configuration;
|
||||||
@ -20,6 +21,7 @@ using osu.Game.Rulesets.Judgements;
|
|||||||
using osu.Game.Rulesets.Scoring;
|
using osu.Game.Rulesets.Scoring;
|
||||||
using osu.Game.Skinning;
|
using osu.Game.Skinning;
|
||||||
using osu.Game.Tests.Visual;
|
using osu.Game.Tests.Visual;
|
||||||
|
using osuTK;
|
||||||
|
|
||||||
namespace osu.Game.Rulesets.Catch.Tests
|
namespace osu.Game.Rulesets.Catch.Tests
|
||||||
{
|
{
|
||||||
@ -170,16 +172,25 @@ namespace osu.Game.Rulesets.Catch.Tests
|
|||||||
}
|
}
|
||||||
|
|
||||||
[Test]
|
[Test]
|
||||||
public void TestCatcherStacking()
|
public void TestCatcherRandomStacking()
|
||||||
|
{
|
||||||
|
AddStep("catch more fruits", () => attemptCatch(() => new Fruit
|
||||||
|
{
|
||||||
|
X = (RNG.NextSingle() - 0.5f) * Catcher.CalculateCatchWidth(Vector2.One)
|
||||||
|
}, 50));
|
||||||
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void TestCatcherStackingSameCaughtPosition()
|
||||||
{
|
{
|
||||||
AddStep("catch fruit", () => attemptCatch(new Fruit()));
|
AddStep("catch fruit", () => attemptCatch(new Fruit()));
|
||||||
checkPlate(1);
|
checkPlate(1);
|
||||||
AddStep("catch more fruits", () => attemptCatch(new Fruit(), 9));
|
AddStep("catch more fruits", () => attemptCatch(() => new Fruit(), 9));
|
||||||
checkPlate(10);
|
checkPlate(10);
|
||||||
AddAssert("caught objects are stacked", () =>
|
AddAssert("caught objects are stacked", () =>
|
||||||
catcher.CaughtObjects.All(obj => obj.Y <= 0) &&
|
catcher.CaughtObjects.All(obj => obj.Y <= Catcher.CAUGHT_FRUIT_VERTICAL_OFFSET) &&
|
||||||
catcher.CaughtObjects.Any(obj => obj.Y == 0) &&
|
catcher.CaughtObjects.Any(obj => obj.Y == Catcher.CAUGHT_FRUIT_VERTICAL_OFFSET) &&
|
||||||
catcher.CaughtObjects.Any(obj => obj.Y < -20));
|
catcher.CaughtObjects.Any(obj => obj.Y < -25));
|
||||||
}
|
}
|
||||||
|
|
||||||
[Test]
|
[Test]
|
||||||
@ -189,11 +200,11 @@ namespace osu.Game.Rulesets.Catch.Tests
|
|||||||
AddStep("catch tiny droplet", () => attemptCatch(new TinyDroplet()));
|
AddStep("catch tiny droplet", () => attemptCatch(new TinyDroplet()));
|
||||||
AddAssert("tiny droplet is exploded", () => catcher.CaughtObjects.Count() == 1 && droppedObjectContainer.Count == 1);
|
AddAssert("tiny droplet is exploded", () => catcher.CaughtObjects.Count() == 1 && droppedObjectContainer.Count == 1);
|
||||||
AddUntilStep("wait explosion", () => !droppedObjectContainer.Any());
|
AddUntilStep("wait explosion", () => !droppedObjectContainer.Any());
|
||||||
AddStep("catch more fruits", () => attemptCatch(new Fruit(), 9));
|
AddStep("catch more fruits", () => attemptCatch(() => new Fruit(), 9));
|
||||||
AddStep("explode", () => catcher.Explode());
|
AddStep("explode", () => catcher.Explode());
|
||||||
AddAssert("fruits are exploded", () => !catcher.CaughtObjects.Any() && droppedObjectContainer.Count == 10);
|
AddAssert("fruits are exploded", () => !catcher.CaughtObjects.Any() && droppedObjectContainer.Count == 10);
|
||||||
AddUntilStep("wait explosion", () => !droppedObjectContainer.Any());
|
AddUntilStep("wait explosion", () => !droppedObjectContainer.Any());
|
||||||
AddStep("catch fruits", () => attemptCatch(new Fruit(), 10));
|
AddStep("catch fruits", () => attemptCatch(() => new Fruit(), 10));
|
||||||
AddStep("drop", () => catcher.Drop());
|
AddStep("drop", () => catcher.Drop());
|
||||||
AddAssert("fruits are dropped", () => !catcher.CaughtObjects.Any() && droppedObjectContainer.Count == 10);
|
AddAssert("fruits are dropped", () => !catcher.CaughtObjects.Any() && droppedObjectContainer.Count == 10);
|
||||||
}
|
}
|
||||||
@ -222,10 +233,15 @@ namespace osu.Game.Rulesets.Catch.Tests
|
|||||||
|
|
||||||
private void checkHyperDash(bool state) => AddAssert($"catcher is {(state ? "" : "not ")}hyper dashing", () => catcher.HyperDashing == state);
|
private void checkHyperDash(bool state) => AddAssert($"catcher is {(state ? "" : "not ")}hyper dashing", () => catcher.HyperDashing == state);
|
||||||
|
|
||||||
private void attemptCatch(CatchHitObject hitObject, int count = 1)
|
private void attemptCatch(CatchHitObject hitObject)
|
||||||
|
{
|
||||||
|
attemptCatch(() => hitObject, 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void attemptCatch(Func<CatchHitObject> hitObject, int count)
|
||||||
{
|
{
|
||||||
for (var i = 0; i < count; i++)
|
for (var i = 0; i < count; i++)
|
||||||
attemptCatch(hitObject, out _, out _);
|
attemptCatch(hitObject(), out _, out _);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void attemptCatch(CatchHitObject hitObject, out DrawableCatchHitObject drawableObject, out JudgementResult result)
|
private void attemptCatch(CatchHitObject hitObject, out DrawableCatchHitObject drawableObject, out JudgementResult result)
|
||||||
|
@ -8,6 +8,8 @@ using osu.Framework.Extensions.IEnumerableExtensions;
|
|||||||
using osu.Framework.Graphics;
|
using osu.Framework.Graphics;
|
||||||
using osu.Framework.Graphics.Containers;
|
using osu.Framework.Graphics.Containers;
|
||||||
using osu.Framework.Testing;
|
using osu.Framework.Testing;
|
||||||
|
using osu.Framework.Threading;
|
||||||
|
using osu.Framework.Utils;
|
||||||
using osu.Game.Beatmaps;
|
using osu.Game.Beatmaps;
|
||||||
using osu.Game.Beatmaps.ControlPoints;
|
using osu.Game.Beatmaps.ControlPoints;
|
||||||
using osu.Game.Configuration;
|
using osu.Game.Configuration;
|
||||||
@ -31,12 +33,32 @@ namespace osu.Game.Rulesets.Catch.Tests
|
|||||||
|
|
||||||
private float circleSize;
|
private float circleSize;
|
||||||
|
|
||||||
|
private ScheduledDelegate addManyFruit;
|
||||||
|
|
||||||
|
private BeatmapDifficulty beatmapDifficulty;
|
||||||
|
|
||||||
public TestSceneCatcherArea()
|
public TestSceneCatcherArea()
|
||||||
{
|
{
|
||||||
AddSliderStep<float>("circle size", 0, 8, 5, createCatcher);
|
AddSliderStep<float>("circle size", 0, 8, 5, createCatcher);
|
||||||
AddToggleStep("hyper dash", t => this.ChildrenOfType<TestCatcherArea>().ForEach(area => area.ToggleHyperDash(t)));
|
AddToggleStep("hyper dash", t => this.ChildrenOfType<TestCatcherArea>().ForEach(area => area.ToggleHyperDash(t)));
|
||||||
|
|
||||||
AddStep("catch fruit", () => attemptCatch(new Fruit()));
|
AddStep("catch centered fruit", () => attemptCatch(new Fruit()));
|
||||||
|
AddStep("catch many random fruit", () =>
|
||||||
|
{
|
||||||
|
int count = 50;
|
||||||
|
|
||||||
|
addManyFruit?.Cancel();
|
||||||
|
addManyFruit = Scheduler.AddDelayed(() =>
|
||||||
|
{
|
||||||
|
attemptCatch(new Fruit
|
||||||
|
{
|
||||||
|
X = (RNG.NextSingle() - 0.5f) * Catcher.CalculateCatchWidth(beatmapDifficulty) * 0.6f,
|
||||||
|
});
|
||||||
|
|
||||||
|
if (count-- == 0)
|
||||||
|
addManyFruit?.Cancel();
|
||||||
|
}, 50, true);
|
||||||
|
});
|
||||||
AddStep("catch fruit last in combo", () => attemptCatch(new Fruit { LastInCombo = true }));
|
AddStep("catch fruit last in combo", () => attemptCatch(new Fruit { LastInCombo = true }));
|
||||||
AddStep("catch kiai fruit", () => attemptCatch(new TestSceneCatcher.TestKiaiFruit()));
|
AddStep("catch kiai fruit", () => attemptCatch(new TestSceneCatcher.TestKiaiFruit()));
|
||||||
AddStep("miss last in combo", () => attemptCatch(new Fruit { X = 100, LastInCombo = true }));
|
AddStep("miss last in combo", () => attemptCatch(new Fruit { X = 100, LastInCombo = true }));
|
||||||
@ -45,10 +67,7 @@ namespace osu.Game.Rulesets.Catch.Tests
|
|||||||
private void attemptCatch(Fruit fruit)
|
private void attemptCatch(Fruit fruit)
|
||||||
{
|
{
|
||||||
fruit.X = fruit.OriginalX + catcher.X;
|
fruit.X = fruit.OriginalX + catcher.X;
|
||||||
fruit.ApplyDefaults(new ControlPointInfo(), new BeatmapDifficulty
|
fruit.ApplyDefaults(new ControlPointInfo(), beatmapDifficulty);
|
||||||
{
|
|
||||||
CircleSize = circleSize
|
|
||||||
});
|
|
||||||
|
|
||||||
foreach (var area in this.ChildrenOfType<CatcherArea>())
|
foreach (var area in this.ChildrenOfType<CatcherArea>())
|
||||||
{
|
{
|
||||||
@ -71,6 +90,11 @@ namespace osu.Game.Rulesets.Catch.Tests
|
|||||||
{
|
{
|
||||||
circleSize = size;
|
circleSize = size;
|
||||||
|
|
||||||
|
beatmapDifficulty = new BeatmapDifficulty
|
||||||
|
{
|
||||||
|
CircleSize = circleSize
|
||||||
|
};
|
||||||
|
|
||||||
SetContents(() =>
|
SetContents(() =>
|
||||||
{
|
{
|
||||||
var droppedObjectContainer = new Container<CaughtObject>
|
var droppedObjectContainer = new Container<CaughtObject>
|
||||||
@ -84,7 +108,7 @@ namespace osu.Game.Rulesets.Catch.Tests
|
|||||||
Children = new Drawable[]
|
Children = new Drawable[]
|
||||||
{
|
{
|
||||||
droppedObjectContainer,
|
droppedObjectContainer,
|
||||||
new TestCatcherArea(droppedObjectContainer, new BeatmapDifficulty { CircleSize = size })
|
new TestCatcherArea(droppedObjectContainer, beatmapDifficulty)
|
||||||
{
|
{
|
||||||
Anchor = Anchor.Centre,
|
Anchor = Anchor.Centre,
|
||||||
Origin = Anchor.TopCentre,
|
Origin = Anchor.TopCentre,
|
||||||
|
@ -53,6 +53,16 @@ namespace osu.Game.Rulesets.Catch.UI
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public const double BASE_SPEED = 1.0;
|
public const double BASE_SPEED = 1.0;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// The amount by which caught fruit should be offset from the plate surface to make them look visually "caught".
|
||||||
|
/// </summary>
|
||||||
|
public const float CAUGHT_FRUIT_VERTICAL_OFFSET = -5;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// The amount by which caught fruit should be scaled down to fit on the plate.
|
||||||
|
/// </summary>
|
||||||
|
private const float caught_fruit_scale_adjust = 0.5f;
|
||||||
|
|
||||||
[NotNull]
|
[NotNull]
|
||||||
private readonly Container trailsTarget;
|
private readonly Container trailsTarget;
|
||||||
|
|
||||||
@ -202,13 +212,13 @@ namespace osu.Game.Rulesets.Catch.UI
|
|||||||
/// Calculates the width of the area used for attempting catches in gameplay.
|
/// Calculates the width of the area used for attempting catches in gameplay.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="scale">The scale of the catcher.</param>
|
/// <param name="scale">The scale of the catcher.</param>
|
||||||
internal static float CalculateCatchWidth(Vector2 scale) => CatcherArea.CATCHER_SIZE * Math.Abs(scale.X) * ALLOWED_CATCH_RANGE;
|
public static float CalculateCatchWidth(Vector2 scale) => CatcherArea.CATCHER_SIZE * Math.Abs(scale.X) * ALLOWED_CATCH_RANGE;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Calculates the width of the area used for attempting catches in gameplay.
|
/// Calculates the width of the area used for attempting catches in gameplay.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="difficulty">The beatmap difficulty.</param>
|
/// <param name="difficulty">The beatmap difficulty.</param>
|
||||||
internal static float CalculateCatchWidth(BeatmapDifficulty difficulty) => CalculateCatchWidth(calculateScale(difficulty));
|
public static float CalculateCatchWidth(BeatmapDifficulty difficulty) => CalculateCatchWidth(calculateScale(difficulty));
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Determine if this catcher can catch a <see cref="CatchHitObject"/> in the current position.
|
/// Determine if this catcher can catch a <see cref="CatchHitObject"/> in the current position.
|
||||||
@ -240,7 +250,7 @@ namespace osu.Game.Rulesets.Catch.UI
|
|||||||
|
|
||||||
if (result.IsHit)
|
if (result.IsHit)
|
||||||
{
|
{
|
||||||
var positionInStack = computePositionInStack(new Vector2(palpableObject.X - X, 0), palpableObject.DisplaySize.X / 2);
|
var positionInStack = computePositionInStack(new Vector2(palpableObject.X - X, 0), palpableObject.DisplaySize.X);
|
||||||
|
|
||||||
if (CatchFruitOnPlate)
|
if (CatchFruitOnPlate)
|
||||||
placeCaughtObject(palpableObject, positionInStack);
|
placeCaughtObject(palpableObject, positionInStack);
|
||||||
@ -470,7 +480,7 @@ namespace osu.Game.Rulesets.Catch.UI
|
|||||||
caughtObject.CopyStateFrom(drawableObject);
|
caughtObject.CopyStateFrom(drawableObject);
|
||||||
caughtObject.Anchor = Anchor.TopCentre;
|
caughtObject.Anchor = Anchor.TopCentre;
|
||||||
caughtObject.Position = position;
|
caughtObject.Position = position;
|
||||||
caughtObject.Scale /= 2;
|
caughtObject.Scale *= caught_fruit_scale_adjust;
|
||||||
|
|
||||||
caughtObjectContainer.Add(caughtObject);
|
caughtObjectContainer.Add(caughtObject);
|
||||||
|
|
||||||
@ -480,19 +490,21 @@ namespace osu.Game.Rulesets.Catch.UI
|
|||||||
|
|
||||||
private Vector2 computePositionInStack(Vector2 position, float displayRadius)
|
private Vector2 computePositionInStack(Vector2 position, float displayRadius)
|
||||||
{
|
{
|
||||||
const float radius_div_2 = CatchHitObject.OBJECT_RADIUS / 2;
|
// this is taken from osu-stable (lenience should be 10 * 10 at standard scale).
|
||||||
const float allowance = 10;
|
const float lenience_adjust = 10 / CatchHitObject.OBJECT_RADIUS;
|
||||||
|
|
||||||
while (caughtObjectContainer.Any(f => Vector2Extensions.Distance(f.Position, position) < (displayRadius + radius_div_2) / (allowance / 2)))
|
float adjustedRadius = displayRadius * lenience_adjust;
|
||||||
|
float checkDistance = MathF.Pow(adjustedRadius, 2);
|
||||||
|
|
||||||
|
// offset fruit vertically to better place "above" the plate.
|
||||||
|
position.Y += CAUGHT_FRUIT_VERTICAL_OFFSET;
|
||||||
|
|
||||||
|
while (caughtObjectContainer.Any(f => Vector2Extensions.DistanceSquared(f.Position, position) < checkDistance))
|
||||||
{
|
{
|
||||||
float diff = (displayRadius + radius_div_2) / allowance;
|
position.X += RNG.NextSingle(-adjustedRadius, adjustedRadius);
|
||||||
|
position.Y -= RNG.NextSingle(0, 5);
|
||||||
position.X += (RNG.NextSingle() - 0.5f) * diff * 2;
|
|
||||||
position.Y -= RNG.NextSingle() * diff;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
position.X = Math.Clamp(position.X, -CatcherArea.CATCHER_SIZE / 2, CatcherArea.CATCHER_SIZE / 2);
|
|
||||||
|
|
||||||
return position;
|
return position;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -32,7 +32,7 @@ namespace osu.Game.Rulesets.Osu.Tests
|
|||||||
{
|
{
|
||||||
Position = new Vector2(128, 128),
|
Position = new Vector2(128, 128),
|
||||||
ComboIndex = 1,
|
ComboIndex = 1,
|
||||||
}), null));
|
})));
|
||||||
}
|
}
|
||||||
|
|
||||||
private HitCircle prepareObject(HitCircle circle)
|
private HitCircle prepareObject(HitCircle circle)
|
||||||
|
@ -57,7 +57,7 @@ namespace osu.Game.Rulesets.Osu.Tests
|
|||||||
new Vector2(300, 0),
|
new Vector2(300, 0),
|
||||||
}),
|
}),
|
||||||
RepeatCount = 1
|
RepeatCount = 1
|
||||||
}), null));
|
})));
|
||||||
}
|
}
|
||||||
|
|
||||||
[Test]
|
[Test]
|
||||||
|
@ -37,7 +37,7 @@ namespace osu.Game.Rulesets.Osu.Tests
|
|||||||
Position = new Vector2(256, 192),
|
Position = new Vector2(256, 192),
|
||||||
ComboIndex = 1,
|
ComboIndex = 1,
|
||||||
Duration = 1000,
|
Duration = 1000,
|
||||||
}), null));
|
})));
|
||||||
|
|
||||||
AddAssert("rotation is reset", () => dho.Result.RateAdjustedRotation == 0);
|
AddAssert("rotation is reset", () => dho.Result.RateAdjustedRotation == 0);
|
||||||
}
|
}
|
||||||
|
@ -21,6 +21,7 @@ using osu.Game.Rulesets.Osu.UI;
|
|||||||
using osu.Game.Rulesets.Replays;
|
using osu.Game.Rulesets.Replays;
|
||||||
using osu.Game.Rulesets.Scoring;
|
using osu.Game.Rulesets.Scoring;
|
||||||
using osu.Game.Scoring;
|
using osu.Game.Scoring;
|
||||||
|
using osu.Game.Screens.Play;
|
||||||
using osu.Game.Storyboards;
|
using osu.Game.Storyboards;
|
||||||
using osu.Game.Tests.Visual;
|
using osu.Game.Tests.Visual;
|
||||||
using osuTK;
|
using osuTK;
|
||||||
@ -193,7 +194,7 @@ namespace osu.Game.Rulesets.Osu.Tests
|
|||||||
|
|
||||||
addSeekStep(0);
|
addSeekStep(0);
|
||||||
|
|
||||||
AddStep("adjust track rate", () => Player.GameplayClockContainer.UserPlaybackRate.Value = rate);
|
AddStep("adjust track rate", () => ((MasterGameplayClockContainer)Player.GameplayClockContainer).UserPlaybackRate.Value = rate);
|
||||||
|
|
||||||
addSeekStep(1000);
|
addSeekStep(1000);
|
||||||
AddAssert("progress almost same", () => Precision.AlmostEquals(expectedProgress, drawableSpinner.Progress, 0.05));
|
AddAssert("progress almost same", () => Precision.AlmostEquals(expectedProgress, drawableSpinner.Progress, 0.05));
|
||||||
|
@ -34,9 +34,9 @@ namespace osu.Game.Rulesets.Osu.Mods
|
|||||||
var osuObject = (OsuHitObject)drawable.HitObject;
|
var osuObject = (OsuHitObject)drawable.HitObject;
|
||||||
Vector2 origin = drawable.Position;
|
Vector2 origin = drawable.Position;
|
||||||
|
|
||||||
// Wiggle the repeat points with the slider instead of independently.
|
// Wiggle the repeat points and the tail with the slider instead of independently.
|
||||||
// Also fixes an issue with repeat points being positioned incorrectly.
|
// Also fixes an issue with repeat points being positioned incorrectly.
|
||||||
if (osuObject is SliderRepeat)
|
if (osuObject is SliderRepeat || osuObject is SliderTailCircle)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
Random objRand = new Random((int)osuObject.StartTime);
|
Random objRand = new Random((int)osuObject.StartTime);
|
||||||
|
@ -42,7 +42,7 @@ namespace osu.Game.Rulesets.Osu.UI
|
|||||||
base.PopIn();
|
base.PopIn();
|
||||||
|
|
||||||
GameplayCursor.ActiveCursor.Hide();
|
GameplayCursor.ActiveCursor.Hide();
|
||||||
cursorScaleContainer.MoveTo(GameplayCursor.ActiveCursor.Position);
|
cursorScaleContainer.Position = ToLocalSpace(GameplayCursor.ActiveCursor.ScreenSpaceDrawQuad.Centre);
|
||||||
clickToResumeCursor.Appear();
|
clickToResumeCursor.Appear();
|
||||||
|
|
||||||
if (localCursorContainer == null)
|
if (localCursorContainer == null)
|
||||||
|
@ -18,7 +18,7 @@ namespace osu.Game.Rulesets.Taiko.Tests
|
|||||||
{
|
{
|
||||||
StartTime = 400,
|
StartTime = 400,
|
||||||
Major = true
|
Major = true
|
||||||
}), null));
|
})));
|
||||||
AddHitObject(barLine);
|
AddHitObject(barLine);
|
||||||
RemoveHitObject(barLine);
|
RemoveHitObject(barLine);
|
||||||
|
|
||||||
@ -26,7 +26,7 @@ namespace osu.Game.Rulesets.Taiko.Tests
|
|||||||
{
|
{
|
||||||
StartTime = 200,
|
StartTime = 200,
|
||||||
Major = false
|
Major = false
|
||||||
}), null));
|
})));
|
||||||
AddHitObject(barLine);
|
AddHitObject(barLine);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -20,7 +20,7 @@ namespace osu.Game.Rulesets.Taiko.Tests
|
|||||||
Duration = 500,
|
Duration = 500,
|
||||||
IsStrong = false,
|
IsStrong = false,
|
||||||
TickRate = 2
|
TickRate = 2
|
||||||
}), null));
|
})));
|
||||||
|
|
||||||
AddHitObject(drumRoll);
|
AddHitObject(drumRoll);
|
||||||
RemoveHitObject(drumRoll);
|
RemoveHitObject(drumRoll);
|
||||||
@ -31,7 +31,7 @@ namespace osu.Game.Rulesets.Taiko.Tests
|
|||||||
Duration = 400,
|
Duration = 400,
|
||||||
IsStrong = true,
|
IsStrong = true,
|
||||||
TickRate = 16
|
TickRate = 16
|
||||||
}), null));
|
})));
|
||||||
|
|
||||||
AddHitObject(drumRoll);
|
AddHitObject(drumRoll);
|
||||||
}
|
}
|
||||||
|
@ -19,7 +19,7 @@ namespace osu.Game.Rulesets.Taiko.Tests
|
|||||||
Type = HitType.Rim,
|
Type = HitType.Rim,
|
||||||
IsStrong = false,
|
IsStrong = false,
|
||||||
StartTime = 300
|
StartTime = 300
|
||||||
}), null));
|
})));
|
||||||
|
|
||||||
AddHitObject(hit);
|
AddHitObject(hit);
|
||||||
RemoveHitObject(hit);
|
RemoveHitObject(hit);
|
||||||
@ -29,7 +29,7 @@ namespace osu.Game.Rulesets.Taiko.Tests
|
|||||||
Type = HitType.Centre,
|
Type = HitType.Centre,
|
||||||
IsStrong = true,
|
IsStrong = true,
|
||||||
StartTime = 500
|
StartTime = 500
|
||||||
}), null));
|
})));
|
||||||
|
|
||||||
AddHitObject(hit);
|
AddHitObject(hit);
|
||||||
}
|
}
|
||||||
|
@ -1,32 +0,0 @@
|
|||||||
// 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 NUnit.Framework;
|
|
||||||
using osu.Framework.Testing;
|
|
||||||
using osu.Game.Rulesets.Osu;
|
|
||||||
using osu.Game.Screens.Play;
|
|
||||||
using osu.Game.Tests.Visual;
|
|
||||||
|
|
||||||
namespace osu.Game.Tests.Gameplay
|
|
||||||
{
|
|
||||||
[HeadlessTest]
|
|
||||||
public class TestSceneGameplayClockContainer : OsuTestScene
|
|
||||||
{
|
|
||||||
[Test]
|
|
||||||
public void TestStartThenElapsedTime()
|
|
||||||
{
|
|
||||||
GameplayClockContainer gcc = null;
|
|
||||||
|
|
||||||
AddStep("create container", () =>
|
|
||||||
{
|
|
||||||
var working = CreateWorkingBeatmap(new OsuRuleset().RulesetInfo);
|
|
||||||
working.LoadTrack();
|
|
||||||
|
|
||||||
Add(gcc = new GameplayClockContainer(working, 0));
|
|
||||||
});
|
|
||||||
|
|
||||||
AddStep("start track", () => gcc.Start());
|
|
||||||
AddUntilStep("elapsed greater than zero", () => gcc.GameplayClock.ElapsedFrameTime > 0);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -0,0 +1,58 @@
|
|||||||
|
// 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 NUnit.Framework;
|
||||||
|
using osu.Framework.Testing;
|
||||||
|
using osu.Game.Rulesets.Osu;
|
||||||
|
using osu.Game.Screens.Play;
|
||||||
|
using osu.Game.Tests.Visual;
|
||||||
|
|
||||||
|
namespace osu.Game.Tests.Gameplay
|
||||||
|
{
|
||||||
|
[HeadlessTest]
|
||||||
|
public class TestSceneMasterGameplayClockContainer : OsuTestScene
|
||||||
|
{
|
||||||
|
[Test]
|
||||||
|
public void TestStartThenElapsedTime()
|
||||||
|
{
|
||||||
|
GameplayClockContainer gcc = null;
|
||||||
|
|
||||||
|
AddStep("create container", () =>
|
||||||
|
{
|
||||||
|
var working = CreateWorkingBeatmap(new OsuRuleset().RulesetInfo);
|
||||||
|
working.LoadTrack();
|
||||||
|
|
||||||
|
Add(gcc = new MasterGameplayClockContainer(working, 0));
|
||||||
|
});
|
||||||
|
|
||||||
|
AddStep("start clock", () => gcc.Start());
|
||||||
|
AddUntilStep("elapsed greater than zero", () => gcc.GameplayClock.ElapsedFrameTime > 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void TestElapseThenReset()
|
||||||
|
{
|
||||||
|
GameplayClockContainer gcc = null;
|
||||||
|
|
||||||
|
AddStep("create container", () =>
|
||||||
|
{
|
||||||
|
var working = CreateWorkingBeatmap(new OsuRuleset().RulesetInfo);
|
||||||
|
working.LoadTrack();
|
||||||
|
|
||||||
|
Add(gcc = new MasterGameplayClockContainer(working, 0));
|
||||||
|
});
|
||||||
|
|
||||||
|
AddStep("start clock", () => gcc.Start());
|
||||||
|
AddUntilStep("current time greater 2000", () => gcc.GameplayClock.CurrentTime > 2000);
|
||||||
|
|
||||||
|
double timeAtReset = 0;
|
||||||
|
AddStep("reset clock", () =>
|
||||||
|
{
|
||||||
|
timeAtReset = gcc.GameplayClock.CurrentTime;
|
||||||
|
gcc.Reset();
|
||||||
|
});
|
||||||
|
|
||||||
|
AddAssert("current time < time at reset", () => gcc.GameplayClock.CurrentTime < timeAtReset);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -20,6 +20,7 @@ using osu.Game.Rulesets;
|
|||||||
using osu.Game.Rulesets.Mods;
|
using osu.Game.Rulesets.Mods;
|
||||||
using osu.Game.Rulesets.Osu;
|
using osu.Game.Rulesets.Osu;
|
||||||
using osu.Game.Rulesets.Osu.Mods;
|
using osu.Game.Rulesets.Osu.Mods;
|
||||||
|
using osu.Game.Rulesets.UI;
|
||||||
using osu.Game.Screens.Play;
|
using osu.Game.Screens.Play;
|
||||||
using osu.Game.Skinning;
|
using osu.Game.Skinning;
|
||||||
using osu.Game.Storyboards;
|
using osu.Game.Storyboards;
|
||||||
@ -67,15 +68,17 @@ namespace osu.Game.Tests.Gameplay
|
|||||||
var working = CreateWorkingBeatmap(new OsuRuleset().RulesetInfo);
|
var working = CreateWorkingBeatmap(new OsuRuleset().RulesetInfo);
|
||||||
working.LoadTrack();
|
working.LoadTrack();
|
||||||
|
|
||||||
Add(gameplayContainer = new GameplayClockContainer(working, 0));
|
Add(gameplayContainer = new MasterGameplayClockContainer(working, 0)
|
||||||
|
|
||||||
gameplayContainer.Add(sample = new DrawableStoryboardSample(new StoryboardSampleInfo(string.Empty, 0, 1))
|
|
||||||
{
|
{
|
||||||
Clock = gameplayContainer.GameplayClock
|
IsPaused = { Value = true },
|
||||||
|
Child = new FrameStabilityContainer
|
||||||
|
{
|
||||||
|
Child = sample = new DrawableStoryboardSample(new StoryboardSampleInfo(string.Empty, 0, 1))
|
||||||
|
}
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
AddStep("start time", () => gameplayContainer.Start());
|
AddStep("reset clock", () => gameplayContainer.Start());
|
||||||
|
|
||||||
AddUntilStep("sample played", () => sample.RequestedPlaying);
|
AddUntilStep("sample played", () => sample.RequestedPlaying);
|
||||||
AddUntilStep("sample has lifetime end", () => sample.LifetimeEnd < double.MaxValue);
|
AddUntilStep("sample has lifetime end", () => sample.LifetimeEnd < double.MaxValue);
|
||||||
@ -92,11 +95,13 @@ namespace osu.Game.Tests.Gameplay
|
|||||||
var working = CreateWorkingBeatmap(new OsuRuleset().RulesetInfo);
|
var working = CreateWorkingBeatmap(new OsuRuleset().RulesetInfo);
|
||||||
working.LoadTrack();
|
working.LoadTrack();
|
||||||
|
|
||||||
Add(gameplayContainer = new GameplayClockContainer(working, 1000, true));
|
Add(gameplayContainer = new MasterGameplayClockContainer(working, 1000, true)
|
||||||
|
|
||||||
gameplayContainer.Add(sample = new DrawableStoryboardSample(new StoryboardSampleInfo(string.Empty, 0, 1))
|
|
||||||
{
|
{
|
||||||
Clock = gameplayContainer.GameplayClock
|
IsPaused = { Value = true },
|
||||||
|
Child = new FrameStabilityContainer
|
||||||
|
{
|
||||||
|
Child = sample = new DrawableStoryboardSample(new StoryboardSampleInfo(string.Empty, 0, 1))
|
||||||
|
}
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -140,7 +145,7 @@ namespace osu.Game.Tests.Gameplay
|
|||||||
|
|
||||||
var beatmapSkinSourceContainer = new BeatmapSkinProvidingContainer(Beatmap.Value.Skin);
|
var beatmapSkinSourceContainer = new BeatmapSkinProvidingContainer(Beatmap.Value.Skin);
|
||||||
|
|
||||||
Add(gameplayContainer = new GameplayClockContainer(Beatmap.Value, 0)
|
Add(gameplayContainer = new MasterGameplayClockContainer(Beatmap.Value, 0)
|
||||||
{
|
{
|
||||||
Child = beatmapSkinSourceContainer
|
Child = beatmapSkinSourceContainer
|
||||||
});
|
});
|
||||||
|
@ -130,9 +130,9 @@ namespace osu.Game.Tests.Visual.Gameplay
|
|||||||
|
|
||||||
public double GameplayClockTime => GameplayClockContainer.GameplayClock.CurrentTime;
|
public double GameplayClockTime => GameplayClockContainer.GameplayClock.CurrentTime;
|
||||||
|
|
||||||
protected override void UpdateAfterChildren()
|
protected override void Update()
|
||||||
{
|
{
|
||||||
base.UpdateAfterChildren();
|
base.Update();
|
||||||
|
|
||||||
if (!FirstFrameClockTime.HasValue)
|
if (!FirstFrameClockTime.HasValue)
|
||||||
{
|
{
|
||||||
|
@ -33,7 +33,7 @@ namespace osu.Game.Tests.Visual.Gameplay
|
|||||||
var working = CreateWorkingBeatmap(CreateBeatmap(new OsuRuleset().RulesetInfo));
|
var working = CreateWorkingBeatmap(CreateBeatmap(new OsuRuleset().RulesetInfo));
|
||||||
working.LoadTrack();
|
working.LoadTrack();
|
||||||
|
|
||||||
Child = gameplayClockContainer = new GameplayClockContainer(working, 0)
|
Child = gameplayClockContainer = new MasterGameplayClockContainer(working, 0)
|
||||||
{
|
{
|
||||||
RelativeSizeAxes = Axes.Both,
|
RelativeSizeAxes = Axes.Both,
|
||||||
Children = new Drawable[]
|
Children = new Drawable[]
|
||||||
@ -80,7 +80,7 @@ namespace osu.Game.Tests.Visual.Gameplay
|
|||||||
AddStep("move mouse", () => InputManager.MoveMouseTo(skip.ScreenSpaceDrawQuad.Centre));
|
AddStep("move mouse", () => InputManager.MoveMouseTo(skip.ScreenSpaceDrawQuad.Centre));
|
||||||
AddStep("click", () =>
|
AddStep("click", () =>
|
||||||
{
|
{
|
||||||
increment = skip_time - gameplayClock.CurrentTime - GameplayClockContainer.MINIMUM_SKIP_TIME / 2;
|
increment = skip_time - gameplayClock.CurrentTime - MasterGameplayClockContainer.MINIMUM_SKIP_TIME / 2;
|
||||||
InputManager.Click(MouseButton.Left);
|
InputManager.Click(MouseButton.Left);
|
||||||
});
|
});
|
||||||
AddStep("click", () => InputManager.Click(MouseButton.Left));
|
AddStep("click", () => InputManager.Click(MouseButton.Left));
|
||||||
|
@ -288,7 +288,7 @@ namespace osu.Game.Tests.Visual.Gameplay
|
|||||||
|
|
||||||
public override void WatchUser(int userId)
|
public override void WatchUser(int userId)
|
||||||
{
|
{
|
||||||
if (sentState)
|
if (!PlayingUsers.Contains(userId) && sentState)
|
||||||
{
|
{
|
||||||
// usually the server would do this.
|
// usually the server would do this.
|
||||||
sendState(beatmapId);
|
sendState(beatmapId);
|
||||||
|
@ -167,7 +167,7 @@ namespace osu.Game.Tests.Visual.UserInterface
|
|||||||
GetModButton(mod).SelectNext(1);
|
GetModButton(mod).SelectNext(1);
|
||||||
|
|
||||||
public void SetModSettingsWidth(float newWidth) =>
|
public void SetModSettingsWidth(float newWidth) =>
|
||||||
ModSettingsContainer.Width = newWidth;
|
ModSettingsContainer.Parent.Width = newWidth;
|
||||||
}
|
}
|
||||||
|
|
||||||
public class TestRulesetInfo : RulesetInfo
|
public class TestRulesetInfo : RulesetInfo
|
||||||
|
@ -47,6 +47,8 @@ namespace osu.Game.Online.Spectator
|
|||||||
|
|
||||||
private readonly BindableList<int> playingUsers = new BindableList<int>();
|
private readonly BindableList<int> playingUsers = new BindableList<int>();
|
||||||
|
|
||||||
|
private readonly Dictionary<int, SpectatorState> playingUserStates = new Dictionary<int, SpectatorState>();
|
||||||
|
|
||||||
[CanBeNull]
|
[CanBeNull]
|
||||||
private IBeatmap currentBeatmap;
|
private IBeatmap currentBeatmap;
|
||||||
|
|
||||||
@ -69,7 +71,7 @@ namespace osu.Game.Online.Spectator
|
|||||||
public event Action<int, FrameDataBundle> OnNewFrames;
|
public event Action<int, FrameDataBundle> OnNewFrames;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Called whenever a user starts a play session.
|
/// Called whenever a user starts a play session, or immediately if the user is being watched and currently in a play session.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public event Action<int, SpectatorState> OnUserBeganPlaying;
|
public event Action<int, SpectatorState> OnUserBeganPlaying;
|
||||||
|
|
||||||
@ -122,26 +124,39 @@ namespace osu.Game.Online.Spectator
|
|||||||
beginPlaying();
|
beginPlaying();
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
{
|
||||||
|
lock (userLock)
|
||||||
{
|
{
|
||||||
playingUsers.Clear();
|
playingUsers.Clear();
|
||||||
|
playingUserStates.Clear();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}, true);
|
}, true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Task ISpectatorClient.UserBeganPlaying(int userId, SpectatorState state)
|
Task ISpectatorClient.UserBeganPlaying(int userId, SpectatorState state)
|
||||||
|
{
|
||||||
|
lock (userLock)
|
||||||
{
|
{
|
||||||
if (!playingUsers.Contains(userId))
|
if (!playingUsers.Contains(userId))
|
||||||
playingUsers.Add(userId);
|
playingUsers.Add(userId);
|
||||||
|
|
||||||
|
playingUserStates[userId] = state;
|
||||||
|
}
|
||||||
|
|
||||||
OnUserBeganPlaying?.Invoke(userId, state);
|
OnUserBeganPlaying?.Invoke(userId, state);
|
||||||
|
|
||||||
return Task.CompletedTask;
|
return Task.CompletedTask;
|
||||||
}
|
}
|
||||||
|
|
||||||
Task ISpectatorClient.UserFinishedPlaying(int userId, SpectatorState state)
|
Task ISpectatorClient.UserFinishedPlaying(int userId, SpectatorState state)
|
||||||
|
{
|
||||||
|
lock (userLock)
|
||||||
{
|
{
|
||||||
playingUsers.Remove(userId);
|
playingUsers.Remove(userId);
|
||||||
|
playingUserStates.Remove(userId);
|
||||||
|
}
|
||||||
|
|
||||||
OnUserFinishedPlaying?.Invoke(userId, state);
|
OnUserFinishedPlaying?.Invoke(userId, state);
|
||||||
|
|
||||||
@ -268,5 +283,37 @@ namespace osu.Game.Online.Spectator
|
|||||||
|
|
||||||
lastSendTime = Time.Current;
|
lastSendTime = Time.Current;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Attempts to retrieve the <see cref="SpectatorState"/> for a currently-playing user.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="userId">The user.</param>
|
||||||
|
/// <param name="state">The current <see cref="SpectatorState"/> for the user, if they're playing. <c>null</c> if the user is not playing.</param>
|
||||||
|
/// <returns><c>true</c> if successful (the user is playing), <c>false</c> otherwise.</returns>
|
||||||
|
public bool TryGetPlayingUserState(int userId, out SpectatorState state)
|
||||||
|
{
|
||||||
|
lock (userLock)
|
||||||
|
return playingUserStates.TryGetValue(userId, out state);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Bind an action to <see cref="OnUserBeganPlaying"/> with the option of running the bound action once immediately.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="callback">The action to perform when a user begins playing.</param>
|
||||||
|
/// <param name="runOnceImmediately">Whether the action provided in <paramref name="callback"/> should be run once immediately for all users currently playing.</param>
|
||||||
|
public void BindUserBeganPlaying(Action<int, SpectatorState> callback, bool runOnceImmediately = false)
|
||||||
|
{
|
||||||
|
// The lock is taken before the event is subscribed to to prevent doubling of events.
|
||||||
|
lock (userLock)
|
||||||
|
{
|
||||||
|
OnUserBeganPlaying += callback;
|
||||||
|
|
||||||
|
if (!runOnceImmediately)
|
||||||
|
return;
|
||||||
|
|
||||||
|
foreach (var (userId, state) in playingUserStates)
|
||||||
|
callback(userId, state);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -245,18 +245,24 @@ namespace osu.Game.Overlays.Mods
|
|||||||
},
|
},
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
ModSettingsContainer = new ModSettingsContainer
|
new Container
|
||||||
{
|
{
|
||||||
RelativeSizeAxes = Axes.Both,
|
RelativeSizeAxes = Axes.Both,
|
||||||
Anchor = Anchor.BottomRight,
|
Anchor = Anchor.BottomRight,
|
||||||
Origin = Anchor.BottomRight,
|
Origin = Anchor.BottomRight,
|
||||||
Width = 0.3f,
|
|
||||||
Alpha = 0,
|
|
||||||
Padding = new MarginPadding(30),
|
Padding = new MarginPadding(30),
|
||||||
|
Width = 0.3f,
|
||||||
|
Children = new Drawable[]
|
||||||
|
{
|
||||||
|
ModSettingsContainer = new ModSettingsContainer
|
||||||
|
{
|
||||||
|
Alpha = 0,
|
||||||
SelectedMods = { BindTarget = SelectedMods },
|
SelectedMods = { BindTarget = SelectedMods },
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
}
|
||||||
|
},
|
||||||
},
|
},
|
||||||
new Drawable[]
|
new Drawable[]
|
||||||
{
|
{
|
||||||
|
@ -129,9 +129,10 @@ namespace osu.Game.Overlays.Settings.Sections.Input
|
|||||||
rotation.BindTo(handler.Rotation);
|
rotation.BindTo(handler.Rotation);
|
||||||
rotation.BindValueChanged(val =>
|
rotation.BindValueChanged(val =>
|
||||||
{
|
{
|
||||||
|
tabletContainer.RotateTo(-val.NewValue, 800, Easing.OutQuint);
|
||||||
usableAreaContainer.RotateTo(val.NewValue, 100, Easing.OutQuint)
|
usableAreaContainer.RotateTo(val.NewValue, 100, Easing.OutQuint)
|
||||||
.OnComplete(_ => checkBounds()); // required as we are using SSDQ.
|
.OnComplete(_ => checkBounds()); // required as we are using SSDQ.
|
||||||
});
|
}, true);
|
||||||
|
|
||||||
tablet.BindTo(handler.Tablet);
|
tablet.BindTo(handler.Tablet);
|
||||||
tablet.BindValueChanged(_ => Scheduler.AddOnce(updateTabletDetails));
|
tablet.BindValueChanged(_ => Scheduler.AddOnce(updateTabletDetails));
|
||||||
@ -183,8 +184,10 @@ namespace osu.Game.Overlays.Settings.Sections.Input
|
|||||||
if (!(tablet.Value?.Size is Vector2 size))
|
if (!(tablet.Value?.Size is Vector2 size))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
float fitX = size.X / (DrawWidth - Padding.Left - Padding.Right);
|
float maxDimension = size.LengthFast;
|
||||||
float fitY = size.Y / DrawHeight;
|
|
||||||
|
float fitX = maxDimension / (DrawWidth - Padding.Left - Padding.Right);
|
||||||
|
float fitY = maxDimension / DrawHeight;
|
||||||
|
|
||||||
float adjust = MathF.Max(fitX, fitY);
|
float adjust = MathF.Max(fitX, fitY);
|
||||||
|
|
||||||
|
@ -4,6 +4,7 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Collections.Specialized;
|
using System.Collections.Specialized;
|
||||||
|
using System.Diagnostics;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using JetBrains.Annotations;
|
using JetBrains.Annotations;
|
||||||
using osu.Framework.Allocation;
|
using osu.Framework.Allocation;
|
||||||
@ -39,7 +40,7 @@ namespace osu.Game.Rulesets.Objects.Drawables
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// The <see cref="HitObject"/> currently represented by this <see cref="DrawableHitObject"/>.
|
/// The <see cref="HitObject"/> currently represented by this <see cref="DrawableHitObject"/>.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public HitObject HitObject { get; private set; }
|
public HitObject HitObject => lifetimeEntry?.HitObject;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// The parenting <see cref="DrawableHitObject"/>, if any.
|
/// The parenting <see cref="DrawableHitObject"/>, if any.
|
||||||
@ -108,7 +109,7 @@ namespace osu.Game.Rulesets.Objects.Drawables
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// The scoring result of this <see cref="DrawableHitObject"/>.
|
/// The scoring result of this <see cref="DrawableHitObject"/>.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public JudgementResult Result { get; private set; }
|
public JudgementResult Result => lifetimeEntry?.Result;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// The relative X position of this hit object for sample playback balance adjustment.
|
/// The relative X position of this hit object for sample playback balance adjustment.
|
||||||
@ -141,13 +142,14 @@ namespace osu.Game.Rulesets.Objects.Drawables
|
|||||||
public IBindable<ArmedState> State => state;
|
public IBindable<ArmedState> State => state;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Whether <see cref="HitObject"/> is currently applied.
|
/// Whether a <see cref="HitObjectLifetimeEntry"/> is currently applied.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
private bool hasHitObjectApplied;
|
private bool hasEntryApplied;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// The <see cref="HitObjectLifetimeEntry"/> controlling the lifetime of the currently-attached <see cref="HitObject"/>.
|
/// The <see cref="HitObjectLifetimeEntry"/> controlling the lifetime of the currently-attached <see cref="HitObject"/>.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
/// <remarks>Even if it is not null, it may not be fully applied until loaded (<see cref="hasEntryApplied"/> is false).</remarks>
|
||||||
[CanBeNull]
|
[CanBeNull]
|
||||||
private HitObjectLifetimeEntry lifetimeEntry;
|
private HitObjectLifetimeEntry lifetimeEntry;
|
||||||
|
|
||||||
@ -164,11 +166,15 @@ namespace osu.Game.Rulesets.Objects.Drawables
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="initialHitObject">
|
/// <param name="initialHitObject">
|
||||||
/// The <see cref="HitObject"/> to be initially applied to this <see cref="DrawableHitObject"/>.
|
/// The <see cref="HitObject"/> to be initially applied to this <see cref="DrawableHitObject"/>.
|
||||||
/// If <c>null</c>, a hitobject is expected to be later applied via <see cref="Apply"/> (or automatically via pooling).
|
/// If <c>null</c>, a hitobject is expected to be later applied via <see cref="Apply(osu.Game.Rulesets.Objects.HitObjectLifetimeEntry)"/> (or automatically via pooling).
|
||||||
/// </param>
|
/// </param>
|
||||||
protected DrawableHitObject([CanBeNull] HitObject initialHitObject = null)
|
protected DrawableHitObject([CanBeNull] HitObject initialHitObject = null)
|
||||||
{
|
{
|
||||||
HitObject = initialHitObject;
|
if (initialHitObject != null)
|
||||||
|
{
|
||||||
|
lifetimeEntry = new SyntheticHitObjectEntry(initialHitObject);
|
||||||
|
ensureEntryHasResult();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
[BackgroundDependencyLoader]
|
[BackgroundDependencyLoader]
|
||||||
@ -184,8 +190,8 @@ namespace osu.Game.Rulesets.Objects.Drawables
|
|||||||
{
|
{
|
||||||
base.LoadAsyncComplete();
|
base.LoadAsyncComplete();
|
||||||
|
|
||||||
if (HitObject != null)
|
if (lifetimeEntry != null && !hasEntryApplied)
|
||||||
Apply(HitObject, lifetimeEntry);
|
Apply(lifetimeEntry);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override void LoadComplete()
|
protected override void LoadComplete()
|
||||||
@ -198,37 +204,47 @@ namespace osu.Game.Rulesets.Objects.Drawables
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Applies a new <see cref="HitObject"/> to be represented by this <see cref="DrawableHitObject"/>.
|
/// Applies a hit object to be represented by this <see cref="DrawableHitObject"/>.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="hitObject">The <see cref="HitObject"/> to apply.</param>
|
[Obsolete("Use either overload of Apply that takes a single argument of type HitObject or HitObjectLifetimeEntry")]
|
||||||
/// <param name="lifetimeEntry">The <see cref="HitObjectLifetimeEntry"/> controlling the lifetime of <paramref name="hitObject"/>.</param>
|
|
||||||
public void Apply([NotNull] HitObject hitObject, [CanBeNull] HitObjectLifetimeEntry lifetimeEntry)
|
public void Apply([NotNull] HitObject hitObject, [CanBeNull] HitObjectLifetimeEntry lifetimeEntry)
|
||||||
|
{
|
||||||
|
if (lifetimeEntry != null)
|
||||||
|
Apply(lifetimeEntry);
|
||||||
|
else
|
||||||
|
Apply(hitObject);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Applies a new <see cref="HitObject"/> to be represented by this <see cref="DrawableHitObject"/>.
|
||||||
|
/// A new <see cref="HitObjectLifetimeEntry"/> is automatically created and applied to this <see cref="DrawableHitObject"/>.
|
||||||
|
/// </summary>
|
||||||
|
public void Apply([NotNull] HitObject hitObject)
|
||||||
|
{
|
||||||
|
if (hitObject == null)
|
||||||
|
throw new ArgumentNullException($"Cannot apply a null {nameof(HitObject)}.");
|
||||||
|
|
||||||
|
Apply(new SyntheticHitObjectEntry(hitObject));
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Applies a new <see cref="HitObjectLifetimeEntry"/> to be represented by this <see cref="DrawableHitObject"/>.
|
||||||
|
/// </summary>
|
||||||
|
public void Apply([NotNull] HitObjectLifetimeEntry newEntry)
|
||||||
{
|
{
|
||||||
free();
|
free();
|
||||||
|
|
||||||
HitObject = hitObject ?? throw new InvalidOperationException($"Cannot apply a null {nameof(HitObject)}.");
|
lifetimeEntry = newEntry;
|
||||||
|
|
||||||
this.lifetimeEntry = lifetimeEntry;
|
// LifetimeStart is already computed using HitObjectLifetimeEntry's InitialLifetimeOffset.
|
||||||
|
// We override this with DHO's InitialLifetimeOffset for a non-pooled DHO.
|
||||||
|
if (newEntry is SyntheticHitObjectEntry)
|
||||||
|
lifetimeEntry.LifetimeStart = HitObject.StartTime - InitialLifetimeOffset;
|
||||||
|
|
||||||
if (lifetimeEntry != null)
|
|
||||||
{
|
|
||||||
// Transfer lifetime from the entry.
|
|
||||||
LifetimeStart = lifetimeEntry.LifetimeStart;
|
LifetimeStart = lifetimeEntry.LifetimeStart;
|
||||||
LifetimeEnd = lifetimeEntry.LifetimeEnd;
|
LifetimeEnd = lifetimeEntry.LifetimeEnd;
|
||||||
|
|
||||||
// Copy any existing result from the entry (required for rewind / judgement revert).
|
ensureEntryHasResult();
|
||||||
Result = lifetimeEntry.Result;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
LifetimeStart = HitObject.StartTime - InitialLifetimeOffset;
|
|
||||||
|
|
||||||
// Ensure this DHO has a result.
|
|
||||||
Result ??= CreateResult(HitObject.CreateJudgement())
|
|
||||||
?? throw new InvalidOperationException($"{GetType().ReadableName()} must provide a {nameof(JudgementResult)} through {nameof(CreateResult)}.");
|
|
||||||
|
|
||||||
// Copy back the result to the entry for potential future retrieval.
|
|
||||||
if (lifetimeEntry != null)
|
|
||||||
lifetimeEntry.Result = Result;
|
|
||||||
|
|
||||||
foreach (var h in HitObject.NestedHitObjects)
|
foreach (var h in HitObject.NestedHitObjects)
|
||||||
{
|
{
|
||||||
@ -278,16 +294,15 @@ namespace osu.Game.Rulesets.Objects.Drawables
|
|||||||
updateState(ArmedState.Idle, true);
|
updateState(ArmedState.Idle, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
hasHitObjectApplied = true;
|
hasEntryApplied = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Removes the currently applied <see cref="HitObject"/>
|
/// Removes the currently applied <see cref="lifetimeEntry"/>
|
||||||
/// </summary>
|
/// </summary>
|
||||||
private void free()
|
private void free()
|
||||||
{
|
{
|
||||||
if (!hasHitObjectApplied)
|
if (!hasEntryApplied) return;
|
||||||
return;
|
|
||||||
|
|
||||||
StartTimeBindable.UnbindFrom(HitObject.StartTimeBindable);
|
StartTimeBindable.UnbindFrom(HitObject.StartTimeBindable);
|
||||||
if (HitObject is IHasComboInformation combo)
|
if (HitObject is IHasComboInformation combo)
|
||||||
@ -319,14 +334,12 @@ namespace osu.Game.Rulesets.Objects.Drawables
|
|||||||
|
|
||||||
OnFree();
|
OnFree();
|
||||||
|
|
||||||
HitObject = null;
|
|
||||||
ParentHitObject = null;
|
ParentHitObject = null;
|
||||||
Result = null;
|
|
||||||
lifetimeEntry = null;
|
lifetimeEntry = null;
|
||||||
|
|
||||||
clearExistingStateTransforms();
|
clearExistingStateTransforms();
|
||||||
|
|
||||||
hasHitObjectApplied = false;
|
hasEntryApplied = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected sealed override void FreeAfterUse()
|
protected sealed override void FreeAfterUse()
|
||||||
@ -385,7 +398,9 @@ namespace osu.Game.Rulesets.Objects.Drawables
|
|||||||
|
|
||||||
private void onDefaultsApplied(HitObject hitObject)
|
private void onDefaultsApplied(HitObject hitObject)
|
||||||
{
|
{
|
||||||
Apply(hitObject, lifetimeEntry);
|
Debug.Assert(lifetimeEntry != null);
|
||||||
|
Apply(lifetimeEntry);
|
||||||
|
|
||||||
DefaultsApplied?.Invoke(this);
|
DefaultsApplied?.Invoke(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -783,6 +798,13 @@ namespace osu.Game.Rulesets.Objects.Drawables
|
|||||||
/// <param name="judgement">The <see cref="Judgement"/> that provides the scoring information.</param>
|
/// <param name="judgement">The <see cref="Judgement"/> that provides the scoring information.</param>
|
||||||
protected virtual JudgementResult CreateResult(Judgement judgement) => new JudgementResult(HitObject, judgement);
|
protected virtual JudgementResult CreateResult(Judgement judgement) => new JudgementResult(HitObject, judgement);
|
||||||
|
|
||||||
|
private void ensureEntryHasResult()
|
||||||
|
{
|
||||||
|
Debug.Assert(lifetimeEntry != null);
|
||||||
|
lifetimeEntry.Result ??= CreateResult(HitObject.CreateJudgement())
|
||||||
|
?? throw new InvalidOperationException($"{GetType().ReadableName()} must provide a {nameof(JudgementResult)} through {nameof(CreateResult)}.");
|
||||||
|
}
|
||||||
|
|
||||||
protected override void Dispose(bool isDisposing)
|
protected override void Dispose(bool isDisposing)
|
||||||
{
|
{
|
||||||
base.Dispose(isDisposing);
|
base.Dispose(isDisposing);
|
||||||
|
19
osu.Game/Rulesets/Objects/SyntheticHitObjectEntry.cs
Normal file
19
osu.Game/Rulesets/Objects/SyntheticHitObjectEntry.cs
Normal file
@ -0,0 +1,19 @@
|
|||||||
|
// 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 osu.Game.Rulesets.Objects.Drawables;
|
||||||
|
|
||||||
|
namespace osu.Game.Rulesets.Objects
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Created for a <see cref="DrawableHitObject"/> when only <see cref="HitObject"/> is given
|
||||||
|
/// to make sure a <see cref="DrawableHitObject"/> is always associated with a <see cref="HitObjectLifetimeEntry"/>.
|
||||||
|
/// </summary>
|
||||||
|
internal class SyntheticHitObjectEntry : HitObjectLifetimeEntry
|
||||||
|
{
|
||||||
|
public SyntheticHitObjectEntry(HitObject hitObject)
|
||||||
|
: base(hitObject)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -362,7 +362,7 @@ namespace osu.Game.Rulesets.UI
|
|||||||
lifetimeEntryMap[hitObject] = entry = CreateLifetimeEntry(hitObject);
|
lifetimeEntryMap[hitObject] = entry = CreateLifetimeEntry(hitObject);
|
||||||
|
|
||||||
dho.ParentHitObject = parent;
|
dho.ParentHitObject = parent;
|
||||||
dho.Apply(hitObject, entry);
|
dho.Apply(entry);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -19,7 +19,7 @@ namespace osu.Game.Screens.Play
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public class GameplayClock : IFrameBasedClock
|
public class GameplayClock : IFrameBasedClock
|
||||||
{
|
{
|
||||||
private readonly IFrameBasedClock underlyingClock;
|
internal readonly IFrameBasedClock UnderlyingClock;
|
||||||
|
|
||||||
public readonly BindableBool IsPaused = new BindableBool();
|
public readonly BindableBool IsPaused = new BindableBool();
|
||||||
|
|
||||||
@ -30,12 +30,12 @@ namespace osu.Game.Screens.Play
|
|||||||
|
|
||||||
public GameplayClock(IFrameBasedClock underlyingClock)
|
public GameplayClock(IFrameBasedClock underlyingClock)
|
||||||
{
|
{
|
||||||
this.underlyingClock = underlyingClock;
|
UnderlyingClock = underlyingClock;
|
||||||
}
|
}
|
||||||
|
|
||||||
public double CurrentTime => underlyingClock.CurrentTime;
|
public double CurrentTime => UnderlyingClock.CurrentTime;
|
||||||
|
|
||||||
public double Rate => underlyingClock.Rate;
|
public double Rate => UnderlyingClock.Rate;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// The rate of gameplay when playback is at 100%.
|
/// The rate of gameplay when playback is at 100%.
|
||||||
@ -59,19 +59,19 @@ namespace osu.Game.Screens.Play
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public bool IsRunning => underlyingClock.IsRunning;
|
public bool IsRunning => UnderlyingClock.IsRunning;
|
||||||
|
|
||||||
public void ProcessFrame()
|
public void ProcessFrame()
|
||||||
{
|
{
|
||||||
// intentionally not updating the underlying clock (handled externally).
|
// intentionally not updating the underlying clock (handled externally).
|
||||||
}
|
}
|
||||||
|
|
||||||
public double ElapsedFrameTime => underlyingClock.ElapsedFrameTime;
|
public double ElapsedFrameTime => UnderlyingClock.ElapsedFrameTime;
|
||||||
|
|
||||||
public double FramesPerSecond => underlyingClock.FramesPerSecond;
|
public double FramesPerSecond => UnderlyingClock.FramesPerSecond;
|
||||||
|
|
||||||
public FrameTimeInfo TimeInfo => underlyingClock.TimeInfo;
|
public FrameTimeInfo TimeInfo => UnderlyingClock.TimeInfo;
|
||||||
|
|
||||||
public IClock Source => underlyingClock;
|
public IClock Source => UnderlyingClock;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,300 +1,148 @@
|
|||||||
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
|
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
|
||||||
// See the LICENCE file in the repository root for full licence text.
|
// See the LICENCE file in the repository root for full licence text.
|
||||||
|
|
||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Diagnostics.CodeAnalysis;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
using osu.Framework;
|
|
||||||
using osu.Framework.Allocation;
|
using osu.Framework.Allocation;
|
||||||
using osu.Framework.Audio;
|
|
||||||
using osu.Framework.Audio.Track;
|
|
||||||
using osu.Framework.Bindables;
|
using osu.Framework.Bindables;
|
||||||
using osu.Framework.Graphics;
|
using osu.Framework.Graphics;
|
||||||
using osu.Framework.Graphics.Containers;
|
using osu.Framework.Graphics.Containers;
|
||||||
using osu.Framework.Timing;
|
using osu.Framework.Timing;
|
||||||
using osu.Game.Beatmaps;
|
|
||||||
using osu.Game.Configuration;
|
|
||||||
|
|
||||||
namespace osu.Game.Screens.Play
|
namespace osu.Game.Screens.Play
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Encapsulates gameplay timing logic and provides a <see cref="Play.GameplayClock"/> for children.
|
/// Encapsulates gameplay timing logic and provides a <see cref="GameplayClock"/> via DI for gameplay components to use.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public class GameplayClockContainer : Container
|
public abstract class GameplayClockContainer : Container
|
||||||
{
|
{
|
||||||
private readonly WorkingBeatmap beatmap;
|
/// <summary>
|
||||||
|
/// The final clock which is exposed to gameplay components.
|
||||||
[NotNull]
|
/// </summary>
|
||||||
private ITrack track;
|
public GameplayClock GameplayClock { get; private set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Whether gameplay is paused.
|
||||||
|
/// </summary>
|
||||||
public readonly BindableBool IsPaused = new BindableBool();
|
public readonly BindableBool IsPaused = new BindableBool();
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// The decoupled clock used for gameplay. Should be used for seeks and clock control.
|
/// The adjustable source clock used for gameplay. Should be used for seeks and clock control.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
private readonly DecoupleableInterpolatingFramedClock adjustableClock;
|
protected readonly DecoupleableInterpolatingFramedClock AdjustableSource;
|
||||||
|
|
||||||
private readonly double gameplayStartTime;
|
|
||||||
private readonly bool startAtGameplayStart;
|
|
||||||
|
|
||||||
private readonly double firstHitObjectTime;
|
|
||||||
|
|
||||||
public readonly BindableNumber<double> UserPlaybackRate = new BindableDouble(1)
|
|
||||||
{
|
|
||||||
Default = 1,
|
|
||||||
MinValue = 0.5,
|
|
||||||
MaxValue = 2,
|
|
||||||
Precision = 0.1,
|
|
||||||
};
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// The final clock which is exposed to underlying components.
|
/// The source clock.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public GameplayClock GameplayClock => localGameplayClock;
|
protected IClock SourceClock { get; private set; }
|
||||||
|
|
||||||
[Cached(typeof(GameplayClock))]
|
|
||||||
private readonly LocalGameplayClock localGameplayClock;
|
|
||||||
|
|
||||||
private Bindable<double> userAudioOffset;
|
|
||||||
|
|
||||||
private readonly FramedOffsetClock userOffsetClock;
|
|
||||||
|
|
||||||
private readonly FramedOffsetClock platformOffsetClock;
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Creates a new <see cref="GameplayClockContainer"/>.
|
/// Creates a new <see cref="GameplayClockContainer"/>.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="beatmap">The beatmap being played.</param>
|
/// <param name="sourceClock">The source <see cref="IClock"/> used for timing.</param>
|
||||||
/// <param name="gameplayStartTime">The suggested time to start gameplay at.</param>
|
protected GameplayClockContainer(IClock sourceClock)
|
||||||
/// <param name="startAtGameplayStart">
|
|
||||||
/// Whether <paramref name="gameplayStartTime"/> should be used regardless of when storyboard events and hitobjects are supposed to start.
|
|
||||||
/// </param>
|
|
||||||
public GameplayClockContainer(WorkingBeatmap beatmap, double gameplayStartTime, bool startAtGameplayStart = false)
|
|
||||||
{
|
{
|
||||||
this.beatmap = beatmap;
|
SourceClock = sourceClock;
|
||||||
this.gameplayStartTime = gameplayStartTime;
|
|
||||||
this.startAtGameplayStart = startAtGameplayStart;
|
|
||||||
track = beatmap.Track;
|
|
||||||
|
|
||||||
firstHitObjectTime = beatmap.Beatmap.HitObjects.First().StartTime;
|
|
||||||
|
|
||||||
RelativeSizeAxes = Axes.Both;
|
RelativeSizeAxes = Axes.Both;
|
||||||
|
|
||||||
adjustableClock = new DecoupleableInterpolatingFramedClock { IsCoupled = false };
|
AdjustableSource = new DecoupleableInterpolatingFramedClock { IsCoupled = false };
|
||||||
|
IsPaused.BindValueChanged(OnIsPausedChanged);
|
||||||
|
}
|
||||||
|
|
||||||
// Lazer's audio timings in general doesn't match stable. This is the result of user testing, albeit limited.
|
protected override IReadOnlyDependencyContainer CreateChildDependencies(IReadOnlyDependencyContainer parent)
|
||||||
// This only seems to be required on windows. We need to eventually figure out why, with a bit of luck.
|
{
|
||||||
platformOffsetClock = new HardwareCorrectionOffsetClock(adjustableClock) { Offset = RuntimeInfo.OS == RuntimeInfo.Platform.Windows ? 15 : 0 };
|
var dependencies = new DependencyContainer(base.CreateChildDependencies(parent));
|
||||||
|
|
||||||
// the final usable gameplay clock with user-set offsets applied.
|
|
||||||
userOffsetClock = new HardwareCorrectionOffsetClock(platformOffsetClock);
|
|
||||||
|
|
||||||
// the clock to be exposed via DI to children.
|
|
||||||
localGameplayClock = new LocalGameplayClock(userOffsetClock);
|
|
||||||
|
|
||||||
|
dependencies.CacheAs(GameplayClock = CreateGameplayClock(AdjustableSource));
|
||||||
GameplayClock.IsPaused.BindTo(IsPaused);
|
GameplayClock.IsPaused.BindTo(IsPaused);
|
||||||
|
|
||||||
IsPaused.BindValueChanged(onPauseChanged);
|
return dependencies;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void onPauseChanged(ValueChangedEvent<bool> isPaused)
|
|
||||||
{
|
|
||||||
if (isPaused.NewValue)
|
|
||||||
this.TransformBindableTo(pauseFreqAdjust, 0, 200, Easing.Out).OnComplete(_ => adjustableClock.Stop());
|
|
||||||
else
|
|
||||||
this.TransformBindableTo(pauseFreqAdjust, 1, 200, Easing.In);
|
|
||||||
}
|
|
||||||
|
|
||||||
private double totalOffset => userOffsetClock.Offset + platformOffsetClock.Offset;
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Duration before gameplay start time required before skip button displays.
|
/// Starts gameplay.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public const double MINIMUM_SKIP_TIME = 1000;
|
public virtual void Start()
|
||||||
|
|
||||||
private readonly BindableDouble pauseFreqAdjust = new BindableDouble(1);
|
|
||||||
|
|
||||||
[BackgroundDependencyLoader]
|
|
||||||
private void load(OsuConfigManager config)
|
|
||||||
{
|
{
|
||||||
userAudioOffset = config.GetBindable<double>(OsuSetting.AudioOffset);
|
// Ensure that the source clock is set.
|
||||||
userAudioOffset.BindValueChanged(offset => userOffsetClock.Offset = offset.NewValue, true);
|
ChangeSource(SourceClock);
|
||||||
|
|
||||||
// sane default provided by ruleset.
|
if (!AdjustableSource.IsRunning)
|
||||||
double startTime = gameplayStartTime;
|
|
||||||
|
|
||||||
if (!startAtGameplayStart)
|
|
||||||
{
|
|
||||||
startTime = Math.Min(0, startTime);
|
|
||||||
|
|
||||||
// if a storyboard is present, it may dictate the appropriate start time by having events in negative time space.
|
|
||||||
// this is commonly used to display an intro before the audio track start.
|
|
||||||
double? firstStoryboardEvent = beatmap.Storyboard.EarliestEventTime;
|
|
||||||
if (firstStoryboardEvent != null)
|
|
||||||
startTime = Math.Min(startTime, firstStoryboardEvent.Value);
|
|
||||||
|
|
||||||
// some beatmaps specify a current lead-in time which should be used instead of the ruleset-provided value when available.
|
|
||||||
// this is not available as an option in the live editor but can still be applied via .osu editing.
|
|
||||||
if (beatmap.BeatmapInfo.AudioLeadIn > 0)
|
|
||||||
startTime = Math.Min(startTime, firstHitObjectTime - beatmap.BeatmapInfo.AudioLeadIn);
|
|
||||||
}
|
|
||||||
|
|
||||||
Seek(startTime);
|
|
||||||
|
|
||||||
adjustableClock.ProcessFrame();
|
|
||||||
}
|
|
||||||
|
|
||||||
public void Restart()
|
|
||||||
{
|
|
||||||
Task.Run(() =>
|
|
||||||
{
|
|
||||||
track.Seek(0);
|
|
||||||
track.Stop();
|
|
||||||
|
|
||||||
Schedule(() =>
|
|
||||||
{
|
|
||||||
adjustableClock.ChangeSource(track);
|
|
||||||
updateRate();
|
|
||||||
|
|
||||||
if (!IsPaused.Value)
|
|
||||||
Start();
|
|
||||||
});
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
public void Start()
|
|
||||||
{
|
|
||||||
if (!adjustableClock.IsRunning)
|
|
||||||
{
|
{
|
||||||
// Seeking the decoupled clock to its current time ensures that its source clock will be seeked to the same time
|
// Seeking the decoupled clock to its current time ensures that its source clock will be seeked to the same time
|
||||||
// This accounts for the audio clock source potentially taking time to enter a completely stopped state
|
// This accounts for the clock source potentially taking time to enter a completely stopped state
|
||||||
Seek(GameplayClock.CurrentTime);
|
Seek(GameplayClock.CurrentTime);
|
||||||
|
|
||||||
adjustableClock.Start();
|
AdjustableSource.Start();
|
||||||
}
|
}
|
||||||
|
|
||||||
IsPaused.Value = false;
|
IsPaused.Value = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Skip forward to the next valid skip point.
|
|
||||||
/// </summary>
|
|
||||||
public void Skip()
|
|
||||||
{
|
|
||||||
if (GameplayClock.CurrentTime > gameplayStartTime - MINIMUM_SKIP_TIME)
|
|
||||||
return;
|
|
||||||
|
|
||||||
double skipTarget = gameplayStartTime - MINIMUM_SKIP_TIME;
|
|
||||||
|
|
||||||
if (GameplayClock.CurrentTime < 0 && skipTarget > 6000)
|
|
||||||
// double skip exception for storyboards with very long intros
|
|
||||||
skipTarget = 0;
|
|
||||||
|
|
||||||
Seek(skipTarget);
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Seek to a specific time in gameplay.
|
/// Seek to a specific time in gameplay.
|
||||||
/// <remarks>
|
|
||||||
/// Adjusts for any offsets which have been applied (so the seek may not be the expected point in time on the underlying audio track).
|
|
||||||
/// </remarks>
|
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="time">The destination time to seek to.</param>
|
/// <param name="time">The destination time to seek to.</param>
|
||||||
public void Seek(double time)
|
public virtual void Seek(double time)
|
||||||
{
|
{
|
||||||
// remove the offset component here because most of the time we want the seek to be aligned to gameplay, not the audio track.
|
AdjustableSource.Seek(time);
|
||||||
// we may want to consider reversing the application of offsets in the future as it may feel more correct.
|
|
||||||
adjustableClock.Seek(time - totalOffset);
|
|
||||||
|
|
||||||
// manually process frame to ensure GameplayClock is correctly updated after a seek.
|
// Manually process to make sure the gameplay clock is correctly updated after a seek.
|
||||||
userOffsetClock.ProcessFrame();
|
GameplayClock.UnderlyingClock.ProcessFrame();
|
||||||
}
|
|
||||||
|
|
||||||
public void Stop()
|
|
||||||
{
|
|
||||||
IsPaused.Value = true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Changes the backing clock to avoid using the originally provided track.
|
/// Stops gameplay.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public void StopUsingBeatmapClock()
|
public virtual void Stop() => IsPaused.Value = true;
|
||||||
{
|
|
||||||
removeSourceClockAdjustments();
|
|
||||||
|
|
||||||
track = new TrackVirtual(track.Length);
|
/// <summary>
|
||||||
adjustableClock.ChangeSource(track);
|
/// Resets this <see cref="GameplayClockContainer"/> and the source to an initial state ready for gameplay.
|
||||||
|
/// </summary>
|
||||||
|
public virtual void Reset()
|
||||||
|
{
|
||||||
|
Seek(0);
|
||||||
|
|
||||||
|
// Manually stop the source in order to not affect the IsPaused state.
|
||||||
|
AdjustableSource.Stop();
|
||||||
|
|
||||||
|
if (!IsPaused.Value)
|
||||||
|
Start();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Changes the source clock.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="sourceClock">The new source.</param>
|
||||||
|
protected void ChangeSource(IClock sourceClock) => AdjustableSource.ChangeSource(SourceClock = sourceClock);
|
||||||
|
|
||||||
protected override void Update()
|
protected override void Update()
|
||||||
{
|
{
|
||||||
if (!IsPaused.Value)
|
if (!IsPaused.Value)
|
||||||
{
|
GameplayClock.UnderlyingClock.ProcessFrame();
|
||||||
userOffsetClock.ProcessFrame();
|
|
||||||
}
|
|
||||||
|
|
||||||
base.Update();
|
base.Update();
|
||||||
}
|
}
|
||||||
|
|
||||||
private bool speedAdjustmentsApplied;
|
/// <summary>
|
||||||
|
/// Invoked when the value of <see cref="IsPaused"/> is changed to start or stop the <see cref="AdjustableSource"/> clock.
|
||||||
private void updateRate()
|
/// </summary>
|
||||||
|
/// <param name="isPaused">Whether the clock should now be paused.</param>
|
||||||
|
protected virtual void OnIsPausedChanged(ValueChangedEvent<bool> isPaused)
|
||||||
{
|
{
|
||||||
if (speedAdjustmentsApplied)
|
if (isPaused.NewValue)
|
||||||
return;
|
AdjustableSource.Stop();
|
||||||
|
else
|
||||||
track.AddAdjustment(AdjustableProperty.Frequency, pauseFreqAdjust);
|
AdjustableSource.Start();
|
||||||
track.AddAdjustment(AdjustableProperty.Tempo, UserPlaybackRate);
|
|
||||||
|
|
||||||
localGameplayClock.MutableNonGameplayAdjustments.Add(pauseFreqAdjust);
|
|
||||||
localGameplayClock.MutableNonGameplayAdjustments.Add(UserPlaybackRate);
|
|
||||||
|
|
||||||
speedAdjustmentsApplied = true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override void Dispose(bool isDisposing)
|
/// <summary>
|
||||||
{
|
/// Creates the final <see cref="GameplayClock"/> which is exposed via DI to be used by gameplay components.
|
||||||
base.Dispose(isDisposing);
|
/// </summary>
|
||||||
removeSourceClockAdjustments();
|
/// <remarks>
|
||||||
}
|
/// Any intermediate clocks such as platform offsets should be applied here.
|
||||||
|
/// </remarks>
|
||||||
private void removeSourceClockAdjustments()
|
/// <param name="source">The <see cref="IFrameBasedClock"/> providing the source time.</param>
|
||||||
{
|
/// <returns>The final <see cref="GameplayClock"/>.</returns>
|
||||||
if (!speedAdjustmentsApplied) return;
|
protected abstract GameplayClock CreateGameplayClock(IFrameBasedClock source);
|
||||||
|
|
||||||
track.RemoveAdjustment(AdjustableProperty.Frequency, pauseFreqAdjust);
|
|
||||||
track.RemoveAdjustment(AdjustableProperty.Tempo, UserPlaybackRate);
|
|
||||||
|
|
||||||
localGameplayClock.MutableNonGameplayAdjustments.Remove(pauseFreqAdjust);
|
|
||||||
localGameplayClock.MutableNonGameplayAdjustments.Remove(UserPlaybackRate);
|
|
||||||
|
|
||||||
speedAdjustmentsApplied = false;
|
|
||||||
}
|
|
||||||
|
|
||||||
private class LocalGameplayClock : GameplayClock
|
|
||||||
{
|
|
||||||
public readonly List<Bindable<double>> MutableNonGameplayAdjustments = new List<Bindable<double>>();
|
|
||||||
|
|
||||||
public override IEnumerable<Bindable<double>> NonGameplayAdjustments => MutableNonGameplayAdjustments;
|
|
||||||
|
|
||||||
public LocalGameplayClock(FramedOffsetClock underlyingClock)
|
|
||||||
: base(underlyingClock)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private class HardwareCorrectionOffsetClock : FramedOffsetClock
|
|
||||||
{
|
|
||||||
// we always want to apply the same real-time offset, so it should be adjusted by the difference in playback rate (from realtime) to achieve this.
|
|
||||||
// base implementation already adds offset at 1.0 rate, so we only add the difference from that here.
|
|
||||||
public override double CurrentTime => base.CurrentTime + Offset * (Rate - 1);
|
|
||||||
|
|
||||||
public HardwareCorrectionOffsetClock(IClock source, bool processSource = true)
|
|
||||||
: base(source, processSource)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
233
osu.Game/Screens/Play/MasterGameplayClockContainer.cs
Normal file
233
osu.Game/Screens/Play/MasterGameplayClockContainer.cs
Normal file
@ -0,0 +1,233 @@
|
|||||||
|
// 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 System.Linq;
|
||||||
|
using osu.Framework;
|
||||||
|
using osu.Framework.Allocation;
|
||||||
|
using osu.Framework.Audio;
|
||||||
|
using osu.Framework.Audio.Track;
|
||||||
|
using osu.Framework.Bindables;
|
||||||
|
using osu.Framework.Graphics;
|
||||||
|
using osu.Framework.Timing;
|
||||||
|
using osu.Game.Beatmaps;
|
||||||
|
using osu.Game.Configuration;
|
||||||
|
|
||||||
|
namespace osu.Game.Screens.Play
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// A <see cref="GameplayClockContainer"/> which uses a <see cref="WorkingBeatmap"/> as a source.
|
||||||
|
/// <para>
|
||||||
|
/// This is the most complete <see cref="GameplayClockContainer"/> which takes into account all user and platform offsets,
|
||||||
|
/// and provides implementations for user actions such as skipping or adjusting playback rates that may occur during gameplay.
|
||||||
|
/// </para>
|
||||||
|
/// </summary>
|
||||||
|
/// <remarks>
|
||||||
|
/// This is intended to be used as a single controller for gameplay, or as a reference source for other <see cref="GameplayClockContainer"/>s.
|
||||||
|
/// </remarks>
|
||||||
|
public class MasterGameplayClockContainer : GameplayClockContainer
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Duration before gameplay start time required before skip button displays.
|
||||||
|
/// </summary>
|
||||||
|
public const double MINIMUM_SKIP_TIME = 1000;
|
||||||
|
|
||||||
|
protected Track Track => (Track)SourceClock;
|
||||||
|
|
||||||
|
public readonly BindableNumber<double> UserPlaybackRate = new BindableDouble(1)
|
||||||
|
{
|
||||||
|
Default = 1,
|
||||||
|
MinValue = 0.5,
|
||||||
|
MaxValue = 2,
|
||||||
|
Precision = 0.1,
|
||||||
|
};
|
||||||
|
|
||||||
|
private double totalOffset => userOffsetClock.Offset + platformOffsetClock.Offset;
|
||||||
|
|
||||||
|
private readonly BindableDouble pauseFreqAdjust = new BindableDouble(1);
|
||||||
|
|
||||||
|
private readonly WorkingBeatmap beatmap;
|
||||||
|
private readonly double gameplayStartTime;
|
||||||
|
private readonly bool startAtGameplayStart;
|
||||||
|
private readonly double firstHitObjectTime;
|
||||||
|
|
||||||
|
private FramedOffsetClock userOffsetClock;
|
||||||
|
private FramedOffsetClock platformOffsetClock;
|
||||||
|
private MasterGameplayClock masterGameplayClock;
|
||||||
|
private Bindable<double> userAudioOffset;
|
||||||
|
private double startOffset;
|
||||||
|
|
||||||
|
public MasterGameplayClockContainer(WorkingBeatmap beatmap, double gameplayStartTime, bool startAtGameplayStart = false)
|
||||||
|
: base(beatmap.Track)
|
||||||
|
{
|
||||||
|
this.beatmap = beatmap;
|
||||||
|
this.gameplayStartTime = gameplayStartTime;
|
||||||
|
this.startAtGameplayStart = startAtGameplayStart;
|
||||||
|
|
||||||
|
firstHitObjectTime = beatmap.Beatmap.HitObjects.First().StartTime;
|
||||||
|
}
|
||||||
|
|
||||||
|
[BackgroundDependencyLoader]
|
||||||
|
private void load(OsuConfigManager config)
|
||||||
|
{
|
||||||
|
userAudioOffset = config.GetBindable<double>(OsuSetting.AudioOffset);
|
||||||
|
userAudioOffset.BindValueChanged(offset => userOffsetClock.Offset = offset.NewValue, true);
|
||||||
|
|
||||||
|
// sane default provided by ruleset.
|
||||||
|
startOffset = gameplayStartTime;
|
||||||
|
|
||||||
|
if (!startAtGameplayStart)
|
||||||
|
{
|
||||||
|
startOffset = Math.Min(0, startOffset);
|
||||||
|
|
||||||
|
// if a storyboard is present, it may dictate the appropriate start time by having events in negative time space.
|
||||||
|
// this is commonly used to display an intro before the audio track start.
|
||||||
|
double? firstStoryboardEvent = beatmap.Storyboard.EarliestEventTime;
|
||||||
|
if (firstStoryboardEvent != null)
|
||||||
|
startOffset = Math.Min(startOffset, firstStoryboardEvent.Value);
|
||||||
|
|
||||||
|
// some beatmaps specify a current lead-in time which should be used instead of the ruleset-provided value when available.
|
||||||
|
// this is not available as an option in the live editor but can still be applied via .osu editing.
|
||||||
|
if (beatmap.BeatmapInfo.AudioLeadIn > 0)
|
||||||
|
startOffset = Math.Min(startOffset, firstHitObjectTime - beatmap.BeatmapInfo.AudioLeadIn);
|
||||||
|
}
|
||||||
|
|
||||||
|
Seek(startOffset);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected override void OnIsPausedChanged(ValueChangedEvent<bool> isPaused)
|
||||||
|
{
|
||||||
|
// The source is stopped by a frequency fade first.
|
||||||
|
if (isPaused.NewValue)
|
||||||
|
this.TransformBindableTo(pauseFreqAdjust, 0, 200, Easing.Out).OnComplete(_ => AdjustableSource.Stop());
|
||||||
|
else
|
||||||
|
this.TransformBindableTo(pauseFreqAdjust, 1, 200, Easing.In);
|
||||||
|
}
|
||||||
|
|
||||||
|
public override void Start()
|
||||||
|
{
|
||||||
|
addSourceClockAdjustments();
|
||||||
|
base.Start();
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Seek to a specific time in gameplay.
|
||||||
|
/// </summary>
|
||||||
|
/// <remarks>
|
||||||
|
/// Adjusts for any offsets which have been applied (so the seek may not be the expected point in time on the underlying audio track).
|
||||||
|
/// </remarks>
|
||||||
|
/// <param name="time">The destination time to seek to.</param>
|
||||||
|
public override void Seek(double time)
|
||||||
|
{
|
||||||
|
// remove the offset component here because most of the time we want the seek to be aligned to gameplay, not the audio track.
|
||||||
|
// we may want to consider reversing the application of offsets in the future as it may feel more correct.
|
||||||
|
base.Seek(time - totalOffset);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Skip forward to the next valid skip point.
|
||||||
|
/// </summary>
|
||||||
|
public void Skip()
|
||||||
|
{
|
||||||
|
if (GameplayClock.CurrentTime > gameplayStartTime - MINIMUM_SKIP_TIME)
|
||||||
|
return;
|
||||||
|
|
||||||
|
double skipTarget = gameplayStartTime - MINIMUM_SKIP_TIME;
|
||||||
|
|
||||||
|
if (GameplayClock.CurrentTime < 0 && skipTarget > 6000)
|
||||||
|
// double skip exception for storyboards with very long intros
|
||||||
|
skipTarget = 0;
|
||||||
|
|
||||||
|
Seek(skipTarget);
|
||||||
|
}
|
||||||
|
|
||||||
|
public override void Reset()
|
||||||
|
{
|
||||||
|
base.Reset();
|
||||||
|
Seek(startOffset);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected override GameplayClock CreateGameplayClock(IFrameBasedClock source)
|
||||||
|
{
|
||||||
|
// Lazer's audio timings in general doesn't match stable. This is the result of user testing, albeit limited.
|
||||||
|
// This only seems to be required on windows. We need to eventually figure out why, with a bit of luck.
|
||||||
|
platformOffsetClock = new HardwareCorrectionOffsetClock(source) { Offset = RuntimeInfo.OS == RuntimeInfo.Platform.Windows ? 15 : 0 };
|
||||||
|
|
||||||
|
// the final usable gameplay clock with user-set offsets applied.
|
||||||
|
userOffsetClock = new HardwareCorrectionOffsetClock(platformOffsetClock);
|
||||||
|
|
||||||
|
return masterGameplayClock = new MasterGameplayClock(userOffsetClock);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Changes the backing clock to avoid using the originally provided track.
|
||||||
|
/// </summary>
|
||||||
|
public void StopUsingBeatmapClock()
|
||||||
|
{
|
||||||
|
removeSourceClockAdjustments();
|
||||||
|
ChangeSource(new TrackVirtual(beatmap.Track.Length));
|
||||||
|
addSourceClockAdjustments();
|
||||||
|
}
|
||||||
|
|
||||||
|
private bool speedAdjustmentsApplied;
|
||||||
|
|
||||||
|
private void addSourceClockAdjustments()
|
||||||
|
{
|
||||||
|
if (speedAdjustmentsApplied)
|
||||||
|
return;
|
||||||
|
|
||||||
|
Track.AddAdjustment(AdjustableProperty.Frequency, pauseFreqAdjust);
|
||||||
|
Track.AddAdjustment(AdjustableProperty.Tempo, UserPlaybackRate);
|
||||||
|
|
||||||
|
masterGameplayClock.MutableNonGameplayAdjustments.Add(pauseFreqAdjust);
|
||||||
|
masterGameplayClock.MutableNonGameplayAdjustments.Add(UserPlaybackRate);
|
||||||
|
|
||||||
|
speedAdjustmentsApplied = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void removeSourceClockAdjustments()
|
||||||
|
{
|
||||||
|
if (!speedAdjustmentsApplied)
|
||||||
|
return;
|
||||||
|
|
||||||
|
Track.RemoveAdjustment(AdjustableProperty.Frequency, pauseFreqAdjust);
|
||||||
|
Track.RemoveAdjustment(AdjustableProperty.Tempo, UserPlaybackRate);
|
||||||
|
|
||||||
|
masterGameplayClock.MutableNonGameplayAdjustments.Remove(pauseFreqAdjust);
|
||||||
|
masterGameplayClock.MutableNonGameplayAdjustments.Remove(UserPlaybackRate);
|
||||||
|
|
||||||
|
speedAdjustmentsApplied = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected override void Dispose(bool isDisposing)
|
||||||
|
{
|
||||||
|
base.Dispose(isDisposing);
|
||||||
|
removeSourceClockAdjustments();
|
||||||
|
}
|
||||||
|
|
||||||
|
private class HardwareCorrectionOffsetClock : FramedOffsetClock
|
||||||
|
{
|
||||||
|
// we always want to apply the same real-time offset, so it should be adjusted by the difference in playback rate (from realtime) to achieve this.
|
||||||
|
// base implementation already adds offset at 1.0 rate, so we only add the difference from that here.
|
||||||
|
public override double CurrentTime => base.CurrentTime + Offset * (Rate - 1);
|
||||||
|
|
||||||
|
public HardwareCorrectionOffsetClock(IClock source, bool processSource = true)
|
||||||
|
: base(source, processSource)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private class MasterGameplayClock : GameplayClock
|
||||||
|
{
|
||||||
|
public readonly List<Bindable<double>> MutableNonGameplayAdjustments = new List<Bindable<double>>();
|
||||||
|
|
||||||
|
public override IEnumerable<Bindable<double>> NonGameplayAdjustments => MutableNonGameplayAdjustments;
|
||||||
|
|
||||||
|
public MasterGameplayClock(FramedOffsetClock underlyingClock)
|
||||||
|
: base(underlyingClock)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -295,7 +295,7 @@ namespace osu.Game.Screens.Play
|
|||||||
IsBreakTime.BindValueChanged(onBreakTimeChanged, true);
|
IsBreakTime.BindValueChanged(onBreakTimeChanged, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected virtual GameplayClockContainer CreateGameplayClockContainer(WorkingBeatmap beatmap, double gameplayStart) => new GameplayClockContainer(beatmap, gameplayStart);
|
protected virtual GameplayClockContainer CreateGameplayClockContainer(WorkingBeatmap beatmap, double gameplayStart) => new MasterGameplayClockContainer(beatmap, gameplayStart);
|
||||||
|
|
||||||
private Drawable createUnderlayComponents() =>
|
private Drawable createUnderlayComponents() =>
|
||||||
DimmableStoryboard = new DimmableStoryboard(Beatmap.Value.Storyboard) { RelativeSizeAxes = Axes.Both };
|
DimmableStoryboard = new DimmableStoryboard(Beatmap.Value.Storyboard) { RelativeSizeAxes = Axes.Both };
|
||||||
@ -342,7 +342,6 @@ namespace osu.Game.Screens.Play
|
|||||||
Action = () => PerformExit(true),
|
Action = () => PerformExit(true),
|
||||||
IsPaused = { BindTarget = GameplayClockContainer.IsPaused }
|
IsPaused = { BindTarget = GameplayClockContainer.IsPaused }
|
||||||
},
|
},
|
||||||
PlayerSettingsOverlay = { PlaybackSettings = { UserPlaybackRate = { BindTarget = GameplayClockContainer.UserPlaybackRate } } },
|
|
||||||
KeyCounter =
|
KeyCounter =
|
||||||
{
|
{
|
||||||
AlwaysVisible = { BindTarget = DrawableRuleset.HasReplayLoaded },
|
AlwaysVisible = { BindTarget = DrawableRuleset.HasReplayLoaded },
|
||||||
@ -386,6 +385,9 @@ namespace osu.Game.Screens.Play
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
if (GameplayClockContainer is MasterGameplayClockContainer master)
|
||||||
|
HUDOverlay.PlayerSettingsOverlay.PlaybackSettings.UserPlaybackRate.BindTarget = master.UserPlaybackRate;
|
||||||
|
|
||||||
if (!Configuration.AllowSkippingIntro)
|
if (!Configuration.AllowSkippingIntro)
|
||||||
skipOverlay.Expire();
|
skipOverlay.Expire();
|
||||||
|
|
||||||
@ -533,7 +535,8 @@ namespace osu.Game.Screens.Play
|
|||||||
// user requested skip
|
// user requested skip
|
||||||
// disable sample playback to stop currently playing samples and perform skip
|
// disable sample playback to stop currently playing samples and perform skip
|
||||||
samplePlaybackDisabled.Value = true;
|
samplePlaybackDisabled.Value = true;
|
||||||
GameplayClockContainer.Skip();
|
|
||||||
|
(GameplayClockContainer as MasterGameplayClockContainer)?.Skip();
|
||||||
|
|
||||||
// return samplePlaybackDisabled.Value to what is defined by the beatmap's current state
|
// return samplePlaybackDisabled.Value to what is defined by the beatmap's current state
|
||||||
updateSampleDisabledState();
|
updateSampleDisabledState();
|
||||||
@ -808,7 +811,7 @@ namespace osu.Game.Screens.Play
|
|||||||
if (GameplayClockContainer.GameplayClock.IsRunning)
|
if (GameplayClockContainer.GameplayClock.IsRunning)
|
||||||
throw new InvalidOperationException($"{nameof(StartGameplay)} should not be called when the gameplay clock is already running");
|
throw new InvalidOperationException($"{nameof(StartGameplay)} should not be called when the gameplay clock is already running");
|
||||||
|
|
||||||
GameplayClockContainer.Restart();
|
GameplayClockContainer.Reset();
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void OnSuspending(IScreen next)
|
public override void OnSuspending(IScreen next)
|
||||||
@ -832,7 +835,7 @@ namespace osu.Game.Screens.Play
|
|||||||
|
|
||||||
// GameplayClockContainer performs seeks / start / stop operations on the beatmap's track.
|
// GameplayClockContainer performs seeks / start / stop operations on the beatmap's track.
|
||||||
// as we are no longer the current screen, we cannot guarantee the track is still usable.
|
// as we are no longer the current screen, we cannot guarantee the track is still usable.
|
||||||
GameplayClockContainer?.StopUsingBeatmapClock();
|
(GameplayClockContainer as MasterGameplayClockContainer)?.StopUsingBeatmapClock();
|
||||||
|
|
||||||
musicController.ResetTrackAdjustments();
|
musicController.ResetTrackAdjustments();
|
||||||
|
|
||||||
|
@ -90,7 +90,7 @@ namespace osu.Game.Screens.Play
|
|||||||
|
|
||||||
private const double fade_time = 300;
|
private const double fade_time = 300;
|
||||||
|
|
||||||
private double fadeOutBeginTime => startTime - GameplayClockContainer.MINIMUM_SKIP_TIME;
|
private double fadeOutBeginTime => startTime - MasterGameplayClockContainer.MINIMUM_SKIP_TIME;
|
||||||
|
|
||||||
protected override void LoadComplete()
|
protected override void LoadComplete()
|
||||||
{
|
{
|
||||||
|
@ -61,7 +61,7 @@ namespace osu.Game.Screens.Play
|
|||||||
if (firstFrameTime == null || firstFrameTime <= gameplayStart + 5000)
|
if (firstFrameTime == null || firstFrameTime <= gameplayStart + 5000)
|
||||||
return base.CreateGameplayClockContainer(beatmap, gameplayStart);
|
return base.CreateGameplayClockContainer(beatmap, gameplayStart);
|
||||||
|
|
||||||
return new GameplayClockContainer(beatmap, firstFrameTime.Value, true);
|
return new MasterGameplayClockContainer(beatmap, firstFrameTime.Value, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
public override bool OnExiting(IScreen next)
|
public override bool OnExiting(IScreen next)
|
||||||
|
@ -44,7 +44,6 @@ namespace osu.Game.Screens.Spectate
|
|||||||
private readonly object stateLock = new object();
|
private readonly object stateLock = new object();
|
||||||
|
|
||||||
private readonly Dictionary<int, User> userMap = new Dictionary<int, User>();
|
private readonly Dictionary<int, User> userMap = new Dictionary<int, User>();
|
||||||
private readonly Dictionary<int, SpectatorState> spectatorStates = new Dictionary<int, SpectatorState>();
|
|
||||||
private readonly Dictionary<int, GameplayState> gameplayStates = new Dictionary<int, GameplayState>();
|
private readonly Dictionary<int, GameplayState> gameplayStates = new Dictionary<int, GameplayState>();
|
||||||
|
|
||||||
private IBindable<WeakReference<BeatmapSetInfo>> managerUpdated;
|
private IBindable<WeakReference<BeatmapSetInfo>> managerUpdated;
|
||||||
@ -62,26 +61,42 @@ namespace osu.Game.Screens.Spectate
|
|||||||
{
|
{
|
||||||
base.LoadComplete();
|
base.LoadComplete();
|
||||||
|
|
||||||
spectatorClient.OnUserBeganPlaying += userBeganPlaying;
|
populateAllUsers().ContinueWith(_ => Schedule(() =>
|
||||||
|
{
|
||||||
|
spectatorClient.BindUserBeganPlaying(userBeganPlaying, true);
|
||||||
spectatorClient.OnUserFinishedPlaying += userFinishedPlaying;
|
spectatorClient.OnUserFinishedPlaying += userFinishedPlaying;
|
||||||
spectatorClient.OnNewFrames += userSentFrames;
|
spectatorClient.OnNewFrames += userSentFrames;
|
||||||
|
|
||||||
foreach (var id in userIds)
|
managerUpdated = beatmaps.ItemUpdated.GetBoundCopy();
|
||||||
|
managerUpdated.BindValueChanged(beatmapUpdated);
|
||||||
|
|
||||||
|
lock (stateLock)
|
||||||
{
|
{
|
||||||
userLookupCache.GetUserAsync(id).ContinueWith(u => Schedule(() =>
|
foreach (var (id, _) in userMap)
|
||||||
|
spectatorClient.WatchUser(id);
|
||||||
|
}
|
||||||
|
}));
|
||||||
|
}
|
||||||
|
|
||||||
|
private Task populateAllUsers()
|
||||||
{
|
{
|
||||||
if (u.Result == null)
|
var userLookupTasks = new Task[userIds.Length];
|
||||||
|
|
||||||
|
for (int i = 0; i < userIds.Length; i++)
|
||||||
|
{
|
||||||
|
var userId = userIds[i];
|
||||||
|
|
||||||
|
userLookupTasks[i] = userLookupCache.GetUserAsync(userId).ContinueWith(task =>
|
||||||
|
{
|
||||||
|
if (!task.IsCompletedSuccessfully)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
lock (stateLock)
|
lock (stateLock)
|
||||||
userMap[id] = u.Result;
|
userMap[userId] = task.Result;
|
||||||
|
});
|
||||||
spectatorClient.WatchUser(id);
|
|
||||||
}), TaskContinuationOptions.OnlyOnRanToCompletion);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
managerUpdated = beatmaps.ItemUpdated.GetBoundCopy();
|
return Task.WhenAll(userLookupTasks);
|
||||||
managerUpdated.BindValueChanged(beatmapUpdated);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void beatmapUpdated(ValueChangedEvent<WeakReference<BeatmapSetInfo>> e)
|
private void beatmapUpdated(ValueChangedEvent<WeakReference<BeatmapSetInfo>> e)
|
||||||
@ -91,9 +106,12 @@ namespace osu.Game.Screens.Spectate
|
|||||||
|
|
||||||
lock (stateLock)
|
lock (stateLock)
|
||||||
{
|
{
|
||||||
foreach (var (userId, state) in spectatorStates)
|
foreach (var (userId, _) in userMap)
|
||||||
{
|
{
|
||||||
if (beatmapSet.Beatmaps.Any(b => b.OnlineBeatmapID == state.BeatmapID))
|
if (!spectatorClient.TryGetPlayingUserState(userId, out var userState))
|
||||||
|
continue;
|
||||||
|
|
||||||
|
if (beatmapSet.Beatmaps.Any(b => b.OnlineBeatmapID == userState.BeatmapID))
|
||||||
updateGameplayState(userId);
|
updateGameplayState(userId);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -109,7 +127,10 @@ namespace osu.Game.Screens.Spectate
|
|||||||
if (!userMap.ContainsKey(userId))
|
if (!userMap.ContainsKey(userId))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
spectatorStates[userId] = state;
|
// The user may have stopped playing.
|
||||||
|
if (!spectatorClient.TryGetPlayingUserState(userId, out _))
|
||||||
|
return;
|
||||||
|
|
||||||
Schedule(() => OnUserStateChanged(userId, state));
|
Schedule(() => OnUserStateChanged(userId, state));
|
||||||
|
|
||||||
updateGameplayState(userId);
|
updateGameplayState(userId);
|
||||||
@ -122,7 +143,10 @@ namespace osu.Game.Screens.Spectate
|
|||||||
{
|
{
|
||||||
Debug.Assert(userMap.ContainsKey(userId));
|
Debug.Assert(userMap.ContainsKey(userId));
|
||||||
|
|
||||||
var spectatorState = spectatorStates[userId];
|
// The user may have stopped playing.
|
||||||
|
if (!spectatorClient.TryGetPlayingUserState(userId, out var spectatorState))
|
||||||
|
return;
|
||||||
|
|
||||||
var user = userMap[userId];
|
var user = userMap[userId];
|
||||||
|
|
||||||
var resolvedRuleset = rulesets.AvailableRulesets.FirstOrDefault(r => r.ID == spectatorState.RulesetID)?.CreateInstance();
|
var resolvedRuleset = rulesets.AvailableRulesets.FirstOrDefault(r => r.ID == spectatorState.RulesetID)?.CreateInstance();
|
||||||
|
@ -29,7 +29,7 @@
|
|||||||
<PackageReference Include="Microsoft.Extensions.Configuration.Abstractions" Version="5.0.0" />
|
<PackageReference Include="Microsoft.Extensions.Configuration.Abstractions" Version="5.0.0" />
|
||||||
<PackageReference Include="Microsoft.NETCore.Targets" Version="3.1.0" />
|
<PackageReference Include="Microsoft.NETCore.Targets" Version="3.1.0" />
|
||||||
<PackageReference Include="Newtonsoft.Json" Version="13.0.1" />
|
<PackageReference Include="Newtonsoft.Json" Version="13.0.1" />
|
||||||
<PackageReference Include="ppy.osu.Framework" Version="2021.419.0" />
|
<PackageReference Include="ppy.osu.Framework" Version="2021.422.0" />
|
||||||
<PackageReference Include="ppy.osu.Game.Resources" Version="2021.412.0" />
|
<PackageReference Include="ppy.osu.Game.Resources" Version="2021.412.0" />
|
||||||
<PackageReference Include="Sentry" Version="3.2.0" />
|
<PackageReference Include="Sentry" Version="3.2.0" />
|
||||||
<PackageReference Include="SharpCompress" Version="0.28.1" />
|
<PackageReference Include="SharpCompress" Version="0.28.1" />
|
||||||
|
@ -70,7 +70,7 @@
|
|||||||
<Reference Include="System.Net.Http" />
|
<Reference Include="System.Net.Http" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup Label="Package References">
|
<ItemGroup Label="Package References">
|
||||||
<PackageReference Include="ppy.osu.Framework.iOS" Version="2021.419.0" />
|
<PackageReference Include="ppy.osu.Framework.iOS" Version="2021.422.0" />
|
||||||
<PackageReference Include="ppy.osu.Game.Resources" Version="2021.412.0" />
|
<PackageReference Include="ppy.osu.Game.Resources" Version="2021.412.0" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<!-- See https://github.com/dotnet/runtime/issues/35988 (can be removed after Xamarin uses net5.0 / net6.0) -->
|
<!-- See https://github.com/dotnet/runtime/issues/35988 (can be removed after Xamarin uses net5.0 / net6.0) -->
|
||||||
@ -93,7 +93,7 @@
|
|||||||
<PackageReference Include="Microsoft.EntityFrameworkCore.Sqlite" Version="2.2.6" />
|
<PackageReference Include="Microsoft.EntityFrameworkCore.Sqlite" Version="2.2.6" />
|
||||||
<PackageReference Include="Microsoft.EntityFrameworkCore.Sqlite.Core" Version="2.2.6" />
|
<PackageReference Include="Microsoft.EntityFrameworkCore.Sqlite.Core" Version="2.2.6" />
|
||||||
<PackageReference Include="Newtonsoft.Json" Version="12.0.3" />
|
<PackageReference Include="Newtonsoft.Json" Version="12.0.3" />
|
||||||
<PackageReference Include="ppy.osu.Framework" Version="2021.419.0" />
|
<PackageReference Include="ppy.osu.Framework" Version="2021.422.0" />
|
||||||
<PackageReference Include="SharpCompress" Version="0.28.1" />
|
<PackageReference Include="SharpCompress" Version="0.28.1" />
|
||||||
<PackageReference Include="NUnit" Version="3.12.0" />
|
<PackageReference Include="NUnit" Version="3.12.0" />
|
||||||
<PackageReference Include="SharpRaven" Version="2.4.0" />
|
<PackageReference Include="SharpRaven" Version="2.4.0" />
|
||||||
|
Loading…
Reference in New Issue
Block a user