1
0
mirror of https://github.com/ppy/osu.git synced 2024-12-14 20:22:55 +08:00

Merge branch 'master' into ouendan2-hidden

This commit is contained in:
Bartłomiej Dach 2021-10-26 17:20:45 +02:00 committed by GitHub
commit 57f83a22e7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
44 changed files with 770 additions and 225 deletions

View File

@ -51,8 +51,8 @@
<Reference Include="Java.Interop" /> <Reference Include="Java.Interop" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<PackageReference Include="ppy.osu.Game.Resources" Version="2021.1015.0" /> <PackageReference Include="ppy.osu.Game.Resources" Version="2021.1026.0" />
<PackageReference Include="ppy.osu.Framework.Android" Version="2021.1014.0" /> <PackageReference Include="ppy.osu.Framework.Android" Version="2021.1026.0" />
</ItemGroup> </ItemGroup>
<ItemGroup Label="Transitive Dependencies"> <ItemGroup Label="Transitive Dependencies">
<!-- Realm needs to be directly referenced in all Xamarin projects, as it will not pull in its transitive dependencies otherwise. --> <!-- Realm needs to be directly referenced in all Xamarin projects, as it will not pull in its transitive dependencies otherwise. -->

View File

@ -0,0 +1,91 @@
// 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.Framework.Input.Events;
using osu.Framework.Timing;
using osu.Game.Beatmaps;
using osu.Game.Rulesets.Catch.Edit;
using osu.Game.Rulesets.Catch.Edit.Blueprints.Components;
using osu.Game.Rulesets.Catch.Objects;
using osu.Game.Rulesets.Catch.UI;
using osu.Game.Rulesets.UI;
using osu.Game.Rulesets.UI.Scrolling;
using osu.Game.Tests.Visual;
using osuTK;
namespace osu.Game.Rulesets.Catch.Tests.Editor
{
public class TestSceneCatchDistanceSnapGrid : OsuManualInputManagerTestScene
{
private readonly ManualClock manualClock = new ManualClock();
[Cached(typeof(Playfield))]
private readonly CatchPlayfield playfield;
private ScrollingHitObjectContainer hitObjectContainer => playfield.HitObjectContainer;
private readonly CatchDistanceSnapGrid distanceGrid;
private readonly FruitOutline fruitOutline;
private readonly Fruit fruit = new Fruit();
public TestSceneCatchDistanceSnapGrid()
{
Child = new Container
{
Anchor = Anchor.Centre,
Origin = Anchor.Centre,
RelativeSizeAxes = Axes.Y,
Width = 500,
Children = new Drawable[]
{
new ScrollingTestContainer(ScrollingDirection.Down)
{
RelativeSizeAxes = Axes.Both,
Child = playfield = new CatchPlayfield(new BeatmapDifficulty())
{
RelativeSizeAxes = Axes.Both,
Clock = new FramedClock(manualClock)
}
},
distanceGrid = new CatchDistanceSnapGrid(new double[] { 0, -1, 1 }),
fruitOutline = new FruitOutline()
},
};
}
protected override void Update()
{
base.Update();
distanceGrid.StartTime = 100;
distanceGrid.StartX = 250;
Vector2 screenSpacePosition = InputManager.CurrentState.Mouse.Position;
var result = distanceGrid.GetSnappedPosition(screenSpacePosition);
if (result != null)
{
fruit.OriginalX = hitObjectContainer.ToLocalSpace(result.ScreenSpacePosition).X;
if (result.Time != null)
fruit.StartTime = result.Time.Value;
}
fruitOutline.Position = CatchHitObjectUtils.GetStartPosition(hitObjectContainer, fruit);
fruitOutline.UpdateFrom(fruit);
}
protected override bool OnScroll(ScrollEvent e)
{
manualClock.CurrentTime -= e.ScrollDelta.Y * 50;
return true;
}
}
}

View File

@ -0,0 +1,141 @@
// 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 JetBrains.Annotations;
using osu.Framework.Allocation;
using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers;
using osu.Framework.Graphics.Lines;
using osu.Framework.Graphics.Primitives;
using osu.Game.Rulesets.Catch.UI;
using osu.Game.Rulesets.Edit;
using osu.Game.Rulesets.UI;
using osu.Game.Rulesets.UI.Scrolling;
using osuTK;
namespace osu.Game.Rulesets.Catch.Edit
{
/// <summary>
/// The guide lines used in the osu!catch editor to compose patterns that can be caught with constant speed.
/// Currently, only forward placement (an object is snapped based on the previous object, not the opposite) is supported.
/// </summary>
public class CatchDistanceSnapGrid : CompositeDrawable
{
public double StartTime { get; set; }
public float StartX { get; set; }
private const double max_vertical_line_length_in_time = CatchPlayfield.WIDTH / Catcher.BASE_SPEED * 2;
private readonly double[] velocities;
private readonly List<Path> verticalPaths = new List<Path>();
private readonly List<Vector2[]> verticalLineVertices = new List<Vector2[]>();
[Resolved]
private Playfield playfield { get; set; }
private ScrollingHitObjectContainer hitObjectContainer => (ScrollingHitObjectContainer)playfield.HitObjectContainer;
public CatchDistanceSnapGrid(double[] velocities)
{
RelativeSizeAxes = Axes.Both;
Anchor = Anchor.BottomLeft;
this.velocities = velocities;
for (int i = 0; i < velocities.Length; i++)
{
verticalPaths.Add(new SmoothPath
{
PathRadius = 2,
Alpha = 0.5f,
});
verticalLineVertices.Add(new[] { Vector2.Zero, Vector2.Zero });
}
AddRangeInternal(verticalPaths);
}
protected override void Update()
{
base.Update();
double currentTime = hitObjectContainer.Time.Current;
for (int i = 0; i < velocities.Length; i++)
{
double velocity = velocities[i];
// The line ends at the top of the playfield.
double endTime = hitObjectContainer.TimeAtPosition(-hitObjectContainer.DrawHeight, currentTime);
// Non-vertical lines are cut at the sides of the playfield.
// Vertical lines are cut at some reasonable length.
if (velocity > 0)
endTime = Math.Min(endTime, StartTime + (CatchPlayfield.WIDTH - StartX) / velocity);
else if (velocity < 0)
endTime = Math.Min(endTime, StartTime + StartX / -velocity);
else
endTime = Math.Min(endTime, StartTime + max_vertical_line_length_in_time);
Vector2[] lineVertices = verticalLineVertices[i];
lineVertices[0] = calculatePosition(velocity, StartTime);
lineVertices[1] = calculatePosition(velocity, endTime);
var verticalPath = verticalPaths[i];
verticalPath.Vertices = verticalLineVertices[i];
verticalPath.OriginPosition = verticalPath.PositionInBoundingBox(Vector2.Zero);
}
Vector2 calculatePosition(double velocity, double time)
{
// Don't draw inverted lines.
time = Math.Max(time, StartTime);
float x = StartX + (float)((time - StartTime) * velocity);
float y = hitObjectContainer.PositionAtTime(time, currentTime);
return new Vector2(x, y);
}
}
[CanBeNull]
public SnapResult GetSnappedPosition(Vector2 screenSpacePosition)
{
double time = hitObjectContainer.TimeAtScreenSpacePosition(screenSpacePosition);
// If the cursor is below the distance snap grid, snap to the origin.
// Not returning `null` to retain the continuous snapping behavior when the cursor is slightly below the origin.
// This behavior is not currently visible in the editor because editor chooses the snap start time based on the mouse position.
if (time <= StartTime)
{
float y = hitObjectContainer.PositionAtTime(StartTime);
Vector2 originPosition = hitObjectContainer.ToScreenSpace(new Vector2(StartX, y));
return new SnapResult(originPosition, StartTime);
}
return enumerateSnappingCandidates(time)
.OrderBy(pos => Vector2.DistanceSquared(screenSpacePosition, pos.ScreenSpacePosition))
.FirstOrDefault();
}
private IEnumerable<SnapResult> enumerateSnappingCandidates(double time)
{
float y = hitObjectContainer.PositionAtTime(time);
foreach (double velocity in velocities)
{
float x = (float)(StartX + (time - StartTime) * velocity);
Vector2 screenSpacePosition = hitObjectContainer.ToScreenSpace(new Vector2(x, y + hitObjectContainer.DrawHeight));
yield return new SnapResult(screenSpacePosition, time);
}
}
protected override bool ComputeIsMaskedAway(RectangleF maskingBounds) => false;
}
}

View File

