Merge branch 'master' into news
@ -51,7 +51,7 @@
|
||||
<Reference Include="Java.Interop" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<PackageReference Include="ppy.osu.Game.Resources" Version="2020.727.1" />
|
||||
<PackageReference Include="ppy.osu.Framework.Android" Version="2020.723.0" />
|
||||
<PackageReference Include="ppy.osu.Game.Resources" Version="2020.731.0" />
|
||||
<PackageReference Include="ppy.osu.Framework.Android" Version="2020.730.1" />
|
||||
</ItemGroup>
|
||||
</Project>
|
||||
|
@ -1,6 +1,8 @@
|
||||
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
|
||||
// See the LICENCE file in the repository root for full licence text.
|
||||
|
||||
using System.Collections.Generic;
|
||||
using osu.Game.Audio;
|
||||
using osu.Game.Rulesets.Catch.Judgements;
|
||||
using osu.Game.Rulesets.Judgements;
|
||||
|
||||
@ -8,8 +10,27 @@ namespace osu.Game.Rulesets.Catch.Objects
|
||||
{
|
||||
public class Banana : Fruit
|
||||
{
|
||||
/// <summary>
|
||||
/// Index of banana in current shower.
|
||||
/// </summary>
|
||||
public int BananaIndex;
|
||||
|
||||
public override FruitVisualRepresentation VisualRepresentation => FruitVisualRepresentation.Banana;
|
||||
|
||||
public override Judgement CreateJudgement() => new CatchBananaJudgement();
|
||||
|
||||
private static readonly List<HitSampleInfo> samples = new List<HitSampleInfo> { new BananaHitSampleInfo() };
|
||||
|
||||
public Banana()
|
||||
{
|
||||
Samples = samples;
|
||||
}
|
||||
|
||||
private class BananaHitSampleInfo : HitSampleInfo
|
||||
{
|
||||
private static string[] lookupNames { get; } = { "metronomelow", "catch-banana" };
|
||||
|
||||
public override IEnumerable<string> LookupNames => lookupNames;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -30,15 +30,21 @@ namespace osu.Game.Rulesets.Catch.Objects
|
||||
if (spacing <= 0)
|
||||
return;
|
||||
|
||||
for (double i = StartTime; i <= EndTime; i += spacing)
|
||||
double time = StartTime;
|
||||
int i = 0;
|
||||
|
||||
while (time <= EndTime)
|
||||
{
|
||||
cancellationToken.ThrowIfCancellationRequested();
|
||||
|
||||
AddNested(new Banana
|
||||
{
|
||||
Samples = Samples,
|
||||
StartTime = i
|
||||
StartTime = time,
|
||||
BananaIndex = i,
|
||||
});
|
||||
|
||||
time += spacing;
|
||||
i++;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -40,6 +40,13 @@ namespace osu.Game.Rulesets.Catch.Objects.Drawables
|
||||
float getRandomAngle() => 180 * (RNG.NextSingle() * 2 - 1);
|
||||
}
|
||||
|
||||
public override void PlaySamples()
|
||||
{
|
||||
base.PlaySamples();
|
||||
if (Samples != null)
|
||||
Samples.Frequency.Value = 0.77f + ((Banana)HitObject).BananaIndex * 0.006f;
|
||||
}
|
||||
|
||||
private Color4 getBananaColour()
|
||||
{
|
||||
switch (RNG.Next(0, 3))
|
||||
|
@ -1,12 +1,27 @@
|
||||
// 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.Framework.Graphics;
|
||||
using osu.Framework.Graphics.Containers;
|
||||
using osu.Game.Tests.Visual;
|
||||
|
||||
namespace osu.Game.Rulesets.Osu.Tests
|
||||
{
|
||||
public abstract class OsuSkinnableTestScene : SkinnableTestScene
|
||||
{
|
||||
private Container content;
|
||||
|
||||
protected override Container<Drawable> Content
|
||||
{
|
||||
get
|
||||
{
|
||||
if (content == null)
|
||||
base.Content.Add(content = new OsuInputManager(new RulesetInfo { ID = 0 }));
|
||||
|
||||
return content;
|
||||
}
|
||||
}
|
||||
|
||||
protected override Ruleset CreateRulesetForSkinProvider() => new OsuRuleset();
|
||||
}
|
||||
}
|
||||
|
After Width: | Height: | Size: 26 KiB |
After Width: | Height: | Size: 45 KiB |
After Width: | Height: | Size: 162 KiB |
BIN
osu.Game.Rulesets.Osu.Tests/Resources/old-skin/spinner-clear.png
Normal file
After Width: | Height: | Size: 38 KiB |
BIN
osu.Game.Rulesets.Osu.Tests/Resources/old-skin/spinner-metre.png
Normal file
After Width: | Height: | Size: 14 KiB |
BIN
osu.Game.Rulesets.Osu.Tests/Resources/old-skin/spinner-osu.png
Normal file
After Width: | Height: | Size: 18 KiB |
BIN
osu.Game.Rulesets.Osu.Tests/Resources/old-skin/spinner-spin.png
Normal file
After Width: | Height: | Size: 21 KiB |
BIN
osu.Game.Rulesets.Osu.Tests/Resources/old-skin/spinnerbonus.wav
Normal file
BIN
osu.Game.Rulesets.Osu.Tests/Resources/old-skin/spinnerspin.wav
Normal file
@ -3,7 +3,6 @@
|
||||
|
||||
using System.Collections.Generic;
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Framework.Graphics.Containers;
|
||||
using osu.Game.Audio;
|
||||
using osu.Game.Beatmaps;
|
||||
using osu.Game.Beatmaps.ControlPoints;
|
||||
@ -26,19 +25,6 @@ namespace osu.Game.Rulesets.Osu.Tests
|
||||
[TestFixture]
|
||||
public class TestSceneSlider : OsuSkinnableTestScene
|
||||
{
|
||||
private Container content;
|
||||
|
||||
protected override Container<Drawable> Content
|
||||
{
|
||||
get
|
||||
{
|
||||
if (content == null)
|
||||
base.Content.Add(content = new OsuInputManager(new RulesetInfo { ID = 0 }));
|
||||
|
||||
return content;
|
||||
}
|
||||
}
|
||||
|
||||
private int depthIndex;
|
||||
|
||||
public TestSceneSlider()
|
||||
|
@ -4,37 +4,30 @@
|
||||
using System.Linq;
|
||||
using NUnit.Framework;
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Framework.Graphics.Containers;
|
||||
using osu.Game.Beatmaps;
|
||||
using osu.Game.Beatmaps.ControlPoints;
|
||||
using osu.Game.Rulesets.Mods;
|
||||
using osu.Game.Rulesets.Osu.Objects;
|
||||
using osu.Game.Rulesets.Osu.Objects.Drawables;
|
||||
using osu.Game.Tests.Visual;
|
||||
|
||||
namespace osu.Game.Rulesets.Osu.Tests
|
||||
{
|
||||
[TestFixture]
|
||||
public class TestSceneSpinner : OsuTestScene
|
||||
public class TestSceneSpinner : OsuSkinnableTestScene
|
||||
{
|
||||
private readonly Container content;
|
||||
protected override Container<Drawable> Content => content;
|
||||
|
||||
private int depthIndex;
|
||||
|
||||
public TestSceneSpinner()
|
||||
{
|
||||
base.Content.Add(content = new OsuInputManager(new RulesetInfo { ID = 0 }));
|
||||
|
||||
AddStep("Miss Big", () => testSingle(2));
|
||||
AddStep("Miss Medium", () => testSingle(5));
|
||||
AddStep("Miss Small", () => testSingle(7));
|
||||
AddStep("Hit Big", () => testSingle(2, true));
|
||||
AddStep("Hit Medium", () => testSingle(5, true));
|
||||
AddStep("Hit Small", () => testSingle(7, true));
|
||||
AddStep("Miss Big", () => SetContents(() => testSingle(2)));
|
||||
AddStep("Miss Medium", () => SetContents(() => testSingle(5)));
|
||||
AddStep("Miss Small", () => SetContents(() => testSingle(7)));
|
||||
AddStep("Hit Big", () => SetContents(() => testSingle(2, true)));
|
||||
AddStep("Hit Medium", () => SetContents(() => testSingle(5, true)));
|
||||
AddStep("Hit Small", () => SetContents(() => testSingle(7, true)));
|
||||
}
|
||||
|
||||
private void testSingle(float circleSize, bool auto = false)
|
||||
private Drawable testSingle(float circleSize, bool auto = false)
|
||||
{
|
||||
var spinner = new Spinner { StartTime = Time.Current + 2000, EndTime = Time.Current + 5000 };
|
||||
|
||||
@ -49,12 +42,12 @@ namespace osu.Game.Rulesets.Osu.Tests
|
||||
foreach (var mod in SelectedMods.Value.OfType<IApplicableToDrawableHitObjects>())
|
||||
mod.ApplyToDrawableHitObjects(new[] { drawable });
|
||||
|
||||
Add(drawable);
|
||||
return drawable;
|
||||
}
|
||||
|
||||
private class TestDrawableSpinner : DrawableSpinner
|
||||
{
|
||||
private bool auto;
|
||||
private readonly bool auto;
|
||||
|
||||
public TestDrawableSpinner(Spinner s, bool auto)
|
||||
: base(s)
|
||||
@ -62,16 +55,11 @@ namespace osu.Game.Rulesets.Osu.Tests
|
||||
this.auto = auto;
|
||||
}
|
||||
|
||||
protected override void CheckForResult(bool userTriggered, double timeOffset)
|
||||
protected override void Update()
|
||||
{
|
||||
if (auto && !userTriggered && Time.Current > Spinner.StartTime + Spinner.Duration / 2 && Progress < 1)
|
||||
{
|
||||
// force completion only once to not break human interaction
|
||||
Disc.CumulativeRotation = Spinner.SpinsRequired * 360;
|
||||
auto = false;
|
||||
}
|
||||
|
||||
base.CheckForResult(userTriggered, timeOffset);
|
||||
base.Update();
|
||||
if (auto)
|
||||
RotationTracker.AddRotation((float)(Clock.ElapsedFrameTime * 3));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,6 +1,7 @@
|
||||
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
|
||||
// See the LICENCE file in the repository root for full licence text.
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using NUnit.Framework;
|
||||
@ -60,39 +61,60 @@ namespace osu.Game.Rulesets.Osu.Tests
|
||||
[Test]
|
||||
public void TestSpinnerRewindingRotation()
|
||||
{
|
||||
double trackerRotationTolerance = 0;
|
||||
|
||||
addSeekStep(5000);
|
||||
AddAssert("is disc rotation not almost 0", () => !Precision.AlmostEquals(drawableSpinner.Disc.Rotation, 0, 100));
|
||||
AddAssert("is disc rotation absolute not almost 0", () => !Precision.AlmostEquals(drawableSpinner.Disc.CumulativeRotation, 0, 100));
|
||||
AddStep("calculate rotation tolerance", () =>
|
||||
{
|
||||
trackerRotationTolerance = Math.Abs(drawableSpinner.RotationTracker.Rotation * 0.1f);
|
||||
});
|
||||
AddAssert("is disc rotation not almost 0", () => !Precision.AlmostEquals(drawableSpinner.RotationTracker.Rotation, 0, 100));
|
||||
AddAssert("is disc rotation absolute not almost 0", () => !Precision.AlmostEquals(drawableSpinner.RotationTracker.CumulativeRotation, 0, 100));
|
||||
|
||||
addSeekStep(0);
|
||||
AddAssert("is disc rotation almost 0", () => Precision.AlmostEquals(drawableSpinner.Disc.Rotation, 0, 100));
|
||||
AddAssert("is disc rotation absolute almost 0", () => Precision.AlmostEquals(drawableSpinner.Disc.CumulativeRotation, 0, 100));
|
||||
AddAssert("is disc rotation almost 0", () => Precision.AlmostEquals(drawableSpinner.RotationTracker.Rotation, 0, trackerRotationTolerance));
|
||||
AddAssert("is disc rotation absolute almost 0", () => Precision.AlmostEquals(drawableSpinner.RotationTracker.CumulativeRotation, 0, 100));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestSpinnerMiddleRewindingRotation()
|
||||
{
|
||||
double finalAbsoluteDiscRotation = 0, finalRelativeDiscRotation = 0, finalSpinnerSymbolRotation = 0;
|
||||
double finalCumulativeTrackerRotation = 0;
|
||||
double finalTrackerRotation = 0, trackerRotationTolerance = 0;
|
||||
double finalSpinnerSymbolRotation = 0, spinnerSymbolRotationTolerance = 0;
|
||||
|
||||
addSeekStep(5000);
|
||||
AddStep("retrieve disc relative rotation", () => finalRelativeDiscRotation = drawableSpinner.Disc.Rotation);
|
||||
AddStep("retrieve disc absolute rotation", () => finalAbsoluteDiscRotation = drawableSpinner.Disc.CumulativeRotation);
|
||||
AddStep("retrieve spinner symbol rotation", () => finalSpinnerSymbolRotation = spinnerSymbol.Rotation);
|
||||
AddStep("retrieve disc rotation", () =>
|
||||
{
|
||||
finalTrackerRotation = drawableSpinner.RotationTracker.Rotation;
|
||||
trackerRotationTolerance = Math.Abs(finalTrackerRotation * 0.05f);
|
||||
});
|
||||
AddStep("retrieve spinner symbol rotation", () =>
|
||||
{
|
||||
finalSpinnerSymbolRotation = spinnerSymbol.Rotation;
|
||||
spinnerSymbolRotationTolerance = Math.Abs(finalSpinnerSymbolRotation * 0.05f);
|
||||
});
|
||||
AddStep("retrieve cumulative disc rotation", () => finalCumulativeTrackerRotation = drawableSpinner.RotationTracker.CumulativeRotation);
|
||||
|
||||
addSeekStep(2500);
|
||||
AddUntilStep("disc rotation rewound",
|
||||
AddAssert("disc rotation rewound",
|
||||
// we want to make sure that the rotation at time 2500 is in the same direction as at time 5000, but about half-way in.
|
||||
() => Precision.AlmostEquals(drawableSpinner.Disc.Rotation, finalRelativeDiscRotation / 2, 100));
|
||||
AddUntilStep("symbol rotation rewound",
|
||||
() => Precision.AlmostEquals(spinnerSymbol.Rotation, finalSpinnerSymbolRotation / 2, 100));
|
||||
// due to the exponential damping applied we're allowing a larger margin of error of about 10%
|
||||
// (5% relative to the final rotation value, but we're half-way through the spin).
|
||||
() => Precision.AlmostEquals(drawableSpinner.RotationTracker.Rotation, finalTrackerRotation / 2, trackerRotationTolerance));
|
||||
AddAssert("symbol rotation rewound",
|
||||
() => Precision.AlmostEquals(spinnerSymbol.Rotation, finalSpinnerSymbolRotation / 2, spinnerSymbolRotationTolerance));
|
||||
AddAssert("is cumulative rotation rewound",
|
||||
// cumulative rotation is not damped, so we're treating it as the "ground truth" and allowing a comparatively smaller margin of error.
|
||||
() => Precision.AlmostEquals(drawableSpinner.RotationTracker.CumulativeRotation, finalCumulativeTrackerRotation / 2, 100));
|
||||
|
||||
addSeekStep(5000);
|
||||
AddAssert("is disc rotation almost same",
|
||||
() => Precision.AlmostEquals(drawableSpinner.Disc.Rotation, finalRelativeDiscRotation, 100));
|
||||
() => Precision.AlmostEquals(drawableSpinner.RotationTracker.Rotation, finalTrackerRotation, trackerRotationTolerance));
|
||||
AddAssert("is symbol rotation almost same",
|
||||
() => Precision.AlmostEquals(spinnerSymbol.Rotation, finalSpinnerSymbolRotation, 100));
|
||||
AddAssert("is disc rotation absolute almost same",
|
||||
() => Precision.AlmostEquals(drawableSpinner.Disc.CumulativeRotation, finalAbsoluteDiscRotation, 100));
|
||||
() => Precision.AlmostEquals(spinnerSymbol.Rotation, finalSpinnerSymbolRotation, spinnerSymbolRotationTolerance));
|
||||
AddAssert("is cumulative rotation almost same",
|
||||
() => Precision.AlmostEquals(drawableSpinner.RotationTracker.CumulativeRotation, finalCumulativeTrackerRotation, 100));
|
||||
}
|
||||
|
||||
[Test]
|
||||
@ -115,7 +137,7 @@ namespace osu.Game.Rulesets.Osu.Tests
|
||||
|
||||
addSeekStep(5000);
|
||||
|
||||
AddAssert("disc spin direction correct", () => clockwise ? drawableSpinner.Disc.Rotation > 0 : drawableSpinner.Disc.Rotation < 0);
|
||||
AddAssert("disc spin direction correct", () => clockwise ? drawableSpinner.RotationTracker.Rotation > 0 : drawableSpinner.RotationTracker.Rotation < 0);
|
||||
AddAssert("spinner symbol direction correct", () => clockwise ? spinnerSymbol.Rotation > 0 : spinnerSymbol.Rotation < 0);
|
||||
}
|
||||
|
||||
@ -142,7 +164,7 @@ namespace osu.Game.Rulesets.Osu.Tests
|
||||
{
|
||||
// multipled by 2 to nullify the score multiplier. (autoplay mod selected)
|
||||
var totalScore = ((ScoreExposedPlayer)Player).ScoreProcessor.TotalScore.Value * 2;
|
||||
return totalScore == (int)(drawableSpinner.Disc.CumulativeRotation / 360) * SpinnerTick.SCORE_PER_TICK;
|
||||
return totalScore == (int)(drawableSpinner.RotationTracker.CumulativeRotation / 360) * SpinnerTick.SCORE_PER_TICK;
|
||||
});
|
||||
|
||||
addSeekStep(0);
|
||||
|
@ -82,9 +82,7 @@ namespace osu.Game.Rulesets.Osu.Mods
|
||||
|
||||
case DrawableSpinner spinner:
|
||||
// hide elements we don't care about.
|
||||
spinner.Disc.Hide();
|
||||
spinner.Ticks.Hide();
|
||||
spinner.Background.Hide();
|
||||
// todo: hide background
|
||||
|
||||
using (spinner.BeginAbsoluteSequence(fadeOutStartTime + longFadeDuration, true))
|
||||
spinner.FadeOut(fadeOutDuration);
|
||||
|
@ -40,8 +40,8 @@ namespace osu.Game.Rulesets.Osu.Mods
|
||||
{
|
||||
var spinner = (DrawableSpinner)drawable;
|
||||
|
||||
spinner.Disc.Tracking = true;
|
||||
spinner.Disc.Rotate(MathUtils.RadiansToDegrees((float)spinner.Clock.ElapsedFrameTime * 0.03f));
|
||||
spinner.RotationTracker.Tracking = true;
|
||||
spinner.RotationTracker.AddRotation(MathUtils.RadiansToDegrees((float)spinner.Clock.ElapsedFrameTime * 0.03f));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -43,6 +43,8 @@ namespace osu.Game.Rulesets.Osu.Mods
|
||||
|
||||
var h = drawableOsu.HitObject;
|
||||
|
||||
//todo: expose and hide spinner background somehow
|
||||
|
||||
switch (drawable)
|
||||
{
|
||||
case DrawableHitCircle circle:
|
||||
@ -56,11 +58,6 @@ namespace osu.Game.Rulesets.Osu.Mods
|
||||
slider.Body.OnSkinChanged += () => applySliderState(slider);
|
||||
applySliderState(slider);
|
||||
break;
|
||||
|
||||
case DrawableSpinner spinner:
|
||||
spinner.Disc.Hide();
|
||||
spinner.Background.Hide();
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -3,21 +3,18 @@
|
||||
|
||||
using System;
|
||||
using System.Linq;
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Framework.Graphics.Containers;
|
||||
using osu.Game.Rulesets.Objects.Drawables;
|
||||
using osu.Game.Rulesets.Osu.Objects.Drawables.Pieces;
|
||||
using osuTK;
|
||||
using osuTK.Graphics;
|
||||
using osu.Game.Graphics;
|
||||
using osu.Framework.Extensions.Color4Extensions;
|
||||
using osu.Framework.Allocation;
|
||||
using osu.Framework.Bindables;
|
||||
using osu.Framework.Graphics.Sprites;
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Framework.Graphics.Containers;
|
||||
using osu.Game.Graphics;
|
||||
using osu.Game.Rulesets.Objects;
|
||||
using osu.Framework.Utils;
|
||||
using osu.Game.Rulesets.Objects.Drawables;
|
||||
using osu.Game.Rulesets.Osu.Objects.Drawables.Pieces;
|
||||
using osu.Game.Rulesets.Scoring;
|
||||
using osu.Game.Screens.Ranking;
|
||||
using osu.Game.Skinning;
|
||||
using osuTK;
|
||||
|
||||
namespace osu.Game.Rulesets.Osu.Objects.Drawables
|
||||
{
|
||||
@ -27,28 +24,12 @@ namespace osu.Game.Rulesets.Osu.Objects.Drawables
|
||||
|
||||
private readonly Container<DrawableSpinnerTick> ticks;
|
||||
|
||||
public readonly SpinnerDisc Disc;
|
||||
public readonly SpinnerTicks Ticks;
|
||||
public readonly SpinnerRotationTracker RotationTracker;
|
||||
public readonly SpinnerSpmCounter SpmCounter;
|
||||
private readonly SpinnerBonusDisplay bonusDisplay;
|
||||
|
||||
private readonly Container mainContainer;
|
||||
|
||||
public readonly SpinnerBackground Background;
|
||||
private readonly Container circleContainer;
|
||||
private readonly CirclePiece circle;
|
||||
private readonly GlowPiece glow;
|
||||
|
||||
private readonly SpriteIcon symbol;
|
||||
|
||||
private readonly Color4 baseColour = Color4Extensions.FromHex(@"002c3c");
|
||||
private readonly Color4 fillColour = Color4Extensions.FromHex(@"005b7c");
|
||||
|
||||
private readonly IBindable<Vector2> positionBindable = new Bindable<Vector2>();
|
||||
|
||||
private Color4 normalColour;
|
||||
private Color4 completeColour;
|
||||
|
||||
public DrawableSpinner(Spinner s)
|
||||
: base(s)
|
||||
{
|
||||
@ -57,66 +38,20 @@ namespace osu.Game.Rulesets.Osu.Objects.Drawables
|
||||
|
||||
RelativeSizeAxes = Axes.Both;
|
||||
|
||||
// we are slightly bigger than our parent, to clip the top and bottom of the circle
|
||||
Height = 1.3f;
|
||||
|
||||
Spinner = s;
|
||||
|
||||
InternalChildren = new Drawable[]
|
||||
{
|
||||
ticks = new Container<DrawableSpinnerTick>(),
|
||||
circleContainer = new Container
|
||||
{
|
||||
AutoSizeAxes = Axes.Both,
|
||||
Anchor = Anchor.Centre,
|
||||
Origin = Anchor.Centre,
|
||||
Children = new Drawable[]
|
||||
{
|
||||
glow = new GlowPiece(),
|
||||
circle = new CirclePiece
|
||||
{
|
||||
Position = Vector2.Zero,
|
||||
Anchor = Anchor.Centre,
|
||||
},
|
||||
new RingPiece(),
|
||||
symbol = new SpriteIcon
|
||||
{
|
||||
Anchor = Anchor.Centre,
|
||||
Origin = Anchor.Centre,
|
||||
Size = new Vector2(48),
|
||||
Icon = FontAwesome.Solid.Asterisk,
|
||||
Shadow = false,
|
||||
},
|
||||
}
|
||||
},
|
||||
mainContainer = new AspectContainer
|
||||
new AspectContainer
|
||||
{
|
||||
Anchor = Anchor.Centre,
|
||||
Origin = Anchor.Centre,
|
||||
RelativeSizeAxes = Axes.Y,
|
||||
Children = new[]
|
||||
Children = new Drawable[]
|
||||
{
|
||||
Background = new SpinnerBackground
|
||||
{
|
||||
Disc =
|
||||
{
|
||||
Alpha = 0f,
|
||||
},
|
||||
Anchor = Anchor.Centre,
|
||||
Origin = Anchor.Centre,
|
||||
},
|
||||
Disc = new SpinnerDisc(Spinner)
|
||||
{
|
||||
Scale = Vector2.Zero,
|
||||
Anchor = Anchor.Centre,
|
||||
Origin = Anchor.Centre,
|
||||
},
|
||||
circleContainer.CreateProxy(),
|
||||
Ticks = new SpinnerTicks
|
||||
{
|
||||
Anchor = Anchor.Centre,
|
||||
Origin = Anchor.Centre,
|
||||
},
|
||||
new SkinnableDrawable(new OsuSkinComponent(OsuSkinComponents.SpinnerBody), _ => new DefaultSpinnerDisc()),
|
||||
RotationTracker = new SpinnerRotationTracker(Spinner)
|
||||
}
|
||||
},
|
||||
SpmCounter = new SpinnerSpmCounter
|
||||
@ -135,6 +70,58 @@ namespace osu.Game.Rulesets.Osu.Objects.Drawables
|
||||
};
|
||||
}
|
||||
|
||||
private Bindable<bool> isSpinning;
|
||||
|
||||
protected override void LoadComplete()
|
||||
{
|
||||
base.LoadComplete();
|
||||
|
||||
isSpinning = RotationTracker.IsSpinning.GetBoundCopy();
|
||||
isSpinning.BindValueChanged(updateSpinningSample);
|
||||
}
|
||||
|
||||
private SkinnableSound spinningSample;
|
||||
|
||||
private const float minimum_volume = 0.0001f;
|
||||
|
||||
protected override void LoadSamples()
|
||||
{
|
||||
base.LoadSamples();
|
||||
|
||||
spinningSample?.Expire();
|
||||
spinningSample = null;
|
||||
|
||||
var firstSample = HitObject.Samples.FirstOrDefault();
|
||||
|
||||
if (firstSample != null)
|
||||
{
|
||||
var clone = HitObject.SampleControlPoint.ApplyTo(firstSample);
|
||||
clone.Name = "spinnerspin";
|
||||
|
||||
AddInternal(spinningSample = new SkinnableSound(clone)
|
||||
{
|
||||
Volume = { Value = minimum_volume },
|
||||
Looping = true,
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
private void updateSpinningSample(ValueChangedEvent<bool> tracking)
|
||||
{
|
||||
// note that samples will not start playing if exiting a seek operation in the middle of a spinner.
|
||||
// may be something we want to address at a later point, but not so easy to make happen right now
|
||||
// (SkinnableSound would need to expose whether the sample is already playing and this logic would need to run in Update).
|
||||
if (tracking.NewValue && ShouldPlaySamples)
|
||||
{
|
||||
spinningSample?.Play();
|
||||
spinningSample?.VolumeTo(1, 200);
|
||||
}
|
||||
else
|
||||
{
|
||||
spinningSample?.VolumeTo(minimum_volume, 200).Finally(_ => spinningSample.Stop());
|
||||
}
|
||||
}
|
||||
|
||||
protected override void AddNestedHitObject(DrawableHitObject hitObject)
|
||||
{
|
||||
base.AddNestedHitObject(hitObject);
|
||||
@ -147,6 +134,17 @@ namespace osu.Game.Rulesets.Osu.Objects.Drawables
|
||||
}
|
||||
}
|
||||
|
||||
protected override void UpdateStateTransforms(ArmedState state)
|
||||
{
|
||||
base.UpdateStateTransforms(state);
|
||||
|
||||
using (BeginDelayedSequence(Spinner.Duration, true))
|
||||
this.FadeOut(160);
|
||||
|
||||
// skin change does a rewind of transforms, which will stop the spinning sound from playing if it's currently in playback.
|
||||
isSpinning?.TriggerChange();
|
||||
}
|
||||
|
||||
protected override void ClearNestedHitObjects()
|
||||
{
|
||||
base.ClearNestedHitObjects();
|
||||
@ -170,31 +168,20 @@ namespace osu.Game.Rulesets.Osu.Objects.Drawables
|
||||
[BackgroundDependencyLoader]
|
||||
private void load(OsuColour colours)
|
||||
{
|
||||
normalColour = baseColour;
|
||||
completeColour = colours.YellowLight;
|
||||
|
||||
Background.AccentColour = normalColour;
|
||||
Ticks.AccentColour = normalColour;
|
||||
|
||||
Disc.AccentColour = fillColour;
|
||||
circle.Colour = colours.BlueDark;
|
||||
glow.Colour = colours.BlueDark;
|
||||
|
||||
positionBindable.BindValueChanged(pos => Position = pos.NewValue);
|
||||
positionBindable.BindTo(HitObject.PositionBindable);
|
||||
}
|
||||
|
||||
public float Progress => Math.Clamp(Disc.CumulativeRotation / 360 / Spinner.SpinsRequired, 0, 1);
|
||||
/// <summary>
|
||||
/// The completion progress of this spinner from 0..1 (clamped).
|
||||
/// </summary>
|
||||
public float Progress => Math.Clamp(RotationTracker.CumulativeRotation / 360 / Spinner.SpinsRequired, 0, 1);
|
||||
|
||||
protected override void CheckForResult(bool userTriggered, double timeOffset)
|
||||
{
|
||||
if (Time.Current < HitObject.StartTime) return;
|
||||
|
||||
if (Progress >= 1 && !Disc.Complete)
|
||||
{
|
||||
Disc.Complete = true;
|
||||
transformFillColour(completeColour, 200);
|
||||
}
|
||||
RotationTracker.Complete.Value = Progress >= 1;
|
||||
|
||||
if (userTriggered || Time.Current < Spinner.EndTime)
|
||||
return;
|
||||
@ -219,29 +206,24 @@ namespace osu.Game.Rulesets.Osu.Objects.Drawables
|
||||
protected override void Update()
|
||||
{
|
||||
base.Update();
|
||||
|
||||
if (HandleUserInput)
|
||||
Disc.Tracking = OsuActionInputManager?.PressedActions.Any(x => x == OsuAction.LeftButton || x == OsuAction.RightButton) ?? false;
|
||||
RotationTracker.Tracking = !Result.HasResult && (OsuActionInputManager?.PressedActions.Any(x => x == OsuAction.LeftButton || x == OsuAction.RightButton) ?? false);
|
||||
|
||||
if (spinningSample != null)
|
||||
// todo: implement SpinnerFrequencyModulate
|
||||
spinningSample.Frequency.Value = 0.5f + Progress;
|
||||
}
|
||||
|
||||
protected override void UpdateAfterChildren()
|
||||
{
|
||||
base.UpdateAfterChildren();
|
||||
|
||||
if (!SpmCounter.IsPresent && Disc.Tracking)
|
||||
if (!SpmCounter.IsPresent && RotationTracker.Tracking)
|
||||
SpmCounter.FadeIn(HitObject.TimeFadeIn);
|
||||
|
||||
circle.Rotation = Disc.Rotation;
|
||||
Ticks.Rotation = Disc.Rotation;
|
||||
|
||||
SpmCounter.SetRotation(Disc.CumulativeRotation);
|
||||
SpmCounter.SetRotation(RotationTracker.CumulativeRotation);
|
||||
|
||||
updateBonusScore();
|
||||
|
||||
float relativeCircleScale = Spinner.Scale * circle.DrawHeight / mainContainer.DrawHeight;
|
||||
float targetScale = relativeCircleScale + (1 - relativeCircleScale) * Progress;
|
||||
Disc.Scale = new Vector2((float)Interpolation.Lerp(Disc.Scale.X, targetScale, Math.Clamp(Math.Abs(Time.Elapsed) / 100, 0, 1)));
|
||||
|
||||
symbol.Rotation = (float)Interpolation.Lerp(symbol.Rotation, Disc.Rotation / 2, Math.Clamp(Math.Abs(Time.Elapsed) / 40, 0, 1));
|
||||
}
|
||||
|
||||
private int wholeSpins;
|
||||
@ -251,7 +233,7 @@ namespace osu.Game.Rulesets.Osu.Objects.Drawables
|
||||
if (ticks.Count == 0)
|
||||
return;
|
||||
|
||||
int spins = (int)(Disc.CumulativeRotation / 360);
|
||||
int spins = (int)(RotationTracker.CumulativeRotation / 360);
|
||||
|
||||
if (spins < wholeSpins)
|
||||
{
|
||||
@ -275,64 +257,5 @@ namespace osu.Game.Rulesets.Osu.Objects.Drawables
|
||||
wholeSpins++;
|
||||
}
|
||||
}
|
||||
|
||||
protected override void UpdateInitialTransforms()
|
||||
{
|
||||
base.UpdateInitialTransforms();
|
||||
|
||||
circleContainer.ScaleTo(0);
|
||||
mainContainer.ScaleTo(0);
|
||||
|
||||
using (BeginDelayedSequence(HitObject.TimePreempt / 2, true))
|
||||
{
|
||||
float phaseOneScale = Spinner.Scale * 0.7f;
|
||||
|
||||
circleContainer.ScaleTo(phaseOneScale, HitObject.TimePreempt / 4, Easing.OutQuint);
|
||||
|
||||
mainContainer
|
||||
.ScaleTo(phaseOneScale * circle.DrawHeight / DrawHeight * 1.6f, HitObject.TimePreempt / 4, Easing.OutQuint)
|
||||
.RotateTo((float)(25 * Spinner.Duration / 2000), HitObject.TimePreempt + Spinner.Duration);
|
||||
|
||||
using (BeginDelayedSequence(HitObject.TimePreempt / 2, true))
|
||||
{
|
||||
circleContainer.ScaleTo(Spinner.Scale, 400, Easing.OutQuint);
|
||||
mainContainer.ScaleTo(1, 400, Easing.OutQuint);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
protected override void UpdateStateTransforms(ArmedState state)
|
||||
{
|
||||
base.UpdateStateTransforms(state);
|
||||
|
||||
using (BeginDelayedSequence(Spinner.Duration, true))
|
||||
{
|
||||
this.FadeOut(160);
|
||||
|
||||
switch (state)
|
||||
{
|
||||
case ArmedState.Hit:
|
||||
transformFillColour(completeColour, 0);
|
||||
this.ScaleTo(Scale * 1.2f, 320, Easing.Out);
|
||||
mainContainer.RotateTo(mainContainer.Rotation + 180, 320);
|
||||
break;
|
||||
|
||||
case ArmedState.Miss:
|
||||
this.ScaleTo(Scale * 0.8f, 320, Easing.In);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void transformFillColour(Colour4 colour, double duration)
|
||||
{
|
||||
Disc.FadeAccent(colour, duration);
|
||||
|
||||
Background.FadeAccent(colour.Darken(1), duration);
|
||||
Ticks.FadeAccent(colour, duration);
|
||||
|
||||
circle.FadeColour(colour, duration);
|
||||
glow.FadeColour(colour, duration);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -0,0 +1,189 @@
|
||||
// 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 osu.Framework.Allocation;
|
||||
using osu.Framework.Bindables;
|
||||
using osu.Framework.Extensions.Color4Extensions;
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Framework.Graphics.Containers;
|
||||
using osu.Framework.Utils;
|
||||
using osu.Game.Graphics;
|
||||
using osu.Game.Rulesets.Objects.Drawables;
|
||||
using osuTK;
|
||||
using osuTK.Graphics;
|
||||
|
||||
namespace osu.Game.Rulesets.Osu.Objects.Drawables.Pieces
|
||||
{
|
||||
public class DefaultSpinnerDisc : CompositeDrawable
|
||||
{
|
||||
private DrawableSpinner drawableSpinner;
|
||||
|
||||
private Spinner spinner;
|
||||
|
||||
private const float idle_alpha = 0.2f;
|
||||
private const float tracking_alpha = 0.4f;
|
||||
|
||||
private Color4 normalColour;
|
||||
private Color4 completeColour;
|
||||
|
||||
private SpinnerTicks ticks;
|
||||
|
||||
private int wholeRotationCount;
|
||||
|
||||
private SpinnerFill fill;
|
||||
private Container mainContainer;
|
||||
private SpinnerCentreLayer centre;
|
||||
private SpinnerBackgroundLayer background;
|
||||
|
||||
public DefaultSpinnerDisc()
|
||||
{
|
||||
RelativeSizeAxes = Axes.Both;
|
||||
|
||||
// we are slightly bigger than our parent, to clip the top and bottom of the circle
|
||||
// this should probably be revisited when scaled spinners are a thing.
|
||||
Scale = new Vector2(1.3f);
|
||||
|
||||
Anchor = Anchor.Centre;
|
||||
Origin = Anchor.Centre;
|
||||
}
|
||||
|
||||
[BackgroundDependencyLoader]
|
||||
private void load(OsuColour colours, DrawableHitObject drawableHitObject)
|
||||
{
|
||||
drawableSpinner = (DrawableSpinner)drawableHitObject;
|
||||
spinner = (Spinner)drawableSpinner.HitObject;
|
||||
|
||||
normalColour = colours.BlueDark;
|
||||
completeColour = colours.YellowLight;
|
||||
|
||||
InternalChildren = new Drawable[]
|
||||
{
|
||||
mainContainer = new Container
|
||||
{
|
||||
RelativeSizeAxes = Axes.Both,
|
||||
Anchor = Anchor.Centre,
|
||||
Origin = Anchor.Centre,
|
||||
Children = new Drawable[]
|
||||
{
|
||||
background = new SpinnerBackgroundLayer(),
|
||||
fill = new SpinnerFill
|
||||
{
|
||||
Alpha = idle_alpha,
|
||||
AccentColour = normalColour
|
||||
},
|
||||
ticks = new SpinnerTicks
|
||||
{
|
||||
Anchor = Anchor.Centre,
|
||||
Origin = Anchor.Centre,
|
||||
AccentColour = normalColour
|
||||
},
|
||||
}
|
||||
},
|
||||
centre = new SpinnerCentreLayer
|
||||
{
|
||||
Anchor = Anchor.Centre,
|
||||
Origin = Anchor.Centre,
|
||||
},
|
||||
};
|
||||
}
|
||||
|
||||
protected override void LoadComplete()
|
||||
{
|
||||
base.LoadComplete();
|
||||
|
||||
drawableSpinner.RotationTracker.Complete.BindValueChanged(complete => updateComplete(complete.NewValue, 200));
|
||||
drawableSpinner.State.BindValueChanged(updateStateTransforms, true);
|
||||
}
|
||||
|
||||
protected override void Update()
|
||||
{
|
||||
base.Update();
|
||||
|
||||
if (drawableSpinner.RotationTracker.Complete.Value)
|
||||
{
|
||||
if (checkNewRotationCount)
|
||||
{
|
||||
fill.FinishTransforms(false, nameof(Alpha));
|
||||
fill
|
||||
.FadeTo(tracking_alpha + 0.2f, 60, Easing.OutExpo)
|
||||
.Then()
|
||||
.FadeTo(tracking_alpha, 250, Easing.OutQuint);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
fill.Alpha = (float)Interpolation.Damp(fill.Alpha, drawableSpinner.RotationTracker.Tracking ? tracking_alpha : idle_alpha, 0.98f, (float)Math.Abs(Clock.ElapsedFrameTime));
|
||||
}
|
||||
|
||||
const float initial_scale = 0.2f;
|
||||
float targetScale = initial_scale + (1 - initial_scale) * drawableSpinner.Progress;
|
||||
|
||||
fill.Scale = new Vector2((float)Interpolation.Lerp(fill.Scale.X, targetScale, Math.Clamp(Math.Abs(Time.Elapsed) / 100, 0, 1)));
|
||||
mainContainer.Rotation = drawableSpinner.RotationTracker.Rotation;
|
||||
}
|
||||
|
||||
private void updateStateTransforms(ValueChangedEvent<ArmedState> state)
|
||||
{
|
||||
centre.ScaleTo(0);
|
||||
mainContainer.ScaleTo(0);
|
||||
|
||||
using (BeginAbsoluteSequence(spinner.StartTime - spinner.TimePreempt / 2, true))
|
||||
{
|
||||
// constant ambient rotation to give the spinner "spinning" character.
|
||||
this.RotateTo((float)(25 * spinner.Duration / 2000), spinner.TimePreempt + spinner.Duration);
|
||||
|
||||
centre.ScaleTo(0.3f, spinner.TimePreempt / 4, Easing.OutQuint);
|
||||
mainContainer.ScaleTo(0.2f, spinner.TimePreempt / 4, Easing.OutQuint);
|
||||
|
||||
using (BeginDelayedSequence(spinner.TimePreempt / 2, true))
|
||||
{
|
||||
centre.ScaleTo(0.5f, spinner.TimePreempt / 2, Easing.OutQuint);
|
||||
mainContainer.ScaleTo(1, spinner.TimePreempt / 2, Easing.OutQuint);
|
||||
}
|
||||
}
|
||||
|
||||
// transforms we have from completing the spinner will be rolled back, so reapply immediately.
|
||||
updateComplete(state.NewValue == ArmedState.Hit, 0);
|
||||
|
||||
using (BeginDelayedSequence(spinner.Duration, true))
|
||||
{
|
||||
switch (state.NewValue)
|
||||
{
|
||||
case ArmedState.Hit:
|
||||
this.ScaleTo(Scale * 1.2f, 320, Easing.Out);
|
||||
this.RotateTo(mainContainer.Rotation + 180, 320);
|
||||
break;
|
||||
|
||||
case ArmedState.Miss:
|
||||
this.ScaleTo(Scale * 0.8f, 320, Easing.In);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void updateComplete(bool complete, double duration)
|
||||
{
|
||||
var colour = complete ? completeColour : normalColour;
|
||||
|
||||
ticks.FadeAccent(colour.Darken(1), duration);
|
||||
fill.FadeAccent(colour.Darken(1), duration);
|
||||
|
||||
background.FadeAccent(colour, duration);
|
||||
centre.FadeAccent(colour, duration);
|
||||
}
|
||||
|
||||
private bool checkNewRotationCount
|
||||
{
|
||||
get
|
||||
{
|
||||
int rotations = (int)(drawableSpinner.RotationTracker.CumulativeRotation / 360);
|
||||
|
||||
if (wholeRotationCount == rotations) return false;
|
||||
|
||||
wholeRotationCount = rotations;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -10,7 +10,7 @@ using osuTK.Graphics;
|
||||
|
||||
namespace osu.Game.Rulesets.Osu.Objects.Drawables.Pieces
|
||||
{
|
||||
public class SpinnerBackground : CircularContainer, IHasAccentColour
|
||||
public class SpinnerFill : CircularContainer, IHasAccentColour
|
||||
{
|
||||
public readonly Box Disc;
|
||||
|
||||
@ -31,11 +31,14 @@ namespace osu.Game.Rulesets.Osu.Objects.Drawables.Pieces
|
||||
}
|
||||
}
|
||||
|
||||
public SpinnerBackground()
|
||||
public SpinnerFill()
|
||||
{
|
||||
RelativeSizeAxes = Axes.Both;
|
||||
Masking = true;
|
||||
|
||||
Anchor = Anchor.Centre;
|
||||
Origin = Anchor.Centre;
|
||||
|
||||
Children = new Drawable[]
|
||||
{
|
||||
Disc = new Box
|
@ -2,76 +2,33 @@
|
||||
// See the LICENCE file in the repository root for full licence text.
|
||||
|
||||
using System;
|
||||
using osu.Framework.Bindables;
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Framework.Graphics.Containers;
|
||||
using osu.Framework.Input.Events;
|
||||
using osu.Game.Graphics;
|
||||
using osuTK;
|
||||
using osuTK.Graphics;
|
||||
using osu.Framework.Utils;
|
||||
using osuTK;
|
||||
|
||||
namespace osu.Game.Rulesets.Osu.Objects.Drawables.Pieces
|
||||
{
|
||||
public class SpinnerDisc : CircularContainer, IHasAccentColour
|
||||
public class SpinnerRotationTracker : CircularContainer
|
||||
{
|
||||
private readonly Spinner spinner;
|
||||
|
||||
public Color4 AccentColour
|
||||
{
|
||||
get => background.AccentColour;
|
||||
set => background.AccentColour = value;
|
||||
}
|
||||
|
||||
private readonly SpinnerBackground background;
|
||||
|
||||
private const float idle_alpha = 0.2f;
|
||||
private const float tracking_alpha = 0.4f;
|
||||
|
||||
public override bool IsPresent => true; // handle input when hidden
|
||||
|
||||
public SpinnerDisc(Spinner s)
|
||||
public SpinnerRotationTracker(Spinner s)
|
||||
{
|
||||
spinner = s;
|
||||
|
||||
RelativeSizeAxes = Axes.Both;
|
||||
|
||||
Children = new Drawable[]
|
||||
{
|
||||
background = new SpinnerBackground { Alpha = idle_alpha },
|
||||
};
|
||||
}
|
||||
|
||||
public override bool ReceivePositionalInputAt(Vector2 screenSpacePos) => true;
|
||||
|
||||
private bool tracking;
|
||||
public bool Tracking { get; set; }
|
||||
|
||||
public bool Tracking
|
||||
{
|
||||
get => tracking;
|
||||
set
|
||||
{
|
||||
if (value == tracking) return;
|
||||
|
||||
tracking = value;
|
||||
|
||||
background.FadeTo(tracking ? tracking_alpha : idle_alpha, 100);
|
||||
}
|
||||
}
|
||||
|
||||
private bool complete;
|
||||
|
||||
public bool Complete
|
||||
{
|
||||
get => complete;
|
||||
set
|
||||
{
|
||||
if (value == complete) return;
|
||||
|
||||
complete = value;
|
||||
|
||||
updateCompleteTick();
|
||||
}
|
||||
}
|
||||
public readonly BindableBool Complete = new BindableBool();
|
||||
|
||||
/// <summary>
|
||||
/// The total rotation performed on the spinner disc, disregarding the spin direction.
|
||||
@ -84,7 +41,12 @@ namespace osu.Game.Rulesets.Osu.Objects.Drawables.Pieces
|
||||
/// If the spinner is spun 360 degrees clockwise and then 360 degrees counter-clockwise,
|
||||
/// this property will return the value of 720 (as opposed to 0 for <see cref="Drawable.Rotation"/>).
|
||||
/// </example>
|
||||
public float CumulativeRotation;
|
||||
public float CumulativeRotation { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// Whether the spinning is spinning at a reasonable speed to be considered visually spinning.
|
||||
/// </summary>
|
||||
public readonly BindableBool IsSpinning = new BindableBool();
|
||||
|
||||
/// <summary>
|
||||
/// Whether currently in the correct time range to allow spinning.
|
||||
@ -101,9 +63,6 @@ namespace osu.Game.Rulesets.Osu.Objects.Drawables.Pieces
|
||||
|
||||
private float lastAngle;
|
||||
private float currentRotation;
|
||||
private int completeTick;
|
||||
|
||||
private bool updateCompleteTick() => completeTick != (completeTick = (int)(CumulativeRotation / 360));
|
||||
|
||||
private bool rotationTransferred;
|
||||
|
||||
@ -114,21 +73,14 @@ namespace osu.Game.Rulesets.Osu.Objects.Drawables.Pieces
|
||||
|
||||
var delta = thisAngle - lastAngle;
|
||||
|
||||
if (tracking)
|
||||
Rotate(delta);
|
||||
if (Tracking)
|
||||
AddRotation(delta);
|
||||
|
||||
lastAngle = thisAngle;
|
||||
|
||||
if (Complete && updateCompleteTick())
|
||||
{
|
||||
background.FinishTransforms(false, nameof(Alpha));
|
||||
background
|
||||
.FadeTo(tracking_alpha + 0.2f, 60, Easing.OutExpo)
|
||||
.Then()
|
||||
.FadeTo(tracking_alpha, 250, Easing.OutQuint);
|
||||
}
|
||||
IsSpinning.Value = isSpinnableTime && Math.Abs(currentRotation / 2 - Rotation) > 5f;
|
||||
|
||||
Rotation = (float)Interpolation.Lerp(Rotation, currentRotation / 2, Math.Clamp(Math.Abs(Time.Elapsed) / 40, 0, 1));
|
||||
Rotation = (float)Interpolation.Damp(Rotation, currentRotation / 2, 0.99, Math.Abs(Time.Elapsed));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@ -138,7 +90,7 @@ namespace osu.Game.Rulesets.Osu.Objects.Drawables.Pieces
|
||||
/// Will be a no-op if not a valid time to spin.
|
||||
/// </remarks>
|
||||
/// <param name="angle">The delta angle.</param>
|
||||
public void Rotate(float angle)
|
||||
public void AddRotation(float angle)
|
||||
{
|
||||
if (!isSpinnableTime)
|
||||
return;
|
@ -0,0 +1,22 @@
|
||||
// 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.Framework.Allocation;
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Game.Graphics;
|
||||
using osu.Game.Rulesets.Objects.Drawables;
|
||||
using osu.Game.Rulesets.Osu.Objects.Drawables.Pieces;
|
||||
|
||||
namespace osu.Game.Rulesets.Osu.Objects.Drawables
|
||||
{
|
||||
public class SpinnerBackgroundLayer : SpinnerFill
|
||||
{
|
||||
[BackgroundDependencyLoader]
|
||||
private void load(OsuColour colours, DrawableHitObject drawableHitObject)
|
||||
{
|
||||
Disc.Alpha = 0;
|
||||
Anchor = Anchor.Centre;
|
||||
Origin = Anchor.Centre;
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,71 @@
|
||||
// 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 osu.Framework.Allocation;
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Framework.Graphics.Containers;
|
||||
using osu.Framework.Graphics.Sprites;
|
||||
using osu.Framework.Utils;
|
||||
using osu.Game.Graphics;
|
||||
using osu.Game.Rulesets.Objects.Drawables;
|
||||
using osu.Game.Rulesets.Osu.Objects.Drawables.Pieces;
|
||||
using osuTK;
|
||||
using osuTK.Graphics;
|
||||
|
||||
namespace osu.Game.Rulesets.Osu.Objects.Drawables
|
||||
{
|
||||
public class SpinnerCentreLayer : CompositeDrawable, IHasAccentColour
|
||||
{
|
||||
private DrawableSpinner spinner;
|
||||
|
||||
private CirclePiece circle;
|
||||
private GlowPiece glow;
|
||||
private SpriteIcon symbol;
|
||||
|
||||
[BackgroundDependencyLoader]
|
||||
private void load(DrawableHitObject drawableHitObject)
|
||||
{
|
||||
spinner = (DrawableSpinner)drawableHitObject;
|
||||
|
||||
InternalChildren = new Drawable[]
|
||||
{
|
||||
glow = new GlowPiece(),
|
||||
circle = new CirclePiece
|
||||
{
|
||||
Position = Vector2.Zero,
|
||||
Anchor = Anchor.Centre,
|
||||
},
|
||||
new RingPiece(),
|
||||
symbol = new SpriteIcon
|
||||
{
|
||||
Anchor = Anchor.Centre,
|
||||
Origin = Anchor.Centre,
|
||||
Size = new Vector2(48),
|
||||
Icon = FontAwesome.Solid.Asterisk,
|
||||
Shadow = false,
|
||||
},
|
||||
};
|
||||
}
|
||||
|
||||
protected override void Update()
|
||||
{
|
||||
base.Update();
|
||||
symbol.Rotation = (float)Interpolation.Lerp(symbol.Rotation, spinner.RotationTracker.Rotation / 2, Math.Clamp(Math.Abs(Time.Elapsed) / 40, 0, 1));
|
||||
}
|
||||
|
||||
private Color4 accentColour;
|
||||
|
||||
public Color4 AccentColour
|
||||
{
|
||||
get => accentColour;
|
||||
set
|
||||
{
|
||||
accentColour = value;
|
||||
|
||||
circle.Colour = accentColour;
|
||||
glow.Colour = accentColour;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -17,5 +17,6 @@ namespace osu.Game.Rulesets.Osu
|
||||
SliderFollowCircle,
|
||||
SliderBall,
|
||||
SliderBody,
|
||||
SpinnerBody
|
||||
}
|
||||
}
|
||||
|
99
osu.Game.Rulesets.Osu/Skinning/LegacyNewStyleSpinner.cs
Normal file
@ -0,0 +1,99 @@
|
||||
// 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.Framework.Allocation;
|
||||
using osu.Framework.Bindables;
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Framework.Graphics.Containers;
|
||||
using osu.Framework.Graphics.Sprites;
|
||||
using osu.Framework.Utils;
|
||||
using osu.Game.Rulesets.Objects.Drawables;
|
||||
using osu.Game.Rulesets.Osu.Objects;
|
||||
using osu.Game.Rulesets.Osu.Objects.Drawables;
|
||||
using osu.Game.Skinning;
|
||||
using osuTK;
|
||||
using osuTK.Graphics;
|
||||
|
||||
namespace osu.Game.Rulesets.Osu.Skinning
|
||||
{
|
||||
/// <summary>
|
||||
/// Legacy skinned spinner with two main spinning layers, one fixed overlay and one final spinning overlay.
|
||||
/// No background layer.
|
||||
/// </summary>
|
||||
public class LegacyNewStyleSpinner : CompositeDrawable
|
||||
{
|
||||
private Sprite discBottom;
|
||||
private Sprite discTop;
|
||||
private Sprite spinningMiddle;
|
||||
private Sprite fixedMiddle;
|
||||
|
||||
private DrawableSpinner drawableSpinner;
|
||||
|
||||
private const float final_scale = 0.625f;
|
||||
|
||||
[BackgroundDependencyLoader]
|
||||
private void load(ISkinSource source, DrawableHitObject drawableObject)
|
||||
{
|
||||
drawableSpinner = (DrawableSpinner)drawableObject;
|
||||
|
||||
Scale = new Vector2(final_scale);
|
||||
|
||||
InternalChildren = new Drawable[]
|
||||
{
|
||||
discBottom = new Sprite
|
||||
{
|
||||
Anchor = Anchor.Centre,
|
||||
Origin = Anchor.Centre,
|
||||
Texture = source.GetTexture("spinner-bottom")
|
||||
},
|
||||
discTop = new Sprite
|
||||
{
|
||||
Anchor = Anchor.Centre,
|
||||
Origin = Anchor.Centre,
|
||||
Texture = source.GetTexture("spinner-top")
|
||||
},
|
||||
fixedMiddle = new Sprite
|
||||
{
|
||||
Anchor = Anchor.Centre,
|
||||
Origin = Anchor.Centre,
|
||||
Texture = source.GetTexture("spinner-middle")
|
||||
},
|
||||
spinningMiddle = new Sprite
|
||||
{
|
||||
Anchor = Anchor.Centre,
|
||||
Origin = Anchor.Centre,
|
||||
Texture = source.GetTexture("spinner-middle2")
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
protected override void LoadComplete()
|
||||
{
|
||||
base.LoadComplete();
|
||||
|
||||
this.FadeOut();
|
||||
drawableSpinner.State.BindValueChanged(updateStateTransforms, true);
|
||||
}
|
||||
|
||||
private void updateStateTransforms(ValueChangedEvent<ArmedState> state)
|
||||
{
|
||||
var spinner = (Spinner)drawableSpinner.HitObject;
|
||||
|
||||
using (BeginAbsoluteSequence(spinner.StartTime - spinner.TimePreempt / 2, true))
|
||||
this.FadeInFromZero(spinner.TimePreempt / 2);
|
||||
|
||||
fixedMiddle.FadeColour(Color4.White);
|
||||
using (BeginAbsoluteSequence(spinner.StartTime, true))
|
||||
fixedMiddle.FadeColour(Color4.Red, spinner.Duration);
|
||||
}
|
||||
|
||||
protected override void Update()
|
||||
{
|
||||
base.Update();
|
||||
spinningMiddle.Rotation = discTop.Rotation = drawableSpinner.RotationTracker.Rotation;
|
||||
discBottom.Rotation = discTop.Rotation / 3;
|
||||
|
||||
Scale = new Vector2(final_scale * (0.8f + (float)Interpolation.ApplyEasing(Easing.Out, drawableSpinner.Progress) * 0.2f));
|
||||
}
|
||||
}
|
||||
}
|
114
osu.Game.Rulesets.Osu/Skinning/LegacyOldStyleSpinner.cs
Normal file
@ -0,0 +1,114 @@
|
||||
// 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 osu.Framework.Allocation;
|
||||
using osu.Framework.Bindables;
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Framework.Graphics.Containers;
|
||||
using osu.Framework.Graphics.Sprites;
|
||||
using osu.Framework.Utils;
|
||||
using osu.Game.Rulesets.Objects.Drawables;
|
||||
using osu.Game.Rulesets.Osu.Objects.Drawables;
|
||||
using osu.Game.Skinning;
|
||||
using osuTK;
|
||||
|
||||
namespace osu.Game.Rulesets.Osu.Skinning
|
||||
{
|
||||
/// <summary>
|
||||
/// Legacy skinned spinner with one main spinning layer and a background layer.
|
||||
/// </summary>
|
||||
public class LegacyOldStyleSpinner : CompositeDrawable
|
||||
{
|
||||
private DrawableSpinner drawableSpinner;
|
||||
private Sprite disc;
|
||||
private Container metre;
|
||||
|
||||
private const float background_y_offset = 20;
|
||||
|
||||
private const float sprite_scale = 1 / 1.6f;
|
||||
|
||||
[BackgroundDependencyLoader]
|
||||
private void load(ISkinSource source, DrawableHitObject drawableObject)
|
||||
{
|
||||
drawableSpinner = (DrawableSpinner)drawableObject;
|
||||
|
||||
RelativeSizeAxes = Axes.Both;
|
||||
|
||||
InternalChildren = new Drawable[]
|
||||
{
|
||||
new Sprite
|
||||
{
|
||||
Anchor = Anchor.BottomCentre,
|
||||
Origin = Anchor.BottomCentre,
|
||||
Texture = source.GetTexture("spinner-background"),
|
||||
Y = background_y_offset,
|
||||
Scale = new Vector2(sprite_scale)
|
||||
},
|
||||
disc = new Sprite
|
||||
{
|
||||
Anchor = Anchor.Centre,
|
||||
Origin = Anchor.Centre,
|
||||
Texture = source.GetTexture("spinner-circle"),
|
||||
Scale = new Vector2(sprite_scale)
|
||||
},
|
||||
metre = new Container
|
||||
{
|
||||
Anchor = Anchor.BottomCentre,
|
||||
Origin = Anchor.BottomCentre,
|
||||
Y = background_y_offset,
|
||||
Masking = true,
|
||||
Child = new Sprite
|
||||
{
|
||||
Texture = source.GetTexture("spinner-metre"),
|
||||
Anchor = Anchor.BottomCentre,
|
||||
Origin = Anchor.BottomCentre,
|
||||
},
|
||||
Scale = new Vector2(0.625f)
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
private Vector2 metreFinalSize;
|
||||
|
||||
protected override void LoadComplete()
|
||||
{
|
||||
base.LoadComplete();
|
||||
|
||||
this.FadeOut();
|
||||
drawableSpinner.State.BindValueChanged(updateStateTransforms, true);
|
||||
|
||||
metreFinalSize = metre.Size = metre.Child.Size;
|
||||
}
|
||||
|
||||
private void updateStateTransforms(ValueChangedEvent<ArmedState> state)
|
||||
{
|
||||
var spinner = drawableSpinner.HitObject;
|
||||
|
||||
using (BeginAbsoluteSequence(spinner.StartTime - spinner.TimePreempt / 2, true))
|
||||
this.FadeInFromZero(spinner.TimePreempt / 2);
|
||||
}
|
||||
|
||||
protected override void Update()
|
||||
{
|
||||
base.Update();
|
||||
disc.Rotation = drawableSpinner.RotationTracker.Rotation;
|
||||
metre.Height = getMetreHeight(drawableSpinner.Progress);
|
||||
}
|
||||
|
||||
private const int total_bars = 10;
|
||||
|
||||
private float getMetreHeight(float progress)
|
||||
{
|
||||
progress = Math.Min(99, progress * 100);
|
||||
|
||||
int barCount = (int)progress / 10;
|
||||
|
||||
// todo: add SpinnerNoBlink support
|
||||
if (RNG.NextBool(((int)progress % 10) / 10f))
|
||||
barCount++;
|
||||
|
||||
return (float)barCount / total_bars * metreFinalSize.Y;
|
||||
}
|
||||
}
|
||||
}
|
@ -102,6 +102,16 @@ namespace osu.Game.Rulesets.Osu.Skinning
|
||||
Scale = new Vector2(0.8f),
|
||||
Spacing = new Vector2(-overlap, 0)
|
||||
};
|
||||
|
||||
case OsuSkinComponents.SpinnerBody:
|
||||
bool hasBackground = Source.GetTexture("spinner-background") != null;
|
||||
|
||||
if (Source.GetTexture("spinner-top") != null && !hasBackground)
|
||||
return new LegacyNewStyleSpinner();
|
||||
else if (hasBackground)
|
||||
return new LegacyOldStyleSpinner();
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
return null;
|
||||
|
@ -0,0 +1,10 @@
|
||||
osu file format v14
|
||||
|
||||
[General]
|
||||
Mode: 1
|
||||
|
||||
[TimingPoints]
|
||||
0,300,4,1,2,100,1,0
|
||||
|
||||
[HitObjects]
|
||||
444,320,1000,5,0,0:0:0:0:
|
@ -0,0 +1,52 @@
|
||||
// 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.Reflection;
|
||||
using NUnit.Framework;
|
||||
using osu.Framework.IO.Stores;
|
||||
using osu.Game.Tests.Beatmaps;
|
||||
|
||||
namespace osu.Game.Rulesets.Taiko.Tests
|
||||
{
|
||||
public class TestSceneTaikoHitObjectSamples : HitObjectSampleTest
|
||||
{
|
||||
protected override Ruleset CreatePlayerRuleset() => new TaikoRuleset();
|
||||
|
||||
protected override IResourceStore<byte[]> Resources => new DllResourceStore(Assembly.GetAssembly(typeof(TestSceneTaikoHitObjectSamples)));
|
||||
|
||||
[TestCase("taiko-normal-hitnormal")]
|
||||
[TestCase("normal-hitnormal")]
|
||||
[TestCase("hitnormal")]
|
||||
public void TestDefaultCustomSampleFromBeatmap(string expectedSample)
|
||||
{
|
||||
SetupSkins(expectedSample, expectedSample);
|
||||
|
||||
CreateTestWithBeatmap("taiko-hitobject-beatmap-custom-sample-bank.osu");
|
||||
|
||||
AssertBeatmapLookup(expectedSample);
|
||||
}
|
||||
|
||||
[TestCase("taiko-normal-hitnormal")]
|
||||
[TestCase("normal-hitnormal")]
|
||||
[TestCase("hitnormal")]
|
||||
public void TestDefaultCustomSampleFromUserSkinFallback(string expectedSample)
|
||||
{
|
||||
SetupSkins(string.Empty, expectedSample);
|
||||
|
||||
CreateTestWithBeatmap("taiko-hitobject-beatmap-custom-sample-bank.osu");
|
||||
|
||||
AssertUserLookup(expectedSample);
|
||||
}
|
||||
|
||||
[TestCase("taiko-normal-hitnormal2")]
|
||||
[TestCase("normal-hitnormal2")]
|
||||
public void TestUserSkinLookupIgnoresSampleBank(string unwantedSample)
|
||||
{
|
||||
SetupSkins(string.Empty, unwantedSample);
|
||||
|
||||
CreateTestWithBeatmap("taiko-hitobject-beatmap-custom-sample-bank.osu");
|
||||
|
||||
AssertNoLookup(unwantedSample);
|
||||
}
|
||||
}
|
||||
}
|
@ -67,9 +67,11 @@ namespace osu.Game.Tests.Gameplay
|
||||
/// Tests that a hitobject which provides a custom sample set of 2 retrieves the following samples from the beatmap skin:
|
||||
/// normal-hitnormal2
|
||||
/// normal-hitnormal
|
||||
/// hitnormal
|
||||
/// </summary>
|
||||
[TestCase("normal-hitnormal2")]
|
||||
[TestCase("normal-hitnormal")]
|
||||
[TestCase("hitnormal")]
|
||||
public void TestDefaultCustomSampleFromBeatmap(string expectedSample)
|
||||
{
|
||||
SetupSkins(expectedSample, expectedSample);
|
||||
@ -80,12 +82,13 @@ namespace osu.Game.Tests.Gameplay
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Tests that a hitobject which provides a custom sample set of 2 retrieves the following samples from the user skin when the beatmap does not contain the sample:
|
||||
/// normal-hitnormal2
|
||||
/// Tests that a hitobject which provides a custom sample set of 2 retrieves the following samples from the user skin
|
||||
/// (ignoring the custom sample set index) when the beatmap skin does not contain the sample:
|
||||
/// normal-hitnormal
|
||||
/// hitnormal
|
||||
/// </summary>
|
||||
[TestCase("normal-hitnormal2")]
|
||||
[TestCase("normal-hitnormal")]
|
||||
[TestCase("hitnormal")]
|
||||
public void TestDefaultCustomSampleFromUserSkinFallback(string expectedSample)
|
||||
{
|
||||
SetupSkins(string.Empty, expectedSample);
|
||||
@ -95,6 +98,23 @@ namespace osu.Game.Tests.Gameplay
|
||||
AssertUserLookup(expectedSample);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Tests that a hitobject which provides a custom sample set of 2 does not retrieve a normal-hitnormal2 sample from the user skin
|
||||
/// if the beatmap skin does not contain the sample.
|
||||
/// User skins in stable ignore the custom sample set index when performing lookups.
|
||||
/// </summary>
|
||||
[Test]
|
||||
public void TestUserSkinLookupIgnoresSampleBank()
|
||||
{
|
||||
const string unwanted_sample = "normal-hitnormal2";
|
||||
|
||||
SetupSkins(string.Empty, unwanted_sample);
|
||||
|
||||
CreateTestWithBeatmap("hitobject-beatmap-custom-sample.osu");
|
||||
|
||||
AssertNoLookup(unwanted_sample);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Tests that a hitobject which provides a sample file retrieves the sample file from the beatmap skin.
|
||||
/// </summary>
|
||||
@ -145,6 +165,7 @@ namespace osu.Game.Tests.Gameplay
|
||||
/// </summary>
|
||||
[TestCase("normal-hitnormal2")]
|
||||
[TestCase("normal-hitnormal")]
|
||||
[TestCase("hitnormal")]
|
||||
public void TestControlPointCustomSampleFromBeatmap(string sampleName)
|
||||
{
|
||||
SetupSkins(sampleName, sampleName);
|
||||
@ -178,7 +199,7 @@ namespace osu.Game.Tests.Gameplay
|
||||
string[] expectedSamples =
|
||||
{
|
||||
"normal-hitnormal2",
|
||||
"normal-hitwhistle2"
|
||||
"normal-hitwhistle" // user skin lookups ignore custom sample set index
|
||||
};
|
||||
|
||||
SetupSkins(expectedSamples[0], expectedSamples[1]);
|
||||
|
@ -3,14 +3,24 @@
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Net;
|
||||
using System.Threading.Tasks;
|
||||
using JetBrains.Annotations;
|
||||
using Newtonsoft.Json.Linq;
|
||||
using NUnit.Framework;
|
||||
using osu.Framework.Graphics.Containers;
|
||||
using osu.Framework.Testing;
|
||||
using osu.Game.Graphics.Containers;
|
||||
using osu.Game.Graphics.UserInterface;
|
||||
using osu.Game.Online.API;
|
||||
using osu.Game.Online.API.Requests;
|
||||
using osu.Game.Online.Multiplayer;
|
||||
using osu.Game.Rulesets.Osu;
|
||||
using osu.Game.Rulesets.Scoring;
|
||||
using osu.Game.Scoring;
|
||||
using osu.Game.Screens.Multi.Ranking;
|
||||
using osu.Game.Screens.Ranking;
|
||||
using osu.Game.Tests.Beatmaps;
|
||||
using osu.Game.Users;
|
||||
|
||||
@ -18,43 +28,134 @@ namespace osu.Game.Tests.Visual.Multiplayer
|
||||
{
|
||||
public class TestSceneTimeshiftResultsScreen : ScreenTestScene
|
||||
{
|
||||
private bool roomsReceived;
|
||||
private const int scores_per_result = 10;
|
||||
|
||||
private TestResultsScreen resultsScreen;
|
||||
private int currentScoreId;
|
||||
private bool requestComplete;
|
||||
|
||||
[SetUp]
|
||||
public void Setup() => Schedule(() =>
|
||||
{
|
||||
roomsReceived = false;
|
||||
currentScoreId = 0;
|
||||
requestComplete = false;
|
||||
bindHandler();
|
||||
});
|
||||
|
||||
[Test]
|
||||
public void TestShowResultsWithScore()
|
||||
public void TestShowWithUserScore()
|
||||
{
|
||||
createResults(new TestScoreInfo(new OsuRuleset().RulesetInfo));
|
||||
AddWaitStep("wait for display", 5);
|
||||
ScoreInfo userScore = null;
|
||||
|
||||
AddStep("bind user score info handler", () =>
|
||||
{
|
||||
userScore = new TestScoreInfo(new OsuRuleset().RulesetInfo) { OnlineScoreID = currentScoreId++ };
|
||||
bindHandler(userScore: userScore);
|
||||
});
|
||||
|
||||
createResults(() => userScore);
|
||||
waitForDisplay();
|
||||
|
||||
AddAssert("user score selected", () => this.ChildrenOfType<ScorePanel>().Single(p => p.Score.OnlineScoreID == userScore.OnlineScoreID).State == PanelState.Expanded);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestShowResultsNullScore()
|
||||
public void TestShowNullUserScore()
|
||||
{
|
||||
createResults(null);
|
||||
AddWaitStep("wait for display", 5);
|
||||
createResults();
|
||||
waitForDisplay();
|
||||
|
||||
AddAssert("top score selected", () => this.ChildrenOfType<ScorePanel>().OrderByDescending(p => p.Score.TotalScore).First().State == PanelState.Expanded);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestShowResultsNullScoreWithDelay()
|
||||
public void TestShowUserScoreWithDelay()
|
||||
{
|
||||
ScoreInfo userScore = null;
|
||||
|
||||
AddStep("bind user score info handler", () =>
|
||||
{
|
||||
userScore = new TestScoreInfo(new OsuRuleset().RulesetInfo) { OnlineScoreID = currentScoreId++ };
|
||||
bindHandler(3000, userScore);
|
||||
});
|
||||
|
||||
createResults(() => userScore);
|
||||
waitForDisplay();
|
||||
|
||||
AddAssert("more than 1 panel displayed", () => this.ChildrenOfType<ScorePanel>().Count() > 1);
|
||||
AddAssert("user score selected", () => this.ChildrenOfType<ScorePanel>().Single(p => p.Score.OnlineScoreID == userScore.OnlineScoreID).State == PanelState.Expanded);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestShowNullUserScoreWithDelay()
|
||||
{
|
||||
AddStep("bind delayed handler", () => bindHandler(3000));
|
||||
createResults(null);
|
||||
AddUntilStep("wait for rooms to be received", () => roomsReceived);
|
||||
AddWaitStep("wait for display", 5);
|
||||
|
||||
createResults();
|
||||
waitForDisplay();
|
||||
|
||||
AddAssert("top score selected", () => this.ChildrenOfType<ScorePanel>().OrderByDescending(p => p.Score.TotalScore).First().State == PanelState.Expanded);
|
||||
}
|
||||
|
||||
private void createResults(ScoreInfo score)
|
||||
[Test]
|
||||
public void TestFetchWhenScrolledToTheRight()
|
||||
{
|
||||
createResults();
|
||||
waitForDisplay();
|
||||
|
||||
AddStep("bind delayed handler", () => bindHandler(3000));
|
||||
|
||||
for (int i = 0; i < 2; i++)
|
||||
{
|
||||
int beforePanelCount = 0;
|
||||
|
||||
AddStep("get panel count", () => beforePanelCount = this.ChildrenOfType<ScorePanel>().Count());
|
||||
AddStep("scroll to right", () => resultsScreen.ScorePanelList.ChildrenOfType<OsuScrollContainer>().Single().ScrollToEnd(false));
|
||||
|
||||
AddAssert("right loading spinner shown", () => resultsScreen.RightSpinner.State.Value == Visibility.Visible);
|
||||
waitForDisplay();
|
||||
|
||||
AddAssert($"count increased by {scores_per_result}", () => this.ChildrenOfType<ScorePanel>().Count() == beforePanelCount + scores_per_result);
|
||||
AddAssert("right loading spinner hidden", () => resultsScreen.RightSpinner.State.Value == Visibility.Hidden);
|
||||
}
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestFetchWhenScrolledToTheLeft()
|
||||
{
|
||||
ScoreInfo userScore = null;
|
||||
|
||||
AddStep("bind user score info handler", () =>
|
||||
{
|
||||
userScore = new TestScoreInfo(new OsuRuleset().RulesetInfo) { OnlineScoreID = currentScoreId++ };
|
||||
bindHandler(userScore: userScore);
|
||||
});
|
||||
|
||||
createResults(() => userScore);
|
||||
waitForDisplay();
|
||||
|
||||
AddStep("bind delayed handler", () => bindHandler(3000));
|
||||
|
||||
for (int i = 0; i < 2; i++)
|
||||
{
|
||||
int beforePanelCount = 0;
|
||||
|
||||
AddStep("get panel count", () => beforePanelCount = this.ChildrenOfType<ScorePanel>().Count());
|
||||
AddStep("scroll to left", () => resultsScreen.ScorePanelList.ChildrenOfType<OsuScrollContainer>().Single().ScrollToStart(false));
|
||||
|
||||
AddAssert("left loading spinner shown", () => resultsScreen.LeftSpinner.State.Value == Visibility.Visible);
|
||||
waitForDisplay();
|
||||
|
||||
AddAssert($"count increased by {scores_per_result}", () => this.ChildrenOfType<ScorePanel>().Count() == beforePanelCount + scores_per_result);
|
||||
AddAssert("left loading spinner hidden", () => resultsScreen.LeftSpinner.State.Value == Visibility.Hidden);
|
||||
}
|
||||
}
|
||||
|
||||
private void createResults(Func<ScoreInfo> getScore = null)
|
||||
{
|
||||
AddStep("load results", () =>
|
||||
{
|
||||
LoadScreen(new TimeshiftResultsScreen(score, 1, new PlaylistItem
|
||||
LoadScreen(resultsScreen = new TestResultsScreen(getScore?.Invoke(), 1, new PlaylistItem
|
||||
{
|
||||
Beatmap = { Value = new TestBeatmap(new OsuRuleset().RulesetInfo).BeatmapInfo },
|
||||
Ruleset = { Value = new OsuRuleset().RulesetInfo }
|
||||
@ -62,42 +163,40 @@ namespace osu.Game.Tests.Visual.Multiplayer
|
||||
});
|
||||
}
|
||||
|
||||
private void bindHandler(double delay = 0)
|
||||
private void waitForDisplay()
|
||||
{
|
||||
var roomScores = new List<MultiplayerScore>();
|
||||
|
||||
for (int i = 0; i < 10; i++)
|
||||
{
|
||||
roomScores.Add(new MultiplayerScore
|
||||
{
|
||||
ID = i,
|
||||
Accuracy = 0.9 - 0.01 * i,
|
||||
EndedAt = DateTimeOffset.Now.Subtract(TimeSpan.FromHours(i)),
|
||||
Passed = true,
|
||||
Rank = ScoreRank.B,
|
||||
MaxCombo = 999,
|
||||
TotalScore = 999999 - i * 1000,
|
||||
User = new User
|
||||
{
|
||||
Id = 2,
|
||||
Username = $"peppy{i}",
|
||||
CoverUrl = "https://osu.ppy.sh/images/headers/profile-covers/c3.jpg",
|
||||
},
|
||||
Statistics =
|
||||
{
|
||||
{ HitResult.Miss, 1 },
|
||||
{ HitResult.Meh, 50 },
|
||||
{ HitResult.Good, 100 },
|
||||
{ HitResult.Great, 300 },
|
||||
}
|
||||
});
|
||||
AddUntilStep("wait for request to complete", () => requestComplete);
|
||||
AddWaitStep("wait for display", 5);
|
||||
}
|
||||
|
||||
((DummyAPIAccess)API).HandleRequest = request =>
|
||||
private void bindHandler(double delay = 0, ScoreInfo userScore = null, bool failRequests = false) => ((DummyAPIAccess)API).HandleRequest = request =>
|
||||
{
|
||||
requestComplete = false;
|
||||
|
||||
if (failRequests)
|
||||
{
|
||||
triggerFail(request, delay);
|
||||
return;
|
||||
}
|
||||
|
||||
switch (request)
|
||||
{
|
||||
case GetRoomPlaylistScoresRequest r:
|
||||
case ShowPlaylistUserScoreRequest s:
|
||||
if (userScore == null)
|
||||
triggerFail(s, delay);
|
||||
else
|
||||
triggerSuccess(s, createUserResponse(userScore), delay);
|
||||
break;
|
||||
|
||||
case IndexPlaylistScoresRequest i:
|
||||
triggerSuccess(i, createIndexResponse(i), delay);
|
||||
break;
|
||||
}
|
||||
};
|
||||
|
||||
private void triggerSuccess<T>(APIRequest<T> req, T result, double delay)
|
||||
where T : class
|
||||
{
|
||||
if (delay == 0)
|
||||
success();
|
||||
else
|
||||
@ -111,13 +210,167 @@ namespace osu.Game.Tests.Visual.Multiplayer
|
||||
|
||||
void success()
|
||||
{
|
||||
r.TriggerSuccess(new RoomPlaylistScores { Scores = roomScores });
|
||||
roomsReceived = true;
|
||||
requestComplete = true;
|
||||
req.TriggerSuccess(result);
|
||||
}
|
||||
}
|
||||
|
||||
break;
|
||||
private void triggerFail(APIRequest req, double delay)
|
||||
{
|
||||
if (delay == 0)
|
||||
fail();
|
||||
else
|
||||
{
|
||||
Task.Run(async () =>
|
||||
{
|
||||
await Task.Delay(TimeSpan.FromMilliseconds(delay));
|
||||
Schedule(fail);
|
||||
});
|
||||
}
|
||||
|
||||
void fail()
|
||||
{
|
||||
requestComplete = true;
|
||||
req.TriggerFailure(new WebException("Failed."));
|
||||
}
|
||||
}
|
||||
|
||||
private MultiplayerScore createUserResponse([NotNull] ScoreInfo userScore)
|
||||
{
|
||||
var multiplayerUserScore = new MultiplayerScore
|
||||
{
|
||||
ID = (int)(userScore.OnlineScoreID ?? currentScoreId++),
|
||||
Accuracy = userScore.Accuracy,
|
||||
EndedAt = userScore.Date,
|
||||
Passed = userScore.Passed,
|
||||
Rank = userScore.Rank,
|
||||
Position = 200,
|
||||
MaxCombo = userScore.MaxCombo,
|
||||
TotalScore = userScore.TotalScore,
|
||||
User = userScore.User,
|
||||
Statistics = userScore.Statistics,
|
||||
ScoresAround = new MultiplayerScoresAround
|
||||
{
|
||||
Higher = new MultiplayerScores(),
|
||||
Lower = new MultiplayerScores()
|
||||
}
|
||||
};
|
||||
|
||||
for (int i = 1; i <= scores_per_result; i++)
|
||||
{
|
||||
multiplayerUserScore.ScoresAround.Lower.Scores.Add(new MultiplayerScore
|
||||
{
|
||||
ID = currentScoreId++,
|
||||
Accuracy = userScore.Accuracy,
|
||||
EndedAt = userScore.Date,
|
||||
Passed = true,
|
||||
Rank = userScore.Rank,
|
||||
MaxCombo = userScore.MaxCombo,
|
||||
TotalScore = userScore.TotalScore - i,
|
||||
User = new User
|
||||
{
|
||||
Id = 2,
|
||||
Username = $"peppy{i}",
|
||||
CoverUrl = "https://osu.ppy.sh/images/headers/profile-covers/c3.jpg",
|
||||
},
|
||||
Statistics = userScore.Statistics
|
||||
});
|
||||
|
||||
multiplayerUserScore.ScoresAround.Higher.Scores.Add(new MultiplayerScore
|
||||
{
|
||||
ID = currentScoreId++,
|
||||
Accuracy = userScore.Accuracy,
|
||||
EndedAt = userScore.Date,
|
||||
Passed = true,
|
||||
Rank = userScore.Rank,
|
||||
MaxCombo = userScore.MaxCombo,
|
||||
TotalScore = userScore.TotalScore + i,
|
||||
User = new User
|
||||
{
|
||||
Id = 2,
|
||||
Username = $"peppy{i}",
|
||||
CoverUrl = "https://osu.ppy.sh/images/headers/profile-covers/c3.jpg",
|
||||
},
|
||||
Statistics = userScore.Statistics
|
||||
});
|
||||
}
|
||||
|
||||
addCursor(multiplayerUserScore.ScoresAround.Lower);
|
||||
addCursor(multiplayerUserScore.ScoresAround.Higher);
|
||||
|
||||
return multiplayerUserScore;
|
||||
}
|
||||
|
||||
private IndexedMultiplayerScores createIndexResponse(IndexPlaylistScoresRequest req)
|
||||
{
|
||||
var result = new IndexedMultiplayerScores();
|
||||
|
||||
long startTotalScore = req.Cursor?.Properties["total_score"].ToObject<long>() ?? 1000000;
|
||||
string sort = req.IndexParams?.Properties["sort"].ToObject<string>() ?? "score_desc";
|
||||
|
||||
for (int i = 1; i <= scores_per_result; i++)
|
||||
{
|
||||
result.Scores.Add(new MultiplayerScore
|
||||
{
|
||||
ID = currentScoreId++,
|
||||
Accuracy = 1,
|
||||
EndedAt = DateTimeOffset.Now,
|
||||
Passed = true,
|
||||
Rank = ScoreRank.X,
|
||||
MaxCombo = 1000,
|
||||
TotalScore = startTotalScore + (sort == "score_asc" ? i : -i),
|
||||
User = new User
|
||||
{
|
||||
Id = 2,
|
||||
Username = $"peppy{i}",
|
||||
CoverUrl = "https://osu.ppy.sh/images/headers/profile-covers/c3.jpg",
|
||||
},
|
||||
Statistics = new Dictionary<HitResult, int>
|
||||
{
|
||||
{ HitResult.Miss, 1 },
|
||||
{ HitResult.Meh, 50 },
|
||||
{ HitResult.Good, 100 },
|
||||
{ HitResult.Great, 300 }
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
addCursor(result);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
private void addCursor(MultiplayerScores scores)
|
||||
{
|
||||
scores.Cursor = new Cursor
|
||||
{
|
||||
Properties = new Dictionary<string, JToken>
|
||||
{
|
||||
{ "total_score", JToken.FromObject(scores.Scores[^1].TotalScore) },
|
||||
{ "score_id", JToken.FromObject(scores.Scores[^1].ID) },
|
||||
}
|
||||
};
|
||||
|
||||
scores.Params = new IndexScoresParams
|
||||
{
|
||||
Properties = new Dictionary<string, JToken>
|
||||
{
|
||||
{ "sort", JToken.FromObject(scores.Scores[^1].TotalScore > scores.Scores[^2].TotalScore ? "score_asc" : "score_desc") }
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
private class TestResultsScreen : TimeshiftResultsScreen
|
||||
{
|
||||
public new LoadingSpinner LeftSpinner => base.LeftSpinner;
|
||||
public new LoadingSpinner CentreSpinner => base.CentreSpinner;
|
||||
public new LoadingSpinner RightSpinner => base.RightSpinner;
|
||||
public new ScorePanelList ScorePanelList => base.ScorePanelList;
|
||||
|
||||
public TestResultsScreen(ScoreInfo score, int roomId, PlaylistItem playlistItem, bool allowRetry = true)
|
||||
: base(score, roomId, playlistItem, allowRetry)
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -81,7 +81,7 @@ namespace osu.Game.Tournament.Screens.Ladder.Components
|
||||
{
|
||||
}
|
||||
|
||||
private class SettingsRoundDropdown : LadderSettingsDropdown<TournamentRound>
|
||||
private class SettingsRoundDropdown : SettingsDropdown<TournamentRound>
|
||||
{
|
||||
public SettingsRoundDropdown(BindableList<TournamentRound> rounds)
|
||||
{
|
||||
|
@ -1,26 +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 osu.Game.Graphics.UserInterface;
|
||||
using osu.Game.Overlays.Settings;
|
||||
|
||||
namespace osu.Game.Tournament.Screens.Ladder.Components
|
||||
{
|
||||
public class LadderSettingsDropdown<T> : SettingsDropdown<T>
|
||||
{
|
||||
protected override OsuDropdown<T> CreateDropdown() => new DropdownControl();
|
||||
|
||||
private new class DropdownControl : SettingsDropdown<T>.DropdownControl
|
||||
{
|
||||
protected override DropdownMenu CreateMenu() => new Menu();
|
||||
|
||||
private new class Menu : OsuDropdownMenu
|
||||
{
|
||||
public Menu()
|
||||
{
|
||||
MaxHeight = 200;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -6,11 +6,12 @@ using System.Collections.Specialized;
|
||||
using System.Linq;
|
||||
using osu.Framework.Bindables;
|
||||
using osu.Framework.Extensions.IEnumerableExtensions;
|
||||
using osu.Game.Overlays.Settings;
|
||||
using osu.Game.Tournament.Models;
|
||||
|
||||
namespace osu.Game.Tournament.Screens.Ladder.Components
|
||||
{
|
||||
public class SettingsTeamDropdown : LadderSettingsDropdown<TournamentTeam>
|
||||
public class SettingsTeamDropdown : SettingsDropdown<TournamentTeam>
|
||||
{
|
||||
public SettingsTeamDropdown(BindableList<TournamentTeam> teams)
|
||||
{
|
||||
|
@ -136,6 +136,11 @@ namespace osu.Game.Online.API
|
||||
Success?.Invoke();
|
||||
}
|
||||
|
||||
internal void TriggerFailure(Exception e)
|
||||
{
|
||||
Failure?.Invoke(e);
|
||||
}
|
||||
|
||||
public void Cancel() => Fail(new OperationCanceledException(@"Request cancelled"));
|
||||
|
||||
public void Fail(Exception e)
|
||||
@ -166,7 +171,7 @@ namespace osu.Game.Online.API
|
||||
}
|
||||
|
||||
Logger.Log($@"Failing request {this} ({e})", LoggingTarget.Network);
|
||||
pendingFailure = () => Failure?.Invoke(e);
|
||||
pendingFailure = () => TriggerFailure(e);
|
||||
checkAndScheduleFailure();
|
||||
}
|
||||
|
||||
|
@ -15,6 +15,6 @@ namespace osu.Game.Online.API.Requests
|
||||
{
|
||||
[UsedImplicitly]
|
||||
[JsonExtensionData]
|
||||
public IDictionary<string, JToken> Properties;
|
||||
public IDictionary<string, JToken> Properties { get; set; } = new Dictionary<string, JToken>();
|
||||
}
|
||||
}
|
||||
|
@ -11,17 +11,20 @@ namespace osu.Game.Online.Multiplayer
|
||||
{
|
||||
private readonly int roomId;
|
||||
private readonly int playlistItemId;
|
||||
private readonly string versionHash;
|
||||
|
||||
public CreateRoomScoreRequest(int roomId, int playlistItemId)
|
||||
public CreateRoomScoreRequest(int roomId, int playlistItemId, string versionHash)
|
||||
{
|
||||
this.roomId = roomId;
|
||||
this.playlistItemId = playlistItemId;
|
||||
this.versionHash = versionHash;
|
||||
}
|
||||
|
||||
protected override WebRequest CreateWebRequest()
|
||||
{
|
||||
var req = base.CreateWebRequest();
|
||||
req.Method = HttpMethod.Post;
|
||||
req.AddParameter("version_hash", versionHash);
|
||||
return req;
|
||||
}
|
||||
|
||||
|
@ -1,29 +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 System.Collections.Generic;
|
||||
using Newtonsoft.Json;
|
||||
using osu.Game.Online.API;
|
||||
|
||||
namespace osu.Game.Online.Multiplayer
|
||||
{
|
||||
public class GetRoomPlaylistScoresRequest : APIRequest<RoomPlaylistScores>
|
||||
{
|
||||
private readonly int roomId;
|
||||
private readonly int playlistItemId;
|
||||
|
||||
public GetRoomPlaylistScoresRequest(int roomId, int playlistItemId)
|
||||
{
|
||||
this.roomId = roomId;
|
||||
this.playlistItemId = playlistItemId;
|
||||
}
|
||||
|
||||
protected override string Target => $@"rooms/{roomId}/playlist/{playlistItemId}/scores";
|
||||
}
|
||||
|
||||
public class RoomPlaylistScores
|
||||
{
|
||||
[JsonProperty("scores")]
|
||||
public List<MultiplayerScore> Scores { get; set; }
|
||||
}
|
||||
}
|
59
osu.Game/Online/Multiplayer/IndexPlaylistScoresRequest.cs
Normal file
@ -0,0 +1,59 @@
|
||||
// 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.Diagnostics;
|
||||
using JetBrains.Annotations;
|
||||
using osu.Framework.IO.Network;
|
||||
using osu.Game.Extensions;
|
||||
using osu.Game.Online.API;
|
||||
using osu.Game.Online.API.Requests;
|
||||
|
||||
namespace osu.Game.Online.Multiplayer
|
||||
{
|
||||
/// <summary>
|
||||
/// Returns a list of scores for the specified playlist item.
|
||||
/// </summary>
|
||||
public class IndexPlaylistScoresRequest : APIRequest<IndexedMultiplayerScores>
|
||||
{
|
||||
public readonly int RoomId;
|
||||
public readonly int PlaylistItemId;
|
||||
|
||||
[CanBeNull]
|
||||
public readonly Cursor Cursor;
|
||||
|
||||
[CanBeNull]
|
||||
public readonly IndexScoresParams IndexParams;
|
||||
|
||||
public IndexPlaylistScoresRequest(int roomId, int playlistItemId)
|
||||
{
|
||||
RoomId = roomId;
|
||||
PlaylistItemId = playlistItemId;
|
||||
}
|
||||
|
||||
public IndexPlaylistScoresRequest(int roomId, int playlistItemId, [NotNull] Cursor cursor, [NotNull] IndexScoresParams indexParams)
|
||||
: this(roomId, playlistItemId)
|
||||
{
|
||||
Cursor = cursor;
|
||||
IndexParams = indexParams;
|
||||
}
|
||||
|
||||
protected override WebRequest CreateWebRequest()
|
||||
{
|
||||
var req = base.CreateWebRequest();
|
||||
|
||||
if (Cursor != null)
|
||||
{
|
||||
Debug.Assert(IndexParams != null);
|
||||
|
||||
req.AddCursor(Cursor);
|
||||
|
||||
foreach (var (key, value) in IndexParams.Properties)
|
||||
req.AddParameter(key, value.ToString());
|
||||
}
|
||||
|
||||
return req;
|
||||
}
|
||||
|
||||
protected override string Target => $@"rooms/{RoomId}/playlist/{PlaylistItemId}/scores";
|
||||
}
|
||||
}
|
20
osu.Game/Online/Multiplayer/IndexScoresParams.cs
Normal file
@ -0,0 +1,20 @@
|
||||
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
|
||||
// See the LICENCE file in the repository root for full licence text.
|
||||
|
||||
using System.Collections.Generic;
|
||||
using JetBrains.Annotations;
|
||||
using Newtonsoft.Json;
|
||||
using Newtonsoft.Json.Linq;
|
||||
|
||||
namespace osu.Game.Online.Multiplayer
|
||||
{
|
||||
/// <summary>
|
||||
/// A collection of parameters which should be passed to the index endpoint to fetch the next page.
|
||||
/// </summary>
|
||||
public class IndexScoresParams
|
||||
{
|
||||
[UsedImplicitly]
|
||||
[JsonExtensionData]
|
||||
public IDictionary<string, JToken> Properties { get; set; } = new Dictionary<string, JToken>();
|
||||
}
|
||||
}
|
27
osu.Game/Online/Multiplayer/IndexedMultiplayerScores.cs
Normal file
@ -0,0 +1,27 @@
|
||||
// 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 JetBrains.Annotations;
|
||||
using Newtonsoft.Json;
|
||||
|
||||
namespace osu.Game.Online.Multiplayer
|
||||
{
|
||||
/// <summary>
|
||||
/// A <see cref="MultiplayerScores"/> object returned via a <see cref="IndexPlaylistScoresRequest"/>.
|
||||
/// </summary>
|
||||
public class IndexedMultiplayerScores : MultiplayerScores
|
||||
{
|
||||
/// <summary>
|
||||
/// The total scores in the playlist item.
|
||||
/// </summary>
|
||||
[JsonProperty("total")]
|
||||
public int? TotalScores { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// The user's score, if any.
|
||||
/// </summary>
|
||||
[JsonProperty("user_score")]
|
||||
[CanBeNull]
|
||||
public MultiplayerScore UserScore { get; set; }
|
||||
}
|
||||
}
|
@ -4,6 +4,7 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using JetBrains.Annotations;
|
||||
using Newtonsoft.Json;
|
||||
using Newtonsoft.Json.Converters;
|
||||
using osu.Game.Online.API;
|
||||
@ -47,6 +48,19 @@ namespace osu.Game.Online.Multiplayer
|
||||
[JsonProperty("ended_at")]
|
||||
public DateTimeOffset EndedAt { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// The position of this score, starting at 1.
|
||||
/// </summary>
|
||||
[JsonProperty("position")]
|
||||
public int? Position { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Any scores in the room around this score.
|
||||
/// </summary>
|
||||
[JsonProperty("scores_around")]
|
||||
[CanBeNull]
|
||||
public MultiplayerScoresAround ScoresAround { get; set; }
|
||||
|
||||
public ScoreInfo CreateScoreInfo(PlaylistItem playlistItem)
|
||||
{
|
||||
var rulesetInstance = playlistItem.Ruleset.Value.CreateInstance();
|
||||
@ -66,7 +80,8 @@ namespace osu.Game.Online.Multiplayer
|
||||
Date = EndedAt,
|
||||
Hash = string.Empty, // todo: temporary?
|
||||
Rank = Rank,
|
||||
Mods = Mods?.Select(m => m.ToMod(rulesetInstance)).ToArray() ?? Array.Empty<Mod>()
|
||||
Mods = Mods?.Select(m => m.ToMod(rulesetInstance)).ToArray() ?? Array.Empty<Mod>(),
|
||||
Position = Position,
|
||||
};
|
||||
|
||||
return scoreInfo;
|
||||
|
27
osu.Game/Online/Multiplayer/MultiplayerScores.cs
Normal file
@ -0,0 +1,27 @@
|
||||
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
|
||||
// See the LICENCE file in the repository root for full licence text.
|
||||
|
||||
using System.Collections.Generic;
|
||||
using Newtonsoft.Json;
|
||||
using osu.Game.Online.API.Requests;
|
||||
|
||||
namespace osu.Game.Online.Multiplayer
|
||||
{
|
||||
/// <summary>
|
||||
/// An object which contains scores and related data for fetching next pages.
|
||||
/// </summary>
|
||||
public class MultiplayerScores : ResponseWithCursor
|
||||
{
|
||||
/// <summary>
|
||||
/// The scores.
|
||||
/// </summary>
|
||||
[JsonProperty("scores")]
|
||||
public List<MultiplayerScore> Scores { get; set; } = new List<MultiplayerScore>();
|
||||
|
||||
/// <summary>
|
||||
/// The parameters to be used to fetch the next page.
|
||||
/// </summary>
|
||||
[JsonProperty("params")]
|
||||
public IndexScoresParams Params { get; set; } = new IndexScoresParams();
|
||||
}
|
||||
}
|
28
osu.Game/Online/Multiplayer/MultiplayerScoresAround.cs
Normal file
@ -0,0 +1,28 @@
|
||||
// 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 JetBrains.Annotations;
|
||||
using Newtonsoft.Json;
|
||||
|
||||
namespace osu.Game.Online.Multiplayer
|
||||
{
|
||||
/// <summary>
|
||||
/// An object which stores scores higher and lower than the user's score.
|
||||
/// </summary>
|
||||
public class MultiplayerScoresAround
|
||||
{
|
||||
/// <summary>
|
||||
/// Scores sorted "higher" than the user's score, depending on the sorting order.
|
||||
/// </summary>
|
||||
[JsonProperty("higher")]
|
||||
[CanBeNull]
|
||||
public MultiplayerScores Higher { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Scores sorted "lower" than the user's score, depending on the sorting order.
|
||||
/// </summary>
|
||||
[JsonProperty("lower")]
|
||||
[CanBeNull]
|
||||
public MultiplayerScores Lower { get; set; }
|
||||
}
|
||||
}
|
23
osu.Game/Online/Multiplayer/ShowPlaylistUserScoreRequest.cs
Normal file
@ -0,0 +1,23 @@
|
||||
// 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.Online.API;
|
||||
|
||||
namespace osu.Game.Online.Multiplayer
|
||||
{
|
||||
public class ShowPlaylistUserScoreRequest : APIRequest<MultiplayerScore>
|
||||
{
|
||||
private readonly int roomId;
|
||||
private readonly int playlistItemId;
|
||||
private readonly long userId;
|
||||
|
||||
public ShowPlaylistUserScoreRequest(int roomId, int playlistItemId, long userId)
|
||||
{
|
||||
this.roomId = roomId;
|
||||
this.playlistItemId = playlistItemId;
|
||||
this.userId = userId;
|
||||
}
|
||||
|
||||
protected override string Target => $"rooms/{roomId}/playlist/{playlistItemId}/scores/users/{userId}";
|
||||
}
|
||||
}
|
@ -11,6 +11,7 @@ using osu.Framework.Allocation;
|
||||
using osu.Framework.Audio;
|
||||
using osu.Framework.Bindables;
|
||||
using osu.Framework.Development;
|
||||
using osu.Framework.Extensions;
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Framework.Graphics.Containers;
|
||||
using osu.Framework.IO.Stores;
|
||||
@ -97,6 +98,11 @@ namespace osu.Game
|
||||
|
||||
public virtual Version AssemblyVersion => Assembly.GetEntryAssembly()?.GetName().Version ?? new Version();
|
||||
|
||||
/// <summary>
|
||||
/// MD5 representation of the game executable.
|
||||
/// </summary>
|
||||
public string VersionHash { get; private set; }
|
||||
|
||||
public bool IsDeployedBuild => AssemblyVersion.Major > 0;
|
||||
|
||||
public virtual string Version
|
||||
@ -128,6 +134,9 @@ namespace osu.Game
|
||||
[BackgroundDependencyLoader]
|
||||
private void load()
|
||||
{
|
||||
using (var str = File.OpenRead(typeof(OsuGameBase).Assembly.Location))
|
||||
VersionHash = str.ComputeMD5Hash();
|
||||
|
||||
Resources.AddStore(new DllResourceStore(OsuResources.ResourceAssembly));
|
||||
|
||||
dependencies.Cache(contextFactory = new DatabaseContextFactory(Storage));
|
||||
|
@ -236,8 +236,8 @@ namespace osu.Game.Overlays
|
||||
{
|
||||
if (beatmap is Bindable<WorkingBeatmap> working)
|
||||
working.Value = beatmaps.GetWorkingBeatmap(playable.Beatmaps.First(), beatmap.Value);
|
||||
beatmap.Value.Track.Restart();
|
||||
|
||||
restartTrack();
|
||||
return PreviousTrackResult.Previous;
|
||||
}
|
||||
|
||||
@ -262,13 +262,21 @@ namespace osu.Game.Overlays
|
||||
{
|
||||
if (beatmap is Bindable<WorkingBeatmap> working)
|
||||
working.Value = beatmaps.GetWorkingBeatmap(playable.Beatmaps.First(), beatmap.Value);
|
||||
beatmap.Value.Track.Restart();
|
||||
|
||||
restartTrack();
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
private void restartTrack()
|
||||
{
|
||||
// if not scheduled, the previously track will be stopped one frame later (see ScheduleAfterChildren logic in GameBase).
|
||||
// we probably want to move this to a central method for switching to a new working beatmap in the future.
|
||||
Schedule(() => beatmap.Value.Track.Restart());
|
||||
}
|
||||
|
||||
private WorkingBeatmap current;
|
||||
|
||||
private TrackChangeDirection? queuedDirection;
|
||||
|
@ -41,7 +41,7 @@ namespace osu.Game.Overlays.Profile
|
||||
Masking = true,
|
||||
Children = new Drawable[]
|
||||
{
|
||||
coverContainer = new UserCoverBackground
|
||||
coverContainer = new ProfileCoverBackground
|
||||
{
|
||||
RelativeSizeAxes = Axes.Both,
|
||||
},
|
||||
@ -100,5 +100,10 @@ namespace osu.Game.Overlays.Profile
|
||||
IconTexture = "Icons/profile";
|
||||
}
|
||||
}
|
||||
|
||||
private class ProfileCoverBackground : UserCoverBackground
|
||||
{
|
||||
protected override double LoadDelay => 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -116,8 +116,6 @@ namespace osu.Game.Overlays.Settings.Sections
|
||||
private class SkinDropdownControl : DropdownControl
|
||||
{
|
||||
protected override string GenerateItemText(SkinInfo item) => item.ToString();
|
||||
|
||||
protected override DropdownMenu CreateMenu() => base.CreateMenu().With(m => m.MaxHeight = 200);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -38,6 +38,8 @@ namespace osu.Game.Overlays.Settings
|
||||
Margin = new MarginPadding { Top = 5 };
|
||||
RelativeSizeAxes = Axes.X;
|
||||
}
|
||||
|
||||
protected override DropdownMenu CreateMenu() => base.CreateMenu().With(m => m.MaxHeight = 200);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -65,11 +65,15 @@ namespace osu.Game.Rulesets
|
||||
// the requesting assembly may be located out of the executable's base directory, thus requiring manual resolving of its dependencies.
|
||||
// this attempts resolving the ruleset dependencies on game core and framework assemblies by returning assemblies with the same assembly name
|
||||
// already loaded in the AppDomain.
|
||||
foreach (var curAsm in AppDomain.CurrentDomain.GetAssemblies())
|
||||
{
|
||||
if (asm.Name.Equals(curAsm.GetName().Name, StringComparison.Ordinal))
|
||||
return curAsm;
|
||||
}
|
||||
var domainAssembly = AppDomain.CurrentDomain.GetAssemblies()
|
||||
// Given name is always going to be equally-or-more qualified than the assembly name.
|
||||
.Where(a => args.Name.Contains(a.GetName().Name, StringComparison.Ordinal))
|
||||
// Pick the greatest assembly version.
|
||||
.OrderByDescending(a => a.GetName().Version)
|
||||
.FirstOrDefault();
|
||||
|
||||
if (domainAssembly != null)
|
||||
return domainAssembly;
|
||||
|
||||
return loadedAssemblies.Keys.FirstOrDefault(a => a.FullName == asm.FullName);
|
||||
}
|
||||
|
@ -179,6 +179,13 @@ namespace osu.Game.Scoring
|
||||
[JsonIgnore]
|
||||
public bool DeletePending { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// The position of this score, starting at 1.
|
||||
/// </summary>
|
||||
[NotMapped]
|
||||
[JsonProperty("position")]
|
||||
public int? Position { get; set; }
|
||||
|
||||
[Serializable]
|
||||
protected class DeserializedMod : IMod
|
||||
{
|
||||
|
@ -58,7 +58,7 @@ namespace osu.Game.Screens.Multi.Play
|
||||
if (!playlistItem.RequiredMods.All(m => Mods.Value.Any(m.Equals)))
|
||||
throw new InvalidOperationException("Current Mods do not match PlaylistItem's RequiredMods");
|
||||
|
||||
var req = new CreateRoomScoreRequest(roomId.Value ?? 0, playlistItem.ID);
|
||||
var req = new CreateRoomScoreRequest(roomId.Value ?? 0, playlistItem.ID, Game.VersionHash);
|
||||
req.Success += r => token = r.ID;
|
||||
req.Failure += e =>
|
||||
{
|
||||
|
@ -3,7 +3,9 @@
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
using System.Linq;
|
||||
using JetBrains.Annotations;
|
||||
using osu.Framework.Allocation;
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Framework.Graphics.Containers;
|
||||
@ -20,7 +22,15 @@ namespace osu.Game.Screens.Multi.Ranking
|
||||
private readonly int roomId;
|
||||
private readonly PlaylistItem playlistItem;
|
||||
|
||||
private LoadingSpinner loadingLayer;
|
||||
protected LoadingSpinner LeftSpinner { get; private set; }
|
||||
protected LoadingSpinner CentreSpinner { get; private set; }
|
||||
protected LoadingSpinner RightSpinner { get; private set; }
|
||||
|
||||
private MultiplayerScores higherScores;
|
||||
private MultiplayerScores lowerScores;
|
||||
|
||||
[Resolved]
|
||||
private IAPIProvider api { get; set; }
|
||||
|
||||
public TimeshiftResultsScreen(ScoreInfo score, int roomId, PlaylistItem playlistItem, bool allowRetry = true)
|
||||
: base(score, allowRetry)
|
||||
@ -32,29 +42,209 @@ namespace osu.Game.Screens.Multi.Ranking
|
||||
[BackgroundDependencyLoader]
|
||||
private void load()
|
||||
{
|
||||
AddInternal(loadingLayer = new LoadingLayer
|
||||
AddInternal(new Container
|
||||
{
|
||||
RelativeSizeAxes = Axes.Both,
|
||||
Padding = new MarginPadding { Bottom = TwoLayerButton.SIZE_EXTENDED.Y },
|
||||
Children = new Drawable[]
|
||||
{
|
||||
LeftSpinner = new PanelListLoadingSpinner(ScorePanelList)
|
||||
{
|
||||
Anchor = Anchor.CentreLeft,
|
||||
Origin = Anchor.Centre,
|
||||
},
|
||||
CentreSpinner = new PanelListLoadingSpinner(ScorePanelList)
|
||||
{
|
||||
Anchor = Anchor.Centre,
|
||||
Origin = Anchor.Centre,
|
||||
X = -10,
|
||||
State = { Value = Score == null ? Visibility.Visible : Visibility.Hidden },
|
||||
Padding = new MarginPadding { Bottom = TwoLayerButton.SIZE_EXTENDED.Y }
|
||||
},
|
||||
RightSpinner = new PanelListLoadingSpinner(ScorePanelList)
|
||||
{
|
||||
Anchor = Anchor.CentreRight,
|
||||
Origin = Anchor.Centre,
|
||||
},
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
protected override APIRequest FetchScores(Action<IEnumerable<ScoreInfo>> scoresCallback)
|
||||
{
|
||||
var req = new GetRoomPlaylistScoresRequest(roomId, playlistItem.ID);
|
||||
// This performs two requests:
|
||||
// 1. A request to show the user's score (and scores around).
|
||||
// 2. If that fails, a request to index the room starting from the highest score.
|
||||
|
||||
req.Success += r =>
|
||||
var userScoreReq = new ShowPlaylistUserScoreRequest(roomId, playlistItem.ID, api.LocalUser.Value.Id);
|
||||
|
||||
userScoreReq.Success += userScore =>
|
||||
{
|
||||
scoresCallback?.Invoke(r.Scores.Where(s => s.ID != Score?.OnlineScoreID).Select(s => s.CreateScoreInfo(playlistItem)));
|
||||
loadingLayer.Hide();
|
||||
var allScores = new List<MultiplayerScore> { userScore };
|
||||
|
||||
if (userScore.ScoresAround?.Higher != null)
|
||||
{
|
||||
allScores.AddRange(userScore.ScoresAround.Higher.Scores);
|
||||
higherScores = userScore.ScoresAround.Higher;
|
||||
|
||||
Debug.Assert(userScore.Position != null);
|
||||
setPositions(higherScores, userScore.Position.Value, -1);
|
||||
}
|
||||
|
||||
if (userScore.ScoresAround?.Lower != null)
|
||||
{
|
||||
allScores.AddRange(userScore.ScoresAround.Lower.Scores);
|
||||
lowerScores = userScore.ScoresAround.Lower;
|
||||
|
||||
Debug.Assert(userScore.Position != null);
|
||||
setPositions(lowerScores, userScore.Position.Value, 1);
|
||||
}
|
||||
|
||||
performSuccessCallback(scoresCallback, allScores);
|
||||
};
|
||||
|
||||
req.Failure += _ => loadingLayer.Hide();
|
||||
// On failure, fallback to a normal index.
|
||||
userScoreReq.Failure += _ => api.Queue(createIndexRequest(scoresCallback));
|
||||
|
||||
return req;
|
||||
return userScoreReq;
|
||||
}
|
||||
|
||||
protected override APIRequest FetchNextPage(int direction, Action<IEnumerable<ScoreInfo>> scoresCallback)
|
||||
{
|
||||
Debug.Assert(direction == 1 || direction == -1);
|
||||
|
||||
MultiplayerScores pivot = direction == -1 ? higherScores : lowerScores;
|
||||
|
||||
if (pivot?.Cursor == null)
|
||||
return null;
|
||||
|
||||
if (pivot == higherScores)
|
||||
LeftSpinner.Show();
|
||||
else
|
||||
RightSpinner.Show();
|
||||
|
||||
return createIndexRequest(scoresCallback, pivot);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates a <see cref="IndexPlaylistScoresRequest"/> with an optional score pivot.
|
||||
/// </summary>
|
||||
/// <remarks>Does not queue the request.</remarks>
|
||||
/// <param name="scoresCallback">The callback to perform with the resulting scores.</param>
|
||||
/// <param name="pivot">An optional score pivot to retrieve scores around. Can be null to retrieve scores from the highest score.</param>
|
||||
/// <returns>The indexing <see cref="APIRequest"/>.</returns>
|
||||
private APIRequest createIndexRequest(Action<IEnumerable<ScoreInfo>> scoresCallback, [CanBeNull] MultiplayerScores pivot = null)
|
||||
{
|
||||
var indexReq = pivot != null
|
||||
? new IndexPlaylistScoresRequest(roomId, playlistItem.ID, pivot.Cursor, pivot.Params)
|
||||
: new IndexPlaylistScoresRequest(roomId, playlistItem.ID);
|
||||
|
||||
indexReq.Success += r =>
|
||||
{
|
||||
if (pivot == lowerScores)
|
||||
{
|
||||
lowerScores = r;
|
||||
setPositions(r, pivot, 1);
|
||||
}
|
||||
else
|
||||
{
|
||||
higherScores = r;
|
||||
setPositions(r, pivot, -1);
|
||||
}
|
||||
|
||||
performSuccessCallback(scoresCallback, r.Scores, r);
|
||||
};
|
||||
|
||||
indexReq.Failure += _ => hideLoadingSpinners(pivot);
|
||||
|
||||
return indexReq;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Transforms returned <see cref="MultiplayerScores"/> into <see cref="ScoreInfo"/>s, ensure the <see cref="ScorePanelList"/> is put into a sane state, and invokes a given success callback.
|
||||
/// </summary>
|
||||
/// <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)
|
||||
{
|
||||
var scoreInfos = new List<ScoreInfo>(scores.Select(s => s.CreateScoreInfo(playlistItem)));
|
||||
|
||||
// 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(() =>
|
||||
{
|
||||
// Prefer selecting the local user's score, or otherwise default to the first visible score.
|
||||
SelectedScore.Value = scoreInfos.FirstOrDefault(s => s.User.Id == 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.OnlineScoreID != Score?.OnlineScoreID));
|
||||
|
||||
hideLoadingSpinners(pivot);
|
||||
}
|
||||
|
||||
private void hideLoadingSpinners([CanBeNull] MultiplayerScores pivot = null)
|
||||
{
|
||||
CentreSpinner.Hide();
|
||||
|
||||
if (pivot == lowerScores)
|
||||
RightSpinner.Hide();
|
||||
else if (pivot == higherScores)
|
||||
LeftSpinner.Hide();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Applies positions to all <see cref="MultiplayerScore"/>s referenced to a given pivot.
|
||||
/// </summary>
|
||||
/// <param name="scores">The <see cref="MultiplayerScores"/> to set positions on.</param>
|
||||
/// <param name="pivot">The pivot.</param>
|
||||
/// <param name="increment">The amount to increment the pivot position by for each <see cref="MultiplayerScore"/> in <paramref name="scores"/>.</param>
|
||||
private void setPositions([NotNull] MultiplayerScores scores, [CanBeNull] MultiplayerScores pivot, int increment)
|
||||
=> setPositions(scores, pivot?.Scores[^1].Position ?? 0, increment);
|
||||
|
||||
/// <summary>
|
||||
/// Applies positions to all <see cref="MultiplayerScore"/>s referenced to a given pivot.
|
||||
/// </summary>
|
||||
/// <param name="scores">The <see cref="MultiplayerScores"/> to set positions on.</param>
|
||||
/// <param name="pivotPosition">The pivot position.</param>
|
||||
/// <param name="increment">The amount to increment the pivot position by for each <see cref="MultiplayerScore"/> in <paramref name="scores"/>.</param>
|
||||
private void setPositions([NotNull] MultiplayerScores scores, int pivotPosition, int increment)
|
||||
{
|
||||
foreach (var s in scores.Scores)
|
||||
{
|
||||
pivotPosition += increment;
|
||||
s.Position = pivotPosition;
|
||||
}
|
||||
}
|
||||
|
||||
private class PanelListLoadingSpinner : LoadingSpinner
|
||||
{
|
||||
private readonly ScorePanelList list;
|
||||
|
||||
/// <summary>
|
||||
/// Creates a new <see cref="PanelListLoadingSpinner"/>.
|
||||
/// </summary>
|
||||
/// <param name="list">The list to track.</param>
|
||||
/// <param name="withBox">Whether the spinner should have a surrounding black box for visibility.</param>
|
||||
public PanelListLoadingSpinner(ScorePanelList list, bool withBox = true)
|
||||
: base(withBox)
|
||||
{
|
||||
this.list = list;
|
||||
}
|
||||
|
||||
protected override void Update()
|
||||
{
|
||||
base.Update();
|
||||
|
||||
float panelOffset = list.DrawWidth / 2 - ScorePanel.EXPANDED_WIDTH;
|
||||
|
||||
if ((Anchor & Anchor.x0) > 0)
|
||||
X = (float)(panelOffset - list.Current);
|
||||
else if ((Anchor & Anchor.x2) > 0)
|
||||
X = (float)(list.ScrollableExtent - list.Current - panelOffset);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -0,0 +1,37 @@
|
||||
// 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.Framework.Allocation;
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Framework.Graphics.Containers;
|
||||
using osu.Game.Graphics;
|
||||
using osu.Game.Graphics.Sprites;
|
||||
using osu.Game.Scoring;
|
||||
|
||||
namespace osu.Game.Screens.Ranking.Contracted
|
||||
{
|
||||
public class ContractedPanelTopContent : CompositeDrawable
|
||||
{
|
||||
private readonly ScoreInfo score;
|
||||
|
||||
public ContractedPanelTopContent(ScoreInfo score)
|
||||
{
|
||||
this.score = score;
|
||||
|
||||
RelativeSizeAxes = Axes.Both;
|
||||
}
|
||||
|
||||
[BackgroundDependencyLoader]
|
||||
private void load()
|
||||
{
|
||||
InternalChild = new OsuSpriteText
|
||||
{
|
||||
Anchor = Anchor.TopCentre,
|
||||
Origin = Anchor.TopCentre,
|
||||
Y = 6,
|
||||
Text = score.Position != null ? $"#{score.Position}" : string.Empty,
|
||||
Font = OsuFont.GetFont(size: 18, weight: FontWeight.Bold)
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
@ -37,7 +37,8 @@ namespace osu.Game.Screens.Ranking
|
||||
public readonly Bindable<ScoreInfo> SelectedScore = new Bindable<ScoreInfo>();
|
||||
|
||||
public readonly ScoreInfo Score;
|
||||
private readonly bool allowRetry;
|
||||
|
||||
protected ScorePanelList ScorePanelList { get; private set; }
|
||||
|
||||
[Resolved(CanBeNull = true)]
|
||||
private Player player { get; set; }
|
||||
@ -47,9 +48,13 @@ namespace osu.Game.Screens.Ranking
|
||||
|
||||
private StatisticsPanel statisticsPanel;
|
||||
private Drawable bottomPanel;
|
||||
private ScorePanelList scorePanelList;
|
||||
private Container<ScorePanel> detachedPanelContainer;
|
||||
|
||||
private bool fetchedInitialScores;
|
||||
private APIRequest nextPageRequest;
|
||||
|
||||
private readonly bool allowRetry;
|
||||
|
||||
protected ResultsScreen(ScoreInfo score, bool allowRetry = true)
|
||||
{
|
||||
Score = score;
|
||||
@ -84,7 +89,7 @@ namespace osu.Game.Screens.Ranking
|
||||
RelativeSizeAxes = Axes.Both,
|
||||
Score = { BindTarget = SelectedScore }
|
||||
},
|
||||
scorePanelList = new ScorePanelList
|
||||
ScorePanelList = new ScorePanelList
|
||||
{
|
||||
RelativeSizeAxes = Axes.Both,
|
||||
SelectedScore = { BindTarget = SelectedScore },
|
||||
@ -142,7 +147,7 @@ namespace osu.Game.Screens.Ranking
|
||||
};
|
||||
|
||||
if (Score != null)
|
||||
scorePanelList.AddScore(Score);
|
||||
ScorePanelList.AddScore(Score);
|
||||
|
||||
if (player != null && allowRetry)
|
||||
{
|
||||
@ -164,11 +169,7 @@ namespace osu.Game.Screens.Ranking
|
||||
{
|
||||
base.LoadComplete();
|
||||
|
||||
var req = FetchScores(scores => Schedule(() =>
|
||||
{
|
||||
foreach (var s in scores)
|
||||
addScore(s);
|
||||
}));
|
||||
var req = FetchScores(fetchScoresCallback);
|
||||
|
||||
if (req != null)
|
||||
api.Queue(req);
|
||||
@ -176,6 +177,28 @@ namespace osu.Game.Screens.Ranking
|
||||
statisticsPanel.State.BindValueChanged(onStatisticsStateChanged, true);
|
||||
}
|
||||
|
||||
protected override void Update()
|
||||
{
|
||||
base.Update();
|
||||
|
||||
if (fetchedInitialScores && nextPageRequest == null)
|
||||
{
|
||||
if (ScorePanelList.IsScrolledToStart)
|
||||
nextPageRequest = FetchNextPage(-1, fetchScoresCallback);
|
||||
else if (ScorePanelList.IsScrolledToEnd)
|
||||
nextPageRequest = FetchNextPage(1, fetchScoresCallback);
|
||||
|
||||
if (nextPageRequest != null)
|
||||
{
|
||||
// Scheduled after children to give the list a chance to update its scroll position and not potentially trigger a second request too early.
|
||||
nextPageRequest.Success += () => ScheduleAfterChildren(() => nextPageRequest = null);
|
||||
nextPageRequest.Failure += _ => ScheduleAfterChildren(() => nextPageRequest = null);
|
||||
|
||||
api.Queue(nextPageRequest);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Performs a fetch/refresh of scores to be displayed.
|
||||
/// </summary>
|
||||
@ -183,6 +206,22 @@ namespace osu.Game.Screens.Ranking
|
||||
/// <returns>An <see cref="APIRequest"/> responsible for the fetch operation. This will be queued and performed automatically.</returns>
|
||||
protected virtual APIRequest FetchScores(Action<IEnumerable<ScoreInfo>> scoresCallback) => null;
|
||||
|
||||
/// <summary>
|
||||
/// Performs a fetch of the next page of scores. This is invoked every frame until a non-null <see cref="APIRequest"/> is returned.
|
||||
/// </summary>
|
||||
/// <param name="direction">The fetch direction. -1 to fetch scores greater than the current start of the list, and 1 to fetch scores lower than the current end of the list.</param>
|
||||
/// <param name="scoresCallback">A callback which should be called when fetching is completed. Scheduling is not required.</param>
|
||||
/// <returns>An <see cref="APIRequest"/> responsible for the fetch operation. This will be queued and performed automatically.</returns>
|
||||
protected virtual APIRequest FetchNextPage(int direction, Action<IEnumerable<ScoreInfo>> scoresCallback) => null;
|
||||
|
||||
private void fetchScoresCallback(IEnumerable<ScoreInfo> scores) => Schedule(() =>
|
||||
{
|
||||
foreach (var s in scores)
|
||||
addScore(s);
|
||||
|
||||
fetchedInitialScores = true;
|
||||
});
|
||||
|
||||
public override void OnEntering(IScreen last)
|
||||
{
|
||||
base.OnEntering(last);
|
||||
@ -213,7 +252,7 @@ namespace osu.Game.Screens.Ranking
|
||||
|
||||
private void addScore(ScoreInfo score)
|
||||
{
|
||||
var panel = scorePanelList.AddScore(score);
|
||||
var panel = ScorePanelList.AddScore(score);
|
||||
|
||||
if (detachedPanel != null)
|
||||
panel.Alpha = 0;
|
||||
@ -226,11 +265,11 @@ namespace osu.Game.Screens.Ranking
|
||||
if (state.NewValue == Visibility.Visible)
|
||||
{
|
||||
// Detach the panel in its original location, and move into the desired location in the local container.
|
||||
var expandedPanel = scorePanelList.GetPanelForScore(SelectedScore.Value);
|
||||
var expandedPanel = ScorePanelList.GetPanelForScore(SelectedScore.Value);
|
||||
var screenSpacePos = expandedPanel.ScreenSpaceDrawQuad.TopLeft;
|
||||
|
||||
// Detach and move into the local container.
|
||||
scorePanelList.Detach(expandedPanel);
|
||||
ScorePanelList.Detach(expandedPanel);
|
||||
detachedPanelContainer.Add(expandedPanel);
|
||||
|
||||
// Move into its original location in the local container first, then to the final location.
|
||||
@ -240,9 +279,9 @@ namespace osu.Game.Screens.Ranking
|
||||
.MoveTo(new Vector2(StatisticsPanel.SIDE_PADDING, origLocation.Y), 150, Easing.OutQuint);
|
||||
|
||||
// Hide contracted panels.
|
||||
foreach (var contracted in scorePanelList.GetScorePanels().Where(p => p.State == PanelState.Contracted))
|
||||
foreach (var contracted in ScorePanelList.GetScorePanels().Where(p => p.State == PanelState.Contracted))
|
||||
contracted.FadeOut(150, Easing.OutQuint);
|
||||
scorePanelList.HandleInput = false;
|
||||
ScorePanelList.HandleInput = false;
|
||||
|
||||
// Dim background.
|
||||
Background.FadeTo(0.1f, 150);
|
||||
@ -255,7 +294,7 @@ namespace osu.Game.Screens.Ranking
|
||||
|
||||
// Remove from the local container and re-attach.
|
||||
detachedPanelContainer.Remove(detachedPanel);
|
||||
scorePanelList.Attach(detachedPanel);
|
||||
ScorePanelList.Attach(detachedPanel);
|
||||
|
||||
// Move into its original location in the attached container first, then to the final location.
|
||||
var origLocation = detachedPanel.Parent.ToLocalSpace(screenSpacePos);
|
||||
@ -264,9 +303,9 @@ namespace osu.Game.Screens.Ranking
|
||||
.MoveTo(new Vector2(0, origLocation.Y), 150, Easing.OutQuint);
|
||||
|
||||
// Show contracted panels.
|
||||
foreach (var contracted in scorePanelList.GetScorePanels().Where(p => p.State == PanelState.Contracted))
|
||||
foreach (var contracted in ScorePanelList.GetScorePanels().Where(p => p.State == PanelState.Contracted))
|
||||
contracted.FadeIn(150, Easing.OutQuint);
|
||||
scorePanelList.HandleInput = true;
|
||||
ScorePanelList.HandleInput = true;
|
||||
|
||||
// Un-dim background.
|
||||
Background.FadeTo(0.5f, 150);
|
||||
|
@ -151,7 +151,7 @@ namespace osu.Game.Screens.Ranking
|
||||
RelativeSizeAxes = Axes.Both,
|
||||
User = Score.User,
|
||||
Colour = ColourInfo.GradientVertical(Color4.White.Opacity(0.5f), Color4Extensions.FromHex("#444").Opacity(0))
|
||||
},
|
||||
}
|
||||
}
|
||||
},
|
||||
middleLayerContentContainer = new Container { RelativeSizeAxes = Axes.Both }
|
||||
@ -203,8 +203,8 @@ namespace osu.Game.Screens.Ranking
|
||||
topLayerBackground.FadeColour(expanded_top_layer_colour, resize_duration, Easing.OutQuint);
|
||||
middleLayerBackground.FadeColour(expanded_middle_layer_colour, resize_duration, Easing.OutQuint);
|
||||
|
||||
topLayerContentContainer.Add(middleLayerContent = new ExpandedPanelTopContent(Score.User).With(d => d.Alpha = 0));
|
||||
middleLayerContentContainer.Add(topLayerContent = new ExpandedPanelMiddleContent(Score).With(d => d.Alpha = 0));
|
||||
topLayerContentContainer.Add(topLayerContent = new ExpandedPanelTopContent(Score.User).With(d => d.Alpha = 0));
|
||||
middleLayerContentContainer.Add(middleLayerContent = new ExpandedPanelMiddleContent(Score).With(d => d.Alpha = 0));
|
||||
break;
|
||||
|
||||
case PanelState.Contracted:
|
||||
@ -213,7 +213,8 @@ namespace osu.Game.Screens.Ranking
|
||||
topLayerBackground.FadeColour(contracted_top_layer_colour, resize_duration, Easing.OutQuint);
|
||||
middleLayerBackground.FadeColour(contracted_middle_layer_colour, resize_duration, Easing.OutQuint);
|
||||
|
||||
middleLayerContentContainer.Add(topLayerContent = new ContractedPanelMiddleContent(Score).With(d => d.Alpha = 0));
|
||||
topLayerContentContainer.Add(topLayerContent = new ContractedPanelTopContent(Score).With(d => d.Alpha = 0));
|
||||
middleLayerContentContainer.Add(middleLayerContent = new ContractedPanelMiddleContent(Score).With(d => d.Alpha = 0));
|
||||
break;
|
||||
}
|
||||
|
||||
|
@ -26,6 +26,31 @@ namespace osu.Game.Screens.Ranking
|
||||
/// </summary>
|
||||
private const float expanded_panel_spacing = 15;
|
||||
|
||||
/// <summary>
|
||||
/// Minimum distance from either end point of the list that the list can be considered scrolled to the end point.
|
||||
/// </summary>
|
||||
private const float scroll_endpoint_distance = 100;
|
||||
|
||||
/// <summary>
|
||||
/// Whether this <see cref="ScorePanelList"/> can be scrolled and is currently scrolled to the start.
|
||||
/// </summary>
|
||||
public bool IsScrolledToStart => flow.Count > 0 && scroll.ScrollableExtent > 0 && scroll.Current <= scroll_endpoint_distance;
|
||||
|
||||
/// <summary>
|
||||
/// Whether this <see cref="ScorePanelList"/> can be scrolled and is currently scrolled to the end.
|
||||
/// </summary>
|
||||
public bool IsScrolledToEnd => flow.Count > 0 && scroll.ScrollableExtent > 0 && scroll.IsScrolledToEnd(scroll_endpoint_distance);
|
||||
|
||||
/// <summary>
|
||||
/// The current scroll position.
|
||||
/// </summary>
|
||||
public double Current => scroll.Current;
|
||||
|
||||
/// <summary>
|
||||
/// The scrollable extent.
|
||||
/// </summary>
|
||||
public double ScrollableExtent => scroll.ScrollableExtent;
|
||||
|
||||
/// <summary>
|
||||
/// An action to be invoked if a <see cref="ScorePanel"/> is clicked while in an expanded state.
|
||||
/// </summary>
|
||||
|
@ -14,6 +14,7 @@ namespace osu.Game.Skinning
|
||||
public class LegacyBeatmapSkin : LegacySkin
|
||||
{
|
||||
protected override bool AllowManiaSkin => false;
|
||||
protected override bool UseCustomSampleBanks => true;
|
||||
|
||||
public LegacyBeatmapSkin(BeatmapInfo beatmap, IResourceStore<byte[]> storage, AudioManager audioManager)
|
||||
: base(createSkinInfo(beatmap), new LegacySkinResourceStore<BeatmapSetFileInfo>(beatmap.BeatmapSet, storage), audioManager, beatmap.Path)
|
||||
|
@ -38,6 +38,12 @@ namespace osu.Game.Skinning
|
||||
|
||||
protected virtual bool AllowManiaSkin => hasKeyTexture.Value;
|
||||
|
||||
/// <summary>
|
||||
/// Whether this skin can use samples with a custom bank (custom sample set in stable terminology).
|
||||
/// Added in order to match sample lookup logic from stable (in stable, only the beatmap skin could use samples with a custom sample bank).
|
||||
/// </summary>
|
||||
protected virtual bool UseCustomSampleBanks => false;
|
||||
|
||||
public new LegacySkinConfiguration Configuration
|
||||
{
|
||||
get => base.Configuration as LegacySkinConfiguration;
|
||||
@ -337,7 +343,12 @@ namespace osu.Game.Skinning
|
||||
|
||||
public override SampleChannel GetSample(ISampleInfo sampleInfo)
|
||||
{
|
||||
foreach (var lookup in sampleInfo.LookupNames)
|
||||
var lookupNames = sampleInfo.LookupNames;
|
||||
|
||||
if (sampleInfo is HitSampleInfo hitSample)
|
||||
lookupNames = getLegacyLookupNames(hitSample);
|
||||
|
||||
foreach (var lookup in lookupNames)
|
||||
{
|
||||
var sample = Samples?.Get(lookup);
|
||||
|
||||
@ -345,10 +356,6 @@ namespace osu.Game.Skinning
|
||||
return sample;
|
||||
}
|
||||
|
||||
if (sampleInfo is HitSampleInfo hsi)
|
||||
// Try fallback to non-bank samples.
|
||||
return Samples?.Get(hsi.Name);
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
@ -361,5 +368,23 @@ namespace osu.Game.Skinning
|
||||
string lastPiece = componentName.Split('/').Last();
|
||||
yield return componentName.StartsWith("Gameplay/taiko/") ? "taiko-" + lastPiece : lastPiece;
|
||||
}
|
||||
|
||||
private IEnumerable<string> getLegacyLookupNames(HitSampleInfo hitSample)
|
||||
{
|
||||
var lookupNames = hitSample.LookupNames;
|
||||
|
||||
if (!UseCustomSampleBanks && !string.IsNullOrEmpty(hitSample.Suffix))
|
||||
// for compatibility with stable, exclude the lookup names with the custom sample bank suffix, if they are not valid for use in this skin.
|
||||
// using .EndsWith() is intentional as it ensures parity in all edge cases
|
||||
// (see LegacyTaikoSampleInfo for an example of one - prioritising the taiko prefix should still apply, but the sample bank should not).
|
||||
lookupNames = hitSample.LookupNames.Where(name => !name.EndsWith(hitSample.Suffix));
|
||||
|
||||
// also for compatibility, try falling back to non-bank samples (so-called "universal" samples) as the last resort.
|
||||
// going forward specifying banks shall always be required, even for elements that wouldn't require it on stable,
|
||||
// which is why this is done locally here.
|
||||
lookupNames = lookupNames.Append(hitSample.Name);
|
||||
|
||||
return lookupNames;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -37,6 +37,8 @@ namespace osu.Game.Tests
|
||||
Statistics[HitResult.Meh] = 50;
|
||||
Statistics[HitResult.Good] = 100;
|
||||
Statistics[HitResult.Great] = 300;
|
||||
|
||||
Position = 1;
|
||||
}
|
||||
|
||||
private class TestModHardRock : ModHardRock
|
||||
|
@ -1,6 +1,7 @@
|
||||
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
|
||||
// See the LICENCE file in the repository root for full licence text.
|
||||
|
||||
using System;
|
||||
using osu.Framework.Allocation;
|
||||
using osu.Framework.Extensions.Color4Extensions;
|
||||
using osu.Framework.Graphics;
|
||||
@ -23,6 +24,16 @@ namespace osu.Game.Users
|
||||
|
||||
protected override Drawable CreateDrawable(User user) => new Cover(user);
|
||||
|
||||
protected override double LoadDelay => 300;
|
||||
|
||||
/// <summary>
|
||||
/// Delay before the background is unloaded while off-screen.
|
||||
/// </summary>
|
||||
protected virtual double UnloadDelay => 5000;
|
||||
|
||||
protected override DelayedLoadWrapper CreateDelayedLoadWrapper(Func<Drawable> createContentFunc, double timeBeforeLoad)
|
||||
=> new DelayedLoadUnloadWrapper(createContentFunc, timeBeforeLoad, UnloadDelay);
|
||||
|
||||
[LongRunningLoad]
|
||||
private class Cover : CompositeDrawable
|
||||
{
|
||||
|
@ -4,7 +4,6 @@
|
||||
using System;
|
||||
using osu.Framework.Allocation;
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Framework.Graphics.Containers;
|
||||
using osu.Framework.Graphics.Shapes;
|
||||
using osu.Game.Graphics;
|
||||
using osu.Game.Graphics.Sprites;
|
||||
@ -25,7 +24,7 @@ namespace osu.Game.Users
|
||||
|
||||
protected Action ViewProfile { get; private set; }
|
||||
|
||||
protected DelayedLoadUnloadWrapper Background { get; private set; }
|
||||
protected Drawable Background { get; private set; }
|
||||
|
||||
protected UserPanel(User user)
|
||||
{
|
||||
@ -56,17 +55,12 @@ namespace osu.Game.Users
|
||||
RelativeSizeAxes = Axes.Both,
|
||||
Colour = ColourProvider?.Background5 ?? Colours.Gray1
|
||||
},
|
||||
Background = new DelayedLoadUnloadWrapper(() => new UserCoverBackground
|
||||
Background = new UserCoverBackground
|
||||
{
|
||||
RelativeSizeAxes = Axes.Both,
|
||||
Anchor = Anchor.Centre,
|
||||
Origin = Anchor.Centre,
|
||||
User = User,
|
||||
}, 300, 5000)
|
||||
{
|
||||
Anchor = Anchor.CentreRight,
|
||||
Origin = Anchor.CentreRight,
|
||||
RelativeSizeAxes = Axes.Both,
|
||||
},
|
||||
CreateLayout()
|
||||
});
|
||||
|
@ -24,8 +24,8 @@
|
||||
<PackageReference Include="Microsoft.EntityFrameworkCore.Sqlite" Version="2.2.6" />
|
||||
<PackageReference Include="Microsoft.EntityFrameworkCore.Sqlite.Core" Version="2.2.6" />
|
||||
<PackageReference Include="Newtonsoft.Json" Version="12.0.3" />
|
||||
<PackageReference Include="ppy.osu.Framework" Version="2020.723.0" />
|
||||
<PackageReference Include="ppy.osu.Game.Resources" Version="2020.727.1" />
|
||||
<PackageReference Include="ppy.osu.Framework" Version="2020.730.1" />
|
||||
<PackageReference Include="ppy.osu.Game.Resources" Version="2020.731.0" />
|
||||
<PackageReference Include="Sentry" Version="2.1.5" />
|
||||
<PackageReference Include="SharpCompress" Version="0.26.0" />
|
||||
<PackageReference Include="NUnit" Version="3.12.0" />
|
||||
|
@ -70,8 +70,8 @@
|
||||
<Reference Include="System.Net.Http" />
|
||||
</ItemGroup>
|
||||
<ItemGroup Label="Package References">
|
||||
<PackageReference Include="ppy.osu.Framework.iOS" Version="2020.723.0" />
|
||||
<PackageReference Include="ppy.osu.Game.Resources" Version="2020.727.1" />
|
||||
<PackageReference Include="ppy.osu.Framework.iOS" Version="2020.730.1" />
|
||||
<PackageReference Include="ppy.osu.Game.Resources" Version="2020.731.0" />
|
||||
</ItemGroup>
|
||||
<!-- Xamarin.iOS does not automatically handle transitive dependencies from NuGet packages. -->
|
||||
<ItemGroup Label="Transitive Dependencies">
|
||||
@ -80,7 +80,7 @@
|
||||
<PackageReference Include="Microsoft.EntityFrameworkCore.Sqlite" Version="2.2.6" />
|
||||
<PackageReference Include="Microsoft.EntityFrameworkCore.Sqlite.Core" Version="2.2.6" />
|
||||
<PackageReference Include="Newtonsoft.Json" Version="12.0.3" />
|
||||
<PackageReference Include="ppy.osu.Framework" Version="2020.723.0" />
|
||||
<PackageReference Include="ppy.osu.Framework" Version="2020.730.1" />
|
||||
<PackageReference Include="SharpCompress" Version="0.26.0" />
|
||||
<PackageReference Include="NUnit" Version="3.12.0" />
|
||||
<PackageReference Include="SharpRaven" Version="2.4.0" />
|
||||
|