mirror of
https://github.com/ppy/osu.git
synced 2024-11-11 14:17:26 +08:00
Merge branch 'master' into fix-resume-skip-forward
This commit is contained in:
commit
3d93e0ded1
@ -70,10 +70,17 @@ namespace osu.Game.Rulesets.Catch.Tests.Editor
|
||||
[Cached]
|
||||
private readonly BindableBeatDivisor beatDivisor;
|
||||
|
||||
protected override Container<Drawable> Content { get; } = new Container { RelativeSizeAxes = Axes.Both };
|
||||
|
||||
public EditorBeatmapDependencyContainer(IBeatmap beatmap, BindableBeatDivisor beatDivisor)
|
||||
{
|
||||
editorClock = new EditorClock(beatmap, beatDivisor);
|
||||
this.beatDivisor = beatDivisor;
|
||||
|
||||
InternalChildren = new Drawable[]
|
||||
{
|
||||
editorClock = new EditorClock(beatmap, beatDivisor),
|
||||
Content,
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -35,7 +35,7 @@ namespace osu.Game.Rulesets.Mania.Tests.Editor
|
||||
public void Setup() => Schedule(() =>
|
||||
{
|
||||
BeatDivisor.Value = 8;
|
||||
Clock.Seek(0);
|
||||
EditorClock.Seek(0);
|
||||
|
||||
Child = composer = new TestComposer { RelativeSizeAxes = Axes.Both };
|
||||
});
|
||||
@ -53,7 +53,7 @@ namespace osu.Game.Rulesets.Mania.Tests.Editor
|
||||
{
|
||||
lastObject = this.ChildrenOfType<DrawableHitObject>().Single(d => d.HitObject == composer.EditorBeatmap.HitObjects.Last());
|
||||
originalTime = lastObject.HitObject.StartTime;
|
||||
Clock.Seek(composer.EditorBeatmap.HitObjects.Last().StartTime);
|
||||
EditorClock.Seek(composer.EditorBeatmap.HitObjects.Last().StartTime);
|
||||
});
|
||||
|
||||
AddStep("select all objects", () => composer.EditorBeatmap.SelectedHitObjects.AddRange(composer.EditorBeatmap.HitObjects));
|
||||
@ -90,7 +90,7 @@ namespace osu.Game.Rulesets.Mania.Tests.Editor
|
||||
{
|
||||
lastObject = this.ChildrenOfType<DrawableHitObject>().Single(d => d.HitObject == composer.EditorBeatmap.HitObjects.Last());
|
||||
originalTime = lastObject.HitObject.StartTime;
|
||||
Clock.Seek(composer.EditorBeatmap.HitObjects.Last().StartTime);
|
||||
EditorClock.Seek(composer.EditorBeatmap.HitObjects.Last().StartTime);
|
||||
});
|
||||
|
||||
AddStep("select all objects", () => composer.EditorBeatmap.SelectedHitObjects.AddRange(composer.EditorBeatmap.HitObjects));
|
||||
@ -125,7 +125,7 @@ namespace osu.Game.Rulesets.Mania.Tests.Editor
|
||||
AddStep("seek to last object", () =>
|
||||
{
|
||||
lastObject = this.ChildrenOfType<DrawableHitObject>().Single(d => d.HitObject == composer.EditorBeatmap.HitObjects.Last());
|
||||
Clock.Seek(composer.EditorBeatmap.HitObjects.Last().StartTime);
|
||||
EditorClock.Seek(composer.EditorBeatmap.HitObjects.Last().StartTime);
|
||||
});
|
||||
|
||||
AddStep("select all objects", () => composer.EditorBeatmap.SelectedHitObjects.AddRange(composer.EditorBeatmap.HitObjects));
|
||||
|
@ -3,9 +3,11 @@
|
||||
|
||||
using System.Linq;
|
||||
using NUnit.Framework;
|
||||
using osu.Framework.Testing;
|
||||
using osu.Framework.Utils;
|
||||
using osu.Game.Rulesets.Objects;
|
||||
using osu.Game.Rulesets.Objects.Types;
|
||||
using osu.Game.Rulesets.Osu.Edit;
|
||||
using osu.Game.Rulesets.Osu.Objects;
|
||||
using osuTK;
|
||||
using osuTK.Input;
|
||||
@ -14,6 +16,8 @@ namespace osu.Game.Rulesets.Osu.Tests.Editor
|
||||
{
|
||||
public class TestSceneObjectMerging : TestSceneOsuEditor
|
||||
{
|
||||
private OsuSelectionHandler selectionHandler => Editor.ChildrenOfType<OsuSelectionHandler>().First();
|
||||
|
||||
[Test]
|
||||
public void TestSimpleMerge()
|
||||
{
|
||||
@ -29,6 +33,9 @@ namespace osu.Game.Rulesets.Osu.Tests.Editor
|
||||
EditorBeatmap.SelectedHitObjects.Add(circle2);
|
||||
});
|
||||
|
||||
moveMouseToHitObject(1);
|
||||
AddAssert("merge option available", () => selectionHandler.ContextMenuItems.Any(o => o.Text.Value == "Merge selection"));
|
||||
|
||||
mergeSelection();
|
||||
|
||||
AddAssert("slider created", () => circle1 is not null && circle2 is not null && sliderCreatedFor(
|
||||
@ -174,6 +181,30 @@ namespace osu.Game.Rulesets.Osu.Tests.Editor
|
||||
AddAssert("spinner not merged", () => EditorBeatmap.HitObjects.Contains(spinner));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestIllegalMerge()
|
||||
{
|
||||
HitCircle? circle1 = null;
|
||||
HitCircle? circle2 = null;
|
||||
|
||||
AddStep("add two circles on the same position", () =>
|
||||
{
|
||||
circle1 = new HitCircle();
|
||||
circle2 = new HitCircle { Position = circle1.Position + Vector2.UnitX, StartTime = 1 };
|
||||
EditorClock.Seek(0);
|
||||
EditorBeatmap.Add(circle1);
|
||||
EditorBeatmap.Add(circle2);
|
||||
EditorBeatmap.SelectedHitObjects.Add(circle1);
|
||||
EditorBeatmap.SelectedHitObjects.Add(circle2);
|
||||
});
|
||||
|
||||
moveMouseToHitObject(1);
|
||||
AddAssert("merge option not available", () => selectionHandler.ContextMenuItems.Length > 0 && selectionHandler.ContextMenuItems.All(o => o.Text.Value != "Merge selection"));
|
||||
mergeSelection();
|
||||
AddAssert("circles not merged", () => circle1 is not null && circle2 is not null
|
||||
&& EditorBeatmap.HitObjects.Contains(circle1) && EditorBeatmap.HitObjects.Contains(circle2));
|
||||
}
|
||||
|
||||
private void mergeSelection()
|
||||
{
|
||||
AddStep("merge selection", () =>
|
||||
@ -225,5 +256,17 @@ namespace osu.Game.Rulesets.Osu.Tests.Editor
|
||||
|
||||
return mergedSlider.Samples[0] is not null;
|
||||
}
|
||||
|
||||
private void moveMouseToHitObject(int index)
|
||||
{
|
||||
AddStep($"hover mouse over hit object {index}", () =>
|
||||
{
|
||||
if (EditorBeatmap.HitObjects.Count <= index)
|
||||
return;
|
||||
|
||||
Vector2 position = ((OsuHitObject)EditorBeatmap.HitObjects[index]).Position;
|
||||
InputManager.MoveMouseTo(selectionHandler.ToScreenSpace(position));
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -59,10 +59,9 @@ namespace osu.Game.Rulesets.Osu.Tests.Editor
|
||||
}
|
||||
});
|
||||
|
||||
editorClock = new EditorClock(editorBeatmap);
|
||||
|
||||
base.Content.Children = new Drawable[]
|
||||
{
|
||||
editorClock = new EditorClock(editorBeatmap),
|
||||
snapProvider,
|
||||
Content
|
||||
};
|
||||
|
@ -18,11 +18,14 @@ namespace osu.Game.Rulesets.Osu.Difficulty.Evaluators
|
||||
private const double min_velocity = 0.5;
|
||||
private const double slider_multiplier = 1.3;
|
||||
|
||||
private const double min_angle_multiplier = 0.2;
|
||||
|
||||
/// <summary>
|
||||
/// Evaluates the difficulty of memorising and hitting an object, based on:
|
||||
/// <list type="bullet">
|
||||
/// <item><description>distance between a number of previous objects and the current object,</description></item>
|
||||
/// <item><description>the visual opacity of the current object,</description></item>
|
||||
/// <item><description>the angle made by the current object,</description></item>
|
||||
/// <item><description>length and speed of the current object (for sliders),</description></item>
|
||||
/// <item><description>and whether the hidden mod is enabled.</description></item>
|
||||
/// </list>
|
||||
@ -43,6 +46,8 @@ namespace osu.Game.Rulesets.Osu.Difficulty.Evaluators
|
||||
|
||||
OsuDifficultyHitObject lastObj = osuCurrent;
|
||||
|
||||
double angleRepeatCount = 0.0;
|
||||
|
||||
// This is iterating backwards in time from the current object.
|
||||
for (int i = 0; i < Math.Min(current.Index, 10); i++)
|
||||
{
|
||||
@ -66,6 +71,13 @@ namespace osu.Game.Rulesets.Osu.Difficulty.Evaluators
|
||||
double opacityBonus = 1.0 + max_opacity_bonus * (1.0 - osuCurrent.OpacityAt(currentHitObject.StartTime, hidden));
|
||||
|
||||
result += stackNerf * opacityBonus * scalingFactor * jumpDistance / cumulativeStrainTime;
|
||||
|
||||
if (currentObj.Angle != null && osuCurrent.Angle != null)
|
||||
{
|
||||
// Objects further back in time should count less for the nerf.
|
||||
if (Math.Abs(currentObj.Angle.Value - osuCurrent.Angle.Value) < 0.02)
|
||||
angleRepeatCount += Math.Max(1.0 - 0.1 * i, 0.0);
|
||||
}
|
||||
}
|
||||
|
||||
lastObj = currentObj;
|
||||
@ -77,6 +89,9 @@ namespace osu.Game.Rulesets.Osu.Difficulty.Evaluators
|
||||
if (hidden)
|
||||
result *= 1.0 + hidden_bonus;
|
||||
|
||||
// Nerf patterns with repeated angles.
|
||||
result *= min_angle_multiplier + (1.0 - min_angle_multiplier) / (angleRepeatCount + 1.0);
|
||||
|
||||
double sliderBonus = 0.0;
|
||||
|
||||
if (osuCurrent.BaseObject is Slider osuSlider)
|
||||
|
@ -26,7 +26,7 @@ namespace osu.Game.Rulesets.Osu.Difficulty.Skills
|
||||
hasHiddenMod = mods.Any(m => m is OsuModHidden);
|
||||
}
|
||||
|
||||
private double skillMultiplier => 0.05;
|
||||
private double skillMultiplier => 0.052;
|
||||
private double strainDecayBase => 0.15;
|
||||
|
||||
private double currentStrain;
|
||||
|
@ -358,7 +358,7 @@ namespace osu.Game.Rulesets.Osu.Edit
|
||||
{
|
||||
var mergeableObjects = selectedMergeableObjects;
|
||||
|
||||
if (mergeableObjects.Length < 2)
|
||||
if (!canMerge(mergeableObjects))
|
||||
return;
|
||||
|
||||
ChangeHandler?.BeginChange();
|
||||
@ -445,8 +445,13 @@ namespace osu.Game.Rulesets.Osu.Edit
|
||||
foreach (var item in base.GetContextMenuItemsForSelection(selection))
|
||||
yield return item;
|
||||
|
||||
if (selectedMergeableObjects.Length > 1)
|
||||
if (canMerge(selectedMergeableObjects))
|
||||
yield return new OsuMenuItem("Merge selection", MenuItemType.Destructive, mergeSelection);
|
||||
}
|
||||
|
||||
private bool canMerge(IReadOnlyList<OsuHitObject> objects) =>
|
||||
objects.Count > 1
|
||||
&& (objects.Any(h => h is Slider)
|
||||
|| objects.Zip(objects.Skip(1), (h1, h2) => Precision.DefinitelyBigger(Vector2.DistanceSquared(h1.Position, h2.Position), 1)).Any(x => x));
|
||||
}
|
||||
}
|
||||
|
@ -22,7 +22,7 @@ namespace osu.Game.Rulesets.Taiko.Tests.Editor
|
||||
public void Setup() => Schedule(() =>
|
||||
{
|
||||
BeatDivisor.Value = 8;
|
||||
Clock.Seek(0);
|
||||
EditorClock.Seek(0);
|
||||
|
||||
Child = new TestComposer { RelativeSizeAxes = Axes.Both };
|
||||
});
|
||||
|
@ -1,8 +1,6 @@
|
||||
// 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.
|
||||
|
||||
#nullable disable
|
||||
|
||||
using NUnit.Framework;
|
||||
using osu.Framework.Allocation;
|
||||
using osu.Framework.Bindables;
|
||||
@ -23,13 +21,13 @@ namespace osu.Game.Tests.Editing
|
||||
[HeadlessTest]
|
||||
public class TestSceneHitObjectComposerDistanceSnapping : EditorClockTestScene
|
||||
{
|
||||
private TestHitObjectComposer composer;
|
||||
private TestHitObjectComposer composer = null!;
|
||||
|
||||
[Cached(typeof(EditorBeatmap))]
|
||||
[Cached(typeof(IBeatSnapProvider))]
|
||||
private readonly EditorBeatmap editorBeatmap;
|
||||
|
||||
protected override Container<Drawable> Content { get; }
|
||||
protected override Container<Drawable> Content { get; } = new Container { RelativeSizeAxes = Axes.Both };
|
||||
|
||||
public TestSceneHitObjectComposerDistanceSnapping()
|
||||
{
|
||||
@ -40,15 +38,9 @@ namespace osu.Game.Tests.Editing
|
||||
{
|
||||
editorBeatmap = new EditorBeatmap(new OsuBeatmap
|
||||
{
|
||||
BeatmapInfo =
|
||||
{
|
||||
Ruleset = new OsuRuleset().RulesetInfo,
|
||||
},
|
||||
BeatmapInfo = { Ruleset = new OsuRuleset().RulesetInfo },
|
||||
}),
|
||||
Content = new Container
|
||||
{
|
||||
RelativeSizeAxes = Axes.Both,
|
||||
}
|
||||
Content
|
||||
},
|
||||
});
|
||||
}
|
||||
@ -205,7 +197,7 @@ namespace osu.Game.Tests.Editing
|
||||
assertSnappedDistance(400, 400);
|
||||
}
|
||||
|
||||
private void assertSnapDistance(float expectedDistance, HitObject hitObject = null)
|
||||
private void assertSnapDistance(float expectedDistance, HitObject? hitObject = null)
|
||||
=> AddAssert($"distance is {expectedDistance}", () => composer.GetBeatSnapDistanceAt(hitObject ?? new HitObject()), () => Is.EqualTo(expectedDistance));
|
||||
|
||||
private void assertDurationToDistance(double duration, float expectedDistance)
|
||||
|
@ -194,8 +194,16 @@ namespace osu.Game.Tests.Resources
|
||||
[HitResult.LargeTickHit] = 100,
|
||||
[HitResult.LargeTickMiss] = 50,
|
||||
[HitResult.SmallBonus] = 10,
|
||||
[HitResult.SmallBonus] = 50
|
||||
[HitResult.LargeBonus] = 50
|
||||
},
|
||||
MaximumStatistics = new Dictionary<HitResult, int>
|
||||
{
|
||||
[HitResult.Perfect] = 971,
|
||||
[HitResult.SmallTickHit] = 75,
|
||||
[HitResult.LargeTickHit] = 150,
|
||||
[HitResult.SmallBonus] = 10,
|
||||
[HitResult.LargeBonus] = 50,
|
||||
}
|
||||
};
|
||||
|
||||
private class TestModHardRock : ModHardRock
|
||||
|
@ -55,51 +55,51 @@ namespace osu.Game.Tests.Visual.Editing
|
||||
[Test]
|
||||
public void TestStopAtTrackEnd()
|
||||
{
|
||||
AddStep("reset clock", () => Clock.Seek(0));
|
||||
AddStep("reset clock", () => EditorClock.Seek(0));
|
||||
|
||||
AddStep("start clock", () => Clock.Start());
|
||||
AddAssert("clock running", () => Clock.IsRunning);
|
||||
AddStep("start clock", () => EditorClock.Start());
|
||||
AddAssert("clock running", () => EditorClock.IsRunning);
|
||||
|
||||
AddStep("seek near end", () => Clock.Seek(Clock.TrackLength - 250));
|
||||
AddUntilStep("clock stops", () => !Clock.IsRunning);
|
||||
AddStep("seek near end", () => EditorClock.Seek(EditorClock.TrackLength - 250));
|
||||
AddUntilStep("clock stops", () => !EditorClock.IsRunning);
|
||||
|
||||
AddUntilStep("clock stopped at end", () => Clock.CurrentTime, () => Is.EqualTo(Clock.TrackLength));
|
||||
AddUntilStep("clock stopped at end", () => EditorClock.CurrentTime - EditorClock.TotalAppliedOffset, () => Is.EqualTo(EditorClock.TrackLength));
|
||||
|
||||
AddStep("start clock again", () => Clock.Start());
|
||||
AddAssert("clock looped to start", () => Clock.IsRunning && Clock.CurrentTime < 500);
|
||||
AddStep("start clock again", () => EditorClock.Start());
|
||||
AddAssert("clock looped to start", () => EditorClock.IsRunning && EditorClock.CurrentTime < 500);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestWrapWhenStoppedAtTrackEnd()
|
||||
{
|
||||
AddStep("reset clock", () => Clock.Seek(0));
|
||||
AddStep("reset clock", () => EditorClock.Seek(0));
|
||||
|
||||
AddStep("stop clock", () => Clock.Stop());
|
||||
AddAssert("clock stopped", () => !Clock.IsRunning);
|
||||
AddStep("stop clock", () => EditorClock.Stop());
|
||||
AddAssert("clock stopped", () => !EditorClock.IsRunning);
|
||||
|
||||
AddStep("seek exactly to end", () => Clock.Seek(Clock.TrackLength));
|
||||
AddAssert("clock stopped at end", () => Clock.CurrentTime, () => Is.EqualTo(Clock.TrackLength));
|
||||
AddStep("seek exactly to end", () => EditorClock.Seek(EditorClock.TrackLength));
|
||||
AddAssert("clock stopped at end", () => EditorClock.CurrentTime, () => Is.EqualTo(EditorClock.TrackLength));
|
||||
|
||||
AddStep("start clock again", () => Clock.Start());
|
||||
AddAssert("clock looped to start", () => Clock.IsRunning && Clock.CurrentTime < 500);
|
||||
AddStep("start clock again", () => EditorClock.Start());
|
||||
AddAssert("clock looped to start", () => EditorClock.IsRunning && EditorClock.CurrentTime < 500);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestClampWhenSeekOutsideBeatmapBounds()
|
||||
{
|
||||
AddStep("stop clock", () => Clock.Stop());
|
||||
AddStep("stop clock", () => EditorClock.Stop());
|
||||
|
||||
AddStep("seek before start time", () => Clock.Seek(-1000));
|
||||
AddAssert("time is clamped to 0", () => Clock.CurrentTime, () => Is.EqualTo(0));
|
||||
AddStep("seek before start time", () => EditorClock.Seek(-1000));
|
||||
AddAssert("time is clamped to 0", () => EditorClock.CurrentTime, () => Is.EqualTo(0));
|
||||
|
||||
AddStep("seek beyond track length", () => Clock.Seek(Clock.TrackLength + 1000));
|
||||
AddAssert("time is clamped to track length", () => Clock.CurrentTime, () => Is.EqualTo(Clock.TrackLength));
|
||||
AddStep("seek beyond track length", () => EditorClock.Seek(EditorClock.TrackLength + 1000));
|
||||
AddAssert("time is clamped to track length", () => EditorClock.CurrentTime, () => Is.EqualTo(EditorClock.TrackLength));
|
||||
|
||||
AddStep("seek smoothly before start time", () => Clock.SeekSmoothlyTo(-1000));
|
||||
AddUntilStep("time is clamped to 0", () => Clock.CurrentTime, () => Is.EqualTo(0));
|
||||
AddStep("seek smoothly before start time", () => EditorClock.SeekSmoothlyTo(-1000));
|
||||
AddUntilStep("time is clamped to 0", () => EditorClock.CurrentTime, () => Is.EqualTo(0));
|
||||
|
||||
AddStep("seek smoothly beyond track length", () => Clock.SeekSmoothlyTo(Clock.TrackLength + 1000));
|
||||
AddUntilStep("time is clamped to track length", () => Clock.CurrentTime, () => Is.EqualTo(Clock.TrackLength));
|
||||
AddStep("seek smoothly beyond track length", () => EditorClock.SeekSmoothlyTo(EditorClock.TrackLength + 1000));
|
||||
AddUntilStep("time is clamped to track length", () => EditorClock.CurrentTime, () => Is.EqualTo(EditorClock.TrackLength));
|
||||
}
|
||||
|
||||
protected override void Dispose(bool isDisposing)
|
||||
|
@ -28,6 +28,11 @@ namespace osu.Game.Tests.Visual.Editing
|
||||
{
|
||||
base.LoadComplete();
|
||||
|
||||
Child = new TimingPointVisualiser(Beatmap.Value.Beatmap, 5000) { Clock = EditorClock };
|
||||
}
|
||||
|
||||
protected override Beatmap CreateEditorClockBeatmap()
|
||||
{
|
||||
var testBeatmap = new Beatmap
|
||||
{
|
||||
ControlPointInfo = new ControlPointInfo(),
|
||||
@ -45,9 +50,7 @@ namespace osu.Game.Tests.Visual.Editing
|
||||
testBeatmap.ControlPointInfo.Add(450, new TimingControlPoint { BeatLength = 100 });
|
||||
testBeatmap.ControlPointInfo.Add(500, new TimingControlPoint { BeatLength = 307.69230769230802 });
|
||||
|
||||
Beatmap.Value = CreateWorkingBeatmap(testBeatmap);
|
||||
|
||||
Child = new TimingPointVisualiser(testBeatmap, 5000) { Clock = Clock };
|
||||
return testBeatmap;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@ -59,17 +62,17 @@ namespace osu.Game.Tests.Visual.Editing
|
||||
reset();
|
||||
|
||||
// Forwards
|
||||
AddStep("Seek(0)", () => Clock.Seek(0));
|
||||
AddStep("Seek(0)", () => EditorClock.Seek(0));
|
||||
checkTime(0);
|
||||
AddStep("Seek(33)", () => Clock.Seek(33));
|
||||
AddStep("Seek(33)", () => EditorClock.Seek(33));
|
||||
checkTime(33);
|
||||
AddStep("Seek(89)", () => Clock.Seek(89));
|
||||
AddStep("Seek(89)", () => EditorClock.Seek(89));
|
||||
checkTime(89);
|
||||
|
||||
// Backwards
|
||||
AddStep("Seek(25)", () => Clock.Seek(25));
|
||||
AddStep("Seek(25)", () => EditorClock.Seek(25));
|
||||
checkTime(25);
|
||||
AddStep("Seek(0)", () => Clock.Seek(0));
|
||||
AddStep("Seek(0)", () => EditorClock.Seek(0));
|
||||
checkTime(0);
|
||||
}
|
||||
|
||||
@ -82,19 +85,19 @@ namespace osu.Game.Tests.Visual.Editing
|
||||
{
|
||||
reset();
|
||||
|
||||
AddStep("Seek(0), Snap", () => Clock.SeekSnapped(0));
|
||||
AddStep("Seek(0), Snap", () => EditorClock.SeekSnapped(0));
|
||||
checkTime(0);
|
||||
AddStep("Seek(50), Snap", () => Clock.SeekSnapped(50));
|
||||
AddStep("Seek(50), Snap", () => EditorClock.SeekSnapped(50));
|
||||
checkTime(50);
|
||||
AddStep("Seek(100), Snap", () => Clock.SeekSnapped(100));
|
||||
AddStep("Seek(100), Snap", () => EditorClock.SeekSnapped(100));
|
||||
checkTime(100);
|
||||
AddStep("Seek(175), Snap", () => Clock.SeekSnapped(175));
|
||||
AddStep("Seek(175), Snap", () => EditorClock.SeekSnapped(175));
|
||||
checkTime(175);
|
||||
AddStep("Seek(350), Snap", () => Clock.SeekSnapped(350));
|
||||
AddStep("Seek(350), Snap", () => EditorClock.SeekSnapped(350));
|
||||
checkTime(350);
|
||||
AddStep("Seek(400), Snap", () => Clock.SeekSnapped(400));
|
||||
AddStep("Seek(400), Snap", () => EditorClock.SeekSnapped(400));
|
||||
checkTime(400);
|
||||
AddStep("Seek(450), Snap", () => Clock.SeekSnapped(450));
|
||||
AddStep("Seek(450), Snap", () => EditorClock.SeekSnapped(450));
|
||||
checkTime(450);
|
||||
}
|
||||
|
||||
@ -107,17 +110,17 @@ namespace osu.Game.Tests.Visual.Editing
|
||||
{
|
||||
reset();
|
||||
|
||||
AddStep("Seek(24), Snap", () => Clock.SeekSnapped(24));
|
||||
AddStep("Seek(24), Snap", () => EditorClock.SeekSnapped(24));
|
||||
checkTime(0);
|
||||
AddStep("Seek(26), Snap", () => Clock.SeekSnapped(26));
|
||||
AddStep("Seek(26), Snap", () => EditorClock.SeekSnapped(26));
|
||||
checkTime(50);
|
||||
AddStep("Seek(150), Snap", () => Clock.SeekSnapped(150));
|
||||
AddStep("Seek(150), Snap", () => EditorClock.SeekSnapped(150));
|
||||
checkTime(100);
|
||||
AddStep("Seek(170), Snap", () => Clock.SeekSnapped(170));
|
||||
AddStep("Seek(170), Snap", () => EditorClock.SeekSnapped(170));
|
||||
checkTime(175);
|
||||
AddStep("Seek(274), Snap", () => Clock.SeekSnapped(274));
|
||||
AddStep("Seek(274), Snap", () => EditorClock.SeekSnapped(274));
|
||||
checkTime(175);
|
||||
AddStep("Seek(276), Snap", () => Clock.SeekSnapped(276));
|
||||
AddStep("Seek(276), Snap", () => EditorClock.SeekSnapped(276));
|
||||
checkTime(350);
|
||||
}
|
||||
|
||||
@ -129,15 +132,15 @@ namespace osu.Game.Tests.Visual.Editing
|
||||
{
|
||||
reset();
|
||||
|
||||
AddStep("SeekForward", () => Clock.SeekForward());
|
||||
AddStep("SeekForward", () => EditorClock.SeekForward());
|
||||
checkTime(50);
|
||||
AddStep("SeekForward", () => Clock.SeekForward());
|
||||
AddStep("SeekForward", () => EditorClock.SeekForward());
|
||||
checkTime(100);
|
||||
AddStep("SeekForward", () => Clock.SeekForward());
|
||||
AddStep("SeekForward", () => EditorClock.SeekForward());
|
||||
checkTime(200);
|
||||
AddStep("SeekForward", () => Clock.SeekForward());
|
||||
AddStep("SeekForward", () => EditorClock.SeekForward());
|
||||
checkTime(400);
|
||||
AddStep("SeekForward", () => Clock.SeekForward());
|
||||
AddStep("SeekForward", () => EditorClock.SeekForward());
|
||||
checkTime(450);
|
||||
}
|
||||
|
||||
@ -149,17 +152,17 @@ namespace osu.Game.Tests.Visual.Editing
|
||||
{
|
||||
reset();
|
||||
|
||||
AddStep("SeekForward, Snap", () => Clock.SeekForward(true));
|
||||
AddStep("SeekForward, Snap", () => EditorClock.SeekForward(true));
|
||||
checkTime(50);
|
||||
AddStep("SeekForward, Snap", () => Clock.SeekForward(true));
|
||||
AddStep("SeekForward, Snap", () => EditorClock.SeekForward(true));
|
||||
checkTime(100);
|
||||
AddStep("SeekForward, Snap", () => Clock.SeekForward(true));
|
||||
AddStep("SeekForward, Snap", () => EditorClock.SeekForward(true));
|
||||
checkTime(175);
|
||||
AddStep("SeekForward, Snap", () => Clock.SeekForward(true));
|
||||
AddStep("SeekForward, Snap", () => EditorClock.SeekForward(true));
|
||||
checkTime(350);
|
||||
AddStep("SeekForward, Snap", () => Clock.SeekForward(true));
|
||||
AddStep("SeekForward, Snap", () => EditorClock.SeekForward(true));
|
||||
checkTime(400);
|
||||
AddStep("SeekForward, Snap", () => Clock.SeekForward(true));
|
||||
AddStep("SeekForward, Snap", () => EditorClock.SeekForward(true));
|
||||
checkTime(450);
|
||||
}
|
||||
|
||||
@ -172,30 +175,30 @@ namespace osu.Game.Tests.Visual.Editing
|
||||
{
|
||||
reset();
|
||||
|
||||
AddStep("Seek(49)", () => Clock.Seek(49));
|
||||
AddStep("Seek(49)", () => EditorClock.Seek(49));
|
||||
checkTime(49);
|
||||
AddStep("SeekForward, Snap", () => Clock.SeekForward(true));
|
||||
AddStep("SeekForward, Snap", () => EditorClock.SeekForward(true));
|
||||
checkTime(50);
|
||||
AddStep("Seek(49.999)", () => Clock.Seek(49.999));
|
||||
AddStep("SeekForward, Snap", () => Clock.SeekForward(true));
|
||||
AddStep("Seek(49.999)", () => EditorClock.Seek(49.999));
|
||||
AddStep("SeekForward, Snap", () => EditorClock.SeekForward(true));
|
||||
checkTime(100);
|
||||
AddStep("Seek(99)", () => Clock.Seek(99));
|
||||
AddStep("SeekForward, Snap", () => Clock.SeekForward(true));
|
||||
AddStep("Seek(99)", () => EditorClock.Seek(99));
|
||||
AddStep("SeekForward, Snap", () => EditorClock.SeekForward(true));
|
||||
checkTime(100);
|
||||
AddStep("Seek(99.999)", () => Clock.Seek(99.999));
|
||||
AddStep("SeekForward, Snap", () => Clock.SeekForward(true));
|
||||
AddStep("Seek(99.999)", () => EditorClock.Seek(99.999));
|
||||
AddStep("SeekForward, Snap", () => EditorClock.SeekForward(true));
|
||||
checkTime(150);
|
||||
AddStep("Seek(174)", () => Clock.Seek(174));
|
||||
AddStep("SeekForward, Snap", () => Clock.SeekForward(true));
|
||||
AddStep("Seek(174)", () => EditorClock.Seek(174));
|
||||
AddStep("SeekForward, Snap", () => EditorClock.SeekForward(true));
|
||||
checkTime(175);
|
||||
AddStep("Seek(349)", () => Clock.Seek(349));
|
||||
AddStep("SeekForward, Snap", () => Clock.SeekForward(true));
|
||||
AddStep("Seek(349)", () => EditorClock.Seek(349));
|
||||
AddStep("SeekForward, Snap", () => EditorClock.SeekForward(true));
|
||||
checkTime(350);
|
||||
AddStep("Seek(399)", () => Clock.Seek(399));
|
||||
AddStep("SeekForward, Snap", () => Clock.SeekForward(true));
|
||||
AddStep("Seek(399)", () => EditorClock.Seek(399));
|
||||
AddStep("SeekForward, Snap", () => EditorClock.SeekForward(true));
|
||||
checkTime(400);
|
||||
AddStep("Seek(449)", () => Clock.Seek(449));
|
||||
AddStep("SeekForward, Snap", () => Clock.SeekForward(true));
|
||||
AddStep("Seek(449)", () => EditorClock.Seek(449));
|
||||
AddStep("SeekForward, Snap", () => EditorClock.SeekForward(true));
|
||||
checkTime(450);
|
||||
}
|
||||
|
||||
@ -207,17 +210,17 @@ namespace osu.Game.Tests.Visual.Editing
|
||||
{
|
||||
reset();
|
||||
|
||||
AddStep("Seek(450)", () => Clock.Seek(450));
|
||||
AddStep("Seek(450)", () => EditorClock.Seek(450));
|
||||
checkTime(450);
|
||||
AddStep("SeekBackward", () => Clock.SeekBackward());
|
||||
AddStep("SeekBackward", () => EditorClock.SeekBackward());
|
||||
checkTime(400);
|
||||
AddStep("SeekBackward", () => Clock.SeekBackward());
|
||||
AddStep("SeekBackward", () => EditorClock.SeekBackward());
|
||||
checkTime(350);
|
||||
AddStep("SeekBackward", () => Clock.SeekBackward());
|
||||
AddStep("SeekBackward", () => EditorClock.SeekBackward());
|
||||
checkTime(150);
|
||||
AddStep("SeekBackward", () => Clock.SeekBackward());
|
||||
AddStep("SeekBackward", () => EditorClock.SeekBackward());
|
||||
checkTime(50);
|
||||
AddStep("SeekBackward", () => Clock.SeekBackward());
|
||||
AddStep("SeekBackward", () => EditorClock.SeekBackward());
|
||||
checkTime(0);
|
||||
}
|
||||
|
||||
@ -229,19 +232,19 @@ namespace osu.Game.Tests.Visual.Editing
|
||||
{
|
||||
reset();
|
||||
|
||||
AddStep("Seek(450)", () => Clock.Seek(450));
|
||||
AddStep("Seek(450)", () => EditorClock.Seek(450));
|
||||
checkTime(450);
|
||||
AddStep("SeekBackward, Snap", () => Clock.SeekBackward(true));
|
||||
AddStep("SeekBackward, Snap", () => EditorClock.SeekBackward(true));
|
||||
checkTime(400);
|
||||
AddStep("SeekBackward, Snap", () => Clock.SeekBackward(true));
|
||||
AddStep("SeekBackward, Snap", () => EditorClock.SeekBackward(true));
|
||||
checkTime(350);
|
||||
AddStep("SeekBackward, Snap", () => Clock.SeekBackward(true));
|
||||
AddStep("SeekBackward, Snap", () => EditorClock.SeekBackward(true));
|
||||
checkTime(175);
|
||||
AddStep("SeekBackward, Snap", () => Clock.SeekBackward(true));
|
||||
AddStep("SeekBackward, Snap", () => EditorClock.SeekBackward(true));
|
||||
checkTime(100);
|
||||
AddStep("SeekBackward, Snap", () => Clock.SeekBackward(true));
|
||||
AddStep("SeekBackward, Snap", () => EditorClock.SeekBackward(true));
|
||||
checkTime(50);
|
||||
AddStep("SeekBackward, Snap", () => Clock.SeekBackward(true));
|
||||
AddStep("SeekBackward, Snap", () => EditorClock.SeekBackward(true));
|
||||
checkTime(0);
|
||||
}
|
||||
|
||||
@ -254,18 +257,18 @@ namespace osu.Game.Tests.Visual.Editing
|
||||
{
|
||||
reset();
|
||||
|
||||
AddStep("Seek(451)", () => Clock.Seek(451));
|
||||
AddStep("Seek(451)", () => EditorClock.Seek(451));
|
||||
checkTime(451);
|
||||
AddStep("SeekBackward, Snap", () => Clock.SeekBackward(true));
|
||||
AddStep("SeekBackward, Snap", () => EditorClock.SeekBackward(true));
|
||||
checkTime(450);
|
||||
AddStep("Seek(450.999)", () => Clock.Seek(450.999));
|
||||
AddStep("SeekBackward, Snap", () => Clock.SeekBackward(true));
|
||||
AddStep("Seek(450.999)", () => EditorClock.Seek(450.999));
|
||||
AddStep("SeekBackward, Snap", () => EditorClock.SeekBackward(true));
|
||||
checkTime(450);
|
||||
AddStep("Seek(401)", () => Clock.Seek(401));
|
||||
AddStep("SeekBackward, Snap", () => Clock.SeekBackward(true));
|
||||
AddStep("Seek(401)", () => EditorClock.Seek(401));
|
||||
AddStep("SeekBackward, Snap", () => EditorClock.SeekBackward(true));
|
||||
checkTime(400);
|
||||
AddStep("Seek(401.999)", () => Clock.Seek(401.999));
|
||||
AddStep("SeekBackward, Snap", () => Clock.SeekBackward(true));
|
||||
AddStep("Seek(401.999)", () => EditorClock.Seek(401.999));
|
||||
AddStep("SeekBackward, Snap", () => EditorClock.SeekBackward(true));
|
||||
checkTime(400);
|
||||
}
|
||||
|
||||
@ -279,37 +282,37 @@ namespace osu.Game.Tests.Visual.Editing
|
||||
|
||||
double lastTime = 0;
|
||||
|
||||
AddStep("Seek(0)", () => Clock.Seek(0));
|
||||
AddStep("Seek(0)", () => EditorClock.Seek(0));
|
||||
checkTime(0);
|
||||
|
||||
for (int i = 0; i < 9; i++)
|
||||
{
|
||||
AddStep("SeekForward, Snap", () =>
|
||||
{
|
||||
lastTime = Clock.CurrentTime;
|
||||
Clock.SeekForward(true);
|
||||
lastTime = EditorClock.CurrentTime;
|
||||
EditorClock.SeekForward(true);
|
||||
});
|
||||
AddAssert("Time > lastTime", () => Clock.CurrentTime > lastTime);
|
||||
AddAssert("Time > lastTime", () => EditorClock.CurrentTime > lastTime);
|
||||
}
|
||||
|
||||
for (int i = 0; i < 9; i++)
|
||||
{
|
||||
AddStep("SeekBackward, Snap", () =>
|
||||
{
|
||||
lastTime = Clock.CurrentTime;
|
||||
Clock.SeekBackward(true);
|
||||
lastTime = EditorClock.CurrentTime;
|
||||
EditorClock.SeekBackward(true);
|
||||
});
|
||||
AddAssert("Time < lastTime", () => Clock.CurrentTime < lastTime);
|
||||
AddAssert("Time < lastTime", () => EditorClock.CurrentTime < lastTime);
|
||||
}
|
||||
|
||||
checkTime(0);
|
||||
}
|
||||
|
||||
private void checkTime(double expectedTime) => AddAssert($"Current time is {expectedTime}", () => Clock.CurrentTime, () => Is.EqualTo(expectedTime));
|
||||
private void checkTime(double expectedTime) => AddUntilStep($"Current time is {expectedTime}", () => EditorClock.CurrentTime, () => Is.EqualTo(expectedTime));
|
||||
|
||||
private void reset()
|
||||
{
|
||||
AddStep("Reset", () => Clock.Seek(0));
|
||||
AddStep("Reset", () => EditorClock.Seek(0));
|
||||
}
|
||||
|
||||
private class TimingPointVisualiser : CompositeDrawable
|
||||
|
@ -113,7 +113,7 @@ namespace osu.Game.Tests.Visual.Editing
|
||||
.TriggerClick();
|
||||
});
|
||||
|
||||
AddUntilStep("wait for track playing", () => Clock.IsRunning);
|
||||
AddUntilStep("wait for track playing", () => EditorClock.IsRunning);
|
||||
|
||||
AddStep("click reset button", () =>
|
||||
{
|
||||
@ -122,7 +122,7 @@ namespace osu.Game.Tests.Visual.Editing
|
||||
.TriggerClick();
|
||||
});
|
||||
|
||||
AddUntilStep("wait for track stopped", () => !Clock.IsRunning);
|
||||
AddUntilStep("wait for track stopped", () => !EditorClock.IsRunning);
|
||||
}
|
||||
|
||||
protected override void Dispose(bool isDisposing)
|
||||
|
@ -17,7 +17,7 @@ namespace osu.Game.Tests.Visual.Editing
|
||||
protected override void LoadComplete()
|
||||
{
|
||||
base.LoadComplete();
|
||||
Clock.Seek(10000);
|
||||
EditorClock.Seek(10000);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -17,8 +17,6 @@ namespace osu.Game.Tests.Visual.Editing
|
||||
{
|
||||
double initialVisibleRange = 0;
|
||||
|
||||
AddUntilStep("wait for load", () => MusicController.TrackLoaded);
|
||||
|
||||
AddStep("reset zoom", () => TimelineArea.Timeline.Zoom = 100);
|
||||
AddStep("get initial range", () => initialVisibleRange = TimelineArea.Timeline.VisibleRange);
|
||||
|
||||
@ -36,8 +34,6 @@ namespace osu.Game.Tests.Visual.Editing
|
||||
{
|
||||
double initialVisibleRange = 0;
|
||||
|
||||
AddUntilStep("wait for load", () => MusicController.TrackLoaded);
|
||||
|
||||
AddStep("reset timeline size", () => TimelineArea.Timeline.Width = 1);
|
||||
AddStep("get initial range", () => initialVisibleRange = TimelineArea.Timeline.VisibleRange);
|
||||
|
||||
|
@ -53,7 +53,7 @@ namespace osu.Game.Tests.Visual.Editing
|
||||
[SetUpSteps]
|
||||
public void SetUpSteps()
|
||||
{
|
||||
AddStep("Stop clock", () => Clock.Stop());
|
||||
AddStep("Stop clock", () => EditorClock.Stop());
|
||||
|
||||
AddUntilStep("wait for rows to load", () => Child.ChildrenOfType<EffectRowAttribute>().Any());
|
||||
}
|
||||
@ -68,10 +68,10 @@ namespace osu.Game.Tests.Visual.Editing
|
||||
});
|
||||
|
||||
AddUntilStep("Selection changed", () => timingScreen.SelectedGroup.Value.Time == 54670);
|
||||
AddUntilStep("Ensure seeked to correct time", () => Clock.CurrentTimeAccurate == 54670);
|
||||
AddUntilStep("Ensure seeked to correct time", () => EditorClock.CurrentTimeAccurate == 54670);
|
||||
|
||||
AddStep("Seek to just before next point", () => Clock.Seek(69000));
|
||||
AddStep("Start clock", () => Clock.Start());
|
||||
AddStep("Seek to just before next point", () => EditorClock.Seek(69000));
|
||||
AddStep("Start clock", () => EditorClock.Start());
|
||||
|
||||
AddUntilStep("Selection changed", () => timingScreen.SelectedGroup.Value.Time == 69670);
|
||||
}
|
||||
@ -86,9 +86,9 @@ namespace osu.Game.Tests.Visual.Editing
|
||||
});
|
||||
|
||||
AddUntilStep("Selection changed", () => timingScreen.SelectedGroup.Value.Time == 54670);
|
||||
AddUntilStep("Ensure seeked to correct time", () => Clock.CurrentTimeAccurate == 54670);
|
||||
AddUntilStep("Ensure seeked to correct time", () => EditorClock.CurrentTimeAccurate == 54670);
|
||||
|
||||
AddStep("Seek to later", () => Clock.Seek(80000));
|
||||
AddStep("Seek to later", () => EditorClock.Seek(80000));
|
||||
AddUntilStep("Selection changed", () => timingScreen.SelectedGroup.Value.Time == 69670);
|
||||
}
|
||||
|
||||
|
@ -9,12 +9,14 @@ using osu.Framework.Bindables;
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Framework.Graphics.Containers;
|
||||
using osu.Framework.Graphics.Shapes;
|
||||
using osu.Framework.Testing;
|
||||
using osu.Game.Beatmaps;
|
||||
using osu.Game.Graphics.Cursor;
|
||||
using osu.Game.Graphics.UserInterface;
|
||||
using osu.Game.Rulesets.Edit;
|
||||
using osu.Game.Screens.Edit;
|
||||
using osu.Game.Screens.Edit.Compose.Components.Timeline;
|
||||
using osu.Game.Storyboards;
|
||||
using osuTK;
|
||||
using osuTK.Graphics;
|
||||
|
||||
@ -28,10 +30,14 @@ namespace osu.Game.Tests.Visual.Editing
|
||||
|
||||
protected EditorBeatmap EditorBeatmap { get; private set; }
|
||||
|
||||
[BackgroundDependencyLoader]
|
||||
private void load(AudioManager audio)
|
||||
[Resolved]
|
||||
private AudioManager audio { get; set; }
|
||||
|
||||
protected override WorkingBeatmap CreateWorkingBeatmap(IBeatmap beatmap, Storyboard storyboard = null) => new WaveformTestBeatmap(audio);
|
||||
|
||||
protected override void LoadComplete()
|
||||
{
|
||||
Beatmap.Value = new WaveformTestBeatmap(audio);
|
||||
base.LoadComplete();
|
||||
|
||||
var playable = Beatmap.Value.GetPlayableBeatmap(Beatmap.Value.BeatmapInfo.Ruleset);
|
||||
EditorBeatmap = new EditorBeatmap(playable);
|
||||
@ -68,11 +74,11 @@ namespace osu.Game.Tests.Visual.Editing
|
||||
});
|
||||
}
|
||||
|
||||
protected override void LoadComplete()
|
||||
[SetUpSteps]
|
||||
public void SetUpSteps()
|
||||
{
|
||||
base.LoadComplete();
|
||||
|
||||
Clock.Seek(2500);
|
||||
AddUntilStep("wait for track loaded", () => MusicController.TrackLoaded);
|
||||
AddStep("seek forward", () => EditorClock.Seek(2500));
|
||||
}
|
||||
|
||||
public abstract Drawable CreateTestComponent();
|
||||
|
@ -37,7 +37,7 @@ namespace osu.Game.Tests.Visual.Gameplay
|
||||
{
|
||||
Dependencies.Cache(rulesets = new RealmRulesetStore(Realm));
|
||||
Dependencies.Cache(beatmaps = new BeatmapManager(LocalStorage, Realm, null, audio, Resources, host, Beatmap.Default));
|
||||
Dependencies.Cache(new ScoreManager(rulesets, () => beatmaps, LocalStorage, Realm, Scheduler, API));
|
||||
Dependencies.Cache(new ScoreManager(rulesets, () => beatmaps, LocalStorage, Realm, API));
|
||||
Dependencies.Cache(Realm);
|
||||
}
|
||||
|
||||
|
@ -61,6 +61,7 @@ namespace osu.Game.Tests.Visual.Playlists
|
||||
userScore = TestResources.CreateTestScoreInfo();
|
||||
userScore.TotalScore = 0;
|
||||
userScore.Statistics = new Dictionary<HitResult, int>();
|
||||
userScore.MaximumStatistics = new Dictionary<HitResult, int>();
|
||||
|
||||
bindHandler();
|
||||
|
||||
|
@ -47,7 +47,7 @@ namespace osu.Game.Tests.Visual.SongSelect
|
||||
|
||||
dependencies.Cache(rulesetStore = new RealmRulesetStore(Realm));
|
||||
dependencies.Cache(beatmapManager = new BeatmapManager(LocalStorage, Realm, null, dependencies.Get<AudioManager>(), Resources, dependencies.Get<GameHost>(), Beatmap.Default));
|
||||
dependencies.Cache(scoreManager = new ScoreManager(rulesetStore, () => beatmapManager, LocalStorage, Realm, Scheduler, API));
|
||||
dependencies.Cache(scoreManager = new ScoreManager(rulesetStore, () => beatmapManager, LocalStorage, Realm, API));
|
||||
Dependencies.Cache(Realm);
|
||||
|
||||
return dependencies;
|
||||
|
@ -32,7 +32,7 @@ namespace osu.Game.Tests.Visual.SongSelect
|
||||
{
|
||||
Dependencies.Cache(rulesets = new RealmRulesetStore(Realm));
|
||||
Dependencies.Cache(beatmapManager = new BeatmapManager(LocalStorage, Realm, null, audio, Resources, host, Beatmap.Default));
|
||||
Dependencies.Cache(scoreManager = new ScoreManager(rulesets, () => beatmapManager, LocalStorage, Realm, Scheduler, API));
|
||||
Dependencies.Cache(scoreManager = new ScoreManager(rulesets, () => beatmapManager, LocalStorage, Realm, API));
|
||||
Dependencies.Cache(Realm);
|
||||
|
||||
beatmapManager.Import(TestResources.GetQuickTestBeatmapForImport()).WaitSafely();
|
||||
|
@ -73,7 +73,7 @@ namespace osu.Game.Tests.Visual.UserInterface
|
||||
|
||||
dependencies.Cache(new RealmRulesetStore(Realm));
|
||||
dependencies.Cache(beatmapManager = new BeatmapManager(LocalStorage, Realm, null, dependencies.Get<AudioManager>(), Resources, dependencies.Get<GameHost>(), Beatmap.Default));
|
||||
dependencies.Cache(scoreManager = new ScoreManager(dependencies.Get<RulesetStore>(), () => beatmapManager, LocalStorage, Realm, Scheduler, API));
|
||||
dependencies.Cache(scoreManager = new ScoreManager(dependencies.Get<RulesetStore>(), () => beatmapManager, LocalStorage, Realm, API));
|
||||
Dependencies.Cache(Realm);
|
||||
|
||||
return dependencies;
|
||||
|
@ -1,8 +1,6 @@
|
||||
// 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.
|
||||
|
||||
#nullable disable
|
||||
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using NUnit.Framework;
|
||||
@ -19,11 +17,11 @@ namespace osu.Game.Tests.Visual.UserInterface
|
||||
[TestFixture]
|
||||
public class TestSceneNotificationOverlay : OsuTestScene
|
||||
{
|
||||
private NotificationOverlay notificationOverlay;
|
||||
private NotificationOverlay notificationOverlay = null!;
|
||||
|
||||
private readonly List<ProgressNotification> progressingNotifications = new List<ProgressNotification>();
|
||||
|
||||
private SpriteText displayedCount;
|
||||
private SpriteText displayedCount = null!;
|
||||
|
||||
[SetUp]
|
||||
public void SetUp() => Schedule(() =>
|
||||
@ -46,7 +44,7 @@ namespace osu.Game.Tests.Visual.UserInterface
|
||||
[Test]
|
||||
public void TestCompleteProgress()
|
||||
{
|
||||
ProgressNotification notification = null;
|
||||
ProgressNotification notification = null!;
|
||||
AddStep("add progress notification", () =>
|
||||
{
|
||||
notification = new ProgressNotification
|
||||
@ -64,7 +62,7 @@ namespace osu.Game.Tests.Visual.UserInterface
|
||||
[Test]
|
||||
public void TestCancelProgress()
|
||||
{
|
||||
ProgressNotification notification = null;
|
||||
ProgressNotification notification = null!;
|
||||
AddStep("add progress notification", () =>
|
||||
{
|
||||
notification = new ProgressNotification
|
||||
|
@ -124,7 +124,7 @@ namespace osu.Game.Beatmaps
|
||||
finalClockSource.ProcessFrame();
|
||||
}
|
||||
|
||||
private double totalAppliedOffset
|
||||
public double TotalAppliedOffset
|
||||
{
|
||||
get
|
||||
{
|
||||
@ -169,7 +169,7 @@ namespace osu.Game.Beatmaps
|
||||
|
||||
public bool Seek(double position)
|
||||
{
|
||||
bool success = decoupledClock.Seek(position - totalAppliedOffset);
|
||||
bool success = decoupledClock.Seek(position - TotalAppliedOffset);
|
||||
finalClockSource.ProcessFrame();
|
||||
|
||||
return success;
|
||||
|
@ -1,8 +1,6 @@
|
||||
// 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.
|
||||
|
||||
#nullable disable
|
||||
|
||||
using osu.Game.Overlays.Notifications;
|
||||
|
||||
namespace osu.Game.Database
|
||||
|
@ -77,6 +77,12 @@ namespace osu.Game.Online.API.Requests.Responses
|
||||
[JsonProperty("maximum_statistics")]
|
||||
public Dictionary<HitResult, int> MaximumStatistics { get; set; } = new Dictionary<HitResult, int>();
|
||||
|
||||
/// <summary>
|
||||
/// Used to preserve the total score for legacy scores.
|
||||
/// </summary>
|
||||
[JsonProperty("legacy_total_score")]
|
||||
public int? LegacyTotalScore { get; set; }
|
||||
|
||||
#region osu-web API additions (not stored to database).
|
||||
|
||||
[JsonProperty("id")]
|
||||
|
@ -185,6 +185,12 @@ namespace osu.Game
|
||||
|
||||
private RealmAccess realm;
|
||||
|
||||
/// <summary>
|
||||
/// For now, this is used as a source specifically for beat synced components.
|
||||
/// Going forward, it could potentially be used as the single source-of-truth for beatmap timing.
|
||||
/// </summary>
|
||||
private readonly FramedBeatmapClock beatmapClock = new FramedBeatmapClock(true);
|
||||
|
||||
protected override Container<Drawable> Content => content;
|
||||
|
||||
private Container content;
|
||||
@ -273,7 +279,7 @@ namespace osu.Game
|
||||
dependencies.Cache(difficultyCache = new BeatmapDifficultyCache());
|
||||
|
||||
// ordering is important here to ensure foreign keys rules are not broken in ModelStore.Cleanup()
|
||||
dependencies.Cache(ScoreManager = new ScoreManager(RulesetStore, () => BeatmapManager, Storage, realm, Scheduler, API, difficultyCache, LocalConfig));
|
||||
dependencies.Cache(ScoreManager = new ScoreManager(RulesetStore, () => BeatmapManager, Storage, realm, API, LocalConfig));
|
||||
|
||||
dependencies.Cache(BeatmapManager = new BeatmapManager(Storage, realm, API, Audio, Resources, Host, defaultBeatmap, difficultyCache, performOnlineLookups: true));
|
||||
|
||||
@ -368,10 +374,24 @@ namespace osu.Game
|
||||
AddInternal(MusicController = new MusicController());
|
||||
dependencies.CacheAs(MusicController);
|
||||
|
||||
MusicController.TrackChanged += onTrackChanged;
|
||||
AddInternal(beatmapClock);
|
||||
|
||||
Ruleset.BindValueChanged(onRulesetChanged);
|
||||
Beatmap.BindValueChanged(onBeatmapChanged);
|
||||
}
|
||||
|
||||
private void onTrackChanged(WorkingBeatmap beatmap, TrackChangeDirection direction)
|
||||
{
|
||||
// FramedBeatmapClock uses a decoupled clock internally which will mutate the source if it is an `IAdjustableClock`.
|
||||
// We don't want this for now, as the intention of beatmapClock is to be a read-only source for beat sync components.
|
||||
//
|
||||
// Encapsulating in a FramedClock will avoid any mutations.
|
||||
var framedClock = new FramedClock(beatmap.Track);
|
||||
|
||||
beatmapClock.ChangeSource(framedClock);
|
||||
}
|
||||
|
||||
protected virtual void InitialiseFonts()
|
||||
{
|
||||
AddFont(Resources, @"Fonts/osuFont");
|
||||
@ -587,7 +607,7 @@ namespace osu.Game
|
||||
}
|
||||
|
||||
ControlPointInfo IBeatSyncProvider.ControlPoints => Beatmap.Value.BeatmapLoaded ? Beatmap.Value.Beatmap.ControlPointInfo : null;
|
||||
IClock IBeatSyncProvider.Clock => Beatmap.Value.TrackLoaded ? Beatmap.Value.Track : (IClock)null;
|
||||
IClock IBeatSyncProvider.Clock => beatmapClock;
|
||||
ChannelAmplitudes IHasAmplitudes.CurrentAmplitudes => Beatmap.Value.TrackLoaded ? Beatmap.Value.Track.CurrentAmplitudes : ChannelAmplitudes.Empty;
|
||||
}
|
||||
}
|
||||
|
@ -6,10 +6,8 @@
|
||||
using System.Diagnostics;
|
||||
using System.Linq;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using osu.Framework.Allocation;
|
||||
using osu.Framework.Bindables;
|
||||
using osu.Framework.Extensions;
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Framework.Graphics.Containers;
|
||||
using osu.Framework.Graphics.Shapes;
|
||||
@ -87,27 +85,19 @@ namespace osu.Game.Overlays.BeatmapSet.Scores
|
||||
MD5Hash = apiBeatmap.MD5Hash
|
||||
};
|
||||
|
||||
scoreManager.OrderByTotalScoreAsync(value.Scores.Select(s => s.ToScoreInfo(rulesets, beatmapInfo)).ToArray(), loadCancellationSource.Token)
|
||||
.ContinueWith(task => Schedule(() =>
|
||||
{
|
||||
if (loadCancellationSource.IsCancellationRequested)
|
||||
return;
|
||||
var scores = scoreManager.OrderByTotalScore(value.Scores.Select(s => s.ToScoreInfo(rulesets, beatmapInfo))).ToArray();
|
||||
var topScore = scores.First();
|
||||
|
||||
var scores = task.GetResultSafely();
|
||||
scoreTable.DisplayScores(scores, apiBeatmap.Status.GrantsPerformancePoints());
|
||||
scoreTable.Show();
|
||||
|
||||
var topScore = scores.First();
|
||||
var userScore = value.UserScore;
|
||||
var userScoreInfo = userScore?.Score.ToScoreInfo(rulesets, beatmapInfo);
|
||||
|
||||
scoreTable.DisplayScores(scores, apiBeatmap.Status.GrantsPerformancePoints());
|
||||
scoreTable.Show();
|
||||
topScoresContainer.Add(new DrawableTopScore(topScore));
|
||||
|
||||
var userScore = value.UserScore;
|
||||
var userScoreInfo = userScore?.Score.ToScoreInfo(rulesets, beatmapInfo);
|
||||
|
||||
topScoresContainer.Add(new DrawableTopScore(topScore));
|
||||
|
||||
if (userScoreInfo != null && userScoreInfo.OnlineID != topScore.OnlineID)
|
||||
topScoresContainer.Add(new DrawableTopScore(userScoreInfo, userScore.Position));
|
||||
}), TaskContinuationOptions.OnlyOnRanToCompletion);
|
||||
if (userScoreInfo != null && userScoreInfo.OnlineID != topScore.OnlineID)
|
||||
topScoresContainer.Add(new DrawableTopScore(userScoreInfo, userScore.Position));
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -64,14 +64,8 @@ namespace osu.Game.Overlays
|
||||
RelativeSizeAxes = Axes.X,
|
||||
Children = new[]
|
||||
{
|
||||
new NotificationSection(AccountsStrings.NotificationsTitle, "Clear All")
|
||||
{
|
||||
AcceptTypes = new[] { typeof(SimpleNotification) }
|
||||
},
|
||||
new NotificationSection(@"Running Tasks", @"Cancel All")
|
||||
{
|
||||
AcceptTypes = new[] { typeof(ProgressNotification) }
|
||||
}
|
||||
new NotificationSection(AccountsStrings.NotificationsTitle, new[] { typeof(SimpleNotification) }, "Clear All"),
|
||||
new NotificationSection(@"Running Tasks", new[] { typeof(ProgressNotification) }, @"Cancel All"),
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -133,7 +127,7 @@ namespace osu.Game.Overlays
|
||||
|
||||
var ourType = notification.GetType();
|
||||
|
||||
var section = sections.Children.FirstOrDefault(s => s.AcceptTypes.Any(accept => accept.IsAssignableFrom(ourType)));
|
||||
var section = sections.Children.FirstOrDefault(s => s.AcceptedNotificationTypes.Any(accept => accept.IsAssignableFrom(ourType)));
|
||||
section?.Add(notification, notification.DisplayOnTop ? -runningDepth : runningDepth);
|
||||
|
||||
if (notification.IsImportant)
|
||||
|
@ -1,8 +1,6 @@
|
||||
// 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.
|
||||
|
||||
#nullable disable
|
||||
|
||||
using System;
|
||||
using osu.Framework.Allocation;
|
||||
using osu.Framework.Extensions.Color4Extensions;
|
||||
@ -26,7 +24,7 @@ namespace osu.Game.Overlays.Notifications
|
||||
/// <summary>
|
||||
/// User requested close.
|
||||
/// </summary>
|
||||
public event Action Closed;
|
||||
public event Action? Closed;
|
||||
|
||||
public abstract LocalisableString Text { get; set; }
|
||||
|
||||
@ -38,7 +36,7 @@ namespace osu.Game.Overlays.Notifications
|
||||
/// <summary>
|
||||
/// Run on user activating the notification. Return true to close.
|
||||
/// </summary>
|
||||
public Func<bool> Activated;
|
||||
public Func<bool>? Activated;
|
||||
|
||||
/// <summary>
|
||||
/// Should we show at the top of our section on display?
|
||||
@ -212,7 +210,7 @@ namespace osu.Game.Overlays.Notifications
|
||||
public class NotificationLight : Container
|
||||
{
|
||||
private bool pulsate;
|
||||
private Container pulsateLayer;
|
||||
private Container pulsateLayer = null!;
|
||||
|
||||
public bool Pulsate
|
||||
{
|
||||
|
@ -1,8 +1,6 @@
|
||||
// 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.
|
||||
|
||||
#nullable disable
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
@ -21,9 +19,9 @@ namespace osu.Game.Overlays.Notifications
|
||||
{
|
||||
public class NotificationSection : AlwaysUpdateFillFlowContainer<Drawable>
|
||||
{
|
||||
private OsuSpriteText countDrawable;
|
||||
private OsuSpriteText countDrawable = null!;
|
||||
|
||||
private FlowContainer<Notification> notifications;
|
||||
private FlowContainer<Notification> notifications = null!;
|
||||
|
||||
public int DisplayedCount => notifications.Count(n => !n.WasClosed);
|
||||
public int UnreadCount => notifications.Count(n => !n.WasClosed && !n.Read);
|
||||
@ -33,14 +31,16 @@ namespace osu.Game.Overlays.Notifications
|
||||
notifications.Insert((int)position, notification);
|
||||
}
|
||||
|
||||
public IEnumerable<Type> AcceptTypes;
|
||||
public IEnumerable<Type> AcceptedNotificationTypes { get; }
|
||||
|
||||
private readonly string clearButtonText;
|
||||
|
||||
private readonly LocalisableString titleText;
|
||||
|
||||
public NotificationSection(LocalisableString title, string clearButtonText)
|
||||
public NotificationSection(LocalisableString title, IEnumerable<Type> acceptedNotificationTypes, string clearButtonText)
|
||||
{
|
||||
AcceptedNotificationTypes = acceptedNotificationTypes.ToArray();
|
||||
|
||||
this.clearButtonText = clearButtonText.ToUpperInvariant();
|
||||
titleText = title;
|
||||
}
|
||||
@ -159,7 +159,7 @@ namespace osu.Game.Overlays.Notifications
|
||||
|
||||
public void MarkAllRead()
|
||||
{
|
||||
notifications?.Children.ForEach(n => n.Read = true);
|
||||
notifications.Children.ForEach(n => n.Read = true);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1,8 +1,6 @@
|
||||
// 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.
|
||||
|
||||
#nullable disable
|
||||
|
||||
using System;
|
||||
using System.Threading;
|
||||
using osu.Framework.Allocation;
|
||||
@ -25,6 +23,18 @@ namespace osu.Game.Overlays.Notifications
|
||||
{
|
||||
private const float loading_spinner_size = 22;
|
||||
|
||||
public Func<bool>? CancelRequested { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// The function to post completion notifications back to.
|
||||
/// </summary>
|
||||
public Action<Notification>? CompletionTarget { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// An action to complete when the completion notification is clicked. Return true to close.
|
||||
/// </summary>
|
||||
public Func<bool>? CompletionClickAction { get; set; }
|
||||
|
||||
private LocalisableString text;
|
||||
|
||||
public override LocalisableString Text
|
||||
@ -142,7 +152,7 @@ namespace osu.Game.Overlays.Notifications
|
||||
Text = CompletionText
|
||||
};
|
||||
|
||||
protected virtual void Completed()
|
||||
protected void Completed()
|
||||
{
|
||||
CompletionTarget?.Invoke(CreateCompletionNotification());
|
||||
base.Close();
|
||||
@ -155,8 +165,8 @@ namespace osu.Game.Overlays.Notifications
|
||||
private Color4 colourActive;
|
||||
private Color4 colourCancelled;
|
||||
|
||||
private Box iconBackground;
|
||||
private LoadingSpinner loadingSpinner;
|
||||
private Box iconBackground = null!;
|
||||
private LoadingSpinner loadingSpinner = null!;
|
||||
|
||||
private readonly TextFlowContainer textDrawable;
|
||||
|
||||
@ -222,18 +232,6 @@ namespace osu.Game.Overlays.Notifications
|
||||
}
|
||||
}
|
||||
|
||||
public Func<bool> CancelRequested { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// The function to post completion notifications back to.
|
||||
/// </summary>
|
||||
public Action<Notification> CompletionTarget { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// An action to complete when the completion notification is clicked. Return true to close.
|
||||
/// </summary>
|
||||
public Func<bool> CompletionClickAction;
|
||||
|
||||
private class ProgressBar : Container
|
||||
{
|
||||
private readonly Box box;
|
||||
|
@ -1,8 +1,6 @@
|
||||
// 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.
|
||||
|
||||
#nullable disable
|
||||
|
||||
using osu.Framework.Allocation;
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Framework.Graphics.Colour;
|
||||
|
@ -3,6 +3,7 @@
|
||||
|
||||
#nullable disable
|
||||
|
||||
using System.Diagnostics;
|
||||
using osu.Framework.Bindables;
|
||||
using osu.Framework.Extensions.Color4Extensions;
|
||||
using osu.Framework.Graphics;
|
||||
@ -37,6 +38,10 @@ namespace osu.Game.Overlays.Profile
|
||||
// todo: pending implementation.
|
||||
// TabControl.AddItem(LayoutStrings.HeaderUsersModding);
|
||||
|
||||
// Haphazardly guaranteed by OverlayHeader constructor (see CreateBackground / CreateContent).
|
||||
Debug.Assert(centreHeaderContainer != null);
|
||||
Debug.Assert(detailHeaderContainer != null);
|
||||
|
||||
centreHeaderContainer.DetailsVisible.BindValueChanged(visible => detailHeaderContainer.Expanded = visible.NewValue, true);
|
||||
}
|
||||
|
||||
|
@ -11,10 +11,7 @@ using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using JetBrains.Annotations;
|
||||
using osu.Framework.Bindables;
|
||||
using osu.Framework.Extensions;
|
||||
using osu.Framework.Logging;
|
||||
using osu.Framework.Platform;
|
||||
using osu.Framework.Threading;
|
||||
using osu.Game.Beatmaps;
|
||||
using osu.Game.Configuration;
|
||||
using osu.Game.Database;
|
||||
@ -28,17 +25,12 @@ namespace osu.Game.Scoring
|
||||
{
|
||||
public class ScoreManager : ModelManager<ScoreInfo>, IModelImporter<ScoreInfo>
|
||||
{
|
||||
private readonly Scheduler scheduler;
|
||||
private readonly BeatmapDifficultyCache difficultyCache;
|
||||
private readonly OsuConfigManager configManager;
|
||||
private readonly ScoreImporter scoreImporter;
|
||||
|
||||
public ScoreManager(RulesetStore rulesets, Func<BeatmapManager> beatmaps, Storage storage, RealmAccess realm, Scheduler scheduler, IAPIProvider api,
|
||||
BeatmapDifficultyCache difficultyCache = null, OsuConfigManager configManager = null)
|
||||
public ScoreManager(RulesetStore rulesets, Func<BeatmapManager> beatmaps, Storage storage, RealmAccess realm, IAPIProvider api, OsuConfigManager configManager = null)
|
||||
: base(storage, realm)
|
||||
{
|
||||
this.scheduler = scheduler;
|
||||
this.difficultyCache = difficultyCache;
|
||||
this.configManager = configManager;
|
||||
|
||||
scoreImporter = new ScoreImporter(rulesets, beatmaps, storage, realm, api)
|
||||
@ -63,28 +55,9 @@ namespace osu.Game.Scoring
|
||||
/// Orders an array of <see cref="ScoreInfo"/>s by total score.
|
||||
/// </summary>
|
||||
/// <param name="scores">The array of <see cref="ScoreInfo"/>s to reorder.</param>
|
||||
/// <param name="cancellationToken">A <see cref="CancellationToken"/> to cancel the process.</param>
|
||||
/// <returns>The given <paramref name="scores"/> ordered by decreasing total score.</returns>
|
||||
public async Task<ScoreInfo[]> OrderByTotalScoreAsync(ScoreInfo[] scores, CancellationToken cancellationToken = default)
|
||||
{
|
||||
if (difficultyCache != null)
|
||||
{
|
||||
// Compute difficulties asynchronously first to prevent blocking via the GetTotalScore() call below.
|
||||
foreach (var s in scores)
|
||||
{
|
||||
await difficultyCache.GetDifficultyAsync(s.BeatmapInfo, s.Ruleset, s.Mods, cancellationToken).ConfigureAwait(false);
|
||||
cancellationToken.ThrowIfCancellationRequested();
|
||||
}
|
||||
}
|
||||
|
||||
long[] totalScores = await Task.WhenAll(scores.Select(s => GetTotalScoreAsync(s, cancellationToken: cancellationToken))).ConfigureAwait(false);
|
||||
|
||||
return scores.Select((score, index) => (score, totalScore: totalScores[index]))
|
||||
.OrderByDescending(g => g.totalScore)
|
||||
.ThenBy(g => g.score.OnlineID)
|
||||
.Select(g => g.score)
|
||||
.ToArray();
|
||||
}
|
||||
public IEnumerable<ScoreInfo> OrderByTotalScore(IEnumerable<ScoreInfo> scores)
|
||||
=> scores.OrderByDescending(s => GetTotalScore(s)).ThenBy(s => s.OnlineID);
|
||||
|
||||
/// <summary>
|
||||
/// Retrieves a bindable that represents the total score of a <see cref="ScoreInfo"/>.
|
||||
@ -106,44 +79,18 @@ namespace osu.Game.Scoring
|
||||
/// <returns>The bindable containing the formatted total score string.</returns>
|
||||
public Bindable<string> GetBindableTotalScoreString([NotNull] ScoreInfo score) => new TotalScoreStringBindable(GetBindableTotalScore(score));
|
||||
|
||||
/// <summary>
|
||||
/// Retrieves the total score of a <see cref="ScoreInfo"/> in the given <see cref="ScoringMode"/>.
|
||||
/// The score is returned in a callback that is run on the update thread.
|
||||
/// </summary>
|
||||
/// <param name="score">The <see cref="ScoreInfo"/> to calculate the total score of.</param>
|
||||
/// <param name="callback">The callback to be invoked with the total score.</param>
|
||||
/// <param name="mode">The <see cref="ScoringMode"/> to return the total score as.</param>
|
||||
/// <param name="cancellationToken">A <see cref="CancellationToken"/> to cancel the process.</param>
|
||||
public void GetTotalScore([NotNull] ScoreInfo score, [NotNull] Action<long> callback, ScoringMode mode = ScoringMode.Standardised, CancellationToken cancellationToken = default)
|
||||
{
|
||||
GetTotalScoreAsync(score, mode, cancellationToken)
|
||||
.ContinueWith(task => scheduler.Add(() =>
|
||||
{
|
||||
if (!cancellationToken.IsCancellationRequested)
|
||||
callback(task.GetResultSafely());
|
||||
}), TaskContinuationOptions.OnlyOnRanToCompletion);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Retrieves the total score of a <see cref="ScoreInfo"/> in the given <see cref="ScoringMode"/>.
|
||||
/// </summary>
|
||||
/// <param name="score">The <see cref="ScoreInfo"/> to calculate the total score of.</param>
|
||||
/// <param name="mode">The <see cref="ScoringMode"/> to return the total score as.</param>
|
||||
/// <param name="cancellationToken">A <see cref="CancellationToken"/> to cancel the process.</param>
|
||||
/// <returns>The total score.</returns>
|
||||
public async Task<long> GetTotalScoreAsync([NotNull] ScoreInfo score, ScoringMode mode = ScoringMode.Standardised, CancellationToken cancellationToken = default)
|
||||
public long GetTotalScore([NotNull] ScoreInfo score, ScoringMode mode = ScoringMode.Standardised)
|
||||
{
|
||||
// TODO: This is required for playlist aggregate scores. They should likely not be getting here in the first place.
|
||||
if (string.IsNullOrEmpty(score.BeatmapInfo.MD5Hash))
|
||||
return score.TotalScore;
|
||||
|
||||
int? beatmapMaxCombo = await GetMaximumAchievableComboAsync(score, cancellationToken).ConfigureAwait(false);
|
||||
if (beatmapMaxCombo == null)
|
||||
return score.TotalScore;
|
||||
|
||||
if (beatmapMaxCombo == 0)
|
||||
return 0;
|
||||
|
||||
var ruleset = score.Ruleset.CreateInstance();
|
||||
var scoreProcessor = ruleset.CreateScoreProcessor();
|
||||
scoreProcessor.Mods.Value = score.Mods;
|
||||
@ -155,35 +102,8 @@ namespace osu.Game.Scoring
|
||||
/// Retrieves the maximum achievable combo for the provided score.
|
||||
/// </summary>
|
||||
/// <param name="score">The <see cref="ScoreInfo"/> to compute the maximum achievable combo for.</param>
|
||||
/// <param name="cancellationToken">A <see cref="CancellationToken"/> to cancel the process.</param>
|
||||
/// <returns>The maximum achievable combo. A <see langword="null"/> return value indicates the difficulty cache has failed to retrieve the combo.</returns>
|
||||
public async Task<int?> GetMaximumAchievableComboAsync([NotNull] ScoreInfo score, CancellationToken cancellationToken = default)
|
||||
{
|
||||
if (score.IsLegacyScore)
|
||||
{
|
||||
// This score is guaranteed to be an osu!stable score.
|
||||
// The combo must be determined through either the beatmap's max combo value or the difficulty calculator, as lazer's scoring has changed and the score statistics cannot be used.
|
||||
#pragma warning disable CS0618
|
||||
if (score.BeatmapInfo.MaxCombo != null)
|
||||
return score.BeatmapInfo.MaxCombo.Value;
|
||||
#pragma warning restore CS0618
|
||||
|
||||
if (difficultyCache == null)
|
||||
return null;
|
||||
|
||||
// We can compute the max combo locally after the async beatmap difficulty computation.
|
||||
var difficulty = await difficultyCache.GetDifficultyAsync(score.BeatmapInfo, score.Ruleset, score.Mods, cancellationToken).ConfigureAwait(false);
|
||||
|
||||
if (difficulty == null)
|
||||
Logger.Log($"Couldn't get beatmap difficulty for beatmap {score.BeatmapInfo.OnlineID}");
|
||||
|
||||
return difficulty?.MaxCombo;
|
||||
}
|
||||
|
||||
// This is guaranteed to be a non-legacy score.
|
||||
// The combo must be determined through the score's statistics, as both the beatmap's max combo and the difficulty calculator will provide osu!stable combo values.
|
||||
return Enum.GetValues(typeof(HitResult)).OfType<HitResult>().Where(r => r.AffectsCombo()).Select(r => score.Statistics.GetValueOrDefault(r)).Sum();
|
||||
}
|
||||
/// <returns>The maximum achievable combo.</returns>
|
||||
public int GetMaximumAchievableCombo([NotNull] ScoreInfo score) => score.MaximumStatistics.Where(kvp => kvp.Key.AffectsCombo()).Sum(kvp => kvp.Value);
|
||||
|
||||
/// <summary>
|
||||
/// Provides the total score of a <see cref="ScoreInfo"/>. Responds to changes in the currently-selected <see cref="ScoringMode"/>.
|
||||
@ -191,10 +111,6 @@ namespace osu.Game.Scoring
|
||||
private class TotalScoreBindable : Bindable<long>
|
||||
{
|
||||
private readonly Bindable<ScoringMode> scoringMode = new Bindable<ScoringMode>();
|
||||
private readonly ScoreInfo score;
|
||||
private readonly ScoreManager scoreManager;
|
||||
|
||||
private CancellationTokenSource difficultyCalculationCancellationSource;
|
||||
|
||||
/// <summary>
|
||||
/// Creates a new <see cref="TotalScoreBindable"/>.
|
||||
@ -204,19 +120,8 @@ namespace osu.Game.Scoring
|
||||
/// <param name="configManager">The config.</param>
|
||||
public TotalScoreBindable(ScoreInfo score, ScoreManager scoreManager, OsuConfigManager configManager)
|
||||
{
|
||||
this.score = score;
|
||||
this.scoreManager = scoreManager;
|
||||
|
||||
configManager?.BindWith(OsuSetting.ScoreDisplayMode, scoringMode);
|
||||
scoringMode.BindValueChanged(onScoringModeChanged, true);
|
||||
}
|
||||
|
||||
private void onScoringModeChanged(ValueChangedEvent<ScoringMode> mode)
|
||||
{
|
||||
difficultyCalculationCancellationSource?.Cancel();
|
||||
difficultyCalculationCancellationSource = new CancellationTokenSource();
|
||||
|
||||
scoreManager.GetTotalScore(score, s => Value = s, mode.NewValue, difficultyCalculationCancellationSource.Token);
|
||||
scoringMode.BindValueChanged(mode => Value = scoreManager.GetTotalScore(score, mode.NewValue), true);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -5,7 +5,6 @@
|
||||
|
||||
using System;
|
||||
using osu.Framework.Allocation;
|
||||
using osu.Framework.Audio.Track;
|
||||
using osu.Framework.Bindables;
|
||||
using osu.Framework.Extensions.Color4Extensions;
|
||||
using osu.Framework.Graphics;
|
||||
@ -64,8 +63,6 @@ namespace osu.Game.Screens.Edit.Compose.Components.Timeline
|
||||
/// </summary>
|
||||
private bool trackWasPlaying;
|
||||
|
||||
private Track track;
|
||||
|
||||
/// <summary>
|
||||
/// The timeline zoom level at a 1x zoom scale.
|
||||
/// </summary>
|
||||
@ -93,6 +90,8 @@ namespace osu.Game.Screens.Edit.Compose.Components.Timeline
|
||||
|
||||
private Bindable<float> waveformOpacity;
|
||||
|
||||
private double trackLengthForZoom;
|
||||
|
||||
[BackgroundDependencyLoader]
|
||||
private void load(IBindable<WorkingBeatmap> beatmap, OsuColour colours, OsuConfigManager config)
|
||||
{
|
||||
@ -144,9 +143,6 @@ namespace osu.Game.Screens.Edit.Compose.Components.Timeline
|
||||
Beatmap.BindValueChanged(b =>
|
||||
{
|
||||
waveform.Waveform = b.NewValue.Waveform;
|
||||
track = b.NewValue.Track;
|
||||
|
||||
setupTimelineZoom();
|
||||
}, true);
|
||||
|
||||
Zoom = (float)(defaultTimelineZoom * editorBeatmap.BeatmapInfo.TimelineZoom);
|
||||
@ -185,8 +181,6 @@ namespace osu.Game.Screens.Edit.Compose.Components.Timeline
|
||||
private void updateWaveformOpacity() =>
|
||||
waveform.FadeTo(WaveformVisible.Value ? waveformOpacity.Value : 0, 200, Easing.OutQuint);
|
||||
|
||||
private float getZoomLevelForVisibleMilliseconds(double milliseconds) => Math.Max(1, (float)(track.Length / milliseconds));
|
||||
|
||||
protected override void Update()
|
||||
{
|
||||
base.Update();
|
||||
@ -197,20 +191,21 @@ namespace osu.Game.Screens.Edit.Compose.Components.Timeline
|
||||
// This needs to happen after transforms are updated, but before the scroll position is updated in base.UpdateAfterChildren
|
||||
if (editorClock.IsRunning)
|
||||
scrollToTrackTime();
|
||||
}
|
||||
|
||||
private void setupTimelineZoom()
|
||||
{
|
||||
if (!track.IsLoaded)
|
||||
if (editorClock.TrackLength != trackLengthForZoom)
|
||||
{
|
||||
Scheduler.AddOnce(setupTimelineZoom);
|
||||
return;
|
||||
defaultTimelineZoom = getZoomLevelForVisibleMilliseconds(6000);
|
||||
|
||||
float initialZoom = (float)(defaultTimelineZoom * editorBeatmap.BeatmapInfo.TimelineZoom);
|
||||
float minimumZoom = getZoomLevelForVisibleMilliseconds(10000);
|
||||
float maximumZoom = getZoomLevelForVisibleMilliseconds(500);
|
||||
|
||||
SetupZoom(initialZoom, minimumZoom, maximumZoom);
|
||||
|
||||
float getZoomLevelForVisibleMilliseconds(double milliseconds) => Math.Max(1, (float)(editorClock.TrackLength / milliseconds));
|
||||
|
||||
trackLengthForZoom = editorClock.TrackLength;
|
||||
}
|
||||
|
||||
defaultTimelineZoom = getZoomLevelForVisibleMilliseconds(6000);
|
||||
|
||||
float initialZoom = (float)(defaultTimelineZoom * editorBeatmap.BeatmapInfo.TimelineZoom);
|
||||
SetupZoom(initialZoom, getZoomLevelForVisibleMilliseconds(10000), getZoomLevelForVisibleMilliseconds(500));
|
||||
}
|
||||
|
||||
protected override bool OnScroll(ScrollEvent e)
|
||||
@ -255,16 +250,13 @@ namespace osu.Game.Screens.Edit.Compose.Components.Timeline
|
||||
|
||||
private void seekTrackToCurrent()
|
||||
{
|
||||
if (!track.IsLoaded)
|
||||
return;
|
||||
|
||||
double target = Current / Content.DrawWidth * track.Length;
|
||||
editorClock.Seek(Math.Min(track.Length, target));
|
||||
double target = Current / Content.DrawWidth * editorClock.TrackLength;
|
||||
editorClock.Seek(Math.Min(editorClock.TrackLength, target));
|
||||
}
|
||||
|
||||
private void scrollToTrackTime()
|
||||
{
|
||||
if (!track.IsLoaded || track.Length == 0)
|
||||
if (editorClock.TrackLength == 0)
|
||||
return;
|
||||
|
||||
// covers the case where the user starts playback after a drag is in progress.
|
||||
@ -272,7 +264,7 @@ namespace osu.Game.Screens.Edit.Compose.Components.Timeline
|
||||
if (handlingDragInput)
|
||||
editorClock.Stop();
|
||||
|
||||
ScrollTo((float)(editorClock.CurrentTime / track.Length) * Content.DrawWidth, false);
|
||||
ScrollTo((float)(editorClock.CurrentTime / editorClock.TrackLength) * Content.DrawWidth, false);
|
||||
}
|
||||
|
||||
protected override bool OnMouseDown(MouseDownEvent e)
|
||||
@ -310,12 +302,12 @@ namespace osu.Game.Screens.Edit.Compose.Components.Timeline
|
||||
/// <summary>
|
||||
/// The total amount of time visible on the timeline.
|
||||
/// </summary>
|
||||
public double VisibleRange => track.Length / Zoom;
|
||||
public double VisibleRange => editorClock.TrackLength / Zoom;
|
||||
|
||||
public SnapResult FindSnappedPositionAndTime(Vector2 screenSpacePosition, SnapType snapType = SnapType.All) =>
|
||||
new SnapResult(screenSpacePosition, beatSnapProvider.SnapTime(getTimeFromPosition(Content.ToLocalSpace(screenSpacePosition))));
|
||||
|
||||
private double getTimeFromPosition(Vector2 localPosition) =>
|
||||
(localPosition.X / Content.DrawWidth) * track.Length;
|
||||
(localPosition.X / Content.DrawWidth) * editorClock.TrackLength;
|
||||
}
|
||||
}
|
||||
|
@ -220,7 +220,7 @@ namespace osu.Game.Screens.Edit
|
||||
}
|
||||
|
||||
// Todo: should probably be done at a DrawableRuleset level to share logic with Player.
|
||||
clock = new EditorClock(playableBeatmap, beatDivisor) { IsCoupled = false };
|
||||
clock = new EditorClock(playableBeatmap, beatDivisor);
|
||||
clock.ChangeSource(loadableBeatmap.Track);
|
||||
|
||||
dependencies.CacheAs(clock);
|
||||
|
@ -4,10 +4,12 @@
|
||||
#nullable disable
|
||||
|
||||
using System;
|
||||
using System.Diagnostics;
|
||||
using System.Linq;
|
||||
using osu.Framework.Audio.Track;
|
||||
using osu.Framework.Bindables;
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Framework.Graphics.Containers;
|
||||
using osu.Framework.Graphics.Transforms;
|
||||
using osu.Framework.Timing;
|
||||
using osu.Framework.Utils;
|
||||
@ -19,7 +21,7 @@ namespace osu.Game.Screens.Edit
|
||||
/// <summary>
|
||||
/// A decoupled clock which adds editor-specific functionality, such as snapping to a user-defined beat divisor.
|
||||
/// </summary>
|
||||
public class EditorClock : Component, IFrameBasedClock, IAdjustableClock, ISourceChangeableClock
|
||||
public class EditorClock : CompositeComponent, IFrameBasedClock, IAdjustableClock, ISourceChangeableClock
|
||||
{
|
||||
public IBindable<Track> Track => track;
|
||||
|
||||
@ -33,7 +35,7 @@ namespace osu.Game.Screens.Edit
|
||||
|
||||
private readonly BindableBeatDivisor beatDivisor;
|
||||
|
||||
private readonly DecoupleableInterpolatingFramedClock underlyingClock;
|
||||
private readonly FramedBeatmapClock underlyingClock;
|
||||
|
||||
private bool playbackFinished;
|
||||
|
||||
@ -52,7 +54,8 @@ namespace osu.Game.Screens.Edit
|
||||
|
||||
this.beatDivisor = beatDivisor ?? new BindableBeatDivisor();
|
||||
|
||||
underlyingClock = new DecoupleableInterpolatingFramedClock();
|
||||
underlyingClock = new FramedBeatmapClock(applyOffsets: true) { IsCoupled = false };
|
||||
AddInternal(underlyingClock);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@ -155,6 +158,8 @@ namespace osu.Game.Screens.Edit
|
||||
|
||||
public double CurrentTime => underlyingClock.CurrentTime;
|
||||
|
||||
public double TotalAppliedOffset => underlyingClock.TotalAppliedOffset;
|
||||
|
||||
public void Reset()
|
||||
{
|
||||
ClearTransforms();
|
||||
@ -219,18 +224,7 @@ namespace osu.Game.Screens.Edit
|
||||
|
||||
public void ProcessFrame()
|
||||
{
|
||||
underlyingClock.ProcessFrame();
|
||||
|
||||
playbackFinished = CurrentTime >= TrackLength;
|
||||
|
||||
if (playbackFinished)
|
||||
{
|
||||
if (IsRunning)
|
||||
underlyingClock.Stop();
|
||||
|
||||
if (CurrentTime > TrackLength)
|
||||
underlyingClock.Seek(TrackLength);
|
||||
}
|
||||
// Noop to ensure an external consumer doesn't process the internal clock an extra time.
|
||||
}
|
||||
|
||||
public double ElapsedFrameTime => underlyingClock.ElapsedFrameTime;
|
||||
@ -247,18 +241,26 @@ namespace osu.Game.Screens.Edit
|
||||
|
||||
public IClock Source => underlyingClock.Source;
|
||||
|
||||
public bool IsCoupled
|
||||
{
|
||||
get => underlyingClock.IsCoupled;
|
||||
set => underlyingClock.IsCoupled = value;
|
||||
}
|
||||
|
||||
private const double transform_time = 300;
|
||||
|
||||
protected override void Update()
|
||||
{
|
||||
base.Update();
|
||||
|
||||
// EditorClock wasn't being added in many places. This gives us more certainty that it is.
|
||||
Debug.Assert(underlyingClock.LoadState > LoadState.NotLoaded);
|
||||
|
||||
playbackFinished = CurrentTime >= TrackLength;
|
||||
|
||||
if (playbackFinished)
|
||||
{
|
||||
if (IsRunning)
|
||||
underlyingClock.Stop();
|
||||
|
||||
if (CurrentTime > TrackLength)
|
||||
underlyingClock.Seek(TrackLength);
|
||||
}
|
||||
|
||||
updateSeekingState();
|
||||
}
|
||||
|
||||
|
@ -180,31 +180,26 @@ namespace osu.Game.Screens.OnlinePlay.Playlists
|
||||
/// <param name="callback">The callback to invoke with the final <see cref="ScoreInfo"/>s.</param>
|
||||
/// <param name="scores">The <see cref="MultiplayerScore"/>s that were retrieved from <see cref="APIRequest"/>s.</param>
|
||||
/// <param name="pivot">An optional pivot around which the scores were retrieved.</param>
|
||||
private void performSuccessCallback([NotNull] Action<IEnumerable<ScoreInfo>> callback, [NotNull] List<MultiplayerScore> scores, [CanBeNull] MultiplayerScores pivot = null)
|
||||
private void performSuccessCallback([NotNull] Action<IEnumerable<ScoreInfo>> callback, [NotNull] List<MultiplayerScore> scores, [CanBeNull] MultiplayerScores pivot = null) => Schedule(() =>
|
||||
{
|
||||
var scoreInfos = scores.Select(s => s.CreateScoreInfo(rulesets, playlistItem, Beatmap.Value.BeatmapInfo)).ToArray();
|
||||
var scoreInfos = scoreManager.OrderByTotalScore(scores.Select(s => s.CreateScoreInfo(rulesets, playlistItem, Beatmap.Value.BeatmapInfo))).ToArray();
|
||||
|
||||
// Score panels calculate total score before displaying, which can take some time. In order to count that calculation as part of the loading spinner display duration,
|
||||
// calculate the total scores locally before invoking the success callback.
|
||||
scoreManager.OrderByTotalScoreAsync(scoreInfos).ContinueWith(_ => Schedule(() =>
|
||||
// Select a score if we don't already have one selected.
|
||||
// Note: This is done before the callback so that the panel list centres on the selected score before panels are added (eliminating initial scroll).
|
||||
if (SelectedScore.Value == null)
|
||||
{
|
||||
// Select a score if we don't already have one selected.
|
||||
// Note: This is done before the callback so that the panel list centres on the selected score before panels are added (eliminating initial scroll).
|
||||
if (SelectedScore.Value == null)
|
||||
Schedule(() =>
|
||||
{
|
||||
Schedule(() =>
|
||||
{
|
||||
// Prefer selecting the local user's score, or otherwise default to the first visible score.
|
||||
SelectedScore.Value = scoreInfos.FirstOrDefault(s => s.User.OnlineID == api.LocalUser.Value.Id) ?? scoreInfos.FirstOrDefault();
|
||||
});
|
||||
}
|
||||
// Prefer selecting the local user's score, or otherwise default to the first visible score.
|
||||
SelectedScore.Value = scoreInfos.FirstOrDefault(s => s.User.OnlineID == api.LocalUser.Value.Id) ?? scoreInfos.FirstOrDefault();
|
||||
});
|
||||
}
|
||||
|
||||
// Invoke callback to add the scores. Exclude the user's current score which was added previously.
|
||||
callback.Invoke(scoreInfos.Where(s => s.OnlineID != Score?.OnlineID));
|
||||
// Invoke callback to add the scores. Exclude the user's current score which was added previously.
|
||||
callback.Invoke(scoreInfos.Where(s => s.OnlineID != Score?.OnlineID));
|
||||
|
||||
hideLoadingSpinners(pivot);
|
||||
}));
|
||||
}
|
||||
hideLoadingSpinners(pivot);
|
||||
});
|
||||
|
||||
private void hideLoadingSpinners([CanBeNull] MultiplayerScores pivot = null)
|
||||
{
|
||||
|
@ -67,12 +67,10 @@ namespace osu.Game.Screens.Ranking.Expanded
|
||||
var metadata = beatmap.BeatmapSet?.Metadata ?? beatmap.Metadata;
|
||||
string creator = metadata.Author.Username;
|
||||
|
||||
int? beatmapMaxCombo = scoreManager.GetMaximumAchievableComboAsync(score).GetResultSafely();
|
||||
|
||||
var topStatistics = new List<StatisticDisplay>
|
||||
{
|
||||
new AccuracyStatistic(score.Accuracy),
|
||||
new ComboStatistic(score.MaxCombo, beatmapMaxCombo),
|
||||
new ComboStatistic(score.MaxCombo, scoreManager.GetMaximumAchievableCombo(score)),
|
||||
new PerformanceStatistic(score),
|
||||
};
|
||||
|
||||
|
@ -8,11 +8,9 @@ using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
using System.Linq;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using JetBrains.Annotations;
|
||||
using osu.Framework.Allocation;
|
||||
using osu.Framework.Bindables;
|
||||
using osu.Framework.Extensions;
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Framework.Graphics.Containers;
|
||||
using osu.Framework.Input.Events;
|
||||
@ -151,32 +149,27 @@ namespace osu.Game.Screens.Ranking
|
||||
|
||||
var score = trackingContainer.Panel.Score;
|
||||
|
||||
// Calculating score can take a while in extreme scenarios, so only display scores after the process completes.
|
||||
scoreManager.GetTotalScoreAsync(score)
|
||||
.ContinueWith(task => Schedule(() =>
|
||||
{
|
||||
flow.SetLayoutPosition(trackingContainer, task.GetResultSafely());
|
||||
flow.SetLayoutPosition(trackingContainer, scoreManager.GetTotalScore(score));
|
||||
|
||||
trackingContainer.Show();
|
||||
trackingContainer.Show();
|
||||
|
||||
if (SelectedScore.Value?.Equals(score) == true)
|
||||
{
|
||||
SelectedScore.TriggerChange();
|
||||
}
|
||||
else
|
||||
{
|
||||
// We want the scroll position to remain relative to the expanded panel. When a new panel is added after the expanded panel, nothing needs to be done.
|
||||
// But when a panel is added before the expanded panel, we need to offset the scroll position by the width of the new panel.
|
||||
if (expandedPanel != null && flow.GetPanelIndex(score) < flow.GetPanelIndex(expandedPanel.Score))
|
||||
{
|
||||
// A somewhat hacky property is used here because we need to:
|
||||
// 1) Scroll after the scroll container's visible range is updated.
|
||||
// 2) Scroll before the scroll container's scroll position is updated.
|
||||
// Without this, we would have a 1-frame positioning error which looks very jarring.
|
||||
scroll.InstantScrollTarget = (scroll.InstantScrollTarget ?? scroll.Target) + ScorePanel.CONTRACTED_WIDTH + panel_spacing;
|
||||
}
|
||||
}
|
||||
}), TaskContinuationOptions.OnlyOnRanToCompletion);
|
||||
if (SelectedScore.Value?.Equals(score) == true)
|
||||
{
|
||||
SelectedScore.TriggerChange();
|
||||
}
|
||||
else
|
||||
{
|
||||
// We want the scroll position to remain relative to the expanded panel. When a new panel is added after the expanded panel, nothing needs to be done.
|
||||
// But when a panel is added before the expanded panel, we need to offset the scroll position by the width of the new panel.
|
||||
if (expandedPanel != null && flow.GetPanelIndex(score) < flow.GetPanelIndex(expandedPanel.Score))
|
||||
{
|
||||
// A somewhat hacky property is used here because we need to:
|
||||
// 1) Scroll after the scroll container's visible range is updated.
|
||||
// 2) Scroll before the scroll container's scroll position is updated.
|
||||
// Without this, we would have a 1-frame positioning error which looks very jarring.
|
||||
scroll.InstantScrollTarget = (scroll.InstantScrollTarget ?? scroll.Target) + ScorePanel.CONTRACTED_WIDTH + panel_spacing;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
@ -8,10 +8,8 @@ using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
using System.Linq;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using osu.Framework.Allocation;
|
||||
using osu.Framework.Bindables;
|
||||
using osu.Framework.Extensions;
|
||||
using osu.Game.Beatmaps;
|
||||
using osu.Game.Database;
|
||||
using osu.Game.Extensions;
|
||||
@ -150,17 +148,12 @@ namespace osu.Game.Screens.Select.Leaderboards
|
||||
|
||||
var req = new GetScoresRequest(fetchBeatmapInfo, fetchRuleset, Scope, requestMods);
|
||||
|
||||
req.Success += r =>
|
||||
req.Success += r => Schedule(() =>
|
||||
{
|
||||
scoreManager.OrderByTotalScoreAsync(r.Scores.Select(s => s.ToScoreInfo(rulesets, fetchBeatmapInfo)).ToArray(), cancellationToken)
|
||||
.ContinueWith(task => Schedule(() =>
|
||||
{
|
||||
if (cancellationToken.IsCancellationRequested)
|
||||
return;
|
||||
|
||||
SetScores(task.GetResultSafely(), r.UserScore?.CreateScoreInfo(rulesets, fetchBeatmapInfo));
|
||||
}), TaskContinuationOptions.OnlyOnRanToCompletion);
|
||||
};
|
||||
SetScores(
|
||||
scoreManager.OrderByTotalScore(r.Scores.Select(s => s.ToScoreInfo(rulesets, fetchBeatmapInfo))),
|
||||
r.UserScore?.CreateScoreInfo(rulesets, fetchBeatmapInfo));
|
||||
});
|
||||
|
||||
return req;
|
||||
}
|
||||
@ -213,16 +206,9 @@ namespace osu.Game.Screens.Select.Leaderboards
|
||||
scores = scores.Where(s => s.Mods.Any(m => selectedMods.Contains(m.Acronym)));
|
||||
}
|
||||
|
||||
scores = scores.Detach();
|
||||
scores = scoreManager.OrderByTotalScore(scores.Detach());
|
||||
|
||||
scoreManager.OrderByTotalScoreAsync(scores.ToArray(), cancellationToken)
|
||||
.ContinueWith(ordered => Schedule(() =>
|
||||
{
|
||||
if (cancellationToken.IsCancellationRequested)
|
||||
return;
|
||||
|
||||
SetScores(ordered.GetResultSafely());
|
||||
}), TaskContinuationOptions.OnlyOnRanToCompletion);
|
||||
Schedule(() => SetScores(scores));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -6,6 +6,8 @@
|
||||
using osu.Framework.Allocation;
|
||||
using osu.Framework.Audio;
|
||||
using osu.Framework.Bindables;
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Framework.Graphics.Containers;
|
||||
using osu.Framework.Input.Events;
|
||||
using osu.Game.Beatmaps;
|
||||
using osu.Game.Overlays;
|
||||
@ -24,30 +26,39 @@ namespace osu.Game.Tests.Visual
|
||||
|
||||
protected readonly BindableBeatDivisor BeatDivisor = new BindableBeatDivisor();
|
||||
|
||||
[Cached]
|
||||
protected new readonly EditorClock Clock;
|
||||
protected EditorClock EditorClock;
|
||||
|
||||
private readonly Bindable<double> frequencyAdjustment = new BindableDouble(1);
|
||||
|
||||
private IBeatmap editorClockBeatmap;
|
||||
protected virtual bool ScrollUsingMouseWheel => true;
|
||||
|
||||
protected EditorClockTestScene()
|
||||
{
|
||||
Clock = new EditorClock(new Beatmap(), BeatDivisor) { IsCoupled = false };
|
||||
}
|
||||
protected override Container<Drawable> Content => content;
|
||||
|
||||
private readonly Container<Drawable> content = new Container { RelativeSizeAxes = Axes.Both };
|
||||
|
||||
protected override IReadOnlyDependencyContainer CreateChildDependencies(IReadOnlyDependencyContainer parent)
|
||||
{
|
||||
var dependencies = new DependencyContainer(base.CreateChildDependencies(parent));
|
||||
|
||||
editorClockBeatmap = CreateEditorClockBeatmap();
|
||||
|
||||
base.Content.AddRange(new Drawable[]
|
||||
{
|
||||
EditorClock = new EditorClock(editorClockBeatmap, BeatDivisor),
|
||||
content
|
||||
});
|
||||
|
||||
dependencies.Cache(BeatDivisor);
|
||||
dependencies.CacheAs(Clock);
|
||||
dependencies.CacheAs(EditorClock);
|
||||
|
||||
return dependencies;
|
||||
}
|
||||
|
||||
protected override void LoadComplete()
|
||||
{
|
||||
Beatmap.Value = CreateWorkingBeatmap(editorClockBeatmap);
|
||||
|
||||
base.LoadComplete();
|
||||
|
||||
Beatmap.BindValueChanged(beatmapChanged, true);
|
||||
@ -55,22 +66,13 @@ namespace osu.Game.Tests.Visual
|
||||
AddSliderStep("editor clock rate", 0.0, 2.0, 1.0, v => frequencyAdjustment.Value = v);
|
||||
}
|
||||
|
||||
protected virtual IBeatmap CreateEditorClockBeatmap() => new Beatmap();
|
||||
|
||||
private void beatmapChanged(ValueChangedEvent<WorkingBeatmap> e)
|
||||
{
|
||||
e.OldValue?.Track.RemoveAdjustment(AdjustableProperty.Frequency, frequencyAdjustment);
|
||||
|
||||
Clock.Beatmap = e.NewValue.Beatmap;
|
||||
Clock.ChangeSource(e.NewValue.Track);
|
||||
Clock.ProcessFrame();
|
||||
|
||||
e.NewValue.Track.AddAdjustment(AdjustableProperty.Frequency, frequencyAdjustment);
|
||||
}
|
||||
|
||||
protected override void Update()
|
||||
{
|
||||
base.Update();
|
||||
|
||||
Clock.ProcessFrame();
|
||||
EditorClock.ChangeSource(e.NewValue.Track);
|
||||
}
|
||||
|
||||
protected override bool OnScroll(ScrollEvent e)
|
||||
@ -79,9 +81,9 @@ namespace osu.Game.Tests.Visual
|
||||
return false;
|
||||
|
||||
if (e.ScrollDelta.Y > 0)
|
||||
Clock.SeekBackward(true);
|
||||
EditorClock.SeekBackward(true);
|
||||
else
|
||||
Clock.SeekForward(true);
|
||||
EditorClock.SeekForward(true);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
@ -30,10 +30,15 @@ namespace osu.Game.Tests.Visual
|
||||
{
|
||||
var dependencies = new DependencyContainer(base.CreateChildDependencies(parent));
|
||||
|
||||
dependencies.CacheAs(new EditorClock());
|
||||
|
||||
var playable = GetPlayableBeatmap();
|
||||
dependencies.CacheAs(new EditorBeatmap(playable));
|
||||
|
||||
var editorClock = new EditorClock();
|
||||
base.Content.Add(editorClock);
|
||||
dependencies.CacheAs(editorClock);
|
||||
|
||||
var editorBeatmap = new EditorBeatmap(playable);
|
||||
// Not adding to hierarchy as we don't satisfy its dependencies. Probably not good.
|
||||
dependencies.CacheAs(editorBeatmap);
|
||||
|
||||
return dependencies;
|
||||
}
|
||||
|
@ -1,9 +1,6 @@
|
||||
// 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.
|
||||
|
||||
#nullable disable
|
||||
|
||||
using JetBrains.Annotations;
|
||||
using osu.Framework.Allocation;
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Framework.Graphics.Containers;
|
||||
@ -19,19 +16,23 @@ namespace osu.Game.Tests.Visual
|
||||
[Cached]
|
||||
private readonly EditorClock editorClock = new EditorClock();
|
||||
|
||||
protected override Container<Drawable> Content => content ?? base.Content;
|
||||
protected override Container<Drawable> Content => content;
|
||||
private readonly Container content;
|
||||
|
||||
protected SelectionBlueprintTestScene()
|
||||
{
|
||||
base.Content.Add(content = new Container
|
||||
base.Content.AddRange(new Drawable[]
|
||||
{
|
||||
Clock = new FramedClock(new StopwatchClock()),
|
||||
RelativeSizeAxes = Axes.Both
|
||||
editorClock,
|
||||
content = new Container
|
||||
{
|
||||
Clock = new FramedClock(new StopwatchClock()),
|
||||
RelativeSizeAxes = Axes.Both
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
protected void AddBlueprint(HitObjectSelectionBlueprint blueprint, [CanBeNull] DrawableHitObject drawableObject = null)
|
||||
protected void AddBlueprint(HitObjectSelectionBlueprint blueprint, DrawableHitObject? drawableObject = null)
|
||||
{
|
||||
Add(blueprint.With(d =>
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user