@ -2,14 +2,23 @@
// See the LICENCE file in the repository root for full licence text. // See the LICENCE file in the repository root for full licence text.
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq;
using JetBrains.Annotations;
using osu.Framework.Allocation; using osu.Framework.Allocation;
using osu.Framework.Bindables;
using osu.Framework.Graphics; using osu.Framework.Graphics;
using osu.Framework.Graphics.Sprites;
using osu.Framework.Input;
using osu.Game.Beatmaps; using osu.Game.Beatmaps;
using osu.Game.Graphics.UserInterface;
using osu.Game.Rulesets.Catch.Objects; using osu.Game.Rulesets.Catch.Objects;
using osu.Game.Rulesets.Catch.UI;
using osu.Game.Rulesets.Edit; using osu.Game.Rulesets.Edit;
using osu.Game.Rulesets.Edit.Tools; using osu.Game.Rulesets.Edit.Tools;
using osu.Game.Rulesets.Mods; using osu.Game.Rulesets.Mods;
using osu.Game.Rulesets.Objects;
using osu.Game.Rulesets.UI; using osu.Game.Rulesets.UI;
using osu.Game.Screens.Edit.Components.TernaryButtons;
using osu.Game.Screens.Edit.Compose.Components; using osu.Game.Screens.Edit.Compose.Components;
using osuTK; using osuTK;
@ -17,6 +26,14 @@ namespace osu.Game.Rulesets.Catch.Edit
{ {
public class CatchHitObjectComposer : HitObjectComposer<CatchHitObject> public class CatchHitObjectComposer : HitObjectComposer<CatchHitObject>
{ {
private const float distance_snap_radius = 50;
private CatchDistanceSnapGrid distanceSnapGrid;
private readonly Bindable<TernaryState> distanceSnapToggle = new Bindable<TernaryState>();
private InputManager inputManager;
public CatchHitObjectComposer(CatchRuleset ruleset) public CatchHitObjectComposer(CatchRuleset ruleset)
: base(ruleset) : base(ruleset)
{ {
@ -30,6 +47,27 @@ namespace osu.Game.Rulesets.Catch.Edit
RelativeSizeAxes = Axes.Both, RelativeSizeAxes = Axes.Both,
PlayfieldBorderStyle = { Value = PlayfieldBorderStyle.Corners } PlayfieldBorderStyle = { Value = PlayfieldBorderStyle.Corners }
}); });
LayerBelowRuleset.Add(distanceSnapGrid = new CatchDistanceSnapGrid(new[]
{
0.0,
Catcher.BASE_SPEED, -Catcher.BASE_SPEED,
Catcher.BASE_SPEED / 2, -Catcher.BASE_SPEED / 2,
}));
}
protected override void LoadComplete()
{
base.LoadComplete();
inputManager = GetContainingInputManager();
}
protected override void Update()
{
base.Update();
updateDistanceSnapGrid();
} }
protected override DrawableRuleset<CatchHitObject> CreateDrawableRuleset(Ruleset ruleset, IBeatmap beatmap, IReadOnlyList<Mod> mods = null) => protected override DrawableRuleset<CatchHitObject> CreateDrawableRuleset(Ruleset ruleset, IBeatmap beatmap, IReadOnlyList<Mod> mods = null) =>
@ -42,14 +80,95 @@ namespace osu.Game.Rulesets.Catch.Edit
new BananaShowerCompositionTool() new BananaShowerCompositionTool()
}; };
protected override IEnumerable<TernaryButton> CreateTernaryButtons() => base.CreateTernaryButtons().Concat(new[]
{
new TernaryButton(distanceSnapToggle, "Distance Snap", () => new SpriteIcon { Icon = FontAwesome.Solid.Ruler })
});
public override SnapResult SnapScreenSpacePositionToValidTime(Vector2 screenSpacePosition) public override SnapResult SnapScreenSpacePositionToValidTime(Vector2 screenSpacePosition)
{ {
var result = base.SnapScreenSpacePositionToValidTime(screenSpacePosition); var result = base.SnapScreenSpacePositionToValidTime(screenSpacePosition);
// TODO: implement position snap
result.ScreenSpacePosition.X = screenSpacePosition.X; result.ScreenSpacePosition.X = screenSpacePosition.X;
if (distanceSnapGrid.IsPresent && distanceSnapGrid.GetSnappedPosition(result.ScreenSpacePosition) is SnapResult snapResult &&
Vector2.Distance(snapResult.ScreenSpacePosition, result.ScreenSpacePosition) < distance_snap_radius)
{
result = snapResult;
}
return result; return result;
} }
protected override ComposeBlueprintContainer CreateBlueprintContainer() => new CatchBlueprintContainer(this); protected override ComposeBlueprintContainer CreateBlueprintContainer() => new CatchBlueprintContainer(this);
[CanBeNull]
private PalpableCatchHitObject getLastSnappableHitObject(double time)
{
var hitObject = EditorBeatmap.HitObjects.OfType<CatchHitObject>().LastOrDefault(h => h.GetEndTime() < time && !(h is BananaShower));
switch (hitObject)
{
case Fruit fruit:
return fruit;
case JuiceStream juiceStream:
return juiceStream.NestedHitObjects.OfType<PalpableCatchHitObject>().LastOrDefault(h => !(h is TinyDroplet));
default:
return null;
}
}
[CanBeNull]
private PalpableCatchHitObject getDistanceSnapGridSourceHitObject()
{
switch (BlueprintContainer.CurrentTool)
{
case SelectTool _:
if (EditorBeatmap.SelectedHitObjects.Count == 0)
return null;
double minTime = EditorBeatmap.SelectedHitObjects.Min(hitObject => hitObject.StartTime);
return getLastSnappableHitObject(minTime);
case FruitCompositionTool _:
case JuiceStreamCompositionTool _:
if (!CursorInPlacementArea)
return null;
if (EditorBeatmap.PlacementObject.Value is JuiceStream)
{
// Juice stream path is not subject to snapping.
return null;
}
double timeAtCursor = ((CatchPlayfield)Playfield).TimeAtScreenSpacePosition(inputManager.CurrentState.Mouse.Position);
return getLastSnappableHitObject(timeAtCursor);
default:
return null;
}
}
private void updateDistanceSnapGrid()
{
if (distanceSnapToggle.Value != TernaryState.True)
{
distanceSnapGrid.Hide();
return;
}
var sourceHitObject = getDistanceSnapGridSourceHitObject();
if (sourceHitObject == null)
{
distanceSnapGrid.Hide();
return;
}
distanceSnapGrid.Show();
distanceSnapGrid.StartTime = sourceHitObject.GetEndTime();
distanceSnapGrid.StartX = sourceHitObject.EffectiveX;
}
} }
} }

View File

@ -775,5 +775,22 @@ namespace osu.Game.Tests.Beatmaps.Formats
Assert.That(seventh.ControlPoints[4].Type == null); Assert.That(seventh.ControlPoints[4].Type == null);
} }
} }
[Test]
public void TestSliderLengthExtensionEdgeCase()
{
var decoder = new LegacyBeatmapDecoder { ApplyOffsets = false };
using (var resStream = TestResources.OpenResource("duplicate-last-position-slider.osu"))
using (var stream = new LineBufferedReader(resStream))
{
var decoded = decoder.Decode(stream);
var path = ((IHasPath)decoded.HitObjects[0]).Path;
Assert.That(path.ExpectedDistance.Value, Is.EqualTo(2));
Assert.That(path.Distance, Is.EqualTo(1));
}
}
} }
} }

View File

@ -0,0 +1,19 @@
osu file format v14
[Difficulty]
HPDrainRate:7
CircleSize:10
OverallDifficulty:9
ApproachRate:10
SliderMultiplier:0.4
SliderTickRate:1
[TimingPoints]
382,923.076923076923,3,2,1,75,1,0
382,-1000,3,2,1,75,0,0
[HitObjects]
// Importantly, the last position is specified twice.
// In this case, osu-stable doesn't extend the slider length even when the "expected" length is higher than the actual.
261,171,25305,6,0,B|262:171|262:171|262:171,1,2,8|0,0:0|0:0,0:0:0:0:

View File

