mirror of
https://github.com/ppy/osu.git
synced 2024-11-06 06:57:39 +08:00
Merge remote-tracking branch 'refs/remotes/ppy/master' into overlay-scroll-container
This commit is contained in:
commit
2dc81bbcfa
@ -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.Linq;
|
||||
using osu.Framework.Bindables;
|
||||
using osu.Game.Beatmaps;
|
||||
using osu.Game.Configuration;
|
||||
@ -30,6 +31,22 @@ namespace osu.Game.Rulesets.Catch.Mods
|
||||
Value = 5,
|
||||
};
|
||||
|
||||
public override string SettingDescription
|
||||
{
|
||||
get
|
||||
{
|
||||
string circleSize = CircleSize.IsDefault ? string.Empty : $"CS {CircleSize.Value:N1}";
|
||||
string approachRate = ApproachRate.IsDefault ? string.Empty : $"AR {ApproachRate.Value:N1}";
|
||||
|
||||
return string.Join(", ", new[]
|
||||
{
|
||||
circleSize,
|
||||
base.SettingDescription,
|
||||
approachRate
|
||||
}.Where(s => !string.IsNullOrEmpty(s)));
|
||||
}
|
||||
}
|
||||
|
||||
protected override void TransferSettings(BeatmapDifficulty difficulty)
|
||||
{
|
||||
base.TransferSettings(difficulty);
|
||||
|
Binary file not shown.
After Width: | Height: | Size: 17 KiB |
Binary file not shown.
After Width: | Height: | Size: 49 KiB |
70
osu.Game.Rulesets.Osu.Tests/TestSceneSpinnerSpunOut.cs
Normal file
70
osu.Game.Rulesets.Osu.Tests/TestSceneSpinnerSpunOut.cs
Normal file
@ -0,0 +1,70 @@
|
||||
// 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;
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Game.Beatmaps;
|
||||
using osu.Game.Beatmaps.ControlPoints;
|
||||
using osu.Game.Rulesets.Mods;
|
||||
using osu.Game.Rulesets.Osu.Mods;
|
||||
using osu.Game.Rulesets.Osu.Objects;
|
||||
using osu.Game.Rulesets.Osu.Objects.Drawables;
|
||||
using osu.Game.Rulesets.Osu.Objects.Drawables.Pieces;
|
||||
using osu.Game.Tests.Visual;
|
||||
|
||||
namespace osu.Game.Rulesets.Osu.Tests
|
||||
{
|
||||
[TestFixture]
|
||||
public class TestSceneSpinnerSpunOut : OsuTestScene
|
||||
{
|
||||
public override IReadOnlyList<Type> RequiredTypes => new[]
|
||||
{
|
||||
typeof(SpinnerDisc),
|
||||
typeof(DrawableSpinner),
|
||||
typeof(DrawableOsuHitObject),
|
||||
typeof(OsuModSpunOut)
|
||||
};
|
||||
|
||||
[SetUp]
|
||||
public void SetUp() => Schedule(() =>
|
||||
{
|
||||
SelectedMods.Value = new[] { new OsuModSpunOut() };
|
||||
});
|
||||
|
||||
[Test]
|
||||
public void TestSpunOut()
|
||||
{
|
||||
DrawableSpinner spinner = null;
|
||||
|
||||
AddStep("create spinner", () => spinner = createSpinner());
|
||||
|
||||
AddUntilStep("wait for end", () => Time.Current > spinner.LifetimeEnd);
|
||||
|
||||
AddAssert("spinner is completed", () => spinner.Progress >= 1);
|
||||
}
|
||||
|
||||
private DrawableSpinner createSpinner()
|
||||
{
|
||||
var spinner = new Spinner
|
||||
{
|
||||
StartTime = Time.Current + 500,
|
||||
EndTime = Time.Current + 2500
|
||||
};
|
||||
spinner.ApplyDefaults(new ControlPointInfo(), new BeatmapDifficulty());
|
||||
|
||||
var drawableSpinner = new DrawableSpinner(spinner)
|
||||
{
|
||||
Anchor = Anchor.Centre
|
||||
};
|
||||
|
||||
foreach (var mod in SelectedMods.Value.OfType<IApplicableToDrawableHitObjects>())
|
||||
mod.ApplyToDrawableHitObjects(new[] { drawableSpinner });
|
||||
|
||||
Add(drawableSpinner);
|
||||
return drawableSpinner;
|
||||
}
|
||||
}
|
||||
}
|
@ -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.Linq;
|
||||
using osu.Framework.Bindables;
|
||||
using osu.Game.Beatmaps;
|
||||
using osu.Game.Configuration;
|
||||
@ -30,6 +31,22 @@ namespace osu.Game.Rulesets.Osu.Mods
|
||||
Value = 5,
|
||||
};
|
||||
|
||||
public override string SettingDescription
|
||||
{
|
||||
get
|
||||
{
|
||||
string circleSize = CircleSize.IsDefault ? string.Empty : $"CS {CircleSize.Value:N1}";
|
||||
string approachRate = ApproachRate.IsDefault ? string.Empty : $"AR {ApproachRate.Value:N1}";
|
||||
|
||||
return string.Join(", ", new[]
|
||||
{
|
||||
circleSize,
|
||||
base.SettingDescription,
|
||||
approachRate
|
||||
}.Where(s => !string.IsNullOrEmpty(s)));
|
||||
}
|
||||
}
|
||||
|
||||
protected override void TransferSettings(BeatmapDifficulty difficulty)
|
||||
{
|
||||
base.TransferSettings(difficulty);
|
||||
|
@ -2,21 +2,46 @@
|
||||
// See the LICENCE file in the repository root for full licence text.
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Framework.Graphics.Sprites;
|
||||
using osu.Framework.Utils;
|
||||
using osu.Game.Graphics;
|
||||
using osu.Game.Rulesets.Mods;
|
||||
using osu.Game.Rulesets.Objects.Drawables;
|
||||
using osu.Game.Rulesets.Osu.Objects.Drawables;
|
||||
|
||||
namespace osu.Game.Rulesets.Osu.Mods
|
||||
{
|
||||
public class OsuModSpunOut : Mod
|
||||
public class OsuModSpunOut : Mod, IApplicableToDrawableHitObjects
|
||||
{
|
||||
public override string Name => "Spun Out";
|
||||
public override string Acronym => "SO";
|
||||
public override IconUsage? Icon => OsuIcon.ModSpunout;
|
||||
public override ModType Type => ModType.DifficultyReduction;
|
||||
public override ModType Type => ModType.Automation;
|
||||
public override string Description => @"Spinners will be automatically completed.";
|
||||
public override double ScoreMultiplier => 0.9;
|
||||
public override bool Ranked => true;
|
||||
public override Type[] IncompatibleMods => new[] { typeof(ModAutoplay), typeof(OsuModAutopilot) };
|
||||
|
||||
public void ApplyToDrawableHitObjects(IEnumerable<DrawableHitObject> drawables)
|
||||
{
|
||||
foreach (var hitObject in drawables)
|
||||
{
|
||||
if (hitObject is DrawableSpinner spinner)
|
||||
{
|
||||
spinner.HandleUserInput = false;
|
||||
spinner.OnUpdate += onSpinnerUpdate;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void onSpinnerUpdate(Drawable drawable)
|
||||
{
|
||||
var spinner = (DrawableSpinner)drawable;
|
||||
|
||||
spinner.Disc.Tracking = true;
|
||||
spinner.Disc.Rotate(MathUtils.RadiansToDegrees((float)spinner.Clock.ElapsedFrameTime * 0.03f));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -30,6 +30,8 @@ namespace osu.Game.Rulesets.Osu.Objects.Drawables
|
||||
public readonly SkinnableDrawable CirclePiece;
|
||||
private readonly Container scaleContainer;
|
||||
|
||||
protected virtual OsuSkinComponents CirclePieceComponent => OsuSkinComponents.HitCircle;
|
||||
|
||||
public DrawableHitCircle(HitCircle h)
|
||||
: base(h)
|
||||
{
|
||||
@ -57,7 +59,7 @@ namespace osu.Game.Rulesets.Osu.Objects.Drawables
|
||||
return true;
|
||||
},
|
||||
},
|
||||
CirclePiece = new SkinnableDrawable(new OsuSkinComponent(OsuSkinComponents.HitCircle), _ => new MainCirclePiece()),
|
||||
CirclePiece = new SkinnableDrawable(new OsuSkinComponent(CirclePieceComponent), _ => new MainCirclePiece()),
|
||||
ApproachCircle = new ApproachCircle
|
||||
{
|
||||
Alpha = 0,
|
||||
|
@ -14,6 +14,8 @@ namespace osu.Game.Rulesets.Osu.Objects.Drawables
|
||||
private readonly IBindable<Vector2> positionBindable = new Bindable<Vector2>();
|
||||
private readonly IBindable<int> pathVersion = new Bindable<int>();
|
||||
|
||||
protected override OsuSkinComponents CirclePieceComponent => OsuSkinComponents.SliderHeadHitCircle;
|
||||
|
||||
private readonly Slider slider;
|
||||
|
||||
public DrawableSliderHead(Slider slider, HitCircle h)
|
||||
|
@ -87,6 +87,9 @@ namespace osu.Game.Rulesets.Osu.Objects.Drawables
|
||||
|
||||
public void UpdateSnakingPosition(Vector2 start, Vector2 end)
|
||||
{
|
||||
// When the repeat is hit, the arrow should fade out on spot rather than following the slider
|
||||
if (IsHit) return;
|
||||
|
||||
bool isRepeatAtEnd = sliderRepeat.RepeatIndex % 2 == 0;
|
||||
List<Vector2> curve = ((PlaySliderBody)drawableSlider.Body.Drawable).CurrentCurve;
|
||||
|
||||
|
@ -176,17 +176,18 @@ namespace osu.Game.Rulesets.Osu.Objects.Drawables
|
||||
|
||||
protected override void Update()
|
||||
{
|
||||
Disc.Tracking = OsuActionInputManager?.PressedActions.Any(x => x == OsuAction.LeftButton || x == OsuAction.RightButton) ?? false;
|
||||
if (!SpmCounter.IsPresent && Disc.Tracking)
|
||||
SpmCounter.FadeIn(HitObject.TimeFadeIn);
|
||||
|
||||
base.Update();
|
||||
if (HandleUserInput)
|
||||
Disc.Tracking = OsuActionInputManager?.PressedActions.Any(x => x == OsuAction.LeftButton || x == OsuAction.RightButton) ?? false;
|
||||
}
|
||||
|
||||
protected override void UpdateAfterChildren()
|
||||
{
|
||||
base.UpdateAfterChildren();
|
||||
|
||||
if (!SpmCounter.IsPresent && Disc.Tracking)
|
||||
SpmCounter.FadeIn(HitObject.TimeFadeIn);
|
||||
|
||||
circle.Rotation = Disc.Rotation;
|
||||
Ticks.Rotation = Disc.Rotation;
|
||||
SpmCounter.SetRotation(Disc.RotationAbsolute);
|
||||
|
@ -73,6 +73,11 @@ namespace osu.Game.Rulesets.Osu.Objects.Drawables.Pieces
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Whether currently in the correct time range to allow spinning.
|
||||
/// </summary>
|
||||
private bool isSpinnableTime => spinner.StartTime <= Time.Current && spinner.EndTime > Time.Current;
|
||||
|
||||
protected override bool OnMouseMove(MouseMoveEvent e)
|
||||
{
|
||||
mousePosition = Parent.ToLocalSpace(e.ScreenSpaceMousePosition);
|
||||
@ -93,27 +98,12 @@ namespace osu.Game.Rulesets.Osu.Objects.Drawables.Pieces
|
||||
protected override void Update()
|
||||
{
|
||||
base.Update();
|
||||
|
||||
var thisAngle = -MathUtils.RadiansToDegrees(MathF.Atan2(mousePosition.X - DrawSize.X / 2, mousePosition.Y - DrawSize.Y / 2));
|
||||
|
||||
bool validAndTracking = tracking && spinner.StartTime <= Time.Current && spinner.EndTime > Time.Current;
|
||||
var delta = thisAngle - lastAngle;
|
||||
|
||||
if (validAndTracking)
|
||||
{
|
||||
if (!rotationTransferred)
|
||||
{
|
||||
currentRotation = Rotation * 2;
|
||||
rotationTransferred = true;
|
||||
}
|
||||
|
||||
if (thisAngle - lastAngle > 180)
|
||||
lastAngle += 360;
|
||||
else if (lastAngle - thisAngle > 180)
|
||||
lastAngle -= 360;
|
||||
|
||||
currentRotation += thisAngle - lastAngle;
|
||||
RotationAbsolute += Math.Abs(thisAngle - lastAngle) * Math.Sign(Clock.ElapsedFrameTime);
|
||||
}
|
||||
if (tracking)
|
||||
Rotate(delta);
|
||||
|
||||
lastAngle = thisAngle;
|
||||
|
||||
@ -128,5 +118,38 @@ namespace osu.Game.Rulesets.Osu.Objects.Drawables.Pieces
|
||||
|
||||
Rotation = (float)Interpolation.Lerp(Rotation, currentRotation / 2, Math.Clamp(Math.Abs(Time.Elapsed) / 40, 0, 1));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Rotate the disc by the provided angle (in addition to any existing rotation).
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// 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)
|
||||
{
|
||||
if (!isSpinnableTime)
|
||||
return;
|
||||
|
||||
if (!rotationTransferred)
|
||||
{
|
||||
currentRotation = Rotation * 2;
|
||||
rotationTransferred = true;
|
||||
}
|
||||
|
||||
if (angle > 180)
|
||||
{
|
||||
lastAngle += 360;
|
||||
angle -= 360;
|
||||
}
|
||||
else if (-angle > 180)
|
||||
{
|
||||
lastAngle -= 360;
|
||||
angle += 360;
|
||||
}
|
||||
|
||||
currentRotation += angle;
|
||||
RotationAbsolute += Math.Abs(angle) * Math.Sign(Clock.ElapsedFrameTime);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -113,7 +113,6 @@ namespace osu.Game.Rulesets.Osu
|
||||
new OsuModEasy(),
|
||||
new OsuModNoFail(),
|
||||
new MultiMod(new OsuModHalfTime(), new OsuModDaycore()),
|
||||
new OsuModSpunOut(),
|
||||
};
|
||||
|
||||
case ModType.DifficultyIncrease:
|
||||
@ -139,6 +138,7 @@ namespace osu.Game.Rulesets.Osu
|
||||
new MultiMod(new OsuModAutoplay(), new OsuModCinema()),
|
||||
new OsuModRelax(),
|
||||
new OsuModAutopilot(),
|
||||
new OsuModSpunOut(),
|
||||
};
|
||||
|
||||
case ModType.Fun:
|
||||
|
@ -13,6 +13,7 @@ namespace osu.Game.Rulesets.Osu
|
||||
ApproachCircle,
|
||||
ReverseArrow,
|
||||
HitCircleText,
|
||||
SliderHeadHitCircle,
|
||||
SliderFollowCircle,
|
||||
SliderBall,
|
||||
SliderBody,
|
||||
|
@ -6,6 +6,7 @@ using osu.Framework.Bindables;
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Framework.Graphics.Containers;
|
||||
using osu.Framework.Graphics.Sprites;
|
||||
using osu.Framework.Graphics.Textures;
|
||||
using osu.Game.Graphics;
|
||||
using osu.Game.Graphics.Sprites;
|
||||
using osu.Game.Rulesets.Objects.Drawables;
|
||||
@ -18,8 +19,12 @@ namespace osu.Game.Rulesets.Osu.Skinning
|
||||
{
|
||||
public class LegacyMainCirclePiece : CompositeDrawable
|
||||
{
|
||||
public LegacyMainCirclePiece()
|
||||
private readonly string priorityLookup;
|
||||
|
||||
public LegacyMainCirclePiece(string priorityLookup = null)
|
||||
{
|
||||
this.priorityLookup = priorityLookup;
|
||||
|
||||
Size = new Vector2(OsuHitObject.OBJECT_RADIUS * 2);
|
||||
}
|
||||
|
||||
@ -39,7 +44,7 @@ namespace osu.Game.Rulesets.Osu.Skinning
|
||||
{
|
||||
hitCircleSprite = new Sprite
|
||||
{
|
||||
Texture = skin.GetTexture("hitcircle"),
|
||||
Texture = getTextureWithFallback(string.Empty),
|
||||
Colour = drawableObject.AccentColour.Value,
|
||||
Anchor = Anchor.Centre,
|
||||
Origin = Anchor.Centre,
|
||||
@ -51,7 +56,7 @@ namespace osu.Game.Rulesets.Osu.Skinning
|
||||
}, confineMode: ConfineMode.NoScaling),
|
||||
new Sprite
|
||||
{
|
||||
Texture = skin.GetTexture("hitcircleoverlay"),
|
||||
Texture = getTextureWithFallback("overlay"),
|
||||
Anchor = Anchor.Centre,
|
||||
Origin = Anchor.Centre,
|
||||
}
|
||||
@ -65,6 +70,16 @@ namespace osu.Game.Rulesets.Osu.Skinning
|
||||
|
||||
indexInCurrentCombo.BindTo(osuObject.IndexInCurrentComboBindable);
|
||||
indexInCurrentCombo.BindValueChanged(index => hitCircleText.Text = (index.NewValue + 1).ToString(), true);
|
||||
|
||||
Texture getTextureWithFallback(string name)
|
||||
{
|
||||
Texture tex = null;
|
||||
|
||||
if (!string.IsNullOrEmpty(priorityLookup))
|
||||
tex = skin.GetTexture($"{priorityLookup}{name}");
|
||||
|
||||
return tex ?? skin.GetTexture($"hitcircle{name}");
|
||||
}
|
||||
}
|
||||
|
||||
private void updateState(ValueChangedEvent<ArmedState> state)
|
||||
|
@ -82,6 +82,12 @@ namespace osu.Game.Rulesets.Osu.Skinning
|
||||
|
||||
return null;
|
||||
|
||||
case OsuSkinComponents.SliderHeadHitCircle:
|
||||
if (hasHitCircle.Value)
|
||||
return new LegacyMainCirclePiece("sliderstartcircle");
|
||||
|
||||
return null;
|
||||
|
||||
case OsuSkinComponents.HitCircle:
|
||||
if (hasHitCircle.Value)
|
||||
return new LegacyMainCirclePiece();
|
||||
|
9
osu.Game.Tests/Resources/mania-skin-duplicate.ini
Normal file
9
osu.Game.Tests/Resources/mania-skin-duplicate.ini
Normal file
@ -0,0 +1,9 @@
|
||||
[Mania]
|
||||
Keys: 4
|
||||
ColumnWidth: 10,10,10,10
|
||||
HitPosition: 470
|
||||
|
||||
[Mania]
|
||||
Keys: 4
|
||||
ColumnWidth: 20,20,20,20
|
||||
HitPosition: 460
|
4
osu.Game.Tests/Resources/mania-skin-extra-data.ini
Normal file
4
osu.Game.Tests/Resources/mania-skin-extra-data.ini
Normal file
@ -0,0 +1,4 @@
|
||||
[Mania]
|
||||
Keys: 4
|
||||
ColumnWidth: 10,10,10,10,10,10,10
|
||||
HitPosition: 470
|
9
osu.Game.Tests/Resources/mania-skin-multiple.ini
Normal file
9
osu.Game.Tests/Resources/mania-skin-multiple.ini
Normal file
@ -0,0 +1,9 @@
|
||||
[Mania]
|
||||
Keys: 4
|
||||
ColumnWidth: 10,10,10,10
|
||||
HitPosition: 470
|
||||
|
||||
[Mania]
|
||||
Keys: 2
|
||||
ColumnWidth: 20,20
|
||||
HitPosition: 460
|
4
osu.Game.Tests/Resources/mania-skin-single.ini
Normal file
4
osu.Game.Tests/Resources/mania-skin-single.ini
Normal file
@ -0,0 +1,4 @@
|
||||
[Mania]
|
||||
Keys: 4
|
||||
ColumnWidth: 10,10,10,10
|
||||
HitPosition: 470
|
87
osu.Game.Tests/Skins/LegacyManiaSkinDecoderTest.cs
Normal file
87
osu.Game.Tests/Skins/LegacyManiaSkinDecoderTest.cs
Normal file
@ -0,0 +1,87 @@
|
||||
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
|
||||
// See the LICENCE file in the repository root for full licence text.
|
||||
|
||||
using NUnit.Framework;
|
||||
using osu.Game.IO;
|
||||
using osu.Game.Skinning;
|
||||
using osu.Game.Tests.Resources;
|
||||
|
||||
namespace osu.Game.Tests.Skins
|
||||
{
|
||||
[TestFixture]
|
||||
public class LegacyManiaSkinDecoderTest
|
||||
{
|
||||
[Test]
|
||||
public void TestParseSingleConfig()
|
||||
{
|
||||
var decoder = new LegacyManiaSkinDecoder();
|
||||
|
||||
using (var resStream = TestResources.OpenResource("mania-skin-single.ini"))
|
||||
using (var stream = new LineBufferedReader(resStream))
|
||||
{
|
||||
var configs = decoder.Decode(stream);
|
||||
|
||||
Assert.That(configs.Count, Is.EqualTo(1));
|
||||
Assert.That(configs[0].Keys, Is.EqualTo(4));
|
||||
Assert.That(configs[0].ColumnWidth, Is.EquivalentTo(new float[] { 16, 16, 16, 16 }));
|
||||
Assert.That(configs[0].HitPosition, Is.EqualTo(16));
|
||||
}
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestParseMultipleConfig()
|
||||
{
|
||||
var decoder = new LegacyManiaSkinDecoder();
|
||||
|
||||
using (var resStream = TestResources.OpenResource("mania-skin-multiple.ini"))
|
||||
using (var stream = new LineBufferedReader(resStream))
|
||||
{
|
||||
var configs = decoder.Decode(stream);
|
||||
|
||||
Assert.That(configs.Count, Is.EqualTo(2));
|
||||
|
||||
Assert.That(configs[0].Keys, Is.EqualTo(4));
|
||||
Assert.That(configs[0].ColumnWidth, Is.EquivalentTo(new float[] { 16, 16, 16, 16 }));
|
||||
Assert.That(configs[0].HitPosition, Is.EqualTo(16));
|
||||
|
||||
Assert.That(configs[1].Keys, Is.EqualTo(2));
|
||||
Assert.That(configs[1].ColumnWidth, Is.EquivalentTo(new float[] { 32, 32 }));
|
||||
Assert.That(configs[1].HitPosition, Is.EqualTo(32));
|
||||
}
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestParseDuplicateConfig()
|
||||
{
|
||||
var decoder = new LegacyManiaSkinDecoder();
|
||||
|
||||
using (var resStream = TestResources.OpenResource("mania-skin-single.ini"))
|
||||
using (var stream = new LineBufferedReader(resStream))
|
||||
{
|
||||
var configs = decoder.Decode(stream);
|
||||
|
||||
Assert.That(configs.Count, Is.EqualTo(1));
|
||||
Assert.That(configs[0].Keys, Is.EqualTo(4));
|
||||
Assert.That(configs[0].ColumnWidth, Is.EquivalentTo(new float[] { 16, 16, 16, 16 }));
|
||||
Assert.That(configs[0].HitPosition, Is.EqualTo(16));
|
||||
}
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestParseWithUnnecessaryExtraData()
|
||||
{
|
||||
var decoder = new LegacyManiaSkinDecoder();
|
||||
|
||||
using (var resStream = TestResources.OpenResource("mania-skin-extra-data.ini"))
|
||||
using (var stream = new LineBufferedReader(resStream))
|
||||
{
|
||||
var configs = decoder.Decode(stream);
|
||||
|
||||
Assert.That(configs.Count, Is.EqualTo(1));
|
||||
Assert.That(configs[0].Keys, Is.EqualTo(4));
|
||||
Assert.That(configs[0].ColumnWidth, Is.EquivalentTo(new float[] { 16, 16, 16, 16 }));
|
||||
Assert.That(configs[0].HitPosition, Is.EqualTo(16));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -4,7 +4,6 @@
|
||||
using System.Linq;
|
||||
using NUnit.Framework;
|
||||
using osu.Framework.Allocation;
|
||||
using osu.Framework.Screens;
|
||||
using osu.Game.Configuration;
|
||||
using osu.Game.Rulesets;
|
||||
using osu.Game.Rulesets.Catch;
|
||||
@ -74,9 +73,6 @@ namespace osu.Game.Tests.Visual.Gameplay
|
||||
Beatmap.Value = working;
|
||||
SelectedMods.Value = new[] { ruleset.GetAllMods().First(m => m is ModNoFail) };
|
||||
|
||||
Player?.Exit();
|
||||
Player = null;
|
||||
|
||||
Player = CreatePlayer(ruleset);
|
||||
|
||||
LoadScreen(Player);
|
||||
|
@ -4,9 +4,13 @@
|
||||
using System.ComponentModel;
|
||||
using System.Linq;
|
||||
using osu.Framework.Testing;
|
||||
using osu.Game.Beatmaps.Timing;
|
||||
using osu.Game.Rulesets;
|
||||
using osu.Game.Rulesets.Objects;
|
||||
using osu.Game.Rulesets.Scoring;
|
||||
using osu.Game.Screens.Play;
|
||||
using osu.Game.Screens.Play.Break;
|
||||
using osu.Game.Screens.Ranking;
|
||||
|
||||
namespace osu.Game.Tests.Visual.Gameplay
|
||||
{
|
||||
@ -17,21 +21,38 @@ namespace osu.Game.Tests.Visual.Gameplay
|
||||
|
||||
protected override Player CreatePlayer(Ruleset ruleset)
|
||||
{
|
||||
SelectedMods.Value = SelectedMods.Value.Concat(new[] { ruleset.GetAutoplayMod() }).ToArray();
|
||||
return new TestPlayer(false, false);
|
||||
SelectedMods.Value = new[] { ruleset.GetAutoplayMod() };
|
||||
return new TestPlayer(false);
|
||||
}
|
||||
|
||||
protected override void AddCheckSteps()
|
||||
{
|
||||
AddUntilStep("score above zero", () => Player.ScoreProcessor.TotalScore.Value > 0);
|
||||
AddUntilStep("key counter counted keys", () => Player.HUDOverlay.KeyCounter.Children.Any(kc => kc.CountPresses > 2));
|
||||
AddStep("seek to break time", () => Player.GameplayClockContainer.Seek(Player.ChildrenOfType<BreakTracker>().First().Breaks.First().StartTime));
|
||||
AddUntilStep("wait for seek to complete", () =>
|
||||
Player.HUDOverlay.Progress.ReferenceClock.CurrentTime >= Player.BreakOverlay.Breaks.First().StartTime);
|
||||
seekToBreak(0);
|
||||
AddAssert("keys not counting", () => !Player.HUDOverlay.KeyCounter.IsCounting);
|
||||
AddAssert("overlay displays 100% accuracy", () => Player.BreakOverlay.ChildrenOfType<BreakInfo>().Single().AccuracyDisplay.Current.Value == 1);
|
||||
AddStep("rewind", () => Player.GameplayClockContainer.Seek(-80000));
|
||||
AddUntilStep("key counter reset", () => Player.HUDOverlay.KeyCounter.Children.All(kc => kc.CountPresses == 0));
|
||||
|
||||
seekToBreak(0);
|
||||
seekToBreak(1);
|
||||
|
||||
AddStep("seek to completion", () => Player.GameplayClockContainer.Seek(Player.DrawableRuleset.Objects.Last().GetEndTime()));
|
||||
AddUntilStep("results displayed", () => getResultsScreen() != null);
|
||||
|
||||
AddAssert("score has combo", () => getResultsScreen().Score.Combo > 100);
|
||||
AddAssert("score has no misses", () => getResultsScreen().Score.Statistics[HitResult.Miss] == 0);
|
||||
|
||||
ResultsScreen getResultsScreen() => Stack.CurrentScreen as ResultsScreen;
|
||||
}
|
||||
|
||||
private void seekToBreak(int breakIndex)
|
||||
{
|
||||
AddStep($"seek to break {breakIndex}", () => Player.GameplayClockContainer.Seek(destBreak().StartTime));
|
||||
AddUntilStep("wait for seek to complete", () => Player.HUDOverlay.Progress.ReferenceClock.CurrentTime >= destBreak().StartTime);
|
||||
|
||||
BreakPeriod destBreak() => Player.ChildrenOfType<BreakTracker>().First().Breaks.ElementAt(breakIndex);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -17,13 +17,12 @@ using osu.Game.Replays;
|
||||
using osu.Game.Rulesets;
|
||||
using osu.Game.Rulesets.Replays;
|
||||
using osu.Game.Rulesets.UI;
|
||||
using osu.Game.Tests.Visual;
|
||||
using osu.Game.Tests.Visual.UserInterface;
|
||||
using osuTK;
|
||||
using osuTK.Graphics;
|
||||
using osuTK.Input;
|
||||
|
||||
namespace osu.Game.Tests.Gameplay
|
||||
namespace osu.Game.Tests.Visual.Gameplay
|
||||
{
|
||||
public class TestSceneReplayRecorder : OsuManualInputManagerTestScene
|
||||
{
|
@ -13,12 +13,11 @@ using osu.Game.Replays;
|
||||
using osu.Game.Rulesets;
|
||||
using osu.Game.Rulesets.Replays;
|
||||
using osu.Game.Rulesets.UI;
|
||||
using osu.Game.Tests.Visual;
|
||||
using osu.Game.Tests.Visual.UserInterface;
|
||||
using osuTK;
|
||||
using osuTK.Graphics;
|
||||
|
||||
namespace osu.Game.Tests.Gameplay
|
||||
namespace osu.Game.Tests.Visual.Gameplay
|
||||
{
|
||||
public class TestSceneReplayRecording : OsuTestScene
|
||||
{
|
@ -83,6 +83,82 @@ namespace osu.Game.Tests.Visual.SongSelect
|
||||
waitForSelection(set_count, 3);
|
||||
}
|
||||
|
||||
[TestCase(true)]
|
||||
[TestCase(false)]
|
||||
public void TestTraversalBeyondVisible(bool forwards)
|
||||
{
|
||||
var sets = new List<BeatmapSetInfo>();
|
||||
|
||||
const int total_set_count = 200;
|
||||
|
||||
for (int i = 0; i < total_set_count; i++)
|
||||
sets.Add(createTestBeatmapSet(i + 1));
|
||||
|
||||
loadBeatmaps(sets);
|
||||
|
||||
for (int i = 1; i < total_set_count; i += i)
|
||||
selectNextAndAssert(i);
|
||||
|
||||
void selectNextAndAssert(int amount)
|
||||
{
|
||||
setSelected(forwards ? 1 : total_set_count, 1);
|
||||
|
||||
AddStep($"{(forwards ? "Next" : "Previous")} beatmap {amount} times", () =>
|
||||
{
|
||||
for (int i = 0; i < amount; i++)
|
||||
{
|
||||
carousel.SelectNext(forwards ? 1 : -1);
|
||||
}
|
||||
});
|
||||
|
||||
waitForSelection(forwards ? amount + 1 : total_set_count - amount);
|
||||
}
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestTraversalBeyondVisibleDifficulties()
|
||||
{
|
||||
var sets = new List<BeatmapSetInfo>();
|
||||
|
||||
const int total_set_count = 20;
|
||||
|
||||
for (int i = 0; i < total_set_count; i++)
|
||||
sets.Add(createTestBeatmapSet(i + 1));
|
||||
|
||||
loadBeatmaps(sets);
|
||||
|
||||
// Selects next set once, difficulty index doesn't change
|
||||
selectNextAndAssert(3, true, 2, 1);
|
||||
|
||||
// Selects next set 16 times (50 \ 3 == 16), difficulty index changes twice (50 % 3 == 2)
|
||||
selectNextAndAssert(50, true, 17, 3);
|
||||
|
||||
// Travels around the carousel thrice (200 \ 60 == 3)
|
||||
// continues to select 20 times (200 \ 60 == 20)
|
||||
// selects next set 6 times (20 \ 3 == 6)
|
||||
// difficulty index changes twice (20 % 3 == 2)
|
||||
selectNextAndAssert(200, true, 7, 3);
|
||||
|
||||
// All same but in reverse
|
||||
selectNextAndAssert(3, false, 19, 3);
|
||||
selectNextAndAssert(50, false, 4, 1);
|
||||
selectNextAndAssert(200, false, 14, 1);
|
||||
|
||||
void selectNextAndAssert(int amount, bool forwards, int expectedSet, int expectedDiff)
|
||||
{
|
||||
// Select very first or very last difficulty
|
||||
setSelected(forwards ? 1 : 20, forwards ? 1 : 3);
|
||||
|
||||
AddStep($"{(forwards ? "Next" : "Previous")} difficulty {amount} times", () =>
|
||||
{
|
||||
for (int i = 0; i < amount; i++)
|
||||
carousel.SelectNext(forwards ? 1 : -1, false);
|
||||
});
|
||||
|
||||
waitForSelection(expectedSet, expectedDiff);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Test filtering
|
||||
/// </summary>
|
||||
|
@ -91,13 +91,14 @@ namespace osu.Game.Tests.Visual.UserInterface
|
||||
|
||||
var easierMods = osu.GetModsFor(ModType.DifficultyReduction);
|
||||
var harderMods = osu.GetModsFor(ModType.DifficultyIncrease);
|
||||
var conversionMods = osu.GetModsFor(ModType.Conversion);
|
||||
|
||||
var noFailMod = osu.GetModsFor(ModType.DifficultyReduction).FirstOrDefault(m => m is OsuModNoFail);
|
||||
var hiddenMod = harderMods.FirstOrDefault(m => m is OsuModHidden);
|
||||
|
||||
var doubleTimeMod = harderMods.OfType<MultiMod>().FirstOrDefault(m => m.Mods.Any(a => a is OsuModDoubleTime));
|
||||
|
||||
var spunOutMod = easierMods.FirstOrDefault(m => m is OsuModSpunOut);
|
||||
var targetMod = conversionMods.FirstOrDefault(m => m is OsuModTarget);
|
||||
|
||||
var easy = easierMods.FirstOrDefault(m => m is OsuModEasy);
|
||||
var hardRock = harderMods.FirstOrDefault(m => m is OsuModHardRock);
|
||||
@ -109,7 +110,7 @@ namespace osu.Game.Tests.Visual.UserInterface
|
||||
testMultiplierTextColour(noFailMod, () => modSelect.LowMultiplierColour);
|
||||
testMultiplierTextColour(hiddenMod, () => modSelect.HighMultiplierColour);
|
||||
|
||||
testUnimplementedMod(spunOutMod);
|
||||
testUnimplementedMod(targetMod);
|
||||
}
|
||||
|
||||
[Test]
|
||||
|
@ -41,6 +41,7 @@ namespace osu.Game.Beatmaps.Formats
|
||||
section = Section.None;
|
||||
}
|
||||
|
||||
OnBeginNewSection(section);
|
||||
continue;
|
||||
}
|
||||
|
||||
@ -57,6 +58,14 @@ namespace osu.Game.Beatmaps.Formats
|
||||
|
||||
protected virtual bool ShouldSkipLine(string line) => string.IsNullOrWhiteSpace(line) || line.AsSpan().TrimStart().StartsWith("//".AsSpan(), StringComparison.Ordinal);
|
||||
|
||||
/// <summary>
|
||||
/// Invoked when a new <see cref="Section"/> has been entered.
|
||||
/// </summary>
|
||||
/// <param name="section">The entered <see cref="Section"/>.</param>
|
||||
protected virtual void OnBeginNewSection(Section section)
|
||||
{
|
||||
}
|
||||
|
||||
protected virtual void ParseLine(T output, Section section, string line)
|
||||
{
|
||||
line = StripComments(line);
|
||||
@ -139,7 +148,8 @@ namespace osu.Game.Beatmaps.Formats
|
||||
Colours,
|
||||
HitObjects,
|
||||
Variables,
|
||||
Fonts
|
||||
Fonts,
|
||||
Mania
|
||||
}
|
||||
|
||||
internal class LegacyDifficultyControlPoint : DifficultyControlPoint
|
||||
|
@ -2,9 +2,15 @@
|
||||
// See the LICENCE file in the repository root for full licence text.
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Reflection;
|
||||
using Newtonsoft.Json;
|
||||
using osu.Framework.Bindables;
|
||||
using osu.Framework.Graphics.Sprites;
|
||||
using osu.Game.Configuration;
|
||||
using osu.Game.IO.Serialization;
|
||||
using osu.Game.Rulesets.UI;
|
||||
|
||||
namespace osu.Game.Rulesets.Mods
|
||||
{
|
||||
@ -42,6 +48,51 @@ namespace osu.Game.Rulesets.Mods
|
||||
[JsonIgnore]
|
||||
public virtual string Description => string.Empty;
|
||||
|
||||
/// <summary>
|
||||
/// The tooltip to display for this mod when used in a <see cref="ModIcon"/>.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// Differs from <see cref="Name"/>, as the value of attributes (AR, CS, etc) changeable via the mod
|
||||
/// are displayed in the tooltip.
|
||||
/// </remarks>
|
||||
[JsonIgnore]
|
||||
public string IconTooltip
|
||||
{
|
||||
get
|
||||
{
|
||||
string description = SettingDescription;
|
||||
|
||||
return string.IsNullOrEmpty(description) ? Name : $"{Name} ({description})";
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The description of editable settings of a mod to use in the <see cref="IconTooltip"/>.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// Parentheses are added to the tooltip, surrounding the value of this property. If this property is <c>string.Empty</c>,
|
||||
/// the tooltip will not have parentheses.
|
||||
/// </remarks>
|
||||
public virtual string SettingDescription
|
||||
{
|
||||
get
|
||||
{
|
||||
var tooltipTexts = new List<string>();
|
||||
|
||||
foreach ((SettingSourceAttribute attr, PropertyInfo property) in this.GetOrderedSettingsSourceProperties())
|
||||
{
|
||||
object bindableObj = property.GetValue(this);
|
||||
|
||||
if ((bindableObj as IHasDefaultValue)?.IsDefault == true)
|
||||
continue;
|
||||
|
||||
tooltipTexts.Add($"{attr.Label} {bindableObj}");
|
||||
}
|
||||
|
||||
return string.Join(", ", tooltipTexts.Where(s => !string.IsNullOrEmpty(s)));
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The score multiplier of this mod.
|
||||
/// </summary>
|
||||
|
@ -7,6 +7,7 @@ using osu.Framework.Graphics.Sprites;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using osu.Game.Configuration;
|
||||
using System.Linq;
|
||||
|
||||
namespace osu.Game.Rulesets.Mods
|
||||
{
|
||||
@ -52,6 +53,21 @@ namespace osu.Game.Rulesets.Mods
|
||||
Value = 5,
|
||||
};
|
||||
|
||||
public override string SettingDescription
|
||||
{
|
||||
get
|
||||
{
|
||||
string drainRate = DrainRate.IsDefault ? string.Empty : $"HP {DrainRate.Value:N1}";
|
||||
string overallDifficulty = OverallDifficulty.IsDefault ? string.Empty : $"OD {OverallDifficulty.Value:N1}";
|
||||
|
||||
return string.Join(", ", new[]
|
||||
{
|
||||
drainRate,
|
||||
overallDifficulty
|
||||
}.Where(s => !string.IsNullOrEmpty(s)));
|
||||
}
|
||||
}
|
||||
|
||||
private BeatmapDifficulty difficulty;
|
||||
|
||||
public void ReadFromDifficulty(BeatmapDifficulty difficulty)
|
||||
@ -79,7 +95,7 @@ namespace osu.Game.Rulesets.Mods
|
||||
|
||||
/// <summary>
|
||||
/// Transfer a setting from <see cref="BeatmapDifficulty"/> to a configuration bindable.
|
||||
/// Only performs the transfer if the user it not currently overriding..
|
||||
/// Only performs the transfer if the user is not currently overriding.
|
||||
/// </summary>
|
||||
protected void TransferSetting<T>(BindableNumber<T> bindable, T beatmapDefault)
|
||||
where T : struct, IComparable<T>, IConvertible, IEquatable<T>
|
||||
|
@ -2,6 +2,7 @@
|
||||
// See the LICENCE file in the repository root for full licence text.
|
||||
|
||||
using System;
|
||||
using Humanizer;
|
||||
using osu.Framework.Bindables;
|
||||
using osu.Framework.Graphics.Sprites;
|
||||
using osu.Game.Beatmaps;
|
||||
@ -28,6 +29,8 @@ namespace osu.Game.Rulesets.Mods
|
||||
MaxValue = 10
|
||||
};
|
||||
|
||||
public override string SettingDescription => Retries.IsDefault ? string.Empty : $"{"lives".ToQuantity(Retries.Value)}";
|
||||
|
||||
private int retries;
|
||||
|
||||
private BindableNumber<double> health;
|
||||
|
@ -15,5 +15,7 @@ namespace osu.Game.Rulesets.Mods
|
||||
{
|
||||
track.AddAdjustment(AdjustableProperty.Tempo, SpeedChange);
|
||||
}
|
||||
|
||||
public override string SettingDescription => SpeedChange.IsDefault ? string.Empty : $"{SpeedChange.Value:N2}x";
|
||||
}
|
||||
}
|
||||
|
@ -26,6 +26,8 @@ namespace osu.Game.Rulesets.Mods
|
||||
[SettingSource("Final rate", "The final speed to ramp to")]
|
||||
public abstract BindableNumber<double> FinalRate { get; }
|
||||
|
||||
public override string SettingDescription => $"{InitialRate.Value:N2}x to {FinalRate.Value:N2}x";
|
||||
|
||||
private double finalRateTime;
|
||||
private double beginRampTime;
|
||||
|
||||
|
@ -38,6 +38,15 @@ namespace osu.Game.Rulesets.Objects.Drawables
|
||||
private readonly Lazy<List<DrawableHitObject>> nestedHitObjects = new Lazy<List<DrawableHitObject>>();
|
||||
public IReadOnlyList<DrawableHitObject> NestedHitObjects => nestedHitObjects.IsValueCreated ? nestedHitObjects.Value : (IReadOnlyList<DrawableHitObject>)Array.Empty<DrawableHitObject>();
|
||||
|
||||
/// <summary>
|
||||
/// Whether this object should handle any user input events.
|
||||
/// </summary>
|
||||
public bool HandleUserInput { get; set; } = true;
|
||||
|
||||
public override bool PropagatePositionalInputSubTree => HandleUserInput;
|
||||
|
||||
public override bool PropagateNonPositionalInputSubTree => HandleUserInput;
|
||||
|
||||
/// <summary>
|
||||
/// Invoked when a <see cref="JudgementResult"/> has been applied by this <see cref="DrawableHitObject"/> or a nested <see cref="DrawableHitObject"/>.
|
||||
/// </summary>
|
||||
|
@ -28,7 +28,7 @@ namespace osu.Game.Rulesets.UI
|
||||
|
||||
private readonly ModType type;
|
||||
|
||||
public virtual string TooltipText { get; }
|
||||
public virtual string TooltipText => mod.IconTooltip;
|
||||
|
||||
private Mod mod;
|
||||
|
||||
@ -48,8 +48,6 @@ namespace osu.Game.Rulesets.UI
|
||||
|
||||
type = mod.Type;
|
||||
|
||||
TooltipText = mod.Name;
|
||||
|
||||
Size = new Vector2(size);
|
||||
|
||||
Children = new Drawable[]
|
||||
|
@ -637,6 +637,39 @@ namespace osu.Game.Screens.Play
|
||||
return base.OnExiting(next);
|
||||
}
|
||||
|
||||
protected virtual void GotoRanking()
|
||||
{
|
||||
if (DrawableRuleset.ReplayScore != null)
|
||||
{
|
||||
// if a replay is present, we likely don't want to import into the local database.
|
||||
this.Push(CreateResults(CreateScore()));
|
||||
return;
|
||||
}
|
||||
|
||||
LegacyByteArrayReader replayReader = null;
|
||||
|
||||
var score = new Score { ScoreInfo = CreateScore() };
|
||||
|
||||
if (recordingReplay?.Frames.Count > 0)
|
||||
{
|
||||
score.Replay = recordingReplay;
|
||||
|
||||
using (var stream = new MemoryStream())
|
||||
{
|
||||
new LegacyScoreEncoder(score, gameplayBeatmap.PlayableBeatmap).Encode(stream);
|
||||
replayReader = new LegacyByteArrayReader(stream.ToArray(), "replay.osr");
|
||||
}
|
||||
}
|
||||
|
||||
scoreManager.Import(score.ScoreInfo, replayReader)
|
||||
.ContinueWith(imported => Schedule(() =>
|
||||
{
|
||||
// screen may be in the exiting transition phase.
|
||||
if (this.IsCurrentScreen())
|
||||
this.Push(CreateResults(imported.Result));
|
||||
}));
|
||||
}
|
||||
|
||||
private void fadeOut(bool instant = false)
|
||||
{
|
||||
float fadeOutDuration = instant ? 0 : 250;
|
||||
@ -649,36 +682,7 @@ namespace osu.Game.Screens.Play
|
||||
private void scheduleGotoRanking()
|
||||
{
|
||||
completionProgressDelegate?.Cancel();
|
||||
completionProgressDelegate = Schedule(delegate
|
||||
{
|
||||
if (DrawableRuleset.ReplayScore != null)
|
||||
this.Push(CreateResults(DrawableRuleset.ReplayScore.ScoreInfo));
|
||||
else
|
||||
{
|
||||
var score = new Score { ScoreInfo = CreateScore() };
|
||||
|
||||
LegacyByteArrayReader replayReader = null;
|
||||
|
||||
if (recordingReplay?.Frames.Count > 0)
|
||||
{
|
||||
score.Replay = recordingReplay;
|
||||
|
||||
using (var stream = new MemoryStream())
|
||||
{
|
||||
new LegacyScoreEncoder(score, gameplayBeatmap.PlayableBeatmap).Encode(stream);
|
||||
replayReader = new LegacyByteArrayReader(stream.ToArray(), "replay.osr");
|
||||
}
|
||||
}
|
||||
|
||||
scoreManager.Import(score.ScoreInfo, replayReader)
|
||||
.ContinueWith(imported => Schedule(() =>
|
||||
{
|
||||
// screen may be in the exiting transition phase.
|
||||
if (this.IsCurrentScreen())
|
||||
this.Push(CreateResults(imported.Result));
|
||||
}));
|
||||
}
|
||||
});
|
||||
completionProgressDelegate = Schedule(GotoRanking);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
@ -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 osu.Framework.Screens;
|
||||
using osu.Game.Scoring;
|
||||
|
||||
namespace osu.Game.Screens.Play
|
||||
@ -23,6 +24,11 @@ namespace osu.Game.Screens.Play
|
||||
DrawableRuleset?.SetReplayScore(score);
|
||||
}
|
||||
|
||||
protected override void GotoRanking()
|
||||
{
|
||||
this.Push(CreateResults(DrawableRuleset.ReplayScore.ScoreInfo));
|
||||
}
|
||||
|
||||
protected override ScoreInfo CreateScore() => score.ScoreInfo;
|
||||
}
|
||||
}
|
||||
|
@ -31,13 +31,13 @@ namespace osu.Game.Screens.Ranking
|
||||
[Resolved(CanBeNull = true)]
|
||||
private Player player { get; set; }
|
||||
|
||||
private readonly ScoreInfo score;
|
||||
public readonly ScoreInfo Score;
|
||||
|
||||
private Drawable bottomPanel;
|
||||
|
||||
public ResultsScreen(ScoreInfo score)
|
||||
{
|
||||
this.score = score;
|
||||
Score = score;
|
||||
}
|
||||
|
||||
[BackgroundDependencyLoader]
|
||||
@ -47,7 +47,7 @@ namespace osu.Game.Screens.Ranking
|
||||
{
|
||||
new ResultsScrollContainer
|
||||
{
|
||||
Child = new ScorePanel(score)
|
||||
Child = new ScorePanel(Score)
|
||||
{
|
||||
Anchor = Anchor.Centre,
|
||||
Origin = Anchor.Centre,
|
||||
@ -77,7 +77,7 @@ namespace osu.Game.Screens.Ranking
|
||||
Direction = FillDirection.Horizontal,
|
||||
Children = new Drawable[]
|
||||
{
|
||||
new ReplayDownloadButton(score) { Width = 300 },
|
||||
new ReplayDownloadButton(Score) { Width = 300 },
|
||||
new RetryButton { Width = 300 },
|
||||
}
|
||||
}
|
||||
|
@ -253,46 +253,37 @@ namespace osu.Game.Screens.Select
|
||||
/// <param name="skipDifficulties">Whether to skip individual difficulties and only increment over full groups.</param>
|
||||
public void SelectNext(int direction = 1, bool skipDifficulties = true)
|
||||
{
|
||||
var visibleItems = Items.Where(s => !s.Item.Filtered.Value).ToList();
|
||||
|
||||
if (!visibleItems.Any())
|
||||
if (beatmapSets.All(s => s.Filtered.Value))
|
||||
return;
|
||||
|
||||
DrawableCarouselItem drawable = null;
|
||||
if (skipDifficulties)
|
||||
selectNextSet(direction, true);
|
||||
else
|
||||
selectNextDifficulty(direction);
|
||||
}
|
||||
|
||||
if (selectedBeatmap != null && (drawable = selectedBeatmap.Drawables.FirstOrDefault()) == null)
|
||||
// if the selected beatmap isn't present yet, we can't correctly change selection.
|
||||
// we can fix this by changing this method to not reference drawables / Items in the first place.
|
||||
return;
|
||||
private void selectNextSet(int direction, bool skipDifficulties)
|
||||
{
|
||||
var unfilteredSets = beatmapSets.Where(s => !s.Filtered.Value).ToList();
|
||||
|
||||
int originalIndex = visibleItems.IndexOf(drawable);
|
||||
int currentIndex = originalIndex;
|
||||
var nextSet = unfilteredSets[(unfilteredSets.IndexOf(selectedBeatmapSet) + direction + unfilteredSets.Count) % unfilteredSets.Count];
|
||||
|
||||
// local function to increment the index in the required direction, wrapping over extremities.
|
||||
int incrementIndex() => currentIndex = (currentIndex + direction + visibleItems.Count) % visibleItems.Count;
|
||||
if (skipDifficulties)
|
||||
select(nextSet);
|
||||
else
|
||||
select(direction > 0 ? nextSet.Beatmaps.First(b => !b.Filtered.Value) : nextSet.Beatmaps.Last(b => !b.Filtered.Value));
|
||||
}
|
||||
|
||||
while (incrementIndex() != originalIndex)
|
||||
{
|
||||
var item = visibleItems[currentIndex].Item;
|
||||
private void selectNextDifficulty(int direction)
|
||||
{
|
||||
var unfilteredDifficulties = selectedBeatmapSet.Children.Where(s => !s.Filtered.Value).ToList();
|
||||
|
||||
if (item.Filtered.Value || item.State.Value == CarouselItemState.Selected) continue;
|
||||
int index = unfilteredDifficulties.IndexOf(selectedBeatmap);
|
||||
|
||||
switch (item)
|
||||
{
|
||||
case CarouselBeatmap beatmap:
|
||||
if (skipDifficulties) continue;
|
||||
|
||||
select(beatmap);
|
||||
return;
|
||||
|
||||
case CarouselBeatmapSet set:
|
||||
if (skipDifficulties)
|
||||
select(set);
|
||||
else
|
||||
select(direction > 0 ? set.Beatmaps.First(b => !b.Filtered.Value) : set.Beatmaps.Last(b => !b.Filtered.Value));
|
||||
return;
|
||||
}
|
||||
}
|
||||
if (index + direction < 0 || index + direction >= unfilteredDifficulties.Count)
|
||||
selectNextSet(direction, false);
|
||||
else
|
||||
select(unfilteredDifficulties[index + direction]);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
30
osu.Game/Skinning/LegacyManiaSkinConfiguration.cs
Normal file
30
osu.Game/Skinning/LegacyManiaSkinConfiguration.cs
Normal file
@ -0,0 +1,30 @@
|
||||
// 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;
|
||||
|
||||
namespace osu.Game.Skinning
|
||||
{
|
||||
public class LegacyManiaSkinConfiguration
|
||||
{
|
||||
public readonly int Keys;
|
||||
|
||||
public readonly float[] ColumnLineWidth;
|
||||
public readonly float[] ColumnSpacing;
|
||||
public readonly float[] ColumnWidth;
|
||||
|
||||
public float HitPosition = 124.8f; // (480 - 402) * 1.6f
|
||||
|
||||
public LegacyManiaSkinConfiguration(int keys)
|
||||
{
|
||||
Keys = keys;
|
||||
|
||||
ColumnLineWidth = new float[keys + 1];
|
||||
ColumnSpacing = new float[keys - 1];
|
||||
ColumnWidth = new float[keys];
|
||||
|
||||
ColumnLineWidth.AsSpan().Fill(2);
|
||||
ColumnWidth.AsSpan().Fill(48);
|
||||
}
|
||||
}
|
||||
}
|
110
osu.Game/Skinning/LegacyManiaSkinDecoder.cs
Normal file
110
osu.Game/Skinning/LegacyManiaSkinDecoder.cs
Normal file
@ -0,0 +1,110 @@
|
||||
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
|
||||
// See the LICENCE file in the repository root for full licence text.
|
||||
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
using System.Globalization;
|
||||
using System.Linq;
|
||||
using osu.Game.Beatmaps.Formats;
|
||||
|
||||
namespace osu.Game.Skinning
|
||||
{
|
||||
public class LegacyManiaSkinDecoder : LegacyDecoder<List<LegacyManiaSkinConfiguration>>
|
||||
{
|
||||
private const float size_scale_factor = 1.6f;
|
||||
|
||||
public LegacyManiaSkinDecoder()
|
||||
: base(1)
|
||||
{
|
||||
}
|
||||
|
||||
private readonly List<string> pendingLines = new List<string>();
|
||||
private LegacyManiaSkinConfiguration currentConfig;
|
||||
|
||||
protected override void OnBeginNewSection(Section section)
|
||||
{
|
||||
base.OnBeginNewSection(section);
|
||||
|
||||
// If a new section is reached with pending lines remaining, they can all be discarded as there isn't a valid configuration to parse them into.
|
||||
pendingLines.Clear();
|
||||
currentConfig = null;
|
||||
}
|
||||
|
||||
protected override void ParseLine(List<LegacyManiaSkinConfiguration> output, Section section, string line)
|
||||
{
|
||||
line = StripComments(line);
|
||||
|
||||
switch (section)
|
||||
{
|
||||
case Section.Mania:
|
||||
var pair = SplitKeyVal(line);
|
||||
|
||||
switch (pair.Key)
|
||||
{
|
||||
case "Keys":
|
||||
currentConfig = new LegacyManiaSkinConfiguration(int.Parse(pair.Value, CultureInfo.InvariantCulture));
|
||||
|
||||
// Silently ignore duplicate configurations.
|
||||
if (output.All(c => c.Keys != currentConfig.Keys))
|
||||
output.Add(currentConfig);
|
||||
|
||||
// All existing lines can be flushed now that we have a valid configuration.
|
||||
flushPendingLines();
|
||||
break;
|
||||
|
||||
default:
|
||||
pendingLines.Add(line);
|
||||
|
||||
// Hold all lines until a "Keys" item is found.
|
||||
if (currentConfig != null)
|
||||
flushPendingLines();
|
||||
break;
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
private void flushPendingLines()
|
||||
{
|
||||
Debug.Assert(currentConfig != null);
|
||||
|
||||
foreach (var line in pendingLines)
|
||||
{
|
||||
var pair = SplitKeyVal(line);
|
||||
|
||||
switch (pair.Key)
|
||||
{
|
||||
case "ColumnLineWidth":
|
||||
parseArrayValue(pair.Value, currentConfig.ColumnLineWidth);
|
||||
break;
|
||||
|
||||
case "ColumnSpacing":
|
||||
parseArrayValue(pair.Value, currentConfig.ColumnSpacing);
|
||||
break;
|
||||
|
||||
case "ColumnWidth":
|
||||
parseArrayValue(pair.Value, currentConfig.ColumnWidth);
|
||||
break;
|
||||
|
||||
case "HitPosition":
|
||||
currentConfig.HitPosition = (480 - float.Parse(pair.Value, CultureInfo.InvariantCulture)) * size_scale_factor;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void parseArrayValue(string value, float[] output)
|
||||
{
|
||||
string[] values = value.Split(',');
|
||||
|
||||
for (int i = 0; i < values.Length; i++)
|
||||
{
|
||||
if (i >= output.Length)
|
||||
break;
|
||||
|
||||
output[i] = float.Parse(values[i], CultureInfo.InvariantCulture) * size_scale_factor;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user