mirror of
https://github.com/ppy/osu
synced 2025-02-06 13:22:14 +00:00
Parse osu-web error text to present invalid items to the user in a more approachable format
This commit is contained in:
parent
e78c5d0858
commit
6f82e6351f
@ -3,6 +3,7 @@
|
|||||||
|
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Specialized;
|
using System.Collections.Specialized;
|
||||||
|
using System.Linq;
|
||||||
using Humanizer;
|
using Humanizer;
|
||||||
using osu.Framework.Allocation;
|
using osu.Framework.Allocation;
|
||||||
using osu.Framework.Graphics;
|
using osu.Framework.Graphics;
|
||||||
@ -349,9 +350,31 @@ namespace osu.Game.Screens.OnlinePlay.Playlists
|
|||||||
|
|
||||||
private void onError(string text)
|
private void onError(string text)
|
||||||
{
|
{
|
||||||
ErrorText.Text = text;
|
// see https://github.com/ppy/osu-web/blob/2c97aaeb64fb4ed97c747d8383a35b30f57428c7/app/Models/Multiplayer/PlaylistItem.php#L48.
|
||||||
ErrorText.FadeIn(50);
|
const string not_found_prefix = "beatmaps not found:";
|
||||||
|
|
||||||
|
if (text.StartsWith(not_found_prefix, StringComparison.Ordinal))
|
||||||
|
{
|
||||||
|
ErrorText.Text = "One or more beatmap was not available online. Please remove or replaced the highlighted items.";
|
||||||
|
|
||||||
|
int[] invalidBeatmapIDs = text
|
||||||
|
.Substring(not_found_prefix.Length + 1)
|
||||||
|
.Split(", ")
|
||||||
|
.Select(int.Parse)
|
||||||
|
.ToArray();
|
||||||
|
|
||||||
|
foreach (var item in Playlist)
|
||||||
|
{
|
||||||
|
if (invalidBeatmapIDs.Contains(item.BeatmapID))
|
||||||
|
item.MarkInvalid();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
ErrorText.Text = text;
|
||||||
|
}
|
||||||
|
|
||||||
|
ErrorText.FadeIn(50);
|
||||||
loadingLayer.Hide();
|
loadingLayer.Hide();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user