@ -224,7 +224,7 @@ namespace osu.Game.Tests.Visual.Components
public new PreviewTrack CurrentTrack => base.CurrentTrack; public new PreviewTrack CurrentTrack => base.CurrentTrack;
protected override TrackManagerPreviewTrack CreatePreviewTrack(BeatmapSetInfo beatmapSetInfo, ITrackStore trackStore) => new TestPreviewTrack(beatmapSetInfo, trackStore); protected override TrackManagerPreviewTrack CreatePreviewTrack(IBeatmapSetInfo beatmapSetInfo, ITrackStore trackStore) => new TestPreviewTrack(beatmapSetInfo, trackStore);
public override bool UpdateSubTree() public override bool UpdateSubTree()
{ {
@ -240,7 +240,7 @@ namespace osu.Game.Tests.Visual.Components
public new Track Track => base.Track; public new Track Track => base.Track;
public TestPreviewTrack(BeatmapSetInfo beatmapSetInfo, ITrackStore trackManager) public TestPreviewTrack(IBeatmapSetInfo beatmapSetInfo, ITrackStore trackManager)
: base(beatmapSetInfo, trackManager) : base(beatmapSetInfo, trackManager)
{ {
this.trackManager = trackManager; this.trackManager = trackManager;

View File

@ -56,6 +56,11 @@ namespace osu.Game.Tests.Visual.Editing
checkMutations(); checkMutations();
// After placement these must be non-default as defaults are read-only.
AddAssert("Placed object has non-default control points", () =>
editorBeatmap.HitObjects[0].SampleControlPoint != SampleControlPoint.DEFAULT &&
editorBeatmap.HitObjects[0].DifficultyControlPoint != DifficultyControlPoint.DEFAULT);
AddStep("Save", () => InputManager.Keys(PlatformAction.Save)); AddStep("Save", () => InputManager.Keys(PlatformAction.Save));
checkMutations(); checkMutations();

View File

@ -92,6 +92,18 @@ namespace osu.Game.Tests.Visual.Multiplayer
assertChatFocused(true); assertChatFocused(true);
} }
[Test]
public void TestFocusLostOnBackKey()
{
setLocalUserPlaying(true);
assertChatFocused(false);
AddStep("press tab", () => InputManager.Key(Key.Tab));
assertChatFocused(true);
AddStep("press escape", () => InputManager.Key(Key.Escape));
assertChatFocused(false);
}
[Test] [Test]
public void TestFocusOnTabKeyWhenNotExpanded() public void TestFocusOnTabKeyWhenNotExpanded()
{ {

View File

@ -7,14 +7,12 @@ using System.Linq;
using NUnit.Framework; using NUnit.Framework;
using osu.Framework.Graphics.Containers; using osu.Framework.Graphics.Containers;
using osu.Framework.Testing; using osu.Framework.Testing;
using osu.Game.Beatmaps;
using osu.Game.Graphics.UserInterface; using osu.Game.Graphics.UserInterface;
using osu.Game.Online.API; using osu.Game.Online.API;
using osu.Game.Online.API.Requests; using osu.Game.Online.API.Requests;
using osu.Game.Online.API.Requests.Responses; using osu.Game.Online.API.Requests.Responses;
using osu.Game.Overlays; using osu.Game.Overlays;
using osu.Game.Overlays.BeatmapListing; using osu.Game.Overlays.BeatmapListing;
using osu.Game.Rulesets;
using osu.Game.Scoring; using osu.Game.Scoring;
using osu.Game.Users; using osu.Game.Users;
using osuTK.Input; using osuTK.Input;
@ -92,7 +90,7 @@ namespace osu.Game.Tests.Visual.Online
{ {
AddAssert("is visible", () => overlay.State.Value == Visibility.Visible); AddAssert("is visible", () => overlay.State.Value == Visibility.Visible);
AddStep("show many results", () => fetchFor(Enumerable.Repeat(CreateBeatmap(Ruleset.Value).BeatmapInfo.BeatmapSet, 100).ToArray())); AddStep("show many results", () => fetchFor(Enumerable.Repeat(CreateAPIBeatmapSet(Ruleset.Value), 10).ToArray()));
AddUntilStep("placeholder hidden", () => !overlay.ChildrenOfType<BeatmapListingOverlay.NotFoundDrawable>().Any(d => d.IsPresent)); AddUntilStep("placeholder hidden", () => !overlay.ChildrenOfType<BeatmapListingOverlay.NotFoundDrawable>().Any(d => d.IsPresent));
@ -114,7 +112,7 @@ namespace osu.Game.Tests.Visual.Online
AddStep("fetch for 0 beatmaps", () => fetchFor()); AddStep("fetch for 0 beatmaps", () => fetchFor());
AddUntilStep("placeholder shown", () => overlay.ChildrenOfType<BeatmapListingOverlay.NotFoundDrawable>().SingleOrDefault()?.IsPresent == true); AddUntilStep("placeholder shown", () => overlay.ChildrenOfType<BeatmapListingOverlay.NotFoundDrawable>().SingleOrDefault()?.IsPresent == true);
AddStep("fetch for 1 beatmap", () => fetchFor(CreateBeatmap(Ruleset.Value).BeatmapInfo.BeatmapSet)); AddStep("fetch for 1 beatmap", () => fetchFor(CreateAPIBeatmapSet(Ruleset.Value)));
AddUntilStep("placeholder hidden", () => !overlay.ChildrenOfType<BeatmapListingOverlay.NotFoundDrawable>().Any(d => d.IsPresent)); AddUntilStep("placeholder hidden", () => !overlay.ChildrenOfType<BeatmapListingOverlay.NotFoundDrawable>().Any(d => d.IsPresent));
AddStep("fetch for 0 beatmaps", () => fetchFor()); AddStep("fetch for 0 beatmaps", () => fetchFor());
@ -188,7 +186,7 @@ namespace osu.Game.Tests.Visual.Online
[Test] [Test]
public void TestUserWithoutSupporterUsesSupporterOnlyFiltersWithResults() public void TestUserWithoutSupporterUsesSupporterOnlyFiltersWithResults()
{ {
AddStep("fetch for 1 beatmap", () => fetchFor(CreateBeatmap(Ruleset.Value).BeatmapInfo.BeatmapSet)); AddStep("fetch for 1 beatmap", () => fetchFor(CreateAPIBeatmapSet(Ruleset.Value)));
AddStep("set dummy as non-supporter", () => ((DummyAPIAccess)API).LocalUser.Value.IsSupporter = false); AddStep("set dummy as non-supporter", () => ((DummyAPIAccess)API).LocalUser.Value.IsSupporter = false);
// only Rank Achieved filter // only Rank Achieved filter
@ -218,7 +216,7 @@ namespace osu.Game.Tests.Visual.Online
[Test] [Test]
public void TestUserWithSupporterUsesSupporterOnlyFiltersWithResults() public void TestUserWithSupporterUsesSupporterOnlyFiltersWithResults()
{ {
AddStep("fetch for 1 beatmap", () => fetchFor(CreateBeatmap(Ruleset.Value).BeatmapInfo.BeatmapSet)); AddStep("fetch for 1 beatmap", () => fetchFor(CreateAPIBeatmapSet(Ruleset.Value)));
AddStep("set dummy as supporter", () => ((DummyAPIAccess)API).LocalUser.Value.IsSupporter = true); AddStep("set dummy as supporter", () => ((DummyAPIAccess)API).LocalUser.Value.IsSupporter = true);
// only Rank Achieved filter // only Rank Achieved filter
@ -247,10 +245,10 @@ namespace osu.Game.Tests.Visual.Online
private static int searchCount; private static int searchCount;
private void fetchFor(params BeatmapSetInfo[] beatmaps) private void fetchFor(params APIBeatmapSet[] beatmaps)
{ {
setsForResponse.Clear(); setsForResponse.Clear();
setsForResponse.AddRange(beatmaps.Select(b => new TestAPIBeatmapSet(b))); setsForResponse.AddRange(beatmaps);
// trigger arbitrary change for fetching. // trigger arbitrary change for fetching.
searchControl.Query.Value = $"search {searchCount++}"; searchControl.Query.Value = $"search {searchCount++}";
@ -286,17 +284,5 @@ namespace osu.Game.Tests.Visual.Online
!overlay.ChildrenOfType<BeatmapListingOverlay.SupporterRequiredDrawable>().Any(d => d.IsPresent) !overlay.ChildrenOfType<BeatmapListingOverlay.SupporterRequiredDrawable>().Any(d => d.IsPresent)
&& !overlay.ChildrenOfType<BeatmapListingOverlay.NotFoundDrawable>().Any(d => d.IsPresent)); && !overlay.ChildrenOfType<BeatmapListingOverlay.NotFoundDrawable>().Any(d => d.IsPresent));
} }
private class TestAPIBeatmapSet : APIBeatmapSet
{
private readonly BeatmapSetInfo beatmapSet;
public TestAPIBeatmapSet(BeatmapSetInfo beatmapSet)
{
this.beatmapSet = beatmapSet;
}
public override BeatmapSetInfo ToBeatmapSet(RulesetStore rulesets) => beatmapSet;
}
} }
} }

View File

@ -73,10 +73,10 @@ namespace osu.Game.Tests.Visual.Online
Ranked = DateTime.Now, Ranked = DateTime.Now,
BPM = 111, BPM = 111,
HasVideo = true, HasVideo = true,
Ratings = Enumerable.Range(0, 11).ToArray(),
HasStoryboard = true, HasStoryboard = true,
Covers = new BeatmapSetOnlineCovers(), Covers = new BeatmapSetOnlineCovers(),
}, },
Metrics = new BeatmapSetMetrics { Ratings = Enumerable.Range(0, 11).ToArray() },
Beatmaps = new List<BeatmapInfo> Beatmaps = new List<BeatmapInfo>
{ {
new BeatmapInfo new BeatmapInfo
@ -92,17 +92,17 @@ namespace osu.Game.Tests.Visual.Online
OverallDifficulty = 4.5f, OverallDifficulty = 4.5f,
ApproachRate = 6, ApproachRate = 6,
}, },
OnlineInfo = new BeatmapOnlineInfo OnlineInfo = new APIBeatmap
{ {
CircleCount = 111, CircleCount = 111,
SliderCount = 12, SliderCount = 12,
PlayCount = 222, PlayCount = 222,
PassCount = 21, PassCount = 21,
}, FailTimes = new APIFailTimes
Metrics = new BeatmapMetrics {
{ Fails = Enumerable.Range(1, 100).Select(i => i % 12 - 6).ToArray(),
Fails = Enumerable.Range(1, 100).Select(i => i % 12 - 6).ToArray(), Retries = Enumerable.Range(-2, 100).Select(i => i % 12 - 6).ToArray(),
Retries = Enumerable.Range(-2, 100).Select(i => i % 12 - 6).ToArray(), },
}, },
}, },
}, },
@ -153,8 +153,8 @@ namespace osu.Game.Tests.Visual.Online
Covers = new BeatmapSetOnlineCovers(), Covers = new BeatmapSetOnlineCovers(),
Language = new BeatmapSetOnlineLanguage { Id = 3, Name = "English" }, Language = new BeatmapSetOnlineLanguage { Id = 3, Name = "English" },
Genre = new BeatmapSetOnlineGenre { Id = 4, Name = "Rock" }, Genre = new BeatmapSetOnlineGenre { Id = 4, Name = "Rock" },
Ratings = Enumerable.Range(0, 11).ToArray(),
}, },
Metrics = new BeatmapSetMetrics { Ratings = Enumerable.Range(0, 11).ToArray() },
Beatmaps = new List<BeatmapInfo> Beatmaps = new List<BeatmapInfo>
{ {
new BeatmapInfo new BeatmapInfo
@ -170,17 +170,17 @@ namespace osu.Game.Tests.Visual.Online
OverallDifficulty = 7, OverallDifficulty = 7,
ApproachRate = 6, ApproachRate = 6,
}, },
OnlineInfo = new BeatmapOnlineInfo OnlineInfo = new APIBeatmap
{ {
CircleCount = 123, CircleCount = 123,
SliderCount = 45, SliderCount = 45,
PlayCount = 567, PlayCount = 567,
PassCount = 89, PassCount = 89,
}, FailTimes = new APIFailTimes
Metrics = new BeatmapMetrics {
{ Fails = Enumerable.Range(1, 100).Select(i => i % 12 - 6).ToArray(),
Fails = Enumerable.Range(1, 100).Select(i => i % 12 - 6).ToArray(), Retries = Enumerable.Range(-2, 100).Select(i => i % 12 - 6).ToArray(),
Retries = Enumerable.Range(-2, 100).Select(i => i % 12 - 6).ToArray(), },
}, },
}, },
}, },
@ -204,12 +204,14 @@ namespace osu.Game.Tests.Visual.Online
Version = ruleset.Name, Version = ruleset.Name,
Ruleset = ruleset, Ruleset = ruleset,
BaseDifficulty = new BeatmapDifficulty(), BaseDifficulty = new BeatmapDifficulty(),
OnlineInfo = new BeatmapOnlineInfo(), OnlineInfo = new APIBeatmap
Metrics = new BeatmapMetrics
{ {
Fails = Enumerable.Range(1, 100).Select(i => i % 12 - 6).ToArray(), FailTimes = new APIFailTimes
Retries = Enumerable.Range(-2, 100).Select(i => i % 12 - 6).ToArray(), {
}, Fails = Enumerable.Range(1, 100).Select(i => i % 12 - 6).ToArray(),
Retries = Enumerable.Range(-2, 100).Select(i => i % 12 - 6).ToArray(),
},
}
}); });
} }
@ -228,8 +230,8 @@ namespace osu.Game.Tests.Visual.Online
OnlineInfo = new APIBeatmapSet OnlineInfo = new APIBeatmapSet
{ {
Covers = new BeatmapSetOnlineCovers(), Covers = new BeatmapSetOnlineCovers(),
Ratings = Enumerable.Range(0, 11).ToArray(),
}, },
Metrics = new BeatmapSetMetrics { Ratings = Enumerable.Range(0, 11).ToArray() },
Beatmaps = beatmaps Beatmaps = beatmaps
}); });
}); });
@ -288,12 +290,14 @@ namespace osu.Game.Tests.Visual.Online
{ {
OverallDifficulty = 3.5f, OverallDifficulty = 3.5f,
}, },
OnlineInfo = new BeatmapOnlineInfo(), OnlineInfo = new APIBeatmap
Metrics = new BeatmapMetrics
{ {
Fails = Enumerable.Range(1, 100).Select(j => j % 12 - 6).ToArray(), FailTimes = new APIFailTimes
Retries = Enumerable.Range(-2, 100).Select(j => j % 12 - 6).ToArray(), {
}, Fails = Enumerable.Range(1, 100).Select(j => j % 12 - 6).ToArray(),
Retries = Enumerable.Range(-2, 100).Select(j => j % 12 - 6).ToArray(),
},
}
}); });
} }
@ -316,8 +320,8 @@ namespace osu.Game.Tests.Visual.Online
HasVideo = true, HasVideo = true,
HasStoryboard = true, HasStoryboard = true,
Covers = new BeatmapSetOnlineCovers(), Covers = new BeatmapSetOnlineCovers(),
Ratings = Enumerable.Range(0, 11).ToArray(),
}, },
Metrics = new BeatmapSetMetrics { Ratings = Enumerable.Range(0, 11).ToArray() },
Beatmaps = beatmaps, Beatmaps = beatmaps,
}; };
} }

View File

@ -39,27 +39,30 @@ namespace osu.Game.Tests.Visual.Online
var secondSet = createSet(); var secondSet = createSet();
AddStep("set first set", () => details.BeatmapSet = firstSet); AddStep("set first set", () => details.BeatmapSet = firstSet);
AddAssert("ratings set", () => details.Ratings.Metrics == firstSet.Metrics); AddAssert("ratings set", () => details.Ratings.Ratings == firstSet.Ratings);
AddStep("set second set", () => details.BeatmapSet = secondSet); AddStep("set second set", () => details.BeatmapSet = secondSet);
AddAssert("ratings set", () => details.Ratings.Metrics == secondSet.Metrics); AddAssert("ratings set", () => details.Ratings.Ratings == secondSet.Ratings);
static BeatmapSetInfo createSet() => new BeatmapSetInfo static BeatmapSetInfo createSet() => new BeatmapSetInfo
{ {
Metrics = new BeatmapSetMetrics { Ratings = Enumerable.Range(0, 11).Select(_ => RNG.Next(10)).ToArray() },
Beatmaps = new List<BeatmapInfo> Beatmaps = new List<BeatmapInfo>
{ {
new BeatmapInfo new BeatmapInfo
{ {
Metrics = new BeatmapMetrics OnlineInfo = new APIBeatmap
{ {
Fails = Enumerable.Range(1, 100).Select(_ => RNG.Next(10)).ToArray(), FailTimes = new APIFailTimes
Retries = Enumerable.Range(-2, 100).Select(_ => RNG.Next(10)).ToArray(), {
}, Fails = Enumerable.Range(1, 100).Select(_ => RNG.Next(10)).ToArray(),
Retries = Enumerable.Range(-2, 100).Select(_ => RNG.Next(10)).ToArray(),
},
}
} }
}, },
OnlineInfo = new APIBeatmapSet OnlineInfo = new APIBeatmapSet
{ {
Ratings = Enumerable.Range(0, 11).Select(_ => RNG.Next(10)).ToArray(),
Status = BeatmapSetOnlineStatus.Ranked Status = BeatmapSetOnlineStatus.Ranked
} }
}; };

View File

@ -11,6 +11,7 @@ using osu.Framework.Testing;
using osu.Framework.Utils; using osu.Framework.Utils;
using osu.Game.Beatmaps; using osu.Game.Beatmaps;
using osu.Game.Graphics.UserInterface; using osu.Game.Graphics.UserInterface;
using osu.Game.Online.API.Requests.Responses;
using osu.Game.Overlays; using osu.Game.Overlays;
using osu.Game.Overlays.BeatmapSet; using osu.Game.Overlays.BeatmapSet;
using osu.Game.Screens.Select.Details; using osu.Game.Screens.Select.Details;
@ -59,17 +60,20 @@ namespace osu.Game.Tests.Visual.Online
var secondBeatmap = createBeatmap(); var secondBeatmap = createBeatmap();
AddStep("set first set", () => successRate.BeatmapInfo = firstBeatmap); AddStep("set first set", () => successRate.BeatmapInfo = firstBeatmap);
AddAssert("ratings set", () => successRate.Graph.Metrics == firstBeatmap.Metrics); AddAssert("ratings set", () => successRate.Graph.FailTimes == firstBeatmap.FailTimes);
AddStep("set second set", () => successRate.BeatmapInfo = secondBeatmap); AddStep("set second set", () => successRate.BeatmapInfo = secondBeatmap);
AddAssert("ratings set", () => successRate.Graph.Metrics == secondBeatmap.Metrics); AddAssert("ratings set", () => successRate.Graph.FailTimes == secondBeatmap.FailTimes);
static BeatmapInfo createBeatmap() => new BeatmapInfo static BeatmapInfo createBeatmap() => new BeatmapInfo
{ {
Metrics = new BeatmapMetrics OnlineInfo = new APIBeatmap
{ {
Fails = Enumerable.Range(1, 100).Select(_ => RNG.Next(10)).ToArray(), FailTimes = new APIFailTimes
Retries = Enumerable.Range(-2, 100).Select(_ => RNG.Next(10)).ToArray(), {
Fails = Enumerable.Range(1, 100).Select(_ => RNG.Next(10)).ToArray(),
Retries = Enumerable.Range(-2, 100).Select(_ => RNG.Next(10)).ToArray(),
}
} }
}; };
} }
@ -79,13 +83,16 @@ namespace osu.Game.Tests.Visual.Online
{ {
AddStep("set beatmap", () => successRate.BeatmapInfo = new BeatmapInfo AddStep("set beatmap", () => successRate.BeatmapInfo = new BeatmapInfo
{ {
Metrics = new BeatmapMetrics OnlineInfo = new APIBeatmap
{ {
Fails = Enumerable.Range(1, 100).ToArray(), FailTimes = new APIFailTimes
{
Fails = Enumerable.Range(1, 100).ToArray(),
}
} }
}); });
AddAssert("graph max values correct",
() => successRate.ChildrenOfType<BarGraph>().All(graph => graph.MaxValue == 100)); AddAssert("graph max values correct", () => successRate.ChildrenOfType<BarGraph>().All(graph => graph.MaxValue == 100));
} }
[Test] [Test]
@ -93,11 +100,13 @@ namespace osu.Game.Tests.Visual.Online
{ {
AddStep("set beatmap", () => successRate.BeatmapInfo = new BeatmapInfo AddStep("set beatmap", () => successRate.BeatmapInfo = new BeatmapInfo
{ {
Metrics = new BeatmapMetrics() OnlineInfo = new APIBeatmap
{
FailTimes = new APIFailTimes(),
}
}); });
AddAssert("graph max values correct", AddAssert("graph max values correct", () => successRate.ChildrenOfType<BarGraph>().All(graph => graph.MaxValue == 0));
() => successRate.ChildrenOfType<BarGraph>().All(graph => graph.MaxValue == 0));
} }
private class GraphExposingSuccessRate : SuccessRate private class GraphExposingSuccessRate : SuccessRate

View File

@ -6,6 +6,7 @@ using NUnit.Framework;
using osu.Framework.Graphics; using osu.Framework.Graphics;
using osu.Game.Beatmaps; using osu.Game.Beatmaps;
using osu.Game.Online.API; using osu.Game.Online.API;
using osu.Game.Online.API.Requests.Responses;
using osu.Game.Screens.Select; using osu.Game.Screens.Select;
namespace osu.Game.Tests.Visual.SongSelect namespace osu.Game.Tests.Visual.SongSelect
@ -34,7 +35,10 @@ namespace osu.Game.Tests.Visual.SongSelect
{ {
BeatmapSet = new BeatmapSetInfo BeatmapSet = new BeatmapSetInfo
{ {
Metrics = new BeatmapSetMetrics { Ratings = Enumerable.Range(0, 11).ToArray() } OnlineInfo = new APIBeatmapSet
{
Ratings = Enumerable.Range(0, 11).ToArray(),
}
}, },
Version = "All Metrics", Version = "All Metrics",
Metadata = new BeatmapMetadata Metadata = new BeatmapMetadata
@ -50,11 +54,14 @@ namespace osu.Game.Tests.Visual.SongSelect
ApproachRate = 3.5f, ApproachRate = 3.5f,
}, },
StarDifficulty = 5.3f, StarDifficulty = 5.3f,
Metrics = new BeatmapMetrics OnlineInfo = new APIBeatmap
{ {
Fails = Enumerable.Range(1, 100).Select(i => i % 12 - 6).ToArray(), FailTimes = new APIFailTimes
Retries = Enumerable.Range(-2, 100).Select(i => i % 12 - 6).ToArray(), {
}, Fails = Enumerable.Range(1, 100).Select(i => i % 12 - 6).ToArray(),
Retries = Enumerable.Range(-2, 100).Select(i => i % 12 - 6).ToArray(),
},
}
}); });
} }
@ -65,7 +72,10 @@ namespace osu.Game.Tests.Visual.SongSelect
{ {
BeatmapSet = new BeatmapSetInfo BeatmapSet = new BeatmapSetInfo
{ {
Metrics = new BeatmapSetMetrics { Ratings = Enumerable.Range(0, 11).ToArray() } OnlineInfo = new APIBeatmapSet
{
Ratings = Enumerable.Range(0, 11).ToArray(),
}
}, },
Version = "All Metrics", Version = "All Metrics",
Metadata = new BeatmapMetadata Metadata = new BeatmapMetadata
@ -80,11 +90,14 @@ namespace osu.Game.Tests.Visual.SongSelect
ApproachRate = 3.5f, ApproachRate = 3.5f,
}, },
StarDifficulty = 5.3f, StarDifficulty = 5.3f,
Metrics = new BeatmapMetrics OnlineInfo = new APIBeatmap
{ {
Fails = Enumerable.Range(1, 100).Select(i => i % 12 - 6).ToArray(), FailTimes = new APIFailTimes
Retries = Enumerable.Range(-2, 100).Select(i => i % 12 - 6).ToArray(), {
}, Fails = Enumerable.Range(1, 100).Select(i => i % 12 - 6).ToArray(),
Retries = Enumerable.Range(-2, 100).Select(i => i % 12 - 6).ToArray(),
},
}
}); });
} }
@ -95,7 +108,10 @@ namespace osu.Game.Tests.Visual.SongSelect
{ {
BeatmapSet = new BeatmapSetInfo BeatmapSet = new BeatmapSetInfo
{ {
Metrics = new BeatmapSetMetrics { Ratings = Enumerable.Range(0, 11).ToArray() } OnlineInfo = new APIBeatmapSet
{
Ratings = Enumerable.Range(0, 11).ToArray(),
}
}, },
Version = "Only Ratings", Version = "Only Ratings",
Metadata = new BeatmapMetadata Metadata = new BeatmapMetadata
@ -133,11 +149,14 @@ namespace osu.Game.Tests.Visual.SongSelect
ApproachRate = 7, ApproachRate = 7,
}, },
StarDifficulty = 2.91f, StarDifficulty = 2.91f,
Metrics = new BeatmapMetrics OnlineInfo = new APIBeatmap
{ {
Fails = Enumerable.Range(1, 100).Select(i => i % 12 - 6).ToArray(), FailTimes = new APIFailTimes
Retries = Enumerable.Range(-2, 100).Select(i => i % 12 - 6).ToArray(), {
}, Fails = Enumerable.Range(1, 100).Select(i => i % 12 - 6).ToArray(),
Retries = Enumerable.Range(-2, 100).Select(i => i % 12 - 6).ToArray(),
},
}
}); });
} }

View File

@ -8,6 +8,7 @@ using osu.Framework.Platform;
using osu.Framework.Testing; using osu.Framework.Testing;
using osu.Framework.Utils; using osu.Framework.Utils;
using osu.Game.Beatmaps; using osu.Game.Beatmaps;
using osu.Game.Online.API.Requests.Responses;
using osu.Game.Rulesets; using osu.Game.Rulesets;
using osu.Game.Tests.Visual; using osu.Game.Tests.Visual;
using osu.Game.Tournament.IO; using osu.Game.Tournament.IO;
@ -160,7 +161,7 @@ namespace osu.Game.Tournament.Tests
Artist = "Test Artist", Artist = "Test Artist",
ID = RNG.Next(0, 1000000) ID = RNG.Next(0, 1000000)
}, },
OnlineInfo = new BeatmapOnlineInfo(), OnlineInfo = new APIBeatmap(),
}; };
protected override ITestSceneTestRunner CreateRunner() => new TournamentTestSceneTestRunner(); protected override ITestSceneTestRunner CreateRunner() => new TournamentTestSceneTestRunner();

View File

@ -43,11 +43,11 @@ namespace osu.Game.Audio
} }
/// <summary> /// <summary>
/// Retrieves a <see cref="PreviewTrack"/> for a <see cref="BeatmapSetInfo"/>. /// Retrieves a <see cref="PreviewTrack"/> for a <see cref="IBeatmapSetInfo"/>.
/// </summary> /// </summary>
/// <param name="beatmapSetInfo">The <see cref="BeatmapSetInfo"/> to retrieve the preview track for.</param> /// <param name="beatmapSetInfo">The <see cref="IBeatmapSetInfo"/> to retrieve the preview track for.</param>
/// <returns>The playable <see cref="PreviewTrack"/>.</returns> /// <returns>The playable <see cref="PreviewTrack"/>.</returns>
public PreviewTrack Get(BeatmapSetInfo beatmapSetInfo) public PreviewTrack Get(IBeatmapSetInfo beatmapSetInfo)
{ {
var track = CreatePreviewTrack(beatmapSetInfo, trackStore); var track = CreatePreviewTrack(beatmapSetInfo, trackStore);
@ -91,7 +91,7 @@ namespace osu.Game.Audio
/// <summary> /// <summary>
/// Creates the <see cref="TrackManagerPreviewTrack"/>. /// Creates the <see cref="TrackManagerPreviewTrack"/>.
/// </summary> /// </summary>
protected virtual TrackManagerPreviewTrack CreatePreviewTrack(BeatmapSetInfo beatmapSetInfo, ITrackStore trackStore) => protected virtual TrackManagerPreviewTrack CreatePreviewTrack(IBeatmapSetInfo beatmapSetInfo, ITrackStore trackStore) =>
new TrackManagerPreviewTrack(beatmapSetInfo, trackStore); new TrackManagerPreviewTrack(beatmapSetInfo, trackStore);
public class TrackManagerPreviewTrack : PreviewTrack public class TrackManagerPreviewTrack : PreviewTrack
@ -99,10 +99,10 @@ namespace osu.Game.Audio
[Resolved(canBeNull: true)] [Resolved(canBeNull: true)]
public IPreviewTrackOwner Owner { get; private set; } public IPreviewTrackOwner Owner { get; private set; }
private readonly BeatmapSetInfo beatmapSetInfo; private readonly IBeatmapSetInfo beatmapSetInfo;
private readonly ITrackStore trackManager; private readonly ITrackStore trackManager;
public TrackManagerPreviewTrack(BeatmapSetInfo beatmapSetInfo, ITrackStore trackManager) public TrackManagerPreviewTrack(IBeatmapSetInfo beatmapSetInfo, ITrackStore trackManager)
{ {
this.beatmapSetInfo = beatmapSetInfo; this.beatmapSetInfo = beatmapSetInfo;
this.trackManager = trackManager; this.trackManager = trackManager;
@ -114,7 +114,7 @@ namespace osu.Game.Audio
Logger.Log($"A {nameof(PreviewTrack)} was created without a containing {nameof(IPreviewTrackOwner)}. An owner should be added for correct behaviour."); Logger.Log($"A {nameof(PreviewTrack)} was created without a containing {nameof(IPreviewTrackOwner)}. An owner should be added for correct behaviour.");
} }
protected override Track GetTrack() => trackManager.Get($"https://b.ppy.sh/preview/{beatmapSetInfo?.OnlineBeatmapSetID}.mp3"); protected override Track GetTrack() => trackManager.Get($"https://b.ppy.sh/preview/{beatmapSetInfo.OnlineID}.mp3");
} }
private class PreviewTrackStore : AudioCollectionManager<AdjustableAudioComponent>, ITrackStore private class PreviewTrackStore : AudioCollectionManager<AdjustableAudioComponent>, ITrackStore

View File

@ -9,7 +9,7 @@ namespace osu.Game.Beatmaps
/// <summary> /// <summary>
/// Beatmap metrics based on accumulated online data from community plays. /// Beatmap metrics based on accumulated online data from community plays.
/// </summary> /// </summary>
public class BeatmapMetrics public class APIFailTimes
{ {
/// <summary> /// <summary>
/// Points of failure on a relative time scale (usually 0..100). /// Points of failure on a relative time scale (usually 0..100).

View File

@ -9,6 +9,7 @@ using System.Linq;
using Newtonsoft.Json; using Newtonsoft.Json;
using osu.Framework.Testing; using osu.Framework.Testing;
using osu.Game.Database; using osu.Game.Database;
using osu.Game.Online.API.Requests.Responses;
using osu.Game.Rulesets; using osu.Game.Rulesets;
using osu.Game.Scoring; using osu.Game.Scoring;
@ -16,7 +17,7 @@ namespace osu.Game.Beatmaps
{ {
[ExcludeFromDynamicCompile] [ExcludeFromDynamicCompile]
[Serializable] [Serializable]
public class BeatmapInfo : IEquatable<BeatmapInfo>, IHasPrimaryKey, IBeatmapInfo public class BeatmapInfo : IEquatable<BeatmapInfo>, IHasPrimaryKey, IBeatmapInfo, IBeatmapOnlineInfo
{ {
public int ID { get; set; } public int ID { get; set; }
@ -47,10 +48,7 @@ namespace osu.Game.Beatmaps
public BeatmapDifficulty BaseDifficulty { get; set; } public BeatmapDifficulty BaseDifficulty { get; set; }
[NotMapped] [NotMapped]
public BeatmapMetrics Metrics { get; set; } public APIBeatmap OnlineInfo { get; set; }
[NotMapped]
public BeatmapOnlineInfo OnlineInfo { get; set; }
[NotMapped] [NotMapped]
public int? MaxCombo { get; set; } public int? MaxCombo { get; set; }
@ -184,13 +182,43 @@ namespace osu.Game.Beatmaps
#region Implementation of IBeatmapInfo #region Implementation of IBeatmapInfo
[JsonIgnore]
string IBeatmapInfo.DifficultyName => Version; string IBeatmapInfo.DifficultyName => Version;
[JsonIgnore]
IBeatmapMetadataInfo IBeatmapInfo.Metadata => Metadata; IBeatmapMetadataInfo IBeatmapInfo.Metadata => Metadata;
[JsonIgnore]
IBeatmapDifficultyInfo IBeatmapInfo.Difficulty => BaseDifficulty; IBeatmapDifficultyInfo IBeatmapInfo.Difficulty => BaseDifficulty;
[JsonIgnore]
IBeatmapSetInfo IBeatmapInfo.BeatmapSet => BeatmapSet; IBeatmapSetInfo IBeatmapInfo.BeatmapSet => BeatmapSet;
[JsonIgnore]
IRulesetInfo IBeatmapInfo.Ruleset => Ruleset; IRulesetInfo IBeatmapInfo.Ruleset => Ruleset;
[JsonIgnore]
double IBeatmapInfo.StarRating => StarDifficulty; double IBeatmapInfo.StarRating => StarDifficulty;
#endregion #endregion
#region Implementation of IBeatmapOnlineInfo
[JsonIgnore]
public int CircleCount => OnlineInfo.CircleCount;
[JsonIgnore]
public int SliderCount => OnlineInfo.SliderCount;
[JsonIgnore]
public int PlayCount => OnlineInfo.PlayCount;
[JsonIgnore]
public int PassCount => OnlineInfo.PassCount;
[JsonIgnore]
public APIFailTimes FailTimes => OnlineInfo.FailTimes;
#endregion
} }
} }

View File

@ -38,9 +38,6 @@ namespace osu.Game.Beatmaps
[NotMapped] [NotMapped]
public APIBeatmapSet OnlineInfo { get; set; } public APIBeatmapSet OnlineInfo { get; set; }
[NotMapped]
public BeatmapSetMetrics Metrics { get; set; }
/// <summary> /// <summary>
/// The maximum star difficulty of all beatmaps in this set. /// The maximum star difficulty of all beatmaps in this set.
/// </summary> /// </summary>
@ -172,6 +169,10 @@ namespace osu.Game.Beatmaps
[JsonIgnore] [JsonIgnore]
public int? TrackId => OnlineInfo?.TrackId; public int? TrackId => OnlineInfo?.TrackId;
[NotMapped]
[JsonIgnore]
public int[] Ratings => OnlineInfo?.Ratings;
#endregion #endregion
} }
} }

View File

@ -1,17 +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;
using Newtonsoft.Json;
namespace osu.Game.Beatmaps
{
public class BeatmapSetMetrics
{
/// <summary>
/// Total vote counts of user ratings on a scale of 0..10 where 0 is unused (probably will be fixed at API?).
/// </summary>
[JsonProperty("ratings")]
public int[] Ratings { get; set; } = Array.Empty<int>();
}
}

View File

@ -460,7 +460,7 @@ namespace osu.Game.Beatmaps.Formats
var curveData = pathData as IHasPathWithRepeats; var curveData = pathData as IHasPathWithRepeats;
writer.Write(FormattableString.Invariant($"{(curveData?.RepeatCount ?? 0) + 1},")); writer.Write(FormattableString.Invariant($"{(curveData?.RepeatCount ?? 0) + 1},"));
writer.Write(FormattableString.Invariant($"{pathData.Path.Distance},")); writer.Write(FormattableString.Invariant($"{pathData.Path.ExpectedDistance.Value ?? pathData.Path.Distance},"));
if (curveData != null) if (curveData != null)
{ {

View File

@ -1,31 +1,40 @@
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence. // Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
// See the LICENCE file in the repository root for full licence text. // See the LICENCE file in the repository root for full licence text.
#nullable enable
namespace osu.Game.Beatmaps namespace osu.Game.Beatmaps
{ {
/// <summary> /// <summary>
/// Beatmap info retrieved for previewing locally without having the beatmap downloaded. /// Beatmap info retrieved for previewing locally.
/// </summary> /// </summary>
public class BeatmapOnlineInfo public interface IBeatmapOnlineInfo
{ {
/// <summary>
/// The max combo of this beatmap.
/// </summary>
int? MaxCombo { get; }
/// <summary> /// <summary>
/// The amount of circles in this beatmap. /// The amount of circles in this beatmap.
/// </summary> /// </summary>
public int CircleCount { get; set; } public int CircleCount { get; }
/// <summary> /// <summary>
/// The amount of sliders in this beatmap. /// The amount of sliders in this beatmap.
/// </summary> /// </summary>
public int SliderCount { get; set; } public int SliderCount { get; }
/// <summary> /// <summary>
/// The amount of plays this beatmap has. /// The amount of plays this beatmap has.
/// </summary> /// </summary>
public int PlayCount { get; set; } public int PlayCount { get; }
/// <summary> /// <summary>
/// The amount of passes this beatmap has. /// The amount of passes this beatmap has.
/// </summary> /// </summary>
public int PassCount { get; set; } public int PassCount { get; }
APIFailTimes? FailTimes { get; }
} }
} }

View File

@ -97,5 +97,10 @@ namespace osu.Game.Beatmaps
/// Non-null only if the track is linked to a featured artist track entry. /// Non-null only if the track is linked to a featured artist track entry.
/// </summary> /// </summary>
int? TrackId { get; } int? TrackId { get; }
/// <summary>
/// Total vote counts of user ratings on a scale of 0..10 where 0 is unused (probably will be fixed at API?).
/// </summary>
int[]? Ratings { get; }
} }
} }

View File

@ -462,10 +462,12 @@ namespace osu.Game.Database
if (retrievedItem == null) if (retrievedItem == null)
throw new ArgumentException(@"Specified model could not be found", nameof(item)); throw new ArgumentException(@"Specified model could not be found", nameof(item));
using (var outputStream = exportStorage.GetStream($"{getValidFilename(item.ToString())}{HandledExtensions.First()}", FileAccess.Write, FileMode.Create)) string filename = $"{getValidFilename(item.ToString())}{HandledExtensions.First()}";
ExportModelTo(retrievedItem, outputStream);
exportStorage.OpenInNativeExplorer(); using (var stream = exportStorage.GetStream(filename, FileAccess.Write, FileMode.Create))
ExportModelTo(retrievedItem, stream);
exportStorage.PresentFileExternally(filename);
} }
/// <summary> /// <summary>

View File

@ -109,40 +109,42 @@ namespace osu.Game.Graphics
if (Interlocked.Decrement(ref screenShotTasks) == 0 && cursorVisibility.Value == false) if (Interlocked.Decrement(ref screenShotTasks) == 0 && cursorVisibility.Value == false)
cursorVisibility.Value = true; cursorVisibility.Value = true;
var fileName = getFileName(); string filename = getFilename();
if (fileName == null) return;
var stream = storage.GetStream(fileName, FileAccess.Write); if (filename == null) return;
switch (screenshotFormat.Value) using (var stream = storage.GetStream(filename, FileAccess.Write))
{ {
case ScreenshotFormat.Png: switch (screenshotFormat.Value)
await image.SaveAsPngAsync(stream).ConfigureAwait(false); {
break; case ScreenshotFormat.Png:
await image.SaveAsPngAsync(stream).ConfigureAwait(false);
break;
case ScreenshotFormat.Jpg: case ScreenshotFormat.Jpg:
const int jpeg_quality = 92; const int jpeg_quality = 92;
await image.SaveAsJpegAsync(stream, new JpegEncoder { Quality = jpeg_quality }).ConfigureAwait(false); await image.SaveAsJpegAsync(stream, new JpegEncoder { Quality = jpeg_quality }).ConfigureAwait(false);
break; break;
default: default:
throw new InvalidOperationException($"Unknown enum member {nameof(ScreenshotFormat)} {screenshotFormat.Value}."); throw new InvalidOperationException($"Unknown enum member {nameof(ScreenshotFormat)} {screenshotFormat.Value}.");
}
} }
notificationOverlay.Post(new SimpleNotification notificationOverlay.Post(new SimpleNotification
{ {
Text = $"{fileName} saved!", Text = $"{filename} saved!",
Activated = () => Activated = () =>
{ {
storage.OpenInNativeExplorer(); storage.PresentFileExternally(filename);
return true; return true;
} }
}); });
} }
}); });
private string getFileName() private string getFilename()
{ {
var dt = DateTime.Now; var dt = DateTime.Now;
var fileExt = screenshotFormat.ToString().ToLowerInvariant(); var fileExt = screenshotFormat.ToString().ToLowerInvariant();

View File

@ -70,7 +70,9 @@ namespace osu.Game.IO
public override Stream GetStream(string path, FileAccess access = FileAccess.Read, FileMode mode = FileMode.OpenOrCreate) => public override Stream GetStream(string path, FileAccess access = FileAccess.Read, FileMode mode = FileMode.OpenOrCreate) =>
UnderlyingStorage.GetStream(MutatePath(path), access, mode); UnderlyingStorage.GetStream(MutatePath(path), access, mode);
public override void OpenPathInNativeExplorer(string path) => UnderlyingStorage.OpenPathInNativeExplorer(MutatePath(path)); public override void OpenFileExternally(string filename) => UnderlyingStorage.OpenFileExternally(MutatePath(filename));
public override void PresentFileExternally(string filename) => UnderlyingStorage.PresentFileExternally(MutatePath(filename));
public override Storage GetStorageForDirectory(string path) public override Storage GetStorageForDirectory(string path)
{ {

View File

@ -1,20 +1,38 @@
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence. // Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
// See the LICENCE file in the repository root for full licence text. // See the LICENCE file in the repository root for full licence text.
using osu.Framework.IO.Network;
using osu.Game.Beatmaps; using osu.Game.Beatmaps;
using osu.Game.Online.API.Requests.Responses; using osu.Game.Online.API.Requests.Responses;
#nullable enable
namespace osu.Game.Online.API.Requests namespace osu.Game.Online.API.Requests
{ {
public class GetBeatmapRequest : APIRequest<APIBeatmap> public class GetBeatmapRequest : APIRequest<APIBeatmap>
{ {
private readonly BeatmapInfo beatmapInfo; private readonly IBeatmapInfo beatmapInfo;
public GetBeatmapRequest(BeatmapInfo beatmapInfo) private readonly string filename;
public GetBeatmapRequest(IBeatmapInfo beatmapInfo)
{ {
this.beatmapInfo = beatmapInfo; this.beatmapInfo = beatmapInfo;
filename = (beatmapInfo as BeatmapInfo)?.Path ?? string.Empty;
} }
protected override string Target => $@"beatmaps/lookup?id={beatmapInfo.OnlineBeatmapID}&checksum={beatmapInfo.MD5Hash}&filename={System.Uri.EscapeUriString(beatmapInfo.Path ?? string.Empty)}"; protected override WebRequest CreateWebRequest()
{
var request = base.CreateWebRequest();
request.AddParameter(@"id", beatmapInfo.OnlineID.ToString());
request.AddParameter(@"checksum", beatmapInfo.MD5Hash);
request.AddParameter(@"filename", filename);
return request;
}
protected override string Target => @"beatmaps/lookup";
} }
} }

View File

@ -10,7 +10,7 @@ using osu.Game.Rulesets;
namespace osu.Game.Online.API.Requests.Responses namespace osu.Game.Online.API.Requests.Responses
{ {
public class APIBeatmap : IBeatmapInfo public class APIBeatmap : IBeatmapInfo, IBeatmapOnlineInfo
{ {
[JsonProperty(@"id")] [JsonProperty(@"id")]
public int OnlineID { get; set; } public int OnlineID { get; set; }
@ -31,10 +31,10 @@ namespace osu.Game.Online.API.Requests.Responses
public APIBeatmapSet? BeatmapSet { get; set; } public APIBeatmapSet? BeatmapSet { get; set; }
[JsonProperty(@"playcount")] [JsonProperty(@"playcount")]
private int playCount { get; set; } public int PlayCount { get; set; }
[JsonProperty(@"passcount")] [JsonProperty(@"passcount")]
private int passCount { get; set; } public int PassCount { get; set; }
[JsonProperty(@"mode_int")] [JsonProperty(@"mode_int")]
public int RulesetID { get; set; } public int RulesetID { get; set; }
@ -60,19 +60,21 @@ namespace osu.Game.Online.API.Requests.Responses
private double lengthInSeconds { get; set; } private double lengthInSeconds { get; set; }
[JsonProperty(@"count_circles")] [JsonProperty(@"count_circles")]
private int circleCount { get; set; } public int CircleCount { get; set; }
[JsonProperty(@"count_sliders")] [JsonProperty(@"count_sliders")]
private int sliderCount { get; set; } public int SliderCount { get; set; }
[JsonProperty(@"version")] [JsonProperty(@"version")]
public string DifficultyName { get; set; } = string.Empty; public string DifficultyName { get; set; } = string.Empty;
[JsonProperty(@"failtimes")] [JsonProperty(@"failtimes")]
private BeatmapMetrics? metrics { get; set; } public APIFailTimes? FailTimes { get; set; }
[JsonProperty(@"max_combo")] [JsonProperty(@"max_combo")]
private int? maxCombo { get; set; } public int? MaxCombo { get; set; }
public double BPM { get; set; }
public virtual BeatmapInfo ToBeatmapInfo(RulesetStore rulesets) public virtual BeatmapInfo ToBeatmapInfo(RulesetStore rulesets)
{ {
@ -90,8 +92,7 @@ namespace osu.Game.Online.API.Requests.Responses
Status = Status, Status = Status,
MD5Hash = Checksum, MD5Hash = Checksum,
BeatmapSet = set, BeatmapSet = set,
Metrics = metrics, MaxCombo = MaxCombo,
MaxCombo = maxCombo,
BaseDifficulty = new BeatmapDifficulty BaseDifficulty = new BeatmapDifficulty
{ {
DrainRate = drainRate, DrainRate = drainRate,
@ -99,13 +100,7 @@ namespace osu.Game.Online.API.Requests.Responses
ApproachRate = approachRate, ApproachRate = approachRate,
OverallDifficulty = overallDifficulty, OverallDifficulty = overallDifficulty,
}, },
OnlineInfo = new BeatmapOnlineInfo OnlineInfo = this,
{
PlayCount = playCount,
PassCount = passCount,
CircleCount = circleCount,
SliderCount = sliderCount,
},
}; };
} }
@ -127,7 +122,7 @@ namespace osu.Game.Online.API.Requests.Responses
public IRulesetInfo Ruleset => new RulesetInfo { ID = RulesetID }; public IRulesetInfo Ruleset => new RulesetInfo { ID = RulesetID };
public double BPM => throw new NotImplementedException(); [JsonIgnore]
public string Hash => throw new NotImplementedException(); public string Hash => throw new NotImplementedException();
#endregion #endregion

View File

@ -58,8 +58,8 @@ namespace osu.Game.Online.API.Requests.Responses
[JsonProperty(@"last_updated")] [JsonProperty(@"last_updated")]
public DateTimeOffset? LastUpdated { get; set; } public DateTimeOffset? LastUpdated { get; set; }
[JsonProperty(@"ratings")] [JsonProperty("ratings")]
private int[] ratings { get; set; } = Array.Empty<int>(); public int[] Ratings { get; set; } = Array.Empty<int>();
[JsonProperty(@"track_id")] [JsonProperty(@"track_id")]
public int? TrackId { get; set; } public int? TrackId { get; set; }
@ -119,7 +119,7 @@ namespace osu.Game.Online.API.Requests.Responses
public string Tags { get; set; } = string.Empty; public string Tags { get; set; } = string.Empty;
[JsonProperty(@"beatmaps")] [JsonProperty(@"beatmaps")]
private IEnumerable<APIBeatmap> beatmaps { get; set; } = Array.Empty<APIBeatmap>(); public IEnumerable<APIBeatmap> Beatmaps { get; set; } = Array.Empty<APIBeatmap>();
public virtual BeatmapSetInfo ToBeatmapSet(RulesetStore rulesets) public virtual BeatmapSetInfo ToBeatmapSet(RulesetStore rulesets)
{ {
@ -128,11 +128,10 @@ namespace osu.Game.Online.API.Requests.Responses
OnlineBeatmapSetID = OnlineID, OnlineBeatmapSetID = OnlineID,
Metadata = metadata, Metadata = metadata,
Status = Status, Status = Status,
Metrics = new BeatmapSetMetrics { Ratings = ratings },
OnlineInfo = this OnlineInfo = this
}; };
beatmapSet.Beatmaps = beatmaps.Select(b => beatmapSet.Beatmaps = Beatmaps.Select(b =>
{ {
var beatmap = b.ToBeatmapInfo(rulesets); var beatmap = b.ToBeatmapInfo(rulesets);
beatmap.BeatmapSet = beatmapSet; beatmap.BeatmapSet = beatmapSet;
@ -157,7 +156,7 @@ namespace osu.Game.Online.API.Requests.Responses
#region Implementation of IBeatmapSetInfo #region Implementation of IBeatmapSetInfo
IEnumerable<IBeatmapInfo> IBeatmapSetInfo.Beatmaps => beatmaps; IEnumerable<IBeatmapInfo> IBeatmapSetInfo.Beatmaps => Beatmaps;
IBeatmapMetadataInfo IBeatmapSetInfo.Metadata => metadata; IBeatmapMetadataInfo IBeatmapSetInfo.Metadata => metadata;

View File

@ -913,13 +913,15 @@ namespace osu.Game
} }
else if (recentLogCount == short_term_display_limit) else if (recentLogCount == short_term_display_limit)
{ {
var logFile = $@"{entry.Target.ToString().ToLowerInvariant()}.log";
Schedule(() => Notifications.Post(new SimpleNotification Schedule(() => Notifications.Post(new SimpleNotification
{ {
Icon = FontAwesome.Solid.EllipsisH, Icon = FontAwesome.Solid.EllipsisH,
Text = "Subsequent messages have been logged. Click to view log files.", Text = "Subsequent messages have been logged. Click to view log files.",
Activated = () => Activated = () =>
{ {
Storage.GetStorageForDirectory("logs").OpenInNativeExplorer(); Storage.GetStorageForDirectory(@"logs").PresentFileExternally(logFile);
return true; return true;
} }
})); }));

View File

@ -52,7 +52,7 @@ namespace osu.Game.Overlays.BeatmapSet
private void updateDisplay() private void updateDisplay()
{ {
Ratings.Metrics = BeatmapSet?.Metrics; Ratings.Ratings = BeatmapSet?.Ratings;
ratingBox.Alpha = BeatmapSet?.OnlineInfo?.Status > 0 ? 1 : 0; ratingBox.Alpha = BeatmapSet?.OnlineInfo?.Status > 0 ? 1 : 0;
} }

View File

@ -48,7 +48,7 @@ namespace osu.Game.Overlays.BeatmapSet
successRate.Length = rate; successRate.Length = rate;
percentContainer.ResizeWidthTo(successRate.Length, 250, Easing.InOutCubic); percentContainer.ResizeWidthTo(successRate.Length, 250, Easing.InOutCubic);
Graph.Metrics = beatmapInfo?.Metrics; Graph.FailTimes = beatmapInfo?.FailTimes;
} }
public SuccessRate() public SuccessRate()

View File

@ -67,7 +67,7 @@ namespace osu.Game.Overlays.Settings.Sections.General
Add(new SettingsButton Add(new SettingsButton
{ {
Text = GeneralSettingsStrings.OpenOsuFolder, Text = GeneralSettingsStrings.OpenOsuFolder,
Action = storage.OpenInNativeExplorer, Action = storage.PresentExternally,
}); });
Add(new SettingsButton Add(new SettingsButton

View File

@ -119,6 +119,8 @@ namespace osu.Game.Rulesets.Objects
DifficultyControlPoint = (DifficultyControlPoint)legacyInfo.DifficultyPointAt(StartTime).DeepClone(); DifficultyControlPoint = (DifficultyControlPoint)legacyInfo.DifficultyPointAt(StartTime).DeepClone();
DifficultyControlPoint.Time = StartTime; DifficultyControlPoint.Time = StartTime;
} }
else if (DifficultyControlPoint == DifficultyControlPoint.DEFAULT)
DifficultyControlPoint = new DifficultyControlPoint();
ApplyDefaultsToSelf(controlPointInfo, difficulty); ApplyDefaultsToSelf(controlPointInfo, difficulty);
@ -128,6 +130,8 @@ namespace osu.Game.Rulesets.Objects
SampleControlPoint = (SampleControlPoint)legacyInfo.SamplePointAt(this.GetEndTime() + control_point_leniency).DeepClone(); SampleControlPoint = (SampleControlPoint)legacyInfo.SamplePointAt(this.GetEndTime() + control_point_leniency).DeepClone();
SampleControlPoint.Time = this.GetEndTime() + control_point_leniency; SampleControlPoint.Time = this.GetEndTime() + control_point_leniency;
} }
else if (SampleControlPoint == SampleControlPoint.DEFAULT)
SampleControlPoint = new SampleControlPoint();
nestedHitObjects.Clear(); nestedHitObjects.Clear();

View File

@ -280,6 +280,13 @@ namespace osu.Game.Rulesets.Objects
if (ExpectedDistance.Value is double expectedDistance && calculatedLength != expectedDistance) if (ExpectedDistance.Value is double expectedDistance && calculatedLength != expectedDistance)
{ {
// In osu-stable, if the last two control points of a slider are equal, extension is not performed.
if (ControlPoints.Count >= 2 && ControlPoints[^1].Position == ControlPoints[^2].Position && expectedDistance > calculatedLength)
{
cumulativeLength.Add(calculatedLength);
return;
}
// The last length is always incorrect // The last length is always incorrect
cumulativeLength.RemoveAt(cumulativeLength.Count - 1); cumulativeLength.RemoveAt(cumulativeLength.Count - 1);

View File

@ -19,7 +19,7 @@ namespace osu.Game.Rulesets.Objects
public static void Reverse(this SliderPath sliderPath, out Vector2 positionalOffset) public static void Reverse(this SliderPath sliderPath, out Vector2 positionalOffset)
{ {
var points = sliderPath.ControlPoints.ToArray(); var points = sliderPath.ControlPoints.ToArray();
positionalOffset = points.Last().Position; positionalOffset = sliderPath.PositionAt(1);
sliderPath.ControlPoints.Clear(); sliderPath.ControlPoints.Clear();
@ -32,7 +32,10 @@ namespace osu.Game.Rulesets.Objects
// propagate types forwards to last null type // propagate types forwards to last null type
if (i == points.Length - 1) if (i == points.Length - 1)
{
p.Type = lastType; p.Type = lastType;
p.Position = Vector2.Zero;
}
else if (p.Type != null) else if (p.Type != null)
(p.Type, lastType) = (lastType, p.Type); (p.Type, lastType) = (lastType, p.Type);

View File

@ -75,6 +75,15 @@ namespace osu.Game.Screens.OnlinePlay.Multiplayer
{ {
switch (e.Action) switch (e.Action)
{ {
case GlobalAction.Back:
if (Textbox.HasFocus)
{
Schedule(() => Textbox.KillFocus());
return true;
}
break;
case GlobalAction.ToggleChatFocus: case GlobalAction.ToggleChatFocus:
if (Textbox.HasFocus) if (Textbox.HasFocus)
{ {

View File

@ -29,7 +29,7 @@ namespace osu.Game.Screens.Select
private const float transition_duration = 250; private const float transition_duration = 250;
private readonly AdvancedStats advanced; private readonly AdvancedStats advanced;
private readonly UserRatings ratings; private readonly UserRatings ratingsDisplay;
private readonly MetadataSection description, source, tags; private readonly MetadataSection description, source, tags;
private readonly Container failRetryContainer; private readonly Container failRetryContainer;
private readonly FailRetryGraph failRetryGraph; private readonly FailRetryGraph failRetryGraph;
@ -43,6 +43,10 @@ namespace osu.Game.Screens.Select
private BeatmapInfo beatmapInfo; private BeatmapInfo beatmapInfo;
private APIFailTimes failTimes;
private int[] ratings;
public BeatmapInfo BeatmapInfo public BeatmapInfo BeatmapInfo
{ {
get => beatmapInfo; get => beatmapInfo;
@ -52,6 +56,9 @@ namespace osu.Game.Screens.Select
beatmapInfo = value; beatmapInfo = value;
failTimes = beatmapInfo?.OnlineInfo?.FailTimes;
ratings = beatmapInfo?.BeatmapSet?.Ratings;
Scheduler.AddOnce(updateStatistics); Scheduler.AddOnce(updateStatistics);
} }
} }
@ -110,7 +117,7 @@ namespace osu.Game.Screens.Select
RelativeSizeAxes = Axes.X, RelativeSizeAxes = Axes.X,
Height = 134, Height = 134,
Padding = new MarginPadding { Horizontal = spacing, Top = spacing }, Padding = new MarginPadding { Horizontal = spacing, Top = spacing },
Child = ratings = new UserRatings Child = ratingsDisplay = new UserRatings
{ {
RelativeSizeAxes = Axes.Both, RelativeSizeAxes = Axes.Both,
}, },
@ -176,7 +183,7 @@ namespace osu.Game.Screens.Select
tags.Text = BeatmapInfo?.Metadata?.Tags; tags.Text = BeatmapInfo?.Metadata?.Tags;
// metrics may have been previously fetched // metrics may have been previously fetched
if (BeatmapInfo?.BeatmapSet?.Metrics != null && BeatmapInfo?.Metrics != null) if (ratings != null && failTimes != null)
{ {
updateMetrics(); updateMetrics();
return; return;
@ -201,14 +208,8 @@ namespace osu.Game.Screens.Select
// the beatmap has been changed since we started the lookup. // the beatmap has been changed since we started the lookup.
return; return;
var b = res.ToBeatmapInfo(rulesets); ratings = res.BeatmapSet?.Ratings;
failTimes = res.FailTimes;
if (requestedBeatmap.BeatmapSet == null)
requestedBeatmap.BeatmapSet = b.BeatmapSet;
else
requestedBeatmap.BeatmapSet.Metrics = b.BeatmapSet.Metrics;
requestedBeatmap.Metrics = b.Metrics;
updateMetrics(); updateMetrics();
}); });
@ -232,29 +233,28 @@ namespace osu.Game.Screens.Select
private void updateMetrics() private void updateMetrics()
{ {
var hasRatings = beatmapInfo?.BeatmapSet?.Metrics?.Ratings?.Any() ?? false; var hasMetrics = (failTimes?.Retries?.Any() ?? false) || (failTimes?.Fails?.Any() ?? false);
var hasRetriesFails = (beatmapInfo?.Metrics?.Retries?.Any() ?? false) || (beatmapInfo?.Metrics?.Fails?.Any() ?? false);
if (hasRatings) if (ratings?.Any() ?? false)
{ {
ratings.Metrics = beatmapInfo.BeatmapSet.Metrics; ratingsDisplay.Ratings = ratings;
ratings.FadeIn(transition_duration); ratingsDisplay.FadeIn(transition_duration);
} }
else else
{ {
// loading or just has no data server-side. // loading or just has no data server-side.
ratings.Metrics = new BeatmapSetMetrics { Ratings = new int[10] }; ratingsDisplay.Ratings = new int[10];
ratings.FadeTo(0.25f, transition_duration); ratingsDisplay.FadeTo(0.25f, transition_duration);
} }
if (hasRetriesFails) if (hasMetrics)
{ {
failRetryGraph.Metrics = beatmapInfo.Metrics; failRetryGraph.FailTimes = failTimes;
failRetryContainer.FadeIn(transition_duration); failRetryContainer.FadeIn(transition_duration);
} }
else else
{ {
failRetryGraph.Metrics = new BeatmapMetrics failRetryGraph.FailTimes = new APIFailTimes
{ {
Fails = new int[100], Fails = new int[100],
Retries = new int[100], Retries = new int[100],

View File

@ -16,19 +16,19 @@ namespace osu.Game.Screens.Select.Details
{ {
private readonly BarGraph retryGraph, failGraph; private readonly BarGraph retryGraph, failGraph;
private BeatmapMetrics metrics; private APIFailTimes failTimes;
public BeatmapMetrics Metrics public APIFailTimes FailTimes
{ {
get => metrics; get => failTimes;
set set
{ {
if (value == metrics) return; if (value == failTimes) return;
metrics = value; failTimes = value;
var retries = Metrics?.Retries ?? Array.Empty<int>(); var retries = FailTimes?.Retries ?? Array.Empty<int>();
var fails = Metrics?.Fails ?? Array.Empty<int>(); var fails = FailTimes?.Fails ?? Array.Empty<int>();
var retriesAndFails = sumRetriesAndFails(retries, fails); var retriesAndFails = sumRetriesAndFails(retries, fails);
float maxValue = retriesAndFails.Any() ? retriesAndFails.Max() : 0; float maxValue = retriesAndFails.Any() ? retriesAndFails.Max() : 0;

View File

@ -1,15 +1,14 @@
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence. // Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
// See the LICENCE file in the repository root for full licence text. // See the LICENCE file in the repository root for full licence text.
using System.Linq;
using osu.Framework.Allocation; using osu.Framework.Allocation;
using osu.Framework.Extensions.LocalisationExtensions;
using osu.Framework.Graphics; using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers; using osu.Framework.Graphics.Containers;
using osu.Game.Graphics; using osu.Game.Graphics;
using osu.Game.Graphics.Sprites; using osu.Game.Graphics.Sprites;
using osu.Game.Graphics.UserInterface; using osu.Game.Graphics.UserInterface;
using System.Linq;
using osu.Framework.Extensions.LocalisationExtensions;
using osu.Game.Beatmaps;
using osu.Game.Resources.Localisation.Web; using osu.Game.Resources.Localisation.Web;
namespace osu.Game.Screens.Select.Details namespace osu.Game.Screens.Select.Details
@ -22,20 +21,20 @@ namespace osu.Game.Screens.Select.Details
private readonly Container graphContainer; private readonly Container graphContainer;
private readonly BarGraph graph; private readonly BarGraph graph;
private BeatmapSetMetrics metrics; private int[] ratings;
public BeatmapSetMetrics Metrics public int[] Ratings
{ {
get => metrics; get => ratings;
set set
{ {
if (value == metrics) return; if (value == ratings) return;
metrics = value; ratings = value;
const int rating_range = 10; const int rating_range = 10;
if (metrics == null) if (ratings == null)
{ {
negativeRatings.Text = 0.ToLocalisableString(@"N0"); negativeRatings.Text = 0.ToLocalisableString(@"N0");
positiveRatings.Text = 0.ToLocalisableString(@"N0"); positiveRatings.Text = 0.ToLocalisableString(@"N0");
@ -44,15 +43,15 @@ namespace osu.Game.Screens.Select.Details
} }
else else
{ {
var ratings = Metrics.Ratings.Skip(1).Take(rating_range); // adjust for API returning weird empty data at 0. var usableRange = Ratings.Skip(1).Take(rating_range); // adjust for API returning weird empty data at 0.
var negativeCount = ratings.Take(rating_range / 2).Sum(); var negativeCount = usableRange.Take(rating_range / 2).Sum();
var totalCount = ratings.Sum(); var totalCount = usableRange.Sum();
negativeRatings.Text = negativeCount.ToLocalisableString(@"N0"); negativeRatings.Text = negativeCount.ToLocalisableString(@"N0");
positiveRatings.Text = (totalCount - negativeCount).ToLocalisableString(@"N0"); positiveRatings.Text = (totalCount - negativeCount).ToLocalisableString(@"N0");
ratingsBar.Length = totalCount == 0 ? 0 : (float)negativeCount / totalCount; ratingsBar.Length = totalCount == 0 ? 0 : (float)negativeCount / totalCount;
graph.Values = ratings.Take(rating_range).Select(r => (float)r); graph.Values = usableRange.Take(rating_range).Select(r => (float)r);
} }
} }
} }

View File

@ -32,7 +32,7 @@ namespace osu.Game.Tests.Beatmaps
BeatmapInfo.BeatmapSet.Metadata = BeatmapInfo.Metadata; BeatmapInfo.BeatmapSet.Metadata = BeatmapInfo.Metadata;
BeatmapInfo.BeatmapSet.Beatmaps = new List<BeatmapInfo> { BeatmapInfo }; BeatmapInfo.BeatmapSet.Beatmaps = new List<BeatmapInfo> { BeatmapInfo };
BeatmapInfo.Length = 75000; BeatmapInfo.Length = 75000;
BeatmapInfo.OnlineInfo = new BeatmapOnlineInfo(); BeatmapInfo.OnlineInfo = new APIBeatmap();
BeatmapInfo.BeatmapSet.OnlineInfo = new APIBeatmapSet BeatmapInfo.BeatmapSet.OnlineInfo = new APIBeatmapSet
{ {
Status = BeatmapSetOnlineStatus.Ranked, Status = BeatmapSetOnlineStatus.Ranked,

View File

@ -20,6 +20,7 @@ using osu.Framework.Timing;
using osu.Game.Beatmaps; using osu.Game.Beatmaps;
using osu.Game.Database; using osu.Game.Database;
using osu.Game.Online.API; using osu.Game.Online.API;
using osu.Game.Online.API.Requests.Responses;
using osu.Game.Overlays; using osu.Game.Overlays;
using osu.Game.Rulesets; using osu.Game.Rulesets;
using osu.Game.Rulesets.Mods; using osu.Game.Rulesets.Mods;
@ -174,6 +175,56 @@ namespace osu.Game.Tests.Visual
protected virtual IBeatmap CreateBeatmap(RulesetInfo ruleset) => new TestBeatmap(ruleset); protected virtual IBeatmap CreateBeatmap(RulesetInfo ruleset) => new TestBeatmap(ruleset);
protected APIBeatmapSet CreateAPIBeatmapSet(RulesetInfo ruleset)
{
var beatmap = CreateBeatmap(ruleset).BeatmapInfo;
return new APIBeatmapSet
{
Covers = beatmap.BeatmapSet.Covers,
OnlineID = beatmap.BeatmapSet.OnlineID,
Status = beatmap.BeatmapSet.Status,
Preview = beatmap.BeatmapSet.Preview,
HasFavourited = beatmap.BeatmapSet.HasFavourited,
PlayCount = beatmap.BeatmapSet.PlayCount,
FavouriteCount = beatmap.BeatmapSet.FavouriteCount,
BPM = beatmap.BeatmapSet.BPM,
HasExplicitContent = beatmap.BeatmapSet.HasExplicitContent,
HasVideo = beatmap.BeatmapSet.HasVideo,
HasStoryboard = beatmap.BeatmapSet.HasStoryboard,
Submitted = beatmap.BeatmapSet.Submitted,
Ranked = beatmap.BeatmapSet.Ranked,
LastUpdated = beatmap.BeatmapSet.LastUpdated,
TrackId = beatmap.BeatmapSet.TrackId,
Title = beatmap.BeatmapSet.Metadata.Title,
TitleUnicode = beatmap.BeatmapSet.Metadata.TitleUnicode,
Artist = beatmap.BeatmapSet.Metadata.Artist,
ArtistUnicode = beatmap.BeatmapSet.Metadata.ArtistUnicode,
Author = beatmap.BeatmapSet.Metadata.Author,
AuthorID = beatmap.BeatmapSet.Metadata.AuthorID,
AuthorString = beatmap.BeatmapSet.Metadata.AuthorString,
Availability = beatmap.BeatmapSet.Availability,
Genre = beatmap.BeatmapSet.Genre,
Language = beatmap.BeatmapSet.Language,
Source = beatmap.BeatmapSet.Metadata.Source,
Tags = beatmap.BeatmapSet.Metadata.Tags,
Beatmaps = new[]
{
new APIBeatmap
{
OnlineID = beatmap.OnlineID,
OnlineBeatmapSetID = beatmap.BeatmapSet.OnlineID,
Status = beatmap.Status,
Checksum = beatmap.MD5Hash,
AuthorID = beatmap.Metadata.AuthorID,
RulesetID = beatmap.RulesetID,
StarRating = beatmap.StarDifficulty,
DifficultyName = beatmap.Version,
}
}
};
}
protected WorkingBeatmap CreateWorkingBeatmap(RulesetInfo ruleset) => protected WorkingBeatmap CreateWorkingBeatmap(RulesetInfo ruleset) =>
CreateWorkingBeatmap(CreateBeatmap(ruleset)); CreateWorkingBeatmap(CreateBeatmap(ruleset));

View File

@ -36,8 +36,8 @@
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets> <IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference> </PackageReference>
<PackageReference Include="Realm" Version="10.6.0" /> <PackageReference Include="Realm" Version="10.6.0" />
<PackageReference Include="ppy.osu.Framework" Version="2021.1014.0" /> <PackageReference Include="ppy.osu.Framework" Version="2021.1026.0" />
<PackageReference Include="ppy.osu.Game.Resources" Version="2021.1015.0" /> <PackageReference Include="ppy.osu.Game.Resources" Version="2021.1026.0" />
<PackageReference Include="Sentry" Version="3.9.4" /> <PackageReference Include="Sentry" Version="3.9.4" />
<PackageReference Include="SharpCompress" Version="0.29.0" /> <PackageReference Include="SharpCompress" Version="0.29.0" />
<PackageReference Include="NUnit" Version="3.13.2" /> <PackageReference Include="NUnit" Version="3.13.2" />

View File

@ -70,8 +70,8 @@
<Reference Include="System.Net.Http" /> <Reference Include="System.Net.Http" />
</ItemGroup> </ItemGroup>
<ItemGroup Label="Package References"> <ItemGroup Label="Package References">
<PackageReference Include="ppy.osu.Framework.iOS" Version="2021.1014.0" /> <PackageReference Include="ppy.osu.Framework.iOS" Version="2021.1026.0" />
<PackageReference Include="ppy.osu.Game.Resources" Version="2021.1015.0" /> <PackageReference Include="ppy.osu.Game.Resources" Version="2021.1026.0" />
</ItemGroup> </ItemGroup>
<!-- See https://github.com/dotnet/runtime/issues/35988 (can be removed after Xamarin uses net5.0 / net6.0) --> <!-- See https://github.com/dotnet/runtime/issues/35988 (can be removed after Xamarin uses net5.0 / net6.0) -->
<PropertyGroup> <PropertyGroup>
@ -93,7 +93,7 @@
<PackageReference Include="Microsoft.EntityFrameworkCore.Sqlite" Version="2.2.6" /> <PackageReference Include="Microsoft.EntityFrameworkCore.Sqlite" Version="2.2.6" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Sqlite.Core" Version="2.2.6" /> <PackageReference Include="Microsoft.EntityFrameworkCore.Sqlite.Core" Version="2.2.6" />
<PackageReference Include="Newtonsoft.Json" Version="13.0.1" /> <PackageReference Include="Newtonsoft.Json" Version="13.0.1" />
<PackageReference Include="ppy.osu.Framework" Version="2021.1014.0" /> <PackageReference Include="ppy.osu.Framework" Version="2021.1026.0" />
<PackageReference Include="SharpCompress" Version="0.28.3" /> <PackageReference Include="SharpCompress" Version="0.28.3" />
<PackageReference Include="NUnit" Version="3.13.2" /> <PackageReference Include="NUnit" Version="3.13.2" />
<PackageReference Include="SharpRaven" Version="2.4.0" /> <PackageReference Include="SharpRaven" Version="2.4.0" />